diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fb5645e8c44f3032ad0e2fb74e608885dc764aa2..34b1755a4caca433a4cdc62faadff918e2f3bc70 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -18,17 +18,19 @@ variables:
PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm"
TESTCASE_TIMEOUT_STV: 900
TESTCASE_TIMEOUT_LTV: 2400
+ TESTCASE_TIMEOUT_STV_SANITIZERS: 1800
+ GIT_CLEAN_FLAGS: -ffdxq
MANUAL_PIPELINE_TYPE:
description: "Type for the manual pipeline run. Use 'pytest-mld' to run MLD test against reference float codec." # Not implemented yet, but may be good to have a manual pipeline trigger
value: 'default'
options:
- 'default'
- 'pytest-mld'
- - 'pytest-mld-interop'
- 'pytest-mld-long'
- 'pytest-saturation-smoke-test'
- 'evs-26444'
- 'sanitizer-stv'
+ - 'pytest-renderer'
default:
@@ -53,9 +55,6 @@ workflow:
- if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-mld'
variables:
IVAS_PIPELINE_NAME: 'Run MLD tool against float ref: $CI_COMMIT_BRANCH'
- - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-mld-interop'
- variables:
- IVAS_PIPELINE_NAME: 'Run MLD tool agains float ref - interop: $CI_COMMIT_BRANCH'
- if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-mld-long'
variables:
IVAS_PIPELINE_NAME: 'Run MLD tool against float ref (long test vectors): $CI_COMMIT_BRANCH'
@@ -68,6 +67,9 @@ workflow:
- if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'sanitizer-stv'
variables:
IVAS_PIPELINE_NAME: 'Short testvectors sanitizers'
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-renderer'
+ variables:
+ IVAS_PIPELINE_NAME: 'Renderer test: $CI_COMMIT_BRANCH'
- if: $CI_PIPELINE_SOURCE == 'schedule' # Scheduled in any branch
variables:
IVAS_PIPELINE_NAME: 'Scheduled pipeline: $CI_COMMIT_BRANCH'
@@ -172,15 +174,6 @@ stages:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: never
-
-.rules-pytest-mld-interop:
- rules:
- - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-mld-interop"
- - if: $CI_PIPELINE_SOURCE == 'push'
- when: never
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- when: never
-
.rules-pytest-saturation-smoke-test:
rules:
- if: $PYTEST_SMOKE_TEST # Set by scheduled pipeline
@@ -222,6 +215,8 @@ stages:
MLD_ARTIFACT_NAME: "mld--$CI_JOB_NAME-$CI_JOB_ID--sha-$CI_COMMIT_SHORT_SHA.csv"
MERGED_CSV_ARTIFACT_NAME: "$CI_JOB_NAME--merged_csv--$CI_JOB_ID.csv"
PAGES_HTML_ARTIFACT_NAME: "$CI_JOB_NAME-index.html"
+ SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html"
+ IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME"
script:
- *print-common-info
- *update-scripts-repo
@@ -240,10 +235,13 @@ stages:
### run pytest
- exit_code=0
- - python3 -m pytest $TEST_SUITE -v --create_cut --html=report.html --self-contained-html --junit-xml=report-junit.xml --mld --ssnr --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || exit_code=$?
+ - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report.html --self-contained-html --junit-xml=report-junit.xml --mld --ssnr --odg --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || exit_code=$?
- zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true
- - python3 scripts/parse_mld_xml.py report-junit.xml $MLD_ARTIFACT_NAME
+ - python3 scripts/parse_xml_report.py report-junit.xml $MLD_ARTIFACT_NAME
+ - mkdir $IMAGES_ARTIFACT_NAME
+ - for MEASURE in MLD DIFF SSNR;do python3 scripts/create_histogram_summary.py $MLD_ARTIFACT_NAME images_"$CI_JOB_NAME"/summary_"$MEASURE".csv images_"$CI_JOB_NAME"/summary_"$MEASURE".png --measure $MEASURE; done
+ - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_NAME $CI_JOB_ID $CI_JOB_NAME
- if [ $USE_LTV -eq 1 ] && [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]; then
- id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH $CI_JOB_NAME $CI_PROJECT_ID)
@@ -255,7 +253,7 @@ stages:
- python3 ci/basop-pages/create_report_pages.py $PAGES_HTML_ARTIFACT_NAME $MERGED_CSV_ARTIFACT_NAME $MLD_ARTIFACT_NAME $file_previous $CI_JOB_ID $id_previous $CI_JOB_NAME
- else
# create empty file for artifacts to avoid errors
- - touch $CI_JOB_NAME-index.html
+ - touch $PAGES_HTML_ARTIFACT_NAME
- touch $MERGED_CSV_ARTIFACT_NAME
- fi
@@ -276,6 +274,9 @@ stages:
- $PAGES_HTML_ARTIFACT_NAME
- $MLD_ARTIFACT_NAME
- $MERGED_CSV_ARTIFACT_NAME
+ - images
+ - $SUMMARY_HTML_ARTIFACT_NAME
+ - $IMAGES_ARTIFACT_NAME
expose_as: "pytest mld results"
reports:
junit:
@@ -301,8 +302,8 @@ stages:
- make clean
- make -j CLANG=$CLANG_NUM
- if [[ $CLANG_NUM == 3 ]]; then export UBSAN_OPTIONS="suppressions=scripts/ubsan.supp,report_error_type=1"; fi
- - testcase_timeout=$TESTCASE_TIMEOUT_STV
- - python3 -m pytest $SHORT_TEST_SUITE -v --tb=no --update_ref 1 -m create_ref --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout $testcase_timeout --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec
+ - testcase_timeout=$TESTCASE_TIMEOUT_STV_SANITIZERS
+ - python3 -m pytest $SHORT_TEST_SUITE -v --tb=no --update_ref 1 -m create_ref --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
@@ -410,98 +411,94 @@ build-codec-linux-instrumented-make:
# Short test jobs
# ---------------------------------------------------------------
-#ivas-pytest-mld-enc-dec:
-# extends:
-# - .rules-pytest-mld
-# - .test-job-linux
-# before_script:
-# - USE_LTV=0
-# - TEST_SUITE="$SHORT_TEST_SUITE"
-# - LEVEL_SCALING=1.0
-# <<: *ivas-pytest-anchor
-
-ivas-pytest-mld-dec:
+### jobs that test fx encoder -> flt decoder
+ivas-pytest-mld-enc:
extends:
- .rules-pytest-mld
- - .test-job-linux
+ - .test-job-linux
before_script:
- USE_LTV=0
- - DUT_ENCODER_PATH=./IVAS_cod_ref
+ - DUT_DECODER_PATH=./IVAS_dec_ref
- TEST_SUITE="$SHORT_TEST_SUITE"
- LEVEL_SCALING=1.0
<<: *ivas-pytest-anchor
-
-#ivas-pytest-mld-enc-dec-lev-10:
-# extends:
-# - .rules-pytest-mld
-# - .test-job-linux
-# before_script:
-# - USE_LTV=0
-# - TEST_SUITE="$SHORT_TEST_SUITE"
-# - LEVEL_SCALING=0.3162
-# <<: *ivas-pytest-anchor
-
-ivas-pytest-mld-dec-lev-10:
+
+ivas-pytest-mld-enc-lev-10:
extends:
- .rules-pytest-mld
- .test-job-linux
before_script:
- - USE_LTV=0
- - DUT_ENCODER_PATH=./IVAS_cod_ref
+ - USE_LTV=0
+ - DUT_DECODER_PATH=./IVAS_dec_ref
- TEST_SUITE="$SHORT_TEST_SUITE"
- LEVEL_SCALING=0.3162
<<: *ivas-pytest-anchor
-#ivas-pytest-mld-enc-dec-lev+10:
-# extends:
-# - .rules-pytest-mld
-# - .test-job-linux
-# before_script:
-# - USE_LTV=0
-# - TEST_SUITE="$SHORT_TEST_SUITE"
-# - LEVEL_SCALING=3.162
-# <<: *ivas-pytest-anchor
-
-ivas-pytest-mld-dec-lev+10:
+ivas-pytest-mld-enc-lev+10:
extends:
- .rules-pytest-mld
- .test-job-linux
before_script:
- - USE_LTV=0
- - DUT_ENCODER_PATH=./IVAS_cod_ref
+ - USE_LTV=0
+ - DUT_DECODER_PATH=./IVAS_dec_ref
- TEST_SUITE="$SHORT_TEST_SUITE"
- LEVEL_SCALING=3.162
<<: *ivas-pytest-anchor
-ivas-pytest-mld-long-enc-fx-dec-flt-interop:
+ivas-pytest-enc-msan:
extends:
- - .rules-pytest-mld-interop
- .test-job-linux
before_script:
- - USE_LTV=0
+ - CLANG_NUM=1
- DUT_DECODER_PATH=./IVAS_dec_ref
- - TEST_SUITE="$SHORT_TEST_SUITE"
- - LEVEL_SCALING=1.0
- <<: *ivas-pytest-anchor
+ <<: *ivas-pytest-sanitizers-anchor
-ivas-pytest-mld-long-enc-fx-dec-flt-lev-10-interop:
+ivas-pytest-enc-asan:
extends:
- - .rules-pytest-mld-interop
- .test-job-linux
before_script:
- - USE_LTV=0
+ - CLANG_NUM=2
- DUT_DECODER_PATH=./IVAS_dec_ref
- - TEST_SUITE="$SHORT_TEST_SUITE"
- - LEVEL_SCALING=0.3162
- <<: *ivas-pytest-anchor
+ <<: *ivas-pytest-sanitizers-anchor
-ivas-pytest-mld-long-enc-fx-dec-flt-lev+10-interop:
+ivas-pytest-enc-usan:
extends:
- - .rules-pytest-mld-interop
- .test-job-linux
before_script:
- - USE_LTV=0
+ - CLANG_NUM=3
- DUT_DECODER_PATH=./IVAS_dec_ref
+ <<: *ivas-pytest-sanitizers-anchor
+
+### jobs that test flt encoder -> fx decoder
+ivas-pytest-mld-dec:
+ extends:
+ - .rules-pytest-mld
+ - .test-job-linux
+ before_script:
+ - USE_LTV=0
+ - DUT_ENCODER_PATH=./IVAS_cod_ref
+ - TEST_SUITE="$SHORT_TEST_SUITE"
+ - LEVEL_SCALING=1.0
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-mld-dec-lev-10:
+ extends:
+ - .rules-pytest-mld
+ - .test-job-linux
+ before_script:
+ - USE_LTV=0
+ - DUT_ENCODER_PATH=./IVAS_cod_ref
+ - TEST_SUITE="$SHORT_TEST_SUITE"
+ - LEVEL_SCALING=0.3162
+ <<: *ivas-pytest-anchor
+
+ivas-pytest-mld-dec-lev+10:
+ extends:
+ - .rules-pytest-mld
+ - .test-job-linux
+ before_script:
+ - USE_LTV=0
+ - DUT_ENCODER_PATH=./IVAS_cod_ref
- TEST_SUITE="$SHORT_TEST_SUITE"
- LEVEL_SCALING=3.162
<<: *ivas-pytest-anchor
@@ -511,6 +508,7 @@ ivas-pytest-dec-msan:
- .test-job-linux
before_script:
- CLANG_NUM=1
+ - DUT_ENCODER_PATH=./IVAS_cod_ref
<<: *ivas-pytest-sanitizers-anchor
ivas-pytest-dec-asan:
@@ -518,6 +516,7 @@ ivas-pytest-dec-asan:
- .test-job-linux
before_script:
- CLANG_NUM=2
+ - DUT_ENCODER_PATH=./IVAS_cod_ref
<<: *ivas-pytest-sanitizers-anchor
ivas-pytest-dec-usan:
@@ -525,18 +524,20 @@ ivas-pytest-dec-usan:
- .test-job-linux
before_script:
- CLANG_NUM=3
+ - DUT_ENCODER_PATH=./IVAS_cod_ref
<<: *ivas-pytest-sanitizers-anchor
# ---------------------------------------------------------------
# Long test jobs
# ---------------------------------------------------------------
-ivas-pytest-mld-long-enc-dec:
+ivas-pytest-mld-long-enc:
extends:
- .rules-pytest-mld-long
- .test-job-linux
before_script:
- - USE_LTV=1
+ - USE_LTV=1
+ - DUT_DECODER_PATH=./IVAS_dec_ref
- TEST_SUITE="$LONG_TEST_SUITE"
- LEVEL_SCALING=1.0
<<: *ivas-pytest-anchor
@@ -552,12 +553,13 @@ ivas-pytest-mld-long-dec:
- LEVEL_SCALING=1.0
<<: *ivas-pytest-anchor
-ivas-pytest-mld-long-enc-dec-lev-10:
+ivas-pytest-mld-long-enc-lev-10:
extends:
- .rules-pytest-mld-long
- .test-job-linux
before_script:
- - USE_LTV=1
+ - USE_LTV=1
+ - DUT_DECODER_PATH=./IVAS_dec_ref
- TEST_SUITE="$LONG_TEST_SUITE"
- LEVEL_SCALING=0.3162
<<: *ivas-pytest-anchor
@@ -567,18 +569,19 @@ ivas-pytest-mld-long-dec-lev-10:
- .rules-pytest-mld-long
- .test-job-linux
before_script:
- - USE_LTV=1
+ - USE_LTV=1
- DUT_ENCODER_PATH=./IVAS_cod_ref
- TEST_SUITE="$LONG_TEST_SUITE"
- LEVEL_SCALING=0.3162
<<: *ivas-pytest-anchor
-ivas-pytest-mld-long-enc-dec-lev+10:
+ivas-pytest-mld-long-enc-lev+10:
extends:
- .rules-pytest-mld-long
- .test-job-linux
before_script:
- - USE_LTV=1
+ - USE_LTV=1
+ - DUT_DECODER_PATH=./IVAS_dec_ref
- TEST_SUITE="$LONG_TEST_SUITE"
- LEVEL_SCALING=3.162
<<: *ivas-pytest-anchor
@@ -678,6 +681,18 @@ be-2-evs-26444:
junit:
- report-junit.xml
+ivas-pytest-renderer:
+ extends:
+ - .test-job-linux
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-renderer"
+ before_script:
+ - USE_LTV=0
+ - TEST_SUITE="tests/renderer"
+ - LEVEL_SCALING=1.0
+ <<: *ivas-pytest-anchor
+
+
# job that sets up gitlab pages website
pages:
stage: deploy
diff --git a/Makefile b/Makefile
index 0467146babc3405405b5641641845fe4011f9eae..28ed2ea9150b29ca7f09ca3a171b1b28a6505641 100644
--- a/Makefile
+++ b/Makefile
@@ -60,6 +60,8 @@ CFLAGS += -std=c99 -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long \
-Wno-implicit-fallthrough -ffp-contract=off
# to be uncommented in CI
# CFLAGS += -Werror
+CFLAGS += -Winit-self
+CFLAGS += -Wunused-but-set-variable
# libs to link
LDLIBS += -lm
diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj
index f55a30abbd690261a49233e1d5cadbbb59ef1c9a..28dae4b83bcd32f3fac943c53d3420f30e53c6fb 100644
--- a/Workspace_msvc/lib_com.vcxproj
+++ b/Workspace_msvc/lib_com.vcxproj
@@ -399,8 +399,7 @@
-
-
+
diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters
index d46cc4712a40bc6363cc3460921e6dc9d1cac854..46d83453ac2480c96dc4f570a757346e4fd4d77b 100644
--- a/Workspace_msvc/lib_com.vcxproj.filters
+++ b/Workspace_msvc/lib_com.vcxproj.filters
@@ -593,11 +593,10 @@
common_h
-
-
common_h
+
diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj
index c62874ec0afbfb789e4d8814ab3938b3e33f3410..1f95040e1f2189e4fed248f58eddd0e27e8da7a0 100644
--- a/Workspace_msvc/renderer.vcxproj
+++ b/Workspace_msvc/renderer.vcxproj
@@ -65,7 +65,7 @@
Disabled
- ..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;.%(AdditionalIncludeDirectories)
+ ..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories)
_CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions)
EnableFastChecks
diff --git a/apps/renderer.c b/apps/renderer.c
index 06437f3316b4c857a4e0d19e19ef210e1b19c1cb..0798a7f74843f929dc911df6426d596d0d88864c 100644
--- a/apps/renderer.c
+++ b/apps/renderer.c
@@ -49,7 +49,7 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
+#include "prot_fx.h"
#endif
#define WMC_TOOL_SKIP
diff --git a/lib_com/ACcontextMapping.c b/lib_com/ACcontextMapping.c
index 07637ff320105e2b3401795614086daec85f97ce..54f5e18feee3490e5829aaee85b9d1dc82b0d809 100644
--- a/lib_com/ACcontextMapping.c
+++ b/lib_com/ACcontextMapping.c
@@ -47,6 +47,7 @@
*-------------------------------------------------------------------*/
/*! r: index of next coefficient */
+#ifndef IVAS_FLOAT_FIXED
int16_t get_next_coeff_mapped_ivas(
int16_t ii[2], /* i/o: coefficient indexes */
int32_t *pp, /* o : peak(1)/hole(0) indicator */
@@ -64,6 +65,28 @@ int16_t get_next_coeff_mapped_ivas(
return hm_cfg->indexBuffer[*idx];
}
+#else
+Word16 get_next_coeff_mapped_ivas(
+ Word16 ii[2], /* i/o: coefficient indexes */
+ Word32 *pp, /* o : peak(1)/hole(0) indicator */
+ Word16 *idx, /* o : index in unmapped domain */
+ CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */
+)
+{
+ UWord32 p;
+
+ p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) );
+ p >>= sub( sizeof( p ) * 8, 1 );
+ *pp = p;
+ move32();
+ *idx = ii[p];
+ move16();
+ ii[p] = add( ii[p], 1 );
+ move16();
+
+ return hm_cfg->indexBuffer[*idx];
+}
+#endif
/*-------------------------------------------------------------------*
diff --git a/lib_com/ACcontextMapping_fx.c b/lib_com/ACcontextMapping_fx.c
index 6cf368a46d5f166a2866d9e0a71f23651d65edec..ef550869294a871eac2f8084330357af76a39452 100644
--- a/lib_com/ACcontextMapping_fx.c
+++ b/lib_com/ACcontextMapping_fx.c
@@ -6,8 +6,7 @@
#include "options.h"
#include "basop_util.h"
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
/* Returns: index of next coefficient */
diff --git a/lib_com/ari_fx.c b/lib_com/ari_fx.c
index a16885a62a723d1abd6e6afa9ee585eb146f8366..3b36d10b320b4ca5ef082d785740f10754e03ba1 100644
--- a/lib_com/ari_fx.c
+++ b/lib_com/ari_fx.c
@@ -5,8 +5,7 @@
#include
#include "assert.h"
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "cnst.h"
/**
diff --git a/lib_com/ari_hm_fx.c b/lib_com/ari_hm_fx.c
index e7032468ba083a7d95e7041ed6183bdbcaddf588..767aea860a1f2591044ee1b3ee9de2c0ce1c380a 100644
--- a/lib_com/ari_hm_fx.c
+++ b/lib_com/ari_hm_fx.c
@@ -9,8 +9,7 @@
#include "cnst.h"
#include "basop_util.h"
#include "rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) )
void UnmapIndex(
@@ -35,7 +34,7 @@ void UnmapIndex(
*FractionalResolution = kLtpHmFractionalResolution;
move16();
- *Lag = L_shr( L_mult0( LtpPitchLag, Ratios_fx[Bandwidth][LtpPitchIndex][Multiplier - 1] ), 8 );
+ *Lag = L_shr( L_mult0( LtpPitchLag, Ratios_fx[Bandwidth][LtpPitchIndex][sub( Multiplier, 1 )] ), 8 );
move32();
}
ELSE
@@ -75,6 +74,7 @@ void UnmapIndex(
}
}
*Lag = L_deposit_l( Lag16 );
+ move32();
}
}
@@ -95,7 +95,7 @@ void ConfigureContextHm(
Bandwidth = 0;
move16();
- IF( GE_16( NumCoeffs, 256 ) )
+ if ( GE_16( NumCoeffs, 256 ) )
{
Bandwidth = 1;
move16();
@@ -104,7 +104,7 @@ void ConfigureContextHm(
SmallerLags = 0;
move16();
test();
- IF( ( LE_16( TargetBits, kSmallerLagsTargetBitsThreshold ) ) || ( Bandwidth == 0 ) )
+ if ( ( LE_16( TargetBits, kSmallerLagsTargetBitsThreshold ) ) || ( Bandwidth == 0 ) )
{
SmallerLags = 1;
move16();
@@ -134,6 +134,7 @@ void ConfigureContextHm(
}
}
hm_cfg->numPeakIndices = (Word16) ( tmp - hm_cfg->indexBuffer );
+ move16();
/* Set up and fill holeIndices */
hm_cfg->holeIndices = hm_cfg->indexBuffer + hm_cfg->numPeakIndices;
@@ -161,6 +162,7 @@ void ConfigureContextHm(
}
}
hm_cfg->numHoleIndices = (Word16) ( tmp - hm_cfg->holeIndices );
+ move16();
*tmp++ = NumCoeffs;
move16(); /* Add extremal element signaling the end of the buffer */
}
@@ -186,7 +188,7 @@ Word16 CountIndexBits(
}
-int tcx_hm_render(
+Word32 tcx_hm_render(
Word32 lag, /* i: pitch lag Q0 */
Word16 fract_res, /* i: fractional resolution of the lag Q0 */
Word16 p[] /* o: harmonic model Q13 */
@@ -231,6 +233,7 @@ int tcx_hm_render(
FOR( k = 1; k <= kTcxHmParabolaHalfWidth; ++k )
{
p[kTcxHmParabolaHalfWidth + k] = round_fx( Mpy_32_16_1( BASOP_Util_InvLog2( L_shl( L_mult0( i_mult2( negate( k ), k ), tmp ), 10 ) ), height ) );
+ move16();
}
/* Mirror */
FOR( k = -kTcxHmParabolaHalfWidth; k < 0; ++k )
@@ -279,7 +282,7 @@ void tcx_hm_modify_envelope(
l2 = s_min( add( k, kTcxHmParabolaHalfWidth ), L_frame_m1 );
FOR( x = l1; x <= l2; ++x )
{
- env[x] = Mpy_32_16_1( env[x], inv_shape[x - k + kTcxHmParabolaHalfWidth] );
+ env[x] = Mpy_32_16_1( env[x], inv_shape[add( sub( x, k ), kTcxHmParabolaHalfWidth )] );
move32();
}
diff --git a/lib_com/arith_coder.c b/lib_com/arith_coder.c
index 58729a004822ca49272c29c6f95e3f24543e53b9..bba7ab973482d64139bab72adab396014fe674af 100644
--- a/lib_com/arith_coder.c
+++ b/lib_com/arith_coder.c
@@ -168,11 +168,11 @@ void powfp_odd2_evs(
h = shl( 1, k ); /* highest bit of exp2 */
out2 = base;
move16();
- out = mult_r( out, pows[k + 1] ); /* we already know that "exp" has the highest bit set to one since we calculated .. */
+ out = mult_r( out, pows[add( k, 1 )] ); /* we already know that "exp" has the highest bit set to one since we calculated .. */
/* .. the effective length of "exp" earlier on, thus we omit the branch for out2 */
if ( s_and( exp2, h ) != 0 )
{
- out2 = mult_r( out2, pows[k + 1] );
+ out2 = mult_r( out2, pows[add( k, 1 )] );
}
h = shr( h, 1 );
@@ -223,7 +223,7 @@ void powfp_odd2_evs(
* and decoder remain synchronized.
*-------------------------------------------------------------------------*/
-void tcx_arith_scale_envelope_flt(
+void tcx_arith_scale_envelope_ivas(
const Word16 L_spec_core, /* i : number of lines to scale Q0 */
Word16 L_frame, /* i : number of lines Q0 */
const Word32 env[], /* i : unscaled envelope Q16 */
@@ -315,7 +315,7 @@ void tcx_arith_scale_envelope_flt(
IF( tmp <= 0 )
{
tmp = 0;
-
+ move16();
FOR( k = 0; k < L_frame; k++ )
{
s_env[k] = 0;
@@ -518,7 +518,7 @@ void tcx_arith_scale_envelope_flt(
* and decoder remain synchronized.
*-------------------------------------------------------------------------*/
-void tcx_arith_render_envelope_flt(
+void tcx_arith_render_envelope_ivas(
const Word16 A_ind[], /* i : LPC coefficients of signal envelope */
const Word16 L_frame, /* i : number of spectral lines */
const Word16 L_spec, /* i : length of the coded spectrum */
diff --git a/lib_com/arith_coder_fx.c b/lib_com/arith_coder_fx.c
index 69d646406e63d003ae085bae970907c06446db50..64cc81d04c07e795318487e3314dd0242216b140 100644
--- a/lib_com/arith_coder_fx.c
+++ b/lib_com/arith_coder_fx.c
@@ -5,8 +5,7 @@
#include
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "cnst.h"
@@ -196,6 +195,7 @@ void tcx_arith_scale_envelope(
Word16 mean_e, tmp, tmp2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -264,6 +264,7 @@ void tcx_arith_scale_envelope(
IF( tmp <= 0 )
{
tmp = 0;
+ move16();
set16_fx( s_env, 0, L_frame );
}
ELSE
@@ -429,6 +430,7 @@ void tcx_arith_scale_envelope(
L_tmp = Mpy_32_16_1( L_shl( env[k], tmp ), iscale );
L_tmp = L_min( L_tmp, a );
s_env[k] = round_fx( L_tmp );
+ move16();
}
}
diff --git a/lib_com/basop_tcx_utils.c b/lib_com/basop_tcx_utils.c
index f189a57529afcc9a37f35b795b66000be104d12d..5730b22126beff8eabb02fc57af0f929f9341efa 100644
--- a/lib_com/basop_tcx_utils.c
+++ b/lib_com/basop_tcx_utils.c
@@ -73,7 +73,7 @@ void basop_lpc2mdct( Word16 *lpcCoeffs, Word16 lpcOrder, Word16 *mdct_gains, Wor
/* short-cut, to avoid calling of BASOP_getTables() */
ptwiddle = SineTable512_fx;
step = 8;
-
+ move16();
/*ODFT*/
assert( lpcOrder < FDNS_NPTS );
@@ -106,6 +106,7 @@ void basop_lpc2mdct( Word16 *lpcCoeffs, Word16 lpcOrder, Word16 *mdct_gains, Wor
j = FDNS_NPTS - 1;
k = 0;
move16();
+ move16();
FOR( i = 0; i < FDNS_NPTS / 2; i++ )
{
diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c
index 4044484d32909f3def868e69585b42ac7f8d7883..e22f0f6e7297615462a73a682abefbaeb6e11fa1 100644
--- a/lib_com/basop_util.c
+++ b/lib_com/basop_util.c
@@ -1583,6 +1583,22 @@ Word16 idiv1616( Word16 x, Word16 y )
return y;
}
+Word16 idiv1616_1( Word16 x, Word16 y )
+{
+ IF( L_mult0( x, y ) < 0 )
+ {
+ return negate( idiv1616( abs_s( x ), abs_s( y ) ) );
+ }
+ ELSE IF( L_mult0( x, y ) > 0 )
+ {
+ return idiv1616( x, y );
+ }
+ ELSE
+ {
+ return 0;
+ }
+}
+
Word32 norm_llQ31( /* o : normalized result Q31 */
Word32 L_c, /* i : upper bits of accu Q-1 */
Word32 L_sum, /* i : lower bits of accu, unsigned Q31 */
diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h
index 380c8316bfa3e1c8707e03cc256176b3b20f51a1..d633a33f918410a7b5ee32b6aceb7a1a279af15c 100644
--- a/lib_com/basop_util.h
+++ b/lib_com/basop_util.h
@@ -582,6 +582,8 @@ Word16 idiv1616U( Word16 x, Word16 y );
Word16 idiv1616( Word16 x, Word16 y );
+Word16 idiv1616_1( Word16 x, Word16 y );
+
/*------------------------------------------------------------------*
* Dot_product16HQ:
*
diff --git a/lib_com/bitalloc.c b/lib_com/bitalloc.c
index 975740a9cd43bcda67f79fe66d85b3c190f10823..7e1c92f9cd439cad5c19d1dbb500424454bfeb80 100644
--- a/lib_com/bitalloc.c
+++ b/lib_com/bitalloc.c
@@ -849,6 +849,8 @@ int16_t BitAllocWB(
factor_fx[0] = 16384; /*Q13 move16(); */
factor_fx[1] = 24576; /*Q13 move16(); */
+ move16();
+ move16();
{
R_diff_32_fx[0] = L_sub( Ravg_sub_32_fx[0], Ravg_sub_32_fx[1] );
move32(); /*Q16 */
@@ -1013,6 +1015,7 @@ int16_t BitAllocWB(
{
L_tmp = L_add( L_tmp, Rsubband_buf[i] ); /*Q21 */
R[i] = extract_h( L_shr( Rsubband_buf[i], 5 ) ); /*Q0 */
+ move16();
}
t_fx = extract_h( L_shr( L_tmp, 5 ) ); /*Q0 */
diff --git a/lib_com/bitalloc_fx.c b/lib_com/bitalloc_fx.c
index 8ae8a674f104240efef35cbd0dc89a2c15de2603..c20235e391d15ae9f3e1a8b1ebf2efe1e7a0e561 100644
--- a/lib_com/bitalloc_fx.c
+++ b/lib_com/bitalloc_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
void bitalloc_fx(
Word16 *y, /* i : reordered norm of sub-vectors Q0 */
@@ -26,6 +25,7 @@ void bitalloc_fx(
Word16 ii;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
Word16 SFM_thr = SFM_G1G2;
move16();
@@ -294,7 +294,7 @@ Word16 BitAllocF_fx(
t_fx = L_deposit_l( 0 );
n = 0;
move16();
- tmp = add( band_end_HQ[num_env_bands - 1], shl( band_end_HQ[num_env_bands - 1], 1 ) );
+ tmp = add( band_end_HQ[sub( num_env_bands, 1 )], shl( band_end_HQ[sub( num_env_bands, 1 )], 1 ) );
exp1 = norm_s( tmp );
tmp = div_s( 16384, shl( tmp, exp1 ) ); /*15 + 14 - exp1*/
exp2 = norm_s( tmp );
@@ -318,6 +318,7 @@ Word16 BitAllocF_fx(
ELSE
{
Rsubband_w32_fx[i] = L_deposit_l( 0 );
+ move32();
}
}
}
@@ -338,7 +339,7 @@ Word16 BitAllocF_fx(
t_fx = L_deposit_l( 0 );
n = 0;
move16();
- tmp = add( band_end_HQ[N - 1], shl( band_end_HQ[N - 1], 1 ) );
+ tmp = add( band_end_HQ[sub( N, 1 )], shl( band_end_HQ[sub( N, 1 )], 1 ) );
exp1 = norm_s( tmp );
tmp = div_s( 16384, shl( tmp, exp1 ) ); /*15 + 14 - exp1*/
exp2 = norm_s( tmp );
@@ -346,7 +347,7 @@ Word16 BitAllocF_fx(
exp1 = add( 29, sub( exp2, exp1 ) );
FOR( i = 0; i < N; i++ )
{
- L_tmp2 = L_sub( L_mult0( y[i], band_end_HQ[N - 1] ), L_tmp1 );
+ L_tmp2 = L_sub( L_mult0( y[i], band_end_HQ[sub( N, 1 )] ), L_tmp1 );
Rsubband_w32_fx[i] = L_mult0( extract_l( L_tmp2 ), Nb[i] );
move32(); /*Q0*/
IF( Rsubband_w32_fx[i] > 0 )
@@ -361,6 +362,7 @@ Word16 BitAllocF_fx(
ELSE
{
Rsubband_w32_fx[i] = L_deposit_l( 0 );
+ move32();
}
}
}
@@ -397,6 +399,7 @@ Word16 BitAllocF_fx(
ELSE
{
Rsubband_w32_fx[i] = L_deposit_l( 0 );
+ move32();
}
}
}
@@ -416,6 +419,7 @@ Word16 BitAllocF_fx(
IF( ( LT_32( Rsubband_w32_fx[i], L_shl( add( bs, LNb[i] ), 15 ) ) ) && ( EQ_16( low_rate, 1 ) ) )
{
Rsubband_w32_fx[i] = L_deposit_l( 0 );
+ move32();
}
ELSE IF( LE_32( Rsubband_w32_fx[i], L_shl( Nb[i], 15 ) ) )
{
@@ -437,7 +441,7 @@ Word16 BitAllocF_fx(
L_tmp1 = L_sub( t_fx, L_shl( B, 15 ) );
L_tmp2 = L_abs( L_tmp1 );
- if ( n > 0 )
+ IF( n > 0 )
{
exp1 = sub( norm_l( L_tmp2 ), 1 );
exp2 = norm_s( n );
@@ -486,6 +490,7 @@ Word16 BitAllocF_fx(
{
B = add( B, Nb[i] );
Rsubband_w32_fx[i] = L_deposit_l( 0 );
+ move32();
IF( B >= 0 )
{
BREAK;
@@ -502,6 +507,7 @@ Word16 BitAllocF_fx(
FOR( i = 0; i < N; i++ )
{
Rsubband_fx[i] = extract_l( L_shr( Rsubband_w32_fx[i], 12 ) );
+ move16();
tmp = add( tmp, Rsubband_fx[i] );
}
@@ -609,6 +615,7 @@ static void Bit_group_fx(
tmp = sub( fac_fx[1], tmp ); /*Q13 */
L_tmp = L_mult( y_index[i], tmp ); /*Q14 */
y_index[i] = extract_h( L_shl( L_tmp, 2 ) ); /*Q0 */
+ move16();
}
}
ELSE
@@ -620,6 +627,7 @@ static void Bit_group_fx(
tmp = sub( fac_fx[0], tmp ); /*Q13 */
L_tmp = L_mult( y_index[i], tmp ); /*Q14 */
y_index[i] = extract_h( L_shl( L_tmp, 2 ) ); /*Q0 */
+ move16();
}
}
@@ -653,6 +661,7 @@ static void Bit_group_fx(
FOR( k = 0; k <= i; k++ )
{
R_temp_fx[k] = L_deposit_h( 0 ); /*Q21 */
+ move32();
}
}
ELSE
@@ -676,8 +685,9 @@ static void Bit_group_fx(
IF( LT_32( R_temp_fx[i], L_tmp ) )
{
R_temp_fx[i] = L_deposit_h( 0 );
+ move32();
norm_sum = sub( norm_sum, y_index[i] );
- i--;
+ i = sub( i, 1 );
}
ELSE
{
@@ -701,15 +711,18 @@ static void Bit_group_fx(
FOR( j = bit_band; j < band_num; j++ )
{
R_temp_fx[j] = L_deposit_l( 0 );
+ move32();
}
norm_sum = 0;
+ move16();
FOR( k = 0; k < bit_band; k++ )
{
norm_sum = add( norm_sum, y_index[k] );
}
i = bit_band;
+ move16();
FOR( j = 0; j < bit_band; j++ )
{
IF( norm_sum == 0 )
@@ -717,6 +730,7 @@ static void Bit_group_fx(
FOR( k = 0; k < i; k++ )
{
R_temp_fx[k] = L_deposit_l( 0 ); /*Q21 */
+ move32();
}
}
ELSE
@@ -735,6 +749,7 @@ static void Bit_group_fx(
}
}
R_sum_fx = 0;
+ move32();
L_tmp = L_shl( L_deposit_l( thr ), 21 ); /*Q21 */
FOR( k = 0; k < i; k++ )
{
@@ -744,8 +759,10 @@ static void Bit_group_fx(
{
norm_sum = sub( norm_sum, y_index[m] );
R_temp_fx[m] = L_deposit_l( 0 ); /*Q21 */
+ move32();
}
i = k;
+ move16();
BREAK;
}
ELSE
@@ -759,6 +776,7 @@ static void Bit_group_fx(
}
R_sum_org_fx = R_sum_fx;
+ move32();
}
}
@@ -796,6 +814,7 @@ Word16 BitAllocWB_fx( /* o : t
Word16 BANDS;
Word16 tmp, exp;
Word16 Rsum_sub_fx_tmp = 0; /* initialize just to avoid compiler warning */
+ move16();
Word32 L_tmp, L_tmp1;
Word32 Rsubband_buf[NB_SFM];
@@ -845,7 +864,7 @@ Word16 BitAllocWB_fx( /* o : t
}
}
Ravg_sub_32_fx[1] = L_mult( Rsum_sub_fx[1], 4096 ); /*16 0+15+1 //q15 1/8 =4096 */
-
+ move32();
Rsum_sub_fx[2] = 0;
move16();
FOR( j = SFM_G1G2; j < BANDS; j++ )
@@ -870,6 +889,8 @@ Word16 BitAllocWB_fx( /* o : t
factor_fx[0] = 16384; /*Q13 move16(); */
factor_fx[1] = 24576; /*Q13 move16(); */
+ move16();
+ move16();
{
R_diff_32_fx[0] = L_sub( Ravg_sub_32_fx[0], Ravg_sub_32_fx[1] );
move32(); /*Q16 */
@@ -1030,6 +1051,7 @@ Word16 BitAllocWB_fx( /* o : t
FOR( i = 0; i < BANDS; i++ )
{
Rsubband_fx[i] = extract_l( L_shr( Rsubband_buf[i], 18 ) );
+ move16();
}
/* Calcuate total used bits and initialize R to be used for Noise Filling */
@@ -1038,6 +1060,7 @@ Word16 BitAllocWB_fx( /* o : t
{
L_tmp = L_add( L_tmp, Rsubband_buf[i] ); /*Q21 */
R[i] = extract_h( L_shr( Rsubband_buf[i], 5 ) ); /*Q0 */
+ move16();
}
t_fx = extract_h( L_shr( L_tmp, 5 ) ); /*Q0 */
diff --git a/lib_com/bitallocsum_fx.c b/lib_com/bitallocsum_fx.c
index fd34a0c1d225791932e1b1e38c6a7e607fb58f8e..c8ad205e1e3ae5fa02fd6ac91575d713fe475df2 100644
--- a/lib_com/bitallocsum_fx.c
+++ b/lib_com/bitallocsum_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
/*--------------------------------------------------------------------------
* bitallocsum_fx()
@@ -36,6 +35,7 @@ void bitallocsum_fx(
total = add( total, tmp );
}
*sum = total;
+ move16();
IF( LE_16( length, L_FRAME32k ) )
{
@@ -50,6 +50,7 @@ void bitallocsum_fx(
move16();
diff = sub( diff, 1 );
*sum = add( *sum, 1 );
+ move16();
}
i = add( i, 1 );
if ( GE_16( i, nb_sfm ) )
diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c
index ef0296335db91af740f6fe48e3ba3e5a06a775af..22bb0040b94db3e0e82f53ab392785a818d38cc1 100644
--- a/lib_com/bits_alloc_fx.c
+++ b/lib_com/bits_alloc_fx.c
@@ -5,8 +5,7 @@
#include
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#include "basop_util.h"
#include "rom_com.h"
@@ -67,7 +66,7 @@ void BITS_ALLOC_init_config_acelp(
/*ACELP ICB config*/
test();
- IF( EQ_16( rate_mode_index, 0 ) || NE_16( narrowBand, 0 ) )
+ IF( ( rate_mode_index == 0 ) || ( narrowBand != 0 ) )
{
move16();
move16();
@@ -149,16 +148,16 @@ Word16 BITS_ALLOC_config_acelp(
{
move16();
pConfigAcelp->formant_enh = 1;
- if ( EQ_16( coder_type, INACTIVE ) )
+ if ( coder_type == INACTIVE )
{
move16();
pConfigAcelp->formant_enh = 0;
}
}
- IF( s_and( (Word16) EQ_16( band_index, 1 ), (Word16) EQ_16( nb_subfr, 4 ) ) )
+ IF( L_and( EQ_16( band_index, 1 ), EQ_16( nb_subfr, 4 ) ) )
{
- IF( EQ_16( coder_type, INACTIVE ) )
+ IF( coder_type == INACTIVE )
{
pConfigAcelp->pre_emphasis = 0;
move16();
@@ -213,7 +212,9 @@ Word16 BITS_ALLOC_config_acelp(
IF( GT_16( coder_type, ACELP_MODE_MAX ) ) /* keep pitch sharpening for RF_ALLPRED mode */
{
pConfigAcelp->pitch_sharpening = 0;
+ move16();
pConfigAcelp->phase_scrambling = 0;
+ move16();
}
/*Allocate bits and different modes*/
@@ -238,9 +239,10 @@ Word16 BITS_ALLOC_config_acelp(
move16();
pConfigAcelp->ltf_bits = ACELP_LTF_BITS[pConfigAcelp->ltf_mode];
- if ( s_and( (Word16) EQ_16( nb_subfr, 5 ), (Word16) EQ_16( pConfigAcelp->ltf_bits, 4 ) ) )
+ IF( L_and( EQ_16( nb_subfr, 5 ), EQ_16( pConfigAcelp->ltf_bits, 4 ) ) )
{
pConfigAcelp->ltf_bits = add( pConfigAcelp->ltf_bits, 1 );
+ move16();
}
bits = add( bits, pConfigAcelp->ltf_bits );
@@ -253,9 +255,10 @@ Word16 BITS_ALLOC_config_acelp(
/* skip subframe 1, 3 gain encoding, and use from subframe 0, and 3, respectively */
test();
test();
- IF( GE_16( coder_type, ACELP_MODE_MAX ) && ( EQ_16( i, 1 ) || EQ_16( i, 3 ) ) )
+ if ( GE_16( coder_type, ACELP_MODE_MAX ) && ( EQ_16( i, 1 ) || EQ_16( i, 3 ) ) )
{
pConfigAcelp->gains_mode[i] = 0;
+ move16();
}
bits = add( bits, ACELP_GAINS_BITS[pConfigAcelp->gains_mode[i]] );
@@ -267,7 +270,7 @@ Word16 BITS_ALLOC_config_acelp(
/*Innovation*/
- if ( LT_16( bits_frame, bits ) )
+ IF( LT_16( bits_frame, bits ) )
{
printf( "Warning: bits per frame too low\n" );
return -1;
@@ -280,10 +283,15 @@ Word16 BITS_ALLOC_config_acelp(
ELSE IF( EQ_16( coder_type, RF_GENPRED ) )
{
pConfigAcelp->fixed_cdk_index[0] = 0; /* 7 bits */
+ move16();
pConfigAcelp->fixed_cdk_index[1] = -1;
+ move16();
pConfigAcelp->fixed_cdk_index[2] = 0; /* 7 bits */
+ move16();
pConfigAcelp->fixed_cdk_index[3] = -1;
+ move16();
pConfigAcelp->fixed_cdk_index[4] = -1;
+ move16();
bits = add( bits, 14 );
}
ELSE IF( EQ_16( coder_type, RF_NOPRED ) )
@@ -339,14 +347,14 @@ static Word16 BITS_ALLOC_adjust_generic(
FOR( k = 0; k < pulseconfig_size - 1; k++ )
{
- IF( i_mult2( pulseconfigbits[k], nb_subfr ) > bits_subframe2 )
+ IF( GT_16( i_mult2( pulseconfigbits[k], nb_subfr ), bits_subframe2 ) )
{
k = sub( k, 1 ); /* previous mode did not exceed bit-budget */
BREAK;
}
}
- if ( i_mult2( pulseconfigbits[k], nb_subfr ) > bits_subframe2 )
+ if ( GT_16( i_mult2( pulseconfigbits[k], nb_subfr ), bits_subframe2 ) )
{
k = sub( k, 1 ); /* previous mode did not exceed bit-budget */
}
@@ -361,14 +369,14 @@ static Word16 BITS_ALLOC_adjust_generic(
bits_currsubframe = sub( add( i_mult2( sfr, bits_subframe2 ), bits_subframe2 ), bitsused );
/* try increasing mode while below threshold */
- WHILE( ( LT_16( k, pulseconfig_size - 1 ) ) && ( LE_16( i_mult2( pulseconfigbits[add( k, 1 )], nb_subfr ), bits_currsubframe ) ) )
+ WHILE( ( LT_16( k, sub( pulseconfig_size, 1 ) ) ) && ( LE_16( i_mult2( pulseconfigbits[k + 1], nb_subfr ), bits_currsubframe ) ) )
{
test();
k = add( k, 1 );
}
/* try decreasing mode until below threshold */
- WHILE( i_mult2( pulseconfigbits[k], nb_subfr ) > bits_currsubframe )
+ WHILE( GT_16( i_mult2( pulseconfigbits[k], nb_subfr ), bits_currsubframe ) )
{
k = sub( k, 1 );
@@ -416,9 +424,11 @@ static Word16 fcb_table(
// PMT("Not floating point computation, but fixed point operator are still missing ")
out = PulseConfTable[n].bits;
- if ( L_subfr > L_SUBFR )
+ move16();
+ if ( GT_16( L_subfr, L_SUBFR ) )
{
out = fast_FCB_bits_2sfr[n];
+ move16();
}
return ( out );
@@ -448,50 +458,61 @@ static ivas_error acelp_FCB_allocator(
// PMT("Not floating point computation, but fixed point operator are still missing ")
error = IVAS_ERR_OK;
+ move32();
cdbk = coder_type; /* just to avoid warning when DEBUGGING is deactivated */
+ move16();
p_fixed_cdk_index = fixed_cdk_index;
+ move16();
/* TRANSITION coding: first subframe bit-budget was already fixed, glottal pulse not in the first subframe */
- if ( tc_subfr >= L_SUBFR && fix_first )
+ test();
+ IF( GE_16( tc_subfr, L_SUBFR ) && fix_first )
{
Word16 i;
- for ( i = 0; i < nb_subfr; i++ )
+ FOR( i = 0; i < nb_subfr; i++ )
{
- *nBits -= ACELP_FIXED_CDK_BITS( fixed_cdk_index[i] );
+ *nBits = sub( *nBits, ACELP_FIXED_CDK_BITS( fixed_cdk_index[i] ) );
+ move16();
}
return error;
}
/* TRANSITION coding: first subframe bit-budget was already fixed, glottal pulse in the first subframe */
sfr = 0;
- if ( fix_first )
+ move16();
+ IF( fix_first )
{
- *nBits -= ACELP_FIXED_CDK_BITS( fixed_cdk_index[0] );
+ *nBits = sub( *nBits, ACELP_FIXED_CDK_BITS( fixed_cdk_index[0] ) );
+ move16();
sfr = 1;
+ move16();
p_fixed_cdk_index++;
nb_subfr = 3;
+ move16();
}
/* distribute the bit-budget equally between subframes */
- if ( L_subfr > L_SUBFR ) /* access fast_FCB_bits_2sfr */
+ IF( GT_16( L_subfr, L_SUBFR ) ) /* access fast_FCB_bits_2sfr */
{
max_n = 6;
+ move16();
}
- else
+ ELSE
{
max_n = ACELP_FIXED_CDK_NB;
+ move16();
}
- for ( cdbk = 0; cdbk < max_n; cdbk++ )
+ FOR( cdbk = 0; cdbk < max_n; cdbk++ )
{
- if ( fcb_table( cdbk, L_subfr ) * nb_subfr > *nBits )
+ IF( GT_32( L_mult0( fcb_table( cdbk, L_subfr ), nb_subfr ), L_deposit_l( *nBits ) ) )
{
- break;
+ BREAK;
}
}
- cdbk--;
+ cdbk = sub( cdbk, 1 );
#ifdef DEBUGGING
if ( cdbk < 0 && coder_type != TRANSITION )
@@ -506,64 +527,74 @@ static ivas_error acelp_FCB_allocator(
set16_fx( p_fixed_cdk_index, cdbk, nb_subfr );
nBits_tmp = 0;
- if ( cdbk >= 0 )
+ move16();
+ IF( cdbk >= 0 )
{
nBits_tmp = fcb_table( cdbk, L_subfr );
+ move16();
}
- else
+ ELSE
{
nBits_tmp = 0;
+ move16();
}
- *nBits -= nBits_tmp * nb_subfr;
+ *nBits = sub( *nBits, i_mult( nBits_tmp, nb_subfr ) );
+ move16();
/* try to increase the FCB bit-budget of the first subframe(s) */
- if ( cdbk < ACELP_FIXED_CDK_NB - 1 )
+ IF( LT_16( cdbk, ACELP_FIXED_CDK_NB - 1 ) )
{
- step = fcb_table( cdbk + 1, L_subfr ) - nBits_tmp;
- while ( *nBits >= step )
+ step = sub( fcb_table( add( cdbk, 1 ), L_subfr ), nBits_tmp );
+ WHILE( GE_16( *nBits, step ) )
{
( *p_fixed_cdk_index )++;
- *nBits -= step;
+ *nBits = sub( *nBits, step );
+ move16();
p_fixed_cdk_index++;
}
/* try to increase the FCB of the first subframe in cases when the next step is lower than the current step */
- step = fcb_table( fixed_cdk_index[sfr] + 1, L_subfr ) - fcb_table( fixed_cdk_index[sfr], L_subfr );
- if ( *nBits >= step && cdbk >= 0 )
+ step = sub( fcb_table( add( fixed_cdk_index[sfr], 1 ), L_subfr ), fcb_table( fixed_cdk_index[sfr], L_subfr ) );
+ test();
+ IF( GE_16( *nBits, step ) && cdbk >= 0 )
{
fixed_cdk_index[sfr]++;
- *nBits -= step;
-
- if ( *nBits >= step && fixed_cdk_index[sfr + 1] == fixed_cdk_index[sfr] - 1 )
+ *nBits = sub( *nBits, step );
+ move16();
+ test();
+ IF( GE_16( *nBits, step ) && EQ_16( fixed_cdk_index[sfr + 1], sub( fixed_cdk_index[sfr], 1 ) ) )
{
sfr++;
fixed_cdk_index[sfr]++;
- *nBits -= step;
+ *nBits = sub( *nBits, step );
+ move16();
}
}
}
/* TRANSITION coding: allocate highest FCBQ bit-budget to the subframe with the glottal-shape codebook */
- if ( tc_subfr >= L_SUBFR )
+ IF( GE_16( tc_subfr, L_SUBFR ) )
{
Word16 tempr;
SWAP( fixed_cdk_index[0], fixed_cdk_index[tc_subfr / L_SUBFR] );
/* TRANSITION coding: allocate second highest FCBQ bit-budget to the last subframe */
- if ( tc_subfr / L_SUBFR < nb_subfr - 1 )
+ IF( idiv1616( tc_subfr, L_SUBFR ) < sub( nb_subfr, 1 ) )
{
- SWAP( fixed_cdk_index[( tc_subfr - L_SUBFR ) / L_SUBFR], fixed_cdk_index[nb_subfr - 1] );
+ SWAP( fixed_cdk_index[sub( tc_subfr, L_SUBFR ) / L_SUBFR], fixed_cdk_index[nb_subfr - 1] );
}
}
/* when subframe length > L_SUBFR, number of bits instead of codebook index is signalled */
- if ( L_subfr > L_SUBFR )
+ IF( GT_16( L_subfr, L_SUBFR ) )
{
Word16 i, j;
- for ( i = 0; i < nb_subfr; i++ )
+ FOR( i = 0; i < nb_subfr; i++ )
{
j = fixed_cdk_index[i];
+ move16();
fixed_cdk_index[i] = fast_FCB_bits_2sfr[j];
+ move16();
}
}
@@ -614,22 +645,31 @@ ivas_error config_acelp1(
#ifdef DEBUGGING
#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
(void) active_cnt;
+ (void) core_brate_inpI;
#endif
#endif
ivas_error error;
error = IVAS_ERR_OK;
+ move32();
// PMT("Not floating point computation, but fixed point operator are still missing ")
/*-----------------------------------------------------------------*
* Set the flag indicating two-stage Unvoiced (UC) frame
*-----------------------------------------------------------------*/
*uc_two_stage_flag = 0;
- if ( coder_type == UNVOICED )
+ move16();
+ IF( EQ_16( coder_type, UNVOICED ) )
{
- if ( total_brate >= MIN_UNVOICED_TWO_STAGE_BRATE && element_mode > EVS_MONO && ( idchan == 0 || ( ( total_brate >= 8500 || extl_brate == 0 ) && tdm_LRTD_flag == 1 ) ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ if ( GE_32( total_brate, MIN_UNVOICED_TWO_STAGE_BRATE ) && element_mode > EVS_MONO && ( idchan == 0 || ( ( GE_32( total_brate, 8500 ) || extl_brate == 0 ) && EQ_16( tdm_LRTD_flag, 1 ) ) ) )
{
*uc_two_stage_flag = 1;
+ move16();
}
}
@@ -637,9 +677,10 @@ ivas_error config_acelp1(
* Set the number of subframes
*-----------------------------------------------------------------*/
- if ( L_frame == L_FRAME )
+ IF( EQ_16( L_frame, L_FRAME ) )
{
nb_subfr = NB_SUBFR;
+ move16();
#ifdef DEBUGGING
if ( ( ( core_brate_inp < 5900 && coder_type > UNVOICED ) && !( core_brate_inp < MIN_TC_BRATE && coder_type == TRANSITION ) ) && !( idchan > 0 && element_mode == IVAS_CPE_TD ) && !( element_mode == IVAS_SCE && tdm_low_rate_mode ) )
@@ -653,9 +694,10 @@ ivas_error config_acelp1(
}
#endif
}
- else /* L_frame == L_FRAME16k */
+ ELSE /* L_frame == L_FRAME16k */
{
nb_subfr = NB_SUBFR16k;
+ move16();
#ifdef DEBUGGING
if ( core_brate_inp < ACELP_16k_LOW_LIMIT && core == ACELP_CORE )
@@ -666,13 +708,16 @@ ivas_error config_acelp1(
}
coder_type_sw = coder_type;
- if ( core != ACELP_CORE )
+ move16();
+ IF( core != ACELP_CORE )
{
/* used in acelp_core_switch_enc() */
nb_subfr = 1;
- if ( L_frame == L_FRAME )
+ move16();
+ if ( EQ_16( L_frame, L_FRAME ) )
{
coder_type_sw = TRANSITION;
+ move16();
}
}
@@ -681,171 +726,230 @@ ivas_error config_acelp1(
*-----------------------------------------------------------------*/
flag_hardcoded = 0;
+ move16();
i = 0;
+ move16();
- while ( i < SIZE_BRATE_INTERMED_TBL )
+ WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) )
{
- if ( core_brate_inp == brate_intermed_tbl[i] )
+ IF( EQ_32( core_brate_inp, brate_intermed_tbl[i] ) )
{
flag_hardcoded = 1;
- break;
+ move16();
+ BREAK;
}
- if ( core_brate_inp < brate_intermed_tbl[i] )
+ IF( LT_32( core_brate_inp, brate_intermed_tbl[i] ) )
{
flag_hardcoded = 0;
- break;
+ move16();
+ BREAK;
}
i++;
}
- if ( element_mode == IVAS_CPE_TD && coder_type == AUDIO &&
- core_brate_inp <= 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 */
+ test();
+ test();
+ test();
+ if ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( coder_type, AUDIO ) &&
+ LE_32( core_brate_inp, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */
{
- i--;
+ i = sub( i, 1 );
}
core_brate = brate_intermed_tbl[i];
+ move32();
if ( element_mode > EVS_MONO )
{
flag_hardcoded = 0; /* use automatic and flexible ACELP bit-budget allocation */
+ move16();
}
+ test();
if ( core != ACELP_CORE && element_mode == EVS_MONO ) /* needed for mode1 core switching in EVS mono */
{
flag_hardcoded = 1;
+ move16();
}
/*-----------------------------------------------------------------*
* ACELP bit allocation
*-----------------------------------------------------------------*/
-
- if ( !( coder_type == TRANSITION && tc_subfr != -1 ) || enc_dec == DEC )
+ test();
+ test();
+ IF( !( EQ_16( coder_type, TRANSITION ) && NE_16( tc_subfr, -1 ) ) || EQ_16( enc_dec, DEC ) )
{
/* Set the bit-budget */
- bits = (Word16) ( core_brate_inp / FRAMES_PER_SEC );
+ bits = extract_l( Mpy_32_32( core_brate_inp, ONE_BY_FRAMES_PER_SEC_Q31 ) );
- if ( coder_type == TRANSITION && enc_dec == DEC && tc_call == 1 )
+ test();
+ test();
+ if ( EQ_16( coder_type, TRANSITION ) && EQ_16( enc_dec, DEC ) && EQ_16( tc_call, 1 ) )
{
- bits += *nBits_es_Pred; /* equalize for 4th signaling bit estimated at the encoder in TC_0_192 */
+ bits = add( bits, *nBits_es_Pred ); /* equalize for 4th signaling bit estimated at the encoder in TC_0_192 */
}
/* Subtract signalling bits */
- if ( enc_dec == DEC && idchan == 1 && element_mode > EVS_MONO )
+ test();
+ test();
+ IF( EQ_16( enc_dec, DEC ) && EQ_16( idchan, 1 ) && element_mode > EVS_MONO )
{
- bits -= TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS;
+ bits = sub( bits, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS );
- if ( tdm_LRTD_flag == 1 )
+ if ( EQ_16( tdm_LRTD_flag, 1 ) )
{
- bits += STEREO_BITS_TCA;
+ bits = add( bits, STEREO_BITS_TCA );
}
/* subtract TBE/BWE flag */
- if ( extl_brate > 0 && ( extl == WB_TBE || extl == SWB_TBE || extl == FB_TBE || extl == WB_BWE || extl == SWB_BWE || extl == FB_BWE ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ if ( extl_brate > 0 && ( EQ_16( extl, WB_TBE ) || EQ_16( extl, SWB_TBE ) || EQ_16( extl, FB_TBE ) || EQ_16( extl, WB_BWE ) || EQ_16( extl, SWB_BWE ) || EQ_16( extl, FB_BWE ) ) )
{
- bits--;
+ bits = sub( bits, 1 );
}
}
- else
+ ELSE
{
/* Subtract signalling bits */
- bits -= signalling_bits;
+ bits = sub( bits, signalling_bits );
}
- if ( extl_brate > 0 && ( extl == WB_TBE || extl == SWB_TBE || extl == FB_TBE || extl == WB_BWE || extl == SWB_BWE || extl == FB_BWE ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ if ( extl_brate > 0 && ( EQ_16( extl, WB_TBE ) || EQ_16( extl, SWB_TBE ) || EQ_16( extl, FB_TBE ) || EQ_16( extl, WB_BWE ) || EQ_16( extl, SWB_BWE ) || EQ_16( extl, FB_BWE ) ) )
{
/* extension layer signalling bit is counted in the extension layer bitbudget */
- bits++;
+ bits = add( bits, 1 );
}
/*-----------------------------------------------------------------*
* LSF Q bit-budget
*-----------------------------------------------------------------*/
-
- if ( !tdm_lp_reuse_flag || idchan == 0 )
+ test();
+ test();
+ test();
+ IF( !tdm_lp_reuse_flag || idchan == 0 )
{
/* LSF Q bit-budget */
acelp_cfg->lsf_bits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )];
+ move16();
- if ( !flag_hardcoded )
+ IF( !flag_hardcoded )
{
- if ( L_frame == L_FRAME )
+ IF( EQ_16( L_frame, L_FRAME ) )
{
- if ( element_mode == IVAS_SCE && tdm_low_rate_mode )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( element_mode, IVAS_SCE ) && tdm_low_rate_mode )
{
acelp_cfg->lsf_bits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )];
+ move16();
}
- else if ( ( total_brate < 7200 || coder_type == INACTIVE || coder_type == AUDIO ) && idchan == 1 )
+ ELSE IF( ( LT_32( total_brate, 7200 ) || coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( idchan, 1 ) )
{
/* TD stereo, secondary channel: do nothing */
acelp_cfg->lsf_bits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )];
+ move16();
}
- else if ( element_mode > EVS_MONO && coder_type == AUDIO && brate_intermed_tbl[i] < ACELP_9k60 )
+ ELSE IF( element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) && LT_32( brate_intermed_tbl[i], ACELP_9k60 ) )
{
/* primary channel: do nothing */
}
- else if ( element_mode > EVS_MONO && coder_type == AUDIO /*&& brate_intermed_tbl[i] >= ACELP_9k60*/ )
+ ELSE IF( element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) /*&& brate_intermed_tbl[i] >= ACELP_9k60*/ )
{
acelp_cfg->lsf_bits = 42;
+ move16();
}
- else if ( total_brate <= 9600 || coder_type == UNVOICED )
+ ELSE IF( LE_32( total_brate, 9600 ) || EQ_16( coder_type, UNVOICED ) )
{
acelp_cfg->lsf_bits = 31;
+ move16();
}
- else if ( total_brate <= 20000 )
+ ELSE IF( LE_32( total_brate, 20000 ) )
{
acelp_cfg->lsf_bits = 36;
+ move16();
}
- else
+ ELSE
{
acelp_cfg->lsf_bits = 41;
+ move16();
}
}
- else /* L_frame == L_FRAME16k */
+ ELSE /* L_frame == L_FRAME16k */
{
acelp_cfg->lsf_bits = 41;
+ move16();
}
}
- bits -= acelp_cfg->lsf_bits;
+ bits = sub( bits, acelp_cfg->lsf_bits );
/* mid-LSF Q bit-budget */
acelp_cfg->mid_lsf_bits = mid_LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )];
+ move16();
- if ( element_mode > EVS_MONO && coder_type == AUDIO /*&& brate_intermed_tbl[i] < ACELP_9k60*/ )
+ test();
+ if ( element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) /*&& brate_intermed_tbl[i] < ACELP_9k60*/ )
{
acelp_cfg->mid_lsf_bits = 5;
+ move16();
/* primary channel: do nothing */
}
- bits -= acelp_cfg->mid_lsf_bits;
+ bits = sub( bits, acelp_cfg->mid_lsf_bits );
}
#if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE
- else if ( tdm_lp_reuse_flag == 1 && idchan == 1 && active_cnt != 1 )
+ ELSE IF( EQ_16( tdm_lp_reuse_flag, 1 ) && EQ_16( idchan, 1 ) && NE_16( active_cnt, 1 ) )
{
- bits -= TDM_IC_LSF_PRED_BITS;
+ bits = sub( bits, TDM_IC_LSF_PRED_BITS );
}
#endif
/* gain Q bit-budget - part 1 */
- if ( ( coder_type != UNVOICED && coder_type != AUDIO && coder_type != INACTIVE && !( core_brate <= ACELP_8k00 && coder_type != TRANSITION ) ) || ( coder_type == INACTIVE && total_brate > MAX_GSC_INACTIVE_BRATE ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( NE_16( coder_type, UNVOICED ) && NE_16( coder_type, AUDIO ) && coder_type != INACTIVE && !( LE_32( core_brate, ACELP_8k00 ) && NE_16( coder_type, TRANSITION ) ) ) || ( coder_type == INACTIVE && GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) )
{
*nBits_es_Pred = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, -1, -1 )];
- bits -= *nBits_es_Pred;
+ move16();
+ bits = sub( bits, *nBits_es_Pred );
}
- else if ( *uc_two_stage_flag )
+ ELSE IF( *uc_two_stage_flag )
{
*nBits_es_Pred = 4;
- bits -= *nBits_es_Pred;
+ move16();
+ bits = sub( bits, *nBits_es_Pred );
}
}
- else
+ ELSE
{
bits = *unbits;
+ move16();
}
- if ( coder_type == TRANSITION && tc_call == 0 )
+ test();
+ IF( EQ_16( coder_type, TRANSITION ) && tc_call == 0 )
{
*unbits = bits;
return error;
@@ -854,14 +958,19 @@ ivas_error config_acelp1(
/*-----------------------------------------------------------------*
* Low-rate mode - bits are allocated in tdm_low_rate_enc()
*-----------------------------------------------------------------*/
-
- if ( element_mode == IVAS_SCE && tdm_low_rate_mode )
+ test();
+ IF( EQ_16( element_mode, IVAS_SCE ) && tdm_low_rate_mode )
{
acelp_cfg->FEC_mode = 0;
acelp_cfg->ltf_mode = FULL_BAND;
*nBits_es_Pred = 0;
*unbits = 0;
acelp_cfg->ubits = 0;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
return error;
}
@@ -871,34 +980,43 @@ ivas_error config_acelp1(
*-----------------------------------------------------------------*/
acelp_cfg->FEC_mode = 0;
- if ( core_brate >= ACELP_11k60 && ( idchan == 0 || element_mode == EVS_MONO ) )
+ move16();
+ test();
+ test();
+ IF( GE_32( core_brate, ACELP_11k60 ) && ( idchan == 0 || element_mode == EVS_MONO ) )
{
acelp_cfg->FEC_mode = 1;
+ move16();
- if ( coder_type > UNVOICED && coder_type < AUDIO && coder_type != VOICED )
+ test();
+ test();
+ if ( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && NE_16( coder_type, VOICED ) )
{
- bits -= FEC_BITS_CLS;
+ bits = sub( bits, FEC_BITS_CLS );
}
- if ( coder_type != TRANSITION )
+ IF( NE_16( coder_type, TRANSITION ) )
{
- if ( total_brate >= ACELP_16k40 )
+ IF( GE_32( total_brate, ACELP_16k40 ) )
{
acelp_cfg->FEC_mode = 2;
-
- if ( coder_type > UNVOICED && coder_type < AUDIO )
+ move16();
+ test();
+ if ( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) )
{
- bits -= FEC_BITS_ENR;
+ bits = sub( bits, FEC_BITS_ENR );
}
}
- if ( total_brate >= ACELP_32k )
+ IF( GE_32( total_brate, ACELP_32k ) )
{
acelp_cfg->FEC_mode = 3;
+ move16();
- if ( coder_type > UNVOICED && coder_type < AUDIO )
+ test();
+ if ( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) )
{
- bits -= FEC_BITS_POS;
+ bits = sub( bits, FEC_BITS_POS );
}
}
}
@@ -907,50 +1025,68 @@ ivas_error config_acelp1(
/*-----------------------------------------------------------------*
* LP filtering of the adaptive excitation
*-----------------------------------------------------------------*/
-
- if ( idchan > 0 && element_mode > EVS_MONO )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( idchan > 0 && element_mode > EVS_MONO )
{
acelp_cfg->ltf_mode = FULL_BAND;
+ move16();
}
- else if ( coder_type == UNVOICED )
+ ELSE IF( EQ_16( coder_type, UNVOICED ) )
{
acelp_cfg->ltf_mode = FULL_BAND;
+ move16();
}
- else if ( ( coder_type == GENERIC || coder_type == TRANSITION ) && core_brate < ACELP_11k60 )
+ ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) ) && core_brate < ACELP_11k60 )
{
acelp_cfg->ltf_mode = LOW_PASS;
+ move16();
}
- else if ( core_brate >= ACELP_11k60 && ( coder_type != AUDIO && !( coder_type == INACTIVE && L_frame == L_FRAME ) ) )
+ ELSE IF( GE_32( core_brate, ACELP_11k60 ) && ( NE_16( coder_type, AUDIO ) && !( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME ) ) ) )
{
- if ( coder_type == INACTIVE && L_frame == L_FRAME16k && total_brate <= MAX_GSC_INACTIVE_BRATE ) /* GSC Inactive @16kHz */
+ test();
+ test();
+ IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) /* GSC Inactive @16kHz */
{
acelp_cfg->ltf_mode = FULL_BAND;
+ move16();
}
- else
+ ELSE
{
acelp_cfg->ltf_mode = NORMAL_OPERATION;
+ move16();
if ( coder_type != TRANSITION )
{
- bits -= nb_subfr;
+ bits = sub( bits, nb_subfr );
}
}
}
- else
+ ELSE
{
acelp_cfg->ltf_mode = FULL_BAND;
+ move16();
}
/*-----------------------------------------------------------------*
* UC bit-budget
*-----------------------------------------------------------------*/
-
- if ( ( ( coder_type == UNVOICED && !( *uc_two_stage_flag ) ) || ( coder_type == INACTIVE && core_brate <= ACELP_9k60 ) ) && ( idchan == 0 || element_mode == EVS_MONO ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ if ( ( ( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) ) || ( coder_type == INACTIVE && LE_32( core_brate, ACELP_9k60 ) ) ) && ( idchan == 0 || element_mode == EVS_MONO ) )
{
- bits -= NBITS_NOISENESS; /* noiseness */
+ bits = sub( bits, NBITS_NOISENESS ); /* noiseness */
}
- if ( coder_type == UNVOICED && !( *uc_two_stage_flag ) )
+ if ( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) )
{
- bits -= ( 3 * NB_SUBFR ); /* tilt factor */
+ bits = sub( bits, 3 * NB_SUBFR ); /* tilt factor */
}
/*-----------------------------------------------------------------*
@@ -958,100 +1094,102 @@ ivas_error config_acelp1(
*-----------------------------------------------------------------*/
fix_first = 0;
- if ( coder_type == TRANSITION )
+ move16();
+ IF( EQ_16( coder_type, TRANSITION ) )
{
- if ( tc_call == 2 )
+ if ( EQ_16( tc_call, 2 ) )
{
fix_first = 1;
+ move16();
}
/* TC signalling */
- if ( L_frame == L_FRAME )
+ IF( EQ_16( L_frame, L_FRAME ) )
{
- if ( tc_subfr == TC_0_0 )
+ IF( EQ_16( tc_subfr, TC_0_0 ) )
{
if ( enc_dec == ENC )
{
- bits -= 1; /* TC signalling */
+ bits = sub( bits, 1 ); /* TC signalling */
}
- if ( acelp_cfg->ltf_mode == NORMAL_OPERATION )
+ if ( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
{
- bits -= 3; /* LP filtering flag */
+ bits = sub( bits, 3 ); /* LP filtering flag */
}
}
- else if ( tc_subfr == TC_0_64 )
+ ELSE IF( EQ_16( tc_subfr, TC_0_64 ) )
{
if ( enc_dec == ENC )
{
- bits -= 4; /* TC signalling */
+ bits = sub( bits, 4 ); /* TC signalling */
}
- if ( acelp_cfg->ltf_mode == NORMAL_OPERATION )
+ if ( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
{
- bits -= 3; /* LP filtering flag */
+ bits = sub( bits, 3 ); /* LP filtering flag */
}
}
- else if ( tc_subfr == TC_0_128 )
+ ELSE IF( EQ_16( tc_subfr, TC_0_128 ) )
{
if ( enc_dec == ENC )
{
- bits -= 4; /* TC signalling */
+ bits = sub( bits, 4 ); /* TC signalling */
}
- if ( acelp_cfg->ltf_mode == NORMAL_OPERATION )
+ if ( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
{
- bits -= 2; /* LP filtering flag */
+ bits = sub( bits, 2 ); /* LP filtering flag */
}
}
- else if ( tc_subfr == TC_0_192 )
+ ELSE IF( EQ_16( tc_subfr, TC_0_192 ) )
{
if ( enc_dec == ENC )
{
- bits -= 3; /* TC signalling */
+ bits = sub( bits, 3 ); /* TC signalling */
}
- if ( acelp_cfg->ltf_mode == NORMAL_OPERATION )
+ if ( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
{
- bits -= 1; /* LP filtering flag */
+ bits = sub( bits, 1 ); /* LP filtering flag */
}
}
- else if ( tc_subfr == L_SUBFR )
+ ELSE IF( EQ_16( tc_subfr, L_SUBFR ) )
{
if ( enc_dec == ENC )
{
- bits -= 3; /* TC signalling */
+ bits = sub( bits, 3 ); /* TC signalling */
}
- if ( acelp_cfg->ltf_mode == NORMAL_OPERATION )
+ IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
{
- bits -= ( L_FRAME - tc_subfr - L_SUBFR ) / L_SUBFR; /* LP filtering flag */
+ bits = sub( bits, idiv1616( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */
}
}
- else
+ ELSE
{
if ( enc_dec == ENC )
{
- bits -= 4; /* TC signalling */
+ bits = sub( bits, 4 ); /* TC signalling */
}
- if ( acelp_cfg->ltf_mode == NORMAL_OPERATION )
+ IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
{
- bits -= ( L_FRAME - tc_subfr - L_SUBFR ) / L_SUBFR; /* LP filtering flag */
+ bits = sub( bits, idiv1616_1( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */
}
}
}
- else /* L_frame == L_FRAME16k */
+ ELSE /* L_frame == L_FRAME16k */
{
- if ( enc_dec == ENC )
+ IF( enc_dec == ENC )
{
- if ( tc_subfr <= 2 * L_SUBFR )
+ IF( LE_16( tc_subfr, 2 * L_SUBFR ) )
{
- bits -= 2; /* TC signalling */
+ bits = sub( bits, 2 ); /* TC signalling */
}
- else
+ ELSE
{
- bits -= 3; /* TC signalling */
+ bits = sub( bits, 3 ); /* TC signalling */
}
}
@@ -1059,7 +1197,7 @@ ivas_error config_acelp1(
}
/* glottal-shape codebook bits */
- bits -= ( 3 + 6 + 1 + 3 );
+ bits = sub( bits, 3 + 6 + 1 + 3 );
}
/*-----------------------------------------------------------------*
@@ -1067,24 +1205,43 @@ ivas_error config_acelp1(
*-----------------------------------------------------------------*/
acelp_cfg->fcb_mode = 0;
-
- if ( element_mode == IVAS_CPE_TD && tdm_low_rate_mode == 1 && coder_type != INACTIVE && coder_type != UNVOICED ) /* GENERIC low rate mode for secondary channel */
+ move16();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( tdm_low_rate_mode, 1 ) && coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) ) /* GENERIC low rate mode for secondary channel */
{
set16_fx( acelp_cfg->pitch_bits, 0, NB_SUBFR16k );
set16_fx( acelp_cfg->gains_mode, 0, NB_SUBFR16k );
- for ( i = 0; i < 2; i++ )
+ FOR( i = 0; i < 2; i++ )
{
acelp_cfg->pitch_bits[i] = 0;
- if ( tdm_Pitch_reuse_flag == 0 )
+ move16();
+ IF( tdm_Pitch_reuse_flag == 0 )
{
- acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, GENERIC, 2 * i * L_SUBFR, TC_SUBFR2IDX_fx( tc_subfr ) )];
- bits -= acelp_cfg->pitch_bits[i];
+ acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, GENERIC, i_mult( 2 * L_SUBFR, i ), TC_SUBFR2IDX_fx( tc_subfr ) )];
+ move16();
+ bits = sub( bits, acelp_cfg->pitch_bits[i] );
}
- acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, GENERIC, i * L_SUBFR, TC_SUBFR2IDX_fx( tc_subfr ) )];
- bits -= acelp_cfg->gains_mode[i];
+ acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, GENERIC, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )];
+ bits = sub( bits, acelp_cfg->gains_mode[i] );
}
acelp_cfg->fcb_mode = 1;
+ move16();
#ifdef DEBUGGING
if ( bits >= 55 )
@@ -1094,89 +1251,111 @@ ivas_error config_acelp1(
}
else
#endif
- if ( bits >= 16 )
- {
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
- }
- else
+ IF( GE_16( bits, 16 ) )
+ {
+ acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
+ }
+ ELSE
{
acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
acelp_cfg->fixed_cdk_index[1] = -1;
+ move16();
}
acelp_cfg->fixed_cdk_index[2] = -1;
+ move16();
acelp_cfg->fixed_cdk_index[3] = -1;
+ move16();
}
- else if ( ( coder_type != INACTIVE && nb_subfr == NB_SUBFR && coder_type != AUDIO ) || ( nb_subfr == NB_SUBFR16k && ( total_brate > MAX_GSC_INACTIVE_BRATE || coder_type != INACTIVE ) ) || core == HQ_CORE )
+ ELSE IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) || coder_type != INACTIVE ) ) || EQ_16( core, HQ_CORE ) )
{
/* pitch Q & gain Q bit-budget - part 2*/
- for ( i = 0; i < nb_subfr; i++ )
+ FOR( i = 0; i < nb_subfr; i++ )
{
- if ( L_frame == L_FRAME )
+ IF( EQ_16( L_frame, L_FRAME ) )
{
- if ( tdm_Pitch_reuse_flag == 1 && idchan == 1 )
+ IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) && EQ_16( idchan, 1 ) )
{
acelp_cfg->pitch_bits[i] = 0;
+ move16();
}
- else
+ ELSE
{
- acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, i * L_SUBFR, TC_SUBFR2IDX_fx( tc_subfr ) )];
+ acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )];
+ move16();
}
- acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type_sw, i * L_SUBFR, TC_SUBFR2IDX_fx( tc_subfr ) )];
+ acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type_sw, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )];
+ move16();
}
- else /* L_frame == L_FRAME16k */
+ ELSE /* L_frame == L_FRAME16k */
{
- if ( tdm_Pitch_reuse_flag == 1 && idchan == 1 )
+ test();
+ IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) && EQ_16( idchan, 1 ) )
{
acelp_cfg->pitch_bits[i] = 0;
+ move16();
}
- else
+ ELSE
{
- acelp_cfg->pitch_bits[i] = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i * L_SUBFR, TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
+ acelp_cfg->pitch_bits[i] = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
+ move16();
}
- acelp_cfg->gains_mode[i] = gain_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type_sw, i * L_SUBFR, TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
+ acelp_cfg->gains_mode[i] = gain_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type_sw, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
+ move16();
}
- bits -= acelp_cfg->pitch_bits[i];
+ bits = sub( bits, acelp_cfg->pitch_bits[i] );
- if ( coder_type == INACTIVE && acelp_cfg->gains_mode[i] == 6 /* VQ vs. SQ threshold @32 kbps */ )
+ test();
+ IF( coder_type == INACTIVE && EQ_16( acelp_cfg->gains_mode[i], 6 ) /* VQ vs. SQ threshold @32 kbps */ )
{
- bits -= 5;
+ bits = sub( bits, 5 );
}
- else
+ ELSE
{
- if ( *uc_two_stage_flag == 1 )
+ if ( EQ_16( *uc_two_stage_flag, 1 ) )
{
acelp_cfg->gains_mode[i] = 7;
+ move16();
}
- bits -= acelp_cfg->gains_mode[i];
+ bits = sub( bits, acelp_cfg->gains_mode[i] );
}
}
/* algebraic codebook bit-budget */
- if ( flag_hardcoded || ( core_brate_inp >= MIN_BRATE_AVQ_EXC && coder_type != INACTIVE ) || ( total_brate > MAX_GSC_INACTIVE_BRATE && coder_type == INACTIVE ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( flag_hardcoded || ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) || ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) && coder_type == INACTIVE ) )
{
- for ( i = 0; i < nb_subfr; i++ )
+ FOR( i = 0; i < nb_subfr; i++ )
{
- if ( L_frame == L_FRAME )
+ IF( EQ_16( L_frame, L_FRAME ) )
{
- acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, i * L_SUBFR, TC_SUBFR2IDX_fx( tc_subfr ) )];
+ acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )];
+ move16();
}
- else /* L_frame == L_FRAME16k */
+ ELSE /* L_frame == L_FRAME16k */
{
- acelp_cfg->fixed_cdk_index[i] = FCB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i * L_SUBFR, TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
+ acelp_cfg->fixed_cdk_index[i] = FCB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
+ move16();
}
- bits -= acelp_cfg->fixed_cdk_index[i];
+ bits = sub( bits, acelp_cfg->fixed_cdk_index[i] );
}
}
- else if ( !( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) )
+ ELSE IF( !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) )
{
- if ( coder_type == UNVOICED && !( *uc_two_stage_flag ) )
+ test();
+ IF( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) )
{
- i = bits / NB_SUBFR;
+ i = idiv1616( bits, NB_SUBFR );
+ move16();
if ( i % 2 == 0 )
{
- i--; /* must be odd */
+ i = sub( i, 1 ); /* must be odd */
}
i = s_min( i, 13 );
#ifdef DEBUG_MODE_TD
@@ -1185,55 +1364,71 @@ ivas_error config_acelp1(
#endif
i = s_max( i, 0 ); /* If i == 0-> random noise generator will be used as FCB */
set16_fx( acelp_cfg->fixed_cdk_index, i, NB_SUBFR );
- bits -= ( i * NB_SUBFR );
+ bits = sub( bits, i_mult( i, NB_SUBFR ) );
}
- else
+ ELSE
{
acelp_cfg->fcb_mode = 1;
- if ( element_mode == IVAS_CPE_TD )
+ move16();
+ test();
+ test();
+ IF( EQ_16( element_mode, IVAS_CPE_TD ) )
{
- if ( bits >= ACELP_FIXED_CDK_BITS( 0 ) * ( nb_subfr ) ) /* enough bits for all fcb */
+ IF( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), ( nb_subfr ) ) ) ) /* enough bits for all fcb */
{
acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
}
- else if ( bits >= ACELP_FIXED_CDK_BITS( 0 ) * ( nb_subfr - 1 ) )
+ ELSE IF( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 1 ) ) ) )
{
acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr - 1, L_SUBFR, coder_type, tc_subfr, fix_first );
acelp_cfg->fixed_cdk_index[3] = -1;
+ move16();
}
- else if ( bits >= ACELP_FIXED_CDK_BITS( 0 ) * ( nb_subfr - 2 ) )
+ ELSE IF( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 2 ) ) ) )
{
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr - 2, L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 2 ), L_SUBFR, coder_type, tc_subfr, fix_first );
acelp_cfg->fixed_cdk_index[2] = acelp_cfg->fixed_cdk_index[1];
+ move16();
acelp_cfg->fixed_cdk_index[1] = -1;
+ move16();
acelp_cfg->fixed_cdk_index[3] = -1;
+ move16();
}
- else if ( bits >= ACELP_FIXED_CDK_BITS( 0 ) )
+ ELSE IF( GE_16( bits, ACELP_FIXED_CDK_BITS( 0 ) ) )
{
acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 1, L_SUBFR, coder_type, tc_subfr, fix_first );
acelp_cfg->fixed_cdk_index[1] = acelp_cfg->fixed_cdk_index[0];
+ move16();
acelp_cfg->fixed_cdk_index[0] = -1;
+ move16();
acelp_cfg->fixed_cdk_index[2] = -1;
+ move16();
acelp_cfg->fixed_cdk_index[3] = -1;
+ move16();
}
- else /* No FCB */
+ ELSE /* No FCB */
{
#ifdef DEBUGGING
IVAS_ERROR( IVAS_ERR_INTERNAL, "WARNING!!!, No bit allocated to FCB, check frame %d\n" );
#endif
acelp_cfg->fixed_cdk_index[0] = -1;
+ move16();
acelp_cfg->fixed_cdk_index[1] = -1;
+ move16();
acelp_cfg->fixed_cdk_index[2] = -1;
+ move16();
acelp_cfg->fixed_cdk_index[3] = -1;
+ move16();
}
}
- else if ( element_mode != IVAS_CPE_TD && GSC_IVAS_mode > 0 && L_frame == L_FRAME16k )
+ ELSE IF( element_mode != IVAS_CPE_TD && GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) )
{
bits = 100; /* 9 kbps for fcb */
+ move16();
acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
}
- else
+ ELSE
{
acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
}
@@ -1241,102 +1436,136 @@ ivas_error config_acelp1(
}
/* AVQ codebook */
- if ( ( core_brate_inp >= MIN_BRATE_AVQ_EXC && coder_type != INACTIVE ) || ( total_brate > MAX_GSC_INACTIVE_BRATE && coder_type == INACTIVE ) )
+ test();
+ test();
+ test();
+ IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) || ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) && coder_type == INACTIVE ) )
{
- for ( i = 0; i < nb_subfr; i++ )
+ FOR( i = 0; i < nb_subfr; i++ )
{
- if ( flag_hardcoded )
+ IF( flag_hardcoded )
{
- acelp_cfg->AVQ_cdk_bits[i] = AVQ_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i * L_SUBFR, TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
+ acelp_cfg->AVQ_cdk_bits[i] = AVQ_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
+ move16();
{
- bits -= acelp_cfg->AVQ_cdk_bits[i];
+ bits = sub( bits, acelp_cfg->AVQ_cdk_bits[i] );
}
}
- bits -= G_AVQ_BITS;
+ bits = sub( bits, G_AVQ_BITS );
}
- if ( core_brate_inp >= MIN_BRATE_AVQ_EXC && core_brate_inp <= MAX_BRATE_AVQ_EXC_TD && coder_type == GENERIC )
+ test();
+ test();
+ if ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && LE_32( core_brate_inp, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( coder_type, GENERIC ) )
{
/* harm. flag ACELP AVQ */
- bits--;
+ bits = sub( bits, 1 );
}
- if ( !flag_hardcoded )
+ IF( !flag_hardcoded )
{
Word16 bit_tmp;
- bit_tmp = bits / nb_subfr;
+ bit_tmp = idiv1616( bits, nb_subfr );
set16_fx( acelp_cfg->AVQ_cdk_bits, bit_tmp, nb_subfr );
- bits -= bit_tmp * nb_subfr;
+ bits = sub( bits, i_mult( bit_tmp, nb_subfr ) );
bit_tmp = bits % nb_subfr;
- acelp_cfg->AVQ_cdk_bits[0] += bit_tmp;
- bits -= bit_tmp;
+ move16();
+ acelp_cfg->AVQ_cdk_bits[0] = add( acelp_cfg->AVQ_cdk_bits[0], bit_tmp );
+ move16();
+ bits = sub( bits, bit_tmp );
}
}
}
- else if ( ( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) || ( ( coder_type == INACTIVE || coder_type == AUDIO ) && nb_subfr == NB_SUBFR ) || ( coder_type == INACTIVE && total_brate <= MAX_GSC_INACTIVE_BRATE ) )
+ ELSE IF( ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) || ( ( coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( nb_subfr, NB_SUBFR ) ) || ( coder_type == INACTIVE && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) )
{
Word32 Local_BR, Pitch_BR;
Word16 Pitch_CT;
/* as defined at the beginning of [enc,dec]_pit_exc() */
- if ( GSC_IVAS_mode > 0 && ( GSC_noisy_speech || core_brate > GSC_H_RATE_STG ) )
+ test();
+ test();
+ IF( GSC_IVAS_mode > 0 && ( GSC_noisy_speech || GT_32( core_brate, GSC_H_RATE_STG ) ) )
{
Local_BR = ACELP_8k00;
+ move32();
Pitch_CT = GENERIC;
+ move16();
Pitch_BR = ACELP_8k00;
- if ( L_frame == L_FRAME16k )
+ move32();
+ IF( EQ_16( L_frame, L_FRAME16k ) )
{
Local_BR = ACELP_14k80;
- if ( GSC_IVAS_mode > 0 && core_brate < IVAS_24k4 )
+ move32();
+ test();
+ if ( GSC_IVAS_mode > 0 && LT_32( core_brate, IVAS_24k4 ) )
{
Local_BR = ACELP_9k60;
+ move32();
}
Pitch_BR = core_brate;
+ move32();
}
}
- else if ( GSC_noisy_speech )
+ ELSE IF( GSC_noisy_speech )
{
Local_BR = ACELP_7k20;
+ move32();
Pitch_CT = GENERIC;
+ move16();
Pitch_BR = ACELP_7k20;
- if ( L_frame == L_FRAME16k )
+ move32();
+ if ( EQ_16( L_frame, L_FRAME16k ) )
{
Pitch_BR = core_brate;
+ move32();
}
}
- else
+ ELSE
{
Local_BR = ACELP_7k20;
+ move32();
Pitch_CT = AUDIO;
+ move16();
Pitch_BR = core_brate;
+ move32();
- if ( L_frame == L_FRAME16k )
+ IF( EQ_16( L_frame, L_FRAME16k ) )
{
Local_BR = ACELP_13k20;
+ move32();
Pitch_CT = GENERIC;
+ move16();
}
}
- for ( i = 0; i < nb_subfr; i++ )
+ FOR( i = 0; i < nb_subfr; i++ )
{
- if ( L_frame == L_FRAME16k )
+ IF( EQ_16( L_frame, L_FRAME16k ) )
{
- acelp_cfg->pitch_bits[i] = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( Pitch_BR, Pitch_CT, i * L_SUBFR, 0 )];
- acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( Local_BR, LOCAL_CT, i * L_SUBFR, 0 )];
+ acelp_cfg->pitch_bits[i] = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( Pitch_BR, Pitch_CT, i_mult( i, L_SUBFR ), 0 )];
+ move16();
+ acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( Local_BR, LOCAL_CT, i_mult( i, L_SUBFR ), 0 )];
+ move16();
}
- else
+ ELSE
{
- acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( Pitch_BR, Pitch_CT, i * L_SUBFR, 0 )];
- acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( Local_BR, LOCAL_CT, i * L_SUBFR, 0 )];
- acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, LOCAL_CT, i * L_SUBFR, 0 )];
+ acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( Pitch_BR, Pitch_CT, i_mult( i, L_SUBFR ), 0 )];
+ move16();
+ acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( Local_BR, LOCAL_CT, i_mult( i, L_SUBFR ), 0 )];
+ move16();
+ acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, LOCAL_CT, i_mult( i, L_SUBFR ), 0 )];
+ move16();
}
}
}
- if ( coder_type == TRANSITION && ( tc_call == 1 && tc_subfr == 0 && L_frame == L_FRAME ) )
+ test();
+ test();
+ test();
+ IF( EQ_16( coder_type, TRANSITION ) && ( EQ_16( tc_call, 1 ) && tc_subfr == 0 && EQ_16( L_frame, L_FRAME ) ) )
{
return error;
}
@@ -1346,70 +1575,101 @@ ivas_error config_acelp1(
*-----------------------------------------------------------------*/
acelp_cfg->ubits = 0; /* these bits could be reused for something else */
+ move16();
- if ( flag_hardcoded && core_brate != PPP_NELP_2k80 )
+ test();
+ IF( flag_hardcoded && NE_32( core_brate, PPP_NELP_2k80 ) )
{
/* unused bits */
- if ( coder_type == AUDIO || ( coder_type == INACTIVE && core_brate <= ACELP_24k40 ) )
+ IF( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE && LE_32( core_brate, ACELP_24k40 ) ) )
{
acelp_cfg->ubits = 0;
+ move16();
}
- else if ( L_frame == L_FRAME )
+ ELSE IF( EQ_16( L_frame, L_FRAME ) )
{
acelp_cfg->ubits = reserved_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, -1, TC_SUBFR2IDX_fx( tc_subfr ) )];
+ move16();
}
- else
+ ELSE
{
acelp_cfg->ubits = 0;
+ move16();
}
- bits -= acelp_cfg->ubits;
+ bits = sub( bits, acelp_cfg->ubits );
}
/* sanity check */
- if ( ( coder_type != INACTIVE && nb_subfr == NB_SUBFR && coder_type != AUDIO ) || nb_subfr == NB_SUBFR16k )
+ test();
+ test();
+ test();
+ IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || EQ_16( nb_subfr, NB_SUBFR16k ) )
{
- if ( ( L_frame == L_FRAME16k && coder_type == INACTIVE && total_brate <= MAX_GSC_INACTIVE_BRATE ) || ( GSC_IVAS_mode > 0 && L_frame == L_FRAME16k ) ) /* GSC Inactive @16kHz */
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( EQ_16( L_frame, L_FRAME16k ) && coder_type == INACTIVE && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) || ( GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) ) /* GSC Inactive @16kHz */
{
acelp_cfg->ubits = 0;
+ move16();
}
- else if ( flag_hardcoded && core == ACELP_CORE && bits != 0 )
+ ELSE IF( flag_hardcoded && core == ACELP_CORE && bits != 0 )
{
#ifdef DEBUGGING
IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR: bit-budget incorrect (%d bits) in frame %d.\n", (Word32) bits );
#endif
}
- else if ( bits > 0 && !( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) )
+ ELSE IF( bits > 0 && !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) )
{
- if ( idchan > 0 && element_mode == IVAS_CPE_TD )
+ test();
+ test();
+ test();
+ test();
+ IF( idchan > 0 && EQ_16( element_mode, IVAS_CPE_TD ) )
{
#if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE
- if ( !tdm_lp_reuse_flag )
+ IF( !tdm_lp_reuse_flag )
{
- acelp_cfg->lsf_bits += bits; /* increase LSF Q bits */
+ acelp_cfg->lsf_bits = add( acelp_cfg->lsf_bits, bits ); /* increase LSF Q bits */
+ move16();
bits = 0;
+ move16();
}
- else
+ ELSE
{
Word16 nb_prm = 4;
- if ( tdm_low_rate_mode == 1 )
+ move16();
+ if ( EQ_16( tdm_low_rate_mode, 1 ) )
{
nb_prm = 2;
+ move16();
}
/* First add remaining bits on gains */
- bits -= allocate_unused( core_brate, coder_type, bits, nb_prm, 0, GAINSPRM, acelp_cfg->gains_mode );
+ bits = sub( bits, allocate_unused( core_brate, coder_type, bits, nb_prm, 0, GAINSPRM, acelp_cfg->gains_mode ) );
/* Then, Increase pitch bit budget */
- if ( tdm_Pitch_reuse_flag == 0 && bits > 0 )
+ test();
+ IF( tdm_Pitch_reuse_flag == 0 && bits > 0 )
{
- bits -= allocate_unused( core_brate, coder_type, bits, nb_prm, 0, PITCHPRM, acelp_cfg->pitch_bits );
+ bits = sub( bits, allocate_unused( core_brate, coder_type, bits, nb_prm, 0, PITCHPRM, acelp_cfg->pitch_bits ) );
}
/* Increase mid-lsf bit budget */
- if ( tdm_lp_reuse_flag == 0 && bits > 0 )
+ test();
+ IF( tdm_lp_reuse_flag == 0 && bits > 0 )
{
- bits -= allocate_unused( core_brate, coder_type, bits, 1, 0, MID_LSFSPRM, &acelp_cfg->mid_lsf_bits );
- bits -= allocate_unused( core_brate, coder_type, bits, 1, 0, LSFPRM, &acelp_cfg->lsf_bits );
+ bits = sub( bits, allocate_unused( core_brate, coder_type, bits, 1, 0, MID_LSFSPRM, &acelp_cfg->mid_lsf_bits ) );
+ bits = sub( bits, allocate_unused( core_brate, coder_type, bits, 1, 0, LSFPRM, &acelp_cfg->lsf_bits ) );
}
}
#else
@@ -1447,27 +1707,34 @@ ivas_error config_acelp1(
#endif
}
- else if ( core == ACELP_CORE && coder_type >= UNVOICED && coder_type <= GENERIC && L_frame == L_FRAME )
+ ELSE IF( core == ACELP_CORE && GE_16( coder_type, UNVOICED ) && LE_16( coder_type, GENERIC ) && EQ_16( L_frame, L_FRAME ) )
{
- acelp_cfg->lsf_bits += bits; /* increase LSF Q bits */
+ acelp_cfg->lsf_bits = add( acelp_cfg->lsf_bits, bits ); /* increase LSF Q bits */
+ move16();
- if ( acelp_cfg->lsf_bits > 46 )
+ test();
+ IF( GT_16( acelp_cfg->lsf_bits, 46 ) )
{
- acelp_cfg->ubits = acelp_cfg->lsf_bits - 46;
+ acelp_cfg->ubits = sub( acelp_cfg->lsf_bits, 46 );
+ move16();
acelp_cfg->lsf_bits = 46;
+ move16();
}
- else if ( acelp_cfg->lsf_bits > 42 && L_frame == L_FRAME )
+ ELSE IF( GT_16( acelp_cfg->lsf_bits, 42 ) && EQ_16( L_frame, L_FRAME ) )
{
- acelp_cfg->ubits = acelp_cfg->lsf_bits - 42;
+ acelp_cfg->ubits = sub( acelp_cfg->lsf_bits, 42 );
+ move16();
acelp_cfg->lsf_bits = 42;
+ move16();
}
}
- else
+ ELSE
{
acelp_cfg->ubits = bits;
+ move16();
}
}
- else if ( bits < 0 && !( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) )
+ ELSE IF( bits < 0 && !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) )
{
#ifdef DEBUGGING
IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR: bit-budget incorrect (%d bits) in frame %d.\n", (Word32) bits );
@@ -1494,75 +1761,92 @@ static Word16 allocate_unused(
Word16 *prm_bit_mode )
{
Word16 max_bit_per_pos = 0, bit_added = 0;
+ move16();
+ move16();
// PMT("Not floating point computation, but fixed point operator are still missing ")
- if ( prm_type == GAINSPRM )
+ IF( prm_type == GAINSPRM )
{
max_bit_per_pos = 6;
- if ( core_brate > ACELP_8k00 )
+ move16();
+ IF( GT_32( core_brate, ACELP_8k00 ) )
{
max_bit_per_pos = 7;
+ move16();
}
- else if ( coder_type != UNVOICED )
+ ELSE IF( NE_16( coder_type, UNVOICED ) )
{
- if ( subfr >= 1 )
+ IF( GE_16( subfr, 1 ) )
{
max_bit_per_pos = 7;
+ move16();
}
- else if ( subfr == 0 )
+ ELSE IF( subfr == 0 )
{
max_bit_per_pos = 8;
+ move16();
}
}
- else if ( coder_type == UNVOICED )
+ ELSE IF( EQ_16( coder_type, UNVOICED ) )
{
max_bit_per_pos = 9; /* No real limit on UC gain bit budget of the secondary channel */
+ move16();
}
}
- else if ( prm_type == PITCHPRM )
+ ELSE IF( EQ_16( prm_type, PITCHPRM ) )
{
max_bit_per_pos = 6;
- if ( subfr == 0 || subfr == 2 || nb_prm == 2 )
+ move16();
+ test();
+ test();
+ if ( subfr == 0 || EQ_16( subfr, 2 ) || EQ_16( nb_prm, 2 ) )
{
max_bit_per_pos = 10;
+ move16();
}
- if ( coder_type == UNVOICED )
+ if ( EQ_16( coder_type, UNVOICED ) )
{
max_bit_per_pos = 0; /* Should not allocate bits in case of unvoiced coder type */
+ move16();
}
}
- else if ( prm_type == MID_LSFSPRM )
+ ELSE IF( EQ_16( prm_type, MID_LSFSPRM ) )
{
max_bit_per_pos = 5;
+ move16();
}
- else if ( prm_type == LSFPRM )
+ ELSE IF( EQ_16( prm_type, LSFPRM ) )
{
max_bit_per_pos = 42;
+ move16();
}
- else
+ ELSE
{
#ifdef DEBUG_MODE_TD
IVAS_ERROR( IVAS_ERR_WRONG_MODE, "unknown mode in bit_alloc.c" );
#endif
}
- max_bit_per_pos = s_min( unused_bits, max_bit_per_pos - prm_bit_mode[subfr] );
- if ( max_bit_per_pos < 0 )
+ max_bit_per_pos = s_min( unused_bits, sub( max_bit_per_pos, prm_bit_mode[subfr] ) );
+ test();
+ IF( max_bit_per_pos < 0 )
{
return 0;
}
- else if ( max_bit_per_pos >= 0 && subfr == ( nb_prm - 1 ) )
+ ELSE IF( max_bit_per_pos >= 0 && EQ_16( subfr, sub( nb_prm, 1 ) ) )
{
- prm_bit_mode[subfr] += max_bit_per_pos;
+ prm_bit_mode[subfr] = add( prm_bit_mode[subfr], max_bit_per_pos );
+ move16();
}
- else
+ ELSE
{
- prm_bit_mode[subfr] += max_bit_per_pos;
- bit_added += allocate_unused( core_brate, coder_type, unused_bits - max_bit_per_pos, nb_prm, subfr + 1, prm_type, &prm_bit_mode[0] );
+ prm_bit_mode[subfr] = add( prm_bit_mode[subfr], max_bit_per_pos );
+ move16();
+ bit_added = add( bit_added, allocate_unused( core_brate, coder_type, sub( unused_bits, max_bit_per_pos ), nb_prm, add( subfr, 1 ), prm_type, &prm_bit_mode[0] ) );
}
- return bit_added + max_bit_per_pos;
+ return add( bit_added, max_bit_per_pos );
}
@@ -1589,7 +1873,7 @@ Word16 set_ACELP_flag(
test();
test();
test();
- IF( EQ_16( element_mode, IVAS_CPE_DFT ) && EQ_16( idchan, 0 ) && LE_32( total_brate, SID_2k40 ) && EQ_16( bwidth, WB ) && EQ_16( cng_type, LP_CNG ) )
+ IF( EQ_16( element_mode, IVAS_CPE_DFT ) && ( idchan == 0 ) && LE_32( total_brate, SID_2k40 ) && EQ_16( bwidth, WB ) && EQ_16( cng_type, LP_CNG ) )
{
return 1;
}
@@ -1598,7 +1882,7 @@ Word16 set_ACELP_flag(
test();
test();
test();
- IF( GE_32( element_brate, IVAS_24k4 ) && EQ_16( idchan, 0 ) && ( EQ_16( tdm_LRTD_flag, 0 ) || GT_32( element_brate, IVAS_24k4 ) ) )
+ IF( GE_32( element_brate, IVAS_24k4 ) && ( idchan == 0 ) && ( ( tdm_LRTD_flag == 0 ) || GT_32( element_brate, IVAS_24k4 ) ) )
{
return 1;
}
@@ -1721,7 +2005,7 @@ Word16 set_ACELP_flag_IVAS(
test();
test();
test();
- IF( EQ_16( element_mode, IVAS_CPE_DFT ) && EQ_16( idchan, 0 ) && LE_32( total_brate, SID_2k40 ) && EQ_16( bwidth, WB ) && EQ_16( cng_type, LP_CNG ) )
+ IF( EQ_16( element_mode, IVAS_CPE_DFT ) && ( idchan == 0 ) && LE_32( total_brate, SID_2k40 ) && EQ_16( bwidth, WB ) && EQ_16( cng_type, LP_CNG ) )
{
return 1;
}
@@ -1730,7 +2014,7 @@ Word16 set_ACELP_flag_IVAS(
test();
test();
test();
- IF( GE_32( element_brate, IVAS_24k4 ) && EQ_16( idchan, 0 ) && ( EQ_16( tdm_LRTD_flag, 0 ) || GT_32( element_brate, IVAS_24k4 ) ) )
+ IF( GE_32( element_brate, IVAS_24k4 ) && ( idchan == 0 ) && ( ( tdm_LRTD_flag == 0 ) || GT_32( element_brate, IVAS_24k4 ) ) )
{
return 1;
}
diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c
index 47c30f497f880bc601564fef35972664bfc5b90b..975dd32938cccef10c5145d6dad51c4c97eab6f6 100644
--- a/lib_com/bitstream.c
+++ b/lib_com/bitstream.c
@@ -159,6 +159,138 @@ Word16 rate2EVSmode_float(
* Re-allocate the list of indices
*-------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+ivas_error ind_list_realloc(
+ INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */
+ const Word16 max_num_indices, /* i : new maximum number of allowed indices in the list */
+ Encoder_Struct *st_ivas /* i : IVAS encoder structure */
+)
+{
+ Word16 i, n, ch, n_channels, ind_list_pos, is_metadata, ivas_max_num_indices;
+ INDICE_HANDLE new_ind_list;
+ BSTR_ENC_HANDLE hBstr;
+
+ IF( st_ivas == NULL )
+ {
+ return IVAS_ERR_OK;
+ }
+
+ /* get the pointer to the beginning of the old buffer of indices (either metadata or core coders) */
+ IF( old_ind_list == st_ivas->ind_list_metadata )
+ {
+ is_metadata = 1;
+ ivas_max_num_indices = st_ivas->ivas_max_num_indices_metadata;
+ }
+ ELSE
+ {
+ is_metadata = 0;
+ ivas_max_num_indices = st_ivas->ivas_max_num_indices;
+ }
+ move16();
+ move16();
+
+ /* allocate new buffer of indices */
+ IF( ( new_ind_list = (INDICE_HANDLE) malloc( max_num_indices * sizeof( Indice ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of indices!\n" ) );
+ }
+
+ /* move indices from the old list to the new list */
+ FOR( i = 0; i < s_min( max_num_indices, ivas_max_num_indices ); i++ )
+ {
+ IF( GT_16( old_ind_list[i].nb_bits, -1 ) )
+ {
+ new_ind_list[i].id = old_ind_list[i].id;
+ new_ind_list[i].value = old_ind_list[i].value;
+ move16();
+ move16();
+ }
+ new_ind_list[i].nb_bits = old_ind_list[i].nb_bits;
+ move16();
+ }
+
+ /* reset nb_bits of all other indices to -1 */
+ FOR( ; i < max_num_indices; i++ )
+ {
+ new_ind_list[i].nb_bits = -1;
+ move16();
+ }
+
+ /* update parameters in all SCE elements */
+ FOR( n = 0; n < st_ivas->nSCE; n++ )
+ {
+ /* get the pointer to hBstr */
+ IF( is_metadata )
+ {
+ hBstr = st_ivas->hSCE[n]->hMetaData;
+ }
+ ELSE
+ {
+ hBstr = st_ivas->hSCE[n]->hCoreCoder[0]->hBstr;
+ }
+
+ IF( hBstr != NULL )
+ {
+ /* get the current position inside the old list */
+ ind_list_pos = (Word16) ( hBstr->ind_list - old_ind_list );
+
+ /* set pointers in the new list */
+ *( hBstr->ivas_ind_list_zero ) = new_ind_list;
+ hBstr->ind_list = &new_ind_list[ind_list_pos];
+
+ /* set the new maximum number of indices */
+ *( hBstr->ivas_max_num_indices ) = max_num_indices;
+ move16();
+ }
+ }
+
+ /* update parameters in all CPE elements */
+ FOR( n = 0; n < st_ivas->nCPE; n++ )
+ {
+ /* get the pointer to hBstr */
+ IF( is_metadata )
+ {
+ n_channels = 1;
+ }
+ ELSE
+ {
+ n_channels = CPE_CHANNELS;
+ }
+ move16();
+
+ FOR( ch = 0; ch < n_channels; ch++ )
+ {
+ IF( is_metadata )
+ {
+ hBstr = st_ivas->hCPE[n]->hMetaData;
+ }
+ ELSE
+ {
+ hBstr = st_ivas->hCPE[n]->hCoreCoder[ch]->hBstr;
+ }
+
+ IF( hBstr != NULL )
+ {
+ /* get the current position inside the old list */
+ ind_list_pos = (Word16) ( hBstr->ind_list - old_ind_list );
+
+ /* set pointers in the new list */
+ *( hBstr->ivas_ind_list_zero ) = new_ind_list;
+ hBstr->ind_list = &new_ind_list[ind_list_pos];
+
+ /* set the new maximum number of indices */
+ *( hBstr->ivas_max_num_indices ) = max_num_indices;
+ move16();
+ }
+ }
+ }
+
+ /* free the old list */
+ free( old_ind_list );
+
+ return IVAS_ERR_OK;
+}
+#else
ivas_error ind_list_realloc(
INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */
const int16_t max_num_indices, /* i : new maximum number of allowed indices in the list */
@@ -280,6 +412,7 @@ ivas_error ind_list_realloc(
return IVAS_ERR_OK;
}
+#endif // IVAS_FLOAT_FIXED
/*-----------------------------------------------------------------------*
@@ -1267,6 +1400,61 @@ void move_indices(
* Check, if we will not overwrite an existing indice -> adjust the location
*-------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+ivas_error check_ind_list_limits(
+ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
+)
+{
+ Indice *ivas_ind_list_zero, *ivas_ind_list_last;
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+ move32();
+ ivas_ind_list_zero = *( hBstr->ivas_ind_list_zero );
+
+ /* check, if the maximum number of indices has been reached and re-allocate the buffer */
+ /* the re-allocation can be avoided by increasing the limits in get_ivas_max_num_indices() or get_ivas_max_num_indices_metadata() */
+ IF( GE_16( (Word16) ( &hBstr->ind_list[hBstr->nb_ind_tot] - ivas_ind_list_zero ), *( hBstr->ivas_max_num_indices ) ) )
+ {
+
+ /* reallocate the buffer of indices with increased limit */
+ IF( ( error = ind_list_realloc( *hBstr->ivas_ind_list_zero, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES, hBstr->st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+ /* check, if we will not overwrite an existing indice */
+ IF( hBstr->ind_list[hBstr->nb_ind_tot].nb_bits > 0 )
+ {
+ IF( hBstr->nb_ind_tot == 0 )
+ {
+ /* move the pointer to the next available empty slot */
+ ivas_ind_list_last = &ivas_ind_list_zero[*( hBstr->ivas_max_num_indices )];
+ WHILE( hBstr->ind_list[0].nb_bits > 0 && hBstr->ind_list < ivas_ind_list_last )
+ {
+ hBstr->ind_list++;
+ }
+
+ IF( hBstr->ind_list >= ivas_ind_list_last )
+ {
+
+ /* no available empty slot -> need to re-allocate the buffer */
+ IF( ( error = ind_list_realloc( *hBstr->ivas_ind_list_zero, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES, hBstr->st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+ ELSE
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Buffer of indices corrupted in frame %d! Attempt to overwrite indice ID = %d (value: %d, bits: %d)!\n", hBstr->ind_list[hBstr->nb_ind_tot].id, hBstr->ind_list[hBstr->nb_ind_tot].value, hBstr->ind_list[hBstr->nb_ind_tot].nb_bits );
+ }
+ }
+
+ return error;
+}
+#else
ivas_error check_ind_list_limits(
BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
)
@@ -1319,6 +1507,7 @@ ivas_error check_ind_list_limits(
return error;
}
+#endif // IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
@@ -1327,6 +1516,67 @@ ivas_error check_ind_list_limits(
* Push a new indice into the buffer
*-------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+ivas_error push_indice(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ Word16 id, /* i : ID of the indice */
+ UWord16 value, /* i : value of the quantized indice */
+ Word16 nb_bits /* i : number of bits used to quantize the indice */
+)
+{
+ Word16 i;
+ Word16 j;
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+ move32();
+
+ /* check the limits of the list of indices */
+ IF( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
+ {
+ return IVAS_ERROR( error, "Error occured in push_indice() while re-allocating the list of indices (frame %d) !\n" );
+ }
+
+ /* find the location in the list of indices based on ID */
+ i = hBstr->nb_ind_tot;
+ move16();
+ WHILE( i > 0 && LT_16( id, hBstr->ind_list[i - 1].id ) )
+ {
+ i = sub( i, 1 );
+ }
+
+ /* shift indices, if the new ID is to be written somewhere inside the list */
+ IF( i < hBstr->nb_ind_tot )
+ {
+ FOR( j = hBstr->nb_ind_tot; j > i; j-- )
+ {
+ hBstr->ind_list[j].id = hBstr->ind_list[j - 1].id;
+ hBstr->ind_list[j].nb_bits = hBstr->ind_list[j - 1].nb_bits;
+ hBstr->ind_list[j].value = hBstr->ind_list[j - 1].value;
+ move16();
+ move16();
+ move16();
+ }
+ }
+
+
+ /* store the new indice in the list */
+ hBstr->ind_list[i].id = id;
+ hBstr->ind_list[i].value = value;
+ hBstr->ind_list[i].nb_bits = nb_bits;
+ move16();
+ move16();
+ move16();
+
+ /* updates */
+ hBstr->nb_ind_tot = add( hBstr->nb_ind_tot, 1 );
+ hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );
+ move16();
+ move16();
+
+ return error;
+}
+#else
ivas_error push_indice(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
int16_t id, /* i : ID of the indice */
@@ -1377,13 +1627,61 @@ ivas_error push_indice(
return error;
}
+#endif // IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
* push_next_indice()
*
* Push a new indice into the buffer at the next position
*-------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+ivas_error push_next_indice(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ UWord16 value, /* i : value of the quantized indice */
+ Word16 nb_bits /* i : number of bits used to quantize the indice */
+)
+{
+ Word16 prev_id;
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+ move32();
+
+
+ /* check the limits of the list of indices */
+ IF( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /* get the id of the previous indice -> it will be re-used */
+ IF( hBstr->nb_ind_tot > 0 )
+ {
+ prev_id = hBstr->ind_list[hBstr->nb_ind_tot - 1].id;
+ }
+ ELSE
+ {
+ prev_id = 0;
+ }
+ move16();
+
+ /* store the values in the list */
+ hBstr->ind_list[hBstr->nb_ind_tot].id = prev_id;
+ hBstr->ind_list[hBstr->nb_ind_tot].value = value;
+ hBstr->ind_list[hBstr->nb_ind_tot].nb_bits = nb_bits;
+ move16();
+ move16();
+ move16();
+
+ /* updates */
+ hBstr->nb_ind_tot = add( hBstr->nb_ind_tot, 1 );
+ hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );
+ move16();
+ move16();
+ return error;
+}
+#else
ivas_error push_next_indice(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
uint16_t value, /* i : value of the quantized indice */
@@ -1423,7 +1721,7 @@ ivas_error push_next_indice(
return error;
}
-
+#endif
/*-------------------------------------------------------------------*
* push_next_bits()
@@ -1698,6 +1996,38 @@ uint16_t get_indice(
*-------------------------------------------------------------------*/
/*! r: value of the indice */
+#ifdef IVAS_FLOAT_FIXED
+UWord16 get_indice_st(
+ Decoder_State *st, /* i/o: decoder state structure */
+ const Word32 element_brate, /* i : element bitrate */
+ const Word16 pos, /* i : absolute position in the bitstream */
+ const Word16 nb_bits /* i : number of bits to quantize the indice */
+)
+{
+ UWord16 value;
+ Word16 i;
+
+ assert( nb_bits <= 16 );
+
+ /* detect corrupted bitstream */
+ IF( GT_32( L_deposit_l( add( pos, nb_bits ) ), Mpy_32_32( element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ) )
+ {
+ st->BER_detect = 1;
+ move16();
+ return ( 0 );
+ }
+
+ value = 0;
+ move16();
+ FOR( i = 0; i < nb_bits; i++ )
+ {
+ value = shl( value, 1 );
+ value = add( value, st->bit_stream[add( pos, i )] );
+ }
+
+ return value;
+}
+#else
uint16_t get_indice_st(
Decoder_State *st, /* i/o: decoder state structure */
const int32_t element_brate, /* i : element bitrate */
@@ -1726,7 +2056,8 @@ uint16_t get_indice_st(
return value;
}
-
+#endif
+#ifndef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
* get_indice_1()
*
@@ -1750,7 +2081,7 @@ uint16_t get_indice_1(
return st->bit_stream[pos];
}
-
+#endif
#define WMC_TOOL_SKIP
/*-------------------------------------------------------------------*
@@ -1782,15 +2113,24 @@ void reset_indices_enc(
*
* Reset the buffer of decoder indices
*-------------------------------------------------------------------*/
-
+#ifdef IVAS_FLOAT_FIXED
void reset_indices_dec(
Decoder_State *st )
{
st->next_bit_pos = 0;
+ move16();
return;
}
+#else
+void reset_indices_dec(
+ Decoder_State *st )
+{
+ st->next_bit_pos = 0;
+ return;
+}
+#endif
/*-------------------------------------------------------------------*
* write_indices_to_stream()
*
@@ -2020,7 +2360,7 @@ ivas_error write_indices_ivas(
return error;
}
-
+#ifndef IVAS_FLOAT_FIXED
/*---------------------------------------------------------------------*
* convertSerialToBytestream( )
*
@@ -2069,7 +2409,7 @@ void convertBytestreamToSerial(
serial[i] = ( bytestream[( i >> 3 )] >> ( 7 - ( i & 7 ) ) ) & 0x1;
}
}
-
+#endif
/*-------------------------------------------------------------------*
* decoder_selectCodec()
*
@@ -2804,7 +3144,7 @@ ivas_error read_indices(
return error;
}
-
+#ifndef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
* get_rfFrameType()
*
@@ -3222,5 +3562,5 @@ void dtx_read_padding_bits(
return;
}
-
+#endif
#undef WMC_TOOL_SKIP
diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c
index 2fca67ff96e8903562e2577c44308c18fe7eeabd..1dc907e43f49d9e37f40bef27eba4b621a30f6f7 100644
--- a/lib_com/bitstream_fx.c
+++ b/lib_com/bitstream_fx.c
@@ -39,7 +39,7 @@
#include
#include "options.h"
#include "ivas_cnst.h" /* Common constants */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "ivas_prot_fx.h"
#include "basop_util.h"
#include "rom_com.h"
@@ -121,18 +121,22 @@ static void pack_bit(
UWord8 *omask /* i/o: output mask to indicate where in the octet the bit is to be written */
)
{
- if ( *omask == 0x80 )
+ if ( EQ_16( *omask, 0x80 ) )
{
**pt = 0;
+ move16();
}
- if ( bit != 0 )
+ IF( bit != 0 )
{
- **pt = **pt | *omask;
+ **pt = (UWord8) s_or( **pt, *omask );
+ move16();
}
- *omask >>= 1;
- if ( *omask == 0 )
+ *omask = (UWord8) shr( *omask, 1 );
+ move16();
+ IF( *omask == 0 )
{
*omask = 0x80;
+ move16();
( *pt )++;
}
@@ -151,11 +155,13 @@ static Word16 unpack_bit(
{
Word16 bit;
- bit = ( **pt & *mask ) != 0;
- *mask >>= 1;
- if ( *mask == 0 )
+ bit = s_and( **pt, *mask ) != 0;
+ *mask = (UWord8) shr( *mask, 1 );
+ move16();
+ IF( *mask == 0 )
{
*mask = 0x80;
+ move16();
( *pt )++;
}
return bit;
@@ -212,6 +218,7 @@ Word16 rate2EVSmode(
if ( is_amr_wb != NULL )
{
*is_amr_wb = 0;
+ move16();
}
switch ( brate )
{
@@ -250,6 +257,7 @@ Word16 rate2EVSmode(
if ( is_amr_wb != NULL )
{
*is_amr_wb = 1;
+ move16();
}
return rate2AMRWB_IOmode( brate );
}
@@ -274,29 +282,32 @@ void push_indice_fx(
{
/* indice with the same name as the previous one */
i = hBstr->next_ind_fx;
+ move16();
}
ELSE
{
/* new indice - find an empty slot in the list */
i = id;
move16();
- WHILE( NE_16( hBstr->ind_list_fx[i].nb_bits, -1 ) )
+ WHILE( NE_16( hBstr->ind_list[i].nb_bits, -1 ) )
{
i = add( i, 1 );
}
}
/* store the values in the list */
- hBstr->ind_list_fx[i].value = value;
+ hBstr->ind_list[i].value = value;
move16();
- hBstr->ind_list_fx[i].nb_bits = nb_bits;
+ hBstr->ind_list[i].nb_bits = nb_bits;
move16();
/* updates */
hBstr->next_ind_fx = add( i, 1 );
+ move16();
hBstr->last_ind_fx = id;
move16();
- hBstr->nb_bits_tot_fx = add( hBstr->nb_bits_tot_fx, nb_bits );
+ hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );
+ move16();
return;
}
@@ -314,15 +325,16 @@ void push_next_indice_fx(
{
/* store the values in the list */
- hBstr->ind_list_fx[hBstr->next_ind_fx].value = value;
+ hBstr->ind_list[hBstr->next_ind_fx].value = value;
move16();
- hBstr->ind_list_fx[hBstr->next_ind_fx].nb_bits = nb_bits;
+ hBstr->ind_list[hBstr->next_ind_fx].nb_bits = nb_bits;
move16();
hBstr->next_ind_fx = add( hBstr->next_ind_fx, 1 );
-
+ move16();
/* update the total number of bits already written */
- hBstr->nb_bits_tot_fx = add( hBstr->nb_bits_tot_fx, nb_bits );
+ hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );
+ move16();
return;
}
@@ -343,7 +355,7 @@ void push_next_bits_fx(
Word16 i, nb_bits_m15;
Indice *ptr;
- ptr = &hBstr->ind_list_fx[hBstr->next_ind_fx];
+ ptr = &hBstr->ind_list[hBstr->next_ind_fx];
nb_bits_m15 = sub( nb_bits, 15 );
i = 0;
move16();
@@ -374,8 +386,10 @@ void push_next_bits_fx(
++ptr;
}
}
- hBstr->next_ind_fx = (Word16) ( ptr - hBstr->ind_list_fx );
- hBstr->nb_bits_tot_fx = add( hBstr->nb_bits_tot_fx, nb_bits );
+ hBstr->next_ind_fx = (Word16) ( ptr - hBstr->ind_list );
+ move16();
+ hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );
+ move16();
}
/*-------------------------------------------------------------------*
@@ -397,7 +411,7 @@ UWord16 get_next_indice_fx( /* o : value of the indice */
value = 0;
move16();
- nbits_total = (Word16) ( st_fx->total_brate / FRAMES_PER_SEC );
+ nbits_total = extract_l( Mpy_32_32( st_fx->total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
/* detect corrupted bitstream */
IF( GT_16( add( st_fx->next_bit_pos, nb_bits ), nbits_total ) )
{
@@ -409,11 +423,12 @@ UWord16 get_next_indice_fx( /* o : value of the indice */
FOR( i = 0; i < nb_bits; i++ )
{
value = lshl( value, 1 );
- value = add( value, st_fx->bit_stream[st_fx->next_bit_pos + i] );
+ value = add( value, st_fx->bit_stream[add( st_fx->next_bit_pos, i )] );
}
/* update the position in the bitstream */
st_fx->next_bit_pos = add( st_fx->next_bit_pos, nb_bits );
+ move16();
return value;
}
@@ -428,7 +443,7 @@ UWord16 get_next_indice_1_fx( /* o : value of the indice *
)
{
Word16 nbits_total;
- nbits_total = (Word16) ( st_fx->total_brate / FRAMES_PER_SEC );
+ nbits_total = extract_l( Mpy_32_32( st_fx->total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
/* detect corrupted bitstream */
test();
test();
@@ -458,6 +473,7 @@ void get_next_indice_tmp_fx(
{
/* update the position in the bitstream */
st_fx->next_bit_pos = add( st_fx->next_bit_pos, nb_bits );
+ move16();
}
/*-------------------------------------------------------------------*
@@ -490,7 +506,7 @@ UWord16 get_indice_fx( /* o : value of the indice */
FOR( i = 0; i < nb_bits; i++ )
{
value = lshl( value, 1 );
- value = add( value, st_fx->bit_stream[pos + i] );
+ value = add( value, st_fx->bit_stream[add( pos, i )] );
}
return value;
@@ -508,7 +524,7 @@ UWord16 get_indice_1_fx( /* o : value of the indice */
)
{
Word16 nbits_total;
- nbits_total = (Word16) ( st_fx->total_brate / FRAMES_PER_SEC );
+ nbits_total = extract_l( Mpy_32_32( st_fx->total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
/* detect corrupted bitstream */
IF( GT_16( add( pos, 1 ), nbits_total ) )
{
@@ -532,7 +548,7 @@ void reset_indices_enc_fx(
{
Word16 i;
- hBstr->nb_bits_tot_fx = 0;
+ hBstr->nb_bits_tot = 0;
move16();
hBstr->next_ind_fx = 0;
move16();
@@ -541,7 +557,7 @@ void reset_indices_enc_fx(
FOR( i = 0; i < MAX_NUM_INDICES; i++ )
{
- hBstr->ind_list_fx[i].nb_bits = -1;
+ hBstr->ind_list[i].nb_bits = -1;
move16();
}
@@ -584,80 +600,89 @@ void write_indices_fx(
Word32 mask;
UWord8 header;
Word16 isAmrWb = 0;
+ move16();
- if ( st_fx->bitstreamformat == G192 )
+ IF( st_fx->bitstreamformat == G192 )
{
/*-----------------------------------------------------------------*
* Encode Sync Header and Frame Length
*-----------------------------------------------------------------*/
pt_stream = stream;
- for ( i = 0; i < ( 2 + MAX_BITS_PER_FRAME ); ++i )
+ FOR( i = 0; i < ( 2 + MAX_BITS_PER_FRAME ); ++i )
{
stream[i] = 0;
+ move16();
}
- *pt_stream++ = (Word16) SYNC_GOOD_FRAME;
- *pt_stream++ = hBstr->nb_bits_tot_fx;
+ *pt_stream++ = SYNC_GOOD_FRAME;
+ move16();
+ *pt_stream++ = hBstr->nb_bits_tot;
+ move16();
/*----------------------------------------------------------------*
* Bitstream packing (conversion of individual indices into a serial stream)
* Writing the serial stream into file
*----------------------------------------------------------------*/
- for ( i = 0; i < MAX_NUM_INDICES; i++ )
+ FOR( i = 0; i < MAX_NUM_INDICES; i++ )
{
- if ( hBstr->ind_list_fx[i].nb_bits != -1 )
+ IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) )
{
/* mask from MSB to LSB */
- mask = 1 << ( hBstr->ind_list_fx[i].nb_bits - 1 );
+ mask = L_shl( 1, sub( hBstr->ind_list[i].nb_bits, 1 ) );
/* write bit by bit */
- for ( k = 0; k < hBstr->ind_list_fx[i].nb_bits; k++ )
+ FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ )
{
- if ( hBstr->ind_list_fx[i].value & mask )
+ IF( L_and( hBstr->ind_list[i].value, mask ) )
{
*pt_stream++ = G192_BIN1;
+ move16();
}
- else
+ ELSE
{
*pt_stream++ = G192_BIN0;
+ move16();
}
- mask >>= 1;
+ mask = L_shr( mask, 1 );
}
}
}
}
- else
+ ELSE
{
/* Create and write ToC header */
/* qbit always set to 1 on encoder side for AMRWBIO , no qbit in use for EVS, but set to 0(bad) */
- header = (UWord8) ( st_fx->Opt_AMR_WB << 5 | st_fx->Opt_AMR_WB << 4 | rate2EVSmode( hBstr->nb_bits_tot_fx * 50, &isAmrWb ) );
+ header = (UWord8) ( s_or( s_or( shl( st_fx->Opt_AMR_WB, 5 ), shl( st_fx->Opt_AMR_WB, 4 ) ), rate2EVSmode( L_mult0( hBstr->nb_bits_tot, 50 ), &isAmrWb ) ) );
+ move16();
fwrite( &header, sizeof( UWord8 ), 1, file );
/* Write speech bits */
- fwrite( pFrame, sizeof( UWord8 ), ( pFrame_size + 7 ) >> 3, file );
+ fwrite( pFrame, sizeof( UWord8 ), shr( add( pFrame_size, 7 ), 3 ), file );
}
/* Clearing of indices */
FOR( i = 0; i < MAX_NUM_INDICES; i++ )
{
- hBstr->ind_list_fx[i].nb_bits = -1;
+ hBstr->ind_list[i].nb_bits = -1;
move16();
}
- if ( st_fx->bitstreamformat == G192 )
+ IF( st_fx->bitstreamformat == G192 )
{
/* write the serial stream into file */
fwrite( stream, sizeof( unsigned short ), 2 + stream[1], file );
}
/* reset index pointers */
- hBstr->nb_bits_tot_fx = 0;
+ hBstr->nb_bits_tot = 0;
+ move16();
hBstr->next_ind_fx = 0;
+ move16();
hBstr->last_ind_fx = -1;
+ move16();
return;
}
-
/*-------------------------------------------------------------------*
* write_indices_buf_fx()
*
@@ -689,8 +714,8 @@ void write_indices_buf_fx(
stream[i] = 0;
}
//*pt_stream++ = (Word16) SYNC_GOOD_FRAME;
- //*pt_stream++ = hBstr->nb_bits_tot_fx;
- *num_bits = hBstr->nb_bits_tot_fx;
+ //*pt_stream++ = hBstr->nb_bits_tot;
+ *num_bits = hBstr->nb_bits_tot;
/*----------------------------------------------------------------*
* Bitstream packing (conversion of individual indices into a serial stream)
@@ -698,15 +723,15 @@ void write_indices_buf_fx(
*----------------------------------------------------------------*/
for ( i = 0; i < MAX_NUM_INDICES; i++ )
{
- if ( hBstr->ind_list_fx[i].nb_bits != -1 )
+ if ( hBstr->ind_list[i].nb_bits != -1 )
{
/* mask from MSB to LSB */
- mask = 1 << ( hBstr->ind_list_fx[i].nb_bits - 1 );
+ mask = 1 << ( hBstr->ind_list[i].nb_bits - 1 );
/* write bit by bit */
- for ( k = 0; k < hBstr->ind_list_fx[i].nb_bits; k++ )
+ for ( k = 0; k < hBstr->ind_list[i].nb_bits; k++ )
{
- if ( hBstr->ind_list_fx[i].value & mask )
+ if ( hBstr->ind_list[i].value & mask )
{
//*pt_stream++ = G192_BIN1;
*pt_stream++ = 1;
@@ -726,7 +751,7 @@ void write_indices_buf_fx(
{
/* Create and write ToC header */
/* qbit always set to 1 on encoder side for AMRWBIO , no qbit in use for EVS, but set to 0(bad) */
- header = (UWord8) ( st_fx->Opt_AMR_WB << 5 | st_fx->Opt_AMR_WB << 4 | rate2EVSmode( hBstr->nb_bits_tot_fx * 50, &isAmrWb ) );
+ header = (UWord8) ( st_fx->Opt_AMR_WB << 5 | st_fx->Opt_AMR_WB << 4 | rate2EVSmode( hBstr->nb_bits_tot * 50, &isAmrWb ) );
// fwrite(&header, sizeof(UWord8), 1, file);
memcpy( out_buf, &header, sizeof( UWord8 ) );
*num_bits += sizeof( UWord8 );
@@ -739,7 +764,7 @@ void write_indices_buf_fx(
/* Clearing of indices */
FOR( i = 0; i < MAX_NUM_INDICES; i++ )
{
- hBstr->ind_list_fx[i].nb_bits = -1;
+ hBstr->ind_list[i].nb_bits = -1;
move16();
}
@@ -755,13 +780,12 @@ void write_indices_buf_fx(
//*num_bits += sizeof( unsigned short ) * ( 2 + stream[1] );
}
/* reset index pointers */
- hBstr->nb_bits_tot_fx = 0;
+ hBstr->nb_bits_tot = 0;
hBstr->next_ind_fx = 0;
hBstr->last_ind_fx = -1;
return;
}
-
/*-------------------------------------------------------------------*
* indices_to_serial()
*
@@ -782,65 +806,74 @@ void indices_to_serial(
UWord8 omask = 0x80;
UWord8 *pt_pFrame = pFrame;
Word16 isAmrWb = 0;
+ move16();
+ move16();
+ move16();
+ move16();
- if ( st_fx->Opt_AMR_WB )
+ IF( st_fx->Opt_AMR_WB )
{
cmi = rate2EVSmode( st_fx->total_brate, &isAmrWb );
- core_mode = rate2EVSmode( hBstr->nb_bits_tot_fx * 50, &isAmrWb );
+ core_mode = rate2EVSmode( L_mult0( hBstr->nb_bits_tot, 50 ), &isAmrWb );
j = 0;
- for ( i = 0; i < MAX_NUM_INDICES; i++ )
+ move16();
+ FOR( i = 0; i < MAX_NUM_INDICES; i++ )
{
- if ( hBstr->ind_list_fx[i].nb_bits != -1 )
+ IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) )
{
/* mask from MSB to LSB */
- mask = 1 << ( hBstr->ind_list_fx[i].nb_bits - 1 );
+ mask = L_shl( 1, sub( hBstr->ind_list[i].nb_bits, 1 ) );
/* temporarily save bit */
- for ( k = 0; k < hBstr->ind_list_fx[i].nb_bits; k++ )
+ FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ )
{
- amrwb_bits[j++] = ( hBstr->ind_list_fx[i].value & mask ) > 0;
- mask >>= 1;
+ amrwb_bits[j++] = L_and( hBstr->ind_list[i].value, mask ) > 0;
+ move16();
+ mask = L_shr( mask, 1 );
}
}
}
}
- *pFrame_size = hBstr->nb_bits_tot_fx;
+ *pFrame_size = hBstr->nb_bits_tot;
+ move16();
/*----------------------------------------------------------------*
* Bitstream packing (conversion of individual indices into a serial stream)
*----------------------------------------------------------------*/
j = 0;
- for ( i = 0; i < MAX_NUM_INDICES; i++ )
+ move16();
+ FOR( i = 0; i < MAX_NUM_INDICES; i++ )
{
- if ( hBstr->ind_list_fx[i].nb_bits != -1 )
+ IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) )
{
/* mask from MSB to LSB */
- mask = 1 << ( hBstr->ind_list_fx[i].nb_bits - 1 );
+ mask = L_shl( 1, sub( hBstr->ind_list[i].nb_bits, 1 ) );
/* write bit by bit */
- for ( k = 0; k < hBstr->ind_list_fx[i].nb_bits; k++ )
+ FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ )
{
- if ( st_fx->Opt_AMR_WB )
+ IF( st_fx->Opt_AMR_WB )
{
pack_bit( amrwb_bits[sort_ptr[core_mode][j++]], &pt_pFrame, &omask );
}
- else
+ ELSE
{
- pack_bit( hBstr->ind_list_fx[i].value & mask, &pt_pFrame, &omask );
- j++;
+ pack_bit( hBstr->ind_list[i].value & mask, &pt_pFrame, &omask );
+ j = add( j, 1 );
}
- mask >>= 1;
+ mask = L_shr( mask, 1 );
}
}
}
- if ( st_fx->Opt_AMR_WB && core_mode == AMRWB_IO_SID ) /* SID UPD frame always written now .... */
+ test();
+ IF( st_fx->Opt_AMR_WB && EQ_16( core_mode, AMRWB_IO_SID ) ) /* SID UPD frame always written now .... */
{
/* insert STI bit and CMI */
pack_bit( 1, &pt_pFrame, &omask );
- for ( mask = 0x08; mask > 0; mask >>= 1 )
+ FOR( mask = 0x08; mask > 0; mask >>= 1 )
{
pack_bit( cmi & mask, &pt_pFrame, &omask );
}
@@ -869,7 +902,8 @@ void indices_to_serial_generic(
nb_bits_tot = 0;
move16();
- omask = ( 0x80 >> ( *pFrame_size & 0x7 ) );
+ omask = (UWord8) shr( 0x80, s_and( *pFrame_size, 0x7 ) );
+ move16();
pt_pFrame += shr( *pFrame_size, 3 );
/*----------------------------------------------------------------*
@@ -877,27 +911,26 @@ void indices_to_serial_generic(
*----------------------------------------------------------------*/
j = 0;
move16();
- for ( i = 0; i < num_indices; i++ )
- {
- if ( ind_list[i].nb_bits != -1 )
- {
+ FOR( i = 0; i < num_indices; i++ ){
+ IF( NE_16( ind_list[i].nb_bits, -1 ) ){
/* mask from MSB to LSB */
- mask = 1 << ( ind_list[i].nb_bits - 1 );
+ mask = L_shl( 1, sub( ind_list[i].nb_bits, 1 ) );
- /* write bit by bit */
- for ( k = 0; k < ind_list[i].nb_bits; k++ )
- {
- pack_bit( ind_list[i].value & mask, &pt_pFrame, &omask );
- j++;
- mask >>= 1;
- }
- nb_bits_tot = add( nb_bits_tot, ind_list[i].nb_bits );
- }
+ /* write bit by bit */
+ FOR( k = 0; k < ind_list[i].nb_bits; k++ )
+ {
+ pack_bit( ind_list[i].value & mask, &pt_pFrame, &omask );
+ j++;
+ mask = L_shr( mask, 1 );
}
+ nb_bits_tot = add( nb_bits_tot, ind_list[i].nb_bits );
+}
+}
- *pFrame_size = add( *pFrame_size, nb_bits_tot );
+*pFrame_size = add( *pFrame_size, nb_bits_tot );
+move16();
- return;
+return;
}
@@ -924,7 +957,7 @@ static void decoder_selectCodec(
st->Opt_AMR_WB = 1;
move16();
}
- ELSE IF( NE_32( total_brate, FRAME_NO_DATA ) )
+ ELSE IF( total_brate != FRAME_NO_DATA )
{
st->Opt_AMR_WB = 0;
move16();
@@ -1008,7 +1041,7 @@ static void decoder_selectCodec(
IF( st->ini_frame == 0 )
{
- IF( EQ_16( st->codec_mode, -1 ) )
+ if ( EQ_16( st->codec_mode, -1 ) )
{
st->codec_mode = MODE1;
move16();
@@ -1020,7 +1053,7 @@ static void decoder_selectCodec(
/* set SID/CNG type */
IF( EQ_32( total_brate, SID_2k40 ) )
{
- IF( bit0 == G192_BIN0 )
+ IF( EQ_16( bit0, G192_BIN0 ) )
{
st->cng_type = LP_CNG;
move16();
@@ -1032,6 +1065,7 @@ static void decoder_selectCodec(
ELSE
{
st->cng_type = FD_CNG;
+ move16();
test();
if ( EQ_16( st->last_codec_mode, MODE2 ) && EQ_32( st->last_total_brate, 13200 ) )
{
@@ -1040,6 +1074,7 @@ static void decoder_selectCodec(
}
}
st->hTdCngDec->last_cng_type_fx = st->cng_type; /* CNG type switching at the first correctly received SID frame */
+ move16();
}
@@ -1058,7 +1093,7 @@ void dec_prm_core( Decoder_State *st )
st->core = -1;
move16();
- IF( EQ_32( st->total_brate, FRAME_NO_DATA ) )
+ IF( st->total_brate == FRAME_NO_DATA )
{
st->m_frame_type = ZERO_FRAME;
move16();
@@ -1087,10 +1122,12 @@ void dec_prm_core( Decoder_State *st )
/* Get bandwidth mode */
st->bwidth = get_next_indice( st, FrameSizeConfig[frame_size_index].bandwidth_bits );
+ move16();
st->bwidth = add( st->bwidth, FrameSizeConfig[frame_size_index].bandwidth_min );
+ move16();
- if ( GT_16( st->bwidth, FB ) )
+ IF( GT_16( st->bwidth, FB ) )
{
st->bwidth = FB;
move16();
@@ -1098,7 +1135,8 @@ void dec_prm_core( Decoder_State *st )
move16();
}
- if ( GT_16( st->bwidth, SWB ) && LT_32( st->total_brate, ACELP_16k40 ) )
+ test();
+ IF( GT_16( st->bwidth, SWB ) && LT_32( st->total_brate, ACELP_16k40 ) )
{
st->bwidth = SWB;
move16();
@@ -1150,7 +1188,7 @@ void decision_matrix_core_dec(
move16();
test();
- IF( EQ_32( st->total_brate, FRAME_NO_DATA ) || EQ_32( st->total_brate, SID_2k40 ) )
+ IF( ( st->total_brate == FRAME_NO_DATA ) || EQ_32( st->total_brate, SID_2k40 ) )
{
st->core = ACELP_CORE;
move16();
@@ -1177,6 +1215,7 @@ void decision_matrix_core_dec(
{
/* read the ACELP/HQ core selection bit */
st->core = imult1616( get_next_indice( st, 1 ), HQ_CORE );
+ move16();
}
ELSE
{
@@ -1188,7 +1227,7 @@ void decision_matrix_core_dec(
* Read ACELP signalling bits from the bitstream
*-----------------------------------------------------------------*/
- IF( EQ_16( st->core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE )
{
/* find the section in the ACELP signalling table corresponding to bitrate */
start_idx = 0;
@@ -1208,6 +1247,7 @@ void decision_matrix_core_dec(
/* retrieve the signalling indice */
ind = acelp_sig_tbl[add( start_idx, get_next_indice( st, nBits ) )];
st->bwidth = extract_l( L_and( L_shr( ind, 3 ), 0x7 ) );
+ move16();
/* convert signalling indice into signalling information */
if ( EQ_32( L_and( ind, 0x7 ), LR_MDCT ) )
@@ -1360,7 +1400,7 @@ static void mdct_switching_dec(
/* Rewind bitstream */
st->next_bit_pos = next_bit_pos_save;
move16();
- IF( st->bfi != 0 )
+ if ( st->bfi != 0 )
{
st->core = core_save;
move16();
@@ -1418,6 +1458,7 @@ Word16 BRATE2IDX16k_fx( Word32 brate )
if ( EQ_32( brate, ACELP_16k40 ) )
{
brate = ACELP_14k80;
+ move16();
}
/* This is a Fast Bit Rate Value to Index Value Binary Search */
@@ -1449,8 +1490,8 @@ Word32 BIT_ALLOC_IDX_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc )
temp = BRATE2IDX_fx( brate );
L_temp = L_mac0( L_temp, 4 * 256, temp );
- if ( tc >= 0 )
- L_temp = L_mac0( L_temp, ( 10 - 4 ) * 256, temp );
+ IF( tc >= 0 )
+ L_temp = L_mac0( L_temp, ( 10 - 4 ) * 256, temp );
/* So either 'temp' x 4 when 'tc < 0', 'temp' x 10 otherwise */
L_temp = L_mac0( L_temp, 1 * 256, s_max( 0, tc ) );
@@ -1480,8 +1521,8 @@ Word32 BIT_ALLOC_IDX_16KHZ_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 t
temp = BRATE2IDX16k_fx( brate );
L_temp = L_mac0( L_temp, 3, temp );
- if ( tc >= 0 )
- L_temp = L_mac0( L_temp, ( 7 - 3 ), temp );
+ IF( tc >= 0 )
+ L_temp = L_mac0( L_temp, ( 7 - 3 ), temp );
/* So either 'temp' x 3 when 'tc < 0', 'temp' x 7 otherwise */
L_temp = L_mac0( L_temp, 1, s_max( 0, tc ) );
@@ -1521,25 +1562,29 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
Word16 num_bits_read;
st->bfi = 0;
+ move16();
st->BER_detect = 0;
+ move16();
st->mdct_sw_enable = 0;
+ move16();
st->mdct_sw = 0;
+ move16();
reset_indices_dec_fx( st );
/* read the Sync Header field from the bitstream */
/* in case rew_flag is set, read until first good frame is encountered */
- do
+ DO
{
/* read the Sync header */
- if ( fread( &utmp, sizeof( unsigned short ), 1, file ) != 1 )
+ IF( NE_32( fread( &utmp, sizeof( unsigned short ), 1, file ), 1 ) )
{
- if ( ferror( file ) )
+ IF( ferror( file ) )
{
/* error during reading */
fprintf( stderr, "\nError reading the bitstream !" );
exit( -1 );
}
- else
+ ELSE
{
/* end of file reached */
return 0;
@@ -1547,39 +1592,39 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
}
/* set the BFI indicator according the value of Sync Header */
- if ( EQ_16( utmp, SYNC_BAD_FRAME ) )
+ IF( EQ_16( utmp, SYNC_BAD_FRAME ) )
{
st->bfi = 1;
+ move16();
}
-
-
- else
+ ELSE
{
st->bfi = 0;
+ move16();
}
/* read the Frame Length field from the bitstream */
- if ( fread( &num_bits, sizeof( unsigned short ), 1, file ) != 1 )
+ IF( NE_32( fread( &num_bits, sizeof( unsigned short ), 1, file ), 1 ) )
{
- if ( ferror( file ) )
+ IF( ferror( file ) )
{
/* error during reading */
fprintf( stderr, "\nError reading the bitstream !" );
exit( -1 );
}
- else
+ ELSE
{
/* end of file reached */
return 0;
}
}
/* convert the frame length to total bitrate */
- total_brate = (long) ( num_bits * 50 );
+ total_brate = L_mult0( num_bits, 50 );
/* read ITU-T G.192 serial stream of indices from file to the local buffer */
/* Validate that the G.192 length is within the defined bit rate range
to not allow writing past the end of the "stream" buffer */
- if ( num_bits > MAX_BITS_PER_FRAME )
+ IF( GT_16( num_bits, MAX_BITS_PER_FRAME ) )
{
fprintf( stderr, "\nError, too large G.192 frame (size(%d))! Exiting ! \n", num_bits );
exit( -1 );
@@ -1587,7 +1632,7 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
/* verify that a valid num bits value is present in the G.192 file */
/* only AMRWB or EVS bit rates or 0(NO DATA) are allowed in G.192 file frame reading */
- if ( rate2EVSmode( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */
+ IF( rate2EVSmode( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */
{
fprintf( stderr, "\nError, illegal bit rate (%d) in the G.192 frame ! Exiting ! \n", total_brate );
exit( -1 );
@@ -1595,63 +1640,77 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
pt_stream = stream;
num_bits_read = (Word16) fread( pt_stream, sizeof( unsigned short ), num_bits, file );
+ move16();
- if ( num_bits_read != num_bits )
+ IF( NE_16( num_bits_read, num_bits ) )
{
fprintf( stderr, "\nError, invalid number of bits read ! Exiting ! \n" );
exit( -1 );
}
-
- } while ( rew_flag && ( st->bfi || LT_32( total_brate, 2800 ) ) );
+ test();
+ }
+ WHILE( rew_flag && ( st->bfi || LT_32( total_brate, 2800 ) ) );
/* G.192 RX DTX handler*/
- if ( !rew_flag )
+ IF( !rew_flag )
{
/* handle SID_FIRST, SID_BAD, SPEECH_LOST, NO_DATA as properly as possible for the ITU-T G.192 format */
/* (total_brate, bfi , st_CNG) = rx_handler(received frame type, [previous frame type], past CNG state, past core) */
curr_ft_good_sp = 0;
+ move16();
curr_ft_bad_sp = 0;
+ move16();
- if ( total_brate > SID_2k40 )
+ IF( GT_32( total_brate, SID_2k40 ) )
{
- if ( st->bfi == 0 )
+ IF( st->bfi == 0 )
{
curr_ft_good_sp = 1;
+ move16();
}
- else
+ ELSE
{
curr_ft_bad_sp = 1;
+ move16();
}
}
sid_update = 0;
+ move16();
sid_upd_bad = 0;
+ move16();
- if ( total_brate == SID_1k75 || total_brate == SID_2k40 )
+ test();
+ IF( total_brate == SID_1k75 || total_brate == SID_2k40 )
{
- if ( st->bfi == 0 )
+ IF( st->bfi == 0 )
{
sid_update = 1;
+ move16();
}
- else
+ ELSE
{
sid_upd_bad = 1; /* may happen in CS , corrupt but detected sid frame */
+ move16();
}
}
/* all zero indeces/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain */
/* all zero indeces/bits may be a result of CS bit errors and/or erroneously injected by gateways or by a bad dejitter handlers */
- if ( total_brate == SID_1k75 && sid_update == 1 )
+ test();
+ IF( EQ_32( total_brate, SID_1k75 ) && EQ_16( sid_update, 1 ) )
{
/* valid sid_update received, check for very risky but formally valid content */
Word16 sum = 0;
- for ( k = 0; k < num_bits; ++k )
+ move16();
+ FOR( k = 0; k < num_bits; ++k )
{
- sum += ( pt_stream[k] == G192_BIN1 ); /* check of 35 zeroes, 35 ones */
+ sum = add( sum, extract_l( EQ_16( pt_stream[k], G192_BIN1 ) ) ); /* check of 35 zeroes, 35 ones */
}
if ( sum == 0 )
{ /* all zeros */
sid_upd_bad = 1; /* initial signal as corrupt (BER likley) */
+ move16();
}
}
@@ -1662,14 +1721,21 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR .
*/
- if ( sid_upd_bad )
+ IF( sid_upd_bad )
{
sid_upd_bad = 0;
+ move16();
total_brate = FRAME_NO_DATA; /* treat SID_BAD as a stolen signaling frame --> SPEECH LOST */
+ move32();
}
g192_sid_first = 0;
- if ( st->core == AMR_WB_CORE && st->prev_ft_speech_fx && total_brate == FRAME_NO_DATA && st->bfi == 0 )
+ move16();
+
+ test();
+ test();
+ test();
+ if ( EQ_16( st->core, AMR_WB_CORE ) && st->prev_ft_speech_fx && total_brate == FRAME_NO_DATA && st->bfi == 0 )
{
g192_sid_first = 1; /* SID_FIRST detected for previous AMRWB/AMRWBIO active frames only */
/*
@@ -1678,43 +1744,58 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
and a good length 0 "SID_FIRST"(NO_DATA) frame is sent in AMRWBIO,
, due to the one frame state memory in the AMRWB legacy G.192 SID_FIRST encoding
*/
+ move16();
}
speech_bad = 0;
- if ( total_brate > SID_2k40 && st->bfi != 0 ) /* CS-type of CRC failure frame */
+ move16();
+
+ test();
+ if ( GT_32( total_brate, SID_2k40 ) && st->bfi != 0 ) /* CS-type of CRC failure frame */
{
speech_bad = 1; /* initial assumption, CNG_state decides what to do */
+ move16();
}
speech_lost = 0;
+ move16();
+
+ test();
if ( total_brate == 0 && st->bfi != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */
{
speech_lost = 1; /* initial assumption, CNG_state decides what to do */
+ move16();
}
/* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame
as this frame was never transmitted, one can not know it is good and has a a length of zero ) */
- if ( st->CNG_fx != 0 )
+ IF( st->CNG_fx != 0 )
{
/* We were in CNG synthesis */
if ( curr_ft_good_sp != 0 )
{
/* only a good speech frame makes you leave CNG synthesis */
st->CNG_fx = 0;
+ move16();
}
}
- else
+ ELSE
{
/* We were in SPEECH synthesis */
/* only a received SID frame can make the decoder enter into CNG synthsis */
+ test();
+ test();
if ( g192_sid_first || sid_update || sid_upd_bad )
{
st->CNG_fx = 1;
+ move16();
}
}
/* handle the g.192 _simulated_ untransmitted frame, setting for decoder SPEECH synthesis */
+ test();
+ test();
if ( ( st->CNG_fx == 0 ) && ( total_brate == 0 && st->bfi == 0 ) )
{
st->bfi = 1;
@@ -1723,14 +1804,21 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
}
/* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */
+ test();
+ test();
+ test();
if ( ( ( st->CNG_fx != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */
( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */
{
st->bfi = 0;
+ move16();
total_brate = 0;
+ move32();
}
/* update for next frame's G.192 file format's SID_FIRST detection (primarily for AMRWBIO) */
+ test();
st->prev_ft_speech_fx = ( ( curr_ft_good_sp != 0 ) || ( curr_ft_bad_sp != 0 ) );
+ move16();
/* st->total brate= total_brate ; updated in a good frame below */
} /* rew_flag */
@@ -1739,7 +1827,8 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
#ifdef DEBUGGING
st->bfi |= file_read_FECpattern();
#endif
- if ( st->bfi == 0 && !rew_flag )
+ test();
+ IF( st->bfi == 0 && !rew_flag )
{
/* select MODE1 or MODE2 */
decoder_selectCodec( st, total_brate, *pt_stream );
@@ -1747,10 +1836,11 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
Mpy_32_16_ss( total_brate, 5243, &L_tmp, &utmp ); /* 5243 is 1/50 in Q18. (0+18-15=3) */
st->total_num_bits = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */
+ move16();
/* in case rew_flag is set, rewind the file and return */
/* (used in io_enc() to print out info about technologies and to initialize the codec) */
- if ( rew_flag )
+ IF( rew_flag )
{
rewind( file );
st->total_brate = total_brate;
@@ -1759,24 +1849,27 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem
}
/* GOOD frame */
- if ( st->bfi == 0 )
+ IF( st->bfi == 0 )
{
/* GOOD frame - convert ITU-T G.192 words to short values */
bit_stream_ptr = st->bit_stream;
- for ( k = 0; k < num_bits; ++k )
+ FOR( k = 0; k < num_bits; ++k )
{
- *bit_stream_ptr++ = ( *pt_stream++ == G192_BIN1 );
+ *bit_stream_ptr++ = (UWord16) EQ_32( *pt_stream++, G192_BIN1 );
+ move16();
}
/*add two zero bytes for arithmetic coder flush*/
- for ( k = 0; k < 2 * 8; ++k )
+ FOR( k = 0; k < 2 * 8; ++k )
{
*bit_stream_ptr++ = 0;
+ move16();
}
/*a change of the total bitrate should not be
known to the decoder, if the received frame was lost*/
st->total_brate = total_brate;
+ move32();
mdct_switching_dec( st );
}
@@ -1815,87 +1908,115 @@ static Word32 read_indices_mime_handle_dtx(
Word16 speech_bad = 0;
Word16 sid_upd_bad = 0, sid_update = 0;
Word16 amrwb_sid_first = 0; /* derived from sti SID_FIRST indicator in AMRWB payload */
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
/* keep st->CNG , st_bfi and total_brate updated for proper synthesis in DTX and FER */
- if ( GT_32( total_brate, SID_2k40 ) )
+ IF( GT_32( total_brate, SID_2k40 ) )
{
- if ( st->bfi != 1 ) /* so far derived from q bit in AMRWB/AMRWBIO cases */
+ if ( NE_16( st->bfi, 1 ) ) /* so far derived from q bit in AMRWB/AMRWBIO cases */
{
curr_ft_good_sp = 1;
+ move16();
}
}
/* handle q_bit and lost_sp clash , assume worst case */
- if ( speech_lost != 0 ) /* overrides a good q_bit */
+ IF( speech_lost != 0 ) /* overrides a good q_bit */
{
curr_ft_good_sp = 0;
+ move16();
st->bfi = 1; /* override qbit */
+ move16();
}
/* now_bfi_fx has been set based on q_bit and ToC fields */
/* SID_UPDATE check */
- if ( total_brate == SID_1k75 || total_brate == SID_2k40 )
+ test();
+ IF( total_brate == SID_1k75 || total_brate == SID_2k40 )
{
- if ( st->bfi == 0 )
+ IF( st->bfi == 0 )
{
/* typically from q bit */
sid_update = 1;
+ move16();
}
- else
+ ELSE
{
sid_upd_bad = 1; /* may happen in saving from e.g. a CS-connection */
+ move16();
}
}
- if ( isAMRWB_IOmode && total_brate == 0 && sti == 0 )
+ test();
+ test();
+ IF( isAMRWB_IOmode && total_brate == 0 && sti == 0 )
{
- if ( st->bfi )
+ IF( st->bfi )
{
sid_upd_bad = 1; /* corrupt sid_first, signaled as bad sid */
+ move16();
}
- else
+ ELSE
{
amrwb_sid_first = 1; /* 1-sti */
+ move16();
}
}
- if ( sid_upd_bad != 0 && ( ( isAMRWB_IOmode != 0 && st->Opt_AMR_WB == 0 ) || /* switch to AMRWBIO */
- ( isAMRWB_IOmode != 1 && st->Opt_AMR_WB == 1 ) /* switch from AMRWBIO */
- ) )
+ test();
+ test();
+ test();
+ test();
+ IF( sid_upd_bad != 0 && ( ( isAMRWB_IOmode != 0 && st->Opt_AMR_WB == 0 ) || /* switch to AMRWBIO */
+ ( NE_16( isAMRWB_IOmode, 1 ) && EQ_16( st->Opt_AMR_WB, 1 ) ) /* switch from AMRWBIO */
+ ) )
{
/* do not allow a normal start of CNG synthesis if this SID(with BER or FER) is a switch to/from AMRWBIO */
sid_upd_bad = 0; /* revert this detection due to AMRWBIO/EVS mode switch */
+ move16();
total_brate = 0;
+ move32();
no_data = 1;
+ move16();
assert( st->bfi == 1 ); /* bfi stays 1 */
}
- if ( GT_32( total_brate, SID_2k40 ) && st->bfi == 1 ) /* typically from q bit */
+ test();
+ if ( GT_32( total_brate, SID_2k40 ) && EQ_16( st->bfi, 1 ) ) /* typically from q bit */
{
speech_bad = 1; /* initial assumption, CNG synt state decides what to actually do */
+ move16();
}
/* all frame types decoded */
/* update CNG synthesis state */
/* Decoder can only enter CNG-synthesis for CNG frame types (sid_upd, sid_bad, sid_first) */
- if ( st->CNG_fx != 0 )
+ IF( st->CNG_fx != 0 )
{
/* We were in CNG synthesis */
if ( curr_ft_good_sp != 0 )
{
/* only a good speech frame makes decoder leave CNG synthesis */
st->CNG_fx = 0;
+ move16();
}
}
- else
+ ELSE
{
/* We were in SPEECH synthesis */
/* only a received SID frame can make the decoder enter into CNG synthesis */
+ test();
+ test();
if ( amrwb_sid_first || sid_update || sid_upd_bad )
{
st->CNG_fx = 1;
+ move16();
}
}
@@ -1903,20 +2024,28 @@ static Word32 read_indices_mime_handle_dtx(
/* in SPEECH synthesis, make sure to activate speech plc for a received no_data frame,
no_data frames may be injected by the network or by the dejitter buffer */
/* modify bfi_flag to stay/move into the correct decoder PLC section */
+ test();
if ( ( st->CNG_fx == 0 ) && ( no_data != 0 ) )
{
/* treat no_data received in speech synthesis as SP_LOST frames, SPEECH PLC code will now become active */
st->bfi = 1;
+ move16();
/* total_brate= 0; always zero for no_data */
}
/* in CNG */
/* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */
- if ( ( st->CNG_fx != 0 && ( speech_bad || speech_lost || no_data ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */
- sid_upd_bad ) /* SID_UPD_BAD --> start/stay CNG */
+ test();
+ test();
+ test();
+ test();
+ IF( ( st->CNG_fx != 0 && ( speech_bad || speech_lost || no_data ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */
+ sid_upd_bad ) /* SID_UPD_BAD --> start/stay CNG */
{
- st->bfi = 0; /* mark as good to not start speech PLC */
+ st->bfi = 0; /* mark as good to not start speech PLC */
+ move16();
total_brate = 0; /* this zeroing needed for speech_bad, sid_bad frames */
+ move32();
}
@@ -1929,22 +2058,33 @@ static Word32 read_indices_mime_handle_dtx(
/* handle available AMRWB/AMRWBIO MIME header ToC rate-info at startup */
- if ( ( st->bfi == 1 && st->ini_frame == 0 ) &&
- ( ( st->amrwb_rfc4867_flag != 0 ) || ( st->amrwb_rfc4867_flag == 0 && isAMRWB_IOmode != 0 ) ) ) /*AMRWB ToC */
+ test();
+ test();
+ test();
+ test();
+ IF( ( EQ_16( st->bfi, 1 ) && st->ini_frame == 0 ) &&
+ ( ( st->amrwb_rfc4867_flag != 0 ) || ( st->amrwb_rfc4867_flag == 0 && isAMRWB_IOmode != 0 ) ) ) /*AMRWB ToC */
{
Word32 init_rate;
init_rate = total_brate; /* default , may have been modified from original ToC value */
- if ( speech_lost != 0 || no_data != 0 )
+ move32();
+
+ test();
+ IF( speech_lost != 0 || no_data != 0 )
{
init_rate = ACELP_12k65; /* make sure the decoder starts up in a selected AMRWB mode */
+ move32();
}
- else if ( speech_bad != 0 )
+ ELSE IF( speech_bad != 0 )
{
init_rate = AMRWB_IOmode2rate[core_mode]; /* read from from ToC */
+ move32();
}
st->total_brate = init_rate; /* not updated on bfi as decoderSelectCodec is not called below */
+ move32();
st->core_brate = init_rate;
+ move32();
}
return total_brate;
@@ -1964,27 +2104,31 @@ static void read_indices_mime_handle_sti_and_all_zero_bits(
{
Word16 k;
- if ( sti == 0 )
+ IF( sti == 0 )
{
*total_brate = 0; /* signal received SID_FIRST as a good frame with no bits */
- for ( k = 0; k < 35; k++ )
+ move32();
+ FOR( k = 0; k < 35; k++ )
{
- st->bfi |= st->bit_stream[k]; /* partity check of 35 zeroes, any single 1 gives BFI */
+ st->bfi = s_or( st->bfi, st->bit_stream[k] ); /* partity check of 35 zeroes, any single 1 gives BFI */
+ move16();
}
}
/* all zero bit SID_update results in a valid LP filter with extremely high LP-filter-gain */
/* all zero bits signal may be a result of CS bit errors or erronesouly injected by gateways or bad dejitter handlers */
- if ( sti == 1 )
+ IF( EQ_16( sti, 1 ) )
{ /*sid_update received */
Word16 sum = 0;
- for ( k = 0; k < 35; k++ )
+ move16();
+ FOR( k = 0; k < 35; k++ )
{
- sum += st->bit_stream[k]; /* check of 35 zeroes */
+ sum = add( sum, st->bit_stream[k] ); /* check of 35 zeroes */
}
if ( sum == 0 )
{
st->bfi = 1; /* eventually becomes SID_UPD_BAD */
+ move16();
}
}
}
@@ -2015,22 +2159,31 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem
Word16 speech_lost = 0, no_data = 0;
Word16 num_bytes_read;
+ move16();
+ move16();
+ move16();
+ move16();
+
st->BER_detect = 0;
+ move16();
st->bfi = 0;
+ move16();
st->mdct_sw_enable = 0;
+ move16();
st->mdct_sw = 0;
+ move16();
reset_indices_dec_fx( st );
/* read the FT Header field from the bitstream */
- if ( fread( &header, sizeof( UWord8 ), 1, file ) != 1 )
+ IF( NE_32( fread( &header, sizeof( UWord8 ), 1, file ), 1 ) )
{
- if ( ferror( file ) )
+ IF( ferror( file ) )
{
/* error during reading */
fprintf( stderr, "\nError reading the bitstream !" );
exit( -1 );
}
- else
+ ELSE
{
/* end of file reached */
return 0;
@@ -2039,8 +2192,9 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem
/* init local RXDTX flags */
sti = -1;
+ move16();
- if ( st->amrwb_rfc4867_flag != 0 )
+ IF( st->amrwb_rfc4867_flag != 0 )
{
/* RFC 4867
5.3 ....
@@ -2054,12 +2208,16 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem
Section 4.3.2. The P bits are padding and MUST be set to 0, and MUST be ignored. */
isAMRWB_IOmode = 1;
- qbit = ( header >> 2 ) & 0x01; /* b2 bit (b7 is the F bit ) */
+ move16();
+ qbit = s_and( shr( header, 2 ), 0x01 ); /* b2 bit (b7 is the F bit ) */
+ move16();
st->bfi = !qbit;
- core_mode = ( ( header >> 3 ) & 0x0F ); /* b6..b3 */
- total_brate = AMRWB_IOmode2rate[core_mode]; /* get the frame length from the header */
+ move16();
+ core_mode = s_and( shr( header, 3 ), 0x0F ); /* b6..b3 */
+ total_brate = AMRWB_IOmode2rate[core_mode]; /* get the frame length from the header */
+ move32();
}
- else
+ ELSE
{
/*0 1 2 3 4 5 6 7 MS-bit ---> LS-bit
+-+-+-+-+-+-+-+-+
@@ -2071,40 +2229,47 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem
x is the q-bit if E=1, q==1(good), Q==0(bad, maybe bit errors in payload )
H,F always 0 in RTP format.
*/
- isAMRWB_IOmode = ( header & 0x20 ) > 0; /* get EVS mode-from header */ /* b2 */
- core_mode = ( header & 0x0F ); /* b4,b5,b6,b7 */
+ isAMRWB_IOmode = extract_l( GT_16( s_and( header, 0x20 ), 0 ) ); /* get EVS mode-from header */ /* b2 */
+ core_mode = s_and( header, 0x0F ); /* b4,b5,b6,b7 */
- if ( isAMRWB_IOmode )
+ IF( isAMRWB_IOmode )
{
- qbit = ( header & 0x10 ) > 0; /* get Q bit, valid for IO rates */ /* b3 */
+ qbit = extract_l( GT_16( s_and( header, 0x10 ), 0 ) ); /* get Q bit, valid for IO rates */ /* b3 */
total_brate = AMRWB_IOmode2rate[core_mode];
+ move32();
}
- else
+ ELSE
{
qbit = 1; /* assume good q_bit for the unused EVS-mode bit, complete ToC validity checked later */
+ move16();
total_brate = PRIMARYmode2rate[core_mode];
+ move32();
}
st->bfi = !qbit;
+ move16();
}
/* set up RX-DTX-handler input */
- if ( core_mode == 14 )
+ if ( EQ_16( core_mode, 14 ) )
{
/* SP_LOST */
speech_lost = 1;
+ move16();
}
- if ( core_mode == 15 )
+ if ( EQ_16( core_mode, 15 ) )
{
/* NO_DATA unsent CNG frame OR any frame marked or injected as no_data by e.g a signaling layer or dejitter buffer */
no_data = 1;
+ move16();
}
Mpy_32_16_ss( total_brate, 5243, &L_tmp, &utmp ); /* 5243 is 1/50 in Q18. (0+18-15=3) */
num_bits = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */
st->total_num_bits = num_bits;
+ move16();
- if ( total_brate < 0 )
+ IF( total_brate < 0 )
{
/* validate that total_brate (derived from RTP packet or a file header) is one of the defined bit rates */
fprintf( stderr, "\n Error. Illegal total bit rate (= %d) in MIME ToC header \n", total_brate );
@@ -2112,26 +2277,33 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem
}
/* Check correctness of ToC headers */
- if ( st->amrwb_rfc4867_flag == 0 )
+ IF( st->amrwb_rfc4867_flag == 0 )
{
/* EVS ToC header (FT field(b2-b7), H bit (b0), F bit (b1) , (EVS-modebit(b2)=0 unused(Qbit)(b3)==0) */
- if ( ( isAMRWB_IOmode == 0 ) && ( ( num_bits < 0 ) || ( ( header & 0x80 ) > 0 ) || ( ( header & 0x40 ) > 0 ) || ( header & 0x30 ) != 0x00 ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( isAMRWB_IOmode == 0 ) && ( ( num_bits < 0 ) || ( s_and( header, 0x80 ) > 0 ) || ( s_and( header, 0x40 ) > 0 ) || s_and( header, 0x30 ) != 0x00 ) )
{
/* incorrect FT header */
fprintf( stderr, "\nError in EVS FT ToC header(%02x) ! ", header );
exit( -1 );
}
- else if ( ( isAMRWB_IOmode != 0 ) && ( ( num_bits < 0 ) || ( ( header & 0x80 ) > 0 ) || ( ( header & 0x40 ) > 0 ) ) ) /* AMRWBIO */
+ ELSE IF( ( isAMRWB_IOmode != 0 ) && ( ( num_bits < 0 ) || ( s_and( header, 0x80 ) > 0 ) || ( s_and( header, 0x40 ) > 0 ) ) ) /* AMRWBIO */
{
/* incorrect IO FT header */
fprintf( stderr, "\nError in EVS(AMRWBIO) FT ToC header(%02x) ! ", header );
exit( -1 );
}
}
- else
+ ELSE
{
/* legacy AMRWB ToC, is only using Padding bits which MUST be ignored */
- if ( num_bits < 0 )
+ IF( num_bits < 0 )
{
/* incorrect FT header */
fprintf( stderr, "\nError in AMRWB RFC4867 Toc(FT) header(%02x) !", header );
@@ -2140,8 +2312,8 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem
}
/* read serial stream of indices from file to the local buffer */
- num_bytes_read = (Word16) fread( pFrame, sizeof( UWord8 ), ( num_bits + 7 ) >> 3, file );
- if ( num_bytes_read != ( num_bits + 7 ) >> 3 )
+ num_bytes_read = extract_l( fread( pFrame, sizeof( UWord8 ), shr( add( num_bits, 7 ), 3 ), file ) );
+ IF( NE_16( num_bytes_read, shr( add( num_bits, 7 ), 3 ) ) )
{
fprintf( stderr, "\nError, invalid number of bytes read ! Exiting ! \n" );
exit( -1 );
@@ -2149,10 +2321,13 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem
/* in case rew_flag is set, rewind the file and return */
/* (used in io_dec() to attempt print out info about technologies and to initialize the codec ) */
- if ( rew_flag )
+ IF( rew_flag )
{
st->total_brate = total_brate; /* used for the codec banner output */
- if ( st->bfi == 0 && speech_lost == 0 && no_data == 0 )
+ move32();
+ test();
+ test();
+ IF( st->bfi == 0 && speech_lost == 0 && no_data == 0 )
{
decoder_selectCodec( st, total_brate, unpack_bit( &pt_pFrame, &mask ) ? G192_BIN1 : G192_BIN0 );
}
@@ -2162,51 +2337,56 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem
/* unpack speech data */
bit_stream_ptr = st->bit_stream;
- for ( k = 0; k < num_bits; k++ )
+ FOR( k = 0; k < num_bits; k++ )
{
- if ( isAMRWB_IOmode )
+ IF( isAMRWB_IOmode )
{
st->bit_stream[sort_ptr[core_mode][k]] = unpack_bit( &pt_pFrame, &mask );
+ move16();
bit_stream_ptr++;
}
- else
+ ELSE
{
*bit_stream_ptr++ = unpack_bit( &pt_pFrame, &mask );
+ move16();
}
}
/* unpack auxiliary bits */
/* Note: the cmi bits are unpacked for demo purposes; */
- if ( isAMRWB_IOmode && total_brate == SID_1k75 )
+ test();
+ IF( isAMRWB_IOmode && EQ_32( total_brate, SID_1k75 ) )
{
sti = unpack_bit( &pt_pFrame, &mask );
- cmi = unpack_bit( &pt_pFrame, &mask ) << 3;
- cmi |= unpack_bit( &pt_pFrame, &mask ) << 2;
- cmi |= unpack_bit( &pt_pFrame, &mask ) << 1;
- cmi |= unpack_bit( &pt_pFrame, &mask );
+ cmi = shl( unpack_bit( &pt_pFrame, &mask ), 3 );
+ cmi = s_or( cmi, shl( unpack_bit( &pt_pFrame, &mask ), 2 ) );
+ cmi = s_or( cmi, shl( unpack_bit( &pt_pFrame, &mask ), 1 ) );
+ cmi = s_or( cmi, unpack_bit( &pt_pFrame, &mask ) );
read_indices_mime_handle_sti_and_all_zero_bits( st, &total_brate, sti );
}
/*add two zero bytes for arithmetic coder flush*/
- for ( k = 0; k < 2 * 8; ++k )
+ FOR( k = 0; k < 2 * 8; ++k )
{
*bit_stream_ptr++ = 0;
+ move16();
}
/* MIME RX_DTX handler */
- if ( !rew_flag )
+ IF( !rew_flag )
{
total_brate = read_indices_mime_handle_dtx( st, isAMRWB_IOmode, core_mode, total_brate, sti, speech_lost, no_data );
}
- if ( st->bfi == 0 )
+ IF( st->bfi == 0 )
{
/* select MODE1 or MODE2 in MIME */
decoder_selectCodec( st, total_brate, *st->bit_stream ? G192_BIN1 : G192_BIN0 );
/* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */
st->total_brate = total_brate;
+ move32();
mdct_switching_dec( st );
}
/* else{ bfi stay in past synthesis mode(SP,CNG) } */
@@ -2226,7 +2406,9 @@ static void berCheck(
)
{
/* In case of RF flag = 1, and valid RF packet with primary and partial copy */
- if ( ( EQ_16( st->bwidth, NB ) || EQ_16( st->bwidth, FB ) ) || ( GE_16( *coder_type, TRANSITION ) ) )
+ test();
+ test();
+ IF( ( EQ_16( st->bwidth, NB ) || EQ_16( st->bwidth, FB ) ) || ( GE_16( *coder_type, TRANSITION ) ) )
{
if ( EQ_16( st->use_partial_copy, 1 ) )
{
@@ -2271,13 +2453,17 @@ void getPartialCopyInfo(
/* reset number of target bits in case of rate switching */
st->rf_target_bits = 0;
+ move16();
/* Get the number of bits used for RF*/
IF( EQ_16( st->rf_flag, 1 ) )
{
*coder_type = s_and( ind, 0x7 );
+ move16();
st->bwidth = s_and( shr( ind, 3 ), 0x7 );
+ move16();
*sharpFlag = s_and( shr( ind, 6 ), 0x1 );
+ move16();
st->codec_mode = MODE2;
move16();
get_rfTargetBits( st->rf_frame_type, &( st->rf_target_bits ) );
@@ -2285,17 +2471,22 @@ void getPartialCopyInfo(
IF( EQ_16( st->bfi, FRAMEMODE_FUTURE ) )
{
st->use_partial_copy = 1;
+ move16();
/* now set the frame mode to normal mode */
test();
IF( GE_16( st->rf_frame_type, RF_TCXFD ) && LE_16( st->rf_frame_type, RF_TCXTD2 ) )
{
st->bfi = 1;
+ move16();
st->core = 1;
+ move16();
}
ELSE
{
st->bfi = FRAMEMODE_NORMAL;
+ move16();
st->core = 0;
+ move16();
}
}
/* check for bit errors */
@@ -2322,14 +2513,16 @@ void get_rfFlag(
/* Init */
*rf_flag = 0;
+ move16();
/* check for rf_flag in the packet and extract the rf_frame_type and rf_fec_offset */
test();
test();
- IF( EQ_32( st->total_brate, ACELP_13k20 ) && ( EQ_16( st->bfi, FRAMEMODE_NORMAL ) || EQ_16( st->bfi, FRAMEMODE_FUTURE ) ) )
+ IF( EQ_32( st->total_brate, ACELP_13k20 ) && ( ( st->bfi == FRAMEMODE_NORMAL ) || EQ_16( st->bfi, FRAMEMODE_FUTURE ) ) )
{
/* find the section in the ACELP signalling table corresponding to bitrate */
start_idx = 0;
+ move16();
WHILE( NE_32( acelp_sig_tbl[start_idx], st->total_brate ) )
{
start_idx++;
@@ -2341,21 +2534,26 @@ void get_rfFlag(
/* retrieve the number of bits */
nBits_tmp = (Word16) acelp_sig_tbl[start_idx++];
+ move16();
/* retrieve the signalling indice */
- ind_tmp = (Word16) acelp_sig_tbl[start_idx + get_indice( st, 0, nBits_tmp )];
+ ind_tmp = (Word16) acelp_sig_tbl[add( start_idx, get_indice( st, 0, nBits_tmp ) )];
+ move16();
/* convert signalling indice into RF flag. */
*rf_flag = s_and( shr( ind_tmp, 7 ), 0x1 );
+ move16();
if ( ind )
{
*ind = ind_tmp;
+ move16();
}
if ( nBits )
{
*nBits = nBits_tmp;
+ move16();
}
}
}
@@ -2372,16 +2570,17 @@ void get_rfFrameType(
)
{
Word16 num_bits = 0;
+ move16();
IF( EQ_16( st->rf_flag, 1 ) )
{
/*num_bits = st->total_brate/50;*/
- if ( EQ_32( st->total_brate, ACELP_13k20 ) )
+ IF( EQ_32( st->total_brate, ACELP_13k20 ) )
{
num_bits = 264;
move16(); /* @13.2kbps */
}
- else
+ ELSE
{
UWord16 lsb;
Word32 L_tmp;
@@ -2390,11 +2589,13 @@ void get_rfFrameType(
}
/* the last three bits in a packet is the RF frame type */
- *rf_frame_type = get_indice( st, num_bits - 3, 3 );
+ *rf_frame_type = get_indice( st, sub( num_bits, 3 ), 3 );
+ move16();
}
ELSE
{
*rf_frame_type = 0;
+ move16();
}
}
@@ -2414,12 +2615,12 @@ void get_rf_fec_offset(
IF( EQ_16( st->rf_flag, 1 ) )
{
/*num_bits = st->total_brate/50;*/
- if ( EQ_32( st->total_brate, ACELP_13k20 ) )
+ IF( EQ_32( st->total_brate, ACELP_13k20 ) )
{
num_bits = 264;
move16(); /* @13.2kbps */
}
- else
+ ELSE
{
UWord16 lsb;
Word32 L_tmp;
@@ -2428,16 +2629,17 @@ void get_rf_fec_offset(
}
/* the two bits before the rf frame type contain the fec offset */
- tmp = get_indice( st, num_bits - 5, 2 );
+ tmp = get_indice( st, sub( num_bits, 5 ), 2 );
- if ( tmp == 0 )
+ IF( tmp == 0 )
{
*rf_fec_offset = 2;
move16();
}
- else
+ ELSE
{
*rf_fec_offset = add( shl( tmp, 1 ), 1 );
+ move16();
}
}
ELSE
@@ -2465,31 +2667,39 @@ void get_rfTargetBits(
{
case RF_NO_DATA:
*rf_target_bits = 5;
+ move16();
BREAK;
case RF_TCXFD:
*rf_target_bits = 27;
+ move16();
BREAK;
case RF_TCXTD1:
*rf_target_bits = 16;
+ move16();
BREAK;
case RF_TCXTD2:
*rf_target_bits = 16;
+ move16();
BREAK;
case RF_ALLPRED:
/* 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 = 63;
+ move16();
BREAK;
case RF_NOPRED:
/* Es_pred bits 3 bits, LTF: 0, pitch: 0, FCB: 7,7,7,7, gain: 6,0,6,0, Diff GFr: 2*/
*rf_target_bits = 66;
+ move16();
BREAK;
case RF_GENPRED:
/* Es_pred bits 3 bits, LTF: 1, pitch: 8,0,8,0, FCB: 6,7,5,5, gain: 5,0,5,0, Diff GFr: 0*/
*rf_target_bits = 70;
+ move16();
BREAK;
case RF_NELP:
/* gain: 19, Diff GFr: 5 */
*rf_target_bits = 45;
+ move16();
BREAK;
}
}
@@ -2515,9 +2725,11 @@ void get_NextCoderType_fx(
FOR( k = 0; k < ACELP_13k20 / 50; k++ )
{
- bit_stream[k] = ( bitsteam[k / 8] >> ( 7 - ( k % 8 ) ) ) & 0x1;
+ bit_stream[k] = (UWord8) s_and( shr( bitsteam[k / 8], sub( 7, ( k % 8 ) ) ), 0x1 );
+ move16();
}
start_idx = 0;
+ move16();
WHILE( NE_32( acelp_sig_tbl[start_idx], ACELP_13k20 ) )
{
start_idx = add( start_idx, 1 );
@@ -2530,13 +2742,15 @@ void get_NextCoderType_fx(
tmp = 0;
move16();
nBits_tmp = (Word16) acelp_sig_tbl[start_idx++];
+ move16();
FOR( k = 0; k < nBits_tmp; k++ )
{
tmp = lshl( tmp, 1 );
tmp = add( tmp, bit_stream[k] );
}
/* retrieve the signalling indice */
- *next_coder_type = s_and( (Word16) acelp_sig_tbl[start_idx + tmp], 0x7 );
+ *next_coder_type = s_and( (Word16) acelp_sig_tbl[add( start_idx, tmp )], 0x7 );
+ move16();
}
/*-------------------------------------------------------------------*
@@ -2564,84 +2778,110 @@ void read_indices_from_djb_fx(
Word32 total_brate;
Word16 speech_lost = 0;
+ move16();
+ move16();
+ move16();
+ move16();
+
st->bfi = 0;
+ move16();
st->BER_detect = 0;
+ move16();
st->mdct_sw_enable = 0;
+ move16();
st->mdct_sw = 0;
+ move16();
reset_indices_dec_fx( st );
st->bfi = !qbit;
- total_brate = (Word32) (num_bits) *50;
+ move16();
+ total_brate = L_mult0( num_bits, 50 );
st->total_num_bits = num_bits;
+ move16();
- if ( num_bits == 0 ) /* guess type of missing frame for SP_LOST and NO_DATA */
+ IF( num_bits == 0 ) /* guess type of missing frame for SP_LOST and NO_DATA */
{
speech_lost = st->CNG_fx == 0;
+ move16();
+ move16();
no_data = st->CNG_fx != 0;
+ move16();
+ move16();
}
- if ( partialframe || st->prev_use_partial_copy )
+ test();
+ IF( partialframe || st->prev_use_partial_copy )
{
st->next_coder_type = next_coder_type;
+ move16();
}
- else
+ ELSE
{
st->next_coder_type = INACTIVE;
+ move16();
}
- if ( partialframe == 1 )
+ if ( EQ_16( partialframe, 1 ) )
{
st->bfi = 2;
+ move16();
}
/* unpack speech data */
bit_stream_ptr = st->bit_stream;
/* convert bitstream from compact bytes to short values and store it in decoder state */
- for ( k = 0; k < num_bits; k++ )
+ FOR( k = 0; k < num_bits; k++ )
{
- if ( st->bitstreamformat == VOIP_RTPDUMP && isAMRWB_IOmode )
+ test();
+ IF( st->bitstreamformat == VOIP_RTPDUMP && isAMRWB_IOmode )
{
st->bit_stream[sort_ptr[core_mode][k]] = unpack_bit( &pt_stream, &mask );
+ move16();
bit_stream_ptr++;
}
- else
+ ELSE
{
*bit_stream_ptr++ = unpack_bit( &pt_stream, &mask );
+ move16();
}
}
/* unpack auxiliary bits */
- if ( isAMRWB_IOmode && total_brate == SID_1k75 )
+ test();
+ IF( isAMRWB_IOmode && EQ_32( total_brate, SID_1k75 ) )
{
- if ( st->bitstreamformat == VOIP_RTPDUMP )
+ IF( EQ_16( st->bitstreamformat, VOIP_RTPDUMP ) )
{
/* A.2.2.1.3: AMR-WB SID_1k75 frame is followed by STI bit and CMI bits */
sti = unpack_bit( &pt_stream, &mask );
}
- else
+ ELSE
{
/* VOIP_G192_RTP does not contain STI and CMI */
sti = 1;
+ move16();
}
read_indices_mime_handle_sti_and_all_zero_bits( st, &total_brate, sti );
}
/* add two zero bytes for arithmetic coder flush */
- for ( k = 0; k < 8 * 2; ++k )
+ FOR( k = 0; k < 8 * 2; ++k )
{
*bit_stream_ptr++ = 0;
+ move16();
}
total_brate = read_indices_mime_handle_dtx( st, isAMRWB_IOmode, core_mode, total_brate, sti, speech_lost, no_data );
/* st->CNG_fx set inside */
- if ( st->bfi != 1 )
+ IF( NE_16( st->bfi, 1 ) )
{
/* select Mode 1 or Mode 2 */
decoder_selectCodec( st, total_brate, *st->bit_stream ? G192_BIN1 : G192_BIN0 );
/* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */
st->total_brate = total_brate;
+ move32();
mdct_switching_dec( st );
}
@@ -2668,15 +2908,17 @@ static UWord16 get_indice_preview(
bitstreamShortPtr = bitstreamShort;
FOR( i = 0; i < bitstreamSize; i++ )
{
- *bitstreamShortPtr++ = ( bitstream[i / 8] >> ( 7 - ( i % 8 ) ) ) & 0x1;
+ *bitstreamShortPtr++ = s_and( shr( bitstream[i / 8], sub( 7, ( i % 8 ) ) ), 0x1 );
+ move16();
}
assert( nb_bits <= 16 );
value = 0;
+ move16();
FOR( i = 0; i < nb_bits; i++ )
{
value = shl( value, 1 );
- value = add( value, bitstreamShort[pos + i] );
+ value = add( value, bitstreamShort[add( pos, i )] );
}
return value;
}
@@ -2698,14 +2940,18 @@ void evs_dec_previewFrame(
Word16 rf_flag;
rf_flag = 0;
+ move16();
*partialCopyFrameType = 0;
+ move16();
*partialCopyOffset = 0;
- total_brate = bitstreamSize * 50;
+ move16();
+ total_brate = L_mult0( bitstreamSize, 50 );
IF( EQ_32( total_brate, ACELP_13k20 ) )
{
/* find the section in the ACELP signalling table corresponding to bitrate */
start_idx = 0;
+ move16();
WHILE( NE_32( acelp_sig_tbl[start_idx], total_brate ) )
{
start_idx = add( start_idx, 1 );
@@ -2716,9 +2962,11 @@ void evs_dec_previewFrame(
start_idx = add( start_idx, 1 );
/* retrieve the number of bits */
nBits = (Word16) acelp_sig_tbl[start_idx++];
+ move16();
/* retrieve the signalling indice */
- ind = acelp_sig_tbl[start_idx + get_indice_preview( bitstream, bitstreamSize, 0, nBits )];
+ ind = acelp_sig_tbl[add( start_idx, get_indice_preview( bitstream, bitstreamSize, 0, nBits ) )];
+ move32();
/* convert signalling indice into RF flag. */
rf_flag = s_and( extract_l( L_shr( ind, 7 ) ), 0x1 );
@@ -2726,14 +2974,15 @@ void evs_dec_previewFrame(
IF( rf_flag != 0 )
{
/* read the fec offset at which the partial copy is received */
- ind = get_indice_preview( bitstream, bitstreamSize, ( bitstreamSize - 5 ), 2 );
+ ind = get_indice_preview( bitstream, bitstreamSize, sub( bitstreamSize, 5 ), 2 );
IF( ind == 0 ) *partialCopyOffset = 2;
ELSE IF( EQ_32( ind, 1 ) ) *partialCopyOffset = 3;
ELSE IF( EQ_32( ind, 2 ) ) *partialCopyOffset = 5;
ELSE IF( EQ_32( ind, 3 ) ) *partialCopyOffset = 7;
-
+ move16();
/* the last three bits in a packet is the RF frame type */
*partialCopyFrameType = get_indice_preview( bitstream, bitstreamSize, bitstreamSize - 3, 3 );
+ move16();
}
}
}
@@ -2748,6 +2997,7 @@ void dtx_read_padding_bits_fx(
tmp = st->total_brate;
move32();
st->total_brate = L_add( st->total_brate, L_mult0( num_bits, FRAMES_PER_SEC ) );
+ move32();
get_next_indice_fx( st, num_bits );
st->total_brate = tmp;
move32();
diff --git a/lib_com/cb_shape_fx.c b/lib_com/cb_shape_fx.c
index d8dec57d6e2b008080f310d4a5ca32814ed7af75..fcd9e06e4a237f67e8560474738803ff8d44b8b1 100644
--- a/lib_com/cb_shape_fx.c
+++ b/lib_com/cb_shape_fx.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* */
/*
* E_GAIN_f_pitch_sharpening
@@ -29,7 +28,7 @@ static void E_GAIN_f_pitch_sharpening( Word16 *x, Word16 pit_lag, Word16 L_subfr
FOR( i = pit_lag; i < L_subfr; i++ )
{
/*x[i] += x[i - pit_lag] * F_PIT_SHARP;*/
- tmp = mult_r( x[i - pit_lag], 27853 /*F_PIT_SHARP Q15*/ );
+ tmp = mult_r( x[sub( i, pit_lag )], 27853 /*F_PIT_SHARP Q15*/ );
x[i] = add( x[i], tmp );
move16();
}
@@ -101,7 +100,7 @@ void cb_shape_fx(
{
weight_a_fx( p_Aq, A_num, g1, M );
weight_a_fx( p_Aq, A_den, g2, M );
- set16_fx( buff, 0, M + L_subfr );
+ set16_fx( buff, 0, add( M, L_subfr ) );
IF( formantTiltFlag )
{
Copy( A_num, buff + M, M + 1 );
@@ -109,7 +108,7 @@ void cb_shape_fx(
E_UTIL_synthesis( 1, A_den, buff + M, buff + M, L_subfr, buff, 0, M );
/*Compute tilt of formant enhancement*/
- tilt = extract_l( L_shr( get_gain( buff + M + 1, buff + M, L_subfr - 1 ), 1 ) );
+ tilt = extract_l( L_shr( get_gain( buff + M + 1, buff + M, sub( L_subfr, 1 ) ), 1 ) );
/*Combine tilt of code and fe*/
tmp = 0;
diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c
index b2022f7252d456ba6c4668c0138bdf8cf9744419..e81ab78ec78cfad53252bc9594f31ddfb953b0b5 100644
--- a/lib_com/cldfb.c
+++ b/lib_com/cldfb.c
@@ -40,11 +40,10 @@
#include
#include "stat_dec.h"
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "rom_com_fx.h"
#include "wmc_auto.h"
-#include "prot_fx2.h"
#if __STDC_VERSION__ >= 199901L
#if defined __ICL
#define restrict __restrict
@@ -60,6 +59,8 @@
static void cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs );
+static void cldfb_init_proto_and_twiddles_enc( HANDLE_CLDFB_FILTER_BANK hs );
+
static float GetEnergyCldfb_ivas( float *energyValuesSum, float *energyLookahead, float **realValues, float **imagValues, const int16_t numberBands, int16_t numberCols, TEC_ENC_HANDLE hTecEnc );
/*-------------------------------------------------------------------*
@@ -270,6 +271,7 @@ void cldfbAnalysis_ivas_fx(
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;
@@ -293,7 +295,7 @@ void cldfbAnalysis_ivas_fx(
IF( GT_16( samplesToProcess, -1 ) )
{
Copy32( timeIn_fx, timeBuffer_fx + offset, samplesToProcess );
- set32_fx( timeBuffer_fx + offset + samplesToProcess, 0, sub( frameSize, samplesToProcess ) );
+ set32_fx( timeBuffer_fx + add( offset, samplesToProcess ), 0, sub( frameSize, samplesToProcess ) );
}
ELSE
{
@@ -307,11 +309,12 @@ void cldfbAnalysis_ivas_fx(
}
M1 = h_cldfb->no_channels;
+ move16();
M2 = shr( M1, 1 );
M4 = shr( M1, 2 );
L2 = shl( M1, 1 );
- IF( M2 & 1 )
+ if ( s_and( M2, 1 ) )
{
M4 = add( M4, 1 );
}
@@ -328,29 +331,29 @@ void cldfbAnalysis_ivas_fx(
FOR( k = 0; k < M4; k++ )
{
/* prototype filter */
- r1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // Qx
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // Qx
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // Qx
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // Qx
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // Qx
-
- r2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ) ); // Qx
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ) ); // Qx
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ) ); // Qx
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ) ); // Qx
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ) ); // Qx
-
- i1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // Qx
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // Qx
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // Qx
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // Qx
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // Qx
-
- i2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // Qx
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // Qx
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // Qx
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // Qx
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // Qx
+ r1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx
+
+ r2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx
+
+ i1_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx
+
+ i2_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx
r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // Qx - 1
r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1
@@ -361,47 +364,47 @@ void cldfbAnalysis_ivas_fx(
rr12_fx = L_sub( r1_fx, r2_fx ); // Qx - 1
ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // Qx - 1
// cplxMult( &rBuffer_fx[2 * k], &rBuffer_fx[2 * k + 1], rr12_fx, ri12_fx, rot_vctr_re_fx[k], rot_vctr_im_fx[k] );
- rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // Qx - 3
+ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // Qx - 3
move32();
- rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // Qx - 3
+ rBuffer_fx[add( 2 * k, 1 )] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // Qx - 3
move32();
/* folding + pre modulation of DCT IV */
ir12_fx = L_add( r1_fx, r2_fx ); // Qx - 1
ii12_fx = L_sub( i1_fx, i2_fx ); // Qx - 1
// cplxMult( &iBuffer_fx[2 * k], &iBuffer_fx[2 * k + 1], ir12_fx, ii12_fx, rot_vctr_re_fx[k], rot_vctr_im_fx[k] );
- iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // Qx - 3
+ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // Qx - 3
move32();
- iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // Qx - 3
+ iBuffer_fx[add( 2 * k, 1 )] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // Qx - 3
move32();
}
FOR( k = M4; k < M2; k++ )
{
/* prototype filter */
- r1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // Qx
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // Qx
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // Qx
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // Qx
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // Qx
-
- r2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // Qx
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // Qx
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // Qx
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // Qx
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // Qx
-
- i1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // Qx
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // Qx
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // Qx
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // Qx
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // Qx
-
- i2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // Qx
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // Qx
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // Qx
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // Qx
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // Qx
+ r1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx
+
+ r2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx
+
+ i1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx
+
+ i2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx
r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // Qx - 1
r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1
@@ -412,18 +415,18 @@ void cldfbAnalysis_ivas_fx(
rr12_fx = L_add( r1_fx, r2_fx ); // Qx - 1
ri12_fx = L_sub( i1_fx, i2_fx ); // Qx - 1
// cplxMult( &rBuffer_fx[2 * k], &rBuffer[2 * k + 1], rr12, ri12, rot_vctr_re[k], rot_vctr_im[k] );
- rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // Qx - 3
+ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // Qx - 3
move32();
- rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // Qx - 3
+ rBuffer_fx[add( 2 * k, 1 )] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // Qx - 3
move32();
/* folding + pre modulation of DCT IV */
ir12_fx = L_sub( r1_fx, r2_fx ); // Qx - 1
ii12_fx = L_add( i1_fx, i2_fx ); // Qx - 1
// cplxMult( &iBuffer[2 * k], &iBuffer[2 * k + 1], ir12, ii12, rot_vctr_re[k], rot_vctr_im[k] );
- iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // Qx - 3
+ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // Qx - 3
move32();
- iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // Qx - 3
+ iBuffer_fx[add( 2 * k, 1 )] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // Qx - 3
move32();
}
@@ -435,9 +438,9 @@ void cldfbAnalysis_ivas_fx(
FOR( k = 0; k < M2; k++ )
{
// cplxMult( &realBuffer[i][M1 - 1 - ( 2 * k )], &realBuffer[i][2 * k], rBuffer[2 * k], rBuffer[2 * k + 1], rot_vctr_re[k], rot_vctr_im[k] );
- realBuffer_fx[i][M1 - 1 - ( 2 * k )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // Qx - 5
+ realBuffer_fx[i][sub( sub( M1, 1 ), shl( k, 1 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[add( 2 * k, 1 )], rot_vctr_im_fx[k] ); // Qx - 5
move32();
- realBuffer_fx[i][2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // Qx - 5
+ realBuffer_fx[i][2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[add( 2 * k, 1 )], rot_vctr_re_fx[k] ); // Qx - 5
move32();
}
@@ -450,14 +453,14 @@ void cldfbAnalysis_ivas_fx(
{
/* do it inplace */
// cplxMult( &imagBuffer[i][2 * k], &imagBuffer[i][M1 - 1 - ( 2 * k )], iBuffer[2 * k], iBuffer[2 * k + 1], rot_vctr_re[k], rot_vctr_im[k] );
- imagBuffer_fx[i][2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // QX - 5
+ imagBuffer_fx[i][2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[add( 2 * k, 1 )], rot_vctr_im_fx[k] ); // QX - 5
move32();
- imagBuffer_fx[i][M1 - 1 - ( 2 * k )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // Qx - 5
+ imagBuffer_fx[i][sub( sub( M1, 1 ), shl( k, 1 ) )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[add( 2 * k, 1 )], rot_vctr_re_fx[k] ); // Qx - 5
move32();
}
- timeBuffer_fx += L2 * 5;
- timeBuffer_fx += h_cldfb->no_channels - h_cldfb->p_filter_length;
+ timeBuffer_fx += i_mult( L2, 5 );
+ timeBuffer_fx += sub( h_cldfb->no_channels, h_cldfb->p_filter_length );
}
/* update memory */
@@ -702,6 +705,7 @@ void cldfbAnalysis_ts_fx(
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;
@@ -716,40 +720,45 @@ void cldfbAnalysis_ts_fx(
Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )];
Word16 offset, frameSize;
- offset = h_cldfb->p_filter_length - h_cldfb->no_channels;
- frameSize = h_cldfb->no_channels * h_cldfb->no_col;
+ 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 ( samplesToProcess > -1 )
+ IF( GT_16( samplesToProcess, -1 ) )
{
Copy32( timeIn_fx, timeBuffer_fx + offset, samplesToProcess );
- set32_fx( timeBuffer_fx + offset + samplesToProcess, 0, ( frameSize - samplesToProcess ) );
+ set32_fx( timeBuffer_fx + add( offset, samplesToProcess ), 0, sub( frameSize, samplesToProcess ) );
}
- else
+ ELSE
{
Copy32( timeIn_fx, timeBuffer_fx + offset, frameSize );
}
h_cldfb->Q_cldfb_state = *q_cldfb;
+ move16();
/* only process needed cols */
- if ( samplesToProcess > -1 )
+ IF( samplesToProcess > -1 )
{
- no_col = min( no_col, ( samplesToProcess + h_cldfb->no_channels - 1 ) / h_cldfb->no_channels );
+ no_col = 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 = M1 >> 1;
- M4 = M1 >> 2;
- L2 = M1 << 1;
+ move16();
+ M2 = shr( M1, 1 );
+ move16();
+ M4 = shr( M1, 2 );
+ move16();
+ L2 = shl( M1, 1 );
+ move16();
- if ( M2 & 1 )
+ if ( s_and( M2, 1 ) )
{
- M4 += 1;
+ M4 = add( M4, 1 );
}
rot_vctr_re_fx = h_cldfb->rot_vec_ana_re_fx; // q = 29
@@ -759,35 +768,36 @@ void cldfbAnalysis_ts_fx(
ptr_pf_fx = h_cldfb->p_filter;
ptr_pf_sf = h_cldfb->p_filter_sf;
+ move16();
- for ( i = 0; i < no_col; i++ )
+ FOR( i = 0; i < no_col; i++ )
{
- for ( k = 0; k < M4; k++ )
+ FOR( k = 0; k < M4; k++ )
{
/* prototype filter */
- r1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q
-
- r2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ) ); // q
-
- i1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // q
-
- i2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q
+ r1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q
+
+ r2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q
+
+ i1_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q
+
+ i2_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 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
@@ -798,43 +808,47 @@ void cldfbAnalysis_ts_fx(
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] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
+ rBuffer_fx[add( 2 * k, 1 )] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ 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] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
+ iBuffer_fx[add( 2 * k, 1 )] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ move32();
+ move32();
}
- for ( k = M4; k < M2; k++ )
+ FOR( k = M4; k < M2; k++ )
{
/* prototype filter */
- r1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q
-
- r2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // q
-
- i1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q
-
- i2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // q
+ r1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q
+
+ r2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q
+
+ i1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q
+
+ i2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 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
@@ -845,72 +859,88 @@ void cldfbAnalysis_ts_fx(
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] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
+ rBuffer_fx[add( 2 * k, 1 )] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ 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] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
+ iBuffer_fx[add( 2 * k, 1 )] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ move32();
+ move32();
}
*q_cldfb = sub( *q_cldfb, 3 );
+ move16();
/* FFT of DST IV */
Word16 q_shift;
- q_shift = sub( s_min( getScaleFactor32( rBuffer_fx, 2 * M2 ), getScaleFactor32( iBuffer_fx, 2 * M2 ) ), find_guarded_bits_fx( M2 ) );
+ q_shift = sub( s_min( getScaleFactor32( rBuffer_fx, shl( M2, 1 ) ), getScaleFactor32( iBuffer_fx, shl( M2, 1 ) ) ), find_guarded_bits_fx( M2 ) );
*q_cldfb = add( *q_cldfb, q_shift );
- for ( Word16 ind = 0; ind < 2 * M2; ind++ )
+ move16();
+ FOR( Word16 ind = 0; ind < shl( M2, 1 ); ind++ )
{
rBuffer_fx[ind] = L_shl( rBuffer_fx[ind], q_shift );
+ move32();
}
- for ( Word16 ind = 0; ind < 2 * M2; ind++ )
+ FOR( Word16 ind = 0; ind < shl( M2, 1 ); ind++ )
{
iBuffer_fx[ind] = L_shl( iBuffer_fx[ind], q_shift );
+ move32();
}
fft_cldfb_fx( rBuffer_fx, M2 );
/* post modulation of DST IV */
- for ( k = 0; k < M2; k++ )
+ 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 - ( 2 * k )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5
- realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5
+ realBuffer_fx[sub( sub( M1, 1 ), shl( k, 1 ) )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[add( 2 * k, 1 )], rot_vctr_im_fx[k] ) ); // q - 5
+ realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[add( 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 );
- q_shift = s_min( getScaleFactor32( rBuffer_fx, 2 * M2 ), getScaleFactor32( iBuffer_fx, 2 * M2 ) );
+ q_shift = s_min( getScaleFactor32( rBuffer_fx, shl( M2, 1 ) ), getScaleFactor32( iBuffer_fx, shl( M2, 1 ) ) );
*q_cldfb = add( *q_cldfb, q_shift );
- for ( Word16 ind = 0; ind < 2 * M2; ind++ )
+ move16();
+ FOR( Word16 ind = 0; ind < shl( M2, 1 ); ind++ )
{
rBuffer_fx[ind] = L_shl( rBuffer_fx[ind], q_shift );
+ move32();
}
- for ( Word16 ind = 0; ind < 2 * M2; ind++ )
+ FOR( Word16 ind = 0; ind < shl( M2, 1 ); ind++ )
{
iBuffer_fx[ind] = L_shl( iBuffer_fx[ind], q_shift );
+ move32();
}
/* post modulation of DCT IV */
- for ( k = 0; k < M2; k++ )
+ FOR( k = 0; k < M2; k++ )
{
/* do it inplace */
/*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/
- imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5
- imagBuffer_fx[M1 - 1 - ( 2 * k )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5
+ imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[add( 2 * k, 1 )], rot_vctr_im_fx[k] ) ); // q - 5
+ imagBuffer_fx[sub( sub( M1, 1 ), shl( k, 1 ) )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[add( 2 * k, 1 )], rot_vctr_re_fx[k] ) ); // q - 5
+ move32();
+ move32();
}
- if ( h_cldfb->prototype == CLDFB_PROTOTYPE_5_00MS )
+ 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 )
+ IF( rot_vctr_delay_re_fx != NULL )
{
- for ( k = 0; k < M1; k++ )
+ FOR( k = 0; k < M1; k++ )
{
Word32 cplx_aux_fx;
/* delay */
@@ -923,20 +953,22 @@ void cldfbAnalysis_ts_fx(
cplx_aux_fx = L_sub( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ) ); // q - 5
imagBuffer_fx[k] = L_add( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ) ); // q - 5
realBuffer_fx[k] = cplx_aux_fx;
+ move32();
+ move32();
}
}
}
- timeBuffer_fx += L2 * 5;
- timeBuffer_fx += h_cldfb->no_channels - h_cldfb->p_filter_length;
+ timeBuffer_fx += i_mult( L2, 5 );
+ timeBuffer_fx += sub( h_cldfb->no_channels, h_cldfb->p_filter_length );
}
/* update memory */
- if ( samplesToProcess > -1 )
+ IF( GT_16( samplesToProcess, -1 ) )
{
Copy32( buffer_fx + samplesToProcess, h_cldfb->cldfb_state_fx, offset );
}
- else
+ ELSE
{
Copy32( buffer_fx + frameSize, h_cldfb->cldfb_state_fx, offset );
}
@@ -958,7 +990,7 @@ void cldfbAnalysis_ts_fx_fixed_q(
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];
@@ -972,39 +1004,44 @@ void cldfbAnalysis_ts_fx_fixed_q(
Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )];
Word16 offset, frameSize;
- offset = h_cldfb->p_filter_length - h_cldfb->no_channels;
- frameSize = h_cldfb->no_channels * h_cldfb->no_col;
+ 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 );
h_cldfb->Q_cldfb_state = *q_cldfb;
+ move16();
- if ( samplesToProcess > -1 )
+ IF( GT_16( samplesToProcess, -1 ) )
{
Copy32( timeIn_fx, timeBuffer_fx + offset, samplesToProcess );
- set32_fx( timeBuffer_fx + offset + samplesToProcess, 0, ( frameSize - samplesToProcess ) );
+ set32_fx( timeBuffer_fx + add( offset, samplesToProcess ), 0, sub( frameSize, samplesToProcess ) );
}
- else
+ ELSE
{
Copy32( timeIn_fx, timeBuffer_fx + offset, frameSize );
}
/* only process needed cols */
- if ( samplesToProcess > -1 )
+ IF( GT_16( samplesToProcess, -1 ) )
{
- no_col = min( no_col, ( samplesToProcess + h_cldfb->no_channels - 1 ) / h_cldfb->no_channels );
+ no_col = 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 = M1 >> 1;
- M4 = M1 >> 2;
- L2 = M1 << 1;
+ M2 = shr( M1, 1 );
+ M4 = shr( M1, 2 );
+ L2 = shl( M1, 1 );
+ move16();
+ move16();
+ move16();
+ move16();
- if ( M2 & 1 )
+ if ( s_and( M2, 1 ) )
{
- M4 += 1;
+ M4 = add( M4, 1 );
}
rot_vctr_re_fx = h_cldfb->rot_vec_ana_re_fx; // q = 29
@@ -1014,35 +1051,36 @@ void cldfbAnalysis_ts_fx_fixed_q(
ptr_pf_fx = h_cldfb->p_filter;
ptr_pf_sf = h_cldfb->p_filter_sf;
+ move16();
- for ( i = 0; i < no_col; i++ )
+ FOR( i = 0; i < no_col; i++ )
{
- for ( k = 0; k < M4; k++ )
+ FOR( k = 0; k < M4; k++ )
{
/* prototype filter */
- r1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q
-
- r2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ) ); // q
-
- i1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // q
-
- i2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q
+ r1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q
+
+ r2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q
+
+ i1_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q
+
+ i2_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 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
@@ -1053,43 +1091,47 @@ void cldfbAnalysis_ts_fx_fixed_q(
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] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3
+ rBuffer_fx[add( 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] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3
+ iBuffer_fx[add( 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++ )
+ FOR( k = M4; k < M2; k++ )
{
/* prototype filter */
- r1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q
- r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q
-
- r2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // q
- r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // q
-
- i1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q
- i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q
-
- i2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // q
- i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // q
+ r1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q
+
+ r2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q
+
+ i1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q
+
+ i2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q
+ i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 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
@@ -1100,50 +1142,60 @@ void cldfbAnalysis_ts_fx_fixed_q(
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] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3
+ rBuffer_fx[add( 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] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3
- iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3
+ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3
+ iBuffer_fx[add( 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++ )
+ 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 - ( 2 * k )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5
- realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5
+ realBuffer_fx[sub( sub( M1, 1 ), shl( k, 1 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[add( 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[add( 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++ )
+ FOR( k = 0; k < M2; k++ )
{
/* do it inplace */
/*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/
- imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5
- imagBuffer_fx[M1 - 1 - ( 2 * k )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5
+ imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[add( 2 * k, 1 )], rot_vctr_im_fx[k] ); // q - 5
+ imagBuffer_fx[sub( sub( M1, 1 ), shl( k, 1 ) )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[add( 2 * k, 1 )], rot_vctr_re_fx[k] ); // q - 5
+ move32();
+ move32();
}
- if ( h_cldfb->prototype == CLDFB_PROTOTYPE_5_00MS )
+ 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 )
+ IF( rot_vctr_delay_re_fx != NULL )
{
- for ( k = 0; k < M1; k++ )
+ FOR( k = 0; k < M1; k++ )
{
Word32 cplx_aux_fx;
/* delay */
@@ -1153,23 +1205,25 @@ void cldfbAnalysis_ts_fx_fixed_q(
/*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 = L_sub( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ) ); // q - 5
- imagBuffer_fx[k] = L_add( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ) ); // q - 5
+ cplx_aux_fx = 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 += L2 * 5;
- timeBuffer_fx += h_cldfb->no_channels - h_cldfb->p_filter_length;
+ timeBuffer_fx += i_mult( L2, 5 );
+ timeBuffer_fx += sub( h_cldfb->no_channels, h_cldfb->p_filter_length );
}
/* update memory */
- if ( samplesToProcess > -1 )
+ IF( GT_16( samplesToProcess, -1 ) )
{
Copy32( buffer_fx + samplesToProcess, h_cldfb->cldfb_state_fx, offset );
}
- else
+ ELSE
{
Copy32( buffer_fx + frameSize, h_cldfb->cldfb_state_fx, offset );
}
@@ -1411,7 +1465,7 @@ void cldfbSynthesis_ivas_fx(
/* only process needed cols */
IF( GT_16( samplesToProcess, -1 ) )
{
- no_col = min( no_col, ( samplesToProcess + h_cldfb->no_channels - 1 ) / h_cldfb->no_channels );
+ no_col = min( no_col, idiv1616( sub( add( samplesToProcess, h_cldfb->no_channels ), 1 ), h_cldfb->no_channels ) );
move16();
}
@@ -1422,7 +1476,7 @@ void cldfbSynthesis_ivas_fx(
rot_vctr_delay_im_fx = h_cldfb->rot_vec_syn_delay_im_fx;
synthesisBuffer_fx = buffer_fx;
- Copy32( h_cldfb->cldfb_state_fx, synthesisBuffer_fx + ( M1 * no_col ), h_cldfb->p_filter_length );
+ Copy32( h_cldfb->cldfb_state_fx, synthesisBuffer_fx + i_mult( M1, no_col ), h_cldfb->p_filter_length );
p_filter = h_cldfb->p_filter;
p_filter_sf = h_cldfb->p_filter_sf;
@@ -1430,7 +1484,7 @@ void cldfbSynthesis_ivas_fx(
ptr_time_out_fx = timeOut_fx;
/*synthesisBuffer += M1 * h_cldfb->no_col;*/
- synthesisBuffer_fx += M1 * no_col;
+ synthesisBuffer_fx += i_mult( M1, no_col );
FOR( k = 0; k < no_col; k++ )
{
@@ -1448,8 +1502,8 @@ void cldfbSynthesis_ivas_fx(
sin((EVS_PI/M1)*(i+0.5)*(-(h_cldfb->ds-M1)*0.5)));*/
/*cplxMult(&rBuffer[i], &iBuffer[i], realBuffer[k][i], imagBuffer[k][i], rot_vctr_delay_re[i], rot_vctr_delay_im[i]);*/
/*cplxMult(&realBuffer[k][i], &imagBuffer[k][i], realBuffer[k][i], imagBuffer[k][i], rot_vctr_delay_re[i], rot_vctr_delay_im[i]);*/
- cplx_aux = L_sub( Mpy_32_32( realBuffer_fx[k][i], rot_vctr_delay_re_fx[i] ), Mpy_32_32( imagBuffer_fx[k][i], rot_vctr_delay_im_fx[i] ) ); // Qx
- imagBuffer_fx[k][i] = L_add( Mpy_32_32( realBuffer_fx[k][i], rot_vctr_delay_im_fx[i] ), Mpy_32_32( imagBuffer_fx[k][i], rot_vctr_delay_re_fx[i] ) );
+ cplx_aux = Msub_32_32( Mpy_32_32( realBuffer_fx[k][i], rot_vctr_delay_re_fx[i] ), imagBuffer_fx[k][i], rot_vctr_delay_im_fx[i] ); // Qx
+ imagBuffer_fx[k][i] = Madd_32_32( Mpy_32_32( realBuffer_fx[k][i], rot_vctr_delay_im_fx[i] ), imagBuffer_fx[k][i], rot_vctr_delay_re_fx[i] );
move32();
realBuffer_fx[k][i] = cplx_aux;
move32();
@@ -1460,9 +1514,9 @@ void cldfbSynthesis_ivas_fx(
}
FOR( i = Mz; i < M1; i++ )
{
- realBuffer_fx[k][i] = L_deposit_l( 0 );
+ realBuffer_fx[k][i] = 0;
move32();
- imagBuffer_fx[k][i] = L_deposit_l( 0 );
+ imagBuffer_fx[k][i] = 0;
move32();
}
@@ -1470,16 +1524,16 @@ void cldfbSynthesis_ivas_fx(
{
/* pre modulation of DST IV */
/*cplxMult(&rBuffer[2*i], &rBuffer[2*i+1], realBuffer[k][2*i], realBuffer[k][M1-1-2*i], rot_vctr_re[i], rot_vctr_im[i]);*/
- rBuffer_fx[2 * i] = L_sub( Mpy_32_32( realBuffer_fx[k][2 * i], rot_vctr_re_fx[i] ), Mpy_32_32( realBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_im_fx[i] ) ); // Qx
+ rBuffer_fx[2 * i] = Msub_32_32( Mpy_32_32( realBuffer_fx[k][2 * i], rot_vctr_re_fx[i] ), realBuffer_fx[k][sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_im_fx[i] ); // Qx
move32();
- rBuffer_fx[2 * i + 1] = L_add( Mpy_32_32( realBuffer_fx[k][2 * i], rot_vctr_im_fx[i] ), Mpy_32_32( realBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_re_fx[i] ) ); // Qx
+ rBuffer_fx[add( 2 * i, 1 )] = Madd_32_32( Mpy_32_32( realBuffer_fx[k][2 * i], rot_vctr_im_fx[i] ), realBuffer_fx[k][sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_re_fx[i] ); // Qx
move32();
/* pre modulation of DCT IV */
/*cplxMult(&iBuffer[2*i], &iBuffer[2*i+1],-imagBuffer[k][2*i], imagBuffer[k][M1-1-2*i], rot_vctr_re[i], rot_vctr_im[i]);*/
- iBuffer_fx[2 * i] = L_sub( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_re_fx[i] ), Mpy_32_32( imagBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_im_fx[i] ) ); // Qx
+ iBuffer_fx[2 * i] = Msub_32_32( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_re_fx[i] ), imagBuffer_fx[k][sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_im_fx[i] ); // Qx
move32();
- iBuffer_fx[2 * i + 1] = L_add( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_im_fx[i] ), Mpy_32_32( imagBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_re_fx[i] ) ); // Qx
+ iBuffer_fx[add( 2 * i, 1 )] = Madd_32_32( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_im_fx[i] ), imagBuffer_fx[k][sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_re_fx[i] ); // Qx
move32();
}
@@ -1493,69 +1547,69 @@ void cldfbSynthesis_ivas_fx(
FOR( i = 0; i < M41; i++ )
{
/* post modulation of DST IV */
- rr12_fx = L_sub( Mpy_32_32( rBuffer_fx[M1 - 2 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ), Mpy_32_32( rBuffer_fx[M1 - 1 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ) ); // Qx
- ri12_fx = L_add( Mpy_32_32( rBuffer_fx[M1 - 2 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ), Mpy_32_32( rBuffer_fx[M1 - 1 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ) ); // Qx
+ rr12_fx = Msub_32_32( Mpy_32_32( rBuffer_fx[sub( sub( M1, 2 ), shl( i, 1 ) )], rot_vctr_re_fx[sub( sub( M2, 1 ), i )] ), rBuffer_fx[sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_im_fx[sub( sub( M2, 1 ), i )] ); // Qx
+ ri12_fx = Madd_32_32( Mpy_32_32( rBuffer_fx[sub( sub( M1, 2 ), shl( i, 1 ) )], rot_vctr_im_fx[sub( sub( M2, 1 ), i )] ), rBuffer_fx[sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_re_fx[sub( sub( M2, 1 ), i )] ); // Qx
/* post modulation of DCT IV */
- ir12_fx = L_sub( Mpy_32_32( iBuffer_fx[M1 - 2 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ), Mpy_32_32( iBuffer_fx[M1 - 1 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ) ); // Qx
- ii12_fx = L_add( Mpy_32_32( iBuffer_fx[M1 - 2 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ), Mpy_32_32( iBuffer_fx[M1 - 1 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ) ); // Qx
+ ir12_fx = Msub_32_32( Mpy_32_32( iBuffer_fx[sub( sub( M1, 2 ), shl( i, 1 ) )], rot_vctr_re_fx[sub( sub( M2, 1 ), i )] ), iBuffer_fx[sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_im_fx[sub( sub( M2, 1 ), i )] ); // Qx
+ ii12_fx = Madd_32_32( Mpy_32_32( iBuffer_fx[sub( sub( M1, 2 ), shl( i, 1 ) )], rot_vctr_im_fx[sub( sub( M2, 1 ), i )] ), iBuffer_fx[sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_re_fx[sub( sub( M2, 1 ), i )] ); // Qx
- new_samples_fx[M1 + M2 + 1 + 2 * i] = L_negate( L_add( rr12_fx, ii12_fx ) ); // Qx
+ new_samples_fx[add( add( add( M1, M2 ), 1 ), shl( i, 1 ) )] = L_negate( L_add( rr12_fx, ii12_fx ) ); // Qx
move32();
- new_samples_fx[M2 - 2 - 2 * i] = L_negate( L_add( ri12_fx, ir12_fx ) ); // Qx
+ new_samples_fx[sub( sub( M2, 2 ), shl( i, 1 ) )] = L_negate( L_add( ri12_fx, ir12_fx ) ); // Qx
move32();
- new_samples_fx[M1 + M2 - 2 - 2 * i] = L_sub( rr12_fx, ii12_fx ); // Qx
+ new_samples_fx[sub( sub( add( M1, M2 ), 2 ), shl( i, 1 ) )] = L_sub( rr12_fx, ii12_fx ); // Qx
move32();
- new_samples_fx[M2 + 1 + 2 * i] = L_sub( ir12_fx, ri12_fx ); // Qx
+ new_samples_fx[add( add( M2, 1 ), shl( i, 1 ) )] = L_sub( ir12_fx, ri12_fx ); // Qx
move32();
}
FOR( i = 0; i < M42; i++ )
{
/* post modulation of DST IV */
- rr12_fx = L_sub( Mpy_32_32( rBuffer_fx[2 * i], rot_vctr_re_fx[i] ), Mpy_32_32( rBuffer_fx[2 * i + 1], rot_vctr_im_fx[i] ) ); // Qx
- ri12_fx = L_add( Mpy_32_32( rBuffer_fx[2 * i], rot_vctr_im_fx[i] ), Mpy_32_32( rBuffer_fx[2 * i + 1], rot_vctr_re_fx[i] ) ); // Qx
+ rr12_fx = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * i], rot_vctr_re_fx[i] ), rBuffer_fx[add( 2 * i, 1 )], rot_vctr_im_fx[i] ); // Qx
+ ri12_fx = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * i], rot_vctr_im_fx[i] ), rBuffer_fx[add( 2 * i, 1 )], rot_vctr_re_fx[i] ); // Qx
/* post modulation of DCT IV */
- ir12_fx = L_sub( Mpy_32_32( iBuffer_fx[2 * i], rot_vctr_re_fx[i] ), Mpy_32_32( iBuffer_fx[2 * i + 1], rot_vctr_im_fx[i] ) ); // Qx
- ii12_fx = L_add( Mpy_32_32( iBuffer_fx[2 * i], rot_vctr_im_fx[i] ), Mpy_32_32( iBuffer_fx[2 * i + 1], rot_vctr_re_fx[i] ) ); // Qx
+ ir12_fx = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * i], rot_vctr_re_fx[i] ), iBuffer_fx[add( 2 * i, 1 )], rot_vctr_im_fx[i] ); // Qx
+ ii12_fx = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * i], rot_vctr_im_fx[i] ), iBuffer_fx[add( 2 * i, 1 )], rot_vctr_re_fx[i] ); // Qx
- new_samples_fx[M1 + M2 + 2 * i] = L_add( ri12_fx, ir12_fx ); // Qx
+ new_samples_fx[add( add( M1, M2 ), shl( i, 1 ) )] = L_add( ri12_fx, ir12_fx ); // Qx
move32();
- new_samples_fx[M2 - 1 - 2 * i] = L_add( rr12_fx, ii12_fx ); // Qx
+ new_samples_fx[sub( sub( M2, 1 ), shl( i, 1 ) )] = L_add( rr12_fx, ii12_fx ); // Qx
move32();
- new_samples_fx[M1 + M2 - 1 - 2 * i] = L_sub( ir12_fx, ri12_fx ); // Qx
+ new_samples_fx[sub( sub( add( M1, M2 ), 1 ), shl( i, 1 ) )] = L_sub( ir12_fx, ri12_fx ); // Qx
move32();
- new_samples_fx[M2 + 2 * i] = L_sub( rr12_fx, ii12_fx ); // Qx
+ new_samples_fx[add( M2, shl( i, 1 ) )] = L_sub( rr12_fx, ii12_fx ); // Qx
move32();
}
/* synthesis prototype filter */
FOR( i = 0; i < L2; i++ )
{
- accu0 = L_add( synthesisBuffer_fx[0 * L2 + i], Mpy_32_16_1( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 0 * L2 + i )] ), p_filter_sf ) ); // Qx - 1
- accu1 = L_add( synthesisBuffer_fx[1 * L2 + i], Mpy_32_16_1( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 1 * L2 + i )] ), p_filter_sf ) ); // Qx - 1
- accu2 = L_add( synthesisBuffer_fx[2 * L2 + i], Mpy_32_16_1( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 2 * L2 + i )] ), p_filter_sf ) ); // Qx - 1
- accu3 = L_add( synthesisBuffer_fx[3 * L2 + i], Mpy_32_16_1( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 3 * L2 + i )] ), p_filter_sf ) ); // Qx - 1
- accu4 = L_add( synthesisBuffer_fx[4 * L2 + i], Mpy_32_16_1( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 4 * L2 + i )] ), p_filter_sf ) ); // Qx - 1
+ accu0 = Madd_32_16( synthesisBuffer_fx[i], Mpy_32_16_1( new_samples_fx[sub( sub( L2, 1 ), i )], p_filter[i] ), p_filter_sf ); // Qx - 1
+ accu1 = Madd_32_16( synthesisBuffer_fx[add( L2, i )], Mpy_32_16_1( new_samples_fx[sub( sub( L2, 1 ), i )], p_filter[add( L2, i )] ), p_filter_sf ); // Qx - 1
+ accu2 = Madd_32_16( synthesisBuffer_fx[add( i_mult( 2, L2 ), i )], Mpy_32_16_1( new_samples_fx[sub( sub( L2, 1 ), i )], p_filter[add( i_mult( 2, L2 ), i )] ), p_filter_sf ); // Qx - 1
+ accu3 = Madd_32_16( synthesisBuffer_fx[add( i_mult( 3, L2 ), i )], Mpy_32_16_1( new_samples_fx[sub( sub( L2, 1 ), i )], p_filter[add( i_mult( 3, L2 ), i )] ), p_filter_sf ); // Qx - 1
+ accu4 = Madd_32_16( synthesisBuffer_fx[add( i_mult( 4, L2 ), i )], Mpy_32_16_1( new_samples_fx[sub( sub( L2, 1 ), i )], p_filter[add( i_mult( 4, L2 ), i )] ), p_filter_sf ); // Qx - 1
- synthesisBuffer_fx[0 * L2 + i] = accu0;
+ synthesisBuffer_fx[i] = accu0;
move32();
- synthesisBuffer_fx[1 * L2 + i] = accu1;
+ synthesisBuffer_fx[add( L2, i )] = accu1;
move32();
- synthesisBuffer_fx[2 * L2 + i] = accu2;
+ synthesisBuffer_fx[add( i_mult( 2, L2 ), i )] = accu2;
move32();
- synthesisBuffer_fx[3 * L2 + i] = accu3;
+ synthesisBuffer_fx[add( i_mult( 3, L2 ), i )] = accu3;
move32();
- synthesisBuffer_fx[4 * L2 + i] = accu4;
+ synthesisBuffer_fx[add( i_mult( 4, L2 ), i )] = accu4;
move32();
}
FOR( i = 0; i < M1; i++ )
{
- ptr_time_out_fx[M1 - 1 - i] = synthesisBuffer_fx[4 * L2 + M1 + i];
+ ptr_time_out_fx[sub( sub( M1, 1 ), i )] = synthesisBuffer_fx[add( i_mult( 4, L2 ), add( M1, i ) )];
move32();
}
@@ -1596,6 +1650,28 @@ void configureCldfb_ivas(
return;
}
+void configureCldfb_ivas_enc(
+ HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */
+ const int32_t sampling_rate /* i : sampling rate */
+)
+{
+
+ h_cldfb->no_col = CLDFB_NO_COL_MAX;
+ h_cldfb->bandsToZero = 0;
+ h_cldfb->nab = 0;
+
+ h_cldfb->no_channels = (int16_t) ( sampling_rate * INV_CLDFB_BANDWIDTH + 0.5f );
+ h_cldfb->p_filter_length = 10 * h_cldfb->no_channels;
+#ifdef IVAS_FLOAT_FIXED
+ h_cldfb->zeros = 0;
+ h_cldfb->anaScalefactor = 0;
+ h_cldfb->synScalefactor = 0;
+ h_cldfb->filterScale = 1;
+#endif
+ cldfb_init_proto_and_twiddles_enc( h_cldfb );
+
+ return;
+}
#ifdef IVAS_FLOAT_FIXED
void configureCldfb_ivas_fx(
HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */
@@ -1604,16 +1680,23 @@ void configureCldfb_ivas_fx(
{
h_cldfb->no_col = CLDFB_NO_COL_MAX;
+ move16();
h_cldfb->bandsToZero = 0;
+ move16();
h_cldfb->nab = 0;
+ move16();
// h_cldfb->no_channels = (int16_t) ( sampling_rate * INV_CLDFB_BANDWIDTH + 0.5f );
- Word32 n_sampling_rate = sampling_rate * 2;
- Word32 val = L_add( Mpy_32_16_1( n_sampling_rate, 41 /* INV_CLDFB_BANDWIDTH in Q15 */ ), 1 );
- val = L_shr( val, 1 );
- h_cldfb->no_channels = extract_l( val );
-
- h_cldfb->p_filter_length = 10 * h_cldfb->no_channels;
+ h_cldfb->no_channels = extract_l( Mpy_32_32_r( sampling_rate, INV_CLDFB_BANDWIDTH_Q31 ) );
+ move16();
+ h_cldfb->zeros = 0;
+ move16();
+ h_cldfb->anaScalefactor = 0;
+ move16();
+ h_cldfb->synScalefactor = 0;
+ move16();
+ h_cldfb->p_filter_length = i_mult( 10, h_cldfb->no_channels );
+ move16();
cldfb_init_proto_and_twiddles( h_cldfb );
@@ -1626,6 +1709,67 @@ void configureCldfb_ivas_fx(
* open and configures a CLDFB handle
*--------------------------------------------------------------------*/
#ifdef IVAS_FLOAT_FIXED
+ivas_error openCldfb_ivas_fx(
+ HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
+ CLDFB_TYPE type, /* i : analysis or synthesis */
+ const Word32 sampling_rate, /* i : sampling rate */
+ CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
+)
+{
+ HANDLE_CLDFB_FILTER_BANK hs;
+ Word16 buf_len;
+
+ IF( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
+ }
+
+ hs->type = type;
+ move16();
+ hs->prototype = prototype;
+ move16();
+
+ // configureCldfb_ivas( hs, sampling_rate );
+ configureCldfb_ivas_fx( hs, sampling_rate );
+ hs->memory_flt = NULL;
+ hs->FilterStates = NULL;
+ hs->memory_length = 0;
+ move16();
+
+ IF( EQ_32( type, CLDFB_ANALYSIS ) )
+ {
+ buf_len = sub( hs->p_filter_length, hs->no_channels );
+ }
+ ELSE
+ {
+ buf_len = hs->p_filter_length;
+ move16();
+ }
+
+ IF( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
+ }
+
+ hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer
+ hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/
+ set32_fx( hs->cldfb_state_fx, 0, buf_len );
+ hs->Q_cldfb_state = Q11;
+ /* TODO: remove the floating point dependency */
+
+ /*IF( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
+ }*/
+
+ // set_f( hs->cldfb_state, 0.0f, buf_len );
+
+ *h_cldfb = hs;
+ move16();
+
+ return IVAS_ERR_OK;
+}
+
ivas_error openCldfb_ivas(
HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
CLDFB_TYPE type, /* i : analysis or synthesis */
@@ -1645,6 +1789,7 @@ ivas_error openCldfb_ivas(
hs->prototype = prototype;
configureCldfb_ivas( hs, sampling_rate );
+
hs->memory_flt = NULL;
hs->memory_length = 0;
@@ -1668,9 +1813,12 @@ ivas_error openCldfb_ivas(
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
}
hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer
- hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/
+ move16();
+ hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/
+ move16();
set32_fx( hs->cldfb_state_fx, 0, buf_len );
hs->Q_cldfb_state = Q11;
+ move16();
#endif // IVAS_FLOAT_FIXED
@@ -1722,74 +1870,76 @@ ivas_error openCldfb_ivas(
return IVAS_ERR_OK;
}
#endif
-#ifdef IVAS_FLOAT_FIXED
-ivas_error openCldfb_ivas_fx(
+ivas_error openCldfb_ivas_enc(
HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
CLDFB_TYPE type, /* i : analysis or synthesis */
- const Word32 sampling_rate, /* i : sampling rate */
+ const int32_t sampling_rate, /* i : sampling rate */
CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
)
{
HANDLE_CLDFB_FILTER_BANK hs;
- Word16 buf_len;
+ int16_t buf_len;
- IF( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL )
+ if ( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
}
hs->type = type;
- move16();
hs->prototype = prototype;
- move16();
- // configureCldfb_ivas( hs, sampling_rate );
- configureCldfb_ivas_fx( hs, sampling_rate );
+ configureCldfb_ivas_enc( hs, sampling_rate );
hs->memory_flt = NULL;
hs->memory_length = 0;
- move16();
- IF( EQ_32( type, CLDFB_ANALYSIS ) )
+ if ( type == CLDFB_ANALYSIS )
{
- buf_len = sub( hs->p_filter_length, hs->no_channels );
+ buf_len = hs->p_filter_length - hs->no_channels;
+#ifdef IVAS_FLOAT_FIXED
+ hs->FilterStates = (Word16 *) malloc( ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) );
+ hs->FilterStates_eg = 0;
+#endif
}
- ELSE
+ else
{
buf_len = hs->p_filter_length;
- move16();
+#ifdef IVAS_FLOAT_FIXED
+ hs->FilterStates = (Word16 *) malloc( 2 * ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) );
+ hs->FilterStates_eg = 0;
+#endif
}
- IF( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL )
+ if ( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
}
-
- hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer
- hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/
- set32_fx( hs->cldfb_state_fx, 0, buf_len );
- hs->Q_cldfb_state = Q11;
- /* TODO: remove the floating point dependency */
-
- IF( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL )
+ set_f( hs->cldfb_state, 0.0f, buf_len );
+#ifdef IVAS_FLOAT_FIXED
+ if ( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
}
+ hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer
+ move16();
+ hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/
+ move16();
+ set32_fx( hs->cldfb_state_fx, 0, buf_len );
+ set16_fx( hs->FilterStates, 0, i_mult( 9 + 16, hs->no_channels ) );
+ set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) );
+#endif // IVAS_FLOAT_FIXED
- set_f( hs->cldfb_state, 0.0f, buf_len );
*h_cldfb = hs;
- move16();
return IVAS_ERR_OK;
}
-#endif
/*-------------------------------------------------------------------*
* resampleCldfb_ivas()
*
* Change sample rate of filter bank
*--------------------------------------------------------------------*/
-
+#ifndef IVAS_FLOAT_FIXED
void resampleCldfb_ivas(
HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */
const int32_t newSamplerate )
@@ -1809,7 +1959,7 @@ void resampleCldfb_ivas(
return;
}
-#ifdef IVAS_FLOAT_FIXED
+#else
void resampleCldfb_ivas_fx(
HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */
const Word32 newSamplerate )
@@ -1862,6 +2012,44 @@ void analysisCldfbEncoder_ivas(
return;
}
+void analysisCldfbEncoder_ivas_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 *timeIn,
+ Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word32 *ppBuf_Ener,
+ Word16 *enerBuffSum_exp,
+ CLDFB_SCALE_FACTOR *scale )
+{
+ Word16 i;
+ CLDFB_SCALE_FACTOR enerScale;
+ Word32 *ppBuf_Real[CLDFB_NO_COL_MAX];
+ Word32 *ppBuf_Imag[CLDFB_NO_COL_MAX];
+ Word16 *ppBuf_Real16[CLDFB_NO_COL_MAX];
+ Word16 *ppBuf_Imag16[CLDFB_NO_COL_MAX];
+ Word32 workBuffer[256];
+
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ ppBuf_Real[i] = &realBuffer[i][0];
+ ppBuf_Imag[i] = &imagBuffer[i][0];
+ ppBuf_Real16[i] = &realBuffer16[i][0];
+ ppBuf_Imag16[i] = &imagBuffer16[i][0];
+ }
+
+ cldfbAnalysisFiltering( st->cldfbAnaEnc, ppBuf_Real, ppBuf_Imag, scale, timeIn, 0, CLDFB_NO_COL_MAX, workBuffer );
+
+ enerScale.lb_scale = negate( scale->lb_scale );
+ enerScale.lb_scale16 = negate( scale->lb_scale );
+
+ AnalysisPostSpectrumScaling_Fx( st->cldfbAnaEnc, ppBuf_Real, ppBuf_Imag, ppBuf_Real16, ppBuf_Imag16, &enerScale.lb_scale16 );
+
+ GetEnergyCldfb( &st->energyCoreLookahead_Fx, &st->sf_energyCoreLookahead_Fx, 1, ppBuf_Real16, ppBuf_Imag16, enerScale.lb_scale16, st->cldfbAnaEnc->no_channels, st->cldfbAnaEnc->no_col, &st->currEnergyHF_fx, &st->currEnergyHF_e_fx, ppBuf_Ener, enerBuffSum_exp, st->hTECEnc );
+
+ return;
+}
/*-------------------------------------------------------------------*
* GetEnergyCldfb_ivas()
*
@@ -1949,6 +2137,7 @@ void deleteCldfb_ivas(
{
HANDLE_CLDFB_FILTER_BANK hs = *h_cldfb;
+ test();
IF( h_cldfb == NULL || *h_cldfb == NULL )
{
return;
@@ -1959,10 +2148,15 @@ void deleteCldfb_ivas(
free( hs->cldfb_state );
}
#ifdef IVAS_FLOAT_FIXED
- if ( hs->cldfb_state_fx )
+ IF( hs->cldfb_state_fx )
{
free( hs->cldfb_state_fx );
}
+
+ IF( hs->FilterStates )
+ {
+ free( hs->FilterStates );
+ }
#endif
free( hs );
@@ -1988,10 +2182,10 @@ void deleteCldfb_ivas_fx(
free( hs->cldfb_state_fx );
}
#ifdef IVAS_FLOAT_FIXED // TODO : Will be removed later
- IF( hs->cldfb_state )
- {
- free( hs->cldfb_state );
- }
+ // IF( hs->cldfb_state )
+ //{
+ // free( hs->cldfb_state );
+ // }
#endif
free( hs );
@@ -2390,7 +2584,416 @@ static void cldfb_init_proto_and_twiddles(
return;
}
+static void cldfb_init_proto_and_twiddles_enc(
+ HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
+)
+{
+ /*find appropriate set of rotVecs*/
+ switch ( hs->no_channels )
+ {
+ case 10:
+ hs->rot_vec_ana_re = rot_vec_ana_re_L10;
+ hs->rot_vec_ana_im = rot_vec_ana_im_L10;
+ hs->rot_vec_syn_re = rot_vec_syn_re_L10;
+ hs->rot_vec_syn_im = rot_vec_syn_im_L10;
+#ifdef IVAS_FLOAT_FIXED
+ hs->rot_vec_ana_re_fx = rot_vec_ana_re_L10_fx;
+ hs->rot_vec_ana_im_fx = rot_vec_ana_im_L10_fx;
+ hs->rot_vec_syn_re_fx = rot_vec_syn_re_L10_fx;
+ hs->rot_vec_syn_im_fx = rot_vec_syn_im_L10_fx;
+ hs->rRotVctr = rRotVectr_10;
+ hs->iRotVctr = iRotVectr_10;
+ IF( hs->type == CLDFB_SYNTHESIS )
+ {
+ hs->synScalefactor = add( cldfb_synScale[0], hs->filterScale );
+ move16();
+ }
+ ELSE
+ {
+ hs->anaScalefactor = add( cldfb_anaScale[0], hs->filterScale );
+ move16();
+ }
+#endif
+ if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS )
+ {
+ hs->p_filter_flt = CLDFB80_10_flt;
+ hs->scale_flt = CLDFB80_10_SCALE;
+ hs->ds = 10;
+ hs->da = 10;
+ hs->rot_vec_ana_delay_re = NULL;
+ hs->rot_vec_ana_delay_im = NULL;
+ hs->rot_vec_syn_delay_re = NULL;
+ hs->rot_vec_syn_delay_im = NULL;
+#ifdef IVAS_FLOAT_FIXED
+ hs->p_filter_sf = (Word16) 17036;
+ hs->scale = cldfb_scale_2_5ms[0];
+ hs->p_filter = cldfb_protoFilter_2_5ms[0];
+#endif
+ }
+ else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
+ {
+ hs->p_filter_flt = LDQMF_10;
+ hs->scale_flt = LDQMF_10_SCALE;
+ hs->ds = 40;
+ hs->da = -20;
+ hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_ana_delay_im = rot_vec_delay_im_LDQMF;
+ hs->rot_vec_syn_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_syn_delay_im = rot_vec_delay_im_LDQMF;
+#ifdef IVAS_FLOAT_FIXED
+ hs->p_filter_sf = (Word16) 15388;
+ hs->p_filter = cldfb_protoFilter_5_0ms[0];
+ hs->scale = cldfb_scale_5_0ms[0];
+#endif
+ }
+ break;
+
+ case 16:
+ hs->rot_vec_ana_re = rot_vec_ana_re_L16;
+ hs->rot_vec_ana_im = rot_vec_ana_im_L16;
+ hs->rot_vec_syn_re = rot_vec_syn_re_L16;
+ hs->rot_vec_syn_im = rot_vec_syn_im_L16;
+#ifdef IVAS_FLOAT_FIXED
+ hs->rot_vec_ana_re_fx = rot_vec_ana_re_L16_fx;
+ hs->rot_vec_ana_im_fx = rot_vec_ana_im_L16_fx;
+ hs->rot_vec_syn_re_fx = rot_vec_syn_re_L16_fx;
+ hs->rot_vec_syn_im_fx = rot_vec_syn_im_L16_fx;
+ hs->rRotVctr = rRotVectr_16;
+ hs->iRotVctr = iRotVectr_16;
+ {
+ hs->anaScalefactor = add( cldfb_anaScale[1], hs->filterScale );
+ move16();
+ }
+#endif
+ if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS )
+ {
+ hs->p_filter_flt = CLDFB80_16_flt;
+ hs->scale_flt = CLDFB80_16_SCALE;
+ hs->ds = 20;
+ hs->da = 20;
+ hs->rot_vec_ana_delay_re = NULL;
+ hs->rot_vec_ana_delay_im = NULL;
+ hs->rot_vec_syn_delay_re = NULL;
+ hs->rot_vec_syn_delay_im = NULL;
+#ifdef IVAS_FLOAT_FIXED
+ hs->p_filter_sf = (Word16) 17051;
+ hs->p_filter = cldfb_protoFilter_2_5ms[1];
+ hs->scale = cldfb_scale_2_5ms[1];
+#endif
+ }
+ else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
+ {
+ hs->p_filter_flt = LDQMF_16;
+ hs->scale_flt = LDQMF_16_SCALE;
+ hs->ds = 80;
+ hs->da = -40;
+ hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_ana_delay_im = rot_vec_delay_im_LDQMF;
+ hs->rot_vec_syn_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_syn_delay_im = rot_vec_delay_im_LDQMF;
+#ifdef IVAS_FLOAT_FIXED
+ hs->p_filter_sf = (Word16) 15388;
+ hs->p_filter = cldfb_protoFilter_5_0ms[1];
+ hs->scale = cldfb_scale_5_0ms[1];
+#endif
+ }
+ break;
+
+ case 20:
+ hs->rot_vec_ana_re = rot_vec_ana_re_L20;
+ hs->rot_vec_ana_im = rot_vec_ana_im_L20;
+ hs->rot_vec_syn_re = rot_vec_syn_re_L20;
+ hs->rot_vec_syn_im = rot_vec_syn_im_L20;
+#ifdef IVAS_FLOAT_FIXED
+ hs->rRotVctr = rRotVectr_20;
+ hs->iRotVctr = iRotVectr_20;
+ hs->rot_vec_ana_re_fx = rot_vec_ana_re_L20_fx;
+ hs->rot_vec_ana_im_fx = rot_vec_ana_im_L20_fx;
+ hs->rot_vec_syn_re_fx = rot_vec_syn_re_L20_fx;
+ hs->rot_vec_syn_im_fx = rot_vec_syn_im_L20_fx;
+ IF( hs->type == CLDFB_SYNTHESIS )
+ {
+ hs->synScalefactor = add( cldfb_synScale[2], hs->filterScale );
+ move16();
+ }
+ ELSE
+ {
+ hs->anaScalefactor = add( cldfb_anaScale[2], hs->filterScale );
+ move16();
+ }
+#endif
+ if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS )
+ {
+ hs->p_filter_flt = CLDFB80_20_flt;
+ hs->scale_flt = CLDFB80_20_SCALE;
+ hs->ds = 20;
+ hs->da = 20;
+ hs->rot_vec_ana_delay_re = NULL;
+ hs->rot_vec_ana_delay_im = NULL;
+ hs->rot_vec_syn_delay_re = NULL;
+ hs->rot_vec_syn_delay_im = NULL;
+#ifdef IVAS_FLOAT_FIXED
+ hs->p_filter_sf = (Word16) 17050;
+ hs->p_filter = cldfb_protoFilter_2_5ms[2];
+ hs->scale = cldfb_scale_2_5ms[2];
+#endif
+ }
+ else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
+ {
+ hs->p_filter_flt = LDQMF_20;
+ hs->scale_flt = LDQMF_20_SCALE;
+ hs->ds = 80;
+ hs->da = -40;
+ hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_ana_delay_im = rot_vec_delay_im_LDQMF;
+ hs->rot_vec_syn_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_syn_delay_im = rot_vec_delay_im_LDQMF;
+#ifdef IVAS_FLOAT_FIXED
+ hs->p_filter_sf = (Word16) 15390;
+ hs->p_filter = cldfb_protoFilter_5_0ms[2];
+ hs->scale = cldfb_scale_5_0ms[2];
+#endif
+ }
+ break;
+ case 30:
+ hs->rot_vec_ana_re = rot_vec_ana_re_L30;
+ hs->rot_vec_ana_im = rot_vec_ana_im_L30;
+ hs->rot_vec_syn_re = rot_vec_syn_re_L30;
+ hs->rot_vec_syn_im = rot_vec_syn_im_L30;
+#ifdef IVAS_FLOAT_FIXED
+ hs->rot_vec_ana_re_fx = rot_vec_ana_re_L30_fx;
+ hs->rot_vec_ana_im_fx = rot_vec_ana_im_L30_fx;
+ hs->rot_vec_syn_re_fx = rot_vec_syn_re_L30_fx;
+ hs->rot_vec_syn_im_fx = rot_vec_syn_im_L30_fx;
+ hs->rRotVctr = rRotVectr_30;
+ hs->iRotVctr = iRotVectr_30;
+ IF( hs->type == CLDFB_SYNTHESIS )
+ {
+ hs->synScalefactor = add( cldfb_synScale[6], hs->filterScale );
+ move16();
+ }
+ ELSE
+ {
+ hs->anaScalefactor = add( cldfb_anaScale[6], hs->filterScale );
+ move16();
+ }
+#endif
+ if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS )
+ {
+ hs->p_filter_flt = CLDFB80_30_flt;
+ hs->scale_flt = CLDFB80_30_SCALE;
+ hs->ds = 30;
+ hs->da = 30;
+ hs->rot_vec_ana_delay_re = NULL;
+ hs->rot_vec_ana_delay_im = NULL;
+ hs->rot_vec_syn_delay_re = NULL;
+ hs->rot_vec_syn_delay_im = NULL;
+#ifdef IVAS_FLOAT_FIXED
+ hs->p_filter_sf = (Word16) 17051;
+ hs->scale = cldfb_scale_2_5ms[6];
+ hs->p_filter = cldfb_protoFilter_2_5ms[6];
+#endif
+ }
+ else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
+ {
+ hs->p_filter_flt = LDQMF_30;
+ hs->scale_flt = LDQMF_30_SCALE;
+ hs->ds = 120;
+ hs->da = -60;
+ hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_ana_delay_im = rot_vec_delay_im_LDQMF;
+ hs->rot_vec_syn_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_syn_delay_im = rot_vec_delay_im_LDQMF;
+#ifdef IVAS_FLOAT_FIXED
+ hs->p_filter_sf = (Word16) 15388;
+ hs->scale = cldfb_scale_5_0ms[6];
+ hs->p_filter = cldfb_protoFilter_5_0ms[6];
+#endif
+ }
+ break;
+
+ case 32:
+ hs->rot_vec_ana_re = rot_vec_ana_re_L32;
+ hs->rot_vec_ana_im = rot_vec_ana_im_L32;
+ hs->rot_vec_syn_re = rot_vec_syn_re_L32;
+ hs->rot_vec_syn_im = rot_vec_syn_im_L32;
+#ifdef IVAS_FLOAT_FIXED
+ hs->rot_vec_ana_re_fx = rot_vec_ana_re_L32_fx;
+ hs->rot_vec_ana_im_fx = rot_vec_ana_im_L32_fx;
+ hs->rot_vec_syn_re_fx = rot_vec_syn_re_L32_fx;
+ hs->rot_vec_syn_im_fx = rot_vec_syn_im_L32_fx;
+ hs->rRotVctr = rRotVectr_32;
+ hs->iRotVctr = iRotVectr_32;
+ {
+ hs->anaScalefactor = add( cldfb_anaScale[3], hs->filterScale );
+ move16();
+ }
+#endif
+ if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS )
+ {
+ hs->p_filter_flt = CLDFB80_32_flt;
+ hs->scale_flt = CLDFB80_32_SCALE;
+ hs->ds = 32;
+ hs->da = 32;
+ hs->rot_vec_ana_delay_re = NULL;
+ hs->rot_vec_ana_delay_im = NULL;
+ hs->rot_vec_syn_delay_re = NULL;
+ hs->rot_vec_syn_delay_im = NULL;
+#ifdef IVAS_FLOAT_FIXED
+ hs->p_filter_sf = (Word16) 17050;
+ hs->p_filter = cldfb_protoFilter_2_5ms[3];
+ hs->scale = cldfb_scale_2_5ms[3];
+#endif
+ }
+ else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
+ {
+ hs->p_filter_flt = LDQMF_32;
+ hs->scale_flt = LDQMF_32_SCALE;
+ hs->ds = 160;
+ hs->da = -80;
+ hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_ana_delay_im = rot_vec_delay_im_LDQMF;
+ hs->rot_vec_syn_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_syn_delay_im = rot_vec_delay_im_LDQMF;
+#ifdef IVAS_FLOAT_FIXED
+ hs->p_filter_sf = (Word16) 15392;
+ hs->scale = cldfb_scale_5_0ms[3];
+ hs->p_filter = cldfb_protoFilter_5_0ms[3];
+#endif
+ }
+ break;
+
+ case 40:
+ hs->rot_vec_ana_re = rot_vec_ana_re_L40;
+ hs->rot_vec_ana_im = rot_vec_ana_im_L40;
+ hs->rot_vec_syn_re = rot_vec_syn_re_L40;
+ hs->rot_vec_syn_im = rot_vec_syn_im_L40;
+#ifdef IVAS_FLOAT_FIXED
+ hs->rot_vec_ana_re_fx = rot_vec_ana_re_L40_fx;
+ hs->rot_vec_ana_im_fx = rot_vec_ana_im_L40_fx;
+ hs->rot_vec_syn_re_fx = rot_vec_syn_re_L40_fx;
+ hs->rot_vec_syn_im_fx = rot_vec_syn_im_L40_fx;
+ hs->rRotVctr = rRotVectr_40;
+ hs->iRotVctr = iRotVectr_40;
+ IF( hs->type == CLDFB_SYNTHESIS )
+ {
+ hs->synScalefactor = add( cldfb_synScale[4], hs->filterScale );
+ move16();
+ }
+ ELSE
+ {
+ hs->anaScalefactor = add( cldfb_anaScale[4], hs->filterScale );
+ move16();
+ }
+#endif
+ if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS )
+ {
+ hs->p_filter_flt = CLDFB80_40_flt;
+ hs->scale_flt = CLDFB80_40_SCALE;
+ hs->ds = 40;
+ hs->da = 40;
+ hs->rot_vec_ana_delay_re = NULL;
+ hs->rot_vec_ana_delay_im = NULL;
+ hs->rot_vec_syn_delay_re = NULL;
+ hs->rot_vec_syn_delay_im = NULL;
+#ifdef IVAS_FLOAT_FIXED
+ hs->p_filter_sf = (Word16) 17051;
+ hs->q_scale = norm_s( (Word16) CLDFB80_40_SCALE );
+ hs->scale = cldfb_scale_2_5ms[4];
+ hs->p_filter = cldfb_protoFilter_2_5ms[4];
+#endif
+ }
+ else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
+ {
+ hs->p_filter_flt = LDQMF_40;
+ hs->scale_flt = LDQMF_40_SCALE;
+ hs->ds = 160;
+ hs->da = -80;
+ hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_ana_delay_im = rot_vec_delay_im_LDQMF;
+ hs->rot_vec_syn_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_syn_delay_im = rot_vec_delay_im_LDQMF;
+#ifdef IVAS_FLOAT_FIXED
+ hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
+ hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+ hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
+ hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+ hs->p_filter_sf = (Word16) 15391;
+ hs->p_filter = cldfb_protoFilter_5_0ms[4];
+ hs->scale = cldfb_scale_5_0ms[4];
+#endif
+ }
+ break;
+
+ case 60:
+ hs->rot_vec_ana_re = rot_vec_ana_re_L60;
+ hs->rot_vec_ana_im = rot_vec_ana_im_L60;
+ hs->rot_vec_syn_re = rot_vec_syn_re_L60;
+ hs->rot_vec_syn_im = rot_vec_syn_im_L60;
+#ifdef IVAS_FLOAT_FIXED
+ hs->rot_vec_ana_re_fx = rot_vec_ana_re_L60_fx;
+ hs->rot_vec_ana_im_fx = rot_vec_ana_im_L60_fx;
+ hs->rot_vec_syn_re_fx = rot_vec_syn_re_L60_fx;
+ hs->rot_vec_syn_im_fx = rot_vec_syn_im_L60_fx;
+ hs->rRotVctr = rRotVectr_60;
+ hs->iRotVctr = iRotVectr_60;
+ IF( hs->type == CLDFB_SYNTHESIS )
+ {
+ hs->synScalefactor = add( cldfb_synScale[5], hs->filterScale );
+ move16();
+ }
+ ELSE
+ {
+ hs->anaScalefactor = add( cldfb_anaScale[5], hs->filterScale );
+ move16();
+ }
+#endif
+ if ( hs->prototype == CLDFB_PROTOTYPE_1_25MS )
+ {
+ hs->p_filter_flt = CLDFB80_60_flt;
+ hs->scale_flt = CLDFB80_60_SCALE;
+ hs->ds = 60;
+ hs->da = 60;
+ hs->rot_vec_ana_delay_re = NULL;
+ hs->rot_vec_ana_delay_im = NULL;
+ hs->rot_vec_syn_delay_re = NULL;
+ hs->rot_vec_syn_delay_im = NULL;
+#ifdef IVAS_FLOAT_FIXED
+ hs->rot_vec_ana_delay_re_fx = NULL;
+ hs->rot_vec_ana_delay_im_fx = NULL;
+ hs->rot_vec_syn_delay_re_fx = NULL;
+ hs->rot_vec_syn_delay_im_fx = NULL;
+ hs->p_filter_sf = (Word16) 17051;
+ hs->p_filter = cldfb_protoFilter_2_5ms[5];
+ hs->scale = cldfb_scale_2_5ms[5];
+#endif
+ }
+ else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
+ {
+ hs->p_filter_flt = LDQMF_60;
+ hs->scale_flt = LDQMF_60_SCALE;
+ hs->ds = 240;
+ hs->da = -120;
+ hs->rot_vec_ana_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_ana_delay_im = rot_vec_delay_im_LDQMF;
+ hs->rot_vec_syn_delay_re = rot_vec_delay_re_LDQMF;
+ hs->rot_vec_syn_delay_im = rot_vec_delay_im_LDQMF;
+#ifdef IVAS_FLOAT_FIXED
+ hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
+ hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+ hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
+ hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
+ hs->p_filter_sf = (Word16) 15391;
+ hs->p_filter = cldfb_protoFilter_5_0ms[5];
+ hs->scale = cldfb_scale_5_0ms[5];
+#endif
+ }
+ break;
+ }
+
+ return;
+}
/*-------------------------------------------------------------------*
* cldfb_save_memory_ivas()
*
@@ -2403,7 +3006,7 @@ ivas_error cldfb_save_memory_ivas_fx(
{
UWord16 offset = sub( hs->p_filter_length, hs->no_channels );
- IF( hs->memory_flt != NULL || NE_16( hs->memory_length, 0 ) )
+ IF( hs->memory_flt != NULL || ( hs->memory_length != 0 ) )
{
/* memory already stored; Free memory first */
return IVAS_ERR_OK;
@@ -2434,8 +3037,7 @@ ivas_error cldfb_save_memory_ivas_fx(
return IVAS_ERR_OK;
}
-#endif // IVAS_FLOAT_FIXED
-
+#else
ivas_error cldfb_save_memory_ivas(
HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
)
@@ -2467,7 +3069,7 @@ ivas_error cldfb_save_memory_ivas(
return IVAS_ERR_OK;
}
-
+#endif
/*-------------------------------------------------------------------*
* cldfb_restore_memory_ivas()
@@ -2481,13 +3083,14 @@ void cldfb_restore_memory_ivas_fx(
{
UWord16 offset = sub( hs->p_filter_length, hs->no_channels );
UWord16 size;
+ test();
IF( hs->memory_flt == NULL || EQ_16( hs->memory_length, 0 ) )
{
/* memory not allocated */
return;
}
- IF( EQ_16( hs->type, CLDFB_ANALYSIS ) )
+ IF( hs->type == CLDFB_ANALYSIS )
{
size = offset;
move16();
@@ -2507,7 +3110,9 @@ void cldfb_restore_memory_ivas_fx(
L_lerp_fx_q11( hs->cldfb_state_fx, hs->cldfb_state_fx, size, hs->memory_length );
}
hs->cldfb_state_length = size;
+ move16();
hs->memory_length = 0;
+ move16();
#if 1 // Remove later
free( hs->memory_flt );
hs->memory_flt = NULL;
@@ -2517,8 +3122,7 @@ void cldfb_restore_memory_ivas_fx(
return;
}
-#endif // IVAS_FLOAT_FIXED
-
+#else
void cldfb_restore_memory_ivas(
HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
)
@@ -2556,7 +3160,7 @@ void cldfb_restore_memory_ivas(
return;
}
-
+#endif
/*-------------------------------------------------------------------*
* cldfb_reset_memory_ivas()
@@ -2596,16 +3200,20 @@ void cldfb_reset_memory_fx(
IF( hs->type == CLDFB_ANALYSIS )
{
memory_length = offset;
+ move16();
}
ELSE
{
memory_length = hs->p_filter_length;
+ move16();
}
hs->cldfb_state_length = memory_length;
+ move16();
/* save the memory */
set32_fx( hs->cldfb_state_fx, 0, memory_length );
hs->Q_cldfb_state = Q11;
+ move16();
return;
}
diff --git a/lib_com/cldfb_evs.c b/lib_com/cldfb_evs.c
index 59c8df22186294ae1abb94a73f6e441505023d76..bad77d7f177404ce7c2f942a7755c43b336f0d0d 100644
--- a/lib_com/cldfb_evs.c
+++ b/lib_com/cldfb_evs.c
@@ -20,8 +20,7 @@
#include "stat_com.h"
#include "rom_com.h"
#include "basop_util.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include
#define STATE_BUFFER_SIZE ( 9 + 16 )
@@ -230,19 +229,21 @@ static void calcModulation( Word32 *rYR,
{
cmplx CL_x, CL_z;
cmplx_s C_c;
- int i;
- int lc = m >> 1;
+ Word32 i;
+ Word32 lc = L_shr( m, 1 );
const Word16 *cr = rRotVctr;
const Word16 *ci = iRotVctr;
- for ( i = 0; i < lc; i++ )
+ FOR( i = 0; i < lc; i++ )
{
CL_x = CL_form( *rXR, *rXI );
C_c = C_form( *cr, *ci );
CL_z = CL_mult_32x16( CL_x, C_c );
*rYR = CL_Extract_real( CL_z );
+ move64();
*rYI = CL_Extract_imag( CL_z );
+ move64();
rYR += srYR;
rYI += srYI;
rXR += srXR;
@@ -251,7 +252,9 @@ static void calcModulation( Word32 *rYR,
CL_x = CL_form( *iXR, *iXI );
CL_z = CL_mult_32x16( CL_x, C_c );
*iYR = CL_Extract_real( CL_z );
+ move64();
*iYI = CL_Extract_imag( CL_z );
+ move64();
iYR += siYR;
iYI += siYI;
iXR += siXR;
@@ -298,14 +301,14 @@ static void calcModulationAndFolding( Word16 *rY,
const Word16 *r11, *r12, *r21, *r22;
- y11 = &rY[m + m2 + 1];
- y12 = &rY[m2 - 2];
- y13 = &rY[m + m2 - 2];
+ y11 = &rY[add( add( m, m2 ), 1 )];
+ y12 = &rY[sub( m2, 2 )];
+ y13 = &rY[sub( add( m, m2 ), 2 )];
y14 = &rY[m2 + 1];
- y21 = &rY[m + m2];
+ y21 = &rY[add( m, m2 )];
y22 = &rY[m2 - 1];
- y23 = &rY[m + m2 - 1];
+ y23 = &rY[sub( add( m, m2 ), 1 )];
y24 = &rY[m2];
x11 = &rX[m - 2];
@@ -416,6 +419,7 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
stride = 1; /* constant */
+ move16();
m = cldfbBank->no_channels;
move16();
L2 = shl( m, 1 );
@@ -447,12 +451,12 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
p_stride = CLDFB_NO_POLY;
pFilter = &cldfbBank->p_filter[p_stride - CLDFB_NO_POLY];
- pFilter1 = &pFilter[p_stride * L3M1];
- pFilter2 = &pFilter[p_stride * L3];
- pFilter3 = &pFilter[p_stride * m2];
- pFilter4 = &pFilter[p_stride * M2M1];
- pFilter5 = &pFilter[p_stride * L4M1];
- pFilter6 = &pFilter[p_stride * M0M2];
+ pFilter1 = &pFilter[i_mult( p_stride, L3M1 )];
+ pFilter2 = &pFilter[i_mult( p_stride, L3 )];
+ pFilter3 = &pFilter[i_mult( p_stride, m2 )];
+ pFilter4 = &pFilter[i_mult( p_stride, M2M1 )];
+ pFilter5 = &pFilter[i_mult( p_stride, L4M1 )];
+ pFilter6 = &pFilter[i_mult( p_stride, M0M2 )];
nSamples = i_mult( nTimeSlots, cldfbBank->no_channels );
nSamplesUpd = i_mult( cldfbBank->no_col, cldfbBank->no_channels );
@@ -465,7 +469,7 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
move16();
FOR( i = 0; i < offset; i += cldfbBank->no_channels )
{
- cldfbBank->FilterStates_e[k] = cldfbBank->FilterStates_e[k + cldfbBank->no_col];
+ cldfbBank->FilterStates_e[k] = cldfbBank->FilterStates_e[add( k, cldfbBank->no_col )];
move16();
assert( (size_t) k < sizeof( cldfbBank->FilterStates_e ) / sizeof( cldfbBank->FilterStates_e[0] ) );
scale = s_max( scale, cldfbBank->FilterStates_e[k] );
@@ -517,80 +521,80 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
FOR( i = 0; i < M4; i++ )
{
/* prototype filter */
- r1 = L_msu0( 0, pFilter1[0 - p_stride * 2 * i], pStates1[0 * L2 - 2 * i] );
- r1 = L_msu0( r1, pFilter1[1 - p_stride * 2 * i], pStates1[1 * L2 - 2 * i] );
- r1 = L_msu0( r1, pFilter1[2 - p_stride * 2 * i], pStates1[2 * L2 - 2 * i] );
- r1 = L_msu0( r1, pFilter1[3 - p_stride * 2 * i], pStates1[3 * L2 - 2 * i] );
- r1 = L_msu0( r1, pFilter1[4 - p_stride * 2 * i], pStates1[4 * L2 - 2 * i] );
-
- r2 = L_msu0( 0, pFilter2[0 + p_stride * 2 * i], pStates2[0 * L2 + 2 * i] );
- r2 = L_msu0( r2, pFilter2[1 + p_stride * 2 * i], pStates2[1 * L2 + 2 * i] );
- r2 = L_msu0( r2, pFilter2[2 + p_stride * 2 * i], pStates2[2 * L2 + 2 * i] );
- r2 = L_msu0( r2, pFilter2[3 + p_stride * 2 * i], pStates2[3 * L2 + 2 * i] );
- r2 = L_msu0( r2, pFilter2[4 + p_stride * 2 * i], pStates2[4 * L2 + 2 * i] );
-
- i1 = L_msu0( 0, pFilter3[0 + p_stride * 2 * i], pStates3[0 * L2 + 2 * i] );
- i1 = L_msu0( i1, pFilter3[1 + p_stride * 2 * i], pStates3[1 * L2 + 2 * i] );
- i1 = L_msu0( i1, pFilter3[2 + p_stride * 2 * i], pStates3[2 * L2 + 2 * i] );
- i1 = L_msu0( i1, pFilter3[3 + p_stride * 2 * i], pStates3[3 * L2 + 2 * i] );
- i1 = L_msu0( i1, pFilter3[4 + p_stride * 2 * i], pStates3[4 * L2 + 2 * i] );
-
- i2 = L_msu0( 0, pFilter4[0 - p_stride * 2 * i], pStates4[0 * L2 - 2 * i] );
- i2 = L_msu0( i2, pFilter4[1 - p_stride * 2 * i], pStates4[1 * L2 - 2 * i] );
- i2 = L_msu0( i2, pFilter4[2 - p_stride * 2 * i], pStates4[2 * L2 - 2 * i] );
- i2 = L_msu0( i2, pFilter4[3 - p_stride * 2 * i], pStates4[3 * L2 - 2 * i] );
- i2 = L_msu0( i2, pFilter4[4 - p_stride * 2 * i], pStates4[4 * L2 - 2 * i] );
+ r1 = L_msu0( 0, pFilter1[sub( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 0, L2 ), shl( i, 1 ) )] );
+ r1 = L_msu0( r1, pFilter1[sub( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 1, L2 ), shl( i, 1 ) )] );
+ r1 = L_msu0( r1, pFilter1[sub( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 2, L2 ), shl( i, 1 ) )] );
+ r1 = L_msu0( r1, pFilter1[sub( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 3, L2 ), shl( i, 1 ) )] );
+ r1 = L_msu0( r1, pFilter1[sub( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 4, L2 ), shl( i, 1 ) )] );
+
+ r2 = L_msu0( 0, pFilter2[add( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates2[add( i_mult( 0, L2 ), shl( i, 1 ) )] );
+ r2 = L_msu0( r2, pFilter2[add( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates2[add( i_mult( 1, L2 ), shl( i, 1 ) )] );
+ r2 = L_msu0( r2, pFilter2[add( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates2[add( i_mult( 2, L2 ), shl( i, 1 ) )] );
+ r2 = L_msu0( r2, pFilter2[add( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates2[add( i_mult( 3, L2 ), shl( i, 1 ) )] );
+ r2 = L_msu0( r2, pFilter2[add( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates2[add( i_mult( 4, L2 ), shl( i, 1 ) )] );
+
+ i1 = L_msu0( 0, pFilter3[add( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 0, L2 ), shl( i, 1 ) )] );
+ i1 = L_msu0( i1, pFilter3[add( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 1, L2 ), shl( i, 1 ) )] );
+ i1 = L_msu0( i1, pFilter3[add( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 2, L2 ), shl( i, 1 ) )] );
+ i1 = L_msu0( i1, pFilter3[add( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 3, L2 ), shl( i, 1 ) )] );
+ i1 = L_msu0( i1, pFilter3[add( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 4, L2 ), shl( i, 1 ) )] );
+
+ i2 = L_msu0( 0, pFilter4[sub( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates4[sub( i_mult( 0, L2 ), shl( i, 1 ) )] );
+ i2 = L_msu0( i2, pFilter4[sub( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates4[sub( i_mult( 1, L2 ), shl( i, 1 ) )] );
+ i2 = L_msu0( i2, pFilter4[sub( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates4[sub( i_mult( 2, L2 ), shl( i, 1 ) )] );
+ i2 = L_msu0( i2, pFilter4[sub( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates4[sub( i_mult( 3, L2 ), shl( i, 1 ) )] );
+ i2 = L_msu0( i2, pFilter4[sub( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates4[sub( i_mult( 4, L2 ), shl( i, 1 ) )] );
/* folding */
rBuffer[2 * i] = L_sub( r1, r2 );
move32();
- rBuffer[2 * i + 1] = L_negate( L_add( i1, i2 ) );
+ rBuffer[add( shl( i, 1 ), 1 )] = L_negate( L_add( i1, i2 ) );
move32();
/* folding */
iBuffer[2 * i] = L_add( r1, r2 );
move32();
- iBuffer[2 * i + 1] = L_sub( i1, i2 );
+ iBuffer[add( shl( i, 1 ), 1 )] = L_sub( i1, i2 );
move32();
}
FOR( i = M4; i < m2; i++ )
{
/* prototype filter */
- r1 = L_msu0( 0, pFilter1[0 - p_stride * 2 * i], pStates1[0 * L2 - 2 * i] );
- r1 = L_msu0( r1, pFilter1[1 - p_stride * 2 * i], pStates1[1 * L2 - 2 * i] );
- r1 = L_msu0( r1, pFilter1[2 - p_stride * 2 * i], pStates1[2 * L2 - 2 * i] );
- r1 = L_msu0( r1, pFilter1[3 - p_stride * 2 * i], pStates1[3 * L2 - 2 * i] );
- r1 = L_msu0( r1, pFilter1[4 - p_stride * 2 * i], pStates1[4 * L2 - 2 * i] );
-
- r2 = L_msu0( 0, pFilter6[0 + p_stride * 2 * i], pStates6[0 * L2 + 2 * i] );
- r2 = L_msu0( r2, pFilter6[1 + p_stride * 2 * i], pStates6[1 * L2 + 2 * i] );
- r2 = L_msu0( r2, pFilter6[2 + p_stride * 2 * i], pStates6[2 * L2 + 2 * i] );
- r2 = L_msu0( r2, pFilter6[3 + p_stride * 2 * i], pStates6[3 * L2 + 2 * i] );
- r2 = L_msu0( r2, pFilter6[4 + p_stride * 2 * i], pStates6[4 * L2 + 2 * i] );
-
- i1 = L_msu0( 0, pFilter5[0 - p_stride * 2 * i], pStates5[0 * L2 - 2 * i] );
- i1 = L_msu0( i1, pFilter5[1 - p_stride * 2 * i], pStates5[1 * L2 - 2 * i] );
- i1 = L_msu0( i1, pFilter5[2 - p_stride * 2 * i], pStates5[2 * L2 - 2 * i] );
- i1 = L_msu0( i1, pFilter5[3 - p_stride * 2 * i], pStates5[3 * L2 - 2 * i] );
- i1 = L_msu0( i1, pFilter5[4 - p_stride * 2 * i], pStates5[4 * L2 - 2 * i] );
-
- i2 = L_msu0( 0, pFilter3[0 + p_stride * 2 * i], pStates3[0 * L2 + 2 * i] );
- i2 = L_msu0( i2, pFilter3[1 + p_stride * 2 * i], pStates3[1 * L2 + 2 * i] );
- i2 = L_msu0( i2, pFilter3[2 + p_stride * 2 * i], pStates3[2 * L2 + 2 * i] );
- i2 = L_msu0( i2, pFilter3[3 + p_stride * 2 * i], pStates3[3 * L2 + 2 * i] );
- i2 = L_msu0( i2, pFilter3[4 + p_stride * 2 * i], pStates3[4 * L2 + 2 * i] );
+ r1 = L_msu0( 0, pFilter1[sub( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 0, L2 ), shl( i, 1 ) )] );
+ r1 = L_msu0( r1, pFilter1[sub( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 1, L2 ), shl( i, 1 ) )] );
+ r1 = L_msu0( r1, pFilter1[sub( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 2, L2 ), shl( i, 1 ) )] );
+ r1 = L_msu0( r1, pFilter1[sub( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 3, L2 ), shl( i, 1 ) )] );
+ r1 = L_msu0( r1, pFilter1[sub( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 4, L2 ), shl( i, 1 ) )] );
+
+ r2 = L_msu0( 0, pFilter6[add( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates6[add( i_mult( 0, L2 ), shl( i, 1 ) )] );
+ r2 = L_msu0( r2, pFilter6[add( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates6[add( i_mult( 1, L2 ), shl( i, 1 ) )] );
+ r2 = L_msu0( r2, pFilter6[add( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates6[add( i_mult( 2, L2 ), shl( i, 1 ) )] );
+ r2 = L_msu0( r2, pFilter6[add( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates6[add( i_mult( 3, L2 ), shl( i, 1 ) )] );
+ r2 = L_msu0( r2, pFilter6[add( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates6[add( i_mult( 4, L2 ), shl( i, 1 ) )] );
+
+ i1 = L_msu0( 0, pFilter5[sub( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates5[sub( i_mult( 0, L2 ), shl( i, 1 ) )] );
+ i1 = L_msu0( i1, pFilter5[sub( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates5[sub( i_mult( 1, L2 ), shl( i, 1 ) )] );
+ i1 = L_msu0( i1, pFilter5[sub( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates5[sub( i_mult( 2, L2 ), shl( i, 1 ) )] );
+ i1 = L_msu0( i1, pFilter5[sub( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates5[sub( i_mult( 3, L2 ), shl( i, 1 ) )] );
+ i1 = L_msu0( i1, pFilter5[sub( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates5[sub( i_mult( 4, L2 ), shl( i, 1 ) )] );
+
+ i2 = L_msu0( 0, pFilter3[add( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 0, L2 ), shl( i, 1 ) )] );
+ i2 = L_msu0( i2, pFilter3[add( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 1, L2 ), shl( i, 1 ) )] );
+ i2 = L_msu0( i2, pFilter3[add( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 2, L2 ), shl( i, 1 ) )] );
+ i2 = L_msu0( i2, pFilter3[add( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 3, L2 ), shl( i, 1 ) )] );
+ i2 = L_msu0( i2, pFilter3[add( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 4, L2 ), shl( i, 1 ) )] );
/* folding */
rBuffer[2 * i] = L_add( r1, r2 );
move32();
- rBuffer[2 * i + 1] = L_sub( i1, i2 );
+ rBuffer[add( shl( i, 1 ), 1 )] = L_sub( i1, i2 );
move32();
/* folding */
iBuffer[2 * i] = L_sub( r1, r2 );
move32();
- iBuffer[2 * i + 1] = L_add( i1, i2 );
+ iBuffer[add( shl( i, 1 ), 1 )] = L_add( i1, i2 );
move32();
}
@@ -722,7 +726,7 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
iBuffer = &pWorkBuffer[m];
nBuffer = (Word16 *) ( &pWorkBuffer[L2] );
- rAnalysisS = &pWorkBuffer[3 * m];
+ rAnalysisS = &pWorkBuffer[i_mult( 3, m )];
iAnalysisS = &pWorkBuffer[4 * m];
rRotVctr = cldfbBank->rRotVctr;
@@ -784,7 +788,9 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
FOR( ; i < m; i += 2 )
{
rAnalysisS[i] = L_deposit_l( 0 );
+ move32();
iAnalysisS[i] = L_deposit_l( 0 );
+ move32();
}
}
@@ -812,7 +818,9 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
FOR( ; i < m; i += 2 )
{
rAnalysisS[i] = L_deposit_l( 0 );
+ move32();
iAnalysisS[i] = L_deposit_l( 0 );
+ move32();
}
}
}
@@ -837,14 +845,14 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
calcModulationAndFolding( nBuffer, rBuffer, iBuffer, rRotVctr, iRotVctr, cldfbBank->synGain, scale, m, m2 );
/* prototype filter */
- pStates = &cldfbBank->FilterStates[k * L2];
+ pStates = &cldfbBank->FilterStates[i_mult( k, L2 )];
pFilterS = &cldfbBank->p_filter[0];
pFilterM = &cldfbBank->p_filter[shr( cldfbBank->p_filter_length, 1 )];
FOR( i = 0; i < channels0; i++ )
{
pStatesI = &pStates[i];
- pStatesR = &pStates[i + channels3];
+ pStatesR = &pStates[add( i, channels3 )];
acc = L_mult( *pStatesI, *pFilterS++ );
acc = L_mac( acc, *pStatesR, *pFilterM++ );
@@ -866,21 +874,22 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
pStatesI += channels4;
acc = L_mac( acc, *pStatesI, *pFilterS++ );
- acc = L_mac( acc, nBuffer[channels1 - i], *pFilterM++ );
+ acc = L_mac( acc, nBuffer[sub( channels1, i )], *pFilterM++ );
BASOP_SATURATE_WARNING_OFF_EVS
#ifdef BASOP_NOGLOB
- timeOut[( offset1 - i ) * stride] = round_fx_sat( L_shl_sat( acc, outScale ) );
+ timeOut[i_mult( sub( offset1, i ), stride )] = round_fx_sat( L_shl_sat( acc, outScale ) );
#else
timeOut[( offset1 - i ) * stride] = round_fx( L_shl( acc, outScale ) );
#endif
BASOP_SATURATE_WARNING_ON_EVS
+ move16();
}
FOR( ; i < cldfbBank->no_channels; i++ )
{
- pStatesI = &pStates[i + channels2];
- pStatesR = &pStates[i + channels2 + channels3];
+ pStatesI = &pStates[add( i, channels2 )];
+ pStatesR = &pStates[add( add( i, channels2 ), channels3 )];
acc = L_mult( *pStatesI, *pFilterS++ );
acc = L_mac( acc, *pStatesR, *pFilterM++ );
@@ -905,22 +914,23 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
BASOP_SATURATE_WARNING_OFF_EVS
#ifdef BASOP_NOGLOB
- timeOut[( offset2 - i ) * stride] = round_fx_sat( L_shl_sat( acc, outScale ) );
+ timeOut[i_mult( sub( offset2, i ), stride )] = round_fx_sat( L_shl_sat( acc, outScale ) );
#else
timeOut[( offset2 - i ) * stride] = round_fx( L_shl( acc, outScale ) );
#endif
BASOP_SATURATE_WARNING_ON_EVS
+ move16();
}
FOR( i = 0; i < cldfbBank->no_channels; i++ )
{
- pStates[statesSizeM1 + i] = nBuffer[channels1 - i];
+ pStates[add( statesSizeM1, i )] = nBuffer[sub( channels1, i )];
move16();
- pStates[statesSizeM2 + i] = nBuffer[channels1 + m - i];
+ pStates[add( statesSizeM2, i )] = nBuffer[sub( add( channels1, m ), i )];
move16();
}
- timeOut = &timeOut[m * stride];
+ timeOut = &timeOut[i_mult( m, stride )];
}
/* move filter states */
@@ -945,6 +955,7 @@ void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */
move16();
assert( h_cldfb->no_channels >= 10 );
h_cldfb->no_col = div_l( frameSize, shr( h_cldfb->no_channels, 1 ) );
+ move16();
/* was cldfbInitFilterBank()*/
h_cldfb->anaScalefactor = 0;
@@ -964,6 +975,7 @@ void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */
move16();
h_cldfb->flags = s_or( h_cldfb->flags, CLDFB_FLAG_2_5MS_SETUP );
+ move16();
h_cldfb->filterScale = CLDFB_CLDFB80_PFT_SCALE;
move16();
@@ -1005,7 +1017,7 @@ ivas_error openCldfb(
HANDLE_CLDFB_FILTER_BANK hs;
hs = (HANDLE_CLDFB_FILTER_BANK) count_malloc( sizeof( CLDFB_FILTER_BANK ) );
- if ( hs == NULL )
+ IF( hs == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
}
@@ -1048,7 +1060,7 @@ ivas_error openCldfb(
move16();
}
}
- ELSE IF( hs->type == CLDFB_SYNTHESIS )
+ ELSE IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) )
{
IF( hs->FilterStates != 0 )
{
@@ -1102,8 +1114,8 @@ void resampleCldfb( HANDLE_CLDFB_FILTER_BANK hs,
IF( firstFrame == 0 )
{
/*low complexity-resampling only stored previous samples that are needed for next frame modulation */
- lerp( hs->FilterStates + ( noChannelsOld * hs->no_col ), hs->FilterStates + ( noChannelsOld * hs->no_col ), timeOffset, timeOffsetOld );
- Copy( hs->FilterStates + ( noChannelsOld * hs->no_col ), hs->FilterStates + frameSize, timeOffset );
+ lerp( hs->FilterStates + i_mult( noChannelsOld, hs->no_col ), hs->FilterStates + i_mult( noChannelsOld, hs->no_col ), timeOffset, timeOffsetOld );
+ Copy( hs->FilterStates + i_mult( noChannelsOld, hs->no_col ), hs->FilterStates + frameSize, timeOffset );
}
return;
@@ -1159,6 +1171,8 @@ AnalysisPostSpectrumScaling_Fx( HANDLE_CLDFB_FILTER_BANK cldfbBank, /*!< Handle
rSubband16[i][j] = round_fx( L_shl( rSubband32[i][j], headRoom ) );
iSubband16[i][j] = round_fx( L_shl( iSubband32[i][j], headRoom ) );
#endif
+ move32();
+ move32();
}
}
@@ -1195,6 +1209,7 @@ void analysisCldfbEncoder_fx(
Word16 *ppBuf_Imag16[CLDFB_NO_COL_MAX];
Word32 workBuffer[256];
Word16 num_slots = 1;
+ move16();
FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
{
@@ -1272,6 +1287,7 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead)
// Word16 freqTable[2] = {20, 40};
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
FOR( k = 0; k < numberCols; k++ )
@@ -1286,7 +1302,7 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead)
}
}
- IF( GE_16( numberBands, freqTable[1] ) )
+ IF( GE_16( numberBands, freqTable[1] ) && hTecEnc != NULL )
{
Word32 *tempEnergyValuesArry[CLDFB_NO_COL_MAX];
Word16 ScaleX2;
@@ -1310,12 +1326,13 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead)
FOR( j = 0; j < numberBands; j++ )
{
energyValuesSum[j] = L_deposit_l( 0 );
+ move32();
energyValuesSumE[j] = 31;
move16();
FOR( k = 0; k < CLDFB_NO_COL_MAX; k++ )
{
nrg = L_shr_r( energyValues[k][j], sub( energyValuesSumE[j], 31 ) );
- IF( L_sub( maxWord32, nrg ) < energyValuesSum[j] )
+ IF( LT_32( L_sub( maxWord32, nrg ), energyValuesSum[j] ) )
{
energyValuesSumE[j] = add( energyValuesSumE[j], 1 );
move16();
@@ -1327,9 +1344,10 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead)
move32();
}
test();
- IF( j == 0 || GT_16( energyValuesSumE[j], *energyValuesSum_Exp ) )
+ if ( j == 0 || GT_16( energyValuesSumE[j], *energyValuesSum_Exp ) )
{
*energyValuesSum_Exp = energyValuesSumE[j];
+ move16();
}
}
FOR( j = 0; j < numberBands; j++ )
@@ -1419,6 +1437,7 @@ CLDFB_getNumChannels( Word32 sampleRate )
{
Word16 nChannels = 0;
+ move16();
SWITCH( sampleRate )
@@ -1510,7 +1529,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle
hs->p_filter = cldfb_protoFilter_2_5ms[0];
hs->scale = cldfb_scale_2_5ms[0];
move16();
- IF( hs->type == CLDFB_SYNTHESIS )
+ IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) )
{
hs->synScalefactor = add( cldfb_synScale[0], hs->filterScale );
move16();
@@ -1520,7 +1539,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle
hs->anaScalefactor = add( cldfb_anaScale[0], hs->filterScale );
move16();
}
- break;
+ BREAK;
case 16:
hs->rRotVctr = rRotVectr_16;
@@ -1534,7 +1553,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle
hs->anaScalefactor = add( cldfb_anaScale[1], hs->filterScale );
move16();
}
- break;
+ BREAK;
case 20:
hs->rRotVctr = rRotVectr_20;
@@ -1544,7 +1563,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle
hs->p_filter = cldfb_protoFilter_2_5ms[2];
hs->scale = cldfb_scale_2_5ms[2];
move16();
- IF( hs->type == CLDFB_SYNTHESIS )
+ IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) )
{
hs->synScalefactor = add( cldfb_synScale[2], hs->filterScale );
move16();
@@ -1554,7 +1573,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle
hs->anaScalefactor = add( cldfb_anaScale[2], hs->filterScale );
move16();
}
- break;
+ BREAK;
case 32:
hs->rRotVctr = rRotVectr_32;
@@ -1568,7 +1587,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle
hs->anaScalefactor = add( cldfb_anaScale[3], hs->filterScale );
move16();
}
- break;
+ BREAK;
case 40:
hs->rRotVctr = rRotVectr_40;
@@ -1578,7 +1597,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle
hs->p_filter = cldfb_protoFilter_2_5ms[4];
hs->scale = cldfb_scale_2_5ms[4];
move16();
- IF( hs->type == CLDFB_SYNTHESIS )
+ IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) )
{
hs->synScalefactor = add( cldfb_synScale[4], hs->filterScale );
move16();
@@ -1588,7 +1607,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle
hs->anaScalefactor = add( cldfb_anaScale[4], hs->filterScale );
move16();
}
- break;
+ BREAK;
case 60:
hs->rRotVctr = rRotVectr_60;
@@ -1598,7 +1617,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle
hs->p_filter = cldfb_protoFilter_2_5ms[5];
hs->scale = cldfb_scale_2_5ms[5];
move16();
- IF( hs->type == CLDFB_SYNTHESIS )
+ IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) )
{
hs->synScalefactor = add( cldfb_synScale[5], hs->filterScale );
move16();
@@ -1608,7 +1627,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle
hs->anaScalefactor = add( cldfb_anaScale[5], hs->filterScale );
move16();
}
- break;
+ BREAK;
}
}
@@ -1624,7 +1643,7 @@ ivas_error
cldfb_save_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle */
{
- if ( hs->memory != NULL || hs->memory_length != 0 )
+ IF( hs->memory != NULL || hs->memory_length != 0 )
{
/* memory already stored; Free memory first */
return IVAS_ERR_OK;
@@ -1637,7 +1656,7 @@ cldfb_save_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle */
Copy( hs->FilterStates_e, hs->memory + hs->memory_length, CLDFB_MEM_EXPONENTS );
hs->memory[hs->memory_length + CLDFB_MEM_EXPONENTS] = hs->FilterStates_eg;
move16();
- if ( hs->memory == NULL )
+ IF( hs->memory == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" );
}
diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c
index e8e69432f12cbb9a97064f19907f2a4045fbeee6..b43b174484afef7a20210a21898cd13171605194 100644
--- a/lib_com/cng_exc_fx.c
+++ b/lib_com/cng_exc_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h"
#include "ivas_rom_com_fx.h"
@@ -86,7 +85,7 @@ void CNG_exc_fx(
IF( *first_CNG == 0 )
{
- IF( EQ_32( core_brate, FRAME_NO_DATA ) )
+ IF( core_brate == FRAME_NO_DATA )
{
/* needed only in decoder when the very first SID frame was erased and this frame is FRAME_NO_DATA frame */
/*fenew = dotp( fexc, fexc, pit_max )/pit_max;*/
@@ -102,7 +101,7 @@ void CNG_exc_fx(
move32();
}
- if ( EQ_16( element_mode, EVS_MONO ) )
+ if ( element_mode == EVS_MONO )
{
*lp_ener = *Enew;
move32();
@@ -114,7 +113,7 @@ void CNG_exc_fx(
*---------------------------------------------------------------------*/
test();
test();
- IF( NE_32( last_core_brate, SID_1k75 ) && NE_32( last_core_brate, FRAME_NO_DATA ) && NE_32( last_core_brate, SID_2k40 ) )
+ IF( NE_32( last_core_brate, SID_1k75 ) && ( last_core_brate != FRAME_NO_DATA ) && NE_32( last_core_brate, SID_2k40 ) )
{
/* Partially reset CNG energy after active speech period */
test();
@@ -171,7 +170,7 @@ if ( EQ_16( allow_cn_step, 1 ) )
move16();
}
/* If not mono, skip CNG here */
-if ( GT_16( element_mode, IVAS_SCE ) )
+IF( GT_16( element_mode, IVAS_SCE ) )
{
return;
}
@@ -234,9 +233,9 @@ FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR )
FOR( i = 0; i < L_SUBFR; i++ )
{
/* exc2[i] *= enr */
- L_tmp = L_mult( exc2[i_subfr + i], tmp ); /* Q-4 * Q_exc+19 -> Q_exc +16 */
+ L_tmp = L_mult( exc2[add( i_subfr, i )], tmp ); /* Q-4 * Q_exc+19 -> Q_exc +16 */
#ifdef BASOP_NOGLOB
- exc2[i_subfr + i] = round_fx_sat( L_shl_sat( L_tmp, exp ) );
+ exc2[add( i_subfr, i )] = round_fx_sat( L_shl_sat( L_tmp, exp ) );
#else
exc2[i_subfr + i] = round_fx( L_shl( L_tmp, exp ) );
#endif
@@ -307,15 +306,16 @@ IF( NE_16( Opt_AMR_WB, 1 ) )
/* calculate the spectrum of random excitation signal */
Copy( exc2, fft_io, L_frame );
+ Word16 Q_new_inp, mem_decim_size; // TO be removed
IF( EQ_16( L_frame, L_FRAME16k ) )
{
- modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0 );
+ modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0, &Q_new_inp, &mem_decim_size );
}
/* fft_rel(fft_io, L_FFT, LOG2_L_FFT); */
fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT ); /* ??????? */
ptR = &fft_io[1];
- ptI = &fft_io[sub( L_FFT, 1 )];
+ ptI = &fft_io[L_FFT - 1];
FOR( i = 0; i < NUM_ENV_CNG; i++ )
{
/* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */
@@ -351,20 +351,23 @@ IF( NE_16( Opt_AMR_WB, 1 ) )
if ( denv[i] < 0 )
{
- denv[i] = L_deposit_l( 0 );
+ denv[i] = 0;
+ move32();
}
}
set32_fx( itmp, 0, NUM_ENV_CNG );
set16_fx( fft_io, 0, L_FFT );
ptR = &fft_io[1];
- ptI = &fft_io[sub( L_FFT, 1 )];
+ ptI = &fft_io[L_FFT - 1];
FOR( i = 0; i < NUM_ENV_CNG; i++ )
{
/* *ptR = own_random( cng_ener_seed1 ); */
/* *ptI = own_random( cng_ener_seed1 ); */
*ptR = Random( cng_ener_seed1 );
+ move16();
*ptI = Random( cng_ener_seed1 );
+ move16();
/* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */
L_tmp = L_mult0( *ptR, *ptR ); /* Q0 */
@@ -395,7 +398,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) )
}
}
ptR = &fft_io[1];
- ptI = &fft_io[sub( L_FFT, 1 )];
+ ptI = &fft_io[L_FFT - 1];
FOR( i = 0; i < NUM_ENV_CNG; i++ )
{
/* *ptR *= sqrt(itmp[i]/env[i]); */
@@ -428,13 +431,14 @@ IF( NE_16( Opt_AMR_WB, 1 ) )
#else
*ptR = extract_h( L_shl( L_tmp2, add( exp, Q_exc ) ) ); /*Q_exc*/
#endif
+ move16();
L_tmp2 = Mult_32_16( L_tmp, *ptI ); /*Q(16-exp)*/
#ifdef BASOP_NOGLOB
*ptI = extract_h( L_shl_sat( L_tmp2, add( exp, Q_exc ) ) ); /*Q_exc*/
#else
*ptI = extract_h( L_shl( L_tmp2, add( exp, Q_exc ) ) ); /*Q_exc*/
#endif
-
+ move16();
ptR++;
ptI--;
}
@@ -443,7 +447,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) )
IF( EQ_16( L_frame, L_FRAME16k ) )
{
- modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0 );
+ modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0, &Q_new_inp, &mem_decim_size );
}
/* enr1 = dotp( fft_io, fft_io, L_frame ) / L_frame; */
@@ -509,7 +513,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) )
test();
test();
test();
- IF( NE_32( last_core_brate, SID_2k40 ) && NE_32( last_core_brate, SID_1k75 ) && NE_32( last_core_brate, FRAME_NO_DATA ) && EQ_32( core_brate, SID_2k40 ) )
+ IF( NE_32( last_core_brate, SID_2k40 ) && NE_32( last_core_brate, SID_1k75 ) && ( last_core_brate != FRAME_NO_DATA ) && EQ_32( core_brate, SID_2k40 ) )
{
#ifdef BASOP_NOGLOB
IF( GT_32( L_tmp, L_shl_sat( 1, sub( 31, exp ) ) ) )
@@ -525,8 +529,9 @@ IF( NE_16( Opt_AMR_WB, 1 ) )
FOR( i = 0; i < L_SUBFR; i++ )
{
/* fft_io[i] *= enr */
- L_tmp = L_mult( fft_io[i_subfr + i], tmp ); /* Q_exc + 16 - exp */
- fft_io[i_subfr + i] = round_fx( L_shl( L_tmp, exp ) ); /*Q_exc*/
+ L_tmp = L_mult( fft_io[add( i_subfr, i )], tmp ); /* Q_exc + 16 - exp */
+ fft_io[add( i_subfr, i )] = round_fx( L_shl( L_tmp, exp ) ); /*Q_exc*/
+ move16();
}
}
@@ -674,6 +679,7 @@ void cng_params_postupd_fx(
Word32 last_active_brate;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
ptr = add( sub( ho_circ_ptr, *cng_buf_cnt ), 1 );
@@ -686,7 +692,9 @@ void cng_params_postupd_fx(
{
exc2 = &cng_exc2_buf[ptr * L_FFT];
Q_exc = cng_Qexc_buf[ptr];
+ move16();
last_active_brate = cng_brate_buf[ptr];
+ move32();
/* calculate the spectrum of residual signal */
Copy( exc2, fft_io, L_FFT );
@@ -758,10 +766,12 @@ void cng_params_postupd_fx(
if ( EQ_16( ptr, HO_HIST_SIZE ) )
{
ptr = 0;
+ move16();
}
}
*cng_buf_cnt = 0;
+ move16();
return;
}
@@ -810,11 +820,13 @@ void cng_params_upd_fx(
Word16 exp_pow;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* update the pointer to circular buffer of old LSP vectors */
*ho_circ_ptr = add( *ho_circ_ptr, 1 );
+ move16();
if ( EQ_16( *ho_circ_ptr, HO_HIST_SIZE ) )
{
@@ -837,7 +849,6 @@ void cng_params_upd_fx(
scale = norm_s( maxv );
pt_exc2 = exc2;
- move16();
L_ener = L_deposit_l( 0 );
IF( EQ_16( L_frame, L_FRAME ) )
{
@@ -891,10 +902,11 @@ void cng_params_upd_fx(
ho_ener_circ[*ho_circ_ptr] = L_ener;
move32();
- IF( EQ_16( enc_dec_flag, ENC ) )
+ IF( enc_dec_flag == ENC )
{
/* Store residual signal for postponed FFT-processing*/
*cng_buf_cnt = add( *cng_buf_cnt, 1 );
+ move16();
if ( GT_16( *cng_buf_cnt, HO_HIST_SIZE ) )
{
*cng_buf_cnt = HO_HIST_SIZE;
@@ -974,6 +986,7 @@ void cng_params_upd_fx(
Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG );
}
*ho_circ_size = add( *ho_circ_size, 1 );
+ move16();
if ( GT_16( *ho_circ_size, HO_HIST_SIZE ) )
{
*ho_circ_size = HO_HIST_SIZE;
@@ -1016,15 +1029,17 @@ void cng_params_upd_ivas_fx(
Word16 exp1;
Word16 CNG_mode;
Word16 tmp = 0;
+ move16();
Word16 temp_lo_fx, temp_hi_fx;
Word16 exp_pow;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
-
/* update the pointer to circular buffer of old LSP vectors */
*ho_circ_ptr = add( *ho_circ_ptr, 1 );
+ move16();
if ( EQ_16( *ho_circ_ptr, HO_HIST_SIZE ) )
{
@@ -1047,7 +1062,6 @@ void cng_params_upd_ivas_fx(
scale = norm_s( maxv );
pt_exc2 = exc2;
- move16();
L_ener = L_deposit_l( 0 );
IF( EQ_16( L_frame, L_FRAME ) )
{
@@ -1101,10 +1115,11 @@ void cng_params_upd_ivas_fx(
ho_ener_circ[*ho_circ_ptr] = L_ener;
move32();
- IF( EQ_16( enc_dec_flag, ENC ) )
+ IF( enc_dec_flag == ENC )
{
/* Store residual signal for postponed FFT-processing*/
*cng_buf_cnt = add( *cng_buf_cnt, 1 );
+ move16();
if ( GT_16( *cng_buf_cnt, HO_HIST_SIZE ) )
{
*cng_buf_cnt = HO_HIST_SIZE;
@@ -1148,16 +1163,23 @@ void cng_params_upd_ivas_fx(
Copy32( sp, env, NUM_ENV_CNG );
Word16 shift = 0;
- if ( element_mode == IVAS_SCE || element_mode == IVAS_CPE_DFT )
+ move16();
+ test();
+ IF( EQ_16( element_mode, IVAS_SCE ) || EQ_16( element_mode, IVAS_CPE_DFT ) )
{
Word32 att_fx = 0;
Word16 index = 0;
+ move32();
+ move16();
apply_scale_ivas_fx( &att_fx, bwidth, last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO, &index );
att_fx = pow_10_q23[index]; // Q23
- tmp = extract_h( att_fx ); // Q7
+ move32();
+ tmp = extract_h( att_fx ); // Q7
+ move16();
shift = 8;
+ move16();
}
- else
+ ELSE
{
CNG_mode = get_cng_mode( last_active_brate );
/* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */
@@ -1187,6 +1209,7 @@ void cng_params_upd_ivas_fx(
scale_sig32( &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG, shift );
}
*ho_circ_size = add( *ho_circ_size, 1 );
+ move16();
if ( GT_16( *ho_circ_size, HO_HIST_SIZE ) )
{
*ho_circ_size = HO_HIST_SIZE;
@@ -1212,22 +1235,27 @@ Word16 get_cng_mode(
IF( GT_32( last_active_brate, ACELP_13k20 ) )
{
CNG_mode = 4;
+ move16();
}
ELSE IF( GT_32( last_active_brate, ACELP_9k60 ) )
{
CNG_mode = 3;
+ move16();
}
ELSE IF( GT_32( last_active_brate, ACELP_8k00 ) )
{
CNG_mode = 2;
+ move16();
}
ELSE IF( GT_32( last_active_brate, ACELP_7k20 ) )
{
CNG_mode = 1;
+ move16();
}
ELSE
{
CNG_mode = 0;
+ move16();
}
return ( CNG_mode );
diff --git a/lib_com/cnst.h b/lib_com/cnst.h
index a1ec42fb9ea23d574405d905dfe0fd8f73c8bc2a..53b1d472377dd240b7ddedb23c1b5e807c3f7889 100644
--- a/lib_com/cnst.h
+++ b/lib_com/cnst.h
@@ -156,6 +156,8 @@
#define RANDOM_INITSEED 21845 /* Seed for random generators */
#ifndef FLT_MIN
#define FLT_MIN ( 1.175494351e-38F )
+#define FLT_MIN_10_EXP (-37) // min decimal exponent
+#define FLT_MIN_EXP (-125) // min binary exponent
#endif
#ifndef FLT_MAX
#define FLT_MAX ( 3.402823466e+38F )
@@ -573,11 +575,9 @@ enum
*----------------------------------------------------------------------------------*/
#define FRAMES_PER_SEC 50
-#ifdef IVAS_FLOAT_FIXED
#define MAX_PARAM_SPATIAL_SUB_FRAMES_PER_SEC 200 //(FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)
-#define ONE_BY_FRAMES_PER_SEC_Q31 ((Word32)(0x028F5C29))
+#define ONE_BY_FRAMES_PER_SEC_Q31 ( 42949673 )
#define FRAMES_PER_SEC_BY_2 (FRAMES_PER_SEC >> 1)
-#endif
#define INV_FRAME_PER_SEC_Q15 656
#define INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 164
#define FRAME_SIZE_NS 20000000L
@@ -607,6 +607,7 @@ enum
#define N_WS2N_FRAMES 40 /* number of frames for attenuation during the band-width switching */
#define N_NS2W_FRAMES 20 /* number of frames for attenuation during the band-width switching */
+#define ONE_BY_N_NS2W_FRAMES_Q15 ( 1638 )
/*----------------------------------------------------------------------------------*
* Coder types (only for ACELP core when not running in AMR-WB IO mode)
@@ -1918,6 +1919,7 @@ typedef enum _DCTTYPE
#define N_SMC_MIXTURES 6 /* number of mixtures */
#define N_PCA_COEF 12 /* number of PCA components */
#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 */
#define M_LSP_SPMUS 6 /* number of LSPs used in speech/music classifier */
#define NB_BANDS_SPMUS 15
@@ -2880,6 +2882,7 @@ typedef enum SIGNAL_CLASSIFER_MODE
#define SCALE_GAIN_ANA_16 ( 3 )
#define SCALE_GAIN_ANA_20 ( 3 )
#define SCALE_GAIN_ANA_32 ( 2 )
+#define SCALE_GAIN_ANA_30 ( 2 )
#define SCALE_GAIN_ANA_40 ( 2 )
#define SCALE_GAIN_ANA_60 ( 1 )
@@ -2891,6 +2894,7 @@ typedef enum SIGNAL_CLASSIFER_MODE
#define SCALE_CLDFB_ANA_32 ( SCALE_MODULATION + SCALE_GAIN_ANA_32 )
#define SCALE_CLDFB_ANA_40 ( SCALE_MODULATION + SCALE_GAIN_ANA_40 )
#define SCALE_CLDFB_ANA_60 ( SCALE_MODULATION + SCALE_GAIN_ANA_60 )
+#define SCALE_CLDFB_ANA_30 ( SCALE_MODULATION + SCALE_GAIN_ANA_30 )
#define SCALE_CLDFB_SYN_10 ( SCALE_MODULATION + SCALE_GAIN_SYN )
#define SCALE_CLDFB_SYN_16 ( SCALE_MODULATION + SCALE_GAIN_SYN )
@@ -2898,6 +2902,7 @@ typedef enum SIGNAL_CLASSIFER_MODE
#define SCALE_CLDFB_SYN_32 ( SCALE_MODULATION + SCALE_GAIN_SYN )
#define SCALE_CLDFB_SYN_40 ( SCALE_MODULATION + SCALE_GAIN_SYN )
#define SCALE_CLDFB_SYN_60 ( SCALE_MODULATION + SCALE_GAIN_SYN )
+#define SCALE_CLDFB_SYN_30 ( SCALE_MODULATION + SCALE_GAIN_SYN )
/************************************************************************/
/* FFT */
diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c
index 79f0fa4c57e355992586f670fc57ab7884244699..e2fbbb9f31e2c7550d61c7c46468ea3be5b1259a 100644
--- a/lib_com/codec_tcx_common.c
+++ b/lib_com/codec_tcx_common.c
@@ -7,8 +7,7 @@
#include
#include "options.h"
#include "prot.h"
-#include "prot_fx2.h"
-#include "prot_fx1.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "rom_basop_util.h"
#include "rom_com.h"
@@ -37,7 +36,7 @@ Word16 tcxGetNoiseFillingTilt(
{
firstLine = shr( L_frame, 3 );
- Copy_Scale_sig( A, As, lpcorder + 1, sub( norm_s( A[0] ), 2 ) );
+ Copy_Scale_sig( A, As, add( lpcorder, 1 ), sub( norm_s( A[0] ), 2 ) );
tmp = get_gain( As + 1, As, lpcorder );
BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef BASOP_NOGLOB
@@ -68,6 +67,7 @@ void tcxFormantEnhancement(
Word16 xn_buf_e, xn_one, m, e;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
k = shr( L_frame, 6 ); /* FDNS_NPTS = 64 */
@@ -144,7 +144,7 @@ void tcxFormantEnhancement(
fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) );
BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef BASOP_NOGLOB
- xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) );
+ xn_buf[add( l, j )] = s_min( xn_one, shl_o( mult( xn_buf[add( l, j )], fac ), fac_e, &Overflow ) );
#else
xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) );
#endif
@@ -193,7 +193,7 @@ void tcxFormantEnhancement(
fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) );
BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef BASOP_NOGLOB
- xn_buf[l + j] = s_min( xn_one, shl_sat( mult( xn_buf[l + j], fac ), fac_e ) );
+ xn_buf[add( l, j )] = s_min( xn_one, shl_sat( mult( xn_buf[add( l, j )], fac ), fac_e ) );
#else
xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) );
#endif
@@ -241,6 +241,7 @@ void tcxFormantEnhancement_with_shift(
Word16 xn_buf_e, xn_one, m, e;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
k = shr( L_frame, 6 ); /* FDNS_NPTS = 64 */
@@ -295,16 +296,16 @@ void tcxFormantEnhancement_with_shift(
move16();
tmp = sub( e, fac_e );
- IF( GT_16( tmp, 0 ) )
+ IF( tmp > 0 )
{
fac0 = shr( fac0, tmp );
}
- IF( LT_16( tmp, 0 ) )
+ IF( tmp < 0 )
{
fac1 = shl( fac1, tmp );
}
- IF( GT_16( tmp, 0 ) )
+ IF( tmp > 0 )
{
fac_e = e;
move16();
@@ -321,7 +322,7 @@ void tcxFormantEnhancement_with_shift(
fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) );
BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef BASOP_NOGLOB
- xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) );
+ xn_buf[add( l, j )] = s_min( xn_one, shl_o( mult( xn_buf[add( l, j )], fac ), fac_e, &Overflow ) );
#else
xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) );
#endif
@@ -370,7 +371,7 @@ void tcxFormantEnhancement_with_shift(
fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) );
BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef BASOP_NOGLOB
- xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) );
+ xn_buf[add( l, j )] = s_min( xn_one, shl_o( mult( xn_buf[add( l, j )], fac ), fac_e, &Overflow ) );
#else
xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) );
#endif
@@ -427,7 +428,7 @@ void tcxInvertWindowGrouping(
test();
test();
- if ( ( frame_cnt != 0 ) && ( bfi == 0 ) && NE_16( last_core, ACELP_CORE ) ) /* fix sub-window overlap */
+ if ( ( frame_cnt != 0 ) && ( bfi == 0 ) && ( last_core != ACELP_CORE ) ) /* fix sub-window overlap */
{
hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode;
move16();
@@ -459,7 +460,7 @@ void tcxInvertWindowGrouping(
move32();
}
- p = spectrum + L_frame - 1;
+ p = spectrum + sub( L_frame, 1 );
FOR( i = sub( L_frame, 1 ); i > L_win; i -= 2 )
{
*p-- = spectrum[i];
@@ -475,8 +476,8 @@ void tcxInvertWindowGrouping(
IF( LT_16( L_spec, L_frame ) )
{
Copy32( spectrum + 8, spectrum + 16, sub( shr( L_spec, 1 ), 8 ) );
- Copy32( spectrum + L_frame / 2, spectrum + 8, 8 );
- Copy32( spectrum + L_frame / 2 + 8, spectrum + L_spec / 2 + 8, sub( shr( L_spec, 1 ), 8 ) );
+ Copy32( spectrum + shr( L_frame, 1 ), spectrum + 8, 8 );
+ Copy32( spectrum + add( shr( L_frame, 1 ), 8 ), spectrum + add( shr( L_spec, 1 ), 8 ), sub( shr( L_spec, 1 ), 8 ) );
}
ELSE
{
@@ -642,7 +643,7 @@ void tcx5SpectrumInterleaving_fx(
FOR( i = 0; i < tcx5Size; i++ )
{
interleaveBuf[2 * i] = spectrum[i];
- interleaveBuf[2 * i + 1] = spectrum[tcx5Size + i];
+ interleaveBuf[add( 2 * i, 1 )] = spectrum[add( tcx5Size, i )];
}
Copy32( interleaveBuf, spectrum, shl( tcx5Size, 1 ) );
@@ -669,7 +670,7 @@ void tcx5SpectrumDeinterleaving_fx(
FOR( i = 0; i < tcx5Size; i++ )
{
interleaveBuf[i] = spectrum[2 * i];
- interleaveBuf[tcx5Size + i] = spectrum[2 * i + 1];
+ interleaveBuf[add( tcx5Size, i )] = spectrum[add( 2 * i, 1 )];
}
Copy32( interleaveBuf, spectrum, shl( tcx5Size, 1 ) );
@@ -693,7 +694,7 @@ void tcx5TnsGrouping_fx(
{
Copy32( spectrum + 8, spectrum + 16, sub( L_spec, 8 ) );
Copy32( spectrum + L_frame, spectrum + 8, 8 );
- Copy32( spectrum + L_frame + 8, spectrum + L_spec + 8, sub( L_spec, 8 ) );
+ Copy32( spectrum + add( L_frame, 8 ), spectrum + add( L_spec, 8 ), sub( L_spec, 8 ) );
}
ELSE
{
@@ -722,11 +723,11 @@ void tcx5TnsUngrouping_fx(
/* undo rearrangement of LF sub-window lines prior to TNS analysis */
IF( LT_16( L_spec, L_frame ) )
{
- Copy32( spectrum + L_spec + 8, spectrum + L_frame + 8, sub( L_spec, 8 ) );
+ Copy32( spectrum + L_spec + 8, spectrum + add( L_frame, 8 ), sub( L_spec, 8 ) );
Copy32( spectrum + 8, spectrum + L_frame, 8 );
Copy32( spectrum + 16, spectrum + 8, sub( L_spec, 8 ) );
set32_fx( spectrum + L_spec, 0, sub( L_frame, L_spec ) );
- set32_fx( spectrum + L_frame + L_spec, 0, sub( L_frame, L_spec ) );
+ set32_fx( spectrum + add( L_frame, L_spec ), 0, sub( L_frame, L_spec ) );
}
ELSE
{
diff --git a/lib_com/codec_tcx_common_flt.c b/lib_com/codec_tcx_common_flt.c
index 12e7d80994eb62b11ddb7a7294a38143c5898dcc..a9314e871522aa830b23aa958b94faa95c78bab9 100644
--- a/lib_com/codec_tcx_common_flt.c
+++ b/lib_com/codec_tcx_common_flt.c
@@ -145,7 +145,7 @@ void tcxInvertWindowGrouping_flt(
float xn_buf[],
float spectrum[],
const int16_t L_frame,
- const int16_t fUseTns,
+ const int8_t fUseTns,
const int16_t last_core,
const int16_t index,
const int16_t frame_cnt,
diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c
index c91e6f78262f5422a0e7b1239950cf05f23e038b..a10ecac19110b777bf32ff0c5fe80d60d94b229c 100644
--- a/lib_com/core_com_config.c
+++ b/lib_com/core_com_config.c
@@ -41,8 +41,9 @@
#include "prot.h"
#include "wmc_auto.h"
#include "ivas_prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
+#define FSCALE_DENOM_BY_12800_Q15 1311
/*-------------------------------------------------------------------*
* is_EVS_bitrate()
*
@@ -58,9 +59,11 @@ Word16 is_EVS_bitrate(
Word16 j;
j = 0;
+ move16();
WHILE( LT_16( j, SIZE_BRATE_TBL ) && NE_32( ivas_total_brate, brate_tbl[j] ) )
{
- j++;
+ test();
+ j = add( j, 1 );
}
/* AMR-WB IO mode/EVS primary mode determination */
@@ -86,10 +89,12 @@ Word16 is_EVS_bitrate(
}
*Opt_AMR_WB = 1;
+ move16();
}
ELSE
{
*Opt_AMR_WB = 0;
+ move16();
}
return 1;
@@ -107,45 +112,59 @@ Word16 get_codec_mode(
const Word32 total_brate /* i : total bitrate */
)
{
- Word16 codec_mode = -1;
+ Word16 codec_mode;
+ codec_mode = -1;
+ move16();
SWITCH( total_brate )
{
case 5900:
codec_mode = MODE1;
+ move16();
BREAK;
case 7200:
codec_mode = MODE1;
+ move16();
BREAK;
case 8000:
codec_mode = MODE1;
+ move16();
BREAK;
case 9600:
codec_mode = MODE2;
+ move16();
BREAK;
case 13200:
codec_mode = MODE1;
+ move16();
BREAK;
case 16400:
codec_mode = MODE2;
+ move16();
BREAK;
case 24400:
codec_mode = MODE2;
+ move16();
BREAK;
case 32000:
codec_mode = MODE1;
+ move16();
BREAK;
case 48000:
codec_mode = MODE2;
+ move16();
BREAK;
case 64000:
codec_mode = MODE1;
+ move16();
BREAK;
case 96000:
codec_mode = MODE2;
+ move16();
BREAK;
case 128000:
codec_mode = MODE2;
+ move16();
BREAK;
}
@@ -280,44 +299,63 @@ Word16 getTcxonly(
const Word16 is_ism_format /* i : flag indicating ISM format */
)
{
- Word16 tcxonly = 0;
+ Word16 tcxonly;
+ tcxonly = 0;
+ move16();
SWITCH( element_mode )
{
case EVS_MONO:
- IF( GT_32( total_brate, ACELP_32k ) )
+ if ( GT_32( total_brate, ACELP_32k ) )
{
tcxonly = 1;
+ move16();
}
BREAK;
case IVAS_SCE:
IF( is_ism_format )
{
- IF( GT_32( total_brate, MAX_ACELP_BRATE_ISM ) )
+ if ( GT_32( total_brate, MAX_ACELP_BRATE_ISM ) )
{
tcxonly = 1;
+ move16();
}
}
ELSE
{
- IF( GT_32( total_brate, MAX_ACELP_BRATE ) )
+ if ( GT_32( total_brate, MAX_ACELP_BRATE ) )
{
tcxonly = 1;
+ move16();
}
}
BREAK;
case IVAS_CPE_DFT:
case IVAS_CPE_TD:
- IF( GT_32( total_brate, MAX_ACELP_BRATE ) )
+ if ( GT_32( total_brate, MAX_ACELP_BRATE ) )
{
tcxonly = 1;
+ move16();
}
BREAK;
case IVAS_CPE_MDCT:
- IF( GE_32( total_brate, ( MCT_flag ? IVAS_32k : IVAS_48k ) ) )
+ IF( MCT_flag )
{
- tcxonly = 1;
+
+ if ( GE_32( total_brate, IVAS_32k ) )
+ {
+ tcxonly = 1;
+ move16();
+ }
+ }
+ ELSE
+ {
+ if ( GE_32( total_brate, IVAS_48k ) )
+ {
+ tcxonly = 1;
+ move16();
+ }
}
BREAK;
}
@@ -349,6 +387,7 @@ Word16 getTcxonly(
test();
test();
test();
+ test();
if ( ( ( LE_16( element_mode, IVAS_SCE ) && GT_32( total_brate, LPC_SHAPED_ARI_MAX_RATE ) ) || ( GT_16( element_mode, IVAS_SCE ) && GT_32( total_brate, LPC_SHAPED_ARI_MAX_RATE_CPE ) ) ) && !rf_flag && ( ( LE_32( total_brate, IVAS_64k ) && NE_16( element_mode, IVAS_CPE_DFT ) ) || ( LT_32( total_brate, 24400 ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
{
ctx_hm = 1;
@@ -372,7 +411,7 @@ Word16 getTcxonly(
resq = 0;
move16();
- IF( LE_32( total_brate, IVAS_64k ) )
+ if ( LE_32( total_brate, IVAS_64k ) )
{
resq = 1;
move16();
@@ -393,13 +432,15 @@ Word16 getTcxonly(
const Word16 element_mode /* i : IVAS element mode */
)
{
- Word16 tnsAllowed = 0;
+ Word16 tnsAllowed;
tnsAllowed = 0;
move16();
- IF( NE_16( igf, 0 ) )
+ IF( igf != 0 )
{
- IF( GT_32( total_brate, HQ_16k40 ) || ( GT_32( total_brate, HQ_13k20 ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) )
+ test();
+ test();
+ if ( GT_32( total_brate, HQ_16k40 ) || ( GT_32( total_brate, HQ_13k20 ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) )
{
tnsAllowed = 1;
move16();
@@ -407,7 +448,7 @@ Word16 getTcxonly(
}
ELSE
{
- IF( GT_32( total_brate, HQ_32k ) )
+ if ( GT_32( total_brate, HQ_32k ) )
{
tnsAllowed = 1;
move16();
@@ -429,19 +470,28 @@ Word16 getTcxonly(
const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
)
{
- Word16 restrictedMode = 3;
+ Word16 restrictedMode;
+ restrictedMode = 3;
+ move16();
+ test();
+ test();
+ test();
+ test();
IF( !Opt_AMR_WB && ( GT_32( total_brate, HQ_32k ) && NE_16( element_mode, IVAS_SCE ) ) )
{
restrictedMode = 6;
+ move16();
}
ELSE IF( !Opt_AMR_WB && ( GT_32( total_brate, HQ_48k ) && EQ_16( element_mode, IVAS_SCE ) ) )
{
restrictedMode = 6;
+ move16();
}
ELSE IF( Opt_AMR_WB )
{
restrictedMode = 1;
+ move16();
}
return restrictedMode;
@@ -483,7 +533,7 @@ Word16 getTcxonly(
const Word32 sr_core /* i : internal sampling rate */
)
{
- return (Word16) ( ( FSCALE_DENOM * sr_core ) / 12800 );
+ return extract_l( Mpy_32_16_1( sr_core, FSCALE_DENOM_BY_12800_Q15 ) );
}
#endif
@@ -590,19 +640,19 @@ Word16 getTcxonly(
test();
test();
test();
- IF( EQ_32( bwidth, NB ) )
+ test();
+ IF( bwidth == NB )
{
sr_core = INT_FS_12k8;
move32();
}
- ELSE IF( EQ_16( element_mode, EVS_MONO ) && ( L_and( EQ_32( bwidth, WB ), LT_32( total_brate, ACELP_13k20 ) ) ||
- L_and( EQ_32( bwidth, SWB ), LE_32( total_brate, ACELP_13k20 ) ) || EQ_16( rf_mode, 1 ) ) )
-
+ ELSE IF( element_mode == EVS_MONO && ( L_and( EQ_32( bwidth, WB ), LT_32( total_brate, ACELP_13k20 ) ) ||
+ L_and( EQ_32( bwidth, SWB ), LE_32( total_brate, ACELP_13k20 ) ) || EQ_16( rf_mode, 1 ) ) )
{
sr_core = INT_FS_12k8;
move32();
}
- ELSE IF( GT_16( element_mode, EVS_MONO ) && flag_ACELP16k == 0 )
+ ELSE IF( element_mode > EVS_MONO && flag_ACELP16k == 0 )
{
sr_core = INT_FS_12k8;
move32();
@@ -620,12 +670,14 @@ Word16 getTcxonly(
ELSE IF( bwd_swb_or_fb_flag && LE_32( total_brate, MAX_ACELP_BRATE_ISM ) && EQ_16( element_mode, IVAS_SCE ) && is_ism_format )
{
sr_core = INT_FS_16k;
+ move32();
}
ELSE IF( bwd_swb_or_fb_flag && LE_32( total_brate, MAX_ACELP_BRATE ) && EQ_16( element_mode, IVAS_SCE ) && is_ism_format )
{
sr_core = 25600;
+ move32();
}
- ELSE IF( ( EQ_16( element_mode, EVS_MONO ) && ( bwd_swb_or_fb_flag && LE_32( total_brate, HQ_64k ) ) ) || ( GT_16( element_mode, IVAS_SCE ) && ( ( EQ_16( bwidth, SWB ) && LE_32( total_brate, IVAS_96k ) ) || ( EQ_16( bwidth, FB ) && LE_32( total_brate, IVAS_96k ) ) ) ) )
+ ELSE IF( ( element_mode == EVS_MONO && ( bwd_swb_or_fb_flag && LE_32( total_brate, HQ_64k ) ) ) || ( GT_16( element_mode, IVAS_SCE ) && ( ( EQ_16( bwidth, SWB ) && LE_32( total_brate, IVAS_96k ) ) || ( EQ_16( bwidth, FB ) && LE_32( total_brate, IVAS_96k ) ) ) ) )
{
sr_core = 25600;
move32();
@@ -652,7 +704,7 @@ Word16 getTcxonly(
tcxBandwidth = 16384 /*0.5f Q15*/;
move16();
- if ( EQ_16( bwidth, NB ) )
+ if ( bwidth == NB )
{
tcxBandwidth = 10240 /*0.3125f Q15*/;
move16();
@@ -786,7 +838,8 @@ Word16 getTcxonly(
const Word16 rf_mode /* i : flag to signal the RF mode */
)
{
- Word16 igfPresent = 0;
+ Word16 igfPresent;
+ igfPresent = 0;
move16();
IF( EQ_16( bwidth, SWB ) )
@@ -795,7 +848,7 @@ Word16 getTcxonly(
{
case EVS_MONO:
case IVAS_SCE:
- IF( LE_32( total_brate, HQ_64k ) )
+ if ( LE_32( total_brate, HQ_64k ) )
{
igfPresent = 1;
move16();
@@ -803,14 +856,14 @@ Word16 getTcxonly(
BREAK;
case IVAS_CPE_DFT:
case IVAS_CPE_TD:
- IF( LE_32( total_brate, HQ_48k ) )
+ if ( LE_32( total_brate, HQ_48k ) )
{
igfPresent = 1;
move16();
}
BREAK;
case IVAS_CPE_MDCT:
- IF( LE_32( total_brate, IVAS_96k ) )
+ if ( LE_32( total_brate, IVAS_96k ) )
{
igfPresent = 1;
move16();
@@ -824,7 +877,7 @@ Word16 getTcxonly(
{
case EVS_MONO:
case IVAS_SCE:
- IF( LE_32( total_brate, IVAS_128k ) )
+ if ( LE_32( total_brate, IVAS_128k ) )
{
igfPresent = 1;
move16();
@@ -832,14 +885,14 @@ Word16 getTcxonly(
BREAK;
case IVAS_CPE_DFT:
case IVAS_CPE_TD:
- IF( LE_32( total_brate, IVAS_48k ) )
+ if ( LE_32( total_brate, IVAS_48k ) )
{
igfPresent = 1;
move16();
}
BREAK;
case IVAS_CPE_MDCT:
- IF( LE_32( total_brate, IVAS_128k ) )
+ if ( LE_32( total_brate, IVAS_128k ) )
{
igfPresent = 1;
move16();
@@ -847,13 +900,13 @@ Word16 getTcxonly(
BREAK;
}
}
- ELSE IF( bwidth == WB )
+ ELSE IF( EQ_16( bwidth, WB ) )
{
SWITCH( element_mode )
{
case EVS_MONO:
case IVAS_SCE:
- IF( LE_32( total_brate, ACELP_9k60 ) )
+ if ( LE_32( total_brate, ACELP_9k60 ) )
{
igfPresent = 1;
move16();
@@ -862,7 +915,7 @@ Word16 getTcxonly(
case IVAS_CPE_DFT:
case IVAS_CPE_TD:
case IVAS_CPE_MDCT:
- IF( LE_32( total_brate, ACELP_13k20 ) )
+ if ( LE_32( total_brate, ACELP_13k20 ) )
{
igfPresent = 1;
move16();
@@ -873,7 +926,7 @@ Word16 getTcxonly(
test();
test();
test();
- IF( ( ( EQ_16( bwidth, WB ) ) || ( EQ_16( bwidth, SWB ) ) ) && ( EQ_16( rf_mode, 1 ) ) && ( EQ_32( total_brate, ACELP_13k20 ) ) )
+ if ( ( ( EQ_16( bwidth, WB ) ) || ( EQ_16( bwidth, SWB ) ) ) && ( EQ_16( rf_mode, 1 ) ) && ( EQ_32( total_brate, ACELP_13k20 ) ) )
{
igfPresent = 1;
move16();
@@ -928,17 +981,20 @@ Word16 getTcxonly(
const Word16 bwidth /* i : audio bandwidth */
)
{
- Word16 flag_cna = 0;
+ Word16 flag_cna;
+ flag_cna = 0;
+ move16();
+ test();
IF( EQ_16( element_mode, IVAS_CPE_DFT ) && LE_32( element_brate, CNA_MAX_BRATE_DFT_STEREO ) )
{
flag_cna = 1;
+ move16();
}
ELSE
{
- move16();
test();
- IF( LE_16( bwidth, SWB ) && ( LE_32( total_brate, ACELP_13k20 ) ) )
+ if ( LE_16( bwidth, SWB ) && ( LE_32( total_brate, ACELP_13k20 ) ) )
{
flag_cna = 1;
move16();
@@ -957,12 +1013,12 @@ Word16 getTcxonly(
const Word32 sr_core /* i : internal sampling rate */
)
{
- Word16 tcxltp = 0;
+ Word16 tcxltp;
tcxltp = 0;
move16();
- test();
- IF( ( LE_32( sr_core, 25600 ) ) )
+
+ if ( ( LE_32( sr_core, 25600 ) ) )
{
tcxltp = 1;
move16();
@@ -1070,18 +1126,23 @@ Word16 getTcxonly(
{
case NB:
tcx_coded_lines = 160;
+ move16();
BREAK;
case WB:
tcx_coded_lines = 320;
+ move16();
BREAK;
case SWB:
tcx_coded_lines = 640;
+ move16();
BREAK;
case FB:
tcx_coded_lines = 960;
+ move16();
BREAK;
default:
tcx_coded_lines = 0;
+ move16();
BREAK;
}
@@ -1100,13 +1161,15 @@ Word16 getTcxonly(
const Word16 element_mode /* i : IVAS element mode */
)
{
- Word16 tcx_lpc_shaped_ari = 0;
-
+ Word16 tcx_lpc_shaped_ari;
+ tcx_lpc_shaped_ari = 0;
move16();
+
+ test();
test();
test();
test();
- IF( ( ( LE_16( element_mode, IVAS_SCE ) && LE_32( total_brate, LPC_SHAPED_ARI_MAX_RATE ) ) || ( GT_16( element_mode, IVAS_SCE ) && LE_32( total_brate, LPC_SHAPED_ARI_MAX_RATE_CPE ) ) ) || rf_mode )
+ if ( ( ( LE_16( element_mode, IVAS_SCE ) && LE_32( total_brate, LPC_SHAPED_ARI_MAX_RATE ) ) || ( GT_16( element_mode, IVAS_SCE ) && LE_32( total_brate, LPC_SHAPED_ARI_MAX_RATE_CPE ) ) ) || rf_mode )
{
tcx_lpc_shaped_ari = 1;
move16();
@@ -1363,11 +1426,15 @@ Word16 getTcxonly(
hTcxCfg->tcx_mdct_window_delayFB = mdctWindowLengthFB;
hTcxCfg->tcx_mdct_window_length = mdctWindowLength;
hTcxCfg->tcx_mdct_window_lengthFB = mdctWindowLengthFB;
+ move16();
+ move16();
+ move16();
+ move16();
mdct_window_sine_IVAS_updated( hTcxCfg->tcx_mdct_window, sr_core, hTcxCfg->tcx_mdct_window_length, FULL_OVERLAP, element_mode );
IF( EQ_16( hTcxCfg->tcx_mdct_window_length, hTcxCfg->tcx_mdct_window_lengthFB ) )
{
- Copy_pword( hTcxCfg->tcx_mdct_window, hTcxCfg->tcx_mdct_windowFB, hTcxCfg->tcx_mdct_window_length / 2 );
+ Copy_pword( hTcxCfg->tcx_mdct_window, hTcxCfg->tcx_mdct_windowFB, shr( hTcxCfg->tcx_mdct_window_length, 1 ) );
}
ELSE
{
@@ -1380,11 +1447,13 @@ Word16 getTcxonly(
/*1.25ms transition window for ACELP->TCX*/
hTcxCfg->tcx_mdct_window_trans_length = NS2SA_fx2( sr_core, ACELP_TCX_TRANS_NS );
+ move16();
mdct_window_sine_IVAS_updated( hTcxCfg->tcx_mdct_window_trans, sr_core, hTcxCfg->tcx_mdct_window_trans_length, TRANSITION_OVERLAP, element_mode );
hTcxCfg->tcx_mdct_window_trans_lengthFB = NS2SA_fx2( input_Fs, ACELP_TCX_TRANS_NS );
+ move16();
IF( EQ_16( hTcxCfg->tcx_mdct_window_trans_length, hTcxCfg->tcx_mdct_window_trans_lengthFB ) )
{
- Copy_pword( hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_trans_length / 2 );
+ Copy_pword( hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_transFB, shr( hTcxCfg->tcx_mdct_window_trans_length, 1 ) );
}
ELSE
{
@@ -1394,12 +1463,14 @@ Word16 getTcxonly(
/*compute minimum length for "half" window: lookahead - 5ms. It must be also multiple of 2*/
hTcxCfg->tcx_mdct_window_half_length = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA_fx2( 12800, 5000000L ), sr2fscale( sr_core ) ), LD_FSCALE_DENOM ) );
hTcxCfg->tcx_mdct_window_half_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA_fx2( 12800, 5000000L ), sr2fscale( input_Fs ) ), LD_FSCALE_DENOM ) );
+ move16();
+ move16();
assert( GT_16( hTcxCfg->tcx_mdct_window_half_length, 16 ) && "Half window can not be large enough!" );
mdct_window_sine_IVAS_updated( hTcxCfg->tcx_mdct_window_half, sr_core, hTcxCfg->tcx_mdct_window_half_length, HALF_OVERLAP, element_mode );
IF( EQ_16( hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_half_lengthFB ) )
{
- Copy_pword( hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_half_length / 2 );
+ Copy_pword( hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_halfFB, shr( hTcxCfg->tcx_mdct_window_half_length, 1 ) );
}
ELSE
{
@@ -1409,10 +1480,12 @@ Word16 getTcxonly(
/* minimum overlap 1.25 ms */
hTcxCfg->tcx_mdct_window_min_length = shr( L_frame, 4 ); /* 1.25ms */
hTcxCfg->tcx_mdct_window_min_lengthFB = shr( L_frameTCX, 4 ); /* 1.25ms */
+ move16();
+ move16();
/* save complexity by copying the small windows if they have the same length */
IF( EQ_16( hTcxCfg->tcx_mdct_window_min_length, hTcxCfg->tcx_mdct_window_trans_length ) )
{
- Copy_pword( hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_min_length / 2 );
+ Copy_pword( hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_minimum, shr( hTcxCfg->tcx_mdct_window_min_length, 1 ) );
}
ELSE
{
@@ -1421,11 +1494,11 @@ Word16 getTcxonly(
IF( EQ_16( hTcxCfg->tcx_mdct_window_min_lengthFB, hTcxCfg->tcx_mdct_window_trans_lengthFB ) )
{
- Copy_pword( hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_min_lengthFB / 2 );
+ Copy_pword( hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_minimumFB, shr( hTcxCfg->tcx_mdct_window_min_lengthFB, 1 ) );
}
ELSE IF( EQ_16( hTcxCfg->tcx_mdct_window_min_length, hTcxCfg->tcx_mdct_window_min_lengthFB ) )
{
- Copy_pword( hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_min_lengthFB / 2 );
+ Copy_pword( hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_minimumFB, shr( hTcxCfg->tcx_mdct_window_min_lengthFB, 1 ) );
}
ELSE
{
@@ -1437,6 +1510,10 @@ Word16 getTcxonly(
/*<0 rectangular transition with optimized window size = L_frame+L_frame/4*/
hTcxCfg->lfacNext = sub( hTcxCfg->tcx_offset, shr( L_frame, 2 ) );
hTcxCfg->lfacNextFB = sub( hTcxCfg->tcx_offsetFB, shr( L_frameTCX, 2 ) );
+ move16();
+ move16();
+ move16();
+ move16();
return;
}
@@ -1470,6 +1547,8 @@ Word16 getTcxonly(
hTcxCfg->tcx5Size = shr( L_frame, 2 ); /* Always 5 ms */
hTcxCfg->tcx5SizeFB = shr( L_frameTCX, 2 ); /* Always 5 ms */
+ move16();
+ move16();
hTcxCfg->tcx_mdct_window_length_old = hTcxCfg->tcx_mdct_window_length;
move16();
@@ -1484,49 +1563,60 @@ Word16 getTcxonly(
hTcxCfg->tcxRateLoopOpt = 0;
move16();
- IF( tcxonly != 0 )
+ if ( tcxonly != 0 )
{
hTcxCfg->tcxRateLoopOpt = 2;
move16();
}
- IF( EQ_16( element_mode, IVAS_CPE_MDCT ) )
- hTcxCfg->tcxRateLoopOpt = 3;
+ if ( EQ_16( element_mode, IVAS_CPE_MDCT ) )
+ {
+ hTcxCfg->tcxRateLoopOpt = 3;
+ move16();
+ }
hTcxCfg->bandwidth = getTcxBandwidth( bwidth );
move16();
/* set number of coded lines */
hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( bwidth );
+ move16();
/* TNS in TCX */
hTcxCfg->pCurrentTnsConfig = NULL;
hTcxCfg->fIsTNSAllowed = getTnsAllowed( total_brate, igf, element_mode );
+ move16();
IF( hTcxCfg->fIsTNSAllowed )
{
InitTnsConfigs( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag );
- SetAllowTnsOnWhite( hTcxCfg->tnsConfig, element_mode == IVAS_CPE_MDCT );
+ SetAllowTnsOnWhite( hTcxCfg->tnsConfig, (Word8) EQ_16( element_mode, IVAS_CPE_MDCT ) );
}
IF( ini_frame == 0 )
{
hTcxCfg->tcx_curr_overlap_mode = hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW;
hTcxCfg->last_aldo = 1;
+ move16();
+ move16();
+ move16();
}
/* Context HM*/
hTcxCfg->ctx_hm = getCtxHm( element_mode, total_brate, rf_mode );
+ move16();
/* Residual Coding*/
hTcxCfg->resq = getResq( total_brate );
- IF( hTcxCfg->resq && !tcxonly )
+ move16();
+ test();
+ if ( hTcxCfg->resq && !tcxonly )
{
hTcxCfg->tcxRateLoopOpt = 1;
move16();
}
/*Set bandwidth scale*/
- IF( EQ_16( bwidth, NB ) )
+ IF( bwidth == NB )
{
na_scale_bwidth = NB;
}
@@ -1538,21 +1628,27 @@ Word16 getTcxonly(
{
na_scale_bwidth = SWB;
}
+ move16();
hTcxCfg->na_scale = 32767 /*1.0f Q15*/;
+ move16();
+ test();
IF( LT_16( na_scale_bwidth, SWB ) && !tcxonly )
{
FOR( i = 0; i < SIZE_SCALE_TABLE_TCX; i++ )
{
+ test();
+ test();
IF( ( EQ_16( na_scale_bwidth, scaleTcxTable[i].bwmode ) ) &&
( GE_32( total_brate, scaleTcxTable[i].bitrateFrom ) ) &&
( LT_32( total_brate, scaleTcxTable[i].bitrateTo ) ) )
{
- IF( rf_mode )
+ if ( rf_mode )
{
- i--;
+ i = sub( i, 1 );
}
hTcxCfg->na_scale = scaleTcxTable[i].scale;
+ move16();
BREAK;
}
}
diff --git a/lib_com/deemph.c b/lib_com/deemph.c
index a746d326ea57e84ee76d6f36ad703270b7a8ac49..9583a79d4c21627746d37604084611bbbccc0dc1 100644
--- a/lib_com/deemph.c
+++ b/lib_com/deemph.c
@@ -38,8 +38,7 @@
#include "options.h"
#include "prot.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
* deemph()
*
@@ -79,13 +78,16 @@ void deemph_fx_32(
Word32 *mem /* i/o: memory (y[-1]) Qx*/
)
{
- int16_t i;
+ Word16 i;
signal[0] = L_add( signal[0], Mpy_32_16_1( ( *mem ), mu ) );
+ move32();
FOR( i = 1; i < L; i++ )
{
signal[i] = L_add( signal[i], Mpy_32_16_1( signal[i - 1], mu ) );
signal[i] = L_shl( signal[i], shift );
+ move32();
+ move32();
}
*mem = signal[L - 1];
@@ -125,7 +127,9 @@ void deemph_fx(
Word16 i;
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
+ Flag Overflow;
+ Overflow = 0;
+ move32();
#endif
L_tmp = L_deposit_h( signal[0] );
@@ -136,6 +140,7 @@ void deemph_fx(
L_tmp = L_mac( L_tmp, *mem, mu );
signal[0] = round_fx( L_tmp );
#endif
+ move16();
FOR( i = 1; i < L; i++ )
{
@@ -147,6 +152,7 @@ void deemph_fx(
L_tmp = L_mac( L_tmp, signal[i - 1], mu );
signal[i] = round_fx( L_tmp );
#endif /* BASOP_NOGLOB */
+ move16();
}
*mem = signal[L - 1];
@@ -169,7 +175,9 @@ void Deemph2(
Word16 i;
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
+ Flag Overflow;
+ Overflow = 0;
+ move32();
#endif
/* saturation can occur in L_mac() */
@@ -215,7 +223,9 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W
Word16 i;
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
+ Flag Overflow;
+ Overflow = 0;
+ move32();
#endif
/* signal[0] = signal[0] + mu * (*mem); */
@@ -232,6 +242,7 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W
L_tmp = L_msu( Mpy_32_16_1( L_tmp, mu ), x[i], shift );
x[i] = round_fx( L_tmp );
#endif
+ move16();
}
}
ELSE
@@ -245,6 +256,7 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W
L_tmp = L_msu( Mpy_32_16_1( L_tmp, mu ), shr( x[i], shift ), -32768 );
x[i] = round_fx( L_tmp );
#endif
+ move16();
}
}
diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c
index 0c0beef9ec54164b276fef2e0b9fa77a2ac94c0f..c1e1e869ccf7edaffd278c77435f785e950ce39c 100644
--- a/lib_com/delay_comp.c
+++ b/lib_com/delay_comp.c
@@ -39,8 +39,7 @@
#include "prot.h"
#include "ivas_cnst.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*--------------------------------------------------------------------------
* get_delay()
@@ -124,10 +123,11 @@ Word32 get_delay_fx( /* o : delay value in ms
#endif
)
{
- Word32 delay = 0;
+ Word32 delay;
+ delay = 0;
move32();
- IF( EQ_16( what_delay, ENC ) )
+ IF( what_delay == ENC )
{
IF( EQ_16( ivas_format, MONO_FORMAT ) ) /* EVS mono */
{
@@ -139,14 +139,14 @@ Word32 get_delay_fx( /* o : delay value in ms
delay = IVAS_ENC_DELAY_NS;
move32();
test();
- IF( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) )
+ if ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) )
{
delay = 0; /* All delay is compensated in the decoder with MASA */
move32();
}
}
test();
- IF( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) )
+ if ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) )
{
/* compensate for DirAC/SPAR filterbank delay */
delay = L_add( delay, IVAS_FB_ENC_DELAY_NS );
@@ -177,7 +177,7 @@ Word32 get_delay_fx( /* o : delay value in ms
IF( NE_16( output_config, AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) )
{
#endif
- IF( hCldfb != NULL )
+ if ( hCldfb != NULL )
{
/* compensate for filterbank delay */
delay = L_add( delay, IVAS_FB_DEC_DELAY_NS );
@@ -186,7 +186,7 @@ Word32 get_delay_fx( /* o : delay value in ms
}
#endif
test();
- IF( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) )
+ if ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) )
{
delay = L_add( delay, IVAS_ENC_DELAY_NS ); /* Compensate also the encoder delay in the decoder with MASA */
}
diff --git a/lib_com/dlpc_bfi_fx.c b/lib_com/dlpc_bfi_fx.c
index 63391f6d004b2c2dba98a219b0566d6135659515..be4b2769671f470b500ca229cf0c41b6120c384d 100644
--- a/lib_com/dlpc_bfi_fx.c
+++ b/lib_com/dlpc_bfi_fx.c
@@ -6,8 +6,7 @@
/* Header files */
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
void dlpc_bfi(
const Word16 L_frame,
@@ -35,7 +34,7 @@ void dlpc_bfi(
{
/* Decode the second LPC */
lsf_dec_bfi( MODE2, &lsf_q[M], &lsf_q[0], lsf_adaptive_mean, lsfBase, mem_MA, mem_AR, *stab_fac,
- 0, L_frame, last_good, nbLostCmpt + 1, plcBackgroundNoiseUpdated, lsf_q_cng, lsf_cng, old_lsf_q_cng, 0, 0, tcxonly, 0 );
+ 0, L_frame, last_good, add( nbLostCmpt, 1 ), plcBackgroundNoiseUpdated, lsf_q_cng, lsf_cng, old_lsf_q_cng, 0, 0, tcxonly, 0 );
}
/**/ /*No local variabvles defined*/
}
diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c
index 0bc9234c2f540408d5631075d6eace42b46ceedc..bd27d2137a5234757c747e4b90270f0c69c67bbf 100644
--- a/lib_com/edct_fx.c
+++ b/lib_com/edct_fx.c
@@ -4,11 +4,10 @@
#include
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "stl.h"
@@ -18,140 +17,146 @@
static Word16 get_edxt_factor( Word16 length ) /* Returns value of sqrtf(2.f/length) in Q15 */
{
- Word16 factor = 0; /*Q15*/
+ Word16 factor; /*Q15*/
+ factor = 0;
+ move16();
IF( EQ_16( length, 512 ) )
{
factor = 2048;
+ move16();
}
ELSE IF( EQ_16( length, 256 ) )
{
factor = 2896;
+ move16();
}
ELSE IF( EQ_16( length, 128 ) )
{
factor = 4096;
+ move16();
}
ELSE IF( EQ_16( length, 640 ) )
{
factor = 1832;
+ move16();
}
ELSE IF( EQ_16( length, 320 ) )
{
factor = 2590;
+ move16();
}
ELSE IF( EQ_16( length, 160 ) )
{
factor = 3663;
+ move16();
}
ELSE IF( EQ_16( length, 80 ) )
{
factor = 5181;
+ move16();
}
ELSE IF( EQ_16( length, 40 ) )
{
factor = 7327;
+ move16();
}
ELSE IF( EQ_16( length, 960 ) )
{
factor = 1496;
+ move16();
}
ELSE IF( EQ_16( length, 480 ) )
{
factor = 2115;
+ move16();
}
ELSE IF( EQ_16( length, 240 ) )
{
factor = 2991;
+ move16();
}
ELSE IF( EQ_16( length, 120 ) )
{
factor = 4230;
+ move16();
}
ELSE IF( EQ_16( length, 1200 ) )
{
factor = 1338;
+ move16();
}
ELSE IF( EQ_16( length, 800 ) )
{
factor = 1638;
+ move16();
}
ELSE IF( EQ_16( length, 400 ) )
{
factor = 2317;
+ move16();
}
ELSE IF( EQ_16( length, 200 ) )
{
factor = 3277;
+ move16();
}
return factor;
}
static Word16 const *get_edct_table( Word16 length, Word16 *q )
{
- Word16 const *edct_table = NULL;
+ Word16 const *edct_table;
+ edct_table = NULL;
SWITCH( length )
{
case 1200:
edct_table = edct_table_600_fx;
- move16();
*q = add( *q, 2 );
+ move16();
BREAK;
case 960:
edct_table = edct_table_480_fx;
- move16();
BREAK;
case 640:
edct_table = edct_table_320_fx;
- move16();
BREAK;
case 320:
edct_table = edct_table_160_fx;
- move16();
BREAK;
case 256:
edct_table = edct_table_128_fx;
- move16();
BREAK;
case 240:
edct_table = edct_table_120_fx;
- move16();
BREAK;
case 200:
edct_table = edct_table_100_fx;
- move16();
BREAK;
case 160:
edct_table = edct_table_80_fx;
- move16();
BREAK;
case 40:
edct_table = edct_table_20_fx;
- move16();
BREAK;
case 800:
edct_table = edct_table_400_fx;
- move16();
*q = add( *q, 2 );
+ move16();
BREAK;
case 512:
edct_table = edct_table_256_fx;
- move16();
BREAK;
case 480:
edct_table = edct_table_240_fx;
- move16();
BREAK;
case 400:
edct_table = edct_table_200_fx;
- move16();
BREAK;
case 128:
edct_table = edct_table_64_fx;
- move16();
BREAK;
case 80:
edct_table = edct_table_40_fx;
- move16();
BREAK;
default:
BREAK;
@@ -182,7 +187,7 @@ void edct_fx(
Word16 i;
Word32 re;
Word32 im;
- const Word16 *edct_table = 0; /*Q16 */
+ const Word16 *edct_table; /*Q16 */
Word32 complex_buf[2 * ( L_FRAME48k / 2 + 240 )];
Word32 L_tmp;
Word16 tmp;
@@ -193,32 +198,34 @@ void edct_fx(
/* Twiddling and Pre-rotate */
FOR( i = 0; i < len1; i++ )
{
- L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Q(q+1) */
- complex_buf[2 * i] = Madd_32_16( L_tmp, x[length - 1 - 2 * i], edct_table[len1 - 1 - i] ); /*Q(q+1) */
+ L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Q(q+1) */
+ complex_buf[2 * i] = Madd_32_16( L_tmp, x[sub( length, add( 1, shl( i, 1 ) ) )], edct_table[sub( len1, add( 1, i ) )] ); /*Q(q+1) */
move32();
- L_tmp = Mult_32_16( x[length - 1 - 2 * i], edct_table[i] ); /*Q(q+1) */
+ L_tmp = Mult_32_16( x[sub( length, add( 1, shl( i, 1 ) ) )], edct_table[i] ); /*Q(q+1) */
- complex_buf[2 * i + 1] = Msub_32_16( L_tmp, x[2 * i], edct_table[len1 - 1 - i] ); /*Q(q+1) */
+ complex_buf[add( shl( i, 1 ), 1 )] = Msub_32_16( L_tmp, x[shl( i, 1 )], edct_table[sub( len1, add( 1, i ) )] ); /*Q(q+1) */
move32();
}
*q = sub( 15, *q );
+ move16();
BASOP_cfft( (cmplx *) complex_buf, len1, q, y );
tmp = div_s( 1, length ); /*Q15 */
tmp = round_fx( L_shl( L_mult( tmp, 19302 ), 2 ) ); /*Q15 */
FOR( i = 0; i < len1; i++ )
{
- re = Msub_32_16( complex_buf[2 * i], complex_buf[2 * i + 1], tmp );
- im = Madd_32_16( complex_buf[2 * i + 1], complex_buf[2 * i], tmp );
- y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[len1 - 1 - i] ) );
+ re = Msub_32_16( complex_buf[2 * i], complex_buf[add( shl( i, 1 ), 1 )], tmp );
+ im = Madd_32_16( complex_buf[add( shl( i, 1 ), 1 )], complex_buf[2 * i], tmp );
+ y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[sub( len1, add( 1, i ) )] ) );
move32();
- y[length - 1 - 2 * i] = L_sub( Mult_32_16( re, edct_table[len1 - 1 - i] ), Mult_32_16( im, edct_table[i] ) );
+ y[sub( length, add( 1, shl( i, 1 ) ) )] = L_sub( Mult_32_16( re, edct_table[sub( len1, add( 1, i ) )] ), Mult_32_16( im, edct_table[i] ) );
move32();
} /*Q(q-2) */
*q = sub( 15 + 2, *q );
+ move16();
return;
}
@@ -245,7 +252,7 @@ void edst_fx(
Word16 i;
Word32 re;
Word32 im;
- const Word16 *edct_table = 0; /*Q16 */
+ const Word16 *edct_table; /*Q16 */
Word32 complex_buf[2 * ( L_FRAME48k / 2 + 240 )];
Word32 L_tmp;
Word16 tmp;
@@ -256,31 +263,33 @@ void edst_fx(
/* Twiddling and Pre-rotate */
FOR( i = 0; i < len1; i++ )
{
- L_tmp = Mult_32_16( x[length - 1 - 2 * i], edct_table[i] );
- complex_buf[2 * i] = Madd_32_16( L_tmp, x[2 * i], edct_table[len1 - 1 - i] );
+ L_tmp = Mult_32_16( x[sub( length, add( 1, shl( i, 1 ) ) )], edct_table[i] );
+ complex_buf[2 * i] = Madd_32_16( L_tmp, x[2 * i], edct_table[sub( len1, add( 1, i ) )] );
move32();
L_tmp = Mult_32_16( x[2 * i], edct_table[i] );
- complex_buf[2 * i + 1] = Msub_32_16( L_tmp, x[length - 1 - 2 * i], edct_table[len1 - 1 - i] );
+ complex_buf[add( shl( i, 1 ), 1 )] = Msub_32_16( L_tmp, x[sub( length, add( 1, shl( i, 1 ) ) )], edct_table[sub( len1, add( 1, i ) )] );
move32();
}
*q = sub( 15, *q );
+ move16();
BASOP_cfft( (cmplx *) complex_buf, len1, q, y );
tmp = div_s( 1, length ); /*Q15 */
tmp = round_fx( L_shl( L_mult( tmp, 19302 ), 2 ) ); /*Q15 */
FOR( i = 0; i < len1; i++ )
{
- re = Msub_32_16( complex_buf[2 * i], complex_buf[2 * i + 1], tmp );
- im = Madd_32_16( complex_buf[2 * i + 1], complex_buf[2 * i], tmp );
- y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[len1 - 1 - i] ) );
+ re = Msub_32_16( complex_buf[2 * i], complex_buf[add( shl( i, 1 ), 1 )], tmp );
+ im = Madd_32_16( complex_buf[add( shl( i, 1 ), 1 )], complex_buf[2 * i], tmp );
+ y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[sub( len1, add( 1, i ) )] ) );
move32();
- y[length - 1 - 2 * i] = L_sub( Mult_32_16( im, edct_table[i] ), Mult_32_16( re, edct_table[len1 - 1 - i] ) );
+ y[sub( length, add( 1, shl( i, 1 ) ) )] = L_sub( Mult_32_16( im, edct_table[i] ), Mult_32_16( re, edct_table[sub( len1, add( 1, i ) )] ) );
move32();
} /*Q(q) */
*q = sub( 15 + 2, *q );
+ move16();
return;
}
@@ -316,7 +325,7 @@ void edct_16fx(
Word16 i;
Word16 re[L_FRAME48k / 2];
Word16 im[L_FRAME48k / 2];
- const Word16 *edct_table = 0;
+ const Word16 *edct_table = NULL;
Word16 re2[L_FRAME48k / 2];
Word16 im2[L_FRAME48k / 2];
@@ -330,24 +339,23 @@ void edct_16fx(
(void) element_mode;
#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
+ Flag Overflow;
+ Overflow = 0;
+ move32();
#endif
/*COMPLETE: some eDCT sub function are missing */
IF( EQ_16( length, L_FRAME32k ) )
{
edct_table = &edct_table_320_16fx[0];
- move16();
}
ELSE IF( EQ_16( length, L_FRAME ) )
{
edct_table = &edct_table_128_16fx[0];
- move16();
}
ELSE IF( EQ_16( length, L_FRAME16k ) )
{
edct_table = &edct_table_160_16fx[0];
- move16();
}
ELSE
{
@@ -356,8 +364,8 @@ void edct_16fx(
/* Twiddling and Pre-rotate */
Lmax = L_deposit_l( 0 );
Len2 = shr( length, 1 );
- px = x + length - 1;
- pt = edct_table + Len2 - 1;
+ px = x + sub( length, 1 );
+ pt = edct_table + sub( Len2, 1 );
FOR( i = 0; i < Len2; i++ )
{
i2 = shl( i, 1 );
@@ -376,14 +384,15 @@ void edct_16fx(
}
tmp = 31;
+ move16();
if ( Lmax != 0 )
{
tmp = norm_l( Lmax );
}
Q_edct = sub( tmp, bh ); /*creating a bit-headroom */
- px = x + length - 1;
- pt = edct_table + Len2 - 1;
+ px = x + sub( length, 1 );
+ pt = edct_table + sub( Len2, 1 );
FOR( i = 0; i < Len2; i++ )
{
i2 = shl( i, 1 );
@@ -396,7 +405,7 @@ void edct_16fx(
Lacc = L_mac( L_tmp, *px, *pt ); /*Q(Qx+16) */
re2[i] = round_fx( L_shl( Lacc, Q_edct ) ); /* Q(Qx+Q_edct) */
#endif
-
+ move16();
L_tmp = L_mult( *px, edct_table[i] ); /*Q(Qx+16) */
#ifdef BASOP_NOGLOB
Lacc = L_msu_o( L_tmp, x[i2], *pt, &Overflow ); /*Q(Qx+16) */
@@ -405,6 +414,7 @@ void edct_16fx(
Lacc = L_msu( L_tmp, x[i2], *pt ); /*Q(Qx+16) */
im2[i] = round_fx( L_shl( Lacc, Q_edct ) ); /* Q(Qx+Q_edct) */
#endif
+ move16();
px -= 2;
pt--;
}
@@ -426,7 +436,7 @@ void edct_16fx(
tmp = div_s( 1, length ); /*Q15 */
L_tmp = L_mult( tmp, 19302 ); /*Q29, (3*PI/4) in Q13 */
fact = round_fx( L_shl( L_tmp, 2 ) ); /*Q15 */
- FOR( i = 0; i < length / 2; i++ )
+ FOR( i = 0; i < shr( length, 1 ); i++ )
{
tmp = mult_r( im2[i], fact ); /*Q(Qx+Q_edct) */
#ifdef BASOP_NOGLOB
@@ -448,8 +458,8 @@ void edct_16fx(
}
/* Post-rotate and obtain the output data */
- py = y + length - 1;
- pt = edct_table + Len2 - 1;
+ py = y + sub( length, 1 );
+ pt = edct_table + sub( Len2, 1 );
FOR( i = 0; i < Len2; i++ )
{
i2 = shl( i, 1 );
@@ -462,14 +472,16 @@ void edct_16fx(
Lacc = L_mac( L_tmp, im[i], *pt ); /*Q(Qx+Q_edct+16) */
y[i2] = round_fx( L_shr( Lacc, Q_edct ) ); /* Q(Qx) */
#endif /* BASOP_NOGLOB */
+ move16();
- L_tmp = L_mult( re[i], edct_table[length / 2 - 1 - i] ); /*Q(Qx+Q_edct+16) */
- Lacc = L_msu( L_tmp, im[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */
+ L_tmp = L_mult( re[i], edct_table[sub( shr( length, 1 ), add( 1, i ) )] ); /*Q(Qx+Q_edct+16) */
+ Lacc = L_msu( L_tmp, im[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */
#ifdef BASOP_NOGLOB
*py = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */
#else /* BASOP_NOGLOB */
*py = round_fx( L_shr( Lacc, Q_edct ) ); /* Q(Qx) */
#endif
+ move16();
py -= 2;
pt--;
@@ -521,13 +533,13 @@ void iedct_short_fx(
}
FOR( i = 0; i < seg_len_div4; i++ )
{
- out[i] = alias[seg_len_div4 + i];
+ out[i] = alias[add( seg_len_div4, i )];
move32();
- out[seg_len_div4 + i] = L_negate( alias[seg_len_div2 - 1 - i] );
+ out[add( seg_len_div4, i )] = L_negate( alias[sub( sub( seg_len_div2, 1 ), i )] );
move32();
- out[seg_len_div2 + i] = L_negate( alias[seg_len_div4 - 1 - i] );
+ out[add( seg_len_div2, i )] = L_negate( alias[sub( sub( seg_len_div4, 1 ), i )] );
move32();
- out[seg_len_3mul_div4 + i] = L_negate( alias[i] );
+ out[add( seg_len_3mul_div4, i )] = L_negate( alias[i] );
move32();
}
@@ -549,112 +561,132 @@ void edxt_fx(
const UWord16 synthesis /* i : nonzero for inverse */
)
{
- Word16 k, m, fac = 0;
- const Word16 *cosPtr = NULL, *sinPtr = NULL;
- Word16 n = 0;
-
+ Word16 k, m, fac;
+ const Word16 *cosPtr, *sinPtr;
+ Word16 n;
+ n = 0;
+ move16();
+ cosPtr = NULL;
+ sinPtr = NULL;
IF( EQ_16( length, 512 ) )
{
cosPtr = cos_scale_tbl_512;
sinPtr = sin_scale_tbl_512;
n = 1;
+ move16();
}
ELSE IF( EQ_16( length, 256 ) )
{
cosPtr = cos_scale_tbl_512;
sinPtr = sin_scale_tbl_512;
n = 2;
+ move16();
}
ELSE IF( EQ_16( length, 128 ) )
{
cosPtr = cos_scale_tbl_512;
sinPtr = sin_scale_tbl_512;
n = 4;
+ move16();
}
ELSE IF( EQ_16( length, 640 ) )
{
cosPtr = cos_scale_tbl_640;
sinPtr = sin_scale_tbl_640;
n = 1;
+ move16();
}
ELSE IF( EQ_16( length, 320 ) )
{
cosPtr = cos_scale_tbl_640;
sinPtr = sin_scale_tbl_640;
n = 2;
+ move16();
}
ELSE IF( EQ_16( length, 160 ) )
{
cosPtr = cos_scale_tbl_640;
sinPtr = sin_scale_tbl_640;
n = 4;
+ move16();
}
ELSE IF( EQ_16( length, 80 ) )
{
cosPtr = cos_scale_tbl_640;
sinPtr = sin_scale_tbl_640;
n = 8;
+ move16();
}
ELSE IF( EQ_16( length, 40 ) )
{
cosPtr = cos_scale_tbl_640;
sinPtr = sin_scale_tbl_640;
n = 16;
+ move16();
}
ELSE IF( EQ_16( length, 960 ) )
{
cosPtr = cos_scale_tbl_960;
sinPtr = sin_scale_tbl_960;
n = 1;
+ move16();
}
ELSE IF( EQ_16( length, 480 ) )
{
cosPtr = cos_scale_tbl_960;
sinPtr = sin_scale_tbl_960;
n = 2;
+ move16();
}
ELSE IF( EQ_16( length, 240 ) )
{
cosPtr = cos_scale_tbl_960;
sinPtr = sin_scale_tbl_960;
n = 4;
+ move16();
}
ELSE IF( EQ_16( length, 120 ) )
{
cosPtr = cos_scale_tbl_960;
sinPtr = sin_scale_tbl_960;
n = 8;
+ move16();
}
ELSE IF( EQ_16( length, 1200 ) )
{
cosPtr = cos_scale_tbl_1200;
sinPtr = sin_scale_tbl_1200;
n = 1;
+ move16();
}
ELSE IF( EQ_16( length, 800 ) )
{
cosPtr = cos_scale_tbl_800;
sinPtr = sin_scale_tbl_800;
n = 1;
+ move16();
}
ELSE IF( EQ_16( length, 400 ) )
{
cosPtr = cos_scale_tbl_800;
sinPtr = sin_scale_tbl_800;
n = 2;
+ move16();
}
ELSE IF( EQ_16( length, 200 ) )
{
cosPtr = cos_scale_tbl_800;
sinPtr = sin_scale_tbl_800;
n = 4;
+ move16();
}
#ifdef FAST_EDXT
+ test();
IF( EQ_16( kernelType, MDST_II ) || EQ_16( kernelType, MDCT_II ) )
{
const Word16 Nm1 = sub( length, 1 );
- const Word16 xSign = 2 * ( kernelType >> 1 ) - 1;
+ const Word16 xSign = sub( imult1616( 2, shr( kernelType, 1 ) ), 1 );
Word32 re[L_FRAME_PLUS];
Word32 im[L_FRAME_PLUS];
@@ -663,8 +695,11 @@ void edxt_fx(
FOR( k = shr( Nm1, 1 ); k >= 0; k-- ) /* pre-modulation of audio input */
{
re[k] = x[2 * k];
- re[Nm1 - k] = Mpy_32_16_1( x[2 * k + 1], shl_sat( xSign, 15 ) );
- im[k] = im[Nm1 - k] = 0;
+ re[sub( Nm1, k )] = Mpy_32_16_1( x[add( shl( k, 1 ), 1 )], shl_sat( xSign, 15 ) );
+ im[k] = im[sub( Nm1, k )] = 0;
+ move32();
+ move32();
+ move32();
}
IF( EQ_16( length, 512 ) )
@@ -682,13 +717,16 @@ void edxt_fx(
{
// const float wRe = cosf( scale * k );
// const float wIm = sinf( scale * k );
- const Word16 wRe = cosPtr[k * n];
- const Word16 wIm = sinPtr[k * n];
+ const Word16 wRe = cosPtr[imult1616( k, n )];
+ const Word16 wIm = sinPtr[imult1616( k, n )];
y[k] /*pt 1*/ = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) );
- y[length - k] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) );
+ y[sub( length, k )] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) );
+ move32();
+ move32();
}
y[shr( length, 1 )] = Mpy_32_16_1( re[shr( length, 1 )], INV_SQRT_2_Q15 );
+ move32();
}
ELSE /* forw. DST-II */
{
@@ -696,16 +734,20 @@ void edxt_fx(
{
// const float wRe = cosf( scale * k );
// const float wIm = sinf( scale * k );
- const Word16 wRe = cosPtr[k * n];
- const Word16 wIm = sinPtr[k * n];
+ const Word16 wRe = cosPtr[imult1616( k, n )];
+ const Word16 wIm = sinPtr[imult1616( k, n )];
- y[Nm1 - k] = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) );
+ y[sub( Nm1, k )] = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) );
y[k - 1] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) );
+ move32();
+ move32();
}
y[shr( Nm1, 1 )] = Mpy_32_16_1( re[shr( length, 1 )], INV_SQRT_2_Q15 );
+ move32();
}
- y[Nm1 - Nm1 * ( kernelType >> 1 )] = L_shr( re[0], 1 );
+ y[sub( Nm1, imult1616( Nm1, shl( kernelType, 1 ) ) )] = L_shr( re[0], 1 );
+ move32();
}
ELSE /* inverse II = III */
{
@@ -715,13 +757,16 @@ void edxt_fx(
{
// const float wRe = cosf( scale * k ) * 0.5f;
// const float wIm = sinf( scale * k ) * 0.5f;
- const Word16 wRe = shr( cosPtr[k * n], 1 );
- const Word16 wIm = shr( sinPtr[k * n], 1 );
+ const Word16 wRe = shr( cosPtr[imult1616( k, n )], 1 );
+ const Word16 wIm = shr( sinPtr[imult1616( k, n )], 1 );
- re[k] = L_add( Mpy_32_16_1( x[k], wRe ), Mpy_32_16_1( x[length - k], wIm ) );
- im[k] = L_sub( Mpy_32_16_1( x[length - k], wRe ), Mpy_32_16_1( x[k], wIm ) );
+ re[k] = L_add( Mpy_32_16_1( x[k], wRe ), Mpy_32_16_1( x[sub( length, k )], wIm ) );
+ im[k] = L_sub( Mpy_32_16_1( x[sub( length, k )], wRe ), Mpy_32_16_1( x[k], wIm ) );
+ move32();
+ move32();
}
re[shr( length, 1 )] = Mpy_32_16_1( x[shr( length, 1 )], INV_SQRT_2_Q15 );
+ move32();
}
ELSE /* DST type III */
{
@@ -729,21 +774,28 @@ void edxt_fx(
{
// const float wRe = cosf( scale * k ) * 0.5f;
// const float wIm = sinf( scale * k ) * 0.5f;
- const Word16 wRe = shr( cosPtr[k * n], 1 );
- const Word16 wIm = shr( sinPtr[k * n], 1 );
+ const Word16 wRe = shr( cosPtr[imult1616( k, n )], 1 );
+ const Word16 wIm = shr( sinPtr[imult1616( k, n )], 1 );
- re[k] = L_add( Mpy_32_16_1( x[Nm1 - k], wRe ), Mpy_32_16_1( x[k - 1], wIm ) );
- im[k] = L_sub( Mpy_32_16_1( x[k - 1], wRe ), Mpy_32_16_1( x[Nm1 - k], wIm ) );
+ re[k] = L_add( Mpy_32_16_1( x[sub( Nm1, k )], wRe ), Mpy_32_16_1( x[sub( k, 1 )], wIm ) );
+ im[k] = L_sub( Mpy_32_16_1( x[sub( k, 1 )], wRe ), Mpy_32_16_1( x[sub( Nm1, k )], wIm ) );
+ move32();
+ move32();
}
re[shr( length, 1 )] = Mpy_32_16_1( x[shr( Nm1, 1 )], INV_SQRT_2_Q15 );
+ move32();
}
- re[0] = x[Nm1 - Nm1 * shr( kernelType, 1 )];
+ re[0] = x[sub( Nm1, imult1616( Nm1, shr( kernelType, 1 ) ) )];
im[0] = im[shr( length, 1 )] = 0;
+ move32();
+ move32();
FOR( k = shr( Nm1, 1 ); k > 0; k-- )
{
- re[length - k] = re[k];
- im[length - k] = L_negate( im[k] );
+ re[sub( length, k )] = re[k];
+ im[sub( length, k )] = L_negate( im[k] );
+ move32();
+ move32();
}
IF( EQ_16( length, 512 ) )
@@ -758,14 +810,16 @@ void edxt_fx(
FOR( k = shr( Nm1, 1 ); k >= 0; k-- ) /* post-modulation of FFT output */
{
y[2 * k] = re[k];
- IF( NE_16( xSign, 0 ) )
+ move32();
+ IF( xSign != 0 )
{
- y[2 * k + 1] = Mpy_32_16_1( re[sub( Nm1, k )], shl_sat( xSign, 15 ) );
+ y[add( shl( k, 1 ), 1 )] = Mpy_32_16_1( re[sub( Nm1, k )], shl_sat( xSign, 15 ) );
}
ELSE
{
- y[2 * k + 1] = 0;
+ y[add( shl( k, 1 ), 1 )] = 0;
}
+ move32();
}
}
}
@@ -812,7 +866,7 @@ void edxt_fx(
#endif // IVAS_FLOAT_FIXED_TO_BE_DONE
/*v_multc(y, (kernelType == MDCT_II ? -1.f : 1.f) * sqrtf(2.f / length), y, length);*/
fac = get_edxt_factor( length ); /* Q15 */
- IF( EQ_16( kernelType, MDCT_II ) )
+ if ( EQ_16( kernelType, MDCT_II ) )
{
fac = negate( fac );
}
@@ -820,6 +874,7 @@ void edxt_fx(
FOR( m = 0; m < length; m++ )
{
y[m] = Mpy_32_16_1( y[m], fac );
+ move32();
}
return;
}
diff --git a/lib_com/enh64.c b/lib_com/enh64.c
index f0b80407634c3a6e6b1f2cfe423d3c6072917828..dda2d451b6e0e13ce1689fdda506acdbd7044e53 100644
--- a/lib_com/enh64.c
+++ b/lib_com/enh64.c
@@ -1062,6 +1062,56 @@ Word64 W_msu_16_16( Word64 L64_var1, Word16 var2, Word16 var3 )
return L64_var_out;
}
+/* Below BASOP is not part of STL 2023 library, might be proposed in next update */
+/*________________________________________________________________________________________________
+| |
+| Function Name : W_mac_32_32 |
+| |
+| Purpose : |
+| |
+| Multiply var1 by var2 and shift the result left by 1 and add the 64 bit result to L64_acc, |
+| return a 64 bit result. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_acc |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_acc <= 0x7fffffff ffffffffLL. |
+| |
+| var1 |
+| 32 bit signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= var1 <= 0x7fff 0000. |
+| |
+| var2 |
+| 32 bit signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= var2 <= 0x7fff 0000. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. |
+|_________________________________________________________________________________________________|
+*/
+Word64 W_mac_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 )
+{
+ Word64 L64_var_out = W_mult_32_32( L_var2, L_var3 );
+ L64_var_out = W_add( L64_var1, L64_var_out );
+
+#if ( WMOPS )
+ multiCounter[currCounter].W_mult_32_32--;
+ /* multiCounter[currCounter].W_add--; */
+#endif
+
+ return L64_var_out;
+}
+
/*___________________________________________________________________________
| |
diff --git a/lib_com/enh64.h b/lib_com/enh64.h
index 9016a27aef7990c5e5038fe54400d01a622be81d..8aed870a67e0688ab7e3398caa7f7aa040f186b0 100644
--- a/lib_com/enh64.h
+++ b/lib_com/enh64.h
@@ -36,6 +36,8 @@ Word64 W_msu0_16_16( Word64 L64_acc, Word16 var1, Word16 var2 );
Word64 W_mult_16_16( Word16 var1, Word16 var2 );
Word64 W_mac_16_16( Word64 L64_acc, Word16 var1, Word16 var2 );
Word64 W_msu_16_16( Word64 L64_acc, Word16 var1, Word16 var2 );
+/* BASOP W_mac_32_32 is not part of STL 2023 library, might be proposed in next update */
+Word64 W_mac_32_32( Word64 L64_acc, Word32 var1, Word32 var2 );
Word64 W_deposit32_l( Word32 L_var1 );
Word64 W_deposit32_h( Word32 L_var1 );
diff --git a/lib_com/enhancer_fx.c b/lib_com/enhancer_fx.c
index 6336dd685b19ffd2a84bd3a515fe94eec665c84c..7f529ec125be9e019273fec1354b8abc302108b8 100644
--- a/lib_com/enhancer_fx.c
+++ b/lib_com/enhancer_fx.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
#include "basop_util.h"
/*---------------------------------------------------------------------*
@@ -25,38 +24,38 @@ static void phase_dispersion_fx( Word32 gain_code, Word16 gain_pit, Word16 code[
static void agc2_fx( const Word16 *sig_in, Word16 *sig_out, const Word16 l_trm );
/*======================================================================================*/
-/* FUNCTION : enhancer_fx() */
+/* FUNCTION : enhancer_fx() */
/*--------------------------------------------------------------------------------------*/
-/* PURPOSE : Enhancement of the excitation signal before synthesis */
+/* PURPOSE : Enhancement of the excitation signal before synthesis */
/*--------------------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word32) core_brate : decoder bitrate */
-/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode */
-/* _ (Word16) coder_type : coder type */
-/* _ (Word16) i_subfr : subframe number */
-/* _ (Word16) voice_fac : subframe voicing estimation (Q15) */
-/* _ (Word16) stab_fac : LP filter stablility measure (Q15) */
-/* _ (Word32) norm_gain_code : normalised innovative cb. gain (Q16) */
-/* _ (Word16) gain_inov : gain of the unscaled innovation (Q12) */
-/* _ (Word16) gain_pit_fx : Pitch gain (Q14) */
-/* _ (Word16) Q_exc : Q of the excitation */
-/* _ (Word16) Enc : Encoder = 1; decoder = 0 */
+/* INPUT ARGUMENTS : */
+/* _ (Word32) core_brate : decoder bitrate */
+/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode */
+/* _ (Word16) coder_type : coder type */
+/* _ (Word16) i_subfr : subframe number */
+/* _ (Word16) voice_fac : subframe voicing estimation (Q15) */
+/* _ (Word16) stab_fac : LP filter stablility measure (Q15) */
+/* _ (Word32) norm_gain_code : normalised innovative cb. gain (Q16) */
+/* _ (Word16) gain_inov : gain of the unscaled innovation (Q12) */
+/* _ (Word16) gain_pit_fx : Pitch gain (Q14) */
+/* _ (Word16) Q_exc : Q of the excitation */
+/* _ (Word16) Enc : Encoder = 1; decoder = 0 */
/*--------------------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16*) voice_factors_fx : TBE voicing factor (Q15) */
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) voice_factors_fx : TBE voicing factor (Q15) */
/*--------------------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _ (Word32*) gc_threshold : gain code threshold (Q16) */
-/* _ (Word16*[]) code : innovation (Q12) */
-/* _ (Word16*[]) exc2 : adapt. excitation/total exc (Q0) */
-/* _ (struct dispMem_fx*) dm_fx : phase dispersion algorithm memory */
-/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word32*) gc_threshold : gain code threshold (Q16) */
+/* _ (Word16*[]) code : innovation (Q12) */
+/* _ (Word16*[]) exc2 : adapt. excitation/total exc (Q0) */
+/* _ (struct dispMem_fx*) dm_fx : phase dispersion algorithm memory */
+/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */
/*--------------------------------------------------------------------------------------*/
-/* _ None */
+/* _ None */
/*--------------------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
+/* RETURN ARGUMENTS : */
+/* _ None */
/*======================================================================================*/
void enhancer_fx(
const Word32 core_brate, /* i : decoder bitrate */
@@ -87,7 +86,6 @@ void enhancer_fx(
pit_sharp = gain_pit;
move16(); /* to remove gcc warning */
pt_exc2 = exc2 + i_subfr;
- move16();
/*------------------------------------------------------------*
* Phase dispersion to enhance noise at low bit rate
@@ -120,7 +118,7 @@ void enhancer_fx(
i = 0;
move16(); /* high dispersion */
}
- ELSE if ( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || EQ_16( coder_type, AUDIO ) || EQ_16( coder_type, INACTIVE ) ) && LE_32( core_brate, ACELP_9k60 ) )
+ ELSE if ( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && LE_32( core_brate, ACELP_9k60 ) )
{
i = 1;
move16(); /* low dispersion */
@@ -186,6 +184,7 @@ void enhancer_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
pt_exc2[i] = round_fx( L_shl( L_mult( gain_code_hi, code[i] ), sc ) ); /*Q0 */ /* code in Q12 (Q9 for encoder) */
+ move16();
}
}
ELSE
@@ -236,9 +235,11 @@ void enhancer_fx(
#ifdef BASOP_NOGLOB
L_tmp = L_shl_sat( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc );
pt_exc2[0] = msu_r_sat( L_tmp, -32768, pt_exc2[0] );
+ move16();
#else
L_tmp = L_shl( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc );
pt_exc2[0] = msu_r( L_tmp, -32768, pt_exc2[0] );
+ move16();
#endif
move16(); /* in Q_exc */
@@ -251,6 +252,7 @@ void enhancer_fx(
tmp16 = msu_r_sat( L_tmp, code[i - 1], tmp );
L_tmp = L_shl_sat( L_mult( gain_code_hi, tmp16 ), sc );
pt_exc2[i] = msu_r_sat( L_tmp, -32768, pt_exc2[i] );
+ move16();
#else
tmp16 = msu_r( L_tmp, code[i - 1], tmp );
L_tmp = L_shl( L_mult( gain_code_hi, tmp16 ), sc );
@@ -265,8 +267,10 @@ void enhancer_fx(
L_tmp = L_shl( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc );
#ifdef BASOP_NOGLOB
pt_exc2[L_SUBFR - 1] = msu_r_sat( L_tmp, -32768, pt_exc2[L_SUBFR - 1] );
+ move16();
#else
pt_exc2[L_SUBFR - 1] = msu_r( L_tmp, -32768, pt_exc2[L_SUBFR - 1] );
+ move16();
#endif
move16(); /* in Q_exc */
test();
@@ -294,38 +298,38 @@ void enhancer_fx(
/*======================================================================================*/
-/* FUNCTION : enhancer_fx() */
+/* FUNCTION : enhancer_fx() */
/*--------------------------------------------------------------------------------------*/
-/* PURPOSE : Enhancement of the excitation signal before synthesis */
+/* PURPOSE : Enhancement of the excitation signal before synthesis */
/*--------------------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word32) core_brate : decoder bitrate */
-/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode */
-/* _ (Word16) coder_type : coder type */
-/* _ (Word16) i_subfr : subframe number */
-/* _ (Word16) voice_fac : subframe voicing estimation (Q15) */
-/* _ (Word16) stab_fac : LP filter stablility measure (Q15) */
-/* _ (Word32) norm_gain_code : normalised innovative cb. gain (Q16) */
-/* _ (Word16) gain_inov : gain of the unscaled innovation (Q12) */
-/* _ (Word16) gain_pit_fx : Pitch gain (Q14) */
-/* _ (Word16) Q_exc : Q of the excitation */
-/* _ (Word16) Enc : Encoder = 1; decoder = 0 */
+/* INPUT ARGUMENTS : */
+/* _ (Word32) core_brate : decoder bitrate */
+/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode */
+/* _ (Word16) coder_type : coder type */
+/* _ (Word16) i_subfr : subframe number */
+/* _ (Word16) voice_fac : subframe voicing estimation (Q15) */
+/* _ (Word16) stab_fac : LP filter stablility measure (Q15) */
+/* _ (Word32) norm_gain_code : normalised innovative cb. gain (Q16) */
+/* _ (Word16) gain_inov : gain of the unscaled innovation (Q12) */
+/* _ (Word16) gain_pit_fx : Pitch gain (Q14) */
+/* _ (Word16) Q_exc : Q of the excitation */
+/* _ (Word16) Enc : Encoder = 1; decoder = 0 */
/*--------------------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16*) voice_factors_fx : TBE voicing factor (Q15) */
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) voice_factors_fx : TBE voicing factor (Q15) */
/*--------------------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _ (Word32*) gc_threshold : gain code threshold (Q16) */
-/* _ (Word16*[]) code : innovation (Q12) */
-/* _ (Word16*[]) exc2 : adapt. excitation/total exc (Q0) */
-/* _ (struct dispMem_fx*) dm_fx : phase dispersion algorithm memory */
-/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word32*) gc_threshold : gain code threshold (Q16) */
+/* _ (Word16*[]) code : innovation (Q12) */
+/* _ (Word16*[]) exc2 : adapt. excitation/total exc (Q0) */
+/* _ (struct dispMem_fx*) dm_fx : phase dispersion algorithm memory */
+/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */
/*--------------------------------------------------------------------------------------*/
-/* _ None */
+/* _ None */
/*--------------------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
+/* RETURN ARGUMENTS : */
+/* _ None */
/*======================================================================================*/
void enhancer_ivas_fx(
const Word16 codec_mode, /* i : flag indicating Codec Mode */
@@ -358,7 +362,6 @@ void enhancer_ivas_fx(
pit_sharp = gain_pit;
move16(); /* to remove gcc warning */
pt_exc2 = exc2 + i_subfr;
- move16();
/*------------------------------------------------------------*
* Phase dispersion to enhance noise at low bit rate
@@ -366,6 +369,9 @@ void enhancer_ivas_fx(
i = 2;
move16(); /* no dispersion */
+ test();
+ test();
+ test();
IF( Opt_AMR_WB )
{
IF( LE_32( core_brate, ACELP_6k60 ) )
@@ -391,7 +397,7 @@ void enhancer_ivas_fx(
i = 0;
move16(); /* high dispersion */
}
- ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || EQ_16( coder_type, AUDIO ) || EQ_16( coder_type, INACTIVE ) ) && LE_32( core_brate, ACELP_9k60 ) )
+ ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && LE_32( core_brate, ACELP_9k60 ) )
{
i = 1;
move16(); /* low dispersion */
@@ -399,18 +405,29 @@ void enhancer_ivas_fx(
}
ELSE IF( EQ_16( codec_mode, MODE2 ) )
{
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
IF( ( NE_16( coder_type, VOICED ) && LE_16( cbk_index, 2 ) ) || ( EQ_16( coder_type, UNVOICED ) && EQ_16( L_frame, L_FRAME ) && LE_16( cbk_index, 10 ) ) || ( EQ_16( coder_type, UNVOICED ) && EQ_16( L_frame, L_FRAME16k ) && LE_16( cbk_index, 14 ) ) )
{
i = 0; /* high dispersion */
+ move16();
}
ELSE IF( NE_16( coder_type, VOICED ) && LE_16( cbk_index, 7 ) )
{
i = 1; /* low dispersion */
+ move16();
}
}
ELSE IF( EQ_16( codec_mode, MODE1 ) && EQ_16( coder_type, UNVOICED ) && cbk_index /*uc_two_stage_flag*/ )
{
i = 0; /* high dispersion */
+ move16();
}
phase_dispersion_fx( norm_gain_code, gain_pit, code, i, dm_fx );
@@ -472,6 +489,7 @@ void enhancer_ivas_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
pt_exc2[i] = round_fx( L_shl( L_mult( gain_code_hi, code[i] ), sc ) ); /*Q0 */ /* code in Q12 (Q9 for encoder) */
+ move16();
}
}
ELSE
@@ -593,7 +611,7 @@ Word16 E_UTIL_enhancer(
move16();
code_exp = 15 - 9;
- exc2_exp = 15 - Q_new;
+ exc2_exp = sub( 15, Q_new );
gain_inov = shr( gain_inov, 1 );
/*-----------------------------------------------------------------*
* Phase dispersion to enhance noise at low bit rates
@@ -659,8 +677,9 @@ Word16 E_UTIL_enhancer(
L_tmp = Mpy_32_32( L_tmp, 1804608000l /*1.0f/1.19f Q31*/ );
L_tmp = L_max( L_tmp, *gc_threshold );
}
- move32();
+
*gc_threshold = L_tmp; /* in 15Q16 */
+ move32();
/* gain = ( (fac * L_tmp) + (gain_code - fac*gain_code) ) * gain_inov */
/* exponent of L_tmp: 31-16 + 15-11 */
@@ -670,7 +689,6 @@ Word16 E_UTIL_enhancer(
tmp = norm_l( L_tmp );
/* exponent of code: 31-16 + 15-11 - tmp + code_exp */
- move16();
code_exp = sub( add( 31 - 16 + 15 - 11, code_exp ), tmp );
#ifdef BASOP_NOGLOB
@@ -699,7 +717,7 @@ Word16 E_UTIL_enhancer(
gain = add( sub( code_exp, exc2_exp ), 1 );
tmp = mac_r( 268435456l /*0.125f Q31*/, 4096 /*0.125f Q15*/, voice_fac ); /* 0.25=voiced, 0=unvoiced */
- if ( EQ_16( L_frame, L_FRAME16k ) )
+ IF( EQ_16( L_frame, L_FRAME16k ) )
{
tmp = mac_r( 322122560l /*0.150f Q31*/, 4915 /*0.150f Q15*/, voice_fac ); /* 0.30=voiced, 0=unvoiced */
}
@@ -707,7 +725,7 @@ Word16 E_UTIL_enhancer(
/* exc2[0] = exc2[0] + code[0] - tmp*code[1]; */
L_tmp = L_mult( code[0], 16384 );
L_tmp = L_msu0( L_tmp, tmp, code[1] );
- if ( gain )
+ IF( gain )
{
#ifdef BASOP_NOGLOB
L_tmp = L_shl_sat( L_tmp, gain );
@@ -722,14 +740,14 @@ Word16 E_UTIL_enhancer(
#endif
move16();
- FOR( i = 1; i < L_subfr - 1; i++ )
+ FOR( i = 1; i < sub( L_subfr, 1 ); i++ )
{
/* exc2[i] = exc2[i] + code[i] - tmp*(code[i+1]+code[i-1]); */
L_tmp = L_mult( code[i], 16384 );
#ifdef BASOP_NOGLOB
L_tmp = L_msu0_sat( L_tmp, tmp, code[i - 1] );
L_tmp = L_msu0_sat( L_tmp, tmp, code[i + 1] );
- if ( gain )
+ IF( gain )
{
L_tmp = L_shl_sat( L_tmp, gain );
}
@@ -749,7 +767,7 @@ Word16 E_UTIL_enhancer(
L_tmp = L_mult( code[i], 16384 );
#ifdef BASOP_NOGLOB
L_tmp = L_msu0_sat( L_tmp, tmp, code[i - 1] );
- if ( gain )
+ IF( gain )
{
L_tmp = L_shl_sat( L_tmp, gain );
}
@@ -774,28 +792,28 @@ Word16 E_UTIL_enhancer(
* post-processing to enhance noise in low bit rate.
*-----------------------------------------------------------------------*/
/*======================================================================================*/
-/* FUNCTION : phase_dispersion_fx() */
+/* FUNCTION : phase_dispersion_fx() */
/*--------------------------------------------------------------------------------------*/
-/* PURPOSE : post-processing to enhance noise in low bit rate. */
+/* PURPOSE : post-processing to enhance noise in low bit rate. */
/*--------------------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word32) gain_code : gain of code Q16 */
-/* _ (Word16) gain_pit : gain of pitch Q14 */
-/* _ (Word16) mode : level, 0=hi, 1=lo, 2=off */
+/* INPUT ARGUMENTS : */
+/* _ (Word32) gain_code : gain of code Q16 */
+/* _ (Word16) gain_pit : gain of pitch Q14 */
+/* _ (Word16) mode : level, 0=hi, 1=lo, 2=off */
/*--------------------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ None */
+/* OUTPUT ARGUMENTS : */
+/* _ None */
/*--------------------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _ (Word16[]) code : code vector (Q12) */
-/* _ (struct dispMem_fx*) dm_fx : static memory (size = 8) */
-/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word16[]) code : code vector (Q12) */
+/* _ (struct dispMem_fx*) dm_fx : static memory (size = 8) */
+/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */
/*--------------------------------------------------------------------------------------*/
-/* _ None */
+/* _ None */
/*--------------------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
+/* RETURN ARGUMENTS : */
+/* _ None */
/*======================================================================================*/
static void phase_dispersion_fx(
Word32 gain_code, /* i : gain of code Q16 */
@@ -886,26 +904,19 @@ static void phase_dispersion_fx(
r_fft_fx_lc( phs_tbl_dec, SIZE, SIZE2, NUM_STAGES, code, code2, 1 );
h_real = Mid_H_phasedisp;
- move16();
if ( state == 0 )
{
h_real = Low_H_phasedisp;
- move16();
}
/* FFT Coefs are in code2 */
code2_real = code2;
- move16();
code2_imag = code2 + L_SUBFR - 1;
- move16();
code_real = code;
- move16();
code_imag = code + L_SUBFR - 1;
- move16();
h_imag = h_real + L_SUBFR - 1;
- move16();
*code_real++ = mult( *code2_real++, *h_real++ );
move16(); /* DC */
@@ -937,25 +948,25 @@ static void phase_dispersion_fx(
}
/*======================================================================================*/
-/* FUNCTION : agc2_fx() */
+/* FUNCTION : agc2_fx() */
/*--------------------------------------------------------------------------------------*/
-/* PURPOSE : AGC post-processing for lower G722.2 modes */
+/* PURPOSE : AGC post-processing for lower G722.2 modes */
/*--------------------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16*[]) sig_in : postfilter input signal (Q0) */
-/* _ (Word16) l_trm : subframe size */
+/* INPUT ARGUMENTS : */
+/* _ (Word16*[]) sig_in : postfilter input signal (Q0) */
+/* _ (Word16) l_trm : subframe size */
/*--------------------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ None */
+/* OUTPUT ARGUMENTS : */
+/* _ None */
/*--------------------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _ (Word16*[]) sig_out : postfilter output signal (Q0) */
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word16*[]) sig_out : postfilter output signal (Q0) */
/*--------------------------------------------------------------------------------------*/
-/* _ None */
+/* _ None */
/*--------------------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
+/* RETURN ARGUMENTS : */
+/* _ None */
/*======================================================================================*/
static void agc2_fx(
const Word16 *sig_in, /* i : postfilter input signal */
@@ -1034,6 +1045,7 @@ static void agc2_fx(
#else
sig_out[i] = round_fx( L_shl( L_mac( -8192, sig_out[i], g0 ), 2 ) );
#endif
+ move16();
}
}
}
diff --git a/lib_com/enr_1_az.c b/lib_com/enr_1_az.c
index f55d6917bbf72fcbca14e7f44414e36749f39214..3285c515a469368aa8f0d7f366614a5c74b197e1 100644
--- a/lib_com/enr_1_az.c
+++ b/lib_com/enr_1_az.c
@@ -39,7 +39,7 @@
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
* enr_1_Az()
@@ -84,6 +84,7 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3
Word32 L_tmp, L_tmp2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* Find the impulse response */
@@ -99,12 +100,14 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3
/* h1_in Q11, h1_out Q10 */
L_tmp = L_mult( a0, 1 << 13 ); /* Q25 = L_mult(Q11,Q13) */
*y = round_fx( L_tmp ); /* Q25 to Q9 */
- L_tmp2 = L_mult( *y, *y ); /* Q19 = L_mult(Q9,Q9) */
+ move16();
+ L_tmp2 = L_mult( *y, *y ); /* Q19 = L_mult(Q9,Q9) */
y++;
L_tmp = L_msu( 0, Aq[1], y[-1] ); /* Q23 = L_mult(Q14,Q9) */
L_tmp = L_shl( L_tmp, q );
- *y = round_fx( L_tmp ); /* Q25 to Q9 */
+ *y = round_fx( L_tmp ); /* Q25 to Q9 */
+ move16();
L_tmp2 = L_mac( L_tmp2, *y, *y ); /* Q19 = L_mult(Q9,Q9) */
y++;
@@ -124,6 +127,7 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3
#ifdef BASOP_NOGLOB
L_tmp = L_shl_o( L_tmp, q, &Overflow );
*y = round_fx_o( L_tmp, &Overflow );
+ move16();
L_tmp2 = L_mac_o( L_tmp2, *y, *y, &Overflow );
#else
L_tmp = L_shl( L_tmp, q );
@@ -148,6 +152,7 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3
#ifdef BASOP_NOGLOB
L_tmp = L_shl_o( L_tmp, q, &Overflow );
*y = round_fx_o( L_tmp, &Overflow );
+ move16();
L_tmp2 = L_mac_o( L_tmp2, *y, *y, &Overflow );
#else
L_tmp = L_shl( L_tmp, q );
@@ -158,6 +163,7 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3
}
#ifdef BASOP_NOGLOB
*Overflow_out = Overflow;
+ move32();
return round_fx_o( L_tmp2, Overflow_out ); /* Q19 to Q3 */
#else
return round_fx( L_tmp2 ); /* Q19 to Q3 */
@@ -170,6 +176,7 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3
)
{
Flag Overflow = 0;
+ move32();
return Enr_1_Az_fx_o( Aq, len, &Overflow );
}
#endif
diff --git a/lib_com/env_adj.c b/lib_com/env_adj.c
index e6b6e57bda0551278d00b145b039e555336d267e..39e29e8fa48f220f9b788726f50ed7fb175d300a 100644
--- a/lib_com/env_adj.c
+++ b/lib_com/env_adj.c
@@ -40,8 +40,7 @@
#include "rom_com.h"
#include "prot.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*--------------------------------------------------------------------------*
* env_adj()
@@ -259,7 +258,8 @@ void env_adj_fx(
}
ELSE
{
- adj[i] = MAX_16; /* Q15, 1.0f (saturated) */
+ adj[i] = MAX_16; /* Q15, 1.0f (saturated) */
+ move16();
IF( EQ_16( att_state, 1 ) ) /* End of attenuation region found */
{
/* tmp = min(1, max(0, len-ENV_ADJ_START)*(1.0f/ENV_ADJ_INCL)); */
@@ -269,7 +269,6 @@ void env_adj_fx(
tmp = round_fx( L_shl( L_mult0( s_max( 0, sub( len, ENV_ADJ_START_FX ) ), ENV_ADJ_INV_INCL_FX ), 16 ) ); /* Q15 (15+16-16) */
#endif
tmp_diff = sub( MAX_16, tmp ); /* Q15 */
- move16();
FOR( j = start; j < i; j++ )
{
/* adj[j] = max(tmp + (1-tmp)*adj[j],env_stab); */
diff --git a/lib_com/env_stab.c b/lib_com/env_stab.c
index 4140a64dc887f2dec96901aeb3b5f3468637997d..1ccdd1184a130314dc1319c5374a3265e4cc7696 100644
--- a/lib_com/env_stab.c
+++ b/lib_com/env_stab.c
@@ -43,8 +43,7 @@
#include "rom_com.h"
#include "wmc_auto.h"
#include "stl.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*--------------------------------------------------------------------------*
* Local constants
*--------------------------------------------------------------------------*/
@@ -201,6 +200,7 @@ Word16 env_stability_fx( /* in Q15 */
Word16 inv_nb_sfm;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
IF( core_switching_flag )
@@ -377,6 +377,7 @@ Word16 env_stab_smo_fx( /* Q0 */
Word16 tmp, sum, exp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* get previous state */
prev_state = maximum_fx( env_stab_state_p, NUM_ENV_STAB_PLC_STATES, &maxval );
@@ -415,8 +416,10 @@ Word16 env_stab_smo_fx( /* Q0 */
{
#ifdef BASOP_NOGLOB
env_stab_state_p[i] = round_fx_o( L_shl_o( L_mult_o( env_stab_state_p[i], tmp, &Overflow ), add( exp, 1 ), &Overflow ), &Overflow ); /* Q15 */
+ move16();
#else
env_stab_state_p[i] = round_fx( L_shl( L_mult( env_stab_state_p[i], tmp ), add( exp, 1 ) ) ); /* Q15 */
+ move16();
#endif
}
diff --git a/lib_com/env_stab_trans.c b/lib_com/env_stab_trans.c
index 2062f4e77d23726ff2c2eed0a5e06003414e51a5..1d1ccff3245ffa8af2fafeacd023e534bc00f356 100644
--- a/lib_com/env_stab_trans.c
+++ b/lib_com/env_stab_trans.c
@@ -41,8 +41,7 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*--------------------------------------------------------------------------*
* env_stab_transient_detect()
*
@@ -231,6 +230,7 @@ void env_stab_transient_detect_fx(
FOR( blk = 0; blk < NUM_SUBFRAMES; blk++ )
{
L_E_sub[blk] = L_deposit_l( 0 ); /* Q9 */
+ move32();
FOR( i = 0; i < BANDS_PER_SUBFRAMES; i++ ) /* 9 times -> < 2^4 */
{
@@ -291,7 +291,7 @@ void env_stab_transient_detect_fx(
*no_att_hangover = ATT_LIM_HANGOVER;
move16();
}
- ELSE if ( *no_att_hangover > 0 )
+ ELSE IF( *no_att_hangover > 0 )
{
*no_att_hangover = sub( *no_att_hangover, 1 );
move16();
diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c
index c556536e4e0489e29be1217cab38950cf60c72d5..6f541c11f3f459016f3637e2d699e7902e8906fe 100644
--- a/lib_com/est_tilt_fx.c
+++ b/lib_com/est_tilt_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
#include "stl.h"
#include "basop_util.h"
diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c
index 5e0ec84eda15b64c72f2fb6f354dc58800bfb16c..bf501e2f76646fa550558ef7583a1f3f5103b295 100644
--- a/lib_com/fd_cng_com.c
+++ b/lib_com/fd_cng_com.c
@@ -39,7 +39,7 @@
#include "options.h"
#include
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
@@ -957,60 +957,66 @@ void SynthesisSTFT_flt(
void SynthesisSTFT_fx(
Word32 *fftBuffer, /* i : FFT bins */
- Word16 Q_in,
Word32 *timeDomainOutput,
Word32 *olapBuffer,
const Word16 *olapWin,
- const int16_t tcx_transition,
+ const Word16 tcx_transition,
HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- const int16_t element_mode, /* i : element mode */
- const int16_t nchan_out /* i : number of output channels */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 nchan_out /* i : number of output channels */
)
{
- int16_t i;
+ Word16 i;
Word32 buf_fx[M + 1 + 320], tmp_fx;
/* Perform IFFT */
RFFTN_fx( fftBuffer, hFdCngCom->fftSineTab_fx, hFdCngCom->fftlen, 1 );
/* Handle overlap in P/S domain for stereo */
- IF( ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT ) && nchan_out == 2 )
+ test();
+ test();
+ IF( ( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_DFT ) ) && EQ_16( nchan_out, 2 ) )
{
- mvl2l( olapBuffer + 3 * hFdCngCom->frameSize / 4 - ( M + 1 ), buf_fx, hFdCngCom->frameSize + M + 1 );
- set_l( olapBuffer, 0, hFdCngCom->fftlen );
+ Copy32( olapBuffer + sub( i_mult( 3, shr( hFdCngCom->frameSize, 2 ) ), ( M + 1 ) ), buf_fx, add( hFdCngCom->frameSize, M + 1 ) );
+ set32_fx( olapBuffer, 0, hFdCngCom->fftlen );
}
ELSE
{
- mvl2l( olapBuffer + hFdCngCom->frameSize, olapBuffer, hFdCngCom->frameSize );
- set_l( olapBuffer + hFdCngCom->frameSize, 0, hFdCngCom->frameSize ); /*olapBuffer, fftBuffer, olapWin*/
+ Copy32( olapBuffer + hFdCngCom->frameSize, olapBuffer, hFdCngCom->frameSize );
+ set32_fx( olapBuffer + hFdCngCom->frameSize, 0, hFdCngCom->frameSize ); /*olapBuffer, fftBuffer, olapWin*/
}
IF( tcx_transition )
{
- FOR( i = 0; i < 5 * hFdCngCom->frameSize / 4; i++ )
+ FOR( i = 0; i < i_mult( 5, shr( hFdCngCom->frameSize, 2 ) ); i++ )
{
olapBuffer[i] = fftBuffer[i];
+ move32();
}
}
ELSE
{
- FOR( i = hFdCngCom->frameSize / 4; i < 3 * hFdCngCom->frameSize / 4; i++ )
+ FOR( i = hFdCngCom->frameSize / 4; i < i_mult( 3, shr( hFdCngCom->frameSize, 2 ) ); i++ )
{
- olapBuffer[i] = L_add( olapBuffer[i], Mpy_32_16_1( fftBuffer[i], olapWin[i - hFdCngCom->frameSize / 4] ) );
+ olapBuffer[i] = L_add( olapBuffer[i], Mpy_32_16_1( fftBuffer[i], olapWin[sub( i, shr( hFdCngCom->frameSize, 2 ) )] ) );
+ move32();
}
- FOR( ; i < 5 * hFdCngCom->frameSize / 4; i++ )
+ FOR( ; i < i_mult( 5, shr( hFdCngCom->frameSize, 2 ) ); i++ )
{
olapBuffer[i] = fftBuffer[i];
+ move32();
}
}
- FOR( ; i < 7 * hFdCngCom->frameSize / 4; i++ )
+ FOR( ; i < i_mult( 7, shr( hFdCngCom->frameSize, 2 ) ); i++ )
{
- olapBuffer[i] = Mpy_32_16_1( fftBuffer[i], olapWin[i - 3 * hFdCngCom->frameSize / 4] );
+ olapBuffer[i] = Mpy_32_16_1( fftBuffer[i], olapWin[sub( i, i_mult( 3, shr( hFdCngCom->frameSize, 2 ) ) )] );
+ move32();
}
FOR( ; i < hFdCngCom->fftlen; i++ )
{
olapBuffer[i] = 0;
+ move32();
}
Word32 fftScale = 0;
@@ -1018,44 +1024,50 @@ void SynthesisSTFT_fx(
{
case 640:
fftScale = FFT_SCALING_640;
- break;
+ move32();
+ BREAK;
case 512:
fftScale = FFT_SCALING_512;
- break;
+ move32();
+ BREAK;
default:
assert( !"Not supported FFT length!" );
}
/* Get time-domain signal */
// v_multc(olapBuffer + hFdCngCom->frameSize / 4, (float)(hFdCngCom->fftlen / 2), timeDomainOutput, hFdCngCom->frameSize);
v_multc_fixed( olapBuffer + hFdCngCom->frameSize / 4, fftScale, timeDomainOutput, hFdCngCom->frameSize ); // Q_in - 9
- /* Get excitation */
- IF( ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT ) && nchan_out == 2 )
+ /* Get excitation */
+ test();
+ test();
+ IF( ( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_DFT ) ) && EQ_16( nchan_out, 2 ) )
{
FOR( i = 0; i < hFdCngCom->frameSize / 2; i++ )
{
- buf_fx[i + ( M + 1 )] = L_add( buf_fx[i + ( M + 1 )], olapBuffer[i + hFdCngCom->frameSize / 4] );
+ buf_fx[i + ( M + 1 )] = L_add( buf_fx[i + ( M + 1 )], olapBuffer[add( i, shr( hFdCngCom->frameSize, 2 ) )] );
+ move32();
}
// v_multc(buf, (float)(hFdCngCom->fftlen / 2), buf, M + 1 + hFdCngCom->frameSize);
- v_multc_fixed( buf_fx, fftScale, buf_fx, M + 1 + hFdCngCom->frameSize );
+ v_multc_fixed( buf_fx, fftScale, buf_fx, add( M + 1, hFdCngCom->frameSize ) );
}
ELSE
{
// v_multc(olapBuffer + hFdCngCom->frameSize / 4 - (M + 1), (float)(hFdCngCom->fftlen / 2), buf, M + 1 + hFdCngCom->frameSize);
- v_multc_fixed( olapBuffer + ( hFdCngCom->frameSize / 4 ) - ( M + 1 ), fftScale, buf_fx, M + 1 + hFdCngCom->frameSize );
+ v_multc_fixed( olapBuffer + sub( shr( hFdCngCom->frameSize, 2 ), ( M + 1 ) ), fftScale, buf_fx, add( M + 1, hFdCngCom->frameSize ) );
}
tmp_fx = buf_fx[0];
+ move32();
// preemph(buf + 1, PREEMPH_FAC_FLT, M + hFdCngCom->frameSize, &tmp);
- preemph_ivas_fx( buf_fx + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp_fx );
+ preemph_ivas_fx( buf_fx + 1, PREEMPH_FAC, add( M, hFdCngCom->frameSize ), &tmp_fx );
// residu(hFdCngCom->A_cng_flt, M, buf + 1 + M, hFdCngCom->exc_cng_flt, hFdCngCom->frameSize);
// floatToFixed_arr( hFdCngCom->A_cng_flt, hFdCngCom->A_cng, Q13, M + 1 );
// residu_ivas_fx( hFdCngCom->A_cng, Q13, M, buf_fx + 1 + M, hFdCngCom->exc_cng_32fx, hFdCngCom->frameSize );
residu_ivas_fx( hFdCngCom->A_cng, ( 15 - norm_s( hFdCngCom->A_cng[0] - 1 ) ), M, buf_fx + 1 + M, hFdCngCom->exc_cng_32fx, hFdCngCom->frameSize );
- for ( i = 0; i < hFdCngCom->frameSize; i++ )
- {
- hFdCngCom->exc_cng_flt[i] = fix_to_float( hFdCngCom->exc_cng_32fx[i], Q_in - 9 );
- }
+ // for ( i = 0; i < hFdCngCom->frameSize; i++ )
+ //{
+ // hFdCngCom->exc_cng_flt[i] = fix_to_float( hFdCngCom->exc_cng_32fx[i], Q_in - 9 );
+ // }
return;
}
@@ -1149,7 +1161,8 @@ void SynthesisSTFT_dirac_fx(
FOR( i = shr( hFdCngCom->frameSize, 2 ); i < i_mult( 3, shr( hFdCngCom->frameSize, 2 ) ); i++ )
{
- olapBuffer[i] = L_add( olapBuffer[i], Mpy_32_16_1( fftBuffer[i], olapWin[i - hFdCngCom->frameSize / 4] ) );
+ olapBuffer[i] = L_add( olapBuffer[i], Mpy_32_16_1( fftBuffer[i], olapWin[sub( i, shr( hFdCngCom->frameSize, 2 ) )] ) );
+ move32();
}
FOR( ; i < i_mult( 5, shr( hFdCngCom->frameSize, 2 ) ); i++ )
{
@@ -1186,14 +1199,15 @@ void SynthesisSTFT_dirac_fx(
}
/* Get time-domain signal */
- v_multc_fixed( olapBuffer + hFdCngCom->frameSize / 4, fftScale, timeDomainOutput, samples_out ); // Q_in - 9
+ v_multc_fixed( olapBuffer + shr( hFdCngCom->frameSize, 2 ), fftScale, timeDomainOutput, samples_out ); // Q_in - 9
/* Get excitation */
- v_multc_fixed( olapBuffer + ( hFdCngCom->frameSize / 4 ) - ( M + 1 ), fftScale, buf, M + 1 + hFdCngCom->frameSize );
+ v_multc_fixed( olapBuffer + sub( shr( hFdCngCom->frameSize, 2 ), ( M + 1 ) ), fftScale, buf, add( M + 1, hFdCngCom->frameSize ) );
tmp = buf[0];
+ move32();
preemph_ivas_fx( buf + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp );
// residu_ivas_fx( hFdCngCom->A_cng, Q13, M, buf + 1 + M, hFdCngCom->exc_cng_32fx, hFdCngCom->frameSize );
- residu_ivas_fx( hFdCngCom->A_cng, 15 - norm_s( hFdCngCom->A_cng[0] - 1 ), M, buf + 1 + M, hFdCngCom->exc_cng_32fx, hFdCngCom->frameSize );
+ residu_ivas_fx( hFdCngCom->A_cng, sub( 15, norm_s( hFdCngCom->A_cng[0] - 1 ) ), M, buf + 1 + M, hFdCngCom->exc_cng_32fx, hFdCngCom->frameSize );
/* update and window olapBuf if we have a output frame that is shorter than the default frame size...*/
IF( LT_16( samples_out, hFdCngCom->frameSize ) )
@@ -1202,7 +1216,8 @@ void SynthesisSTFT_dirac_fx(
}
FOR( i = i_mult( 5, shr( hFdCngCom->frameSize, 2 ) ); i < i_mult( 7, shr( hFdCngCom->frameSize, 2 ) ); i++ )
{
- olapBuffer[i] = Mpy_32_16_1( olapBuffer[i], olapWin[i - 3 * hFdCngCom->frameSize / 4] );
+ olapBuffer[i] = Mpy_32_16_1( olapBuffer[i], olapWin[sub( i, i_mult( 3, shr( hFdCngCom->frameSize, 2 ) ) )] );
+ move32();
}
return;
@@ -1286,9 +1301,10 @@ Word32 rand_gauss_fx(
temp = own_random( seed );
temp = L_add( temp, own_random( seed ) );
temp = L_add( temp, own_random( seed ) );
- temp = L_shr( temp, 15 - q );
+ temp = L_shr( temp, sub( 15, q ) );
*x = temp;
+ move32();
return temp;
}
@@ -1311,6 +1327,7 @@ Word16 rand_gauss_fix(
temp = L_add( temp, shr( own_random( seed ), Q2 ) );
*x = (Word16) temp;
+ move32();
return (Word16) temp;
}
diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c
index 7125ec40cc4db0d5f111f9f312b5bbfcc6f4a788..a42a85a1590b0c46fb30baff9661cb77e7d41ce8 100644
--- a/lib_com/fd_cng_com_fx.c
+++ b/lib_com/fd_cng_com_fx.c
@@ -9,8 +9,7 @@
#include "options.h"
#include "rom_basop_util.h"
#include "rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#define DELTA_SHIFT 2
@@ -395,10 +394,12 @@ void compress_range(
if ( in_s != 0 )
{
out[i] = extract_h( L_tmp );
+ move16();
}
if ( out[i] == 0 )
{
out[i] = 1;
+ move16();
}
}
}
@@ -417,10 +418,12 @@ void compress_range(
if ( in[i] != 0 )
{
out[i] = extract_h( L_tmp );
+ move16();
}
if ( out[i] == 0 )
{
out[i] = 1;
+ move16();
}
}
}
@@ -523,7 +526,7 @@ void expand_range_var_exp(
move32();
Word32 tmp_low_lim = L_shr( low_lim, maxOutExp );
- IF( LT_32( out[i], tmp_low_lim ) )
+ if ( LT_32( out[i], tmp_low_lim ) )
{
out[i] = tmp_low_lim;
move32();
@@ -603,6 +606,7 @@ void minimum_statistics(
Word16 msNoiseFloor16;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -765,7 +769,7 @@ void minimum_statistics(
FOR( j = start; j < stop; j++ )
{
- /* Compute optimal smoothing parameter for PSD estimation */ test();
+ /* Compute optimal smoothing parameter for PSD estimation */
test();
IF( ( scalar == 0 ) || ( msNoiseFloor[j] == 0 ) )
{
@@ -827,6 +831,7 @@ void minimum_statistics(
/* Compute the PSD (smoothed periodogram) in each band */
msPsd[j] = round_fx( L_add( Mpy_32_16_1( msAlpha[j], msPsd[j] ),
Mpy_32_16_1( L_sub( 2147483647l /*1.0 Q31*/, msAlpha[j] ), msPeriodog[j] ) ) );
+ move16();
}
msPsdSum[cnt] = dotp_s_fx( msPsd + start, psize + start, current_len, CNG_HS );
move32();
@@ -1077,6 +1082,7 @@ void minimum_statistics(
FOR( j = 0; j < len; j++ )
{
msCurrentMinOut[j] = L_deposit_h( msPeriodog[j] );
+ move32();
}
set32_fx( hFdCngCom->msAlphaCor, 2147483647l /*1.0 Q31*/, cnt );
set32_fx( msAlpha, 0l /*0.0 Q31*/, len );
@@ -1123,6 +1129,7 @@ void minimum_statistics(
FOR( j = 0; j < len; j++ )
{
msNoiseEst[j] = round_fx( L_mac( L_mult( 31130 /*0.95 Q15*/, msNoiseEst[j] ), 1638 /*0.05 Q15*/, msNoiseFloor[j] ) );
+ move16();
}
}
#ifdef IVAS_CODE_CNG_COM
@@ -1221,6 +1228,7 @@ void minimum_statistics_fx(
Word16 msNoiseFloor16;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -1352,8 +1360,12 @@ void minimum_statistics_fx(
scalar16 = shl( scalar16, s3 );
scalar16 = s_max( scalar16, MSALPHACORMAX );
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ hFdCngCom->msAlphaCor[cnt] = Madd_32_16( L_mult( scalar16, msAlphaCorAlpha2 ), hFdCngCom->msAlphaCor[cnt], msAlphaCorAlpha );
+#else
hFdCngCom->msAlphaCor[cnt] = L_add( Mpy_32_16_1( hFdCngCom->msAlphaCor[cnt], msAlphaCorAlpha ),
L_mult( scalar16, msAlphaCorAlpha2 ) );
+#endif
move32();
}
@@ -1379,7 +1391,7 @@ void minimum_statistics_fx(
FOR( j = start; j < stop; j++ )
{
- /* Compute optimal smoothing parameter for PSD estimation */ test();
+ /* Compute optimal smoothing parameter for PSD estimation */
test();
IF( ( scalar == 0 ) || ( msNoiseFloor[j] == 0 ) )
{
@@ -1439,8 +1451,13 @@ void minimum_statistics_fx(
}
/* Compute the PSD (smoothed periodogram) in each band */
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ msPsd[j] = round_fx( Madd_32_16( Mpy_32_16_1( msAlpha[j], msPsd[j] ), L_sub( 2147483647l /*1.0 Q31*/, msAlpha[j] ), msPeriodog[j] ) );
+#else
msPsd[j] = round_fx( L_add( Mpy_32_16_1( msAlpha[j], msPsd[j] ),
Mpy_32_16_1( L_sub( 2147483647l /*1.0 Q31*/, msAlpha[j] ), msPeriodog[j] ) ) );
+#endif
+ move16();
}
msPsdSum[cnt] = dotp_s_fx( msPsd + start, psize + start, current_len, CNG_HS );
move32();
@@ -1518,13 +1535,21 @@ void minimum_statistics_fx(
/* Compute bias correction Bmin */
tmp0 = Mpy_32_16_1( scalar, QeqInv );
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ tmp1 = L_msu( 1073741824l /*0.5 Q31*/, msM_win, QeqInv );
+#else
tmp1 = L_sub( 1073741824l /*0.5 Q31*/, L_mult( msM_win, QeqInv ) );
+#endif
tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( tmp0, tmp1, &s );
msBminWin[j] = L_add( 134217728l /*1.0 Q27*/, L_shl( L_deposit_h( tmp16 ), add( s, 7 - 4 ) ) );
move32();
tmp0 = Mpy_32_16_1( scalar2, QeqInv );
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ tmp1 = L_msu( 1073741824l /*0.5 Q31*/, msM_subwin, QeqInv );
+#else
tmp1 = L_sub( 1073741824l /*0.5 Q31*/, L_mult( msM_subwin, QeqInv ) );
+#endif
tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( tmp0, tmp1, &s );
msBminSubWin[j] = L_add( 134217728l /*1.0 Q27*/, L_shl( L_deposit_h( tmp16 ), s ) );
move32();
@@ -1691,6 +1716,7 @@ void minimum_statistics_fx(
FOR( j = 0; j < len; j++ )
{
msCurrentMinOut[j] = L_deposit_h( msPeriodog[j] );
+ move32();
}
set32_fx( hFdCngCom->msAlphaCor, 2147483647l /*1.0 Q31*/, cnt );
set32_fx( msAlpha, 0l /*0.0 Q31*/, len );
@@ -1731,12 +1757,14 @@ void minimum_statistics_fx(
ELSE
{
hFdCngCom->msFrCnt = add( hFdCngCom->msFrCnt, 1 );
+ move16();
}
/* Smooth noise estimate during CNG phases */
FOR( j = 0; j < len; j++ )
{
msNoiseEst[j] = round_fx( L_mac( L_mult( 31130 /*0.95 Q15*/, msNoiseEst[j] ), 1638 /*0.05 Q15*/, msNoiseFloor[j] ) );
+ move16();
}
}
if ( enc_dec == DEC && element_mode == IVAS_CPE_TD )
@@ -1804,6 +1832,7 @@ void apply_scale(
{
*scale = L_add( *scale, L_deposit_h( scaleTable[i].scale ) );
+ move32();
}
}
@@ -1837,6 +1866,7 @@ Word16 apply_scale_ind(
{
*scale = L_add( *scale, L_deposit_h( scaleTable[i].scale ) );
+ move32();
}
return i;
}
@@ -1864,7 +1894,9 @@ void apply_scale_ivas_fx(
assert( i < scaleTableSize );
*scale = L_add( *scale, L_deposit_h( scaleTable[i].scale ) );
+ move32();
*index = i;
+ move16();
}
#endif // IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------
@@ -1961,6 +1993,7 @@ void scalebands(
delta = 0;
move16();
partpowLD64M1 = 0L; /* to avoid compilation warnings */
+ move32();
/* Interpolate the bin/band-wise levels from the partition levels */
IF( EQ_16( nband, npart ) )
@@ -2102,6 +2135,7 @@ void scalebands_fx(
delta = 0;
move16();
partpowLD64M1 = 0L; /* to avoid compilation warnings */
+ move32();
/* Interpolate the bin/band-wise levels from the partition levels */
IF( EQ_16( nband, npart ) )
@@ -2155,7 +2189,14 @@ void scalebands_fx(
nint = sub( midband[j], midband[j - 1] );
/* log-linear interpolation */
- partpowLD64 = BASOP_Util_Log2( L_add( partpow[j], DELTA_FX ) );
+ IF( NE_32( partpow[j], MAX_32 ) )
+ {
+ partpowLD64 = BASOP_Util_Log2( L_add( partpow[j], DELTA_FX ) );
+ }
+ ELSE
+ {
+ partpowLD64 = BASOP_Util_Log2( partpow[j] );
+ }
tmp = L_sub( partpowLD64, partpowLD64M1 );
tmp = Mpy_32_16_1( tmp, getNormReciprocalWord16( nint ) );
@@ -2208,7 +2249,21 @@ void scalebands_fx(
move32();
FOR( ; i <= part[stopPartM1]; i++ )
{
- val = L_shl( Mpy_32_16_1( val, delta ), s1 );
+ test();
+ IF( val != 0 && delta != 0 )
+ {
+ val = L_shl( Mpy_32_16_1( val, delta ), s1 );
+ IF( val == 0 )
+ {
+ val = 1;
+ move32();
+ }
+ }
+ ELSE
+ {
+ val = 0;
+ move32();
+ }
bandpow[i] = val;
move32();
}
@@ -2241,6 +2296,7 @@ static void getmidbands(
Word16 j, max_psize, shift;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -2248,6 +2304,7 @@ static void getmidbands(
move16();
/* first half partition */ move16();
midband[0] = part[0];
+ move16();
psize[0] = add( part[0], 1 );
move16();
psize_inv[0] = getNormReciprocalWord16( psize[0] );
@@ -2401,8 +2458,10 @@ void AnalysisSTFT_fx(
FOR( i = 0; i < hFdCngCom->fftlen; i++ )
{
fftBuffer[i] = L_shr( fftBuffer[i], 11 );
+ move32();
}
*fftBuffer_exp = WORD16_BITS + 11;
+ move16();
/* Perform FFT */
RFFTN_fx( fftBuffer, hFdCngCom->fftSineTab_fx, hFdCngCom->fftlen, -1 );
@@ -2439,9 +2498,11 @@ void SynthesisSTFT(
/* Perform IFFT */
scale = 0;
+ move16();
BASOP_rfft( fftBuffer, hFdCngCom->fftlen, &scale, 1 );
fftBufferExp = add( fftBufferExp, scale );
hFdCngCom->fftBuffer_exp = fftBufferExp;
+ move16();
fftBufferExp = add( fftBufferExp, hFdCngCom->fftlenShift );
@@ -2465,16 +2526,17 @@ void SynthesisSTFT(
{
FOR( i = 0; i < len; i++ )
{
- olapBuffer[i] = round_fx( L_shl( fftBuffer[i], fftBufferExp - 15 ) );
+ olapBuffer[i] = round_fx_sat( L_shl_sat( fftBuffer[i], fftBufferExp - 15 ) );
+ move16();
}
}
ELSE
{
FOR( i = 0; i < len4; i++ )
{
- olapBuffer[i + 1 * len4] = add_sat( olapBuffer[i + 1 * len4], mult_r( round_fx( L_shl( fftBuffer[i + 1 * len4], fftBufferExp - 15 ) ), olapWin[i].v.im ) );
+ olapBuffer[i + 1 * len4] = add_sat( olapBuffer[i + 1 * len4], mult_r( round_fx_sat( L_shl_sat( fftBuffer[i + 1 * len4], fftBufferExp - 15 ) ), olapWin[i].v.im ) );
move16();
- olapBuffer[i + 2 * len4] = add_sat( olapBuffer[i + 2 * len4], mult_r( round_fx( L_shl( fftBuffer[i + 2 * len4], fftBufferExp - 15 ) ), olapWin[len4 - 1 - i].v.re ) );
+ olapBuffer[i + 2 * len4] = add_sat( olapBuffer[i + 2 * len4], mult_r( round_fx_sat( L_shl_sat( fftBuffer[i + 2 * len4], fftBufferExp - 15 ) ), olapWin[len4 - 1 - i].v.re ) );
move16();
}
FOR( i = len3; i < len; i++ )
@@ -2485,9 +2547,9 @@ void SynthesisSTFT(
FOR( i = 0; i < len4; i++ )
{
- olapBuffer[i + 5 * len4] = mult_r( round_fx( L_shl( fftBuffer[i + 5 * len4], fftBufferExp - 15 ) ), olapWin[i].v.re );
+ olapBuffer[i + 5 * len4] = mult_r( round_fx_sat( L_shl_sat( fftBuffer[i + 5 * len4], fftBufferExp - 15 ) ), olapWin[i].v.re );
move16();
- olapBuffer[i + 6 * len4] = mult_r( round_fx( L_shl( fftBuffer[i + 6 * len4], fftBufferExp - 15 ) ), olapWin[len4 - 1 - i].v.im );
+ olapBuffer[i + 6 * len4] = mult_r( round_fx_sat( L_shl_sat( fftBuffer[i + 6 * len4], fftBufferExp - 15 ) ), olapWin[len4 - 1 - i].v.im );
move16();
}
@@ -2685,6 +2747,7 @@ void mhvals(
tmp2_m = BASOP_Util_Add_Mant32Exp( tmp2_m, tmp2_e, L_deposit_h( m_array[i] ), 0, &tmp2_e );
assert( tmp2_e == 0 );
*m = extract_h( tmp2_m );
+ move32();
}
}
@@ -2735,9 +2798,12 @@ void lpc_from_spectrum(
Word32 *powspec = hFdCngCom->cngNoiseLevel; /*i : pointer to noise levels format Q5.27*/
Word16 powspec_exp = hFdCngCom->cngNoiseLevelExp;
+ move16();
Word16 fftlen = hFdCngCom->fftlen; /*i : size of fft*/
Word16 *A = hFdCngCom->A_cng; /*o : lpc coefficients format Q3.12*/
+ move16();
Word16 lpcorder = M;
+ move16();
scale = 0;
move16();
@@ -2767,6 +2833,7 @@ void lpc_from_spectrum(
*ptr = nf;
move32();
*pti = L_deposit_l( 0 );
+ move32();
ptr += 2;
pti += 2;
}
@@ -2776,6 +2843,7 @@ void lpc_from_spectrum(
*ptr = L_max( nf, L_shl( powspec[i - start], s1 ) );
move32();
*pti = L_deposit_l( 0 );
+ move32();
ptr += 2;
pti += 2;
}
@@ -2785,6 +2853,7 @@ void lpc_from_spectrum(
*ptr = nf;
move32();
*pti = L_deposit_l( 0 );
+ move32();
ptr += 2;
pti += 2;
}
@@ -2960,6 +3029,7 @@ void FdCng_exc(
Word16 i;
*CNG_mode = -1;
+ move16();
FOR( i = 0; i < L_frame / L_SUBFR; i++ )
{
diff --git a/lib_com/fft.c b/lib_com/fft.c
index 75f54e2c3687db9e255cced18cc3969259efab4a..c40556298afc72ef798433d84e7caf51de974910 100644
--- a/lib_com/fft.c
+++ b/lib_com/fft.c
@@ -6513,21 +6513,21 @@ static void BASOP_fft8(
move32();
im[s * 6] = L_add( s05, s07 );
move32();
- re[s * 3] = L_add( s08, s14 );
+ re[i_mult( s, 3 )] = L_add( s08, s14 );
move32();
- re[s * 7] = L_sub( s08, s14 );
+ re[i_mult( s, 7 )] = L_sub( s08, s14 );
move32();
- im[s * 3] = L_add( s09, s15 );
+ im[i_mult( s, 3 )] = L_add( s09, s15 );
move32();
- im[s * 7] = L_sub( s09, s15 );
+ im[i_mult( s, 7 )] = L_sub( s09, s15 );
move32();
re[s * 1] = L_add( s10, s12 );
move32();
- re[s * 5] = L_sub( s10, s12 );
+ re[i_mult( s, 5 )] = L_sub( s10, s12 );
move32();
im[s * 1] = L_add( s11, s13 );
move32();
- im[s * 5] = L_sub( s11, s13 );
+ im[i_mult( s, 5 )] = L_sub( s11, s13 );
move32();
return;
@@ -6581,23 +6581,23 @@ static void BASOP_fftN2(
IF( i == 0 )
{
- cplxMpy4_8_1( x02, x03, x[2 * i + 2 * 1 * dim1], x[2 * i + 2 * 1 * dim1 + 1] );
- cplxMpy4_8_1( x04, x05, x[2 * i + 2 * 2 * dim1], x[2 * i + 2 * 2 * dim1 + 1] );
- cplxMpy4_8_1( x06, x07, x[2 * i + 2 * 3 * dim1], x[2 * i + 2 * 3 * dim1 + 1] );
- cplxMpy4_8_1( x08, x09, x[2 * i + 2 * 4 * dim1], x[2 * i + 2 * 4 * dim1 + 1] );
- cplxMpy4_8_1( x10, x11, x[2 * i + 2 * 5 * dim1], x[2 * i + 2 * 5 * dim1 + 1] );
- cplxMpy4_8_1( x12, x13, x[2 * i + 2 * 6 * dim1], x[2 * i + 2 * 6 * dim1 + 1] );
- cplxMpy4_8_1( x14, x15, x[2 * i + 2 * 7 * dim1], x[2 * i + 2 * 7 * dim1 + 1] );
+ cplxMpy4_8_1( x02, x03, x[add( shl( i, 1 ), i_mult( 2 * 1, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 1, dim1 ) ), 1 )] );
+ cplxMpy4_8_1( x04, x05, x[add( shl( i, 1 ), i_mult( 2 * 2, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 2, dim1 ) ), 1 )] );
+ cplxMpy4_8_1( x06, x07, x[add( shl( i, 1 ), i_mult( 2 * 3, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 3, dim1 ) ), 1 )] );
+ cplxMpy4_8_1( x08, x09, x[add( shl( i, 1 ), i_mult( 2 * 4, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 4, dim1 ) ), 1 )] );
+ cplxMpy4_8_1( x10, x11, x[add( shl( i, 1 ), i_mult( 2 * 5, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 5, dim1 ) ), 1 )] );
+ cplxMpy4_8_1( x12, x13, x[add( shl( i, 1 ), i_mult( 2 * 6, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 6, dim1 ) ), 1 )] );
+ cplxMpy4_8_1( x14, x15, x[add( shl( i, 1 ), i_mult( 2 * 7, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 7, dim1 ) ), 1 )] );
}
ELSE
{
- cplxMpy4_8_0( x02, x03, x[2 * i + 2 * 1 * dim1], x[2 * i + 2 * 1 * dim1 + 1], W[sc * i + sc * 1 * dim1 - Woff], W[sc * i + sc * 1 * dim1 + 1 - Woff] );
- cplxMpy4_8_0( x04, x05, x[2 * i + 2 * 2 * dim1], x[2 * i + 2 * 2 * dim1 + 1], W[sc * i + sc * 2 * dim1 - Woff], W[sc * i + sc * 2 * dim1 + 1 - Woff] );
- cplxMpy4_8_0( x06, x07, x[2 * i + 2 * 3 * dim1], x[2 * i + 2 * 3 * dim1 + 1], W[sc * i + sc * 3 * dim1 - Woff], W[sc * i + sc * 3 * dim1 + 1 - Woff] );
- cplxMpy4_8_0( x08, x09, x[2 * i + 2 * 4 * dim1], x[2 * i + 2 * 4 * dim1 + 1], W[sc * i + sc * 4 * dim1 - Woff], W[sc * i + sc * 4 * dim1 + 1 - Woff] );
- cplxMpy4_8_0( x10, x11, x[2 * i + 2 * 5 * dim1], x[2 * i + 2 * 5 * dim1 + 1], W[sc * i + sc * 5 * dim1 - Woff], W[sc * i + sc * 5 * dim1 + 1 - Woff] );
- cplxMpy4_8_0( x12, x13, x[2 * i + 2 * 6 * dim1], x[2 * i + 2 * 6 * dim1 + 1], W[sc * i + sc * 6 * dim1 - Woff], W[sc * i + sc * 6 * dim1 + 1 - Woff] );
- cplxMpy4_8_0( x14, x15, x[2 * i + 2 * 7 * dim1], x[2 * i + 2 * 7 * dim1 + 1], W[sc * i + sc * 7 * dim1 - Woff], W[sc * i + sc * 7 * dim1 + 1 - Woff] );
+ cplxMpy4_8_0( x02, x03, x[add( shl( i, 1 ), i_mult( 2 * 1, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 1, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 1, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 1, dim1 ) ) ), 1 ), Woff )] );
+ cplxMpy4_8_0( x04, x05, x[add( shl( i, 1 ), i_mult( 2 * 2, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 2, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 2, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 2, dim1 ) ) ), 1 ), Woff )] );
+ cplxMpy4_8_0( x06, x07, x[add( shl( i, 1 ), i_mult( 2 * 3, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 3, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 3, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 3, dim1 ) ) ), 1 ), Woff )] );
+ cplxMpy4_8_0( x08, x09, x[add( shl( i, 1 ), i_mult( 2 * 4, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 4, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 4, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 4, dim1 ) ) ), 1 ), Woff )] );
+ cplxMpy4_8_0( x10, x11, x[add( shl( i, 1 ), i_mult( 2 * 5, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 5, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 5, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 5, dim1 ) ) ), 1 ), Woff )] );
+ cplxMpy4_8_0( x12, x13, x[add( shl( i, 1 ), i_mult( 2 * 6, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 6, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 6, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 6, dim1 ) ) ), 1 ), Woff )] );
+ cplxMpy4_8_0( x14, x15, x[add( shl( i, 1 ), i_mult( 2 * 7, dim1 ) )], x[add( add( shl( i, 1 ), i_mult( 2 * 7, dim1 ) ), 1 )], W[sub( add( i_mult( sc, i ), i_mult( sc, i_mult( 7, dim1 ) ) ), Woff )], W[sub( add( add( i_mult( sc, i ), i_mult( sc, i_mult( 7, dim1 ) ) ), 1 ), Woff )] );
}
t00 = L_shr( L_add( x00, x08 ), SCALEFACTORN2 - 1 );
t02 = L_shr( L_sub( x00, x08 ), SCALEFACTORN2 - 1 );
@@ -6639,37 +6639,37 @@ static void BASOP_fftN2(
s13 = Mpy_32_16_1( L_sub( t03, t01 ), C81_FX );
s15 = Mpy_32_16_1( L_add( t01, t03 ), C82_FX );
- re[sx * i + sx * 0 * dim1] = L_add( s00, s02 );
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 0, dim1 ) ) )] = L_add( s00, s02 );
move32();
- im[sx * i + sx * 0 * dim1] = L_add( s01, s03 );
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 0, dim1 ) ) )] = L_add( s01, s03 );
move32();
- re[sx * i + sx * 1 * dim1] = L_add( s10, s12 );
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 1, dim1 ) ) )] = L_add( s10, s12 );
move32();
- im[sx * i + sx * 1 * dim1] = L_add( s11, s13 );
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 1, dim1 ) ) )] = L_add( s11, s13 );
move32();
- re[sx * i + sx * 2 * dim1] = L_sub( s04, s06 );
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 2, dim1 ) ) )] = L_sub( s04, s06 );
move32();
- im[sx * i + sx * 2 * dim1] = L_sub( s05, s07 );
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 2, dim1 ) ) )] = L_sub( s05, s07 );
move32();
- re[sx * i + sx * 3 * dim1] = L_add( s08, s14 );
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 3, dim1 ) ) )] = L_add( s08, s14 );
move32();
- im[sx * i + sx * 3 * dim1] = L_add( s09, s15 );
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 3, dim1 ) ) )] = L_add( s09, s15 );
move32();
- re[sx * i + sx * 4 * dim1] = L_sub( s00, s02 );
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 4, dim1 ) ) )] = L_sub( s00, s02 );
move32();
- im[sx * i + sx * 4 * dim1] = L_sub( s01, s03 );
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 4, dim1 ) ) )] = L_sub( s01, s03 );
move32();
- re[sx * i + sx * 5 * dim1] = L_sub( s10, s12 );
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 5, dim1 ) ) )] = L_sub( s10, s12 );
move32();
- im[sx * i + sx * 5 * dim1] = L_sub( s11, s13 );
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 5, dim1 ) ) )] = L_sub( s11, s13 );
move32();
- re[sx * i + sx * 6 * dim1] = L_add( s04, s06 );
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 6, dim1 ) ) )] = L_add( s04, s06 );
move32();
- im[sx * i + sx * 6 * dim1] = L_add( s05, s07 );
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 6, dim1 ) ) )] = L_add( s05, s07 );
move32();
- re[sx * i + sx * 7 * dim1] = L_sub( s08, s14 );
+ re[add( i_mult( sx, i ), i_mult( sx, i_mult( 7, dim1 ) ) )] = L_sub( s08, s14 );
move32();
- im[sx * i + sx * 7 * dim1] = L_sub( s09, s15 );
+ im[add( i_mult( sx, i ), i_mult( sx, i_mult( 7, dim1 ) ) )] = L_sub( s09, s15 );
move32();
}
diff --git a/lib_com/fft_cldfb_fx.c b/lib_com/fft_cldfb_fx.c
index 6271eea2662614b131ec35080de00a1ac8f7aa99..d60a285f5561ca43ee3b695f4fa7af6ed3bc5633 100644
--- a/lib_com/fft_cldfb_fx.c
+++ b/lib_com/fft_cldfb_fx.c
@@ -37,7 +37,7 @@
#include
#include "options.h"
#include
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_cnst.h"
#include "wmc_auto.h"
#include "basop_util.h"
diff --git a/lib_com/fft_evs.c b/lib_com/fft_evs.c
index 9f98faaa4f77b3e92d0d503dc6c8114cd36190f5..56b735804472042cf19e8d6f9dd97bfa78533dbb 100644
--- a/lib_com/fft_evs.c
+++ b/lib_com/fft_evs.c
@@ -3,8 +3,7 @@
====================================================================================*/
#include
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "rom_basop_util.h"
#include "rom_com.h"
@@ -555,12 +554,15 @@ void fft16( Word32 *re, Word32 *im, Word16 s, Word16 bScale )
FOR( i = 0; i < 16; i++ )
{
inp_data[i] = CL_form( re[s * i], im[s * i] );
+ move64();
}
fft16_with_cmplx_data( inp_data, bScale );
FOR( i = 0; i < 16; i++ )
{
re[s * i] = CL_Extract_real( inp_data[i] );
+ move32();
im[s * i] = CL_Extract_imag( inp_data[i] );
+ move32();
}
}
}
@@ -1927,6 +1929,7 @@ static void fftN2(
cmplx s0, s1, s2, s3, s4, s5, s6, s7;
i = 0;
+ move16();
{
y0 = CL_shr( x_cmplx[i + 0 * dim1], 1 );
y1 = CL_shr( x_cmplx[i + 1 * dim1], 1 );
@@ -2463,7 +2466,9 @@ void BASOP_rfft( Word32 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign )
case 320:
case 640:
c1 = FFTC( 0x66666680 );
+ move16();
c2 = FFTC( 0x99999980 );
+ move16();
FOR( i = 0; i < sizeOfFft2; i++ )
{
x[2 * i] = Mpy_32_xx( x[2 * i], c1 );
diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c
index 7a0d153eb87f1ff66635ca999d3da60f490d942a..024221ca6cffcc973588886a0ce131cdb5cce31d 100644
--- a/lib_com/fft_fx.c
+++ b/lib_com/fft_fx.c
@@ -45,8 +45,7 @@
#include
#include "cnst.h"
// #include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
//#include "cnst_fx.h"
#include "rom_com.h"
#include "rom_com_fx.h"
@@ -188,27 +187,48 @@ static void fft15_shift2(
Word32 f4o7, f4o8, f4o9, f4o10, f4o11, f4o12, f4o13, f4o14, f4o15, f4o16, f4o17, f4o18, f4o19;
in0 = Idx[0];
+ move16();
in8 = Idx[n1];
+ move16();
in16 = Idx[n1 * 2];
- in24 = Idx[n1 * 3];
+ move16();
+ in24 = Idx[i_mult( n1, 3 )];
+ move16();
in32 = Idx[n1 * 4];
- in1 = Idx[n1 * 5];
+ move16();
+ in1 = Idx[i_mult( n1, 5 )];
+ move16();
in9 = Idx[n1 * 6];
- in17 = Idx[n1 * 7];
+ move16();
+ in17 = Idx[i_mult( n1, 7 )];
+ move16();
in25 = Idx[n1 * 8];
- in33 = Idx[n1 * 9];
+ move16();
+ in33 = Idx[i_mult( n1, 9 )];
+ move16();
in2 = Idx[n1 * 10];
- in10 = Idx[n1 * 11];
+ move16();
+ in10 = Idx[i_mult( n1, 11 )];
+ move16();
in18 = Idx[n1 * 12];
- in26 = Idx[n1 * 13];
+ move16();
+ in26 = Idx[i_mult( n1, 13 )];
+ move16();
in34 = Idx[n1 * 14];
+ move16();
f2i13 = zRe[in0];
+ move32();
f2i14 = zIm[in0];
+ move32();
f2i21 = zRe[in1];
+ move32();
f2i22 = zRe[in2];
+ move32();
f2i23 = zIm[in1];
+ move32();
f2i24 = zIm[in2];
+ move32();
f2i15 = L_add( f2i21, f2i22 );
f2i16 = Mpy_32_16_1( L_sub( f2i22, f2i21 ), FFT_15PONIT_WNK4 );
@@ -225,29 +245,41 @@ static void fft15_shift2(
fi6 = L_sub( f2i20, f2i16 );
f3i1 = zRe[in9];
+ move32();
f4i2 = zRe[in10];
+ move32();
f4i3 = zRe[in8];
+ move32();
f3i2 = L_add( f4i2, f4i3 );
f3i3 = L_sub( f3i1, L_shr( f3i2, 1 ) );
f3i4 = Mpy_32_16_1( L_sub( f4i3, f4i2 ), FFT_15PONIT_WNK4 );
f3i5 = zIm[in9];
+ move32();
f4i4 = zIm[in10];
+ move32();
f4i5 = zIm[in8];
+ move32();
f3i6 = L_add( f4i4, f4i5 );
f3i7 = Mpy_32_16_1( L_sub( f4i4, f4i5 ), FFT_15PONIT_WNK4 );
f3i8 = L_sub( f3i5, L_shr( f3i6, 1 ) );
f3i9 = zRe[in33];
+ move32();
f4i6 = zRe[in34];
+ move32();
f4i7 = zRe[in32];
+ move32();
f3i10 = L_add( f4i6, f4i7 );
f3i11 = L_sub( f3i9, L_shr( f3i10, 1 ) );
f3i12 = Mpy_32_16_1( L_sub( f4i7, f4i6 ), FFT_15PONIT_WNK4 );
f3i13 = zIm[in33];
+ move32();
f4i8 = zIm[in34];
+ move32();
f4i9 = zIm[in32];
+ move32();
f3i14 = L_add( f4i8, f4i9 );
f3i15 = Mpy_32_16_1( L_sub( f4i8, f4i9 ), FFT_15PONIT_WNK4 );
f4i1 = L_sub( f3i13, L_shr( f3i14, 1 ) );
@@ -272,29 +304,41 @@ static void fft15_shift2(
fi24 = L_add( fi22, fi23 );
f4i10 = zRe[in24];
+ move32();
fo6 = zRe[in25];
+ move32();
fo7 = zRe[in26];
+ move32();
f4i11 = L_add( fo6, fo7 );
f4i12 = L_sub( f4i10, L_shr( f4i11, 1 ) );
f4i13 = Mpy_32_16_1( L_sub( fo7, fo6 ), FFT_15PONIT_WNK4 );
f4i14 = zIm[in24];
+ move32();
fo8 = zIm[in25];
+ move32();
fo9 = zIm[in26];
+ move32();
f4i15 = L_add( fo8, fo9 );
f4i16 = Mpy_32_16_1( L_sub( fo8, fo9 ), FFT_15PONIT_WNK4 );
f4i17 = L_sub( f4i14, L_shr( f4i15, 1 ) );
f4i18 = zRe[in18];
+ move32();
f2o10 = zRe[in16];
+ move32();
f2o11 = zRe[in17];
+ move32();
f4i19 = L_add( f2o10, f2o11 );
f4i20 = L_sub( f4i18, L_shr( f4i19, 1 ) );
fo1 = Mpy_32_16_1( L_sub( f2o11, f2o10 ), FFT_15PONIT_WNK4 );
fo2 = zIm[in18];
+ move32();
f2o12 = zIm[in16];
+ move32();
f2o13 = zIm[in17];
+ move32();
fo3 = L_add( f2o12, f2o13 );
fo4 = Mpy_32_16_1( L_sub( f2o12, f2o13 ), FFT_15PONIT_WNK4 );
fo5 = L_sub( fo2, L_shr( fo3, 1 ) );
@@ -327,12 +371,17 @@ static void fft15_shift2(
fo14 = L_add( Mpy_32_16_1( fo15, FFT_15PONIT_WNK3 ), Mpy_32_16_1( fo16, FFT_15PONIT_WNK2 ) );
zRe[in0] = L_add( fi1, fo11 );
+ move32();
fo17 = L_add( fo10, fo12 );
zRe[in18] = L_sub( fo17, fo14 );
+ move32();
zRe[in24] = L_add( fo17, fo14 );
+ move32();
fo18 = L_sub( fo12, fo10 );
zRe[in9] = L_sub( fo18, fo13 );
+ move32();
zRe[in33] = L_add( fo18, fo13 );
+ move32();
f2o1 = Mpy_32_16_1( L_sub( f2i3, fi15 ), FFT_15PONIT_WNK1 );
f2o2 = L_add( f2i3, fi15 );
@@ -342,12 +391,17 @@ static void fft15_shift2(
f2o4 = L_sub( Mpy_32_16_1( f2o6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f2o7, FFT_15PONIT_WNK3 ) );
f2o5 = L_add( Mpy_32_16_1( f2o6, FFT_15PONIT_WNK3 ), Mpy_32_16_1( f2o7, FFT_15PONIT_WNK2 ) );
zIm[in0] = L_add( fi2, f2o2 );
+ move32();
f2o8 = L_add( f2o1, f2o3 );
zIm[in24] = L_sub( f2o8, f2o5 );
+ move32();
zIm[in18] = L_add( f2o5, f2o8 );
+ move32();
f2o9 = L_sub( f2o3, f2o1 );
zIm[in33] = L_sub( f2o9, f2o4 );
+ move32();
zIm[in9] = L_add( f2o4, f2o9 );
+ move32();
f2o14 = Mpy_32_16_1( L_sub( fi30, fi12 ), FFT_15PONIT_WNK1 );
f2o15 = L_add( fi30, fi12 );
@@ -357,12 +411,17 @@ static void fft15_shift2(
f3o2 = L_sub( Mpy_32_16_1( f3o4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o5, FFT_15PONIT_WNK3 ) );
f3o3 = L_add( Mpy_32_16_1( f3o5, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o4, FFT_15PONIT_WNK3 ) );
zRe[in2] = L_add( fi3, f2o15 );
+ move32();
f3o6 = L_add( f2o14, f3o1 );
zRe[in17] = L_sub( f3o6, f3o3 );
+ move32();
zRe[in26] = L_add( f3o6, f3o3 );
+ move32();
f3o7 = L_sub( f3o1, f2o14 );
zRe[in8] = L_sub( f3o7, f3o2 );
+ move32();
zRe[in32] = L_add( f3o7, f3o2 );
+ move32();
f3o8 = Mpy_32_16_1( L_sub( f2i6, fi18 ), FFT_15PONIT_WNK1 );
f3o9 = L_add( f2i6, fi18 );
@@ -372,12 +431,17 @@ static void fft15_shift2(
f3o11 = L_sub( Mpy_32_16_1( f3o13, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o14, FFT_15PONIT_WNK3 ) );
f3o12 = L_add( Mpy_32_16_1( f3o14, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o13, FFT_15PONIT_WNK3 ) );
zIm[in2] = L_add( fi6, f3o9 );
+ move32();
f3o15 = L_add( f3o8, f3o10 );
zIm[in26] = L_sub( f3o15, f3o12 );
+ move32();
zIm[in17] = L_add( f3o12, f3o15 );
+ move32();
f4o1 = L_sub( f3o10, f3o8 );
zIm[in8] = L_add( f3o11, f4o1 );
+ move32();
zIm[in32] = L_sub( f4o1, f3o11 );
+ move32();
f4o2 = Mpy_32_16_1( L_sub( f2i9, fi21 ), FFT_15PONIT_WNK1 );
f4o3 = L_add( f2i9, fi21 );
@@ -387,13 +451,18 @@ static void fft15_shift2(
f4o5 = L_add( Mpy_32_16_1( f4o8, FFT_15PONIT_WNK3 ), Mpy_32_16_1( f4o7, FFT_15PONIT_WNK2 ) );
f4o6 = L_sub( Mpy_32_16_1( f4o8, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f4o7, FFT_15PONIT_WNK3 ) );
zIm[in1] = L_add( fi5, f4o3 );
+ move32();
f4o9 = L_sub( f4o4, f4o2 );
f4o10 = L_add( f4o2, f4o4 );
zIm[in10] = L_add( f4o6, f4o9 );
+ move32();
zIm[in34] = L_sub( f4o9, f4o6 );
+ move32();
zIm[in25] = L_sub( f4o10, f4o5 );
+ move32();
zIm[in16] = L_add( f4o5, f4o10 );
+ move32();
f4o11 = Mpy_32_16_1( L_sub( f2i12, fi24 ), FFT_15PONIT_WNK1 );
f4o12 = L_add( f2i12, fi24 );
@@ -403,13 +472,18 @@ static void fft15_shift2(
f4o14 = L_add( Mpy_32_16_1( f4o16, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f4o17, FFT_15PONIT_WNK3 ) );
f4o15 = L_sub( Mpy_32_16_1( f4o17, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f4o16, FFT_15PONIT_WNK3 ) );
zRe[in1] = L_add( fi4, f4o12 );
+ move32();
f4o18 = L_sub( f4o13, f4o11 );
f4o19 = L_add( f4o11, f4o13 );
zRe[in10] = L_sub( f4o18, f4o15 );
+ move32();
zRe[in34] = L_add( f4o18, f4o15 );
+ move32();
zRe[in16] = L_sub( f4o19, f4o14 );
+ move32();
zRe[in25] = L_add( f4o19, f4o14 );
+ move32();
return;
}
@@ -441,20 +515,35 @@ static void fft15_shift8(
Word32 f5o8, f5o9, f5o10, f5o11, f5o12, f5o13, f5o14, f5o15, f5o16, f5o17, f5o18, f5o19, f5o21, f5o22;
in0 = Idx[0];
+ move16();
in8 = Idx[n1];
+ move16();
in16 = Idx[n1 * 2];
- in24 = Idx[n1 * 3];
+ move16();
+ in24 = Idx[i_mult( n1, 3 )];
+ move16();
in32 = Idx[n1 * 4];
- in1 = Idx[n1 * 5];
+ move16();
+ in1 = Idx[i_mult( n1, 5 )];
+ move16();
in9 = Idx[n1 * 6];
- in17 = Idx[n1 * 7];
+ move16();
+ in17 = Idx[i_mult( n1, 7 )];
+ move16();
in25 = Idx[n1 * 8];
- in33 = Idx[n1 * 9];
+ move16();
+ in33 = Idx[i_mult( n1, 9 )];
+ move16();
in2 = Idx[n1 * 10];
- in10 = Idx[n1 * 11];
+ move16();
+ in10 = Idx[i_mult( n1, 11 )];
+ move16();
in18 = Idx[n1 * 12];
- in26 = Idx[n1 * 13];
+ move16();
+ in26 = Idx[i_mult( n1, 13 )];
+ move16();
in34 = Idx[n1 * 14];
+ move16();
f2i13 = zRe[in0];
f2i14 = zIm[in0];
@@ -478,17 +567,29 @@ static void fft15_shift8(
fi6 = L_sub( f3i5, f3i1 );
f3i10 = zRe[in9];
+ move32();
f4i11 = zRe[in10];
+ move32();
f4i12 = zRe[in8];
+ move32();
f3i14 = zIm[in9];
+ move32();
f4i13 = zIm[in10];
+ move32();
f4i14 = zIm[in8];
+ move32();
f4i3 = zRe[in33];
+ move32();
f4i15 = zRe[in34];
+ move32();
fo1 = zRe[in32];
+ move32();
f4i7 = zIm[in33];
+ move32();
fo2 = zIm[in34];
+ move32();
fo3 = zIm[in32];
+ move32();
f3i11 = L_add( f4i11, f4i12 );
@@ -524,17 +625,29 @@ static void fft15_shift8(
fi24 = L_add( fi22, fi23 );
fo4 = zRe[in24];
+ move32();
f2o5 = zRe[in25];
+ move32();
f2o6 = zRe[in26];
+ move32();
fo8 = zIm[in24];
+ move32();
f2o7 = zIm[in25];
+ move32();
f2o8 = zIm[in26];
+ move32();
fo12 = zRe[in18];
+ move32();
f2o9 = zRe[in16];
+ move32();
f2o10 = zRe[in17];
+ move32();
f2o1 = zIm[in18];
+ move32();
f2o11 = zIm[in16];
+ move32();
f2o12 = zIm[in17];
+ move32();
fo5 = L_add( f2o5, f2o6 );
@@ -577,12 +690,17 @@ static void fft15_shift8(
f3o1 = L_sub( Mpy_32_16_1( f3o3, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o4, FFT_15PONIT_WNK3 ) );
f3o2 = L_add( Mpy_32_16_1( f3o4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o3, FFT_15PONIT_WNK3 ) );
zRe[in0] = L_add( fi1, f2o14 );
+ move32();
f3o5 = L_add( f2o13, f2o15 );
zRe[in24] = L_sub( f3o5, f3o2 );
+ move32();
zRe[in18] = L_add( f3o5, f3o2 );
+ move32();
f3o6 = L_sub( f2o15, f2o13 );
zRe[in33] = L_sub( f3o6, f3o1 );
+ move32();
zRe[in9] = L_add( f3o6, f3o1 );
+ move32();
f3o7 = Mpy_32_16_1( L_sub( f2i3, fi15 ), FFT_15PONIT_WNK1 );
f3o8 = L_add( f2i3, fi15 );
@@ -592,12 +710,17 @@ static void fft15_shift8(
f3o10 = L_sub( Mpy_32_16_1( f3o12, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o13, FFT_15PONIT_WNK3 ) );
f3o11 = L_add( Mpy_32_16_1( f3o13, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f3o12, FFT_15PONIT_WNK3 ) );
zIm[in0] = L_add( fi2, f3o8 );
+ move32();
f3o14 = L_add( f3o7, f3o9 );
zIm[in18] = L_sub( f3o14, f3o11 );
+ move32();
zIm[in24] = L_add( f3o11, f3o14 );
+ move32();
f3o15 = L_sub( f3o9, f3o7 );
zIm[in9] = L_sub( f3o15, f3o10 );
+ move32();
zIm[in33] = L_add( f3o10, f3o15 );
+ move32();
f4o1 = Mpy_32_16_1( L_sub( fi30, fi12 ), FFT_15PONIT_WNK1 );
f4o2 = L_add( fi30, fi12 );
@@ -607,12 +730,17 @@ static void fft15_shift8(
f4o4 = L_sub( Mpy_32_16_1( f4o6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f4o7, FFT_15PONIT_WNK3 ) );
f4o5 = L_add( Mpy_32_16_1( f4o7, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f4o6, FFT_15PONIT_WNK3 ) );
zRe[in2] = L_add( fi3, f4o2 );
+ move32();
f4o8 = L_add( f4o1, f4o3 );
zRe[in26] = L_sub( f4o8, f4o5 );
+ move32();
zRe[in17] = L_add( f4o8, f4o5 );
+ move32();
f4o9 = L_sub( f4o3, f4o1 );
zRe[in32] = L_sub( f4o9, f4o4 );
+ move32();
zRe[in8] = L_add( f4o9, f4o4 );
+ move32();
f4o10 = Mpy_32_16_1( L_sub( f2i6, fi18 ), FFT_15PONIT_WNK1 );
f4o11 = L_add( f2i6, fi18 );
@@ -622,12 +750,17 @@ static void fft15_shift8(
f4o13 = L_sub( Mpy_32_16_1( f4o15, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f5o1, FFT_15PONIT_WNK3 ) );
f4o14 = L_add( Mpy_32_16_1( f5o1, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f4o15, FFT_15PONIT_WNK3 ) );
zIm[in2] = L_add( fi6, f4o11 );
+ move32();
f5o2 = L_add( f4o10, f4o12 );
zIm[in17] = L_sub( f5o2, f4o14 );
+ move32();
zIm[in26] = L_add( f4o14, f5o2 );
+ move32();
f5o3 = L_sub( f4o12, f4o10 );
zIm[in32] = L_add( f4o13, f5o3 );
+ move32();
zIm[in8] = L_sub( f5o3, f4o13 );
+ move32();
f5o4 = Mpy_32_16_1( L_sub( f2i9, fi21 ), FFT_15PONIT_WNK1 );
f5o5 = L_add( f2i9, fi21 );
@@ -637,13 +770,18 @@ static void fft15_shift8(
f5o7 = L_add( Mpy_32_16_1( f5o9, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f5o10, FFT_15PONIT_WNK3 ) );
f5o8 = L_sub( Mpy_32_16_1( f5o10, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f5o9, FFT_15PONIT_WNK3 ) );
zIm[in1] = L_add( fi5, f5o5 );
+ move32();
f5o11 = L_sub( f5o6, f5o4 );
f5o12 = L_add( f5o4, f5o6 );
zIm[in34] = L_add( f5o8, f5o11 );
+ move32();
zIm[in10] = L_sub( f5o11, f5o8 );
+ move32();
zIm[in16] = L_sub( f5o12, f5o7 );
+ move32();
zIm[in25] = L_add( f5o7, f5o12 );
+ move32();
f5o13 = Mpy_32_16_1( L_sub( f2i12, fi24 ), FFT_15PONIT_WNK1 );
f5o14 = L_add( f2i12, fi24 );
@@ -653,13 +791,18 @@ static void fft15_shift8(
f5o16 = L_add( Mpy_32_16_1( f5o18, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f5o19, FFT_15PONIT_WNK3 ) );
f5o17 = L_sub( Mpy_32_16_1( f5o19, FFT_15PONIT_WNK2 ), Mpy_32_16_1( f5o18, FFT_15PONIT_WNK3 ) );
zRe[in1] = L_add( fi4, f5o14 );
+ move32();
f5o21 = L_sub( f5o15, f5o13 );
f5o22 = L_add( f5o13, f5o15 );
zRe[in34] = L_sub( f5o21, f5o17 );
+ move32();
zRe[in10] = L_add( f5o21, f5o17 );
+ move32();
zRe[in25] = L_sub( f5o22, f5o16 );
+ move32();
zRe[in16] = L_add( f5o22, f5o16 );
+ move32();
return;
}
@@ -681,17 +824,28 @@ static void fft5_shift1(
Word16 in1, in2, in3, in4, in5;
in1 = Idx[0];
+ move16();
in2 = Idx[n1];
+ move16();
in3 = Idx[n1 * 2];
- in4 = Idx[n1 * 3];
+ move16();
+ in4 = Idx[i_mult( n1, 3 )];
+ move16();
in5 = Idx[n1 * 4];
+ move16();
fi1 = zRe[in1];
+ move32();
fi2 = zIm[in1];
+ move32();
fo3 = zRe[in2];
+ move32();
fo4 = zRe[in5];
+ move32();
fo6 = zRe[in3];
+ move32();
fo7 = zRe[in4];
+ move32();
fo5 = L_add( fo3, fo4 );
fo8 = L_add( fo6, fo7 );
@@ -701,9 +855,13 @@ static void fft5_shift1(
fi6 = L_sub( fo3, fo4 );
fo3 = zIm[in2];
+ move32();
fo4 = zIm[in5];
+ move32();
fo6 = zIm[in3];
+ move32();
fo7 = zIm[in4];
+ move32();
fo5 = L_add( fo3, fo4 );
fo8 = L_add( fo6, fo7 );
@@ -713,7 +871,9 @@ static void fft5_shift1(
fo2 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 );
zRe[in1] = L_add( fi1, fi3 );
+ move32();
zIm[in1] = L_add( fi2, fi8 );
+ move32();
fo3 = L_add( Mpy_32_16_1( fi7, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fo1, FFT_15PONIT_WNK3 ) );
fo4 = L_sub( Mpy_32_16_1( fo1, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi7, FFT_15PONIT_WNK3 ) );
@@ -722,9 +882,13 @@ static void fft5_shift1(
fo6 = L_sub( fo7, fi5 );
zRe[in2] = L_add( fo5, fo3 );
+ move32();
zRe[in3] = L_sub( fo6, fo4 );
+ move32();
zRe[in4] = L_add( fo6, fo4 );
+ move32();
zRe[in5] = L_sub( fo5, fo3 );
+ move32();
fo3 = L_add( Mpy_32_16_1( fi6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi4, FFT_15PONIT_WNK3 ) );
fo4 = L_sub( Mpy_32_16_1( fi4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi6, FFT_15PONIT_WNK3 ) );
@@ -733,9 +897,13 @@ static void fft5_shift1(
fo6 = L_sub( fo7, fo2 );
zIm[in2] = L_sub( fo5, fo3 );
+ move32();
zIm[in3] = L_add( fo4, fo6 );
+ move32();
zIm[in4] = L_sub( fo6, fo4 );
+ move32();
zIm[in5] = L_add( fo3, fo5 );
+ move32();
return;
}
@@ -757,17 +925,28 @@ static void fft5_shift4(
Word16 in1, in2, in3, in4, in5;
in1 = Idx[0];
+ move16();
in2 = Idx[n1];
+ move16();
in3 = Idx[n1 * 2];
- in4 = Idx[n1 * 3];
+ move16();
+ in4 = Idx[i_mult( n1, 3 )];
+ move16();
in5 = Idx[n1 * 4];
+ move16();
fi1 = zRe[in1];
+ move32();
fi2 = zIm[in1];
+ move32();
fo3 = zRe[in2];
+ move32();
fo4 = zRe[in5];
+ move32();
fo6 = zRe[in3];
+ move32();
fo7 = zRe[in4];
+ move32();
fo5 = L_add( fo3, fo4 );
fo8 = L_add( fo6, fo7 );
@@ -777,9 +956,13 @@ static void fft5_shift4(
fi6 = L_sub( fo3, fo4 );
fo3 = zIm[in2];
+ move32();
fo4 = zIm[in5];
+ move32();
fo6 = zIm[in3];
+ move32();
fo7 = zIm[in4];
+ move32();
fo5 = L_add( fo3, fo4 );
fo8 = L_add( fo6, fo7 );
@@ -789,7 +972,9 @@ static void fft5_shift4(
fo2 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 );
zRe[in1] = L_add( fi1, fi3 );
+ move32();
zIm[in1] = L_add( fi2, fi8 );
+ move32();
fo3 = L_add( Mpy_32_16_1( fi7, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fo1, FFT_15PONIT_WNK3 ) );
fo4 = L_sub( Mpy_32_16_1( fo1, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi7, FFT_15PONIT_WNK3 ) );
@@ -798,9 +983,13 @@ static void fft5_shift4(
fo6 = L_sub( fo7, fi5 );
zRe[in2] = L_sub( fo5, fo3 );
+ move32();
zRe[in4] = L_sub( fo6, fo4 );
+ move32();
zRe[in3] = L_add( fo6, fo4 );
+ move32();
zRe[in5] = L_add( fo5, fo3 );
+ move32();
fo3 = L_add( Mpy_32_16_1( fi6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi4, FFT_15PONIT_WNK3 ) );
fo4 = L_sub( Mpy_32_16_1( fi4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi6, FFT_15PONIT_WNK3 ) );
@@ -809,9 +998,13 @@ static void fft5_shift4(
fo6 = L_sub( fo7, fo2 );
zIm[in3] = L_sub( fo6, fo4 );
+ move32();
zIm[in2] = L_add( fo3, fo5 );
+ move32();
zIm[in4] = L_add( fo4, fo6 );
+ move32();
zIm[in5] = L_sub( fo5, fo3 );
+ move32();
return;
}
@@ -832,17 +1025,28 @@ static void fft5_32(
Word16 in1, in2, in3, in4, in5;
in1 = Idx[0];
+ move16();
in2 = Idx[32];
+ move16();
in3 = Idx[64];
+ move16();
in4 = Idx[96];
+ move16();
in5 = Idx[128];
+ move16();
fi1 = zRe[in1];
+ move32();
fi2 = zIm[in1];
+ move32();
fo3 = zRe[in2];
+ move32();
fo4 = zRe[in5];
+ move32();
fo6 = zRe[in3];
+ move32();
fo7 = zRe[in4];
+ move32();
fo5 = L_add( fo3, fo4 );
fo8 = L_add( fo6, fo7 );
@@ -852,9 +1056,13 @@ static void fft5_32(
fi6 = L_sub( fo3, fo4 );
fo3 = zIm[in2];
+ move32();
fo4 = zIm[in5];
+ move32();
fo6 = zIm[in3];
+ move32();
fo7 = zIm[in4];
+ move32();
fo5 = L_add( fo3, fo4 );
fo8 = L_add( fo6, fo7 );
@@ -864,7 +1072,9 @@ static void fft5_32(
fo2 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 );
zRe[in1] = L_add( fi1, fi3 );
+ move32();
zIm[in1] = L_add( fi2, fi8 );
+ move32();
fo3 = L_add( Mpy_32_16_1( fi7, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fo1, FFT_15PONIT_WNK3 ) );
fo4 = L_sub( Mpy_32_16_1( fo1, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi7, FFT_15PONIT_WNK3 ) );
@@ -873,9 +1083,13 @@ static void fft5_32(
fo6 = L_sub( fo7, fi5 );
zRe[in2] = L_add( fo6, fo4 );
+ move32();
zRe[in3] = L_add( fo5, fo3 );
+ move32();
zRe[in4] = L_sub( fo5, fo3 );
+ move32();
zRe[in5] = L_sub( fo6, fo4 );
+ move32();
fo3 = L_add( Mpy_32_16_1( fi6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi4, FFT_15PONIT_WNK3 ) );
fo4 = L_sub( Mpy_32_16_1( fi4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi6, FFT_15PONIT_WNK3 ) );
@@ -884,9 +1098,13 @@ static void fft5_32(
fo6 = L_sub( fo7, fo2 );
zIm[in2] = L_sub( fo6, fo4 );
+ move32();
zIm[in3] = L_sub( fo5, fo3 );
+ move32();
zIm[in4] = L_add( fo3, fo5 );
+ move32();
zIm[in5] = L_add( fo4, fo6 );
+ move32();
return;
}
@@ -907,8 +1125,11 @@ static void fft64(
FOR( i = 0; i < 64; i++ )
{
id = Idx[i];
+ move16();
z[2 * i] = x[id];
- z[2 * i + 1] = y[id];
+ move32();
+ z[add( shl( i, 1 ), 1 )] = y[id];
+ move32();
}
cdftForw( 128, z, Ip_fft64, w_fft64_fx );
@@ -916,9 +1137,13 @@ static void fft64(
FOR( i = 0; i < 64; i++ )
{
jd = Odx_fft64[i];
+ move16();
id = Idx[jd];
+ move16();
x[id] = z[2 * i];
- y[id] = z[2 * i + 1];
+ move32();
+ y[id] = z[add( shl( i, 1 ), 1 )];
+ move32();
}
return;
@@ -942,8 +1167,11 @@ static void fft32_15(
FOR( i = 0; i < 32; i++ )
{
id = Idx[i];
+ move16();
z[2 * i] = x[id];
- z[2 * i + 1] = y[id];
+ move32();
+ z[add( shl( i, 1 ), 1 )] = y[id];
+ move32();
}
cdftForw( 64, z, Ip_fft32, w_fft32_fx );
@@ -951,9 +1179,13 @@ static void fft32_15(
FOR( i = 0; i < 32; i++ )
{
jd = Odx_fft32_15[i];
+ move16();
id = Idx[jd];
+ move16();
x[id] = z[2 * i];
- y[id] = z[2 * i + 1];
+ move32();
+ y[id] = z[add( shl( i, 1 ), 1 )];
+ move32();
}
return;
@@ -976,8 +1208,11 @@ static void fft32_5(
FOR( i = 0; i < 32; i++ )
{
id = Idx[i];
+ move16();
z[2 * i] = x[id];
- z[2 * i + 1] = y[id];
+ move32();
+ z[add( shl( i, 1 ), 1 )] = y[id];
+ move32();
}
cdftForw( 64, z, Ip_fft32, w_fft32_fx );
@@ -985,9 +1220,13 @@ static void fft32_5(
FOR( i = 0; i < 32; i++ )
{
jd = Odx_fft32_5[i];
+ move16();
id = Idx[jd];
+ move16();
x[id] = z[2 * i];
- y[id] = z[2 * i + 1];
+ move32();
+ y[id] = z[add( shl( i, 1 ), 1 )];
+ move32();
}
return;
@@ -1010,8 +1249,11 @@ static void fft16_ivas(
FOR( i = 0; i < 16; i++ )
{
id = Idx[i];
+ move16();
z[2 * i] = x[id];
- z[2 * i + 1] = y[id];
+ move32();
+ z[add( shl( i, 1 ), 1 )] = y[id];
+ move32();
}
cdftForw( 32, z, Ip_fft16, w_fft16_fx );
@@ -1019,9 +1261,13 @@ static void fft16_ivas(
FOR( i = 0; i < 16; i++ )
{
jd = Odx_fft16[i];
+ move16();
id = Idx[jd];
+ move16();
x[id] = z[2 * i];
- y[id] = z[2 * i + 1];
+ move32();
+ y[id] = z[add( shl( i, 1 ), 1 )];
+ move32();
}
return;
@@ -1044,8 +1290,11 @@ static void fft8(
FOR( i = 0; i < 8; i++ )
{
id = Idx[i];
+ move16();
z[2 * i] = x[id];
- z[2 * i + 1] = y[id];
+ move32();
+ z[add( shl( i, 1 ), 1 )] = y[id];
+ move32();
}
cdftForw( 16, z, Ip_fft8, w_fft8_fx );
@@ -1053,8 +1302,11 @@ static void fft8(
FOR( i = 0; i < 8; i++ )
{
id = Idx[i];
+ move16();
x[id] = z[2 * i];
- y[id] = z[2 * i + 1];
+ move32();
+ y[id] = z[add( shl( i, 1 ), 1 )];
+ move32();
}
return;
@@ -1077,8 +1329,11 @@ static void fft8_5(
FOR( i = 0; i < 8; i++ )
{
id = Idx[i];
+ move16();
z[2 * i] = x[id];
- z[2 * i + 1] = y[id];
+ move32();
+ z[add( shl( i, 1 ), 1 )] = y[id];
+ move32();
}
cdftForw( 16, z, Ip_fft8, w_fft8_fx );
@@ -1086,9 +1341,13 @@ static void fft8_5(
FOR( i = 0; i < 8; i++ )
{
jd = Odx_fft8_5[i];
+ move16();
id = Idx[jd];
+ move16();
x[id] = z[2 * i];
- y[id] = z[2 * i + 1];
+ move32();
+ y[id] = z[add( shl( i, 1 ), 1 )];
+ move32();
}
return;
}
@@ -1110,17 +1369,28 @@ static void fft5_8(
Word16 in1, in2, in3, in4, in5;
in1 = Idx[0];
+ move16();
in2 = Idx[n1];
+ move16();
in3 = Idx[n1 * 2];
- in4 = Idx[n1 * 3];
+ move16();
+ in4 = Idx[i_mult( n1, 3 )];
+ move16();
in5 = Idx[n1 * 4];
+ move16();
fi1 = zRe[in1];
+ move32();
fi2 = zIm[in1];
+ move32();
fo3 = zRe[in2];
+ move32();
fo4 = zRe[in5];
+ move32();
fo6 = zRe[in3];
+ move32();
fo7 = zRe[in4];
+ move32();
fo5 = L_add( fo3, fo4 );
fo8 = L_add( fo6, fo7 );
@@ -1130,9 +1400,13 @@ static void fft5_8(
fi6 = L_sub( fo3, fo4 );
fo3 = zIm[in2];
+ move32();
fo4 = zIm[in5];
+ move32();
fo6 = zIm[in3];
+ move32();
fo7 = zIm[in4];
+ move32();
fo5 = L_add( fo3, fo4 );
fo8 = L_add( fo6, fo7 );
@@ -1142,7 +1416,9 @@ static void fft5_8(
fo2 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 );
zRe[in1] = L_add( fi1, fi3 );
+ move32();
zIm[in1] = L_add( fi2, fi8 );
+ move32();
fo3 = L_add( Mpy_32_16_1( fi7, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fo1, FFT_15PONIT_WNK3 ) );
fo4 = L_sub( Mpy_32_16_1( fo1, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi7, FFT_15PONIT_WNK3 ) );
@@ -1151,9 +1427,13 @@ static void fft5_8(
fo6 = L_sub( fo7, fi5 );
zRe[in2] = L_sub( fo6, fo4 );
+ move32();
zRe[in3] = L_sub( fo5, fo3 );
+ move32();
zRe[in5] = L_add( fo6, fo4 );
+ move32();
zRe[in4] = L_add( fo5, fo3 );
+ move32();
fo3 = L_add( Mpy_32_16_1( fi6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi4, FFT_15PONIT_WNK3 ) );
fo4 = L_sub( Mpy_32_16_1( fi4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi6, FFT_15PONIT_WNK3 ) );
@@ -1162,9 +1442,13 @@ static void fft5_8(
fo6 = L_sub( fo7, fo2 );
zIm[in2] = L_add( fo4, fo6 );
+ move32();
zIm[in3] = L_add( fo3, fo5 );
+ move32();
zIm[in4] = L_sub( fo5, fo3 );
+ move32();
zIm[in5] = L_sub( fo6, fo4 );
+ move32();
return;
}
@@ -1186,8 +1470,11 @@ static void fft4_5(
FOR( i = 0; i < 4; i++ )
{
id = Idx[i];
+ move16();
z[2 * i] = x[id];
- z[2 * i + 1] = y[id];
+ move32();
+ z[add( shl( i, 1 ), 1 )] = y[id];
+ move32();
}
cdftForw( 8, z, Ip_fft4, w_fft4_fx );
@@ -1195,9 +1482,13 @@ static void fft4_5(
FOR( i = 0; i < 4; i++ )
{
jd = Odx_fft4_5[i];
+ move16();
id = Idx[jd];
+ move16();
x[id] = z[2 * i];
- y[id] = z[2 * i + 1];
+ move32();
+ y[id] = z[add( shl( i, 1 ), 1 )];
+ move32();
}
return;
}
@@ -1218,17 +1509,28 @@ static void fft5_4(
Word16 in1, in2, in3, in4, in5;
in1 = Idx[0];
+ move16();
in2 = Idx[n1];
+ move16();
in3 = Idx[n1 * 2];
- in4 = Idx[n1 * 3];
+ move16();
+ in4 = Idx[i_mult( n1, 3 )];
+ move16();
in5 = Idx[n1 * 4];
+ move16();
fi1 = zRe[in1];
+ move32();
fi2 = zIm[in1];
+ move32();
fo3 = zRe[in2];
+ move32();
fo4 = zRe[in5];
+ move32();
fo6 = zRe[in3];
+ move32();
fo7 = zRe[in4];
+ move32();
fo5 = L_add( fo3, fo4 );
fo8 = L_add( fo6, fo7 );
@@ -1238,9 +1540,13 @@ static void fft5_4(
fi6 = L_sub( fo3, fo4 );
fo3 = zIm[in2];
+ move32();
fo4 = zIm[in5];
+ move32();
fo6 = zIm[in3];
+ move32();
fo7 = zIm[in4];
+ move32();
fo5 = L_add( fo3, fo4 );
fo8 = L_add( fo6, fo7 );
@@ -1250,7 +1556,9 @@ static void fft5_4(
fo2 = Mpy_32_16_1( L_sub( fo5, fo8 ), FFT_15PONIT_WNK1 );
zRe[in1] = L_add( fi1, fi3 );
+ move32();
zIm[in1] = L_add( fi2, fi8 );
+ move32();
fo3 = L_add( Mpy_32_16_1( fi7, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fo1, FFT_15PONIT_WNK3 ) );
fo4 = L_sub( Mpy_32_16_1( fo1, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi7, FFT_15PONIT_WNK3 ) );
@@ -1259,9 +1567,13 @@ static void fft5_4(
fo6 = L_sub( fo7, fi5 );
zRe[in2] = L_sub( fo5, fo3 );
+ move32();
zRe[in4] = L_sub( fo6, fo4 );
+ move32();
zRe[in3] = L_add( fo6, fo4 );
+ move32();
zRe[in5] = L_add( fo5, fo3 );
+ move32();
fo3 = L_add( Mpy_32_16_1( fi6, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi4, FFT_15PONIT_WNK3 ) );
fo4 = L_sub( Mpy_32_16_1( fi4, FFT_15PONIT_WNK2 ), Mpy_32_16_1( fi6, FFT_15PONIT_WNK3 ) );
@@ -1270,9 +1582,13 @@ static void fft5_4(
fo6 = L_sub( fo7, fo2 );
zIm[in2] = L_add( fo3, fo5 );
+ move32();
zIm[in3] = L_sub( fo6, fo4 );
+ move32();
zIm[in4] = L_add( fo4, fo6 );
+ move32();
zIm[in5] = L_sub( fo5, fo3 );
+ move32();
return;
}
@@ -1292,7 +1608,7 @@ void DoRTFT80_fx(
/* Applying 16-point FFT for 5 times based on the address table Idx_dortft80 */
FOR( j = 0; j < 5; j++ )
{
- fft16_ivas( x, y, Idx_dortft80 + 16 * j );
+ fft16_ivas( x, y, Idx_dortft80 + shl( j, 4 ) );
}
/* Applying 5-point FFT for 16 times based on the address table Idx_dortft80 */
@@ -1319,7 +1635,7 @@ void DoRTFT120_fx(
/* Applying 8-point FFT for 15 times based on the address table Idx_dortft120 */
FOR( j = 0; j < 15; j++ )
{
- fft8( x, y, Idx_dortft120 + 8 * j );
+ fft8( x, y, Idx_dortft120 + shl( j, 3 ) );
}
/* Applying 15-point FFT for 8 times based on the address table Idx_dortft120 */
@@ -1346,7 +1662,7 @@ void DoRTFT160_fx(
/* Applying 32-point FFT for 5 times based on the address table Idx_dortft160 */
FOR( j = 0; j < 5; j++ )
{
- fft32_5( x, y, Idx_dortft160 + 32 * j );
+ fft32_5( x, y, Idx_dortft160 + shl( j, 5 ) );
}
/* Applying 5-point FFT for 32 times based on the address table Idx_dortft160 */
@@ -1373,7 +1689,7 @@ void DoRTFT320_fx(
/* Applying 64-point FFT for 5 times based on the address table Idx_dortft160 */
FOR( j = 0; j < 5; j++ )
{
- fft64( x, y, Idx_dortft320 + 64 * j );
+ fft64( x, y, Idx_dortft320 + shl( j, 6 ) );
}
/* Applying 5-point FFT for 64 times based on the address table Idx_dortft160 */
@@ -1400,7 +1716,7 @@ void DoRTFT480_fx(
/* Applying 32-point FFT for 15 times based on the address table Idx_dortft160 */
FOR( j = 0; j < 15; j++ )
{
- fft32_15( x, y, Idx_dortft480 + 32 * j );
+ fft32_15( x, y, Idx_dortft480 + shl( j, 5 ) );
}
/* Applying 5-point FFT for 32 times based on the address table Idx_dortft160 */
@@ -1426,7 +1742,7 @@ void DoRTFT40_fx(
/* Applying 8-point FFT for 5 times based on the address table Idx_dortft40 */
FOR( j = 0; j < 5; j++ )
{
- fft8_5( x, y, Idx_dortft40 + 8 * j );
+ fft8_5( x, y, Idx_dortft40 + shl( j, 3 ) );
}
/* Applying 5-point FFT for 8 times based on the address table Idx_dortft40 */
@@ -1453,7 +1769,7 @@ void DoRTFT20_fx(
/* Applying 4-point FFT for 5 times based on the address table Idx_dortft20 */
FOR( j = 0; j < 5; j++ )
{
- fft4_5( x, y, Idx_dortft20 + 4 * j );
+ fft4_5( x, y, Idx_dortft20 + shl( j, 2 ) );
}
/* Applying 5-point FFT for 4 times based on the address table Idx_dortft20 */
@@ -1482,17 +1798,23 @@ void DoRTFT128_fx(
FOR( i = 0; i < 128; i++ )
{
z[2 * i] = x[i];
- z[2 * i + 1] = y[i];
+ move32();
+ z[add( shl( i, 1 ), 1 )] = y[i];
+ move32();
}
cdftForw( 256, z, Ip_fft128, w_fft128_fx );
x[0] = z[0];
+ move32();
y[0] = z[1];
+ move32();
FOR( i = 1; i < 128; i++ )
{
x[128 - i] = z[2 * i];
- y[128 - i] = z[2 * i + 1];
+ move32();
+ y[128 - i] = z[add( shl( i, 1 ), 1 )];
+ move32();
}
return;
@@ -1535,22 +1857,30 @@ static void bitrv2_SR(
IF( EQ_16( n, 64 ) )
{
m = 4;
+ move16();
l = -1;
+ move16();
}
ELSE IF( EQ_16( n, 256 ) )
{
m = 8;
+ move16();
l = -1;
+ move16();
}
ELSE IF( EQ_16( n, 16 ) )
{
m = 2;
+ move16();
l = -1;
+ move16();
}
ELSE
{
l = n;
+ move16();
m = 1;
+ move16();
WHILE( shl( m, 3 ) < l )
{
@@ -1562,7 +1892,7 @@ static void bitrv2_SR(
m2 = shl( m, 1 );
- IF( EQ_16( l, 0 ) )
+ IF( l == 0 )
{
FOR( k = 0; k < m; k++ )
{
@@ -1571,55 +1901,95 @@ static void bitrv2_SR(
j1 = add( shl( j, 1 ), ip[k] );
k1 = add( shl( k, 1 ), ip[j] );
xr = a[j1];
+ move32();
xi = a[j1 + 1];
+ move32();
yr = a[k1];
+ move32();
yi = a[k1 + 1];
+ move32();
a[j1] = yr;
+ move32();
a[j1 + 1] = yi;
+ move32();
a[k1] = xr;
+ move32();
a[k1 + 1] = xi;
- j1 += m2;
- k1 += 2 * m2;
+ move32();
+ j1 = add( j1, m2 );
+ k1 = add( k1, 2 * m2 );
xr = a[j1];
+ move32();
xi = a[j1 + 1];
+ move32();
yr = a[k1];
+ move32();
yi = a[k1 + 1];
+ move32();
a[j1] = yr;
+ move32();
a[j1 + 1] = yi;
+ move32();
a[k1] = xr;
+ move32();
a[k1 + 1] = xi;
+ move32();
j1 = add( j1, m2 );
k1 = sub( k1, m2 );
xr = a[j1];
+ move32();
xi = a[j1 + 1];
+ move32();
yr = a[k1];
+ move32();
yi = a[k1 + 1];
+ move32();
a[j1] = yr;
+ move32();
a[j1 + 1] = yi;
+ move32();
a[k1] = xr;
+ move32();
a[k1 + 1] = xi;
+ move32();
j1 = add( j1, m2 );
k1 = add( k1, shl( m2, 1 ) );
xr = a[j1];
+ move32();
xi = a[j1 + 1];
+ move32();
yr = a[k1];
+ move32();
yi = a[k1 + 1];
+ move32();
a[j1] = yr;
+ move32();
a[j1 + 1] = yi;
+ move32();
a[k1] = xr;
+ move32();
a[k1 + 1] = xi;
+ move32();
}
j1 = add( shl( k, 1 ), add( m2, ip[k] ) );
k1 = add( j1, m2 );
xr = a[j1];
+ move32();
xi = a[j1 + 1];
+ move32();
yr = a[k1];
+ move32();
yi = a[k1 + 1];
+ move32();
a[j1] = yr;
+ move32();
a[j1 + 1] = yi;
+ move32();
a[k1] = xr;
+ move32();
a[k1 + 1] = xi;
+ move32();
}
}
ELSE
@@ -1631,23 +2001,39 @@ static void bitrv2_SR(
j1 = add( shl( j, 1 ), ip[k] );
k1 = add( shl( k, 1 ), ip[j] );
xr = a[j1];
+ move32();
xi = a[j1 + 1];
+ move32();
yr = a[k1];
+ move32();
yi = a[k1 + 1];
+ move32();
a[j1] = yr;
+ move32();
a[j1 + 1] = yi;
+ move32();
a[k1] = xr;
+ move32();
a[k1 + 1] = xi;
+ move32();
j1 = add( j1, m2 );
k1 = add( k1, m2 );
xr = a[j1];
+ move32();
xi = a[j1 + 1];
+ move32();
yr = a[k1];
+ move32();
yi = a[k1 + 1];
+ move32();
a[j1] = yr;
+ move32();
a[j1 + 1] = yi;
+ move32();
a[k1] = xr;
+ move32();
a[k1 + 1] = xi;
+ move32();
}
}
}
@@ -1670,12 +2056,14 @@ static void cftfsub(
Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
l = 2;
+ move16();
IF( GT_16( n, 8 ) )
{
cft1st( n, a, w );
l = 8;
+ move16();
WHILE( LT_16( shl( l, 2 ), n ) )
{
@@ -1700,13 +2088,21 @@ static void cftfsub(
x3r = L_sub( a[j2], a[j3] );
x3i = L_sub( a[j2 + 1], a[j3 + 1] );
a[j] = L_add( x0r, x2r );
+ move32();
a[j + 1] = L_add( x0i, x2i );
+ move32();
a[j2] = L_sub( x0r, x2r );
+ move32();
a[j2 + 1] = L_sub( x0i, x2i );
+ move32();
a[j1] = L_sub( x1r, x3i );
+ move32();
a[j1 + 1] = L_add( x1i, x3r );
+ move32();
a[j3] = L_add( x1r, x3i );
+ move32();
a[j3 + 1] = L_sub( x1i, x3r );
+ move32();
}
}
ELSE
@@ -1717,9 +2113,13 @@ static void cftfsub(
x0r = L_sub( a[j], a[j1] );
x0i = L_sub( a[j + 1], a[j1 + 1] );
a[j] = L_add( a[j], a[j1] );
+ move32();
a[j + 1] = L_add( a[j + 1], a[j1 + 1] );
+ move32();
a[j1] = x0r;
+ move32();
a[j1 + 1] = x0i;
+ move32();
}
}
@@ -1750,13 +2150,21 @@ static void cft1st(
x3r = L_sub( a[4], a[6] );
x3i = L_sub( a[5], a[7] );
a[0] = L_add( x0r, x2r );
+ move32();
a[1] = L_add( x0i, x2i );
+ move32();
a[4] = L_sub( x0r, x2r );
+ move32();
a[5] = L_sub( x0i, x2i );
+ move32();
a[2] = L_sub( x1r, x3i );
+ move32();
a[3] = L_add( x1i, x3r );
+ move32();
a[6] = L_add( x1r, x3i );
+ move32();
a[7] = L_sub( x1i, x3r );
+ move32();
wk1r = w[2];
x0r = L_add( a[8], a[10] );
x0i = L_add( a[9], a[11] );
@@ -1767,27 +2175,40 @@ static void cft1st(
x3r = L_sub( a[12], a[14] );
x3i = L_sub( a[13], a[15] );
a[8] = L_add( x0r, x2r );
+ move32();
a[9] = L_add( x0i, x2i );
+ move32();
a[12] = L_sub( x2i, x0i );
+ move32();
a[13] = L_sub( x0r, x2r );
+ move32();
x0r = L_sub( x1r, x3i );
x0i = L_add( x1i, x3r );
a[10] = Mpy_32_16_1( L_sub( x0r, x0i ), wk1r );
+ move32();
a[11] = Mpy_32_16_1( L_add( x0r, x0i ), wk1r );
+ move32();
x0r = L_add( x3i, x1r );
x0i = L_sub( x3r, x1i );
a[14] = Mpy_32_16_1( L_sub( x0i, x0r ), wk1r );
+ move32();
a[15] = Mpy_32_16_1( L_add( x0i, x0r ), wk1r );
+ move32();
k1 = 0;
+ move16();
FOR( j = 16; j < n; j += 16 )
{
k1 = add( k1, 2 );
k2 = shl( k1, 1 );
wk2r = w[k1];
+ move16();
wk2i = w[k1 + 1];
+ move16();
wk1r = w[k2];
+ move16();
wk1i = w[k2 + 1];
+ move16();
wtmp = mult_r( wk2i, wk1i );
wk3r = sub( wk1r, wtmp );
wk3r = sub( wk3r, wtmp );
@@ -1803,21 +2224,31 @@ static void cft1st(
x3r = L_sub( a[j + 4], a[j + 6] );
x3i = L_sub( a[j + 5], a[j + 7] );
a[j] = L_add( x0r, x2r );
+ move32();
a[j + 1] = L_add( x0i, x2i );
+ move32();
x0r = L_sub( x0r, x2r );
x0i = L_sub( x0i, x2i );
a[j + 4] = L_sub( Mpy_32_16_1( x0r, wk2r ), Mpy_32_16_1( x0i, wk2i ) );
+ move32();
a[j + 5] = L_add( Mpy_32_16_1( x0i, wk2r ), Mpy_32_16_1( x0r, wk2i ) );
+ move32();
x0r = L_sub( x1r, x3i );
x0i = L_add( x1i, x3r );
a[j + 2] = L_sub( Mpy_32_16_1( x0r, wk1r ), Mpy_32_16_1( x0i, wk1i ) );
+ move32();
a[j + 3] = L_add( Mpy_32_16_1( x0i, wk1r ), Mpy_32_16_1( x0r, wk1i ) );
+ move32();
x0r = L_add( x1r, x3i );
x0i = L_sub( x1i, x3r );
a[j + 6] = L_sub( Mpy_32_16_1( x0r, wk3r ), Mpy_32_16_1( x0i, wk3i ) );
+ move32();
a[j + 7] = L_add( Mpy_32_16_1( x0i, wk3r ), Mpy_32_16_1( x0r, wk3i ) );
+ move32();
wk1r = w[k2 + 2];
+ move16();
wk1i = w[k2 + 3];
+ move16();
wtmp = mult_r( wk2r, wk1i );
wk3r = sub( wk1r, wtmp );
wk3r = sub( wk3r, wtmp );
@@ -1833,19 +2264,26 @@ static void cft1st(
x3r = L_sub( a[j + 12], a[j + 14] );
x3i = L_sub( a[j + 13], a[j + 15] );
a[j + 8] = L_add( x0r, x2r );
+ move32();
a[j + 9] = L_add( x0i, x2i );
+ move32();
x0r = L_sub( x0r, x2r );
x0i = L_sub( x0i, x2i );
a[j + 12] = L_negate( L_add( Mpy_32_16_1( x0r, wk2i ), Mpy_32_16_1( x0i, wk2r ) ) );
+ move32();
a[j + 13] = L_sub( Mpy_32_16_1( x0r, wk2r ), Mpy_32_16_1( x0i, wk2i ) );
+ move32();
x0r = L_sub( x1r, x3i );
x0i = L_add( x1i, x3r );
a[j + 10] = L_sub( Mpy_32_16_1( x0r, wk1r ), Mpy_32_16_1( x0i, wk1i ) );
+ move32();
a[j + 11] = L_add( Mpy_32_16_1( x0i, wk1r ), Mpy_32_16_1( x0r, wk1i ) );
x0r = L_add( x1r, x3i );
x0i = L_sub( x1i, x3r );
a[j + 14] = L_sub( Mpy_32_16_1( x0r, wk3r ), Mpy_32_16_1( x0i, wk3i ) );
+ move32();
a[j + 15] = L_add( Mpy_32_16_1( x0i, wk3r ), Mpy_32_16_1( x0r, wk3i ) );
+ move32();
}
return;
@@ -1882,16 +2320,25 @@ static void cftmdl(
x3r = L_sub( a[j2], a[j3] );
x3i = L_sub( a[j2 + 1], a[j3 + 1] );
a[j] = L_add( x0r, x2r );
+ move32();
a[j + 1] = L_add( x0i, x2i );
+ move32();
a[j2] = L_sub( x0r, x2r );
+ move32();
a[j2 + 1] = L_sub( x0i, x2i );
+ move32();
a[j1] = L_sub( x1r, x3i );
+ move32();
a[j1 + 1] = L_add( x1i, x3r );
+ move32();
a[j3] = L_add( x1r, x3i );
+ move32();
a[j3 + 1] = L_sub( x1i, x3r );
+ move32();
}
wk1r = w[2];
+ move16();
FOR( j = m; j < l + m; j += 2 )
{
j1 = add( j, l );
@@ -1906,29 +2353,42 @@ static void cftmdl(
x3r = L_sub( a[j2], a[j3] );
x3i = L_sub( a[j2 + 1], a[j3 + 1] );
a[j] = L_add( x0r, x2r );
+ move32();
a[j + 1] = L_add( x0i, x2i );
+ move32();
a[j2] = L_sub( x2i, x0i );
+ move32();
a[j2 + 1] = L_sub( x0r, x2r );
+ move32();
x0r = L_sub( x1r, x3i );
x0i = L_add( x1i, x3r );
a[j1] = Mpy_32_16_1( L_sub( x0r, x0i ), wk1r );
+ move32();
a[j1 + 1] = Mpy_32_16_1( L_add( x0r, x0i ), wk1r );
+ move32();
x0r = L_add( x3i, x1r );
x0i = L_sub( x3r, x1i );
a[j3] = Mpy_32_16_1( L_sub( x0i, x0r ), wk1r );
+ move32();
a[j3 + 1] = Mpy_32_16_1( L_add( x0i, x0r ), wk1r );
+ move32();
}
k1 = 0;
+ move16();
m2 = shl( m, 1 );
FOR( k = m2; k < n; k += m2 )
{
k1 = add( k1, 2 );
k2 = shl( k1, 1 );
wk2r = w[k1];
+ move16();
wk2i = w[k1 + 1];
+ move16();
wk1r = w[k2];
+ move16();
wk1i = w[k2 + 1];
+ move16();
wtmp = mult_r( wk2i, wk1i );
wk3r = sub( wk1r, wtmp );
wk3r = sub( wk3r, wtmp );
@@ -1949,23 +2409,33 @@ static void cftmdl(
x3r = L_sub( a[j2], a[j3] );
x3i = L_sub( a[j2 + 1], a[j3 + 1] );
a[j] = L_add( x0r, x2r );
+ move32();
a[j + 1] = L_add( x0i, x2i );
+ move32();
x0r = L_sub( x0r, x2r );
x0i = L_sub( x0i, x2i );
a[j2] = L_sub( Mpy_32_16_1( x0r, wk2r ), Mpy_32_16_1( x0i, wk2i ) );
+ move32();
a[j2 + 1] = L_add( Mpy_32_16_1( x0i, wk2r ), Mpy_32_16_1( x0r, wk2i ) );
+ move32();
x0r = L_sub( x1r, x3i );
x0i = L_add( x1i, x3r );
a[j1] = L_sub( Mpy_32_16_1( x0r, wk1r ), Mpy_32_16_1( x0i, wk1i ) );
+ move32();
a[j1 + 1] = L_add( Mpy_32_16_1( x0i, wk1r ), Mpy_32_16_1( x0r, wk1i ) );
+ move32();
x0r = L_add( x1r, x3i );
x0i = L_sub( x1i, x3r );
a[j3] = L_sub( Mpy_32_16_1( x0r, wk3r ), Mpy_32_16_1( x0i, wk3i ) );
+ move32();
a[j3 + 1] = L_add( Mpy_32_16_1( x0i, wk3r ), Mpy_32_16_1( x0r, wk3i ) );
+ move32();
}
wk1r = w[k2 + 2];
+ move16();
wk1i = w[k2 + 3];
+ move16();
wtmp = mult_r( wk2r, wk1i );
wk3r = sub( wk1r, wtmp );
wk3r = sub( wk3r, wtmp );
@@ -1986,19 +2456,27 @@ static void cftmdl(
x3r = L_sub( a[j2], a[j3] );
x3i = L_sub( a[j2 + 1], a[j3 + 1] );
a[j] = L_add( x0r, x2r );
+ move32();
a[j + 1] = L_add( x0i, x2i );
+ move32();
x0r = L_sub( x0r, x2r );
x0i = L_sub( x0i, x2i );
a[j2] = L_negate( L_add( Mpy_32_16_1( x0r, wk2i ), Mpy_32_16_1( x0i, wk2r ) ) );
+ move32();
a[j2 + 1] = L_sub( Mpy_32_16_1( x0r, wk2r ), Mpy_32_16_1( x0i, wk2i ) );
+ move32();
x0r = L_sub( x1r, x3i );
x0i = L_add( x1i, x3r );
a[j1] = L_sub( Mpy_32_16_1( x0r, wk1r ), Mpy_32_16_1( x0i, wk1i ) );
+ move32();
a[j1 + 1] = L_add( Mpy_32_16_1( x0i, wk1r ), Mpy_32_16_1( x0r, wk1i ) );
+ move32();
x0r = L_add( x1r, x3i );
x0i = L_sub( x1i, x3r );
a[j3] = L_sub( Mpy_32_16_1( x0r, wk3r ), Mpy_32_16_1( x0i, wk3i ) );
+ move32();
a[j3 + 1] = L_add( Mpy_32_16_1( x0i, wk3r ), Mpy_32_16_1( x0r, wk3i ) );
+ move32();
}
}
@@ -2015,10 +2493,12 @@ static void cftbsub(
Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
l = 2;
+ move16();
IF( GT_16( n, 8 ) )
{
cft1st( n, a, w );
l = 8;
+ move16();
WHILE( LT_16( shl( l, 2 ), n ) )
{
@@ -2043,13 +2523,21 @@ static void cftbsub(
x3r = L_sub( a[j2], a[j3] );
x3i = L_sub( a[j2 + 1], a[j3 + 1] );
a[j] = L_add( x0r, x2r );
+ move32();
a[j + 1] = L_sub( x0i, x2i );
+ move32();
a[j2] = L_sub( x0r, x2r );
+ move32();
a[j2 + 1] = L_add( x0i, x2i );
+ move32();
a[j1] = L_sub( x1r, x3i );
+ move32();
a[j1 + 1] = L_sub( x1i, x3r );
+ move32();
a[j3] = L_add( x1r, x3i );
+ move32();
a[j3 + 1] = L_add( x1i, x3r );
+ move32();
}
}
ELSE
@@ -2060,9 +2548,13 @@ static void cftbsub(
x0r = L_sub( a[j], a[j1] );
x0i = L_sub( a[j1 + 1], a[j + 1] );
a[j] = L_add( a[j], a[j1] );
+ move32();
a[j + 1] = L_negate( L_add( a[j + 1], a[j1 + 1] ) );
+ move32();
a[j1] = x0r;
+ move32();
a[j1 + 1] = x0i;
+ move32();
}
}
@@ -2080,22 +2572,28 @@ static void rftfsub(
Word32 xr, xi, yr, yi;
m = shr( n, 1 );
- ks = 2 * nc / m;
+ ks = idiv1616( shl( nc, 1 ), m );
kk = 0;
+ move16();
FOR( j = 2; j < m; j += 2 )
{
k = sub( n, j );
kk = add( kk, ks );
- wkr = sub( (Word16) 0x4000, c[nc - kk] );
+ wkr = sub( (Word16) 0x4000, c[sub( nc, kk )] );
wki = c[kk];
+ move16();
xr = L_sub( a[j], a[k] );
xi = L_add( a[j + 1], a[k + 1] );
yr = L_sub( Mpy_32_16_1( xr, wkr ), Mpy_32_16_1( xi, wki ) );
yi = L_add( Mpy_32_16_1( xi, wkr ), Mpy_32_16_1( xr, wki ) );
a[j] = L_sub( a[j], yr );
+ move32();
a[j + 1] = L_sub( a[j + 1], yi );
+ move32();
a[k] = L_add( a[k], yr );
+ move32();
a[k + 1] = L_sub( a[k + 1], yi );
+ move32();
}
return;
@@ -2112,23 +2610,29 @@ static void rftbsub(
Word16 wkr, wki;
Word32 xr, xi, yr, yi;
a[1] = L_negate( a[1] );
+ move32();
m = shr( n, 1 );
- ks = 2 * nc / m;
+ ks = idiv1616( shl( nc, 1 ), m );
kk = 0;
+ move16();
FOR( j = 2; j < m; j += 2 )
{
- k = n - j;
- kk += ks;
- wkr = sub( (Word16) 0x4000, c[nc - kk] );
+ k = sub( n, j );
+ kk = add( kk, ks );
+ wkr = sub( (Word16) 0x4000, c[sub( nc, kk )] );
wki = c[kk];
xr = L_sub( a[j], a[k] );
xi = L_add( a[j + 1], a[k + 1] );
yr = L_add( Mpy_32_16_1( xr, wkr ), Mpy_32_16_1( xi, wki ) );
yi = L_sub( Mpy_32_16_1( xi, wkr ), Mpy_32_16_1( xr, wki ) );
a[j] = L_sub( a[j], yr );
+ move32();
a[j + 1] = L_sub( yi, a[j + 1] );
+ move32();
a[k] = L_add( a[k], yr );
+ move32();
a[k + 1] = L_sub( yi, a[k + 1] );
+ move32();
}
a[m + 1] = L_negate( a[m + 1] );
@@ -2147,19 +2651,23 @@ static void dctsub(
Word32 xr;
m = shr( n, 1 );
- ks = nc / n;
+ ks = idiv1616( nc, n );
kk = 0;
+ move16();
FOR( j = 1; j < m; j++ )
{
k = sub( n, j );
- kk += ks;
- wkr = sub( c[kk], c[nc - kk] );
- wki = add( c[kk], c[nc - kk] );
+ kk = add( kk, ks );
+ wkr = sub( c[kk], c[sub( nc, kk )] );
+ wki = add( c[kk], c[sub( nc, kk )] );
xr = L_sub( Mpy_32_16_1( a[j], wki ), Mpy_32_16_1( a[k], wkr ) );
a[j] = L_add( Mpy_32_16_1( a[j], wkr ), Mpy_32_16_1( a[k], wki ) );
+ move32();
a[k] = xr;
+ move32();
}
a[m] = Mpy_32_16_1( a[m], c[0] );
+ move32();
return;
}
@@ -2185,26 +2693,34 @@ void edct2_fx_ivas(
Copy32( in, a, n );
nw = ip[0];
- IF( GT_16( n, shl( nw, 2 ) ) )
+ move16();
+ if ( GT_16( n, shl( nw, 2 ) ) )
{
nw = shr( n, 2 );
}
nc = ip[1];
- IF( GT_16( n, nc ) )
+ move16();
+ if ( GT_16( n, nc ) )
{
nc = n;
+ move16();
}
- IF( LT_16( isgn, 0 ) )
+ IF( isgn < 0 )
{
xr = a[n - 1];
+ move16();
FOR( j = n - 2; j >= 2; j -= 2 )
{
a[j + 1] = L_sub( a[j], a[j - 1] );
+ move32();
a[j] = L_add( a[j], a[j - 1] );
+ move32();
}
a[1] = L_sub( a[0], xr );
+ move32();
a[0] = L_add( a[0], xr );
+ move32();
IF( GT_16( n, 4 ) )
{
@@ -2218,14 +2734,15 @@ void edct2_fx_ivas(
}
}
- IF( GE_16( isgn, 0 ) )
+ IF( isgn >= 0 )
{
a[0] = L_shr( a[0], 1 );
+ move32();
}
dctsub( n, a, nc, w + nw );
- IF( GE_16( isgn, 0 ) )
+ IF( isgn >= 0 )
{
IF( GT_16( n, 4 ) )
{
@@ -2239,16 +2756,21 @@ void edct2_fx_ivas(
}
xr = L_sub( a[0], a[1] );
a[0] = L_add( a[0], a[1] );
+ move32();
FOR( j = 2; j < n; j += 2 )
{
a[j - 1] = L_sub( a[j], a[j + 1] );
+ move32();
a[j] = L_add( a[j], a[j + 1] );
+ move32();
}
a[n - 1] = xr;
+ move32();
FOR( j = 0; j < n; j++ )
{
a[j] = L_shr( a[j], 5 );
+ move32();
}
}
}
@@ -2266,7 +2788,9 @@ void DoRTFTn_fx_ivas(
FOR( i = 0; i < n; i++ )
{
z[2 * i] = x[i];
- z[2 * i + 1] = y[i];
+ move32();
+ z[add( shl( i, 1 ), 1 )] = y[i];
+ move32();
}
SWITCH( n )
@@ -2294,11 +2818,15 @@ void DoRTFTn_fx_ivas(
}
x[0] = z[0];
+ move32();
y[0] = z[1];
+ move32();
FOR( i = 1; i < n; i++ )
{
- x[n - i] = z[2 * i];
- y[n - i] = z[2 * i + 1];
+ x[sub( n, i )] = z[2 * i];
+ move32();
+ y[sub( n, i )] = z[add( shl( i, 1 ), 1 )];
+ move32();
}
return;
@@ -2322,22 +2850,31 @@ void fft3_fx_ivas(
/* Determine the order of the transform, the length of decimated */
/* transforms m, and the step for the sine and cosine tables. */
- switch ( n )
+ SWITCH( n )
{
case 1536:
order = 9;
+ move16();
m = 512;
+ move16();
step = 1;
- break;
+ move16();
+ BREAK;
case 384:
order = 7;
+ move16();
m = 128;
+ move16();
step = 4;
- break;
+ move16();
+ BREAK;
default:
order = 9;
+ move16();
m = 512;
+ move16();
step = 1;
+ move16();
}
/* Compose decimated sequences X[3i], X[3i+1],X[3i+2] */
@@ -2352,8 +2889,11 @@ void fft3_fx_ivas(
FOR( i = 0; i < n / 3; i++ )
{
*z0++ = *x++; /* Z0[i] = X[3i]; */
+ move32();
*z1++ = *x++; /* Z1[i] = X[3i+1]; */
+ move32();
*z2++ = *x++; /* Z2[i] = X[3i+2]; */
+ move32();
}
fft_rel_fx32( &Z0[0], m, order );
@@ -2373,49 +2913,59 @@ void fft3_fx_ivas(
c1_step = negate( step );
s1_step = step;
+ move16();
c2_step = negate( shl( step, 1 ) );
s2_step = shl( step, 1 );
c1_ind = add( T_SIN_PI_2, c1_step );
s1_ind = s1_step;
+ move16();
c2_ind = add( T_SIN_PI_2, c2_step );
s2_ind = s2_step;
+ move16();
/* special case: i = 0 */
RY[0] = L_add( RZ0[0], L_add( RZ1[0], RZ2[0] ) );
+ move32();
/* first 3/12 */
- for ( i = 1; i < 3 * m / 8; i++, c1_ind = add( c1_ind, c1_step ), s1_ind = add( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ) )
+ FOR( i = 1; i < i_mult( 3, shr( m, 3 ) ); ( i++, c1_ind = add( c1_ind, c1_step ), s1_ind = add( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ) ) )
{
RY[i] = L_add( RZ0[i], L_add( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ),
L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ),
L_add( Mpy_32_16_1( RZ2[i], t_sin[c2_ind] ),
Mpy_32_16_1( IZ2[-i], t_sin[s2_ind] ) ) ) ) );
+ move32();
IY[-i] = L_sub( IZ0[-i], L_add( L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ),
Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ) ),
L_sub( Mpy_32_16_1( RZ2[i], t_sin[s2_ind] ),
Mpy_32_16_1( IZ2[-i], t_sin[c2_ind] ) ) ) );
+ move32();
}
/* next 1/12 */
- for ( ; i < 4 * m / 8; i++, c1_ind = add( c1_ind, c1_step ), s1_ind = add( s1_ind, s1_step ), c2_ind = sub( c2_ind, c2_step ), s2_ind = sub( s2_ind, s2_step ) )
+ FOR( ; i < 4 * m / 8; ( i++, c1_ind = add( c1_ind, c1_step ), s1_ind = add( s1_ind, s1_step ), c2_ind = sub( c2_ind, c2_step ), s2_ind = sub( s2_ind, s2_step ) ) )
{
RY[i] = L_add( RZ0[i], L_sub( L_add( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ),
Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ) ),
L_sub( Mpy_32_16_1( RZ2[i], t_sin[c2_ind] ),
Mpy_32_16_1( IZ2[-i], t_sin[s2_ind] ) ) ) );
+ move32();
IY[-i] = L_sub( IZ0[-i], L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ),
L_sub( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ),
L_add( Mpy_32_16_1( RZ2[i], t_sin[s2_ind] ),
Mpy_32_16_1( IZ2[-i], t_sin[c2_ind] ) ) ) ) );
+ move32();
}
/* special case: i = m/2 i.e. 1/3 */
RY[i] = L_add( RZ0[i],
L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ),
Mpy_32_16_1( RZ2[i], t_sin[c2_ind] ) ) );
+ move32();
IY[-i] = L_negate( L_add( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ),
Mpy_32_16_1( RZ2[i], t_sin[s2_ind] ) ) );
- i++;
+ move32();
+ i = add( i, 1 );
c1_ind = add( c1_ind, c1_step );
s1_ind = add( s1_ind, s1_step );
@@ -2423,69 +2973,81 @@ void fft3_fx_ivas(
s2_ind = sub( s2_ind, s2_step );
/* next 2/12 */
- for ( j = i - 2; i < 6 * m / 8; i++, j--, c1_ind = add( c1_ind, c1_step ), s1_ind = add( s1_ind, s1_step ), c2_ind = sub( c2_ind, c2_step ), s2_ind = sub( s2_ind, s2_step ) )
+ FOR( j = i - 2; i < 6 * m / 8; ( i++, j--, c1_ind = add( c1_ind, c1_step ), s1_ind = add( s1_ind, s1_step ), c2_ind = sub( c2_ind, c2_step ), s2_ind = sub( s2_ind, s2_step ) ) )
{
RY[i] = L_add( RZ0[j], L_sub( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ),
L_add( Mpy_32_16_1( IZ1[-j], t_sin[s1_ind] ),
L_add( Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ),
Mpy_32_16_1( IZ2[-j], t_sin[s2_ind] ) ) ) ) );
+ move32();
IY[-i] = L_negate( L_add( IZ0[-j], L_add( Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ),
L_add( Mpy_32_16_1( IZ1[-j], t_sin[c1_ind] ),
L_sub( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ),
Mpy_32_16_1( IZ2[-j], t_sin[c2_ind] ) ) ) ) ) );
+ move32();
}
/*--------------------------half--------------------------*/
/* next 2/12 */
- for ( ; i < 8 * m / 8; i++, j--, c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ) )
+ FOR( ; i < 8 * m / 8; ( i++, j--, c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ) ) )
{
RY[i] = L_sub( RZ0[j], L_add( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ),
L_add( Mpy_32_16_1( IZ1[-j], t_sin[s1_ind] ),
L_sub( Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ),
Mpy_32_16_1( IZ2[-j], t_sin[s2_ind] ) ) ) ) );
+ move32();
IY[-i] = L_negate( L_add( IZ0[-j], L_sub( Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ),
L_add( Mpy_32_16_1( IZ1[-j], t_sin[c1_ind] ),
L_add( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ),
Mpy_32_16_1( IZ2[-j], t_sin[c2_ind] ) ) ) ) ) );
+ move32();
}
/* special case: i = m, i.e 2/3 */
RY[i] = L_sub( RZ0[j], L_add( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ),
Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ) ) );
- IY[-i++] = L_sub( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ),
- Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ) );
+ move32();
+ IY[-i] = L_sub( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ),
+ Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ) );
+ move32();
+ i = add( i, 1 );
c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step );
/* next 1/12 */
- for ( j = 1; i < 9 * m / 8; i++, j++, c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ) )
+ FOR( j = 1; i < i_mult( 9, shr( m, 3 ) ); ( i++, j++, c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = add( c2_ind, c2_step ), s2_ind = add( s2_ind, s2_step ) ) )
{
RY[i] = L_sub( RZ0[j], L_sub( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ),
L_sub( Mpy_32_16_1( IZ1[-j], t_sin[s1_ind] ),
L_add( Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ),
Mpy_32_16_1( IZ2[-j], t_sin[s2_ind] ) ) ) ) );
+ move32();
IY[-i] = L_sub( IZ0[-j], L_add( Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ),
L_sub( Mpy_32_16_1( IZ1[-j], t_sin[c1_ind] ),
L_sub( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ),
Mpy_32_16_1( IZ2[-j], t_sin[c2_ind] ) ) ) ) );
+ move32();
}
/* last 3/12 */
- for ( ; i < 12 * m / 8; i++, j++, c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = sub( c2_ind, c2_step ), s2_ind = sub( s2_ind, s2_step ) )
+ FOR( ; i < 12 * m / 8; ( i++, j++, c1_ind = sub( c1_ind, c1_step ), s1_ind = sub( s1_ind, s1_step ), c2_ind = sub( c2_ind, c2_step ), s2_ind = sub( s2_ind, s2_step ) ) )
{
RY[i] = L_sub( RZ0[j], L_sub( L_sub( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ),
Mpy_32_16_1( IZ1[-j], t_sin[s1_ind] ) ),
L_sub( Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ),
Mpy_32_16_1( IZ2[-j], t_sin[s2_ind] ) ) ) );
+ move32();
IY[-i] = L_sub( IZ0[-j], L_sub( L_add( Mpy_32_16_1( RZ1[j], t_sin[s1_ind] ),
Mpy_32_16_1( IZ1[-j], t_sin[c1_ind] ) ),
L_add( Mpy_32_16_1( RZ2[j], t_sin[s2_ind] ),
Mpy_32_16_1( IZ2[-j], t_sin[c2_ind] ) ) ) );
+ move32();
}
/* special case: i = 3*m/2 */
RY[i] = L_sub( RZ0[j], L_sub( Mpy_32_16_1( RZ1[j], t_sin[c1_ind] ),
Mpy_32_16_1( RZ2[j], t_sin[c2_ind] ) ) );
+ move32();
return;
}
@@ -2506,22 +3068,31 @@ void ifft3_fx_ivas(
/* Determine the order of the transform, the length of decimated */
/* transforms m, and the step for the sine and cosine tables. */
- switch ( n )
+ SWITCH( n )
{
case 1536:
order = 9;
+ move16();
m = 512;
+ move16();
step = 1;
- break;
+ move16();
+ BREAK;
case 384:
order = 7;
+ move16();
m = 128;
+ move16();
step = 4;
- break;
+ move16();
+ BREAK;
default:
order = 9;
+ move16();
m = 512;
+ move16();
step = 1;
+ move16();
}
/* pointer initialization */
@@ -2534,23 +3105,27 @@ void ifft3_fx_ivas(
RZ0 = &Z[0];
RZ1 = RZ0 + m;
- RZ2 = RZ0 + n / 2 - m / 2;
+ RZ2 = RZ0 + sub( shr( n, 1 ), shr( m, 1 ) );
IZ0 = &Z[n];
IZ1 = IZ0 - m;
- IZ2 = IZ0 - n / 2 + m / 2;
+ IZ2 = IZ0 - sub( shr( n, 1 ), shr( m, 1 ) );
/* Inverse butterflies of order 3. */
/* Construction of Y0 */
RY0[0] = L_add( RZ0[0], L_add( RZ1[0], RZ2[0] ) );
+ move32();
FOR( i = 1; i < m / 2; i++ )
{
RY0[i] = L_add( RZ0[i], L_add( RZ1[i], RZ2[-i] ) );
+ move32();
IY0[-i] = L_add( IZ0[-i], L_sub( IZ1[-i], IZ2[i] ) );
+ move32();
}
/* m/2 */
RY0[i] = L_add( RZ0[i], L_add( RZ1[i], RZ2[-i] ) );
+ move32();
/* Construction of Y1 */
c0_ind = T_SIN_PI_2;
@@ -2565,6 +3140,7 @@ void ifft3_fx_ivas(
L_add( Mpy_32_16_1( RZ2[0], t_sin[c2_ind] ),
L_add( Mpy_32_16_1( IZ1[0], t_sin[s1_ind] ),
Mpy_32_16_1( IZ2[0], t_sin[s2_ind] ) ) ) ) );
+ move32();
c0_ind = sub( c0_ind, step );
s0_ind = add( s0_ind, step );
@@ -2572,7 +3148,7 @@ void ifft3_fx_ivas(
s1_ind = sub( s1_ind, step );
c2_ind = sub( c2_ind, step );
s2_ind = add( s2_ind, step );
- for ( i = 1; i < m / 4; i++, c0_ind = sub( c0_ind, step ), s0_ind = add( s0_ind, step ), c1_ind = add( c1_ind, step ), s1_ind = sub( s1_ind, step ), c2_ind = sub( c2_ind, step ), s2_ind = add( s2_ind, step ) )
+ FOR( i = 1; i < m / 4; ( i++, c0_ind = sub( c0_ind, step ), s0_ind = add( s0_ind, step ), c1_ind = add( c1_ind, step ), s1_ind = sub( s1_ind, step ), c2_ind = sub( c2_ind, step ), s2_ind = add( s2_ind, step ) ) )
{
RY1[i] = L_sub( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ),
L_add( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ),
@@ -2580,15 +3156,17 @@ void ifft3_fx_ivas(
L_add( Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ),
L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ),
Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) ) );
+ move32();
IY1[-i] = L_add( L_sub( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ),
Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ) ),
L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ),
L_add( Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ),
L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ),
Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ) );
+ move32();
}
- for ( ; i < m / 2; i++, c0_ind = sub( c0_ind, step ), s0_ind = add( s0_ind, step ), c1_ind = add( c1_ind, step ), s1_ind = sub( s1_ind, step ), c2_ind = add( c2_ind, step ), s2_ind = sub( s2_ind, step ) )
+ FOR( ; i < m / 2; ( i++, c0_ind = sub( c0_ind, step ), s0_ind = add( s0_ind, step ), c1_ind = add( c1_ind, step ), s1_ind = sub( s1_ind, step ), c2_ind = add( c2_ind, step ), s2_ind = sub( s2_ind, step ) ) )
{
RY1[i] = L_sub( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ),
L_add( L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ),
@@ -2596,12 +3174,14 @@ void ifft3_fx_ivas(
L_add( Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ),
L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ),
Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) );
+ move32();
IY1[-i] = L_sub( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ),
L_sub( L_add( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ),
Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ) ),
L_add( Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ),
L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ),
Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ) );
+ move32();
}
/* m/2 */
@@ -2611,20 +3191,28 @@ void ifft3_fx_ivas(
L_add( Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ),
L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ),
Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) );
+ move32();
/* Construction of Y2 */
c0_ind = T_SIN_PI_2;
+ move16();
s0_ind = 0;
+ move16();
c1_ind = T_SIN_PI_2 * 1 / 3;
+ move16();
s1_ind = T_SIN_PI_2 * 2 / 3;
+ move16();
c2_ind = T_SIN_PI_2 * 1 / 3;
+ move16();
s2_ind = T_SIN_PI_2 * 2 / 3;
- step2 = 2 * step;
+ move16();
+ step2 = shl( step, 1 );
RY2[0] = L_sub( Mpy_32_16_1( RZ0[0], t_sin[c0_ind] ),
L_sub( L_add( Mpy_32_16_1( RZ1[0], t_sin[c1_ind] ),
Mpy_32_16_1( RZ2[0], t_sin[c2_ind] ) ),
L_add( Mpy_32_16_1( IZ1[0], t_sin[s1_ind] ),
Mpy_32_16_1( IZ2[0], t_sin[s2_ind] ) ) ) );
+ move32();
c0_ind = sub( c0_ind, step2 );
s0_ind = add( s0_ind, step2 );
@@ -2632,7 +3220,7 @@ void ifft3_fx_ivas(
s1_ind = add( s1_ind, step2 );
c2_ind = add( c2_ind, step2 );
s2_ind = sub( s2_ind, step2 );
- for ( i = 1; i < m / 8; i++, c0_ind = sub( c0_ind, step2 ), s0_ind = add( s0_ind, step2 ), c1_ind = sub( c1_ind, step2 ), s1_ind = add( s1_ind, step2 ), c2_ind = add( c2_ind, step2 ), s2_ind = sub( s2_ind, step2 ) )
+ FOR( i = 1; i < m / 8; ( i++, c0_ind = sub( c0_ind, step2 ), s0_ind = add( s0_ind, step2 ), c1_ind = sub( c1_ind, step2 ), s1_ind = add( s1_ind, step2 ), c2_ind = add( c2_ind, step2 ), s2_ind = sub( s2_ind, step2 ) ) )
{
RY2[i] = L_sub( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ),
L_add( L_add( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ),
@@ -2640,15 +3228,17 @@ void ifft3_fx_ivas(
L_sub( Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ),
L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ),
Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) );
+ move32();
IY2[-i] = L_add( L_sub( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ),
Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ) ),
L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ),
L_sub( Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ),
L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ),
Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ) );
+ move32();
}
- for ( ; i < m / 4; i++, c0_ind = sub( c0_ind, step2 ), s0_ind = add( s0_ind, step2 ), c1_ind = add( c1_ind, step2 ), s1_ind = sub( s1_ind, step2 ), c2_ind = add( c2_ind, step2 ), s2_ind = sub( s2_ind, step2 ) )
+ FOR( ; i < m / 4; ( i++, c0_ind = sub( c0_ind, step2 ), s0_ind = add( s0_ind, step2 ), c1_ind = add( c1_ind, step2 ), s1_ind = sub( s1_ind, step2 ), c2_ind = add( c2_ind, step2 ), s2_ind = sub( s2_ind, step2 ) ) )
{
RY2[i] = L_add( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ),
L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ),
@@ -2656,15 +3246,17 @@ void ifft3_fx_ivas(
Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ) ),
L_add( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ),
Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) ) );
+ move32();
IY2[-i] = L_add( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ),
L_add( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ),
L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ),
L_sub( Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ),
L_sub( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ),
Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) ) ) );
+ move32();
}
- for ( ; i < 3 * m / 8; i++, c0_ind = sub( c0_ind, step2 ), s0_ind = add( s0_ind, step2 ), c1_ind = add( c1_ind, step2 ), s1_ind = sub( s1_ind, step2 ), c2_ind = sub( c2_ind, step2 ), s2_ind = add( s2_ind, step2 ) )
+ FOR( ; i < i_mult( 3, shr( m, 3 ) ); ( i++, c0_ind = sub( c0_ind, step2 ), s0_ind = add( s0_ind, step2 ), c1_ind = add( c1_ind, step2 ), s1_ind = sub( s1_ind, step2 ), c2_ind = sub( c2_ind, step2 ), s2_ind = add( s2_ind, step2 ) ) )
{
RY2[i] = L_sub( L_add( Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ),
Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ) ),
@@ -2672,15 +3264,17 @@ void ifft3_fx_ivas(
Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ) ),
L_sub( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ),
Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) );
+ move32();
IY2[-i] = L_sub( L_add( Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ),
L_add( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ),
L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ),
Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ) ) ) ),
L_add( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ),
Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) );
+ move32();
}
- for ( ; i < m / 2; i++, c0_ind = add( c0_ind, step2 ), s0_ind = sub( s0_ind, step2 ), c1_ind = add( c1_ind, step2 ), s1_ind = sub( s1_ind, step2 ), c2_ind = sub( c2_ind, step2 ), s2_ind = add( s2_ind, step2 ) )
+ FOR( ; i < m / 2; ( i++, c0_ind = add( c0_ind, step2 ), s0_ind = sub( s0_ind, step2 ), c1_ind = add( c1_ind, step2 ), s1_ind = sub( s1_ind, step2 ), c2_ind = sub( c2_ind, step2 ), s2_ind = add( s2_ind, step2 ) ) )
{
RY2[i] = L_sub( L_sub( Mpy_32_16_1( RZ1[i], t_sin[c1_ind] ),
Mpy_32_16_1( RZ0[i], t_sin[c0_ind] ) ),
@@ -2688,12 +3282,14 @@ void ifft3_fx_ivas(
Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ) ),
L_sub( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ),
Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) );
+ move32();
IY2[-i] = L_add( L_sub( Mpy_32_16_1( IZ1[-i], t_sin[c1_ind] ),
Mpy_32_16_1( IZ0[-i], t_sin[c0_ind] ) ),
L_sub( L_add( Mpy_32_16_1( IZ2[i], t_sin[c2_ind] ),
Mpy_32_16_1( RZ0[i], t_sin[s0_ind] ) ),
L_add( Mpy_32_16_1( RZ1[i], t_sin[s1_ind] ),
Mpy_32_16_1( RZ2[-i], t_sin[s2_ind] ) ) ) );
+ move32();
}
/* m/2 */
@@ -2703,6 +3299,7 @@ void ifft3_fx_ivas(
Mpy_32_16_1( IZ0[-i], t_sin[s0_ind] ) ),
L_sub( Mpy_32_16_1( IZ1[-i], t_sin[s1_ind] ),
Mpy_32_16_1( IZ2[i], t_sin[s2_ind] ) ) ) );
+ move32();
/* Compute the inverse FFT for all 3 blocks. */
ifft_rel_fx32( RY0, m, order );
@@ -2717,9 +3314,15 @@ void ifft3_fx_ivas(
scale = (Word16) ( 0x2AAB );
FOR( i = 0; i < n; )
{
- X[i++] = Mpy_32_16_1( ( *y0++ ), scale );
- X[i++] = Mpy_32_16_1( ( *y1++ ), scale );
- X[i++] = Mpy_32_16_1( ( *y2++ ), scale );
+ X[i] = Mpy_32_16_1( ( *y0++ ), scale );
+ move32();
+ i = add( i, 1 );
+ X[i] = Mpy_32_16_1( ( *y1++ ), scale );
+ move32();
+ i = add( i, 1 );
+ X[i] = Mpy_32_16_1( ( *y2++ ), scale );
+ move32();
+ i = add( i, 1 );
}
return;
@@ -2734,27 +3337,36 @@ static void rfft_post(
Word32 tmp1, tmp2, tmp3, tmp4;
Word16 s, c;
Word16 i = 0;
+ move16();
tmp1 = L_add( buf[0], buf[1] );
buf[1] = L_sub( buf[0], buf[1] );
+ move32();
buf[0] = tmp1;
+ move32();
- FOR( i = 1; i <= ( len + 2 ) / 4; i++ )
+ FOR( i = 1; i <= shr( add( len, 2 ), 2 ); i++ )
{
- s = sine_table[i]; /* sin(pi*i/(len/2)) */
- c = sine_table[i + len / 4]; /* cos(pi*i/(len/2)) */
+ s = sine_table[i]; /* sin(pi*i/(len/2)) */
+ move16();
+ c = sine_table[add( i, shr( len, 2 ) )]; /* cos(pi*i/(len/2)) */
+ move16();
- tmp1 = L_sub( buf[2 * i], buf[len - 2 * i] );
- tmp2 = L_add( buf[2 * i + 1], buf[len - 2 * i + 1] );
+ tmp1 = L_sub( buf[2 * i], buf[sub( len, shl( i, 1 ) )] );
+ tmp2 = L_add( buf[add( shl( i, 1 ), 1 )], buf[add( sub( len, shl( i, 1 ) ), 1 )] );
tmp3 = L_sub( Mpy_32_16_1( tmp1, s ), Mpy_32_16_1( tmp2, c ) ); /* real part of j*W(k,N)*[T(k) - T'(N-k)] */
tmp4 = L_add( Mpy_32_16_1( tmp1, c ), Mpy_32_16_1( tmp2, s ) ); /* imag part of j*W(k,N)*[T(k) - T'(N-k)] */
- tmp1 = L_add( buf[2 * i], buf[len - 2 * i] );
- tmp2 = L_sub( buf[2 * i + 1], buf[len - 2 * i + 1] );
+ tmp1 = L_add( buf[2 * i], buf[sub( len, shl( i, 1 ) )] );
+ tmp2 = L_sub( buf[add( shl( i, 1 ), 1 )], buf[add( sub( len, shl( i, 1 ) ), 1 )] );
buf[2 * i] = L_shr( L_sub( tmp1, tmp3 ), 1 );
- buf[2 * i + 1] = L_shr( L_sub( tmp2, tmp4 ), 1 );
- buf[len - 2 * i] = L_shr( L_add( tmp1, tmp3 ), 1 );
- buf[len - 2 * i + 1] = L_negate( L_shr( L_add( tmp2, tmp4 ), 1 ) );
+ move32();
+ buf[add( shl( i, 1 ), 1 )] = L_shr( L_sub( tmp2, tmp4 ), 1 );
+ move32();
+ buf[sub( len, shl( i, 1 ) )] = L_shr( L_add( tmp1, tmp3 ), 1 );
+ move32();
+ buf[add( sub( len, shl( i, 1 ) ), 1 )] = L_negate( L_shr( L_add( tmp2, tmp4 ), 1 ) );
+ move32();
}
}
@@ -2770,24 +3382,32 @@ static void rfft_pre(
tmp1 = L_add( buf[0], buf[1] );
buf[1] = Mpy_32_16_1( L_sub( buf[0], buf[1] ), scale );
+ move32();
buf[0] = Mpy_32_16_1( tmp1, scale );
+ move32();
- FOR( i = 1; i <= ( len + 2 ) / 4; i++ )
+ FOR( i = 1; i <= shr( add( len, 2 ), 2 ); i++ )
{
- s = sine_table[i]; /* sin(pi*i/(len/2)) */
- c = sine_table[i + len / 4]; /* cos(pi*i/(len/2)) */
+ s = sine_table[i]; /* sin(pi*i/(len/2)) */
+ move16();
+ c = sine_table[add( i, shr( len, 2 ) )]; /* cos(pi*i/(len/2)) */
+ move16();
- tmp1 = L_sub( buf[2 * i], buf[len - 2 * i] );
- tmp2 = L_add( buf[2 * i + 1], buf[len - 2 * i + 1] );
+ tmp1 = L_sub( buf[2 * i], buf[sub( len, shl( i, 1 ) )] );
+ tmp2 = L_add( buf[add( shl( i, 1 ), 1 )], buf[add( sub( len, shl( i, 1 ) ), 1 )] );
tmp3 = L_add( Mpy_32_16_1( tmp1, s ), Mpy_32_16_1( tmp2, c ) ); /* real part of j*W(k,N)*[T(k) - T'(N-k)] */
tmp4 = L_sub( Mpy_32_16_1( tmp2, s ), Mpy_32_16_1( tmp1, c ) ); /* imag part of j*W(k,N)*[T(k) - T'(N-k)] */
- tmp1 = L_add( buf[2 * i], buf[len - 2 * i] );
- tmp2 = L_sub( buf[2 * i + 1], buf[len - 2 * i + 1] );
+ tmp1 = L_add( buf[2 * i], buf[sub( len, shl( i, 1 ) )] );
+ tmp2 = L_sub( buf[add( shl( i, 1 ), 1 )], buf[add( sub( len, shl( i, 1 ) ), 1 )] );
buf[2 * i] = Mpy_32_16_1( L_add( tmp1, tmp3 ), scale );
- buf[2 * i + 1] = L_negate( Mpy_32_16_1( L_add( tmp2, tmp4 ), scale ) );
- buf[len - 2 * i] = Mpy_32_16_1( L_sub( tmp1, tmp3 ), scale );
- buf[len - 2 * i + 1] = Mpy_32_16_1( L_sub( tmp2, tmp4 ), scale );
+ move32();
+ buf[add( shl( i, 1 ), 1 )] = L_negate( Mpy_32_16_1( L_add( tmp2, tmp4 ), scale ) );
+ move32();
+ buf[sub( len, shl( i, 1 ) )] = Mpy_32_16_1( L_sub( tmp1, tmp3 ), scale );
+ move32();
+ buf[add( sub( len, shl( i, 1 ) ), 1 )] = Mpy_32_16_1( L_sub( tmp2, tmp4 ), scale );
+ move32();
}
return;
@@ -2814,13 +3434,17 @@ Word16 RFFTN_fx(
FOR( i = 0; i < 320; i++ )
{
x[i] = data[2 * i];
- y[i] = data[2 * i + 1];
+ move32();
+ y[i] = data[add( shl( i, 1 ), 1 )];
+ move32();
}
DoRTFT320_fx( x, y );
FOR( i = 0; i < 320; i++ )
{
data[2 * i] = x[i];
- data[2 * i + 1] = y[i];
+ move32();
+ data[add( shl( i, 1 ), 1 )] = y[i];
+ move32();
}
IF( EQ_16( sign, -1 ) )
@@ -2834,27 +3458,36 @@ Word16 RFFTN_fx(
{
Word16 i;
const Word16 log2 = 9;
+ move16();
Word32 reordered_data[512];
IF( EQ_16( sign, -1 ) )
{
fft_rel_fx32( data, len, log2 );
reordered_data[0] = data[0];
+ move32();
reordered_data[1] = data[len / 2];
+ move32();
FOR( i = 1; i < len / 2; i++ )
{
reordered_data[2 * i] = data[i];
- reordered_data[2 * i + 1] = data[len - i];
+ move32();
+ reordered_data[add( shl( i, 1 ), 1 )] = data[sub( len, i )];
+ move32();
}
}
ELSE
{
reordered_data[0] = data[0];
+ move32();
reordered_data[len / 2] = data[1];
+ move32();
FOR( i = 1; i < len / 2; i++ )
{
reordered_data[i] = data[2 * i];
- reordered_data[len - i] = data[2 * i + 1];
+ move32();
+ reordered_data[sub( len, i )] = data[add( shl( i, 1 ), 1 )];
+ move32();
}
ifft_rel_fx32( reordered_data, len, log2 );
}
@@ -2876,7 +3509,9 @@ static void butterfly(
Word32 *aMinusb )
{
*aPlusb = L_add( a, b );
+ move32();
*aMinusb = L_sub( a, b );
+ move32();
return;
}
@@ -2892,14 +3527,22 @@ static void fft2(
Word32 re2, im2;
re1 = pInOut[0];
+ move32();
im1 = pInOut[1];
+ move32();
re2 = pInOut[2];
+ move32();
im2 = pInOut[3];
+ move32();
pInOut[0] = L_add( re1, re2 );
+ move32();
pInOut[1] = L_add( im1, im2 );
+ move32();
pInOut[2] = L_sub( re1, re2 );
+ move32();
pInOut[3] = L_sub( im1, im2 );
+ move32();
return;
}
@@ -2917,11 +3560,17 @@ static void fft3_2( Word32 *pInOut )
Word32 tmp3, tmp4;
re1 = pInOut[0];
+ move32();
im1 = pInOut[1];
+ move32();
re2 = pInOut[2];
+ move32();
im2 = pInOut[3];
+ move32();
re3 = pInOut[4];
+ move32();
im3 = pInOut[5];
+ move32();
/* FFT MATRIX:
1.0000 1.0000 1.0000
@@ -2934,12 +3583,18 @@ static void fft3_2( Word32 *pInOut )
tmp2 = L_sub( re2, re3 );
tmp4 = L_sub( im2, im3 );
pInOut[0] = L_add( re1, tmp1 );
+ move32();
pInOut[1] = L_add( im1, tmp3 );
+ move32();
pInOut[2] = L_sub( re1, L_sub( Mpy_32_16_1( tmp1, C31 ), Mpy_32_16_1( tmp4, C32 ) ) );
+ move32();
pInOut[4] = L_sub( re1, L_add( Mpy_32_16_1( tmp1, C31 ), Mpy_32_16_1( tmp4, C32 ) ) );
+ move32();
pInOut[3] = L_sub( im1, L_add( Mpy_32_16_1( tmp2, C32 ), Mpy_32_16_1( tmp3, C31 ) ) );
+ move32();
pInOut[5] = L_add( im1, L_sub( Mpy_32_16_1( tmp2, C32 ), Mpy_32_16_1( tmp3, C31 ) ) );
+ move32();
}
@@ -2957,13 +3612,21 @@ static void fft4(
Word32 tmp7, tmp8;
re1 = pInOut[0];
+ move32();
im1 = pInOut[1];
+ move32();
re2 = pInOut[2];
+ move32();
im2 = pInOut[3];
+ move32();
re3 = pInOut[4];
+ move32();
im3 = pInOut[5];
+ move32();
re4 = pInOut[6];
+ move32();
im4 = pInOut[7];
+ move32();
/*
1.0000 1.0000 1.0000 1.0000
@@ -2976,19 +3639,27 @@ static void fft4(
tmp5 = L_add( im1, im3 );
tmp7 = L_add( im2, im4 );
pInOut[0] = L_add( tmp1, tmp3 );
+ move32();
pInOut[4] = L_sub( tmp1, tmp3 );
+ move32();
pInOut[1] = L_add( tmp5, tmp7 );
+ move32();
pInOut[5] = L_sub( tmp5, tmp7 );
+ move32();
tmp2 = L_sub( re1, re3 );
tmp4 = L_sub( re2, re4 );
tmp6 = L_sub( im1, im3 );
tmp8 = L_sub( im2, im4 );
pInOut[2] = L_add( tmp2, tmp8 );
+ move32();
pInOut[6] = L_sub( tmp2, tmp8 );
+ move32();
pInOut[3] = L_sub( tmp6, tmp4 );
+ move32();
pInOut[7] = L_add( tmp4, tmp6 );
+ move32();
return;
}
@@ -3005,10 +3676,15 @@ static void fft5(
cmplx t[4];
x[0] = pInOut[0];
+ move32();
x[1] = pInOut[1];
+ move32();
x[2] = pInOut[2];
+ move32();
x[3] = pInOut[3];
+ move32();
x[4] = pInOut[4];
+ move32();
/*
1.0000 1.0000 1.0000 1.0000 1.0000
@@ -3019,17 +3695,26 @@ static void fft5(
1.0000 0.3090 + 0.9511i -0.8090 + 0.5878i -0.8090 - 0.5878i 0.3090 - 0.9511i
*/
t[0] = CL_add( x[1], x[4] );
+ move32();
t[1] = CL_sub( x[1], x[4] );
+ move32();
t[2] = CL_add( x[2], x[3] );
+ move32();
t[3] = CL_sub( x[2], x[3] );
+ move32();
pInOut[0] = CL_add( x[0], CL_add( t[0], t[2] ) );
+ move32();
pInOut[1] = CL_add( CL_add( x[0], CL_sub( CL_scale( t[0], C51 ), CL_scale( t[2], C53 ) ) ), CL_add( CL_conjugate( CL_scale( CL_swap_real_imag( t[1] ), C52 ) ), CL_conjugate( CL_scale( CL_swap_real_imag( t[3] ), C54 ) ) ) );
+ move32();
pInOut[4] = CL_add( x[0], CL_sub( CL_scale( t[0], C51 ), CL_add( CL_scale( t[2], C53 ), CL_add( CL_conjugate( CL_scale( CL_swap_real_imag( t[1] ), C52 ) ), CL_conjugate( CL_scale( CL_swap_real_imag( t[3] ), C54 ) ) ) ) ) );
+ move32();
pInOut[2] = CL_add( CL_sub( x[0], CL_scale( t[0], C53 ) ), CL_add( CL_scale( t[2], C51 ), CL_sub( CL_conjugate( CL_scale( CL_swap_real_imag( t[1] ), C54 ) ), CL_conjugate( CL_scale( CL_swap_real_imag( t[3] ), C52 ) ) ) ) );
+ move32();
pInOut[3] = CL_add( CL_sub( x[0], CL_scale( t[0], C53 ) ), CL_add( CL_sub( CL_scale( t[2], C51 ), CL_conjugate( CL_scale( CL_swap_real_imag( t[1] ), C54 ) ) ), CL_conjugate( CL_scale( CL_swap_real_imag( t[3] ), C52 ) ) ) );
+ move32();
return;
}
@@ -3049,9 +3734,13 @@ static void fft8_2(
Word32 im3_5p, im3_5m;
re0 = pInOut[0];
+ move32();
im0 = pInOut[1];
+ move32();
re4 = pInOut[8];
+ move32();
im4 = pInOut[9];
+ move32();
butterfly( pInOut[1 * 2], pInOut[7 * 2], &re1_7p, &re1_7m );
butterfly( pInOut[1 * 2 + 1], pInOut[7 * 2 + 1], &im1_7p, &im1_7m );
butterfly( pInOut[2 * 2], pInOut[6 * 2], &re2_6p, &re2_6m );
@@ -3069,29 +3758,45 @@ static void fft8_2(
6: 1 + 0i - 0 + 1i -1 - 0i 0 - 1i 1 + 0i - 0 + 1i - 1 - 0i - 0 - 1i
7: 1 + 0i C81 + C81i -0 + 1i -C81 + C81i -1 - 0i -C81 - C81i - 0 - 1i C81 - C81i
*/
- pInOut[0] = re0 + re4 + re1_7p + re2_6p + re3_5p;
- pInOut[1] = im0 + im4 + im1_7p + im2_6p + im3_5p;
+ pInOut[0] = L_add( L_add( L_add( L_add( re0, re4 ), re1_7p ), re2_6p ), re3_5p );
+ move32();
+ pInOut[1] = L_add( L_add( L_add( L_add( im0, im4 ), im1_7p ), im2_6p ), im3_5p );
+ move32();
- pInOut[2] = re0 + Mpy_32_16_1( L_sub( re1_7p, re3_5p ), C81 ) - re4 + Mpy_32_16_1( L_add( im1_7m, im3_5m ), C81 ) + im2_6m;
- pInOut[3] = im0 + Mpy_32_16_1( L_sub( im1_7p, im3_5p ), C81 ) - im4 - Mpy_32_16_1( L_add( re1_7m, re3_5m ), C81 ) - re2_6m;
+ pInOut[2] = L_add( L_add( L_sub( L_add( re0, Mpy_32_16_1( L_sub( re1_7p, re3_5p ), C81 ) ), re4 ), Mpy_32_16_1( L_add( im1_7m, im3_5m ), C81 ) ), im2_6m );
+ move32();
+ pInOut[3] = L_sub( L_sub( L_sub( L_add( im0, Mpy_32_16_1( L_sub( im1_7p, im3_5p ), C81 ) ), im4 ), Mpy_32_16_1( L_add( re1_7m, re3_5m ), C81 ) ), re2_6m );
+ move32();
- pInOut[4] = re0 - re2_6p + re4 + im1_7m - im3_5m;
- pInOut[5] = im0 - im2_6p + im4 - re1_7m + re3_5m;
+ pInOut[4] = L_sub( L_add( L_add( L_sub( re0, re2_6p ), re4 ), im1_7m ), im3_5m );
+ move32();
+ pInOut[5] = L_add( L_sub( L_add( L_sub( im0, im2_6p ), im4 ), re1_7m ), re3_5m );
+ move32();
- pInOut[6] = re0 + Mpy_32_16_1( L_sub( re3_5p, re1_7p ), C81 ) - re4 + Mpy_32_16_1( L_add( im1_7m, im3_5m ), C81 ) - im2_6m;
- pInOut[7] = im0 + Mpy_32_16_1( L_sub( im3_5p, im1_7p ), C81 ) - im4 - Mpy_32_16_1( L_add( re1_7m, re3_5m ), C81 ) + re2_6m;
+ pInOut[6] = L_sub( L_add( L_sub( L_add( re0, Mpy_32_16_1( L_sub( re3_5p, re1_7p ), C81 ) ), re4 ), Mpy_32_16_1( L_add( im1_7m, im3_5m ), C81 ) ), im2_6m );
+ move32();
+ pInOut[7] = L_add( L_sub( L_sub( L_add( im0, Mpy_32_16_1( L_sub( im3_5p, im1_7p ), C81 ) ), im4 ), Mpy_32_16_1( L_add( re1_7m, re3_5m ), C81 ) ), re2_6m );
+ move32();
- pInOut[8] = re0 - re1_7p + re2_6p - re3_5p + re4;
- pInOut[9] = im0 - im1_7p + im2_6p - im3_5p + im4;
+ pInOut[8] = L_add( L_sub( L_add( L_sub( re0, re1_7p ), re2_6p ), re3_5p ), re4 );
+ move32();
+ pInOut[9] = L_add( L_sub( L_add( L_sub( im0, im1_7p ), im2_6p ), im3_5p ), im4 );
+ move32();
- pInOut[10] = re0 + Mpy_32_16_1( L_sub( re3_5p, re1_7p ), C81 ) - re4 - Mpy_32_16_1( L_add( im1_7m, im3_5m ), C81 ) + im2_6m;
- pInOut[11] = im0 + Mpy_32_16_1( L_sub( im3_5p, im1_7p ), C81 ) - im4 + Mpy_32_16_1( L_add( re1_7m, re3_5m ), C81 ) - re2_6m;
+ pInOut[10] = L_add( L_sub( L_sub( L_add( re0, Mpy_32_16_1( L_sub( re3_5p, re1_7p ), C81 ) ), re4 ), Mpy_32_16_1( L_add( im1_7m, im3_5m ), C81 ) ), im2_6m );
+ move32();
+ pInOut[11] = L_sub( L_add( L_sub( L_add( im0, Mpy_32_16_1( L_sub( im3_5p, im1_7p ), C81 ) ), im4 ), Mpy_32_16_1( L_add( re1_7m, re3_5m ), C81 ) ), re2_6m );
+ move32();
- pInOut[12] = re0 - re2_6p + re4 - im1_7m + im3_5m;
- pInOut[13] = im0 - im2_6p + im4 + re1_7m - re3_5m;
+ pInOut[12] = L_add( L_sub( L_add( L_sub( re0, re2_6p ), re4 ), im1_7m ), im3_5m );
+ move32();
+ pInOut[13] = L_sub( L_add( L_add( L_sub( im0, im2_6p ), im4 ), re1_7m ), re3_5m );
+ move32();
- pInOut[14] = re0 + Mpy_32_16_1( L_sub( re1_7p, re3_5p ), C81 ) - re4 - Mpy_32_16_1( L_add( im1_7m, im3_5m ), C81 ) - im2_6m;
- pInOut[15] = im0 + Mpy_32_16_1( L_sub( im1_7p, im3_5p ), C81 ) - im4 + Mpy_32_16_1( L_add( re1_7m, re3_5m ), C81 ) + re2_6m;
+ pInOut[14] = L_sub( L_sub( L_sub( L_add( re0, Mpy_32_16_1( L_sub( re1_7p, re3_5p ), C81 ) ), re4 ), Mpy_32_16_1( L_add( im1_7m, im3_5m ), C81 ) ), im2_6m );
+ move32();
+ pInOut[15] = L_add( L_add( L_sub( L_add( im0, Mpy_32_16_1( L_sub( im1_7p, im3_5p ), C81 ) ), im4 ), Mpy_32_16_1( L_add( re1_7m, re3_5m ), C81 ) ), re2_6m );
+ move32();
return;
}
@@ -3113,16 +3818,20 @@ static void nextFFT(
fft4( x );
BREAK;
case 5:
- FOR( Word32 i = 0; i < 5; i++ )
+ FOR( Word16 i = 0; i < 5; i++ )
{
val[i].re = x[2 * i];
- val[i].im = x[2 * i + 1];
+ move32();
+ val[i].im = x[add( shl( i, 1 ), 1 )];
+ move32();
}
fft5( val );
- FOR( Word32 i = 0; i < 5; i++ )
+ FOR( Word16 i = 0; i < 5; i++ )
{
x[2 * i] = val[i].re;
- x[2 * i + 1] = val[i].im;
+ move32();
+ x[add( shl( i, 1 ), 1 )] = val[i].im;
+ move32();
}
BREAK;
case 8:
@@ -3142,16 +3851,19 @@ static __inline Word16 findFactor(
const Word16 length )
{
Word16 i = 0;
+ move16();
Word16 factor = 0;
+ move16();
WHILE( CTFFTfactors[i] != 0 )
{
- IF( EQ_16( 0, ( length % CTFFTfactors[i] ) ) )
+ IF( ( length % CTFFTfactors[i] ) == 0 )
{
factor = CTFFTfactors[i];
+ move16();
BREAK;
}
- i++;
+ i = add( i, 1 );
}
return factor;
}
@@ -3165,12 +3877,17 @@ static __inline void twiddle(
Word16 i, ii;
const Word16 *ptr_sin = &sin_twiddle_table_25_5_5[0];
const Word16 *ptr_cos = &cos_twiddle_table_25_5_5[0];
+
+ test();
+ test();
+ test();
+ test();
IF( EQ_16( length, 16 ) && EQ_16( n1, 8 ) && EQ_16( n2, 2 ) )
{
ptr_sin = &sin_twiddle_table_16_8_2[0];
ptr_cos = &cos_twiddle_table_16_8_2[0];
}
- ELSE IF( length != 25 || n1 != 5 || n2 != 5 )
+ ELSE IF( NE_16( length, 25 ) || NE_16( n1, 5 ) || NE_16( n2, 5 ) )
{
assert( 0 );
}
@@ -3180,10 +3897,12 @@ static __inline void twiddle(
FOR( ii = 1; ii < n2; ii++ )
{
Word32 xRe, xIm;
- xRe = x[2 * ( i * n2 + ii )];
- xIm = x[2 * ( i * n2 + ii ) + 1];
- x[2 * ( i * n2 + ii )] = (Word32) L_sub( Mpy_32_16_1( xRe, ptr_cos[i * n2 + ii] ), Mpy_32_16_1( xIm, ptr_sin[i * n2 + ii] ) );
- x[2 * ( i * n2 + ii ) + 1] = (Word32) L_add( Mpy_32_16_1( xRe, ptr_sin[i * n2 + ii] ), Mpy_32_16_1( xIm, ptr_cos[i * n2 + ii] ) );
+ xRe = x[shl( ( add( i_mult( i, n2 ), ii ) ), 1 )];
+ xIm = x[add( shl( ( add( i_mult( i, n2 ), ii ) ), 1 ), 1 )];
+ x[shl( ( add( i_mult( i, n2 ), ii ) ), 1 )] = L_sub( Mpy_32_16_1( xRe, ptr_cos[add( i_mult( i, n2 ), ii )] ), Mpy_32_16_1( xIm, ptr_sin[add( i_mult( i, n2 ), ii )] ) );
+ move32();
+ x[add( shl( ( add( i_mult( i, n2 ), ii ) ), 1 ), 1 )] = L_add( Mpy_32_16_1( xRe, ptr_sin[add( i_mult( i, n2 ), ii )] ), Mpy_32_16_1( xIm, ptr_cos[add( i_mult( i, n2 ), ii )] ) );
+ move32();
}
}
return;
@@ -3198,6 +3917,7 @@ static void cooleyTukeyFFT(
Word16 i, ii;
Word16 n1, n2;
Word16 cnt = 0;
+ move16();
Word32 *src, *dest;
cmplx val[5];
@@ -3218,13 +3938,17 @@ static void cooleyTukeyFFT(
FOR( i = 0; i < 5; i++ )
{
val[i].re = x[2 * i];
- val[i].im = x[2 * i + 1];
+ move32();
+ val[i].im = x[add( shl( i, 1 ), 1 )];
+ move32();
}
fft5( val );
FOR( i = 0; i < 5; i++ )
{
x[2 * i] = val[i].re;
- x[2 * i + 1] = val[i].im;
+ move32();
+ x[add( shl( i, 1 ), 1 )] = val[i].im;
+ move32();
}
BREAK;
case 8:
@@ -3234,10 +3958,11 @@ static void cooleyTukeyFFT(
{
factor = findFactor( length );
- IF( GT_16( factor, 0 ) && GT_16( length / factor, 1 ) )
+ IF( GT_16( factor, 0 ) && GT_16( idiv1616( length, factor ), 1 ) )
{
n1 = factor;
- n2 = length / factor;
+ move16();
+ n2 = idiv1616( length, factor );
/* DATA Resorting for stage1 */
dest = scratch;
@@ -3249,7 +3974,9 @@ static void cooleyTukeyFFT(
/* *dest++ = x[2*(i+ii*n1)]; */
/* *dest++ = x[2*(i+ii*n1)+1]; */
*dest++ = *src;
+ move32();
*dest++ = *( src + 1 );
+ move32();
src += 2 * n1;
}
}
@@ -3258,39 +3985,47 @@ static void cooleyTukeyFFT(
FOR( i = 0; i < length; i++ )
{
*dest++ = *src++;
+ move32();
*dest++ = *src++;
+ move32();
}
/* perform n1 ffts of length n2 */
FOR( i = 0; i < n1; i++ )
{
- cooleyTukeyFFT( x + 2 * i * n2, n2, scratch + 2 * i * n2 );
+ cooleyTukeyFFT( x + shl( i_mult( i, n2 ), 1 ), n2, scratch + shl( i_mult( i, n2 ), 1 ) );
}
/*data twiddeling */
twiddle( x, length, n1, n2 );
/* DATA Resorting for stage2 */
cnt = 0;
+ move16();
FOR( i = 0; i < n2; i++ )
{
FOR( ii = 0; ii < n1; ii++ )
{
- scratch[2 * cnt] = x[2 * ( i + ii * n2 )];
- scratch[2 * cnt + 1] = x[2 * ( i + ii * n2 ) + 1];
- cnt++;
+ scratch[2 * cnt] = x[shl( add( i, i_mult( ii, n2 ) ), 1 )];
+ move32();
+ scratch[add( shl( cnt, 1 ), 1 )] = x[add( shl( add( i, i_mult( ii, n2 ) ), 1 ), 1 )];
+ move32();
+ cnt = add( cnt, 1 );
}
}
/* perform n2 ffts of length n1 */
FOR( i = 0; i < n2; i++ )
{
- nextFFT( scratch + 2 * i * n1, n1 );
+ nextFFT( scratch + shl( i_mult( i, n1 ), 1 ), n1 );
}
cnt = 0;
+ move16();
FOR( i = 0; i < n1; i++ )
{
FOR( ii = 0; ii < n2; ii++ )
{
- x[2 * cnt] = scratch[2 * ( i + ii * n1 )];
- x[2 * cnt + 1] = scratch[2 * ( i + ii * n1 ) + 1];
- cnt++;
+ x[2 * cnt] = scratch[shl( add( i, i_mult( ii, n1 ) ), 1 )];
+ move32();
+ x[add( shl( cnt, 1 ), 1 )] = scratch[add( shl( add( i, i_mult( ii, n1 ) ), 1 ), 1 )];
+ move32();
+ cnt = add( cnt, 1 );
}
}
}
@@ -3318,38 +4053,52 @@ static void pfaDFT(
{
Word32 *tmp = scratch1;
Word16 n1_inv = 1, n2_inv = 1;
+ move16();
+ move16();
Word16 n2 = factor[0 /*idx*/];
- Word16 n1 = length / n2;
+ move16();
+ Word16 n1 = idiv1616( length, n2 );
Word16 idx, incr;
- WHILE( ( ( n1_inv * n1 ) % n2 ) != 1 )
+ WHILE( ( i_mult( n1_inv, n1 ) % n2 ) != 1 )
{
- n1_inv++;
+ n1_inv = add( n1_inv, 1 );
}
- WHILE( ( ( n2_inv * n2 ) % n1 ) != 1 )
+ WHILE( ( i_mult( n2_inv, n2 ) % n1 ) != 1 )
{
- n2_inv++;
+ n2_inv = add( n2_inv, 1 );
}
idx = 0;
- incr = n1 * n1_inv;
+ move16();
+ incr = i_mult( n1, n1_inv );
+ move16();
cnt = 0;
+ move16();
FOR( i = 0; i < n1; i++ )
{
FOR( ii = 0; ii < n2 - 1; ii++ )
{
- tmp[cnt++] = x[2 * idx];
- tmp[cnt++] = x[2 * idx + 1];
+ tmp[cnt] = x[2 * idx];
+ move32();
+ cnt = add( cnt, 1 );
+ tmp[cnt] = x[add( shl( idx, 1 ), 1 )];
+ move32();
+ cnt = add( cnt, 1 );
- idx += incr;
+ idx = add( idx, incr );
IF( GT_16( idx, length ) )
{
- idx -= length;
+ idx = sub( idx, length );
}
}
- tmp[cnt++] = x[2 * idx];
- tmp[cnt++] = x[2 * idx + 1];
- idx++;
+ tmp[cnt] = x[2 * idx];
+ move32();
+ cnt = add( cnt, 1 );
+ tmp[cnt] = x[add( shl( idx, 1 ), 1 )];
+ move32();
+ cnt = add( cnt, 1 );
+ idx = add( idx, 1 );
}
FOR( cnt = 0; cnt < length; cnt += n2 )
{
@@ -3359,35 +4108,45 @@ static void pfaDFT(
{
FOR( i = 0; i < n2; i++ )
{
- x[2 * ( cnt + i * n1 )] = tmp[2 * ( cnt * n2 + i )];
- x[2 * ( cnt + i * n1 ) + 1] = tmp[2 * ( cnt * n2 + i ) + 1];
+ x[shl( add( cnt, i_mult( i, n1 ) ), 1 )] = tmp[shl( add( i_mult( cnt, n2 ), i ), 1 )];
+ move32();
+ x[add( shl( add( cnt, i_mult( i, n1 ) ), 1 ), 1 )] = tmp[add( shl( add( i_mult( cnt, n2 ), i ), 1 ), 1 )];
+ move32();
}
}
FOR( cnt = 0; cnt < length; cnt += n1 )
{
- pfaDFT( x + 2 * cnt, n1, tmp, numFactors - 1, &factor[1] );
+ pfaDFT( x + 2 * cnt, n1, tmp, sub( numFactors, 1 ), &factor[1] );
}
idx = 0;
+ move16();
cnt = 0;
+ move16();
FOR( i = 0; i < n2; i++ )
{
- idx = i * n1;
+ idx = i_mult( i, n1 );
FOR( ii = 0; ii < n1; ii++ )
{
- tmp[2 * idx] = x[cnt++];
- tmp[2 * idx + 1] = x[cnt++];
- idx += n2;
+ tmp[2 * idx] = x[cnt];
+ move32();
+ cnt = add( cnt, 1 );
+ tmp[add( shl( idx, 1 ), 1 )] = x[cnt];
+ move32();
+ cnt = add( cnt, 1 );
+ idx = add( idx, n2 );
IF( GT_16( idx, length ) )
{
- idx -= length;
+ idx = sub( idx, length );
}
}
}
FOR( cnt = 0; cnt < length; cnt++ )
{
x[2 * cnt] = tmp[2 * cnt];
- x[2 * cnt + 1] = tmp[2 * cnt + 1];
+ move32();
+ x[add( shl( cnt, 1 ), 1 )] = tmp[add( shl( cnt, 1 ), 1 )];
+ move32();
}
}
ELSE
@@ -3405,11 +4164,14 @@ static void fftf_interleave(
const Word16 len )
{
Word16 i = 0;
+ move16();
FOR( i = 0; i < len; i++ )
{
*out++ = *re++;
+ move32();
*out++ = *im++;
+ move32();
}
return;
@@ -3422,11 +4184,14 @@ static void fftf_deinterleave(
const Word16 len )
{
Word16 i = 0;
+ move16();
FOR( i = 0; i < len; i++ )
{
*re++ = *in++;
+ move32();
*im++ = *in++;
+ move32();
}
return;
@@ -3439,6 +4204,9 @@ static void DoRTFT600(
{
Word32 scratch[1200], cmplx[1200];
Word16 factors[3] = { 25, 8, 3 };
+ move16();
+ move16();
+ move16();
fftf_interleave( x, y, cmplx, 600 );
pfaDFT( cmplx, 600, scratch, 3, factors );
@@ -3454,6 +4222,8 @@ static void DoRTFT400(
{
Word32 scratch[800], cmplx[800];
Word16 factors[2] = { 25, 16 };
+ move16();
+ move16();
fftf_interleave( x, y, cmplx, 400 );
pfaDFT( cmplx, 400, scratch, 2, factors );
@@ -3470,6 +4240,9 @@ static void DoRTFT240(
{
Word32 scratch[480], cmplx[480];
Word16 factors[3] = { 16, 5, 3 };
+ move16();
+ move16();
+ move16();
fftf_interleave( x, y, cmplx, 240 );
pfaDFT( cmplx, 240, scratch, 3, factors );
@@ -3485,6 +4258,8 @@ static void DoRTFT200(
{
Word32 scratch[400], cmplx[400];
Word16 factors[2] = { 25, 8 };
+ move16();
+ move16();
fftf_interleave( x, y, cmplx, 200 );
pfaDFT( cmplx, 200, scratch, 2, factors );
@@ -3500,6 +4275,8 @@ static void DoRTFT100(
{
Word32 scratch[200], cmplx[200];
Word16 factors[2] = { 25, 4 };
+ move16();
+ move16();
fftf_interleave( x, y, cmplx, 100 );
pfaDFT( cmplx, 100, scratch, 2, factors );
@@ -3585,6 +4362,7 @@ static void fft_len5(
t = CL_scale( CL_sub( y1, y3 ), FFT_C54 );
y1 = CL_add( y1, y3 );
x[0] = CL_add( x[0], y1 );
+ move64();
y1 = CL_add( x[0], CL_shl( CL_scale( y1, FFT_C55 ), 1 ) );
y3 = CL_sub( y1, t );
@@ -3595,9 +4373,13 @@ static void fft_len5(
y2 = CL_add( t, CL_scale( y2, FFT_C53 ) );
x[1] = CL_msu_j( y1, y2 );
+ move64();
x[4] = CL_mac_j( y1, y2 );
+ move64();
x[2] = CL_mac_j( y3, y4 );
+ move64();
x[3] = CL_msu_j( y3, y4 );
+ move64();
return;
}
@@ -3608,36 +4390,63 @@ static void fft_len8(
cmplx t[8], s[8];
t[0] = CL_add( x[0], x[4] );
+ move64();
t[1] = CL_sub( x[0], x[4] );
+ move64();
t[2] = CL_add( x[1], x[5] );
+ move64();
t[3] = CL_sub( x[1], x[5] );
+ move64();
t[4] = CL_add( x[2], x[6] );
+ move64();
t[5] = CL_sub( x[2], x[6] );
+ move64();
t[6] = CL_add( x[3], x[7] );
+ move64();
t[7] = CL_sub( x[3], x[7] );
+ move64();
s[0] = CL_add( t[0], t[4] );
+ move64();
s[2] = CL_sub( t[0], t[4] );
+ move64();
s[4] = CL_mac_j( t[1], t[5] );
+ move64();
s[5] = CL_msu_j( t[1], t[5] );
+ move64();
s[1] = CL_add( t[2], t[6] );
+ move64();
s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) );
+ move64();
t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) );
+ move64();
t[1] = CL_sub( t[3], t[7] );
+ move64();
s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 );
+ move64();
s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 );
+ move64();
s[7] = CL_conjugate( s[7] );
+ move64();
x[0] = CL_add( s[0], s[1] );
+ move64();
x[4] = CL_sub( s[0], s[1] );
+ move64();
x[2] = CL_sub( s[2], s[3] );
+ move64();
x[6] = CL_add( s[2], s[3] );
+ move64();
x[3] = CL_add( s[4], s[7] );
+ move64();
x[7] = CL_sub( s[4], s[7] );
+ move64();
x[1] = CL_add( s[5], s[6] );
+ move64();
x[5] = CL_sub( s[5], s[6] );
+ move64();
return;
}
@@ -3650,58 +4459,100 @@ static void fft_len10(
cmplx y[10];
s[0] = CL_add( x[6], x[4] );
+ move64();
s[3] = CL_sub( x[6], x[4] );
+ move64();
s[2] = CL_add( x[2], x[8] );
+ move64();
s[1] = CL_sub( x[2], x[8] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[0] = CL_add( x[0], s[0] );
+ move64();
s[0] = CL_add( y[0], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
+ move64();
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[2] = CL_msu_j( s[0], s[1] );
+ move64();
y[8] = CL_mac_j( s[0], s[1] );
+ move64();
y[4] = CL_mac_j( s[2], s[3] );
+ move64();
y[6] = CL_msu_j( s[2], s[3] );
+ move64();
s[0] = CL_add( x[1], x[9] );
+ move64();
s[3] = CL_sub( x[1], x[9] );
+ move64();
s[2] = CL_add( x[7], x[3] );
+ move64();
s[1] = CL_sub( x[7], x[3] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[1] = CL_add( x[5], s[0] );
+ move64();
s[0] = CL_add( y[1], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[3] = CL_msu_j( s[0], s[1] );
+ move64();
y[9] = CL_mac_j( s[0], s[1] );
+ move64();
+ move64();
y[5] = CL_mac_j( s[2], s[3] );
+ move64();
y[7] = CL_msu_j( s[2], s[3] );
+ move64();
x[0] = CL_add( y[0], y[1] );
+ move64();
x[5] = CL_sub( y[0], y[1] );
+ move64();
x[2] = CL_add( y[2], y[3] );
+ move64();
x[7] = CL_sub( y[2], y[3] );
+ move64();
x[4] = CL_add( y[4], y[5] );
+ move64();
x[9] = CL_sub( y[4], y[5] );
+ move64();
x[6] = CL_add( y[6], y[7] );
+ move64();
x[1] = CL_sub( y[6], y[7] );
+ move64();
x[8] = CL_add( y[8], y[9] );
+ move64();
x[3] = CL_sub( y[8], y[9] );
+ move64();
return;
}
@@ -3714,101 +4565,176 @@ static void fft_len15(
cmplx y[15];
s[0] = CL_add( x[3], x[12] );
+ move64();
s[3] = CL_sub( x[3], x[12] );
+ move64();
s[2] = CL_add( x[6], x[9] );
+ move64();
s[1] = CL_sub( x[6], x[9] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[0] = CL_add( x[0], s[0] );
+ move64();
s[0] = CL_add( y[0], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[1] = CL_msu_j( s[0], s[1] );
+ move64();
y[4] = CL_mac_j( s[0], s[1] );
+ move64();
y[2] = CL_mac_j( s[2], s[3] );
+ move64();
y[3] = CL_msu_j( s[2], s[3] );
+ move64();
s[0] = CL_add( x[8], x[2] );
+ move64();
s[3] = CL_sub( x[8], x[2] );
+ move64();
s[2] = CL_add( x[11], x[14] );
+ move64();
s[1] = CL_sub( x[11], x[14] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[5] = CL_add( x[5], s[0] );
+ move64();
s[0] = CL_add( y[5], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[6] = CL_msu_j( s[0], s[1] );
+ move64();
y[9] = CL_mac_j( s[0], s[1] );
+ move64();
y[7] = CL_mac_j( s[2], s[3] );
+ move64();
y[8] = CL_msu_j( s[2], s[3] );
+ move64();
s[0] = CL_add( x[13], x[7] );
+ move64();
s[3] = CL_sub( x[13], x[7] );
+ move64();
s[2] = CL_add( x[1], x[4] );
+ move64();
s[1] = CL_sub( x[1], x[4] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[10] = CL_add( x[10], s[0] );
+ move64();
s[0] = CL_add( y[10], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[11] = CL_msu_j( s[0], s[1] );
+ move64();
y[14] = CL_mac_j( s[0], s[1] );
+ move64();
y[12] = CL_mac_j( s[2], s[3] );
+ move64();
y[13] = CL_msu_j( s[2], s[3] );
+ move64();
s[0] = CL_add( y[5], y[10] );
+ move64();
s[1] = CL_scale( CL_sub( y[5], y[10] ), FFT_C31 );
+ move64();
x[0] = CL_add( y[0], s[0] );
+ move64();
s[0] = CL_sub( y[0], CL_shr( s[0], 1 ) );
+ move64();
x[10] = CL_mac_j( s[0], s[1] );
+ move64();
x[5] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = CL_add( y[6], y[11] );
+ move64();
s[1] = CL_scale( CL_sub( y[6], y[11] ), FFT_C31 );
+ move64();
x[6] = CL_add( y[1], s[0] );
+ move64();
s[0] = CL_sub( y[1], CL_shr( s[0], 1 ) );
+ move64();
x[1] = CL_mac_j( s[0], s[1] );
+ move64();
x[11] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = CL_add( y[7], y[12] );
+ move64();
s[1] = CL_scale( CL_sub( y[7], y[12] ), FFT_C31 );
+ move64();
x[12] = CL_add( y[2], s[0] );
+ move64();
s[0] = CL_sub( y[2], CL_shr( s[0], 1 ) );
+ move64();
x[7] = CL_mac_j( s[0], s[1] );
+ move64();
x[2] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = CL_add( y[8], y[13] );
+ move64();
s[1] = CL_scale( CL_sub( y[8], y[13] ), FFT_C31 );
+ move64();
x[3] = CL_add( y[3], s[0] );
+ move64();
s[0] = CL_sub( y[3], CL_shr( s[0], 1 ) );
+ move64();
x[13] = CL_mac_j( s[0], s[1] );
+ move64();
x[8] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = CL_add( y[9], y[14] );
+ move64();
s[1] = CL_scale( CL_sub( y[9], y[14] ), FFT_C31 );
+ move64();
x[9] = CL_add( y[4], s[0] );
+ move64();
s[0] = CL_sub( y[4], CL_shr( s[0], 1 ) );
+ move64();
x[4] = CL_mac_j( s[0], s[1] );
+ move64();
x[14] = CL_msu_j( s[0], s[1] );
+ move64();
return;
}
@@ -3821,137 +4747,242 @@ static void fft_len16(
cmplx y[16];
s[0] = CL_shr( x[0], SCALEFACTOR16 );
+ move64();
s[1] = CL_shr( x[4], SCALEFACTOR16 );
+ move64();
s[2] = CL_shr( x[8], SCALEFACTOR16 );
+ move64();
s[3] = CL_shr( x[12], SCALEFACTOR16 );
+ move64();
t[0] = CL_add( s[0], s[2] );
+ move64();
t[1] = CL_sub( s[0], s[2] );
+ move64();
t[2] = CL_add( s[1], s[3] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( s[1] ), CL_conjugate( s[3] ) ) );
+ move64();
y[0] = CL_add( t[0], t[2] );
+ move64();
y[1] = CL_sub( t[1], t[3] );
+ move64();
y[2] = CL_sub( t[0], t[2] );
+ move64();
y[3] = CL_add( t[1], t[3] );
+ move64();
s[0] = CL_shr( x[1], SCALEFACTOR16 );
+ move64();
s[1] = CL_shr( x[5], SCALEFACTOR16 );
+ move64();
s[2] = CL_shr( x[9], SCALEFACTOR16 );
+ move64();
s[3] = CL_shr( x[13], SCALEFACTOR16 );
+ move64();
t[0] = CL_add( s[0], s[2] );
+ move64();
t[1] = CL_sub( s[0], s[2] );
+ move64();
t[2] = CL_add( s[1], s[3] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( s[1] ), CL_conjugate( s[3] ) ) );
+ move64();
y[4] = CL_add( t[0], t[2] );
+ move64();
y[5] = CL_sub( t[1], t[3] );
+ move64();
y[6] = CL_sub( t[0], t[2] );
+ move64();
y[7] = CL_add( t[1], t[3] );
+ move64();
s[0] = CL_shr( x[2], SCALEFACTOR16 );
+ move64();
s[1] = CL_shr( x[6], SCALEFACTOR16 );
+ move64();
s[2] = CL_shr( x[10], SCALEFACTOR16 );
+ move64();
s[3] = CL_shr( x[14], SCALEFACTOR16 );
+ move64();
t[0] = CL_add( s[0], s[2] );
+ move64();
t[1] = CL_sub( s[0], s[2] );
+ move64();
t[2] = CL_add( s[1], s[3] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( s[1] ), CL_conjugate( s[3] ) ) );
+ move64();
y[8] = CL_add( t[0], t[2] );
+ move64();
y[9] = CL_sub( t[1], t[3] );
+ move64();
y[10] = CL_swap_real_imag( CL_sub( t[0], t[2] ) );
+ move64();
y[10] = CL_conjugate( y[10] );
+ move64();
y[11] = CL_add( t[1], t[3] );
+ move64();
s[0] = CL_shr( x[3], SCALEFACTOR16 );
+ move64();
s[1] = CL_shr( x[7], SCALEFACTOR16 );
+ move64();
s[2] = CL_shr( x[11], SCALEFACTOR16 );
+ move64();
s[3] = CL_shr( x[15], SCALEFACTOR16 );
+ move64();
t[0] = CL_add( s[0], s[2] );
+ move64();
t[1] = CL_sub( s[0], s[2] );
+ move64();
t[2] = CL_add( s[1], s[3] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( s[1] ), CL_conjugate( s[3] ) ) );
+ move64();
y[12] = CL_add( t[0], t[2] );
+ move64();
y[13] = CL_sub( t[1], t[3] );
+ move64();
y[14] = CL_sub( t[0], t[2] );
+ move64();
y[15] = CL_add( t[1], t[3] );
+ move64();
s[0] = CL_scale( y[11], FFT_C162 );
+ move64();
y[11] = CL_mac_j( s[0], s[0] );
+ move64();
s[0] = CL_scale( y[14], FFT_C162 );
+ move64();
y[14] = CL_mac_j( s[0], s[0] );
+ move64();
s[0] = CL_scale( y[6], FFT_C161 );
+ move64();
y[6] = CL_mac_j( s[0], s[0] );
+ move64();
y[6] = CL_swap_real_imag( y[6] );
+ move64();
y[6] = CL_conjugate( y[6] );
+ move64();
s[0] = CL_scale( y[9], FFT_C161 );
+ move64();
y[9] = CL_mac_j( s[0], s[0] );
+ move64();
y[9] = CL_swap_real_imag( y[9] );
+ move64();
y[9] = CL_conjugate( y[9] );
+ move64();
s[0] = CL_scale( y[5], FFT_C163 );
+ move64();
s[1] = CL_scale( y[5], FFT_C166 );
+ move64();
y[5] = CL_mac_j( s[0], s[1] );
+ move64();
s[0] = CL_scale( y[7], FFT_C165 );
+ move64();
s[1] = CL_scale( y[7], FFT_C164 );
+ move64();
y[7] = CL_mac_j( s[0], s[1] );
+ move64();
s[0] = CL_scale( y[13], FFT_C165 );
+ move64();
s[1] = CL_scale( y[13], FFT_C164 );
+ move64();
y[13] = CL_mac_j( s[0], s[1] );
+ move64();
s[0] = CL_scale( y[15], FFT_C164 );
+ move64();
s[1] = CL_scale( y[15], FFT_C165 );
+ move64();
y[15] = CL_mac_j( s[0], s[1] );
+ move64();
t[0] = CL_add( y[0], y[8] );
+ move64();
t[1] = CL_sub( y[0], y[8] );
+ move64();
t[2] = CL_add( y[4], y[12] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( y[4] ), CL_conjugate( y[12] ) ) );
+ move64();
x[0] = CL_add( t[0], t[2] );
+ move64();
x[4] = CL_sub( t[1], t[3] );
+ move64();
x[8] = CL_sub( t[0], t[2] );
+ move64();
x[12] = CL_add( t[1], t[3] );
+ move64();
t[0] = CL_add( y[1], y[9] );
+ move64();
t[1] = CL_sub( y[1], y[9] );
+ move64();
t[2] = CL_add( y[5], y[13] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( y[5] ), CL_conjugate( y[13] ) ) );
+ move64();
x[1] = CL_add( t[0], t[2] );
+ move64();
x[5] = CL_sub( t[1], t[3] );
+ move64();
x[9] = CL_sub( t[0], t[2] );
+ move64();
x[13] = CL_add( t[1], t[3] );
+ move64();
t[0] = CL_add( y[2], y[10] );
+ move64();
t[1] = CL_sub( y[2], y[10] );
+ move64();
t[2] = CL_add( y[6], y[14] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( y[6] ), CL_conjugate( y[14] ) ) );
+ move64();
x[2] = CL_add( t[0], t[2] );
+ move64();
x[6] = CL_sub( t[1], t[3] );
+ move64();
x[10] = CL_sub( t[0], t[2] );
+ move64();
x[14] = CL_add( t[1], t[3] );
+ move64();
t[0] = CL_add( y[3], y[11] );
+ move64();
t[1] = CL_sub( y[3], y[11] );
+ move64();
t[2] = CL_add( y[7], y[15] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( y[7] ), CL_conjugate( y[15] ) ) );
+ move64();
x[3] = CL_add( t[0], t[2] );
+ move64();
x[7] = CL_sub( t[1], t[3] );
+ move64();
x[11] = CL_sub( t[0], t[2] );
+ move64();
x[15] = CL_add( t[1], t[3] );
+ move64();
return;
}
@@ -3966,154 +4997,274 @@ static void fft_len20_fx(
cmplx y[20];
xx[0] = CL_shr( x[0], SCALEFACTOR20 );
+ move64();
xx[1] = CL_shr( x[16], SCALEFACTOR20 );
+ move64();
xx[2] = CL_shr( x[12], SCALEFACTOR20 );
+ move64();
xx[3] = CL_shr( x[8], SCALEFACTOR20 );
+ move64();
xx[4] = CL_shr( x[4], SCALEFACTOR20 );
+ move64();
s[0] = CL_add( xx[1], xx[4] );
+ move64();
s[3] = CL_sub( xx[1], xx[4] );
+ move64();
s[2] = CL_add( xx[2], xx[3] );
+ move64();
s[1] = CL_sub( xx[2], xx[3] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[0] = CL_add( xx[0], s[0] );
+ move64();
s[0] = CL_add( y[0], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[4] = CL_msu_j( s[0], s[1] );
+ move64();
y[16] = CL_mac_j( s[0], s[1] );
+ move64();
y[8] = CL_mac_j( s[2], s[3] );
+ move64();
y[12] = CL_msu_j( s[2], s[3] );
+ move64();
xx[0] = CL_shr( x[5], SCALEFACTOR20 );
+ move64();
xx[1] = CL_shr( x[1], SCALEFACTOR20 );
+ move64();
xx[2] = CL_shr( x[17], SCALEFACTOR20 );
+ move64();
xx[3] = CL_shr( x[13], SCALEFACTOR20 );
+ move64();
xx[4] = CL_shr( x[9], SCALEFACTOR20 );
+ move64();
s[0] = CL_add( xx[1], xx[4] );
+ move64();
s[3] = CL_sub( xx[1], xx[4] );
+ move64();
s[2] = CL_add( xx[2], xx[3] );
+ move64();
s[1] = CL_sub( xx[2], xx[3] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[1] = CL_add( xx[0], s[0] );
+ move64();
s[0] = CL_add( y[1], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[5] = CL_msu_j( s[0], s[1] );
+ move64();
y[17] = CL_mac_j( s[0], s[1] );
+ move64();
y[9] = CL_mac_j( s[2], s[3] );
+ move64();
y[13] = CL_msu_j( s[2], s[3] );
+ move64();
xx[0] = CL_shr( x[10], SCALEFACTOR20 );
+ move64();
xx[1] = CL_shr( x[6], SCALEFACTOR20 );
+ move64();
xx[2] = CL_shr( x[2], SCALEFACTOR20 );
+ move64();
xx[3] = CL_shr( x[18], SCALEFACTOR20 );
+ move64();
xx[4] = CL_shr( x[14], SCALEFACTOR20 );
+ move64();
s[0] = CL_add( xx[1], xx[4] );
+ move64();
s[3] = CL_sub( xx[1], xx[4] );
+ move64();
s[2] = CL_add( xx[2], xx[3] );
+ move64();
s[1] = CL_sub( xx[2], xx[3] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[2] = CL_add( xx[0], s[0] );
+ move64();
s[0] = CL_add( y[2], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[6] = CL_msu_j( s[0], s[1] );
+ move64();
y[18] = CL_mac_j( s[0], s[1] );
+ move64();
y[10] = CL_mac_j( s[2], s[3] );
+ move64();
y[14] = CL_msu_j( s[2], s[3] );
+ move64();
xx[0] = CL_shr( x[15], SCALEFACTOR20 );
+ move64();
xx[1] = CL_shr( x[11], SCALEFACTOR20 );
+ move64();
xx[2] = CL_shr( x[7], SCALEFACTOR20 );
+ move64();
xx[3] = CL_shr( x[3], SCALEFACTOR20 );
+ move64();
xx[4] = CL_shr( x[19], SCALEFACTOR20 );
+ move64();
s[0] = CL_add( xx[1], xx[4] );
+ move64();
s[3] = CL_sub( xx[1], xx[4] );
+ move64();
s[2] = CL_add( xx[2], xx[3] );
+ move64();
s[1] = CL_sub( xx[2], xx[3] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[3] = CL_add( xx[0], s[0] );
+ move64();
s[0] = CL_add( y[3], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[7] = CL_msu_j( s[0], s[1] );
+ move64();
y[19] = CL_mac_j( s[0], s[1] );
+ move64();
y[11] = CL_mac_j( s[2], s[3] );
+ move64();
y[15] = CL_msu_j( s[2], s[3] );
+ move64();
tt[0] = CL_add( y[0], y[2] );
+ move64();
tt[1] = CL_sub( y[0], y[2] );
+ move64();
tt[2] = CL_add( y[1], y[3] );
+ move64();
tt[3] = CL_swap_real_imag( CL_conjugate( CL_sub( y[1], y[3] ) ) );
+ move64();
x[0] = CL_add( tt[0], tt[2] );
+ move64();
x[5] = CL_sub( tt[1], tt[3] );
+ move64();
x[10] = CL_sub( tt[0], tt[2] );
+ move64();
x[15] = CL_add( tt[1], tt[3] );
+ move64();
tt[0] = CL_add( y[4], y[6] );
+ move64();
tt[1] = CL_sub( y[4], y[6] );
+ move64();
tt[2] = CL_add( y[5], y[7] );
+ move64();
tt[3] = CL_swap_real_imag( CL_conjugate( CL_sub( y[5], y[7] ) ) );
+ move64();
x[4] = CL_add( tt[0], tt[2] );
+ move64();
x[9] = CL_sub( tt[1], tt[3] );
+ move64();
x[14] = CL_sub( tt[0], tt[2] );
+ move64();
x[19] = CL_add( tt[1], tt[3] );
+ move64();
tt[0] = CL_add( y[8], y[10] );
+ move64();
tt[1] = CL_sub( y[8], y[10] );
+ move64();
tt[2] = CL_add( y[9], y[11] );
+ move64();
tt[3] = CL_swap_real_imag( CL_conjugate( CL_sub( y[9], y[11] ) ) );
+ move64();
x[8] = CL_add( tt[0], tt[2] );
+ move64();
x[13] = CL_sub( tt[1], tt[3] );
+ move64();
x[18] = CL_sub( tt[0], tt[2] );
+ move64();
x[3] = CL_add( tt[1], tt[3] );
+ move64();
tt[0] = CL_add( y[12], y[14] );
+ move64();
tt[1] = CL_sub( y[12], y[14] );
+ move64();
tt[2] = CL_add( y[13], y[15] );
+ move64();
tt[3] = CL_swap_real_imag( CL_conjugate( CL_sub( y[13], y[15] ) ) );
+ move64();
x[12] = CL_add( tt[0], tt[2] );
+ move64();
x[17] = CL_sub( tt[1], tt[3] );
+ move64();
x[2] = CL_sub( tt[0], tt[2] );
+ move64();
x[7] = CL_add( tt[1], tt[3] );
+ move64();
tt[0] = CL_add( y[16], y[18] );
+ move64();
tt[1] = CL_sub( y[16], y[18] );
+ move64();
tt[2] = CL_add( y[17], y[19] );
+ move64();
tt[3] = CL_swap_real_imag( CL_conjugate( CL_sub( y[17], y[19] ) ) );
+ move64();
x[16] = CL_add( tt[0], tt[2] );
+ move64();
x[1] = CL_sub( tt[1], tt[3] );
+ move64();
x[6] = CL_sub( tt[0], tt[2] );
+ move64();
x[11] = CL_add( tt[1], tt[3] );
+ move64();
return;
}
@@ -4132,323 +5283,561 @@ static void fft_len30(
h = &x[15];
xx[0] = x[0];
+ move64();
xx[1] = x[18];
+ move64();
xx[2] = x[6];
+ move64();
xx[3] = x[24];
+ move64();
xx[4] = x[12];
+ move64();
xx[5] = x[20];
+ move64();
xx[6] = x[8];
+ move64();
xx[7] = x[26];
+ move64();
xx[8] = x[14];
+ move64();
xx[9] = x[2];
+ move64();
xx[10] = x[10];
+ move64();
xx[11] = x[28];
+ move64();
xx[12] = x[16];
+ move64();
xx[13] = x[4];
+ move64();
xx[14] = x[22];
+ move64();
s[0] = CL_add( xx[1], xx[4] );
+ move64();
s[3] = CL_sub( xx[1], xx[4] );
+ move64();
s[2] = CL_add( xx[2], xx[3] );
+ move64();
s[1] = CL_sub( xx[2], xx[3] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[0] = CL_add( xx[0], s[0] );
s[0] = CL_add( y[0], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[1] = CL_msu_j( s[0], s[1] );
+ move64();
y[4] = CL_mac_j( s[0], s[1] );
+ move64();
y[2] = CL_mac_j( s[2], s[3] );
+ move64();
y[3] = CL_msu_j( s[2], s[3] );
+ move64();
s[0] = CL_add( xx[6], xx[9] );
+ move64();
s[3] = CL_sub( xx[6], xx[9] );
+ move64();
s[2] = CL_add( xx[7], xx[8] );
+ move64();
s[1] = CL_sub( xx[7], xx[8] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[5] = CL_add( xx[5], s[0] );
+ move64();
s[0] = CL_add( y[5], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[6] = CL_msu_j( s[0], s[1] );
+ move64();
y[9] = CL_mac_j( s[0], s[1] );
+ move64();
y[7] = CL_mac_j( s[2], s[3] );
+ move64();
y[8] = CL_msu_j( s[2], s[3] );
+ move64();
s[0] = CL_add( xx[11], xx[14] );
+ move64();
s[3] = CL_sub( xx[11], xx[14] );
+ move64();
s[2] = CL_add( xx[12], xx[13] );
+ move64();
s[1] = CL_sub( xx[12], xx[13] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[10] = CL_add( xx[10], s[0] );
+ move64();
s[0] = CL_add( y[10], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[11] = CL_msu_j( s[0], s[1] );
+ move64();
y[14] = CL_mac_j( s[0], s[1] );
+ move64();
y[12] = CL_mac_j( s[2], s[3] );
+ move64();
y[13] = CL_msu_j( s[2], s[3] );
+ move64();
s[0] = CL_add( y[5], y[10] );
+ move64();
s[1] = CL_scale( CL_sub( y[5], y[10] ), FFT_C31 );
+ move64();
z[0] = CL_add( y[0], s[0] );
+ move64();
s[0] = CL_sub( y[0], CL_shr( s[0], 1 ) );
+ move64();
z[10] = CL_mac_j( s[0], s[1] );
+ move64();
z[5] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = CL_add( y[6], y[11] );
+ move64();
s[1] = CL_scale( CL_sub( y[6], y[11] ), FFT_C31 );
+ move64();
z[6] = CL_add( y[1], s[0] );
+ move64();
s[0] = CL_sub( y[1], CL_shr( s[0], 1 ) );
+ move64();
z[1] = CL_mac_j( s[0], s[1] );
+ move64();
z[11] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = CL_add( y[7], y[12] );
+ move64();
s[1] = CL_scale( CL_sub( y[7], y[12] ), FFT_C31 );
+ move64();
z[12] = CL_add( y[2], s[0] );
+ move64();
s[0] = CL_sub( y[2], CL_shr( s[0], 1 ) );
+ move64();
z[7] = CL_mac_j( s[0], s[1] );
+ move64();
z[2] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = CL_add( y[8], y[13] );
+ move64();
s[1] = CL_scale( CL_sub( y[8], y[13] ), FFT_C31 );
+ move64();
z[3] = CL_add( y[3], s[0] );
+ move64();
s[0] = CL_sub( y[3], CL_shr( s[0], 1 ) );
+ move64();
z[13] = CL_mac_j( s[0], s[1] );
+ move64();
z[8] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = CL_add( y[9], y[14] );
+ move64();
s[1] = CL_scale( CL_sub( y[9], y[14] ), FFT_C31 );
+ move64();
z[9] = CL_add( y[4], s[0] );
+ move64();
s[0] = CL_sub( y[4], CL_shr( s[0], 1 ) );
+ move64();
z[4] = CL_mac_j( s[0], s[1] );
+ move64();
z[14] = CL_msu_j( s[0], s[1] );
+ move64();
xx[0] = x[15];
+ move64();
xx[1] = x[3];
+ move64();
xx[2] = x[21];
+ move64();
xx[3] = x[9];
+ move64();
xx[4] = x[27];
+ move64();
xx[5] = x[5];
+ move64();
xx[6] = x[23];
+ move64();
xx[7] = x[11];
+ move64();
xx[8] = x[29];
+ move64();
xx[9] = x[17];
+ move64();
xx[10] = x[25];
+ move64();
xx[11] = x[13];
+ move64();
xx[12] = x[1];
+ move64();
xx[13] = x[19];
+ move64();
xx[14] = x[7];
+ move64();
s[0] = CL_add( xx[1], xx[4] );
+ move64();
s[3] = CL_sub( xx[1], xx[4] );
+ move64();
s[2] = CL_add( xx[2], xx[3] );
+ move64();
s[1] = CL_sub( xx[2], xx[3] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[0] = CL_add( xx[0], s[0] );
+ move64();
s[0] = CL_add( y[0], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[1] = CL_msu_j( s[0], s[1] );
+ move64();
y[4] = CL_mac_j( s[0], s[1] );
+ move64();
y[2] = CL_mac_j( s[2], s[3] );
+ move64();
y[3] = CL_msu_j( s[2], s[3] );
+ move64();
s[0] = CL_add( xx[6], xx[9] );
+ move64();
s[3] = CL_sub( xx[6], xx[9] );
+ move64();
s[2] = CL_add( xx[7], xx[8] );
+ move64();
s[1] = CL_sub( xx[7], xx[8] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[5] = CL_add( xx[5], s[0] );
+ move64();
s[0] = CL_add( y[5], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[6] = CL_msu_j( s[0], s[1] );
+ move64();
y[9] = CL_mac_j( s[0], s[1] );
+ move64();
y[7] = CL_mac_j( s[2], s[3] );
+ move64();
y[8] = CL_msu_j( s[2], s[3] );
+ move64();
s[0] = CL_add( xx[11], xx[14] );
+ move64();
s[3] = CL_sub( xx[11], xx[14] );
+ move64();
s[2] = CL_add( xx[12], xx[13] );
+ move64();
s[1] = CL_sub( xx[12], xx[13] );
+ move64();
t = CL_scale( CL_sub( s[0], s[2] ), FFT_C54 );
s[0] = CL_add( s[0], s[2] );
+ move64();
y[10] = CL_add( xx[10], s[0] );
+ move64();
s[0] = CL_add( y[10], CL_shl( CL_scale( s[0], FFT_C55 ), 1 ) );
+ move64();
s[2] = CL_sub( s[0], t );
+ move64();
s[0] = CL_add( s[0], t );
+ move64();
t = CL_scale( CL_add( s[3], s[1] ), FFT_C51 );
s[3] = CL_add( t, CL_shl( CL_scale( s[3], FFT_C52 ), 1 ) );
+ move64();
s[1] = CL_add( t, CL_scale( s[1], FFT_C53 ) );
+ move64();
y[11] = CL_msu_j( s[0], s[1] );
+ move64();
y[14] = CL_mac_j( s[0], s[1] );
+ move64();
y[12] = CL_mac_j( s[2], s[3] );
+ move64();
y[13] = CL_msu_j( s[2], s[3] );
+ move64();
s[0] = CL_add( y[5], y[10] );
+ move64();
s[1] = CL_scale( CL_sub( y[5], y[10] ), FFT_C31 );
+ move64();
z[15] = CL_add( y[0], s[0] );
+ move64();
s[0] = CL_sub( y[0], CL_shr( s[0], 1 ) );
+ move64();
z[25] = CL_mac_j( s[0], s[1] );
+ move64();
z[20] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = CL_add( y[6], y[11] );
+ move64();
s[1] = CL_scale( CL_sub( y[6], y[11] ), FFT_C31 );
+ move64();
z[21] = CL_add( y[1], s[0] );
+ move64();
s[0] = CL_sub( y[1], CL_shr( s[0], 1 ) );
+ move64();
z[16] = CL_mac_j( s[0], s[1] );
+ move64();
z[26] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = CL_add( y[7], y[12] );
+ move64();
s[1] = CL_scale( CL_sub( y[7], y[12] ), FFT_C31 );
+ move64();
z[27] = CL_add( y[2], s[0] );
+ move64();
s[0] = CL_sub( y[2], CL_shr( s[0], 1 ) );
+ move64();
z[22] = CL_mac_j( s[0], s[1] );
+ move64();
z[17] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = CL_add( y[8], y[13] );
+ move64();
s[1] = CL_scale( CL_sub( y[8], y[13] ), FFT_C31 );
+ move64();
z[18] = CL_add( y[3], s[0] );
+ move64();
s[0] = CL_sub( y[3], CL_shr( s[0], 1 ) );
+ move64();
z[28] = CL_mac_j( s[0], s[1] );
+ move64();
z[23] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = CL_add( y[9], y[14] );
+ move64();
s[1] = CL_scale( CL_sub( y[9], y[14] ), FFT_C31 );
+ move64();
z[24] = CL_add( y[4], s[0] );
+ move64();
s[0] = CL_sub( y[4], CL_shr( s[0], 1 ) );
+ move64();
z[19] = CL_mac_j( s[0], s[1] );
+ move64();
z[29] = CL_msu_j( s[0], s[1] );
+ move64();
s[0] = z[0];
+ move64();
s[1] = z[15];
+ move64();
*l = CL_add( s[0], s[1] );
+ move64();
*h = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[8];
+ move64();
s[1] = z[23];
+ move64();
*h = CL_add( s[0], s[1] );
+ move64();
*l = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[1];
+ move64();
s[1] = z[16];
+ move64();
*l = CL_add( s[0], s[1] );
+ move64();
*h = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[9];
+ move64();
s[1] = z[24];
+ move64();
*h = CL_add( s[0], s[1] );
+ move64();
*l = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[2];
+ move64();
s[1] = z[17];
+ move64();
*l = CL_add( s[0], s[1] );
+ move64();
*h = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[10];
+ move64();
s[1] = z[25];
+ move64();
*h = CL_add( s[0], s[1] );
+ move64();
*l = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[3];
+ move64();
s[1] = z[18];
+ move64();
*l = CL_add( s[0], s[1] );
+ move64();
*h = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[11];
+ move64();
s[1] = z[26];
+ move64();
*h = CL_add( s[0], s[1] );
+ move64();
*l = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[4];
+ move64();
s[1] = z[19];
+ move64();
*l = CL_add( s[0], s[1] );
+ move64();
*h = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[12];
+ move64();
s[1] = z[27];
+ move64();
*h = CL_add( s[0], s[1] );
+ move64();
*l = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[5];
+ move64();
s[1] = z[20];
+ move64();
*l = CL_add( s[0], s[1] );
+ move64();
*h = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[13];
+ move64();
s[1] = z[28];
+ move64();
*h = CL_add( s[0], s[1] );
+ move64();
*l = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[6];
+ move64();
s[1] = z[21];
+ move64();
*l = CL_add( s[0], s[1] );
+ move64();
*h = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[14];
+ move64();
s[1] = z[29];
+ move64();
*h = CL_add( s[0], s[1] );
+ move64();
*l = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
s[0] = z[7];
+ move64();
s[1] = z[22];
+ move64();
*l = CL_add( s[0], s[1] );
+ move64();
*h = CL_sub( s[0], s[1] );
+ move64();
l += 1, h += 1;
return;
@@ -4462,333 +5851,577 @@ static void fft_len32(
cmplx ab;
xx[0] = x[0];
+ move64();
xx[1] = x[4];
+ move64();
xx[2] = x[8];
+ move64();
xx[3] = x[12];
+ move64();
xx[4] = x[16];
+ move64();
xx[5] = x[20];
+ move64();
xx[6] = x[24];
+ move64();
xx[7] = x[28];
+ move64();
t[0] = CL_add( xx[0], xx[4] );
+ move64();
t[1] = CL_sub( xx[0], xx[4] );
+ move64();
t[2] = CL_add( xx[1], xx[5] );
+ move64();
t[3] = CL_sub( xx[1], xx[5] );
+ move64();
t[4] = CL_add( xx[2], xx[6] );
+ move64();
t[5] = CL_sub( xx[2], xx[6] );
+ move64();
t[6] = CL_add( xx[3], xx[7] );
+ move64();
t[7] = CL_sub( xx[3], xx[7] );
+ move64();
s[0] = CL_add( t[0], t[4] );
+ move64();
s[2] = CL_sub( t[0], t[4] );
+ move64();
s[4] = CL_mac_j( t[1], t[5] );
+ move64();
s[5] = CL_msu_j( t[1], t[5] );
+ move64();
s[1] = CL_add( t[2], t[6] );
+ move64();
s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) );
+ move64();
t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) );
+ move64();
t[1] = CL_sub( t[3], t[7] );
+ move64();
{
s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 );
+ move64();
s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 );
+ move64();
s[7] = CL_conjugate( s[7] );
+ move64();
};
y[0] = CL_add( s[0], s[1] );
+ move64();
y[4] = CL_sub( s[0], s[1] );
+ move64();
y[2] = CL_sub( s[2], s[3] );
+ move64();
y[6] = CL_add( s[2], s[3] );
+ move64();
y[3] = CL_add( s[4], s[7] );
+ move64();
y[7] = CL_sub( s[4], s[7] );
+ move64();
y[1] = CL_add( s[5], s[6] );
+ move64();
y[5] = CL_sub( s[5], s[6] );
+ move64();
xx[0] = x[1];
+ move64();
xx[1] = x[5];
+ move64();
xx[2] = x[9];
+ move64();
xx[3] = x[13];
+ move64();
xx[4] = x[17];
+ move64();
xx[5] = x[21];
+ move64();
xx[6] = x[25];
+ move64();
xx[7] = x[29];
+ move64();
t[0] = CL_add( xx[0], xx[4] );
+ move64();
t[1] = CL_sub( xx[0], xx[4] );
+ move64();
t[2] = CL_add( xx[1], xx[5] );
+ move64();
t[3] = CL_sub( xx[1], xx[5] );
+ move64();
t[4] = CL_add( xx[2], xx[6] );
+ move64();
t[5] = CL_sub( xx[2], xx[6] );
+ move64();
t[6] = CL_add( xx[3], xx[7] );
+ move64();
t[7] = CL_sub( xx[3], xx[7] );
+ move64();
s[0] = CL_add( t[0], t[4] );
+ move64();
s[2] = CL_sub( t[0], t[4] );
+ move64();
s[4] = CL_mac_j( t[1], t[5] );
+ move64();
s[5] = CL_msu_j( t[1], t[5] );
+ move64();
s[1] = CL_add( t[2], t[6] );
+ move64();
s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) );
+ move64();
t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) );
+ move64();
t[1] = CL_sub( t[3], t[7] );
+ move64();
{
s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 );
+ move64();
s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 );
+ move64();
s[7] = CL_conjugate( s[7] );
+ move64();
};
y[8] = CL_add( s[0], s[1] );
+ move64();
y[12] = CL_sub( s[0], s[1] );
+ move64();
y[10] = CL_sub( s[2], s[3] );
+ move64();
y[14] = CL_add( s[2], s[3] );
+ move64();
y[11] = CL_add( s[4], s[7] );
+ move64();
y[15] = CL_sub( s[4], s[7] );
+ move64();
y[9] = CL_add( s[5], s[6] );
+ move64();
y[13] = CL_sub( s[5], s[6] );
+ move64();
xx[0] = x[2];
+ move64();
xx[1] = x[6];
+ move64();
xx[2] = x[10];
+ move64();
xx[3] = x[14];
+ move64();
xx[4] = x[18];
+ move64();
xx[5] = x[22];
+ move64();
xx[6] = x[26];
+ move64();
xx[7] = x[30];
+ move64();
t[0] = CL_add( xx[0], xx[4] );
+ move64();
t[1] = CL_sub( xx[0], xx[4] );
+ move64();
t[2] = CL_add( xx[1], xx[5] );
+ move64();
t[3] = CL_sub( xx[1], xx[5] );
+ move64();
t[4] = CL_add( xx[2], xx[6] );
+ move64();
t[5] = CL_sub( xx[2], xx[6] );
+ move64();
t[6] = CL_add( xx[3], xx[7] );
+ move64();
t[7] = CL_sub( xx[3], xx[7] );
+ move64();
s[0] = CL_add( t[0], t[4] );
+ move64();
s[2] = CL_sub( t[0], t[4] );
+ move64();
s[4] = CL_mac_j( t[1], t[5] );
+ move64();
s[5] = CL_msu_j( t[1], t[5] );
+ move64();
s[1] = CL_add( t[2], t[6] );
+ move64();
s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) );
+ move64();
t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) );
+ move64();
t[1] = CL_sub( t[3], t[7] );
+ move64();
{
s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 );
+ move64();
s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 );
+ move64();
s[7] = CL_conjugate( s[7] );
+ move64();
};
y[16] = CL_add( s[0], s[1] );
+ move64();
y[20] = CL_sub( s[0], s[1] );
+ move64();
y[18] = CL_sub( s[2], s[3] );
+ move64();
y[22] = CL_add( s[2], s[3] );
+ move64();
y[19] = CL_add( s[4], s[7] );
+ move64();
y[23] = CL_sub( s[4], s[7] );
+ move64();
y[17] = CL_add( s[5], s[6] );
+ move64();
y[21] = CL_sub( s[5], s[6] );
+ move64();
xx[0] = x[3];
+ move64();
xx[1] = x[7];
+ move64();
xx[2] = x[11];
+ move64();
xx[3] = x[15];
+ move64();
xx[4] = x[19];
+ move64();
xx[5] = x[23];
+ move64();
xx[6] = x[27];
+ move64();
xx[7] = x[31];
+ move64();
t[0] = CL_add( xx[0], xx[4] );
+ move64();
t[1] = CL_sub( xx[0], xx[4] );
+ move64();
t[2] = CL_add( xx[1], xx[5] );
+ move64();
t[3] = CL_sub( xx[1], xx[5] );
+ move64();
t[4] = CL_add( xx[2], xx[6] );
+ move64();
t[5] = CL_sub( xx[2], xx[6] );
+ move64();
t[6] = CL_add( xx[3], xx[7] );
+ move64();
t[7] = CL_sub( xx[3], xx[7] );
+ move64();
s[0] = CL_add( t[0], t[4] );
+ move64();
s[2] = CL_sub( t[0], t[4] );
+ move64();
s[4] = CL_mac_j( t[1], t[5] );
+ move64();
s[5] = CL_msu_j( t[1], t[5] );
+ move64();
s[1] = CL_add( t[2], t[6] );
+ move64();
s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) );
+ move64();
t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) );
+ move64();
t[1] = CL_sub( t[3], t[7] );
+ move64();
{
s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 );
+ move64();
s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 );
+ move64();
s[7] = CL_conjugate( s[7] );
+ move64();
};
y[24] = CL_add( s[0], s[1] );
+ move64();
y[28] = CL_sub( s[0], s[1] );
+ move64();
y[26] = CL_sub( s[2], s[3] );
+ move64();
y[30] = CL_add( s[2], s[3] );
+ move64();
y[27] = CL_add( s[4], s[7] );
+ move64();
y[31] = CL_sub( s[4], s[7] );
+ move64();
y[25] = CL_add( s[5], s[6] );
+ move64();
y[29] = CL_sub( s[5], s[6] );
+ move64();
{
ab = y[9];
+ move64();
y[9] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[0] ), CL_scale( ab, FFT_RotVector_32_fx[1] ) );
+ move64();
};
{
ab = y[10];
+ move64();
y[10] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[2] ), CL_scale( ab, FFT_RotVector_32_fx[3] ) );
+ move64();
};
{
ab = y[11];
+ move64();
y[11] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[4] ), CL_scale( ab, FFT_RotVector_32_fx[5] ) );
+ move64();
};
{
ab = y[12];
+ move64();
y[12] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[6] ), CL_scale( ab, FFT_RotVector_32_fx[7] ) );
+ move64();
};
{
ab = y[13];
+ move64();
y[13] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[8] ), CL_scale( ab, FFT_RotVector_32_fx[9] ) );
+ move64();
};
{
ab = y[14];
+ move64();
y[14] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[10] ), CL_scale( ab, FFT_RotVector_32_fx[11] ) );
+ move64();
};
{
ab = y[15];
+ move64();
y[15] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[12] ), CL_scale( ab, FFT_RotVector_32_fx[13] ) );
+ move64();
};
{
ab = y[17];
+ move64();
y[17] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[14] ), CL_scale( ab, FFT_RotVector_32_fx[15] ) );
+ move64();
};
{
ab = y[18];
+ move64();
y[18] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[16] ), CL_scale( ab, FFT_RotVector_32_fx[17] ) );
+ move64();
};
{
ab = y[19];
+ move64();
y[19] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[18] ), CL_scale( ab, FFT_RotVector_32_fx[19] ) );
+ move64();
};
{
ab = y[21];
+ move64();
y[21] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[20] ), CL_scale( ab, FFT_RotVector_32_fx[21] ) );
+ move64();
};
{
ab = y[22];
+ move64();
y[22] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[22] ), CL_scale( ab, FFT_RotVector_32_fx[23] ) );
+ move64();
};
{
ab = y[23];
+ move64();
y[23] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[24] ), CL_scale( ab, FFT_RotVector_32_fx[25] ) );
+ move64();
};
{
ab = y[25];
+ move64();
y[25] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[26] ), CL_scale( ab, FFT_RotVector_32_fx[27] ) );
+ move64();
};
{
ab = y[26];
+ move64();
y[26] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[28] ), CL_scale( ab, FFT_RotVector_32_fx[29] ) );
+ move64();
};
{
ab = y[27];
+ move64();
y[27] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[30] ), CL_scale( ab, FFT_RotVector_32_fx[31] ) );
+ move64();
};
{
ab = y[28];
+ move64();
y[28] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[32] ), CL_scale( ab, FFT_RotVector_32_fx[33] ) );
+ move64();
};
{
ab = y[29];
+ move64();
y[29] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[34] ), CL_scale( ab, FFT_RotVector_32_fx[35] ) );
+ move64();
};
{
ab = y[30];
+ move64();
y[30] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[36] ), CL_scale( ab, FFT_RotVector_32_fx[37] ) );
+ move64();
};
{
ab = y[31];
+ move64();
y[31] = CL_mac_j( CL_scale( ab, FFT_RotVector_32_fx[38] ), CL_scale( ab, FFT_RotVector_32_fx[39] ) );
+ move64();
};
t[0] = CL_add( y[0], y[16] );
+ move64();
t[1] = CL_sub( y[0], y[16] );
+ move64();
t[2] = CL_add( y[8], y[24] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( y[8] ), CL_conjugate( y[24] ) ) );
+ move64();
x[0] = CL_add( t[0], t[2] );
+ move64();
x[8] = CL_sub( t[1], t[3] );
+ move64();
x[16] = CL_sub( t[0], t[2] );
+ move64();
x[24] = CL_add( t[1], t[3] );
+ move64();
t[0] = CL_add( y[1], y[17] );
+ move64();
t[1] = CL_sub( y[1], y[17] );
+ move64();
t[2] = CL_add( y[9], y[25] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( y[9] ), CL_conjugate( y[25] ) ) );
+ move64();
x[1] = CL_add( t[0], t[2] );
+ move64();
x[9] = CL_sub( t[1], t[3] );
+ move64();
x[17] = CL_sub( t[0], t[2] );
+ move64();
x[25] = CL_add( t[1], t[3] );
+ move64();
t[0] = CL_add( y[2], y[18] );
+ move64();
t[1] = CL_sub( y[2], y[18] );
+ move64();
t[2] = CL_add( y[10], y[26] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( y[10] ), CL_conjugate( y[26] ) ) );
+ move64();
x[2] = CL_add( t[0], t[2] );
+ move64();
x[10] = CL_sub( t[1], t[3] );
+ move64();
x[18] = CL_sub( t[0], t[2] );
+ move64();
x[26] = CL_add( t[1], t[3] );
+ move64();
t[0] = CL_add( y[3], y[19] );
+ move64();
t[1] = CL_sub( y[3], y[19] );
+ move64();
t[2] = CL_add( y[11], y[27] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( y[11] ), CL_conjugate( y[27] ) ) );
+ move64();
x[3] = CL_add( t[0], t[2] );
+ move64();
x[11] = CL_sub( t[1], t[3] );
+ move64();
x[19] = CL_sub( t[0], t[2] );
+ move64();
x[27] = CL_add( t[1], t[3] );
+ move64();
t[0] = CL_msu_j( y[4], y[20] );
+ move64();
t[1] = CL_mac_j( y[4], y[20] );
+ move64();
t[2] = CL_add( y[12], y[28] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( y[12] ), CL_conjugate( y[28] ) ) );
+ move64();
x[4] = CL_add( t[0], t[2] );
+ move64();
x[12] = CL_sub( t[1], t[3] );
+ move64();
x[20] = CL_sub( t[0], t[2] );
+ move64();
x[28] = CL_add( t[1], t[3] );
+ move64();
t[0] = CL_add( y[5], y[21] );
+ move64();
t[1] = CL_sub( y[5], y[21] );
+ move64();
t[2] = CL_add( y[13], y[29] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( y[13] ), CL_conjugate( y[29] ) ) );
+ move64();
x[5] = CL_add( t[0], t[2] );
+ move64();
x[13] = CL_sub( t[1], t[3] );
+ move64();
x[21] = CL_sub( t[0], t[2] );
+ move64();
x[29] = CL_add( t[1], t[3] );
+ move64();
t[0] = CL_add( y[6], y[22] );
+ move64();
t[1] = CL_sub( y[6], y[22] );
+ move64();
t[2] = CL_add( y[14], y[30] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( y[14] ), CL_conjugate( y[30] ) ) );
+ move64();
x[6] = CL_add( t[0], t[2] );
+ move64();
x[14] = CL_sub( t[1], t[3] );
+ move64();
x[22] = CL_sub( t[0], t[2] );
+ move64();
x[30] = CL_add( t[1], t[3] );
+ move64();
t[0] = CL_add( y[7], y[23] );
+ move64();
t[1] = CL_sub( y[7], y[23] );
+ move64();
t[2] = CL_add( y[15], y[31] );
+ move64();
t[3] = CL_swap_real_imag( CL_sub( CL_conjugate( y[15] ), CL_conjugate( y[31] ) ) );
+ move64();
x[7] = CL_add( t[0], t[2] );
+ move64();
x[15] = CL_sub( t[1], t[3] );
+ move64();
x[23] = CL_sub( t[0], t[2] );
+ move64();
x[31] = CL_add( t[1], t[3] );
+ move64();
return;
}
@@ -4809,8 +6442,10 @@ static void fft_lenN(
{
FOR( j = 0; j < dim1; j++ )
{
- xx[i * dim1 + j].re = x[i + j * dim2].re;
- xx[i * dim1 + j].im = x[i + j * dim2].im;
+ xx[add( i_mult( i, dim1 ), j )].re = x[add( i, i_mult( j, dim2 ) )].re;
+ move64();
+ xx[add( i_mult( i, dim1 ), j )].im = x[add( i, i_mult( j, dim2 ) )].im;
+ move64();
}
}
@@ -4819,56 +6454,56 @@ static void fft_lenN(
case 5:
FOR( i = 0; i < dim2; i++ )
{
- fft_len5( &xx[i * dim1] );
+ fft_len5( &xx[i_mult( i, dim1 )] );
}
BREAK;
case 8:
FOR( i = 0; i < dim2; i++ )
{
- fft_len8( &xx[i * dim1] );
+ fft_len8( &xx[i_mult( i, dim1 )] );
}
BREAK;
case 10:
FOR( i = 0; i < dim2; i++ )
{
- fft_len10( &xx[i * dim1] );
+ fft_len10( &xx[i_mult( i, dim1 )] );
}
BREAK;
case 15:
FOR( i = 0; i < dim2; i++ )
{
- fft_len15( &xx[i * dim1] );
+ fft_len15( &xx[i_mult( i, dim1 )] );
}
BREAK;
case 16:
FOR( i = 0; i < dim2; i++ )
{
- fft_len16( &xx[i * dim1] );
+ fft_len16( &xx[i_mult( i, dim1 )] );
}
BREAK;
case 20:
FOR( i = 0; i < dim2; i++ )
{
- fft_len20_fx( &xx[i * dim1] );
+ fft_len20_fx( &xx[i_mult( i, dim1 )] );
}
BREAK;
case 30:
FOR( i = 0; i < dim2; i++ )
{
- fft_len30( &xx[i * dim1] );
+ fft_len30( &xx[i_mult( i, dim1 )] );
}
BREAK;
case 32:
FOR( i = 0; i < dim2; i++ )
{
- fft_len32( &xx[i * dim1] );
+ fft_len32( &xx[i_mult( i, dim1 )] );
}
BREAK;
}
@@ -4882,100 +6517,145 @@ static void fft_lenN(
cmplx s[8];
cmplx y[8];
+ test();
+ test();
+ test();
+ test();
IF( EQ_16( dim1, 30 ) || EQ_16( dim1, 20 ) || EQ_16( dim1, 15 ) || EQ_16( dim1, 10 ) || EQ_16( dim1, 5 ) )
{
FOR( i = 0; i < dim1; i++ )
{
{
- y[0] = xx[i + 0 * dim1];
+ y[0] = xx[i]; // y[0] = xx[i + 0 * dim1]
};
- IF( EQ_16( i, 0 ) )
+ IF( i == 0 )
{
{
- y[1] = xx[i + 1 * dim1];
+ y[1] = xx[add( i, i_mult( 1, dim1 ) )];
+ move64();
};
{
- y[2] = xx[i + 2 * dim1];
+ y[2] = xx[add( i, i_mult( 2, dim1 ) )];
+ move64();
};
{
- y[3] = xx[i + 3 * dim1];
+ y[3] = xx[add( i, i_mult( 3, dim1 ) )];
+ move64();
};
{
- y[4] = xx[i + 4 * dim1];
+ y[4] = xx[add( i, i_mult( 4, dim1 ) )];
+ move64();
};
{
- y[5] = xx[i + 5 * dim1];
+ y[5] = xx[add( i, i_mult( 5, dim1 ) )];
+ move64();
};
{
- y[6] = xx[i + 6 * dim1];
+ y[6] = xx[add( i, i_mult( 6, dim1 ) )];
+ move64();
};
{
- y[7] = xx[i + 7 * dim1];
+ y[7] = xx[add( i, i_mult( 7, dim1 ) )];
+ move64();
};
}
ELSE
{
{
- y[1] = CL_mac_j( CL_scale( xx[i + 1 * dim1], W[sc * i + sc * 1 * dim1 * 2 - Woff] ),
- CL_scale( xx[i + 1 * dim1], W[sc * i + sc * 1 * dim1 * 2 + 1 - Woff] ) );
+ y[1] = CL_mac_j( CL_scale( xx[add( i, i_mult( 1, dim1 ) )], W[sub( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 1 ), dim1 ), 1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 1, dim1 ) )], W[sub( add( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 1 ), dim1 ), 1 ) ), 1 ), Woff )] ) );
+ move64();
};
{
- y[2] = CL_mac_j( CL_scale( xx[i + 2 * dim1], W[sc * i + sc * 2 * dim1 * 2 - Woff] ),
- CL_scale( xx[i + 2 * dim1], W[sc * i + sc * 2 * dim1 * 2 + 1 - Woff] ) );
+ y[2] = CL_mac_j( CL_scale( xx[add( i, i_mult( 2, dim1 ) )], W[sub( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 2 ), dim1 ), 1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 2, dim1 ) )], W[sub( add( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 2 ), dim1 ), 1 ) ), 1 ), Woff )] ) );
+ move64();
};
{
- y[3] = CL_mac_j( CL_scale( xx[i + 3 * dim1], W[sc * i + sc * 3 * dim1 * 2 - Woff] ),
- CL_scale( xx[i + 3 * dim1], W[sc * i + sc * 3 * dim1 * 2 + 1 - Woff] ) );
+ y[3] = CL_mac_j( CL_scale( xx[add( i, i_mult( 3, dim1 ) )], W[sub( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 3 ), dim1 ), 1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 3, dim1 ) )], W[sub( add( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 3 ), dim1 ), 1 ) ), 1 ), Woff )] ) );
+ move64();
};
{
- y[4] = CL_mac_j( CL_scale( xx[i + 4 * dim1], W[sc * i + sc * 4 * dim1 * 2 - Woff] ),
- CL_scale( xx[i + 4 * dim1], W[sc * i + sc * 4 * dim1 * 2 + 1 - Woff] ) );
+ y[4] = CL_mac_j( CL_scale( xx[add( i, i_mult( 4, dim1 ) )], W[sub( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 4 ), dim1 ), 1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 4, dim1 ) )], W[sub( add( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 4 ), dim1 ), 1 ) ), 1 ), Woff )] ) );
+ move64();
};
{
- y[5] = CL_mac_j( CL_scale( xx[i + 5 * dim1], W[sc * i + sc * 5 * dim1 * 2 - Woff] ),
- CL_scale( xx[i + 5 * dim1], W[sc * i + sc * 5 * dim1 * 2 + 1 - Woff] ) );
+ y[5] = CL_mac_j( CL_scale( xx[add( i, i_mult( 5, dim1 ) )], W[sub( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 5 ), dim1 ), 1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 5, dim1 ) )], W[sub( add( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 5 ), dim1 ), 1 ) ), 1 ), Woff )] ) );
+ move64();
};
{
- y[6] = CL_mac_j( CL_scale( xx[i + 6 * dim1], W[sc * i + sc * 6 * dim1 * 2 - Woff] ),
- CL_scale( xx[i + 6 * dim1], W[sc * i + sc * 6 * dim1 * 2 + 1 - Woff] ) );
+ y[6] = CL_mac_j( CL_scale( xx[add( i, i_mult( 6, dim1 ) )], W[sub( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 6 ), dim1 ), 1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 6, dim1 ) )], W[sub( add( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 6 ), dim1 ), 1 ) ), 1 ), Woff )] ) );
+ move64();
};
{
- y[7] = CL_mac_j( CL_scale( xx[i + 7 * dim1], W[sc * i + sc * 7 * dim1 * 2 - Woff] ),
- CL_scale( xx[i + 7 * dim1], W[sc * i + sc * 7 * dim1 * 2 + 1 - Woff] ) );
+ y[7] = CL_mac_j( CL_scale( xx[add( i, i_mult( 7, dim1 ) )], W[sub( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 7 ), dim1 ), 1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 7, dim1 ) )], W[sub( add( add( i_mult( sc, i ), shl( i_mult( i_mult( sc, 7 ), dim1 ), 1 ) ), 1 ), Woff )] ) );
+ move64();
};
}
t[0] = CL_add( y[0], y[4] );
+ move64();
t[1] = CL_sub( y[0], y[4] );
+ move64();
t[2] = CL_add( y[1], y[5] );
+ move64();
t[3] = CL_sub( y[1], y[5] );
+ move64();
t[4] = CL_add( y[2], y[6] );
+ move64();
t[5] = CL_sub( y[2], y[6] );
+ move64();
t[6] = CL_add( y[3], y[7] );
+ move64();
t[7] = CL_sub( y[3], y[7] );
+ move64();
s[0] = CL_add( t[0], t[4] );
+ move64();
s[2] = CL_sub( t[0], t[4] );
+ move64();
s[4] = CL_mac_j( t[1], t[5] );
+ move64();
s[5] = CL_msu_j( t[1], t[5] );
+ move64();
s[1] = CL_add( t[2], t[6] );
+ move64();
s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) );
+ move64();
t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) );
+ move64();
t[1] = CL_sub( t[3], t[7] );
+ move64();
s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 );
+ move64();
s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 );
+ move64();
s[7] = CL_conjugate( s[7] );
-
- x[i + 0 * dim1] = CL_add( s[0], s[1] );
- x[i + 1 * dim1] = CL_add( s[5], s[6] );
- x[i + 2 * dim1] = CL_sub( s[2], s[3] );
- x[i + 3 * dim1] = CL_add( s[4], s[7] );
- x[i + 4 * dim1] = CL_sub( s[0], s[1] );
- x[i + 5 * dim1] = CL_sub( s[5], s[6] );
- x[i + 6 * dim1] = CL_add( s[2], s[3] );
- x[i + 7 * dim1] = CL_sub( s[4], s[7] );
+ move64();
+
+ x[i] = CL_add( s[0], s[1] ); /*x[add(i + i_mult(0 , dim1)] = CL_add( s[0], s[1] )*/
+ move64();
+ x[add( i, i_mult( 1, dim1 ) )] = CL_add( s[5], s[6] );
+ move64();
+ x[add( i, i_mult( 2, dim1 ) )] = CL_sub( s[2], s[3] );
+ move64();
+ x[add( i, i_mult( 3, dim1 ) )] = CL_add( s[4], s[7] );
+ move64();
+ x[add( i, i_mult( 4, dim1 ) )] = CL_sub( s[0], s[1] );
+ move64();
+ x[add( i, i_mult( 5, dim1 ) )] = CL_sub( s[5], s[6] );
+ move64();
+ x[add( i, i_mult( 6, dim1 ) )] = CL_add( s[2], s[3] );
+ move64();
+ x[add( i, i_mult( 7, dim1 ) )] = CL_sub( s[4], s[7] );
+ move64();
}
}
ELSE
@@ -4983,95 +6663,137 @@ static void fft_lenN(
FOR( i = 0; i < dim1; i++ )
{
{
- y[0] = xx[i + 0 * dim1];
+ y[0] = xx[i]; /* y[0] = xx[i + 0 * dim1] */
+ move64();
};
- IF( EQ_16( i, 0 ) )
+ IF( i == 0 )
{
{
- y[1] = xx[i + 1 * dim1];
+ y[1] = xx[add( i, i_mult( 1, dim1 ) )];
+ move64();
};
{
- y[2] = xx[i + 2 * dim1];
+ y[2] = xx[add( i, i_mult( 2, dim1 ) )];
+ move64();
};
{
- y[3] = xx[i + 3 * dim1];
+ y[3] = xx[add( i, i_mult( 3, dim1 ) )];
+ move64();
};
{
- y[4] = xx[i + 4 * dim1];
+ y[4] = xx[add( i, i_mult( 4, dim1 ) )];
+ move64();
};
{
- y[5] = xx[i + 5 * dim1];
+ y[5] = xx[add( i, i_mult( 5, dim1 ) )];
+ move64();
};
{
- y[6] = xx[i + 6 * dim1];
+ y[6] = xx[add( i, i_mult( 6, dim1 ) )];
+ move64();
};
{
- y[7] = xx[i + 7 * dim1];
+ y[7] = xx[add( i, i_mult( 7, dim1 ) )];
+ move64();
};
}
ELSE
{
{
- y[1] = CL_mac_j( CL_scale( xx[i + 1 * dim1], W[sc * i + sc * 1 * dim1 - Woff] ),
- CL_scale( xx[i + 1 * dim1], W[sc * i + sc * 1 * dim1 + 1 - Woff] ) );
+ y[1] = CL_mac_j( CL_scale( xx[add( i, i_mult( 1, dim1 ) )], W[sub( add( i_mult( sc, i ), i_mult( i_mult( sc, 1 ), dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 1, dim1 ) )], W[sub( add( add( i_mult( sc, i ), i_mult( i_mult( sc, 1 ), dim1 ) ), 1 ), Woff )] ) );
+ move64();
};
{
- y[2] = CL_mac_j( CL_scale( xx[i + 2 * dim1], W[sc * i + sc * 2 * dim1 - Woff] ),
- CL_scale( xx[i + 2 * dim1], W[sc * i + sc * 2 * dim1 + 1 - Woff] ) );
+ y[2] = CL_mac_j( CL_scale( xx[add( i, i_mult( 2, dim1 ) )], W[sub( add( i_mult( sc, i ), i_mult( i_mult( sc, 2 ), dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 2, dim1 ) )], W[sub( add( add( i_mult( sc, i ), i_mult( i_mult( sc, 2 ), dim1 ) ), 1 ), Woff )] ) );
+ move64();
};
{
- y[3] = CL_mac_j( CL_scale( xx[i + 3 * dim1], W[sc * i + sc * 3 * dim1 - Woff] ),
- CL_scale( xx[i + 3 * dim1], W[sc * i + sc * 3 * dim1 + 1 - Woff] ) );
+ y[3] = CL_mac_j( CL_scale( xx[add( i, i_mult( 3, dim1 ) )], W[sub( add( i_mult( sc, i ), i_mult( i_mult( sc, 3 ), dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 3, dim1 ) )], W[sub( add( add( i_mult( sc, i ), i_mult( i_mult( sc, 3 ), dim1 ) ), 1 ), Woff )] ) );
+ move64();
};
{
- y[4] = CL_mac_j( CL_scale( xx[i + 4 * dim1], W[sc * i + sc * 4 * dim1 - Woff] ),
- CL_scale( xx[i + 4 * dim1], W[sc * i + sc * 4 * dim1 + 1 - Woff] ) );
+ y[4] = CL_mac_j( CL_scale( xx[add( i, i_mult( 4, dim1 ) )], W[sub( add( i_mult( sc, i ), i_mult( i_mult( sc, 4 ), dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 4, dim1 ) )], W[sub( add( add( i_mult( sc, i ), i_mult( i_mult( sc, 4 ), dim1 ) ), 1 ), Woff )] ) );
+ move64();
};
{
- y[5] = CL_mac_j( CL_scale( xx[i + 5 * dim1], W[sc * i + sc * 5 * dim1 - Woff] ),
- CL_scale( xx[i + 5 * dim1], W[sc * i + sc * 5 * dim1 + 1 - Woff] ) );
+ y[5] = CL_mac_j( CL_scale( xx[add( i, i_mult( 5, dim1 ) )], W[sub( add( i_mult( sc, i ), i_mult( i_mult( sc, 5 ), dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 5, dim1 ) )], W[sub( add( add( i_mult( sc, i ), i_mult( i_mult( sc, 5 ), dim1 ) ), 1 ), Woff )] ) );
+ move64();
};
{
- y[6] = CL_mac_j( CL_scale( xx[i + 6 * dim1], W[sc * i + sc * 6 * dim1 - Woff] ),
- CL_scale( xx[i + 6 * dim1], W[sc * i + sc * 6 * dim1 + 1 - Woff] ) );
+ y[6] = CL_mac_j( CL_scale( xx[add( i, i_mult( 6, dim1 ) )], W[sub( add( i_mult( sc, i ), i_mult( i_mult( sc, 6 ), dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 6, dim1 ) )], W[sub( add( add( i_mult( sc, i ), i_mult( i_mult( sc, 6 ), dim1 ) ), 1 ), Woff )] ) );
+ move64();
};
{
- y[7] = CL_mac_j( CL_scale( xx[i + 7 * dim1], W[sc * i + sc * 7 * dim1 - Woff] ),
- CL_scale( xx[i + 7 * dim1], W[sc * i + sc * 7 * dim1 + 1 - Woff] ) );
+ y[7] = CL_mac_j( CL_scale( xx[add( i, i_mult( 7, dim1 ) )], W[sub( add( i_mult( sc, i ), i_mult( i_mult( sc, 7 ), dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( 7, dim1 ) )], W[sub( add( add( i_mult( sc, i ), i_mult( i_mult( sc, 7 ), dim1 ) ), 1 ), Woff )] ) );
+ move64();
};
}
t[0] = CL_add( y[0], y[4] );
+ move64();
t[1] = CL_sub( y[0], y[4] );
+ move64();
t[2] = CL_add( y[1], y[5] );
+ move64();
t[3] = CL_sub( y[1], y[5] );
+ move64();
t[4] = CL_add( y[2], y[6] );
+ move64();
t[5] = CL_sub( y[2], y[6] );
+ move64();
t[6] = CL_add( y[3], y[7] );
+ move64();
t[7] = CL_sub( y[3], y[7] );
+ move64();
s[0] = CL_add( t[0], t[4] );
+ move64();
s[2] = CL_sub( t[0], t[4] );
+ move64();
s[4] = CL_mac_j( t[1], t[5] );
+ move64();
s[5] = CL_msu_j( t[1], t[5] );
+ move64();
s[1] = CL_add( t[2], t[6] );
+ move64();
s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) );
+ move64();
t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) );
+ move64();
t[1] = CL_sub( t[3], t[7] );
+ move64();
s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 );
+ move64();
s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 );
+ move64();
s[7] = CL_conjugate( s[7] );
-
- x[i + 0 * dim1] = CL_add( s[0], s[1] );
- x[i + 1 * dim1] = CL_add( s[5], s[6] );
- x[i + 2 * dim1] = CL_sub( s[2], s[3] );
- x[i + 3 * dim1] = CL_add( s[4], s[7] );
- x[i + 4 * dim1] = CL_sub( s[0], s[1] );
- x[i + 5 * dim1] = CL_sub( s[5], s[6] );
- x[i + 6 * dim1] = CL_add( s[2], s[3] );
- x[i + 7 * dim1] = CL_sub( s[4], s[7] );
+ move64();
+
+ x[i] = CL_add( s[0], s[1] ); /*x[i + 0 * dim1] = CL_add( s[0], s[1] )*/
+ move64();
+ x[add( i, i_mult( 1, dim1 ) )] = CL_add( s[5], s[6] );
+ move64();
+ x[add( i, i_mult( 2, dim1 ) )] = CL_sub( s[2], s[3] );
+ move64();
+ x[add( i, i_mult( 3, dim1 ) )] = CL_add( s[4], s[7] );
+ move64();
+ x[add( i, i_mult( 4, dim1 ) )] = CL_sub( s[0], s[1] );
+ move64();
+ x[add( i, i_mult( 5, dim1 ) )] = CL_sub( s[5], s[6] );
+ move64();
+ x[add( i, i_mult( 6, dim1 ) )] = CL_add( s[2], s[3] );
+ move64();
+ x[add( i, i_mult( 7, dim1 ) )] = CL_sub( s[4], s[7] );
+ move64();
}
}
BREAK;
@@ -5083,32 +6805,35 @@ static void fft_lenN(
FOR( j = 0; j < dim2; j++ )
{
{
- y[j] = xx[0 + j * dim1];
+ y[j] = xx[0 + i_mult( j, dim1 )]; /*y[j] = xx[0 + j * dim1];*/
};
}
fft_len10( &y[0] );
FOR( j = 0; j < dim2; j++ )
{
- x[0 + j * dim1] = y[j];
+ x[0 + i_mult( j, dim1 )] = y[j];
+ move64();
}
FOR( i = 1; i < dim1; i++ )
{
{
y[( 0 + 0 )] = xx[i + ( 0 + 0 ) * dim1];
+ move64();
}
FOR( j = 1; j < dim2; j++ )
{
{
- y[( j + 0 )] = CL_mac_j( CL_scale( xx[i + ( j + 0 ) * dim1], W[sc * i + sc * j * dim1 - Woff] ),
- CL_scale( xx[i + ( j + 0 ) * dim1], W[sc * i + sc * j * dim1 + 1 - Woff] ) );
+ y[( j + 0 )] = CL_mac_j( CL_scale( xx[add( i, i_mult( ( j + 0 ), dim1 ) )], W[sub( add( i_mult( sc, i ), i_mult( i_mult( sc, j ), dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( ( j + 0 ), dim1 ) )], W[sub( add( add( i_mult( sc, i ), i_mult( i_mult( sc, j ), dim1 ) ), 1 ), Woff )] ) );
+ move64();
}
}
fft_len10( &y[0] );
FOR( j = 0; j < dim2; j++ )
{
- x[i + j * dim1] = y[j];
+ x[add( i, i_mult( j, dim1 ) )] = y[j];
}
}
BREAK;
@@ -5120,14 +6845,15 @@ static void fft_lenN(
FOR( j = 0; j < dim2; j++ )
{
{
- y[j] = xx[0 + j * dim1];
+ y[j] = xx[0 + i_mult( j, dim1 )];
+ move64();
};
}
fft_len16( &y[0] );
FOR( j = 0; j < dim2; j++ )
{
- x[0 + j * dim1] = y[j];
+ x[0 + i_mult( j, dim1 )] = y[j];
}
FOR( i = 1; i < dim1; i++ )
@@ -5139,14 +6865,16 @@ static void fft_lenN(
FOR( j = 1; j < dim2; j++ )
{
{
- y[( j + 0 )] = CL_mac_j( CL_scale( xx[i + ( j + 0 ) * dim1], W[sc * i + sc * j * dim1 - Woff] ),
- CL_scale( xx[i + ( j + 0 ) * dim1], W[sc * i + sc * j * dim1 + 1 - Woff] ) );
+ y[( j + 0 )] = CL_mac_j( CL_scale( xx[add( i, i_mult( ( j + 0 ), dim1 ) )], W[sub( add( i_mult( sc, i ), i_mult( i_mult( sc, j ), dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( ( j + 0 ), dim1 ) )], W[sub( add( add( i_mult( sc, i ), i_mult( i_mult( sc, j ), dim1 ) ), 1 ), Woff )] ) );
+ move64();
}
}
fft_len16( &y[0] );
FOR( j = 0; j < dim2; j++ )
{
- x[i + j * dim1] = y[j];
+ x[add( i, i_mult( j, dim1 ) )] = y[j];
+ move64();
}
}
BREAK;
@@ -5158,40 +6886,47 @@ static void fft_lenN(
FOR( j = 0; j < dim2; j++ )
{
{
- y[j] = xx[0 + j * dim1];
+ y[j] = xx[0 + i_mult( j, dim1 )];
+ move64();
};
}
fft_len20_fx( &y[0] );
FOR( j = 0; j < dim2; j++ )
{
- x[0 + j * dim1] = y[j];
+ x[0 + i_mult( j, dim1 )] = y[j];
+ move64();
}
FOR( i = 1; i < dim1; i++ )
{
{
- y[( 0 + 0 )] = xx[i + ( 0 + 0 ) * dim1];
+ y[( 0 + 0 )] = xx[add( i, ( 0 + 0 ) * dim1 )];
+ move64();
}
{
- y[( 0 + 1 )] = CL_mac_j( CL_scale( xx[i + ( 0 + 1 ) * dim1], W[len + sc * i + 0 * dim1 - Woff] ),
- CL_scale( xx[i + ( 0 + 1 ) * dim1], W[len + sc * i + 0 * dim1 + 1 - Woff] ) );
+ y[( 0 + 1 )] = CL_mac_j( CL_scale( xx[add( i, i_mult( ( 0 + 1 ), dim1 ) )], W[sub( add( len, i_mult( sc, i ) ) + 0 * dim1, Woff )] ),
+ CL_scale( xx[add( i, i_mult( ( 0 + 1 ), dim1 ) )], W[sub( add( add( len, i_mult( sc, i ) ) + 0 * dim1, 1 ), Woff )] ) );
+ move64();
}
FOR( j = 2; j < dim2; j = j + 2 )
{
{
- y[( j + 0 )] = CL_mac_j( CL_scale( xx[i + ( j + 0 ) * dim1], W[sc * i + j * dim1 - Woff] ),
- CL_scale( xx[i + ( j + 0 ) * dim1], W[sc * i + j * dim1 + 1 - Woff] ) );
+ y[( j + 0 )] = CL_mac_j( CL_scale( xx[add( i, i_mult( ( j + 0 ), dim1 ) )], W[sub( add( i_mult( sc, i ), i_mult( j, dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( ( j + 0 ), dim1 ) )], W[sub( add( add( i_mult( sc, i ), i_mult( j, dim1 ) ), 1 ), Woff )] ) );
+ move64();
}
{
- y[( j + 1 )] = CL_mac_j( CL_scale( xx[i + ( j + 1 ) * dim1], W[len + sc * i + j * dim1 - Woff] ),
- CL_scale( xx[i + ( j + 1 ) * dim1], W[len + sc * i + j * dim1 + 1 - Woff] ) );
+ y[( j + 1 )] = CL_mac_j( CL_scale( xx[add( i, i_mult( ( j + 1 ), dim1 ) )], W[sub( add( add( len, i_mult( sc, i ) ), i_mult( j, dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( ( j + 1 ), dim1 ) )], W[sub( add( add( add( len, i_mult( sc, i ) ), i_mult( j, dim1 ) ), 1 ), Woff )] ) );
+ move64();
}
}
fft_len20_fx( &y[0] );
FOR( j = 0; j < dim2; j++ )
{
x[i + j * dim1] = y[j];
+ move64();
}
}
BREAK;
@@ -5204,39 +6939,46 @@ static void fft_lenN(
{
{
y[j] = xx[0 + j * dim1];
+ move64();
};
}
fft_len32( &y[0] );
FOR( j = 0; j < dim2; j++ )
{
x[0 + j * dim1] = y[j];
+ move64();
}
FOR( i = 1; i < dim1; i++ )
{
{
y[( 0 + 0 )] = xx[i + ( 0 + 0 ) * dim1];
+ move64();
}
{
- y[( 0 + 1 )] = CL_mac_j( CL_scale( xx[i + ( 0 + 1 ) * dim1], W[len + sc * i + 0 * dim1 - Woff] ),
- CL_scale( xx[i + ( 0 + 1 ) * dim1], W[len + sc * i + 0 * dim1 + 1 - Woff] ) );
+ y[( 0 + 1 )] = CL_mac_j( CL_scale( xx[add( i, i_mult( ( 0 + 1 ), dim1 ) )], W[sub( add( len, i_mult( sc, i ) ) + 0 * dim1, Woff )] ),
+ CL_scale( xx[add( i, i_mult( ( 0 + 1 ), dim1 ) )], W[sub( add( add( len, i_mult( sc, i ) ) + 0 * dim1, 1 ), Woff )] ) );
+ move64();
}
FOR( j = 2; j < dim2; j = j + 2 )
{
{
- y[( j + 0 )] = CL_mac_j( CL_scale( xx[i + ( j + 0 ) * dim1], W[sc * i + j * dim1 - Woff] ),
- CL_scale( xx[i + ( j + 0 ) * dim1], W[sc * i + j * dim1 + 1 - Woff] ) );
+ y[( j + 0 )] = CL_mac_j( CL_scale( xx[add( i, i_mult( ( j + 0 ), dim1 ) )], W[sub( add( i_mult( sc, i ), i_mult( j, dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( ( j + 0 ), dim1 ) )], W[sub( add( add( i_mult( sc, i ), i_mult( j, dim1 ) ), 1 ), Woff )] ) );
+ move64();
}
{
- y[( j + 1 )] = CL_mac_j( CL_scale( xx[i + ( j + 1 ) * dim1], W[len + sc * i + j * dim1 - Woff] ),
- CL_scale( xx[i + ( j + 1 ) * dim1], W[len + sc * i + j * dim1 + 1 - Woff] ) );
+ y[( j + 1 )] = CL_mac_j( CL_scale( xx[add( i, i_mult( ( j + 1 ), dim1 ) )], W[sub( add( add( len, i_mult( sc, i ) ), i_mult( j, dim1 ) ), Woff )] ),
+ CL_scale( xx[add( i, i_mult( ( j + 1 ), dim1 ) )], W[sub( add( add( add( len, i_mult( sc, i ) ), i_mult( j, dim1 ) ), 1 ), Woff )] ) );
+ move64();
}
}
fft_len32( &y[0] );
FOR( j = 0; j < dim2; j++ )
{
- x[i + j * dim1] = y[j];
+ x[add( i, i_mult( j, dim1 ) )] = y[j];
+ move64();
}
}
BREAK;
@@ -5260,10 +7002,12 @@ void fft_fx(
{
cmplx x[960];
- FOR( Word32 j = 0; j < length; j++ )
+ FOR( Word16 j = 0; j < length; j++ )
{
- x[j].re = re[s * j];
- x[j].im = im[s * j];
+ x[j].re = re[i_mult( s, j )];
+ move32();
+ x[j].im = im[i_mult( s, j )];
+ move32();
}
SWITCH( length )
@@ -5323,10 +7067,12 @@ void fft_fx(
assert( !"fft length is not supported!" );
}
- FOR( Word32 j = 0; j < length; j++ )
+ FOR( Word16 j = 0; j < length; j++ )
{
- re[s * j] = x[j].re;
- im[s * j] = x[j].im;
+ re[i_mult( s, j )] = x[j].re;
+ move32();
+ im[i_mult( s, j )] = x[j].im;
+ move32();
}
return;
@@ -5343,33 +7089,63 @@ void rfft_fx(
Word32 tmp, t1, t2, t3, t4;
Word16 s1, s2;
- sizeOfFft2 = length >> 1;
- sizeOfFft4 = length >> 2;
+ sizeOfFft2 = shr( length, 1 );
+ sizeOfFft4 = shr( length, 2 );
SWITCH( sizeOfFft2 )
{
case 80:
s1 = 409;
+ move16();
s2 = -409;
+ move16();
BREAK;
case 128:
s1 = 256;
+ move16();
s2 = -256;
+ move16();
BREAK;
case 160:
s1 = 204;
+ move16();
s2 = -204;
+ move16();
+ BREAK;
+ case 256:
+ s1 = 128;
+ move16();
+ s2 = -128;
+ move16();
BREAK;
case 320:
s1 = 102;
+ move16();
s2 = -102;
+ move16();
BREAK;
case 480:
s1 = 68;
+ move16();
s2 = -68;
+ move16();
+ BREAK;
+ case 640:
+ s1 = 51;
+ move16();
+ s2 = -51;
+ move16();
+ BREAK;
+ case 960:
+ s1 = 34;
+ move16();
+ s2 = -34;
+ move16();
BREAK;
default:
s1 = -1;
+ move16();
s2 = -1;
+ move16();
printf( "Configuration not supported" );
assert( 0 );
}
@@ -5383,21 +7159,27 @@ void rfft_fx(
tmp = L_add( x[0], x[1] );
x[1] = L_sub( x[0], x[1] );
+ move32();
x[0] = tmp;
+ move32();
FOR( i = 1; i <= sizeOfFft4; i++ )
{
- t1 = L_sub( x[2 * i], x[length - 2 * i] );
- t2 = L_add( x[2 * i + 1], x[length - 2 * i + 1] );
+ t1 = L_sub( x[2 * i], x[sub( length, shl( i, 1 ) )] );
+ t2 = L_add( x[add( shl( i, 1 ), 1 )], x[add( sub( length, shl( i, 1 ) ), 1 )] );
t3 = L_sub( Mpy_32_16_1( t1, w[i] ), Mpy_32_16_1( t2, w[i + sizeOfFft4] ) );
t4 = L_add( Mpy_32_16_1( t1, w[i + sizeOfFft4] ), Mpy_32_16_1( t2, w[i] ) );
- t1 = L_add( x[2 * i], x[length - 2 * i] );
- t2 = L_sub( x[2 * i + 1], x[length - 2 * i + 1] );
+ t1 = L_add( x[2 * i], x[sub( length, shl( i, 1 ) )] );
+ t2 = L_sub( x[add( shl( i, 1 ), 1 )], x[add( sub( length, shl( i, 1 ) ), 1 )] );
x[2 * i] = Mpy_32_16_1( L_sub( t1, t3 ), 16384 );
- x[2 * i + 1] = Mpy_32_16_1( L_sub( t2, t4 ), 16384 );
- x[length - 2 * i] = Mpy_32_16_1( L_add( t1, t3 ), 16384 );
- x[length - 2 * i + 1] = Mpy_32_16_1( L_negate( L_add( t2, t4 ) ), 16384 );
+ move32();
+ x[add( shl( i, 1 ), 1 )] = Mpy_32_16_1( L_sub( t2, t4 ), 16384 );
+ move32();
+ x[sub( length, shl( i, 1 ) )] = Mpy_32_16_1( L_add( t1, t3 ), 16384 );
+ move32();
+ x[add( sub( length, shl( i, 1 ) ), 1 )] = Mpy_32_16_1( L_negate( L_add( t2, t4 ) ), 16384 );
+ move32();
}
BREAK;
@@ -5406,21 +7188,27 @@ void rfft_fx(
tmp = Mpy_32_16_1( L_add( x[0], x[1] ), 16384 );
x[1] = Mpy_32_16_1( L_sub( x[1], x[0] ), 16384 );
+ move32();
x[0] = tmp;
+ move32();
FOR( i = 1; i <= sizeOfFft4; i++ )
{
- t1 = L_sub( x[2 * i], x[length - 2 * i] );
- t2 = L_add( x[2 * i + 1], x[length - 2 * i + 1] );
- t3 = L_add( Mpy_32_16_1( t1, w[i] ), Mpy_32_16_1( t2, w[i + sizeOfFft4] ) );
- t4 = L_sub( Mpy_32_16_1( t2, w[i] ), Mpy_32_16_1( t1, w[i + sizeOfFft4] ) );
- t1 = L_add( x[2 * i], x[length - 2 * i] );
- t2 = L_sub( x[2 * i + 1], x[length - 2 * i + 1] );
+ t1 = L_sub( x[2 * i], x[sub( length, shl( i, 1 ) )] );
+ t2 = L_add( x[add( shl( i, 1 ), 1 )], x[add( sub( length, shl( i, 1 ) ), 1 )] );
+ t3 = L_add( Mpy_32_16_1( t1, w[i] ), Mpy_32_16_1( t2, w[add( i, sizeOfFft4 )] ) );
+ t4 = L_sub( Mpy_32_16_1( t2, w[i] ), Mpy_32_16_1( t1, w[add( i, sizeOfFft4 )] ) );
+ t1 = L_add( x[2 * i], x[sub( length, shl( i, 1 ) )] );
+ t2 = L_sub( x[add( shl( i, 1 ), 1 )], x[add( sub( length, shl( i, 1 ) ), 1 )] );
x[2 * i] = Mpy_32_16_1( L_sub( t1, t3 ), 16384 );
- x[2 * i + 1] = Mpy_32_16_1( L_sub( t4, t2 ), 16384 );
- x[length - 2 * i] = Mpy_32_16_1( L_add( t1, t3 ), 16384 );
- x[length - 2 * i + 1] = Mpy_32_16_1( L_add( t2, t4 ), 16384 );
+ move32();
+ x[add( shl( i, 1 ), 1 )] = Mpy_32_16_1( L_sub( t4, t2 ), 16384 );
+ move32();
+ x[sub( length, shl( i, 1 ) )] = Mpy_32_16_1( L_add( t1, t3 ), 16384 );
+ move32();
+ x[add( sub( length, shl( i, 1 ) ), 1 )] = Mpy_32_16_1( L_add( t2, t4 ), 16384 );
+ move32();
}
fft_fx( x, x + 1, sizeOfFft2, 2 );
@@ -5428,7 +7216,9 @@ void rfft_fx(
FOR( i = 0; i < length; i += 2 )
{
x[i] = Mpy_32_16_1( x[i], s1 );
+ move32();
x[i + 1] = Mpy_32_16_1( x[i + 1], s2 );
+ move32();
}
BREAK;
@@ -5439,28 +7229,45 @@ void rfft_fx(
Word16 find_guarded_bits_fx( Word32 n )
{
- return n <= 1 ? 0 : n <= 2 ? 1
- : n <= 4 ? 2
- : n <= 8 ? 3
- : n <= 16 ? 4
- : n <= 32 ? 5
- : n <= 64 ? 6
- : n <= 128 ? 7
- : n <= 256 ? 8
- : n <= 512 ? 9
- : n <= 1024 ? 10
- : n <= 2048 ? 11
- : n <= 4096 ? 12
- : n <= 8192 ? 13
- : n <= 16384 ? 14
- : 15;
+ // return n <= 1 ? 0 : n <= 2 ? 1
+ // : n <= 4 ? 2
+ // : n <= 8 ? 3
+ // : n <= 16 ? 4
+ // : n <= 32 ? 5
+ // : n <= 64 ? 6
+ // : n <= 128 ? 7
+ // : n <= 256 ? 8
+ // : n <= 512 ? 9
+ // : n <= 1024 ? 10
+ // : n <= 2048 ? 11
+ // : n <= 4096 ? 12
+ // : n <= 8192 ? 13
+ // : n <= 16384 ? 14
+ // : 15;
+ /*Word16 val = 0;
+ move32();
+ test();
+ WHILE( GT_32( n, L_shl( 1, val ) ) && LT_32( val, 16 ) )
+ {
+ val = add( val, 1 );
+ }*/
+ IF( LE_32( n, 1 ) )
+ {
+ return 0;
+ }
+ ELSE
+ {
+
+ return sub( 31, norm_l( L_sub( n, 1 ) ) );
+ }
}
Word16 L_norm_arr( Word32 *arr, Word16 size )
{
Word16 q = 31;
- FOR( int i = 0; i < size; i++ )
- if ( arr[i] != 0 )
+ move16();
+ FOR( Word16 i = 0; i < size; i++ )
+ IF( arr[i] != 0 )
{
q = s_min( q, norm_l( arr[i] ) );
}
@@ -5470,15 +7277,17 @@ Word16 L_norm_arr( Word32 *arr, Word16 size )
Word16 get_min_scalefactor( Word32 x, Word32 y )
{
Word16 scf = Q31;
- IF( EQ_32( x, 0 ) && EQ_32( y, 0 ) )
+ move16();
+ test();
+ IF( x == 0 && y == 0 )
{
return 0;
}
- IF( NE_32( x, 0 ) )
+ IF( x != 0 )
{
scf = s_min( scf, norm_l( x ) );
}
- IF( NE_32( y, 0 ) )
+ IF( y != 0 )
{
scf = s_min( scf, norm_l( y ) );
}
@@ -5487,8 +7296,8 @@ Word16 get_min_scalefactor( Word32 x, Word32 y )
Flag is_zero_arr( Word32 *arr, Word16 size )
{
- FOR( int i = 0; i < size; i++ )
- if ( arr[i] != 0 )
+ FOR( Word16 i = 0; i < size; i++ )
+ IF( arr[i] != 0 )
{
return 0;
}
diff --git a/lib_com/fft_fx_evs.c b/lib_com/fft_fx_evs.c
index b36bac55fd931ea25aba39c6fbd2e1e9b43cb2a3..c17de364316b9a4093286ce66ae45358534f4300 100644
--- a/lib_com/fft_fx_evs.c
+++ b/lib_com/fft_fx_evs.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
#include "stl.h"
#include
@@ -808,10 +807,8 @@ static void cftbsub_fx(
move32();
a[j1] = x0r;
move32();
- move32();
a[j1 + 1] = x0i;
move32();
- move32();
}
}
}
@@ -842,7 +839,7 @@ static void rftfsub_fx(
{
k = sub( n, j );
kk = add( kk, ks );
- wkr = sub( 8192, c[nc - kk] );
+ wkr = sub( 8192, c[sub( nc, kk )] );
wki = c[kk];
move16();
xr = L_sub( a[j], a[k] );
@@ -888,7 +885,7 @@ static void rftbsub_fx(
{
k = sub( n, j );
kk = add( kk, ks );
- wkr = sub( 8192, c[nc - kk] );
+ wkr = sub( 8192, c[sub( nc, kk )] );
wki = c[kk];
move16();
xr = L_sub( a[j], a[k] );
@@ -936,8 +933,8 @@ static void dctsub_fx(
{
k = sub( n, j );
kk = add( kk, ks );
- wkr = sub( c[kk], c[nc - kk] );
- wki = add( c[kk], c[nc - kk] );
+ wkr = sub( c[kk], c[sub( nc, kk )] );
+ wki = add( c[kk], c[sub( nc, kk )] );
xr = L_sub( Mult_32_16( L_shl( a[j], 1 ), wki ), Mult_32_16( L_shl( a[k], 1 ), wkr ) );
a[j] = L_add( Mult_32_16( L_shl( a[j], 1 ), wkr ), Mult_32_16( L_shl( a[k], 1 ), wki ) );
move32();
@@ -945,6 +942,7 @@ static void dctsub_fx(
move32();
}
a[m] = Mult_32_16( L_shl( a[m], 1 ), c[0] );
+ move16();
}
/*-----------------------------------------------------------------*
@@ -967,7 +965,9 @@ void edct2_fx(
Word32 xr;
*q = Exp16Array( n, in );
+ move16();
*q = add( *q, 6 );
+ move16();
FOR( j = 0; j < n; j++ )
{
a[j] = L_shl( (Word32) in[j], *q );
@@ -1264,6 +1264,7 @@ static void fft5_32_16fx(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
i0 = Idx[0];
move16();
@@ -1509,7 +1510,6 @@ static void fft32_5_16fx(
Word16 i, id, jd;
Word16 z[64];
- move16(); /*penalty for 1 ptr init */
FOR( i = 0; i < 32; i++ )
{
id = Idx[i];
@@ -1522,7 +1522,6 @@ static void fft32_5_16fx(
cdftForw_16fx( 64, z, Ip_fft32, w_fft32_16fx );
- move16(); /*penalty for 1 ptr init */
FOR( i = 0; i < 32; i++ )
{
jd = Odx_fft32_5[i];
@@ -1604,7 +1603,6 @@ void DoRTFT128_16fx(
Word16 i;
Word16 z[256];
- move16(); /*penalty for 1 ptr init */
FOR( i = 0; i < 128; i++ )
{
z[2 * i] = x[i];
@@ -1619,8 +1617,6 @@ void DoRTFT128_16fx(
move16();
y[0] = z[1];
move16();
- move16(); /*penalty for 1 ptr init */
- move16(); /*penalty for 1 ptr init */
FOR( i = 1; i < 128; i++ )
{
x[128 - i] = z[2 * i];
@@ -1840,6 +1836,7 @@ static void cftfsub_16fx(
Word16 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
l = 2;
@@ -1940,6 +1937,7 @@ static void cft1st_16fx(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
#ifdef BASOP_NOGLOB
@@ -2042,20 +2040,24 @@ static void cft1st_16fx(
#ifdef BASOP_NOGLOB
a[10] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
tmp = add_o( x0r, x0i, &Overflow );
L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */
a[11] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /* Q(Qx+Q_edct) */
+ move16();
x0r = add_o( x3i, x1r, &Overflow );
x0i = sub_o( x3r, x1i, &Overflow );
tmp = sub_o( x0i, x0r, &Overflow );
L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */
a[14] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
tmp = add_o( x0i, x0r, &Overflow );
L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */
a[15] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
#else
a[10] = round_fx( L_shl( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */
@@ -2114,30 +2116,36 @@ static void cft1st_16fx(
L_tmp = Mult_32_16( wk2r, x0r ); /*Q(15+Qx+Q_edct) */
L_tmp = Msub_32_16( L_tmp, wk2i, x0i ); /*Q(15+Qx+Q_edct) */
a[j + 4] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
L_tmp = Mult_32_16( wk2r, x0i ); /*Q(15+Qx+Q_edct) */
L_tmp = Madd_32_16( L_tmp, wk2i, x0r ); /*Q(15+Qx+Q_edct) */
a[j + 5] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
x0r = sub_o( x1r, x3i, &Overflow );
x0i = add_o( x1i, x3r, &Overflow );
L_tmp = Mult_32_16( wk1r, x0r ); /*Q(15+Qx+Q_edct) */
L_tmp = Msub_32_16( L_tmp, wk1i, x0i ); /*Q(15+Qx+Q_edct) */
a[j + 2] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
L_tmp = Mult_32_16( wk1r, x0i ); /*Q(15+Qx+Q_edct) */
L_tmp = Madd_32_16( L_tmp, wk1i, x0r ); /*Q(15+Qx+Q_edct) */
a[j + 3] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
x0r = add_o( x1r, x3i, &Overflow );
x0i = sub_o( x1i, x3r, &Overflow );
L_tmp = Mult_32_16( wk3r, x0r ); /*Q(15+Qx+Q_edct) */
L_tmp = Msub_32_16( L_tmp, wk3i, x0i ); /*Q(15+Qx+Q_edct) */
a[j + 6] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
L_tmp = Mult_32_16( wk3r, x0i ); /*Q(15+Qx+Q_edct) */
L_tmp = Madd_32_16( L_tmp, wk3i, x0r ); /*Q(15+Qx+Q_edct) */
a[j + 7] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
wk1r = w[k2 + 2];
move32();
@@ -2168,21 +2176,25 @@ static void cft1st_16fx(
L_tmp = Mult_32_16( wk2i, tmp ); /*Q(15+Qx+Q_edct) */
L_tmp = Msub_32_16( L_tmp, wk2r, x0i ); /*Q(15+Qx+Q_edct) */
a[j + 12] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
tmp = negate( x0i );
L_tmp = Mult_32_16( wk2i, tmp ); /*Q(15+Qx+Q_edct) */
L_tmp = Madd_32_16( L_tmp, wk2r, x0r ); /*Q(15+Qx+Q_edct) */
a[j + 13] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
x0r = sub_o( x1r, x3i, &Overflow );
x0i = add_o( x1i, x3r, &Overflow );
L_tmp = Mult_32_16( wk1r, x0r ); /*Q(15+Qx+Q_edct) */
L_tmp = Msub_32_16( L_tmp, wk1i, x0i ); /*Q(15+Qx+Q_edct) */
a[j + 10] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
L_tmp = Mult_32_16( wk1r, x0i ); /*Q(15+Qx+Q_edct) */
L_tmp = Madd_32_16( L_tmp, wk1i, x0r ); /*Q(15+Qx+Q_edct) */
a[j + 11] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
x0r = add_o( x1r, x3i, &Overflow );
x0i = sub_o( x1i, x3r, &Overflow );
@@ -2190,10 +2202,12 @@ static void cft1st_16fx(
L_tmp = Mult_32_16( wk3r, x0r ); /*Q(15+Qx+Q_edct) */
L_tmp = Msub_32_16( L_tmp, wk3i, x0i ); /*Q(15+Qx+Q_edct) */
a[j + 14] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
L_tmp = Mult_32_16( wk3r, x0i ); /*Q(15+Qx+Q_edct) */
L_tmp = Madd_32_16( L_tmp, wk3i, x0r ); /*Q(15+Qx+Q_edct) */
a[j + 15] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
#else
x0r = add( a[j], a[j + 2] );
x0i = add( a[j + 1], a[j + 3] );
@@ -2318,9 +2332,9 @@ static void cftmdl_16fx(
Word32 L_x0r, L_x0i;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
m = shl( l, 2 );
- move16();
FOR( j = 0; j < l; j += 2 )
{
#ifdef BASOP_NOGLOB
@@ -2413,20 +2427,24 @@ static void cftmdl_16fx(
tmp = sub_o( x0r, x0i, &Overflow );
L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */
a[j1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
tmp = add_o( x0r, x0i, &Overflow );
L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */
a[j1 + 1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
x0r = add_o( x3i, x1r, &Overflow );
x0i = sub_o( x3r, x1i, &Overflow );
tmp = sub_o( x0i, x0r, &Overflow );
L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */
a[j3] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
tmp = add_o( x0i, x0r, &Overflow );
L_tmp = Mult_32_16( wk1r, tmp ); /*Q(15+Qx+Q_edct) */
a[j3 + 1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
#else
j1 = add( j, l );
j2 = add( j1, l );
@@ -2517,10 +2535,12 @@ static void cftmdl_16fx(
L_tmp = Mult_32_16( wk2r, x0r ); /*Q(15+Qx+Q_edct) */
L_tmp = Msub_32_16( L_tmp, wk2i, x0i ); /*Q(15+Qx+Q_edct) */
a[j2] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
L_tmp = Mult_32_16( wk2r, x0i ); /*Q(15+Qx+Q_edct) */
L_tmp = Madd_32_16( L_tmp, wk2i, x0r ); /*Q(15+Qx+Q_edct) */
a[j2 + 1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
x0r = sub_o( x1r, x3i, &Overflow );
x0i = add_o( x1i, x3r, &Overflow );
@@ -2528,10 +2548,12 @@ static void cftmdl_16fx(
L_tmp = Mult_32_16( wk1r, x0r ); /*Q(15+Qx+Q_edct) */
L_tmp = Msub_32_16( L_tmp, wk1i, x0i ); /*Q(15+Qx+Q_edct) */
a[j1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
L_tmp = Mult_32_16( wk1r, x0i ); /*Q(15+Qx+Q_edct) */
L_tmp = Madd_32_16( L_tmp, wk1i, x0r ); /*Q(15+Qx+Q_edct) */
a[j1 + 1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
L_x0r = L_add( (Word32) x1r, (Word32) x3i );
L_x0i = L_sub( (Word32) x1i, (Word32) x3r );
@@ -2540,10 +2562,12 @@ static void cftmdl_16fx(
L_tmp = Mult_32_16( wk3r, x0r ); /*Q(15+Qx+Q_edct) */
L_tmp = Msub_32_16( L_tmp, wk3i, x0i ); /*Q(15+Qx+Q_edct) */
a[j3] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
L_tmp = Mult_32_16( wk3r, x0i ); /*Q(15+Qx+Q_edct) */
L_tmp = Madd_32_16( L_tmp, wk3i, x0r ); /*Q(15+Qx+Q_edct) */
a[j3 + 1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
#else
j1 = add( j, l );
j2 = add( j1, l );
@@ -2641,11 +2665,13 @@ static void cftmdl_16fx(
L_tmp = Mult_32_16( wk2i, tmp ); /*Q(15+Qx+Q_edct) */
L_tmp = Msub_32_16( L_tmp, wk2r, x0i ); /*Q(15+Qx+Q_edct) */
a[j2] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
tmp = negate( x0i );
L_tmp = Mult_32_16( wk2i, tmp ); /*Q(15+Qx+Q_edct) */
L_tmp = Madd_32_16( L_tmp, wk2r, x0r ); /*Q(15+Qx+Q_edct) */
a[j2 + 1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
x0r = sub_o( x1r, x3i, &Overflow );
x0i = add_o( x1i, x3r, &Overflow );
@@ -2653,10 +2679,12 @@ static void cftmdl_16fx(
L_tmp = Mult_32_16( wk1r, x0r ); /*Q(15+Qx+Q_edct) */
L_tmp = Msub_32_16( L_tmp, wk1i, x0i ); /*Q(15+Qx+Q_edct) */
a[j1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
L_tmp = Mult_32_16( wk1r, x0i ); /*Q(15+Qx+Q_edct) */
L_tmp = Madd_32_16( L_tmp, wk1i, x0r ); /*Q(15+Qx+Q_edct) */
a[j1 + 1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
x0r = add_o( x1r, x3i, &Overflow );
x0i = sub_o( x1i, x3r, &Overflow );
@@ -2664,10 +2692,12 @@ static void cftmdl_16fx(
L_tmp = Mult_32_16( wk3r, x0r ); /*Q(15+Qx+Q_edct) */
L_tmp = Msub_32_16( L_tmp, wk3i, x0i ); /*Q(15+Qx+Q_edct) */
a[j3] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
L_tmp = Mult_32_16( wk3r, x0i ); /*Q(15+Qx+Q_edct) */
L_tmp = Madd_32_16( L_tmp, wk3i, x0r ); /*Q(15+Qx+Q_edct) */
a[j3 + 1] = round_fx_o( L_shl_o( L_tmp, 1, &Overflow ), &Overflow ); /*Q(Qx+Q_edct) */
+ move16();
#else
j1 = add( j, l );
j2 = add( j1, l );
@@ -2843,6 +2873,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_mac0( acc, *RZ2, t_sin[c2_ind] );
acc = L_mac0( acc, *IZ2, t_sin[s2_ind] );
*RY++ = round_fx( acc ); /* bit growth = 1 (compensated by non-fractional mode MAC). */
+ move16();
acc = L_shl( *IZ0--, 15 );
acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] );
@@ -2850,6 +2881,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_msu0( acc, *RZ2++, t_sin[s2_ind] );
acc = L_mac0( acc, *IZ2--, t_sin[c2_ind] );
*IY-- = round_fx( acc );
+ move16();
c1_ind = add( c1_ind, c1_step );
s1_ind = add( s1_ind, s1_step );
@@ -2867,6 +2899,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_msu0( acc, *RZ2, t_sin[c2_ind] );
acc = L_mac0( acc, *IZ2, t_sin[s2_ind] );
*RY++ = round_fx( acc );
+ move16();
acc = L_shl( *IZ0--, 15 );
acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] );
@@ -2874,6 +2907,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_msu0( acc, *RZ2++, t_sin[s2_ind] );
acc = L_msu0( acc, *IZ2--, t_sin[c2_ind] );
*IY-- = round_fx( acc );
+ move16();
c1_ind = add( c1_ind, c1_step );
s1_ind = add( s1_ind, s1_step );
@@ -2886,11 +2920,14 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_mac0( acc, *RZ1, t_sin[c1_ind] );
acc = L_msu0( acc, *RZ2, t_sin[c2_ind] );
*RY++ = round_fx( acc );
+ move16();
acc = 0;
+ move32();
acc = L_msu0( acc, *RZ1--, t_sin[s1_ind] );
acc = L_msu0( acc, *RZ2--, t_sin[s2_ind] );
*IY-- = round_fx( acc );
+ move16();
IZ0++;
IZ1++;
IZ2++;
@@ -2910,6 +2947,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_msu0( acc, *RZ2, t_sin[c2_ind] );
acc = L_msu0( acc, *IZ2, t_sin[s2_ind] );
*RY++ = round_fx( acc );
+ move16();
acc = L_mult0( *IZ0++, -32768 );
acc = L_msu0( acc, *RZ1--, t_sin[s1_ind] );
@@ -2917,6 +2955,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_msu0( acc, *RZ2--, t_sin[s2_ind] );
acc = L_mac0( acc, *IZ2++, t_sin[c2_ind] );
*IY-- = round_fx( acc );
+ move16();
c1_ind = add( c1_ind, c1_step );
s1_ind = add( s1_ind, s1_step );
@@ -2935,6 +2974,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_msu0( acc, *RZ2, t_sin[c2_ind] );
acc = L_mac0( acc, *IZ2, t_sin[s2_ind] );
*RY++ = round_fx( acc );
+ move16();
acc = L_mult0( *IZ0++, -32768 );
acc = L_msu0( acc, *RZ1--, t_sin[s1_ind] );
@@ -2942,6 +2982,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_mac0( acc, *RZ2--, t_sin[s2_ind] );
acc = L_mac0( acc, *IZ2++, t_sin[c2_ind] );
*IY-- = round_fx( acc );
+ move16();
c1_ind = sub( c1_ind, c1_step );
s1_ind = sub( s1_ind, s1_step );
@@ -2954,11 +2995,13 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_msu0( acc, *RZ1, t_sin[c1_ind] );
acc = L_msu0( acc, *RZ2, t_sin[c2_ind] );
*RY++ = round_fx( acc );
+ move16();
acc = L_deposit_l( 0 );
acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] );
acc = L_mac0( acc, *RZ2++, t_sin[s2_ind] );
*IY-- = round_fx( acc );
+ move16();
IZ0--; /* Just decrement the address counter */
IZ1--;
IZ2--;
@@ -2978,6 +3021,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_msu0( acc, *RZ2, t_sin[c2_ind] );
acc = L_msu0( acc, *IZ2, t_sin[s2_ind] );
*RY++ = round_fx( acc );
+ move16();
acc = L_shl( *IZ0--, 15 );
acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] );
@@ -2985,6 +3029,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_mac0( acc, *RZ2++, t_sin[s2_ind] );
acc = L_msu0( acc, *IZ2--, t_sin[c2_ind] );
*IY-- = round_fx( acc );
+ move16();
c1_ind = sub( c1_ind, c1_step );
s1_ind = sub( s1_ind, s1_step );
@@ -3002,6 +3047,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_mac0( acc, *RZ2, t_sin[c2_ind] );
acc = L_msu0( acc, *IZ2, t_sin[s2_ind] );
*RY++ = round_fx( acc );
+ move16();
acc = L_shl( *IZ0--, 15 );
acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] );
@@ -3009,6 +3055,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_mac0( acc, *RZ2++, t_sin[s2_ind] );
acc = L_mac0( acc, *IZ2--, t_sin[c2_ind] );
*IY-- = round_fx( acc );
+ move16();
c1_ind = sub( c1_ind, c1_step );
s1_ind = sub( s1_ind, s1_step );
@@ -3021,6 +3068,7 @@ void fft3_fx( const Word16 X[], Word16 Y[], const Word16 n )
acc = L_msu0( acc, *RZ1, t_sin[c1_ind] );
acc = L_mac0( acc, *RZ2, t_sin[c2_ind] );
*RY = round_fx( acc );
+ move16();
return;
}
@@ -3151,6 +3199,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_msu0( acc, *IZ1--, t_sin[s1_ind] );
acc = L_msu0( acc, *IZ2++, t_sin[s2_ind] );
*RY1++ = round_fx( acc );
+ move16();
c0_ind = sub( c0_ind, step );
s0_ind = add( s0_ind, step );
@@ -3170,6 +3219,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_msu0( acc, *IZ1, t_sin[s1_ind] );
acc = L_msu0( acc, *IZ2, t_sin[s2_ind] );
*RY1++ = round_fx( acc );
+ move16();
acc = L_mult0( *IZ0--, t_sin[c0_ind] );
acc = L_msu0( acc, *IZ1--, t_sin[c1_ind] );
@@ -3178,6 +3228,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_mac0( acc, *RZ1++, t_sin[s1_ind] );
acc = L_msu0( acc, *RZ2--, t_sin[s2_ind] );
*IY1-- = round_fx( acc );
+ move16();
c0_ind = sub( c0_ind, step );
s0_ind = add( s0_ind, step );
@@ -3198,6 +3249,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_msu0( acc, *IZ1, t_sin[s1_ind] );
acc = L_msu0( acc, *IZ2, t_sin[s2_ind] );
*RY1++ = round_fx( acc );
+ move16();
acc = L_mult0( *IZ0--, t_sin[c0_ind] );
acc = L_msu0( acc, *IZ1--, t_sin[c1_ind] );
@@ -3206,6 +3258,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_mac0( acc, *RZ1++, t_sin[s1_ind] );
acc = L_msu0( acc, *RZ2--, t_sin[s2_ind] );
*IY1-- = round_fx( acc );
+ move16();
c0_ind = sub( c0_ind, step );
s0_ind = add( s0_ind, step );
@@ -3223,6 +3276,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_msu0( acc, *IZ1, t_sin[s1_ind] );
acc = L_msu0( acc, *IZ2, t_sin[s2_ind] );
*RY1++ = round_fx( acc );
+ move16();
/* Construction of Y2 */
c0_ind = T_SIN_PI_2;
@@ -3246,6 +3300,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_mac0( acc, *IZ1--, t_sin[s1_ind] );
acc = L_mac0( acc, *IZ2++, t_sin[s2_ind] );
*RY2++ = round_fx( acc );
+ move16();
c0_ind = sub( c0_ind, step2 );
s0_ind = add( s0_ind, step2 );
@@ -3265,6 +3320,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_mac0( acc, *IZ1, t_sin[s1_ind] );
acc = L_mac0( acc, *IZ2, t_sin[s2_ind] );
*RY2++ = round_fx( acc );
+ move16();
acc = L_mult0( *IZ0--, t_sin[c0_ind] );
acc = L_msu0( acc, *IZ1--, t_sin[c1_ind] );
@@ -3273,6 +3329,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] );
acc = L_mac0( acc, *RZ2--, t_sin[s2_ind] );
*IY2-- = round_fx( acc );
+ move16();
c0_ind = sub( c0_ind, step2 );
s0_ind = add( s0_ind, step2 );
@@ -3293,6 +3350,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_mac0( acc, *IZ1, t_sin[s1_ind] );
acc = L_mac0( acc, *IZ2, t_sin[s2_ind] );
*RY2++ = round_fx( acc );
+ move16();
acc = L_mult0( *IZ0--, t_sin[c0_ind] );
acc = L_mac0( acc, *IZ1--, t_sin[c1_ind] );
@@ -3301,6 +3359,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] );
acc = L_mac0( acc, *RZ2--, t_sin[s2_ind] );
*IY2-- = round_fx( acc );
+ move16();
c0_ind = sub( c0_ind, step2 );
s0_ind = add( s0_ind, step2 );
@@ -3321,6 +3380,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_mac0( acc, *IZ1, t_sin[s1_ind] );
acc = L_msu0( acc, *IZ2, t_sin[s2_ind] );
*RY2++ = round_fx( acc );
+ move16();
acc = L_mult0( *IZ0--, t_sin[c0_ind] );
acc = L_mac0( acc, *IZ1--, t_sin[c1_ind] );
@@ -3329,6 +3389,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] );
acc = L_msu0( acc, *RZ2--, t_sin[s2_ind] );
*IY2-- = round_fx( acc );
+ move16();
c0_ind = sub( c0_ind, step2 );
s0_ind = add( s0_ind, step2 );
@@ -3349,6 +3410,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_mac0( acc, *IZ1, t_sin[s1_ind] );
acc = L_msu0( acc, *IZ2, t_sin[s2_ind] );
*RY2++ = round_fx( acc );
+ move16();
acc = L_mult0( *IZ1--, t_sin[c1_ind] );
acc = L_msu0( acc, *IZ0--, t_sin[c0_ind] );
@@ -3357,6 +3419,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] );
acc = L_msu0( acc, *RZ2--, t_sin[s2_ind] );
*IY2-- = round_fx( acc );
+ move16();
c0_ind = add( c0_ind, step2 );
s0_ind = sub( s0_ind, step2 );
@@ -3374,6 +3437,7 @@ void ifft3_fx( const Word16 Z[], Word16 X[], const Word16 n )
acc = L_mac0( acc, *IZ1, t_sin[s1_ind] );
acc = L_msu0( acc, *IZ2, t_sin[s2_ind] );
*RY2++ = round_fx( acc );
+ move16();
/* Compute the inverse FFT for all 3 blocks. */
RY0 = &Y[0]; /* Rewind the pointers. */
diff --git a/lib_com/fft_rel.c b/lib_com/fft_rel.c
index 0891367c612e3114a60dc949556c16815d38540d..4682fb65e5522f1f7bbed3284118dfea8c70d7aa 100644
--- a/lib_com/fft_rel.c
+++ b/lib_com/fft_rel.c
@@ -39,8 +39,7 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*---------------------------------------------------------------------*
* Local constants
@@ -317,6 +316,7 @@ void fft_rel_fx(
Word16 *xi2, *xi3, *xi4, *xi1;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -357,7 +357,7 @@ void fft_rel_fx(
move16();
x1 = &x[1];
move16();
- FOR( i = 0; i < n / 2; i++ )
+ FOR( i = 0; i < shr( n, 1 ); i++ )
{
xt = *x0;
move16();
@@ -400,7 +400,7 @@ void fft_rel_fx(
n2 = shl( n4, 1 );
n1 = shl( n2, 1 );
- step = N_MAX_SAS / n1;
+ step = idiv1616( N_MAX_SAS, n1 );
x0 = x;
x1 = x + n2;
@@ -679,6 +679,8 @@ void fft_rel_fx32(
Word32 *x2even, *x2odd;
Word32 temp[512];
+ test();
+ test();
IF( EQ_16( n, 128 ) || EQ_16( n, 256 ) || EQ_16( n, 512 ) )
{
idx = fft256_read_indexes;
@@ -690,10 +692,14 @@ void fft_rel_fx32(
FOR( i = 0; i < 64; i++ )
{
j = *idx++;
+ move16();
k = *idx++;
+ move16();
*x2++ = L_add( x[shr( j, 1 )], x[shr( k, 1 )] );
+ move16();
*x2++ = L_sub( x[shr( j, 1 )], x[shr( k, 1 )] );
+ move16();
}
}
ELSE IF( EQ_16( n, 256 ) )
@@ -702,10 +708,14 @@ void fft_rel_fx32(
FOR( i = 0; i < 128; i++ )
{
j = *idx++;
+ move16();
k = *idx++;
+ move16();
*x2++ = L_add( x[j], x[k] );
+ move16();
*x2++ = L_sub( x[j], x[k] );
+ move16();
}
}
ELSE IF( EQ_16( n, 512 ) )
@@ -721,11 +731,15 @@ void fft_rel_fx32(
idx++;
*x2even++ = L_add( x[j], x[k] );
+ move16();
*x2even++ = L_sub( x[j], x[k] );
- j++;
- k++;
+ move16();
+ j = add( j, 1 );
+ k = add( k, 1 );
*x2odd++ = L_add( x[j], x[k] );
+ move16();
*x2odd++ = L_sub( x[j], x[k] );
+ move16();
}
}
@@ -746,11 +760,15 @@ void fft_rel_fx32(
FOR( i = 0; i < n; i += 4 )
{
*x2++ = L_add( *x0++, *x1 ); /* x[i] = xt + x[i+n2]; */
+ move16();
*x2++ = *x0;
+ move16();
x0--;
*x2++ = L_sub( *x0, *x1 ); /* x[i+n2] = xt - x[i+n2]; */
+ move16();
x1++;
*x2++ = L_negate( *x1 ); /* x[i+n2+n4] = -x[i+n2+n4]; */
+ move16();
x0 += 4;
x1 += 3; /* x1 has already advanced */
@@ -764,23 +782,27 @@ void fft_rel_fx32(
*-----------------------------------------------------------------*/
j = 0;
+ move16();
x0 = &x[0];
- FOR( i = 0; i < n - 1; i++ )
+ FOR( i = 0; i < sub( n, 1 ); i++ )
{
IF( LT_16( i, j ) )
{
xt = x[j];
+ move32();
x[j] = *x0;
+ move32();
*x0 = xt;
+ move32();
}
x0++;
- k = n / 2;
+ k = shr( n, 1 );
WHILE( LE_16( k, j ) )
{
- j -= k;
+ j = sub( j, k );
k = shr( k, 1 );
}
- j += k;
+ j = add( j, k );
}
/*-----------------------------------------------------------------*
@@ -789,10 +811,12 @@ void fft_rel_fx32(
x0 = &x[0];
x1 = &x[1];
- FOR( i = 0; i < n / 2; i++ )
+ FOR( i = 0; i < shr( n, 1 ); i++ )
{
*x1 = L_sub( *x0, *x1 );
+ move32();
*x0 = L_sub( L_shl( *x0, 1 ), *x1 );
+ move32();
x0++;
x0++;
@@ -813,9 +837,12 @@ void fft_rel_fx32(
FOR( i = 0; i < n; i += 4 )
{
- *x1 = L_sub( *x0, *x1 ); /* x[i+n2] = xt - x[i+n2]; */
+ *x1 = L_sub( *x0, *x1 ); /* x[i+n2] = xt - x[i+n2]; */
+ move32();
*x0 = L_sub( L_shl( *x0, 1 ), *x1++ ); /* x[i] = xt + x[i+n2]; */
- *x1 = L_negate( *x1 ); /* x[i+n2+n4] = -x[i+n2+n4]; */
+ move32();
+ *x1 = L_negate( *x1 ); /* x[i+n2+n4] = -x[i+n2+n4]; */
+ move32();
x0 += 4;
x1 += 3; /* x1 has already advanced */
@@ -835,10 +862,14 @@ void fft_rel_fx32(
*-----------------------------------------------------------------*/
n4 = 1;
+ move16();
n2 = 2;
+ move16();
n1 = 4;
+ move16();
step = N_MAX_DIV4;
+ move16();
FOR( k = 3; k <= m; k++ )
{
@@ -853,9 +884,12 @@ void fft_rel_fx32(
FOR( i = 0; i < n; i += n1 )
{
- *x1 = L_sub( *x0, *x1 ); /* x[i+n2] = xt - x[i+n2]; */
+ *x1 = L_sub( *x0, *x1 ); /* x[i+n2] = xt - x[i+n2]; */
+ move32();
*x0 = L_sub( L_shl( *x0, 1 ), *x1 ); /* x[i] = xt + x[i+n2]; */
- *x2 = L_negate( *x2 ); /* x[i+n2+n4] = -x[i+n2+n4]; */
+ move32();
+ *x2 = L_negate( *x2 ); /* x[i+n2+n4] = -x[i+n2+n4]; */
+ move32();
s = sincos_t_ext_fx;
c = s + N_MAX_FFT / 4; /* 1024/4 = 256, 256/4=64 */
@@ -878,9 +912,13 @@ void fft_rel_fx32(
t2 = L_sub( Mpy_32_16_1( *xi3, *s ), Mpy_32_16_1( *xi4, *c ) ); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); */
*xi4 = L_sub( *xi2, t2 );
+ move32();
*xi2 = L_sub( *xi1, t1 );
+ move32();
*xi1 = L_sub( L_shl( *xi1, 1 ), *xi2 );
+ move32();
*xi3 = L_negate( L_add( L_shl( t2, 1 ), *xi4 ) );
+ move32();
}
x1 += n1;
diff --git a/lib_com/fft_rel_fx.c b/lib_com/fft_rel_fx.c
index 405c500b5906579f5526f6fe2cbd0942010cabf1..b07cb3acbe15034a5f13a05cf1d6a35a8892c708 100644
--- a/lib_com/fft_rel_fx.c
+++ b/lib_com/fft_rel_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
#include "stl.h"
#include "stdint.h"
@@ -85,6 +84,7 @@ static void c_fft_fx(
const Word16 *table_ptr;
const Word16 *input_ptr1, *input_ptr2, *input_ptr3, *input_ptr4;
Word16 shift = 0;
+ move16();
/* Setup Reorder Variables */
table_ptr = NULL;
table_ptr = FFT_REORDER_1024;
@@ -92,18 +92,23 @@ static void c_fft_fx(
{
case 1024:
shift = 0;
+ move16();
BREAK;
case 512:
shift = 1;
+ move16();
BREAK;
case 256:
shift = 2;
+ move16();
BREAK;
case 128:
shift = 3;
+ move16();
BREAK;
case 64:
shift = 4;
+ move16();
BREAK;
}
/* The FFT part */
diff --git a/lib_com/fill_spectrum.c b/lib_com/fill_spectrum.c
index 187ee475dd839985875891788093db43aa86c8a0..b75a670178eb0e4d3a550d826b3bd856cd5ffbef 100644
--- a/lib_com/fill_spectrum.c
+++ b/lib_com/fill_spectrum.c
@@ -40,8 +40,7 @@
#include "rom_com.h"
#include "prot.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
@@ -352,13 +351,15 @@ void ivas_fill_spectrum_fx(
IF( EQ_16( HQ_mode, HQ_HARMONIC ) )
{
/*high_sfm = (core_brate == HQ_BWE_CROSSOVER_BRATE) ? HVQ_THRES_SFM_24k-1 : HVQ_THRES_SFM_32k-3; */
- high_sfm = sub( HVQ_THRES_SFM_32k, 1 );
- IF( LT_32( L_core_brate, HQ_BWE_CROSSOVER_BRATE ) )
+ high_sfm = HVQ_THRES_SFM_32k - 1;
+ move16();
+ if ( LT_32( L_core_brate, HQ_BWE_CROSSOVER_BRATE ) )
{
- high_sfm = sub( HVQ_THRES_SFM_24k, 1 );
+ high_sfm = HVQ_THRES_SFM_24k - 1;
+ move16();
}
- IF( LT_16( last_sfm, high_sfm ) )
+ if ( LT_16( last_sfm, high_sfm ) )
{
last_sfm = high_sfm;
move16();
@@ -381,7 +382,7 @@ void ivas_fill_spectrum_fx(
test();
test();
IF( EQ_16( length, L_FRAME16k ) ||
- ( ( EQ_16( length, L_FRAME32k ) && NE_16( HQ_mode, HQ_HARMONIC ) && NE_16( HQ_mode, HQ_HVQ ) ) && EQ_16( *no_att_hangover, 0 ) ) )
+ ( ( EQ_16( length, L_FRAME32k ) && NE_16( HQ_mode, HQ_HARMONIC ) && NE_16( HQ_mode, HQ_HVQ ) ) && ( *no_att_hangover == 0 ) ) )
{
/* Norm adjustment function */
env_adj_fx( npulses, length, last_sfm, norm_adj, env_stab, sfmsize );
@@ -393,7 +394,7 @@ void ivas_fill_spectrum_fx(
test();
test();
test();
- IF( EQ_16( length, L_FRAME32k ) && ( ( LT_16( env_stab, 16384 ) && *no_att_hangover == 0 ) || EQ_16( HQ_mode, HQ_HVQ ) ) )
+ if ( EQ_16( length, L_FRAME32k ) && ( ( LT_16( env_stab, 16384 ) && *no_att_hangover == 0 ) || EQ_16( HQ_mode, HQ_HVQ ) ) )
{
flag_32K_env_hangover = 1;
move16();
@@ -426,7 +427,7 @@ void ivas_fill_spectrum_fx(
*----------------------------------------------------------------*/
test();
- IF( NE_16( HQ_mode, HQ_HVQ ) && GT_16( cb_size, 0 ) )
+ IF( NE_16( HQ_mode, HQ_HVQ ) && ( cb_size > 0 ) )
{
apply_noisefill_HQ_fx( R, length, flag_32K_env_hangover, L_core_brate, last_sfm, CodeBook,
CodeBook_mod, cb_size, sfm_start, sfm_end, sfmsize, coeff );
@@ -436,7 +437,7 @@ void ivas_fill_spectrum_fx(
* Normal mode BWE
*----------------------------------------------------------------*/
- IF( EQ_16( HQ_mode, HQ_NORMAL ) )
+ IF( HQ_mode == HQ_NORMAL )
{
hq_fold_bwe_fx( last_sfm, sfm_end, num_sfm, coeff );
}
@@ -524,6 +525,7 @@ void ivas_fill_spectrum_fx(
IF( EQ_16( length, L_FRAME32k ) && LE_32( L_core_brate, HQ_32k ) )
{
*prev_R = R[SFM_N_WB - 1];
+ move16();
Copy32( L_coeff_out + L_FRAME16k - L_HQ_WB_BWE, prev_coeff_out, L_HQ_WB_BWE );
}
@@ -784,6 +786,7 @@ void fill_spectrum_fx(
IF( EQ_16( length, L_FRAME32k ) && LE_32( L_core_brate, HQ_32k ) )
{
*prev_R = R[SFM_N_WB - 1];
+ move16();
Copy32( L_coeff_out + L_FRAME16k - L_HQ_WB_BWE, prev_coeff_out, L_HQ_WB_BWE );
}
diff --git a/lib_com/findpulse.c b/lib_com/findpulse.c
index be75d3c838bdd5e52095ce7338b3178d2a3a28de..e7104810c704a825563f95c3115307041f222f5a 100644
--- a/lib_com/findpulse.c
+++ b/lib_com/findpulse.c
@@ -40,8 +40,7 @@
#include "prot.h"
#include "cnst.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*----------------------------------------------------------------------------------*
* findpulse()
@@ -185,7 +184,6 @@ Word16 findpulse_fx( /* o : pulse position
*------------------------------------------------------------------------*/
ptr = resf + L_frame - 1;
- move16();
maxi = 0;
move16();
diff --git a/lib_com/fine_gain_bits_fx.c b/lib_com/fine_gain_bits_fx.c
index 1ffc695350454076b0d03a3fc118f2f22421aa64..627eda6e0a29878d2a104cd2c356d7a560093fc2 100644
--- a/lib_com/fine_gain_bits_fx.c
+++ b/lib_com/fine_gain_bits_fx.c
@@ -3,10 +3,9 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
@@ -87,7 +86,6 @@ Word16 assign_gain_bits_fx( /* o : Number of assigned
}
/* Re-adjust bit budget for gain quantization */
- move16();
gain_bits_tot = 0;
move16();
*Rcalc = 0;
@@ -125,7 +123,7 @@ static void ivas_subband_gain_bits_fx(
{
/*bps = (short)(Rk[i]*((word16)min(32767, ceil(32767.0f/sfmsize[i]); inexact C-integer division approx. */
bps = extract_l( L_shr( L_mult0( Rk[i], fg_inv_tbl_fx[sfmsize[i] >> 3] ), 18 ) ); /* 3+15 */
- IF( EQ_32( L_shl( L_mult0( sfmsize[i], add( bps, 1 ) ), 3 ), Rk[i] ) )
+ if ( EQ_32( L_shl( L_mult0( sfmsize[i], add( bps, 1 ) ), 3 ), Rk[i] ) )
{
bps = add( bps, 1 );
}
@@ -138,7 +136,7 @@ static void ivas_subband_gain_bits_fx(
tot = add( tot, b );
}
- IF( EQ_16( tot, 0 ) )
+ if ( tot == 0 )
{
/* If no gain bits were assigned, use one bit anyway for potential PVQ overage */
bits[0] = 1;
@@ -177,7 +175,7 @@ Word16 ivas_assign_gain_bits_fx( /* o : Number of ass
move16();
FOR( i = 0; i < BANDS; i++ )
{
- IF( GT_16( Rk[i], 0 ) )
+ IF( Rk[i] > 0 )
{
Rk[i] = sub( Rk[i], shl( gain_bits_array[i], 3 ) );
move16();
diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c
index 7cf76a7cf329e7d33bb8cd300f9ee2061a12ec4c..5ba9b55a632b61ab8ca8638af242a9a6cadfe769 100644
--- a/lib_com/float_to_fix_ops.c
+++ b/lib_com/float_to_fix_ops.c
@@ -4,25 +4,24 @@
#include
#include "options.h"
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
+
Word32 floatToFixed( float f, Word16 Q )
{
+ Word64 result_32;
if ( f == 1.0f && Q == Q15 )
return MAX16B;
if ( f == 1.0f && Q == Q31 )
return MAXVAL_WORD32;
if ( Q < 0 )
- return (Word32) ( (float) ( f ) / (double) ( 1llu << ( -Q ) ) + ( f >= 0 ? 0.5 : -0.5 ) );
+ result_32 = (Word64) ( (float) ( f ) / (double) ( 1llu << ( -Q ) ) + ( f >= 0 ? 0.5 : -0.5 ) );
else
- {
- Word64 result_32;
result_32 = (Word64) ( f * (double) ( 1llu << Q ) + ( f >= 0 ? 0.5 : -0.5 ) );
- if ( result_32 > MAX_32 )
- return MAX_32;
- if ( result_32 < MIN_32 )
- return MIN_32;
- return (Word32) result_32;
- }
+ if ( result_32 > MAX_32 )
+ return MAX_32;
+ if ( result_32 < MIN_32 )
+ return MIN_32;
+ return (Word32) result_32;
}
float fixedToFloat( Word32 i, Word16 Q )
diff --git a/lib_com/frame_ener.c b/lib_com/frame_ener.c
index 46fcddfb3f15501b967a8f7499f559bcd327f5aa..5af9eed54817734d963c4fbfe5bcad03f66bedfc 100644
--- a/lib_com/frame_ener.c
+++ b/lib_com/frame_ener.c
@@ -40,8 +40,7 @@
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*----------------------------------------------------------------------------------*
* fer_energy()
*
@@ -107,11 +106,12 @@ void fer_energy_fx(
IF( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, ONSET ) || EQ_16( clas, SIN_ONSET ) ) /* Voiced or Onset current frame */
{
len = ( pitch ); /* pitch value */
+ move16();
pt_synth = synth;
- IF( NE_16( offset, 0 ) )
+ IF( offset != 0 )
{
- pt_synth = synth + L_frame - len;
+ pt_synth = synth + sub( L_frame, len );
}
emaximum_32fx( q_synth, pt_synth, len, enr ); /* pitch synchronous E */
@@ -119,22 +119,25 @@ void fer_energy_fx(
ELSE
{
pt_synth = synth;
- IF( NE_16( offset, 0 ) )
+ IF( offset != 0 )
{
pt_synth = synth + shr( L_frame, 1 );
}
W_tmp = 0;
- for ( int i = 0; i < shr( L_frame, 1 ); i++ )
+ move64();
+ FOR( int i = 0; i < L_frame / 2; i++ )
{
W_tmp = W_add( W_tmp, W_mult0_32_32( pt_synth[i], pt_synth[i] ) ); // Q = q_synth * 2
}
shift = W_norm( W_tmp );
W_tmp = W_shl( W_tmp, shift ); // Q = q_synth * 2 + shift
*enr = W_extract_h( W_tmp ); // Q = q_synth * 2 + shift - 32
+ move32();
enr_tmp = BASOP_Util_Divide3216_Scale( *enr, shr( L_frame, 1 ) /*Q0*/, &exp );
- *enr = L_shr( L_deposit_l( enr_tmp ), ( shift - 32 - exp - 1 ) );
+ *enr = L_shr( L_deposit_l( enr_tmp ), sub( sub( sub( shift, 32 ), exp ), 1 ) );
+ move32();
}
return;
}
@@ -291,8 +294,10 @@ Word16 frame_ener_fx(
IF( EQ_16( L_frame, 320 ) )
{
*enr_q = Mult_32_16( *enr_q, 26214 ); /*x 0.8 to get /160*/
+ move32();
i = norm_l( *enr_q );
*enr_q = L_shl( *enr_q, i );
+ move32();
exp_enrq = add( i, exp_enrq );
}
}
@@ -301,6 +306,7 @@ Word16 frame_ener_fx(
exp_enrq = sub( exp_enrq, add( Q_new, Q_new ) );
enr_q_tmp /*Q30 exp2+exp_enrq*/ = BASOP_Util_Divide3216_Scale( *enr_q /*Q31*/, L_frame2 /*Q0*/, &exp2 );
*enr_q = L_shr( L_deposit_l( enr_q_tmp ), sub( 30, add( exp2, exp_enrq ) ) ); /*Q0*/
+ move32();
*enr_q = L_add( *enr_q, 1 );
move32();
exp_enrq = 0;
@@ -331,6 +337,7 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8
Word16 len, enern;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
diff --git a/lib_com/gain_inov_fx.c b/lib_com/gain_inov_fx.c
index 7f767c0280cec81306d84c54e7b143c867a5396e..e2f65421a479a918a98a3a884910e849f324fbe0 100644
--- a/lib_com/gain_inov_fx.c
+++ b/lib_com/gain_inov_fx.c
@@ -5,8 +5,7 @@
#include
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "rom_com.h"
diff --git a/lib_com/get_gain.c b/lib_com/get_gain.c
index e6288ad015196dde23606256b8d0bb4c91fc02b7..5f9c8f56a0f67b4355d6af240da3134733a56b38 100644
--- a/lib_com/get_gain.c
+++ b/lib_com/get_gain.c
@@ -38,8 +38,7 @@
#include "options.h"
#include "prot.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*----------------------------------------------------------------------------------*
* get_gain()
@@ -87,6 +86,7 @@ Word32 get_gain( /* output: codebook gain (adaptive or fixed)
Word16 exp_c, exp_e, exp, tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -122,6 +122,7 @@ Word32 get_gain2( /* output: codebook gain (adaptive or fixed)
Word16 m_corr, m_ener, negative, Q_corr, Q_ener;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
negative = 0;
diff --git a/lib_com/gs_bitallocation.c b/lib_com/gs_bitallocation.c
index 6d24ab7bb39fa5a77e7288aea37c1c94a069469c..3898daf95cbc7f98a1b03ebd47ac57050ba1832d 100644
--- a/lib_com/gs_bitallocation.c
+++ b/lib_com/gs_bitallocation.c
@@ -43,6 +43,7 @@
#include "ivas_prot.h"
#include "wmc_auto.h"
+
/*-------------------------------------------------------------------*
* Local function prototypes
*-------------------------------------------------------------------*/
@@ -51,6 +52,29 @@ 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 );
+#ifdef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING
+#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 );
+#endif
/*-------------------------------------------------------------------*
* bands_and_bit_alloc()
@@ -89,8 +113,12 @@ void bands_and_bit_alloc(
int16_t pos, band;
float SWB_bit_budget;
float bits_per_bands[MBANDS_GN_BITALLOC16k];
+#ifndef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING
float fzero_val, mp, mb, nb_bands_adj, bit_adj;
int16_t nb_pulse_per_band[MBANDS_GN_BITALLOC16k];
+#else
+ float fzero_val;
+#endif
/* initializations */
nb_tot_bands = 16;
@@ -190,6 +218,7 @@ void bands_and_bit_alloc(
{
if ( GSC_IVAS_mode > 0 )
{
+#ifndef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING
SWB_bit_budget = *bit;
st_band = 5;
@@ -368,6 +397,10 @@ void bands_and_bit_alloc(
bits_per_bands[i] += sum_bit;
}
}
+#else
+ 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;
+#endif
}
else if ( GSC_noisy_speech )
{
@@ -927,3 +960,304 @@ static float Find_bit_frac(
return ( var_out );
}
+
+#ifdef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING
+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;
+ Word16 tmp;
+
+ ind = 0;
+ tmp = vec_fx[0];
+
+ for ( j = 1; j < lvec_fx; j++ )
+ {
+ if ( vec_fx[j] > tmp )
+ {
+ ind = j;
+ }
+ tmp = s_max( tmp, vec_fx[j] );
+ }
+ *max_fx = tmp;
+
+ return ind;
+}
+#endif
diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c
index b3da54d2a8e66bc9cfc828fb9135d244dece5a0e..943291cec8a416278ca5dc4f6b0449bc29e3f95a 100644
--- a/lib_com/gs_bitallocation_fx.c
+++ b/lib_com/gs_bitallocation_fx.c
@@ -2,12 +2,11 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "assert.h" /* Debug prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "assert.h" /* Debug prototypes */
#include "stl.h"
/*==================================================================================*/
@@ -579,7 +578,7 @@ void bands_and_bit_alloc_fx(
#endif
test();
- if ( EQ_16( bwidth, NB ) && GT_16( nb_bands_max, 10 ) )
+ if ( ( bwidth == NB ) && GT_16( nb_bands_max, 10 ) )
{
nb_bands_max = 10;
move16();
@@ -588,8 +587,10 @@ void bands_and_bit_alloc_fx(
/*------------------------------------------------------------------------
* Find extra number of band to code according to bit rate availables
*-----------------------------------------------------------------------*/
+ test();
WHILE( GE_16( bit_tmp, bit_new_bands ) && LE_16( nb_bands, sub( nb_bands_max, 1 ) ) )
{
+ test();
bit_tmp = sub( bit_tmp, bit_new_bands );
nb_bands = add( nb_bands, 1 );
}
diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c
index 48990d122ce28448252959f56161e70dc9a6b119..6bc6eac23711a45293ac7b4aae01f8add9ee8bf1 100644
--- a/lib_com/gs_bitallocation_ivas_fx.c
+++ b/lib_com/gs_bitallocation_ivas_fx.c
@@ -6,14 +6,44 @@
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
#include "prot.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "ivas_prot.h" /* Function prototypes */
#include "assert.h" /* Debug prototypes */
#include "stl.h"
static void reajust_bits_fx( Word32 *bits_per_bands, const Word16 st_band, const Word16 end_band, const Word16 sum_bit_in, const Word16 bit_bdgt_in );
+#ifdef FIX_802_1137_1137_GSC_IVAS_FXFLT_DECODING
+/*-------------------------------------------------------------------*
+ * Local constants
+ *-------------------------------------------------------------------*/
+#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 */
+/*-----------------------------------------------------------------*
+ * Local functions
+ *-----------------------------------------------------------------*/
+static Word16 Find_norm_inv( const Word32 ToDivide, Word16 *e_div );
+static Word16 Find_bit_alloc_IVAS( const Word32 core_brate, const Word16 GSC_IVAS_mode, const Word16 Diff_len, const Word16 nb_tot_bands, Word16 *bit, Word16 *max_ener_band, Word16 *ener_vec, Word32 *bits_per_bands );
+#endif
+#ifdef FIX_802__NON_BE_DECODING
+static Word32 Find_bit_frac( const Word16 nb_band, const Word16 remaining_bits );
+#endif
/*==================================================================================*/
/* FUNCTION : void bands_and_bit_alloc_ivas_fx(); */
/*----------------------------------------------------------------------------------*/
@@ -81,18 +111,16 @@ void bands_and_bit_alloc_ivas_fx(
Word32 bits_per_bands[MBANDS_GN_BITALLOC16k]; // Q18
Word16 w_sum_bit;
Word16 fzero_val;
+#ifndef FIX_802_1137_1137_GSC_IVAS_FXFLT_DECODING
Word32 mp, mb, nb_bands_adj, bit_adj;
Word16 nb_pulse_per_band[MBANDS_GN_BITALLOC16k];
-#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
- (void) GSC_IVAS_mode;
- (void) element_mode;
#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
#endif
nb_tot_bands = MBANDS_GN;
move16();
- IF( EQ_16( L_frame, L_FRAME16k ) )
+ if ( EQ_16( L_frame, L_FRAME16k ) )
{
nb_tot_bands = MBANDS_GN_BITALLOC16k;
move16();
@@ -108,6 +136,7 @@ void bands_and_bit_alloc_ivas_fx(
#else /* BASOP_NOGLOB */
ener_vec[0] = add( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1] ); /*Q12 */
#endif
+ move16();
Copy( Ener_per_bd_iQ_tmp + 1, ener_vec, MBANDS_GN - 1 ); /*Q12 */
ener_vec[MBANDS_GN - 1] = ener_vec[MBANDS_GN - 2];
move16();
@@ -133,7 +162,8 @@ void bands_and_bit_alloc_ivas_fx(
bit_new_bands = 5;
move16();
#if 1 // def ADD_LRTD
- IF( GT_32( core_brate, ACELP_16k40 ) && EQ_16( L_frame, L_FRAME16k ) )
+ test();
+ if ( GT_32( core_brate, ACELP_16k40 ) && EQ_16( L_frame, L_FRAME16k ) )
{
bit_new_bands = 7;
move16();
@@ -156,8 +186,11 @@ void bands_and_bit_alloc_ivas_fx(
i = add( i, 1 );
}
- IF( GT_16( element_mode, EVS_MONO ) && EQ_16( coder_type, AUDIO ) &&
- LE_32( core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */
+ test();
+ test();
+ test();
+ if ( ( element_mode > EVS_MONO ) && EQ_16( coder_type, AUDIO ) &&
+ LE_32( core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */
{
i = sub( i, 1 );
}
@@ -171,7 +204,7 @@ void bands_and_bit_alloc_ivas_fx(
test();
test();
- IF( ( EQ_16( coder_type, AUDIO ) || EQ_16( coder_type, INACTIVE ) ) && EQ_16( bwidth, NB ) )
+ IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && ( bwidth == NB ) )
{
IF( GE_32( core_brate, ACELP_9k60 ) )
{
@@ -202,22 +235,28 @@ void bands_and_bit_alloc_ivas_fx(
}
#if 1 // def ADD_LRTD
- IF( L_frame == L_FRAME16k )
+ IF( EQ_16( L_frame, L_FRAME16k ) )
{
- *bit -= 8;
+ *bit = sub( *bit, 8 );
+ move16();
}
- IF( coder_type == INACTIVE && core_brate <= GSC_LRES_GAINQ_LIMIT ) /* can happen only for 2nd channel inactive */
+ test();
+ IF( coder_type == INACTIVE && LE_32( core_brate, GSC_LRES_GAINQ_LIMIT ) ) /* can happen only for 2nd channel inactive */
{
- *bit += GSC_LRES_NB_NITS;
+ *bit = add( *bit, GSC_LRES_NB_NITS );
+ move16();
}
IF( *bit > 0 )
{
IF( GSC_IVAS_mode > 0 )
{
+#ifndef FIX_802_1137_1137_GSC_IVAS_FXFLT_DECODING
SWB_bit_budget = *bit; // Q0
+ move16();
st_band = 5;
+ move16();
set_l( bits_per_bands, 0, MBANDS_GN_BITALLOC16k );
@@ -232,45 +271,48 @@ void bands_and_bit_alloc_ivas_fx(
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 )
+ if ( LE_16( GSC_IVAS_mode, 3 ) )
{
- nb_bands_max -= 6;
+ nb_bands_max = sub( nb_bands_max, 6 );
}
- IF( GSC_IVAS_mode == 2 )
+ IF( EQ_16( GSC_IVAS_mode, 2 ) )
{
// bit_fracf += 0.1f;
bit_fracf = L_add( bit_fracf, 26214 ); // Q18
- nb_bands_max--;
+ nb_bands_max = sub( nb_bands_max, 1 );
}
- IF( GSC_IVAS_mode == 3 )
+ IF( EQ_16( GSC_IVAS_mode, 3 ) )
{
// bit_fracf -= 0.1f;
bit_fracf = L_sub( bit_fracf, 26214 ); // Q18
- nb_bands_max += 3;
+ nb_bands_max = add( 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 = ONE_IN_Q18;
- IF( GSC_IVAS_mode == 1 && core_brate < GSC_L_RATE_STG )
+ move32();
+ test();
+ test();
+ IF( EQ_16( GSC_IVAS_mode, 1 ) && LT_32( core_brate, GSC_L_RATE_STG ) )
{
// nb_bands_adj = 0.0125f * SWB_bit_budget - 0.75f;
nb_bands_adj = L_sub( Mpy_32_32( 26843546, L_shl( SWB_bit_budget, Q18 ) ), 196608 ); // Q18
}
- ELSE IF( GSC_IVAS_mode != 2 && core_brate > GSC_H_RATE_STG )
+ ELSE IF( NE_16( GSC_IVAS_mode, 2 ) && GT_32( core_brate, GSC_H_RATE_STG ) )
{
// nb_bands_adj = 0.02f * SWB_bit_budget - 1.2f;
nb_bands_adj = L_sub( Mpy_32_32( 42949673, L_shl( SWB_bit_budget, Q18 ) ), 314572 ); // Q18
}
// nb_bands_max = (int16_t)(nb_bands_max * nb_bands_adj + 0.5f);
- nb_bands_max = (Word16) L_shr_r( nb_bands_max * nb_bands_adj, Q18 ); // Q0
+ nb_bands_max = extract_l( L_shr_r( nb_bands_max * nb_bands_adj, Q18 ) ); // Q0
nb_bands_max = check_bounds_s( nb_bands_max, 5, nb_tot_bands );
// bit_fracf *= SWB_bit_budget;
- bit_fracf = bit_fracf * SWB_bit_budget; // Q18
+ bit_fracf = imult3216( bit_fracf, extract_l( SWB_bit_budget ) ); // Q18
/* Estimation of the number of bit used in HF */
/* with only the first weigthing The number of bits in max_ener_band[st_band-1] = 17% of bit_fracf */
@@ -278,43 +320,52 @@ void bands_and_bit_alloc_ivas_fx(
mb = Mpy_32_32( 365072220, bit_fracf ); // Q18
// mp = 2 * DSR_NB_PULSE);
mp = 2359296; // Q18
- IF( core_brate < GSC_L_RATE_STG && GSC_IVAS_mode == 3 )
+ move32();
+ test();
+ IF( LT_32( core_brate, GSC_L_RATE_STG ) && EQ_16( GSC_IVAS_mode, 3 ) )
{
// mp = 1.5f * DSR_NB_PULSE;
mp = 1769472; // Q18
+ move32();
}
- ELSE IF( core_brate < GSC_L_RATE_STG )
+ ELSE IF( LT_32( core_brate, GSC_L_RATE_STG ) )
{
// mp = DSR_NB_PULSE;
mp = DSR_NB_PULSE_Q18;
+ move32();
}
/* 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));
- nb_tot_bands = (Word16) ( L_sub( L_shl( SWB_bit_budget, Q18 ), bit_fracf ) / L_add( mp, L_shr( L_sub( mb, mp ), 1 ) ) );
- mp = min( mp, mb );
- IF( nb_tot_bands + st_band > nb_bands_max )
+ nb_tot_bands = extract_l( L_sub( L_shl( SWB_bit_budget, Q18 ), bit_fracf ) / L_add( mp, L_shr( L_sub( mb, mp ), 1 ) ) );
+ mp = L_min( mp, mb );
+ IF( GT_16( add( nb_tot_bands, st_band ), nb_bands_max ) )
{
- bit_adj = ( ( mb + mp ) / 2 ) * ( nb_tot_bands + st_band - nb_bands_max );
- bit_adj = max( 0, bit_adj );
- nb_tot_bands = nb_bands_max - st_band;
+ bit_adj = imult3216( L_shr( L_add( mb, mp ), 1 ), sub( add( nb_tot_bands, st_band ), nb_bands_max ) );
+ bit_adj = L_max( 0, bit_adj );
+ nb_tot_bands = sub( nb_bands_max, st_band );
// bit_fracf += bit_adj;
bit_fracf = L_add( bit_fracf, bit_adj ); // Q18
}
- nb_tot_bands += st_band;
+ nb_tot_bands = add( nb_tot_bands, st_band );
/* Allocate bits to LF */
// etmp = 0.23f;
Word32 etmp_32fx = 493921239; // Q15
+ move32();
FOR( j = 0; j < st_band; j++ )
{
i = j;
+ move16();
max_ener_band[j] = i;
+ move16();
ener_vec[i] = MIN16B;
+ move16();
// bits_per_bands[j] = etmp * bit_fracf;
bits_per_bands[j] = Mpy_32_32( bit_fracf, etmp_32fx ); // 33 - 15 = Q18
+ move32();
// etmp -= 0.015f;
etmp_32fx = L_sub( etmp_32fx, 32212255 );
}
@@ -326,44 +377,51 @@ void bands_and_bit_alloc_ivas_fx(
set_s( nb_pulse_per_band, 2, MBANDS_GN_BITALLOC16k );
FOR( i = st_band + 2; i < nb_tot_bands - 1; i++ )
{
- IF( ener_vec[i] < ener_vec[i - 1] && ener_vec[i] < ener_vec[i + 1] )
+ test();
+ if ( LT_16( ener_vec[i], ener_vec[i - 1] ) && LT_16( ener_vec[i], ener_vec[i + 1] ) )
{
nb_pulse_per_band[i] = 1;
+ move16();
}
}
FOR( j = st_band; j < nb_tot_bands; j++ )
{
- IF( j > 6 )
+ IF( GT_16( j, 6 ) )
{
i = maximum_fx( ener_vec, nb_tot_bands, &etmp );
}
ELSE
{
i = j;
+ move16();
}
max_ener_band[j] = i;
+ move16();
ener_vec[i] = MIN16B;
+ move16();
}
/* Recompute the final bit distribution for HF */
- IF( nb_tot_bands > st_band )
+ IF( GT_16( nb_tot_bands, st_band ) )
{
// bit_fracf = DSR_NB_PULSE;
- mb = ( SWB_bit_budget * 2 / ( nb_tot_bands - st_band ) ) - mp; // Q18
- bit_fracf = ( mb - mp ) / ( nb_tot_bands - st_band );
+ mb = ( L_shl( SWB_bit_budget, 1 ) / sub( nb_tot_bands, st_band ) ) - mp; // Q18
+ bit_fracf = L_sub( mb, mp ) / sub( nb_tot_bands, st_band );
mb = L_sub( mb, bit_fracf );
/* Do the distribution */
FOR( j = st_band; j < nb_tot_bands; j++ )
{
- IF( nb_pulse_per_band[max_ener_band[j]] > 1 )
+ IF( GT_16( nb_pulse_per_band[max_ener_band[j]], 1 ) )
{
bits_per_bands[max_ener_band[j]] = mb;
+ move32();
}
ELSE
{
// bits_per_bands[max_ener_band[j]] = 4.5f;
bits_per_bands[max_ener_band[j]] = 1179648;
+ move32();
}
mb = L_sub( mb, bit_fracf );
SWB_bit_budget = L_sub( SWB_bit_budget, bits_per_bands[max_ener_band[j]] ); // Q18
@@ -373,61 +431,69 @@ void bands_and_bit_alloc_ivas_fx(
/* Series of verification in case bit allocated != the budget */
IF( SWB_bit_budget > 0 )
{
- i = st_band - 1;
+ i = sub( st_band, 1 );
WHILE( SWB_bit_budget > 0 )
{
// bits_per_bands[i]++;
bits_per_bands[i] = L_add( bits_per_bands[i], 262144 );
// SWB_bit_budget--;
SWB_bit_budget = L_sub( SWB_bit_budget, 262144 );
- i--;
- IF( i == -1 )
+ i = sub( i, 1 );
+ IF( EQ_16( i, -1 ) )
{
- i = st_band - 1;
+ i = sub( st_band, 1 );
}
}
}
nb_bands = nb_tot_bands;
+ move16();
sum_bit = 0;
+ move32();
j = 0;
+ move16();
FOR( i = 0; i < nb_bands; i++ )
{
// if (bits_per_bands[i] > 112)
- IF( bits_per_bands[i] > 29360128 )
+ IF( GT_32( bits_per_bands[i], 29360128 ) )
{
- sum_bit += bits_per_bands[i] - 112;
+ sum_bit = L_add( sum_bit, L_sub( bits_per_bands[i], 112 ) );
sum_bit = L_add( sum_bit, L_sub( bits_per_bands[i], 29360128 ) );
// bits_per_bands[i] = 112;
bits_per_bands[i] = 29360128;
- j = i + 1;
+ move32();
+ j = add( i, 1 );
}
/* safety check for overage bit reallocation */
// else if (bits_per_bands[i] + sum_bit / 3 > 112)
- ELSE IF( bits_per_bands[i] + sum_bit / 3 > 29360128 )
+ ELSE IF( GT_32( L_add( bits_per_bands[i], divide3216( L_shl( sum_bit, 1 ), 3 ) ), 29360128 ) )
{
- j = i + 1;
+ j = add( i, 1 );
}
}
IF( sum_bit != 0 )
{
// sum_bit /= (nb_bands - j);
- sum_bit = sum_bit / ( nb_bands - j );
+ sum_bit = divide3216( L_shl( sum_bit, 1 ), sub( nb_bands, j ) );
FOR( i = j; i < nb_bands; i++ )
{
- bits_per_bands[i] += sum_bit;
+ bits_per_bands[i] = L_add( bits_per_bands[i], sum_bit );
}
}
+#else
+ nb_tot_bands = Find_bit_alloc_IVAS( core_brate, GSC_IVAS_mode, Diff_len, nb_tot_bands, bit, max_ener_band, ener_vec, bits_per_bands );
+ nb_bands = nb_tot_bands;
+#endif
}
ELSE
#endif
IF( EQ_16( GSC_noisy_speech, 1 ) )
{
SWB_bit_budget = *bit;
- move16();
+ move32();
nb_bands = 5;
move16();
@@ -435,22 +501,30 @@ void bands_and_bit_alloc_ivas_fx(
// fzero_val = 0.0f;
fzero_val = 0;
- IF( element_mode > EVS_MONO )
+ move16();
+
+ if ( element_mode > EVS_MONO )
{
fzero_val = MIN16B;
+ move16();
}
- IF( coder_type == UNVOICED && element_mode > EVS_MONO )
+ test();
+ IF( EQ_16( coder_type, UNVOICED ) && element_mode > EVS_MONO )
{
nb_bands = 3;
- IF( SWB_bit_budget > 20 )
+ move16();
+
+ if ( GT_32( SWB_bit_budget, 20 ) )
{
nb_bands = 5;
+ move16();
}
}
- ELSE IF( bwidth < SWB )
+ ELSE IF( LT_16( bwidth, SWB ) )
{
nb_bands = 7;
+ move16();
}
#endif
@@ -460,8 +534,11 @@ void bands_and_bit_alloc_ivas_fx(
set32_fx( bits_per_bands, 0, MBANDS_GN );
/*bit_fracf = (1.0f/nb_bands)*(SWB_bit_budget); */
- bit_fracf = L_mult( div_s( 1, nb_bands ), shl( (Word16) SWB_bit_budget, 2 ) ); /* Q18 */
-
+#ifdef FIX_802__NON_BE_DECODING
+ bit_fracf = Find_bit_frac( nb_bands, extract_l( SWB_bit_budget ) );
+#else
+ bit_fracf = L_mult( div_s( 1, nb_bands ), shl( (Word16) SWB_bit_budget, 2 ) ); /* Q18 */
+#endif
nb_tot_bands = sub( nb_bands_max, 6 );
nb_tot_bands = s_min( nb_tot_bands, 16 );
@@ -476,11 +553,13 @@ void bands_and_bit_alloc_ivas_fx(
move16();
}
#if 1 // def ADD_LRTD
- IF( bwidth < SWB )
+ IF( LT_16( bwidth, SWB ) )
{
- IF( coder_type == UNVOICED && element_mode > EVS_MONO )
+ test();
+ if ( EQ_16( coder_type, UNVOICED ) && element_mode > EVS_MONO )
{
nb_tot_bands = 5;
+ move16();
}
#endif
FOR( ; j < nb_bands; j++ )
@@ -500,7 +579,9 @@ void bands_and_bit_alloc_ivas_fx(
{
i = maximum_fx( ener_vec, nb_tot_bands, &etmp );
max_ener_band[j] = i;
+ move16();
ener_vec[i] = fzero_val;
+ move16();
}
}
#endif
@@ -508,24 +589,28 @@ void bands_and_bit_alloc_ivas_fx(
}
ELSE
{
- bit_index++;
+ bit_index = add( bit_index, 1 );
bit_tmp = sub( *bit, GSC_freq_bits[bit_index] );
- bit_index++;
+ bit_index = add( bit_index, 1 );
nb_bands_max = add( nb_bands_max, GSC_freq_bits[bit_index] );
- bit_index++;
+ bit_index = add( bit_index, 1 );
*pvq_len = 112;
move16();
st_band = 7;
move16();
#if 1 // def ADD_LRTD
- IF( L_frame == L_FRAME16k && core_brate > ACELP_16k40 )
+ test();
+ IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_16k40 ) )
{
*pvq_len = 160;
+ move16();
st_band = 10;
- nb_bands = *pvq_len / 16;
- bit_tmp -= 35;
+ move16();
+ nb_bands = shr( *pvq_len, 4 );
+ bit_tmp = sub( bit_tmp, 35 );
bit_new_bands = 5;
+ move16();
}
#endif
IF( LE_32( core_brate, ACELP_9k60 ) )
@@ -550,7 +635,7 @@ void bands_and_bit_alloc_ivas_fx(
nb_bands = shr( *pvq_len, 4 );
#if 1 // def ADD_LRTD
- nb_bands_max = min( nb_bands_max, MBANDS_GN_BITALLOC16k );
+ nb_bands_max = s_min( nb_bands_max, MBANDS_GN_BITALLOC16k );
#endif
/*------------------------------------------------------------------------
* Ajustement of the maximum number of bands in function of the
@@ -560,17 +645,17 @@ void bands_and_bit_alloc_ivas_fx(
test();
test();
test();
- IF( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) )
+ IF( coder_type == INACTIVE || GE_16( noise_lev, NOISE_LEVEL_SP3 ) )
{
/* Probably classification error -> concentrate bits on LF */
#if 1 // def ADD_LRTD
- IF( L_frame == L_FRAME16k && core_brate >= ACELP_24k40 )
+ IF( EQ_16( L_frame, L_FRAME16k ) && GE_32( core_brate, ACELP_24k40 ) )
{
- nb_bands_max = nb_tot_bands - 2;
+ nb_bands_max = sub( nb_tot_bands, 2 );
}
- ELSE IF( core_brate >= ACELP_16k40 )
+ ELSE IF( GE_32( core_brate, ACELP_16k40 ) )
{
- nb_bands_max = nb_bands + 2;
+ nb_bands_max = add( nb_bands, 2 );
}
ELSE
#endif
@@ -594,29 +679,30 @@ void bands_and_bit_alloc_ivas_fx(
nb_bands_max = sub( nb_bands_max, 1 );
}
#if 1 // def ADD_LRTD
- IF( L_frame == L_FRAME16k )
+ IF( EQ_16( L_frame, L_FRAME16k ) )
{
- IF( core_brate < ACELP_24k40 )
+ IF( LT_32( core_brate, ACELP_24k40 ) )
{
- nb_bands_max -= 4;
+ nb_bands_max = sub( nb_bands_max, 4 );
}
- ELSE IF( core_brate < ACELP_32k )
+ ELSE IF( LT_32( core_brate, ACELP_32k ) )
{
- IF( Diff_len > 0 || noise_lev >= NOISE_LEVEL_SP2 )
+ test();
+ IF( GT_16( Diff_len, 0 ) || GE_16( noise_lev, NOISE_LEVEL_SP2 ) )
{
- nb_bands_max -= 2;
- bit_new_bands *= 2;
+ nb_bands_max = sub( nb_bands_max, 2 );
+ bit_new_bands = shl( bit_new_bands, 1 );
}
}
ELSE IF( core_brate >= ACELP_32k )
{
- bit_new_bands *= 2;
+ bit_new_bands = shl( bit_new_bands, 1 );
}
}
#endif
test();
- IF( EQ_16( bwidth, NB ) && GT_16( nb_bands_max, 10 ) )
+ if ( ( bwidth == NB ) && GT_16( nb_bands_max, 10 ) )
{
nb_bands_max = 10;
move16();
@@ -625,8 +711,10 @@ void bands_and_bit_alloc_ivas_fx(
/*------------------------------------------------------------------------
* Find extra number of band to code according to bit rate availables
*-----------------------------------------------------------------------*/
+ test();
WHILE( GE_16( bit_tmp, bit_new_bands ) && LE_16( nb_bands, sub( nb_bands_max, 1 ) ) )
{
+ test();
bit_tmp = sub( bit_tmp, bit_new_bands );
nb_bands = add( nb_bands, 1 );
}
@@ -635,14 +723,20 @@ void bands_and_bit_alloc_ivas_fx(
* Fractional bits to distribute on the first x bands
*-----------------------------------------------------------------------*/
#if 1 // def ADD_LRTD
- IF( L_frame == L_FRAME16k && core_brate > ACELP_32k )
+ test();
+ IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_32k ) )
{
bit_fracf = 0;
+ move32();
}
ELSE
#endif
{
- bit_fracf = L_mult( div_s( 1, st_band ), shl( bit_tmp, 2 ) ); /* Q18 */
+#ifdef FIX_802__NON_BE_DECODING
+ bit_fracf = Find_bit_frac( st_band, bit_tmp );
+#else
+ bit_fracf = L_mult( div_s( 1, st_band ), shl( bit_tmp, 2 ) ); /* Q18 */
+#endif
}
/*------------------------------------------------------------------------
* Complete the bit allocation per frequency band
@@ -662,20 +756,22 @@ void bands_and_bit_alloc_ivas_fx(
bit_index = add( bit_index, 1 );
}
#if 1 // def ADD_LRTD
- IF( L_frame == L_FRAME16k && core_brate > ACELP_16k40 )
+ IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_16k40 ) )
{
bit_index = 0;
- i = imax - 1;
+ move16();
+ i = sub( imax, 1 );
// bits_per_bands[i] += Compl_GSC_freq_bits[bit_index];
bits_per_bands[i] = L_add( bits_per_bands[i], L_shl( Compl_GSC_freq_bits[bit_index], Q18 ) );
- i++;
- bit_index++;
+ i = add( i, 1 );
+ bit_index = add( bit_index, 1 );
FOR( ; i < 10; i++ )
{
// bits_per_bands[i] += Compl_GSC_freq_bits[bit_index] + bit_fracf;
bits_per_bands[i] = L_add( bits_per_bands[i], L_add( L_shl( Compl_GSC_freq_bits[bit_index], Q18 ), bit_fracf ) );
- bit_index++;
+ move32();
+ bit_index = add( bit_index, 1 );
}
}
#endif
@@ -694,7 +790,8 @@ void bands_and_bit_alloc_ivas_fx(
{
FOR( j = 0; j < nb_tot_bands; j++ )
{
- bits_per_bands[j] = max( bits_per_bands[j], 0 );
+ bits_per_bands[j] = L_max( bits_per_bands[j], 0 );
+ move32();
}
}
@@ -703,26 +800,28 @@ void bands_and_bit_alloc_ivas_fx(
* Complete the bit allocation per frequency band for 16kHz high brate mode
*--------------------------------------------------------------------------*/
#if 1 // def ADD_LRTD
- IF( L_frame == L_FRAME16k && core_brate > ACELP_32k )
+ IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_32k ) )
{
FOR( j = st_band; j < nb_bands; j++ )
{
// bits_per_bands[j] = bit_new_bands;
bits_per_bands[j] = L_shl( bit_new_bands, Q18 );
+ move32();
}
// bit_fracf = (1.0f / nb_bands) * (bit_tmp);
- bit_fracf = ( 262144 / nb_bands ) * ( bit_tmp );
+ bit_fracf = L_shl( L_mult0( idiv1616( 16384, nb_bands ), bit_tmp ), 4 );
// etmp = 2.0f * bit_fracf / (nb_bands + 1);
- etmp = (Word16) L_shr( L_shl( bit_fracf, Q1 ) / ( nb_bands + 1 ), Q3 ); // Q15
+ etmp = divide3216( L_shr( bit_fracf, Q2 ), add( nb_bands, 1 ) ); // Q15
// bit_fracf = etmp;
bit_fracf = L_shl( etmp, Q3 ); // Q18
- FOR( j = nb_bands - 1; j >= 0; j-- )
+ FOR( j = sub( nb_bands, 1 ); j >= 0; j-- )
{
// bits_per_bands[j] = etmp;
// etmp += bit_fracf;
bits_per_bands[j] = L_add( bits_per_bands[j], L_shl( etmp, Q3 ) ); // Q18
+ move32();
etmp = (Word16) L_add( etmp, L_shr( bit_fracf, Q3 ) );
}
}
@@ -886,15 +985,17 @@ void bands_and_bit_alloc_ivas_fx(
{
// bits_per_bands[i] = (float)floor(bits_per_bands[i]);
bits_per_bands[i] = L_shl( L_shr( bits_per_bands[i], Q18 ), Q18 );
+ move32();
sum_bit = L_add( sum_bit, L_shr( bits_per_bands[i], Q18 ) );
}
- IF( GSC_IVAS_mode != 0 && sum_bit < *bit ) /* If we need to add bits, we are doing it on the LF */
+ test();
+ IF( GSC_IVAS_mode != 0 && LT_32( sum_bit, *bit ) ) /* If we need to add bits, we are doing it on the LF */
{
- reajust_bits_fx( bits_per_bands, 0, nb_bands, (int16_t) sum_bit, *bit );
+ reajust_bits_fx( bits_per_bands, 0, nb_bands, (Word16) sum_bit, *bit );
}
ELSE
{
- reajust_bits_fx( bits_per_bands, nb_bands - 1, 0, (int16_t) sum_bit, *bit );
+ reajust_bits_fx( bits_per_bands, sub( nb_bands, 1 ), 0, (Word16) sum_bit, *bit );
}
w_sum_bit = 0;
move16();
@@ -945,7 +1046,9 @@ void bands_and_bit_alloc_ivas_fx(
{
set_s( out_bits_per_bands, 0, nb_tot_bands );
*nb_subbands = 0;
+ move16();
*pvq_len = 0;
+ move16();
}
#endif
return;
@@ -968,43 +1071,389 @@ static void reajust_bits_fx(
Word16 bit_bdgt, sum_bit;
incr = 1;
- IF( end_band < st_band )
+ move16();
+ if ( LT_16( end_band, st_band ) )
{
incr = -1;
+ move16();
}
- IF( bit_bdgt_in < sum_bit_in )
+ IF( LT_16( bit_bdgt_in, sum_bit_in ) )
{
amount_to_add = -1;
+ move16();
bit_bdgt = sum_bit_in;
+ move16();
sum_bit = bit_bdgt_in;
+ move16();
}
ELSE
{
bit_bdgt = bit_bdgt_in;
+ move16();
sum_bit = sum_bit_in;
+ move16();
amount_to_add = 1;
+ move16();
}
i = st_band;
- WHILE( bit_bdgt > sum_bit )
+ move16();
+ WHILE( GT_16( bit_bdgt, sum_bit ) )
{
- // if (amount_to_add > 0 || (amount_to_add < 0 && bits_per_bands[i] > 1))
- IF( amount_to_add > 0 || ( amount_to_add < 0 && bits_per_bands[i] > 262144 ) )
+ /* if (amount_to_add > 0 || (amount_to_add < 0 && bits_per_bands[i] > 1))*/
+ test();
+ test();
+ IF( amount_to_add > 0 || ( amount_to_add < 0 && GT_32( bits_per_bands[i], 262144 ) ) )
{
- // bits_per_bands[i] += amount_to_add;
+ /* bits_per_bands[i] += amount_to_add;*/
bits_per_bands[i] = L_add( bits_per_bands[i], L_shl( amount_to_add, Q18 ) );
+ move32();
sum_bit = add( sum_bit, abs_s( amount_to_add ) );
}
- i += incr;
- IF( i == end_band )
+ i = add( i, incr );
+ if ( EQ_16( i, end_band ) )
{
i = st_band;
+ move16();
}
}
return;
}
+#ifdef FIX_802__NON_BE_DECODING
+
+/*-------------------------------------------------------------------*
+ * Find_bit_frac()
+ *
+ * Computes the fraction of the remaining bit budget to allocate to the bands
+ *-------------------------------------------------------------------*/
+
+static Word32 Find_bit_frac(
+ const Word16 nb_band,
+ const Word16 remaining_bits )
+{
+ int16_t inv_bandQ15;
+ int32_t L_out;
+
+ inv_bandQ15 = 6553;
+ move16();
+ IF( nb_band == 7 )
+ {
+ inv_bandQ15 = 4681;
+ move16();
+ }
+ ELSE IF( nb_band == 3 )
+ {
+ inv_bandQ15 = 10922;
+ move16();
+ }
+ ELSE IF( nb_band == 4 )
+ {
+ inv_bandQ15 = 8192;
+ move16();
+ }
+ ELSE IF( nb_band == 5 )
+ {
+ inv_bandQ15 = 6536;
+ move16();
+ }
+ ELSE IF( nb_band == 10 )
+ {
+ inv_bandQ15 = 3277;
+ move16();
+ }
+ ELSE
+ {
+#ifdef DEBUGGING
+ printf( "1/%d NOT DEFINED in Find_bit_frac\n", nb_band );
+#endif
+ }
+ L_out = L_mult( inv_bandQ15, shl( remaining_bits, 2 ) );
+
+ return ( L_out );
+}
+#endif
+#ifdef FIX_802_1137_1137_GSC_IVAS_FXFLT_DECODING
+static Word16 Find_bit_alloc_IVAS( /*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 */
+ Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */
+ Word16 *max_ener_band, /* i/o: Energy based sorted order */
+ Word16 *ener_vec, /* i/o: Energy per band order */
+ Word32 *bits_per_bands /* o : Number of bit allowed per allowed subband 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;
+ Word32 Ltmp, etmp_32fx;
+
+ SWB_bit_budget = *bit; // Q0
+ st_band = 5;
+ nb_bands_max = nb_tot_bands_in;
+
+ move16();
+ move16();
+ move16();
+
+ set32_fx( bits_per_bands, 0, MBANDS_GN_BITALLOC16k );
+
+ /* Decide the percentage 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, Q18 ) ), Q18_0_76 ); /* Q18 */
+
+ /* bit_fracf = check_bounds(bit_fracf, 0.50f, 0.75f); */
+ bit_fracf = check_bounds_l( bit_fracf, Q18_0_50, Q18_0_75 ); /* Q18 */
+
+ /* Adjustment 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 ( LE_16( GSC_IVAS_mode, 3 ) )
+ {
+ nb_bands_max = sub( nb_bands_max, 6 );
+ }
+ IF( EQ_16( GSC_IVAS_mode, 2 ) )
+ {
+ /* bit_fracf += 0.1f; */
+ bit_fracf = L_add( bit_fracf, Q18_0_1 ); /* Q18*/
+ nb_bands_max = sub( nb_bands_max, 1 );
+ }
+ IF( EQ_16( GSC_IVAS_mode, 3 ) )
+ {
+ /* bit_fracf -= 0.1f; */
+ bit_fracf = L_sub( bit_fracf, Q18_0_1 ); /* Q18*/
+ nb_bands_max = add( 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;
+ move32();
+ IF( EQ_16( GSC_IVAS_mode, 1 ) && LT_32( 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, Q18 ) ), Q18_0_75 ); // Q18
+ }
+ ELSE IF( NE_16( GSC_IVAS_mode, 2 ) && GT_32( 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, Q18 ) ), 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;
+ move32();
+
+ test();
+ IF( LT_32( core_brate, GSC_L_RATE_STG ) && EQ_16( GSC_IVAS_mode, 3 ) )
+ {
+ /* mp = 1.5f * DSR_NB_PULSE;*/
+ mp = Q18_1_5xDSR_NB_PULSE;
+ move32();
+ }
+ ELSE IF( LT_32( core_brate, GSC_L_RATE_STG ) )
+ {
+ /* mp = DSR_NB_PULSE;*/
+ mp = Q18_DSR_NB_PULSE;
+ move32();
+ }
+
+ /* 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, Q18 ), 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 = L_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 = sub( nb_bands_max, st_band );
+ /* bit_fracf += bit_adj; */
+ bit_fracf = L_add( bit_fracf, bit_adj ); /* Q18 */
+ }
+ nb_tot_bands_loc = add( nb_tot_bands_loc, st_band );
+
+ /* Allocate bits to LF */
+ /* etmp = 0.23f; */
+ etmp_32fx = Q31_0_23;
+ move32();
+ FOR( j = 0; j < st_band; j++ )
+ {
+ i = j;
+ move16();
+ max_ener_band[j] = i;
+ move16();
+ ener_vec[i] = MIN16B;
+ move16();
+ /* bits_per_bands[j] = etmp * bit_fracf; */
+ bits_per_bands[j] = Mpy_32_32( bit_fracf, etmp_32fx ); /* 18 + 31 + 1 - 32 = Q18 */
+ move32();
+ /* etmp -= 0.015f; */
+ etmp_32fx = L_sub( etmp_32fx, Q31_0_015 ); /* Q18 */
+ }
+
+ /* SWB_bit_budget -= bit_fracf; */
+ SWB_bit_budget = L_sub( L_shl( SWB_bit_budget, Q18 ), bit_fracf ); /* Q0->Q18 */
+
+ /* Find low energy band in HF */
+ set16_fx( nb_pulse_per_band, 2, MBANDS_GN_BITALLOC16k );
+ FOR( i = st_band + 2; i < nb_tot_bands_loc - 1; i++ )
+ {
+ test();
+ if ( LT_16( ener_vec[i], ener_vec[i - 1] ) && LT_16( ener_vec[i], ener_vec[i + 1] ) ) /* i +1 and i -1 can be considered as 2 ptrs */
+ {
+ nb_pulse_per_band[i] = 1;
+ move16();
+ }
+ }
+ FOR( j = st_band; j < nb_tot_bands_loc; j++ )
+ {
+ IF( GT_16( j, 6 ) )
+ {
+ i = maximum_fx( ener_vec, nb_tot_bands_loc, &etmp );
+ }
+ ELSE
+ {
+ i = j;
+ move16();
+ }
+ max_ener_band[j] = i;
+ move16();
+ ener_vec[i] = MIN16B;
+ move16();
+ }
+
+ /* Recompute the final bit distribution for HF */
+ IF( GT_16( nb_tot_bands_loc, st_band ) )
+ {
+ /* mb = ( SWB_bit_budget * 2 / ( nb_tot_bands_loc - st_band ) ) - mp; */
+ /* bit_fracf = ( mb - mp ) / ( 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 = L_sub( 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;
+ move32();
+ if ( GT_16( nb_pulse_per_band[max_ener_band[j]], 1 ) )
+ {
+ bits_per_bands[max_ener_band[j]] = mb;
+ move32();
+ }
+ mb = L_sub( mb, bit_fracf );
+ SWB_bit_budget = L_sub( 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 = sub( st_band, 1 );
+ WHILE( SWB_bit_budget > 0 )
+ {
+ /* bits_per_bands[i]++; */
+ bits_per_bands[i] = L_add( bits_per_bands[i], Q18_1_0 );
+ move32();
+ /* SWB_bit_budget--; */
+ SWB_bit_budget = L_sub( SWB_bit_budget, Q18_1_0 );
+ i--;
+ if ( EQ_16( i, -1 ) )
+ {
+ i = sub( st_band, 1 );
+ }
+ }
+ }
+
+ /*nb_bands = nb_tot_bands_loc;*/
+
+ sum_bit = 0;
+ move32();
+ j = 0;
+ move16();
+ FOR( i = 0; i < nb_tot_bands_loc; i++ )
+ {
+ /* if (bits_per_bands[i] > 112) */
+ IF( GT_32( 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;
+ move32();
+ j = add( j, add( i, 1 ) );
+ }
+
+ /* safety check for overage bit reallocation */
+ /* else if (bits_per_bands[i] + sum_bit / 3 > 112) */
+ ELSE IF( GT_32( 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 );
+ move32();
+ }
+ }
+ return nb_tot_bands_loc;
+}
+static Word16 Find_norm_inv( const Word32 ToDivide, Word16 *e_div ) /* Find normalized 1 / ToDivide */
+{
+ 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 );
+ move16();
+ return d_tmp;
+}
+#endif
#endif
diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c
index e81af00c84eb13cd4b23adbb046224ba712281ae..4de024088b91d5d005196915898c47bd143487d6 100644
--- a/lib_com/gs_gains_fx.c
+++ b/lib_com/gs_gains_fx.c
@@ -37,8 +37,7 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "stl.h"
/*-------------------------------------------------------------------*
@@ -111,6 +110,7 @@ void Comp_and_apply_gain_fx(
L32 = L_shl( L_mult( exc_diffQ[i], y_gain ), tmp_exp ); /*Q_exc+16 */
exc_diffQ[i] = round_fx( L32 ); /*Q_exc */
#endif /* BASOP_NOGLOB */
+ move16();
}
}
ELSE
@@ -223,7 +223,7 @@ void Ener_per_band_comp_fx(
IF( EQ_16( Eflag, 1 ) )
{
- y_gain4_fx[j + 1] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 );
+ y_gain4_fx[add( j, 1 )] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 );
move16();
pt_fx += 32;
}
@@ -237,7 +237,7 @@ void Ener_per_band_comp_ivas_fx(
const Word16 Q_exc, /* i : frame length */
const Word16 Mband, /* i : Max band */
const Word16 Eflag, /* i : flag of highest band */
- const int16_t L_frame /* i : frame length */
+ const Word16 L_frame /* i : frame length */
)
{
const Word16 *pt_fx;
@@ -260,12 +260,12 @@ void Ener_per_band_comp_ivas_fx(
IF( EQ_16( Eflag, 1 ) )
{
- y_gain4_fx[j + 1] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 );
+ y_gain4_fx[add( j, 1 )] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 );
move16();
pt_fx += 32;
}
- if ( L_frame == L_FRAME16k )
+ IF( EQ_16( L_frame, L_FRAME16k ) )
{
y_gain4_fx[j + 2] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 );
move16();
@@ -296,7 +296,7 @@ static void GSC_gain_adj(
/* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
Word16 Gain_off, i;
- IF( NE_16( coder_type, INACTIVE ) )
+ IF( coder_type != INACTIVE )
{
FOR( i = 0; i < MBANDS_GN; i++ )
{
@@ -369,6 +369,7 @@ static void GSC_gain_adj_ivas_fx(
/* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
Word16 Gain_off, i;
+ test();
IF( NE_16( coder_type, INACTIVE ) && NE_16( coder_type, UNVOICED ) )
{
FOR( i = 0; i < Mbands_gn; i++ )
@@ -383,6 +384,8 @@ static void GSC_gain_adj_ivas_fx(
{
Gain_off = 0;
move16();
+
+ test();
IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) )
{
Gain_off = 18432;
@@ -467,27 +470,27 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai
test();
IF( ( EQ_16( coder_type, AUDIO ) || EQ_16( coder_type, INACTIVE ) ) && EQ_16( bwidth_fx, NB ) )
{
- idx_g_fx = (Word16) get_next_indice( st_fx, 6 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
VDQ_vec_fx( &mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 6 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
move16();
VDQ_vec_fx( y_gainQ_fx, Mean_dic_NB_fx, Gain_dic1_NB_fx, idx_g_fx, 3 );
IF( LT_32( core_brate_fx, ACELP_9k60 ) )
{
- idx_g_fx = (Word16) get_next_indice( st_fx, 5 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NB_fx, idx_g_fx, 3 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 4 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 );
VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NB_fx, idx_g_fx, 4 );
}
ELSE
{
- idx_g_fx = (Word16) get_next_indice( st_fx, 6 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NBHR_fx, idx_g_fx, 3 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 7 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 7 );
VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4 );
}
test();
@@ -515,7 +518,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai
}
ELSE
{
- idx_g_fx = (Word16) get_next_indice( st_fx, 6 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
VDQ_vec_fx( &mean_4g_fx, mean_m_fx, mean_gain_dic_fx, idx_g_fx, 1 );
@@ -524,10 +527,10 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai
/*--------------------------------------------------------------------------------------*
* UQ of the first 8 bands and half of the last 8 bands
*--------------------------------------------------------------------------------------*/
- idx_g_fx = (Word16) get_next_indice( st_fx, 5 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 5 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
VDQ_vec_fx( y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4 );
/*----------------------------------------------------------------------*
@@ -535,7 +538,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai
* And scaling
*----------------------------------------------------------------------*/
- idx_g_fx = (Word16) get_next_indice( st_fx, 5 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
VDQ_vec_fx( y_gainQ_fx + 7, YGain_mean_LR_fx + 7, YGain_dic3_LR_fx, idx_g_fx, 5 );
@@ -568,16 +571,16 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai
}
ELSE
{
- idx_g_fx = (Word16) get_next_indice( st_fx, 6 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
VDQ_vec_fx( y_gainQ_fx, YG_mean16_fx, YG_dicMR_1_fx, idx_g_fx, 4 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 5 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
VDQ_vec_fx( y_gainQ_fx + 4, YG_mean16_fx + 4, YG_dicMR_2_fx, idx_g_fx, 4 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 5 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
VDQ_vec_fx( y_gainQ_fx + 8, YG_mean16_fx + 8, YG_dicMR_3_fx, idx_g_fx, 4 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 4 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 );
VDQ_vec_fx( y_gainQ_fx + 12, YG_mean16_fx + 12, YG_dicMR_4_fx, idx_g_fx, 4 );
}
}
@@ -631,27 +634,26 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc
test();
IF( ( EQ_16( coder_type, AUDIO ) || EQ_16( coder_type, INACTIVE ) ) && EQ_16( bwidth_fx, NB ) )
{
- idx_g_fx = (Word16) get_next_indice( st_fx, 6 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
VDQ_vec_fx( &mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 6 );
- move16();
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
VDQ_vec_fx( y_gainQ_fx, Mean_dic_NB_fx, Gain_dic1_NB_fx, idx_g_fx, 3 );
IF( LT_32( core_brate_fx, ACELP_9k60 ) )
{
- idx_g_fx = (Word16) get_next_indice( st_fx, 5 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NB_fx, idx_g_fx, 3 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 4 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 );
VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NB_fx, idx_g_fx, 4 );
}
ELSE
{
- idx_g_fx = (Word16) get_next_indice( st_fx, 6 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NBHR_fx, idx_g_fx, 3 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 7 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 7 );
VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4 );
}
test();
@@ -679,7 +681,7 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc
}
ELSE
{
- idx_g_fx = (Word16) get_next_indice( st_fx, 6 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
VDQ_vec_fx( &mean_4g_fx, mean_m_fx, mean_gain_dic_fx, idx_g_fx, 1 );
@@ -688,10 +690,10 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc
/*--------------------------------------------------------------------------------------*
* UQ of the first 8 bands and half of the last 8 bands
*--------------------------------------------------------------------------------------*/
- idx_g_fx = (Word16) get_next_indice( st_fx, 5 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 5 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
VDQ_vec_fx( y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4 );
/*----------------------------------------------------------------------*
@@ -699,7 +701,7 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc
* And scaling
*----------------------------------------------------------------------*/
- idx_g_fx = (Word16) get_next_indice( st_fx, 5 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
VDQ_vec_fx( y_gainQ_fx + 7, YGain_mean_LR_fx + 7, YGain_dic3_LR_fx, idx_g_fx, 5 );
@@ -717,6 +719,7 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc
{
/*y_gainQ_fx[i] *= 1.41f;*/
y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */
+ move16();
}
/*----------------------------------------------------------------------*
* Copy the true Q values in the specific bands
@@ -732,35 +735,35 @@ Word16 gsc_gaindec_ivas_fx( /* o : average frequenc
}
ELSE
{
- if ( st_fx->L_frame == L_FRAME )
+ IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
- idx_g_fx = (Word16) get_next_indice( st_fx, 6 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
VDQ_vec_fx( y_gainQ_fx, YG_mean16_fx, YG_dicMR_1_fx, idx_g_fx, 4 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 5 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
VDQ_vec_fx( y_gainQ_fx + 4, YG_mean16_fx + 4, YG_dicMR_2_fx, idx_g_fx, 4 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 5 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
VDQ_vec_fx( y_gainQ_fx + 8, YG_mean16_fx + 8, YG_dicMR_3_fx, idx_g_fx, 4 );
- idx_g_fx = (Word16) get_next_indice( st_fx, 4 );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 );
VDQ_vec_fx( y_gainQ_fx + 12, YG_mean16_fx + 12, YG_dicMR_4_fx, idx_g_fx, 4 );
}
- else
+ ELSE
{
- idx_g_fx = get_next_indice( st_fx, 7 );
+ idx_g_fx = get_next_indice_fx( st_fx, 7 );
VDQ_vec_fx( y_gainQ_fx, YG_mean16HR_fx, YG_dicHR_1_fx, idx_g_fx, 4 );
- idx_g_fx = get_next_indice( st_fx, 6 );
+ idx_g_fx = get_next_indice_fx( st_fx, 6 );
VDQ_vec_fx( y_gainQ_fx + 4, YG_mean16HR_fx + 4, YG_dicHR_2_fx, idx_g_fx, 4 );
- idx_g_fx = get_next_indice( st_fx, 6 );
+ idx_g_fx = get_next_indice_fx( st_fx, 6 );
VDQ_vec_fx( y_gainQ_fx + 8, YG_mean16HR_fx + 8, YG_dicHR_3_fx, idx_g_fx, 4 );
- idx_g_fx = get_next_indice( st_fx, 6 );
+ idx_g_fx = get_next_indice_fx( st_fx, 6 );
VDQ_vec_fx( y_gainQ_fx + 12, YG_mean16HR_16kHz_fx, YG_dicHR_4_16kHz_fx, idx_g_fx, 4 );
- idx_g_fx = get_next_indice( st_fx, 3 );
+ idx_g_fx = get_next_indice_fx( st_fx, 3 );
VDQ_vec_fx( y_gainQ_fx + 16, YG_meanL2G_16kHz_fx, YG_dicL2G_16kHz_fx, idx_g_fx, 2 );
}
}
@@ -799,7 +802,7 @@ Word16 gsc_gainQ_fx( /*Q12*/
test();
test();
- IF( ( EQ_16( coder_type, AUDIO ) || EQ_16( coder_type, INACTIVE ) ) && EQ_16( bwidth, NB ) )
+ IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && ( bwidth == NB ) )
{
/*ftmp1 = mean(y_gain4, 10)-0.6f;*/
@@ -827,6 +830,7 @@ Word16 gsc_gainQ_fx( /*Q12*/
/* Quantized mean gain without clipping */
mean_4g[0] = round_fx( L_tmp );
+ move16();
idx_g = vquant_fx( mean_4g, Gain_meanNB_fx, mean_4g, Gain_mean_dicNB_fx, 1, 64 );
push_indice_fx( hBstr, IND_MEAN_GAIN2, idx_g, 6 );
@@ -863,12 +867,18 @@ Word16 gsc_gainQ_fx( /*Q12*/
/* Some energy is needed in high band for stat_noise_uv_enc
to be functional in inactive speech */
y_gain_tmp[10] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[6], 8192 ), y_gain_tmp[7], 8192 ), y_gain_tmp[8], 8192 ) );
+ move16();
y_gain_tmp[11] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[7], 8192 ), y_gain_tmp[8], 8192 ), y_gain_tmp[9], 8192 ) );
+ move16();
y_gain_tmp[12] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[8], 8192 ), y_gain_tmp[9], 8192 ), y_gain_tmp[10], 8192 ) );
+ move16();
y_gain_tmp[13] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[9], 8192 ), y_gain_tmp[10], 8192 ), y_gain_tmp[11], 8192 ) );
+ move16();
y_gain_tmp[14] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[10], 8192 ), y_gain_tmp[11], 8192 ), y_gain_tmp[12], 8192 ) );
+ move16();
y_gain_tmp[15] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[11], 8192 ), y_gain_tmp[12], 8192 ), y_gain_tmp[13], 8192 ) );
+ move16();
}
ELSE
{
@@ -880,6 +890,7 @@ Word16 gsc_gainQ_fx( /*Q12*/
/*ftmp1 = mean(y_gain4, 16);*/
L_tmp = 0;
+ move32();
FOR( cnt = 0; cnt < 16; cnt++ )
{
L_tmp = L_mac( L_tmp, y_gain4[cnt], 2048 );
@@ -889,6 +900,7 @@ Word16 gsc_gainQ_fx( /*Q12*/
tmp1 = sub( tmp16, 4915 );
tmp2 = add( tmp16, 4915 );
L_tmp = 0;
+ move32();
FOR( i = 0; i < 16; i++ )
{
y_gain_tmp2[i] = y_gain4[i];
@@ -904,8 +916,10 @@ Word16 gsc_gainQ_fx( /*Q12*/
FOR( ; i < Mbands_gn; i++ )
{
y_gain_tmp2[i] = y_gain4[i];
+ move16();
/*if(y_gain4[i] < ftmp1-0.6f)*/
y_gain_tmp2[i] = s_max( y_gain_tmp2[i], tmp1 ); /* Just the last move is needed, because s_max and s_min could be done in 1 line*/
+ move16();
/*else if(y_gain4[i] > ftmp1+0.6f)*/
y_gain_tmp2[i] = s_min( y_gain_tmp2[i], tmp2 );
move16();
@@ -913,6 +927,7 @@ Word16 gsc_gainQ_fx( /*Q12*/
/* Quantized mean gain without clipping */
mean_4g[0] = round_fx( L_tmp );
+ move16();
/*idx_g = (short)vquant(mean_4g, mean_m, mean_4g, mean_gain_dic, 1, 64);*/
@@ -940,6 +955,7 @@ Word16 gsc_gainQ_fx( /*Q12*/
move16();
idx_g = 0;
+ move16();
/*idx_g = (short)vquant(y_gain_tmp2, YGain_mean_LR, y_gain_tmp2, YGain_dic1_LR, 3, 32);*/
idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 );
@@ -962,6 +978,7 @@ Word16 gsc_gainQ_fx( /*Q12*/
Copy( y_gain_tmp2 + 8, y_gain_tmp + 8, 3 );
y_gain_tmp[15] = y_gain_tmp2[11];
+ move16();
ifft_rel_fx( y_gain_tmp + 8, 8, 3 );
FOR( i = 8; i < 16; i++ )
diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c
index 16fbddb4136c31409f816a86fbdd27766235ee4b..01a0556208933370f8cb507ed705e700f5df5b3d 100644
--- a/lib_com/gs_inact_switching_fx.c
+++ b/lib_com/gs_inact_switching_fx.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "stl.h"
/*-------------------------------------------------------------------*
@@ -137,6 +136,7 @@ void Inac_swtch_ematch_fx(
L_tmp = L_shl( L_tmp, add( exp, 15 ) ); /* Q(Q_exc+1) -> Q(16+Q_exc)*/
*pt_exc = round_fx( L_tmp );
#endif
+ move16();
pt_exc++;
}
}
@@ -152,6 +152,7 @@ void Inac_swtch_ematch_fx(
L_tmp = L_shl( L_tmp, add( exp, 15 ) ); /* Q(Q_exc+1) -> Q(16+Q_exc)*/
*pt_exc = round_fx( L_tmp ); /*Q_exc*/
#endif
+ move16();
pt_exc++;
}
}
@@ -243,6 +244,7 @@ void Inac_switch_ematch_ivas_fx(
L_tmp = L_mult( ALPHA0_FX, lt_ener_per_band[i] ); /*Q(15+12+1)=Q(28) */
L_tmp = L_mac( L_tmp, BETA0_FX, Ener_per_bd[i] ); /*Q28 */
lt_ener_per_band[i] = round_fx( L_tmp ); /*Q12 */
+ move16();
ftmp = sub( lt_ener_per_band[i], Ener_per_bd[i] ); /*Q12 */
@@ -263,6 +265,7 @@ void Inac_switch_ematch_ivas_fx(
L_tmp = L_mult0( *pt_exc, ftmp );
L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/
*pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/
+ move16();
pt_exc++;
}
}
@@ -273,6 +276,7 @@ void Inac_switch_ematch_ivas_fx(
L_tmp = L_mult0( *pt_exc, ftmp );
L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/
*pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/
+ move16();
pt_exc++;
}
}
diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c
index 1809a1f6f2320e2e13c4c65da33983fec3c3e008..2dea2adef957003bf5943d58b7576da6feb92116 100644
--- a/lib_com/gs_noisefill_fx.c
+++ b/lib_com/gs_noisefill_fx.c
@@ -4,8 +4,7 @@
#include
#include "options.h"
#include "rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
* gs_noisf()
@@ -96,17 +95,17 @@ static void EstimateNoiseLevel_inner_fx(
noise_offset = 8192;
move16();
/*0.25f * 32768 */
- IF( bitrate > ACELP_24k40 )
+ IF( GT_32( bitrate, ACELP_24k40 ) )
{
noise_offset = 6554;
move16(); /*.2f * 32768 */
}
- ELSE IF( bitrate >= ACELP_22k60 )
+ ELSE IF( GE_32( bitrate, ACELP_22k60 ) )
{
noise_offset = 9830;
move16(); /*.3f * 32768 */
}
- ELSE IF( bitrate >= ACELP_9k60 )
+ ELSE IF( GE_32( bitrate, ACELP_9k60 ) )
{
noise_offset = 11469;
move16(); /*0.35f * 32768 */
@@ -194,6 +193,7 @@ static void EstimateNoiseLevel_fx(
}
}
test();
+ test();
IF( ( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) && EQ_16( L_frame, L_FRAME ) )
{
FOR( i_band = 9; i_band < Mbands_gn; i_band++ )
@@ -280,8 +280,7 @@ static void Apply_NoiseFill_fx(
FOR( i_band = 0; i_band < Mbands_gn; i_band++ )
{
- StartBin += NB_Qbins;
- move16();
+ StartBin = add( StartBin, NB_Qbins );
NB_Qbins = freq_nsbin_per_band[i_band];
move16();
@@ -333,7 +332,7 @@ void freq_dnw_scaling_fx(
start_sc = L_frame;
move16();
test();
- IF( LE_32( core_brate, ACELP_8k00 ) && EQ_16( coder_type, INACTIVE ) )
+ IF( LE_32( core_brate, ACELP_8k00 ) && ( coder_type == INACTIVE ) )
{
sc_dyn = mult_r( sc_dyn, 4915 ); /*Q15 (0.15 in Q15) */
start_sc = 64;
@@ -357,6 +356,7 @@ void freq_dnw_scaling_fx(
}
}
+ test();
IF( EQ_16( L_frame, L_FRAME16k ) && LE_32( core_brate, ACELP_24k40 ) )
{
/*sc_dyn += 0.125f;*/
@@ -411,12 +411,15 @@ static void Decreas_freqPeak_fx(
Word16 tmp2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move16();
#endif
move16(); /*ptr init*/
lsf_new_diff[0] = 0; /* prevent unitialized value */
+ move16();
FOR( j = 1; j < ( M - 1 ); j++ )
{
lsf_new_diff[j] = sub( lsf_new[j], lsf_new[j - 1] ); /*Qx2.56 */
+ move16();
}
avrg = 0;
@@ -479,6 +482,7 @@ static void Decreas_freqPeak_fx(
tmp1 = negate( tmp );
tmp2 = *src;
+ move16();
*( src ) = tmp1;
move16();
if ( tmp2 > 0 )
@@ -528,6 +532,7 @@ static void envelop_modify_fx(
Word16 Q_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move16();
#endif
start_band = i_mult( last_bin, 16 );
@@ -550,7 +555,8 @@ static void envelop_modify_fx(
move16();
Ener_fx = Isqrt_lc( Ener_fx, &exp1 ); /*Q(31-exp1) */
- weight_fx = 16384; /*Q15 */
+ weight_fx = 16384; /*Q15 */
+ move16();
src_fx = &exc_diffQ_fx[start_band]; /*Q_exc */
FOR( i = last_bin; i < last_bin + 4; i++ )
{
@@ -578,7 +584,7 @@ static void envelop_modify_fx(
L_tmp = L_mult0( sub( 32767, weight_fx ), Random( seed_tcx ) ); /*Q30 */
tmp1 = round_fx( L_shr( L_tmp, 2 ) );
- L_exc_diffQ_fx[16 * i + j] = L_mult0( Ener1_fx, add( tmp, tmp1 ) ); /*Q12 */
+ L_exc_diffQ_fx[add( i_mult( 16, i ), j )] = L_mult0( Ener1_fx, add( tmp, tmp1 ) ); /*Q12 */
move32();
src_fx++;
}
@@ -609,7 +615,7 @@ static void envelop_modify_fx(
L_tmp = L_mult0( sub( 32767, weight_fx ), Random( seed_tcx ) ); /*Q30 */
tmp1 = round_fx( L_shr( L_tmp, 2 ) ); /*Q12 */
- L_exc_diffQ_fx[16 * i + j] = L_mult0( Ener1_fx, add( tmp, tmp1 ) ); /*Q12 */
+ L_exc_diffQ_fx[add( i_mult( 16, i ), j )] = L_mult0( Ener1_fx, add( tmp, tmp1 ) ); /*Q12 */
move32();
src_fx++;
}
@@ -618,7 +624,7 @@ static void envelop_modify_fx(
move16();
FOR( i = start_band; i < L_FRAME; i++ )
{
- IF( GT_32( L_abs( L_exc_diffQ_fx[i] ), exc_diffQ_max ) )
+ if ( GT_32( L_abs( L_exc_diffQ_fx[i] ), exc_diffQ_max ) )
{
exc_diffQ_max = L_abs( L_exc_diffQ_fx[i] );
}
@@ -632,6 +638,7 @@ static void envelop_modify_fx(
FOR( i = start_band; i < L_FRAME; i++ )
{
exc_diffQ_fx[i] = extract_l( L_exc_diffQ_fx[i] );
+ move16();
}
}
ELSE
@@ -641,6 +648,7 @@ static void envelop_modify_fx(
FOR( i = start_band; i < L_FRAME; i++ )
{
exc_diffQ_fx[i] = extract_l( L_shr( L_exc_diffQ_fx[i], Q_tmp ) );
+ move16();
}
}
@@ -783,11 +791,13 @@ void highband_exc_dct_in_fx(
}
test();
-
+ test();
+ test();
IF( GSC_IVAS_mode == 0 && GSC_noisy_speech && !bfi && LE_16( element_mode, IVAS_SCE ) )
{
set16_fx( noisepb, 3277, MBANDS_GN );
}
+ test();
IF( LT_32( core_brate, 6000 ) && LE_16( coder_type, UNVOICED ) )
{
FOR( i = 0; i < L_frame; i++ )
@@ -829,6 +839,7 @@ void highband_exc_dct_in_fx(
tmp = msu_r( -7680 * 65536, -17564, shl( i, 6 ) ); /*-15 in Q9; -0.067 in Q18 and i in Q6= Q9 */
L_tmp = L_mult( exc_diffQ[i], tmp ); /*Q(Qexc_diffQ+10) */
exc_diffQ[i] = round_fx( L_shl( L_tmp, 16 - 10 ) ); /*Qexc_diffQ */
+ move16();
}
}
}
@@ -1211,6 +1222,10 @@ void highband_exc_dct_in_ivas_fx(
move16();
}
+ test();
+ test();
+ test();
+ test();
IF( bfi || LT_32( core_brate, 6000 ) || ( LT_32( core_brate, 8600 ) && EQ_16( coder_type, UNVOICED ) ) )
{
set16_fx( noisepb, 13107, MBANDS_GN ); /*0.4 in Q15 */
@@ -1229,12 +1244,15 @@ void highband_exc_dct_in_ivas_fx(
Copy( exc_diffQ, exc_wo_nf, L_frame );
}
+ test();
test();
IF( GSC_IVAS_mode == 0 && GSC_noisy_speech && !bfi && LE_16( element_mode, IVAS_SCE ) )
{
set16_fx( noisepb, 3277, MBANDS_GN );
}
+
+ test();
IF( LT_32( core_brate, 6000 ) && LE_16( coder_type, UNVOICED ) )
{
FOR( i = 0; i < L_frame; i++ )
@@ -1268,6 +1286,7 @@ void highband_exc_dct_in_ivas_fx(
{
Ener_per_band_comp_ivas_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1, L_frame );
+ test();
IF( LT_16( nb_subfr, 4 ) && LT_16( L_frame, L_FRAME16k ) )
{
FOR( i = L_FRAME - 16; i < L_FRAME; i++ )
@@ -1276,6 +1295,7 @@ void highband_exc_dct_in_ivas_fx(
tmp = msu_r( -7680 * 65536, -17564, shl( i, 6 ) ); /*-15 in Q9; -0.067 in Q18 and i in Q6= Q9 */
L_tmp = L_mult( exc_diffQ[i], tmp ); /*Q(Qexc_diffQ+10) */
exc_diffQ[i] = round_fx( L_shl( L_tmp, 16 - 10 ) ); /*Qexc_diffQ */
+ move16();
}
}
}
@@ -1328,23 +1348,30 @@ void highband_exc_dct_in_ivas_fx(
{
// float scale_factLF = 0.9f;
Word16 scale_factLF = 29491;
+ move16();
// float scale_factHF = 0.9f;
Word16 scale_factHF = 29491;
+ move16();
- IF( GSC_IVAS_mode == 1 && GSC_noisy_speech == 0 )
+ test();
+ test();
+ IF( EQ_16( GSC_IVAS_mode, 1 ) && GSC_noisy_speech == 0 )
{
// scale_factHF = 0.8f;
scale_factHF = 26214;
+ move16();
}
- ELSE IF( GSC_IVAS_mode == 2 || GSC_noisy_speech == 1 )
+ ELSE IF( EQ_16( GSC_IVAS_mode, 2 ) || EQ_16( GSC_noisy_speech, 1 ) )
{
// scale_factHF = 0.71f;
scale_factHF = 23265;
+ move16();
}
- ELSE IF( GSC_IVAS_mode == 3 )
+ ELSE IF( EQ_16( GSC_IVAS_mode, 3 ) )
{
// scale_factHF = 0.9f;
scale_factHF = 29491;
+ move16();
}
FOR( i = 0; i < pit_band_idx * 16; i++ )
{
@@ -1355,44 +1382,51 @@ void highband_exc_dct_in_ivas_fx(
{
// exc_diffQ[i] *= scale_factHF;
exc_diffQ[i] = mult_r( exc_diffQ[i], scale_factHF );
+ move16();
}
}
ELSE IF( GSC_noisy_speech )
{
// float scale_fact = 0.9f;
Word16 scale_fact = 29491;
+ move16();
- IF( element_mode == IVAS_CPE_TD )
+ IF( EQ_16( element_mode, IVAS_CPE_TD ) )
{
IF( coder_type == INACTIVE )
{
// scale_fact = 1.0f;
scale_fact = 32767;
+ move16();
}
ELSE
{
// scale_fact = 0.95f;
scale_fact = 31129;
+ move16();
}
}
- ELSE IF( element_mode > IVAS_SCE )
+ ELSE IF( GT_16( element_mode, IVAS_SCE ) )
{
// scale_fact = 0.71f;
scale_fact = 23265;
+ move16();
}
FOR( i = 0; i < L_frame; i++ )
{
// exc_diffQ[i] *= scale_fact;
exc_diffQ[i] = mult_r( exc_diffQ[i], scale_fact );
+ move16();
}
}
- IF( GSC_noisy_speech && element_mode > IVAS_SCE && core_brate < ACELP_7k20 )
+ IF( GSC_noisy_speech && GT_16( element_mode, IVAS_SCE ) && LT_32( core_brate, ACELP_7k20 ) )
{
FOR( i = 80; i < L_frame; i++ )
{
// exc_diffQ[i] *= (+0.0024f * (float)i + 1.192f);
exc_diffQ[i] = mult_r( shl( exc_diffQ[i], 1 ) /*Q16*/, (Word16) L_shr( L_add( 629 * i, 312475 ) /*Q18*/, Q4 ) /*Q14*/ );
+ move16();
}
}
#else
@@ -1421,7 +1455,7 @@ void highband_exc_dct_in_ivas_fx(
Vr_add( exc_dct_in, exc_diffQ, exc_dct_in, L_frame );
test();
- IF( core_brate == ACELP_8k00 && bwidth != NB )
+ IF( EQ_32( core_brate, ACELP_8k00 ) && bwidth != NB )
{
IF( EQ_16( bwe_flag, 1 ) )
{
diff --git a/lib_com/gs_preech.c b/lib_com/gs_preech.c
index 36487d90fc51331bed25deeb7f12b4a09ab57ad7..1c3c3ccfebe23fc6a268c80417435302aad0e5c1 100644
--- a/lib_com/gs_preech.c
+++ b/lib_com/gs_preech.c
@@ -41,8 +41,7 @@
#include "rom_com.h"
#include "prot.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
* Local constants
@@ -159,7 +158,7 @@ void pre_echo_att_fx(
Word16 att_len;
test();
- IF( GT_16( gsc_attack_flag_fx, 0 ) && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */
+ IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */
{
/*-------------------------------------------------------------------------*
* Find where the onset (attack) occurs by computing the energy per section
@@ -167,9 +166,11 @@ void pre_echo_att_fx(
* gradual onset
*-------------------------------------------------------------------------*/
att_len = ATT_LENGHT;
- if ( L_frame == L_FRAME16k )
+ move16();
+ if ( EQ_16( L_frame, L_FRAME16k ) )
{
att_len = ATT_LENGHT16k;
+ move16();
}
FOR( i = 0; i < att_len; i++ )
{
@@ -210,6 +211,7 @@ void pre_echo_att_fx(
/* = isqrt(etmp/(*Last_frame_ener)) */
etmp_fx = L_max( etmp_fx, 1 );
*Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 );
+ move32();
n1 = norm_l( etmp_fx );
n2 = norm_l( *Last_frame_ener_fx );
@@ -234,6 +236,7 @@ void pre_echo_att_fx(
{
/*exc_fx[i] *= ratio_fx;*/
exc_fx[i] = round_fx( L_shl( L_mac( -8192, exc_fx[i], ratio_fx ), 2 ) );
+ move16();
}
}
*Last_frame_ener_fx = etmp1_fx;
diff --git a/lib_com/guided_plc_util_fx.c b/lib_com/guided_plc_util_fx.c
index 87ab481438797fde15361be6dfddd7e690d51d9c..2610a7693db6701bbede427b8115aacb58e30e2f 100644
--- a/lib_com/guided_plc_util_fx.c
+++ b/lib_com/guided_plc_util_fx.c
@@ -4,8 +4,7 @@
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "basop_util.h"
#include "rom_basop_util.h"
@@ -71,6 +70,7 @@ void updateLSFForConcealment(
L_tmp = L_mult( divide_by_3_Q15, decState->lsfoldbfi1_14Q1[i] );
L_tmp = L_mac( L_tmp, divide_by_3_Q15, decState->lsfoldbfi0_14Q1[i] );
decState->lsf_adaptive_mean_14Q1[i] = mac_r( L_tmp, divide_by_3_Q15, lsf_14Q1[i] );
+ move16();
decState->lsfoldbfi1_14Q1[i] = decState->lsfoldbfi0_14Q1[i];
move16();
decState->lsfoldbfi0_14Q1[i] = lsf_14Q1[i];
@@ -96,7 +96,6 @@ void getConcealedLP(
Word16 lsp[( NB_DIV + 1 ) * M];
Word32 int_fs;
- move16();
lsf = memDecState->lsf_con;
diff --git a/lib_com/hp50.c b/lib_com/hp50.c
index 0e99e3203004354378827d0150da1e98e39fcdd2..dbabd5632224e2cabe735a9c4b6a333e6289b703 100644
--- a/lib_com/hp50.c
+++ b/lib_com/hp50.c
@@ -39,8 +39,7 @@
#include "options.h"
#include "prot.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*
* hp20
@@ -200,7 +199,7 @@ static void filter_2nd_order(
BASOP_SATURATE_ERROR_ON_EVS
L_sum = HP50_Mpy_32_32_fix( b2, mem[2] ); /* b2*x2 */
L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( b1, mem[3] ) ); /* b1*x1 */
- x2 = shr( signal[0 * stride], prescale );
+ x2 = shr( signal[0], prescale );
L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x2 ) ); /* b2*x0 */
L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[0], a2 ) ); /* y2*a2 */
L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a1 ) ); /* y1*a1 */
@@ -213,16 +212,16 @@ static void filter_2nd_order(
BASOP_SATURATE_ERROR_OFF_EVS
BASOP_SATURATE_WARNING_OFF_EVS
#ifdef BASOP_NOGLOB
- signal[0 * stride] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow );
+ signal[0] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow );
#else /* BASOP_NOGLOB */
- signal[0 * stride] = round_fx( L_shl( L_y2, prescale ) );
+ signal[0] = round_fx( L_shl( L_y2, prescale ) );
#endif /* BASOP_NOGLOB */
BASOP_SATURATE_WARNING_ON_EVS
BASOP_SATURATE_ERROR_ON_EVS
L_sum = HP50_Mpy_32_32_fix( b2, mem[3] ); /* b2*x2 */
L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b1, x2 ) ); /* b1*x1 */
- x1 = shr( signal[1 * stride], prescale );
+ x1 = shr( signal[stride], prescale );
L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x1 ) ); /* b2*x0 */
L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a2 ) ); /* y2*a2 */
L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) ); /* y1*a1 */
@@ -235,11 +234,12 @@ static void filter_2nd_order(
BASOP_SATURATE_ERROR_OFF_EVS
BASOP_SATURATE_WARNING_OFF_EVS
#ifdef BASOP_NOGLOB
- signal[1 * stride] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow );
+ signal[stride] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow );
#else /* BASOP_NOGLOB */
- signal[1 * stride] = round_fx( L_shl( L_y1, prescale ) );
+ signal[stride] = round_fx( L_shl( L_y1, prescale ) );
#endif /* BASOP_NOGLOB */
BASOP_SATURATE_WARNING_ON_EVS
+ move16();
/* New we use a trick and toggle x1/x2 and L_y1/L_y2 to save a few cycles unrolling the loop by 2 */
FOR( i = 2; i < lg; i += 2 )
@@ -261,9 +261,10 @@ static void filter_2nd_order(
BASOP_SATURATE_ERROR_OFF_EVS
BASOP_SATURATE_WARNING_OFF_EVS
#ifdef BASOP_NOGLOB
- signal[i * stride] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow );
+ signal[i_mult( i, stride )] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow );
#else /* BASOP_NOGLOB */
- signal[i * stride] = round_fx( L_shl( L_y2, prescale ) );
+ signal[i_mult( i, stride )] = round_fx( L_shl( L_y2, prescale ) );
+ move16();
#endif /* BASOP_NOGLOB */
BASOP_SATURATE_WARNING_ON_EVS
/* y[i+1] = b2*x[i-1] + b1*x[i-0] + b2*x[i+1] + a2*y[i-1] + a1*y[i+0]; */
@@ -283,11 +284,12 @@ static void filter_2nd_order(
BASOP_SATURATE_ERROR_OFF_EVS
BASOP_SATURATE_WARNING_OFF_EVS
#ifdef BASOP_NOGLOB
- signal[( i + 1 ) * stride] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow );
+ signal[i_mult( add( i, 1 ), stride )] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow );
#else /* BASOP_NOGLOB */
- signal[( i + 1 ) * stride] = round_fx( L_shl( L_y1, prescale ) );
+ signal[i_mult( add( i, 1 ), stride )] = round_fx( L_shl( L_y1, prescale ) );
#endif
BASOP_SATURATE_WARNING_ON_EVS
+ move16();
}
/* update static filter memory from variables */
mem[0] = L_y2;
@@ -295,7 +297,9 @@ static void filter_2nd_order(
mem[1] = L_y1;
move32();
mem[2] = L_deposit_h( x2 );
+ move32();
mem[3] = L_deposit_h( x1 );
+ move32();
return;
@@ -438,7 +442,7 @@ void hp20( Word16 signal[], /* i/o: signal to filter any *
}
-#ifdef IVAS_FLOAT_FIXED
+#if 0
void hp20_fix32(
Word32 signal_fx[],
const Word16 lg,
@@ -590,3 +594,189 @@ void hp20_fix32(
return;
}
#endif
+
+#ifdef IVAS_FLOAT_FIXED
+void hp20_fix32(
+ Word32 signal_fx[],
+ const Word16 lg,
+ Word32 mem_fx[],
+ const Word32 Fs )
+{
+ Word16 i;
+ Word32 a1_fx, a2_fx, b1_fx, b2_fx;
+ Word16 Qx0, Qx1, Qx2, Qy1, Qprev_y1, Qy2, Qprev_y2, Qmin;
+ Word64 x0_fx64, x1_fx64, x2_fx64, y0_fx64, y1_fx64, y2_fx64, R1, R2, R3, R4, R5;
+
+ IF( EQ_32( 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_fx = 1061816033l /* 1.977786483776764 Q29*/;
+ a2_fx = -525076131l /*-0.978030508491796 Q29*/;
+ b1_fx = -1061881538l /*-1.977908496134280 Q29*/;
+ b2_fx = 530940769l /* 0.988954248067140 Q29*/;
+ }
+ ELSE IF( EQ_32( 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_fx = 1067778748l /* 1.988892905899653 Q29*/;
+ a2_fx = -530940770l /*-0.988954249933127 Q29*/;
+ b1_fx = -1067795215l /*-1.988923577916390 Q29*/;
+ b2_fx = 533897608l /* 0.994461788958195 Q29*/;
+ }
+ ELSE IF( EQ_32( 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_fx = 1070760263l /* 1.994446410541927 Q29*/;
+ a2_fx = -533897608l /*-0.994461789075954 Q29*/;
+ b1_fx = -1070764392l /*-1.994454099808940 Q29*/;
+ b2_fx = 535382196l /* 0.997227049904470 Q29*/;
+ }
+ 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_fx = 1071754114l /* 1.996297601769122 Q29*/;
+ a2_fx = -534886875l /*-0.996304442992686 Q29*/;
+ b1_fx = -1071755951l /*-1.996301022380904 Q29*/;
+ b2_fx = 535877975l /* 0.998150511190452 Q29*/;
+ }
+ move32();
+ move32();
+ move32();
+ move32();
+
+ Qprev_y1 = extract_l( mem_fx[4] );
+ Qprev_y2 = extract_l( mem_fx[5] );
+ y1_fx64 = W_deposit32_l( mem_fx[0] );
+ y2_fx64 = W_deposit32_l( mem_fx[1] );
+ x0_fx64 = W_deposit32_l( mem_fx[2] );
+ x1_fx64 = W_deposit32_l( mem_fx[3] );
+
+ FOR( i = 0; i < lg; i++ )
+ {
+ x2_fx64 = x1_fx64;
+ move64();
+ x1_fx64 = x0_fx64;
+ move64();
+ x0_fx64 = W_deposit32_l( signal_fx[i] );
+
+ Qy1 = W_norm( y1_fx64 );
+ if ( y1_fx64 == 0 )
+ {
+ Qy1 = 62;
+ move16();
+ }
+ Qy1 = sub( Qy1, 34 );
+ R1 = W_mult0_32_32( W_extract_l( W_shl( y1_fx64, Qy1 ) ), a1_fx );
+ Qy1 = add( Qy1, Qprev_y1 );
+
+ Qy2 = W_norm( y2_fx64 );
+ if ( y2_fx64 == 0 )
+ {
+ Qy2 = 62;
+ move16();
+ }
+ Qy2 = sub( Qy2, 34 );
+ R2 = W_mult0_32_32( W_extract_l( W_shl( y2_fx64, Qy2 ) ), a2_fx );
+ Qy2 = add( Qy2, Qprev_y2 );
+
+ Qx0 = W_norm( x0_fx64 );
+ if ( x0_fx64 == 0 )
+ {
+ Qx0 = 62;
+ move16();
+ }
+ Qx0 = sub( Qx0, 34 );
+ R3 = W_mult0_32_32( W_extract_l( W_shl( x0_fx64, Qx0 ) ), b2_fx );
+
+ Qx1 = W_norm( x1_fx64 );
+ if ( x1_fx64 == 0 )
+ {
+ Qx1 = 62;
+ move16();
+ }
+ Qx1 = sub( Qx1, 34 );
+ R4 = W_mult0_32_32( W_extract_l( W_shl( x1_fx64, Qx1 ) ), b1_fx );
+
+ Qx2 = W_norm( x2_fx64 );
+ if ( x2_fx64 == 0 )
+ {
+ Qx2 = 62;
+ move16();
+ }
+ Qx2 = sub( Qx2, 34 );
+ R5 = W_mult0_32_32( W_extract_l( W_shl( x2_fx64, Qx2 ) ), b2_fx );
+
+ Qmin = s_min( Qy1, Qy2 );
+
+ y0_fx64 = W_add( W_shr( R1, sub( Qy1, Qmin ) ), W_shr( R2, sub( Qy2, Qmin ) ) );
+
+ Qmin = s_min( Qmin, Qx0 );
+ Qmin = s_min( Qmin, Qx1 );
+ Qmin = s_min( Qmin, Qx2 );
+
+ y0_fx64 = W_add( W_shr( y0_fx64, sub( s_min( Qy1, Qy2 ), Qmin ) ), W_add( W_shr( R3, sub( Qx0, Qmin ) ), W_add( W_shr( R4, sub( Qx1, Qmin ) ), W_shr( R5, sub( Qx2, Qmin ) ) ) ) );
+
+ y0_fx64 = W_shr( y0_fx64, 29 );
+
+ signal_fx[i] = W_extract_l( W_shr( y0_fx64, Qmin ) );
+ move32();
+ IF( signal_fx[i] < 0 )
+ {
+ signal_fx[i] = L_add( signal_fx[i], 1 );
+ move32();
+ }
+
+ y2_fx64 = y1_fx64;
+ y1_fx64 = y0_fx64;
+ Qprev_y2 = Qprev_y1;
+ Qprev_y1 = Qmin;
+ move64();
+ move64();
+ move16();
+ move16();
+ }
+
+ Qy1 = W_norm( y1_fx64 );
+ test();
+ IF( y1_fx64 != 0 && LT_16( Qy1, 32 ) )
+ {
+ y1_fx64 = W_shr( y1_fx64, sub( 32, Qy1 ) );
+ Qprev_y1 = sub( Qprev_y1, sub( 32, Qy1 ) );
+ }
+
+ Qy2 = W_norm( y2_fx64 );
+ test();
+ IF( y2_fx64 != 0 && LT_16( Qy2, 32 ) )
+ {
+ y2_fx64 = W_shr( y2_fx64, sub( 32, Qy2 ) );
+ Qprev_y2 = sub( Qprev_y2, sub( 32, Qy2 ) );
+ }
+
+ mem_fx[0] = W_extract_l( y1_fx64 );
+ mem_fx[1] = W_extract_l( y2_fx64 );
+ mem_fx[2] = W_extract_l( x0_fx64 );
+ mem_fx[3] = W_extract_l( x1_fx64 );
+ mem_fx[4] = Qprev_y1;
+ mem_fx[5] = Qprev_y2;
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+
+ return;
+}
+#endif
diff --git a/lib_com/hq2_bit_alloc.c b/lib_com/hq2_bit_alloc.c
index cd7f17aab8c611f11186312ce45654a53bb71d70..3653ffea8d4ed89b9e82e77f0cf31f5d5f9576f7 100644
--- a/lib_com/hq2_bit_alloc.c
+++ b/lib_com/hq2_bit_alloc.c
@@ -216,7 +216,7 @@ static void Bits2indvsb_fx(
th_5_fx = shl( 5, QRavg );
FOR( j = 0; j < be_cnt_fx; j++ )
{
- IF( sub( abs_s( sub( Ravg_fx, shl( y_index_fx[j], QRavg ) ) ), th_5_fx ) > 0 )
+ if ( sub( abs_s( sub( Ravg_fx, shl( y_index_fx[j], QRavg ) ) ), th_5_fx ) > 0 )
{
enr_diffcnt_fx = add( enr_diffcnt_fx, 1 );
}
@@ -461,10 +461,12 @@ void hq2_bit_alloc_har(
}
gmax_range_fx[i] = add( gmax_range_fx[i], temp_fx );
+ move16();
}
ELSE
{
gmax_range_fx[i] = add( gmax_range_fx[i], temp_fx );
+ move16();
}
}
@@ -477,7 +479,7 @@ void hq2_bit_alloc_har(
}
grp_bound_fx[i] = harmonic_band_fx;
move16();
- grp_bound_fx[i + 1] = N_fx;
+ grp_bound_fx[add( i, 1 )] = N_fx;
move16();
@@ -575,7 +577,7 @@ void hq2_bit_alloc_har(
FOR( i = 0; i < sub( N_fx, harmonic_band_fx ); i++ )
{
- y_index_fx[i] = extract_h( L_shl( L_temp_band_energy[harmonic_band_fx + i], sub( 16, SWB_BWE_LR_Qbe ) ) );
+ y_index_fx[i] = extract_h( L_shl( L_temp_band_energy[add( harmonic_band_fx, i )], sub( 16, SWB_BWE_LR_Qbe ) ) );
move16();
index_fx[i] = add( harmonic_band_fx, i );
move16();
@@ -643,6 +645,7 @@ void hq2_bit_alloc_har(
#ifdef BASOP_NOGLOB
lf_hf_ge_r_fx = round_fx_o( L_shl_o( L_temp, sub( 15 + 16, sub( add( SWB_BWE_LR_Qbe, QIns ), 30 ) ), &Overflow ), &Overflow );
Overflow = 0; /* reset BASOP Overflow */
+ move16();
#else
lf_hf_ge_r_fx = round_fx( L_shl( L_temp, sub( 15 + 16, sub( add( SWB_BWE_LR_Qbe, QIns ), 30 ) ) ) );
#endif
@@ -694,24 +697,30 @@ void hq2_bit_alloc_har(
L_temp = Mpy_32_16_1( L_Ravg_sub[1], extract_h( L_mult( bits_fact_fx, B_norm_fx ) ) );
L_temp = Mpy_32_16_1( L_temp, Inv_norm_sum_fx );
Bits_grp_fx[1] = extract_h( L_shr( L_temp, exp_shift ) );
+ move16();
L_temp = Mpy_32_16_1( L_Ravg_sub[2], extract_h( L_mult( bits_fact1_fx, B_norm_fx ) ) );
L_temp = Mpy_32_16_1( L_temp, Inv_norm_sum_fx );
Bits_grp_fx[2] = extract_h( L_shr( L_temp, exp_shift ) );
+ move16();
Bits_grp_fx[0] = sub( sub( B_fx, Bits_grp_fx[1] ), Bits_grp_fx[2] );
+ move16();
}
ELSE
{
L_temp = Mpy_32_16_1( L_Ravg_sub[0], extract_h( L_mult( bits_fact_fx, B_norm_fx ) ) );
L_temp = Mpy_32_16_1( L_temp, Inv_norm_sum_fx );
Bits_grp_fx[0] = extract_h( L_shr( L_temp, exp_shift ) );
+ move16();
L_temp = Mpy_32_16_1( L_Ravg_sub[2], extract_h( L_mult( bits_fact1_fx, B_norm_fx ) ) );
L_temp = Mpy_32_16_1( L_temp, Inv_norm_sum_fx );
Bits_grp_fx[2] = extract_h( L_shr( L_temp, exp_shift ) );
+ move16();
Bits_grp_fx[1] = sub( sub( B_fx, Bits_grp_fx[0] ), Bits_grp_fx[2] );
+ move16();
}
IF( sub( Bits_grp_fx[2], THR2 ) < 0 )
@@ -823,6 +832,7 @@ void hq2_bit_alloc(
FOR( k = 0; k < bands; k++ )
{
L_Rk[k] = L_shl( L_deposit_l( p2a_flags[k] ), SWB_BWE_LR_QRk );
+ move32();
}
}
diff --git a/lib_com/hq2_bit_alloc_fx.c b/lib_com/hq2_bit_alloc_fx.c
index eb3342b299ecc2fe12aa0cab0027fc5724467a39..486de81de13abff40fb0e1fd33da87d016e59e0c 100644
--- a/lib_com/hq2_bit_alloc_fx.c
+++ b/lib_com/hq2_bit_alloc_fx.c
@@ -32,7 +32,7 @@
#include
#include "options.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#define MIN_BITS_FIX 0 /* QRk=18 */
@@ -100,6 +100,7 @@ void Bits2indvsb_fx(
FOR( i = 0; i < band_num_fx; i++ )
{
y_index_fx[i] = extract_h( L_shr( L_y_ptr[i], sub( SWB_BWE_LR_Qbe, 16 ) ) );
+ move16();
index_fx[i] = i;
move16();
}
@@ -120,6 +121,7 @@ void Bits2indvsb_fx(
y_index_fx[j] = 0;
move16();
L_R_temp[j] = L_deposit_l( 0 );
+ move32();
}
ELSE
{
@@ -310,6 +312,12 @@ void hq2_bit_alloc_har_fx(
Word16 exp_shift;
+#ifdef BASOP_NOGLOB
+ Flag Overflow;
+ Overflow = 0;
+ move32();
+#endif
+
L_THR1 = L_shl( L_deposit_l( THR1 ), SWB_BWE_LR_QRk );
L_THR2 = L_shl( L_deposit_l( THR2 ), SWB_BWE_LR_QRk );
L_THR3 = L_shl( L_deposit_l( THR3 ), SWB_BWE_LR_QRk );
@@ -370,14 +378,13 @@ void hq2_bit_alloc_har_fx(
{
FOR( temp_fx = 2; temp_fx <= k_fx; )
{
- IF( LT_32( L_temp_band_energy[gmax_range_fx[i] + temp_fx - 1], L_temp_band_energy[gmax_range_fx[i] + temp_fx] ) )
+ IF( LT_32( L_temp_band_energy[sub( add( gmax_range_fx[i], temp_fx ), 1 )], L_temp_band_energy[add( gmax_range_fx[i], temp_fx )] ) )
{
BREAK;
}
- ELSE IF( GE_32( L_temp_band_energy[gmax_range_fx[i] + temp_fx - 1], L_temp_band_energy[gmax_range_fx[i] + temp_fx] ) )
+ ELSE IF( GE_32( L_temp_band_energy[sub( add( gmax_range_fx[i], temp_fx ), 1 )], L_temp_band_energy[add( gmax_range_fx[i], temp_fx )] ) )
{
temp_fx = add( temp_fx, 1 );
- ;
IF( GT_16( temp_fx, k_fx ) )
{
temp_fx = sub( temp_fx, 1 );
@@ -405,7 +412,7 @@ void hq2_bit_alloc_har_fx(
}
grp_bound_fx[i] = harmonic_band_fx;
move16();
- grp_bound_fx[i + 1] = N_fx;
+ grp_bound_fx[add( i, 1 )] = N_fx;
move16();
@@ -441,6 +448,7 @@ void hq2_bit_alloc_har_fx(
G1_BE_DIFF_POS_fx = j;
move16();
L_G1_BE_DIFF_VAL = L_temp_band_energydiff[j];
+ move32();
}
}
@@ -502,6 +510,7 @@ void hq2_bit_alloc_har_fx(
FOR( i = 0; i < j; i++ )
{
y_index_fx[i] = extract_h( L_shl( L_temp_band_energy[harmonic_band_fx + i], sub( 16, SWB_BWE_LR_Qbe ) ) );
+ move16();
index_fx[i] = add( harmonic_band_fx, i );
move16();
}
@@ -563,7 +572,13 @@ void hq2_bit_alloc_har_fx(
L_temp = Mult_32_16( L_Ravg_sub[GRP_SB - 1], sub( GRP_SB, 1 ) ); /* Qbe+0+1 */
L_temp = Mult_32_16( L_temp, Inv_norm_sum_fx ); /* Qbe+1+QIpb+1 */
+#ifdef BASOP_NOGLOB
+ lf_hf_ge_r_fx = round_fx_o( L_shl_o( L_temp, sub( 15 + 16, sub( add( SWB_BWE_LR_Qbe, QIns ), 30 ) ), &Overflow ), &Overflow );
+ Overflow = 0; /* reset BASOP Overflow */
+ move32();
+#else
lf_hf_ge_r_fx = round_fx( L_shl( L_temp, sub( 15 + 16, sub( add( SWB_BWE_LR_Qbe, QIns ), 30 ) ) ) );
+#endif
exp_normn = norm_s( norm_sum_fx );
exp_normn = sub( exp_normn, 1 );
@@ -592,6 +607,7 @@ void hq2_bit_alloc_har_fx(
L_temp = L_add( L_shl( L_temp, SWB_BWE_LR_Qbe ), L_temp2 );
Bits_grp_fx[GRP_SB - 1] = extract_h( L_shl( L_temp, sub( 16, SWB_BWE_LR_Qbe ) ) );
+ move16();
Bits_grp_fx[GRP_SB - 1] = s_min( Bits_grp_fx[GRP_SB - 1], 10 );
move16();
@@ -613,10 +629,12 @@ void hq2_bit_alloc_har_fx(
L_temp = Mult_32_16( L_Ravg_sub[1], extract_h( L_mult( bits_fact_fx, B_norm_fx ) ) );
L_temp = Mult_32_16( L_temp, Inv_norm_sum_fx );
Bits_grp_fx[1] = extract_h( L_shr( L_temp, exp_shift ) );
+ move16();
L_temp = Mult_32_16( L_Ravg_sub[2], extract_h( L_mult( bits_fact1_fx, B_norm_fx ) ) );
L_temp = Mult_32_16( L_temp, Inv_norm_sum_fx );
Bits_grp_fx[2] = extract_h( L_shr( L_temp, exp_shift ) );
+ move16();
Bits_grp_fx[0] = sub( sub( B_fx, Bits_grp_fx[1] ), Bits_grp_fx[2] );
move16();
@@ -626,10 +644,12 @@ void hq2_bit_alloc_har_fx(
L_temp = Mult_32_16( L_Ravg_sub[0], extract_h( L_mult( bits_fact_fx, B_norm_fx ) ) );
L_temp = Mult_32_16( L_temp, Inv_norm_sum_fx );
Bits_grp_fx[0] = extract_h( L_shr( L_temp, exp_shift ) );
+ move16();
L_temp = Mult_32_16( L_Ravg_sub[2], extract_h( L_mult( bits_fact1_fx, B_norm_fx ) ) );
L_temp = Mult_32_16( L_temp, Inv_norm_sum_fx );
Bits_grp_fx[2] = extract_h( L_shr( L_temp, exp_shift ) );
+ move16();
Bits_grp_fx[1] = sub( sub( B_fx, Bits_grp_fx[0] ), Bits_grp_fx[2] );
move16();
@@ -721,13 +741,21 @@ Word32 hq2_bit_alloc_fx(
IF( is_transient && EQ_16( bands, 32 ) )
{
L_Rk[6] = L_deposit_l( 0 );
+ move32();
L_Rk[7] = L_deposit_l( 0 );
+ move32();
L_Rk[14] = L_deposit_l( 0 );
+ move32();
L_Rk[15] = L_deposit_l( 0 );
+ move32();
L_Rk[22] = L_deposit_l( 0 );
+ move32();
L_Rk[23] = L_deposit_l( 0 );
+ move32();
L_Rk[30] = L_deposit_l( 0 );
+ move32();
L_Rk[31] = L_deposit_l( 0 );
+ move32();
}
}
ELSE
@@ -736,6 +764,7 @@ Word32 hq2_bit_alloc_fx(
FOR( k = 0; k < bands; k++ )
{
L_Rk[k] = L_shl( L_deposit_l( p2a_flags[k] ), SWB_BWE_LR_QRk );
+ move32();
}
}
@@ -814,6 +843,7 @@ Word32 hq2_bit_alloc_fx(
IF( LT_32( L_Rk[k], MIN_BITS_FIX ) )
{
L_Rk[k] = L_deposit_l( 0 );
+ move32();
negflag = 1;
move16();
}
@@ -846,9 +876,10 @@ Word32 hq2_bit_alloc_fx(
}
/* prune worst allocation and recalculate total allocation */
- if ( GT_16( maxdex_fx, -1 ) )
+ IF( GT_16( maxdex_fx, -1 ) )
{
L_Rk[maxdex_fx] = L_deposit_l( 0 );
+ move32();
}
FOR( k = 0; k < bands; k++ )
{
@@ -875,14 +906,17 @@ Word32 hq2_bit_alloc_fx(
IF( LT_16( k, 11 ) && LT_32( L_Rk[k], L_THR1 ) )
{
L_Rk[k] = L_deposit_l( 0 );
+ move32();
}
ELSE IF( GE_16( k, 11 ) && LT_16( k, 16 ) && LT_32( L_Rk[k], L_THR2 ) )
{
L_Rk[k] = L_deposit_l( 0 );
+ move32();
}
ELSE if ( GE_16( k, 16 ) && LT_16( k, bands ) && LT_32( L_Rk[k], L_THR3 ) )
{
L_Rk[k] = L_deposit_l( 0 );
+ move32();
}
L_dummy = L_add( L_dummy, L_Rk[k] );
@@ -898,9 +932,9 @@ Word32 hq2_bit_alloc_fx(
FOR( k = 0; k < NB_SWB_SUBBANDS; k++ )
{
test();
- IF( p2a_flags[bands - NB_SWB_SUBBANDS + k] == 1 && L_Rk[bands - NB_SWB_SUBBANDS + k] == 0 )
+ IF( EQ_16( p2a_flags[add( sub( bands, NB_SWB_SUBBANDS ), k )], 1 ) && L_Rk[add( sub( bands, NB_SWB_SUBBANDS ), k )] == 0 )
{
- p2a_flags[bands - NB_SWB_SUBBANDS + k] = 0;
+ p2a_flags[add( sub( bands, NB_SWB_SUBBANDS ), k )] = 0;
move16();
bit_budget_temp_fx = sub( bit_budget_temp_fx, bits_lagIndices_modeNormal[k] );
}
diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c
index c649e8d178602f3dd18f53614caa2f038e66319e..206a37bc84924d96ff41c9e14031da2686bf6314 100644
--- a/lib_com/hq2_core_com_fx.c
+++ b/lib_com/hq2_core_com_fx.c
@@ -35,7 +35,7 @@
#include "options.h"
#include "cnst.h" /* Audio core constants */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*--------------------------------------------------------------------------*
@@ -91,9 +91,11 @@ void mdct_spectrum_denorm_fx(
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move16(); /* allow overflow happen. */
#endif
exp_safe = 4; /* safe bit for overflow */
+ move16();
FOR( k = 0; k < bands; k++ )
{
@@ -407,7 +409,9 @@ IF( is_transient )
bands_sh = *bands;
move16();
*bands = shl( bands_sh, 2 );
+ move16();
*length = shl( *length, 2 );
+ move16();
FOR( i = 1; i <= 3; i++ )
{
@@ -523,6 +527,7 @@ void spt_shorten_domain_pre_fx(
}
kpos = 0;
+ move16();
j = 0;
move16();
FOR( k = sub( BANDS, SPT_SHORTEN_SBNUM ); k < BANDS; k++ )
@@ -702,9 +707,13 @@ void bit_allocation_second_fx(
const Word16 input_frame )
{
Word16 k, k2 = 0;
+ move16();
Word16 ever_bits[BANDS_MAX], ever_sort[BANDS_MAX]; /*Q12 */
Word16 class_flag = 0;
+ move16();
Word16 rk_temp = 32767, ever_temp = 32767; /*Q12 */
+ move16();
+ move16();
Word16 exp;
Word16 tmp;
Word32 L_tmp;
diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c
index 9f787fde5ed12ff334ef671262fdd086298475cb..c7326bd8e6b89b48cd25cae686d473677ceedc28 100644
--- a/lib_com/hq2_noise_inject_fx.c
+++ b/lib_com/hq2_noise_inject_fx.c
@@ -32,7 +32,7 @@
#include
#include "options.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "oper_32b.h"
#include "move.h"
#include "count.h"
@@ -82,6 +82,7 @@ void hq2_noise_inject_fx(
Word16 sb = bands;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move16();
#endif
satur = 0;
@@ -194,6 +195,7 @@ void hq2_noise_inject_fx(
}
max_pos_pulse = k;
+ move16();
L_tmp2 = Ep_fx[k];
move32();
L_tmp = L_max( 1, L_tmp2 );
diff --git a/lib_com/hq_bit_allocation_fx.c b/lib_com/hq_bit_allocation_fx.c
index 2b798c962f5f403bb6f824419fcc4ff676e2f854..4ac2252f840d40a1b38e68171127c7698e8d20aa 100644
--- a/lib_com/hq_bit_allocation_fx.c
+++ b/lib_com/hq_bit_allocation_fx.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
-#include "options.h" /* Compilation switches */
-#include "stl.h" /* required for wmc_tool */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "cnst.h" /* Common constants */
+#include "options.h" /* Compilation switches */
+#include "stl.h" /* required for wmc_tool */
+#include "prot_fx.h" /* Function prototypes */
+#include "cnst.h" /* Common constants */
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
@@ -61,6 +60,7 @@ void ivas_hq_bit_allocation_fx(
{
/* 'nf_idx' 2-bits index written later */
*num_bits = sub( *num_bits, 2 );
+ move16();
}
test();
@@ -74,10 +74,12 @@ void ivas_hq_bit_allocation_fx(
{
*num_bits = sub( *num_bits, HQ_GENERIC_SWB_NBITS );
}
+ move16();
IF( EQ_16( length, L_SPEC48k ) )
{
*num_bits = sub( *num_bits, HQ_GENERIC_FB_NBITS );
+ move16();
}
}
@@ -103,6 +105,7 @@ void ivas_hq_bit_allocation_fx(
{
/* classification and limit bandwidth for bit allocation */
sfm_limit = sub( sfm_limit, 2 );
+ move16();
limit_band_noise_level_calc_fx( wnorm, &sfm_limit, core_brate, noise_level );
/* Detect important band in high frequency region */
@@ -150,6 +153,7 @@ void ivas_hq_bit_allocation_fx(
ELSE IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || ( EQ_16( hqswb_clas, HQ_TRANSIENT ) && EQ_16( length, L_FRAME32k ) && LE_32( core_brate, HQ_32k ) ) )
{
*sum = BitAllocF_fx( wnorm, core_brate, *num_bits, nb_sfm, R, Rsubband, hqswb_clas, num_env_bands );
+ move16();
}
ELSE IF( EQ_16( length, L_FRAME16k ) && LE_32( core_brate, HQ_32k ) )
{
@@ -172,6 +176,7 @@ void ivas_hq_bit_allocation_fx(
/* Estimate number of bits per band */
*sum = BitAllocWB_fx( wnorm, *num_bits, nb_sfm, R, Rsubband );
+ move16();
}
ELSE
{
@@ -201,22 +206,27 @@ ELSE
/* Find last coded core band */
*core_sfm = sub( nb_sfm, 1 );
+move16();
test();
test();
IF( hqswb_clas == HQ_NORMAL || EQ_16( hqswb_clas, HQ_HARMONIC ) )
{
*core_sfm = find_last_band_fx( R, nb_sfm );
+ move16();
}
ELSE IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) )
{
*core_sfm = find_last_band_fx( R, nb_sfm );
+ move16();
IF( LT_16( *core_sfm, num_env_bands ) )
{
*core_sfm = sub( num_env_bands, 1 );
+ move16();
}
}
*num_bits = sub( *num_bits, *sum );
+move16();
return;
}
@@ -352,6 +362,7 @@ void hq_bit_allocation_fx(
ELSE IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || ( EQ_16( hqswb_clas, HQ_TRANSIENT ) && EQ_16( length, L_FRAME32k ) && LE_32( core_brate, HQ_32k ) ) )
{
*sum = BitAllocF_fx( wnorm, core_brate, *num_bits, nb_sfm, R, Rsubband, hqswb_clas, num_env_bands );
+ move16();
}
ELSE IF( EQ_16( length, L_FRAME16k ) && EQ_32( core_brate, HQ_32k ) )
{
@@ -376,6 +387,7 @@ void hq_bit_allocation_fx(
/* Estimate number of bits per band */
*sum = BitAllocWB_fx( wnorm, *num_bits, nb_sfm, R, Rsubband );
+ move16();
}
ELSE
{
@@ -405,22 +417,27 @@ void hq_bit_allocation_fx(
/* Find last coded core band */
*core_sfm = sub( nb_sfm, 1 );
+ move16();
test();
test();
IF( hqswb_clas == HQ_NORMAL || EQ_16( hqswb_clas, HQ_HARMONIC ) )
{
*core_sfm = find_last_band_fx( R, nb_sfm );
+ move16();
}
ELSE IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) )
{
*core_sfm = find_last_band_fx( R, nb_sfm );
+ move16();
IF( LT_16( *core_sfm, num_env_bands ) )
{
*core_sfm = sub( num_env_bands, 1 );
+ move16();
}
}
*num_bits = sub( *num_bits, *sum );
+ move16();
return;
}
diff --git a/lib_com/hq_conf.c b/lib_com/hq_conf.c
index c027eb7002df9fbfae10c0a9fe71ca6d7bf1edfb..d96448b02f216491c3fce4087f508b2b84de9d75 100644
--- a/lib_com/hq_conf.c
+++ b/lib_com/hq_conf.c
@@ -40,8 +40,7 @@
#include "rom_com.h"
#include "prot.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*--------------------------------------------------------------------------*
* hq_configure()
@@ -277,6 +276,7 @@ void hq_configure_fx(
Word16 i, bw_ext;
bw_ext = 0;
+ move16();
*start_norm = 0;
move16();
@@ -521,10 +521,13 @@ void hq_configure_fx(
{
/*sfmsize[i] = (int16_t)(1.25f * p_sfmsize[i]);*/
sfmsize[i] = mult_r( shl( p_sfmsize[i], 1 ), 20480 );
+ move16();
/*sfm_start[i] = (int16_t)(1.25f * p_sfm_start[i]);*/
sfm_start[i] = mult_r( shl( p_sfm_start[i], 1 ), 20480 );
+ move16();
/*sfm_end[i] = (int16_t)(1.25f * p_sfm_end[i]);*/
sfm_end[i] = mult_r( shl( p_sfm_end[i], 1 ), 20480 );
+ move16();
}
*nb_sfm = *num_sfm;
*num_env_bands = *num_sfm;
@@ -539,6 +542,7 @@ void hq_configure_fx(
}
*numnrmibits = extract_l( L_mult0( sub( *num_env_bands, 1 ), NORMI_BITS ) );
+ move16();
return;
}
diff --git a/lib_com/hq_conf_fx.c b/lib_com/hq_conf_fx.c
index 4596658823c518a01393528729868399db802fdb..eb675986b941327f64030740700e97dcf40ef763 100644
--- a/lib_com/hq_conf_fx.c
+++ b/lib_com/hq_conf_fx.c
@@ -4,10 +4,9 @@
#include
#include "options.h"
-#include "cnst.h" /* Audio core constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "cnst.h" /* Audio core constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
@@ -285,10 +284,13 @@ void ivas_hq_configure_fx(
{
/*sfmsize[i] = (int16_t)(1.25f * p_sfmsize[i]);*/
sfmsize[i] = mult_r( shl( p_sfmsize[i], 1 ), 20480 );
+ move16();
/*sfm_start[i] = (int16_t)(1.25f * p_sfm_start[i]);*/
sfm_start[i] = mult_r( shl( p_sfm_start[i], 1 ), 20480 );
+ move16();
/*sfm_end[i] = (int16_t)(1.25f * p_sfm_end[i]);*/
sfm_end[i] = mult_r( shl( p_sfm_end[i], 1 ), 20480 );
+ move16();
}
*nb_sfm = *num_sfm;
*num_env_bands = *num_sfm;
@@ -303,6 +305,7 @@ void ivas_hq_configure_fx(
}
*numnrmibits = extract_l( L_mult0( sub( *num_env_bands, 1 ), NORMI_BITS ) );
+ move16();
return;
}
@@ -577,10 +580,13 @@ void hq_configure_evs_fx(
{
/*sfmsize[i] = (int16_t)(1.25f * p_sfmsize[i]);*/
sfmsize[i] = mult_r( shl( p_sfmsize[i], 1 ), 20480 );
+ move16();
/*sfm_start[i] = (int16_t)(1.25f * p_sfm_start[i]);*/
sfm_start[i] = mult_r( shl( p_sfm_start[i], 1 ), 20480 );
+ move16();
/*sfm_end[i] = (int16_t)(1.25f * p_sfm_end[i]);*/
sfm_end[i] = mult_r( shl( p_sfm_end[i], 1 ), 20480 );
+ move16();
}
*nb_sfm = *num_sfm;
*num_env_bands = *num_sfm;
@@ -595,6 +601,7 @@ void hq_configure_evs_fx(
}
*numnrmibits = extract_l( L_mult0( sub( *num_env_bands, 1 ), NORMI_BITS ) );
+ move16();
return;
}
diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c
index 7e6ab6dfb47e79fb33189c21a87b11dfd4a27b01..ddc12e4eb59dfdcd0f83723449413ad6f754fb7d 100644
--- a/lib_com/hq_tools_fx.c
+++ b/lib_com/hq_tools_fx.c
@@ -38,7 +38,7 @@
#include "options.h" /* Compilation switches */
#include "rom_com.h" /* Static table prototypes FIP version */
#include "stl.h" /* required for wmc_tool */
-#include "prot_fx2.h"
+#include "prot_fx.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
@@ -125,6 +125,7 @@ void hq_swb_harmonic_calc_norm_envelop_fx(
/* Apply MA filter */
L_envelope[env_index] = L_deposit_l( EPSILLON_FX );
+ move32();
FOR( n_lag = 0; n_lag < n_lag_now; n_lag++ )
{
L_tmp = L_abs( L_SWB_signal[add( n_freq, n_lag )] );
@@ -469,6 +470,7 @@ void apply_noisefill_HQ_fx(
{
/*coeff[j] = cb_buff[j - istart] * E_corr; */
coeff[j] = extract_h( L_shl( L_mult( cb_buff[j - istart], E_corr ), 2 ) ); /*Q12 (12+13+1+2-16) */
+ move16();
}
}
ELSE
@@ -542,6 +544,7 @@ void harm_bwe_fine_fx(
FOR( i = sfm_start[sfm]; i < sfm_end[sfm]; i++ )
{
coeff_out[i] = L_deposit_l( 0 );
+ move16();
}
}
}
@@ -765,6 +768,7 @@ void hq_fold_bwe_fx(
src = coeff + sfm_end[last_sfm] - 1;
first_coeff = sfm_end[last_sfm];
+ move16();
dst = coeff + sfm_end[last_sfm];
end = coeff + sfm_end[num_sfm - 1];
@@ -851,6 +855,7 @@ void ivas_harm_bwe_fx(
Word32 normq, L_tmp, L_tmp2;
Word32 E_L;
Word16 alfa = 16384;
+ move16();
Word16 tmp, tmp1, exp1;
Word16 beta;
Word32 *src, *dst;
@@ -1035,6 +1040,7 @@ void harm_bwe_fx(
Word32 normq, L_tmp, L_tmp2;
Word32 E_L;
Word16 alfa = 16384;
+ move16();
Word16 tmp, tmp1, exp1;
Word16 beta;
Word32 *src, *dst;
@@ -1061,9 +1067,11 @@ void harm_bwe_fx(
/* shaping the BWE spectrum further by envelopes and noise factors */
L_tmp = L_mult( 29491, prev_noise_level[0] ); /* 15 +1 +15 */
noise_level[0] = round_fx( L_mac( L_tmp, 3277, noise_level[0] ) ); /*15 */
+ move16();
L_tmp = L_mult( 29491, prev_noise_level[1] );
noise_level[1] = round_fx( L_mac( L_tmp, 3277, noise_level[1] ) );
+ move16();
test();
IF( prev_hq_mode == HQ_NORMAL || EQ_16( prev_hq_mode, HQ_GEN_SWB ) )
@@ -1221,7 +1229,9 @@ void hvq_bwe_fx(
Word32 L_normq;
Word32 L_E;
Word32 L_tmp_norm = 0;
+ move32();
Word16 bwe_noise_th = 0;
+ move16();
Word16 peak_band, low, high, sel_norm;
Word16 norm_ind;
Word32 *L_src, *L_dst;
@@ -1248,6 +1258,8 @@ void hvq_bwe_fx(
/* shaping the BWE spectrum further by envelopes and noise factors */
noise_level[0] = round_fx( L_mac( L_mult( 29491, prev_noise_level[0] ), 3277, noise_level[0] ) ); /* Q15 (15+15+1-16) */
noise_level[1] = round_fx( L_mac( L_mult( 29491, prev_noise_level[1] ), 3277, noise_level[1] ) ); /* Q15 (15+15+1-16) */
+ move16();
+ move16();
test();
IF( prev_hq_mode == HQ_NORMAL || EQ_16( prev_hq_mode, HQ_GEN_SWB ) )
@@ -2116,7 +2128,9 @@ void hq_wb_nf_bwe_fx(
}
/* calculate the peak-average ratio of saturable subbands */
num = 0;
+ move16();
sharp_fx = 0;
+ move16();
FOR( sfm = last_sfm; sfm >= 8; sfm-- )
{
tmp = shl( sfmsize[sfm], 9 ); /*Q9 */
@@ -2491,6 +2505,7 @@ void hq_wb_nf_bwe_fx(
Copy32( L_normq_v, prev_normq_fx, SFM_N_WB );
Copy32( L_coeff_out + L_FRAME16k - L_HQ_WB_BWE, prev_coeff_out_fx, L_HQ_WB_BWE );
*prev_R = R[SFM_N_WB - 1];
+ move16();
return;
}
@@ -2520,6 +2535,7 @@ void enforce_zero_for_min_envelope_fx(
FOR( j = sfm_start[0]; j < sfm_end[0]; j++ )
{
L_coefsq[j] = L_deposit_l( 0 );
+ move32();
}
}
@@ -2530,6 +2546,7 @@ void enforce_zero_for_min_envelope_fx(
FOR( j = sfm_start[i]; j < sfm_end[i]; j++ )
{
L_coefsq[j] = L_deposit_l( 0 );
+ move32();
}
}
}
diff --git a/lib_com/hvq_pvq_bitalloc_fx.c b/lib_com/hvq_pvq_bitalloc_fx.c
index 43e014ce916d44c3dcc6c761383e3205cf6ee7e9..4775f1b7822e808553fe60c62d10bf39ec7a6315 100644
--- a/lib_com/hvq_pvq_bitalloc_fx.c
+++ b/lib_com/hvq_pvq_bitalloc_fx.c
@@ -5,9 +5,8 @@
#include "options.h" /* Compilation switches */
#include "rom_com.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "cnst.h" /* Common constants */
/*--------------------------------------------------------------------------*/
/* Function hvq_pvq_bitalloc */
@@ -50,6 +49,7 @@ Word16 hvq_pvq_bitalloc_fx(
{
num_sfm = SFM_N_HARM;
}
+ move16();
IF( LT_32( core_brate, HQ_BWE_CROSSOVER_BRATE ) )
{
@@ -159,6 +159,7 @@ Word16 hvq_pvq_bitalloc_fx(
IF( EQ_16( band_len_harm[k_max], 96 ) )
{
n = 61;
+ move16();
}
ELSE
{
@@ -172,6 +173,7 @@ Word16 hvq_pvq_bitalloc_fx(
sel_bands[*n_sel_bands] = k_max;
move16();
*n_sel_bands = add( *n_sel_bands, 1 );
+ move16();
R[k_max] = 1; /* Mark that the band has been encoded for fill_spectrum */
move16();
}
diff --git a/lib_com/ifft_rel.c b/lib_com/ifft_rel.c
index ff67fd3e4e414db73a17c84e42eb00750320f81e..43aa3f122860712ab0f33bb466f36ad5bbd2c492 100644
--- a/lib_com/ifft_rel.c
+++ b/lib_com/ifft_rel.c
@@ -39,8 +39,7 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-----------------------------------------------------------------*
* Local constants
*-----------------------------------------------------------------*/
@@ -309,6 +308,7 @@ void ifft_rel_fx(
Word16 tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move16();
#endif
@@ -1034,6 +1034,7 @@ void ifft_rel_fx32(
const Word16 *idx;
Word32 temp[512];
Word16 n_inv = 128;
+ move16();
SWITCH( n )
{
@@ -1050,6 +1051,7 @@ void ifft_rel_fx32(
assert( 0 );
BREAK;
}
+ move16();
/*-----------------------------------------------------------------*
* IFFT
@@ -1060,11 +1062,13 @@ void ifft_rel_fx32(
FOR( k = 1; k < m; k++ )
{
is = 0;
+ move16();
id = n2;
+ move16();
n2 = shr( n2, 1 );
n4 = shr( n2, 2 );
n8 = shr( n4, 1 );
- WHILE( LT_16( is, n - 1 ) )
+ WHILE( LT_16( is, sub( n, 1 ) ) )
{
xi1 = x + is + 1;
xi2 = xi1 + n4;
@@ -1075,32 +1079,42 @@ void ifft_rel_fx32(
{
t1 = L_sub( *xi1, *xi3 );
*xi1 = L_add( *xi1, *xi3 );
+ move32();
*xi2 = L_shl( *xi2, 1 );
+ move32();
*xi3 = L_sub( t1, L_shl( *xi4, 1 ) );
+ move32();
*xi4 = L_add( t1, L_shl( *xi4, 1 ) );
- IF( n4 != 1 )
+ move32();
+ IF( NE_16( n4, 1 ) )
{
t1 = Mpy_32_16_1( L_sub( *( xi2 + n8 ), *( xi1 + n8 ) ), INV_SQRT_2_16 );
t2 = Mpy_32_16_1( L_add( *( xi4 + n8 ), *( xi3 + n8 ) ), INV_SQRT_2_16 );
*( xi1 + n8 ) = L_add( *( xi1 + n8 ), *( xi2 + n8 ) );
+ move32();
*( xi2 + n8 ) = L_sub( *( xi4 + n8 ), *( xi3 + n8 ) );
+ move32();
*( xi3 + n8 ) = L_shl( L_negate( L_add( t2, t1 ) ), 1 );
+ move32();
*( xi4 + n8 ) = L_shl( L_sub( t1, t2 ), 1 );
+ move32();
}
xi1 += id;
xi2 += id;
xi3 += id;
xi4 += id;
}
- is = 2 * id - n2;
- id = 4 * id;
+ is = sub( shl( id, 1 ), n2 );
+ id = shl( id, 2 );
}
+ /*Can be acheived with a shr */
step = N_MAX_FFT / n2;
+ move16();
s = sincos_t_ext_fx + step;
c = s + N_MAX_FFT / 4;
- s3 = sincos_t_ext_fx + 3 * step;
+ s3 = sincos_t_ext_fx + imult1616( 3, step );
c3 = s3 + N_MAX_FFT / 4;
FOR( j = 2; j <= n8; j++ )
{
@@ -1110,51 +1124,61 @@ void ifft_rel_fx32(
ss3 = *s3;
is = 0;
- id = 2 * n2;
+ move16();
+ id = shl( n2, 1 );
+ move16();
c += step;
s += step;
- c3 += 3 * step;
- s3 += 3 * step;
- WHILE( LT_16( is, n - 1 ) )
+ c3 += imult1616( 3, step );
+ s3 += imult1616( 3, step );
+ WHILE( LT_16( is, sub( n, 1 ) ) )
{
- xup1 = x + j + is;
- xup3 = xup1 + 2 * n4;
- xdn6 = xup3 - 2 * j + 2;
- xdn8 = xdn6 + 2 * n4;
+ xup1 = x + add( j, is );
+ xup3 = xup1 + shl( n4, 1 );
+ xdn6 = xup3 - sub( shl( j, 1 ), 2 );
+ xdn8 = xdn6 + shl( n4, 1 );
FOR( i = is; i < n; i += id )
{
t1 = L_sub( *xup1, *xdn6 );
*xup1 = L_add( *xup1, *xdn6 );
+ move32();
xup1 += n4;
xdn6 -= n4;
t2 = L_sub( *xdn6, *xup1 );
*xdn6 = L_add( *xup1, *xdn6 );
+ move32();
xdn6 += n4;
t3 = L_add( *xdn8, *xup3 );
*xdn6 = L_sub( *xdn8, *xup3 );
+ move32();
xup3 += n4;
xdn8 -= n4;
t4 = L_add( *xup3, *xdn8 );
*xup1 = L_sub( *xup3, *xdn8 );
+ move32();
t5 = L_sub( t1, t4 );
t1 = L_add( t1, t4 );
t4 = L_sub( t2, t3 );
t2 = L_add( t2, t3 );
*xup3 = L_sub( Mpy_32_16_1( t1, cc3 ), Mpy_32_16_1( t2, ss3 ) );
+ move32();
xup3 -= n4;
*xup3 = L_add( Mpy_32_16_1( t5, cc1 ), Mpy_32_16_1( t4, ss1 ) );
+ move32();
*xdn8 = L_sub( Mpy_32_16_1( t5, ss1 ), Mpy_32_16_1( t4, cc1 ) );
+ move32();
xdn8 += n4;
*xdn8 = L_add( Mpy_32_16_1( t2, cc3 ), Mpy_32_16_1( t1, ss3 ) );
+ move32();
xup1 -= n4;
xup1 += id;
@@ -1162,7 +1186,7 @@ void ifft_rel_fx32(
xdn6 += id;
xdn8 += id;
}
- is = shl( id, 1 ) - n2;
+ is = sub( shl( id, 1 ), n2 );
id = shl( id, 2 );
}
}
@@ -1173,7 +1197,9 @@ void ifft_rel_fx32(
*-----------------------------------------------------------------*/
is = 1;
+ move16();
id = 4;
+ move16();
WHILE( LT_16( is, n ) )
{
xi0 = x + is;
@@ -1182,12 +1208,15 @@ void ifft_rel_fx32(
FOR( i0 = is; i0 <= n; i0 += id )
{
r1 = *xi0;
+ move32();
*xi0 = L_add( r1, *xi1 );
+ move32();
*xi1 = L_sub( r1, *xi1 );
+ move32();
xi0 += id;
xi1 += id;
}
- is = shl( id, 1 ) - 1;
+ is = sub( shl( id, 1 ), 1 );
id = shl( id, 2 );
}
@@ -1203,6 +1232,7 @@ void ifft_rel_fx32(
{
j = *idx++;
temp[i] = x[1 + shr( j, 1 )];
+ move32();
}
}
ELSE IF( EQ_16( n, 256 ) )
@@ -1211,6 +1241,7 @@ void ifft_rel_fx32(
{
j = *idx++;
temp[i] = x[1 + j];
+ move32();
}
}
ELSE IF( EQ_16( n, 512 ) )
@@ -1219,7 +1250,9 @@ void ifft_rel_fx32(
{
j = *idx++;
temp[i] = x[1 + 2 * j];
+ move32();
temp[i + 256] = x[2 + 2 * j];
+ move32();
}
}
ELSE
@@ -1233,6 +1266,9 @@ void ifft_rel_fx32(
xt = x[j];
x[j] = x[i];
x[i] = xt;
+ move32();
+ move32();
+ move32();
}
k = shr( n, 1 );
WHILE( LT_16( k, j ) )
@@ -1251,6 +1287,7 @@ void ifft_rel_fx32(
FOR( i = 1; i <= n; i++ )
{
x[i] = Mpy_32_16_1( xi0[i], n_inv );
+ move32();
}
return;
diff --git a/lib_com/igf_base.c b/lib_com/igf_base.c
index 658707947596e3ea302bdc14adcb938822c7d3dd..637dd0270ff48384dddfc988071a41b7ae7e3284 100644
--- a/lib_com/igf_base.c
+++ b/lib_com/igf_base.c
@@ -41,7 +41,7 @@
#include "rom_com.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif
/*---------------------------------------------------------------------*
diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c
index 1b9f44d63987275fd66699f17ffadc466883182f..022720707b89f513cd299cc8eeba1b5c2fb3f740 100644
--- a/lib_com/igf_base_fx.c
+++ b/lib_com/igf_base_fx.c
@@ -8,8 +8,7 @@
#include
#include "options.h"
#include "stl.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "basop_util.h"
@@ -455,8 +454,10 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou
tmp2 = norm_s( frameLength );
bandwidth = shl( frameLength, tmp2 );
hGrid->swb_offset_len = extract_l( L_shr( sampleRate, 2 ) );
+ move16();
tmp1 = sub( norm_s( hGrid->swb_offset_len ), 1 );
hGrid->swb_offset_len = shl( hGrid->swb_offset_len, tmp1 );
+ move16();
bandwidth = div_s( hGrid->swb_offset_len, bandwidth );
tmp2 = sub( add( tmp2, 1 ), tmp1 );
bandwidth = shr( bandwidth, sub( 15, tmp2 ) );
@@ -467,12 +468,15 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou
hGrid->startSfb = 0;
move16();
hGrid->stopSfb = sub( hGrid->swb_offset_len, 1 );
+ move16();
hGrid->startLine = hGrid->swb_offset[hGrid->startSfb];
move16();
hGrid->stopLine = hGrid->swb_offset[hGrid->stopSfb];
move16();
hGrid->startFrequency = imult1616( bandwidth, hGrid->startLine );
+ move16();
hGrid->stopFrequency = imult1616( bandwidth, hGrid->stopLine );
+ move16();
L_tmp1 = L_mult0( igfMinFq, frameLength );
tmp1 = sub( norm_l( L_tmp1 ), 1 );
@@ -484,10 +488,14 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou
hGrid->minSrcSubband = div_s( extract_h( L_tmp1 ), extract_h( L_tmp2 ) );
hGrid->minSrcSubband = shr( hGrid->minSrcSubband, tmp1 );
+ move16();
+ move16();
hGrid->minSrcSubband = add( hGrid->minSrcSubband, s_and( hGrid->minSrcSubband, 1 ) );
+ move16();
hGrid->minSrcFrequency = imult1616( bandwidth, hGrid->minSrcSubband );
+ move16();
hGrid->infoGranuleLen = frameLength;
move16();
hGrid->infoTransFac = transFac;
@@ -528,59 +536,91 @@ static void IGF_gridSetUp( H_IGF_GRID hGrid, /**< ou
case IGF_BITRATE_RF_WB_13200:
hGrid->nTiles = 2;
+ move16();
wrp_sfb = 2;
+ move16();
/*1st*/
hGrid->sfbWrap[0 + 1] = wrp_sfb;
+ move16();
hGrid->sbWrap[0] = hGrid->minSrcSubband;
+ move16();
hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb];
+ move16();
/*2nd*/
hGrid->sfbWrap[1 + 1] = hGrid->stopSfb;
+ move16();
hGrid->sbWrap[1] = hGrid->minSrcSubband;
+ move16();
hGrid->tile[1 + 1] = hGrid->swb_offset[hGrid->stopSfb];
+ move16();
BREAK;
case IGF_BITRATE_SWB_9600:
hGrid->nTiles = 3;
+ move16();
wrp_sfb = 1;
+ move16();
/*1st*/
hGrid->sfbWrap[0 + 1] = wrp_sfb;
+ move16();
hGrid->sbWrap[0] = hGrid->minSrcSubband;
+ move16();
hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb];
+ move16();
/*2nd*/
wrp_sfb = 2;
+ move16();
hGrid->sfbWrap[1 + 1] = wrp_sfb;
+ move16();
hGrid->sbWrap[1] = hGrid->minSrcSubband + IGF_ApplyTransFac( 32, transFac );
+ move16();
hGrid->tile[1 + 1] = hGrid->swb_offset[wrp_sfb];
+ move16();
/*3rd*/
hGrid->sfbWrap[2 + 1] = hGrid->stopSfb;
+ move16();
hGrid->sbWrap[2] = hGrid->minSrcSubband + IGF_ApplyTransFac( 46, transFac );
+ move16();
hGrid->tile[2 + 1] = hGrid->swb_offset[hGrid->stopSfb];
+ move16();
BREAK;
case IGF_BITRATE_RF_SWB_13200:
hGrid->nTiles = 3;
+ move16();
wrp_sfb = 1;
+ move16();
/*1st*/
hGrid->sfbWrap[0 + 1] = wrp_sfb;
+ move16();
hGrid->sbWrap[0] = hGrid->minSrcSubband;
+ move16();
hGrid->tile[0 + 1] = hGrid->swb_offset[wrp_sfb];
+ move16();
/*2nd*/
wrp_sfb = 2;
+ move16();
hGrid->sfbWrap[1 + 1] = wrp_sfb;
+ move16();
hGrid->sbWrap[1] = hGrid->minSrcSubband + IGF_ApplyTransFac( 32, transFac );
+ move16();
hGrid->tile[1 + 1] = hGrid->swb_offset[wrp_sfb];
+ move16();
/*3rd*/
hGrid->sfbWrap[2 + 1] = hGrid->stopSfb;
+ move16();
hGrid->sbWrap[2] = hGrid->minSrcSubband + IGF_ApplyTransFac( 46, transFac );
+ move16();
hGrid->tile[2 + 1] = hGrid->swb_offset[hGrid->stopSfb];
+ move16();
BREAK;
@@ -869,19 +909,26 @@ static void IGF_gridSetUp_ivas_fx(
/* inits */
swb_offset = NULL;
swb_offset_len = 0;
+ move16();
+
+ test();
+ test();
IF( EQ_16( transFac, 8192 ) && EQ_16( bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) )
{
bitRateIndex = IGF_BITRATE_SWB_48000_CPE_TCX10;
+ move16();
}
ELSE IF( EQ_16( transFac, 8192 ) && EQ_16( bitRateIndex, IGF_BITRATE_FB_48000_CPE ) )
{
bitRateIndex = IGF_BITRATE_FB_48000_CPE_TCX10;
+ move16();
}
IF( NE_16( bitRateIndex, IGF_BITRATE_UNKNOWN ) )
{
swb_offset = &swb_offset_LB_new[bitRateIndex][1];
swb_offset_len = swb_offset_LB_new[bitRateIndex][0];
+ move16();
Copy( &igf_whitening_TH_ivas_fx[bitRateIndex][0][0], &hGrid->whiteningThreshold[0][0], IGF_MAX_TILES * 2 );
}
ELSE
@@ -892,29 +939,41 @@ static void IGF_gridSetUp_ivas_fx(
FOR( sfb = 0; sfb < swb_offset_len; sfb++ )
{
hGrid->swb_offset[sfb] = IGF_ApplyTransFac( swb_offset[sfb], transFac );
+ move16();
}
FOR( sfb = swb_offset_len; sfb < IGF_MAX_SFB; sfb++ )
{
hGrid->swb_offset[sfb] = 0;
+ move16();
}
hGrid->infoIsRefined = 0;
+ move16();
frameLength = IGF_ApplyTransFac( frameLength, transFac );
tmp2 = norm_s( frameLength );
bandwidth_fx = shl( frameLength, tmp2 );
hGrid->swb_offset_len = extract_l( L_shr( sampleRate, 2 ) );
+ move16();
tmp1 = sub( norm_s( hGrid->swb_offset_len ), 1 );
hGrid->swb_offset_len = shl( hGrid->swb_offset_len, tmp1 );
+ move16();
bandwidth_fx = div_s( hGrid->swb_offset_len, bandwidth_fx );
tmp2 = sub( add( tmp2, 1 ), tmp1 );
bandwidth_fx = shr( bandwidth_fx, sub( 15, tmp2 ) );
hGrid->swb_offset_len = swb_offset_len;
+ move16();
hGrid->startSfb = 0;
+ move16();
hGrid->stopSfb = sub( hGrid->swb_offset_len, 1 );
+ move16();
hGrid->startLine = hGrid->swb_offset[hGrid->startSfb];
+ move16();
hGrid->stopLine = hGrid->swb_offset[hGrid->stopSfb];
+ move16();
hGrid->startFrequency = imult1616( bandwidth_fx, hGrid->startLine );
+ move16();
hGrid->stopFrequency = imult1616( bandwidth_fx, hGrid->stopLine );
+ move16();
L_tmp1 = L_mult0( igfMinFq, frameLength );
tmp1 = sub( norm_l( L_tmp1 ), 1 );
L_tmp1 = L_shl( L_tmp1, tmp1 );
@@ -922,28 +981,44 @@ static void IGF_gridSetUp_ivas_fx(
L_tmp2 = L_shl( sampleRate, tmp2 );
tmp1 = add( WORD16_BITS - 1, sub( tmp1, add( tmp2, 1 ) ) ); /* takes into account sampleRate >> 1 */
hGrid->minSrcSubband = div_s( extract_h( L_tmp1 ), extract_h( L_tmp2 ) );
+ move16();
hGrid->minSrcSubband = shr( hGrid->minSrcSubband, tmp1 );
+ move16();
hGrid->minSrcSubband = add( hGrid->minSrcSubband, s_and( hGrid->minSrcSubband, 1 ) );
+ move16();
hGrid->minSrcFrequency = imult1616( bandwidth_fx, hGrid->minSrcSubband );
+ move16();
hGrid->infoGranuleLen = frameLength;
+ move16();
hGrid->sfbWrap[0] = 0;
+ move16();
hGrid->tile[0] = hGrid->startLine;
+ move16();
igf_tile_offset = &igf_tile_offset_table[bitRateIndex][1];
hGrid->nTiles = igf_tile_offset_table[bitRateIndex][0];
+ move16();
hGrid->tile[0] = hGrid->startLine;
+ move16();
hGrid->sfbWrap[0] = 0;
+ move16();
FOR( k = 0; k < hGrid->nTiles; k++ )
{
hGrid->sfbWrap[k + 1] = igf_tile_offset[2 * k];
+ move16();
hGrid->sbWrap[k] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( igf_tile_offset[2 * k + 1], transFac ) );
+ move16();
hGrid->tile[k + 1] = hGrid->swb_offset[igf_tile_offset[2 * k]];
+ move16();
}
FOR( t = hGrid->nTiles + 1; t < IGF_MAX_TILES; t++ )
{
hGrid->tile[t] = 0;
+ move16();
hGrid->sbWrap[t - 1] = 0;
+ move16();
hGrid->sfbWrap[t] = 0;
+ move16();
}
/* adapt level envelope: */
@@ -1008,7 +1083,6 @@ static void IGF_gridSetUp_ivas_fx(
hGrid->gFactor = 16384 /*1.00f Q14*/;
move16();
hGrid->fFactor = 0; /*0.00f Q30*/
- ;
move16();
hGrid->lFactor = 16384 /*1.00f Q14*/;
move16();
@@ -1047,11 +1121,14 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
Flag Carry = 0;
+ move16();
+ move16();
#endif
FOR( sfb = startSfb; sfb < stopSfb; sfb++ )
{
sfbEnergy[sfb] = L_deposit_l( 0 );
+ move16();
}
IF( NULL == pPowerSpectrum )
{
@@ -1064,6 +1141,7 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in
FOR( line = swb_offset[sfb]; line < swb_offset[sfb + 1]; line++ )
{
Carry = 0;
+ move16();
#ifdef BASOP_NOGLOB
sfbEnergy[sfb] = L_add_co( sfbEnergy[sfb], pPowerSpectrum[line], &Carry, &Overflow );
#else /* BASOP_NOGLOB */
@@ -1071,6 +1149,7 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in
#endif /* BASOP_NOGLOB */
move32();
Overflow = 0;
+ move16();
#ifdef BASOP_NOGLOB
L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow );
#else /* BASOP_NOGLOB */
@@ -1233,7 +1312,9 @@ Word16 IGFCommonFuncsIGFConfiguration(
//100820 temp fix
#endif
hIGFInfo->nfSeedBuf[0] = 0;
+ move16();
hIGFInfo->nfSeedBuf[1] = 0;
+ move16();
hIGFInfo->nfSeed = &hIGFInfo->nfSeedBuf[0];
move16();
@@ -1314,7 +1395,9 @@ Word16 IGFCommonFuncsIGFConfiguration_ivas_fx(
//100820 temp fix
#endif
hIGFInfo->nfSeedBuf[0] = 0;
+ move16();
hIGFInfo->nfSeedBuf[1] = 0;
+ move16();
hIGFInfo->nfSeed = &hIGFInfo->nfSeedBuf[0];
move16();
@@ -1371,12 +1454,14 @@ Word16 IGFCommonFuncsIGFGetCFTables(
Word16 bitRateIndex;
retValue = 0; /* bitrate index is unknown -> error! */
+ move16();
bitRateIndex = IGF_MapBitRateToIndex( total_brate, bwidth, element_mode, rf_mode );
IF( bitRateIndex != IGF_BITRATE_UNKNOWN )
{
retValue = 1; /* no error */
+ move16();
SWITCH( bitRateIndex )
{
diff --git a/lib_com/index_pvq_opt_fx.c b/lib_com/index_pvq_opt_fx.c
index 713c2afb05cc9567f9b4327c25240ed3f8aab1d3..3ca87f63825890d0c13eb85534e52d95ee28d7b5 100644
--- a/lib_com/index_pvq_opt_fx.c
+++ b/lib_com/index_pvq_opt_fx.c
@@ -7,8 +7,7 @@
#include "options.h"
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#define N_OPT_FX 5 /* complexity setting, direct functional calculation limit & low dim recursion limit */
@@ -191,6 +190,7 @@ static UWord32 direct_msize_fx( Word16 dim_in, Word16 k_in )
UWord32 UL_msize, k, ksq;
UL_msize = 1; /* k==0 or dim==1 , and base fot other dims */
+ move32();
IF( k_in != 0 )
{
k = UL_deposit_l( k_in ); /*k = (UWord32) k_in;*/
@@ -226,7 +226,9 @@ static void initOffsets_fx( Word16 dim_in, UWord32 *h_mem, Word16 k_val_in )
h_mem[0] = UL_deposit_l( 0 ); /* A(=>0,k=0) */
+ move32();
h_mem[1] = UL_deposit_l( 1 ); /* A(*,k=1) */
+ move32();
UL_k_val_in = UL_deposit_l( k_val_in );
IF( EQ_16( dim_in, 2 ) )
@@ -360,6 +362,7 @@ static void a_u_fwd_fx( UWord32 *a_u_in,
u_kp1 = UL_lshr( a_u_in[k_val_in], 1 );
a_u_in[mem_size_m1] = UL_addNsD( 1U, UL_addNsD( u_kp1_prev, UL_addNsD( u_k_prev, u_kp1 ) ) );
+ move32();
return;
}
@@ -381,7 +384,9 @@ static UWord32 nm_h_prep_opt_fx( /* o: msize for dim */
Word16 end_loop, add_last_odd;
h[0] = UL_deposit_l( 0 ); /* % A(=>0,k=0) */
+ move32();
h[1] = UL_deposit_l( 1 ); /* % A(*,k=1) */
+ move32();
mem_size_m1 = add( k_val_in, 1 );
@@ -490,6 +495,7 @@ static Word16 find_amp_split_offset_func_mem_fx( /* o: found k_value */
UWord32 *UL_tmp_offset ) /* o: offset found */
{
Word16 not_ready, low, k_test = 0;
+ move16();
UWord16 sgn;
UWord32 UL_tmp;
/* split over A(n,k) = h_mem(k), or use direct A function evaluation */
@@ -504,6 +510,7 @@ static Word16 find_amp_split_offset_func_mem_fx( /* o: found k_value */
{
k_test = shr( add( low, high ), 1 ); /*% split range in half */
*UL_tmp_offset = ( *h_func_ptr )( UL_deposit_l( k_test ) ); /* call direct A offset-function */
+ move32();
UL_tmp = UL_subNs( *UL_tmp_offset, ind_in, &sgn );
IF( sgn )
@@ -548,6 +555,7 @@ static Word16 get_lead_sign_fx( UWord32 *ind )
move16();
}
( *ind ) = UL_lshr( *ind, 1 );
+ move32();
return leading_sign;
}
@@ -566,6 +574,7 @@ static void mind2vec_one_fx(
/* NB input k_val_in can be zero */
/* *vec_out = leading_sign*k_val_in; */
*vec_out = (Word16) ind; /* dummy assignment to avoid gcc "unused parameter" warning for ind, i.e no move16() needed */
+ move16();
/* *vec_out = extract_l(L_mult0(leading_sign,k_val_in)); move16(); // 3 ops */
if ( leading_sign < 0 )
@@ -623,6 +632,7 @@ static Word16 setval_update_sign_fx( Word16 k_delta,
{
mind2vec_one_fx( k_delta, *leading_sign, *ind_in, vec_out );
*leading_sign = get_lead_sign_fx( ind_in );
+ move16();
k_max_local = sub( k_max_local, k_delta );
}
return k_max_local;
@@ -874,12 +884,16 @@ static void vec2mind_one_fx(
)
{
*ind = (Word32) ( *k_val_out_ptr ); /* dummy assignment to avoid gcc "unused parameter" warning for *k_val_out_ptr, i.e no move32 needed() */
+ move32();
*ind = UL_deposit_l( 0 );
+ move32();
*next_sign_ind = UL_deposit_l( 0 );
+ move32();
if ( *vec_in < 0 )
{
*next_sign_ind = UL_deposit_l( 1 ); /*single basicop */
+ move32();
}
return;
}
@@ -903,8 +917,10 @@ static void vec2mind_two_fx(
*k_val_out_ptr = abs01;
move16(); /* can be zero */
*ind = UL_deposit_l( 0 ); /* [KMAX 0 ] , and dual zeros */
+ move32();
*next_sign_ind = UL_deposit_h( SIGNBIT_SHRT_FX ); /* "unset" sign flag set */ /* dual zeroes can happen in a recursive encoding call */
+ move32();
IF( abs01 != 0 )
@@ -912,6 +928,7 @@ static void vec2mind_two_fx(
sptr = 0;
move16(); /*used as ptr to vec0 or vec1 value */
*next_sign_ind = UL_deposit_l( sptr );
+ move32();
test();
IF( abs0 != 0 && abs1 != 0 )
@@ -933,6 +950,7 @@ static void vec2mind_two_fx(
{
/* [ 0 KMAX]*/
*ind = UL_deposit_l( (UWord16) sub( lshl( abs1, 1 ), 1 ) );
+ move32();
sptr = 1;
move16();
}
@@ -942,6 +960,7 @@ static void vec2mind_two_fx(
if ( vec_in[sptr] < 0 )
{
*next_sign_ind = UL_deposit_l( 1 ); /*single instruction */
+ move32();
}
}
return;
@@ -958,6 +977,7 @@ static void enc_push_sign( Word16 val, UWord32 *next_sign_ind, UWord32 *index )
IF( ( UL_and( *next_sign_ind, SIGNBIT_FX ) == 0 ) && ( val != 0 ) )
{
*index = UL_addNsD( UL_lshl( *index, 1 ), *next_sign_ind );
+ move32();
}
/* push sign to next non_zero position */
@@ -965,10 +985,12 @@ static void enc_push_sign( Word16 val, UWord32 *next_sign_ind, UWord32 *index )
if ( val < 0 )
{
*next_sign_ind = UL_deposit_l( 1 ); /* single basicop */
+ move32();
}
if ( val > 0 )
{
*next_sign_ind = UL_deposit_l( 0 ); /* single basicop */
+ move32();
}
}
@@ -997,8 +1019,10 @@ static void vec2mind_gen345_fx(
move32(); /* adaptive function call setup */
*index = UL_addNsD( *index, ( *a_func_ptr )( UL_deposit_l( *k_val_out_ptr ) ) );
+ move32();
*k_val_out_ptr = add( *k_val_out_ptr, abs_s( tmp_val ) );
+ move16();
return;
}
@@ -1075,6 +1099,7 @@ static void vec2mind_fx( Word16 dim_in, /* i : dim
mem_size_m1 = add( k_val_in, 1 );
*next_sign_ind = UL_deposit_h( SIGNBIT_SHRT_FX ); /* highest bit set signals no sign found yet, should always be 0 or 1 out, */
+ move32();
pos = sub( dim_in, 2 ); /* adress 2nd last sample */
vec2mind_two_fx( &vec_in[pos], &k_val_acc, next_sign_ind, index );
@@ -1090,6 +1115,7 @@ static void vec2mind_fx( Word16 dim_in, /* i : dim
/* now add indexing offset up to this reverse (r_l) accumulated amplitude point */
*index = UL_addNsD( *index, tmp_h ); /* k_val_acc==0 ==>0 */
+ move32();
/* k_val_acc = k_val_acc + vec_abs[pos];*/ /* now increase acc k value for next N */
k_val_acc = add( k_val_acc, abs_s( tmp_val ) );
diff --git a/lib_com/int_lsp.c b/lib_com/int_lsp.c
index a340281f7b2e553b09996f374e751676f3fefc85..b6528030e17949b4ff1af298ed0996668d5d87ae 100644
--- a/lib_com/int_lsp.c
+++ b/lib_com/int_lsp.c
@@ -40,8 +40,7 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*---------------------------------------------------------------------*
* int_lsp()
@@ -130,13 +129,17 @@ void int_lsp_fx(
move16();
fold = sub( 32767, fnew ); /* 1.0 - fac_new */
if ( fold != 0 )
+ {
fold = add( fold, 1 );
+ }
FOR( i = 0; i < m; i++ )
{
L_tmp = L_mult( lsp_old[i], fold );
L_tmp = L_mac( L_tmp, lsp_new[i], fnew );
- if ( fold == 0 )
+ IF( fold == 0 )
+ {
L_tmp = L_mac( L_tmp, lsp_new[i], 1 ); /* 'fnew' should have been 32768 */
+ }
lsp[i] = round_fx( L_tmp );
}
IF( Opt_AMR_WB )
@@ -302,7 +305,7 @@ void int_lsp4_fx(
move16();
E_LPC_f_lsp_a_conversion( lsp, Aq, m );
- Aq += ( m + 1 );
+ Aq += add( m, 1 );
move16();
}
diff --git a/lib_com/interleave_spectrum.c b/lib_com/interleave_spectrum.c
index 12e628fb79fb90dbbbd5a725276c2894eb69cf3b..9fdba4c77be73760a2090220daecf80eb3a7304f 100644
--- a/lib_com/interleave_spectrum.c
+++ b/lib_com/interleave_spectrum.c
@@ -40,8 +40,7 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
@@ -321,6 +320,7 @@ void ivas_de_interleave_spectrum_fx(
grps = N_INTL_GRP_48;
move16();
l_frame = L_FRAME48k;
+ move16();
p2 = coefs_out + sublen[2]; /* 240, length/4 */
p3 = coefs_out + sublen[4]; /* 480, 2*length/4 */
p4 = coefs_out + sublen[5]; /* 720, 3*length/4 */
diff --git a/lib_com/interpol.c b/lib_com/interpol.c
index 2dfab173b28ffbc49195a1f17ec9b0f89198a8aa..f4e42de2c1b484589ca1fd06d5f677b15a00a7c3 100644
--- a/lib_com/interpol.c
+++ b/lib_com/interpol.c
@@ -39,8 +39,7 @@
#include "prot.h"
#include "wmc_auto.h"
#include "rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "prot_fx_enc.h"
/*-------------------------------------------------------------------*
diff --git a/lib_com/isf_dec_amr_wb_fx.c b/lib_com/isf_dec_amr_wb_fx.c
index b97bee56d07f80ab684993511aef38cbeef96c21..586dea53549dcaa098721848f4301909748f5d02 100644
--- a/lib_com/isf_dec_amr_wb_fx.c
+++ b/lib_com/isf_dec_amr_wb_fx.c
@@ -31,10 +31,10 @@
*******************************************************************************************************/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#ifdef _MSC_VER
void E_LPC_isf_isp_conversion( const Word16 isf[], Word16 isp[], const Word16 m );
@@ -146,7 +146,7 @@ void isf_dec_amr_wb_fx(
* A(z) calculation
*-------------------------------------------------------------------------------------*/
- if ( st->rate_switching_reset )
+ IF( st->rate_switching_reset )
{
/*extrapolation instead of interpolation*/
Copy( isp_new, st->lsp_old_fx, M );
@@ -160,13 +160,15 @@ void isf_dec_amr_wb_fx(
* Check ISF stability : distance between old ISF and current ISF
*------------------------------------------------------------------*/
- IF( EQ_16( st->element_mode, EVS_MONO ) )
+ IF( st->element_mode == EVS_MONO )
{
st->stab_fac_fx = lsf_stab_fx( isf_new, st->lsf_old_fx, 1, st->L_frame );
+ move16();
}
- else
+ ELSE
{
st->stab_fac_fx = lsf_stab_ivas_fx( isf_new, st->lsf_old_fx, 1, st->L_frame );
+ move16();
}
return;
diff --git a/lib_com/ivas_agc_com_fx.c b/lib_com/ivas_agc_com_fx.c
index 3b8a95e9320edc52aeedc7c8257da5986e5cb67e..c173e79a24766c24a6d67ee00564a0027e354c65 100644
--- a/lib_com/ivas_agc_com_fx.c
+++ b/lib_com/ivas_agc_com_fx.c
@@ -45,9 +45,9 @@
* Local constants
*------------------------------------------------------------------------------------------*/
-#define SQRKMAX ( 1.5f )
-#define NBITS_DIFFG ( 2 )
-#define DBSTEP ( -6.f ) /* desired dB step value in dB*/
+//#define SQRKMAX ( 1.5f )
+//#define NBITS_DIFFG ( 2 )
+//#define DBSTEP ( -6.f ) /* desired dB step value in dB*/
#define ABS_EMIN_MAX ( 3 )
#define MAXATTEXP ( 1 ) /* the desired maximum attenuation exponent range per frame*/
@@ -70,6 +70,7 @@ void ivas_agc_initWindowFunc_fx(
const Word16 *cos_val;
a = A_FX; /* for DBSTEP -6.f */
+ move16();
SWITCH( length )
{
@@ -87,9 +88,10 @@ void ivas_agc_initWindowFunc_fx(
BREAK;
}
- for ( i = 0; i < length; i++ )
+ FOR( i = 0; i < length; i++ )
{
- pWinFunc[i] = add( MAX_16, (Word16) Mpy_32_16_1( L_sub( (Word32) cos_val[i], (Word32) MAX_16 ), a ) );
+ pWinFunc[i] = add( MAX_16, extract_l( Mpy_32_16_1( L_sub( cos_val[i], MAX_16 ), a ) ) );
+ move16();
}
return;
@@ -112,12 +114,14 @@ void ivas_agc_calcGainParams_fx(
// Word16 nbits;
// nbits = NBITS_DIFFG;
- assert( EQ_16( numCoeffs, IVAS_SPAR_MAX_DMX_CHS ) );
+ assert( numCoeffs == IVAS_SPAR_MAX_DMX_CHS );
*absEmin = s_max( ABS_EMIN_MAX, LOG2_NUMCOEFF_SQRKMAX );
+ move16();
// totExp = add( add( *absEmin, AGC_EMAX ), 1 );
/**betaE = (UWord16)ceilf(logf(totExp) * INV_LOG_2);*/
*betaE = (UWord16) LOG2_4;
+ move16();
/*Bm = (UWord16)ceilf(logf((AGC_EMAX + 1 + 1)) * INV_LOG_2);*/
// Bm = 1;
@@ -130,6 +134,8 @@ void ivas_agc_calcGainParams_fx(
/**maxAttExp = ((UWord16) powf( 2, Bm ) ) - 2;*/
*maxAttExp = sub( shl( 2, 1 ), 2 );
*maxAttExp = s_min( MAXATTEXP, *maxAttExp );
+ move16();
+ move16();
return;
}
diff --git a/lib_com/ivas_arith.c b/lib_com/ivas_arith.c
index 852ddee0d678f21a979b1ebeef57daf75d1fce1b..92357f05e160cc736bf660978cffe76ec9e7a1d9 100644
--- a/lib_com/ivas_arith.c
+++ b/lib_com/ivas_arith.c
@@ -35,6 +35,7 @@
#include "wmc_auto.h"
#include "prot.h"
#include "ivas_prot.h"
+#include "ivas_prot_fx.h"
#include "stat_dec.h"
/*-----------------------------------------------------------------------------------------*
@@ -45,6 +46,39 @@
* Similar to ari_start_decoding_14bits_fx(), but do not read past frame boundary.
*-----------------------------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+void ivas_ari_start_decoding_14bits_ext_1_lfe(
+ Decoder_State *st,
+ Tastat *s,
+ Word16 *extra_bits_read )
+{
+ Word32 val;
+
+ IF( GE_16( st->bits_frame, add( st->next_bit_pos, cbitsnew ) ) )
+ {
+ val = get_next_indice( st, cbitsnew );
+ }
+ ELSE
+ {
+ Word16 rem_bits;
+ rem_bits = sub( st->bits_frame, st->next_bit_pos );
+ val = get_next_indice( st, rem_bits );
+ val = L_shl( val, sub( cbitsnew, rem_bits ) );
+ *extra_bits_read = add( *extra_bits_read, sub( cbitsnew, rem_bits ) );
+ move16();
+ }
+
+ s->low = 0;
+ s->high = ari_q4new;
+ s->value = val;
+
+ move32();
+ move32();
+ move32();
+
+ return;
+}
+#else
void ivas_ari_start_decoding_14bits_ext_1_lfe(
Decoder_State *st,
Tastat *s,
@@ -71,9 +105,28 @@ void ivas_ari_start_decoding_14bits_ext_1_lfe(
return;
}
-
+#endif
/* Helper function to determine the symbol. */
+#ifdef IVAS_FLOAT_FIXED
+static UWord16 ivas_ari_get_symbol(
+ const UWord16 *p,
+ UWord32 range,
+ UWord32 cum )
+{
+ UWord16 symbol;
+
+ symbol = 0;
+ move16();
+
+ WHILE( GT_64( W_mult0_32_32( p[symbol + 1], range ), cum ) )
+ {
+ symbol = u_extract_l( UL_addNsD( symbol, 1 ) );
+ }
+
+ return symbol;
+}
+#else
static uint16_t ivas_ari_get_symbol(
const uint16_t *p,
uint32_t range,
@@ -91,6 +144,7 @@ static uint16_t ivas_ari_get_symbol(
return symbol;
}
+#endif
/*---------------------------------------------------------------
* Function ivas_ari_decode_14bits_bit_ext_1_lfe()
@@ -98,6 +152,86 @@ static uint16_t ivas_ari_get_symbol(
*
*-------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+UWord16 ivas_ari_decode_14bits_bit_ext_1_lfe(
+ Decoder_State *st,
+ Tastat *s,
+ const UWord16 *cum_freq,
+ Word16 *extra_bits_read )
+{
+ UWord16 symbol;
+ UWord32 low, high, range, value;
+ UWord32 cum;
+
+ /* read s->low,high,value sequentially */
+ low = s->low;
+ high = s->high;
+ value = s->value;
+
+ move32();
+ move32();
+ move32();
+
+ range = UL_addNsD( UL_subNsD( high, low ), 1 );
+ cum = UL_subNsD( UL_lshl( ( UL_addNsD( UL_subNsD( value, low ), 1 ) ), stat_bitsnew ), 1 );
+
+ symbol = ivas_ari_get_symbol( cum_freq, range, cum );
+
+ high = UL_subNsD( UL_addNsD( low, mul_sbc_14bits_ivas( range, cum_freq[symbol] ) ), 1 );
+ low = UL_addNsD( low, mul_sbc_14bits_ivas( range, cum_freq[symbol + 1] ) );
+
+ FOR( ;; )
+ {
+ IF( GE_32( high, ari_q2new ) )
+ {
+ IF( GE_32( low, ari_q2new ) )
+ {
+ value = UL_subNsD( value, ari_q2new );
+ low = UL_subNsD( low, ari_q2new );
+ high = UL_subNsD( high, ari_q2new );
+ }
+ ELSE
+ {
+ test();
+ IF( GE_32( low, ari_q1new ) && LT_32( high, ari_q3new ) )
+ {
+ value = UL_subNsD( value, ari_q1new );
+ low = UL_subNsD( low, ari_q1new );
+ high = UL_subNsD( high, ari_q1new );
+ }
+ ELSE
+ {
+ BREAK;
+ }
+ }
+ }
+
+ low = UL_addNsD( low, low );
+ high = UL_addNsD( high, UL_addNsD( high, 1 ) );
+
+ IF( GE_16( st->next_bit_pos, st->bits_frame ) )
+ {
+ value = UL_lshl( value, 1 );
+ *extra_bits_read = add( *extra_bits_read, 1 );
+ move16();
+ }
+ ELSE
+ {
+ value = UL_or( UL_lshl( value, 1 ), get_next_indice_1( st ) );
+ }
+ }
+
+ s->low = low;
+ s->high = high;
+ s->value = value;
+
+ move32();
+ move32();
+ move32();
+
+ return symbol;
+}
+#else
uint16_t ivas_ari_decode_14bits_bit_ext_1_lfe(
Decoder_State *st,
Tastat *s,
@@ -166,6 +300,7 @@ uint16_t ivas_ari_decode_14bits_bit_ext_1_lfe(
return symbol;
}
+#endif
/*---------------------------------------------------------------
* Function ivas_ari_done_decoding_14bits_ext_1_lfe()
@@ -173,6 +308,16 @@ uint16_t ivas_ari_decode_14bits_bit_ext_1_lfe(
*
*-------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+void ivas_ari_done_decoding_14bits_ext_1_lfe(
+ Decoder_State *st,
+ const Word16 extra_bits_read )
+{
+ get_next_indice_tmp( st, negate( sub( cbitsnew - 2, extra_bits_read ) ) );
+
+ return;
+}
+#else
void ivas_ari_done_decoding_14bits_ext_1_lfe(
Decoder_State *st,
const int16_t extra_bits_read )
@@ -181,6 +326,7 @@ void ivas_ari_done_decoding_14bits_ext_1_lfe(
return;
}
+#endif
/*---------------------------------------------------------------
@@ -188,7 +334,7 @@ void ivas_ari_done_decoding_14bits_ext_1_lfe(
*
* Arith encoding of last table entry
*-------------------------------------------------------------*/
-
+#ifndef IVAS_FLOAT_FIXED
void ivas_ari_done_encoding_14bits(
BSTR_ENC_HANDLE hBstr,
Tastat *s )
@@ -224,14 +370,51 @@ void ivas_ari_done_encoding_14bits(
return;
}
+#else
+void ivas_ari_done_encoding_14bits_fx(
+ BSTR_ENC_HANDLE hBstr,
+ Tastat *s )
+{
+ Word32 low;
+ Word32 bits_to_follow;
+ /* not needed, s points to s->low */
+ low = s->low;
+ move32();
+ bits_to_follow = L_add( s->bits_to_follow, 1 );
+
+ IF( LT_32( low, ari_q1new ) )
+ {
+ push_next_indice( hBstr, 0, 1 ); /*send a zero*/
+
+ FOR( ; bits_to_follow > 0; bits_to_follow-- )
+ {
+ push_next_indice( hBstr, 1, 1 ); /*send a one*/
+ }
+ }
+ ELSE
+ {
+ push_next_indice( hBstr, 1, 1 ); /*send a one*/
+ FOR( ; bits_to_follow > 0; bits_to_follow-- )
+ {
+ push_next_indice( hBstr, 0, 1 ); /*send a zero*/
+ }
+ }
+
+ /*It is done so no need to save values-> no counting*/
+ /*s->low = low;
+ s->bits_to_follow = bits_to_follow;*/
+
+ return;
+}
+#endif
/*---------------------------------------------------------------
* Function ivas_ari_encode_14bits_ext()
*
* Arith encode function for extended proba tables
*-------------------------------------------------------------*/
-
+#ifndef IVAS_FLOAT_FIXED
void ivas_ari_encode_14bits_ext(
BSTR_ENC_HANDLE hBstr,
Tastat *s,
@@ -300,3 +483,80 @@ void ivas_ari_encode_14bits_ext(
return;
}
+#else
+void ivas_ari_encode_14bits_ext_fx(
+ BSTR_ENC_HANDLE hBstr,
+ Tastat *s,
+ Word32 symbol,
+ const UWord16 *cum_freq )
+{
+ Word32 low, high, range;
+ Word32 bits_to_follow;
+
+ /*for all operation using bit_ptr=&ptr[bp] */
+ /* for reading s->high,low,bits_to_follow sequentially */
+ high = s->high;
+ low = s->low;
+ range = L_add( L_sub( high, low ), 1 );
+ move32();
+ move32();
+
+ high = L_sub( L_add( low, mul_sbc_14bits_ivas( range, cum_freq[symbol] ) ), 1 );
+ low = L_add( low, mul_sbc_14bits_ivas( range, cum_freq[L_add( symbol, 1 )] ) );
+
+ bits_to_follow = s->bits_to_follow;
+ move32();
+
+ FOR( ;; )
+ {
+ IF( LT_32( high, ari_q2new ) )
+ {
+ push_next_indice( hBstr, 0, 1 ); /*send a zero*/
+ FOR( ; bits_to_follow > 0; bits_to_follow-- )
+ {
+ push_next_indice( hBstr, 1, 1 ); /*send a one*/
+ }
+ }
+ ELSE
+ {
+ IF( GE_32( low, ari_q2new ) )
+ {
+ push_next_indice( hBstr, 1, 1 ); /*send a one*/
+ FOR( ; bits_to_follow > 0; bits_to_follow-- )
+ {
+ push_next_indice( hBstr, 0, 1 ); /*send a zero*/
+ }
+ low = L_sub( low, ari_q2new );
+ high = L_sub( high, ari_q2new ); /* Subtract offset to top. */
+ }
+ ELSE
+ {
+ /* Output an opposite bit */
+ test();
+ IF( GE_32( low, ari_q1new ) && LT_32( high, ari_q3new ) ) /* Output an opposite bit */
+ {
+ /* later if in middle half. */
+ bits_to_follow = L_add( bits_to_follow, 1 );
+ low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/
+ high = L_sub( high, ari_q1new );
+ }
+ ELSE
+ {
+ BREAK; /* Otherwise exit loop. */
+ }
+ }
+ }
+ low = L_add( low, low );
+ high = L_add( L_add( high, high ), 1 ); /* Scale up code range. */
+ }
+
+ s->low = low;
+ s->high = high;
+ s->bits_to_follow = bits_to_follow;
+ move32();
+ move32();
+ move32();
+
+ return;
+}
+#endif
diff --git a/lib_com/ivas_avq_pos_reorder_com.c b/lib_com/ivas_avq_pos_reorder_com.c
index 27878028d835f33db183da0ad5aa5fcc722d1fa2..692e89f8662aa6da0b0cc7dcd5c834dc0bf37af5 100644
--- a/lib_com/ivas_avq_pos_reorder_com.c
+++ b/lib_com/ivas_avq_pos_reorder_com.c
@@ -41,6 +41,7 @@
*
*-----------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
void ordr_esti(
const int16_t svLength, /* i : sub-vector index */
int16_t *Mpos, /* i/o: dominant sub-vector position from ACV */
@@ -61,3 +62,31 @@ void ordr_esti(
return;
}
+#else
+void ordr_esti(
+ const Word16 svLength, /* i : sub-vector index */
+ Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */
+ Word16 svOrder[], /* i/o: AVQ sub-vector order */
+ const Word16 Nsv /* i : total sub-vectors in a sub-frames */
+)
+{
+ Word16 i, tmp;
+
+ tmp = svOrder[0];
+ svOrder[0] = *Mpos;
+ *Mpos = sub( Nsv, 1 );
+
+ move16();
+ move16();
+ move16();
+
+ FOR( i = 1; i < svLength; ( tmp++, i++ ) )
+ {
+ svOrder[i] = tmp;
+ move16();
+ }
+
+ return;
+}
+
+#endif
diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h
index 1b6940be546336a64fdad66d7006591808482911..b56c3d35b18d9c7a64691bed6dff7d443194e563 100644
--- a/lib_com/ivas_cnst.h
+++ b/lib_com/ivas_cnst.h
@@ -586,8 +586,14 @@ typedef enum
#define STEREO_DFT_FLAG_BITS 1
#define STEREO_DFT_SIDEGAIN_NBITS 5
#define STEREO_DFT_FEC_THRESHOLD 10
+#ifdef IVAS_FLOAT_FIXED
+#define STEREO_DFT_FEC_THRESHOLD_PLUS_1_INV_Q31 ( 195225786 )
+#define STEREO_DFT_BITDIFF_LP_FAC_Q31 ( 128849019 ) /* Low-pass filter coefficient for filtering bit difference between absolute and differential coding */
+#define STEREO_DFT_BITDIFF_ABS_SELECT_Q31 ( 1717986918 ) /* Constant to set tendency for selecting absolute coding mode */
+#else
#define STEREO_DFT_BITDIFF_LP_FAC (0.06f) /* Low-pass filter coefficient for filtering bit difference between absolute and differential coding */
#define STEREO_DFT_BITDIFF_ABS_SELECT (0.8f) /* Constant to set tendency for selecting absolute coding mode */
+#endif
#define STEREO_DFT_BITDIFF_INIT (12.0f) /* Init value for low-pass bit difference */
#define STEREO_DFT_BITDIFF_INIT_FX (12288) /* Init value for low-pass bit difference in Q10*/
@@ -991,6 +997,7 @@ typedef enum
#define DIRAC_DIFF_NUM_AMBI_COMP 4
#define DIRAC_HOA_RENDERING_NUM_VIRT_DECORR_LS 8
#define DIRAC_GAIN_LIMIT 31.622776601683793f /* 30db gain limitiation */
+#define DIRAC_GAIN_LIMIT_Q26 ( 2122168614 ) /* 30db gain limitiation */
#define DIRAC_MAX_NUM_DECORR_FILTERS 22
#define DIRAC_MAX_DECORR_FILTER_LEN 20
#define DIRAC_DECORR_NUM_SPLIT_BANDS 3
@@ -1068,6 +1075,9 @@ typedef enum
#define IVAS_SPAR_DYN_ACTIVEW_THRESH (0.0039f)
#define IVAS_SPAR_DYN_ACTIVEW_THRESH_FX (8375186) /* 0.0039f in Q31 */
#define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH (32.0f)
+#ifdef IVAS_FLOAT_FIXED
+#define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH_Q0 (32)
+#endif
#define MAX_QUANT_STRATS 3
#define MAX_CODING_STRATS 3
@@ -1280,6 +1290,9 @@ enum
#define MASA_NO_POINTS_EQUATOR 430
#define MASA_NO_CIRCLES 121
+#ifdef IVAS_FLOAT_FIXED
+#define MASA_NO_CIRCLES_Q23 ( 1015021568 )
+#endif
#define MASA_ASIN_OFFSET 0.0064471690266724975f
#define MASA_ASIN_OFFSET_Q15 ( 211 )
#define MASA_NTOT2_FAC 32768.00566947353f
@@ -1681,6 +1694,8 @@ typedef enum
#define DEG_360_IN_Q22 (360 << Q22)
#define DEG_180_IN_Q22 (180 << Q22)
#define DEG_90_IN_Q22 (90 << Q22)
+#define ONE_BY_360_Q31 ( 5965232 )
+#define ONE_BY_180_Q31 ( 11930465 )
/* ----- Enums - TD Renderer ----- */
diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c
index 2f9a462e802470dbae58d623f1726f2951774beb..83269c34bdb7ac4cf95ae9471c40c05aa63d67ee 100644
--- a/lib_com/ivas_cov_smooth.c
+++ b/lib_com/ivas_cov_smooth.c
@@ -36,7 +36,7 @@
#include "ivas_prot.h"
#include "wmc_auto.h"
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-----------------------------------------------------------------------------------------*
* Local constants
@@ -56,6 +56,7 @@ static Word32 ivas_calculate_update_factor_fx(
Word16 active_bins )
{
Word32 update_factor_temp = 0;
+ move32();
Word16 k;
FOR( k = 0; k < active_bins; k++ )
@@ -107,6 +108,8 @@ static void ivas_calculate_smoothning_factor_fx(
{
Word32 smooth_fact, L_tmp = 0;
Word16 tmp, exp_diff = 0;
+ move32();
+ move16();
tmp = BASOP_Util_Divide3232_Scale( update_factor, L_shl( L_deposit_l( min_pool_size ), Q22 ), &exp_diff ); // (Q15 - exp_diff)
*Smoothing_factor = L_shl_sat( L_deposit_l( tmp ), add( Q16, exp_diff ) ); // Q31
@@ -204,6 +207,7 @@ static void ivas_set_up_cov_smoothing_fx(
FOR( j = 0; j < pFb->filterbank_num_bands; j++ )
{
Word16 active_bins = pFb->fb_bin_to_band.pFb_active_bins_per_band[j];
+ move16();
update_factor = ivas_calculate_update_factor_fx( pFb->fb_bin_to_band.pFb_bin_to_band_fx[j], active_bins );
ivas_calculate_smoothning_factor_fx( &hCovState->pSmoothing_factor_fx[j], update_factor, min_pool_size, max_update_rate, smooth_mode, ivas_total_brate, j );
}
@@ -214,6 +218,7 @@ static void ivas_set_up_cov_smoothing_fx(
{
Word32 *p_bin_to_band = pFb->fb_bin_to_band.pp_short_stride_bin_to_band_fx[j];
Word16 active_bins = pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j];
+ move16();
update_factor = ivas_calculate_update_factor_fx( p_bin_to_band, active_bins );
ivas_calculate_smoothning_factor_fx( &hCovState->pSmoothing_factor_fx[j], update_factor, min_pool_size, max_update_rate, smooth_mode, ivas_total_brate, j );
}
@@ -268,6 +273,59 @@ static void ivas_set_up_cov_smoothing(
#endif
+#ifdef IVAS_FLOAT_FIXED
+/*-------------------------------------------------------------------------
+ * ivas_spar_covar_smooth_enc_open_fx()
+ *
+ * Allocate and initialize SPAR Covar. smoothing handle
+ *------------------------------------------------------------------------*/
+
+ivas_error ivas_spar_covar_smooth_enc_open_fx(
+ ivas_cov_smooth_state_t **hCovState_out, /* i/o: SPAR Covar. smoothing handle */
+ const ivas_cov_smooth_cfg_t *cov_smooth_cfg, /* i : SPAR config. handle */
+ ivas_filterbank_t *pFb, /* i/o: FB handle */
+ 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_cov_smooth_state_t *hCovState;
+ Word16 i, j;
+
+ IF( ( hCovState = (ivas_cov_smooth_state_t *) malloc( sizeof( ivas_cov_smooth_state_t ) ) ) == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" );
+ }
+
+ IF( ( hCovState->pSmoothing_factor_fx = (Word32 *) malloc( sizeof( Word32 ) * cov_smooth_cfg->max_bands ) ) == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" );
+ }
+
+ FOR( i = 0; i < nchan_inp; i++ )
+ {
+ FOR( j = 0; j < nchan_inp; j++ )
+ {
+ IF( ( hCovState->pPrior_cov_real_fx[i][j] = (Word32 *) malloc( sizeof( Word32 ) * cov_smooth_cfg->max_bands ) ) == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder Fixed" );
+ }
+ set_zero_fx( hCovState->pPrior_cov_real_fx[i][j], cov_smooth_cfg->max_bands );
+ IF( ( hCovState->q_cov_real_per_band[i][j] = (Word16 *) malloc( sizeof( Word16 ) * cov_smooth_cfg->max_bands ) ) == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder Fixed" );
+ }
+ set_s( hCovState->q_cov_real_per_band[i][j], Q31, cov_smooth_cfg->max_bands );
+ }
+ }
+
+ ivas_set_up_cov_smoothing_fx( hCovState, pFb, cov_smooth_cfg->max_update_rate_fx, cov_smooth_cfg->min_pool_size, smooth_mode, ivas_total_brate );
+
+ *hCovState_out = hCovState;
+
+ return IVAS_ERR_OK;
+}
+#else
/*-------------------------------------------------------------------------
* ivas_spar_covar_smooth_enc_open()
*
@@ -291,17 +349,10 @@ ivas_error ivas_spar_covar_smooth_enc_open(
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" );
}
-#ifdef IVAS_FLOAT_FIXED
- IF( ( hCovState->pSmoothing_factor_fx = (Word32 *) malloc( sizeof( Word32 ) * cov_smooth_cfg->max_bands ) ) == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" );
- }
-#else
if ( ( hCovState->pSmoothing_factor = (float *) malloc( sizeof( float ) * cov_smooth_cfg->max_bands ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" );
}
-#endif
for ( i = 0; i < nchan_inp; i++ )
{
@@ -312,28 +363,57 @@ ivas_error ivas_spar_covar_smooth_enc_open(
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" );
}
set_zero( hCovState->pPrior_cov_real[i][j], cov_smooth_cfg->max_bands );
-#ifdef IVAS_FLOAT_FIXED
- if ( ( hCovState->pPrior_cov_real_fx[i][j] = (Word32 *) malloc( sizeof( Word32 ) * cov_smooth_cfg->max_bands ) ) == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder Fixed" );
- }
- set_zero_fx( hCovState->pPrior_cov_real_fx[i][j], cov_smooth_cfg->max_bands );
-#endif
}
}
-#ifdef IVAS_FLOAT_FIXED
- ivas_set_up_cov_smoothing_fx( hCovState, pFb, cov_smooth_cfg->max_update_rate_fx, cov_smooth_cfg->min_pool_size, smooth_mode, ivas_total_brate );
-#else
ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size, smooth_mode, ivas_total_brate );
-#endif
*hCovState_out = hCovState;
return IVAS_ERR_OK;
}
+#endif
+#ifdef IVAS_FLOAT_FIXED
+/*-------------------------------------------------------------------------
+ * ivas_spar_covar_smooth_enc_close_fx()
+ *
+ * Deallocate SPAR Covar. smoothing handle
+ *------------------------------------------------------------------------*/
+void ivas_spar_covar_smooth_enc_close_fx(
+ ivas_cov_smooth_state_t **hCovState_out, /* i/o: SPAR Covar. smoothing handle */
+ const Word16 nchan_inp /* i : number of input channels */
+)
+{
+ ivas_cov_smooth_state_t *hCovState;
+ Word16 i, j;
+
+ hCovState = *hCovState_out;
+
+ IF( hCovState != NULL )
+ {
+ free( hCovState->pSmoothing_factor_fx );
+ hCovState->pSmoothing_factor_fx = NULL;
+
+ FOR( i = 0; i < nchan_inp; i++ )
+ {
+ FOR( j = 0; j < nchan_inp; j++ )
+ {
+ free( hCovState->pPrior_cov_real_fx[i][j] );
+ hCovState->pPrior_cov_real_fx[i][j] = NULL;
+ free( hCovState->q_cov_real_per_band[i][j] );
+ hCovState->q_cov_real_per_band[i][j] = NULL;
+ }
+ }
+
+ free( hCovState );
+ hCovState_out = NULL;
+ }
+
+ return;
+}
+#else
/*-------------------------------------------------------------------------
* ivas_spar_covar_smooth_enc_close()
*
@@ -352,13 +432,8 @@ void ivas_spar_covar_smooth_enc_close(
if ( hCovState != NULL )
{
-#ifdef IVAS_FLOAT_FIXED
- free( hCovState->pSmoothing_factor_fx );
- hCovState->pSmoothing_factor_fx = NULL;
-#else
free( hCovState->pSmoothing_factor );
hCovState->pSmoothing_factor = NULL;
-#endif
for ( i = 0; i < nchan_inp; i++ )
{
@@ -366,10 +441,6 @@ void ivas_spar_covar_smooth_enc_close(
{
free( hCovState->pPrior_cov_real[i][j] );
hCovState->pPrior_cov_real[i][j] = NULL;
-#ifdef IVAS_FLOAT_FIXED
- free( hCovState->pPrior_cov_real_fx[i][j] );
- hCovState->pPrior_cov_real_fx[i][j] = NULL;
-#endif
}
}
@@ -379,6 +450,7 @@ void ivas_spar_covar_smooth_enc_close(
return;
}
+#endif
#ifdef IVAS_FLOAT_FIXED
@@ -398,25 +470,38 @@ static void ivas_compute_smooth_cov_fx(
const Word16 end_band,
const Word16 num_ch,
const Word16 transient_det[2],
- Word16 q_cov[][IVAS_SPAR_MAX_CH] )
+ Word16 *q_cov[IVAS_SPAR_MAX_CH] )
{
Word16 i, j, k;
Word16 prev_idx = hCovState->prior_bank_idx;
Word32 factor = 0, L_tmp, L_tmp1;
Word16 sm_b;
Word16 non_sm_b_idx;
+ Word16 q_tmp[IVAS_MAX_NUM_BANDS];
+
sm_b = BAND_SMOOTH_REST_START_IDX;
+ move16();
+ move16();
+ move32();
assert( end_band <= pFb->filterbank_num_bands );
+ test();
IF( EQ_16( prev_idx, -1 ) || EQ_16( transient_det[1], 1 ) )
{
+ FOR( i = 0; i < num_ch; i++ )
+ {
+ FOR( j = 0; j < num_ch; j++ )
+ {
+ set_s( hCovState->q_cov_real_per_band[i][j], q_cov[i][j], pFb->filterbank_num_bands );
+ }
+ }
FOR( i = 0; i < num_ch; i++ )
{
FOR( k = start_band; k < end_band; k++ )
{
L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], fac ); // (Q31, Q31) -> Q31
- pCov_buf[i][i][k] = L_add( pCov_buf[i][i][k], L_shl( L_tmp, sub( q_cov[i][i], Q31 ) ) );
+ pCov_buf[i][i][k] = L_add( pCov_buf[i][i][k], L_shl( L_tmp, sub( hCovState->q_cov_real_per_band[i][i][k], Q31 ) ) );
move32();
}
}
@@ -439,16 +524,20 @@ static void ivas_compute_smooth_cov_fx(
move32();
}
+ set_s( q_tmp, q_cov[i][j], sub( end_band, start_band ) );
FOR( k = start_band; k < non_sm_b_idx; k++ )
{
L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], pCov_buf[i][j][k] ); // (Q31, q_cov[i][j]) -> q_cov[i][j]
- L_tmp1 = Mpy_32_32( L_sub( ONE_IN_Q31, hCovState->pSmoothing_factor_fx[k] ), pPrior_cov_buf[i][j][k] ); // (Q31, q_cov[i][j]) -> q_cov[i][j]
- pCov_buf[i][j][k] = L_add( L_tmp, L_tmp1 );
+ L_tmp1 = Mpy_32_32( L_sub( ONE_IN_Q31, hCovState->pSmoothing_factor_fx[k] ), pPrior_cov_buf[i][j][k] ); // (Q31, hCovState->q_cov_real_per_band[i][j][k]) -> hCovState->q_cov_real_per_band[i][j][k]
+ pCov_buf[i][j][k] = BASOP_Util_Add_Mant32Exp( L_tmp, sub( Q31, q_cov[i][j] ), L_tmp1, sub( Q31, hCovState->q_cov_real_per_band[i][j][k] ), &q_tmp[k] );
move32();
- L_tmp = L_shl( Mpy_32_32( hCovState->pSmoothing_factor_fx[k], factor ), sub( q_cov[i][j], Q31 ) ); // ((Q31, Q31) -> Q31) -> q_cov[i][j]
+ q_tmp[k] = sub( Q31, q_tmp[k] );
+ move16();
+ L_tmp = L_shl( Mpy_32_32( hCovState->pSmoothing_factor_fx[k], factor ), sub( q_tmp[k], Q31 ) ); // ((Q31, Q31) -> Q31) -> q_tmp[k]
pCov_buf[i][j][k] = L_add( pCov_buf[i][j][k], L_tmp );
move32();
}
+ mvs2s( q_tmp, hCovState->q_cov_real_per_band[i][j], pFb->filterbank_num_bands );
}
}
FOR( i = 0; i < num_ch; i++ )
@@ -456,12 +545,12 @@ static void ivas_compute_smooth_cov_fx(
FOR( k = non_sm_b_idx; k < end_band; k++ )
{
L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], fac ); // (Q31, Q31) -> Q31
- pCov_buf[i][i][k] = L_add( pCov_buf[i][i][k], L_shl( L_tmp, sub( q_cov[i][i], Q31 ) ) );
+ pCov_buf[i][i][k] = L_add( pCov_buf[i][i][k], L_shl( L_tmp, sub( hCovState->q_cov_real_per_band[i][i][k], Q31 ) ) );
move32();
}
}
}
- ELSE IF( EQ_16( prev_idx, 0 ) )
+ ELSE IF( prev_idx == 0 )
{
FOR( i = 0; i < num_ch; i++ )
{
@@ -481,13 +570,16 @@ static void ivas_compute_smooth_cov_fx(
FOR( k = start_band; k < end_band; k++ )
{
L_tmp = Mpy_32_32( hCovState->pSmoothing_factor_fx[k], pCov_buf[i][j][k] ); // (Q31, q_cov[i][j]) -> q_cov[i][j]
- L_tmp1 = Mpy_32_32( L_sub( ONE_IN_Q31, hCovState->pSmoothing_factor_fx[k] ), pPrior_cov_buf[i][j][k] ); // (Q31, q_cov[i][j]) -> q_cov[i][j]
- pCov_buf[i][j][k] = L_add( L_tmp, L_tmp1 );
+ L_tmp1 = Mpy_32_32( L_sub( ONE_IN_Q31, hCovState->pSmoothing_factor_fx[k] ), pPrior_cov_buf[i][j][k] ); // (Q31, hCovState->q_cov_real_per_band[i][j][k]) -> hCovState->q_cov_real_per_band[i][j][k]
+ pCov_buf[i][j][k] = BASOP_Util_Add_Mant32Exp( L_tmp, sub( Q31, q_cov[i][j] ), L_tmp1, sub( Q31, hCovState->q_cov_real_per_band[i][j][k] ), &q_tmp[k] );
move32();
- L_tmp = L_shl( Mpy_32_32( hCovState->pSmoothing_factor_fx[k], factor ), sub( q_cov[i][j], Q31 ) ); // ((Q31, Q31) -> Q31) -> q_cov[i][j]
+ q_tmp[k] = sub( Q31, q_tmp[k] );
+ move16();
+ L_tmp = L_shl( Mpy_32_32( hCovState->pSmoothing_factor_fx[k], factor ), sub( q_tmp[k], Q31 ) ); // ((Q31, Q31) -> Q31) -> q_tmp[k]
pCov_buf[i][j][k] = L_add( pCov_buf[i][j][k], L_tmp );
move32();
}
+ mvs2s( q_tmp, hCovState->q_cov_real_per_band[i][j], pFb->filterbank_num_bands );
}
}
}
@@ -604,12 +696,12 @@ void ivas_cov_smooth_process_fx(
const Word16 end_band,
const Word16 num_ch,
const Word16 transient_det[2],
- Word16 q_cov[][IVAS_SPAR_MAX_CH] )
+ Word16 *q_cov[IVAS_SPAR_MAX_CH] )
{
Word16 i, j;
- Word16 num_bands = end_band - start_band;
+ Word16 num_bands = sub( end_band, start_band );
- ivas_compute_smooth_cov_fx( hCovState, pFb, cov_real, hCovState->pPrior_cov_real_fx, (Word32) ( 1e-20f * ONE_IN_Q31 ), start_band, end_band, num_ch, transient_det, q_cov );
+ ivas_compute_smooth_cov_fx( hCovState, pFb, cov_real, hCovState->pPrior_cov_real_fx, 0, start_band, end_band, num_ch, transient_det, q_cov );
FOR( i = 0; i < num_ch; i++ )
{
diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c
index 8a37462d40d0de7f8202dea493e8d70dc594b11d..cce2880bd4cd4041ce2681eb64ace0b8dfab76ab 100644
--- a/lib_com/ivas_dirac_com.c
+++ b/lib_com/ivas_dirac_com.c
@@ -40,9 +40,11 @@
#include "prot.h"
#include "cnst.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*-----------------------------------------------------------------------*
* Local function prototypes
@@ -61,38 +63,38 @@ static UWord16 deindex_sph_idx_general_fx( const Word16 idx_sph, const Word16 no
*------------------------------------------------------------------------*/
/*! r: HO-DirAC flag */
-int16_t ivas_get_hodirac_flag(
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int16_t sba_order /* i : Ambisonic (SBA) order */
+#ifdef IVAS_FLOAT_FIXED
+Word16 ivas_get_hodirac_flag_fx(
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate */
+ const Word16 sba_order /* i : Ambisonic (SBA) order */
)
{
- if ( sba_order > 1 && ivas_total_brate > IVAS_256k )
+ IF( GT_16( sba_order, 1 ) && GT_32( ivas_total_brate, IVAS_256k ) )
{
return 1;
}
- else
+ ELSE
{
return 0;
}
}
+#endif
-#ifdef IVAS_FLOAT_FIXED
-Word16 ivas_get_hodirac_flag_fx(
- const Word32 ivas_total_brate, /* i : IVAS total bitrate */
- const Word16 sba_order /* i : Ambisonic (SBA) order */
+int16_t ivas_get_hodirac_flag(
+ const int32_t ivas_total_brate, /* i : IVAS total bitrate */
+ const int16_t sba_order /* i : Ambisonic (SBA) order */
)
{
- IF( GT_16( sba_order, 1 ) && GT_32( ivas_total_brate, IVAS_256k ) )
+ if ( sba_order > 1 && ivas_total_brate > IVAS_256k )
{
return 1;
}
- ELSE
+ else
{
return 0;
}
}
-#endif
/*-------------------------------------------------------------------------
* ivas_dirac_sba_config()
*
@@ -118,14 +120,19 @@ ivas_error ivas_dirac_config_fx(
Word16 *dirac_to_spar_md_bands;
error = IVAS_ERR_OK;
+ move32();
- IF( EQ_16( enc_dec, ENC ) )
+ IF( enc_dec == ENC )
{
ivas_format = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->ivas_format;
+ move32();
element_mode = &( (Encoder_Struct *) st_ivas )->hEncoderConfig->element_mode_init;
sba_order = ( (Encoder_Struct *) st_ivas )->sba_analysis_order;
+ move16();
ivas_total_brate = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->ivas_total_brate;
+ move32();
Fs = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->input_Fs;
+ move32();
band_grouping = ( (Encoder_Struct *) st_ivas )->hDirAC->band_grouping;
hConfig = ( (Encoder_Struct *) st_ivas )->hDirAC->hConfig;
hQMetaData = ( (Encoder_Struct *) st_ivas )->hQMetaData;
@@ -145,8 +152,11 @@ ivas_error ivas_dirac_config_fx(
ivas_format = ( (Decoder_Struct *) st_ivas )->ivas_format;
element_mode = &( (Decoder_Struct *) st_ivas )->element_mode_init;
sba_order = ( (Decoder_Struct *) st_ivas )->sba_analysis_order;
+ move16();
ivas_total_brate = ( (Decoder_Struct *) st_ivas )->hDecoderConfig->ivas_total_brate;
+ move32();
Fs = ( (Decoder_Struct *) st_ivas )->hDecoderConfig->output_Fs;
+ move32();
band_grouping = ( (Decoder_Struct *) st_ivas )->hDirAC->band_grouping;
hConfig = ( (Decoder_Struct *) st_ivas )->hDirAC->hConfig;
hQMetaData = ( (Decoder_Struct *) st_ivas )->hQMetaData;
@@ -163,71 +173,90 @@ ivas_error ivas_dirac_config_fx(
( (Decoder_Struct *) st_ivas )->hDirAC->hFbMdft = hFbMdft;
}
- IF( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+ test();
+ IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
hConfig->nbands = IVAS_MAX_NUM_BANDS;
+ move16();
spar_dirac_split_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
- IF( ivas_get_hodirac_flag( ivas_total_brate, sba_order ) ) // add call after merge of 100861_dirac_dec
+ IF( ivas_get_hodirac_flag_fx( ivas_total_brate, sba_order ) ) // add call after merge of 100861_dirac_dec
{
spar_dirac_split_band = 0;
+ move16();
}
}
ELSE
{
hConfig->nbands = 5;
spar_dirac_split_band = 0;
+
+ move16();
+ move16();
}
hConfig->enc_param_start_band = 0;
hConfig->dec_param_estim = FALSE;
- IF( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) /* skip for MASA decoder */
+
+ move16();
+ move16();
+
+ test();
+ IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) /* skip for MASA decoder */
{
- IF( ( error = ivas_dirac_sba_config_fx( hQMetaData, element_mode, ivas_total_brate, sba_order, hConfig->nbands - spar_dirac_split_band,
- ivas_format ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_sba_config_fx( hQMetaData, element_mode, ivas_total_brate, sba_order, sub( hConfig->nbands, spar_dirac_split_band ),
+ ivas_format ) ),
+ IVAS_ERR_OK ) )
{
return error;
}
IF( hQMetaData != NULL )
{
- IF( enc_dec == ENC )
+ if ( enc_dec == ENC )
{
hConfig->nbands = hQMetaData->q_direction[0].cfg.nbands;
+ move16();
}
hConfig->enc_param_start_band = add( hQMetaData->q_direction[0].cfg.start_band, spar_dirac_split_band );
+ move16();
}
hConfig->dec_param_estim = TRUE;
- IF( hConfig->dec_param_estim == TRUE )
+ move16();
+ if ( EQ_16( hConfig->dec_param_estim, TRUE ) )
{
hConfig->enc_param_start_band = spar_dirac_split_band;
+ move16();
}
- IF( ivas_get_hodirac_flag( ivas_total_brate, sba_order ) )
+ IF( ivas_get_hodirac_flag_fx( ivas_total_brate, sba_order ) )
{
hConfig->dec_param_estim = FALSE;
hConfig->enc_param_start_band = 0;
- set_c( (int8_t *) hQMetaData->twoDirBands, (int8_t) 1, hQMetaData->q_direction[0].cfg.nbands );
- hQMetaData->numTwoDirBands = (uint8_t) hQMetaData->q_direction[0].cfg.nbands;
+ move16();
+ move16();
+
+ set_c( (Word8 *) hQMetaData->twoDirBands, (Word8) 1, hQMetaData->q_direction[0].cfg.nbands );
+ hQMetaData->numTwoDirBands = (UWord8) hQMetaData->q_direction[0].cfg.nbands;
}
}
- IF( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+ test();
+ IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
// 100861_dirac_dec
- ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft );
+ ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft );
}
ELSE
{
- ivas_dirac_config_bands( band_grouping, hConfig->nbands, (Word16) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), NULL, 0, 0, hFbMdft );
+ ivas_dirac_config_bands_fx( band_grouping, hConfig->nbands, (Word16) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), NULL, 0, 0, hFbMdft );
}
return error;
}
-#endif
-
+#else
ivas_error ivas_dirac_config(
void *st_ivas, /* i/o: IVAS encoder/decoder state structure */
const int16_t enc_dec /* i : encoder or decoder flag */
@@ -354,6 +383,7 @@ ivas_error ivas_dirac_config(
return error;
}
+#endif
/*-------------------------------------------------------------------------
@@ -362,6 +392,7 @@ ivas_error ivas_dirac_config(
* DirAC Configuration freq. band function; used also in MASA decoder
*------------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
void ivas_dirac_config_bands(
int16_t *band_grouping, /* o : band grouping */
const int16_t nbands, /* i : number of bands */
@@ -458,8 +489,7 @@ void ivas_dirac_config_bands(
return;
}
-
-#ifdef IVAS_FLOAT_FIXED
+#else
void ivas_dirac_config_bands_fx(
Word16 *band_grouping, /* o : band grouping */
const Word16 nbands, /* i : number of bands */
@@ -587,62 +617,89 @@ void ivas_get_dirac_sba_max_md_bits_fx(
const Word16 nbands,
IVAS_FORMAT ivas_format )
{
- IF( sba_total_brate <= IVAS_13k2 )
+ IF( LE_32( sba_total_brate, IVAS_13k2 ) )
{
*bits_frame_nominal = ACELP_9k60 / FRAMES_PER_SEC;
*metadata_max_bits = 70;
+
+ move16();
+ move16();
}
- ELSE IF( sba_total_brate <= IVAS_16k4 )
+ ELSE IF( LE_32( sba_total_brate, IVAS_16k4 ) )
{
*bits_frame_nominal = ACELP_13k20 / FRAMES_PER_SEC;
*metadata_max_bits = 80;
+
+ move16();
+ move16();
}
- ELSE IF( sba_total_brate <= IVAS_24k4 )
+ ELSE IF( LE_32( sba_total_brate, IVAS_24k4 ) )
{
*bits_frame_nominal = ACELP_16k40 / FRAMES_PER_SEC;
*metadata_max_bits = 103;
+
+ move16();
+ move16();
/* OSBA needs an additional 2-bits safety margin to avoid acelp crashes */
- IF( ivas_format == SBA_ISM_FORMAT )
+ IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
( *metadata_max_bits ) = sub( ( *metadata_max_bits ), 3 );
+ move16();
}
}
- ELSE IF( sba_total_brate <= IVAS_32k )
+ ELSE IF( LE_32( sba_total_brate, IVAS_32k ) )
{
*bits_frame_nominal = ACELP_32k / FRAMES_PER_SEC;
*metadata_max_bits = 214;
+
+ move16();
+ move16();
}
- ELSE IF( sba_total_brate <= IVAS_48k )
+ ELSE IF( LE_32( sba_total_brate, IVAS_48k ) )
{
*bits_frame_nominal = IVAS_48k / FRAMES_PER_SEC;
*metadata_max_bits = 240;
+
+ move16();
+ move16();
}
- ELSE IF( sba_total_brate <= IVAS_64k )
+ ELSE IF( LE_32( sba_total_brate, IVAS_64k ) )
{
*bits_frame_nominal = IVAS_64k / FRAMES_PER_SEC;
*metadata_max_bits = 200;
+
+ move16();
+ move16();
}
- ELSE IF( sba_total_brate <= IVAS_80k )
+ ELSE IF( LE_32( sba_total_brate, IVAS_80k ) )
{
*bits_frame_nominal = IVAS_80k / FRAMES_PER_SEC;
*metadata_max_bits = 200;
+
+ move16();
+ move16();
}
- ELSE IF( sba_total_brate <= IVAS_96k )
+ ELSE IF( LE_32( sba_total_brate, IVAS_96k ) )
{
*bits_frame_nominal = IVAS_96k / FRAMES_PER_SEC;
*metadata_max_bits = 200;
+
+ move16();
+ move16();
}
- ELSE IF( sba_total_brate <= IVAS_128k )
+ ELSE IF( LE_32( sba_total_brate, IVAS_128k ) )
{
*bits_frame_nominal = IVAS_128k / FRAMES_PER_SEC;
*metadata_max_bits = 250;
+
+ move16();
+ move16();
}
ELSE
{
- //*bits_frame_nominal = (int16_t) ( sba_total_brate / FRAMES_PER_SEC );
- Word16 tmp_exp = 0, tmp;
- tmp = BASOP_Util_Divide3232_Scale( sba_total_brate, FRAMES_PER_SEC, &tmp_exp );
- *bits_frame_nominal = shr( tmp, 15 - tmp_exp );
+ /* *bits_frame_nominal = (int16_t) ( sba_total_brate / FRAMES_PER_SEC ); */
+ *bits_frame_nominal = extract_l( Mpy_32_32( sba_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+ move16();
*metadata_max_bits = MAX16B; /* no limit */
}
Word32 var1 = L_mult0( *metadata_max_bits, nbands );
@@ -651,6 +708,9 @@ void ivas_get_dirac_sba_max_md_bits_fx(
Word32 var2_32 = L_deposit_h( var2 );
Word32 var4 = var2_32;
+ move16();
+ move32();
+
Word16 exp_res = 0;
IF( var1 % 5 != 0 )
{
@@ -659,23 +719,28 @@ void ivas_get_dirac_sba_max_md_bits_fx(
}
Word16 flag = BASOP_Util_Cmp_Mant32Exp( MAX16B, 31, var4, exp );
Word32 tmp;
- if ( flag == 1 )
+ IF( EQ_16( flag, 1 ) )
{
tmp = var4;
+ move32();
}
- else
+ ELSE
{
tmp = MAX16B;
exp = 31;
+
+ move32();
+ move16();
}
*metadata_max_bits = (Word16) L_shr( tmp, 31 - exp );
- ;
*qmetadata_max_bit_req = QMETADATA_MAXBIT_REQ_SBA >> 1;
+ move16();
+ move16();
+
return;
}
-#endif
-
+#else
void ivas_get_dirac_sba_max_md_bits(
const int32_t sba_total_brate,
int16_t *bits_frame_nominal,
@@ -744,6 +809,7 @@ void ivas_get_dirac_sba_max_md_bits(
return;
}
+#endif
/*-------------------------------------------------------------------------
* ivas_dirac_sba_config()
@@ -767,12 +833,19 @@ ivas_error ivas_dirac_sba_config_fx(
Word32 tmp1 = IVAS_192k;
Word32 tmp2 = SPAR_DIRAC_SPLIT_START_BAND;
Word16 exp = 0;
+
+ move32();
+ move32();
+ move16();
Word16 tmp3 = BASOP_Util_Divide3232_Scale( tmp1, tmp2, &exp );
- Word32 res = L_shr( L_deposit_h( tmp3 ), 31 - exp );
+ Word32 res = L_shr( L_deposit_h( tmp3 ), sub( 31, exp ) );
error = IVAS_ERR_OK;
hQMetaData->is_masa_ivas_format = 0;
- hodirac_flag = ivas_get_hodirac_flag( sba_total_brate, sba_order ); // implemented on 100861_dirac_dec
+ move32();
+ move16();
+
+ hodirac_flag = ivas_get_hodirac_flag_fx( sba_total_brate, sba_order ); // implemented on 100861_dirac_dec
/* map the bitrate for SID frame */
IF( EQ_32( sba_total_brate, IVAS_SID_5k2 ) )
@@ -780,10 +853,12 @@ ivas_error ivas_dirac_sba_config_fx(
IF( EQ_16( *element_mode, IVAS_SCE ) )
{
sba_total_brate = ACELP_24k40;
+ move32();
}
ELSE
{
sba_total_brate = ACELP_48k;
+ move32();
}
}
@@ -792,10 +867,12 @@ ivas_error ivas_dirac_sba_config_fx(
IF( LE_32( sba_total_brate, IVAS_16k4 ) )
{
hQMetaData->useLowerRes = 1;
+ move16();
}
ELSE
{
hQMetaData->useLowerRes = 0;
+ move16();
}
nbands_coded = nbands;
@@ -804,25 +881,31 @@ ivas_error ivas_dirac_sba_config_fx(
{
hQMetaData->useLowerBandRes = 1;
Word16 tmp = nbands % 2;
+
+ move16();
+ move16();
nbands_coded = add( shr( nbands, 1 ), tmp );
}
ELSE
{
hQMetaData->useLowerBandRes = 0;
+ move16();
IF( hodirac_flag == 0 )
{
- nbands_coded = nbands - 1; /* always combine the last two bands */
+ nbands_coded = sub( nbands, 1 ); /* always combine the last two bands */
}
}
{
Word16 no_dirs = 1;
+ move16();
IF( hodirac_flag )
{
no_dirs = 2;
+ move16();
}
- IF( ( error = ivas_qmetadata_allocate_memory( hQMetaData, nbands_coded, no_dirs, 0 ) ) != IVAS_ERR_OK ) // WIP
+ IF( NE_32( ( error = ivas_qmetadata_allocate_memory( hQMetaData, nbands_coded, no_dirs, 0 ) ), IVAS_ERR_OK ) ) // WIP
{
return error;
}
@@ -833,8 +916,7 @@ ivas_error ivas_dirac_sba_config_fx(
return error;
}
-#endif
-
+#else
ivas_error ivas_dirac_sba_config(
IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
int16_t *element_mode, /* i/o: element mode of the core coder */
@@ -909,6 +991,7 @@ ivas_error ivas_dirac_sba_config(
return error;
}
+#endif
#ifdef IVAS_FLOAT_FIXED
@@ -931,7 +1014,7 @@ void computeDirectionVectors_fixed(
Word16 norm_x, norm_y, norm_z;
Word32 scaled_x, scaled_y, scaled_z;
Word16 e_x, e_y, e_z;
- for ( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i )
+ FOR( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i )
{
norm_x = norm_l( *intensity_real_x );
norm_y = norm_l( *intensity_real_y );
@@ -939,9 +1022,9 @@ 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 );
- e_x = i_e - norm_x;
- e_y = i_e - norm_y;
- e_z = i_e - norm_z;
+ e_x = sub( i_e, norm_x );
+ e_y = sub( i_e, norm_y );
+ e_z = sub( i_e, norm_z );
temp1 = BASOP_Util_Add_Mant32Exp( Mult_32_32( scaled_x, scaled_x ), 2 * e_x, Mult_32_32( scaled_y, scaled_y ), 2 * e_y, &exp1 );
intensityNorm = BASOP_Util_Add_Mant32Exp( temp1, exp1, Mult_32_32( scaled_z, scaled_z ), 2 * e_z, &intensityNorm_e );
@@ -951,6 +1034,10 @@ void computeDirectionVectors_fixed(
*( direction_vector_x++ ) = ONE_IN_Q30;
*( direction_vector_y++ ) = 0;
*( direction_vector_z++ ) = 0;
+
+ move32();
+ move32();
+ move32();
intensity_real_x++;
intensity_real_y++;
intensity_real_z++;
@@ -964,6 +1051,10 @@ void computeDirectionVectors_fixed(
intensity_real_y++;
*( direction_vector_z++ ) = L_shl( Mult_32_32( scaled_z, intensityNorm ), e_z + intensityNorm_e - 1 ); /*Q30*/
intensity_real_z++;
+
+ move32();
+ move32();
+ move32();
}
}
@@ -990,48 +1081,55 @@ void computeDirectionVectors_fx(
Word16 i;
Word32 intensityNorm;
- Word16 sq = 31 - ( 2 * ( *i_q ) - 31 );
- Word16 sq1 = ( 2 * ( *i_q ) - 31 );
+ Word16 sq = sub( 31, sub( 2 * ( *i_q ), 31 ) );
+ Word16 sq1 = sub( 2 * ( *i_q ), 31 );
Word16 exp = sq;
Word16 local_i_q = sq1;
Word16 min_factor = 30;
+
+ move16();
+ move16();
+ move16();
+
Word32 *init_x = intensity_real_x;
Word32 *init_y = intensity_real_y;
Word32 *init_z = intensity_real_z;
// First loop to determine the Q for the direction vector
- for ( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i )
+ FOR( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i )
{
intensityNorm = L_add( L_add( Mpy_32_32_r( *( intensity_real_x ), *( intensity_real_x ) ),
Mpy_32_32_r( *( intensity_real_y ), *( intensity_real_y ) ) ),
Mpy_32_32_r( *( intensity_real_z ), *( intensity_real_z ) ) ); /*Q (2*i_q - 31) */
exp = sq;
- if ( intensityNorm <= EPSILON_FX )
+ move16();
+ IF( LE_32( intensityNorm, EPSILON_FX ) )
{
intensity_real_x++;
intensity_real_y++;
intensity_real_z++;
}
- else
+ ELSE
{
intensityNorm = ISqrt32( intensityNorm, &exp ); // Q31-exp
intensity_real_x++; // i_q + Q31-exp -31 = i_q -exp
intensity_real_y++; // i_q + Q31-exp -31 = i_q -exp
intensity_real_z++; // i_q + Q31-exp-31 = i_q -exo
- local_i_q = *i_q - exp;
- min_factor = min( min_factor, local_i_q );
+ local_i_q = sub( *i_q, exp );
+ min_factor = s_min( min_factor, local_i_q );
}
}
intensity_real_x = init_x;
intensity_real_y = init_y;
intensity_real_z = init_z;
// Actual processing loop for the direction vector
- for ( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i )
+ FOR( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i )
{
intensityNorm = L_add( L_add( Mpy_32_32_r( *( intensity_real_x ), *( intensity_real_x ) ),
Mpy_32_32_r( *( intensity_real_y ), *( intensity_real_y ) ) ),
Mpy_32_32_r( *( intensity_real_z ), *( intensity_real_z ) ) ); /*Q (2*i_q - 31) */
exp = sq;
- if ( intensityNorm <= EPSILON_FX )
+ move16();
+ IF( LE_32( intensityNorm, EPSILON_FX ) )
{
intensityNorm = L_shl( 1, min_factor );
*( direction_vector_x++ ) = L_shl( 1, min_factor );
@@ -1040,8 +1138,12 @@ void computeDirectionVectors_fx(
intensity_real_x++;
intensity_real_y++;
intensity_real_z++;
+
+ move32();
+ move32();
+ move32();
}
- else
+ ELSE
{
intensityNorm = ISqrt32( intensityNorm, &exp ); // Q31-exp
Word32 temp = L_shr( Mpy_32_32( *( intensity_real_x++ ), intensityNorm ), ( *i_q - exp - min_factor ) );
@@ -1050,9 +1152,14 @@ void computeDirectionVectors_fx(
*( direction_vector_y++ ) = temp; // i_q + Q31-exp -31 = i_q -exp
temp = L_shr( Mpy_32_32( *( intensity_real_z++ ), intensityNorm ), ( *i_q - exp - min_factor ) );
*( direction_vector_z++ ) = temp; // i_q + Q31-exp-31 = i_q -exp
+
+ move32();
+ move32();
+ move32();
}
}
*i_q = min_factor;
+ move16();
return;
}
#endif
@@ -1125,6 +1232,7 @@ void computeDiffuseness_fx(
Word32 energy_slow[CLDFB_NO_CHANNELS_MAX];
Word16 i, j, k;
Word32 tmp = 0, tmp_1;
+ move32();
Word32 *p_tmp;
const Word32 *p_tmp_c;
@@ -1134,58 +1242,83 @@ void computeDiffuseness_fx(
set_val_Word32( intensity_slow_abs, 0, CLDFB_NO_CHANNELS_MAX );
set_val_Word32( energy_slow, 0, CLDFB_NO_CHANNELS_MAX );
- for ( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i )
+ FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i )
{
/* Energy slow */
p_tmp_c = buffer_energy + i * num_freq_bands;
- for ( k = 0; k < num_freq_bands; k++ )
+ FOR( k = 0; k < num_freq_bands; k++ )
{
energy_slow[k] = L_add( *( p_tmp_c++ ), energy_slow[k] ); // Q(q_factor_energy)
+ move32();
}
/* Intensity slow */
- for ( j = 0; j < DIRAC_NUM_DIMS; ++j )
+ FOR( j = 0; j < DIRAC_NUM_DIMS; ++j )
{
p_tmp = buffer_intensity[j][i];
- for ( k = 0; k < num_freq_bands; k++ )
+ FOR( k = 0; k < num_freq_bands; k++ )
{
intensity_slow[j * num_freq_bands + k] = L_add( *( p_tmp++ ), intensity_slow[j * num_freq_bands + k] );
+ move32();
}
}
}
/* intensity_slow.^2 + intensity_slow_abs*/
- for ( j = 0; j < DIRAC_NUM_DIMS; ++j )
+ FOR( j = 0; j < DIRAC_NUM_DIMS; ++j )
{
- p_tmp = intensity_slow + j * num_freq_bands;
+ p_tmp = intensity_slow + imult1616( j, num_freq_bands );
- for ( k = 0; k < num_freq_bands; k++ )
+ FOR( k = 0; k < num_freq_bands; k++ )
{
*( p_tmp ) = Mpy_32_32( *p_tmp, *( p_tmp ) ); // Q( 2*(q_factor_intensity + scale_fact - 1) -31 )
intensity_slow_abs[k] = L_add( *( p_tmp++ ), intensity_slow_abs[k] );
+ move32();
+ move32();
}
}
- Word16 init_exp = 31 - ( ( 2 * ( q_factor_intensity ) ) - 31 ), exp;
+ Word16 init_exp = sub( 31, sub( ( ( 2 * ( q_factor_intensity ) ) ), 31 ) ), exp;
Word16 exp1 = 0, exp2;
+ move16();
/* Compute Diffuseness */
p_tmp = intensity_slow_abs;
- for ( i = 0; i < num_freq_bands; ++i )
+ FOR( i = 0; i < num_freq_bands; ++i )
{
exp = init_exp;
Word32 temp = *( p_tmp++ );
+ move32();
tmp_1 = Sqrt32( temp, &exp );
tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp_1, L_add( energy_slow[i], 1 ), &exp1 ) );
- exp2 = 31 - exp1 + ( 31 - exp - q_factor_energy );
- if ( exp2 > 30 )
+ exp2 = add( sub( 31, exp1 ), sub( sub( 31, exp ), q_factor_energy ) );
+ IF( GT_32( exp2, 30 ) )
{
- tmp = L_shr( tmp, ( exp2 - 30 ) );
- exp2 -= ( exp2 - 30 );
+ tmp = L_shr( tmp, sub( exp2, 30 ) );
+ exp2 = sub( exp2, sub( exp2, 30 ) );
}
tmp = L_sub( L_shl( 1, exp2 ), tmp );
- diffuseness[i] = ( ( tmp < L_shl( 1, exp2 ) ) ? ( ( tmp < 0 ) ? 0 : tmp ) : L_shl( 1, exp2 ) );
+ // diffuseness[i] = ( ( tmp < L_shl( 1, exp2 ) ) ? ( ( tmp < 0 ) ? 0 : tmp ) : L_shl( 1, exp2 ) );
+
+ IF( LT_32( tmp, L_shl( 1, exp2 ) ) )
+ {
+ IF( tmp < 0 )
+ {
+ diffuseness[i] = 0;
+ }
+ ELSE
+ {
+ diffuseness[i] = tmp;
+ }
+ }
+ ELSE
+ {
+ diffuseness[i] = L_shl( 1, exp2 );
+ }
out_exp[i] = exp2;
+
+ move32();
+ move16();
}
return;
}
@@ -1317,7 +1450,7 @@ void computeDiffuseness_fixed(
tmp = Sqrt32( p_tmp[i], &exp1 );
tmp = BASOP_Util_Divide3232_Scale_cadence( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 );
- q_tmp = sub( 31, exp2 ) + sub( sub( 31, exp1 ), q_ene );
+ q_tmp = add( sub( 31, exp2 ), sub( sub( 31, exp1 ), q_ene ) );
IF( LT_16( q_tmp, Q30 ) )
{
@@ -1327,6 +1460,7 @@ void computeDiffuseness_fixed(
{
tmp = L_sub( ONE_IN_Q30, L_shr( tmp, sub( q_tmp, Q30 ) ) );
q_tmp = Q30;
+ move16();
}
IF( GE_32( tmp, L_shl( 1, q_tmp ) ) )
@@ -1334,7 +1468,7 @@ void computeDiffuseness_fixed(
diffuseness[i] = ONE_IN_Q30;
move32();
}
- ELSE IF( LE_32( tmp, 0 ) )
+ ELSE IF( tmp <= 0 )
{
diffuseness[i] = 0;
move32();
@@ -1496,9 +1630,10 @@ Word32 deindex_azimuth_fx(
test();
IF( NE_32( mc_format, MC_LS_SETUP_INVALID ) && EQ_16( no_bits, 2 ) )
{
- IF( EQ_16( s_and( id_phi, 1 ), 0 ) )
+ IF( s_and( id_phi, 1 ) == 0 )
{
phi_hat_fx = cb_azi_chan_fx[shr( id_phi, 1 )];
+ move32();
}
ELSE
{
@@ -1506,7 +1641,7 @@ Word32 deindex_azimuth_fx(
}
return phi_hat_fx;
}
- flag_delta = (Word16) EQ_16( s_and( id_th, 1 ), 1 );
+ flag_delta = extract_l( EQ_16( s_and( id_th, 1 ), 1 ) );
IF( remap )
{
@@ -1623,9 +1758,11 @@ void deindex_spherical_component_fx(
*az_idx = sph_idx;
move16();
*az_fx = deindex_azimuth_fx( *az_idx, no_bits, 0, 0, mc_format );
+ move16();
BREAK;
default:
*el_idx = deindex_sph_idx_general_fx( sph_idx, no_bits, el_fx, az_fx, az_idx, mc_format );
+ move16();
BREAK;
}
@@ -2058,14 +2195,15 @@ static UWord16 deindex_sph_idx_general_fx(
}
}
- IF( EQ_32( id_th, 0 ) )
+ IF( id_th == 0 )
{
id_phi = idx_sph;
move16();
}
ELSE
{
- IF( EQ_32( id_th, sub( no_th, 1 ) ) && GT_16( no_bits, 4 ) )
+ test();
+ if ( EQ_32( id_th, sub( no_th, 1 ) ) && GT_16( no_bits, 4 ) )
{
id_phi = 0;
move16();
@@ -2075,10 +2213,12 @@ static UWord16 deindex_sph_idx_general_fx(
q_id_th = norm_l( id_th );
id_th_fx = L_shl( id_th, q_id_th );
*theta_dec_fx = L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[no_bits - 3] ), sub( 31, q_id_th ) );
+ move32();
- IF( GE_32( *theta_dec_fx, L_shl( 90, Q22 ) ) )
+ IF( GE_32( *theta_dec_fx, 90 << Q22 ) )
{
- *theta_dec_fx = L_shl( 90, 22 ) * sign_theta;
+ *theta_dec_fx = 90 << 22 * sign_theta;
+ move32();
*phi_dec_fx = 0;
move32();
*p_id_phi = 0;
@@ -2089,6 +2229,7 @@ static UWord16 deindex_sph_idx_general_fx(
*theta_dec_fx *= sign_theta;
*phi_dec_fx = deindex_azimuth_fx( id_phi, no_bits, id_th, 0, mc_format );
+ move32();
*p_id_phi = id_phi;
move16();
}
diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c
index 749952dfd80089c2c26fe01526bb1ef9b28f96d2..d448ed8de3145b38abc0906cd2c5fa9548568ea2 100644
--- a/lib_com/ivas_fb_mixer.c
+++ b/lib_com/ivas_fb_mixer.c
@@ -39,8 +39,10 @@
#include
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*------------------------------------------------------------------------------------------*
@@ -54,7 +56,7 @@ static void ivas_get_ld_fb_resp_fx( Word32 **ppIdeal_FRs_re_fx, Word32 **ppIdeal
#endif
static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate );
#ifdef IVAS_FLOAT_FIXED
-static ivas_error ivas_filterbank_setup_fx( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate, Word16 *index );
+static ivas_error ivas_filterbank_setup_fx( IVAS_FB_MIXER_HANDLE hFbMixer, const Word32 sampling_rate, Word16 *index );
#endif
static ivas_error ivas_fb_mixer_get_window( const int16_t fade_len, const int32_t sampling_rate, const float **pWindow );
#ifdef IVAS_FLOAT_FIXED
@@ -62,6 +64,7 @@ static ivas_error ivas_fb_mixer_get_window_fx( const Word16 fade_len, const Word
#endif
+#ifdef IVAS_FLOAT_FIXED
/*-----------------------------------------------------------------------------------------*
* Function ivas_get_num_bands_from_bw_idx()
*
@@ -69,7 +72,6 @@ static ivas_error ivas_fb_mixer_get_window_fx( const Word16 fade_len, const Word
*-----------------------------------------------------------------------------------------*/
/*! r: number of spectral bands */
-#ifdef IVAS_FLOAT_FIXED
Word16 ivas_get_num_bands_from_bw_idx(
const Word16 bwidth /* i : audio bandwidth */
)
@@ -77,11 +79,19 @@ Word16 ivas_get_num_bands_from_bw_idx(
Word16 num_active_bands;
assert( bwidth > 0 ); /*NB BW is not supported*/
- num_active_bands = ivas_num_active_bands[bwidth - 1];
+ num_active_bands = ivas_num_active_bands[sub( bwidth, 1 )];
+ move16();
return num_active_bands;
}
#else
+/*-----------------------------------------------------------------------------------------*
+ * Function ivas_get_num_bands_from_bw_idx()
+ *
+ * Get number of bands from BW index
+ *-----------------------------------------------------------------------------------------*/
+
+/*! r: number of spectral bands */
int16_t ivas_get_num_bands_from_bw_idx(
const int16_t bwidth /* i : audio bandwidth */
)
@@ -95,6 +105,7 @@ int16_t ivas_get_num_bands_from_bw_idx(
}
#endif
+
/*-----------------------------------------------------------------------------------------*
* Function ivas_get_num_bands()
*
@@ -105,7 +116,11 @@ int16_t ivas_get_num_bands_from_bw_idx(
static Word16 ivas_get_num_bands(
const Word32 sampling_rate )
{
+#ifdef IVAS_FLOAT_FIXED
+ Word16 bwidth = ivas_get_bw_idx_from_sample_rate_fx( sampling_rate );
+#else
Word16 bwidth = ivas_get_bw_idx_from_sample_rate( sampling_rate );
+#endif
Word16 num_active_bands = ivas_get_num_bands_from_bw_idx( bwidth );
return num_active_bands;
@@ -154,31 +169,54 @@ ivas_error ivas_fb_set_cfg(
pFb_cfg->active_w_mixing = active_w_mixing;
pFb_cfg->windowed_fr_offset = 0;
- IF( ivas_format == ISM_FORMAT )
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+
+ IF( EQ_16( ivas_format, ISM_FORMAT ) )
{
pFb_cfg->fb_latency = NS2SA( sampling_rate, DELAY_FB_4_NS );
pFb_cfg->fade_len = NS2SA( sampling_rate, DELAY_FB_4_NS );
pFb_cfg->prior_input_length = NS2SA( sampling_rate, DELAY_DIRAC_ENC_CMP_NS_PARAM_ISM ) + NS2SA( sampling_rate, DIRAC_SLOT_ENC_NS );
+
+ move16();
+ move16();
+ move16();
}
- ELSE IF( ivas_format == SBA_FORMAT )
+ ELSE IF( EQ_16( ivas_format, SBA_FORMAT ) )
{
pFb_cfg->fb_latency = NS2SA( sampling_rate, DELAY_FB_1_NS );
pFb_cfg->fade_len = NS2SA( sampling_rate, DELAY_FB_4_NS );
pFb_cfg->prior_input_length = NS2SA( sampling_rate, FRAME_SIZE_NS );
pFb_cfg->windowed_fr_offset = (Word16) ( (float) ( sampling_rate / FRAMES_PER_SEC ) * 3.0f / 4.0f ) - NS2SA( sampling_rate, DELAY_DIRAC_SPAR_ENC_CMP_NS );
+
+ move16();
+ move16();
+ move16();
}
- ELSE IF( ivas_format == MASA_FORMAT )
+ ELSE IF( EQ_16( ivas_format, MASA_FORMAT ) )
{
pFb_cfg->fb_latency = NS2SA( sampling_rate, DELAY_FB_1_NS );
pFb_cfg->fade_len = NS2SA( sampling_rate, DELAY_FB_1_NS );
pFb_cfg->prior_input_length = NS2SA( sampling_rate, DELAY_DIRAC_ENC_CMP_NS ) + NS2SA( sampling_rate, DIRAC_SLOT_ENC_NS );
+
+ move16();
+ move16();
+ move16();
}
- ELSE IF( ivas_format == MC_FORMAT )
+ ELSE IF( EQ_16( ivas_format, MC_FORMAT ) )
{
pFb_cfg->fb_latency = NS2SA( sampling_rate, DELAY_FB_1_NS );
pFb_cfg->fade_len = NS2SA( sampling_rate, DELAY_FB_1_NS );
pFb_cfg->prior_input_length = NS2SA( sampling_rate, DELAY_DIRAC_ENC_CMP_NS ) + NS2SA( sampling_rate, PARAM_MC_SLOT_ENC_NS );
+
+ move16();
+ move16();
+ move16();
}
*pFb_cfg_out = pFb_cfg;
@@ -455,13 +493,15 @@ ivas_error ivas_FB_mixer_open_fx(
)
{
IVAS_FB_MIXER_HANDLE hFbMixer;
- int16_t i, j, frame_len, num_bands;
- int16_t num_chs_alloc;
+ Word16 i, j, frame_len, num_bands;
+ Word16 num_chs_alloc, exp;
ivas_error error;
error = IVAS_ERR_OK;
+ move32();
- frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC );
+ frame_len = BASOP_Util_Divide3232_Scale( sampling_rate, FRAMES_PER_SEC, &exp );
+ frame_len = shr( frame_len, sub( 15, exp ) );
hFbMixer = *hFbMixer_out;
@@ -485,18 +525,19 @@ ivas_error ivas_FB_mixer_open_fx(
}
}
- IF( fb_cfg->active_w_mixing == -1 )
+ IF( EQ_16( fb_cfg->active_w_mixing, -1 ) )
{
num_chs_alloc = 0;
move16();
}
ELSE IF( fb_cfg->active_w_mixing )
{
- num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in );
+ num_chs_alloc = s_max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in );
}
ELSE
{
num_chs_alloc = 1; /* only W channel processed for predicting YZX */
+ move16();
}
#ifndef IVAS_FLOAT_FIXED /////////////////////////////// FLOAT ///////////////////////////////////////////////
@@ -523,23 +564,23 @@ ivas_error ivas_FB_mixer_open_fx(
}
}
#else
- for ( i = 0; i < num_chs_alloc; i++ )
+ FOR( i = 0; i < num_chs_alloc; i++ )
{
- if ( fb_cfg->num_out_chans == 0 )
+ IF( fb_cfg->num_out_chans == 0 )
{
hFbMixer->ppFilterbank_inFR_re_fx[i] = NULL;
hFbMixer->ppFilterbank_inFR_im_fx[i] = NULL;
}
- else
+ ELSE
{
j = fb_cfg->remix_order[i];
- if ( ( hFbMixer->ppFilterbank_inFR_re_fx[j] = (Word32 *) malloc( sizeof( Word32 ) * frame_len ) ) == NULL )
+ IF( ( hFbMixer->ppFilterbank_inFR_re_fx[j] = (Word32 *) malloc( sizeof( Word32 ) * frame_len ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
}
- if ( ( hFbMixer->ppFilterbank_inFR_im_fx[j] = (Word32 *) malloc( sizeof( Word32 ) * frame_len ) ) == NULL )
+ IF( ( hFbMixer->ppFilterbank_inFR_im_fx[j] = (Word32 *) malloc( sizeof( Word32 ) * frame_len ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
}
@@ -547,14 +588,14 @@ ivas_error ivas_FB_mixer_open_fx(
}
#endif
- IF( fb_cfg->active_w_mixing == -1 )
+ IF( EQ_16( fb_cfg->active_w_mixing, -1 ) )
{
num_chs_alloc = 0;
move16();
}
ELSE
{
- num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in );
+ num_chs_alloc = s_max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in );
}
#ifndef IVAS_FLOAT_FIXED //////////////////////////// Float //////////////////////////////////////
@@ -577,7 +618,8 @@ ivas_error ivas_FB_mixer_open_fx(
}
#endif
- IF( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->num_out_chans > 0 ) )
+ test();
+ IF( ( NE_16( fb_cfg->active_w_mixing, -1 ) ) && ( fb_cfg->num_out_chans > 0 ) )
{
#ifndef IVAS_FLOAT_FIXED ////////////////////////////////////////// FLOAT //////////////////////////////////////////////////////
float *pTemp_mem;
@@ -616,13 +658,13 @@ ivas_error ivas_FB_mixer_open_fx(
{
IF( fb_cfg->num_out_chans > 0 )
{
- const int16_t *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs;
+ const Word16 *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs;
num_bands = ivas_get_num_bands( sampling_rate );
ivas_get_active_bins( &pActive_bins_per_band, &pActive_bins_per_band_abs, &pStart_offset, &pStart_offset_abs, sampling_rate );
- IF( fb_cfg->active_w_mixing != -1 )
+ IF( NE_16( fb_cfg->active_w_mixing, -1 ) )
{
FOR( i = 0; i < num_bands; i++ )
{
@@ -639,16 +681,18 @@ ivas_error ivas_FB_mixer_open_fx(
}
}
- IF( sampling_rate != 48000 )
+ IF( NE_32( sampling_rate, 48000 ) )
{
- int16_t num_diff_bands, start_diff_band_non48k;
+ Word16 num_diff_bands, start_diff_band_non48k;
num_diff_bands = MAX_NUM_BANDS_DIFF_NON48K;
- start_diff_band_non48k = num_bands - num_diff_bands;
+ move16();
+ start_diff_band_non48k = sub( num_bands, num_diff_bands );
hFbMixer->num_diff_bands = num_diff_bands;
+ move16();
- for ( j = start_diff_band_non48k; j < num_bands; j++ )
+ FOR( j = start_diff_band_non48k; j < num_bands; j++ )
{
#if 0 ////////////////////////////////// FLOAT ////////////////////////
if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL )
@@ -683,9 +727,9 @@ ivas_error ivas_FB_mixer_open_fx(
hFbMixer->fb_cfg = fb_cfg;
set_s( hFbMixer->first_frame, 1, hFbMixer->fb_cfg->num_out_chans );
- set_s( hFbMixer->first_frame + hFbMixer->fb_cfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - hFbMixer->fb_cfg->num_out_chans );
+ set_s( hFbMixer->first_frame + hFbMixer->fb_cfg->num_out_chans, 0, sub( IVAS_SPAR_MAX_CH, hFbMixer->fb_cfg->num_out_chans ) );
- if ( !spar_reconfig_flag )
+ IF( !spar_reconfig_flag )
{
#ifdef IVAS_FLOAT_FIXED
#if 1 /*********************Intermediate Conversion that needs to remove *****************************/
@@ -710,7 +754,7 @@ ivas_error ivas_FB_mixer_open_fx(
// }
/************************************* Float table is gettin assigned here **************************************/
- if ( ( error = ivas_fb_mixer_get_window( hFbMixer->fb_cfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_fb_mixer_get_window( hFbMixer->fb_cfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade ) ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -765,7 +809,7 @@ ivas_error ivas_FB_mixer_open_fx(
set16_fx( index, 0, IVAS_MAX_NUM_FB_BANDS );
#endif /*********************Intermediate Conversion that needs to remove *****************************/
- IF( ( error = ivas_filterbank_setup_fx( hFbMixer, sampling_rate, index ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_filterbank_setup_fx( hFbMixer, sampling_rate, index ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -863,6 +907,7 @@ ivas_error ivas_FB_mixer_open_fx(
* Deallocate FB mixer handle
*------------------------------------------------------------------------*/
+
void ivas_FB_mixer_close(
IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */
const int32_t sampling_rate, /* i : sampling rate in Hz */
@@ -995,32 +1040,35 @@ void ivas_FB_mixer_close(
return;
}
+
#ifdef IVAS_FLOAT_FIXED
void ivas_FB_mixer_close_fx(
IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */
- const int32_t sampling_rate, /* i : sampling rate in Hz */
- const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */
+ const Word32 sampling_rate, /* i : sampling rate in Hz */
+ const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */
)
{
IVAS_FB_MIXER_HANDLE hFbMixer;
IVAS_FB_CFG *fb_cfg;
- int16_t i, j, num_bands;
- int16_t num_chs_alloc;
+ Word16 i, j, num_bands;
+ Word16 num_chs_alloc;
hFbMixer = *hFbMixer_in;
fb_cfg = hFbMixer->fb_cfg;
- IF( fb_cfg->active_w_mixing == -1 )
+ IF( EQ_16( fb_cfg->active_w_mixing, -1 ) )
{
num_chs_alloc = 0;
+ move16();
}
ELSE IF( fb_cfg->active_w_mixing )
{
- num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in );
+ num_chs_alloc = s_max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in );
}
ELSE
{
num_chs_alloc = 1; /* only W channel processed for predicting YZX */
+ move16();
}
IF( hFbMixer != NULL )
@@ -1030,6 +1078,7 @@ void ivas_FB_mixer_close_fx(
IF( fb_cfg->num_out_chans > 0 )
{
j = fb_cfg->remix_order[i];
+ move16();
free( hFbMixer->ppFilterbank_inFR_re_fx[j] );
hFbMixer->ppFilterbank_inFR_re_fx[j] = NULL;
@@ -1039,13 +1088,14 @@ void ivas_FB_mixer_close_fx(
}
}
- IF( fb_cfg->active_w_mixing == -1 )
+ IF( EQ_16( fb_cfg->active_w_mixing, -1 ) )
{
num_chs_alloc = 0;
+ move16();
}
ELSE
{
- num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in );
+ num_chs_alloc = s_max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in );
}
FOR( i = 0; i < num_chs_alloc; i++ )
@@ -1054,7 +1104,8 @@ void ivas_FB_mixer_close_fx(
hFbMixer->ppFilterbank_prior_input_fx[i] = NULL;
}
- IF( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->num_out_chans > 0 ) )
+ test();
+ IF( NE_16( fb_cfg->active_w_mixing, -1 ) && ( fb_cfg->num_out_chans > 0 ) )
{
free( hFbMixer->prior_mixer_fx[0][0] );
hFbMixer->prior_mixer_fx[0][0] = NULL;
@@ -1066,7 +1117,7 @@ void ivas_FB_mixer_close_fx(
{
num_bands = hFbMixer->pFb->filterbank_num_bands;
- IF( fb_cfg->active_w_mixing != -1 )
+ IF( NE_16( fb_cfg->active_w_mixing, -1 ) )
{
FOR( i = 0; i < num_bands; i++ )
{
@@ -1075,10 +1126,10 @@ void ivas_FB_mixer_close_fx(
}
}
- IF( sampling_rate != 48000 )
+ IF( NE_32( sampling_rate, 48000 ) )
{
- int16_t start_diff_band_non48k;
- start_diff_band_non48k = num_bands - hFbMixer->num_diff_bands;
+ Word16 start_diff_band_non48k;
+ start_diff_band_non48k = sub( num_bands, hFbMixer->num_diff_bands );
FOR( j = start_diff_band_non48k; j < num_bands; j++ )
{
@@ -1113,7 +1164,6 @@ void ivas_FB_mixer_close_fx(
return;
}
#endif
-
/*-----------------------------------------------------------------------------------------*
* Function ivas_fb_mixer_pcm_ingest()
*
@@ -1293,33 +1343,40 @@ void ivas_fb_mixer_cross_fading_fx(
{
Word16 k, fade_start_offset, fade_end_offset;
- if ( hFbMixer->first_frame[ch] == 0 )
+ IF( hFbMixer->first_frame[ch] == 0 )
{
fade_start_offset = hFbMixer->cross_fade_start_offset;
fade_end_offset = hFbMixer->cross_fade_end_offset;
+ move16();
+ move16();
- for ( k = 0; k < fade_start_offset; k++ )
+ FOR( k = 0; k < fade_start_offset; k++ )
{
ppOut_pcm_fx[ch][k] = pMdft_out_old_fx[k + cf_offset];
+ move32();
}
- for ( k = fade_start_offset; k < fade_end_offset; k++ )
+ FOR( k = fade_start_offset; k < fade_end_offset; k++ )
{
- ppOut_pcm_fx[ch][k] = L_add( Mpy_32_16_1( pMdft_out_new_fx[k + cf_offset], hFbMixer->pFilterbank_cross_fade_fx[k - fade_start_offset] ), Mpy_32_16_1( pMdft_out_old_fx[k + cf_offset], ( ONE_IN_Q15 - hFbMixer->pFilterbank_cross_fade_fx[k - fade_start_offset] ) ) );
+ ppOut_pcm_fx[ch][k] = L_add( Mpy_32_16_1( pMdft_out_new_fx[k + cf_offset], hFbMixer->pFilterbank_cross_fade_fx[k - fade_start_offset] ), Mpy_32_16_1( pMdft_out_old_fx[k + cf_offset], sub( 32767, hFbMixer->pFilterbank_cross_fade_fx[k - fade_start_offset] ) ) );
+ move32();
}
- for ( k = fade_end_offset; k < frame_len; k++ )
+ FOR( k = fade_end_offset; k < frame_len; k++ )
{
ppOut_pcm_fx[ch][k] = pMdft_out_new_fx[k + cf_offset];
+ move32();
}
}
- else
+ ELSE
{
hFbMixer->first_frame[ch] = 0;
+ move32();
- for ( k = 0; k < frame_len; k++ )
+ FOR( k = 0; k < frame_len; k++ )
{
ppOut_pcm_fx[ch][k] = pMdft_out_new_fx[k + cf_offset];
+ move32();
}
}
@@ -1746,6 +1803,7 @@ static Word16 ivas_calculate_abs_fr_fx(
Word32 cldfb_nrg_fx = 0;
Word16 cldfb_nrg_e = 0;
move16();
+ move16();
Word16 short_stride = pFb->fb_bin_to_band.short_stride;
move16();
const Word16 num_bins_per_short_stride_bin = ( const Word16 )( ( sampling_rate / FRAMES_PER_SEC ) / short_stride );
@@ -1790,7 +1848,7 @@ static Word16 ivas_calculate_abs_fr_fx(
/* accumulate bin energies within a short stride bin */
- short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shl( sq_abs_fx, Q22 - ( Q31 - sq_abs_e ) ) );
+ short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shl( sq_abs_fx, sub( Q22, sub( Q31, sq_abs_e ) ) ) );
move32();
IF( !( ( j + 1 ) % num_bins_per_short_stride_bin ) )
@@ -1806,7 +1864,6 @@ static Word16 ivas_calculate_abs_fr_fx(
/* accumulate bin energies within a CLDFB band */
cldfb_nrg_fx = BASOP_Util_Add_Mant32Exp( cldfb_nrg_fx, cldfb_nrg_e, sq_abs_fx, sq_abs_e, &cldfb_nrg_e );
- move32();
IF( !( ( j + 1 ) % num_bins_per_cldfb_band ) )
{
@@ -1816,6 +1873,7 @@ static Word16 ivas_calculate_abs_fr_fx(
move32();
pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j / num_bins_per_cldfb_band][i] = temp;
cldfb_nrg_fx = 0;
+ move32();
cldfb_nrg_e = 0;
move16();
}
@@ -1828,17 +1886,17 @@ static Word16 ivas_calculate_abs_fr_fx(
move16();
short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22
move32();
- short_stride_pow_spec_fx[j] = L_max( L_sub( short_stride_pow_spec_fx[j], (Word32) ( 0.3f * ONE_IN_Q22 ) ), 0 );
+ short_stride_pow_spec_fx[j] = L_max( L_sub( short_stride_pow_spec_fx[j], 1258291 ), 0 ); // 0.3f * ONE_IN_Q22c
move32();
- tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], (Word32) ( 0.7f * ONE_IN_Q22 ), &exp_diff );
+ tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], 2936012, &exp_diff ); // 0.7f * ONE_IN_Q22
move16();
short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22
move32();
- IF( GT_32( short_stride_pow_spec_fx[j], 0 ) )
+ IF( short_stride_pow_spec_fx[j] > 0 )
{
assert( idx_short_stride_bin_to_band < 2 * MDFT_FB_BANDS_240 ); /* array size of p_short_stride_bin_to_band */
- IF( short_mdft_start_bin == -1 )
+ IF( EQ_16( short_mdft_start_bin, -1 ) )
{
short_mdft_start_bin = j;
move16();
@@ -1847,13 +1905,15 @@ static Word16 ivas_calculate_abs_fr_fx(
pFb->fb_bin_to_band.pp_short_stride_bin_to_band_fx[i] = &pFb->fb_bin_to_band.p_short_stride_bin_to_band_fx[idx_short_stride_bin_to_band];
index[i] = idx_short_stride_bin_to_band;
+ move16();
}
pFb->fb_bin_to_band.p_short_stride_bin_to_band_fx[idx_short_stride_bin_to_band] = short_stride_pow_spec_fx[j];
move32();
- idx_short_stride_bin_to_band++;
+ idx_short_stride_bin_to_band = add( idx_short_stride_bin_to_band, 1 );
- pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[i]++;
+ pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[i] = add( pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[i], 1 );
+ move16();
}
}
}
@@ -1885,14 +1945,15 @@ static Word16 ivas_calculate_abs_fr_fx(
}
}
- sum_over_spar_bands_fx = max( sum_over_spar_bands_fx, EPSILON_FX );
+ sum_over_spar_bands_fx = L_max( sum_over_spar_bands_fx, EPSILON_FX );
move32();
FOR( i = 0; i < bands; i++ )
{
+ test();
IF( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] == 0 && !any_non_zero )
{
- spar_start++;
+ spar_start = add( spar_start, 1 );
}
ELSE
{
@@ -1911,7 +1972,9 @@ static Word16 ivas_calculate_abs_fr_fx(
move16();
}
- frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC );
+ Word16 exp;
+ frame_len = BASOP_Util_Divide3232_Scale( sampling_rate, FRAMES_PER_SEC, &exp );
+ frame_len = shr( frame_len, sub( 15, exp ) );
set_l( ppFilterbank_FRs_s_fx, 0, frame_len );
@@ -1969,13 +2032,15 @@ static Word16 ivas_calculate_abs_fr_fx(
temp_fx = L_sub( temp_fx, 1258291 );
move32();
- IF( temp_fx < 0 )
+ if ( temp_fx < 0 )
{
temp_fx = 0;
move32();
}
- IF( j < ( abs_active_bins + abs_start_offset ) && j >= abs_start_offset && alloc_fb_resp != -1 )
+ test();
+ test();
+ IF( LT_16( j, add( abs_active_bins, abs_start_offset ) ) && GE_16( j, abs_start_offset ) && NE_16( alloc_fb_resp, -1 ) )
{
pFb->fb_bin_to_band.pFb_bin_to_band_fx[i][idx] = temp_fx;
move32();
@@ -1990,13 +2055,14 @@ static Word16 ivas_calculate_abs_fr_fx(
FOR( i = 0; i < frame_len; i++ )
{
- IF( ppFilterbank_FRs_s_fx[i] < 0 )
+ if ( ppFilterbank_FRs_s_fx[i] < 0 )
{
ppFilterbank_FRs_s_fx[i] = 419430;
+ move32();
}
}
- IF( alloc_fb_resp != -1 )
+ IF( NE_16( alloc_fb_resp, -1 ) )
{
FOR( j = 0; j < bands; j++ )
{
@@ -2004,6 +2070,10 @@ static Word16 ivas_calculate_abs_fr_fx(
Word16 abs_start_offset = pFb->fb_bin_to_band.pFb_start_bin_per_band[j];
Word16 exp_diff = 0, tmp;
+ move16();
+ move16();
+ move16();
+
FOR( i = 0; i < abs_active_bins; i++ )
{
tmp = BASOP_Util_Divide3232_Scale( pFb->fb_bin_to_band.pFb_bin_to_band_fx[j][i], ppFilterbank_FRs_s_fx[i + abs_start_offset], &exp_diff );
@@ -2224,10 +2294,10 @@ static ivas_error ivas_filterbank_setup(
#ifdef IVAS_FLOAT_FIXED
static ivas_error ivas_filterbank_setup_fx(
IVAS_FB_MIXER_HANDLE hFbMixer,
- const int32_t sampling_rate,
+ const Word32 sampling_rate,
Word16 *index )
{
- Word16 i, j;
+ Word16 i, j, exp, tmp;
const Word32 *pAll_fb_fr_fx[2];
const Word16 *pAll_bins_start_offset = NULL;
const Word16 *pAll_bins_per_band = NULL;
@@ -2238,14 +2308,16 @@ static ivas_error ivas_filterbank_setup_fx(
IVAS_FB_CFG *pCfg = hFbMixer->fb_cfg;
error = IVAS_ERR_OK;
+ move32();
IF( pCfg->num_out_chans > 0 )
{
hFbMixer->pFb->filterbank_num_bands = ivas_get_num_bands( sampling_rate );
+ move16();
ivas_get_active_bins( &pAll_bins_per_band, &pAll_bins_per_band_abs, &pAll_bins_start_offset, &pAll_bins_start_offset_abs, sampling_rate );
- IF( pCfg->fb_latency == NS2SA( sampling_rate, DELAY_FB_1_NS ) )
+ IF( EQ_16( pCfg->fb_latency, NS2SA( sampling_rate, DELAY_FB_1_NS ) ) )
{
pAll_fb_fr_fx[0] = ivas_fb_fr_12band_1ms_re_fx; // Q30
move32();
@@ -2261,19 +2333,19 @@ static ivas_error ivas_filterbank_setup_fx(
}
}
- hFbMixer->cross_fade_end_offset = pCfg->fade_len + pCfg->pcm_offset;
+ hFbMixer->cross_fade_end_offset = add( pCfg->fade_len, pCfg->pcm_offset );
move16();
- hFbMixer->cross_fade_start_offset = hFbMixer->cross_fade_end_offset - pCfg->fade_len;
+ hFbMixer->cross_fade_start_offset = sub( hFbMixer->cross_fade_end_offset, pCfg->fade_len );
move16();
- hFbMixer->ana_window_offset = pCfg->fb_latency + pCfg->pcm_offset;
+ hFbMixer->ana_window_offset = add( pCfg->fb_latency, pCfg->pcm_offset );
move16();
- IF( ( error = ivas_fb_mixer_get_window_fx( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window_fx ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_fb_mixer_get_window_fx( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window_fx ) ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_fb_mixer_get_window_fx( pCfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade_fx ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_fb_mixer_get_window_fx( pCfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade_fx ) ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2282,6 +2354,7 @@ static ivas_error ivas_filterbank_setup_fx(
{
ivas_filterbank_t *pFb = hFbMixer->pFb;
Word16 offset = 0;
+ move16();
pFb->fb_consts.pFilterbank_bins_per_band = pAll_bins_per_band;
pFb->fb_consts.pFilterbank_bins_start_offset = pAll_bins_start_offset;
@@ -2294,19 +2367,23 @@ static ivas_error ivas_filterbank_setup_fx(
case 48000:
pFb->fb_bin_to_band.num_cldfb_bands = 60; /* sampling_rate * 1.0f / 800.0f */
move16();
- break;
+ BREAK;
case 32000:
pFb->fb_bin_to_band.num_cldfb_bands = 40;
move16();
- break;
+ BREAK;
case 16000:
pFb->fb_bin_to_band.num_cldfb_bands = 20;
move16();
- break;
+ BREAK;
}
/*pFb->fb_bin_to_band.cldfb_stride = ( int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX );*/ /* equals num_cldfb_bands*/
- pFb->fb_bin_to_band.short_stride = extract_l( ( sampling_rate / FRAMES_PER_SEC ) / 4 );
+ // pFb->fb_bin_to_band.short_stride = extract_l( ( sampling_rate / FRAMES_PER_SEC ) / 4 );
+ tmp = BASOP_Util_Divide3232_Scale( sampling_rate, FRAMES_PER_SEC, &exp );
+ pFb->fb_bin_to_band.short_stride = shr( tmp, sub( 15, exp ) + 2 );
+
+ move16();
set_l( pFb->fb_bin_to_band.p_short_stride_bin_to_band_fx, 0, 2 * MDFT_FB_BANDS_240 );
@@ -2329,7 +2406,7 @@ static ivas_error ivas_filterbank_setup_fx(
move32();
}
}
- IF( sampling_rate == 48000 )
+ IF( EQ_32( sampling_rate, 48000 ) )
{
FOR( j = 0; j < pFb->filterbank_num_bands; j++ )
{
@@ -2388,6 +2465,8 @@ static ivas_error ivas_filterbank_setup_fx(
active_bins_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_per_band[j];
start_offset_temp[j - start_diff_band_non48k] = pFb->fb_consts.pFilterbank_bins_start_offset[j];
+ move16();
+ move16();
}
ivas_get_ld_fb_resp_fx( ppFilterbank_FRs_re_temp_fx, ppFilterbank_FRs_im_temp_fx, ppFilterbank_FRs_re_temp_fx, ppFilterbank_FRs_im_temp_fx,
@@ -2479,6 +2558,7 @@ static ivas_error ivas_fb_mixer_get_window_fx(
ivas_error error;
error = IVAS_ERR_OK;
+ move32();
IF( EQ_16( fade_len, NS2SA( sampling_rate, DELAY_FB_4_NS ) ) )
{
@@ -2489,10 +2569,10 @@ static ivas_error ivas_fb_mixer_get_window_fx(
BREAK;
case 32000:
*pWindow = ivas_fb_cf_4ms_32k_fx;
- break;
+ BREAK;
case 16000:
*pWindow = ivas_fb_cf_4ms_16k_fx;
- break;
+ BREAK;
default:
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unsupported Sampling frequency!" );
}
@@ -2554,10 +2634,10 @@ static const Word32 *ivas_get_cheby_ramp_fx(
{
case IVAS_FB_1MS_32K_SAMP:
pCheby_fx = ivas_fb_resp_cheby_ramp_32del_fx;
- break;
+ BREAK;
case IVAS_FB_1MS_16K_SAMP:
pCheby_fx = ivas_fb_resp_cheby_ramp_16del_fx;
- break;
+ BREAK;
default:
assert( !"Unsupported cheby ramp length!" );
}
@@ -2714,6 +2794,7 @@ static void ivas_get_ld_fb_resp_fx(
Word16 b, s, frame_len;
const Word32 *pCheby_fx;
frame_len = 0;
+ move16();
/*common scratch buffers for computing impulse/frequency responses,
pre-ring, post-ring and circular shifted outputs to optimize stack*/
Word32 scratch1_fx[L_FRAME32k * 2];
@@ -2728,22 +2809,27 @@ static void ivas_get_ld_fb_resp_fx(
{
case 48000:
frame_len = 960;
+ move16();
han_win_fx = ivas_han_win_48k_fx; // Q31
- break;
+ BREAK;
case 32000:
frame_len = 640;
+ move16();
han_win_fx = ivas_han_win_32k_fx; // Q31
- break;
+ BREAK;
case 16000:
frame_len = 320;
+ move16();
han_win_fx = ivas_han_win_16k_fx; // Q31
- break;
+ BREAK;
}
pCheby_fx = ivas_get_cheby_ramp_fx( delay ); // Q31
b = 0;
s = 0;
+ move16();
+ move16();
assert( sampling_rate == 32000 || sampling_rate == 16000 );
@@ -2754,7 +2840,7 @@ static void ivas_get_ld_fb_resp_fx(
Copy32( ppIdeal_FRs_re_fx[b], &scratch2_fx[pStart_offset[b]], pActive_bins[b] );
Copy32( ppIdeal_FRs_im_fx[b], &scratch2_fx[frame_len + pStart_offset[b]], pActive_bins[b] ); // Q30
- Word16 guard_bits = L_norm_arr( scratch2_fx, shl( L_FRAME32k, 1 ) ) - find_guarded_bits_fx( shl( frame_len, 1 ) );
+ Word16 guard_bits = sub( L_norm_arr( scratch2_fx, shl( L_FRAME32k, 1 ) ), find_guarded_bits_fx( shl( frame_len, 1 ) ) );
Scale_sig32( scratch2_fx, shl( L_FRAME32k, 1 ), guard_bits );
ivas_imdft_fx( scratch2_fx, &scratch2_fx[frame_len], scratch1_fx, frame_len );
@@ -2763,6 +2849,9 @@ static void ivas_get_ld_fb_resp_fx(
{
scratch2_fx[x] = L_shr( scratch2_fx[x], guard_bits );
scratch1_fx[x] = L_shr( scratch1_fx[x], guard_bits );
+
+ move32();
+ move32();
}
/*apply circular shift and hanning window*/
@@ -2771,18 +2860,21 @@ static void ivas_get_ld_fb_resp_fx(
{
scratch2_fx[sub( s, delay )] = Mpy_32_32( scratch1_fx[s], L_sub( ONE_IN_Q31, han_win_fx[sub( s, delay )] ) ); // Q(30 + 31 - 31) == Q30
+ move32();
}
FOR( ; s < 2 * frame_len; s++ )
{
scratch2_fx[sub( s, delay )] = Mpy_32_32( scratch1_fx[s], han_win_fx[sub( s, add( frame_len, delay ) )] ); // Q30
+ move32();
}
FOR( s = 0; s < delay; s++ )
{
scratch2_fx[add( sub( shl( frame_len, 1 ), delay ), s )] = L_negate( Mpy_32_32( scratch1_fx[s], han_win_fx[add( sub( frame_len, delay ), s )] ) ); // Q30
+ move32();
}
/*apply heavy/cheby ramp window and compute pre ring*/
@@ -2790,6 +2882,7 @@ static void ivas_get_ld_fb_resp_fx(
FOR( s = 0; s < delay + 1; s++ )
{
scratch1_fx[s] = Mpy_32_32( scratch2_fx[s], pCheby_fx[sub( delay, s )] ); // Q30
+ move32();
}
FOR( ; s < frame_len; s++ )
@@ -2801,27 +2894,32 @@ static void ivas_get_ld_fb_resp_fx(
FOR( ; s < 2 * frame_len - delay; s++ )
{
scratch1_fx[s] = scratch2_fx[s];
+ move32();
}
FOR( ; s < 2 * frame_len; s++ )
{
scratch1_fx[s] = Mpy_32_32( scratch2_fx[s], L_sub( ONE_IN_Q31, pCheby_fx[sub( s, sub( shl( frame_len, 1 ), delay ) )] ) ); // Q30
+ move32();
}
/*IR - pre ring + post ring*/
FOR( s = 1; s < 2 * frame_len; s++ )
{
scratch2_fx[s] = L_sub( L_sub( scratch2_fx[s] /*pre ring*/, scratch1_fx[s] /*post ring*/ ), scratch1_fx[sub( shl( frame_len, 1 ), s )] );
+ move32();
}
FOR( s = 0; s < 2 * frame_len - delay; s++ )
{
scratch1_fx[add( s, delay )] = scratch2_fx[s];
+ move32();
}
FOR( ; s < 2 * frame_len; s++ )
{
scratch1_fx[sub( s, sub( shl( frame_len, 1 ), delay ) )] = L_negate( scratch2_fx[s] );
+ move32();
}
/* apply final window*/
@@ -2829,21 +2927,28 @@ static void ivas_get_ld_fb_resp_fx(
Word16 offset = 1;
Word16 delay_16 = 0;
- IF( delay == IVAS_FB_1MS_16K_SAMP )
+ move16();
+ move16();
+
+ if ( EQ_16( delay, IVAS_FB_1MS_16K_SAMP ) )
{
delay_16 = 1;
+ move16();
}
FOR( s = 0; s < delay; s++ )
{
- scratch1_fx[s] = Mpy_32_32( scratch1_fx[s], sine_till_delay[s + ( offset * delay_16 )] );
+ scratch1_fx[s] = Mpy_32_32( scratch1_fx[s], sine_till_delay[add( s, imult1616( offset, delay_16 ) )] );
offset = add( offset, 1 );
scratch1_fx[s] = L_shl( scratch1_fx[s], 1 ); // Q30
+
+ move32();
+ move32();
}
const Word32 *sine_till_frame_len = NULL;
- IF( delay == IVAS_FB_1MS_16K_SAMP )
+ IF( EQ_16( delay, IVAS_FB_1MS_16K_SAMP ) )
{
sine_till_frame_len = ivas_sine_frame_len_640_del_16_fx; // Q30
}
@@ -2852,18 +2957,24 @@ static void ivas_get_ld_fb_resp_fx(
sine_till_frame_len = ivas_sine_frame_len_640_del_32_fx; // Q30
}
Word16 iterator = 0;
+ move16();
FOR( s = 2 * delay; s < frame_len + 1; s++ )
{
scratch1_fx[s] = Mpy_32_32( scratch1_fx[s], sine_till_frame_len[iterator] );
iterator = add( iterator, 1 );
scratch1_fx[s] = L_shl( scratch1_fx[s], 1 ); // Q30
+ move32();
+ move32();
+
// assert(fabs(scratch1[s]) - fabs(fix_to_float(scratc h1_fx[s], 30)) < 0.00001);
}
FOR( ; s < 2 * frame_len; s++ )
{
scratch1_fx[s] = 0;
+
+ move32();
}
/*compute frequency response*/
diff --git a/lib_com/ivas_filters.c b/lib_com/ivas_filters.c
index 69a4e13c1aa953ecfa529ba3d6572fff6a33861f..21ec2a2a4896fd890a4dc424fe7fc24452b82245 100644
--- a/lib_com/ivas_filters.c
+++ b/lib_com/ivas_filters.c
@@ -43,8 +43,9 @@
/*------------------------------------------------------------------------------------------*
* Local functions declaration
*------------------------------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
static void ivas_iir_2_filter( ivas_filters_process_state_t *filter_state, float *pIn_Out, const int16_t length, const int16_t stage );
-#ifdef IVAS_FLOAT_FIXED
+#else
static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q_fcator );
#endif
/*-----------------------------------------------------------------------------------------*
@@ -52,7 +53,7 @@ static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Wo
*
* Initialisation call for filtering a signal
*-----------------------------------------------------------------------------------------*/
-
+#ifndef IVAS_FLOAT_FIXED
void ivas_filters_init(
ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
const float *filt_coeff, /* i : filter coefficients */
@@ -98,48 +99,99 @@ void ivas_filters_init(
return;
}
-#ifdef IVAS_FLOAT_FIXED
+#else
void ivas_filters_init_fx(
ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
const Word32 *filt_coeff_fx, /* i : filter coefficients */
+ const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */
const Word16 order ) /* i : filter order */
{
Word16 i;
filter_state->order = order;
+ move16();
+
+ test();
IF( EQ_16( order, IVAS_FILTER_ORDER_2 ) || EQ_16( order, IVAS_FILTER_ORDER_1 ) )
{
filter_state->filt_len = add( order, 1 );
+ move16();
FOR( i = 0; i < IVAS_BIQUAD_FILT_LEN; i++ )
{
filter_state->num_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i];
- filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[add( i, IVAS_BIQUAD_FILT_LEN )];
+ filter_state->num_e[IVAS_FILTER_STAGE_0][i] = 1;
+ filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN];
+ filter_state->den_e[IVAS_FILTER_STAGE_0][i] = 1;
+ move32();
+ move32();
+ move16();
+ move16();
}
filter_state->state_fx[0][0] = 0;
+ filter_state->state_e[0][0] = 0;
filter_state->state_fx[0][1] = 0;
+ filter_state->state_e[0][1] = 0;
filter_state->state_fx[0][2] = 0;
+ filter_state->state_e[0][2] = 0;
+ move32();
+ move32();
+ move32();
+ move16();
+ move16();
+ move16();
}
ELSE
{
filter_state->filt_len = IVAS_BIQUAD_FILT_LEN;
+ move16();
FOR( i = 0; i < IVAS_BIQUAD_FILT_LEN; i++ )
{
filter_state->num_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i];
- filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[add( i, IVAS_BIQUAD_FILT_LEN )];
- filter_state->num_fx[IVAS_FILTER_STAGE_1][i] = filt_coeff_fx[add( i, i_mult( IVAS_BIQUAD_FILT_LEN, 2 ) )];
- filter_state->den_fx[IVAS_FILTER_STAGE_1][i] = filt_coeff_fx[add( i, i_mult( IVAS_BIQUAD_FILT_LEN, 3 ) )];
+ filter_state->num_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i];
+ filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN];
+ filter_state->den_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN];
+ filter_state->num_fx[IVAS_FILTER_STAGE_1][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN * 2];
+ filter_state->num_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 2];
+ filter_state->den_fx[IVAS_FILTER_STAGE_1][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN * 3];
+ filter_state->den_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 3];
+ move32();
+ move32();
+ move32();
+ move32();
+ move16();
+ move16();
+ move16();
+ move16();
}
filter_state->state_fx[0][0] = 0;
+ filter_state->state_e[0][0] = 0;
filter_state->state_fx[0][1] = 0;
+ filter_state->state_e[0][1] = 0;
filter_state->state_fx[0][2] = 0;
+ filter_state->state_e[0][2] = 0;
filter_state->state_fx[1][0] = 0;
+ filter_state->state_e[1][0] = 0;
filter_state->state_fx[1][1] = 0;
+ filter_state->state_e[1][1] = 0;
filter_state->state_fx[1][2] = 0;
+ filter_state->state_e[1][2] = 0;
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
}
return;
@@ -152,6 +204,7 @@ void ivas_filters_init_fx(
*
* Process call for selecting the type filter
*-----------------------------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
void ivas_filter_process(
ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
float *pIn_Out, /* i/o: signal subject to filtering */
@@ -177,7 +230,7 @@ void ivas_filter_process(
return;
}
-#ifdef IVAS_FLOAT_FIXED
+#else
void ivas_filter_process_fx(
ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
Word32 *pIn_Out_fx, /* i/o: signal subject to filtering */
@@ -210,6 +263,7 @@ void ivas_filter_process_fx(
*
* Process call for filtering a signal
*-----------------------------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
static void ivas_iir_2_filter(
ivas_filters_process_state_t *filter_state,
float *pIn_Out,
@@ -235,7 +289,7 @@ static void ivas_iir_2_filter(
return;
}
-#ifdef IVAS_FLOAT_FIXED
+#else
static void ivas_iir_2_filter_fx(
ivas_filters_process_state_t *filter_state,
Word32 *pIn_Out_fx,
@@ -247,92 +301,47 @@ static void ivas_iir_2_filter_fx(
Word32 *pIn_fx = pIn_Out_fx;
Word32 *pOut_fx = pIn_Out_fx;
+ Word16 pOut_e;
Word32 tmp_pIn_buf_i_fx;
- Word32 L_tmp, L_tmp_1;
- Word64 L_tmp_2;
- Word16 L_tmp_q_factor, L_tmp_2_q_factor, L_tmp_3_q_factor, L_tmp_4_q_factor, L_tmp_5_q_factor, L_tmp_6_q_factor;
+ Word32 L_tmp_prod, L_tmp;
+ Word16 L_prod_e, L_tmp_e;
- Word16 q_factor_diff;
-
- Word16 q_factor_filter_num = 30;
- Word16 q_factor_filter_den = 30;
+ move16();
+ move16();
FOR( i = 0; i < length; i++ )
{
tmp_pIn_buf_i_fx = pIn_fx[i];
+ move32();
- /*L_tmp = Mpy_32_32(pIn_fx[i], filter_state->num_fx[stage][0]);*/
+ L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][0], pIn_fx[i] );
+ L_prod_e = sub( 31, sub( q_factor, filter_state->num_e[stage][0] ) ); // 31 - ( ( q_factor + ( 31 - filter_state->num_e[stage][0] ) ) - 31 )
- L_tmp_q_factor = sub( add( q_factor, q_factor_filter_num ), 31 );
+ pOut_fx[i] = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][0], filter_state->state_e[stage][0], L_tmp_prod, L_prod_e, &pOut_e );
+ move32();
- IF( GE_16( L_tmp_q_factor, q_factor ) )
- {
- q_factor_diff = sub( L_tmp_q_factor, q_factor );
- pOut_fx[i] = L_add( ( filter_state->state_fx[stage][0] ), L_shr( Mpy_32_32( filter_state->num_fx[stage][0], pIn_fx[i] ), q_factor_diff ) );
- L_tmp_2_q_factor = q_factor;
- }
- ELSE
+ FOR( j = 1; j < filter_state->filt_len; j++ )
{
- q_factor_diff = sub( q_factor, L_tmp_q_factor );
- pOut_fx[i] = L_add( L_shr( filter_state->state_fx[stage][0], q_factor_diff ), ( Mpy_32_32( filter_state->num_fx[stage][0], pIn_fx[i] ) ) );
- pOut_fx[i] = L_shl( pOut_fx[i], q_factor_diff );
- L_tmp_2_q_factor = q_factor;
- }
+ L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx );
+ L_prod_e = sub( 31, sub( q_factor, filter_state->num_e[stage][j] ) ); // 31 - ( ( q_factor + ( 31 - filter_state->num_e[stage][j] ) ) - 31 )
+ L_tmp = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][j], filter_state->state_e[stage][j], L_tmp_prod, L_prod_e, &L_tmp_e );
- FOR( j = 1; j < filter_state->filt_len; j++ )
+ L_tmp_prod = Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] );
+ L_prod_e = add( pOut_e, filter_state->den_e[stage][j] ); // 31 - ( ( ( 31 - pOut_e ) + ( 31 - filter_state->den_e[stage][j] ) ) - 31 );
+
+ filter_state->state_fx[stage][j - 1] = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, L_negate( L_tmp_prod ), L_prod_e, &filter_state->state_e[stage][j - 1] );
+ move32();
+ }
+
+ /* Scaling pOut_fx to Q11 */
+ pOut_fx[i] = L_shr_sat( pOut_fx[i], sub( sub( 31, q_factor ), pOut_e ) );
+ move32();
+ IF( pOut_fx[i] < 0 )
{
- /*L_tmp_1 = filter_state->num_fx[stage][j] * tmp_pIn_buf_i_fx;*/
-
- L_tmp_3_q_factor = sub( add( q_factor_filter_num, q_factor ), 31 );
-
- IF( GE_16( L_tmp_3_q_factor, q_factor ) )
- {
- q_factor_diff = sub( L_tmp_3_q_factor, q_factor );
- L_tmp = L_add( ( filter_state->state_fx[stage][j] ), L_shr( Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ), q_factor_diff ) );
- L_tmp_4_q_factor = q_factor;
- }
- ELSE
- {
- q_factor_diff = sub( q_factor, L_tmp_3_q_factor );
- L_tmp = L_add( L_shr( filter_state->state_fx[stage][j], q_factor_diff ), ( Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ) ) );
- L_tmp_4_q_factor = L_tmp_3_q_factor;
- }
-
- /*L_tmp_3 = filter_state->den_fx[stage][j] * pOut_fx[i];*/
-
- L_tmp_5_q_factor = sub( add( q_factor_filter_den, L_tmp_2_q_factor ), 31 );
-
-
- IF( GE_16( L_tmp_5_q_factor, L_tmp_4_q_factor ) )
- {
- q_factor_diff = sub( L_tmp_5_q_factor, L_tmp_4_q_factor );
- L_tmp_1 = L_sub( L_tmp, L_shr( Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ), q_factor_diff ) );
- L_tmp_6_q_factor = L_tmp_4_q_factor;
- }
- ELSE
- {
- q_factor_diff = sub( L_tmp_4_q_factor, L_tmp_5_q_factor );
- L_tmp_1 = L_sub( L_shr( L_tmp, q_factor_diff ), Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ) );
- L_tmp_6_q_factor = L_tmp_5_q_factor;
- }
-
- IF( GE_16( L_tmp_6_q_factor, q_factor ) )
- {
- q_factor_diff = sub( L_tmp_6_q_factor, q_factor );
- L_tmp_2 = W_shr( (Word64) L_tmp_1, q_factor_diff );
- }
- ELSE
- {
- q_factor_diff = sub( q_factor, L_tmp_6_q_factor );
- L_tmp_2 = W_shl( (Word64) L_tmp_1, q_factor_diff );
- }
-
-
- filter_state->state_fx[stage][j - 1] = W_extract_l( L_tmp_2 );
-
- // filter_state->state[stage][j - 1] = WORD322FL_SCALE(filter_state->state_fx[stage][j - 1], sub(31, q_factor));
+ pOut_fx[i] = L_add( pOut_fx[i], 1 );
+ move32();
}
}
}
diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c
index 6f0b03286d802c16165da43771e79551c7cf0f1c..6a287d2daa7256d1c79f2a00ddda56db54e9990b 100644
--- a/lib_com/ivas_ism_com.c
+++ b/lib_com/ivas_ism_com.c
@@ -41,8 +41,7 @@
#include "ivas_rom_com.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#define IVAS_FLOAT_FIXED_TO_BE_REMOVED
@@ -52,8 +51,11 @@
#define BITS_ISM_INACTIVE ( BRATE_ISM_INACTIVE / FRAMES_PER_SEC )
-#define BETA_ISM_LOW_IMP 0.6f
-#define BETA_ISM_MEDIUM_IMP 0.8f
+#define BETA_ISM_LOW_IMP 0.6f
+#define BETA_ISM_LOW_IMP_Q31 ( 1288490189 )
+#define BETA_ISM_MEDIUM_IMP 0.8f
+#define BETA_ISM_MEDIUM_IMP_Q31 ( 1717986918 )
+#define BETA_ISM_MEDIUM_IMP_BY_8_Q31 ( 214748365 )
#define MAX_BRATE_TCX_32k 48000
#define BITS_IVAS_512k ( IVAS_512k / FRAMES_PER_SEC )
@@ -70,6 +72,7 @@
* Convert bit-budget to bitrate
*-------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
void bitbudget_to_brate(
const Word16 x[], /* i : bitbudgets */
Word32 y[], /* o : bitrates */
@@ -79,6 +82,23 @@ void bitbudget_to_brate(
Word16 i;
FOR( i = 0; i < N; i++ )
+ {
+ y[i] = FRAMES_PER_SEC * x[i];
+ move32();
+ }
+
+ return;
+}
+#else
+void bitbudget_to_brate(
+ const int16_t x[], /* i : bitbudgets */
+ int32_t y[], /* o : bitrates */
+ const int16_t N /* i : number of entries to be converted */
+)
+{
+ int16_t i;
+
+ for ( i = 0; i < N; i++ )
{
y[i] = FRAMES_PER_SEC * x[i];
}
@@ -86,6 +106,8 @@ void bitbudget_to_brate(
return;
}
+#endif
+
/*-------------------------------------------------------------------*
* ivas_ism_config()
@@ -414,7 +436,7 @@ ivas_error ivas_ism_config_fx(
ivas_error error;
error = IVAS_ERR_OK;
- move16();
+ move32();
IF( combined_format_flag )
{
n_ISms = nchan_ism;
@@ -446,8 +468,9 @@ ivas_error ivas_ism_config_fx(
// bits_ism = (Word16) ( ism_total_brate / FRAMES_PER_SEC );
bits_ism = (Word16) Mpy_32_32( 42949673, ism_total_brate );
tmp1 = BASOP_Util_Divide1616_Scale( bits_ism, n_ISms, &exp );
- set_s( bits_element, shr( tmp1, ( 15 - exp ) ), n_ISms );
+ set_s( bits_element, shr( tmp1, sub( 15, exp ) ), n_ISms );
bits_element[n_ISms - 1] = add( bits_element[n_ISms - 1], bits_ism % n_ISms );
+ move16();
/* ISM common signaling bits are counted in MASA MD bit-budget */
}
@@ -459,22 +482,26 @@ ivas_error ivas_ism_config_fx(
//(Q31 +Q0) - Q31 --> Q0
bits_ism = (Word16) Mpy_32_32( 42949673, ism_total_brate );
tmp1 = BASOP_Util_Divide1616_Scale( bits_ism, n_ISms, &exp );
- set_s( bits_element, shr( tmp1, ( 15 - exp ) ), n_ISms );
+ set_s( bits_element, shr( tmp1, sub( 15, exp ) ), n_ISms );
bits_element[n_ISms - 1] = add( bits_element[n_ISms - 1], bits_ism % n_ISms );
+ move16();
bitbudget_to_brate( bits_element, element_brate, n_ISms );
/* count ISm common signaling bits */
IF( hIsmMeta != NULL )
{
nb_bits_metadata[0] = add( nb_bits_metadata[0], add( n_ISms * ISM_METADATA_FLAG_BITS, nchan_ism ) );
+ move16();
IF( GE_32( ism_total_brate, ISM_EXTENDED_METADATA_BRATE ) )
{
nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_EXTENDED_METADATA_BITS );
+ move16();
IF( ism_extended_metadata_flag )
{
nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_IS_NDP_BITS );
+ move16();
}
}
@@ -484,6 +511,9 @@ ivas_error ivas_ism_config_fx(
{
nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_MD_FLAG_BITS );
nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_FLAG_BITS );
+
+ move16();
+ move16();
}
ELSE
{
@@ -491,6 +521,9 @@ ivas_error ivas_ism_config_fx(
{
nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_MD_FLAG_BITS );
nb_bits_metadata[0] = add( nb_bits_metadata[0], ISM_METADATA_INACTIVE_FLAG_BITS );
+
+ move16();
+ move16();
}
}
}
@@ -504,6 +537,7 @@ ivas_error ivas_ism_config_fx(
tmp1 = BASOP_Util_Divide1616_Scale( bits_side, n_ISms, &exp );
set_s( nb_bits_metadata, shr( tmp1, ( 15 - exp ) ), n_ISms );
nb_bits_metadata[n_ISms - 1] = add( nb_bits_metadata[n_ISms - 1], bits_side % n_ISms );
+ move16();
v_sub_s( bits_element, nb_bits_metadata, bits_CoreCoder, n_ISms );
bitbudget_to_brate( bits_CoreCoder, total_brate, n_ISms );
@@ -526,21 +560,24 @@ ivas_error ivas_ism_config_fx(
diff = add( diff, sub( bits_CoreCoder[ch], BITS_ISM_INACTIVE ) );
bits_CoreCoder[ch] = BITS_ISM_INACTIVE;
flag_higher[ch] = 0;
+ move16();
+ move16();
}
}
n_higher = sum_s( flag_higher, n_ISms );
test();
- IF( GT_16( diff, 0 ) && GT_16( n_higher, 0 ) )
+ IF( diff > 0 && n_higher > 0 )
{
tmp = BASOP_Util_Divide1616_Scale( diff, n_higher, &exp );
- tmp = shr( tmp, ( 15 - exp ) );
+ tmp = shr( tmp, sub( 15, exp ) );
FOR( ch = 0; ch < n_ISms; ch++ )
{
IF( flag_higher[ch] )
{
bits_CoreCoder[ch] = add( bits_CoreCoder[ch], tmp );
+ move16();
}
}
@@ -548,11 +585,12 @@ ivas_error ivas_ism_config_fx(
move16();
ch = 0;
move16();
- WHILE( EQ_16( flag_higher[ch], 0 ) )
+ WHILE( flag_higher[ch] == 0 )
{
ch = add( ch, 1 );
}
bits_CoreCoder[ch] = add( bits_CoreCoder[ch], tmp );
+ move16();
}
bitbudget_to_brate( bits_CoreCoder, total_brate, n_ISms );
@@ -585,15 +623,13 @@ ivas_error ivas_ism_config_fx(
ELSE IF( EQ_16( ism_imp[ch], ISM_LOW_IMP ) )
{
// tmp = (Word16) ( BETA_ISM_LOW_IMP * bits_CoreCoder[ch] );
- tmp1 = BASOP_Util_Divide1616_Scale( bits_CoreCoder[ch], 5, &exp );
- tmp = shr( mult( tmp1, 24576 ), ( 15 - exp + 13 ) - 15 );
+ tmp = extract_l( Mpy_32_32( BETA_ISM_LOW_IMP_Q31, bits_CoreCoder[ch] ) );
tmp = s_max( limit, tmp );
}
ELSE IF( EQ_16( ism_imp[ch], ISM_MEDIUM_IMP ) )
{
// tmp = (Word16) ( BETA_ISM_MEDIUM_IMP * bits_CoreCoder[ch] );
- tmp1 = BASOP_Util_Divide1616_Scale( bits_CoreCoder[ch], 5, &exp );
- tmp = shr( mult( tmp1, 16384 ), ( 15 - exp + 12 ) - 15 );
+ tmp = extract_l( Mpy_32_32( BETA_ISM_MEDIUM_IMP_BY_8_Q31, L_shl( bits_CoreCoder[ch], Q3 ) ) );
tmp = s_max( limit, tmp );
}
ELSE /* ism_imp[ch] == ISM_HIGH_IMP */
@@ -608,15 +644,16 @@ ivas_error ivas_ism_config_fx(
}
test();
- IF( GT_16( diff, 0 ) && GT_16( n_higher, 0 ) )
+ IF( diff > 0 && n_higher > 0 )
{
tmp = BASOP_Util_Divide1616_Scale( diff, n_higher, &exp );
- tmp = shr( tmp, ( 15 - exp ) );
+ tmp = shr( tmp, sub( 15, exp ) );
FOR( ch = 0; ch < n_ISms; ch++ )
{
IF( flag_higher[ch] )
{
bits_CoreCoder[ch] = add( bits_CoreCoder[ch], tmp );
+ move16();
}
}
@@ -624,11 +661,12 @@ ivas_error ivas_ism_config_fx(
move16();
ch = 0;
move16();
- WHILE( EQ_16( flag_higher[ch], 0 ) )
+ WHILE( flag_higher[ch] == 0 )
{
ch = add( ch, 1 );
}
bits_CoreCoder[ch] = add( bits_CoreCoder[ch], tmp );
+ move16();
}
/* verify for the maximum bitrate @12.8kHz core */
@@ -638,7 +676,7 @@ ivas_error ivas_ism_config_fx(
{
limit_high = BITS_IVAS_512k;
move16();
- IF( LT_32( element_brate[ch], SCE_CORE_16k_LOW_LIMIT ) ) /* replicate function set_ACELP_flag() -> it is not intended to switch the ACELP internal sampling rate within an object */
+ if ( LT_32( element_brate[ch], SCE_CORE_16k_LOW_LIMIT ) ) /* replicate function set_ACELP_flag() -> it is not intended to switch the ACELP internal sampling rate within an object */
{
limit_high = BITS_ACELP_12k8_HIGH_LIMIT;
move16();
@@ -669,13 +707,13 @@ ivas_error ivas_ism_config_fx(
}
}
- IF( GT_16( diff, 0 ) )
+ IF( diff > 0 )
{
ch = 0;
move16();
FOR( ch = 0; ch < n_ISms; ch++ )
{
- IF( EQ_16( flag_higher[ch], 0 ) )
+ IF( flag_higher[ch] == 0 )
{
IF( GT_16( diff, limit_high ) )
{
@@ -686,8 +724,9 @@ ivas_error ivas_ism_config_fx(
ELSE
{
bits_CoreCoder[ch] = add( bits_CoreCoder[ch], diff );
+ move16();
- IF( combined_format_flag )
+ if ( combined_format_flag )
{
diff = 0;
move16();
@@ -700,7 +739,7 @@ ivas_error ivas_ism_config_fx(
IF( combined_format_flag )
{
- IF( GT_16( diff, 0 ) )
+ IF( diff > 0 )
{
FOR( ch = 0; ch < n_ISms; ch++ )
{
@@ -852,7 +891,7 @@ Word16 ism_quant_meta_fx(
Word32 qlow_fx, step_fx;
Word16 tmp, tmp_e;
- IF( val <= borders_fx[1] )
+ IF( LE_32( val, borders_fx[1] ) )
{
qlow_fx = borders_fx[0];
move32();
@@ -861,7 +900,7 @@ Word16 ism_quant_meta_fx(
step_fx = q_step_border_fx;
move32();
}
- ELSE IF( val <= borders_fx[2] )
+ ELSE IF( LE_32( val, borders_fx[2] ) )
{
qlow_fx = borders_fx[1];
move32();
@@ -889,6 +928,7 @@ Word16 ism_quant_meta_fx(
// idx = idx_start + (int16_t) max( 0.f, min( cbsize - 1, ( ( val - qlow_fx ) / step_fx + 0.5f ) ) );
*valQ = L_add( imult3216( step_fx, sub( idx, idx_start ) ), qlow_fx );
+ move32();
return idx;
}
@@ -948,29 +988,48 @@ Word32 ism_dequant_meta_fx(
const Word16 cbsize /* i : codebook size */
)
{
- Word16 idx_start;
+ Word16 idx_start, tmp1, tmp2, exp1, exp2;
Word32 qlow_fx, step_fx, valQ_fx;
- IF( idx <= L_shr( L_sub( borders_fx[1], borders_fx[0] ), 21 ) / L_shr( q_step_border_fx, 21 ) )
+ tmp1 = BASOP_Util_Divide3232_Scale( L_shr( L_sub( borders_fx[1], borders_fx[0] ), 21 ), L_shr( q_step_border_fx, 21 ), &exp1 );
+ tmp1 = shr( tmp1, sub( 15, exp1 ) );
+
+ tmp2 = BASOP_Util_Divide3232_Scale( L_shr( L_sub( borders_fx[3], borders_fx[2] ), 21 ), L_shr( q_step_border_fx, 21 ), &exp2 );
+ tmp2 = shr( tmp2, sub( 15, exp2 ) );
+
+
+ IF( LE_16( idx, tmp1 ) )
{
qlow_fx = borders_fx[0];
idx_start = 0;
step_fx = q_step_border_fx;
+
+ move32();
+ move32();
+ move16();
}
- ELSE IF( idx <= cbsize - 1 - L_shr( L_sub( borders_fx[3], borders_fx[2] ), 21 ) / L_shr( q_step_border_fx, 21 ) )
+ ELSE IF( LE_16( idx, sub( sub( cbsize, 1 ), tmp2 ) ) )
{
qlow_fx = borders_fx[1];
- idx_start = (Word16) ( L_shr( L_sub( borders_fx[1], borders_fx[0] ), 21 ) / L_shr( q_step_border_fx, 21 ) );
+ idx_start = tmp1;
step_fx = q_step_fx;
+
+ move32();
+ move32();
+ move16();
}
ELSE
{
qlow_fx = borders_fx[2];
- idx_start = (Word16) ( cbsize - 1 - L_shr( L_sub( borders_fx[3], borders_fx[2] ), 21 ) / L_shr( q_step_border_fx, 21 ) );
+ idx_start = (Word16) sub( sub( cbsize, 1 ), tmp2 );
step_fx = q_step_border_fx;
+
+ move32();
+ move32();
+ move16();
}
- valQ_fx = sub( idx, idx_start ) * step_fx + qlow_fx;
+ valQ_fx = L_add( sub( idx, idx_start ) * step_fx, qlow_fx );
return valQ_fx;
}
@@ -1093,6 +1152,7 @@ void ivas_param_ism_config_fx(
* ---------------------------------------------------------------*/
/*! r : ISM format mode */
+#ifdef IVAS_FLOAT_FIXED
ISM_MODE ivas_ism_mode_select(
const Word16 nchan_inp, /* i : number of input objects */
const Word32 ivas_total_brate /* i : IVAS total bitrate */
@@ -1115,7 +1175,27 @@ ISM_MODE ivas_ism_mode_select(
return ism_mode;
}
+#else
+ISM_MODE ivas_ism_mode_select(
+ const int16_t nchan_inp, /* i : number of input objects */
+ const int32_t ivas_total_brate /* i : IVAS total bitrate */
+)
+{
+ ISM_MODE ism_mode = ISM_MODE_NONE;
+
+ if ( nchan_inp > 2 && ivas_total_brate <= ACELP_32k )
+ {
+ ism_mode = ISM_MODE_PARAM;
+ }
+ else
+ {
+ ism_mode = ISM_MODE_DISC;
+ }
+
+ return ism_mode;
+}
+#endif
/*---------------------------------------------------------------
* ivas_ism_metadata_close()
@@ -1252,13 +1332,26 @@ void ivas_get_ism_sid_quan_bitbudget_fx(
*nBits_coh = ISM_DTX_COH_SCA_BITS;
*nBits_sce_id = 1;
- IF( nchan_ism >= 3 )
+ move16();
+ move16();
+ move16();
+ move16();
+ move32();
+ move32();
+
+ IF( GE_16( nchan_ism, 3 ) )
{
*nBits_azimuth = ISM_DTX_AZI_BITS_LOW;
*nBits_elevation = ISM_DTX_ELE_BITS_LOW;
*q_step_fx = ISM_Q_STEP_LOW_FX;
*q_step_border_fx = ISM_Q_STEP_BORDER_LOW_FX;
*nBits_sce_id = 2;
+
+ move16();
+ move16();
+ move16();
+ move16();
+ move32();
}
return;
diff --git a/lib_com/ivas_lfe_com.c b/lib_com/ivas_lfe_com.c
index 1239813943963509a45a0fd0b775ee8295915ad2..7fdfe40fa4f993ec8e045eaac4ea6b9ae743b625 100644
--- a/lib_com/ivas_lfe_com.c
+++ b/lib_com/ivas_lfe_com.c
@@ -44,6 +44,9 @@
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*-----------------------------------------------------------------------------------------*
@@ -51,7 +54,7 @@
*
* Selects LFE filter coeff based on config.
*-----------------------------------------------------------------------------------------*/
-
+#ifndef IVAS_FLOAT_FIXED
void ivas_lfe_lpf_select_filt_coeff(
const int32_t sampling_rate, /* i : sampling rate */
const int16_t order, /* i : filter order */
@@ -99,11 +102,12 @@ void ivas_lfe_lpf_select_filt_coeff(
return;
}
-#ifdef IVAS_FLOAT_FIXED
+#else
void ivas_lfe_lpf_select_filt_coeff_fx(
- const Word32 sampling_rate, /* i : sampling rate */
- const Word16 order, /* i : filter order */
- const Word32 **ppFilt_coeff_fx /* o : filter coefficients */
+ const Word32 sampling_rate, /* i : sampling rate */
+ const Word16 order, /* i : filter order */
+ const Word32 **ppFilt_coeff_fx, /* o : filter coefficients */
+ const Word16 **ppFilt_coeff_e /* o : exponents of filter coefficients */
)
{
SWITCH( order )
@@ -129,12 +133,15 @@ void ivas_lfe_lpf_select_filt_coeff_fx(
{
case 16000:
*ppFilt_coeff_fx = ivas_lpf_4_butter_16k_sos_fx;
+ *ppFilt_coeff_e = ivas_lpf_4_butter_16k_sos_e;
BREAK;
case 32000:
*ppFilt_coeff_fx = ivas_lpf_4_butter_32k_sos_fx;
+ *ppFilt_coeff_e = ivas_lpf_4_butter_32k_sos_e;
BREAK;
case 48000:
*ppFilt_coeff_fx = ivas_lpf_4_butter_48k_sos_fx;
+ *ppFilt_coeff_e = ivas_lpf_4_butter_48k_sos_e;
BREAK;
default:
BREAK;
@@ -182,15 +189,24 @@ void ivas_lfe_window_init_fx(
/* 10ms stride, MDCT will be done in two iterations */
hLFEWindow->dct_len = shr( frame_len, 1 );
+ move16();
/* 8ms of latency */
- hLFEWindow->fade_len = NS2SA( sampling_rate, IVAS_LFE_FADE_NS );
+ hLFEWindow->fade_len = NS2SA_fx2( sampling_rate, IVAS_LFE_FADE_NS );
hLFEWindow->zero_pad_len = ( mult( IVAS_ZERO_PAD_LEN_MULT_FAC_fx, sub( hLFEWindow->dct_len, hLFEWindow->fade_len ) ) );
hLFEWindow->full_len = add( add( hLFEWindow->zero_pad_len, hLFEWindow->fade_len ), hLFEWindow->dct_len );
+ move16();
+ move16();
+ move16();
+
+ move16();
+ move16();
+ move16();
+ move16();
return;
}
-#endif
+#else
void ivas_lfe_window_init(
LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle */
const int32_t sampling_rate, /* i : sampling rate */
@@ -225,3 +241,4 @@ void ivas_lfe_window_init(
return;
}
+#endif
diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c
index bbfc3d69c25b4917625d0fc2928e8078f560a744..e0005e4b8bcd34e69c6f72da85649de46e69213d 100644
--- a/lib_com/ivas_masa_com.c
+++ b/lib_com/ivas_masa_com.c
@@ -41,7 +41,7 @@
#include "ivas_stat_dec.h"
#include "wmc_auto.h"
#include "ivas_rom_com_fx.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
@@ -179,7 +179,7 @@ void ivas_masa_set_elements_fx(
const Word32 ism_total_brate /* i : initial ISM total bitrate */
)
{
- Word16 tmp, tmp_e;
+ Word16 tmp;
IF( EQ_16( nchan_transport, 2 ) )
{
@@ -195,7 +195,7 @@ void ivas_masa_set_elements_fx(
*element_mode = IVAS_SCE; /* This is needed for the initialization phase to initialize codec mode to SCE, since it is written first to the file*/
move16();
}
- ELSE IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) && NE_16( ism_mode, ISM_MODE_NONE ) )
+ ELSE IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) && ism_mode != ISM_MODE_NONE )
{
*nCPE = 1;
move16();
@@ -232,12 +232,15 @@ void ivas_masa_set_elements_fx(
move16();
}
}
- tmp = BASOP_Util_Divide3216_Scale( ivas_total_brate, FRAMES_PER_SEC, &tmp_e );
- hQMetaData->bits_frame_nominal = shr( tmp, negate( add( 1, tmp_e ) ) ); // Q0
+ /* hQMetaData->bits_frame_nominal = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ); */
+ hQMetaData->bits_frame_nominal = extract_l( Mpy_32_32( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+ test();
+ test();
+ test();
IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) && ( EQ_16( ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( ism_mode, ISM_MASA_MODE_DISC ) ) )
{
- tmp = BASOP_Util_Divide3216_Scale( ism_total_brate, FRAMES_PER_SEC, &tmp_e );
- tmp = shr( tmp, negate( add( 1, tmp_e ) ) ); // Q0
+ /* hQMetaData->bits_frame_nominal -= (int16_t) ( ism_total_brate / FRAMES_PER_SEC ); */
+ tmp = extract_l( Mpy_32_32( ism_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
hQMetaData->bits_frame_nominal = sub( hQMetaData->bits_frame_nominal, tmp );
}
}
@@ -270,8 +273,7 @@ void ivas_masa_set_elements_fx(
}
ELSE
{
- hQMetaData->bits_frame_nominal = (Word16) ( ivas_total_brate / FRAMES_PER_SEC );
- move16();
+ hQMetaData->bits_frame_nominal = extract_l( Mpy_32_32( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
}
*element_mode = IVAS_SCE;
move16();
@@ -511,35 +513,35 @@ void ivas_masa_set_coding_config_fx(
/* Setup coding parameters based on the bitrate, transport channel count, subframe metadata information,
* and number of directions in metadata. */
nbands = 0;
+ move16();
nTwoDirBands = 0;
+ move16();
i = 0;
move16();
/* First select correct bit budget table */
masa_bits_table = masa_bits;
- move16();
test();
IF( isMcMasa )
{
masa_bits_table = mcmasa_bits;
- move16();
}
ELSE IF( LT_32( ivas_total_brate, IVAS_48k ) && EQ_16( nchan_transport, 2 ) )
{
masa_bits_table = masa_bits_LR_stereo;
- move16();
}
- WHILE( EQ_16( nbands, 0 ) && LT_16( i, IVAS_NUM_ACTIVE_BRATES ) )
+ WHILE( nbands == 0 && LT_16( i, IVAS_NUM_ACTIVE_BRATES ) )
{
+ test();
IF( LE_32( ivas_total_brate, ivas_brate_tbl[i + SIZE_IVAS_BRATE_TBL - IVAS_NUM_ACTIVE_BRATES] ) )
{
Word16 idx_bands;
test();
test();
- IF( LT_32( ivas_total_brate, IVAS_48k ) && EQ_16( nchan_transport, 2 ) && GT_16( i, 3 ) )
+ if ( LT_32( ivas_total_brate, IVAS_48k ) && EQ_16( nchan_transport, 2 ) && GT_16( i, 3 ) )
{
/* because it uses the bitallocation for the lower bit rates from 'masa_bits_LR_stereo' and it has 4 elements */
i = 3;
@@ -550,7 +552,16 @@ void ivas_masa_set_coding_config_fx(
IF( GT_16( config->numberOfDirections, 1 ) )
{
- nTwoDirBands = config->joinedSubframes ? masa_twodir_bands_joined[i] : masa_twodir_bands[i];
+ IF( config->joinedSubframes )
+ {
+ nTwoDirBands = masa_twodir_bands_joined[i];
+ move16();
+ }
+ ELSE
+ {
+ nTwoDirBands = masa_twodir_bands[i];
+ move16();
+ }
test();
test();
@@ -564,20 +575,23 @@ void ivas_masa_set_coding_config_fx(
IF( config->joinedSubframes )
{
nbands = masa_joined_nbands[idx_bands];
+ move16();
}
ELSE
{
nbands = masa_nbands[idx_bands];
+ move16();
}
- config->max_metadata_bits = masa_bits_table[i];
+ config->max_metadata_bits = (UWord16) masa_bits_table[i];
move16();
test();
IF( EQ_32( ivas_total_brate, IVAS_64k ) && GT_16( config->numberOfDirections, 1 ) )
{
/* At 64k, we increase metadata bit budget when there is two directions present. */
- config->max_metadata_bits = (UWord16) L_add( config->max_metadata_bits, MASA_EXTRA_BAND_META_BITS );
+ config->max_metadata_bits = (UWord16) add( config->max_metadata_bits, MASA_EXTRA_BAND_META_BITS );
+ move16();
}
test();
@@ -586,21 +600,26 @@ void ivas_masa_set_coding_config_fx(
IF( ( ( EQ_32( ivas_total_brate, IVAS_32k ) && EQ_16( nchan_transport, 2 ) ) || EQ_32( ivas_total_brate, IVAS_48k ) ) && config->joinedSubframes )
{
/* At 32k and 48k, we increase metadata bit budget when joinedSubframes. */
- config->max_metadata_bits = (UWord16) L_add( config->max_metadata_bits, MASA_SMALL_INC_META_BITS );
+ config->max_metadata_bits = (UWord16) add( config->max_metadata_bits, MASA_SMALL_INC_META_BITS );
+ move16();
}
}
i = add( i, 1 );
}
config->numCodingBands = nbands;
+ move16();
config->numTwoDirBands = nTwoDirBands;
+ move16();
IF( EQ_16( config->joinedSubframes, TRUE ) )
{
config->mergeRatiosOverSubframes = FALSE;
+ move16();
}
ELSE
{
config->mergeRatiosOverSubframes = TRUE;
+ move16();
}
/* Setup frequency band mapping based on the number of used coding bands */
@@ -620,7 +639,7 @@ void ivas_masa_set_coding_config_fx(
BREAK;
case MASA_FREQUENCY_BANDS:
/* With input count of bands, no mapping is needed but for unified processing later, we store normal mapping */
- FOR( i = 0; i < add( MASA_FREQUENCY_BANDS, 1 ); i++ )
+ FOR( i = 0; i < MASA_FREQUENCY_BANDS + 1; i++ )
{
band_mapping[i] = i;
move16();
@@ -631,12 +650,14 @@ void ivas_masa_set_coding_config_fx(
}
config->useCoherence = TRUE;
+ move16();
test();
test();
test();
IF( ( !isMcMasa && LT_32( ivas_total_brate, IVAS_48k ) ) || ( isMcMasa && LT_32( ivas_total_brate, IVAS_16k4 ) ) )
{
config->useCoherence = FALSE;
+ move16();
}
return;
@@ -769,6 +790,7 @@ void masa_sample_rate_band_correction_fx(
UWord8 numBands48k;
numBands48k = config->numCodingBands;
+ move16();
FOR( band = 1; band < config->numCodingBands + 1; band++ )
{
@@ -778,18 +800,22 @@ void masa_sample_rate_band_correction_fx(
IF( GE_16( highBand, (Word16) maxBand ) )
{
config->numCodingBands = band;
+ move16();
hQMetaData->numCodingBands = band;
+ move16();
IF( is_encoder )
{
- test();
- IF( GT_16( hQMetaData->q_direction->cfg.nbands, (Word16) band ) )
+ if ( GT_16( hQMetaData->q_direction->cfg.nbands, (Word16) band ) )
{
hQMetaData->q_direction->cfg.nbands = band;
+ move16();
}
- IF( EQ_16( (Word16) hQMetaData->no_directions, 2 ) && GT_16( hQMetaData->q_direction[1].cfg.nbands, (Word16) band ) )
+ test();
+ if ( EQ_16( (Word16) hQMetaData->no_directions, 2 ) && GT_16( hQMetaData->q_direction[1].cfg.nbands, (Word16) band ) )
{
hQMetaData->q_direction[1].cfg.nbands = band;
+ move16();
}
}
@@ -812,9 +838,11 @@ void masa_sample_rate_band_correction_fx(
hQMetaData->q_direction[0].band_data[band].energy_ratio_fx[sf] = 0;
move32();
- IF( hQMetaData->coherence_flag && hQMetaData->q_direction[0].coherence_band_data != NULL )
+ test();
+ if ( hQMetaData->coherence_flag && hQMetaData->q_direction[0].coherence_band_data != NULL )
{
hQMetaData->q_direction[0].coherence_band_data[band].spread_coherence[sf] = 0u;
+ move16();
}
IF( EQ_16( (Word16) hQMetaData->no_directions, 2 ) )
@@ -826,21 +854,26 @@ void masa_sample_rate_band_correction_fx(
hQMetaData->q_direction[1].band_data[band].energy_ratio_fx[sf] = 0;
move32();
- IF( hQMetaData->coherence_flag && hQMetaData->q_direction[1].coherence_band_data != NULL )
+ test();
+ if ( hQMetaData->coherence_flag && hQMetaData->q_direction[1].coherence_band_data != NULL )
{
hQMetaData->q_direction[1].coherence_band_data[band].spread_coherence[sf] = 0u;
+ move16();
}
}
- IF( hQMetaData->coherence_flag && hQMetaData->surcoh_band_data != NULL )
+ test();
+ if ( hQMetaData->coherence_flag && hQMetaData->surcoh_band_data != NULL )
{
hQMetaData->surcoh_band_data[band].surround_coherence[sf] = 0u;
+ move16();
}
}
- IF( EQ_16( (Word16) hQMetaData->no_directions, 2 ) )
+ if ( EQ_16( (Word16) hQMetaData->no_directions, 2 ) )
{
hQMetaData->twoDirBands[band] = 0;
+ move16();
}
}
@@ -854,14 +887,21 @@ void masa_sample_rate_band_correction_fx(
hExtOutMeta->directionIndex[0][sf][band] = SPH_IDX_FRONT;
move16();
hExtOutMeta->directToTotalRatio[0][sf][band] = 0u;
+ move16();
hExtOutMeta->spreadCoherence[0][sf][band] = 0u;
+ move16();
hExtOutMeta->directionIndex[1][sf][band] = SPH_IDX_FRONT;
+ move16();
hExtOutMeta->directToTotalRatio[1][sf][band] = 0u;
+ move16();
hExtOutMeta->spreadCoherence[1][sf][band] = 0u;
+ move16();
hExtOutMeta->surroundCoherence[sf][band] = 0u;
+ move16();
hExtOutMeta->diffuseToTotalRatio[sf][band] = UINT8_MAX;
+ move16();
}
}
}
@@ -992,7 +1032,7 @@ UWord16 index_theta_phi_16_fx(
move32();
phi_fx = L_add( phi_fx, L_shl( 180, Q22 ) );
- IF( LT_32( theta_fx, 0 ) )
+ IF( theta_fx < 0 )
{
abs_theta_fx = L_negate( theta_fx );
sign_th = -1;
@@ -1030,11 +1070,13 @@ UWord16 index_theta_phi_16_fx(
IF( EQ_16( sign_th, -1 ) )
{
*p_theta = L_negate( theta_hat_fx );
+ move32();
}
*p_phi = L_sub( phi_hat_fx, L_shl( 180, Q22 ) );
+ move32();
/* Starting from Equator, alternating positive and negative */
- IF( EQ_16( id_th, 0 ) )
+ IF( id_th == 0 )
{
idx_sph = id_phi;
move16();
@@ -1045,7 +1087,7 @@ UWord16 index_theta_phi_16_fx(
{
idx_sph = 65534;
move16();
- IF( LT_16( sign_th, 0 ) )
+ if ( sign_th < 0 )
{
idx_sph = 65535;
move16();
@@ -1058,7 +1100,7 @@ UWord16 index_theta_phi_16_fx(
cum_n = (UWord16) L_add( cum_n, gridData->no_phi[0] );
- IF( GT_16( sign_th, 0 ) )
+ IF( sign_th > 0 )
{
cum_n = (UWord16) L_sub( cum_n, shl( gridData->no_phi[id_th], 1 ) );
}
@@ -1076,7 +1118,7 @@ UWord16 index_theta_phi_16_fx(
/*-------------------------------------------------------------------------
- * quantize_phi_masa()
+ * quantize_theta_masa()
*
*
*------------------------------------------------------------------------*/
@@ -1137,15 +1179,18 @@ static Word16 quantize_theta_masa_fx(
{
imin = sub( imin, 1 );
*xhat_fx = Mpy_32_16_1( MASA_ANGLE_AT_EQUATOR_DEG_Q31, shl( imin, 6 ) ); // 31 + 6 - 15 = Q22
+ move32();
}
ELSE
{
*xhat_fx = L_shl( 90, Q22 );
+ move32();
}
}
ELSE
{
*xhat_fx = Mpy_32_16_1( MASA_ANGLE_AT_EQUATOR_DEG_Q31, shl( imin, 6 ) ); // 31 + 6 - 15 = Q22
+ move32();
}
return imin;
@@ -1258,6 +1303,7 @@ static Word16 quantize_phi_masa_fx(
}
*phi_hat_fx = L_add( L_shl( Mpy_32_16_1( delta_phi_fx, id_phi ), 15 ), dd_fx ); // q22 + q0 - 15 = q7 -> q7 + 15 = q22
+ move32();
return id_phi;
}
@@ -1414,7 +1460,7 @@ void deindex_sph_idx(
return;
}
-
+#ifdef IVAS_FLOAT_FIXED
void deindex_sph_idx_fx(
const UWord16 sphIndex, /* i : Spherical index */
const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */
@@ -1440,6 +1486,19 @@ void deindex_sph_idx_fx(
Word16 tmp16, tmp_e;
move16();
move16();
+ move16();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
IF( GE_32( sphIndex, limit_index1 ) )
{
@@ -1482,9 +1541,9 @@ void deindex_sph_idx_fx(
tmp32 = L_shr( tmp32, sub( Q8, tmp16 ) ); /* Q23 */
estim_fx = L_add( ba_crt_fx, tmp32 ); /* Q23 */
- if ( GT_32( estim_fx, MASA_NO_CIRCLES << Q23 ) )
+ if ( GT_32( estim_fx, MASA_NO_CIRCLES_Q23 ) )
{
- estim_fx = MASA_NO_CIRCLES << Q23;
+ estim_fx = MASA_NO_CIRCLES_Q23;
move32();
}
@@ -1537,7 +1596,7 @@ void deindex_sph_idx_fx(
move16();
IF( LT_32( sphIndex, base_low ) )
{
- id_th--;
+ id_th = sub( id_th, 1 );
n_crt = n[id_th];
move16();
IF( id_th == 0 )
@@ -1557,7 +1616,7 @@ void deindex_sph_idx_fx(
}
ELSE IF( GE_32( sphIndex, base_up ) )
{
- id_th++;
+ id_th = add( id_th, 1 );
n_crt = n[id_th];
move16();
base_low = base_up;
@@ -1624,7 +1683,7 @@ void deindex_sph_idx_fx(
}
return;
}
-
+#endif
/*---------------------------------------------------------------
* valid_ratio_index()
*
@@ -1693,7 +1752,7 @@ Word16 valid_ratio_index_fx(
move16();
FOR( i = len - 1; i >= 0; i-- )
{
- IF( EQ_16( index, 0 ) )
+ IF( index == 0 )
{
elem = 0;
move16();
@@ -1768,7 +1827,7 @@ void reconstruct_ism_ratios_fx(
sum = 0;
move32();
- FOR( i = 0; i < sub( nchan_ism, 1 ); i++ )
+ FOR( i = 0; i < nchan_ism - 1; i++ )
{
q_energy_ratio_ism[i] = L_shl( L_mult( ratio_ism_idx[i], step ), 14 ); // q0 + q15 + 1 + 14 = q30;
move32();
@@ -1779,7 +1838,7 @@ void reconstruct_ism_ratios_fx(
q_energy_ratio_ism[nchan_ism - 1] = L_sub( ONE_IN_Q30, sum );
move32();
- IF( LT_32( q_energy_ratio_ism[nchan_ism - 1], 0 ) )
+ if ( q_energy_ratio_ism[nchan_ism - 1] < 0 )
{
q_energy_ratio_ism[nchan_ism - 1] = 0;
move32();
@@ -1917,7 +1976,7 @@ void distribute_evenly_ism_fx(
move16();
FOR( i = 0; i < nchan_ism; i++ )
{
- IF( EQ_16( K, 0 ) )
+ IF( K == 0 )
{
idx[i] = 0;
move16();
@@ -2011,6 +2070,7 @@ Word32 calculate_cpe_brate_MASA_ISM_fx(
WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( ivas_total_brate, ivas_brate_tbl[k] ) )
{
+ test();
k = add( k, 1 );
}
diff --git a/lib_com/ivas_mc_param_com.c b/lib_com/ivas_mc_param_com.c
index 07ab1f9b8b71c6e9e088412728db3138224fca68..1b19b9037c75678cec3b28759ed605fddecd0c68 100644
--- a/lib_com/ivas_mc_param_com.c
+++ b/lib_com/ivas_mc_param_com.c
@@ -36,11 +36,14 @@
#include "options.h"
#include "ivas_cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_stat_com.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*-------------------------------------------------------------------------
@@ -313,7 +316,8 @@ void ivas_param_mc_set_coded_bands(
FOR( i = 0; i < hMetadataPMC->nbands_coded; i++ )
{
- hMetadataPMC->nbands_in_param_frame[hMetadataPMC->coding_band_mapping[i]]++;
+ hMetadataPMC->nbands_in_param_frame[hMetadataPMC->coding_band_mapping[i]] = add( hMetadataPMC->nbands_in_param_frame[hMetadataPMC->coding_band_mapping[i]], 1 );
+ move16();
}
return;
diff --git a/lib_com/ivas_mcmasa_com.c b/lib_com/ivas_mcmasa_com.c
index f8550d48efcff47c2cbaf9b0f1920346da953072..c10c0d2dd30faf65ffb0c134f9b263cffa3b9b41 100644
--- a/lib_com/ivas_mcmasa_com.c
+++ b/lib_com/ivas_mcmasa_com.c
@@ -108,12 +108,14 @@ void ivas_mcmasa_set_separate_channel_mode_fx(
IF( GE_32( ivas_total_brate, MCMASA_SEPARATE_BRATE ) )
{
*separateChannelEnabled = 1;
+ move16();
*separateChannelIndex = 2; /* Center channel */
move16();
}
ELSE
{
*separateChannelEnabled = 0;
+ move16();
*separateChannelIndex = 0;
move16();
}
@@ -165,23 +167,43 @@ void ivas_mcmasa_split_brate_fx(
IF( LT_32( ivas_total_brate, IVAS_96k ) )
{
*brate_sce = Mpy_32_32( MCMASA_MONOBITRATIO_64k_Q31, ivas_total_brate ); /* Q0 */
+ move32();
}
ELSE
{
*brate_sce = Mpy_32_32( MCMASA_MONOBITRATIO_Q31, ivas_total_brate ); /* Q0 */
+ move32();
}
*brate_cpe = L_sub( ivas_total_brate, *brate_sce );
+ move32();
}
ELSE
{
- Word16 tmp_e = 0;
+ Word16 tmp, tmp_e;
+ tmp_e = 0;
move16();
- Word16 tmp = BASOP_Util_Divide3216_Scale( ivas_total_brate, ( add( nCPE, nSCE ) ), &tmp_e );
- *brate_sce = GT_16( nSCE, 0 ) ? ( L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) ) ) : 0;
- move32();
- *brate_cpe = GT_16( nCPE, 0 ) ? ( L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) ) ) : 0;
- move32();
+ tmp = BASOP_Util_Divide3216_Scale( ivas_total_brate, ( add( nCPE, nSCE ) ), &tmp_e );
+ IF( nSCE > 0 )
+ {
+ *brate_sce = L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) );
+ move32();
+ }
+ ELSE
+ {
+ *brate_sce = 0;
+ move32();
+ }
+ IF( nCPE > 0 )
+ {
+ *brate_cpe = L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) );
+ move32();
+ }
+ ELSE
+ {
+ *brate_cpe = 0;
+ move32();
+ }
}
return;
diff --git a/lib_com/ivas_mct_com.c b/lib_com/ivas_mct_com.c
index 6da936755c7000fb82b154096ccc2ed1c45fe9a3..dd79107482c4fb69974d810720acd6fbca5e5fab 100644
--- a/lib_com/ivas_mct_com.c
+++ b/lib_com/ivas_mct_com.c
@@ -35,7 +35,6 @@
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "prot.h"
-#include "prot_fx1.h"
#include "wmc_auto.h"
#include
@@ -210,20 +209,21 @@ void splitAvailableBitsMCT(
Word16 core[MCT_MAX_CHANNELS];
MCT_CHAN_MODE mct_chan_mode[MCT_MAX_CHANNELS];
min_bits_tot = 0;
+ move16();
FOR( i = 0; i < nchan; i++ )
{
IF( enc_dec == ENC )
{
mct_chan_mode[i] = ( (Encoder_State *) sts[i] )->mct_chan_mode;
- move16();
+ move32();
core[i] = ( (Encoder_State *) sts[i] )->core;
move16();
}
ELSE
{
mct_chan_mode[i] = ( (Decoder_State *) sts[i] )->mct_chan_mode;
- move16();
+ move32();
core[i] = ( (Decoder_State *) sts[i] )->core;
move16();
}
@@ -231,24 +231,30 @@ void splitAvailableBitsMCT(
FOR( i = 0; i < nchan; i++ )
{
- IF( mct_chan_mode[i] != MCT_CHAN_MODE_IGNORE )
+ IF( NE_32( mct_chan_mode[i], MCT_CHAN_MODE_IGNORE ) )
{
min_chan_bits[i] = 0;
move16();
- nSubframes = ( core[i] == TCX_20_CORE ) ? 1 : NB_DIV;
- move16();
+ IF( EQ_32( core[i], TCX_20_CORE ) )
+ {
+ nSubframes = 1;
+ move16();
+ }
+ ELSE
+ {
+ nSubframes = NB_DIV;
+ move16();
+ }
FOR( k = 0; k < nSubframes; k++ )
{
- min_chan_bits[i] += SMDCT_MINIMUM_ARITH_BITS + MIN_SAFETY_BITS_MC;
+ min_chan_bits[i] = add( min_chan_bits[i], SMDCT_MINIMUM_ARITH_BITS + MIN_SAFETY_BITS_MC );
move16();
}
- min_bits_tot += min_chan_bits[i];
- move16();
+ min_bits_tot = add( min_bits_tot, min_chan_bits[i] );
}
}
- remaining_bits = total_bits - min_bits_tot;
- move16();
+ remaining_bits = sub( total_bits, min_bits_tot );
/*initial value of bits already given*/
bits_split = 0;
@@ -263,25 +269,20 @@ void splitAvailableBitsMCT(
IF( enc_dec == ENC )
{
bits_frame_channel = &( (Encoder_State *) sts[i] )->bits_frame_channel;
- move16();
}
ELSE /* DEC */
{
bits_frame_channel = &( (Decoder_State *) sts[i] )->bits_frame_channel;
- move16();
}
- IF(
- mct_chan_mode[i] != MCT_CHAN_MODE_IGNORE )
+ IF( NE_32( mct_chan_mode[i], MCT_CHAN_MODE_IGNORE ) )
{
assert( split_ratio[i] >= 1 && split_ratio[i] < BITRATE_MCT_RATIO_RANGE );
- *bits_frame_channel = (Word16) L_shr( (Word32) split_ratio[i] * remaining_bits, NBBITS_MCT_RATIO ) + min_chan_bits[i];
- move16();
- bits_split += *bits_frame_channel;
- move16();
+ *bits_frame_channel = add( extract_l( L_shr( L_mult0( split_ratio[i], remaining_bits ), NBBITS_MCT_RATIO ) ), min_chan_bits[i] );
+ bits_split = add( bits_split, *bits_frame_channel );
/*determine channel with most bits (energy)*/
- IF( *bits_frame_channel > tmp )
+ IF( GT_16( *bits_frame_channel, tmp ) )
{
tmp = *bits_frame_channel;
move16();
@@ -292,10 +293,9 @@ void splitAvailableBitsMCT(
}
/*if bits distributed are more than available bits, substract the proportional amount of bits from all channels*/
- IF( bits_split != total_bits )
+ IF( NE_16( bits_split, total_bits ) )
{
- diff = bits_split - total_bits;
- move16();
+ diff = sub( bits_split, total_bits );
/*re-count bits distributed to each channel*/
bits_split = 0;
@@ -306,68 +306,61 @@ void splitAvailableBitsMCT(
IF( enc_dec == ENC )
{
bits_frame_channel = &( (Encoder_State *) sts[i] )->bits_frame_channel;
- move16();
}
ELSE /* DEC */
{
bits_frame_channel = &( (Decoder_State *) sts[i] )->bits_frame_channel;
- move16();
}
- IF( mct_chan_mode[i] != MCT_CHAN_MODE_IGNORE )
+ IF( NE_32( mct_chan_mode[i], MCT_CHAN_MODE_IGNORE ) )
{
- Word32 temp_res = (Word32) diff * split_ratio[i];
+ Word32 temp_res;
+ temp_res = L_mult0( diff, split_ratio[i] );
IF( temp_res < 0 )
{
- temp_res = -temp_res;
- move16();
+ temp_res = L_negate( temp_res );
temp_res = L_shr( temp_res, NBBITS_MCT_RATIO );
- move16();
- temp_res = -temp_res;
- move16();
+ temp_res = L_negate( temp_res );
}
ELSE
{
temp_res = L_shr( temp_res, NBBITS_MCT_RATIO );
- move16();
}
- *bits_frame_channel -= (Word16) temp_res;
- move16();
- *bits_frame_channel = max( min_chan_bits[i], *bits_frame_channel );
+ *bits_frame_channel = sub( *bits_frame_channel, extract_l( temp_res ) );
move16();
- bits_split += *bits_frame_channel;
+ *bits_frame_channel = s_max( min_chan_bits[i], *bits_frame_channel );
move16();
+ bits_split = add( bits_split, *bits_frame_channel );
}
}
}
/*if there any bits left assign them to the channel with the maximum energy (or more bits)*/
- IF( total_bits != bits_split )
+ IF( NE_16( total_bits, bits_split ) )
{
IF( enc_dec == ENC )
{
bits_frame_channel = &( (Encoder_State *) sts[max_chn] )->bits_frame_channel;
- move16();
}
ELSE /* DEC */
{
bits_frame_channel = &( (Decoder_State *) sts[max_chn] )->bits_frame_channel;
- move16();
}
- *bits_frame_channel += ( total_bits - bits_split );
- move16();
+ *bits_frame_channel = add( *bits_frame_channel, sub( total_bits, bits_split ) );
/*if all channels are silent assign bits to ch 0*/
IF( enc_dec == ENC )
{
- IF( ( (Encoder_State *) sts[max_chn] )->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
+ IF( EQ_32( ( (Encoder_State *) sts[max_chn] )->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
assert( bits_split == 0 );
( (Encoder_State *) sts[max_chn] )->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
- ( (Encoder_State *) sts[max_chn] )->side_bits_frame_channel = ( ( (Encoder_State *) sts[max_chn] )->core ) * ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL );
- *bits_frame_channel -= ( (Encoder_State *) sts[max_chn] )->side_bits_frame_channel;
+ move32();
+ ( (Encoder_State *) sts[max_chn] )->side_bits_frame_channel = imult1616( ( ( (Encoder_State *) sts[max_chn] )->core ), ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ) );
+ move16();
+ *bits_frame_channel = sub( *bits_frame_channel, ( (Encoder_State *) sts[max_chn] )->side_bits_frame_channel );
move16();
}
}
diff --git a/lib_com/ivas_mdct_core_com.c b/lib_com/ivas_mdct_core_com.c
index b98f3a470cd8a456705735e2831b72a209c0a1a5..7e7a00cfc71e19746759cf9ed1da0852d1d4ecfe 100644
--- a/lib_com/ivas_mdct_core_com.c
+++ b/lib_com/ivas_mdct_core_com.c
@@ -37,8 +37,7 @@
#include "prot.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
@@ -55,14 +54,23 @@ void ivas_mdct_tcx10_bit_distribution_fx(
)
{
Word16 k;
- Word16 min_required_bits = add( add( NBITS_TCX_GAIN, i_mult2( NOISE_FILL_RANGES, NBITS_NOISE_FILL_LEVEL ) ), SMDCT_MINIMUM_ARITH_BITS );
+ Word16 min_required_bits;
+ min_required_bits = add( add( NBITS_TCX_GAIN, i_mult2( NOISE_FILL_RANGES, NBITS_NOISE_FILL_LEVEL ) ), SMDCT_MINIMUM_ARITH_BITS );
FOR( k = 0; k < 2; k++ )
{
- IF( nbits_tcx & 1 )
+ IF( s_and( nbits_tcx, 1 ) )
{
- target_bitsTCX10[k] = sub( add( shr( nbits_tcx, 1 ), ( k == 0 ? 1 : 0 ) ), nTnsBitsTCX10[k] );
- move16();
+ IF( k == 0 )
+ {
+ target_bitsTCX10[k] = sub( add( shr( nbits_tcx, 1 ), 1 ), nTnsBitsTCX10[k] );
+ move16();
+ }
+ ELSE
+ {
+ target_bitsTCX10[k] = sub( add( shr( nbits_tcx, 1 ), 0 ), nTnsBitsTCX10[k] );
+ move16();
+ }
}
ELSE
{
diff --git a/lib_com/ivas_mdct_imdct_fx.c b/lib_com/ivas_mdct_imdct_fx.c
index c14432c0839aa787f3423fe0a202b55664b42fcf..c25f4fab4bdcba6f02162341aa654d2fec309cc9 100644
--- a/lib_com/ivas_mdct_imdct_fx.c
+++ b/lib_com/ivas_mdct_imdct_fx.c
@@ -32,7 +32,7 @@
#include
#include "options.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#include "ivas_rom_com_fx.h"
#ifdef DEBUGGING
@@ -69,7 +69,8 @@ void ivas_tda_fx(
)
{
Word16 i;
- Word16 len_by_2 = shr( length, 1 );
+ Word16 len_by_2;
+ len_by_2 = shr( length, 1 );
FOR( i = 0; i < len_by_2; i++ )
{
@@ -101,19 +102,22 @@ void ivas_dct_windowing_fx(
Word32 *pTemp_lfe )
{
Word16 i;
- Word16 rem_len = 0;
+ Word16 rem_len;
+ rem_len = 0;
+ move16();
Copy32( pBuffer_prev, pOut_buf + zero_pad_len, fade_len );
- Copy32( pTemp_lfe, ( pOut_buf + fade_len + zero_pad_len ), dct_len );
+ Copy32( pTemp_lfe, ( pOut_buf + add( fade_len, zero_pad_len ) ), dct_len );
set32_fx( pOut_buf, 0, zero_pad_len );
- Copy32( ( pOut_buf + full_len - fade_len ), pBuffer_prev, fade_len );
+ Copy32( ( pOut_buf + sub( full_len, fade_len ) ), pBuffer_prev, fade_len );
FOR( i = 0; i < fade_len; i++ )
{
pOut_buf[add( zero_pad_len, i )] = Mult_32_32( pOut_buf[add( zero_pad_len, i )], pWindow_coeffs[i] );
+ move32();
}
rem_len = sub( full_len, ( add( i_mult( zero_pad_len, 3 ), fade_len ) ) );
@@ -121,6 +125,7 @@ void ivas_dct_windowing_fx(
FOR( i = 0; i < rem_len; i++ )
{
pOut_buf[add( add( i_mult( zero_pad_len, 3 ), fade_len ), i )] = Mult_32_32( pOut_buf[add( add( i_mult( zero_pad_len, 3 ), fade_len ), i )], pWindow_coeffs[sub( sub( fade_len, i ), 1 )] );
+ move32();
}
set32_fx( &pOut_buf[full_len], 0, sub( frame_len, full_len ) );
@@ -153,14 +158,18 @@ void ivas_mdct_fx(
FOR( i = 0; i < len_by_2; i++ )
{
- pOut[i] = L_sub( pIn[len_by_2 + i], pIn[len_by_2 - i - 1] );
- pOut[len_by_2 + i] = L_add( pIn[length * 2 - i - 1], pIn[length + i] );
+ pOut[i] = L_sub( pIn[add( len_by_2, i )], pIn[sub( sub( len_by_2, i ), 1 )] );
+ move32();
+ pOut[add( len_by_2, i )] = L_add( pIn[sub( sub( imult1616( length, 2 ), i ), 1 )], pIn[add( length, i )] );
+ move32();
}
FOR( i = 0; i < len_by_2; i++ )
{
- re[i] = L_negate( L_add( Mpy_32_16_1( pOut[2 * i], pTwid_re[i] ), Mpy_32_16_1( pOut[length - 1 - 2 * i], pTwid_im[i] ) ) );
- im[i] = L_sub( Mpy_32_16_1( pOut[length - 1 - 2 * i], pTwid_re[i] ), Mpy_32_16_1( pOut[2 * i], pTwid_im[i] ) );
+ re[i] = L_negate( L_add( Mpy_32_16_1( pOut[2 * i], pTwid_re[i] ), Mpy_32_16_1( pOut[sub( sub( length, 1 ), imult1616( 2, i ) )], pTwid_im[i] ) ) );
+ move32();
+ im[i] = L_sub( Mpy_32_16_1( pOut[sub( sub( length, 1 ), imult1616( 2, i ) )], pTwid_re[i] ), Mpy_32_16_1( pOut[2 * i], pTwid_im[i] ) );
+ move32();
}
DoFFT_fx( &re[0], &im[0], len_by_2 );
@@ -168,21 +177,28 @@ void ivas_mdct_fx(
FOR( i = 0; i < len_by_2; i++ )
{
re[i] = Mult_32_32( re[i], ivas_mdct_scaling_gain );
+ move32();
im[i] = Mult_32_32( im[i], ivas_mdct_scaling_gain );
+ move32();
}
- *q_out = *q_out + Q15;
+ *q_out = add( *q_out, Q15 );
+ move16();
FOR( i = 0; i < len_by_2; i++ )
{
Word32 tmp;
tmp = L_sub( Mpy_32_16_1( re[i], pTwid_re[i] ), Mpy_32_16_1( im[i], pTwid_im[i] ) );
im[i] = L_add( Mpy_32_16_1( im[i], pTwid_re[i] ), Mpy_32_16_1( re[i], pTwid_im[i] ) );
+ move32();
re[i] = tmp;
+ move32();
}
FOR( i = 0; i < len_by_2; i++ )
{
- pOut[length - 2 * i - 1] = re[i];
+ pOut[sub( sub( length, imult1616( 2, i ) ), 1 )] = re[i];
+ move32();
pOut[2 * i] = im[i];
+ move32();
}
return;
@@ -201,23 +217,32 @@ static void ivas_ifft_cplx(
const Word16 length )
{
Word16 i;
- Word32 ivas_imdct_one_by_powergain = IVAS_ONE_BY_IMDCT_SCALING_GAIN_Q16;
+ Word32 ivas_imdct_one_by_powergain;
+ ivas_imdct_one_by_powergain = IVAS_ONE_BY_IMDCT_SCALING_GAIN_Q16;
+ move32();
/*re-arrange inputs to use fft as ifft */
re[0] = Mult_32_32( re[0], ivas_imdct_one_by_powergain );
+ move32();
im[0] = Mult_32_32( im[0], ivas_imdct_one_by_powergain );
+ move32();
FOR( i = 1; i <= shr( length, 1 ); i++ )
{
- Word32 tmp = Mult_32_32( re[length - i], ivas_imdct_one_by_powergain );
- re[length - i] = Mult_32_32( re[i], ivas_imdct_one_by_powergain );
+ Word32 tmp;
+ tmp = Mult_32_32( re[sub( length, i )], ivas_imdct_one_by_powergain );
+ re[sub( length, i )] = Mult_32_32( re[i], ivas_imdct_one_by_powergain );
+ move32();
re[i] = tmp;
+ move32();
- tmp = Mult_32_32( im[length - i], ivas_imdct_one_by_powergain );
- im[length - i] = Mult_32_32( im[i], ivas_imdct_one_by_powergain );
+ tmp = Mult_32_32( im[sub( length, i )], ivas_imdct_one_by_powergain );
+ im[sub( length, i )] = Mult_32_32( im[i], ivas_imdct_one_by_powergain );
+ move32();
im[i] = tmp;
+ move32();
}
- DoFFT_fx( re, im, (Word16) length );
+ DoFFT_fx( re, im, length );
return;
}
@@ -236,14 +261,19 @@ void ivas_itda_fx(
)
{
Word16 i;
- Word16 len_by_2 = shr( length, 1 );
+ Word16 len_by_2;
+ len_by_2 = shr( length, 1 );
FOR( i = 0; i < len_by_2; i++ )
{
- pOut[i] = -re[len_by_2 - i - 1];
- pOut[len_by_2 + i] = re[i];
- pOut[length + i] = re[len_by_2 + i];
- pOut[3 * len_by_2 + i] = re[length - i - 1];
+ pOut[i] = L_negate( re[sub( sub( len_by_2, i ), 1 )] );
+ move32();
+ pOut[add( len_by_2, i )] = re[i];
+ move32();
+ pOut[add( length, i )] = re[add( len_by_2, i )];
+ move32();
+ pOut[add( imult1616( 3, len_by_2 ), i )] = re[sub( sub( length, i ), 1 )];
+ move32();
}
return;
@@ -263,23 +293,27 @@ void ivas_imdct_fx(
Word16 *q_out )
{
const Word16 *pTwid_re, *pTwid_im;
- Word16 len_by_2 = shr( length, 1 );
+ Word16 len_by_2;
Word16 i;
Word32 re[IVAS_480_PT_LEN];
Word32 im[IVAS_480_PT_LEN];
+ len_by_2 = shr( length, 1 );
ivas_get_twid_factors_fx1( length, &pTwid_re, &pTwid_im );
FOR( i = 0; i < len_by_2; i++ )
{
- re[i] = L_add( Mpy_32_16_1( pIn[length - 2 * i - 1], pTwid_re[i] ), Mpy_32_16_1( pIn[2 * i], pTwid_im[i] ) ); /*stl_arr_index*/
- im[i] = L_sub( Mpy_32_16_1( pIn[2 * i], pTwid_re[i] ), Mpy_32_16_1( pIn[length - 2 * i - 1], pTwid_im[i] ) ); /*stl_arr_index*/
+ re[i] = L_add( Mpy_32_16_1( pIn[sub( sub( length, shl( i, 1 ) ), 1 )], pTwid_re[i] ), Mpy_32_16_1( pIn[2 * i], pTwid_im[i] ) ); /*stl_arr_index*/
+ move32();
+ im[i] = L_sub( Mpy_32_16_1( pIn[2 * i], pTwid_re[i] ), Mpy_32_16_1( pIn[sub( sub( length, shl( i, 1 ) ), 1 )], pTwid_im[i] ) ); /*stl_arr_index*/
+ move32();
}
ivas_ifft_cplx( &re[0], &im[0], len_by_2 );
- IF( GT_16( len_by_2, 0 ) )
+ IF( len_by_2 > 0 )
{
- *q_out = *q_out - Q15;
+ *q_out = sub( *q_out, Q15 );
+ move16();
}
FOR( i = 0; i < len_by_2; i++ )
@@ -287,21 +321,29 @@ void ivas_imdct_fx(
Word32 tmp;
tmp = L_add( Mpy_32_16_1( re[i], pTwid_re[i] ), Mpy_32_16_1( im[i], pTwid_im[i] ) );
im[i] = L_sub( Mpy_32_16_1( im[i], pTwid_re[i] ), Mpy_32_16_1( re[i], pTwid_im[i] ) );
+ move32();
re[i] = tmp;
+ move32();
}
FOR( i = ( len_by_2 - 1 ); i >= 0; i-- )
{
- re[2 * i + 1] = im[( len_by_2 - 1 ) - i];
- re[2 * i] = -re[i];
+ re[add( shl( i, 1 ), 1 )] = im[sub( sub( len_by_2, 1 ), i )];
+ move32();
+ re[2 * i] = L_negate( re[i] );
+ move32();
}
FOR( i = 0; i < len_by_2; i++ )
{
- pOut[i] = -re[len_by_2 - i - 1];
- pOut[len_by_2 + i] = re[i];
- pOut[length + i] = re[len_by_2 + i];
- pOut[3 * len_by_2 + i] = re[length - i - 1];
+ pOut[i] = L_negate( re[sub( sub( len_by_2, i ), 1 )] );
+ move32();
+ pOut[add( len_by_2, i )] = re[i];
+ move32();
+ pOut[add( length, i )] = re[add( len_by_2, i )];
+ move32();
+ pOut[add( imult1616( 3, len_by_2 ), i )] = re[sub( sub( length, i ), 1 )];
+ move32();
}
return;
@@ -313,7 +355,6 @@ void ivas_imdct_fx(
*
* Sets/Maps the fft twiddle tables based on fft length
*-----------------------------------------------------------------------------------------*/
-
void ivas_get_twid_factors_fx1(
const Word16 length,
const Word16 **pTwid_re,
@@ -347,7 +388,6 @@ void ivas_get_twid_factors_fx1(
return;
}
-
/*-----------------------------------------------------------------------------------------*
* Function ivas_get_mdct_scaling_gain_fx()
*
@@ -357,23 +397,28 @@ void ivas_get_twid_factors_fx1(
Word32 ivas_get_mdct_scaling_gain_fx(
const Word16 dct_len_by_2 )
{
- Word32 gain = 0;
+ Word32 gain;
+ gain = 0;
+ move32();
SWITCH( dct_len_by_2 )
{
case L_FRAME48k >> 2:
{
gain = IVAS_MDCT_SCALING_GAIN_48k_Q46;
+ move32();
BREAK;
}
case L_FRAME32k >> 2:
{
gain = IVAS_MDCT_SCALING_GAIN_32k_Q46;
+ move32();
BREAK;
}
case L_FRAME16k >> 2:
{
gain = IVAS_MDCT_SCALING_GAIN_16k_Q46;
+ move32();
BREAK;
}
default:
diff --git a/lib_com/ivas_mdft_imdft.c b/lib_com/ivas_mdft_imdft.c
index ab93395231c61ba4b21082b67ae4980d533f3c30..564285b094a41ecc65afedfdacf4ca53345fea1c 100644
--- a/lib_com/ivas_mdft_imdft.c
+++ b/lib_com/ivas_mdft_imdft.c
@@ -41,13 +41,15 @@
#ifdef IVAS_FLOAT_FIXED
#include
#include
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "debug.h"
#define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) )
#define fix_to_float( n, factor ) ( (float) n / ( 1 << factor ) )
#define SHC( x ) ( (Word16) x )
#endif
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*-----------------------------------------------------------------------------------------*
* Local constants
@@ -77,14 +79,13 @@ static void ivas_get_mdft_twid_factors_fx(
const Word16 length,
const Word32 **ppTwid )
{
- switch ( length )
+ SWITCH( length )
{
case L_FRAME48k:
*ppTwid = &ivas_mdft_coeff_cos_twid_960_fx[0];
break;
case L_FRAME32k:
*ppTwid = &ivas_mdft_coeff_cos_twid_640_fx[0];
-
break;
case L_FRAME16k:
*ppTwid = &ivas_mdft_coeff_cos_twid_320_fx[0];
@@ -104,7 +105,6 @@ static void ivas_get_mdft_twid_factors_fx(
case IVAS_40_PT_LEN:
*ppTwid = &ivas_mdft_coeff_cos_twid_40_fx[0];
break;
-
default:
assert( !"Not supported FFT length!" );
break;
@@ -122,7 +122,7 @@ static void ivas_get_imdft_twid_factors_fx(
const Word16 length,
const Word32 **ppTwid )
{
- switch ( length )
+ SWITCH( length )
{
case L_FRAME48k:
*ppTwid = ivas_mdft_coeff_cos_twid_960_fx;
@@ -271,31 +271,37 @@ static void get_one_by_length_fx(
Word32 *one_by_length,
const Word16 length )
{
- if ( length == L_FRAME48k )
+ IF( EQ_16( length, L_FRAME48k ) )
{
*one_by_length = IVAS_ONE_BY_960_Q37;
+ move32();
}
- else if ( length == L_FRAME32k )
+ ELSE IF( EQ_16( length, L_FRAME32k ) )
{
*one_by_length = IVAS_ONE_BY_640_Q37;
+ move32();
}
- else if ( length == L_FRAME16k )
+ ELSE IF( EQ_16( length, L_FRAME16k ) )
{
*one_by_length = IVAS_ONE_BY_320_Q37;
+ move32();
}
- else if ( length == IVAS_240_PT_LEN )
+ ELSE IF( EQ_16( length, IVAS_240_PT_LEN ) )
{
*one_by_length = IVAS_ONE_BY_240_Q37;
+ move32();
}
- else if ( length == IVAS_160_PT_LEN )
+ ELSE IF( EQ_16( length, IVAS_160_PT_LEN ) )
{
*one_by_length = IVAS_ONE_BY_160_Q37;
+ move32();
}
- else if ( length == IVAS_80_PT_LEN )
+ ELSE IF( EQ_16( length, IVAS_80_PT_LEN ) )
{
*one_by_length = IVAS_ONE_BY_80_Q37;
+ move32();
}
- else
+ ELSE
{
assert( !"Not supported FFT length!" );
}
@@ -320,17 +326,23 @@ static void ivas_ifft_cplx1_fx(
/* re-arrange inputs to use fft as ifft */
re[0] = Mpy_32_32( re[0], one_by_length );
+ move32();
im[0] = Mpy_32_32( im[0], one_by_length );
+ move32();
- for ( i = 1; i <= length >> 1; i++ )
+ FOR( i = 1; i <= length >> 1; i++ )
{
- tmp = Mpy_32_32( re[length - i], one_by_length ); /*stl_arr_index*/
- re[length - i] = Mpy_32_32( re[i], one_by_length ); /*stl_arr_index*/
+ tmp = Mpy_32_32( re[sub( length, i )], one_by_length ); /*stl_arr_index*/
+ re[sub( length, i )] = Mpy_32_32( re[i], one_by_length ); /*stl_arr_index*/
+ move32();
re[i] = tmp;
+ move32();
- tmp = Mpy_32_32( im[length - i], one_by_length ); /*stl_arr_index*/
- im[length - i] = Mpy_32_32( im[i], one_by_length ); /*stl_arr_index*/
+ tmp = Mpy_32_32( im[sub( length, i )], one_by_length ); /*stl_arr_index*/
+ im[sub( length, i )] = Mpy_32_32( im[i], one_by_length ); /*stl_arr_index*/
+ move32();
im[i] = tmp;
+ move32();
}
fft_fx( re, im, length, 1 );
@@ -358,34 +370,42 @@ void ivas_mdft_fx(
Word32 im[L_FRAME48k];
Word16 j, len_by_2;
const Word32 *pTwid;
- len_by_2 = mdft_length >> 1;
+ len_by_2 = shr( mdft_length, 1 );
ivas_get_mdft_twid_factors_fx( mdft_length, &pTwid );
- if ( mdft_length == input_length )
+ IF( EQ_16( mdft_length, input_length ) )
{
- for ( j = 0; j < mdft_length; j++ )
+ FOR( j = 0; j < mdft_length; j++ )
{
re[j] = Mpy_32_32( pIn[j], pTwid[j] );
- im[j] = Mpy_32_32( -pIn[j], pTwid[mdft_length - j] );
+ move32();
+ im[j] = Mpy_32_32( L_negate( pIn[j] ), pTwid[sub( mdft_length, j )] );
+ move32();
}
}
- else
+ ELSE
{
- for ( j = 0; j < mdft_length; j++ )
+ FOR( j = 0; j < mdft_length; j++ )
{
- re[j] = Msub_32_32( Mpy_32_32( pIn[j], pTwid[j] ), pIn[j + mdft_length], pTwid[mdft_length - j] );
- im[j] = Msub_32_32( Mpy_32_32( -pIn[j], pTwid[mdft_length - j] ), pIn[j + mdft_length], pTwid[j] );
+ re[j] = Msub_32_32( Mpy_32_32( pIn[j], pTwid[j] ), pIn[add( mdft_length, j )], pTwid[sub( mdft_length, j )] );
+ move32();
+ im[j] = Msub_32_32( Mpy_32_32( L_negate( pIn[j] ), pTwid[sub( mdft_length, j )] ), pIn[add( mdft_length, j )], pTwid[j] );
+ move32();
}
}
fft_fx( re, im, mdft_length, 1 );
- for ( j = 0; j < len_by_2; j++ )
+ FOR( j = 0; j < len_by_2; j++ )
{
pOut_re[2 * j] = re[j];
- pOut_re[2 * j + 1] = re[mdft_length - j - 1];
+ move32();
+ pOut_re[add( imult1616( 2, j ), 1 )] = re[sub( sub( mdft_length, j ), 1 )];
+ move32();
pOut_im[2 * j] = im[j];
- pOut_im[2 * j + 1] = -im[mdft_length - j - 1];
+ move32();
+ pOut_im[add( imult1616( 2, j ), 1 )] = L_negate( im[sub( sub( mdft_length, j ), 1 )] );
+ move32();
}
return;
}
@@ -408,28 +428,35 @@ void ivas_imdft_fx(
Word32 *re_tmp = pOut;
Word32 *im_tmp = pOut + length;
Word32 tmp;
- Word32 j;
- Word32 len_by_2 = length >> 1;
+ Word16 j;
+ Word16 len_by_2;
const Word32 *pTwid;
+ len_by_2 = shr( length, 1 );
ivas_get_imdft_twid_factors_fx( length, &pTwid );
- for ( j = 0; j < len_by_2; j++ )
+ FOR( j = 0; j < len_by_2; j++ )
{
re_tmp[j] = pRe[2 * j];
- re_tmp[j + len_by_2] = pRe[length - 2 * j - 1];
+ move32();
+ re_tmp[add( j, len_by_2 )] = pRe[sub( sub( length, imult1616( 2, j ) ), 1 )];
+ move32();
im_tmp[j] = pIm[2 * j];
- im_tmp[j + len_by_2] = -pIm[length - 2 * j - 1];
+ move32();
+ im_tmp[add( j, len_by_2 )] = L_negate( pIm[sub( sub( length, imult1616( 2, j ) ), 1 )] );
+ move32();
}
ivas_ifft_cplx1_fx( re_tmp, im_tmp, length );
- for ( j = 0; j < length; j++ )
+ FOR( j = 0; j < length; j++ )
{
- tmp = Msub_32_32( Mpy_32_32( re_tmp[j] >> 6, pTwid[j] ), im_tmp[j] >> 6, pTwid[length - j] );
- im_tmp[j] = -( Madd_32_32( Mpy_32_32( re_tmp[j] >> 6, pTwid[length - j] ), im_tmp[j] >> 6, pTwid[j] ) );
+ tmp = Msub_32_32( Mpy_32_32( L_shr( re_tmp[j], Q6 ), pTwid[j] ), L_shr( im_tmp[j], Q6 ), pTwid[sub( length, j )] );
+ im_tmp[j] = L_negate( Madd_32_32( Mpy_32_32( L_shr( re_tmp[j], Q6 ), pTwid[sub( length, j )] ), L_shr( im_tmp[j], Q6 ), pTwid[j] ) );
+ move32();
re_tmp[j] = tmp;
+ move32();
}
return;
}
diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com.c
index afdac0d9bc934bdab993ab1eb7f5cac23dc75285..5dbe0386623a0845e217207edbca48b86f06bfe9 100644
--- a/lib_com/ivas_omasa_com.c
+++ b/lib_com/ivas_omasa_com.c
@@ -36,11 +36,10 @@
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "prot.h"
-#include "prot_fx1.h"
#include "ivas_rom_com.h"
#include "rom_com.h"
#include
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*---------------------------------------------------------------
* Local constants
@@ -95,7 +94,7 @@ ISM_MODE ivas_omasa_ism_mode_select_fx(
)
{
ISM_MODE ism_mode = ISM_MODE_NONE;
- move16();
+ move32();
SWITCH( nchan_ism )
{
@@ -103,73 +102,73 @@ ISM_MODE ivas_omasa_ism_mode_select_fx(
IF( GE_32( ivas_total_brate, IVAS_24k4 ) )
{
ism_mode = ISM_MASA_MODE_DISC;
- move16();
+ move32();
}
ELSE
{
ism_mode = ISM_MODE_NONE;
- move16();
+ move32();
}
BREAK;
case 2:
IF( GE_32( ivas_total_brate, IVAS_48k ) )
{
ism_mode = ISM_MASA_MODE_DISC;
- move16();
+ move32();
}
ELSE IF( GE_32( ivas_total_brate, IVAS_32k ) )
{
ism_mode = ISM_MASA_MODE_PARAM_ONE_OBJ;
- move16();
+ move32();
}
ELSE
{
ism_mode = ISM_MODE_NONE;
- move16();
+ move32();
}
BREAK;
case 3:
IF( GE_32( ivas_total_brate, IVAS_96k ) )
{
ism_mode = ISM_MASA_MODE_DISC;
- move16();
+ move32();
}
ELSE IF( GE_32( ivas_total_brate, IVAS_64k ) )
{
ism_mode = ISM_MASA_MODE_PARAM_ONE_OBJ;
- move16();
+ move32();
}
ELSE IF( GE_32( ivas_total_brate, IVAS_32k ) )
{
ism_mode = ISM_MASA_MODE_MASA_ONE_OBJ;
- move16();
+ move32();
}
ELSE
{
ism_mode = ISM_MODE_NONE;
- move16();
+ move32();
}
BREAK;
case 4:
IF( GE_32( ivas_total_brate, IVAS_128k ) )
{
ism_mode = ISM_MASA_MODE_DISC;
- move16();
+ move32();
}
ELSE IF( GE_32( ivas_total_brate, IVAS_64k ) )
{
ism_mode = ISM_MASA_MODE_PARAM_ONE_OBJ;
- move16();
+ move32();
}
ELSE IF( GE_32( ivas_total_brate, IVAS_32k ) )
{
ism_mode = ISM_MASA_MODE_MASA_ONE_OBJ;
- move16();
+ move32();
}
ELSE
{
ism_mode = ISM_MODE_NONE;
- move16();
+ move32();
}
BREAK;
}
@@ -661,8 +660,10 @@ void ivas_combined_format_brate_sanity_fx(
nBits = extract_l( Mpy_32_32( *core_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
*diff_nBits = sub( nBits, limit_high );
+ move16();
IF( *diff_nBits > 0 )
{
+ test();
IF( EQ_16( core, TCX_20_CORE ) || EQ_16( core, TCX_10_CORE ) )
{
*diff_nBits = 0;
@@ -671,6 +672,7 @@ void ivas_combined_format_brate_sanity_fx(
ELSE /* ACELP core */
{
*core_brate = L_sub( *core_brate, L_mult0( *diff_nBits, FRAMES_PER_SEC ) );
+ move32();
}
}
}
@@ -883,6 +885,12 @@ void calculate_nbits_meta(
static Word16 get_bits_ism( Word32 val )
{
Word16 res;
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
IF( LE_32( val, 536870912 ) && GT_32( val, 447750340 ) )
{
res = 0;
@@ -1038,19 +1046,22 @@ void get_panning_gain(
const Word16 sinAngleMapped,
Word16 *panningGains )
{
- Word16 tbl_len = 601;
- Word16 idx = shr( tbl_len, 1 );
+ Word16 tbl_len, idx, lim_l, lim_r;
const Word16 *ptr_sin = &ivas_sine_panning_tbl_fx[0];
const Word16 *ptr_tan_0 = ivas_tan_panning_gain_tbl_fx;
- Word16 lim_l = 0;
+ tbl_len = 601;
move16();
- Word16 lim_r = tbl_len;
+ idx = shr( tbl_len, 1 );
+ lim_l = 0;
+ move16();
+ lim_r = tbl_len;
move16();
WHILE( 1 )
{
idx = shr( add( lim_l, lim_r ), 1 );
+ test();
IF( GE_16( idx, tbl_len ) )
{
panningGains[0] = ptr_tan_0[tbl_len - 1];
@@ -1059,7 +1070,7 @@ void get_panning_gain(
move16();
BREAK;
}
- ELSE IF( LT_16( idx, 0 ) )
+ ELSE IF( idx < 0 )
{
panningGains[0] = ptr_tan_0[0];
move16();
@@ -1073,7 +1084,7 @@ void get_panning_gain(
{
panningGains[0] = ptr_tan_0[idx + 1];
move16();
- panningGains[1] = ptr_tan_0[tbl_len - idx - 2];
+ panningGains[1] = ptr_tan_0[sub( sub( tbl_len, idx ), 2 )];
move16();
BREAK;
}
@@ -1081,25 +1092,26 @@ void get_panning_gain(
{
panningGains[0] = ptr_tan_0[idx];
move16();
- panningGains[1] = ptr_tan_0[tbl_len - idx - 1];
+ panningGains[1] = ptr_tan_0[sub( sub( tbl_len, idx ), 1 )];
move16();
BREAK;
}
ELSE
{
- Word16 mid = extract_l( L_shr( L_add( L_deposit_l( ptr_sin[idx] ), L_deposit_l( ptr_sin[idx + 1] ) ), 1 ) );
+ Word16 mid;
+ mid = extract_l( L_shr( L_add( L_deposit_l( ptr_sin[idx] ), L_deposit_l( ptr_sin[idx + 1] ) ), 1 ) );
IF( LE_16( sinAngleMapped, mid ) )
{
panningGains[0] = ptr_tan_0[idx];
move16();
- panningGains[1] = ptr_tan_0[tbl_len - idx - 1];
+ panningGains[1] = ptr_tan_0[sub( sub( tbl_len, idx ), 1 )];
move16();
}
ELSE
{
panningGains[0] = ptr_tan_0[idx + 1];
move16();
- panningGains[1] = ptr_tan_0[tbl_len - idx - 2];
+ panningGains[1] = ptr_tan_0[sub( sub( tbl_len, idx ), 2 )];
move16();
}
BREAK;
@@ -1147,7 +1159,8 @@ void ivas_get_stereo_panning_gains_fx(
azSubEl = add( azSubEl, 360 );
}
// sin_az_cos_el = (ptr_sin_az[azAddEl] + ptr_sin_az[azSubEl])/2;
- Word16 sin_az_cos_el = extract_l( L_shr( L_add( L_deposit_l( ptr_sin_az[azAddEl + 180] ), L_deposit_l( ptr_sin_az[azSubEl + 180] ) ), 1 ) );
+ Word16 sin_az_cos_el;
+ sin_az_cos_el = extract_l( L_shr( L_add( L_deposit_l( ptr_sin_az[azAddEl + 180] ), L_deposit_l( ptr_sin_az[azSubEl + 180] ) ), 1 ) );
IF( GE_16( sin_az_cos_el, SIN_30_DEGREES_Q15 ) )
{ /* Left side */
@@ -1198,13 +1211,14 @@ Word16 calculate_brate_limit_flag_fx(
FOR( n = 0; n < nchan_ism; n++ )
{
brate_limit_flag = add( brate_limit_flag, ism_imp[n] );
- if ( ism_imp[n] == 0 )
+ IF( ism_imp[n] == 0 )
{
nzeros = add( nzeros, 1 );
}
}
nchan_ism_sat = nchan_ism;
- if ( EQ_16( nchan_ism & 1, 1 ) )
+ move16();
+ IF( EQ_16( s_and( nchan_ism, 1 ), 1 ) )
{
nchan_ism_sat = sub( nchan_ism, 1 );
}
diff --git a/lib_com/ivas_pca_tools.c b/lib_com/ivas_pca_tools.c
index 98db76f4b8c28a6207e500248f76b827f556bbe9..f2c6d8d0e96fbc851d878ed4e01c0edef0c3de50 100644
--- a/lib_com/ivas_pca_tools.c
+++ b/lib_com/ivas_pca_tools.c
@@ -40,7 +40,7 @@
#include "wmc_auto.h"
#include "prot.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
+#include "prot_fx.h"
#endif
/*---------------------------------------------------------------------*
@@ -82,7 +82,7 @@ void eye_matrix_fx(
}
FOR( i = 0; i < n; i++ )
{
- mat[i * n + i] = d;
+ mat[add( imult1616( i, n ), i )] = d;
move16();
}
@@ -606,21 +606,37 @@ void dquat2mat_fx(
dy = mult( d, y );
dz = mult( d, z );
m[0] = sub( sub( aw, bx ), add( cy, dz ) );
+ move16();
m[1] = sub( sub( cz, dy ), add( ax, bw ) );
- m[2] = add( sub( sub( -ay, bz ), cw ), dx );
+ move16();
+ m[2] = add( sub( sub( negate( ay ), bz ), cw ), dx );
+ move16();
m[3] = sub( sub( by, az ), add( cx, dw ) );
+ move16();
m[4] = add( sub( add( bw, ax ), dy ), cz );
- m[5] = add( add( add( -bx, aw ), dz ), cy );
- m[6] = sub( sub( add( -by, az ), dw ), cx );
- m[7] = add( sub( sub( -bz, ay ), dx ), cw );
+ move16();
+ m[5] = add( add( add( negate( bx ), aw ), dz ), cy );
+ move16();
+ m[6] = sub( sub( add( negate( by ), az ), dw ), cx );
+ move16();
+ m[7] = add( sub( sub( negate( bz ), ay ), dx ), cw );
+ move16();
m[8] = sub( add( add( cw, dx ), ay ), bz );
- m[9] = sub( sub( add( -cx, dw ), az ), by );
- m[10] = add( add( add( -cy, dz ), aw ), bx );
- m[11] = sub( add( sub( -cz, dy ), ax ), bw );
+ move16();
+ m[9] = sub( sub( add( negate( cx ), dw ), az ), by );
+ move16();
+ m[10] = add( add( add( negate( cy ), dz ), aw ), bx );
+ move16();
+ m[11] = sub( add( sub( negate( cz ), dy ), ax ), bw );
+ move16();
m[12] = add( add( sub( dw, cx ), by ), az );
- m[13] = add( sub( sub( -dx, cw ), bz ), ay );
- m[14] = sub( add( sub( -dy, cz ), bw ), ax );
- m[15] = add( add( add( -dz, cy ), bx ), aw );
+ move16();
+ m[13] = add( sub( sub( negate( dx ), cw ), bz ), ay );
+ move16();
+ m[14] = sub( add( sub( negate( dy ), cz ), bw ), ax );
+ move16();
+ m[15] = add( add( add( negate( dz ), cy ), bx ), aw );
+ move16();
return;
}
@@ -691,23 +707,28 @@ void quat_shortestpath_fx(
{
Word32 d0, d1;
Word16 res, i;
- Word16 exp1 = 0, exp2 = 0;
+ Word16 exp1, exp2;
+ exp1 = 0;
+ move16();
+ exp2 = 0;
+ move16();
d0 = dotp_fx( q00, q01, IVAS_PCA_INTERP, &exp1 );
d1 = dotp_fx( q10, q11, IVAS_PCA_INTERP, &exp2 );
res = 0;
move16();
- IF( LT_32( d0, 0 ) && LT_32( d1, 0 ) )
+ test();
+ IF( d0 < 0 && d1 < 0 )
{
res = 1;
move16();
}
ELSE
{
- IF( LT_32( d0, 0 ) )
+ IF( d0 < 0 )
{
- IF( GT_32( ( -d0 ), d1 ) )
+ if ( GT_32( L_negate( d0 ), d1 ) )
{
res = 1;
move16();
@@ -715,9 +736,9 @@ void quat_shortestpath_fx(
}
ELSE
{
- IF( LT_32( d1, 0 ) )
+ IF( d1 < 0 )
{
- IF( GT_32( ( -d1 ), d0 ) )
+ if ( GT_32( L_negate( d1 ), d0 ) )
{
res = 1;
move16();
@@ -730,9 +751,9 @@ void quat_shortestpath_fx(
{
FOR( i = 0; i < IVAS_PCA_INTERP; i++ )
{
- q01[i] = -q01[i];
+ q01[i] = negate( q01[i] );
move16();
- q11[i] = -q11[i];
+ q11[i] = negate( q11[i] );
move16();
}
}
@@ -802,14 +823,17 @@ static void norm_quat_fx(
Word16 *q )
{
Word32 norm_q;
- Word16 i, exp1 = 0;
+ Word16 i, exp1;
+ exp1 = 0;
+ move16();
norm_q = dotp_fx( q, q, IVAS_PCA_INTERP, &exp1 );
- exp1 = ( 31 - ( exp1 + 2 ) );
+ exp1 = sub( 31, add( exp1, 2 ) );
norm_q = ISqrt32( norm_q, &exp1 ); /*q(15 - exp)*/
FOR( i = 0; i < IVAS_PCA_INTERP; i++ )
{
- q[i] = mult( q[i], (Word16) L_shr( norm_q, 15 ) ); // todo : recheck
+ q[i] = mult( q[i], extract_l( L_shr( norm_q, 15 ) ) ); // todo : recheck
+ move16();
}
return;
@@ -846,11 +870,15 @@ static void quat_nlerp_preproc_fx(
FOR( i = 0; i < IVAS_PCA_INTERP; i++ )
{
- tmp1 = mult( ( MAX_16 - alpha ), q1[i] );
+ tmp1 = mult( sub( MAX_16, alpha ), q1[i] );
tmp2 = mult_r( alpha, q0[i] );
- IF( ( alpha == q0[i] ) && ( alpha == 32767 ) )
- tmp2 = 32767;
+ if ( EQ_16( alpha, q0[i] ) && EQ_16( alpha, 32767 ) )
+ {
+ tmp2 = 32767;
+ move16();
+ }
q_slerp[i] = add( tmp1, tmp2 );
+ move16();
}
norm_quat_fx( q_slerp );
@@ -898,13 +926,15 @@ void pca_interp_preproc_fx(
FOR( j = 0; j < len; j++ )
{
tmp = sub( len, 1 );
- IF( EQ_16( j, 0 ) )
+ IF( j == 0 )
{
alpha = 0;
move16();
}
ELSE
- alpha = idiv1616( j, tmp ); // the increment can be updated by simple delta //q15
+ {
+ alpha = idiv1616( j, tmp ); // the increment can be updated by simple delta //q15
+ }
tmp2 = mult( EVS_PI_FX, alpha ); // q13
tmp3 = getCosWord16( tmp2 ); // q14
alpha = shr( sub( ONE_IN_Q14, tmp3 ), 1 ); // q15
@@ -960,9 +990,13 @@ static void sp2cart_fx(
s2 = getSinWord16( ph2 ); // q15
s1s2 = mult( s1, s2 ); // q15
q[3] = mult( getSinWord16( ph3 ), s1s2 ); // q15
+ move16();
q[2] = mult( getCosWord16( ph3 ), s1s2 ); // q15
- q[1] = mult( getCosWord16( ph2 ), s1 ); // q15
+ move16();
+ q[1] = mult( getCosWord16( ph2 ), s1 ); // q15
+ move16();
q[0] = shl_sat( getCosWord16( ph1 ), 1 ); // q15
+ move16();
return;
}
@@ -986,10 +1020,11 @@ static Word16 calc_n2_fx(
const Word16 ph1 )
{
Word16 n2;
- Word32 temp = L_mult( 23040, getSinWord16( ph1 ) ); // q8
+ Word32 temp;
+ temp = L_mult( 23040, getSinWord16( ph1 ) ); // q8
n2 = round_fx( temp );
n2 = shr( n2, 7 );
- IF( EQ_16( s_and( n2, 1 ), 0 ) )
+ IF( s_and( n2, 1 ) == 0 )
{
n2 = add( n2, 1 );
}
@@ -1031,14 +1066,14 @@ static Word16 calc_n3_fx(
n3 = shr( n3, 8 );
- IF( EQ_16( n3, 0 ) )
+ IF( n3 == 0 )
{
n3 = 1;
move16();
}
ELSE
{
- IF( ( s_and( n3, 1 ) ) == 1 )
+ IF( EQ_16( s_and( n3, 1 ), 1 ) )
{
n3 = add( n3, 1 );
}
@@ -1215,7 +1250,7 @@ static Word16 get_pca_offset_n2_fx(
}
ELSE
{
- index2 = ivas_pca_offset_n2[IVAS_PCA_N1 - 1 - index1];
+ index2 = ivas_pca_offset_n2[sub( sub( IVAS_PCA_N1, 1 ), index1 )];
move16();
}
@@ -1436,11 +1471,11 @@ void pca_dec_s3_fx(
move16();
FOR( i = 0; i < IVAS_PCA_N1; i++ )
{
- IF( j < ivas_pca_offset_index1[i + 1] )
+ IF( LT_32( j, ivas_pca_offset_index1[i + 1] ) )
{
index1 = i;
move16();
- break;
+ BREAK;
}
}
@@ -1448,7 +1483,9 @@ void pca_dec_s3_fx(
n1 = IVAS_PCA_N1;
move16();
- Word16 num_fx = 12868;
+ Word16 num_fx;
+ num_fx = 12868;
+ move16();
d_fx = idiv1616( num_fx, n1 ); // Q12
ph1_q_fx = i_mult( index1, d_fx ); // Q12
@@ -1460,11 +1497,11 @@ void pca_dec_s3_fx(
move16();
FOR( i = 0; i < n2; i++ )
{
- IF( j < ivas_pca_offset_index2[i + get_pca_offset_n2_fx( index1 ) + 1] )
+ IF( LT_32( j, L_deposit_l( ivas_pca_offset_index2[add( add( i, get_pca_offset_n2_fx( index1 ) ), 1 )] ) ) )
{
index2 = i;
move16();
- break;
+ BREAK;
}
}
@@ -1484,10 +1521,10 @@ void pca_dec_s3_fx(
ph2_q_fx = i_mult( index2, d_fx ); // Q12
}
- j = L_sub( j, ivas_pca_offset_index2[index2 + get_pca_offset_n2_fx( index1 )] );
+ j = L_sub( j, ivas_pca_offset_index2[add( index2, get_pca_offset_n2_fx( index1 ) )] );
+
+ index3 = extract_l( j );
- index3 = (Word16) j;
- move16();
n3 = calc_n3_fx( ph1_q_fx, ph2_q_fx );
IF( EQ_16( n3, 1 ) )
diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h
index 82fa14f65a23073baf048ce5187a93497ae01d4d..ed5433f53bf4e3157d77f3f9aaabe897eef39000 100644
--- a/lib_com/ivas_prot.h
+++ b/lib_com/ivas_prot.h
@@ -45,6 +45,10 @@
#include "ivas_stat_com.h"
#include "ivas_error_utils.h"
+#ifdef IVAS_FLOAT_FIXED
+#define IVAS_FLOAT_FIXED_TO_BE_REMOVED
+#endif // IVAS_FLOAT_FIXED
+
/* clang-format off */
/*----------------------------------------------------------------------------------*
@@ -162,8 +166,8 @@ ivas_error ivas_sce_enc(
ivas_error ivas_cpe_enc(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const int16_t cpe_id, /* i : CPE # identifier */
- const float data_f_ch0[], /* i : input signal for channel 0 */
- const float data_f_ch1[], /* i : input signal for channel 1 */
+ float data_f_ch0[], /* i : input signal for channel 0 */
+ float data_f_ch1[], /* i : input signal for channel 1 */
const int16_t input_frame, /* i : input frame length per channel */
const int16_t nb_bits_metadata /* i : number of metadata bits */
);
@@ -221,6 +225,51 @@ ivas_error pre_proc_front_ivas(
const int32_t ivas_total_brate /* i : IVAS total bitrate */
);
+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 int32_t element_brate, /* i : SCE/CPE element bitrate */
+ const int16_t nb_bits_metadata, /* i : number of metadata bits */
+ const int16_t input_frame, /* i : frame length */
+ const int16_t n, /* i : channel number */
+ float old_inp_12k8[], /* o : buffer of old input signal */
+ float old_inp_16k[], /* o : buffer of old input signal @16kHz */
+ float *ener, /* o : residual energy from Levinson-Durbin */
+ float *relE, /* o : frame relative energy */
+ float A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */
+ float Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */
+ float epsP[M + 1], /* o : LP prediction errors */
+ float lsp_new[M], /* o : LSPs at the end of the frame */
+ float lsp_mid[M], /* o : LSPs in the middle of the frame */
+ int16_t *vad_hover_flag, /* o : VAD hangover flag */
+ int16_t *attack_flag, /* o : flag signaling attack */
+ float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */
+ float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */
+ float old_wsp[], /* o : weighted input signal buffer */
+ float pitch_fr[NB_SUBFR], /* o : fractional pitch values */
+ float voicing_fr[NB_SUBFR], /* o : fractional pitch gains */
+ int16_t *loc_harm, /* o : harmonicity flag */
+ float *cor_map_sum, /* o : speech/music clasif. parameter */
+ int16_t *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO */
+ float enerBuffer[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */
+ float fft_buff[2 * L_FFT], /* o : FFT buffer */
+ const float tdm_A_PCh[M + 1], /* i : unq. LP coeff. of primary channel */
+ const float tdm_lsp_new_PCh[M], /* i : unq. LSPs of primary channel */
+ const float currFlatness, /* i : flatness parameter */
+ const int16_t tdm_ratio_idx, /* i : Current Ratio_L index */
+ float fr_bands_LR[][2 * NB_BANDS], /* i : energy in frequency bands */
+ const float Etot_LR[], /* i : total energy Left & Right channel */
+ float lf_E_LR[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */
+ const int16_t localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */
+ float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */
+ const int16_t flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */
+ const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */
+ const int16_t force_front_vad, /* i : flag to force VAD decision */
+ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/
+ const IVAS_FORMAT ivas_format, /* i : IVAS format */
+ const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
+ const int32_t ivas_total_brate /* i : IVAS total bitrate */
+);
ivas_error pre_proc_ivas(
Encoder_State *st, /* i/o: encoder state structure */
const int16_t last_element_mode, /* i : last element mode */
@@ -533,7 +582,7 @@ ivas_error ivas_core_enc(
const int16_t flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */
);
#ifdef IVAS_FLOAT_FIXED
-ivas_error ivas_core_dec(
+ivas_error ivas_core_dec_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
@@ -675,7 +724,27 @@ int16_t ivas_smc_gmm(
int16_t *high_lpn_flag, /* i/o: sp/mus LPN flag */
const int16_t flag_spitch /* i : flag to indicate very short stable pitch */
);
-
+#ifdef IVAS_FLOAT_FIXED
+/*! r: S/M decision (0=speech or noise,1=unclear,2=music) */
+Word16 ivas_smc_gmm_fx(
+ Encoder_State *st, /* i/o: state structure */
+ STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
+ const Word16 localVAD_HE_SAD, /* i : HE-SAD flag without hangover */
+ const Word16 Etot_fx, /* i : total frame energy */
+ Word16 lsp_new_fx[M], /* i : LSPs in current frame TODO:For now removing 'const' to avoid warning */
+ Word16 cor_map_sum_fx, /* i : correlation map sum (from multi-harmonic anal.) */
+ Word32 epsP_fx[M + 1], /* i : LP prediciton error TODO:For now removing 'const' to avoid warning */
+ Word32 PS_fx[], /* i : energy spectrum TODO:For now removing 'const' to avoid warning */
+ const Word16 non_sta_fx, /* i : unbound non-stationarity */
+ const Word16 relE_fx, /* i : relative frame energy */
+ Word16 *high_lpn_flag, /* i/o: sp/mus LPN flag */
+ const Word16 flag_spitch /* i : flag to indicate very short stable pitch */
+ ,
+ Word16 Qfact_PS,
+ Word16 Q_esp,
+ Word16 Qfact_PS_past
+);
+#endif
void ivas_smc_mode_selection(
Encoder_State *st, /* i/o: encoder state structure */
const int32_t element_brate, /* i : element bitrate */
@@ -822,7 +891,7 @@ void smooth_dft2td_transition(
void smooth_dft2td_transition_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
Word32 *output_fx[CPE_CHANNELS], /* i/o: synthesis @external Fs */
- const int16_t output_frame /* i : output frame lenght */
+ const Word16 output_frame /* i : output frame lenght */
);
/*! r: flag indicating a valid bitrate */
int16_t is_IVAS_bitrate(
@@ -862,8 +931,8 @@ void ivas_mdft_fx(
const Word32 *pIn, /* i : input time-domain signal */
Word32 *pOut_re, /* o : Real part of MDFT signal */
Word32 *pOut_im, /* o : Imag. part of MDFT signal */
- const int16_t length, /* i : signal length */
- const int16_t mdft_length /* i : MDFT length */
+ const Word16 length, /* i : signal length */
+ const Word16 mdft_length /* i : MDFT length */
);
void ivas_imdft_fx(
@@ -923,7 +992,7 @@ Word16 rand_triangular_signed_fx(
#endif
Word64 var_32_fx(
const Word32 *x, /* i : input vector */
- const int16_t len, /* i : length of inputvector */
+ const Word16 len, /* i : length of inputvector */
Word16 q /* q : q-factor for the array */
);
@@ -932,11 +1001,13 @@ void dtx_read_padding_bits(
const int16_t num_bits
);
-void ivas_apply_non_diegetic_panning(
+#ifndef IVAS_FLOAT_FIXED
+void ivas_apply_non_diegetic_panning(
float *output_f[], /* i/o: core-coder transport mono channel/stereo output */
const float non_diegetic_pan_gain, /* i : non-diegetic panning gain */
const int16_t output_frame /* i : output frame length per channel */
);
+#endif
/*----------------------------------------------------------------------------------*
@@ -1133,11 +1204,19 @@ ivas_error ivas_ism_config(
const int16_t combined_format_flag /* i : flag indicating combined format */
);
+#ifdef IVAS_FLOAT_FIXED
void bitbudget_to_brate(
const Word16 x[], /* i : bitbudgets */
Word32 y[], /* o : bitrates */
const Word16 N /* i : number of entries to be converted */
);
+#else
+void bitbudget_to_brate(
+ const int16_t x[], /* i : bitbudgets */
+ int32_t y[], /* o : bitrates */
+ const int16_t N /* i : number of entries to be converted */
+);
+#endif
void ivas_ism_reset_metadata(
ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */
@@ -1151,6 +1230,17 @@ void ivas_ism_reset_metadata_API(
);
/*! r: index of the winning codeword */
+#ifdef IVAS_FLOAT_FIXED
+Word16 ism_quant_meta_fx(
+ const Word32 val, /* i : scalar value to quantize */
+ Word32 *valQ, /* o : quantized value */
+ const Word32 borders_fx[], /* i : level borders */
+ const Word32 q_step_fx, /* i : quantization step */
+ const Word32 q_step_border_fx, /* i : quantization step at the border */
+ const Word16 cbsize /* i : codebook size */
+);
+#endif
+
int16_t ism_quant_meta(
const float val, /* i : scalar value to quantize */
float *valQ, /* o : quantized value */
@@ -1169,6 +1259,17 @@ float ism_dequant_meta(
const int16_t cbsize /* i : codebook size */
);
+#ifdef IVAS_FLOAT_FIXED
+ivas_error ivas_set_ism_metadata_fx(
+ ISM_METADATA_HANDLE hIsmMeta, /* o : ISM metadata handle */
+ const Word32 azimuth, /* i : azimuth value */
+ const Word32 elevation, /* i : elevation value */
+ const Word16 radius_meta, /* i : radius */
+ const Word32 yaw, /* i : yaw */
+ const Word32 pitch, /* i : pitch */
+ const Word16 non_diegetic_flag /* i : non-diegetic object flag */
+);
+#else
ivas_error ivas_set_ism_metadata(
ISM_METADATA_HANDLE hIsmMeta, /* o : ISM metadata handle */
const float azimuth, /* i : azimuth value */
@@ -1178,7 +1279,7 @@ ivas_error ivas_set_ism_metadata(
const float pitch, /* i : pitch */
const int16_t non_diegetic_flag /* i : non-diegetic object flag */
);
-
+#endif
ivas_error ivas_ism_metadata_enc_create(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const int16_t n_ISms, /* i : number of objects */
@@ -1199,6 +1300,25 @@ ivas_error ivas_ism_enc(
const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */
);
+#ifdef IVAS_FLOAT_FIXED
+ivas_error ivas_ism_metadata_enc(
+ 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 */
+ ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
+ SCE_ENC_HANDLE hSCE[], /* i/o: SCE encoder handles */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ Word16 nb_bits_metadata[], /* o : number of metadata bits */
+ const Word16 localVAD[], /* i : VAD flag */
+ const Word16 ism_mode, /* i : ISM mode */
+ const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */
+ const Word16 ism_extended_metadata_flag, /* i : Extended metadata flag */
+ const Word32 lp_noise_CPE, /* i : LP filtered total noise estimation */
+ const Word16 flag_omasa_ener_brate, /* i : less bitrate for objects in OMASA flag */
+ Word16 *omasa_stereo_sw_cnt,
+ const Word16 ini_frame
+);
+#else
ivas_error ivas_ism_metadata_enc(
int32_t *ism_total_brate, /* i/o: ISM total bitrate */
const int16_t nchan_ism, /* i : number of ISM channels */
@@ -1216,7 +1336,7 @@ ivas_error ivas_ism_metadata_enc(
int16_t *omasa_stereo_sw_cnt,
const int16_t ini_frame
);
-
+#endif
ivas_error ivas_ism_metadata_dec(
const int32_t ism_total_brate, /* i : ISM total bitrate */
const int16_t nchan_ism, /* i : number of ISM channels */
@@ -1239,10 +1359,17 @@ ivas_error ivas_ism_metadata_dec(
*----------------------------------------------------------------------------------*/
/*! r: ISM format mode */
+#ifdef IVAS_FLOAT_FIXED
ISM_MODE ivas_ism_mode_select(
const Word16 nchan_inp, /* i : number of input objects */
const Word32 ivas_total_brate /* i : IVAS total bitrate */
);
+#else
+ISM_MODE ivas_ism_mode_select(
+ const int16_t nchan_inp, /* i : number of input objects */
+ const int32_t ivas_total_brate /* i : IVAS total bitrate */
+);
+#endif
ivas_error ivas_param_ism_enc_open(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
@@ -1366,9 +1493,9 @@ void ivas_param_ism_dec_render(
#ifdef IVAS_FLOAT_FIXED
void ivas_param_ism_dec_render_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */
- uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */
- uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */
+ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */
+ UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */
+ UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */
Word32 *output_f_fx[]
);
void ivas_param_ism_params_to_masa_param_mapping_fx(
@@ -1388,6 +1515,19 @@ void ivas_param_ism_params_to_masa_param_mapping(
ivas_error ivas_ism_dtx_open(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
+#ifdef IVAS_FLOAT_FIXED
+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 */
+ 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 */
+);
+#endif // IVAS_FLOAT_FIXED
/*! r: indication of DTX frame */
int16_t ivas_ism_dtx_enc(
@@ -1438,6 +1578,14 @@ void ivas_ism_metadata_sid_dec(
ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */
int16_t nb_bits_metadata[] /* o : number of metadata bits */
);
+#ifdef IVAS_FLOAT_FIXED
+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 */
+);
+#endif // IVAS_FLOAT_FIXED
void ivas_ism_get_sce_id_dtx(
ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
@@ -1450,6 +1598,14 @@ void ivas_param_ism_compute_noisy_speech_flag(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
+#ifdef IVAS_FLOAT_FIXED
+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 */
+);
+#endif // IVAS_FLOAT_FIXED
void ivas_ism_coh_estim_dtx_enc(
ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */
SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */
@@ -1844,6 +2000,16 @@ void filter_with_allpass(
);
/*! r: used GR order */
+#ifdef IVAS_FLOAT_FIXED
+Word16 write_bitstream_adapt_GR(
+ BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
+ const Word16 ind, /* i : bitstream index */
+ const Word16 *in, /* i : values to be written in bitstream */
+ const Word16 len, /* i : values vector length */
+ const Word16 GR_ord, /* i : GR order to be used */
+ const Word16 no_GR_ord /* i : speech/music 0/1 */
+);
+#else
int16_t write_bitstream_adapt_GR(
BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
const int16_t Indice, /* i : identifier for bitstream index */
@@ -1852,8 +2018,27 @@ int16_t write_bitstream_adapt_GR(
const int16_t GR_ord, /* i : GR order to be used */
const int16_t sp_aud_decision /* i : speech/music 0/1 */
);
+#endif
/*! r: used GR order */
+#ifdef IVAS_FLOAT_FIXED
+Word16 adapt_GR_ief_fx(
+ const Word16 *in, /* i : vector to encode */
+ Word16 *in_diff, /* o : encoded symbols in case of differential encoding */
+ const Word16 *prev, /* i : previous frame data */
+ const Word16 len, /* i : input vector length */
+ const Word16 no_symb, /* i : number of symbols */
+ Word16 *nbits, /* o : number of used bits */
+ Word16 *in_enc, /* o : symbold actually encoded after adapt_GR */
+ const Word16 *map0, /* i : mapping array */
+ const Word16 no_GR_ord, /* i : number of GR order to try 2: 0,1; 3:0,1,2 */
+ Word16 *nbits_diff, /* o : number bits in diff encoding */
+ const Word16 side_gain_counter, /* i : number of frames since last abs coding */
+ Word16 *side_gain_bitdiff_lp, /* i/o: LP-filtered bit difference between abs/diff */
+ Word16 *q_side_gain_bitdiff_lp, /* i/o: Q of LP-filtered bit difference between abs/diff */
+ const Word16 try_diff /* i : diff coding allowed 1/0 */
+);
+#else
int16_t adapt_GR_ief(
const int16_t *in, /* i : vector to encode */
int16_t *in_diff, /* o : encoded symbols in case of differential encoding */
@@ -1869,7 +2054,23 @@ int16_t adapt_GR_ief(
float *side_gain_bitdiff_lp, /* i/o: LP-filtered bit difference between abs/diff */
const int16_t try_diff /* i : diff coding allowed 1/0 */
);
+#endif
+#ifdef IVAS_FLOAT_FIXED
+Word16 adapt_GR_rpg1_ief(
+ const Word16 *in, /* i : res pred gains input vector */
+ Word16 *in_diff, /* o : encoded symbols in case of differential encoding */
+ const Word16 *prev, /* i : previous frame data */
+ const Word16 len, /* i : input vector length */
+ const Word16 no_symb, /* i : number of symbols */
+ Word16 *nbits, /* o : number of used bits */
+ Word16 *in_enc, /* o : symbold actually encoded after adapt_GR */
+ const Word16 *maps, /* i : mapping array */
+ Word16 *nbits_diff, /* o : estimated no of bits for differential encoding */
+ const Word16 no_GR_ord, /* i : number of GR order to try 2: 0,1; 3:0,1,2 */
+ const Word16 try_diff /* i : diff coding allowed 1/0 */
+);
+#else
/*! r: used GR order */
int16_t adapt_GR_rpg1_ief(
const int16_t *in, /* i : res pred gains input vector */
@@ -1884,16 +2085,35 @@ int16_t adapt_GR_rpg1_ief(
const int16_t no_GR_ord, /* i : number of GR order to try 2: 0,1; 3:0,1,2 */
const int16_t try_diff /* i : diff coding allowed 1/0 */
);
+#endif
/*! r: number of bits written */
+#ifdef IVAS_FLOAT_FIXED
+Word16 write_GR1(
+ BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
+ const Word16 ind, /* i : bitstream index */
+ const Word16 *in, /* i : data to be encoded */
+ const Word16 len /* i : input data length */
+);
+#else
int16_t write_GR1(
BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
const int16_t ind, /* i : bitstream index */
const int16_t *in, /* i : input vector */
const int16_t len /* i : vector length */
);
+#endif
/*! r: number of bits written */
+#ifdef IVAS_FLOAT_FIXED
+Word16 write_bitstream_GR(
+ BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
+ const Word16 ind, /* i : bitstream index */
+ const Word16 *in, /* i : input vector */
+ const Word16 len, /* i : input vector length */
+ const Word16 GR_ord /* i : GR order */
+);
+#else
int16_t write_bitstream_GR(
BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
const int16_t ind, /* i : bitstream index */
@@ -1901,6 +2121,7 @@ int16_t write_bitstream_GR(
const int16_t len, /* i : input data length */
const int16_t GR_ord /* i : GR order to be used */
);
+#endif
#ifndef IVAS_FLOAT_FIXED
/*! r: number of bits read */
@@ -2205,7 +2426,7 @@ void stereo_tca_dec(
void stereo_tca_dec_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
Word32 *synth[CPE_CHANNELS], /* i/o: output synth */
- const int16_t output_frame /* i : length of a frame per channel */
+ const Word16 output_frame /* i : length of a frame per channel */
);
void stereo_tca_scale_R_channel(
@@ -2217,7 +2438,7 @@ void stereo_tca_scale_R_channel(
void stereo_tca_scale_R_channel_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
Word32 *output_fx, /* i/o: output synthesis, R channel */
- const int16_t output_frame /* i : frame length */
+ const Word16 output_frame /* i : frame length */
);
void adjustTargetSignal(
@@ -2230,10 +2451,10 @@ void adjustTargetSignal(
void adjustTargetSignal_fx(
Word32 *target_fx,
- const int16_t prevShift,
- const int16_t currShift,
- const int16_t L_shift_adapt,
- const int16_t method);
+ const Word16 prevShift,
+ const Word16 currShift,
+ const Word16 L_shift_adapt,
+ const Word16 method);
/*----------------------------------------------------------------------------------*
* IC-BWE Stereo prototypes
*----------------------------------------------------------------------------------*/
@@ -2391,7 +2612,7 @@ void stereo_td_init_dec(
void stereo_td_init_dec_fx(
STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */
- const int16_t last_element_mode /* i : last element mode */
+ const Word16 last_element_mode /* i : last element mode */
);
void tdm_configure_dec(
@@ -2421,9 +2642,9 @@ void tdm_upmix_plain_fx(
const Word32 SCh_2_R_fx[], /* i : secondary channel */
const Word32 LR_ratio_fx, /* i : mixing ratio */
const Word32 inv_den_LR_ratio_fx, /* i : inverse mixing ration */
- const int16_t start_index, /* i : start index */
- const int16_t end_index, /* i : end index */
- const int16_t plus_minus_flag /* i : plus/minus flag */
+ const Word16 start_index, /* i : start index */
+ const Word16 end_index, /* i : end index */
+ const Word16 plus_minus_flag /* i : plus/minus flag */
);
void stereo_tdm_combine(
@@ -2439,9 +2660,9 @@ void stereo_tdm_combine_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
Word32 *PCh_2_L_fx, /* i/o: Primary channel -> output as left channel */
Word32 *SCh_2_R_fx, /* i/o: Secondary channel -> output as right channel*/
- const int16_t output_frame, /* i : Number of samples */
- const int16_t flag_HB, /* i : flag to distinguish between core (0) and HB (1) synthesis */
- const int16_t tdm_ratio_idx /* i : TDM ratio index */
+ const Word16 output_frame, /* i : Number of samples */
+ const Word16 flag_HB, /* i : flag to distinguish between core (0) and HB (1) synthesis */
+ const Word16 tdm_ratio_idx /* i : TDM ratio index */
);
/*! r: replication decision; 1 = Use old LP */
@@ -2573,7 +2794,6 @@ void tdm_low_rate_dec(
float *bwe_exc, /* o : excitation for SWB TBE */
const float *lsf_new /* i : ISFs at the end of the frame */
);
-
#ifdef IVAS_FLOAT_FIXED
void tdm_SCh_LSF_intra_pred_fx(
const Word32 element_brate, /* i : element bitrate */
@@ -2581,7 +2801,6 @@ void tdm_SCh_LSF_intra_pred_fx(
Word16 *pred_lsf_SCh_fx /* o : predicted secondary channel LSFs */
);
#endif
-
void tdm_SCh_LSF_intra_pred(
const int32_t element_brate, /* i : element bitrate */
const float *tdm_lsfQ_PCh, /* i : primary channel LSFs */
@@ -2602,13 +2821,13 @@ void tdm_SCh_lsf_reuse_fx(
void tdm_SCh_lsf_reuse_ivas_fx(
- const int16_t enc_dec, /* i : encoder/decoder flag */
- const int32_t element_brate, /* i : element bitrate */
+ const Word16 enc_dec, /* i : encoder/decoder flag */
+ const Word32 element_brate, /* i : element bitrate */
Word16 lsf_new[M], /* i/o: LSFs at the end of the frame */
Word16 lsp_new[M], /* i/o: LSPs at the end of the frame */
const Word16 tdm_lsfQ_PCh[M], /* i : primary channel LSFs (log2(2.56)) */
const Word16 lsf_wgts[M], /* i : LSF weights Q15? */
- int16_t *beta_index /* i/o: quantization index */
+ Word16 *beta_index /* i/o: quantization index */
);
void tdm_SCh_lsf_reuse(
@@ -2761,11 +2980,6 @@ ivas_error initMdctItdHandling(
const int32_t input_Fs /* i : input sampling rate */
);
-ivas_error initMdctItdHandling_fx(
- STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */
- const Word32 input_Fs /* i : input sampling rate */
-);
-
void stereo_mdct_enc_destroy(
STEREO_MDCT_ENC_DATA_HANDLE *hStereoMdct /* i/o: encoder MDCT stereo handle */
);
@@ -3056,17 +3270,19 @@ void parse_stereo_from_bitstream(
);
#endif
+#ifndef IVAS_FLOAT_FIXED
void FindSplitRatio(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
Encoder_State **sts /* i/o: Encoder state structure */
);
+#endif
void ComputeSpectrumNoiseMeasure(
const float *powerSpec,
const int16_t L_frame,
const int16_t startLine,
const int16_t resetMemory,
- int16_t *noiseFlags,
+ int8_t *noiseFlags,
const int16_t lowpassLine
);
@@ -3117,7 +3333,32 @@ void dequantize_sns(
float snsQ_out[CPE_CHANNELS][NB_DIV][M],
Decoder_State **sts
);
+#ifdef IVAS_FLOAT_FIXED
+void sns_avq_cod_fx(
+ const Word32 *sns_fx, /* i : Input sns vectors */
+ Word16 exp_sns,
+ const Word32 *snsmid_fx, /* i : Input mid-sns vectors */
+ Word16 exp_snsmid,
+ Word32 *sns_q_fx, /* o : Quantized LFS vectors Q16 */
+ Word32 *snsmid_q_fx, /* o : Quantized mid-LFS vectors Q16 */
+ Word16 *index, /* o : Quantization indices */
+ const Word16 core, /* i : core */
+ const Word16 L_frame,
+ const Word16 low_brate_mode /* i : flag low bit operating mode */
+);
+void sns_avq_cod_stereo_fx(
+ const Word32 *snsl_fx, /* i : Input sns vector (left channel) */
+ Word16 exp_snl,
+ const Word32 *snsr_fx, /* i : Input sns vector (right channel) */
+ Word16 exp_snr,
+ const Word16 L_frame,
+ Word32 *snsl_q_fx, /* o : Quantized sns vector (left channel) Q16 */
+ Word32 *snsr_q_fx, /* o : Quantized sns vector (right channel) Q16 */
+ Word16 *indexl, /* o : Quantization indices (left channel) */
+ Word16 *indexr /* o : Quantization indices (right channel) */
+);
+#else
void sns_avq_cod(
const float *sns, /* i : Input sns vectors */
const float *snsmid, /* i : Input mid-sns vectors */
@@ -3128,7 +3369,6 @@ void sns_avq_cod(
const int16_t L_frame,
const int16_t low_brate_mode /* i : flag low bit operating mode */
);
-
void sns_avq_cod_stereo(
const float *snsl, /* i : Input sns vector (left channel) */
const float *snsr, /* i : Input sns vector (right channel) */
@@ -3138,6 +3378,7 @@ void sns_avq_cod_stereo(
int16_t *indexl, /* o : Quantization indices (left channel) */
int16_t *indexr /* o : Quantization indices (right channel) */
);
+#endif
void sns_avq_dec(
int16_t *index, /* i : Quantization indices */
@@ -3212,7 +3453,7 @@ void applyDmxMdctStereo(
void applyDmxMdctStereo_fx(
const CPE_DEC_HANDLE hCPE, /* i : CPE handle */
Word32 *output_fx[CPE_CHANNELS], /* o : output from core decoder */
- const int16_t output_frame /* i : output frame length */
+ const Word16 output_frame /* i : output frame length */
);
@@ -3303,8 +3544,8 @@ void stereo_cna_update_params(
void stereo_cna_update_params_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
Word32 *output_fx[CPE_CHANNELS], /* i : Output signal */
- const int16_t output_frame, /* i : Output frame length */
- const int16_t tdm_ratio_idx /* i : TDM ratio index */
+ const Word16 output_frame, /* i : Output frame length */
+ const Word16 tdm_ratio_idx /* i : TDM ratio index */
);
void dtx_enc_init(
Encoder_State *st, /* i : Encoder state handle */
@@ -3375,6 +3616,20 @@ void v_add_inc_fx(
const Word16 y_inc, /* i : increment for vector y[] */
const Word16 N /* i : Vector length */
);
+Word32 logsumexp_fx(
+ const Word32 x[], /* i : input array x */
+ const Word16 x_e,
+ const Word16 N /* i : number of elements in array x */
+);
+Word32 lin_interp32_fx(
+ const Word32 x, /* i : the value to be mapped */
+ const Word32 x1, /* i : source range interval: low end */
+ const Word32 y1, /* i : source range interval: high end */
+ const Word32 x2, /* i : target range interval: low */
+ const Word32 y2, /* i : target range interval: high */
+ const Word16 flag_sat, /* i : flag to indicate whether to apply saturation */
+ Word16 *Q_io /*i/o : i/o Q factor of the output*/
+);
#endif
void v_mult_inc(
@@ -3459,6 +3714,13 @@ float sumAbs(
const int16_t lvec /* i : length of input vector */
);
+#ifdef IVAS_FLOAT_FIXED
+Word32 sumAbs_fx(
+ const Word32 *vec, /* i : input vector */
+ const Word16 lvec /* i : length of input vector */
+);
+#endif
+
void mvc2c(
const uint8_t x[], /* i : input vector */
uint8_t y[], /* o : output vector */
@@ -3472,6 +3734,21 @@ float dot_product_cholesky(
const int16_t N /* i : vector & matrix size */
);
+#ifdef IVAS_FLOAT_FIXED
+Word32 dot_product_cholesky_fx(
+ const Word32 *x, /* i : vector x */
+ const Word32 *A, /* i : Cholesky matrix A */
+ const Word16 N /* i : vector & matrix size */
+);
+Word32 dot_product_cholesky_fixed(
+ const Word32 *x, /* i : vector x */
+ const Word32 *A, /* i : Cholesky matrix A */
+ const Word16 N, /* i : vector & matrix size */
+ const Word16 exp_x,
+ const Word16 exp_A,
+ Word16 *exp_sum );
+#endif
+
#ifdef IVAS_FLOAT_FIXED
void v_mult_mat_fx(
Word32 *y_fx, /* o : the product x*A */
@@ -3483,6 +3760,14 @@ void v_mult_mat_fx(
const Word16 N, /* i : number of rows */
const Word16 C /* i : number of columns */
);
+void v_mult_mat_fixed(
+ Word32 *y, /* o : the product x*A */
+ const Word32 *x, /* i : vector x */
+ const Word32 *A, /* i : matrix A */
+ const Word16 Nr, /* i : number of rows */
+ const Word16 Nc, /* i : number of columns */
+ Word16 guardbits
+);
#endif
void v_mult_mat(
@@ -3571,11 +3856,11 @@ void stereo_td2dft_update(
void stereo_td2dft_update_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- const int16_t n, /* i : channel number */
+ const Word16 n, /* i : channel number */
Word32 output_fx[], /* i/o: synthesis @internal Fs */
Word32 synth_fx[], /* i/o: synthesis @output Fs */
Word32 hb_synth_fx[], /* i/o: hb synthesis */
- const int16_t output_frame /* i : frame length */
+ const Word16 output_frame /* i : frame length */
);
void stereo_mdct2dft_update(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
@@ -3589,12 +3874,21 @@ void stereo_mdct2dft_update_fx(
Word32 synth0_fx[] /* i/o: synthesis @output Fs, ch0 */
);
/*! r: number of bits written */
+#ifdef IVAS_FLOAT_FIXED
+Word16 write_GR0(
+ BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
+ const Word16 ind, /* i : bitstream index */
+ const Word16 *in, /* i : data to be encoded */
+ const Word16 len /* i : input data length */
+);
+#else
int16_t write_GR0(
BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
const int16_t ind, /* i : bitstream index */
const int16_t *in, /* i : data to be encoded */
const int16_t len /* i : input data length */
);
+#endif
#ifndef IVAS_FLOAT_FIXED
/*! r: number of bits read */
@@ -3672,6 +3966,23 @@ void getChannelEnergies(
float nrg[MCT_MAX_CHANNELS], /* o : energies */
const int16_t nchan /* i : number of channels */
);
+#ifdef IVAS_FLOAT_FIXED
+void mctStereoIGF_enc_fx(
+ MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
+ Encoder_State **sts, /* i/o: encoder state structure */
+ Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2], /* i : MDCT spectrum for ITF */
+ Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate*/
+ Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : same as above but for inverse spect.*/
+ Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */
+#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED
+ float *orig_spectrum[MCT_MAX_CHANNELS][2], /* i : MDCT spectrum for ITF */
+ float powerSpec[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate*/
+ float *powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV], /* i : same as above but for inverse spect.*/
+ float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */
+#endif
+ const Word16 sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */
+);
+#endif // IVAS_FLOAT_FIXED
void mctStereoIGF_enc(
MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
@@ -3814,7 +4125,7 @@ void deindex_sph_idx(
float *phi /* o : Azimuth */
);
void deindex_sph_idx_fx(
- const uint16_t sphIndex, /* i : Spherical index */
+ const UWord16 sphIndex, /* i : Spherical index */
const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */
Word32 *theta_fx, /* o : Elevation */
Word32 *phi_fx /* o : Azimuth */
@@ -4740,7 +5051,7 @@ void ivas_param_mc_dec_digest_tc(
void ivas_param_mc_dec_digest_tc_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */
+ const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */
Word32 *transport_channels_f_fx[],
Word16 transport_f_e );
@@ -5207,11 +5518,19 @@ ivas_error ivas_spar_dec_open(
const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */
);
+#ifndef IVAS_FLOAT_FIXED
void ivas_spar_dec_close(
SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */
const int32_t output_Fs, /* i : output sampling rate */
const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */
);
+#else
+void ivas_spar_dec_close_fx(
+ SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */
+ const Word32 output_Fs, /* i : output sampling rate */
+ const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */
+);
+#endif
ivas_error ivas_spar_dec(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */
@@ -5219,13 +5538,13 @@ ivas_error ivas_spar_dec(
);
void ivas_spar_config(
- int32_t ivas_total_brate, /* i : codec total bitrate */
- const int16_t sba_order, /* i : Ambisonic (SBA) order */
- int16_t *nchan_transport, /* o : number of transport channels */
- int16_t *nSCE, /* o : number of SCEs */
- int16_t *nCPE, /* o : number of CPEs */
- int32_t *core_nominal_brate, /* o : core-coding nominal bitrate */
- const int16_t sid_format /* i : IVAS format indicator from SID frame */
+ int32_t ivas_total_brate, /* i : codec total bitrate */
+ const int16_t sba_order, /* i : Ambisonic (SBA) order */
+ int16_t *nchan_transport, /* o : number of transport channels */
+ int16_t *nSCE, /* o : number of SCEs */
+ int16_t *nCPE, /* o : number of CPEs */
+ int32_t *core_nominal_brate, /* o : core-coding nominal bitrate */
+ const int16_t sid_format /* i : IVAS format indicator from SID frame */
);
#ifdef IVAS_FLOAT_FIXED
ivas_error ivas_sba_linear_renderer_fx(
@@ -5248,13 +5567,13 @@ ivas_error ivas_sba_linear_renderer(
);
#ifdef IVAS_FLOAT_FIXED
void ivas_sba_mix_matrix_determiner_fx(
- SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */
- Word32 *output_fx[], /* i/o: transport/output audio channels */
- const Word16 bfi, /* i : BFI flag */
- const Word16 nchan_remapped, /* i : num channels after remapping of TCs */
- const Word16 output_frame, /* i : output frame length */
- const Word16 num_md_sub_frames, /* i : number of subframes in mixing matrix */
- const Word16 Q_p_Output /* i : number of subframes in mixing matrix */
+ SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */
+ Word32 *output_fx[], /* i/o: transport/output audio channels */
+ const Word16 bfi, /* i : BFI flag */
+ const Word16 nchan_remapped, /* i : num channels after remapping of TCs */
+ const Word16 output_frame, /* i : output frame length */
+ const Word16 num_md_sub_frames, /* i : number of subframes in mixing matrix*/
+ const Word16 Q_output /* i : Q of transport/output audio channels */
);
#endif // IVAS_FLOAT_FIXED
@@ -5674,18 +5993,18 @@ void ivas_get_spar_md_from_dirac_fx(
Word32 azi_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
Word32 ele_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
Word32 diffuseness[IVAS_MAX_NUM_BANDS],
- const int16_t n_ts,
+ const Word16 n_ts,
Word32 ***mixer_mat,
ivas_spar_md_t *hSpar_md,
ivas_spar_md_com_cfg *hSpar_md_cfg,
- const int16_t start_band,
- const int16_t end_band,
- const int16_t order,
- const int16_t dtx_vad,
+ const Word16 start_band,
+ const Word16 end_band,
+ const Word16 order,
+ const Word16 dtx_vad,
Word32 Wscale_d[IVAS_MAX_NUM_BANDS],
- const uint8_t useLowerRes,
- const int16_t active_w_vlbr,
- const int16_t dyn_active_w_flag
+ const UWord8 useLowerRes,
+ const Word16 active_w_vlbr,
+ const Word16 dyn_active_w_flag
);
#endif
void ivas_get_spar_md_from_dirac(
@@ -5748,10 +6067,10 @@ void ivas_spar_md_dec_close(
void ivas_spar_get_parameters_fx(
SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */
const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
- const int16_t ts, /* i : time slot index */
- const int16_t num_ch_out, /* i : number of channels out */
- const int16_t num_ch_in, /* i : number of channels in */
- const int16_t num_spar_bands, /* i : number of SPAR bands */
+ const Word16 ts, /* i : time slot index */
+ const Word16 num_ch_out, /* i : number of channels out */
+ const Word16 num_ch_in, /* i : number of channels in */
+ const Word16 num_spar_bands, /* i : number of SPAR bands */
Word32 par_mat_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] /* o : mixing matrix */
);
void ivas_spar_get_parameters(
@@ -5789,10 +6108,10 @@ void ivas_spar_to_dirac(
void ivas_spar_to_dirac_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
- const int16_t dtx_vad, /* i : DTX frame flag */
- const int16_t num_bands_out, /* i : number of output bands */
- const int16_t bw, /* i : band joining factor */
- const int16_t dyn_active_w_flag /* i : dynamic active W flag */
+ const Word16 dtx_vad, /* i : DTX frame flag */
+ const Word16 num_bands_out, /* i : number of output bands */
+ const Word16 bw, /* i : band joining factor */
+ const Word16 dyn_active_w_flag /* i : dynamic active W flag */
);
void ivas_spar_update_md_hist(
ivas_spar_md_dec_state_t *hMdDec /* i/o: SPAR MD decoder handle */
@@ -5835,6 +6154,21 @@ void ivas_spar_dec_gen_umx_mat(
const int16_t num_md_sub_frames
);
+#ifdef IVAS_FLOAT_FIXED
+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 */
+);
+
+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 */
+);
+#else
/* Covariance module */
ivas_error ivas_spar_covar_enc_open(
ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */
@@ -5849,26 +6183,30 @@ void ivas_spar_covar_enc_close(
ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */
const int16_t nchan_inp /* i : number of input channels */
);
+#endif
#ifdef IVAS_FLOAT_FIXED
-ivas_error ivas_enc_cov_handler_process(
- ivas_enc_cov_handler_state_t *hCovEnc, /* i/o: SPAR Covar. encoder handle */
- float **ppIn_FR_real,
- float **ppIn_FR_imag,
- float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
- float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
- ivas_filterbank_t *pFb, /* i/o: FB handle */
- const int16_t start_band,
- const int16_t end_band,
- const int16_t num_ch,
- const int16_t dtx_vad,
- const int16_t transient_det[2],
- const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH],
- int16_t *res_ind,
- const int16_t *remix_order,
- int16_t *dyn_active_w_flag,
- const int16_t nchan_transport,
- const int16_t is_sba
+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,
+ Word16 *q_ppIn_FR,
+ Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
+ Word16 *q_cov_real[IVAS_SPAR_MAX_CH],
+ Word32 *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
+ 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
);
#else
void ivas_enc_cov_handler_process(
@@ -5892,6 +6230,21 @@ void ivas_enc_cov_handler_process(
);
#endif
+#ifdef IVAS_FLOAT_FIXED
+ivas_error ivas_spar_covar_smooth_enc_open_fx(
+ ivas_cov_smooth_state_t **hCovState, /* i/o: SPAR Covar. smoothing handle */
+ const ivas_cov_smooth_cfg_t *cov_smooth_cfg, /* i : SPAR config. handle */
+ ivas_filterbank_t *pFb, /* i/o: FB handle */
+ 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 */
+);
+
+void ivas_spar_covar_smooth_enc_close_fx(
+ ivas_cov_smooth_state_t **hCovState, /* i/o: SPAR Covar. encoder handle */
+ const Word16 nchan_inp /* i : number of input channels */
+);
+#else
ivas_error ivas_spar_covar_smooth_enc_open(
ivas_cov_smooth_state_t **hCovState, /* i/o: SPAR Covar. smoothing handle */
const ivas_cov_smooth_cfg_t *cov_smooth_cfg, /* i : SPAR config. handle */
@@ -5905,6 +6258,7 @@ void ivas_spar_covar_smooth_enc_close(
ivas_cov_smooth_state_t **hCovState, /* i/o: SPAR Covar. encoder handle */
const int16_t nchan_inp /* i : number of input channels */
);
+#endif
#ifdef IVAS_FLOAT_FIXED
void ivas_cov_smooth_process_fx(
@@ -5915,7 +6269,7 @@ void ivas_cov_smooth_process_fx(
const Word16 end_band,
const Word16 num_ch,
const Word16 transient_det[2],
- Word16 q_cov[][IVAS_SPAR_MAX_CH]
+ Word16 *q_cov[IVAS_SPAR_MAX_CH]
);
#else
void ivas_cov_smooth_process(
@@ -6187,22 +6541,45 @@ void ivas_arith_decode_cmplx_cell_array(
int16_t *pSymbol_re_old
);
+#ifndef IVAS_FLOAT_FIXED
void ivas_ari_start_decoding_14bits_ext_1_lfe(
Decoder_State *st,
Tastat *s,
int16_t *extra_bits_read
);
+#else
+void ivas_ari_start_decoding_14bits_ext_1_lfe(
+ Decoder_State *st,
+ Tastat *s,
+ Word16 *extra_bits_read
+);
+#endif
+#ifndef IVAS_FLOAT_FIXED
uint16_t ivas_ari_decode_14bits_bit_ext_1_lfe(
Decoder_State *st, Tastat *s,
const uint16_t *cum_freq,
int16_t *extra_bits_read
);
+#else
+UWord16 ivas_ari_decode_14bits_bit_ext_1_lfe(
+ Decoder_State *st, Tastat *s,
+ const UWord16 *cum_freq,
+ Word16 *extra_bits_read
+);
+#endif
+#ifndef IVAS_FLOAT_FIXED
void ivas_ari_done_decoding_14bits_ext_1_lfe(
Decoder_State *st,
const int16_t extra_bits_read
);
+#else
+void ivas_ari_done_decoding_14bits_ext_1_lfe(
+ Decoder_State *st,
+ const Word16 extra_bits_read
+);
+#endif
void ivas_ari_done_encoding_14bits(
BSTR_ENC_HANDLE hBstr, Tastat *s
@@ -6253,12 +6630,12 @@ void ivas_quantise_real_values(
);
void ivas_quantise_real_values_fx(
const Word32 *values_fx,
- const int16_t q_levels,
+ const Word16 q_levels,
const Word32 min_value_fx,
const Word32 max_value_fx,
- int16_t *index,
+ Word16 *index,
Word32 *quant_fx,
- const int16_t dim);
+ const Word16 dim);
void ivas_spar_get_uniform_quant_strat(
ivas_spar_md_com_cfg *pSpar_md_com_cfg,
@@ -6999,11 +7376,13 @@ void ivas_mono_downmix_render_passive(
const int16_t output_frame /* i : output frame length */
);
+#ifndef IVAS_FLOAT_FIXED
void ivas_mono_stereo_downmix_mcmasa(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
float *output_f[], /* i/o: synthesized core-coder transport channels/mono or stereo output */
int16_t output_frame /* i : output frame length per channel */
);
+#endif
#ifdef IVAS_FLOAT_FIXED
void ivas_lfe_synth_with_filters_fx(
MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, /* i/o: LFE synthesis structure for McMASA */
@@ -7114,7 +7493,8 @@ void ivas_lfe_lpf_select_filt_coeff(
void ivas_lfe_lpf_select_filt_coeff_fx(
const Word32 sampling_rate, /* i : sampling rate */
const Word16 order, /* i : filter order */
- const Word32 **ppFilt_coeff_fx /* o : filter coefficients */
+ const Word32 **ppFilt_coeff_fx, /* o : filter coefficients */
+ const Word16 **ppFilt_coeff_e /* o : exponents of filter coefficients */
);
#endif
@@ -7129,6 +7509,7 @@ void ivas_filters_init(
void ivas_filters_init_fx(
ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
const Word32 *filt_coeff, /* i : filter coefficients */
+ const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */
const Word16 order /* i : filter order */
);
#endif
@@ -7299,6 +7680,17 @@ void ivas_set_surplus_brate_dec(
int32_t *ism_total_brate /* i : ISM total bitrate */
);
+#ifdef IVAS_FLOAT_FIXED
+void ivas_set_ism_importance_interformat_fx(
+ const Word32 ism_total_brate, /* i/o: ISms total bitrate */
+ 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 */
+ const Word32 lp_noise_CPE_fx, /* i : LP filtered total noise estimation */
+ Word16 ism_imp[] /* o : ISM importance flags */
+);
+#endif
+
void ivas_set_ism_importance_interformat(
const int32_t ism_total_brate, /* i/o: ISms total bitrate */
const int16_t nchan_transport, /* i : number of transported channels */
@@ -7382,11 +7774,13 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm(
float *output_f[] /* o : rendered time signal */
);
#endif
+#ifndef IVAS_FLOAT_FIXED
void ivas_omasa_rearrange_channels(
float *output[], /* o : output synthesis signal */
const int16_t nchan_transport_ism, /* i : number of ISM TCs */
const int16_t output_frame /* i : output frame length per channel */
);
+#endif
#ifndef IVAS_FLOAT_FIXED
void ivas_omasa_dirac_rend_jbm(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
@@ -7519,6 +7913,15 @@ ivas_error ivas_FB_mixer_open(
const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */
);
+#ifdef IVAS_FLOAT_FIXED
+void ivas_FB_mixer_close_fx(
+ IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */
+ const Word32 sampling_rate, /* i : sampling rate in Hz */
+ const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */
+);
+
+#endif
+
void ivas_FB_mixer_close(
IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */
const int32_t sampling_rate, /* i : sampling rate in Hz */
@@ -7574,9 +7977,15 @@ void ivas_fb_mixer_cross_fading(
);
/*! r: number of spectral bands */
+#ifdef IVAS_FLOAT_FIXED
+Word16 ivas_get_num_bands_from_bw_idx(
+ const Word16 bwidth /* i : audio bandwidth */
+);
+#else
int16_t ivas_get_num_bands_from_bw_idx(
const int16_t bwidth /* i : audio bandwidth */
);
+#endif
#ifdef IVAS_FLOAT_FIXED
/*to be moved to prot_fx1.h*/
diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h
index a96ef417a4de54e95db368531039e966c8a4975a..8ed4fd451bb6c15d91f70a3fbed443c899865599 100644
--- a/lib_com/ivas_prot_fx.h
+++ b/lib_com/ivas_prot_fx.h
@@ -1123,6 +1123,20 @@ void stereo_dft_dec_fx(
const Word16 num_md_sub_frames /* i : number of MD subframes */
);
+// ivas_stereo_dft_enc.c
+#ifdef IVAS_FLOAT_FIXED
+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 */
+ Word16 *output_start_index,
+ Word16 *output_end_index,
+ const Word16 chan, /* i : channel number */
+ const Word32 input_Fs, /* i : input sampling rate */
+ const Word32 output_sampling_rate, /* i : output sampling rate */
+ const Word16 L_frame, /* i : frame length at internal Fs */
+ Word16 *nrg_out_fx_e );
+#endif
void ivas_ls_setup_conversion_fx(
Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
@@ -1388,7 +1402,8 @@ void decoder_tcx_tns_fx(
STnsData *tnsData,
const Word16 bfi, /* i : Bad frame indicator */
const Word16 frame_cnt, /* i : frame counter in the super frame */
- const Word16 whitenedDomain );
+ const Word16 whitenedDomain,
+ Word16 *length );
void ivas_mdct_core_tns_ns_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
@@ -2100,9 +2115,9 @@ void td_bwe_dec_init_ivas_fx(
);
void ivas_dirac_dec_render_sf_fx(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */
- const int16_t nchan_transport, /* i : number of transport channels */
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */
+ const Word16 nchan_transport, /* i : number of transport channels */
Word32 *pppQMfFrame_ts_re_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX],
Word32 *pppQMfFrame_ts_im_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] );
@@ -2116,15 +2131,15 @@ void ivas_dirac_dec_render_fx(
);
void ivas_dirac_dec_read_BS_fx(
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate */
Decoder_State *st, /* i/o: decoder Core state structure */
DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */
IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q metadata */
- int16_t *nb_bits, /* o : number of bits read */
- const int16_t last_bit_pos, /* i : last read bitstream position */
- const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */
- int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */
+ Word16 *nb_bits, /* o : number of bits read */
+ const Word16 last_bit_pos, /* i : last read bitstream position */
+ const Word16 hodirac_flag, /* i : flag to indicate HO-DirAC mode */
+ Word16 *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */
);
ivas_error ivas_dirac_dec_config_fx(
@@ -2166,23 +2181,23 @@ ivas_error ivas_ism_metadata_dec_create_fx(
Word32 element_brate_tmp[] /* o : element bitrate per object */
);
ivas_error ivas_sba_dec_reconfigure_fx(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- uint16_t *nSamplesFlushed, /* o : number of samples flushed */
- int16_t *data /* o : output synthesis signal */
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ UWord16 *nSamplesFlushed, /* o : number of samples flushed */
+ Word16 *data /* o : output synthesis signal */
);
ivas_error ivas_spar_md_dec_matrix_open_fx(
ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
- const int16_t num_channels, /* i : number of internal channels */
- const int16_t num_md_sub_frames /* i : number of MD subframes */
+ const Word16 num_channels, /* i : number of internal channels */
+ const Word16 num_md_sub_frames /* i : number of MD subframes */
);
void ivas_spar_md_dec_matrix_close_fx(
ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */
- const int16_t num_channels /* i : number of internal channels */
+ const Word16 num_channels /* i : number of internal channels */
);
ivas_error ivas_spar_dec_open_fx(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
+ const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */
);
void ivas_param_mc_dec_read_BS_fx(
@@ -2226,8 +2241,8 @@ ivas_error ivas_FB_mixer_open_fx(
void ivas_FB_mixer_close_fx(
IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */
- const int32_t sampling_rate, /* i : sampling rate in Hz */
- const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */
+ const Word32 sampling_rate, /* i : sampling rate in Hz */
+ const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */
);
void ivas_fb_mixer_cross_fading_fx(
@@ -2235,9 +2250,9 @@ void ivas_fb_mixer_cross_fading_fx(
Word32 **ppOut_pcm_fx,
Word32 *pMdft_out_old_fx,
Word32 *pMdft_out_new_fx,
- const int16_t ch,
- const int16_t frame_len,
- const int16_t cf_offset );
+ const Word16 ch,
+ const Word16 frame_len,
+ const Word16 cf_offset );
// ivas_omasa_dec.c
ivas_error ivas_omasa_dirac_td_binaural_jbm_fx(
@@ -2393,4 +2408,164 @@ Word16 ism_quant_meta_fx(
const Word16 cbsize /* i : codebook size */
);
+/*! r: number of channels to be analysed */
+Word16 getNumChanAnalysis_fx(
+ Encoder_Struct *st_ivas /* i : IVAS encoder structure */
+);
+
+ivas_error ivas_limiter_open_fx(
+ IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */
+ const Word16 max_num_channels, /* i : maximum number of I/O channels to be processed */
+ const Word32 sampling_rate /* i : sampling rate for processing */
+);
+
+void ivas_limiter_close_fx(
+ IVAS_LIMITER_HANDLE *phLimiter /* i/o: pointer to limiter handle, can be NULL */
+);
+
+void copy_masa_descriptive_meta_fx(
+ MASA_DECRIPTIVE_META *outMeta, /* o : metadata to be written */
+ MASA_DECRIPTIVE_META *inMeta /* i : input metadata */
+);
+
+void efap_free_data_fx(
+ EFAP_HANDLE *hEFAPdata /* i/o: EFAP handle to be freed */
+);
+
+void tdm_SCh_LSF_intra_pred_fx(
+ const Word32 element_brate, /* i : element bitrate */
+ const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs */
+ Word16 *pred_lsf_SCh_fx /* o : predicted secondary channel LSFs */
+);
+
+ivas_error ivas_create_lfe_lpf_enc_fx(
+ ivas_filters_process_state_t **hLfeLpf, /* o : LFE LPF handle */
+ const Word32 input_Fs /* i : input sampling rate */
+);
+
+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 */
+ const Word16 input_frame /* i : input frame length per channel */
+);
+
+// ivas_arith.c
+void ivas_ari_done_encoding_14bits_fx(
+ BSTR_ENC_HANDLE hBstr,
+ Tastat *s );
+
+void ivas_ari_encode_14bits_ext_fx(
+ BSTR_ENC_HANDLE hBstr,
+ Tastat *s,
+ Word32 symbol,
+ const UWord16 *cum_freq );
+
+void ms_inv_mask_processing_fx(
+ STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: 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 iSubframe, /* i : subframe number */
+ const Word32 x_0_fx[], /* i : spectrum 1 */
+ const Word32 x_1_fx[], /* i : spectrum 2 */
+ Word32 x_inv_0_fx[], /* o : inverse spectrum 1 */
+ Word32 x_inv_1_fx[], /* o : inverse spectrum 2 */
+ int16_t maxSfb /* i : number of stereo frequency bands */
+);
+
+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 */
+ Word32 x_0_fx[], /* i/o: spectrum 1 */
+ Word32 x_1_fx[], /* i/o: spectrum 1 */
+ Word16 maxSfb /* i : number of stereo frequency bands*/
+);
+
+void convertToMS_fx(
+ const int16_t L_frame, /* i : frame length */
+ Word32 x0[], /* i/o: mid/left channel coefficients */
+ Word32 x1[], /* i/o: side/right channel coefficients */
+ const Word32 norm_fac /* i : normalization factor */
+);
+
+void FindSplitRatio_fx(
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ Encoder_State **sts /* i/o: Encoder state structure */
+);
+
+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 */
+ 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 */
+);
+
+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 */
+ Word32 *mdst_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i/o: MDST spectrum */
+ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse spectrum */
+ Word32 *inv_mdst_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */
+ const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */
+ Word16 q_spec );
+
+// bw_detect_fx.c
+Word16 set_bw_mct_fx(
+ CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE encoder structures */
+ const Word16 nCPE /* i : number of CPEs */
+);
+
+
+// ivas_mct_enc_mct.c
+void write_mct_bitstream_fx(
+ Encoder_State **sts, /* i/o: encoder state structure */
+ MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
+ const Word16 nchan /* i : number of channels */
+);
+
+void getChannelEnergies_fx(
+ Encoder_State **sts, /* i/o: Encoder state structure */
+ Word32 nrg[MCT_MAX_CHANNELS], /* o : buffer with energies for each channel */
+ Word16 nrg_e[MCT_MAX_CHANNELS], /* o : exponents of energies for each channel */
+ const Word16 nchan /* i : number of channels */
+);
+
+void apply_MCT_enc_fx(
+ MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
+ Encoder_State **sts, /* i/o: encoder state structure */
+ Word32 *mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: MDST spectrum */
+ Word32 *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse spectrum */
+ Word32 *inv_mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */
+ const Word16 nchan /* i : number of channels */
+);
#endif
+
+void ivas_spar_config_fx(
+ Word32 ivas_total_brate, /* i : codec total bitrate */
+ const Word16 sba_order, /* i : Ambisonic (SBA) order */
+ Word16 *nchan_transport, /* o : number of transport channels */
+ Word16 *nSCE, /* o : number of SCEs */
+ Word16 *nCPE, /* o : number of CPEs */
+ Word32 *core_nominal_brate, /* o : core-coding nominal bitrate */
+ const Word16 sid_format /* i : IVAS format indicator from SID frame */
+);
+
+Word16 ivas_get_bw_idx_from_sample_rate_fx(
+ const Word32 sampling_rate /* i : sampling rate */
+);
+
+void ivas_spar_bitrate_dist_fx(
+ Word32 core_brates_act[], /* o : bitrates per core-coder */
+ const Word16 nAvailBits, /* i : number of available bits */
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate */
+ const Word16 sba_order, /* i : Ambisonic (SBA) order */
+ const Word16 bwidth /* i : audio bandwidth */
+);
diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com.c
index bc998fed5a6500d5d1b088639efa50d3e9578293..3bcec831e87b6d4ee95bb86a0a08d6c5d6df389d 100644
--- a/lib_com/ivas_qmetadata_com.c
+++ b/lib_com/ivas_qmetadata_com.c
@@ -38,15 +38,17 @@
#include "ivas_rom_com.h"
#include "ivas_prot.h"
#include "prot.h"
-#include "prot_fx1.h"
#include "cnst.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
-//#include "debug.h"
+// #include "debug.h"
/*-----------------------------------------------------------------------*
* Local constants
@@ -139,6 +141,7 @@ ivas_error ivas_qmetadata_allocate_memory(
ELSE
{
do_realloc = TRUE;
+ move16();
}
IF( do_realloc )
@@ -146,6 +149,7 @@ ivas_error ivas_qmetadata_allocate_memory(
ivas_qmetadata_free_memory( hQMetaData );
hQMetaData->numCodingBands = (UWord8) nbands;
+ move16();
hQMetaData->no_directions = ndirs;
move16();
hQMetaData->coherence_flag = coherence_flag;
@@ -160,7 +164,7 @@ ivas_error ivas_qmetadata_allocate_memory(
{
hQMetaData->q_direction[dir].cfg.nbands = nbands;
move16();
- IF( EQ_16( nbands, 0 ) )
+ IF( nbands == 0 )
{
hQMetaData->q_direction[dir].band_data = NULL;
}
@@ -427,6 +431,7 @@ void ivas_qmetadata_close(
IVAS_QMETADATA_HANDLE *hQMetaData /* i/o: q_metadata handle */
)
{
+ test();
IF( hQMetaData == NULL || *hQMetaData == NULL )
{
return;
@@ -547,10 +552,10 @@ ivas_error only_reduce_bits_direction_fx(
delta = 1;
move16();
- IF( GT_16( reduce_bits, 0 ) )
+ IF( reduce_bits > 0 )
{
- red_times = reduce_bits / ( coding_subbands * no_subframes ); /* number of complete reductions by 1 bit */
- IF( GT_16( red_times, 0 ) )
+ red_times = idiv1616( reduce_bits, imult1616( coding_subbands, no_subframes ) ); /* number of complete reductions by 1 bit */
+ IF( red_times > 0 )
{
FOR( j = 0; j < coding_subbands; j++ )
{
@@ -582,14 +587,15 @@ ivas_error only_reduce_bits_direction_fx(
bits_dir0 = (Word16 *) q_direction->band_data[j].bits_sph_idx;
FOR( k = 0; k < no_subframes; k++ )
{
+ test();
IF( LT_16( n, rem ) && GT_16( bits_dir0[k], sub( MASA_MIN_BITS_TF, delta ) ) )
{
bits_dir0[k] = sub( bits_dir0[k], 1 );
move16();
- n++;
+ n = add( n, 1 );
}
- IF( LT_16( max_nb, bits_dir0[k] ) )
+ if ( LT_16( max_nb, bits_dir0[k] ) )
{
max_nb = bits_dir0[k];
move16();
@@ -635,7 +641,9 @@ ivas_error only_reduce_bits_direction_fx(
FOR( j = 0; j < m; j++ )
{
index1 = ind_order[j];
+ move16();
index2 = ind_order[j + 1];
+ move16();
tmp = 0;
move16();
FOR( k = 0; k < no_subframes; k++ )
@@ -643,6 +651,7 @@ ivas_error only_reduce_bits_direction_fx(
tmp = add( tmp, sub( bits_sph_idx_orig[index1][k], q_direction->band_data[index1].bits_sph_idx[k] ) );
}
penalty[0] = L_shr( W_extract_l( W_mult_32_16( tmp, bits_sph_idx_orig[index2][0] ) ), 1 );
+ move32();
tmp = 0;
move16();
FOR( k = 0; k < no_subframes; k++ )
@@ -650,6 +659,7 @@ ivas_error only_reduce_bits_direction_fx(
tmp = add( tmp, sub( bits_sph_idx_orig[index2][k], q_direction->band_data[index2].bits_sph_idx[k] ) );
}
penalty[1] = L_shr( W_extract_l( W_mult_32_16( tmp, bits_sph_idx_orig[index1][0] ) ), 1 );
+ move32();
IF( LT_32( penalty[0], penalty[1] ) )
{
sorted = 0;
@@ -691,7 +701,7 @@ ivas_error only_reduce_bits_direction_fx(
move16();
FOR( k = 0; k < no_subframes; k++ )
{
- IF( GT_16( bits_sph_idx_orig[j][k], 0 ) )
+ IF( bits_sph_idx_orig[j][k] > 0 )
{
tmp = add( tmp, sub( bits_sph_idx_orig[j][k], q_direction->band_data[j].bits_sph_idx[k] ) );
}
@@ -709,7 +719,7 @@ ivas_error only_reduce_bits_direction_fx(
{
FOR( k = 0; k < no_subframes; k++ )
{
- IF( GT_16( bits_sph_idx_orig[j][k], 0 ) )
+ IF( bits_sph_idx_orig[j][k] > 0 )
{
tmp = BASOP_Util_Divide3232_Scale( extract_l( L_sub( bits_sph_idx_orig[j][k], q_direction->band_data[j].bits_sph_idx[k] ) ), bits_sph_idx_orig[j][k], &tmp_e );
tmp_32 = L_add( tmp_32, L_shl( tmp, tmp_e ) );
@@ -725,6 +735,7 @@ ivas_error only_reduce_bits_direction_fx(
}
*reduce_bits_out = negate( reduce_bits );
+ move16();
return IVAS_ERR_OK;
}
@@ -856,32 +867,36 @@ void update_bits_next_block(
Word16 k;
diff = *p_diff;
move16();
- IF( LT_16( diff, 0 ) )
+ IF( diff < 0 )
{
/* increase bits for next subbands */
k = 0;
move16();
- WHILE( LT_16( diff, 0 ) && LT_16( j, max_i ) && LT_16( k, max_k ) )
+ WHILE( diff < 0 && LT_16( j, max_i ) && LT_16( k, max_k ) )
{
+ test();
+ test();
IF( LT_32( q_direction->band_data[j].bits_sph_idx[k], MASA_DIRECTION_MAX_BITS ) )
{
q_direction->band_data[j].bits_sph_idx[k] = (UWord16) L_add( q_direction->band_data[j].bits_sph_idx[k], 1 );
move16();
- diff++;
+ diff = add( diff, 1 );
}
- k++;
+ k = add( k, 1 );
}
}
ELSE
{
k = 0;
- WHILE( GT_16( diff, 0 ) && LT_16( k, max_k ) )
+ move16();
+ WHILE( diff > 0 && LT_16( k, max_k ) )
{
- IF( GT_32( q_direction->band_data[j].bits_sph_idx[k], 0 ) )
+ test();
+ IF( q_direction->band_data[j].bits_sph_idx[k] > 0 )
{
q_direction->band_data[j].bits_sph_idx[k] = (UWord16) L_sub( q_direction->band_data[j].bits_sph_idx[k], 1 );
move16();
- diff--;
+ diff = sub( diff, 1 );
}
}
}
@@ -990,8 +1005,8 @@ void invdct4_transform_fx(
a_fx = L_add( v_fx[0], v_fx[2] );
b_fx = L_sub( v_fx[0], v_fx[2] );
- c_fx = L_shl( L_add( Mpy_32_32( 1402911360, v_fx[1] ), Mpy_32_32( 581104896, v_fx[3] ) ), 31 - 30 );
- d_fx = L_shl( L_sub( Mpy_32_32( 581104896, v_fx[1] ), Mpy_32_32( 1402911360, v_fx[3] ) ), 31 - 30 );
+ c_fx = L_shl( L_add( Mpy_32_32( 1402911360, v_fx[1] ), Mpy_32_32( 581104896, v_fx[3] ) ), Q31 - Q30 );
+ d_fx = L_shl( L_sub( Mpy_32_32( 581104896, v_fx[1] ), Mpy_32_32( 1402911360, v_fx[3] ) ), Q31 - Q30 );
f_invdct_v_fx[0] = L_shl( L_add( a_fx, c_fx ), 7 );
move32();
f_invdct_v_fx[1] = L_shl( L_add( b_fx, d_fx ), 7 );
@@ -1003,9 +1018,10 @@ void invdct4_transform_fx(
FOR( i = 0; i < 4; i++ )
{
- IF( LT_32( f_invdct_v_fx[i], 0 ) )
+ IF( f_invdct_v_fx[i] < 0 )
{
invdct_v[i] = 0;
+ move16();
}
ELSE
{
@@ -1015,6 +1031,7 @@ void invdct4_transform_fx(
move32();
}
invdct_v[i] = (UWord8) L_shr( f_invdct_v_fx[i], q );
+ move16();
}
}
@@ -1043,12 +1060,16 @@ void masa_compensate_two_dir_energy_ratio_index_fx(
IF( hodirac_flag )
{
*ratio_index_mod1 = masa_diffuse_ratios[ratio_index_1][ratio_index_2].hordiac_ratio1;
+ move16();
*ratio_index_mod2 = masa_diffuse_ratios[ratio_index_1][ratio_index_2].hoardia_ratio2;
+ move16();
}
ELSE
{
*ratio_index_mod1 = masa_diffuse_ratios[ratio_index_1][ratio_index_2].ratio1;
+ move16();
*ratio_index_mod2 = masa_diffuse_ratios[ratio_index_1][ratio_index_2].ratio2;
+ move16();
}
return;
@@ -1222,8 +1243,10 @@ void ivas_qmetadata_direction_vector_to_azimuth_elevation_fx(
L_tmp = L_add( Mpy_32_32( dv[0], dv[0] ), Mpy_32_32( dv[1], dv[1] ) ); /* 2 * dv_q - 31 */
e_tmp = shl( sub( 31, dv_q ), 1 );
L_tmp = Sqrt32( L_tmp, &e_tmp );
- *el = L_mult0( BASOP_util_atan2( dv[2], L_tmp, 31 - dv_q - e_tmp ), 29335 ); /* Q22 */
- *az = L_mult0( BASOP_util_atan2( dv[1], dv[0], 0 ), 29335 ); /* Q22 */
+ *el = L_mult0( BASOP_util_atan2( dv[2], L_tmp, sub( sub( 31, dv_q ), e_tmp ) ), 29335 ); /* Q22 */
+ move32();
+ *az = L_mult0( BASOP_util_atan2( dv[1], dv[0], 0 ), 29335 ); /* Q22 */
+ move32();
return;
}
#endif
diff --git a/lib_com/ivas_qspherical_com.c b/lib_com/ivas_qspherical_com.c
index 9c2f5f64343a1769212ec99c052660a00fc9134a..0eb7f6a1c32a0cb85e321b729c21320757e4c906 100644
--- a/lib_com/ivas_qspherical_com.c
+++ b/lib_com/ivas_qspherical_com.c
@@ -41,6 +41,9 @@
#include "cnst.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*-------------------------------------------------------------------------
@@ -78,7 +81,7 @@ Word16 ivas_qmetadata_dereorder_generic(
const UWord16 uns_value /* i : unsigned value result of ReorderGeneric */
)
{
- IF( NE_32( L_and( uns_value, 1 ), 0 ) )
+ IF( L_and( uns_value, 1 ) != 0 )
{
return sub( negate( extract_l( L_shr( uns_value, 1 ) ) ), 1 );
}
@@ -121,7 +124,7 @@ Word16 ivas_dirac_project_elevation_index(
Word16 el_idx_proj;
/* evaluate floor((el_idx / (el_alph - 1)) * (el_alph_proj - 1) + 0.5) using only integer */
- el_idx_proj = ( 2 * el_idx * ( el_alph_proj - 1 ) + ( el_alph - 1 ) ) / ( 2 * ( el_alph - 1 ) );
+ el_idx_proj = idiv1616( add( imult1616( imult1616( 2, el_idx ), sub( el_alph_proj, 1 ) ), sub( el_alph, 1 ) ), imult1616( 2, sub( el_alph, 1 ) ) );
return el_idx_proj;
}
@@ -161,11 +164,11 @@ Word16 ivas_chan_project_elevation_index(
/* evaluate floor((el_idx / (el_alph - 1)) * (el_alph_proj - 1) + 0.5) using only integer */
IF( EQ_16( el_idx, sub( el_alph, 1 ) ) )
{
- el_idx_proj = el_alph_proj - 1;
+ el_idx_proj = sub( el_alph_proj, 1 );
}
ELSE
{
- el_idx_proj = ( 2 * el_idx * el_alph_proj + el_alph ) / ( 2 * el_alph );
+ el_idx_proj = idiv1616( add( imult1616( imult1616( 2, el_idx ), el_alph_proj ), el_alph ), imult1616( 2, el_alph ) );
}
return el_idx_proj;
@@ -216,9 +219,9 @@ Word16 ivas_dirac_project_azimuth_index(
}
/* evaluate floor((az_idx / az_alph) * az_alph_proj + 0.5) using only integer */
- az_idx_proj = ( 2 * az_idx * az_alph_proj + az_alph ) / ( 2 * az_alph );
+ az_idx_proj = idiv1616( add( imult1616( imult1616( 2, az_idx ), az_alph_proj ), az_alph ), imult1616( 2, az_alph ) );
- IF( EQ_16( az_idx_proj, az_alph_proj ) )
+ if ( EQ_16( az_idx_proj, az_alph_proj ) )
{
az_idx_proj = 0;
move16();
@@ -280,6 +283,7 @@ void small_reduction_direction(
IF( GT_32( bits_dir[i][j], MASA_MIN_BITS_TF ) )
{
bits_dir[i][j] = (UWord16) L_sub( bits_dir[i][j], 1 );
+ move16();
( *diff )--;
}
}
@@ -411,7 +415,9 @@ Word16 quantize_phi_fx(
Word32 temp_res;
delta_phi_fx = delta_phi_val[n];
+ move32();
inv_delta_phi_fx = inv_delta_phi_val[n];
+ move32();
IF( EQ_16( n, 1 ) )
{
*phi_hat = 0;
@@ -433,17 +439,17 @@ Word16 quantize_phi_fx(
}
temp_res = Mpy_32_32( L_sub( L_sub( phi, DEGREE_180_Q_22 ), dd_fx ), inv_delta_phi_fx );
- id_phi = round_fx( L_shr( temp_res, 22 - 16 ) );
+ id_phi = round_fx( L_shr( temp_res, Q22 - Q16 ) );
assert( L_sub( L_abs( temp_res ), abs( id_phi ) * ONE_IN_Q22 ) <= ONE_IN_Q21 );
- IF( LT_16( add( id_phi, shr( n, 1 ) ), 0 ) )
+ IF( add( id_phi, shr( n, 1 ) ) < 0 )
{
id_phi = add( id_phi, 1 );
}
- IF( GE_16( sub( id_phi, shr( n, 1 ) ), 0 ) )
+ IF( sub( id_phi, shr( n, 1 ) ) >= 0 )
{
id_phi = negate( shr( n, 1 ) );
}
@@ -465,6 +471,7 @@ ELSE
}
*phi_hat = L_add( L_add( ( id_phi * delta_phi_fx ), dd_fx ), DEGREE_180_Q_22 );
+move32();
id_phi = add( id_phi, shr( n, 1 ) );
return id_phi;
@@ -574,6 +581,66 @@ Word32 companding_azimuth_fx(
Word32 comp_azi_fx;
Word16 i, not_done, start;
Word32 abs_azi_fx;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
test();
test();
@@ -628,6 +695,7 @@ Word32 companding_azimuth_fx(
move16();
WHILE( not_done && ( LT_16( i, sub( no_points, 1 ) ) ) )
{
+ test();
IF( LE_32( abs_azi_fx, pA_fx[i + 1] ) )
{
not_done = 0;
@@ -669,11 +737,11 @@ Word32 companding_azimuth_fx(
}
ELSE
{
- i++;
+ i = add( i, 1 );
}
}
- IF( LT_32( azi_fx, 0 ) )
+ IF( azi_fx < 0 )
{
comp_azi_fx = L_negate( comp_azi_fx );
}
diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c
index c3b7456f3d2dd980090d24b77845ed534c910bc9..8733ad0bd32caf5461105d5b01d8886153668b2d 100644
--- a/lib_com/ivas_rom_com.c
+++ b/lib_com/ivas_rom_com.c
@@ -557,18 +557,6 @@ const float ica_sincInterp2[2*SINC_ORDER1+1] =
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 Word32 ica_sincInterp2_fx[2 * SINC_ORDER1 + 1] =
-{
- 0, -4988604, 0, 7486127, 0,
--12594991, 0, 20905753, 0, -33172179, 0,
-50472307, 0, -74575663, 0, 108767895, 0,
--160155039, 0, 247433071, 0, -439753119, 0,
-1361749503, 2147483647, 1361749503, 0, -439753119, 0,
-247433071, 0, -160155039, 0, 108767895, 0,
--74575663, 0, 50472307, 0, -33172179, 0,
-20905753, 0, -12594991, 0, 7486127, 0,
--4988604, 0
-};
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,
@@ -596,13 +584,6 @@ const float icbwe_gsMapping_tbl[16] =
-0.1690688f, -0.0987095f, -0.0700000f, -0.0500000f, -0.0200000f, 0.0000000f, 0.0400000f, 0.0800000f
};
-const Word16 pow_10_icbwe_gsMapping_tbl_fx[16] = //Q14
-{
- 164 ,733 ,1793 ,3195 ,4524 ,5875 ,7438 ,9155 ,11101 ,13053 ,13945 ,14602 ,15647 ,16384 ,
- 17965 ,19698
-};
-
-
const float icbwe_gsMappingDFT_tbl[128] =
{
-5.0000000f, -4.5000000f, -4.0000000f, -3.5000000f, -3.0000000f, -2.5000000f, -1.9000000f, -1.5474502f,
@@ -623,20 +604,6 @@ const float icbwe_gsMappingDFT_tbl[128] =
0.0155180f, 0.0224511f, 0.0298570f, 0.0375954f, 0.0457853f, 0.0549424f, 0.0659733f, 0.0785186f
};
-const Word16 pow_10_icbwe_gsMappingDFT_tbl_fx[128] = //Q14
-{
- 0 ,1 ,2 ,5 ,16 ,52 ,206 ,464 ,518 ,585 ,667 ,688 ,803 ,899 ,
- 1324 ,1349 ,1513 ,1534 ,1578 ,1625 ,1711 ,1756 ,1808 ,1879 ,1926 ,2001 ,2050 ,2130 ,
- 2191 ,2280 ,2366 ,2394 ,2456 ,2574 ,2643 ,2726 ,2796 ,2850 ,2869 ,2908 ,2962 ,2991 ,
- 3023 ,3051 ,3091 ,3130 ,3202 ,3233 ,3268 ,3342 ,3388 ,3429 ,3483 ,3519 ,3553 ,3595 ,
- 3651 ,3706 ,3738 ,3795 ,3844 ,3890 ,3946 ,3990 ,4028 ,4075 ,4119 ,4166 ,4214 ,4259 ,
- 4303 ,4350 ,4389 ,4441 ,4481 ,4540 ,4605 ,4684 ,4764 ,4854 ,4950 ,5068 ,5198 ,5348 ,
- 5519 ,5692 ,5881 ,6073 ,6273 ,6473 ,6676 ,6883 ,7124 ,7364 ,7616 ,7852 ,8097 ,8370 ,
- 8630 ,8916 ,9200 ,9496 ,9866 ,10252 ,10652 ,11052 ,11436 ,11813 ,12247 ,12697 ,13153 ,13611 ,
- 14072 ,14503 ,14936 ,15336 ,15702 ,16032 ,16384 ,16664 ,16980 ,17253 ,17550 ,17866 ,18206 ,18594 ,
- 19072 ,19631
-};
-
/*----------------------------------------------------------------------------------*
* TD Stereo ROM tables
@@ -650,14 +617,6 @@ const float tdm_ratio_tabl[TDM_NQ+1] =
0.9045f, 0.9330f, 0.9568f, 0.9755f, 0.9891f, 1.0000f, 1.0000f, 1.0000f
};
-const UWord32 tdm_ratio_tabl_fx[TDM_NQ + 1] =
-{ 0, 0, 23407572, 52613348, 92771296,
-143881408, 205084688, 275736896, 355193792, 442596384, 536870912,
-636943680, 741955584, 850403520, 961428416, 1073741824, 1186055168,
-1297080064, 1405528064, 1510540032, 1610612736, 1704887296, 1792289792,
-1871746688, 1942398976, 2003602304, 2054712320, 2094870272, 2124076032,
-2147483647, 2147483647, 2147483647 };
-
const float tdm_den_ratio_tabl[TDM_NQ+1] = /* 1.0f/(2*LR_ratio*LR_ratio-2*LR_ratio+1) */
{
1.0000f, 1.0000f, 1.0221f, 1.0501f, 1.0902f, 1.1429f, 1.2088f, 1.2884f,
@@ -666,14 +625,6 @@ const float tdm_den_ratio_tabl[TDM_NQ+1] = /* 1.0f/(2*LR_ratio*LR_ratio-2*LR_ra
1.2088f, 1.1429f, 1.0902f, 1.0501f, 1.0221f, 1.0000f, 1.0000f, 1.0000f
};
-const UWord32 tdm_den_ratio_tabl_fx[TDM_NQ + 1] =
-{ 1073741824, 1073741824, 1097471488, 1127536256, 1170593280,
-1227179520, 1297939072, 1383409024, 1483374336, 1596009856, 1717986944,
-1842648320, 1960330496, 2058470400, 2124290816, 2147483647, 2124290816,
-2058470400, 1960330496, 1842648320, 1717986944, 1596009856, 1483374336,
-1383409024, 1297939072, 1227179520, 1170593280, 1127536256, 1097471488,
-1073741824, 1073741824, 1073741824 };
-
const int16_t tdm_bit_allc_tbl[5][6] =
{
/* IC -- UC -- GC -- TM --AC */
@@ -683,59 +634,7 @@ const int16_t tdm_bit_allc_tbl[5][6] =
{ 1650, 6050, 0, 10000, 0, 10000 }, /* IVAS_32k */
{ 1650, 6050, 0, 13000, 0, 14000 } /* IVAS_48k */
};
-#ifdef IVAS_FLOAT_FIXED
-/* LSFs Intra-frame prediction tables */
-//2.56
-const Word16 tdm_LSF_MEAN_RE_USE_OUT_fx[M] =
-{
- 771, 1335, 2229, 3431, 4383, 5354, 6371, 7273, 8183, 9198, 10133, 10991, 12058, 13104, 14200, 15152
-};
-//2.56
-const Word16 tdm_LSF_MEAN_RE_USE_IN_fx[M] =
-{
- 733, 1337, 2271, 3451, 4418, 5382, 6430, 7304, 8221, 9247, 10165, 11079, 12115, 13197, 14266, 15269,
-};
-//2.56
-const Word16 tdm_LSF_MEAN_RE_USE_fx[M] =
-{
- 680, 1369, 2354, 3448, 4498, 5435, 6546, 7494, 8446, 9437, 10328, 11248, 12241, 13199, 14189, 15174
-};
-
-const Word16 tdm_Beta_Q1bit_re_use_13k2_fx[2] = { 31784, 24576 };//Q15
-const Word16 tdm_Beta_Q1bit_re_use_16k4_fx[2] = { 31129, 23265 };//Q15
-const Word16 tdm_Beta_Q1bit_re_use_24k4_32k_fx[2] = { 30474, 23920 };//Q15
-const Word16 tdm_Beta_Q1bit_re_use_48k_fx[2] = { 31784, 25231 };//Q15
-//Q15
-const Word16 tdm_RE_USE_adaptive_beta_prd_diag_3_fx[15 + 16 + 15] =
-{
- 29028, 6750, 1916, 27016, 7516, 1195, 26787, 5557, -196, 27796, 6753, 2172, 29434, 4446, 2175, 26053, 6337, 3063, 26043, 5521, 3633, 26082,
- 5989, 3515, 25672, 5911, 4846, 24123, 6494, 4374, 24971, 6225, 6235, 24146, 5619, 5848, 23638, 5393, 6445, 22579, 4027, 6694, 20698, 1779,
- 5789, 17681
-};
-//2.56
-const Word16 tdm_LSF_MEAN_PRED_QNT_fx[M] =
-{
- 1002, 1558, 2478, 3467, 4377, 5326, 6274, 7160, 8182, 9099, 10022, 10967, 12051, 13081, 14148, 15113
-};
-//2.56
-const Word16 tdm_LSF_MEAN_PRED_QNT_IN_fx[M] =
-{
- 739, 1371, 2303, 3436, 4431, 5394, 6378, 7321, 8293, 9282, 10221, 11153, 12166, 13193, 14252, 15290
-};
-//2.56
-const Word16 tdm_LSF_MEAN_PRED_QNT_OUT_fx[M] =
-{
- 733, 1337, 2271, 3451, 4418, 5382, 6430, 7304, 8221, 9247, 10165, 11079, 12115, 13197, 14266, 15269
-};
-//Q15
-const Word16 tdm_PRED_QNT_fixed_beta_prd_diag_3_fx[15 + 16 + 15] =
-{
- 23067, 3941, -3666, 24050, 5907, 829, 21960, 6229, -6052, 25859, 9862, -1369, 28559, 6019, 108, 22658, 7844, 697, 22045, 7998, 2310, 24735,
- 6497, 2464, 23434, 7120, 2903, 20194, 10049, 711, 26610, 6622, 5190, 23955, 5721, 3945, 23906, 6481, 4033, 24581, 4043, 5599, 20879, 3473,
- 3909, 21541
-};
-#endif
/* LSFs Intra-frame prediction tables */
const float tdm_LSF_MEAN_RE_USE_OUT[M] =
{
@@ -903,30 +802,12 @@ const float dft_cng_coh_pred[STEREO_DFT_N_COH_PRED][STEREO_DFT_COH_PRED_COEFFS]
{ 0.202543f, 0.048819f, 0.263407f, 0.023538f, 0.092021f, 0.395655f, 0.013064f, -0.011127f, 0.035466f, 0.976055f, 0.009968f, 0.162957f, 0.383185f, -0.365493f, 2.534677f},
{ 1.393664f, -0.131401f, 0.989429f, 0.738330f, 0.683865f, 0.001677f, -0.225448f, -0.012158f, 1.084608f, -0.115464f, 0.022371f, -0.045560f, -0.336230f, 0.422742f, 0.499163f}
};
-#ifdef IVAS_FLOAT_FIXED
-const Word16 dft_cng_coh_pred_fx[STEREO_DFT_N_COH_PRED][STEREO_DFT_COH_PRED_COEFFS] /*Q-13*/= {
- { 4926, -827, 10396, 696, 2285, 5488, 668, 1547, -1416, 2633, 76, -690, 2967, -3495, 6212 },
- { 7007, 3446, 3385, -76, -3274, 11352, 101, -125, 1281, 4238, 1312, -2487, 3913, -4593, 11326 },
- { 1659, 399, 2157, 192, 753, 3241, 107, -91, 290, 7995, 81, 1334, 3139, -2994, 20764 },
- { 11416, -1076, 8105, 6048, 5602, 13, -1846, -99, 8885, -945, 183, -373, -2754, 3463, 4089 }
-};
-#endif // IVAS_FLOAT_FIXED
const int16_t dft_cng_coh_u2i[9] = { 4, 5, 3, 6, 2, 7, 1, 8, 0 }; /* Coherence unary codeword -> residual codeword conversion table */
const int16_t dft_cng_coh_i2u[9] = { 8, 6, 4, 2, 0, 1, 3, 5, 7 }; /* Coherence residual codeword -> unary codeword conversion table */
const int16_t dft_cng_coh_alpha_start[STEREO_DFT_N_COH_ALPHA_STEPS - 1] = { 15, 16, 17, 18 };
-#ifdef IVAS_FLOAT_FIXED
-const Word16 dft_cng_alpha_bits_fx[STEREO_DFT_N_COH_ALPHA_STEPS][STEREO_DFT_N_COH_ALPHA_LEVELS]/*Q-15*/ =
-{
- { 3277/*0.1f*/, 19661/*0.6f*/ },
- { 3277/*0.1f*/, 19661/*0.6f*/ },
- { 3277/*0.1f*/, 22938/*0.7f*/ },
- { 3277/*0.1f*/, 29491/*0.9f*/ },
- { 6554/*0.2f*/, 29491/*0.9f*/ }
-};
-#endif // IVAS_FLOAT_FIXED
const float dft_cng_alpha_bits[STEREO_DFT_N_COH_ALPHA_STEPS][STEREO_DFT_N_COH_ALPHA_LEVELS] =
{
@@ -954,13 +835,6 @@ const float diffuseness_reconstructions[DIRAC_DIFFUSE_LEVELS] =
0.85009765625f
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 diffuseness_reconstructions_fx[DIRAC_DIFFUSE_LEVELS] = // q = 30
-{
- 0, 42467328, 96206848, 170655744, 331087872, 508821504, 678952960, 912785408
-};
-#endif
-
const float diffuseness_thresholds[DIRAC_DIFFUSE_LEVELS + 1] =
{
0.0f,
@@ -974,21 +848,6 @@ const float diffuseness_thresholds[DIRAC_DIFFUSE_LEVELS + 1] =
2.0f /* out-of-range large value to make searching easier */
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 diffuseness_thresholds_fx[DIRAC_DIFFUSE_LEVELS + 1] =
-{
- 0,
- 20447232,
- 67633152,
- 128188416,
- 237502464,
- 428605440,
- 587988992,
- 788791296,
- MAX_32 /* out-of-range large value to make searching easier */
-};
-#endif // IVAS_FLOAT_FIXED
-
const int16_t DirAC_band_grouping_12[12 + 1] =
{
0, 1, 2, 3, 4, 5, 6, 7, 11, 17, 25, 40, 60
@@ -1657,7 +1516,6 @@ const ivas_huff_models_t ivas_huff_decd_r_consts[TOTAL_DECD_QUANT_STRATS] =
/* DTX quantization and bitstream constants */
const float dtx_pd_real_min_max[2] = { 0, 1.6f };
-const Word32 dtx_pd_real_min_max_fx[2] = { 0, 429496729 };
const int16_t dtx_pd_real_q_levels[3][3] = { { 7,7,7 },{ 7,7,0 },{ 3,0,0 } };
const int16_t dtx_pr_real_q_levels[3][3] = { { 9,9,9 },{ 9,7,9 },{ 9,5,7 } };
const int16_t pr_pr_idx_pairs[3][3][2] = { { { 0, 0 },{ 0, 0 },{ 0, 0 } },{ { 0, 0 },{ 0, 0 },{ 0, 0 } },{ { 0, 0 },{ 1, 3 },{ 0, 0 } } };
@@ -2783,28 +2641,12 @@ const float ivas_param_mc_quant_ild_5d1_48[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] =
-8.0f, -5.5f, -3.5f, -1.5f, 0.0f, 1.5f, 3.5f, 5.5f, 8.0f, 10.0f, 13.0f, 20.0f
};
-#ifdef IVAS_FLOAT_FIXED
-//Q8
-const Word16 ivas_param_mc_quant_ild_5d1_48_fx[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] =
-{
- -25600 ,-5120 ,-3328 ,-2560 ,-2048 ,-1408 ,-896 ,-384 ,0 ,384 ,896 ,1408 ,2048 ,2560 ,3328 ,5120 ,
-};
-#endif
-
/* Quantizer for ICCs in Parametric MC Processing */
const float ivas_param_mc_quant_icc[PARAM_MC_SZ_ICC_QUANTIZER] =
{
-0.99f, -0.589f, 0.0f, 0.36764f, 0.60092f, 0.84118f, 0.937f, 1.0f
};
-#ifdef IVAS_FLOAT_FIXED
-//Q15
-const Word16 ivas_param_mc_quant_icc_fx[PARAM_MC_SZ_ICC_QUANTIZER] =
-{
- -32440,-19300,0,12046,19690,27563,30703,32767
-};
-#endif
-
/* Alphabet for delta coding for the ICCs in Parametric MC processing */
const uint16_t ivas_param_mc_cum_freq_icc_cicp6_48_16bits[PARAM_MC_SZ_ICC_QUANTIZER + 1] =
{
@@ -3110,29 +2952,6 @@ const float coherence_cb1_masa[MASA_NO_CV_COH1*MASA_MAXIMUM_CODING_SUBBANDS] =
0.0017f, 0.2521f, -0.2479f, 0.7217f, -0.7157f
};
-#ifdef IVAS_FLOAT_FIXED
-
-const Word32 coherence_cb0_masa_fx[DIRAC_DIFFUSE_LEVELS * 2 * MASA_NO_CV_COH] = //q = 21
-{
- 100243, 534144, 1156579, 2068840, 2846464, 3531184, 4125936, 0, 253965, 864655, 1467377,
- 2129448, 2977326, 3768791, 0, 0, 338480, 1189924, 2035915, 2872888, 3640026, 0, 0, 0,
- 492621, 1532179, 2527278, 3470157, 0, 0, 0, 0, 499331, 1506803, 2465831, 3425697, 0,
- 0, 0, 0, 503316, 1473668, 2392221, 3406404, 0, 0, 0, 0, 737778, 1970903, 3450654, 0, 0,
- 0, 0, 0, 2097152, 0, 0, 0, 0, 0, 0, 0, 303038, 719742, 1122186, 1577897, 2117075, 2770337,
- 3648834, 0, 419849, 932603, 1440533, 2011797, 2745172, 3571240, 0, 0, 548824, 1165177,
- 1812987, 2555379, 3366138, 0, 0, 0, 695835, 1428160, 2190475, 3084910, 0, 0, 0, 0, 697093,
- 1381603, 2092957, 2970406, 0, 0, 0, 0, 708417, 1396283, 2099039, 2992426, 0, 0, 0, 0, 835924,
- 1728892, 2836607, 0, 0, 0, 0, 0, 2097152, 0, 0, 0, 0, 0, 0, 0
-};
-
-const Word32 coherence_cb1_masa_fx[MASA_NO_CV_COH1*MASA_MAXIMUM_CODING_SUBBANDS] = // q = 21
-{
- -3984, 544630, -565392, 1314704, -1320157, -11534, 541484, -583847, 1357486, -1371118,
- -6081, 525546, -551551, 1362729, -1371537, -838, 533934, -540855, 1436758, -1414109,
- 3565, 528692, -519883, 1513514, -1500931
-};
-#endif
-
const int16_t len_cb_dct0_masa[DIRAC_DIFFUSE_LEVELS] = { 7, 6, 5, 4, 4, 4, 3, 2 };
const uint8_t sur_coherence_cb_masa[MASA_MAX_NO_CV_SUR_COH*MASA_NO_CB_SUR_COH] =
@@ -3171,31 +2990,6 @@ const int16_t no_phi_masa[NO_SPHERICAL_GRIDS][MAX_NO_THETA] = /* from 1 to 11 bi
{ 60, 60, 58, 56, 54, 50, 46, 41, 36, 30, 23, 17, 10, 1 },
{ 89, 89, 88, 86, 84, 81, 77, 73, 68, 63, 57, 51, 44, 38, 30, 23, 15, 8, 1 }
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 no_phi_masa_inv_fx[NO_SPHERICAL_GRIDS][MAX_NO_THETA] = /* from 1 to 11 bits*/ /*q factor = 8*/
-{
- {1073741824},
- {536870912},
- {536870912, 1073741824},
- {268435456, 536870912},
- {178956970, 306783378, 1073741824, 2147483647},
- {153391689, 165191049, 238609294, 1073741824, 2147483647},
- {97612893, 102261126, 126322567, 195225786, 715827882, 2147483647},
- {65075262, 67108864, 74051160, 93368854, 126322567, 238609294, 2147483647},
- {44739242, 45691141, 47721858, 52377649, 61356675, 76695844, 107374182, 178956970, 1073741824, 2147483647},
- {35791394, 35791394, 37025580, 38347922, 39768215, 42949672, 46684427, 52377649, 59652323, 71582788, 93368854, 126322567, 214748364, 2147483647},
- {24129029, 24129029, 24403223, 24970740, 25565281, 26512143, 27889398, 29417584, 31580641, 34087042, 37675151, 42107522, 48806446, 56512727, 71582788, 93368854, 143165576, 268435456, 2147483647}
-};
-
-const Word32 azimuth_cb_fx[8] =
-{
- 0, -754974720, -377487360, 377487360, -188743680, 188743680, -566231040, 566231040
-};
-
-const Word32 delta_theta_masa_fx[NO_SPHERICAL_GRIDS - 2] =
-{ 188743680, 188743680, 150994944, 106954752, 83886080, 62914560, 45214596, 28101836, 20971520 };
-
-#endif
const float delta_theta_masa[NO_SPHERICAL_GRIDS - 2] =
{ /*180.0f, 90.0f,*/ 45.0f, 45.0f, 36.0f, 25.5f, 20.0f, /*14.9f*/ 15.0f, 10.78f, 6.7f, 5.0f };
@@ -3322,29 +3116,6 @@ const float ls_elevation_CICP16[9] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 35
const float ls_azimuth_CICP19[11] = { 30.0f, -30.0f, 0.0f, 135.0f, -135.0f, 90.0f, -90.0f, 30.0f, -30.0f, 135.0f, -135.0f };
const float ls_elevation_CICP19[11] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 35.0f, 35.0f, 35.0f, 35.0f };
-const float cb_azi_chan[] = { 0.0f, 30.0f, 110.0f, 135.0f };
-
-#ifdef IVAS_FLOAT_FIXED
-const int16_t ls_azimuth_CICP2_idx[2] = { 1, 2 };
-const int16_t ls_elevation_CICP2_idx[2] = { 0, 0 };
-
-const int16_t ls_azimuth_CICP6_idx[5] = { 1, 2, 0, 7, 8 };
-const int16_t ls_elevation_CICP6_idx[5] = { 0, 0, 0, 0, 0 };
-
-const int16_t ls_azimuth_CICP12_idx[7] = { 1, 2, 0, 7, 8, 9, 10 };
-const int16_t ls_elevation_CICP12_idx[7] = { 0, 0, 0, 0, 0, 0, 0 };
-
-const int16_t ls_azimuth_CICP14_idx[7] = { 1, 2, 0, 7, 8, 1, 2 };
-const int16_t ls_elevation_CICP14_idx[7] = { 0, 0, 0, 0, 0, 3, 4 };
-
-const int16_t ls_azimuth_CICP16_idx[9] = { 1, 2, 0, 7, 8, 1, 2, 7, 8 };
-const int16_t ls_elevation_CICP16_idx[9] = { 0, 0, 0, 0, 0, 3, 3, 3, 3 };
-
-
-const int16_t ls_azimuth_CICP19_idx[11] = { 1, 2, 0, 9, 10, 5, 6, 1, 2, 9, 10 };
-const int16_t ls_elevation_CICP19_idx[11] = { 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3 };
-
-
const float shoebox_sin_cos_tbl[11][2] ={{0.00000000f, 1.00000000f }, //0
{0.500000000f, 0.866025388f}, { -0.500000000f, 0.866025388f}, //30, -30
{0.573576450f , 0.819152057f}, {-0.573576450f, 0.819152057f}, //35, -35
@@ -3352,80 +3123,7 @@ const float shoebox_sin_cos_tbl[11][2] ={{0.00000000f, 1.00000000f }, //0
{0.939692616f , -0.342020124f}, {-0.939692616f,-0.342020124f},//110,-110
{0.707106769f , -0.707106769f}, {-0.707106769f,-0.707106769f}}; //135, -135
-const Word32 shoebox_sin_cos_tbl_fx[11][2] ={{0,1073741824} , //0
- {536870912, 929887680},{-536870912, 929887680}, //30, -30
- {615873024,879557824},{-615873024,879557824},//35, -35
- {1073741824,0}, {-1073741824,0},//90, -90
- {1008987264,-367241312}, {-1008987264,-367241312},//110,-110
- {759250112,-759250112},{-759250112,-759250112}}; //135, -135 //Q.30
-
-#endif
-
-
-
-const Word32 delta_phi_val[90] =
-{ 0, 1509949440, 754974720, 503316480, 377487360, 301989888,
-251658240, 215707056, 188743680, 167772160, 150994944,
-137268128, 125829120, 116149960, 107853528, 100663296,
-94371840, 88820552, 83886080, 79471024, 75497472,
-71902352, 68634064, 65649976, 62914560, 60397976,
-58074980, 55924052, 53926764, 52067224, 50331648,
-48708048, 47185920, 45756044, 44410276, 43141412,
-41943040, 40809444, 39735512, 38716652, 37748736,
-36828036, 35951176, 35115104, 34317032, 33554432,
-32824988, 32126584, 31457280, 30815294, 30198988,
-29606852, 29037490, 28489612, 27962026, 27453626,
-26963382, 26490342, 26033612, 25592364, 25165824,
-24753270, 24354024, 23967452, 23592960, 23229992,
-22878022, 22536558, 22205138, 21883326, 21570706,
-21266894, 20971520, 20684238, 20404722, 20132660,
-19867756, 19609732, 19358326, 19113284, 18874368,
-18641352, 18414018, 18192162, 17975588, 17764112,
-17557552, 17355740, 17158516, 16965724 };
-
-const Word32 inv_delta_phi_val[90] =
-{ 0, 5965232, 11930464, 17895697, 23860929, 29826161,
-35791394, 41756626, 47721858, 53687091, 59652323,
-65617555, 71582788, 77548020, 83513252, 89478485,
-95443717, 101408950, 107374182, 113339414, 119304647,
-125269879, 131235111, 137200344, 143165576, 149130808,
-155096041, 161061273, 167026505, 172991738, 178956970,
-184922203, 190887435, 196852667, 202817900, 208783132,
-214748364, 220713597, 226678829, 232644061, 238609294,
-244574526, 250539758, 256504991, 262470223, 268435456,
-274400688, 280365920, 286331153, 292296385, 298261617,
-304226850, 310192082, 316157314, 322122547, 328087779,
-334053011, 340018244, 345983476, 351948708, 357913941,
-363879173, 369844406, 375809638, 381774870, 387740103,
-393705335, 399670567, 405635800, 411601032, 417566264,
-423531497, 429496729, 435461961, 441427194, 447392426,
-453357659, 459322891, 465288123, 471253356, 477218588,
-483183820, 489149053, 495114285, 501079517, 507044750,
-513009982, 518975214, 524940447, 530905679, };
-
-const Word32 dd_val[90] =
-{ 0, 754974720, 377487360, 251658240, 188743680, 150994944,
-125829120, 107853528, 94371840, 83886080, 75497472,
-68634064, 62914560, 58074980, 53926764, 50331648,
-47185920, 44410276, 41943040, 39735512, 37748736,
-35951176, 34317032, 32824988, 31457280, 30198988,
-29037490, 27962026, 26963382, 26033612, 25165824,
-24354024, 23592960, 22878022, 22205138, 21570706,
-20971520, 20404722, 19867756, 19358326, 18874368,
-18414018, 17975588, 17557552, 17158516, 16777216,
-16412494, 16063292, 15728640, 15407647, 15099494,
-14803426, 14518745, 14244806, 13981013, 13726813,
-13481691, 13245171, 13016806, 12796182, 12582912,
-12376635, 12177012, 11983726, 11796480, 11614996,
-11439011, 11268279, 11102569, 10941663, 10785353,
-10633447, 10485760, 10342119, 10202361, 10066330,
-9933878, 9804866, 9679163, 9556642, 9437184,
-9320676, 9207009, 9096081, 8987794, 8882056,
-8778776, 8677870, 8579258, 8482862 };
-
-#ifdef IVAS_FLOAT_FIXED
-const Word32 cb_azi_chan_fx[] = { 0, 125829120, 461373440, 566231040 };
-#endif
+const float cb_azi_chan[] = { 0.0f, 30.0f, 110.0f, 135.0f };
const float McMASA_LFEGain_vectors[64] =
{
@@ -3515,53 +3213,6 @@ const float dct12[12*12]=
0.2887f, -0.4048f, 0.3943f, -0.3772f, 0.3536f, -0.3239f, 0.2887f, -0.2485f, 0.2041f, -0.1562f, 0.1057f, -0.0533f
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 dct4_fx[4*4] =
-{
- 1073741824, 1402951040, 1073741824, 581109056,
- 1073741824, 581109056, -1073741824, -1402951040,
- 1073741824, -581109056, -1073741824, 1402951040,
- 1073741824, -1402951040, 1073741824, -581109056
-};
-
-const Word32 dct5_fx[5*5] =
-{
- 960354688, 1291711360, 1098867328, 798219648, 419618304,
- 960354688, 798219648, -419618304, -1291711360, -1098867328,
- 960354688, 0, -1358283392, 0, 1358283392,
- 960354688, -798219648, -419618304, 1291711360, -1098867328,
- 960354688, -1291711360, 1098867328, -798219648, 419618304
-};
-
-const Word32 dct8_fx[8*8] =
-{
- 759350208, 1053125952, 991922688, 892708928, 759350208, 596570944, 410813632, 209379648,
- 759350208, 892708928, 410813632, -209379648, -759350208, -1053125952, -991922688, -596570944,
- 759350208, 596570944, -410813632, -1053125952, -759350208, 209379648, 991922688, 892708928,
- 759350208, 209379648, -991922688, -596570944, 759350208, 892708928, -410813632, -1053125952,
- 759350208, -209379648, -991922688, 596570944, 759350208, -892708928, -410813632, 1053125952,
- 759350208, -596570944, -410813632, 1053125952, -759350208, -209379648, 991922688, -892708928,
- 759350208, -892708928, 410813632, 209379648, -759350208, 1053125952, -991922688, 596570944,
- 759350208, -1053125952, 991922688, -892708928, 759350208, -596570944, 410813632, -209379648
-};
-
-const Word32 dct12_fx[12*12]=
-{
- 619978560, 869301376, 846752832, 810030848, 759350208, 695569984, 619978560, 533649696, 438301408, 335436960, 226989024, 114460880,
- 619978560, 810030848, 619978560, 335436960, 0, -335436960, -619978560, -810030848, -876602816, -810030848, -619978560, -335436960,
- 619978560, 695569984, 226989024, -335436960, -759350208, -869301376, -619978560, -114460880, 438301408, 810030848, 846752832, 533649696,
- 619978560, 533649696, -226989024, -810030848, -759350208, -114460880, 619978560, 869301376, 438301408, -335436960, -846752832, -695569984,
- 619978560, 335436960, -619978560, -810030848, 0, 810030848, 619978560, -335436960, -876602816, -335436960, 619978560, 810030848, 619978560,
- 114460880, -846752832, -335436960, 759350208, 533649696, -619978560, -695569984, 438301408, 810030848, -226989024, -869301376, 619978560,
- -114460880, -846752832, 335436960, 759350208, -533649696, -619978560, 695569984, 438301408, -810030848, -226989024, 869301376, 619978560,
- -335436960, -619978560, 810030848, 0, -810030848, 619978560, 335436960, -876602816, 335436960, 619978560, -810030848, 619978560, -533649696,
- -226989024, 810030848, -759350208, 114460880, 619978560, -869301376, 438301408, 335436960, -846752832, 695569984, 619978560, -695569984,
- 226989024, 335436960, -759350208, 869301376, -619978560, 114460880, 438301408, -810030848, 846752832, -533649696, 619978560, -810030848,
- 619978560, -335436960, 0, 335436960, -619978560, 810030848, -876602816, 810030848, -619978560, 335436960, 619978560, -869301376, 846752832,
- -810030848, 759350208, -695569984, 619978560, -533649696, 438301408, -335436960, 226989024, -114460880
-};
-#endif
-
/*----------------------------------------------------------------------------------*
* ISM ROM tables
*----------------------------------------------------------------------------------*/
@@ -3576,20 +3227,6 @@ const float ism_elevation_borders[4] =
ISM_ELEVATION_MIN, ISM_ELEVATION_LOW_BORDER, ISM_ELEVATION_HIGH_BORDER, ISM_ELEVATION_MAX
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 ism_azimuth_borders_fx[4] =
-{
- ISM_AZIMUTH_MIN_FX, ISM_AZIMUTH_LOW_BORDER_FX, ISM_AZIMUTH_HIGH_BORDER_FX, ISM_AZIMUTH_MAX_FX
-};
-
-const Word32 ism_elevation_borders_fx[4] =
-{
- ISM_ELEVATION_MIN_FX, ISM_ELEVATION_LOW_BORDER_FX, ISM_ELEVATION_HIGH_BORDER_FX, ISM_ELEVATION_MAX_FX
-};
-
-#endif
-
-
/*----------------------------------------------------------------------------------*
* Param ISM ROM tables
*----------------------------------------------------------------------------------*/
@@ -3703,11 +3340,6 @@ const float ivas_lfe_window_coeff_48k[IVAS_LFE_FADE_LEN_48K] =
0.999999941142332f, 0.999999966087832f, 0.999999983040042f, 0.999999993835372f
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 ivas_lfe_window_coeff_48k_fx[IVAS_LFE_FADE_LEN_48K] = { 0x0003a373, 0x000608f6, 0x000888a7, 0x000b3e1b, 0x000e34f1, 0x001174a2, 0x00150328, 0x0018e5e1, 0x001d21eb, 0x0021bc4d, 0x0026ba09, 0x002c202f, 0x0031f3dc, 0x00383a43, 0x003ef8ad, 0x0046347b, 0x004df325, 0x00563a3f, 0x005f0f74, 0x00687888, 0x00727b59, 0x007d1ddb, 0x0088661c, 0x00945a41, 0x00a10087, 0x00ae5f3d, 0x00bc7ccd, 0x00cb5fb3, 0x00db0e7d, 0x00eb8fd0, 0x00fcea61, 0x010f24f8, 0x0122466a, 0x013655a0, 0x014b598e, 0x01615936, 0x01785ba8, 0x01906800, 0x01a9855e, 0x01c3baf0, 0x01df0fee, 0x01fb8b90, 0x02193514, 0x023813c4, 0x02582ee4, 0x02798db8, 0x029c378c, 0x02c033a4, 0x02e58944, 0x030c3fa8, 0x03345e0c, 0x035deba0, 0x0388ef8c, 0x03b570f0, 0x03e376dc, 0x04130858, 0x04442c58, 0x0476e9b8, 0x04ab4760, 0x04e14c00, 0x0518fe48, 0x055264c8, 0x058d8600, 0x05ca6850, 0x06091200, 0x06498930, 0x068bd3f0, 0x06cff830, 0x0715fba8, 0x075de408, 0x07a7b6c8, 0x07f37940, 0x084130a0, 0x0890e200, 0x08e29220, 0x093645c0, 0x098c0150, 0x09e3c940, 0x0a3da180, 0x0a998e30, 0x0af792e0, 0x0b57b320, 0x0bb9f240, 0x0c1e5360, 0x0c84d940, 0x0ced8690, 0x0d585dc0, 0x0dc560f0, 0x0e349200, 0x0ea5f2b0, 0x0f198450, 0x0f8f4820, 0x10073f00, 0x10816980, 0x10fdc840, 0x117c5b00, 0x11fd21e0, 0x12801c60, 0x130549a0, 0x138ca8c0, 0x14163880, 0x14a1f740, 0x152fe320, 0x15bffa00, 0x16523980, 0x16e69ee0, 0x177d2700, 0x1815cec0, 0x18b09260, 0x194d6e00, 0x19ec5d60, 0x1a8d5c20, 0x1b306580, 0x1bd57440, 0x1c7c8300, 0x1d258c40, 0x1dd08a00, 0x1e7d7600, 0x1f2c49a0, 0x1fdcfe20, 0x208f8c40, 0x2143ed00, 0x21fa1840, 0x22b20680, 0x236baf40, 0x24270a00, 0x24e40e00, 0x25a2b280, 0x2662ee00, 0x2724b700, 0x27e80400, 0x28acca80, 0x297300c0, 0x2a3a9c00, 0x2b039180, 0x2bcdd680, 0x2c995fc0, 0x2d6621c0, 0x2e341140, 0x2f032240, 0x2fd34900, 0x30a47900, 0x3176a640, 0x3249c440, 0x331dc600, 0x33f29f40, 0x34c842c0, 0x359ea340, 0x3675b3c0, 0x374d66c0, 0x3825af00, 0x38fe7ec0, 0x39d7c880, 0x3ab17e40, 0x3b8b9240, 0x3c65f6c0, 0x3d409d80, 0x3e1b7880, 0x3ef679c0, 0x3fd19340, 0x40acb680, 0x4187d580, 0x4262e280, 0x433dce80, 0x44188c00, 0x44f30c80, 0x45cd4180, 0x46a71e00, 0x47809300, 0x48599300, 0x49320f80, 0x4a09fb80, 0x4ae14880, 0x4bb7e900, 0x4c8dcf80, 0x4d62ee80, 0x4e373880, 0x4f0aa080, 0x4fdd1900, 0x50ae9600, 0x517f0980, 0x524e6780, 0x531ca380, 0x53e9b100, 0x54b58400, 0x55801080, 0x56494b00, 0x57112800, 0x57d79c00, 0x589c9c00, 0x59601d00, 0x5a221480, 0x5ae27880, 0x5ba13e00, 0x5c5e5c00, 0x5d19c880, 0x5dd37a80, 0x5e8b6800, 0x5f418980, 0x5ff5d580, 0x60a84480, 0x6158ce00, 0x62076a80, 0x62b41280, 0x635ebf80, 0x64076a80, 0x64ae0d00, 0x6552a100, 0x65f52080, 0x66958680, 0x6733cd00, 0x67cff000, 0x6869ea80, 0x6901b880, 0x69975600, 0x6a2abf80, 0x6abbf200, 0x6b4aea80, 0x6bd7a680, 0x6c622300, 0x6cea5f80, 0x6d705900, 0x6df40f00, 0x6e758080, 0x6ef4ac80, 0x6f719300, 0x6fec3380, 0x70648f00, 0x70daa580, 0x714e7880, 0x71c00880, 0x722f5780, 0x729c6700, 0x73073980, 0x736fd100, 0x73d62f80, 0x743a5900, 0x749c5080, 0x74fc1880, 0x7559b600, 0x75b52b80, 0x760e7e80, 0x7665b280, 0x76bacc80, 0x770dd180, 0x775ec600, 0x77adb000, 0x77fa9480, 0x78457900, 0x788e6400, 0x78d55b80, 0x791a6500, 0x795d8780, 0x799ec900, 0x79de3100, 0x7a1bc580, 0x7a578d80, 0x7a919100, 0x7ac9d600, 0x7b006500, 0x7b354400, 0x7b687b80, 0x7b9a1300, 0x7bca1180, 0x7bf87f80, 0x7c256400, 0x7c50c780, 0x7c7ab180, 0x7ca32a00, 0x7cca3900, 0x7cefe600, 0x7d143900, 0x7d373a80, 0x7d58f280, 0x7d796800, 0x7d98a380, 0x7db6ad00, 0x7dd38c80, 0x7def4900, 0x7e09eb00, 0x7e237a00, 0x7e3bfd80, 0x7e537d80, 0x7e6a0180, 0x7e7f9080, 0x7e943200, 0x7ea7ed80, 0x7ebaca00, 0x7ecccf00, 0x7ede0300, 0x7eee6d00, 0x7efe1400, 0x7f0cfe80, 0x7f1b3380, 0x7f28b900, 0x7f359500, 0x7f41ce80, 0x7f4d6b80, 0x7f587180, 0x7f62e680, 0x7f6cd000, 0x7f763400, 0x7f7f1780, 0x7f878080, 0x7f8f7380, 0x7f96f580, 0x7f9e0b80, 0x7fa4bb00, 0x7fab0780, 0x7fb0f600, 0x7fb68b00, 0x7fbbca00, 0x7fc0b800, 0x7fc55880, 0x7fc9af80, 0x7fcdc080, 0x7fd18f00, 0x7fd51e80, 0x7fd87280, 0x7fdb8d80, 0x7fde7380, 0x7fe12700, 0x7fe3aa80, 0x7fe60100, 0x7fe82d00, 0x7fea3180, 0x7fec1000, 0x7fedcb00, 0x7fef6500, 0x7ff0e000, 0x7ff23e00, 0x7ff38080, 0x7ff4a980, 0x7ff5ba80, 0x7ff6b580, 0x7ff79c00, 0x7ff86e80, 0x7ff92f80, 0x7ff9e000, 0x7ffa8100, 0x7ffb1380, 0x7ffb9880, 0x7ffc1180, 0x7ffc7f80, 0x7ffce300, 0x7ffd3c80, 0x7ffd8d80, 0x7ffdd680, 0x7ffe1880, 0x7ffe5300, 0x7ffe8800, 0x7ffeb700, 0x7ffee100, 0x7fff0600, 0x7fff2700, 0x7fff4480, 0x7fff5e80, 0x7fff7500, 0x7fff8900, 0x7fff9a80, 0x7fffaa00, 0x7fffb780, 0x7fffc300, 0x7fffcd00, 0x7fffd580, 0x7fffdc80, 0x7fffe300, 0x7fffe880, 0x7fffec80, 0x7ffff080, 0x7ffff380, 0x7ffff680, 0x7ffff880, 0x7ffffa00, 0x7ffffb80, 0x7ffffc80, 0x7ffffd80, 0x7ffffe80, 0x7fffff00, 0x7fffff00, 0x7fffff80, 0x7fffff80, 0x7fffffff, 0x7fffffff };
-#endif
-
-
const float ivas_lfe_window_coeff_32k[IVAS_LFE_FADE_LEN_32K] =
{
0.000135992220705702f, 0.000243900754874608f, 0.000366502488193403f, 0.000507754555407233f,
@@ -3776,11 +3408,6 @@ const float ivas_lfe_window_coeff_32k[IVAS_LFE_FADE_LEN_32K] =
0.999999871092647f, 0.999999932837961f, 0.999999970256211f, 0.999999990753058f
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 ivas_lfe_window_coeff_32k_fx[IVAS_LFE_FADE_LEN_32K] = { 0x000474c9, 0x0007fdfd, 0x000c0272, 0x0010a35b, 0x0015f4ae, 0x001c079e, 0x0022ecc2, 0x002ab4c6, 0x003370ac, 0x003d31e5, 0x00480a5f, 0x00540c87, 0x00614b4e, 0x006fda25, 0x007fccfb, 0x0091383a, 0x00a430c2, 0x00b8cbe7, 0x00cf1f67, 0x00e74167, 0x0101486c, 0x011d4b52, 0x013b614e, 0x015ba1d8, 0x017e24ae, 0x01a301c8, 0x01ca514e, 0x01f42b90, 0x0220a900, 0x024fe224, 0x0281ef88, 0x02b6e9c0, 0x02eee954, 0x032a06b4, 0x03685a34, 0x03a9fc00, 0x03ef0408, 0x043789f8, 0x0483a538, 0x04d36cd0, 0x0526f760, 0x057e5b20, 0x05d9adc0, 0x06390470, 0x069c73c0, 0x07040fa8, 0x076feb68, 0x07e01990, 0x0854abe0, 0x08cdb350, 0x094b4000, 0x09cd6120, 0x0a5424d0, 0x0adf9870, 0x0b6fc830, 0x0c04bf20, 0x0c9e8760, 0x0d3d29c0, 0x0de0ade0, 0x0e891a50, 0x0f367440, 0x0fe8bfa0, 0x109fff00, 0x115c33a0, 0x121d5d80, 0x12e37b00, 0x13ae8960, 0x147e8440, 0x155365c0, 0x162d26c0, 0x170bbe80, 0x17ef22e0, 0x18d74820, 0x19c42100, 0x1ab59f20, 0x1babb200, 0x1ca64840, 0x1da54e80, 0x1ea8b080, 0x1fb057e0, 0x20bc2d80, 0x21cc1800, 0x22dffd40, 0x23f7c1c0, 0x25134800, 0x26327200, 0x27552000, 0x287b30c0, 0x29a48280, 0x2ad0f180, 0x2c005940, 0x2d329440, 0x2e677c00, 0x2f9ee880, 0x30d8b100, 0x3214ac40, 0x3352afc0, 0x34929040, 0x35d421c0, 0x37173780, 0x385ba480, 0x39a13b00, 0x3ae7cc40, 0x3c2f2a00, 0x3d7724c0, 0x3ebf8d80, 0x40083400, 0x4150e980, 0x42997d80, 0x43e1c000, 0x45298180, 0x46709200, 0x47b6c280, 0x48fbe380, 0x4a3fc600, 0x4b823b80, 0x4cc31600, 0x4e022800, 0x4f3f4500, 0x507a4080, 0x51b2ee80, 0x52e92580, 0x541cba80, 0x554d8580, 0x567b5e00, 0x57a61d80, 0x58cd9e00, 0x59f1bb80, 0x5b125200, 0x5c2f3f00, 0x5d486280, 0x5e5d9d00, 0x5f6ecf80, 0x607bde00, 0x6184ad00, 0x62892280, 0x63892680, 0x6484a280, 0x657b8100, 0x666daf00, 0x675b1980, 0x6843b100, 0x69276680, 0x6a062d00, 0x6adff980, 0x6bb4c180, 0x6c847d80, 0x6d4f2680, 0x6e14b800, 0x6ed52e80, 0x6f908900, 0x7046c680, 0x70f7e880, 0x71a3f300, 0x724aea00, 0x72ecd300, 0x7389b680, 0x74219c80, 0x74b48f80, 0x75429b80, 0x75cbcc80, 0x76503100, 0x76cfd800, 0x774ad280, 0x77c13180, 0x78330780, 0x78a06880, 0x79096800, 0x796e1b80, 0x79ce9980, 0x7a2af880, 0x7a835000, 0x7ad7b800, 0x7b284980, 0x7b751c80, 0x7bbe4c00, 0x7c03f080, 0x7c462580, 0x7c850480, 0x7cc0a880, 0x7cf92c00, 0x7d2eaa80, 0x7d613e00, 0x7d910180, 0x7dbe0f80, 0x7de88300, 0x7e107600, 0x7e360300, 0x7e594280, 0x7e7a4f80, 0x7e994200, 0x7eb63280, 0x7ed13a00, 0x7eea6f00, 0x7f01e980, 0x7f17c000, 0x7f2c0800, 0x7f3ed780, 0x7f504280, 0x7f605d80, 0x7f6f3c00, 0x7f7cf100, 0x7f898e00, 0x7f952500, 0x7f9fc600, 0x7fa98200, 0x7fb26800, 0x7fba8680, 0x7fc1eb80, 0x7fc8a400, 0x7fcebd80, 0x7fd44380, 0x7fd94100, 0x7fddc180, 0x7fe1ce80, 0x7fe57180, 0x7fe8b400, 0x7feb9d80, 0x7fee3680, 0x7ff08600, 0x7ff29280, 0x7ff46300, 0x7ff5fc80, 0x7ff76500, 0x7ff8a180, 0x7ff9b600, 0x7ffaa780, 0x7ffb7900, 0x7ffc2e80, 0x7ffccb80, 0x7ffd5200, 0x7ffdc580, 0x7ffe2800, 0x7ffe7b80, 0x7ffec200, 0x7ffefd80, 0x7fff2f00, 0x7fff5880, 0x7fff7a80, 0x7fff9680, 0x7fffad80, 0x7fffc000, 0x7fffcf00, 0x7fffdb00, 0x7fffe480, 0x7fffeb80, 0x7ffff180, 0x7ffff580, 0x7ffff900, 0x7ffffb00, 0x7ffffd00, 0x7ffffe00, 0x7fffff00, 0x7fffff80, 0x7fffffff, 0x7fffffff };
-#endif
-
-
const float ivas_lfe_window_coeff_16k[IVAS_LFE_FADE_LEN_16K] =
{
0.000192322041967661f, 0.000432042541451336f, 0.000754275578824202f, 0.00117365342860051f,
@@ -3817,11 +3444,6 @@ const float ivas_lfe_window_coeff_16k[IVAS_LFE_FADE_LEN_16K] =
0.999999311268578f, 0.999999715534135f, 0.999999906669617f, 0.999999981506116f
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 ivas_lfe_window_coeff_16k_fx[IVAS_LFE_FADE_LEN_16K] = { 0x00064d50, 0x000e283c, 0x0018b753, 0x00267552, 0x0037e397, 0x004d8c2b, 0x006801d2, 0x0087dfb9, 0x00adc8fc, 0x00da680b, 0x010e6df8, 0x014a91a0, 0x018f8ecc, 0x01de252a, 0x02371734, 0x029b2908, 0x030b1f1c, 0x0387bd00, 0x0411c3e8, 0x04a9f148, 0x0550fd60, 0x060799b0, 0x06ce6f88, 0x07a61e78, 0x088f3ad0, 0x098a4c30, 0x0a97cc00, 0x0bb82430, 0x0cebadd0, 0x0e32afe0, 0x0f8d5df0, 0x10fbd760, 0x127e2680, 0x14143f40, 0x15bdff00, 0x177b2bc0, 0x194b7440, 0x1b2e6f00, 0x1d239ae0, 0x1f2a5ee0, 0x21420ac0, 0x2369d700, 0x25a0e640, 0x27e64500, 0x2a38ebc0, 0x2c97bfc0, 0x2f019400, 0x31752b00, 0x33f13800, 0x36746180, 0x38fd42c0, 0x3b8a6cc0, 0x3e1a6a80, 0x40abc080, 0x433cf080, 0x45cc7c80, 0x4858e600, 0x4ae0b400, 0x4d627280, 0x4fdcb500, 0x524e1b00, 0x54b54e80, 0x57110880, 0x59601300, 0x5ba14800, 0x5dd39780, 0x5ff60500, 0x6207aa80, 0x6407ba80, 0x65f57e80, 0x67d05b00, 0x6997cc80, 0x6b4b6b00, 0x6ceae880, 0x6e761080, 0x6fecc980, 0x714f1280, 0x729d0480, 0x73d6ce80, 0x74fcb800, 0x760f1d80, 0x770e6e80, 0x77fb2f00, 0x78d5f280, 0x799f5b80, 0x7a581b80, 0x7b00ec80, 0x7b9a9480, 0x7c25df80, 0x7ca39e80, 0x7d14a680, 0x7d79ce00, 0x7dd3eb00, 0x7e23d180, 0x7e6a5180, 0x7ea83680, 0x7ede4580, 0x7f0d3a80, 0x7f35cb00, 0x7f58a180, 0x7f765e80, 0x7f8f9880, 0x7fa4db80, 0x7fb6a700, 0x7fc57100, 0x7fd1a400, 0x7fdb9f80, 0x7fe3b980, 0x7fea3e00, 0x7fef6f80, 0x7ff38900, 0x7ff6bc80, 0x7ff93500, 0x7ffb1780, 0x7ffc8300, 0x7ffd9080, 0x7ffe5500, 0x7ffee280, 0x7fff4580, 0x7fff8a00, 0x7fffb800, 0x7fffd580, 0x7fffe880, 0x7ffff400, 0x7ffffa00, 0x7ffffd80, 0x7fffff00, 0x7fffffff };
-#endif
-
-
const float ivas_lpf_4_butter_16k_sos[IVAS_BIQUAD_FILT_LEN << 2] =
{
3.97464794223146e-07f, 7.94929601777927e-07f, 3.97464788468481e-07f, 1.f,
@@ -3829,16 +3451,6 @@ const float ivas_lpf_4_butter_16k_sos[IVAS_BIQUAD_FILT_LEN << 2] =
1.00000001447843f, 1.f, -1.95913666348268f, 0.961692382252710f
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 ivas_lpf_4_butter_16k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2] =
-{
- 0x1ab, 0x356, 0x1ab, 0x40000000,
- 0x85ec0b80, 0x3a3cb940, 0x40000000, 0x7fffffff,
- 0x40000000, 0x40000000, 0x829d8180, 0x3d8c5e40
-};
-#endif
-
-
const float ivas_lpf_4_butter_32k_sos[IVAS_BIQUAD_FILT_LEN << 2] =
{
2.56674586654460e-08f, 5.13349181918215e-08f, 2.56674582938215e-08f, 1,
@@ -3846,16 +3458,6 @@ const float ivas_lpf_4_butter_32k_sos[IVAS_BIQUAD_FILT_LEN << 2] =
1.00000001447843f, 1, -1.98000953138860f, 0.980654742275836f
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 ivas_lpf_4_butter_32k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2] =
-{
- 0x1c, 0x37, 0x1c, 0x40000000,
- 0x82fd4b80, 0x3d0d2280, 0x40000000, 0x7fffffff,
- 0x40000000, 0x40000000, 0x81478600, 0x3ec30c00
-};
-#endif
-
-
const float ivas_lpf_4_butter_48k_sos[IVAS_BIQUAD_FILT_LEN << 2] =
{
5.12617881476274e-09f, 1.02523584294987e-08f, 5.12617879059970e-09f,
@@ -3863,55 +3465,21 @@ const float ivas_lpf_4_butter_48k_sos[IVAS_BIQUAD_FILT_LEN << 2] =
1.00000000471366f, 1.f , -1.98677297369091f, 0.987060670205863f
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 ivas_lpf_4_butter_48k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2] =
-{
- 0x6, 0xb, 0x6, 0x40000000,
- 0x81ffd700, 0x3e04d500, 0x40000000, 0x7fffff80,
- 0x40000000, 0x40000000, 0x80d8b600, 0x3f2c0080
-};
-#endif
-
-
const float ivas_lpf_2_butter_16k[IVAS_BIQUAD_FILT_LEN << 1] =
{
0.000628720643081143f, 0.00125744128616229f, 0.000628720643081143f, 1.f, -1.92783286977036f, 0.930347752342683f
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 ivas_lpf_2_butter_16k_fx[IVAS_BIQUAD_FILT_LEN << 1] =
-{
- 0xa4d0c, 0x149a17, 0xa4d0c, 0x40000000, 0x849e6300, 0x3b8ad140
-};
-#endif
-
-
const float ivas_lpf_2_butter_32k[IVAS_BIQUAD_FILT_LEN << 1] =
{
0.000159990787823749f, 0.000319981575647499f, 0.000159990787823749f, 1.f, -1.96390539174033f, 0.964545354891623f
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 ivas_lpf_2_butter_32k_fx[IVAS_BIQUAD_FILT_LEN << 1] =
-{
- 0x53e1a, 0x29f0d, 0x40000000, 0x824f6000, 0x3dbb1c80, 0x29f0d
-};
-#endif
-
-
const float ivas_lpf_2_butter_48k[IVAS_BIQUAD_FILT_LEN << 1] =
{
7.15317998432330e-05f, 0.000143063599686466f, 7.15317998432330e-05f, 1.f, -1.97593552482925f, 0.976221652028620f
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 ivas_lpf_2_butter_48k_fx[IVAS_BIQUAD_FILT_LEN << 1] =
-{
- 0x12c07, 0x2580d, 0x12c07, 0x40000000, 0x818a4580, 0x3e7a6a80
-};
-#endif
-
-
const ivas_lfe_freq_models ivas_str_lfe_freq_models =
{
{ 16384, 14924, 13463, 12003, 10542, 9082, 7622, 6161,
@@ -3963,26 +3531,6 @@ const int16_t ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP] = { 1, 0 };
const float ivas_lfe_lpf_delay[2] = { 0.00175f, 0.0035f };
const Word16 ivas_lfe_lpf_delay_Q15[2] = { 57, 114 };
-#ifdef IVAS_FLOAT_FIXED
-//Q31
-const UWord32 d_hamm_lfe_plc_fx[LFE_PLC_LENANA / 2] = {
- 171798691, 172140039, 173163845, 174869403, 177255533, 180320587, 184062447, 188478526,
- 193565772, 199320670, 205739242, 212817053, 220549212, 228930373, 237954746, 247616094,
- 257907739, 268822570, 280353042, 292491188, 305228618, 318556530, 332465713, 346946555,
- 361989047, 377582794, 393717019, 410380572, 427561937, 445249239, 463430255, 482092421,
- 501222838, 520808286, 540835229, 561289828, 582157945, 603425159, 625076772, 647097821,
- 669473086, 692187106, 715224182, 738568392, 762203605, 786113486, 810281510, 834690976,
- 859325014, 884166600, 909198565, 934403610, 959764316, 985263157, 1010882509, 1036604668,
- 1062411858, 1088286242, 1114209939, 1140165034, 1166133589, 1192097656, 1218039293, 1243940572,
- 1269783591, 1295550491, 1321223465, 1346784770, 1372216740, 1397501800, 1422622476, 1447561406,
- 1472301355, 1496825225, 1521116069, 1545157098, 1568931699, 1592423440, 1615616087, 1638493611,
- 1661040202, 1683240277, 1705078494, 1726539762, 1747609248, 1768272390, 1788514910, 1808322817,
- 1827682422, 1846580346, 1865003529, 1882939237, 1900375077, 1917298998, 1933699304, 1949564660,
- 1964884103, 1979647046, 1993843284, 2007463009, 2020496806, 2032935668, 2044771000, 2055994621,
- 2066598775, 2076576133, 2085919801, 2094623320, 2102680676, 2110086301, 2116835076, 2122922337,
- 2128343877, 2133095950, 2137175272, 2140579023, 2143304850, 2145350871, 2146715671, 2147398307
-};
-#else
const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2] =
{
0.08000000000000002, 0.08015895227847719, 0.08063569926248770, 0.08142991147368656, 0.08254104003450596, 0.08396831704748331, 0.08571075612595230, 0.08776715307573196,
@@ -4001,7 +3549,6 @@ const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2] =
0.96233504613317988, 0.96698111571154954, 0.97133209998031445, 0.97538499198789563, 0.97913699079334116, 0.98258550340204664, 0.98572814655776630, 0.98856274838967395,
0.99108734991333569, 0.99330020638455863, 0.99519978850517732, 0.99678478347994692, 0.99805409592381300, 0.99900684861892730, 0.99964238312089115, 0.99996026021380402
};
-#endif
/*------------------------------------------------------------------------------------------*
* MDFT/iMDFT ROM tables
@@ -4605,687 +4152,7 @@ const float ivas_mdft_coeff_cos_twid_40[IVAS_40_PT_LEN + 1] =
0.3826834324f, 0.3461170571f, 0.3090169944f, 0.2714404499f, 0.2334453639f, 0.1950903220f,
0.1564344650f, 0.1175373975f, 0.0784590957f, 0.0392598158f, 0.000000000f
};
-#ifdef IVAS_FLOAT_FIXED
- const Word32 ivas_mdft_coeff_cos_twid_960_fx[IVAS_960_PT_LEN + 1] =
-{
- 2147483647 ,
- 2147480832 ,2147472128 ,2147457792 ,2147437696 ,
- 2147411840 ,2147380096 ,2147342848 ,2147299712 ,
- 2147250816 ,2147196160 ,2147135872 ,2147069696 ,
- 2146997888 ,2146920192 ,2146836864 ,2146747776 ,
- 2146652928 ,2146552320 ,2146445952 ,2146333824 ,
- 2146216064 ,2146092416 ,2145963136 ,2145827968 ,
- 2145687168 ,2145540608 ,2145388288 ,2145230208 ,
- 2145066496 ,2144896896 ,2144721664 ,2144540544 ,
- 2144353792 ,2144161280 ,2143963008 ,2143759104 ,
- 2143549312 ,2143333888 ,2143112704 ,2142885760 ,
- 2142653056 ,2142414592 ,2142170496 ,2141920512 ,
- 2141664896 ,2141403648 ,2141136512 ,2140863616 ,
- 2140585088 ,2140300800 ,2140010752 ,2139715072 ,
- 2139413632 ,2139106432 ,2138793472 ,2138474752 ,
- 2138150400 ,2137820288 ,2137484544 ,2137142912 ,
- 2136795648 ,2136442624 ,2136083968 ,2135719552 ,
- 2135349376 ,2134973440 ,2134591872 ,2134204544 ,
- 2133811584 ,2133412864 ,2133008384 ,2132598272 ,
- 2132182400 ,2131760896 ,2131333632 ,2130900608 ,
- 2130461952 ,2130017536 ,2129567360 ,2129111680 ,
- 2128650112 ,2128182912 ,2127710080 ,2127231488 ,
- 2126747136 ,2126257152 ,2125761536 ,2125260160 ,
- 2124753152 ,2124240384 ,2123721984 ,2123197824 ,
- 2122668032 ,2122132608 ,2121591424 ,2121044608 ,
- 2120492032 ,2119933824 ,2119369984 ,2118800384 ,
- 2118225152 ,2117644288 ,2117057792 ,2116465536 ,
- 2115867648 ,2115264128 ,2114654848 ,2114039936 ,
- 2113419392 ,2112793216 ,2112161408 ,2111523840 ,
- 2110880640 ,2110231808 ,2109577344 ,2108917248 ,
- 2108251520 ,2107580032 ,2106903040 ,2106220288 ,
- 2105532032 ,2104838016 ,2104138496 ,2103433216 ,
- 2102722304 ,2102005888 ,2101283712 ,2100556032 ,
- 2099822592 ,2099083648 ,2098338944 ,2097588736 ,
- 2096832896 ,2096071424 ,2095304320 ,2094531712 ,
- 2093753344 ,2092969472 ,2092179968 ,2091384832 ,
- 2090584192 ,2089777920 ,2088966016 ,2088148480 ,
- 2087325440 ,2086496768 ,2085662464 ,2084822656 ,
- 2083977216 ,2083126272 ,2082269696 ,2081407488 ,
- 2080539776 ,2079666560 ,2078787712 ,2077903232 ,
- 2077013248 ,2076117632 ,2075216640 ,2074309888 ,
- 2073397760 ,2072479872 ,2071556608 ,2070627712 ,
- 2069693312 ,2068753408 ,2067807872 ,2066856832 ,
- 2065900288 ,2064938240 ,2063970560 ,2062997504 ,
- 2062018816 ,2061034624 ,2060044928 ,2059049728 ,
- 2058049024 ,2057042688 ,2056030976 ,2055013760 ,
- 2053990912 ,2052962688 ,2051928960 ,2050889728 ,
- 2049844992 ,2048794752 ,2047739008 ,2046677888 ,
- 2045611136 ,2044539008 ,2043461376 ,2042378368 ,
- 2041289728 ,2040195712 ,2039096192 ,2037991296 ,
- 2036880896 ,2035764992 ,2034643712 ,2033516928 ,
- 2032384768 ,2031247104 ,2030104064 ,2028955520 ,
- 2027801600 ,2026642176 ,2025477376 ,2024307200 ,
- 2023131520 ,2021950464 ,2020764032 ,2019572096 ,
- 2018374784 ,2017172096 ,2015964032 ,2014750592 ,
- 2013531648 ,2012307328 ,2011077760 ,2009842688 ,
- 2008602240 ,2007356416 ,2006105216 ,2004848640 ,
- 2003586816 ,2002319488 ,2001046912 ,1999768832 ,
- 1998485504 ,1997196800 ,1995902720 ,1994603264 ,
- 1993298560 ,1991988480 ,1990673152 ,1989352320 ,
- 1988026240 ,1986694912 ,1985358208 ,1984016128 ,
- 1982668800 ,1981316224 ,1979958272 ,1978595072 ,
- 1977226496 ,1975852672 ,1974473472 ,1973089152 ,
- 1971699456 ,1970304384 ,1968904192 ,1967498624 ,
- 1966087808 ,1964671872 ,1963250560 ,1961823872 ,
- 1960392064 ,1958955008 ,1957512704 ,1956065152 ,
- 1954612352 ,1953154304 ,1951691136 ,1950222592 ,
- 1948748928 ,1947270016 ,1945785856 ,1944296576 ,
- 1942801920 ,1941302272 ,1939797248 ,1938287104 ,
- 1936771840 ,1935251328 ,1933725568 ,1932194688 ,
- 1930658688 ,1929117440 ,1927571072 ,1926019584 ,
- 1924462848 ,1922900992 ,1921334016 ,1919761920 ,
- 1918184576 ,1916602112 ,1915014656 ,1913421952 ,
- 1911824128 ,1910221184 ,1908613248 ,1907000064 ,
- 1905381760 ,1903758464 ,1902130048 ,1900496512 ,
- 1898857856 ,1897214208 ,1895565312 ,1893911552 ,
- 1892252544 ,1890588544 ,1888919552 ,1887245440 ,
- 1885566208 ,1883881984 ,1882192768 ,1880498432 ,
- 1878799104 ,1877094656 ,1875385344 ,1873670912 ,
- 1871951488 ,1870227072 ,1868497536 ,1866763136 ,
- 1865023744 ,1863279232 ,1861529856 ,1859775360 ,
- 1858016000 ,1856251648 ,1854482304 ,1852707968 ,
- 1850928768 ,1849144448 ,1847355392 ,1845561216 ,
- 1843762176 ,1841958144 ,1840149248 ,1838335360 ,
- 1836516608 ,1834692864 ,1832864384 ,1831030784 ,
- 1829192448 ,1827349120 ,1825500928 ,1823647744 ,
- 1821789824 ,1819927040 ,1818059264 ,1816186624 ,
- 1814309248 ,1812426880 ,1810539776 ,1808647680 ,
- 1806750848 ,1804849152 ,1802942720 ,1801031296 ,
- 1799115136 ,1797194112 ,1795268352 ,1793337728 ,
- 1791402368 ,1789462144 ,1787517184 ,1785567360 ,
- 1783612800 ,1781653504 ,1779689344 ,1777720576 ,
- 1775746944 ,1773768576 ,1771785344 ,1769797504 ,
- 1767804928 ,1765807616 ,1763805440 ,1761798656 ,
- 1759787136 ,1757771008 ,1755750016 ,1753724416 ,
- 1751694080 ,1749659008 ,1747619328 ,1745574912 ,
- 1743525888 ,1741472128 ,1739413760 ,1737350784 ,
- 1735283072 ,1733210752 ,1731133696 ,1729052160 ,
- 1726965888 ,1724875008 ,1722779520 ,1720679424 ,
- 1718574720 ,1716465408 ,1714351616 ,1712233088 ,
- 1710109952 ,1707982336 ,1705850112 ,1703713280 ,
- 1701571968 ,1699426048 ,1697275648 ,1695120640 ,
- 1692961024 ,1690796928 ,1688628352 ,1686455296 ,
- 1684277632 ,1682095488 ,1679908864 ,1677717632 ,
- 1675522048 ,1673321984 ,1671117312 ,1668908288 ,
- 1666694656 ,1664476672 ,1662254208 ,1660027264 ,
- 1657795968 ,1655560192 ,1653319936 ,1651075200 ,
- 1648826240 ,1646572672 ,1644314752 ,1642052480 ,
- 1639785728 ,1637514752 ,1635239168 ,1632959360 ,
- 1630675200 ,1628386560 ,1626093568 ,1623796352 ,
- 1621494656 ,1619188736 ,1616878336 ,1614563712 ,
- 1612244736 ,1609921408 ,1607593856 ,1605261952 ,
- 1602925696 ,1600585216 ,1598240384 ,1595891328 ,
- 1593538048 ,1591180416 ,1588818560 ,1586452480 ,
- 1584082048 ,1581707520 ,1579328640 ,1576945536 ,
- 1574558336 ,1572166784 ,1569771136 ,1567371136 ,
- 1564967040 ,1562558720 ,1560146304 ,1557729664 ,
- 1555308800 ,1552883712 ,1550454656 ,1548021248 ,
- 1545583872 ,1543142272 ,1540696576 ,1538246656 ,
- 1535792768 ,1533334656 ,1530872448 ,1528406272 ,
- 1525935872 ,1523461376 ,1520982912 ,1518500224 ,
- 1516013568 ,1513522816 ,1511028096 ,1508529280 ,
- 1506026368 ,1503519488 ,1501008512 ,1498493568 ,
- 1495974656 ,1493451648 ,1490924672 ,1488393728 ,
- 1485858816 ,1483319936 ,1480777088 ,1478230144 ,
- 1475679360 ,1473124608 ,1470565888 ,1468003328 ,
- 1465436672 ,1462866176 ,1460291840 ,1457713536 ,
- 1455131264 ,1452545152 ,1449955200 ,1447361280 ,
- 1444763520 ,1442161920 ,1439556352 ,1436947072 ,
- 1434333824 ,1431716864 ,1429095936 ,1426471296 ,
- 1423842688 ,1421210368 ,1418574336 ,1415934336 ,
- 1413290624 ,1410643200 ,1407991808 ,1405336832 ,
- 1402678016 ,1400015488 ,1397349120 ,1394679040 ,
- 1392005248 ,1389327744 ,1386646528 ,1383961600 ,
- 1381272960 ,1378580608 ,1375884544 ,1373184768 ,
- 1370481408 ,1367774336 ,1365063552 ,1362349184 ,
- 1359631232 ,1356909440 ,1354184192 ,1351455232 ,
- 1348722688 ,1345986560 ,1343246720 ,1340503424 ,
- 1337756416 ,1335005952 ,1332251776 ,1329494144 ,
- 1326732928 ,1323968128 ,1321199744 ,1318427904 ,
- 1315652480 ,1312873600 ,1310091136 ,1307305216 ,
- 1304515712 ,1301722880 ,1298926464 ,1296126464 ,
- 1293323136 ,1290516352 ,1287705984 ,1284892288 ,
- 1282075136 ,1279254528 ,1276430464 ,1273603072 ,
- 1270772224 ,1267937920 ,1265100288 ,1262259200 ,
- 1259414784 ,1256567040 ,1253715840 ,1250861312 ,
- 1248003456 ,1245142272 ,1242277760 ,1239409920 ,
- 1236538624 ,1233664128 ,1230786432 ,1227905280 ,
- 1225020928 ,1222133248 ,1219242368 ,1216348160 ,
- 1213450624 ,1210550016 ,1207646080 ,1204738816 ,
- 1201828480 ,1198914816 ,1195998080 ,1193078016 ,
- 1190154752 ,1187228416 ,1184298752 ,1181366016 ,
- 1178430080 ,1175491072 ,1172548736 ,1169603456 ,
- 1166654976 ,1163703296 ,1160748544 ,1157790720 ,
- 1154829824 ,1151865728 ,1148898688 ,1145928448 ,
- 1142955136 ,1139978880 ,1136999552 ,1134017024 ,
- 1131031680 ,1128043136 ,1125051648 ,1122057088 ,
- 1119059584 ,1116059136 ,1113055616 ,1110049152 ,
- 1107039616 ,1104027264 ,1101011840 ,1097993600 ,
- 1094972288 ,1091948032 ,1088920960 ,1085890944 ,
- 1082857984 ,1079822208 ,1076783488 ,1073741824 ,
- 1070697344 ,1067649984 ,1064599744 ,1061546688 ,
- 1058490816 ,1055432064 ,1052370496 ,1049306112 ,
- 1046238912 ,1043168960 ,1040096192 ,1037020608 ,
- 1033942272 ,1030861120 ,1027777280 ,1024690624 ,
- 1021601280 ,1018509184 ,1015414336 ,1012316800 ,
- 1009216512 ,1006113536 ,1003007936 ,999899584 ,
- 996788544 ,993674880 ,990558528 ,987439552 ,
- 984317888 ,981193600 ,978066688 ,974937152 ,
- 971805056 ,968670336 ,965532992 ,962393088 ,
- 959250560 ,956105536 ,952957888 ,949807744 ,
- 946655040 ,943499776 ,940342016 ,937181696 ,
- 934018880 ,930853632 ,927685824 ,924515520 ,
- 921342784 ,918167552 ,914989888 ,911809792 ,
- 908627200 ,905442176 ,902254784 ,899064960 ,
- 895872704 ,892678080 ,889481024 ,886281600 ,
- 883079808 ,879875648 ,876669120 ,873460288 ,
- 870249088 ,867035584 ,863819712 ,860601536 ,
- 857381120 ,854158336 ,850933312 ,847705984 ,
- 844476352 ,841244544 ,838010432 ,834774080 ,
- 831535488 ,828294656 ,825051648 ,821806400 ,
- 818558976 ,815309376 ,812057536 ,808803520 ,
- 805547392 ,802289088 ,799028608 ,795766016 ,
- 792501312 ,789234496 ,785965504 ,782694464 ,
- 779421248 ,776146048 ,772868736 ,769589312 ,
- 766307840 ,763024320 ,759738816 ,756451200 ,
- 753161600 ,749870016 ,746576320 ,743280704 ,
- 739983104 ,736683520 ,733381952 ,730078400 ,
- 726772864 ,723465472 ,720156096 ,716844800 ,
- 713531520 ,710216384 ,706899392 ,703580480 ,
- 700259648 ,696936960 ,693612416 ,690286016 ,
- 686957760 ,683627648 ,680295744 ,676961984 ,
- 673626432 ,670289024 ,666949888 ,663608960 ,
- 660266240 ,656921728 ,653575488 ,650227520 ,
- 646877760 ,643526272 ,640173120 ,636818176 ,
- 633461568 ,630103296 ,626743296 ,623381568 ,
- 620018240 ,616653248 ,613286592 ,609918336 ,
- 606548352 ,603176832 ,599803648 ,596428864 ,
- 593052544 ,589674560 ,586295040 ,582913920 ,
- 579531264 ,576147072 ,572761280 ,569374016 ,
- 565985152 ,562594816 ,559203008 ,555809664 ,
- 552414848 ,549018560 ,545620736 ,542221504 ,
- 538820864 ,535418720 ,532015168 ,528610176 ,
- 525203776 ,521795968 ,518386752 ,514976160 ,
- 511564192 ,508150848 ,504736160 ,501320096 ,
- 497902720 ,494483968 ,491063936 ,487642560 ,
- 484219904 ,480795936 ,477370656 ,473944128 ,
- 470516320 ,467087264 ,463656960 ,460225408 ,
- 456792608 ,453358592 ,449923392 ,446486944 ,
- 443049344 ,439610528 ,436170528 ,432729376 ,
- 429287072 ,425843616 ,422399008 ,418953280 ,
- 415506432 ,412058464 ,408609376 ,405159232 ,
- 401707968 ,398255648 ,394802272 ,391347808 ,
- 387892320 ,384435776 ,380978208 ,377519648 ,
- 374060032 ,370599456 ,367137856 ,363675296 ,
- 360211744 ,356747232 ,353281760 ,349815360 ,
- 346348032 ,342879744 ,339410560 ,335940448 ,
- 332469472 ,328997568 ,325524800 ,322051168 ,
- 318576640 ,315101280 ,311625088 ,308148064 ,
- 304670208 ,301191520 ,297712032 ,294231776 ,
- 290750688 ,287268864 ,283786240 ,280302848 ,
- 276818752 ,273333888 ,269848288 ,266361952 ,
- 262874928 ,259387184 ,255898752 ,252409632 ,
- 248919840 ,245429392 ,241938272 ,238446512 ,
- 234954112 ,231461072 ,227967424 ,224473168 ,
- 220978304 ,217482848 ,213986816 ,210490208 ,
- 206993040 ,203495312 ,199997040 ,196498224 ,
- 192998896 ,189499040 ,185998688 ,182497840 ,
- 178996496 ,175494672 ,171992384 ,168489632 ,
- 164986416 ,161482768 ,157978704 ,154474192 ,
- 150969280 ,147463968 ,143958256 ,140452144 ,
- 136945680 ,133438832 ,129931632 ,126424088 ,
- 122916200 ,119407992 ,115899456 ,112390608 ,
- 108881464 ,105372032 ,101862312 ,98352320 ,
- 94842064 ,91331552 ,87820800 ,84309816 ,
- 80798600 ,77287168 ,73775528 ,70263696 ,
- 66751672 ,63239472 ,59727100 ,56214568 ,
- 52701888 ,49189064 ,45676112 ,42163032 ,
- 38649844 ,35136552 ,31623164 ,28109692 ,
- 24596146 ,21082532 ,17568864 ,14055147 ,
- 10541393 ,7027612 ,3513810 ,0 ,
-};
-
- const Word32 ivas_mdft_coeff_cos_twid_640_fx[IVAS_640_PT_LEN + 1] =
-{
- 2147483647 ,
- 2147477120 ,2147457792 ,2147425408 ,2147380096 ,
- 2147321984 ,2147250816 ,2147166720 ,2147069696 ,
- 2146959744 ,2146836864 ,2146701056 ,2146552320 ,
- 2146390656 ,2146216064 ,2146028416 ,2145827968 ,
- 2145614592 ,2145388288 ,2145149056 ,2144896896 ,
- 2144631808 ,2144353792 ,2144062848 ,2143759104 ,
- 2143442304 ,2143112704 ,2142770048 ,2142414592 ,
- 2142046208 ,2141664896 ,2141270784 ,2140863616 ,
- 2140443648 ,2140010752 ,2139565056 ,2139106432 ,
- 2138634880 ,2138150400 ,2137653120 ,2137142912 ,
- 2136619904 ,2136083968 ,2135535104 ,2134973440 ,
- 2134398976 ,2133811584 ,2133211392 ,2132598272 ,
- 2131972352 ,2131333632 ,2130681984 ,2130017536 ,
- 2129340288 ,2128650112 ,2127947264 ,2127231488 ,
- 2126502912 ,2125761536 ,2125007360 ,2124240384 ,
- 2123460608 ,2122668032 ,2121862656 ,2121044608 ,
- 2120213632 ,2119369984 ,2118513536 ,2117644288 ,
- 2116762368 ,2115867648 ,2114960128 ,2114039936 ,
- 2113107072 ,2112161408 ,2111202944 ,2110231808 ,
- 2109248000 ,2108251520 ,2107242240 ,2106220288 ,
- 2105185792 ,2104138496 ,2103078528 ,2102005888 ,
- 2100920576 ,2099822592 ,2098712064 ,2097588736 ,
- 2096452864 ,2095304320 ,2094143232 ,2092969472 ,
- 2091783168 ,2090584192 ,2089372672 ,2088148480 ,
- 2086911744 ,2085662464 ,2084400640 ,2083126272 ,
- 2081839360 ,2080539776 ,2079227776 ,2077903232 ,
- 2076566144 ,2075216640 ,2073854464 ,2072479872 ,
- 2071092864 ,2069693312 ,2068281344 ,2066856832 ,
- 2065420032 ,2063970560 ,2062508800 ,2061034624 ,
- 2059548032 ,2058049024 ,2056537600 ,2055013760 ,
- 2053477504 ,2051928960 ,2050368000 ,2048794752 ,
- 2047209088 ,2045611136 ,2044000896 ,2042378368 ,
- 2040743424 ,2039096192 ,2037436800 ,2035764992 ,
- 2034081024 ,2032384768 ,2030676224 ,2028955520 ,
- 2027222528 ,2025477376 ,2023720064 ,2021950464 ,
- 2020168704 ,2018374784 ,2016568704 ,2014750592 ,
- 2012920192 ,2011077760 ,2009223168 ,2007356416 ,
- 2005477632 ,2003586816 ,2001683840 ,1999768832 ,
- 1997841792 ,1995902720 ,1993951616 ,1991988480 ,
- 1990013440 ,1988026240 ,1986027264 ,1984016128 ,
- 1981993216 ,1979958272 ,1977911424 ,1975852672 ,
- 1973782016 ,1971699456 ,1969604992 ,1967498624 ,
- 1965380480 ,1963250560 ,1961108736 ,1958955008 ,
- 1956789632 ,1954612352 ,1952423424 ,1950222592 ,
- 1948010112 ,1945785856 ,1943549952 ,1941302272 ,
- 1939042816 ,1936771840 ,1934489088 ,1932194688 ,
- 1929888768 ,1927571072 ,1925241856 ,1922900992 ,
- 1920548608 ,1918184576 ,1915809024 ,1913421952 ,
- 1911023360 ,1908613248 ,1906191616 ,1903758464 ,
- 1901313920 ,1898857856 ,1896390400 ,1893911552 ,
- 1891421184 ,1888919552 ,1886406400 ,1883881984 ,
- 1881346176 ,1878799104 ,1876240640 ,1873670912 ,
- 1871089920 ,1868497536 ,1865894016 ,1863279232 ,
- 1860653184 ,1858016000 ,1855367552 ,1852707968 ,
- 1850037248 ,1847355392 ,1844662272 ,1841958144 ,
- 1839242880 ,1836516608 ,1833779200 ,1831030784 ,
- 1828271360 ,1825500928 ,1822719360 ,1819927040 ,
- 1817123584 ,1814309248 ,1811483904 ,1808647680 ,
- 1805800704 ,1802942720 ,1800073856 ,1797194112 ,
- 1794303616 ,1791402368 ,1788490240 ,1785567360 ,
- 1782633728 ,1779689344 ,1776734336 ,1773768576 ,
- 1770792064 ,1767804928 ,1764807168 ,1761798656 ,
- 1758779648 ,1755750016 ,1752709760 ,1749659008 ,
- 1746597760 ,1743525888 ,1740443520 ,1737350784 ,
- 1734247424 ,1731133696 ,1728009600 ,1724875008 ,
- 1721730048 ,1718574720 ,1715409024 ,1712233088 ,
- 1709046784 ,1705850112 ,1702643200 ,1699426048 ,
- 1696198656 ,1692961024 ,1689713280 ,1686455296 ,
- 1683187072 ,1679908864 ,1676620416 ,1673321984 ,
- 1670013312 ,1666694656 ,1663366016 ,1660027264 ,
- 1656678656 ,1653319936 ,1649951232 ,1646572672 ,
- 1643184128 ,1639785728 ,1636377472 ,1632959360 ,
- 1629531392 ,1626093568 ,1622646016 ,1619188736 ,
- 1615721600 ,1612244736 ,1608758144 ,1605261952 ,
- 1601756032 ,1598240384 ,1594715264 ,1591180416 ,
- 1587636096 ,1584082048 ,1580518656 ,1576945536 ,
- 1573363072 ,1569771136 ,1566169600 ,1562558720 ,
- 1558938496 ,1555308800 ,1551669760 ,1548021248 ,
- 1544363648 ,1540696576 ,1537020288 ,1533334656 ,
- 1529639808 ,1525935872 ,1522222592 ,1518500224 ,
- 1514768768 ,1511028096 ,1507278336 ,1503519488 ,
- 1499751552 ,1495974656 ,1492188672 ,1488393728 ,
- 1484589824 ,1480777088 ,1476955264 ,1473124608 ,
- 1469285120 ,1465436672 ,1461579520 ,1457713536 ,
- 1453838720 ,1449955200 ,1446062848 ,1442161920 ,
- 1438252160 ,1434333824 ,1430406912 ,1426471296 ,
- 1422527104 ,1418574336 ,1414612992 ,1410643200 ,
- 1406664832 ,1402678016 ,1398682752 ,1394679040 ,
- 1390667008 ,1386646528 ,1382617728 ,1378580608 ,
- 1374535168 ,1370481408 ,1366419456 ,1362349184 ,
- 1358270848 ,1354184192 ,1350089472 ,1345986560 ,
- 1341875584 ,1337756416 ,1333629312 ,1329494144 ,
- 1325350912 ,1321199744 ,1317040640 ,1312873600 ,
- 1308698624 ,1304515712 ,1300325120 ,1296126464 ,
- 1291920128 ,1287705984 ,1283484160 ,1279254528 ,
- 1275017216 ,1270772224 ,1266519552 ,1262259200 ,
- 1257991296 ,1253715840 ,1249432832 ,1245142272 ,
- 1240844160 ,1236538624 ,1232225664 ,1227905280 ,
- 1223577472 ,1219242368 ,1214899840 ,1210550016 ,
- 1206192896 ,1201828480 ,1197456896 ,1193078016 ,
- 1188691968 ,1184298752 ,1179898496 ,1175491072 ,
- 1171076480 ,1166654976 ,1162226304 ,1157790720 ,
- 1153348224 ,1148898688 ,1144442240 ,1139978880 ,
- 1135508608 ,1131031680 ,1126547712 ,1122057088 ,
- 1117559680 ,1113055616 ,1108544768 ,1104027264 ,
- 1099503104 ,1094972288 ,1090434944 ,1085890944 ,
- 1081340416 ,1076783488 ,1072219968 ,1067649984 ,
- 1063073600 ,1058490816 ,1053901632 ,1049306112 ,
- 1044704320 ,1040096192 ,1035481792 ,1030861120 ,
- 1026234304 ,1021601280 ,1016962112 ,1012316800 ,
- 1007665408 ,1003007936 ,998344384 ,993674880 ,
- 988999360 ,984317888 ,979630464 ,974937152 ,
- 970238016 ,965532992 ,960822144 ,956105536 ,
- 951383104 ,946655040 ,941921216 ,937181696 ,
- 932436544 ,927685824 ,922929472 ,918167552 ,
- 913400128 ,908627200 ,903848768 ,899064960 ,
- 894275648 ,889481024 ,884681024 ,879875648 ,
- 875065024 ,870249088 ,865427968 ,860601536 ,
- 855769984 ,850933312 ,846091456 ,841244544 ,
- 836392512 ,831535488 ,826673472 ,821806400 ,
- 816934464 ,812057536 ,807175744 ,802289088 ,
- 797397632 ,792501312 ,787600256 ,782694464 ,
- 777783936 ,772868736 ,767948864 ,763024320 ,
- 758095232 ,753161600 ,748223424 ,743280704 ,
- 738333568 ,733381952 ,728425856 ,723465472 ,
- 718500672 ,713531520 ,708558144 ,703580480 ,
- 698598528 ,693612416 ,688622080 ,683627648 ,
- 678629056 ,673626432 ,668619712 ,663608960 ,
- 658594176 ,653575488 ,648552832 ,643526272 ,
- 638495872 ,633461568 ,628423488 ,623381568 ,
- 618335936 ,613286592 ,608233536 ,603176832 ,
- 598116480 ,593052544 ,587985024 ,582913920 ,
- 577839360 ,572761280 ,567679744 ,562594816 ,
- 557506496 ,552414848 ,547319808 ,542221504 ,
- 537119936 ,532015168 ,526907136 ,521795968 ,
- 516681632 ,511564192 ,506443680 ,501320096 ,
- 496193504 ,491063936 ,485931392 ,480795936 ,
- 475657568 ,470516320 ,465372256 ,460225408 ,
- 455075776 ,449923392 ,444768288 ,439610528 ,
- 434450112 ,429287072 ,424121440 ,418953280 ,
- 413782592 ,408609376 ,403433728 ,398255648 ,
- 393075168 ,387892320 ,382707136 ,377519648 ,
- 372329856 ,367137856 ,361943648 ,356747232 ,
- 351548672 ,346348032 ,341145280 ,335940448 ,
- 330733632 ,325524800 ,320314016 ,315101280 ,
- 309886688 ,304670208 ,299451872 ,294231776 ,
- 289009856 ,283786240 ,278560896 ,273333888 ,
- 268105200 ,262874928 ,257643056 ,252409632 ,
- 247174704 ,241938272 ,236700384 ,231461072 ,
- 226220368 ,220978304 ,215734912 ,210490208 ,
- 205244240 ,199997040 ,194748624 ,189499040 ,
- 184248320 ,178996496 ,173743584 ,168489632 ,
- 163234656 ,157978704 ,152721792 ,147463968 ,
- 142205248 ,136945680 ,131685280 ,126424088 ,
- 121162136 ,115899456 ,110636072 ,105372032 ,
- 100107344 ,94842064 ,89576208 ,84309816 ,
- 79042912 ,73775528 ,68507704 ,63239472 ,
- 57970852 ,52701888 ,47432604 ,42163032 ,
- 36893208 ,31623164 ,26352928 ,21082532 ,
- 15812011 ,10541393 ,5270713 ,0 ,
- };
-
- const Word32 ivas_mdft_coeff_cos_twid_320_fx[IVAS_320_PT_LEN + 1] =
- {
- 2147483647 ,
- 2147457792 ,2147380096 ,2147250816 ,2147069696 ,
- 2146836864 ,2146552320 ,2146216064 ,2145827968 ,
- 2145388288 ,2144896896 ,2144353792 ,2143759104 ,
- 2143112704 ,2142414592 ,2141664896 ,2140863616 ,
- 2140010752 ,2139106432 ,2138150400 ,2137142912 ,
- 2136083968 ,2134973440 ,2133811584 ,2132598272 ,
- 2131333632 ,2130017536 ,2128650112 ,2127231488 ,
- 2125761536 ,2124240384 ,2122668032 ,2121044608 ,
- 2119369984 ,2117644288 ,2115867648 ,2114039936 ,
- 2112161408 ,2110231808 ,2108251520 ,2106220288 ,
- 2104138496 ,2102005888 ,2099822592 ,2097588736 ,
- 2095304320 ,2092969472 ,2090584192 ,2088148480 ,
- 2085662464 ,2083126272 ,2080539776 ,2077903232 ,
- 2075216640 ,2072479872 ,2069693312 ,2066856832 ,
- 2063970560 ,2061034624 ,2058049024 ,2055013760 ,
- 2051928960 ,2048794752 ,2045611136 ,2042378368 ,
- 2039096192 ,2035764992 ,2032384768 ,2028955520 ,
- 2025477376 ,2021950464 ,2018374784 ,2014750592 ,
- 2011077760 ,2007356416 ,2003586816 ,1999768832 ,
- 1995902720 ,1991988480 ,1988026240 ,1984016128 ,
- 1979958272 ,1975852672 ,1971699456 ,1967498624 ,
- 1963250560 ,1958955008 ,1954612352 ,1950222592 ,
- 1945785856 ,1941302272 ,1936771840 ,1932194688 ,
- 1927571072 ,1922900992 ,1918184576 ,1913421952 ,
- 1908613248 ,1903758464 ,1898857856 ,1893911552 ,
- 1888919552 ,1883881984 ,1878799104 ,1873670912 ,
- 1868497536 ,1863279232 ,1858016000 ,1852707968 ,
- 1847355392 ,1841958144 ,1836516608 ,1831030784 ,
- 1825500928 ,1819927040 ,1814309248 ,1808647680 ,
- 1802942720 ,1797194112 ,1791402368 ,1785567360 ,
- 1779689344 ,1773768576 ,1767804928 ,1761798656 ,
- 1755750016 ,1749659008 ,1743525888 ,1737350784 ,
- 1731133696 ,1724875008 ,1718574720 ,1712233088 ,
- 1705850112 ,1699426048 ,1692961024 ,1686455296 ,
- 1679908864 ,1673321984 ,1666694656 ,1660027264 ,
- 1653319936 ,1646572672 ,1639785728 ,1632959360 ,
- 1626093568 ,1619188736 ,1612244736 ,1605261952 ,
- 1598240384 ,1591180416 ,1584082048 ,1576945536 ,
- 1569771136 ,1562558720 ,1555308800 ,1548021248 ,
- 1540696576 ,1533334656 ,1525935872 ,1518500224 ,
- 1511028096 ,1503519488 ,1495974656 ,1488393728 ,
- 1480777088 ,1473124608 ,1465436672 ,1457713536 ,
- 1449955200 ,1442161920 ,1434333824 ,1426471296 ,
- 1418574336 ,1410643200 ,1402678016 ,1394679040 ,
- 1386646528 ,1378580608 ,1370481408 ,1362349184 ,
- 1354184192 ,1345986560 ,1337756416 ,1329494144 ,
- 1321199744 ,1312873600 ,1304515712 ,1296126464 ,
- 1287705984 ,1279254528 ,1270772224 ,1262259200 ,
- 1253715840 ,1245142272 ,1236538624 ,1227905280 ,
- 1219242368 ,1210550016 ,1201828480 ,1193078016 ,
- 1184298752 ,1175491072 ,1166654976 ,1157790720 ,
- 1148898688 ,1139978880 ,1131031680 ,1122057088 ,
- 1113055616 ,1104027264 ,1094972288 ,1085890944 ,
- 1076783488 ,1067649984 ,1058490816 ,1049306112 ,
- 1040096192 ,1030861120 ,1021601280 ,1012316800 ,
- 1003007936 ,993674880 ,984317888 ,974937152 ,
- 965532992 ,956105536 ,946655040 ,937181696 ,
- 927685824 ,918167552 ,908627200 ,899064960 ,
- 889481024 ,879875648 ,870249088 ,860601536 ,
- 850933312 ,841244544 ,831535488 ,821806400 ,
- 812057536 ,802289088 ,792501312 ,782694464 ,
- 772868736 ,763024320 ,753161600 ,743280704 ,
- 733381952 ,723465472 ,713531520 ,703580480 ,
- 693612416 ,683627648 ,673626432 ,663608960 ,
- 653575488 ,643526272 ,633461568 ,623381568 ,
- 613286592 ,603176832 ,593052544 ,582913920 ,
- 572761280 ,562594816 ,552414848 ,542221504 ,
- 532015168 ,521795968 ,511564192 ,501320096 ,
- 491063936 ,480795936 ,470516320 ,460225408 ,
- 449923392 ,439610528 ,429287072 ,418953280 ,
- 408609376 ,398255648 ,387892320 ,377519648 ,
- 367137856 ,356747232 ,346348032 ,335940448 ,
- 325524800 ,315101280 ,304670208 ,294231776 ,
- 283786240 ,273333888 ,262874928 ,252409632 ,
- 241938272 ,231461072 ,220978304 ,210490208 ,
- 199997040 ,189499040 ,178996496 ,168489632 ,
- 157978704 ,147463968 ,136945680 ,126424088 ,
- 115899456 ,105372032 ,94842064 ,84309816 ,
- 73775528 ,63239472 ,52701888 ,42163032 ,
- 31623164 ,21082532 ,10541393 ,0 ,
- };
-
- const Word32 ivas_mdft_coeff_cos_twid_240_fx[IVAS_240_PT_LEN + 1] =
- {
- 2147483647 ,
- 2147437696 ,2147299712 ,2147069696 ,2146747776 ,
- 2146333824 ,2145827968 ,2145230208 ,2144540544 ,
- 2143759104 ,2142885760 ,2141920512 ,2140863616 ,
- 2139715072 ,2138474752 ,2137142912 ,2135719552 ,
- 2134204544 ,2132598272 ,2130900608 ,2129111680 ,
- 2127231488 ,2125260160 ,2123197824 ,2121044608 ,
- 2118800384 ,2116465536 ,2114039936 ,2111523840 ,
- 2108917248 ,2106220288 ,2103433216 ,2100556032 ,
- 2097588736 ,2094531712 ,2091384832 ,2088148480 ,
- 2084822656 ,2081407488 ,2077903232 ,2074309888 ,
- 2070627712 ,2066856832 ,2062997504 ,2059049728 ,
- 2055013760 ,2050889728 ,2046677888 ,2042378368 ,
- 2037991296 ,2033516928 ,2028955520 ,2024307200 ,
- 2019572096 ,2014750592 ,2009842688 ,2004848640 ,
- 1999768832 ,1994603264 ,1989352320 ,1984016128 ,
- 1978595072 ,1973089152 ,1967498624 ,1961823872 ,
- 1956065152 ,1950222592 ,1944296576 ,1938287104 ,
- 1932194688 ,1926019584 ,1919761920 ,1913421952 ,
- 1907000064 ,1900496512 ,1893911552 ,1887245440 ,
- 1880498432 ,1873670912 ,1866763136 ,1859775360 ,
- 1852707968 ,1845561216 ,1838335360 ,1831030784 ,
- 1823647744 ,1816186624 ,1808647680 ,1801031296 ,
- 1793337728 ,1785567360 ,1777720576 ,1769797504 ,
- 1761798656 ,1753724416 ,1745574912 ,1737350784 ,
- 1729052160 ,1720679424 ,1712233088 ,1703713280 ,
- 1695120640 ,1686455296 ,1677717632 ,1668908288 ,
- 1660027264 ,1651075200 ,1642052480 ,1632959360 ,
- 1623796352 ,1614563712 ,1605261952 ,1595891328 ,
- 1586452480 ,1576945536 ,1567371136 ,1557729664 ,
- 1548021248 ,1538246656 ,1528406272 ,1518500224 ,
- 1508529280 ,1498493568 ,1488393728 ,1478230144 ,
- 1468003328 ,1457713536 ,1447361280 ,1436947072 ,
- 1426471296 ,1415934336 ,1405336832 ,1394679040 ,
- 1383961600 ,1373184768 ,1362349184 ,1351455232 ,
- 1340503424 ,1329494144 ,1318427904 ,1307305216 ,
- 1296126464 ,1284892288 ,1273603072 ,1262259200 ,
- 1250861312 ,1239409920 ,1227905280 ,1216348160 ,
- 1204738816 ,1193078016 ,1181366016 ,1169603456 ,
- 1157790720 ,1145928448 ,1134017024 ,1122057088 ,
- 1110049152 ,1097993600 ,1085890944 ,1073741824 ,
- 1061546688 ,1049306112 ,1037020608 ,1024690624 ,
- 1012316800 ,999899584 ,987439552 ,974937152 ,
- 962393088 ,949807744 ,937181696 ,924515520 ,
- 911809792 ,899064960 ,886281600 ,873460288 ,
- 860601536 ,847705984 ,834774080 ,821806400 ,
- 808803520 ,795766016 ,782694464 ,769589312 ,
- 756451200 ,743280704 ,730078400 ,716844800 ,
- 703580480 ,690286016 ,676961984 ,663608960 ,
- 650227520 ,636818176 ,623381568 ,609918336 ,
- 596428864 ,582913920 ,569374016 ,555809664 ,
- 542221504 ,528610176 ,514976160 ,501320096 ,
- 487642560 ,473944128 ,460225408 ,446486944 ,
- 432729376 ,418953280 ,405159232 ,391347808 ,
- 377519648 ,363675296 ,349815360 ,335940448 ,
- 322051168 ,308148064 ,294231776 ,280302848 ,
- 266361952 ,252409632 ,238446512 ,224473168 ,
- 210490208 ,196498224 ,182497840 ,168489632 ,
- 154474192 ,140452144 ,126424088 ,112390608 ,
- 98352320 ,84309816 ,70263696 ,56214568 ,
- 42163032 ,28109692 ,14055147 ,0 ,
- };
-const Word32 ivas_mdft_coeff_cos_twid_160_fx[IVAS_160_PT_LEN + 1] =
-{
- 2147483647 ,
- 2147380096 ,2147069696 ,2146552320 ,2145827968 ,
- 2144896896 ,2143759104 ,2142414592 ,2140863616 ,
- 2139106432 ,2137142912 ,2134973440 ,2132598272 ,
- 2130017536 ,2127231488 ,2124240384 ,2121044608 ,
- 2117644288 ,2114039936 ,2110231808 ,2106220288 ,
- 2102005888 ,2097588736 ,2092969472 ,2088148480 ,
- 2083126272 ,2077903232 ,2072479872 ,2066856832 ,
- 2061034624 ,2055013760 ,2048794752 ,2042378368 ,
- 2035764992 ,2028955520 ,2021950464 ,2014750592 ,
- 2007356416 ,1999768832 ,1991988480 ,1984016128 ,
- 1975852672 ,1967498624 ,1958955008 ,1950222592 ,
- 1941302272 ,1932194688 ,1922900992 ,1913421952 ,
- 1903758464 ,1893911552 ,1883881984 ,1873670912 ,
- 1863279232 ,1852707968 ,1841958144 ,1831030784 ,
- 1819927040 ,1808647680 ,1797194112 ,1785567360 ,
- 1773768576 ,1761798656 ,1749659008 ,1737350784 ,
- 1724875008 ,1712233088 ,1699426048 ,1686455296 ,
- 1673321984 ,1660027264 ,1646572672 ,1632959360 ,
- 1619188736 ,1605261952 ,1591180416 ,1576945536 ,
- 1562558720 ,1548021248 ,1533334656 ,1518500224 ,
- 1503519488 ,1488393728 ,1473124608 ,1457713536 ,
- 1442161920 ,1426471296 ,1410643200 ,1394679040 ,
- 1378580608 ,1362349184 ,1345986560 ,1329494144 ,
- 1312873600 ,1296126464 ,1279254528 ,1262259200 ,
- 1245142272 ,1227905280 ,1210550016 ,1193078016 ,
- 1175491072 ,1157790720 ,1139978880 ,1122057088 ,
- 1104027264 ,1085890944 ,1067649984 ,1049306112 ,
- 1030861120 ,1012316800 ,993674880 ,974937152 ,
- 956105536 ,937181696 ,918167552 ,899064960 ,
- 879875648 ,860601536 ,841244544 ,821806400 ,
- 802289088 ,782694464 ,763024320 ,743280704 ,
- 723465472 ,703580480 ,683627648 ,663608960 ,
- 643526272 ,623381568 ,603176832 ,582913920 ,
- 562594816 ,542221504 ,521795968 ,501320096 ,
- 480795936 ,460225408 ,439610528 ,418953280 ,
- 398255648 ,377519648 ,356747232 ,335940448 ,
- 315101280 ,294231776 ,273333888 ,252409632 ,
- 231461072 ,210490208 ,189499040 ,168489632 ,
- 147463968 ,126424088 ,105372032 ,84309816 ,
- 63239472 ,42163032 ,21082532 ,0 ,
-};
-
-const Word32 ivas_mdft_coeff_cos_twid_120_fx[IVAS_120_PT_LEN + 1] =
-{
- 2147483647 ,
- 2147299712 ,2146747776 ,2145827968 ,2144540544 ,
- 2142885760 ,2140863616 ,2138474752 ,2135719552 ,
- 2132598272 ,2129111680 ,2125260160 ,2121044608 ,
- 2116465536 ,2111523840 ,2106220288 ,2100556032 ,
- 2094531712 ,2088148480 ,2081407488 ,2074309888 ,
- 2066856832 ,2059049728 ,2050889728 ,2042378368 ,
- 2033516928 ,2024307200 ,2014750592 ,2004848640 ,
- 1994603264 ,1984016128 ,1973089152 ,1961823872 ,
- 1950222592 ,1938287104 ,1926019584 ,1913421952 ,
- 1900496512 ,1887245440 ,1873670912 ,1859775360 ,
- 1845561216 ,1831030784 ,1816186624 ,1801031296 ,
- 1785567360 ,1769797504 ,1753724416 ,1737350784 ,
- 1720679424 ,1703713280 ,1686455296 ,1668908288 ,
- 1651075200 ,1632959360 ,1614563712 ,1595891328 ,
- 1576945536 ,1557729664 ,1538246656 ,1518500224 ,
- 1498493568 ,1478230144 ,1457713536 ,1436947072 ,
- 1415934336 ,1394679040 ,1373184768 ,1351455232 ,
- 1329494144 ,1307305216 ,1284892288 ,1262259200 ,
- 1239409920 ,1216348160 ,1193078016 ,1169603456 ,
- 1145928448 ,1122057088 ,1097993600 ,1073741824 ,
- 1049306112 ,1024690624 ,999899584 ,974937152 ,
- 949807744 ,924515520 ,899064960 ,873460288 ,
- 847705984 ,821806400 ,795766016 ,769589312 ,
- 743280704 ,716844800 ,690286016 ,663608960 ,
- 636818176 ,609918336 ,582913920 ,555809664 ,
- 528610176 ,501320096 ,473944128 ,446486944 ,
- 418953280 ,391347808 ,363675296 ,335940448 ,
- 308148064 ,280302848 ,252409632 ,224473168 ,
- 196498224 ,168489632 ,140452144 ,112390608 ,
- 84309816 ,56214568 ,28109692 ,0 ,
-};
-
-const Word32 ivas_mdft_coeff_cos_twid_80_fx[IVAS_80_PT_LEN + 1] =
-{
- 2147483647 ,
- 2147069696 ,2145827968 ,2143759104 ,2140863616 ,
- 2137142912 ,2132598272 ,2127231488 ,2121044608 ,
- 2114039936 ,2106220288 ,2097588736 ,2088148480 ,
- 2077903232 ,2066856832 ,2055013760 ,2042378368 ,
- 2028955520 ,2014750592 ,1999768832 ,1984016128 ,
- 1967498624 ,1950222592 ,1932194688 ,1913421952 ,
- 1893911552 ,1873670912 ,1852707968 ,1831030784 ,
- 1808647680 ,1785567360 ,1761798656 ,1737350784 ,
- 1712233088 ,1686455296 ,1660027264 ,1632959360 ,
- 1605261952 ,1576945536 ,1548021248 ,1518500224 ,
- 1488393728 ,1457713536 ,1426471296 ,1394679040 ,
- 1362349184 ,1329494144 ,1296126464 ,1262259200 ,
- 1227905280 ,1193078016 ,1157790720 ,1122057088 ,
- 1085890944 ,1049306112 ,1012316800 ,974937152 ,
- 937181696 ,899064960 ,860601536 ,821806400 ,
- 782694464 ,743280704 ,703580480 ,663608960 ,
- 623381568 ,582913920 ,542221504 ,501320096 ,
- 460225408 ,418953280 ,377519648 ,335940448 ,
- 294231776 ,252409632 ,210490208 ,168489632 ,
- 126424088 ,84309816 ,42163032 ,0 ,
-};
-
-const Word32 ivas_mdft_coeff_cos_twid_40_fx[IVAS_40_PT_LEN + 1] =
-{
- 2147483647 ,
- 2145827968 ,2140863616 ,2132598272 ,2121044608 ,
- 2106220288 ,2088148480 ,2066856832 ,2042378368 ,
- 2014750592 ,1984016128 ,1950222592 ,1913421952 ,
- 1873670912 ,1831030784 ,1785567360 ,1737350784 ,
- 1686455296 ,1632959360 ,1576945536 ,1518500224 ,
- 1457713536 ,1394679040 ,1329494144 ,1262259200 ,
- 1193078016 ,1122057088 ,1049306112 ,974937152 ,
- 899064960 ,821806400 ,743280704 ,663608960 ,
- 582913920 ,501320096 ,418953280 ,335940448 ,
- 252409632 ,168489632 ,84309816 ,0 ,
-};
-#endif
const float ivas_sin_twiddle_480[IVAS_480_PT_LEN >> 1] =
{
-0.000818122995607253f, -0.00736304124977957f, -0.0139076440957708f, -0.0204516511845773f,
@@ -5609,18 +4476,7 @@ 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
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 dirac_gains_norm_term_int[9] = //Q30
-{
- 1073741824, 759250176, 1073741824, 438353280, 219176688, 1073741824, 309962528, 98018768,
- 40015996
-};
-const Word32 dirac_gains_norm_term_fx[9] = //Q31
-{
- 2147483647, 1518500352, 2147483647, 876706560, 438353376, 2147483647, 619925056, 196037536, 80031992
-};
-#endif
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},
@@ -5715,102 +4571,7 @@ const float dirac_gains_Pnm[91][9] =
{-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}
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 dirac_gains_Pnm_int[91][9] = //Q27
-{
- {-134217728, 0, 134217728, 0, 0, -134217728, 0, 0, 0},
- {-134197288, 2342396, 134156400, -7026119, 122639, -134095104, 14049026, -613106, 10701},
- {-134135976, 4684105, 133972536, -14043751, 490416, -133727536, 28061840, -2450586, 85575},
- {-134033784, 7024438, 133666264, -21044428, 1102895, -133115936, 42002312, -5506921, 288606},
- {-133890784, 9362478, 133238096, -28019012, 1959264, -132262040, 55833192, -9772457, 683351},
- {-133706992, 11697809, 132688440, -34959892, 3058584, -131167848, 69520408, -15234719, 1332861},
- {-133482480, 14029564, 132017976, -41858120, 4399464, -129836328, 83027720, -21876818, 2299344},
- {-133217280, 16357047, 131227600, -48705360, 5980272, -128270864, 96320208, -29678480, 3644062},
- {-132911536, 18679510, 130318176, -55493180, 7799064, -126475552, 109363520, -38615824, 5427104},
- {-132565296, 20996256, 129290928, -62213284, 9853607, -124455056, 122123976, -48661468, 7707213},
- {-132178656, 23306694, 128146968, -68857816, 12141505, -122214432, 134569248, -59785232, 10541761},
- {-131751776, 25609964, 126887800, -75418320, 14659851, -119759704, 146666688, -71952528, 13986158},
- {-131284736, 27905410, 125514928, -81886824, 17405570, -117097048, 158385376, -85126080, 18094094},
- {-130777744, 30192412, 124030024, -88255768, 20375446, -114233392, 169695776, -99266128, 22917396},
- {-130230888, 32470208, 122434848, -94517128, 23565774, -111176104, 180568608, -114328832, 28505376},
- {-129644368, 34738112, 120731408, -100663320, 26972664, -107933048, 190976128, -130267952, 34905200},
- {-129018344, 36995424, 118921736, -106686840, 30591964, -104512608, 200891728, -147034448, 42161440},
- {-128353056, 39241452, 117008088, -112580368, 34419264, -100923608, 210290720, -164576576, 50316080},
- {-127648640, 41475572, 114992728, -118336848, 38449984, -97175216, 219149232, -182840512, 59408524},
- {-126905360, 43697012, 112878208, -123949000, 42679048, -93277184, 227444688, -201769248, 69474696},
- {-126123408, 45905176, 110666976, -129410248, 47101484, -89239304, 235156848, -221304640, 80548296},
- {-125303040, 48099312, 108361848, -134713792, 51711740, -85072152, 242266352, -241385344, 92659128},
- {-124444528, 50278820, 105965584, -139853120, 56504308, -80786280, 248755776, -261949392, 105834368},
- {-123548080, 52443040, 103481048, -144822272, 61473384, -76392608, 254609280, -282932704, 120097808},
- {-122614016, 54591264, 100911328, -149614784, 66612780, -71902504, 259812912, -304269024, 135469312},
- {-121642584, 56722880, 98259536, -154225168, 71916384, -67327280, 264354304, -325891904, 151965872},
- {-120634104, 58837188, 95528944, -158647504, 77377552, -62678672, 268222720, -347732352, 169600480},
- {-119588872, 60933588, 92722800, -162876704, 82989840, -57968464, 271409984, -369722464, 188383040},
- {-118507224, 63011412, 89844624, -166907264, 88746208, -53208660, 273908992, -391791360, 208319200},
- {-117389480, 65070028, 86897888, -170734608, 94639696, -48411356, 275714624, -413868832, 229411120},
- {-116235952, 67108864, 83886096, -174353936, 100663296, -43588484, 276824064, -435884832, 251658240},
- {-115047032, 69127240, 80812992, -177760784, 106809472, -38752388, 277236128, -457767936, 275054816},
- {-113823072, 71124576, 77682296, -180951136, 113070880, -33915128, 276951296, -479447744, 299592224},
- {-112564464, 73100224, 74497888, -183920976, 119439696, -29088994, 275972448, -500852768, 325257600},
- {-111271560, 75053584, 71263600, -186666800, 125908272, -24285974, 274304128, -521913568, 352034976},
- {-109944736, 76984136, 67983320, -189185120, 132468856, -19517968, 271952224, -542560640, 379905024},
- {-108584440, 78891192, 64661120, -191472992, 139113184, -14796968, 268925472, -562724864, 408843424},
- {-107191040, 80774240, 61300996, -193527600, 145833472, -10134552, 265233552, -582338944, 438823936},
- {-105765016, 82632672, 57907084, -195346384, 152621264, -5542341, 260888528, -601335936, 469815200},
- {-104306760, 84465968, 54483472, -196927072, 159468512, -1031517, 255903808, -619651456, 501783968},
- {-102816736, 86273488, 51034412, -198267904, 166366624, 3386773, 250294992, -637221056, 534692032},
- {-101295408, 88054736, 47564080, -199367280, 173307296, 7701825, 244078832, -653983232, 568498944},
- {-99743224, 89809192, 44076620, -200223728, 180282192, 11903295, 237274256, -669879040, 603161856},
- {-98160648, 91536272, 40576356, -200836160, 187282720, 15980983, 229901280, -684849728, 638632640},
- {-96548144, 93235488, 37067500, -201203920, 194300432, 19925212, 221981760, -698840192, 674862144},
- {-94906272, 94906272, 33554432, -201326592, 201326592, 23726568, 213539056, -711796992, 711796992},
- {-93235488, 96548144, 30041364, -201203920, 208352752, 27376188, 204597888, -723670016, 749382016},
- {-91536272, 98160648, 26532496, -200836160, 215370464, 30865648, 195183856, -734411520, 787559936},
- {-89809200, 99743208, 23032272, -200223728, 222370864, 34186800, 185324752, -743976000, 826268864},
- {-88054736, 101295408, 19544786, -199367280, 229345888, 37332284, 175048640, -752322176, 865447872},
- {-86273488, 102816736, 16074439, -198268032, 236286560, 40294912, 164385440, -759410496, 905030144},
- {-84465944, 104306784, 12625336, -196927072, 243184800, 43068320, 153365504, -765205632, 944950528},
- {-82632672, 105765016, 9201773, -195346384, 250031920, 45646496, 142020480, -769675200, 985139200},
- {-80774256, 107191032, 5807891, -193527600, 256819584, 48024044, 130382952, -772789696, 1025526400},
- {-78891192, 108584440, 2447739, -191472992, 263540000, 50196224, 118485736, -774524480, 1066041600},
- {-76984120, 109944720, -874438, -189185120, 270184320, 52158672, 106363224, -774856768, 1106610176},
- {-75053584, 111271544, -4154720, -186666800, 276744864, 53907864, 94049432, -773768704, 1147159552},
- {-73100224, 112564464, -7389016, -183920976, 283213504, 55440728, 81579720, -771245696, 1187614080},
- {-71124568, 113823072, -10573435, -180951136, 289582400, 56754824, 68989160, -767276288, 1227898496},
- {-69127232, 115047064, -13704140, -177760784, 295843776, 57848416, 56313356, -761853888, 1267938048},
- {-67108880, 116235952, -16777203, -174353936, 301989888, 58720256, 43588536, -754974720, 1307654528},
- {-65070028, 117389472, -19788994, -170734608, 308013440, 59369844, 30850226, -746639232, 1346972928},
- {-63011400, 118507224, -22735772, -166907264, 313906944, 59797272, 18134762, -736851968, 1385816832},
- {-60933588, 119588872, -25613950, -162876704, 319663424, 60003204, 5477891, -725620736, 1424110464},
- {-58837172, 120634088, -28420080, -158647504, 325275584, 59989016, -7084927, -712957184, 1461778688},
- {-56722868, 121642576, -31150674, -154225168, 330736768, 59756660, -19517928, -698877184, 1498746240},
- {-54591276, 122613992, -33802452, -149614784, 336040384, 59308680, -31786382, -683399744, 1534940800},
- {-52443040, 123548064, -36372160, -144822272, 341179712, 58648260, -43855684, -666547776, 1570288384},
- {-50278848, 124444520, -38856688, -139853264, 346148864, 57779188, -55691916, -648348160, 1604717952},
- {-48099324, 125303040, -41252988, -134713792, 350941376, 56705796, -67261816, -628830848, 1638160896},
- {-45905160, 126123416, -43558124, -129410240, 355551744, 55433036, -78532848, -608029120, 1670546304},
- {-43697012, 126905360, -45769332, -123949000, 359974080, 53966400, -89473440, -585980480, 1701810944},
- {-41475560, 127648632, -47883864, -118336808, 364203168, 52311936, -100052728, -562724992, 1731889152},
- {-39241464, 128353048, -49899212, -112580408, 368233856, 50476188, -110241232, -538305984, 1760719104},
- {-36995424, 129018360, -51812888, -106686856, 372061216, 48466224, -120010336, -512769824, 1788240512},
- {-34738100, 129644368, -53622532, -100663280, 375680512, 46289628, -129332608, -486166400, 1814398208},
- {-32470208, 130230888, -55325984, -94517088, 379087360, 43954400, -138181984, -458547616, 1839134464},
- {-30192412, 130777744, -56921148, -88255752, 382277728, 41469052, -146533552, -429968768, 1862399872},
- {-27905450, 131284752, -58406064, -81886920, 385247552, 38842476, -154363936, -400487584, 1884144384},
- {-25609950, 131751776, -59778952, -75418272, 387993376, 36083912, -161651424, -370163232, 1904324096},
- {-23306666, 132178656, -61038128, -68857760, 390511712, 33203050, -168375472, -339058272, 1922894464},
- {-20996270, 132565280, -62182040, -62213328, 392799456, 30209874, -174517136, -307236864, 1939817984},
- {-18679498, 132911536, -63209344, -55493124, 394854208, 27114732, -180059392, -274765312, 1955057024},
- {-16357021, 133217280, -64118736, -48705292, 396672992, 23928188, -184986656, -241711232, 1968580864},
- {-14029578, 133482472, -64909128, -41858176, 398253664, 20661142, -189285248, -208144320, 1980359808},
- {-11697849, 133706992, -65579560, -34960012, 399594624, 17324636, -192943088, -174134880, 1990369664},
- {-9362556, 133890784, -66129224, -28019252, 400693888, 13929935, -195949824, -139755008, 1998589184},
- {-7024411, 134033784, -66557432, -21044346, 401550304, 10488515, -198297168, -105077560, 2004999424},
- {-4684126, 134135976, -66863648, -14043818, 402162752, 7011926, -199978640, -70176320, 2009588352},
- {-2342414, 134197304, -67047540, -7026174, 402530496, 3511839, -200989440, -35125516, 2012346496},
- {-5, 134217728, -67108864, -17, 402653184, 8, -201326592, -88, 2013265920}
-};
-#endif
+
const float dirac_gains_trg_term[181][2] =
{
{-1.000000e+00f,8.742278e-08f},
@@ -5995,376 +4756,7 @@ const float dirac_gains_trg_term[181][2] =
{9.998477e-01f,-1.745241e-02f},
{1.000000e+00f,0.000000e+00f}
};
-#ifdef IVAS_FLOAT_FIXED
-const Word32 dirac_gains_trg_term_int[181][2] = //Q30
-{
- {-1073741824, 93},
- {-1073578304, -18739436},
- {-1073087680, -37473000},
- {-1072270272, -56195404},
- {-1071126272, -74900440},
- {-1069655936, -93582656},
- {-1067859776, -112236624},
- {-1065738240, -130856168},
- {-1063292288, -149436080},
- {-1060522368, -167970160},
- {-1057429248, -186453440},
- {-1054014208, -204879600},
- {-1050278016, -223243376},
- {-1046221952, -241539408},
- {-1041847104, -259761664},
- {-1037154944, -277904896},
- {-1032146880, -295963392},
- {-1026824448, -313931616},
- {-1021189120, -331804480},
- {-1015242880, -349576096},
- {-1008987264, -367241408},
- {-1002424448, -384794592},
- {-995556160, -402230656},
- {-988384640, -419544416},
- {-980912000, -436730112},
- {-973140608, -453782944},
- {-965072832, -470697376},
- {-956710976, -487468704},
- {-948057792, -504091296},
- {-939115840, -520560224},
- {-929887680, -536871040},
- {-920376384, -553017856},
- {-910584576, -568996544},
- {-900515712, -584801664},
- {-890172480, -600428672},
- {-879557888, -615873088},
- {-868675520, -631129536},
- {-857528320, -646194048},
- {-846120128, -661061376},
- {-834454080, -675727744},
- {-822533888, -690187904},
- {-810363392, -704438016},
- {-797945664, -718473536},
- {-785285056, -732290112},
- {-772385152, -745883904},
- {-759250176, -759250176},
- {-745883904, -772385152},
- {-732290112, -785285056},
- {-718473600, -797945664},
- {-704438016, -810363392},
- {-690187904, -822533888},
- {-675727552, -834454144},
- {-661061376, -846120128},
- {-646194048, -857528320},
- {-631129536, -868675392},
- {-615873088, -879557760},
- {-600428672, -890172352},
- {-584801792, -900515712},
- {-568996544, -910584576},
- {-553017856, -920376384},
- {-536871040, -929887680},
- {-520560224, -939115776},
- {-504091296, -948057792},
- {-487468704, -956710976},
- {-470697376, -965072832},
- {-453782944, -973140608},
- {-436730208, -980911936},
- {-419544416, -988384640},
- {-402230784, -995556160},
- {-384794592, -1002424448},
- {-367241280, -1008987264},
- {-349576096, -1015242880},
- {-331804480, -1021189120},
- {-313931712, -1026824384},
- {-295963392, -1032146880},
- {-277904800, -1037154944},
- {-259761664, -1041847104},
- {-241539296, -1046221952},
- {-223243488, -1050278016},
- {-204879600, -1054014208},
- {-186453328, -1057429248},
- {-167970160, -1060522368},
- {-149435984, -1063292288},
- {-130856168, -1065738240},
- {-112236624, -1067859776},
- {-93582792, -1069655936},
- {-74900448, -1071126272},
- {-56195288, -1072270272},
- {-37473008, -1073087680},
- {-18739318, -1073578304},
- {-46, -1073741824},
- {18739350, -1073578304},
- {37473052, -1073087680},
- {56195320, -1072270272},
- {74900480, -1071126272},
- {93582824, -1069655936},
- {112236512, -1067859776},
- {130856168, -1065738240},
- {149435984, -1063292288},
- {167970272, -1060522368},
- {186453328, -1057429248},
- {204879504, -1054014208},
- {223243488, -1050278016},
- {241539296, -1046221952},
- {259761664, -1041847104},
- {277904896, -1037154944},
- {295963392, -1032146880},
- {313931712, -1026824448},
- {331804480, -1021189120},
- {349576096, -1015242880},
- {367241408, -1008987264},
- {384794720, -1002424320},
- {402230784, -995556160},
- {419544320, -988384640},
- {436730112, -980912000},
- {453782848, -973140608},
- {470697504, -965072832},
- {487468576, -956710976},
- {504091296, -948057792},
- {520560352, -939115776},
- {536870912, -929887680},
- {553017920, -920376384},
- {568996544, -910584704},
- {584801664, -900515712},
- {600428800, -890172224},
- {615873088, -879557888},
- {631129536, -868675392},
- {646193920, -857528320},
- {661061504, -846120064},
- {675727616, -834454144},
- {690187904, -822533888},
- {704438016, -810363136},
- {718473536, -797945792},
- {732290176, -785285056},
- {745883776, -772385216},
- {759250176, -759250176},
- {772385216, -745883776},
- {785285056, -732290112},
- {797945664, -718473536},
- {810363264, -704438016},
- {822533888, -690187904},
- {834454144, -675727616},
- {846120128, -661061504},
- {857528320, -646193920},
- {868675392, -631129536},
- {879557888, -615873088},
- {890172352, -600428800},
- {900515712, -584801792},
- {910584704, -568996544},
- {920376384, -553017920},
- {929887680, -536870912},
- {939115776, -520560352},
- {948057792, -504091296},
- {956710976, -487468576},
- {965072832, -470697504},
- {973140608, -453782944},
- {980911936, -436730112},
- {988384640, -419544320},
- {995556160, -402230784},
- {1002424320, -384794592},
- {1008987264, -367241280},
- {1015242880, -349576096},
- {1021189120, -331804480},
- {1026824448, -313931712},
- {1032146880, -295963392},
- {1037154944, -277904800},
- {1041847104, -259761664},
- {1046221952, -241539296},
- {1050278016, -223243488},
- {1054014208, -204879600},
- {1057429248, -186453328},
- {1060522368, -167970272},
- {1063292288, -149435984},
- {1065738240, -130856168},
- {1067859776, -112236624},
- {1069655936, -93582760},
- {1071126272, -74900440},
- {1072270272, -56195308},
- {1073087680, -37473052},
- {1073578304, -18739382},
- {1073741824, 0}
-};
-
-const Word32 dirac_gains_trg_term_fx[181][2] = //Q31
-{
- {(-2147483647 - 1),187},
- {-2147156608,-37478872},
- {-2146175360,-74946000},
- {-2144540544,-112390808},
- {-2142252544,-149800880},
- {-2139311872,-187165312},
- {-2135719552,-224473248},
- {-2131476480,-261712336},
- {-2126584576,-298872160},
- {-2121044736,-335940320},
- {-2114858496,-372906880},
- {-2108028416,-409759200},
- {-2100556032,-446486752},
- {-2092443904,-483078816},
- {-2083694208,-519523328},
- {-2074309888,-555809792},
- {-2064293760,-591926784},
- {-2053648896,-627863232},
- {-2042378240,-663608960},
- {-2030485760,-699152192},
- {-2017974528,-734482816},
- {-2004848896,-769589184},
- {-1991112320,-804461312},
- {-1976769280,-839088832},
- {-1961824000,-873460224},
- {-1946281216,-907565888},
- {-1930145664,-941394752},
- {-1913421952,-974937408},
- {-1896115584,-1008182592},
- {-1878231680,-1041120448},
- {-1859775360,-1073742080},
- {-1840752768,-1106035712},
- {-1821169152,-1137993088},
- {-1801031424,-1169603328},
- {-1780344960,-1200857344},
- {-1759115776,-1231746176},
- {-1737351040,-1262259072},
- {-1715056640,-1292388096},
- {-1692240256,-1322122752},
- {-1668908160,-1351455488},
- {-1645067776,-1380375808},
- {-1620726784,-1408876032},
- {-1595891328,-1436947072},
- {-1570570112,-1464580224},
- {-1544770304,-1491767808},
- {-1518500352,-1518500352},
- {-1491767808,-1544770304},
- {-1464580224,-1570570112},
- {-1436947200,-1595891328},
- {-1408876032,-1620726784},
- {-1380375808,-1645067776},
- {-1351455104,-1668908288},
- {-1322122752,-1692240256},
- {-1292388096,-1715056640},
- {-1262259072,-1737350784},
- {-1231746176,-1759115520},
- {-1200857344,-1780344704},
- {-1169603584,-1801031424},
- {-1137993088,-1821169152},
- {-1106035712,-1840752768},
- {-1073742080,-1859775360},
- {-1041120448,-1878231552},
- {-1008182592,-1896115584},
- {-974937408,-1913421952},
- {-941394752,-1930145664},
- {-907565888,-1946281216},
- {-873460416,-1961823872},
- {-839088832,-1976769280},
- {-804461568,-1991112320},
- {-769589184,-2004848896},
- {-734482560,-2017974528},
- {-699152192,-2030485760},
- {-663608960,-2042378240},
- {-627863424,-2053648768},
- {-591926784,-2064293760},
- {-555809600,-2074309888},
- {-519523328,-2083694208},
- {-483078592,-2092443904},
- {-446486976,-2100556032},
- {-409759200,-2108028416},
- {-372906656, -2114858496},
- { -335940320,-2121044736 },
- { -298871968,-2126584576 },
- { -261712336,-2131476480 },
- { -224473248,-2135719552 },
- { -187165584,-2139311872 },
- { -149800896,-2142252544 },
- { -112390576,-2144540544 },
- { -74946016,-2146175360 },
- { -37478636,-2147156608 },
- { -93,(-2147483647 - 1) },
- { 37478700,-2147156608 },
- { 74946104,-2146175360 },
- { 112390640,-2144540544 },
- { 149800960,-2142252544 },
- { 187165648,-2139311872 },
- { 224473024,-2135719552 },
- { 261712336,-2131476480 },
- { 298871968,-2126584576 },
- { 335940544,-2121044736 },
- { 372906656,-2114858496 },
- { 409759008,-2108028416 },
- { 446486976,-2100556032 },
- { 483078592,-2092443904 },
- { 519523328,-2083694208 },
- { 555809792,-2074309888 },
- { 591926784,-2064293760 },
- { 627863424,-2053648896 },
- { 663608960,-2042378240 },
- { 699152192,-2030485760 },
- { 734482816,-2017974528 },
- { 769589440,-2004848640 },
- { 804461568,-1991112320 },
- { 839088640,-1976769280 },
- { 873460224,-1961824000 },
- { 907565696,-1946281216 },
- { 941395008,-1930145664 },
- { 974937152,-1913421952 },
- { 1008182592,-1896115584 },
- { 1041120704,-1878231552 },
- { 1073741824,-1859775360 },
- { 1106035840,-1840752768 },
- { 1137993088,-1821169408 },
- { 1169603328,-1801031424 },
- { 1200857600,-1780344448 },
- { 1231746176,-1759115776 },
- { 1262259072,-1737350784 },
- { 1292387840,-1715056640 },
- { 1322123008,-1692240128 },
- { 1351455232,-1668908288 },
- { 1380375808,-1645067776 },
- { 1408876032,-1620726272 },
- { 1436947072,-1595891584 },
- { 1464580352,-1570570112 },
- { 1491767552,-1544770432 },
- { 1518500352,-1518500352 },
- { 1544770432,-1491767552 },
- { 1570570112,-1464580224 },
- { 1595891328,-1436947072 },
- { 1620726528,-1408876032 },
- { 1645067776,-1380375808 },
- { 1668908288,-1351455232 },
- { 1692240256,-1322123008 },
- { 1715056640,-1292387840 },
- { 1737350784,-1262259072 },
- { 1759115776,-1231746176 },
- { 1780344704,-1200857600 },
- { 1801031424,-1169603584 },
- { 1821169408,-1137993088 },
- { 1840752768,-1106035840 },
- { 1859775360,-1073741824 },
- { 1878231552,-1041120704 },
- { 1896115584,-1008182592 },
- { 1913421952,-974937152 },
- { 1930145664,-941395008 },
- { 1946281216,-907565888 },
- { 1961823872,-873460224 },
- { 1976769280,-839088640 },
- { 1991112320,-804461568 },
- { 2004848640,-769589184 },
- { 2017974528,-734482560 },
- { 2030485760,-699152192 },
- { 2042378240,-663608960 },
- { 2053648896,-627863424 },
- { 2064293760,-591926784 },
- { 2074309888,-555809600 },
- { 2083694208,-519523328 },
- { 2092443904,-483078592 },
- { 2100556032,-446486976 },
- { 2108028416,-409759200 },
- { 2114858496,-372906656 },
- { 2121044736,-335940544 },
- { 2126584576,-298871968 },
- { 2131476480,-261712336 },
- { 2135719552,-224473248 },
- { 2139311872,-187165520 },
- { 2142252544,-149800880 },
- { 2144540544,-112390616 },
- { 2146175360,-74946104 },
- { 2147156608,-37478764 },
- { 2147483647,0 } };
-#endif
+
/*----------------------------------------------------------------------------------*
* FB ROM tables
*----------------------------------------------------------------------------------*/
@@ -6429,24 +4821,6 @@ const float ivas_fb_cf_4ms_16k[IVAS_FB_4MS_16K_SAMP] =
0.9664963994f, 0.9747640903f, 0.9818880329f, 0.9878510650f, 0.9926388212f, 0.9962397673f, 0.9986452283f, 0.9998494093f,
};
-#ifdef IVAS_FLOAT_FIXED
-const Word16 ivas_fb_cf_4ms_48k_fx[IVAS_FB_4MS_48K_SAMP] =
-{
-0, 4, 13, 26, 44, 66, 92, 123, 158, 197, 241, 289, 341, 398, 458, 524, 593, 667, 744, 826, 913, 1003, 1097, 1196, 1298, 1405, 1516, 1630, 1749, 1871, 1998, 2128, 2262, 2400, 2541, 2687, 2836, 2988, 3144, 3304, 3467, 3634, 3804, 3977, 4154, 4334, 4517, 4704, 4893, 5086, 5282, 5480, 5682, 5886, 6094, 6304, 6516, 6732, 6949, 7170, 7393, 7618, 7846, 8076, 8308, 8542, 8779, 9017, 9258, 9500, 9744, 9990, 10238, 10487, 10738, 10990, 11244, 11499, 11756, 12014, 12273, 12533, 12794, 13056, 13319, 13582, 13847, 14112, 14378, 14644, 14911, 15178, 15446, 15713, 15981, 16249, 16518, 16786, 17054, 17321, 17589, 17856, 18123, 18389, 18655, 18920, 19185, 19448, 19711, 19973, 20234, 20494, 20753, 21011, 21268, 21523, 21777, 22029, 22280, 22529, 22777, 23023, 23267, 23509, 23750, 23988, 24225, 24459, 24691, 24921, 25149, 25374, 25597, 25818, 26035, 26251, 26463, 26673, 26881, 27085, 27287, 27485, 27681, 27874, 28063, 28250, 28433, 28613, 28790, 28963, 29133, 29300, 29463, 29623, 29779, 29931, 30080, 30226, 30367, 30505, 30639, 30769, 30896, 31018, 31137, 31251, 31362, 31469, 31571, 31670, 31764, 31854, 31941, 32023, 32100, 32174, 32243, 32309, 32369, 32426, 32478, 32526, 32570, 32609, 32644, 32675, 32701, 32723, 32741, 32754, 32763, 32767,
-};
-
-const Word16 ivas_fb_cf_4ms_32k_fx[IVAS_FB_4MS_32K_SAMP] =
-{
- 1, 11, 30, 60, 99, 149, 208, 276, 355, 443, 541, 648, 765, 891, 1026, 1171, 1325, 1488, 1660, 1840, 2030, 2228, 2435, 2650, 2873, 3105, 3345, 3592, 3847, 4110, 4380, 4657, 4941, 5233, 5530, 5835, 6146, 6463, 6786, 7115, 7449, 7789, 8134, 8483, 8838, 9197, 9561, 9928, 10300, 10675, 11054, 11435, 11820, 12208, 12598, 12990, 13385, 13781, 14179, 14578, 14978, 15379, 15780, 16182, 16585, 16987, 17388, 17789, 18189, 18588, 18986, 19382, 19777, 20169, 20559, 20947, 21332, 21713, 22092, 22467, 22839, 23206, 23570, 23929, 24284, 24633, 24978, 25318, 25652, 25981, 26304, 26621, 26932, 27237, 27534, 27826, 28110, 28387, 28657, 28920, 29175, 29422, 29662, 29894, 30117, 30332, 30539, 30737, 30927, 31107, 31279, 31442, 31596, 31741, 31876, 32002, 32119, 32226, 32324, 32412, 32491, 32559, 32618, 32668, 32707, 32737, 32756, 32766,
-};
-
-const Word16 ivas_fb_cf_4ms_16k_fx[IVAS_FB_4MS_16K_SAMP] =
-{
-4, 44, 123, 241, 398, 593, 826, 1097, 1405, 1749, 2128, 2541, 2988, 3467, 3977, 4517, 5086, 5682, 6304, 6949, 7618, 8308, 9017, 9744, 10487, 11244, 12014, 12794, 13582, 14378, 15178, 15981, 16786, 17589, 18389, 19185, 19973, 20753, 21523, 22280, 23023, 23750, 24459, 25149, 25818, 26463, 27085, 27681, 28250, 28790, 29300, 29779, 30226, 30639, 31018, 31362, 31670, 31941, 32174, 32369, 32526, 32644, 32723, 32763,
-};
-#endif
-
-
const float ivas_fb_fcs_12band_1ms[IVAS_FB_BANDS_12] =
{
0.0083333333f, 0.0250000000f, 0.0416666667f, 0.0583333333f,
@@ -6573,24 +4947,6 @@ const float ivas_fb_cf_1ms_16k[IVAS_FB_1MS_16K_SAMP] =
0.5490085702f, 0.6451423386f, 0.7356983684f, 0.8171966421f, 0.8865052267f, 0.9409606322f, 0.9784701679f, 0.9975923633f,
};
-#ifdef IVAS_FLOAT_FIXED
-const Word16 ivas_fb_cf_1ms_48k_fx[IVAS_FB_1MS_48K_SAMP] =
-{
- 8, 78, 218, 427, 705, 1050, 1460, 1934, 2470, 3066, 3718, 4425, 5184, 5990, 6840, 7732, 8660, 9622, 10612, 11627, 12663, 13715, 14778, 15847, 16920, 17989, 19052, 20104, 21140, 22155, 23145, 24107, 25035, 25927, 26777, 27583, 28342, 29049, 29701, 30297, 30833, 31307, 31717, 32062, 32340, 32549, 32689, 32759,
-};
-
-const Word16 ivas_fb_cf_1ms_32k_fx[IVAS_FB_1MS_32K_SAMP] =
-{
- 19, 177, 491, 957, 1573, 2330, 3224, 4244, 5381, 6624, 7960, 9378, 10864, 12403, 13979, 15580, 17187, 18788, 20364, 21903, 23389, 24807, 26143, 27386, 28523, 29543, 30437, 31194, 31810, 32276, 32590, 32748,
-};
-
-const Word16 ivas_fb_cf_1ms_16k_fx[IVAS_FB_1MS_16K_SAMP] =
-{
-78, 705, 1934, 3718, 5990, 8660, 11627, 14778, 17989, 21140, 24107, 26777, 29049, 30833, 32062, 32689,
- };
-
-#endif
-
const float ivas_fb_fr_12band_1ms_re[IVAS_FB_12_1MS_LEN] =
{
0.9748788957f, 0.9427895242f, 0.8792742509f, 0.7856320394f, 0.6637543553f, 0.5159842697f, 0.3449612971f, 0.1523029468f,
@@ -7634,22 +5990,6 @@ const float ivas_fb_resp_cheby_ramp_16del[IVAS_FB_1MS_16K_SAMP + 1] =
0.500000000000000f
};
-#ifdef IVAS_FLOAT_FIXED
-/* Q Factor is 31*/
-const Word32 ivas_fb_resp_cheby_ramp_32del_fx[IVAS_FB_1MS_32K_SAMP + 1] = {
- 21970992, 16097417, 21859084, 28772960, 36989692, 46636088, 57839904, 70755400, 85490472,
- 102165872, 120908192, 141807584, 164922576, 190321136, 218072144, 248214064, 280795872,
- 315834176, 353276992, 393021664, 435109696, 479474528, 525959424, 574472512, 624859584,
- 676981248, 730657728, 785668096, 841854208, 899002688, 956860544, 1015180800, 1073741824,
-};
-
-/* Q Factor is 31*/
-const Word32 ivas_fb_resp_cheby_ramp_16del_fx[IVAS_FB_1MS_16K_SAMP + 1] = {
- 23460896, 29872362, 47814248, 71691184, 102337872, 140498880, 186843680, 241748256, 305433120,
- 377921280, 458893152, 547769792, 643727232, 745668672, 852315136, 962208832, 1073741824,
-};
-#endif
-
const int16_t ivas_num_active_bands[FB - WB + 1] =
{
IVAS_16K_12BANDS_ACTIVE_BANDS, IVAS_FB_BANDS_12, IVAS_FB_BANDS_12
@@ -7796,140 +6136,6 @@ const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] =
0.2253418f, 2.2539062f, 2.265625f, 0.57128906f, -0.7661133f, -0.6245117f, 0.21313477f, 1.2248535f, 0.8737793f, -0.12524414f, -0.9609375f, -2.416504f, -1.1223145f, -0.70532227f, -0.31469727f, -0.592041f,
};
-#ifdef IVAS_FLOAT_FIXED
-/*Q12*/
-const Word16 ivas_sns_cdbk_tcx20_stage1_fx[ 128 * 16 ] =
-{
- -7498 , -8552 , -3948 , 11493 , 10929 , 4767 , 5696 , 4985 , 5673 , 1825 , -1927 , -2174 , -3321 , -4771 , -5964 , -7214 ,
- -10641 , -13643 , -7600 , -1477 , 6893 , 10597 , 4021 , 919 , -537 , 684 , 6146 , 1349 , 1375 , 4748 , 736 , -3571 ,
- 8121 , 9016 , 4721 , 3315 , 3543 , 4759 , 5279 , 5578 , 4435 , 3410 , 492 , -2942 , -8990 , -12493 , -13751 , -14493 ,
- 646 , 4522 , 1609 , -2654 , -4481 , -4275 , -4938 , -4698 , -4089 , -1547 , 1428 , 4430 , 5202 , 4974 , 3429 , 441 ,
- 1001 , -2898 , -4776 , -4824 , -1005 , 1623 , 4558 , 5049 , 5546 , 4459 , 3687 , 3688 , -126 , -3430 , -5243 , -7311 ,
- -3765 , -762 , -3030 , -6261 , -7149 , -5194 , -3869 , 997 , 5325 , 6801 , 5249 , 4107 , 2928 , 2308 , 1946 , 369 ,
- 10168 , 5956 , 3730 , 2771 , 2326 , 2853 , 3117 , 2884 , 1479 , -133 , -2832 , -4621 , -6076 , -6372 , -6981 , -8269 ,
- 9885 , 6118 , 4056 , 3729 , 2954 , 2262 , 382 , -887 , -2030 , -1996 , -3016 , -3773 , -4113 , -4045 , -4375 , -5152 ,
- -3335 , 5139 , 6949 , 5817 , 4078 , 4678 , 4112 , 3805 , 2705 , 921 , -2675 , -4919 , -5304 , -5636 , -7035 , -9300 ,
- -5726 , 774 , 1426 , -213 , -1582 , -1060 , -1381 , -448 , -337 , 307 , -78 , 485 , 1252 , 2090 , 2767 , 1723 ,
- 4376 , 8005 , 8723 , 8483 , 6453 , 4642 , 1740 , -811 , -3455 , -4423 , -5495 , -5697 , -5721 , -5357 , -5457 , -6006 ,
- 9786 , 10280 , 4686 , 1498 , -692 , -958 , 1101 , 3151 , 2236 , 2122 , -1101 , -3777 , -4952 , -6004 , -7796 , -9579 ,
- -5550 , 5500 , 6501 , 7932 , 2414 , 2004 , -724 , -797 , 465 , 79 , 1246 , -954 , -8806 , -5066 , -857 , -3387 ,
- 3592 , -6275 , -6564 , -5666 , -2347 , -3624 , -3711 , -4039 , -4858 , -5538 , -5004 , -2044 , 6173 , 16714 , 9046 , 14147 ,
- 16852 , 13619 , 9025 , 4301 , 605 , -1497 , -3065 , -3483 , -4472 , -4221 , -4897 , -5230 , -4820 , -4121 , -3894 , -4701 ,
- 3227 , 10297 , 4142 , -3143 , -5540 , -3558 , 1739 , 5927 , 5194 , 4741 , -1693 , -3809 , -3779 , -3780 , -3312 , -6653 ,
- -9100 , -5057 , -1642 , 2448 , -2023 , 4879 , 133 , 5593 , 1767 , 4924 , 6821 , 2411 , -1210 , -4078 , -4246 , -1619 ,
- -7619 , -11980 , 600 , 2505 , 2570 , -5562 , 1970 , -1802 , 2335 , 4846 , -4895 , 3392 , 5151 , 6508 , 2257 , -277 ,
- 8936 , 11845 , 11978 , 10584 , 9236 , 7186 , 3794 , 1874 , -708 , -3953 , -7322 , -9670 , -10750 , -10778 , -10917 , -11335 ,
- 8587 , 838 , -5142 , -8197 , -8172 , -5767 , -4419 , -1944 , -79 , 1853 , 3022 , 3823 , 4142 , 4618 , 3723 , 3112 ,
- -5283 , 568 , 1979 , 2570 , 2120 , 2234 , 1918 , 2247 , 1603 , 2038 , 1584 , -93 , -1478 , -3355 , -4339 , -4312 ,
- 3278 , 2345 , 280 , -2908 , -4330 , -3770 , -3036 , -1236 , 758 , 3245 , 3120 , 2288 , 1603 , 916 , -401 , -2152 ,
- 18828 , 10647 , 3579 , -3906 , -287 , 10855 , 5635 , -3673 , -6872 , -5289 , -2424 , -5462 , -6052 , -2769 , -4104 , -8707 ,
- -4121 , 2761 , 3751 , 4035 , 3218 , -38 , -1640 , -513 , -750 , -12 , -1597 , -1672 , -1522 , -637 , 42 , -1302 ,
- -5458 , 2924 , 6701 , 9084 , 6798 , 7952 , 4454 , 5450 , 5949 , 5277 , -2303 , -8307 , -11701 , -10523 , -8863 , -7432 ,
- 379 , 6294 , 8583 , 7842 , 6055 , 3554 , -1419 , -894 , -4610 , -4731 , -3777 , -2242 , -3681 , -3172 , -3323 , -4856 ,
- 9040 , 14426 , 8046 , 2314 , -89 , 612 , 655 , 895 , -4796 , -4631 , -1323 , -264 , -6051 , -6580 , -5728 , -6526 ,
- 10320 , 9632 , 5351 , 853 , -2496 , -4459 , -5580 , -5161 , -5476 , -4380 , -3281 , -1752 , -624 , 1835 , 2457 , 2762 ,
- 6230 , 4286 , 3054 , 2103 , 1411 , 882 , -116 , -345 , 353 , 511 , -1457 , -2334 , -2581 , -2840 , -3948 , -5209 ,
- -2351 , -845 , -4051 , -7663 , -8133 , -6619 , -6596 , -5580 , -3850 , -278 , 3739 , 7371 , 8632 , 9397 , 9551 , 7277 ,
- 14878 , 8087 , 1612 , -2811 , -4559 , -4173 , -3660 , -2457 , -1780 , -938 , -1082 , -880 , -541 , 40 , -680 , -1056 ,
- -357 , 6763 , 7507 , 2217 , 983 , 5824 , 3263 , 5362 , 4023 , 5140 , -7718 , -7703 , -6304 , -5528 , -5237 , -8233 ,
- -9056 , -2879 , 4548 , 9096 , 9567 , 8235 , 6713 , 5876 , 4240 , 2331 , -452 , -3615 , -6496 , -8240 , -9501 , -10367 ,
- -6591 , -10319 , -10037 , 1092 , 9508 , 10608 , 14496 , -4303 , -5138 , -1136 , 3886 , 5677 , 2912 , -4172 , -5188 , -1298 ,
- 3868 , 10098 , 10930 , 8191 , 5304 , 4169 , 3641 , 2883 , 1198 , -205 , -3154 , -5928 , -8536 , -10323 , -10806 , -11331 ,
- -580 , -1263 , -2402 , -5074 , -6014 , -4529 , -3202 , -2168 , -259 , 2212 , 3665 , 5339 , 5604 , 4695 , 3222 , 754 ,
- 1658 , -3851 , -5014 , -4529 , -1764 , -300 , 8217 , 16396 , 2000 , 824 , 665 , -1713 , -3175 , -3034 , -3057 , -3324 ,
- -11375 , -8634 , -6184 , -6208 , -4129 , -150 , 1519 , 4345 , 5629 , 5310 , 4007 , 4455 , 3926 , 3560 , 3104 , 823 ,
- 7473 , 12120 , 11294 , 4728 , 3568 , 5501 , 3688 , 3508 , 1692 , -1661 , -8566 , -9762 , -8843 , -8001 , -8086 , -8653 ,
- 8613 , 5171 , 4353 , 3298 , 925 , -530 , -1637 , -2214 , -3071 , -2941 , -3234 , -2961 , -2504 , -1211 , -880 , -1176 ,
- 621 , 10589 , 7196 , 3759 , 1529 , -659 , -1898 , -893 , -380 , -88 , -927 , -1736 , -2729 , -3606 , -4369 , -6410 ,
- -10687 , -7849 , -5755 , -6353 , -5913 , -3150 , -2865 , -1183 , -382 , 1696 , 2622 , 5191 , 7208 , 8842 , 10178 , 8401 ,
- -366 , 8121 , 9838 , 5330 , 503 , 3640 , 5493 , 4385 , 472 , -837 , -3977 , -9982 , -8797 , -5441 , -3061 , -5319 ,
- 10435 , 576 , -3431 , -5099 , -5048 , -3131 , -1414 , 1467 , 2492 , 2334 , 1243 , 257 , 1129 , 1454 , -1171 , -2093 ,
- -2408 , 4154 , 6243 , 5033 , 3118 , 2477 , 901 , 862 , 622 , 627 , -473 , -1897 , -2823 , -3803 , -5378 , -7253 ,
- 5751 , -3944 , -5457 , -3268 , 270 , -185 , -1373 , -2563 , -3758 , -4024 , -4052 , -3460 , -2709 , -237 , 9209 , 19800 ,
- 11172 , 15303 , 13936 , 10936 , 5606 , 374 , -3235 , -4534 , -5841 , -5872 , -6303 , -6525 , -6391 , -6176 , -6037 , -6414 ,
- 5173 , 10429 , 7690 , -211 , -4293 , -3886 , -1661 , 896 , 81 , -608 , -1808 , -2380 , -2191 , -1905 , -2123 , -3203 ,
- -8788 , -1052 , 5387 , 6699 , 5899 , 3671 , 3443 , 3830 , 4015 , 2746 , -536 , -2438 , -3985 , -4693 , -6124 , -8075 ,
- -8721 , -8773 , -1913 , 3002 , 5005 , -1141 , -1250 , 4860 , 3573 , -249 , 246 , 1790 , 3243 , 3739 , -189 , -3222 ,
- 12821 , 11330 , 7418 , 6142 , 4487 , 3660 , 3434 , 2422 , 898 , -805 , -4025 , -7013 , -9016 , -9871 , -10400 , -11484 ,
- 6459 , 1432 , -705 , -1814 , -2564 , -2337 , -2669 , -1789 , -1565 , -767 , -696 , -14 , 629 , 1614 , 2310 , 2475 ,
- 523 , 864 , 661 , 262 , 533 , 1619 , 2390 , 2554 , 2076 , 1532 , 248 , -542 , -1545 , -2462 , -3431 , -5282 ,
- 2754 , 7840 , 1531 , -5320 , -7337 , -5059 , -1828 , 2415 , 2801 , 2414 , 920 , -54 , -675 , 295 , 594 , -1290 ,
- 16459 , 9353 , 5397 , 5154 , 6401 , 4035 , 525 , -1206 , -2684 , -3963 , -5726 , -6290 , -6446 , -6516 , -6917 , -7575 ,
- 3331 , 2764 , 1820 , 1449 , 404 , 197 , -617 , -518 , -755 , -625 , -1250 , -1192 , -1278 , -978 , -1091 , -1661 ,
- 1202 , 10867 , 13999 , 10573 , 8667 , 5713 , 3901 , 1699 , -649 , -3697 , -6326 , -8102 , -9055 , -9334 , -9517 , -9940 ,
- 3105 , 10471 , 11637 , 9256 , 1588 , -4373 , -5838 , -3257 , -2501 , -2719 , -3963 , -4248 , -3642 , -2230 , -780 , -2506 ,
- 7036 , 12562 , 13320 , 10158 , 3016 , -3341 , -3328 , 586 , 1408 , -1129 , -5924 , -5878 , -5793 , -6843 , -7570 , -8279 ,
- 11292 , 4466 , 2522 , 790 , -1414 , -1946 , -1506 , -261 , 583 , 802 , -656 , -1773 , -2651 , -2250 , -3307 , -4691 ,
- 4319 , 4371 , 4567 , 4600 , 3221 , 2633 , 1994 , 1398 , 564 , -536 , -2662 , -3664 , -4402 , -4565 , -5348 , -6489 ,
- -7437 , -5416 , -5951 , -7745 , -7676 , -4554 , -4813 , -2349 , 668 , 6481 , 8239 , 7629 , 6574 , 6530 , 6295 , 3525 ,
- 13292 , 11390 , 5199 , 2139 , 489 , -271 , -644 , -427 , -1114 , -1854 , -3425 , -4756 , -5461 , -5211 , -4922 , -4424 ,
- 710 , 9953 , 9525 , 5612 , 1946 , 2958 , 298 , -154 , -1714 , -3333 , -6410 , -9882 , -5524 , -2172 , -432 , -1382 ,
- -10643 , -8047 , -2326 , 2007 , 3553 , 2546 , 4871 , 5435 , 4843 , 4106 , 2244 , 1050 , -497 , -1808 , -2878 , -4457 ,
- 294 , -9337 , -8427 , -1045 , 9093 , 10411 , 3417 , 3239 , 2068 , -534 , 1078 , -1517 , -2125 , -1732 , -2738 , -2145 ,
- 5432 , 12777 , 10582 , 2772 , -92 , 2136 , 2501 , 4105 , 2738 , 3539 , -1530 , -8480 , -9513 , -8753 , -8426 , -9787 ,
- 5972 , 8255 , 4335 , -524 , -2484 , -2872 , -3937 , -3518 , -3037 , -774 , 635 , 1891 , 1590 , 660 , -1520 , -4672 ,
- 6572 , 3645 , -218 , -1090 , 345 , 2321 , 3692 , 4654 , 4719 , 3041 , 2117 , 459 , -3402 , -7045 , -8640 , -11170 ,
- -5410 , -344 , -990 , -3893 , -5051 , -2311 , -77 , 3918 , 4679 , 4822 , 3303 , 1776 , 337 , 305 , 409 , -1472 ,
- 8389 , 11222 , 8707 , 4721 , 3131 , 2061 , 1130 , 791 , -354 , -651 , -3686 , -5202 , -6383 , -7339 , -7792 , -8746 ,
- 9298 , 9362 , 6305 , 3177 , 968 , -72 , -945 , -819 , -1079 , -725 , -2067 , -2739 , -3434 , -4331 , -5460 , -7441 ,
- 2704 , 6870 , 6571 , 6294 , 4511 , 3348 , 2296 , 2931 , 2159 , 954 , -1545 , -3421 , -5465 , -7201 , -9296 , -11710 ,
- 880 , -1826 , -3492 , -4233 , -3893 , -2425 , -1948 , -823 , -259 , 657 , 1000 , 2107 , 2906 , 3603 , 3958 , 3790 ,
- -196 , 6860 , 8581 , 9562 , 7277 , 7244 , 1471 , 1946 , -228 , -338 , -3115 , -7547 , -11656 , -9838 , -4686 , -5339 ,
- 8578 , 4837 , 2226 , 754 , -1817 , -2201 , 499 , 2914 , 3313 , 3158 , -527 , -4733 , -5791 , -4100 , -3403 , -3706 ,
- -4232 , 6556 , 1920 , 6615 , -946 , 4468 , 280 , 2157 , 766 , -524 , -922 , -1974 , -2072 , -1600 , -4968 , -5524 ,
- 7288 , 2936 , -1640 , -4588 , -6332 , -6285 , -6188 , -5571 , -5223 , -3844 , -1671 , 2013 , 5110 , 8289 , 8345 , 7362 ,
- 11493 , 11342 , 6954 , 1821 , -1692 , -2612 , -3300 , -3319 , -3814 , -2738 , -2931 , -2814 , -2479 , -1890 , -1719 , -2303 ,
- 8177 , 11903 , 6525 , -1422 , -3274 , 251 , 4220 , 4653 , 3045 , -303 , -5550 , -5079 , -5244 , -5314 , -5883 , -6703 ,
- -9438 , -3031 , 483 , 1317 , 1847 , 1874 , 3018 , 2956 , 788 , 3090 , 730 , -1912 , -1688 , 122 , 860 , -1017 ,
- -3693 , -4977 , -541 , 2877 , 3327 , -2337 , -4262 , -2189 , 699 , 2375 , 3310 , 1962 , 1504 , 1017 , 1319 , -390 ,
- 6065 , 7469 , 7234 , 10424 , 10658 , 7912 , 5388 , 4640 , 2156 , -733 , -4795 , -9010 , -11277 , -11766 , -11999 , -12365 ,
- 10932 , 2437 , -1845 , -3262 , -3753 , -3716 , -4031 , -3422 , -2848 , -1620 , -1167 , 176 , 1764 , 2966 , 3342 , 4047 ,
- -619 , -1377 , -1334 , -455 , -198 , 333 , 279 , 702 , 835 , 1061 , 505 , 476 , 127 , 254 , 270 , -859 ,
- 5215 , 1197 , -575 , -1227 , -2612 , -2325 , -649 , 1885 , 2691 , 2793 , 1163 , -765 , -1768 , -1371 , -1567 , -2082 ,
- 19164 , 11491 , 4615 , -1985 , -3389 , 3234 , 9530 , 1792 , -6657 , -7546 , -6135 , -3576 , -5395 , -6848 , -4207 , -4089 ,
- -5579 , 2618 , 4644 , 1302 , 270 , 4372 , 3748 , 1797 , -752 , -937 , -2728 , -2859 , -706 , -865 , -1022 , -3304 ,
- -1838 , 6025 , 10256 , 11080 , 7972 , 1492 , -1232 , 2649 , 3965 , 3980 , -6137 , -7448 , -7596 , -7566 , -6578 , -9023 ,
- 1944 , 6450 , 7024 , 8636 , 7062 , 1810 , -1661 , -772 , 542 , -13 , -3255 , -4851 , -5285 , -5086 , -5501 , -7043 ,
- 8123 , 16086 , 12234 , 5222 , 1088 , 112 , 327 , 1928 , -3259 , -5187 , -6713 , -7464 , -5697 , -5814 , -5336 , -5649 ,
- 859 , 7375 , 6059 , 2544 , 375 , -1579 , -3831 , -3783 , -3738 , -2686 , -2393 , -1129 , 29 , 1048 , 1033 , -183 ,
- 2101 , 4211 , 3442 , 2574 , 2178 , 2151 , 1104 , 386 , 135 , -216 , -2007 , -2668 , -2626 , -2609 , -3456 , -4701 ,
- -5046 , -336 , -968 , -3416 , -4451 , -3637 , -4472 , -3410 , -3255 , -1874 , -1058 , 1763 , 4855 , 7351 , 9606 , 8347 ,
- 19995 , 9006 , 2634 , -634 , -1483 , -1947 , -2216 , -805 , -298 , -446 , -2156 , -3518 , -3871 , -4075 , -4720 , -5467 ,
- -2272 , 8650 , 9022 , 2896 , -866 , 3555 , 4656 , 4146 , 4057 , 5105 , 893 , -7960 , -11942 , -9282 , -3999 , -6659 ,
- -3314 , 4163 , 6336 , 8539 , 7909 , 6703 , 4331 , 4759 , 3115 , 1223 , -1904 , -4488 , -6662 , -8210 , -10273 , -12228 ,
- -1219 , -6996 , -6238 , 5560 , 19256 , 6948 , 16806 , -1718 , -4399 , -4432 , 1743 , -4434 , -5576 , -4824 , -5420 , -5055 ,
- 7337 , 7092 , 7560 , 9007 , 7842 , 4106 , 2111 , 1823 , -310 , -2228 , -4758 , -6480 , -7636 , -7833 , -8350 , -9284 ,
- -127 , -7162 , -7239 , -8124 , -5968 , -3470 , -2064 , 167 , 1784 , 2556 , 3741 , 6051 , 7042 , 5293 , 3278 , 4242 ,
- -4837 , -8327 , -8445 , -7964 , -6737 , -3635 , 12584 , 10749 , 9489 , 14113 , 4466 , -818 , -963 , -2829 , -1662 , -5183 ,
- -9221 , -7856 , -8616 , -9610 , -8803 , -4648 , -2322 , 3345 , 7609 , 8661 , 7189 , 7848 , 6804 , 4876 , 3375 , 1368 ,
- 3370 , 8415 , 9491 , 3696 , 2112 , 4195 , 2535 , 1216 , -704 , -2599 , -4917 , -4773 , -4766 , -4924 , -5695 , -6652 ,
- 5033 , 6480 , 5225 , 2803 , 1389 , 388 , -1095 , -1930 , -1285 , -783 , -2330 , -2783 , -2299 , -2271 , -2847 , -3696 ,
- 6462 , 10974 , 9445 , 5632 , 3121 , 338 , -2526 , -3512 , -4157 , -4256 , -4496 , -3576 , -3213 , -3003 , -3042 , -4191 ,
- -8903 , -5489 , -3362 , -3932 , -2867 , -42 , -794 , 1047 , 1551 , 2990 , 1925 , 1809 , 2047 , 3857 , 5983 , 4180 ,
- -1078 , 5534 , 5668 , 8546 , 7579 , 7727 , 3515 , 2403 , 425 , -3939 , -7676 , -10486 , -4654 , -3810 , -5900 , -3854 ,
- 11241 , 2333 , -888 , -2668 , -601 , 2056 , 973 , -782 , -1134 , -628 , -1278 , -1464 , -1036 , -1025 , -2566 , -2532 ,
- 188 , 993 , 1510 , 3746 , 3964 , 4113 , 3912 , 3774 , 2904 , 1760 , -544 , -2262 , -3823 , -5032 , -6585 , -8617 ,
- 17244 , 5164 , -3514 , -5803 , -5740 , -3512 , -4264 , -5949 , -7105 , -7263 , -6297 , -4203 , 3488 , 882 , 9119 , 17753 ,
- 18572 , 16918 , 11329 , 8930 , 3706 , 2301 , -534 , -4811 , -6296 , -6264 , -6923 , -7015 , -7012 , -7183 , -7628 , -8090 ,
- 2776 , 9267 , 4870 , -2407 , -3332 , 1594 , 479 , 626 , -2334 , -2117 , -1714 , -1452 , -1892 , -1016 , -575 , -2774 ,
- -5418 , -1560 , 977 , 3118 , 4128 , 4683 , 3995 , 3168 , 1326 , 367 , -798 , -1786 , -2341 , -2513 , -3011 , -4334 ,
- -5417 , -6011 , -5325 , -2432 , 93 , 2347 , 2339 , 1497 , 2097 , 3182 , 2553 , 1778 , 1688 , 2154 , 997 , -1540 ,
- 9725 , 13565 , 12472 , 9916 , 5050 , 2613 , 1338 , 621 , -1049 , -4212 , -7066 , -8072 , -8504 , -8673 , -8645 , -9079 ,
- 3568 , 2083 , 779 , -447 , -1488 , -1526 , -2026 , -1584 , -1564 , -893 , -955 , -362 , 96 , 991 , 1665 , 1663 ,
- 4308 , 2100 , 967 , 1304 , 1477 , 1636 , 1557 , 2064 , 2234 , 1529 , -1013 , -2413 , -2782 , -3000 , -4202 , -5767 ,
- -2729 , 7254 , 5313 , 626 , -4368 , -3106 , 689 , 2051 , 1436 , 577 , 2137 , -551 , -4980 , -1408 , 137 , -3079 ,
- 15090 , 13574 , 8552 , 4879 , 2489 , 603 , 625 , 413 , -965 , -1853 , -5221 , -7106 , -7498 , -7482 , -7752 , -8349 ,
- 2370 , 3151 , 1957 , 225 , -516 , -337 , -392 , 223 , 813 , 1307 , 124 , -276 , -702 , -1169 , -2432 , -4348 ,
- -4031 , 4338 , 9696 , 9577 , 10361 , 8623 , 7730 , 5093 , 2251 , -518 , -3768 , -6931 , -9490 , -10533 , -10950 , -11448 ,
- 10303 , 15787 , 11780 , 8011 , -1234 , -5671 , -6127 , -5176 , -4588 , -3477 , -4783 , -2583 , -2036 , -3150 , -2990 , -4066 ,
- 1649 , 10539 , 12961 , 10244 , 5607 , -356 , -2601 , -488 , 30 , -2077 , -2877 , -8331 , -8515 , -7727 , -3810 , -4247 ,
- 8997 , 5275 , 2084 , -488 , -2018 , -2461 , -3081 , -2315 , -2223 , -1654 , -1778 , -1155 , -563 , 285 , 587 , 507 ,
- 2053 , 8908 , 7041 , 522 , -1083 , 1920 , 1555 , 2991 , 959 , 1714 , -3254 , -3680 , -2792 , -4401 , -4878 , -7576 ,
- -9455 , -8989 , -9057 , -10160 , -9541 , -6763 , -5661 , -3200 , -593 , 3501 , 6901 , 10117 , 10416 , 11442 , 11927 , 9115 ,
- 7190 , 11877 , 7889 , 1661 , -96 , 1823 , 1276 , 741 , -1950 , -1969 , -4935 , -5445 , -5084 , -4151 , -3666 , -5162 ,
- 923 , 9232 , 9280 , 2340 , -3138 , -2558 , 873 , 5017 , 3579 , -513 , -3936 , -9898 , -4597 , -2889 , -1289 , -2425 ,
-};
-#endif
const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] =
{
-1.1569824f, -0.4765625f, 0.008056641f, 0.47802734f, 0.38330078f, -0.075683594f, -0.3737793f, -0.29516602f, -0.1352539f, 0.012939453f, 0.22241211f, 0.375f, 0.31689453f, 0.20874023f, 0.2541504f, 0.25439453f,
@@ -7997,76 +6203,7 @@ const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] =
0.3227539f, -1.0678711f, -1.1435547f, 0.068603516f, 0.7546387f, 0.38745117f, 0.09008789f, -0.0007324219f, -0.12792969f, 0.076416016f, 0.24853516f, 0.28735352f, 0.076660156f, -0.041748047f, -0.01977539f, 0.08911133f,
0.6101074f, -0.22070312f, -0.5324707f, -0.119384766f, 0.10473633f, 0.16333008f, -0.15112305f, -0.34472656f, -0.39746094f, -0.43652344f, -0.23876953f, 0.0017089844f, 0.056152344f, 0.22973633f, 0.50024414f, 0.7751465f,
};
-#ifdef IVAS_FLOAT_FIXED
-/*Q12*/
-const Word16 ivas_sns_cdbk_tcx20_stage2_fx[ 64 * 16 ] =
-{
- -4739 , -1952 , 33 , 1958 , 1570 , -310 , -1531 , -1209 , -554 , 53 , 911 , 1536 , 1298 , 855 , 1041 , 1042 ,
- -1663 , -904 , -175 , 651 , -1032 , -2713 , -1113 , 1177 , 1464 , 826 , 214 , -1494 , -1846 , 763 , 2736 , 3107 ,
- 112 , -859 , -1631 , -2224 , -1919 , -1030 , -1104 , -307 , 1536 , 3827 , 3753 , 1748 , 107 , -638 , -468 , -902 ,
- 46 , 1539 , 3454 , 2870 , 2388 , -2034 , -3447 , -1887 , -692 , -27 , -310 , -923 , -859 , -521 , 27 , 377 ,
- 1736 , 793 , 312 , 1806 , 467 , -1631 , -500 , 1432 , 2116 , -102 , -2181 , -280 , 2082 , -270 , -2800 , -2981 ,
- -499 , 628 , 1238 , 973 , 1115 , 3296 , 3147 , 1180 , -225 , -1217 , -1869 , -1759 , -1756 , -1809 , -1438 , -1005 ,
- -814 , -42 , -125 , -171 , 215 , 305 , 107 , -109 , 761 , 921 , 805 , 630 , 183 , -456 , -1018 , -1190 ,
- 3133 , 1965 , 1284 , 613 , 952 , 693 , 240 , -514 , -738 , -801 , -702 , -785 , -963 , -1364 , -1554 , -1460 ,
- -2540 , -1194 , -624 , 654 , 1697 , 2507 , 1824 , 793 , -441 , -1656 , -427 , 1665 , 1549 , -53 , -1580 , -2175 ,
- -2612 , -80 , 1350 , -1143 , -868 , 3411 , 1168 , -1279 , -1792 , -1401 , -43 , 224 , 407 , 470 , 941 , 1247 ,
- -3135 , -2208 , -1570 , -1618 , -898 , 791 , 778 , -354 , -184 , 553 , 1861 , 2776 , 2413 , 1232 , 177 , -614 ,
- 1427 , -894 , 74 , 274 , 1641 , 1416 , -2247 , -3524 , -984 , 2485 , 916 , -207 , 570 , 111 , -306 , -753 ,
- 567 , 223 , 845 , -469 , -3177 , -2357 , 2872 , 824 , -1392 , 757 , 1566 , -859 , -167 , 552 , 315 , -101 ,
- -1017 , -1966 , -2969 , -2645 , -1036 , 1791 , 2595 , 2648 , 2209 , 1368 , 569 , 1255 , 1349 , -305 , -1605 , -2241 ,
- -180 , -2117 , -1548 , 2748 , 1044 , -1910 , -2213 , -915 , 378 , 69 , 1015 , 1919 , 2044 , 1120 , -379 , -1075 ,
- 61 , 1450 , 1443 , -536 , -2041 , -2153 , -241 , 101 , -1208 , -1900 , -710 , 1553 , 1938 , 1209 , 785 , 249 ,
- -871 , -3584 , -3398 , -2068 , -1304 , -586 , 802 , 1195 , 1173 , 629 , 692 , 918 , 1136 , 1304 , 1676 , 2286 ,
- -5190 , 69 , 1485 , 2699 , 2450 , 2023 , 739 , 746 , 653 , -67 , -772 , -1497 , -1398 , -1046 , -609 , -285 ,
- 436 , 3227 , 395 , -2370 , -1678 , 289 , 1631 , 1271 , 450 , 574 , 1098 , 1346 , 176 , -1624 , -2479 , -2743 ,
- -2034 , 1082 , 2695 , 1685 , 1183 , 915 , 636 , -341 , -486 , 350 , 1164 , 625 , -760 , -1982 , -2380 , -2349 ,
- 914 , 1532 , 886 , -2080 , -3920 , -4687 , -1446 , 2800 , 2748 , 1303 , 524 , -634 , -11 , 747 , 691 , 632 ,
- 1084 , -467 , -438 , 1087 , 2116 , 2201 , 1470 , 691 , 853 , 987 , 574 , -224 , -1366 , -2404 , -3041 , -3123 ,
- 3022 , -593 , -1542 , -411 , 421 , 580 , 276 , -223 , -67 , -96 , -91 , -202 , -250 , -445 , -371 , -7 ,
- 4287 , 2796 , 539 , -861 , -426 , -868 , -1334 , -1937 , -2448 , -2081 , -837 , 139 , 474 , 386 , 738 , 1432 ,
- -3717 , -1050 , 587 , 144 , -312 , -549 , -30 , 857 , 1641 , 2410 , 2657 , 2049 , 788 , -915 , -1966 , -2594 ,
- 1656 , 90 , 245 , 2403 , 4979 , 1448 , -716 , -288 , -387 , -1023 , -1625 , -1371 , -1425 , -1584 , -1505 , -899 ,
- 2943 , -214 , -1605 , -563 , 565 , 838 , 558 , -616 , -919 , -1002 , 498 , 2396 , 2264 , -116 , -2465 , -2562 ,
- 29 , 1348 , 1688 , 136 , -859 , -273 , -627 , 84 , 1360 , 3635 , 2904 , -1691 , -2928 , -2031 , -1197 , -1576 ,
- -3472 , 1420 , 442 , -1499 , -1990 , -1702 , -1566 , -1104 , 78 , 1033 , 1640 , 1632 , 1574 , 1220 , 1212 , 1081 ,
- 1953 , -23 , -627 , -1383 , -1259 , 1004 , 3624 , 2500 , -1346 , -2634 , -1795 , -778 , -511 , -345 , 456 , 1163 ,
- 4332 , -964 , -3948 , -3470 , 1285 , 4835 , 3224 , 584 , -77 , -893 , -848 , -484 , -428 , -664 , -1430 , -1053 ,
- -117 , -1788 , -833 , 558 , 730 , 891 , -108 , -1659 , -2651 , -2745 , -1081 , 1583 , 2809 , 2204 , 1191 , 1018 ,
- -1345 , -373 , -461 , -1404 , -2370 , -2179 , -1860 , -1422 , -886 , -763 , -387 , 596 , 1341 , 2668 , 4449 , 4396 ,
- 703 , 1081 , 785 , 116 , -226 , 588 , 371 , 128 , -841 , -1511 , -2399 , -3059 , -3098 , -175 , 3474 , 4064 ,
- 2514 , -777 , -1994 , -1860 , -1724 , -1633 , -1409 , -1049 , -426 , 483 , 1396 , 1809 , 1677 , 1298 , 934 , 762 ,
- -2407 , 787 , 1259 , 1895 , 1549 , 339 , -1486 , -2126 , -2176 , -1736 , -1109 , -617 , -109 , 887 , 2228 , 2818 ,
- -2370 , -192 , 160 , -107 , 141 , -1165 , -2137 , 299 , 2936 , 3445 , -1416 , -1420 , 1045 , 1309 , 500 , -1029 ,
- -803 , 477 , 733 , 1105 , 1659 , 1199 , 396 , -525 , -596 , -699 , -668 , -547 , -466 , -585 , -527 , -153 ,
- -854 , -1179 , -969 , -484 , 67 , 243 , 278 , -137 , -55 , 12 , 281 , 514 , 599 , 462 , 461 , 759 ,
- -555 , 4717 , 2129 , -264 , -987 , -522 , -88 , -291 , -391 , -491 , -515 , -766 , -855 , -879 , -331 , 88 ,
- -1373 , -2671 , -1199 , 3480 , 2467 , 1443 , 608 , 260 , -542 , -1600 , -1685 , -1118 , -694 , -114 , 750 , 1987 ,
- 934 , 3323 , 1049 , -2373 , 769 , 3068 , 503 , -1591 , -2364 , -3449 , -3986 , -3071 , 844 , 5877 , 941 , -474 ,
- -425 , 228 , -1215 , -1583 , -1505 , -1579 , -934 , -791 , -484 , -477 , 1056 , 4177 , 4488 , 3123 , -786 , -3291 ,
- 1305 , -1331 , -1055 , 1844 , 3061 , 1077 , -2285 , -2600 , 230 , 4597 , 1138 , -3419 , -3967 , -827 , 2157 , 77 ,
- 997 , 210 , -659 , -997 , -624 , 153 , 286 , -62 , -2489 , 591 , 3868 , 1520 , -1263 , -1424 , -494 , 387 ,
- 550 , 1926 , -1797 , -3507 , -2499 , -447 , 586 , 751 , 425 , -141 , -276 , 149 , 519 , 762 , 1372 , 1626 ,
- 4225 , -2078 , 205 , 1305 , -229 , -2501 , -1305 , -231 , 298 , 233 , -219 , -284 , -355 , -157 , 196 , 896 ,
- 1933 , 2394 , 2521 , -320 , -2587 , -3794 , -3666 , -1887 , -607 , -128 , 189 , 577 , 518 , 1040 , 1956 , 1861 ,
- -4582 , -2223 , -1479 , -548 , -20 , 1204 , 1867 , 1627 , 992 , -767 , -2361 , -1057 , 474 , 2119 , 2744 , 2011 ,
- -3537 , -810 , -278 , -246 , 338 , 2203 , 3 , -278 , -22 , 2105 , 1761 , -1452 , -2749 , -633 , 2262 , 1334 ,
- 2549 , 1831 , 1526 , 633 , -570 , -1662 , -2041 , -1590 , -568 , 965 , 2087 , 1627 , 325 , -934 , -1811 , -2366 ,
- -2625 , 735 , 4126 , 1924 , -1352 , -1375 , -67 , -263 , -332 , -611 , -223 , 69 , -41 , -365 , -50 , 449 ,
- 1945 , -542 , 862 , 1501 , -463 , -3503 , -3203 , 3338 , 4340 , -1886 , -1472 , -176 , -899 , -1007 , 153 , 1012 ,
- 1176 , -2807 , 927 , 489 , -701 , -1222 , 1377 , 2025 , 1740 , 704 , 835 , 366 , -857 , -1584 , -1462 , -1007 ,
- 1374 , 1113 , 165 , -297 , -35 , -391 , -815 , -1221 , -716 , -497 , -249 , 51 , 360 , 245 , 279 , 635 ,
- 4741 , 2291 , -661 , -1808 , -1569 , -1013 , -23 , 449 , 899 , 914 , -15 , -826 , -1123 , -1159 , -870 , -227 ,
- -3095 , -3457 , -326 , 1213 , 999 , 1504 , 2296 , 1487 , 1074 , 733 , 257 , -216 , -595 , -863 , -635 , -376 ,
- 1313 , 1943 , 2320 , 2119 , 1731 , 1184 , 521 , -954 , -2164 , -2882 , -2594 , -1657 , -957 , -667 , -49 , 792 ,
- -225 , 2104 , 1245 , 2010 , 1467 , -381 , -1564 , -1777 , -2347 , -1964 , -723 , 1747 , 2298 , 1153 , -937 , -2106 ,
- 1110 , -1091 , -1843 , -326 , 890 , 1762 , 1723 , 1959 , 2404 , 1131 , -1081 , -2694 , -2783 , -1612 , -483 , 933 ,
- -3280 , 740 , 493 , -1621 , -2458 , -538 , 3182 , 2390 , 1740 , 648 , 349 , -246 , -677 , -725 , -96 , 98 ,
- 1151 , 1644 , 2333 , 571 , -841 , -749 , 1667 , 2880 , 2249 , 381 , -1951 , -2564 , -2038 , -1604 , -1690 , -1440 ,
- 1322 , -4374 , -4684 , 281 , 3091 , 1587 , 369 , -3 , -524 , 313 , 1018 , 1177 , 314 , -171 , -81 , 365 ,
- 2499 , -904 , -2181 , -489 , 429 , 669 , -619 , -1412 , -1628 , -1788 , -978 , 7 , 230 , 941 , 2049 , 3175
-};
-#endif
+
const float ivas_sns_cdbk_tcx20_stage3[ 32 * 16 ] =
{
-0.12109375f, -0.32348633f, -0.25976562f, 0.21435547f, 0.4814453f, 0.14819336f, -0.22363281f, -0.31030273f, -0.13256836f, 0.10107422f, 0.33276367f, 0.32495117f, 0.16577148f, -0.079833984f, -0.16210938f, -0.15527344f,
@@ -8102,44 +6239,7 @@ const float ivas_sns_cdbk_tcx20_stage3[ 32 * 16 ] =
0.17895508f, -0.31396484f, -0.033203125f, -0.02734375f, -0.0637207f, -0.11791992f, -0.03466797f, 0.0061035156f, 0.07324219f, 0.072753906f, 0.14916992f, 0.13671875f, 0.12524414f, 0.017333984f, -0.08178711f, -0.08618164f,
0.13330078f, -0.15893555f, -0.22045898f, -0.032226562f, -0.07739258f, -0.25463867f, -0.32299805f, -0.2614746f, 0.039794922f, 0.18554688f, 0.1262207f, -0.04321289f, -0.010498047f, 0.13330078f, 0.31860352f, 0.44506836f,
};
-#ifdef IVAS_FLOAT_FIXED
-/*Q12*/
-const Word16 ivas_sns_cdbk_tcx20_stage3_fx[32 * 16] =
-{
- -496 , -1325 , -1064 , 878 , 1972 , 607 , -916 , -1271 , -543 , 414 , 1363 , 1331 , 679 , -327 , -664 , -636 ,
- 362 , -60 , -548 , -1188 , 3577 , -1280 , -794 , 791 , -404 , 216 , -537 , -90 , -322 , -81 , -302 , 662 ,
- -474 , 1151 , 1105 , -431 , -442 , -1174 , -1503 , -1387 , -649 , 79 , 712 , 865 , 1105 , 707 , 299 , 37 ,
- 334 , 155 , -1060 , -1247 , -263 , 534 , 1502 , 1635 , 1393 , 587 , -48 , -494 , -698 , -945 , -853 , -533 ,
- -102 , -2580 , 3220 , -45 , -520 , -353 , 93 , 202 , 19 , -559 , -404 , 0 , 267 , 59 , 248 , 455 ,
- -1614 , 689 , 1170 , -355 , -659 , 214 , 1065 , 234 , -205 , -321 , 68 , 241 , 302 , -162 , -349 , -318 ,
- 49 , -471 , -419 , -290 , 40 , -128 , -639 , -61 , 432 , -165 , -1970 , -1140 , 2419 , 2709 , 567 , -934 ,
- 1995 , 749 , -847 , -723 , -809 , -1302 , -1034 , 36 , 1174 , 1053 , 777 , 479 , 202 , -226 , -725 , -798 ,
- 503 , -396 , 223 , 711 , 939 , 1443 , 1651 , 131 , -658 , -607 , -422 , -361 , -558 , -963 , -997 , -639 ,
- -2380 , -60 , -1779 , -303 , 1247 , 1476 , 787 , 528 , 535 , 131 , -102 , -243 , -199 , -125 , 129 , 359 ,
- -480 , 67 , 624 , 1594 , 1140 , -29 , -302 , -842 , -1229 , -1468 , -958 , -139 , 349 , 447 , 512 , 716 ,
- -441 , 257 , -20 , 524 , -98 , -901 , -345 , 1409 , 932 , -1626 , -1328 , 1998 , 1784 , -632 , -919 , -596 ,
- 13 , -162 , 276 , -73 , -1083 , 1249 , 1237 , -1331 , -2051 , 634 , 2497 , 636 , -778 , -595 , 73 , -539 ,
- 150 , -478 , -1380 , -2201 , -557 , 1248 , 1317 , -435 , -672 , -351 , 51 , 444 , 824 , 719 , 625 , 695 ,
- -1787 , -1936 , -691 , -455 , -726 , -586 , 62 , 521 , 559 , 532 , 788 , 935 , 953 , 717 , 592 , 523 ,
- -307 , 803 , 537 , -415 , -32 , -772 , -200 , 1387 , 1056 , -700 , -1667 , -1182 , -198 , 200 , 611 , 879 ,
- -1136 , -297 , 1067 , 1599 , 933 , 85 , -496 , -329 , 704 , 1505 , 440 , -791 , -926 , -846 , -811 , -698 ,
- 554 , 1640 , -641 , -1038 , 1272 , 2216 , -1350 , -1756 , 606 , 710 , -732 , -972 , -109 , -55 , -189 , -155 ,
- -1245 , 526 , 853 , -490 , -1359 , -1307 , -459 , 418 , 1330 , 1485 , 1076 , 66 , -528 , -675 , -21 , 330 ,
- 1408 , 1470 , 1952 , 558 , -474 , -218 , 330 , -50 , -91 , -404 , -330 , -556 , -753 , -1070 , -1056 , -717 ,
- 48 , -64 , 1098 , -961 , -1463 , 2614 , -1256 , 333 , -225 , 412 , -110 , -417 , -56 , -260 , 2 , 305 ,
- -416 , 207 , 378 , 157 , -143 , 675 , 352 , 15 , -633 , -373 , 108 , -981 , -1789 , -1138 , 895 , 2685 ,
- -658 , 135 , 341 , 217 , -171 , 367 , 678 , 235 , -334 , 875 , 199 , -2878 , -1134 , 2089 , 1114 , -1075 ,
- 2544 , 16 , 331 , 686 , 339 , -461 , -853 , -1260 , -1021 , -628 , 3 , 359 , 463 , 93 , -282 , -329 ,
- 1673 , -1600 , -1453 , 892 , 900 , -44 , 456 , 879 , 586 , -366 , -785 , -970 , -549 , -140 , 126 , 396 ,
- -901 , 3362 , -1315 , 487 , -27 , -544 , 32 , -54 , -225 , -100 , 268 , -6 , -228 , -277 , -289 , -183 ,
- -605 , -695 , -453 , 2594 , -1649 , -1440 , 1218 , 352 , 100 , -292 , 42 , 3 , -89 , 81 , 342 , 494 ,
- -276 , 125 , 78 , 668 , 688 , 152 , 243 , 303 , 145 , 226 , 286 , 252 , 795 , 844 , -1302 , -3227 ,
- 522 , -167 , -889 , -105 , 51 , -136 , -646 , 213 , -785 , -1079 , 132 , 3267 , -1969 , -884 , 1495 , 982 ,
- 1886 , 878 , 347 , -1000 , -2044 , -679 , 1235 , 203 , -306 , -879 , -543 , -38 , 273 , 119 , 160 , 390 ,
- 733 , -1286 , -136 , -112 , -261 , -483 , -142 , 25 , 300 , 298 , 611 , 560 , 513 , 71 , -335 , -353 ,
- 546 , -651 , -903 , -132 , -317 , -1043 , -1323 , -1071 , 163 , 760 , 517 , -177 , -43 , 546 , 1305 , 1823
-};
-#endif
+
const float ivas_sns_cdbk_tcx20_stage4[ 32 * 16 ] =
{
-0.0056152344f, -0.03955078f, 0.071777344f, 0.26879883f, 0.44140625f, -0.08203125f, -0.20092773f, -0.009277344f, 0.05810547f, -0.06347656f, -0.07910156f, -0.05126953f, -0.07006836f, -0.068847656f, -0.07885742f, -0.09082031f,
@@ -8176,49 +6276,8 @@ const float ivas_sns_cdbk_tcx20_stage4[ 32 * 16 ] =
-0.0017089844f, -0.014160156f, -0.048339844f, -0.037109375f, -0.0949707f, -0.005859375f, 0.48388672f, -0.17480469f, -0.19140625f, 0.5727539f, -0.18920898f, -0.26391602f, 0.0048828125f, 0.067871094f, -0.045654297f, -0.06201172f,
};
-#ifdef IVAS_FLOAT_FIXED
-/*Q12*/
-const Word16 ivas_sns_cdbk_tcx20_stage4_fx[ 32 * 16 ] =
-{
- -23 , -162 , 294 , 1101 , 1808 , -336 , -823 , -38 , 238 , -260 , -324 , -210 , -287 , -282 , -323 , -372 ,
- -49 , -247 , 49 , 204 , -183 , 155 , 406 , 257 , 91 , -371 , 16 , 1575 , 421 , -2168 , -1339 , 1183 ,
- -1457 , 1563 , 444 , 336 , 129 , -10 , -15 , -113 , -128 , -394 , -382 , -424 , -287 , 33 , 271 , 436 ,
- 157 , 92 , -904 , 2169 , -1450 , 1225 , -665 , -162 , 218 , -301 , -211 , 88 , 190 , 121 , -213 , -353 ,
- 311 , -803 , 192 , -2 , -217 , -143 , 781 , 349 , -660 , -1220 , -924 , -287 , 221 , 635 , 780 , 987 ,
- 337 , 1084 , -628 , -576 , -28 , 247 , -210 , -956 , -1165 , -580 , 325 , 976 , 847 , 398 , 61 , -133 ,
- 843 , -807 , 219 , 110 , -49 , -191 , -461 , 246 , 1392 , 1370 , -584 , -1545 , -895 , 69 , 341 , -57 ,
- 1408 , -1582 , -268 , -301 , -440 , 153 , 593 , 65 , 11 , 367 , 796 , 421 , -129 , -246 , -411 , -437 ,
- 526 , 80 , 669 , 935 , -656 , -1721 , -781 , 354 , 349 , -93 , 46 , 56 , -14 , 78 , -24 , 196 ,
- 112 , 33 , -306 , 471 , 9 , -1712 , 2296 , -1177 , 94 , -317 , -118 , 790 , 230 , 22 , -199 , -227 ,
- -152 , 530 , -1584 , -390 , 9 , -51 , 806 , 1056 , 519 , -417 , -360 , 39 , 581 , 595 , -314 , -867 ,
- 1217 , 271 , -1536 , -330 , 608 , -3 , -86 , 55 , -58 , -462 , -331 , -230 , -564 , -248 , 434 , 1262 ,
- -103 , 98 , -113 , -4 , 335 , -551 , -94 , 2816 , -1630 , -504 , 276 , 178 , -221 , -60 , -186 , -238 ,
- 60 , 171 , -102 , 21 , -326 , -190 , -116 , 90 , -469 , -487 , -171 , -8 , -1140 , 1358 , 2645 , -1333 ,
- -573 , -82 , 1285 , -2182 , 1292 , 153 , -175 , -243 , -223 , -40 , -30 , 63 , 315 , 338 , 48 , 55 ,
- -204 , 94 , -337 , -350 , 51 , 63 , -918 , 640 , -809 , 2336 , -1509 , 298 , 1930 , -1470 , 602 , -418 ,
- -702 , -781 , -877 , -125 , 396 , -358 , -395 , 70 , 355 , 170 , 242 , 140 , 333 , 526 , 492 , 514 ,
- -184 , 25 , 155 , 70 , 264 , 34 , -841 , -103 , 303 , 255 , -655 , -1131 , 1838 , 578 , -1675 , 1067 ,
- -612 , 728 , 94 , -512 , 2 , 779 , 158 , -163 , 387 , 828 , 919 , 457 , -331 , -696 , -1030 , -1009 ,
- -383 , 115 , -175 , 222 , 65 , -691 , -1245 , -708 , 283 , 1251 , 953 , -372 , 549 , 1413 , 150 , -1428 ,
- -820 , -428 , 172 , 383 , 42 , 193 , 1079 , 977 , 557 , -176 , -262 , -564 , -744 , -413 , -138 , 143 ,
- 600 , 113 , 1392 , -21 , -405 , 175 , -764 , -1357 , -582 , 164 , 149 , -297 , -490 , -7 , 387 , 944 ,
- 977 , 1086 , 140 , 175 , 207 , 142 , 499 , 161 , -74 , -393 , -441 , -657 , -705 , -513 , -398 , -208 ,
- -335 , -210 , -840 , 473 , 592 , -45 , -670 , -209 , 154 , 998 , 1575 , 223 , -1650 , -900 , 325 , 520 ,
- -1044 , -1156 , 804 , 1184 , 196 , -140 , 51 , -475 , -858 , -334 , 550 , 669 , 323 , 208 , 55 , -32 ,
- -278 , 97 , -45 , -152 , -784 , 487 , -82 , -1620 , 2324 , -113 , -981 , 425 , -194 , 122 , 307 , 487 ,
- 390 , -32 , 1476 , -311 , -835 , 256 , 628 , 184 , 17 , -565 , -603 , 62 , 717 , 453 , -600 , -1235 ,
- 262 , -96 , 317 , -990 , 168 , 771 , -1790 , 1064 , 1028 , -1523 , 167 , 1061 , 15 , -183 , -130 , -142 ,
- 104 , 381 , 464 , -114 , -36 , -288 , 116 , -216 , -800 , -1336 , 2780 , -303 , -616 , -288 , -113 , 265 ,
- -203 , 637 , -66 , -1133 , -1244 , -550 , 336 , 402 , 307 , 157 , 228 , -16 , -76 , 160 , 435 , 626 ,
- -177 , -754 , -187 , -206 , 868 , 2171 , 398 , -527 , -386 , -355 , -360 , -395 , -185 , 90 , -54 , 58 ,
- -7 , -58 , -198 , -152 , -389 , -24 , 1982 , -716 , -784 , 2346 , -775 , -1081 , 20 , 278 , -187 , -254
-};
-#endif
const float *const ivas_sns_cdbks_tcx20[SNS_MSVQ_NSTAGES_TCX20] = { ivas_sns_cdbk_tcx20_stage1, ivas_sns_cdbk_tcx20_stage2, ivas_sns_cdbk_tcx20_stage3, ivas_sns_cdbk_tcx20_stage4 };
-#ifdef IVAS_FLOAT_FIXED
-const Word16 *const ivas_sns_cdbks_tcx20_fx[SNS_MSVQ_NSTAGES_TCX20] = { ivas_sns_cdbk_tcx20_stage1_fx, ivas_sns_cdbk_tcx20_stage2_fx, ivas_sns_cdbk_tcx20_stage3_fx, ivas_sns_cdbk_tcx20_stage4_fx };
-#endif
const int16_t ivas_sns_cdbks_tcx10_levels[SNS_MSVQ_NSTAGES_TCX10] = { 128, 32, 8 };
const int16_t ivas_sns_cdbks_tcx10_bits[SNS_MSVQ_NSTAGES_TCX10] = { 7, 5, 3 };
@@ -8354,140 +6413,7 @@ const float ivas_sns_cdbk_tcx10_stage1[ 128 * 16 ] =
3.256836f, 3.5593262f, 2.2746582f, 1.1318359f, 0.3149414f, -0.02368164f, 0.27172852f, -0.19335938f, -0.48779297f, -0.9663086f, -0.9187012f, -1.0222168f, -1.512207f, -1.6816406f, -1.8964844f, -2.1069336f,
-0.057617188f, -0.45092773f, -0.9638672f, -0.72143555f, 0.20703125f, 1.4692383f, 1.921875f, 1.6833496f, 1.3933105f, 0.6699219f, 0.17333984f, -0.43798828f, -0.9772949f, -1.1477051f, -1.3552246f, -1.4057617f,
};
-#ifdef IVAS_FLOAT_FIXED
-/*Q12*/
-const Word16 ivas_sns_cdbk_tcx10_stage1_fx[ 128 * 16 ] =
-{
- 4155 , 4844 , 1339 , -2626 , -4982 , -4674 , -4721 , -3645 , -803 , 3032 , 4826 , 4436 , 3204 , 1104 , -1360 , -4129 ,
--1594 , -1284 , -4844 , -8342 , -8548 , -7606 , -6706 , -5389 , -1713 , 2074 , 5231 , 5641 , 7605 , 9627 , 9427 , 6422 ,
-1788 , 7725 , 11493 , 9169 , 6341 , 587 , 299 , -4595 , -4548 , -3005 , -1718 , -3671 , -4272 , -3268 , -4935 , -7392 ,
-6395 , 3818 , 2406 , 1897 , 897 , 256 , -693 , -1410 , -1832 , -2500 , -2621 , -2342 , -1577 , -1062 , -856 , -776 ,
-4150 , 7919 , 3439 , -2033 , -2704 , -1557 , 231 , 1278 , 3321 , 2731 , -93 , -3269 , -3781 , -2586 , -2807 , -4238 ,
--3449 , -354 , 2017 , 2387 , 4764 , 5609 , 2963 , 1108 , 1421 , 28 , -950 , -1353 , -2415 , -2770 , -4077 , -4929 ,
-8524 , 7457 , 4506 , 1934 , 338 , -1987 , -2756 , -2266 , -1957 , -2240 , -2375 , -2413 , -2097 , -1743 , -1348 , -1577 ,
-7090 , 5351 , 2190 , 948 , 174 , 15 , 389 , 653 , 810 , 817 , 897 , 265 , -1778 , -3881 , -6266 , -7674 ,
-6804 , 11715 , 7237 , -532 , -1146 , 4914 , 6089 , 4999 , 2534 , -5124 , -6431 , -5499 , -5543 , -5359 , -6419 , -8238 ,
-7709 , 2493 , -2143 , -6489 , -5196 , -3714 , -2590 , -832 , -1060 , 376 , 749 , 4940 , 4149 , -203 , -522 , 2334 ,
-2478 , 4656 , 6266 , 8166 , 8080 , 7910 , 7237 , 5633 , 3847 , 82 , -2972 , -5614 , -9294 , -11465 , -12330 , -12680 ,
--3763 , 439 , 1331 , -211 , -1125 , 837 , 3525 , 1259 , 263 , -714 , -2457 , -3123 , -445 , 2047 , 1650 , 487 ,
-4433 , 3075 , 1944 , 16 , -1183 , -2102 , -2546 , -2683 , -2426 , -1757 , -724 , 250 , 488 , 152 , 994 , 2067 ,
--9469 , -5101 , -2893 , -3433 , -2063 , 164 , 2573 , 3814 , 3385 , 1553 , 818 , -98 , 1471 , 3904 , 3575 , 1801 ,
-15946 , 17207 , 12819 , 11001 , 8646 , 8327 , 189 , -5678 , -6626 , -8191 , -8726 , -8916 , -9067 , -9108 , -8807 , -9017 ,
--5510 , -1763 , 1586 , 4321 , 5956 , 6915 , 5607 , 1816 , -152 , -948 , -2191 , -3237 , -3324 , -3026 , -2853 , -3196 ,
-8688 , 10873 , 8275 , 4634 , 1734 , -557 , -1294 , -1577 , -1538 , -3121 , -4044 , -4288 , -3973 , -4095 , -4377 , -5339 ,
-8314 , 381 , -4203 , -6906 , -2427 , 2895 , 4683 , -1276 , -3574 , -1537 , 382 , -1706 , -1536 , -1335 , 2670 , 5175 ,
-2014 , 6901 , 7450 , 8391 , 5660 , 5349 , 3318 , 632 , -1645 , -7184 , -11554 , -6162 , -2239 , -4081 , -3232 , -3618 ,
-2463 , 7959 , 4852 , -2086 , -2118 , 2942 , 2680 , 273 , -1971 , -3815 , -4209 , -3731 , -1973 , 228 , 710 , -2203 ,
-2203 , 1934 , 716 , -1238 , -808 , -125 , -35 , 38 , -139 , -93 , 845 , 1853 , 747 , -583 , -2071 , -3245 ,
--8428 , -9073 , -4283 , -324 , 6076 , 5438 , -488 , -2617 , -275 , 3550 , -1050 , -170 , 4675 , 4235 , 2065 , 669 ,
-11333 , 11955 , 6902 , 1934 , -1514 , -2879 , -3232 , -4238 , -3422 , -2837 , -2629 , -2898 , -2649 , -2035 , -2008 , -1783 ,
-426 , 4019 , 4713 , 3739 , 3356 , 3491 , 3050 , 1887 , 1284 , -268 , -2029 , -3494 , -4307 , -4440 , -5214 , -6212 ,
-2092 , 5801 , 8237 , 9551 , 6780 , 3678 , 2472 , 1019 , 1067 , -1082 , -3123 , -5119 , -7460 , -7403 , -7732 , -8778 ,
-961 , 1615 , -886 , -4376 , -5548 , -5310 , -4982 , -4885 , -3665 , -1478 , 1198 , 2863 , 4755 , 6850 , 7462 , 5426 ,
-12293 , 13814 , 11807 , 11074 , 9876 , 10313 , 5810 , 199 , -2989 , -7493 , -10043 , -10534 , -10988 , -11237 , -10950 , -10951 ,
-250 , 3000 , 5233 , 3533 , 1034 , 378 , -553 , -1707 , -2133 , -2878 , -2837 , -2353 , -1841 , -364 , 705 , 534 ,
-8771 , 7295 , 2905 , -1528 , -2797 , -2224 , -2434 , -3707 , -3996 , -3372 , -2464 , -2340 , 88 , 2453 , 2127 , 1224 ,
--5356 , -4080 , -3178 , -3415 , -3409 , -2987 , -2237 , -677 , 1836 , 4189 , 5902 , 5483 , 3659 , 2525 , 1749 , -4 ,
-8540 , 13122 , 10394 , 3057 , 1011 , 2922 , 1889 , -673 , -1284 , -4815 , -6548 , -6657 , -5605 , -4808 , -4643 , -5902 ,
--904 , 3036 , 3724 , 1024 , 621 , 2200 , 3068 , 4347 , 4727 , 939 , -3049 , -4688 , -4457 , -3259 , -3173 , -4155 ,
-7412 , 8540 , 3520 , -908 , -2046 , -2396 , -2247 , -1458 , -976 , 74 , -489 , 690 , 143 , -3498 , -4187 , -2172 ,
--9034 , -10692 , -9925 , -9020 , -3884 , 6891 , 9607 , 8744 , 7840 , 4174 , 2713 , 2569 , 3504 , 3316 , -948 , -5856 ,
-12528 , 15782 , 10788 , 3495 , -369 , -2158 , -2473 , -3242 , -3527 , -5125 , -5686 , -5358 , -4614 , -3620 , -2829 , -3594 ,
-3762 , 7050 , 3669 , -309 , -1556 , -2008 , -2380 , -2362 , -2016 , -1483 , -971 , -939 , -639 , 127 , 288 , -234 ,
-5466 , 5096 , 839 , -4326 , -4389 , -495 , 3962 , 6525 , 4641 , 474 , -1865 , -1808 , -2070 , -3368 , -3972 , -4710 ,
--7682 , -10419 , -8678 , 2804 , 7231 , 15597 , 6455 , -2426 , -908 , 2257 , 7253 , 5190 , -3489 , -5573 , -6505 , -1107 ,
-10313 , 8489 , 4954 , 1234 , -1203 , -393 , 1849 , 1910 , 915 , -2272 , -5380 , -5480 , -3449 , -3573 , -4108 , -3807 ,
-9010 , 7210 , 5020 , 3041 , 1855 , 1295 , 314 , -953 , -2075 , -2616 , -2829 , -2858 , -3271 , -3970 , -4378 , -4795 ,
-1460 , 6841 , 8628 , 3136 , 3143 , 6063 , 5972 , 3426 , 2223 , -5238 , -7341 , -6357 , -5904 , -3889 , -4715 , -7448 ,
-1449 , -1827 , -4550 , -6487 , -5713 , -2732 , -660 , 433 , 1307 , 2371 , 2794 , 3239 , 3158 , 2432 , 2376 , 2409 ,
-5243 , 9630 , 12091 , 11941 , 10590 , 7240 , 4378 , 1797 , -801 , -6201 , -9586 , -10323 , -9468 , -8915 , -8728 , -8887 ,
--6934 , -1067 , 786 , -193 , 251 , 625 , 700 , 418 , 356 , 314 , 163 , 106 , 6 , 1088 , 1894 , 1487 ,
-6060 , 3896 , 485 , -2939 , -4736 , -3436 , 282 , 2032 , 1869 , -523 , -3273 , -3045 , -833 , -16 , 1127 , 3049 ,
--6670 , -1890 , 358 , -230 , 447 , 2409 , 3909 , 6279 , 5449 , 1441 , -878 , -2018 , -2272 , -1424 , -1908 , -3000 ,
-11826 , 16636 , 13050 , 6279 , 1706 , 781 , 2337 , -3227 , -5169 , -7375 , -6710 , -5822 , -6503 , -6377 , -5089 , -6343 ,
-485 , 663 , 700 , 2165 , 1981 , 966 , 376 , 1834 , 2298 , 1627 , 1114 , 702 , -758 , -3039 , -4935 , -6179 ,
-15276 , 10241 , 6249 , 2873 , 783 , 322 , 994 , 1738 , 951 , -1804 , -4461 , -5446 , -5652 , -6733 , -7613 , -7717 ,
--4421 , -2251 , -2182 , -3670 , -3227 , -2064 , -1880 , -1860 , -609 , 307 , 1234 , 2129 , 3532 , 5592 , 5516 , 3853 ,
-3360 , 7922 , 10867 , 9394 , 6526 , 1053 , 1896 , 2883 , 1638 , -5507 , -7666 , -7210 , -7668 , -4745 , -5551 , -7191 ,
-2467 , 6411 , 8292 , 4274 , 2274 , 1209 , -243 , -1212 , -1185 , -2826 , -3570 , -3368 , -3512 , -3049 , -2692 , -3269 ,
-3028 , 7338 , 7308 , 4275 , 997 , -2048 , -3118 , -4094 , -3189 , -2517 , -1649 , -1480 , -692 , 504 , -1307 , -3355 ,
--13713 , -11806 , -7131 , -79 , 6455 , 6414 , -589 , -4681 , -1922 , 6331 , 330 , 637 , 6245 , 5108 , 4653 , 3749 ,
-14977 , 9830 , 6085 , 2938 , 1863 , 1059 , -553 , -2267 , -3180 , -4394 , -5086 , -4951 , -4163 , -4237 , -4011 , -3909 ,
--1081 , 3251 , 6408 , 7149 , 4954 , 5039 , 4478 , 4353 , 4522 , 680 , -6756 , -9382 , -7832 , -5831 , -3856 , -6094 ,
-7162 , 7991 , 4675 , 976 , 841 , 2948 , 4353 , 3456 , 2703 , 451 , -1709 , -4266 , -5937 , -7074 , -7860 , -8711 ,
-7238 , -605 , -4007 , 3 , 8333 , 1173 , -2176 , -5314 , -6069 , -5080 , -4591 , -4717 , -2795 , -241 , 5388 , 13461 ,
-10596 , 12578 , 13802 , 10908 , 7436 , 2231 , 2444 , 1872 , -2275 , -7177 , -9152 , -9171 , -8796 , -8290 , -8520 , -8488 ,
--737 , 2442 , 485 , -2808 , -3574 , -3229 , -2953 , -2353 , -857 , 704 , 1697 , 2241 , 2025 , 2311 , 2655 , 1952 ,
-12162 , 6690 , 2238 , -2622 , -4617 , -5816 , -5879 , -5236 , -4308 , -2961 , -1748 , -1607 , 1838 , 2753 , 3664 , 5448 ,
--3077 , 452 , 1966 , -389 , -1269 , 118 , 175 , 1055 , 3620 , 4579 , 1375 , -1234 , -1480 , -1197 , -1718 , -2974 ,
-15858 , 15042 , 10523 , 5569 , 4228 , 4314 , 3082 , 654 , -1725 , -5657 , -8057 , -9036 , -8888 , -8704 , -8514 , -8690 ,
-1704 , 1674 , 529 , 1843 , 4216 , 6144 , 6034 , 4105 , 2177 , -429 , -2012 , -2595 , -4212 , -5660 , -6417 , -7102 ,
-4241 , 3011 , -177 , -3536 , -4674 , -3686 , -1588 , 992 , 3180 , 2882 , 1972 , 1063 , 676 , -379 , -1461 , -2516 ,
--10246 , -9377 , -9897 , -10469 , -9129 , -5712 , -3574 , -1246 , 1237 , 4416 , 7620 , 7504 , 9023 , 11338 , 10287 , 8226 ,
-5873 , 10679 , 11753 , 7933 , 5561 , 2214 , 30 , -1608 , -3259 , -6151 , -6707 , -5993 , -5418 , -4939 , -4492 , -5477 ,
-1703 , 1720 , 48 , -171 , 92 , 1005 , 1475 , 1312 , 659 , -228 , -981 , -1903 , -1549 , -716 , -784 , -1681 ,
-534 , 4872 , 3894 , -2429 , -4953 , -2172 , 3168 , 2622 , 2251 , 1388 , -2147 , -4094 , -1110 , 1384 , -375 , -2832 ,
--10365 , -5877 , -612 , 3409 , 4994 , 5250 , 3856 , 2179 , 1532 , 1289 , 947 , 43 , -882 , -1327 , -1874 , -2562 ,
-7364 , 8825 , 6753 , 3174 , 1572 , 1020 , -1433 , -3832 , -4629 , -5540 , -5397 , -4403 , -2961 , -1278 , 255 , 511 ,
-3616 , 2982 , 2441 , 1531 , 2154 , 2980 , 1762 , 767 , 272 , -953 , -1744 , -2069 , -2225 , -2573 , -3790 , -5149 ,
-6016 , 10717 , 11396 , 4773 , 1867 , 5061 , 5183 , 3833 , 2366 , -3588 , -10444 , -10907 , -9023 , -5516 , -3941 , -7793 ,
-6375 , 1989 , -1308 , -3670 , -4356 , -4171 , -3980 , -3432 , -2043 , -587 , 591 , 1288 , 2794 , 3630 , 3600 , 3279 ,
-8179 , 11466 , 8560 , 3788 , 3482 , 5771 , 6843 , 5604 , 4908 , 1374 , -3903 , -8790 , -11546 , -12047 , -11857 , -11832 ,
--3090 , 661 , 1382 , -807 , 2129 , 5268 , 1730 , -823 , -481 , -2827 , -4904 , -3053 , -219 , 1606 , 3077 , 350 ,
-8949 , 4159 , 587 , -2658 , -2926 , -2276 , -1678 , -1050 , -331 , -65 , -22 , -396 , -501 , -142 , -463 , -1189 ,
--5048 , -1761 , -1240 , -3476 , -3747 , -2868 , 162 , 3168 , 4073 , 1904 , 569 , 468 , 1695 , 3016 , 2504 , 582 ,
-13457 , 16793 , 15820 , 10226 , 6095 , -181 , -2293 , -4895 , -6222 , -6960 , -7158 , -7267 , -7171 , -6955 , -6811 , -6477 ,
--1163 , 1485 , 2929 , 4720 , 6317 , 6894 , 3387 , -44 , -1981 , -2797 , -3233 , -2707 , -2580 , -3352 , -3680 , -4195 ,
-10024 , 13762 , 8664 , 2406 , 361 , 330 , 523 , -3418 , -2716 , 1302 , -192 , -7081 , -7539 , -6126 , -4791 , -5509 ,
-221 , -2249 , -2660 , -1660 , -613 , -278 , -544 , -655 , 183 , 1048 , 1304 , 660 , 1055 , 1496 , 1247 , 1445 ,
-846 , 5133 , 6934 , 10757 , 11411 , 9325 , 4488 , 1331 , -3265 , -7057 , -8303 , -5003 , -4657 , -8262 , -7258 , -6419 ,
-9482 , 12253 , 6534 , -607 , -2653 , -673 , 306 , -1178 , -1765 , -3207 , -3766 , -3761 , -3142 , -1768 , -2113 , -3942 ,
--550 , 1425 , 2011 , 157 , -1079 , -1413 , -1697 , -1610 , -686 , 39 , 810 , 288 , 848 , 1801 , 1010 , -1353 ,
--10109 , -11744 , -7706 , 379 , 8248 , 6559 , 38 , -828 , 2185 , 6885 , 844 , 754 , 4769 , 3153 , -890 , -2538 ,
-13503 , 12466 , 7450 , 1458 , -2178 , -4645 , -5771 , -6295 , -6474 , -5971 , -4508 , -2899 , 1290 , 560 , 405 , 1608 ,
-4667 , 8260 , 6596 , 1763 , 3540 , 6861 , 3573 , -969 , -5225 , -5388 , -4163 , -2503 , -3545 , -3940 , -3641 , -5886 ,
-5072 , 10057 , 11017 , 4484 , 3638 , 2703 , 2095 , 2224 , 2067 , -2996 , -4340 , -4397 , -7071 , -7750 , -8132 , -8671 ,
-7076 , 4469 , 996 , -4409 , -7469 , -8582 , -7901 , -7025 , -4868 , -1656 , 2572 , 4172 , 4462 , 5363 , 6290 , 6510 ,
-11515 , 12880 , 10465 , 3540 , 1874 , 6237 , 6698 , 3799 , -2308 , -7772 , -8623 , -8541 , -7869 , -7144 , -7664 , -7087 ,
-1889 , 3817 , 3520 , 1054 , -342 , -451 , -2129 , -3116 , -3726 , -5315 , -4316 , -2809 , 54 , 3440 , 4742 , 3688 ,
-12822 , 7564 , 3096 , -1375 , -2981 , -3502 , -2957 , -2787 , -2321 , -2052 , -2014 , -1157 , -656 , -1499 , -1036 , 856 ,
--7298 , -3128 , -1459 , -3766 , -3686 , -1244 , 669 , 2187 , 5005 , 6621 , 4491 , 1512 , 782 , 783 , -274 , -1196 ,
-12071 , 12166 , 10231 , 7547 , 4891 , 1997 , 167 , -1868 , -2940 , -5141 , -6998 , -7442 , -6793 , -6155 , -5653 , -6081 ,
--1753 , 1625 , 4228 , 3372 , 2337 , 4063 , 4415 , 1944 , 491 , -2688 , -5614 , -5677 , -3836 , -1216 , -247 , -1444 ,
-12512 , 6411 , 2980 , 101 , -359 , -558 , -915 , -211 , -81 , -568 , -1190 , -2006 , -2777 , -3666 , -4294 , -5379 ,
--9543 , -6774 , -6214 , -7549 , -7059 , -3854 , -1628 , 2101 , 5622 , 6976 , 6572 , 5418 , 5229 , 4875 , 3740 , 2087 ,
-8837 , 12535 , 11328 , 7255 , 2550 , -2526 , -4345 , -6428 , -5892 , -7230 , -7262 , -4485 , -1885 , -283 , -223 , -1946 ,
-9129 , 8498 , 4366 , 281 , -3607 , -5680 , -5660 , -5230 , -3574 , -1874 , -344 , -92 , 1479 , 1933 , 516 , -142 ,
-5256 , 9433 , 6759 , -793 , -3866 , -459 , 5206 , 4388 , 3690 , -2799 , -7970 , -5691 , -3094 , -697 , -2658 , -6706 ,
--2216 , -5889 , -3568 , 2955 , 9741 , 7436 , 239 , -1003 , 1111 , 4778 , -1103 , -1008 , 1967 , -1394 , -4972 , -7074 ,
-10789 , 7440 , 2779 , -665 , -2630 , -3084 , -1314 , 514 , 584 , -2094 , -4598 , -5089 , -1705 , -879 , -523 , 474 ,
-6838 , 5757 , 5081 , 5754 , 4886 , 2602 , 782 , 166 , -233 , -2235 , -3851 , -4886 , -4905 , -4949 , -5029 , -5777 ,
-3777 , 8672 , 7923 , 2766 , 875 , 3035 , 2111 , 256 , -660 , -3765 , -6885 , -7930 , -5724 , -1376 , 64 , -3141 ,
-1043 , 1116 , -2723 , -6588 , -6935 , -6723 , -5310 , 129 , 5099 , 4079 , 3612 , 2961 , 2573 , 4722 , 2989 , -43 ,
-1107 , 6435 , 9892 , 10493 , 10103 , 8530 , 4943 , 5882 , 5571 , -2662 , -9598 , -11372 , -11225 , -10110 , -8411 , -9579 ,
--5006 , -976 , 1744 , 1682 , 136 , -921 , -1278 , -2195 , -2395 , -1642 , 74 , 1034 , 1476 , 2263 , 2966 , 3036 ,
-5150 , 4553 , 3608 , 1262 , -1364 , -913 , 1595 , 2380 , 2112 , -469 , -3306 , -3879 , -2810 , -2832 , -2793 , -2294 ,
--3555 , -3199 , -1984 , -903 , 897 , 2488 , 1905 , 2582 , 2162 , 544 , 447 , 1148 , 647 , -112 , -935 , -2133 ,
-19565 , 17281 , 11036 , 5756 , 1904 , 520 , -2148 , -4844 , -5499 , -5875 , -6311 , -6526 , -6486 , -6349 , -6068 , -5956 ,
--4564 , 687 , 4457 , 4047 , 2491 , 1633 , 917 , 80 , 46 , 286 , -541 , -1798 , -2353 , -1410 , -1770 , -2208 ,
-10582 , 8739 , 6358 , 4552 , 5070 , 5384 , 3814 , 1464 , -830 , -3127 , -4787 , -5934 , -6628 , -7437 , -8195 , -9024 ,
--8243 , -6062 , -5955 , -6127 , -4538 , -1750 , -708 , 329 , 1275 , 2189 , 2653 , 2630 , 4348 , 7441 , 7186 , 5331 ,
-3524 , 8176 , 10617 , 11183 , 9097 , 4548 , 2951 , -138 , -2003 , -4822 , -9077 , -10737 , -10317 , -6266 , -1688 , -5048 ,
--160 , 2942 , 5298 , 6724 , 7063 , 1816 , -1506 , -2566 , -575 , -1613 , -6146 , -5214 , -2667 , -893 , -655 , -1848 ,
-1846 , 4832 , 4243 , 1910 , 516 , -856 , -1034 , -742 , -737 , -953 , -523 , -41 , -980 , -1924 , -2386 , -3170 ,
--15228 , -14072 , -7488 , 944 , 6245 , 6079 , 828 , -630 , 1680 , 6027 , 390 , 513 , 5448 , 5516 , 2111 , 1639 ,
-19563 , 12033 , 6609 , 1145 , -1338 , -2373 , -3214 , -3154 , -3135 , -3507 , -3551 , -3495 , -3191 , -3941 , -4145 , -4305 ,
--3621 , -2181 , 970 , 8464 , 10422 , 7881 , 6143 , 5042 , 3015 , 869 , -2539 , -3894 , -5022 , -7336 , -8360 , -9855 ,
-4589 , 9181 , 6169 , 1082 , 342 , 359 , 16 , 127 , 334 , -1624 , -2322 , -2546 , -2957 , -3264 , -4017 , -5471 ,
-3606 , -2296 , -3662 , -4758 , -3791 , -5478 , -4900 , -5253 , -5389 , -5139 , -4257 , -168 , 6209 , 6583 , 9851 , 18841 ,
-8752 , 12363 , 11875 , 8625 , 6928 , 5159 , 4395 , 2087 , 1077 , -2569 , -6852 , -9550 , -10394 , -10712 , -10636 , -10548 ,
-1860 , 2305 , -375 , -3366 , -3658 , -1668 , 102 , 33 , -397 , -793 , -1050 , -1026 , 612 , 3009 , 3141 , 1271 ,
-3601 , 5629 , 2769 , -909 , -3496 , -4488 , -4379 , -4804 , -4034 , -2723 , -478 , 276 , 2538 , 4467 , 3717 , 2316 ,
--1091 , -1227 , -3638 , -5036 , -2839 , 46 , 2252 , 4024 , 4850 , 4463 , 2408 , 276 , -365 , -206 , -1119 , -2800 ,
-13340 , 14579 , 9317 , 4636 , 1290 , -97 , 1113 , -792 , -1998 , -3958 , -3763 , -4187 , -6194 , -6888 , -7768 , -8630 ,
--236 , -1847 , -3948 , -2955 , 848 , 6018 , 7872 , 6895 , 5707 , 2744 , 710 , -1794 , -4003 , -4701 , -5551 , -5758
-};
-#endif
+
const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] =
{
0.30615234f, 0.48828125f, -0.02709961f, -0.47680664f, -0.5300293f, -0.25463867f, -0.13305664f, -0.14941406f, -0.14819336f, 0.08666992f, 0.28833008f, 0.27514648f, 0.099365234f, -0.017578125f, 0.033203125f, 0.15893555f,
@@ -8524,44 +6450,6 @@ const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] =
-0.20361328f, -0.21557617f, -0.16308594f, -0.041748047f, -0.111083984f, -0.057617188f, 0.0390625f, 0.013183594f, 0.17358398f, 0.74902344f, 0.9448242f, 0.4477539f, -0.09423828f, -0.32739258f, -0.50634766f, -0.6467285f,
};
-#ifdef IVAS_FLOAT_FIXED
-/*Q12*/
-const Word16 ivas_sns_cdbk_tcx10_stage2_fx[ 32 * 16 ] =
-{
- 1254 , 2000 , -111 , -1953 , -2171 , -1043 , -545 , -612 , -607 , 355 , 1181 , 1127 , 407 , -72 , 136 , 651 ,
- 1677 , -181 , -362 , 1586 , 2110 , 1730 , 1432 , 1098 , 154 , -818 , -1272 , -1336 , -1575 , -1560 , -1581 , -1103 ,
- -657 , -1538 , -1699 , -507 , 1053 , 1212 , 186 , -178 , -469 , -827 , 133 , 2395 , 4402 , 1302 , -1796 , -3012 ,
- -2950 , 352 , 1493 , 317 , -158 , -83 , 933 , 969 , -252 , -2462 , -2188 , -58 , 1292 , 1447 , 1121 , 226 ,
- 698 , -549 , -716 , -673 , -616 , -664 , 851 , 3231 , 3395 , 1140 , -408 , -1086 , -1210 , -1305 , -1243 , -845 ,
- 2743 , 2575 , 2092 , 1507 , 389 , -1102 , -1786 , -2168 , -2057 , -1183 , -331 , 322 , -167 , -615 , -313 , 93 ,
- -600 , -1922 , -1784 , -461 , 89 , -257 , -435 , -978 , -1404 , -863 , 41 , 1077 , 1513 , 1868 , 2050 , 2065 ,
- -2614 , -1550 , -493 , 1920 , 2469 , 1658 , 1322 , 891 , 120 , 39 , 375 , 58 , -816 , -1117 , -1258 , -1006 ,
- 4114 , 141 , -1496 , -667 , -717 , -670 , 81 , 172 , -377 , -514 , -566 , -636 , -562 , -172 , 483 , 1384 ,
- -1224 , -232 , 927 , 1449 , 1662 , 219 , -1358 , -2391 , -2453 , -568 , 1446 , 1748 , 514 , -215 , 94 , 381 ,
- -2542 , -2686 , -1605 , -961 , -430 , -99 , 429 , 1125 , 1378 , 1174 , 1221 , 1454 , 908 , 258 , 15 , 360 ,
- -990 , 1611 , 1860 , -56 , -115 , 132 , -143 , 570 , 2335 , 1232 , -117 , -340 , -953 , -1048 , -1653 , -2325 ,
- -1043 , 825 , 558 , 90 , 77 , 1451 , 1251 , -180 , -132 , 1996 , 1103 , -2372 , -3534 , -1902 , 879 , 933 ,
- 413 , -20 , 632 , 2414 , 2389 , 615 , -571 , -1252 , -1630 , -1721 , -1782 , -2012 , -990 , 319 , 1376 , 1819 ,
- -3559 , -518 , 1547 , 1324 , -401 , -1236 , -464 , 286 , 445 , 417 , 78 , -85 , -106 , 81 , 648 , 1542 ,
- 175 , 86 , 1305 , 954 , -1355 , -3290 , -3017 , -1397 , 49 , 1139 , 1881 , 2013 , 1238 , 580 , -71 , -289 ,
- -1374 , 310 , -1225 , -3016 , -2673 , -729 , 1486 , 1715 , 1031 , 429 , 124 , -461 , 110 , 1435 , 1736 , 1102 ,
- 1452 , 2766 , 1584 , 39 , -167 , 368 , 1002 , 674 , -710 , -1804 , -1906 , -1640 , -1156 , -768 , -151 , 418 ,
- 1743 , 660 , -478 , -657 , -589 , -842 , -315 , -227 , -806 , -1840 , -1270 , 444 , 2334 , 2275 , 464 , -895 ,
- -1221 , -2116 , -2089 , -944 , 1010 , 2035 , 1826 , 1844 , 652 , -1037 , -1405 , -1030 , -188 , 323 , 779 , 1560 ,
- 1345 , 1687 , 1678 , 945 , -1118 , -3020 , -1357 , 854 , 1198 , 98 , -913 , -918 , -434 , -448 , -201 , 605 ,
- -720 , 1466 , 2918 , 2271 , 1555 , 1037 , 3 , -715 , -816 , -748 , -566 , -552 , -1105 , -1496 , -1558 , -972 ,
- 769 , -1385 , -1653 , -673 , -1444 , -2353 , -1657 , 161 , 1159 , 991 , 469 , -49 , 638 , 1195 , 1616 , 2213 ,
- 921 , -1842 , -199 , 2419 , 2210 , -340 , -2057 , -988 , 955 , 653 , -182 , 179 , -79 , -812 , -707 , -130 ,
- 3529 , 896 , 163 , 98 , -379 , -690 , -478 , 329 , 251 , 506 , 958 , 943 , 23 , -1379 , -2370 , -2398 ,
- 2120 , 592 , -895 , -1916 , 1168 , 4037 , 176 , -2475 , -1664 , 291 , -325 , -455 , 71 , 89 , -566 , -249 ,
- 2005 , -2001 , -3131 , -1768 , -336 , 467 , 955 , 603 , 145 , 776 , 1259 , 1064 , 391 , -96 , -317 , -16 ,
- -458 , 921 , 2 , -1318 , -618 , 1762 , 2872 , 1443 , -494 , -954 , 625 , 807 , -263 , -885 , -1580 , -1861 ,
- -913 , -1382 , 280 , 380 , 190 , 897 , -146 , 150 , 2509 , 2072 , -1691 , -2832 , -2267 , 665 , 2229 , -140 ,
- -57 , 1690 , 1163 , -536 , -1436 , -1521 , -1073 , -1169 , -1491 , -1688 , -1247 , -678 , 313 , 1668 , 2955 , 3108 ,
- -3201 , 226 , 404 , -1437 , -1195 , 554 , 435 , -1440 , -1127 , 652 , 1406 , 1076 , 1635 , 1724 , 858 , -571 ,
- -834 , -883 , -668 , -171 , -455 , -236 , 160 , 54 , 711 , 3068 , 3870 , 1834 , -386 , -1341 , -2074 , -2649
-};
-#endif
const float ivas_sns_cdbk_tcx10_stage3[ 8 * 16 ] =
{
0.15209961f, -0.12768555f, 0.09375f, -0.083496094f, -0.25390625f, 0.12524414f, 0.2993164f, -0.09863281f, -0.34814453f, -0.2434082f, -0.11254883f, -0.060058594f, 0.032470703f, 0.15527344f, 0.23413086f, 0.2355957f,
@@ -8574,27 +6462,8 @@ const float ivas_sns_cdbk_tcx10_stage3[ 8 * 16 ] =
-0.1821289f, 0.060058594f, 0.24780273f, 0.41674805f, 0.2890625f, -0.1472168f, -0.20581055f, -0.083984375f, -0.060302734f, -0.19921875f, -0.17651367f, -0.08984375f, 0.011230469f, 0.13110352f, 0.080078125f, -0.09106445f,
};
-#ifdef IVAS_FLOAT_FIXED
-/*Q12*/
-const Word16 ivas_sns_cdbk_tcx10_stage3_fx[ 8 * 16 ] =
-{
- 623 , -523 , 384 , -342 , -1040 , 513 , 1226 , -404 , -1426 , -997 , -461 , -246 , 133 , 636 , 959 , 965 ,
- -665 , -455 , -1300 , -1050 , 567 , 1223 , 430 , 481 , 1090 , 223 , -598 , -788 , 171 , 859 , 304 , -492 ,
- -208 , 605 , -411 , -1315 , -717 , -764 , -1112 , -319 , 15 , -176 , 415 , 1433 , 1263 , 414 , 315 , 561 ,
- -784 , -124 , 922 , 326 , -1112 , -803 , 1144 , 1435 , 427 , 25 , 268 , 478 , 151 , -534 , -930 , -887 ,
- 1087 , -853 , -1027 , 490 , 1117 , 729 , -10 , -523 , -934 , 31 , 874 , 798 , 188 , -485 , -729 , -753 ,
- 1051 , 1010 , 416 , -120 , -588 , -573 , -850 , -806 , 717 , 1704 , 536 , -841 , -665 , 167 , -153 , -1004 ,
- -357 , 94 , 2 , 303 , 589 , 278 , 15 , 480 , 358 , 5 , -311 , -465 , -1287 , -1594 , -94 , 1984 ,
- -746 , 246 , 1015 , 1707 , 1184 , -603 , -843 , -344 , -247 , -816 , -723 , -368 , 46 , 537 , 328 , -373
-};
-#endif
-
const float *const ivas_sns_cdbks_tcx10[SNS_MSVQ_NSTAGES_TCX10] = { ivas_sns_cdbk_tcx10_stage1, ivas_sns_cdbk_tcx10_stage2, ivas_sns_cdbk_tcx10_stage3};
-#ifdef IVAS_FLOAT_FIXED
-const Word16 *const ivas_sns_cdbks_tcx10_fx[SNS_MSVQ_NSTAGES_TCX10] = { ivas_sns_cdbk_tcx10_stage1_fx, ivas_sns_cdbk_tcx10_stage2_fx, ivas_sns_cdbk_tcx10_stage3_fx};
-#endif
-
const int16_t ivas_sns_cdbks_side_tcx20_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 32 };
const int16_t ivas_sns_cdbks_side_tcx20_bits[SNS_MSVQ_NSTAGES_SIDE] = { 5, 5 };
const int16_t ivas_sns_cdbks_side_tcx10_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 8 };
@@ -8636,44 +6505,6 @@ const float ivas_sns_cdbks_side_tcx20_stage1[ 32 * 16 ] =
-0.19580078f, -0.14624023f, -0.11303711f, -0.055908203f, -0.052001953f, -0.009033203f, 0.022949219f, -0.0068359375f, -0.032470703f, 0.0017089844f, 0.045410156f, 0.025146484f, 0.039794922f, 0.07543945f, 0.1574707f, 0.24267578f,
};
-#ifdef IVAS_FLOAT_FIXED
-/*Q15*/
-const Word16 ivas_sns_cdbks_side_tcx20_stage1_fx[ 32 * 16 ] =
-{
- -3728 , -2160 , 1376 , 1464 , 5856 , -904 , -10680 , -6904 , -1608 , 416 , 424 , 496 , 2688 , 4152 , 4160 , 4952 ,
- -560 , 3056 , 7720 , 7344 , 3520 , 1648 , 1304 , -240 , -1584 , -2856 , -2792 , -3952 , -3656 , -3480 , -2920 , -2560 ,
- -8728 , 8968 , 14888 , 5968 , 21344 , 5920 , 4776 , -264 , 8624 , -1504 , -17040 , -5336 , 1256 , -10424 , -14160 , -14288 ,
- -1448 , -3424 , -3008 , -3480 , -3088 , 3056 , 8840 , 5432 , 2032 , 360 , 712 , -784 , -1200 , -1288 , -1424 , -1288 ,
- 13432 , 2072 , -720 , -472 , -456 , -608 , -1712 , -1696 , -1040 , -1144 , -904 , -1920 , -1488 , -1384 , -1248 , -704 ,
- 80 , 1008 , 664 , 448 , -296 , 424 , 312 , -992 , -1584 , -728 , 392 , -568 , -376 , -24 , 392 , 840 ,
- 5688 , 7336 , 6456 , -624 , -9016 , -17624 , -10056 , -1160 , 24 , -1624 , 2464 , 1712 , 4152 , 5344 , 3976 , 2960 ,
- -10488 , -9544 , -8104 , -5832 , -4608 , -3472 , -4152 , -3560 , -2824 , -2432 , 1000 , 5216 , 8184 , 10328 , 13400 , 16880 ,
- -16272 , -1104 , 2744 , 1400 , 1136 , 1768 , 1136 , 776 , 1232 , 1040 , 928 , 8 , 936 , 1008 , 1448 , 1816 ,
- -1328 , 736 , 320 , 1208 , 1824 , 1536 , 1064 , 2656 , 3136 , 1408 , -288 , -2120 , -1880 , -1544 , -3200 , -3528 ,
- 8896 , 12112 , 13000 , 12592 , 9880 , 7096 , 5096 , 3976 , -264 , -4192 , -7528 , -12816 , -14632 , -15344 , -11792 , -6072 ,
- -10376 , -9040 , -7304 , -6064 , -5168 , -3880 , -1520 , 1064 , 3592 , 5512 , 6664 , 5456 , 6560 , 6544 , 4664 , 3288 ,
- -920 , -896 , -2184 , -3256 , -3448 , -3456 , -1864 , 568 , 2016 , 2568 , 2880 , 1688 , 1776 , 1696 , 1400 , 1440 ,
- -4720 , -10120 , -2584 , 1744 , 2104 , 1056 , 1888 , 1904 , 1680 , 1368 , 1768 , 496 , 944 , 1104 , 768 , 608 ,
- 16256 , 14832 , 9552 , 5128 , 1712 , 576 , -1640 , -2176 , -3552 , -4936 , -5616 , -6728 , -6040 , -5752 , -6296 , -5320 ,
- -184 , -1008 , -3024 , -4136 , -5216 , -3936 , -3624 , -4376 , -4232 , -3232 , 576 , 4216 , 7160 , 8144 , 6144 , 6728 ,
- -368 , -2000 , -1056 , 5944 , 2240 , -4560 , -3328 , 56 , -152 , 320 , 1032 , -224 , 144 , 784 , 568 , 592 ,
- -1480 , -1800 , -1408 , 1760 , 6952 , 8256 , 2920 , -1120 , -1624 , -2040 , -2016 , -2568 , -1720 , -1448 , -1512 , -1160 ,
- 2664 , 6728 , 1408 , 3608 , 12192 , 14000 , 10448 , 6336 , 512 , -5864 , -6624 , -12560 , -8152 , -6744 , -8048 , -9928 ,
- -13144 , -6696 , -1600 , 616 , -2632 , 528 , 4400 , 8960 , 11480 , 11720 , 6280 , -1864 , -3816 , -5160 , -4912 , -4168 ,
- 9056 , 9144 , 7344 , 1176 , -3360 , -2016 , -2800 , -6504 , -8400 , -7448 , -6560 , -4112 , -88 , 2680 , 4856 , 7016 ,
- -3744 , -2248 , 8016 , -104 , -1416 , -1088 , 800 , -120 , -736 , 56 , 608 , -488 , -336 , 72 , 224 , 504 ,
- 2632 , 7816 , 5536 , 952 , -1432 , -3464 , -2552 , -1216 , -208 , -848 , -1208 , -2080 , -1416 , -1040 , -1064 , -408 ,
- -2368 , -5768 , -9744 , -11552 , -11408 , -8432 , -6872 , -6064 , -3680 , -1736 , 3160 , 10064 , 12880 , 18576 , 13312 , 9632 ,
- -7928 , -3608 , -1672 , 1288 , -2016 , -608 , 360 , 1408 , -7064 , -632 , 304 , 1576 , 8632 , 12056 , 4336 , -6424 ,
- 5312 , 5368 , 4720 , 3544 , 2936 , 3752 , 3848 , 3816 , 4296 , 3704 , 696 , -5192 , -6936 , -8968 , -11080 , -9816 ,
- -4792 , 2248 , 8104 , 12752 , 10440 , 8984 , 6280 , 4520 , 2280 , -616 , -3800 , -9336 , -11736 , -12464 , -8504 , -4352 ,
- -21240 , -19008 , -5088 , -2328 , -2720 , 320 , 3480 , 3464 , 4584 , 4256 , 5712 , 6032 , 3072 , 4104 , 6776 , 8592 ,
- 2568 , 5384 , -472 , -6848 , -2944 , 1408 , 2200 , 248 , -1216 , -960 , -656 , -1040 , 120 , 528 , 504 , 1176 ,
- -776 , -4680 , -12008 , -3696 , 1384 , 4616 , 1360 , 304 , 1304 , 1816 , 2016 , 1336 , 1840 , 2104 , 1720 , 1360 ,
- 7576 , 7056 , 5488 , 5128 , 4136 , 3440 , 2848 , 656 , -1136 , -4208 , -6088 , -9664 , -8864 , -5648 , -2272 , 1552 ,
- -6416 , -4792 , -3704 , -1832 , -1704 , -296 , 752 , -224 , -1064 , 56 , 1488 , 824 , 1304 , 2472 , 5160 , 7952
-};
-#endif
const float ivas_sns_cdbks_side_tcx20_stage2[ 32 * 16 ] =
{
-0.013916016f, 0.0007324219f, 0.017089844f, 0.005859375f, 0.056152344f, -0.08178711f, -0.2927246f, 0.00390625f, 0.140625f, 0.03881836f, 0.010498047f, 0.038330078f, 0.042236328f, 0.020751953f, 0.005859375f, 0.0075683594f,
@@ -8710,51 +6541,8 @@ const float ivas_sns_cdbks_side_tcx20_stage2[ 32 * 16 ] =
0.0847168f, 0.18920898f, -0.1796875f, -0.01586914f, -0.017822266f, -0.021728516f, 0.006591797f, -0.0075683594f, -0.019042969f, -0.0107421875f, -0.0146484375f, 0.014160156f, 0.0034179688f, -0.0056152344f, -0.0036621094f, -0.0017089844f,
};
-#ifdef IVAS_FLOAT_FIXED
-/*Q15*/
-const Word16 ivas_sns_cdbks_side_tcx20_stage2_fx[ 32 * 16 ] =
-{
- -456 , 24 , 560 , 192 , 1840 , -2680 , -9592 , 128 , 4608 , 1272 , 344 , 1256 , 1384 , 680 , 192 , 248 ,
- -2328 , -3360 , 1248 , 3000 , 3896 , 4416 , 1664 , -3648 , -4536 , -6792 , -8432 , -4936 , 1064 , 2664 , 5760 , 10312 ,
- 2344 , 952 , 640 , 264 , 768 , 680 , 1056 , 720 , 1136 , 584 , -1240 , -4600 , -7104 , -3616 , 1888 , 5520 ,
- -3544 , -896 , -2704 , -2696 , -2592 , 1632 , 3360 , 7824 , 8416 , 1040 , -5184 , -4800 , -264 , -16 , -472 , 896 ,
- -744 , 920 , 4624 , -2216 , -2408 , 5328 , -240 , -2152 , -936 , -352 , -784 , 416 , -192 , -216 , -464 , -592 ,
- -3192 , -3016 , -2016 , -392 , 216 , 1368 , 272 , -576 , -2792 , -4120 , -2064 , 4488 , 8256 , 5024 , 64 , -1528 ,
- -6632 , 8864 , 1944 , 136 , 728 , -320 , -872 , -896 , -1072 , -552 , -848 , -48 , -248 , -312 , 152 , -32 ,
- 2112 , -8752 , 4024 , 840 , -208 , 144 , 280 , -56 , 200 , -232 , -616 , 392 , 280 , 328 , 664 , 600 ,
- -24 , -1232 , -1192 , -512 , 184 , -184 , -96 , 1072 , 1560 , 624 , -344 , 576 , 416 , 144 , -440 , -552 ,
- 2272 , 1736 , 2000 , 4384 , 4400 , 176 , -3256 , -6008 , -7160 , -2736 , 664 , 1928 , 440 , 376 , 640 , 136 ,
- 120 , -1656 , -168 , 6256 , -6160 , -1792 , 16 , -712 , -64 , 56 , 136 , 816 , 728 , 904 , 888 , 632 ,
- 808 , -136 , -872 , -2816 , -2072 , -2248 , -2456 , -1640 , -2000 , -200 , 1848 , 2896 , 1928 , 2208 , 2544 , 2208 ,
- 4488 , 2784 , 2328 , 1536 , 808 , 160 , -352 , -216 , 464 , -240 , -1360 , -888 , -1360 , -1992 , -3040 , -3120 ,
- -5496 , 2184 , 5968 , 2424 , -656 , 1816 , 1280 , -3936 , -3536 , 4040 , 12432 , 1072 , -5288 , -4992 , -3456 , -3848 ,
- -432 , -368 , -1224 , 88 , -1520 , -8008 , 3272 , 3624 , 280 , 336 , 432 , 1264 , 544 , 488 , 632 , 592 ,
- 1448 , 2544 , -1144 , -6016 , 5152 , 2008 , -968 , -616 , -784 , 24 , -344 , 288 , -184 , -304 , -488 , -616 ,
- 4488 , 368 , -1096 , -568 , -2544 , -4016 , -2504 , -568 , 4672 , 6984 , 4776 , 1056 , -2744 , -3944 , -2496 , -1880 ,
- 968 , -4008 , -8112 , 3112 , 6192 , 856 , 424 , 984 , 296 , -304 , -840 , 288 , -80 , -56 , 288 , -8 ,
- -1264 , -1272 , -2912 , -2256 , 728 , 3352 , 4208 , 2752 , 2152 , 2680 , 2488 , 1312 , -1568 , -3096 , -3392 , -3904 ,
- 304 , 1536 , 2680 , 1232 , 208 , -1256 , -384 , 9248 , 912 , -8256 , -4200 , 520 , 376 , -472 , -1448 , -1008 ,
- 2088 , 4072 , 3128 , -4384 , -8616 , -2072 , 1088 , 2160 , 1592 , 864 , 192 , 648 , -96 , -192 , -24 , -432 ,
- -552 , -1712 , -1880 , 264 , -384 , -2256 , -2816 , -536 , -400 , 1536 , 5952 , 8824 , 4416 , -800 , -4176 , -5480 ,
- -720 , -1768 , -744 , -16 , 2360 , 2736 , 1856 , -488 , 928 , 3080 , 2008 , -15984 , -608 , 5080 , 1920 , 352 ,
- 12608 , -1616 , -2600 , -824 , -760 , -680 , 880 , -16 , -1720 , -1112 , -1520 , -352 , -592 , -728 , -528 , -440 ,
- -7816 , -2128 , -592 , -112 , 1320 , 632 , 600 , 1008 , 984 , 936 , 336 , 1216 , 704 , 1144 , 1152 , 616 ,
- 1264 , 944 , 848 , 1416 , 1144 , -720 , -1136 , -640 , -776 , -3120 , -4552 , -1072 , 448 , 1928 , 2120 , 1896 ,
- -488 , 488 , 416 , 1488 , 240 , 2720 , 5832 , 1008 , -3848 , -2352 , -1576 , -232 , -528 , -800 , -1088 , -1272 ,
- 2264 , -1608 , -7672 , -10576 , -5000 , -928 , 1928 , 1832 , 2824 , 2688 , 1712 , 1792 , 728 , 2584 , 4280 , 3144 ,
- -4408 , -880 , 3512 , 5256 , 4360 , 1432 , 288 , 656 , 1312 , 576 , -984 , -816 , -2224 , -2840 , -2504 , -2744 ,
- -640 , -1960 , -2008 , 264 , 1048 , 2688 , -1480 , -8376 , -904 , 3448 , 2056 , 1536 , 952 , 1040 , 1392 , 936 ,
- -1640 , 2768 , 8904 , 1744 , -2096 , -4256 , -2392 , -1696 , -1200 , -48 , -32 , 712 , 296 , -24 , -432 , -608 ,
- 2776 , 6200 , -5888 , -520 , -584 , -712 , 216 , -248 , -624 , -352 , -480 , 464 , 112 , -184 , -120 , -56
-};
-#endif
const float *const ivas_sns_cdbks_side_tcx20[SNS_MSVQ_NSTAGES_SIDE] = { ivas_sns_cdbks_side_tcx20_stage1, ivas_sns_cdbks_side_tcx20_stage2 };
-#ifdef IVAS_FLOAT_FIXED
-/*Q15*/
-const Word16 *const ivas_sns_cdbks_side_tcx20_fx[SNS_MSVQ_NSTAGES_SIDE] = { ivas_sns_cdbks_side_tcx20_stage1_fx, ivas_sns_cdbks_side_tcx20_stage2_fx };
-#endif
-
const float ivas_sns_cdbks_side_tcx10_stage1[ 32 * 16 ] =
{
-0.23950195f, -0.203125f, -0.17822266f, -0.1315918f, -0.123291016f, -0.095947266f, -0.106933594f, -0.16552734f, -0.14941406f, -0.075683594f, 0.026367188f, 0.1015625f, 0.17041016f, 0.2770996f, 0.37890625f, 0.5148926f,
@@ -8792,45 +6580,6 @@ const float ivas_sns_cdbks_side_tcx10_stage1[ 32 * 16 ] =
}
;
-#ifdef IVAS_FLOAT_FIXED
-/*Q15*/
-const Word16 ivas_sns_cdbks_side_tcx10_stage1_fx[ 32 * 16 ] =
-{
-
- -7848 , -6656 , -5840 , -4312 , -4040 , -3144 , -3504 , -5424 , -4896 , -2480 , 864 , 3328 , 5584 , 9080 , 12416 , 16872 ,
- 4224 , 6824 , 7512 , 9824 , 7952 , 4744 , 2576 , 808 , -2496 , -6040 , -8736 , -10896 , -9040 , -4576 , -1000 , -1680 ,
- -4640 , -4360 , -3664 , -1224 , -1248 , 1688 , 2408 , 240 , 1472 , -768 , -4040 , -384 , 9208 , 7928 , 2304 , -4904 ,
- 1752 , 4024 , 4568 , 3272 , 2560 , 608 , 1128 , 3400 , 2144 , -992 , -3240 , -3264 , -1968 , -3920 , -5976 , -4080 ,
- -1424 , -1096 , -2184 , -2136 , -1600 , -3816 , -6736 , -6640 , -5104 , -32 , 3400 , 6944 , 8000 , 4760 , 3232 , 4416 ,
- 1904 , 7392 , 3336 , -2824 , -2448 , 1712 , 1720 , -1384 , -2312 , -1216 , -792 , -1032 , -1048 , -1328 , -1248 , -432 ,
- 656 , -1096 , -4768 , -13792 , -6424 , 1248 , 872 , 536 , 1256 , 1896 , 2216 , 2648 , 2992 , 3336 , 3928 , 4496 ,
- 4480 , 10016 , 15456 , 17952 , 13048 , 8872 , 5768 , 3016 , -432 , -5624 , -10376 , -13808 , -17456 , -15040 , -8984 , -6896 ,
- -12776 , -12320 , -12112 , -9552 , -8552 , -6528 , -4960 , -2968 , -1336 , 4376 , 9872 , 12640 , 13320 , 10192 , 9832 , 10872 ,
- 11504 , 17136 , 13720 , 4704 , -1232 , -4304 , -6024 , -5920 , -5168 , -5728 , -5584 , -4984 , -2704 , -2168 , -2112 , -1136 ,
- -21904 , -10168 , -7024 , -3928 , -3384 , 2632 , 7144 , 6840 , 3328 , 1080 , -1440 , 2560 , 2400 , 2544 , 6792 , 12520 ,
- -5624 , -3840 , -1144 , 1976 , 5928 , 11032 , 12960 , 8904 , 4208 , -1208 , -5624 , -6976 , -6816 , -5680 , -4096 , -4008 ,
- -6144 , -13096 , -584 , 3296 , 1888 , 928 , 1800 , 1400 , 1360 , 1536 , 1368 , 1792 , 2032 , 1032 , 440 , 936 ,
- 11408 , 7680 , -1800 , -5968 , -9432 , -10216 , -9208 , -6496 , -5136 , -2704 , 992 , 4472 , 7248 , 6808 , 5392 , 6960 ,
- -1896 , -3464 , 2944 , 9976 , 6208 , 4840 , 2976 , -688 , -1752 , -1456 , -2336 , -2912 , -2616 , -2816 , -3208 , -3800 ,
- 5776 , 8536 , 7128 , 6888 , 6600 , 9088 , 7080 , -40 , -360 , -3832 , -7640 , -5192 , -2648 , -2912 , -11704 , -16760 ,
- -12496 , -15912 , -11792 , -5288 , -856 , 296 , -416 , 1320 , 3128 , 5064 , 5352 , 6272 , 6928 , 6656 , 5896 , 5848 ,
- 1912 , 2064 , 1344 , 1048 , 2592 , 2200 , -944 , -1656 , -816 , -5840 , -10576 , -5456 , -176 , 1808 , 3912 , 8560 ,
- 1568 , -1384 , -7912 , -1256 , 1728 , 2248 , 1904 , 392 , -456 , -360 , 656 , 904 , 1016 , 760 , 464 , -264 ,
- -120 , 48 , 448 , 0 , 696 , 1096 , 488 , 152 , 1864 , 4400 , 2848 , -168 , -2384 , -3120 , -3592 , -2656 ,
- -5232 , -3632 , -4264 , -2352 , -2128 , -1848 , -1512 , -400 , 1592 , 1208 , -16 , -800 , -424 , 3016 , 7024 , 9784 ,
- 18344 , 5184 , -408 , -1416 , -1904 , -488 , -704 , -1256 , -1104 , -1232 , -2264 , -2504 , -2088 , -2120 , -2776 , -3272 ,
- -1304 , -1072 , -992 , -1688 , -1168 , -1344 , -1280 , 584 , 1688 , 456 , -1464 , -2000 , -400 , 2392 , 4040 , 3568 ,
- 14784 , 15304 , 12752 , 7616 , 5384 , 5928 , 6856 , 1112 , -4496 , -9040 , -13088 , -12584 , -10176 , -9328 , -9488 , -1528 ,
- -2888 , -7528 , -13744 , -16216 , -13232 , -9088 , -7384 , -4312 , -1464 , 3944 , 8176 , 10192 , 17080 , 15872 , 10728 , 9872 ,
- 10880 , 9704 , 5888 , 2192 , 3280 , 4544 , 1144 , -1072 , -3952 , -6872 , -9712 , -6848 , -2696 , -5512 , -5248 , 4304 ,
- -14480 , 576 , 2424 , 1096 , 1448 , 1544 , 992 , 1336 , 1344 , 752 , 152 , 616 , 936 , 616 , -16 , 680 ,
- -12000 , -7664 , -2680 , -496 , -1608 , 2592 , 7576 , 9280 , 12576 , 9576 , 3256 , -288 , -3216 , -5392 , -6208 , -5304 ,
- -5584 , -6016 , -6232 , -5184 , -6632 , -7168 , -4296 , 328 , 3936 , 8224 , 8200 , 6736 , 4760 , 4576 , 3400 , 952 ,
- 2288 , 2368 , 5984 , 832 , -8112 , -9376 , -3656 , -1216 , 120 , 1048 , 1440 , 1880 , 2560 , 2360 , 936 , 536 ,
- 2568 , 4440 , 5712 , 5072 , 4120 , -312 , -4944 , -6440 , -6424 , -3376 , -1504 , -856 , 664 , 784 , 432 , 48 ,
- 8304 , 7392 , 7344 , 5608 , 5952 , 5536 , 5408 , 6632 , 5584 , 848 , -5448 , -7904 , -10480 , -13136 , -12536 , -9104
-};
-#endif
const float ivas_sns_cdbks_side_tcx10_stage2[ 8 * 16 ] =
{
-0.13989258f, -0.024658203f, 0.12670898f, 0.027832031f, 0.06689453f, 0.12817383f, 0.07495117f, -0.01977539f, -0.05834961f, -0.07543945f, -0.06542969f, -0.0546875f, -0.04345703f, -0.0063476562f, 0.034179688f, 0.029541016f,
@@ -8843,25 +6592,8 @@ const float ivas_sns_cdbks_side_tcx10_stage2[ 8 * 16 ] =
0.20898438f, -0.011230469f, -0.08496094f, -0.010986328f, 0.032958984f, -0.013183594f, -0.057861328f, -0.07104492f, -0.06689453f, -0.056396484f, -0.047851562f, -0.03491211f, -0.011962891f, 0.032714844f, 0.08178711f, 0.11035156f,
};
-#ifdef IVAS_FLOAT_FIXED
-/*Q15*/
-const Word16 ivas_sns_cdbks_side_tcx10_stage2_fx[ 8 * 16 ] =
-{
- -4584 , -808 , 4152 , 912 , 2192 , 4200 , 2456 , -648 , -1912 , -2472 , -2144 , -1792 , -1424 , -208 , 1120 , 968 ,
- -2200 , -3752 , -3208 , -2992 , -3992 , -328 , 3600 , 3784 , 1968 , 1248 , 672 , 568 , 792 , 928 , 1256 , 1656 ,
- 1808 , 1000 , 1280 , 1904 , 704 , 1064 , 1312 , -288 , -1832 , -784 , 1216 , 2080 , 888 , -2416 , -4176 , -3776 ,
- 3672 , 6576 , 1488 , -3552 , -4648 , -2792 , -1064 , 1112 , 1448 , 216 , -408 , -608 , -440 , -344 , -256 , -400 ,
- -1368 , -2416 , -4856 , 696 , 5248 , 3904 , 1832 , 2648 , 4112 , 1776 , -1008 , -1336 , -1976 , -2336 , -2544 , -2376 ,
- -2440 , -1352 , -1328 , -2248 , -1384 , -1264 , -1680 , -2912 , -1816 , 1208 , 2960 , 2192 , 2920 , 4296 , 2664 , 176 ,
- -1736 , 1104 , 5248 , 5632 , 808 , -4352 , -4568 , -1376 , 224 , 664 , 280 , 48 , -376 , -992 , -736 , 128 ,
- 6848 , -368 , -2784 , -360 , 1080 , -432 , -1896 , -2328 , -2192 , -1848 , -1568 , -1144 , -392 , 1072 , 2680 , 3616
-};
-#endif
const float *const ivas_sns_cdbks_side_tcx10[SNS_MSVQ_NSTAGES_SIDE] = { ivas_sns_cdbks_side_tcx10_stage1, ivas_sns_cdbks_side_tcx10_stage2 };
-#ifdef IVAS_FLOAT_FIXED
-const Word16 *const ivas_sns_cdbks_side_tcx10_fx[SNS_MSVQ_NSTAGES_SIDE] = { ivas_sns_cdbks_side_tcx10_stage1_fx, ivas_sns_cdbks_side_tcx10_stage2_fx };
-#endif
const int16_t sns_1st_cdbk[2][2][8 * 32] =
{
{ /* split 1 */
@@ -9104,1475 +6836,3 @@ const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[9] =
{ +0.000000e+000f, +5.937500e-002f, +1.375000e-001f, +2.343750e-001f, +3.500000e-001f, +4.843750e-001f, +6.375000e-001f, +8.093750e-001f, +1.000000e+000f } /* data */
}
};
-
-#ifdef IVAS_FLOAT_FIXED
-const ACPL_QUANT_TABLE_FX ivas_mc_paramupmix_alpha_quant_table_fx =
-{
- 33, /* nquant */
- 16, /* offset */
- {
- -536870912, -485700416, -439563072, -398458880, -362387872, -331350016, -305345344,
- -284373824, -268435456, -252497104, -231525584, -205520896, -174483040, -138412032,
- -97307856, -51170508, 0, 51170508, 97307856, 138412032, 174483040,
- 205520896, 231525584, 252497104, 268435456, 284373824, 305345344, 331350016,
- 362387872, 398458880, 439563072, 485700416, 536870912, 0, 0
- } /* data in Q28 */
-};
-
-const ACPL_QUANT_TABLE_FX ivas_mc_paramupmix_beta_quant_table_fx[9] =
-{
- {
- 9, /* nquant */
- 0, /* offset */
- { 0, 63753420, 147639504, 251658240, 375809632, 520093696, 684510400, 869059776, 1073741824 } /* data in Q28 */
- },
- { /* Beta #2 */
- 9, /* nquant */
- 0, /* offset */
- { 0, 54638668, 126531672, 215678976, 322080672, 445736544, 586646912, 744811456, 920230272 } /* data in Q28 */
- },
- { /* Beta #3 */
- 9, /* nquant */
- 0, /* offset */
- { 0, 46420464, 107500024, 183238656, 273636384, 378693184, 498409216, 632784256, 781818240 } /* data in Q28 */
- },
- { /* Beta #4 */
- 9, /* nquant */
- 0, /* offset */
- { 0, 39098780, 90544544, 154337280, 230477024, 318963584, 419797344, 532978048, 658505728 } /* data in Q28 */
- },
- { /* Beta #5 */
- 9, /* nquant */
- 0, /* offset */
- { 0, 32673642, 75665248, 128974864, 192602432, 266548032, 350811584, 445393216, 550292672 } /* data in Q28 */
- },
- { /* Beta #6 */
- 9, /* nquant */
- 0, /* offset */
- { 0, 27144998, 62862136, 107151352, 160012704, 221446144, 291451648, 370029408, 457179136 } /* data in Q28 */
- },
- { /* Beta #7 */
- 9, /* nquant */
- 0, /* offset */
- { 0, 22512928, 52135212, 88866816, 132707776, 183658096, 241717760, 306886688, 379165088 } /* data in Q28 */
- },
- { /* Beta #8 */
- 9, /* nquant */
- 0, /* offset */
- { 0, 18777374, 43484452, 74121200, 110687696, 153183840, 201609712, 255965264, 316250528 } /* data in Q28 */
- },
- { /* Beta #9 */
- 9, /* nquant */
- 0, /* offset */
- { 0, 15938355, 36909876, 62914560, 93952408, 130023424, 171127600, 217264944, 268435456 } /* data in Q28 */
- }
-};
-#endif // IVAS_FLOAT_FIXED
-
-const Word32 one_by_q_level[64] =
-{ 0, 2147483647, 1073741824, 715827904, 536870912, 429496736,
-357913952, 306783392, 268435456, 238609296, 214748368,
-195225792, 178956976, 165191056, 153391696, 143165584,
-134217728, 126322568, 119304648, 113025456, 107374184,
-102261128, 97612896, 93368856, 89478488, 85899344,
-82595528, 79536432, 76695848, 74051160, 71582792,
-69273664, 67108864, 65075264, 63161284, 61356676,
-59652324, 58040100, 56512728, 55063684, 53687092,
-52377648, 51130564, 49941480, 48806448, 47721860,
-46684428, 45691140, 44739244, 43826196, 42949672,
-42107524, 41297764, 40518560, 39768216, 39045156,
-38347924, 37675152, 37025580, 36398028, 35791396,
-35204648, 34636832, 34087044 };
-
-/* clang-format on */
-
-#ifdef IVAS_FLOAT_FIXED
-
-/* Q Factor is 31*/
-const Word32 ivas_han_win_48k_fx[L_FRAME32k] = {
- 5760, 22976, 51712, 91904, 143552, 206784, 281408, 367552, 465216,
- 574272, 694912, 826944, 970496, 1125504, 1292032, 1470016, 1659456,
- 1860352, 2072704, 2296576, 2531904, 2778624, 3036864, 3306560, 3587648,
- 3880256, 4184256, 4499712, 4826624, 5164992, 5514752, 5875968, 6248576,
- 6632640, 7028096, 7434944, 7853248, 8282880, 8723968, 9176448, 9640320,
- 10115584, 10602176, 11100224, 11609536, 12130304, 12662400, 13205824, 13760576,
- 14326720, 14904192, 15492928, 16093056, 16704512, 17327232, 17961216, 18606592,
- 19263168, 19931072, 20610240, 21300672, 22002368, 22715328, 23439488, 24174912,
- 24921600, 25679424, 26448512, 27228800, 28020288, 28822976, 29636864, 30461888,
- 31298048, 32145344, 33003840, 33873472, 34754176, 35646016, 36548992, 37463040,
- 38388224, 39324416, 40271680, 41230016, 42199424, 43179840, 44171264, 45173696,
- 46187200, 47211648, 48247104, 49293504, 50350848, 51419200, 52498432, 53588608,
- 54689664, 55801664, 56924544, 58058304, 59202944, 60358400, 61524736, 62701888,
- 63889856, 65088640, 66298176, 67518528, 68749632, 69991488, 71244096, 72507392,
- 73781440, 75066176, 76361536, 77667648, 78984384, 80311744, 81649728, 82998400,
- 84357568, 85727424, 87107776, 88498688, 89900160, 91312128, 92734656, 94167680,
- 95611136, 97065088, 98529472, 100004288, 101489536, 102985152, 104491200, 106007552,
- 107534336, 109071424, 110618816, 112176512, 113744512, 115322816, 116911296, 118510080,
- 120119040, 121738240, 123367552, 125007104, 126656768, 128316608, 129986496, 131666496,
- 133356608, 135056768, 136766976, 138487232, 140217408, 141957632, 143707840, 145467968,
- 147238016, 149017984, 150807872, 152607616, 154417216, 156236672, 158065920, 159904960,
- 161753728, 163612352, 165480640, 167358720, 169246464, 171143808, 173050880, 174967552,
- 176893888, 178829760, 180775296, 182730304, 184694848, 186668928, 188652480, 190645504,
- 192648000, 194659904, 196681216, 198711936, 200752000, 202801344, 204860032, 206928064,
- 209005376, 211091904, 213187648, 215292672, 217406784, 219530048, 221662528, 223804096,
- 225954752, 228114496, 230283264, 232461056, 234647872, 236843584, 239048320, 241262016,
- 243484544, 245716032, 247956288, 250205440, 252463424, 254730112, 257005632, 259289856,
- 261582784, 263884416, 266194688, 268513664, 270841216, 273177344, 275522048, 277875264,
- 280237056, 282607296, 284986048, 287373184, 289768768, 292172672, 294584960, 297005632,
- 299434560, 301871808, 304317312, 306771072, 309233024, 311703040, 314181312, 316667712,
- 319162240, 321664832, 324175424, 326694080, 329220672, 331755200, 334297728, 336848192,
- 339406528, 341972672, 344546688, 347128448, 349718080, 352315328, 354920384, 357533120,
- 360153536, 362781568, 365417152, 368060352, 370711168, 373369408, 376035200, 378708416,
- 381389120, 384077120, 386772608, 389475456, 392185536, 394902976, 397627648, 400359552,
- 403098624, 405844928, 408598400, 411358976, 414126592, 416901312, 419683008, 422471680,
- 425267392, 428070016, 430879552, 433695936, 436519232, 439349312, 442186112, 445029696,
- 447880064, 450737088, 453600832, 456471168, 459348160, 462231616, 465121600, 468018176,
- 470921280, 473830784, 476746688, 479668928, 482597632, 485532608, 488473856, 491421376,
- 494375168, 497335168, 500301184, 503273472, 506251840, 509236288, 512226752, 515223296,
- 518225728, 521234048, 524248320, 527268608, 530294592, 533326528, 536364096, 539407552,
- 542456576, 545511296, 548571712, 551637888, 554709440, 557786624, 560869376, 563957504,
- 567051264, 570150272, 573254656, 576364544, 579479616, 582600064, 585725696, 588856704,
- 591992704, 595134080, 598280256, 601431680, 604588160, 607749632, 610916224, 614087680,
- 617264128, 620445312, 623631488, 626822336, 630017984, 633218496, 636423616, 639633408,
- 642847872, 646067008, 649290624, 652518784, 655751552, 658988672, 662230400, 665476352,
- 668726784, 671981504, 675240576, 678503808, 681771264, 685042944, 688318784, 691598848,
- 694882880, 698171072, 701463168, 704759296, 708059392, 711363328, 714671296, 717982976,
- 721298560, 724617728, 727940864, 731267392, 734597760, 737931776, 741269376, 744610624,
- 747955200, 751303488, 754655040, 758009984, 761368512, 764730240, 768095360, 771463616,
- 774835200, 778209792, 781587840, 784968832, 788352896, 791740160, 795130304, 798523584,
- 801919616, 805318784, 808720640, 812125312, 815532928, 818943168, 822356288, 825771840,
- 829190272, 832611200, 836034816, 839460928, 842889472, 846320640, 849754112, 853190080,
- 856628352, 860068992, 863511808, 866957056, 870404352, 873853696, 877305408, 880759104,
- 884215040, 887672832, 891132736, 894594496, 898058112, 901523840, 904991232, 908460544,
- 911931456, 915404288, 918878528, 922354560, 925832384, 929311616, 932792512, 936274816,
- 939758720, 943243904, 946730624, 950218560, 953707840, 957198528, 960690368, 964183488,
- 967677568, 971172992, 974669440, 978166912, 981665536, 985164992, 988665600, 992166912,
- 995669248, 999172288, 1002676288, 1006180864, 1009686208, 1013192384, 1016698880, 1020206336,
- 1023714176, 1027222656, 1030731584, 1034241024, 1037750784, 1041260928, 1044771584, 1048282368,
- 1051793600, 1055304896, 1058816512, 1062328192, 1065839872, 1069351872, 1072863808, 1076375808,
- 1079887744, 1083399680, 1086911488, 1090423168, 1093934592, 1097445760, 1100956928, 1104467584,
- 1107977984, 1111488000, 1114997504, 1118506624, 1122015232, 1125523456, 1129031040, 1132538112,
- 1136044544, 1139550336, 1143055360, 1146559616, 1150063104, 1153565696, 1157067648, 1160568576,
- 1164068480, 1167567488, 1171065600, 1174562560, 1178058496, 1181553408, 1185046912, 1188539520,
- 1192030720, 1195520768, 1199009408, 1202496768, 1205982720, 1209467008, 1212950144, 1216431744,
- 1219911936, 1223390336, 1226867328, 1230342528, 1233816192, 1237288064, 1240758144, 1244226560,
- 1247693056, 1251157760, 1254620416, 1258081152, 1261539968, 1264996864, 1268451712, 1271904384,
- 1275355008, 1278803456, 1282249728, 1285693696, 1289135488, 1292574848, 1296011904, 1299446784,
- 1302878976, 1306308736, 1309736064, 1313160960, 1316583296, 1320002944, 1323420032, 1326834304,
- 1330246144, 1333655040, 1337061120, 1340464512, 1343865088, 1347262592, 1350657152, 1354048768,
- 1357437440, 1360823168, 1364205824, 1367585280, 1370961664, 1374334720, 1377704704, 1381071360,
- 1384434816, 1387794944, 1391151616, 1394504960, 1397854976, 1401201152, 1404544000, 1407883520,
- 1411219328, 1414551552, 1417880064, 1421204992, 1424526080, 1427843456, 1431157120, 1434466944,
- 1437772928, 1441074944, 1444373120, 1447667072, 1450957312, 1454243328, 1457525248, 1460803328,
- 1464077056, 1467346688, 1470612096, 1473873408, 1477130240, 1480382848, 1483630976, 1486874752,
- 1490114048, 1493348992, 1496579584, 1499805440, 1503026944, 1506243584, 1509455744, 1512663296,
- 1515866112, 1519064192, 1522257536, 1525446144, 1528629760, 1531808512, 1534982272, 1538151296,
- 1541315328, 1544474368, 1547628288, 1550777216, 1553921024, 1557059840, 1560193152, 1563321472,
- 1566444672, 1569562240, 1572674816, 1575782016, 1578883584, 1581980032, 1585070848, 1588156416,
- 1591236352, 1594310912, 1597379584, 1600442880, 1603500544, 1606552576, 1609598592
-};
-
-/* Q Factor is 31*/
-const Word32 ivas_han_win_32k_fx[L_FRAME32k] = {
- 12928, 51648, 116224, 206656, 322880, 464960, 632832, 826496, 1046016,
- 1291328, 1562496, 1859392, 2182080, 2530560, 2904832, 3304832, 3730560,
- 4182080, 4659328, 5162304, 5690944, 6245312, 6825344, 7431104, 8062464,
- 8719488, 9402112, 10110336, 10844160, 11603520, 12388480, 13198976, 14034944,
- 14896448, 15783424, 16695808, 17633664, 18596928, 19585536, 20599552, 21638912,
- 22703552, 23793472, 24908672, 26049088, 27214720, 28405504, 29621504, 30862592,
- 32128704, 33419968, 34736192, 36077440, 37443712, 38834816, 40250880, 41691776,
- 43157504, 44648064, 46163328, 47703360, 49268032, 50857408, 52471296, 54109824,
- 55772928, 57460416, 59172416, 60908800, 62669568, 64454656, 66264064, 68097664,
- 69955456, 71837440, 73743488, 75673600, 77627712, 79605824, 81607808, 83633664,
- 85683392, 87756864, 89854080, 91974912, 94119360, 96287424, 98478976, 100694016,
- 102932416, 105194240, 107479296, 109787648, 112119232, 114473856, 116851584, 119252352,
- 121676096, 124122688, 126592192, 129084480, 131599488, 134137088, 136697408, 139280192,
- 141885440, 144513152, 147163264, 149835584, 152530176, 155246848, 157985728, 160746560,
- 163529408, 166334144, 169160704, 172009024, 174879040, 177770752, 180683904, 183618624,
- 186574720, 189552128, 192550848, 195570752, 198611840, 201673920, 204756992, 207860992,
- 210985792, 214131392, 217297600, 220484480, 223691840, 226919680, 230167936, 233436416,
- 236725120, 240033984, 243362880, 246711744, 250080512, 253469120, 256877440, 260305472,
- 263753024, 267220096, 270706496, 274212288, 277737280, 281281408, 284844672, 288426880,
- 292027904, 295647808, 299286464, 302943744, 306619456, 310313728, 314026368, 317757248,
- 321506304, 325273472, 329058688, 332861760, 336682688, 340521408, 344377664, 348251520,
- 352142784, 356051456, 359977344, 363920448, 367880640, 371857792, 375851840, 379862656,
- 383890112, 387934272, 391994880, 396071936, 400165248, 404274816, 408400384, 412542016,
- 416699584, 420872960, 425062016, 429266688, 433486912, 437722368, 441973248, 446239360,
- 450520576, 454816704, 459127808, 463453696, 467794112, 472149248, 476518784, 480902784,
- 485300992, 489713344, 494139840, 498580032, 503034304, 507502208, 511983808, 516478848,
- 520987392, 525509120, 530044032, 534592000, 539153088, 543726912, 548313600, 552912832,
- 557524608, 562148736, 566785408, 571434048, 576094784, 580767616, 585452224, 590148608,
- 594856576, 599576192, 604307072, 609049344, 613802752, 618567296, 623342592, 628128896,
- 632925888, 637733504, 642551552, 647380096, 652218752, 657067648, 661926400, 666795264,
- 671673856, 676562176, 681459968, 686367232, 691283648, 696209536, 701144320, 706088192,
- 711040768, 716002176, 720972224, 725950656, 730937472, 735932480, 740935808, 745947008,
- 750966144, 755992960, 761027456, 766069504, 771118976, 776175680, 781239680, 786310528,
- 791388416, 796472896, 801564288, 806662080, 811766400, 816876928, 821993792, 827116544,
- 832245248, 837379776, 842520064, 847665856, 852817152, 857973696, 863135424, 868302208,
- 873474048, 878650560, 883831808, 889017728, 894207936, 899402624, 904601216, 909804160,
- 915010944, 920221696, 925435904, 930653952, 935875200, 941099776, 946327616, 951558592,
- 956792384, 962029120, 967268416, 972510272, 977754624, 983001344, 988250112, 993501120,
- 998753856, 1004008576, 1009264704, 1014522624, 1019781888, 1025042560, 1030304256, 1035566976,
- 1040830784, 1046095232, 1051360384, 1056626048, 1061892224, 1067158592, 1072425280, 1077691776,
- 1082958208, 1088224512, 1093490560, 1098755968, 1104020736, 1109284864, 1114548224, 1119810432,
- 1125071616, 1130331520, 1135590272, 1140847232, 1146102912, 1151356544, 1156608512, 1161858304,
- 1167106048, 1172351616, 1177594624, 1182835200, 1188073344, 1193308544, 1198541056, 1203770368,
- 1208996736, 1214219648, 1219439232, 1224655488, 1229867904, 1235076736, 1240281472, 1245482240,
- 1250679040, 1255871360, 1261059456, 1266243072, 1271421952, 1276596224, 1281765504, 1286929920,
- 1292089088, 1297243008, 1302391552, 1307534592, 1312672000, 1317803520, 1322929280, 1328049152,
- 1333162752, 1338270336, 1343371264, 1348465920, 1353553920, 1358635264, 1363709568, 1368776960,
- 1373837312, 1378890496, 1383936256, 1388974336, 1394004992, 1399028224, 1404043264, 1409050496,
- 1414049792, 1419040640, 1424023424, 1428997632, 1433963392, 1438920448, 1443868672, 1448808064,
- 1453738496, 1458659328, 1463571328, 1468473856, 1473366912, 1478250240, 1483124096, 1487987968,
- 1492841856, 1497685632, 1502519296, 1507342592, 1512155392, 1516957696, 1521749504, 1526530176,
- 1531299968, 1536059008, 1540806912, 1545543424, 1550268672, 1554982528, 1559684864, 1564375168,
- 1569053952, 1573720832, 1578375680, 1583018240, 1587648640, 1592266496, 1596872192, 1601464960,
- 1606045312, 1610612736, 1615167488, 1619708672, 1624237184, 1628752384, 1633254272, 1637742464,
- 1642217216, 1646678400, 1651125504, 1655558784, 1659978240, 1664383616, 1668774784, 1673151488,
- 1677513856, 1681861760, 1686194816, 1690513408, 1694817024, 1699105792, 1703379200, 1707637760,
- 1711880960, 1716108800, 1720321152, 1724518144, 1728699392, 1732865024, 1737014400, 1741148160,
- 1745265792, 1749367296, 1753452288, 1757521152, 1761573632, 1765609344, 1769628416, 1773630976,
- 1777616640, 1781585408, 1785536768, 1789471488, 1793388800, 1797288832, 1801171328, 1805036544,
- 1808883968, 1812713728, 1816525824, 1820320000, 1824096000, 1827854208, 1831594112, 1835315968,
- 1839019520, 1842704384, 1846370944, 1850018944, 1853648256, 1857258624, 1860850432, 1864423168,
- 1867976960, 1871511296, 1875026688, 1878522880, 1881999616, 1885456896, 1888894720, 1892312832,
- 1895711488, 1899089920, 1902448896, 1905787904, 1909106688, 1912405504, 1915684096, 1918942592,
- 1922180480, 1925398016, 1928595200, 1931771904, 1934927616, 1938062848, 1941177344, 1944270848,
- 1947343360, 1950395136, 1953425664, 1956434944, 1959422976, 1962389632, 1965335040, 1968259072,
- 1971161344, 1974042368, 1976901504, 1979739008, 1982554624, 1985348352, 1988120320, 1990870272,
- 1993597952, 1996303616, 1998987264, 2001648384, 2004287104, 2006903552, 2009497728, 2012069376,
- 2014618112, 2017144576, 2019648256, 2022129024, 2024587136, 2027022336, 2029434624, 2031823872,
- 2034190080, 2036533120, 2038853120, 2041149696, 2043423232, 2045673344, 2047900160, 2050103296,
- 2052283136, 2054439552, 2056572160, 2058681216, 2060766464, 2062828160, 2064865920, 2066879744,
- 2068869888, 2070835968, 2072778240, 2074696192, 2076590336, 2078460160, 2080305792, 2082127360,
- 2083924608, 2085697536, 2087446016, 2089170304, 2090870144, 2092545280, 2094196096, 2095822336,
- 2097424128, 2099001088, 2100553472, 2102081024, 2103584000, 2105062144, 2106515456, 2107943936,
- 2109347584, 2110726272, 2112080000, 2113408768, 2114712448, 2115991168, 2117244672, 2118473216,
- 2119676672, 2120854912, 2122007936, 2123135744, 2124238336, 2125315584, 2126367616, 2127394304,
- 2128395520, 2129371648, 2130322048, 2131247232, 2132146944, 2133021184, 2133869824, 2134693120,
- 2135490816, 2136263040, 2137009664, 2137730688, 2138426112, 2139095936, 2139740160, 2140358656,
- 2140951552, 2141518720, 2142060288, 2142576128, 2143066112, 2143530496, 2143969152, 2144382080,
- 2144769280, 2145130496, 2145466112, 2145775872, 2146060032, 2146318208, 2146550528, 2146757120,
- 2146937984, 2147092992, 2147222016, 2147325440, 2147403008, 2147454592, 2147480448
-};
-
-/* Q Factor is 31*/
-const Word32 ivas_han_win_16k_fx[L_FRAME32k] = {
- 51584, 206336, 464192, 825216, 1289344, 1856512, 2526592, 3299648, 4175552,
- 5154240, 6235584, 7419520, 8705856, 10094592, 11585472, 13178432, 14873280,
- 16669824, 18568000, 20567552, 22668288, 24869952, 27172480, 29575488, 32078848,
- 34682304, 37385600, 40188480, 43090624, 46091840, 49191808, 52390144, 55686656,
- 59081024, 62572800, 66161792, 69847552, 73629824, 77508160, 81482176, 85551552,
- 89715904, 93974784, 98327808, 102774528, 107314560, 111947456, 116672768, 121490048,
- 126398720, 131398528, 136488832, 141669184, 146939136, 152298048, 157745600, 163281088,
- 168904064, 174614016, 180410304, 186292480, 192259904, 198312000, 204448256, 210667968,
- 216970688, 223355584, 229822336, 236370112, 242998400, 249706432, 256493632, 263359424,
- 270303040, 277323904, 284421184, 291594368, 298842688, 306165440, 313562048, 321031552,
- 328573440, 336186944, 343871360, 351625792, 359449600, 367342144, 375302528, 383329984,
- 391423744, 399583168, 407807232, 416095424, 424446720, 432860480, 441335680, 449871744,
- 458467776, 467122752, 475836160, 484606976, 493434496, 502317568, 511255744, 520247936,
- 529293184, 538390784, 547539840, 556739456, 565988800, 575286848, 584632832, 594025792,
- 603464960, 612949248, 622477568, 632049536, 641663872, 651319808, 661016192, 670752128,
- 680527040, 690339584, 700189056, 710074240, 719994624, 729948800, 739936128, 749955328,
- 760005760, 770086400, 780196224, 790334336, 800499328, 810690816, 820907648, 831148608,
- 841412992, 851699584, 862007680, 872335936, 882683648, 893049664, 903433024, 913832832,
- 924248064, 934677504, 945120256, 955575552, 966042176, 976519040, 987005248, 997499904,
- 1008001792, 1018510080, 1029023552, 1039541440, 1050062528, 1060585984, 1071110720, 1081635456,
- 1092159616, 1102681984, 1113201664, 1123717504, 1134228480, 1144733696, 1155232256, 1165722752,
- 1176204288, 1186676224, 1197137280, 1207586432, 1218022656, 1228445184, 1238852864, 1249244416,
- 1259619328, 1269976192, 1280314368, 1290632832, 1300930304, 1311205888, 1321458432, 1331687552,
- 1341891840, 1352070400, 1362221952, 1372346112, 1382441472, 1392506880, 1402541952, 1412545280,
- 1422516224, 1432453632, 1442356608, 1452224000, 1462054912, 1471848832, 1481604480, 1491320832,
- 1500997120, 1510632320, 1520225536, 1529775744, 1539282176, 1548744192, 1558160256, 1567529728,
- 1576852096, 1586125824, 1595350272, 1604524800, 1613648128, 1622719872, 1631738624, 1640703744,
- 1649614592, 1658469888, 1667269376, 1676011520, 1684695808, 1693321472, 1701887616, 1710393344,
- 1718837760, 1727220480, 1735540352, 1743796480, 1751988480, 1760115200, 1768175616, 1776169856,
- 1784096256, 1791954688, 1799744000, 1807463424, 1815112576, 1822690048, 1830195968, 1837629184,
- 1844988928, 1852274688, 1859485440, 1866620672, 1873679872, 1880662016, 1887566976, 1894393600,
- 1901141248, 1907809536, 1914397696, 1920904960, 1927330816, 1933674624, 1939936000, 1946114048,
- 1952208256, 1958218240, 1964142848, 1969982336, 1975735552, 1981401984, 1986981376, 1992472832,
- 1997876224, 2003190656, 2008415744, 2013551360, 2018596352, 2023550720, 2028413824, 2033185152,
- 2037864192, 2042450688, 2046944256, 2051344128, 2055650048, 2059861888, 2063978752, 2068000512,
- 2071926784, 2075757056, 2079491072, 2083128576, 2086668928, 2090112128, 2093457408, 2096705024,
- 2099854080, 2102904832, 2105856512, 2108709120, 2111462144, 2114115584, 2116668928, 2119122176,
- 2121475072, 2123727104, 2125878528, 2127928576, 2129877504, 2131724800, 2133470464, 2135114496,
- 2136656384, 2138096128, 2139433728, 2140668928, 2141801472, 2142831616, 2143758848, 2144583424,
- 2145304960, 2145923584, 2146439168, 2146851840, 2147161344, 2147367680, 2147470848, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0
-};
-
-/* Q Factor is 30 */
-const Word32 ivas_sine_delay_32_fx[32] = {
- 52686016, 105245104, 157550640, 209476640, 260898000, 311690784, 361732736, 410903232, 459083776,
- 506158400, 552013632, 596539008, 639627264, 681174656, 721080960, 759250112, 795590272,
- 830013632, 862437504, 892783744, 920979136, 946955776, 970651136, 992008064, 1010975232,
- 1027506880, 1041563136, 1053110208, 1062120192, 1068571456, 1072448448, 1073741824
-};
-
-/* Q Factor is 30 */
-const Word32 ivas_sine_frame_len_640_del_32_fx[577] = {
- 1073737856,
- 1073725888, 1073705984, 1073678144, 1073642368, 1073598592, 1073546880, 1073487168, 1073419584,
- 1073343936, 1073260416, 1073168896, 1073069440, 1072962048, 1072846720, 1072723392, 1072592128,
- 1072452928, 1072305792, 1072150656, 1071987648, 1071816640, 1071637696, 1071450816, 1071256000,
- 1071053248, 1070842560, 1070623936, 1070397312, 1070162880, 1069920448, 1069670080, 1069411776,
- 1069145536, 1068871424, 1068589376, 1068299392, 1068001472, 1067695680, 1067381952, 1067060288,
- 1066730752, 1066393344, 1066047936, 1065694720, 1065333568, 1064964544, 1064587584, 1064202752,
- 1063810048, 1063409472, 1063000960, 1062584576, 1062160384, 1061728256, 1061288320, 1060840448,
- 1060384768, 1059921216, 1059449792, 1058970496, 1058483392, 1057988416, 1057485632, 1056974976,
- 1056456512, 1055930240, 1055396096, 1054854144, 1054304384, 1053746816, 1053181440, 1052608256,
- 1052027200, 1051438400, 1050841856, 1050237504, 1049625280, 1049005376, 1048377664, 1047742144,
- 1047098944, 1046447936, 1045789184, 1045122624, 1044448384, 1043766400, 1043076672, 1042379200,
- 1041674048, 1040961088, 1040240512, 1039512192, 1038776128, 1038032384, 1037280960, 1036521856,
- 1035755008, 1034980544, 1034198464, 1033408640, 1032611200, 1031806016, 1030993280, 1030172864,
- 1029344768, 1028509120, 1027665856, 1026814912, 1025956416, 1025090240, 1024216576, 1023335232,
- 1022446400, 1021549888, 1020645824, 1019734208, 1018815104, 1017888384, 1016954112, 1016012288,
- 1015062912, 1014106112, 1013141760, 1012169856, 1011190464, 1010203584, 1009209280, 1008207424,
- 1007198144, 1006181376, 1005157120, 1004125440, 1003086336, 1002039744, 1000985792, 999924352,
- 998855552, 997779328, 996695744, 995604736, 994506368, 993400640, 992287552, 991167104,
- 990039296, 988904128, 987761664, 986611904, 985454784, 984290304, 983118592, 981939648,
- 980753408, 979559872, 978359104, 977151040, 975935744, 974713216, 973483456, 972246528,
- 971002304, 969750976, 968492480, 967226688, 965953792, 964673728, 963386496, 962092288,
- 960790784, 959482176, 958166464, 956843648, 955513792, 954176832, 952832768, 951481600,
- 950123456, 948758272, 947386048, 946006720, 944620480, 943227264, 941826944, 940419776,
- 939005568, 937584384, 936156224, 934721152, 933279232, 931830336, 930374528, 928911808,
- 927442176, 925965760, 924482432, 922992320, 921495296, 919991424, 918480832, 916963328,
- 915439040, 913907968, 912370176, 910825600, 909274240, 907716160, 906151360, 904579840,
- 903001664, 901416768, 899825216, 898226944, 896622016, 895010432, 893392256, 891767424,
- 890136000, 888497984, 886853376, 885202176, 883544448, 881880128, 880209344, 878532032,
- 876848192, 875157824, 873460992, 871757696, 870047872, 868331648, 866608960, 864879872,
- 863144384, 861402496, 859654208, 857899584, 856138624, 854371264, 852597632, 850817600,
- 849031296, 847238720, 845439808, 843634688, 841823296, 840005632, 838181760, 836351680,
- 834515456, 832672960, 830824384, 828969600, 827108672, 825241600, 823368448, 821489152,
- 819603840, 817712384, 815814912, 813911360, 812001728, 810086208, 808164608, 806237056,
- 804303424, 802363904, 800418496, 798467072, 796509760, 794546560, 792577408, 790602432,
- 788621568, 786634880, 784642368, 782644096, 780640000, 778630016, 776614336, 774592896,
- 772565696, 770532864, 768494208, 766449856, 764399872, 762344192, 760282944, 758215936,
- 756143424, 754065280, 751981504, 749892160, 747797248, 745696832, 743590848, 741479424,
- 739362432, 737240000, 735112128, 732978752, 730839936, 728695744, 726546176, 724391168,
- 722230784, 720065088, 717894080, 715717696, 713536000, 711349056, 709156864, 706959360,
- 704756672, 702548672, 700335488, 698117184, 695893696, 693665024, 691431168, 689192192,
- 686948224, 684699008, 682444864, 680185600, 677921280, 675651968, 673377536, 671098176,
- 668813888, 666524608, 664230464, 661931328, 659627264, 657318400, 655004544, 652685952,
- 650362432, 648034112, 645701056, 643363136, 641020480, 638673088, 636320896, 633964032,
- 631602496, 629236224, 626865344, 624489792, 622109632, 619724800, 617335424, 614941504,
- 612542976, 610139968, 607732352, 605320256, 602903680, 600482624, 598057152, 595627264,
- 593192960, 590754240, 588311104, 585863680, 583411840, 580955712, 578495296, 576030528,
- 573561536, 571088320, 568610816, 566129216, 563643264, 561153152, 558659008, 556160576,
- 553658112, 551151488, 548640896, 546126144, 543607360, 541084480, 538557696, 536026848,
- 533492096, 530953376, 528410656, 525864096, 523313568, 520759232, 518200960, 515638880,
- 513073024, 510503328, 507929856, 505352608, 502771616, 500186880, 497598464, 495006400,
- 492410624, 489811200, 487208128, 484601440, 481991200, 479377376, 476760000, 474139104,
- 471514656, 468886720, 466255328, 463620448, 460982144, 458340480, 455695360, 453046880,
- 450395040, 447739872, 445081408, 442419584, 439754496, 437086176, 434414624, 431739840,
- 429061792, 426380672, 423696320, 421008864, 418318304, 415624576, 412927808, 410227968,
- 407525120, 404819200, 402110304, 399398464, 396683616, 393965856, 391245120, 388521568,
- 385795104, 383065760, 380333600, 377598592, 374860800, 372120256, 369376960, 366630848,
- 363882080, 361130624, 358376480, 355619648, 352860192, 350098176, 347333536, 344566304,
- 341796512, 339024192, 336249376, 333472064, 330692256, 327910016, 325125344, 322338304,
- 319548832, 316756960, 313962784, 311166304, 308367488, 305566368, 302763008, 299957376,
- 297149568, 294339552, 291527296, 288712928, 285896416, 283077792, 280257024, 277434208,
- 274609376, 271782464, 268953568, 266122608, 263289760, 260454928, 257618144, 254779488,
- 251938928, 249096480, 246252208, 243406128, 240558224, 237708512, 234857088, 232003888,
- 229148976, 226292384, 223434080, 220574160, 217712592, 214849392, 211984608, 209118256,
- 206250352, 203380944, 200510000, 197637584, 194763696, 191888352, 189011600, 186133440,
- 183253936, 180373024, 177490800, 174607264, 171722416, 168836304, 165948944, 163060368,
- 160170544, 157279584, 154387424, 151494128, 148599712, 145704176, 142807600, 139909920,
- 137011232, 134111504, 131210816, 128309144, 125406504, 122502952, 119598480, 116693128,
- 113786920, 110879856, 107971976, 105063288, 102153832, 99243616, 96332656, 93420992,
- 90508624, 87595600, 84681920, 81767616, 78852704, 75937200, 73021144, 70104536,
- 67187416, 64269804, 61351708, 58433156, 55514176, 52594776, 49674996, 46754840,
- 43834344, 40913520, 37992392, 35070980, 32149316, 29227408, 26305284, 23382966,
- 20460476, 17537830, 14615058, 11692176, 8769208, 5846174, 2923098, 0
-};
-
-
-const Word32 ivas_sine_frame_len_640_del_16_fx[289] = {
- 1073725952,
- 1073678400, 1073599104, 1073488064, 1073345344, 1073170880, 1072964736, 1072726912, 1072457408, 1072156160, 1071823296,
- 1071458752, 1071062528, 1070634688, 1070175232, 1069684096, 1069161472, 1068607168, 1068021312, 1067403904, 1066755008,
- 1066074560, 1065362624, 1064619200, 1063844352, 1063038016, 1062200320, 1061331264, 1060430848, 1059499072, 1058536000,
- 1057541696, 1056516096, 1055459328, 1054371392, 1053252288, 1052102016, 1050920704, 1049708352, 1048465024, 1047190656,
- 1045885376, 1044549184, 1043182208, 1041784320, 1040355712, 1038896320, 1037406272, 1035885568, 1034334272, 1032752448,
- 1031140096, 1029497216, 1027824000, 1026120384, 1024386432, 1022622272, 1020827904, 1019003328, 1017148672, 1015264000,
- 1013349248, 1011404608, 1009430080, 1007425792, 1005391680, 1003327872, 1001234432, 999111424, 996958848, 994776896,
- 992565568, 990324864, 988054912, 985755712, 983427456, 981070144, 978683904, 976268672, 973824576, 971351808,
- 968850240, 966320128, 963761408, 961174272, 958558720, 955914816, 953242752, 950542464, 947814144, 945057728,
- 942273472, 939461440, 936621504, 933753984, 930858880, 927936192, 924986176, 922008896, 919004288, 915972544,
- 912913664, 909827968, 906715264, 903575808, 900409728, 897217024, 893997760, 890752128, 887480128, 884181888,
- 880857600, 877507328, 874131072, 870729024, 867301184, 863847744, 860368832, 856864448, 853334848, 849779968,
- 846199936, 842594944, 838965120, 835310400, 831631104, 827927168, 824198848, 820446144, 816669184, 812868096,
- 809043008, 805194048, 801321216, 797424768, 793504832, 789561344, 785594560, 781604608, 777591488, 773555456,
- 769496640, 765414976, 761310656, 757183936, 753034880, 748863552, 744670080, 740454592, 736217216, 731958144,
- 727677376, 723375232, 719051648, 714706752, 710340864, 705953920, 701546112, 697117632, 692668544, 688198976,
- 683709056, 679198976, 674668864, 670118720, 665548800, 660959296, 656350208, 651721728, 647074048, 642407168,
- 637721344, 633016704, 628293376, 623551488, 618791104, 614012480, 609215744, 604400960, 599568384, 594718080,
- 589850176, 584964864, 580062272, 575142528, 570205824, 565252224, 560281984, 555295168, 550291904, 545272448,
- 540236864, 535185280, 530117952, 525034944, 519936384, 514822496, 509693408, 504549248, 499390144, 494216384,
- 489027968, 483825056, 478607904, 473376640, 468131360, 462872224, 457599424, 452313152, 447013472, 441700608,
- 436374688, 431035904, 425684352, 420320224, 414943680, 409554848, 404153984, 398741152, 393316512, 387880320,
- 382432576, 376973600, 371503488, 366022368, 360530464, 355027904, 349514848, 343991456, 338457920, 332914368,
- 327360992, 321797952, 316225376, 310643520, 305052416, 299452352, 293843392, 288225792, 282599680, 276965152,
- 271322528, 265671856, 260013344, 254347136, 248673408, 242992352, 237304096, 231608848, 225906752, 220197984,
- 214482704, 208761088, 203033328, 197299552, 191559952, 185814672, 180063936, 174307856, 168546624, 162780432,
- 157009424, 151233776, 145453648, 139669232, 133880696, 128088216, 122291928, 116492040, 110688704, 104882096,
- 99072408, 93259768, 87444384, 81626424, 75806048, 69983424, 64158744, 58332160, 52503856, 46674000,
- 40842768, 35010324, 29176854, 23342516, 17507490, 11671948, 5836060, 0
-};
-
-/************************ Q30 *******************************/
-const Word32 ivas_fb_fr_12band_1ms_re_fx[IVAS_FB_12_1MS_LEN] = {
- 1046768256, 1012312512, 944113536, 843565952, 712700800, 554033920, 370399360, 163534048, -67588040,
- -313003296, -547361792, -745791424, -889130944, -964720960, -967822016, -901839040, -777730304,
- -612432896, -426573984, -241764928, -77701744, 50405768, 134107528, 173698992, 183571312,
- 181978912, 174963648, 163434880, 148881184, 132470640, 115304208, 98219512, 81912736,
- 66862960, 53409868, 41724844, 31871182, 23797162, 17385436, 12455156, 8801240,
- 6197829, 4427144, 3280128, 2575327, 2155348, 1897329, 1705752, 1516863,
- 1289431, 1005694, 661856, 267796, -161263, -604780, -1043282, -1457411,
- -1832285, -2155534, -2420027, -2621275, -2759126, -2835035, -2853297, -2818571,
- -2737039, -2614376, -2456980, -2270381, -2060530, -1832512, -1591794, -1343094,
- -1091494, -841376, -597362, -363290, -143021, 60510, 244561, 407408,
- 547618, 664738, 758550, 829643, 878668, 906840, 915250, 905346,
- 878343, 835721, 778738, 708948, 627794, 537107, 438729, 334948,
- 228103, 120925, 16090, -83524, -175327, -256811, -326026, -381381,
- -422046, -447703, -458837, -456405, -442013, -417522, -385138, -347000,
- -305255, -261681, -217812, -174648, -132866, -92642, -53935, -16402,
- 20279, 56463, 92235, 127494, 161728, 194173, 223691, 249012,
- 268700, 281445, 286068, 281804, 268278, 245720, 214858, 177029,
- 133974, 87839, 40901, -4492, -46220, -82436, -111817, -133546,
- -147456, -153913, -153846, -148528, -139528, -128444, -116827, -105934,
- -96699, -89563, -84536, -81138, -78561, -75704, -71400, -64501,
- -54108, -39627, -20946, 1593, 27122, 54374, 81719, 107372,
- 129497, 146446, 156855, 159848, 155068, 142780, 123803, 99496,
- 71589, 42078, 8610925, 16407290, 31915518, 54983844, 85416624, 123087880,
- 168063984, 221958576, 289536032, 364878560, 426914240, 455184448, 434995104, 358099712,
- 224036640, 40240900, -178615296, -412308800, -637390400, -829991424, -968687232, -1037118016,
- -1026013056, -934381184, -769721024, -547208704, -287987072, -16727445, 241188016, 462583776,
- 629070144, 729071296, 758930560, 723116864, 633312128, 506752128, 363680000, 224696192,
- 107612800, 25033840, -24212064, -54589336, -75035176, -87485160, -93580896, -94591848,
- -91737704, -86038536, -78437624, -69711224, -60533488, -51423856, -42794000, -34920752,
- -27987240, -22072318, -17188296, -13279352, -10254646, -7989723, -6353249, -5207335,
- -4426934, -3897128, -3525509, -3236283, -2977071, -2710878, -2419337, -2094076,
- -1738366, -1359253, -969076, -579170, -201992, 153445, 478767, 769398,
- 1021418, 1233894, 1405828, 1538184, 1631253, 1686663, 1705249, 1689093,
- 1639776, 1560317, 1453594, 1324024, 1175972, 1015086, 846649, 676618,
- 509991, 351706, 205173, 73207, -43142, -143513, -229073, -301290,
- -362531, -414799, -460247, -500043, -534968, -564551, -587849, -602888,
- -607619, -599579, -576918, -538114, -482894, -411845, -327078, -231622,
- -129783, -26319, 73437, 164513, 242258, 303205, 344935, 366711,
- 369107, 354325, 325569, 287088, 243371, 199057, 158131, 123882,
- 98274, 82114, 74715, 74333, 78122, 82791, 84734, 80757,
- 68210, 45592, 12513, -29958, -79606, -133015, -186134, -234445,
- -273650, -299897, -310406, -303565, -279332, -239075, -185665, -123028,
- -55984, 10396, 12276729, 12693837, 13547048, 14871155, 16707203, 19094012,
- 22050984, 25567530, 29581572, 33971516, 38534384, 42985632, 46940136, 49924776,
- 51363228, 50604824, 46909464, 39493740, 27503144, 10070768, -13759776, -44999620,
- -84980336, -136135984, -207135712, -303422240, -412817600, -514972896, -589851392, -619651584,
- -591583168, -499579936, -345470464, -138966128, 103208400, 359174656, 604351488, 814326528,
- 967700992, 1048627328, 1048680832, 967863296, 814603776, 604752128, 359708672, 103884792,
- -138140928, -344495008, -498458752, -590328384, -618282624, -588395136, -513462144, -411289888,
- -301917376, -205694144, -134796400, -83778624, -43967052, -12923312, 10688964, 27884292,
- 39622020, 46770036, 50183460, 50644772, 48893804, 45580600, 41282912, 36475948,
- 31549672, 26793770, 22418028, 18548592, 15250408, 12530037, 10357491, 8671122,
- 7396225, 6448686, 5748701, 5221465, 4805724, 4451326, 4123487, 3798131,
- 3463431, 3114322, 2752946, 2383612, 2013354, 1648090, 1293873, 954378,
- 632818, 330406, 48532, -212349, -450755, -665332, -853410, -1012414,
- -1138953, -1230412, -1284349, -1300013, -1277722, -1220043, -1130902, -1016282,
- -883017, -739061, -592113, -449695, -317863, -201395, -102837, -23014,
- 39453, 87271, 124545, 155673, 185224, 216854, 253275, 295449,
- 342868, 393176, 442827, 487113, 521090, 539819, 539332, 516817,
- 471355, 403816, 317194, 216106, 106711, -4112, -109126, -201659,
- -275976, -328059, -355725, -359045, -340068, -302808, -252589, -195699,
- -138533, -87141, -46428, -19866, -8984, -13439, -30918, -57611,
- -88487, -118040, -140755, -151891, -147872, -126858, -88834, -35798,
- 28549, 99021, 169585, 233841, 285797, 320360, 333987, 324942,
- 293611, 242374, 175498, 98630, 18357, -58534, -125609, -177509,
- -210361, -222240, -213241, -185532, -143021, -91031, -35654, 16794,
- 60506, 90695, 104157, 99518, 77443, 40482, -7123, -59963,
- -111945, -157005, -189668, -205697, -202469, -179335, -137639, -80671,
- -13290, 58484, 128123, 189173, 235954, 264066, 270883, 255765,
- 220174, 2505037, 2442157, 2316154, 2126672, 1874467, 1561489, 1192761,
- 775600, 321304, -157412, -645618, -1131069, -1604363, -2065994, -2526609,
- -3015154, -3577470, -4283816, -5223516, -6510031, -8269471, -10642073, -13763168,
- -17761360, -22731886, -28733746, -35756756, -43722016, -52444716, -61644104, -70903304,
- -79696304, -87342288, -93058336, -95895816, -94830640, -88641344, -76058616, -55443336,
- -24863958, 24611116, 107440320, 224788944, 364047616, 507399776, 634242176, 724330048,
- 760427264, 730852288, 631136576, 464936832, 243827808, -13803173, -284784032, -543737088,
- -765995008, -930417472, -1021827456, -1032720576, -964074624, -825139200, -632243584, -406773696,
- -172552176, 47020828, 231770176, 367063072, 445488224, 467504928, 441322720, 381553248,
- 308519520, 243096544, 190940560, 146958368, 109144704, 76984176, 50110068, 28195132,
- 10859917, -2331860, -11867127, -18267046, -22063578, -23780578, -23911906, -22907786,
- -21160858, -19000796, -16689673, -14424574, -12340740, -10519832, -8997765, -7775391,
- -6827615, -6113435, -5583605, -5187945, -4880011, -4620898, -4380691, -4139162,
- -3884798, -3613535, -3326639, -3028821, -2726195, -2424818, -2129499, -1843272,
- -1567228, -1300854, -1042591, -790584, -543428, -300799, -63891, 164435,
- 379755, 576491, 748467, 889663, 994911, 1060624, 1085268, 1069727,
- 1017300, 933554, 825817, 702603, 572797, 444929, 326372, 222801,
- 137707, 72284, 25430, -5886, -26190, -40792, -55143, -74076,
- -101256, -138661, -186386, -242548, -303550, -364410, -419384, -462555,
- -488576, -493231, -474014, -430404, -364059, -278663, -179684, -73826,
- 31531, 129079, 212203, 275656, 315980, 331857, 324141, 295780,
- 251424, 196978, 138929, 83734, 37113, 3535, -14258, -15450,
- -1229, 25423, 60045, 97246, 131265, 156654, 168829, 164631,
- 142633, 103366, 49247, -15601, -85794, -155177, -217478, -266899,
- -298743, -309847, -298949, -266783, -216054, -151145, -77727, -2174,
- 69017, 702811, 654136, 559557, 424419, 255932, 62727, -146313,
- -362395, -578054, -786994, -985086, -1169469, -1339221, -1493760, -1633415,
- -1757450, -1864970, -1953010, -2018235, -2055396, -2060043, -2027296, -1955369,
- -1844129, -1698799, -1527422, -1343910, -1163448, -1004247, -880298, -801810,
- -765486, -754582, -727814, -620985, -336399, 251272, 1302991, 3002489,
- 5560181, 9191239, 14115464, 20525480, 28584940, 38387408, 49958096, 63204572,
- 77930464, 93777392, 110263472, 126708904, 142322784, 156083648, 166946144, 173586320,
- 175308576, 166325584, 128680304, 48303544, -74757040, -231715952, -407042976, -580775616,
- -731094848, -837272320, -882366976, -855569984, -753729472, -582012992, -353498368, -87845872,
- 190881904, 456905760, 685667520, 856595200, 955419584, 975703808, 919454400, 796692096,
- 624085824, 422776032, 215700912, 24714716, -132116288, -242736960, -302620672, -315365760,
- -293500640, -258619744, -225315280, -194015376, -163910608, -135501680, -109209736, -85466480,
- -64529184, -46551644, -31533836, -19377918, -9878438, -2769905, 2268515, 5573895,
- 7492172, 8348992, 8445734, 8040905, 7351921, 6546074, 5747758, 5036624,
- 4458304, 4026662, 3735443, 3561663, 3475902, 3444629, 3437763, 3428836,
- 3399492, 3337488, 3238697, 3103696, 2938339, 2749967, 2547660, 2338971,
- 2130630, 1926285, 1727949, 1534741, 1344902, 1155176, 962956, 765794,
- 563232, 356016, 147339, -58398, -254956, -435840, -594040, -723684,
- -819800, -879714, -902536, -890086, -845966, -775986, -686897, -586473,
- -482133, -380953, -288451, -208799, -143979, -94350, -58234, -32830,
- -14133, 1978, 19701, 42276, 72069, 109808, 154947, 205272,
- 257581, 307614, 350943, 383061, 400284, 399785, 380309, 341971,
- 286657, 217523, 139066, 56385, -24953, -99742, -163283, -212106,
- -243951, -258230, -255733, -167174, -239722, -322173, -408810, -492821,
- -566516, -622391, -653378, -653921, -619965, -549788, -443508, -303565,
- -133727, 60691, 274135, 500595, 734943, 972407, 1209697, 1443978,
- 1673718, 1897211, 2113333, 2319888, 2514652, 2693915, 2854207, 2991285,
- 3102696, 3187122, 3247515, 3290252, 3328147, 3378477, 3464934, 3613501,
- 3852565, 4205968, 4691138, 5309438, 6043184, 6844465, 7633047, 8285794,
- 8638327, 8477588, 7550391, 5561188, 2190063, -2903797, -10053462, -19577218,
- -31739716, -46747292, -64700276, -85602512, -109304912, -135555296, -163926944, -194002976,
- -225285872, -258586768, -293477632, -315364832, -302650912, -242803328, -132218944, 24580560,
- 215544720, 422611008, 623927680, 796557504, 919359168, 975661312, 955439360, 856681664,
- 685819520, 457116384, 191139072, -87558504, -353200000, -581723904, -753469440, -855356160,
- -882212736, -837186048, -731079168, -580827520, -407153984, -231873488, -74945544, 48100840,
- 128479736, 166141328, 175151264, 173462112, 166856272, 156024384, 142286160, 126683672,
- 110236760, 93736176, 77863432, 63103528, 49819328, 38212324, 28380444, 20303444,
- 13891988, 8985083, 5391207, 2889572, 1262319, 294475, -203348, -398749,
- -423662, -382151, -343523, -352875, -428668, -574135, -776792, -1018896,
- -1276918, -1529859, -1757571, -1946540, -2086827, -2175642, -2213314, -2205436,
- -2158564, -2081784, -1982822, -1869689, -1747600, -1621008, -1491391, -1359644,
- -1224514, -1085096, -939557, -787433, -628324, -463767, -295726, -127991,
- 35529, 189782, 330335, 452518, 553054, 629169, 679950, 705285,
- 706896, 687113, 649626, 598183, 537192, 470470, 401849, 334088,
- 269582, 209498, 154619, 104683, 59308, 17469, -21588, -58843,
- -94673, -129406, -162639, -193876, -221997, -245959, -264363, -276167,
- -280285, -276237, -263718, -243144, -215155, -181048, -225261, -273555,
- -307889, -326103, -327476, -312684, -283609, -243038, -194256, -140631,
- -85182, -30244, 22798, 73608, 122885, 172169, 223570, 279366,
- 341593, 411622, 489814, 575248, 665622, 757256, 845294, 923987,
- 987121, 1028456, 1042203, 1023430, 968397, 874758, 741642, 569587,
- 360379, 116796, -157659, -459031, -783110, -1125546, -1481872, -1847416,
- -2217186, -2585716, -2947037, -3294742, -3622346, -3923849, -4194709, -4432970,
- -4640760, -4825675, -5002266, -5192922, -5428408, -5747161, -6193793, -6815752,
- -7658969, -8761350, -10145511, -11809549, -13717971, -15791409, -17898084, -19845242,
- -21374384, -22157722, -21800466, -19845174, -15783279, -9068449, 863064, 14571969,
- 32592328, 55410852, 83458416, 117107272, 156758688, 202942128, 257651808, 325933440,
- 402044000, 464971200, 494205696, 474891008, 398522784, 264288720, 79206760, -142533824,
- -381224512, -613975168, -817483264, -970950784, -1058690624, -1072345920, -1012679872, -893613760,
- -734287744, -546547584, -339769856, -124623176, 88170360, 288225568, 466194112, 614172160,
- 726163904, 798321728, 829131584, 819397568, 772133120, 692285376, 586377152, 462039040,
- 327503712, 191064064, 60554008, -57130884, -156432848, -233429280, -286014272, -313941504,
- -318749984, -303544416, -272698496, -231426688, -185371904, -140057616, -100631488, -69996648,
- -46622364, -28166424, -13810469, -2980571, 4834391, 10133794, 13384151, 15027667,
- 15460742, 15036408, 14051635, 12751812, 11326396, 9916592, 8616869, 7484565,
- 6544389, 5798046, 5229236, 4811721, 4513168, 4300801, 4143382, 4014381,
- 3892172, 3761242, 3611156, 3436579, 3235728, 3009947, 2762235, 2496885,
- 2218419, 1931526, 1640448, 1349202, 1061301, 780105, 508675, 250099,
- 7326, -216639, -418984, -597023, -748502, -871609, -965247, -1029025,
- -1063439, -1069768, -1050128, -1007269, -944511, -865478, -773983, -673761,
- -568371, -460991, -354385, -250799, -152007, -59299, 26411, 104546,
- 174730, 236744, 290418, 335608, 372145, 399853, 418548, 428095,
- 428430, 419636, 401963, 375881, 342083, 301499, 255265, 204699,
- 151239, 96397, 41685, -11436, -61625, -107696, -148661, -183744,
- -212399, -234301, -249338, -257586, -259295, -171383, -167771, -160946,
- -151648, -140875, -129741, -119346, -110602, -104127, -100108, -98276,
- -97857, -97667, -96155, -91604, -82246, -66504, -43110, -11334,
- 28976, 77253, 132282, 192171, 254555, 316653, 375561, 428343,
- 472340, 505222, 525246, 531204, 522588, 499415, 462302, 412189,
- 350367, 278167, 197008, 108113, 12645, -88501, -194453, -304491,
- -417705, -533098, -649202, -764225, -875703, -980757, -1075829, -1157086,
- -1220253, -1261142, -1275529, -1259757, -1210576, -1125738, -1003720, -844248,
- -647867, -416383, -152288, 140834, 458975, 797247, 1150575, 1513140,
- 1879071, 2241774, 2594688, 2930577, 3242477, 3523085, 3766061, 3965621,
- 4118279, 4222622, 4281408, 4301274, 4294860, 4279931, 4280984, 4327080,
- 4452293, 4691546, 5079427, 5643594, 6401946, 7353690, 8475606, 9711576,
- 10969534, 12110916, 12950640, 13248182, 12713298, 10999818, 7719470, 2437137,
- -5306709, -16007364, -30173754, -48382488, -71457888, -101754088, -140816912, -185763344,
- -231466336, -272424224, -303010560, -318021792, -313081312, -285067456, -232401024, -155266144,
- -55676148, 62564504, 194048000, 332049728, 468930560, 596597632, 707022848, 792757376,
- 847434880, 866203136, 846081856, 786193920, 687883392, 554677120, 392130080, 207514704,
- 9432382, -192707744, -389200480, -570675136, -728479808, -856350656, -952308800, -1015864832,
- -1046220032, -1043342848, -1008126784, -942413952, -848923648, -731177152, -593366784, -440223744,
- -276851936, -108565096, 59292484, 221513920, 373199296, 509904800, 627780928, 723682304,
- 795257728, 841006144, 860308096, 853421632, 821452480, 766292160, 690533568, 597361024,
- 490425248, 373702496, 251347920, 127544600, 6357648, -108405296, -213318272, -305445280,
- -382425728, -442537280, -484731648, -508645408, -514583008, -503476768, -476822816, -436599136,
- -385166592, -325160416, -259373680, -190640560, -121721768, -55198692, 6621388, 61783672,
- 108746912, 146423216, 174197536, 191924704, 199906864, 198850976, 189810704, 174114128,
- 153282784, 128943984, 102742896, 76256368, 50914548, 27932052, 8253544, -7485707,
- -18981258, -26263536, -29686804, -29902128, -27874808, -24904632, -21873452, -18924710,
- -16109369, -13513449, -11193274, -9184409, -7497119, -6124396, -5043505, -4222392,
- -3622104, -3201531, -2919256, -2736657, -2618792, -2536063, -2464195, -2384826,
- -2284834, -2156265, -1995319, -1801974, -1578908, -1331064, -1064692, -787000,
- -505396, -227288, 40476, 291657, 521006, 724191, 898044, 1040397,
- 1150221, 1227397, 1272778, 1287922, 1275099, 1237007, 1176756, 1097593,
- 1002895, 895923, 779853, 657586, 531818, 404912, 279016, 155978,
- 37491, -74965, -179989, -276315, -362698, -438012, -501167, -551237,
- -587418, -609171, -616196, -608571, -586708, -551466, -504065, -446144,
- -379632, -306754, -229859, -151391, -73706, 962, 70672, 133776,
- 189046, 235630, 273114, 301432, 320873, 331952, 335393, 331988,
- 322579, 307941, 288792, 265710, 239189, 209598, 177267, 142480,
- 105576, 66945, 27114, -13271, -53400, -92348, -129065, -162474,
- -191486, -215114, -232503, -243037, -246348, -242394, -231432, -214048,
- -191082, -163619, -132881, -100182, -66814, -34004, -2809, 25897,
- 51498, 73603, 92073, 106961, 118497, 127000, 132851, 136409,
- 137987, 137791, 135930, 132384, 127051, 119749, 110286, 98485,
- 84255, 67615, 48748, 27996, 5888, -16902, -39568, -61243,
- -81031, -98099, -111715, -121326, -162998, -160088, -154357, -145969,
- -135159, -122211, -107436, -91156, -73678, -55283, -36214, -16667,
- 3198, 23260, 43411, 63547, 83543, 103238, 122414, 140790,
- 158012, 173664, 187268, 198317, 206286, 210673, 211020, 206956,
- 198214, 184663, 166317, 143347, 116078, 84982, 50655, 13802,
- -24798, -64311, -103888, -142674, -179845, -214613, -246243, -274051,
- -297418, -315773, -328608, -335464, -335942, -329700, -316476, -296086,
- -268464, -233660, -191884, -143511, -89112, -29451, 34490, 101547,
- 170354, 239401, 307043, 371566, 431212, 484258, 529040, 564034,
- 587875, 599425, 597777, 582315, 552693, 508884, 451144, 380049,
- 296447, 201490, 96577, -16612, -136189, -260017, -385787, -510997,
- -633031, -749140, -856549, -952436, -1034059, -1098739, -1143998, -1167540,
- -1167397, -1141901, -1089827, -1010351, -903194, -768558, -607272, -420711,
- -210944, 19368, 266825, 527423, 796421, 1068545, 1337896, 1598264,
- 1843121, 2066095, 2261075, 2422874, 2547443, 2632705, 2678810, 2689041,
- 2669949, 2632165, 2590157, 2562709, 2571986, 2643435, 2803848, 3080521,
- 3498078, 4076931, 4828788, 5754789, 6839761, 8050914, 9330877, 10598671,
- 11740823, 12618964, 13055458, 12877144, 11632705, 8232321, 1712792, -8269488,
- -21676128, -38124492, -56918448, -77081536, -97412152, -116545320, -133029752, -145407808,
- -152301808, -152496656, -145019616, -129208872, -104771344, -71822984, -30912372, 16976826,
- 70442824, 127704136, 186656480, 244947920, 300068000, 349448640, 390571840, 421080480,
- 438886880, 442275104, 429992032, 401322976, 356148672, 294980192, 218969888, 129897104,
- 30128484, -77446248, -189501472, -302382688, -412230048, -515113984, -607177664, -684781632,
- -744644480, -783974400, -800586304, -792999936, -760514496, -703256576, -622199232, -519150624,
- -396712160, -258207056, -107581408, 50718884, 211891600, 370936768, 522825024, 662669440,
- 785895232, 888400000, 966700096, 1018056320, 1040574720, 1033278976, 996150976, 930138240,
- 837128128, 719891072, 581993344, 427717504, 261968336, 89712808, -84335696, -255470448,
- -419050304, -570668224, -706270592, -822273344, -915657792, -984053440, -1025798848, -1039984064,
- -1026470080, -985886720, -919608064, -829707328, -718891392, -590417984, -447997504, -295682944,
- -137750720, 21423548, 177490944, 326252736, 463778272, 586513216, 691375872, 775837824,
- 837987456, 876574784, 891035520, 881494912, 848751424, 794240448, 719980032, 628500544,
- 522760032, 406049152, 281887712, 153916800, 25789502, -98936256, -216899504, -325029824,
- -420629824, -501444512, -565715328, -612217792, -640282304, -649796800, -641192896, -615415808,
- -573878848, -518405728, -451161088, -374573216, -291251040, -203897664, -115224504, -27867474,
- 55691216, 133193880, 202668432, 262478208, 311359200, 348444032, 373271968, 385785760,
- 386315040, 375548096, 354492672, 324428128, 286850336, 243411744, 195858832, 145969024,
- 95489384, 46079124, -742270, -43639588, -81497992, -113449472, -138889424, -157482720,
- -169159888, -174103616, -172726688, -165642240, -153628176, -137586864, -118502264, -97395800,
- -75283368, -53134364, -31835154, -12157406, 5266631, 19962188, 31621642, 40107016,
- 45443876, 47808948, 47510056, 44961972, 40656428, 35131248, 28935710, 22599292,
- 16597725, 11327856, 7077267, 4007588, 2004813, 698472, -159366, -668117,
- -915026, -972592, -904574, -762742, -589613, -417127, -268777, -159451,
- -97435, -84877, -119630, -195920, -305911, -440293, -589480, -743976,
- -895177, -1035483, -1158746, -1260167, -1336478, -1385695, -1407139, -1401122,
- -1368900, -1312362, -1233971, -1136502, -1023004, -896600, -760484, -617774,
- -471538, -324684, -179997, -40056, 92731, 216208, 328430, 427747,
- 512770, 582446, 636028, 673130, 693701, 698053, 686825, 660989,
- 621793, 570758, 509593, 440184, 364504, 284586, 202444, 120043,
- 39232, -38277, -110964, -177497, -236776, -287918, -330276, -363413,
- -387116, -401358, -406302, -402269, -389735, -369301, -341693, -307732,
- -268335, -224488, -177248, -127707, -76997, -26251, 23403, 70879,
- 115146, 155262, 190393, 219846, 243073, 259708, 269557, 272617,
- 269062, 259245, 243667, 222969, 197896, 169274, 137970, 104873,
- 70854, 36751, 3337, -28682, -58696, -86176, -110690, -131889,
- -149514, -163373, -173350, -179385, -181478, -179682, -174108, -164916,
- -152331, -136632, -118169, -97351, -74653, -50603, -25781, -795,
- 23721, 47148, 68883, 88374, 105138, 118782, 129014, 135661,
- 138666, 138092, 134111, 126995, -72761, -56245, -38209, -19019,
- 926, 21206, 41377, 60995, 79616, 96811, 112175, 125335,
- 135964, 143783, 148571, 150171, 148491, 143510, 135276, 123908,
- 109592, 92580, 73182, 51764, 28741, 4570, -20258, -45231,
- -69817, -93477, -115679, -135902, -153653, -168473, -179953, -187739,
- -191549, -191176, -186499, -177490, -164220, -146855, -125663, -101009,
- -73349, -43220, -11236, 21933, 55569, 88924, 121238, 151753,
- 179734, 204484, 225359, 241786, 253272, 259417, 259926, 254614,
- 243416, 226386, 203704, 175675, 142727, 105408, 64381, 20414,
- -25629, -72803, -120096, -166448, -210776, -251991, -289028, -320870,
- -346577, -365309, -376354, -379149, -373302, -358603, -335043, -302817,
- -262324, -214167, -159142, -98227, -32564, 36563, 107751, 179503,
- 250256, 318414, 382371, 440551, 491426, 533563, 565640, 586488,
- 595111, 590727, 572783, 540991, 495337, 436112, 363911, 279647,
- 184541, 80117, -31824, -149225, -269813, -391137, -510624, -625621,
- -733459, -831498, -917191, -988123, -1042078, -1077064, -1091376, -1083624,
- -1052786, -998241, -919828, -817879, -693286, -547530, -382754, -201766,
- -8088, 194084, 399903, 603998, 800600, 983813, 1147877, 1287596,
- 1398749, 1478666, 1526731, 1545029, 1538843, 1517225, 1493308, 1484620,
- 1512997, 1604428, 1788384, 2097022, 2563860, 3222329, 4104042, 5237042,
- 6645377, 8348986, 10388584, 12857124, 15616492, 18195220, 20086854, 20833852,
- 20030730, 17354698, 12586763, 5632648, -3464912, -14518786, -27198686, -41038776,
- -55453300, -69758216, -83199240, -94984200, -104319184, -110446312, -112682200, -110454752,
- -103337336, -91078120, -73623784, -51135812, -23998892, 7179643, 41579336, 78185368,
- 115815920, 153157712, 188808416, 221324672, 249274288, 271290496, 286126560, 292708608,
- 290184736, 277968256, 255773584, 223642784, 181961872, 131465504, 73229656, 8652162,
- -60578956, -132528392, -205066832, -275933056, -342803008, -403363968, -455390976, -496823520,
- -525839776, -540925440, -540935296, -525144960, -493290304, -445593920, -382776288, -306051584,
- -217107424, -118068792, -11447024, 99925072, 212970192, 324453472, 431076864, 529578144,
- 616831424, 689946368, 746362368, 783935232, 801012800, 796497984, 769895232, 721340928,
- 651613760, 562127360, 454901984, 332518336, 198053008, 54997860, -92834592, -241417152,
- -386622272, -524341152, -650604416, -761700160, -854286656, -925495040, -973019712, -995193152,
- -991042688, -960327360, -903553472, -821968256, -717531648, -592866496, -451188992, -296220608,
- -132085040, 36808156, 205888512, 370555840, 526312064, 668891968, 794386240, 899356480,
- 980934400, 1036909248, 1065792000, 1066936320, 1040546496, 987467136, 909149824, 807691200,
- 685777408, 546616256, 393851264, 231466848, 63682176, -105158952, -270702912, -428699744,
- -575114688, -706232704, -818754752, -909882496, -977389312, -1019675904, -1035808896, -1025541568,
- -989316224, -928248256, -844092096, -739190912, -616410240, -479058656, -330797152, -175539264,
- -17346022, 139682832, 291517408, 434303488, 564462720, 678784448, 774506688, 849384640,
- 901743936, 930519040, 935273728, 916205312, 874131520, 810461056, 727147968, 626633152,
- 511772224, 385754272, 252012128, 114127448, -24266644, -159583088, -288375648, -407428352,
- -513837376, -605083264, -679091392, -734279488, -769591104, -784513984, -779083840, -753872640,
- -709962816, -648908288, -572682880, -483618976, -384336832, -277668320, -166575776, -54069264,
- 56875640, 163397472, 262823600, 352738016, 431040544, 495996064, 546272512, 580966656,
- 599617664, 602207872, 589151552, 561271552, 519765696, 466163232, 402273376, 330127520,
- 251916672, 169926224, 86470040, 3825426, -75828792, -150469632, -218281248, -277698720,
- -327443424, -366549120, -394378400, -410629056, -415330784, -408832544, -391780864, -365090688,
- -329909184, -287574176, -239568528, -187472016, -132911848, -77513936, -22855780, 29577298,
- 78431608, 122519032, 160844800, 192628240, 217316432, 234590304, 244363440, 246773968,
- 242169824, 231088240, 214230352, 192431808, 166630544, 137832768, 107078304, 75406624,
- 43824304, 13275079, -15386599, -41417940, -64205456, -83277544, -98311776, -109136888,
- -115729656, -118206952, -116813448, -111905648, -103932808, -93415768, -80924248, -67053716,
- -52402552, -37550280, -23037704, -9349536, 3099972, 13977919, 23039974, 30133750,
- 35198404, 38260568, 39427008, 38874332, 36836352, 33589632, 29437968, 24696382,
- 19675442, 14666438, 9928193, 5675861, 2072344, -777524, -2829749, -4100893,
- -4665396, -4650187, -4237832, -3670417, -3111787, -2588999, -2111154, -1692910,
- -1342761, -1064792, -858034, -718046, -637371, -606817, -616039, -654489,
- -711863, -778707, -846654, -908726, -959364, -994500, -1011439, -1008780,
- -986218, -944402, -884714, -809115, -719958, -619860, -511553, -397807,
- -281326, -164706, -50372, 59439, 162717, 257679, 342798, 416803,
- 478690, 527728, 563468, 585733, 594629, 590529, 574063, 546100,
- 507723, 460200, 404950, 343501, 277458, 208453, 138112, 68013,
- -346, -65582, -126442, -181831, -230824, -272671, -306807, -332846,
- -350584, -359987, -361185, -354465, -340256, -319119, -291736, -258891,
- -221458, -180384, -136669, -91350, -45474, -81, 43821, 85280,
- 123419, 157461, 186741, 210730, 229036, 241421, 247797, 248224,
- 242908, 232183, 216503, 196419, 172565, 145631, 116349, 85467,
- 53736, 21886, -9380, -39409, -67596, -93402, -116356, -136059,
- -152188, -164499, -172828, -177091, -177288, -173497, -165880, -154675,
- -140195, -122823, -103005, -81242, -58073, -34073, -9827, 14076,
- 37067, 58607, 78202, 95423, 109908, 121382, 129651, 134613,
- 136254, 134645, 129937, 122348, -44011, -24892, -4829, 15720,
- 36281, 56369, 75506, 93227, 109092, 122701, 133696, 141775,
- 146697, 148290, 146451, 141157, 132459, 120486, 105445, 87616,
- 67345, 45046, 21187, -3718, -29118, -54435, -79078, -102456,
- -123992, -143137, -159380, -172271, -181421, -186524, -187359, -183802,
- -175830, -163523, -147066, -126746, -102945, -76138, -46876, -15782,
- 16466, 49153, 81535, 112860, 142385, 169387, 193186, 213156,
- 228742, 239468, 244958, 244937, 239247, 227851, 210839, 188425,
- 160956, 128901, 92851, 53506, 11664, -31790, -75908, -119691,
- -162116, -202159, -238815, -271127, -298207, -319262, -333613, -340713,
- -340163, -331730, -315348, -291129, -259362, -220512, -175214, -124263,
- -68599, -9299, 52451, 115372, 178114, 239282, 297468, 351266,
- 399319, 440334, 473120, 496614, 509913, 512295, 503248, 482484,
- 449964, 405893, 350744, 285237, 210350, 127286, 37477, -57465,
- -155750, -255468, -354592, -451046, -542708, -627478, -703289, -768173,
- -820272, -857921, -879657, -884318, -871054, -839446, -789522, -721878,
- -637689, -538829, -427837, -308012, -183306, -58351, 61766, 171575,
- 265595, 338530, 385818, 403920, 391045, 347469, 276387, 184146,
- 81162, -18121, -94264, -123407, -76036, 81568, 389991, 895519,
- 1710701, 3002792, 4825273, 7109226, 9729646, 12512602, 15248433, 17702624,
- 19630608, 20791430, 20963006, 19955790, 17626208, 13887624, 8719623, 2174045,
- -5621665, -14464834, -24081046, -34131360, -44222504, -53920252, -62765096, -70290080,
- -76039792, -79590136, -80567832, -78669104, -73676656, -65474260, -54058260, -39545472,
- -22176940, -2317326, 19550376, 42834668, 66849928, 90834856, 113974736, 135426640,
- 154347008, 169920736, 181390720, 188086896, 189453888, 185076096, 174699280, 158247904,
- 135837376, 107780464, 74587640, 36960972, -4218522, -47909872, -92937136, -138019856,
- -181808096, -222921312, -259989808, -291697568, -316825344, -334292320, -343195264, -342844000,
- -332791264, -312856704, -283143456, -244046832, -196254272, -140736784, -78731208, -11714102,
- 58632672, 130463552, 201817312, 270670080, 334992000, 392806176, 442247552, 481620896,
- 509455360, 524554208, 526038368, 513381696, 486437344, 445453888, 391080448, 324360480,
- 246714016, 159908576, 66019492, -32619810, -133476120, -233882016, -331106848, -422431424,
- -505224224, -577016896, -635577152, -678976448, -705651136, -714454400, -704697856, -676181184,
- -629208640, -564592384, -483640672, -388133216, -280282016, -162679760, -38236756, 89892360,
- 218389968, 343862752, 462932736, 572329472, 668980864, 750100160, 813266368, 856496128,
- 878304640, 877753856, 854486592, 808744960, 741372928, 653802560, 548023872, 426538944,
- 292301664, 148644560, -806035, -152223392, -301680672, -445254848, -579131904, -699710144,
- -803698816, -888209216, -950836352, -989727616, -1003637824, -991967616, -954785856, -892832832,
- -807506624, -700830848, -575405568, -434342368, -281185056, -119818392, 45633172, 210913568,
- 371747552, 523954144, 663558144, 786896576, 890717440, 972267648, 1029367616, 1060471360,
- 1064709056, 1041912064, 992618752, 918061696, 820136128, 701350912, 564763136, 413905312,
- 252702016, 85283768, -84153016, -251373152, -412193952, -562598208, -698834304, -817510976,
- -915681728, -990918592, -1041372160, -1065817344, -1063683392, -1035067008, -980729024, -902074176,
- -801114432, -680417408, -543040576, -392453440, -232449024, -67047936, 99603672, 263338768,
- 420074528, 565914944, 697248640, 810838912, 903904448, 974187712, 1020010432, 1040314112,
- 1034684224, 1003358720, 947219392, 867767552, 767083328, 647771264, 512892224, 365884480,
- 210475200, 50585176, -109770824, -266585856, -415961728, -554206912, -677928256, -784115520,
- -870214784, -934190464, -974573952, -990497408, -981711808, -948590080, -892113472, -813843264,
- -715877760, -600795712, -471588352, -331581056, -184347104, -33615956, 116822016, 263211632,
- 401927360, 529563904, 643020416, 739576448, 816957632, 873389632, 907638720, 919038784,
- 907503104, 873521728, 818144448, 742948992, 649996672, 541776128, 421136352, 291211584,
- 155339280, 16974000, -120401088, -253362480, -378632256, -493159552, -594195200, -679358336,
- -746692608, -794711040, -822428992, -829383232, -815638016, -781777600, -728885632, -658512064,
- -572628224, -473572352, -363985824, -246742688, -124873992, -1489180, 120303760, 237476976,
- 347158464, 446702912, 533755744, 606308928, 662747520, 701884928, 722987456, 725786624,
- 710479424, 677716736, 628580224, 564548800, 487455296, 399434400, 302864160, 200301680,
- 94415504, -12084029, -116514408, -216288720, -308979968, -392380352, -464553824, -523880992,
- -569095168, -599308544, -614028672, -613164032, -597019520, -566281600, -521994336, -465525920,
- -398528192, -322889120, -240680240, -154100192, -65416176, 23095468, 109207648, 190798608,
- 265904304, 332765472, 389868896, 435980928, 470173824, 491842976, 500715808, 496851904,
- 480634304, 452752704, 414179264, 366137088, 310063456, 247567808, 180386464, 110334864,
- 39258892, -31013516, -98719224, -162203968, -219962560, -270674336, -313232768, -346769088,
- -370668672, -384580928, -388421408, -382367424, -366846528, -342518912, -310254080, -271102432,
- -226263200, -177048848, -124847760, -71085712, -17187518, 35460372, 85545152, 131860032,
- 173332944, 209050736, 238278608, 260474080, 275295552, 282605088, 282465888, 275134240,
- 261046656, 240802480, 215142736, 184925744, 151100368, 114677616, 76701576, 38220244,
- 257309, -36214540, -70298016, -101192744, -128213464, -150804368, -168549456, -181178720,
- -188570000, -190746832, -187872144, -180238592, -168255376, -152432528, -133362752, -111701864,
- -88148040, -63420712, -38239704, -13305140, 10721270, 33233146, 53694084, 71649704,
- 86736888, 98689968, 107343928, 112634456, 114595192, 113352176, 109115832, 102170872,
- 92864472, 81593048, 68788288, 54902676, 40395092, 25716910, 11298924, -2460449,
- -15205434, -26631372, -36491212, -44599896, -50836640, -55145052, -57531268, -58060172,
- -56849976, -54065368, -49909488, -44615140, -38435440, -31634326, -24477204, -17222048,
- -10111227, -3364318, 2827930, 8308287, 12956318, 16690166, 19466890, 21281350,
- 22163806, 22176328, 21408246, 19970784, 17991204, 15606606, 12957738, 10182934,
- 7412561, 4764010, 2337587, 213264, -1551419, -2922471, -3889289, -4463602,
- -4677182, -4578945, -4230953, -3704343, -3074240, -2415525, -1797252, -1280920,
- -898770, -627791, -434755, -305164, -227603, -191690, -187557, -206218,
- -239500, -280340, -322733, -361874, -394053, -416670, -428076, -427515,
- -414945, -390943, -356535, -313106, -262250, -205705, -145243, -82626,
- -19530, 42469, 101945, 157622, 208399, 253344, 291709, 322917,
- 346571, 362440, 370466, 370745, 363530, 349215, 328325, 301500,
- 269486, 233106, 193250, 150849, 106856, 62226, 17894, -25242,
- -66343, -104637, -139433, -170137, -196253, -217395, -233281, -243746,
- -248732, -248291, -242579, -231853, -216463, -196846, -173514, -147048,
- -118082, -87293, -55383, -23069, 8934, 39937, 69279, 96351,
- 120609, 141582, 158888, 172233, 181426, 186370, 187072, 183631,
- 176235, 165155, 150734, 133374, 113527, 91685, 68363, 44092,
- 19408, -5162, -29106, -51936, -73196, -92471, -109389, -123633,
- -134942, -143118, -148026, -149603, -147856, -142863, -134772, -123799,
- -110225, -94386, -76670, -57503, -37343, -16663, 4054, 24338,
- 43732, 61811, 78191, 92535, 62535, 80267, 96515, 110869,
- 122950, 132423, 139005, 142473, 142671, 139519, 133011, 123223,
- 110309, 94503, 76111, 55508, 33131, 9465, -14962, -39597,
- -63868, -87203, -109039, -128839, -146103, -160377, -171269, -178455,
- -181688, -180805, -175730, -166482, -153172, -136001, -115264, -91340,
- -64689, -35842, -5393, 26011, 57690, 88934, 119026, 147254,
- 172929, 195397, 214061, 228390, 237937, 242348, 241373, 234879,
- 222848, 205389, 182733, 155232, 123355, 87684, 48894, 7752,
- -34905, -78188, -121168, -162899, -202440, -238873, -271320, -298971,
- -321092, -337048, -346317, -348499, -343329, -330684, -310588, -283215,
- -248890, -208087, -161430, -109684, -53754, 5325, 66401, 128208,
- 189391, 248521, 304122, 354711, 398828, 435097, 462282, 479357,
- 485586, 480607, 464520, 437982, 402277, 359398, 312090, 263877,
- 219044, 182590, 160108, 157649, 181489, 237891, 332809, 471594,
- 658900, 898625, 1197641, 1570523, 1996663, 2404745, 2717774, 2865679,
- 2785718, 2427096, 1754169, 749686, -583221, -2219740, -4113328, -6196593,
- -8383364, -10571665, -12647668, -14490343, -15976733, -16987568, -17413068, -17158614,
- -16150145, -14338955, -11705745, -8263683, -4060347, 821616, 6265157, 12120884,
- 18210488, 24331478, 30263100, 35773284, 40626432, 44591748, 47451940, 49011856,
- 49106908, 47610828, 44442580, 39572032, 33024242, 24882062, 15286939, 4437778,
- -7412170, -19960400, -32862134, -45739056, -58189596, -69800496, -80159352, -88867704,
- -95554448, -99888904, -101593376, -100454560, -96333512, -89173816, -79007528, -65958664,
- -50244076, -32171454, -12134525, 9394608, 31875820, 54713840, 77273336, 98895824,
- 118918056, 136691248, 151600704, 163085296, 170656112, 173913744, 172563664, 166429120,
- 155461200, 139745456, 119505000, 95099632, 67021116, 35884416, 2415097, -32566908,
- -68166792, -103437232, -137402992, -169087216, -197538720, -221859376, -241231120, -254941424,
- -262406848, -263193680, -257034992, -243843760, -223721280, -196960640, -164045024, -125640616,
- -82584344, -35866404, 13391901, 63964612, 114551216, 163809728, 210391808, 252979168,
- 290320064, 321265088, 344801344, 360083392, 366461088, 363502304, 351010944, 329038400,
- 297889248, 258119712, 210529696, 156147840, 96210000, 32131786, -34524592, -102088152,
- -168820816, -232961936, -292774464, -346591552, -392862560, -430196672, -457403712, -473530208,
- -477890048, -470088800, -450040832, -417978368, -374452640, -320326336, -256757808, -185176992,
- -107253736, -24859086, 59979564, 145128320, 228400464, 307612608, 380641824, 445482432,
- 500300512, 543485312, 573695616, 589899584, 591407872, 577897856, 549428800, 506447456,
- 449783328, 380634208, 300541536, 211356352, 115196864, 14397969, -88545520, -191040832,
- -290462720, -384220896, -469827680, -544963968, -607541824, -655762304, -688166080, -703676928,
- -701634816, -681819648, -644463424, -590250752, -520308160, -436181376, -339801440, -233440544,
- -119658328, -1240033, 118872048, 237652048, 352067200, 459155616, 556103232, 640318080,
- 709499520, 761700928, 795384128, 809463808, 803340864, 776923520, 730635776, 665412608,
- 582681792, 484333184, 372675584, 250382144, 120426184, -13991622, -149522608, -282754144,
- -410296096, -528867712, -635382464, -727028736, -801344512, -856283200, -890270272, -902247552,
- -891705280, -858699904, -803857856, -728364736, -633940096, -522797984, -397595008, -261366368,
- -117451720, 30587386, 179056320, 324220320, 462399104, 590061056, 703913984, 800990592,
- 878726208, 935027008, 968326336, 977628096, 962536000, 923267520, 860652416, 776115520,
- 671644160, 549741504, 413365632, 265857680, 110858864, -47779968, -206094880, -360108800,
- -505932192, -639862208, -758477376, -858725824, -938004160, -994225728, -1025875712, -1032052032,
- -1012490816, -967575808, -898331200, -806398464, -693996736, -563869056, -419215008, -263610912,
- -100920864, 64800176, 229408368, 388775616, 538893952, 675977408, 796558208, 897575488,
- 976453568, 1031168128, 1060298880, 1063066560, 1039353856, 989709440, 915335680, 818058560,
- 700282816, 564931648, 415373344, 255336384, 88815592, -80029120, -246977680, -407857120,
- -558646720, -695580608, -815240832, -914661376, -991426624, -1043686208, -1070172608, -1070248192,
- -1043923520, -991857408, -915341120, -816266432, -697079168, -560719104, -410547744, -250265472,
- -83820864, 84686600, 251107216, 411343136, 561449088, 697729408, 816829056, 915815936,
- 992253184, 1044259072, 1070553344, 1070488704, 1044066752, 991938048, 915385920, 816295104,
- 697105216, 560750656, 410588608, 250316144, 83879304, -84624008, -251044992, -411286048,
- -561401792, -697695936, -816812672, -915819008, -992277056, -1044304128, -1070619200, -1070574144,
- -1044169920, -992056576, -915517184, -816436096, -697252864, -560901952, -410740480, -250465744,
- -84023984, 84486696, 250917232, 411169760, 561298496, 697607040, 816739008, 915761280,
- 992235520, 1044278912, 1070609856, 1070580032, 1044190208, 992090048, 915562432, 816491584,
- 697316864, 560972608, 410815936, 250544048, 84103240, -84408312, -250841440, -411098144,
- -561232512, -697547840, -816687680, -915718464, -992201920, -1044254720, -1070595200, -1070574848,
- -1044194112, -992102592, -915582912, -816519232, -697350784, -561011712, -410859200, -250590352,
- -84151408, 84359424, 250792960, 411051168, 561188032, 697506752, 816650880, 915686656,
- 992175616, 1044234432, 1070581248, 1070567360, 1044193024, 992107776, 915594112, 816535872,
- 697372352, 561037568, 410888512, 250622304, 84185136, -84324824, -250758368, -411017408,
- -561155904, -697477056, -816624192, -915663552, -992156544, -1044219712, -1070571008, -1070561728,
- -1044192000, -992111168, -915601728, -816547392, -697387392, -561055616, -410909120, -250644896,
- -84209144, 84299992, 250733312, 410992736, 561132224, 697454848, 816603968, 915645824,
- 992141696, 1044208000, 1070562816, 1070557056, 1044191040, 992113920, 915607936, 816556928,
- 697399936, 561070784, 410926464, 250663904, 84229272, -84279312, -250712656, -410972640,
- -561113216, -697437440, -816588608, -915632832, -992131328, -1044200448, -1070558208, -1070555520,
- -1044192384, -992118080, -915614784, -816566208, -697411328, -561084032, -410941184, -250679696,
- -84245752, 84262552, 250696016, 410956544, 561098048, 697423552, 816576320, 915622464,
- 992123200, 1044194816, 1070555200
-};
-
-/************************ Q30 *******************************/
-const Word32 ivas_fb_fr_12band_1ms_im_fx[IVAS_FB_12_1MS_LEN] = {
- -96495528, -286734272, -468692800, -637041216, -786562176, -912433280, -1009964416, -1075182976, -1098333440,
- -1060972224, -954328512, -784950848, -567387776, -321857280, -71378072, 161019520, 355191072,
- 496249664, 576290688, 595228096, 560553408, 486341472, 391112608, 296445024, 219833024,
- 161425424, 113971872, 75074912, 43676944, 18947558, 106207, -13606639, -22959300,
- -28697174, -31541624, -32158708, -31154358, -29054292, -26304144, -23261552, -20202826,
- -17324756, -14756116, -12565362, -10774012, -9366401, -8302065, -7524551, -6970827,
- -6577419, -6286071, -6046737, -5819771, -5576294, -5297871, -4975268, -4606808,
- -4196583, -3752523, -3284873, -2804624, -2322651, -1848752, -1391471, -957667,
- -552820, -180887, 155183, 453533, 712892, 932744, 1112922, 1253892,
- 1356428, 1421957, 1452251, 1449752, 1417222, 1357998, 1275581, 1173833,
- 1056523, 927513, 790325, 648358, 504521, 361522, 221574, 86743,
- -41290, -160871, -270597, -368994, -454781, -526614, -583403, -624117,
- -648145, -655120, -645267, -619210, -578251, -524110, -459110, -385841,
- -307254, -226274, -145851, -68575, 3253, 67950, 124299, 171779,
- 210318, 240423, 262847, 278659, 288884, 294565, 296445, 295082,
- 290614, 282963, 271701, 256332, 236226, 210937, 180155, 143993,
- 102888, 57812, 10083, -38529, -86081, -130429, -169562, -201608,
- -225146, -239179, -243376, -237949, -223786, -202225, -175080, -144342,
- -112142, -80430, -50955, -24990, -3380, 13628, 26240, 35170,
- 41402, 46169, 50665, 56013, 62999, 72081, 83214, 95949,
- 109364, 122266, 133211, 140767, 143575, 140609, 131207, 115267,
- 93186, 65957, 34996, 2134, -30636, -61239, -87791, -108676,
- -122781, -129495, 12356724, 36406252, 58390684, 76977432, 90719600, 98265728,
- 98008264, 88608552, 62420976, 2547174, -98862584, -234978608, -391650304, -549723776,
- -687929024, -785620992, -825677888, -796781568, -695135040, -525144384, -299188480, -36327380,
- 239749920, 503413376, 729982272, 898556864, 994367488, 1010422464, 948197568, 817333696,
- 634343104, 420516896, 199273200, -6719048, -178276784, -302004160, -371805248, -389615456,
- -365008416, -315253344, -262675984, -217917568, -178521248, -143001072, -111343304, -83569488,
- -59728692, -39750832, -23483756, -10668693, -980101, 5968707, 10589352, 13306198,
- 14527738, 14637296, 13974127, 12830675, 11443325, 9996437, 8620832, 7402724,
- 6386965, 5588127, 4995412, 4583292, 4315642, 4154179, 4060473, 4001515,
- 3949354, 3884093, 3791711, 3665350, 3502261, 3304372, 3075215, 2820550,
- 2545809, 2257129, 1959450, 1657946, 1356600, 1059795, 771079, 494646,
- 234059, -6519, -223731, -414017, -575061, -704879, -803133, -870150,
- -907983, -919252, -907936, -878057, -834296, -780659, -721070, -658192,
- -594157, -529649, -464852, -398810, -330536, -258557, -182049, -100384,
- -14134, 75538, 166137, 254665, 337160, 409716, 468199, 509317,
- 530349, 530086, 508400, 466928, 408381, 336929, 257279, 174830,
- 94651, 21581, -40724, -89563, -123905, -143909, -151339, -148811,
- -139947, -128462, -118197, -112219, -112926, -121327, -137375, -159531,
- -185372, -211440, -234054, -249316, -253979, -245431, -222426, -184880,
- -134334, -73467, -6263, 62723, 128418, 186074, 231361, 261147,
- 273444, 267948, 261810, 763373, 1198560, 1499796, 1578270, 1304628,
- 517808, -987783, -3443484, -7111908, -12256820, -19143168, -27996048, -39000040,
- -52248820, -67752040, -85376464, -104873664, -125808744, -147634944, -169591248, -190910720,
- -210637232, -228834976, -242239792, -233744176, -184602112, -88256112, 52564248, 227312048,
- 419154080, 607121280, 768828480, 883312000, 933778624, 909811200, 808862336, 636755584,
- 407214048, 140391440, -139342896, -406167488, -635714880, -807834944, -908809408, -932820096,
- -882419648, -768029696, -606446400, -418634368, -226977824, -52442412, 88143752, 184240560,
- 233125792, 241364816, 227710480, 209276640, 189331712, 167814560, 145682224, 123701848,
- 102633120, 83021960, 65302000, 49722020, 36415812, 25376218, 16511686, 9640718,
- 4539034, 941445, -1420767, -2818065, -3495818, -3676385, -3542409, -3243683,
- -2888735, -2555377, -2287831, -2108851, -2019462, -2010501, -2062586, -2155553,
- -2267238, -2380241, -2479146, -2554886, -2600826, -2615545, -2598567, -2552488,
- -2479078, -2381454, -2260948, -2119607, -1957826, -1777065, -1577959, -1362941,
- -1134431, -897064, -655697, -417094, -187702, 25095, 215280, 377113,
- 507239, 603471, 666470, 698219, 703186, 686502, 654728, 613906,
- 570192, 528056, 491058, 460427, 436171, 416130, 397422, 375887,
- 347709, 309014, 257411, 191469, 111939, 20899, -77459, -178052,
- -274516, -360654, -430246, -478480, -501684, -498487, -469248, -416789,
- -345433, -261310, -171090, -82033, -635, 67321, 117943, 148920,
- 160318, 153895, 133448, 103776, 70703, 39859, 16616, 4954,
- 7564, 25024, 56260, 98143, 146331, 195238, 239125, 272241,
- 289930, 288679, 266989, 225117, 165550, 92349, 11219, -71466,
- -148857, -214705, -263567, -291740, -297224, -280306, -243136, -189895,
- -125985, -57873, 7933, 65157, 108741, 134971, 142193, 130597,
- 102524, 61859, 13944, -35316, -79751, -113898, -133249, -135053,
- -118286, -84087, -35339, 23302, 86186, 146930, 199365, 237874,
- 258253, 257864, 236196, 194657, 136724, 67341, -7287, -80567,
- -145896, -270343, -808574, -1340072, -1858807, -2358665, -2831742, -3270963,
- -3669340, -4023521, -4333619, -4606985, -4857566, -5108708, -5390687, -5741295,
- -6200425, -6807718, -7593886, -8575752, -9745172, -11063108, -12448231, -13772797,
- -14853837, -15454158, -15279006, -13985197, -11185029, -6465256, 602227, 10431847,
- 23410894, 39863840, 60045788, 84103768, 112100696, 143979968, 179711728, 219302416,
- 264231232, 316950432, 366815488, 391499840, 373734272, 303947296, 180205328, 8607086,
- -197450336, -418782432, -632721152, -815848960, -946877184, -1009294400, -993460928, -897898880,
- -729596672, -503316064, -239947616, 35840880, 298430624, 524143840, 693923584, 795387200,
- 824107840, 783846592, 685860544, 547189184, 388365568, 230527600, 92671240, -11219515,
- -74492144, -105158200, -120261872, -127544112, -128388320, -124354624, -116661448, -106489408,
- -94793200, -82429304, -70062176, -58237700, -47334588, -37619828, -29226616, -22202334,
- -16501587, -12028281, -8635400, -6159899, -4423260, -3257870, -2504859, -2031762,
- -1726474, -1507393, -1314142, -1112384, -883004, -624119, -340602, -45467,
- 248842, 528315, 783713, 1007231, 1196662, 1351165, 1473983, 1568019,
- 1637995, 1686519, 1716364, 1727429, 1719421, 1689696, 1636232, 1556028,
- 1448006, 1311510, 1148760, 963094, 760758, 548770, 336091, 131254,
- -56814, -221101, -355658, -457521, -525555, -561787, -569830, -555666,
- -525766, -487535, -447411, -411297, -382938, -364634, -356100, -355594,
- -359287, -362732, -360583, -348172, -321291, -277591, -216139, -138411,
- -47457, 51579, 152676, 248783, 333218, 399646, 443388, 461240,
- 452449, 418164, 361960, 288882, 205559, 118975, 36377, -35977,
- -92851, -131037, -149092, -147929, -130154, -100234, -63486, -25973,
- 6639, 29226, 38204, 31469, 9051, -27322, -73989, -126155,
- -177996, -223678, -257577, -275273, -273644, -251592, -209808, -151108,
- -79807, -1677, 76962, 149510, 210060, 253638, 277008, 278653,
- 259231, -101021, -297456, -477733, -632297, -753728, -836696, -878615,
- -879031, -839751, -763739, -654959, -517096, -353514, -166209, 43748,
- 276781, 533724, 815969, 1123958, 1457300, 1813342, 2187857, 2574262,
- 2965417, 3353797, 3734536, 4106324, 4475222, 4855377, 5272512, 5763051,
- 6375849, 7168185, 8204533, 9548340, 11257436, 13371571, 15905385, 18833006,
- 22081010, 25512624, 28924300, 32032662, 34478724, 35820256, 35546928, 33078728,
- 27793346, 19027280, 6112874, -11628489, -34851840, -64232176, -100493888, -144608256,
- -198909072, -270631488, -359662496, -448624032, -516131776, -543967680, -518454176, -432622496,
- -287176640, -90768024, 140893552, 386715040, 622670976, 824595136, 971067648, 1045974272,
- 1040467264, 954060352, 794731136, 578022784, 325234560, 60958056, -189791088, -404423968,
- -565354624, -661869440, -691213888, -658569600, -576189312, -461441856, -334519392, -215323504,
- -121182328, -57886044, -14972652, 16811060, 39759696, 55435020, 65035460, 69706136,
- 70441104, 68189248, 63775032, 57948004, 51329736, 44447116, 37701544, 31399154,
- 25736924, 20832988, 16723796, 13393488, 10776430, 8783249, 7304115, 6229334,
- 5450365, 4874027, 4420041, 4029271, 3658127, 3282309, 2889391, 2480032,
- 2060348, 1642421, 1237795, 858544, 512575, 205752, -60998, -288674,
- -481834, -645256, -785054, -905653, -1011013, -1102347, -1179780, -1240896,
- -1282805, -1301283, -1292960, -1254661, -1185341, -1085250, -957344, -806069,
- -638185, -461195, -283738, -113885, 40607, 173836, 281340, 361227,
- 413418, 440281, 445517, 434398, 412451, 385525, 358529, 335589,
- 319068, 309999, 307515, 309612, 312947, 313829, 308220, 292759,
- 264732, 222913, 167314, 99696, 23013, -58414, -139717, -215530,
- -280898, -331372, -363803, -376281, -368659, -342216, -299851, -245477,
- -183947, -120287, -59527, -210294, -218804, -207034, -170663, -107684,
- -17542, 97483, 233628, 384636, 543572, 702055, 852320, 986414,
- 1098210, 1182279, 1235630, 1256080, 1243695, 1198697, 1122785, 1016812,
- 882318, 719277, 528144, 307851, 58485, -220576, -527549, -860384,
- -1213683, -1581737, -1955989, -2329539, -2695405, -3052665, -3405215, -3769076,
- -4170617, -4653891, -5276647, -6116192, -7261256, -8815022, -10881268, -13564073,
- -16947616, -21093540, -26015144, -31675226, -37956612, -44665032, -51498380, -58060316,
- -63829408, -68189520, -70395848, -69627624, -64938208, -55334156, -39669268, -16742548,
- 15011598, 57892376, 121157856, 215274688, 334456672, 461378272, 576139200, 658546880,
- 691230336, 661933376, 565469888, 404588960, 189999104, -60718748, -324979552, -577770304,
- -794500352, -953869504, -1040332032, -1045906432, -971073600, -824675520, -622820672, -386923360,
- -141145440, 90490632, 286893152, 432351840, 518213184, 543769536, 515984864, 448531552,
- 359622208, 270636384, 198948336, 144668672, 100561448, 64293740, 34896780, 11649924,
- -6117171, -19054578, -27836140, -33125540, -35583508, -35831208, -34449244, -31950346,
- -28780702, -25304532, -21811144, -18510242, -15544263, -12991323, -10880449, -9198353,
- -7904592, -6938712, -6232849, -5716818, -5326765, -5007114, -4715109, -4419761,
- -4103101, -3757115, -3383050, -2987624, -2581751, -2177166, -1785567, -1416314,
- -1076470, -769692, -497117, -257162, -46868, 137886, 301064, 446309,
- 576003, 691438, 792390, 877665, 945087, 992265, 1016767, 1016861,
- 991628, 941464, 867976, 774150, 663993, 542420, 414732, 286370,
- 162380, 47204, -55707, -143950, -216326, -272693, -313915, -341561,
- -357718, -364650, -364603, -359521, -350944, -339867, -326770, -311628,
- -294057, -273429, -249069, -220397, -187092, -149183, -107127, -61803,
- -14483, 33260, 79674, 122959, 161417, 193583, -137153, -86096,
- -23462, 46165, 118296, 188311, 252569, 308033, 353183, 387345,
- 411326, 426448, 434961, 438884, 440375, 440558, 440044, 437930,
- 432614, 421046, 399869, 364878, 312384, 238720, 141646, 19702,
- -126527, -295376, -483051, -684957, -894831, -1106337, -1312215, -1505978,
- -1680884, -1831578, -1952736, -2040617, -2091372, -2102604, -2071473, -1996480,
- -1875541, -1708206, -1493799, -1234127, -931547, -591976, -222473, 165877,
- 561490, 950008, 1319512, 1659151, 1966270, 2245658, 2518227, 2819813,
- 3210306, 3770160, 4608328, 5854141, 7662371, 10198175, 13638330, 18147660,
- 23877010, 30930782, 39364468, 49144104, 60148836, 72123392, 84694024, 97312800,
- 109298904, 119765360, 127705376, 131866912, 130934488, 123231464, 107234464, 75050672,
- 9470806, -97677456, -239897616, -403333024, -569087680, -716066368, -823729024, -874943616,
- -858298112, -769767616, -613463168, -401328448, -152012800, 111316600, 362752096, 579800640,
- 754066560, 884317376, 967646720, 1002358976, 988932224, 930137792, 830908864, 698079680,
- 539965760, 365883200, 185588480, 8720114, -155758112, -300047104, -417930816, -505075680,
- -559213504, -580180096, -569826624, -531795520, -471193568, -394169856, -307444800, -217803664,
- -131610264, -54348980, 9748328, 57999172, 89445504, 104945984, 107368432, 102279568,
- 94596192, 85655480, 75877136, 65846368, 56016016, 46757852, 38321108, 30867838,
- 24467266, 19124186, 14784349, 11357873, 8727069, 6764325, 5338255, 4325655,
- 3614320, 3109507, 2733412, 2427369, 2148937, 1871452, 1580043, 1270071,
- 943252, 606145, 267130, -64446, -380185, -672695, -936550, -1167777,
- -1364195, -1524669, -1649207, -1738275, -1792904, -1814221, -1803670, -1762759,
- -1693364, -1597596, -1478091, -1337881, -1180581, -1010189, -831132, -647987,
- -465420, -287874, -119474, 36238, 176365, 298810, 402244, 486148,
- 550683, 596630, 625208, 637968, 636614, 622900, 598511, 565006,
- 523771, 476024, 422831, 365155, 303902, 239978, 174336, 108003,
- 42099, -22177, -83566, -140800, -192647, -237981, -275829, -305435,
- -326287, -338158, -341095, -335431, -321739, -300823, -273643, -241298,
- -204944, -165780, -124974, -83660, -42880, 10137, 29849, 47985,
- 63702, 76520, 86314, 93425, 98550, 102746, 107236, 113334,
- 122202, 134769, 151505, 172398, 196816, 223585, 250966, 276853,
- 298844, 314511, 321522, 317919, 302199, 273538, 231774, 177523,
- 112040, 37218, -44643, -130911, -218896, -305922, -389579, -467717,
- -538627, -600924, -653636, -695990, -727439, -747408, -755314, -750348,
- -731559, -697715, -647504, -579487, -492405, -385195, -257342, -108895,
- 59211, 245234, 446381, 659034, 878627, 1100007, 1317397, 1524851,
- 1716231, 1885675, 2027510, 2136678, 2208531, 2239209, 2225330, 2164370,
- 2054318, 1894140, 1683476, 1423258, 1115462, 763860, 373717, -47467,
- -490570, -944379, -1396841, -1835173, -2248037, -2626382, -2966637, -3272111,
- -3556917, -3847305, -4185583, -4630274, -5258922, -6165632, -7461554, -9268313,
- -11715324, -14927984, -19021866, -24085232, -30171698, -37277344, -45335748, -54189964,
- -63598244, -73198584, -82549584, -91078392, -98377112, -103118416, -100391208, -84628624,
- -52954552, -4492618, 59827860, 137363792, 223933312, 314109568, 401591168, 479653696,
- 541630720, 581410176, 593897728, 575427264, 524078976, 439891712, 324946016, 183315184,
- 20883088, -154960944, -335730752, -512333504, -675605952, -816870016, -928462720, -1004220224,
- -1039868736, -1033319296, -984830528, -897064000, -775182272, -627308096, -461708352, -284291552,
- -100579392, 83598736, 262525088, 430732416, 583209600, 715532736, 824009920, 905775040,
- 958871552, 982291840, 975995776, 940888192, 878773504, 792274432, 684731072, 560072576,
- 422675872, 277208288, 128466608, -18787604, -159985744, -290901824, -407785088, -507474624,
- -587489088, -646091776, -682326144, -696024192, -687785152, -658928000, -611418688, -547776704,
- -470963680, -384259392, -291130144, -195094672, -99592464, -7860071, 77180528, 153017120,
- 217622960, 269510560, 307761952, 332035072, 342546656, 340033376, 325693088, 301109632,
- 268164672, 228941216, 185622192, 140390128, 95330560, 52345244, 13076479, -21151680,
- -49376268, -71017224, -85881800, -94147080, -96327536, -93222768, -85856648, -75400496,
- -63097824, -50176000, -37774988, -26857674, -18169908, -11863887, -7301392, -3914018,
- -1479242, 185291, 1236420, 1817970, 2053955, 2052907, 1903852, 1679448,
- 1434536, 1209401, 1029974, 911183, 857962, 868350, 934655, 1046022,
- 1189342, 1351150, 1518125, 1678330, 1821294, 1938725, 2024278, 2073883,
- 2085335, 2058391, 1994281, 1895693, 1766278, 1610593, 1433645, 1240831,
- 1037545, 829139, 620601, 416556, 221024, 37473, -131344, -283279,
- -416878, -531220, -625958, -701127, -757159, -794697, -814605, -817824,
- -805400, -778384, -737905, -685103, -621229, -547610, -465741, -377252,
- -283979, -187900, -91166, 4001, 95326, 180608, 257764, 324972,
- 380709, 423871, 453787, 470280, 473637, 464613, 444338, 414280,
- 376112, 331644, 282692, 231012, 178188, 125609, 74399, 25440,
- -20646, -63433, -102670, -138199, -169921, -197722, -221454, -240892,
- -255747, -265667, -270281, -269233, -262252, -249189, -230092, -205221,
- -175099, -140492, -102411, -62059, -20785, 19997, 58880, 94556,
- 125879, 151942, 172113, 186075, 193810, 195596, 191955, 183604,
- 171377, 156168, 138843, 120200, 100900, 81458, 62216, 43368,
- 24971, 6998, -10624, -27957, -45013, -61705, -77836, -93079,
- -106999, -119067, -128714, -135370, -138532, -137806, -132971, -123999,
- -111091, -94667, -75361, -53969, 10765, 32074, 52722, 72311,
- 90486, 106963, 121523, 134027, 144392, 152600, 158658, 162605,
- 164468, 164267, 161985, 157577, 150955, 142011, 130615, 116649,
- 100019, 80692, 58704, 34200, 7431, -21221, -51265, -82083,
- -112977, -143167, -171845, -198187, -221409, -240776, -255657, -265518,
- -269970, -268744, -261725, -248915, -230452, -206572, -177616, -143996,
- -106204, -64784, -20348, 26444, 74865, 124130, 173377, 221686,
- 268054, 311432, 350709, 384766, 412472, 432751, 444591, 447117,
- 439606, 421553, 392681, 352994, 302769, 242592, 173323, 96118,
- 12366, -76299, -168083, -261025, -353085, -442152, -526117, -602884,
- -670441, -726859, -770364, -799329, -812348, -808221, -786031, -745129,
- -685209, -606288, -508783, -393474, -261578, -114689, 45155, 215561,
- 393723, 576534, 760547, 942104, 1117306, 1282158, 1432549, 1564416,
- 1673729, 1756688, 1809722, 1829726, 1814087, 1760970, 1669365, 1539414,
- 1372449, 1171316, 940345, 685584, 414591, 136477, -138614, -399774,
- -636264, -838162, -997771, -1110606, -1177191, -1204204, -1206433, -1207707,
- -1242622, -1356751, -1607660, -2063815, -2804506, -3917005, -5495374, -7636020,
- -10436517, -13992514, -18402674, -23818388, -30616280, -38795064, -47468192, -55465196,
- -61624760, -64816688, -64030596, -58439904, -47471160, -30852034, -8650500, 18708296,
- 50440096, 85421744, 122227560, 159185040, 194443776, 226058080, 252076752, 270638720,
- 280067616, 278963616, 266285680, 241422224, 204245248, 155146128, 95049592, 25405990,
- -51839956, -134302160, -219227456, -303587872, -384188544, -457786240, -521215424, -571515392,
- -606054656, -622647040, -619654592, -596072512, -551593600, -486646944, -402411264, -300798944,
- -184413264, -56477480, 79260352, 218645328, 357251200, 490529920, 613968768, 723250432,
- 814409344, 883978944, 929123648, 947751552, 938601472, 901303104, 836405248, 745373248,
- 630551936, 495099232, 342887840, 178382704, 6494100, -167583760, -338549120, -501169472,
- -650463872, -781868416, -891402304, -975790912, -1032769600, -1061261696, -1060915456, -1031960960,
- -975385600, -892916224, -786977856, -660620736, -517435968, -361449888, -197010624, -28662768,
- 138980608, 301369056, 454141632, 593248768, 715063168, 816478784, 894992576, 948769664,
- 976686784, 978356608, 954128576, 905069824, 832924288, 740053568, 629360000, 504194944,
- 368255424, 225472400, 79893288, -64436384, -203589744, -333869568, -451910592, -554770112,
- -640004160, -705727744, -750656768, -774131456, -776120512, -757206720, -718553856, -661857536,
- -589281088, -503378688, -407008864, -303241088, -195258304, -86258672, 20640266, 122492392,
- 216605760, 300615264, 372542752, 430843584, 474437952, 502727104, 515593600, 513386816,
- 496894016, 467298720, 426127872, 375190336, 316508064, 252243568, 184625248, 115873648,
- 48130852, -16604751, -76536328, -130117360, -176090096, -213512624, -241774240, -260598816,
- -270036736, -270445792, -262462656, -246965456, -225030192, -197881696, -166842016, -133277536,
- -98547200, -63953468, -30697916, 157309, 27720696, 51294532, 70389352, 84729480,
- 94249824, 99084304, 99546808, 96105616, 89352656, 79969008, 68688296, 56259452,
- 43410724, 30816176, 19066356, 8644033, -93590, -6926218, -11773978, -14694671,
- -15872813, -15605618, -14280676, -12378042, -10430668, -8704424, -7182491, -5854782,
- -4729147, -3804335, -3072066, -2516383, -2116394, -1847634, -1684290, -1600530,
- -1572012, -1576721, -1595767, -1613665, -1618550, -1602016, -1558925, -1486975,
- -1386301, -1258946, -1108416, -939180, -756297, -565028, -370575, -177839,
- 8715, 185182, 348246, 495214, 623986, 733038, 821363, 888436,
- 934161, 958831, 963086, 947887, 914478, 864367, 799293, 721209,
- 632236, 534643, 430794, 323115, 214029, 105923, 1076, -98376,
- -190504, -273617, -346304, -407458, -456294, -492355, -515505, -525917,
- -524051, -510616, -486547, -452951, -411079, -362277, -307954, -249541,
- -188465, -126117, -63839, -2894, 55536, 110376, 160649, 205502,
- 244200, 276144, 300872, 318070, 327574, 329385, 323660, 310724,
- 291059, 265298, 234214, 198698, 159739, 118393, 75754, 32922,
- -9033, -49104, -86375, -120044, -149449, -174076, -193569, -207727,
- -216503, -219983, -218381, -212007, -201261, -186599, -168524, -147564,
- -124261, -99161, -72807, -45733, -18468, 8473, 34584, 59372,
- 82359, 103090, 121141, 136131, 147730, 155680, 159803, 160015,
- 156337, 148897, 137934, 123794, 106916, 87821, 67091, 45345,
- 23216, 1326, -19743, -39465, 109887, 120382, 128416, 133765,
- 136261, 135794, 132320, 125859, 116497, 104388, 89749, 72858,
- 54047, 33695, 12222, -9922, -32266, -54329, -75626, -95683,
- -114044, -130284, -144009, -154878, -162593, -166923, -167696, -164811,
- -158239, -148026, -134294, -117244, -97153, -74370, -49314, -22469,
- 5628, 34390, 63198, 91407, 118365, 143426, 165965, 185395,
- 201183, 212860, 220042, 222435, 219848, 212195, 199508, 181929,
- 159715, 133233, 102952, 69434, 33331, -4639, -43696, -83016,
- -121744, -159013, -193957, -225733, -253530, -276597, -294249, -305894,
- -311042, -309326, -300512, -284516, -261407, -231423, -194963, -152600,
- -105060, -53228, 1881, 59128, 117284, 175043, 231069, 284005,
- 332527, 375354, 411300, 439283, 458370, 467783, 466935, 455431,
- 433101, 399985, 356360, 302726, 239820, 168592, 90219, 6068,
- -82296, -173156, -264641, -354785, -441533, -522811, -596538, -660703,
- -713385, -752830, -777471, -786003, -777391, -750944, -706300, -643488,
- -562898, -465330, -351937, -224267, -84196, 66044, 223948, 386697,
- 551263, 714370, 872609, 1022412, 1160192, 1282340, 1385409, 1466141,
- 1521718, 1549819, 1548936, 1518450, 1458982, 1372447, 1262386, 1133907,
- 993924, 850871, 714752, 596518, 507835, 460031, 463573, 526525,
- 653821, 845263, 1094812, 1388217, 1702729, 2004387, 2248836, 2377871,
- 2322716, 1997670, 1310909, 31361, -2276023, -5884963, -10790734, -16840258,
- -23748608, -31120974, -38472224, -45255760, -50892408, -54804412, -56448304, -55348896,
- -51129788, -43541476, -32483506, -18021422, -395893, 19975162, 42503072, 66442420,
- 90913264, 114929960, 137436576, 157346768, 173587488, 185144144, 191106144, 190710336,
- 183381248, 168765648, 146760624, 117533176, 81530704, 39481248, -7616625, -58514600,
- -111745512, -165663824, -218494432, -268388400, -313484064, -351971232, -382156480, -402527424,
- -411813344, -409040128, -393577504, -365176384, -323994752, -270611200, -206024384, -131639056,
- -49237472, 39062252, 130860688, 223542656, 314352192, 400474784, 479124064, 547630784,
- 603530816, 644649344, 669178624, 675746624, 663473536, 632014912, 581589056, 512987520,
- 427568224, 327230528, 214373088, 91835128, -37177272, -169178032, -300498464, -427392512,
- -546146752, -653191616, -745210944, -819245440, -872788352, -903868288, -911118272, -893827520,
- -851974272, -786238976, -697996288, -589286400, -462766208, -321640832, -169578832, -10611593,
- 150978672, 310780032, 464377088, 607478720, 736043264, 846397952, 935348160, 1000273472,
- 1039207744, 1050900416, 1034856960, 991357632, 921452992, 826937088, 710298944, 574652800,
- 423651328, 261382080, 92266240, -79072984, -248102448, -410503776, -562126720, -699092736,
- -817911936, -915573376, -989624896, -1038234688, -1060238592, -1055167808, -1023259008, -965445760,
- -883330880, -779142016, -655670144, -516193728, -364390176, -204236960, -39905496, 124349848,
- 284304192, 435873248, 575219968, 698854144, 803721536, 887281600, 947570240, 983247040,
- 993625152, 978684224, 939064256, 876042880, 791495168, 687838208, 567961280, 435144608,
- 292968064, 145212944, -4240369, -151516576, -292848000, -424673056, -543728192, -647130176,
- -732447680, -797759168, -841696640, -863474048, -862898880, -840368384, -796849536, -733844032,
- -653339328, -557747648, -449833824, -332635680, -209377712, -83381528, 42024892, 163596368,
- 278255872, 383173696, 475838368, 554117568, 616307264, 661168640, 687951104, 696401792,
- 686761024, 659744256, 616512064, 558627584, 488004704, 406847392, 317582464, 222787984,
- 125119136, 27233782, -68280144, -158973472, -242598960, -317167264, -380994112, -432737696,
- -471425664, -496470656, -507674976, -505223904, -489668640, -461899200, -423108800, -374750624,
- -318488480, -256143216, -189636144, -120931576, -51979948, 15336795, 79255984, 138179872,
- 190714864, 235703648, 272249056, 299729728, 317807040, 326423456, 325792768, 316382656,
- 298890368, 274212512, 243410272, 207670816, 168266608, 126513920, 83731472, 41200944,
- 130175, -38379756, -73362784, -104010672, -129689920, -149952464, -164540112, -173382736,
- -176590656, -174441552, -167362736, -155909328, -140739472, -122587248, -102234616, -80482928,
- -58125464, -35921428, -14572560, 5297181, 23158150, 38587464, 51277008, 61037024,
- 67795232, 71591800, 72570464, 70966328, 67090884, 61315048, 54050700, 45731812,
- 36795552, 27664472, 18730052, 10338603, 2779584, -3722787, -9014984, -13015846,
- -15715349, -17169656, -17493876, -16851572, -15443180, -13491852, -11229971, -8883501,
- -6659666, -4731320, -3230436, -2179638, -1456508, -951706, -619736, -422906,
- -328742, -307762, -334784, -388143, -450439, -507929, -550755, -572282,
- -568989, -539768, -485654, -409163, -313997, -204481, -85334, 38748,
- 163232, 284008, 397435, 500481, 590686, 666220, 725799, 768696,
- 794640, 803805, 796717, 774237, 737483, 687817, 626774, 556060,
- 477482, 392946, 304395, 213796, 123081, 34130, -51284, -131518,
- -205101, -270753, -327424, -374293, -410797, -436619, -451696, -456198,
- -450524, -435265, -411195, -379231, -340412, -295864, -246780, -194382,
- -139908, -84576, -29579, 23948, 74940, 122415, 165488, 203392,
- 235477, 261232, 280287, 292420, 297563, 295805, 287381, 272679,
- 252217, 226642, 196699, 163225, 127113, 89298, 50723, 12319,
- -25022, -60468, -93267, -122762, -148403, -169755, -186505, -198455,
- -205529, -207755, -205269, -198296, -187147, -172200, -153899, -132733,
- -109235, -83965, -57505, -30448, -3387, 23090, 48419, 72062,
- 93519, 112344, 128152, 140629, 149540, 154739, 156171, 153875,
- 147984, 138721, 126390, 111370, 94099, 75064, 54779, 33779,
- 12593, -8262, -28303, -47084, 123494, 129971, 133493, 133924,
- 131201, 125331, 116398, 104559, 90037, 73124, 54170, 33578,
- 11793, -10702, -33406, -55797, -77356, -97567, -115939, -132009,
- -145355, -155607, -162458, -165670, -165080, -160609, -152268, -140154,
- -124457, -105454, -83508, -59060, -32622, -4767, 23884, 52680,
- 80946, 108005, 133192, 155874, 175459, 191418, 203293, 210711,
- 213394, 211167, 203964, 191828, 174916, 153495, 127939, 98723,
- 66416, 31667, -4798, -42202, -79720, -116501, -151685, -184419,
- -213882, -239294, -259946, -275209, -284560, -287590, -284024, -273728,
- -256722, -233178, -203429, -167959, -127402, -82528, -34229, 16495,
- 68562, 120826, 172104, 221199, 266929, 308151, 343787, 372847,
- 394455, 407868, 412493, 407908, 393872, 370338, 337461, 295599,
- 245318, 187388, 122773, 52620, -21757, -98901, -177232, -255084,
- -330731, -402431, -468456, -527135, -576892, -616284, -644032, -659054,
- -660495, -647746, -620468, -578601, -522379, -452338, -369318, -274467,
- -169243, -55405, 64986, 189594, 315816, 440826, 561623, 675096,
- 778120, 867669, 940959, 995619, 1029881, 1042792, 1034432, 1006137,
- 960689, 902497, 837686, 774157, 721490, 690799, 694367, 745251,
- 856581, 1040935, 1309312, 1670468, 2129651, 2688819, 3345656, 4105519,
- 4976393, 5840188, 6459558, 6619945, 6147045, 4905821, 2810464, -169248,
- -4002855, -8597662, -13799897, -19399282, -25136440, -30713178, -35805064, -40075928,
- -43193604, -44846368, -44759276, -42709760, -38541820, -32178052, -23629058, -12999656,
- -491521, 13597969, 28880844, 44887552, 61079704, 76866240, 91622528, 104711816,
- 115508400, 123421568, 127919688, 128553392, 124977088, 116967832, 104440944, 87461480,
- 66251100, 41189824, 12812431, -18200672, -51037968, -84776544, -118406512, -150859520,
- -181040640, -207862576, -230281344, -247332144, -258164320, -262074240, -258534976, -247221616,
- -228031216, -201096704, -166793872, -125740976, -78790864, -27015406, 28317512, 85773968,
- 143790256, 200714592, 254853088, 304518720, 348082144, 384022272, 410975936, 427784064,
- 433533952, 427595232, 409648832, 379707872, 338129120, 285614880, 223204848, 152257552,
- 74422120, -8399482, -94098672, -180413920, -264990464, -345444480, -419429888, -484706304,
- -539205312, -581094272, -608834752, -621234048, -617488768, -597217728, -560484416, -507806784,
- -440154880, -358935456, -265963920, -163424032, -53816484, 60102860, 175393008, 289004832,
- 397862624, 498948160, 589385088, 666520704, 728003904, 771855360, 796529472, 800965376,
- 784625088, 747518528, 690213376, 613829888, 520020448, 410934048, 289166720, 157698512,
- 19819390, -120954952, -260974400, -396551008, -524057792, -640027584, -741248576, -824854336,
- -888405760, -929962176, -948139904, -942156672, -911859520, -857736896, -780912768, -683123584,
- -566678912, -434405344, -289576544, -135830144, 22925716, 182614304, 339097376, 488284896,
- 626244608, 749307648, 854168576, 937975616, 998409984, 1033750912, 1042925056, 1025539008,
- 981893504, 912979136, 820453376, 706599552, 574268864, 426807104, 267967136, 101810936,
- -67397744, -235305840, -397586848, -550055296, -688779008, -810183040, -911146880, -989084800,
- -1042054592, -1068829184, -1068826112, -1042089792, -989328512, -911898304, -811770624, -691481728,
- -554069376, -402995648, -242059584, -75301504, 93098968, 258928160, 418044256, 566481536,
- 700549504, 816925696, 912738304, 985637504, 1033853888, 1056241408, 1052304960, 1022211200,
- 966782848, 887476096, 786342208, 665974016, 529439200, 380201408, 222031488, 58911676,
- -105065728, -265801808, -419294496, -561739072, -689623232, -799814720, -889638656, -956942720,
- -1000149696, -1018294336, -1011044736, -978708096, -922219648, -843115968, -743493120, -625951040,
- -493525056, -349607232, -197858608, -42115448, 113708584, 265721584, 410151424, 543440192,
- 662332480, 763955904, 845890496, 906227200, 943612480, 957278400, 947058112, 913385664,
- 857280704, 780318336, 684585088, 572622656, 447359776, 312035584, 170115056, 25199920,
- -119063552, -259076960, -391380192, -512737632, -620217856, -711264960, -783759808, -836069184,
- -867082944, -876236800, -863521472, -829477248, -775175296, -702184896, -612528832, -508627616,
- -393234080, -269360256, -140198384, -9038325, 120816904, 246134720, 363834016, 471061440,
- 565260864, 644234816, 706195520, 749805696, 774206528, 779033856, 764420928, 730989120,
- 679825600, 612449984, 530770240, 437028800, 333741664, 223630656, 109551536, -5580210,
- -118864264, -227488864, -328800992, -420371296, -500052800, -566030976, -616865088, -651519232,
- -669382144, -670276608, -654456960, -622595968, -575760768, -515379648, -443199648, -361236896,
- -271720576, -177032864, -79645232, 17945830, 113283088, 204010512, 287931712, 363063040,
- 427680576, 480359328, 520004224, 545871936, 557583232, 555125952, 538848000, 509441632,
- 467918976, 415579744, 353972064, 284847840, 210113616, 131778400, 51899980, -27469024,
- -104333832, -176807568, -243157520, -301846336, -351567360, -391273184, -420196800, -437865024,
- -444103968, -439036576, -423072480, -396890720, -361415584, -317786848, -267324960, -211492304,
- -151851792, -90023688, -27642056, 33688092, 92431824, 147162464, 196595872, 239620272,
- 275320544, 302996800, 322176864, 332622304, 334328064, 327516064, 312622880, 290282112,
- 261301872, 226638432, 187366672, 144647984, 99697160, 53748436, 8022341, -36306296,
- -78138080, -116475864, -150447968, -179327376, -202546304, -219706160, -230582416, -235124880,
- -233452928, -225846496, -212732912, -194670144, -172327120, -146461568, -117896304, -87494416,
- -56134348, -24685366, 6015840, 35186796, 62118600, 86192504, 106893400, 123819856,
- 136690672, 145347696, 149755152, 149995552, 146262368, 138849824, 128140336, 114589888,
- 98711832, 81059840, 62210316, 42744900, 23233612, 4218996, -13798199, -30371520,
- -45119144, -57731856, -67978520, -75708944, -80854288, -83424880, -83505872, -81250776,
- -76873240, -70637384, -62847076, -53834452, -43948188, -33541804, -22962404, -12540202,
- -2579104, 6651381, 14922708, 22052188, 27906138, 32401252, 35504228, 37229756,
- 37636996, 36824736, 34925464, 32098614, 28523208, 24390258, 19895138, 15230230,
- 10578097, 6105390, 1957699, -1744518, -4908812, -7472372, -9402388, -10695210,
- -11374340, -11487438, -11102430, -10302999, -9183557, -7844043, -6384651, -4900844,
- -3478715, -2191066, -1094124, -225317, 398208, 779956, 943926, 936293,
- 833844, 703157, 565034, 427621, 299915, 188242, 97070, 28671,
- -16282, -38631, -40246, -23848, 7370, 49924, 100305, 155103,
- 211184, 265743, 316398, 361188, 398601, 427542, 447320, 457596,
- 458351, 449838, 432541, 407131, 374438, 335404, 291067, 242523,
- 190911, 137380, 83081, 29131, -23391, -73477, -120193, -162709,
- -200302, -232373, -258456, -278222, -291483, -298191, -298431, -292422,
- -280496, -263099, -240767, -214119, -183837, -150654, -115335, -78667,
- -41439, -4430, 31603, 65943, 97920, 126924, 152420, 173951,
- 191152, 203753, 211586, 214590, 212809, 206390, 195581, 180724,
- 162245, 140642, 116472, 90338, 62871, 34716, 6512, -21115,
- -47577, -72327, -94874, -114790, -131717, -145374, -155554, -162130,
- -165050, -164338, -160089, -152466, -141696, -128062, -111900, -93592,
- -73557, -52247, -30134, -7706, 14546, 36139, 56604, 75501,
- 92426, 107025, 118997, 128106, 134187, 137146, 136964, 133700,
- 127480, 118502, 107020, 93345, 116040, 106373, 94004, 79158,
- 62121, 43240, 22912, 1579, -20281, -42169, -63569, -83966,
- -102856, -119760, -134234, -145882, -154369, -159426, -160859, -158557,
- -152493, -142728, -129410, -112770, -93122, -70853, -46417, -20326,
- 6860, 34548, 62118, 88942, 114393, 137861, 158767, 176575,
- 190802, 201034, 206937, 208261, 204852, 196660, 183736, 166241,
- 144442, 118709, 89511, 57407, 23039, -12886, -49603, -86311,
- -122184, -156394, -188125, -216596, -241075, -260902, -275496, -284383,
- -287194, -283688, -273753, -257415, -234835, -206316, -172290, -133320,
- -90085, -43369, 5950, 56922, 108538, 159746, 209478, 256659,
- 300236, 339190, 372562, 399462, 419103, 430808, 434043, 428427,
- 413772, 390087, 357626, 316892, 268676, 214058, 154439, 91515,
- 27295, -35962, -95765, -149503, -194502, -228208, -248287, -252875,
- -240711, -211453, -165805, -105883, -35276, 40539, 114314, 176503,
- 215759, 217978, 167946, 29216, -265669, -759935, -1454826, -2329191,
- -3341857, -4434792, -5535889, -6563153, -7428902, -8044769, -8326572, -8199427,
- -7602384, -6492797, -4849871, -2677498, -5997, 3107152, 6577829, 10296906,
- 14133125, 17937022, 21545892, 24789544, 27496750, 29502072, 30652904, 30816402,
- 29886096, 27787848, 24484978, 19982264, 14328683, 7618649, -8275, -8369346,
- -17242212, -26370120, -35468600, -44233488, -52350068, -59503100, -65387360, -69718488,
- -72243656, -72751784, -71082920, -67136432, -60877660, -52342804, -41641768, -28958772,
- -14550630, 1257369, 18077938, 35470524, 52952152, 70010080, 86115976, 100741256,
- 113373128, 123530864, 130781872, 134756976, 135164528, 131802696, 124569704, 113471440,
- 98626208, 80266312, 58736392, 34488268, 8072537, -19873172, -48638900, -77459776,
- -105535736, -132052984, -156206736, -177224544, -194389536, -207063008, -214705568, -216896176,
- -213348592, -203924480, -188642880, -167685488, -141397504, -110283944, -75001352, -36344852,
- 4768980, 47323316, 90225720, 132335712, 172494592, 209556688, 242421216, 270063936,
- 291567712, 306150848, 313192864, 312256320, 303104480, 285713824, 260281152, 227224928,
- 187180496, 140989248, 89681992, 34456540, -23349740, -82291968, -140853584, -197485040,
- -250644464, -298839136, -340666720, -374855200, -400300192, -416098816, -421578912, -416322848,
- -400184960, -373302304, -336098016, -289277056, -233814336, -170935472, -102090216, -28919474,
- 46783608, 123117448, 198119696, 269817600, 336279616, 395667328, 446285568, 486630272,
- 515431904, 531693952, 534724512, 524161024, 499986336, 462536352, 412498304, 350899776,
- 279088736, 198704400, 111640296, 19999716, -73955136, -167859072, -259303504, -345898400,
- -425334720, -495445856, -554266496, -600087168, -631503040, -647455744, -647266496, -630660352,
- -597779904, -549188672, -485863232, -409174688, -320859648, -222981056, -117879984, -8119592,
- 103577704, 214398032, 321507232, 422123680, 513590720, 593446784, 659491904, 709847616,
- 743010112, 757894080, 753866240, 730767680, 688924608, 629145984, 552709376, 461334048,
- 357142464, 242611072, 120511064, -6158985, -134247200, -260527344, -381780576, -494877952,
- -596861632, -685022336, -756971776, -810707072, -844666432, -857773504, -849470528, -819737792,
- -769099840, -698617600, -609866880, -504903104, -386213792, -256659104, -119402648, 22166518,
- 164518080, 304069184, 437275360, 560721088, 671207872, 765837888, 842089984, 897887232,
- 931653440, 942357376, 929543168, 893346752, 834496704, 754300416, 654615040, 537804480,
- 406682912, 264446352, 114594352, -39157032, -192968032, -342971968, -485373120, -616543680,
- -733116800, -832073664, -910822080, -967264896, -999856064, -1007642752, -990292800, -948106752,
- -882013184, -793548800, -684822016, -558462848, -417558400, -265576992, -106281872, 56362708,
- 218291040, 375438528, 523844608, 659753344, 779709440, 880646656, 959966976, 1015607872,
- 1046096320, 1050588096, 1028890880, 981471296, 909444864, 814549696, 699104192, 565949568,
- 418379808, 260058736, 94928648, -72889120, -239197984, -399832192, -550762240, -688196992,
- -808680064, -909177600, -987155392, -1040643904, -1068288256, -1069383232, -1043891456, -992444800,
- -916328960, -817451520, -698297344, -561877056, -411613792, -251225136, -84665176, 83959240,
- 250492800, 410833184, 561032192, 697392512, 816558400, 915598016, 992075520, 1044110528,
- 1070424512, 1070372096, 1043956672, 991830592, 915278784, 816187328, 696996800, 560642560,
- 410482208, 250213232, 83781792, -84714288, -251126384, -411357152, -561461504, -697743552,
- -816847808, -915841536, -992287296, -1044302592, -1070606528, -1070551232, -1044137856, -992016512,
- -915470336, -816383744, -697196352, -560842560, -410679552, -250404528, -83963680, 84544936,
- 250972336, 411220768, 561344576, 697647424, 816773248, 915788800, 992256192, 1044292480,
- 1070616448, 1070579840, 1044183488, 992077376, 915544384, 816468800, 697290112, 560942720,
- 410783712, 250510352, 84068912, -84442472, -250874656, -411129728, -561261824, -697574272,
- -816710848, -915738048, -992217536, -1044266240, -1070602624, -1070578112, -1044193344, -992097920,
- -915574656, -816507712, -697336256, -560994752, -410840192, -250569808, -84129840, 84381496,
- 250815008, 411072672, 561208512, 697525760, 816667968, 915701504, 992187968, 1044243968,
- 1070587840, 1070570944, 1044193664, 992105472, 915588992, 816528256, 697362432, 561025728,
- 410875072, 250607648, 84169704, -84340632, -250774144, -411032768, -561170496, -697490560,
- -816636288, -915674048, -992165248, -1044226432, -1070575744, -1070564352, -1044192576, -992109760,
- -915598336, -816542272, -697380608, -561047424, -410899648, -250634432, -84197944, 84311648,
- 250745136, 411004448, 561143488, 697465472, 816613632, 915654272, 992148736, 1044213504,
- 1070566592, 1070559104, 1044191232, 992112320, 915604608, 816552064, 697393600, 561063296,
- 410917984, 250654720, 84219640, -84289112, -250722352, -410981984, -561121984, -697445376,
- -816595520, -915638656, -992135872, -1044203776, -1070560128, -1070556032, -1044191616, -992116032,
- -915611456, -816561792, -697405888, -561077696, -410934112, -250672080, -84237752, 84270736,
- 250704176, 410964480, 561105536, 697430400, 816582400, 915627520, 992127104, 1044197440,
- 1070556416, 1070555008, 1044193216, 992120256, 915618176, 816570816, 697417024, 561090688,
- 410948576, 250687680, 84254088
-};
-
-#endif
diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h
index e90ae83ac2f82687af9198058b061c4c4ce874ab..a897454522c6c08fbefcf421d174b9137c64ffa2 100644
--- a/lib_com/ivas_rom_com.h
+++ b/lib_com/ivas_rom_com.h
@@ -87,7 +87,6 @@ extern const uint16_t ECSQ_tab_inverse[1 + ECSQ_SEGMENT_SIZE];
*----------------------------------------------------------------------------------*/
extern const float ica_sincInterp2[];
-extern const Word32 ica_sincInterp2_fx[];
extern const float ica_sincInterp4[];
extern const float ica_sincInterp6[];
@@ -96,18 +95,14 @@ extern const float ica_sincInterp6[];
*----------------------------------------------------------------------------------*/
extern const float icbwe_gsMapping_tbl[];
-extern const Word16 pow_10_icbwe_gsMapping_tbl_fx[];
extern const float icbwe_gsMappingDFT_tbl[];
-extern const Word16 pow_10_icbwe_gsMappingDFT_tbl_fx[];
/*----------------------------------------------------------------------------------*
* TD Stereo ROM tables
*----------------------------------------------------------------------------------*/
extern const float tdm_ratio_tabl[];
-extern const UWord32 tdm_ratio_tabl_fx[TDM_NQ + 1];
extern const float tdm_den_ratio_tabl[];
-extern const UWord32 tdm_den_ratio_tabl_fx[];
extern const int16_t tdm_bit_allc_tbl[5][6];
/* LSFs Intra-frame prediction tables */
@@ -166,22 +161,12 @@ extern const float dft_cng_coh_pred[][STEREO_DFT_COH_PRED_COEFFS];
extern const int16_t dft_cng_coh_u2i[9];
extern const int16_t dft_cng_coh_i2u[9];
extern const float dft_cng_alpha_bits[STEREO_DFT_N_COH_ALPHA_STEPS][STEREO_DFT_N_COH_ALPHA_LEVELS];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word16 dft_cng_alpha_bits_fx[STEREO_DFT_N_COH_ALPHA_STEPS][STEREO_DFT_N_COH_ALPHA_LEVELS];
-extern const Word16 dft_cng_coh_pred_fx[][STEREO_DFT_COH_PRED_COEFFS];
-#endif // IVAS_FLOAT_FIXED
extern const int16_t dft_cng_coh_alpha_start[STEREO_DFT_N_COH_ALPHA_STEPS - 1];
/*----------------------------------------------------------------------------------*
* DirAC ROM tables
*----------------------------------------------------------------------------------*/
-#ifdef IVAS_FLOAT_FIXED
-extern const Word32 diffuseness_reconstructions_fx[DIRAC_DIFFUSE_LEVELS];
-extern const Word32 diffuseness_thresholds_fx[DIRAC_DIFFUSE_LEVELS + 1];
-extern const Masa_Diffuseness_Ratios masa_diffuse_ratios[DIRAC_DIFFUSE_LEVELS][DIRAC_DIFFUSE_LEVELS];
-#endif
-
extern const float diffuseness_reconstructions[DIRAC_DIFFUSE_LEVELS];
extern const float diffuseness_thresholds[DIRAC_DIFFUSE_LEVELS + 1];
extern const int16_t DirAC_band_grouping_12[12 + 1];
@@ -215,12 +200,10 @@ extern const int16_t HOA_keep_ind_spar[IVAS_SPAR_MAX_CH];
extern const int16_t HOA_keep_ind_spar512[IVAS_SPAR_MAX_CH];
extern const float dtx_pd_real_min_max[2];
-extern const Word32 dtx_pd_real_min_max_fx[2];
extern const int16_t dtx_pd_real_q_levels[3][3];
extern const int16_t dtx_pr_real_q_levels[3][3];
extern const int16_t pr_pr_idx_pairs[3][3][2];
extern const int16_t pr_pd_idx_pairs[3][3][2];
-extern const Word32 one_by_q_level[64];
/*----------------------------------------------------------------------*
* PCA ROM tables
@@ -254,8 +237,6 @@ extern const int16_t Param_MC_index[MAX_CICP_CHANNELS];
extern const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS];
extern const float ivas_param_mc_quant_ild_5d1_48[PARAM_MC_SZ_ILD_QUANTIZER_4BITS];
extern const float ivas_param_mc_quant_icc[PARAM_MC_SZ_ICC_QUANTIZER];
-extern const Word16 ivas_param_mc_quant_ild_5d1_48_fx[PARAM_MC_SZ_ILD_QUANTIZER_4BITS];
-extern const Word16 ivas_param_mc_quant_icc_fx[PARAM_MC_SZ_ICC_QUANTIZER];
extern const uint16_t ivas_param_mc_cum_freq_ild_cicp6_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS + 1];
extern const uint16_t ivas_param_mc_sym_freq_ild_cicp6_48_16bits[PARAM_MC_SZ_ILD_QUANTIZER_4BITS];
extern const uint16_t ivas_param_mc_cum_freq_ild_delta_cicp6_48_16bits[2 * PARAM_MC_SZ_ILD_QUANTIZER_4BITS];
@@ -301,14 +282,6 @@ extern const int16_t bits_direction_masa[DIRAC_DIFFUSE_LEVELS];
extern const int16_t no_theta_masa[NO_SPHERICAL_GRIDS - 2];
extern const int16_t no_phi_masa[NO_SPHERICAL_GRIDS][MAX_NO_THETA];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word32 no_phi_masa_inv_fx[NO_SPHERICAL_GRIDS][MAX_NO_THETA];
-extern const Word32 azimuth_cb_fx[8];
-extern const Word32 delta_theta_masa_fx[NO_SPHERICAL_GRIDS - 2];
-extern const Word32 coherence_cb0_masa_fx[DIRAC_DIFFUSE_LEVELS * 2 * MASA_NO_CV_COH];
-extern const Word32 coherence_cb1_masa_fx[MASA_NO_CV_COH1 * MASA_MAXIMUM_CODING_SUBBANDS]; /* 25 */
-#endif
-
extern const float delta_theta_masa[NO_SPHERICAL_GRIDS - 2];
extern const float azimuth_cb[8];
@@ -356,30 +329,9 @@ extern const float ls_azimuth_CICP16[9];
extern const float ls_elevation_CICP16[9];
extern const float ls_azimuth_CICP19[11];
extern const float ls_elevation_CICP19[11];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word16 ls_azimuth_CICP2_idx[2];
-extern const Word16 ls_elevation_CICP2_idx[2];
-extern const Word16 ls_azimuth_CICP6_idx[5];
-extern const Word16 ls_elevation_CICP6_idx[5];
-extern const Word16 ls_azimuth_CICP12_idx[7];
-extern const Word16 ls_elevation_CICP12_idx[7];
-extern const Word16 ls_azimuth_CICP14_idx[7];
-extern const Word16 ls_elevation_CICP14_idx[7];
-extern const Word16 ls_azimuth_CICP16_idx[9];
-extern const Word16 ls_elevation_CICP16_idx[9];
-extern const Word16 ls_azimuth_CICP19_idx[11];
-extern const Word16 ls_elevation_CICP19_idx[11];
extern const float shoebox_sin_cos_tbl[11][2];
-extern const Word32 shoebox_sin_cos_tbl_fx[11][2];
-#endif
extern const float cb_azi_chan[];
-extern const Word32 delta_phi_val[90];
-extern const Word32 inv_delta_phi_val[90];
-extern const Word32 dd_val[90];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word32 cb_azi_chan_fx[];
-#endif
extern const float McMASA_LFEGain_vectors[64];
@@ -393,12 +345,6 @@ extern const float dct5[];
extern const float dct8[];
extern const float dct12[];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word32 dct4_fx[];
-extern const Word32 dct5_fx[];
-extern const Word32 dct8_fx[];
-extern const Word32 dct12_fx[];
-#endif
/*----------------------------------------------------------------------------------*
* ISM ROM tables
*----------------------------------------------------------------------------------*/
@@ -406,11 +352,6 @@ extern const Word32 dct12_fx[];
extern const float ism_azimuth_borders[4];
extern const float ism_elevation_borders[4];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word32 ism_azimuth_borders_fx[4];
-extern const Word32 ism_elevation_borders_fx[4];
-#endif
-
/*----------------------------------------------------------------------------------*
* Param ISM ROM tables
*----------------------------------------------------------------------------------*/
@@ -428,27 +369,10 @@ extern const float ivas_lpf_2_butter_16k[IVAS_BIQUAD_FILT_LEN << 1];
extern const float ivas_lpf_2_butter_32k[IVAS_BIQUAD_FILT_LEN << 1];
extern const float ivas_lpf_2_butter_48k[IVAS_BIQUAD_FILT_LEN << 1];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word32 ivas_lpf_4_butter_16k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2];
-extern const Word32 ivas_lpf_4_butter_32k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2];
-extern const Word32 ivas_lpf_4_butter_48k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2];
-extern const Word32 ivas_lpf_2_butter_16k_fx[IVAS_BIQUAD_FILT_LEN << 1];
-extern const Word32 ivas_lpf_2_butter_32k_fx[IVAS_BIQUAD_FILT_LEN << 1];
-extern const Word32 ivas_lpf_2_butter_48k_fx[IVAS_BIQUAD_FILT_LEN << 1];
-#endif
-
-
extern const float ivas_lfe_window_coeff_48k[IVAS_LFE_FADE_LEN_48K];
extern const float ivas_lfe_window_coeff_32k[IVAS_LFE_FADE_LEN_32K];
extern const float ivas_lfe_window_coeff_16k[IVAS_LFE_FADE_LEN_16K];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word32 ivas_lfe_window_coeff_48k_fx[IVAS_LFE_FADE_LEN_48K];
-extern const Word32 ivas_lfe_window_coeff_32k_fx[IVAS_LFE_FADE_LEN_32K];
-extern const Word32 ivas_lfe_window_coeff_16k_fx[IVAS_LFE_FADE_LEN_16K];
-#endif
-
-
extern const int16_t ivas_lfe_num_ele_in_coder_models[2][4];
extern const Word16 ivas_lfe_log2_num_ele_in_coder_models_fx[2][4];
extern const int16_t ivas_lfe_num_dct_pass_bins_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP];
@@ -456,11 +380,7 @@ extern const int16_t ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP];
extern const ivas_lfe_freq_models ivas_str_lfe_freq_models;
extern const float ivas_lfe_lpf_delay[2];
extern const Word16 ivas_lfe_lpf_delay_Q15[2];
-#ifdef IVAS_FLOAT_FIXED
-extern const UWord32 d_hamm_lfe_plc_fx[LFE_PLC_LENANA / 2];
-#else
extern const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2];
-#endif
extern const float ivas_sin_twiddle_480[IVAS_480_PT_LEN >> 1];
extern const float ivas_cos_twiddle_480[IVAS_480_PT_LEN >> 1];
extern const float ivas_sin_twiddle_320[IVAS_320_PT_LEN >> 1];
@@ -482,27 +402,11 @@ extern const float ivas_mdft_coeff_cos_twid_40[IVAS_40_PT_LEN + 1];
extern const float ivas_mdft_coeff_cos_twid_960[IVAS_960_PT_LEN + 1];
extern const float ivas_mdft_coeff_cos_twid_640[IVAS_640_PT_LEN + 1];
extern const float ivas_mdft_coeff_cos_twid_320[IVAS_320_PT_LEN + 1];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word32 ivas_mdft_coeff_cos_twid_240_fx[IVAS_240_PT_LEN + 1];
-extern const Word32 ivas_mdft_coeff_cos_twid_160_fx[IVAS_160_PT_LEN + 1];
-extern const Word32 ivas_mdft_coeff_cos_twid_120_fx[IVAS_120_PT_LEN + 1];
-extern const Word32 ivas_mdft_coeff_cos_twid_80_fx[IVAS_80_PT_LEN + 1];
-extern const Word32 ivas_mdft_coeff_cos_twid_40_fx[IVAS_40_PT_LEN + 1];
-extern const Word32 ivas_mdft_coeff_cos_twid_960_fx[IVAS_960_PT_LEN + 1];
-extern const Word32 ivas_mdft_coeff_cos_twid_640_fx[IVAS_640_PT_LEN + 1];
-extern const Word32 ivas_mdft_coeff_cos_twid_320_fx[IVAS_320_PT_LEN + 1];
-#endif
extern const int16_t 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];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word32 dirac_gains_norm_term_int[9];
-extern const Word32 dirac_gains_norm_term_fx[9];
-extern const Word32 dirac_gains_Pnm_int[91][9];
-extern const Word32 dirac_gains_trg_term_int[181][2];
-extern const Word32 dirac_gains_trg_term_fx[181][2];
-#endif
+
/*------------------------------------------------------------------------------------------*
* FB ROM tables
*------------------------------------------------------------------------------------------*/
@@ -525,23 +429,9 @@ extern const float ivas_fb_cf_1ms_32k[IVAS_FB_1MS_32K_SAMP];
extern const float ivas_fb_cf_4ms_16k[IVAS_FB_4MS_16K_SAMP];
extern const float ivas_fb_cf_1ms_16k[IVAS_FB_1MS_16K_SAMP];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word16 ivas_fb_cf_4ms_48k_fx[IVAS_FB_4MS_48K_SAMP];
-extern const Word16 ivas_fb_cf_1ms_48k_fx[IVAS_FB_1MS_48K_SAMP];
-extern const Word16 ivas_fb_cf_4ms_32k_fx[IVAS_FB_4MS_32K_SAMP];
-extern const Word16 ivas_fb_cf_1ms_32k_fx[IVAS_FB_1MS_32K_SAMP];
-extern const Word16 ivas_fb_cf_4ms_16k_fx[IVAS_FB_4MS_16K_SAMP];
-extern const Word16 ivas_fb_cf_1ms_16k_fx[IVAS_FB_1MS_16K_SAMP];
-#endif
-
extern const float ivas_fb_resp_cheby_ramp_32del[IVAS_FB_1MS_32K_SAMP + 1];
extern const float ivas_fb_resp_cheby_ramp_16del[IVAS_FB_1MS_16K_SAMP + 1];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word32 ivas_fb_resp_cheby_ramp_32del_fx[IVAS_FB_1MS_32K_SAMP + 1];
-extern const Word32 ivas_fb_resp_cheby_ramp_16del_fx[IVAS_FB_1MS_16K_SAMP + 1];
-#endif
-
extern const int16_t ivas_num_active_bands[FB - WB + 1];
/*------------------------------------------------------------------------------------------*
@@ -556,10 +446,6 @@ extern const int16_t ivas_sns_cdbks_tcx10_bits[];
extern const float *const ivas_sns_cdbks_tcx20[];
extern const float *const ivas_sns_cdbks_tcx10[];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word16 *const ivas_sns_cdbks_tcx20_fx[];
-extern const Word16 *const ivas_sns_cdbks_tcx10_fx[];
-#endif
extern const int16_t ivas_sns_cdbks_side_tcx20_levels[];
extern const int16_t ivas_sns_cdbks_side_tcx20_bits[];
@@ -568,10 +454,6 @@ extern const int16_t ivas_sns_cdbks_side_tcx10_bits[];
extern const float *const ivas_sns_cdbks_side_tcx20[];
extern const float *const ivas_sns_cdbks_side_tcx10[];
-#ifdef IVAS_FLOAT_FIXED
-extern const Word16 *const ivas_sns_cdbks_side_tcx20_fx[];
-extern const Word16 *const ivas_sns_cdbks_side_tcx10_fx[];
-#endif
/* means and codebooks for the split VQ in the 2-stage SNS VQ */
extern const int16_t sns_1st_cdbk[2][2][8 * 32];
@@ -588,24 +470,5 @@ extern const int16_t ivas_param_upmx_mx_qmap[33];
extern const ACPL_QUANT_TABLE ivas_mc_paramupmix_alpha_quant_table;
extern const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[9];
-#ifdef IVAS_FLOAT_FIXED
-extern const ACPL_QUANT_TABLE_FX ivas_mc_paramupmix_alpha_quant_table_fx;
-extern const ACPL_QUANT_TABLE_FX ivas_mc_paramupmix_beta_quant_table_fx[9];
-#endif // IVAS_FLOAT_FIXED
-
-#ifdef IVAS_FLOAT_FIXED
-extern const Word32 ivas_han_win_48k_fx[L_FRAME32k];
-extern const Word32 ivas_han_win_32k_fx[L_FRAME32k];
-extern const Word32 ivas_han_win_16k_fx[L_FRAME32k];
-
-extern const Word32 ivas_sine_delay_32_fx[32];
-
-extern const Word32 ivas_sine_frame_len_640_del_32_fx[577];
-extern const Word32 ivas_sine_frame_len_640_del_16_fx[289];
-
-extern const Word32 ivas_fb_fr_12band_1ms_re_fx[IVAS_FB_12_1MS_LEN];
-extern const Word32 ivas_fb_fr_12band_1ms_im_fx[IVAS_FB_12_1MS_LEN];
-#endif
-
/* IVAS_ROM_COM_H */
#endif
diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c
index 0570d4f3c3f4af6beb991ece86efb194c7d80d11..affd420b94eb44e1325d8fb7fdcd7c3bad5380f4 100644
--- a/lib_com/ivas_rom_com_fx.c
+++ b/lib_com/ivas_rom_com_fx.c
@@ -1244,4 +1244,3754 @@ const Masa_Diffuseness_Ratios masa_diffuse_ratios[DIRAC_DIFFUSE_LEVELS][DIRAC_DI
};
#endif
+/*----------------------------------------------------------------------------------*
+ * Stereo ICA ROM tables
+ *----------------------------------------------------------------------------------*/
+
+const Word32 ica_sincInterp2_fx[2 * SINC_ORDER1 + 1] = {
+ 0, -4988604, 0, 7486127, 0,
+ -12594991, 0, 20905753, 0, -33172179, 0,
+ 50472307, 0, -74575663, 0, 108767895, 0,
+ -160155039, 0, 247433071, 0, -439753119, 0,
+ 1361749503, 2147483647, 1361749503, 0, -439753119, 0,
+ 247433071, 0, -160155039, 0, 108767895, 0,
+ -74575663, 0, 50472307, 0, -33172179, 0,
+ 20905753, 0, -12594991, 0, 7486127, 0,
+ -4988604, 0
+};
+
+/*----------------------------------------------------------------------------------*
+ * Stereo IC-BWE ROM tables
+ *----------------------------------------------------------------------------------*/
+
+// Q14
+const Word16 pow_10_icbwe_gsMapping_tbl_fx[16] = {
+ 164, 733, 1793, 3195, 4524, 5875, 7438, 9155, 11101, 13053, 13945, 14602, 15647, 16384,
+ 17965, 19698
+};
+
+// Q14
+const Word16 pow_10_icbwe_gsMappingDFT_tbl_fx[128] = {
+ 0, 1, 2, 5, 16, 52, 206, 464, 518, 585, 667, 688, 803, 899,
+ 1324, 1349, 1513, 1534, 1578, 1625, 1711, 1756, 1808, 1879, 1926, 2001, 2050, 2130,
+ 2191, 2280, 2366, 2394, 2456, 2574, 2643, 2726, 2796, 2850, 2869, 2908, 2962, 2991,
+ 3023, 3051, 3091, 3130, 3202, 3233, 3268, 3342, 3388, 3429, 3483, 3519, 3553, 3595,
+ 3651, 3706, 3738, 3795, 3844, 3890, 3946, 3990, 4028, 4075, 4119, 4166, 4214, 4259,
+ 4303, 4350, 4389, 4441, 4481, 4540, 4605, 4684, 4764, 4854, 4950, 5068, 5198, 5348,
+ 5519, 5692, 5881, 6073, 6273, 6473, 6676, 6883, 7124, 7364, 7616, 7852, 8097, 8370,
+ 8630, 8916, 9200, 9496, 9866, 10252, 10652, 11052, 11436, 11813, 12247, 12697, 13153, 13611,
+ 14072, 14503, 14936, 15336, 15702, 16032, 16384, 16664, 16980, 17253, 17550, 17866, 18206, 18594,
+ 19072, 19631
+};
+
+/*----------------------------------------------------------------------------------*
+ * TD Stereo ROM tables
+ *----------------------------------------------------------------------------------*/
+
+// Q31
+const UWord32 tdm_ratio_tabl_fx[TDM_NQ + 1] = {
+ 0, 0, 23407572, 52613348, 92771296,
+ 143881408, 205084688, 275736896, 355193792, 442596384, 536870912,
+ 636943680, 741955584, 850403520, 961428416, 1073741824, 1186055168,
+ 1297080064, 1405528064, 1510540032, 1610612736, 1704887296, 1792289792,
+ 1871746688, 1942398976, 2003602304, 2054712320, 2094870272, 2124076032,
+ 2147483647, 2147483647, 2147483647
+};
+
+// Q24
+const Word32 tdm_ratio_tabl_fx_Q24[TDM_NQ + 1] = {
+ 0, 0, 182871, 411041, 724775, 1124073, 1602224, 2154194,
+ 2774951, 3457784, 4194304, 4976122, 5796528, 6643777, 7511159, 8388608,
+ 9266056, 10133438, 10980688, 11801094, 12582912, 13319432, 14002264, 14623021,
+ 15174992, 15653143, 16052440, 16366174, 16594344, 16777216, 16777216, 16777216
+};
+
+const UWord32 tdm_den_ratio_tabl_fx[TDM_NQ + 1] = {
+ 1073741824, 1073741824, 1097471488, 1127536256, 1170593280,
+ 1227179520, 1297939072, 1383409024, 1483374336, 1596009856, 1717986944,
+ 1842648320, 1960330496, 2058470400, 2124290816, 2147483647, 2124290816,
+ 2058470400, 1960330496, 1842648320, 1717986944, 1596009856, 1483374336,
+ 1383409024, 1297939072, 1227179520, 1170593280, 1127536256, 1097471488,
+ 1073741824, 1073741824, 1073741824
+};
+
+/* LSFs Intra-frame prediction tables */
+
+// 2.56
+const Word16 tdm_LSF_MEAN_RE_USE_OUT_fx[M] = {
+ 771, 1335, 2229, 3431, 4383, 5354, 6371, 7273, 8183, 9198, 10133, 10991, 12058, 13104, 14200, 15152
+};
+
+// 2.56
+const Word16 tdm_LSF_MEAN_RE_USE_IN_fx[M] = {
+ 733,
+ 1337,
+ 2271,
+ 3451,
+ 4418,
+ 5382,
+ 6430,
+ 7304,
+ 8221,
+ 9247,
+ 10165,
+ 11079,
+ 12115,
+ 13197,
+ 14266,
+ 15269,
+};
+
+// 2.56
+const Word16 tdm_LSF_MEAN_RE_USE_fx[M] = {
+ 680, 1369, 2354, 3448, 4498, 5435, 6546, 7494, 8446, 9437, 10328, 11248, 12241, 13199, 14189, 15174
+};
+
+// Q15
+const Word16 tdm_Beta_Q1bit_re_use_13k2_fx[2] = { 31784, 24576 };
+
+// Q15
+const Word16 tdm_Beta_Q1bit_re_use_16k4_fx[2] = { 31129, 23265 };
+
+// Q15
+const Word16 tdm_Beta_Q1bit_re_use_24k4_32k_fx[2] = { 30474, 23920 };
+
+// Q15
+const Word16 tdm_Beta_Q1bit_re_use_48k_fx[2] = { 31784, 25231 };
+
+// Q15
+const Word16 tdm_RE_USE_adaptive_beta_prd_diag_3_fx[15 + 16 + 15] = {
+ 29028, 6750, 1916, 27016, 7516, 1195, 26787, 5557, -196, 27796, 6753, 2172, 29434, 4446, 2175, 26053, 6337, 3063, 26043, 5521, 3633, 26082,
+ 5989, 3515, 25672, 5911, 4846, 24123, 6494, 4374, 24971, 6225, 6235, 24146, 5619, 5848, 23638, 5393, 6445, 22579, 4027, 6694, 20698, 1779,
+ 5789, 17681
+};
+
+// 2.56
+const Word16 tdm_LSF_MEAN_PRED_QNT_fx[M] = {
+ 1002, 1558, 2478, 3467, 4377, 5326, 6274, 7160, 8182, 9099, 10022, 10967, 12051, 13081, 14148, 15113
+};
+
+// 2.56
+const Word16 tdm_LSF_MEAN_PRED_QNT_IN_fx[M] = {
+ 739, 1371, 2303, 3436, 4431, 5394, 6378, 7321, 8293, 9282, 10221, 11153, 12166, 13193, 14252, 15290
+};
+
+// 2.56
+const Word16 tdm_LSF_MEAN_PRED_QNT_OUT_fx[M] = {
+ 733, 1337, 2271, 3451, 4418, 5382, 6430, 7304, 8221, 9247, 10165, 11079, 12115, 13197, 14266, 15269
+};
+
+// Q15
+const Word16 tdm_PRED_QNT_fixed_beta_prd_diag_3_fx[15 + 16 + 15] = {
+ 23067, 3941, -3666, 24050, 5907, 829, 21960, 6229, -6052, 25859, 9862, -1369, 28559, 6019, 108, 22658, 7844, 697, 22045, 7998, 2310, 24735,
+ 6497, 2464, 23434, 7120, 2903, 20194, 10049, 711, 26610, 6622, 5190, 23955, 5721, 3945, 23906, 6481, 4033, 24581, 4043, 5599, 20879, 3473,
+ 3909, 21541
+};
+
+/*----------------------------------------------------------------------------------*
+ * Stereo DTX ROM tables
+ *----------------------------------------------------------------------------------*/
+
+/*Q-13*/
+const Word16 dft_cng_coh_pred_fx[STEREO_DFT_N_COH_PRED][STEREO_DFT_COH_PRED_COEFFS] = {
+ { 4926, -827, 10396, 696, 2285, 5488, 668, 1547, -1416, 2633, 76, -690, 2967, -3495, 6212 },
+ { 7007, 3446, 3385, -76, -3274, 11352, 101, -125, 1281, 4238, 1312, -2487, 3913, -4593, 11326 },
+ { 1659, 399, 2157, 192, 753, 3241, 107, -91, 290, 7995, 81, 1334, 3139, -2994, 20764 },
+ { 11416, -1076, 8105, 6048, 5602, 13, -1846, -99, 8885, -945, 183, -373, -2754, 3463, 4089 }
+};
+
+/*Q-15*/
+const Word16 dft_cng_alpha_bits_fx[STEREO_DFT_N_COH_ALPHA_STEPS][STEREO_DFT_N_COH_ALPHA_LEVELS] = {
+ { 3277 /*0.1f*/, 19661 /*0.6f*/ },
+ { 3277 /*0.1f*/, 19661 /*0.6f*/ },
+ { 3277 /*0.1f*/, 22938 /*0.7f*/ },
+ { 3277 /*0.1f*/, 29491 /*0.9f*/ },
+ { 6554 /*0.2f*/, 29491 /*0.9f*/ }
+};
+
+/*----------------------------------------------------------------------------------*
+ * DirAC ROM tables
+ *----------------------------------------------------------------------------------*/
+
+// q = 30
+const Word32 diffuseness_reconstructions_fx[DIRAC_DIFFUSE_LEVELS] = {
+ 0, 42467328, 96206848, 170655744, 331087872, 508821504, 678952960, 912785408
+};
+
+const Word32 diffuseness_thresholds_fx[DIRAC_DIFFUSE_LEVELS + 1] = {
+ 0,
+ 20447232,
+ 67633152,
+ 128188416,
+ 237502464,
+ 428605440,
+ 587988992,
+ 788791296,
+ MAX_32 /* out-of-range large value to make searching easier */
+};
+
+/*------------------------------------------------------------------------------------------*
+ * SPAR ROM tables
+ *------------------------------------------------------------------------------------------*/
+
+const Word32 dtx_pd_real_min_max_fx[2] = {
+ 0, 429496729
+};
+
+const Word32 one_by_q_level[64] = {
+ 0, 2147483647, 1073741824, 715827904, 536870912, 429496736,
+ 357913952, 306783392, 268435456, 238609296, 214748368,
+ 195225792, 178956976, 165191056, 153391696, 143165584,
+ 134217728, 126322568, 119304648, 113025456, 107374184,
+ 102261128, 97612896, 93368856, 89478488, 85899344,
+ 82595528, 79536432, 76695848, 74051160, 71582792,
+ 69273664, 67108864, 65075264, 63161284, 61356676,
+ 59652324, 58040100, 56512728, 55063684, 53687092,
+ 52377648, 51130564, 49941480, 48806448, 47721860,
+ 46684428, 45691140, 44739244, 43826196, 42949672,
+ 42107524, 41297764, 40518560, 39768216, 39045156,
+ 38347924, 37675152, 37025580, 36398028, 35791396,
+ 35204648, 34636832, 34087044
+};
+
+/*----------------------------------------------------------------------------------*
+ * Parametric MC ROM tables
+ *----------------------------------------------------------------------------------*/
+
+// Q8
+const Word16 ivas_param_mc_quant_ild_5d1_48_fx[PARAM_MC_SZ_ILD_QUANTIZER_4BITS] = {
+ -25600, -5120, -3328, -2560, -2048, -1408, -896, -384, 0, 384, 896, 1408, 2048, 2560, 3328, 5120
+};
+
+// Q15
+const Word16 ivas_param_mc_quant_icc_fx[PARAM_MC_SZ_ICC_QUANTIZER] = {
+ -32440, -19300, 0, 12046, 19690, 27563, 30703, 32767
+};
+
+/*----------------------------------------------------------------------------------*
+ * MASA ROM tables
+ *----------------------------------------------------------------------------------*/
+
+/* from 1 to 11 bits*/ /*q factor = 8*/
+const Word32 no_phi_masa_inv_fx[NO_SPHERICAL_GRIDS][MAX_NO_THETA] = {
+ { 1073741824 },
+ { 536870912 },
+ { 536870912, 1073741824 },
+ { 268435456, 536870912 },
+ { 178956970, 306783378, 1073741824, 2147483647 },
+ { 153391689, 165191049, 238609294, 1073741824, 2147483647 },
+ { 97612893, 102261126, 126322567, 195225786, 715827882, 2147483647 },
+ { 65075262, 67108864, 74051160, 93368854, 126322567, 238609294, 2147483647 },
+ { 44739242, 45691141, 47721858, 52377649, 61356675, 76695844, 107374182, 178956970, 1073741824, 2147483647 },
+ { 35791394, 35791394, 37025580, 38347922, 39768215, 42949672, 46684427, 52377649, 59652323, 71582788, 93368854, 126322567, 214748364, 2147483647 },
+ { 24129029, 24129029, 24403223, 24970740, 25565281, 26512143, 27889398, 29417584, 31580641, 34087042, 37675151, 42107522, 48806446, 56512727, 71582788, 93368854, 143165576, 268435456, 2147483647 }
+};
+
+const Word32 azimuth_cb_fx[8] = {
+ 0, -754974720, -377487360, 377487360, -188743680, 188743680, -566231040, 566231040
+};
+
+const Word32 delta_theta_masa_fx[NO_SPHERICAL_GRIDS - 2] = {
+ 188743680, 188743680, 150994944, 106954752, 83886080, 62914560, 45214596, 28101836, 20971520
+};
+
+// q = 21
+const Word32 coherence_cb0_masa_fx[DIRAC_DIFFUSE_LEVELS * 2 * MASA_NO_CV_COH] = {
+ 100243, 534144, 1156579, 2068840, 2846464, 3531184, 4125936, 0, 253965, 864655, 1467377,
+ 2129448, 2977326, 3768791, 0, 0, 338480, 1189924, 2035915, 2872888, 3640026, 0, 0, 0,
+ 492621, 1532179, 2527278, 3470157, 0, 0, 0, 0, 499331, 1506803, 2465831, 3425697, 0,
+ 0, 0, 0, 503316, 1473668, 2392221, 3406404, 0, 0, 0, 0, 737778, 1970903, 3450654, 0, 0,
+ 0, 0, 0, 2097152, 0, 0, 0, 0, 0, 0, 0, 303038, 719742, 1122186, 1577897, 2117075, 2770337,
+ 3648834, 0, 419849, 932603, 1440533, 2011797, 2745172, 3571240, 0, 0, 548824, 1165177,
+ 1812987, 2555379, 3366138, 0, 0, 0, 695835, 1428160, 2190475, 3084910, 0, 0, 0, 0, 697093,
+ 1381603, 2092957, 2970406, 0, 0, 0, 0, 708417, 1396283, 2099039, 2992426, 0, 0, 0, 0, 835924,
+ 1728892, 2836607, 0, 0, 0, 0, 0, 2097152, 0, 0, 0, 0, 0, 0, 0
+};
+
+// q = 21
+const Word32 coherence_cb1_masa_fx[MASA_NO_CV_COH1 * MASA_MAXIMUM_CODING_SUBBANDS] = {
+ -3984, 544630, -565392, 1314704, -1320157, -11534, 541484, -583847, 1357486, -1371118,
+ -6081, 525546, -551551, 1362729, -1371537, -838, 533934, -540855, 1436758, -1414109,
+ 3565, 528692, -519883, 1513514, -1500931
+};
+
+/* Multi-channel input and output setups */
+const int16_t ls_azimuth_CICP2_idx[2] = { 1, 2 };
+const int16_t ls_elevation_CICP2_idx[2] = { 0, 0 };
+
+const int16_t ls_azimuth_CICP6_idx[5] = { 1, 2, 0, 7, 8 };
+const int16_t ls_elevation_CICP6_idx[5] = { 0, 0, 0, 0, 0 };
+
+const int16_t ls_azimuth_CICP12_idx[7] = { 1, 2, 0, 7, 8, 9, 10 };
+const int16_t ls_elevation_CICP12_idx[7] = { 0, 0, 0, 0, 0, 0, 0 };
+
+const int16_t ls_azimuth_CICP14_idx[7] = { 1, 2, 0, 7, 8, 1, 2 };
+const int16_t ls_elevation_CICP14_idx[7] = { 0, 0, 0, 0, 0, 3, 4 };
+
+const int16_t ls_azimuth_CICP16_idx[9] = { 1, 2, 0, 7, 8, 1, 2, 7, 8 };
+const int16_t ls_elevation_CICP16_idx[9] = { 0, 0, 0, 0, 0, 3, 3, 3, 3 };
+
+const int16_t ls_azimuth_CICP19_idx[11] = { 1, 2, 0, 9, 10, 5, 6, 1, 2, 9, 10 };
+const int16_t ls_elevation_CICP19_idx[11] = { 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3 };
+
+const Word32 shoebox_sin_cos_tbl_fx[11][2] = { { 0, 1073741824 }, // 0
+ { 536870912, 929887680 },
+ { -536870912, 929887680 }, // 30, -30
+ { 615873024, 879557824 },
+ { -615873024, 879557824 }, // 35, -35
+ { 1073741824, 0 },
+ { -1073741824, 0 }, // 90, -90
+ { 1008987264, -367241312 },
+ { -1008987264, -367241312 }, // 110,-110
+ { 759250112, -759250112 },
+ { -759250112, -759250112 } }; // 135, -135 //Q.30
+
+const Word32 delta_phi_val[90] = {
+ 0, 1509949440, 754974720, 503316480, 377487360, 301989888,
+ 251658240, 215707056, 188743680, 167772160, 150994944,
+ 137268128, 125829120, 116149960, 107853528, 100663296,
+ 94371840, 88820552, 83886080, 79471024, 75497472,
+ 71902352, 68634064, 65649976, 62914560, 60397976,
+ 58074980, 55924052, 53926764, 52067224, 50331648,
+ 48708048, 47185920, 45756044, 44410276, 43141412,
+ 41943040, 40809444, 39735512, 38716652, 37748736,
+ 36828036, 35951176, 35115104, 34317032, 33554432,
+ 32824988, 32126584, 31457280, 30815294, 30198988,
+ 29606852, 29037490, 28489612, 27962026, 27453626,
+ 26963382, 26490342, 26033612, 25592364, 25165824,
+ 24753270, 24354024, 23967452, 23592960, 23229992,
+ 22878022, 22536558, 22205138, 21883326, 21570706,
+ 21266894, 20971520, 20684238, 20404722, 20132660,
+ 19867756, 19609732, 19358326, 19113284, 18874368,
+ 18641352, 18414018, 18192162, 17975588, 17764112,
+ 17557552, 17355740, 17158516, 16965724
+};
+
+const Word32 inv_delta_phi_val[90] = {
+ 0, 5965232, 11930464, 17895697, 23860929, 29826161,
+ 35791394, 41756626, 47721858, 53687091, 59652323,
+ 65617555, 71582788, 77548020, 83513252, 89478485,
+ 95443717, 101408950, 107374182, 113339414, 119304647,
+ 125269879, 131235111, 137200344, 143165576, 149130808,
+ 155096041, 161061273, 167026505, 172991738, 178956970,
+ 184922203, 190887435, 196852667, 202817900, 208783132,
+ 214748364, 220713597, 226678829, 232644061, 238609294,
+ 244574526, 250539758, 256504991, 262470223, 268435456,
+ 274400688, 280365920, 286331153, 292296385, 298261617,
+ 304226850, 310192082, 316157314, 322122547, 328087779,
+ 334053011, 340018244, 345983476, 351948708, 357913941,
+ 363879173, 369844406, 375809638, 381774870, 387740103,
+ 393705335, 399670567, 405635800, 411601032, 417566264,
+ 423531497, 429496729, 435461961, 441427194, 447392426,
+ 453357659, 459322891, 465288123, 471253356, 477218588,
+ 483183820, 489149053, 495114285, 501079517, 507044750,
+ 513009982, 518975214, 524940447, 530905679
+};
+
+const Word32 dd_val[90] = {
+ 0, 754974720, 377487360, 251658240, 188743680, 150994944,
+ 125829120, 107853528, 94371840, 83886080, 75497472,
+ 68634064, 62914560, 58074980, 53926764, 50331648,
+ 47185920, 44410276, 41943040, 39735512, 37748736,
+ 35951176, 34317032, 32824988, 31457280, 30198988,
+ 29037490, 27962026, 26963382, 26033612, 25165824,
+ 24354024, 23592960, 22878022, 22205138, 21570706,
+ 20971520, 20404722, 19867756, 19358326, 18874368,
+ 18414018, 17975588, 17557552, 17158516, 16777216,
+ 16412494, 16063292, 15728640, 15407647, 15099494,
+ 14803426, 14518745, 14244806, 13981013, 13726813,
+ 13481691, 13245171, 13016806, 12796182, 12582912,
+ 12376635, 12177012, 11983726, 11796480, 11614996,
+ 11439011, 11268279, 11102569, 10941663, 10785353,
+ 10633447, 10485760, 10342119, 10202361, 10066330,
+ 9933878, 9804866, 9679163, 9556642, 9437184,
+ 9320676, 9207009, 9096081, 8987794, 8882056,
+ 8778776, 8677870, 8579258, 8482862
+};
+
+const Word32 cb_azi_chan_fx[] = { 0, 125829120, 461373440, 566231040 };
+
+/*----------------------------------------------------------------------------------*
+ * MASA and ISM (OMASA) combined format ROM tables
+ *----------------------------------------------------------------------------------*/
+
+const Word32 dct4_fx[4 * 4] = {
+ 1073741824, 1402951040, 1073741824, 581109056,
+ 1073741824, 581109056, -1073741824, -1402951040,
+ 1073741824, -581109056, -1073741824, 1402951040,
+ 1073741824, -1402951040, 1073741824, -581109056
+};
+
+const Word32 dct5_fx[5 * 5] = {
+ 960354688, 1291711360, 1098867328, 798219648, 419618304,
+ 960354688, 798219648, -419618304, -1291711360, -1098867328,
+ 960354688, 0, -1358283392, 0, 1358283392,
+ 960354688, -798219648, -419618304, 1291711360, -1098867328,
+ 960354688, -1291711360, 1098867328, -798219648, 419618304
+};
+
+const Word32 dct8_fx[8 * 8] = {
+ 759350208, 1053125952, 991922688, 892708928, 759350208, 596570944, 410813632, 209379648,
+ 759350208, 892708928, 410813632, -209379648, -759350208, -1053125952, -991922688, -596570944,
+ 759350208, 596570944, -410813632, -1053125952, -759350208, 209379648, 991922688, 892708928,
+ 759350208, 209379648, -991922688, -596570944, 759350208, 892708928, -410813632, -1053125952,
+ 759350208, -209379648, -991922688, 596570944, 759350208, -892708928, -410813632, 1053125952,
+ 759350208, -596570944, -410813632, 1053125952, -759350208, -209379648, 991922688, -892708928,
+ 759350208, -892708928, 410813632, 209379648, -759350208, 1053125952, -991922688, 596570944,
+ 759350208, -1053125952, 991922688, -892708928, 759350208, -596570944, 410813632, -209379648
+};
+
+const Word32 dct12_fx[12 * 12] = {
+ 619978560, 869301376, 846752832, 810030848, 759350208, 695569984, 619978560, 533649696, 438301408, 335436960, 226989024, 114460880,
+ 619978560, 810030848, 619978560, 335436960, 0, -335436960, -619978560, -810030848, -876602816, -810030848, -619978560, -335436960,
+ 619978560, 695569984, 226989024, -335436960, -759350208, -869301376, -619978560, -114460880, 438301408, 810030848, 846752832, 533649696,
+ 619978560, 533649696, -226989024, -810030848, -759350208, -114460880, 619978560, 869301376, 438301408, -335436960, -846752832, -695569984,
+ 619978560, 335436960, -619978560, -810030848, 0, 810030848, 619978560, -335436960, -876602816, -335436960, 619978560, 810030848, 619978560,
+ 114460880, -846752832, -335436960, 759350208, 533649696, -619978560, -695569984, 438301408, 810030848, -226989024, -869301376, 619978560,
+ -114460880, -846752832, 335436960, 759350208, -533649696, -619978560, 695569984, 438301408, -810030848, -226989024, 869301376, 619978560,
+ -335436960, -619978560, 810030848, 0, -810030848, 619978560, 335436960, -876602816, 335436960, 619978560, -810030848, 619978560, -533649696,
+ -226989024, 810030848, -759350208, 114460880, 619978560, -869301376, 438301408, 335436960, -846752832, 695569984, 619978560, -695569984,
+ 226989024, 335436960, -759350208, 869301376, -619978560, 114460880, 438301408, -810030848, 846752832, -533649696, 619978560, -810030848,
+ 619978560, -335436960, 0, 335436960, -619978560, 810030848, -876602816, 810030848, -619978560, 335436960, 619978560, -869301376, 846752832,
+ -810030848, 759350208, -695569984, 619978560, -533649696, 438301408, -335436960, 226989024, -114460880
+};
+
+/*----------------------------------------------------------------------------------*
+ * ISM ROM tables
+ *----------------------------------------------------------------------------------*/
+
+const Word32 ism_azimuth_borders_fx[4] = {
+ ISM_AZIMUTH_MIN_FX, ISM_AZIMUTH_LOW_BORDER_FX, ISM_AZIMUTH_HIGH_BORDER_FX, ISM_AZIMUTH_MAX_FX
+};
+
+const Word32 ism_elevation_borders_fx[4] = {
+ ISM_ELEVATION_MIN_FX, ISM_ELEVATION_LOW_BORDER_FX, ISM_ELEVATION_HIGH_BORDER_FX, ISM_ELEVATION_MAX_FX
+};
+
+/*----------------------------------------------------------------------------------*
+ * LFE coding ROM tables
+ *----------------------------------------------------------------------------------*/
+
+const Word32 ivas_lpf_4_butter_16k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2] = {
+ // 0x1ab, 0x356, 0x1ab, 0x40000000,
+ 0x3558C94E, 0x3558C95D, 0x3558C94E, 0x40000000,
+ 0x85ec0b80, 0x3a3cb940, 0x40000000, 0x7fffffff,
+ 0x40000000, 0x40000000, 0x829d8180, 0x3d8c5e40
+};
+const Word16 ivas_lpf_4_butter_16k_sos_e[IVAS_BIQUAD_FILT_LEN << 2] = {
+ -20, -19, -20, 1, 1, 1, 1, 1, 1, 1, 1, 1
+};
+
+const Word32 ivas_lpf_4_butter_32k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2] = {
+ // 0x1c, 0x37, 0x1c, 0x40000000,
+ 0x371ED5AA, 0x371ED5BA, 0x371ED5AA, 0x40000000,
+ 0x82fd4b80, 0x3d0d2280, 0x40000000, 0x7fffffff,
+ 0x40000000, 0x40000000, 0x81478600, 0x3ec30c00
+};
+const Word16 ivas_lpf_4_butter_32k_sos_e[IVAS_BIQUAD_FILT_LEN << 2] = {
+ -24, -23, -24, 1, 1, 1, 1, 1, 1, 1, 1, 1
+};
+
+const Word32 ivas_lpf_4_butter_48k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2] = {
+ // 6, 11, 6, 1073741824, /* Q30 */
+ 1477520448, 1477520448, 1477520448, 1073741824,
+ -2113939767, 1040504054, 1073741824, 2147483480,
+ 1073741829, 1073741824, -2133281237, 1059848324
+};
+const Word16 ivas_lpf_4_butter_48k_sos_e[IVAS_BIQUAD_FILT_LEN << 2] = {
+ -27, -26, -27, 1, 1, 1, 1, 1, 1, 1, 1, 1
+};
+
+const Word32 ivas_lpf_2_butter_16k_fx[IVAS_BIQUAD_FILT_LEN << 1] = { /* Q30 */
+ 0xa4d0c, 0x149a17, 0xa4d0c, 0x40000000, 0x849e6300, 0x3b8ad140
+};
+
+const Word32 ivas_lpf_2_butter_32k_fx[IVAS_BIQUAD_FILT_LEN << 1] = { /* Q30 */
+ // 0x53e1a, 0x29f0d, 0x40000000, 0x824f6000, 0x3dbb1c80, 0x29f0d
+ 0x29F0D, 0x53E1A, 0x29F0D, 0x40000000, 0x824F5FC3, 0x3DBB1C71
+};
+
+const Word32 ivas_lpf_2_butter_48k_fx[IVAS_BIQUAD_FILT_LEN << 1] = { /* Q30 */
+ 0x12c07, 0x2580d, 0x12c07, 0x40000000, 0x818a4580, 0x3e7a6a80
+};
+
+const Word32 ivas_lfe_window_coeff_48k_fx[IVAS_LFE_FADE_LEN_48K] = {
+ 0x0003a373, 0x000608f6, 0x000888a7, 0x000b3e1b, 0x000e34f1, 0x001174a2, 0x00150328, 0x0018e5e1, 0x001d21eb, 0x0021bc4d, 0x0026ba09, 0x002c202f, 0x0031f3dc, 0x00383a43, 0x003ef8ad, 0x0046347b, 0x004df325, 0x00563a3f, 0x005f0f74, 0x00687888, 0x00727b59, 0x007d1ddb, 0x0088661c, 0x00945a41, 0x00a10087, 0x00ae5f3d, 0x00bc7ccd, 0x00cb5fb3, 0x00db0e7d, 0x00eb8fd0, 0x00fcea61, 0x010f24f8, 0x0122466a, 0x013655a0, 0x014b598e, 0x01615936, 0x01785ba8, 0x01906800, 0x01a9855e, 0x01c3baf0, 0x01df0fee, 0x01fb8b90, 0x02193514, 0x023813c4, 0x02582ee4, 0x02798db8, 0x029c378c, 0x02c033a4, 0x02e58944, 0x030c3fa8, 0x03345e0c, 0x035deba0, 0x0388ef8c, 0x03b570f0, 0x03e376dc, 0x04130858, 0x04442c58, 0x0476e9b8, 0x04ab4760, 0x04e14c00, 0x0518fe48, 0x055264c8, 0x058d8600, 0x05ca6850, 0x06091200, 0x06498930, 0x068bd3f0, 0x06cff830, 0x0715fba8, 0x075de408, 0x07a7b6c8, 0x07f37940, 0x084130a0, 0x0890e200, 0x08e29220, 0x093645c0, 0x098c0150, 0x09e3c940, 0x0a3da180, 0x0a998e30, 0x0af792e0, 0x0b57b320, 0x0bb9f240, 0x0c1e5360, 0x0c84d940, 0x0ced8690, 0x0d585dc0, 0x0dc560f0, 0x0e349200, 0x0ea5f2b0, 0x0f198450, 0x0f8f4820, 0x10073f00, 0x10816980, 0x10fdc840, 0x117c5b00, 0x11fd21e0, 0x12801c60, 0x130549a0, 0x138ca8c0, 0x14163880, 0x14a1f740, 0x152fe320, 0x15bffa00, 0x16523980, 0x16e69ee0, 0x177d2700, 0x1815cec0, 0x18b09260, 0x194d6e00, 0x19ec5d60, 0x1a8d5c20, 0x1b306580, 0x1bd57440, 0x1c7c8300, 0x1d258c40, 0x1dd08a00, 0x1e7d7600, 0x1f2c49a0, 0x1fdcfe20, 0x208f8c40, 0x2143ed00, 0x21fa1840, 0x22b20680, 0x236baf40, 0x24270a00, 0x24e40e00, 0x25a2b280, 0x2662ee00, 0x2724b700, 0x27e80400, 0x28acca80, 0x297300c0, 0x2a3a9c00, 0x2b039180, 0x2bcdd680, 0x2c995fc0, 0x2d6621c0, 0x2e341140, 0x2f032240, 0x2fd34900, 0x30a47900, 0x3176a640, 0x3249c440, 0x331dc600, 0x33f29f40, 0x34c842c0, 0x359ea340, 0x3675b3c0, 0x374d66c0, 0x3825af00, 0x38fe7ec0, 0x39d7c880, 0x3ab17e40, 0x3b8b9240, 0x3c65f6c0, 0x3d409d80, 0x3e1b7880, 0x3ef679c0, 0x3fd19340, 0x40acb680, 0x4187d580, 0x4262e280, 0x433dce80, 0x44188c00, 0x44f30c80, 0x45cd4180, 0x46a71e00, 0x47809300, 0x48599300, 0x49320f80, 0x4a09fb80, 0x4ae14880, 0x4bb7e900, 0x4c8dcf80, 0x4d62ee80, 0x4e373880, 0x4f0aa080, 0x4fdd1900, 0x50ae9600, 0x517f0980, 0x524e6780, 0x531ca380, 0x53e9b100, 0x54b58400, 0x55801080, 0x56494b00, 0x57112800, 0x57d79c00, 0x589c9c00, 0x59601d00, 0x5a221480, 0x5ae27880, 0x5ba13e00, 0x5c5e5c00, 0x5d19c880, 0x5dd37a80, 0x5e8b6800, 0x5f418980, 0x5ff5d580, 0x60a84480, 0x6158ce00, 0x62076a80, 0x62b41280, 0x635ebf80, 0x64076a80, 0x64ae0d00, 0x6552a100, 0x65f52080, 0x66958680, 0x6733cd00, 0x67cff000, 0x6869ea80, 0x6901b880, 0x69975600, 0x6a2abf80, 0x6abbf200, 0x6b4aea80, 0x6bd7a680, 0x6c622300, 0x6cea5f80, 0x6d705900, 0x6df40f00, 0x6e758080, 0x6ef4ac80, 0x6f719300, 0x6fec3380, 0x70648f00, 0x70daa580, 0x714e7880, 0x71c00880, 0x722f5780, 0x729c6700, 0x73073980, 0x736fd100, 0x73d62f80, 0x743a5900, 0x749c5080, 0x74fc1880, 0x7559b600, 0x75b52b80, 0x760e7e80, 0x7665b280, 0x76bacc80, 0x770dd180, 0x775ec600, 0x77adb000, 0x77fa9480, 0x78457900, 0x788e6400, 0x78d55b80, 0x791a6500, 0x795d8780, 0x799ec900, 0x79de3100, 0x7a1bc580, 0x7a578d80, 0x7a919100, 0x7ac9d600, 0x7b006500, 0x7b354400, 0x7b687b80, 0x7b9a1300, 0x7bca1180, 0x7bf87f80, 0x7c256400, 0x7c50c780, 0x7c7ab180, 0x7ca32a00, 0x7cca3900, 0x7cefe600, 0x7d143900, 0x7d373a80, 0x7d58f280, 0x7d796800, 0x7d98a380, 0x7db6ad00, 0x7dd38c80, 0x7def4900, 0x7e09eb00, 0x7e237a00, 0x7e3bfd80, 0x7e537d80, 0x7e6a0180, 0x7e7f9080, 0x7e943200, 0x7ea7ed80, 0x7ebaca00, 0x7ecccf00, 0x7ede0300, 0x7eee6d00, 0x7efe1400, 0x7f0cfe80, 0x7f1b3380, 0x7f28b900, 0x7f359500, 0x7f41ce80, 0x7f4d6b80, 0x7f587180, 0x7f62e680, 0x7f6cd000, 0x7f763400, 0x7f7f1780, 0x7f878080, 0x7f8f7380, 0x7f96f580, 0x7f9e0b80, 0x7fa4bb00, 0x7fab0780, 0x7fb0f600, 0x7fb68b00, 0x7fbbca00, 0x7fc0b800, 0x7fc55880, 0x7fc9af80, 0x7fcdc080, 0x7fd18f00, 0x7fd51e80, 0x7fd87280, 0x7fdb8d80, 0x7fde7380, 0x7fe12700, 0x7fe3aa80, 0x7fe60100, 0x7fe82d00, 0x7fea3180, 0x7fec1000, 0x7fedcb00, 0x7fef6500, 0x7ff0e000, 0x7ff23e00, 0x7ff38080, 0x7ff4a980, 0x7ff5ba80, 0x7ff6b580, 0x7ff79c00, 0x7ff86e80, 0x7ff92f80, 0x7ff9e000, 0x7ffa8100, 0x7ffb1380, 0x7ffb9880, 0x7ffc1180, 0x7ffc7f80, 0x7ffce300, 0x7ffd3c80, 0x7ffd8d80, 0x7ffdd680, 0x7ffe1880, 0x7ffe5300, 0x7ffe8800, 0x7ffeb700, 0x7ffee100, 0x7fff0600, 0x7fff2700, 0x7fff4480, 0x7fff5e80, 0x7fff7500, 0x7fff8900, 0x7fff9a80, 0x7fffaa00, 0x7fffb780, 0x7fffc300, 0x7fffcd00, 0x7fffd580, 0x7fffdc80, 0x7fffe300, 0x7fffe880, 0x7fffec80, 0x7ffff080, 0x7ffff380, 0x7ffff680, 0x7ffff880, 0x7ffffa00, 0x7ffffb80, 0x7ffffc80, 0x7ffffd80, 0x7ffffe80, 0x7fffff00, 0x7fffff00, 0x7fffff80, 0x7fffff80, 0x7fffffff, 0x7fffffff
+};
+
+const Word32 ivas_lfe_window_coeff_32k_fx[IVAS_LFE_FADE_LEN_32K] = {
+ 0x000474c9, 0x0007fdfd, 0x000c0272, 0x0010a35b, 0x0015f4ae, 0x001c079e, 0x0022ecc2, 0x002ab4c6, 0x003370ac, 0x003d31e5, 0x00480a5f, 0x00540c87, 0x00614b4e, 0x006fda25, 0x007fccfb, 0x0091383a, 0x00a430c2, 0x00b8cbe7, 0x00cf1f67, 0x00e74167, 0x0101486c, 0x011d4b52, 0x013b614e, 0x015ba1d8, 0x017e24ae, 0x01a301c8, 0x01ca514e, 0x01f42b90, 0x0220a900, 0x024fe224, 0x0281ef88, 0x02b6e9c0, 0x02eee954, 0x032a06b4, 0x03685a34, 0x03a9fc00, 0x03ef0408, 0x043789f8, 0x0483a538, 0x04d36cd0, 0x0526f760, 0x057e5b20, 0x05d9adc0, 0x06390470, 0x069c73c0, 0x07040fa8, 0x076feb68, 0x07e01990, 0x0854abe0, 0x08cdb350, 0x094b4000, 0x09cd6120, 0x0a5424d0, 0x0adf9870, 0x0b6fc830, 0x0c04bf20, 0x0c9e8760, 0x0d3d29c0, 0x0de0ade0, 0x0e891a50, 0x0f367440, 0x0fe8bfa0, 0x109fff00, 0x115c33a0, 0x121d5d80, 0x12e37b00, 0x13ae8960, 0x147e8440, 0x155365c0, 0x162d26c0, 0x170bbe80, 0x17ef22e0, 0x18d74820, 0x19c42100, 0x1ab59f20, 0x1babb200, 0x1ca64840, 0x1da54e80, 0x1ea8b080, 0x1fb057e0, 0x20bc2d80, 0x21cc1800, 0x22dffd40, 0x23f7c1c0, 0x25134800, 0x26327200, 0x27552000, 0x287b30c0, 0x29a48280, 0x2ad0f180, 0x2c005940, 0x2d329440, 0x2e677c00, 0x2f9ee880, 0x30d8b100, 0x3214ac40, 0x3352afc0, 0x34929040, 0x35d421c0, 0x37173780, 0x385ba480, 0x39a13b00, 0x3ae7cc40, 0x3c2f2a00, 0x3d7724c0, 0x3ebf8d80, 0x40083400, 0x4150e980, 0x42997d80, 0x43e1c000, 0x45298180, 0x46709200, 0x47b6c280, 0x48fbe380, 0x4a3fc600, 0x4b823b80, 0x4cc31600, 0x4e022800, 0x4f3f4500, 0x507a4080, 0x51b2ee80, 0x52e92580, 0x541cba80, 0x554d8580, 0x567b5e00, 0x57a61d80, 0x58cd9e00, 0x59f1bb80, 0x5b125200, 0x5c2f3f00, 0x5d486280, 0x5e5d9d00, 0x5f6ecf80, 0x607bde00, 0x6184ad00, 0x62892280, 0x63892680, 0x6484a280, 0x657b8100, 0x666daf00, 0x675b1980, 0x6843b100, 0x69276680, 0x6a062d00, 0x6adff980, 0x6bb4c180, 0x6c847d80, 0x6d4f2680, 0x6e14b800, 0x6ed52e80, 0x6f908900, 0x7046c680, 0x70f7e880, 0x71a3f300, 0x724aea00, 0x72ecd300, 0x7389b680, 0x74219c80, 0x74b48f80, 0x75429b80, 0x75cbcc80, 0x76503100, 0x76cfd800, 0x774ad280, 0x77c13180, 0x78330780, 0x78a06880, 0x79096800, 0x796e1b80, 0x79ce9980, 0x7a2af880, 0x7a835000, 0x7ad7b800, 0x7b284980, 0x7b751c80, 0x7bbe4c00, 0x7c03f080, 0x7c462580, 0x7c850480, 0x7cc0a880, 0x7cf92c00, 0x7d2eaa80, 0x7d613e00, 0x7d910180, 0x7dbe0f80, 0x7de88300, 0x7e107600, 0x7e360300, 0x7e594280, 0x7e7a4f80, 0x7e994200, 0x7eb63280, 0x7ed13a00, 0x7eea6f00, 0x7f01e980, 0x7f17c000, 0x7f2c0800, 0x7f3ed780, 0x7f504280, 0x7f605d80, 0x7f6f3c00, 0x7f7cf100, 0x7f898e00, 0x7f952500, 0x7f9fc600, 0x7fa98200, 0x7fb26800, 0x7fba8680, 0x7fc1eb80, 0x7fc8a400, 0x7fcebd80, 0x7fd44380, 0x7fd94100, 0x7fddc180, 0x7fe1ce80, 0x7fe57180, 0x7fe8b400, 0x7feb9d80, 0x7fee3680, 0x7ff08600, 0x7ff29280, 0x7ff46300, 0x7ff5fc80, 0x7ff76500, 0x7ff8a180, 0x7ff9b600, 0x7ffaa780, 0x7ffb7900, 0x7ffc2e80, 0x7ffccb80, 0x7ffd5200, 0x7ffdc580, 0x7ffe2800, 0x7ffe7b80, 0x7ffec200, 0x7ffefd80, 0x7fff2f00, 0x7fff5880, 0x7fff7a80, 0x7fff9680, 0x7fffad80, 0x7fffc000, 0x7fffcf00, 0x7fffdb00, 0x7fffe480, 0x7fffeb80, 0x7ffff180, 0x7ffff580, 0x7ffff900, 0x7ffffb00, 0x7ffffd00, 0x7ffffe00, 0x7fffff00, 0x7fffff80, 0x7fffffff, 0x7fffffff
+};
+
+const Word32 ivas_lfe_window_coeff_16k_fx[IVAS_LFE_FADE_LEN_16K] = {
+ 0x00064d50, 0x000e283c, 0x0018b753, 0x00267552, 0x0037e397, 0x004d8c2b, 0x006801d2, 0x0087dfb9, 0x00adc8fc, 0x00da680b, 0x010e6df8, 0x014a91a0, 0x018f8ecc, 0x01de252a, 0x02371734, 0x029b2908, 0x030b1f1c, 0x0387bd00, 0x0411c3e8, 0x04a9f148, 0x0550fd60, 0x060799b0, 0x06ce6f88, 0x07a61e78, 0x088f3ad0, 0x098a4c30, 0x0a97cc00, 0x0bb82430, 0x0cebadd0, 0x0e32afe0, 0x0f8d5df0, 0x10fbd760, 0x127e2680, 0x14143f40, 0x15bdff00, 0x177b2bc0, 0x194b7440, 0x1b2e6f00, 0x1d239ae0, 0x1f2a5ee0, 0x21420ac0, 0x2369d700, 0x25a0e640, 0x27e64500, 0x2a38ebc0, 0x2c97bfc0, 0x2f019400, 0x31752b00, 0x33f13800, 0x36746180, 0x38fd42c0, 0x3b8a6cc0, 0x3e1a6a80, 0x40abc080, 0x433cf080, 0x45cc7c80, 0x4858e600, 0x4ae0b400, 0x4d627280, 0x4fdcb500, 0x524e1b00, 0x54b54e80, 0x57110880, 0x59601300, 0x5ba14800, 0x5dd39780, 0x5ff60500, 0x6207aa80, 0x6407ba80, 0x65f57e80, 0x67d05b00, 0x6997cc80, 0x6b4b6b00, 0x6ceae880, 0x6e761080, 0x6fecc980, 0x714f1280, 0x729d0480, 0x73d6ce80, 0x74fcb800, 0x760f1d80, 0x770e6e80, 0x77fb2f00, 0x78d5f280, 0x799f5b80, 0x7a581b80, 0x7b00ec80, 0x7b9a9480, 0x7c25df80, 0x7ca39e80, 0x7d14a680, 0x7d79ce00, 0x7dd3eb00, 0x7e23d180, 0x7e6a5180, 0x7ea83680, 0x7ede4580, 0x7f0d3a80, 0x7f35cb00, 0x7f58a180, 0x7f765e80, 0x7f8f9880, 0x7fa4db80, 0x7fb6a700, 0x7fc57100, 0x7fd1a400, 0x7fdb9f80, 0x7fe3b980, 0x7fea3e00, 0x7fef6f80, 0x7ff38900, 0x7ff6bc80, 0x7ff93500, 0x7ffb1780, 0x7ffc8300, 0x7ffd9080, 0x7ffe5500, 0x7ffee280, 0x7fff4580, 0x7fff8a00, 0x7fffb800, 0x7fffd580, 0x7fffe880, 0x7ffff400, 0x7ffffa00, 0x7ffffd80, 0x7fffff00, 0x7fffffff
+};
+
+// Q31
+const UWord32 d_hamm_lfe_plc_fx[LFE_PLC_LENANA / 2] = {
+ 171798691, 172140039, 173163845, 174869403, 177255533, 180320587, 184062447, 188478526,
+ 193565772, 199320670, 205739242, 212817053, 220549212, 228930373, 237954746, 247616094,
+ 257907739, 268822570, 280353042, 292491188, 305228618, 318556530, 332465713, 346946555,
+ 361989047, 377582794, 393717019, 410380572, 427561937, 445249239, 463430255, 482092421,
+ 501222838, 520808286, 540835229, 561289828, 582157945, 603425159, 625076772, 647097821,
+ 669473086, 692187106, 715224182, 738568392, 762203605, 786113486, 810281510, 834690976,
+ 859325014, 884166600, 909198565, 934403610, 959764316, 985263157, 1010882509, 1036604668,
+ 1062411858, 1088286242, 1114209939, 1140165034, 1166133589, 1192097656, 1218039293, 1243940572,
+ 1269783591, 1295550491, 1321223465, 1346784770, 1372216740, 1397501800, 1422622476, 1447561406,
+ 1472301355, 1496825225, 1521116069, 1545157098, 1568931699, 1592423440, 1615616087, 1638493611,
+ 1661040202, 1683240277, 1705078494, 1726539762, 1747609248, 1768272390, 1788514910, 1808322817,
+ 1827682422, 1846580346, 1865003529, 1882939237, 1900375077, 1917298998, 1933699304, 1949564660,
+ 1964884103, 1979647046, 1993843284, 2007463009, 2020496806, 2032935668, 2044771000, 2055994621,
+ 2066598775, 2076576133, 2085919801, 2094623320, 2102680676, 2110086301, 2116835076, 2122922337,
+ 2128343877, 2133095950, 2137175272, 2140579023, 2143304850, 2145350871, 2146715671, 2147398307
+};
+
+/*------------------------------------------------------------------------------------------*
+ * MDFT/iMDFT ROM tables
+ *------------------------------------------------------------------------------------------*/
+
+const Word32 ivas_mdft_coeff_cos_twid_960_fx[IVAS_960_PT_LEN + 1] = {
+ 2147483647,
+ 2147480832, 2147472128, 2147457792, 2147437696,
+ 2147411840, 2147380096, 2147342848, 2147299712,
+ 2147250816, 2147196160, 2147135872, 2147069696,
+ 2146997888, 2146920192, 2146836864, 2146747776,
+ 2146652928, 2146552320, 2146445952, 2146333824,
+ 2146216064, 2146092416, 2145963136, 2145827968,
+ 2145687168, 2145540608, 2145388288, 2145230208,
+ 2145066496, 2144896896, 2144721664, 2144540544,
+ 2144353792, 2144161280, 2143963008, 2143759104,
+ 2143549312, 2143333888, 2143112704, 2142885760,
+ 2142653056, 2142414592, 2142170496, 2141920512,
+ 2141664896, 2141403648, 2141136512, 2140863616,
+ 2140585088, 2140300800, 2140010752, 2139715072,
+ 2139413632, 2139106432, 2138793472, 2138474752,
+ 2138150400, 2137820288, 2137484544, 2137142912,
+ 2136795648, 2136442624, 2136083968, 2135719552,
+ 2135349376, 2134973440, 2134591872, 2134204544,
+ 2133811584, 2133412864, 2133008384, 2132598272,
+ 2132182400, 2131760896, 2131333632, 2130900608,
+ 2130461952, 2130017536, 2129567360, 2129111680,
+ 2128650112, 2128182912, 2127710080, 2127231488,
+ 2126747136, 2126257152, 2125761536, 2125260160,
+ 2124753152, 2124240384, 2123721984, 2123197824,
+ 2122668032, 2122132608, 2121591424, 2121044608,
+ 2120492032, 2119933824, 2119369984, 2118800384,
+ 2118225152, 2117644288, 2117057792, 2116465536,
+ 2115867648, 2115264128, 2114654848, 2114039936,
+ 2113419392, 2112793216, 2112161408, 2111523840,
+ 2110880640, 2110231808, 2109577344, 2108917248,
+ 2108251520, 2107580032, 2106903040, 2106220288,
+ 2105532032, 2104838016, 2104138496, 2103433216,
+ 2102722304, 2102005888, 2101283712, 2100556032,
+ 2099822592, 2099083648, 2098338944, 2097588736,
+ 2096832896, 2096071424, 2095304320, 2094531712,
+ 2093753344, 2092969472, 2092179968, 2091384832,
+ 2090584192, 2089777920, 2088966016, 2088148480,
+ 2087325440, 2086496768, 2085662464, 2084822656,
+ 2083977216, 2083126272, 2082269696, 2081407488,
+ 2080539776, 2079666560, 2078787712, 2077903232,
+ 2077013248, 2076117632, 2075216640, 2074309888,
+ 2073397760, 2072479872, 2071556608, 2070627712,
+ 2069693312, 2068753408, 2067807872, 2066856832,
+ 2065900288, 2064938240, 2063970560, 2062997504,
+ 2062018816, 2061034624, 2060044928, 2059049728,
+ 2058049024, 2057042688, 2056030976, 2055013760,
+ 2053990912, 2052962688, 2051928960, 2050889728,
+ 2049844992, 2048794752, 2047739008, 2046677888,
+ 2045611136, 2044539008, 2043461376, 2042378368,
+ 2041289728, 2040195712, 2039096192, 2037991296,
+ 2036880896, 2035764992, 2034643712, 2033516928,
+ 2032384768, 2031247104, 2030104064, 2028955520,
+ 2027801600, 2026642176, 2025477376, 2024307200,
+ 2023131520, 2021950464, 2020764032, 2019572096,
+ 2018374784, 2017172096, 2015964032, 2014750592,
+ 2013531648, 2012307328, 2011077760, 2009842688,
+ 2008602240, 2007356416, 2006105216, 2004848640,
+ 2003586816, 2002319488, 2001046912, 1999768832,
+ 1998485504, 1997196800, 1995902720, 1994603264,
+ 1993298560, 1991988480, 1990673152, 1989352320,
+ 1988026240, 1986694912, 1985358208, 1984016128,
+ 1982668800, 1981316224, 1979958272, 1978595072,
+ 1977226496, 1975852672, 1974473472, 1973089152,
+ 1971699456, 1970304384, 1968904192, 1967498624,
+ 1966087808, 1964671872, 1963250560, 1961823872,
+ 1960392064, 1958955008, 1957512704, 1956065152,
+ 1954612352, 1953154304, 1951691136, 1950222592,
+ 1948748928, 1947270016, 1945785856, 1944296576,
+ 1942801920, 1941302272, 1939797248, 1938287104,
+ 1936771840, 1935251328, 1933725568, 1932194688,
+ 1930658688, 1929117440, 1927571072, 1926019584,
+ 1924462848, 1922900992, 1921334016, 1919761920,
+ 1918184576, 1916602112, 1915014656, 1913421952,
+ 1911824128, 1910221184, 1908613248, 1907000064,
+ 1905381760, 1903758464, 1902130048, 1900496512,
+ 1898857856, 1897214208, 1895565312, 1893911552,
+ 1892252544, 1890588544, 1888919552, 1887245440,
+ 1885566208, 1883881984, 1882192768, 1880498432,
+ 1878799104, 1877094656, 1875385344, 1873670912,
+ 1871951488, 1870227072, 1868497536, 1866763136,
+ 1865023744, 1863279232, 1861529856, 1859775360,
+ 1858016000, 1856251648, 1854482304, 1852707968,
+ 1850928768, 1849144448, 1847355392, 1845561216,
+ 1843762176, 1841958144, 1840149248, 1838335360,
+ 1836516608, 1834692864, 1832864384, 1831030784,
+ 1829192448, 1827349120, 1825500928, 1823647744,
+ 1821789824, 1819927040, 1818059264, 1816186624,
+ 1814309248, 1812426880, 1810539776, 1808647680,
+ 1806750848, 1804849152, 1802942720, 1801031296,
+ 1799115136, 1797194112, 1795268352, 1793337728,
+ 1791402368, 1789462144, 1787517184, 1785567360,
+ 1783612800, 1781653504, 1779689344, 1777720576,
+ 1775746944, 1773768576, 1771785344, 1769797504,
+ 1767804928, 1765807616, 1763805440, 1761798656,
+ 1759787136, 1757771008, 1755750016, 1753724416,
+ 1751694080, 1749659008, 1747619328, 1745574912,
+ 1743525888, 1741472128, 1739413760, 1737350784,
+ 1735283072, 1733210752, 1731133696, 1729052160,
+ 1726965888, 1724875008, 1722779520, 1720679424,
+ 1718574720, 1716465408, 1714351616, 1712233088,
+ 1710109952, 1707982336, 1705850112, 1703713280,
+ 1701571968, 1699426048, 1697275648, 1695120640,
+ 1692961024, 1690796928, 1688628352, 1686455296,
+ 1684277632, 1682095488, 1679908864, 1677717632,
+ 1675522048, 1673321984, 1671117312, 1668908288,
+ 1666694656, 1664476672, 1662254208, 1660027264,
+ 1657795968, 1655560192, 1653319936, 1651075200,
+ 1648826240, 1646572672, 1644314752, 1642052480,
+ 1639785728, 1637514752, 1635239168, 1632959360,
+ 1630675200, 1628386560, 1626093568, 1623796352,
+ 1621494656, 1619188736, 1616878336, 1614563712,
+ 1612244736, 1609921408, 1607593856, 1605261952,
+ 1602925696, 1600585216, 1598240384, 1595891328,
+ 1593538048, 1591180416, 1588818560, 1586452480,
+ 1584082048, 1581707520, 1579328640, 1576945536,
+ 1574558336, 1572166784, 1569771136, 1567371136,
+ 1564967040, 1562558720, 1560146304, 1557729664,
+ 1555308800, 1552883712, 1550454656, 1548021248,
+ 1545583872, 1543142272, 1540696576, 1538246656,
+ 1535792768, 1533334656, 1530872448, 1528406272,
+ 1525935872, 1523461376, 1520982912, 1518500224,
+ 1516013568, 1513522816, 1511028096, 1508529280,
+ 1506026368, 1503519488, 1501008512, 1498493568,
+ 1495974656, 1493451648, 1490924672, 1488393728,
+ 1485858816, 1483319936, 1480777088, 1478230144,
+ 1475679360, 1473124608, 1470565888, 1468003328,
+ 1465436672, 1462866176, 1460291840, 1457713536,
+ 1455131264, 1452545152, 1449955200, 1447361280,
+ 1444763520, 1442161920, 1439556352, 1436947072,
+ 1434333824, 1431716864, 1429095936, 1426471296,
+ 1423842688, 1421210368, 1418574336, 1415934336,
+ 1413290624, 1410643200, 1407991808, 1405336832,
+ 1402678016, 1400015488, 1397349120, 1394679040,
+ 1392005248, 1389327744, 1386646528, 1383961600,
+ 1381272960, 1378580608, 1375884544, 1373184768,
+ 1370481408, 1367774336, 1365063552, 1362349184,
+ 1359631232, 1356909440, 1354184192, 1351455232,
+ 1348722688, 1345986560, 1343246720, 1340503424,
+ 1337756416, 1335005952, 1332251776, 1329494144,
+ 1326732928, 1323968128, 1321199744, 1318427904,
+ 1315652480, 1312873600, 1310091136, 1307305216,
+ 1304515712, 1301722880, 1298926464, 1296126464,
+ 1293323136, 1290516352, 1287705984, 1284892288,
+ 1282075136, 1279254528, 1276430464, 1273603072,
+ 1270772224, 1267937920, 1265100288, 1262259200,
+ 1259414784, 1256567040, 1253715840, 1250861312,
+ 1248003456, 1245142272, 1242277760, 1239409920,
+ 1236538624, 1233664128, 1230786432, 1227905280,
+ 1225020928, 1222133248, 1219242368, 1216348160,
+ 1213450624, 1210550016, 1207646080, 1204738816,
+ 1201828480, 1198914816, 1195998080, 1193078016,
+ 1190154752, 1187228416, 1184298752, 1181366016,
+ 1178430080, 1175491072, 1172548736, 1169603456,
+ 1166654976, 1163703296, 1160748544, 1157790720,
+ 1154829824, 1151865728, 1148898688, 1145928448,
+ 1142955136, 1139978880, 1136999552, 1134017024,
+ 1131031680, 1128043136, 1125051648, 1122057088,
+ 1119059584, 1116059136, 1113055616, 1110049152,
+ 1107039616, 1104027264, 1101011840, 1097993600,
+ 1094972288, 1091948032, 1088920960, 1085890944,
+ 1082857984, 1079822208, 1076783488, 1073741824,
+ 1070697344, 1067649984, 1064599744, 1061546688,
+ 1058490816, 1055432064, 1052370496, 1049306112,
+ 1046238912, 1043168960, 1040096192, 1037020608,
+ 1033942272, 1030861120, 1027777280, 1024690624,
+ 1021601280, 1018509184, 1015414336, 1012316800,
+ 1009216512, 1006113536, 1003007936, 999899584,
+ 996788544, 993674880, 990558528, 987439552,
+ 984317888, 981193600, 978066688, 974937152,
+ 971805056, 968670336, 965532992, 962393088,
+ 959250560, 956105536, 952957888, 949807744,
+ 946655040, 943499776, 940342016, 937181696,
+ 934018880, 930853632, 927685824, 924515520,
+ 921342784, 918167552, 914989888, 911809792,
+ 908627200, 905442176, 902254784, 899064960,
+ 895872704, 892678080, 889481024, 886281600,
+ 883079808, 879875648, 876669120, 873460288,
+ 870249088, 867035584, 863819712, 860601536,
+ 857381120, 854158336, 850933312, 847705984,
+ 844476352, 841244544, 838010432, 834774080,
+ 831535488, 828294656, 825051648, 821806400,
+ 818558976, 815309376, 812057536, 808803520,
+ 805547392, 802289088, 799028608, 795766016,
+ 792501312, 789234496, 785965504, 782694464,
+ 779421248, 776146048, 772868736, 769589312,
+ 766307840, 763024320, 759738816, 756451200,
+ 753161600, 749870016, 746576320, 743280704,
+ 739983104, 736683520, 733381952, 730078400,
+ 726772864, 723465472, 720156096, 716844800,
+ 713531520, 710216384, 706899392, 703580480,
+ 700259648, 696936960, 693612416, 690286016,
+ 686957760, 683627648, 680295744, 676961984,
+ 673626432, 670289024, 666949888, 663608960,
+ 660266240, 656921728, 653575488, 650227520,
+ 646877760, 643526272, 640173120, 636818176,
+ 633461568, 630103296, 626743296, 623381568,
+ 620018240, 616653248, 613286592, 609918336,
+ 606548352, 603176832, 599803648, 596428864,
+ 593052544, 589674560, 586295040, 582913920,
+ 579531264, 576147072, 572761280, 569374016,
+ 565985152, 562594816, 559203008, 555809664,
+ 552414848, 549018560, 545620736, 542221504,
+ 538820864, 535418720, 532015168, 528610176,
+ 525203776, 521795968, 518386752, 514976160,
+ 511564192, 508150848, 504736160, 501320096,
+ 497902720, 494483968, 491063936, 487642560,
+ 484219904, 480795936, 477370656, 473944128,
+ 470516320, 467087264, 463656960, 460225408,
+ 456792608, 453358592, 449923392, 446486944,
+ 443049344, 439610528, 436170528, 432729376,
+ 429287072, 425843616, 422399008, 418953280,
+ 415506432, 412058464, 408609376, 405159232,
+ 401707968, 398255648, 394802272, 391347808,
+ 387892320, 384435776, 380978208, 377519648,
+ 374060032, 370599456, 367137856, 363675296,
+ 360211744, 356747232, 353281760, 349815360,
+ 346348032, 342879744, 339410560, 335940448,
+ 332469472, 328997568, 325524800, 322051168,
+ 318576640, 315101280, 311625088, 308148064,
+ 304670208, 301191520, 297712032, 294231776,
+ 290750688, 287268864, 283786240, 280302848,
+ 276818752, 273333888, 269848288, 266361952,
+ 262874928, 259387184, 255898752, 252409632,
+ 248919840, 245429392, 241938272, 238446512,
+ 234954112, 231461072, 227967424, 224473168,
+ 220978304, 217482848, 213986816, 210490208,
+ 206993040, 203495312, 199997040, 196498224,
+ 192998896, 189499040, 185998688, 182497840,
+ 178996496, 175494672, 171992384, 168489632,
+ 164986416, 161482768, 157978704, 154474192,
+ 150969280, 147463968, 143958256, 140452144,
+ 136945680, 133438832, 129931632, 126424088,
+ 122916200, 119407992, 115899456, 112390608,
+ 108881464, 105372032, 101862312, 98352320,
+ 94842064, 91331552, 87820800, 84309816,
+ 80798600, 77287168, 73775528, 70263696,
+ 66751672, 63239472, 59727100, 56214568,
+ 52701888, 49189064, 45676112, 42163032,
+ 38649844, 35136552, 31623164, 28109692,
+ 24596146, 21082532, 17568864, 14055147,
+ 10541393, 7027612, 3513810, 0
+};
+
+const Word32 ivas_mdft_coeff_cos_twid_640_fx[IVAS_640_PT_LEN + 1] = {
+ 2147483647,
+ 2147477120, 2147457792, 2147425408, 2147380096,
+ 2147321984, 2147250816, 2147166720, 2147069696,
+ 2146959744, 2146836864, 2146701056, 2146552320,
+ 2146390656, 2146216064, 2146028416, 2145827968,
+ 2145614592, 2145388288, 2145149056, 2144896896,
+ 2144631808, 2144353792, 2144062848, 2143759104,
+ 2143442304, 2143112704, 2142770048, 2142414592,
+ 2142046208, 2141664896, 2141270784, 2140863616,
+ 2140443648, 2140010752, 2139565056, 2139106432,
+ 2138634880, 2138150400, 2137653120, 2137142912,
+ 2136619904, 2136083968, 2135535104, 2134973440,
+ 2134398976, 2133811584, 2133211392, 2132598272,
+ 2131972352, 2131333632, 2130681984, 2130017536,
+ 2129340288, 2128650112, 2127947264, 2127231488,
+ 2126502912, 2125761536, 2125007360, 2124240384,
+ 2123460608, 2122668032, 2121862656, 2121044608,
+ 2120213632, 2119369984, 2118513536, 2117644288,
+ 2116762368, 2115867648, 2114960128, 2114039936,
+ 2113107072, 2112161408, 2111202944, 2110231808,
+ 2109248000, 2108251520, 2107242240, 2106220288,
+ 2105185792, 2104138496, 2103078528, 2102005888,
+ 2100920576, 2099822592, 2098712064, 2097588736,
+ 2096452864, 2095304320, 2094143232, 2092969472,
+ 2091783168, 2090584192, 2089372672, 2088148480,
+ 2086911744, 2085662464, 2084400640, 2083126272,
+ 2081839360, 2080539776, 2079227776, 2077903232,
+ 2076566144, 2075216640, 2073854464, 2072479872,
+ 2071092864, 2069693312, 2068281344, 2066856832,
+ 2065420032, 2063970560, 2062508800, 2061034624,
+ 2059548032, 2058049024, 2056537600, 2055013760,
+ 2053477504, 2051928960, 2050368000, 2048794752,
+ 2047209088, 2045611136, 2044000896, 2042378368,
+ 2040743424, 2039096192, 2037436800, 2035764992,
+ 2034081024, 2032384768, 2030676224, 2028955520,
+ 2027222528, 2025477376, 2023720064, 2021950464,
+ 2020168704, 2018374784, 2016568704, 2014750592,
+ 2012920192, 2011077760, 2009223168, 2007356416,
+ 2005477632, 2003586816, 2001683840, 1999768832,
+ 1997841792, 1995902720, 1993951616, 1991988480,
+ 1990013440, 1988026240, 1986027264, 1984016128,
+ 1981993216, 1979958272, 1977911424, 1975852672,
+ 1973782016, 1971699456, 1969604992, 1967498624,
+ 1965380480, 1963250560, 1961108736, 1958955008,
+ 1956789632, 1954612352, 1952423424, 1950222592,
+ 1948010112, 1945785856, 1943549952, 1941302272,
+ 1939042816, 1936771840, 1934489088, 1932194688,
+ 1929888768, 1927571072, 1925241856, 1922900992,
+ 1920548608, 1918184576, 1915809024, 1913421952,
+ 1911023360, 1908613248, 1906191616, 1903758464,
+ 1901313920, 1898857856, 1896390400, 1893911552,
+ 1891421184, 1888919552, 1886406400, 1883881984,
+ 1881346176, 1878799104, 1876240640, 1873670912,
+ 1871089920, 1868497536, 1865894016, 1863279232,
+ 1860653184, 1858016000, 1855367552, 1852707968,
+ 1850037248, 1847355392, 1844662272, 1841958144,
+ 1839242880, 1836516608, 1833779200, 1831030784,
+ 1828271360, 1825500928, 1822719360, 1819927040,
+ 1817123584, 1814309248, 1811483904, 1808647680,
+ 1805800704, 1802942720, 1800073856, 1797194112,
+ 1794303616, 1791402368, 1788490240, 1785567360,
+ 1782633728, 1779689344, 1776734336, 1773768576,
+ 1770792064, 1767804928, 1764807168, 1761798656,
+ 1758779648, 1755750016, 1752709760, 1749659008,
+ 1746597760, 1743525888, 1740443520, 1737350784,
+ 1734247424, 1731133696, 1728009600, 1724875008,
+ 1721730048, 1718574720, 1715409024, 1712233088,
+ 1709046784, 1705850112, 1702643200, 1699426048,
+ 1696198656, 1692961024, 1689713280, 1686455296,
+ 1683187072, 1679908864, 1676620416, 1673321984,
+ 1670013312, 1666694656, 1663366016, 1660027264,
+ 1656678656, 1653319936, 1649951232, 1646572672,
+ 1643184128, 1639785728, 1636377472, 1632959360,
+ 1629531392, 1626093568, 1622646016, 1619188736,
+ 1615721600, 1612244736, 1608758144, 1605261952,
+ 1601756032, 1598240384, 1594715264, 1591180416,
+ 1587636096, 1584082048, 1580518656, 1576945536,
+ 1573363072, 1569771136, 1566169600, 1562558720,
+ 1558938496, 1555308800, 1551669760, 1548021248,
+ 1544363648, 1540696576, 1537020288, 1533334656,
+ 1529639808, 1525935872, 1522222592, 1518500224,
+ 1514768768, 1511028096, 1507278336, 1503519488,
+ 1499751552, 1495974656, 1492188672, 1488393728,
+ 1484589824, 1480777088, 1476955264, 1473124608,
+ 1469285120, 1465436672, 1461579520, 1457713536,
+ 1453838720, 1449955200, 1446062848, 1442161920,
+ 1438252160, 1434333824, 1430406912, 1426471296,
+ 1422527104, 1418574336, 1414612992, 1410643200,
+ 1406664832, 1402678016, 1398682752, 1394679040,
+ 1390667008, 1386646528, 1382617728, 1378580608,
+ 1374535168, 1370481408, 1366419456, 1362349184,
+ 1358270848, 1354184192, 1350089472, 1345986560,
+ 1341875584, 1337756416, 1333629312, 1329494144,
+ 1325350912, 1321199744, 1317040640, 1312873600,
+ 1308698624, 1304515712, 1300325120, 1296126464,
+ 1291920128, 1287705984, 1283484160, 1279254528,
+ 1275017216, 1270772224, 1266519552, 1262259200,
+ 1257991296, 1253715840, 1249432832, 1245142272,
+ 1240844160, 1236538624, 1232225664, 1227905280,
+ 1223577472, 1219242368, 1214899840, 1210550016,
+ 1206192896, 1201828480, 1197456896, 1193078016,
+ 1188691968, 1184298752, 1179898496, 1175491072,
+ 1171076480, 1166654976, 1162226304, 1157790720,
+ 1153348224, 1148898688, 1144442240, 1139978880,
+ 1135508608, 1131031680, 1126547712, 1122057088,
+ 1117559680, 1113055616, 1108544768, 1104027264,
+ 1099503104, 1094972288, 1090434944, 1085890944,
+ 1081340416, 1076783488, 1072219968, 1067649984,
+ 1063073600, 1058490816, 1053901632, 1049306112,
+ 1044704320, 1040096192, 1035481792, 1030861120,
+ 1026234304, 1021601280, 1016962112, 1012316800,
+ 1007665408, 1003007936, 998344384, 993674880,
+ 988999360, 984317888, 979630464, 974937152,
+ 970238016, 965532992, 960822144, 956105536,
+ 951383104, 946655040, 941921216, 937181696,
+ 932436544, 927685824, 922929472, 918167552,
+ 913400128, 908627200, 903848768, 899064960,
+ 894275648, 889481024, 884681024, 879875648,
+ 875065024, 870249088, 865427968, 860601536,
+ 855769984, 850933312, 846091456, 841244544,
+ 836392512, 831535488, 826673472, 821806400,
+ 816934464, 812057536, 807175744, 802289088,
+ 797397632, 792501312, 787600256, 782694464,
+ 777783936, 772868736, 767948864, 763024320,
+ 758095232, 753161600, 748223424, 743280704,
+ 738333568, 733381952, 728425856, 723465472,
+ 718500672, 713531520, 708558144, 703580480,
+ 698598528, 693612416, 688622080, 683627648,
+ 678629056, 673626432, 668619712, 663608960,
+ 658594176, 653575488, 648552832, 643526272,
+ 638495872, 633461568, 628423488, 623381568,
+ 618335936, 613286592, 608233536, 603176832,
+ 598116480, 593052544, 587985024, 582913920,
+ 577839360, 572761280, 567679744, 562594816,
+ 557506496, 552414848, 547319808, 542221504,
+ 537119936, 532015168, 526907136, 521795968,
+ 516681632, 511564192, 506443680, 501320096,
+ 496193504, 491063936, 485931392, 480795936,
+ 475657568, 470516320, 465372256, 460225408,
+ 455075776, 449923392, 444768288, 439610528,
+ 434450112, 429287072, 424121440, 418953280,
+ 413782592, 408609376, 403433728, 398255648,
+ 393075168, 387892320, 382707136, 377519648,
+ 372329856, 367137856, 361943648, 356747232,
+ 351548672, 346348032, 341145280, 335940448,
+ 330733632, 325524800, 320314016, 315101280,
+ 309886688, 304670208, 299451872, 294231776,
+ 289009856, 283786240, 278560896, 273333888,
+ 268105200, 262874928, 257643056, 252409632,
+ 247174704, 241938272, 236700384, 231461072,
+ 226220368, 220978304, 215734912, 210490208,
+ 205244240, 199997040, 194748624, 189499040,
+ 184248320, 178996496, 173743584, 168489632,
+ 163234656, 157978704, 152721792, 147463968,
+ 142205248, 136945680, 131685280, 126424088,
+ 121162136, 115899456, 110636072, 105372032,
+ 100107344, 94842064, 89576208, 84309816,
+ 79042912, 73775528, 68507704, 63239472,
+ 57970852, 52701888, 47432604, 42163032,
+ 36893208, 31623164, 26352928, 21082532,
+ 15812011, 10541393, 5270713, 0
+};
+
+const Word32 ivas_mdft_coeff_cos_twid_320_fx[IVAS_320_PT_LEN + 1] = {
+ 2147483647,
+ 2147457792, 2147380096, 2147250816, 2147069696,
+ 2146836864, 2146552320, 2146216064, 2145827968,
+ 2145388288, 2144896896, 2144353792, 2143759104,
+ 2143112704, 2142414592, 2141664896, 2140863616,
+ 2140010752, 2139106432, 2138150400, 2137142912,
+ 2136083968, 2134973440, 2133811584, 2132598272,
+ 2131333632, 2130017536, 2128650112, 2127231488,
+ 2125761536, 2124240384, 2122668032, 2121044608,
+ 2119369984, 2117644288, 2115867648, 2114039936,
+ 2112161408, 2110231808, 2108251520, 2106220288,
+ 2104138496, 2102005888, 2099822592, 2097588736,
+ 2095304320, 2092969472, 2090584192, 2088148480,
+ 2085662464, 2083126272, 2080539776, 2077903232,
+ 2075216640, 2072479872, 2069693312, 2066856832,
+ 2063970560, 2061034624, 2058049024, 2055013760,
+ 2051928960, 2048794752, 2045611136, 2042378368,
+ 2039096192, 2035764992, 2032384768, 2028955520,
+ 2025477376, 2021950464, 2018374784, 2014750592,
+ 2011077760, 2007356416, 2003586816, 1999768832,
+ 1995902720, 1991988480, 1988026240, 1984016128,
+ 1979958272, 1975852672, 1971699456, 1967498624,
+ 1963250560, 1958955008, 1954612352, 1950222592,
+ 1945785856, 1941302272, 1936771840, 1932194688,
+ 1927571072, 1922900992, 1918184576, 1913421952,
+ 1908613248, 1903758464, 1898857856, 1893911552,
+ 1888919552, 1883881984, 1878799104, 1873670912,
+ 1868497536, 1863279232, 1858016000, 1852707968,
+ 1847355392, 1841958144, 1836516608, 1831030784,
+ 1825500928, 1819927040, 1814309248, 1808647680,
+ 1802942720, 1797194112, 1791402368, 1785567360,
+ 1779689344, 1773768576, 1767804928, 1761798656,
+ 1755750016, 1749659008, 1743525888, 1737350784,
+ 1731133696, 1724875008, 1718574720, 1712233088,
+ 1705850112, 1699426048, 1692961024, 1686455296,
+ 1679908864, 1673321984, 1666694656, 1660027264,
+ 1653319936, 1646572672, 1639785728, 1632959360,
+ 1626093568, 1619188736, 1612244736, 1605261952,
+ 1598240384, 1591180416, 1584082048, 1576945536,
+ 1569771136, 1562558720, 1555308800, 1548021248,
+ 1540696576, 1533334656, 1525935872, 1518500224,
+ 1511028096, 1503519488, 1495974656, 1488393728,
+ 1480777088, 1473124608, 1465436672, 1457713536,
+ 1449955200, 1442161920, 1434333824, 1426471296,
+ 1418574336, 1410643200, 1402678016, 1394679040,
+ 1386646528, 1378580608, 1370481408, 1362349184,
+ 1354184192, 1345986560, 1337756416, 1329494144,
+ 1321199744, 1312873600, 1304515712, 1296126464,
+ 1287705984, 1279254528, 1270772224, 1262259200,
+ 1253715840, 1245142272, 1236538624, 1227905280,
+ 1219242368, 1210550016, 1201828480, 1193078016,
+ 1184298752, 1175491072, 1166654976, 1157790720,
+ 1148898688, 1139978880, 1131031680, 1122057088,
+ 1113055616, 1104027264, 1094972288, 1085890944,
+ 1076783488, 1067649984, 1058490816, 1049306112,
+ 1040096192, 1030861120, 1021601280, 1012316800,
+ 1003007936, 993674880, 984317888, 974937152,
+ 965532992, 956105536, 946655040, 937181696,
+ 927685824, 918167552, 908627200, 899064960,
+ 889481024, 879875648, 870249088, 860601536,
+ 850933312, 841244544, 831535488, 821806400,
+ 812057536, 802289088, 792501312, 782694464,
+ 772868736, 763024320, 753161600, 743280704,
+ 733381952, 723465472, 713531520, 703580480,
+ 693612416, 683627648, 673626432, 663608960,
+ 653575488, 643526272, 633461568, 623381568,
+ 613286592, 603176832, 593052544, 582913920,
+ 572761280, 562594816, 552414848, 542221504,
+ 532015168, 521795968, 511564192, 501320096,
+ 491063936, 480795936, 470516320, 460225408,
+ 449923392, 439610528, 429287072, 418953280,
+ 408609376, 398255648, 387892320, 377519648,
+ 367137856, 356747232, 346348032, 335940448,
+ 325524800, 315101280, 304670208, 294231776,
+ 283786240, 273333888, 262874928, 252409632,
+ 241938272, 231461072, 220978304, 210490208,
+ 199997040, 189499040, 178996496, 168489632,
+ 157978704, 147463968, 136945680, 126424088,
+ 115899456, 105372032, 94842064, 84309816,
+ 73775528, 63239472, 52701888, 42163032,
+ 31623164, 21082532, 10541393, 0
+};
+
+const Word32 ivas_mdft_coeff_cos_twid_240_fx[IVAS_240_PT_LEN + 1] = {
+ 2147483647,
+ 2147437696, 2147299712, 2147069696, 2146747776,
+ 2146333824, 2145827968, 2145230208, 2144540544,
+ 2143759104, 2142885760, 2141920512, 2140863616,
+ 2139715072, 2138474752, 2137142912, 2135719552,
+ 2134204544, 2132598272, 2130900608, 2129111680,
+ 2127231488, 2125260160, 2123197824, 2121044608,
+ 2118800384, 2116465536, 2114039936, 2111523840,
+ 2108917248, 2106220288, 2103433216, 2100556032,
+ 2097588736, 2094531712, 2091384832, 2088148480,
+ 2084822656, 2081407488, 2077903232, 2074309888,
+ 2070627712, 2066856832, 2062997504, 2059049728,
+ 2055013760, 2050889728, 2046677888, 2042378368,
+ 2037991296, 2033516928, 2028955520, 2024307200,
+ 2019572096, 2014750592, 2009842688, 2004848640,
+ 1999768832, 1994603264, 1989352320, 1984016128,
+ 1978595072, 1973089152, 1967498624, 1961823872,
+ 1956065152, 1950222592, 1944296576, 1938287104,
+ 1932194688, 1926019584, 1919761920, 1913421952,
+ 1907000064, 1900496512, 1893911552, 1887245440,
+ 1880498432, 1873670912, 1866763136, 1859775360,
+ 1852707968, 1845561216, 1838335360, 1831030784,
+ 1823647744, 1816186624, 1808647680, 1801031296,
+ 1793337728, 1785567360, 1777720576, 1769797504,
+ 1761798656, 1753724416, 1745574912, 1737350784,
+ 1729052160, 1720679424, 1712233088, 1703713280,
+ 1695120640, 1686455296, 1677717632, 1668908288,
+ 1660027264, 1651075200, 1642052480, 1632959360,
+ 1623796352, 1614563712, 1605261952, 1595891328,
+ 1586452480, 1576945536, 1567371136, 1557729664,
+ 1548021248, 1538246656, 1528406272, 1518500224,
+ 1508529280, 1498493568, 1488393728, 1478230144,
+ 1468003328, 1457713536, 1447361280, 1436947072,
+ 1426471296, 1415934336, 1405336832, 1394679040,
+ 1383961600, 1373184768, 1362349184, 1351455232,
+ 1340503424, 1329494144, 1318427904, 1307305216,
+ 1296126464, 1284892288, 1273603072, 1262259200,
+ 1250861312, 1239409920, 1227905280, 1216348160,
+ 1204738816, 1193078016, 1181366016, 1169603456,
+ 1157790720, 1145928448, 1134017024, 1122057088,
+ 1110049152, 1097993600, 1085890944, 1073741824,
+ 1061546688, 1049306112, 1037020608, 1024690624,
+ 1012316800, 999899584, 987439552, 974937152,
+ 962393088, 949807744, 937181696, 924515520,
+ 911809792, 899064960, 886281600, 873460288,
+ 860601536, 847705984, 834774080, 821806400,
+ 808803520, 795766016, 782694464, 769589312,
+ 756451200, 743280704, 730078400, 716844800,
+ 703580480, 690286016, 676961984, 663608960,
+ 650227520, 636818176, 623381568, 609918336,
+ 596428864, 582913920, 569374016, 555809664,
+ 542221504, 528610176, 514976160, 501320096,
+ 487642560, 473944128, 460225408, 446486944,
+ 432729376, 418953280, 405159232, 391347808,
+ 377519648, 363675296, 349815360, 335940448,
+ 322051168, 308148064, 294231776, 280302848,
+ 266361952, 252409632, 238446512, 224473168,
+ 210490208, 196498224, 182497840, 168489632,
+ 154474192, 140452144, 126424088, 112390608,
+ 98352320, 84309816, 70263696, 56214568,
+ 42163032, 28109692, 14055147, 0
+};
+
+const Word32 ivas_mdft_coeff_cos_twid_160_fx[IVAS_160_PT_LEN + 1] = {
+ 2147483647,
+ 2147380096, 2147069696, 2146552320, 2145827968,
+ 2144896896, 2143759104, 2142414592, 2140863616,
+ 2139106432, 2137142912, 2134973440, 2132598272,
+ 2130017536, 2127231488, 2124240384, 2121044608,
+ 2117644288, 2114039936, 2110231808, 2106220288,
+ 2102005888, 2097588736, 2092969472, 2088148480,
+ 2083126272, 2077903232, 2072479872, 2066856832,
+ 2061034624, 2055013760, 2048794752, 2042378368,
+ 2035764992, 2028955520, 2021950464, 2014750592,
+ 2007356416, 1999768832, 1991988480, 1984016128,
+ 1975852672, 1967498624, 1958955008, 1950222592,
+ 1941302272, 1932194688, 1922900992, 1913421952,
+ 1903758464, 1893911552, 1883881984, 1873670912,
+ 1863279232, 1852707968, 1841958144, 1831030784,
+ 1819927040, 1808647680, 1797194112, 1785567360,
+ 1773768576, 1761798656, 1749659008, 1737350784,
+ 1724875008, 1712233088, 1699426048, 1686455296,
+ 1673321984, 1660027264, 1646572672, 1632959360,
+ 1619188736, 1605261952, 1591180416, 1576945536,
+ 1562558720, 1548021248, 1533334656, 1518500224,
+ 1503519488, 1488393728, 1473124608, 1457713536,
+ 1442161920, 1426471296, 1410643200, 1394679040,
+ 1378580608, 1362349184, 1345986560, 1329494144,
+ 1312873600, 1296126464, 1279254528, 1262259200,
+ 1245142272, 1227905280, 1210550016, 1193078016,
+ 1175491072, 1157790720, 1139978880, 1122057088,
+ 1104027264, 1085890944, 1067649984, 1049306112,
+ 1030861120, 1012316800, 993674880, 974937152,
+ 956105536, 937181696, 918167552, 899064960,
+ 879875648, 860601536, 841244544, 821806400,
+ 802289088, 782694464, 763024320, 743280704,
+ 723465472, 703580480, 683627648, 663608960,
+ 643526272, 623381568, 603176832, 582913920,
+ 562594816, 542221504, 521795968, 501320096,
+ 480795936, 460225408, 439610528, 418953280,
+ 398255648, 377519648, 356747232, 335940448,
+ 315101280, 294231776, 273333888, 252409632,
+ 231461072, 210490208, 189499040, 168489632,
+ 147463968, 126424088, 105372032, 84309816,
+ 63239472, 42163032, 21082532, 0
+};
+
+const Word32 ivas_mdft_coeff_cos_twid_120_fx[IVAS_120_PT_LEN + 1] = {
+ 2147483647,
+ 2147299712, 2146747776, 2145827968, 2144540544,
+ 2142885760, 2140863616, 2138474752, 2135719552,
+ 2132598272, 2129111680, 2125260160, 2121044608,
+ 2116465536, 2111523840, 2106220288, 2100556032,
+ 2094531712, 2088148480, 2081407488, 2074309888,
+ 2066856832, 2059049728, 2050889728, 2042378368,
+ 2033516928, 2024307200, 2014750592, 2004848640,
+ 1994603264, 1984016128, 1973089152, 1961823872,
+ 1950222592, 1938287104, 1926019584, 1913421952,
+ 1900496512, 1887245440, 1873670912, 1859775360,
+ 1845561216, 1831030784, 1816186624, 1801031296,
+ 1785567360, 1769797504, 1753724416, 1737350784,
+ 1720679424, 1703713280, 1686455296, 1668908288,
+ 1651075200, 1632959360, 1614563712, 1595891328,
+ 1576945536, 1557729664, 1538246656, 1518500224,
+ 1498493568, 1478230144, 1457713536, 1436947072,
+ 1415934336, 1394679040, 1373184768, 1351455232,
+ 1329494144, 1307305216, 1284892288, 1262259200,
+ 1239409920, 1216348160, 1193078016, 1169603456,
+ 1145928448, 1122057088, 1097993600, 1073741824,
+ 1049306112, 1024690624, 999899584, 974937152,
+ 949807744, 924515520, 899064960, 873460288,
+ 847705984, 821806400, 795766016, 769589312,
+ 743280704, 716844800, 690286016, 663608960,
+ 636818176, 609918336, 582913920, 555809664,
+ 528610176, 501320096, 473944128, 446486944,
+ 418953280, 391347808, 363675296, 335940448,
+ 308148064, 280302848, 252409632, 224473168,
+ 196498224, 168489632, 140452144, 112390608,
+ 84309816, 56214568, 28109692, 0
+};
+
+const Word32 ivas_mdft_coeff_cos_twid_80_fx[IVAS_80_PT_LEN + 1] = {
+ 2147483647,
+ 2147069696, 2145827968, 2143759104, 2140863616,
+ 2137142912, 2132598272, 2127231488, 2121044608,
+ 2114039936, 2106220288, 2097588736, 2088148480,
+ 2077903232, 2066856832, 2055013760, 2042378368,
+ 2028955520, 2014750592, 1999768832, 1984016128,
+ 1967498624, 1950222592, 1932194688, 1913421952,
+ 1893911552, 1873670912, 1852707968, 1831030784,
+ 1808647680, 1785567360, 1761798656, 1737350784,
+ 1712233088, 1686455296, 1660027264, 1632959360,
+ 1605261952, 1576945536, 1548021248, 1518500224,
+ 1488393728, 1457713536, 1426471296, 1394679040,
+ 1362349184, 1329494144, 1296126464, 1262259200,
+ 1227905280, 1193078016, 1157790720, 1122057088,
+ 1085890944, 1049306112, 1012316800, 974937152,
+ 937181696, 899064960, 860601536, 821806400,
+ 782694464, 743280704, 703580480, 663608960,
+ 623381568, 582913920, 542221504, 501320096,
+ 460225408, 418953280, 377519648, 335940448,
+ 294231776, 252409632, 210490208, 168489632,
+ 126424088, 84309816, 42163032, 0
+};
+
+const Word32 ivas_mdft_coeff_cos_twid_40_fx[IVAS_40_PT_LEN + 1] = {
+ 2147483647,
+ 2145827968, 2140863616, 2132598272, 2121044608,
+ 2106220288, 2088148480, 2066856832, 2042378368,
+ 2014750592, 1984016128, 1950222592, 1913421952,
+ 1873670912, 1831030784, 1785567360, 1737350784,
+ 1686455296, 1632959360, 1576945536, 1518500224,
+ 1457713536, 1394679040, 1329494144, 1262259200,
+ 1193078016, 1122057088, 1049306112, 974937152,
+ 899064960, 821806400, 743280704, 663608960,
+ 582913920, 501320096, 418953280, 335940448,
+ 252409632, 168489632, 84309816, 0
+};
+
+// Q30
+const Word32 dirac_gains_norm_term_int[9] = {
+ 1073741824, 759250176, 1073741824, 438353280, 219176688, 1073741824, 309962528, 98018768,
+ 40015996
+};
+
+// Q31
+const Word32 dirac_gains_norm_term_fx[9] = {
+ 2147483647, 1518500352, 2147483647, 876706560, 438353376, 2147483647, 619925056, 196037536, 80031992
+};
+
+// Q27
+const Word32 dirac_gains_Pnm_int[91][9] = {
+ { -134217728, 0, 134217728, 0, 0, -134217728, 0, 0, 0 },
+ { -134197288, 2342396, 134156400, -7026119, 122639, -134095104, 14049026, -613106, 10701 },
+ { -134135976, 4684105, 133972536, -14043751, 490416, -133727536, 28061840, -2450586, 85575 },
+ { -134033784, 7024438, 133666264, -21044428, 1102895, -133115936, 42002312, -5506921, 288606 },
+ { -133890784, 9362478, 133238096, -28019012, 1959264, -132262040, 55833192, -9772457, 683351 },
+ { -133706992, 11697809, 132688440, -34959892, 3058584, -131167848, 69520408, -15234719, 1332861 },
+ { -133482480, 14029564, 132017976, -41858120, 4399464, -129836328, 83027720, -21876818, 2299344 },
+ { -133217280, 16357047, 131227600, -48705360, 5980272, -128270864, 96320208, -29678480, 3644062 },
+ { -132911536, 18679510, 130318176, -55493180, 7799064, -126475552, 109363520, -38615824, 5427104 },
+ { -132565296, 20996256, 129290928, -62213284, 9853607, -124455056, 122123976, -48661468, 7707213 },
+ { -132178656, 23306694, 128146968, -68857816, 12141505, -122214432, 134569248, -59785232, 10541761 },
+ { -131751776, 25609964, 126887800, -75418320, 14659851, -119759704, 146666688, -71952528, 13986158 },
+ { -131284736, 27905410, 125514928, -81886824, 17405570, -117097048, 158385376, -85126080, 18094094 },
+ { -130777744, 30192412, 124030024, -88255768, 20375446, -114233392, 169695776, -99266128, 22917396 },
+ { -130230888, 32470208, 122434848, -94517128, 23565774, -111176104, 180568608, -114328832, 28505376 },
+ { -129644368, 34738112, 120731408, -100663320, 26972664, -107933048, 190976128, -130267952, 34905200 },
+ { -129018344, 36995424, 118921736, -106686840, 30591964, -104512608, 200891728, -147034448, 42161440 },
+ { -128353056, 39241452, 117008088, -112580368, 34419264, -100923608, 210290720, -164576576, 50316080 },
+ { -127648640, 41475572, 114992728, -118336848, 38449984, -97175216, 219149232, -182840512, 59408524 },
+ { -126905360, 43697012, 112878208, -123949000, 42679048, -93277184, 227444688, -201769248, 69474696 },
+ { -126123408, 45905176, 110666976, -129410248, 47101484, -89239304, 235156848, -221304640, 80548296 },
+ { -125303040, 48099312, 108361848, -134713792, 51711740, -85072152, 242266352, -241385344, 92659128 },
+ { -124444528, 50278820, 105965584, -139853120, 56504308, -80786280, 248755776, -261949392, 105834368 },
+ { -123548080, 52443040, 103481048, -144822272, 61473384, -76392608, 254609280, -282932704, 120097808 },
+ { -122614016, 54591264, 100911328, -149614784, 66612780, -71902504, 259812912, -304269024, 135469312 },
+ { -121642584, 56722880, 98259536, -154225168, 71916384, -67327280, 264354304, -325891904, 151965872 },
+ { -120634104, 58837188, 95528944, -158647504, 77377552, -62678672, 268222720, -347732352, 169600480 },
+ { -119588872, 60933588, 92722800, -162876704, 82989840, -57968464, 271409984, -369722464, 188383040 },
+ { -118507224, 63011412, 89844624, -166907264, 88746208, -53208660, 273908992, -391791360, 208319200 },
+ { -117389480, 65070028, 86897888, -170734608, 94639696, -48411356, 275714624, -413868832, 229411120 },
+ { -116235952, 67108864, 83886096, -174353936, 100663296, -43588484, 276824064, -435884832, 251658240 },
+ { -115047032, 69127240, 80812992, -177760784, 106809472, -38752388, 277236128, -457767936, 275054816 },
+ { -113823072, 71124576, 77682296, -180951136, 113070880, -33915128, 276951296, -479447744, 299592224 },
+ { -112564464, 73100224, 74497888, -183920976, 119439696, -29088994, 275972448, -500852768, 325257600 },
+ { -111271560, 75053584, 71263600, -186666800, 125908272, -24285974, 274304128, -521913568, 352034976 },
+ { -109944736, 76984136, 67983320, -189185120, 132468856, -19517968, 271952224, -542560640, 379905024 },
+ { -108584440, 78891192, 64661120, -191472992, 139113184, -14796968, 268925472, -562724864, 408843424 },
+ { -107191040, 80774240, 61300996, -193527600, 145833472, -10134552, 265233552, -582338944, 438823936 },
+ { -105765016, 82632672, 57907084, -195346384, 152621264, -5542341, 260888528, -601335936, 469815200 },
+ { -104306760, 84465968, 54483472, -196927072, 159468512, -1031517, 255903808, -619651456, 501783968 },
+ { -102816736, 86273488, 51034412, -198267904, 166366624, 3386773, 250294992, -637221056, 534692032 },
+ { -101295408, 88054736, 47564080, -199367280, 173307296, 7701825, 244078832, -653983232, 568498944 },
+ { -99743224, 89809192, 44076620, -200223728, 180282192, 11903295, 237274256, -669879040, 603161856 },
+ { -98160648, 91536272, 40576356, -200836160, 187282720, 15980983, 229901280, -684849728, 638632640 },
+ { -96548144, 93235488, 37067500, -201203920, 194300432, 19925212, 221981760, -698840192, 674862144 },
+ { -94906272, 94906272, 33554432, -201326592, 201326592, 23726568, 213539056, -711796992, 711796992 },
+ { -93235488, 96548144, 30041364, -201203920, 208352752, 27376188, 204597888, -723670016, 749382016 },
+ { -91536272, 98160648, 26532496, -200836160, 215370464, 30865648, 195183856, -734411520, 787559936 },
+ { -89809200, 99743208, 23032272, -200223728, 222370864, 34186800, 185324752, -743976000, 826268864 },
+ { -88054736, 101295408, 19544786, -199367280, 229345888, 37332284, 175048640, -752322176, 865447872 },
+ { -86273488, 102816736, 16074439, -198268032, 236286560, 40294912, 164385440, -759410496, 905030144 },
+ { -84465944, 104306784, 12625336, -196927072, 243184800, 43068320, 153365504, -765205632, 944950528 },
+ { -82632672, 105765016, 9201773, -195346384, 250031920, 45646496, 142020480, -769675200, 985139200 },
+ { -80774256, 107191032, 5807891, -193527600, 256819584, 48024044, 130382952, -772789696, 1025526400 },
+ { -78891192, 108584440, 2447739, -191472992, 263540000, 50196224, 118485736, -774524480, 1066041600 },
+ { -76984120, 109944720, -874438, -189185120, 270184320, 52158672, 106363224, -774856768, 1106610176 },
+ { -75053584, 111271544, -4154720, -186666800, 276744864, 53907864, 94049432, -773768704, 1147159552 },
+ { -73100224, 112564464, -7389016, -183920976, 283213504, 55440728, 81579720, -771245696, 1187614080 },
+ { -71124568, 113823072, -10573435, -180951136, 289582400, 56754824, 68989160, -767276288, 1227898496 },
+ { -69127232, 115047064, -13704140, -177760784, 295843776, 57848416, 56313356, -761853888, 1267938048 },
+ { -67108880, 116235952, -16777203, -174353936, 301989888, 58720256, 43588536, -754974720, 1307654528 },
+ { -65070028, 117389472, -19788994, -170734608, 308013440, 59369844, 30850226, -746639232, 1346972928 },
+ { -63011400, 118507224, -22735772, -166907264, 313906944, 59797272, 18134762, -736851968, 1385816832 },
+ { -60933588, 119588872, -25613950, -162876704, 319663424, 60003204, 5477891, -725620736, 1424110464 },
+ { -58837172, 120634088, -28420080, -158647504, 325275584, 59989016, -7084927, -712957184, 1461778688 },
+ { -56722868, 121642576, -31150674, -154225168, 330736768, 59756660, -19517928, -698877184, 1498746240 },
+ { -54591276, 122613992, -33802452, -149614784, 336040384, 59308680, -31786382, -683399744, 1534940800 },
+ { -52443040, 123548064, -36372160, -144822272, 341179712, 58648260, -43855684, -666547776, 1570288384 },
+ { -50278848, 124444520, -38856688, -139853264, 346148864, 57779188, -55691916, -648348160, 1604717952 },
+ { -48099324, 125303040, -41252988, -134713792, 350941376, 56705796, -67261816, -628830848, 1638160896 },
+ { -45905160, 126123416, -43558124, -129410240, 355551744, 55433036, -78532848, -608029120, 1670546304 },
+ { -43697012, 126905360, -45769332, -123949000, 359974080, 53966400, -89473440, -585980480, 1701810944 },
+ { -41475560, 127648632, -47883864, -118336808, 364203168, 52311936, -100052728, -562724992, 1731889152 },
+ { -39241464, 128353048, -49899212, -112580408, 368233856, 50476188, -110241232, -538305984, 1760719104 },
+ { -36995424, 129018360, -51812888, -106686856, 372061216, 48466224, -120010336, -512769824, 1788240512 },
+ { -34738100, 129644368, -53622532, -100663280, 375680512, 46289628, -129332608, -486166400, 1814398208 },
+ { -32470208, 130230888, -55325984, -94517088, 379087360, 43954400, -138181984, -458547616, 1839134464 },
+ { -30192412, 130777744, -56921148, -88255752, 382277728, 41469052, -146533552, -429968768, 1862399872 },
+ { -27905450, 131284752, -58406064, -81886920, 385247552, 38842476, -154363936, -400487584, 1884144384 },
+ { -25609950, 131751776, -59778952, -75418272, 387993376, 36083912, -161651424, -370163232, 1904324096 },
+ { -23306666, 132178656, -61038128, -68857760, 390511712, 33203050, -168375472, -339058272, 1922894464 },
+ { -20996270, 132565280, -62182040, -62213328, 392799456, 30209874, -174517136, -307236864, 1939817984 },
+ { -18679498, 132911536, -63209344, -55493124, 394854208, 27114732, -180059392, -274765312, 1955057024 },
+ { -16357021, 133217280, -64118736, -48705292, 396672992, 23928188, -184986656, -241711232, 1968580864 },
+ { -14029578, 133482472, -64909128, -41858176, 398253664, 20661142, -189285248, -208144320, 1980359808 },
+ { -11697849, 133706992, -65579560, -34960012, 399594624, 17324636, -192943088, -174134880, 1990369664 },
+ { -9362556, 133890784, -66129224, -28019252, 400693888, 13929935, -195949824, -139755008, 1998589184 },
+ { -7024411, 134033784, -66557432, -21044346, 401550304, 10488515, -198297168, -105077560, 2004999424 },
+ { -4684126, 134135976, -66863648, -14043818, 402162752, 7011926, -199978640, -70176320, 2009588352 },
+ { -2342414, 134197304, -67047540, -7026174, 402530496, 3511839, -200989440, -35125516, 2012346496 },
+ { -5, 134217728, -67108864, -17, 402653184, 8, -201326592, -88, 2013265920 }
+};
+
+// Q30
+const Word32 dirac_gains_trg_term_int[181][2] = {
+ { -1073741824, 93 },
+ { -1073578304, -18739436 },
+ { -1073087680, -37473000 },
+ { -1072270272, -56195404 },
+ { -1071126272, -74900440 },
+ { -1069655936, -93582656 },
+ { -1067859776, -112236624 },
+ { -1065738240, -130856168 },
+ { -1063292288, -149436080 },
+ { -1060522368, -167970160 },
+ { -1057429248, -186453440 },
+ { -1054014208, -204879600 },
+ { -1050278016, -223243376 },
+ { -1046221952, -241539408 },
+ { -1041847104, -259761664 },
+ { -1037154944, -277904896 },
+ { -1032146880, -295963392 },
+ { -1026824448, -313931616 },
+ { -1021189120, -331804480 },
+ { -1015242880, -349576096 },
+ { -1008987264, -367241408 },
+ { -1002424448, -384794592 },
+ { -995556160, -402230656 },
+ { -988384640, -419544416 },
+ { -980912000, -436730112 },
+ { -973140608, -453782944 },
+ { -965072832, -470697376 },
+ { -956710976, -487468704 },
+ { -948057792, -504091296 },
+ { -939115840, -520560224 },
+ { -929887680, -536871040 },
+ { -920376384, -553017856 },
+ { -910584576, -568996544 },
+ { -900515712, -584801664 },
+ { -890172480, -600428672 },
+ { -879557888, -615873088 },
+ { -868675520, -631129536 },
+ { -857528320, -646194048 },
+ { -846120128, -661061376 },
+ { -834454080, -675727744 },
+ { -822533888, -690187904 },
+ { -810363392, -704438016 },
+ { -797945664, -718473536 },
+ { -785285056, -732290112 },
+ { -772385152, -745883904 },
+ { -759250176, -759250176 },
+ { -745883904, -772385152 },
+ { -732290112, -785285056 },
+ { -718473600, -797945664 },
+ { -704438016, -810363392 },
+ { -690187904, -822533888 },
+ { -675727552, -834454144 },
+ { -661061376, -846120128 },
+ { -646194048, -857528320 },
+ { -631129536, -868675392 },
+ { -615873088, -879557760 },
+ { -600428672, -890172352 },
+ { -584801792, -900515712 },
+ { -568996544, -910584576 },
+ { -553017856, -920376384 },
+ { -536871040, -929887680 },
+ { -520560224, -939115776 },
+ { -504091296, -948057792 },
+ { -487468704, -956710976 },
+ { -470697376, -965072832 },
+ { -453782944, -973140608 },
+ { -436730208, -980911936 },
+ { -419544416, -988384640 },
+ { -402230784, -995556160 },
+ { -384794592, -1002424448 },
+ { -367241280, -1008987264 },
+ { -349576096, -1015242880 },
+ { -331804480, -1021189120 },
+ { -313931712, -1026824384 },
+ { -295963392, -1032146880 },
+ { -277904800, -1037154944 },
+ { -259761664, -1041847104 },
+ { -241539296, -1046221952 },
+ { -223243488, -1050278016 },
+ { -204879600, -1054014208 },
+ { -186453328, -1057429248 },
+ { -167970160, -1060522368 },
+ { -149435984, -1063292288 },
+ { -130856168, -1065738240 },
+ { -112236624, -1067859776 },
+ { -93582792, -1069655936 },
+ { -74900448, -1071126272 },
+ { -56195288, -1072270272 },
+ { -37473008, -1073087680 },
+ { -18739318, -1073578304 },
+ { -46, -1073741824 },
+ { 18739350, -1073578304 },
+ { 37473052, -1073087680 },
+ { 56195320, -1072270272 },
+ { 74900480, -1071126272 },
+ { 93582824, -1069655936 },
+ { 112236512, -1067859776 },
+ { 130856168, -1065738240 },
+ { 149435984, -1063292288 },
+ { 167970272, -1060522368 },
+ { 186453328, -1057429248 },
+ { 204879504, -1054014208 },
+ { 223243488, -1050278016 },
+ { 241539296, -1046221952 },
+ { 259761664, -1041847104 },
+ { 277904896, -1037154944 },
+ { 295963392, -1032146880 },
+ { 313931712, -1026824448 },
+ { 331804480, -1021189120 },
+ { 349576096, -1015242880 },
+ { 367241408, -1008987264 },
+ { 384794720, -1002424320 },
+ { 402230784, -995556160 },
+ { 419544320, -988384640 },
+ { 436730112, -980912000 },
+ { 453782848, -973140608 },
+ { 470697504, -965072832 },
+ { 487468576, -956710976 },
+ { 504091296, -948057792 },
+ { 520560352, -939115776 },
+ { 536870912, -929887680 },
+ { 553017920, -920376384 },
+ { 568996544, -910584704 },
+ { 584801664, -900515712 },
+ { 600428800, -890172224 },
+ { 615873088, -879557888 },
+ { 631129536, -868675392 },
+ { 646193920, -857528320 },
+ { 661061504, -846120064 },
+ { 675727616, -834454144 },
+ { 690187904, -822533888 },
+ { 704438016, -810363136 },
+ { 718473536, -797945792 },
+ { 732290176, -785285056 },
+ { 745883776, -772385216 },
+ { 759250176, -759250176 },
+ { 772385216, -745883776 },
+ { 785285056, -732290112 },
+ { 797945664, -718473536 },
+ { 810363264, -704438016 },
+ { 822533888, -690187904 },
+ { 834454144, -675727616 },
+ { 846120128, -661061504 },
+ { 857528320, -646193920 },
+ { 868675392, -631129536 },
+ { 879557888, -615873088 },
+ { 890172352, -600428800 },
+ { 900515712, -584801792 },
+ { 910584704, -568996544 },
+ { 920376384, -553017920 },
+ { 929887680, -536870912 },
+ { 939115776, -520560352 },
+ { 948057792, -504091296 },
+ { 956710976, -487468576 },
+ { 965072832, -470697504 },
+ { 973140608, -453782944 },
+ { 980911936, -436730112 },
+ { 988384640, -419544320 },
+ { 995556160, -402230784 },
+ { 1002424320, -384794592 },
+ { 1008987264, -367241280 },
+ { 1015242880, -349576096 },
+ { 1021189120, -331804480 },
+ { 1026824448, -313931712 },
+ { 1032146880, -295963392 },
+ { 1037154944, -277904800 },
+ { 1041847104, -259761664 },
+ { 1046221952, -241539296 },
+ { 1050278016, -223243488 },
+ { 1054014208, -204879600 },
+ { 1057429248, -186453328 },
+ { 1060522368, -167970272 },
+ { 1063292288, -149435984 },
+ { 1065738240, -130856168 },
+ { 1067859776, -112236624 },
+ { 1069655936, -93582760 },
+ { 1071126272, -74900440 },
+ { 1072270272, -56195308 },
+ { 1073087680, -37473052 },
+ { 1073578304, -18739382 },
+ { 1073741824, 0 }
+};
+
+// Q31
+const Word32 dirac_gains_trg_term_fx[181][2] = {
+ { ( -2147483647 - 1 ), 187 },
+ { -2147156608, -37478872 },
+ { -2146175360, -74946000 },
+ { -2144540544, -112390808 },
+ { -2142252544, -149800880 },
+ { -2139311872, -187165312 },
+ { -2135719552, -224473248 },
+ { -2131476480, -261712336 },
+ { -2126584576, -298872160 },
+ { -2121044736, -335940320 },
+ { -2114858496, -372906880 },
+ { -2108028416, -409759200 },
+ { -2100556032, -446486752 },
+ { -2092443904, -483078816 },
+ { -2083694208, -519523328 },
+ { -2074309888, -555809792 },
+ { -2064293760, -591926784 },
+ { -2053648896, -627863232 },
+ { -2042378240, -663608960 },
+ { -2030485760, -699152192 },
+ { -2017974528, -734482816 },
+ { -2004848896, -769589184 },
+ { -1991112320, -804461312 },
+ { -1976769280, -839088832 },
+ { -1961824000, -873460224 },
+ { -1946281216, -907565888 },
+ { -1930145664, -941394752 },
+ { -1913421952, -974937408 },
+ { -1896115584, -1008182592 },
+ { -1878231680, -1041120448 },
+ { -1859775360, -1073742080 },
+ { -1840752768, -1106035712 },
+ { -1821169152, -1137993088 },
+ { -1801031424, -1169603328 },
+ { -1780344960, -1200857344 },
+ { -1759115776, -1231746176 },
+ { -1737351040, -1262259072 },
+ { -1715056640, -1292388096 },
+ { -1692240256, -1322122752 },
+ { -1668908160, -1351455488 },
+ { -1645067776, -1380375808 },
+ { -1620726784, -1408876032 },
+ { -1595891328, -1436947072 },
+ { -1570570112, -1464580224 },
+ { -1544770304, -1491767808 },
+ { -1518500352, -1518500352 },
+ { -1491767808, -1544770304 },
+ { -1464580224, -1570570112 },
+ { -1436947200, -1595891328 },
+ { -1408876032, -1620726784 },
+ { -1380375808, -1645067776 },
+ { -1351455104, -1668908288 },
+ { -1322122752, -1692240256 },
+ { -1292388096, -1715056640 },
+ { -1262259072, -1737350784 },
+ { -1231746176, -1759115520 },
+ { -1200857344, -1780344704 },
+ { -1169603584, -1801031424 },
+ { -1137993088, -1821169152 },
+ { -1106035712, -1840752768 },
+ { -1073742080, -1859775360 },
+ { -1041120448, -1878231552 },
+ { -1008182592, -1896115584 },
+ { -974937408, -1913421952 },
+ { -941394752, -1930145664 },
+ { -907565888, -1946281216 },
+ { -873460416, -1961823872 },
+ { -839088832, -1976769280 },
+ { -804461568, -1991112320 },
+ { -769589184, -2004848896 },
+ { -734482560, -2017974528 },
+ { -699152192, -2030485760 },
+ { -663608960, -2042378240 },
+ { -627863424, -2053648768 },
+ { -591926784, -2064293760 },
+ { -555809600, -2074309888 },
+ { -519523328, -2083694208 },
+ { -483078592, -2092443904 },
+ { -446486976, -2100556032 },
+ { -409759200, -2108028416 },
+ { -372906656, -2114858496 },
+ { -335940320, -2121044736 },
+ { -298871968, -2126584576 },
+ { -261712336, -2131476480 },
+ { -224473248, -2135719552 },
+ { -187165584, -2139311872 },
+ { -149800896, -2142252544 },
+ { -112390576, -2144540544 },
+ { -74946016, -2146175360 },
+ { -37478636, -2147156608 },
+ { -93, ( -2147483647 - 1 ) },
+ { 37478700, -2147156608 },
+ { 74946104, -2146175360 },
+ { 112390640, -2144540544 },
+ { 149800960, -2142252544 },
+ { 187165648, -2139311872 },
+ { 224473024, -2135719552 },
+ { 261712336, -2131476480 },
+ { 298871968, -2126584576 },
+ { 335940544, -2121044736 },
+ { 372906656, -2114858496 },
+ { 409759008, -2108028416 },
+ { 446486976, -2100556032 },
+ { 483078592, -2092443904 },
+ { 519523328, -2083694208 },
+ { 555809792, -2074309888 },
+ { 591926784, -2064293760 },
+ { 627863424, -2053648896 },
+ { 663608960, -2042378240 },
+ { 699152192, -2030485760 },
+ { 734482816, -2017974528 },
+ { 769589440, -2004848640 },
+ { 804461568, -1991112320 },
+ { 839088640, -1976769280 },
+ { 873460224, -1961824000 },
+ { 907565696, -1946281216 },
+ { 941395008, -1930145664 },
+ { 974937152, -1913421952 },
+ { 1008182592, -1896115584 },
+ { 1041120704, -1878231552 },
+ { 1073741824, -1859775360 },
+ { 1106035840, -1840752768 },
+ { 1137993088, -1821169408 },
+ { 1169603328, -1801031424 },
+ { 1200857600, -1780344448 },
+ { 1231746176, -1759115776 },
+ { 1262259072, -1737350784 },
+ { 1292387840, -1715056640 },
+ { 1322123008, -1692240128 },
+ { 1351455232, -1668908288 },
+ { 1380375808, -1645067776 },
+ { 1408876032, -1620726272 },
+ { 1436947072, -1595891584 },
+ { 1464580352, -1570570112 },
+ { 1491767552, -1544770432 },
+ { 1518500352, -1518500352 },
+ { 1544770432, -1491767552 },
+ { 1570570112, -1464580224 },
+ { 1595891328, -1436947072 },
+ { 1620726528, -1408876032 },
+ { 1645067776, -1380375808 },
+ { 1668908288, -1351455232 },
+ { 1692240256, -1322123008 },
+ { 1715056640, -1292387840 },
+ { 1737350784, -1262259072 },
+ { 1759115776, -1231746176 },
+ { 1780344704, -1200857600 },
+ { 1801031424, -1169603584 },
+ { 1821169408, -1137993088 },
+ { 1840752768, -1106035840 },
+ { 1859775360, -1073741824 },
+ { 1878231552, -1041120704 },
+ { 1896115584, -1008182592 },
+ { 1913421952, -974937152 },
+ { 1930145664, -941395008 },
+ { 1946281216, -907565888 },
+ { 1961823872, -873460224 },
+ { 1976769280, -839088640 },
+ { 1991112320, -804461568 },
+ { 2004848640, -769589184 },
+ { 2017974528, -734482560 },
+ { 2030485760, -699152192 },
+ { 2042378240, -663608960 },
+ { 2053648896, -627863424 },
+ { 2064293760, -591926784 },
+ { 2074309888, -555809600 },
+ { 2083694208, -519523328 },
+ { 2092443904, -483078592 },
+ { 2100556032, -446486976 },
+ { 2108028416, -409759200 },
+ { 2114858496, -372906656 },
+ { 2121044736, -335940544 },
+ { 2126584576, -298871968 },
+ { 2131476480, -261712336 },
+ { 2135719552, -224473248 },
+ { 2139311872, -187165520 },
+ { 2142252544, -149800880 },
+ { 2144540544, -112390616 },
+ { 2146175360, -74946104 },
+ { 2147156608, -37478764 },
+ { 2147483647, 0 }
+};
+
+/*------------------------------------------------------------------------------------------*
+ * FB ROM tables
+ *------------------------------------------------------------------------------------------*/
+
+const Word16 ivas_fb_cf_4ms_48k_fx[IVAS_FB_4MS_48K_SAMP] = {
+ 0, 4, 13, 26, 44, 66, 92, 123, 158, 197, 241, 289, 341, 398, 458, 524, 593, 667, 744, 826, 913, 1003, 1097, 1196, 1298, 1405, 1516, 1630, 1749, 1871, 1998, 2128, 2262, 2400, 2541, 2687, 2836, 2988, 3144, 3304, 3467, 3634, 3804, 3977, 4154, 4334, 4517, 4704, 4893, 5086, 5282, 5480, 5682, 5886, 6094, 6304, 6516, 6732, 6949, 7170, 7393, 7618, 7846, 8076, 8308, 8542, 8779, 9017, 9258, 9500, 9744, 9990, 10238, 10487, 10738, 10990, 11244, 11499, 11756, 12014, 12273, 12533, 12794, 13056, 13319, 13582, 13847, 14112, 14378, 14644, 14911, 15178, 15446, 15713, 15981, 16249, 16518, 16786, 17054, 17321, 17589, 17856, 18123, 18389, 18655, 18920, 19185, 19448, 19711, 19973, 20234, 20494, 20753, 21011, 21268, 21523, 21777, 22029, 22280, 22529, 22777, 23023, 23267, 23509, 23750, 23988, 24225, 24459, 24691, 24921, 25149, 25374, 25597, 25818, 26035, 26251, 26463, 26673, 26881, 27085, 27287, 27485, 27681, 27874, 28063, 28250, 28433, 28613, 28790, 28963, 29133, 29300, 29463, 29623, 29779, 29931, 30080, 30226, 30367, 30505, 30639, 30769, 30896, 31018, 31137, 31251, 31362, 31469, 31571, 31670, 31764, 31854, 31941, 32023, 32100, 32174, 32243, 32309, 32369, 32426, 32478, 32526, 32570, 32609, 32644, 32675, 32701, 32723, 32741, 32754, 32763, 32767
+};
+
+const Word16 ivas_fb_cf_4ms_32k_fx[IVAS_FB_4MS_32K_SAMP] = {
+ 1, 11, 30, 60, 99, 149, 208, 276, 355, 443, 541, 648, 765, 891, 1026, 1171, 1325, 1488, 1660, 1840, 2030, 2228, 2435, 2650, 2873, 3105, 3345, 3592, 3847, 4110, 4380, 4657, 4941, 5233, 5530, 5835, 6146, 6463, 6786, 7115, 7449, 7789, 8134, 8483, 8838, 9197, 9561, 9928, 10300, 10675, 11054, 11435, 11820, 12208, 12598, 12990, 13385, 13781, 14179, 14578, 14978, 15379, 15780, 16182, 16585, 16987, 17388, 17789, 18189, 18588, 18986, 19382, 19777, 20169, 20559, 20947, 21332, 21713, 22092, 22467, 22839, 23206, 23570, 23929, 24284, 24633, 24978, 25318, 25652, 25981, 26304, 26621, 26932, 27237, 27534, 27826, 28110, 28387, 28657, 28920, 29175, 29422, 29662, 29894, 30117, 30332, 30539, 30737, 30927, 31107, 31279, 31442, 31596, 31741, 31876, 32002, 32119, 32226, 32324, 32412, 32491, 32559, 32618, 32668, 32707, 32737, 32756, 32766
+};
+
+const Word16 ivas_fb_cf_4ms_16k_fx[IVAS_FB_4MS_16K_SAMP] = {
+ 4, 44, 123, 241, 398, 593, 826, 1097, 1405, 1749, 2128, 2541, 2988, 3467, 3977, 4517, 5086, 5682, 6304, 6949, 7618, 8308, 9017, 9744, 10487, 11244, 12014, 12794, 13582, 14378, 15178, 15981, 16786, 17589, 18389, 19185, 19973, 20753, 21523, 22280, 23023, 23750, 24459, 25149, 25818, 26463, 27085, 27681, 28250, 28790, 29300, 29779, 30226, 30639, 31018, 31362, 31670, 31941, 32174, 32369, 32526, 32644, 32723, 32763
+};
+
+const Word16 ivas_fb_cf_1ms_48k_fx[IVAS_FB_1MS_48K_SAMP] = {
+ 8, 78, 218, 427, 705, 1050, 1460, 1934, 2470, 3066, 3718, 4425, 5184, 5990, 6840, 7732, 8660, 9622, 10612, 11627, 12663, 13715, 14778, 15847, 16920, 17989, 19052, 20104, 21140, 22155, 23145, 24107, 25035, 25927, 26777, 27583, 28342, 29049, 29701, 30297, 30833, 31307, 31717, 32062, 32340, 32549, 32689, 32759
+};
+
+const Word16 ivas_fb_cf_1ms_32k_fx[IVAS_FB_1MS_32K_SAMP] = {
+ 19, 177, 491, 957, 1573, 2330, 3224, 4244, 5381, 6624, 7960, 9378, 10864, 12403, 13979, 15580, 17187, 18788, 20364, 21903, 23389, 24807, 26143, 27386, 28523, 29543, 30437, 31194, 31810, 32276, 32590, 32748
+};
+
+const Word16 ivas_fb_cf_1ms_16k_fx[IVAS_FB_1MS_16K_SAMP] = {
+ 78, 705, 1934, 3718, 5990, 8660, 11627, 14778, 17989, 21140, 24107, 26777, 29049, 30833, 32062, 32689
+};
+
+/* Q Factor is 31*/
+const Word32 ivas_fb_resp_cheby_ramp_32del_fx[IVAS_FB_1MS_32K_SAMP + 1] = {
+ 21970992, 16097417, 21859084, 28772960, 36989692, 46636088, 57839904, 70755400, 85490472,
+ 102165872, 120908192, 141807584, 164922576, 190321136, 218072144, 248214064, 280795872,
+ 315834176, 353276992, 393021664, 435109696, 479474528, 525959424, 574472512, 624859584,
+ 676981248, 730657728, 785668096, 841854208, 899002688, 956860544, 1015180800, 1073741824
+};
+
+/* Q Factor is 31*/
+const Word32 ivas_fb_resp_cheby_ramp_16del_fx[IVAS_FB_1MS_16K_SAMP + 1] = {
+ 23460896, 29872362, 47814248, 71691184, 102337872, 140498880, 186843680, 241748256, 305433120,
+ 377921280, 458893152, 547769792, 643727232, 745668672, 852315136, 962208832, 1073741824
+};
+
+/*------------------------------------------------------------------------------------------*
+ * SNS MSVQ codebooks and means
+ *------------------------------------------------------------------------------------------*/
+
+/*Q12*/
+const Word16 ivas_sns_cdbk_tcx20_stage1_fx[128 * 16] = {
+ -7498, -8552, -3948, 11493, 10929, 4767, 5696, 4985, 5673, 1825, -1927, -2174, -3321, -4771, -5964, -7214,
+ -10641, -13643, -7600, -1477, 6893, 10597, 4021, 919, -537, 684, 6146, 1349, 1375, 4748, 736, -3571,
+ 8121, 9016, 4721, 3315, 3543, 4759, 5279, 5578, 4435, 3410, 492, -2942, -8990, -12493, -13751, -14493,
+ 646, 4522, 1609, -2654, -4481, -4275, -4938, -4698, -4089, -1547, 1428, 4430, 5202, 4974, 3429, 441,
+ 1001, -2898, -4776, -4824, -1005, 1623, 4558, 5049, 5546, 4459, 3687, 3688, -126, -3430, -5243, -7311,
+ -3765, -762, -3030, -6261, -7149, -5194, -3869, 997, 5325, 6801, 5249, 4107, 2928, 2308, 1946, 369,
+ 10168, 5956, 3730, 2771, 2326, 2853, 3117, 2884, 1479, -133, -2832, -4621, -6076, -6372, -6981, -8269,
+ 9885, 6118, 4056, 3729, 2954, 2262, 382, -887, -2030, -1996, -3016, -3773, -4113, -4045, -4375, -5152,
+ -3335, 5139, 6949, 5817, 4078, 4678, 4112, 3805, 2705, 921, -2675, -4919, -5304, -5636, -7035, -9300,
+ -5726, 774, 1426, -213, -1582, -1060, -1381, -448, -337, 307, -78, 485, 1252, 2090, 2767, 1723,
+ 4376, 8005, 8723, 8483, 6453, 4642, 1740, -811, -3455, -4423, -5495, -5697, -5721, -5357, -5457, -6006,
+ 9786, 10280, 4686, 1498, -692, -958, 1101, 3151, 2236, 2122, -1101, -3777, -4952, -6004, -7796, -9579,
+ -5550, 5500, 6501, 7932, 2414, 2004, -724, -797, 465, 79, 1246, -954, -8806, -5066, -857, -3387,
+ 3592, -6275, -6564, -5666, -2347, -3624, -3711, -4039, -4858, -5538, -5004, -2044, 6173, 16714, 9046, 14147,
+ 16852, 13619, 9025, 4301, 605, -1497, -3065, -3483, -4472, -4221, -4897, -5230, -4820, -4121, -3894, -4701,
+ 3227, 10297, 4142, -3143, -5540, -3558, 1739, 5927, 5194, 4741, -1693, -3809, -3779, -3780, -3312, -6653,
+ -9100, -5057, -1642, 2448, -2023, 4879, 133, 5593, 1767, 4924, 6821, 2411, -1210, -4078, -4246, -1619,
+ -7619, -11980, 600, 2505, 2570, -5562, 1970, -1802, 2335, 4846, -4895, 3392, 5151, 6508, 2257, -277,
+ 8936, 11845, 11978, 10584, 9236, 7186, 3794, 1874, -708, -3953, -7322, -9670, -10750, -10778, -10917, -11335,
+ 8587, 838, -5142, -8197, -8172, -5767, -4419, -1944, -79, 1853, 3022, 3823, 4142, 4618, 3723, 3112,
+ -5283, 568, 1979, 2570, 2120, 2234, 1918, 2247, 1603, 2038, 1584, -93, -1478, -3355, -4339, -4312,
+ 3278, 2345, 280, -2908, -4330, -3770, -3036, -1236, 758, 3245, 3120, 2288, 1603, 916, -401, -2152,
+ 18828, 10647, 3579, -3906, -287, 10855, 5635, -3673, -6872, -5289, -2424, -5462, -6052, -2769, -4104, -8707,
+ -4121, 2761, 3751, 4035, 3218, -38, -1640, -513, -750, -12, -1597, -1672, -1522, -637, 42, -1302,
+ -5458, 2924, 6701, 9084, 6798, 7952, 4454, 5450, 5949, 5277, -2303, -8307, -11701, -10523, -8863, -7432,
+ 379, 6294, 8583, 7842, 6055, 3554, -1419, -894, -4610, -4731, -3777, -2242, -3681, -3172, -3323, -4856,
+ 9040, 14426, 8046, 2314, -89, 612, 655, 895, -4796, -4631, -1323, -264, -6051, -6580, -5728, -6526,
+ 10320, 9632, 5351, 853, -2496, -4459, -5580, -5161, -5476, -4380, -3281, -1752, -624, 1835, 2457, 2762,
+ 6230, 4286, 3054, 2103, 1411, 882, -116, -345, 353, 511, -1457, -2334, -2581, -2840, -3948, -5209,
+ -2351, -845, -4051, -7663, -8133, -6619, -6596, -5580, -3850, -278, 3739, 7371, 8632, 9397, 9551, 7277,
+ 14878, 8087, 1612, -2811, -4559, -4173, -3660, -2457, -1780, -938, -1082, -880, -541, 40, -680, -1056,
+ -357, 6763, 7507, 2217, 983, 5824, 3263, 5362, 4023, 5140, -7718, -7703, -6304, -5528, -5237, -8233,
+ -9056, -2879, 4548, 9096, 9567, 8235, 6713, 5876, 4240, 2331, -452, -3615, -6496, -8240, -9501, -10367,
+ -6591, -10319, -10037, 1092, 9508, 10608, 14496, -4303, -5138, -1136, 3886, 5677, 2912, -4172, -5188, -1298,
+ 3868, 10098, 10930, 8191, 5304, 4169, 3641, 2883, 1198, -205, -3154, -5928, -8536, -10323, -10806, -11331,
+ -580, -1263, -2402, -5074, -6014, -4529, -3202, -2168, -259, 2212, 3665, 5339, 5604, 4695, 3222, 754,
+ 1658, -3851, -5014, -4529, -1764, -300, 8217, 16396, 2000, 824, 665, -1713, -3175, -3034, -3057, -3324,
+ -11375, -8634, -6184, -6208, -4129, -150, 1519, 4345, 5629, 5310, 4007, 4455, 3926, 3560, 3104, 823,
+ 7473, 12120, 11294, 4728, 3568, 5501, 3688, 3508, 1692, -1661, -8566, -9762, -8843, -8001, -8086, -8653,
+ 8613, 5171, 4353, 3298, 925, -530, -1637, -2214, -3071, -2941, -3234, -2961, -2504, -1211, -880, -1176,
+ 621, 10589, 7196, 3759, 1529, -659, -1898, -893, -380, -88, -927, -1736, -2729, -3606, -4369, -6410,
+ -10687, -7849, -5755, -6353, -5913, -3150, -2865, -1183, -382, 1696, 2622, 5191, 7208, 8842, 10178, 8401,
+ -366, 8121, 9838, 5330, 503, 3640, 5493, 4385, 472, -837, -3977, -9982, -8797, -5441, -3061, -5319,
+ 10435, 576, -3431, -5099, -5048, -3131, -1414, 1467, 2492, 2334, 1243, 257, 1129, 1454, -1171, -2093,
+ -2408, 4154, 6243, 5033, 3118, 2477, 901, 862, 622, 627, -473, -1897, -2823, -3803, -5378, -7253,
+ 5751, -3944, -5457, -3268, 270, -185, -1373, -2563, -3758, -4024, -4052, -3460, -2709, -237, 9209, 19800,
+ 11172, 15303, 13936, 10936, 5606, 374, -3235, -4534, -5841, -5872, -6303, -6525, -6391, -6176, -6037, -6414,
+ 5173, 10429, 7690, -211, -4293, -3886, -1661, 896, 81, -608, -1808, -2380, -2191, -1905, -2123, -3203,
+ -8788, -1052, 5387, 6699, 5899, 3671, 3443, 3830, 4015, 2746, -536, -2438, -3985, -4693, -6124, -8075,
+ -8721, -8773, -1913, 3002, 5005, -1141, -1250, 4860, 3573, -249, 246, 1790, 3243, 3739, -189, -3222,
+ 12821, 11330, 7418, 6142, 4487, 3660, 3434, 2422, 898, -805, -4025, -7013, -9016, -9871, -10400, -11484,
+ 6459, 1432, -705, -1814, -2564, -2337, -2669, -1789, -1565, -767, -696, -14, 629, 1614, 2310, 2475,
+ 523, 864, 661, 262, 533, 1619, 2390, 2554, 2076, 1532, 248, -542, -1545, -2462, -3431, -5282,
+ 2754, 7840, 1531, -5320, -7337, -5059, -1828, 2415, 2801, 2414, 920, -54, -675, 295, 594, -1290,
+ 16459, 9353, 5397, 5154, 6401, 4035, 525, -1206, -2684, -3963, -5726, -6290, -6446, -6516, -6917, -7575,
+ 3331, 2764, 1820, 1449, 404, 197, -617, -518, -755, -625, -1250, -1192, -1278, -978, -1091, -1661,
+ 1202, 10867, 13999, 10573, 8667, 5713, 3901, 1699, -649, -3697, -6326, -8102, -9055, -9334, -9517, -9940,
+ 3105, 10471, 11637, 9256, 1588, -4373, -5838, -3257, -2501, -2719, -3963, -4248, -3642, -2230, -780, -2506,
+ 7036, 12562, 13320, 10158, 3016, -3341, -3328, 586, 1408, -1129, -5924, -5878, -5793, -6843, -7570, -8279,
+ 11292, 4466, 2522, 790, -1414, -1946, -1506, -261, 583, 802, -656, -1773, -2651, -2250, -3307, -4691,
+ 4319, 4371, 4567, 4600, 3221, 2633, 1994, 1398, 564, -536, -2662, -3664, -4402, -4565, -5348, -6489,
+ -7437, -5416, -5951, -7745, -7676, -4554, -4813, -2349, 668, 6481, 8239, 7629, 6574, 6530, 6295, 3525,
+ 13292, 11390, 5199, 2139, 489, -271, -644, -427, -1114, -1854, -3425, -4756, -5461, -5211, -4922, -4424,
+ 710, 9953, 9525, 5612, 1946, 2958, 298, -154, -1714, -3333, -6410, -9882, -5524, -2172, -432, -1382,
+ -10643, -8047, -2326, 2007, 3553, 2546, 4871, 5435, 4843, 4106, 2244, 1050, -497, -1808, -2878, -4457,
+ 294, -9337, -8427, -1045, 9093, 10411, 3417, 3239, 2068, -534, 1078, -1517, -2125, -1732, -2738, -2145,
+ 5432, 12777, 10582, 2772, -92, 2136, 2501, 4105, 2738, 3539, -1530, -8480, -9513, -8753, -8426, -9787,
+ 5972, 8255, 4335, -524, -2484, -2872, -3937, -3518, -3037, -774, 635, 1891, 1590, 660, -1520, -4672,
+ 6572, 3645, -218, -1090, 345, 2321, 3692, 4654, 4719, 3041, 2117, 459, -3402, -7045, -8640, -11170,
+ -5410, -344, -990, -3893, -5051, -2311, -77, 3918, 4679, 4822, 3303, 1776, 337, 305, 409, -1472,
+ 8389, 11222, 8707, 4721, 3131, 2061, 1130, 791, -354, -651, -3686, -5202, -6383, -7339, -7792, -8746,
+ 9298, 9362, 6305, 3177, 968, -72, -945, -819, -1079, -725, -2067, -2739, -3434, -4331, -5460, -7441,
+ 2704, 6870, 6571, 6294, 4511, 3348, 2296, 2931, 2159, 954, -1545, -3421, -5465, -7201, -9296, -11710,
+ 880, -1826, -3492, -4233, -3893, -2425, -1948, -823, -259, 657, 1000, 2107, 2906, 3603, 3958, 3790,
+ -196, 6860, 8581, 9562, 7277, 7244, 1471, 1946, -228, -338, -3115, -7547, -11656, -9838, -4686, -5339,
+ 8578, 4837, 2226, 754, -1817, -2201, 499, 2914, 3313, 3158, -527, -4733, -5791, -4100, -3403, -3706,
+ -4232, 6556, 1920, 6615, -946, 4468, 280, 2157, 766, -524, -922, -1974, -2072, -1600, -4968, -5524,
+ 7288, 2936, -1640, -4588, -6332, -6285, -6188, -5571, -5223, -3844, -1671, 2013, 5110, 8289, 8345, 7362,
+ 11493, 11342, 6954, 1821, -1692, -2612, -3300, -3319, -3814, -2738, -2931, -2814, -2479, -1890, -1719, -2303,
+ 8177, 11903, 6525, -1422, -3274, 251, 4220, 4653, 3045, -303, -5550, -5079, -5244, -5314, -5883, -6703,
+ -9438, -3031, 483, 1317, 1847, 1874, 3018, 2956, 788, 3090, 730, -1912, -1688, 122, 860, -1017,
+ -3693, -4977, -541, 2877, 3327, -2337, -4262, -2189, 699, 2375, 3310, 1962, 1504, 1017, 1319, -390,
+ 6065, 7469, 7234, 10424, 10658, 7912, 5388, 4640, 2156, -733, -4795, -9010, -11277, -11766, -11999, -12365,
+ 10932, 2437, -1845, -3262, -3753, -3716, -4031, -3422, -2848, -1620, -1167, 176, 1764, 2966, 3342, 4047,
+ -619, -1377, -1334, -455, -198, 333, 279, 702, 835, 1061, 505, 476, 127, 254, 270, -859,
+ 5215, 1197, -575, -1227, -2612, -2325, -649, 1885, 2691, 2793, 1163, -765, -1768, -1371, -1567, -2082,
+ 19164, 11491, 4615, -1985, -3389, 3234, 9530, 1792, -6657, -7546, -6135, -3576, -5395, -6848, -4207, -4089,
+ -5579, 2618, 4644, 1302, 270, 4372, 3748, 1797, -752, -937, -2728, -2859, -706, -865, -1022, -3304,
+ -1838, 6025, 10256, 11080, 7972, 1492, -1232, 2649, 3965, 3980, -6137, -7448, -7596, -7566, -6578, -9023,
+ 1944, 6450, 7024, 8636, 7062, 1810, -1661, -772, 542, -13, -3255, -4851, -5285, -5086, -5501, -7043,
+ 8123, 16086, 12234, 5222, 1088, 112, 327, 1928, -3259, -5187, -6713, -7464, -5697, -5814, -5336, -5649,
+ 859, 7375, 6059, 2544, 375, -1579, -3831, -3783, -3738, -2686, -2393, -1129, 29, 1048, 1033, -183,
+ 2101, 4211, 3442, 2574, 2178, 2151, 1104, 386, 135, -216, -2007, -2668, -2626, -2609, -3456, -4701,
+ -5046, -336, -968, -3416, -4451, -3637, -4472, -3410, -3255, -1874, -1058, 1763, 4855, 7351, 9606, 8347,
+ 19995, 9006, 2634, -634, -1483, -1947, -2216, -805, -298, -446, -2156, -3518, -3871, -4075, -4720, -5467,
+ -2272, 8650, 9022, 2896, -866, 3555, 4656, 4146, 4057, 5105, 893, -7960, -11942, -9282, -3999, -6659,
+ -3314, 4163, 6336, 8539, 7909, 6703, 4331, 4759, 3115, 1223, -1904, -4488, -6662, -8210, -10273, -12228,
+ -1219, -6996, -6238, 5560, 19256, 6948, 16806, -1718, -4399, -4432, 1743, -4434, -5576, -4824, -5420, -5055,
+ 7337, 7092, 7560, 9007, 7842, 4106, 2111, 1823, -310, -2228, -4758, -6480, -7636, -7833, -8350, -9284,
+ -127, -7162, -7239, -8124, -5968, -3470, -2064, 167, 1784, 2556, 3741, 6051, 7042, 5293, 3278, 4242,
+ -4837, -8327, -8445, -7964, -6737, -3635, 12584, 10749, 9489, 14113, 4466, -818, -963, -2829, -1662, -5183,
+ -9221, -7856, -8616, -9610, -8803, -4648, -2322, 3345, 7609, 8661, 7189, 7848, 6804, 4876, 3375, 1368,
+ 3370, 8415, 9491, 3696, 2112, 4195, 2535, 1216, -704, -2599, -4917, -4773, -4766, -4924, -5695, -6652,
+ 5033, 6480, 5225, 2803, 1389, 388, -1095, -1930, -1285, -783, -2330, -2783, -2299, -2271, -2847, -3696,
+ 6462, 10974, 9445, 5632, 3121, 338, -2526, -3512, -4157, -4256, -4496, -3576, -3213, -3003, -3042, -4191,
+ -8903, -5489, -3362, -3932, -2867, -42, -794, 1047, 1551, 2990, 1925, 1809, 2047, 3857, 5983, 4180,
+ -1078, 5534, 5668, 8546, 7579, 7727, 3515, 2403, 425, -3939, -7676, -10486, -4654, -3810, -5900, -3854,
+ 11241, 2333, -888, -2668, -601, 2056, 973, -782, -1134, -628, -1278, -1464, -1036, -1025, -2566, -2532,
+ 188, 993, 1510, 3746, 3964, 4113, 3912, 3774, 2904, 1760, -544, -2262, -3823, -5032, -6585, -8617,
+ 17244, 5164, -3514, -5803, -5740, -3512, -4264, -5949, -7105, -7263, -6297, -4203, 3488, 882, 9119, 17753,
+ 18572, 16918, 11329, 8930, 3706, 2301, -534, -4811, -6296, -6264, -6923, -7015, -7012, -7183, -7628, -8090,
+ 2776, 9267, 4870, -2407, -3332, 1594, 479, 626, -2334, -2117, -1714, -1452, -1892, -1016, -575, -2774,
+ -5418, -1560, 977, 3118, 4128, 4683, 3995, 3168, 1326, 367, -798, -1786, -2341, -2513, -3011, -4334,
+ -5417, -6011, -5325, -2432, 93, 2347, 2339, 1497, 2097, 3182, 2553, 1778, 1688, 2154, 997, -1540,
+ 9725, 13565, 12472, 9916, 5050, 2613, 1338, 621, -1049, -4212, -7066, -8072, -8504, -8673, -8645, -9079,
+ 3568, 2083, 779, -447, -1488, -1526, -2026, -1584, -1564, -893, -955, -362, 96, 991, 1665, 1663,
+ 4308, 2100, 967, 1304, 1477, 1636, 1557, 2064, 2234, 1529, -1013, -2413, -2782, -3000, -4202, -5767,
+ -2729, 7254, 5313, 626, -4368, -3106, 689, 2051, 1436, 577, 2137, -551, -4980, -1408, 137, -3079,
+ 15090, 13574, 8552, 4879, 2489, 603, 625, 413, -965, -1853, -5221, -7106, -7498, -7482, -7752, -8349,
+ 2370, 3151, 1957, 225, -516, -337, -392, 223, 813, 1307, 124, -276, -702, -1169, -2432, -4348,
+ -4031, 4338, 9696, 9577, 10361, 8623, 7730, 5093, 2251, -518, -3768, -6931, -9490, -10533, -10950, -11448,
+ 10303, 15787, 11780, 8011, -1234, -5671, -6127, -5176, -4588, -3477, -4783, -2583, -2036, -3150, -2990, -4066,
+ 1649, 10539, 12961, 10244, 5607, -356, -2601, -488, 30, -2077, -2877, -8331, -8515, -7727, -3810, -4247,
+ 8997, 5275, 2084, -488, -2018, -2461, -3081, -2315, -2223, -1654, -1778, -1155, -563, 285, 587, 507,
+ 2053, 8908, 7041, 522, -1083, 1920, 1555, 2991, 959, 1714, -3254, -3680, -2792, -4401, -4878, -7576,
+ -9455, -8989, -9057, -10160, -9541, -6763, -5661, -3200, -593, 3501, 6901, 10117, 10416, 11442, 11927, 9115,
+ 7190, 11877, 7889, 1661, -96, 1823, 1276, 741, -1950, -1969, -4935, -5445, -5084, -4151, -3666, -5162,
+ 923, 9232, 9280, 2340, -3138, -2558, 873, 5017, 3579, -513, -3936, -9898, -4597, -2889, -1289, -2425
+};
+
+/*Q12*/
+const Word16 ivas_sns_cdbk_tcx20_stage2_fx[64 * 16] = {
+ -4739, -1952, 33, 1958, 1570, -310, -1531, -1209, -554, 53, 911, 1536, 1298, 855, 1041, 1042,
+ -1663, -904, -175, 651, -1032, -2713, -1113, 1177, 1464, 826, 214, -1494, -1846, 763, 2736, 3107,
+ 112, -859, -1631, -2224, -1919, -1030, -1104, -307, 1536, 3827, 3753, 1748, 107, -638, -468, -902,
+ 46, 1539, 3454, 2870, 2388, -2034, -3447, -1887, -692, -27, -310, -923, -859, -521, 27, 377,
+ 1736, 793, 312, 1806, 467, -1631, -500, 1432, 2116, -102, -2181, -280, 2082, -270, -2800, -2981,
+ -499, 628, 1238, 973, 1115, 3296, 3147, 1180, -225, -1217, -1869, -1759, -1756, -1809, -1438, -1005,
+ -814, -42, -125, -171, 215, 305, 107, -109, 761, 921, 805, 630, 183, -456, -1018, -1190,
+ 3133, 1965, 1284, 613, 952, 693, 240, -514, -738, -801, -702, -785, -963, -1364, -1554, -1460,
+ -2540, -1194, -624, 654, 1697, 2507, 1824, 793, -441, -1656, -427, 1665, 1549, -53, -1580, -2175,
+ -2612, -80, 1350, -1143, -868, 3411, 1168, -1279, -1792, -1401, -43, 224, 407, 470, 941, 1247,
+ -3135, -2208, -1570, -1618, -898, 791, 778, -354, -184, 553, 1861, 2776, 2413, 1232, 177, -614,
+ 1427, -894, 74, 274, 1641, 1416, -2247, -3524, -984, 2485, 916, -207, 570, 111, -306, -753,
+ 567, 223, 845, -469, -3177, -2357, 2872, 824, -1392, 757, 1566, -859, -167, 552, 315, -101,
+ -1017, -1966, -2969, -2645, -1036, 1791, 2595, 2648, 2209, 1368, 569, 1255, 1349, -305, -1605, -2241,
+ -180, -2117, -1548, 2748, 1044, -1910, -2213, -915, 378, 69, 1015, 1919, 2044, 1120, -379, -1075,
+ 61, 1450, 1443, -536, -2041, -2153, -241, 101, -1208, -1900, -710, 1553, 1938, 1209, 785, 249,
+ -871, -3584, -3398, -2068, -1304, -586, 802, 1195, 1173, 629, 692, 918, 1136, 1304, 1676, 2286,
+ -5190, 69, 1485, 2699, 2450, 2023, 739, 746, 653, -67, -772, -1497, -1398, -1046, -609, -285,
+ 436, 3227, 395, -2370, -1678, 289, 1631, 1271, 450, 574, 1098, 1346, 176, -1624, -2479, -2743,
+ -2034, 1082, 2695, 1685, 1183, 915, 636, -341, -486, 350, 1164, 625, -760, -1982, -2380, -2349,
+ 914, 1532, 886, -2080, -3920, -4687, -1446, 2800, 2748, 1303, 524, -634, -11, 747, 691, 632,
+ 1084, -467, -438, 1087, 2116, 2201, 1470, 691, 853, 987, 574, -224, -1366, -2404, -3041, -3123,
+ 3022, -593, -1542, -411, 421, 580, 276, -223, -67, -96, -91, -202, -250, -445, -371, -7,
+ 4287, 2796, 539, -861, -426, -868, -1334, -1937, -2448, -2081, -837, 139, 474, 386, 738, 1432,
+ -3717, -1050, 587, 144, -312, -549, -30, 857, 1641, 2410, 2657, 2049, 788, -915, -1966, -2594,
+ 1656, 90, 245, 2403, 4979, 1448, -716, -288, -387, -1023, -1625, -1371, -1425, -1584, -1505, -899,
+ 2943, -214, -1605, -563, 565, 838, 558, -616, -919, -1002, 498, 2396, 2264, -116, -2465, -2562,
+ 29, 1348, 1688, 136, -859, -273, -627, 84, 1360, 3635, 2904, -1691, -2928, -2031, -1197, -1576,
+ -3472, 1420, 442, -1499, -1990, -1702, -1566, -1104, 78, 1033, 1640, 1632, 1574, 1220, 1212, 1081,
+ 1953, -23, -627, -1383, -1259, 1004, 3624, 2500, -1346, -2634, -1795, -778, -511, -345, 456, 1163,
+ 4332, -964, -3948, -3470, 1285, 4835, 3224, 584, -77, -893, -848, -484, -428, -664, -1430, -1053,
+ -117, -1788, -833, 558, 730, 891, -108, -1659, -2651, -2745, -1081, 1583, 2809, 2204, 1191, 1018,
+ -1345, -373, -461, -1404, -2370, -2179, -1860, -1422, -886, -763, -387, 596, 1341, 2668, 4449, 4396,
+ 703, 1081, 785, 116, -226, 588, 371, 128, -841, -1511, -2399, -3059, -3098, -175, 3474, 4064,
+ 2514, -777, -1994, -1860, -1724, -1633, -1409, -1049, -426, 483, 1396, 1809, 1677, 1298, 934, 762,
+ -2407, 787, 1259, 1895, 1549, 339, -1486, -2126, -2176, -1736, -1109, -617, -109, 887, 2228, 2818,
+ -2370, -192, 160, -107, 141, -1165, -2137, 299, 2936, 3445, -1416, -1420, 1045, 1309, 500, -1029,
+ -803, 477, 733, 1105, 1659, 1199, 396, -525, -596, -699, -668, -547, -466, -585, -527, -153,
+ -854, -1179, -969, -484, 67, 243, 278, -137, -55, 12, 281, 514, 599, 462, 461, 759,
+ -555, 4717, 2129, -264, -987, -522, -88, -291, -391, -491, -515, -766, -855, -879, -331, 88,
+ -1373, -2671, -1199, 3480, 2467, 1443, 608, 260, -542, -1600, -1685, -1118, -694, -114, 750, 1987,
+ 934, 3323, 1049, -2373, 769, 3068, 503, -1591, -2364, -3449, -3986, -3071, 844, 5877, 941, -474,
+ -425, 228, -1215, -1583, -1505, -1579, -934, -791, -484, -477, 1056, 4177, 4488, 3123, -786, -3291,
+ 1305, -1331, -1055, 1844, 3061, 1077, -2285, -2600, 230, 4597, 1138, -3419, -3967, -827, 2157, 77,
+ 997, 210, -659, -997, -624, 153, 286, -62, -2489, 591, 3868, 1520, -1263, -1424, -494, 387,
+ 550, 1926, -1797, -3507, -2499, -447, 586, 751, 425, -141, -276, 149, 519, 762, 1372, 1626,
+ 4225, -2078, 205, 1305, -229, -2501, -1305, -231, 298, 233, -219, -284, -355, -157, 196, 896,
+ 1933, 2394, 2521, -320, -2587, -3794, -3666, -1887, -607, -128, 189, 577, 518, 1040, 1956, 1861,
+ -4582, -2223, -1479, -548, -20, 1204, 1867, 1627, 992, -767, -2361, -1057, 474, 2119, 2744, 2011,
+ -3537, -810, -278, -246, 338, 2203, 3, -278, -22, 2105, 1761, -1452, -2749, -633, 2262, 1334,
+ 2549, 1831, 1526, 633, -570, -1662, -2041, -1590, -568, 965, 2087, 1627, 325, -934, -1811, -2366,
+ -2625, 735, 4126, 1924, -1352, -1375, -67, -263, -332, -611, -223, 69, -41, -365, -50, 449,
+ 1945, -542, 862, 1501, -463, -3503, -3203, 3338, 4340, -1886, -1472, -176, -899, -1007, 153, 1012,
+ 1176, -2807, 927, 489, -701, -1222, 1377, 2025, 1740, 704, 835, 366, -857, -1584, -1462, -1007,
+ 1374, 1113, 165, -297, -35, -391, -815, -1221, -716, -497, -249, 51, 360, 245, 279, 635,
+ 4741, 2291, -661, -1808, -1569, -1013, -23, 449, 899, 914, -15, -826, -1123, -1159, -870, -227,
+ -3095, -3457, -326, 1213, 999, 1504, 2296, 1487, 1074, 733, 257, -216, -595, -863, -635, -376,
+ 1313, 1943, 2320, 2119, 1731, 1184, 521, -954, -2164, -2882, -2594, -1657, -957, -667, -49, 792,
+ -225, 2104, 1245, 2010, 1467, -381, -1564, -1777, -2347, -1964, -723, 1747, 2298, 1153, -937, -2106,
+ 1110, -1091, -1843, -326, 890, 1762, 1723, 1959, 2404, 1131, -1081, -2694, -2783, -1612, -483, 933,
+ -3280, 740, 493, -1621, -2458, -538, 3182, 2390, 1740, 648, 349, -246, -677, -725, -96, 98,
+ 1151, 1644, 2333, 571, -841, -749, 1667, 2880, 2249, 381, -1951, -2564, -2038, -1604, -1690, -1440,
+ 1322, -4374, -4684, 281, 3091, 1587, 369, -3, -524, 313, 1018, 1177, 314, -171, -81, 365,
+ 2499, -904, -2181, -489, 429, 669, -619, -1412, -1628, -1788, -978, 7, 230, 941, 2049, 3175
+};
+
+/*Q12*/
+const Word16 ivas_sns_cdbk_tcx20_stage3_fx[32 * 16] = {
+ -496, -1325, -1064, 878, 1972, 607, -916, -1271, -543, 414, 1363, 1331, 679, -327, -664, -636,
+ 362, -60, -548, -1188, 3577, -1280, -794, 791, -404, 216, -537, -90, -322, -81, -302, 662,
+ -474, 1151, 1105, -431, -442, -1174, -1503, -1387, -649, 79, 712, 865, 1105, 707, 299, 37,
+ 334, 155, -1060, -1247, -263, 534, 1502, 1635, 1393, 587, -48, -494, -698, -945, -853, -533,
+ -102, -2580, 3220, -45, -520, -353, 93, 202, 19, -559, -404, 0, 267, 59, 248, 455,
+ -1614, 689, 1170, -355, -659, 214, 1065, 234, -205, -321, 68, 241, 302, -162, -349, -318,
+ 49, -471, -419, -290, 40, -128, -639, -61, 432, -165, -1970, -1140, 2419, 2709, 567, -934,
+ 1995, 749, -847, -723, -809, -1302, -1034, 36, 1174, 1053, 777, 479, 202, -226, -725, -798,
+ 503, -396, 223, 711, 939, 1443, 1651, 131, -658, -607, -422, -361, -558, -963, -997, -639,
+ -2380, -60, -1779, -303, 1247, 1476, 787, 528, 535, 131, -102, -243, -199, -125, 129, 359,
+ -480, 67, 624, 1594, 1140, -29, -302, -842, -1229, -1468, -958, -139, 349, 447, 512, 716,
+ -441, 257, -20, 524, -98, -901, -345, 1409, 932, -1626, -1328, 1998, 1784, -632, -919, -596,
+ 13, -162, 276, -73, -1083, 1249, 1237, -1331, -2051, 634, 2497, 636, -778, -595, 73, -539,
+ 150, -478, -1380, -2201, -557, 1248, 1317, -435, -672, -351, 51, 444, 824, 719, 625, 695,
+ -1787, -1936, -691, -455, -726, -586, 62, 521, 559, 532, 788, 935, 953, 717, 592, 523,
+ -307, 803, 537, -415, -32, -772, -200, 1387, 1056, -700, -1667, -1182, -198, 200, 611, 879,
+ -1136, -297, 1067, 1599, 933, 85, -496, -329, 704, 1505, 440, -791, -926, -846, -811, -698,
+ 554, 1640, -641, -1038, 1272, 2216, -1350, -1756, 606, 710, -732, -972, -109, -55, -189, -155,
+ -1245, 526, 853, -490, -1359, -1307, -459, 418, 1330, 1485, 1076, 66, -528, -675, -21, 330,
+ 1408, 1470, 1952, 558, -474, -218, 330, -50, -91, -404, -330, -556, -753, -1070, -1056, -717,
+ 48, -64, 1098, -961, -1463, 2614, -1256, 333, -225, 412, -110, -417, -56, -260, 2, 305,
+ -416, 207, 378, 157, -143, 675, 352, 15, -633, -373, 108, -981, -1789, -1138, 895, 2685,
+ -658, 135, 341, 217, -171, 367, 678, 235, -334, 875, 199, -2878, -1134, 2089, 1114, -1075,
+ 2544, 16, 331, 686, 339, -461, -853, -1260, -1021, -628, 3, 359, 463, 93, -282, -329,
+ 1673, -1600, -1453, 892, 900, -44, 456, 879, 586, -366, -785, -970, -549, -140, 126, 396,
+ -901, 3362, -1315, 487, -27, -544, 32, -54, -225, -100, 268, -6, -228, -277, -289, -183,
+ -605, -695, -453, 2594, -1649, -1440, 1218, 352, 100, -292, 42, 3, -89, 81, 342, 494,
+ -276, 125, 78, 668, 688, 152, 243, 303, 145, 226, 286, 252, 795, 844, -1302, -3227,
+ 522, -167, -889, -105, 51, -136, -646, 213, -785, -1079, 132, 3267, -1969, -884, 1495, 982,
+ 1886, 878, 347, -1000, -2044, -679, 1235, 203, -306, -879, -543, -38, 273, 119, 160, 390,
+ 733, -1286, -136, -112, -261, -483, -142, 25, 300, 298, 611, 560, 513, 71, -335, -353,
+ 546, -651, -903, -132, -317, -1043, -1323, -1071, 163, 760, 517, -177, -43, 546, 1305, 1823
+};
+
+/*Q12*/
+const Word16 ivas_sns_cdbk_tcx20_stage4_fx[32 * 16] = {
+ -23, -162, 294, 1101, 1808, -336, -823, -38, 238, -260, -324, -210, -287, -282, -323, -372,
+ -49, -247, 49, 204, -183, 155, 406, 257, 91, -371, 16, 1575, 421, -2168, -1339, 1183,
+ -1457, 1563, 444, 336, 129, -10, -15, -113, -128, -394, -382, -424, -287, 33, 271, 436,
+ 157, 92, -904, 2169, -1450, 1225, -665, -162, 218, -301, -211, 88, 190, 121, -213, -353,
+ 311, -803, 192, -2, -217, -143, 781, 349, -660, -1220, -924, -287, 221, 635, 780, 987,
+ 337, 1084, -628, -576, -28, 247, -210, -956, -1165, -580, 325, 976, 847, 398, 61, -133,
+ 843, -807, 219, 110, -49, -191, -461, 246, 1392, 1370, -584, -1545, -895, 69, 341, -57,
+ 1408, -1582, -268, -301, -440, 153, 593, 65, 11, 367, 796, 421, -129, -246, -411, -437,
+ 526, 80, 669, 935, -656, -1721, -781, 354, 349, -93, 46, 56, -14, 78, -24, 196,
+ 112, 33, -306, 471, 9, -1712, 2296, -1177, 94, -317, -118, 790, 230, 22, -199, -227,
+ -152, 530, -1584, -390, 9, -51, 806, 1056, 519, -417, -360, 39, 581, 595, -314, -867,
+ 1217, 271, -1536, -330, 608, -3, -86, 55, -58, -462, -331, -230, -564, -248, 434, 1262,
+ -103, 98, -113, -4, 335, -551, -94, 2816, -1630, -504, 276, 178, -221, -60, -186, -238,
+ 60, 171, -102, 21, -326, -190, -116, 90, -469, -487, -171, -8, -1140, 1358, 2645, -1333,
+ -573, -82, 1285, -2182, 1292, 153, -175, -243, -223, -40, -30, 63, 315, 338, 48, 55,
+ -204, 94, -337, -350, 51, 63, -918, 640, -809, 2336, -1509, 298, 1930, -1470, 602, -418,
+ -702, -781, -877, -125, 396, -358, -395, 70, 355, 170, 242, 140, 333, 526, 492, 514,
+ -184, 25, 155, 70, 264, 34, -841, -103, 303, 255, -655, -1131, 1838, 578, -1675, 1067,
+ -612, 728, 94, -512, 2, 779, 158, -163, 387, 828, 919, 457, -331, -696, -1030, -1009,
+ -383, 115, -175, 222, 65, -691, -1245, -708, 283, 1251, 953, -372, 549, 1413, 150, -1428,
+ -820, -428, 172, 383, 42, 193, 1079, 977, 557, -176, -262, -564, -744, -413, -138, 143,
+ 600, 113, 1392, -21, -405, 175, -764, -1357, -582, 164, 149, -297, -490, -7, 387, 944,
+ 977, 1086, 140, 175, 207, 142, 499, 161, -74, -393, -441, -657, -705, -513, -398, -208,
+ -335, -210, -840, 473, 592, -45, -670, -209, 154, 998, 1575, 223, -1650, -900, 325, 520,
+ -1044, -1156, 804, 1184, 196, -140, 51, -475, -858, -334, 550, 669, 323, 208, 55, -32,
+ -278, 97, -45, -152, -784, 487, -82, -1620, 2324, -113, -981, 425, -194, 122, 307, 487,
+ 390, -32, 1476, -311, -835, 256, 628, 184, 17, -565, -603, 62, 717, 453, -600, -1235,
+ 262, -96, 317, -990, 168, 771, -1790, 1064, 1028, -1523, 167, 1061, 15, -183, -130, -142,
+ 104, 381, 464, -114, -36, -288, 116, -216, -800, -1336, 2780, -303, -616, -288, -113, 265,
+ -203, 637, -66, -1133, -1244, -550, 336, 402, 307, 157, 228, -16, -76, 160, 435, 626,
+ -177, -754, -187, -206, 868, 2171, 398, -527, -386, -355, -360, -395, -185, 90, -54, 58,
+ -7, -58, -198, -152, -389, -24, 1982, -716, -784, 2346, -775, -1081, 20, 278, -187, -254
+};
+
+const Word16 *const ivas_sns_cdbks_tcx20_fx[SNS_MSVQ_NSTAGES_TCX20] = {
+ ivas_sns_cdbk_tcx20_stage1_fx, ivas_sns_cdbk_tcx20_stage2_fx, ivas_sns_cdbk_tcx20_stage3_fx, ivas_sns_cdbk_tcx20_stage4_fx
+};
+
+/*Q12*/
+const Word16 ivas_sns_cdbk_tcx10_stage1_fx[128 * 16] = {
+ 4155, 4844, 1339, -2626, -4982, -4674, -4721, -3645, -803, 3032, 4826, 4436, 3204, 1104, -1360, -4129,
+ -1594, -1284, -4844, -8342, -8548, -7606, -6706, -5389, -1713, 2074, 5231, 5641, 7605, 9627, 9427, 6422,
+ 1788, 7725, 11493, 9169, 6341, 587, 299, -4595, -4548, -3005, -1718, -3671, -4272, -3268, -4935, -7392,
+ 6395, 3818, 2406, 1897, 897, 256, -693, -1410, -1832, -2500, -2621, -2342, -1577, -1062, -856, -776,
+ 4150, 7919, 3439, -2033, -2704, -1557, 231, 1278, 3321, 2731, -93, -3269, -3781, -2586, -2807, -4238,
+ -3449, -354, 2017, 2387, 4764, 5609, 2963, 1108, 1421, 28, -950, -1353, -2415, -2770, -4077, -4929,
+ 8524, 7457, 4506, 1934, 338, -1987, -2756, -2266, -1957, -2240, -2375, -2413, -2097, -1743, -1348, -1577,
+ 7090, 5351, 2190, 948, 174, 15, 389, 653, 810, 817, 897, 265, -1778, -3881, -6266, -7674,
+ 6804, 11715, 7237, -532, -1146, 4914, 6089, 4999, 2534, -5124, -6431, -5499, -5543, -5359, -6419, -8238,
+ 7709, 2493, -2143, -6489, -5196, -3714, -2590, -832, -1060, 376, 749, 4940, 4149, -203, -522, 2334,
+ 2478, 4656, 6266, 8166, 8080, 7910, 7237, 5633, 3847, 82, -2972, -5614, -9294, -11465, -12330, -12680,
+ -3763, 439, 1331, -211, -1125, 837, 3525, 1259, 263, -714, -2457, -3123, -445, 2047, 1650, 487,
+ 4433, 3075, 1944, 16, -1183, -2102, -2546, -2683, -2426, -1757, -724, 250, 488, 152, 994, 2067,
+ -9469, -5101, -2893, -3433, -2063, 164, 2573, 3814, 3385, 1553, 818, -98, 1471, 3904, 3575, 1801,
+ 15946, 17207, 12819, 11001, 8646, 8327, 189, -5678, -6626, -8191, -8726, -8916, -9067, -9108, -8807, -9017,
+ -5510, -1763, 1586, 4321, 5956, 6915, 5607, 1816, -152, -948, -2191, -3237, -3324, -3026, -2853, -3196,
+ 8688, 10873, 8275, 4634, 1734, -557, -1294, -1577, -1538, -3121, -4044, -4288, -3973, -4095, -4377, -5339,
+ 8314, 381, -4203, -6906, -2427, 2895, 4683, -1276, -3574, -1537, 382, -1706, -1536, -1335, 2670, 5175,
+ 2014, 6901, 7450, 8391, 5660, 5349, 3318, 632, -1645, -7184, -11554, -6162, -2239, -4081, -3232, -3618,
+ 2463, 7959, 4852, -2086, -2118, 2942, 2680, 273, -1971, -3815, -4209, -3731, -1973, 228, 710, -2203,
+ 2203, 1934, 716, -1238, -808, -125, -35, 38, -139, -93, 845, 1853, 747, -583, -2071, -3245,
+ -8428, -9073, -4283, -324, 6076, 5438, -488, -2617, -275, 3550, -1050, -170, 4675, 4235, 2065, 669,
+ 11333, 11955, 6902, 1934, -1514, -2879, -3232, -4238, -3422, -2837, -2629, -2898, -2649, -2035, -2008, -1783,
+ 426, 4019, 4713, 3739, 3356, 3491, 3050, 1887, 1284, -268, -2029, -3494, -4307, -4440, -5214, -6212,
+ 2092, 5801, 8237, 9551, 6780, 3678, 2472, 1019, 1067, -1082, -3123, -5119, -7460, -7403, -7732, -8778,
+ 961, 1615, -886, -4376, -5548, -5310, -4982, -4885, -3665, -1478, 1198, 2863, 4755, 6850, 7462, 5426,
+ 12293, 13814, 11807, 11074, 9876, 10313, 5810, 199, -2989, -7493, -10043, -10534, -10988, -11237, -10950, -10951,
+ 250, 3000, 5233, 3533, 1034, 378, -553, -1707, -2133, -2878, -2837, -2353, -1841, -364, 705, 534,
+ 8771, 7295, 2905, -1528, -2797, -2224, -2434, -3707, -3996, -3372, -2464, -2340, 88, 2453, 2127, 1224,
+ -5356, -4080, -3178, -3415, -3409, -2987, -2237, -677, 1836, 4189, 5902, 5483, 3659, 2525, 1749, -4,
+ 8540, 13122, 10394, 3057, 1011, 2922, 1889, -673, -1284, -4815, -6548, -6657, -5605, -4808, -4643, -5902,
+ -904, 3036, 3724, 1024, 621, 2200, 3068, 4347, 4727, 939, -3049, -4688, -4457, -3259, -3173, -4155,
+ 7412, 8540, 3520, -908, -2046, -2396, -2247, -1458, -976, 74, -489, 690, 143, -3498, -4187, -2172,
+ -9034, -10692, -9925, -9020, -3884, 6891, 9607, 8744, 7840, 4174, 2713, 2569, 3504, 3316, -948, -5856,
+ 12528, 15782, 10788, 3495, -369, -2158, -2473, -3242, -3527, -5125, -5686, -5358, -4614, -3620, -2829, -3594,
+ 3762, 7050, 3669, -309, -1556, -2008, -2380, -2362, -2016, -1483, -971, -939, -639, 127, 288, -234,
+ 5466, 5096, 839, -4326, -4389, -495, 3962, 6525, 4641, 474, -1865, -1808, -2070, -3368, -3972, -4710,
+ -7682, -10419, -8678, 2804, 7231, 15597, 6455, -2426, -908, 2257, 7253, 5190, -3489, -5573, -6505, -1107,
+ 10313, 8489, 4954, 1234, -1203, -393, 1849, 1910, 915, -2272, -5380, -5480, -3449, -3573, -4108, -3807,
+ 9010, 7210, 5020, 3041, 1855, 1295, 314, -953, -2075, -2616, -2829, -2858, -3271, -3970, -4378, -4795,
+ 1460, 6841, 8628, 3136, 3143, 6063, 5972, 3426, 2223, -5238, -7341, -6357, -5904, -3889, -4715, -7448,
+ 1449, -1827, -4550, -6487, -5713, -2732, -660, 433, 1307, 2371, 2794, 3239, 3158, 2432, 2376, 2409,
+ 5243, 9630, 12091, 11941, 10590, 7240, 4378, 1797, -801, -6201, -9586, -10323, -9468, -8915, -8728, -8887,
+ -6934, -1067, 786, -193, 251, 625, 700, 418, 356, 314, 163, 106, 6, 1088, 1894, 1487,
+ 6060, 3896, 485, -2939, -4736, -3436, 282, 2032, 1869, -523, -3273, -3045, -833, -16, 1127, 3049,
+ -6670, -1890, 358, -230, 447, 2409, 3909, 6279, 5449, 1441, -878, -2018, -2272, -1424, -1908, -3000,
+ 11826, 16636, 13050, 6279, 1706, 781, 2337, -3227, -5169, -7375, -6710, -5822, -6503, -6377, -5089, -6343,
+ 485, 663, 700, 2165, 1981, 966, 376, 1834, 2298, 1627, 1114, 702, -758, -3039, -4935, -6179,
+ 15276, 10241, 6249, 2873, 783, 322, 994, 1738, 951, -1804, -4461, -5446, -5652, -6733, -7613, -7717,
+ -4421, -2251, -2182, -3670, -3227, -2064, -1880, -1860, -609, 307, 1234, 2129, 3532, 5592, 5516, 3853,
+ 3360, 7922, 10867, 9394, 6526, 1053, 1896, 2883, 1638, -5507, -7666, -7210, -7668, -4745, -5551, -7191,
+ 2467, 6411, 8292, 4274, 2274, 1209, -243, -1212, -1185, -2826, -3570, -3368, -3512, -3049, -2692, -3269,
+ 3028, 7338, 7308, 4275, 997, -2048, -3118, -4094, -3189, -2517, -1649, -1480, -692, 504, -1307, -3355,
+ -13713, -11806, -7131, -79, 6455, 6414, -589, -4681, -1922, 6331, 330, 637, 6245, 5108, 4653, 3749,
+ 14977, 9830, 6085, 2938, 1863, 1059, -553, -2267, -3180, -4394, -5086, -4951, -4163, -4237, -4011, -3909,
+ -1081, 3251, 6408, 7149, 4954, 5039, 4478, 4353, 4522, 680, -6756, -9382, -7832, -5831, -3856, -6094,
+ 7162, 7991, 4675, 976, 841, 2948, 4353, 3456, 2703, 451, -1709, -4266, -5937, -7074, -7860, -8711,
+ 7238, -605, -4007, 3, 8333, 1173, -2176, -5314, -6069, -5080, -4591, -4717, -2795, -241, 5388, 13461,
+ 10596, 12578, 13802, 10908, 7436, 2231, 2444, 1872, -2275, -7177, -9152, -9171, -8796, -8290, -8520, -8488,
+ -737, 2442, 485, -2808, -3574, -3229, -2953, -2353, -857, 704, 1697, 2241, 2025, 2311, 2655, 1952,
+ 12162, 6690, 2238, -2622, -4617, -5816, -5879, -5236, -4308, -2961, -1748, -1607, 1838, 2753, 3664, 5448,
+ -3077, 452, 1966, -389, -1269, 118, 175, 1055, 3620, 4579, 1375, -1234, -1480, -1197, -1718, -2974,
+ 15858, 15042, 10523, 5569, 4228, 4314, 3082, 654, -1725, -5657, -8057, -9036, -8888, -8704, -8514, -8690,
+ 1704, 1674, 529, 1843, 4216, 6144, 6034, 4105, 2177, -429, -2012, -2595, -4212, -5660, -6417, -7102,
+ 4241, 3011, -177, -3536, -4674, -3686, -1588, 992, 3180, 2882, 1972, 1063, 676, -379, -1461, -2516,
+ -10246, -9377, -9897, -10469, -9129, -5712, -3574, -1246, 1237, 4416, 7620, 7504, 9023, 11338, 10287, 8226,
+ 5873, 10679, 11753, 7933, 5561, 2214, 30, -1608, -3259, -6151, -6707, -5993, -5418, -4939, -4492, -5477,
+ 1703, 1720, 48, -171, 92, 1005, 1475, 1312, 659, -228, -981, -1903, -1549, -716, -784, -1681,
+ 534, 4872, 3894, -2429, -4953, -2172, 3168, 2622, 2251, 1388, -2147, -4094, -1110, 1384, -375, -2832,
+ -10365, -5877, -612, 3409, 4994, 5250, 3856, 2179, 1532, 1289, 947, 43, -882, -1327, -1874, -2562,
+ 7364, 8825, 6753, 3174, 1572, 1020, -1433, -3832, -4629, -5540, -5397, -4403, -2961, -1278, 255, 511,
+ 3616, 2982, 2441, 1531, 2154, 2980, 1762, 767, 272, -953, -1744, -2069, -2225, -2573, -3790, -5149,
+ 6016, 10717, 11396, 4773, 1867, 5061, 5183, 3833, 2366, -3588, -10444, -10907, -9023, -5516, -3941, -7793,
+ 6375, 1989, -1308, -3670, -4356, -4171, -3980, -3432, -2043, -587, 591, 1288, 2794, 3630, 3600, 3279,
+ 8179, 11466, 8560, 3788, 3482, 5771, 6843, 5604, 4908, 1374, -3903, -8790, -11546, -12047, -11857, -11832,
+ -3090, 661, 1382, -807, 2129, 5268, 1730, -823, -481, -2827, -4904, -3053, -219, 1606, 3077, 350,
+ 8949, 4159, 587, -2658, -2926, -2276, -1678, -1050, -331, -65, -22, -396, -501, -142, -463, -1189,
+ -5048, -1761, -1240, -3476, -3747, -2868, 162, 3168, 4073, 1904, 569, 468, 1695, 3016, 2504, 582,
+ 13457, 16793, 15820, 10226, 6095, -181, -2293, -4895, -6222, -6960, -7158, -7267, -7171, -6955, -6811, -6477,
+ -1163, 1485, 2929, 4720, 6317, 6894, 3387, -44, -1981, -2797, -3233, -2707, -2580, -3352, -3680, -4195,
+ 10024, 13762, 8664, 2406, 361, 330, 523, -3418, -2716, 1302, -192, -7081, -7539, -6126, -4791, -5509,
+ 221, -2249, -2660, -1660, -613, -278, -544, -655, 183, 1048, 1304, 660, 1055, 1496, 1247, 1445,
+ 846, 5133, 6934, 10757, 11411, 9325, 4488, 1331, -3265, -7057, -8303, -5003, -4657, -8262, -7258, -6419,
+ 9482, 12253, 6534, -607, -2653, -673, 306, -1178, -1765, -3207, -3766, -3761, -3142, -1768, -2113, -3942,
+ -550, 1425, 2011, 157, -1079, -1413, -1697, -1610, -686, 39, 810, 288, 848, 1801, 1010, -1353,
+ -10109, -11744, -7706, 379, 8248, 6559, 38, -828, 2185, 6885, 844, 754, 4769, 3153, -890, -2538,
+ 13503, 12466, 7450, 1458, -2178, -4645, -5771, -6295, -6474, -5971, -4508, -2899, 1290, 560, 405, 1608,
+ 4667, 8260, 6596, 1763, 3540, 6861, 3573, -969, -5225, -5388, -4163, -2503, -3545, -3940, -3641, -5886,
+ 5072, 10057, 11017, 4484, 3638, 2703, 2095, 2224, 2067, -2996, -4340, -4397, -7071, -7750, -8132, -8671,
+ 7076, 4469, 996, -4409, -7469, -8582, -7901, -7025, -4868, -1656, 2572, 4172, 4462, 5363, 6290, 6510,
+ 11515, 12880, 10465, 3540, 1874, 6237, 6698, 3799, -2308, -7772, -8623, -8541, -7869, -7144, -7664, -7087,
+ 1889, 3817, 3520, 1054, -342, -451, -2129, -3116, -3726, -5315, -4316, -2809, 54, 3440, 4742, 3688,
+ 12822, 7564, 3096, -1375, -2981, -3502, -2957, -2787, -2321, -2052, -2014, -1157, -656, -1499, -1036, 856,
+ -7298, -3128, -1459, -3766, -3686, -1244, 669, 2187, 5005, 6621, 4491, 1512, 782, 783, -274, -1196,
+ 12071, 12166, 10231, 7547, 4891, 1997, 167, -1868, -2940, -5141, -6998, -7442, -6793, -6155, -5653, -6081,
+ -1753, 1625, 4228, 3372, 2337, 4063, 4415, 1944, 491, -2688, -5614, -5677, -3836, -1216, -247, -1444,
+ 12512, 6411, 2980, 101, -359, -558, -915, -211, -81, -568, -1190, -2006, -2777, -3666, -4294, -5379,
+ -9543, -6774, -6214, -7549, -7059, -3854, -1628, 2101, 5622, 6976, 6572, 5418, 5229, 4875, 3740, 2087,
+ 8837, 12535, 11328, 7255, 2550, -2526, -4345, -6428, -5892, -7230, -7262, -4485, -1885, -283, -223, -1946,
+ 9129, 8498, 4366, 281, -3607, -5680, -5660, -5230, -3574, -1874, -344, -92, 1479, 1933, 516, -142,
+ 5256, 9433, 6759, -793, -3866, -459, 5206, 4388, 3690, -2799, -7970, -5691, -3094, -697, -2658, -6706,
+ -2216, -5889, -3568, 2955, 9741, 7436, 239, -1003, 1111, 4778, -1103, -1008, 1967, -1394, -4972, -7074,
+ 10789, 7440, 2779, -665, -2630, -3084, -1314, 514, 584, -2094, -4598, -5089, -1705, -879, -523, 474,
+ 6838, 5757, 5081, 5754, 4886, 2602, 782, 166, -233, -2235, -3851, -4886, -4905, -4949, -5029, -5777,
+ 3777, 8672, 7923, 2766, 875, 3035, 2111, 256, -660, -3765, -6885, -7930, -5724, -1376, 64, -3141,
+ 1043, 1116, -2723, -6588, -6935, -6723, -5310, 129, 5099, 4079, 3612, 2961, 2573, 4722, 2989, -43,
+ 1107, 6435, 9892, 10493, 10103, 8530, 4943, 5882, 5571, -2662, -9598, -11372, -11225, -10110, -8411, -9579,
+ -5006, -976, 1744, 1682, 136, -921, -1278, -2195, -2395, -1642, 74, 1034, 1476, 2263, 2966, 3036,
+ 5150, 4553, 3608, 1262, -1364, -913, 1595, 2380, 2112, -469, -3306, -3879, -2810, -2832, -2793, -2294,
+ -3555, -3199, -1984, -903, 897, 2488, 1905, 2582, 2162, 544, 447, 1148, 647, -112, -935, -2133,
+ 19565, 17281, 11036, 5756, 1904, 520, -2148, -4844, -5499, -5875, -6311, -6526, -6486, -6349, -6068, -5956,
+ -4564, 687, 4457, 4047, 2491, 1633, 917, 80, 46, 286, -541, -1798, -2353, -1410, -1770, -2208,
+ 10582, 8739, 6358, 4552, 5070, 5384, 3814, 1464, -830, -3127, -4787, -5934, -6628, -7437, -8195, -9024,
+ -8243, -6062, -5955, -6127, -4538, -1750, -708, 329, 1275, 2189, 2653, 2630, 4348, 7441, 7186, 5331,
+ 3524, 8176, 10617, 11183, 9097, 4548, 2951, -138, -2003, -4822, -9077, -10737, -10317, -6266, -1688, -5048,
+ -160, 2942, 5298, 6724, 7063, 1816, -1506, -2566, -575, -1613, -6146, -5214, -2667, -893, -655, -1848,
+ 1846, 4832, 4243, 1910, 516, -856, -1034, -742, -737, -953, -523, -41, -980, -1924, -2386, -3170,
+ -15228, -14072, -7488, 944, 6245, 6079, 828, -630, 1680, 6027, 390, 513, 5448, 5516, 2111, 1639,
+ 19563, 12033, 6609, 1145, -1338, -2373, -3214, -3154, -3135, -3507, -3551, -3495, -3191, -3941, -4145, -4305,
+ -3621, -2181, 970, 8464, 10422, 7881, 6143, 5042, 3015, 869, -2539, -3894, -5022, -7336, -8360, -9855,
+ 4589, 9181, 6169, 1082, 342, 359, 16, 127, 334, -1624, -2322, -2546, -2957, -3264, -4017, -5471,
+ 3606, -2296, -3662, -4758, -3791, -5478, -4900, -5253, -5389, -5139, -4257, -168, 6209, 6583, 9851, 18841,
+ 8752, 12363, 11875, 8625, 6928, 5159, 4395, 2087, 1077, -2569, -6852, -9550, -10394, -10712, -10636, -10548,
+ 1860, 2305, -375, -3366, -3658, -1668, 102, 33, -397, -793, -1050, -1026, 612, 3009, 3141, 1271,
+ 3601, 5629, 2769, -909, -3496, -4488, -4379, -4804, -4034, -2723, -478, 276, 2538, 4467, 3717, 2316,
+ -1091, -1227, -3638, -5036, -2839, 46, 2252, 4024, 4850, 4463, 2408, 276, -365, -206, -1119, -2800,
+ 13340, 14579, 9317, 4636, 1290, -97, 1113, -792, -1998, -3958, -3763, -4187, -6194, -6888, -7768, -8630,
+ -236, -1847, -3948, -2955, 848, 6018, 7872, 6895, 5707, 2744, 710, -1794, -4003, -4701, -5551, -5758
+};
+
+/*Q12*/
+const Word16 ivas_sns_cdbk_tcx10_stage2_fx[32 * 16] = {
+ 1254, 2000, -111, -1953, -2171, -1043, -545, -612, -607, 355, 1181, 1127, 407, -72, 136, 651,
+ 1677, -181, -362, 1586, 2110, 1730, 1432, 1098, 154, -818, -1272, -1336, -1575, -1560, -1581, -1103,
+ -657, -1538, -1699, -507, 1053, 1212, 186, -178, -469, -827, 133, 2395, 4402, 1302, -1796, -3012,
+ -2950, 352, 1493, 317, -158, -83, 933, 969, -252, -2462, -2188, -58, 1292, 1447, 1121, 226,
+ 698, -549, -716, -673, -616, -664, 851, 3231, 3395, 1140, -408, -1086, -1210, -1305, -1243, -845,
+ 2743, 2575, 2092, 1507, 389, -1102, -1786, -2168, -2057, -1183, -331, 322, -167, -615, -313, 93,
+ -600, -1922, -1784, -461, 89, -257, -435, -978, -1404, -863, 41, 1077, 1513, 1868, 2050, 2065,
+ -2614, -1550, -493, 1920, 2469, 1658, 1322, 891, 120, 39, 375, 58, -816, -1117, -1258, -1006,
+ 4114, 141, -1496, -667, -717, -670, 81, 172, -377, -514, -566, -636, -562, -172, 483, 1384,
+ -1224, -232, 927, 1449, 1662, 219, -1358, -2391, -2453, -568, 1446, 1748, 514, -215, 94, 381,
+ -2542, -2686, -1605, -961, -430, -99, 429, 1125, 1378, 1174, 1221, 1454, 908, 258, 15, 360,
+ -990, 1611, 1860, -56, -115, 132, -143, 570, 2335, 1232, -117, -340, -953, -1048, -1653, -2325,
+ -1043, 825, 558, 90, 77, 1451, 1251, -180, -132, 1996, 1103, -2372, -3534, -1902, 879, 933,
+ 413, -20, 632, 2414, 2389, 615, -571, -1252, -1630, -1721, -1782, -2012, -990, 319, 1376, 1819,
+ -3559, -518, 1547, 1324, -401, -1236, -464, 286, 445, 417, 78, -85, -106, 81, 648, 1542,
+ 175, 86, 1305, 954, -1355, -3290, -3017, -1397, 49, 1139, 1881, 2013, 1238, 580, -71, -289,
+ -1374, 310, -1225, -3016, -2673, -729, 1486, 1715, 1031, 429, 124, -461, 110, 1435, 1736, 1102,
+ 1452, 2766, 1584, 39, -167, 368, 1002, 674, -710, -1804, -1906, -1640, -1156, -768, -151, 418,
+ 1743, 660, -478, -657, -589, -842, -315, -227, -806, -1840, -1270, 444, 2334, 2275, 464, -895,
+ -1221, -2116, -2089, -944, 1010, 2035, 1826, 1844, 652, -1037, -1405, -1030, -188, 323, 779, 1560,
+ 1345, 1687, 1678, 945, -1118, -3020, -1357, 854, 1198, 98, -913, -918, -434, -448, -201, 605,
+ -720, 1466, 2918, 2271, 1555, 1037, 3, -715, -816, -748, -566, -552, -1105, -1496, -1558, -972,
+ 769, -1385, -1653, -673, -1444, -2353, -1657, 161, 1159, 991, 469, -49, 638, 1195, 1616, 2213,
+ 921, -1842, -199, 2419, 2210, -340, -2057, -988, 955, 653, -182, 179, -79, -812, -707, -130,
+ 3529, 896, 163, 98, -379, -690, -478, 329, 251, 506, 958, 943, 23, -1379, -2370, -2398,
+ 2120, 592, -895, -1916, 1168, 4037, 176, -2475, -1664, 291, -325, -455, 71, 89, -566, -249,
+ 2005, -2001, -3131, -1768, -336, 467, 955, 603, 145, 776, 1259, 1064, 391, -96, -317, -16,
+ -458, 921, 2, -1318, -618, 1762, 2872, 1443, -494, -954, 625, 807, -263, -885, -1580, -1861,
+ -913, -1382, 280, 380, 190, 897, -146, 150, 2509, 2072, -1691, -2832, -2267, 665, 2229, -140,
+ -57, 1690, 1163, -536, -1436, -1521, -1073, -1169, -1491, -1688, -1247, -678, 313, 1668, 2955, 3108,
+ -3201, 226, 404, -1437, -1195, 554, 435, -1440, -1127, 652, 1406, 1076, 1635, 1724, 858, -571,
+ -834, -883, -668, -171, -455, -236, 160, 54, 711, 3068, 3870, 1834, -386, -1341, -2074, -2649
+};
+
+/*Q12*/
+const Word16 ivas_sns_cdbk_tcx10_stage3_fx[8 * 16] = {
+ 623, -523, 384, -342, -1040, 513, 1226, -404, -1426, -997, -461, -246, 133, 636, 959, 965,
+ -665, -455, -1300, -1050, 567, 1223, 430, 481, 1090, 223, -598, -788, 171, 859, 304, -492,
+ -208, 605, -411, -1315, -717, -764, -1112, -319, 15, -176, 415, 1433, 1263, 414, 315, 561,
+ -784, -124, 922, 326, -1112, -803, 1144, 1435, 427, 25, 268, 478, 151, -534, -930, -887,
+ 1087, -853, -1027, 490, 1117, 729, -10, -523, -934, 31, 874, 798, 188, -485, -729, -753,
+ 1051, 1010, 416, -120, -588, -573, -850, -806, 717, 1704, 536, -841, -665, 167, -153, -1004,
+ -357, 94, 2, 303, 589, 278, 15, 480, 358, 5, -311, -465, -1287, -1594, -94, 1984,
+ -746, 246, 1015, 1707, 1184, -603, -843, -344, -247, -816, -723, -368, 46, 537, 328, -373
+};
+
+
+const Word16 *const ivas_sns_cdbks_tcx10_fx[SNS_MSVQ_NSTAGES_TCX10] = {
+ ivas_sns_cdbk_tcx10_stage1_fx, ivas_sns_cdbk_tcx10_stage2_fx, ivas_sns_cdbk_tcx10_stage3_fx
+};
+
+/*Q15*/
+const Word16 ivas_sns_cdbks_side_tcx20_stage1_fx[32 * 16] = {
+ -3728, -2160, 1376, 1464, 5856, -904, -10680, -6904, -1608, 416, 424, 496, 2688, 4152, 4160, 4952,
+ -560, 3056, 7720, 7344, 3520, 1648, 1304, -240, -1584, -2856, -2792, -3952, -3656, -3480, -2920, -2560,
+ -8728, 8968, 14888, 5968, 21344, 5920, 4776, -264, 8624, -1504, -17040, -5336, 1256, -10424, -14160, -14288,
+ -1448, -3424, -3008, -3480, -3088, 3056, 8840, 5432, 2032, 360, 712, -784, -1200, -1288, -1424, -1288,
+ 13432, 2072, -720, -472, -456, -608, -1712, -1696, -1040, -1144, -904, -1920, -1488, -1384, -1248, -704,
+ 80, 1008, 664, 448, -296, 424, 312, -992, -1584, -728, 392, -568, -376, -24, 392, 840,
+ 5688, 7336, 6456, -624, -9016, -17624, -10056, -1160, 24, -1624, 2464, 1712, 4152, 5344, 3976, 2960,
+ -10488, -9544, -8104, -5832, -4608, -3472, -4152, -3560, -2824, -2432, 1000, 5216, 8184, 10328, 13400, 16880,
+ -16272, -1104, 2744, 1400, 1136, 1768, 1136, 776, 1232, 1040, 928, 8, 936, 1008, 1448, 1816,
+ -1328, 736, 320, 1208, 1824, 1536, 1064, 2656, 3136, 1408, -288, -2120, -1880, -1544, -3200, -3528,
+ 8896, 12112, 13000, 12592, 9880, 7096, 5096, 3976, -264, -4192, -7528, -12816, -14632, -15344, -11792, -6072,
+ -10376, -9040, -7304, -6064, -5168, -3880, -1520, 1064, 3592, 5512, 6664, 5456, 6560, 6544, 4664, 3288,
+ -920, -896, -2184, -3256, -3448, -3456, -1864, 568, 2016, 2568, 2880, 1688, 1776, 1696, 1400, 1440,
+ -4720, -10120, -2584, 1744, 2104, 1056, 1888, 1904, 1680, 1368, 1768, 496, 944, 1104, 768, 608,
+ 16256, 14832, 9552, 5128, 1712, 576, -1640, -2176, -3552, -4936, -5616, -6728, -6040, -5752, -6296, -5320,
+ -184, -1008, -3024, -4136, -5216, -3936, -3624, -4376, -4232, -3232, 576, 4216, 7160, 8144, 6144, 6728,
+ -368, -2000, -1056, 5944, 2240, -4560, -3328, 56, -152, 320, 1032, -224, 144, 784, 568, 592,
+ -1480, -1800, -1408, 1760, 6952, 8256, 2920, -1120, -1624, -2040, -2016, -2568, -1720, -1448, -1512, -1160,
+ 2664, 6728, 1408, 3608, 12192, 14000, 10448, 6336, 512, -5864, -6624, -12560, -8152, -6744, -8048, -9928,
+ -13144, -6696, -1600, 616, -2632, 528, 4400, 8960, 11480, 11720, 6280, -1864, -3816, -5160, -4912, -4168,
+ 9056, 9144, 7344, 1176, -3360, -2016, -2800, -6504, -8400, -7448, -6560, -4112, -88, 2680, 4856, 7016,
+ -3744, -2248, 8016, -104, -1416, -1088, 800, -120, -736, 56, 608, -488, -336, 72, 224, 504,
+ 2632, 7816, 5536, 952, -1432, -3464, -2552, -1216, -208, -848, -1208, -2080, -1416, -1040, -1064, -408,
+ -2368, -5768, -9744, -11552, -11408, -8432, -6872, -6064, -3680, -1736, 3160, 10064, 12880, 18576, 13312, 9632,
+ -7928, -3608, -1672, 1288, -2016, -608, 360, 1408, -7064, -632, 304, 1576, 8632, 12056, 4336, -6424,
+ 5312, 5368, 4720, 3544, 2936, 3752, 3848, 3816, 4296, 3704, 696, -5192, -6936, -8968, -11080, -9816,
+ -4792, 2248, 8104, 12752, 10440, 8984, 6280, 4520, 2280, -616, -3800, -9336, -11736, -12464, -8504, -4352,
+ -21240, -19008, -5088, -2328, -2720, 320, 3480, 3464, 4584, 4256, 5712, 6032, 3072, 4104, 6776, 8592,
+ 2568, 5384, -472, -6848, -2944, 1408, 2200, 248, -1216, -960, -656, -1040, 120, 528, 504, 1176,
+ -776, -4680, -12008, -3696, 1384, 4616, 1360, 304, 1304, 1816, 2016, 1336, 1840, 2104, 1720, 1360,
+ 7576, 7056, 5488, 5128, 4136, 3440, 2848, 656, -1136, -4208, -6088, -9664, -8864, -5648, -2272, 1552,
+ -6416, -4792, -3704, -1832, -1704, -296, 752, -224, -1064, 56, 1488, 824, 1304, 2472, 5160, 7952
+};
+
+/*Q15*/
+const Word16 ivas_sns_cdbks_side_tcx20_stage2_fx[32 * 16] = {
+ -456, 24, 560, 192, 1840, -2680, -9592, 128, 4608, 1272, 344, 1256, 1384, 680, 192, 248,
+ -2328, -3360, 1248, 3000, 3896, 4416, 1664, -3648, -4536, -6792, -8432, -4936, 1064, 2664, 5760, 10312,
+ 2344, 952, 640, 264, 768, 680, 1056, 720, 1136, 584, -1240, -4600, -7104, -3616, 1888, 5520,
+ -3544, -896, -2704, -2696, -2592, 1632, 3360, 7824, 8416, 1040, -5184, -4800, -264, -16, -472, 896,
+ -744, 920, 4624, -2216, -2408, 5328, -240, -2152, -936, -352, -784, 416, -192, -216, -464, -592,
+ -3192, -3016, -2016, -392, 216, 1368, 272, -576, -2792, -4120, -2064, 4488, 8256, 5024, 64, -1528,
+ -6632, 8864, 1944, 136, 728, -320, -872, -896, -1072, -552, -848, -48, -248, -312, 152, -32,
+ 2112, -8752, 4024, 840, -208, 144, 280, -56, 200, -232, -616, 392, 280, 328, 664, 600,
+ -24, -1232, -1192, -512, 184, -184, -96, 1072, 1560, 624, -344, 576, 416, 144, -440, -552,
+ 2272, 1736, 2000, 4384, 4400, 176, -3256, -6008, -7160, -2736, 664, 1928, 440, 376, 640, 136,
+ 120, -1656, -168, 6256, -6160, -1792, 16, -712, -64, 56, 136, 816, 728, 904, 888, 632,
+ 808, -136, -872, -2816, -2072, -2248, -2456, -1640, -2000, -200, 1848, 2896, 1928, 2208, 2544, 2208,
+ 4488, 2784, 2328, 1536, 808, 160, -352, -216, 464, -240, -1360, -888, -1360, -1992, -3040, -3120,
+ -5496, 2184, 5968, 2424, -656, 1816, 1280, -3936, -3536, 4040, 12432, 1072, -5288, -4992, -3456, -3848,
+ -432, -368, -1224, 88, -1520, -8008, 3272, 3624, 280, 336, 432, 1264, 544, 488, 632, 592,
+ 1448, 2544, -1144, -6016, 5152, 2008, -968, -616, -784, 24, -344, 288, -184, -304, -488, -616,
+ 4488, 368, -1096, -568, -2544, -4016, -2504, -568, 4672, 6984, 4776, 1056, -2744, -3944, -2496, -1880,
+ 968, -4008, -8112, 3112, 6192, 856, 424, 984, 296, -304, -840, 288, -80, -56, 288, -8,
+ -1264, -1272, -2912, -2256, 728, 3352, 4208, 2752, 2152, 2680, 2488, 1312, -1568, -3096, -3392, -3904,
+ 304, 1536, 2680, 1232, 208, -1256, -384, 9248, 912, -8256, -4200, 520, 376, -472, -1448, -1008,
+ 2088, 4072, 3128, -4384, -8616, -2072, 1088, 2160, 1592, 864, 192, 648, -96, -192, -24, -432,
+ -552, -1712, -1880, 264, -384, -2256, -2816, -536, -400, 1536, 5952, 8824, 4416, -800, -4176, -5480,
+ -720, -1768, -744, -16, 2360, 2736, 1856, -488, 928, 3080, 2008, -15984, -608, 5080, 1920, 352,
+ 12608, -1616, -2600, -824, -760, -680, 880, -16, -1720, -1112, -1520, -352, -592, -728, -528, -440,
+ -7816, -2128, -592, -112, 1320, 632, 600, 1008, 984, 936, 336, 1216, 704, 1144, 1152, 616,
+ 1264, 944, 848, 1416, 1144, -720, -1136, -640, -776, -3120, -4552, -1072, 448, 1928, 2120, 1896,
+ -488, 488, 416, 1488, 240, 2720, 5832, 1008, -3848, -2352, -1576, -232, -528, -800, -1088, -1272,
+ 2264, -1608, -7672, -10576, -5000, -928, 1928, 1832, 2824, 2688, 1712, 1792, 728, 2584, 4280, 3144,
+ -4408, -880, 3512, 5256, 4360, 1432, 288, 656, 1312, 576, -984, -816, -2224, -2840, -2504, -2744,
+ -640, -1960, -2008, 264, 1048, 2688, -1480, -8376, -904, 3448, 2056, 1536, 952, 1040, 1392, 936,
+ -1640, 2768, 8904, 1744, -2096, -4256, -2392, -1696, -1200, -48, -32, 712, 296, -24, -432, -608,
+ 2776, 6200, -5888, -520, -584, -712, 216, -248, -624, -352, -480, 464, 112, -184, -120, -56
+};
+
+/*Q15*/
+const Word16 *const ivas_sns_cdbks_side_tcx20_fx[SNS_MSVQ_NSTAGES_SIDE] = {
+ ivas_sns_cdbks_side_tcx20_stage1_fx, ivas_sns_cdbks_side_tcx20_stage2_fx
+};
+
+/*Q15*/
+const Word16 ivas_sns_cdbks_side_tcx10_stage1_fx[32 * 16] = {
+
+ -7848, -6656, -5840, -4312, -4040, -3144, -3504, -5424, -4896, -2480, 864, 3328, 5584, 9080, 12416, 16872,
+ 4224, 6824, 7512, 9824, 7952, 4744, 2576, 808, -2496, -6040, -8736, -10896, -9040, -4576, -1000, -1680,
+ -4640, -4360, -3664, -1224, -1248, 1688, 2408, 240, 1472, -768, -4040, -384, 9208, 7928, 2304, -4904,
+ 1752, 4024, 4568, 3272, 2560, 608, 1128, 3400, 2144, -992, -3240, -3264, -1968, -3920, -5976, -4080,
+ -1424, -1096, -2184, -2136, -1600, -3816, -6736, -6640, -5104, -32, 3400, 6944, 8000, 4760, 3232, 4416,
+ 1904, 7392, 3336, -2824, -2448, 1712, 1720, -1384, -2312, -1216, -792, -1032, -1048, -1328, -1248, -432,
+ 656, -1096, -4768, -13792, -6424, 1248, 872, 536, 1256, 1896, 2216, 2648, 2992, 3336, 3928, 4496,
+ 4480, 10016, 15456, 17952, 13048, 8872, 5768, 3016, -432, -5624, -10376, -13808, -17456, -15040, -8984, -6896,
+ -12776, -12320, -12112, -9552, -8552, -6528, -4960, -2968, -1336, 4376, 9872, 12640, 13320, 10192, 9832, 10872,
+ 11504, 17136, 13720, 4704, -1232, -4304, -6024, -5920, -5168, -5728, -5584, -4984, -2704, -2168, -2112, -1136,
+ -21904, -10168, -7024, -3928, -3384, 2632, 7144, 6840, 3328, 1080, -1440, 2560, 2400, 2544, 6792, 12520,
+ -5624, -3840, -1144, 1976, 5928, 11032, 12960, 8904, 4208, -1208, -5624, -6976, -6816, -5680, -4096, -4008,
+ -6144, -13096, -584, 3296, 1888, 928, 1800, 1400, 1360, 1536, 1368, 1792, 2032, 1032, 440, 936,
+ 11408, 7680, -1800, -5968, -9432, -10216, -9208, -6496, -5136, -2704, 992, 4472, 7248, 6808, 5392, 6960,
+ -1896, -3464, 2944, 9976, 6208, 4840, 2976, -688, -1752, -1456, -2336, -2912, -2616, -2816, -3208, -3800,
+ 5776, 8536, 7128, 6888, 6600, 9088, 7080, -40, -360, -3832, -7640, -5192, -2648, -2912, -11704, -16760,
+ -12496, -15912, -11792, -5288, -856, 296, -416, 1320, 3128, 5064, 5352, 6272, 6928, 6656, 5896, 5848,
+ 1912, 2064, 1344, 1048, 2592, 2200, -944, -1656, -816, -5840, -10576, -5456, -176, 1808, 3912, 8560,
+ 1568, -1384, -7912, -1256, 1728, 2248, 1904, 392, -456, -360, 656, 904, 1016, 760, 464, -264,
+ -120, 48, 448, 0, 696, 1096, 488, 152, 1864, 4400, 2848, -168, -2384, -3120, -3592, -2656,
+ -5232, -3632, -4264, -2352, -2128, -1848, -1512, -400, 1592, 1208, -16, -800, -424, 3016, 7024, 9784,
+ 18344, 5184, -408, -1416, -1904, -488, -704, -1256, -1104, -1232, -2264, -2504, -2088, -2120, -2776, -3272,
+ -1304, -1072, -992, -1688, -1168, -1344, -1280, 584, 1688, 456, -1464, -2000, -400, 2392, 4040, 3568,
+ 14784, 15304, 12752, 7616, 5384, 5928, 6856, 1112, -4496, -9040, -13088, -12584, -10176, -9328, -9488, -1528,
+ -2888, -7528, -13744, -16216, -13232, -9088, -7384, -4312, -1464, 3944, 8176, 10192, 17080, 15872, 10728, 9872,
+ 10880, 9704, 5888, 2192, 3280, 4544, 1144, -1072, -3952, -6872, -9712, -6848, -2696, -5512, -5248, 4304,
+ -14480, 576, 2424, 1096, 1448, 1544, 992, 1336, 1344, 752, 152, 616, 936, 616, -16, 680,
+ -12000, -7664, -2680, -496, -1608, 2592, 7576, 9280, 12576, 9576, 3256, -288, -3216, -5392, -6208, -5304,
+ -5584, -6016, -6232, -5184, -6632, -7168, -4296, 328, 3936, 8224, 8200, 6736, 4760, 4576, 3400, 952,
+ 2288, 2368, 5984, 832, -8112, -9376, -3656, -1216, 120, 1048, 1440, 1880, 2560, 2360, 936, 536,
+ 2568, 4440, 5712, 5072, 4120, -312, -4944, -6440, -6424, -3376, -1504, -856, 664, 784, 432, 48,
+ 8304, 7392, 7344, 5608, 5952, 5536, 5408, 6632, 5584, 848, -5448, -7904, -10480, -13136, -12536, -9104
+};
+
+/*Q15*/
+const Word16 ivas_sns_cdbks_side_tcx10_stage2_fx[8 * 16] = {
+ -4584, -808, 4152, 912, 2192, 4200, 2456, -648, -1912, -2472, -2144, -1792, -1424, -208, 1120, 968,
+ -2200, -3752, -3208, -2992, -3992, -328, 3600, 3784, 1968, 1248, 672, 568, 792, 928, 1256, 1656,
+ 1808, 1000, 1280, 1904, 704, 1064, 1312, -288, -1832, -784, 1216, 2080, 888, -2416, -4176, -3776,
+ 3672, 6576, 1488, -3552, -4648, -2792, -1064, 1112, 1448, 216, -408, -608, -440, -344, -256, -400,
+ -1368, -2416, -4856, 696, 5248, 3904, 1832, 2648, 4112, 1776, -1008, -1336, -1976, -2336, -2544, -2376,
+ -2440, -1352, -1328, -2248, -1384, -1264, -1680, -2912, -1816, 1208, 2960, 2192, 2920, 4296, 2664, 176,
+ -1736, 1104, 5248, 5632, 808, -4352, -4568, -1376, 224, 664, 280, 48, -376, -992, -736, 128,
+ 6848, -368, -2784, -360, 1080, -432, -1896, -2328, -2192, -1848, -1568, -1144, -392, 1072, 2680, 3616
+};
+
+const Word16 *const ivas_sns_cdbks_side_tcx10_fx[SNS_MSVQ_NSTAGES_SIDE] = {
+ ivas_sns_cdbks_side_tcx10_stage1_fx, ivas_sns_cdbks_side_tcx10_stage2_fx
+};
+
+/*----------------------------------------------------------------------*
+ * MC ParamUpmix ROM tables
+ *-----------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+const ACPL_QUANT_TABLE_FX ivas_mc_paramupmix_alpha_quant_table_fx = {
+ 33, /* nquant */
+ 16, /* offset */
+ {
+ -536870912, -485700416, -439563072, -398458880, -362387872, -331350016, -305345344,
+ -284373824, -268435456, -252497104, -231525584, -205520896, -174483040, -138412032,
+ -97307856, -51170508, 0, 51170508, 97307856, 138412032, 174483040,
+ 205520896, 231525584, 252497104, 268435456, 284373824, 305345344, 331350016,
+ 362387872, 398458880, 439563072, 485700416, 536870912, 0, 0 } /* data in Q28 */
+};
+
+const ACPL_QUANT_TABLE_FX ivas_mc_paramupmix_beta_quant_table_fx[9] = {
+ {
+ 9, /* nquant */
+ 0, /* offset */
+ { 0, 63753420, 147639504, 251658240, 375809632, 520093696, 684510400, 869059776, 1073741824 } /* data in Q28 */
+ },
+ {
+ /* Beta #2 */
+ 9, /* nquant */
+ 0, /* offset */
+ { 0, 54638668, 126531672, 215678976, 322080672, 445736544, 586646912, 744811456, 920230272 } /* data in Q28 */
+ },
+ {
+ /* Beta #3 */
+ 9, /* nquant */
+ 0, /* offset */
+ { 0, 46420464, 107500024, 183238656, 273636384, 378693184, 498409216, 632784256, 781818240 } /* data in Q28 */
+ },
+ {
+ /* Beta #4 */
+ 9, /* nquant */
+ 0, /* offset */
+ { 0, 39098780, 90544544, 154337280, 230477024, 318963584, 419797344, 532978048, 658505728 } /* data in Q28 */
+ },
+ {
+ /* Beta #5 */
+ 9, /* nquant */
+ 0, /* offset */
+ { 0, 32673642, 75665248, 128974864, 192602432, 266548032, 350811584, 445393216, 550292672 } /* data in Q28 */
+ },
+ {
+ /* Beta #6 */
+ 9, /* nquant */
+ 0, /* offset */
+ { 0, 27144998, 62862136, 107151352, 160012704, 221446144, 291451648, 370029408, 457179136 } /* data in Q28 */
+ },
+ {
+ /* Beta #7 */
+ 9, /* nquant */
+ 0, /* offset */
+ { 0, 22512928, 52135212, 88866816, 132707776, 183658096, 241717760, 306886688, 379165088 } /* data in Q28 */
+ },
+ {
+ /* Beta #8 */
+ 9, /* nquant */
+ 0, /* offset */
+ { 0, 18777374, 43484452, 74121200, 110687696, 153183840, 201609712, 255965264, 316250528 } /* data in Q28 */
+ },
+ {
+ /* Beta #9 */
+ 9, /* nquant */
+ 0, /* offset */
+ { 0, 15938355, 36909876, 62914560, 93952408, 130023424, 171127600, 217264944, 268435456 } /* data in Q28 */
+ }
+};
+#endif
+/* Q Factor is 31*/
+const Word32 ivas_han_win_48k_fx[L_FRAME32k] = {
+ 5760, 22976, 51712, 91904, 143552, 206784, 281408, 367552, 465216,
+ 574272, 694912, 826944, 970496, 1125504, 1292032, 1470016, 1659456,
+ 1860352, 2072704, 2296576, 2531904, 2778624, 3036864, 3306560, 3587648,
+ 3880256, 4184256, 4499712, 4826624, 5164992, 5514752, 5875968, 6248576,
+ 6632640, 7028096, 7434944, 7853248, 8282880, 8723968, 9176448, 9640320,
+ 10115584, 10602176, 11100224, 11609536, 12130304, 12662400, 13205824, 13760576,
+ 14326720, 14904192, 15492928, 16093056, 16704512, 17327232, 17961216, 18606592,
+ 19263168, 19931072, 20610240, 21300672, 22002368, 22715328, 23439488, 24174912,
+ 24921600, 25679424, 26448512, 27228800, 28020288, 28822976, 29636864, 30461888,
+ 31298048, 32145344, 33003840, 33873472, 34754176, 35646016, 36548992, 37463040,
+ 38388224, 39324416, 40271680, 41230016, 42199424, 43179840, 44171264, 45173696,
+ 46187200, 47211648, 48247104, 49293504, 50350848, 51419200, 52498432, 53588608,
+ 54689664, 55801664, 56924544, 58058304, 59202944, 60358400, 61524736, 62701888,
+ 63889856, 65088640, 66298176, 67518528, 68749632, 69991488, 71244096, 72507392,
+ 73781440, 75066176, 76361536, 77667648, 78984384, 80311744, 81649728, 82998400,
+ 84357568, 85727424, 87107776, 88498688, 89900160, 91312128, 92734656, 94167680,
+ 95611136, 97065088, 98529472, 100004288, 101489536, 102985152, 104491200, 106007552,
+ 107534336, 109071424, 110618816, 112176512, 113744512, 115322816, 116911296, 118510080,
+ 120119040, 121738240, 123367552, 125007104, 126656768, 128316608, 129986496, 131666496,
+ 133356608, 135056768, 136766976, 138487232, 140217408, 141957632, 143707840, 145467968,
+ 147238016, 149017984, 150807872, 152607616, 154417216, 156236672, 158065920, 159904960,
+ 161753728, 163612352, 165480640, 167358720, 169246464, 171143808, 173050880, 174967552,
+ 176893888, 178829760, 180775296, 182730304, 184694848, 186668928, 188652480, 190645504,
+ 192648000, 194659904, 196681216, 198711936, 200752000, 202801344, 204860032, 206928064,
+ 209005376, 211091904, 213187648, 215292672, 217406784, 219530048, 221662528, 223804096,
+ 225954752, 228114496, 230283264, 232461056, 234647872, 236843584, 239048320, 241262016,
+ 243484544, 245716032, 247956288, 250205440, 252463424, 254730112, 257005632, 259289856,
+ 261582784, 263884416, 266194688, 268513664, 270841216, 273177344, 275522048, 277875264,
+ 280237056, 282607296, 284986048, 287373184, 289768768, 292172672, 294584960, 297005632,
+ 299434560, 301871808, 304317312, 306771072, 309233024, 311703040, 314181312, 316667712,
+ 319162240, 321664832, 324175424, 326694080, 329220672, 331755200, 334297728, 336848192,
+ 339406528, 341972672, 344546688, 347128448, 349718080, 352315328, 354920384, 357533120,
+ 360153536, 362781568, 365417152, 368060352, 370711168, 373369408, 376035200, 378708416,
+ 381389120, 384077120, 386772608, 389475456, 392185536, 394902976, 397627648, 400359552,
+ 403098624, 405844928, 408598400, 411358976, 414126592, 416901312, 419683008, 422471680,
+ 425267392, 428070016, 430879552, 433695936, 436519232, 439349312, 442186112, 445029696,
+ 447880064, 450737088, 453600832, 456471168, 459348160, 462231616, 465121600, 468018176,
+ 470921280, 473830784, 476746688, 479668928, 482597632, 485532608, 488473856, 491421376,
+ 494375168, 497335168, 500301184, 503273472, 506251840, 509236288, 512226752, 515223296,
+ 518225728, 521234048, 524248320, 527268608, 530294592, 533326528, 536364096, 539407552,
+ 542456576, 545511296, 548571712, 551637888, 554709440, 557786624, 560869376, 563957504,
+ 567051264, 570150272, 573254656, 576364544, 579479616, 582600064, 585725696, 588856704,
+ 591992704, 595134080, 598280256, 601431680, 604588160, 607749632, 610916224, 614087680,
+ 617264128, 620445312, 623631488, 626822336, 630017984, 633218496, 636423616, 639633408,
+ 642847872, 646067008, 649290624, 652518784, 655751552, 658988672, 662230400, 665476352,
+ 668726784, 671981504, 675240576, 678503808, 681771264, 685042944, 688318784, 691598848,
+ 694882880, 698171072, 701463168, 704759296, 708059392, 711363328, 714671296, 717982976,
+ 721298560, 724617728, 727940864, 731267392, 734597760, 737931776, 741269376, 744610624,
+ 747955200, 751303488, 754655040, 758009984, 761368512, 764730240, 768095360, 771463616,
+ 774835200, 778209792, 781587840, 784968832, 788352896, 791740160, 795130304, 798523584,
+ 801919616, 805318784, 808720640, 812125312, 815532928, 818943168, 822356288, 825771840,
+ 829190272, 832611200, 836034816, 839460928, 842889472, 846320640, 849754112, 853190080,
+ 856628352, 860068992, 863511808, 866957056, 870404352, 873853696, 877305408, 880759104,
+ 884215040, 887672832, 891132736, 894594496, 898058112, 901523840, 904991232, 908460544,
+ 911931456, 915404288, 918878528, 922354560, 925832384, 929311616, 932792512, 936274816,
+ 939758720, 943243904, 946730624, 950218560, 953707840, 957198528, 960690368, 964183488,
+ 967677568, 971172992, 974669440, 978166912, 981665536, 985164992, 988665600, 992166912,
+ 995669248, 999172288, 1002676288, 1006180864, 1009686208, 1013192384, 1016698880, 1020206336,
+ 1023714176, 1027222656, 1030731584, 1034241024, 1037750784, 1041260928, 1044771584, 1048282368,
+ 1051793600, 1055304896, 1058816512, 1062328192, 1065839872, 1069351872, 1072863808, 1076375808,
+ 1079887744, 1083399680, 1086911488, 1090423168, 1093934592, 1097445760, 1100956928, 1104467584,
+ 1107977984, 1111488000, 1114997504, 1118506624, 1122015232, 1125523456, 1129031040, 1132538112,
+ 1136044544, 1139550336, 1143055360, 1146559616, 1150063104, 1153565696, 1157067648, 1160568576,
+ 1164068480, 1167567488, 1171065600, 1174562560, 1178058496, 1181553408, 1185046912, 1188539520,
+ 1192030720, 1195520768, 1199009408, 1202496768, 1205982720, 1209467008, 1212950144, 1216431744,
+ 1219911936, 1223390336, 1226867328, 1230342528, 1233816192, 1237288064, 1240758144, 1244226560,
+ 1247693056, 1251157760, 1254620416, 1258081152, 1261539968, 1264996864, 1268451712, 1271904384,
+ 1275355008, 1278803456, 1282249728, 1285693696, 1289135488, 1292574848, 1296011904, 1299446784,
+ 1302878976, 1306308736, 1309736064, 1313160960, 1316583296, 1320002944, 1323420032, 1326834304,
+ 1330246144, 1333655040, 1337061120, 1340464512, 1343865088, 1347262592, 1350657152, 1354048768,
+ 1357437440, 1360823168, 1364205824, 1367585280, 1370961664, 1374334720, 1377704704, 1381071360,
+ 1384434816, 1387794944, 1391151616, 1394504960, 1397854976, 1401201152, 1404544000, 1407883520,
+ 1411219328, 1414551552, 1417880064, 1421204992, 1424526080, 1427843456, 1431157120, 1434466944,
+ 1437772928, 1441074944, 1444373120, 1447667072, 1450957312, 1454243328, 1457525248, 1460803328,
+ 1464077056, 1467346688, 1470612096, 1473873408, 1477130240, 1480382848, 1483630976, 1486874752,
+ 1490114048, 1493348992, 1496579584, 1499805440, 1503026944, 1506243584, 1509455744, 1512663296,
+ 1515866112, 1519064192, 1522257536, 1525446144, 1528629760, 1531808512, 1534982272, 1538151296,
+ 1541315328, 1544474368, 1547628288, 1550777216, 1553921024, 1557059840, 1560193152, 1563321472,
+ 1566444672, 1569562240, 1572674816, 1575782016, 1578883584, 1581980032, 1585070848, 1588156416,
+ 1591236352, 1594310912, 1597379584, 1600442880, 1603500544, 1606552576, 1609598592
+};
+
+/* Q Factor is 31*/
+const Word32 ivas_han_win_32k_fx[L_FRAME32k] = {
+ 12928, 51648, 116224, 206656, 322880, 464960, 632832, 826496, 1046016,
+ 1291328, 1562496, 1859392, 2182080, 2530560, 2904832, 3304832, 3730560,
+ 4182080, 4659328, 5162304, 5690944, 6245312, 6825344, 7431104, 8062464,
+ 8719488, 9402112, 10110336, 10844160, 11603520, 12388480, 13198976, 14034944,
+ 14896448, 15783424, 16695808, 17633664, 18596928, 19585536, 20599552, 21638912,
+ 22703552, 23793472, 24908672, 26049088, 27214720, 28405504, 29621504, 30862592,
+ 32128704, 33419968, 34736192, 36077440, 37443712, 38834816, 40250880, 41691776,
+ 43157504, 44648064, 46163328, 47703360, 49268032, 50857408, 52471296, 54109824,
+ 55772928, 57460416, 59172416, 60908800, 62669568, 64454656, 66264064, 68097664,
+ 69955456, 71837440, 73743488, 75673600, 77627712, 79605824, 81607808, 83633664,
+ 85683392, 87756864, 89854080, 91974912, 94119360, 96287424, 98478976, 100694016,
+ 102932416, 105194240, 107479296, 109787648, 112119232, 114473856, 116851584, 119252352,
+ 121676096, 124122688, 126592192, 129084480, 131599488, 134137088, 136697408, 139280192,
+ 141885440, 144513152, 147163264, 149835584, 152530176, 155246848, 157985728, 160746560,
+ 163529408, 166334144, 169160704, 172009024, 174879040, 177770752, 180683904, 183618624,
+ 186574720, 189552128, 192550848, 195570752, 198611840, 201673920, 204756992, 207860992,
+ 210985792, 214131392, 217297600, 220484480, 223691840, 226919680, 230167936, 233436416,
+ 236725120, 240033984, 243362880, 246711744, 250080512, 253469120, 256877440, 260305472,
+ 263753024, 267220096, 270706496, 274212288, 277737280, 281281408, 284844672, 288426880,
+ 292027904, 295647808, 299286464, 302943744, 306619456, 310313728, 314026368, 317757248,
+ 321506304, 325273472, 329058688, 332861760, 336682688, 340521408, 344377664, 348251520,
+ 352142784, 356051456, 359977344, 363920448, 367880640, 371857792, 375851840, 379862656,
+ 383890112, 387934272, 391994880, 396071936, 400165248, 404274816, 408400384, 412542016,
+ 416699584, 420872960, 425062016, 429266688, 433486912, 437722368, 441973248, 446239360,
+ 450520576, 454816704, 459127808, 463453696, 467794112, 472149248, 476518784, 480902784,
+ 485300992, 489713344, 494139840, 498580032, 503034304, 507502208, 511983808, 516478848,
+ 520987392, 525509120, 530044032, 534592000, 539153088, 543726912, 548313600, 552912832,
+ 557524608, 562148736, 566785408, 571434048, 576094784, 580767616, 585452224, 590148608,
+ 594856576, 599576192, 604307072, 609049344, 613802752, 618567296, 623342592, 628128896,
+ 632925888, 637733504, 642551552, 647380096, 652218752, 657067648, 661926400, 666795264,
+ 671673856, 676562176, 681459968, 686367232, 691283648, 696209536, 701144320, 706088192,
+ 711040768, 716002176, 720972224, 725950656, 730937472, 735932480, 740935808, 745947008,
+ 750966144, 755992960, 761027456, 766069504, 771118976, 776175680, 781239680, 786310528,
+ 791388416, 796472896, 801564288, 806662080, 811766400, 816876928, 821993792, 827116544,
+ 832245248, 837379776, 842520064, 847665856, 852817152, 857973696, 863135424, 868302208,
+ 873474048, 878650560, 883831808, 889017728, 894207936, 899402624, 904601216, 909804160,
+ 915010944, 920221696, 925435904, 930653952, 935875200, 941099776, 946327616, 951558592,
+ 956792384, 962029120, 967268416, 972510272, 977754624, 983001344, 988250112, 993501120,
+ 998753856, 1004008576, 1009264704, 1014522624, 1019781888, 1025042560, 1030304256, 1035566976,
+ 1040830784, 1046095232, 1051360384, 1056626048, 1061892224, 1067158592, 1072425280, 1077691776,
+ 1082958208, 1088224512, 1093490560, 1098755968, 1104020736, 1109284864, 1114548224, 1119810432,
+ 1125071616, 1130331520, 1135590272, 1140847232, 1146102912, 1151356544, 1156608512, 1161858304,
+ 1167106048, 1172351616, 1177594624, 1182835200, 1188073344, 1193308544, 1198541056, 1203770368,
+ 1208996736, 1214219648, 1219439232, 1224655488, 1229867904, 1235076736, 1240281472, 1245482240,
+ 1250679040, 1255871360, 1261059456, 1266243072, 1271421952, 1276596224, 1281765504, 1286929920,
+ 1292089088, 1297243008, 1302391552, 1307534592, 1312672000, 1317803520, 1322929280, 1328049152,
+ 1333162752, 1338270336, 1343371264, 1348465920, 1353553920, 1358635264, 1363709568, 1368776960,
+ 1373837312, 1378890496, 1383936256, 1388974336, 1394004992, 1399028224, 1404043264, 1409050496,
+ 1414049792, 1419040640, 1424023424, 1428997632, 1433963392, 1438920448, 1443868672, 1448808064,
+ 1453738496, 1458659328, 1463571328, 1468473856, 1473366912, 1478250240, 1483124096, 1487987968,
+ 1492841856, 1497685632, 1502519296, 1507342592, 1512155392, 1516957696, 1521749504, 1526530176,
+ 1531299968, 1536059008, 1540806912, 1545543424, 1550268672, 1554982528, 1559684864, 1564375168,
+ 1569053952, 1573720832, 1578375680, 1583018240, 1587648640, 1592266496, 1596872192, 1601464960,
+ 1606045312, 1610612736, 1615167488, 1619708672, 1624237184, 1628752384, 1633254272, 1637742464,
+ 1642217216, 1646678400, 1651125504, 1655558784, 1659978240, 1664383616, 1668774784, 1673151488,
+ 1677513856, 1681861760, 1686194816, 1690513408, 1694817024, 1699105792, 1703379200, 1707637760,
+ 1711880960, 1716108800, 1720321152, 1724518144, 1728699392, 1732865024, 1737014400, 1741148160,
+ 1745265792, 1749367296, 1753452288, 1757521152, 1761573632, 1765609344, 1769628416, 1773630976,
+ 1777616640, 1781585408, 1785536768, 1789471488, 1793388800, 1797288832, 1801171328, 1805036544,
+ 1808883968, 1812713728, 1816525824, 1820320000, 1824096000, 1827854208, 1831594112, 1835315968,
+ 1839019520, 1842704384, 1846370944, 1850018944, 1853648256, 1857258624, 1860850432, 1864423168,
+ 1867976960, 1871511296, 1875026688, 1878522880, 1881999616, 1885456896, 1888894720, 1892312832,
+ 1895711488, 1899089920, 1902448896, 1905787904, 1909106688, 1912405504, 1915684096, 1918942592,
+ 1922180480, 1925398016, 1928595200, 1931771904, 1934927616, 1938062848, 1941177344, 1944270848,
+ 1947343360, 1950395136, 1953425664, 1956434944, 1959422976, 1962389632, 1965335040, 1968259072,
+ 1971161344, 1974042368, 1976901504, 1979739008, 1982554624, 1985348352, 1988120320, 1990870272,
+ 1993597952, 1996303616, 1998987264, 2001648384, 2004287104, 2006903552, 2009497728, 2012069376,
+ 2014618112, 2017144576, 2019648256, 2022129024, 2024587136, 2027022336, 2029434624, 2031823872,
+ 2034190080, 2036533120, 2038853120, 2041149696, 2043423232, 2045673344, 2047900160, 2050103296,
+ 2052283136, 2054439552, 2056572160, 2058681216, 2060766464, 2062828160, 2064865920, 2066879744,
+ 2068869888, 2070835968, 2072778240, 2074696192, 2076590336, 2078460160, 2080305792, 2082127360,
+ 2083924608, 2085697536, 2087446016, 2089170304, 2090870144, 2092545280, 2094196096, 2095822336,
+ 2097424128, 2099001088, 2100553472, 2102081024, 2103584000, 2105062144, 2106515456, 2107943936,
+ 2109347584, 2110726272, 2112080000, 2113408768, 2114712448, 2115991168, 2117244672, 2118473216,
+ 2119676672, 2120854912, 2122007936, 2123135744, 2124238336, 2125315584, 2126367616, 2127394304,
+ 2128395520, 2129371648, 2130322048, 2131247232, 2132146944, 2133021184, 2133869824, 2134693120,
+ 2135490816, 2136263040, 2137009664, 2137730688, 2138426112, 2139095936, 2139740160, 2140358656,
+ 2140951552, 2141518720, 2142060288, 2142576128, 2143066112, 2143530496, 2143969152, 2144382080,
+ 2144769280, 2145130496, 2145466112, 2145775872, 2146060032, 2146318208, 2146550528, 2146757120,
+ 2146937984, 2147092992, 2147222016, 2147325440, 2147403008, 2147454592, 2147480448
+};
+
+/* Q Factor is 31*/
+const Word32 ivas_han_win_16k_fx[L_FRAME32k] = {
+ 51584, 206336, 464192, 825216, 1289344, 1856512, 2526592, 3299648, 4175552,
+ 5154240, 6235584, 7419520, 8705856, 10094592, 11585472, 13178432, 14873280,
+ 16669824, 18568000, 20567552, 22668288, 24869952, 27172480, 29575488, 32078848,
+ 34682304, 37385600, 40188480, 43090624, 46091840, 49191808, 52390144, 55686656,
+ 59081024, 62572800, 66161792, 69847552, 73629824, 77508160, 81482176, 85551552,
+ 89715904, 93974784, 98327808, 102774528, 107314560, 111947456, 116672768, 121490048,
+ 126398720, 131398528, 136488832, 141669184, 146939136, 152298048, 157745600, 163281088,
+ 168904064, 174614016, 180410304, 186292480, 192259904, 198312000, 204448256, 210667968,
+ 216970688, 223355584, 229822336, 236370112, 242998400, 249706432, 256493632, 263359424,
+ 270303040, 277323904, 284421184, 291594368, 298842688, 306165440, 313562048, 321031552,
+ 328573440, 336186944, 343871360, 351625792, 359449600, 367342144, 375302528, 383329984,
+ 391423744, 399583168, 407807232, 416095424, 424446720, 432860480, 441335680, 449871744,
+ 458467776, 467122752, 475836160, 484606976, 493434496, 502317568, 511255744, 520247936,
+ 529293184, 538390784, 547539840, 556739456, 565988800, 575286848, 584632832, 594025792,
+ 603464960, 612949248, 622477568, 632049536, 641663872, 651319808, 661016192, 670752128,
+ 680527040, 690339584, 700189056, 710074240, 719994624, 729948800, 739936128, 749955328,
+ 760005760, 770086400, 780196224, 790334336, 800499328, 810690816, 820907648, 831148608,
+ 841412992, 851699584, 862007680, 872335936, 882683648, 893049664, 903433024, 913832832,
+ 924248064, 934677504, 945120256, 955575552, 966042176, 976519040, 987005248, 997499904,
+ 1008001792, 1018510080, 1029023552, 1039541440, 1050062528, 1060585984, 1071110720, 1081635456,
+ 1092159616, 1102681984, 1113201664, 1123717504, 1134228480, 1144733696, 1155232256, 1165722752,
+ 1176204288, 1186676224, 1197137280, 1207586432, 1218022656, 1228445184, 1238852864, 1249244416,
+ 1259619328, 1269976192, 1280314368, 1290632832, 1300930304, 1311205888, 1321458432, 1331687552,
+ 1341891840, 1352070400, 1362221952, 1372346112, 1382441472, 1392506880, 1402541952, 1412545280,
+ 1422516224, 1432453632, 1442356608, 1452224000, 1462054912, 1471848832, 1481604480, 1491320832,
+ 1500997120, 1510632320, 1520225536, 1529775744, 1539282176, 1548744192, 1558160256, 1567529728,
+ 1576852096, 1586125824, 1595350272, 1604524800, 1613648128, 1622719872, 1631738624, 1640703744,
+ 1649614592, 1658469888, 1667269376, 1676011520, 1684695808, 1693321472, 1701887616, 1710393344,
+ 1718837760, 1727220480, 1735540352, 1743796480, 1751988480, 1760115200, 1768175616, 1776169856,
+ 1784096256, 1791954688, 1799744000, 1807463424, 1815112576, 1822690048, 1830195968, 1837629184,
+ 1844988928, 1852274688, 1859485440, 1866620672, 1873679872, 1880662016, 1887566976, 1894393600,
+ 1901141248, 1907809536, 1914397696, 1920904960, 1927330816, 1933674624, 1939936000, 1946114048,
+ 1952208256, 1958218240, 1964142848, 1969982336, 1975735552, 1981401984, 1986981376, 1992472832,
+ 1997876224, 2003190656, 2008415744, 2013551360, 2018596352, 2023550720, 2028413824, 2033185152,
+ 2037864192, 2042450688, 2046944256, 2051344128, 2055650048, 2059861888, 2063978752, 2068000512,
+ 2071926784, 2075757056, 2079491072, 2083128576, 2086668928, 2090112128, 2093457408, 2096705024,
+ 2099854080, 2102904832, 2105856512, 2108709120, 2111462144, 2114115584, 2116668928, 2119122176,
+ 2121475072, 2123727104, 2125878528, 2127928576, 2129877504, 2131724800, 2133470464, 2135114496,
+ 2136656384, 2138096128, 2139433728, 2140668928, 2141801472, 2142831616, 2143758848, 2144583424,
+ 2145304960, 2145923584, 2146439168, 2146851840, 2147161344, 2147367680, 2147470848, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0
+};
+
+/* Q Factor is 30 */
+const Word32 ivas_sine_delay_32_fx[32] = {
+ 52686016, 105245104, 157550640, 209476640, 260898000, 311690784, 361732736, 410903232, 459083776,
+ 506158400, 552013632, 596539008, 639627264, 681174656, 721080960, 759250112, 795590272,
+ 830013632, 862437504, 892783744, 920979136, 946955776, 970651136, 992008064, 1010975232,
+ 1027506880, 1041563136, 1053110208, 1062120192, 1068571456, 1072448448, 1073741824
+};
+
+/* Q Factor is 30 */
+const Word32 ivas_sine_frame_len_640_del_32_fx[577] = {
+ 1073737856,
+ 1073725888, 1073705984, 1073678144, 1073642368, 1073598592, 1073546880, 1073487168, 1073419584,
+ 1073343936, 1073260416, 1073168896, 1073069440, 1072962048, 1072846720, 1072723392, 1072592128,
+ 1072452928, 1072305792, 1072150656, 1071987648, 1071816640, 1071637696, 1071450816, 1071256000,
+ 1071053248, 1070842560, 1070623936, 1070397312, 1070162880, 1069920448, 1069670080, 1069411776,
+ 1069145536, 1068871424, 1068589376, 1068299392, 1068001472, 1067695680, 1067381952, 1067060288,
+ 1066730752, 1066393344, 1066047936, 1065694720, 1065333568, 1064964544, 1064587584, 1064202752,
+ 1063810048, 1063409472, 1063000960, 1062584576, 1062160384, 1061728256, 1061288320, 1060840448,
+ 1060384768, 1059921216, 1059449792, 1058970496, 1058483392, 1057988416, 1057485632, 1056974976,
+ 1056456512, 1055930240, 1055396096, 1054854144, 1054304384, 1053746816, 1053181440, 1052608256,
+ 1052027200, 1051438400, 1050841856, 1050237504, 1049625280, 1049005376, 1048377664, 1047742144,
+ 1047098944, 1046447936, 1045789184, 1045122624, 1044448384, 1043766400, 1043076672, 1042379200,
+ 1041674048, 1040961088, 1040240512, 1039512192, 1038776128, 1038032384, 1037280960, 1036521856,
+ 1035755008, 1034980544, 1034198464, 1033408640, 1032611200, 1031806016, 1030993280, 1030172864,
+ 1029344768, 1028509120, 1027665856, 1026814912, 1025956416, 1025090240, 1024216576, 1023335232,
+ 1022446400, 1021549888, 1020645824, 1019734208, 1018815104, 1017888384, 1016954112, 1016012288,
+ 1015062912, 1014106112, 1013141760, 1012169856, 1011190464, 1010203584, 1009209280, 1008207424,
+ 1007198144, 1006181376, 1005157120, 1004125440, 1003086336, 1002039744, 1000985792, 999924352,
+ 998855552, 997779328, 996695744, 995604736, 994506368, 993400640, 992287552, 991167104,
+ 990039296, 988904128, 987761664, 986611904, 985454784, 984290304, 983118592, 981939648,
+ 980753408, 979559872, 978359104, 977151040, 975935744, 974713216, 973483456, 972246528,
+ 971002304, 969750976, 968492480, 967226688, 965953792, 964673728, 963386496, 962092288,
+ 960790784, 959482176, 958166464, 956843648, 955513792, 954176832, 952832768, 951481600,
+ 950123456, 948758272, 947386048, 946006720, 944620480, 943227264, 941826944, 940419776,
+ 939005568, 937584384, 936156224, 934721152, 933279232, 931830336, 930374528, 928911808,
+ 927442176, 925965760, 924482432, 922992320, 921495296, 919991424, 918480832, 916963328,
+ 915439040, 913907968, 912370176, 910825600, 909274240, 907716160, 906151360, 904579840,
+ 903001664, 901416768, 899825216, 898226944, 896622016, 895010432, 893392256, 891767424,
+ 890136000, 888497984, 886853376, 885202176, 883544448, 881880128, 880209344, 878532032,
+ 876848192, 875157824, 873460992, 871757696, 870047872, 868331648, 866608960, 864879872,
+ 863144384, 861402496, 859654208, 857899584, 856138624, 854371264, 852597632, 850817600,
+ 849031296, 847238720, 845439808, 843634688, 841823296, 840005632, 838181760, 836351680,
+ 834515456, 832672960, 830824384, 828969600, 827108672, 825241600, 823368448, 821489152,
+ 819603840, 817712384, 815814912, 813911360, 812001728, 810086208, 808164608, 806237056,
+ 804303424, 802363904, 800418496, 798467072, 796509760, 794546560, 792577408, 790602432,
+ 788621568, 786634880, 784642368, 782644096, 780640000, 778630016, 776614336, 774592896,
+ 772565696, 770532864, 768494208, 766449856, 764399872, 762344192, 760282944, 758215936,
+ 756143424, 754065280, 751981504, 749892160, 747797248, 745696832, 743590848, 741479424,
+ 739362432, 737240000, 735112128, 732978752, 730839936, 728695744, 726546176, 724391168,
+ 722230784, 720065088, 717894080, 715717696, 713536000, 711349056, 709156864, 706959360,
+ 704756672, 702548672, 700335488, 698117184, 695893696, 693665024, 691431168, 689192192,
+ 686948224, 684699008, 682444864, 680185600, 677921280, 675651968, 673377536, 671098176,
+ 668813888, 666524608, 664230464, 661931328, 659627264, 657318400, 655004544, 652685952,
+ 650362432, 648034112, 645701056, 643363136, 641020480, 638673088, 636320896, 633964032,
+ 631602496, 629236224, 626865344, 624489792, 622109632, 619724800, 617335424, 614941504,
+ 612542976, 610139968, 607732352, 605320256, 602903680, 600482624, 598057152, 595627264,
+ 593192960, 590754240, 588311104, 585863680, 583411840, 580955712, 578495296, 576030528,
+ 573561536, 571088320, 568610816, 566129216, 563643264, 561153152, 558659008, 556160576,
+ 553658112, 551151488, 548640896, 546126144, 543607360, 541084480, 538557696, 536026848,
+ 533492096, 530953376, 528410656, 525864096, 523313568, 520759232, 518200960, 515638880,
+ 513073024, 510503328, 507929856, 505352608, 502771616, 500186880, 497598464, 495006400,
+ 492410624, 489811200, 487208128, 484601440, 481991200, 479377376, 476760000, 474139104,
+ 471514656, 468886720, 466255328, 463620448, 460982144, 458340480, 455695360, 453046880,
+ 450395040, 447739872, 445081408, 442419584, 439754496, 437086176, 434414624, 431739840,
+ 429061792, 426380672, 423696320, 421008864, 418318304, 415624576, 412927808, 410227968,
+ 407525120, 404819200, 402110304, 399398464, 396683616, 393965856, 391245120, 388521568,
+ 385795104, 383065760, 380333600, 377598592, 374860800, 372120256, 369376960, 366630848,
+ 363882080, 361130624, 358376480, 355619648, 352860192, 350098176, 347333536, 344566304,
+ 341796512, 339024192, 336249376, 333472064, 330692256, 327910016, 325125344, 322338304,
+ 319548832, 316756960, 313962784, 311166304, 308367488, 305566368, 302763008, 299957376,
+ 297149568, 294339552, 291527296, 288712928, 285896416, 283077792, 280257024, 277434208,
+ 274609376, 271782464, 268953568, 266122608, 263289760, 260454928, 257618144, 254779488,
+ 251938928, 249096480, 246252208, 243406128, 240558224, 237708512, 234857088, 232003888,
+ 229148976, 226292384, 223434080, 220574160, 217712592, 214849392, 211984608, 209118256,
+ 206250352, 203380944, 200510000, 197637584, 194763696, 191888352, 189011600, 186133440,
+ 183253936, 180373024, 177490800, 174607264, 171722416, 168836304, 165948944, 163060368,
+ 160170544, 157279584, 154387424, 151494128, 148599712, 145704176, 142807600, 139909920,
+ 137011232, 134111504, 131210816, 128309144, 125406504, 122502952, 119598480, 116693128,
+ 113786920, 110879856, 107971976, 105063288, 102153832, 99243616, 96332656, 93420992,
+ 90508624, 87595600, 84681920, 81767616, 78852704, 75937200, 73021144, 70104536,
+ 67187416, 64269804, 61351708, 58433156, 55514176, 52594776, 49674996, 46754840,
+ 43834344, 40913520, 37992392, 35070980, 32149316, 29227408, 26305284, 23382966,
+ 20460476, 17537830, 14615058, 11692176, 8769208, 5846174, 2923098, 0
+};
+
+
+const Word32 ivas_sine_frame_len_640_del_16_fx[289] = {
+ 1073725952,
+ 1073678400, 1073599104, 1073488064, 1073345344, 1073170880, 1072964736, 1072726912, 1072457408, 1072156160, 1071823296,
+ 1071458752, 1071062528, 1070634688, 1070175232, 1069684096, 1069161472, 1068607168, 1068021312, 1067403904, 1066755008,
+ 1066074560, 1065362624, 1064619200, 1063844352, 1063038016, 1062200320, 1061331264, 1060430848, 1059499072, 1058536000,
+ 1057541696, 1056516096, 1055459328, 1054371392, 1053252288, 1052102016, 1050920704, 1049708352, 1048465024, 1047190656,
+ 1045885376, 1044549184, 1043182208, 1041784320, 1040355712, 1038896320, 1037406272, 1035885568, 1034334272, 1032752448,
+ 1031140096, 1029497216, 1027824000, 1026120384, 1024386432, 1022622272, 1020827904, 1019003328, 1017148672, 1015264000,
+ 1013349248, 1011404608, 1009430080, 1007425792, 1005391680, 1003327872, 1001234432, 999111424, 996958848, 994776896,
+ 992565568, 990324864, 988054912, 985755712, 983427456, 981070144, 978683904, 976268672, 973824576, 971351808,
+ 968850240, 966320128, 963761408, 961174272, 958558720, 955914816, 953242752, 950542464, 947814144, 945057728,
+ 942273472, 939461440, 936621504, 933753984, 930858880, 927936192, 924986176, 922008896, 919004288, 915972544,
+ 912913664, 909827968, 906715264, 903575808, 900409728, 897217024, 893997760, 890752128, 887480128, 884181888,
+ 880857600, 877507328, 874131072, 870729024, 867301184, 863847744, 860368832, 856864448, 853334848, 849779968,
+ 846199936, 842594944, 838965120, 835310400, 831631104, 827927168, 824198848, 820446144, 816669184, 812868096,
+ 809043008, 805194048, 801321216, 797424768, 793504832, 789561344, 785594560, 781604608, 777591488, 773555456,
+ 769496640, 765414976, 761310656, 757183936, 753034880, 748863552, 744670080, 740454592, 736217216, 731958144,
+ 727677376, 723375232, 719051648, 714706752, 710340864, 705953920, 701546112, 697117632, 692668544, 688198976,
+ 683709056, 679198976, 674668864, 670118720, 665548800, 660959296, 656350208, 651721728, 647074048, 642407168,
+ 637721344, 633016704, 628293376, 623551488, 618791104, 614012480, 609215744, 604400960, 599568384, 594718080,
+ 589850176, 584964864, 580062272, 575142528, 570205824, 565252224, 560281984, 555295168, 550291904, 545272448,
+ 540236864, 535185280, 530117952, 525034944, 519936384, 514822496, 509693408, 504549248, 499390144, 494216384,
+ 489027968, 483825056, 478607904, 473376640, 468131360, 462872224, 457599424, 452313152, 447013472, 441700608,
+ 436374688, 431035904, 425684352, 420320224, 414943680, 409554848, 404153984, 398741152, 393316512, 387880320,
+ 382432576, 376973600, 371503488, 366022368, 360530464, 355027904, 349514848, 343991456, 338457920, 332914368,
+ 327360992, 321797952, 316225376, 310643520, 305052416, 299452352, 293843392, 288225792, 282599680, 276965152,
+ 271322528, 265671856, 260013344, 254347136, 248673408, 242992352, 237304096, 231608848, 225906752, 220197984,
+ 214482704, 208761088, 203033328, 197299552, 191559952, 185814672, 180063936, 174307856, 168546624, 162780432,
+ 157009424, 151233776, 145453648, 139669232, 133880696, 128088216, 122291928, 116492040, 110688704, 104882096,
+ 99072408, 93259768, 87444384, 81626424, 75806048, 69983424, 64158744, 58332160, 52503856, 46674000,
+ 40842768, 35010324, 29176854, 23342516, 17507490, 11671948, 5836060, 0
+};
+
+/************************ Q30 *******************************/
+const Word32 ivas_fb_fr_12band_1ms_re_fx[IVAS_FB_12_1MS_LEN] = {
+ 1046768256, 1012312512, 944113536, 843565952, 712700800, 554033920, 370399360, 163534048, -67588040,
+ -313003296, -547361792, -745791424, -889130944, -964720960, -967822016, -901839040, -777730304,
+ -612432896, -426573984, -241764928, -77701744, 50405768, 134107528, 173698992, 183571312,
+ 181978912, 174963648, 163434880, 148881184, 132470640, 115304208, 98219512, 81912736,
+ 66862960, 53409868, 41724844, 31871182, 23797162, 17385436, 12455156, 8801240,
+ 6197829, 4427144, 3280128, 2575327, 2155348, 1897329, 1705752, 1516863,
+ 1289431, 1005694, 661856, 267796, -161263, -604780, -1043282, -1457411,
+ -1832285, -2155534, -2420027, -2621275, -2759126, -2835035, -2853297, -2818571,
+ -2737039, -2614376, -2456980, -2270381, -2060530, -1832512, -1591794, -1343094,
+ -1091494, -841376, -597362, -363290, -143021, 60510, 244561, 407408,
+ 547618, 664738, 758550, 829643, 878668, 906840, 915250, 905346,
+ 878343, 835721, 778738, 708948, 627794, 537107, 438729, 334948,
+ 228103, 120925, 16090, -83524, -175327, -256811, -326026, -381381,
+ -422046, -447703, -458837, -456405, -442013, -417522, -385138, -347000,
+ -305255, -261681, -217812, -174648, -132866, -92642, -53935, -16402,
+ 20279, 56463, 92235, 127494, 161728, 194173, 223691, 249012,
+ 268700, 281445, 286068, 281804, 268278, 245720, 214858, 177029,
+ 133974, 87839, 40901, -4492, -46220, -82436, -111817, -133546,
+ -147456, -153913, -153846, -148528, -139528, -128444, -116827, -105934,
+ -96699, -89563, -84536, -81138, -78561, -75704, -71400, -64501,
+ -54108, -39627, -20946, 1593, 27122, 54374, 81719, 107372,
+ 129497, 146446, 156855, 159848, 155068, 142780, 123803, 99496,
+ 71589, 42078, 8610925, 16407290, 31915518, 54983844, 85416624, 123087880,
+ 168063984, 221958576, 289536032, 364878560, 426914240, 455184448, 434995104, 358099712,
+ 224036640, 40240900, -178615296, -412308800, -637390400, -829991424, -968687232, -1037118016,
+ -1026013056, -934381184, -769721024, -547208704, -287987072, -16727445, 241188016, 462583776,
+ 629070144, 729071296, 758930560, 723116864, 633312128, 506752128, 363680000, 224696192,
+ 107612800, 25033840, -24212064, -54589336, -75035176, -87485160, -93580896, -94591848,
+ -91737704, -86038536, -78437624, -69711224, -60533488, -51423856, -42794000, -34920752,
+ -27987240, -22072318, -17188296, -13279352, -10254646, -7989723, -6353249, -5207335,
+ -4426934, -3897128, -3525509, -3236283, -2977071, -2710878, -2419337, -2094076,
+ -1738366, -1359253, -969076, -579170, -201992, 153445, 478767, 769398,
+ 1021418, 1233894, 1405828, 1538184, 1631253, 1686663, 1705249, 1689093,
+ 1639776, 1560317, 1453594, 1324024, 1175972, 1015086, 846649, 676618,
+ 509991, 351706, 205173, 73207, -43142, -143513, -229073, -301290,
+ -362531, -414799, -460247, -500043, -534968, -564551, -587849, -602888,
+ -607619, -599579, -576918, -538114, -482894, -411845, -327078, -231622,
+ -129783, -26319, 73437, 164513, 242258, 303205, 344935, 366711,
+ 369107, 354325, 325569, 287088, 243371, 199057, 158131, 123882,
+ 98274, 82114, 74715, 74333, 78122, 82791, 84734, 80757,
+ 68210, 45592, 12513, -29958, -79606, -133015, -186134, -234445,
+ -273650, -299897, -310406, -303565, -279332, -239075, -185665, -123028,
+ -55984, 10396, 12276729, 12693837, 13547048, 14871155, 16707203, 19094012,
+ 22050984, 25567530, 29581572, 33971516, 38534384, 42985632, 46940136, 49924776,
+ 51363228, 50604824, 46909464, 39493740, 27503144, 10070768, -13759776, -44999620,
+ -84980336, -136135984, -207135712, -303422240, -412817600, -514972896, -589851392, -619651584,
+ -591583168, -499579936, -345470464, -138966128, 103208400, 359174656, 604351488, 814326528,
+ 967700992, 1048627328, 1048680832, 967863296, 814603776, 604752128, 359708672, 103884792,
+ -138140928, -344495008, -498458752, -590328384, -618282624, -588395136, -513462144, -411289888,
+ -301917376, -205694144, -134796400, -83778624, -43967052, -12923312, 10688964, 27884292,
+ 39622020, 46770036, 50183460, 50644772, 48893804, 45580600, 41282912, 36475948,
+ 31549672, 26793770, 22418028, 18548592, 15250408, 12530037, 10357491, 8671122,
+ 7396225, 6448686, 5748701, 5221465, 4805724, 4451326, 4123487, 3798131,
+ 3463431, 3114322, 2752946, 2383612, 2013354, 1648090, 1293873, 954378,
+ 632818, 330406, 48532, -212349, -450755, -665332, -853410, -1012414,
+ -1138953, -1230412, -1284349, -1300013, -1277722, -1220043, -1130902, -1016282,
+ -883017, -739061, -592113, -449695, -317863, -201395, -102837, -23014,
+ 39453, 87271, 124545, 155673, 185224, 216854, 253275, 295449,
+ 342868, 393176, 442827, 487113, 521090, 539819, 539332, 516817,
+ 471355, 403816, 317194, 216106, 106711, -4112, -109126, -201659,
+ -275976, -328059, -355725, -359045, -340068, -302808, -252589, -195699,
+ -138533, -87141, -46428, -19866, -8984, -13439, -30918, -57611,
+ -88487, -118040, -140755, -151891, -147872, -126858, -88834, -35798,
+ 28549, 99021, 169585, 233841, 285797, 320360, 333987, 324942,
+ 293611, 242374, 175498, 98630, 18357, -58534, -125609, -177509,
+ -210361, -222240, -213241, -185532, -143021, -91031, -35654, 16794,
+ 60506, 90695, 104157, 99518, 77443, 40482, -7123, -59963,
+ -111945, -157005, -189668, -205697, -202469, -179335, -137639, -80671,
+ -13290, 58484, 128123, 189173, 235954, 264066, 270883, 255765,
+ 220174, 2505037, 2442157, 2316154, 2126672, 1874467, 1561489, 1192761,
+ 775600, 321304, -157412, -645618, -1131069, -1604363, -2065994, -2526609,
+ -3015154, -3577470, -4283816, -5223516, -6510031, -8269471, -10642073, -13763168,
+ -17761360, -22731886, -28733746, -35756756, -43722016, -52444716, -61644104, -70903304,
+ -79696304, -87342288, -93058336, -95895816, -94830640, -88641344, -76058616, -55443336,
+ -24863958, 24611116, 107440320, 224788944, 364047616, 507399776, 634242176, 724330048,
+ 760427264, 730852288, 631136576, 464936832, 243827808, -13803173, -284784032, -543737088,
+ -765995008, -930417472, -1021827456, -1032720576, -964074624, -825139200, -632243584, -406773696,
+ -172552176, 47020828, 231770176, 367063072, 445488224, 467504928, 441322720, 381553248,
+ 308519520, 243096544, 190940560, 146958368, 109144704, 76984176, 50110068, 28195132,
+ 10859917, -2331860, -11867127, -18267046, -22063578, -23780578, -23911906, -22907786,
+ -21160858, -19000796, -16689673, -14424574, -12340740, -10519832, -8997765, -7775391,
+ -6827615, -6113435, -5583605, -5187945, -4880011, -4620898, -4380691, -4139162,
+ -3884798, -3613535, -3326639, -3028821, -2726195, -2424818, -2129499, -1843272,
+ -1567228, -1300854, -1042591, -790584, -543428, -300799, -63891, 164435,
+ 379755, 576491, 748467, 889663, 994911, 1060624, 1085268, 1069727,
+ 1017300, 933554, 825817, 702603, 572797, 444929, 326372, 222801,
+ 137707, 72284, 25430, -5886, -26190, -40792, -55143, -74076,
+ -101256, -138661, -186386, -242548, -303550, -364410, -419384, -462555,
+ -488576, -493231, -474014, -430404, -364059, -278663, -179684, -73826,
+ 31531, 129079, 212203, 275656, 315980, 331857, 324141, 295780,
+ 251424, 196978, 138929, 83734, 37113, 3535, -14258, -15450,
+ -1229, 25423, 60045, 97246, 131265, 156654, 168829, 164631,
+ 142633, 103366, 49247, -15601, -85794, -155177, -217478, -266899,
+ -298743, -309847, -298949, -266783, -216054, -151145, -77727, -2174,
+ 69017, 702811, 654136, 559557, 424419, 255932, 62727, -146313,
+ -362395, -578054, -786994, -985086, -1169469, -1339221, -1493760, -1633415,
+ -1757450, -1864970, -1953010, -2018235, -2055396, -2060043, -2027296, -1955369,
+ -1844129, -1698799, -1527422, -1343910, -1163448, -1004247, -880298, -801810,
+ -765486, -754582, -727814, -620985, -336399, 251272, 1302991, 3002489,
+ 5560181, 9191239, 14115464, 20525480, 28584940, 38387408, 49958096, 63204572,
+ 77930464, 93777392, 110263472, 126708904, 142322784, 156083648, 166946144, 173586320,
+ 175308576, 166325584, 128680304, 48303544, -74757040, -231715952, -407042976, -580775616,
+ -731094848, -837272320, -882366976, -855569984, -753729472, -582012992, -353498368, -87845872,
+ 190881904, 456905760, 685667520, 856595200, 955419584, 975703808, 919454400, 796692096,
+ 624085824, 422776032, 215700912, 24714716, -132116288, -242736960, -302620672, -315365760,
+ -293500640, -258619744, -225315280, -194015376, -163910608, -135501680, -109209736, -85466480,
+ -64529184, -46551644, -31533836, -19377918, -9878438, -2769905, 2268515, 5573895,
+ 7492172, 8348992, 8445734, 8040905, 7351921, 6546074, 5747758, 5036624,
+ 4458304, 4026662, 3735443, 3561663, 3475902, 3444629, 3437763, 3428836,
+ 3399492, 3337488, 3238697, 3103696, 2938339, 2749967, 2547660, 2338971,
+ 2130630, 1926285, 1727949, 1534741, 1344902, 1155176, 962956, 765794,
+ 563232, 356016, 147339, -58398, -254956, -435840, -594040, -723684,
+ -819800, -879714, -902536, -890086, -845966, -775986, -686897, -586473,
+ -482133, -380953, -288451, -208799, -143979, -94350, -58234, -32830,
+ -14133, 1978, 19701, 42276, 72069, 109808, 154947, 205272,
+ 257581, 307614, 350943, 383061, 400284, 399785, 380309, 341971,
+ 286657, 217523, 139066, 56385, -24953, -99742, -163283, -212106,
+ -243951, -258230, -255733, -167174, -239722, -322173, -408810, -492821,
+ -566516, -622391, -653378, -653921, -619965, -549788, -443508, -303565,
+ -133727, 60691, 274135, 500595, 734943, 972407, 1209697, 1443978,
+ 1673718, 1897211, 2113333, 2319888, 2514652, 2693915, 2854207, 2991285,
+ 3102696, 3187122, 3247515, 3290252, 3328147, 3378477, 3464934, 3613501,
+ 3852565, 4205968, 4691138, 5309438, 6043184, 6844465, 7633047, 8285794,
+ 8638327, 8477588, 7550391, 5561188, 2190063, -2903797, -10053462, -19577218,
+ -31739716, -46747292, -64700276, -85602512, -109304912, -135555296, -163926944, -194002976,
+ -225285872, -258586768, -293477632, -315364832, -302650912, -242803328, -132218944, 24580560,
+ 215544720, 422611008, 623927680, 796557504, 919359168, 975661312, 955439360, 856681664,
+ 685819520, 457116384, 191139072, -87558504, -353200000, -581723904, -753469440, -855356160,
+ -882212736, -837186048, -731079168, -580827520, -407153984, -231873488, -74945544, 48100840,
+ 128479736, 166141328, 175151264, 173462112, 166856272, 156024384, 142286160, 126683672,
+ 110236760, 93736176, 77863432, 63103528, 49819328, 38212324, 28380444, 20303444,
+ 13891988, 8985083, 5391207, 2889572, 1262319, 294475, -203348, -398749,
+ -423662, -382151, -343523, -352875, -428668, -574135, -776792, -1018896,
+ -1276918, -1529859, -1757571, -1946540, -2086827, -2175642, -2213314, -2205436,
+ -2158564, -2081784, -1982822, -1869689, -1747600, -1621008, -1491391, -1359644,
+ -1224514, -1085096, -939557, -787433, -628324, -463767, -295726, -127991,
+ 35529, 189782, 330335, 452518, 553054, 629169, 679950, 705285,
+ 706896, 687113, 649626, 598183, 537192, 470470, 401849, 334088,
+ 269582, 209498, 154619, 104683, 59308, 17469, -21588, -58843,
+ -94673, -129406, -162639, -193876, -221997, -245959, -264363, -276167,
+ -280285, -276237, -263718, -243144, -215155, -181048, -225261, -273555,
+ -307889, -326103, -327476, -312684, -283609, -243038, -194256, -140631,
+ -85182, -30244, 22798, 73608, 122885, 172169, 223570, 279366,
+ 341593, 411622, 489814, 575248, 665622, 757256, 845294, 923987,
+ 987121, 1028456, 1042203, 1023430, 968397, 874758, 741642, 569587,
+ 360379, 116796, -157659, -459031, -783110, -1125546, -1481872, -1847416,
+ -2217186, -2585716, -2947037, -3294742, -3622346, -3923849, -4194709, -4432970,
+ -4640760, -4825675, -5002266, -5192922, -5428408, -5747161, -6193793, -6815752,
+ -7658969, -8761350, -10145511, -11809549, -13717971, -15791409, -17898084, -19845242,
+ -21374384, -22157722, -21800466, -19845174, -15783279, -9068449, 863064, 14571969,
+ 32592328, 55410852, 83458416, 117107272, 156758688, 202942128, 257651808, 325933440,
+ 402044000, 464971200, 494205696, 474891008, 398522784, 264288720, 79206760, -142533824,
+ -381224512, -613975168, -817483264, -970950784, -1058690624, -1072345920, -1012679872, -893613760,
+ -734287744, -546547584, -339769856, -124623176, 88170360, 288225568, 466194112, 614172160,
+ 726163904, 798321728, 829131584, 819397568, 772133120, 692285376, 586377152, 462039040,
+ 327503712, 191064064, 60554008, -57130884, -156432848, -233429280, -286014272, -313941504,
+ -318749984, -303544416, -272698496, -231426688, -185371904, -140057616, -100631488, -69996648,
+ -46622364, -28166424, -13810469, -2980571, 4834391, 10133794, 13384151, 15027667,
+ 15460742, 15036408, 14051635, 12751812, 11326396, 9916592, 8616869, 7484565,
+ 6544389, 5798046, 5229236, 4811721, 4513168, 4300801, 4143382, 4014381,
+ 3892172, 3761242, 3611156, 3436579, 3235728, 3009947, 2762235, 2496885,
+ 2218419, 1931526, 1640448, 1349202, 1061301, 780105, 508675, 250099,
+ 7326, -216639, -418984, -597023, -748502, -871609, -965247, -1029025,
+ -1063439, -1069768, -1050128, -1007269, -944511, -865478, -773983, -673761,
+ -568371, -460991, -354385, -250799, -152007, -59299, 26411, 104546,
+ 174730, 236744, 290418, 335608, 372145, 399853, 418548, 428095,
+ 428430, 419636, 401963, 375881, 342083, 301499, 255265, 204699,
+ 151239, 96397, 41685, -11436, -61625, -107696, -148661, -183744,
+ -212399, -234301, -249338, -257586, -259295, -171383, -167771, -160946,
+ -151648, -140875, -129741, -119346, -110602, -104127, -100108, -98276,
+ -97857, -97667, -96155, -91604, -82246, -66504, -43110, -11334,
+ 28976, 77253, 132282, 192171, 254555, 316653, 375561, 428343,
+ 472340, 505222, 525246, 531204, 522588, 499415, 462302, 412189,
+ 350367, 278167, 197008, 108113, 12645, -88501, -194453, -304491,
+ -417705, -533098, -649202, -764225, -875703, -980757, -1075829, -1157086,
+ -1220253, -1261142, -1275529, -1259757, -1210576, -1125738, -1003720, -844248,
+ -647867, -416383, -152288, 140834, 458975, 797247, 1150575, 1513140,
+ 1879071, 2241774, 2594688, 2930577, 3242477, 3523085, 3766061, 3965621,
+ 4118279, 4222622, 4281408, 4301274, 4294860, 4279931, 4280984, 4327080,
+ 4452293, 4691546, 5079427, 5643594, 6401946, 7353690, 8475606, 9711576,
+ 10969534, 12110916, 12950640, 13248182, 12713298, 10999818, 7719470, 2437137,
+ -5306709, -16007364, -30173754, -48382488, -71457888, -101754088, -140816912, -185763344,
+ -231466336, -272424224, -303010560, -318021792, -313081312, -285067456, -232401024, -155266144,
+ -55676148, 62564504, 194048000, 332049728, 468930560, 596597632, 707022848, 792757376,
+ 847434880, 866203136, 846081856, 786193920, 687883392, 554677120, 392130080, 207514704,
+ 9432382, -192707744, -389200480, -570675136, -728479808, -856350656, -952308800, -1015864832,
+ -1046220032, -1043342848, -1008126784, -942413952, -848923648, -731177152, -593366784, -440223744,
+ -276851936, -108565096, 59292484, 221513920, 373199296, 509904800, 627780928, 723682304,
+ 795257728, 841006144, 860308096, 853421632, 821452480, 766292160, 690533568, 597361024,
+ 490425248, 373702496, 251347920, 127544600, 6357648, -108405296, -213318272, -305445280,
+ -382425728, -442537280, -484731648, -508645408, -514583008, -503476768, -476822816, -436599136,
+ -385166592, -325160416, -259373680, -190640560, -121721768, -55198692, 6621388, 61783672,
+ 108746912, 146423216, 174197536, 191924704, 199906864, 198850976, 189810704, 174114128,
+ 153282784, 128943984, 102742896, 76256368, 50914548, 27932052, 8253544, -7485707,
+ -18981258, -26263536, -29686804, -29902128, -27874808, -24904632, -21873452, -18924710,
+ -16109369, -13513449, -11193274, -9184409, -7497119, -6124396, -5043505, -4222392,
+ -3622104, -3201531, -2919256, -2736657, -2618792, -2536063, -2464195, -2384826,
+ -2284834, -2156265, -1995319, -1801974, -1578908, -1331064, -1064692, -787000,
+ -505396, -227288, 40476, 291657, 521006, 724191, 898044, 1040397,
+ 1150221, 1227397, 1272778, 1287922, 1275099, 1237007, 1176756, 1097593,
+ 1002895, 895923, 779853, 657586, 531818, 404912, 279016, 155978,
+ 37491, -74965, -179989, -276315, -362698, -438012, -501167, -551237,
+ -587418, -609171, -616196, -608571, -586708, -551466, -504065, -446144,
+ -379632, -306754, -229859, -151391, -73706, 962, 70672, 133776,
+ 189046, 235630, 273114, 301432, 320873, 331952, 335393, 331988,
+ 322579, 307941, 288792, 265710, 239189, 209598, 177267, 142480,
+ 105576, 66945, 27114, -13271, -53400, -92348, -129065, -162474,
+ -191486, -215114, -232503, -243037, -246348, -242394, -231432, -214048,
+ -191082, -163619, -132881, -100182, -66814, -34004, -2809, 25897,
+ 51498, 73603, 92073, 106961, 118497, 127000, 132851, 136409,
+ 137987, 137791, 135930, 132384, 127051, 119749, 110286, 98485,
+ 84255, 67615, 48748, 27996, 5888, -16902, -39568, -61243,
+ -81031, -98099, -111715, -121326, -162998, -160088, -154357, -145969,
+ -135159, -122211, -107436, -91156, -73678, -55283, -36214, -16667,
+ 3198, 23260, 43411, 63547, 83543, 103238, 122414, 140790,
+ 158012, 173664, 187268, 198317, 206286, 210673, 211020, 206956,
+ 198214, 184663, 166317, 143347, 116078, 84982, 50655, 13802,
+ -24798, -64311, -103888, -142674, -179845, -214613, -246243, -274051,
+ -297418, -315773, -328608, -335464, -335942, -329700, -316476, -296086,
+ -268464, -233660, -191884, -143511, -89112, -29451, 34490, 101547,
+ 170354, 239401, 307043, 371566, 431212, 484258, 529040, 564034,
+ 587875, 599425, 597777, 582315, 552693, 508884, 451144, 380049,
+ 296447, 201490, 96577, -16612, -136189, -260017, -385787, -510997,
+ -633031, -749140, -856549, -952436, -1034059, -1098739, -1143998, -1167540,
+ -1167397, -1141901, -1089827, -1010351, -903194, -768558, -607272, -420711,
+ -210944, 19368, 266825, 527423, 796421, 1068545, 1337896, 1598264,
+ 1843121, 2066095, 2261075, 2422874, 2547443, 2632705, 2678810, 2689041,
+ 2669949, 2632165, 2590157, 2562709, 2571986, 2643435, 2803848, 3080521,
+ 3498078, 4076931, 4828788, 5754789, 6839761, 8050914, 9330877, 10598671,
+ 11740823, 12618964, 13055458, 12877144, 11632705, 8232321, 1712792, -8269488,
+ -21676128, -38124492, -56918448, -77081536, -97412152, -116545320, -133029752, -145407808,
+ -152301808, -152496656, -145019616, -129208872, -104771344, -71822984, -30912372, 16976826,
+ 70442824, 127704136, 186656480, 244947920, 300068000, 349448640, 390571840, 421080480,
+ 438886880, 442275104, 429992032, 401322976, 356148672, 294980192, 218969888, 129897104,
+ 30128484, -77446248, -189501472, -302382688, -412230048, -515113984, -607177664, -684781632,
+ -744644480, -783974400, -800586304, -792999936, -760514496, -703256576, -622199232, -519150624,
+ -396712160, -258207056, -107581408, 50718884, 211891600, 370936768, 522825024, 662669440,
+ 785895232, 888400000, 966700096, 1018056320, 1040574720, 1033278976, 996150976, 930138240,
+ 837128128, 719891072, 581993344, 427717504, 261968336, 89712808, -84335696, -255470448,
+ -419050304, -570668224, -706270592, -822273344, -915657792, -984053440, -1025798848, -1039984064,
+ -1026470080, -985886720, -919608064, -829707328, -718891392, -590417984, -447997504, -295682944,
+ -137750720, 21423548, 177490944, 326252736, 463778272, 586513216, 691375872, 775837824,
+ 837987456, 876574784, 891035520, 881494912, 848751424, 794240448, 719980032, 628500544,
+ 522760032, 406049152, 281887712, 153916800, 25789502, -98936256, -216899504, -325029824,
+ -420629824, -501444512, -565715328, -612217792, -640282304, -649796800, -641192896, -615415808,
+ -573878848, -518405728, -451161088, -374573216, -291251040, -203897664, -115224504, -27867474,
+ 55691216, 133193880, 202668432, 262478208, 311359200, 348444032, 373271968, 385785760,
+ 386315040, 375548096, 354492672, 324428128, 286850336, 243411744, 195858832, 145969024,
+ 95489384, 46079124, -742270, -43639588, -81497992, -113449472, -138889424, -157482720,
+ -169159888, -174103616, -172726688, -165642240, -153628176, -137586864, -118502264, -97395800,
+ -75283368, -53134364, -31835154, -12157406, 5266631, 19962188, 31621642, 40107016,
+ 45443876, 47808948, 47510056, 44961972, 40656428, 35131248, 28935710, 22599292,
+ 16597725, 11327856, 7077267, 4007588, 2004813, 698472, -159366, -668117,
+ -915026, -972592, -904574, -762742, -589613, -417127, -268777, -159451,
+ -97435, -84877, -119630, -195920, -305911, -440293, -589480, -743976,
+ -895177, -1035483, -1158746, -1260167, -1336478, -1385695, -1407139, -1401122,
+ -1368900, -1312362, -1233971, -1136502, -1023004, -896600, -760484, -617774,
+ -471538, -324684, -179997, -40056, 92731, 216208, 328430, 427747,
+ 512770, 582446, 636028, 673130, 693701, 698053, 686825, 660989,
+ 621793, 570758, 509593, 440184, 364504, 284586, 202444, 120043,
+ 39232, -38277, -110964, -177497, -236776, -287918, -330276, -363413,
+ -387116, -401358, -406302, -402269, -389735, -369301, -341693, -307732,
+ -268335, -224488, -177248, -127707, -76997, -26251, 23403, 70879,
+ 115146, 155262, 190393, 219846, 243073, 259708, 269557, 272617,
+ 269062, 259245, 243667, 222969, 197896, 169274, 137970, 104873,
+ 70854, 36751, 3337, -28682, -58696, -86176, -110690, -131889,
+ -149514, -163373, -173350, -179385, -181478, -179682, -174108, -164916,
+ -152331, -136632, -118169, -97351, -74653, -50603, -25781, -795,
+ 23721, 47148, 68883, 88374, 105138, 118782, 129014, 135661,
+ 138666, 138092, 134111, 126995, -72761, -56245, -38209, -19019,
+ 926, 21206, 41377, 60995, 79616, 96811, 112175, 125335,
+ 135964, 143783, 148571, 150171, 148491, 143510, 135276, 123908,
+ 109592, 92580, 73182, 51764, 28741, 4570, -20258, -45231,
+ -69817, -93477, -115679, -135902, -153653, -168473, -179953, -187739,
+ -191549, -191176, -186499, -177490, -164220, -146855, -125663, -101009,
+ -73349, -43220, -11236, 21933, 55569, 88924, 121238, 151753,
+ 179734, 204484, 225359, 241786, 253272, 259417, 259926, 254614,
+ 243416, 226386, 203704, 175675, 142727, 105408, 64381, 20414,
+ -25629, -72803, -120096, -166448, -210776, -251991, -289028, -320870,
+ -346577, -365309, -376354, -379149, -373302, -358603, -335043, -302817,
+ -262324, -214167, -159142, -98227, -32564, 36563, 107751, 179503,
+ 250256, 318414, 382371, 440551, 491426, 533563, 565640, 586488,
+ 595111, 590727, 572783, 540991, 495337, 436112, 363911, 279647,
+ 184541, 80117, -31824, -149225, -269813, -391137, -510624, -625621,
+ -733459, -831498, -917191, -988123, -1042078, -1077064, -1091376, -1083624,
+ -1052786, -998241, -919828, -817879, -693286, -547530, -382754, -201766,
+ -8088, 194084, 399903, 603998, 800600, 983813, 1147877, 1287596,
+ 1398749, 1478666, 1526731, 1545029, 1538843, 1517225, 1493308, 1484620,
+ 1512997, 1604428, 1788384, 2097022, 2563860, 3222329, 4104042, 5237042,
+ 6645377, 8348986, 10388584, 12857124, 15616492, 18195220, 20086854, 20833852,
+ 20030730, 17354698, 12586763, 5632648, -3464912, -14518786, -27198686, -41038776,
+ -55453300, -69758216, -83199240, -94984200, -104319184, -110446312, -112682200, -110454752,
+ -103337336, -91078120, -73623784, -51135812, -23998892, 7179643, 41579336, 78185368,
+ 115815920, 153157712, 188808416, 221324672, 249274288, 271290496, 286126560, 292708608,
+ 290184736, 277968256, 255773584, 223642784, 181961872, 131465504, 73229656, 8652162,
+ -60578956, -132528392, -205066832, -275933056, -342803008, -403363968, -455390976, -496823520,
+ -525839776, -540925440, -540935296, -525144960, -493290304, -445593920, -382776288, -306051584,
+ -217107424, -118068792, -11447024, 99925072, 212970192, 324453472, 431076864, 529578144,
+ 616831424, 689946368, 746362368, 783935232, 801012800, 796497984, 769895232, 721340928,
+ 651613760, 562127360, 454901984, 332518336, 198053008, 54997860, -92834592, -241417152,
+ -386622272, -524341152, -650604416, -761700160, -854286656, -925495040, -973019712, -995193152,
+ -991042688, -960327360, -903553472, -821968256, -717531648, -592866496, -451188992, -296220608,
+ -132085040, 36808156, 205888512, 370555840, 526312064, 668891968, 794386240, 899356480,
+ 980934400, 1036909248, 1065792000, 1066936320, 1040546496, 987467136, 909149824, 807691200,
+ 685777408, 546616256, 393851264, 231466848, 63682176, -105158952, -270702912, -428699744,
+ -575114688, -706232704, -818754752, -909882496, -977389312, -1019675904, -1035808896, -1025541568,
+ -989316224, -928248256, -844092096, -739190912, -616410240, -479058656, -330797152, -175539264,
+ -17346022, 139682832, 291517408, 434303488, 564462720, 678784448, 774506688, 849384640,
+ 901743936, 930519040, 935273728, 916205312, 874131520, 810461056, 727147968, 626633152,
+ 511772224, 385754272, 252012128, 114127448, -24266644, -159583088, -288375648, -407428352,
+ -513837376, -605083264, -679091392, -734279488, -769591104, -784513984, -779083840, -753872640,
+ -709962816, -648908288, -572682880, -483618976, -384336832, -277668320, -166575776, -54069264,
+ 56875640, 163397472, 262823600, 352738016, 431040544, 495996064, 546272512, 580966656,
+ 599617664, 602207872, 589151552, 561271552, 519765696, 466163232, 402273376, 330127520,
+ 251916672, 169926224, 86470040, 3825426, -75828792, -150469632, -218281248, -277698720,
+ -327443424, -366549120, -394378400, -410629056, -415330784, -408832544, -391780864, -365090688,
+ -329909184, -287574176, -239568528, -187472016, -132911848, -77513936, -22855780, 29577298,
+ 78431608, 122519032, 160844800, 192628240, 217316432, 234590304, 244363440, 246773968,
+ 242169824, 231088240, 214230352, 192431808, 166630544, 137832768, 107078304, 75406624,
+ 43824304, 13275079, -15386599, -41417940, -64205456, -83277544, -98311776, -109136888,
+ -115729656, -118206952, -116813448, -111905648, -103932808, -93415768, -80924248, -67053716,
+ -52402552, -37550280, -23037704, -9349536, 3099972, 13977919, 23039974, 30133750,
+ 35198404, 38260568, 39427008, 38874332, 36836352, 33589632, 29437968, 24696382,
+ 19675442, 14666438, 9928193, 5675861, 2072344, -777524, -2829749, -4100893,
+ -4665396, -4650187, -4237832, -3670417, -3111787, -2588999, -2111154, -1692910,
+ -1342761, -1064792, -858034, -718046, -637371, -606817, -616039, -654489,
+ -711863, -778707, -846654, -908726, -959364, -994500, -1011439, -1008780,
+ -986218, -944402, -884714, -809115, -719958, -619860, -511553, -397807,
+ -281326, -164706, -50372, 59439, 162717, 257679, 342798, 416803,
+ 478690, 527728, 563468, 585733, 594629, 590529, 574063, 546100,
+ 507723, 460200, 404950, 343501, 277458, 208453, 138112, 68013,
+ -346, -65582, -126442, -181831, -230824, -272671, -306807, -332846,
+ -350584, -359987, -361185, -354465, -340256, -319119, -291736, -258891,
+ -221458, -180384, -136669, -91350, -45474, -81, 43821, 85280,
+ 123419, 157461, 186741, 210730, 229036, 241421, 247797, 248224,
+ 242908, 232183, 216503, 196419, 172565, 145631, 116349, 85467,
+ 53736, 21886, -9380, -39409, -67596, -93402, -116356, -136059,
+ -152188, -164499, -172828, -177091, -177288, -173497, -165880, -154675,
+ -140195, -122823, -103005, -81242, -58073, -34073, -9827, 14076,
+ 37067, 58607, 78202, 95423, 109908, 121382, 129651, 134613,
+ 136254, 134645, 129937, 122348, -44011, -24892, -4829, 15720,
+ 36281, 56369, 75506, 93227, 109092, 122701, 133696, 141775,
+ 146697, 148290, 146451, 141157, 132459, 120486, 105445, 87616,
+ 67345, 45046, 21187, -3718, -29118, -54435, -79078, -102456,
+ -123992, -143137, -159380, -172271, -181421, -186524, -187359, -183802,
+ -175830, -163523, -147066, -126746, -102945, -76138, -46876, -15782,
+ 16466, 49153, 81535, 112860, 142385, 169387, 193186, 213156,
+ 228742, 239468, 244958, 244937, 239247, 227851, 210839, 188425,
+ 160956, 128901, 92851, 53506, 11664, -31790, -75908, -119691,
+ -162116, -202159, -238815, -271127, -298207, -319262, -333613, -340713,
+ -340163, -331730, -315348, -291129, -259362, -220512, -175214, -124263,
+ -68599, -9299, 52451, 115372, 178114, 239282, 297468, 351266,
+ 399319, 440334, 473120, 496614, 509913, 512295, 503248, 482484,
+ 449964, 405893, 350744, 285237, 210350, 127286, 37477, -57465,
+ -155750, -255468, -354592, -451046, -542708, -627478, -703289, -768173,
+ -820272, -857921, -879657, -884318, -871054, -839446, -789522, -721878,
+ -637689, -538829, -427837, -308012, -183306, -58351, 61766, 171575,
+ 265595, 338530, 385818, 403920, 391045, 347469, 276387, 184146,
+ 81162, -18121, -94264, -123407, -76036, 81568, 389991, 895519,
+ 1710701, 3002792, 4825273, 7109226, 9729646, 12512602, 15248433, 17702624,
+ 19630608, 20791430, 20963006, 19955790, 17626208, 13887624, 8719623, 2174045,
+ -5621665, -14464834, -24081046, -34131360, -44222504, -53920252, -62765096, -70290080,
+ -76039792, -79590136, -80567832, -78669104, -73676656, -65474260, -54058260, -39545472,
+ -22176940, -2317326, 19550376, 42834668, 66849928, 90834856, 113974736, 135426640,
+ 154347008, 169920736, 181390720, 188086896, 189453888, 185076096, 174699280, 158247904,
+ 135837376, 107780464, 74587640, 36960972, -4218522, -47909872, -92937136, -138019856,
+ -181808096, -222921312, -259989808, -291697568, -316825344, -334292320, -343195264, -342844000,
+ -332791264, -312856704, -283143456, -244046832, -196254272, -140736784, -78731208, -11714102,
+ 58632672, 130463552, 201817312, 270670080, 334992000, 392806176, 442247552, 481620896,
+ 509455360, 524554208, 526038368, 513381696, 486437344, 445453888, 391080448, 324360480,
+ 246714016, 159908576, 66019492, -32619810, -133476120, -233882016, -331106848, -422431424,
+ -505224224, -577016896, -635577152, -678976448, -705651136, -714454400, -704697856, -676181184,
+ -629208640, -564592384, -483640672, -388133216, -280282016, -162679760, -38236756, 89892360,
+ 218389968, 343862752, 462932736, 572329472, 668980864, 750100160, 813266368, 856496128,
+ 878304640, 877753856, 854486592, 808744960, 741372928, 653802560, 548023872, 426538944,
+ 292301664, 148644560, -806035, -152223392, -301680672, -445254848, -579131904, -699710144,
+ -803698816, -888209216, -950836352, -989727616, -1003637824, -991967616, -954785856, -892832832,
+ -807506624, -700830848, -575405568, -434342368, -281185056, -119818392, 45633172, 210913568,
+ 371747552, 523954144, 663558144, 786896576, 890717440, 972267648, 1029367616, 1060471360,
+ 1064709056, 1041912064, 992618752, 918061696, 820136128, 701350912, 564763136, 413905312,
+ 252702016, 85283768, -84153016, -251373152, -412193952, -562598208, -698834304, -817510976,
+ -915681728, -990918592, -1041372160, -1065817344, -1063683392, -1035067008, -980729024, -902074176,
+ -801114432, -680417408, -543040576, -392453440, -232449024, -67047936, 99603672, 263338768,
+ 420074528, 565914944, 697248640, 810838912, 903904448, 974187712, 1020010432, 1040314112,
+ 1034684224, 1003358720, 947219392, 867767552, 767083328, 647771264, 512892224, 365884480,
+ 210475200, 50585176, -109770824, -266585856, -415961728, -554206912, -677928256, -784115520,
+ -870214784, -934190464, -974573952, -990497408, -981711808, -948590080, -892113472, -813843264,
+ -715877760, -600795712, -471588352, -331581056, -184347104, -33615956, 116822016, 263211632,
+ 401927360, 529563904, 643020416, 739576448, 816957632, 873389632, 907638720, 919038784,
+ 907503104, 873521728, 818144448, 742948992, 649996672, 541776128, 421136352, 291211584,
+ 155339280, 16974000, -120401088, -253362480, -378632256, -493159552, -594195200, -679358336,
+ -746692608, -794711040, -822428992, -829383232, -815638016, -781777600, -728885632, -658512064,
+ -572628224, -473572352, -363985824, -246742688, -124873992, -1489180, 120303760, 237476976,
+ 347158464, 446702912, 533755744, 606308928, 662747520, 701884928, 722987456, 725786624,
+ 710479424, 677716736, 628580224, 564548800, 487455296, 399434400, 302864160, 200301680,
+ 94415504, -12084029, -116514408, -216288720, -308979968, -392380352, -464553824, -523880992,
+ -569095168, -599308544, -614028672, -613164032, -597019520, -566281600, -521994336, -465525920,
+ -398528192, -322889120, -240680240, -154100192, -65416176, 23095468, 109207648, 190798608,
+ 265904304, 332765472, 389868896, 435980928, 470173824, 491842976, 500715808, 496851904,
+ 480634304, 452752704, 414179264, 366137088, 310063456, 247567808, 180386464, 110334864,
+ 39258892, -31013516, -98719224, -162203968, -219962560, -270674336, -313232768, -346769088,
+ -370668672, -384580928, -388421408, -382367424, -366846528, -342518912, -310254080, -271102432,
+ -226263200, -177048848, -124847760, -71085712, -17187518, 35460372, 85545152, 131860032,
+ 173332944, 209050736, 238278608, 260474080, 275295552, 282605088, 282465888, 275134240,
+ 261046656, 240802480, 215142736, 184925744, 151100368, 114677616, 76701576, 38220244,
+ 257309, -36214540, -70298016, -101192744, -128213464, -150804368, -168549456, -181178720,
+ -188570000, -190746832, -187872144, -180238592, -168255376, -152432528, -133362752, -111701864,
+ -88148040, -63420712, -38239704, -13305140, 10721270, 33233146, 53694084, 71649704,
+ 86736888, 98689968, 107343928, 112634456, 114595192, 113352176, 109115832, 102170872,
+ 92864472, 81593048, 68788288, 54902676, 40395092, 25716910, 11298924, -2460449,
+ -15205434, -26631372, -36491212, -44599896, -50836640, -55145052, -57531268, -58060172,
+ -56849976, -54065368, -49909488, -44615140, -38435440, -31634326, -24477204, -17222048,
+ -10111227, -3364318, 2827930, 8308287, 12956318, 16690166, 19466890, 21281350,
+ 22163806, 22176328, 21408246, 19970784, 17991204, 15606606, 12957738, 10182934,
+ 7412561, 4764010, 2337587, 213264, -1551419, -2922471, -3889289, -4463602,
+ -4677182, -4578945, -4230953, -3704343, -3074240, -2415525, -1797252, -1280920,
+ -898770, -627791, -434755, -305164, -227603, -191690, -187557, -206218,
+ -239500, -280340, -322733, -361874, -394053, -416670, -428076, -427515,
+ -414945, -390943, -356535, -313106, -262250, -205705, -145243, -82626,
+ -19530, 42469, 101945, 157622, 208399, 253344, 291709, 322917,
+ 346571, 362440, 370466, 370745, 363530, 349215, 328325, 301500,
+ 269486, 233106, 193250, 150849, 106856, 62226, 17894, -25242,
+ -66343, -104637, -139433, -170137, -196253, -217395, -233281, -243746,
+ -248732, -248291, -242579, -231853, -216463, -196846, -173514, -147048,
+ -118082, -87293, -55383, -23069, 8934, 39937, 69279, 96351,
+ 120609, 141582, 158888, 172233, 181426, 186370, 187072, 183631,
+ 176235, 165155, 150734, 133374, 113527, 91685, 68363, 44092,
+ 19408, -5162, -29106, -51936, -73196, -92471, -109389, -123633,
+ -134942, -143118, -148026, -149603, -147856, -142863, -134772, -123799,
+ -110225, -94386, -76670, -57503, -37343, -16663, 4054, 24338,
+ 43732, 61811, 78191, 92535, 62535, 80267, 96515, 110869,
+ 122950, 132423, 139005, 142473, 142671, 139519, 133011, 123223,
+ 110309, 94503, 76111, 55508, 33131, 9465, -14962, -39597,
+ -63868, -87203, -109039, -128839, -146103, -160377, -171269, -178455,
+ -181688, -180805, -175730, -166482, -153172, -136001, -115264, -91340,
+ -64689, -35842, -5393, 26011, 57690, 88934, 119026, 147254,
+ 172929, 195397, 214061, 228390, 237937, 242348, 241373, 234879,
+ 222848, 205389, 182733, 155232, 123355, 87684, 48894, 7752,
+ -34905, -78188, -121168, -162899, -202440, -238873, -271320, -298971,
+ -321092, -337048, -346317, -348499, -343329, -330684, -310588, -283215,
+ -248890, -208087, -161430, -109684, -53754, 5325, 66401, 128208,
+ 189391, 248521, 304122, 354711, 398828, 435097, 462282, 479357,
+ 485586, 480607, 464520, 437982, 402277, 359398, 312090, 263877,
+ 219044, 182590, 160108, 157649, 181489, 237891, 332809, 471594,
+ 658900, 898625, 1197641, 1570523, 1996663, 2404745, 2717774, 2865679,
+ 2785718, 2427096, 1754169, 749686, -583221, -2219740, -4113328, -6196593,
+ -8383364, -10571665, -12647668, -14490343, -15976733, -16987568, -17413068, -17158614,
+ -16150145, -14338955, -11705745, -8263683, -4060347, 821616, 6265157, 12120884,
+ 18210488, 24331478, 30263100, 35773284, 40626432, 44591748, 47451940, 49011856,
+ 49106908, 47610828, 44442580, 39572032, 33024242, 24882062, 15286939, 4437778,
+ -7412170, -19960400, -32862134, -45739056, -58189596, -69800496, -80159352, -88867704,
+ -95554448, -99888904, -101593376, -100454560, -96333512, -89173816, -79007528, -65958664,
+ -50244076, -32171454, -12134525, 9394608, 31875820, 54713840, 77273336, 98895824,
+ 118918056, 136691248, 151600704, 163085296, 170656112, 173913744, 172563664, 166429120,
+ 155461200, 139745456, 119505000, 95099632, 67021116, 35884416, 2415097, -32566908,
+ -68166792, -103437232, -137402992, -169087216, -197538720, -221859376, -241231120, -254941424,
+ -262406848, -263193680, -257034992, -243843760, -223721280, -196960640, -164045024, -125640616,
+ -82584344, -35866404, 13391901, 63964612, 114551216, 163809728, 210391808, 252979168,
+ 290320064, 321265088, 344801344, 360083392, 366461088, 363502304, 351010944, 329038400,
+ 297889248, 258119712, 210529696, 156147840, 96210000, 32131786, -34524592, -102088152,
+ -168820816, -232961936, -292774464, -346591552, -392862560, -430196672, -457403712, -473530208,
+ -477890048, -470088800, -450040832, -417978368, -374452640, -320326336, -256757808, -185176992,
+ -107253736, -24859086, 59979564, 145128320, 228400464, 307612608, 380641824, 445482432,
+ 500300512, 543485312, 573695616, 589899584, 591407872, 577897856, 549428800, 506447456,
+ 449783328, 380634208, 300541536, 211356352, 115196864, 14397969, -88545520, -191040832,
+ -290462720, -384220896, -469827680, -544963968, -607541824, -655762304, -688166080, -703676928,
+ -701634816, -681819648, -644463424, -590250752, -520308160, -436181376, -339801440, -233440544,
+ -119658328, -1240033, 118872048, 237652048, 352067200, 459155616, 556103232, 640318080,
+ 709499520, 761700928, 795384128, 809463808, 803340864, 776923520, 730635776, 665412608,
+ 582681792, 484333184, 372675584, 250382144, 120426184, -13991622, -149522608, -282754144,
+ -410296096, -528867712, -635382464, -727028736, -801344512, -856283200, -890270272, -902247552,
+ -891705280, -858699904, -803857856, -728364736, -633940096, -522797984, -397595008, -261366368,
+ -117451720, 30587386, 179056320, 324220320, 462399104, 590061056, 703913984, 800990592,
+ 878726208, 935027008, 968326336, 977628096, 962536000, 923267520, 860652416, 776115520,
+ 671644160, 549741504, 413365632, 265857680, 110858864, -47779968, -206094880, -360108800,
+ -505932192, -639862208, -758477376, -858725824, -938004160, -994225728, -1025875712, -1032052032,
+ -1012490816, -967575808, -898331200, -806398464, -693996736, -563869056, -419215008, -263610912,
+ -100920864, 64800176, 229408368, 388775616, 538893952, 675977408, 796558208, 897575488,
+ 976453568, 1031168128, 1060298880, 1063066560, 1039353856, 989709440, 915335680, 818058560,
+ 700282816, 564931648, 415373344, 255336384, 88815592, -80029120, -246977680, -407857120,
+ -558646720, -695580608, -815240832, -914661376, -991426624, -1043686208, -1070172608, -1070248192,
+ -1043923520, -991857408, -915341120, -816266432, -697079168, -560719104, -410547744, -250265472,
+ -83820864, 84686600, 251107216, 411343136, 561449088, 697729408, 816829056, 915815936,
+ 992253184, 1044259072, 1070553344, 1070488704, 1044066752, 991938048, 915385920, 816295104,
+ 697105216, 560750656, 410588608, 250316144, 83879304, -84624008, -251044992, -411286048,
+ -561401792, -697695936, -816812672, -915819008, -992277056, -1044304128, -1070619200, -1070574144,
+ -1044169920, -992056576, -915517184, -816436096, -697252864, -560901952, -410740480, -250465744,
+ -84023984, 84486696, 250917232, 411169760, 561298496, 697607040, 816739008, 915761280,
+ 992235520, 1044278912, 1070609856, 1070580032, 1044190208, 992090048, 915562432, 816491584,
+ 697316864, 560972608, 410815936, 250544048, 84103240, -84408312, -250841440, -411098144,
+ -561232512, -697547840, -816687680, -915718464, -992201920, -1044254720, -1070595200, -1070574848,
+ -1044194112, -992102592, -915582912, -816519232, -697350784, -561011712, -410859200, -250590352,
+ -84151408, 84359424, 250792960, 411051168, 561188032, 697506752, 816650880, 915686656,
+ 992175616, 1044234432, 1070581248, 1070567360, 1044193024, 992107776, 915594112, 816535872,
+ 697372352, 561037568, 410888512, 250622304, 84185136, -84324824, -250758368, -411017408,
+ -561155904, -697477056, -816624192, -915663552, -992156544, -1044219712, -1070571008, -1070561728,
+ -1044192000, -992111168, -915601728, -816547392, -697387392, -561055616, -410909120, -250644896,
+ -84209144, 84299992, 250733312, 410992736, 561132224, 697454848, 816603968, 915645824,
+ 992141696, 1044208000, 1070562816, 1070557056, 1044191040, 992113920, 915607936, 816556928,
+ 697399936, 561070784, 410926464, 250663904, 84229272, -84279312, -250712656, -410972640,
+ -561113216, -697437440, -816588608, -915632832, -992131328, -1044200448, -1070558208, -1070555520,
+ -1044192384, -992118080, -915614784, -816566208, -697411328, -561084032, -410941184, -250679696,
+ -84245752, 84262552, 250696016, 410956544, 561098048, 697423552, 816576320, 915622464,
+ 992123200, 1044194816, 1070555200
+};
+
+/************************ Q30 *******************************/
+const Word32 ivas_fb_fr_12band_1ms_im_fx[IVAS_FB_12_1MS_LEN] = {
+ -96495528, -286734272, -468692800, -637041216, -786562176, -912433280, -1009964416, -1075182976, -1098333440,
+ -1060972224, -954328512, -784950848, -567387776, -321857280, -71378072, 161019520, 355191072,
+ 496249664, 576290688, 595228096, 560553408, 486341472, 391112608, 296445024, 219833024,
+ 161425424, 113971872, 75074912, 43676944, 18947558, 106207, -13606639, -22959300,
+ -28697174, -31541624, -32158708, -31154358, -29054292, -26304144, -23261552, -20202826,
+ -17324756, -14756116, -12565362, -10774012, -9366401, -8302065, -7524551, -6970827,
+ -6577419, -6286071, -6046737, -5819771, -5576294, -5297871, -4975268, -4606808,
+ -4196583, -3752523, -3284873, -2804624, -2322651, -1848752, -1391471, -957667,
+ -552820, -180887, 155183, 453533, 712892, 932744, 1112922, 1253892,
+ 1356428, 1421957, 1452251, 1449752, 1417222, 1357998, 1275581, 1173833,
+ 1056523, 927513, 790325, 648358, 504521, 361522, 221574, 86743,
+ -41290, -160871, -270597, -368994, -454781, -526614, -583403, -624117,
+ -648145, -655120, -645267, -619210, -578251, -524110, -459110, -385841,
+ -307254, -226274, -145851, -68575, 3253, 67950, 124299, 171779,
+ 210318, 240423, 262847, 278659, 288884, 294565, 296445, 295082,
+ 290614, 282963, 271701, 256332, 236226, 210937, 180155, 143993,
+ 102888, 57812, 10083, -38529, -86081, -130429, -169562, -201608,
+ -225146, -239179, -243376, -237949, -223786, -202225, -175080, -144342,
+ -112142, -80430, -50955, -24990, -3380, 13628, 26240, 35170,
+ 41402, 46169, 50665, 56013, 62999, 72081, 83214, 95949,
+ 109364, 122266, 133211, 140767, 143575, 140609, 131207, 115267,
+ 93186, 65957, 34996, 2134, -30636, -61239, -87791, -108676,
+ -122781, -129495, 12356724, 36406252, 58390684, 76977432, 90719600, 98265728,
+ 98008264, 88608552, 62420976, 2547174, -98862584, -234978608, -391650304, -549723776,
+ -687929024, -785620992, -825677888, -796781568, -695135040, -525144384, -299188480, -36327380,
+ 239749920, 503413376, 729982272, 898556864, 994367488, 1010422464, 948197568, 817333696,
+ 634343104, 420516896, 199273200, -6719048, -178276784, -302004160, -371805248, -389615456,
+ -365008416, -315253344, -262675984, -217917568, -178521248, -143001072, -111343304, -83569488,
+ -59728692, -39750832, -23483756, -10668693, -980101, 5968707, 10589352, 13306198,
+ 14527738, 14637296, 13974127, 12830675, 11443325, 9996437, 8620832, 7402724,
+ 6386965, 5588127, 4995412, 4583292, 4315642, 4154179, 4060473, 4001515,
+ 3949354, 3884093, 3791711, 3665350, 3502261, 3304372, 3075215, 2820550,
+ 2545809, 2257129, 1959450, 1657946, 1356600, 1059795, 771079, 494646,
+ 234059, -6519, -223731, -414017, -575061, -704879, -803133, -870150,
+ -907983, -919252, -907936, -878057, -834296, -780659, -721070, -658192,
+ -594157, -529649, -464852, -398810, -330536, -258557, -182049, -100384,
+ -14134, 75538, 166137, 254665, 337160, 409716, 468199, 509317,
+ 530349, 530086, 508400, 466928, 408381, 336929, 257279, 174830,
+ 94651, 21581, -40724, -89563, -123905, -143909, -151339, -148811,
+ -139947, -128462, -118197, -112219, -112926, -121327, -137375, -159531,
+ -185372, -211440, -234054, -249316, -253979, -245431, -222426, -184880,
+ -134334, -73467, -6263, 62723, 128418, 186074, 231361, 261147,
+ 273444, 267948, 261810, 763373, 1198560, 1499796, 1578270, 1304628,
+ 517808, -987783, -3443484, -7111908, -12256820, -19143168, -27996048, -39000040,
+ -52248820, -67752040, -85376464, -104873664, -125808744, -147634944, -169591248, -190910720,
+ -210637232, -228834976, -242239792, -233744176, -184602112, -88256112, 52564248, 227312048,
+ 419154080, 607121280, 768828480, 883312000, 933778624, 909811200, 808862336, 636755584,
+ 407214048, 140391440, -139342896, -406167488, -635714880, -807834944, -908809408, -932820096,
+ -882419648, -768029696, -606446400, -418634368, -226977824, -52442412, 88143752, 184240560,
+ 233125792, 241364816, 227710480, 209276640, 189331712, 167814560, 145682224, 123701848,
+ 102633120, 83021960, 65302000, 49722020, 36415812, 25376218, 16511686, 9640718,
+ 4539034, 941445, -1420767, -2818065, -3495818, -3676385, -3542409, -3243683,
+ -2888735, -2555377, -2287831, -2108851, -2019462, -2010501, -2062586, -2155553,
+ -2267238, -2380241, -2479146, -2554886, -2600826, -2615545, -2598567, -2552488,
+ -2479078, -2381454, -2260948, -2119607, -1957826, -1777065, -1577959, -1362941,
+ -1134431, -897064, -655697, -417094, -187702, 25095, 215280, 377113,
+ 507239, 603471, 666470, 698219, 703186, 686502, 654728, 613906,
+ 570192, 528056, 491058, 460427, 436171, 416130, 397422, 375887,
+ 347709, 309014, 257411, 191469, 111939, 20899, -77459, -178052,
+ -274516, -360654, -430246, -478480, -501684, -498487, -469248, -416789,
+ -345433, -261310, -171090, -82033, -635, 67321, 117943, 148920,
+ 160318, 153895, 133448, 103776, 70703, 39859, 16616, 4954,
+ 7564, 25024, 56260, 98143, 146331, 195238, 239125, 272241,
+ 289930, 288679, 266989, 225117, 165550, 92349, 11219, -71466,
+ -148857, -214705, -263567, -291740, -297224, -280306, -243136, -189895,
+ -125985, -57873, 7933, 65157, 108741, 134971, 142193, 130597,
+ 102524, 61859, 13944, -35316, -79751, -113898, -133249, -135053,
+ -118286, -84087, -35339, 23302, 86186, 146930, 199365, 237874,
+ 258253, 257864, 236196, 194657, 136724, 67341, -7287, -80567,
+ -145896, -270343, -808574, -1340072, -1858807, -2358665, -2831742, -3270963,
+ -3669340, -4023521, -4333619, -4606985, -4857566, -5108708, -5390687, -5741295,
+ -6200425, -6807718, -7593886, -8575752, -9745172, -11063108, -12448231, -13772797,
+ -14853837, -15454158, -15279006, -13985197, -11185029, -6465256, 602227, 10431847,
+ 23410894, 39863840, 60045788, 84103768, 112100696, 143979968, 179711728, 219302416,
+ 264231232, 316950432, 366815488, 391499840, 373734272, 303947296, 180205328, 8607086,
+ -197450336, -418782432, -632721152, -815848960, -946877184, -1009294400, -993460928, -897898880,
+ -729596672, -503316064, -239947616, 35840880, 298430624, 524143840, 693923584, 795387200,
+ 824107840, 783846592, 685860544, 547189184, 388365568, 230527600, 92671240, -11219515,
+ -74492144, -105158200, -120261872, -127544112, -128388320, -124354624, -116661448, -106489408,
+ -94793200, -82429304, -70062176, -58237700, -47334588, -37619828, -29226616, -22202334,
+ -16501587, -12028281, -8635400, -6159899, -4423260, -3257870, -2504859, -2031762,
+ -1726474, -1507393, -1314142, -1112384, -883004, -624119, -340602, -45467,
+ 248842, 528315, 783713, 1007231, 1196662, 1351165, 1473983, 1568019,
+ 1637995, 1686519, 1716364, 1727429, 1719421, 1689696, 1636232, 1556028,
+ 1448006, 1311510, 1148760, 963094, 760758, 548770, 336091, 131254,
+ -56814, -221101, -355658, -457521, -525555, -561787, -569830, -555666,
+ -525766, -487535, -447411, -411297, -382938, -364634, -356100, -355594,
+ -359287, -362732, -360583, -348172, -321291, -277591, -216139, -138411,
+ -47457, 51579, 152676, 248783, 333218, 399646, 443388, 461240,
+ 452449, 418164, 361960, 288882, 205559, 118975, 36377, -35977,
+ -92851, -131037, -149092, -147929, -130154, -100234, -63486, -25973,
+ 6639, 29226, 38204, 31469, 9051, -27322, -73989, -126155,
+ -177996, -223678, -257577, -275273, -273644, -251592, -209808, -151108,
+ -79807, -1677, 76962, 149510, 210060, 253638, 277008, 278653,
+ 259231, -101021, -297456, -477733, -632297, -753728, -836696, -878615,
+ -879031, -839751, -763739, -654959, -517096, -353514, -166209, 43748,
+ 276781, 533724, 815969, 1123958, 1457300, 1813342, 2187857, 2574262,
+ 2965417, 3353797, 3734536, 4106324, 4475222, 4855377, 5272512, 5763051,
+ 6375849, 7168185, 8204533, 9548340, 11257436, 13371571, 15905385, 18833006,
+ 22081010, 25512624, 28924300, 32032662, 34478724, 35820256, 35546928, 33078728,
+ 27793346, 19027280, 6112874, -11628489, -34851840, -64232176, -100493888, -144608256,
+ -198909072, -270631488, -359662496, -448624032, -516131776, -543967680, -518454176, -432622496,
+ -287176640, -90768024, 140893552, 386715040, 622670976, 824595136, 971067648, 1045974272,
+ 1040467264, 954060352, 794731136, 578022784, 325234560, 60958056, -189791088, -404423968,
+ -565354624, -661869440, -691213888, -658569600, -576189312, -461441856, -334519392, -215323504,
+ -121182328, -57886044, -14972652, 16811060, 39759696, 55435020, 65035460, 69706136,
+ 70441104, 68189248, 63775032, 57948004, 51329736, 44447116, 37701544, 31399154,
+ 25736924, 20832988, 16723796, 13393488, 10776430, 8783249, 7304115, 6229334,
+ 5450365, 4874027, 4420041, 4029271, 3658127, 3282309, 2889391, 2480032,
+ 2060348, 1642421, 1237795, 858544, 512575, 205752, -60998, -288674,
+ -481834, -645256, -785054, -905653, -1011013, -1102347, -1179780, -1240896,
+ -1282805, -1301283, -1292960, -1254661, -1185341, -1085250, -957344, -806069,
+ -638185, -461195, -283738, -113885, 40607, 173836, 281340, 361227,
+ 413418, 440281, 445517, 434398, 412451, 385525, 358529, 335589,
+ 319068, 309999, 307515, 309612, 312947, 313829, 308220, 292759,
+ 264732, 222913, 167314, 99696, 23013, -58414, -139717, -215530,
+ -280898, -331372, -363803, -376281, -368659, -342216, -299851, -245477,
+ -183947, -120287, -59527, -210294, -218804, -207034, -170663, -107684,
+ -17542, 97483, 233628, 384636, 543572, 702055, 852320, 986414,
+ 1098210, 1182279, 1235630, 1256080, 1243695, 1198697, 1122785, 1016812,
+ 882318, 719277, 528144, 307851, 58485, -220576, -527549, -860384,
+ -1213683, -1581737, -1955989, -2329539, -2695405, -3052665, -3405215, -3769076,
+ -4170617, -4653891, -5276647, -6116192, -7261256, -8815022, -10881268, -13564073,
+ -16947616, -21093540, -26015144, -31675226, -37956612, -44665032, -51498380, -58060316,
+ -63829408, -68189520, -70395848, -69627624, -64938208, -55334156, -39669268, -16742548,
+ 15011598, 57892376, 121157856, 215274688, 334456672, 461378272, 576139200, 658546880,
+ 691230336, 661933376, 565469888, 404588960, 189999104, -60718748, -324979552, -577770304,
+ -794500352, -953869504, -1040332032, -1045906432, -971073600, -824675520, -622820672, -386923360,
+ -141145440, 90490632, 286893152, 432351840, 518213184, 543769536, 515984864, 448531552,
+ 359622208, 270636384, 198948336, 144668672, 100561448, 64293740, 34896780, 11649924,
+ -6117171, -19054578, -27836140, -33125540, -35583508, -35831208, -34449244, -31950346,
+ -28780702, -25304532, -21811144, -18510242, -15544263, -12991323, -10880449, -9198353,
+ -7904592, -6938712, -6232849, -5716818, -5326765, -5007114, -4715109, -4419761,
+ -4103101, -3757115, -3383050, -2987624, -2581751, -2177166, -1785567, -1416314,
+ -1076470, -769692, -497117, -257162, -46868, 137886, 301064, 446309,
+ 576003, 691438, 792390, 877665, 945087, 992265, 1016767, 1016861,
+ 991628, 941464, 867976, 774150, 663993, 542420, 414732, 286370,
+ 162380, 47204, -55707, -143950, -216326, -272693, -313915, -341561,
+ -357718, -364650, -364603, -359521, -350944, -339867, -326770, -311628,
+ -294057, -273429, -249069, -220397, -187092, -149183, -107127, -61803,
+ -14483, 33260, 79674, 122959, 161417, 193583, -137153, -86096,
+ -23462, 46165, 118296, 188311, 252569, 308033, 353183, 387345,
+ 411326, 426448, 434961, 438884, 440375, 440558, 440044, 437930,
+ 432614, 421046, 399869, 364878, 312384, 238720, 141646, 19702,
+ -126527, -295376, -483051, -684957, -894831, -1106337, -1312215, -1505978,
+ -1680884, -1831578, -1952736, -2040617, -2091372, -2102604, -2071473, -1996480,
+ -1875541, -1708206, -1493799, -1234127, -931547, -591976, -222473, 165877,
+ 561490, 950008, 1319512, 1659151, 1966270, 2245658, 2518227, 2819813,
+ 3210306, 3770160, 4608328, 5854141, 7662371, 10198175, 13638330, 18147660,
+ 23877010, 30930782, 39364468, 49144104, 60148836, 72123392, 84694024, 97312800,
+ 109298904, 119765360, 127705376, 131866912, 130934488, 123231464, 107234464, 75050672,
+ 9470806, -97677456, -239897616, -403333024, -569087680, -716066368, -823729024, -874943616,
+ -858298112, -769767616, -613463168, -401328448, -152012800, 111316600, 362752096, 579800640,
+ 754066560, 884317376, 967646720, 1002358976, 988932224, 930137792, 830908864, 698079680,
+ 539965760, 365883200, 185588480, 8720114, -155758112, -300047104, -417930816, -505075680,
+ -559213504, -580180096, -569826624, -531795520, -471193568, -394169856, -307444800, -217803664,
+ -131610264, -54348980, 9748328, 57999172, 89445504, 104945984, 107368432, 102279568,
+ 94596192, 85655480, 75877136, 65846368, 56016016, 46757852, 38321108, 30867838,
+ 24467266, 19124186, 14784349, 11357873, 8727069, 6764325, 5338255, 4325655,
+ 3614320, 3109507, 2733412, 2427369, 2148937, 1871452, 1580043, 1270071,
+ 943252, 606145, 267130, -64446, -380185, -672695, -936550, -1167777,
+ -1364195, -1524669, -1649207, -1738275, -1792904, -1814221, -1803670, -1762759,
+ -1693364, -1597596, -1478091, -1337881, -1180581, -1010189, -831132, -647987,
+ -465420, -287874, -119474, 36238, 176365, 298810, 402244, 486148,
+ 550683, 596630, 625208, 637968, 636614, 622900, 598511, 565006,
+ 523771, 476024, 422831, 365155, 303902, 239978, 174336, 108003,
+ 42099, -22177, -83566, -140800, -192647, -237981, -275829, -305435,
+ -326287, -338158, -341095, -335431, -321739, -300823, -273643, -241298,
+ -204944, -165780, -124974, -83660, -42880, 10137, 29849, 47985,
+ 63702, 76520, 86314, 93425, 98550, 102746, 107236, 113334,
+ 122202, 134769, 151505, 172398, 196816, 223585, 250966, 276853,
+ 298844, 314511, 321522, 317919, 302199, 273538, 231774, 177523,
+ 112040, 37218, -44643, -130911, -218896, -305922, -389579, -467717,
+ -538627, -600924, -653636, -695990, -727439, -747408, -755314, -750348,
+ -731559, -697715, -647504, -579487, -492405, -385195, -257342, -108895,
+ 59211, 245234, 446381, 659034, 878627, 1100007, 1317397, 1524851,
+ 1716231, 1885675, 2027510, 2136678, 2208531, 2239209, 2225330, 2164370,
+ 2054318, 1894140, 1683476, 1423258, 1115462, 763860, 373717, -47467,
+ -490570, -944379, -1396841, -1835173, -2248037, -2626382, -2966637, -3272111,
+ -3556917, -3847305, -4185583, -4630274, -5258922, -6165632, -7461554, -9268313,
+ -11715324, -14927984, -19021866, -24085232, -30171698, -37277344, -45335748, -54189964,
+ -63598244, -73198584, -82549584, -91078392, -98377112, -103118416, -100391208, -84628624,
+ -52954552, -4492618, 59827860, 137363792, 223933312, 314109568, 401591168, 479653696,
+ 541630720, 581410176, 593897728, 575427264, 524078976, 439891712, 324946016, 183315184,
+ 20883088, -154960944, -335730752, -512333504, -675605952, -816870016, -928462720, -1004220224,
+ -1039868736, -1033319296, -984830528, -897064000, -775182272, -627308096, -461708352, -284291552,
+ -100579392, 83598736, 262525088, 430732416, 583209600, 715532736, 824009920, 905775040,
+ 958871552, 982291840, 975995776, 940888192, 878773504, 792274432, 684731072, 560072576,
+ 422675872, 277208288, 128466608, -18787604, -159985744, -290901824, -407785088, -507474624,
+ -587489088, -646091776, -682326144, -696024192, -687785152, -658928000, -611418688, -547776704,
+ -470963680, -384259392, -291130144, -195094672, -99592464, -7860071, 77180528, 153017120,
+ 217622960, 269510560, 307761952, 332035072, 342546656, 340033376, 325693088, 301109632,
+ 268164672, 228941216, 185622192, 140390128, 95330560, 52345244, 13076479, -21151680,
+ -49376268, -71017224, -85881800, -94147080, -96327536, -93222768, -85856648, -75400496,
+ -63097824, -50176000, -37774988, -26857674, -18169908, -11863887, -7301392, -3914018,
+ -1479242, 185291, 1236420, 1817970, 2053955, 2052907, 1903852, 1679448,
+ 1434536, 1209401, 1029974, 911183, 857962, 868350, 934655, 1046022,
+ 1189342, 1351150, 1518125, 1678330, 1821294, 1938725, 2024278, 2073883,
+ 2085335, 2058391, 1994281, 1895693, 1766278, 1610593, 1433645, 1240831,
+ 1037545, 829139, 620601, 416556, 221024, 37473, -131344, -283279,
+ -416878, -531220, -625958, -701127, -757159, -794697, -814605, -817824,
+ -805400, -778384, -737905, -685103, -621229, -547610, -465741, -377252,
+ -283979, -187900, -91166, 4001, 95326, 180608, 257764, 324972,
+ 380709, 423871, 453787, 470280, 473637, 464613, 444338, 414280,
+ 376112, 331644, 282692, 231012, 178188, 125609, 74399, 25440,
+ -20646, -63433, -102670, -138199, -169921, -197722, -221454, -240892,
+ -255747, -265667, -270281, -269233, -262252, -249189, -230092, -205221,
+ -175099, -140492, -102411, -62059, -20785, 19997, 58880, 94556,
+ 125879, 151942, 172113, 186075, 193810, 195596, 191955, 183604,
+ 171377, 156168, 138843, 120200, 100900, 81458, 62216, 43368,
+ 24971, 6998, -10624, -27957, -45013, -61705, -77836, -93079,
+ -106999, -119067, -128714, -135370, -138532, -137806, -132971, -123999,
+ -111091, -94667, -75361, -53969, 10765, 32074, 52722, 72311,
+ 90486, 106963, 121523, 134027, 144392, 152600, 158658, 162605,
+ 164468, 164267, 161985, 157577, 150955, 142011, 130615, 116649,
+ 100019, 80692, 58704, 34200, 7431, -21221, -51265, -82083,
+ -112977, -143167, -171845, -198187, -221409, -240776, -255657, -265518,
+ -269970, -268744, -261725, -248915, -230452, -206572, -177616, -143996,
+ -106204, -64784, -20348, 26444, 74865, 124130, 173377, 221686,
+ 268054, 311432, 350709, 384766, 412472, 432751, 444591, 447117,
+ 439606, 421553, 392681, 352994, 302769, 242592, 173323, 96118,
+ 12366, -76299, -168083, -261025, -353085, -442152, -526117, -602884,
+ -670441, -726859, -770364, -799329, -812348, -808221, -786031, -745129,
+ -685209, -606288, -508783, -393474, -261578, -114689, 45155, 215561,
+ 393723, 576534, 760547, 942104, 1117306, 1282158, 1432549, 1564416,
+ 1673729, 1756688, 1809722, 1829726, 1814087, 1760970, 1669365, 1539414,
+ 1372449, 1171316, 940345, 685584, 414591, 136477, -138614, -399774,
+ -636264, -838162, -997771, -1110606, -1177191, -1204204, -1206433, -1207707,
+ -1242622, -1356751, -1607660, -2063815, -2804506, -3917005, -5495374, -7636020,
+ -10436517, -13992514, -18402674, -23818388, -30616280, -38795064, -47468192, -55465196,
+ -61624760, -64816688, -64030596, -58439904, -47471160, -30852034, -8650500, 18708296,
+ 50440096, 85421744, 122227560, 159185040, 194443776, 226058080, 252076752, 270638720,
+ 280067616, 278963616, 266285680, 241422224, 204245248, 155146128, 95049592, 25405990,
+ -51839956, -134302160, -219227456, -303587872, -384188544, -457786240, -521215424, -571515392,
+ -606054656, -622647040, -619654592, -596072512, -551593600, -486646944, -402411264, -300798944,
+ -184413264, -56477480, 79260352, 218645328, 357251200, 490529920, 613968768, 723250432,
+ 814409344, 883978944, 929123648, 947751552, 938601472, 901303104, 836405248, 745373248,
+ 630551936, 495099232, 342887840, 178382704, 6494100, -167583760, -338549120, -501169472,
+ -650463872, -781868416, -891402304, -975790912, -1032769600, -1061261696, -1060915456, -1031960960,
+ -975385600, -892916224, -786977856, -660620736, -517435968, -361449888, -197010624, -28662768,
+ 138980608, 301369056, 454141632, 593248768, 715063168, 816478784, 894992576, 948769664,
+ 976686784, 978356608, 954128576, 905069824, 832924288, 740053568, 629360000, 504194944,
+ 368255424, 225472400, 79893288, -64436384, -203589744, -333869568, -451910592, -554770112,
+ -640004160, -705727744, -750656768, -774131456, -776120512, -757206720, -718553856, -661857536,
+ -589281088, -503378688, -407008864, -303241088, -195258304, -86258672, 20640266, 122492392,
+ 216605760, 300615264, 372542752, 430843584, 474437952, 502727104, 515593600, 513386816,
+ 496894016, 467298720, 426127872, 375190336, 316508064, 252243568, 184625248, 115873648,
+ 48130852, -16604751, -76536328, -130117360, -176090096, -213512624, -241774240, -260598816,
+ -270036736, -270445792, -262462656, -246965456, -225030192, -197881696, -166842016, -133277536,
+ -98547200, -63953468, -30697916, 157309, 27720696, 51294532, 70389352, 84729480,
+ 94249824, 99084304, 99546808, 96105616, 89352656, 79969008, 68688296, 56259452,
+ 43410724, 30816176, 19066356, 8644033, -93590, -6926218, -11773978, -14694671,
+ -15872813, -15605618, -14280676, -12378042, -10430668, -8704424, -7182491, -5854782,
+ -4729147, -3804335, -3072066, -2516383, -2116394, -1847634, -1684290, -1600530,
+ -1572012, -1576721, -1595767, -1613665, -1618550, -1602016, -1558925, -1486975,
+ -1386301, -1258946, -1108416, -939180, -756297, -565028, -370575, -177839,
+ 8715, 185182, 348246, 495214, 623986, 733038, 821363, 888436,
+ 934161, 958831, 963086, 947887, 914478, 864367, 799293, 721209,
+ 632236, 534643, 430794, 323115, 214029, 105923, 1076, -98376,
+ -190504, -273617, -346304, -407458, -456294, -492355, -515505, -525917,
+ -524051, -510616, -486547, -452951, -411079, -362277, -307954, -249541,
+ -188465, -126117, -63839, -2894, 55536, 110376, 160649, 205502,
+ 244200, 276144, 300872, 318070, 327574, 329385, 323660, 310724,
+ 291059, 265298, 234214, 198698, 159739, 118393, 75754, 32922,
+ -9033, -49104, -86375, -120044, -149449, -174076, -193569, -207727,
+ -216503, -219983, -218381, -212007, -201261, -186599, -168524, -147564,
+ -124261, -99161, -72807, -45733, -18468, 8473, 34584, 59372,
+ 82359, 103090, 121141, 136131, 147730, 155680, 159803, 160015,
+ 156337, 148897, 137934, 123794, 106916, 87821, 67091, 45345,
+ 23216, 1326, -19743, -39465, 109887, 120382, 128416, 133765,
+ 136261, 135794, 132320, 125859, 116497, 104388, 89749, 72858,
+ 54047, 33695, 12222, -9922, -32266, -54329, -75626, -95683,
+ -114044, -130284, -144009, -154878, -162593, -166923, -167696, -164811,
+ -158239, -148026, -134294, -117244, -97153, -74370, -49314, -22469,
+ 5628, 34390, 63198, 91407, 118365, 143426, 165965, 185395,
+ 201183, 212860, 220042, 222435, 219848, 212195, 199508, 181929,
+ 159715, 133233, 102952, 69434, 33331, -4639, -43696, -83016,
+ -121744, -159013, -193957, -225733, -253530, -276597, -294249, -305894,
+ -311042, -309326, -300512, -284516, -261407, -231423, -194963, -152600,
+ -105060, -53228, 1881, 59128, 117284, 175043, 231069, 284005,
+ 332527, 375354, 411300, 439283, 458370, 467783, 466935, 455431,
+ 433101, 399985, 356360, 302726, 239820, 168592, 90219, 6068,
+ -82296, -173156, -264641, -354785, -441533, -522811, -596538, -660703,
+ -713385, -752830, -777471, -786003, -777391, -750944, -706300, -643488,
+ -562898, -465330, -351937, -224267, -84196, 66044, 223948, 386697,
+ 551263, 714370, 872609, 1022412, 1160192, 1282340, 1385409, 1466141,
+ 1521718, 1549819, 1548936, 1518450, 1458982, 1372447, 1262386, 1133907,
+ 993924, 850871, 714752, 596518, 507835, 460031, 463573, 526525,
+ 653821, 845263, 1094812, 1388217, 1702729, 2004387, 2248836, 2377871,
+ 2322716, 1997670, 1310909, 31361, -2276023, -5884963, -10790734, -16840258,
+ -23748608, -31120974, -38472224, -45255760, -50892408, -54804412, -56448304, -55348896,
+ -51129788, -43541476, -32483506, -18021422, -395893, 19975162, 42503072, 66442420,
+ 90913264, 114929960, 137436576, 157346768, 173587488, 185144144, 191106144, 190710336,
+ 183381248, 168765648, 146760624, 117533176, 81530704, 39481248, -7616625, -58514600,
+ -111745512, -165663824, -218494432, -268388400, -313484064, -351971232, -382156480, -402527424,
+ -411813344, -409040128, -393577504, -365176384, -323994752, -270611200, -206024384, -131639056,
+ -49237472, 39062252, 130860688, 223542656, 314352192, 400474784, 479124064, 547630784,
+ 603530816, 644649344, 669178624, 675746624, 663473536, 632014912, 581589056, 512987520,
+ 427568224, 327230528, 214373088, 91835128, -37177272, -169178032, -300498464, -427392512,
+ -546146752, -653191616, -745210944, -819245440, -872788352, -903868288, -911118272, -893827520,
+ -851974272, -786238976, -697996288, -589286400, -462766208, -321640832, -169578832, -10611593,
+ 150978672, 310780032, 464377088, 607478720, 736043264, 846397952, 935348160, 1000273472,
+ 1039207744, 1050900416, 1034856960, 991357632, 921452992, 826937088, 710298944, 574652800,
+ 423651328, 261382080, 92266240, -79072984, -248102448, -410503776, -562126720, -699092736,
+ -817911936, -915573376, -989624896, -1038234688, -1060238592, -1055167808, -1023259008, -965445760,
+ -883330880, -779142016, -655670144, -516193728, -364390176, -204236960, -39905496, 124349848,
+ 284304192, 435873248, 575219968, 698854144, 803721536, 887281600, 947570240, 983247040,
+ 993625152, 978684224, 939064256, 876042880, 791495168, 687838208, 567961280, 435144608,
+ 292968064, 145212944, -4240369, -151516576, -292848000, -424673056, -543728192, -647130176,
+ -732447680, -797759168, -841696640, -863474048, -862898880, -840368384, -796849536, -733844032,
+ -653339328, -557747648, -449833824, -332635680, -209377712, -83381528, 42024892, 163596368,
+ 278255872, 383173696, 475838368, 554117568, 616307264, 661168640, 687951104, 696401792,
+ 686761024, 659744256, 616512064, 558627584, 488004704, 406847392, 317582464, 222787984,
+ 125119136, 27233782, -68280144, -158973472, -242598960, -317167264, -380994112, -432737696,
+ -471425664, -496470656, -507674976, -505223904, -489668640, -461899200, -423108800, -374750624,
+ -318488480, -256143216, -189636144, -120931576, -51979948, 15336795, 79255984, 138179872,
+ 190714864, 235703648, 272249056, 299729728, 317807040, 326423456, 325792768, 316382656,
+ 298890368, 274212512, 243410272, 207670816, 168266608, 126513920, 83731472, 41200944,
+ 130175, -38379756, -73362784, -104010672, -129689920, -149952464, -164540112, -173382736,
+ -176590656, -174441552, -167362736, -155909328, -140739472, -122587248, -102234616, -80482928,
+ -58125464, -35921428, -14572560, 5297181, 23158150, 38587464, 51277008, 61037024,
+ 67795232, 71591800, 72570464, 70966328, 67090884, 61315048, 54050700, 45731812,
+ 36795552, 27664472, 18730052, 10338603, 2779584, -3722787, -9014984, -13015846,
+ -15715349, -17169656, -17493876, -16851572, -15443180, -13491852, -11229971, -8883501,
+ -6659666, -4731320, -3230436, -2179638, -1456508, -951706, -619736, -422906,
+ -328742, -307762, -334784, -388143, -450439, -507929, -550755, -572282,
+ -568989, -539768, -485654, -409163, -313997, -204481, -85334, 38748,
+ 163232, 284008, 397435, 500481, 590686, 666220, 725799, 768696,
+ 794640, 803805, 796717, 774237, 737483, 687817, 626774, 556060,
+ 477482, 392946, 304395, 213796, 123081, 34130, -51284, -131518,
+ -205101, -270753, -327424, -374293, -410797, -436619, -451696, -456198,
+ -450524, -435265, -411195, -379231, -340412, -295864, -246780, -194382,
+ -139908, -84576, -29579, 23948, 74940, 122415, 165488, 203392,
+ 235477, 261232, 280287, 292420, 297563, 295805, 287381, 272679,
+ 252217, 226642, 196699, 163225, 127113, 89298, 50723, 12319,
+ -25022, -60468, -93267, -122762, -148403, -169755, -186505, -198455,
+ -205529, -207755, -205269, -198296, -187147, -172200, -153899, -132733,
+ -109235, -83965, -57505, -30448, -3387, 23090, 48419, 72062,
+ 93519, 112344, 128152, 140629, 149540, 154739, 156171, 153875,
+ 147984, 138721, 126390, 111370, 94099, 75064, 54779, 33779,
+ 12593, -8262, -28303, -47084, 123494, 129971, 133493, 133924,
+ 131201, 125331, 116398, 104559, 90037, 73124, 54170, 33578,
+ 11793, -10702, -33406, -55797, -77356, -97567, -115939, -132009,
+ -145355, -155607, -162458, -165670, -165080, -160609, -152268, -140154,
+ -124457, -105454, -83508, -59060, -32622, -4767, 23884, 52680,
+ 80946, 108005, 133192, 155874, 175459, 191418, 203293, 210711,
+ 213394, 211167, 203964, 191828, 174916, 153495, 127939, 98723,
+ 66416, 31667, -4798, -42202, -79720, -116501, -151685, -184419,
+ -213882, -239294, -259946, -275209, -284560, -287590, -284024, -273728,
+ -256722, -233178, -203429, -167959, -127402, -82528, -34229, 16495,
+ 68562, 120826, 172104, 221199, 266929, 308151, 343787, 372847,
+ 394455, 407868, 412493, 407908, 393872, 370338, 337461, 295599,
+ 245318, 187388, 122773, 52620, -21757, -98901, -177232, -255084,
+ -330731, -402431, -468456, -527135, -576892, -616284, -644032, -659054,
+ -660495, -647746, -620468, -578601, -522379, -452338, -369318, -274467,
+ -169243, -55405, 64986, 189594, 315816, 440826, 561623, 675096,
+ 778120, 867669, 940959, 995619, 1029881, 1042792, 1034432, 1006137,
+ 960689, 902497, 837686, 774157, 721490, 690799, 694367, 745251,
+ 856581, 1040935, 1309312, 1670468, 2129651, 2688819, 3345656, 4105519,
+ 4976393, 5840188, 6459558, 6619945, 6147045, 4905821, 2810464, -169248,
+ -4002855, -8597662, -13799897, -19399282, -25136440, -30713178, -35805064, -40075928,
+ -43193604, -44846368, -44759276, -42709760, -38541820, -32178052, -23629058, -12999656,
+ -491521, 13597969, 28880844, 44887552, 61079704, 76866240, 91622528, 104711816,
+ 115508400, 123421568, 127919688, 128553392, 124977088, 116967832, 104440944, 87461480,
+ 66251100, 41189824, 12812431, -18200672, -51037968, -84776544, -118406512, -150859520,
+ -181040640, -207862576, -230281344, -247332144, -258164320, -262074240, -258534976, -247221616,
+ -228031216, -201096704, -166793872, -125740976, -78790864, -27015406, 28317512, 85773968,
+ 143790256, 200714592, 254853088, 304518720, 348082144, 384022272, 410975936, 427784064,
+ 433533952, 427595232, 409648832, 379707872, 338129120, 285614880, 223204848, 152257552,
+ 74422120, -8399482, -94098672, -180413920, -264990464, -345444480, -419429888, -484706304,
+ -539205312, -581094272, -608834752, -621234048, -617488768, -597217728, -560484416, -507806784,
+ -440154880, -358935456, -265963920, -163424032, -53816484, 60102860, 175393008, 289004832,
+ 397862624, 498948160, 589385088, 666520704, 728003904, 771855360, 796529472, 800965376,
+ 784625088, 747518528, 690213376, 613829888, 520020448, 410934048, 289166720, 157698512,
+ 19819390, -120954952, -260974400, -396551008, -524057792, -640027584, -741248576, -824854336,
+ -888405760, -929962176, -948139904, -942156672, -911859520, -857736896, -780912768, -683123584,
+ -566678912, -434405344, -289576544, -135830144, 22925716, 182614304, 339097376, 488284896,
+ 626244608, 749307648, 854168576, 937975616, 998409984, 1033750912, 1042925056, 1025539008,
+ 981893504, 912979136, 820453376, 706599552, 574268864, 426807104, 267967136, 101810936,
+ -67397744, -235305840, -397586848, -550055296, -688779008, -810183040, -911146880, -989084800,
+ -1042054592, -1068829184, -1068826112, -1042089792, -989328512, -911898304, -811770624, -691481728,
+ -554069376, -402995648, -242059584, -75301504, 93098968, 258928160, 418044256, 566481536,
+ 700549504, 816925696, 912738304, 985637504, 1033853888, 1056241408, 1052304960, 1022211200,
+ 966782848, 887476096, 786342208, 665974016, 529439200, 380201408, 222031488, 58911676,
+ -105065728, -265801808, -419294496, -561739072, -689623232, -799814720, -889638656, -956942720,
+ -1000149696, -1018294336, -1011044736, -978708096, -922219648, -843115968, -743493120, -625951040,
+ -493525056, -349607232, -197858608, -42115448, 113708584, 265721584, 410151424, 543440192,
+ 662332480, 763955904, 845890496, 906227200, 943612480, 957278400, 947058112, 913385664,
+ 857280704, 780318336, 684585088, 572622656, 447359776, 312035584, 170115056, 25199920,
+ -119063552, -259076960, -391380192, -512737632, -620217856, -711264960, -783759808, -836069184,
+ -867082944, -876236800, -863521472, -829477248, -775175296, -702184896, -612528832, -508627616,
+ -393234080, -269360256, -140198384, -9038325, 120816904, 246134720, 363834016, 471061440,
+ 565260864, 644234816, 706195520, 749805696, 774206528, 779033856, 764420928, 730989120,
+ 679825600, 612449984, 530770240, 437028800, 333741664, 223630656, 109551536, -5580210,
+ -118864264, -227488864, -328800992, -420371296, -500052800, -566030976, -616865088, -651519232,
+ -669382144, -670276608, -654456960, -622595968, -575760768, -515379648, -443199648, -361236896,
+ -271720576, -177032864, -79645232, 17945830, 113283088, 204010512, 287931712, 363063040,
+ 427680576, 480359328, 520004224, 545871936, 557583232, 555125952, 538848000, 509441632,
+ 467918976, 415579744, 353972064, 284847840, 210113616, 131778400, 51899980, -27469024,
+ -104333832, -176807568, -243157520, -301846336, -351567360, -391273184, -420196800, -437865024,
+ -444103968, -439036576, -423072480, -396890720, -361415584, -317786848, -267324960, -211492304,
+ -151851792, -90023688, -27642056, 33688092, 92431824, 147162464, 196595872, 239620272,
+ 275320544, 302996800, 322176864, 332622304, 334328064, 327516064, 312622880, 290282112,
+ 261301872, 226638432, 187366672, 144647984, 99697160, 53748436, 8022341, -36306296,
+ -78138080, -116475864, -150447968, -179327376, -202546304, -219706160, -230582416, -235124880,
+ -233452928, -225846496, -212732912, -194670144, -172327120, -146461568, -117896304, -87494416,
+ -56134348, -24685366, 6015840, 35186796, 62118600, 86192504, 106893400, 123819856,
+ 136690672, 145347696, 149755152, 149995552, 146262368, 138849824, 128140336, 114589888,
+ 98711832, 81059840, 62210316, 42744900, 23233612, 4218996, -13798199, -30371520,
+ -45119144, -57731856, -67978520, -75708944, -80854288, -83424880, -83505872, -81250776,
+ -76873240, -70637384, -62847076, -53834452, -43948188, -33541804, -22962404, -12540202,
+ -2579104, 6651381, 14922708, 22052188, 27906138, 32401252, 35504228, 37229756,
+ 37636996, 36824736, 34925464, 32098614, 28523208, 24390258, 19895138, 15230230,
+ 10578097, 6105390, 1957699, -1744518, -4908812, -7472372, -9402388, -10695210,
+ -11374340, -11487438, -11102430, -10302999, -9183557, -7844043, -6384651, -4900844,
+ -3478715, -2191066, -1094124, -225317, 398208, 779956, 943926, 936293,
+ 833844, 703157, 565034, 427621, 299915, 188242, 97070, 28671,
+ -16282, -38631, -40246, -23848, 7370, 49924, 100305, 155103,
+ 211184, 265743, 316398, 361188, 398601, 427542, 447320, 457596,
+ 458351, 449838, 432541, 407131, 374438, 335404, 291067, 242523,
+ 190911, 137380, 83081, 29131, -23391, -73477, -120193, -162709,
+ -200302, -232373, -258456, -278222, -291483, -298191, -298431, -292422,
+ -280496, -263099, -240767, -214119, -183837, -150654, -115335, -78667,
+ -41439, -4430, 31603, 65943, 97920, 126924, 152420, 173951,
+ 191152, 203753, 211586, 214590, 212809, 206390, 195581, 180724,
+ 162245, 140642, 116472, 90338, 62871, 34716, 6512, -21115,
+ -47577, -72327, -94874, -114790, -131717, -145374, -155554, -162130,
+ -165050, -164338, -160089, -152466, -141696, -128062, -111900, -93592,
+ -73557, -52247, -30134, -7706, 14546, 36139, 56604, 75501,
+ 92426, 107025, 118997, 128106, 134187, 137146, 136964, 133700,
+ 127480, 118502, 107020, 93345, 116040, 106373, 94004, 79158,
+ 62121, 43240, 22912, 1579, -20281, -42169, -63569, -83966,
+ -102856, -119760, -134234, -145882, -154369, -159426, -160859, -158557,
+ -152493, -142728, -129410, -112770, -93122, -70853, -46417, -20326,
+ 6860, 34548, 62118, 88942, 114393, 137861, 158767, 176575,
+ 190802, 201034, 206937, 208261, 204852, 196660, 183736, 166241,
+ 144442, 118709, 89511, 57407, 23039, -12886, -49603, -86311,
+ -122184, -156394, -188125, -216596, -241075, -260902, -275496, -284383,
+ -287194, -283688, -273753, -257415, -234835, -206316, -172290, -133320,
+ -90085, -43369, 5950, 56922, 108538, 159746, 209478, 256659,
+ 300236, 339190, 372562, 399462, 419103, 430808, 434043, 428427,
+ 413772, 390087, 357626, 316892, 268676, 214058, 154439, 91515,
+ 27295, -35962, -95765, -149503, -194502, -228208, -248287, -252875,
+ -240711, -211453, -165805, -105883, -35276, 40539, 114314, 176503,
+ 215759, 217978, 167946, 29216, -265669, -759935, -1454826, -2329191,
+ -3341857, -4434792, -5535889, -6563153, -7428902, -8044769, -8326572, -8199427,
+ -7602384, -6492797, -4849871, -2677498, -5997, 3107152, 6577829, 10296906,
+ 14133125, 17937022, 21545892, 24789544, 27496750, 29502072, 30652904, 30816402,
+ 29886096, 27787848, 24484978, 19982264, 14328683, 7618649, -8275, -8369346,
+ -17242212, -26370120, -35468600, -44233488, -52350068, -59503100, -65387360, -69718488,
+ -72243656, -72751784, -71082920, -67136432, -60877660, -52342804, -41641768, -28958772,
+ -14550630, 1257369, 18077938, 35470524, 52952152, 70010080, 86115976, 100741256,
+ 113373128, 123530864, 130781872, 134756976, 135164528, 131802696, 124569704, 113471440,
+ 98626208, 80266312, 58736392, 34488268, 8072537, -19873172, -48638900, -77459776,
+ -105535736, -132052984, -156206736, -177224544, -194389536, -207063008, -214705568, -216896176,
+ -213348592, -203924480, -188642880, -167685488, -141397504, -110283944, -75001352, -36344852,
+ 4768980, 47323316, 90225720, 132335712, 172494592, 209556688, 242421216, 270063936,
+ 291567712, 306150848, 313192864, 312256320, 303104480, 285713824, 260281152, 227224928,
+ 187180496, 140989248, 89681992, 34456540, -23349740, -82291968, -140853584, -197485040,
+ -250644464, -298839136, -340666720, -374855200, -400300192, -416098816, -421578912, -416322848,
+ -400184960, -373302304, -336098016, -289277056, -233814336, -170935472, -102090216, -28919474,
+ 46783608, 123117448, 198119696, 269817600, 336279616, 395667328, 446285568, 486630272,
+ 515431904, 531693952, 534724512, 524161024, 499986336, 462536352, 412498304, 350899776,
+ 279088736, 198704400, 111640296, 19999716, -73955136, -167859072, -259303504, -345898400,
+ -425334720, -495445856, -554266496, -600087168, -631503040, -647455744, -647266496, -630660352,
+ -597779904, -549188672, -485863232, -409174688, -320859648, -222981056, -117879984, -8119592,
+ 103577704, 214398032, 321507232, 422123680, 513590720, 593446784, 659491904, 709847616,
+ 743010112, 757894080, 753866240, 730767680, 688924608, 629145984, 552709376, 461334048,
+ 357142464, 242611072, 120511064, -6158985, -134247200, -260527344, -381780576, -494877952,
+ -596861632, -685022336, -756971776, -810707072, -844666432, -857773504, -849470528, -819737792,
+ -769099840, -698617600, -609866880, -504903104, -386213792, -256659104, -119402648, 22166518,
+ 164518080, 304069184, 437275360, 560721088, 671207872, 765837888, 842089984, 897887232,
+ 931653440, 942357376, 929543168, 893346752, 834496704, 754300416, 654615040, 537804480,
+ 406682912, 264446352, 114594352, -39157032, -192968032, -342971968, -485373120, -616543680,
+ -733116800, -832073664, -910822080, -967264896, -999856064, -1007642752, -990292800, -948106752,
+ -882013184, -793548800, -684822016, -558462848, -417558400, -265576992, -106281872, 56362708,
+ 218291040, 375438528, 523844608, 659753344, 779709440, 880646656, 959966976, 1015607872,
+ 1046096320, 1050588096, 1028890880, 981471296, 909444864, 814549696, 699104192, 565949568,
+ 418379808, 260058736, 94928648, -72889120, -239197984, -399832192, -550762240, -688196992,
+ -808680064, -909177600, -987155392, -1040643904, -1068288256, -1069383232, -1043891456, -992444800,
+ -916328960, -817451520, -698297344, -561877056, -411613792, -251225136, -84665176, 83959240,
+ 250492800, 410833184, 561032192, 697392512, 816558400, 915598016, 992075520, 1044110528,
+ 1070424512, 1070372096, 1043956672, 991830592, 915278784, 816187328, 696996800, 560642560,
+ 410482208, 250213232, 83781792, -84714288, -251126384, -411357152, -561461504, -697743552,
+ -816847808, -915841536, -992287296, -1044302592, -1070606528, -1070551232, -1044137856, -992016512,
+ -915470336, -816383744, -697196352, -560842560, -410679552, -250404528, -83963680, 84544936,
+ 250972336, 411220768, 561344576, 697647424, 816773248, 915788800, 992256192, 1044292480,
+ 1070616448, 1070579840, 1044183488, 992077376, 915544384, 816468800, 697290112, 560942720,
+ 410783712, 250510352, 84068912, -84442472, -250874656, -411129728, -561261824, -697574272,
+ -816710848, -915738048, -992217536, -1044266240, -1070602624, -1070578112, -1044193344, -992097920,
+ -915574656, -816507712, -697336256, -560994752, -410840192, -250569808, -84129840, 84381496,
+ 250815008, 411072672, 561208512, 697525760, 816667968, 915701504, 992187968, 1044243968,
+ 1070587840, 1070570944, 1044193664, 992105472, 915588992, 816528256, 697362432, 561025728,
+ 410875072, 250607648, 84169704, -84340632, -250774144, -411032768, -561170496, -697490560,
+ -816636288, -915674048, -992165248, -1044226432, -1070575744, -1070564352, -1044192576, -992109760,
+ -915598336, -816542272, -697380608, -561047424, -410899648, -250634432, -84197944, 84311648,
+ 250745136, 411004448, 561143488, 697465472, 816613632, 915654272, 992148736, 1044213504,
+ 1070566592, 1070559104, 1044191232, 992112320, 915604608, 816552064, 697393600, 561063296,
+ 410917984, 250654720, 84219640, -84289112, -250722352, -410981984, -561121984, -697445376,
+ -816595520, -915638656, -992135872, -1044203776, -1070560128, -1070556032, -1044191616, -992116032,
+ -915611456, -816561792, -697405888, -561077696, -410934112, -250672080, -84237752, 84270736,
+ 250704176, 410964480, 561105536, 697430400, 816582400, 915627520, 992127104, 1044197440,
+ 1070556416, 1070555008, 1044193216, 992120256, 915618176, 816570816, 697417024, 561090688,
+ 410948576, 250687680, 84254088
+};
+
+
/* clang-format on */
diff --git a/lib_com/ivas_rom_com_fx.h b/lib_com/ivas_rom_com_fx.h
index 80f98bb353348b99eae91c0172d1163282e2249c..6692f0afd9713eac8bd2f0078baadd5a04cb058a 100644
--- a/lib_com/ivas_rom_com_fx.h
+++ b/lib_com/ivas_rom_com_fx.h
@@ -40,6 +40,7 @@
#include "stat_com.h"
#include "ivas_stat_com.h"
+
extern const Word16 ivas_sin_twiddle_480_fx[IVAS_480_PT_LEN >> 1];
extern const Word16 ivas_cos_twiddle_480_fx[IVAS_480_PT_LEN >> 1];
extern const Word16 ivas_sin_twiddle_320_fx[IVAS_320_PT_LEN >> 1];
@@ -48,6 +49,7 @@ extern const Word16 ivas_sin_twiddle_160_fx[IVAS_160_PT_LEN >> 1];
extern const Word16 ivas_cos_twiddle_160_fx[IVAS_160_PT_LEN >> 1];
extern const Word16 ivas_sin_twiddle_80_fx[IVAS_80_PT_LEN >> 1];
extern const Word16 ivas_cos_twiddle_80_fx[IVAS_80_PT_LEN >> 1];
+#ifdef IVAS_FLOAT_FIXED
extern const Word16 nf_tw_smoothing_coeffs_fx[N_LTP_GAIN_MEMS];
extern const Word32 dft_res_gains_q_fx[][2];
extern const Word16 dft_res_cod_alpha_fx[STEREO_DFT_BAND_MAX];
@@ -81,10 +83,207 @@ extern const Word32 ls_elevation_CICP16_fx[9];
extern const Word32 ls_azimuth_CICP19_fx[11];
extern const Word32 ls_elevation_CICP19_fx[11];
extern const Word16 pow_10_q11[128];
-#ifdef IVAS_FLOAT_FIXED
extern const Word32 pow_10_q23[14];
-#endif
extern const Word16 ivas_sin_az_fx[361];
extern const Word16 ivas_sine_panning_tbl_fx[601];
extern const Word16 ivas_tan_panning_gain_dirac_tbl_fx[601];
+
+/*----------------------------------------------------------------------------------*
+ * Stereo ICA ROM tables
+ *----------------------------------------------------------------------------------*/
+
+extern const Word32 ica_sincInterp2_fx[];
+
+/*----------------------------------------------------------------------------------*
+ * Stereo IC-BWE ROM tables
+ *----------------------------------------------------------------------------------*/
+
+extern const Word16 pow_10_icbwe_gsMapping_tbl_fx[];
+extern const Word16 pow_10_icbwe_gsMappingDFT_tbl_fx[];
+
+/*----------------------------------------------------------------------------------*
+ * TD Stereo ROM tables
+ *----------------------------------------------------------------------------------*/
+
+extern const UWord32 tdm_ratio_tabl_fx[TDM_NQ + 1];
+extern const Word32 tdm_ratio_tabl_fx_Q24[TDM_NQ + 1];
+extern const UWord32 tdm_den_ratio_tabl_fx[];
+
+/* LSFs Intra-frame prediction tables */
+extern const Word16 tdm_LSF_MEAN_RE_USE_OUT_fx[M];
+extern const Word16 tdm_LSF_MEAN_RE_USE_IN_fx[M];
+extern const Word16 tdm_LSF_MEAN_RE_USE_fx[M];
+
+extern const Word16 tdm_Beta_Q1bit_re_use_13k2_fx[2];
+extern const Word16 tdm_Beta_Q1bit_re_use_16k4_fx[2];
+extern const Word16 tdm_Beta_Q1bit_re_use_24k4_32k_fx[2];
+extern const Word16 tdm_Beta_Q1bit_re_use_48k_fx[2];
+
+extern const Word16 tdm_RE_USE_adaptive_beta_prd_diag_3_fx[15 + 16 + 15];
+
+extern const Word16 tdm_LSF_MEAN_PRED_QNT_OUT_fx[M];
+extern const Word16 tdm_LSF_MEAN_PRED_QNT_IN_fx[M];
+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];
+
+/*----------------------------------------------------------------------------------*
+ * Stereo DTX ROM tables
+ *----------------------------------------------------------------------------------*/
+
+extern const Word16 dft_cng_alpha_bits_fx[STEREO_DFT_N_COH_ALPHA_STEPS][STEREO_DFT_N_COH_ALPHA_LEVELS];
+extern const Word16 dft_cng_coh_pred_fx[][STEREO_DFT_COH_PRED_COEFFS];
+
+/*----------------------------------------------------------------------------------*
+ * DirAC ROM tables
+ *----------------------------------------------------------------------------------*/
+
+extern const Word32 diffuseness_reconstructions_fx[DIRAC_DIFFUSE_LEVELS];
+extern const Word32 diffuseness_thresholds_fx[DIRAC_DIFFUSE_LEVELS + 1];
+extern const Masa_Diffuseness_Ratios masa_diffuse_ratios[DIRAC_DIFFUSE_LEVELS][DIRAC_DIFFUSE_LEVELS];
+
+/*------------------------------------------------------------------------------------------*
+ * SPAR ROM tables
+ *------------------------------------------------------------------------------------------*/
+
+extern const Word32 dtx_pd_real_min_max_fx[2];
+extern const Word32 one_by_q_level[64];
+
+/*----------------------------------------------------------------------------------*
+ * Parametric MC ROM tables
+ *----------------------------------------------------------------------------------*/
+
+extern const Word16 ivas_param_mc_quant_ild_5d1_48_fx[PARAM_MC_SZ_ILD_QUANTIZER_4BITS];
+extern const Word16 ivas_param_mc_quant_icc_fx[PARAM_MC_SZ_ICC_QUANTIZER];
+
+/*----------------------------------------------------------------------------------*
+ * MASA ROM tables
+ *----------------------------------------------------------------------------------*/
+
+extern const Word32 no_phi_masa_inv_fx[NO_SPHERICAL_GRIDS][MAX_NO_THETA];
+extern const Word32 azimuth_cb_fx[8];
+extern const Word32 delta_theta_masa_fx[NO_SPHERICAL_GRIDS - 2];
+extern const Word32 coherence_cb0_masa_fx[DIRAC_DIFFUSE_LEVELS * 2 * MASA_NO_CV_COH];
+extern const Word32 coherence_cb1_masa_fx[MASA_NO_CV_COH1 * MASA_MAXIMUM_CODING_SUBBANDS]; /* 25 */
+
+/* Multi-channel input and output setups */
+extern const Word16 ls_azimuth_CICP2_idx[2];
+extern const Word16 ls_elevation_CICP2_idx[2];
+extern const Word16 ls_azimuth_CICP6_idx[5];
+extern const Word16 ls_elevation_CICP6_idx[5];
+extern const Word16 ls_azimuth_CICP12_idx[7];
+extern const Word16 ls_elevation_CICP12_idx[7];
+extern const Word16 ls_azimuth_CICP14_idx[7];
+extern const Word16 ls_elevation_CICP14_idx[7];
+extern const Word16 ls_azimuth_CICP16_idx[9];
+extern const Word16 ls_elevation_CICP16_idx[9];
+extern const Word16 ls_azimuth_CICP19_idx[11];
+extern const Word16 ls_elevation_CICP19_idx[11];
+
+extern const Word32 shoebox_sin_cos_tbl_fx[11][2];
+
+extern const Word32 delta_phi_val[90];
+extern const Word32 inv_delta_phi_val[90];
+extern const Word32 dd_val[90];
+extern const Word32 cb_azi_chan_fx[];
+
+/*----------------------------------------------------------------------------------*
+ * MASA and ISM (OMASA) combined format ROM tables
+ *----------------------------------------------------------------------------------*/
+
+extern const Word32 dct4_fx[];
+extern const Word32 dct5_fx[];
+extern const Word32 dct8_fx[];
+extern const Word32 dct12_fx[];
+
+/*----------------------------------------------------------------------------------*
+ * ISM ROM tables
+ *----------------------------------------------------------------------------------*/
+
+extern const Word32 ism_azimuth_borders_fx[4];
+extern const Word32 ism_elevation_borders_fx[4];
+
+/*----------------------------------------------------------------------------------*
+ * LFE coding ROM tables
+ *----------------------------------------------------------------------------------*/
+
+extern const Word32 ivas_lpf_4_butter_16k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2];
+extern const Word16 ivas_lpf_4_butter_16k_sos_e[IVAS_BIQUAD_FILT_LEN << 2];
+extern const Word32 ivas_lpf_4_butter_32k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2];
+extern const Word16 ivas_lpf_4_butter_32k_sos_e[IVAS_BIQUAD_FILT_LEN << 2];
+extern const Word32 ivas_lpf_4_butter_48k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2];
+extern const Word16 ivas_lpf_4_butter_48k_sos_e[IVAS_BIQUAD_FILT_LEN << 2];
+extern const Word32 ivas_lpf_2_butter_16k_fx[IVAS_BIQUAD_FILT_LEN << 1];
+extern const Word32 ivas_lpf_2_butter_32k_fx[IVAS_BIQUAD_FILT_LEN << 1];
+extern const Word32 ivas_lpf_2_butter_48k_fx[IVAS_BIQUAD_FILT_LEN << 1];
+
+extern const Word32 ivas_lfe_window_coeff_48k_fx[IVAS_LFE_FADE_LEN_48K];
+extern const Word32 ivas_lfe_window_coeff_32k_fx[IVAS_LFE_FADE_LEN_32K];
+extern const Word32 ivas_lfe_window_coeff_16k_fx[IVAS_LFE_FADE_LEN_16K];
+
+extern const UWord32 d_hamm_lfe_plc_fx[LFE_PLC_LENANA / 2];
+
+/*------------------------------------------------------------------------------------------*
+ * MDFT/iMDFT ROM tables
+ *------------------------------------------------------------------------------------------*/
+
+extern const Word32 ivas_mdft_coeff_cos_twid_240_fx[IVAS_240_PT_LEN + 1];
+extern const Word32 ivas_mdft_coeff_cos_twid_160_fx[IVAS_160_PT_LEN + 1];
+extern const Word32 ivas_mdft_coeff_cos_twid_120_fx[IVAS_120_PT_LEN + 1];
+extern const Word32 ivas_mdft_coeff_cos_twid_80_fx[IVAS_80_PT_LEN + 1];
+extern const Word32 ivas_mdft_coeff_cos_twid_40_fx[IVAS_40_PT_LEN + 1];
+extern const Word32 ivas_mdft_coeff_cos_twid_960_fx[IVAS_960_PT_LEN + 1];
+extern const Word32 ivas_mdft_coeff_cos_twid_640_fx[IVAS_640_PT_LEN + 1];
+extern const Word32 ivas_mdft_coeff_cos_twid_320_fx[IVAS_320_PT_LEN + 1];
+extern const Word32 dirac_gains_norm_term_int[9];
+extern const Word32 dirac_gains_norm_term_fx[9];
+extern const Word32 dirac_gains_Pnm_int[91][9];
+extern const Word32 dirac_gains_trg_term_int[181][2];
+extern const Word32 dirac_gains_trg_term_fx[181][2];
+
+/*------------------------------------------------------------------------------------------*
+ * FB ROM tables
+ *------------------------------------------------------------------------------------------*/
+
+extern const Word16 ivas_fb_cf_4ms_48k_fx[IVAS_FB_4MS_48K_SAMP];
+extern const Word16 ivas_fb_cf_1ms_48k_fx[IVAS_FB_1MS_48K_SAMP];
+extern const Word16 ivas_fb_cf_4ms_32k_fx[IVAS_FB_4MS_32K_SAMP];
+extern const Word16 ivas_fb_cf_1ms_32k_fx[IVAS_FB_1MS_32K_SAMP];
+extern const Word16 ivas_fb_cf_4ms_16k_fx[IVAS_FB_4MS_16K_SAMP];
+extern const Word16 ivas_fb_cf_1ms_16k_fx[IVAS_FB_1MS_16K_SAMP];
+
+extern const Word32 ivas_fb_resp_cheby_ramp_32del_fx[IVAS_FB_1MS_32K_SAMP + 1];
+extern const Word32 ivas_fb_resp_cheby_ramp_16del_fx[IVAS_FB_1MS_16K_SAMP + 1];
+
+/*------------------------------------------------------------------------------------------*
+ * SNS MSVQ codebooks and means
+ *------------------------------------------------------------------------------------------*/
+
+extern const Word16 *const ivas_sns_cdbks_tcx20_fx[];
+extern const Word16 *const ivas_sns_cdbks_tcx10_fx[];
+
+extern const Word16 *const ivas_sns_cdbks_side_tcx20_fx[];
+extern const Word16 *const ivas_sns_cdbks_side_tcx10_fx[];
+
+/*----------------------------------------------------------------------*
+ * MC ParamUpmix ROM tables
+ *-----------------------------------------------------------------------*/
+
+extern const ACPL_QUANT_TABLE_FX ivas_mc_paramupmix_alpha_quant_table_fx;
+extern const ACPL_QUANT_TABLE_FX ivas_mc_paramupmix_beta_quant_table_fx[9];
+
+extern const Word32 ivas_han_win_48k_fx[L_FRAME32k];
+extern const Word32 ivas_han_win_32k_fx[L_FRAME32k];
+extern const Word32 ivas_han_win_16k_fx[L_FRAME32k];
+
+extern const Word32 ivas_sine_delay_32_fx[32];
+
+extern const Word32 ivas_sine_frame_len_640_del_32_fx[577];
+extern const Word32 ivas_sine_frame_len_640_del_16_fx[289];
+
+extern const Word32 ivas_fb_fr_12band_1ms_re_fx[IVAS_FB_12_1MS_LEN];
+extern const Word32 ivas_fb_fr_12band_1ms_im_fx[IVAS_FB_12_1MS_LEN];
+
+#endif
+
+
#endif
diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c
index 23096223fb3a1ab1423d3fed5ec17a6cafce9c63..c5860c1c8287da6dfcd9cf0cc39df4512dddb0da 100644
--- a/lib_com/ivas_sba_config.c
+++ b/lib_com/ivas_sba_config.c
@@ -127,15 +127,15 @@ void ivas_sba_config_fx(
)
{
test();
- IF( ( LT_16( sba_order, 0 ) ) && ( LT_16( nb_channels, 0 ) ) )
+ IF( sba_order < 0 && nb_channels < 0 )
{
assert( 0 && "Either order or number of channels must be positive" );
}
- ELSE IF( LT_16( sba_order, 0 ) )
+ ELSE IF( sba_order < 0 )
{
sba_order = ivas_sba_get_order_fx( nb_channels, sba_planar );
}
- ELSE IF( LT_16( nb_channels, 0 ) )
+ ELSE IF( nb_channels < 0 )
{
nb_channels = ivas_sba_get_nchan_fx( sba_order, sba_planar );
}
@@ -154,9 +154,12 @@ void ivas_sba_config_fx(
IF( nchan_transport != NULL )
{
*nchan_transport = ivas_get_sba_num_TCs_fx( sba_total_brate, sba_order );
+ move16();
}
/* Configure core coder number of elements*/
+ test();
+ test();
IF( nchan_transport != NULL && nSCE != NULL && nCPE != NULL )
{
IF( EQ_16( *nchan_transport, 1 ) )
@@ -227,6 +230,22 @@ Word16 ivas_sba_get_order_fx(
/* sba_order = (int16_t) sqrtf( (float) nb_channels ) - 1 */
Word16 sba_order_non_sba_planar[MAX_INPUT_CHANNELS] = { 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3 };
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
IF( sba_planar )
{
diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c
index 12f546ef38ce81b0fcea000c7a4bd237d80543c7..ee29a001dd2266263cb97a95f0838ef75f8e5ce4 100644
--- a/lib_com/ivas_sns_com_fx.c
+++ b/lib_com/ivas_sns_com_fx.c
@@ -34,8 +34,7 @@
#include "options.h"
#include "cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
@@ -58,21 +57,29 @@ void sns_compute_scf_fx(
Word32 *scf,
Word16 q )
{
- Word16 i, n, k;
+ Word16 i, n, k, exp;
Word32 x[FDNS_NPTS], xs[FDNS_NPTS], mean, xl4[SNS_NPTS], nf, xl[FDNS_NPTS];
Word64 sum;
Word32 L_tmp;
const Word16 *pow_tilt;
const UWord8 nBands = pPsychParams->nBands;
+ move16();
const UWord8 *bandLengths = pPsychParams->bandLengths;
Word8 bw = 0;
+ move16();
const Word16 w_0 = 2730; // (1.0f / 12.0f) in Q15
+ move16();
const Word16 w_1 = 5461; // (2.0f / 12.0f) in Q15
+ move16();
const Word16 w_2 = 8192; // 0.25f ( 3.0f / 12.0f ) in Q15
+ move16();
const Word16 w_3 = w_2;
+ move16();
const Word16 w_4 = w_1;
+ move16();
const Word16 w_5 = w_0;
+ move16();
assert( nBands == FDNS_NPTS );
@@ -81,42 +88,62 @@ void sns_compute_scf_fx(
IF( bandLengths == NULL )
{
bw = (Word8) shr( L_frame, 6 );
+ move16();
/* Energy per band */
k = 0;
+ move16();
FOR( i = 0; i < nBands; ++i )
{
x[i] = 0;
+ move32();
FOR( n = 0; n < bw; ( ++n, ++k ) )
{
x[i] = L_add_sat( x[i], spectrum[k] );
+ move32();
}
- x[i] /= bw;
+ exp = 15;
+ move16();
+ Word16 inv_bw = Invert16( bw, &exp );
+ inv_bw = shl( inv_bw, exp );
+ x[i] = Mpy_32_16_1( x[i], inv_bw );
+ move32();
}
}
ELSE
{
/* Energy per band */
k = 0;
+ move32();
FOR( i = 0; i < nBands; ++i )
{
x[i] = 0;
+ move32();
FOR( n = 0; n < bandLengths[i]; ( ++n, ++k ) )
{
x[i] = L_add_sat( x[i], spectrum[k] );
+ move32();
}
- x[i] /= bandLengths[i];
+ exp = 15;
+ move16();
+ Word16 inv_bw = Invert16( bandLengths[i], &exp );
+ inv_bw = shl( inv_bw, exp );
+ x[i] = Mpy_32_16_1( x[i], inv_bw );
+ move32();
}
}
/* Smoothing */
xs[0] = L_add( Mpy_32_16_1( x[0], 24576 /* 0.75 in Q15 */ ), Mpy_32_16_1( x[1], 8192 /* 0.25 in Q15 */ ) );
+ move32();
FOR( i = 1; i < FDNS_NPTS - 1; i++ )
{
xs[i] = L_add( L_add( Mpy_32_16_1( x[i], 16384 /* 0.5 in Q15 */ ), Mpy_32_16_1( x[i - 1], 8192 /* 0.25 in Q15 */ ) ), Mpy_32_16_1( x[i + 1], 8192 /* 0.25 in Q15 */ ) );
+ move32();
}
xs[FDNS_NPTS - 1] = L_add( Mpy_32_16_1( x[FDNS_NPTS - 1], 24576 /* 0.75 in Q15 */ ), Mpy_32_16_1( x[FDNS_NPTS - 2], 8192 /* 0.25 in Q15 */ ) );
+ move32();
/* Pre-emphasis */
SWITCH( L_frame )
@@ -138,16 +165,20 @@ void sns_compute_scf_fx(
FOR( i = 0; i < FDNS_NPTS; i++ )
{
xs[i] = Mpy_32_16_1( xs[i], pow_tilt[i] );
+ move32();
xs[i] = L_shl( xs[i], Q4 ); // xs => Q8
+ move32();
}
/* Noise floor at -40dB */
sum = 0;
- for ( Word16 ind = 0; ind < FDNS_NPTS; ind++ )
+ move64();
+ FOR( Word16 ind = 0; ind < FDNS_NPTS; ind++ )
{
- sum += (Word64) xs[ind];
+ sum = W_add( sum, (Word64) xs[ind] );
}
- mean = (Word32) ( sum >> 6 );
+ mean = (Word32) W_shr( sum, 6 );
+ move32();
nf = Mpy_32_16_1( mean, 3 ); // 3 => powf( 10.0f, -4.0f ) in Q15
nf = L_max( nf, 0 ); // 0 => powf( 2.0f, -32.0f ) in Q15
@@ -158,6 +189,7 @@ void sns_compute_scf_fx(
if ( LT_32( xs[i], nf ) )
{
xs[i] = nf;
+ move32();
}
}
@@ -169,6 +201,7 @@ void sns_compute_scf_fx(
e_tmp = sub( sub( 30, e_tmp ), q );
/* Note: Mpy_32_16 is used temporarily for this computation, It needs to be replaced with appropriate BASOP. */
xl[i] = Mpy_32_16( e_tmp, f_tmp, 16384 ); /* Q16 */
+ move32();
}
/* Downsampling */
@@ -180,10 +213,11 @@ void sns_compute_scf_fx(
L_tmp = Madd_32_16( L_tmp, xl[3], w_4 );
L_tmp = Madd_32_16( L_tmp, xl[4], w_5 );
xl4[0] = L_tmp;
+ move32();
FOR( n = 1; n < SNS_NPTS - 1; n++ )
{
- int16_t n4 = 4 * n;
+ Word16 n4 = shl( n, 2 );
L_tmp = L_deposit_l( 0 );
L_tmp = Madd_32_16( L_tmp, xl[n4 - 1], w_0 );
@@ -193,6 +227,7 @@ void sns_compute_scf_fx(
L_tmp = Madd_32_16( L_tmp, xl[n4 + 3], w_4 );
L_tmp = Madd_32_16( L_tmp, xl[n4 + 4], w_5 );
xl4[n] = L_tmp;
+ move32();
}
L_tmp = L_deposit_l( 0 );
@@ -206,15 +241,17 @@ void sns_compute_scf_fx(
/* Remove mean and scaling */
sum = 0;
- for ( Word16 ind = 0; ind < SNS_NPTS; ind++ )
+ move64();
+ FOR( Word16 ind = 0; ind < SNS_NPTS; ind++ )
{
- sum += (Word64) xl4[ind];
+ sum = W_add( sum, (Word64) xl4[ind] );
}
- mean = (Word32) ( sum >> 4 );
+ mean = (Word32) W_shr( sum, 4 );
FOR( i = 0; i < SNS_NPTS; i++ )
{
scf[i] = Mpy_32_16_1( L_sub( xl4[i], mean ), 27853 /* 0.85 in in Q15 */ );
+ move32();
}
return;
@@ -242,14 +279,14 @@ void sns_interpolate_scalefactors_fx(
FOR( n = 0; n <= M - 2; n++ )
{
- scf_int[n * 4 + 2] = L_add( scf[n], Mpy_32_16_1( L_sub( scf[n + 1], scf[n] ), 4096 ) ); /* 4096 -> 1/8 in Q15 */
- scf_int[n * 4 + 3] = L_add( scf[n], Mpy_32_16_1( L_sub( scf[n + 1], scf[n] ), 12288 ) ); /* 12288 -> 3/8 in Q15 */
- scf_int[n * 4 + 4] = L_add( scf[n], Mpy_32_16_1( L_sub( scf[n + 1], scf[n] ), 20480 ) ); /* 20480 -> 5/8 in Q15 */
- scf_int[n * 4 + 5] = L_add( scf[n], Mpy_32_16_1( L_sub( scf[n + 1], scf[n] ), 28672 ) ); /* 28672 -> 7/8 in Q15 */
+ scf_int[add( n * 4, 2 )] = Madd_32_16( scf[n], L_sub( scf[n + 1], scf[n] ), 4096 ); /* 4096 -> 1/8 in Q15 */
+ scf_int[add( n * 4, 3 )] = Madd_32_16( scf[n], L_sub( scf[n + 1], scf[n] ), 12288 ); /* 12288 -> 3/8 in Q15 */
+ scf_int[add( n * 4, 4 )] = Madd_32_16( scf[n], L_sub( scf[n + 1], scf[n] ), 20480 ); /* 20480 -> 5/8 in Q15 */
+ scf_int[add( n * 4, 5 )] = Madd_32_16( scf[n], L_sub( scf[n + 1], scf[n] ), 28672 ); /* 28672 -> 7/8 in Q15 */
}
- scf_int[FDNS_NPTS - 2] = L_add( scf[M - 1], Mpy_32_16_1( L_sub( scf[M - 1], scf[M - 2] ), 4096 ) );
- scf_int[FDNS_NPTS - 1] = L_add( scf[M - 1], Mpy_32_16_1( L_sub( scf[M - 1], scf[M - 2] ), 12288 ) );
+ scf_int[FDNS_NPTS - 2] = Madd_32_16( scf[M - 1], L_sub( scf[M - 1], scf[M - 2] ), 4096 );
+ scf_int[FDNS_NPTS - 1] = Madd_32_16( scf[M - 1], L_sub( scf[M - 1], scf[M - 2] ), 12288 );
/* Inversion at encoder-side */
IF( encoder_side == ENC )
@@ -257,6 +294,7 @@ void sns_interpolate_scalefactors_fx(
FOR( n = 0; n < FDNS_NPTS; n++ )
{
scf_int[n] = L_negate( scf_int[n] );
+ move32();
}
}
@@ -266,6 +304,7 @@ void sns_interpolate_scalefactors_fx(
L_tmp = BASOP_util_Pow2( scf_int[n], Q15, &exp );
exp = sub( 15, exp );
scf_int[n] = L_shr( L_tmp, exp );
+ move32();
}
return;
@@ -288,77 +327,98 @@ void sns_shape_spectrum_fx(
Word16 *length )
{
Word16 i, n, k, tmp_k, bw, q_tmp = 0, shift, min_shift = 63;
+ move16();
+ move16();
Word64 L64_tmp[L_FRAME48k];
const UWord8 nBands = pPsychParams->nBands;
+ move16();
const UWord8 *bandLengths = pPsychParams->bandLengths;
IF( bandLengths == NULL )
{
- bw = L_frame / nBands;
+ bw = divide3216( shl( L_frame, 1 ), nBands );
/* Shape spectrum */
k = 0;
+ move16();
FOR( i = 0; i < nBands; ++i )
{
FOR( n = 0; n < bw; ( ++n, ++k ) )
{
L64_tmp[k] = W_mult_32_32( spectrum[k], scf_int[i] ); // Q = q_spectrum + q_scf_int + 1
+ move64();
shift = W_norm( L64_tmp[k] );
IF( LT_16( shift, min_shift ) )
{
min_shift = shift;
+ move16();
}
}
}
tmp_k = k;
+ move16();
if ( length != NULL )
{
*length = k;
+ move16();
}
q_tmp = sub( add( add( *q_spectrum, q_scf_int ), min_shift ), 32 );
- IF( GT_16( q_tmp, 30 ) )
+ if ( GT_16( q_tmp, 30 ) )
{
q_tmp = 30;
+ move16();
}
FOR( k = 0; k < tmp_k; k++ )
{
L64_tmp[k] = W_shr( L64_tmp[k], sub( add( *q_spectrum, q_scf_int ), q_tmp ) );
+ move64();
spectrum[k] = W_sat_l( L64_tmp[k] ); // Q = q_tmp
+ move64();
}
*q_spectrum = q_tmp;
+ move16();
}
ELSE
{
/* Shape spectrum */
k = 0;
+ move16();
FOR( i = 0; i < nBands; ++i )
{
FOR( n = 0; n < bandLengths[i]; ( ++n, ++k ) )
{
L64_tmp[k] = W_mult_32_32( spectrum[k], scf_int[i] ); // Q = q_spectrum + q_scf_int + 1
+ move64();
shift = W_norm( L64_tmp[k] );
IF( LT_16( shift, min_shift ) && NE_64( L64_tmp[k], 0 ) )
{
min_shift = shift;
+ move16();
}
}
}
tmp_k = k;
+ move16();
if ( length != NULL )
{
*length = k;
+ move16();
}
q_tmp = sub( add( add( *q_spectrum, q_scf_int ), min_shift ), 32 );
- IF( GT_16( q_tmp, 30 ) )
+ if ( GT_16( q_tmp, 30 ) )
{
q_tmp = 30;
+ move16();
}
FOR( k = 0; k < tmp_k; k++ )
{
L64_tmp[k] = W_shr( L64_tmp[k], sub( add( *q_spectrum, q_scf_int ), q_tmp ) );
+ move64();
spectrum[k] = W_sat_l( L64_tmp[k] ); // Q = q_tmp
+ move64();
}
*q_spectrum = q_tmp;
+ move16();
}
return;
diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c
index aa762741c9d81d877734661cd29565310fcf5d04..2a29c60740faa3f6efef218431b67ca0645a28a4 100644
--- a/lib_com/ivas_spar_com.c
+++ b/lib_com/ivas_spar_com.c
@@ -36,8 +36,7 @@
#include "basop_util.h"
#include "ivas_stat_com.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
@@ -49,6 +48,9 @@
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*------------------------------------------------------------------------------------------*
@@ -126,6 +128,7 @@ static void ivas_calc_mat_inv( float in_re[MAX_MAT_DIM][MAX_MAT_DIM], const int1
*-----------------------------------------------------------------------------------------*/
/*! r: audio BW index */
+#ifndef IVAS_FLOAT_FIXED
int16_t ivas_get_bw_idx_from_sample_rate(
const int32_t sampling_rate /* i : sampling rate */
)
@@ -150,6 +153,35 @@ int16_t ivas_get_bw_idx_from_sample_rate(
return bwidth;
}
+#else
+Word16 ivas_get_bw_idx_from_sample_rate_fx(
+ const Word32 sampling_rate /* i : sampling rate */
+)
+{
+ Word16 bwidth = 0;
+ move16();
+
+ SWITCH( sampling_rate )
+ {
+ case 16000:
+ bwidth = WB;
+ move16();
+ BREAK;
+ case 32000:
+ bwidth = SWB;
+ move16();
+ BREAK;
+ case 48000:
+ bwidth = FB;
+ move16();
+ BREAK;
+ default:
+ assert( !"Unsupported sample rate!" );
+ }
+
+ return bwidth;
+}
+#endif
/*-------------------------------------------------------------------------
* ivas_spar_config()
@@ -157,6 +189,7 @@ int16_t ivas_get_bw_idx_from_sample_rate(
* SPAR configuration function
*------------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
void ivas_spar_config(
int32_t ivas_total_brate, /* i : codec total bitrate */
const int16_t sba_order, /* i : Ambisonic (SBA) order */
@@ -215,6 +248,84 @@ void ivas_spar_config(
return;
}
+#else
+void ivas_spar_config_fx(
+ Word32 ivas_total_brate, /* i : codec total bitrate */
+ const Word16 sba_order, /* i : Ambisonic (SBA) order */
+ Word16 *nchan_transport, /* o : number of transport channels */
+ Word16 *nSCE, /* o : number of SCEs */
+ Word16 *nCPE, /* o : number of CPEs */
+ Word32 *core_nominal_brate, /* o : core-coding nominal bitrate */
+ const Word16 sid_format /* i : IVAS format indicator from SID frame */
+)
+{
+ IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
+ {
+ IF( EQ_16( sid_format, SID_SBA_1TC ) )
+ {
+ *nchan_transport = 1;
+ move16();
+ }
+ ELSE
+ {
+ *nchan_transport = 2;
+ move16();
+ }
+ }
+ ELSE
+ {
+ *nchan_transport = ivas_get_sba_num_TCs( ivas_total_brate, sba_order );
+ move16();
+ }
+
+ IF( GT_16( *nchan_transport, 1 ) )
+ {
+ *nCPE = shr( add( *nchan_transport, 1 ), 1 );
+ move16();
+ }
+ ELSE
+ {
+ *nCPE = 0;
+ move16();
+ }
+
+ *nSCE = max( 0, sub( *nchan_transport, shl( *nCPE, 1 ) ) );
+ move16();
+
+ IF( EQ_16( *nchan_transport, 1 ) )
+ {
+ /* map SPAR SID bitrate to SPAR active bitrate */
+ IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
+ {
+ ivas_total_brate = IVAS_32k;
+ move32();
+ }
+ assert( ivas_total_brate == IVAS_32k || ivas_total_brate == IVAS_24k4 || ivas_total_brate == IVAS_16k4 || ivas_total_brate == IVAS_13k2 );
+ IF( EQ_32( ivas_total_brate, IVAS_32k ) )
+ {
+ *core_nominal_brate = ACELP_24k40;
+ move32();
+ }
+ ELSE IF( EQ_32( ivas_total_brate, IVAS_24k4 ) )
+ {
+ *core_nominal_brate = ACELP_16k40;
+ move32();
+ }
+ ELSE IF( EQ_32( ivas_total_brate, IVAS_16k4 ) )
+ {
+ *core_nominal_brate = ACELP_13k20;
+ move32();
+ }
+ ELSE IF( EQ_32( ivas_total_brate, IVAS_13k2 ) )
+ {
+ *core_nominal_brate = ACELP_9k60;
+ move32();
+ }
+ }
+
+ return;
+}
+#endif
/*-----------------------------------------------------------------------------------------*
* Function ivas_get_spar_table_idx()
@@ -281,14 +392,21 @@ Word16 ivas_get_spar_table_idx_fx(
{
Word16 table_idx = 0, ind1[IVAS_SPAR_BR_TABLE_LEN];
Word16 i, j = 0, ind2 = -1;
+ move16();
+ move16();
+ move16();
FOR( i = 0; i < IVAS_SPAR_BR_TABLE_LEN; i++ )
{
ind1[j] = 0;
+ move16();
+ test();
IF( ( EQ_32( ivas_spar_br_table_consts[i].ivas_total_brate, ivas_total_brate ) ) &&
( EQ_16( ivas_spar_br_table_consts[i].sba_order, sba_order ) ) )
{
- ind1[j++] = i;
+ ind1[j] = i;
+ j = add( j, 1 );
+ move16();
}
}
@@ -297,6 +415,7 @@ Word16 ivas_get_spar_table_idx_fx(
IF( EQ_16( ivas_spar_br_table_consts[ind1[i]].bwidth, bwidth ) )
{
ind2 = i;
+ move16();
BREAK;
}
}
@@ -304,15 +423,18 @@ Word16 ivas_get_spar_table_idx_fx(
assert( ind2 >= 0 ); /* to check if bw entry is present */
table_idx = ind1[ind2];
+ move16();
IF( ind != NULL )
{
*ind = ind2;
+ move16();
}
IF( bitlen != NULL )
{
- *bitlen = ivas_get_bits_to_encode( j - 1 );
+ *bitlen = ivas_get_bits_to_encode( sub( j, 1 ) );
+ move16();
}
return table_idx;
@@ -350,6 +472,7 @@ Word16 ivas_get_sba_num_TCs_fx(
table_idx = ivas_get_spar_table_idx_fx( ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL );
nchan_transport = ivas_spar_br_table_consts[table_idx].nchan_transport;
+ move16();
return nchan_transport;
}
@@ -598,46 +721,67 @@ static void ivas_get_pred_coeffs_fx(
Word16 pred_dim = sub( in_chans, 1 );
Word16 tmp_shift, prev_tmp_shift, s_div, div_shift;
- w_norm_fac = EQ_16( from_dirac, 1 ) ? ONE_IN_Q29 : 3 * ONE_IN_Q29; // Q29
+ IF( EQ_16( from_dirac, 1 ) )
+ {
+ w_norm_fac = ONE_IN_Q29;
+ move32();
+ }
+ ELSE
+ {
+ w_norm_fac = 3 * ONE_IN_Q29;
+ move32();
+ }
tmp_shift = Q30;
- IF( EQ_16( active_w, 0 ) )
+ move16();
+ IF( active_w == 0 )
{
Word32 pPred_temp[IVAS_MAX_NUM_BANDS];
Word16 q_pred_temp;
prev_tmp_shift = 31;
+ move16();
set32_fx( pPred_temp, 0, IVAS_MAX_NUM_BANDS );
FOR( k = start_band; k < end_band; k++ )
{
div_factor[k] = L_max( 1, cov_real[0][0][k] );
+ move32();
tmp_shift = Q30;
+ move16();
IF( NE_32( cov_real[0][0][k], ONE_IN_Q30 ) )
{
div_factor[k] = L_deposit_l( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, div_factor[k], &s_div ) );
- if ( LT_16( s_div, 0 ) )
+ move32();
+ IF( s_div < 0 )
{
- div_shift = 15 + ( s_div );
+ div_shift = add( 15, s_div );
tmp_shift = Q30;
+ move16();
}
- else
+ ELSE
{
div_shift = 15;
- tmp_shift = Q30 - s_div;
+ move16();
+ tmp_shift = sub( Q30, s_div );
}
div_factor[k] = L_shl( div_factor[k], div_shift ); // Q = tmp_shift
+ move16();
IF( LT_16( tmp_shift, prev_tmp_shift ) )
{
FOR( p = start_band; p < k; p++ )
{
- div_factor[p] = L_shr( div_factor[p], prev_tmp_shift - tmp_shift );
+ div_factor[p] = L_shr( div_factor[p], sub( prev_tmp_shift, tmp_shift ) );
+ move32();
}
prev_tmp_shift = tmp_shift;
+ move16();
}
ELSE IF( GT_16( tmp_shift, prev_tmp_shift ) )
{
- div_factor[k] = L_shr( div_factor[k], tmp_shift - prev_tmp_shift );
+ div_factor[k] = L_shr( div_factor[k], sub( tmp_shift, prev_tmp_shift ) );
+ move32();
tmp_shift = prev_tmp_shift;
+ move16();
}
}
}
@@ -646,68 +790,87 @@ static void ivas_get_pred_coeffs_fx(
{
FOR( k = start_band; k < end_band; k++ )
{
- ppPred_coeffs_re[i][k] = Mpy_32_32( cov_real[i + 1][0][k], div_factor[k] ); // Q30 + temp_shift - 31 => tmp_shift - 1
+ ppPred_coeffs_re[i][k] = Mpy_32_32( cov_real[add( i, 1 )][0][k], div_factor[k] ); // Q30 + temp_shift - 31 => tmp_shift - 1
+ move32();
// IVAS_CALCULATE_SQ_ABS_N( ppPred_coeffs_re[i][k], abs_value );
abs_value = Mpy_32_32( ppPred_coeffs_re[i][k], ppPred_coeffs_re[i][k] ); // Q = 2*tmp_shift - 2 - 31
pPred_temp[k] = L_add( pPred_temp[k], abs_value ); // Q= 2*tmp_shift - 2 - 31
+ move32();
}
}
- *q_pred_coeffs = tmp_shift - 1;
+ *q_pred_coeffs = sub( tmp_shift, 1 );
+ move16();
+
FOR( k = start_band; k < end_band; k++ )
{
- q_pred_temp = 31 - ( 2 * ( *q_pred_coeffs ) - 31 );
+ q_pred_temp = sub( 31, sub( shl( *q_pred_coeffs, 1 ), 31 ) );
pPred_temp[k] = Sqrt32( pPred_temp[k], &q_pred_temp );
+ move32();
IF( LT_16( q_pred_temp, 1 ) )
{
- pPred_temp[k] = L_shr( pPred_temp[k], abs_s( q_pred_temp ) + 1 ); // Q30
+ pPred_temp[k] = L_shr( pPred_temp[k], add( abs_s( q_pred_temp ), 1 ) ); // Q30
+ move32();
q_pred_temp = 1;
+ move16();
}
ELSE IF( GT_16( q_pred_temp, 1 ) )
{
- pPred_temp[k] = L_shl( pPred_temp[k], abs_s( q_pred_temp ) - 1 ); // Q30
+ pPred_temp[k] = L_shl( pPred_temp[k], sub( abs_s( q_pred_temp ), 1 ) ); // Q30
+ move32();
q_pred_temp = 1;
+ move16();
}
- one_in_q = L_shl( 1, ( 31 - q_pred_temp ) );
+ one_in_q = L_shl( 1, sub( 31, q_pred_temp ) );
IF( LT_32( one_in_q, pPred_temp[k] ) )
{
div_factor[k] = pPred_temp[k];
+ move32();
div_factor[k] = L_deposit_l( BASOP_Util_Divide3232_Scale( one_in_q, div_factor[k], &s_div ) );
- if ( LT_16( s_div, 0 ) )
+ move32();
+ IF( s_div < 0 )
{
- div_shift = 15 + ( s_div );
+ div_shift = add( 15, s_div );
tmp_shift = Q30;
+ move16();
}
- else
+ ELSE
{
div_shift = 15;
- tmp_shift = Q30 - s_div;
+ move16();
+ tmp_shift = sub( Q30, s_div );
}
div_factor[k] = L_shl( div_factor[k], div_shift ); // Q = tmp_shift
+ move32();
}
ELSE
{
div_factor[k] = one_in_q;
- tmp_shift = ( 31 - q_pred_temp );
+ move32();
+ tmp_shift = sub( 31, q_pred_temp );
}
IF( LT_16( tmp_shift, prev_tmp_shift ) )
{
FOR( p = start_band; p < k; p++ )
{
- div_factor[p] = L_shr( div_factor[p], prev_tmp_shift - tmp_shift );
+ div_factor[p] = L_shr( div_factor[p], sub( prev_tmp_shift, tmp_shift ) );
+ move32();
}
prev_tmp_shift = tmp_shift;
+ move16();
}
ELSE IF( GT_16( tmp_shift, prev_tmp_shift ) )
{
- div_factor[k] = L_shr( div_factor[k], tmp_shift - prev_tmp_shift );
+ div_factor[k] = L_shr( div_factor[k], sub( tmp_shift, prev_tmp_shift ) );
+ move32();
tmp_shift = prev_tmp_shift;
+ move16();
}
}
@@ -716,11 +879,14 @@ static void ivas_get_pred_coeffs_fx(
FOR( k = start_band; k < end_band; k++ )
{
ppPred_coeffs_re[i][k] = Mpy_32_32( ppPred_coeffs_re[i][k], div_factor[k] ); // Q = q_pred_coeffs + tmp_shift -31
+ move32();
ppDM_Fv_re[i][k] = 0;
+ move32();
}
}
- *q_pred_coeffs = *q_pred_coeffs + tmp_shift - 31;
+ *q_pred_coeffs = sub( add( *q_pred_coeffs, tmp_shift ), 31 );
*q_dm_fv_re = 0;
+ move16();
}
ELSE
{
@@ -735,14 +901,21 @@ static void ivas_get_pred_coeffs_fx(
prev_tmp_shift = 31;
dm_alpha_e = 0;
Word16 dm_beta_re_e = 0;
+ move32();
+ move16();
+ move16();
+ move16();
+
IF( EQ_16( dyn_active_w_flag, 1 ) )
{
activew_quad_thresh = ONE_IN_Q29;
+ move32();
}
ELSE
{
activew_quad_thresh = IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH_Q29;
+ move32();
}
g_th_sq = Mpy_32_32( activew_quad_thresh, activew_quad_thresh ); // Q27
@@ -755,50 +928,65 @@ static void ivas_get_pred_coeffs_fx(
// IVAS_CALCULATE_SQ_ABS_N( cov_real[i][0][k], abs_value );
abs_value = Mpy_32_32( cov_real[i][0][k], cov_real[i][0][k] ); // Q29
dm_alpha[k] = L_add( dm_alpha[k], abs_value ); // Q29
+ move32();
}
}
FOR( k = start_band; k < end_band; k++ )
{
- dm_alpha_e = 31 - Q29;
+ dm_alpha_e = sub( 31, Q29 );
dm_alpha[k] = Sqrt32( dm_alpha[k], &dm_alpha_e );
- IF( LT_16( dm_alpha_e, 0 ) )
+ move32();
+ IF( dm_alpha_e < 0 )
{
dm_alpha[k] = L_shr( dm_alpha[k], abs_s( dm_alpha_e ) );
+ move32();
dm_alpha_e = 0;
+ move16();
}
- ELSE IF( GT_16( dm_alpha_e, 0 ) )
+ ELSE IF( dm_alpha_e > 0 )
{
dm_alpha[k] = L_shl( dm_alpha[k], abs_s( dm_alpha_e ) );
+ move32();
dm_alpha_e = 0;
+ move16();
}
div_factor[k] = L_max( dm_alpha[k], 1 );
+ move32();
div_factor[k] = L_deposit_l( BASOP_Util_Divide3232_Scale( ONE_IN_Q31, div_factor[k], &s_div ) );
- if ( LT_16( s_div, 0 ) )
+ move32();
+ IF( s_div < 0 )
{
- div_shift = 15 + ( s_div );
+ div_shift = add( 15, s_div );
tmp_shift = Q30;
+ move16();
}
- else
+ ELSE
{
div_shift = 15;
- tmp_shift = Q30 - s_div;
+ move16();
+ tmp_shift = sub( Q30, s_div );
}
div_factor[k] = L_shl( div_factor[k], div_shift ); // Q = tmp_shift
+ move32();
IF( LT_16( tmp_shift, prev_tmp_shift ) )
{
FOR( p = start_band; p < k; p++ )
{
- div_factor[p] = L_shr( div_factor[p], prev_tmp_shift - tmp_shift );
+ div_factor[p] = L_shr( div_factor[p], sub( prev_tmp_shift, tmp_shift ) );
+ move32();
}
prev_tmp_shift = tmp_shift;
+ move16();
}
ELSE IF( GT_16( tmp_shift, prev_tmp_shift ) )
{
- div_factor[k] = L_shr( div_factor[k], tmp_shift - prev_tmp_shift );
+ div_factor[k] = L_shr( div_factor[k], sub( tmp_shift, prev_tmp_shift ) );
+ move32();
tmp_shift = prev_tmp_shift;
+ move16();
}
}
@@ -807,16 +995,27 @@ static void ivas_get_pred_coeffs_fx(
FOR( k = start_band; k < end_band; k++ )
{
dm_v_re[i][k] = Mpy_32_32( cov_real[i + 1][0][k], div_factor[k] ); // Q30 + Qb - 31 = tmp_shift - 1
+ move32();
}
}
- IF( EQ_16( dtx_vad, 0 ) )
+ IF( dtx_vad == 0 )
{
dm_f_local = IVAS_ACTIVEW_DM_F_DTX_Q30;
+ move32();
}
ELSE
{
- dm_f_local = ( active_w_vlbr ) ? IVAS_ACTIVEW_DM_F_VLBR_Q30 : IVAS_ACTIVEW_DM_F_Q30;
+ IF( active_w_vlbr )
+ {
+ dm_f_local = IVAS_ACTIVEW_DM_F_VLBR_Q30;
+ move32();
+ }
+ ELSE
+ {
+ dm_f_local = IVAS_ACTIVEW_DM_F_Q30;
+ move32();
+ }
}
FOR( b = start_band; b < end_band; b++ )
@@ -830,11 +1029,13 @@ static void ivas_get_pred_coeffs_fx(
Word32 re;
// IVAS_RMULT_FLOAT( cov_real[j + 1][k][b], dm_v_re[k - 1][b], re );
- re = Mpy_32_32( cov_real[j + 1][k][b], dm_v_re[k - 1][b] ); // Q30 + Q_div_factor - 1 - 31
- real[j] = L_add( real[j], re ); // tmp_shift - 2
+ re = Mpy_32_32( cov_real[add( j, 1 )][k][b], dm_v_re[sub( k, 1 )][b] ); // Q30 + Q_div_factor - 1 - 31
+ real[j] = L_add( real[j], re ); // tmp_shift - 2
+ move32();
}
}
dm_beta_re = 0;
+ move32();
FOR( k = 0; k < pred_dim; k++ )
{
Word32 re;
@@ -843,37 +1044,45 @@ static void ivas_get_pred_coeffs_fx(
dm_beta_re = L_add( dm_beta_re, re ); // Q = 2*tmp_shift - 3 - 31
}
- dm_beta_re_e = 31 - ( 2 * tmp_shift - 3 - 31 );
+ dm_beta_re_e = sub( 31, ( sub( sub( shl( tmp_shift, 1 ), 3 ), 31 ) ) );
dm_w = cov_real[0][0][b]; // Q30
+ move32();
den_f = L_max( dm_w, 1 );
passive_g = L_deposit_l( BASOP_Util_Divide3232_Scale( dm_alpha[b], den_f, &s_div ) );
- div_shift = 15 - ( 31 - dm_alpha_e - Q30 ) + s_div - 1;
+ div_shift = add( ( sub( 15, ( sub( ( sub( 31, dm_alpha_e ) ), Q30 ) ) ) ), sub( s_div, 1 ) );
passive_g = L_shl( passive_g, div_shift ); // Q = 29
IF( EQ_16( dyn_active_w_flag, 1 ) )
{
dm_alpha[b] = 0;
+ move32();
dm_w = 0;
+ move32();
FOR( i = 0; i < pred_dim; i++ )
{
dm_v_re[i][b] = 0;
+ move32();
}
IF( NE_16( sub( tmp_shift, 1 ), 31 ) )
{
- dm_v_re[res_ind - 1][b] = L_shl( 1, sub( tmp_shift, 1 ) );
+ dm_v_re[sub( res_ind, 1 )][b] = L_shl( 1, sub( tmp_shift, 1 ) );
+ move32();
}
ELSE
{
- dm_v_re[res_ind - 1][b] = MAX_32;
+ dm_v_re[sub( res_ind, 1 )][b] = MAX_32;
+ move32();
}
passive_g = activew_quad_thresh;
+ move32();
}
IF( LT_32( passive_g, activew_quad_thresh ) )
{
/*linear activeW*/
dm_y = 0;
+ move32();
FOR( k = 1; k < in_chans; k++ )
{
@@ -883,31 +1092,37 @@ static void ivas_get_pred_coeffs_fx(
den_f = L_max( den_f, Mpy_32_32( w_norm_fac, dm_w ) ); // Q28
DM_F[b] = L_deposit_l( BASOP_Util_Divide3232_Scale( Mpy_32_32( dm_f_local, dm_alpha[b] ), den_f, &s_div ) ); // Q30 + 31 - dm_alpha_e - 31 + den_f_e - 31 => den_f_e - dm_alpha_e - 1
+ move32();
- div_shift = 15 - ( 30 - (dm_alpha_e) -28 ) + s_div;
+ div_shift = add( ( sub( 15, ( sub( ( sub( 30, dm_alpha_e ) ), 28 ) ) ) ), s_div );
DM_F[b] = L_shl( DM_F[b], div_shift ); // Q30
+ move32();
DM_F[b] = L_min( ONE_IN_Q30, DM_F[b] );
+ move32();
L_tmp1 = L_add( L_shr( dm_w, 1 ), Mpy_32_32( dm_alpha[b], DM_F[b] ) ); /* Q 29*/
L_tmp2 = Mpy_32_32( Mpy_32_32( DM_F[b], DM_F[b] ), dm_beta_re );
- L_tmp2_q = 29 + 2 * tmp_shift - 65; // simplified equation for calculating Q of L_tmp2
- L_tmp2 = L_shl( L_tmp2, ( 29 - L_tmp2_q ) );
+ L_tmp2_q = add( 29, sub( shl( tmp_shift, 1 ), 65 ) ); // simplified equation for calculating Q of L_tmp2
+ L_tmp2 = L_shl( L_tmp2, sub( 29, L_tmp2_q ) );
den_f = L_add( L_tmp1, L_tmp2 ); // Q29
den_f = L_max( den_f, 1 );
den_f_e = 29;
+ move16();
L_tmp2 = Mpy_32_32( DM_F[b], dm_beta_re );
- L_tmp2_q = 30 + 2 * tmp_shift - 34 - 31;
- L_tmp2 = L_shl( L_tmp2, ( 30 - dm_alpha_e - L_tmp2_q ) );
- L_tmp1 = L_shr( dm_alpha[b], ( 31 - dm_alpha_e - 30 ) );
+ L_tmp2_q = add( 30, sub( ( sub( shl( tmp_shift, 1 ), 34 ) ), 31 ) );
+ L_tmp2 = L_shl( L_tmp2, ( sub( ( sub( 30, dm_alpha_e ) ), L_tmp2_q ) ) );
+ L_tmp1 = L_shr( dm_alpha[b], ( sub( ( sub( 31, dm_alpha_e ) ), 30 ) ) );
L_tmp1 = L_add( L_tmp1, L_tmp2 ); // Q30
dm_g[b] = L_deposit_l( BASOP_Util_Divide3232_Scale( L_tmp1, den_f, &s_div ) ); // Q30 + den_f_e - 31
- div_shift = 15 - ( 30 - ( den_f_e ) ) + s_div;
+ move32();
+ div_shift = add( sub( 15, ( sub( 30, den_f_e ) ) ), s_div );
dm_g[b] = L_shl( dm_g[b], div_shift ); // Q30
+ move32();
}
ELSE
{
@@ -921,18 +1136,21 @@ static void ivas_get_pred_coeffs_fx(
sqrt_val = L_shl( Mpy_32_32( Mpy_32_32( dm_alpha[b], dm_alpha[b] ), g_th_sq ), 2 ); /*Q27*/
val_e = 4;
+ move16();
+
sqrt_val = BASOP_Util_Add_Mant32Exp( sqrt_val, 4, Mpy_32_32( dm_beta_re, dm_beta_re ), 2 * dm_beta_re_e, &val_e );
sqrt_val = BASOP_Util_Add_Mant32Exp( sqrt_val, val_e, L_negate( L_shl( Mpy_32_32( Mpy_32_32( dm_beta_re, g_th_sq ), dm_w ), 2 ) ), add( dm_beta_re_e, 4 + 1 ), &val_e );
// val_e = norm_l( sqrt_val );
sqrt_val = Sqrt32( sqrt_val, &val_e );
- IF( LT_16( val_e, 0 ) )
+ IF( val_e < 0 )
{
sqrt_val = L_shr( sqrt_val, abs_s( val_e ) );
}
- ELSE IF( GT_16( val_e, 0 ) )
+ ELSE IF( val_e > 0 )
{
sqrt_val = L_shl( sqrt_val, abs_s( val_e ) );
val_e = 0;
+ move16();
}
num_f = BASOP_Util_Add_Mant32Exp( num_f, num_f_e, sqrt_val, 0, &num_f_e );
@@ -940,10 +1158,13 @@ static void ivas_get_pred_coeffs_fx(
den_f_e = add( dm_beta_re_e, 4 );
den_f = L_max( den_f, 1 );
dm_g[b] = activew_quad_thresh; // Q29
+ move32();
DM_F[b] = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_32( dm_g[b], num_f ), den_f, &s_dm_f );
+ move32();
s_dm_f = add( s_dm_f, sub( add( 2, num_f_e ), den_f_e ) ); /*Resultant exp for DM_F s_dm_f +( 2 + num_f_e ) - den_f_e*/
div_shift = sub( s_dm_f, 1 );
DM_F[b] = L_shl( DM_F[b], div_shift ); // Q30
+ move32();
}
}
@@ -952,11 +1173,15 @@ static void ivas_get_pred_coeffs_fx(
FOR( b = start_band; b < end_band; b++ )
{
ppPred_coeffs_re[i][b] = Mpy_32_32( dm_v_re[i][b], dm_g[b] ); // Q = tmp_shift - 1 + 30 - 31
+ move32();
ppDM_Fv_re[i][b] = Mpy_32_32( dm_v_re[i][b], DM_F[b] );
+ move32();
}
}
- *q_pred_coeffs = tmp_shift - 2;
- *q_dm_fv_re = tmp_shift - 2;
+ *q_pred_coeffs = sub( tmp_shift, 2 );
+ move16();
+ *q_dm_fv_re = sub( tmp_shift, 2 );
+ move16();
}
return;
@@ -1068,12 +1293,12 @@ static void ivas_get_Wscaling_factor_fx(
set32_fx( postpred_cov_re[ch], 0, IVAS_SPAR_MAX_CH );
}
- IF( EQ_16( dtx_vad, 0 ) )
+ IF( dtx_vad == 0 )
{
dm_f_local = IVAS_ACTIVEW_DM_F_SCALE_DTX_FX; // Q31
move32();
}
- ELSE IF( NE_16( active_w_vlbr, 0 ) )
+ ELSE IF( active_w_vlbr != 0 )
{
dm_f_local = IVAS_ACTIVEW_DM_F_SCALE_VLBR_FX; // Q31
move32();
@@ -1090,7 +1315,7 @@ static void ivas_get_Wscaling_factor_fx(
move32();
test();
- IF( EQ_16( active_w, 1 ) && EQ_16( dyn_active_w_flag, 0 ) )
+ IF( EQ_16( active_w, 1 ) && ( dyn_active_w_flag == 0 ) )
{
Word16 guard_bits, q_Gw_sq, q_g_sq, q_min, tmp_exp;
Word32 Gw_sq, g_sq, tmp;
@@ -1108,7 +1333,7 @@ static void ivas_get_Wscaling_factor_fx(
guard_bits = find_guarded_bits_fx( num_ch );
- FOR( ch = 0; ch < num_ch - 1; ch++ )
+ FOR( ch = 0; ch < sub( num_ch, 1 ); ch++ )
{
abs_val = L_shr( Mpy_32_32( pred_coeffs_re[ch][b], pred_coeffs_re[ch][b] ), guard_bits );
g_sq = L_add( g_sq, abs_val );
@@ -1141,6 +1366,7 @@ static void ivas_get_Wscaling_factor_fx(
tmp = L_shr( tmp, sub( q_tmp, q_min ) );
pWscale[b] = Mpy_32_32( L_add( Gw_sq, tmp ), ONE_IN_Q30 /* 0.5 in Q31*/ );
+ move32();
q_pWscale[b] = q_Gw_sq;
move16();
}
@@ -1321,7 +1547,7 @@ void ivas_create_fullr_dmx_mat_fx(
{
FOR( b = start_band; b < end_band; b++ )
{
- tmp_p2_re[j][0][b] = -pred_coeffs_re[j - 1][b];
+ tmp_p2_re[j][0][b] = L_negate( pred_coeffs_re[sub( j, 1 )][b] );
move32();
max_val_tmp_p2 = L_max( max_val_tmp_p2, L_abs( tmp_p2_re[j][0][b] ) );
}
@@ -1349,7 +1575,7 @@ void ivas_create_fullr_dmx_mat_fx(
{
FOR( b = start_band; b < end_band; b++ )
{
- tmp_p1_re[0][j][b] = dm_fv_re[j - 1][b];
+ tmp_p1_re[0][j][b] = dm_fv_re[sub( j, 1 )][b];
move32();
max_val = L_max( max_val, L_abs( tmp_p1_re[0][j][b] ) );
}
@@ -1374,6 +1600,7 @@ void ivas_create_fullr_dmx_mat_fx(
}
}
*q_mixer_mat = sub( add( q_dm_fv_re, q_pred_coeffs_re ), add( 31, guard_bits ) );
+ move16();
}
ELSE
{
@@ -1389,6 +1616,7 @@ void ivas_create_fullr_dmx_mat_fx(
}
}
*q_mixer_mat = q_pred_coeffs_re;
+ move16();
}
IF( NE_16( remix_unmix_order, 3 ) )
@@ -1591,13 +1819,15 @@ static void ivas_calc_post_pred_per_band_fx(
FOR( j = 0; j < num_ch; j++ )
{
tmp_re = 0;
+ move64();
FOR( k = 0; k < num_ch; k++ )
{
tmp_re = W_add( tmp_re, W_shr( W_mult0_32_32( cov_real[i][k][band_idx], dmx_mat_conj[k][j] ), guard_bits ) );
}
- IF( LT_64( W_abs( tmp_re ), L_shl( IVAS_FIX_EPS, guard_bits ) ) )
+ if ( LT_64( W_abs( tmp_re ), L_shl( IVAS_FIX_EPS, guard_bits ) ) )
{
tmp_re = 0;
+ move64();
}
temp_mat[i][j] = W_extract_l( W_shr( tmp_re, q_mixer_mat ) ); // Q = (q_cov_real - guard_bits)
move32();
@@ -1631,7 +1861,7 @@ static void ivas_calc_post_pred_per_band_fx(
tmp_re = W_add( tmp_re, W_shr( W_mult0_32_32( mixer_mat[i][k][band_idx], temp_mat[k][j] ), guard_bits ) );
}
- IF( LT_64( W_abs( tmp_re ), L_shl( IVAS_FIX_EPS, guard_bits ) ) )
+ if ( LT_64( W_abs( tmp_re ), L_shl( IVAS_FIX_EPS, guard_bits ) ) )
{
tmp_re = 0;
move64();
@@ -1643,6 +1873,7 @@ static void ivas_calc_post_pred_per_band_fx(
}
*q_postpred_cov_re = sub( q_temp_mat, guard_bits );
+ move16();
FOR( i = 0; i < num_ch; i++ )
{
@@ -1886,29 +2117,29 @@ static void ivas_calc_p_coeffs_per_band_fx(
set32_fx( pSparMd->band_coeffs[b_ts_idx].P_re_fx, 0, IVAS_SPAR_MAX_CH - 1 );
pSparMd->band_coeffs[b_ts_idx].q_P_re_fx = 0;
move16();
- FOR( i = 0; i < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; i++ )
+ FOR( i = 0; i < sub( IVAS_SPAR_MAX_CH, IVAS_SPAR_MAX_DMX_CHS ); i++ )
{
- set32_fx( recon_uu_re[i], 0, IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS );
+ set32_fx( recon_uu_re[i], 0, sub( IVAS_SPAR_MAX_CH, IVAS_SPAR_MAX_DMX_CHS ) );
}
FOR( i = num_dmx; i < num_ch; i++ )
{
FOR( j = num_dmx; j < num_ch; j++ )
{
- cov_uu_re[i - num_dmx][j - num_dmx] = postpred_cov_re[i][j];
+ cov_uu_re[sub( i, num_dmx )][sub( j, num_dmx )] = postpred_cov_re[i][j];
move32();
}
}
q_cov_uu_re = q_postpred_cov_re;
move16();
- IF( dtx_vad == 1 )
+ IF( EQ_16( dtx_vad, 1 ) )
{
FOR( i = 1; i < num_dmx; i++ )
{
FOR( j = 1; j < num_dmx; j++ )
{
- cov_dd_re[i - 1][j - 1] = postpred_cov_re[i][j];
+ cov_dd_re[sub( i, 1 )][sub( j, 1 )] = postpred_cov_re[i][j];
move32();
}
}
@@ -1927,6 +2158,10 @@ static void ivas_calc_p_coeffs_per_band_fx(
recon_uu_re[0][1] = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re1 ), q_C_re ) );
recon_uu_re[1][0] = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re2 ), q_C_re ) );
recon_uu_re[1][1] = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re2 ), q_C_re ) );
+ move32();
+ move32();
+ move32();
+ move32();
FOR( i = 0; i < 2; i++ )
{
@@ -1958,8 +2193,10 @@ static void ivas_calc_p_coeffs_per_band_fx(
move32();
re2 = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][1], re1[1] ), q_C_re ) );
recon_uu_re[0][0] = L_add( recon_uu_re[0][0], re2 );
+ move32();
cov_uu_re[0][0] = L_sub( cov_uu_re[0][0], recon_uu_re[0][0] );
+ move32();
}
ELSE IF( EQ_16( num_dmx, 4 ) )
{
@@ -1990,7 +2227,7 @@ static void ivas_calc_p_coeffs_per_band_fx(
}
/* Step 2: cov_uu - recon_uu */
- FOR( i = 0; i < num_ch - num_dmx; i++ )
+ FOR( i = 0; i < sub( num_ch, num_dmx ); i++ )
{
FOR( j = 0; j < num_ch - num_dmx; j++ )
{
@@ -2005,7 +2242,7 @@ static void ivas_calc_p_coeffs_per_band_fx(
move32();
test();
- IF( EQ_16( dtx_vad, 0 ) && EQ_16( num_dmx, 1 ) )
+ if ( ( dtx_vad == 0 ) && EQ_16( num_dmx, 1 ) )
{
p_norm_scaling = IVAS_P_NORM_SCALING_DTX_FX;
move32();
@@ -2016,7 +2253,7 @@ static void ivas_calc_p_coeffs_per_band_fx(
FOR( i = num_dmx; i < num_ch; i++ )
{
- trace = L_add( trace, L_abs( cov_uu_re[i - num_dmx][i - num_dmx] ) );
+ trace = L_add( trace, L_abs( cov_uu_re[sub( i, num_dmx )][sub( i, num_dmx )] ) );
}
factor = L_max( IVAS_FIX_EPS, postpred_cov_re[0][0] );
@@ -2035,7 +2272,7 @@ static void ivas_calc_p_coeffs_per_band_fx(
IF( EQ_16( i, j ) )
{
/* force diagonal to be real */
- cov_uu_re[i - num_dmx][j - num_dmx] = W_extract_l( W_shr( W_mult0_32_32( cov_uu_re[i - num_dmx][j - num_dmx], factor ), 15 ) );
+ cov_uu_re[sub( i, num_dmx )][sub( j, num_dmx )] = W_extract_l( W_shr( W_mult0_32_32( cov_uu_re[sub( i, num_dmx )][sub( j, num_dmx )], factor ), 15 ) );
move32();
}
ELSE
@@ -2052,8 +2289,8 @@ static void ivas_calc_p_coeffs_per_band_fx(
FOR( i = num_dmx; i < num_ch; i++ )
{
cov_uu_re_exp = sub( 31, q_cov_uu_re );
- cov_uu_re[i - num_dmx][i - num_dmx] = Sqrt32( L_max( 0, cov_uu_re[i - num_dmx][i - num_dmx] ), &cov_uu_re_exp );
- cov_uu_re[i - num_dmx][i - num_dmx] = L_shl( cov_uu_re[i - num_dmx][i - num_dmx], sub( q_cov_uu_re, sub( 31, cov_uu_re_exp ) ) );
+ cov_uu_re[sub( i, num_dmx )][sub( i, num_dmx )] = Sqrt32( L_max( 0, cov_uu_re[sub( i, num_dmx )][sub( i, num_dmx )] ), &cov_uu_re_exp );
+ cov_uu_re[sub( i, num_dmx )][sub( i, num_dmx )] = L_shl( cov_uu_re[sub( i, num_dmx )][sub( i, num_dmx )], sub( q_cov_uu_re, sub( 31, cov_uu_re_exp ) ) );
move32();
move32();
}
@@ -2065,7 +2302,7 @@ static void ivas_calc_p_coeffs_per_band_fx(
{
IF( EQ_16( i, j ) )
{
- pSparMd->band_coeffs[b_ts_idx].P_re_fx[j - num_dmx] = cov_uu_re[i - num_dmx][j - num_dmx];
+ pSparMd->band_coeffs[b_ts_idx].P_re_fx[sub( j, num_dmx )] = cov_uu_re[sub( i, num_dmx )][sub( j, num_dmx )];
move32();
}
}
@@ -2199,9 +2436,9 @@ static void ivas_calc_c_coeffs_per_band_fx(
b_ts_idx = add( band_idx, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) );
- IF( EQ_16( dtx_vad, 0 ) )
+ IF( dtx_vad == 0 )
{
- set32_fx( &pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], 0, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) );
+ set32_fx( &pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], 0, imult1616( sub( IVAS_SPAR_MAX_CH, IVAS_SPAR_MAX_DMX_CHS ), sub( IVAS_SPAR_MAX_DMX_CHS, 1 ) ) );
pSparMd->band_coeffs[b_ts_idx].q_C_re_fx = 0;
move16();
return;
@@ -2211,7 +2448,7 @@ static void ivas_calc_c_coeffs_per_band_fx(
{
FOR( j = 1; j < num_dmx; j++ )
{
- cov_ud_re[i - num_dmx][j - 1] = postpred_cov_re[i][j];
+ cov_ud_re[sub( i, num_dmx )][sub( j, 1 )] = postpred_cov_re[i][j];
move32();
}
}
@@ -2220,7 +2457,8 @@ static void ivas_calc_c_coeffs_per_band_fx(
{
FOR( j = 1; j < num_dmx; j++ )
{
- cov_dd_re[i - 1][j - 1] = postpred_cov_re[i][j];
+ cov_dd_re[sub( i, 1 )][sub( j, 1 )] = postpred_cov_re[i][j];
+ move32();
}
}
@@ -2238,40 +2476,40 @@ static void ivas_calc_c_coeffs_per_band_fx(
IF( LE_32( abs_trace, IVAS_FIX_EPS ) )
{
/* protection from cases when variance of residual channels is very small */
- set32_fx( &pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], 0, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) );
+ set32_fx( &pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], 0, imult1616( sub( IVAS_SPAR_MAX_CH, IVAS_SPAR_MAX_DMX_CHS ), sub( IVAS_SPAR_MAX_DMX_CHS, 1 ) ) );
pSparMd->band_coeffs[b_ts_idx].q_C_re_fx = 0;
move16();
}
ELSE
{
- FOR( i = 0; i < num_dmx - 1; i++ )
+ FOR( i = 0; i < sub( num_dmx, 1 ); i++ )
{
cov_dd_re[i][i] = L_add( trace_cov_dd_re, cov_dd_re[i][i] );
move32();
}
test();
- IF( EQ_16( ivas_is_mat_inv_fx( cov_dd_re, q_post_pred_cov_re, num_dmx - 1 ), 1 ) && LT_16( num_dmx, FOA_CHANNELS ) )
+ IF( EQ_16( ivas_is_mat_inv_fx( cov_dd_re, q_post_pred_cov_re, sub( num_dmx, 1 ) ), 1 ) && LT_16( num_dmx, FOA_CHANNELS ) )
{
- set32_fx( &pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], 0, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) );
+ set32_fx( &pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], 0, imult1616( sub( IVAS_SPAR_MAX_CH, IVAS_SPAR_MAX_DMX_CHS ), sub( IVAS_SPAR_MAX_DMX_CHS, 1 ) ) );
pSparMd->band_coeffs[b_ts_idx].q_C_re_fx = 0;
move16();
}
ELSE
{
- ivas_calc_mat_inv_fx( cov_dd_re, q_post_pred_cov_re, num_dmx - 1, cov_dd_re_inv, &q_cov_dd_re_inv );
+ ivas_calc_mat_inv_fx( cov_dd_re, q_post_pred_cov_re, sub( num_dmx, 1 ), cov_dd_re_inv, &q_cov_dd_re_inv );
Word16 tmp;
Word64 max_val = 1;
move64();
Word64 C_re_fx[IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS][IVAS_SPAR_MAX_DMX_CHS - 1];
- FOR( i = 0; i < num_ch - num_dmx; i++ )
+ FOR( i = 0; i < sub( num_ch, num_dmx ); i++ )
{
- FOR( j = 0; j < num_dmx - 1; j++ )
+ FOR( j = 0; j < sub( num_dmx, 1 ); j++ )
{
C_re_fx[i][j] = 0;
move64();
- FOR( k = 0; k < num_dmx - 1; k++ )
+ FOR( k = 0; k < sub( num_dmx, 1 ); k++ )
{
C_re_fx[i][j] = W_add_nosat( C_re_fx[i][j], W_mult0_32_32( cov_ud_re[i][k], cov_dd_re_inv[k][j] ) );
move64();
@@ -2285,15 +2523,16 @@ static void ivas_calc_c_coeffs_per_band_fx(
tmp = s_max( sub( 32, W_norm( max_val ) ), 0 );
- FOR( i = 0; i < num_ch - num_dmx; i++ )
+ FOR( i = 0; i < sub( num_ch, num_dmx ); i++ )
{
- FOR( j = 0; j < num_dmx - 1; j++ )
+ FOR( j = 0; j < sub( num_dmx, 1 ); j++ )
{
pSparMd->band_coeffs[b_ts_idx].C_re_fx[i][j] = W_extract_l( W_shr( C_re_fx[i][j], tmp ) );
move32();
}
}
pSparMd->band_coeffs[b_ts_idx].q_C_re_fx = sub( add( q_cov_dd_re_inv, q_post_pred_cov_re ), tmp );
+ move16();
}
}
@@ -2396,15 +2635,15 @@ void ivas_calc_c_p_coeffs_fx(
IF( dyn_active_w_flag )
{
- FOR( i = 0; i < num_ch - num_dmx; i++ )
+ FOR( i = 0; i < sub( num_ch, num_dmx ); i++ )
{
- FOR( j = 0; j < num_dmx - 1; j++ )
+ FOR( j = 0; j < sub( num_dmx, 1 ); j++ )
{
- pSparMd->band_coeffs[band_idx + i_ts * IVAS_MAX_NUM_BANDS].C_re_fx[i][j] = 0;
+ pSparMd->band_coeffs[add( band_idx, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].C_re_fx[i][j] = 0;
move32();
}
}
- pSparMd->band_coeffs[band_idx + i_ts * IVAS_MAX_NUM_BANDS].q_C_re_fx = 0;
+ pSparMd->band_coeffs[add( band_idx, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].q_C_re_fx = 0;
move16();
}
IF( EQ_16( compute_p_flag, 1 ) )
@@ -2416,10 +2655,10 @@ void ivas_calc_c_p_coeffs_fx(
{
FOR( i = num_dmx; i < num_ch; i++ )
{
- pSparMd->band_coeffs[band_idx + i_ts * IVAS_MAX_NUM_BANDS].P_re_fx[i - num_dmx] = 0;
+ pSparMd->band_coeffs[add( band_idx, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].P_re_fx[sub( i, num_dmx )] = 0;
move32();
}
- pSparMd->band_coeffs[band_idx + i_ts * IVAS_MAX_NUM_BANDS].q_P_re_fx = 0;
+ pSparMd->band_coeffs[add( band_idx, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].q_P_re_fx = 0;
move16();
}
}
@@ -2509,6 +2748,7 @@ static void ivas_calc_mat_det_fx(
re1 = W_mult0_32_32( in_re[0][1], W_extract_h( re ) );
*det_re = W_sub_nosat( *det_re, re1 );
+ move64();
re1 = W_mult0_32_32( in_re[1][0], in_re[2][1] );
re2 = W_mult0_32_32( in_re[1][1], in_re[2][0] );
@@ -2517,8 +2757,10 @@ static void ivas_calc_mat_det_fx(
re1 = W_mult0_32_32( in_re[0][2], W_extract_h( re ) );
*det_re = W_add_nosat( *det_re, re1 );
+ move64();
*q_det_re = add( q_in_re, sub( add( q_in_re, q_in_re ), 32 ) );
+ move16();
}
ELSE IF( EQ_16( dim, IVAS_MAT_DIM_2 ) )
{
@@ -2526,7 +2768,9 @@ static void ivas_calc_mat_det_fx(
re1 = W_mult0_32_32( in_re[0][0], in_re[1][1] );
re2 = W_mult0_32_32( in_re[0][1], in_re[1][0] );
*det_re = W_sub_nosat( re1, re2 );
+ move64();
*q_det_re = add( q_in_re, q_in_re );
+ move16();
}
ELSE IF( EQ_16( dim, IVAS_MAT_DIM_1 ) )
{
@@ -2772,13 +3016,18 @@ static void ivas_calc_mat_inv_fx(
out_re[0][0] = Mpy_32_16_1( in_re[1][1], one_by_det );
- out_re[0][1] = -Mpy_32_16_1( in_re[0][1], one_by_det );
+ out_re[0][1] = L_negate( Mpy_32_16_1( in_re[0][1], one_by_det ) );
- out_re[1][0] = -Mpy_32_16_1( in_re[1][0], one_by_det );
+ out_re[1][0] = L_negate( Mpy_32_16_1( in_re[1][0], one_by_det ) );
out_re[1][1] = Mpy_32_16_1( in_re[0][0], one_by_det );
+ move32();
+ move32();
+ move32();
+ move32();
*q_out_re = sub( q_in_re, add( q_tmp, q_det_re ) ); // Q = (15-(q_tmp + q_det_re)) + q_in_re - 15
+ move16();
}
ELSE IF( EQ_16( dim, IVAS_MAT_DIM_3 ) )
{
@@ -2796,7 +3045,7 @@ static void ivas_calc_mat_inv_fx(
det_re = W_shr( det_re, q_tmp );
q_det_re = sub( q_det_re, q_tmp );
- IF( EQ_64( det_re, 0 ) )
+ if ( det_re == 0 )
{
det_re = 1;
move64();
@@ -2830,6 +3079,7 @@ static void ivas_calc_mat_inv_fx(
}
}
*q_out_re = sub( add( sub( q_W_tmp, 32 ), q_one_by_det ), 15 );
+ move16();
}
ELSE
{
@@ -2899,7 +3149,7 @@ static Word16 ivas_is_mat_inv_fx(
det = W_mult0_32_32( W_extract_l( det_re ), W_extract_l( det_re ) );
- IF( LE_64( det, IVAS_FIX_EPS ) )
+ if ( LE_64( det, IVAS_FIX_EPS ) )
{
is_det_zero = 1;
move16();
@@ -3011,25 +3261,24 @@ void ivas_compute_spar_params_fx(
q_tmp = sub( 15, tmp_exp );
tmp = sub( add( q_pred_coeffs, q_tmp ), 15 );
- FOR( i = 0; i < num_ch - 1; i++ )
+ FOR( i = 0; i < sub( num_ch, 1 ); i++ )
{
- hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re_fx[i] = Mpy_32_16_1( pred_coeffs_re[i][b], onebyscale_fx );
+ hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].pred_re_fx[i] = Mpy_32_16_1( pred_coeffs_re[i][b], onebyscale_fx );
move32();
- IF( LT_16( tmp, 0 ) )
+ IF( tmp < 0 )
{
- tmp = -tmp;
- move16();
- hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re_fx[i] = L_shl( hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re_fx[i], add( tmp, 22 ) );
+ tmp = negate( tmp );
+ hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].pred_re_fx[i] = L_shl( hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].pred_re_fx[i], add( tmp, 22 ) );
move32();
}
ELSE
{
- hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re_fx[i] = L_shr( hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re_fx[i], sub( tmp, 22 ) );
+ hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].pred_re_fx[i] = L_shr( hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].pred_re_fx[i], sub( tmp, 22 ) );
move32();
}
}
// hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].q_pred_re_fx = sub(add(q_pred_coeffs, q_tmp), 15);
- hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].q_pred_re_fx = Q22;
+ hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].q_pred_re_fx = Q22;
move16();
FOR( i = 0; i < num_ch; i++ )
@@ -3041,22 +3290,22 @@ void ivas_compute_spar_params_fx(
FOR( b = start_band; b < end_band; b++ )
{
- ndm = hSparCfg->num_dmx_chans_per_band[b * bands_bw];
+ ndm = hSparCfg->num_dmx_chans_per_band[imult1616( b, bands_bw )];
move16();
IF( NE_16( ndm, num_ch ) )
{
ivas_calc_c_p_coeffs_fx( hSparMd, cov_real, q_cov_real, i_ts, mixer_mat_fx, *q_mixer_mat, num_ch, ndm, b, dtx_vad, 1, dyn_active_w_flag );
- Word16 q_tmp = hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].q_C_re_fx;
+ Word16 q_tmp = hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].q_C_re_fx;
IF( NE_16( ndm, 1 ) )
{
#ifdef MSAN_FIX
- FOR( i = 0; i < num_ch - ndm; i++ )
+ FOR( i = 0; i < sub( num_ch, ndm ); i++ )
{
- FOR( int j = 0; j < ndm - 1; j++ )
+ FOR( Word16 j = 0; j < sub( ndm, 1 ); j++ )
{
- hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re_fx[i][j] = L_shr( hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re_fx[i][j], sub( q_tmp, 22 ) );
+ hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].C_re_fx[i][j] = L_shr( hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].C_re_fx[i][j], sub( q_tmp, 22 ) );
move32();
}
}
@@ -3069,16 +3318,20 @@ void ivas_compute_spar_params_fx(
}
}
#endif
- hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].q_C_re_fx = Q22;
+ hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].q_C_re_fx = Q22;
+ move16();
}
- q_tmp = hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].q_P_re_fx;
+ q_tmp = hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].q_P_re_fx;
+ move16();
- for ( int j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
+ FOR( Word16 j = 0; j < sub( IVAS_SPAR_MAX_CH, 1 ); j++ )
{
- hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].P_re_fx[j] = L_shr( hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].P_re_fx[j], sub( q_tmp, 22 ) );
+ hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].P_re_fx[j] = L_shr( hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].P_re_fx[j], sub( q_tmp, 22 ) );
+ move32();
}
- hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].q_P_re_fx = Q22;
+ hSparMd->band_coeffs[add( b, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )].q_P_re_fx = Q22;
+ move16();
}
}
@@ -3118,515 +3371,490 @@ void ivas_get_spar_md_from_dirac_fx(
const int16_t dyn_active_w_flag )
{
- int16_t num_ch, band, i, j;
- int16_t block, ch;
+ Word16 num_ch, band, i, j;
+ Word16 block, ch;
- // float response_avg[MAX_OUTPUT_CHANNELS];
Word32 response_avg_fx[MAX_OUTPUT_CHANNELS];
- // float response[MAX_PARAM_SPATIAL_SUBFRAMES][MAX_OUTPUT_CHANNELS];
Word32 response_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MAX_OUTPUT_CHANNELS];
- // float cov_real_dirac[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS];
Word32 cov_real_dirac_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS];
- // float *pCov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
Word32 *pCov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
- // float dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS];
Word32 dm_fv_re_fx[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS];
Word16 q_dm_fv_re_fx = 0;
- // float Wscale[IVAS_MAX_NUM_BANDS];
- Word16 q_Wscale[IVAS_MAX_NUM_BANDS] = { 0 };
- Word32 Wscale_fx[IVAS_MAX_NUM_BANDS] = { 0 };
- // float mixer_mat_local[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH][IVAS_MAX_NUM_BANDS];
+ Word16 q_Wscale[IVAS_MAX_NUM_BANDS];
+ Word32 Wscale_fx[IVAS_MAX_NUM_BANDS];
Word32 mixer_mat_local_fx[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH][IVAS_MAX_NUM_BANDS];
- // float **ppMixer_mat[IVAS_MAX_FB_MIXER_OUT_CH];
Word32 **ppMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH];
- // float *pMixer_mat[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH];
Word32 *pMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH];
Word16 q_ppMixer_mat = 0;
- // float en_ratio_fac, diff_norm_order1, diff_norm_order2, diff_norm_order3;
Word32 en_ratio_fac_fx, diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx;
- int16_t active_w;
+ Word16 active_w;
+ move16();
+ move16();
- int16_t ndm, foa_ch, hoa2_ch;
- // float P_dir_fact[IVAS_SPAR_MAX_CH - 1];
+ Word16 ndm, foa_ch, hoa2_ch;
Word32 P_dir_fact_fx[IVAS_SPAR_MAX_CH - 1];
- const int16_t *remix_order;
+ const Word16 *remix_order;
+ set16_fx( q_Wscale, 0, IVAS_MAX_NUM_BANDS );
+ set32_fx( Wscale_fx, 0, IVAS_MAX_NUM_BANDS );
remix_order = remix_order_set[hSpar_md_cfg->remix_unmix_order];
num_ch = ivas_sba_get_nchan_metadata_fx( order, IVAS_256k /*dummy value as order is always 1 in this function*/ );
hoa2_ch = ivas_sba_get_nchan_metadata_fx( SBA_HOA2_ORDER, IVAS_256k /*dummy value as order is always 1 in this function*/ );
- // hoa2_ch max 6
foa_ch = FOA_CHANNELS;
- // foa_ch 4;
- // diff_norm_order1 = 3.0f;
+ move16();
diff_norm_order1_fx = 3;
- // diff_norm_order2 = 5.0f;
+ move32();
diff_norm_order2_fx = 5;
- // diff_norm_order3 = 7.0f;
+ move32();
diff_norm_order3_fx = 7;
+ move32();
- for ( i = 0; i < IVAS_MAX_FB_MIXER_OUT_CH; i++ )
+ FOR( i = 0; i < IVAS_MAX_FB_MIXER_OUT_CH; i++ )
{
- for ( j = 0; j < IVAS_MAX_SPAR_FB_MIXER_IN_CH; j++ )
+ FOR( j = 0; j < IVAS_MAX_SPAR_FB_MIXER_IN_CH; j++ )
{
- // pMixer_mat[i][j] = mixer_mat_local[i][j];
pMixer_mat_fx[i][j] = mixer_mat_local_fx[i][j];
+ move32();
}
- // ppMixer_mat[i] = pMixer_mat[i];
ppMixer_mat_fx[i] = pMixer_mat_fx[i];
+ move32();
}
- if ( ( start_band >= 6 && hSpar_md_cfg->nchan_transport <= 2 && ( dtx_vad == 1 ) ) || ( useLowerRes && start_band >= 3 && hSpar_md_cfg->nchan_transport <= 2 && ( dtx_vad == 1 ) ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( GE_16( start_band, 6 ) && LE_16( hSpar_md_cfg->nchan_transport, 2 ) && ( EQ_16( dtx_vad, 1 ) ) ) || ( useLowerRes && GE_16( start_band, 3 ) && LE_16( hSpar_md_cfg->nchan_transport, 2 ) && ( EQ_16( dtx_vad, 1 ) ) ) )
{
- // float P_norm[3];
Word32 P_norm_fx[3];
- int16_t idx;
+ Word16 idx;
- ndm = hSpar_md_cfg->num_dmx_chans_per_band[start_band - 1];
- // ndm max value of 4
- // P_norm[0] = 0.0f;
+ ndm = hSpar_md_cfg->num_dmx_chans_per_band[sub( start_band, 1 )];
+ move16();
P_norm_fx[0] = 0;
- for ( i = 0; i < max( 0, foa_ch - ndm ); i++ )
+ move32();
+ FOR( i = 0; i < max( 0, sub( foa_ch, ndm ) ); i++ )
{
- // use 64bit if low precission
- // P_norm[0] += hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i];
- P_norm_fx[0] = P_norm_fx[0] + Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] );
+ P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[sub( start_band, 1 )].P_re_fx[i], hSpar_md->band_coeffs[sub( start_band, 1 )].P_re_fx[i] ) );
+ move32();
}
- // P_norm[0] *= diff_norm_order1 / min( diff_norm_order1, max( 0, foa_ch - ndm ) );
- // P_norm_fx[0] *= diff_norm_order1 / min( diff_norm_order1, max( 0, foa_ch - ndm ) );
- P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[min( diff_norm_order1_fx, max( 0, foa_ch - ndm ) )] );
+ P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[min( diff_norm_order1_fx, max( 0, sub( foa_ch, ndm ) ) )] );
+ move32();
- // P_norm[1] = 0.0f;
P_norm_fx[1] = 0;
- for ( ; i < max( 0, min( num_ch, hoa2_ch ) - ndm ); i++ )
+ move32();
+ FOR( ; i < max( 0, sub( min( num_ch, hoa2_ch ), ndm ) ); i++ )
{
- // P_norm[1] += hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i];
- P_norm_fx[1] = P_norm_fx[1] + Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] );
+ P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[sub( start_band, 1 )].P_re_fx[i], hSpar_md->band_coeffs[sub( start_band, 1 )].P_re_fx[i] ) );
+ move32();
}
- // P_norm[1] *= diff_norm_order2 / min( diff_norm_order2, max( 0, min( num_ch, hoa2_ch ) - ndm ) );
- // P_norm_fx[1] *= diff_norm_order2 / min( diff_norm_order2, max( 0, min( num_ch, hoa2_ch ) - ndm ) );
- P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[min( diff_norm_order2_fx, max( 0, min( num_ch, hoa2_ch ) - ndm ) )] );
-
+ P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[min( diff_norm_order2_fx, max( 0, sub( min( num_ch, hoa2_ch ), ndm ) ) )] );
+ move32();
- // P_norm[2] = 0.0f;
P_norm_fx[2] = 0;
- for ( ; i < num_ch - ndm; i++ )
+ move32();
+ FOR( ; i < sub( num_ch, ndm ); i++ )
{
- // P_norm[2] += hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i];
- P_norm_fx[2] = P_norm_fx[2] + Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] );
+ P_norm_fx[2] = L_add( P_norm_fx[2], Mpy_32_32( hSpar_md->band_coeffs[sub( start_band, 1 )].P_re_fx[i], hSpar_md->band_coeffs[sub( start_band, 1 )].P_re_fx[i] ) );
+ move32();
}
- // P_norm[2] *= diff_norm_order3 / min( diff_norm_order3, max( 0, num_ch - ndm ) );
- // P_norm_fx[2] *= diff_norm_order3 / min( diff_norm_order3, max( 0, num_ch - ndm ) );
- P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, num_ch - ndm ) )] );
+ P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, sub( num_ch, ndm ) ) )] );
+ move32();
- for ( i = 0; i < max( 0, foa_ch - ndm ); i++ )
+ FOR( i = 0; i < max( 0, sub( foa_ch, ndm ) ); i++ )
{
- idx = remix_order[i + ndm] - ndm;
- // P_dir_fact[idx] = hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i];
- P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] );
- // P_dir_fact[idx] = P_dir_fact[idx] / max( IVAS_FLT_EPS, P_norm[0] );
- if ( P_dir_fact_fx[idx] == 0 )
+ idx = sub( remix_order[add( i, ndm )], ndm );
+ P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[sub( start_band, 1 )].P_re_fx[i], hSpar_md->band_coeffs[sub( start_band, 1 )].P_re_fx[i] );
+ move32();
+ IF( P_dir_fact_fx[idx] == 0 )
{
P_dir_fact_fx[idx] = 0;
+ move32();
}
- else
+ ELSE
{
P_dir_fact_fx[idx] = divide3232( P_dir_fact_fx[idx], max( P_norm_fx[0], IVAS_FIX_EPS ) );
+ move32();
P_dir_fact_fx[idx] = L_shl( P_dir_fact_fx[idx], 15 );
+ move32();
}
}
- for ( ; i < max( 0, min( num_ch, hoa2_ch ) - ndm ); i++ )
+ FOR( ; i < max( 0, sub( min( num_ch, hoa2_ch ), ndm ) ); i++ )
{
- idx = remix_order[i + ndm] - ndm;
- // P_dir_fact[idx] = hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i];
- P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] );
- // P_dir_fact[idx] = P_dir_fact[idx] / max( IVAS_FLT_EPS, P_norm[1] );
- if ( P_dir_fact_fx[idx] == 0 )
+ idx = sub( remix_order[add( i, ndm )], ndm );
+ P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[sub( start_band, 1 )].P_re_fx[i], hSpar_md->band_coeffs[sub( start_band, 1 )].P_re_fx[i] );
+ IF( P_dir_fact_fx[idx] == 0 )
{
P_dir_fact_fx[idx] = 0;
+ move32();
}
- else
+ ELSE
{
P_dir_fact_fx[idx] = divide3232( P_dir_fact_fx[idx], max( P_norm_fx[1], IVAS_FIX_EPS ) );
+ move32();
P_dir_fact_fx[idx] = L_shl( P_dir_fact_fx[idx], 15 );
+ move32();
}
}
- for ( ; i < num_ch - ndm; i++ )
+ FOR( ; i < sub( num_ch, ndm ); i++ )
{
- idx = remix_order[i + ndm] - ndm;
- // P_dir_fact[idx] = hSpar_md->band_coeffs[start_band - 1].P_re[i] * hSpar_md->band_coeffs[start_band - 1].P_re[i];
- P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] );
- // P_dir_fact[idx] = P_dir_fact[idx] / max( IVAS_FLT_EPS, P_norm[2] );
- if ( P_dir_fact_fx[idx] == 0 )
+ idx = sub( remix_order[add( i, ndm )], ndm );
+ P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[sub( start_band, 1 )].P_re_fx[i], hSpar_md->band_coeffs[sub( start_band, 1 )].P_re_fx[i] );
+ move32();
+ IF( P_dir_fact_fx[idx] == 0 )
{
P_dir_fact_fx[idx] = 0;
+ move32();
}
- else
+ ELSE
{
P_dir_fact_fx[idx] = divide3232( P_dir_fact_fx[idx], max( P_norm_fx[2], IVAS_FIX_EPS ) );
+ move32();
P_dir_fact_fx[idx] = L_shl( P_dir_fact_fx[idx], 15 );
+ move32();
}
}
}
- for ( int16_t i_ts = 0; i_ts < n_ts; i_ts++ )
+ FOR( Word16 i_ts = 0; i_ts < n_ts; i_ts++ )
{
- for ( band = start_band; band < end_band; band++ )
+ FOR( band = start_band; band < end_band; band++ )
{
ndm = hSpar_md_cfg->num_dmx_chans_per_band[band];
+ move16();
/*SPAR from DirAC*/
- // set_f( response_avg, 0.0f, MAX_OUTPUT_CHANNELS );
set32_fx( response_avg_fx, 0, MAX_OUTPUT_CHANNELS );
- if ( n_ts > 1 )
+ IF( GE_16( n_ts, 1 ) )
{
- // ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][i_ts], (int16_t) ele_dirac[band][i_ts], response_avg, order );
- ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][i_ts], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][i_ts], Q22 ), response_avg_fx, order, Q30 );
- /*for ( int l = 0; l < MAX_OUTPUT_CHANNELS; l++ )
- {
- response_avg[l] = (float) response_avg_fx[l] / ( 1 << 30 );
- }*/
+ ivas_dirac_dec_get_response_fx( extract_l( L_shr( azi_dirac_fx[band][i_ts], Q22 ) ), extract_l( L_shr( ele_dirac_fx[band][i_ts], Q22 ) ), response_avg_fx, order, Q30 );
}
- else if ( useLowerRes )
+ ELSE IF( useLowerRes )
{
- // ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][0], (int16_t) ele_dirac[band][0], response_avg, order );
- ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][0], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][0], Q22 ), response_avg_fx, order, Q30 );
- /*for ( int l = 0; l < MAX_OUTPUT_CHANNELS; l++ )
- {
- response_avg[l] = (float) response_avg_fx[l] / ( 1 << 30 );
- }*/
+ ivas_dirac_dec_get_response_fx( extract_l( L_shr( azi_dirac_fx[band][0], Q22 ) ), extract_l( L_shr( ele_dirac_fx[band][0], Q22 ) ), response_avg_fx, order, Q30 );
}
- else
+ ELSE
{
- for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ )
+ FOR( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ )
{
- // ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][block], (int16_t) ele_dirac[band][block], &( response[block][0] ), order );
- ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][block], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][block], Q22 ), &( response_fx[block][0] ), order, Q30 );
- /*for ( int l = 0; l < MAX_OUTPUT_CHANNELS; l++ )
- {
- response[block][l] = (float) response_fx[block][l] / ( 1 << 30 );
- }*/
+ ivas_dirac_dec_get_response_fx( extract_l( L_shr( azi_dirac_fx[band][block], Q22 ) ), extract_l( L_shr( ele_dirac_fx[band][block], Q22 ) ), &( response_fx[block][0] ), order, Q30 );
}
/* average responses in all subframes*/
{
- // float norm;
Word32 norm_fx;
Word16 norm_q;
- int16_t num_ch_order, hoa2_ch_order;
+ Word16 num_ch_order, hoa2_ch_order;
num_ch_order = ivas_sba_get_nchan_fx( order, 0 );
hoa2_ch_order = ivas_sba_get_nchan_fx( SBA_HOA2_ORDER, 0 );
- for ( ch = 0; ch < num_ch_order; ch++ )
+ FOR( ch = 0; ch < num_ch_order; ch++ )
{
Word64 temp = 0;
- for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ )
+ move64();
+ FOR( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ )
{
- // response_avg[ch] += response[block][ch];
- temp = temp + response_fx[block][ch];
+ temp = W_add( temp, W_deposit32_l( response_fx[block][ch] ) );
}
- // response_avg[ch] /= MAX_PARAM_SPATIAL_SUBFRAMES;
response_avg_fx[ch] = W_extract_l( W_shr( temp, 2 ) );
+ move32();
}
/*normalize 1st order*/
- // norm = 0.0f;
norm_fx = 0;
+ move32();
norm_q = 0;
- for ( ch = 1; ch < foa_ch; ch++ )
+ move16();
+ FOR( ch = 1; ch < foa_ch; ch++ )
{
- // norm += response_avg[ch] * response_avg[ch];
- norm_fx = norm_fx + Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] );
+ norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) );
}
- norm_q = 31 - ( 30 + 30 - 31 );
- // norm = max( EPSILON, sqrtf( norm ) );
- if ( norm_fx )
+ norm_q = sub( 31, ( sub( add( 30, 30 ), 31 ) ) );
+ IF( norm_fx )
{
norm_fx = Sqrt32( norm_fx, &norm_q );
}
- else
+ ELSE
{
norm_fx = EPSILON_FX;
+ move32();
}
- if ( norm_q < 0 )
+ IF( norm_q <= 0 )
{
- norm_fx = L_shr( norm_fx, ( -1 * norm_q ) );
+ norm_fx = L_shr( norm_fx, ( negate( norm_q ) ) );
norm_q = 0;
+ move16();
}
- norm_fx = L_shr( norm_fx, 1 - norm_q );
- for ( ch = 1; ch < foa_ch; ch++ )
+ norm_fx = L_shr( norm_fx, sub( 1, norm_q ) );
+ FOR( ch = 1; ch < foa_ch; ch++ )
{
- // response_avg[ch] /= norm;
- if ( norm_fx < EPSILON_FX_THR )
+ IF( LT_32( norm_fx, EPSILON_FX_THR ) )
{
- if ( response_avg_fx[ch] != 0 )
+ IF( response_avg_fx[ch] != 0 )
{
response_avg_fx[ch] = divide3232( response_avg_fx[ch], EPSILON_FX_THR );
+ move32();
}
response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 );
+ move32();
}
- else if ( response_avg_fx[ch] > norm_fx )
+ ELSE IF( GT_32( response_avg_fx[ch], norm_fx ) )
{
response_avg_fx[ch] = ONE_IN_Q30;
+ move32();
}
- else
+ ELSE
{
response_avg_fx[ch] = divide3232( response_avg_fx[ch], norm_fx );
+ move32();
response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 );
+ move32();
}
- // response_avg[ch] = (float) response_avg_fx[ch] / ( 1 << 30 );
}
/*normalize 2nd order*/
- // norm = 0.0f;
norm_fx = 0;
- for ( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ )
+ move32();
+ FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ )
{
- // norm += response_avg[ch] * response_avg[ch];
- norm_fx = norm_fx + Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] );
+ norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) );
}
- norm_q = 31 - ( 29 + 29 - 31 );
- // norm = max( EPSILON, sqrtf( norm ) );
- if ( norm_fx )
+ norm_q = sub( 31, ( sub( add( 29, 29 ), 31 ) ) );
+ IF( norm_fx )
{
norm_fx = Sqrt32( norm_fx, &norm_q );
}
- else
+ ELSE
{
norm_fx = EPSILON_FX;
+ move32();
}
- if ( norm_q < 0 )
+ IF( norm_q < 0 )
{
- norm_fx = L_shr( norm_fx, -1 * norm_q );
+ norm_fx = L_shr( norm_fx, negate( norm_q ) );
norm_q = 0;
+ move16();
}
- norm_fx = L_shr( norm_fx, 1 - norm_q );
- for ( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ )
+ norm_fx = L_shr( norm_fx, sub( 1, norm_q ) );
+ FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ )
{
- if ( norm_fx < EPSILON_FX_THR )
+ IF( LT_32( norm_fx, EPSILON_FX_THR ) )
{
response_avg_fx[ch] = response_avg_fx[ch];
response_avg_fx[ch] = divide3232( response_avg_fx[ch], EPSILON_FX_THR );
response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 );
+ move32();
+ move32();
+ move32();
}
- else if ( response_avg_fx[ch] > norm_fx )
+ ELSE IF( GT_32( response_avg_fx[ch], norm_fx ) )
{
response_avg_fx[ch] = ONE_IN_Q30;
+ move32();
}
- else
+ ELSE
{
response_avg_fx[ch] = divide3232( response_avg_fx[ch], norm_fx );
response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 );
+ move32();
+ move32();
}
- // response_avg[ch] = (float)response_avg_fx[ch] / (1 << 30);
}
/*normalize 3rd order*/
- // norm = 0.0f;
- for ( ch = hoa2_ch_order; ch < num_ch_order; ch++ )
+ FOR( ch = hoa2_ch_order; ch < num_ch_order; ch++ )
{
- // norm += response_avg[ch] * response_avg[ch];
- norm_fx = norm_fx + Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] );
+ norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) );
}
- norm_q = 31 - ( 29 + 29 - 31 );
- // norm = max( EPSILON, sqrtf( norm ) );
- if ( norm_fx )
+ norm_q = sub( 31, ( sub( add( 29, 29 ), 31 ) ) );
+ IF( norm_fx )
{
norm_fx = Sqrt32( norm_fx, &norm_q );
}
- else
+ ELSE
{
norm_fx = EPSILON_FX;
+ move32();
}
- if ( norm_q < 0 )
+ IF( norm_q < 0 )
{
- norm_fx = L_shr( norm_fx, -1 * norm_q );
+ norm_fx = L_shr( norm_fx, negate( norm_q ) );
norm_q = 0;
+ move16();
}
- norm_fx = L_shr( norm_fx, 1 - norm_q );
- for ( ch = hoa2_ch_order; ch < num_ch_order; ch++ )
+ norm_fx = L_shr( norm_fx, sub( 1, norm_q ) );
+ FOR( ch = hoa2_ch_order; ch < num_ch_order; ch++ )
{
- // response_avg[ch] /= norm;
- if ( norm_fx < EPSILON_FX_THR )
+ IF( LT_32( norm_fx, EPSILON_FX_THR ) )
{
response_avg_fx[ch] = response_avg_fx[ch];
response_avg_fx[ch] = divide3232( response_avg_fx[ch], EPSILON_FX_THR );
response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 );
+ move32();
+ move32();
+ move32();
}
- else if ( response_avg_fx[ch] > norm_fx )
+ ELSE IF( GT_32( response_avg_fx[ch], norm_fx ) )
{
response_avg_fx[ch] = ONE_IN_Q30;
+ move32();
}
- else
+ ELSE
{
response_avg_fx[ch] = divide3232( response_avg_fx[ch], norm_fx );
+ move32();
response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 );
+ move32();
}
- // response_avg[ch] = (float) response_avg_fx[ch] / ( 1 << 30 );
}
}
}
- for ( i = FOA_CHANNELS + 1; i < num_ch; i++ )
+ FOR( i = add( FOA_CHANNELS, 1 ); i < num_ch; i++ )
{
- // response_avg[i] = response_avg[HOA_keep_ind[i]];
response_avg_fx[i] = response_avg_fx[HOA_keep_ind[i]];
+ move32();
}
- // en_ratio_fac = ( 1.0f - diffuseness[band] );
- en_ratio_fac_fx = ( ONE_IN_Q31 - L_shl_sat( diffuseness_fx[band], 1 ) ); // assuming q of dissusion 30
- for ( i = 0; i < num_ch; i++ )
+ en_ratio_fac_fx = L_sub( ONE_IN_Q31, L_shl_sat( diffuseness_fx[band], 1 ) ); // assuming q of dissusion 30
+
+ FOR( i = 0; i < num_ch; i++ )
{
- for ( j = 0; j < num_ch; j++ )
+ FOR( j = 0; j < num_ch; j++ )
{
- if ( i == j )
+ IF( EQ_16( i, j ) )
{
- if ( i == 0 )
+ IF( i == 0 )
{
- // cov_real_dirac[i][i][band] = 1.0f;
cov_real_dirac_fx[i][i][band] = ONE_IN_Q30;
+ move32();
}
- else
+ ELSE
{
Word32 en_ratio_fac_sq = 0;
- // cov_real_dirac[i][j][band] = en_ratio_fac * response_avg[i] * response_avg[j];
+ move32();
cov_real_dirac_fx[i][j][band] = Mpy_32_32( L_shl_sat( Mpy_32_32( en_ratio_fac_fx, response_avg_fx[i] ), 1 ), response_avg_fx[j] );
+ move32();
- if ( hSpar_md_cfg->nchan_transport <= 2 )
+ IF( LE_16( hSpar_md_cfg->nchan_transport, 2 ) )
{
-
- // cov_real_dirac[i][j][band] *= en_ratio_fac;
cov_real_dirac_fx[i][j][band] = Mpy_32_32( cov_real_dirac_fx[i][j][band], en_ratio_fac_fx );
- if ( ( i >= ndm ) && ( dtx_vad == 1 ) )
+ move32();
+ test();
+ IF( ( GE_16( i, ndm ) ) && ( EQ_16( dtx_vad, 1 ) ) )
{
en_ratio_fac_sq = Mpy_32_32( en_ratio_fac_fx, en_ratio_fac_fx );
- cov_real_dirac_fx[i][j][band] = cov_real_dirac_fx[i][j][band] + Mpy_32_32( ( ONE_IN_Q31 - en_ratio_fac_sq ), P_dir_fact_fx[i - ndm] );
- // cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) * P_dir_fact[i - ndm];
+ cov_real_dirac_fx[i][j][band] = L_add( cov_real_dirac_fx[i][j][band], Mpy_32_32( L_sub( ONE_IN_Q31, en_ratio_fac_sq ), P_dir_fact_fx[sub( i, ndm )] ) );
+ move32();
}
- else
+ ELSE
{
- if ( i < foa_ch )
+ IF( LT_16( i, foa_ch ) )
{
en_ratio_fac_sq = Mpy_32_32( en_ratio_fac_fx, en_ratio_fac_fx );
- Word32 temp = Mpy_32_32( ( ONE_IN_Q31 - en_ratio_fac_sq ), ONE_BY_THREE_Q31 );
- cov_real_dirac_fx[i][j][band] = cov_real_dirac_fx[i][j][band] + L_shr( temp, 1 );
- // cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) / diff_norm_order1;
+ Word32 temp = Mpy_32_32( L_sub( ONE_IN_Q31, en_ratio_fac_sq ), ONE_BY_THREE_Q31 );
+ cov_real_dirac_fx[i][j][band] = L_add( cov_real_dirac_fx[i][j][band], L_shr( temp, 1 ) );
+ move32();
}
- else if ( i < hoa2_ch )
+ ELSE IF( LT_16( i, hoa2_ch ) )
{
en_ratio_fac_sq = Mpy_32_32( en_ratio_fac_fx, en_ratio_fac_fx );
- Word32 temp = Mpy_32_32( ( ONE_IN_Q31 - en_ratio_fac_sq ), ONE_BY_FIVE_Q31 );
- cov_real_dirac_fx[i][j][band] = cov_real_dirac_fx[i][j][band] + L_shr( temp, 1 );
- // cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) / diff_norm_order2;
+ Word32 temp = Mpy_32_32( L_sub( ONE_IN_Q31, en_ratio_fac_sq ), ONE_BY_FIVE_Q31 );
+ cov_real_dirac_fx[i][j][band] = L_add( cov_real_dirac_fx[i][j][band], L_shr( temp, 1 ) );
+ move32();
}
- else
+ ELSE
{
en_ratio_fac_sq = Mpy_32_32( en_ratio_fac_fx, en_ratio_fac_fx );
- Word32 temp = Mpy_32_32( ( ONE_IN_Q31 - en_ratio_fac_sq ), ONE_BY_SEVEN_Q31 );
- cov_real_dirac_fx[i][j][band] = cov_real_dirac_fx[i][j][band] + L_shr( temp, 1 );
- // cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) / diff_norm_order3;
+ Word32 temp = Mpy_32_32( L_sub( ONE_IN_Q31, en_ratio_fac_sq ), ONE_BY_SEVEN_Q31 );
+ cov_real_dirac_fx[i][j][band] = L_add( cov_real_dirac_fx[i][j][band], L_shr( temp, 1 ) );
+ move32();
}
}
}
- else
+ ELSE
{
- if ( i < foa_ch )
+ IF( LT_16( i, foa_ch ) )
{
- // cov_real_dirac[i][j][band] += ( 1.0f - en_ratio_fac ) / diff_norm_order1;
- cov_real_dirac_fx[i][j][band] = cov_real_dirac_fx[i][j][band] + L_shr( Mpy_32_32( ( ONE_IN_Q31 - en_ratio_fac_fx ), ONE_BY_THREE_Q31 ), 1 );
+ cov_real_dirac_fx[i][j][band] = L_add( cov_real_dirac_fx[i][j][band], L_shr( Mpy_32_32( L_sub( ONE_IN_Q31, en_ratio_fac_fx ), ONE_BY_THREE_Q31 ), 1 ) );
+ move32();
}
- else if ( i < hoa2_ch )
+ ELSE IF( LT_16( i, hoa2_ch ) )
{
- // cov_real_dirac[i][j][band] += ( 1.0f - en_ratio_fac ) / diff_norm_order2;
- cov_real_dirac_fx[i][j][band] = cov_real_dirac_fx[i][j][band] + L_shr( Mpy_32_32( ( ONE_IN_Q31 - en_ratio_fac_fx ), ONE_BY_FIVE_Q31 ), 1 );
+ cov_real_dirac_fx[i][j][band] = L_add( cov_real_dirac_fx[i][j][band], L_shr( Mpy_32_32( L_sub( ONE_IN_Q31, en_ratio_fac_fx ), ONE_BY_FIVE_Q31 ), 1 ) );
+ move32();
}
- else
+ ELSE
{
- // cov_real_dirac[i][j][band] += ( 1.0f - en_ratio_fac ) / diff_norm_order3;
- cov_real_dirac_fx[i][j][band] = cov_real_dirac_fx[i][j][band] + L_shr( Mpy_32_32( ( ONE_IN_Q31 - en_ratio_fac_fx ), ONE_BY_SEVEN_Q31 ), 1 );
+ cov_real_dirac_fx[i][j][band] = L_add( cov_real_dirac_fx[i][j][band], L_shr( Mpy_32_32( L_sub( ONE_IN_Q31, en_ratio_fac_fx ), ONE_BY_SEVEN_Q31 ), 1 ) );
+ move32();
}
}
}
}
- else
+ ELSE
{
- // cov_real_dirac[i][j][band] = en_ratio_fac * response_avg[i] * response_avg[j];
cov_real_dirac_fx[i][j][band] = L_shl_sat( Mpy_32_32( Mpy_32_32( en_ratio_fac_fx, response_avg_fx[i] ), response_avg_fx[j] ), 1 );
+ move32();
}
}
}
}
- for ( i = 0; i < num_ch; i++ )
+ FOR( i = 0; i < num_ch; i++ )
{
- for ( j = 0; j < num_ch; j++ )
+ FOR( j = 0; j < num_ch; j++ )
{
- // pCov_real[i][j] = cov_real_dirac[i][j];
pCov_real_fx[i][j] = cov_real_dirac_fx[i][j];
+ move32();
}
}
- /*static int frame_counter;
- frame_counter++;
- if (frame_counter > 500)
- {
- frame_counter = frame_counter;
- }*/
-
- active_w = ( dyn_active_w_flag == 1 ) || ( hSpar_md_cfg->active_w == 1 );
-
- // #ifdef IVAS_FLOAT_FIXED
+ test();
+ active_w = ( EQ_16( dyn_active_w_flag, 1 ) ) || ( EQ_16( hSpar_md_cfg->active_w, 1 ) );
ivas_compute_spar_params_fx( pCov_real_fx, Q30, dm_fv_re_fx, &q_dm_fv_re_fx, i_ts, ppMixer_mat_fx, &q_ppMixer_mat, start_band, end_band, dtx_vad, num_ch, 1, active_w, active_w_vlbr, hSpar_md_cfg, hSpar_md, Wscale_fx, q_Wscale, 1, dyn_active_w_flag );
- // #else
- // for (int i = 0; i < num_ch; i++)
- // {
- // for (int j = 0; j < num_ch; j++)
- // {
- // for (int k = start_band; k < end_band; k++)
- // {
- // cov_real_dirac[i][j][k] = (float)cov_real_dirac_fx[i][j][k] / (1 << 30);
- // }
- // }
- // }
-
- // ivas_compute_spar_params( pCov_real, dm_fv_re, i_ts, ppMixer_mat, start_band, end_band, dtx_vad, num_ch, 1, active_w, active_w_vlbr, hSpar_md_cfg, hSpar_md, Wscale, 1, dyn_active_w_flag );
- //
- //#endif // IVAS_FLOAT_FIXED
-
- if ( mixer_mat_fx != NULL )
+ IF( mixer_mat_fx != NULL )
{
- for ( band = start_band; band < end_band; band++ )
+ FOR( band = start_band; band < end_band; band++ )
{
ndm = hSpar_md_cfg->num_dmx_chans_per_band[band];
+ move16();
- for ( i = 0; i < ndm; i++ )
+ FOR( i = 0; i < ndm; i++ )
{
- for ( j = 0; j < num_ch; j++ )
+ FOR( j = 0; j < num_ch; j++ )
{
- mixer_mat_fx[i][j][band + i_ts * IVAS_MAX_NUM_BANDS] = ppMixer_mat_fx[i][j][band];
+ mixer_mat_fx[i][j][add( band, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )] = ppMixer_mat_fx[i][j][band];
+ move32();
}
}
- for ( i = ndm; i < num_ch; i++ )
+ FOR( i = ndm; i < num_ch; i++ )
{
- for ( j = 0; j < num_ch; j++ )
+ FOR( j = 0; j < num_ch; j++ )
{
- mixer_mat_fx[i][j][band + i_ts * IVAS_MAX_NUM_BANDS] = 0;
+ mixer_mat_fx[i][j][add( band, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )] = 0;
+ move32();
}
}
- if ( ( ndm == 1 ) && ( Wscale_d != NULL ) )
+ test();
+ IF( ( EQ_16( ndm, 1 ) ) && ( Wscale_d != NULL ) )
{
- for ( j = 0; j < num_ch; j++ )
+ FOR( j = 0; j < num_ch; j++ )
{
- mixer_mat_fx[0][j][band + i_ts * IVAS_MAX_NUM_BANDS] = Mpy_32_32( mixer_mat_fx[0][j][band + i_ts * IVAS_MAX_NUM_BANDS], Wscale_d[band] );
+ mixer_mat_fx[0][j][add( band, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )] = Mpy_32_32( mixer_mat_fx[0][j][add( band, imult1616( i_ts, IVAS_MAX_NUM_BANDS ) )], Wscale_d[band] );
+ move32();
}
}
}
@@ -6081,147 +6309,140 @@ void ivas_dirac_dec_get_response_fx(
const Word16 ambisonics_order,
Word16 Q_out )
{
- // float response[MAX_OUTPUT_CHANNELS];
- int16_t index_azimuth, index_elevation;
- int16_t el, e, az;
- // float cos_1, cos_2, sin_1, cos_az[3];
+ Word16 index_azimuth, index_elevation;
+ Word16 el, e, az;
Word32 cos_1_fx, cos_2_fx, sin_1_fx, cos_az_fx[3];
- // float sin_az[3];
Word32 sin_az_fx[3];
- // float f, c;
Word32 f_fx;
Word32 c_fx_better;
- int16_t l, m;
- int16_t b, b1, b_2, b1_2, a;
+ Word16 l, m;
+ Word16 b, b1, b_2, b1_2, a;
- index_azimuth = ( azimuth + 180 ) % 360;
- index_elevation = elevation + 90;
- e = index_elevation > 90 ? -1 : 1;
- el = index_elevation > 90 ? 180 - index_elevation : index_elevation;
- az = index_azimuth > 180 ? 360 - index_azimuth : index_azimuth;
- // f = index_azimuth > 180 ? -1.0f : 1.0f;
- f_fx = index_azimuth > 180 ? -1 : 1;
- // cos_1 = dirac_gains_trg_term[az][0];
+ index_azimuth = add( azimuth, 180 ) % 360;
+ move16();
+ index_elevation = add( elevation, 90 );
+ IF( GT_16( index_elevation, 90 ) )
+ {
+ e = -1;
+ move16();
+ }
+ ELSE
+ {
+ e = 1;
+ move16();
+ }
+
+ IF( GT_16( index_elevation, 90 ) )
+ {
+ el = sub( 180, index_elevation );
+ move16();
+ }
+ ELSE
+ {
+ el = index_elevation;
+ move16();
+ }
+
+ IF( GT_16( index_azimuth, 180 ) )
+ {
+ az = sub( 360, index_azimuth );
+ move16();
+ }
+ ELSE
+ {
+ az = index_azimuth;
+ move16();
+ }
+
+ IF( GT_16( index_azimuth, 180 ) )
+ {
+ f_fx = -1;
+ move16();
+ }
+ ELSE
+ {
+ f_fx = 1;
+ move16();
+ }
cos_1_fx = dirac_gains_trg_term_fx[az][0];
- // cos_2 = cos_1 * cos_1;
+ move32();
cos_2_fx = Mpy_32_32( cos_1_fx, cos_1_fx );
- // sin_1 = f * dirac_gains_trg_term[az][1];
sin_1_fx = dirac_gains_trg_term_fx[az][1];
- if ( f_fx == -1 )
+ move32();
+
+ if ( EQ_32( f_fx, -1 ) )
{
sin_1_fx = L_negate( sin_1_fx );
+ move32();
}
- // cos_az[0] = cos_1;
cos_az_fx[0] = cos_1_fx;
- // cos_az[1] = 2.0f * cos_2 - 1.0f;
- cos_az_fx[1] = L_shl_sat( ( cos_2_fx - ONE_IN_Q30 ), 1 );
- // cos_az[2] = 2.0f * cos_1 * cos_az[1] - cos_az[0];
- cos_az_fx[2] = L_shl_sat( ( Mpy_32_32( cos_1_fx, cos_az_fx[1] ) - L_shr( cos_az_fx[0], 1 ) ), 1 );
- // sin_az[0] = sin_1;
+ move32();
+ cos_az_fx[1] = L_shl_sat( L_sub( cos_2_fx, ONE_IN_Q30 ), 1 );
+ move32();
+ cos_az_fx[2] = L_shl_sat( L_sub( Mpy_32_32( cos_1_fx, cos_az_fx[1] ), L_shr( cos_az_fx[0], 1 ) ), 1 );
+ move32();
sin_az_fx[0] = sin_1_fx;
- // sin_az[1] = sin_1 * 2.0f * cos_1;
+ move32();
sin_az_fx[1] = L_shl_sat( Mpy_32_32( sin_1_fx, cos_1_fx ), 1 );
- // sin_az[2] = sin_1 * ( 4.0f * cos_2 - 1.0f );
- sin_az_fx[2] = L_shl_sat( Mpy_32_32( sin_1_fx, ( cos_2_fx - ONE_IN_Q29 ) ), 2 );
+ move32();
+ sin_az_fx[2] = L_shl_sat( Mpy_32_32( sin_1_fx, L_sub( cos_2_fx, ONE_IN_Q29 ) ), 2 );
+ move32();
- // response[0] = 1.0f;
response_fx[0] = L_shl_sat( 1, Q_out );
- /* Un-optimized code - for reference */
- /* for( l = 1; l<= ambisonics_order; l++ ) */
- /* { */
- /* int16_t b, b1, a; */
- /* float c; */
- /* for( m = 0; m < l; m++ ) */
- /* { */
- /* b = l*l+m; */
- /* a = dirac_gains_P_idx[b]; */
- /* c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */
-
- /* if( m%2 == 1 ) */
- /* { */
- /* c = c*e; */
- /* } */
-
- /* response[b] = c * sin_az[l-m-1]; */
-
- /* b1 = l*l+2*l-m; */
- /* response[b1] = c * cos_az[l-m-1]; */
-
- /* } */
-
- /* b = l*l+l; */
- /* a = dirac_gains_P_idx[b]; */
- /* c = dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */
- /* if( l%2 == 1) */
- /* { */
- /* c = c*e; */
- /* } */
-
- /* response[b] = c; */
- /* } */
+ move32();
- for ( l = 1; l <= ambisonics_order; l++ )
+ FOR( l = 1; l <= ambisonics_order; l++ )
{
- b_2 = l * l;
- b1_2 = l * l + 2 * l;
- for ( m = 0; m < l; m += 2 )
+ b_2 = imult1616( l, l );
+ b1_2 = add( imult1616( l, l ), shl( l, 1 ) );
+ FOR( m = 0; m < l; m += 2 )
{
- b = b_2 + m;
+ b = add( b_2, m );
a = dirac_gains_P_idx[b];
- // c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a];
- // c_fx = Mpy_32_32( SQRT2_FIXED, Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] ) );
+ move16();
c_fx_better = local_result_table[el][a];
- // response[b] = c * sin_az[l - m - 1];
- // response_fx[b] = Mpy_32_32( L_shl( c_fx, 3 ), sin_az_fx[l - m - 1] );
- response_fx[b] = L_shl_sat( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), sub( Q_out, 30 ) ); // Q_out
+ move32();
+ response_fx[b] = L_shl_sat( Mpy_32_32( c_fx_better, sin_az_fx[sub( sub( l, m ), 1 )] ), sub( Q_out, 30 ) ); // Q_out
+ move32();
- b1 = b1_2 - m;
- // response[b1] = c * cos_az[l - m - 1];
- // response_fx[b1] = Mpy_32_32( L_shl( c_fx, 3 ), cos_az_fx[l - m - 1] );
- response_fx[b1] = L_shl_sat( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), sub( Q_out, 30 ) ); // Q_out
+ b1 = sub( b1_2, m );
+ response_fx[b1] = L_shl_sat( Mpy_32_32( c_fx_better, cos_az_fx[sub( sub( l, m ), 1 )] ), sub( Q_out, 30 ) ); // Q_out
+ move32();
}
- for ( m = 1; m < l; m += 2 )
+ FOR( m = 1; m < l; m += 2 )
{
- b = b_2 + m;
+ b = add( b_2, m );
a = dirac_gains_P_idx[b];
- // c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a];
- // c_fx = Mpy_32_32( SQRT2_FIXED, Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] ) );
+ move16();
c_fx_better = local_result_table[el][a];
- if ( e == -1 )
+ move32();
+ if ( EQ_16( e, -1 ) )
{
- // c_fx = L_negate( c_fx );
c_fx_better = L_negate( c_fx_better );
}
- // c = c * e;
-
- // response[b] = c * sin_az[l - m - 1];
- // response_fx[b] = Mpy_32_32( L_shl( c_fx, 3 ), sin_az_fx[l - m - 1] );
- response_fx[b] = L_shl_sat( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), sub( Q_out, 30 ) ); // Q_out
- b1 = b1_2 - m;
- // response[b1] = c * cos_az[l - m - 1];
- // response_fx[b1] = Mpy_32_32( L_shl( c_fx, 3 ), cos_az_fx[l - m - 1] );
- response_fx[b1] = L_shl_sat( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), sub( Q_out, 30 ) ); // Q_out
+ response_fx[b] = L_shl_sat( Mpy_32_32( c_fx_better, sin_az_fx[sub( sub( l, m ), 1 )] ), sub( Q_out, 30 ) ); // Q_out
+ move32();
+ b1 = sub( b1_2, m );
+ response_fx[b1] = L_shl_sat( Mpy_32_32( c_fx_better, cos_az_fx[sub( sub( l, m ), 1 )] ), sub( Q_out, 30 ) ); // Q_out
+ move32();
}
- b = b_2 + l;
+ b = add( b_2, l );
a = dirac_gains_P_idx[b];
- // c = dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a];
- // c_fx = Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] );
+ move16();
c_fx_better = local_result_table_2[el][a];
- if ( l % 2 == 1 )
+ move32();
+ IF( EQ_16( ( l % 2 ), 1 ) )
{
- // c = c * e;
- if ( e == -1 )
+ if ( EQ_16( e, -1 ) )
{
- // c_fx = L_negate( c_fx );
c_fx_better = L_negate( c_fx_better );
+ move32();
}
}
-
- // response[b] = c;
- // response_fx[b] = L_shl( c_fx, 2 );
response_fx[b] = L_shl_sat( c_fx_better, sub( Q_out, 30 ) ); // Q_out
+ move32();
}
return;
@@ -6245,7 +6466,7 @@ Word16 ivas_get_bits_to_encode(
WHILE( val )
{
- bits_req++;
+ bits_req = add( bits_req, 1 );
val = L_shr( val, 1 );
}
@@ -6422,15 +6643,6 @@ void ivas_spar_set_bitrate_config(
}
#ifdef IVAS_FLOAT_FIXED
-static Word32 ceil32_fx( Word32 var1, Word16 q )
-{
- Word32 ans, temp;
- ans = L_shr( var1, q );
- temp = L_shl( ans, q );
- IF( GT_32( ans, temp ) )
- return ans;
- ELSE return L_add( ans, 1 );
-}
void ivas_spar_set_bitrate_config_fx(
ivas_spar_md_com_cfg *pSpar_md_cfg, /* i/o: SPAR MD config. handle */
const Word16 table_idx, /* i : config. table index */
@@ -6452,69 +6664,82 @@ void ivas_spar_set_bitrate_config_fx(
Word16 bands_bw;
pSpar_md_cfg->nchan_transport = ivas_spar_br_table_consts[table_idx].nchan_transport;
+ move16();
FOR( i = 0; i < pSpar_md_cfg->nchan_transport; i++ )
{
pSpar_md_cfg->max_freq_per_chan[i] = ivas_spar_br_table_consts[table_idx].fpcs;
+ move16();
}
pSpar_md_cfg->active_w = ivas_spar_br_table_consts[table_idx].active_w;
+ move16();
pSpar_md_cfg->agc_bits_ch_idx = ivas_spar_br_table_consts[table_idx].agc_bits_ch_idx;
-#ifdef IVAS_FLOAT_FIXED
+ move16();
+
ivas_spar_get_uniform_quant_strat_fx( pSpar_md_cfg, table_idx );
-#else
- ivas_spar_get_uniform_quant_strat( pSpar_md_cfg, table_idx );
-#endif
+
pSpar_md_cfg->quant_strat_bits = ivas_get_bits_to_encode( MAX_QUANT_STRATS );
+ move16();
/* BLOCK: getEntropyCoderModels */
pSpar_md_cfg->remix_unmix_order = ivas_spar_br_table_consts[table_idx].dmx_str;
+ move16();
/* bits per block*/
total_bits = 0;
+ move16();
max_bits = 0;
+ move16();
ivas_total_brate = ivas_spar_br_table_consts[table_idx].ivas_total_brate;
+ move32();
sba_order = ivas_spar_br_table_consts[table_idx].sba_order;
+ move16();
ivas_get_spar_table_idx_fx( ivas_total_brate, sba_order, ivas_spar_br_table_consts[table_idx].bwidth, &length, &code );
Word16 temp;
Word16 div1;
FOR( i = 0; i < pSpar_md_cfg->nchan_transport; i++ )
{
- div1 = BASOP_Util_Divide3232_Scale( ivas_spar_br_table_consts[table_idx].core_brs[i][0], FRAMES_PER_SEC, &temp );
- total_bits = add( total_bits, shr( div1, sub( 15, temp ) ) );
- div1 = BASOP_Util_Divide3232_Scale( ivas_spar_br_table_consts[table_idx].core_brs[i][1], FRAMES_PER_SEC, &temp );
- max_bits = add( max_bits, shr( div1, sub( 15, temp ) ) );
+ total_bits = add( total_bits, extract_l( Mpy_32_32( ivas_spar_br_table_consts[table_idx].core_brs[i][0], ONE_BY_FRAMES_PER_SEC_Q31 ) ) );
+ max_bits = add( max_bits, extract_l( Mpy_32_32( ivas_spar_br_table_consts[table_idx].core_brs[i][1], ONE_BY_FRAMES_PER_SEC_Q31 ) ) );
}
-
- div1 = BASOP_Util_Divide3232_Scale( ivas_total_brate, FRAMES_PER_SEC, &temp );
- pSpar_md_cfg->tgt_bits_per_blk = sub( shr( div1, sub( 15, temp ) ), add( add( add( add( add( IVAS_FORMAT_SIGNALING_NBITS_EXTENDED, SBA_PLANAR_BITS ), 0 ), SBA_ORDER_BITS ), length ), total_bits ) );
- pSpar_md_cfg->max_bits_per_blk = sub( shr( div1, sub( 15, temp ) ), add( add( add( add( add( IVAS_FORMAT_SIGNALING_NBITS_EXTENDED, SBA_PLANAR_BITS ), 0 ), SBA_ORDER_BITS ), length ), max_bits ) );
+ /* (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ) */
+ div1 = extract_l( Mpy_32_32( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+ pSpar_md_cfg->tgt_bits_per_blk = sub( div1, add( add( add( add( add( IVAS_FORMAT_SIGNALING_NBITS_EXTENDED, SBA_PLANAR_BITS ), 0 ), SBA_ORDER_BITS ), length ), total_bits ) );
+ pSpar_md_cfg->max_bits_per_blk = sub( div1, add( add( add( add( add( IVAS_FORMAT_SIGNALING_NBITS_EXTENDED, SBA_PLANAR_BITS ), 0 ), SBA_ORDER_BITS ), length ), max_bits ) );
+ move16();
+ move16();
md_coding_bits_header = add( SPAR_NUM_CODING_STRAT_BITS, pSpar_md_cfg->quant_strat_bits );
pSpar_md_cfg->tgt_bits_per_blk = sub( pSpar_md_cfg->tgt_bits_per_blk, md_coding_bits_header );
pSpar_md_cfg->max_bits_per_blk = sub( pSpar_md_cfg->max_bits_per_blk, md_coding_bits_header );
+ move16();
+ move16();
IF( LT_32( ivas_total_brate, IVAS_24k4 ) )
{
bands_bw = 2;
+ move16();
}
ELSE
{
bands_bw = 1;
+ move16();
}
- div1 = BASOP_Util_Divide3232_Scale( i_mult( pSpar_md_cfg->tgt_bits_per_blk, num_bands ), IVAS_MAX_NUM_BANDS, &temp );
- pSpar_md_cfg->tgt_bits_per_blk = (Word16) ceil32_fx( div1, 15 - temp );
-
- div1 = BASOP_Util_Divide3232_Scale( i_mult( pSpar_md_cfg->max_bits_per_blk, num_bands ), IVAS_MAX_NUM_BANDS, &temp );
- pSpar_md_cfg->max_bits_per_blk = (Word16) ceil32_fx( div1, 15 - temp );
+ pSpar_md_cfg->tgt_bits_per_blk = extract_l( Mpy_32_32( i_mult( pSpar_md_cfg->tgt_bits_per_blk, num_bands ), 178956971 /* 1 / IVAS_MAX_NUM_BANDS in Q31 */ ) );
+ pSpar_md_cfg->max_bits_per_blk = extract_l( Mpy_32_32( i_mult( pSpar_md_cfg->max_bits_per_blk, num_bands ), 178956971 /* 1 / IVAS_MAX_NUM_BANDS in Q31 */ ) );
pSpar_md_cfg->tgt_bits_per_blk = add( pSpar_md_cfg->tgt_bits_per_blk, md_coding_bits_header );
pSpar_md_cfg->max_bits_per_blk = add( pSpar_md_cfg->max_bits_per_blk, md_coding_bits_header );
+ move16();
+ move16();
+ move16();
+ move16();
IF( enc_flag )
{
@@ -6522,13 +6747,24 @@ void ivas_spar_set_bitrate_config_fx(
IF( GE_32( ivas_total_brate, BRATE_SPAR_Q_STRAT ) )
{
quant_strat = QUANT_STRAT_0;
+ move16();
}
ELSE
{
quant_strat = QUANT_STRAT_2;
+ move16();
}
- num_PR_bits_dirac_bands = ( EQ_16( dirac2spar_md_flag, 1 ) ) ? sub( num_bands, SPAR_DIRAC_SPLIT_START_BAND ) : 0;
+ IF( EQ_16( dirac2spar_md_flag, 1 ) )
+ {
+ num_PR_bits_dirac_bands = sub( num_bands, SPAR_DIRAC_SPLIT_START_BAND );
+ move16();
+ }
+ ELSE
+ {
+ num_PR_bits_dirac_bands = 0;
+ move16();
+ }
div1 = BASOP_Util_Divide3232_Scale( num_PR_bits_dirac_bands, bands_bw, &temp );
num_PR_bits_dirac_bands = shr( div1, sub( 15, temp ) );
num_PR_bits_dirac_bands = s_max( 0, num_PR_bits_dirac_bands );
@@ -6536,8 +6772,10 @@ void ivas_spar_set_bitrate_config_fx(
n_input = ivas_sba_get_nchan_metadata_fx( sba_order, ivas_total_brate );
n_dmx = ivas_spar_br_table_consts[table_idx].nchan_transport;
+ move16();
n_dec = sub( n_input, n_dmx );
bits_PR = ivas_spar_br_table_consts_fx[table_idx].q_lvls[quant_strat][0];
+ move16();
num_PR_bits_dirac_bands = i_mult( num_PR_bits_dirac_bands, bits_PR );
bits_PR = i_mult( bits_PR, sub( n_input, 1 ) );
bits_C = i_mult( ivas_spar_br_table_consts_fx[table_idx].q_lvls[quant_strat][1], i_mult( sub( n_dmx, 1 ), n_dec ) );
@@ -6560,6 +6798,7 @@ void ivas_spar_set_bitrate_config_fx(
IF( EQ_16( pSpar_md_cfg->nchan_transport, 1 ) )
{
agc_bits = AGC_BITS_PER_CH;
+ move16();
}
ELSE
{
@@ -6569,11 +6808,14 @@ void ivas_spar_set_bitrate_config_fx(
ELSE
{
agc_bits = AGC_SIGNALLING_BITS;
+ move16();
}
+ test();
IF( EQ_32( ivas_total_brate, PCA_BRATE ) && EQ_32( sba_order, SBA_FOA_ORDER ) )
{
pca_bits = 1;
+ move16();
IF( pca_flag )
{
pca_bits = add( pca_bits, sub( add( IVAS_PCA_QBITS, IVAS_PCA_QBITS ), 1 ) );
@@ -6582,9 +6824,11 @@ void ivas_spar_set_bitrate_config_fx(
ELSE
{
pca_bits = 0;
+ move16();
}
pSpar_md_cfg->max_md_bits_spar = add( add( pSpar_md_cfg->max_bits_per_blk, agc_bits ), pca_bits );
+ move16();
}
return;
@@ -6596,6 +6840,7 @@ void ivas_spar_set_bitrate_config_fx(
* Set SPAR bitrate distribution
*-----------------------------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
void ivas_spar_bitrate_dist(
int32_t core_brates_act[], /* o : bitrates per core-coder */
const int16_t nAvailBits, /* i : number of available bits */
@@ -6679,3 +6924,99 @@ void ivas_spar_bitrate_dist(
return;
}
+
+#else
+void ivas_spar_bitrate_dist_fx(
+ Word32 core_brates_act[], /* o : bitrates per core-coder */
+ const Word16 nAvailBits, /* i : number of available bits */
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate */
+ const Word16 sba_order, /* i : Ambisonic (SBA) order */
+ const Word16 bwidth /* i : audio bandwidth */
+)
+{
+ Word16 i, nchan_transport, table_idx, bitlen;
+ Word16 core_bits_act[FOA_CHANNELS], core_range_bits[FOA_CHANNELS];
+ Word16 sum_core_act_bits, residual_bits, overflow_bits;
+
+ table_idx = ivas_get_spar_table_idx( ivas_total_brate, sba_order, bwidth, &bitlen, NULL );
+
+ nchan_transport = ivas_spar_br_table_consts[table_idx].nchan_transport;
+ move16();
+
+ sum_core_act_bits = 0;
+ move16();
+ FOR( i = 0; i < nchan_transport; i++ )
+ {
+ core_bits_act[i] = extract_l( Mpy_32_16_1( ivas_spar_br_table_consts[table_idx].core_brs[i][0], INV_FRAME_PER_SEC_Q15 ) );
+ move16();
+
+ sum_core_act_bits = add( sum_core_act_bits, core_bits_act[i] );
+ }
+
+ residual_bits = sub( nAvailBits, sum_core_act_bits );
+
+ /* First compute core-coder bits as per bitrate distribution table and MD bitrate*/
+ IF( residual_bits > 0 )
+ {
+ FOR( i = 0; i < nchan_transport; i++ )
+ {
+ core_range_bits[i] = extract_l( Mpy_32_16_1( L_sub( ivas_spar_br_table_consts[table_idx].core_brs[i][2], ivas_spar_br_table_consts[table_idx].core_brs[i][0] ), INV_FRAME_PER_SEC_Q15 ) );
+ move16();
+ core_bits_act[i] = add( core_bits_act[i], min( residual_bits, core_range_bits[i] ) );
+ move16();
+ residual_bits = sub( residual_bits, core_range_bits[i] );
+
+ IF( residual_bits <= 0 )
+ {
+ BREAK;
+ }
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < nchan_transport; i++ )
+ {
+ core_range_bits[i] = extract_l( Mpy_32_16_1( L_sub( ivas_spar_br_table_consts[table_idx].core_brs[i][0], ivas_spar_br_table_consts[table_idx].core_brs[i][1] ), INV_FRAME_PER_SEC_Q15 ) );
+ move16();
+ }
+
+ overflow_bits = negate( residual_bits );
+
+ FOR( i = 0; i < nchan_transport; i++ )
+ {
+ core_bits_act[sub( sub( nchan_transport, 1 ), i )] = sub( core_bits_act[sub( sub( nchan_transport, 1 ), i )], min( overflow_bits, core_range_bits[sub( sub( nchan_transport, 1 ), i )] ) );
+ move16();
+ overflow_bits = sub( overflow_bits, core_range_bits[sub( sub( nchan_transport, 1 ), i )] );
+
+ IF( overflow_bits <= 0 )
+ {
+ BREAK;
+ }
+ }
+
+ IF( overflow_bits > 0 )
+ {
+ Word16 overflow_bits_ch;
+ overflow_bits_ch = idiv1616( overflow_bits, nchan_transport );
+
+ FOR( i = 0; i < nchan_transport; i++ )
+ {
+ core_bits_act[i] = sub( core_bits_act[i], overflow_bits_ch );
+ move16();
+ overflow_bits = sub( overflow_bits, overflow_bits_ch );
+ }
+
+ core_bits_act[sub( nchan_transport, 1 )] = sub( core_bits_act[sub( nchan_transport, 1 )], max( 0, overflow_bits ) );
+ move16();
+ }
+ }
+
+ FOR( i = 0; i < nchan_transport; i++ )
+ {
+ core_brates_act[i] = L_mult0( core_bits_act[i], FRAMES_PER_SEC );
+ move32();
+ }
+
+ return;
+}
+#endif
diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util.c
index 859f1ee2440c8cd9210aa848202d35552d53a4e8..78541fd9dcde361cf2c1e00ae763e569a3806aff 100644
--- a/lib_com/ivas_spar_com_quant_util.c
+++ b/lib_com/ivas_spar_com_quant_util.c
@@ -34,13 +34,14 @@
#include "options.h"
#include "math.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include
#include "wmc_auto.h"
-#include "prot_fx1.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*-----------------------------------------------------------------------------------------*
@@ -91,44 +92,50 @@ void ivas_quantise_real_values(
void ivas_quantise_real_values_fx(
const Word32 *values_fx,
- const int16_t q_levels,
+ const Word16 q_levels,
const Word32 min_value_fx,
const Word32 max_value_fx,
- int16_t *index,
+ Word16 *index,
Word32 *quant_fx,
- const int16_t dim )
+ const Word16 dim )
{
- int16_t i;
+ Word16 i;
Word32 q_step_fx, one_by_q_step_fx;
- if ( q_levels == 1 )
+ test();
+ IF( EQ_16( q_levels, 1 ) )
{
- for ( i = 0; i < dim; i++ )
+ FOR( i = 0; i < dim; i++ )
{
quant_fx[i] = 0;
+ move32();
index[i] = 0;
+ move16();
}
}
- else if ( q_levels && max_value_fx != min_value_fx )
+ ELSE IF( q_levels && NE_32( max_value_fx, min_value_fx ) )
{
- Word16 nor_q_level = norm_l( q_levels - 1 );
- Word32 one_by_q_levels = divide3232( L_shl( 1, ( nor_q_level ) ), L_shl( ( q_levels - 1 ), ( nor_q_level ) ) );
+ Word16 nor_q_level = norm_l( sub( q_levels, 1 ) );
+ Word32 one_by_q_levels = divide3232( L_shl( 1, ( nor_q_level ) ), L_shl( sub( q_levels, 1 ), ( nor_q_level ) ) );
one_by_q_levels = L_shl( one_by_q_levels, 16 );
- q_step_fx = Mpy_32_32( ( max_value_fx - min_value_fx ), one_by_q_levels );
- Word32 one_by_max_min = divide3232( ONE_IN_Q28, L_sub( max_value_fx, min_value_fx ) );
- one_by_q_step_fx = ( q_levels - 1 ) * one_by_max_min;
+ q_step_fx = Mpy_32_32( L_sub( max_value_fx, min_value_fx ), one_by_q_levels );
+ Word16 one_by_max_min = divide3232( ONE_IN_Q28, L_sub( max_value_fx, min_value_fx ) );
+ one_by_q_step_fx = L_mult0( sub( q_levels, 1 ), one_by_max_min );
Word32 val_fx;
- for ( i = 0; i < dim; i++ )
+ FOR( i = 0; i < dim; i++ )
{
- val_fx = max( min_value_fx, min( values_fx[i], max_value_fx ) );
- index[i] = (int16_t) L_shr( Mpy_32_32( one_by_q_step_fx, val_fx ), 12 );
- quant_fx[i] = index[i] * q_step_fx;
+ val_fx = L_max( min_value_fx, L_min( values_fx[i], max_value_fx ) );
+ index[i] = extract_l( L_shr( Mpy_32_32( one_by_q_step_fx, val_fx ), 12 ) );
+ move16();
+ quant_fx[i] = imult3216( q_step_fx, index[i] );
+ move16();
}
}
- else
+ ELSE
{
- for ( i = 0; i < dim; i++ )
+ FOR( i = 0; i < dim; i++ )
{
quant_fx[i] = values_fx[i];
+ move32();
}
}
return;
@@ -242,13 +249,13 @@ void ivas_spar_get_uniform_quant_strat_fx(
Pc_q_lvl = ivas_spar_br_table_consts[table_idx].q_lvls[i][3];
move16();
- if ( active_w )
+ IF( active_w )
{
pSpar_md_com_cfg->quant_strat[i].PR.q_levels[0] = PQ_q_lvl;
move16();
pSpar_md_com_cfg->quant_strat[i].PR.q_levels[1] = PQ_q_lvl;
move16();
- pSpar_md_com_cfg->quant_strat[i].PR.min_fx = L_negate( 322122547 ); // -1.2*Q28
+ pSpar_md_com_cfg->quant_strat[i].PR.min_fx = -322122547; // -1.2*Q28
move32();
pSpar_md_com_cfg->quant_strat[i].PR.max_fx = 322122547; // 1.2*Q28
move32();
@@ -257,7 +264,7 @@ void ivas_spar_get_uniform_quant_strat_fx(
move16();
pSpar_md_com_cfg->quant_strat[i].C.q_levels[1] = C_q_lvl;
move16();
- pSpar_md_com_cfg->quant_strat[i].C.min_fx = L_negate( 214748364 ); //-.8*Q28
+ pSpar_md_com_cfg->quant_strat[i].C.min_fx = -214748364; //-.8*Q28
move32();
pSpar_md_com_cfg->quant_strat[i].C.max_fx = 214748364; //.8*Q28
move32();
@@ -275,12 +282,12 @@ void ivas_spar_get_uniform_quant_strat_fx(
move16();
pSpar_md_com_cfg->quant_strat[i].P_c.q_levels[1] = Pc_q_lvl;
move16();
- pSpar_md_com_cfg->quant_strat[i].P_c.min_fx = L_negate( 214748364 ); //-.8*Q28
+ pSpar_md_com_cfg->quant_strat[i].P_c.min_fx = -214748364; //-.8*Q28
move32();
pSpar_md_com_cfg->quant_strat[i].P_c.max_fx = 214748364; //.8*Q28
move32();
}
- else
+ ELSE
{
pSpar_md_com_cfg->quant_strat[i].PR.q_levels[0] = PQ_q_lvl;
move16();
@@ -288,7 +295,7 @@ void ivas_spar_get_uniform_quant_strat_fx(
move16();
pSpar_md_com_cfg->quant_strat[i].PR.max_fx = ONE_IN_Q28; // Q28
move32();
- pSpar_md_com_cfg->quant_strat[i].PR.min_fx = L_negate( ONE_IN_Q28 ); // Q28
+ pSpar_md_com_cfg->quant_strat[i].PR.min_fx = -ONE_IN_Q28; // Q28
move32();
pSpar_md_com_cfg->quant_strat[i].C.q_levels[0] = C_q_lvl;
@@ -297,7 +304,7 @@ void ivas_spar_get_uniform_quant_strat_fx(
move16();
pSpar_md_com_cfg->quant_strat[i].C.max_fx = ONE_IN_Q29; // Q28
move32();
- pSpar_md_com_cfg->quant_strat[i].C.min_fx = L_negate( ONE_IN_Q29 ); // Q28
+ pSpar_md_com_cfg->quant_strat[i].C.min_fx = -ONE_IN_Q29; // Q28
move32();
pSpar_md_com_cfg->quant_strat[i].P_r.q_levels[0] = Pr_q_lvl;
@@ -315,7 +322,7 @@ void ivas_spar_get_uniform_quant_strat_fx(
move16();
pSpar_md_com_cfg->quant_strat[i].P_c.max_fx = ONE_IN_Q27; // Q28
move32();
- pSpar_md_com_cfg->quant_strat[i].P_c.min_fx = L_negate( ONE_IN_Q27 ); // Q28
+ pSpar_md_com_cfg->quant_strat[i].P_c.min_fx = -ONE_IN_Q27; // Q28
move32();
}
}
@@ -334,58 +341,61 @@ void ivas_spar_get_uniform_quant_strat_fx(
void ivas_map_prior_coeffs_quant(
ivas_spar_md_prev_t *pSpar_md_prior,
ivas_spar_md_com_cfg *pSpar_md_cfg,
- const int16_t qsi,
- const int16_t nB )
+ const Word16 qsi,
+ const Word16 nB )
{
- int16_t i, j;
+ Word16 i, j;
- if ( qsi != pSpar_md_cfg->prev_quant_idx )
+ IF( NE_16( qsi, pSpar_md_cfg->prev_quant_idx ) )
{
ivas_quant_strat_t qs = pSpar_md_cfg->quant_strat[qsi];
ivas_quant_strat_t prev_qs = pSpar_md_cfg->quant_strat[pSpar_md_cfg->prev_quant_idx];
- // float one_by_q_lvl_PR = 1.0f / max( prev_qs.PR.q_levels[0] - 1, 1 );
- Word32 one_by_q_lvl_PR_fx = one_by_q_level[max( prev_qs.PR.q_levels[0] - 1, 1 )];
- // float one_by_q_lvl_C = 1.0f / max( prev_qs.C.q_levels[0] - 1, 1 );
- Word32 one_by_q_lvl_C_fx = one_by_q_level[max( prev_qs.C.q_levels[0] - 1, 1 )];
- // float one_by_q_lvl_P_r = 1.0f / max( prev_qs.P_r.q_levels[0] - 1, 1 );
- Word32 one_by_q_lvl_P_r_fx = one_by_q_level[max( prev_qs.P_r.q_levels[0] - 1, 1 )];
- for ( i = 0; i < nB; i++ )
+ Word32 one_by_q_lvl_PR_fx = one_by_q_level[s_max( sub( prev_qs.PR.q_levels[0], 1 ), 1 )];
+ move32();
+ Word32 one_by_q_lvl_C_fx = one_by_q_level[s_max( sub( prev_qs.C.q_levels[0], 1 ), 1 )];
+ move32();
+ Word32 one_by_q_lvl_P_r_fx = one_by_q_level[s_max( sub( prev_qs.P_r.q_levels[0], 1 ), 1 )];
+ move32();
+ FOR( i = 0; i < nB; i++ )
{
- for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
{
- Word32 trial1 = ( qs.PR.q_levels[0] - 1 ) * pSpar_md_prior->band_coeffs_idx[i].pred_index_re[j];
- trial1 = trial1 << 16;
+ Word32 trial1 = L_mult0( sub( qs.PR.q_levels[0], 1 ), pSpar_md_prior->band_coeffs_idx[i].pred_index_re[j] );
+ trial1 = L_shl( trial1, 16 );
trial1 = round_fx( Mpy_32_32( trial1, one_by_q_lvl_PR_fx ) );
- // pSpar_md_prior->band_coeffs_idx_mapped[i].pred_index_re[j] = (int16_t) round( ( qs.PR.q_levels[0] - 1 ) * pSpar_md_prior->band_coeffs_idx[i].pred_index_re[j] * one_by_q_lvl_PR );
pSpar_md_prior->band_coeffs_idx_mapped[i].pred_index_re[j] = extract_l( trial1 );
- Word32 trial2 = ( qs.P_r.q_levels[0] - 1 ) * pSpar_md_prior->band_coeffs_idx[i].decd_index_re[j];
- trial2 = trial2 << 16;
+ move16();
+ Word32 trial2 = L_mult0( sub( qs.P_r.q_levels[0], 1 ), pSpar_md_prior->band_coeffs_idx[i].decd_index_re[j] );
+ trial2 = L_shl( trial2, 16 );
trial2 = round_fx( Mpy_32_32( trial2, one_by_q_lvl_P_r_fx ) );
- // pSpar_md_prior->band_coeffs_idx_mapped[i].decd_index_re[j] = (int16_t) round( ( qs.P_r.q_levels[0] - 1 ) * pSpar_md_prior->band_coeffs_idx[i].decd_index_re[j] * one_by_q_lvl_P_r );
pSpar_md_prior->band_coeffs_idx_mapped[i].decd_index_re[j] = extract_l( trial2 );
+ move16();
}
- for ( j = 0; j < IVAS_SPAR_MAX_C_COEFF; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_C_COEFF; j++ )
{
- Word32 trial1 = ( qs.C.q_levels[0] - 1 ) * pSpar_md_prior->band_coeffs_idx[i].drct_index_re[j];
- trial1 = trial1 << 16;
+ Word32 trial1 = L_mult0( sub( qs.C.q_levels[0], 1 ), pSpar_md_prior->band_coeffs_idx[i].drct_index_re[j] );
+ trial1 = L_shl( trial1, 16 );
trial1 = round_fx( Mpy_32_32( trial1, one_by_q_lvl_C_fx ) );
- // pSpar_md_prior->band_coeffs_idx_mapped[i].drct_index_re[j] = (int16_t) round( ( qs.C.q_levels[0] - 1 ) * pSpar_md_prior->band_coeffs_idx[i].drct_index_re[j] * one_by_q_lvl_C );
pSpar_md_prior->band_coeffs_idx_mapped[i].drct_index_re[j] = extract_l( trial1 );
+ move16();
}
}
}
- else
+ ELSE
{
- for ( i = 0; i < nB; i++ )
+ FOR( i = 0; i < nB; i++ )
{
- for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
{
pSpar_md_prior->band_coeffs_idx_mapped[i].pred_index_re[j] = pSpar_md_prior->band_coeffs_idx[i].pred_index_re[j];
+ move16();
pSpar_md_prior->band_coeffs_idx_mapped[i].decd_index_re[j] = pSpar_md_prior->band_coeffs_idx[i].decd_index_re[j];
+ move16();
}
- for ( j = 0; j < IVAS_SPAR_MAX_C_COEFF; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_C_COEFF; j++ )
{
pSpar_md_prior->band_coeffs_idx_mapped[i].drct_index_re[j] = pSpar_md_prior->band_coeffs_idx[i].drct_index_re[j];
+ move16();
}
}
}
@@ -461,7 +471,9 @@ void ivas_spar_quant_dtx_init_fx(
Word32 *min_max )
{
spar_md->min_max_fx[0] = min_max[0];
+ move32();
spar_md->min_max_fx[1] = min_max[1];
+ move32();
return;
}
@@ -549,7 +561,7 @@ void ivas_clear_band_coeffs_fx(
{
UWord16 i;
- for ( i = 0; i < num_bands; i++ )
+ FOR( i = 0; i < num_bands; i++ )
{
set32_fx( (Word32 *) pband_coeffs[i].C_re_fx, 0, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) );
set32_fx( (Word32 *) pband_coeffs[i].P_re_fx, 0, ( IVAS_SPAR_MAX_CH - 1 ) );
@@ -572,9 +584,8 @@ void ivas_clear_band_coeff_idx(
ivas_band_coeffs_ind_t *pband_coeff_idx,
const UWord16 num_bands )
{
- UWord16 i = 0;
-
- for ( i = 0; i < num_bands; i++ )
+ UWord16 i;
+ FOR( i = 0; i < num_bands; i++ )
{
set16_fx( pband_coeff_idx[i].pred_index_re, 0, ( sub( IVAS_SPAR_MAX_CH, 1 ) ) );
set16_fx( pband_coeff_idx[i].drct_index_re, 0, IVAS_SPAR_MAX_C_COEFF );
diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h
index 34b7942d628ace50d2d52d2ebf1f8008ab97a2f8..0b7519f441694e1336280dc1b428773d2a1ba7e8 100644
--- a/lib_com/ivas_stat_com.h
+++ b/lib_com/ivas_stat_com.h
@@ -93,10 +93,17 @@ typedef struct
int16_t ism_md_fec_cnt_enc; /* counter of continuous frames where MD are not transmitted */
int16_t ism_md_inc_diff_cnt; /* counter of continuous frames where MD are transmitted in inactive segments when MD significantly changes */
float last_true_radius; /* last true Q radius value */
+#ifdef IVAS_FLOAT_FIXED
+ Word16 last_true_radius_fx; /* last true Q radius value */
+#endif
int16_t ism_imp; /* ISM importance flag */
int16_t ism_md_null_flag;
int16_t ism_md_lowrate_flag;
+#ifdef IVAS_FLOAT_FIXED
+ Word32 q_azimuth_old_fx;
+ Word32 q_elevation_old_fx;
+#endif
float q_azimuth_old;
float q_elevation_old;
@@ -367,25 +374,28 @@ typedef struct ivas_agc_com_state_t
/* Covariance structures */
typedef struct ivas_cov_smooth_state_t
{
+#ifdef IVAS_FLOAT_FIXED
+ Word32 *pPrior_cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
+ Word16 *q_cov_real_per_band[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
+#else
float *pPrior_cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
- int16_t prior_bank_idx;
-#ifndef IVAS_FLOAT_FIXED
- float *pSmoothing_factor;
#endif
- int16_t num_bins;
+ int16_t prior_bank_idx;
#ifdef IVAS_FLOAT_FIXED
- Word32 *pPrior_cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
Word32 *pSmoothing_factor_fx; /* Q31 */
+#else
+ float *pSmoothing_factor;
#endif
+ int16_t num_bins;
} ivas_cov_smooth_state_t;
typedef struct ivas_cov_smooth_cfg_t
{
-#ifndef IVAS_FLOAT_FIXED
- float max_update_rate;
-#else
+#ifdef IVAS_FLOAT_FIXED
Word32 max_update_rate_fx; /* Q31 */
+#else
+ float max_update_rate;
#endif
int16_t min_pool_size;
int16_t max_bands;
@@ -596,7 +606,7 @@ typedef struct ivas_masa_qmetadata_frame_struct
#ifndef IVAS_FLOAT_FIXED
float dir_comp_ratio;
#else
- Word16 dir_comp_ratio_fx; /* Q15 */
+ Word16 dir_comp_ratio_fx; /* Q15 */
#endif
uint8_t is_masa_ivas_format;
@@ -728,12 +738,14 @@ typedef struct ivas_filters_process_state_t
Word32 num_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
Word32 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
- Word32 state_fx_q_factor[IVAS_FILTER_MAX_STAGES];
-#endif
+ Word16 num_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
+ Word16 den_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
+ Word16 state_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
+#else
float num[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
float den[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
float state[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
-
+#endif
} ivas_filters_process_state_t;
diff --git a/lib_com/ivas_stereo_dft_com.c b/lib_com/ivas_stereo_dft_com.c
index 595d8f1db0799b243267ea60382473af8e42745b..b315083d87481a970d5fae9b891647c85fb22fee 100644
--- a/lib_com/ivas_stereo_dft_com.c
+++ b/lib_com/ivas_stereo_dft_com.c
@@ -43,6 +43,7 @@
#include "ivas_prot_fx.h"
#endif
+#define INV_FPS 655 // Q15
/*-------------------------------------------------------------------------
* stereo_dft_config()
*
@@ -73,7 +74,7 @@ void stereo_dft_config_fx(
move16();
/* ITD, IPD and residual coding is not used in SID/No data */
- IF( EQ_32( brate, FRAME_NO_DATA ) )
+ IF( brate == FRAME_NO_DATA )
{
*bits_frame_nominal = FRAME_NO_DATA;
move16();
@@ -324,15 +325,16 @@ Word16 stereo_dft_band_config_fx(
Word16 nbands;
/*sanity check*/
- assert( ( EQ_16( band_res, 1 ) || EQ_16( band_res, 0 ) || EQ_16( band_res, 2 ) ) && "stereo DFT: Parameter band resolution not supported!\n" );
+ assert( ( EQ_16( band_res, 1 ) || ( band_res == 0 ) || EQ_16( band_res, 2 ) ) && "stereo DFT: Parameter band resolution not supported!\n" );
band_limits[0] = 1;
move16();
nbands = 0;
move16();
- WHILE( LT_16( band_limits[nbands++], shr( NFFT, 1 ) ) )
+ WHILE( LT_16( band_limits[nbands], shr( NFFT, 1 ) ) )
{
- IF( EQ_16( band_res, 0 ) )
+ nbands = add( nbands, 1 );
+ IF( band_res == 0 )
{
assert( 0 && "stereo DFT: band config failed!\n" );
}
@@ -367,7 +369,7 @@ Word16 stereo_dft_band_config_fx(
assert( ( LT_16( nbands, STEREO_DFT_ERB8_BANDS ) ) && "stereo DFT: band config failed!\n" );
}
}
- nbands = sub( nbands, 1 );
+
band_limits[nbands] = shr( NFFT, 1 ); /*Nyquist Freq*/
move16();
diff --git a/lib_com/ivas_stereo_eclvq_com_fx.c b/lib_com/ivas_stereo_eclvq_com_fx.c
index 1fd3ce5a461e8c189992106a956fc2de5194b03b..c72cc55100ae423916ec2e8dd95634d40fe113fa 100644
--- a/lib_com/ivas_stereo_eclvq_com_fx.c
+++ b/lib_com/ivas_stereo_eclvq_com_fx.c
@@ -54,8 +54,11 @@ void ECSQ_init_instance_fx(
void *ac_handle )
{
ecsq_inst->config_index = config_index;
+ move16();
ecsq_inst->encoding_active = 1;
+ move16();
ecsq_inst->bit_count_estimate = 0;
+ move32();
ecsq_inst->ac_handle = ac_handle;
return;
@@ -73,6 +76,7 @@ Word32 ECSQ_dequantize_gain_fx(
Word32 global_gain;
Word32 L_tmp, L_prod;
Word16 gg_e, tmp_e = 16;
+ move16();
/* pow(10.0, index * ECLVQ_INV_GLOBAL_GAIN_FACTOR) = pow(2.0,(index * ECLVQ_INV_GLOBAL_GAIN_FACTOR)*3.321928 */
L_prod = Mpy_32_16_1( ECLVQ_INV_GLOBAL_GAIN_FACTOR_Q24, shl( index, 8 ) ); /* Q17 */
@@ -103,6 +107,7 @@ void ECSQ_dequantize_vector_fx(
FOR( i = 0; i < N; ++i )
{
output[i] = Mpy_32_16_1( global_gain, input[i] );
+ move32();
}
return;
diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c
index deee92b719df10824542d0b6bcdd313a730875b2..f5f4c423d4ad1522e641dddaa8aa683f3aad3161 100644
--- a/lib_com/ivas_stereo_ica_com_fx.c
+++ b/lib_com/ivas_stereo_ica_com_fx.c
@@ -37,12 +37,14 @@
#include "cnst.h"
#include "ivas_cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "wmc_auto.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*---------------------------------------------------------------
* interpTargetChannel_fx()
@@ -115,6 +117,7 @@ Word32 inv_table_145[N_MAX_SHIFT_CHANGE + 1] = {
Word32 tableD1_145[N_MAX_SHIFT_CHANGE + 1] = { 0, 15027, 120219, 405740, 961755, 1878428, 3245924, 5154407,
7694041, 10954993, 15027425, 20001503, 25967392, 33015256, 41235259, 50717555,
61552334, 73829752, 87639951, 103073111, 120219402 };
+#ifdef IVAS_FLOAT_FIXED
static void interpTargetChannel_fx(
Word32 *target_fx,
const Word16 prevShift,
@@ -130,11 +133,19 @@ static void interpTargetChannel_fx(
Word32 spread_factor2_fx;
Word64 tempD1_fx, tempD2_fx;
- d = sub( prevShift, currShift );
- signShift = GE_16( d, 0 ) ? ( 1 ) : ( -1 );
- move16();
+ d = negate( sub( currShift, prevShift ) );
+ IF( d >= 0 )
+ {
+ signShift = 1;
+ move16();
+ }
+ ELSE
+ {
+ signShift = -1;
+ move16();
+ }
- IF( EQ_16( d, 0 ) )
+ IF( d == 0 )
{
/* this can happen in DFT->TD switching */
return;
@@ -184,21 +195,21 @@ static void interpTargetChannel_fx(
ptr1_fx = target_fx;
ptr2_fx = tempBuff1_fx + ( N_MAX_SHIFT_CHANGE + 1 ) * INTERP_FACTOR1;
- FOR( i = -( N_MAX_SHIFT_CHANGE + 1 ) * INTERP_FACTOR1; i < ( N + N_MAX_SHIFT_CHANGE + 1 ) * INTERP_FACTOR1; i++ )
+ FOR( i = -( N_MAX_SHIFT_CHANGE + 1 ) * INTERP_FACTOR1; i < imult1616( ( add( add( N, N_MAX_SHIFT_CHANGE ), 1 ) ), INTERP_FACTOR1 ); i++ )
{
- IF( i & 0x1 )
+ IF( s_and( i, 0x1 ) )
{
ptr2_fx[i] = 0;
move32();
/* lim1 = ceil((i - SINC_ORDER1)*SPREAD_FACTOR1); */
/* lim2 = floor((i + SINC_ORDER1)*SPREAD_FACTOR1); */
- lim1 = add( shr( ( i - SINC_ORDER1 ), 1 ), 1 );
+ lim1 = add( shr( sub( i, SINC_ORDER1 ), 1 ), 1 );
- lim2 = shr( ( i + SINC_ORDER1 ), 1 );
+ lim2 = shr( add( i, SINC_ORDER1 ), 1 );
FOR( j = lim1; j <= lim2; j++ )
{
- ptr2_fx[i] = L_add( Mpy_32_32( win_fx[j * INTERP_FACTOR1 - i], ptr1_fx[j] ), ptr2_fx[i] );
+ ptr2_fx[i] = L_add( Mpy_32_32( win_fx[sub( imult1616( j, INTERP_FACTOR1 ), i )], ptr1_fx[j] ), ptr2_fx[i] );
move32();
}
}
@@ -213,17 +224,35 @@ static void interpTargetChannel_fx(
ptr1_fx = ptr2_fx;
ptr2_fx = tempBuff2_fx;
- tempD1_fx = table_D1_pointer[L_abs( d )];
- move64();
- tempD2_fx = 3 * table_D1_pointer[L_abs( d )];
- move64();
+ tempD1_fx = W_deposit32_l( table_D1_pointer[L_abs( d )] );
+ tempD2_fx = W_mult0_32_32( 3, table_D1_pointer[L_abs( d )] );
- tempF1_fx = L_sub( d * factor_fx, ( EQ_16( signShift, 1 ) ? ONE_IN_Q12 : -( ONE_IN_Q12 ) ) );
- FOR( k = 0; k < N - 1; k++ )
+ IF( EQ_16( signShift, 1 ) )
{
- Word32 local = ( ( (Word64) tempF1_fx * spread_factor2_fx ) >> 31 ) - ONE_IN_Q12;
- Word32 sign_local = GT_32( local, 0 ) ? 1 : -1;
- Word32 local_int = (Word32) W_shr( W_abs( local ), 12 );
+ tempF1_fx = ONE_IN_Q12;
+ move32();
+ }
+ ELSE
+ {
+ tempF1_fx = -ONE_IN_Q12;
+ move32();
+ }
+ tempF1_fx = L_sub( imult3216( factor_fx, d ), tempF1_fx );
+ FOR( k = 0; k < sub( N, 1 ); k++ )
+ {
+ Word32 local = L_sub( W_extract_l( W_shr( W_mult0_32_32( tempF1_fx, spread_factor2_fx ), 31 ) ), ONE_IN_Q12 );
+ Word32 sign_local;
+ IF( local > 0 )
+ {
+ sign_local = 1;
+ move32();
+ }
+ ELSE
+ {
+ sign_local = -1;
+ move32();
+ }
+ Word32 local_int = W_extract_l( W_shr( W_abs( local ), 12 ) );
Word32 res_a1, res_a2, res_a3;
Word32 res_b1, res_b2, res_b3;
Word32 res_c1, res_c2, res_c3;
@@ -232,24 +261,24 @@ static void interpTargetChannel_fx(
Word64 res_a, res_b, res_c, res_d;
Word64 tempa, tempb;
Word64 mult_a_D1, mult_b_D2;
- local_int = sign_local * local_int;
- local_int_scaled = local_int << 12;
- lim1 = (Word16) local_int;
- IF( local_int_scaled > local )
+ local_int = W_extract_l( W_mult0_32_32( sign_local, local_int ) );
+ local_int_scaled = W_deposit32_l( L_shl( local_int, 12 ) );
+ lim1 = extract_l( local_int );
+ if ( W_sub( local_int_scaled, local ) > 0 )
{
- lim1--;
+ lim1 = sub( lim1, 1 );
}
y_fx[0] = ptr1_fx[lim1];
move32();
- y_fx[1] = ptr1_fx[lim1 + 1];
+ y_fx[1] = ptr1_fx[add( lim1, 1 )];
move32();
- y_fx[2] = ptr1_fx[lim1 + 2];
+ y_fx[2] = ptr1_fx[add( lim1, 2 )];
move32();
- y_fx[3] = ptr1_fx[lim1 + 3];
+ y_fx[3] = ptr1_fx[add( lim1, 3 )];
move32();
- x_fx[0] = lim1 * interp_factor2_fx;
+ x_fx[0] = imult3216( interp_factor2_fx, lim1 );
move32();
x_fx[1] = L_add( x_fx[0], interp_factor2_fx );
move32();
@@ -262,49 +291,60 @@ static void interpTargetChannel_fx(
res_a1 = L_sub( tempF1_fx, x_fx[0] );
res_a2 = L_sub( tempF1_fx, x_fx[1] );
res_a3 = L_sub( tempF1_fx, x_fx[2] );
- res_a = ( ( (Word64) res_a1 * res_a2 ) >> 12 ) * res_a3;
- res_a = ( y_fx[3] * ( res_a >> 16 ) );
+ res_a = W_shr( W_mult0_32_32( res_a1, res_a2 ), 12 ) * res_a3;
+ res_a = ( y_fx[3] * W_shr( res_a, 16 ) );
res_b1 = L_sub( tempF1_fx, x_fx[1] );
res_b2 = L_sub( tempF1_fx, x_fx[2] );
res_b3 = L_sub( tempF1_fx, x_fx[3] );
- res_b = ( ( (Word64) res_b1 * res_b2 ) >> 12 ) * res_b3;
- res_b = ( y_fx[0] * ( res_b >> 16 ) );
+ res_b = W_shr( W_mult0_32_32( res_b1, res_b2 ), 12 ) * res_b3;
+ res_b = ( y_fx[0] * W_shr( res_b, 16 ) );
res_c1 = L_sub( tempF1_fx, x_fx[0] );
res_c2 = L_sub( tempF1_fx, x_fx[2] );
res_c3 = L_sub( tempF1_fx, x_fx[3] );
- res_c = ( ( (Word64) res_c1 * res_c2 ) >> 12 ) * res_c3;
- res_c = ( y_fx[1] * ( res_c >> 16 ) );
+ res_c = W_shr( W_mult0_32_32( res_c1, res_c2 ), 12 ) * res_c3;
+ res_c = ( y_fx[1] * W_shr( res_c, 16 ) );
res_d1 = L_sub( tempF1_fx, x_fx[0] );
res_d2 = L_sub( tempF1_fx, x_fx[1] );
res_d3 = L_sub( tempF1_fx, x_fx[3] );
- res_d = ( ( (Word64) res_d1 * res_d2 ) >> 12 ) * res_d3;
- res_d = ( y_fx[2] * ( res_d >> 16 ) );
+ res_d = W_shr( W_mult0_32_32( res_d1, res_d2 ), 12 ) * res_d3;
+ res_d = ( y_fx[2] * W_shr( res_d, 16 ) );
tempa = W_sub( res_a, res_b );
tempb = W_sub( res_c, res_d );
- mult_a_D1 = ( tempD1_fx * ( tempa >> 14 ) ) >> 15;
- mult_b_D2 = ( tempD2_fx * ( tempb >> 14 ) ) >> 15;
- ptr2_fx[k] = (Word32) ( ( mult_a_D1 + mult_b_D2 ) >> 14 ); // 38-14
- tempF1_fx = (Word32) W_add( tempF1_fx, L_sub( factor_fx, ( EQ_16( signShift, 1 ) ? ONE_IN_Q12 : -( ONE_IN_Q12 ) ) ) );
+ mult_a_D1 = W_shr( ( tempD1_fx * W_shr( tempa, 14 ) ), 15 );
+ mult_b_D2 = W_shr( ( tempD2_fx * W_shr( tempb, 14 ) ), 15 );
+ ptr2_fx[k] = W_extract_l( ( W_shr( W_add( mult_a_D1, mult_b_D2 ), 14 ) ) ); // 38-14
+ move32();
+
+ IF( EQ_16( signShift, 1 ) )
+ {
+ tempF1_fx = W_extract_l( W_add( tempF1_fx, L_sub( factor_fx, ONE_IN_Q12 ) ) );
+ move32();
+ }
+ ELSE
+ {
+ tempF1_fx = W_extract_l( W_add( tempF1_fx, L_sub( factor_fx, -ONE_IN_Q12 ) ) );
+ move32();
+ }
}
ptr1_fx = target_fx;
- Copy32( ptr2_fx, ptr1_fx, N - 1 );
+ Copy32( ptr2_fx, ptr1_fx, sub( N, 1 ) );
return;
}
-
+#endif
/*---------------------------------------------------------------
* Function targetCh_AlignStereoDFT()
*
* Align target channel in DFT stereo to correct FOR shift variations
* ---------------------------------------------------------------*/
-
+#ifdef IVAS_FLOAT_FIXED
static void targetCh_AlignStereoDFT_fx(
Word32 *target_fx,
const Word16 prevShift,
@@ -318,15 +358,14 @@ static void targetCh_AlignStereoDFT_fx(
Word32 fadeOutBuff_fx[L_SHIFT_ADAPT_MAX];
Word32 fadeInBuff_fx[L_SHIFT_ADAPT_MAX];
- d = sub( prevShift, currShift );
+ d = negate( sub( currShift, prevShift ) );
Copy32( target_fx + d, fadeOutBuff_fx, L_shift_adapt );
Copy32( target_fx, fadeInBuff_fx, L_shift_adapt );
- IF( GT_16( L_shift_adapt, 0 ) )
+ IF( L_shift_adapt > 0 )
{
alpha_fx = 0;
- move32();
SWITCH( L_shift_adapt )
{
case 596:
@@ -365,14 +404,14 @@ static void targetCh_AlignStereoDFT_fx(
return;
}
-
+#endif
/*---------------------------------------------------------------
* adjustTargetSignal()
*
* Target signal correction FOR shift variations.
* ---------------------------------------------------------------*/
-
+#ifdef IVAS_FLOAT_FIXED
void adjustTargetSignal_fx(
Word32 *target_fx,
const Word16 prevShift,
@@ -382,7 +421,7 @@ void adjustTargetSignal_fx(
{
/* inter-frame shift variation and target shifting */
- IF( EQ_16( method, 0 ) )
+ IF( method == 0 )
{
interpTargetChannel_fx( target_fx, prevShift, currShift, L_shift_adapt );
}
@@ -393,3 +432,4 @@ void adjustTargetSignal_fx(
return;
}
+#endif
diff --git a/lib_com/ivas_stereo_mdct_bands_com.c b/lib_com/ivas_stereo_mdct_bands_com.c
index 3c06612c415706e90d39bbe5b3486f20ecd1a42b..1cc5694616fcbb5605fc44fde4d5ca7a8ba253cc 100644
--- a/lib_com/ivas_stereo_mdct_bands_com.c
+++ b/lib_com/ivas_stereo_mdct_bands_com.c
@@ -40,8 +40,7 @@
#include "prot.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
@@ -85,13 +84,22 @@ void stereo_mdct_init_bands_fx(
{
tcx_mode = tmp_tcx_mode;
move16();
- L_frameTCX = EQ_16( tcx_mode, TCX_20_CORE ) ? L_frame : ( L_frame / 2 );
- move16();
+
+ IF( EQ_16( tcx_mode, TCX_20_CORE ) )
+ {
+ L_frameTCX = L_frame;
+ move16();
+ }
+ ELSE
+ {
+ L_frameTCX = shr( L_frame, 1 );
+ move16();
+ }
}
ELSE
{
/*transition frame*/
- L_frameTCX = add( L_frame, L_frame / 4 );
+ L_frameTCX = add( L_frame, shr( L_frame, 2 ) );
tcx_mode = TCX_20_CORE;
move16();
}
@@ -101,10 +109,27 @@ void stereo_mdct_init_bands_fx(
{
sfbParam.steBands = mdctStereoBands_32000_640;
- cnt = EQ_16( tcx_mode, TCX_20_CORE ) ? sfbParam.steBands->bdnCnt_TCX20[0] : sfbParam.steBands->bndCnt_TCX10[0];
- move16();
+ IF( EQ_16( tcx_mode, TCX_20_CORE ) )
+ {
+ cnt = sfbParam.steBands->bdnCnt_TCX20[0];
+ move16();
+ }
+ ELSE
+ {
+ cnt = sfbParam.steBands->bndCnt_TCX10[0];
+ move16();
+ }
- sfbWidths = EQ_16( tcx_mode, TCX_20_CORE ) ? sfbParam.steBands->bandLengthsTCX20 : sfbParam.steBands->bandLengthsTCX10;
+ IF( EQ_16( tcx_mode, TCX_20_CORE ) )
+ {
+ sfbWidths = sfbParam.steBands->bandLengthsTCX20;
+ move16();
+ }
+ ELSE
+ {
+ sfbWidths = sfbParam.steBands->bandLengthsTCX10;
+ move16();
+ }
}
ELSE
{
@@ -115,15 +140,40 @@ void stereo_mdct_init_bands_fx(
SWITCH( L_frame )
{
case L_FRAME32k:
- cnt = EQ_16( tcx_mode, TCX_20_CORE ) ? sfbParam.steBands->bdnCnt_TCX20[1] : sfbParam.steBands->bndCnt_TCX10[1];
- move16();
+ IF( EQ_16( tcx_mode, TCX_20_CORE ) )
+ {
+ cnt = sfbParam.steBands->bdnCnt_TCX20[1];
+ move16();
+ }
+ ELSE
+ {
+ cnt = sfbParam.steBands->bndCnt_TCX10[1];
+ move16();
+ }
BREAK;
case L_FRAME25_6k:
- cnt = EQ_16( tcx_mode, TCX_20_CORE ) ? sfbParam.steBands->bdnCnt_TCX20[2] : sfbParam.steBands->bndCnt_TCX10[2];
- move16();
+ IF( EQ_16( tcx_mode, TCX_20_CORE ) )
+ {
+ cnt = sfbParam.steBands->bdnCnt_TCX20[2];
+ move16();
+ }
+ ELSE
+ {
+ cnt = sfbParam.steBands->bndCnt_TCX10[2];
+ move16();
+ }
BREAK;
case L_FRAME16k:
- cnt = EQ_16( tcx_mode, TCX_20_CORE ) ? sfbParam.steBands->bdnCnt_TCX20[3] : sfbParam.steBands->bndCnt_TCX10[3];
+ IF( EQ_16( tcx_mode, TCX_20_CORE ) )
+ {
+ cnt = sfbParam.steBands->bdnCnt_TCX20[3];
+ move16();
+ }
+ ELSE
+ {
+ cnt = sfbParam.steBands->bndCnt_TCX10[3];
+ move16();
+ }
move16();
BREAK;
default:
@@ -131,7 +181,16 @@ void stereo_mdct_init_bands_fx(
return;
}
- sfbWidths = EQ_16( tcx_mode, TCX_20_CORE ) ? sfbParam.steBands->bandLengthsTCX20 : sfbParam.steBands->bandLengthsTCX10;
+ IF( EQ_16( tcx_mode, TCX_20_CORE ) )
+ {
+ sfbWidths = sfbParam.steBands->bandLengthsTCX20;
+ move16();
+ }
+ ELSE
+ {
+ sfbWidths = sfbParam.steBands->bandLengthsTCX10;
+ move16();
+ }
}
ELSE
{
@@ -152,7 +211,16 @@ void stereo_mdct_init_bands_fx(
return;
}
- sfbWidths = EQ_16( tcx_mode, TCX_20_CORE ) ? sfbParam.lpcBndsParam->bandLengthsTCX20 : sfbParam.lpcBndsParam->bandLengthsTCX10;
+ IF( EQ_16( tcx_mode, TCX_20_CORE ) )
+ {
+ sfbWidths = sfbParam.lpcBndsParam->bandLengthsTCX20;
+ move16();
+ }
+ ELSE
+ {
+ sfbWidths = sfbParam.lpcBndsParam->bandLengthsTCX10;
+ move16();
+ }
cnt = 64;
move16();
}
@@ -182,7 +250,17 @@ void stereo_mdct_init_bands_fx(
IF( igf )
{
Word16 sfbOldCnt = *sfbCnt;
- Word16 igfSfbStep = hIgfGrid->infoIsRefined ? 2 : 1;
+ Word16 igfSfbStep;
+ IF( hIgfGrid->infoIsRefined )
+ {
+ igfSfbStep = 2;
+ move16();
+ }
+ ELSE
+ {
+ igfSfbStep = 1;
+ move16();
+ }
Word16 k;
move16();
move16();
@@ -214,7 +292,7 @@ void stereo_mdct_init_bands_fx(
move16();
/* better save than sorry, overwrite anything that is left above */
- FOR( i = *sfbCnt + 1; i < sfbOldCnt + 1; i++ )
+ FOR( i = add( *sfbCnt, 1 ); i < add( sfbOldCnt, 1 ); i++ )
{
sfbOffset[i] = 0;
move16();
@@ -225,9 +303,9 @@ void stereo_mdct_init_bands_fx(
IF( LT_16( sfbOffset[*sfbCnt], L_frameTCX ) )
{
Word16 nMissingBins = sub( L_frameTCX, sfbOffset[*sfbCnt] );
- if ( LT_16( sfbWidths[i] / 2, nMissingBins ) )
+ if ( LT_16( shr( sfbWidths[i], 1 ), nMissingBins ) )
{
- ( *sfbCnt )++;
+ *sfbCnt = add( *sfbCnt, 1 );
}
sfbOffset[*sfbCnt] = L_frameTCX;
move16();
diff --git a/lib_com/ivas_stereo_mdct_stereo_com.c b/lib_com/ivas_stereo_mdct_stereo_com.c
index 28e22b28c46911ae3bf26a510969af724673cac1..f28c69b2242ed7775b9755bac96c22786618f093 100644
--- a/lib_com/ivas_stereo_mdct_stereo_com.c
+++ b/lib_com/ivas_stereo_mdct_stereo_com.c
@@ -37,8 +37,7 @@
#include "wmc_auto.h"
#include
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
@@ -57,10 +56,10 @@ void splitAvailableBits_fx(
Word16 *bits_ch1 /* o : bits for channel 1 */
)
{
- assert( split_ratio >= 1 && split_ratio < SMDCT_BITRATE_RATIO_RANGE );
+ assert( split_ratio >= 1 && LT_16( split_ratio, SMDCT_BITRATE_RATIO_RANGE ) );
/* *bits_ch0 = split_ratio * total_bits / SMDCT_BITRATE_RATIO_RANGE; */
- *bits_ch0 = extract_l( L_mult0( split_ratio, total_bits ) / SMDCT_BITRATE_RATIO_RANGE );
+ *bits_ch0 = extract_l( L_shr( L_mult0( split_ratio, total_bits ), 3 ) );
move16();
/* for SBA mode bias the distribution towards the W channel */
test();
diff --git a/lib_com/ivas_stereo_psychlpc_com.c b/lib_com/ivas_stereo_psychlpc_com.c
index fce1f62abed1c0b1cf0cb288280008536a229267..33b6c20db4642e0d100593d2348d2a7788e9674e 100644
--- a/lib_com/ivas_stereo_psychlpc_com.c
+++ b/lib_com/ivas_stereo_psychlpc_com.c
@@ -84,6 +84,8 @@ ivas_error PsychoacousticParameters_Init(
pPsychParams->nBins = nBins;
pPsychParams->nBands = nBands;
+ move16();
+ move16();
IF( !isWarped )
{
@@ -164,14 +166,22 @@ void SetCurrentPsychParams(
const Word16 last_frame_was_concealed_cng,
TCX_CONFIG_HANDLE hTcxCfg )
{
- IF( EQ_16( hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) && EQ_16( last_frame_was_concealed_cng, 0 ) )
+ test();
+ IF( EQ_16( hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) && ( last_frame_was_concealed_cng == 0 ) )
{
assert( core == TCX_20_CORE );
hTcxCfg->psychParamsCurrent = &hTcxCfg->psychParamsTCX20AfterACELP;
}
ELSE
{
- hTcxCfg->psychParamsCurrent = ( EQ_16( core, TCX_10_CORE ) ) ? &hTcxCfg->psychParamsTCX10 : &hTcxCfg->psychParamsTCX20;
+ IF( EQ_16( core, TCX_10_CORE ) )
+ {
+ hTcxCfg->psychParamsCurrent = &hTcxCfg->psychParamsTCX10;
+ }
+ ELSE
+ {
+ hTcxCfg->psychParamsCurrent = &hTcxCfg->psychParamsTCX20;
+ }
}
return;
diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c
index 2ca004b6ecb45b47d511a706e3664d8e43ffadb6..ed136930da3b397328c569c864f9a25a93e5c627 100644
--- a/lib_com/ivas_stereo_td_bit_alloc.c
+++ b/lib_com/ivas_stereo_td_bit_alloc.c
@@ -41,10 +41,12 @@
#include "prot.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*-------------------------------------------------------------------*
@@ -436,373 +438,477 @@ void tdm_bit_alloc(
#else
void tdm_bit_alloc(
- const Word16 ivas_format, /* i : IVAS format */
- const Word16 ism_mode, /* i : ISM mode in combined format */
- const int32_t element_brate_wo_meta, /* i : element bitrate without metadata */
- const Word16 tdm_lp_reuse_flag, /* i : LPC reusage flag */
- Word32 *total_brate_pri, /* o : Allocated primary channel bitrate */
- Word32 *total_brate_sec, /* o : Allocated secondary channel bitrate */
- Word16 *tdm_low_rate_mode, /* o : secondary channel low rate mode flag*/
- const Word16 coder_type, /* i : secondary channel coder type */
- const Word16 ener_ratio_idx, /* i : correlation ratio indexe */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 bwidth_pri, /* i : bandwidth of the primary channel */
- const Word16 bwidth_sec, /* i : bandwidth of the secondary channel */
- const Word16 flag_ACELP16k_pri, /* i : ACELP@16kHz core flag, primary chan.*/
- const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const Word16 coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */
- const Word16 tdm_inst_ratio_idx_ref /* i : instantaneous correlation ratio idx */
+ const Word16 ivas_format, /* i : IVAS format */
+ const Word16 ism_mode, /* i : ISM mode in combined format */
+ const Word32 element_brate_wo_meta, /* i : element bitrate without metadata */
+ const Word16 tdm_lp_reuse_flag, /* i : LPC reusage flag */
+ Word32 *total_brate_pri, /* o : Allocated primary channel bitrate */
+ Word32 *total_brate_sec, /* o : Allocated secondary channel bitrate */
+ Word16 *tdm_low_rate_mode, /* o : secondary channel low rate mode flag*/
+ const Word16 coder_type, /* i : secondary channel coder type */
+ const Word16 ener_ratio_idx, /* i : correlation ratio indexe */
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
+ const Word16 bwidth_pri, /* i : bandwidth of the primary channel */
+ const Word16 bwidth_sec, /* i : bandwidth of the secondary channel */
+ const Word16 flag_ACELP16k_pri, /* i : ACELP@16kHz core flag, primary chan.*/
+ const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
+ const Word16 coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */
+ const Word16 tdm_inst_ratio_idx_ref /* i : instantaneous correlation ratio idx */
)
{
Word16 idx, four_subfr_fcb, two_subfr_fcb;
Word32 bit_rate_diff_fx;
- Word16 BWE_brate, tmp_bits;
+ Word32 BWE_brate;
+ Word16 tmp_bits;
Word16 tdm_inst_ratio_idx = tdm_inst_ratio_idx_ref;
- IF( tdm_inst_ratio_idx == TDM_NQ )
+ move16();
+ if ( EQ_16( tdm_inst_ratio_idx, TDM_NQ ) )
{
tdm_inst_ratio_idx = LRTD_STEREO_MID_IS_PRIM; /* Bit rate almost split half and half*/
+ move16();
}
/* Decision on using the low rate mode or the normal mode */
/* default is using the low rate mode for the secondary channel coding*/
/* UC and IC are automatically coded with low rate mode */
*tdm_low_rate_mode = 1;
+ move16();
/* Allocating different bitrate to channels */
idx = 0;
- IF( element_brate_wo_meta <= IVAS_13k2 )
+ move16();
+ IF( LE_32( element_brate_wo_meta, IVAS_13k2 ) )
{
idx = 0;
+ move16();
}
- ELSE IF( element_brate_wo_meta <= IVAS_16k4 )
+ ELSE IF( LE_32( element_brate_wo_meta, IVAS_16k4 ) )
{
idx = 1;
+ move16();
}
- ELSE IF( element_brate_wo_meta <= IVAS_24k4 )
+ ELSE IF( LE_32( element_brate_wo_meta, IVAS_24k4 ) )
{
idx = 2;
+ move16();
}
- ELSE IF( element_brate_wo_meta <= IVAS_32k )
+ ELSE IF( LE_32( element_brate_wo_meta, IVAS_32k ) )
{
idx = 3;
+ move16();
}
- ELSE IF( element_brate_wo_meta <= IVAS_48k )
+ ELSE IF( LE_32( element_brate_wo_meta, IVAS_48k ) )
{
idx = 4;
+ move16();
}
- IF( coder_type == UNVOICED && tdm_bit_allc_tbl[idx][coder_type] >= 4200 )
+ test();
+ if ( EQ_16( coder_type, UNVOICED ) && GE_16( tdm_bit_allc_tbl[idx][coder_type], 4200 ) )
{
*tdm_low_rate_mode = 0;
+ move16();
}
/* Secondary channel based bitrate allocation */
*total_brate_sec = tdm_bit_allc_tbl[idx][coder_type];
-
+ move16();
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
/* secondary channel bitrate allocation based on the energy scaling ratio */
- IF( ( ( ivas_format != MASA_ISM_FORMAT || ism_mode == ISM_MODE_NONE ) && ( ( coder_type != UNVOICED ) || tdm_LRTD_flag == 1 ) ) || ( ivas_format == MASA_ISM_FORMAT && ism_mode != ISM_MODE_NONE && coder_type > UNVOICED ) )
+ IF( ( ( NE_16( ivas_format, MASA_ISM_FORMAT ) || ism_mode == ISM_MODE_NONE ) && ( ( NE_16( coder_type, UNVOICED ) ) || EQ_16( tdm_LRTD_flag, 1 ) ) ) || ( EQ_16( ivas_format, MASA_ISM_FORMAT ) && ism_mode != ISM_MODE_NONE && GT_16( coder_type, UNVOICED ) ) )
{
- bit_rate_diff_fx = ( element_brate_wo_meta - 2 * *total_brate_sec );
+ bit_rate_diff_fx = L_sub( element_brate_wo_meta, L_shl( *total_brate_sec, 1 ) );
- IF( tdm_LRTD_flag == 1 ) /* > element_brate > STEREO_22k or CT0 not used */
+ IF( EQ_16( tdm_LRTD_flag, 1 ) ) /* > element_brate > STEREO_22k or CT0 not used */
{
/* further adjustment in function of the energy/correlation ratio */
IF( coder_type == INACTIVE )
{
Word32 res_fix = 0;
- res_fix = Mpy_32_32( 644245095, ( element_brate_wo_meta - 500 ) );
- res_fix = ( ( res_fix / 100 ) * 100 );
+ move32();
+ res_fix = Mpy_32_32( 644245095, L_sub( element_brate_wo_meta, 500 ) );
+ res_fix = imult3216( Mpy_32_32( L_abs( res_fix ), 21474837 ), 100 );
+ if ( res_fix < 0 )
+ {
+ res_fix = L_negate( res_fix );
+ }
*total_brate_sec = max( *total_brate_sec, res_fix );
+ move32();
- //*total_brate_sec = max(*total_brate_sec, (int16_t)(0.3f * (element_brate_wo_meta - 500) / 100) * 100);
- tmp_bits = (Word16) ( -abs( tdm_inst_ratio_idx - 16 ) * 200 * idx );
+ tmp_bits = imult1616( negate( abs_s( sub( tdm_inst_ratio_idx, 16 ) ) ), imult1616( idx, 200 ) );
}
ELSE
{
Word32 res_fix = 0;
- res_fix = Mpy_32_32( 1073741824, ( element_brate_wo_meta - 500 ) );
- res_fix = ( ( res_fix / 100 ) * 100 );
+ move32();
+ res_fix = Mpy_32_32( 1073741824, L_sub( element_brate_wo_meta, 500 ) );
+ res_fix = imult3216( Mpy_32_32( L_abs( res_fix ), 21474837 ), 100 );
+ if ( res_fix < 0 )
+ {
+ res_fix = L_negate( res_fix );
+ }
*total_brate_sec = max( *total_brate_sec, res_fix );
+ move32();
- //*total_brate_sec = max(*total_brate_sec, (int16_t)(0.5f * (element_brate_wo_meta - 500) / 100) * 100);
- /* tmp_bits = -abs(tdm_inst_ratio_idx-16)*200*idx; */
- tmp_bits = (Word16) ( -abs( tdm_inst_ratio_idx - 16 ) * 100 * idx );
+ tmp_bits = imult1616( negate( abs_s( sub( tdm_inst_ratio_idx, 16 ) ) ), imult1616( 100, idx ) );
}
/* tmp_bits should be subtract from the secondary channel bitrate */
/* IF the primary channel doesn't correspond to the channel having the highest correlation to the mono- inverse the bitrate compensation */
- IF( ( ener_ratio_idx >= LRTD_STEREO_MID_IS_PRIM && tdm_inst_ratio_idx < LRTD_STEREO_MID_IS_PRIM ) || ( ener_ratio_idx < LRTD_STEREO_MID_IS_PRIM && tdm_inst_ratio_idx >= LRTD_STEREO_MID_IS_PRIM ) )
+ test();
+ test();
+ test();
+ if ( ( GE_16( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) && LT_16( tdm_inst_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) ) || ( LT_16( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) && GE_16( tdm_inst_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) ) )
{
- tmp_bits *= -1;
+ tmp_bits = negate( tmp_bits );
}
bit_rate_diff_fx = tmp_bits;
+ move16();
}
- ELSE{
- IF( ener_ratio_idx < LRTD_STEREO_MID_IS_PRIM ){
-
- bit_rate_diff_fx = ( LRTD_STEREO_MID_IS_PRIM - ener_ratio_idx ) * bit_rate_diff_fx;
- bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 );
- bit_rate_diff_fx = bit_rate_diff_fx / 10; // basop gives very minor deviation
- }
- ELSE
- {
- bit_rate_diff_fx = ( ener_ratio_idx - LRTD_STEREO_MID_IS_PRIM ) * bit_rate_diff_fx;
- bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 );
- bit_rate_diff_fx = bit_rate_diff_fx / 10; // basop gives very minor deviation
- }
-}
-/*bit_rate_diff2 = ((Word16)(10.f*(-0.5f*ener_ratio_LR+0.5f)*bit_rate_diff)/100)*100;*/
-*total_brate_sec += ( (Word16) ( bit_rate_diff_fx / 100 ) * 100 );
-*total_brate_sec = max( *total_brate_sec, tdm_bit_allc_tbl[idx][coder_type] );
+ ELSE
+ {
+ IF( LT_16( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) )
+ {
-IF( coder_type == INACTIVE && tdm_LRTD_flag == 0 )
-{
- *total_brate_sec = min( *total_brate_sec, MIN_BRATE_SWB_BWE );
-}
+ bit_rate_diff_fx = imult3216( bit_rate_diff_fx, sub( LRTD_STEREO_MID_IS_PRIM, ener_ratio_idx ) );
+ bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 );
+ bit_rate_diff_fx = Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 3277 );
+ if ( bit_rate_diff_fx < 0 )
+ {
+ bit_rate_diff_fx = L_negate( bit_rate_diff_fx );
+ }
+ }
+ ELSE
+ {
+ bit_rate_diff_fx = imult3216( bit_rate_diff_fx, sub( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) );
+ bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 );
+ bit_rate_diff_fx = Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 3277 );
+ if ( bit_rate_diff_fx < 0 )
+ {
+ bit_rate_diff_fx = L_negate( bit_rate_diff_fx );
+ }
+ }
+ }
+ /*bit_rate_diff2 = ((Word16)(10.f*(-0.5f*ener_ratio_LR+0.5f)*bit_rate_diff)/100)*100;*/
+ Word32 temp = imult3216( Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 328 ), 100 );
+ if ( bit_rate_diff_fx < 0 )
+ {
+ temp = L_negate( temp );
+ }
+ *total_brate_sec = L_add( *total_brate_sec, temp );
+ move32();
-IF( ( ener_ratio_idx <= 1 || ener_ratio_idx >= 29 ) && coder_type >= UNVOICED )
-{
- Word16 delta_brate = 0;
+ *total_brate_sec = max( *total_brate_sec, tdm_bit_allc_tbl[idx][coder_type] );
+ move32();
- IF( bwidth_pri > WB )
- {
- delta_brate = 600; /* To slightly compensate for SWB BWE instead of WB BWE */
- IF( element_brate_wo_meta <= IVAS_16k4 )
+ test();
+ IF( ( coder_type == INACTIVE ) && tdm_LRTD_flag == 0 )
{
- delta_brate = 1250; /* To compensate for SWB BWE instead of WB BWE */
+ *total_brate_sec = min( *total_brate_sec, MIN_BRATE_SWB_BWE );
+ move32();
}
- }
- IF( element_brate_wo_meta <= IVAS_13k2 )
- {
- *total_brate_sec = max( *total_brate_sec, 5600 + delta_brate ); /* ~42-47 % of the total bitrate */
- }
- ELSE IF( element_brate_wo_meta <= IVAS_16k4 )
- {
- *total_brate_sec = max( *total_brate_sec, 6500 + delta_brate ); /* ~40-43 % of the total bitrate */
- }
- ELSE IF( element_brate_wo_meta <= IVAS_24k4 )
- {
- *total_brate_sec = max( *total_brate_sec, 9000 + delta_brate ); /* ~37-39 % of the total bitrate */
- }
- ELSE
- {
- *total_brate_sec = max( *total_brate_sec, 9600 + delta_brate ); /* ~30-32% of the total bitrate */
- }
-}
-ELSE
-{
- *total_brate_sec = min( *total_brate_sec, Mpy_32_32( 9663677, element_brate_wo_meta ) * 100 );
-}
+ test();
+ test();
+ IF( ( LE_16( ener_ratio_idx, 1 ) || GE_16( ener_ratio_idx, 29 ) ) && GE_16( coder_type, UNVOICED ) )
+ {
+ Word16 delta_brate = 0;
+ move16();
-*total_brate_sec = min( *total_brate_sec, 18000 );
-}
-ELSE IF( coder_type == UNVOICED )
-{
- IF( tdm_lp_reuse_flag == 0 )
- {
- *total_brate_sec += ( 31 + 5 ) * FRAMES_PER_SEC;
- }
-}
+ IF( GT_16( bwidth_pri, WB ) )
+ {
+ delta_brate = 600; /* To slightly compensate for SWB BWE instead of WB BWE */
+ move16();
+ if ( LE_32( element_brate_wo_meta, IVAS_16k4 ) )
+ {
+ delta_brate = 1250; /* To compensate for SWB BWE instead of WB BWE */
+ move16();
+ }
+ }
-IF( coder_type <= UNVOICED )
-{
- *total_brate_sec = min( *total_brate_sec, MAX_TDM_UC_BRATE );
+ IF( LE_32( element_brate_wo_meta, IVAS_13k2 ) )
+ {
+ *total_brate_sec = max( *total_brate_sec, add( 5600, delta_brate ) ); /* ~42-47 % of the total bitrate */
+ move32();
+ }
+ ELSE IF( LE_32( element_brate_wo_meta, IVAS_16k4 ) )
+ {
+ *total_brate_sec = max( *total_brate_sec, add( 6500, delta_brate ) ); /* ~40-43 % of the total bitrate */
+ move32();
+ }
+ ELSE IF( LE_32( element_brate_wo_meta, IVAS_24k4 ) )
+ {
+ *total_brate_sec = max( *total_brate_sec, add( 9000, delta_brate ) ); /* ~37-39 % of the total bitrate */
+ move32();
+ }
+ ELSE
+ {
+ *total_brate_sec = max( *total_brate_sec, add( 9600, delta_brate ) ); /* ~30-32% of the total bitrate */
+ move32();
+ }
+ }
+ ELSE
+ {
+ *total_brate_sec = min( *total_brate_sec, Mpy_32_32( 9663677, element_brate_wo_meta ) * 100 );
+ move32();
+ }
- IF( *total_brate_sec >= TDM_UC_NORMAL_MODE_MBRATE && tdm_lp_reuse_flag == 0 )
- {
- *tdm_low_rate_mode = 0;
- }
- ELSE IF( *total_brate_sec >= TDM_UC_NORMAL_MODE_MBRATE_LP_R )
- {
- *tdm_low_rate_mode = 0;
+ *total_brate_sec = min( *total_brate_sec, 18000 );
+ move32();
}
- ELSE IF( ( tdm_lp_reuse_flag == 0 && *total_brate_sec < TDM_UC_NORMAL_MODE_MINBR_LP_R && coder_type == UNVOICED ) || ( tdm_lp_reuse_flag == 0 && *total_brate_sec < ( tdm_bit_allc_tbl[idx][0] + MID_LP_BRATE ) ) )
+ ELSE IF( coder_type == UNVOICED )
{
- *total_brate_sec += MID_LP_BRATE;
+ IF( tdm_lp_reuse_flag == 0 )
+ {
+ *total_brate_sec = L_add( *total_brate_sec, imult3216( FRAMES_PER_SEC, 36 ) );
+ move32();
+ }
}
-}
-/* verify that primary channel bitrate is higher than the minimum supported bitrate */
-IF( flag_ACELP16k_pri )
-{
- BWE_brate = SWB_TBE_1k75;
- IF( element_brate_wo_meta < IVAS_24k4 )
+ IF( coder_type <= UNVOICED )
{
- BWE_brate = SWB_TBE_1k10;
+ *total_brate_sec = min( *total_brate_sec, MAX_TDM_UC_BRATE );
+ move32();
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( GE_32( *total_brate_sec, TDM_UC_NORMAL_MODE_MBRATE ) && tdm_lp_reuse_flag == 0 )
+ {
+ *tdm_low_rate_mode = 0;
+ move16();
+ }
+ ELSE IF( GE_32( *total_brate_sec, TDM_UC_NORMAL_MODE_MBRATE_LP_R ) )
+ {
+ *tdm_low_rate_mode = 0;
+ move16();
+ }
+ ELSE IF( ( tdm_lp_reuse_flag == 0 && LT_32( *total_brate_sec, TDM_UC_NORMAL_MODE_MINBR_LP_R ) && EQ_16( coder_type, UNVOICED ) ) || ( tdm_lp_reuse_flag == 0 && LE_32( *total_brate_sec, L_deposit_l( add( tdm_bit_allc_tbl[idx][0], MID_LP_BRATE ) ) ) ) )
+ {
+ *total_brate_sec = L_add( *total_brate_sec, MID_LP_BRATE );
+ move32();
+ }
}
- IF( bwidth_pri > WB && tdm_LRTD_flag == 0 )
- {
- BWE_brate += ( STEREO_BITS_ICBWE + STEREO_ICBWE_MSFLAG_BITS ) * FRAMES_PER_SEC;
- }
- IF( bwidth_pri > SWB && tdm_LRTD_flag == 1 )
+ /* verify that primary channel bitrate is higher than the minimum supported bitrate */
+ IF( flag_ACELP16k_pri )
{
- BWE_brate += 300;
- }
+ BWE_brate = SWB_TBE_1k75;
+ move32();
- IF( bwidth_pri == FB )
- {
- BWE_brate += ( FB_TBE_1k8 - SWB_TBE_1k75 );
- }
+ test();
+ test();
+ if ( LT_32( element_brate_wo_meta, IVAS_24k4 ) )
+ {
+ BWE_brate = SWB_TBE_1k10;
+ move32();
+ }
- IF( element_brate_wo_meta - *total_brate_sec - BWE_brate < 14000 )
- {
- *total_brate_sec = element_brate_wo_meta - 14000 - BWE_brate;
- }
-}
-ELSE
-{
- BWE_brate = SWB_TBE_1k75;
- IF( bwidth_pri == WB )
- {
- BWE_brate = WB_BWE_0k35;
- IF( tdm_LRTD_flag == 0 )
+ test();
+ if ( GT_16( bwidth_pri, WB ) && tdm_LRTD_flag == 0 )
{
- BWE_brate += 250; /* ICA Brate */
+ BWE_brate = L_add( BWE_brate, ( STEREO_BITS_ICBWE + STEREO_ICBWE_MSFLAG_BITS ) * FRAMES_PER_SEC );
+ }
+ test();
+ if ( GT_16( bwidth_pri, SWB ) && EQ_16( tdm_LRTD_flag, 1 ) )
+ {
+ BWE_brate = L_add( BWE_brate, 300 );
}
- }
- ELSE IF( tdm_LRTD_flag == 0 )
- {
- BWE_brate += 350; /* ICA Brate */
- }
-}
-IF( coder_type0 == TRANSITION )
-{
- IF( element_brate_wo_meta > IVAS_13k2 )
- {
- *total_brate_sec = min( *total_brate_sec, element_brate_wo_meta - ( ACELP_8k00 + BWE_brate ) );
+ if ( EQ_16( bwidth_pri, FB ) )
+ {
+ BWE_brate = L_add( BWE_brate, ( FB_TBE_1k8 - SWB_TBE_1k75 ) );
+ }
+
+ IF( LT_32( ( L_sub( ( L_sub( element_brate_wo_meta, *total_brate_sec ) ), BWE_brate ) ), 14000 ) )
+ {
+ *total_brate_sec = L_sub( element_brate_wo_meta, L_add( 14000, BWE_brate ) );
+ move32();
+ }
}
ELSE
{
- *total_brate_sec = min( *total_brate_sec, element_brate_wo_meta - ( ACELP_7k20 + BWE_brate ) );
- }
-}
-ELSE
-{
- *total_brate_sec = min( *total_brate_sec, element_brate_wo_meta - ( 5900 + BWE_brate ) );
-}
-
-IF( coder_type == INACTIVE )
-{
- *total_brate_sec = max( *total_brate_sec, tdm_bit_allc_tbl[0][0] ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */
-}
-ELSE
-{
- *total_brate_sec = max( *total_brate_sec, 3500 ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */
-}
-
-/* Secondary channel bitrate adjusment */
-/* First, adjust the bitrate depending of what is transmitted */
-/* Second, choose the number of subframe for ACELP core depending of the targetted bitratre */
-/* Finally, verify that the concordance between the number of subframe, the parameters sent and the bitrate available */
-IF( coder_type == GENERIC /* || coder_type == AUDIO*/ )
-{
- /* Adjust the bitrate depending of what is transmitted */
- /* IF LPC are transmitted, ensure enough bits are used */
- IF( tdm_lp_reuse_flag == 0 )
- {
- /* Pitch is transmitted as well, further increase the bitrate */
- IF( tdm_Pitch_reuse_flag == 0 )
+ BWE_brate = SWB_TBE_1k75;
+ move32();
+ IF( EQ_16( bwidth_pri, WB ) )
{
- *total_brate_sec = max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SEC_LPC_RATE + MIN_SIGN_RATE );
-
- IF( tdm_LRTD_flag == 1 && bwidth_sec == SWB )
+ BWE_brate = WB_BWE_0k35;
+ move32();
+ if ( tdm_LRTD_flag == 0 )
{
- /* ensure that there are enough bits to code SWB TBE_1k10 as well */
- *total_brate_sec = max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SEC_LPC_RATE + MIN_SIGN_RATE + SWB_TBE_1k10 );
+ BWE_brate = L_add( BWE_brate, 250 ); /* ICA Brate */
}
}
- ELSE /* only LPC is tranmitted -> IF ( *total_brate_sec < MIN_SEC_BRATE+MIN_SEC_LPC_RATE ) */
+ ELSE IF( tdm_LRTD_flag == 0 )
{
- *total_brate_sec = max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_LPC_RATE + MIN_SIGN_RATE );
+ BWE_brate = L_add( BWE_brate, 350 ); /* ICA Brate */
}
}
- ELSE IF( /*tdm_lp_reuse_flag == 1*/ tdm_Pitch_reuse_flag == 0 )
- {
- *total_brate_sec = max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SIGN_RATE );
- }
- /* Choose between 2 and 4 subfr, depending of the bitrate available and prevent the gap between the 2 atlernative */
- IF( tdm_LRTD_flag == 1 )
+ IF( EQ_16( coder_type0, TRANSITION ) )
{
- four_subfr_fcb = (Word16) ( *total_brate_sec - ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 4 * MIN_GAIN_BITS ) * FRAMES_PER_SEC );
- two_subfr_fcb = (Word16) ( *total_brate_sec - ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC );
+ IF( GT_32( element_brate_wo_meta, IVAS_13k2 ) )
+ {
+ *total_brate_sec = min( *total_brate_sec, L_sub( element_brate_wo_meta, L_add( ACELP_8k00, BWE_brate ) ) );
+ move32();
+ }
+ ELSE
+ {
+ *total_brate_sec = min( *total_brate_sec, L_sub( element_brate_wo_meta, L_add( ACELP_7k20, BWE_brate ) ) );
+ move32();
+ }
}
ELSE
{
- four_subfr_fcb = (Word16) ( *total_brate_sec - ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 4 * MIN_GAIN_BITS ) * FRAMES_PER_SEC );
- two_subfr_fcb = (Word16) ( *total_brate_sec - ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC );
+ *total_brate_sec = min( *total_brate_sec, L_sub( element_brate_wo_meta, L_add( 5900, BWE_brate ) ) );
+ move32();
}
- IF( tdm_lp_reuse_flag == 0 )
+ IF( coder_type == INACTIVE )
{
- four_subfr_fcb -= MIN_SEC_LPC_RATE;
- two_subfr_fcb -= MIN_SEC_LPC_RATE;
+ *total_brate_sec = max( *total_brate_sec, tdm_bit_allc_tbl[0][0] ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */
+ move32();
}
-
- IF( tdm_Pitch_reuse_flag == 0 )
+ ELSE
{
- four_subfr_fcb -= ( MIN_SEC_ACB_RATE + 10 * FRAMES_PER_SEC );
- two_subfr_fcb -= MIN_SEC_ACB_RATE;
+ *total_brate_sec = max( *total_brate_sec, 3500 ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */
+ move32();
}
- /* Too much bits for the 2 subfr model but not enough for the the 4 subfr model -> slightly reduce the 2nd channel bitrate */
- IF( two_subfr_fcb > 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC && four_subfr_fcb < MIN_4SUBFR_FCB_RATE * FRAMES_PER_SEC )
+ /* Secondary channel bitrate adjusment */
+ /* First, adjust the bitrate depending of what is transmitted */
+ /* Second, choose the number of subframe for ACELP core depending of the targetted bitratre */
+ /* Finally, verify that the concordance between the number of subframe, the parameters sent and the bitrate available */
+ IF( EQ_16( coder_type, GENERIC ) /* || coder_type == AUDIO*/ )
{
- IF( tdm_LRTD_flag == 1 )
+ /* Adjust the bitrate depending of what is transmitted */
+ /* IF LPC are transmitted, ensure enough bits are used */
+ IF( tdm_lp_reuse_flag == 0 )
+ {
+ /* Pitch is transmitted as well, further increase the bitrate */
+ IF( tdm_Pitch_reuse_flag == 0 )
+ {
+ *total_brate_sec = max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SEC_LPC_RATE + MIN_SIGN_RATE );
+ move32();
+
+ test();
+ IF( EQ_16( tdm_LRTD_flag, 1 ) && EQ_16( bwidth_sec, SWB ) )
+ {
+ /* ensure that there are enough bits to code SWB TBE_1k10 as well */
+ *total_brate_sec = max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SEC_LPC_RATE + MIN_SIGN_RATE + SWB_TBE_1k10 );
+ move32();
+ }
+ }
+ ELSE /* only LPC is tranmitted -> IF ( *total_brate_sec < MIN_SEC_BRATE+MIN_SEC_LPC_RATE ) */
+ {
+ *total_brate_sec = max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_LPC_RATE + MIN_SIGN_RATE );
+ move32();
+ }
+ }
+ ELSE IF( /*tdm_lp_reuse_flag == 1*/ tdm_Pitch_reuse_flag == 0 )
{
- *total_brate_sec = 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC + ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC;
+ *total_brate_sec = max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SIGN_RATE );
+ move32();
+ }
+
+ /* Choose between 2 and 4 subfr, depending of the bitrate available and prevent the gap between the 2 atlernative */
+ IF( EQ_16( tdm_LRTD_flag, 1 ) )
+ {
+ four_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 4 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) );
+ two_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) );
}
ELSE
{
- *total_brate_sec = 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC + ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC;
+ four_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 4 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) );
+ two_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) );
}
IF( tdm_lp_reuse_flag == 0 )
{
- *total_brate_sec += MIN_SEC_LPC_RATE;
+ four_subfr_fcb = sub( four_subfr_fcb, MIN_SEC_LPC_RATE );
+ two_subfr_fcb = sub( two_subfr_fcb, MIN_SEC_LPC_RATE );
}
IF( tdm_Pitch_reuse_flag == 0 )
{
- *total_brate_sec += MIN_SEC_ACB_RATE;
+ four_subfr_fcb = sub( four_subfr_fcb, ( MIN_SEC_ACB_RATE + 10 * FRAMES_PER_SEC ) );
+ two_subfr_fcb = sub( two_subfr_fcb, MIN_SEC_ACB_RATE );
}
- }
- ELSE IF( four_subfr_fcb >= ( 40 ) * FRAMES_PER_SEC ) /* Enough bits to have minimally 2 x 12 + 2*7 bits FCB */
- {
- *tdm_low_rate_mode = 0; /* Use normal rate mode */
- }
- ELSE /* Possible slight increase of secondary channel bit budget to compensate for FCB limited flexibility */
- {
- Word16 tmp_rate, i;
- tmp_rate = two_subfr_fcb;
- idx = NB_RATE_POSS - 2;
- for ( i = 0; i < NB_RATE_POSS; i++ )
+ /* Too much bits for the 2 subfr model but not enough for the the 4 subfr model -> slightly reduce the 2nd channel bitrate */
+ test();
+ IF( GT_16( two_subfr_fcb, 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC ) && LT_16( four_subfr_fcb, MIN_4SUBFR_FCB_RATE * FRAMES_PER_SEC ) )
{
- IF( tmp_rate <= fast_FCB_rates_2sfr[i] )
+ IF( EQ_16( tdm_LRTD_flag, 1 ) )
+ {
+ *total_brate_sec = 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC + ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC;
+ move32();
+ }
+ ELSE
+ {
+ *total_brate_sec = 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC + ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC;
+ move32();
+ }
+
+ IF( tdm_lp_reuse_flag == 0 )
{
- idx = i;
- break;
+ *total_brate_sec = L_add( *total_brate_sec, MIN_SEC_LPC_RATE );
+ move32();
+ }
+
+ IF( tdm_Pitch_reuse_flag == 0 )
+ {
+ *total_brate_sec = L_add( *total_brate_sec, MIN_SEC_ACB_RATE );
+ move32();
}
}
- *total_brate_sec += ( fast_FCB_rates_2sfr[idx] - tmp_rate );
- }
- /* To prevent 13.2 kb/s for primary channel as some bitstream issues arrise with it */
- IF( element_brate_wo_meta - *total_brate_sec == ACELP_13k20 )
- {
- *total_brate_sec += 100;
+ ELSE IF( GE_16( four_subfr_fcb, 40 * FRAMES_PER_SEC ) ) /* Enough bits to have minimally 2 x 12 + 2*7 bits FCB */
+ {
+ *tdm_low_rate_mode = 0; /* Use normal rate mode */
+ move16();
+ }
+ ELSE /* Possible slight increase of secondary channel bit budget to compensate for FCB limited flexibility */
+ {
+ Word16 tmp_rate, i;
+ tmp_rate = two_subfr_fcb;
+ move16();
+ idx = sub( NB_RATE_POSS, 2 );
+
+ FOR( i = 0; i < NB_RATE_POSS; i++ ){
+ IF( LE_16( tmp_rate, fast_FCB_rates_2sfr[i] ) ){
+ idx = i;
+ move16();
+ BREAK;
+ }
}
+ *total_brate_sec = L_add( *total_brate_sec, sub( fast_FCB_rates_2sfr[idx], tmp_rate ) );
+ move32();
+}
+/* To prevent 13.2 kb/s for primary channel as some bitstream issues arrise with it */
+IF( EQ_32( L_sub( element_brate_wo_meta, *total_brate_sec ), ACELP_13k20 ) )
+{
+ *total_brate_sec = L_add( *total_brate_sec, 100 );
+ move32();
+}
}
/* prevent 2.4 kb/s and 2.8 kb/s as they are reserved bitrates for DTX and VBR */
-IF( *total_brate_sec == PPP_NELP_2k80 || *total_brate_sec == SID_2k40 )
+test();
+IF( EQ_32( *total_brate_sec, PPP_NELP_2k80 ) || EQ_32( *total_brate_sec, SID_2k40 ) )
{
- *total_brate_sec -= 100;
+ *total_brate_sec = L_sub( *total_brate_sec, 100 );
+ move32();
}
-*total_brate_pri = element_brate_wo_meta - *total_brate_sec;
+*total_brate_pri = L_sub( element_brate_wo_meta, *total_brate_sec );
+move32();
return;
}
@@ -880,13 +986,13 @@ void td_stereo_param_updt_fx(
{
Word16 i;
/* Copy some primary channel information into the secondary channel structure for later usage */
- IF( tdm_use_IAWB_Ave_lpc == 1 )
+ IF( EQ_16( tdm_use_IAWB_Ave_lpc, 1 ) )
{
/*not being assert*/
Copy( IAWB_Ave_fx, tdm_lsfQ_PCh_fx, M );
lsf2lsp_fx( tdm_lsfQ_PCh_fx, tdm_lspQ_PCh_fx, M, INT_FS_12k8 );
}
- ELSE IF( flag_ACELP16k == 1 )
+ ELSE IF( EQ_16( flag_ACELP16k, 1 ) )
{
Copy( lsp_old_PCh_fx, tdm_lspQ_PCh_fx, M );
lsp_convert_poly_fx( tdm_lspQ_PCh_fx, L_FRAME, 0 );
@@ -902,6 +1008,7 @@ void td_stereo_param_updt_fx(
{
Word16 tmp16;
Word16 mult_factor = 26214 /*0.8f in Q15*/;
+ move16();
FOR( i = 0; i < NB_SUBFR; i++ )
{
tmp16 = mult_r( pitch_buf_PCh_fx[i], mult_factor ); /* Convert 16kHz to 12.8 kHz pitch values */
@@ -964,6 +1071,7 @@ static void tdm_SCh_LSF_intra_pred_zero_bits_fx(
FOR( i = 0; i < M; i++ )
{
pred_lsf_SCh_fx[i] = add( mult_r( beta_fx, tdm_lsfQ_PCh_fx[i] ), mult_r( sub( 32767, beta_fx ), lsf_mean_fx[i] ) );
+ move16();
}
return;
@@ -1019,29 +1127,38 @@ static void tdm_SCh_LSF_intra_pred_tri_diag_mat_fx(
v_sub_16( lsf_SCh_fx, lsf_mean_in_fx, lsf_tmp_fx, M );
lsf_tmp_ptr1_fx = lsf_tmp_fx;
+
lsf_SCh_ptr_fx = lsf_SCh_fx;
+
lsf_tmp_ptr2_fx = lsf_tmp_ptr1_fx;
- *lsf_SCh_ptr_fx = mult_r( *lsf_tmp_ptr1_fx++, *prd_ptr_fx++ ); // Q2.56 + 15 -15
+ *lsf_SCh_ptr_fx = mult_r( *lsf_tmp_ptr1_fx++, *prd_ptr_fx++ ); // Q2.56 + 15 -15
+ move16();
*lsf_SCh_ptr_fx = add( *lsf_SCh_ptr_fx, mult_r( *lsf_tmp_ptr1_fx, *prd_ptr_fx++ ) ); // Q2.56 + 15 -15
+ move16();
lsf_SCh_ptr_fx++;
- FOR( i = 1; i < M - 1; i++ )
+ FOR( i = 1; i < sub( M, 1 ); i++ )
{
lsf_tmp_ptr1_fx = lsf_tmp_ptr2_fx; // Q2.56
*lsf_SCh_ptr_fx = mult_r( *lsf_tmp_ptr1_fx++, *prd_ptr_fx++ ); // Q2.56 + 15 -15
+ move16();
lsf_tmp_ptr2_fx = lsf_tmp_ptr1_fx;
*lsf_SCh_ptr_fx = add( *lsf_SCh_ptr_fx, mult_r( ( *lsf_tmp_ptr1_fx++ ), ( *prd_ptr_fx++ ) ) );
+ move16();
( *lsf_SCh_ptr_fx ) = add( *lsf_SCh_ptr_fx, mult_r( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx++ ) ) );
+ move16();
lsf_SCh_ptr_fx++;
}
lsf_tmp_ptr1_fx = lsf_tmp_ptr2_fx;
*lsf_SCh_ptr_fx = mult_r( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx ) );
+ move16();
lsf_tmp_ptr1_fx++;
prd_ptr_fx++;
*lsf_SCh_ptr_fx = add( mult_r( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx ) ), *lsf_SCh_ptr_fx );
+ move16();
v_add_16( lsf_SCh_fx, lsf_mean_out_fx, lsf_SCh_fx, M );
@@ -1112,25 +1229,30 @@ void tdm_SCh_LSF_intra_pred_fx(
{
Word16 fixed_beta;
- IF( element_brate <= IVAS_13k2 )
+ IF( LE_32( element_brate, IVAS_13k2 ) )
{
fixed_beta = 28508; // 0.87f in Q15
+ move16();
}
- ELSE IF( element_brate <= IVAS_16k4 )
+ ELSE IF( LE_32( element_brate, IVAS_16k4 ) )
{
fixed_beta = 30801; // 0.94f in Q15
+ move16();
}
ELSE IF( element_brate <= IVAS_24k4 )
{
fixed_beta = 29818; // 0.91f in Q15
+ move16();
}
- ELSE IF( element_brate <= IVAS_32k )
+ ELSE IF( LE_32( element_brate, IVAS_32k ) )
{
fixed_beta = 30146; // 0.92f in Q15
+ move16();
}
ELSE
{
fixed_beta = 29818; // 0.91f in Q15
+ move16();
}
tdm_SCh_LSF_intra_pred_zero_bits_fx( tdm_lsfQ_PCh_fx, pred_lsf_SCh_fx, tdm_LSF_MEAN_PRED_QNT_fx, fixed_beta );
@@ -1202,11 +1324,13 @@ static void tdm_SCh_LSF_intra_pred_one_bit_dec_fx(
Word16 beta_fx;
beta_fx = Beta_Q_x_fx[beta_index_fx]; // Q15
+ move16();
/* pulling the LSFs closer to the avergae */
FOR( i = 0; i < M; i++ )
{
pred_lsf_SCh_fx[i] = add( mult_r( beta_fx, tdm_lsfQ_PCh_fx[i] ), mult_r( sub( 32767, beta_fx ), lsf_mean_fx[i] ) );
+ move16();
}
return;
@@ -1262,11 +1386,15 @@ static void tdm_SCh_LSF_intra_pred_one_bit_enc_fx(
Word16 A_temp_fx[M];
Word16 B_temp_fx[M];
Word32 WD_fx[2] = { 0 };
+ move32();
+ move32();
FOR( i = 0; i < M; i++ )
{
A_temp_fx[i] = sub( lsf_SCh_fx[i], lsf_mean_fx[i] );
+ move16();
B_temp_fx[i] = sub( lsf_mean_fx[i], tdm_lsfQ_PCh_fx[i] );
+ move16();
}
FOR( i = 0; i < M; i++ )
@@ -1278,16 +1406,20 @@ static void tdm_SCh_LSF_intra_pred_one_bit_enc_fx(
Word32 Beta_Q_x1 = L_mult( Beta_Q_x_fx[1], Beta_Q_x_fx[1] ); // Q31
WD_fx[0] = L_add( WD_fx[0], L_add( L_add( wgt_A_temp, Mpy_32_16_1( L_shl( wgt_AB_temp, 1 ), Beta_Q_x_fx[0] ) ), Mpy_32_32( wgt_B_temp, Beta_Q_x0 ) ) );
+ move32();
WD_fx[1] = L_add( WD_fx[1], L_add( L_add( wgt_A_temp, Mpy_32_16_1( L_shl( wgt_AB_temp, 1 ), Beta_Q_x_fx[1] ) ), Mpy_32_32( wgt_B_temp, Beta_Q_x1 ) ) );
+ move32();
}
- IF( WD_fx[0] < WD_fx[1] )
+ IF( LT_32( WD_fx[0], WD_fx[1] ) )
{
*beta_index = 0;
+ move16();
}
ELSE
{
*beta_index = 1;
+ move16();
}
tdm_SCh_LSF_intra_pred_one_bit_dec_fx( tdm_lsfQ_PCh_fx, pred_lsf_SCh_fx, tdm_LSF_MEAN_RE_USE_fx, Beta_Q_x_fx, *beta_index );
@@ -1380,7 +1512,7 @@ void tdm_SCh_lsf_reuse_fx(
Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_48k_fx;
}
- IF( EQ_16( enc_dec, ENC ) )
+ IF( enc_dec == ENC )
{
tdm_SCh_LSF_intra_pred_one_bit_enc_fx( lsf_new_fx, tdm_lsfQ_PCh_fx, lsf_new_fx, tdm_LSF_MEAN_RE_USE_fx, lsf_wgts_fx, Beta_Q1bit_re_use_fx, beta_index );
}
diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c
index dfc98c90deb164f1a52d12a6476fd6b8eada42e4..6fecaa54f95e81a4d1087fafba6c6c1c37b87d81 100644
--- a/lib_com/ivas_tools.c
+++ b/lib_com/ivas_tools.c
@@ -35,12 +35,10 @@
#include "options.h"
#include
#include "prot.h"
-#include "prot_fx1.h"
#include "ivas_prot.h"
#include "wmc_auto.h"
#include "ivas_rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
@@ -76,6 +74,26 @@ float sumAbs(
return tmp;
}
+#ifdef IVAS_FLOAT_FIXED
+Word32 sumAbs_fx(
+ const Word32 *vec, /* i : input vector */
+ const Word16 lvec /* i : length of input vector */
+)
+{
+ Word16 i;
+ Word32 tmp;
+
+ tmp = 0;
+ move32();
+ FOR( i = 0; i < lvec; i++ )
+ {
+ tmp = L_add( tmp, L_abs( vec[i] ) );
+ }
+
+ return tmp;
+}
+#endif
+
/*---------------------------------------------------------------------*
* mvc2c()
*
@@ -162,7 +180,9 @@ UWord32 ivas_syn_output_fx(
{
Word16 i, n;
Word16 synth_loc[MAX_JBM_L_FRAME48k];
+ UWord32 tmp;
UWord32 noClipping = 0;
+ move32();
/*-----------------------------------------------------------------*
* float to integer conversion with saturation control
@@ -170,11 +190,13 @@ UWord32 ivas_syn_output_fx(
FOR( n = 0; n < n_channels; n++ )
{
- noClipping += mvl2s_r( synth[n], q_synth, synth_loc, output_frame );
+ tmp = mvl2s_r( synth[n], q_synth, synth_loc, output_frame );
+ noClipping = UL_addNsD( noClipping, tmp );
FOR( i = 0; i < output_frame; i++ )
{
- synth_out[i * n_channels + n] = synth_loc[i];
+ synth_out[L_add( imult1616( i, n_channels ), n )] = synth_loc[i];
+ move16();
}
}
@@ -233,7 +255,8 @@ void ivas_syn_output_f_fx(
{
FOR( i = 0; i < output_frame; i++ )
{
- synth_out[i * n_channels + n] = synth[n][i];
+ synth_out[L_add( imult1616( i, n_channels ), n )] = synth[n][i];
+ move16();
}
}
@@ -269,25 +292,29 @@ void mvr2r_inc_fixed_one(
IF( y_fx < x_fx )
{
ix = 0;
+ move16();
iy = 0;
+ move16();
FOR( i = 0; i < n; i++ )
{
y_fx[iy] = x_fx[ix];
+ move32();
- ix += x_inc;
- iy += y_inc;
+ ix = add( ix, x_inc );
+ iy = add( iy, y_inc );
}
}
ELSE
{
- ix = ( n - 1 ) * x_inc;
- iy = ( n - 1 ) * y_inc;
- FOR( i = n - 1; i >= 0; i-- )
+ ix = imult1616( sub( n, 1 ), x_inc );
+ iy = imult1616( sub( n, 1 ), y_inc );
+ FOR( i = sub( n, 1 ); i >= 0; i-- )
{
y_fx[iy] = x_fx[ix];
+ move32();
- ix -= x_inc;
- iy -= y_inc;
+ ix = sub( ix, x_inc );
+ iy = sub( iy, y_inc );
}
}
@@ -331,7 +358,7 @@ void mvr2r_inc_fixed(
{
ix = i_mult( sub( n, 1 ), x_inc );
iy = i_mult( sub( n, 1 ), y_inc );
- FOR( i = n - 1; i >= 0; i-- )
+ FOR( i = sub( n, 1 ); i >= 0; i-- )
{
y_fx[iy] = x_fx[ix];
move32();
@@ -437,12 +464,16 @@ void v_add_inc_fx(
Word16 ix1 = 0;
Word16 ix2 = 0;
Word16 iy = 0;
+ move16();
+ move16();
+ move16();
FOR( i = 0; i < N; i++ )
{
y[iy] = L_add( x1[ix1], x2[ix2] );
- ix1 += x_inc;
- ix2 += x2_inc;
- iy += y_inc;
+ move32();
+ ix1 = add( ix1, x_inc );
+ ix2 = add( ix2, x2_inc );
+ iy = add( iy, y_inc );
}
return;
}
@@ -473,10 +504,16 @@ void v_mult_inc_fx(
Word16 ix2 = 0;
Word16 iy = 0;
+ move16();
+ move16();
+ move16();
+
FOR( i = 0; i < N; i++ )
{
y_fx[iy] = Mpy_32_32( x1_fx[ix1], x2_fx[ix2] );
+ move32();
y_q_fx[iy] = sub( add( x1_q_fx[ix1], x2_q_fx[ix2] ), 31 );
+ move16();
ix1 = add( ix1, x1_inc );
ix2 = add( ix2, x2_inc );
@@ -502,9 +539,14 @@ void v_mult_inc_fixed(
Word16 ix2 = 0;
Word16 iy = 0;
+ move16();
+ move16();
+ move16();
+
FOR( i = 0; i < N; i++ )
{
y_fx[iy] = Mpy_32_32( x1_fx[ix1], x2_fx[ix2] );
+ move32();
ix1 = add( ix1, x1_inc );
ix2 = add( ix2, x2_inc );
@@ -536,44 +578,6 @@ void v_mult_inc(
int16_t ix2 = 0;
int16_t iy = 0;
-#ifdef IVAS_FLOAT_FIXED
- ///////////////// to be removed ////////////////////////////////
- Word32 x1_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX];
- Word32 x2_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX];
- Word32 y_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX];
- Word16 y_q_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX];
- Word16 x1_q_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX];
- Word16 x2_q_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX];
- FOR( i = 0; i < N; i++ )
- {
- x1_q_fx[ix1] = Q_factor_L( x1[ix1] );
- x1_fx[ix1] = (Word32) ( x1[ix1] * ( W_shl( 1, x1_q_fx[ix1] ) ) );
- x2_q_fx[ix2] = Q_factor_L( x2[ix2] );
- x2_fx[ix2] = (Word32) ( x2[ix2] * ( W_shl( 1, x2_q_fx[ix2] ) ) );
- ix1 = add( ix1, x1_inc );
- ix2 = add( ix2, x2_inc );
- iy = add( iy, y_inc );
- }
- ////////////////////////////////////////////////////////////////////
-
- v_mult_inc_fx( x1_fx, x1_q_fx, x1_inc, x2_fx, x2_q_fx, x2_inc, y_fx, y_q_fx, y_inc, N );
-
- /////////////////////// to be removed ///////////////////////////////
- iy = 0;
- FOR( i = 0; i < N; i++ )
- {
- IF( LT_16( y_q_fx[iy], 0 ) )
- {
- y[iy] = (Float32) y_fx[iy] * ( W_shl( 1, ( -y_q_fx[iy] ) ) );
- }
- ELSE
- {
- y[iy] = (Float32) y_fx[iy] / ( W_shl( 1, y_q_fx[iy] ) );
- }
- iy = add( iy, y_inc );
- }
- ///////////////////////////////////////////////////////////////////////
-#else
for ( i = 0; i < N; i++ )
{
y[iy] = x1[ix1] * x2[ix2];
@@ -581,7 +585,7 @@ void v_mult_inc(
ix2 += x2_inc;
iy += y_inc;
}
-#endif
+
return;
}
@@ -604,6 +608,7 @@ void v_addc_fx(
FOR( i = 0; i < N; i++ )
{
y_fx[i] = L_add( c_fx, x_fx[i] );
+ move32();
}
return;
@@ -627,6 +632,7 @@ void v_addc_fixed(
FOR( i = 0; i < N; i++ )
{
y[i] = L_add( c, x[i] );
+ move32();
}
return;
@@ -642,32 +648,11 @@ void v_addc(
{
int16_t i;
-#ifdef IVAS_FLOAT_FIXED
- Word32 x_fx[CLDFB_NO_CHANNELS_MAX];
- Word32 y_fx[CLDFB_NO_CHANNELS_MAX];
- const Word32 c_fx = (Word32) ( c * L_shl( 1, 29 ) );
-
- //////////////////////////// to be removed //////////////////////
- FOR( i = 0; i < N; i++ )
- {
- x_fx[i] = (Word32) ( x[i] * L_shl( 1, 29 ) );
- }
- /////////////////////////////////////////////////////////////////
-
- v_addc_fx( (const Word32 *) x_fx, c_fx, y_fx, N );
-
- ///////////////////////////// to be removed //////////////////////
- FOR( i = 0; i < N; i++ )
- {
- y[i] = (Float32) y_fx[i] / L_shl( 1, 29 );
- }
- ///////////////////////////////////////////////////////////////////
-#else
for ( i = 0; i < N; i++ )
{
y[i] = c + x[i];
}
-#endif
+
return;
}
@@ -697,12 +682,16 @@ void v_min_fx(
IF( LT_32( L_shr( x1_fx[i], sub( x1_q_fx[i], x2_q_fx[i] ) ), x2_fx[i] ) )
{
y_fx[i] = x1_fx[i];
+ move32();
y_q_fx[i] = x1_q_fx[i];
+ move16();
}
ELSE
{
y_fx[i] = x2_fx[i];
+ move32();
y_q_fx[i] = x2_q_fx[i];
+ move16();
}
}
ELSE
@@ -710,12 +699,16 @@ void v_min_fx(
IF( LT_32( x1_fx[i], L_shr( x2_fx[i], sub( x2_q_fx[i], x1_q_fx[i] ) ) ) )
{
y_fx[i] = x1_fx[i];
+ move32();
y_q_fx[i] = x1_q_fx[i];
+ move16();
}
ELSE
{
y_fx[i] = x2_fx[i];
+ move32();
y_q_fx[i] = x2_q_fx[i];
+ move16();
}
}
}
@@ -738,37 +731,11 @@ void v_min(
{
int16_t i;
-#ifdef IVAS_FLOAT_FIXED
- //////////////////////// to be removed ///////////////////////////////
- Word32 x1_fx[MASA_FREQUENCY_BANDS];
- Word32 x2_fx[MASA_FREQUENCY_BANDS];
- Word32 y_fx[MASA_FREQUENCY_BANDS];
- Word16 x1_q_fx[MASA_FREQUENCY_BANDS];
- Word16 x2_q_fx[MASA_FREQUENCY_BANDS];
- Word16 y_q_fx[MASA_FREQUENCY_BANDS];
- FOR( i = 0; i < N; i++ )
- {
- x1_q_fx[i] = Q_factor_L( x1[i] );
- x1_fx[i] = (Word32) ( x1[i] * ( W_shl( 1, x1_q_fx[i] ) ) );
- x2_q_fx[i] = Q_factor_L( x2[i] );
- x2_fx[i] = (Word32) ( x2[i] * ( W_shl( 1, x2_q_fx[i] ) ) );
- }
- /////////////////////////////////////////////////////////////////////////
-
- v_min_fx( (const Word32 *) x1_fx, x1_q_fx, (const Word32 *) x2_fx, x2_q_fx, y_fx, y_q_fx, N );
-
- //////////////////////// to be removed ////////////////////////////////
- FOR( i = 0; i < N; i++ )
- {
- y[i] = (Float32) y_fx[i] / ( W_shl( 1, y_q_fx[i] ) );
- }
- ///////////////////////////////////////////////////////////////////////
-#else
for ( i = 0; i < N; i++ )
{
y[i] = ( x1[i] < x2[i] ) ? x1[i] : x2[i];
}
-#endif
+
return;
}
@@ -791,6 +758,7 @@ void v_sqrt_fx(
FOR( i = 0; i < N; i++ )
{
y[i] = Sqrt32( x[i], &exp[i] );
+ move32();
}
return;
@@ -833,11 +801,33 @@ void v_sub_s16_fx(
FOR( i = 0; LT_16( i, N ); i++ )
{
y[i] = sub( x1[i], x2[i] );
+ move16();
+ }
+
+ return;
+}
+#endif // IVAS_FLOAT_FIXED
+
+
+#ifdef IVAS_FLOAT_FIXED
+void v_sub32_fx(
+ const Word32 x1[], /* i : Input vector 1 */
+ const Word32 x2[], /* i : Input vector 2 */
+ Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */
+ const Word16 N /* i : Vector length */
+)
+{
+ Word16 i;
+
+ FOR( i = 0; LT_16( i, N ); i++ )
+ {
+ y[i] = L_sub( x1[i], x2[i] );
}
return;
}
#endif // IVAS_FLOAT_FIXED
+
void v_sub_s(
const int16_t x1[], /* i : Input vector 1 */
const int16_t x2[], /* i : Input vector 2 */
@@ -884,7 +874,8 @@ float dot_product_cholesky(
pt_x = x;
for ( j = 0; j <= i; j++ )
{
- tmp_sum += *pt_x++ * *pt_A++;
+ float mul = *pt_x++ * *pt_A++;
+ tmp_sum += mul;
}
suma += tmp_sum * tmp_sum;
@@ -892,6 +883,104 @@ float dot_product_cholesky(
return suma;
}
+#ifdef IVAS_FLOAT_FIXED
+Word32 dot_product_cholesky_fixed(
+ const Word32 *x, /* i : vector x */
+ const Word32 *A, /* i : Cholesky matrix A */
+ const Word16 N, /* i : vector & matrix size */
+ const Word16 exp_x,
+ const Word16 exp_A,
+ Word16 *exp_sum )
+{
+ Word16 i, j;
+ Word32 suma, tmp_sum, mul;
+ const Word32 *pt_x, *pt_A;
+ Word16 mul_exp, tmp_sum_exp;
+ mul_exp = add( exp_x, exp_A );
+ pt_A = A;
+ suma = 0;
+ move32();
+ FOR( i = 0; i < N; i++ )
+ {
+ tmp_sum = 0;
+ move32();
+ tmp_sum_exp = 0;
+ move16();
+ pt_x = x;
+
+ FOR( j = 0; j <= i; j++ )
+ {
+ mul = Mpy_32_32( *pt_x++, *pt_A++ );
+ tmp_sum = BASOP_Util_Add_Mant32Exp( tmp_sum, tmp_sum_exp, mul, mul_exp, &tmp_sum_exp ); // exp_x+exp_A
+ }
+
+ suma = BASOP_Util_Add_Mant32Exp( suma, *exp_sum, Mpy_32_32( tmp_sum, tmp_sum ), shl( tmp_sum_exp, 1 ), exp_sum );
+ }
+
+ return suma;
+}
+#endif
+#ifdef IVAS_FLOAT_FIXED
+void v_mult_mat_fixed(
+ Word32 *y, /* o : the product x*A */
+ const Word32 *x, /* i : vector x */
+ const Word32 *A, /* i : matrix A */
+ const Word16 Nr, /* i : number of rows */
+ const Word16 Nc, /* i : number of columns */
+ Word16 guardbits )
+{
+ Word16 i, j;
+ const Word32 *pt_x, *pt_A;
+ Word32 tmp_y[MAX_V_MULT_MAT];
+ Word32 *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 = L_add( *pt_y, L_shr( Mpy_32_32( ( *pt_x++ ), ( *pt_A++ ) ), guardbits ) );
+ }
+ pt_y++;
+ }
+
+ mvr2r_Word32( tmp_y, y, Nc );
+}
+Word32 dot_product_cholesky_fx(
+ const Word32 *x, /* i : vector x */
+ const Word32 *A, /* i : Cholesky matrix A */
+ const Word16 N /* i : vector & matrix size */
+)
+{
+ Word16 i, j;
+ Word32 suma, tmp_sum;
+ const Word32 *pt_x, *pt_A;
+
+ pt_A = A;
+ suma = 0;
+ move32();
+
+ FOR( i = 0; i < N; i++ )
+ {
+ tmp_sum = 0;
+ move32();
+ pt_x = x;
+ FOR( j = 0; j <= i; j++ )
+ {
+ tmp_sum = L_add( tmp_sum, Mpy_32_32( *pt_x++, *pt_A++ ) );
+ }
+
+ suma = L_add( suma, Mpy_32_32( tmp_sum, tmp_sum ) );
+ }
+
+ return suma;
+}
+
+#endif
#ifdef IVAS_FLOAT_FIXED
/*---------------------------------------------------------------------*
@@ -928,7 +1017,9 @@ void v_mult_mat_fx(
{
pt_x_fx = x_fx;
*pt_y_fx = 0;
+ move32();
y_q_fx[i] = 0;
+ move32();
FOR( j = 0; j < Nr; j++ )
{
temp = Mpy_32_32( *pt_x_fx++, *pt_A_fx++ );
@@ -936,18 +1027,23 @@ void v_mult_mat_fx(
IF( EQ_16( j, 0 ) )
{
*pt_y_fx = temp;
+ move32();
y_q_fx[i] = temp_q;
+ move16();
}
ELSE
{
IF( GT_16( y_q_fx[i], temp_q ) )
{
*pt_y_fx = L_add( L_shr( *pt_y_fx, sub( y_q_fx[i], temp_q ) ), temp );
+ move32();
y_q_fx[i] = temp_q;
+ move16();
}
ELSE
{
*pt_y_fx = L_add( *pt_y_fx, L_shr( temp, sub( temp_q, y_q_fx[i] ) ) );
+ move32();
}
}
}
@@ -977,55 +1073,6 @@ void v_mult_mat(
{
int16_t i, j;
-#ifdef IVAS_FLOAT_FIXED
- //////////////////// to be removed //////////////////////
- Word32 y_fx[NB_MEL_BANDS];
- Word32 x_fx[NB_MEL_BANDS];
- Word32 A_fx[NB_MEL_BANDS * NB_MEL_COEF];
- Word16 y_q_fx[NB_MEL_BANDS];
- Word16 x_q_fx[NB_MEL_BANDS];
- Word16 A_q_fx[NB_MEL_BANDS * NB_MEL_COEF];
- Word32 *pt_x_fx, *pt_A_fx;
- const Float32 *pt_x, *pt_A;
- Word16 *pt_x_q_fx, *pt_A_q_fx;
-
- pt_A_fx = A_fx;
- pt_A_q_fx = A_q_fx;
- pt_A = A;
-
- FOR( i = 0; i < Nc; i++ )
- {
- pt_x = x;
- pt_x_fx = x_fx;
- pt_x_q_fx = x_q_fx;
- FOR( j = 0; j < Nr; j++ )
- {
- IF( EQ_16( i, 0 ) )
- {
- *pt_x_q_fx = sub( Q_factor_L( *pt_x ), 3 );
- *pt_x_fx++ = (Word32) ( *pt_x++ * ( W_shl( 1, *pt_x_q_fx++ ) ) );
- }
- *pt_A_q_fx = sub( Q_factor_L( *pt_A ), 3 );
- *pt_A_fx++ = (Word32) ( *pt_A++ * ( W_shl( 1, *pt_A_q_fx++ ) ) );
- }
- }
-
- v_mult_mat_fx( y_fx, y_q_fx, (const Word32 *) x_fx, x_q_fx, (const Word32 *) A_fx, A_q_fx, Nr, Nc );
-
- ////////////////////////////// to be removed ////////////////////////
- FOR( i = 0; i < Nc; i++ )
- {
- IF( LT_16( y_q_fx[i], 0 ) )
- {
- y[i] = (Float32) y_fx[i] * W_shl( 1, -y_q_fx[i] );
- }
- ELSE
- {
- y[i] = (Float32) y_fx[i] / W_shl( 1, y_q_fx[i] );
- }
- }
- ////////////////////////////////////////////////////////////////////
-#else
const float *pt_x, *pt_A;
float tmp_y[MAX_V_MULT_MAT];
float *pt_y;
@@ -1045,7 +1092,7 @@ void v_mult_mat(
}
mvr2r( tmp_y, y, Nc );
-#endif
+
return;
}
@@ -1083,14 +1130,98 @@ float logsumexp(
return logf( sum ) + max_exp;
}
+#ifdef IVAS_FLOAT_FIXED
+Word32 logsumexp_fx(
+ const Word32 x[], /* i : input array x */
+ const Word16 x_e,
+ const Word16 N /* i : number of elements in array x */
+)
+{
+ Word32 max_exp, temp32_sub;
+ Word32 sum, temp32, pow_temp;
+ Word32 log2_e_fx = 1549082005; // Q30 of log2(e);
+ Word16 log2_e_fx_e = 1;
+ move16();
+ move16();
+ Word16 i;
+ Word16 pow_e, sum_e = 0;
+ move16();
+ max_exp = x[0];
+ move32();
+ sum = 0;
+ move32();
+ FOR( i = 1; i < N; i++ )
+ {
+ IF( GT_32( x[i], max_exp ) )
+ {
+ max_exp = x[i];
+ move32();
+ }
+ }
+ FOR( i = 0; i < N; i++ )
+ {
+ temp32_sub = L_sub( x[i], max_exp );
+ pow_e = 0;
+ move16();
+ temp32 = Mpy_32_32( log2_e_fx, temp32_sub );
+ pow_temp = BASOP_util_Pow2( temp32, add( x_e, log2_e_fx_e ), &pow_e );
+ sum = BASOP_Util_Add_Mant32Exp( sum, sum_e, pow_temp, pow_e, &sum_e );
+ }
+ temp32 = L_add( BASOP_Util_Log2( sum ), L_shl( sum_e, Q25 ) );
+ temp32 = Mpy_32_32( temp32, 1488522239 ); /*logf(x) = log2(x)*logf(2)*/
+ temp32 = L_add( L_shr( temp32, sub( x_e, 6 ) ), max_exp ); // q = 31-x_e
+ return temp32;
+}
+#endif
/*---------------------------------------------------------------------*
* lin_interp()
*
* Linearly maps x from source range to the target range
*---------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+/*! r: mapped output value */
+Word32 lin_interp32_fx(
+ const Word32 x, /* i : the value to be mapped */
+ const Word32 x1, /* i : source range interval: low end */
+ const Word32 y1, /* i : source range interval: high end */
+ const Word32 x2, /* i : target range interval: low */
+ const Word32 y2, /* i : target range interval: high */
+ const Word16 flag_sat, /* i : flag to indicate whether to apply saturation */
+ Word16 *Q_io /*i/o : i/o Q factor of the output*/
+)
+{
+ Word32 temp32;
+ Word32 temp_div;
+ Word16 temp_e = 0;
+ Word16 exp_out = 0;
+ move16();
+ move16();
+ IF( L_sub( x2, x1 ) == 0 )
+ {
+ return y1;
+ }
+ ELSE IF( flag_sat )
+ {
+ IF( GE_32( x, L_max( x1, x2 ) ) )
+ {
+ return GT_32( x1, x2 ) ? y1 : y2;
+ }
+ ELSE IF( LE_32( x, L_min( x1, x2 ) ) )
+ {
+ return LT_32( x1, x2 ) ? y1 : y2;
+ }
+ }
+ temp32 = Mpy_32_32( L_sub( x, x1 ), L_sub( y2, y1 ) ); // Qin*2 -31
+ temp_div = L_deposit_h( BASOP_Util_Divide3232_Scale( temp32, L_sub( x2, x1 ), &temp_e ) ); // 31-temp_e + 2*Qin -31 - Qin = Qin-temp_e
+ temp32 = BASOP_Util_Add_Mant32Exp( y1, sub( 31, *Q_io ), temp_div, sub( 31, sub( *Q_io, temp_e ) ), &exp_out ); // Qin-temp_e
+ *Q_io = sub( 31, exp_out );
+ return temp32;
+}
+
+#endif
/*! r: mapped output value */
float lin_interp(
const float x, /* i : the value to be mapped */
@@ -1327,12 +1458,13 @@ Word16 matrix_product_mant_exp_fx(
Word16 out_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS];
Word16 *Zp_fx_e = out_e;
Word16 row, col;
+ Word16 x_idx, y_idx;
/* Processing */
test();
test();
test();
- IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 0 ) ) /* We use X transpose */
+ IF( EQ_16( transpX, 1 ) && transpY == 0 ) /* We use X transpose */
{
IF( NE_16( rowsX, rowsY ) )
{
@@ -1348,16 +1480,21 @@ Word16 matrix_product_mant_exp_fx(
move16();
FOR( k = 0; k < rowsX; ++k )
{
- ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ), add( X_fx_e, Y_fx_e ), Zp_fx_e );
+ x_idx = add( k, imult1616( i, rowsX ) );
+ y_idx = add( k, imult1616( j, rowsY ) );
+ ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e );
+ move32();
}
Zp_fx++;
Zp_fx_e++;
}
}
row = colsY;
+ move16();
col = colsX;
+ move16();
}
- ELSE IF( EQ_16( transpX, 0 ) && EQ_16( transpY, 1 ) ) /* We use Y transpose */
+ ELSE IF( transpX == 0 && EQ_16( transpY, 1 ) ) /* We use Y transpose */
{
IF( NE_16( colsX, colsY ) )
{
@@ -1373,14 +1510,19 @@ Word16 matrix_product_mant_exp_fx(
move16();
FOR( k = 0; k < colsX; ++k )
{
- ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ), add( X_fx_e, Y_fx_e ), Zp_fx_e );
+ x_idx = add( i, imult1616( k, rowsX ) );
+ y_idx = add( j, imult1616( k, rowsY ) );
+ ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e );
+ move32();
}
Zp_fx++;
Zp_fx_e++;
}
}
row = rowsY;
+ move16();
col = rowsX;
+ move16();
}
ELSE IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 1 ) ) /* We use both transpose */
{
@@ -1398,7 +1540,10 @@ Word16 matrix_product_mant_exp_fx(
move16();
FOR( k = 0; k < colsX; ++k )
{
- ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ), add( X_fx_e, Y_fx_e ), Zp_fx_e );
+ x_idx = add( k, imult1616( i, rowsX ) );
+ y_idx = add( j, imult1616( k, rowsY ) );
+ ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e );
+ move32();
}
Zp_fx++;
@@ -1406,7 +1551,9 @@ Word16 matrix_product_mant_exp_fx(
}
}
row = rowsY;
+ move16();
col = colsX;
+ move16();
}
ELSE /* Regular case */
{
@@ -1425,18 +1572,24 @@ Word16 matrix_product_mant_exp_fx(
move16();
FOR( k = 0; k < colsX; ++k )
{
- ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ), add( X_fx_e, Y_fx_e ), Zp_fx_e );
+ x_idx = add( i, imult1616( k, rowsX ) );
+ y_idx = add( k, imult1616( j, rowsY ) );
+ ( *Zp_fx ) = BASOP_Util_Add_Mant32Exp( *Zp_fx, *Zp_fx_e, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ), add( X_fx_e, Y_fx_e ), Zp_fx_e );
+ move32();
}
Zp_fx++;
Zp_fx_e++;
}
}
row = colsY;
+ move16();
col = rowsX;
+ move16();
}
Zp_fx = Z_fx;
Zp_fx_e = out_e;
Word16 max_exp = -31;
+ move16();
FOR( j = 0; j < row; ++j )
{
FOR( i = 0; i < col; ++i )
@@ -1447,11 +1600,13 @@ Word16 matrix_product_mant_exp_fx(
}
Zp_fx_e = out_e;
*Z_fx_e = max_exp;
+ move16();
FOR( j = 0; j < row; ++j )
{
FOR( i = 0; i < col; ++i )
{
*Zp_fx = L_shr_r( *Zp_fx, sub( *Z_fx_e, *Zp_fx_e ) );
+ move32();
Zp_fx++;
Zp_fx_e++;
}
@@ -1473,13 +1628,14 @@ Word16 matrix_product_fx(
)
{
Word16 i, j, k;
+ Word16 x_idx, y_idx;
Word32 *Zp_fx = Z_fx;
/* Processing */
test();
test();
test();
- IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 0 ) ) /* We use X transpose */
+ IF( EQ_16( transpX, 1 ) && transpY == 0 ) /* We use X transpose */
{
IF( NE_16( rowsX, rowsY ) )
{
@@ -1493,13 +1649,16 @@ Word16 matrix_product_fx(
move32();
FOR( k = 0; k < rowsX; ++k )
{
- ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) );
+ x_idx = add( k, imult1616( i, rowsX ) );
+ y_idx = add( k, imult1616( j, rowsY ) );
+ ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) );
+ move32();
}
Zp_fx++;
}
}
}
- ELSE IF( EQ_16( transpX, 0 ) && EQ_16( transpY, 1 ) ) /* We use Y transpose */
+ ELSE IF( transpX == 0 && EQ_16( transpY, 1 ) ) /* We use Y transpose */
{
IF( NE_16( colsX, colsY ) )
{
@@ -1513,7 +1672,10 @@ Word16 matrix_product_fx(
move32();
FOR( k = 0; k < colsX; ++k )
{
- ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) );
+ x_idx = add( i, imult1616( k, rowsX ) );
+ y_idx = add( j, imult1616( k, rowsY ) );
+ ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) );
+ move32();
}
Zp_fx++;
}
@@ -1533,7 +1695,10 @@ Word16 matrix_product_fx(
move32();
FOR( k = 0; k < colsX; ++k )
{
- ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) );
+ x_idx = add( k, imult1616( i, rowsX ) );
+ y_idx = add( j, imult1616( k, rowsY ) );
+ ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) );
+ move32();
}
Zp_fx++;
@@ -1555,7 +1720,10 @@ Word16 matrix_product_fx(
move32();
FOR( k = 0; k < colsX; ++k )
{
- ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) );
+ x_idx = add( i, imult1616( k, rowsX ) );
+ y_idx = add( k, imult1616( j, rowsY ) );
+ ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) );
+ move32();
}
Zp_fx++;
}
@@ -1578,6 +1746,7 @@ Word16 matrix_product_q30_fx(
)
{
Word16 i, j, k;
+ Word16 x_idx, y_idx;
Word32 *Zp_fx = Z_fx;
Word64 W_tmp;
@@ -1585,7 +1754,7 @@ Word16 matrix_product_q30_fx(
test();
test();
test();
- IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 0 ) ) /* We use X transpose */
+ IF( EQ_16( transpX, 1 ) && transpY == 0 ) /* We use X transpose */
{
IF( NE_16( rowsX, rowsY ) )
{
@@ -1601,15 +1770,18 @@ Word16 matrix_product_q30_fx(
FOR( k = 0; k < rowsX; ++k )
{
//( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) );
- W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) ); // Q56
+ x_idx = add( k, imult1616( i, rowsX ) );
+ y_idx = add( k, imult1616( j, rowsY ) );
+ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56
}
W_tmp = W_shl( W_tmp, 6 );
- ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision
+ ( *Zp_fx ) = W_round64_L( W_tmp );
+ move32();
Zp_fx++;
}
}
}
- ELSE IF( EQ_16( transpX, 0 ) && EQ_16( transpY, 1 ) ) /* We use Y transpose */
+ ELSE IF( transpX == 0 && EQ_16( transpY, 1 ) ) /* We use Y transpose */
{
IF( NE_16( colsX, colsY ) )
{
@@ -1625,10 +1797,13 @@ Word16 matrix_product_q30_fx(
FOR( k = 0; k < colsX; ++k )
{
//( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) );
- W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); // Q56
+ x_idx = add( i, imult1616( k, rowsX ) );
+ y_idx = add( j, imult1616( k, rowsY ) );
+ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56
}
W_tmp = W_shl( W_tmp, 6 );
- ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision
+ ( *Zp_fx ) = W_round64_L( W_tmp );
+ move32();
Zp_fx++;
}
}
@@ -1649,11 +1824,14 @@ Word16 matrix_product_q30_fx(
FOR( k = 0; k < colsX; ++k )
{
//( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) );
+ x_idx = add( k, imult1616( i, rowsX ) );
+ y_idx = add( j, imult1616( k, rowsY ) );
W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); // Q56
}
W_tmp = W_shl( W_tmp, 6 );
- ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision
+ ( *Zp_fx ) = W_round64_L( W_tmp );
+ move32();
Zp_fx++;
}
}
@@ -1675,10 +1853,13 @@ Word16 matrix_product_q30_fx(
FOR( k = 0; k < colsX; ++k )
{
//( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) );
- W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); // Q56
+ x_idx = add( i, imult1616( k, rowsX ) );
+ y_idx = add( k, imult1616( j, rowsY ) );
+ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56
}
W_tmp = W_shl( W_tmp, 6 );
- ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision
+ ( *Zp_fx ) = W_round64_L( W_tmp );
+ move32();
Zp_fx++;
}
}
@@ -1707,12 +1888,13 @@ Word16 matrix_product_mant_exp(
Word16 *Zp_e = Z_e;
Word32 L_tmp;
Word16 tmp_e;
+ Word16 x_idx, y_idx;
/* Processing */
test();
test();
test();
- IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 0 ) ) /* We use X transpose */
+ IF( EQ_16( transpX, 1 ) && transpY == 0 ) /* We use X transpose */
{
IF( NE_16( rowsX, rowsY ) )
{
@@ -1728,11 +1910,14 @@ Word16 matrix_product_mant_exp(
move16();
FOR( k = 0; k < rowsX; ++k )
{
+ x_idx = add( k, imult1616( i, rowsX ) );
+ y_idx = add( k, imult1616( j, rowsY ) );
//( *Zp ) += X[k + i * rowsX] * Y[k + j * rowsY];
- L_tmp = Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] );
- tmp_e = add( X_e[k + i * rowsX], Y_e[k + j * rowsY] );
+ L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] );
+ tmp_e = add( X_e[x_idx], Y_e[y_idx] );
( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e );
+ move32();
( *Zp_e ) = tmp_e;
move16();
}
@@ -1741,7 +1926,7 @@ Word16 matrix_product_mant_exp(
}
}
}
- ELSE IF( EQ_16( transpX, 0 ) && EQ_16( transpY, 1 ) ) /* We use Y transpose */
+ ELSE IF( transpX == 0 && EQ_16( transpY, 1 ) ) /* We use Y transpose */
{
IF( NE_16( colsX, colsY ) )
{
@@ -1757,9 +1942,11 @@ Word16 matrix_product_mant_exp(
move16();
FOR( k = 0; k < colsX; ++k )
{
+ x_idx = add( i, imult1616( k, rowsX ) );
+ y_idx = add( j, imult1616( k, rowsY ) );
//( *Zp ) += X_fx[i + k * rowsX] * Y_fx[j + k * rowsY];
- L_tmp = Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] );
- tmp_e = add( X_e[i + k * rowsX], Y_e[j + k * rowsY] );
+ L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] );
+ tmp_e = add( X_e[x_idx], Y_e[y_idx] );
( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e );
( *Zp_e ) = tmp_e;
@@ -1786,11 +1973,14 @@ Word16 matrix_product_mant_exp(
move16();
FOR( k = 0; k < colsX; ++k )
{
+ x_idx = add( k, imult1616( i, rowsX ) );
+ y_idx = add( j, imult1616( k, rowsY ) );
//( *Zp ) += X_fx[k + i * rowsX] * Y_fx[j + k * rowsY];
- L_tmp = Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] );
- tmp_e = add( X_e[k + i * rowsX], Y_e[j + k * rowsY] );
+ L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] );
+ tmp_e = add( X_e[x_idx], Y_e[y_idx] );
( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e );
+ move32();
( *Zp_e ) = tmp_e;
move16();
}
@@ -1817,11 +2007,14 @@ Word16 matrix_product_mant_exp(
move16();
FOR( k = 0; k < colsX; ++k )
{
+ x_idx = add( i, imult1616( k, rowsX ) );
+ y_idx = add( k, imult1616( j, rowsY ) );
//( *Zp ) += X_fx[i + k * rowsX] * Y_fx[k + j * rowsY];
- L_tmp = Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] );
- tmp_e = add( X_e[i + k * rowsX], Y_e[k + j * rowsY] );
+ L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] );
+ tmp_e = add( X_e[x_idx], Y_e[y_idx] );
( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e );
+ move32();
( *Zp_e ) = tmp_e;
move16();
}
@@ -1906,6 +2099,7 @@ Word16 matrix_diag_product_fx(
{
Word16 i, j;
Word32 *Zp = Z;
+ Word16 tmp;
/* Processing */
IF( EQ_16( transpX, 1 ) ) /* We use X transpose */
@@ -1918,7 +2112,9 @@ Word16 matrix_diag_product_fx(
{
FOR( i = 0; i < colsX; ++i )
{
- *( Zp ) = Mpy_32_32( X[j + i * rowsX], Y[j] );
+ tmp = add( j, imult1616( i, rowsX ) );
+ *( Zp ) = Mpy_32_32( X[tmp], Y[j] );
+ move32();
Zp++;
}
}
@@ -1935,6 +2131,7 @@ Word16 matrix_diag_product_fx(
FOR( i = 0; i < rowsX; ++i )
{
*( Zp ) = Mpy_32_32( *( X ), Y[j] );
+ move32();
Zp++;
X++;
}
@@ -1942,6 +2139,7 @@ Word16 matrix_diag_product_fx(
}
*Z_e = add( X_e, Y_e );
+ move16();
return EXIT_SUCCESS;
}
@@ -1962,6 +2160,7 @@ Word16 diag_matrix_product_fx(
{
Word16 i, j;
Word32 *Zp = Z;
+ Word16 tmp;
/* Processing */
IF( EQ_16( transpX, 1 ) ) /* We use X transpose */
@@ -1974,7 +2173,9 @@ Word16 diag_matrix_product_fx(
{
FOR( j = 0; j < entriesY; ++j )
{
- *( Zp ) = Mpy_32_32( X[i + j * rowsX], Y[j] );
+ tmp = add( i, imult1616( j, rowsX ) );
+ *( Zp ) = Mpy_32_32( X[tmp], Y[j] );
+ move32();
Zp++;
}
}
@@ -1990,6 +2191,7 @@ Word16 diag_matrix_product_fx(
FOR( j = 0; j < entriesY; ++j )
{
*( Zp ) = Mpy_32_32( *( X ), Y[j] );
+ move32();
Zp++;
X++;
}
@@ -1997,6 +2199,7 @@ Word16 diag_matrix_product_fx(
}
*Z_e = add( Y_e, X_e );
+ move16();
return EXIT_SUCCESS;
}
@@ -2073,12 +2276,13 @@ Word16 matrix_product_diag_fx(
{
Word16 j, k;
Word32 *Zp = Z;
+ Word16 y_idx, x_idx;
/* Processing */
test();
test();
test();
- IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 0 ) ) /* We use X transpose */
+ IF( EQ_16( transpX, 1 ) && transpY == 0 ) /* We use X transpose */
{
IF( NE_16( rowsX, rowsY ) )
{
@@ -2088,14 +2292,18 @@ Word16 matrix_product_diag_fx(
FOR( j = 0; j < colsY; ++j )
{
( *Zp ) = 0;
+ move32();
FOR( k = 0; k < rowsX; ++k )
{
- ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[k + j * rowsX], Y[k + j * rowsY] ) );
+ x_idx = add( k, imult1616( j, rowsX ) );
+ y_idx = add( k, imult1616( j, rowsY ) );
+ ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) );
+ move32();
}
Zp++;
}
}
- ELSE IF( EQ_16( transpX, 0 ) && EQ_16( transpY, 1 ) ) /* We use Y transpose */
+ ELSE IF( transpX == 0 && EQ_16( transpY, 1 ) ) /* We use Y transpose */
{
IF( NE_16( colsX, colsY ) )
{
@@ -2104,9 +2312,13 @@ Word16 matrix_product_diag_fx(
FOR( j = 0; j < rowsY; ++j )
{
( *Zp ) = 0;
+ move32();
FOR( k = 0; k < colsX; ++k )
{
- ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[j + k * rowsX], Y[j + k * rowsY] ) );
+ x_idx = add( j, imult1616( k, rowsX ) );
+ y_idx = add( j, imult1616( k, rowsY ) );
+ ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) );
+ move32();
}
Zp++;
}
@@ -2122,9 +2334,13 @@ Word16 matrix_product_diag_fx(
{
( *Zp ) = 0;
+ move32();
FOR( k = 0; k < colsX; ++k )
{
- ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[k + j * rowsX], Y[j + k * rowsY] ) );
+ x_idx = add( k, imult1616( j, rowsX ) );
+ y_idx = add( j, imult1616( k, rowsY ) );
+ ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) );
+ move32();
}
Zp++;
@@ -2140,15 +2356,20 @@ Word16 matrix_product_diag_fx(
FOR( j = 0; j < colsY; ++j )
{
( *Zp ) = 0;
+ move32();
FOR( k = 0; k < colsX; ++k )
{
- ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[j + k * rowsX], Y[k + j * rowsY] ) );
+ x_idx = add( j, imult1616( k, rowsX ) );
+ y_idx = add( k, imult1616( j, rowsY ) );
+ ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) );
+ move32();
}
Zp++;
}
}
*Z_e = add( X_e, Y_e );
+ move16();
return EXIT_SUCCESS;
}
@@ -2264,6 +2485,7 @@ void cmplx_matrix_square_fx(
Word16 i, j, k;
Word32 *realZp, *imagZp;
const Word32 *p_real1, *p_real2, *p_imag1, *p_imag2;
+ Word16 tmp1, tmp2;
/* resulting matrix is hermitean, we only need to calc the upper triangle */
/* we assume transposition needed */
@@ -2273,12 +2495,12 @@ void cmplx_matrix_square_fx(
{
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 );
+ p_real1 = realX + imult1616( i, mRows );
+ p_imag1 = imagX + imult1616( i, mRows );
+ p_real2 = realX + imult1616( j, mRows );
+ p_imag2 = imagX + imult1616( j, mRows );
+ realZp = realZ + add( i, imult1616( nCols, j ) );
+ imagZp = imagZ + add( i, imult1616( nCols, j ) );
*( realZp ) = 0;
move32();
*( imagZp ) = 0;
@@ -2287,7 +2509,9 @@ void cmplx_matrix_square_fx(
FOR( k = 0; k < mRows; k++ )
{
*( imagZp ) = L_add( *( imagZp ), L_sub( Mpy_32_32( *( p_real1 ), *( p_imag2 ) ), Mpy_32_32( *( p_real2 ), *( p_imag1 ) ) ) );
+ move32();
*( realZp ) = L_add( *( realZp ), L_add( Mpy_32_32( *( p_real1 ), *( p_real2 ) ), Mpy_32_32( *( p_imag1 ), *( p_imag2 ) ) ) );
+ move32();
p_real1++;
p_real2++;
p_imag1++;
@@ -2301,9 +2525,11 @@ void cmplx_matrix_square_fx(
{
FOR( j = 0; j < i; j++ )
{
- realZ[i + nCols * j] = realZ[j + nCols * i];
+ tmp1 = add( i, imult1616( nCols, j ) );
+ tmp2 = add( j, imult1616( nCols, i ) );
+ realZ[tmp1] = realZ[tmp2];
move32();
- imagZ[i + nCols * j] = imagZ[j + nCols * i];
+ imagZ[tmp1] = imagZ[tmp2];
move32();
}
}
@@ -2410,6 +2636,7 @@ void v_multc_acc_32_16(
FOR( i = 0; i < N; i++ )
{
y[i] = L_add( y[i], Mpy_32_16_1( x[i], c ) );
+ move32();
}
return;
@@ -2426,6 +2653,7 @@ void v_multc_acc_32_32(
FOR( i = 0; i < N; i++ )
{
y[i] = L_add( y[i], Mpy_32_32( x[i], c ) );
+ move32();
}
return;
@@ -2496,54 +2724,109 @@ void lls_interp_n_fx(
{
Word16 i;
const Word16 n_i_fx[11] = { 0, 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480 }; // Q11
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+
const Word16 one_by_n_fx[11] = { 0, 32767, 16384, 10911, 8192, 6553, 5459, 4681, 4096, 3640, 3276 };
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+
const Word16 sum_i_fx[12] = { 0, 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55 };
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
// 1.0f/ ( N * sum_ii[N] - sum_i[N] * sum_i[N] )
const Word32 res_table[12] = { 0, 0, 0, 357913952, 107374184, 42949672, 20452226, 10956549, 6391320, 3976821, 2603010, 385 };
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
Word32 sum_x_fx, sum_ix_fx, slope_fx, offset_fx;
Word16 dot_exp = 0, sum_ix_q = 0;
- ;
+ move16();
+ move16();
+
Word32 num;
- assert( N > 0 && N <= 10 );
+ assert( N > 0 && LE_16( N, 10 ) );
sum_x_fx = 0;
+ move32();
FOR( int idx = 0; idx < N; idx++ )
{
- sum_x_fx = (Word32) sum_x_fx + x_fx[idx];
+ sum_x_fx = L_add( sum_x_fx, x_fx[idx] );
}
sum_ix_fx = dotp_fx( x_fx, n_i_fx, N, &dot_exp );
- sum_ix_q = 30 - ( dot_exp - ( 11 + 15 ) );
+ sum_ix_q = sub( 30, sub( dot_exp, ( 11 + 15 ) ) );
- sum_ix_fx = L_shr( sum_ix_fx, sum_ix_q - 15 );
- num = L_sub( ( sum_ix_fx * N ), ( sum_x_fx * sum_i_fx[N] ) );
+ sum_ix_fx = L_shr( sum_ix_fx, sub( sum_ix_q, 15 ) );
+ num = L_sub( imult3216( sum_ix_fx, N ), imult3216( sum_x_fx, sum_i_fx[N] ) );
slope_fx = Mpy_32_32( num, res_table[N] );
- offset_fx = Mpy_32_16_1( L_sub( sum_x_fx, ( slope_fx * sum_i_fx[N] ) ), one_by_n_fx[N] );
+ offset_fx = Mpy_32_16_1( L_sub( sum_x_fx, imult3216( slope_fx, sum_i_fx[N] ) ), one_by_n_fx[N] );
IF( upd )
{
FOR( i = 0; i < N; i++ )
{
- IF( slope_fx * i > MAX_WORD16 )
+ IF( GT_32( imult3216( slope_fx, i ), MAX_WORD16 ) )
{
x_fx[i] = MAX_WORD16;
+ move16();
}
ELSE
{
- x_fx[i] = (Word16) L_add_sat( ( slope_fx * i ), offset_fx );
+ x_fx[i] = extract_l( L_add_sat( imult3216( slope_fx, i ), offset_fx ) );
+ move16();
}
}
}
IF( a_fx != NULL )
{
- *a_fx = (Word16) slope_fx;
+ *a_fx = extract_l( slope_fx );
+ move16();
}
IF( b_fx != NULL )
{
- *b_fx = (Word16) offset_fx;
+ *b_fx = extract_l( offset_fx );
+ move16();
}
return;
@@ -2575,6 +2858,7 @@ static Word32 wrap_azi_fixed(
const Word32 azi_deg )
{
Word32 azi = azi_deg;
+ move32();
/* Wrap azimuth value */
WHILE( GT_32( azi, ANGLE_180_DEG_Q22 ) )
@@ -2677,12 +2961,16 @@ void panning_wrap_angles_fixed(
Word32 azi, ele;
azi = azi_deg;
+ move32();
ele = ele_deg;
+ move32();
- IF( L_abs( ele ) < ANGLE_90_DEG_Q22 )
+ IF( LT_32( L_abs( ele ), ANGLE_90_DEG_Q22 ) )
{
*ele_wrapped = ele;
+ move32();
*azi_wrapped = wrap_azi_fixed( azi );
+ move32();
return;
}
ELSE
@@ -2691,36 +2979,40 @@ void panning_wrap_angles_fixed(
IF( ( ( ele % ANGLE_90_DEG_Q22 ) == 0 ) && ( ( ele % ANGLE_180_DEG_Q22 ) != 0 ) )
{
*azi_wrapped = 0;
- WHILE( ele > ANGLE_90_DEG_Q22 )
+ move32();
+ WHILE( GT_32( ele, ANGLE_90_DEG_Q22 ) )
{
- ele -= ANGLE_360_DEG_Q22;
+ ele = L_sub( ele, ANGLE_360_DEG_Q22 );
}
- WHILE( ele < -ANGLE_90_DEG_Q22 )
+ WHILE( LT_32( ele, -ANGLE_90_DEG_Q22 ) )
{
- ele += ANGLE_360_DEG_Q22;
+ ele = L_add( ele, ANGLE_360_DEG_Q22 );
}
*ele_wrapped = ele;
+ move32();
}
ELSE
{
/* Wrap elevation and adjust azimuth accordingly */
- WHILE( L_abs( ele ) > ANGLE_90_DEG_Q22 )
+ WHILE( GT_32( L_abs( ele ), ANGLE_90_DEG_Q22 ) )
{
/* Flip to other hemisphere */
- azi += ANGLE_180_DEG_Q22;
+ azi = L_add( azi, ANGLE_180_DEG_Q22 );
/* Compensate elevation accordingly */
- IF( ele > ANGLE_90_DEG_Q22 )
+ IF( GT_32( ele, ANGLE_90_DEG_Q22 ) )
{
- ele = ANGLE_180_DEG_Q22 - ele;
+ ele = L_sub( ANGLE_180_DEG_Q22, ele );
}
- ELSE IF( ele < -ANGLE_90_DEG_Q22 )
+ ELSE IF( LT_32( ele, -ANGLE_90_DEG_Q22 ) )
{
- ele = -ANGLE_180_DEG_Q22 - ele;
+ ele = L_sub( -ANGLE_180_DEG_Q22, ele );
}
}
*azi_wrapped = wrap_azi_fixed( azi );
+ move32();
*ele_wrapped = ele;
+ move32();
}
return;
@@ -2787,19 +3079,28 @@ void v_sort_ind_fixed(
FOR( i = 0; i < len; i++ )
{
idx[i] = i;
+ move16();
}
FOR( i = len - 2; i >= 0; i-- )
{
tempr = x[i];
+ move32();
tempi = idx[i];
- FOR( j = i + 1; ( j < len ) && ( tempr > x[j] ); j++ )
+ move16();
+ test();
+ FOR( j = add( i, 1 ); LT_16( j, len ) && GT_32( tempr, x[j] ); j++ )
{
+ test();
x[j - 1] = x[j];
+ move32();
idx[j - 1] = idx[j];
+ move16();
}
x[j - 1] = tempr;
+ move32();
idx[j - 1] = tempi;
+ move16();
}
return;
@@ -2840,12 +3141,16 @@ Word16 is_IVAS_bitrate_fx(
Word16 j;
j = SIZE_IVAS_BRATE_TBL - IVAS_NUM_ACTIVE_BRATES; /* skip NO_DATA and SID bitrates */
+ move16();
+
+ test();
WHILE( LE_16( j, SIZE_IVAS_BRATE_TBL ) && NE_32( ivas_total_brate, ivas_brate_tbl[j] ) )
{
- j++;
+ test();
+ j = add( j, 1 );
}
- IF( j >= SIZE_IVAS_BRATE_TBL )
+ IF( GE_16( j, SIZE_IVAS_BRATE_TBL ) )
{
return 0;
}
@@ -2908,9 +3213,9 @@ Word16 is_SIDrate(
test();
test();
- IF( EQ_32( ivas_total_brate, SID_1k75 ) ||
- EQ_32( ivas_total_brate, SID_2k40 ) ||
- EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
+ if ( EQ_32( ivas_total_brate, SID_1k75 ) ||
+ EQ_32( ivas_total_brate, SID_2k40 ) ||
+ EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
{
sid_rate_flag = 1;
move16();
@@ -2970,7 +3275,7 @@ Word16 rand_triangular_signed_fx(
Word16 tmp1, tmp2;
Word16 exp1, exp = 1;
move16();
- IF( LE_16( rand_val, 0 ) )
+ IF( rand_val <= 0 )
{
/* rand_val in [-1, 0] */
/*0.5f * (sqrtf(rand_val + 1.0f) - 1)*/
@@ -3003,7 +3308,6 @@ Word16 rand_triangular_signed_fx(
*
* calculates ceil(log2(val))
*-------------------------------------------------------------------*/
-
Word16 ceil_log_2(
UWord64 val )
{
@@ -3012,70 +3316,263 @@ Word16 ceil_log_2(
{
assert( 0 );
}
- return val <= 1 ? 0 : val <= 2 ? 1
- : val <= 4 ? 2
- : val <= 8 ? 3
- : val <= 16 ? 4
- : val <= 32 ? 5
- : val <= 64 ? 6
- : val <= 128 ? 7
- : val <= 256 ? 8
- : val <= 512 ? 9
- : val <= 1024 ? 10
- : val <= 2048 ? 11
- : val <= 4096 ? 12
- : val <= 8192 ? 13
- : val <= 16384 ? 14
- : val <= 32768 ? 15
- : val <= 65536 ? 16
- : val <= 131072 ? 17
- : val <= 262144 ? 18
- : val <= 524288 ? 19
- : val <= 1048576 ? 20
- : val <= 2097152 ? 21
- : val <= 4194304 ? 22
- : val <= 8388608 ? 23
- : val <= 16777216 ? 24
- : val <= 33554432 ? 25
- : val <= 67108864 ? 26
- : val <= 134217728 ? 27
- : val <= 268435456 ? 28
- : val <= 536870912 ? 29
- : val <= 1073741824 ? 30
- : val <= 2147483648 ? 31
- : val <= 4294967296 ? 32
- : val <= 8589934592 ? 33
- : val <= 17179869184 ? 34
- : val <= 34359738368 ? 35
- : val <= 68719476736 ? 36
- : val <= 137438953472 ? 37
- : val <= 274877906944 ? 38
- : val <= 549755813888 ? 39
- : val <= 1099511627776 ? 40
- : val <= 2199023255552 ? 41
- : val <= 4398046511104 ? 42
- : val <= 8796093022208 ? 43
- : val <= 17592186044416 ? 44
- : val <= 35184372088832 ? 45
- : val <= 70368744177664 ? 46
- : val <= 140737488355328 ? 47
- : val <= 281474976710656 ? 48
- : val <= 562949953421312 ? 49
- : val <= 1125899906842624 ? 50
- : val <= 2251799813685248 ? 51
- : val <= 4503599627370496 ? 52
- : val <= 9007199254740992 ? 53
- : val <= 18014398509481984 ? 54
- : val <= 36028797018963968 ? 55
- : val <= 72057594037927936 ? 56
- : val <= 144115188075855872 ? 57
- : val <= 288230376151711744 ? 58
- : val <= 576460752303423488 ? 59
- : val <= 1152921504606846976 ? 60
- : val <= 2305843009213693952 ? 61
- : val <= 4611686018427387904 ? 62
- : val <= 9223372036854775807 ? 63
- : 64;
+ ELSE IF( LE_64( val, 1 ) )
+ {
+ return 0;
+ }
+ ELSE IF( LE_64( val, 2 ) )
+ {
+ return 1;
+ }
+ ELSE IF( LE_64( val, 4 ) )
+ {
+ return 2;
+ }
+ ELSE IF( LE_64( val, 8 ) )
+ {
+ return 3;
+ }
+ ELSE IF( LE_64( val, 16 ) )
+ {
+ return 4;
+ }
+ ELSE IF( LE_64( val, 32 ) )
+ {
+ return 5;
+ }
+ ELSE IF( LE_64( val, 64 ) )
+ {
+ return 6;
+ }
+ ELSE IF( LE_64( val, 128 ) )
+ {
+ return 7;
+ }
+ ELSE IF( LE_64( val, 256 ) )
+ {
+ return 8;
+ }
+ ELSE IF( LE_64( val, 512 ) )
+ {
+ return 9;
+ }
+ ELSE IF( LE_64( val, 1024 ) )
+ {
+ return 10;
+ }
+ ELSE IF( LE_64( val, 2048 ) )
+ {
+ return 11;
+ }
+ ELSE IF( LE_64( val, 4096 ) )
+ {
+ return 12;
+ }
+ ELSE IF( LE_64( val, 8192 ) )
+ {
+ return 13;
+ }
+ ELSE IF( LE_64( val, 16384 ) )
+ {
+ return 14;
+ }
+ ELSE IF( LE_64( val, 32768 ) )
+ {
+ return 15;
+ }
+ ELSE IF( LE_64( val, 65536 ) )
+ {
+ return 16;
+ }
+ ELSE IF( LE_64( val, 131072 ) )
+ {
+ return 17;
+ }
+ ELSE IF( LE_64( val, 262144 ) )
+ {
+ return 18;
+ }
+ ELSE IF( LE_64( val, 524288 ) )
+ {
+ return 19;
+ }
+ ELSE IF( LE_64( val, 1048576 ) )
+ {
+ return 20;
+ }
+ ELSE IF( LE_64( val, 2097152 ) )
+ {
+ return 21;
+ }
+ ELSE IF( LE_64( val, 4194304 ) )
+ {
+ return 22;
+ }
+ ELSE IF( LE_64( val, 8388608 ) )
+ {
+ return 23;
+ }
+ ELSE IF( LE_64( val, 16777216 ) )
+ {
+ return 24;
+ }
+ ELSE IF( LE_64( val, 33554432 ) )
+ {
+ return 25;
+ }
+ ELSE IF( LE_64( val, 67108864 ) )
+ {
+ return 26;
+ }
+ ELSE IF( LE_64( val, 134217728 ) )
+ {
+ return 27;
+ }
+ ELSE IF( LE_64( val, 268435456 ) )
+ {
+ return 28;
+ }
+ ELSE IF( LE_64( val, 536870912 ) )
+ {
+ return 29;
+ }
+ ELSE IF( LE_64( val, 1073741824 ) )
+ {
+ return 30;
+ }
+ ELSE IF( LE_64( val, 2147483648 ) )
+ {
+ return 31;
+ }
+ ELSE IF( LE_64( val, 4294967296 ) )
+ {
+ return 32;
+ }
+ ELSE IF( LE_64( val, 8589934592 ) )
+ {
+ return 33;
+ }
+ ELSE IF( LE_64( val, 17179869184 ) )
+ {
+ return 34;
+ }
+ ELSE IF( LE_64( val, 34359738368 ) )
+ {
+ return 35;
+ }
+ ELSE IF( LE_64( val, 68719476736 ) )
+ {
+ return 36;
+ }
+ ELSE IF( LE_64( val, 137438953472 ) )
+ {
+ return 37;
+ }
+ ELSE IF( LE_64( val, 274877906944 ) )
+ {
+ return 38;
+ }
+ ELSE IF( LE_64( val, 549755813888 ) )
+ {
+ return 39;
+ }
+ ELSE IF( LE_64( val, 1099511627776 ) )
+ {
+ return 40;
+ }
+ ELSE IF( LE_64( val, 2199023255552 ) )
+ {
+ return 41;
+ }
+ ELSE IF( LE_64( val, 4398046511104 ) )
+ {
+ return 42;
+ }
+ ELSE IF( LE_64( val, 8796093022208 ) )
+ {
+ return 43;
+ }
+ ELSE IF( LE_64( val, 17592186044416 ) )
+ {
+ return 44;
+ }
+ ELSE IF( LE_64( val, 35184372088832 ) )
+ {
+ return 45;
+ }
+ ELSE IF( LE_64( val, 70368744177664 ) )
+ {
+ return 46;
+ }
+ ELSE IF( LE_64( val, 140737488355328 ) )
+ {
+ return 47;
+ }
+ ELSE IF( LE_64( val, 281474976710656 ) )
+ {
+ return 48;
+ }
+ ELSE IF( LE_64( val, 562949953421312 ) )
+ {
+ return 49;
+ }
+ ELSE IF( LE_64( val, 1125899906842624 ) )
+ {
+ return 50;
+ }
+ ELSE IF( LE_64( val, 2251799813685248 ) )
+ {
+ return 51;
+ }
+ ELSE IF( LE_64( val, 4503599627370496 ) )
+ {
+ return 52;
+ }
+ ELSE IF( LE_64( val, 9007199254740992 ) )
+ {
+ return 53;
+ }
+ ELSE IF( LE_64( val, 18014398509481984 ) )
+ {
+ return 54;
+ }
+ ELSE IF( LE_64( val, 36028797018963968 ) )
+ {
+ return 55;
+ }
+ ELSE IF( LE_64( val, 72057594037927936 ) )
+ {
+ return 56;
+ }
+ ELSE IF( LE_64( val, 144115188075855872 ) )
+ {
+ return 57;
+ }
+ ELSE IF( LE_64( val, 288230376151711744 ) )
+ {
+ return 58;
+ }
+ ELSE IF( LE_64( val, 576460752303423488 ) )
+ {
+ return 59;
+ }
+ ELSE IF( LE_64( val, 1152921504606846976 ) )
+ {
+ return 60;
+ }
+ ELSE IF( LE_64( val, 2305843009213693952 ) )
+ {
+ return 61;
+ }
+ ELSE IF( LE_64( val, 4611686018427387904 ) )
+ {
+ return 62;
+ }
+ ELSE IF( LE_64( val, 9223372036854775807 ) )
+ {
+ return 63;
+ }
+ return 64;
}
@@ -3088,32 +3585,34 @@ Word16 ceil_log_2(
*-------------------------------------------------------------------*/
Word64 var_32_fx(
- const Word32 *x, /* i : input vector */
- const int16_t len, /* i : length of inputvector */
- Word16 q /* q : q-factor for the array */
+ const Word32 *x, /* i : input vector */
+ const Word16 len, /* i : length of inputvector */
+ Word16 q /* q : q-factor for the array */
)
{
Word64 mean, var;
mean = 0;
+ move64();
var = 0;
+ move64();
FOR( int i = 0; i < len; i++ )
{
- mean = mean + x[i];
+ mean = W_add( mean, x[i] );
}
- mean = mean / len;
+ mean = mean / len; /* NOTE: No BASOP for 64 bit division */
FOR( int i = 0; i < len; i++ )
{
- var = var + Mpy_32_32( L_sub( x[i], (Word32) mean ), L_sub( x[i], (Word32) mean ) );
+ var = W_add( var, Mpy_32_32( L_sub( x[i], W_extract_l( mean ) ), L_sub( x[i], W_extract_l( mean ) ) ) );
}
- var = var << ( 31 - q );
+ var = W_shl( var, sub( 31, q ) );
- var = var / len;
+ var = var / len; /* NOTE: No BASOP for 64 bit division */
return var;
}
diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c
index 54539e3838ee7f05bca45d0e718f490cf96f7674..86093edcd64bb4058d253e161f8159eb2e922de3 100644
--- a/lib_com/ivas_transient_det.c
+++ b/lib_com/ivas_transient_det.c
@@ -39,7 +39,7 @@
#include "ivas_prot.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
+#include "prot_fx.h"
#endif
#include "ivas_stat_com.h"
@@ -134,11 +134,14 @@ static void ivas_transient_det_init(
float filt_coeff_arr[3][IVAS_BIQUAD_FILT_LEN << 1];
#else
Word32 filt_coeff_arr_fx[3][IVAS_BIQUAD_FILT_LEN << 1];
+ const Word16 *filt_coeff_arr_e = NULL;
#endif
#ifdef IVAS_FLOAT_FIXED
- hTranDet->in_duck_gain = 1073741824; // Q30
+ hTranDet->in_duck_gain = 1073741824; // Q30
+ move32();
hTranDet->out_duck_gain = 1073741824; // Q30
+ move32();
#else
hTranDet->in_duck_gain = 1.0f;
hTranDet->out_duck_gain = 1.0f;
@@ -211,68 +214,104 @@ static void ivas_transient_det_init(
case 48000:
/*env_hpf*/
filt_coeff_arr_fx[0][0] = IVAS_C_HPF_48k_fx;
- filt_coeff_arr_fx[0][1] = -IVAS_C_HPF_48k_fx;
+ move32();
+ filt_coeff_arr_fx[0][1] = L_negate( IVAS_C_HPF_48k_fx );
+ move32();
filt_coeff_arr_fx[0][3] = ONE_IN_Q30;
- filt_coeff_arr_fx[0][4] = -IVAS_C_HPF_48k_fx;
+ move32();
+ filt_coeff_arr_fx[0][4] = L_negate( IVAS_C_HPF_48k_fx );
+ move32();
/*env_fast*/
- filt_coeff_arr_fx[1][0] = ONE_IN_Q30 - IVAS_C_FAST_48k_fx;
+ filt_coeff_arr_fx[1][0] = L_sub( ONE_IN_Q30, IVAS_C_FAST_48k_fx );
+ move32();
filt_coeff_arr_fx[1][3] = ONE_IN_Q30;
- filt_coeff_arr_fx[1][4] = -IVAS_C_FAST_48k_fx;
+ move32();
+ filt_coeff_arr_fx[1][4] = L_negate( IVAS_C_FAST_48k_fx );
+ move32();
/*env_slow*/
- filt_coeff_arr_fx[2][0] = ONE_IN_Q30 - IVAS_C_SLOW_48k_fx;
+ filt_coeff_arr_fx[2][0] = L_sub( ONE_IN_Q30, IVAS_C_SLOW_48k_fx );
+ move32();
filt_coeff_arr_fx[2][3] = ONE_IN_Q30;
- filt_coeff_arr_fx[2][4] = -IVAS_C_SLOW_48k_fx;
+ move32();
+ filt_coeff_arr_fx[2][4] = L_negate( IVAS_C_SLOW_48k_fx );
+ move32();
hTranDet->in_duck_coeff = IVAS_C_IN_DUCK_48k_fx;
+ move32();
hTranDet->out_duck_coeff = IVAS_C_OUT_DUCK_48k_fx;
+ move32();
BREAK;
case 32000:
/*env_hpf*/
filt_coeff_arr_fx[0][0] = IVAS_C_HPF_32k_fx;
- filt_coeff_arr_fx[0][1] = -IVAS_C_HPF_32k_fx;
+ move32();
+ filt_coeff_arr_fx[0][1] = L_negate( IVAS_C_HPF_32k_fx );
+ move32();
filt_coeff_arr_fx[0][3] = ONE_IN_Q30;
- filt_coeff_arr_fx[0][4] = -IVAS_C_HPF_32k_fx;
+ move32();
+ filt_coeff_arr_fx[0][4] = L_negate( IVAS_C_HPF_32k_fx );
+ move32();
/*env_fast*/
- filt_coeff_arr_fx[1][0] = ONE_IN_Q30 - IVAS_C_FAST_32k_fx;
+ filt_coeff_arr_fx[1][0] = L_sub( ONE_IN_Q30, IVAS_C_FAST_32k_fx );
+ move32();
filt_coeff_arr_fx[1][3] = ONE_IN_Q30;
- filt_coeff_arr_fx[1][4] = -IVAS_C_FAST_32k_fx;
+ move32();
+ filt_coeff_arr_fx[1][4] = L_negate( IVAS_C_FAST_32k_fx );
+ move32();
/*env_slow*/
- filt_coeff_arr_fx[2][0] = ONE_IN_Q30 - IVAS_C_SLOW_32k_fx;
+ filt_coeff_arr_fx[2][0] = L_sub( ONE_IN_Q30, IVAS_C_SLOW_32k_fx );
+ move32();
filt_coeff_arr_fx[2][3] = ONE_IN_Q30;
- filt_coeff_arr_fx[2][4] = -IVAS_C_SLOW_32k_fx;
+ move32();
+ filt_coeff_arr_fx[2][4] = L_negate( IVAS_C_SLOW_32k_fx );
+ move32();
hTranDet->in_duck_coeff = IVAS_C_IN_DUCK_32k_fx;
+ move32();
hTranDet->out_duck_coeff = IVAS_C_OUT_DUCK_32k_fx;
+ move32();
BREAK;
case 16000:
/*env_hpf*/
filt_coeff_arr_fx[0][0] = IVAS_C_HPF_16k_fx;
- filt_coeff_arr_fx[0][1] = -IVAS_C_HPF_16k_fx;
+ move32();
+ filt_coeff_arr_fx[0][1] = L_negate( IVAS_C_HPF_16k_fx );
+ move32();
filt_coeff_arr_fx[0][3] = ONE_IN_Q30;
- filt_coeff_arr_fx[0][4] = -IVAS_C_HPF_16k_fx;
+ move32();
+ filt_coeff_arr_fx[0][4] = L_negate( IVAS_C_HPF_16k_fx );
+ move32();
/*env_fast*/
- filt_coeff_arr_fx[1][0] = ONE_IN_Q30 - IVAS_C_FAST_16k_fx;
+ filt_coeff_arr_fx[1][0] = L_sub( ONE_IN_Q30, IVAS_C_FAST_16k_fx );
+ move32();
filt_coeff_arr_fx[1][3] = ONE_IN_Q30;
- filt_coeff_arr_fx[1][4] = -IVAS_C_FAST_16k_fx;
+ move32();
+ filt_coeff_arr_fx[1][4] = L_negate( IVAS_C_FAST_16k_fx );
+ move32();
/*env_slow*/
- filt_coeff_arr_fx[2][0] = ONE_IN_Q30 - IVAS_C_SLOW_16k_fx;
+ filt_coeff_arr_fx[2][0] = L_sub( ONE_IN_Q30, IVAS_C_SLOW_16k_fx );
+ move32();
filt_coeff_arr_fx[2][3] = ONE_IN_Q30;
- filt_coeff_arr_fx[2][4] = -IVAS_C_SLOW_16k_fx;
+ move32();
+ filt_coeff_arr_fx[2][4] = L_negate( IVAS_C_SLOW_16k_fx );
+ move32();
hTranDet->in_duck_coeff = IVAS_C_IN_DUCK_16k_fx;
+ move32();
hTranDet->out_duck_coeff = IVAS_C_OUT_DUCK_16k_fx;
+ move32();
BREAK;
@@ -284,13 +323,14 @@ static void ivas_transient_det_init(
ivas_filters_init( &hTranDet->env_fast, (const float *) filt_coeff_arr[1], IVAS_FILTER_ORDER_1 );
ivas_filters_init( &hTranDet->env_slow, (const float *) filt_coeff_arr[2], IVAS_FILTER_ORDER_1 );
#else
- ivas_filters_init_fx( &hTranDet->env_hpf, (const Word32 *) filt_coeff_arr_fx[0], IVAS_FILTER_ORDER_1 );
- ivas_filters_init_fx( &hTranDet->env_fast, (const Word32 *) filt_coeff_arr_fx[1], IVAS_FILTER_ORDER_1 );
- ivas_filters_init_fx( &hTranDet->env_slow, (const Word32 *) filt_coeff_arr_fx[2], IVAS_FILTER_ORDER_1 );
+ ivas_filters_init_fx( &hTranDet->env_hpf, (const Word32 *) filt_coeff_arr_fx[0], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 );
+ ivas_filters_init_fx( &hTranDet->env_fast, (const Word32 *) filt_coeff_arr_fx[1], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 );
+ ivas_filters_init_fx( &hTranDet->env_slow, (const Word32 *) filt_coeff_arr_fx[2], filt_coeff_arr_e, IVAS_FILTER_ORDER_1 );
#endif
hTranDet->duck_mult_fac = IVAS_TDET_DUCK_MULT_FAC;
+ move32();
return;
}
@@ -332,6 +372,7 @@ void ivas_transient_det_close(
ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */
)
{
+ test();
IF( hTranDet == NULL || *hTranDet == NULL )
{
return;
@@ -360,25 +401,32 @@ void ivas_transient_det_process_fx(
Word32 in_duck_gain[L_FRAME48k];
Word16 num_sf, sf, sf_samp, idx;
Word32 mem = hTranDet->in_duck_gain;
+ move32();
ivas_td_decorr_get_ducking_gains_fx( hTranDet, pIn_pcm, in_duck_gain, NULL, frame_len, IVAS_TDET_ONLY );
transient_det[0] = 0;
+ move16();
transient_det[1] = 0;
- IF( GT_32( L_sub( mem, hTranDet->in_duck_gain ), IVAS_TDET_PARM_TRANS_THR ) )
+ move16();
+ if ( GT_32( L_sub( mem, hTranDet->in_duck_gain ), IVAS_TDET_PARM_TRANS_THR ) )
{
transient_det[0] = 1;
+ move16();
}
num_sf = 16;
- sf_samp = frame_len / num_sf;
+ move16();
+ sf_samp = idiv1616( frame_len, num_sf );
FOR( sf = 1; sf <= num_sf; sf++ )
{
- idx = ( sf_samp * sf ) - 1;
- IF( GT_32( L_sub( mem, in_duck_gain[idx] ), IVAS_POINT_ONE_ONE_IN_Q30 ) )
+ idx = sub( imult1616( sf_samp, sf ), 1 );
+ if ( GT_32( L_sub( mem, in_duck_gain[idx] ), IVAS_POINT_ONE_ONE_IN_Q30 ) )
{
transient_det[1] = 1;
+ move16();
}
mem = in_duck_gain[idx];
+ move32();
}
return;
@@ -470,11 +518,13 @@ static Word32 ivas_calc_duck_gain_fx(
IF( LT_32( Mpy_32_32( duck_mult_fac, env_1 ), Mpy_32_32( L_shr( duck_gain_out, 1 ), env_2 ) ) )
{
- IF( EQ_32( env_1, 0 ) || EQ_32( env_2, 0 ) )
+ test();
+ IF( ( env_1 == 0 ) || ( env_2 == 0 ) )
{
duck_gain_out = 0;
+ move32();
}
- else
+ ELSE
{
duck_gain_out = Mpy_32_32( duck_mult_fac, L_shl( (Word32) ( divide3232( env_1, env_2 ) ), Q16 ) );
duck_gain_out = L_shl( duck_gain_out, Q1 );
@@ -565,14 +615,20 @@ void ivas_td_decorr_get_ducking_gains_fx(
const Word16 tdet_flag )
{
Word16 i, q = Q14;
+ move16();
Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k];
Word32 in_duck_gain = hTranDet->in_duck_gain;
+ move32();
Word32 out_duck_gain = hTranDet->out_duck_gain;
+ move32();
Word32 in_duck_coeff = hTranDet->in_duck_coeff;
+ move32();
Word32 out_duck_coeff = hTranDet->out_duck_coeff;
+ move32();
Word32 duck_mult_fac = hTranDet->duck_mult_fac;
+ move32();
- mvl2l( pIn_pcm, e_fast_fx, frame_len );
+ Copy32( pIn_pcm, e_fast_fx, frame_len );
/* env hpf */
ivas_filter_process_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, q );
@@ -582,7 +638,9 @@ void ivas_td_decorr_get_ducking_gains_fx(
FOR( i = 0; i < frame_len; i++ )
{
e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) );
+ move32();
e_slow_fx[i] = e_fast_fx[i];
+ move32();
}
/* env fast*/
@@ -597,8 +655,10 @@ void ivas_td_decorr_get_ducking_gains_fx(
{
in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_fast_fx[i], duck_mult_fac );
pIn_duck_gains[i] = in_duck_gain;
+ move32();
}
hTranDet->in_duck_gain = in_duck_gain;
+ move32();
}
ELSE
{
@@ -606,11 +666,15 @@ void ivas_td_decorr_get_ducking_gains_fx(
{
in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_fast_fx[i], duck_mult_fac );
pIn_duck_gains[i] = in_duck_gain;
+ move32();
out_duck_gain = ivas_calc_duck_gain_fx( out_duck_gain, out_duck_coeff, e_fast_fx[i], e_slow_fx[i], duck_mult_fac );
pOut_duck_gains[i] = out_duck_gain;
+ move32();
}
hTranDet->in_duck_gain = in_duck_gain;
+ move32();
hTranDet->out_duck_gain = out_duck_gain;
+ move32();
}
return;
diff --git a/lib_com/lag_wind.c b/lib_com/lag_wind.c
index e7fe28882f226c80bfe275a1408adbd5dc6c8184..9cd51345a1f09d77c8426c761ed077b86cc44c5f 100644
--- a/lib_com/lag_wind.c
+++ b/lib_com/lag_wind.c
@@ -38,8 +38,7 @@
#include
#include "options.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "cnst.h"
#include "rom_com.h"
#include "wmc_auto.h"
@@ -231,7 +230,7 @@ void lag_wind(
FOR( i = 1; i <= m; i++ )
{
- tmp = Mpy_32( r_h[i], r_l[i], wnd_h[i - 1], wnd_l[i - 1] );
+ tmp = Mpy_32( r_h[i], r_l[i], wnd_h[sub( i, 1 )], wnd_l[sub( i, 1 )] );
L_Extract( tmp, &r_h[i], &r_l[i] );
}
}
@@ -284,7 +283,8 @@ void lag_wind_32(
FOR( i = 1; i <= m; i++ )
{
- r[i] = Mpy_32_32( r[i], wnd[i - 1] );
+ r[i] = Mpy_32_32( r[i], wnd[sub( i, 1 )] );
+ move32();
}
}
diff --git a/lib_com/lerp.c b/lib_com/lerp.c
index ac11a17ce5c82216f899563d3c0bc8b253df2451..80e789c4cac102b2aa5a24d95599d4b71157f5fc 100644
--- a/lib_com/lerp.c
+++ b/lib_com/lerp.c
@@ -37,8 +37,7 @@
#include
#include "options.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
@@ -213,8 +212,6 @@ void lerp( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOl
BASOP_Util_Divide_MantExp( bufferOldSize, 0, bufferNewSize, 0, &tmp2, &tmpexp );
tmp2 = shr( tmp2, 3 ); /*Q12*/
tmp2 = shl( tmp2, tmpexp );
- test();
- test();
IF( GT_16( tmp1, 16224 /*3,9609375 in Q12*/ ) )
{
Word16 tmpNewSize = shl( bufferOldSize, 1 );
@@ -223,16 +220,17 @@ void lerp( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOl
BASOP_Util_Divide_MantExp( bufferNewSize, 0, bufferOldSize, 0, &tmp1, &tmpexp );
tmp1 = shr( tmp1, 3 ); /*Q12*/
tmp1 = shl( tmp1, tmpexp );
- test();
- IF( LE_16( tmp1, 16224 /*3,9609375 in Q12*/ ) )
+ if ( LE_16( tmp1, 16224 /*3,9609375 in Q12*/ ) )
{
tmpNewSize = bufferNewSize;
+ move16();
}
lerp_proc( f, f_out, tmpNewSize, bufferOldSize );
f = f_out;
bufferOldSize = tmpNewSize;
+ move16();
tmpNewSize = shl( tmpNewSize, 1 );
}
}
@@ -244,20 +242,22 @@ void lerp( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOl
BASOP_Util_Divide_MantExp( bufferOldSize, 0, bufferNewSize, 0, &tmp2, &tmpexp );
tmp2 = shr( tmp2, 3 ); /*Q12*/
tmp2 = shl( tmp2, tmpexp );
- test();
- IF( LE_16( tmp2, 16224 /*3,9609375 in Q12*/ ) )
+
+ if ( LE_16( tmp2, 16224 /*3,9609375 in Q12*/ ) )
{
tmpNewSize = bufferNewSize;
+ move16();
}
lerp_proc( f, f_out, tmpNewSize, bufferOldSize );
f = f_out;
bufferOldSize = tmpNewSize;
+ move16();
tmpNewSize = shr( tmpNewSize, 1 );
}
}
- else
+ ELSE
{
lerp_proc( f, f_out, bufferNewSize, bufferOldSize );
}
@@ -283,7 +283,6 @@ static void lerp_proc( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Wor
if ( ( ( f <= f_out ) && ( f + bufferOldSize >= f_out ) ) || ( ( f_out <= f ) && ( f_out + bufferNewSize >= f ) ) )
{
ptr = buf;
- move16();
}
IF( EQ_16( bufferNewSize, bufferOldSize ) )
@@ -396,10 +395,9 @@ static void lerp_proc32( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16
test();
test();
test();
- IF( ( ( f <= f_out ) && ( f + bufferOldSize >= f_out ) ) || ( ( f_out <= f ) && ( f_out + bufferNewSize >= f ) ) )
+ if ( ( ( f <= f_out ) && ( f + bufferOldSize >= f_out ) ) || ( ( f_out <= f ) && ( f_out + bufferNewSize >= f ) ) )
{
ptr = buf;
- move16();
}
IF( EQ_16( bufferNewSize, bufferOldSize ) )
@@ -408,7 +406,7 @@ static void lerp_proc32( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16
return;
}
- shift = L_shl( L_deposit_l( div_s( bufferOldSize, shl( bufferNewSize, 4 ) ) ), 4 - shift_e + 16 );
+ shift = L_shl( L_deposit_l( div_s( bufferOldSize, shl( bufferNewSize, 4 ) ) ), add( sub( 4, shift_e ), Q16 ) );
pos = L_sub( L_shr( shift, 1 ), 32768l /*1.0f Q15*/ );
@@ -426,16 +424,16 @@ static void lerp_proc32( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16
diff = shr( extract_l( pos ), 1 );
/*buf[0]=f[0]+pos*(f[1]-f[0]);*/
- move16();
*ptr++ = L_add_sat( f[0], Mpy_32_16_1( L_sub( f[1], f[0] ), diff ) );
+ move32();
}
ELSE
{
idx = extract_h( pos );
diff = lshr( extract_l( pos ), 1 );
- move16();
- *ptr++ = L_add_sat( f[idx], Mpy_32_16_1( L_sub( f[idx + 1], f[idx] ), diff ) );
+ *ptr++ = L_add_sat( f[idx], Mpy_32_16_1( L_sub( f[add( idx, 1 )], f[idx] ), diff ) );
+ move32();
}
pos = L_add( pos, shift );
@@ -445,19 +443,19 @@ static void lerp_proc32( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16
FOR( i = 1; i < n; i++ )
{
diff = lshr( extract_l( pos ), 1 );
- IF( LT_32( pos, 0 ) )
+ if ( pos < 0 )
{
diff = sub( 16384 /*0.5f Q15*/, diff );
}
- move16();
*ptr++ = L_add_sat( f[idx], Mpy_32_16_1( L_sub( f[idx + 1], f[idx] ), diff ) );
+ move32();
pos = L_add( pos, shift );
idx = extract_h( pos );
}
/* last point */
- IF( GT_32( pos, L_deposit_h( sub( bufferOldSize, 1 ) ) ) )
+ if ( GT_32( pos, L_deposit_h( sub( bufferOldSize, 1 ) ) ) )
{
idx = sub( bufferOldSize, 2 );
}
@@ -466,8 +464,8 @@ static void lerp_proc32( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16
/* diff = t - point;*/
diff = lshr( extract_l( L_shr( L_sub( pos, L_deposit_h( idx ) ), 1 ) ), 1 );
- move16();
- *ptr++ = L_add_sat( f[idx], L_shl_sat( Mpy_32_16_1( L_sub( f[idx + 1], f[idx] ), diff ), 1 ) );
+ *ptr++ = L_add_sat( f[idx], L_shl_sat( Mpy_32_16_1( L_sub( f[add( idx, 1 )], f[idx] ), diff ), 1 ) );
+ move32();
test();
test();
test();
@@ -489,50 +487,63 @@ static void L_lerp_proc_fx( const Word32 *f_fx, Word32 *f_out_fx, const Word16 b
void L_lerp_fx( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 bufferOldSize, Word16 *q )
{
Word16 tmpNewSize;
- Word16 guard_bits = s_max( find_guarded_bits_fx( bufferNewSize / bufferOldSize ), find_guarded_bits_fx( bufferOldSize / bufferNewSize ) ) + 1;
- IF( getScaleFactor32( f, bufferOldSize ) < guard_bits )
+ Word16 tmp1, tmp2, tmp_e;
+ tmp1 = BASOP_Util_Divide1616_Scale( bufferNewSize, bufferOldSize, &tmp_e );
+ tmp1 = shr( tmp1, sub( 15, tmp_e ) );
+
+ tmp2 = BASOP_Util_Divide1616_Scale( bufferOldSize, bufferNewSize, &tmp_e );
+ tmp2 = shr( tmp2, sub( 15, tmp_e ) );
+ Word16 guard_bits = add( s_max( tmp1, tmp2 ), 1 );
+ IF( LT_16( getScaleFactor32( f, bufferOldSize ), guard_bits ) )
{
- *q -= guard_bits;
+ *q = sub( *q, guard_bits );
FOR( Word16 ind = 0; ind < bufferNewSize; ind++ )
- f[ind] = L_shr( f[ind], guard_bits );
+ {
+ f[ind] = L_shr( f[ind], guard_bits );
+ move32();
+ }
#ifndef MSAN_FIX
FOR( Word16 ind = 0; ind < bufferNewSize; ind++ )
f_out[ind] = L_shr( f_out[ind], guard_bits );
#endif
}
- IF( 128 * bufferNewSize > bufferOldSize * 507 )
+ IF( GT_32( L_mult0( 128, bufferNewSize ), L_mult0( bufferOldSize, 507 ) ) )
{
- tmpNewSize = bufferOldSize * 2;
- WHILE( bufferNewSize > bufferOldSize )
+ tmpNewSize = shl( bufferOldSize, 1 );
+ WHILE( GT_16( bufferNewSize, bufferOldSize ) )
{
- IF( 128 * bufferNewSize <= 507 * bufferOldSize )
+ if ( LE_32( L_mult0( 128, bufferNewSize ), L_mult0( bufferOldSize, 507 ) ) )
{
tmpNewSize = bufferNewSize;
+ move16();
}
L_lerp_proc_fx( f, f_out, tmpNewSize, bufferOldSize );
f = f_out;
bufferOldSize = tmpNewSize;
- tmpNewSize *= 2;
+ move16();
+ tmpNewSize = shl( tmpNewSize, 1 );
}
}
- ELSE IF( 128 * bufferOldSize > bufferNewSize * 507 )
+ ELSE IF( GT_32( L_mult0( 128, bufferOldSize ), L_mult0( bufferNewSize, 507 ) ) )
{
- tmpNewSize = bufferOldSize / 2;
- WHILE( bufferNewSize < bufferOldSize )
+ tmpNewSize = shr( bufferOldSize, 1 );
+ WHILE( LT_16( bufferNewSize, bufferOldSize ) )
{
- IF( 128 * bufferOldSize <= 507 * bufferNewSize )
+ if ( LE_32( L_mult0( 128, bufferOldSize ), L_mult0( bufferNewSize, 507 ) ) )
{
tmpNewSize = bufferNewSize;
+ move16();
}
L_lerp_proc_fx( f, f_out, tmpNewSize, bufferOldSize );
f = f_out;
bufferOldSize = tmpNewSize;
- tmpNewSize /= 2;
+ move16();
+ tmpNewSize = shr( tmpNewSize, 1 );
}
}
ELSE
@@ -546,38 +557,42 @@ void L_lerp_fx_q11( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 buffe
{
Word16 tmpNewSize;
- IF( 128 * bufferNewSize > bufferOldSize * 507 )
+ IF( GT_32( L_mult0( 128, bufferNewSize ), L_mult0( bufferOldSize, 507 ) ) )
{
- tmpNewSize = bufferOldSize * 2;
- WHILE( bufferNewSize > bufferOldSize )
+ tmpNewSize = shl( bufferOldSize, 1 );
+ WHILE( GT_16( bufferNewSize, bufferOldSize ) )
{
- IF( 128 * bufferNewSize <= 507 * bufferOldSize )
+ if ( LE_32( L_mult0( 128, bufferNewSize ), L_mult0( bufferOldSize, 507 ) ) )
{
tmpNewSize = bufferNewSize;
+ move16();
}
lerp_proc32( f, f_out, tmpNewSize, bufferOldSize );
f = f_out;
bufferOldSize = tmpNewSize;
- tmpNewSize *= 2;
+ move16();
+ tmpNewSize = shl( tmpNewSize, 1 );
}
}
- ELSE IF( 128 * bufferOldSize > bufferNewSize * 507 )
+ ELSE IF( GT_32( L_mult0( 128, bufferOldSize ), L_mult0( bufferNewSize, 507 ) ) )
{
- tmpNewSize = bufferOldSize / 2;
- WHILE( bufferNewSize < bufferOldSize )
+ tmpNewSize = shr( bufferOldSize, 1 );
+ WHILE( LT_16( bufferNewSize, bufferOldSize ) )
{
- IF( 128 * bufferOldSize <= 507 * bufferNewSize )
+ if ( LE_32( L_mult0( 128, bufferOldSize ), L_mult0( bufferNewSize, 507 ) ) )
{
tmpNewSize = bufferNewSize;
+ move16();
}
lerp_proc32( f, f_out, tmpNewSize, bufferOldSize );
f = f_out;
bufferOldSize = tmpNewSize;
- tmpNewSize /= 2;
+ move16();
+ tmpNewSize = shr( tmpNewSize, 1 );
}
}
ELSE
@@ -604,7 +619,7 @@ static void L_lerp_proc_fx(
Word32 buf_fx[2 * L_FRAME_MAX];
Word16 tmp;
- IF( bufferNewSize == bufferOldSize )
+ IF( EQ_16( bufferNewSize, bufferOldSize ) )
{
Copy32( f_fx, buf_fx, bufferNewSize );
Copy32( buf_fx, f_out_fx, bufferNewSize );
@@ -616,7 +631,7 @@ static void L_lerp_proc_fx(
shift_fx = L_shl( L_deposit_l( tmp ), 4 - 15 + 21 ); // q =21
pos_fx = Mpy_32_32( L_sub( shift_fx, 1 << 21 ), 1073741824 );
- IF( shift_fx < L_shr( 644245094, 31 - 21 ) )
+ IF( LT_32( shift_fx, L_shr( 644245094, 31 - 21 ) ) )
{
pos_fx = L_sub( pos_fx, L_shr( 279172874, 31 - 21 ) );
}
@@ -625,37 +640,41 @@ static void L_lerp_proc_fx(
IF( pos_fx < 0 )
{
buf_fx[0] = L_add( f_fx[0], L_shl( Mpy_32_32( pos_fx, L_sub( f_fx[1], f_fx[0] ) ), 31 - 21 ) );
+ move32();
}
ELSE
{
- idx = (Word16) L_shr( pos_fx, 21 );
+ idx = extract_l( L_shr( pos_fx, 21 ) );
diff_fx = L_sub( pos_fx, L_shl( idx, 21 ) );
- buf_fx[0] = L_add( f_fx[idx], L_shl( Mpy_32_32( diff_fx, L_sub( f_fx[idx + 1], f_fx[idx] ) ), 31 - 21 ) );
+ buf_fx[0] = L_add( f_fx[idx], L_shl( Mpy_32_32( diff_fx, L_sub( f_fx[add( idx, 1 )], f_fx[idx] ) ), 31 - 21 ) );
+ move32();
}
pos_fx = L_add( pos_fx, shift_fx );
FOR( i = 1; i < bufferNewSize - 1; i++ )
{
- idx = (Word16) L_shr( pos_fx, 21 );
- diff_fx = pos_fx - L_shl( idx, 21 );
+ idx = extract_l( L_shr( pos_fx, 21 ) );
+ diff_fx = L_sub( pos_fx, L_shl( idx, 21 ) );
buf_fx[i] = L_add( f_fx[idx], L_shl( Mpy_32_32( diff_fx, L_sub( f_fx[idx + 1], f_fx[idx] ) ), 31 - 21 ) );
+ move32();
pos_fx = L_add( pos_fx, shift_fx );
}
/* last point */
- idx = (Word16) L_shr( pos_fx, 21 );
+ idx = extract_l( L_shr( pos_fx, 21 ) );
- IF( pos_fx > L_shl( bufferOldSize - 1, 21 ) )
+ if ( GT_32( pos_fx, L_shl( sub( bufferOldSize, 1 ), 21 ) ) )
{
- idx = bufferOldSize - 2;
+ idx = sub( bufferOldSize, 2 );
}
- diff_fx = pos_fx - L_shl( idx, 21 );
+ diff_fx = L_sub( pos_fx, L_shl( idx, 21 ) );
- buf_fx[bufferNewSize - 1] = L_add( f_fx[idx], L_shl( Mpy_32_32( diff_fx, L_sub( f_fx[idx + 1], f_fx[idx] ) ), 31 - 21 ) );
+ buf_fx[sub( bufferNewSize, 1 )] = L_add( f_fx[idx], L_shl( Mpy_32_32( diff_fx, L_sub( f_fx[add( idx, 1 )], f_fx[idx] ) ), 31 - 21 ) );
+ move32();
Copy32( buf_fx, f_out_fx, bufferNewSize );
diff --git a/lib_com/limit_t0_fx.c b/lib_com/limit_t0_fx.c
index 97aa4fd8fdfea28183d1b6f04b73e26638cb3285..6573a7925e67489aedcc548a2a4ace59b060e66b 100644
--- a/lib_com/limit_t0_fx.c
+++ b/lib_com/limit_t0_fx.c
@@ -3,10 +3,9 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h"
diff --git a/lib_com/log2.c b/lib_com/log2.c
index 739dd8e5eeaaa53bf0585eb0cd29bdb4ec3e254b..4e70862d1097ec3b12b6baf4ab0bc0c368dcbbe0 100644
--- a/lib_com/log2.c
+++ b/lib_com/log2.c
@@ -87,7 +87,9 @@ Word32 log10_fx( Word32 Linput )
frac = extract_l( Ltemp2 );
p1 = log2_tab[sub( extract_h( Ltemp2 ), 0x20 )];
+ move16();
p2 = log2_tab[sub( extract_h( Ltemp2 ), 0x1F )];
+ move16();
Ltemp2 = L_mult( n1, 0x200 );
n1 = extract_l( Ltemp2 );
@@ -124,10 +126,10 @@ Word32 pow_10( Word32 x, Word16 *Q )
Word16 count = 0;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
move16();
- ;
xl = extract_l( x );
xh = extract_h( x );
@@ -193,7 +195,7 @@ Word32 pow_10( Word32 x, Word16 *Q )
#else
L_tmp = L_shl( L_tmp, i );
#endif
- IF( Overflow )
+ if ( Overflow )
{
count = add( count, 1 );
}
diff --git a/lib_com/logqnorm_fx.c b/lib_com/logqnorm_fx.c
index 678517ae23f00494e2d48f03ea6a02ea72fc6932..fbbf2a464eb2bfcd1f18fcf59b8d327d66fdf2b0 100644
--- a/lib_com/logqnorm_fx.c
+++ b/lib_com/logqnorm_fx.c
@@ -31,10 +31,10 @@
*******************************************************************************************************/
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
-#include "cnst.h" /* Common constants */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
+#include "cnst.h" /* Common constants */
/*--------------------------------------------------------------------------*
* Local constants
@@ -66,6 +66,7 @@ void logqnorm_fx(
Word16 offset = add( 3, shl( qx, 1 ) ); /* 3 + 2*qx */
lsb = 0U; /* to avoid compilation warnings */
+ move16();
L_temp1 = L_deposit_l( 1 );
FOR( i = 0; i < N; i++ )
@@ -79,6 +80,7 @@ void logqnorm_fx(
FOR( i = 0; i < N; i++ )
{
coefs16[i] = extract_h( L_shl( L_x[i], coefs_shift ) );
+ move16();
L_temp = L_mac0( L_temp, coefs16[i], coefs16[i] );
}
@@ -95,14 +97,14 @@ void logqnorm_fx(
m = add( offset, m );
test();
- IF( m < 5 && hvq_flag )
+ IF( LT_16( m, 5 ) && hvq_flag )
{
m = shl( m, 1 );
IF( LT_32( L_temp1, 1276901417L /* 2^0.25 Q30 */ ) )
{
m = add( m, 2 );
}
- ELSE if ( LT_32( L_temp1, 1805811301L /* 2^0.75 Q30 */ ) )
+ ELSE IF( LT_32( L_temp1, 1805811301L /* 2^0.75 Q30 */ ) )
{
m = add( m, 1 );
}
@@ -119,8 +121,10 @@ void logqnorm_fx(
}
}
*k = s_max( m, 0 );
+ move16();
i = sub( L, 1 );
*k = s_min( *k, i );
+ move16();
return;
}
@@ -149,6 +153,7 @@ void logqnorm_2_fx(
ELSE IF( GT_32( thren[sub( L, 2 )], temp ) )
{
*ynrm = sub( L, 1 );
+ move16();
}
ELSE
{
diff --git a/lib_com/longarith.c b/lib_com/longarith.c
index 2617034d9c7a3887b3e9db84f60a0e2970345caa..65070f093f6bec177b9f5ce288efbb94772e7ce8 100644
--- a/lib_com/longarith.c
+++ b/lib_com/longarith.c
@@ -41,7 +41,7 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif
diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c
index 0df80752308ac8d3d1571f1bfc45c481e4c1375c..f593089b16c4dbd14760862f244b4751f6824021 100644
--- a/lib_com/low_rate_band_att_fx.c
+++ b/lib_com/low_rate_band_att_fx.c
@@ -5,8 +5,7 @@
#include
#include "options.h" /* Compilation switches */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
@@ -46,6 +45,7 @@ void ivas_fine_gain_pred_fx(
UWord16 lsb;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move16();
#endif
FOR( band = 0; band < num_sfm; band++ )
@@ -53,7 +53,7 @@ void ivas_fine_gain_pred_fx(
k = K[i_sort[band]];
move16();
- IF( GT_16( k, 0 ) )
+ IF( k > 0 )
{
/* bw, bw_idx only used if k>0 */
bw = sfm_size[i_sort[band]];
@@ -63,6 +63,7 @@ void ivas_fine_gain_pred_fx(
move16(); /* bw_idx= 0: 8 */
xx = L_deposit_l( 0 );
shift = ivas_band_len_ener_shift[bw_idx];
+ move16();
FOR( i = sfm_start[i_sort[band]]; i < sfm_end[i_sort[band]]; i++ )
{
/*xx += xq[i] * xq[i]; */
@@ -70,7 +71,7 @@ void ivas_fine_gain_pred_fx(
xx = L_mac0( xx, tmp, tmp ); /*30-2*shift */
}
- IF( GT_32( xx, 0 ) )
+ IF( xx > 0 )
{
/* Normalize synthesis to RMS=1.0 */
/*gp = (float) sqrt(bw / xx); */
@@ -163,6 +164,7 @@ void fine_gain_pred_fx(
UWord16 lsb;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
FOR( band = 0; band < num_sfm; band++ )
@@ -322,12 +324,14 @@ void fine_gain_dec_fx(
FOR( band = 0; band < num_sfm; band++ )
{
gbits = gain_bits[ord[band]];
+ move16();
IF( gbits > 0 )
{
IF( fg_pred[band] != 0 )
{
idx = get_next_indice( st, gbits );
gain_dbq = finegain_fx[gbits - 1][idx];
+ move16();
/* Update predicted gain with quantized correction */
L_tmp = L_mult0( gain_dbq, 21771 ); /* 21771=0.05*log2(10) */ /* 14+17=31 */
@@ -339,6 +343,7 @@ void fine_gain_dec_fx(
L_tmp = L_mult0( fg_pred[band], tmp1 ); /*12+exp1 */
fg_pred[band] = round_fx_sat( L_shl_sat( L_tmp, sub( 16, exp1 ) ) ); /*12+exp1+16-exp1-16=12 */
+ move16();
}
}
}
diff --git a/lib_com/lpc_tools.c b/lib_com/lpc_tools.c
index bcf0a5d9a9c891b71dd7d33c62c5e37e88aaae4a..ff6dfea48adcedcbb8899a9a1b0ad6f853f25c10 100644
--- a/lib_com/lpc_tools.c
+++ b/lib_com/lpc_tools.c
@@ -42,7 +42,7 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-----------------------------------------------------------------*
* Local constants
@@ -207,12 +207,16 @@ Word16 lev_dur_fx(
Word16 *rc_fx; /* reflection coefficients 0,...,m-1 */
Word32 at;
Word32 s, err;
- Word16 flag = 0;
+ Word16 flag = 0, tmp16;
+ move16();
rc_fx = &buf_fx[0];
rc_fx[0] = divide3232( L_negate( r_fx[1] ), r_fx[0] ); // Q(31)
+ move16();
a_fx[0] = L_shl( 1, q_a );
+ move32();
a_fx[1] = L_shl( rc_fx[0], sub( q_a, 15 ) );
+ move32();
err = L_add( r_fx[0], Mpy_32_16_1( r_fx[1], rc_fx[0] ) ); // Q(q_r)
IF( epsP != NULL )
{
@@ -225,36 +229,42 @@ Word16 lev_dur_fx(
FOR( i = 2; i <= m; i++ )
{
s = 0; // Q(q_a + q_r - 31)
+ move32();
FOR( j = 0; j < i; j++ )
{
s = L_add( s, Mpy_32_32( r_fx[i - j], a_fx[j] ) );
}
rc_fx[i - 1] = divide3232( L_negate( s ), L_shr( err, sub( 31, q_a ) ) );
+ move16();
- IF( abs_s( rc_fx[i - 1] ) > 32749 ) // 32749 = 0.99945 in Q15
+ if ( GT_16( abs_s( rc_fx[i - 1] ), 32749 ) ) // 32749 = 0.99945 in Q15
{
flag = 1; /* Test for unstable filter. If unstable keep old A(z) */
+ move16();
}
- FOR( j = 1; j <= shr( i, 1 ); j++ )
+ tmp16 = shr( i, 1 );
+ FOR( j = 1; j <= tmp16; j++ )
{
l = sub( i, j );
at = L_add( a_fx[j], Mpy_32_16_1( a_fx[l], rc_fx[i - 1] ) ); // Q(q_a)
a_fx[l] = L_add( a_fx[l], Mpy_32_16_1( a_fx[j], rc_fx[i - 1] ) );
+ move32();
a_fx[j] = at;
move32();
}
a_fx[i] = L_shl( rc_fx[i - 1], sub( q_a, 15 ) );
+ move32();
err = L_add( err, L_shl( Mpy_32_16_1( s, rc_fx[i - 1] ), sub( 31, q_a ) ) ); // q_err - q_s
- IF( LE_32( err, 0 ) )
+ IF( err <= 0 )
{
- err = L_shr( 327, 31 - q_r ); // 327 = 0.01 in Q15
+ err = L_shr( 327, sub( 31, q_r ) ); // 327 = 0.01 in Q15
}
- IF( epsP != NULL )
+ if ( epsP != NULL )
{
epsP[i] = err;
move32();
diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c
index c5849e930cd23129ed9f46f245cf2f79187a5eba..d4c01f46c0108504026973ebc7a6a048f748c6b7 100644
--- a/lib_com/lpc_tools_fx.c
+++ b/lib_com/lpc_tools_fx.c
@@ -38,7 +38,7 @@
#include
#include "options.h" /* Compilation switches */
#include "ivas_cnst.h" /* Common constants */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h"
#include "basop_util.h"
@@ -168,7 +168,7 @@ void autocorr_fx(
void autocorr_fx_32(
const Word16 x[], /* i : Input signal */
const Word16 m, /* i : LPC order Q0 */
- Word32 r[], /* o : Autocorrelations (msb) */
+ Word32 r[], /* o : Autocorrelations */
Word16 *Q_r, /* o : normalisation shift of r Q0 */
const Word16 len, /* i : Frame lenght */
const Word16 *wind, /* i : Window used */
@@ -179,27 +179,29 @@ void autocorr_fx_32(
Word16 i, j, norm, shift, y[MAX_LEN_LP];
Word16 fact;
Word32 L_sum, L_tmp;
+ Word16 tmp16;
IF( EQ_16( rev_flag, 1 ) )
{
/* Windowing of signal */
FOR( i = 0; i < len; i++ )
{
- y[i] = mult_r( x[i], wind[len - i - 1] );
+ y[i] = mult_r( x[i], wind[sub( sub( len, i ), 1 )] );
move16();
}
}
ELSE IF( EQ_16( sym_flag, 1 ) )
{
/* symmetric window of even length */
- FOR( i = 0; i < len / 2; i++ )
+ tmp16 = shr( len, 1 );
+ FOR( i = 0; i < tmp16; i++ )
{
y[i] = mult_r( x[i], wind[i] );
move16();
}
FOR( ; i < len; i++ )
{
- y[i] = mult_r( x[i], wind[len - i - 1] );
+ y[i] = mult_r( x[i], wind[sub( sub( len, i ), 1 )] );
move16();
}
}
@@ -258,7 +260,8 @@ void autocorr_fx_32(
FOR( i = 1; i <= m; i++ )
{
L_sum = L_mult( y[0], y[i] );
- FOR( j = 1; j < len - i; j++ )
+ tmp16 = sub( len, i );
+ FOR( j = 1; j < tmp16; j++ )
{
L_sum = L_mac( L_sum, y[j], y[j + i] );
}
@@ -479,6 +482,7 @@ Word16 E_LPC_lev_dur_stab( const Word16 Rh[], const Word16 Rl[], Word16 A[], Wor
flag = 1;
move16(); /* Test for unstable filter. If unstable keep old A(z) */
}
+ test();
if ( ( mem != NULL ) && ( ( LT_32( L_abs( t2 ), 5 ) ) ) )
{
flag = 1;
@@ -555,6 +559,7 @@ Word16 E_LPC_lev_dur_stab( const Word16 Rh[], const Word16 Rl[], Word16 A[], Wor
#else
A[i] = round_fx( L_shl( t0, k ) );
#endif
+ move16();
}
BASOP_SATURATE_WARNING_ON_EVS
@@ -563,11 +568,11 @@ Word16 E_LPC_lev_dur_stab( const Word16 Rh[], const Word16 Rl[], Word16 A[], Wor
/* Enforce stable LPC filter - parcorr[0] and parcorr[1] are not LPC coeffiecients */
IF( flag )
{
- Copy( mem, A, order + 1 );
+ Copy( mem, A, add( order, 1 ) );
}
ELSE /* If stable LPC filter, store into memories */
{
- Copy( A, mem, order + 1 );
+ Copy( A, mem, add( order, 1 ) );
}
}
@@ -592,6 +597,7 @@ Word16 E_LPC_lev_dur_stab_fx( const Word16 Rh[], const Word16 Rl[], Word32 A[],
Word16 Ah[TCXLTP_LTP_ORDER + 1], Al[TCXLTP_LTP_ORDER + 1]; /* LPC coef. in double prec. */
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -693,6 +699,7 @@ Word16 E_LPC_lev_dur_stab_fx( const Word16 Rh[], const Word16 Rl[], Word32 A[],
flag = 1;
move16(); /* Test for unstable filter. If unstable keep old A(z) */
}
+ test();
if ( ( mem != NULL ) && ( ( LT_32( L_abs( t2 ), 5 ) ) ) )
{
flag = 1;
@@ -767,8 +774,9 @@ Word16 E_LPC_lev_dur_stab_fx( const Word16 Rh[], const Word16 Rl[], Word32 A[],
#ifdef BASOP_NOGLOB
A[i] = L_shl_o( t0, k, &Overflow );
#else
- A[i] = L_shl(t0, k));
+ A[i] = L_shl(t0, k));
#endif
+ move16();
}
BASOP_SATURATE_WARNING_ON_EVS
@@ -777,11 +785,11 @@ Word16 E_LPC_lev_dur_stab_fx( const Word16 Rh[], const Word16 Rl[], Word32 A[],
/* Enforce stable LPC filter - parcorr[0] and parcorr[1] are not LPC coeffiecients */
IF( flag )
{
- Copy32( mem, A, order + 1 );
+ Copy32( mem, A, add( order, 1 ) );
}
ELSE /* If stable LPC filter, store into memories */
{
- Copy32( A, mem, order + 1 );
+ Copy32( A, mem, add( order, 1 ) );
}
}
@@ -821,15 +829,17 @@ void E_LPC_a_add_tilt( const Word16 *a, Word16 *ap, Word16 gamma, Word16 m )
}
Atmp[m + 1] = L_negate( L_mult0( gamma, a[m] ) );
move32();
- Amax = L_max( Amax, L_abs( Atmp[m + 1] ) );
+ Amax = L_max( Amax, L_abs( Atmp[add( m, 1 )] ) );
shift = norm_l( Amax );
ap[0] = shl( a[0], sub( shift, 1 ) );
move16();
FOR( i = 1; i <= m; i++ )
{
ap[i] = round_fx( L_shl( Atmp[i], shift ) );
+ move16();
}
- ap[m + 1] = round_fx( L_shl( Atmp[m + 1], shift ) );
+ ap[add( m, 1 )] = round_fx( L_shl( Atmp[add( m, 1 )], shift ) );
+ move16();
}
void E_LPC_int_lpc_tcx( const Word16 lsp_old[], /* input : LSPs from past frame Q15 */
@@ -844,6 +854,7 @@ void E_LPC_int_lpc_tcx( const Word16 lsp_old[], /* input : LSPs from past frame
{
/*lsp[i] = lsp_old[i]*0.125f + lsp_new[i]*0.875f;*/
lsp[i] = round_fx( L_mac( L_mult( lsp_old[i], 4096 ), lsp_new[i], 28672 ) );
+ move16();
}
E_LPC_f_lsp_a_conversion( lsp, a, M );
@@ -940,6 +951,7 @@ Word16 E_LPC_lsp_unweight(
/* Approximate unweighting by 3-tap FIR */
lsp_uw[0] = add( lsp_w_orig[0], round_fx( L_shl( L_mac0( L_mult0( unw_coeffs[0][1], lsp_w_diff[0] ), unw_coeffs[0][2], lsp_w_diff[1] ), 2 ) ) );
+ move16();
FOR( i = 1; i < lpcorder - 1; ++i )
{
lsp_uw[i] = add( lsp_w_orig[i], round_fx( L_shl( L_mac0( L_mac0( L_mult0( unw_coeffs[i][0], lsp_w_diff[i - 1] ), unw_coeffs[i][1], lsp_w_diff[i] ), unw_coeffs[i][2], lsp_w_diff[i + 1] ), 2 ) ) );
@@ -1002,8 +1014,8 @@ Word32 E_LPC_schur( Word32 r[], Word16 reflCoeff[], Word32 epsP[], const Word16
temp16 = negate( divide3232( g0[0], g1[0] ) );
reflCoeff[0] = temp16;
move16();
- move32();
epsP[0] = r[0];
+ move32();
FOR( i = 0; i < mM1; i++ )
@@ -1075,24 +1087,24 @@ static void spec2isf(
Word16 tmp, i;
Word16 specix, lsfix;
- move16();
- move16();
specix = lsfix = 0;
move16();
+ move16();
s = spec_r[specix++];
+ move16();
WHILE( LT_16( specix, speclen ) && LE_16( lsfix, 15 ) )
{
-
+ test();
/*check for next zero crossing*/
/*for (; s*spec_r[specix] >= 0; specix++);*/
WHILE( mult( s, spec_r[specix] ) >= 0 )
specix = add( specix, 1 );
tmp = divide1616( spec_r[specix - 1], sub( spec_r[specix - 1], spec_r[specix] ) );
- move16();
/*lsf[lsfix] = L_add(L_deposit_h(sub(specix,1)) , L_shl(L_deposit_l(tmp),1));*/ /*Q16*/
lsf[lsfix] = add( shl( sub( specix, 1 ), 7 ), shr( ( tmp ), 8 ) ); /*7Q8*/
+ move16();
lsfix++;
@@ -1103,9 +1115,9 @@ static void spec2isf(
specix = add( specix, 1 );
tmp = divide1616( spec_i[specix - 1], sub( spec_i[specix - 1], spec_i[specix] ) );
- move16();
/*lsf[lsfix] = L_add(L_deposit_h(sub(specix,1)) , L_shl(L_deposit_l(tmp),1));*/ /*Q16*/
lsf[lsfix] = add( shl( sub( specix, 1 ), 7 ), shr( ( tmp ), 8 ) ); /*7Q8*/
+ move16();
lsfix++;
@@ -1144,9 +1156,11 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs, Word16 *lsf, const Word16 *o
Word16 s[4];
Word32 L_tmp, L_tmp1, L_tmp3;
Word16 lpc[19];
+ move16();
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* half length FFT */
@@ -1194,8 +1208,11 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs, Word16 *lsf, const Word16 *o
move16();
}
s[0] = shr( s[0], 1 );
+ move16();
s[1] = shr( s[1], 1 );
+ move16();
s[2] = shr( s[2], 1 );
+ move16();
lpc[0] = mult_r( lpcCoeffs[0], s[0] );
move16();
L_tmp = L_mult( s[0], lpcCoeffs[1] );
@@ -1223,9 +1240,12 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs, Word16 *lsf, const Word16 *o
FOR( j = 0; j < 9; j++ )
{
ptrReal[j * 8] = L_shl( L_deposit_h( lpc[2 * j] ), scale );
+ move32();
ptrImag[j * 8] = L_shl( L_deposit_h( lpc[2 * j + 1] ), scale );
+ move32();
}
ptrReal[j * 8] = L_shl( L_deposit_h( lpc[2 * j] ), scale );
+ move32();
ptrImag[j * 8] = 0;
move16();
j++;
@@ -1233,7 +1253,9 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs, Word16 *lsf, const Word16 *o
FOR( ; j < 16; j++ )
{
ptrReal[j * 8] = L_deposit_h( 0 );
+ move32();
ptrImag[j * 8] = L_deposit_h( 0 );
+ move32();
}
fft16( ptrReal, ptrImag, 8, 0 );
@@ -1246,7 +1268,9 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs, Word16 *lsf, const Word16 *o
ptwiddle = w_a[i - 1];
ptrReal[0] = L_shl( L_deposit_h( lpc[0] ), scale );
+ move32();
ptrImag[0] = L_shl( L_deposit_h( lpc[1] ), scale );
+ move32();
FOR( j = 1; j < 9; j++ )
{
@@ -1266,7 +1290,9 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs, Word16 *lsf, const Word16 *o
FOR( ; j < 16; j++ )
{
ptrReal[j * 8] = L_deposit_h( 0 );
+ move32();
ptrImag[j * 8] = L_deposit_h( 0 );
+ move32();
ptwiddle++;
}
@@ -1293,12 +1319,14 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs, Word16 *lsf, const Word16 *o
pwn15i = &tmpw15;
RealOut[0] = round_fx( 2 * L_add( RealFFT[0], ImagFFT[0] ) );
+ move16();
ImagOut[0] = 0;
move16();
RealOut[128] = 0;
move16();
ImagOut[128] = round_fx( L_sub( L_add( RealFFT[0], RealFFT[0] ), L_add( ImagFFT[0], ImagFFT[0] ) ) );
+ move16();
ptwiddle += 8;
FOR( i = 1; i <= N / 2 / 4; i++ )
@@ -1310,7 +1338,9 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs, Word16 *lsf, const Word16 *o
BASOP_SATURATE_WARNING_OFF_EVS
#ifdef BASOP_NOGLOB
tmpw15.v.re = mac_ro( L_mult( ptwiddle->v.re, pwn17->v.re ), ptwiddle->v.im, pwn17->v.im, &Overflow );
+ move16();
tmpw15.v.im = msu_ro( L_mult( ptwiddle->v.re, pwn17->v.im ), ptwiddle->v.im, pwn17->v.re, &Overflow );
+ move16();
#else /* BASOP_NOGLOB */
tmpw15.v.re = mac_r( L_mult( ptwiddle->v.re, pwn17->v.re ), ptwiddle->v.im, pwn17->v.im );
tmpw15.v.im = msu_r( L_mult( ptwiddle->v.re, pwn17->v.im ), ptwiddle->v.im, pwn17->v.re );
@@ -1323,7 +1353,9 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs, Word16 *lsf, const Word16 *o
BASOP_SATURATE_WARNING_OFF_EVS
#ifdef BASOP_NOGLOB
tmpw15.v.re = msu_ro( L_mult( ptwiddle->v.im, pwn17i->v.im ), ptwiddle->v.re, pwn17i->v.re, &Overflow );
+ move16();
tmpw15.v.im = mac_ro( L_mult( ptwiddle->v.re, pwn17i->v.im ), ptwiddle->v.im, pwn17i->v.re, &Overflow );
+ move16();
#else /* BASOP_NOGLOB */
tmpw15.v.re = msu_r( L_mult( ptwiddle->v.im, pwn17i->v.im ), ptwiddle->v.re, pwn17i->v.re );
tmpw15.v.im = mac_r( L_mult( ptwiddle->v.re, pwn17i->v.im ), ptwiddle->v.im, pwn17i->v.re );
@@ -1350,7 +1382,9 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs, Word16 *lsf, const Word16 *o
BASOP_SATURATE_WARNING_OFF_EVS
#ifdef BASOP_NOGLOB
tmpw15.v.re = mac_ro( L_mult( ptwiddle->v.im, pwn17->v.re ), ptwiddle->v.re, pwn17->v.im, &Overflow );
+ move16();
tmpw15.v.im = msu_ro( L_mult( ptwiddle->v.im, pwn17->v.im ), ptwiddle->v.re, pwn17->v.re, &Overflow );
+ move16();
#else /* BASOP_NOGLOB */
tmpw15.v.re = mac_r( L_mult( ptwiddle->v.im, pwn17->v.re ), ptwiddle->v.re, pwn17->v.im );
tmpw15.v.im = msu_r( L_mult( ptwiddle->v.im, pwn17->v.im ), ptwiddle->v.re, pwn17->v.re );
@@ -1363,7 +1397,9 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs, Word16 *lsf, const Word16 *o
BASOP_SATURATE_WARNING_OFF_EVS
#ifdef BASOP_NOGLOB
tmpw15.v.re = msu_ro( L_mult( ptwiddle->v.re, pwn17i->v.im ), ptwiddle->v.im, pwn17i->v.re, &Overflow );
+ move16();
tmpw15.v.im = mac_ro( L_mult( ptwiddle->v.im, pwn17i->v.im ), ptwiddle->v.re, pwn17i->v.re, &Overflow );
+ move16();
#else /* BASOP_NOGLOB */
tmpw15.v.re = msu_r( L_mult( ptwiddle->v.re, pwn17i->v.im ), ptwiddle->v.im, pwn17i->v.re );
tmpw15.v.im = mac_r( L_mult( ptwiddle->v.im, pwn17i->v.im ), ptwiddle->v.re, pwn17i->v.re );
@@ -1387,7 +1423,9 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs, Word16 *lsf, const Word16 *o
BASOP_SATURATE_WARNING_OFF_EVS
#ifdef BASOP_NOGLOB
tmpw15.v.re = mac_r_sat( L_mult( ptwiddle->v.im, pwn17->v.re ), ptwiddle->v.re, pwn17->v.im );
+ move16();
tmpw15.v.im = msu_r_sat( L_mult( ptwiddle->v.im, pwn17->v.im ), ptwiddle->v.re, pwn17->v.re );
+ move16();
#else
tmpw15.v.re = mac_r( L_mult( ptwiddle->v.im, pwn17->v.re ), ptwiddle->v.re, pwn17->v.im );
tmpw15.v.im = msu_r( L_mult( ptwiddle->v.im, pwn17->v.im ), ptwiddle->v.re, pwn17->v.re );
diff --git a/lib_com/lsf_dec_bfi_fx.c b/lib_com/lsf_dec_bfi_fx.c
index 147c40846fd29fb6961663db5a84a5e258eb5d75..14b842115cd75cafc4fee5c9675d5c3ee66e189b 100644
--- a/lib_com/lsf_dec_bfi_fx.c
+++ b/lib_com/lsf_dec_bfi_fx.c
@@ -8,8 +8,7 @@
#include "basop_util.h"
#include "rom_com.h"
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*---------------------------------------------------------------------*
@@ -65,7 +64,7 @@ void lsf_dec_bfi(
{
pt_meansForFading = GEWB_Ave_fx;
- if ( EQ_16( bwidth, NB ) )
+ if ( bwidth == NB )
{
pt_meansForFading = GENB_Ave_fx;
}
@@ -206,18 +205,22 @@ ELSE IF( tcxonly != 0 )
IF( EQ_16( L_frame, 320 ) )
{
gap = 143;
+ move16();
}
ELSE IF( EQ_16( L_frame, 512 ) )
{
gap = 90;
+ move16();
}
ELSE IF( EQ_16( L_frame, 640 ) )
{
gap = 72;
+ move16();
}
ELSE
{
gap = 48;
+ move16();
}
reorder_lsf_fx( lsf, gap, M, INT_FS_FX );
}
diff --git a/lib_com/lsf_msvq_ma_fx.c b/lib_com/lsf_msvq_ma_fx.c
index 179e644b6c0d85dbb30f82c7944a9302f4038e1b..409566ddcc351bd7ab99b75eebebeac74cd707c1 100644
--- a/lib_com/lsf_msvq_ma_fx.c
+++ b/lib_com/lsf_msvq_ma_fx.c
@@ -6,8 +6,7 @@
#include "cnst.h"
#include "options.h"
#include "rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#ifndef swap
@@ -38,8 +37,8 @@ void midlsf_dec(
Word16 j;
Word32 L_tmp;
Word16 bad_spacing = 0;
-
move16();
+
/* Select codebook */
IF( EQ_16( coder_type, UNVOICED ) )
{
@@ -54,6 +53,7 @@ void midlsf_dec(
L_tmp = L_mult( sub( 0x2000, ratio[idx * M + j] ), qlsf0[j] ); /*Q(x2.56+13+1)->Q(x2.56+14)*/
L_tmp = L_mac( L_tmp, ratio[idx * M + j], qlsf1[j] ); /*Q(x2.56+14)*/
qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); /*Q(x2.56)*/
+ move16();
}
diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c
index 127cee7e95bb00f6efc7b5629ac6af7b0e63dba7..ddce7c19914bfb70759d3366d1443d750a205aa8 100644
--- a/lib_com/lsf_tools.c
+++ b/lib_com/lsf_tools.c
@@ -44,8 +44,7 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif
/*-------------------------------------------------------------------*
@@ -1616,37 +1615,6 @@ void lsp2lsf(
return;
}
-#ifdef IVAS_FLOAT_FIXED
-/*-----------------------------------------------------------------------*
- * lsf2lsp_32_fx()
- *
- * Transformation of LSFs to LSPs
- *
- * LSP are line spectral pairs in cosine domain (-1 to 1).
- * LSF are line spectral frequencies (0 to fs/2).
- *-----------------------------------------------------------------------*/
-
-void lsf2lsp_32_fx(
- const Word32 lsf_fx[], /* i : isf[m] normalized (range: 0<=val<=fs/2) */
- Word16 lsf_q_fx,
- Word16 lsp_fx[], /* o : isp[m] (range: -1<=val<1) */
- Word16 *lsp_q_fx,
- const Word16 m, /* i : LPC order */
- const Word32 Fs /* i : sampling frequency */
-)
-{
- Word16 i;
-
- /* convert LSFs to LSPs */
- FOR( i = 0; i < m; i++ )
- {
- lsp_fx[i] = getCosWord16R2( div_l( L_shr( lsf_fx[i], lsf_q_fx - 13 ), div_l( Fs, shl( 2, 1 ) ) ) );
- }
- *lsp_q_fx = 15;
- return;
-}
-#endif
-
/*-----------------------------------------------------------------------*
* lsf2lsp()
*
@@ -2101,7 +2069,6 @@ void dec_FDCNG_MSVQ_stage1(
}
#ifdef IVAS_FLOAT_FIXED
-
void dec_FDCNG_MSVQ_stage1_fx(
Word16 j_full, /* i : index full range */
Word16 n, /* i : dimension to generate */
@@ -2111,7 +2078,7 @@ void dec_FDCNG_MSVQ_stage1_fx(
Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */
)
{
- Word16 col, segm_ind, j;
+ Word16 col, segm_ind, j, i;
Word32 dct_vec[FDCNG_VQ_MAX_LEN];
const Word8 *cbpW8;
const Word16 *dct_col_shift_tab;
@@ -2121,15 +2088,16 @@ void dec_FDCNG_MSVQ_stage1_fx(
assert( n >= FDCNG_VQ_DCT_MINTRUNC );
segm_ind = 0;
- for ( col = 1; col <= FDCNG_VQ_DCT_NSEGM; col++ )
+ move16();
+ FOR( col = 1; col <= FDCNG_VQ_DCT_NSEGM; col++ )
{
- if ( j_full >= cdk1_ivas_cum_entries_per_segment[col] )
+ if ( GE_16( j_full, cdk1_ivas_cum_entries_per_segment[col] ) )
{
- segm_ind++;
+ segm_ind = add( segm_ind, 1 );
}
}
- j = j_full - cdk1_ivas_cum_entries_per_segment[segm_ind]; /* j is the local segment index */
+ j = sub( j_full, cdk1_ivas_cum_entries_per_segment[segm_ind] ); /* j is the local segment index */
/* Word8 column variable Qx storage*/
@@ -2137,9 +2105,10 @@ void dec_FDCNG_MSVQ_stage1_fx(
cbpW8 += j * cdk1_ivas_cols_per_segment[segm_ind]; /* adaptive ptr init */
dct_col_shift_tab = stage1_dct_col_syn_shift[segm_ind];
- for ( col = 0; col < cdk1_ivas_cols_per_segment[segm_ind]; col++ )
+ FOR( col = 0; col < cdk1_ivas_cols_per_segment[segm_ind]; col++ )
{
- dct_vec[col] = shl( (Word16) cbpW8[col], dct_col_shift_tab[col] );
+ dct_vec[col] = shl( cbpW8[col], dct_col_shift_tab[col] );
+ move32();
/* LOGIC( 1 ) , SHIFT( 1 );
in BASOP: s_and(for W8->W16), shl()
*/
@@ -2147,10 +2116,12 @@ void dec_FDCNG_MSVQ_stage1_fx(
assert( j < cdk1_ivas_entries_per_segment[segm_ind] );
Word16 norm = 20;
+ move16();
- for ( int i = 0; i < cdk1_ivas_cols_per_segment[segm_ind]; i++ )
+ FOR( i = 0; i < cdk1_ivas_cols_per_segment[segm_ind]; i++ )
{
dct_vec_fx[i] = L_shl( dct_vec[i], norm );
+ move32();
}
dctT2_N_apply_matrix_fx( (const Word32 *) dct_vec_fx, idct_vec_fx, cdk1_ivas_cols_per_segment[segm_ind], n, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, idcttype );
@@ -2159,14 +2130,20 @@ void dec_FDCNG_MSVQ_stage1_fx(
/*scale down to original fdcngvq domain and move to Q0 */
/* fdcng_dct_scaleF[1] --> Q15 conversion --> 860 */
// v_multc_att32( idct_vec_fx, 860, idct_vec_fx, n );
- for ( int i = 0; i < n; i++ )
+ FOR( i = 0; i < n; i++ )
+ {
idct_vec_fx[i] = Mpy_32_32( idct_vec_fx[i], 56410112 ); /* norm + 31 - 31 = norm*/
+ move32();
+ }
/* fdcng_dct_scaleF[1] --> 0.0625-->scale down from search Q4 domain to Q0 ,
not really relevant for BASOP loop */
/*add common mid fdcng vector, in fdcng bands domain */
- for ( int i = 0; i < n; i++ )
- uq[i] = L_add( idct_vec_fx[i], L_lshl( cdk1r_tr_midQ_truncQ_fx[i], norm - 10 ) ); // making the Q factors equal
+ FOR( i = 0; i < n; i++ )
+ {
+ uq[i] = L_add( idct_vec_fx[i], L_lshl( cdk1r_tr_midQ_truncQ_fx[i], sub( norm, Q10 ) ) ); // making the Q factors equal
+ move32();
+ }
assert( uq_ind == NULL );
return;
@@ -2255,7 +2232,6 @@ void msvq_dec_float(
}
#ifdef IVAS_FLOAT_FIXED
-
void msvq_dec_fx(
const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */
const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
@@ -2270,20 +2246,24 @@ void msvq_dec_fx(
Word16 *uq_ind, /* o : quantized vector (fixed point) */
Word16 exp )
{
- Word16 i, n, maxn, start;
+ Word16 i, n, maxn, start, k;
Word16 j, max_size = 0;
+ move16();
FOR( i = 0; i < stages; i++ )
{
IF( dims )
{
- IF( max_size < dims[i] )
- max_size = dims[i];
+ if ( LT_16( max_size, dims[i] ) )
+ {
+ max_size = dims[i];
+ move16();
+ }
}
-
ELSE
{
max_size = N;
+ move16();
}
}
@@ -2302,36 +2282,44 @@ void msvq_dec_fx(
IF( dims )
{
n = dims[i];
+ move16();
maxn = n;
+ move16();
}
ELSE
{
n = N;
+ move16();
maxn = maxN;
+ move16();
}
IF( offs )
{
start = offs[i];
+ move16();
}
ELSE
{
start = 0;
+ move16();
}
Word16 guard_bits = find_guarded_bits_fx( max_size );
- if ( i == 0 )
+ IF( i == 0 )
{
- FOR( Word16 k = 0; k < N; k++ )
+ FOR( k = 0; k < N; k++ )
{
uq[k] = L_shr( uq[k], guard_bits );
+ move32();
}
}
+ test();
IF( i == 0 && applyIDCT_flag != 0 )
{
assert( start == 0 );
dec_FDCNG_MSVQ_stage1_fx( Idx[0], N, invTrfMatrix, IDCT_T2_XX_24, uq, uq_ind ); /* IDCT_T2 N=24 used for all synthesis */
- FOR( Word16 k = 0; k < N; k++ )
+ FOR( k = 0; k < N; k++ )
{
uq[k] = L_shr( uq[k], guard_bits );
move32();
@@ -2341,9 +2329,10 @@ void msvq_dec_fx(
{
// v_add( uq + start, cb[i] + Idx[i] * maxn, uq + start, n );
- FOR( Word16 k = 0; k < n; k++ )
+ FOR( k = 0; k < n; k++ )
{
- uq[start + k] = L_add( uq[start + k], L_lshl( cb[i][Idx[i] * maxn + k], 20 - exp - guard_bits ) );
+ uq[add( start, k )] = L_add( uq[add( start, k )], L_lshl( cb[i][add( imult1616( Idx[i], maxn ), k )], sub( sub( 20, exp ), guard_bits ) ) );
+ move32();
}
}
@@ -2352,8 +2341,8 @@ void msvq_dec_fx(
{
FOR( j = 0; j < n; ++j )
{
+ uq_ind[add( start, j )] = add( uq_ind[add( start, j )], (Word16) ( mult( cb[i][add( imult1616( Idx[i], maxn ), j )], 20971 ), sub( add( 13, exp ), 15 ) ) );
move16();
- uq_ind[start + j] = add( uq_ind[start + j], (Word16) ( mult( cb[i][Idx[i] * maxn + j], 20971 ), ( 13 + exp ) - 15 ) );
}
}
#undef WMC_TOOL_SKIP
@@ -2726,42 +2715,54 @@ void dctT2_N_apply_matrix_fx(
assert( dct_dim <= FDCNG_VQ_DCT_MAXTRUNC );
assert( fdcngvq_dim <= FDCNG_VQ_MAX_LEN );
- if ( ( dcttype & 1 ) == 0 ) /* even entries are DCTs */
+ IF( L_and( dcttype, 1 ) == 0 ) /* even entries are DCTs */
{
/* DCT_typeII 24,21 -> XX in worst case */
dim_in = fdcngvq_dim;
+ move16();
dim_out = dct_dim;
+ move16();
mat_step_col = matrix_row_dim; /* matrix maximum storage size dependent, width of first row in matrix */
+ move16();
mat_step_row = 0;
+ move16();
mat_step_col_flag = 1;
+ move16();
assert( dcttype == DCT_T2_21_XX || dcttype == DCT_T2_24_XX );
}
- else
+ ELSE
{
assert( ( dcttype & 1 ) != 0 ); /* idct */
dim_in = dct_dim;
+ move16();
dim_out = fdcngvq_dim;
+ move16();
mat_step_col = 1;
+ move16();
mat_step_row = matrix_row_dim;
+ move16();
mat_step_col_flag = 0;
+ move16();
assert( dcttype == IDCT_T2_XX_24 );
}
pt_y = tmp_y;
- for ( i = 0; i < dim_out; i++ )
+ FOR( i = 0; i < dim_out; i++ )
{
pt_x = input;
*pt_y = 0;
+ move32();
/* +i(DCT) or +i*maxTrunc(IDCT) */
#define WMC_TOOL_SKIP
- pt_A = &( matrix[i * ( mat_step_row + mat_step_col_flag )] ); /* ptr indexing */
+ pt_A = &( matrix[imult1616( i, add( mat_step_row, mat_step_col_flag ) )] ); /* ptr indexing */
PTR_INIT( 1 );
#undef WMC_TOOL_SKIP
- for ( j = 0; j < dim_in; j++ )
+ FOR( j = 0; j < dim_in; j++ )
{
#define WMC_TOOL_SKIP
- *pt_y += Mpy_32_32( ( *pt_x++ ), ( *pt_A ) );
+ *pt_y = L_add( *pt_y, Mpy_32_32( ( *pt_x++ ), ( *pt_A ) ) );
+ move32();
pt_A += mat_step_col; /* step +maxtrunc or +1 */ /* ptr indexing*/
MAC( 1 );
#undef WMC_TOOL_SKIP
@@ -2916,7 +2917,7 @@ void create_IDCT_N_Matrix_fx(
const Word16 alloc_size /* i : RAM buffer size in elements */
)
{
- Word16 c, c1, r, r_flip, W16_val;
+ Word16 c, c1, r, r_flip, W16_val, tmp16;
Word16 len;
Word16 mat_cpy_size;
const Word16 *absval_ptr;
@@ -2927,20 +2928,23 @@ void create_IDCT_N_Matrix_fx(
absval_ptr = unique_idctT2_24coeffsQ16;
idx_ptr = idctT2_24_compressed_idx;
len = FDCNG_VQ_MAX_LEN;
+ move16();
- IF( N == FDCNG_VQ_MAX_LEN_WB )
+ IF( EQ_16( N, FDCNG_VQ_MAX_LEN_WB ) )
{
absval_ptr = unique_idctT2_21coeffsQ16;
idx_ptr = idctT2_21_compressed_idx;
len = N;
+ move16();
}
assert( alloc_size >= ( n_cols * len ) ); /* enough space for the full expanded IDCT matrix */
assert( N <= len );
- mat_cpy_size = ( n_cols ) * ( len >> 1 ); /* NB integer division of "len" */
+ // mat_cpy_size = ( n_cols ) * ( len >> 1 ); /* NB integer division of "len" */
+ mat_cpy_size = imult1616( n_cols, shr( len, 1 ) ); /* NB integer division of "len" */
- IF( NE_16( ( len & 1 ), 0 ) )
+ IF( s_and( len, 1 ) != 0 )
{ /* odd sized DCT with a non-reflected center row */
mat_cpy_size = add( mat_cpy_size, n_cols );
}
@@ -2949,13 +2953,15 @@ void create_IDCT_N_Matrix_fx(
{
idx = (Word16) ( idx_ptr[c] );
W16_val = absval_ptr[abs( idx )];
+ move16();
IF( idx < 0 )
{
- W16_val = -( W16_val );
+ W16_val = negate( W16_val );
}
/* (+1.52587890625e-05f) * 2 ^ 31 is equal to 32768 */
- inv_matrixFloatQ[c] = 32768 * ( W16_val ); /* scaling to 2 ^ 31*/
+ inv_matrixFloatQ[c] = L_shl( W16_val, Q15 ); /* scaling to 2 ^ 31*/
+ move32();
}
/* for even number of coeffs DCT24,
@@ -2967,13 +2973,14 @@ void create_IDCT_N_Matrix_fx(
FOR( c = 0; c < ( n_cols ); c += 2 )
{
- c1 = c + 1;
- r_flip = len - 1;
- FOR( r = 0; r < ( len / 2 ); r_flip-- )
+ c1 = add( c, 1 );
+ r_flip = sub( len, 1 );
+ tmp16 = shr( len, 1 );
+ FOR( r = 0; r < tmp16; r_flip-- )
{
#define WMC_TOOL_SKIP
- ptr[r_flip][c] = ptr[r][c]; /* flipped */
- ptr[r_flip][c1] = -( ptr[r][c1] ); /* flipped and sign swapped */
+ ptr[r_flip][c] = ptr[r][c]; /* flipped */
+ ptr[r_flip][c1] = L_negate( ptr[r][c1] ); /* flipped and sign swapped */
MOVE( 2 );
MULT( 1 ); /* for negate */
#undef WMC_TOOL_SKIP
diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c
index 9454e80f525bb2c6163f54280dc0091c24354898..5b6b612cade3ff8493a5cf6741b881dcc23e6a1c 100644
--- a/lib_com/lsf_tools_fx.c
+++ b/lib_com/lsf_tools_fx.c
@@ -36,7 +36,7 @@
#include "basop_util.h"
#include "rom_com.h"
#include "ivas_cnst.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_error.h"
@@ -178,6 +178,7 @@ void E_LPC_a_isp_conversion( const Word16 a[], Word16 isp[], const Word16 old_is
Word32 f[2][NC_MAX + 1];
Word32 t0, t1;
Word16 scale = 1024;
+ move16();
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
#endif
@@ -437,10 +438,11 @@ void E_LPC_f_isp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m )
DO
{
-
+ test();
/* a[0] = 1.0 */
a[0] = shl( 256, q );
move16();
+
j = sub( m, 1 );
FOR( i = 1; i < nc; i++ )
{
@@ -448,11 +450,13 @@ void E_LPC_f_isp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m )
t0 = L_add( f1[i], f2[i] ); /* f1[i] + f2[i] */
t0 = L_shl( t0, q );
a[i] = round_fx( t0 ); /* from Q23 to Q12 and * 0.5 */
+ move16();
/* a[j] = 0.5*(f1[i] - f2[i]) */
t0 = L_sub( f1[i], f2[i] ); /* f1[i] - f2[i] */
t0 = L_shl( t0, q );
a[j] = round_fx( t0 ); /* from Q23 to Q12 and * 0.5 */
+ move16();
j = sub( j, 1 );
}
@@ -478,11 +482,11 @@ void E_LPC_f_isp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m )
WHILE( t0n == 0 || t0p == 0 ); /*in case of overflow, recalculate coefficients*/
a[nc] = round_fx( t0 ); /* from Q23 to Q12 and * 0.5 */
-
+ move16();
/* a[m] = isp[m-1] */
t0 = L_mult( a[0], isp[m - 1] ); /* from Q15 to Q12 */
a[m] = round_fx( t0 );
-
+ move16();
return;
}
@@ -1440,12 +1444,15 @@ void lsp_weights_fx(
FOR( i = 0; i < lpcOrder; i++ )
{
w[i] = round_fx( L_shl( Lsum1[i], sub( norm[i], n_max + 1 ) ) ); /* Q( 9-n_max) */
+ move16();
}
IF( lpcOrder != LPC_SHB_ORDER_WB )
{
w[3] = round_fx( L_shl( L_mult( w[3], 18022 ), 1 ) ); /* Q( 9-n_max) */
w[4] = round_fx( L_shl( L_mult( w[4], 18022 ), 1 ) ); /* Q( 9-n_max) */
+ move16();
+ move16();
}
*Qout = 9 - n_max;
@@ -1700,6 +1707,7 @@ void a2rc_fx( const Word16 *a, /* i: can be any Q */
L_tmp1 = L_mac_o( L_tmp1, tmp, f_fx[j], &Overflow ); /* denom*f[j]+km*denom*f[j] in Q28 (floating with exp) */
L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */
f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */
+ move16();
#else
L_tmp1 = L_mac( L_tmp1, tmp, f_fx[j] ); /* denom*f[j]+km*denom*f[j] in Q28 (floating with exp) */
L_tmp1 = L_shr( L_tmp1, exp ); /* bringing to true Q28 */
@@ -1842,6 +1850,7 @@ ivas_error lsf_allocate_fx(
ivas_error error;
error = IVAS_ERR_OK;
+ move16();
cumleft = nBits;
move16();
@@ -1995,6 +2004,7 @@ ivas_error find_pred_mode(
ivas_error error;
error = IVAS_ERR_OK;
+ move16();
/* bwidth = 0(NB), 1 (WB), 2(WB2); line index in predmode_tab[][] */
idx = bwidth;
@@ -2002,6 +2012,7 @@ ivas_error find_pred_mode(
if ( GT_16( idx, 1 ) )
{
idx = 1;
+ move16();
}
IF( EQ_32( int_fs, INT_FS_16k ) )
{
@@ -2048,10 +2059,12 @@ ivas_error find_pred_mode(
IF( *predmode > 0 )
{
*p_mode_lvq_p = *p_mode_lvq;
+ move16();
}
ELSE
{
*p_mode_lvq_p = -1;
+ move16();
}
}
}
@@ -2470,6 +2483,7 @@ void lsp2lsf_fx(
L_tmp = L_shr( L_mult0( extract_l( L_tmp ), 5 ), 2 );
}
lsf[i] = extract_l( L_tmp );
+ move16();
}
}
/*===========================================================================*/
@@ -2851,7 +2865,7 @@ void lsf_syn_mem_backup_fx(
move16();
*streaklimit = st_fx->streaklimit_fx;
move16();
- *pstreaklen = st_fx->pstreaklen_fx;
+ *pstreaklen = st_fx->pstreaklen;
move16();
FOR( i = 0; i < L_FFT; i++ )
@@ -2878,9 +2892,12 @@ void lsf_syn_mem_backup_fx(
*btilt_code_fx = hLPDmem->tilt_code;
+ move16();
*gc_threshold_fx = hLPDmem->gc_threshold;
+ move16();
Copy( st_fx->clip_var_fx, clip_var_bck_fx, 6 );
*next_force_sf_bck_fx = st_fx->next_force_safety_net_fx;
+ move16();
return;
@@ -2988,7 +3005,7 @@ void lsf_syn_mem_restore_fx(
move16();
st_fx->streaklimit_fx = streaklimit;
move16();
- st_fx->pstreaklen_fx = pstreaklen;
+ st_fx->pstreaklen = pstreaklen;
move16();
FOR( i = 0; i < L_FFT; i++ )
diff --git a/lib_com/lsp_conv_poly_fx.c b/lib_com/lsp_conv_poly_fx.c
index 2685a127e1e98cf47d5b6541382ecd35e5296010..70b9190027ffde618edbea070a1a3624122db200 100644
--- a/lib_com/lsp_conv_poly_fx.c
+++ b/lib_com/lsp_conv_poly_fx.c
@@ -10,7 +10,7 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
* Local constants
@@ -561,6 +561,8 @@ static void spectautocorr_fx(
*---------------------------------------------------------------------*/
r[1] = L_deposit_l( 0 );
+ move32();
+
r[2] = -G[imid];
move32();
@@ -569,6 +571,7 @@ static void spectautocorr_fx(
r[i] = L_deposit_l( 0 );
r[i + 1] = -r[i - 1];
move32();
+ move32();
}
/*---------------------------------------------------------------------*
@@ -738,8 +741,10 @@ static void zeros2poly_fx(
{
Mpy_32_16_ss( R[j - 1], xr, &mh, &ml );
R[j] = L_add( R[j], mh );
+ move32();
Mpy_32_16_ss( S[j - 1], xs, &mh, &ml );
S[j] = L_add( S[j], mh );
+ move32();
}
}
diff --git a/lib_com/modif_fs.c b/lib_com/modif_fs.c
index e07eb02aa8cf8a6ef604edf10033cb93772dac49..73a08dd3280bf71fd4cd0750fb29bf41fae64032 100644
--- a/lib_com/modif_fs.c
+++ b/lib_com/modif_fs.c
@@ -41,7 +41,7 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
* modify_Fs()
@@ -537,39 +537,99 @@ void Interpolate_allpass_steep_32(
int16_t n, k;
Word32 temp_fx[ALLPASSSECTIONS_STEEP - 1];
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ /* upper allpass filter chain */
+ FOR( k = 0; k < N; k++ )
+ {
+ temp_fx[0] = Madd_32_16( mem_fx[0], in_fx[k], AP2_STEEP_FX[0] );
+ move32();
+ mem_fx[0] = Msub_32_16( in_fx[k], temp_fx[0], AP2_STEEP_FX[0] );
+ move32();
+
+ /* for better performance, unroll this loop */
+ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
+ {
+ temp_fx[n] = Madd_32_16( mem_fx[n], temp_fx[n - 1], AP2_STEEP_FX[n] );
+ move32();
+ mem_fx[n] = Msub_32_16( temp_fx[n - 1], temp_fx[n], AP2_STEEP_FX[n] );
+ move32();
+ }
+
+ out_fx[2 * k + 1] = Madd_32_16( mem_fx[ALLPASSSECTIONS_STEEP - 1], temp_fx[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] );
+ move32();
+ mem_fx[ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp_fx[ALLPASSSECTIONS_STEEP - 2], out_fx[2 * k + 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] );
+ move32();
+ }
+
+ /* lower allpass filter chain */
+ FOR( k = 0; k < N; k++ )
+ {
+ temp_fx[0] = Madd_32_16( mem_fx[ALLPASSSECTIONS_STEEP], in_fx[k], AP1_STEEP_FX[0] );
+ move32();
+ mem_fx[ALLPASSSECTIONS_STEEP] = Msub_32_16( in_fx[k], temp_fx[0], AP1_STEEP_FX[0] );
+ move32();
+
+ /* for better performance, unroll this loop */
+ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
+ {
+ temp_fx[n] = Madd_32_16( mem_fx[ALLPASSSECTIONS_STEEP + n], temp_fx[n - 1], AP1_STEEP_FX[n] );
+ move32();
+ mem_fx[ALLPASSSECTIONS_STEEP + n] = Msub_32_16( temp_fx[n - 1], temp_fx[n], AP1_STEEP_FX[n] );
+ move32();
+ }
+
+ out_fx[2 * k] = Madd_32_16( mem_fx[2 * ALLPASSSECTIONS_STEEP - 1], temp_fx[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] );
+ move32();
+ mem_fx[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp_fx[ALLPASSSECTIONS_STEEP - 2], out_fx[2 * k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] );
+ move32();
+ }
+#else
/* upper allpass filter chain */
FOR( k = 0; k < N; k++ )
{
temp_fx[0] = L_add( mem_fx[0], Mpy_32_16_1( in_fx[k], AP2_STEEP_FX[0] ) );
+ move32();
mem_fx[0] = L_sub( in_fx[k], Mpy_32_16_1( temp_fx[0], AP2_STEEP_FX[0] ) );
+ move32();
/* for better performance, unroll this loop */
FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
{
temp_fx[n] = L_add( mem_fx[n], Mpy_32_16_1( temp_fx[n - 1], AP2_STEEP_FX[n] ) );
+ move32();
mem_fx[n] = L_sub( temp_fx[n - 1], Mpy_32_16_1( temp_fx[n], AP2_STEEP_FX[n] ) );
+ move32();
}
out_fx[2 * k + 1] = L_add( mem_fx[ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp_fx[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) );
+ move32();
mem_fx[ALLPASSSECTIONS_STEEP - 1] = L_sub( temp_fx[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( out_fx[2 * k + 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) );
+ move32();
}
/* lower allpass filter chain */
FOR( k = 0; k < N; k++ )
{
temp_fx[0] = L_add( mem_fx[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( in_fx[k], AP1_STEEP_FX[0] ) );
+ move32();
mem_fx[ALLPASSSECTIONS_STEEP] = L_sub( in_fx[k], Mpy_32_16_1( temp_fx[0], AP1_STEEP_FX[0] ) );
+ move32();
/* for better performance, unroll this loop */
FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
{
temp_fx[n] = L_add( mem_fx[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp_fx[n - 1], AP1_STEEP_FX[n] ) );
+ move32();
mem_fx[ALLPASSSECTIONS_STEEP + n] = L_sub( temp_fx[n - 1], Mpy_32_16_1( temp_fx[n], AP1_STEEP_FX[n] ) );
+ move32();
}
out_fx[2 * k] = L_add( mem_fx[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp_fx[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) );
+ move32();
mem_fx[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp_fx[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( out_fx[2 * k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) );
+ move32();
}
+#endif
return;
}
@@ -676,54 +736,74 @@ void Decimate_allpass_steep_fx32(
FOR( k = 0; k < N / 2; k++ )
{
temp[0] = L_add( mem[0], Mpy_32_16_1( in[2 * k], AP1_STEEP_FX[0] ) );
+ move32();
mem[0] = L_sub( in[2 * k], Mpy_32_16_1( temp[0], AP1_STEEP_FX[0] ) );
+ move32();
temp[1] = L_add( mem[1], Mpy_32_16_1( temp[0], AP1_STEEP_FX[1] ) );
+ move32();
mem[1] = L_sub( temp[0], Mpy_32_16_1( temp[1], AP1_STEEP_FX[1] ) );
+ move32();
out[k] = L_add( mem[ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) );
+ move32();
mem[ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) );
+ move32();
}
/* lower allpass filter chain */
temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ) );
+ move32();
mem[ALLPASSSECTIONS_STEEP] = L_sub( mem[2 * ALLPASSSECTIONS_STEEP], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) );
+ move32();
/* for better performance, unroll this loop */
FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
{
temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) );
+ move32();
/*if ( fabs( temp[n] ) < 1e-12 )
{
temp[n] = sign( temp[n] ) * 1e-12f;
}*/
mem[ALLPASSSECTIONS_STEEP + 1] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) );
+ move32();
}
temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) );
+ move32();
mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) );
out[0] = L_add( out[0], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) );
+ move32();
+ move32();
FOR( k = 1; k < N / 2; k++ )
{
temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( in[2 * k - 1], AP2_STEEP_FX[0] ) );
+ move32();
mem[ALLPASSSECTIONS_STEEP] = L_sub( in[2 * k - 1], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) );
+ move32();
/* for better performance, unroll this loop */
FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ )
{
temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) );
+ move32();
/*if ( fabs( temp[n] ) < 1e-12 )
{
temp[n] = sign( temp[n] ) * 1e-12f;
}*/
mem[ALLPASSSECTIONS_STEEP + n] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n - 1] ) );
+ move32();
}
temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) );
+ move32();
mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) );
+ move32();
out[k] = L_add( out[k], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) );
+ move32();
}
/* z^(-1) */
@@ -824,8 +904,11 @@ void interpolate_3_over_2_allpass_32(
{
/* Upper branch */
Vu[0] = L_add( mem[0], Mpy_32_16_1( ( input[i] - mem[1] ), filt_coeff[0] ) );
+ move32();
Vu[1] = L_add( mem[1], Mpy_32_16_1( ( Vu[0] - mem[2] ), filt_coeff[1] ) );
+ move32();
mem[3] = L_add( mem[2], Mpy_32_16_1( ( Vu[1] - mem[3] ), filt_coeff[2] ) );
+ move32();
mem[1] = Vu[0];
move32();
@@ -836,8 +919,11 @@ void interpolate_3_over_2_allpass_32(
/* Middle branch */
Vm[0] = L_add( mem[0], Mpy_32_16_1( ( input[i] - mem[4] ), filt_coeff[3] ) );
+ move32();
Vm[1] = L_add( mem[4], Mpy_32_16_1( ( Vm[0] - mem[5] ), filt_coeff[4] ) );
+ move32();
mem[6] = L_add( mem[5], Mpy_32_16_1( ( Vm[1] - mem[6] ), filt_coeff[5] ) );
+ move32();
mem[4] = Vm[0];
move32();
@@ -848,8 +934,11 @@ void interpolate_3_over_2_allpass_32(
/* Lower branch */
Vl[0] = L_add( mem[0], Mpy_32_16_1( ( input[i] - mem[7] ), filt_coeff[6] ) );
+ move32();
Vl[1] = L_add( mem[7], Mpy_32_16_1( ( Vl[0] - mem[8] ), filt_coeff[7] ) );
+ move32();
mem[9] = L_add( mem[8], Mpy_32_16_1( ( Vl[1] - mem[9] ), filt_coeff[8] ) );
+ move32();
mem[0] = input[i];
move32();
@@ -1032,7 +1121,7 @@ void interpolate_3_over_1_allpass(
return;
}
-
+#ifdef IVAS_FLOAT_FIXED
void interpolate_3_over_1_allpass_32(
const Word32 *input, /* i : input signal */
const Word16 len, /* i : number of input samples */
@@ -1040,7 +1129,7 @@ void interpolate_3_over_1_allpass_32(
Word32 *mem /* i/o: memory */
)
{
- Word16 i;
+ Word16 i, tmp16;
Word32 Vu[2], Vm[2], Vl[2]; /* Outputs of three cascaded allpass stages (upper, middle, and lower) */
Word32 *out1;
Word32 mem_temp;
@@ -1052,46 +1141,71 @@ void interpolate_3_over_1_allpass_32(
{
/* Upper branch */
Vu[0] = L_add_sat( mem[0], Mpy_32_16_1( L_sub( input[i], mem[1] ), filt_coeff[0] ) );
+ move32();
Vu[1] = L_add_sat( mem[1], Mpy_32_16_1( L_sub( Vu[0], mem[2] ), filt_coeff[1] ) );
+ move32();
mem[3] = L_add_sat( mem[2], Mpy_32_16_1( L_sub( Vu[1], mem[3] ), filt_coeff[2] ) );
+ move32();
mem[1] = Vu[0];
+ move32();
mem[2] = Vu[1];
+ move32();
*out1++ = mem[3];
+ move32();
/* Middle branch */
Vm[0] = L_add_sat( mem[0], Mpy_32_16_1( L_sub( input[i], mem[4] ), filt_coeff[3] ) );
+ move32();
Vm[1] = L_add_sat( mem[4], Mpy_32_16_1( L_sub( Vm[0], mem[5] ), filt_coeff[4] ) );
+ move32();
mem[6] = L_add_sat( mem[5], Mpy_32_16_1( L_sub( Vm[1], mem[6] ), filt_coeff[5] ) );
+ move32();
mem[4] = Vm[0];
+ move32();
mem[5] = Vm[1];
+ move32();
*out1++ = mem[6];
+ move32();
/* Lower branch */
Vl[0] = L_add_sat( mem[0], Mpy_32_16_1( L_sub( input[i], mem[7] ), filt_coeff[6] ) );
+ move32();
Vl[1] = L_add_sat( mem[7], Mpy_32_16_1( L_sub( Vl[0], mem[8] ), filt_coeff[7] ) );
+ move32();
mem[9] = L_add_sat( mem[8], Mpy_32_16_1( L_sub( Vl[1], mem[9] ), filt_coeff[8] ) );
+ move32();
mem[0] = input[i];
+ move32();
mem[7] = Vl[0];
+ move32();
mem[8] = Vl[1];
+ move32();
*out1++ = mem[9];
+ move32();
}
/*LPF*/
- FOR( i = 0; i < len * 3; i++ )
+ tmp16 = imult1616( len, 3 );
+ FOR( i = 0; i < tmp16; i++ )
{
mem_temp = out[i];
+ move32();
out[i] = L_sub_sat( Mpy_32_16_1( L_add_sat( mem[12], mem[11] ), 18768 ), Mpy_32_16_1( L_add_sat( mem_temp, mem[10] ), 2424 ) );
+ move32();
mem[10] = mem[11];
+ move32();
mem[11] = mem[12];
+ move32();
mem[12] = mem_temp;
+ move32();
}
return;
}
-
+#endif
/*-------------------------------------------------------------------*
* retro_interp4_5()
diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c
index 85be57a43461aa0b7627b23d5875091d1f492864..c0c42d31911cd1a88d9b3ba818aeac2c29e6b4b7 100644
--- a/lib_com/modif_fs_fx.c
+++ b/lib_com/modif_fs_fx.c
@@ -5,8 +5,7 @@
#include
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h" /* Static table prototypes */
#include
#include "rom_enc.h" /* prototypes */
@@ -47,7 +46,9 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
Word16 sigOut_fx[], /* o : decimated signal Q0 */
const Word32 fout, /* i : frequency of output Q0 */
Word16 mem_fx[], /* i/o: filter memory Q0 */
- const Word16 nblp /* i : flag indicating if NB low-pass is applied */
+ const Word16 nblp, /* i : flag indicating if NB low-pass is applied */
+ Word16 *Q_new_inp, // TO be removed
+ Word16 *mem_decim_size // TO be removed
)
{
Word16 i;
@@ -68,22 +69,25 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
Word32 t0, t1, t2, L_tmp; /* temporary variables */
Word32 LepsP[M + 1];
Word16 flag_low_order = 0;
+ move16();
Word16 filt_len_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
const Resampling_cfg *cfg_ptr_fx;
/*-------------------------------------------------------------------*
* Find the resampling configuration
*-------------------------------------------------------------------*/
-
+ *Q_new_inp = 0;
/* check if fin and fout are the same */
IF( EQ_32( fin, fout ) )
{
/* just copy the signal_fx and quit */
Copy( sigIn_fx, sigOut_fx, lg );
-
+ *mem_decim_size = 0;
+ *Q_new_inp = 0;
return lg;
}
ELSE
@@ -148,6 +152,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
}
mem_len = shl( filt_len, 1 );
+ *mem_decim_size = mem_len;
signal_fx = signal_tab_fx + 2 * L_FILT_MAX + sub( L_FRAME48k, add( mem_len, lg ) );
signal_ana_fx = signal_fx;
mem_len_ana = mem_len;
@@ -252,6 +257,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
}
/* rescaling */
test();
+
IF( ( GT_16( fac_num, fac_den ) ) == ( ( cfg_ptr_fx->flags_fx & RS_INV_FAC ) != 0 ) )
{
IF( LT_16( fac_num, fac_den ) )
@@ -264,6 +270,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
FOR( i = 0; i < lg_out; i++ )
{
sigOut_fx[i] = round_fx( L_shl( L_mult( sigOut_fx[i], num_den ), 1 ) ); /*Q0*/
+ *Q_new_inp = -1;
}
}
ELSE
@@ -275,6 +282,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
{
#ifdef BASOP_NOGLOB
num_den = shl_o( num_den, 1, &Overflow );
+ //*Q_new_inp = 2;
#else
num_den = shl( num_den, 1 );
#endif
@@ -284,6 +292,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
sigOut_fx[i] = mult_r( sigOut_fx[i], num_den ); /*Q0*/
move16();
}
+ *Q_new_inp = -1;
}
}
ELSE
@@ -291,10 +300,12 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
IF( EQ_16( fac_num, 8 ) )
{
num_den = 26214;
+ move16();
FOR( i = 0; i < lg_out; i++ )
{
sigOut_fx[i] = mult_r( sigOut_fx[i], num_den ); /*Q-1*/
move16();
+ *Q_new_inp = -2;
}
}
ELSE
@@ -303,6 +314,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
FOR( i = 0; i < lg_out; i++ )
{
sigOut_fx[i] = round_fx( L_mac( L_deposit_h( sigOut_fx[i] ), sigOut_fx[i], num_den ) ); /*Q0*/
+ *Q_new_inp = -1;
}
}
}
@@ -313,6 +325,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
{
sigOut_fx[i] = mult_r( sigOut_fx[i], 16384 );
move16(); /*Q-1*/
+ *Q_new_inp = -2;
}
}
/* update the filter memory */
@@ -648,6 +661,7 @@ void Decimate_allpass_steep_fx(
Word16 sum = 0;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
move16();
@@ -673,6 +687,7 @@ void Decimate_allpass_steep_fx(
mem[0] = extract_h( Lacc1 ); /* Qx */
temp[0] = temp1;
move16();
+ move16();
Lacc1 = L_deposit_h( mem[1] ); /* Q16+Qx */
#ifdef BASOP_NOGLOB
@@ -690,12 +705,15 @@ void Decimate_allpass_steep_fx(
mem[1] = extract_h( Lacc ); /* Qx */
temp[1] = temp2;
move16();
+ move16();
Lacc = L_deposit_h( mem[ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */
#ifdef BASOP_NOGLOB
- out_fx[k] = extract_h( L_mac_o( Lacc, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2, &Overflow ) ); /* Qx format */
+ out_fx[k] = extract_h( L_mac_o( Lacc, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2, &Overflow ) ); /* Qx format */
+ move16();
mem[ALLPASSSECTIONS_STEEP - 1] = extract_h( L_msu_o( Lacc1, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], out_fx[k], &Overflow ) ); /* Qx */
+ move16();
#else
out_fx[k] = extract_h( L_mac( Lacc, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2 ) ); /* Qx format */
mem[ALLPASSSECTIONS_STEEP - 1] = extract_h( L_msu( Lacc1, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], out_fx[k] ) ); /* Qx */
@@ -736,7 +754,7 @@ void Decimate_allpass_steep_fx(
Lacc = L_msu( Lacc, AP2_STEEP_FX[1], temp2 ); /* Q(16+x) */
#endif
mem[ALLPASSSECTIONS_STEEP + 1] = extract_h( Lacc ); /* Qx */
-
+ move16();
Lacc = L_deposit_h( mem[2 * ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */
#ifdef BASOP_NOGLOB
@@ -745,13 +763,14 @@ void Decimate_allpass_steep_fx(
Lacc = L_mac( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2 ); /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */
#endif
temp[2] = extract_h( Lacc ); /* temp[2] in Qx */
+ move16();
#ifdef BASOP_NOGLOB
Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp[2], &Overflow ); /* Q(16+x) */
#else
Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp[2] ); /* Q(16+x) */
#endif
mem[2 * ALLPASSSECTIONS_STEEP - 1] = extract_h( Lacc1 ); /* Qx */
-
+ move16();
sum = mult_r( out_fx[0], 16384 ); /* Qx */
#ifdef BASOP_NOGLOB
out_fx[0] = add_sat( sum, mult_r( temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) ); /* Qx */
@@ -780,6 +799,7 @@ void Decimate_allpass_steep_fx(
#endif
mem[ALLPASSSECTIONS_STEEP] = extract_h( Lacc1 ); /* Qx */
+ move16();
temp[0] = temp1;
move16();
@@ -819,6 +839,7 @@ void Decimate_allpass_steep_fx(
sum = mult_r( out_fx[k], 16384 ); /* Qx */
#ifdef BASOP_NOGLOB
out_fx[k] = add_sat( sum, mult_r( temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) );
+ move16();
#else
out_fx[k] = add( sum, mult_r( temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) );
#endif
@@ -850,6 +871,7 @@ void Interpolate_allpass_steep_fx(
Word16 temp1, temp2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*** State in Q0,in_fx Q0, AP1_STEEP in Q15 AP2_STEEP in Q15 OP in Q0 ************/
/*upper allpass filter chain */
@@ -869,6 +891,7 @@ void Interpolate_allpass_steep_fx(
Lacc1 = L_msu_o( Lacc1, AP2_STEEP_FX[0], temp1, &Overflow ); /* Q(16+x) */
mem[0] = round_fx_o( Lacc1, &Overflow );
+ move16();
#else
temp1 = round_fx( Lacc ); /* Qx */
Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[0], temp1 ); /* Q(16+x) */
@@ -887,6 +910,7 @@ void Interpolate_allpass_steep_fx(
temp2 = round_fx_o( Lacc1, &Overflow ); /* Qx */
Lacc = L_msu_o( Lacc, AP2_STEEP_FX[1], temp2, &Overflow ); /* Q(16+x) */
mem[1] = round_fx_o( Lacc, &Overflow ); /* Qx */
+ move16();
#else
temp2 = round_fx( Lacc1 ); /* Qx */
Lacc = L_msu( Lacc, AP2_STEEP_FX[1], temp2 ); /* Q(16+x) */
@@ -896,8 +920,10 @@ void Interpolate_allpass_steep_fx(
Lacc1 = L_deposit_h( temp2 );
Lacc = L_deposit_h( mem[ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */
#ifdef BASOP_NOGLOB
- out_fx[2 * k + 1] = round_fx_o( L_mac_o( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2, &Overflow ), &Overflow ); /* Qx format */
+ out_fx[2 * k + 1] = round_fx_o( L_mac_o( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2, &Overflow ), &Overflow ); /* Qx format */
+ move16();
mem[ALLPASSSECTIONS_STEEP - 1] = round_fx_o( L_msu_o( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], out_fx[2 * k + 1], &Overflow ), &Overflow ); /* Qx */
+ move16();
#else
out_fx[2 * k + 1] = round_fx( L_mac( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2 ) ); /* Qx format */
mem[ALLPASSSECTIONS_STEEP - 1] = round_fx( L_msu( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], out_fx[2 * k + 1] ) ); /* Qx */
@@ -948,8 +974,10 @@ void Interpolate_allpass_steep_fx(
Lacc = L_deposit_h( mem[2 * ALLPASSSECTIONS_STEEP - 1] ); /* Q(16+x) */
Lacc1 = L_deposit_h( temp2 );
#ifdef BASOP_NOGLOB
- out_fx[2 * k] = round_fx_o( L_mac_o( Lacc, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2, &Overflow ), &Overflow ); /* Qx format */
+ out_fx[2 * k] = round_fx_o( L_mac_o( Lacc, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2, &Overflow ), &Overflow ); /* Qx format */
+ move16();
mem[2 * ALLPASSSECTIONS_STEEP - 1] = round_fx_o( L_msu_o( Lacc1, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], out_fx[2 * k], &Overflow ), &Overflow ); /* Qx */
+ move16();
#else
out_fx[2 * k] = round_fx( L_mac( Lacc, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], temp2 ) ); /* Qx format */
mem[2 * ALLPASSSECTIONS_STEEP - 1] = round_fx( L_msu( Lacc1, AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1], out_fx[2 * k] ) ); /* Qx */
diff --git a/lib_com/mslvq_com.c b/lib_com/mslvq_com.c
index 00b77cebfad6178cf4e12d4411ff4506153ef2fc..d7d4c427be231228e23c01dcdf7beb0f7448e97c 100644
--- a/lib_com/mslvq_com.c
+++ b/lib_com/mslvq_com.c
@@ -41,7 +41,7 @@
#include "prot.h"
#include "wmc_auto.h"
#include "ivas_prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
/*-----------------------------------------------------------------*
diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c
index 9a5014b4f5226dfabe05ddd20c3d89da7753ce6a..cce15973882f52b07387750d336a3973c05fb501 100644
--- a/lib_com/mslvq_com_fx.c
+++ b/lib_com/mslvq_com_fx.c
@@ -32,7 +32,7 @@
#include "options.h"
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_cnst.h"
#include "stl.h"
#include "rom_com.h"
@@ -51,7 +51,7 @@ static void idx2c_fx( Word16 n, Word16 *p, Word16 k, Word16 val );
static void divide_64_32_fx( Word16 *xs, Word32 y, Word32 *result, Word32 *rem );
static Word16
decode_indexes_fx( Word16 *index, Word16 no_bits, const Word16 *p_scales, Word16 *p_no_scales, Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *x_lvq, Word16 mode_glb, Word16 *scales );
-static int16_t decode_indexes_ivas_fx(
+static Word16 decode_indexes_ivas_fx(
Word16 *index,
const Word16 no_bits,
const Word16 *p_scales, // Q11
@@ -62,7 +62,7 @@ static int16_t decode_indexes_ivas_fx(
);
static Word32 divide_32_32_fx( Word32 y, Word32 x, Word32 *rem );
static Word16 divide_16_16_fx( Word16 y, Word16 x, Word16 *rem );
-static int16_t decode_indexes_ivas_fx(
+static Word16 decode_indexes_ivas_fx(
Word16 *index,
const Word16 no_bits,
const Word16 *p_scales, // Q11
@@ -180,6 +180,7 @@ static void make_offset_scale_fx(
Word16 i;
offset_scale[j][0] = L_deposit_l( 1 );
+ move32();
FOR( i = 1; i <= no_scl; i++ )
{
offset_scale[j][i] = L_add( offset_scale[j][sub( i, 1 )], tab_no_cv[no_ld[sub( i, 1 )]] );
@@ -239,7 +240,10 @@ decode_indexes_fx(
)
{
Word32 index1 = 0, index2 = 0;
+ move32();
+ move32();
Word16 len_scales = MAX_NO_SCALES * 2, no_modes;
+ move16();
Word16 i, im1, idx_scale;
Word16 tmp;
@@ -264,8 +268,11 @@ decode_indexes_fx(
{
set16_fx( x_lvq, 0, 2 * LATTICE_DIM );
scales_mslvq[0] = 0;
+ move16();
scales_mslvq[1] = 0;
+ move16();
index[i] = 0;
+ move16();
return 1;
}
}
@@ -290,6 +297,7 @@ decode_indexes_fx(
move16();
}
scales_mslvq[0] = 0;
+ move16();
}
ELSE
{
@@ -298,7 +306,9 @@ decode_indexes_fx(
/* safety check in case of bit errors */
set16_fx( x_lvq, 0, 2 * LATTICE_DIM );
scales_mslvq[0] = 0;
+ move16();
scales_mslvq[1] = 0;
+ move16();
return 1;
}
@@ -324,6 +334,7 @@ decode_indexes_fx(
im1 = sub( i, 1 );
decode_comb_fx( L_sub( index1, table_no_cv_fx[im1] ), x_lvq, im1 );
scales_mslvq[0] = p_scales[mode_glb * len_scales + idx_scale];
+ move16();
}
/* second subvector */
@@ -365,7 +376,7 @@ decode_indexes_fx(
return 0;
}
-static int16_t decode_indexes_ivas_fx(
+static Word16 decode_indexes_ivas_fx(
Word16 *index,
const Word16 no_bits,
const Word16 *p_scales, // Q11
@@ -375,31 +386,29 @@ static int16_t decode_indexes_ivas_fx(
Word16 *scales_mslvq /* o: scale values for the decoded MSLVQ LSF codevector Q11*/
)
{
- // UWord32 index1 = 0, index2, idx_scale;
Word32 index1 = 0, index2, idx_scale;
- // uint16_t i;
+ move32();
Word16 i;
- // float scale;
- // Word16 scale;
Word16 len_scales = i_mult( MAX_NO_SCALES, 2 );
UWord32 offset_scale1[MAX_NO_SCALES + 1], offset_scale2[MAX_NO_SCALES + 1];
- if ( no_bits <= 2 * LEN_INDICE ) /* the third short is not used */
+ IF( LE_16( no_bits, 2 * LEN_INDICE ) ) /* the third short is not used */
{
index[2] = 0;
- if ( no_bits <= LEN_INDICE )
+ move16();
+ if ( LE_16( no_bits, LEN_INDICE ) )
{
index[1] = 0;
+ move16();
}
}
/* safety check in case of bit errors */
- for ( i = 0; i < 3; i++ )
+ FOR( i = 0; i < 3; i++ )
{
- if ( index[i] < 0 )
+ IF( index[i] < 0 )
{
- // set_f(x_lvq, 0.0f, 2 * LATTICE_DIM);
set_s( x_lvq, 0, 2 * LATTICE_DIM );
#ifdef MSAN_FIX
scales_mslvq[0] = 0;
@@ -414,22 +423,22 @@ static int16_t decode_indexes_ivas_fx(
create_offset( offset_scale1, offset_scale2, mode_glb, prediction_flag );
/* first subvector */
- if ( offset_scale2[MAX_NO_SCALES - 1] > 0 )
+ IF( offset_scale2[MAX_NO_SCALES - 1] > 0 )
{
- // divide_64_32(index, offset_scale2[MAX_NO_SCALES], &index1, &index2);
divide_64_32_fx( index, offset_scale2[MAX_NO_SCALES], &index1, &index2 );
}
- else
+ ELSE
{
index1 = (UWord32) ( index[0] ); /* this is for very low bitrates, so there is no loss in truncation */
+ move32();
index2 = 0;
+ move32();
}
- if ( index1 == 0 )
+ IF( index1 == 0 )
{
- for ( i = 0; i < LATTICE_DIM; i++ )
+ FOR( i = 0; i < LATTICE_DIM; i++ )
{
- // x_lvq[i] = 0.0;
x_lvq[i] = 0;
#ifdef MSAN_FIX
scales_mslvq[0] = 0;
@@ -437,12 +446,11 @@ static int16_t decode_indexes_ivas_fx(
#endif
}
}
- else
+ ELSE
{
- if ( index1 >= (Word32) offset_scale1[MAX_NO_SCALES] )
+ IF( GE_32( index1, (Word32) offset_scale1[MAX_NO_SCALES] ) )
{
/* safety check in case of bit errors */
- // set_f(x_lvq, 0.0f, 2 * LATTICE_DIM);
set_s( x_lvq, 0, 2 * LATTICE_DIM );
#ifdef MSAN_FIX
scales_mslvq[0] = 0;
@@ -455,23 +463,25 @@ static int16_t decode_indexes_ivas_fx(
/* find idx_scale */
i = 1;
- while ( (int16_t) i <= MAX_NO_SCALES && index1 >= (Word32) offset_scale1[i] )
+ test();
+ WHILE( LE_16( (Word16) i, MAX_NO_SCALES ) && GE_32( index1, (Word32) offset_scale1[i] ) )
{
i++;
}
idx_scale = i - 1;
- index1 -= offset_scale1[idx_scale];
+ index1 = L_sub( index1, offset_scale1[idx_scale] );
/* find idx_leader */
i = 1;
- while ( index1 >= (Word32) table_no_cv[i] )
+ move16();
+ WHILE( GE_32( index1, (Word32) table_no_cv[i] ) )
{
i++;
}
- // decode_comb((Word32)(index1 - table_no_cv[i - 1]), x_lvq, i - 1);
decode_comb_fx( (Word32) ( index1 - table_no_cv[i - 1] ), x_lvq, i - 1 );
scales_mslvq[0] = p_scales[mode_glb * len_scales + idx_scale];
+ move16();
// for (i = 0; i < LATTICE_DIM; i++)
//{
// //x_lvq[i] *= scale;
@@ -480,40 +490,44 @@ static int16_t decode_indexes_ivas_fx(
}
/* second subvector */
- if ( index2 == 0 )
+ IF( index2 == 0 )
{
- for ( i = LATTICE_DIM; i < 2 * LATTICE_DIM; i++ )
+ FOR( i = LATTICE_DIM; i < 2 * LATTICE_DIM; i++ )
{
// x_lvq[i] = 0.0;
x_lvq[i] = 0;
+ move16();
}
#ifdef MSAN_FIX
scales_mslvq[1] = 0;
move16();
#endif
}
- else
+ ELSE
{
/* find the index for the scale/truncation */
i = 1;
- while ( index2 >= (Word32) offset_scale2[i] )
+ move16();
+ WHILE( GE_32( index2, (Word32) offset_scale2[i] ) )
{
i++;
}
idx_scale = i - 1;
- index2 -= offset_scale2[idx_scale];
+ move16();
+ index2 = L_sub( index2, offset_scale2[idx_scale] );
/* find the index of the leader vector */
i = 1;
- while ( index2 >= (Word32) table_no_cv[i] )
+ move16();
+ WHILE( GE_32( index2, (Word32) table_no_cv[i] ) )
{
i++;
}
- // decode_comb((Word32)(index2 - table_no_cv[i - 1]), &x_lvq[LATTICE_DIM], i - 1);
decode_comb_fx( (Word32) ( index2 - table_no_cv[i - 1] ), &x_lvq[LATTICE_DIM], i - 1 );
scales_mslvq[1] = p_scales[mode_glb * len_scales + MAX_NO_SCALES + idx_scale];
+ move16();
// for (i = LATTICE_DIM; i < 2 * LATTICE_DIM; i++)
//{
// //x_lvq[i] *= scale;
@@ -629,28 +643,26 @@ Word16 deindex_lvq_ivas_fx(
IF( EQ_16( sf_flag, 1 ) )
{
- // mode_glb = add(offset_lvq_modes_SN_fx[mode], offset_in_lvq_mode_SN_fx[mode][sub(no_bits, min_lat_bits_SN_fx[mode])]);
- if ( mode < 6 ) /* for NB */
+ IF( LT_16( mode, 6 ) ) /* for NB */
{
- mode_glb = offset_lvq_modes_SN[mode] + offset_in_lvq_mode_SN[mode][no_bits - min_lat_bits_SN[mode]];
+ mode_glb = add( offset_lvq_modes_SN[mode], offset_in_lvq_mode_SN[mode][sub( no_bits, min_lat_bits_SN[mode] )] );
}
- else
+ ELSE
{
- mode_glb = offset_lvq_modes_SN[mode] + no_bits - min_lat_bits_SN[mode]; /* there is granularity of 1 bit */
+ mode_glb = add( offset_lvq_modes_SN[mode], sub( no_bits, min_lat_bits_SN[mode] ) ); /* there is granularity of 1 bit */
}
p_scales = &scales_ivas_fx[0][0]; // Q11
move16();
}
ELSE
{
- // mode_glb = add(offset_lvq_modes_pred_fx[mode], offset_in_lvq_mode_pred_fx[mode][sub(no_bits,min_lat_bits_pred_fx[mode])]);
- if ( ( mode < 6 ) || ( mode == 12 ) ) /* for NB */
+ IF( ( LT_16( mode, 6 ) ) || ( EQ_16( mode, 12 ) ) ) /* for NB */
{
- mode_glb = offset_lvq_modes_pred[mode] + offset_in_lvq_mode_pred[mode][no_bits - min_lat_bits_pred[mode]];
+ mode_glb = add( offset_lvq_modes_pred[mode], offset_in_lvq_mode_pred[mode][sub( no_bits, min_lat_bits_pred[mode] )] );
}
- else
+ ELSE
{
- mode_glb = offset_lvq_modes_pred[mode] + no_bits - min_lat_bits_pred[mode];
+ mode_glb = add( offset_lvq_modes_pred[mode], sub( no_bits, min_lat_bits_pred[mode] ) );
}
p_scales = &scales_p_ivas_fx[0][0]; // Q11
move16();
@@ -678,6 +690,7 @@ Word16 deindex_lvq_ivas_fx(
/* Increase calculation accuracy by shifting more to the left and using rounding instead of truncation*/
L_tmp = L_shl( Mult_32_16( L_tmp, shl( sigma_MSLVQ_fx[mode][i], 3 ) ), 15 ); /* Q13 + Q2 +x2.56 -Q15 */
x_lvq[i] = round_fx( L_tmp );
+ move16();
}
}
IF( scales_mslvq[1] )
@@ -687,6 +700,7 @@ Word16 deindex_lvq_ivas_fx(
L_tmp = L_mult( x_lvq[i], scales_mslvq[1] ); /* Q1+Q11+Q1 = Q13 */
L_tmp = L_shl( Mult_32_16( L_tmp, shl( sigma_MSLVQ_fx[mode][i], 3 ) ), 15 ); /* Q13 + Q2 +x2.56 -Q15 */
x_lvq[i] = round_fx( L_tmp );
+ move16();
}
}
}
@@ -700,6 +714,7 @@ Word16 deindex_lvq_ivas_fx(
L_tmp = L_mult( x_lvq[i], scales_mslvq[0] ); /* Q1+Q11+Q1 = Q13 */
L_tmp = L_shl( Mult_32_16( L_tmp, shl( sigma_p_ivas_fx[mode][i], 3 ) ), 15 ); /* Q13 + Q2 +x2.56 -Q15 */
x_lvq[i] = round_fx( L_tmp );
+ move16();
}
}
IF( scales_mslvq[1] )
@@ -709,6 +724,7 @@ Word16 deindex_lvq_ivas_fx(
L_tmp = L_mult( x_lvq[i], scales_mslvq[1] ); /* Q1+Q11+Q1 = Q13 */
L_tmp = L_shl( Mult_32_16( L_tmp, shl( sigma_p_ivas_fx[mode][i], 3 ) ), 15 ); /* Q13 + Q2 +x2.56 -Q15 */
x_lvq[i] = round_fx( L_tmp );
+ move16();
}
}
}
@@ -757,12 +773,14 @@ Word16 deindex_lvq_cng_fx(
L_tmp = L_mult( x_lvq[i], scales_mslvq[0] ); /* Q1+Q11+Q1 = Q13 */
L_tmp = L_shl( Mult_32_16( L_tmp, shl( sigma_MSLVQ_fx[mode][i], 3 ) ), 15 ); /* Q13 + Q2 +x2.56 -Q15 */
x_lvq[i] = round_fx( L_tmp );
+ move16();
}
FOR( i = LATTICE_DIM; i < 2 * LATTICE_DIM; i++ )
{
L_tmp = L_mult( x_lvq[i], scales_mslvq[1] ); /* Q1+Q11+Q1 = Q13 */
L_tmp = L_shl( Mult_32_16( L_tmp, shl( sigma_MSLVQ_fx[mode][i], 3 ) ), 15 ); /* Q13 + Q2 +x2.56 -Q15 */
x_lvq[i] = round_fx( L_tmp );
+ move16();
}
/* check if permutting needed */
@@ -815,12 +833,14 @@ Word16 deindex_lvq_cng_ivas_fx(
L_tmp = L_mult( x_lvq[i], scales_mslvq[0] ); /* Q1+Q11+Q1 = Q13 */
L_tmp = L_shl( Mult_32_16( L_tmp, shl( sigma_MSLVQ_fx[mode][i], 3 ) ), 15 ); /* Q13 + Q2 +x2.56 -Q15 */
x_lvq[i] = round_fx( L_tmp );
+ move16();
}
FOR( i = LATTICE_DIM; i < 2 * LATTICE_DIM; i++ )
{
L_tmp = L_mult( x_lvq[i], scales_mslvq[1] ); /* Q1+Q11+Q1 = Q13 */
L_tmp = L_shl( Mult_32_16( L_tmp, shl( sigma_MSLVQ_fx[mode][i], 3 ) ), 15 ); /* Q13 + Q2 +x2.56 -Q15 */
x_lvq[i] = round_fx( L_tmp );
+ move16();
}
/* check if permutting needed */
@@ -1248,29 +1268,31 @@ void deindex_lvq_SHB_fx(
{
/* create offsets */
offsets[0] = 0;
+ move32();
FOR( i = 0; i < MAX_NO_SCALES; i++ )
{
offsets[i + 1] = table_no_cv[p_no_lead[i]] + offsets[i];
+ move32();
}
/* find idx_scale */
idx_scale = 0;
WHILE( (Word16) i <= MAX_NO_SCALES && index >= offsets[idx_scale] )
{
- idx_scale++;
+ idx_scale = add( idx_scale, 1 );
}
- idx_scale--;
- index -= offsets[idx_scale];
+ idx_scale = sub( idx_scale, 1 );
+ index = L_sub( index, offsets[idx_scale] );
/* find idx_leader */
i = 1;
- WHILE( index > table_no_cv[i] )
+ WHILE( GT_32( index, table_no_cv[i] ) )
{
- i++;
+ i = add( i, 1 );
}
- i = i - 1;
+ i = sub( i, 1 );
- decode_comb_fx( (Word32) ( index - table_no_cv[i] - 1 ), out, i );
+ decode_comb_fx( (Word32) ( L_sub( L_sub( index, table_no_cv[i] ), 1 ) ), out, i );
scale = p_scales[idx_scale];
FOR( i = 0; i < LATTICE_DIM; i++ )
diff --git a/lib_com/nelp_fx.c b/lib_com/nelp_fx.c
index 841280fa006e5958f5847a6f2df847be3fe36c60..690db58652d44357ae0ccff452100c9099c0f741 100644
--- a/lib_com/nelp_fx.c
+++ b/lib_com/nelp_fx.c
@@ -33,7 +33,7 @@
#include
#include "options.h"
#include "rom_com.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*===================================================================*/
@@ -71,7 +71,9 @@ Word16 dequantize_uvg_fx(
Word16 frac, exp, sc;
Word32 L_tmp;
Word16 Q_gain = 0;
+ move16();
+ test();
IF( EQ_16( bwidth_fx, NB ) )
{
UVG1CB = UVG1CB_NB_FX;
@@ -92,6 +94,7 @@ Word16 dequantize_uvg_fx(
move16();
}
+ test();
IF( !do_scale )
{
sc = 11;
@@ -126,6 +129,7 @@ Word16 dequantize_uvg_fx(
frac = L_Extract_lc( L_tmp, &exp );
frac = extract_l( Pow2( 14, frac ) );
G[i * 5 + k] = round_fx( L_shl( L_mult( frac, UVG2CB1[iG2[i]][k] ), exp - sc ) ); /* Q0 */
+ move16();
}
ELSE IF( EQ_16( i, 1 ) )
{
@@ -134,6 +138,7 @@ Word16 dequantize_uvg_fx(
frac = L_Extract_lc( L_tmp, &exp );
frac = extract_l( Pow2( 14, frac ) );
G[i * 5 + k] = round_fx( L_shl( L_mult( frac, UVG2CB2[iG2[i]][k] ), exp - sc ) ); /* Q0 */
+ move16();
}
}
}
@@ -235,6 +240,7 @@ void generate_nelp_excitation_fx(
L16 = mult_r( L16, 0x6EDA ); /* Q13 */
output[i * 25 + I[j]] = round_fx( L_shl( L_mult( L16, Gains[i] ), 2 ) ); /* Q_exc */
+ move16();
}
FOR( ; j < len; j++ )
{
diff --git a/lib_com/options.h b/lib_com/options.h
index baee66e80a1f2a44b55a1c994d0fcceec80db59a..60ada8b87c408f2a7de5f1f27a39d561f0097f56 100644
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -36,7 +36,7 @@
#ifndef OPTIONS_H
#define OPTIONS_H
-#define DEBUGGING /*allows message printed out during run time */
+//#define DEBUGGING /*allows message printed out during run time */
#ifdef DEBUGGING
#define DEBUG_MODE_INFO /* define to output most important parameters to the subdirectory "res/" */
#define DEBUG_MODE_INFO_TWEAK /* enable command line switch to specify subdirectory for debug info output inside "./res/" */
@@ -45,7 +45,6 @@
#include "stl.h"
-
/* clang-format off */
/* ################### Start compiler switches ######################## */
@@ -80,6 +79,9 @@
#define FIX_1027_GSC_INT_OVERFLOW /* VA: issue 2207: overflow in GSC */
#define NONBE_FIX_1096_NAN_VALUES_IN_DIRAC_TO_STEREO /* FhG: avoid sidegain DFT-Stereo param to be larger than 1 when converting from Dirac parameters */
#define NON_BE_1055_RESET_LP_MEMORIES /* VA: issue 1055: Correctly reset LP filter MA and AR memories in bitrate switching */
+#define NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING /* VA: Add fix point bit allocation for special GSC mode such that float and fixed point have the same final bit allocation */
+#define NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE /* VA: issue 1132: prevent division by extremely low energy value in SWB TBE */
+#define NON_BE_FIX_807_MASA_DTX_BRSW /* Nokia: adds fix to check existence of DTX encoder for secondary channel in TD mode */
/* #################### End FIXES switches ############################ */
@@ -95,6 +97,7 @@
#define FIX_785_REMOVE_DEAD_CODE /* VA: issue 785: remove dead code */
#define FIX_852_FIX_HANDLE_DEREF /* VA: issue 852: Fix missing handle dereferencing of hIsmMetadaData in ivas_ism_metadata_close() */
#define FIX_901_PARAMMC_DEAD_CODE /* FhG: issue 901: remove dead ParamMC code */
+#define IVAS_ENH32_CADENCE_CHANGES
/* #################### End BE switches ################################## */
@@ -112,6 +115,7 @@
#define IVAS_FLOAT_FIXED
#ifdef IVAS_FLOAT_FIXED
#define MSAN_FIX
+#define FIX_818_COMPLEXITY_IMPROV /* Fix for issue 818 */
#endif
#define ISM_DISABLE
#define FIX_TMP_714
@@ -134,6 +138,9 @@
#define FIX_QMETADATA_PENALTY /* Nokia: transform penalty calculation in qmetadata into integer operations */
+#define NONBE_MDCT_ST_DTX_SKIP_DEWHITENING_OF_NOISE_SHAPES_ON_SID_FRAMES /* FhG: issue 1133: skip de-whitening of bg noise shape after frameloss period if the first good frame is an SID */
+#define NONBE_MDCT_ST_PLC_DO_NOT_SCALE_OLD_OUT_IF_FIRST_GOOD_IS_SID /* FhG: issue 1133: in TCX PLC, don't scale hHQ_core->old_out after applying fade to noise in burst frame error */
+
/* ##################### End NON-BE switches ########################### */
#define FIX_740_HQ_CORE_OVA // Proposed fix to solve overlap and add issue for HQ_CORE
#define FIX_746 // proposed fix to solve low bit-rate frame boundaries issues
@@ -151,6 +158,13 @@
#define FIX_798_LSF_SECONDARY_CH_MISSING_CODE /* Adding the missing code to properly render the secondary channel of TD stereo*/
#define FIX_798_WRONG_CPY_OF_PITCH /* The copy of the pitch from primary to secondary channel was wrong AND safety check was really wrong */
#define FIX_800_PROPOSAL_HB_LPC_COEFFICIENT /* Proposal to fix wrong shape of TDBWE, #800 */
+<<<<<<< HEAD
+=======
+
+#define FIX_802__NON_BE_DECODING /* Fix possible difference float and fixed point when computing the GSC bit allocation */
+#define FIX_802_1137_1137_GSC_IVAS_FXFLT_DECODING /* VA: ISSUES 802 and 1137 Made sure that float and fixed point GCS bit allocation is the same during IVAS modes */
+#define FIX_810_PREVENT_UNECESSARY_SAT_IN_TC /* VA : Prevent an unnecessary saturation that can happen in TC, have a minimal impact on most cases. Significant improvement for the last segment of LTV when TC is triggered */
+>>>>>>> main
/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
diff --git a/lib_com/parameter_bitmaping.c b/lib_com/parameter_bitmaping.c
index 5b6374ee038e7e6a43e406dffa2b1d84a5d2b167..2be70b058664caabd37b9745bbcea9efbffe1696 100644
--- a/lib_com/parameter_bitmaping.c
+++ b/lib_com/parameter_bitmaping.c
@@ -39,7 +39,7 @@
#include "options.h"
#include "stat_com.h"
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
diff --git a/lib_com/parameter_bitmaping_fx.c b/lib_com/parameter_bitmaping_fx.c
index ee5dd7d73761190a476adef39d200af70f4b7ac1..e66d7b60342f8ea86197d8aae57f22814e2bf24a 100644
--- a/lib_com/parameter_bitmaping_fx.c
+++ b/lib_com/parameter_bitmaping_fx.c
@@ -2,7 +2,7 @@
#include
#include "options.h"
#include "stat_com.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
/** Get nBits long value from bitstream into *pStream. */
diff --git a/lib_com/phase_dispersion_fx.c b/lib_com/phase_dispersion_fx.c
index 5a1c3d5108b0f3748e0c53e84bcfab0e317ccbe1..b7ca7b739b9f8a93a780a2843c59f0c065b142ce 100644
--- a/lib_com/phase_dispersion_fx.c
+++ b/lib_com/phase_dispersion_fx.c
@@ -4,8 +4,7 @@
#include
#include "options.h" /* EV-VBR compilation switches */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "rom_com.h"
@@ -110,6 +109,7 @@ void phase_dispersion(
FOR( i = 0; i < L_subfr; i++ )
{
x32[i] = L_deposit_h( code[i] );
+ move32();
}
BASOP_rfft( x32, L_subfr, &j, -1 );
diff --git a/lib_com/ppp_fx.c b/lib_com/ppp_fx.c
index 673ffd469acf8650234cc94293239085ee064d24..390c0a47ce1b5ec84c118f3911a939ba84baeb83 100644
--- a/lib_com/ppp_fx.c
+++ b/lib_com/ppp_fx.c
@@ -33,7 +33,7 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*===================================================================*/
/* FUNCTION : Interpol_delay_fx () */
diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c
index 7047d643f596decc0ff942cc3533d7517ef4f90c..21bd9f541e420387a60b6e141a80cc2bd6ef7250 100644
--- a/lib_com/pred_lt4_fx.c
+++ b/lib_com/pred_lt4_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*-------------------------------------------------------------------*
@@ -164,6 +163,7 @@ void pred_lt4_tc_fx(
#ifdef BASOP_NOGLOB
L_sum = L_shl_o( L_sum, 1, &Overflow ); /*Q0h */
excO[j] = round_fx_o( L_sum, &Overflow );
+ move16();
#else
L_sum = L_shl( L_sum, 1 ); /*Q0h */
diff --git a/lib_com/preemph.c b/lib_com/preemph.c
index 89064782f79ea2282394d32d37669a41bb53ad77..decc73f999c246123c1b9bc99dba3302e874d118 100644
--- a/lib_com/preemph.c
+++ b/lib_com/preemph.c
@@ -85,13 +85,17 @@ void preemph_ivas_fx(
Word32 temp;
temp = signal[L - 1];
+ move32();
FOR( i = L - 1; i > 0; i-- )
{
signal[i] = L_sub( signal[i], Mpy_32_16_1( signal[i - 1], mu ) );
+ move32();
}
signal[0] = L_sub( signal[0], Mpy_32_16_1( *mem, mu ) );
+ move32();
*mem = temp;
+ move32();
return;
}
diff --git a/lib_com/preemph_fx.c b/lib_com/preemph_fx.c
index 21dd047ce330a9e6c07b0710fc45c4b06608d12b..63de35dca4110d2b0c9948e50d1bf04d11878c1f 100644
--- a/lib_com/preemph_fx.c
+++ b/lib_com/preemph_fx.c
@@ -3,8 +3,7 @@
====================================================================================*/
#include
#include "options.h" /* Compilation switches */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------*
* preemph_copy_fx()
*
@@ -66,6 +65,7 @@ void E_UTIL_f_preemph2( Word16 shift, Word16 *signal, const Word16 mu, const Wor
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
temp = signal[lg - 1];
move16();
@@ -77,6 +77,7 @@ void E_UTIL_f_preemph2( Word16 shift, Word16 *signal, const Word16 mu, const Wor
L_tmp = L_msu0_o( L_tmp, signal[i - 1], mu, &Overflow );
L_tmp = L_shl_o( L_tmp, add( shift, 1 ), &Overflow );
signal[i] = round_fx_o( L_tmp, &Overflow );
+ move16();
#else
L_tmp = L_msu0( L_tmp, signal[i - 1], mu );
L_tmp = L_shl( L_tmp, add( shift, 1 ) );
@@ -89,6 +90,7 @@ void E_UTIL_f_preemph2( Word16 shift, Word16 *signal, const Word16 mu, const Wor
L_tmp = L_msu0_o( L_tmp, *mem, mu, &Overflow );
L_tmp = L_shl_o( L_tmp, add( shift, 1 ), &Overflow );
signal[0] = round_fx_o( L_tmp, &Overflow );
+ move16();
#else
L_tmp = L_msu0( L_tmp, *mem, mu );
L_tmp = L_shl( L_tmp, add( shift, 1 ) );
@@ -143,13 +145,14 @@ Word16 E_UTIL_f_preemph3( Word16 *signal, const Word16 mu, const Word16 lg, Word
L_tmp = L_msu( L_tmp, signal[i - 1], mus );
L_tmp = L_shl( L_tmp, Q_new );
signal[i] = round_fx( L_tmp );
+ move16();
}
L_tmp = L_mult( signal[0], QVal );
L_tmp = L_msu( L_tmp, *mem, mus );
L_tmp = L_shl( L_tmp, Q_new );
signal[0] = round_fx( L_tmp );
-
+ move16();
*mem = tmp_fixed;
move16();
diff --git a/lib_com/prot.h b/lib_com/prot.h
index d33a848043a4b39b032c3c08121edd0ca2f72e31..12828f0ddefb815916f911f64691e616fcb22b2f 100644
--- a/lib_com/prot.h
+++ b/lib_com/prot.h
@@ -166,18 +166,6 @@ float sum2_f(
const int16_t lvec /* i : length of input vector */
);
-#ifdef IVAS_FLOAT_FIXED
-Word32 sum2_f_32_fx(
- const Word32 *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- Word16 gb );
-
-Word32 sum2_32_fx(
- const Word32 *vec, /* i : input vector */
- const Word16 lvec, /* i : length of input vector */
- Word16 *e );
-#endif
-
void set_c(
int8_t y[], /* i/o: Vector to set */
const int8_t a, /* i : Value to set the vector to */
@@ -276,14 +264,12 @@ int16_t minimum(
float *min_val /* o : minimum value in the input vector */
);
-#ifndef IVAS_FLOAT_FIXED
/*! r: index of the minimum value in the input vector */
int16_t minimum_s(
const int16_t *vec, /* i : Input vector */
const int16_t lvec, /* i : Vector length */
int16_t *min_val /* o : minimum value in the input vector */
);
-#endif
/*! r: return index with max energy value in vector */
int16_t emaximum(
@@ -336,15 +322,6 @@ void v_sub(
const int16_t N /* i : Vector length */
);
-#ifdef IVAS_FLOAT_FIXED
-void v_mult_fixed(
- const Word32 x1[], /* i : Input vector 1 */
- const Word32 x2[], /* i : Input vector 2 */
- Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */
- const Word16 N /* i : Vector length */
-);
-#endif
-
void v_mult(
const float x1[], /* i : Input vector 1 */
const float x2[], /* i : Input vector 2 */
@@ -365,14 +342,6 @@ void v_sub_s(
int16_t y[], /* o : Output vector that contains vector 1 - vector 2 */
const int16_t N /* i : Vector length */
);
-#ifdef IVAS_FLOAT_FIXED
-void v_sub_s16_fx(
- const Word16 x1[], /* i : Input vector 1 */
- const Word16 x2[], /* i : Input vector 2 */
- Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */
- const Word16 N /* i : Vector length */
-);
-#endif // IVAS_FLOAT_FIXED
/*! r: index of the winning codeword */
int16_t squant(
@@ -499,22 +468,6 @@ void delay_signal_float(
const int16_t delay /* i : delay in samples */
);
-#ifdef IVAS_FLOAT_FIXED
-void delay_signal_fx(
- Word32 x[], /* i/o: signal to be delayed */
- const int16_t len, /* i : length of the input signal */
- Word32 mem[], /* i/o: synchronization memory */
- const int16_t delay /* i : delay in samples */
-);
-void delay_signal_q_adj_fx(
- Word32 x[], /* i/o: signal to be delayed */
- const int16_t len, /* i : length of the input signal */
- Word32 mem[], /* i/o: synchronization memory */
- const int16_t delay, /* i : delay in samples */
- const Word16 q_x,
- const Word16 q_mem );
-#endif
-
ivas_error push_indice(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
int16_t id, /* i : ID of the indice */
@@ -522,17 +475,33 @@ ivas_error push_indice(
int16_t nb_bits /* i : number of bits used to quantize the indice */
);
+#ifdef IVAS_FLOAT_FIXED
+ivas_error push_next_indice(
+ BSTR_ENC_HANDLE hBstr,
+ UWord16 value, /* i : value of the quantized indice */
+ Word16 nb_bits /* i : number of bits used to quantize the indice */
+);
+#else
ivas_error push_next_indice(
BSTR_ENC_HANDLE hBstr,
uint16_t value, /* i : value of the quantized indice */
int16_t nb_bits /* i : number of bits used to quantize the indice */
);
+#endif // IVAS_FLOAT_FIXED
+#ifdef IVAS_FLOAT_FIXED
+ivas_error push_next_bits(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */
+ const Word16 nb_bits /* i : number of bits to pack */
+);
+#else
ivas_error push_next_bits(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const uint16_t bits[], /* i : bit buffer to pack, sequence of single bits */
const int16_t nb_bits /* i : number of bits to pack */
);
+#endif // IVAS_FLOAT_FIXED
/*! r: maximum number of indices */
int16_t get_ivas_max_num_indices(
@@ -931,17 +900,6 @@ void lsp2lsf(
const int32_t Fs /* i : sampling frequency */
);
-#ifdef IVAS_FLOAT_FIXED
-void lsf2lsp_32_fx(
- const Word32 lsf_fx[], /* i : isf[m] normalized (range: 0<=val<=fs/2) */
- Word16 lsf_q_fx,
- Word16 lsp_fx[], /* o : isp[m] (range: -1<=val<1) */
- Word16 *lsp_q_fx,
- const Word16 m, /* i : LPC order */
- const Word32 Fs /* i : sampling frequency */
-);
-#endif
-
void lsf2lsp(
const float lsf[], /* i : isf[m] normalized (range: 0<=val<=fs/2) */
float lsp[], /* o : isp[m] (range: -1<=val<1) */
@@ -1759,7 +1717,6 @@ void diff_envelope_coding(
int16_t *difidx /* o : differential code */
);
-#ifndef IVAS_FLOAT_FIXED
/*! r: Number of bits */
int16_t decode_envelope_indices(
Decoder_State *st, /* i/o: decoder state structure */
@@ -1770,9 +1727,7 @@ int16_t decode_envelope_indices(
const int16_t flag_HQ2, /* i : indicator of HQ2 core */
const int16_t is_transient /* i : transient flag */
);
-#endif
-#ifndef IVAS_FLOAT_FIXED
/*! r: Number of bits */
void dequantize_norms(
Decoder_State *st, /* i/o: decoder state structure */
@@ -1782,7 +1737,6 @@ void dequantize_norms(
int16_t *ynrm, /* o : Decoded norm indices */
int16_t *normqlg2 /* o : Log2 of decoded norms */
);
-#endif
void hq_configure(
const int16_t length, /* i : Frame length */
@@ -1829,7 +1783,6 @@ int16_t hq_classifier_enc(
int16_t *hqswb_clas /* o : HQ class */
);
-#ifndef IVAS_FLOAT_FIXED
/*! r: Consumed bits */
int16_t hq_classifier_dec(
Decoder_State *st, /* i/o: decoder state structure */
@@ -1838,7 +1791,6 @@ int16_t hq_classifier_dec(
int16_t *is_transient, /* o : Transient flag */
int16_t *hqswb_clas /* o : HQ class */
);
-#endif
void hq_bit_allocation(
const int32_t core_brate, /* i : Core bitrate */
@@ -2366,7 +2318,7 @@ void pre_proc(
float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */
int16_t *hq_core_type /* o : HQ core type */
);
-#endif
+
/*! r: HQ_CORE/TCX_20_CORE decision */
int16_t mdct_classifier(
@@ -2681,19 +2633,7 @@ void swb_tbe_enc(
float *White_exc16k, /* o : shaped white excitation for the FB TBE */
const float pitch_buf[] /* i : pitch for each subframe */
);
-#ifdef IVAS_FLOAT_FIXED
-void ivas_swb_tbe_dec_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
- const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation */
- Word16 Q_exc,
- const Word16 voice_factors_fx[], /* i : voicing factors */
- const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis */
- Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE */
- Word32 *synth_fx, /* o : SHB synthesis/final synthesis */
- Word16 *pitch_buf_fx,
- Word16 *Q_white_exc );
-#endif
+
void swb_tbe_dec(
Decoder_State *st, /* i/o: decoder state structure */
STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
@@ -2942,18 +2882,6 @@ void swb_bwe_dec_flt(
const int16_t output_frame /* i : frame length */
);
-#ifdef IVAS_FLOAT_FIXED
-Word16 swb_bwe_dec_fx32(
- Decoder_State *st, /* i/o: decoder state structure */
- Word32 output[], /* i : synthesis @internal Fs Q11 */
- Word32 *synth, /* i : ACELP core synthesis/final synthesis Q11 */
- Word32 *hb_synth, /* o : SHB synthesis/final synthesis */
- Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- Word16 output_frame /* i : frame length */
-);
-#endif // IVAS_FLOAT_FIXED
-
-
void hr_bwe_dec_init_flt(
HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */
);
@@ -3721,7 +3649,19 @@ 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 */
@@ -4632,7 +4572,6 @@ void signaling_enc_rf(
Encoder_State *st /* i/o: encoder state structure */
);
-#ifndef IVAS_FLOAT_FIXED
ivas_error acelp_core_dec(
Decoder_State *st, /* i/o: Decoder state structure */
float output[], /* o : synthesis @internal Fs */
@@ -4656,33 +4595,6 @@ ivas_error acelp_core_dec(
STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
const int16_t read_sid_info /* i : read SID info flag */
);
-#endif
-
-#ifdef IVAS_FLOAT_FIXED
-ivas_error acelp_core_dec_ivas_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- Word16 output[], /* o : synthesis @internal Fs */
- Word16 synth[], /* o : synthesis */
- Word16 save_hb_synth[], /* o : HB synthesis */
- Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
- const int16_t sharpFlag, /* i : formant sharpening flag */
- Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */
- int16_t *unbits, /* o : number of unused bits */
- int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */
- const Word16 tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */
- const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
- const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- const int16_t last_element_mode, /* i : last element mode */
- const int32_t last_element_brate, /* i : last element bitrate */
- const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
- const int16_t nchan_out, /* i : number of output channels */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
- const int16_t read_sid_info /* i : read SID info flag */
-);
-#endif
void bass_psfilter_init(
BPF_DEC_HANDLE hBPF /* o : BPF data handle */
@@ -5298,12 +5210,6 @@ ivas_error init_decoder(
const MC_MODE mc_mode /* i : MC mode */
);
-#ifdef IVAS_FLOAT_FIXED
-void destroy_cldfb_decoder_ivas_fx(
- Decoder_State *st /* o : Decoder static variables structure */
-);
-#endif // IVAS_FLOAT_FIXED
-
void destroy_cldfb_decoder_flt(
Decoder_State *st /* o : Decoder static variables structure */
);
@@ -5381,17 +5287,6 @@ void wtda(
const int16_t L /* i : length */
);
-#ifdef IVAS_FLOAT_FIXED
-void wtda_fx32(
- const Word32 *new_audio, /* i : input audio Q11 */
- Word32 *wtda_audio, /* o : windowed audio Q11 */
- Word32 *old_wtda, /* i/o: windowed audio from previous frame Q11 */
- const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */
- const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
- const Word16 L /* i : length */
-);
-#endif
-
void wtda_ext(
const float *new_audio, /* i : input audio */
float *wtda_audio, /* o : windowed audio */
@@ -5449,7 +5344,6 @@ void logqnorm(
const int16_t N, /* i : sub-vector size */
const float *thren );
-#ifndef IVAS_FLOAT_FIXED
void huff_dec(
Decoder_State *st, /* i/o: decoder state structure */
const int16_t N, /* i : Number of codewords to decode */
@@ -5460,7 +5354,6 @@ void huff_dec(
const int16_t *huff_tab, /* i : Huffman table order by codeword lengths */
int16_t *index /* o : Decoded index */
);
-#endif
void calc_norm(
const float *x, /* i : Input vector. */
@@ -5601,38 +5494,30 @@ void hq_hr_dec(
);
-#ifndef IVAS_FLOAT_FIXED
void hdecnrm_context(
Decoder_State *st, /* i/o: decoder state structure */
const int16_t N, /* i : number of norms */
int16_t *index, /* o : indices of quantized norms */
int16_t *n_length /* o : decoded stream length */
);
-#endif
-#ifndef IVAS_FLOAT_FIXED
void hdecnrm_tran(
Decoder_State *st, /* i/o: decoder state structure */
const int16_t N, /* i : number of norms */
int16_t *index /* o : indices of quantized norms */
);
-#endif
-#ifndef IVAS_FLOAT_FIXED
void hdecnrm_resize(
Decoder_State *st, /* i/o: decoder state structure */
const int16_t N, /* i : number of SFMs */
int16_t *index /* o : norm quantization index vector */
);
-#endif
-#ifndef IVAS_FLOAT_FIXED
void hdecnrm(
Decoder_State *st, /* i/o: decoder state structure */
const int16_t N, /* i : number of norms */
int16_t *index /* o : indices of quantized norms */
);
-#endif
/*! r: index of last band */
int16_t find_last_band(
@@ -6072,18 +5957,6 @@ ivas_error core_switching_post_dec(
const int16_t nchan_out, /* i : number of output channels */
const int16_t last_element_mode /* i : element mode of previous frame */
);
-#ifdef IVAS_FLOAT_FIXED
-ivas_error core_switching_pre_dec_ivas_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- const Word16 output_frame, /* i : frame length */
- const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */
- const Word16 nchan_out, /* i : number of output channels */
- const Word16 last_element_mode, /* i : last_element_mode */
- const Word32 last_element_brate, /* i : last element bitrate */
- Word16 Q_old_synthFB,
- Word16 *Q_olapBufferSynth,
- Word16 *Q_olapBufferSynth2 );
-#endif // IVAS_FLOAT_FIXED
ivas_error core_switching_pre_dec(
Decoder_State *st, /* i/o: decoder state structure */
@@ -6921,14 +6794,6 @@ void hp20_flt(
Float32 mem[],
const Word32 Fs );
-#ifdef IVAS_FLOAT_FIXED
-void hp20_fix32(
- Word32 signal_fx[],
- const Word16 lg,
- Word32 mem_fx[],
- const Word32 Fs );
-#endif // IVAS_FLOAT_FIXED
-
void ham_cos_window_flt(
float *fh,
const int16_t n1,
@@ -6968,21 +6833,6 @@ void enc_acelp_tcx_main(
const int16_t vad_hover_flag /* i : VAD hangover flag */
);
-#ifdef IVAS_FLOAT_FIXED
-void getTCXMode_ivas_fx(
- Decoder_State *st, /* i/o: decoder memory state */
- Decoder_State *st0, /* i : bitstream */
- const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
-);
-
-void getTCXWindowing_ivas_fx(
- const Word16 core, /* i : current frame mode */
- const Word16 last_core, /* i : last frame mode */
- const Word16 element_mode, /* i : element mode */
- TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */
- Decoder_State *st0 /* i : bitstream */
-);
-#else
void getTCXMode_ivas(
Decoder_State *st, /* i/o: decoder memory state */
Decoder_State *st0, /* i : bitstream */
@@ -6996,7 +6846,7 @@ void getTCXWindowing_ivas(
TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */
Decoder_State *st0 /* i : bitstream */
);
-#endif
+//#endif
void getLPCparam_ivas(
Decoder_State *st, /* i/o: decoder memory state */
@@ -7410,7 +7260,7 @@ void TNSAnalysis(
TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */
const float ltp_gain, /* i : ltp gain */
STnsData *pTnsData, /* o : TNS data */
- int16_t *pfUseTns, /* o : Flag indicating if TNS is used */
+ int8_t *pfUseTns, /* o : Flag indicating if TNS is used */
float *predictionGain /* o : TNS prediction gain */
);
@@ -7428,7 +7278,7 @@ void ShapeSpectrum(
const int16_t L_frame_glob, /* i : frame length */
int16_t L_spec, /* i : length of the spectrum */
float spectrum[], /* i/o: MDCT spectrum */
- const int16_t fUseTns, /* i : Flag indicating if TNS is used */
+ const int8_t fUseTns, /* i : Flag indicating if TNS is used */
Encoder_State *st, /* i/o: encoder state structure */
float *scf /* i : scale factors */
);
@@ -7474,7 +7324,6 @@ void ACcontextMapping_encode2_no_mem_s17_LC(
int16_t resQMaxBits,
CONTEXT_HM_CONFIG *hm_cfg );
-#ifndef IVAS_FLOAT_FIXED
int16_t ACcontextMapping_decode2_no_mem_s17_LC_ivas(
Decoder_State *st, /* i/o: decoder state */
int16_t *x, /* o : decoded spectrum */
@@ -7483,7 +7332,6 @@ int16_t ACcontextMapping_decode2_no_mem_s17_LC_ivas(
int16_t resQMaxBits, /* i : residual coding maximum bits */
CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */
);
-#endif
int16_t ACcontextMapping_encode2_estimate_no_mem_s17_LC(
const int16_t *x,
@@ -7503,7 +7351,6 @@ void RCcontextMapping_encode2_no_mem_s17_LCS(
const int16_t resQMaxBits,
CONTEXT_HM_CONFIG *hm_cfg );
-#ifndef IVAS_FLOAT_FIXED
int16_t RCcontextMapping_decode2_no_mem_s17_LCS(
Decoder_State *st, /* i/o: decoder state */
int16_t *x, /* o : decoded spectrum */
@@ -7512,7 +7359,6 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS(
const int16_t resQMaxBits, /* i : residual coding maximum bits */
CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */
);
-#endif
int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
int16_t *x, /* Spectral coefficients */
@@ -7684,12 +7530,12 @@ float SQ_gain_estimate(
void tcx_scalar_quantization(
- float *x, /* i : input coefficients */
- int16_t *xq, /* o : quantized coefficients */
- const int16_t L_frame, /* i : frame length */
- const float gain, /* i : quantization gain */
- const float offset, /* i : rounding offset (deadzone) */
- int16_t *memQuantZeros, /* o : coefficients set to 0 */
+ float *x, /* i : input coefficients */
+ int16_t *xq, /* o : quantized coefficients */
+ const int16_t L_frame, /* i : frame length */
+ const float gain, /* i : quantization gain */
+ const float offset, /* i : rounding offset (deadzone) */
+ int8_t *memQuantZeros, /* o : coefficients set to 0 */
const int16_t tcxonly );
int16_t tcx_scalar_quantization_rateloop(
@@ -7698,7 +7544,7 @@ int16_t tcx_scalar_quantization_rateloop(
const int16_t L_frame, /* i : frame length */
float *gain, /* i/o: quantization gain */
float offset, /* i : rounding offset (deadzone) */
- int16_t *memQuantZeros, /* o : coefficients set to 0 */
+ int8_t *memQuantZeros, /* o : coefficients set to 0 */
int16_t *lastnz_out, /* i/o: last nonzero coeff index */
const int16_t target, /* i : target number of bits */
int16_t *nEncoded, /* o : number of encoded coeff */
@@ -7863,13 +7709,6 @@ int16_t ari_start_decoding_14bits_prm_ivas(
int16_t bp,
Tastat *s );
-#ifdef IVAS_FLOAT_FIXED
-Word16 ari_start_decoding_14bits_prm_ivas_fx(
- const Word16 *ptr,
- Word16 bp,
- Tastat *s );
-#endif
-
void ari_decode_14bits_s17_ext_ivas(
Decoder_State *st,
uint16_t *res,
@@ -7900,7 +7739,7 @@ void powfp_odd2_evs(
Word16 *pout2 /* Q15 */
);
-void tcx_arith_scale_envelope_flt(
+void tcx_arith_scale_envelope_ivas(
const Word16 L_spec_core, /* i : number of lines to scale Q0 */
Word16 L_frame, /* i : number of lines Q0 */
const Word32 env[], /* i : unscaled envelope Q16 */
@@ -7910,7 +7749,7 @@ void tcx_arith_scale_envelope_flt(
Word16 *s_env_e /* o : scaled envelope exponent Q0 */
);
-void tcx_arith_render_envelope_flt(
+void tcx_arith_render_envelope_ivas(
const Word16 A_ind[], /* i : LPC coefficients of signal envelope */
const Word16 L_frame, /* i : number of spectral lines */
const Word16 L_spec, /* i : length of the coded spectrum */
@@ -8909,21 +8748,6 @@ void generate_masking_noise(
const int16_t nchan_out /* i : number of output channels */
);
-#ifdef IVAS_FLOAT_FIXED
-void generate_masking_noise_ivas_fx(
- Word32 *timeDomainBuffer, /* i/o: time-domain signal */
- Word16 *exp_out, /* o : time-domain signal exp */
- HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- const Word16 length, /* i : frame size */
- const Word16 core, /* i : core */
- const Word16 return_noise, /* i : noise is returned instead of added */
- const Word16 secondary, /* i : flag to indicate secondary noise generation */
- const Word16 element_mode, /* i : element mode */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
- const Word16 nchan_out /* i : number of output channels */
-);
-#endif
-
void generate_masking_noise_update_seed(
HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
);
@@ -8941,16 +8765,7 @@ void SynthesisSTFT_dirac_flt(
const int16_t samples_out,
HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
);
-#ifdef IVAS_FLOAT_FIXED
-void SynthesisSTFT_dirac_fx(
- Word32 *fftBuffer, /* i : FFT bins */
- Word32 *timeDomainOutput,
- Word32 *olapBuffer,
- const Word16 *olapWin,
- const Word16 samples_out,
- HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
-);
-#endif
+
void generate_masking_noise_dirac(
HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */
@@ -8972,19 +8787,6 @@ void generate_stereo_masking_noise(
const int16_t nchan_out /* i : number of output channels */
);
-#ifdef IVAS_FLOAT_FIXED
-void generate_stereo_masking_noise_fx(
- Word16 *syn, /* i/o: time-domain signal */
- Word16 Q_syn,
- Decoder_State *st, /* i/o: decoder state structure */
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */
- const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
- const int16_t fadeOut, /* i : only fade out of previous state */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */
- const int16_t nchan_out /* i : number of output channels */
-);
-#endif
-
void apply_scale_flt(
float *scale, /* i : scale factor */
const int16_t bwidth, /* i : audio bandwidth */
@@ -9039,20 +8841,6 @@ void SynthesisSTFT_flt(
const int16_t nchan_out /* i : number of output channels */
);
-#ifdef IVAS_FLOAT_FIXED
-void SynthesisSTFT_fx(
- Word32 *fftBuffer, /* i : FFT bins */
- Word16 Q_in,
- Word32 *timeDomainOutput,
- Word32 *olapBuffer,
- const Word16 *olapWin,
- const int16_t tcx_transition,
- HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
- const int16_t element_mode, /* i : element mode */
- const int16_t nchan_out /* i : number of output channels */
-);
-#endif
-
float rand_gauss_flt(
float *x,
int16_t *seed );
@@ -9111,12 +8899,6 @@ void FdCng_decodeSID(
Decoder_State *st /* i/o: decoder state structure */
);
-#ifdef IVAS_FLOAT_FIXED
-void FdCng_decodeSID_ivas_fx(
- Decoder_State *st /* i/o: decoder state structure */
-);
-#endif
-
void FdCng_exc_flt(
HANDLE_FD_CNG_COM hFdCngCom,
int16_t *CNG_mode,
@@ -9358,6 +9140,11 @@ void configureCldfb_ivas(
const int32_t sampling_rate /* i : sampling rate */
);
+void configureCldfb_ivas_enc(
+ HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */
+ const int32_t sampling_rate /* i : sampling rate */
+);
+
void analysisCldfbEncoder_ivas(
Encoder_State *st, /* i/o: encoder state structure */
const float *timeIn,
@@ -9366,6 +9153,17 @@ void analysisCldfbEncoder_ivas(
float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
float *ppBuf_Ener );
+void analysisCldfbEncoder_ivas_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 *timeIn,
+ Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word32 *ppBuf_Ener,
+ Word16 *enerBuffSum_exp,
+ CLDFB_SCALE_FACTOR *scale );
+
ivas_error openCldfb_ivas(
HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
CLDFB_TYPE type, /* i : analysis or synthesis */
@@ -9373,24 +9171,21 @@ ivas_error openCldfb_ivas(
CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
);
+ivas_error openCldfb_ivas_enc(
+ HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */
+ CLDFB_TYPE type, /* i : analysis or synthesis */
+ const int32_t sampling_rate, /* i : sampling rate */
+ CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */
+);
+
void resampleCldfb_ivas(
HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */
const int32_t newSamplerate /* i : new samplerate to operate */
);
-#ifdef IVAS_FLOAT_FIXED
-ivas_error cldfb_save_memory_ivas_fx(
- HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
-);
-#endif // IVAS_FLOAT_FIXED
ivas_error cldfb_save_memory_ivas(
HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
);
-#ifdef IVAS_FLOAT_FIXED
-void cldfb_restore_memory_ivas_fx(
- HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
-);
-#endif // IVAS_FLOAT_FIXED
void cldfb_restore_memory_ivas(
HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
@@ -9453,7 +9248,6 @@ ivas_error config_acelp1_IVAS(
/*! r: ACELP16k flag */
-#ifndef IVAS_FLOAT_FIXED
int16_t set_ACELP_flag_IVAS(
const int16_t element_mode, /* i : element mode */
const int32_t element_brate, /* i : element bitrate */
@@ -9463,7 +9257,6 @@ int16_t set_ACELP_flag_IVAS(
const int16_t bwidth, /* i : audio bandwidth */
const int16_t cng_type /* i : CNG type */
);
-#endif
void FEC_clas_estim(
const float *syn,
@@ -9706,7 +9499,7 @@ void tcxInvertWindowGrouping_flt(
float xn_buf[],
float spectrum[],
const int16_t L_frame,
- const int16_t fUseTns,
+ const int8_t fUseTns,
const int16_t last_core,
const int16_t index,
const int16_t frame_cnt,
@@ -9921,14 +9714,12 @@ int16_t GetPLCModeDecision(
Decoder_State *st /* i/o: decoder memory state pointer */
);
-#ifndef IVAS_FLOAT_FIXED
void addBassPostFilter(
const float *harm_timeIn,
const int16_t samplesToProcess,
float **rAnalysis,
float **iAnalysis,
HANDLE_CLDFB_FILTER_BANK cldfb );
-#endif
ivas_error TonalMDCTConceal_Init_ivas(
TonalMDCTConcealPtr hTonalMDCTConc,
@@ -10118,15 +9909,11 @@ int16_t getRestrictedMode(
int16_t getMdctWindowLength(
const int16_t fscale );
-#ifdef IVAS_FLOAT_FIXED
-Word16 sr2fscale(
- const Word32 sr_core /* i : internal sampling rate */
-);
-#else
+
int16_t sr2fscale(
const int32_t sr_core /* i : internal sampling rate */
);
-#endif
+
int32_t getCoreSamplerateMode2_flt(
const int16_t element_mode, /* i : IVAS element mode */
const int32_t total_brate, /* i : total bitrate */
@@ -10193,7 +9980,7 @@ void IGFEncApplyMono(
float *pMDCTSpectrum, /* i/o: MDCT spectrum */
float *pPowerSpectrum, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
- const int16_t isTNSActive, /* i : flag indicating if the TNS is active */
+ const int8_t isTNSActive, /* i : flag indicating if the TNS is active */
const int16_t sp_aud_decision0, /* i : first stage switching decision */
const int16_t vad_hover_flag /* i : VAD hangover flag */
);
@@ -10277,7 +10064,6 @@ void IGFDecReadData_flt(
const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */
);
-#ifndef IVAS_FLOAT_FIXED
/*! r: return igfAllZero flag indicating if no envelope is transmitted */
int16_t IGFDecReadLevel_flt(
const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */
@@ -10285,7 +10071,6 @@ int16_t IGFDecReadLevel_flt(
const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */
const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */
);
-#endif
void IGFDecRestoreTCX10SubFrameData_flt(
const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */
@@ -10389,7 +10174,6 @@ void IGFSCFEncoderRestoreContextState(
const int16_t igfGridIdx /* i : igf grid index see declaration of IGF_GRID_IDX for details */
);
-#ifndef IVAS_FLOAT_FIXED
void IGFSCFDecoderOpen_ivas(
IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */
H_IGF_INFO hIgfInfo, /* i : IGF info handle */
@@ -10397,15 +10181,11 @@ void IGFSCFDecoderOpen_ivas(
const int16_t bwidth,
const int16_t element_mode,
const int16_t rf_mode );
-#endif
-#ifndef IVAS_FLOAT_FIXED
void IGFSCFDecoderReset_ivas(
IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i : handle to public data or NULL in case there was no instance created */
);
-#endif
-#ifndef IVAS_FLOAT_FIXED
void IGFSCFDecoderDecode_ivas(
IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */
Decoder_State *st, /* i/o: pointer to decoder state */
@@ -10414,7 +10194,6 @@ void IGFSCFDecoderDecode_ivas(
const int16_t indepFlag /* i : if 1 on input the decoder will be forced to reset,
if 0 on input the decoder will be forced to encode without a reset */
);
-#endif
/*! r: offset value */
int16_t tbe_celp_exc_offset_flt(
@@ -10461,3 +10240,5 @@ void init_tcx_cfg(
const int16_t ini_frame,
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
+
+#endif
diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx.h
similarity index 90%
rename from lib_com/prot_fx2.h
rename to lib_com/prot_fx.h
index 131a12285d012ee49e84671c2a3c4f3cbb9e3ee6..0d62a9f2934fa57040d3b53c0d95501db595dc2b 100644
--- a/lib_com/prot_fx2.h
+++ b/lib_com/prot_fx.h
@@ -50,9 +50,20 @@
#define dynamic_calloc( n1, n2 ) calloc( n1, n2 )
#define dynamic_free( n1 ) free( n1 )
+#define mvr2r_Word32( x, y, n ) Copy32( x, y, n )
+#define mvr2r_Word16( x, y, n ) Copy( x, y, n )
+
+#include
+#include
+#include
+#include "options.h"
+#include "typedef.h"
+#include "cnst.h"
+#include "stl.h"
#include "ivas_cnst.h"
#include "stat_enc.h"
#include "stat_dec.h"
+#include "ivas_stat_enc.h"
#include "ivas_stat_dec.h"
#include "ivas_error.h"
#include "ivas_error_utils.h"
@@ -60,7 +71,9 @@
#define TCX_IMDCT_SCALE 15
#define TCX_IMDCT_HEADROOM 1
+/*================================================================================*/
/* conversion functions: */
+/*================================================================================*/
// Float to Word32
Word32 float_to_fix( float number, Word32 Q );
@@ -123,6 +136,12 @@ Word16 L_get_q_buf( float *ptr_flt, Word16 length );
Word16 L_get_q_buf1( float *ptr_flt, Word16 length );
#endif
+/*================================================================================*/
+/* conversion functions: */
+/*================================================================================*/
+
+Word16 norm_ul( UWord32 UL_var1 );
+
Word32 Mult_32_16(
Word32 a,
Word16 b );
@@ -144,6 +163,12 @@ void Vr_add(
Word16 Len /* i : Vector lenght */
);
+void set8_fx(
+ Word8 y[], /* i/o: Vector to set */
+ const Word8 a, /* i : Value to set the vector to */
+ const Word16 N /* i : Lenght of the vector */
+);
+
void set16_fx(
Word16 y[], /* i/o: Vector to set */
const Word16 a, /* i : Value to set the vector to */
@@ -220,6 +245,14 @@ void deindex_lvq_SHB_fx(
const Word16 nbits,
const Word16 mode );
+Word16 deindex_lvq_ivas_fx(
+ Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */
+ Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */
+ Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */
+ Word16 sf_flag, /* i : safety net flag */
+ Word16 no_bits /* i : number of bits for lattice */
+);
+
void permute_fx(
Word16 *pTmp1, /* i/o: vector whose components are to be permuted */
const Word16 *perm /* i : permutation info (indexes that should be interchanged), max two perms */
@@ -881,6 +914,13 @@ Word16 lsf_stab_ivas_fx( /* o : LP filter stability
const Word16 L_frame /* i : frame length */
);
+Word16 lsf_stab_ivas_fx( /* o : LP filter stability Q15*/
+ const Word16 *lsf, /* i : LSF vector Q(x2.56)*/
+ const Word16 *lsfold, /* i : old LSF vector Q(x2.56)*/
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 L_frame /* i : frame length */
+);
+
void reorder_isf_fx(
Word16 *isf, /* i/o: ISFs in the frequency domain (0..0.5) */
const Word16 min_dist, /* i : minimum required distance */
@@ -925,6 +965,17 @@ Word16 vq_dec_lvq_fx(
Word16 *p_no_scales,
Word16 *p_no_scales_p );
+Word16 vq_dec_lvq_ivas_fx(
+ Word16 sf_flag, /* i : safety net flag */
+ Word16 x[], /* o : Decoded vector Q(x2.56)*/
+ Word16 indices[], /* i : Indices */
+ Word16 stages, /* i : Number of stages */
+ Word16 N, /* i : Vector dimension */
+ Word16 mode, /* (i): mode_lvq, or mode_lvq_p */
+ Word16 no_bits /* (i): no. bits for lattice */
+);
+void a2rc_fx( const Word16 *a, Word16 *refl, Word16 lpcorder );
+
Word16 vq_dec_lvq_ivas_fx(
Word16 sf_flag, /* i : safety net flag */
Word16 x[], /* o : Decoded vector Q(x2.56)*/
@@ -2271,7 +2322,9 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
Word16 sigOut_fx[], /* o : decimated signal Q0 */
const Word32 fout, /* i : frequency of output Q0 */
Word16 mem_fx[], /* i/o: filter memory Q0 */
- const Word16 nblp /* i : flag indicating if NB low-pass is applied */
+ const Word16 nblp, /* i : flag indicating if NB low-pass is applied */
+ Word16 *Q_new_inp, // TO be removed
+ Word16 *mem_decim_size // TO be removed
);
Word16 modify_Fs_intcub3m_sup_fx( /* o : length of output */
@@ -2734,7 +2787,7 @@ void ScaleShapedSHB_fx(
Word16 prev_Q_bwe_syn2 );
void ScaleShapedSHB_32(
- const int16_t length, /* i : SHB overlap length */
+ const Word16 length, /* i : SHB overlap length */
Word32 *synSHB_fx, /* i/o: synthesized shb signal Qx */
Word32 *overlap_fx, /* i/o: buffer for overlap-add Qx */
const Word16 *subgain_fx, /* i : subframe gain Q15 */
@@ -5597,12 +5650,29 @@ Word32 dotp_fixed_o(
const Word16 n, /* i : vector length */
const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */
Word16 *res_q );
+
+Word32 dotp_fixed_32(
+ const Word32 x[], /* i : vector x[] */
+ const Word32 y[], /* i : vector y[] */
+ const Word16 n, /* i : vector length */
+ const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */
+ Word16 *res_q /*stores resultant Q*/
+);
+
#ifdef IVAS_FLOAT_FIXED
Word32 dotp_fixed_guarded(
const Word32 x[], /* i : vector x[] */
const Word32 y[], /* i : vector y[] */
const Word16 n /* i : vector length */
);
+
+Word32 dotp_me_fx(
+ const Word32 x[], /* i : vector x[] */
+ const Word32 y[], /* i : vector y[] */
+ const Word16 n, /* i : vector length */
+ Word16 exp_x,
+ Word16 exp_y,
+ Word16 *exp_suma );
#endif
void lsf_end_dec_fx(
@@ -6350,6 +6420,16 @@ void lp_gain_updt_fx(
Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */
const Word16 L_frame /* i : length of the frame */
);
+
+void lp_gain_updt_ivas_fx(
+ const Word16 i_subfr, /* i : subframe number Q0 */
+ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */
+ const Word32 norm_gain_code, /* i : Normalised gain code Q16 */
+ Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */
+ Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */
+ const Word16 L_frame /* i : length of the frame */
+);
+
Word32 gain_dec_gaus_fx( /* o : quantized codebook gain Q16 */
Word16 index, /* i : quantization index */
const Word16 bits, /* i : number of bits to quantize */
@@ -7004,6 +7084,16 @@ void generate_comfort_noise_dec_fx(
const Word16 nchan_out /* i : number of output channels */
);
+void generate_comfort_noise_dec_ivas_fx(
+ Word32 **bufferReal, /* o : matrix to real part of i bands */
+ Word32 **bufferImag, /* o : matrix to imaginary part of i bands */
+ Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */
+ Decoder_State *stdec,
+ Word16 *Q_new,
+ Word16 gen_exc,
+ const Word16 nchan_out /* i : number of output channels */
+);
+
void generate_comfort_noise_dec_hf_fx( Word32 **bufferReal, /* o : matrix to real part of i bands */
Word32 **bufferImag, /* o : matrix to imaginary part of i bands */
Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */
@@ -8885,6 +8975,14 @@ void delay_signal_fx(
const Word16 delay /* i : delay in samples */
);
+void delay_signal_q_adj_fx(
+ Word32 x[], /* i/o: signal to be delayed */
+ const Word16 len, /* i : length of the input signal */
+ Word32 mem[], /* i/o: synchronization memory */
+ const Word16 delay, /* i : delay in samples */
+ const Word16 q_x,
+ const Word16 q_mem );
+
Word32 anint_fixed(
Word32 x, /* i: Round to the nearest integer */
Word16 exp /* i: Exponent for round step */
@@ -9144,6 +9242,10 @@ Word32 sum2_f_16_fx(
const Word16 *vec, /* i : input vector */
const Word16 lvec /* i : length of input vector */
);
+Word32 sum2_f_16_gb_fx(
+ const Word16 *vec, /* i : input vector */
+ const Word16 lvec, /* i : length of input vector */
+ Word16 gb );
Word16 vq_dec_lvq_ivas_fx(
Word16 sf_flag, /* i : safety net flag */
@@ -9163,7 +9265,6 @@ Word16 deindex_lvq_ivas_fx(
Word16 no_bits /* i : number of bits for lattice */
);
-#endif
void deleteCldfb_ivas_fx(
HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */
@@ -9221,3 +9322,827 @@ void ivas_mdct_core_reconstruct_fx(
const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/
Word16 q_x,
Word16 e_sig );
+
+void ari_start_encoding_14bits_ivas_fx(
+ Tastat *s );
+
+void tcx_scalar_quantization_ivas_fx(
+ Word32 *x, /* i: input coefficients */
+ Word16 x_e, /* i: exponent */
+ Word16 *xq, /* o: quantized coefficients */
+ Word16 L_frame, /* i: frame length */
+ Word16 gain, /* i: quantization gain */
+ Word16 gain_e, /* i: quantization gain exponent */
+ Word16 offset, /* i: rounding offset (deadzone) */
+ 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,
+ CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */
+);
+
+Word16 usdequant_fx( /* Qx*/
+ const Word16 idx, /* i: quantizer index Q0*/
+ const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/
+ const Word16 delta /* i: quantization step Qy*/
+);
+
+Word16 usquant_fx( /* o: index of the winning codeword */
+ const Word16 x, /* i: scalar value to quantize Qx*/
+ Word16 *xq, /* o: quantized value Qx*/
+ const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/
+ const Word16 delta, /* i: quantization step Qx-1*/
+ const Word16 cbsize /* i: codebook size */
+);
+
+Word32 Dot_product( /* o : Sum */
+ const Word16 x[], /* i : 12bits: x vector */
+ const Word16 y[], /* i : 12bits: y vector */
+ const Word16 lg /* i : vector length */
+);
+
+Word32 dotp_fx( /* o : dot product of x[] and y[] */
+ const Word16 x[], /* i : vector x[] */
+ const Word16 y[], /* i : vector y[] */
+ const Word16 n, /* i : vector length */
+ Word16 *exp /* (o) : exponent of result (0..+30) */
+);
+
+Word32 sum2_fx_mod( /* o : sum of all squared vector elements Q(2x+1)*/
+ const Word16 *vec, /* i : i vector Qx*/
+ const Word16 lvec /* i : length of i vector */
+);
+
+void Copy_Scale_sig(
+ const Word16 x[], /* i : signal to scale i Qx */
+ Word16 y[], /* o : scaled signal output Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+
+void Scale_sig32(
+ Word32 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 */
+);
+
+void Copy_Scale_sig_16_32(
+ const Word16 x[], /* i : signal to scale i Qx */
+ Word32 y[], /* o : scaled signal output Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+
+void Copy_Scale_sig_16_32_no_sat(
+ const Word16 x[], /* i : signal to scale input Qx */
+ Word32 y[], /* o : scaled signal output Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+
+void Copy_Scale_sig_32_16(
+ const Word32 x[], /* i : signal to scale i Qx */
+ Word16 y[], /* o : scaled signal output Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+
+void Random_Fill(
+ Word16 *seed, /* i/o: random seed */
+ Word16 n, /* i : number of values */
+ Word16 *y, /* o : output values */
+ Word16 scaling /* i : scaling of values */
+);
+
+Word16 mean_fx( /* o : mean of vector */
+ const Word16 *vec_fx, /* i : i vector */
+ const Word16 lvec_fx /* i : length of i vector */
+);
+
+void sort_fx(
+ Word16 *r, /* i/o: Vector to be sorted in place */
+ Word16 lo, /* i : Low limit of sorting range */
+ Word16 up /* I : High limit of sorting range */
+);
+
+void sort_32_fx(
+ Word32 *r, /* i/o: Vector to be sorted in place */
+ const Word16 lo, /* i : Low limit of sorting range */
+ const Word16 up /* I : High limit of sorting range */
+);
+
+Word16 minimum_fx( /* o : index of the minimum value in the input vector */
+ const Word16 *vec_fx, /* i : input vector */
+ const Word16 lvec_fx, /* i : length of input vector */
+ Word16 *min_fx /* o : minimum value in the input vector */
+);
+
+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 minimum_abs32_fx( /* o : index of the minimum value in the input vector */
+ const Word32 *vec_fx, /* i : input vector */
+ const Word16 lvec_fx, /* i : length of input vector */
+ Word32 *min_fx /* o : minimum value in the input vector */
+);
+
+Word16 minimum_32_fx( /* o : index of the minimum value in the input vector */
+ const Word32 *vec_fx, /* i : input vector */
+ const Word16 lvec_fx, /* i : length of input vector */
+ Word32 *min_fx /* o : minimum value in the input vector */
+);
+
+Word16 maximum_32_fx( /* o : index of the maximum value in the input vector */
+ const Word32 *vec, /* i : input vector */
+ const Word16 lvec, /* i : length of input vector */
+ Word32 *max_val /* o : maximum value in the input vector */
+);
+
+Word16 maximum_abs_32_fx( /* o : index of the maximum value in the input vector */
+ const Word32 *vec, /* i : input vector */
+ const Word16 lvec, /* i : length of input vector */
+ Word32 *max_val /* o : maximum value in the input vector */
+);
+
+/*! r: index of the maximum value in the input vector */
+Word16 maximum_s(
+ const Word16 *vec, /* i : input vector */
+ const Word16 lvec, /* i : length of input vector */
+ Word16 *max /* o : maximum value in the input vector */
+);
+
+/*! r: index of the minimum value in the input vector */
+Word16 minimum_s(
+ const Word16 *vec, /* i : Input vector */
+ const Word16 lvec, /* i : Vector length */
+ Word16 *min_val /* o : minimum value in the input vector */
+);
+
+Word16 Exp16Array(
+ const Word16 n, /* (i): Array size */
+ const Word16 *sx /* (i): Data array */
+);
+
+Word16 Exp32Array(
+ const Word16 n, /* (i): Array size */
+ const Word32 *sx /* (i): Data array */
+);
+
+Word32 sum16_32_fx( /* o : sum of all vector elements Qx*/
+ const Word16 *vec, /* i : input vector Qx*/
+ const Word16 lvec /* i : length of input vector */
+);
+
+Word32 sum32_sat( /* o : sum of all vector elements Qx*/
+ const Word32 *vec, /* i : input vector Qx*/
+ const Word16 lvec /* i : length of input vector */
+);
+
+Word32 var_fx_32( /* o: variance of vector Qx+16*/
+ const Word16 *x, /* i: input vector Qx*/
+ const Word16 Qx,
+ const Word16 len /* i: length of inputvector */
+);
+
+Word16 var_fx( /* o: variance of vector Qx*/
+ const Word16 *x, /* i: input vector Qx*/
+ const Word16 Qx,
+ const Word16 len /* i: length of inputvector */
+);
+
+Word16 std_fx( /* o: standard deviation */
+ const Word16 x[], /* i: input vector */
+ const Word16 len /* i: length of the input vector */
+);
+
+Word32 dot_product_mat_fx( /* o : the dot product x'*A*x */
+ const Word16 *x, /* i : vector x Q15 */
+ const Word32 *A, /* i : matrix A Q0*/
+ const Word16 m /* i : vector & matrix size */
+
+);
+
+void Vr_subt(
+ const Word16 x1[], /* i : Input vector 1 */
+ const Word16 x2[], /* i : Input vector 2 */
+ Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */
+ Word16 N /* i : Vector lenght */
+);
+
+Word16 vquant_fx( /* o: index of the winning codevector */
+ Word16 x[], /* i: vector to quantize Q13 */
+ const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/
+ Word16 xq[], /* o: quantized vector Q13 */
+ const Word16 cb[], /* i: codebook Q13 */
+ const Word16 dim, /* i: dimension of codebook vectors */
+ const Word16 cbsize /* i: codebook size */
+);
+
+Word16 w_vquant_fx(
+ Word16 x[], /* i: vector to quantize in Q10 */
+ Word16 Qx,
+ const Word16 weights[], /* i: error weights in Q0 */
+ Word16 xq[], /* o: quantized vector in Q15 */
+ const Word16 cb[], /* i: codebook in Q15 */
+ const Word16 cbsize, /* i: codebook size */
+ const Word16 rev_vect /* i: reverse codebook vectors */
+);
+
+Word16 emaximum_fx( /* o : return index with max energy value in vector Q0 */
+ const Word16 Qvec, /* i : Q of input vector Q0 */
+ const Word16 *vec, /* i : input vector Qx */
+ const Word16 lvec, /* i : length of input vector Q0 */
+ Word32 *ener_max /* o : maximum energy value Q0 */
+);
+
+Word16 emaximum_32fx( /* o : return index with max energy value in vector Q0 */
+ const Word16 Qvec, /* i : Q of input vector Q0 */
+ const Word32 *vec, /* i : input vector Qx */
+ const Word16 lvec, /* i : length of input vector Q0 */
+ Word32 *ener_max /* o : maximum energy value Q0 */
+);
+
+Word32 Mean32( /* o : mean of the elements of the vector */
+ const Word32 in[], /* i : input vector */
+ const Word16 L /* i : length of input vector */
+);
+
+Word32 sum32_fx( /* o : sum of all vector elements Qx*/
+ const Word32 *vec, /* i : input vector Qx*/
+ const Word16 lvec /* i : length of input vector */
+);
+
+Word16 sum16_fx( /* o : sum of all vector elements Qx*/
+ const Word16 *vec, /* i : input vector Qx*/
+ const Word16 lvec /* i : length of input vector */
+);
+
+Word16 own_random2_fx( Word16 seed );
+
+void iDiv_and_mod_32(
+ const Word32 Numer, /* i : 32 bits numerator */
+ const Word16 Denom, /* i : 16 bits denominator */
+ Word32 *Int_quotient, /* o : integer result of the division (int)(num/den) */
+ Word32 *Int_mod, /* o : modulo result of the division num-((int)(num/den)*den)*/
+ const Word16 rshift /* i : 0 if no right shift / 1 if the denom is right shifted by 1 */
+);
+
+void pz_filter_sp_fx(
+ const Word16 b[],
+ const Word16 a[],
+ Word16 x[],
+ Word16 y[],
+ Word16 buf[],
+ Word16 PNR,
+ Word16 PDR,
+ Word16 N,
+ Word16 Qa );
+
+Word32 root_a_fx(
+ Word32 a,
+ Word16 Q_a,
+ Word16 *exp_out );
+
+Word32 root_a_over_b_fx(
+ Word32 a,
+ Word16 Q_a,
+ Word32 b,
+ Word16 Q_b,
+ Word16 *exp_out );
+
+void fir_fx( const Word16 x[], /* i : input vector Qx*/
+ const Word16 h[], /* i : impulse response of the FIR filter Q12*/
+ Word16 y[], /* o : output vector (result of filtering) Qx*/
+ Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/
+ const Word16 L, /* i : input vector size */
+ const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */
+ const Word16 upd /* i : 1 = update the memory, 0 = not */
+ ,
+ Word16 shift /* i : difference between Q15 and scaling of h[] */
+);
+void v_add_32(
+ const Word32 x1[], /* i : Input vector 1 */
+ const Word32 x2[], /* i : Input vector 2 */
+ Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */
+ const Word16 N /* i : Vector length */
+);
+
+void v_shr_32(
+ Word32 x1[], /* i : Input vector 1 */
+ Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */
+ const Word16 N, /* i : Vector length */
+ Word16 shift /*shift value*/
+);
+
+void v_sub_32(
+ const Word32 x1[], /* i : Input vector 1 */
+ const Word32 x2[], /* i : Input vector 2 */
+ Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */
+ const Word16 N /* i : Vector length */
+);
+
+
+void v_add_16(
+ const Word16 x1[], /* i : Input vector 1 */
+ const Word16 x2[], /* i : Input vector 2 */
+ Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */
+ const Word16 N /* i : Vector length */
+);
+
+void v_sub_16(
+ const Word16 x1[], /* i : Input vector 1 */
+ const Word16 x2[], /* i : Input vector 2 */
+ Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */
+ const Word16 N /* i : Vector length */
+);
+
+
+Word16 squant_fx( /* o: index of the winning codeword */
+ const Word16 x, /* i: scalar value to quantize */
+ Word16 *xq, /* o: quantized value */
+ const Word16 cb[], /* i: codebook */
+ const Word16 cbsize /* i: codebook size */
+);
+
+void pz_filter_dp_fx(
+ const Word16 b[],
+ const Word16 a[],
+ Word16 x[],
+ Word16 y[],
+ Word32 buf[],
+ Word16 PNR,
+ Word16 PDR,
+ Word16 N,
+ Word16 Qa );
+
+void Copy_Scale_sig32_16(
+ const Word32 *src, /* i : signal to scale Qx */
+ Word16 *dst, /* o : scaled signal Qx */
+ Word16 len, /* i : size of x[] Q0 */
+ Word16 exp0 ); /* i : exponent: x = round(x << exp) Qx ?exp */
+
+void v_multc_att(
+ const Word16 x[], /* i : Input vector Qx */
+ const Word16 att, /* i : Constant Q15, <= MAX_16 */
+ Word16 y[], /* o : Output vector that contains att*x */
+ const Word16 N /* i : Vector length */
+);
+
+void v_multc_att32(
+ const Word32 x[], /* i : Input vector Qx */
+ const Word16 att, /* i : Constant Q15, <= MAX_16 */
+ Word32 y[], /* o : Output vector that contains att*x */
+ const Word16 N /* i : Vector length */
+);
+
+void v_multc_att3232(
+ const Word32 x[], /* i : Input vector Qx */
+ const Word32 att, /* i : Constant Q32, <= MAX_32 */
+ Word32 y[], /* o : Output vector that contains att*x */
+ const Word16 N /* i : Vector length */
+);
+
+void v_L_mult_1616(
+ const Word16 x1[], /* i : Input vector 1 */
+ const Word16 x2[], /* i : Input vector 2 */
+ Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */
+ const Word16 N /* i : Vector length */
+);
+
+void v_L_mult_3216(
+ const Word32 x1[], /* i : Input vector 1 */
+ const Word16 x2[], /* i : Input vector 2 */
+ Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */
+ const Word16 N /* i : Vector length */
+);
+
+void add_vec_fx(
+ const Word16 x1[], /* i : Input vector 1 */
+ const Word16 Qx1, /* i : SCaling of input 1 */
+ const Word16 x2[], /* i : Input vector 2 */
+ const Word16 Qx2, /* i : SCaling of input 1 */
+ Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */
+ const Word16 Qy, /* i : SCaling of output 1 */
+ const Word16 N /* i : Vector lenght */
+);
+
+Word32 Add_flt32_flt32( /* o: Result (Normalized) */
+ Word32 a, /* i: 1st Value */
+ Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */
+ Word32 b, /* i: 2nd Value */
+ Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */
+ Word16 *exp_out /* o: Exponent of Result */
+);
+
+Word32 Mul_flt32_Q15( /* o: Result (Normalized) */
+ Word32 value, /* i: Pseudo_float Value */
+ Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */
+ Word16 frac /* i: Q15 value */
+);
+
+Word32 Div_flt32_flt32( /* o: Result (Normalized) */
+ Word32 a, /* i: 1st Value */
+ Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */
+ Word32 b, /* i: 2nd Value */
+ Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */
+ Word16 *exp_out /* o: Exponent of Result */
+);
+
+Word32 Calc_Energy_Autoscaled( /* o: Result (Energy) */
+ const Word16 *signal, /* i: Signal */
+ Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */
+ Word16 len, /* i: Frame Length */
+ Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */
+);
+
+Word16 Find_Max_Norm16( const Word16 *src, Word16 len );
+
+Word16 Find_Max_Norm32( const Word32 *src, Word16 len );
+
+Word32 Sqrt_Ratio32( /* o: Result in Q31 */
+ Word32 L_val1, /* i: Mantisa of Val1 */
+ Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */
+ Word32 L_val2, /* i: Mantisa of Val2 */
+ Word16 exp2, /* i: Exp of Val2 (same as exp1) */
+ Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */
+);
+
+Word16 Invert16( /* result in Q'15 + 'exp' */
+ Word16 val,
+ Word16 *exp );
+
+Word16 find_rem( Word16 n, Word16 m, Word16 *r );
+
+Word32 find_remd( Word32 n, Word32 m, Word32 *r );
+
+Word16 rint_new_fx(
+ Word32 x /*Q16 */
+);
+
+Word16 erb_diff_search_fx( Word16 *prev_erb, const Word16 *curr_erb, Word16 *dif_erb, Word16 *pow_spec, const Word16 *cb_fx, Word16 cb_size, Word16 cb_dim, Word16 offset );
+
+void Acelp_dec_total_exc(
+ Word16 *exc_fx, /* i/o: adapt. excitation exc */
+ Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */
+ const Word16 gain_code16, /* i : Gain code Q0 */
+ const Word16 gain_pit_fx, /* i ; Pitch gain in Q14 */
+ const Word16 i_subfr, /* i ; subfr */
+ const Word16 *code_fx, /* i : code in Q9 */
+ const Word16 L_subfr /* i : Subframne lenght */
+);
+
+UWord32 UL_inverse( const UWord32 UL_val, Word16 *exp );
+
+UWord32 UL_div( const UWord32 UL_num, const UWord32 UL_den );
+
+Word16 ratio( const Word32 numer, const Word32 denom, Word16 *expo );
+
+void hp400_12k8_fx(
+ Word16 signal[], /* i/o: input signal / output is divided by 16 */
+ const Word16 lg, /* i : lenght of signal */
+ Word16 mem[] /* i/o: filter memory [6] */
+);
+
+Word16 dot_prod_satcontr( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len );
+
+void E_UTIL_f_convolve( const Word16 x[], const Word16 h[], Word16 y[], const Word16 size );
+
+void floating_point_add(
+ Word32 *mx, /* io: mantissa of the addend Q31 */
+ Word16 *ex, /* io: exponent of the addend Q0 */
+ const Word32 my, /* i: mantissa of the adder Q31 */
+ const Word16 ey /* i: exponent of the adder Q0 */
+);
+/*delay_signal_fx is also present*/
+void delay_signal(
+ Word16 x[], /* i/o: signal to be delayed */
+ const Word16 len, /* i : length of the input signal */
+ Word16 mem[], /* i/o: synchronization memory */
+ const Word16 delay /* i : delay in samples */
+);
+
+void delay_signal32(
+ Word32 x[], /* i/o: signal to be delayed */
+ const Word16 len, /* i : length of the input signal */
+ Word32 mem[], /* i/o: synchronization memory */
+ const Word16 delay /* i : delay in samples */
+);
+
+Word16 lin_interp_fx(
+ const Word16 x, /* i : the value to be mapped */
+ const Word16 x1, /* i : source range interval: low end */
+ const Word16 y1, /* i : source range interval: high end */
+ const Word16 x2, /* i : target range interval: low */
+ const Word16 y2, /* i : target range interval: high */
+ const Word16 flag_sat /* i : flag to indicate whether to apply saturation */
+);
+
+Word16 ceil_log_2( UWord64 val );
+
+Word32 imax_pos_fx(
+ const Word32 *y /* i : Input vector for peak interpolation */
+);
+
+void msvq_dec_fx(
+ const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */
+ const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
+ const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */
+ const Word16 stages, /* i : Number of stages */
+ const Word16 N, /* i : Vector dimension */
+ const Word16 maxN, /* i : Codebook dimension */
+ const Word16 Idx[], /* i : Indices */
+ const Word16 applyIDCT_flag, /* i : applyIDCT flag */
+ const Word32 *invTrfMatrix, /* i : synthesis matrix */
+ Word32 *uq, /* o : quantized vector */
+ Word16 *uq_ind, /* o : quantized vector (fixed point) */
+ Word16 exp );
+
+void dec_FDCNG_MSVQ_stage1_fx(
+ Word16 j_full, /* i : index full range */
+ Word16 n, /* i : dimension to generate */
+ const Word32 *invTrfMatrix, /* i : IDCT matrix for synthesis */
+ const DCTTYPE idcttype, /* i : specify which IDCT */
+ Word32 *uq, /* o : synthesized stage1 vector */
+ Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */
+);
+
+void dctT2_N_apply_matrix_fx(
+ const Word32 *input, /* i : input in fdcng or DCT(fdcng) domain */
+ Word32 *output, /* o : output in DCT(fdcng) or fdcng ordomain */
+ const Word16 dct_dim, /* i : dct processing dim possibly truncated */
+ const Word16 fdcngvq_dim, /* i : fdcng domain length */
+ const Word32 *matrix, /* i : IDCT matrix */
+ const Word16 matrix_row_dim, /* i : */
+ const DCTTYPE dcttype /* i : matrix operation type */
+);
+
+Word32 sum2_f_32_fx(
+ const Word32 *vec, /* i : input vector */
+ const int16_t lvec, /* i : length of input vector */
+ Word16 gb );
+
+Word32 sum2_32_fx(
+ const Word32 *vec, /* i : input vector */
+ const Word16 lvec, /* i : length of input vector */
+ Word16 *e );
+
+void v_mult_fixed(
+ const Word32 x1[], /* i : Input vector 1 */
+ const Word32 x2[], /* i : Input vector 2 */
+ Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */
+ const Word16 N /* i : Vector length */
+);
+
+void v_sub_s16_fx(
+ const Word16 x1[], /* i : Input vector 1 */
+ const Word16 x2[], /* i : Input vector 2 */
+ Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */
+ const Word16 N /* i : Vector length */
+);
+
+void v_sub32_fx(
+ const Word32 x1[], /* i : Input vector 1 */
+ const Word32 x2[], /* i : Input vector 2 */
+ Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */
+ const Word16 N /* i : Vector length */
+);
+
+void ivas_swb_tbe_dec_fx(
+ Decoder_State *st, /* i/o: decoder state structure */
+ STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
+ const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation */
+ Word16 Q_exc,
+ const Word16 voice_factors_fx[], /* i : voicing factors */
+ const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis */
+ Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE */
+ Word32 *synth_fx, /* o : SHB synthesis/final synthesis */
+ Word16 *pitch_buf_fx,
+ Word16 *Q_white_exc );
+
+Word16 swb_bwe_dec_fx32(
+ Decoder_State *st, /* i/o: decoder state structure */
+ Word32 output[], /* i : synthesis @internal Fs Q11 */
+ Word32 *synth, /* i : ACELP core synthesis/final synthesis Q11 */
+ Word32 *hb_synth, /* o : SHB synthesis/final synthesis */
+ Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
+ Word16 output_frame /* i : frame length */
+);
+
+ivas_error acelp_core_dec_ivas_fx(
+ Decoder_State *st, /* i/o: decoder state structure */
+ Word16 output[], /* o : synthesis @internal Fs */
+ Word16 synth[], /* o : synthesis */
+ Word16 save_hb_synth[], /* o : HB synthesis */
+ Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */
+ Word16 *voice_factors, /* o : voicing factors */
+ Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
+ const int16_t sharpFlag, /* i : formant sharpening flag */
+ Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */
+ int16_t *unbits, /* o : number of unused bits */
+ int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
+ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */
+ const Word16 tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */
+ const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
+ const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
+ const int16_t last_element_mode, /* i : last element mode */
+ const int32_t last_element_brate, /* i : last element bitrate */
+ const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
+ const int16_t nchan_out, /* i : number of output channels */
+ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
+ const int16_t read_sid_info /* i : read SID info flag */
+);
+
+void destroy_cldfb_decoder_ivas_fx(
+ Decoder_State *st /* o : Decoder static variables structure */
+);
+
+void wtda_fx32(
+ const Word32 *new_audio, /* i : input audio Q11 */
+ Word32 *wtda_audio, /* o : windowed audio Q11 */
+ Word32 *old_wtda, /* i/o: windowed audio from previous frame Q11 */
+ const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */
+ const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */
+ const Word16 L /* i : length */
+);
+
+ivas_error core_switching_pre_dec_ivas_fx(
+ Decoder_State *st, /* i/o: decoder state structure */
+ const Word16 output_frame, /* i : frame length */
+ const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */
+ const Word16 nchan_out, /* i : number of output channels */
+ const Word16 last_element_mode, /* i : last_element_mode */
+ const Word32 last_element_brate, /* i : last element bitrate */
+ Word16 Q_old_synthFB,
+ Word16 *Q_olapBufferSynth,
+ Word16 *Q_olapBufferSynth2 );
+
+void hp20_fix32(
+ Word32 signal_fx[],
+ const Word16 lg,
+ Word32 mem_fx[],
+ const Word32 Fs );
+
+void getTCXMode_ivas_fx(
+ Decoder_State *st, /* i/o: decoder memory state */
+ Decoder_State *st0, /* i : bitstream */
+ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
+);
+
+void getTCXWindowing_ivas_fx(
+ const Word16 core, /* i : current frame mode */
+ const Word16 last_core, /* i : last frame mode */
+ const Word16 element_mode, /* i : element mode */
+ TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */
+ Decoder_State *st0 /* i : bitstream */
+);
+
+Word16 ari_start_decoding_14bits_prm_ivas_fx(
+ const Word16 *ptr,
+ Word16 bp,
+ Tastat *s );
+
+void generate_masking_noise_ivas_fx(
+ Word32 *timeDomainBuffer, /* i/o: time-domain signal */
+ Word16 *exp_out, /* o : time-domain signal exp */
+ HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
+ const Word16 length, /* i : frame size */
+ const Word16 core, /* i : core */
+ const Word16 return_noise, /* i : noise is returned instead of added */
+ const Word16 secondary, /* i : flag to indicate secondary noise generation */
+ const Word16 element_mode, /* i : element mode */
+ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
+ const Word16 nchan_out /* i : number of output channels */
+);
+
+void SynthesisSTFT_dirac_fx(
+ Word32 *fftBuffer, /* i : FFT bins */
+ Word32 *timeDomainOutput,
+ Word32 *olapBuffer,
+ const Word16 *olapWin,
+ const Word16 samples_out,
+ HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
+);
+
+void generate_stereo_masking_noise_fx(
+ Word16 *syn, /* i/o: time-domain signal */
+ Word16 Q_syn,
+ Decoder_State *st, /* i/o: decoder state structure */
+ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */
+ const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
+ const int16_t fadeOut, /* i : only fade out of previous state */
+ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */
+ const int16_t nchan_out /* i : number of output channels */
+);
+
+void SynthesisSTFT_fx(
+ Word32 *fftBuffer, /* i : FFT bins */
+ Word32 *timeDomainOutput,
+ Word32 *olapBuffer,
+ const Word16 *olapWin,
+ const int16_t tcx_transition,
+ HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
+ const int16_t element_mode, /* i : element mode */
+ const int16_t nchan_out /* i : number of output channels */
+);
+
+void FdCng_decodeSID_ivas_fx(
+ Decoder_State *st /* i/o: decoder state structure */
+);
+
+void cldfb_restore_memory_ivas_fx(
+ HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
+);
+
+ivas_error cldfb_save_memory_ivas_fx(
+ HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
+);
+
+void ordr_esti(
+ const Word16 k, /* i : sub-vector index */
+ Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */
+ Word16 svOrder[], /* i/o: AVQ sub-vector order */
+ const Word16 Nsv /* i : total sub-vectors in a sub-frames */
+);
+
+Word16 sr2fscale(
+ const Word32 sr_core /* i : internal sampling rate */
+);
+
+// pre_proc functions
+/*full implementation pending*/
+void swb_pre_proc_ivas_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ float *new_swb_speech, /* o : original input signal at 32kHz */
+ Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz */
+ float *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz */
+ float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer */
+ float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer */
+ CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */
+);
+
+// tools.c
+Word32 sum2_f_32_fx( /* o : Q(2x - 31 - gb) */
+ const Word32 *vec, /* i : input vector, Qx */
+ const Word16 lvec, /* i : length of input vector */
+ Word16 gb /* i : guard bits */
+);
+
+Word32 sum2_32_exp_fx(
+ const Word32 *vec, /* i : input vector, Qx */
+ const Word16 lvec, /* i : length of input vector */
+ Word16 *exp, /* i/o: exponent of vector */
+ Word16 gb /* i : guard bits */
+);
+
+Word32 sum2_32_fx(
+ const Word32 *vec, /* i : input vector */
+ const Word16 lvec, /* i : length of input vector */
+ Word16 *e );
+#ifdef IVAS_FLOAT_FIXED
+void ProcessStereoIGF_fx(
+ STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct,
+ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
+ int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
+#if 1
+ Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */
+ 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 */
+#endif
+ float *pITFMDCTSpectrum[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */
+ float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
+ float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */
+ float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
+ const int16_t frameno, /* i : flag indicating index of current subfr. */
+ const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */
+ const int32_t element_brate, /* i : element bitrate */
+ const int16_t mct_on /* i : flag mct block (1) or stereo (0) */
+);
+void IGFEncApplyStereo_fx(
+ STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */
+ Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
+ const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */
+ const Word16 igfGridIdx, /* i : IGF grid index */
+ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
+ Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
+ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */
+ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
+ const Word16 frameno, /* i : flag indicating index of current subfr. */
+ const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */
+ const Word32 element_brate, /* i : element bitrate */
+ const Word16 mct_on /* i : flag mct block (1) or stereo (0) */
+);
+
+#endif // IVAS_FLOAT_FIXED
+
+#endif
diff --git a/lib_com/prot_fx1.h b/lib_com/prot_fx1.h
deleted file mode 100644
index db593758b3a584e397435d336abb51f134fb53d8..0000000000000000000000000000000000000000
--- a/lib_com/prot_fx1.h
+++ /dev/null
@@ -1,630 +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 PROT_FX1_H
-#define PROT_FX1_H
-
-#include
-#include
-#include
-#include "options.h"
-#include "typedef.h"
-#include "cnst.h"
-#include "stl.h"
-#define mvr2r_Word32( x, y, n ) Copy32( x, y, n )
-#define mvr2r_Word16( x, y, n ) Copy( x, y, n )
-
-int16_t norm_ul( uint32_t UL_var1 );
-Word16 usdequant_fx( /* Qx*/
- const Word16 idx, /* i: quantizer index Q0*/
- const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/
- const Word16 delta /* i: quantization step Qy*/
-);
-
-Word16 usquant_fx( /* o: index of the winning codeword */
- const Word16 x, /* i: scalar value to quantize Qx*/
- Word16 *xq, /* o: quantized value Qx*/
- const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/
- const Word16 delta, /* i: quantization step Qx-1*/
- const Word16 cbsize /* i: codebook size */
-);
-
-Word32 Dot_product( /* o : Sum */
- const Word16 x[], /* i : 12bits: x vector */
- const Word16 y[], /* i : 12bits: y vector */
- const Word16 lg /* i : vector length */
-);
-
-Word32 dotp_fx( /* o : dot product of x[] and y[] */
- const Word16 x[], /* i : vector x[] */
- const Word16 y[], /* i : vector y[] */
- const Word16 n, /* i : vector length */
- Word16 *exp /* (o) : exponent of result (0..+30) */
-);
-
-Word32 sum2_fx( /* o : sum of all squared vector elements Q(2x+1)*/
- const Word16 *vec, /* i : i vector Qx*/
- const Word16 lvec /* i : length of i vector */
-);
-
-Word32 sum2_fx_mod( /* o : sum of all squared vector elements Q(2x+1)*/
- const Word16 *vec, /* i : i vector Qx*/
- const Word16 lvec /* i : length of i vector */
-);
-
-void Copy(
- const Word16 x[], /* i : i vector */
- Word16 y[], /* o : output vector */
- const Word16 L /* i : vector length */
-);
-
-void Copy32(
- const Word32 x[], /* i : i vector */
- Word32 y[], /* o : output vector */
- const Word16 L /* i : vector length */
-);
-
-void set16_fx(
- Word16 y[], /* i/o: Vector to set */
- const Word16 a, /* i : Value to set the vector to */
- const Word16 N /* i : Lenght of the vector */
-);
-
-void set32_fx(
- Word32 y[], /* i/o: Vector to set */
- const Word32 a, /* i : Value to set the vector to */
- const Word16 N /* i : Lenght of the vector */
-);
-
-void Copy_Scale_sig(
- const Word16 x[], /* i : signal to scale i Qx */
- Word16 y[], /* o : scaled signal output Qx */
- const Word16 lg, /* i : size of x[] Q0 */
- const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
-);
-
-void Copy_Scale_sig_16_32(
- const Word16 x[], /* i : signal to scale i Qx */
- Word32 y[], /* o : scaled signal output Qx */
- const Word16 lg, /* i : size of x[] Q0 */
- const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
-);
-
-void Copy_Scale_sig_16_32_no_sat(
- const Word16 x[], /* i : signal to scale input Qx */
- Word32 y[], /* o : scaled signal output Qx */
- const Word16 lg, /* i : size of x[] Q0 */
- const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
-);
-
-void Copy_Scale_sig_32_16(
- const Word32 x[], /* i : signal to scale i Qx */
- Word16 y[], /* o : scaled signal output Qx */
- const Word16 lg, /* i : size of x[] Q0 */
- const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
-);
-
-void Scale_sig32(
- Word32 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 */
-);
-
-void Random_Fill(
- Word16 *seed, /* i/o: random seed */
- Word16 n, /* i : number of values */
- Word16 *y, /* o : output values */
- Word16 scaling /* i : scaling of values */
-);
-
-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 mean_fx( /* o : mean of vector */
- const Word16 *vec_fx, /* i : i vector */
- const Word16 lvec_fx /* i : length of i vector */
-);
-
-void Vr_add(
- const Word16 *in1, /* i : Input vector 1 */
- const Word16 *in2, /* i : Input vector 2 */
- Word16 *out, /* o : Output vector that contains vector 1 + vector 2 */
- Word16 Len /* i : Vector lenght */
-);
-void sort_fx(
- Word16 *r, /* i/o: Vector to be sorted in place */
- Word16 lo, /* i : Low limit of sorting range */
- Word16 up /* I : High limit of sorting range */
-);
-void sort_32_fx(
- Word32 *r, /* i/o: Vector to be sorted in place */
- const Word16 lo, /* i : Low limit of sorting range */
- const Word16 up /* I : High limit of sorting range */
-);
-Word16 minimum_fx( /* o : index of the minimum value in the input vector */
- const Word16 *vec_fx, /* i : input vector */
- const Word16 lvec_fx, /* i : length of input vector */
- Word16 *min_fx /* o : minimum value in the input vector */
-);
-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 minimum_abs32_fx( /* o : index of the minimum value in the input vector */
- const Word32 *vec_fx, /* i : input vector */
- const Word16 lvec_fx, /* i : length of input vector */
- Word32 *min_fx /* o : minimum value in the input vector */
-);
-Word16 minimum_32_fx( /* o : index of the minimum value in the input vector */
- const Word32 *vec_fx, /* i : input vector */
- const Word16 lvec_fx, /* i : length of input vector */
- Word32 *min_fx /* o : minimum value in the input vector */
-);
-Word16 maximum_32_fx( /* o : index of the maximum value in the input vector */
- const Word32 *vec, /* i : input vector */
- const Word16 lvec, /* i : length of input vector */
- Word32 *max_val /* o : maximum value in the input vector */
-);
-Word16 maximum_abs_32_fx( /* o : index of the maximum value in the input vector */
- const Word32 *vec, /* i : input vector */
- const Word16 lvec, /* i : length of input vector */
- Word32 *max_val /* o : maximum value in the input vector */
-);
-#ifdef IVAS_FLOAT_FIXED
-/*! r: index of the maximum value in the input vector */
-Word16 maximum_s(
- const Word16 *vec, /* i : input vector */
- const Word16 lvec, /* i : length of input vector */
- Word16 *max /* o : maximum value in the input vector */
-);
-
-/*! r: index of the minimum value in the input vector */
-Word16 minimum_s(
- const Word16 *vec, /* i : Input vector */
- const Word16 lvec, /* i : Vector length */
- Word16 *min_val /* o : minimum value in the input vector */
-);
-#endif
-Word16 Exp16Array(
- const Word16 n, /* (i): Array size */
- const Word16 *sx /* (i): Data array */
-);
-Word16 Exp32Array(
- const Word16 n, /* (i): Array size */
- const Word32 *sx /* (i): Data array */
-);
-Word32 sum16_32_fx( /* o : sum of all vector elements Qx*/
- const Word16 *vec, /* i : input vector Qx*/
- const Word16 lvec /* i : length of input vector */
-);
-Word32 sum32_sat( /* o : sum of all vector elements Qx*/
- const Word32 *vec, /* i : input vector Qx*/
- const Word16 lvec /* i : length of input vector */
-);
-Word32 var_fx_32( /* o: variance of vector Qx+16*/
- const Word16 *x, /* i: input vector Qx*/
- const Word16 Qx,
- const Word16 len /* i: length of inputvector */
-);
-Word16 var_fx( /* o: variance of vector Qx*/
- const Word16 *x, /* i: input vector Qx*/
- const Word16 Qx,
- const Word16 len /* i: length of inputvector */
-);
-Word16 std_fx( /* o: standard deviation */
- const Word16 x[], /* i: input vector */
- const Word16 len /* i: length of the input vector */
-);
-Word32 dot_product_mat_fx( /* o : the dot product x'*A*x */
- const Word16 *x, /* i : vector x Q15 */
- const Word32 *A, /* i : matrix A Q0*/
- const Word16 m /* i : vector & matrix size */
-
-);
-void Vr_subt(
- const Word16 x1[], /* i : Input vector 1 */
- const Word16 x2[], /* i : Input vector 2 */
- Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */
- Word16 N /* i : Vector lenght */
-);
-Word16 vquant_fx( /* o: index of the winning codevector */
- Word16 x[], /* i: vector to quantize Q13 */
- const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/
- Word16 xq[], /* o: quantized vector Q13 */
- const Word16 cb[], /* i: codebook Q13 */
- const Word16 dim, /* i: dimension of codebook vectors */
- const Word16 cbsize /* i: codebook size */
-);
-Word16 w_vquant_fx(
- Word16 x[], /* i: vector to quantize in Q10 */
- Word16 Qx,
- const Word16 weights[], /* i: error weights in Q0 */
- Word16 xq[], /* o: quantized vector in Q15 */
- const Word16 cb[], /* i: codebook in Q15 */
- const Word16 cbsize, /* i: codebook size */
- const Word16 rev_vect /* i: reverse codebook vectors */
-);
-Word16 emaximum_fx( /* o : return index with max energy value in vector Q0 */
- const Word16 Qvec, /* i : Q of input vector Q0 */
- const Word16 *vec, /* i : input vector Qx */
- const Word16 lvec, /* i : length of input vector Q0 */
- Word32 *ener_max /* o : maximum energy value Q0 */
-);
-Word16 emaximum_32fx( /* o : return index with max energy value in vector Q0 */
- const Word16 Qvec, /* i : Q of input vector Q0 */
- const Word32 *vec, /* i : input vector Qx */
- const Word16 lvec, /* i : length of input vector Q0 */
- Word32 *ener_max /* o : maximum energy value Q0 */
-);
-Word32 Mean32( /* o : mean of the elements of the vector */
- const Word32 in[], /* i : input vector */
- const Word16 L /* i : length of input vector */
-);
-Word32 sum32_fx( /* o : sum of all vector elements Qx*/
- const Word32 *vec, /* i : input vector Qx*/
- const Word16 lvec /* i : length of input vector */
-);
-Word16 sum16_fx( /* o : sum of all vector elements Qx*/
- const Word16 *vec, /* i : input vector Qx*/
- const Word16 lvec /* i : length of input vector */
-);
-Word16 Random( /* o : output random value */
- Word16 *seed /* i/o: random seed */
-);
-Word16 own_random2_fx( Word16 seed );
-void iDiv_and_mod_32(
- const Word32 Numer, /* i : 32 bits numerator */
- const Word16 Denom, /* i : 16 bits denominator */
- Word32 *Int_quotient, /* o : integer result of the division (int)(num/den) */
- Word32 *Int_mod, /* o : modulo result of the division num-((int)(num/den)*den)*/
- const Word16 rshift /* i : 0 if no right shift / 1 if the denom is right shifted by 1 */
-);
-void pz_filter_sp_fx(
- const Word16 b[],
- const Word16 a[],
- Word16 x[],
- Word16 y[],
- Word16 buf[],
- Word16 PNR,
- Word16 PDR,
- Word16 N,
- Word16 Qa );
-Word32 root_a_fx(
- Word32 a,
- Word16 Q_a,
- Word16 *exp_out );
-Word32 root_a_over_b_fx(
- Word32 a,
- Word16 Q_a,
- Word32 b,
- Word16 Q_b,
- Word16 *exp_out );
-void fir_fx( const Word16 x[], /* i : input vector Qx*/
- const Word16 h[], /* i : impulse response of the FIR filter Q12*/
- Word16 y[], /* o : output vector (result of filtering) Qx*/
- Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/
- const Word16 L, /* i : input vector size */
- const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */
- const Word16 upd /* i : 1 = update the memory, 0 = not */
- ,
- Word16 shift /* i : difference between Q15 and scaling of h[] */
-);
-
-void fir_fx( const Word16 x[], /* i : input vector Qx*/
- const Word16 h[], /* i : impulse response of the FIR filter Q12*/
- Word16 y[], /* o : output vector (result of filtering) Qx*/
- Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/
- const Word16 L, /* i : input vector size */
- const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */
- const Word16 upd /* i : 1 = update the memory, 0 = not */
- ,
- Word16 shift /* i : difference between Q15 and scaling of h[] */
-);
-
-void v_add_32(
- const Word32 x1[], /* i : Input vector 1 */
- const Word32 x2[], /* i : Input vector 2 */
- Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */
- const Word16 N /* i : Vector length */
-);
-
-void v_shr_32(
- Word32 x1[], /* i : Input vector 1 */
- Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */
- const Word16 N, /* i : Vector length */
- Word16 shift /*shift value*/
-);
-
-void v_sub_32(
- const Word32 x1[], /* i : Input vector 1 */
- const Word32 x2[], /* i : Input vector 2 */
- Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */
- const Word16 N /* i : Vector length */
-);
-
-
-void v_add_16(
- const Word16 x1[], /* i : Input vector 1 */
- const Word16 x2[], /* i : Input vector 2 */
- Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */
- const Word16 N /* i : Vector length */
-);
-
-void v_sub_16(
- const Word16 x1[], /* i : Input vector 1 */
- const Word16 x2[], /* i : Input vector 2 */
- Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */
- const Word16 N /* i : Vector length */
-);
-
-
-Word16 squant_fx( /* o: index of the winning codeword */
- const Word16 x, /* i: scalar value to quantize */
- Word16 *xq, /* o: quantized value */
- const Word16 cb[], /* i: codebook */
- const Word16 cbsize /* i: codebook size */
-);
-void pz_filter_dp_fx(
- const Word16 b[],
- const Word16 a[],
- Word16 x[],
- Word16 y[],
- Word32 buf[],
- Word16 PNR,
- Word16 PDR,
- Word16 N,
- Word16 Qa );
-void Copy_Scale_sig32_16(
- const Word32 *src, /* i : signal to scale Qx */
- Word16 *dst, /* o : scaled signal Qx */
- Word16 len, /* i : size of x[] Q0 */
- Word16 exp0 ); /* i : exponent: x = round(x << exp) Qx ?exp */
-
-void v_multc_att(
- const Word16 x[], /* i : Input vector Qx */
- const Word16 att, /* i : Constant Q15, <= MAX_16 */
- Word16 y[], /* o : Output vector that contains att*x */
- const Word16 N /* i : Vector length */
-);
-void v_multc_att32(
- const Word32 x[], /* i : Input vector Qx */
- const Word16 att, /* i : Constant Q15, <= MAX_16 */
- Word32 y[], /* o : Output vector that contains att*x */
- const Word16 N /* i : Vector length */
-);
-void v_multc_att3232(
- const Word32 x[], /* i : Input vector Qx */
- const Word32 att, /* i : Constant Q32, <= MAX_32 */
- Word32 y[], /* o : Output vector that contains att*x */
- const Word16 N /* i : Vector length */
-);
-void v_L_mult_1616(
- const Word16 x1[], /* i : Input vector 1 */
- const Word16 x2[], /* i : Input vector 2 */
- Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */
- const Word16 N /* i : Vector length */
-);
-void v_L_mult_3216(
- const Word32 x1[], /* i : Input vector 1 */
- const Word16 x2[], /* i : Input vector 2 */
- Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */
- const Word16 N /* i : Vector length */
-);
-void add_vec_fx(
- const Word16 x1[], /* i : Input vector 1 */
- const Word16 Qx1, /* i : SCaling of input 1 */
- const Word16 x2[], /* i : Input vector 2 */
- const Word16 Qx2, /* i : SCaling of input 1 */
- Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */
- const Word16 Qy, /* i : SCaling of output 1 */
- const Word16 N /* i : Vector lenght */
-);
-Word32 Add_flt32_flt32( /* o: Result (Normalized) */
- Word32 a, /* i: 1st Value */
- Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */
- Word32 b, /* i: 2nd Value */
- Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */
- Word16 *exp_out /* o: Exponent of Result */
-);
-Word32 Mul_flt32_Q15( /* o: Result (Normalized) */
- Word32 value, /* i: Pseudo_float Value */
- Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */
- Word16 frac /* i: Q15 value */
-);
-Word32 Div_flt32_flt32( /* o: Result (Normalized) */
- Word32 a, /* i: 1st Value */
- Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */
- Word32 b, /* i: 2nd Value */
- Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */
- Word16 *exp_out /* o: Exponent of Result */
-);
-Word32 Calc_Energy_Autoscaled( /* o: Result (Energy) */
- const Word16 *signal, /* i: Signal */
- Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */
- Word16 len, /* i: Frame Length */
- Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */
-);
-Word16 Find_Max_Norm16( const Word16 *src, Word16 len );
-
-Word16 Find_Max_Norm32( const Word32 *src, Word16 len );
-
-Word32 Sqrt_Ratio32( /* o: Result in Q31 */
- Word32 L_val1, /* i: Mantisa of Val1 */
- Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */
- Word32 L_val2, /* i: Mantisa of Val2 */
- Word16 exp2, /* i: Exp of Val2 (same as exp1) */
- Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */
-);
-
-Word16 Invert16( /* result in Q'15 + 'exp' */
- Word16 val,
- Word16 *exp );
-
-Word16 find_rem( Word16 n, Word16 m, Word16 *r );
-Word32 find_remd( Word32 n, Word32 m, Word32 *r );
-
-Word16 rint_new_fx(
- Word32 x /*Q16 */
-);
-
-Word16 erb_diff_search_fx( Word16 *prev_erb, const Word16 *curr_erb, Word16 *dif_erb, Word16 *pow_spec, const Word16 *cb_fx, Word16 cb_size, Word16 cb_dim, Word16 offset );
-
-void Acelp_dec_total_exc(
- Word16 *exc_fx, /* i/o: adapt. excitation exc */
- Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */
- const Word16 gain_code16, /* i : Gain code Q0 */
- const Word16 gain_pit_fx, /* i ; Pitch gain in Q14 */
- const Word16 i_subfr, /* i ; subfr */
- const Word16 *code_fx, /* i : code in Q9 */
- const Word16 L_subfr /* i : Subframne lenght */
-);
-
-UWord32 UL_inverse( const UWord32 UL_val, Word16 *exp );
-
-UWord32 UL_div( const UWord32 UL_num, const UWord32 UL_den );
-
-Word16 ratio( const Word32 numer, const Word32 denom, Word16 *expo );
-
-void hp400_12k8_fx(
- Word16 signal[], /* i/o: input signal / output is divided by 16 */
- const Word16 lg, /* i : lenght of signal */
- Word16 mem[] /* i/o: filter memory [6] */
-);
-
-#ifdef IVAS_FLOAT_FIXED
-void hp400_12k8_ivas_fx(
- Word16 signal[], /* i/o: input signal / output is divided by 16 */
- const Word16 lg, /* i : lenght of signal */
- Word16 mem[] /* i/o: filter memory [6] */
-);
-#endif
-Word16 dot_prod_satcontr( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len );
-
-void E_UTIL_f_convolve( const Word16 x[], const Word16 h[], Word16 y[], const Word16 size );
-
-void floating_point_add(
- Word32 *mx, /* io: mantissa of the addend Q31 */
- Word16 *ex, /* io: exponent of the addend Q0 */
- const Word32 my, /* i: mantissa of the adder Q31 */
- const Word16 ey /* i: exponent of the adder Q0 */
-);
-
-
-#ifdef IVAS_FLOAT_FIXED
-void fft_fx(
- Word32 *re, /* i/o: real part */
- Word32 *im, /* i/o: imag part */
- const Word16 length, /* i : length of fft */
- const Word16 s /* i : sign */
-);
-
-#endif
-void delay_signal(
- Word16 x[], /* i/o: signal to be delayed */
- const Word16 len, /* i : length of the input signal */
- Word16 mem[], /* i/o: synchronization memory */
- const Word16 delay /* i : delay in samples */
-);
-
-void delay_signal32(
- Word32 x[], /* i/o: signal to be delayed */
- const Word16 len, /* i : length of the input signal */
- Word32 mem[], /* i/o: synchronization memory */
- const Word16 delay /* i : delay in samples */
-);
-
-Word16 lin_interp_fx(
- const Word16 x, /* i : the value to be mapped */
- const Word16 x1, /* i : source range interval: low end */
- const Word16 y1, /* i : source range interval: high end */
- const Word16 x2, /* i : target range interval: low */
- const Word16 y2, /* i : target range interval: high */
- const Word16 flag_sat /* i : flag to indicate whether to apply saturation */
-);
-
-Word16 ceil_log_2( UWord64 val );
-
-Word32 imax_pos_fx(
- const Word32 *y /* i : Input vector for peak interpolation */
-);
-
-#ifdef IVAS_FLOAT_FIXED
-void re8_k2y_fx(
- const Word16 *k, /* i : Voronoi index k[0..7] */
- const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) */
- Word16 *y /* o : 8-dimensional point y[0..7] in RE8 */
-);
-
-void re8_PPV_fx(
- const Word32 x[], /* i : point in R^8Q15 */
- Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */
-);
-
-void msvq_dec_fx(
- const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */
- const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
- const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */
- const Word16 stages, /* i : Number of stages */
- const Word16 N, /* i : Vector dimension */
- const Word16 maxN, /* i : Codebook dimension */
- const Word16 Idx[], /* i : Indices */
- const Word16 applyIDCT_flag, /* i : applyIDCT flag */
- const Word32 *invTrfMatrix, /* i : synthesis matrix */
- Word32 *uq, /* o : quantized vector */
- Word16 *uq_ind, /* o : quantized vector (fixed point) */
- Word16 exp );
-
-void dec_FDCNG_MSVQ_stage1_fx(
- Word16 j_full, /* i : index full range */
- Word16 n, /* i : dimension to generate */
- const Word32 *invTrfMatrix, /* i : IDCT matrix for synthesis */
- const DCTTYPE idcttype, /* i : specify which IDCT */
- Word32 *uq, /* o : synthesized stage1 vector */
- Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */
-);
-
-void dctT2_N_apply_matrix_fx(
- const Word32 *input, /* i : input in fdcng or DCT(fdcng) domain */
- Word32 *output, /* o : output in DCT(fdcng) or fdcng ordomain */
- const Word16 dct_dim, /* i : dct processing dim possibly truncated */
- const Word16 fdcngvq_dim, /* i : fdcng domain length */
- const Word32 *matrix, /* i : IDCT matrix */
- const Word16 matrix_row_dim, /* i : */
- const DCTTYPE dcttype /* i : matrix operation type */
-);
-
-#endif
-#endif
diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c
index fe4842a05a4eb634bc79781832eb12c63a0ac637..23c42119bc8bef6c19e295fa0e4eff816d51db35 100644
--- a/lib_com/pvq_com_fx.c
+++ b/lib_com/pvq_com_fx.c
@@ -3,10 +3,9 @@
====================================================================================*/
#include
#include "options.h" /* Compilation switches */
-#include "prot_fx1.h"
-#include "prot_fx2.h" /* Function prototypes */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
/*! r: Approximate integer division for positive input using lookup table */
UWord32 intLimCDivPos_fx(
@@ -55,16 +54,21 @@ static void nearProjQ15_fx(
)
{
const Word16 a[4] = { 14967, -25518, 3415, 32351 };
+ move16();
+ move16();
+ move16();
+ move16();
Word32 b;
UWord16 lsb;
b = L_deposit_l( a[0] );
- b = L_shl( (Word32) add( a[1], extract_h( L_mult0( (Word16) b, x ) ) ), 1 );
+ b = L_shl( L_deposit_l( add( a[1], extract_h( L_mult0( extract_l( b ), x ) ) ) ), 1 );
Mpy_32_16_ss( b, x, &b, &lsb );
- b = L_add( (Word32) a[2], b );
+ b = L_add( L_deposit_l( a[2] ), b );
Mpy_32_16_ss( b, x, &b, &lsb );
- b = L_add( (Word32) a[3], b );
+ b = L_add( L_deposit_l( a[3] ), b );
*result = extract_l( b );
+ move16();
return;
}
@@ -82,13 +86,14 @@ void obtainEnergyQuantizerDensity_fx(
Word16 Rnrg, den, n;
den = sub( shl( L, 1 ), 1 );
- IF( den <= 67 )
+ IF( LE_16( den, 67 ) )
{
Rnrg = extract_l( intLimCDivPos_fx( L_deposit_l( R ), den ) );
}
ELSE
{
n = norm_s( den );
+ move16();
Rnrg = shr( div_s( R, shl( den, n ) ), sub( 15, n ) );
}
Rnrg = add( Rnrg, 28 );
@@ -98,6 +103,7 @@ void obtainEnergyQuantizerDensity_fx(
Rnrg = s_max( Rnrg, 3 );
*Density = obtainEnergyQuantizerDensity_f[Rnrg];
+ move16();
return;
}
@@ -113,6 +119,7 @@ void dsDirac2Dirac_fx(
)
{
*diracs = dsDiracsTab[dsDiracIndex];
+ move16();
return;
}
@@ -132,17 +139,17 @@ void dsDiracPerQuanta_fx(
sv = frQuanta[td];
nsv = sv[0];
-
+ move16();
t_quanta_o = sub( t_quanta, QUANTAQ3OFFSET );
- IF( GE_16( t_quanta_o, sv[nsv] ) )
+ if ( GE_16( t_quanta_o, sv[nsv] ) )
{
*DsIdx = nsv;
move16();
return;
}
- IF( LE_16( t_quanta_o, sv[1] ) )
+ if ( LE_16( t_quanta_o, sv[1] ) )
{
*DsIdx = 1;
move16();
@@ -151,11 +158,11 @@ void dsDiracPerQuanta_fx(
dsIndex = shl( 1, frQuanta[0][td] );
- if ( GT_16( t_quanta_o, sv[shr( nsv, 1 )] ) )
+ IF( GT_16( t_quanta_o, sv[shr( nsv, 1 )] ) )
{
dsIndex = sub( nsv, dsIndex );
}
- FOR( i = sub( frQuanta[0][td], 1 ); i >= 0; i-- )
+ FOR( i = frQuanta[0][td] - 1; i >= 0; i-- )
{
dsIndex = add( dsIndex, shl( sub( shl( lshr( sub( sv[dsIndex], t_quanta_o ), 15 ), 1 ), 1 ), i ) );
}
@@ -163,13 +170,14 @@ void dsDiracPerQuanta_fx(
dsIndex = add( dsIndex, lshr( sub( sv[dsIndex], t_quanta_o ), 15 ) );
dsIndex = sub( dsIndex, lshr( sub( 1, dsIndex ), 15 ) );
- IF( EQ_16( dsm, PVQ_CONS ) )
+ if ( EQ_16( dsm, PVQ_CONS ) )
{
*DsIdx = dsIndex;
move16();
return;
}
*DsIdx = add( dsIndex, lshr( sub( add( sv[add( dsIndex, 1 )], sv[dsIndex] ), shl( t_quanta_o, 1 ) ), 15 ) );
+ move16();
return;
}
@@ -188,6 +196,7 @@ void QuantaPerDsDirac_fx(
move16();
}
*Quanta = add( *Quanta, QUANTAQ3OFFSET );
+ move16();
return;
}
@@ -212,7 +221,7 @@ void conservativeL1Norm_fx(
frQuantaL = hBitsN[L];
*Qreservplus = add( Qreserv, sub( Qvec, QUANTAQ3OFFSET ) );
-
+ move16();
dsDiracPerQuanta_fx( L, Qvec, Fcons, hBitsN, &Minit );
Mprime = Minit;
@@ -222,6 +231,7 @@ void conservativeL1Norm_fx(
Qtestminus = (short) frQuantaL[Mprime];
move16();
*Qspare = sub( Qavail, Qtestminus );
+ move16();
Mprime = sub( Mprime, 1 );
}
WHILE( ( Mprime >= 0 ) && LT_16( *Qspare, QUANTAQ3OFFSET ) );
@@ -229,12 +239,16 @@ void conservativeL1Norm_fx(
if ( Mprime < 0 )
{
*Qspare = add( Qavail, QUANTAQ3OFFSET ); /* single op */
+ move16();
}
dsDirac2Dirac_fx( add( Mprime, 1 ), Dvec );
*Dspecplus = add( Dspec, *Dvec );
+ move16();
*Qreservplus = sub( *Qreservplus, (short) frQuantaL[Minit] );
+ move16();
*Qspare = sub( *Qspare, QUANTAQ3OFFSET );
+ move16();
return;
}
@@ -265,17 +279,23 @@ void bandBitsAdjustment_fx(
L_tmp = L_deposit_l( sub( Breserv, Bff ) );
Btemp = extract_l( intLimCDivSigned_fx( L_tmp, s_min( D, 3 ) ) ); /* result always fits in Word16 */
*Breservplus = add( Bband, Breserv );
+ move16();
}
ELSE
{
Btemp = 0;
move16();
*Breservplus = add( Bband, Bff );
+ move16();
}
*Bband_adj = s_min( extract_l( L_mult( L, 40 ) ), Bband );
+ move16();
*Brem = sub( Bavail, Bff );
+ move16();
*Bband_adj = s_min( *Brem, add( *Bband_adj, Btemp ) );
+ move16();
*Bband_adj = s_max( 0, *Bband_adj );
+ move16();
return;
}
@@ -315,6 +335,7 @@ static void Ratio_rQ3_fx(
tmp = add( 1 << 7, Ratio_base2Q11_fx( opp, near ) );
*result = shr( tmp, 8 );
+ move16();
return;
}
@@ -331,6 +352,7 @@ void densityAngle2RmsProjDec_fx(
Word16 oppTail, nearTail;
phiQ14q = (Word16) intLimCDivPos_fx( L_shl( L_deposit_l( indexphi ), 13 ), shr( D, 1 ) );
+ move16();
if ( indexphi < 0 )
{
phiQ14q = 1 << 13; /* one op */
@@ -343,8 +365,11 @@ void densityAngle2RmsProjDec_fx(
IF( s_or( oppTail, nearTail ) < 0 )
{
*oppQ15 = s_and( oppTail, ( 1 << 15 ) - 1 );
+ move16();
*nearQ15 = s_and( nearTail, ( 1 << 15 ) - 1 );
+ move16();
*oppRatioQ3 = shl( add( 1, shl( nearTail, 1 ) ), 14 );
+ move16();
}
ELSE
{
@@ -366,6 +391,7 @@ void densityAngle2RmsProjEnc_fx(
)
{
*indexphi = mult_r( shl( D, 1 ), phiQ14uq );
+ move16();
if ( s_and( D, 1 ) > 0 )
{
*indexphi = -1; /* one op */
@@ -409,7 +435,7 @@ void NearOppSplitAdjustment_fx(
move16();
IF( GT_16( Nhead, 1 ) )
{
- qavg = extract_h( L_shl( intLimCDivSigned_fx( (Word32) qboth, Np ), 16 ) ); /* qboth may be negative */
+ qavg = extract_h( L_shl( intLimCDivSigned_fx( L_deposit_l( qboth ), Np ), 16 ) ); /* qboth may be negative */
dsDiracPerQuanta_fx( Ntail, qavg, FlagCons, hBitsN, &Midx );
QuantaPerDsDirac_fx( Nhead, Midx, hBitsN, &qmin );
qskew = sub( qavg, qmin );
@@ -425,6 +451,7 @@ void NearOppSplitAdjustment_fx(
L_QIb = (Word32) intLimCDivPos_fx( L_qnum, QIa );
}
*qnear = qboth;
+ move16();
#ifdef BASOP_NOGLOB
QIb = extract_h( L_shl_o( L_QIb, 16, &Overflow ) ); /* may saturate */
#else
@@ -433,9 +460,12 @@ void NearOppSplitAdjustment_fx(
if ( LE_16( QIb, qboth ) )
{
*qnear = QIb;
+ move16();
}
*qopp = sub( qboth, *qnear );
+ move16();
*qglobalupd = sub( qglobal, sub( qac, qzero ) );
+ move16();
return;
}
@@ -462,7 +492,7 @@ void apply_gain_fx(
FOR( band = 0; band < num_sfm; band++ )
{
g = gains[ord[band]];
-
+ move16();
FOR( i = band_start[band]; i < band_end[band]; i++ )
{
/*xq[i] *= g; */
@@ -500,11 +530,13 @@ void fine_gain_quant_fx(
UWord16 lsb;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
FOR( band = 0; band < num_sfm; band++ )
{
gbits = gain_bits[ord[band]];
+ move16();
test();
IF( fg_pred[band] != 0 && gbits > 0 )
{
@@ -539,6 +571,7 @@ void fine_gain_quant_fx(
L_tmp = L_mult0( fg_pred[band], tmp1 ); /*12+exp1 */
fg_pred[band] = round_fx( L_shl( L_tmp, sub( 16, exp1 ) ) ); /*12+exp1+16-exp1-16=12 */
+ move16();
}
}
diff --git a/lib_com/range_com_fx.c b/lib_com/range_com_fx.c
index 4fb29bd5883446d5ed6433dcb0545554ce64eb06..22a7fb8eaf75a13955baba8ca1a0b919f223614c 100644
--- a/lib_com/range_com_fx.c
+++ b/lib_com/range_com_fx.c
@@ -5,8 +5,7 @@
#include
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
-#include "prot_fx1.h"
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*-------------------------------------------------------------------*
@@ -48,6 +47,7 @@ void rangeCoderFinalizationFBits_fx(
if ( x >= 0 )
{
L_Bq15 = (Word32) UL_lshr( INTrc, x );
+ move32();
}
E = 2;
@@ -58,10 +58,12 @@ void rangeCoderFinalizationFBits_fx(
UL_tmp = UL_lshl( UL_deposit_l( Bq15ui16 ), 1 );
Mpy_32_16_uu( UL_tmp, Bq15ui16, &h, &l );
L_Bq15 = (Word32) h;
+ move32();
E = add( shl( B, 1 ), extract_l( L_lshr( L_sub( ( ( 1L << 16 ) - 1L ), L_Bq15 ), 31 ) ) );
B = E;
move16();
}
*FBits = sub( *FBits, B );
+ move16();
return;
}
diff --git a/lib_com/re8_ppv_fx.c b/lib_com/re8_ppv_fx.c
index a786f99362ad656953fb2128d5e1ddd84c4977c0..f330f22c2070006ab76240ea118b83e868c1ce10 100644
--- a/lib_com/re8_ppv_fx.c
+++ b/lib_com/re8_ppv_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
#include "stl.h"
/*-------------------------------------------------------------------*
diff --git a/lib_com/re8_util_fx.c b/lib_com/re8_util_fx.c
index db58c3fae5da1da710b78215498462ac6771703b..00909e2f5b6a48602dc439213ba30568fb7b4a19 100644
--- a/lib_com/re8_util_fx.c
+++ b/lib_com/re8_util_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*-------------------------------------------------------------------*
diff --git a/lib_com/recovernorm_fx.c b/lib_com/recovernorm_fx.c
index e5b72fc51010adc4f8b23990074a364c12b52c4c..a61e1f1839391144f9e9611ab813593c6c953260 100644
--- a/lib_com/recovernorm_fx.c
+++ b/lib_com/recovernorm_fx.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
/*--------------------------------------------------------------------------*
* recovernorm_fx()
diff --git a/lib_com/reordvct_fx.c b/lib_com/reordvct_fx.c
index a26480626f0b2419b49dd9c2debfa067261250dd..07bc21bc836e768a71efb553917fdb12828158ca 100644
--- a/lib_com/reordvct_fx.c
+++ b/lib_com/reordvct_fx.c
@@ -31,8 +31,8 @@
*******************************************************************************************************/
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
/*--------------------------------------------------------------------------*
diff --git a/lib_com/residu.c b/lib_com/residu.c
index 0f1cdb33d645c5aea8fff65a18e9aaf95466032b..2a3ad964dec02f3f27063c67509577323bd961a7 100644
--- a/lib_com/residu.c
+++ b/lib_com/residu.c
@@ -87,16 +87,18 @@ void residu_ivas_fx(
)
{
Word32 s;
- int16_t i, j;
+ Word16 i, j;
- for ( i = 0; i < l; i++ )
+ FOR( i = 0; i < l; i++ )
{
s = x[i];
- for ( j = 1; j <= m; j++ )
+ move32();
+ FOR( j = 1; j <= m; j++ )
{
- s = L_add( s, L_shl( Mpy_32_16_1( x[i - j], a[j] ), Q15 - a_exp ) );
+ s = L_add( s, L_shl( Mpy_32_16_1( x[sub( i, j )], a[j] ), sub( Q15, a_exp ) ) );
}
y[i] = s;
+ move32();
}
return;
diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c
index 5849fb815170fe1b578122ca7d45949294559351..e06ef40eae5ed94fecd78ecca9673fc1e3dfec09 100644
--- a/lib_com/residu_fx.c
+++ b/lib_com/residu_fx.c
@@ -6,8 +6,7 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*--------------------------------------------------------------------*
* Residu3_lc_fx:
diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c
index 9590726d11fe9c45bebdbf79bd07fb6b09d83b54..3bf612bcad39210a2d74a38c66e9978286c493ff 100644
--- a/lib_com/rom_com.c
+++ b/lib_com/rom_com.c
@@ -41,7 +41,7 @@
#include "prot.h"
#include "basop_util.h"
#include "wmc_auto.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/* clang-format off */
@@ -2627,9 +2627,21 @@ const float interpol_frac2_mid[NB_SUBFR*3] = {
0.0f, 0.25f, 0.75f
};
+const Word16 interpol_frac2_mid_fx[NB_SUBFR * 3] = {
+ 8191, 24575, 0,
+ 8191, 24575, 0,
+ 0, 8191, 24575,
+ 0, 8191, 24575
+};
+
const float interpol_frac_12k8[NB_SUBFR] = {
0.25f, 0.5f, 0.75f, 1.0f
};
+
+const Word16 interpol_frac_12k8_fx[NB_SUBFR] = {
+ 8191, 16383, 24575, 32767
+};
+
const Word16 interpol_frac_fx[NB_SUBFR] = { 8192, 16384, 24576,32767 };
const float interpol_isp_amr_wb[NB_SUBFR] = {
@@ -10093,6 +10105,512 @@ const Word16 CLDFB80_60[] =
W16(0x0002), W16(0x0020), W16(0xff00), W16(0xe05e), W16(0x00a9)
};
+const Word16 CLDFB80_30[] =
+{
+ 0, -5, -30, 278, 8546,
+ 0, -4, -33, 306, 9141,
+ 0, -2, -29, 334, 9735,
+ 0, -1, -17, 363, 10324,
+ 0, -1, -13, 397, 10904,
+ 0, -1, -9, 435, 11474,
+ 0, -1, -2, 478, 12028,
+ 0, 0, 6, 525, 12566,
+ 0, 0, 12, 578, 13083,
+ 0, 0, 19, 637, 13579,
+ 0, 0, 26, 701, 14050,
+ 0, 0, 28, 771, 14493,
+ 0, 0, 30, 846, 14906,
+ 0, 0, 28, 927, 15285,
+ 0, 0, 4, 1012, 15630,
+ 0, -1, 27, 1105, 15937,
+ 0, -1, 26, 1201, 16209,
+ 0, 0, 29, 1299, 16442,
+ 0, 1, 31, 1399, 16638,
+ 0, 0, 36, 1498, 16794,
+ 0, 0, 41, 1594, 16911,
+ 0, -1, 45, 1687, 16990,
+ 0, 0, 46, 1774, 17036,
+ 0, 0, 49, 1853, 17052,
+ 0, 0, 50, 1922, 17040,
+ 0, 0, 50, 1981, 16999,
+ 0, 0, 45, 2027, 16924,
+ 0, -1, 39, 2061, 16809,
+ 0, -4, 27, 2080, 16651,
+ 0, -10, 12, 2084, 16463,
+ 0, -17, -10, 2075, 16161,
+ 0, -16, -23, 2054, 15746,
+ 0, -10, -31, 2012, 15307,
+ 0, -4, -32, 1949, 14834,
+ 0, -2, -26, 1862, 14334,
+ 0, -3, -15, 1752, 13816,
+ 0, -2, -1, 1616, 13288,
+ 0, 0, 13, 1454, 12753,
+ 0, -1, 25, 1267, 12212,
+ 0, 0, 35, 1054, 11663,
+ 0, 0, 42, 815, 11104,
+ 0, 1, 45, 552, 10536,
+ 0, -2, 42, 263, 9960,
+ 0, -3, 37, -51, 9379,
+ 0, 9, 33, -391, 8795,
+ 0, -12, 25, -755, 8207,
+ 0, 3, 4, -1144, 7616,
+ 0, 2, -14, -1557, 7022,
+ 0, -2, -34, -1992, 6427,
+ 0, 0, -54, -2449, 5833,
+ 0, 1, -73, -2927, 5244,
+ 0, 1, -90, -3425, 4659,
+ 0, 0, -107, -3942, 4072,
+ 0, 1, -123, -4476, 3479,
+ 0, 1, -139, -5026, 2877,
+ 0, -1, -156, -5590, 2272,
+ 0, 0, -176, -6167, 1684,
+ 0, 6, -199, -6754, 1144,
+ 0, 18, -223, -7348, 682,
+ 0, 32, -249, -7947, 282
+};
+
+const Word16 LDQMF_10_enc_fx[] =
+{
+ 2, -21, 79, -1890, 8640,
+ 1, -35, -5, -3186, 7299,
+ -1, -49, -126, -4597, 5995,
+ -3, -62, -285, -6085, 4767,
+ -5, -74, -484, -7607, 3646,
+ -6, -84, -721, -9114, 2656,
+ -7, -92, -989, -10557, 1815,
+ -7, -99, -1279, -11885, 1125,
+ -8, -104, -1579, -13052, 583,
+ -10, -108, -1869, -14017, 175,
+ -15, -112, -2129, -14742, -104,
+ -21, -117, -2336, -15204, -267,
+ -27, -123, -2462, -15389, -354,
+ -31, -132, -2482, -15293, -380,
+ -33, -144, -2370, -14926, -359,
+ -32, -156, -2104, -14306, -304,
+ -27, -166, -1668, -13461, -230,
+ -18, -169, -1049, -12429, -152,
+ -7, -160, -246, -11250, -82,
+ 6, -132, 739, -9972, -31
+};
+
+const Word16 LDQMF_16_enc_fx[] =
+{
+ 2, -18, 91, -1662, 8892,
+ 2, -27, 46, -2441, 8051,
+ 1, -36, -12, -3271, 7216,
+ 0, -45, -84, -4146, 6396,
+ -2, -53, -171, -5056, 5602,
+ -3, -61, -274, -5991, 4841,
+ -5, -69, -392, -6940, 4121,
+ -6, -76, -526, -7892, 3449,
+ -6, -82, -674, -8835, 2831,
+ -7, -88, -835, -9756, 2270,
+ -7, -93, -1007, -10643, 1767,
+ -7, -97, -1187, -11485, 1324,
+ -7, -101, -1373, -12269, 941,
+ -8, -104, -1560, -12985, 613,
+ -9, -106, -1744, -13622, 338,
+ -11, -109, -1921, -14172, 111,
+ -14, -111, -2084, -14626, -64,
+ -17, -114, -2228, -14977, -185,
+ -21, -117, -2346, -15223, -274,
+ -25, -121, -2433, -15361, -334,
+ -28, -126, -2481, -15389, -368,
+ -31, -132, -2484, -15307, -380,
+ -33, -139, -2436, -15119, -373,
+ -33, -146, -2332, -14828, -350,
+ -32, -154, -2167, -14440, -316,
+ -30, -161, -1935, -13962, -273,
+ -26, -166, -1635, -13402, -225,
+ -21, -169, -1263, -12769, -176,
+ -15, -168, -818, -12074, -128,
+ -8, -161, -301, -11328, -86,
+ 0, -147, 286, -10541, -50,
+ 9, -124, 942, -9725, -23
+};
+
+const Word16 LDQMF_20_enc_fx[] =
+{
+ 2, -17, 95, -1588, 8976,
+ 2, -24, 61, -2202, 8303,
+ 1, -32, 19, -2850, 7632,
+ 1, -39, -32, -3530, 6968,
+ 0, -46, -92, -4236, 6316,
+ -2, -53, -162, -4964, 5680,
+ -3, -59, -241, -5708, 5065,
+ -4, -65, -331, -6464, 4475,
+ -5, -71, -431, -7226, 3914,
+ -6, -76, -540, -7987, 3385,
+ -6, -81, -658, -8741, 2890,
+ -7, -86, -785, -9482, 2432,
+ -7, -90, -919, -10205, 2011,
+ -7, -94, -1060, -10901, 1628,
+ -7, -97, -1205, -11566, 1283,
+ -7, -100, -1354, -12194, 976,
+ -7, -103, -1504, -12778, 706,
+ -8, -105, -1653, -13314, 470,
+ -9, -107, -1798, -13797, 266,
+ -11, -109, -1938, -14222, 90,
+ -14, -111, -2068, -14585, -49,
+ -16, -113, -2187, -14883, -153,
+ -19, -115, -2290, -15114, -234,
+ -22, -118, -2376, -15276, -295,
+ -25, -121, -2439, -15369, -338,
+ -28, -125, -2478, -15391, -365,
+ -30, -130, -2488, -15343, -378,
+ -32, -135, -2467, -15226, -378,
+ -33, -141, -2411, -15042, -368,
+ -33, -147, -2319, -14794, -347,
+ -32, -153, -2186, -14483, -320,
+ -31, -159, -2012, -14114, -286,
+ -28, -164, -1794, -13691, -249,
+ -25, -167, -1531, -13219, -210,
+ -21, -169, -1221, -12702, -171,
+ -16, -168, -866, -12146, -133,
+ -10, -164, -464, -11556, -98,
+ -4, -155, -16, -10938, -67,
+ 3, -141, 476, -10298, -41,
+ 9, -121, 1012, -9642, -21,
+};
+const Word16 LDQMF_30_enc_fx[] =
+{
+ 2, -16, 100, -1489, 9088,
+ 2, -21, 79, -1890, 8640,
+ 2, -26, 55, -2307, 8191,
+ 2, -30, 27, -2740, 7744,
+ 1, -35, -5, -3186, 7299,
+ 0, -40, -41, -3646, 6858,
+ 0, -45, -81, -4116, 6423,
+ -1, -49, -126, -4597, 5995,
+ -2, -54, -174, -5087, 5576,
+ -3, -58, -227, -5583, 5166,
+ -3, -62, -285, -6085, 4767,
+ -4, -66, -347, -6591, 4380,
+ -5, -70, -413, -7099, 4006,
+ -5, -74, -484, -7607, 3646,
+ -6, -77, -559, -8113, 3300,
+ -6, -81, -638, -8616, 2970,
+ -6, -84, -721, -9114, 2656,
+ -7, -87, -807, -9604, 2359,
+ -7, -89, -896, -10086, 2078,
+ -7, -92, -989, -10557, 1815,
+ -7, -94, -1084, -11015, 1568,
+ -7, -97, -1181, -11458, 1338,
+ -7, -99, -1279, -11885, 1125,
+ -7, -101, -1379, -12294, 929,
+ -7, -102, -1479, -12684, 748,
+ -8, -104, -1579, -13052, 583,
+ -8, -105, -1677, -13398, 433,
+ -9, -107, -1774, -13720, 297,
+ -10, -108, -1869, -14017, 175,
+ -11, -109, -1960, -14287, 63,
+ -13, -110, -2047, -14529, -30,
+ -15, -112, -2129, -14742, -104,
+ -17, -113, -2205, -14926, -168,
+ -19, -115, -2274, -15080, -222,
+ -21, -117, -2336, -15204, -267,
+ -23, -118, -2388, -15296, -303,
+ -25, -121, -2430, -15358, -332,
+ -27, -123, -2462, -15389, -354,
+ -28, -126, -2482, -15388, -369,
+ -30, -129, -2489, -15356, -377,
+ -31, -132, -2482, -15293, -380,
+ -32, -136, -2460, -15200, -377,
+ -33, -140, -2423, -15078, -370,
+ -33, -144, -2370, -14926, -359,
+ -33, -148, -2299, -14746, -343,
+ -33, -152, -2211, -14539, -325,
+ -32, -156, -2104, -14306, -304,
+ -31, -160, -1979, -14047, -281,
+ -29, -163, -1833, -13765, -256,
+ -27, -166, -1668, -13461, -230,
+ -24, -168, -1482, -13136, -204,
+ -22, -169, -1276, -12791, -177,
+ -18, -169, -1049, -12429, -152,
+ -15, -168, -802, -12050, -127,
+ -11, -165, -534, -11657, -103,
+ -7, -160, -246, -11250, -82,
+ -3, -153, 63, -10833, -62,
+ 1, -144, 391, -10406, -45,
+ 6, -132, 739, -9972, -31,
+ 11, -117, 1105, -9532, -17
+};
+
+const Word16 LDQMF_32_enc_fx[] =
+{
+ 2, -16, 101, -1477, 9102,
+ 2, -20, 81, -1852, 8682,
+ 2, -25, 59, -2241, 8261,
+ 2, -29, 33, -2644, 7841,
+ 1, -34, 4, -3059, 7424,
+ 1, -38, -28, -3486, 7009,
+ 0, -43, -64, -3924, 6599,
+ -1, -47, -104, -4371, 6195,
+ -1, -51, -148, -4826, 5798,
+ -2, -55, -195, -5288, 5408,
+ -3, -59, -247, -5755, 5027,
+ -4, -63, -302, -6227, 4657,
+ -4, -67, -361, -6702, 4297,
+ -5, -71, -424, -7178, 3948,
+ -5, -74, -491, -7654, 3613,
+ -6, -77, -561, -8129, 3290,
+ -6, -80, -635, -8600, 2980,
+ -6, -83, -713, -9067, 2685,
+ -7, -86, -793, -9528, 2404,
+ -7, -89, -877, -9981, 2138,
+ -7, -91, -963, -10425, 1887,
+ -7, -94, -1051, -10859, 1651,
+ -7, -96, -1141, -11280, 1430,
+ -7, -98, -1233, -11687, 1223,
+ -7, -100, -1326, -12079, 1031,
+ -7, -101, -1420, -12455, 854,
+ -7, -103, -1513, -12813, 690,
+ -8, -104, -1606, -13152, 540,
+ -9, -106, -1699, -13471, 402,
+ -9, -107, -1789, -13768, 277,
+ -10, -108, -1878, -14043, 164,
+ -12, -109, -1963, -14295, 60,
+ -13, -110, -2045, -14522, -27,
+ -15, -112, -2122, -14724, -97,
+ -17, -113, -2194, -14899, -158,
+ -18, -114, -2260, -15049, -211,
+ -20, -116, -2319, -15172, -255,
+ -22, -118, -2371, -15268, -292,
+ -24, -120, -2414, -15337, -321,
+ -26, -122, -2449, -15378, -344,
+ -27, -124, -2473, -15392, -361,
+ -29, -127, -2486, -15379, -373,
+ -30, -130, -2488, -15338, -379,
+ -31, -133, -2477, -15270, -380,
+ -32, -137, -2453, -15176, -376,
+ -33, -140, -2416, -15056, -369,
+ -33, -144, -2364, -14910, -357,
+ -33, -148, -2297, -14740, -343,
+ -33, -152, -2214, -14546, -325,
+ -32, -156, -2115, -14329, -306,
+ -31, -159, -1999, -14089, -284,
+ -29, -162, -1867, -13829, -261,
+ -27, -165, -1716, -13549, -237,
+ -25, -167, -1548, -13250, -213,
+ -23, -169, -1362, -12933, -188,
+ -20, -169, -1158, -12601, -164,
+ -17, -169, -936, -12253, -140,
+ -13, -167, -696, -11892, -117,
+ -10, -163, -437, -11518, -96,
+ -6, -158, -161, -11134, -76,
+ -2, -151, 133, -10741, -58,
+ 2, -142, 444, -10339, -43,
+ 6, -131, 772, -9931, -29,
+ 11, -117, 1117, -9518, -17
+};
+
+const Word16 LDQMF_40_enc_fx[] =
+{
+ 2, -15, 102, -1440, 9144,
+ 2, -19, 87, -1738, 8808,
+ 2, -22, 70, -2045, 8472,
+ 2, -26, 51, -2361, 8135,
+ 2, -30, 30, -2685, 7800,
+ 1, -33, 7, -3017, 7465,
+ 1, -37, -18, -3357, 7133,
+ 0, -41, -46, -3704, 6804,
+ 0, -44, -76, -4057, 6477,
+ -1, -48, -108, -4416, 6155,
+ -1, -51, -143, -4780, 5837,
+ -2, -54, -181, -5148, 5524,
+ -3, -57, -220, -5521, 5216,
+ -3, -61, -263, -5896, 4915,
+ -4, -64, -308, -6274, 4620,
+ -4, -67, -355, -6654, 4332,
+ -5, -69, -405, -7035, 4052,
+ -5, -72, -457, -7416, 3779,
+ -6, -75, -512, -7797, 3514,
+ -6, -78, -569, -8176, 3258,
+ -6, -80, -628, -8553, 3011,
+ -6, -83, -689, -8928, 2772,
+ -6, -85, -753, -9299, 2543,
+ -7, -87, -818, -9665, 2323,
+ -7, -89, -885, -10026, 2113,
+ -7, -91, -954, -10381, 1912,
+ -7, -93, -1024, -10730, 1720,
+ -7, -95, -1096, -11071, 1538,
+ -7, -96, -1169, -11403, 1366,
+ -7, -98, -1242, -11727, 1203,
+ -7, -99, -1317, -12041, 1050,
+ -7, -101, -1391, -12344, 905,
+ -7, -102, -1466, -12636, 770,
+ -8, -103, -1541, -12917, 644,
+ -8, -104, -1616, -13185, 526,
+ -8, -106, -1690, -13440, 416,
+ -9, -107, -1762, -13681, 314,
+ -10, -107, -1834, -13909, 219,
+ -11, -108, -1904, -14121, 132,
+ -12, -109, -1971, -14319, 50,
+ -13, -110, -2037, -14501, -20,
+ -14, -111, -2099, -14666, -77,
+ -16, -112, -2158, -14815, -129,
+ -17, -113, -2214, -14947, -175,
+ -19, -115, -2266, -15063, -215,
+ -20, -116, -2314, -15161, -251,
+ -22, -117, -2356, -15242, -281,
+ -23, -119, -2394, -15306, -307,
+ -25, -120, -2426, -15352, -329,
+ -26, -122, -2451, -15381, -346,
+ -27, -124, -2471, -15392, -360,
+ -29, -126, -2483, -15386, -370,
+ -30, -129, -2488, -15362, -376,
+ -31, -131, -2486, -15320, -379,
+ -32, -134, -2475, -15262, -379,
+ -32, -136, -2456, -15187, -377,
+ -33, -139, -2429, -15095, -371,
+ -33, -142, -2392, -14986, -363,
+ -33, -145, -2345, -14862, -353,
+ -33, -148, -2289, -14722, -341,
+ -33, -151, -2223, -14566, -327,
+ -32, -154, -2147, -14396, -312,
+ -31, -157, -2059, -14212, -295,
+ -30, -160, -1961, -14013, -277,
+ -29, -163, -1852, -13802, -259,
+ -28, -165, -1732, -13578, -240,
+ -26, -167, -1601, -13342, -220,
+ -24, -168, -1458, -13094, -200,
+ -22, -169, -1303, -12835, -181,
+ -20, -169, -1137, -12567, -161,
+ -17, -169, -959, -12288, -142,
+ -14, -167, -770, -12002, -124,
+ -12, -165, -569, -11707, -106,
+ -9, -162, -356, -11404, -90,
+ -6, -158, -132, -11095, -74,
+ -2, -152, 103, -10780, -60,
+ 1, -145, 349, -10460, -47,
+ 4, -137, 606, -10136, -36,
+ 8, -127, 874, -9808, -26,
+ 11, -115, 1152, -9476, -15
+};
+
+const Word16 LDQMF_60_enc_fx[] =
+{
+ 2, -14, 105, -1391, 9200,
+ 2, -17, 95, -1588, 8976,
+ 2, -19, 85, -1788, 8752,
+ 2, -22, 73, -1993, 8528,
+ 2, -24, 61, -2202, 8303,
+ 2, -27, 48, -2414, 8079,
+ 2, -29, 34, -2630, 7855,
+ 1, -32, 19, -2850, 7632,
+ 1, -34, 3, -3073, 7410,
+ 1, -36, -14, -3300, 7188,
+ 1, -39, -32, -3530, 6968,
+ 0, -41, -51, -3762, 6749,
+ 0, -44, -71, -3998, 6531,
+ 0, -46, -92, -4236, 6316,
+ -1, -48, -114, -4476, 6102,
+ -1, -50, -137, -4719, 5890,
+ -2, -53, -162, -4964, 5680,
+ -2, -55, -187, -5210, 5472,
+ -2, -57, -214, -5458, 5267,
+ -3, -59, -241, -5708, 5065,
+ -3, -61, -270, -5959, 4865,
+ -4, -63, -300, -6211, 4669,
+ -4, -65, -331, -6464, 4475,
+ -4, -67, -363, -6718, 4285,
+ -5, -69, -396, -6972, 4098,
+ -5, -71, -431, -7226, 3914,
+ -5, -73, -466, -7480, 3734,
+ -5, -75, -502, -7733, 3558,
+ -6, -76, -540, -7987, 3385,
+ -6, -78, -578, -8239, 3216,
+ -6, -80, -618, -8491, 3051,
+ -6, -81, -658, -8741, 2890,
+ -6, -83, -700, -8990, 2733,
+ -6, -84, -742, -9237, 2581,
+ -7, -86, -785, -9482, 2432,
+ -7, -87, -829, -9726, 2287,
+ -7, -89, -874, -9966, 2147,
+ -7, -90, -919, -10205, 2011,
+ -7, -91, -966, -10440, 1879,
+ -7, -93, -1012, -10672, 1751,
+ -7, -94, -1060, -10901, 1628,
+ -7, -95, -1108, -11127, 1509,
+ -7, -96, -1156, -11349, 1394,
+ -7, -97, -1205, -11566, 1283,
+ -7, -98, -1255, -11780, 1177,
+ -7, -99, -1304, -11989, 1075,
+ -7, -100, -1354, -12194, 976,
+ -7, -101, -1404, -12394, 882,
+ -7, -102, -1454, -12589, 792,
+ -7, -103, -1504, -12778, 706,
+ -8, -104, -1554, -12962, 623,
+ -8, -104, -1603, -13141, 545,
+ -8, -105, -1653, -13314, 470,
+ -9, -106, -1702, -13481, 398,
+ -9, -106, -1750, -13642, 330,
+ -9, -107, -1798, -13797, 266,
+ -10, -108, -1845, -13945, 204,
+ -11, -108, -1892, -14087, 146,
+ -11, -109, -1938, -14222, 90,
+ -12, -110, -1982, -14351, 38,
+ -13, -110, -2026, -14472, -9,
+ -14, -111, -2068, -14585, -49,
+ -14, -111, -2109, -14692, -86,
+ -15, -112, -2149, -14791, -121,
+ -16, -113, -2187, -14883, -153,
+ -17, -114, -2223, -14967, -182,
+ -18, -114, -2258, -15044, -209,
+ -19, -115, -2290, -15114, -234,
+ -20, -116, -2321, -15176, -256,
+ -21, -117, -2350, -15230, -277,
+ -22, -118, -2376, -15276, -295,
+ -23, -119, -2399, -15315, -311,
+ -24, -120, -2421, -15346, -326,
+ -25, -121, -2439, -15369, -338,
+ -26, -123, -2455, -15384, -349,
+ -27, -124, -2468, -15391, -358,
+ -28, -125, -2478, -15391, -365,
+ -29, -127, -2485, -15383, -371,
+ -30, -128, -2488, -15367, -375,
+ -30, -130, -2488, -15343, -378,
+ -31, -132, -2485, -15312, -380,
+ -31, -133, -2478, -15273, -380,
+ -32, -135, -2467, -15226, -378,
+ -32, -137, -2452, -15172, -376,
+ -33, -139, -2434, -15111, -372,
+ -33, -141, -2411, -15042, -368,
+ -33, -143, -2385, -14967, -362,
+ -33, -145, -2354, -14884, -355,
+ -33, -147, -2319, -14794, -347,
+ -33, -149, -2279, -14697, -339,
+ -33, -151, -2235, -14593, -330,
+ -32, -153, -2186, -14483, -320,
+ -32, -155, -2133, -14366, -309,
+ -32, -157, -2075, -14243, -298,
+ -31, -159, -2012, -14114, -286,
+ -30, -161, -1944, -13979, -274,
+ -29, -162, -1871, -13838, -262,
+ -28, -164, -1794, -13691, -249,
+ -27, -165, -1711, -13539, -236,
+ -26, -166, -1623, -13382, -223,
+ -25, -167, -1531, -13219, -210,
+ -24, -168, -1433, -13051, -197,
+ -22, -169, -1330, -12879, -184,
+ -21, -169, -1221, -12702, -171,
+ -19, -169, -1108, -12521, -158,
+ -18, -169, -990, -12335, -145,
+ -16, -168, -866, -12146, -133,
+ -14, -167, -737, -11953, -121,
+ -12, -166, -603, -11756, -109,
+ -10, -164, -464, -11556, -98,
+ -8, -161, -320, -11353, -87,
+ -6, -158, -170, -11147, -77,
+ -4, -155, -16, -10938, -67,
+ -2, -151, 143, -10727, -58,
+ 0, -146, 307, -10514, -49,
+ 3, -141, 476, -10298, -41,
+ 5, -135, 650, -10081, -34,
+ 7, -129, 829, -9862, -27,
+ 9, -121, 1012, -9642, -21,
+ 12, -113, 1199, -9421, -13
+};
/*!
* \brief CLDFB rRotVectr
@@ -10170,6 +10688,29 @@ const Word16 iRotVectr_20[] =
W16(0xbec1), W16(0xb5bf), W16(0xae90), W16(0xa963), W16(0xa658)
};
+/*!
+ * \brief CLDFB rRotVectr
+ *
+ * cldfb bands: 30
+ * global gain: 2.50
+ * scale: sqrt(1.0/4.00)
+ */
+const Word16 rRotVectr_30[] =
+{
+ 25902, 25725, 25265, 24529, 23525, 22262, 20756, 19022, 17080, 14950, 12657, 10226, 7682, 5054, 2370
+};
+
+/*!
+ * \brief CLDFB iRotVectr
+ *
+ * cldfb bands: 30
+ * global gain: 2.50
+ * scale: sqrt(1.0/4.00)
+ */
+const Word16 iRotVectr_30[] =
+{
+ -339, -3045, -5717, -8327, -10845, -13245, -15499, -17584, -19476, -21154, -22601, -23801, -24739, -25406, -25796
+};
/*!
* \brief CLDFB rRotVectr
*
@@ -10266,11 +10807,11 @@ const Word16 iRotVectr_60[] =
const Word16 cldfb_anaScale[] =
{
- SCALE_CLDFB_ANA_10, SCALE_CLDFB_ANA_16, SCALE_CLDFB_ANA_20, SCALE_CLDFB_ANA_32, SCALE_CLDFB_ANA_40, SCALE_CLDFB_ANA_60
+ SCALE_CLDFB_ANA_10, SCALE_CLDFB_ANA_16, SCALE_CLDFB_ANA_20, SCALE_CLDFB_ANA_32, SCALE_CLDFB_ANA_40, SCALE_CLDFB_ANA_60, SCALE_CLDFB_ANA_30
};
const Word16 cldfb_synScale[] =
{
- SCALE_CLDFB_SYN_10, SCALE_CLDFB_SYN_16, SCALE_CLDFB_SYN_20, SCALE_CLDFB_SYN_32, SCALE_CLDFB_SYN_40, SCALE_CLDFB_SYN_60
+ SCALE_CLDFB_SYN_10, SCALE_CLDFB_SYN_16, SCALE_CLDFB_SYN_20, SCALE_CLDFB_SYN_32, SCALE_CLDFB_SYN_40, SCALE_CLDFB_SYN_60, SCALE_CLDFB_SYN_30
};
const Word16 cldfb_synGain[] =
{
@@ -10284,8 +10825,14 @@ const Word16 cldfb_synGain[] =
const Word16 *cldfb_protoFilter_2_5ms[] =
{
- CLDFB80_10, CLDFB80_16, CLDFB80_20, CLDFB80_32, CLDFB80_40, CLDFB80_60
+ CLDFB80_10, CLDFB80_16, CLDFB80_20, CLDFB80_32, CLDFB80_40, CLDFB80_60, CLDFB80_30
+};
+#ifdef IVAS_FLOAT_FIXED
+const Word16 *cldfb_protoFilter_5_0ms[] =
+{
+ LDQMF_10_enc_fx, LDQMF_16_enc_fx, LDQMF_20_enc_fx, LDQMF_32_enc_fx, LDQMF_40_enc_fx, LDQMF_60_enc_fx, LDQMF_30_enc_fx
};
+#endif
const Word16 cldfb_scale_2_5ms[7] =
{
22603/*88.293854 Q8*/, /* 10 bands */
@@ -10293,8 +10840,22 @@ const Word16 cldfb_scale_2_5ms[7] =
22605/*88.300926 Q8*/, /* 20 bands */
22606/*88.303848 Q8*/, /* 32 bands */
22606/*88.304718 Q8*/, /* 40 bands */
- 22535/*88.028412 Q8*/ /* 60 bands */
+ 22535/*88.028412 Q8*/, /* 60 bands */
+ 22588/*88.234489 Q8*/ /* 30 bands */
};
+
+#ifdef IVAS_FLOAT_FIXED
+const Word16 cldfb_scale_5_0ms[7] =
+{
+ 21649/*88.293854 Q8*/, /* 10 bands */
+ 21649/*88.299622 Q8*/, /* 16 bands */
+ 21649/*88.300926 Q8*/, /* 20 bands */
+ 21649/*88.303848 Q8*/, /* 32 bands */
+ 21649/*88.304718 Q8*/, /* 40 bands */
+ 22535/*88.028412 Q8*/, /* 60 bands */
+ 21581/*88.028412 Q8*/ /* 30 bands */
+};
+#endif
const float rot_vec_syn_re_L10[5] =
{
0.1117172025f,0.1048929802f,0.0878011021f,0.0621146404f,0.0303479649f,
@@ -11007,22 +11568,22 @@ const SCALE_SETUP scaleTable_cn_only[SIZE_SCALE_TABLE_CN] =
#endif
const SCALE_SETUP scaleTable_cn_dirac[15] =
{
- { 0, 0, 13200, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, -24576 },
- { 0, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 },
- { 0, 16400, 24400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, -16384 },
- { 0, 24400, 32000, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, -12288 },
+ { 0, 0, 13200, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 },
+ { 0, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 },
+ { 0, 16400, 24400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 },
+ { 0, 24400, 32000, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 },
{ 0, 32000,512001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 },
- { 1, 0, 13200, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, -24576 },
- { 1, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 },
- { 1, 16400, 24400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, -16384 },
- { 1, 24400, 32000, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, -12288 },
+ { 1, 0, 13200, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 },
+ { 1, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 },
+ { 1, 16400, 24400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 },
+ { 1, 24400, 32000, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 },
{ 1, 32000,512001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 },
- { 2, 0, 13200, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, -24576 },
- { 2, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 },
- { 2, 16400, 24400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, -16384 },
- { 2, 24400, 32000, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, -12288 },
+ { 2, 0, 13200, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 },
+ { 2, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 },
+ { 2, 16400, 24400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 },
+ { 2, 24400, 32000, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 },
{ 2, 32000,512001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }
};
const float scaleTable_cn_only_amrwbio_flt[SIZE_SCALE_TABLE_CN_AMRWB][2] =
@@ -19813,7 +20374,6 @@ const float SVWB2_SN1[256] = {
-91.02f, -115.23f, -227.34f, -448.05f, -339.84f, 30.08f, 56.25f, 130.86f, 105.08f, 196.09f, 249.22f, 280.86f, 240.23f, 146.88f, 85.55f, 67.19f
};
-/* An 16-by-16 matrix */
const Word16 SVWB2_SN1_fx[256] = {
-257, -385, -673, 926, 1408, 874, 735, 512, 624, 587, 493, 688, 845, 521, 428, 95,
-32, -90, 1046, 666, 329, -59, -324, -282, -712, -783, -229, 28, -354, -434, -497, -351,
@@ -19896,6 +20456,30 @@ const float SVWB2_AR2[128] = {
0.78f, -1.17f, 28.91f, 67.19f, 26.56f, -1.56f, -13.67f, -9.77f, -60.94f, -85.55f, -168.75f, -112.50f, -71.09f, -14.06f, 44.53f, 44.14f
};
+/* SVWB2_AR1 * 2.56f */
+const Word16 SVWB2_AR1_fx[128] = {
+ -28, -38, -122, 74, 296, 148, 146, 120, 148, 36, -11, -163, -223, -299, -290, -320,
+ -22, -30, -138, -319, -385, 159, 124, 51, 32, -44, -15, -78, -96, -53, 40, 64,
+ -96, -144, -205, -96, 80, 96, 152, 246, 206, 193, 265, 333, 320, 232, 131, 32,
+ 108, 106, 102, 37, -14, -17, -61, -144, -161, -160, -257, -404, -540, -316, -124, 18,
+ 22, 12, 34, -14, -52, -106, -144, -266, -346, -472, -401, -30, -4, -43, -88, -10,
+ -52, -117, -203, 415, 324, 171, 121, -31, 48, -31, -60, -65, 128, 193, 141, 67,
+ -47, -86, 430, 334, 193, 136, 85, 82, 1, -34, 47, 84, 2, -30, -77, -45,
+ -4, -14, -9, -38, -136, -242, -217, -54, -38, 179, 191, 61, 42, -3, 5, -37
+};
+
+/* SVWB2_AR2 * 2.56f */
+const Word16 SVWB2_AR2_fx[128] = {
+ 12, 16, -46, -156, -329, -293, 43, 141, 61, 15, -9, 29, -74, -41, -37, 16,
+ -47, -81, -136, 82, -33, -111, -268, -293, 109, 136, 53, -58, -51, 62, 64, 14,
+ -15, -19, -171, -347, 258, 161, 88, 13, -57, -26, -59, 24, 10, 14, -41, -8,
+ 33, 38, 139, 157, 31, 65, -14, 52, 63, 30, -8, -1, -182, -341, -344, -258,
+ 14, 16, 46, 6, -54, -64, -136, -132, -318, -303, 261, 146, -19, -57, -30, 30,
+ -34, -34, 21, 93, 163, 201, 290, 257, 225, 296, 209, 197, 72, 26, 57, 1,
+ 33, 66, 73, -8, -104, 44, 31, -13, 70, 72, -17, -48, 430, 373, 218, 92,
+ 1, -2, 74, 172, 67, -3, -34, -25, -156, -219, -432, -288, -181, -35, 113, 112
+};
+
/*----------------------------------------------------------------------------------*
* LSF quantization - LSF mode/codebook selection tables
*----------------------------------------------------------------------------------*/
@@ -20649,30 +21233,6 @@ const Word16 AUWB2_MA1_fx[512] =
-19, 43, 35, 40, 42, 55, 63, 101, 133, 194, 222, 152, 117, 145, 133, 213
};
-/* SVWB2_AR1 * 2.56f */
-const Word16 SVWB2_AR1_fx[128] = {
- -28, -38, -122, 74, 296, 148, 146, 120, 148, 36, -11, -163, -223, -299, -290, -320,
- -22, -30, -138, -319, -385, 159, 124, 51, 32, -44, -15, -78, -96, -53, 40, 64,
- -96, -144, -205, -96, 80, 96, 152, 246, 206, 193, 265, 333, 320, 232, 131, 32,
- 108, 106, 102, 37, -14, -17, -61, -144, -161, -160, -257, -404, -540, -316, -124, 18,
- 22, 12, 34, -14, -52, -106, -144, -266, -346, -472, -401, -30, -4, -43, -88, -10,
- -52, -117, -203, 415, 324, 171, 121, -31, 48, -31, -60, -65, 128, 193, 141, 67,
- -47, -86, 430, 334, 193, 136, 85, 82, 1, -34, 47, 84, 2, -30, -77, -45,
- -4, -14, -9, -38, -136, -242, -217, -54, -38, 179, 191, 61, 42, -3, 5, -37
-};
-
-/* SVWB2_AR2 * 2.56f */
-const Word16 SVWB2_AR2_fx[128] = {
- 12, 16, -46, -156, -329, -293, 43, 141, 61, 15, -9, 29, -74, -41, -37, 16,
- -47, -81, -136, 82, -33, -111, -268, -293, 109, 136, 53, -58, -51, 62, 64, 14,
- -15, -19, -171, -347, 258, 161, 88, 13, -57, -26, -59, 24, 10, 14, -41, -8,
- 33, 38, 139, 157, 31, 65, -14, 52, 63, 30, -8, -1, -182, -341, -344, -258,
- 14, 16, 46, 6, -54, -64, -136, -132, -318, -303, 261, 146, -19, -57, -30, 30,
- -34, -34, 21, 93, 163, 201, 290, 257, 225, 296, 209, 197, 72, 26, 57, 1,
- 33, 66, 73, -8, -104, 44, 31, -13, 70, 72, -17, -48, 430, 373, 218, 92,
- 1, -2, 74, 172, 67, -3, -34, -25, -156, -219, -432, -288, -181, -35, 113, 112
-};
-
const Word16 *const Quantizers_fx[] = { SVNB_SN1_fx, SVNB_SN2_fx, GETRNB_SN1_fx, GETRNB_SN2_fx, AUNB_SN1_fx,SVWB_SN1_fx, SVWB_SN2_fx, GETRWB_SN1_fx,
GETRWB_SN2_fx, AUWB_SN1_fx,/* U13, */
TRWB2_SN1_fx, TRWB2_SN2_fx, AUWB2_SN1_fx, CNG_SN1_fx, SVWB2_SN1_fx, SVWB2_SN2_fx
@@ -21626,6 +22186,7 @@ const Word16 scales_fx[][6] =
{2267, 5315, 0, 2666, 1237, 1802}, /* CNG */
};/* An 6-by-146 matrix in Scale = 2048.00f */
+
const Word16 scales_p_fx[][6] =
{
{2998, 4862, 0, 0, 0, 0, },
@@ -21785,7 +22346,6 @@ const Word16 scales_p_fx[][6] =
};
-
/* An 16-by-34 matrix in Scale = 20.48f */
const float sigma_MSLVQ[][16] =
{
@@ -22751,7 +23311,7 @@ const Word16 min_lat_bits_SN_fx[] = { -1, -1, 17, 12, 17, 17, -1, -1, 17, 12, 17
const int16_t min_lat_bits_pred[] = {17, 18, 9, 15, -1, 21, 17, 14, 9, 15, -1, 21, 17, -1, 24, 26, -1, 26, 16};
-const Word16 min_lat_bits_pred_fx[] = { 17, 18, 9, 15, -1, 21, 17, 14, 9, 15, -1, 21, 17, -1, -1, 26, -1, 26, 16 };
+const Word16 min_lat_bits_pred_fx[] = { 17, 18, 9, 15, -1, 21, 17, 14, 9, 15, -1, 21, 17, -1, 24, 26, -1, 26, 16 };
const int16_t offset_lvq_modes_SN[] = {-1,-1,33,64,96, 129,-1,-1,12,43,79,109,-1,-1,137,-1,107,135,
112
@@ -37923,6 +38483,13 @@ const Word32 sigma_BWE_fx[] = {
19499580, 20916386, 22705246, 39204284,
40792208 }; /* for 3 bits first stage */
+const Word16 sigma_BWE16_fx[] = {
+260, 255, 268,
+267, 294, 315, 598,
+622, 289, 288, 297,
+298, 319, 346, 598,
+622 }; /* for 3 bits first stage */
+
const float inv_sigma_BWE[] = {
126.2392994665869f, 128.5766227364854f, 122.2856952550425f, 122.8889356808437f, 111.5502335749417f,
104.0176806054527f, 54.7767591108706f, 52.6444584512409f, /* for 4 bits first stage */
diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h
index 0d5c159c532d7ec9b223013dc2829d12577d9d45..a4d78c03a879c9e1c1f89582f16be3e2727be4af 100644
--- a/lib_com/rom_com.h
+++ b/lib_com/rom_com.h
@@ -236,10 +236,12 @@ extern const Word32 lag_window_16k_32[NUM_LAGW_STRENGTHS][16];
extern const Word32 lag_window_25k6_32[NUM_LAGW_STRENGTHS][16];
extern const Word32 lag_window_32k_32[NUM_LAGW_STRENGTHS][16];
extern const Word32 lag_window_48k_32[16];
-extern const float interpol_frac2[]; /* LPC interpolation coefficients for two-subframe mode */
-extern const Word16 interpol_frac2_fx[]; /* LPC interpolation coefficients for two-subframe mode */
-extern const float interpol_frac2_mid[]; /* LPC interpolation coefficients with mid-ISFs for two-subframe mode */
-extern const float interpol_frac_12k8[]; /* LPC interpolation coefficients */
+extern const float interpol_frac2[]; /* LPC interpolation coefficients for two-subframe mode */
+extern const float interpol_frac2_mid[]; /* LPC interpolation coefficients with mid-ISFs for two-subframe mode */
+extern const float interpol_frac_12k8[]; /* LPC interpolation coefficients */
+extern const Word16 interpol_frac2_fx[]; /* LPC interpolation coefficients for two-subframe mode */
+extern const Word16 interpol_frac2_mid_fx[]; /* LPC interpolation coefficients with mid-ISFs for two-subframe mode */
+extern const Word16 interpol_frac_12k8_fx[]; /* LPC interpolation coefficients */
extern const Word16 interpol_frac_fx[NB_SUBFR];
extern const float interpol_isp_amr_wb[]; /* LPC interpolation coefficients for AMR-WB interoperable mode */
@@ -638,6 +640,8 @@ extern const Word16 inv_sigma_p_fx[][16];
extern const float scales[][MAX_NO_SCALES * 2];
extern const float scales_p[][MAX_NO_SCALES * 2];
extern const Word16 scales_fx[][MAX_NO_SCALES * 2];
+extern const Word16 scales_ivas_fx[][MAX_NO_SCALES * 2];
+extern const Word16 scales_p_ivas_fx[][MAX_NO_SCALES * 2];
extern const Word16 scales_p_fx[][MAX_NO_SCALES * 2];
extern const int16_t predmode_tab_float[][6];
extern const Word16 predmode_tab[][6];
@@ -1611,7 +1615,16 @@ extern const Word16 CLDFB80_20[200];
extern const Word16 CLDFB80_32[320];
extern const Word16 CLDFB80_40[400];
extern const Word16 CLDFB80_60[600];
-
+extern const Word16 CLDFB80_30[300];
+#ifdef IVAS_FLOAT_FIXED
+extern const Word16 LDQMF_10_enc_fx[100];
+extern const Word16 LDQMF_16_enc_fx[160];
+extern const Word16 LDQMF_20_enc_fx[200];
+extern const Word16 LDQMF_30_enc_fx[300];
+extern const Word16 LDQMF_32_enc_fx[320];
+extern const Word16 LDQMF_40_enc_fx[400];
+extern const Word16 LDQMF_60_enc_fx[600];
+#endif
extern const Word16 rRotVectr_10[];
extern const Word16 iRotVectr_10[];
@@ -1625,12 +1638,16 @@ extern const Word16 rRotVectr_40[];
extern const Word16 iRotVectr_40[];
extern const Word16 rRotVectr_60[];
extern const Word16 iRotVectr_60[];
+extern const Word16 rRotVectr_30[];
+extern const Word16 iRotVectr_30[];
extern const Word16 cldfb_anaScale[];
extern const Word16 cldfb_synScale[];
extern const Word16 cldfb_synGain[];
extern const Word16 *cldfb_protoFilter_2_5ms[];
+extern const Word16 *cldfb_protoFilter_5_0ms[];
extern const Word16 cldfb_scale_2_5ms[7];
+extern const Word16 cldfb_scale_5_0ms[7];
extern const float rot_vec_syn_re_L10[5];
@@ -1990,6 +2007,7 @@ extern const Word16 tcx_mdct_window_trans_48_fx[60];
extern const float sigma_BWE[];
extern const Word32 sigma_BWE_fx[];
+extern const Word16 sigma_BWE16_fx[];
extern const float inv_sigma_BWE[];
extern const float scales_BWE[];
extern const Word8 no_lead_BWE[];
diff --git a/lib_com/rom_com_fx.h b/lib_com/rom_com_fx.h
index a077741060617855a57a28b8de3d48988d5abf2a..ac6a0ef466454b142454964902582182753984c7 100644
--- a/lib_com/rom_com_fx.h
+++ b/lib_com/rom_com_fx.h
@@ -85,6 +85,14 @@ extern const Word16 LDQMF_32_fx[320];
extern const Word16 LDQMF_40_fx[400];
extern const Word16 LDQMF_60_fx[600];
+extern const Word16 LDQMF_10_enc_fx[100];
+extern const Word16 LDQMF_16_enc_fx[160];
+extern const Word16 LDQMF_20_enc_fx[200];
+extern const Word16 LDQMF_30_enc_fx[300];
+extern const Word16 LDQMF_32_enc_fx[320];
+extern const Word16 LDQMF_40_enc_fx[400];
+extern const Word16 LDQMF_60_enc_fx[600];
+
extern const Word32 rot_vec_delay_re_LDQMF_fx[60];
extern const Word32 rot_vec_delay_im_LDQMF_fx[60];
diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c
index e6ca64931dc6f2a2a3f7c8207dfb7fb3e1ea9227..2e61cb93851f6c4ecd3d80bc635244242a40b630 100644
--- a/lib_com/scale_mem_fx.c
+++ b/lib_com/scale_mem_fx.c
@@ -34,8 +34,8 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
-#include "options.h" /* Common prototypes */
-#include "prot_fx2.h" /* Common prototypes */
+#include "options.h" /* Common prototypes */
+#include "prot_fx.h" /* Common prototypes */
#include "ivas_cnst.h"
#include "stl.h"
diff --git a/lib_com/stab_est_fx.c b/lib_com/stab_est_fx.c
index 52998bbae6e5f2790a034ca8f89eff6192b96980..e0c75e5632b0fff6ffb0633acc7b22b627126f23 100644
--- a/lib_com/stab_est_fx.c
+++ b/lib_com/stab_est_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
/*-------------------------------------------------------------------*
* Local constants
diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h
index 05fd4b64332dedbbd11896aad51010a403aa9b70..d9baadc351334c476df28a069cf6df8b27ca7946 100644
--- a/lib_com/stat_com.h
+++ b/lib_com/stat_com.h
@@ -782,6 +782,7 @@ typedef struct cldfb_filter_bank_struct
float scale_flt; /* scaling of frequency domain */
Word16 scale; /* scaling of frequency domain */ /* Q8 */
+ Word16 q_scale;
} CLDFB_FILTER_BANK, *HANDLE_CLDFB_FILTER_BANK;
diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c
index 8d8949758e6cf25a8b9868d9130daa00c8b8c9df..9869019fa6fce0836ae920230d65336527464d8d 100644
--- a/lib_com/stat_noise_uv_mod_fx.c
+++ b/lib_com/stat_noise_uv_mod_fx.c
@@ -3,10 +3,9 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "cnst.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "cnst.h" /* Function prototypes */
/*---------------------------------------------------------------------*
* Local function prototypes
@@ -77,6 +76,7 @@ void stat_noise_uv_mod_fx(
Word16 Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*---------------------------------------------------------*
@@ -188,7 +188,7 @@ void stat_noise_uv_mod_fx(
ELSE
{
*uv_count = s_min( *uv_count, FULL_NG );
-
+ move16();
tmp_nom = sub( *uv_count, START_NG );
tmp_den = sub( FULL_NG, START_NG );
tmp_shift = norm_s( tmp_den );
@@ -228,6 +228,7 @@ void stat_noise_uv_mod_fx(
IF( EQ_16( *uv_count, 1 ) )
{
*ge_sm = L_shr( L_Ge, Q_local );
+ move32();
}
ELSE
{
@@ -300,8 +301,10 @@ void stat_noise_uv_mod_fx(
L_tmp = L_add( L_tmp3, L_shl( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */
#endif
Exc2_local[i] = extract_h( L_tmp ); /*Q_local */
+ move16();
}
- *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */
+ *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */
+ move16();
Qdiff = sub( Q_exc, Q_local ); /* local excitation and incoming excitation */
Scale_sig( Exc2_local, L_FRAME, Qdiff );
Copy( Exc2_local, exc2, L_FRAME );
@@ -376,7 +379,6 @@ static Word16 calc_tilt_fx( /* o : Excitation tilt Q15*/
r0 = L_deposit_l( 0 );
r1 = L_deposit_l( 0 );
xi = shr( x[0], Q_shift );
- move16();
FOR( i = 0; i < len - 1; i++ )
{
@@ -403,7 +405,6 @@ static Word16 calc_tilt_fx( /* o : Excitation tilt Q15*/
}
tmp_shift = norm_l( r0 );
- move16();
r0 = L_shl( r0, tmp_shift );
tmp_sign = 1;
move16();
diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c
index f194355bf878e5148a44e131a9f0d4f59b7dc730..0ecd34e83db660fac977521d98ec20e75aeb18dc 100644
--- a/lib_com/swb_bwe_com_fx.c
+++ b/lib_com/swb_bwe_com_fx.c
@@ -32,8 +32,7 @@
#include
#include "options.h"
-#include "prot_fx2.h"
-#include "prot_fx1.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "rom_com.h"
@@ -81,8 +80,10 @@ Word16 WB_BWE_gain_pred_fx(
Word32 enerL;
Word16 n_freq, mode, pitch;
Word16 ener_var_flag = 0;
+ move16();
Word16 voice_factor, enerL_16, enerL_40, enerL_64;
Word16 env_var_flag = 0;
+ move16();
Word16 exp;
Word16 tmp, tmp1;
Word32 L_tmp;
@@ -128,7 +129,7 @@ Word16 WB_BWE_gain_pred_fx(
voice_factor = extract_l( L_shr( L_tmp, 2 ) ); /*Q13 */
Copy_Scale_sig( pitch_buf, pitch_buf_tmp, 4, -1 );
pitch = sum16_fx( pitch_buf_tmp, 4 );
- move16(); /*Q5 */
+ /*Q5 */
L_tmp = L_shr( enerL, 4 );
test();
@@ -201,6 +202,7 @@ Word16 WB_BWE_gain_pred_fx(
#ifdef BASOP_NOGLOB
WB_fenv[0] = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /* Q3 */
+ move16();
#else
WB_fenv[0] = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* Q3 */
#endif
@@ -252,12 +254,14 @@ Word16 WB_BWE_gain_pred_fx(
tmp = s_min( tmp, 16384 );
L_tmp = L_shr( L_mult0( tmp, WB_fenv[0] ), 12 ); /*Q15 */
WB_fenv[0] = extract_l( L_tmp ); /*Q3 */
+ move16();
}
IF( GT_16( WB_fenv[0], prev_WB_fenv ) )
{
/*WB_fenv[0]= add(mult_r(9830, WB_fenv[0]), mult_r(22938, prev_WB_fenv)); move16();//Q3 */
WB_fenv[0] = round_fx( L_mac( L_mult( 9830, WB_fenv[0] ), 22938, prev_WB_fenv ) ); /*Q3 */
+ move16();
}
}
@@ -308,11 +312,12 @@ Word16 WB_BWE_gain_pred_fx(
tmp = s_min( tmp, 16384 );
L_tmp = L_shr( L_mult0( tmp, WB_fenv[0] ), 12 ); /*Q3 */
WB_fenv[0] = extract_l( L_tmp ); /*Q3 */
-
+ move16();
IF( GT_16( WB_fenv[0], prev_WB_fenv ) )
{
/*WB_fenv[0] = add(mult_r(9830, WB_fenv[0]), mult_r(22938, prev_WB_fenv));//Q3 */
WB_fenv[0] = round_fx( L_mac( L_mult( 9830, WB_fenv[0] ), 22938, prev_WB_fenv ) ); /*Q3 */
+ move16();
}
}
@@ -332,12 +337,14 @@ Word16 WB_BWE_gain_pred_fx(
L_tmp = L_mult( WB_fenv[0], tmp ); /*Q(21-exp) */
WB_fenv[0] = round_fx( L_shl( L_tmp, sub( exp, 2 ) ) ); /*Q3 */
- tmp1 = mult_r( 328, pitch ); /*Q7 */
- tmp = s_min( s_max( tmp1, 16 ), 256 ); /*Q7 */
- L_tmp = L_shr( L_mult0( WB_fenv[0], tmp ), 7 ); /*Q3 */
- /*WB_fenv[0] = saturate(L_tmp); //Q3 */
+ move16();
+ tmp1 = mult_r( 328, pitch ); /*Q7 */
+ tmp = s_min( s_max( tmp1, 16 ), 256 ); /*Q7 */
+ L_tmp = L_shr( L_mult0( WB_fenv[0], tmp ), 7 ); /*Q3 */
+ /*WB_fenv[0] = saturate(L_tmp); //Q3 */
#ifdef BASOP_NOGLOB
WB_fenv[0] = round_fx_sat( L_shl_sat( L_tmp, 16 ) ); /*Q3 */
+ move16();
#else
WB_fenv[0] = round_fx( L_shl( L_tmp, 16 ) ); /*Q3 */
#endif
@@ -347,11 +354,13 @@ Word16 WB_BWE_gain_pred_fx(
{
/*WB_fenv[0]= add(mult_r(29491, last_wb_bwe_ener), mult_r(3277, WB_fenv[0]));//Q3 */
WB_fenv[0] = round_fx( L_mac( L_mult( 29491, last_wb_bwe_ener ), 3277, WB_fenv[0] ) ); /*Q3 */
+ move16();
}
IF( NE_16( last_extl_fx, WB_BWE ) && LT_16( tilt_wb_fx, 128 ) )
{
WB_fenv[0] = mult_r( s_min( 16384, shl( tilt_wb_fx, 8 ) ), WB_fenv[0] );
+ move16();
}
IF( env_var_flag == 1 )
@@ -620,6 +629,7 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 */
Word16 exp2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
BASOP_SATURATE_WARNING_OFF_EVS
@@ -742,18 +752,17 @@ Word16 ivas_calc_tilt_bwe_fx( /* o : Tilt in Q24 */
Word32 L_ener, L_ener_tot, L_temp;
Word32 tmp1, tmp2;
Word16 sign = 0;
+ move16();
const Word32 *ptr;
Word16 exp2, tmp_exp;
BASOP_SATURATE_WARNING_OFF_EVS
/* this is required for adaptative precision energy summation loop, do not remove */
- move16();
exp2 = 0;
move16();
-
ptr = sp;
- move16();
+
L_ener_tot = L_deposit_l( 1 );
/* Divide Frame Length by 32 */
@@ -796,6 +805,7 @@ Word16 ivas_calc_tilt_bwe_fx( /* o : Tilt in Q24 */
}
L_temp = L_ener_tot;
+ move32();
tmp_exp = sub( Q31, sub( shl( exp_sp, 1 ), Q31 ) );
L_temp = Sqrt32( L_temp, &tmp_exp );
L_temp = L_shl( L_temp, sub( exp_sp, sub( Q31, tmp_exp ) ) );
@@ -805,6 +815,7 @@ Word16 ivas_calc_tilt_bwe_fx( /* o : Tilt in Q24 */
IF( GT_16( sub( exp2, 4 ), norm_l( L_temp ) ) )
{
L_temp = MAX_16;
+ move32();
}
ELSE
{
@@ -833,7 +844,6 @@ void calc_norm_envelop_fx(
Word16 i, lookback, env_index, n_freq, n_lag_now, n_lag, tmp;
lookback = shr( L_swb_norm, 1 );
- move16();
env_index = add( swb_bwe_subband[0], st_offset );
n_lag_now = L_swb_norm;
move16();
@@ -937,6 +947,8 @@ void WB_BWE_decoding_fx(
Word16 alfa, beta;
Word16 flag = 0;
Word16 core_type = 1;
+ move16();
+ move16();
Word16 tmp, tmp1, exp, tmp2;
Word32 L_tmp, L_tmp1, L_tmp2;
Word32 prev_ener_alpha, prev_ener_beta;
@@ -984,6 +996,7 @@ void WB_BWE_decoding_fx(
FOR( n_freq = swb_bwe_subband[0]; n_freq < swb_bwe_subband[4]; n_freq++ )
{
signum[n_freq] = 1;
+ move16();
IF( WB_signal[n_freq] < 0 )
{
signum[n_freq] = -1;
@@ -996,10 +1009,12 @@ void WB_BWE_decoding_fx(
L_tmp1 = L_deposit_l( WB_signal[n_freq] ); /* Q_syn */
L_tmp = L_sub( L_tmp1, L_tmp ); /* Q_syn */
WB_signal[n_freq] = extract_l( L_tmp ); /* Q_syn */
+ move16();
IF( L_tmp > 0 )
{
tmp = sub( 18022, weight ); /* Q15 */
WB_signal[n_freq] = extract_l( Mult_32_16( L_tmp, tmp ) ); /* Q_syn */
+ move16();
}
IF( NE_16( signum[n_freq], 1 ) )
@@ -1021,6 +1036,7 @@ void WB_BWE_decoding_fx(
tmp = div_s( 16384, tmp );
L_tmp = L_shr( L_mult0( WB_signal[n_freq], tmp ), add( exp, Q_syn ) ); /*Q15 */
WB_signal[n_freq] = extract_l( L_tmp ); /*Q15 */
+ move16();
}
ELSE
{
@@ -1188,15 +1204,19 @@ void WB_BWE_decoding_fx(
{
/*wfenv[0]= add(mult_r(9830, WB_fenv[0]), mult_r(22938, prev_WB_fenv[0]));//Q3 */
wfenv[0] = round_fx( L_mac( L_mult( 9830, WB_fenv[0] ), 22938, prev_WB_fenv[0] ) ); /*Q3 */
+ move16();
/*wfenv[1]= add(mult_r(9830, WB_fenv[1]), mult_r(22938, prev_WB_fenv[1]));//Q3 */
wfenv[1] = round_fx( L_mac( L_mult( 9830, WB_fenv[1] ), 22938, prev_WB_fenv[1] ) ); /*Q3 */
+ move16();
}
ELSE
{
/*wfenv[0]= add(mult_r(16384,WB_fenv[0]),mult_r(16384,prev_WB_fenv[0]));//Q3 */
wfenv[0] = round_fx( L_mac( L_mult( 16384, WB_fenv[0] ), 16384, prev_WB_fenv[0] ) ); /*Q3 */
+ move16();
/*wfenv[1]= add(mult_r(13108,WB_fenv[1]),mult_r(13108,prev_WB_fenv[1]));//Q3 */
wfenv[1] = round_fx( L_mac( L_mult( 13108, WB_fenv[1] ), 13108, prev_WB_fenv[1] ) ); /*Q3 */
+ move16();
}
}
ELSE IF( EQ_16( last_extl, WB_BWE ) && LT_32( L_tmp1, L_tmp2 ) && GT_16( WB_fenv[0], prev_WB_fenv[0] ) &&
@@ -1204,16 +1224,20 @@ void WB_BWE_decoding_fx(
{
/*wfenv[0]= add(mult_r(9830,WB_fenv[0]),mult_r(22938,prev_WB_fenv[0]));//Q3 */
wfenv[0] = round_fx( L_mac( L_mult( 9830, WB_fenv[0] ), 22938, prev_WB_fenv[0] ) ); /*Q3 */
+ move16();
/*wfenv[1]= add(mult_r(9830,WB_fenv[1]),mult_r(22938,prev_WB_fenv[1]));//Q3 */
wfenv[1] = round_fx( L_mac( L_mult( 9830, WB_fenv[1] ), 22938, prev_WB_fenv[1] ) ); /*Q3 */
+ move16();
}
ELSE IF( EQ_16( last_extl, WB_BWE ) && GT_32( EnergyL, prev_ener_alpha ) && GT_32( prev_ener_beta, EnergyL ) &&
NE_16( prev_coder_type, UNVOICED ) )
{
/*wfenv[0] = add(shr(WB_fenv[0],1), shr(prev_WB_fenv[0],1));//Q3 */
wfenv[0] = round_fx( L_mac( L_mult( WB_fenv[0], 16384 ), prev_WB_fenv[0], 16384 ) ); /*Q3 */
+ move16();
/*wfenv[1] = add(shr(WB_fenv[1],1), shr(prev_WB_fenv[1],1));//Q3 */
wfenv[1] = round_fx( L_mac( L_mult( WB_fenv[1], 16384 ), prev_WB_fenv[1], 16384 ) ); /*Q3 */
+ move16();
}
ELSE
{
@@ -1309,6 +1333,7 @@ void WB_BWE_decoding_fx(
move32();
}
*Q_syn_hb = add( Q_syn, add( tmp, 3 ) );
+ move16();
return;
}
@@ -1475,6 +1500,7 @@ void SWB_BWE_decoding_fx(
tmp = div_s( 16384, tmp ); /*Q(15+exp) */
L_tmp = L_shr( L_mult0( SWB_signal[n_freq], tmp ), add( exp, Q_syn ) ); /*Q15 */
SWB_signal[n_freq] = extract_l( L_tmp ); /*Q15 */
+ move16();
}
ELSE
{
@@ -1535,12 +1561,14 @@ void SWB_BWE_decoding_fx(
{
L_tmp = L_mult( SWB_fenv[n_band / 4], SWB_fenv[n_band / 4] ); /*Q3 */
prev_SWB_fenv[n_band] = round_fx( L_shl( L_tmp, 14 ) ); /*Q1 */
+ move16();
}
FOR( n_band = 0; n_band < 6; n_band++ )
{
L_tmp = L_mult( SWB_fenv[2 + n_band / 3], SWB_fenv[2 + n_band / 3] ); /*Q3 */
prev_SWB_fenv[8 + n_band] = round_fx( L_shl( L_tmp, 14 ) ); /*Q1 */
+ move16();
}
*prev_weight = 16384;
@@ -1582,6 +1610,7 @@ void SWB_BWE_decoding_fx(
FOR( n_band = 0; n_band < SWB_FENV; n_band++ )
{
SWB_fenv[n_band] = mult_r( SWB_fenv[n_band], 6554 );
+ move16();
}
fenvL_16 = mult_r( fenvL_16, 6554 );
}
@@ -1611,6 +1640,7 @@ void SWB_BWE_decoding_fx(
FOR( n_freq = add( swb_bwe_subband[0], st_offset ); n_freq < tmp; n_freq++ )
{
*Seed = extract_l( L_mac0( 20101L, 12345, *Seed ) );
+ move16();
SWB_signal[n_freq] = mult_r( *Seed, 32767 );
move16(); /*Q15 */
}
@@ -1693,7 +1723,7 @@ void SWB_BWE_decoding_fx(
}
pit1 = &SWB_signal[367 + st_offset];
- move16();
+
IF( GT_16( mult_r( tmp1, 6554 ), tmp2 ) )
{
/*20480 = 5 in Q12 */
@@ -1704,6 +1734,7 @@ void SWB_BWE_decoding_fx(
#else
*pit1 = round_fx( L_shl( L_mult( *pit1, tmp3 ), 3 ) ); /*Q_syn */
#endif
+ move16();
pit1--;
}
}
@@ -1716,7 +1747,6 @@ void SWB_BWE_decoding_fx(
tmp2 = add( add( abs_s( SWB_signal[492 + st_offset] ), abs_s( SWB_signal[493 + st_offset] ) ), add( abs_s( SWB_signal[494 + st_offset] ), abs_s( SWB_signal[495 + st_offset] ) ) );
#endif
pit1 = &SWB_signal[496 + st_offset];
- move16();
test();
IF( ( tmp2 == 0 ) || ( LT_16( tmp2, mult_r( tmp1, 9830 ) ) ) )
@@ -1775,6 +1805,7 @@ void SWB_BWE_decoding_fx(
{
L_tmp = Mult_32_16( L_tmp3, *pit1 ); /*Q(16-exp) */
*pit1-- = round_fx( L_shl( L_tmp, exp ) ); /*Q_syn */
+ move16();
L_tmp3 = L_sub( L_tmp3, L_tmp4 );
}
@@ -1807,6 +1838,7 @@ void SWB_BWE_decoding_fx(
FOR( n_freq = L; n_freq < swb_bwe_subband[SWB_FENV] + st_offset; n_freq++ )
{
signum[n_freq] = 1;
+ move16();
IF( SWB_signal[n_freq] < 0 )
{
signum[n_freq] = -1;
@@ -1827,7 +1859,7 @@ void SWB_BWE_decoding_fx(
{
SWB_signal[n_freq] = extract_l( L_tmp ); /* Q_syn */
}
-
+ move16();
IF( NE_16( signum[n_freq], 1 ) )
{
SWB_signal[n_freq] = negate( SWB_signal[n_freq] );
@@ -1843,7 +1875,8 @@ void SWB_BWE_decoding_fx(
exp = sub( sub( 30, exp ), Q_syn );
tmp = div_s( 16384, tmp ); /* Q(15+exp) */
L_tmp = L_shr( L_mult0( SWB_signal[n_freq], tmp ), add( exp, Q_syn ) ); /* Q15 */
- SWB_signal[n_freq] = extract_l( L_tmp ); /* Q15 */
+ SWB_signal[n_freq] = extract_l( L_tmp );
+ move16(); /* Q15 */
}
ELSE
{
@@ -1852,6 +1885,7 @@ void SWB_BWE_decoding_fx(
}
}
*prev_weight = weight;
+ move16();
}
ELSE
{
@@ -1859,6 +1893,7 @@ ELSE
tmp = shl( div_s( shl( 1, sub( 14, exp ) ), L_swb_norm ), sub( exp, 14 ) ); /* Q15 */
tmp = add( shl( tmp, 1 ), tmp );
*prev_weight = s_max( s_min( tmp, 16384 ), 6554 ); /* Q15 */
+ move16();
}
IF( EQ_16( mode, HARMONIC ) )
@@ -1875,7 +1910,6 @@ IF( EQ_16( mode, HARMONIC ) )
}
mean = extract_l( Mult_32_16( L_mean, 2048 ) ); /*Q15 */
pit1 -= 16;
- move16();
FOR( n_freq = 0; n_freq < 16; n_freq++ )
{
if ( LT_16( abs_s( *pit1 ), mean ) )
@@ -1921,6 +1955,7 @@ FOR( n_band = 0; n_band < SWB_FENV; n_band += L )
FOR( n_freq = add( swb_bwe_subband[n_band], st_offset ); n_freq < tmp; n_freq++ )
{
SWB_signal_32[n_freq] = L_shl( L_mult( tmp_ener, SWB_signal[n_freq] ), tmp_exp ); /*Qsyn */
+ move32();
}
}
ELSE
@@ -2120,7 +2155,6 @@ void time_envelop_shaping_fx(
Word32 L_tmp;
pit = werr;
- move16();
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++ )
@@ -2189,6 +2223,7 @@ void time_envelop_shaping_fx(
#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++;
}
}
@@ -2270,7 +2305,6 @@ void time_reduce_pre_echo_fx(
FOR( i = 0; i < 3; i++ )
{
L_tmp = Mult_32_16( energyL[i], 29491 ); /*Q14 */
- test();
IF( GT_32( L_shr( energyL[i + 1], 1 ), L_tmp ) && GT_32( energyL[i + 1], 1638400 ) )
{
pos = add( i, 1 );
@@ -2287,7 +2321,6 @@ void time_reduce_pre_echo_fx(
}
energy = L_deposit_l( 0 );
j = i_mult( L, pos );
- move16();
FOR( i = 0; i < j; i++ )
{
#ifdef BASOP_NOGLOB
@@ -2340,6 +2373,7 @@ void time_reduce_pre_echo_fx(
#else
error[i] = round_fx( L_shl( Mult_32_16( L_tmp, error[i] ), tmp_exp ) ); /*Q(30-exp+1-16)->Q(15-exp)->Q_synth */
#endif
+ move16();
}
energy = L_deposit_l( 0 );
@@ -2394,6 +2428,7 @@ void time_reduce_pre_echo_fx(
tmp = round_fx( L_shl( Mult_32_16( L_tmp, *pit ), add( 1, exp ) ) ); /*Q0 */
#endif
*pit++ = tmp;
+ move16();
}
}
@@ -2519,6 +2554,7 @@ void calc_normal_length_fx_32(
*L_swb_norm = extract_h( L_add( L_mac( L_mult( L_swb_norm_cur, 3276 ), *prev_L_swb_norm, 29491 ), 32768 ) );
*prev_L_swb_norm = L_swb_norm_cur;
move16();
+ move16();
}
return;
@@ -2700,6 +2736,7 @@ void hq_generic_decoding_fx(
IF( EQ_16( tmp, 0 ) )
{
nband_lf = 0;
+ move16();
}
ELSE
{
diff --git a/lib_com/swb_bwe_com_hr_fx.c b/lib_com/swb_bwe_com_hr_fx.c
index da8997a26b5e0f8b844a929b3ad3e54fee7408cd..cac0ed123cd0d564bd19cd0b8ad47764dca36ea0 100644
--- a/lib_com/swb_bwe_com_hr_fx.c
+++ b/lib_com/swb_bwe_com_hr_fx.c
@@ -4,8 +4,7 @@
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
* swb_hr_nonzero_subband_noise_fill()
diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c
index 738cff5915f600eafe6dbb6b6bdbb0a31cd3035b..adc98d36aa4bc8813e5f1680346db2d359492d53 100644
--- a/lib_com/swb_bwe_com_lr_fx.c
+++ b/lib_com/swb_bwe_com_lr_fx.c
@@ -33,7 +33,7 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include
@@ -87,12 +87,14 @@ static void est_freq_har_decis_fx(
)
{
Word16 temp_hfe2 = 0;
+ move16();
Word16 har_freq_est2_2;
Word16 prev_frm_hfe2_2;
IF( k != 0 )
{
*har_freq_est1 = div_s_ss( sharp, k );
+ move16();
}
test();
@@ -100,6 +102,7 @@ static void est_freq_har_decis_fx(
IF( GT_16( k1, 1 ) )
{
*har_freq_est2 = div_s_ss( sharp1, k1 );
+ move16();
}
ELSE IF( LT_16( k1, 2 ) && ( k2 != 0 || GT_16( k, 1 ) ) )
{
@@ -257,6 +260,7 @@ Word16 har_est_fx(
FOR( i = N; i < temp; i++ )
{
L_input_abs[i] = L_deposit_l( 0 );
+ move16();
}
q = start_pos;
@@ -315,6 +319,7 @@ Word16 har_est_fx(
IF( GT_32( *p_L_blk_peak, *pm1_L_blk_peak ) )
{
*pm1_L_blk_peak = L_deposit_l( 0 );
+ move32();
*pm1_blk_peak_pos = 0;
move16();
}
@@ -325,6 +330,7 @@ Word16 har_est_fx(
*p_blk_peak_pos = *pm1_blk_peak_pos;
move16();
*pm1_L_blk_peak = L_deposit_l( 0 );
+ move32();
*pm1_blk_peak_pos = 0;
move16();
}
@@ -569,7 +575,6 @@ Word16 har_est_fx(
blk_peak_pos_hfsb2[ct_hfsb2] = blk_peak_pos_te[i];
move16();
ct_hfsb2 = add( ct_hfsb2, 1 );
- move16();
}
}
@@ -580,9 +585,11 @@ Word16 har_est_fx(
FOR( i = 1; i < ct_hfsb2; i++ )
{
diff_peak_pos_hfsb2[i - 1] = sub( blk_peak_pos_hfsb2[i], blk_peak_pos_hfsb2[i - 1] );
+ move16();
sum_diff = add( sum_diff, diff_peak_pos_hfsb2[i - 1] );
}
*har_freq_est2 = div_s_ss( sum_diff, ct_hfsb2 );
+ move16();
}
ELSE
{
@@ -648,7 +655,7 @@ void genhf_noise_fx(
FOR( k = 0; k < 2; k++ )
{
nlags[k] = shl( 1, bits_lagIndices_mode0_Har[k] );
-
+ move16();
l = 0;
move16();
WHILE( LT_16( st_last_peakpos, add( fLenLow, subband_offsets[k] ) ) )
@@ -665,7 +672,7 @@ void genhf_noise_fx(
FOR( j = 0; j < sbWidth[k]; j++ )
{
L_xSynth_har[j] = L_shl( L_deposit_l( noise_flr_fx[st_pos + j] ), sub( QsL, Qss ) );
-
+ move32();
L_tmpbuf[j] = L_xSynth_har[j];
move32();
IF( predBuf_fx[st_pos + j] != 0x0 )
@@ -692,6 +699,7 @@ void genhf_noise_fx(
/*xSynth_har[ii] = noise_flr[j];*/
L_xSynth_har[ii] = L_shl( L_deposit_l( noise_flr_fx[j] ), sub( QsL, Qss ) );
+ move32();
L_tmpbuf[ii] = L_xSynth_har[ii];
move32();
IF( predBuf_fx[j] != 0x0 )
@@ -749,6 +757,8 @@ void genhf_noise_fx(
{
st_last_peakpos = add( st_last_peakpos, har_freq_est2 );
}
+ test();
+ test();
WHILE( LT_16( st_last_peakpos, hfband_end[k] ) && LT_16( pul_res[k], pul_res[2 - l] ) && LE_16( l, 2 ) )
{
test();
@@ -813,7 +823,7 @@ static void SmoothSpec_fx(
lo = L_Extract_lc( L_sum, &hi );
*outBuf++ = round_fx( L_shl( Mpy_32_16( hi, lo, inItems ), 16 ) ); /* Q(8+15+1-16)=Q8 -> Q(8+16-16)=Q8 */
-
+ move16();
L_sum = L_mac0( L_sum, 0x0001, *newPtr++ );
/* nItems += 2,
* only used value is 5 -->
@@ -831,6 +841,7 @@ static void SmoothSpec_fx(
lo = L_Extract_lc( L_sum, &hi );
/* 4681 (in Q15) = 0.1428 = 1/7 */
*outBuf++ = round_fx( L_shl( Mpy_32_16( hi, lo, 4681 ), 16 ) ); /* Q(8+15+1-16)=Q8 -> Q(8+16-16)=Q8 */
+ move16();
i = add( i, 1 );
/*-- Moving average. --*/
@@ -843,6 +854,7 @@ static void SmoothSpec_fx(
lo = L_Extract_lc( L_sum, &hi );
/* 4681 (in Q15) = 0.1428 = 1/7 */
*outBuf++ = round_fx( L_shl( Mpy_32_16( hi, lo, 4681 ), 16 ) ); /* Q(8+15+1-16)=Q8 -> Q(8+16-16)=Q8 */
+ move16();
inBuf++;
}
@@ -921,10 +933,11 @@ void SpectrumSmoothing_fx(
Word16 exp_norm;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
*Qss = 10;
-
+ move16();
num_subband_smooth_pre_fx = mult( fLen, 21845 ); /* 1/L_SB = 1/12 = 21845(Q18) Q = exp_normn-18 */
num_subband_smooth_fx = shr( num_subband_smooth_pre_fx, 18 - 15 );
IF( NE_16( num_subband_smooth_pre_fx, shl( num_subband_smooth_fx, 18 - 15 ) ) )
@@ -943,14 +956,17 @@ void SpectrumSmoothing_fx(
FOR( i = fLen; i < fLen + ( num_subband_smooth_fx * L_SB - fLen ); i++ )
{
L_inBuf_pss[i] = L_deposit_l( 0 );
+ move32();
outBuf_pss_fx[i] = 0;
move16();
}
j = 0;
+ move16();
FOR( i = 0; i < num_subband_smooth_fx; i++ )
{
L_max_val[i] = L_deposit_l( 0 );
+ move32();
FOR( k = 0; k < L_SB; k++ )
{
L_inBuf_abs = L_abs( L_inBuf_pss[j] );
@@ -966,6 +982,7 @@ void SpectrumSmoothing_fx(
/* convert to maximum amplitude frequency log scale envelope */
j = 0;
+ move16();
FOR( i = 0; i < num_subband_smooth_fx; i++ )
{
/* max_val_norm = 10.0f / (max_val[i] + 0.001f); */
@@ -1017,6 +1034,7 @@ void SpectrumSmoothing_fx(
#else
outBuf_pss_fx[j] = negate( round_fx( L_shl( Mpy_32_16_r( L_shl( L_abs( L_inBuf_pss[j] ), exp_norm ), max_val_norm_fx ), sub( exp_shift, exp_norm ) ) ) );
#endif
+ move16();
}
}
ELSE
@@ -1154,6 +1172,7 @@ void Get20Log10Spec_fx(
L_tmp = Mpy_32_16_1( L_tmp, 24660 ); /* 6.0206 in Q12 */
L_tmp = L_shl( L_tmp, 2 + 8 ); /* Q7 */
*outBuf_fx++ = round_fx( L_tmp );
+ move16();
}
return;
@@ -1318,9 +1337,11 @@ void SpectrumSmoothing_nss_fx(
Word16 exp_shift;
L_tmp[0] = L_deposit_l( 0 );
+ move32();
FOR( i = 0; i < fLen; i++ )
{
L_tmp[0] = L_or( L_tmp[0], L_abs( L_inBuf[i] ) );
+ move32();
}
exp_norm = norm_l( L_tmp[0] );
Qm = sub( exp_norm, 4 ); /* Qm = sub(add(12, exp_norm), 16); */
@@ -1330,6 +1351,7 @@ void SpectrumSmoothing_nss_fx(
L_tmp[i] = L_shl( L_inBuf[i], exp_norm ); /* Q(12+exp_norm) */
move32();
inBuf_fx[i] = round_fx( L_tmp[i] ); /* Qm */
+ move16();
}
num_subband_smooth_fx = shr( fLen, 3 ); /* L_SB_NSS=8 shr(target, 3); */
@@ -1404,7 +1426,8 @@ void SpectrumSmoothing_nss_fx(
{
L_temp_sum_1[i] = L_deposit_l( 0 );
L_temp_sum_2[i] = L_deposit_l( 0 );
-
+ move32();
+ move32();
FOR( k = 0; k < L_SB_NSS_HALF; k++ )
{
L_temp_sum_1[i] = L_add( L_temp_sum_1[i], extract_l( abs_s( inBufw_fx[k + L_SB_NSS * i] ) ) ); /* Qm */
@@ -1444,7 +1467,9 @@ void SpectrumSmoothing_nss_fx(
L_temp1 = L_negate( L_temp1 );
temp_lo = L_Extract_lc( L_temp1, &temp_hi );
Qsumdiv[i] = sub( 14, temp_hi );
+ move16();
temp_sum_div_fx[i] = extract_l( Pow2( 14, temp_lo ) ); /* Qsumdiv[i] */
+ move16();
exp_norm = norm_s( temp_sum_div_fx[i] );
temp_sum_div_fx[i] = shl( temp_sum_div_fx[i], exp_norm );
move16();
@@ -1457,6 +1482,7 @@ void SpectrumSmoothing_nss_fx(
FOR( i = 0; i < num_subband_smooth_fx; i++ )
{
Qo[i] = add( add( Qm, Qsumdiv[i] ), 1 );
+ move16();
L_temp1 = 0x0L;
FOR( k = 0; k < L_SB_NSS; k++ )
{
@@ -1489,6 +1515,7 @@ void SpectrumSmoothing_nss_fx(
L_outBufw[k + L_SB_NSS * i] = L_shl( L_outBufw[k + L_SB_NSS * i], exp_shift );
move16();
outBufw_fx[k + L_SB_NSS * i] = round_fx( L_outBufw[k + L_SB_NSS * i] );
+ move16();
}
}
*Qss = sub( *Qss, 16 );
@@ -1652,7 +1679,6 @@ void post_hq2_swb_fx(
ELSE
{
k = sub( bands_fx, NB_SWB_SUBBANDS );
- move16();
}
FOR( ; k < bands_fx; k++ )
@@ -1709,7 +1735,8 @@ void GetSynthesizedSpecThinOut_fx(
{
fLen_fx = sbWidth_fx[sb];
lag_fx = lagIndices_fx[sb];
-
+ move16();
+ move16();
if ( GT_16( add( lag_fx, fLen_fx ), predBufLen_fx ) )
{
/* should never happen */
@@ -1963,6 +1990,7 @@ void GetlagGains_fx(
/* Sqrt part sqrt(pow (2.0f, band_energy[i])/lagEnergy) */
QlagGains[sb] = add( Qdiv, 16 );
+ move16();
IF( s_and( Qdiv, 1 ) == 0 ) /* Qdiv % 2 == 0 */
{
L_temp = Sqrt_l( L_shr( L_deposit_h( temp_fx ), 1 ), &exp_norm );
@@ -1970,6 +1998,7 @@ void GetlagGains_fx(
QlagGains[sb] = sub( shr( QlagGains[sb], 1 ), 1 );
move16();
lagGains_fx[sb] = round_fx( L_temp );
+ move16();
}
ELSE
{
@@ -1978,6 +2007,7 @@ void GetlagGains_fx(
QlagGains[sb] = shr( QlagGains[sb], 1 );
move16();
lagGains_fx[sb] = round_fx( L_temp );
+ move16();
}
}
ELSE
@@ -2022,6 +2052,7 @@ void noise_extr_corcod_fx(
SpectrumSmoothing_nss_fx( L_spectra, sspectra_fx, &Qss_s, fLenLow_fx );
Copy( sspectra_fx, sspectra_ni_fx, fLenLow_fx );
tmp_fx = 0;
+ move16();
FOR( i = 0; i < fLenLow_fx; i++ )
{
tmp_fx |= abs_s( sspectra_fx[i] );
@@ -2043,6 +2074,7 @@ void noise_extr_corcod_fx(
}
SpectrumSmoothing_nss_fx( L_spectra_diff, sspectra_diff_fx, &Qss_d, fLenLow_fx );
tmp_fx = 0;
+ move16();
FOR( i = 0; i < fLenLow_fx; i++ )
{
tmp_fx |= abs_s( sspectra_diff_fx[i] );
@@ -2083,7 +2115,7 @@ void noise_extr_corcod_fx(
/*Smoothing the noise components*/
br_adj_fx = 29491; /* br_adj = 0.9f; Q15 */
-
+ move16();
pulse_num_fx = 0;
move16();
FOR( i = 0; i < fLenLow_fx; i++ )
@@ -2211,6 +2243,7 @@ void ton_ene_est_fx(
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
*QbeL = 3;
@@ -2241,6 +2274,7 @@ void ton_ene_est_fx(
QsN = sub( add( QsL, 11 ), 15 );
exp_safe = 4; /*move16();*/
+ move16();
norm_vec_32_16_scale_fx( L_xSynth_har, QsN, fLenHigh, xSynth_har_fx, &QxSynth, exp_safe );
pos = 0;
@@ -2302,6 +2336,7 @@ void ton_ene_est_fx(
#else
L_band_energy_Linear[i] = L_shl( L_band_energy_Linear[i], sub( *QbeL, exp_pow ) );
#endif
+ move32();
/* Div Part */
E_r_fx = 0x7fff;
move16();
@@ -2320,7 +2355,7 @@ void ton_ene_est_fx(
L_E = L_shl( L_E, sub( *QbeL, QE ) );
QE = *QbeL;
-
+ move16();
/* 0.06=15729(Q18) */
exp_shift = sub( 18, QE_r );
#ifdef BASOP_NOGLOB
@@ -2339,6 +2374,7 @@ void ton_ene_est_fx(
sqrt_32n_16_fx( L_temp, Qtemp, &avg_pe_fx[k], &Qavg_pe[k] );
fac_fx = 19661; /* 0.6(Q15) */
+ move16();
IF( pul_res_bnd[k] != 0 )
{
/* Div Part */
@@ -2376,9 +2412,10 @@ void ton_ene_est_fx(
Overflow = 0;
move16();
ni_gain_fx[k] = shl( ni_gain_fx[k], sub( Qni_gain, Qavg_pe[k] ) );
+ move16();
assert( Qni_gain == 8 ); /* 358 is '(short)(1.4*pow(2,Qni_gain))' */
ni_gain_fx[k] = s_max( ni_gain_fx[k], 358 ); /* 1.4 -> 22938(Q14) */
-
+ move16();
exp_shift = QsL - ( QxSynth + Qni_gain + 1 ); /* QsL - (QxSynth+Qni_gain+1) */
FOR( j = band_start[i]; j <= band_end[i]; j++ )
{
@@ -2387,6 +2424,7 @@ void ton_ene_est_fx(
}
exp_safe = 4; /* move16(); */
+ move16();
norm_vec_32_16_scale_fx( &L_xSynth_har[band_start[i] - fLenLow], QsL, band_width[i], &xSynth_har_fx[band_start[i] - fLenLow], &QxSynth_sft, exp_safe );
L_E = sum2_fx( &xSynth_har_fx[sub( band_start[i], fLenLow )], band_width[i] );
@@ -2398,6 +2436,7 @@ void ton_ene_est_fx(
L_E = L_shl( L_E, sub( *QbeL, QE ) );
#endif
QE = *QbeL;
+ move16();
}
ELSE
{
@@ -2412,7 +2451,7 @@ void ton_ene_est_fx(
k = add( k, 1 );
L_be_tonal[i] = L_sub( L_band_energy_Linear[i], L_E );
-
+ move32();
IF( L_be_tonal[i] < 0x0L )
{
L_E = L_deposit_l( 0 );
@@ -2523,6 +2562,7 @@ void Gettonl_scalfact_fx(
band_pos_fx = add( k_fx, harmonic_band );
count_pos_st_fx = pos_fx;
move16();
+ test();
WHILE( LE_16( sb_ton_loc_fx[pos_fx], sub( band_end[band_pos_fx], fLenLow ) ) && sb_ton_loc_fx[pos_fx] >= 0 )
{
test();
@@ -2532,6 +2572,7 @@ void Gettonl_scalfact_fx(
move16();
exp_safe = 2; /* move16(); */
+ move16();
QetEne = add( shl( sub( Qss, exp_safe ), 1 ), 1 );
L_temp = L_add( L_est_ton_ene[k_fx], 0 );
FOR( i = count_pos_st_fx; i < count_pos_end_fx; i++ )
@@ -2607,6 +2648,7 @@ void Gettonl_scalfact_fx(
#else
L_band_energy_Linear[band_pos_fx] = L_shl( L_band_energy_Linear[band_pos_fx], sub( QbeL, exp_pow ) );
#endif
+ move32();
/* Div Part */
exp_normd = norm_l( L_be_tonal[band_pos_fx] );
exp_normd = sub( exp_normd, 1 );
@@ -2691,6 +2733,7 @@ void sqrt_32n_16_fx(
L_in_t = L_shr( L_in_t, exp_norm );
*Qout = shr( Qin_t, 1 );
}
+ move16();
*out_fx = round_fx( L_in_t );
}
@@ -2724,6 +2767,7 @@ void norm_vec_32_16_scale_fx(
FOR( i = 0; i < length_fx; i++ )
{
vec_out_fx[i] = round_fx( L_shl( L_vec_in[i], exp_shift ) );
+ move16();
}
}
@@ -2771,6 +2815,7 @@ void get_sigma_fx_har(
FOR( i = 0; i < length_fx; i++ )
{
L_x_abs_sh[i] = L_shl( L_x_abs[i], exp_norm );
+ move32();
}
L_d = L_deposit_l( 0 );
@@ -2830,7 +2875,8 @@ void get_sigma_fx_har(
*Qsigma = shr( Qd, 1 );
*sigma_fx = round_fx( L_temp );
}
-
+ move16();
+ move16();
return;
}
@@ -2870,7 +2916,8 @@ void FindNBiggest2_simple_fx_har(
{
L_abs_in[j] = L_abs( L_inBuf[j] ); /* Qabs_in */
L_abs_in_sft[j] = L_shr( L_abs_in[j], 8 ); /* 8 is safe shift */
-
+ move32();
+ move32();
if ( LT_32( L_max_in, L_abs_in_sft[j] ) )
{
L_max_in = L_abs_in_sft[j];
@@ -2923,6 +2970,7 @@ void FindNBiggest2_simple_fx_har(
IF( GT_32( L_abs_in[j], L_thr ) )
{
pk_sf_fx[peak_cnt_fx].nmrValue_fx = round_fx( L_abs_in[j] ); /* Qabs_in-16 */
+ move16();
pk_sf_fx[peak_cnt_fx].gainIndex_fx = j;
move16();
L_abs_in[j] = L_deposit_l( 0 );
@@ -3026,6 +3074,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_
Word32 L_temp;
Word32 L_spectra_rm[L_FRAME32k];
Word32 L_cut_input = 410;
+ move32();
Word16 rand_a_fx[L_FRAME32k];
@@ -3033,6 +3082,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_
FOR( i = 0; i < fLenLow_fx; i++ )
{
rand_a_fx[i] = Random( ni_seed_fx );
+ move16();
}
@@ -3090,6 +3140,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_
FOR( i = 0; i < fLenLow_fx; i++ )
{
L_spectra_rm[i] = L_deposit_l( 0 );
+ move32();
if ( GE_32( L_abs( L_spectra_diff[i] ), L_cut_input ) )
{
L_spectra_rm[i] = L_spectra_diff[i];
@@ -3114,6 +3165,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_
{
/*sspectra[i] = sign*((10-ss_min)/10.0f*(float)fabs(sspectra[i])+ss_min);*/
sspectra_fx[i] = add( mult_r( ratio_fx, abs_s( sspectra_fx[i] ) ), ss_min_fx );
+ move16();
IF( sign_fx != 0 )
{
sspectra_fx[i] = negate( sspectra_fx[i] );
@@ -3137,6 +3189,7 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_
L_temp = L_mult( ni_ratio_fx, 20480 ); /* ni_ratio*5 */
L_temp = Mult_32_16( L_temp, rand_a_fx[i] ); /* Q28 */
sspectra_ni_fx[i] = round_fx( L_shr( L_temp, 2 ) ); /* Qss */
+ move16();
}
}
@@ -3166,11 +3219,12 @@ void noiseinj_hf_fx(
Word16 *p_prev_En_sb_fx;
Word16 QbeL = 7; /* Don't need 3, because this E only use under th samples */ /* QsEn=3 */
-
+ move16();
Word16 map_pulse_t_fx[L_FRAME32k];
Word16 map_pulse_fx[L_FRAME32k];
Word16 QsEn = 4; /* kiken */
+ move16();
Word32 L_En[NB_SWB_SUBBANDS];
Word32 *p_L_En;
Word16 QE;
@@ -3196,20 +3250,24 @@ void noiseinj_hf_fx(
Word16 Qdiv;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
set16_fx( map_pulse_t_fx, 0, band_end_fx[BANDS_fx - 1] + 1 );
set16_fx( map_pulse_fx, 0, band_end_fx[BANDS_fx - 1] + 1 );
/*level adjust the missing bands in the core coder */
exp_safe = 4; /*move16();*/
+ move16();
norm_vec_32_16_scale_fx( L_xSynth_har, Qs, fLenHigh_fx, xSynth_har_fx, &QxSynth, exp_safe );
QE = add( shl( QxSynth, 1 ), 1 );
p_L_En = L_En;
+ move32();
p_sqrt_En_fx = sqrt_En_fx;
FOR( k = sub( BANDS_fx, NB_SWB_SUBBANDS ); k < BANDS_fx; k++ )
{
*p_L_En = L_deposit_l( 0 );
+ move32();
IF( p2a_flags_fx[k] == 0 )
{
FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ )
@@ -3217,6 +3275,7 @@ void noiseinj_hf_fx(
IF( LE_32( L_abs( L_xSynth_har[i - fLenLow_fx] ), L_th_g[k - ( BANDS_fx - NB_SWB_SUBBANDS )] ) )
{
*p_L_En = L_mac( *p_L_En, xSynth_har_fx[i - fLenLow_fx], xSynth_har_fx[i - fLenLow_fx] );
+ move32();
}
ELSE
{
@@ -3267,6 +3326,7 @@ void noiseinj_hf_fx(
/* 0.8: 26214.4(Q15) 0.2:6553.6(Q15) */
*p_Enn_sm_sb_fx = round_fx( L_mac( L_mult( *p_sqrt_En_fx, 26214 ), *p_prev_En_sb_fx, 6554 ) );
}
+ move16();
}
p_Enn_sm_sb_fx++;
diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c
index 582dc217b2a7b2c72be4889833ecd81b2deddeaa..aec2805a07fb4ec07fc468433241b4dcfc9853dc 100644
--- a/lib_com/swb_tbe_com.c
+++ b/lib_com/swb_tbe_com.c
@@ -39,8 +39,7 @@
#include
#include "cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
#include "ivas_prot.h"
@@ -56,9 +55,6 @@
static void create_random_vector( float output[], const int16_t length, int16_t seed[] );
static void flip_spectrum( const float input[], float output[], const int16_t length );
static void Hilbert_transform( float tmp_R[], float tmp_I[], float *tmpi_R, float *tmpi_I, const int16_t length, const int16_t HB_stage_id );
-#ifdef IVAS_FLOAT_FIXED
-static void Hilbert_transform_fx_32( Word32 tmp_R[], Word32 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id );
-#endif
static void Estimate_mix_factors( const float *shb_res, const float *exc16kWhtnd, const float *White_exc16k, const float pow1, const float pow22, float *vf_modified, int16_t *vf_ind );
/*-------------------------------------------------------------------*
@@ -241,133 +237,6 @@ void flip_and_downmix_generic(
return;
}
-#ifdef IVAS_FLOAT_FIXED
-void flip_and_downmix_generic_fx_32(
- Word32 input[], /* i : input spectrum Qx*/
- Word32 output[], /* o : output spectrum Qx*/
- const Word16 length, /* i : length of spectra */
- Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/
- Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/
- Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/
- Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */
-)
-{
- Word16 i, j;
- Word32 tmp[L_FRAME32k + HILBERT_ORDER1];
- Word32 tmpi_R[L_FRAME32k];
- Word32 tmpi_I[L_FRAME32k];
- Word32 tmpi2_R[L_FRAME32k + HILBERT_ORDER2];
- Word32 tmpi2_I[L_FRAME32k + HILBERT_ORDER2];
- Word32 tmp_R[L_FRAME32k + HILBERT_ORDER2];
- Word32 tmp_I[L_FRAME32k + HILBERT_ORDER2];
-
- /*Word16 s_tmp[L_FRAME32k];*/
- /*Word16 factor;*/
- Word16 period;
- Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580,
- -26319, -17530, -6393, 6393, 17530, 26319,
- 31580, 32609, 29268, 22005, 11793 }; /* Q15 */
- Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739,
- -19519, -27683, -32137, -32137, -27683,
- -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */
- Word16 *local_negsin_table, *local_cos_table;
- Word32 L_tmp;
-
- /* 1850 Hz downmix */
- period = 17;
- move16();
- local_negsin_table = local_negsin_table17;
- local_cos_table = local_cos_table17;
-
-
- FOR( i = 0; i < length; i = i + 2 )
- {
- input[i] = L_negate( input[i] );
- move16();
- }
-
- Copy32( input, tmp + HILBERT_ORDER1, length );
- Copy32( mem1_ext, tmp, HILBERT_ORDER1 );
-
- /* Hilber transform stage - 0 - single precision */
- Hilbert_transform_fx_32( tmp, /* i: Real component of HB */
- tmp, /* i: Imag component of HB */
- tmpi_R, /* o: Real component of HB */
- tmpi_I, /* o: Imag. component of HB */
- length, /* i: length of the spectra */
- 0 ); /* i: HB transform stage */
-
-
- Copy32( mem2_ext, tmpi2_R, HILBERT_ORDER2 );
- Copy32( mem3_ext, tmpi2_I, HILBERT_ORDER2 );
-
- /* Hilber transform stage - 1 */
- Hilbert_transform_fx_32( tmpi_R, /* i: Real component of HB */
- tmpi_I, /* i: Imag component of HB */
- tmpi2_R, /* o: Real component of HB */
- tmpi2_I, /* o: Imag. component of HB */
- length, /* i: length of the spectra */
- 1 ); /* i: HB transform stage */
- Copy32( tmp + length, mem1_ext, HILBERT_ORDER1 );
- Copy32( mem2_ext + HILBERT_ORDER2, tmp_R, HILBERT_ORDER2 );
- Copy32( mem3_ext + HILBERT_ORDER2, tmp_I, HILBERT_ORDER2 );
-
- /* Hilber transform stage - 2 */
- Hilbert_transform_fx_32( tmpi2_R, /* i: Real component of HB */
- tmpi2_I, /* i: Imag component of HB */
- tmpi_R, /* o: Real component of HB */
- tmpi_I, /* o: Imag. component of HB */
- length, /* i: length of the spectra */
- 2 ); /* i: HB transform stage */
-
- Copy32( tmpi2_R + length, mem2_ext, HILBERT_ORDER2 );
- Copy32( tmpi2_I + length, mem3_ext, HILBERT_ORDER2 );
-
- /* Hilber transform stage - 3 */
- Hilbert_transform_fx_32( tmpi_R, /* i: Real component of HB */
- tmpi_I, /* i: Imag component of HB */
- tmp_R, /* o: Real component of HB */
- tmp_I, /* o: Imag. component of HB */
- length, /* i: length of the spectra */
- 3 ); /* i: HB transform stage */
-
- Copy32( tmp_R + length, mem2_ext + HILBERT_ORDER2, HILBERT_ORDER2 );
- Copy32( tmp_I + length, mem3_ext + HILBERT_ORDER2, HILBERT_ORDER2 );
-
- if ( *phase_state >= period )
- {
- *phase_state = 0;
- move16();
- }
-
- i = 0;
- move16();
- j = *phase_state;
- move16();
-
- WHILE( i < length )
- {
- WHILE( ( j < period ) && ( i < length ) )
- {
- L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] ); /*//Qx+16 */
- L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */
- output[i] = L_tmp; /*Qx */
- i++;
- j++;
- }
-
- if ( j >= period )
- {
- j = 0;
- move16();
- }
- }
-
- *phase_state = j;
- move16();
- return;
-}
-#endif
/*----------------------------------------------
* Hilbert_transform()
@@ -411,66 +280,6 @@ static void Hilbert_transform(
return;
}
-#ifdef IVAS_FLOAT_FIXED
-static void Hilbert_transform_fx_32(
- Word32 tmp_R[], /* i: Real component of HB */
- Word32 tmp_I[], /* i: Real component of HB */
- Word32 tmpi_R[], /* o: Real component of HB */
- Word32 tmpi_I[], /* o: Imag. component of HB */
- const Word16 length, /* i: input length */
- const Word16 HB_stage_id /* i: HB transform stage */
-)
-{
- Word16 i, hb_filter_stage, offset;
- Word32 L_tmp;
-
- hb_filter_stage = 2 * HB_stage_id;
- offset = 0;
- move16();
- if ( HB_stage_id == 0 )
- {
- offset = 1;
- move16();
- }
-
- test();
- test();
- IF( HB_stage_id == 0 || HB_stage_id == 2 )
- {
- FOR( i = 0; i < length; i++ )
- {
- L_tmp = Mult_32_16( tmp_R[i + 4], Hilbert_coeffs_fx[hb_filter_stage][0 + offset] ); /*Qx+15 */
- L_tmp = Madd_32_16( L_tmp, tmp_R[i + 2], Hilbert_coeffs_fx[hb_filter_stage][2 + offset] ); /*Qx+15 */
- L_tmp = Madd_32_16( L_tmp, tmp_R[i], Hilbert_coeffs_fx[hb_filter_stage][4 + offset] ); /*Qx+15 */
- tmpi_R[i] = L_shl( L_tmp, 1 );
- move32(); /*Qx+16 */
-
- L_tmp = Mult_32_16( tmp_I[i + 4 + offset], Hilbert_coeffs_fx[hb_filter_stage + 1][0] ); /*Qx+15 */
- L_tmp = Madd_32_16( L_tmp, tmp_I[i + 2 + offset], Hilbert_coeffs_fx[hb_filter_stage + 1][2] ); /*Qx+15 */
- L_tmp = Madd_32_16( L_tmp, tmp_I[i + offset], Hilbert_coeffs_fx[hb_filter_stage + 1][4] ); /*Qx+15 */
- tmpi_I[i] = L_shl( L_tmp, 1 );
- move32(); /*Qx+16 */
- }
- }
- ELSE IF( HB_stage_id == 1 || HB_stage_id == 3 )
- {
- FOR( i = 0; i < length; i++ )
- {
-
- L_tmp = Mult_32_16( tmpi_R[i + 2], Hilbert_coeffs_fx[hb_filter_stage][2] ); /*Qx+15 */
- L_tmp = Madd_32_16( L_tmp, tmpi_R[i], Hilbert_coeffs_fx[hb_filter_stage][4] ); /*Qx+15 */
- tmpi_R[i + 4] = L_sub( tmp_R[i], L_shl( L_tmp, 1 ) );
- move32(); /*Qx+16 */
-
- L_tmp = Mult_32_16( tmpi_I[i + 2], Hilbert_coeffs_fx[hb_filter_stage + 1][2] ); /*Qx+15 */
- L_tmp = Madd_32_16( L_tmp, tmpi_I[i], Hilbert_coeffs_fx[hb_filter_stage + 1][4] ); /*Qx+15 */
- tmpi_I[i + 4] = L_sub( tmp_I[i], L_shl( L_tmp, 1 ) );
- move32(); /*Qx+16 */
- }
- }
-}
-#endif
-
/*-------------------------------------------------------------------*
* flip_spectrum()
*
@@ -1408,11 +1217,11 @@ void GenSHBSynth_fx_32(
Word32 *shb_syn_speech_32k, /* o : output highband component Qx*/
Word32 Hilbert_Mem[], /* i/o: memory Qx*/
Word32 state_lsyn_filt_shb_local[], /* i/o: memory Qx*/
- const int16_t L_frame, /* i : ACELP frame length */
- int16_t *syn_dm_phase )
+ const Word16 L_frame, /* i : ACELP frame length */
+ Word16 *syn_dm_phase )
{
Word32 speech_buf_32k[L_FRAME32k];
- int16_t i;
+ Word16 i;
Interpolate_allpass_steep_32( input_synspeech, state_lsyn_filt_shb_local, L_FRAME16k, speech_buf_32k );
@@ -1425,14 +1234,15 @@ void GenSHBSynth_fx_32(
FOR( i = 0; i < L_FRAME32k; i++ )
{
// shb_syn_speech_32k[i] = ( ( i % 2 ) == 0 ) ? ( -speech_buf_32k[i] ) : ( speech_buf_32k[i] );
- IF( EQ_16( i % 2, 0 ) )
+ IF( i % 2 == 0 )
{
- shb_syn_speech_32k[i] = -speech_buf_32k[i];
+ shb_syn_speech_32k[i] = L_negate( speech_buf_32k[i] );
}
ELSE
{
shb_syn_speech_32k[i] = speech_buf_32k[i];
}
+ move32();
}
}
@@ -1554,7 +1364,7 @@ void ScaleShapedSHB(
}
#ifdef IVAS_FLOAT_FIXED
void ScaleShapedSHB_32(
- const int16_t length, /* i : SHB overlap length */
+ const Word16 length, /* i : SHB overlap length */
Word32 *synSHB_fx, /* i/o: synthesized shb signal Q_inp/Q_new */
Word32 *overlap_fx, /* i/o: buffer for overlap-add Q_inp/Q_new */
const Word16 *subgain_fx, /* i : subframe gain Q15 */
@@ -1573,26 +1383,33 @@ void ScaleShapedSHB_32(
/* initilaization */
l_frame = L_FRAME16k;
l_shb_lahead = L_SHB_LAHEAD;
+ move16();
+ move16();
skip = skip_bands_SWB_TBE;
- IF( length == SHB_OVERLAP_LEN / 2 )
+ IF( EQ_16( length, SHB_OVERLAP_LEN / 2 ) )
{
skip = skip_bands_WB_TBE;
l_frame = L_FRAME16k / 4;
l_shb_lahead = L_SHB_LAHEAD / 4;
+ move16();
+ move16();
}
/* apply gain for each subframe, and store noise output signal using overlap-add */
set32_fx( mod_syn_fx, 0, l_frame + l_shb_lahead );
- IF( length == SHB_OVERLAP_LEN / 2 )
+ IF( EQ_16( length, SHB_OVERLAP_LEN / 2 ) )
{
sum_gain_fx = 0;
- FOR( k = 0; k < length / 2; k++ )
+ move16();
+ FOR( k = 0; k < shr( length, 1 ); k++ )
{
sum_gain_fx = mult_r( subwin_fx[2 * k + 2], subgain_fx[0] );
- mod_syn_fx[skip[0] + k] = Mpy_32_16_1( synSHB_fx[skip[0] + k], sum_gain_fx ); // Qx
- mod_syn_fx[skip[0] + k + length / 2] = Mpy_32_16_1( synSHB_fx[skip[0] + k + length / 2], subgain_fx[0] ); // Qx
+ mod_syn_fx[add( skip[0], k )] = Mpy_32_16_1( synSHB_fx[add( skip[0], k )], sum_gain_fx );
+ move32(); // Qx
+ mod_syn_fx[add( add( skip[0], k ), shr( length, 1 ) )] = Mpy_32_16_1( synSHB_fx[add( add( skip[0], k ), shr( length, 1 ) )], subgain_fx[0] ); // Qx
+ move32();
}
FOR( i = 1; i < NUM_SHB_SUBFR / 2; i++ )
{
@@ -1600,13 +1417,15 @@ void ScaleShapedSHB_32(
{
L_tmp = L_mult0( subwin_fx[k + 1], subgain_fx[i] );
sum_gain_fx = round_fx( L_mac0( L_tmp, subwin_fx[length - k - 1], subgain_fx[i - 1] ) );
- mod_syn_fx[skip[i] + k] = L_shl( Mpy_32_16_1( synSHB_fx[skip[i] + k], sum_gain_fx ), 1 ); // Qx
+ mod_syn_fx[add( skip[i], k )] = L_shl( Mpy_32_16_1( synSHB_fx[add( skip[i], k )], sum_gain_fx ), 1 ); // Qx
+ move32();
}
}
- FOR( k = 0; k < length / 2; k++ )
+ FOR( k = 0; k < shr( length, 1 ); k++ )
{
- sum_gain_fx = mult_r( subwin_fx[length - 2 * k - 2], subgain_fx[i - 1] );
- mod_syn_fx[skip[i] + k] = Mpy_32_16_1( synSHB_fx[skip[i] + k], sum_gain_fx ); // Qx
+ sum_gain_fx = mult_r( subwin_fx[sub( sub( length, shl( k, 1 ) ), 2 )], subgain_fx[i - 1] );
+ mod_syn_fx[add( skip[i], k )] = Mpy_32_16_1( synSHB_fx[add( skip[i], k )], sum_gain_fx ); // Qx
+ move32();
}
}
ELSE
@@ -1614,52 +1433,61 @@ void ScaleShapedSHB_32(
num_join = NUM_SHB_SUBFR / NUM_SHB_SUBGAINS;
join_length = i_mult( num_join, length );
j = 0;
+ move16();
+ move16();
FOR( k = 0; k < length; k++ )
{
mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], mult_r( subwin_fx[k + 1], subgain_fx[0] ) ); // Qx
- j++;
+ move32();
+ j = add( j, 1 );
}
FOR( i = 0; i < NUM_SHB_SUBGAINS - 1; i++ )
{
FOR( k = 0; k < join_length - length; k++ )
{
- mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], subgain_fx[i * num_join] ); // Qx
- j++;
+ mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], subgain_fx[i_mult( i, num_join )] ); // Qx
+ move32();
+ j = add( j, 1 );
}
FOR( k = 0; k < length; k++ )
{
- L_tmp = L_mult0( subwin_fx[length - k - 1], subgain_fx[i * num_join] );
- mod_syn_fx[j] = L_shl( Mpy_32_16_1( synSHB_fx[j], round_fx( L_mac0( L_tmp, subwin_fx[k + 1], subgain_fx[( i + 1 ) * num_join] ) ) ), 1 ); // Qx
- j++;
+ L_tmp = L_mult0( subwin_fx[length - k - 1], subgain_fx[i_mult( i, num_join )] );
+ mod_syn_fx[j] = L_shl( Mpy_32_16_1( synSHB_fx[j], round_fx( L_mac0( L_tmp, subwin_fx[k + 1], subgain_fx[i_mult( ( i + 1 ), num_join )] ) ) ), 1 ); // Qx
+ move32();
+ j = add( j, 1 );
}
}
FOR( k = 0; k < join_length - length; k++ )
{
mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], subgain_fx[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); // Qx
- j++;
+ move32();
+ j = add( j, 1 );
}
FOR( k = 0; k < length; k++ )
{
- mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], mult_r( subwin_fx[length - k - 1], subgain_fx[( NUM_SHB_SUBGAINS - 1 ) * num_join] ) ); // Qx
- j++;
+ mod_syn_fx[j] = Mpy_32_16_1( synSHB_fx[j], mult_r( subwin_fx[sub( sub( length, k ), 1 )], subgain_fx[( NUM_SHB_SUBGAINS - 1 ) * num_join] ) ); // Qx
+ move32();
+ j = add( j, 1 );
}
}
Word16 norm_shift = norm_l( frame_gain_fx );
- IF( frame_gain_fx == 0 )
+ if ( frame_gain_fx == 0 )
{
norm_shift = 31;
+ move16();
}
norm_shift = s_min( norm_shift, 14 );
norm_shift = sub( norm_shift, 1 );
*Q_new = add( *Q_inp, sub( norm_shift, 13 ) ); // Q_new = Q_inp + min(norm_shift,14) - 14;
-
+ move16();
FOR( i = 0; i < L_SHB_LAHEAD; i++ )
{
- overlap_fx[i] = L_shl( overlap_fx[i], *Q_new - *Q_inp );
+ overlap_fx[i] = L_shl( overlap_fx[i], sub( *Q_new, *Q_inp ) );
+ move32();
}
FOR( i = 0; i < l_shb_lahead; i++ )
@@ -1667,21 +1495,27 @@ void ScaleShapedSHB_32(
synSHB_fx[i] = Mpy_32_32( mod_syn_fx[i], Mpy_32_16_1( L_shl( frame_gain_fx, norm_shift ), win_fx[i] ) ); // Q_new
synSHB_fx[i] = L_add( synSHB_fx[i], overlap_fx[i] );
synSHB_fx[i + l_shb_lahead] = Mpy_32_32( mod_syn_fx[i], L_shl( frame_gain_fx, norm_shift ) ); // Q_new
+ move32();
+ move32();
+ move32();
}
FOR( ; i < l_frame; i++ )
{
synSHB_fx[i] = Mpy_32_32( mod_syn_fx[i], L_shl( frame_gain_fx, norm_shift ) ); // Q_new
+ move32();
}
FOR( ; i < l_frame + l_shb_lahead; i++ )
{
- synSHB_fx[i] = L_shl( synSHB_fx[i], *Q_new - *Q_inp );
+ synSHB_fx[i] = L_shl( synSHB_fx[i], sub( *Q_new, *Q_inp ) );
overlap_fx[i - l_frame] = Mpy_32_32( mod_syn_fx[i], Mpy_32_16_1( L_shl( frame_gain_fx, norm_shift ), win_fx[l_frame + l_shb_lahead - 1 - i] ) ); // Q_new
+ move32();
+ move32();
}
*Q_inp = *Q_new;
-
+ move16();
return;
}
#endif
diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c
index ffb96c5dfc8cb61c835fa1a47bb8cbfffb42a919..55ca77c35b494eb573bd5376c6f0a45ce0ade055 100644
--- a/lib_com/swb_tbe_com_fx.c
+++ b/lib_com/swb_tbe_com_fx.c
@@ -8,8 +8,7 @@
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
@@ -204,6 +203,7 @@ void tbe_celp_exc(
tmp_fx = extract_l( L_mult( tmp_fx, 5 ) ); /*Q5, 2.5 in Q1*/
tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*Q5*/
*error_fx = add( *error_fx, tmp_fx ); /*Q5*/
+ move16();
}
ELSE
{
@@ -233,6 +233,7 @@ void tbe_celp_exc(
tmp_fx = shl( tmp_fx, 2 ); /*now above tmp_fx in Q5*/
tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*move offset_fx to Q5, tmp_fx in Q5, ans tmp_fx in Q5*/
*error_fx = add( *error_fx, tmp_fx ); /*error_fx in Q5*/
+ move16();
}
}
@@ -290,6 +291,7 @@ void tbe_celp_exc_ivas(
tmp_fx = extract_l( L_mult( tmp_fx, 5 ) ); /*Q5, 2.5 in Q1*/
tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*Q5*/
*error_fx = add( *error_fx, tmp_fx ); /*Q5*/
+ move16();
}
ELSE
{
@@ -319,6 +321,7 @@ void tbe_celp_exc_ivas(
tmp_fx = shl( tmp_fx, 2 ); /*now above tmp_fx in Q5*/
tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*move offset_fx to Q5, tmp_fx in Q5, ans tmp_fx in Q5*/
*error_fx = add( *error_fx, tmp_fx ); /*error_fx in Q5*/
+ move16();
}
}
@@ -398,6 +401,7 @@ void flip_and_downmix_generic_fx(
FOR( i = 0; i < HILBERT_ORDER1; i++ )
{
tmp_16[i] = extract_h( mem1_ext[i] ); /* mem1_ext (Qx+16) tmp16 (Qx) */
+ move16();
}
/* Hilber transform stage - 0 - single precision */
@@ -411,6 +415,7 @@ void flip_and_downmix_generic_fx(
FOR( i = 0; i < HILBERT_ORDER1; i++ )
{
mem1_ext[i] = L_deposit_h( tmp_16[i + length] ); /* mem1_ext (Qx+16) tmp16 (Qx) */
+ move32();
}
Copy32( mem2_ext, tmpi2_R, HILBERT_ORDER2 );
@@ -467,6 +472,7 @@ void flip_and_downmix_generic_fx(
L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] ); /*//Qx+16 */
L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */
output[i] = round_fx( L_tmp ); /*Qx */
+ move16();
i++;
j++;
}
@@ -483,6 +489,131 @@ void flip_and_downmix_generic_fx(
return;
}
+void flip_and_downmix_generic_fx_32(
+ Word32 input[], /* i : input spectrum Qx*/
+ Word32 output[], /* o : output spectrum Qx*/
+ const Word16 length, /* i : length of spectra */
+ Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/
+ Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/
+ Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/
+ Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */
+)
+{
+ Word16 i, j;
+ Word32 tmp[L_FRAME32k + HILBERT_ORDER1];
+ Word32 tmpi_R[L_FRAME32k];
+ Word32 tmpi_I[L_FRAME32k];
+ Word32 tmpi2_R[L_FRAME32k + HILBERT_ORDER2];
+ Word32 tmpi2_I[L_FRAME32k + HILBERT_ORDER2];
+ Word32 tmp_R[L_FRAME32k + HILBERT_ORDER2];
+ Word32 tmp_I[L_FRAME32k + HILBERT_ORDER2];
+
+ /*Word16 s_tmp[L_FRAME32k];*/
+ /*Word16 factor;*/
+ Word16 period;
+ Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580,
+ -26319, -17530, -6393, 6393, 17530, 26319,
+ 31580, 32609, 29268, 22005, 11793 }; /* Q15 */
+ Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739,
+ -19519, -27683, -32137, -32137, -27683,
+ -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */
+ Word16 *local_negsin_table, *local_cos_table;
+ Word32 L_tmp;
+
+ /* 1850 Hz downmix */
+ period = 17;
+ move16();
+ local_negsin_table = local_negsin_table17;
+ local_cos_table = local_cos_table17;
+
+
+ FOR( i = 0; i < length; i = i + 2 )
+ {
+ input[i] = L_negate( input[i] );
+ move16();
+ }
+
+ Copy32( input, tmp + HILBERT_ORDER1, length );
+ Copy32( mem1_ext, tmp, HILBERT_ORDER1 );
+
+ /* Hilber transform stage - 0 - single precision */
+ Hilbert_transform_fx( tmp, /* i: Real component of HB */
+ tmp, /* i: Imag component of HB */
+ tmpi_R, /* o: Real component of HB */
+ tmpi_I, /* o: Imag. component of HB */
+ length, /* i: length of the spectra */
+ 0 ); /* i: HB transform stage */
+
+
+ Copy32( mem2_ext, tmpi2_R, HILBERT_ORDER2 );
+ Copy32( mem3_ext, tmpi2_I, HILBERT_ORDER2 );
+
+ /* Hilber transform stage - 1 */
+ Hilbert_transform_fx( tmpi_R, /* i: Real component of HB */
+ tmpi_I, /* i: Imag component of HB */
+ tmpi2_R, /* o: Real component of HB */
+ tmpi2_I, /* o: Imag. component of HB */
+ length, /* i: length of the spectra */
+ 1 ); /* i: HB transform stage */
+ Copy32( tmp + length, mem1_ext, HILBERT_ORDER1 );
+ Copy32( mem2_ext + HILBERT_ORDER2, tmp_R, HILBERT_ORDER2 );
+ Copy32( mem3_ext + HILBERT_ORDER2, tmp_I, HILBERT_ORDER2 );
+
+ /* Hilber transform stage - 2 */
+ Hilbert_transform_fx( tmpi2_R, /* i: Real component of HB */
+ tmpi2_I, /* i: Imag component of HB */
+ tmpi_R, /* o: Real component of HB */
+ tmpi_I, /* o: Imag. component of HB */
+ length, /* i: length of the spectra */
+ 2 ); /* i: HB transform stage */
+
+ Copy32( tmpi2_R + length, mem2_ext, HILBERT_ORDER2 );
+ Copy32( tmpi2_I + length, mem3_ext, HILBERT_ORDER2 );
+
+ /* Hilber transform stage - 3 */
+ Hilbert_transform_fx( tmpi_R, /* i: Real component of HB */
+ tmpi_I, /* i: Imag component of HB */
+ tmp_R, /* o: Real component of HB */
+ tmp_I, /* o: Imag. component of HB */
+ length, /* i: length of the spectra */
+ 3 ); /* i: HB transform stage */
+
+ Copy32( tmp_R + length, mem2_ext + HILBERT_ORDER2, HILBERT_ORDER2 );
+ Copy32( tmp_I + length, mem3_ext + HILBERT_ORDER2, HILBERT_ORDER2 );
+
+ if ( *phase_state >= period )
+ {
+ *phase_state = 0;
+ move16();
+ }
+
+ i = 0;
+ move16();
+ j = *phase_state;
+ move16();
+
+ WHILE( i < length )
+ {
+ WHILE( ( j < period ) && ( i < length ) )
+ {
+ L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] ); /*//Qx+16 */
+ L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */
+ output[i] = L_tmp; /*Qx */
+ i++;
+ j++;
+ }
+
+ if ( j >= period )
+ {
+ j = 0;
+ move16();
+ }
+ }
+
+ *phase_state = j;
+ move16();
+ return;
+}
/*----------------------------------------------
* Hilbert transform - Double precision
@@ -729,6 +860,7 @@ static void filt_mu_fx(
Word16 tmp, exp;
#ifdef FIX_729_MISSING_RESCALING
Flag Overflow = 0;
+ move32();
#endif
@@ -772,14 +904,6 @@ static void filt_mu_fx(
temp = add( temp, *ptrs ); /*Q12 */
#ifdef FIX_729_MISSING_RESCALING
sig_out[n] = shl_o( mult_r( ga, temp ), 1, &Overflow );
-#ifdef DEBUGGING
- if ( Overflow )
- {
- fprintf( stderr, "Saturation in filt_mu_fx for ga = %d, temp = %d, result = %.2f at frame %d\n\n", ga, temp, (float) ga * temp * 4.0 / 65536.0, frame );
- Overflow = 0;
- }
-#endif
-
#else
sig_out[n] = shl( mult_r( ga, temp ), 1 );
#endif
@@ -888,6 +1012,7 @@ static void scale_st_swb(
L_temp = L_shl( L_temp, 1 ); /*14 + Q_bwe_exc +1 */
sig_out_fx[i] = round_fx( L_temp ); /*Q_bwe_exc +15 -16 = Q_bwe_exc-1 */
#endif
+ move16();
}
*gain_prec_fx = gain_fx;
move16();
@@ -1116,6 +1241,7 @@ void ivas_GenShapedWBExcitation_fx(
FOR( i = 0; i < L_FRAME16k / 4; i++ )
{
exc4kWhtnd[i] = shl_r( exc4kWhtnd[i], sub( Q_bwe_exc, 5 ) ); /*Q(Q_bwe_exc)/Q5(if Q_bwe_exc > 5) */
+ move16();
}
}
}
@@ -1142,6 +1268,7 @@ void ivas_GenShapedWBExcitation_fx(
/* Ensure pow1 is greater than zero when computing normalization */
max_val = 0;
+ move16();
FOR( i = 0; i < L_FRAME16k / 4; i++ )
{
excTmp2[i] = abs_s( exc4kWhtnd[i] );
@@ -1171,6 +1298,7 @@ void ivas_GenShapedWBExcitation_fx(
}
n1 = sub( sub( 14, n1 ), Q_bwe_exc );
pow1 = 1;
+ move32();
FOR( i = 0; i < L_FRAME16k / 4; i++ )
{
#ifdef BASOP_NOGLOB
@@ -1224,9 +1352,11 @@ void ivas_GenShapedWBExcitation_fx(
#else
exc4k_frac[i] = extract_h( L_shl( exc4k_32[i], n2 ) ); /* Q(14-n2) */
#endif
+ move16();
}
n2 = 30 - n2 - ( Q_bwe_exc + 6 );
pow22 = 1;
+ move32();
FOR( i = 0; i < L_FRAME16k / 4; i++ )
{
#ifdef BASOP_NOGLOB
@@ -1257,6 +1387,7 @@ void ivas_GenShapedWBExcitation_fx(
#else
exc4kWhtnd[i] = round_fx( L_shl( L_mult( exc4k_frac[i], scale ), sc ) ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */
#endif
+ move16();
}
}
ELSE
@@ -1309,6 +1440,7 @@ void ivas_GenShapedWBExcitation_fx(
L_tmp = L_add( L_tmp, L_shl( L_mult( temp2, exc4k_frac[k] ), sc ) ); /* Q(16+Q_bwe_exc) */
exc4kWhtnd[k] = round_fx( L_tmp ); /* Q_bwe_exc */
#endif
+ move16();
k++;
}
}
@@ -1363,6 +1495,7 @@ void GenShapedWBExcitation_fx(
Word16 avg_voice_fac;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*0.25f*sum_f(voice_factors, NB_SUBFR)*/
@@ -1404,6 +1537,7 @@ void GenShapedWBExcitation_fx(
FOR( i = 0; i < L_FRAME16k / 4; i++ )
{
exc4kWhtnd[i] = shl_r( exc4kWhtnd[i], sub( Q_bwe_exc, 5 ) ); /*Q(Q_bwe_exc)/Q5(if Q_bwe_exc > 5) */
+ move16();
}
}
}
@@ -1459,6 +1593,7 @@ void GenShapedWBExcitation_fx(
}
n1 = sub( sub( 14, n1 ), Q_bwe_exc );
pow1 = 1;
+ move32();
FOR( i = 0; i < L_FRAME16k / 4; i++ )
{
#ifdef BASOP_NOGLOB
@@ -1512,9 +1647,11 @@ void GenShapedWBExcitation_fx(
#else
exc4k_frac[i] = extract_h( L_shl( exc4k_32[i], n2 ) ); /* Q(14-n2) */
#endif
+ move16();
}
n2 = 30 - n2 - ( Q_bwe_exc + 6 );
pow22 = 1;
+ move32();
FOR( i = 0; i < L_FRAME16k / 4; i++ )
{
#ifdef BASOP_NOGLOB
@@ -1545,6 +1682,7 @@ void GenShapedWBExcitation_fx(
#else
exc4kWhtnd[i] = round_fx( L_shl( L_mult( exc4k_frac[i], scale ), sc ) ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */
#endif
+ move16();
}
}
ELSE
@@ -1552,6 +1690,7 @@ void GenShapedWBExcitation_fx(
sc = sub( add( n2, Q_bwe_exc ), 14 ); /* Q_bwe_exc+n2-14*/
k = 0;
+ move16();
FOR( i = 0; i < 4; i++ )
{
test();
@@ -1597,6 +1736,7 @@ void GenShapedWBExcitation_fx(
L_tmp = L_add( L_tmp, L_shl( L_mult( temp2, exc4k_frac[k] ), sc ) ); /* Q(16+Q_bwe_exc) */
exc4kWhtnd[k] = round_fx( L_tmp ); /* Q_bwe_exc */
#endif
+ move16();
k++;
}
}
@@ -1819,10 +1959,14 @@ void GenShapedSHBExcitation_fx(
Word16 excTmp2[L_FRAME16k];
Word16 *White_exc16k;
Word16 excNoisyEnv[L_FRAME16k];
- Word16 csfilt_num2[1] = { 6554 }; /*0.2 in Q15 */
+ Word16 csfilt_num2[1] = { 6554 }; /*0.2 in Q15 */
+ move16();
Word16 neg_csfilt_den2[2] = { -32767, 26214 }; /* {1.0f, -0.8f} */
+ move16();
+ move16();
Word16 varEnvShape;
Word16 fb_deemph_fac = 15729; /*0.48f in Q15 */
+ move16();
Word16 exc16kWhtnd[L_FRAME16k];
Word32 L_tmp;
@@ -1903,6 +2047,7 @@ void GenShapedSHBExcitation_fx(
FOR( i = 0; i < 80; i++ )
{
exc16kWhtnd[temp2 + i] = round_fx( L_shl( L_mult( exc16kWhtnd[temp2 + i], temp1 ), 1 ) );
+ move16();
/* exc16kWhtnd in Q_bwe_exc, shb_res_gshape in Q14 */
}
temp2 = add( temp2, 80 );
@@ -2107,6 +2252,7 @@ void GenShapedSHBExcitation_fx(
if ( L_tmp == 0 )
{
Q_temp = 31;
+ move16();
}
/*Copy_Scale_sig( White_exc16k, White_exc16k, L_FRAME16k, sub(NOISE_QFAC, 5) );)*/
/* White_exc16k in Q6 */
@@ -2231,10 +2377,13 @@ void GenShapedSHBExcitation_fx(
Estimate_mix_factors_fx( shb_res, Q_shb, exc16kWhtnd, *Q_bwe_exc, White_exc16k,
( *Q_bwe_exc - NOISE_QADJ ), pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind );
tmp = voiceFacEst[0];
+ move16();
tmp2 = MAX_16;
+ move16();
if ( LE_16( tmp, 22938 /*0.7f Q15*/ ) )
{
tmp2 = 26214 /*0.8f Q15*/;
+ move16();
}
}
}
@@ -2259,9 +2408,11 @@ void GenShapedSHBExcitation_fx(
/* *vf_ind is an integer scale by 0.125f*/
tmp = shl( *vf_ind, ( 15 - 3 ) );
tmp2 = MAX_16;
+ move16();
if ( LE_16( tmp, 22938 /*0.7f Q15*/ ) )
{
tmp2 = 26214 /*0.8f Q15*/;
+ move16();
}
}
}
@@ -2296,8 +2447,9 @@ void GenShapedSHBExcitation_fx(
White_exc16k_FB[k] = round_fx( L_shl( White_exc16k_32[k], tmp ) ); /* Q_bwe_exc +5 +1 +Q_temp -16 -3 */
}
prev_Q_bwe_exc_fb = *Q_bwe_exc_fb;
+ move16();
*Q_bwe_exc_fb = sub( add( *Q_bwe_exc, Q_temp ), 13 );
-
+ move16();
deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph );
/* i/o: White_exc16k (Q_bwe_exc-NOISE_QADJ) */
/* i: tbe_demph (Q_bwe_exc-NOISE_QADJ) */
@@ -2355,6 +2507,7 @@ void GenShapedSHBExcitation_fx(
L_tmp = L_mult( White_exc16k[k], scale );
/* L_tmp: (Q_bwe_exc-NOISE_QADJ) + 15 + 1 */
exc16kWhtnd[k] = round_fx( L_shl( L_tmp, NOISE_QADJ ) );
+ move16();
/* exc16kWhtnd: Q_bwe_exc */
}
preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph );
@@ -2383,9 +2536,11 @@ void GenShapedSHBExcitation_fx(
IF( EQ_16( coder_type, VOICED ) && ( LT_32( bitrate, ACELP_24k40 ) ) )
{
exp = 0;
+ move16();
tempQ15 = Sqrt16( voice_factors[i], &exp ); /* Q15 */
temp = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */
exp = 0;
+ move16();
tempQ15 = Sqrt16( temp, &exp ); /* Q15 */
temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */
@@ -2408,6 +2563,7 @@ void GenShapedSHBExcitation_fx(
vf_tmp = mult_r( voice_factors[i], vf_tmp );
exp = 0;
+ move16();
tempQ15 = Sqrt16( vf_tmp, &exp ); /* Q15 */
temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */
@@ -2441,6 +2597,7 @@ void GenShapedSHBExcitation_fx(
/* estimate the pre-emph factor */
tempQ15 = sub( MAX_16, voice_factors[i] );
exp = 0;
+ move16();
temp = Sqrt16( tempQ15, &exp );
temp = shl( temp, exp - 1 );
@@ -2633,8 +2790,11 @@ void GenShapedSHBExcitation_ivas_fx(
Word16 excTmp2[L_FRAME16k];
Word16 *White_exc16k;
Word16 excNoisyEnv[L_FRAME16k];
- Word16 csfilt_num2[1] = { 6554 }; /*0.2 in Q15 */
+ Word16 csfilt_num2[1] = { 6554 }; /*0.2 in Q15 */
+ move16();
Word16 neg_csfilt_den2[2] = { -32767, 26214 }; /* {1.0f, -0.8f} */
+ move16();
+ move16();
Word16 varEnvShape;
Word16 fb_deemph_fac = 15729; /*0.48f in Q15 */
Word16 exc16kWhtnd[L_FRAME16k];
@@ -2642,6 +2802,7 @@ void GenShapedSHBExcitation_ivas_fx(
Word32 L_tmp;
Word16 vf_tmp;
Word16 tmp, exp, tmp2 = 0;
+ move16();
Word16 voiceFacEst[NB_SUBFR16k];
Word16 zero_mem[LPC_SHB_ORDER];
Word32 syn_shb_ener_sf[4];
@@ -2668,6 +2829,7 @@ void GenShapedSHBExcitation_ivas_fx(
Word16 c0_part[NUM_SHB_SUBGAINS], c1_part[NUM_SHB_SUBGAINS], c2_part[NUM_SHB_SUBGAINS], c3_part[NUM_SHB_SUBGAINS], c4_part[NUM_SHB_SUBGAINS], c5_part[NUM_SHB_SUBGAINS];
mix_factor = 0;
+ move16();
#endif
set16_fx( zero_mem, 0, LPC_SHB_ORDER );
set16_fx( wht_fil_mem, 0, LPC_WHTN_ORDER );
@@ -2716,6 +2878,7 @@ void GenShapedSHBExcitation_ivas_fx(
FOR( i = 0; i < 80; i++ )
{
exc16kWhtnd[temp2 + i] = round_fx( L_shl( L_mult( exc16kWhtnd[temp2 + i], temp1 ), 1 ) );
+ move16();
/* exc16kWhtnd in Q_bwe_exc, shb_res_gshape in Q14 */
}
temp2 = add( temp2, 80 );
@@ -2832,13 +2995,18 @@ void GenShapedSHBExcitation_ivas_fx(
{
// varEnvShape = 0.995f;
varEnvShape = 32604;
- // csfilt_num2[0] = 1.0f - varEnvShape;
+ move16();
csfilt_num2[0] = 32768 - varEnvShape;
+ // csfilt_num2[0] = sub( 32767, varEnvShape );
+ move16();
neg_csfilt_den2[1] = varEnvShape;
+ move16();
}
White_exc16k = exc16k;
- Word16 Q_excTmp2 = getScaleFactor16( excTmp2, L_FRAME16k ) + *Q_bwe_exc;
+ move16();
+ Word16 Q_excTmp2 = add( getScaleFactor16( excTmp2, L_FRAME16k ), *Q_bwe_exc );
+ test();
/* Track the low band envelope */
IF( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT )
{
@@ -2846,25 +3014,32 @@ void GenShapedSHBExcitation_ivas_fx(
{
mem_csfilt_left = 0;
mem_csfilt_right = 0;
+ move16();
+ move16();
FOR( k = 0; k < L_FRAME16k; k++ )
{
// excNoisyEnvLeft[k] = mem_csfilt_left + csfilt_num2[0] * excTmp2[k];
excNoisyEnvLeft[k] = add( mem_csfilt_left, mult_r( csfilt_num2[0], shl( excTmp2[k], sub( Q_excTmp2, *Q_bwe_exc ) ) ) ); // Q_excTmp2
+ move16();
// mem_csfilt_left = -csfilt_den2[1] * excNoisyEnvLeft[k];
mem_csfilt_left = mult_r( neg_csfilt_den2[1], excNoisyEnvLeft[k] ); // Q_excTmp2
// excNoisyEnvRight[L_FRAME16k - k - 1] = mem_csfilt_right + csfilt_num2[0] * excTmp2[L_FRAME16k - k - 1];
excNoisyEnvRight[L_FRAME16k - k - 1] = add( mem_csfilt_right, mult_r( csfilt_num2[0], shl( excTmp2[L_FRAME16k - k - 1], sub( Q_excTmp2, *Q_bwe_exc ) ) ) ); // Q_excTmp2
+ move16();
// mem_csfilt_right = -csfilt_den2[1] * excNoisyEnvRight[L_FRAME16k - k - 1];
mem_csfilt_right = mult_r( neg_csfilt_den2[1], excNoisyEnvRight[L_FRAME16k - k - 1] ); // Q_excTmp2
}
alpha = 0;
+ move16();
// step = 1.0f / L_FRAME16k;
step = 102; // Q15
+ move16();
FOR( k = 0; k < L_FRAME16k; k++ )
{
// excNoisyEnv[k] = alpha * excNoisyEnvLeft[k] + (1 - alpha) * excNoisyEnvRight[k];
- excNoisyEnv[k] = add( mult_r( alpha, excNoisyEnvLeft[k] ), mult_r( ( 32767 - alpha ), excNoisyEnvRight[k] ) ); // Q_excTmp2
+ excNoisyEnv[k] = add( mult_r( alpha, excNoisyEnvLeft[k] ), mult_r( sub( 32767, alpha ), excNoisyEnvRight[k] ) ); // Q_excTmp2
+ move16();
alpha = add( alpha, step );
}
}
@@ -2887,20 +3062,25 @@ void GenShapedSHBExcitation_ivas_fx(
move32();
}
#if 1 // def ADD_IVAS_TBE_CODE
- IF( extl_brate == SWB_TBE_1k10 || extl_brate == SWB_TBE_1k75 )
+ test();
+ IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) )
{
/* generate gaussian (white) excitation */
FOR( k = 0; k < L_FRAME16k; k++ )
{
White_exc16k[k] = own_random( &bwe_seed[0] );
+ move16();
}
/* normalize the amplitude of the gaussian excitation to that of the LB exc. */
Word32 pow22_inv = POW_EXC16k_WHTND_FX_INV_SQRT;
+ move32();
+ move32();
pow22 = POW_EXC16k_WHTND_FX;
Q_pow22 = -6;
+ move16();
// v_multc(White_exc16k, (float)sqrt(pow1 / pow22), White_exc16k, L_FRAME16k);
- Word16 pow1_exp = Q31 - Q_pow1;
+ Word16 pow1_exp = sub( Q31, Q_pow1 );
Word32 temp_pow = Sqrt32( pow1, &pow1_exp );
temp_pow = L_shl( Mpy_32_32( temp_pow, pow22_inv ), pow1_exp );
/*Word16 out_exp;
@@ -2908,16 +3088,20 @@ void GenShapedSHBExcitation_ivas_fx(
temp_pow1 = L_shl(temp_pow1, out_exp);*/
// v_multc_fixed_16_16(White_exc16k, round_fx(temp_pow), White_exc16k, L_FRAME16k);
L_tmp = 0;
+ move32();
FOR( k = 0; k < L_FRAME16k; k++ )
{
White_exc16k_32[k] = L_mult( White_exc16k[k], round_fx( temp_pow ) );
+ move32();
White_exc16k[k] = round_fx( L_shl( White_exc16k_32[k], *Q_bwe_exc - NOISE_QADJ ) ); // Q_bwe_exc - NOISE_QADJ
+ move16();
L_tmp = max( L_tmp, L_abs( White_exc16k_32[k] ) );
}
Q_temp = norm_l( L_tmp );
IF( L_tmp == 0 )
{
Q_temp = 31;
+ move16();
}
}
ELSE
@@ -2925,6 +3109,7 @@ void GenShapedSHBExcitation_ivas_fx(
{
/* create a random excitation - Reuse exc16k memory */
White_exc16k = exc16k;
+ move16();
create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed );
create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed );
@@ -2949,6 +3134,7 @@ void GenShapedSHBExcitation_ivas_fx(
IF( L_tmp == 0 )
{
Q_temp = 31;
+ move16();
}
/*Copy_Scale_sig( White_exc16k, White_exc16k, L_FRAME16k, sub(NOISE_QFAC, 5) );)*/
/* White_exc16k in Q6 */
@@ -3101,22 +3287,28 @@ void GenShapedSHBExcitation_ivas_fx(
( *Q_bwe_exc - NOISE_QADJ ), pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind );
tmp = voiceFacEst[0];
tmp2 = MAX_16;
+ move16();
+ move16();
if ( LE_16( tmp, 22938 /*0.7f Q15*/ ) )
{
tmp2 = 26214 /*0.8f Q15*/;
+ move16();
}
}
}
ELSE /* decoder side */
{
+ test();
#if 1 // def ADD_IVAS_TBE_CODE
- IF( extl_brate == SWB_TBE_1k10 || extl_brate == SWB_TBE_1k75 )
+ IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) )
{
IF( *vf_ind == 0 )
{
// mix_factor = 0.0f;
mix_factor = 0;
+ move16();
flag_plosive = 1;
+ move16();
}
ELSE
{
@@ -3130,9 +3322,11 @@ void GenShapedSHBExcitation_ivas_fx(
/* *vf_ind is an integer scale by 0.125f*/
tmp = shl( *vf_ind, ( 15 - 3 ) );
tmp2 = MAX_16;
+ move16();
IF( LE_16( tmp, 22938 /*0.7f Q15*/ ) )
{
tmp2 = 26214 /*0.8f Q15*/;
+ move16();
}
}
}
@@ -3153,7 +3347,7 @@ void GenShapedSHBExcitation_ivas_fx(
}
}
#if 1 // def ADD_IVAS_TBE_CODE
- IF( element_mode >= IVAS_CPE_DFT && nlExc16k != NULL )
+ IF( GE_16( element_mode, IVAS_CPE_DFT ) && nlExc16k != NULL )
{
/* save buffers for IC-BWE */
// mvr2r(exc16kWhtnd, nlExc16k, L_FRAME16k);
@@ -3168,6 +3362,7 @@ void GenShapedSHBExcitation_ivas_fx(
FOR( k = 0; k < L_FRAME16k; k++ )
{
mixExc16k[k] = mult_r( White_exc16k[k], temp_fac );
+ move16();
}
}
#endif
@@ -3178,13 +3373,15 @@ void GenShapedSHBExcitation_ivas_fx(
White_exc16k_FB[k] = round_fx( L_shl( White_exc16k_32[k], tmp ) ); /* Q_bwe_exc +5 +1 +Q_temp -16 -3 */
}
prev_Q_bwe_exc_fb = *Q_bwe_exc_fb;
+ move16();
*Q_bwe_exc_fb = sub( add( *Q_bwe_exc, Q_temp ), 13 );
-
+ move16();
deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph );
/* i/o: White_exc16k (Q_bwe_exc-NOISE_QADJ) */
/* i: tbe_demph (Q_bwe_exc-NOISE_QADJ) */
#if 1 // def ADD_IVAS_TBE_CODE
- IF( extl_brate == SWB_TBE_1k10 || extl_brate == SWB_TBE_1k75 )
+ test();
+ IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) )
{
IF( !flag_plosive ) /* use only LB excitation in case of plosives */
{
@@ -3198,17 +3395,20 @@ void GenShapedSHBExcitation_ivas_fx(
old_scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); // Q15
// new_scale = 1.0f;
new_scale = 32767;
+ move16();
// step_scale = (new_scale - old_scale) / (L_FRAME16k / 2);
step_scale = mult_r( sub( new_scale, old_scale ), 205 );
scale = old_scale;
-
+ move16();
/* interpolate between the old and the new value of the mixing factor */
old_fact = *prev_mix_factor;
+ move16();
new_fact = mix_factor;
+ move16();
// step = (new_fact - old_fact) / (L_FRAME16k / 2);
step = mult_r( sub( new_fact, old_fact ), 205 );
fact = old_fact;
-
+ move16();
/* mixing of LB and gaussian excitation in the first half of the frame */
FOR( k = 0; k < L_FRAME16k / 2; k++ )
{
@@ -3217,6 +3417,7 @@ void GenShapedSHBExcitation_ivas_fx(
L_tmp = L_add( L_shl( L_mult( fact, mult_r( White_exc16k[k], scale ) ), NOISE_QADJ ),
L_mult( sub( 32767, fact ), exc16kWhtnd[k] ) ); // Q_bwe_exc
exc16kWhtnd[k] = round_fx( L_tmp );
+ move16();
fact = add_sat( fact, step );
scale = add_sat( scale, step_scale );
}
@@ -3229,6 +3430,7 @@ void GenShapedSHBExcitation_ivas_fx(
L_tmp = L_add( L_shl( L_mult( new_fact, White_exc16k[k] ), NOISE_QADJ ),
mult_r( sub( 32767, new_fact ), exc16kWhtnd[k] ) ); // Q_bwe_exc
exc16kWhtnd[k] = round_fx( L_tmp );
+ move16();
}
}
// preemph(exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph);
@@ -3255,6 +3457,7 @@ void GenShapedSHBExcitation_ivas_fx(
L_tmp = L_mult( White_exc16k[k], scale );
/* L_tmp: (Q_bwe_exc-NOISE_QADJ) + 15 + 1 */
exc16kWhtnd[k] = round_fx( L_shl( L_tmp, NOISE_QADJ ) );
+ move16();
/* exc16kWhtnd: Q_bwe_exc */
}
preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph );
@@ -3269,6 +3472,8 @@ void GenShapedSHBExcitation_ivas_fx(
/*nbSubFr = ( bitrate < ACELP_24k40 )? NB_SUBFR : NB_SUBFR16k;*/
nbSubFr = NB_SUBFR16k;
lSubFr = ( L_FRAME16k / NB_SUBFR16k );
+ move16();
+ move16();
IF( LT_32( bitrate, ACELP_24k40 ) )
{
nbSubFr = NB_SUBFR;
@@ -3277,15 +3482,18 @@ void GenShapedSHBExcitation_ivas_fx(
move16();
}
k = 0;
+ move16();
FOR( i = 0; i < nbSubFr; i++ )
{
test();
IF( EQ_16( coder_type, VOICED ) && ( LT_32( bitrate, ACELP_24k40 ) ) )
{
exp = 0;
+ move16();
tempQ15 = Sqrt16( voice_factors[i], &exp ); /* Q15 */
temp = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */
exp = 0;
+ move16();
tempQ15 = Sqrt16( temp, &exp ); /* Q15 */
temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */
@@ -3308,6 +3516,7 @@ void GenShapedSHBExcitation_ivas_fx(
vf_tmp = mult_r( voice_factors[i], vf_tmp );
exp = 0;
+ move16();
tempQ15 = Sqrt16( vf_tmp, &exp ); /* Q15 */
temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */
@@ -3341,6 +3550,7 @@ void GenShapedSHBExcitation_ivas_fx(
/* estimate the pre-emph factor */
tempQ15 = sub( MAX_16, voice_factors[i] );
exp = 0;
+ move16();
temp = Sqrt16( tempQ15, &exp );
temp = shl( temp, exp - 1 );
@@ -3410,6 +3620,7 @@ void GenShapedSHBExcitation_ivas_fx(
{
L_tmp3 = Mult_32_16( L_tmp2, exc16kWhtnd[i] ); /* *Q_bwe_exc + (31-exp) - 15 */
exc16kWhtnd[i] = round_fx( L_tmp3 ); /* *Q_bwe_exc - exp */
+ move16();
}
}
/* i: L_tmp2 in (Q31-exp) */
@@ -3632,6 +3843,7 @@ void ScaleShapedSHB_fx(
move16();
sum_gain = 0;
+ move16();
FOR( k = 0; k < length / 2; k++ )
{
sum_gain = mult_r( subwin[2 * k + 2], subgain[0] ); /* Q15 */
@@ -3719,7 +3931,10 @@ void ScaleShapedSHB_fx(
Q_gFr_norm = norm_l( frame_gain );
if ( frame_gain == 0 )
+ {
Q_gFr_norm = 31;
+ move16();
+ }
Q_gFr_norm = sub( Q_gFr_norm, 1 ); /* give some headroom */
gain_frame_Q16 = round_fx( L_shl( frame_gain, Q_gFr_norm ) ); /* Q = 18 + Q_gFr_norm - 16
@@ -3737,14 +3952,16 @@ void ScaleShapedSHB_fx(
}
*Qx = *Q_bwe_exc;
-
+ move16();
/* rescale the overlap memory */
FOR( i = 0; i < L_SHB_LAHEAD; i++ )
{
temp2 = 1;
+ move16();
if ( overlap[i] < 0 )
{
temp2 = -1;
+ move16();
}
temp1 = abs_s( overlap[i] );
temp1 = shl( temp1, ( *Q_bwe_exc - prev_Q_bwe_syn2 ) );
@@ -3759,12 +3976,14 @@ void ScaleShapedSHB_fx(
synSHB[i] = mac_r( L_tmp2, overlap[i], MAX_16 );
move16(); /* Q_bwe_exc + Q_gFr_norm - 13 */
synSHB[i + l_shb_lahead] = round_fx( L_tmp ); /* Q_bwe_exc + Q_gFr_norm - 13 */
+ move16();
}
FOR( ; i < l_frame; i++ )
{
L_tmp = Mult_32_16( mod_syn[i], gain_frame_Q16 ); /* Q_bwe_exc + 16 + Q_gFr_norm + 2 - 15 */
synSHB[i] = round_fx( L_tmp ); /* Q_bwe_exc + Q_gFr_norm - 13 */
+ move16();
}
l_frame_tmp = add( l_frame, l_shb_lahead );
@@ -3936,6 +4155,7 @@ void ScaleShapedWB_fx(
{
shift = sub( 13, Q_bwe_exc ); /* earlier = (10 - Q_bwe_exc) but we changed GainFrame Q21 to Q18 */
*Qx = 0;
+ move16();
}
ELSE IF( EQ_16( L_frame, L_FRAME ) ) /* 12.8k core */
{
@@ -3951,6 +4171,7 @@ void ScaleShapedWB_fx(
shift = s_min( min_shift, max_shift2 );
*Qx = ( Q_bwe_exc + 3 ) + shift - 16;
+ move16();
}
ELSE /* 16k core */
{
@@ -3959,17 +4180,21 @@ void ScaleShapedWB_fx(
/* Qx = (Q_bwe_exc+3) + shift - 16 */
/* make sure 14 > Qx > 3 */
min_shift = 3 - ( Q_bwe_exc + 3 - 16 );
+ move16();
max_shift = 13 - ( Q_bwe_exc + 3 - 16 );
+ move16();
max_shift2 = s_min( max_shift, max_headroom ); /* avoid shifting more than the available max_val headroom to avoid overflow */
shift = s_min( min_shift, max_shift2 );
*Qx = ( Q_bwe_exc + 3 ) + shift - 16;
+ move16();
}
/* bring memory st_fx->syn_overlap_fx[] = overlap[i] to new Q = Qx to prepare for addition */
FOR( i = 0; i < l_shb_lahead; i++ )
{
overlap[i] = shl( overlap[i], ( *Qx - prev_Qx ) );
+ move16();
}
FOR( i = 0; i < l_shb_lahead; i++ )
@@ -3978,6 +4203,7 @@ void ScaleShapedWB_fx(
L_tmp = Mult_32_32( mod_syn[i], frame_gain ); /* L_tmp in (Q_bwe_exc+3) */
#ifdef BASOP_NOGLOB
synSHB[i] = round_fx_sat( L_shl_sat( Mult_32_16( L_tmp, win[i] ), shift ) ); /* Qx */
+ move16();
synSHB[i] = add_sat( synSHB[i], overlap[i] );
move16(); /* Qx */
synSHB[i + l_shb_lahead] = round_fx_sat( L_shl_sat( L_tmp, shift ) ); /* Qx */
@@ -3997,6 +4223,7 @@ void ScaleShapedWB_fx(
#else
synSHB[i] = round_fx( L_shl( L_tmp, shift ) ); /* Qx; */
#endif
+ move16();
}
l_frame_tmp = add( l_frame, l_shb_lahead );
@@ -4008,6 +4235,7 @@ void ScaleShapedWB_fx(
#else
overlap[i - l_frame] = round_fx( L_shl( Mult_32_16( L_tmp, win[l_frame + l_shb_lahead - 1 - i] ), shift ) ); /* Qx */
#endif
+ move16();
}
return;
@@ -4268,6 +4496,7 @@ void non_linearity_fx(
Word16 length_half;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -4807,6 +5036,7 @@ void create_random_vector_fx(
j = s_and( j, 0xff );
k = s_and( k, 0xff );
output[i] = round_fx( L_add( L_mult( scale1, gaus_dico_swb_fx[j] ), L_mult( scale2, gaus_dico_swb_fx[k] ) ) ); /*Q5 */
+ move16();
j++;
k++;
}
@@ -4848,19 +5078,29 @@ void interp_code_5over2_fx(
Word16 i, kk, kkp1, i_len2;
Word32 Ltemp;
Word16 factor_i_fx[5] = { 6554, 19661, 32767, 19661, 6554 };
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
Word16 factor_j_fx[5] = { 26214, 13107, 0, 13107, 26214 };
-
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
interp_code_fx[0] = inp_code_fx[0];
move16(); /* Qx */
Ltemp = L_mult( inp_code_fx[0], factor_i_fx[3] ); /* Q(16+x) */
Ltemp = L_mac( Ltemp, inp_code_fx[1], factor_j_fx[3] ); /* Q(16+x) */
interp_code_fx[1] = round_fx( Ltemp ); /*Qx */
-
+ move16();
Ltemp = L_mult( inp_code_fx[0], factor_i_fx[4] ); /*Q(16+x) */
Ltemp = L_mac( Ltemp, inp_code_fx[1], factor_j_fx[4] ); /*Q(16+x) */
interp_code_fx[2] = round_fx( Ltemp ); /* Qx */
-
+ move16();
kk = 1;
move16();
kkp1 = 2;
@@ -4876,35 +5116,35 @@ void interp_code_5over2_fx(
Ltemp = L_mult( inp_code_fx[kk], factor_j_fx[0] ); /*Q(16+x) */
Ltemp = L_mac( Ltemp, inp_code_fx[kkp1], factor_i_fx[0] ); /*Q(16+x) */
interp_code_fx[i] = round_fx( Ltemp ); /*Qx */
-
+ move16();
Ltemp = L_mult( inp_code_fx[kk], factor_j_fx[1] ); /*Q(16+x) */
Ltemp = L_mac( Ltemp, inp_code_fx[kkp1], factor_i_fx[1] ); /*Q(16+x) */
interp_code_fx[i + 1] = round_fx( Ltemp ); /*Qx */
-
+ move16();
Ltemp = L_mult( inp_code_fx[kkp1], factor_i_fx[2] ); /*Q(16+x) */
interp_code_fx[i + 2] = round_fx( Ltemp ); /*Qx */
-
+ move16();
kk++;
kkp1++;
Ltemp = L_mult( inp_code_fx[kk], factor_i_fx[3] ); /*Q(16+x) */
Ltemp = L_mac( Ltemp, inp_code_fx[kkp1], factor_j_fx[3] ); /*Q(16+x) */
interp_code_fx[i + 3] = round_fx( Ltemp ); /*Qx */
-
+ move16();
Ltemp = L_mult( inp_code_fx[kk], factor_i_fx[4] ); /*Q(16+x) */
Ltemp = L_mac( Ltemp, inp_code_fx[kkp1], factor_j_fx[4] ); /*Q(16+x) */
interp_code_fx[i + 4] = round_fx( Ltemp ); /*Qx */
-
+ move16();
kk++;
kkp1++;
}
Ltemp = L_mult( inp_code_fx[kk], factor_j_fx[0] ); /*Q(16+x) */
interp_code_fx[i] = round_fx( Ltemp ); /*Qx */
-
+ move16();
Ltemp = L_mult( inp_code_fx[kk], factor_j_fx[1] ); /*Q(16+x) */
interp_code_fx[i + 1] = round_fx( Ltemp ); /*Qx */
-
+ move16();
return;
}
@@ -5010,6 +5250,11 @@ void elliptic_bpf_48k_generic_fx(
memory2_fx[1][i] = L_shl_sat( memory_fx2[1][i], sub( add( *Q_input_fx, 11 ), memory_fx_Q[1] ) );
memory2_fx[2][i] = L_shl_sat( memory_fx2[2][i], sub( add( *Q_input_fx, 6 ), memory_fx_Q[2] ) );
memory2_fx[3][i] = L_shl_sat( memory_fx2[3][i], sub( add( *Q_input_fx, 1 ), memory_fx_Q[3] ) );
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
#else
memory_fx[0][i] = shl( memory_fx0[0][i], sub( *Q_input_fx, memory_fx_Q[0] ) );
memory2_fx[1][i] = L_shl( memory_fx2[1][i], sub( add( *Q_input_fx, 11 ), memory_fx_Q[1] ) );
@@ -5123,7 +5368,11 @@ void elliptic_bpf_48k_generic_fx(
memory_fx2[0][1] = input_fx[sub( L_FRAME48k, 3 )];
memory_fx2[0][2] = input_fx[sub( L_FRAME48k, 2 )];
memory_fx2[0][3] = input_fx[sub( L_FRAME48k, 1 )];
-
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
L_tmpX = L_shr( Mult_32_16( memory2_fx[1][0], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/
L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/
L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/
@@ -5240,7 +5489,11 @@ void elliptic_bpf_48k_generic_fx(
memory_fx2[1][1] = L_tmp[sub( L_FRAME48k, 3 )];
memory_fx2[1][2] = L_tmp[sub( L_FRAME48k, 2 )];
memory_fx2[1][3] = L_tmp[sub( L_FRAME48k, 1 )];
-
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
FOR( j = 0; j < 4; j++ )
{
#ifdef BASOP_NOGLOB
@@ -5250,6 +5503,9 @@ void elliptic_bpf_48k_generic_fx(
memory2_fx_2[j] = L_shl( memory_fx2[2][j], sub( add( add( *Q_input_fx, 6 ), Q_temp ), memory_fx_Q[2] ) );
memory2_fx_3[j] = L_shl( memory_fx2[3][j], sub( add( add( *Q_input_fx, 1 ), Q_temp ), memory_fx_Q[3] ) );
#endif
+ move32();
+ move32();
+ move32();
}
#ifdef BASOP_NOGLOB
L_tmpX = L_shr( Mult_32_16( memory2_fx_2[0], full_band_bpf_fx[2][4] ), 3 ); /* *Q_input_fx+6 +Q_temp +13 -15 -3 */
@@ -5392,19 +5648,32 @@ void elliptic_bpf_48k_generic_fx(
memory_fx2[3][1] = L_output[sub( L_FRAME48k, 3 )];
memory_fx2[3][2] = L_output[sub( L_FRAME48k, 2 )];
memory_fx2[3][3] = L_output[sub( L_FRAME48k, 1 )];
-
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
memory_fx_Q[0] = *Q_input_fx;
memory_fx_Q[1] = add( *Q_input_fx, 11 );
memory_fx_Q[2] = add( add( *Q_input_fx, 6 ), Q_temp );
memory_fx_Q[3] = add( add( *Q_input_fx, 1 ), Q_temp );
-
+ move16();
+ move16();
+ move16();
+ move16();
Q_temp2 = norm_l( L_tmpMax );
Scale_sig32( L_output, 960, Q_temp2 );
FOR( i = 0; i < 960; i++ )
{
output_fx[i] = extract_h( L_output[i] );
+ move16();
}
*Q_input_fx = sub( add( add( *Q_input_fx, Q_temp ), Q_temp2 ), 15 );
+ move16(); /* BASOP_NOGLOB */
return;
}
@@ -5518,6 +5787,7 @@ void synthesise_fb_high_band_fx(
{
#ifdef BASOP_NOGLOB
output[i] = negate( extract_h( L_shl_sat( L_negate( L_tmp ), tmp3 ) ) ); /*Qout*/
+ move16();
#else
output[i] = negate( extract_h( L_shl( L_negate( L_tmp ), tmp3 ) ) ); /*Qout*/
#endif
@@ -5526,6 +5796,7 @@ void synthesise_fb_high_band_fx(
{
#ifdef BASOP_NOGLOB
output[i] = extract_h( L_shl_sat( L_tmp, tmp3 ) ); /*Qout*/
+ move16();
#else
output[i] = extract_h( L_shl( L_tmp, tmp3 ) ); /*Qout*/
#endif
@@ -5563,6 +5834,7 @@ void Estimate_mix_factors_fx(
Word32 L_tmp1, L_tmp2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
Copy( shb_res, shb_res_local, L_FRAME16k );
@@ -5575,6 +5847,7 @@ void Estimate_mix_factors_fx(
if ( pow3 == 0 )
{
pow3 = 1;
+ move32();
}
/* temp_p1_p2 = (float)sqrt(pow1/pow2); */
@@ -5586,21 +5859,23 @@ void Estimate_mix_factors_fx(
sc1 = Q_bwe_exc - ( Q_frac - exp1 );
sc2 = Q_bwe_exc - ( Q_shb - exp2 );
-
+ move16();
+ move16();
FOR( i = 0; i < L_FRAME16k; i++ )
{
L_tmp1 = Mult_32_16( temp_p1_p2, WN_exc_local[i] ); /* (Q_frac - exp1) +16 */
WN_exc_local[i] = round_fx( L_tmp1 );
-
+ move16();
L_tmp2 = Mult_32_16( temp_p1_p3, shb_res_local[i] ); /* (Q_shb - exp2) +16 */
shb_res_local[i] = round_fx( L_tmp2 );
-
+ move16();
/* temp_numer1[i] = sub(shb_res_local[i], WN_exc_local[i]); */
#ifdef BASOP_NOGLOB
temp_numer1[i] = round_fx_sat( L_sub_sat( L_shl_sat( L_tmp2, sc2 ), L_shl_sat( L_tmp1, sc1 ) ) );
#else
temp_numer1[i] = round_fx( L_sub( L_shl( L_tmp2, sc2 ), L_shl( L_tmp1, sc1 ) ) );
#endif
+ move16();
/* (Q_bwe_exc) */
/* temp_numer2[i] = sub(exc16kWhtnd[i], WN_exc_local[i]); */
@@ -5672,6 +5947,7 @@ void Estimate_mix_factors_fx(
ELSE
{
tmp = 0;
+ move16();
}
vf_modified[0] = s_min( s_max( tmp, 3277 /* 0.1f in Q15*/ ), 32440 /* 0.99f in Q15 */ );
@@ -5805,6 +6081,7 @@ void prep_tbe_exc_fx(
Word16 tmp_code_fx[2 * L_SUBFR * HIBND_ACB_L_FAC];
Word16 tmp_code_preInt_fx[L_SUBFR];
Word16 gain_code16 = 0;
+ move16();
Word16 tmp /*, tmp1, tmp2*/;
/*Word16 random_code[L_SUBFR * HIBND_ACB_L_FAC];*/
Word16 pitch;
@@ -5814,9 +6091,11 @@ void prep_tbe_exc_fx(
Word16 tempQ15;
#ifndef ADD_IVAS_TBE_CODE
Word16 L_subfr = L_SUBFR;
+ move16();
#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/**voice_factors = VF_0th_PARAM + VF_1st_PARAM * voice_fac + VF_2nd_PARAM * voice_fac * voice_fac;
@@ -5826,7 +6105,7 @@ void prep_tbe_exc_fx(
tempQ15 = mac_r( tempQ31, VF_2nd_PARAM_FX, voice_fac_fx );
tempQ31 = L_deposit_h( VF_0th_PARAM_FX );
*voice_factors_fx = mac_r( tempQ31, voice_fac_fx, tempQ15 );
-
+ move16();
tmp = 32767;
move16();
@@ -5843,6 +6122,7 @@ void prep_tbe_exc_fx(
tmp = MAX_16;
move16();
*voice_factors_fx = mult_r( *voice_factors_fx, tmp );
+ move16();
}
*voice_factors_fx = s_min( s_max( *voice_factors_fx, 0 ), MAX_16 );
@@ -5883,6 +6163,7 @@ void prep_tbe_exc_fx(
L_tmp = L_shl( L_tmp, 1 ); /*16+Q_exc */ /* saturation can occur here */
bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx( L_tmp ); /*Q_exc */
#endif /* BASOP_NOGLOB */
+ move16();
}
}
ELSE
@@ -6041,6 +6322,7 @@ void prep_tbe_exc_ivas_fx(
tmp = MAX_16;
move16();
*voice_factors_fx = mult_r( *voice_factors_fx, tmp );
+ move16();
}
*voice_factors_fx = s_min( s_max( *voice_factors_fx, 0 ), MAX_16 );
@@ -6076,6 +6358,7 @@ void prep_tbe_exc_ivas_fx(
L_tmp = L_shl( L_tmp, 1 ); /*16+Q_exc */ /* saturation can occur here */
bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx( L_tmp ); /*Q_exc */
#endif /* BASOP_NOGLOB */
+ move16();
}
}
ELSE
@@ -6089,8 +6372,8 @@ void prep_tbe_exc_ivas_fx(
Ltemp2 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /*Q2 * Q10 -> Q12 */
#ifdef BASOP_NOGLOB
- Ltemp1 = L_shl_o( Ltemp1, Q_exc + 6 /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */
- Ltemp2 = L_shl_o( Ltemp2, Q_exc + 4 /*Q_exc+16-13*/, &Overflow ); /*Q_exc+16 */
+ Ltemp1 = L_shl_o( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */
+ Ltemp2 = L_shl_o( Ltemp2, add( Q_exc, 4 ) /*Q_exc+16-13*/, &Overflow ); /*Q_exc+16 */
tmp_code_preInt_fx[i] = round_fx_o( L_add_o( Ltemp1, Ltemp2, &Overflow ), &Overflow ); /* Q_exc */
#else /* BASOP_NOGLOB */
@@ -6099,6 +6382,7 @@ void prep_tbe_exc_ivas_fx(
tmp_code_preInt_fx[i] = round_fx( L_add( Ltemp1, Ltemp2 ) ); /* Q_exc */
#endif /* BASOP_NOGLOB */
+ move16();
}
}
ELSE
@@ -6108,22 +6392,23 @@ void prep_tbe_exc_ivas_fx(
/*code in the encoder is Q9 and there is no <<1 with Mult_32_16 Q16 * Q9 -> Q9 */
Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] ); /* Q16 + Q9 + 1 - 16 = Q10 */
#ifdef BASOP_NOGLOB
- Ltemp1 = L_shl_o( Ltemp1, Q_exc + 6 /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */
- tmp_code_preInt_fx[i] = round_fx_o( Ltemp1, &Overflow ); /* Q_exc */
+ Ltemp1 = L_shl_o( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */
+ tmp_code_preInt_fx[i] = round_fx_o( Ltemp1, &Overflow ); /* Q_exc */
#else
Ltemp1 = L_shl( Ltemp1, Q_exc + 6 /*Q_exc+16-19*/ ); /*Q_exc+16 */
tmp_code_preInt_fx[i] = round_fx( Ltemp1 ); /* Q_exc */
#endif
+ move16();
}
}
interp_code_4over2_fx( tmp_code_preInt_fx, tmp_code_fx, L_subfr ); /* o: tmp_code in Q_exc */
- FOR( i = 0; i < L_subfr * 2; i++ )
+ FOR( i = 0; i < shl( L_subfr, 1 ); i++ )
{
- L_tmp = L_mult( gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * 2] ); /*Q14+Q_exc+1 */
+ L_tmp = L_mult( gain_pit_fx, bwe_exc_fx[i + shl( i_subfr_fx, 1 )] ); /*Q14+Q_exc+1 */
#ifdef BASOP_NOGLOB
tmp = round_fx_o( L_shl_o( L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/, &Overflow ), &Overflow ); /* tmp in Q_exc */
- bwe_exc_fx[i + i_subfr_fx * 2] = add_o( tmp, tmp_code_fx[i], &Overflow ); /*Q_exc */
+ bwe_exc_fx[i + shl( i_subfr_fx, 1 )] = add_o( tmp, tmp_code_fx[i], &Overflow ); /*Q_exc */
move16();
#else /* BASOP_NOGLOB */
tmp = round_fx( L_shl( L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/ ) ); /* tmp in Q_exc */
diff --git a/lib_com/syn_12k8_fx.c b/lib_com/syn_12k8_fx.c
index f990b0bc9618a3cebb7848d2c388d177d30e720d..86d4c6ef76bbc06a53d7f2bee16af0a546b985ea 100644
--- a/lib_com/syn_12k8_fx.c
+++ b/lib_com/syn_12k8_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
/*===========================================================================*/
diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c
index 5b7fcc4c3a1e6f3d43b487228a71392626efb6dd..e3a3024ba5cdfb351995551dfd5b5baf2e3a3d5f 100644
--- a/lib_com/syn_filt_fx.c
+++ b/lib_com/syn_filt_fx.c
@@ -6,8 +6,7 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "stl.h"
static Word32 syn_kern_2( Word32 L_tmp, const Word16 a[], const Word16 y[] )
@@ -150,6 +149,7 @@ void syn_filt_s_lc_fx(
L_tmp = L_shl( L_tmp, q );
*y++ = round_fx( L_tmp );
#endif
+ move16();
}
FOR( ; i < lg; i++ )
@@ -162,6 +162,7 @@ void syn_filt_s_lc_fx(
L_tmp = L_shl( L_tmp, q );
*y++ = round_fx( L_tmp );
#endif
+ move16();
}
}
@@ -213,6 +214,7 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W
Word32 ( *syn_kern )( Word32 L_tmp, const Word16 a[], const Word16 y[] ) = NULL;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
if ( EQ_16( m, 6 ) )
@@ -257,6 +259,7 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W
L_tmp = L_shl( L_tmp, q );
*y++ = round_fx( L_tmp );
#endif
+ move16();
/* Filtering from Input + Mix of Memory & Output Signal Past */
FOR( i = 1; i < m; i++ )
@@ -287,6 +290,7 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W
L_tmp = L_shl( L_tmp, q );
*y++ = round_fx( L_tmp );
#endif
+ move16();
}
/* Filtering from Input + Output Signal Past */
@@ -300,6 +304,7 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W
L_tmp = L_shl( L_tmp, q );
*y++ = round_fx( L_tmp );
#endif
+ move16();
}
/*-----------------------------------------------------------------------*
@@ -378,6 +383,7 @@ void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[]
}
L_tmp = L_shl_o( L_tmp, q, &Overflow );
*y++ = L_tmp;
+ move32();
}
/* Filtering from Input + Output Signal Past */
@@ -386,6 +392,7 @@ void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[]
L_tmp = syn_kern( Mpy_32_32( a0, *x++ ), a, y );
L_tmp = L_shl_o( L_tmp, q, &Overflow );
*y++ = L_tmp;
+ move32();
}
/*-----------------------------------------------------------------------*
@@ -452,12 +459,12 @@ void ivas_synth_mem_updt2_fx(
}
ELSE
{
- en1_e = 30 - 2 * Q;
- en2_e = 30 - 2 * Q;
+ en1_e = sub( 30, shl( Q, 1 ) );
+ en2_e = sub( 30, shl( Q, 1 ) );
tmp1 = Sqrt32( en1, &en1_e );
tmp2 = Sqrt32( en2, &en2_e );
tmp = BASOP_Util_Divide3232_Scale( tmp1, tmp2, &tmp_e );
- loc_rat_e = en1_e - en2_e + tmp_e;
+ loc_rat_e = add( sub( en1_e, en2_e ), tmp_e );
loc_rat = shl_sat( tmp, loc_rat_e ); // Q15
}
@@ -466,6 +473,7 @@ void ivas_synth_mem_updt2_fx(
{
// mem_syn_r[L_SYN_MEM - M + i] *= loc_rat;
mem_syn_r[L_SYN_MEM - M + i] = mult_r( mem_syn_r[L_SYN_MEM - M + i], loc_rat );
+ move16();
}
}
}
diff --git a/lib_com/tcq_position_arith.c b/lib_com/tcq_position_arith.c
index 4c9764face91a612527b5411a78e8a49f0b0fd1b..4368c569feb246a830b28400a4a4a19ede102dae 100644
--- a/lib_com/tcq_position_arith.c
+++ b/lib_com/tcq_position_arith.c
@@ -61,9 +61,10 @@ static void set16_fx(
{
Word16 i;
- for ( i = 0; i < N; i++ )
+ FOR( i = 0; i < N; i++ )
{
y[i] = a;
+ move16();
}
return;
@@ -76,9 +77,10 @@ static void set32_fx(
)
{
Word16 i;
- for ( i = 0; i < N; i++ )
+ FOR( i = 0; i < N; i++ )
{
y[i] = a;
+ move16();
}
return;
@@ -97,15 +99,15 @@ Word32 ar_div_ivas(
num = L_abs( num );
denum = L_abs( denum );
- if ( L_sub( num, denum ) < 0 || denum == 0 )
+ IF( L_sub( num, denum ) < 0 || denum == 0 )
{
return 0;
}
- else if ( L_sub( num, denum ) == 0 )
+ ELSE IF( L_sub( num, denum ) == 0 )
{
return 1;
}
- else
+ ELSE
{
exp1 = norm_l( num );
exp2 = norm_l( denum );
@@ -113,16 +115,17 @@ Word32 ar_div_ivas(
denum = L_shl( denum, exp );
exp = add( exp, 1 );
varout = 0;
- for ( i = 0; i < exp; i++ )
+ move32();
+ FOR( i = 0; i < exp; i++ )
{
num = L_sub( num, denum );
varout = L_shl( varout, 1 );
- if ( num >= 0 )
+ IF( num >= 0 )
{
num = L_shl( num, 1 );
varout = L_add( varout, 1 );
}
- else
+ ELSE
{
num = L_add( num, denum );
num = L_shl( num, 1 );
@@ -149,30 +152,35 @@ void srt_vec_ind_fx_ivas(
Word32 valMem;
/*initialize */
- for ( pos = 0; pos < length; pos++ )
+ FOR( pos = 0; pos < length; pos++ )
{
I[pos] = pos;
+ move16();
}
- for ( pos = 0; pos < length; pos++ )
+ FOR( pos = 0; pos < length; pos++ )
{
srt[pos] = linear[pos];
+ move32();
}
/* now iterate */
- for ( pos = 0; pos < ( length - 1 ); pos++ )
+ FOR( pos = 0; pos < sub( length, 1 ); pos++ )
{
- for ( npos = ( pos + 1 ); npos < length; npos++ )
+ FOR( npos = add( pos, 1 ); npos < length; npos++ )
{
if ( L_sub( srt[npos], srt[pos] ) < 0 )
{
idxMem = I[pos];
I[pos] = I[npos];
I[npos] = idxMem;
-
+ move16();
+ move16();
valMem = srt[pos];
srt[pos] = srt[npos];
srt[npos] = valMem;
+ move32();
+ move32();
}
}
}
@@ -189,14 +197,15 @@ static Word32 GetBitsFromPulses_fx(
Word32 frac_fx32;
Word32 logCoeff_fx;
Word16 exp = 0;
+ move16();
Word32 mantissa_fx = 0;
-
- if ( m == 0 )
+ move32();
+ IF( m == 0 )
{
return 0;
}
- for ( i = 0; i < min( m, n ); i++ )
+ FOR( i = 0; i < min( m, n ); i++ )
{
logCoeff_fx = L_add( L_shl( i + 1, 16 ), L_sub( table_logcum_fx[n + 1], L_add( table_logcum_fx[i + 2], table_logcum_fx[n - i] ) ) );
logCoeff_fx = L_add( logCoeff_fx, L_sub( table_logcum_fx[m], L_add( table_logcum_fx[i + 1], table_logcum_fx[m - i] ) ) ); /*Q16 */
@@ -220,22 +229,23 @@ static Word32 GetBitsFromPulses_fx(
exp1 = norm_l( pow_getbitsfrompulses_fx[temp_fx1] );
exp2 = norm_l( frac_fx32 );
frac_fx32 = Mult_32_32( L_shl( pow_getbitsfrompulses_fx[temp_fx1], exp1 ), L_shl( frac_fx32, exp2 ) ); /*21 + exp1 + 30 + exp2 - 31 */
- frac_fx32 = L_shr( frac_fx32, exp1 + exp2 ) + 1; /*20 */
+ frac_fx32 = L_add( L_shr( frac_fx32, add( exp1, exp2 ) ), 1 ); /*20 */
- if ( sub( exp, integer_fx ) < 0 )
+ IF( sub( exp, integer_fx ) < 0 )
{
mantissa_fx = L_shr( mantissa_fx, sub( integer_fx, exp ) );
mantissa_fx = L_add( mantissa_fx, frac_fx32 );
exp = integer_fx;
+ move16();
}
- else
+ ELSE
{
mantissa_fx = L_add( mantissa_fx, L_shr( frac_fx32, sub( exp, integer_fx ) ) );
}
if ( L_sub( mantissa_fx, 0x200000 ) >= 0 )
{
- exp++;
+ exp = add( exp, 1 );
mantissa_fx = L_shr( mantissa_fx, 1 );
}
@@ -246,14 +256,14 @@ static Word32 GetBitsFromPulses_fx(
temp32 = L_shl( L_sub( mantissa_fx, L_deposit_h( temp_fx1 ) ), 15 ); /*31 */
exp1 = sub( norm_l( temp32 ), 1 );
temp32 = ar_div_ivas( L_shl( temp32, exp1 ), temp_fx1 ); /*31 + exp1 */
- temp32 = L_shr( temp32, exp1 + 1 ); /*30 */
+ temp32 = L_shr( temp32, add( exp1, 1 ) ); /*30 */
frac_fx32 = L_sub( 0x40000000, L_shr( temp32, 1 ) ); /*30 */
frac_fx32 = Mult_32_32( frac_fx32, temp32 ); /*29 */
frac_fx32 = L_shr( frac_fx32, 13 ); /*16 */
exp1 = norm_l( temp_fx1 );
- temp_fx1 = Log2_norm_lc( L_shl( temp_fx1, exp1 ) ); /*15 */
- frac_fx32 = frac_fx32 + Mult_32_32( frac_fx32, 950680361 ); /* frac_fx32 *= 1/ln(2) */
+ temp_fx1 = Log2_norm_lc( L_shl( temp_fx1, exp1 ) ); /*15 */
+ frac_fx32 = L_add( frac_fx32, Mult_32_32( frac_fx32, 950680361 ) ); /* frac_fx32 *= 1/ln(2) */
return L_add( L_deposit_h( exp ), L_add( L_shl( temp_fx1, 1 ), frac_fx32 ) );
}
@@ -273,138 +283,159 @@ void decode_position_ari_fx_ivas(
Word32 cp, scp, fxone, fxp1;
Word16 stpos = 0, pos, ovrflag, temppos, storepos;
-
+ move16();
fxone = 32768;
fxp1 = 512 * 32768;
+ move32();
+ move32();
temppos = 0;
storepos = 0;
ovrflag = 0;
-
+ move16();
+ move16();
+ move16();
set16_fx( mode_num_nz, 0, TCQ_MAX_BAND_SIZE );
set16_fx( prob, 0, TCQ_MAX_BAND_SIZE );
- for ( i = 0; i < size; i++ )
+ FOR( i = 0; i < size; i++ )
{
position[i] = 0;
+ move32();
}
- if ( L_sub( npulses, 1 ) > 0 )
+ IF( L_sub( npulses, 1 ) > 0 )
{
btcq_fx = GetBitsFromPulses_fx( npulses, size );
- for ( i = 0; i < L_min( npulses, size ); i++ )
+ FOR( i = 0; i < L_min( npulses, size ); i++ )
{
/*calculate the probability of #nz */
pnzp_fx = L_sub( L_deposit_h( add( i, 1 ) ), btcq_fx );
pnzp_fx = L_add( pnzp_fx, L_add( L_sub( table_logcum_fx[size + 1], L_add( table_logcum_fx[i + 2], table_logcum_fx[size - i] ) ), L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[i + 1], table_logcum_fx[npulses - i] ) ) ) );
pnzp_fx = L_add( pnzp_fx, 917498 ); /*16 */
- if ( L_sub( pnzp_fx, 0 ) > 0 )
+ IF( L_sub( pnzp_fx, 0 ) > 0 )
{
integer = extract_h( pnzp_fx );
frac = extract_l( L_shr( L_sub( pnzp_fx, L_deposit_h( integer ) ), 1 ) ); /*15 */
prob[i] = extract_h( L_shl( Pow2( integer, frac ), 16 ) ); /*0 */
+ move16();
if ( prob[i] == 0 )
{
prob[i] = 1;
+ move16();
}
}
- else
+ ELSE
{
prob[i] = 1;
+ move16();
}
}
ar_make_model( prob, mode_num_nz, min( npulses, size ) );
*nz = add( 1, (Word16) ar_decode( pardec, mode_num_nz ) ); /*get #nz */
nzp = *nz;
-
- if ( nzp == 1 )
+ move16();
+ move16();
+ IF( EQ_16( nzp, 1 ) )
{
Word16 tmp;
mode_num_nz[0] = MAX_AR_FREQ;
- for ( i = 0; i < size; i++ )
+ FOR( i = 0; i < size; i++ )
{
- tmp = div_l( L_deposit_h( size - i - 1 ), size );
+ tmp = div_l( L_deposit_h( sub( sub( size, i ), 1 ) ), size );
mode_num_nz[i + 1] = round_fx( L_shr( L_deposit_h( tmp ), 1 ) );
}
position[ar_decode( pardec, mode_num_nz )] = 1;
+ move32();
}
- else
+ ELSE
{
Word16 tmp;
mode_num_nz[0] = MAX_AR_FREQ;
-
- for ( ; nzp > 0; nzp-- )
+ move16();
+ FOR( ; nzp > 0; nzp-- )
{
scp = fxp1;
+ move32();
temppos = 0;
storepos = 0;
-
- for ( i = stpos; i < size; i++ )
+ move16();
+ move16();
+ FOR( i = stpos; i < size; i++ )
{
ovrflag = 0;
-
- if ( nzp == ( size - i ) )
+ move16();
+ IF( EQ_16( nzp, sub( size, i ) ) )
{
cp = 0;
+ move32();
}
- else
+ ELSE
{
tmp = div_l( L_deposit_h( nzp ), ( size - i ) );
cp = L_sub( fxone, tmp );
}
scp = Mult_32_16( scp, extract_l( cp ) );
- mode_num_nz[i + 1 - storepos - stpos] = round_fx( L_shl( scp, 6 ) );
+ mode_num_nz[sub( sub( add( i, 1 ), storepos ), stpos )] = round_fx( L_shl( scp, 6 ) );
- if ( ( mode_num_nz[i + 1 - storepos - stpos] == 0 && scp > 0 ) || mode_num_nz[i - storepos - stpos] == mode_num_nz[i + 1 - storepos - stpos] )
+ IF( ( mode_num_nz[sub( sub( add( i, 1 ), storepos ), stpos )] == 0 && scp > 0 ) || EQ_16( mode_num_nz[sub( sub( i, storepos ), stpos )], mode_num_nz[sub( sub( add( i, 1 ), storepos ), stpos )] ) )
{
ovrflag = 1;
+ move16();
temppos = (Word16) ar_decode( pardec, mode_num_nz );
- storepos += temppos;
+ storepos = add( storepos, temppos );
scp = fxp1;
-
- if ( temppos == i - stpos ) /* esc transmitted */
+ move32();
+ IF( EQ_16( temppos, sub( i, stpos ) ) ) /* esc transmitted */
{
- i--;
+ i = sub( i, 1 );
}
- else
+ ELSE
{
- break;
+ BREAK;
}
}
}
- if ( !ovrflag )
+ IF( !ovrflag )
{
pos = (Word16) ar_decode( pardec, mode_num_nz ) + storepos;
}
- else
+ ELSE
{
pos = storepos;
+ move16();
}
position[stpos + pos] = 1;
- stpos += pos + 1;
+ move32();
+ stpos = add( stpos, add( pos, 1 ) );
}
}
}
- else if ( L_sub( npulses, 1 ) == 0 )
+ ELSE IF( L_sub( npulses, 1 ) == 0 )
{
Word16 tmp;
*nz = npulses;
nzp = *nz;
+ move16();
+ move16();
mode_num_nz[0] = MAX_AR_FREQ;
- for ( i = 0; i < size; i++ )
+ FOR( i = 0; i < size; i++ )
{
- tmp = div_l( L_deposit_h( size - i - 1 ), size );
+ tmp = div_l( L_deposit_h( sub( sub( size, i ), 1 ) ), size );
mode_num_nz[i + 1] = round_fx( L_shr( L_deposit_h( tmp ), 1 ) );
+ move16();
}
position[ar_decode( pardec, mode_num_nz )] = 1;
+ move32();
}
- else
+ ELSE
{
*nz = 0;
+ move16();
}
return;
@@ -421,31 +452,36 @@ void decode_magnitude_usq_fx_ivas(
{
Word16 i, magnp, magnzp;
Word16 magns[TCQ_MAX_BAND_SIZE], magncout = 0;
-
+ move16();
Word16 storemagn, ovrflag, pos, tempmagn = 0, mmodel[MAX_PULSES + 2];
+ move16();
Word32 cp, scp, fxone, fxp1;
fxone = 32768;
+ move32();
fxp1 = 512 * 32768;
+ move32();
ovrflag = 0;
-
+ move16();
set16_fx( magns, 1, TCQ_MAX_BAND_SIZE );
- if ( sub( nzpos, npulses ) == 0 )
+ IF( sub( nzpos, npulses ) == 0 )
{
- for ( i = 0; i < size; i++ )
+ FOR( i = 0; i < size; i++ )
{
out[i] = positions[i];
+ move32();
}
return;
}
- else if ( sub( nzpos, 1 ) == 0 )
+ ELSE IF( sub( nzpos, 1 ) == 0 )
{
- for ( i = 0; i < size; i++ )
+ FOR( i = 0; i < size; i++ )
{
if ( positions[i] != 0 )
{
out[i] = npulses;
+ move32();
return;
}
}
@@ -455,106 +491,119 @@ void decode_magnitude_usq_fx_ivas(
magnp = sub( npulses, 1 );
magncout = 0;
-
+ move16();
set32_fx( out, 0, size );
set16_fx( mmodel, 0, MAX_PULSES + 2 );
mmodel[0] = MAX_AR_FREQ;
+ move16();
magncout = 0;
- for ( pos = 0; pos < size; pos++ )
+ move16();
+ FOR( pos = 0; pos < size; pos++ )
{
scp = fxp1;
- if ( positions[pos] != 0 )
+ move32();
+ IF( positions[pos] != 0 )
{
storemagn = 0;
-
- for ( i = 0; i < magnp; i++ )
+ move16();
+ FOR( i = 0; i < magnp; i++ )
{
ovrflag = 0;
-
- if ( magnzp == ( magnp - i ) )
+ move16();
+ IF( EQ_16( magnzp, sub( magnp, i ) ) )
{
cp = 0;
+ move32();
}
- else
+ ELSE
{
Word16 tmp;
tmp = div_l( L_deposit_h( magnzp ), magnp - i );
cp = L_sub( fxone, tmp );
}
- if ( cp == fxone )
+ if ( EQ_32( cp, fxone ) )
{
break;
}
scp = Mult_32_16( scp, extract_l( cp ) );
- mmodel[i + 1 - storemagn] = round_fx( L_shl( scp, 6 ) );
-
- if ( ( mmodel[i + 1 - storemagn] == 0 && scp > 0 ) || mmodel[i - storemagn] == mmodel[i + 1 - storemagn] )
+ mmodel[sub( add( i, 1 ), storemagn )] = round_fx( L_shl( scp, 6 ) );
+ move16();
+ IF( ( mmodel[sub( add( i, 1 ), storemagn )] == 0 && scp > 0 ) || EQ_16( mmodel[sub( i, storemagn )], mmodel[sub( add( i, 1 ), storemagn )] ) )
{
- mmodel[i + 1 - storemagn] = 0;
+ mmodel[sub( add( i, 1 ), storemagn )] = 0;
+ move16();
/* read data */
tempmagn = (Word16) ar_decode( pardec, mmodel );
- storemagn += tempmagn;
+ storemagn = add( storemagn, tempmagn );
- if ( tempmagn < i )
+ IF( LT_16( tempmagn, i ) )
{
/* just magnitude */
ovrflag = 1;
- break;
+ move16();
+ BREAK;
}
- else
+ ELSE
{
/* esc code */
scp = fxp1;
- i--;
+ move32();
+ i = sub( i, 1 );
}
}
}
- if ( ovrflag )
+ IF( ovrflag )
{
- out[magncout] = storemagn + 1;
+ out[magncout] = L_deposit_l( add( storemagn, 1 ) );
+ move32();
}
- else
+ ELSE
{
- out[magncout] = ar_decode( pardec, mmodel ) + storemagn + 1;
+ out[magncout] = L_add( ar_decode( pardec, mmodel ), L_deposit_l( add( storemagn, 1 ) ) );
+ move32();
}
- magnp -= (Word16) out[magncout];
- magnzp--;
- magncout++;
+ magnp = sub( magnp, (Word16) out[magncout] );
+ magnzp = sub( magnzp, 1 );
+ magncout = add( magncout, 1 );
- if ( magnzp == 0 ) /* last magnitude generation */
+ IF( magnzp == 0 ) /* last magnitude generation */
{
- for ( pos = pos + 1; pos < size; pos++ )
+ FOR( pos = add( pos, 1 ); pos < size; pos++ )
{
- if ( positions[pos] != 0 )
+ IF( positions[pos] != 0 )
{
- out[magncout] = magnp + 1;
+ out[magncout] = L_deposit_l( add( magnp, 1 ) );
+ move32();
return;
}
- else
+ ELSE
{
out[magncout] = 0;
- magncout++;
+ move32();
+ magncout = add( magncout, 1 );
}
}
}
- else if ( magnzp == magnp ) /* rest magnitudes generation */
+ ELSE IF( EQ_16( magnzp, magnp ) ) /* rest magnitudes generation */
{
- for ( pos = pos + 1; pos < size; pos++ )
+ FOR( pos = add( pos, 1 ); pos < size; pos++ )
{
out[magncout] = positions[pos];
- magncout++;
+ move32();
+ magncout = add( magncout, 1 );
}
return;
}
}
- else
+ ELSE
{
out[magncout] = 0;
- magncout++;
+ move32();
+ magncout = add( magncout, 1 );
}
}
@@ -571,11 +620,12 @@ static Word16 quantize_fx_ivas(
qval4_fx = shr( abs_s( add( val, 512 ) ), 12 );
retval_fx = add( shl( qval4_fx, 2 ), DDP_fx[D] );
/* 2nd zero check */
- if ( D == 0 )
+ IF( D == 0 )
{
if ( sub( abs_s( sub( shl( abs_s( retval_fx ), 10 ), abs_s( val ) ) ), abs_s( val ) ) > 0 )
{
retval_fx = 0;
+ move16();
}
}
@@ -600,57 +650,67 @@ void decode_mangitude_tcq_fx_ivas(
Word16 leftp = npulses; /*pulsesnum; */
Word16 leftnz = nzpos; /*nzpos; */
Word16 magn_mode[3] = { MAX_AR_FREQ, 0, 0 };
-
+ move16();
+ move16();
+ move16();
bits_fx = 0;
+ move32();
tcq_bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[npulses - ( nzpos - 1 )] ) );
- if ( sub( nzpos, npulses ) == 0 )
+ IF( sub( nzpos, npulses ) == 0 )
{
- for ( i = 0; i < size; i++ )
+ FOR( i = 0; i < size; i++ )
{
out[i] = positions[i];
+ move32();
}
return;
}
- else if ( sub( nzpos, 1 ) == 0 )
+ ELSE IF( sub( nzpos, 1 ) == 0 )
{
- for ( i = 0; i < size; i++ )
+ FOR( i = 0; i < size; i++ )
{
- if ( positions[i] != 0 )
+ IF( positions[i] != 0 )
{
out[i] = npulses;
+ move32();
return;
}
}
}
st = 0;
- for ( i = 0; i < size && leftnz > 1; i++ )
+ move16();
+ FOR( i = 0; i < size && leftnz > 1; i++ )
{
out[i] = positions[i];
- if ( positions[i] != 0 )
+ move32();
+ IF( positions[i] != 0 )
{
/*generate the trellis path */
symbol = 0;
- for ( j = 0; j < leftp; j++ )
+ move16();
+ FOR( j = 0; j < leftp; j++ )
{
num = sub( leftnz, 1 );
denum = sub( leftp, add( j, 1 ) );
- if ( sub( num, denum ) >= 0 )
+ IF( sub( num, denum ) >= 0 )
{
prob1_fx = MAX_16;
prob0_fx = 0;
+ move16();
+ move16();
}
- else
+ ELSE
{
exp1 = sub( norm_s( num ), 1 );
exp2 = norm_s( denum );
prob1_fx = div_s( shl( num, exp1 ), shl( denum, exp2 ) ); /*15 + exp1 - exp2 */
- exp = 15 + exp1 - exp2;
+ exp = add( 15, sub( exp1, exp2 ) );
prob1_fx = shl( prob1_fx, sub( 15, exp ) );
prob0_fx = sub( MAX_16, prob1_fx );
}
- if ( L_sub( sub( leftp, j ), leftnz ) == 0 )
+ IF( L_sub( sub( leftp, j ), leftnz ) == 0 )
{
symbol = add( j, 1 );
break;
@@ -674,8 +734,8 @@ void decode_mangitude_tcq_fx_ivas(
/*magn_mode[1] = (int16_t)(prob1 * MAX_AR_FREQ); */
magn_mode[1] = mult( prob1_fx, MAX_AR_FREQ );
-
- if ( ar_decode( pardec, magn_mode ) )
+ move16();
+ IF( ar_decode( pardec, magn_mode ) )
{
exp1 = norm_s( prob1_fx );
tmp32 = L_deposit_h( shl( prob1_fx, exp1 ) ); /*exp1 + 15 + 16 */
@@ -683,9 +743,9 @@ void decode_mangitude_tcq_fx_ivas(
bits_fx = L_sub( bits_fx, L_sub( tmp16, L_shl( add( exp1, 1 ), 15 ) ) ); /*15 */
symbol = add( j, 1 );
- break;
+ BREAK;
}
- else
+ ELSE
{
exp1 = norm_s( prob0_fx );
tmp32 = L_deposit_h( shl( prob0_fx, exp1 ) ); /*exp1 + 15 + 16 */
@@ -694,32 +754,36 @@ void decode_mangitude_tcq_fx_ivas(
}
}
out[i] = symbol;
+ move32();
/*leftp -= symbol; */
leftp = sub( leftp, symbol );
- leftnz--;
+ leftnz = sub( leftnz, 1 );
}
quantum1_fx = quantize_fx_ivas( (Word16) out[i], ddec[st][0] );
quantum2_fx = quantize_fx_ivas( (Word16) out[i], ddec[st][1] );
/*generate the next state */
- if ( sub( quantum1_fx, (Word16) out[i] ) == 0 )
+ IF( sub( quantum1_fx, (Word16) out[i] ) == 0 )
{
st = nextstate[st][0];
}
- else
+ ELSE
{
st = nextstate[st][1];
}
+ move16();
}
/*generate the magnitudes */
- for ( ; i < size; i++ )
+ FOR( ; i < size; i++ )
{
out[i] = 0;
+ move32();
if ( positions[i] != 0 )
{
out[i] = add( sub( leftp, leftnz ), 1 );
+ move32();
}
}
@@ -727,6 +791,7 @@ void decode_mangitude_tcq_fx_ivas(
{
/*update the surplus */
*surplus_fx = L_add( *surplus_fx, L_sub( tcq_bits_fx, L_shl( bits_fx, 1 ) ) );
+ move32();
}
return;
@@ -740,18 +805,18 @@ Word16 GetScale_fx_ivas(
{
Word16 pulses = MAX_PULSES, p_est, exp, exp1, exp2, magicnum, tmp;
Word32 t, a, b, ab, estbits_fx = 0;
-
+ move32();
magicnum = 24773; /*Q17: 0.188992013101951f; */
-
+ move16();
t = L_shr( L_mult( magicnum, blen ), 2 );
exp = norm_l( t );
- a = L_shl( 14 - exp, 15 ) + Log2_norm_lc( L_shl( t, exp ) );
+ a = L_add( L_shl( L_deposit_l( sub( 14, exp ) ), 15 ), L_deposit_l( Log2_norm_lc( L_shl( t, exp ) ) ) );
exp1 = sub( norm_l( bits_fx ), 1 );
- exp2 = norm_s( blen - 1 );
+ exp2 = norm_s( sub( blen, 1 ) );
- tmp = div_l( L_shl( bits_fx, exp1 ), shl( blen - 1, exp2 ) );
- b = L_shr( L_deposit_l( tmp ), exp1 - exp2 );
+ tmp = div_l( L_shl( bits_fx, exp1 ), shl( sub( blen, 1 ), exp2 ) );
+ b = L_shr( L_deposit_l( tmp ), sub( exp1, exp2 ) );
ab = L_add( a, b );
@@ -759,18 +824,19 @@ Word16 GetScale_fx_ivas(
pulses = min( p_est, MAX_PULSES );
- for ( ; pulses >= 0; pulses-- )
+ FOR( ; pulses >= 0; pulses-- )
{
estbits_fx = GetBitsFromPulses_fx( pulses, blen );
- if ( L_sub( bits_fx, estbits_fx ) >= 0 )
+ IF( L_sub( bits_fx, estbits_fx ) >= 0 )
{
- break;
+ BREAK;
}
}
if ( surplus_fx != NULL )
{
*surplus_fx = L_add( *surplus_fx, L_sub( bits_fx, estbits_fx ) );
+ move32();
}
return pulses;
@@ -784,11 +850,20 @@ void decode_signs_fx_ivas(
{
Word16 i;
- for ( i = 0; i < size; i++ )
+ FOR( i = 0; i < size; i++ )
{
if ( out[i] != 0 )
{
- out[i] = ( ar_decode( pardec, uniform_model ) > 0 ) ? out[i] : -out[i];
+ IF( ar_decode( pardec, uniform_model ) > 0 )
+ {
+ out[i] = out[i];
+ }
+ ELSE
+ {
+ out[i] = L_negate( out[i] );
+ }
+
+ move32();
}
}
@@ -1144,16 +1219,17 @@ Word32 encode_magnitude_usq_fx_ivas(
static void transmission_bits(
PARCODEC arInst,
- int16_t bit )
+ Word16 bit )
{
bitstream_save_bit( arInst->bsInst, bit );
- arInst->num_bits++;
+ arInst->num_bits = L_add( arInst->num_bits, 1 );
bit = !bit;
-
- for ( ; arInst->bits_to_follow > 0 && arInst->num_bits < arInst->max_bits; arInst->bits_to_follow-- )
+ move16();
+ FOR( ; arInst->bits_to_follow > 0 && arInst->num_bits < arInst->max_bits; arInst->bits_to_follow-- )
{
bitstream_save_bit( arInst->bsInst, bit );
- arInst->num_bits++;
+ arInst->num_bits = L_add( arInst->num_bits, 1 );
+ move32();
}
return;
@@ -1162,16 +1238,20 @@ static void transmission_bits(
void ar_encoder_start(
PARCODEC arInst,
TCQ_PBITSTREAM bsInst,
- int16_t max_bits )
+ Word16 max_bits )
{
arInst->bsInst = bsInst;
arInst->low = 0;
+ move32();
arInst->high = AR_TOP;
+ move32();
arInst->bits_to_follow = 0;
-
+ move16();
arInst->num_bits = 0;
+ move32();
arInst->max_bits = max_bits;
+ move32();
return;
}
@@ -1179,47 +1259,47 @@ void ar_encoder_start(
static void ar_encode(
PARCODEC arInst,
- const int16_t *model,
- int32_t symbol )
+ const Word16 *model,
+ Word32 symbol )
{
- uint32_t range, high, low;
+ UWord32 range, high, low;
high = arInst->high;
low = arInst->low;
- symbol++;
+ symbol = L_add( symbol, 1 );
range = high - low + 1;
high = low + ( range * model[symbol - 1] ) / model[0] - 1;
low = low + ( range * model[symbol] ) / model[0];
- for ( ;; )
+ FOR( ;; )
{
- if ( high < AR_HALF )
+ IF( high < AR_HALF )
{
transmission_bits( arInst, 0 );
}
- else
+ ELSE
{
- if ( low >= AR_HALF )
+ IF( low >= AR_HALF )
{
transmission_bits( arInst, 1 );
low -= AR_HALF;
high -= AR_HALF;
}
- else
+ ELSE
{
- if ( low >= AR_FIRST && high < AR_THIRD )
+ IF( low >= AR_FIRST && high < AR_THIRD )
{
- arInst->bits_to_follow++;
+ arInst->bits_to_follow = add( arInst->bits_to_follow, 1 );
low -= AR_FIRST;
high -= AR_FIRST;
}
- else
+ ELSE
{
- break;
+ BREAK;
}
}
}
@@ -1229,20 +1309,21 @@ static void ar_encode(
}
arInst->high = high;
+ move32();
arInst->low = low;
-
+ move32();
return;
}
static void ar_encode_uniform(
PARCODEC arInst,
- uint16_t data,
- const int16_t bits )
+ UWord16 data,
+ const Word16 bits )
{
- int16_t i;
+ Word16 i;
- for ( i = 0; i < bits; i++ )
+ FOR( i = 0; i < bits; i++ )
{
ar_encode( arInst, uniform_model, data & 0x1 );
data >>= 1;
@@ -1255,7 +1336,8 @@ static void ar_encode_uniform(
void ar_encoder_done(
PARCODEC arInst )
{
- arInst->bits_to_follow++;
+ arInst->bits_to_follow = add( arInst->bits_to_follow, 1 );
+ move16();
transmission_bits( arInst, arInst->low >= AR_FIRST );
return;
@@ -1266,35 +1348,43 @@ void ar_decoder_start(
PARCODEC arInst,
TCQ_PBITSTREAM bsInst )
{
- int16_t i;
+ Word16 i;
arInst->bsInst = bsInst;
-
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move16();
arInst->low = 0;
arInst->high = AR_TOP;
arInst->value = 0;
-
- for ( i = 0; i < AR_BITS; i++ )
+ move32();
+ move32();
+ move32();
+ FOR( i = 0; i < AR_BITS; i++ )
{
- arInst->value = ( arInst->value << 1 ) + bitstream_load_bit( arInst->bsInst );
+ arInst->value = L_add( L_shl( arInst->value, 1 ), bitstream_load_bit( arInst->bsInst ) );
+ move32();
}
return;
}
-static int32_t ar_decode(
+static Word32 ar_decode(
PARCODEC arInst,
- const int16_t *model )
+ const Word16 *model )
{
- uint32_t range;
- int16_t cum;
- int16_t symbol;
+ UWord32 range;
+ Word16 cum;
+ Word16 symbol;
- range = (uint32_t) ( arInst->high - arInst->low ) + 1;
- cum = (int16_t) ( ( ( (uint32_t) ( arInst->value - arInst->low ) + 1 ) * model[0] - 1 ) / range );
+ range = (UWord32) L_add( L_sub( arInst->high, arInst->low ), 1 );
+ cum = (Word16) ( ( ( (UWord32) L_sub( arInst->value, arInst->low ) + 1 ) * model[0] - 1 ) / range );
- for ( symbol = 1; model[symbol] > cum; symbol++ )
+ FOR( symbol = 1; model[symbol] > cum; symbol++ )
{
;
}
@@ -1302,36 +1392,45 @@ static int32_t ar_decode(
arInst->high = arInst->low + ( range * model[symbol - 1] ) / model[0] - 1;
arInst->low = arInst->low + ( range * model[symbol] ) / model[0];
- for ( ;; )
+ FOR( ;; )
{
- if ( arInst->high >= AR_HALF )
+ IF( GE_32( arInst->high, AR_HALF ) )
{
- if ( arInst->low >= AR_HALF )
+ IF( GE_32( arInst->low, AR_HALF ) )
{
- arInst->value -= AR_HALF;
- arInst->low -= AR_HALF;
- arInst->high -= AR_HALF;
+ arInst->value = L_sub( arInst->value, AR_HALF );
+ move32();
+ arInst->low = L_sub( arInst->low, AR_HALF );
+ move32();
+ arInst->high = L_sub( arInst->high, AR_HALF );
+ move32();
}
- else
+ ELSE
{
- if ( arInst->low >= AR_FIRST && arInst->high < AR_THIRD )
+ IF( GE_32( arInst->low, AR_FIRST ) && LT_32( arInst->high, AR_THIRD ) )
{
- arInst->value -= AR_FIRST;
- arInst->low -= AR_FIRST;
- arInst->high -= AR_FIRST;
+ arInst->value = L_sub( arInst->value, AR_FIRST );
+ move32();
+ arInst->low = L_sub( arInst->low, AR_FIRST );
+ move32();
+ arInst->high = L_sub( arInst->high, AR_FIRST );
+ move32();
}
- else
+ ELSE
{
- break;
+ BREAK;
}
}
}
- arInst->low <<= 1;
- arInst->high = ( arInst->high << 1 ) + 1;
- arInst->value = ( arInst->value << 1 ) + bitstream_load_bit( arInst->bsInst );
+ arInst->low = L_shl( arInst->low, 1 );
+ move32();
+ arInst->high = L_add( L_shl( arInst->high, 1 ), 1 );
+ move32();
+ arInst->value = L_add( L_shl( arInst->value, 1 ), bitstream_load_bit( arInst->bsInst ) );
+ move32();
}
- return ( symbol - 1 );
+ return ( sub( symbol, 1 ) );
}
void ar_decoder_done(
@@ -1343,17 +1442,17 @@ void ar_decoder_done(
}
-static int32_t ar_make_model(
- const int16_t *freq,
- int16_t *model,
- const int16_t len )
+static Word32 ar_make_model(
+ const Word16 *freq,
+ Word16 *model,
+ const Word16 len )
{
- int16_t dist;
- uint32_t sum = 0;
- uint32_t cum = 0;
- int16_t i;
+ Word16 dist;
+ UWord32 sum = 0;
+ UWord32 cum = 0;
+ Word16 i;
- for ( i = 0; i < len; i++ )
+ FOR( i = 0; i < len; i++ )
{
sum += freq[i];
}
@@ -1363,58 +1462,62 @@ static int32_t ar_make_model(
return 0;
}
- for ( i = len;; i-- )
+ FOR( i = len;; i-- )
{
- model[i] = (int16_t) ( ( cum * MAX_AR_FREQ ) / sum );
-
+ model[i] = (Word16) ( ( cum * MAX_AR_FREQ ) / sum );
+ move16();
if ( !i )
{
- break;
+ BREAK;
}
cum += freq[i - 1];
}
- for ( i = 0; i < len - 1; i++ )
+ FOR( i = 0; i < sub( len, 1 ); i++ )
{
- dist = model[i] - model[i + 1];
+ dist = sub( model[i], model[i + 1] );
if ( dist <= 0 )
{
- model[i + 1] += dist - 1;
+ model[i + 1] = add( model[i + 1], sub( dist, 1 ) );
+ move16();
}
}
- for ( i = len; i; i-- )
+ FOR( i = len; i; i-- )
{
- dist = model[i - 1] - model[i];
+ dist = sub( model[i - 1], model[i] );
if ( dist <= 0 )
{
- model[i - 1] -= dist - 1;
+ model[i - 1] = sub( model[i - 1], sub( dist, 1 ) );
+ move16();
}
}
- return ( model[0] > model[1] );
+ return ( GT_16( model[0], model[1] ) );
}
static void bitstream_save_bit(
TCQ_PBITSTREAM pBS,
- const int16_t bit )
+ const Word16 bit )
{
- uint8_t cur;
+ UWord8 cur;
cur = pBS->buf[pBS->numByte];
- cur = (uint8_t) ( cur | ( bit << pBS->curPos-- ) );
+ cur = (UWord8) ( cur | shl( bit, pBS->curPos-- ) );
pBS->buf[pBS->numByte] = cur;
- pBS->numbits++;
+ pBS->numbits = L_add( pBS->numbits, 1 );
if ( pBS->curPos < 0 )
{
pBS->curPos = 7;
- pBS->numByte++;
+ move16();
+ pBS->numByte = L_add( pBS->numByte, 1 );
+ move32();
}
return;
@@ -1424,22 +1527,25 @@ static void bitstream_save_bit(
static uint32_t bitstream_load_bit(
TCQ_PBITSTREAM pBS )
{
- uint32_t bit;
+ UWord32 bit;
Word16 *curPos;
/* safety check in case of bit errors */
- if ( pBS->numByte >= pBS->maxBytes )
+ if ( GE_32( pBS->numByte, pBS->maxBytes ) )
{
return 0;
}
curPos = &pBS->curPos;
+ move16();
bit = ( ( pBS->buf[pBS->numByte] >> ( *curPos )-- ) & 0x00000001 );
if ( *curPos < 0 )
{
- pBS->numByte++;
+ pBS->numByte = L_add( pBS->numByte, 1 );
+ move32();
*curPos = 7;
+ move16();
}
return bit;
@@ -1448,18 +1554,20 @@ static uint32_t bitstream_load_bit(
static void bitstream_rollback(
TCQ_PBITSTREAM pBS,
- int16_t numBits )
+ Word16 numBits )
{
- while ( numBits > 0 )
+ WHILE( numBits > 0 )
{
- pBS->curPos++;
- pBS->numbits--;
- if ( pBS->curPos == 8 )
+ pBS->curPos = add( pBS->curPos, 1 );
+ pBS->numbits = L_sub( pBS->numbits, 1 );
+ IF( EQ_16( pBS->curPos, 8 ) )
{
pBS->curPos = 0;
- pBS->numByte--;
+ move16();
+ pBS->numByte = L_sub( pBS->numByte, 1 );
+ move32();
}
- numBits--;
+ numBits = sub( numBits, 1 );
}
return;
@@ -1930,10 +2038,10 @@ float GetISCScale(
void InitLSBTCQ(
- int16_t *bcount )
+ Word16 *bcount )
{
*bcount = 0;
-
+ move16();
return;
}
@@ -2068,12 +2176,12 @@ void TCQLSBdec(
void SaveTCQdata(
PARCODEC arInst,
- int16_t *dpath,
- int16_t bcount )
+ Word16 *dpath,
+ Word16 bcount )
{
- int16_t i;
+ Word16 i;
- for ( i = 0; i < bcount; i++ )
+ FOR( i = 0; i < bcount; i++ )
{
ar_encode_uniform( arInst, dpath[i], 1 );
}
@@ -2083,14 +2191,15 @@ void SaveTCQdata(
void LoadTCQdata(
PARCODEC arInst,
- int16_t *dpath,
- int16_t bcount )
+ Word16 *dpath,
+ Word16 bcount )
{
- int16_t i;
+ Word16 i;
- for ( i = 0; i < bcount; i++ )
+ FOR( i = 0; i < bcount; i++ )
{
- dpath[i] = (int16_t) ar_decode( arInst, uniform_model );
+ dpath[i] = (Word16) ar_decode( arInst, uniform_model );
+ move16();
}
return;
diff --git a/lib_com/tcq_position_arith_fx.c b/lib_com/tcq_position_arith_fx.c
index 12ed381964251f0fe0335fb4345bd869f74d746f..8c4b9a582515ebb6628bc49c7eb0208eddd1abf8 100644
--- a/lib_com/tcq_position_arith_fx.c
+++ b/lib_com/tcq_position_arith_fx.c
@@ -7,8 +7,7 @@
#include "stl.h"
#include "rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
Word32 ar_div(
Word32 num,
@@ -78,15 +77,17 @@ static void bitstream_save_bit(
cur = (UWord8) ( cur | L_shl( bit, pBS->curPos ) );
move16();
pBS->curPos = sub( pBS->curPos, 1 );
+ move16();
pBS->buf[pBS->numByte] = cur;
move16();
pBS->numbits = L_add( pBS->numbits, 1 );
-
+ move32();
IF( pBS->curPos < 0 )
{
pBS->curPos = 7;
move16();
pBS->numByte = L_add( pBS->numByte, 1 );
+ move32();
}
return;
@@ -105,15 +106,13 @@ static UWord32 bitstream_load_bit(
}
curPos = &pBS->curPos;
- move16();
- bit = ( ( pBS->buf[pBS->numByte] >> ( *curPos )-- ) & 0x00000001 );
- move16();
- move16();
- move16();
+ bit = UL_and( UL_lshr( pBS->buf[pBS->numByte], ( *curPos ) ), 0x00000001 );
+ *curPos = sub( *curPos, 1 );
IF( *curPos < 0 )
{
pBS->numByte = L_add( pBS->numByte, 1 );
+ move32();
*curPos = 7;
move16();
}
@@ -131,11 +130,13 @@ static void bitstream_rollback(
pBS->curPos++;
move16();
pBS->numbits = L_sub( pBS->numbits, 1 );
+ move32();
IF( EQ_16( pBS->curPos, 8 ) )
{
pBS->curPos = 0;
move16();
pBS->numByte = L_sub( pBS->numByte, 1 );
+ move32();
}
}
@@ -147,6 +148,7 @@ static void transmission_bits(
{
bitstream_save_bit( arInst->bsInst, bit );
arInst->num_bits = L_add( arInst->num_bits, 1 );
+ move32();
bit = !bit;
move32();
@@ -154,6 +156,7 @@ static void transmission_bits(
{
bitstream_save_bit( arInst->bsInst, bit );
arInst->num_bits = L_add( arInst->num_bits, 1 );
+ move32();
}
return;
@@ -166,7 +169,9 @@ static Word32 ar_make_model_fx(
{
Word16 dist;
Word32 sum = 0;
+ move32();
Word32 cum = 0;
+ move32();
Word16 i, tmp;
FOR( i = 0; i < len; i++ )
@@ -183,7 +188,7 @@ static Word32 ar_make_model_fx(
{
/*model[i] = (short)( ( cum * MAX_AR_FREQ ) / sum ); */
model[i] = extract_l( ar_div( cum * MAX_AR_FREQ, sum ) );
-
+ move16();
if ( i )
cum = L_add( cum, freq[i - 1] );
}
@@ -223,12 +228,14 @@ void ar_encoder_start_fx(
move32();
arInst->low = L_deposit_l( 0 );
+ move32();
arInst->high = AR_TOP;
move32();
arInst->bits_to_follow = 0;
move16();
arInst->num_bits = L_deposit_l( 0 );
+ move32();
arInst->max_bits = max_bits;
move32();
}
@@ -246,8 +253,8 @@ static void ar_encode_fx(
symbol = L_add( symbol, 1 );
range = L_add( L_sub( high, low ), 1 );
- high = L_sub( L_add( low, ar_div( range * model[symbol - 1], model[0] ) ), 1 );
- low = L_add( low, ar_div( range * model[symbol], model[0] ) );
+ high = L_sub( L_add( low, ar_div( imult3216( range, model[symbol - 1] ), model[0] ) ), 1 );
+ low = L_add( low, ar_div( imult3216( range, model[symbol] ), model[0] ) );
FOR( ;; )
{
@@ -330,13 +337,15 @@ void ar_decoder_start_fx(
move32();
arInst->low = L_deposit_l( 0 );
+ move32();
arInst->high = AR_TOP;
move32();
arInst->value = L_deposit_l( 0 );
-
+ move32();
FOR( i = 0; i < AR_BITS; i++ )
{
arInst->value = L_add( L_shl( arInst->value, 1 ), bitstream_load_bit( arInst->bsInst ) );
+ move32();
}
return;
@@ -356,7 +365,7 @@ static Word16 ar_decode_fx(
range = L_add( L_sub( high, low ), 1 );
/*cum = (short)( ( ( (unsigned int)( arInst->value - arInst->low ) + 1 ) * model[0] - 1 ) / range ); */
- cum = extract_l( ar_div( L_sub( L_add( L_sub( value, low ), 1 ) * model[0], 1 ), range ) );
+ cum = extract_l( ar_div( L_sub( imult3216( L_add( L_sub( value, low ), 1 ), model[0] ), 1 ), range ) );
symbol = 1;
move16();
@@ -365,8 +374,8 @@ static Word16 ar_decode_fx(
symbol = add( symbol, 1 );
}
- high = L_sub( L_add( low, ar_div( range * model[symbol - 1], model[0] ) ), 1 );
- low = L_add( low, ar_div( range * model[symbol], model[0] ) );
+ high = L_sub( L_add( low, ar_div( imult3216( range, model[symbol - 1] ), model[0] ) ), 1 );
+ low = L_add( low, ar_div( imult3216( range, model[symbol] ), model[0] ) );
FOR( i = 0; i < 0x7FFF; i++ )
{
@@ -396,7 +405,7 @@ static Word16 ar_decode_fx(
arInst->value = value;
move32();
- return ( symbol - 1 );
+ return ( sub( symbol, 1 ) );
}
void ar_decoder_done_fx(
@@ -472,7 +481,7 @@ static Word32 GetBitsFromPulses_fx(
exp1 = norm_l( pow_getbitsfrompulses_fx[temp_fx1] );
exp2 = norm_l( frac_fx32 );
frac_fx32 = Mult_32_32( L_shl( pow_getbitsfrompulses_fx[temp_fx1], exp1 ), L_shl( frac_fx32, exp2 ) ); /*21 + exp1 + 30 + exp2 - 31 */
- frac_fx32 = L_shr( frac_fx32, exp1 + exp2 ) + 1; /*20 */
+ frac_fx32 = L_add( L_shr( frac_fx32, add( exp1, exp2 ) ), 1 ); /*20 */
IF( LT_16( exp, integer_fx ) )
{
@@ -488,8 +497,7 @@ static Word32 GetBitsFromPulses_fx(
}
IF( GE_32( mantissa_fx, 0x200000 ) )
{
- exp++;
- move16();
+ exp = add( exp, 1 );
mantissa_fx = L_shr( mantissa_fx, 1 );
}
@@ -528,7 +536,7 @@ static void TCQnew_fx(
{
Word16 i, st, dminpos, position;
Word16 pulsesnum, nzpos = 0;
-
+ move16();
Word32 metric_fx[STATES][TCQ_MAX_BAND_SIZE];
Word16 path_fx[STATES][TCQ_MAX_BAND_SIZE];
Word16 quant_fx[STATES][TCQ_MAX_BAND_SIZE];
@@ -570,7 +578,7 @@ static void TCQnew_fx(
exp = norm_l( scale_fx );
tmp32 = L_shl( scale_fx, exp );
tmp32 = Mult_32_16( v_fx[i], extract_h( tmp32 ) ); /*12 + 20 + exp - 16 - 15 + Qscale */
- exp1 = 26 - ( exp - 19 + Qscale );
+ exp1 = sub( 26, add( sub( exp, 19 ), Qscale ) );
exp2 = norm_l( tmp32 );
IF( GE_16( exp2, exp1 ) )
{
@@ -659,7 +667,7 @@ static void TCQnew_fx(
move16();
if ( v_fx[i - 1] <= 0 )
{
- vout_fx[i - 1] = -quant_fx[position][i];
+ vout_fx[i - 1] = negate( quant_fx[position][i] );
move16();
}
position = path_fx[position][i];
@@ -720,10 +728,13 @@ Word32 GetISCScale_fx(
Word16 SafeExp;
Word32 magnbits_fx = 0, tcqmagnbits_fx /*, surplus_fx, bits_fx*/;
+ move32();
Word16 prob0_fx, prob1_fx, num, denum, quantum1_fx, quantum2_fx;
Word32 dmin_fx, scale_fx32;
Word32 actualt_fx;
Word32 pt_fx, sxy_fx = 0, sy2_fx = 0;
+ move32();
+ move32();
Word16 pn_fx, g_fx, scale_fx;
Word16 tmp16, exp, exp1, exp2, Q_temp, hi, lo;
Word32 m_fx, tmp32;
@@ -733,8 +744,15 @@ Word32 GetISCScale_fx(
Word16 Qscale;
Word16 Qsxy = 4;
- exp = 0; /* to avoid compilation warnings */
+ move32();
+ move32();
+ move32();
+ move16();
+
+ exp = 0; /* to avoid compilation warnings */
+ move16();
Qscale = 0; /* to avoid compilation warnings */
+ move16();
set32_fx( dist_fx, 0, size );
set16_fx( exp_dist, 31, size );
@@ -794,15 +812,16 @@ Word32 GetISCScale_fx(
exp2 = norm_l( m_fx );
scale_fx = div_s( shl( pulsesnum, exp1 ), extract_h( L_shl( m_fx, exp2 ) ) ); /*15 + exp1 - (exp2 + 12 - 16) */
- exp = 15 + exp1 - ( exp2 + 12 - 16 ) + 2;
+ exp = add( sub( add( 15, exp1 ), sub( add( exp2, 12 ), 16 ) ), 2 );
move16();
t_fx = 0;
move16();
FOR( i = 0; i < size; i++ )
{
- tmp32 = Mult_32_16( aquants_fx[i], scale_fx ); /*12 + exp - 15 */
- tmp32 = L_shl( tmp32, sub( 16, 12 + exp - 15 ) ); /*16 */
+ tmp32 = Mult_32_16( aquants_fx[i], scale_fx ); /*12 + exp - 15 */
+ tmp32 = L_shl( tmp32, sub( 16, add( 12 - 15, exp ) ) ); /*16 */
magn_fx[i] = extract_h( L_add( 32768, tmp32 ) );
+ move16();
t_fx = add( t_fx, magn_fx[i] );
}
}
@@ -837,8 +856,8 @@ Word32 GetISCScale_fx(
{
FOR( i = 0; i < size; i++ )
{
- sxy_fx = L_add( sxy_fx, L_shl( Mult_32_16( aquants_fx[i], magn_fx[i] ), Qsxy + 3 ) ); /* 12+0-15 +9 -> 6 */
- sy2_fx = L_add( sy2_fx, L_mult0( magn_fx[i], magn_fx[i] ) ); /*0 */
+ sxy_fx = L_add( sxy_fx, L_shl( Mult_32_16( aquants_fx[i], magn_fx[i] ), add( Qsxy, 3 ) ) ); /* 12+0-15 +9 -> 6 */
+ sy2_fx = L_add( sy2_fx, L_mult0( magn_fx[i], magn_fx[i] ) ); /*0 */
}
Q_temp = 32;
move16();
@@ -876,20 +895,21 @@ Word32 GetISCScale_fx(
{
tmp16 = shl( tmp16, exp2 );
}
- g_fx = div_s( extract_h( tmp32 ), tmp16 ); /*15 + 12 + exp1 - 16 - exp2; */
- exp = 15 + 12 + exp1 - 16 - exp2 - 2;
+ g_fx = div_s( extract_h( tmp32 ), tmp16 ); /*15 + 12 + exp1 - 16 - exp2; */
+ exp = add( 15 + 12 - 16 - 2, sub( exp1, exp2 ) ); /*exp = 15 + 12 + exp1 - 16 - exp2 - 2*/
move16();
}
IF( g_fx == 0 )
{
dist_fx[i] = L_deposit_l( 0 );
+ move32();
}
ELSE
{
IF( direction > 0 )
{
- tmp32 = L_add( sxy_fx, L_shr( aquants_fx[i], 12 - Qsxy ) ); /*Qsxy */
+ tmp32 = L_add( sxy_fx, L_shr( aquants_fx[i], sub( 12, Qsxy ) ) ); /*Qsxy */
t32 = L_add( sy2_fx, L_add( 1, L_deposit_l( shl( magn_fx[i], 1 ) ) ) );
IF( LT_16( norm_l( t32 ), 15 ) )
@@ -906,7 +926,7 @@ Word32 GetISCScale_fx(
}
ELSE
{
- tmp32 = L_sub( sxy_fx, L_shr( aquants_fx[i], 12 - Qsxy ) ); /*Qsxy */
+ tmp32 = L_sub( sxy_fx, L_shr( aquants_fx[i], sub( 12, Qsxy ) ) ); /*Qsxy */
t32 = L_add( sy2_fx, L_sub( 1, L_deposit_l( shl( magn_fx[i], 1 ) ) ) );
SafeExp = norm_l( t32 );
@@ -923,7 +943,7 @@ Word32 GetISCScale_fx(
}
}
#ifdef BASOP_NOGLOB
- tmp32 = L_shl_sat( tmp32, 1 - SafeExp ); /* *2 */
+ tmp32 = L_shl_sat( tmp32, sub( 1, SafeExp ) ); /* *2 */
tmp32 = L_sub_sat( L_shl_sat( L_mult0( g_fx, tmp16 ), sub( Qsxy, exp ) ), tmp32 ); /*Qsxy */
#else
tmp32 = L_shl( tmp32, 1 - SafeExp ); /* *2 */
@@ -931,7 +951,7 @@ Word32 GetISCScale_fx(
#endif
dist_fx[i] = Mult_32_16( tmp32, g_fx ); /*Qsxy + exp - 15 */
move32();
- exp_dist[i] = add( Qsxy - 15, exp );
+ exp_dist[i] = add( sub( Qsxy, 15 ), exp );
move16();
if ( LT_16( exp_dist[i], Q_temp ) )
{
@@ -1020,7 +1040,7 @@ Word32 GetISCScale_fx(
exp2 = sub( norm_l( pulsesnum ), 1 );
lo = L_Extract_lc( L_shl( actualt_fx, exp1 ), &hi );
scale_fx32 = Div_32( L_shl( pulsesnum, exp2 ), hi, lo ); /*31 + exp2 - exp1 - 12 */
- Qscale = 31 + exp2 - exp1 - 12 + 2;
+ Qscale = add( 31 - 12 + 2, sub( exp2, exp1 ) ); /*31 + exp2 - exp1 - 12 + 2*/
move16();
}
@@ -1172,8 +1192,7 @@ Word32 GetISCScale_fx(
exp1 = sub( norm_s( num ), 1 );
exp2 = norm_s( denum );
prob1_fx = div_s( shl( num, exp1 ), shl( denum, exp2 ) ); /*15 + exp1 - exp2 */
- exp = 15 + exp1 - exp2;
- move16();
+ exp = add( 15, sub( exp1, exp2 ) );
prob1_fx = shl( prob1_fx, sub( 15, exp ) );
prob0_fx = sub( MAX_16, prob1_fx );
}
@@ -1209,8 +1228,7 @@ Word32 GetISCScale_fx(
}
}
- leftnz--;
- move16();
+ leftnz = sub( leftnz, 1 );
leftp = sub( leftp, abs_s( magn_fx[i] ) );
}
@@ -1218,9 +1236,9 @@ Word32 GetISCScale_fx(
}
/* Update actual occurred surplus */
- tcqmagnbits_fx = L_sub( L_sub( table_logcum_fx[pulsescurr], table_logcum_fx[nzposcurr] ), table_logcum_fx[pulsescurr - ( nzposcurr - 1 )] );
+ tcqmagnbits_fx = L_sub( L_sub( table_logcum_fx[pulsescurr], table_logcum_fx[nzposcurr] ), table_logcum_fx[sub( pulsescurr, sub( nzposcurr, 1 ) )] );
*surplus_fx = L_add( *surplus_fx, L_sub( tcqmagnbits_fx, L_shl( magnbits_fx, 1 ) ) );
-
+ move32();
*nzpout = nzposcurr;
move16();
} /*magnitude coding */
@@ -1236,7 +1254,7 @@ Word32 GetISCScale_fx(
exp2 = sub( norm_l( pulsesnum ), 1 );
lo = L_Extract_lc( L_shl( actualt_fx, exp1 ), &hi );
scale_fx32 = Div_32( L_shl( pulsesnum, exp2 ), hi, lo ); /*31 + exp2 - exp1 - 12 */
- Qscale = 31 + exp2 - exp1 - 12;
+ Qscale = add( 31 - 12, sub( exp2, exp1 ) ); /*31 + exp2 - exp1 - 12*/
move16();
}
test();
@@ -1247,7 +1265,7 @@ Word32 GetISCScale_fx(
FOR( i = 0; i < size; i++ )
{
- if ( abs_s( magn_fx[i] ) > 1 )
+ if ( GT_16( abs_s( magn_fx[i] ), 1 ) )
{
flag_g1 = 1;
move16();
@@ -1270,14 +1288,15 @@ Word32 GetISCScale_fx(
move16();
/*sbuffer[*bcount] = scale_fx32;*/
exp = norm_s( pulsesnum );
- tmp16 = div_l( actualt_fx, shl( pulsesnum, exp - 1 ) );
+ tmp16 = div_l( actualt_fx, shl( pulsesnum, sub( exp, 1 ) ) );
tmp32 = L_shl( L_deposit_l( tmp16 ), exp );
/*sbuffer[*bcount] = 1/((float)tmp32/pow(2.0, 12));*/
sbuffer[*bcount] = tmp32; /*Q12*/
move32();
/*sbuffer[*bcount] = (float)scale_fx32 / pow(2.0, Qscale);*/
- ( *bcount )++;
+ ( *bcount ) = add( *bcount, 1 );
+ move16();
}
}
}
@@ -1297,6 +1316,7 @@ void TCQLSB_fx(
{
Word16 i, st, dminpos, position;
Word16 q_fx = 6554; /*Q15*/
+ move16();
Word32 dmin_fx, curdist1_fx, curdist2_fx, newdist1_fx, newdist2_fx;
Word16 path[STATES_LSB][TCQ_LSB_SIZE];
Word16 quant[STATES_LSB][TCQ_LSB_SIZE];
@@ -1338,9 +1358,9 @@ void TCQLSB_fx(
exp2 = norm_l( s2_fx );
s1_fx16 = extract_h( L_shl( s1_fx, exp1 ) ); /*12 + exp1 - 16*/
s2_fx16 = extract_h( L_shl( s2_fx, exp2 ) ); /*12 + exp2 - 16*/
- exp1 = 12 + exp1 - 16;
+ exp1 = add( 12 - 16, exp1 );
move16();
- exp2 = 12 + exp2 - 16;
+ exp2 = add( 12 - 16, exp2 );
move16();
a1_fx = L_add( abuffer_fx[i], 0 );
@@ -1407,36 +1427,36 @@ void TCQLSB_fx(
/* decision */
IF( LT_32( L_add( curdist1_fx, newdist1_fx ), L_add( curdist2_fx, newdist2_fx ) ) )
{
- path[st][i / 2 + 1] = step_LSB[st][0];
+ path[st][add( shr( i, 1 ), 1 )] = step_LSB[st][0];
move16();
- metric_fx[st][i / 2 + 1] = L_add( curdist1_fx, newdist1_fx );
+ metric_fx[st][add( shr( i, 1 ), 1 )] = L_add( curdist1_fx, newdist1_fx );
move32();
- quant[st][i / 2 + 1] = 0;
+ quant[st][add( shr( i, 1 ), 1 )] = 0;
move16();
- dquant[st][i / 2 + 1] = dqnt_LSB[step_LSB[st][0]][st];
+ dquant[st][add( shr( i, 1 ), 1 )] = dqnt_LSB[step_LSB[st][0]][st];
move16();
}
ELSE
{
- path[st][i / 2 + 1] = step_LSB[st][1];
+ path[st][add( shr( i, 1 ), 1 )] = step_LSB[st][1];
move16();
- metric_fx[st][i / 2 + 1] = L_add( curdist2_fx, newdist2_fx );
+ metric_fx[st][add( shr( i, 1 ), 1 )] = L_add( curdist2_fx, newdist2_fx );
move32();
- quant[st][i / 2 + 1] = 1;
+ quant[st][add( shr( i, 1 ), 1 )] = 1;
move16();
- dquant[st][i / 2 + 1] = dqnt_LSB[step_LSB[st][0]][st];
+ dquant[st][add( shr( i, 1 ), 1 )] = dqnt_LSB[step_LSB[st][0]][st];
move16();
}
- if ( GT_32( MaxPath, metric_fx[st][i / 2 + 1] ) )
+ if ( GT_32( MaxPath, metric_fx[st][add( shr( i, 1 ), 1 )] ) )
{
- MaxPath = L_add( metric_fx[st][i / 2 + 1], 0 );
+ MaxPath = L_add( metric_fx[st][add( shr( i, 1 ), 1 )], 0 );
}
}
/* Metric renormalization to prevent overflow */
FOR( st = 0; st < 4; st++ )
{
- metric_fx[st][i / 2 + 1] = L_sub( metric_fx[st][i / 2 + 1], MaxPath );
+ metric_fx[st][add( shr( i, 1 ), 1 )] = L_sub( metric_fx[st][add( shr( i, 1 ), 1 )], MaxPath );
move32();
}
}
@@ -1461,9 +1481,9 @@ void TCQLSB_fx(
FOR( ; i >= 0; i -= 2 )
{
- qout[i / 2] = quant[position][i / 2 + 1];
+ qout[i / 2] = quant[position][add( shr( i, 1 ), 1 )];
move16();
- dpath[i / 2] = dquant[position][i / 2 + 1];
+ dpath[i / 2] = dquant[position][add( shr( i, 1 ), 1 )];
move16();
IF( s_and( denc_LSB[position][qout[i / 2]], 0x1 ) )
@@ -1487,7 +1507,7 @@ void TCQLSB_fx(
move16();
}
- position = path[position][i / 2 + 1];
+ position = path[position][add( shr( i, 1 ), 1 )];
move16();
}
@@ -1495,6 +1515,7 @@ void TCQLSB_fx(
FOR( i = 0; i < bcount; i++ )
{
mbuffer_fx[i] = add( add( mbuffer_fx[i], shl( mbuffer_fx[i], 2 ) ), dbuffer_fx[i] );
+ move16();
}
return;
@@ -1506,8 +1527,9 @@ void TCQLSBdec_fx(
{
/*float q = QTCQ;*/
Word16 q = 1; /*x5*/
+ move16();
Word16 i, tmp, state = 0;
-
+ move16();
tmp = shr( bcount, 1 );
FOR( i = 0; i < tmp; i++ )
{
@@ -1519,16 +1541,18 @@ void TCQLSBdec_fx(
ELSE
{
mbuffer[2 * i] = negate( q );
+ move16();
}
IF( s_and( ddec_LSB[state][dpath[i]], 0x2 ) )
{
- mbuffer[2 * i + 1] = q;
+ mbuffer[add( shl( i, 1 ), 1 )] = q;
move16();
}
ELSE
{
- mbuffer[2 * i + 1] = negate( q );
+ mbuffer[add( shl( i, 1 ), 1 )] = negate( q );
+ move16();
}
state = dstep_LSB[state][dpath[i]];
@@ -1544,7 +1568,8 @@ void RestoreTCQ_fx(
Word16 *mbuffer )
{
Word16 i, nzpos = 0, flag_g1 = 0;
-
+ move16();
+ move16();
/* calculate actual nz positions */
nzpos = 0;
move16();
@@ -1576,6 +1601,7 @@ void RestoreTCQ_fx(
magn[i] = mbuffer[*bcount];
move16();
*bcount = add( *bcount, 1 );
+ move16();
}
}
}
@@ -1589,7 +1615,8 @@ void RestoreTCQdec_fx(
Word16 *mbuffer )
{
Word16 i, nzpos = 0, flag_g1 = 0;
-
+ move16();
+ move16();
/* calculate actual nz positions */
nzpos = 0;
move16();
@@ -1604,6 +1631,7 @@ void RestoreTCQdec_fx(
move16();
}
magn[i] = extract_l( L_mult0( magn[i], 5 ) );
+ move16();
}
}
@@ -1624,6 +1652,7 @@ void RestoreTCQdec_fx(
magn[i] = mbuffer[*bcount];
move16();
*bcount = add( *bcount, 1 );
+ move16();
}
}
}
@@ -1661,6 +1690,7 @@ void LoadTCQdata_fx(
FOR( i = 0; i < bcount; i++ )
{
dpath[i] = ar_decode_fx( arInst, uniform_model );
+ move16();
}
return;
@@ -1675,12 +1705,15 @@ Word32 encode_position_ari_fx(
{
Word16 i, tmp;
Word16 nz = 0, pulses = 0;
+ move16();
+ move16();
Word16 prob[TCQ_MAX_BAND_SIZE];
Word16 model_num_nz[TCQ_MAX_BAND_SIZE];
Word16 *cur_quants = quants;
Word16 integer, frac;
Word32 /*est_bits_frame_fx, */ btcq_fx = 0, bits_fx = 0, pnzp_fx;
-
+ move16();
+ move16();
Word32 cp, scp, fxone, fxp1;
Word16 pos;
@@ -1704,26 +1737,26 @@ Word32 encode_position_ari_fx(
btcq_fx = GetBitsFromPulses_fx( pulses, size );
/* Estimate TCQ bits */
- bits_fx = L_sub( table_logcum_fx[size + 1], L_add( table_logcum_fx[nz + 1], table_logcum_fx[size - nz + 1] ) );
- bits_fx = L_add( bits_fx, L_sub( btcq_fx, L_sub( table_logcum_fx[size + 1], L_add( table_logcum_fx[nz + 1], table_logcum_fx[size - nz + 1] ) ) ) );
- bits_fx = L_sub( bits_fx, L_sub( table_logcum_fx[pulses], L_add( table_logcum_fx[nz], table_logcum_fx[pulses - ( nz - 1 )] ) ) );
+ bits_fx = L_sub( table_logcum_fx[size + 1], L_add( table_logcum_fx[nz + 1], table_logcum_fx[add( sub( size, nz ), 1 )] ) );
+ bits_fx = L_add( bits_fx, L_sub( btcq_fx, L_sub( table_logcum_fx[size + 1], L_add( table_logcum_fx[nz + 1], table_logcum_fx[add( sub( size, nz ), 1 )] ) ) ) );
+ bits_fx = L_sub( bits_fx, L_sub( table_logcum_fx[pulses], L_add( table_logcum_fx[nz], table_logcum_fx[add( pulses, sub( nz, 1 ) )] ) ) );
bits_fx = L_sub( bits_fx, nz );
*est_bits_frame_fx = L_add( *est_bits_frame_fx, bits_fx );
-
+ move32();
/*caculate the #nz probability */
tmp = s_min( pulses, size );
FOR( i = 0; i < tmp; i++ )
{
pnzp_fx = L_sub( L_deposit_h( add( i, 1 ) ), btcq_fx );
- pnzp_fx = L_add( pnzp_fx, L_add( L_sub( table_logcum_fx[size + 1], L_add( table_logcum_fx[i + 2], table_logcum_fx[size - i] ) ),
- L_sub( table_logcum_fx[pulses], L_add( table_logcum_fx[i + 1], table_logcum_fx[pulses - i] ) ) ) );
+ pnzp_fx = L_add( pnzp_fx, L_add( L_sub( table_logcum_fx[size + 1], L_add( table_logcum_fx[i + 2], table_logcum_fx[sub( size, i )] ) ),
+ L_sub( table_logcum_fx[pulses], L_add( table_logcum_fx[i + 1], table_logcum_fx[sub( pulses, i )] ) ) ) );
pnzp_fx = L_add( pnzp_fx, 917498 ); /*16 */
IF( GT_32( pnzp_fx, 0 ) )
{
integer = extract_h( pnzp_fx );
frac = extract_l( L_shr( L_sub( pnzp_fx, L_deposit_h( integer ) ), 1 ) ); /*15 */
prob[i] = extract_h( L_shl( Pow2( integer, frac ), 16 ) ); /*0 */
-
+ move16();
/*zero probability will incur problems in ar_make_model() */
if ( prob[i] == 0 )
{
@@ -1742,7 +1775,7 @@ Word32 encode_position_ari_fx(
IF( GT_16( nz, 1 ) )
{
- ar_encode_fx( parenc, model_num_nz, nz - 1 ); /*encode #nz */
+ ar_encode_fx( parenc, model_num_nz, sub( nz, 1 ) ); /*encode #nz */
scp = L_add( fxp1, 0 );
pos = 0;
move16();
@@ -1759,11 +1792,11 @@ Word32 encode_position_ari_fx(
}
ELSE
{
- cp = L_sub( fxone, div_l( L_deposit_h( nz ), ( size - i ) ) );
+ cp = L_sub( fxone, div_l( L_deposit_h( nz ), sub( size, i ) ) );
}
scp = Mult_32_16( scp, extract_l( cp ) );
model_num_nz[pos + 1] = round_fx( L_shl( scp, 6 ) );
-
+ move16();
test();
test();
IF( ( model_num_nz[pos + 1] == 0 && scp > 0 ) || model_num_nz[pos] == model_num_nz[pos + 1] )
@@ -1806,8 +1839,8 @@ Word32 encode_position_ari_fx(
move16();
FOR( i = 0; i < size; i++ )
{
- model_num_nz[i + 1] = round_fx( L_shr( L_deposit_h( div_l( L_deposit_h( size - i - 1 ), size ) ), 1 ) );
-
+ model_num_nz[i + 1] = round_fx( L_shr( L_deposit_h( div_l( L_deposit_h( sub( sub( size, i ), 1 ) ), size ) ), 1 ) );
+ move16();
if ( cur_quants[i] != 0 )
{
pos = i;
@@ -1839,7 +1872,7 @@ Word32 encode_magnitude_usq_fx(
/*estimate fac bits */
- bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[npulses - nzpos + 1] ) );
+ bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[add( sub( npulses, nzpos ), 1 )] ) );
*est_frame_bits_fx = L_add( *est_frame_bits_fx, bits_fx );
test();
@@ -1860,11 +1893,13 @@ Word32 encode_magnitude_usq_fx(
tmp = sub( abs_s( magn_fx[i] ), 1 );
FOR( j = 0; j < tmp; j++ )
{
- magn_position[k++] = 0;
+ magn_position[k] = 0;
move16();
+ k = add( k, 1 );
}
- magn_position[k++] = 1;
+ magn_position[k] = 1;
move16();
+ k = add( k, 1 );
}
}
@@ -1892,7 +1927,7 @@ Word32 encode_magnitude_usq_fx(
}
scp = Mult_32_16( scp, extract_l( cp ) );
model_m[pos + 1] = round_fx( L_shl( scp, 6 ) );
-
+ move16();
test();
test();
IF( ( model_m[pos + 1] == 0 && scp > 0 ) || model_m[pos] == model_m[pos + 1] )
@@ -1903,8 +1938,7 @@ Word32 encode_magnitude_usq_fx(
ar_encode_fx( parenc, model_m, pos );
pos = 0;
move16();
- i--;
- move16();
+ i = sub( i, 1 );
scp = L_add( fxp1, 0 );
CONTINUE;
}
@@ -1914,17 +1948,16 @@ Word32 encode_magnitude_usq_fx(
ar_encode_fx( parenc, model_m, pos );
pos = 0;
move16();
- magnzp--;
+ magnzp = sub( magnzp, 1 );
move16();
scp = L_add( fxp1, 0 );
}
ELSE
{
- pos++;
- move16();
+ pos = add( pos, 1 );
}
- magnp--;
+ magnp = sub( magnp, 1 );
move16();
}
return bits_fx;
@@ -1945,6 +1978,9 @@ Word32 encode_magnitude_tcq_fx(
Word16 i, j;
Word32 st;
Word16 magn_mode[3] = { MAX_AR_FREQ, 0, 0 };
+ move16();
+ move16();
+ move16();
Word16 leftp = npulses; /*pulsesnum; */
Word16 leftnz = nzpos; /*nzpos; */
@@ -1952,8 +1988,9 @@ Word32 encode_magnitude_tcq_fx(
move16();
bits_fx = L_deposit_l( 0 );
- tcq_bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[npulses - ( nzpos - 1 )] ) );
+ tcq_bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[sub( npulses, sub( nzpos, 1 ) )] ) );
*est_frame_bits_fx = L_add( *est_frame_bits_fx, tcq_bits_fx );
+ move32();
test();
IF( EQ_16( nzpos, npulses ) || EQ_16( nzpos, 1 ) )
@@ -1989,7 +2026,7 @@ Word32 encode_magnitude_tcq_fx(
exp1 = sub( norm_s( num ), 1 );
exp2 = norm_s( denum );
prob1_fx = div_s( shl( num, exp1 ), shl( denum, exp2 ) ); /*15 + exp1 - exp2 */
- exp = 15 + exp1 - exp2;
+ exp = add( 15, sub( exp1, exp2 ) );
move16();
prob1_fx = shl( prob1_fx, sub( 15, exp ) );
prob0_fx = sub( MAX_16, prob1_fx );
@@ -2014,6 +2051,7 @@ Word32 encode_magnitude_tcq_fx(
}
magn_mode[1] = mult( prob1_fx, MAX_AR_FREQ );
+ move16();
IF( LT_16( j, sub( abs_s( magn_fx[i] ), 1 ) ) )
{
ar_encode_fx( parenc, magn_mode, 0 );
@@ -2046,6 +2084,7 @@ Word32 encode_signs_fx(
Word32 i, sign;
*est_frame_bits_fx = L_add( *est_frame_bits_fx, L_deposit_h( npos ) );
+ move32();
FOR( i = 0; i < size; i++ )
{
IF( magn[i] != 0 )
@@ -2076,6 +2115,8 @@ void decode_position_ari_fx(
Word16 integer, frac;
Word32 cp, scp, fxone, fxp1;
Word16 stpos = 0, pos, ovrflag = 0, temppos, storepos;
+ move16();
+ move16();
fxone = 32768;
move32();
@@ -2104,14 +2145,15 @@ void decode_position_ari_fx(
/*calculate the probability of #nz */
pnzp_fx = L_sub( L_deposit_h( add( i, 1 ) ), btcq_fx );
- pnzp_fx = L_add( pnzp_fx, L_add( L_sub( table_logcum_fx[size + 1], L_add( table_logcum_fx[i + 2], table_logcum_fx[size - i] ) ),
- L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[i + 1], table_logcum_fx[npulses - i] ) ) ) );
+ pnzp_fx = L_add( pnzp_fx, L_add( L_sub( table_logcum_fx[size + 1], L_add( table_logcum_fx[i + 2], table_logcum_fx[sub( size, i )] ) ),
+ L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[i + 1], table_logcum_fx[sub( npulses, i )] ) ) ) );
pnzp_fx = L_add( pnzp_fx, 917498 ); /*16 */
IF( GT_32( pnzp_fx, 0 ) )
{
integer = extract_h( pnzp_fx );
frac = extract_l( L_shr( L_sub( pnzp_fx, L_deposit_h( integer ) ), 1 ) ); /*15 */
prob[i] = extract_h( L_shl( Pow2( integer, frac ), 16 ) ); /*0 */
+ move16();
if ( prob[i] == 0 )
{
prob[i] = 1;
@@ -2127,6 +2169,7 @@ void decode_position_ari_fx(
ar_make_model_fx( prob, mode_num_nz, s_min( npulses, size ) );
*nz = add( 1, ar_decode_fx( pardec, mode_num_nz ) ); /*get #nz */
+ move16();
nzp = *nz;
move16();
IF( nzp == 1 )
@@ -2135,7 +2178,8 @@ void decode_position_ari_fx(
move16();
FOR( i = 0; i < size; i++ )
{
- mode_num_nz[i + 1] = round_fx( L_shr( L_deposit_h( div_l( L_deposit_h( size - i - 1 ), size ) ), 1 ) );
+ mode_num_nz[i + 1] = round_fx( L_shr( L_deposit_h( div_l( L_deposit_h( sub( sub( size, i ), 1 ) ), size ) ), 1 ) );
+ move16();
}
position[ar_decode_fx( pardec, mode_num_nz )] = 1;
@@ -2159,34 +2203,32 @@ void decode_position_ari_fx(
ovrflag = 0;
move16();
- IF( nzp == ( size - i ) )
+ IF( nzp == sub( size, i ) )
{
cp = L_deposit_l( 0 );
}
ELSE
{
- cp = L_sub( fxone, div_l( L_deposit_h( nzp ), ( size - i ) ) );
+ cp = L_sub( fxone, div_l( L_deposit_h( nzp ), sub( size, i ) ) );
}
scp = Mult_32_16( scp, extract_l( cp ) );
- mode_num_nz[i + 1 - storepos - stpos] = round_fx( L_shl( scp, 6 ) );
+ mode_num_nz[sub( sub( add( i, 1 ), storepos ), stpos )] = round_fx( L_shl( scp, 6 ) );
test();
test();
- IF( ( mode_num_nz[i + 1 - storepos - stpos] == 0 && scp > 0 ) || mode_num_nz[i - storepos - stpos] == mode_num_nz[i + 1 - storepos - stpos] )
+ IF( ( mode_num_nz[sub( sub( add( i, 1 ), storepos ), stpos )] == 0 && scp > 0 ) || EQ_16( mode_num_nz[sub( sub( i, storepos ), stpos )], mode_num_nz[sub( sub( add( i, 1 ), storepos ), stpos )] ) )
{
- mode_num_nz[i + 1 - storepos - stpos] = 0;
+ mode_num_nz[sub( sub( add( i, 1 ), storepos ), stpos )] = 0;
move16();
ovrflag = 1;
move16();
temppos = ar_decode_fx( pardec, mode_num_nz );
- move16();
- storepos += temppos;
- move16();
+ storepos = add( storepos, temppos );
scp = L_add( fxp1, 0 );
- IF( temppos == i - stpos ) /* esc transmitted */
+ IF( temppos == sub( i, stpos ) ) /* esc transmitted */
{
- i--;
+ i = sub( i, 1 );
move16();
}
ELSE
@@ -2197,7 +2239,7 @@ void decode_position_ari_fx(
}
IF( !ovrflag )
{
- pos = ar_decode_fx( pardec, mode_num_nz ) + storepos;
+ pos = add( ar_decode_fx( pardec, mode_num_nz ), storepos );
move16();
}
ELSE
@@ -2206,10 +2248,9 @@ void decode_position_ari_fx(
move16();
}
- position[stpos + pos] = 1;
- move16();
- stpos += pos + 1;
+ position[add( stpos, pos )] = 1;
move16();
+ stpos = add( stpos, add( pos, 1 ) );
}
}
}
@@ -2223,7 +2264,8 @@ void decode_position_ari_fx(
move16();
FOR( i = 0; i < size; i++ )
{
- mode_num_nz[i + 1] = round_fx( L_shr( L_deposit_h( div_l( L_deposit_h( size - i - 1 ), size ) ), 1 ) );
+ mode_num_nz[i + 1] = round_fx( L_shr( L_deposit_h( div_l( L_deposit_h( sub( sub( size, i ), 1 ) ), size ) ), 1 ) );
+ move16();
}
position[ar_decode_fx( pardec, mode_num_nz )] = 1;
@@ -2247,7 +2289,10 @@ void decode_magnitude_usq_fx(
{
Word16 i, magnp, magnzp;
Word16 magns[TCQ_MAX_BAND_SIZE], magncout = 0;
+ move16();
Word16 storemagn, ovrflag = 0, pos, tempmagn = 0, mmodel[MAX_PULSES + 2];
+ move16();
+ move16();
Word32 cp, scp, fxone, fxp1;
fxone = 32768;
@@ -2304,13 +2349,13 @@ void decode_magnitude_usq_fx(
ovrflag = 0;
move16();
- IF( magnzp == ( magnp - i ) )
+ IF( magnzp == sub( magnp, i ) )
{
cp = L_deposit_l( 0 );
}
ELSE
{
- cp = L_sub( fxone, div_l( L_deposit_h( magnzp ), magnp - i ) );
+ cp = L_sub( fxone, div_l( L_deposit_h( magnzp ), sub( magnp, i ) ) );
}
IF( cp == fxone )
@@ -2319,18 +2364,17 @@ void decode_magnitude_usq_fx(
}
scp = Mult_32_16( scp, extract_l( cp ) );
- mmodel[i + 1 - storemagn] = round_fx( L_shl( scp, 6 ) );
-
+ mmodel[sub( add( i, 1 ), storemagn )] = round_fx( L_shl( scp, 6 ) );
+ move16();
test();
test();
- IF( ( mmodel[i + 1 - storemagn] == 0 && scp > 0 ) || mmodel[i - storemagn] == mmodel[i + 1 - storemagn] )
+ IF( ( mmodel[sub( add( i, 1 ), storemagn )] == 0 && scp > 0 ) || EQ_16( mmodel[sub( i, storemagn )], mmodel[sub( add( i, 1 ), storemagn )] ) )
{
- mmodel[i + 1 - storemagn] = 0;
+ mmodel[sub( add( i, 1 ), storemagn )] = 0;
move16();
/* read data */
tempmagn = ar_decode_fx( pardec, mmodel );
- storemagn += tempmagn;
- move16();
+ storemagn = add( storemagn, tempmagn );
IF( tempmagn < i )
{
@@ -2343,8 +2387,7 @@ void decode_magnitude_usq_fx(
{
/* esc code */
scp = L_add( fxp1, 0 );
- i--;
- move16();
+ i = sub( i, 1 );
}
}
}
@@ -2359,12 +2402,9 @@ void decode_magnitude_usq_fx(
out[magncout] = ar_decode_fx( pardec, mmodel ) + storemagn + 1;
move16();
}
- magnp -= out[magncout];
- move16();
- magnzp--;
- move16();
- magncout++;
- move16();
+ magnp = sub( magnp, out[magncout] );
+ magnzp = sub( magnzp, 1 );
+ magncout = add( magncout, 1 );
IF( magnzp == 0 ) /* last magnitude generation */
{
@@ -2372,7 +2412,7 @@ void decode_magnitude_usq_fx(
{
IF( positions[pos] != 0 )
{
- out[magncout] = magnp + 1;
+ out[magncout] = add( magnp, 1 );
move16();
return;
}
@@ -2380,7 +2420,7 @@ void decode_magnitude_usq_fx(
{
out[magncout] = 0;
move16();
- magncout++;
+ magncout = add( magncout, 1 );
move16();
}
}
@@ -2391,8 +2431,7 @@ void decode_magnitude_usq_fx(
{
out[magncout] = positions[pos];
move16();
- magncout++;
- move16();
+ magncout = add( magncout, 1 );
}
return;
}
@@ -2401,8 +2440,7 @@ void decode_magnitude_usq_fx(
{
out[magncout] = 0;
move16();
- magncout++;
- move16();
+ magncout = add( magncout, 1 );
}
}
@@ -2424,11 +2462,16 @@ void decode_mangitude_tcq_fx(
Word16 i, j, symbol, st;
Word16 leftp = npulses; /*pulsesnum; */
- Word16 leftnz = nzpos; /*nzpos; */
+ move16();
+ Word16 leftnz = nzpos; /*nzpos; */
+ move16();
Word16 magn_mode[3] = { MAX_AR_FREQ, 0, 0 };
+ move16();
+ move16();
+ move16();
bits_fx = L_deposit_l( 0 );
- tcq_bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[npulses - ( nzpos - 1 )] ) );
+ tcq_bits_fx = L_sub( table_logcum_fx[npulses], L_add( table_logcum_fx[nzpos], table_logcum_fx[sub( npulses, sub( nzpos, 1 ) )] ) );
IF( EQ_16( nzpos, npulses ) )
{
@@ -2462,6 +2505,7 @@ void decode_mangitude_tcq_fx(
}
out[i] = positions[i];
+ move16();
IF( positions[i] != 0 )
{
/*generate the trellis path */
@@ -2483,7 +2527,7 @@ void decode_mangitude_tcq_fx(
exp1 = sub( norm_s( num ), 1 );
exp2 = norm_s( denum );
prob1_fx = div_s( shl( num, exp1 ), shl( denum, exp2 ) ); /*15 + exp1 - exp2 */
- exp = 15 + exp1 - exp2;
+ exp = add( 15, sub( exp1, exp2 ) );
prob1_fx = shl( prob1_fx, sub( 15, exp ) );
prob0_fx = sub( MAX_16, prob1_fx );
}
@@ -2514,7 +2558,7 @@ void decode_mangitude_tcq_fx(
/*magn_mode[1] = (short)(prob1 * MAX_AR_FREQ); */
magn_mode[1] = mult( prob1_fx, MAX_AR_FREQ );
-
+ move16();
IF( ar_decode_fx( pardec, magn_mode ) )
{
exp1 = norm_s( prob1_fx );
@@ -2564,6 +2608,7 @@ void decode_mangitude_tcq_fx(
IF( positions[i] != 0 )
{
out[i] = add( sub( leftp, leftnz ), 1 );
+ move16();
}
}
@@ -2572,6 +2617,7 @@ void decode_mangitude_tcq_fx(
{
/*update the surplus */
*surplus_fx = L_add( *surplus_fx, L_sub( tcq_bits_fx, L_shl( bits_fx, 1 ) ) );
+ move32();
}
return;
@@ -2594,6 +2640,7 @@ void decode_signs_fx(
if ( tmp <= 0 )
{
out[i] = negate( out[i] );
+ move16();
}
}
}
@@ -2608,18 +2655,19 @@ Word16 GetScale_fx(
)
{
Word16 pulses = MAX_PULSES, p_est, exp, exp1, exp2, magicnum;
+ move16();
Word32 t, a, b, ab, estbits_fx = 0;
-
+ move32();
magicnum = 24773;
move16(); /*Q17: 0.188992013101951f; */
t = L_shr( L_mult( magicnum, blen ), 2 );
exp = norm_l( t );
- a = L_shl( 14 - exp, 15 ) + Log2_norm_lc( L_shl( t, exp ) );
+ a = L_add( L_shl( sub( 14, exp ), 15 ), Log2_norm_lc( L_shl( t, exp ) ) );
exp1 = sub( norm_l( bits_fx ), 1 );
- exp2 = norm_s( blen - 1 );
- b = L_shr( L_deposit_l( div_l( L_shl( bits_fx, exp1 ), shl( blen - 1, exp2 ) ) ), exp1 - exp2 );
+ exp2 = norm_s( sub( blen, 1 ) );
+ b = L_shr( L_deposit_l( div_l( L_shl( bits_fx, exp1 ), shl( sub( blen, 1 ), exp2 ) ) ), sub( exp1, exp2 ) );
ab = L_add( a, b );
@@ -2639,6 +2687,7 @@ Word16 GetScale_fx(
IF( surplus_fx != 0 )
{
*surplus_fx = L_add( *surplus_fx, L_sub( bits_fx, estbits_fx ) );
+ move16();
}
return pulses;
diff --git a/lib_com/tcx_ltp_fx.c b/lib_com/tcx_ltp_fx.c
index 0c3190705a143769f8d5585133a26fe20be63fe0..9d18d4841c273cfe6ccb485508e231013cee98a9 100644
--- a/lib_com/tcx_ltp_fx.c
+++ b/lib_com/tcx_ltp_fx.c
@@ -3,8 +3,7 @@
====================================================================================*/
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "cnst.h"
#include "basop_util.h"
#include "rom_com.h"
@@ -402,6 +401,7 @@ void predict_signal(
const Word16 *x0, *win;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
x0 = &excI[-T0 - 1];
frac = negate( frac );
@@ -453,6 +453,7 @@ static void tcx_ltp_synth_filter(
const Word16 *v0, *v1;
const Word16 *w0, *w1;
Word16 alpha, step = 0; /* initialize just to avoid compiler warning */
+ move16();
Word16 i, j, k, L;
IF( gain > 0 )
@@ -663,7 +664,7 @@ static void tcx_ltp_synth_filter32(
L_tmp2 = Mpy_32_16_r( L_tmp2, alpha );
#ifdef BASOP_NOGLOB
L_tmp2 = L_add_sat( synth[j], L_tmp2 );
- IF( zir != NULL )
+ if ( zir != NULL )
{
L_tmp2 = L_sub_sat( L_tmp2, zir[j] );
}
@@ -726,12 +727,13 @@ static void tcx_ltp_synth_filter_10(
assert( GE_16( filtIdx, 0 ) );
w0 = &tcxLtpFilters[filtIdx].filt[pitch_fr];
- w1 = &tcxLtpFilters[filtIdx].filt[pitch_res - pitch_fr];
+ w1 = &tcxLtpFilters[filtIdx].filt[sub( pitch_res, pitch_fr )];
v0 = &tcxLtpFilters[filtIdx].filt[0];
v1 = &tcxLtpFilters[filtIdx].filt[pitch_res];
L = tcxLtpFilters[filtIdx].length;
curr_gain = gain;
+ move16();
gain_step = negate( gain ) / length;
for ( j = 0; j < length; j++ )
@@ -784,7 +786,7 @@ static void tcx_ltp_synth_filter_10_fx(
y0 = in;
y1 = y0 - 1;
- assert( GE_16( filtIdx, 0 ) );
+ assert( filtIdx >= 0 );
w0 = &tcxLtpFilters[filtIdx].filt[pitch_fr];
w1 = &tcxLtpFilters[filtIdx].filt[pitch_res - pitch_fr];
@@ -793,12 +795,15 @@ static void tcx_ltp_synth_filter_10_fx(
L = tcxLtpFilters[filtIdx].length;
curr_gain = gain;
- gain_step = negate( gain ) / length;
+ move16();
+ gain_step = idiv1616( negate( gain ), length ); // TODO
for ( j = 0; j < length; j++ )
{
s = 0;
+ move16();
s2 = 0;
+ move16();
for ( i = 0, k = 0; i < L; i++, k += pitch_res )
{
@@ -810,7 +815,7 @@ static void tcx_ltp_synth_filter_10_fx(
// out[j] = in[j] - curr_gain * s2 * ALPHA + curr_gain * s;
out[j] = L_add_sat( in[j], Mpy_32_16_1( L_sub_sat( s, Mpy_32_16_1( s2, ALPHA ) ), curr_gain ) );
-
+ move32();
x0++;
x1++;
y0++;
@@ -845,7 +850,7 @@ static void tcx_ltp_synth_filter_01(
y0 = in;
y1 = y0 - 1;
- assert( GE_16( filtIdx, 0 ) );
+ assert( filtIdx >= 0 );
w0 = &tcxLtpFilters[filtIdx].filt[pitch_fr];
w1 = &tcxLtpFilters[filtIdx].filt[pitch_res - pitch_fr];
@@ -854,12 +859,16 @@ static void tcx_ltp_synth_filter_01(
L = tcxLtpFilters[filtIdx].length;
curr_gain = 0;
- gain_step = gain / length;
+ move16();
+ // gain_step = gain / length; // TODO
+ gain_step = idiv1616( gain, length ); // TODO
for ( j = 0; j < length; j++ )
{
s = 0;
+ move16();
s2 = 0;
+ move16();
for ( i = 0, k = 0; i < L; i++, k = add( k, pitch_res ) )
{
@@ -871,7 +880,7 @@ static void tcx_ltp_synth_filter_01(
// out[j] = in[j] - curr_gain * s2 * ALPHA + curr_gain * s;
out[j] = add_sat( in[j], mult_r_sat( curr_gain, sub_sat( round_fx_sat( s ), mult_r_sat( round_fx_sat( s2 ), ALPHA ) ) ) );
-
+ move32();
x0++;
x1++;
@@ -907,7 +916,7 @@ static void tcx_ltp_synth_filter_01_fx(
y0 = in;
y1 = y0 - 1;
- assert( GE_16( filtIdx, 0 ) );
+ assert( filtIdx >= 0 );
w0 = &tcxLtpFilters[filtIdx].filt[pitch_fr];
w1 = &tcxLtpFilters[filtIdx].filt[pitch_res - pitch_fr];
@@ -916,12 +925,16 @@ static void tcx_ltp_synth_filter_01_fx(
L = tcxLtpFilters[filtIdx].length;
curr_gain = 0;
- gain_step = gain / length;
+ move16();
+ // gain_step = gain / length; // TODO
+ gain_step = idiv1616( gain, length ); // TODO
for ( j = 0; j < length; j++ )
{
s = 0;
+ move16();
s2 = 0;
+ move16();
for ( i = 0, k = 0; i < L; i++, k = add( k, pitch_res ) )
{
@@ -933,7 +946,7 @@ static void tcx_ltp_synth_filter_01_fx(
// out[j] = in[j] - curr_gain * s2 * ALPHA + curr_gain * s;
out[j] = L_add_sat( in[j], Mpy_32_16_r( L_sub_sat( s, Mpy_32_16_1( s2, ALPHA ) ), curr_gain ) );
-
+ move32();
x0++;
x1++;
@@ -992,7 +1005,7 @@ static void tcx_ltp_synth_filter_11_unequal_pitch(
y0 = in;
y1 = y0 - 1;
- assert( GE_16( filtIdx, 0 ) && GE_16( prev_filtIdx, 0 ) );
+ assert( ( filtIdx >= 0 ) && ( prev_filtIdx >= 0 ) );
w0 = &tcxLtpFilters[prev_filtIdx].filt[prev_pitch_fr];
w1 = &tcxLtpFilters[prev_filtIdx].filt[prev_pitch_res - prev_pitch_fr];
@@ -1000,6 +1013,7 @@ static void tcx_ltp_synth_filter_11_unequal_pitch(
v1 = &tcxLtpFilters[prev_filtIdx].filt[prev_pitch_res];
prev_L = tcxLtpFilters[prev_filtIdx].length;
+ move16();
p0 = &tcxLtpFilters[filtIdx].filt[cur_pitch_fr];
p1 = &tcxLtpFilters[filtIdx].filt[pitch_res - cur_pitch_fr];
@@ -1007,15 +1021,20 @@ static void tcx_ltp_synth_filter_11_unequal_pitch(
q1 = &tcxLtpFilters[filtIdx].filt[pitch_res];
L = tcxLtpFilters[filtIdx].length;
+ move16();
/* 1. decreasing gain filter. The first filter unit with the parameters associated to the previous interval and scaling towards 0 */
gain = prev_gain;
- gain_step = negate( prev_gain ) / length;
+ move16();
+ // gain_step = negate( prev_gain ) / length; // TODO
+ gain_step = idiv1616( negate( prev_gain ), length ); // TODO
for ( j = 0; j < length; j++ )
{
s = 0;
+ move16();
s2 = 0;
+ move16();
for ( i = 0, k = 0; i < prev_L; i++, k += prev_pitch_res )
{
@@ -1047,12 +1066,15 @@ static void tcx_ltp_synth_filter_11_unequal_pitch(
/* 2. increasing gain filter. The second filter unit with the parameters associated to the current interval and scaling from 0 towards current gain */
gain = 0;
- gain_step = cur_gain / length;
+ move16();
+ gain_step = cur_gain / length; // TODO
for ( j = 0; j < length; j++ )
{
s3 = 0;
+ move16();
s4 = 0;
+ move16();
for ( i = 0, k = 0; i < L; i++, k += pitch_res )
{
@@ -1064,7 +1086,7 @@ static void tcx_ltp_synth_filter_11_unequal_pitch(
// out[j] = *(temp_ptr + j) - gain * s4 * ALPHA + gain * s3;
out[j] = add_sat( *( temp_ptr + j ), mult_r_sat( gain, sub_sat( round_fx_sat( s3 ), mult_r_sat( round_fx_sat( s4 ), ALPHA ) ) ) );
-
+ move32();
l0++;
l1++;
@@ -1120,6 +1142,7 @@ static void tcx_ltp_synth_filter_11_unequal_pitch_fx(
v1 = &tcxLtpFilters[prev_filtIdx].filt[prev_pitch_res];
prev_L = tcxLtpFilters[prev_filtIdx].length;
+ move16();
p0 = &tcxLtpFilters[filtIdx].filt[cur_pitch_fr];
p1 = &tcxLtpFilters[filtIdx].filt[pitch_res - cur_pitch_fr];
@@ -1127,15 +1150,19 @@ static void tcx_ltp_synth_filter_11_unequal_pitch_fx(
q1 = &tcxLtpFilters[filtIdx].filt[pitch_res];
L = tcxLtpFilters[filtIdx].length;
+ move16();
/* 1. decreasing gain filter. The first filter unit with the parameters associated to the previous interval and scaling towards 0 */
gain = prev_gain;
- gain_step = negate( prev_gain ) / length;
+ move16();
+ gain_step = idiv1616( negate( prev_gain ), length ); // TODOD
for ( j = 0; j < length; j++ )
{
s = 0;
+ move16();
s2 = 0;
+ move16();
for ( i = 0, k = 0; i < prev_L; i++, k += prev_pitch_res )
{
@@ -1147,7 +1174,7 @@ static void tcx_ltp_synth_filter_11_unequal_pitch_fx(
// out[j] = in[j] - gain * s2 * ALPHA + gain * s;
out[j] = L_add_sat( in[j], Mpy_32_16_r( L_sub_sat( s, Mpy_32_16_1( s2, ALPHA ) ), gain ) );
-
+ move32();
x0++;
x1++;
y0++;
@@ -1167,12 +1194,15 @@ static void tcx_ltp_synth_filter_11_unequal_pitch_fx(
/* 2. increasing gain filter. The second filter unit with the parameters associated to the current interval and scaling from 0 towards current gain */
gain = 0;
- gain_step = cur_gain / length;
+ move16();
+ gain_step = cur_gain / length; // TODO
for ( j = 0; j < length; j++ )
{
s3 = 0;
+ move16();
s4 = 0;
+ move16();
for ( i = 0, k = 0; i < L; i++, k += pitch_res )
{
@@ -1184,7 +1214,7 @@ static void tcx_ltp_synth_filter_11_unequal_pitch_fx(
// out[j] = *(temp_ptr + j) - gain * s4 * ALPHA + gain * s3;
out[j] = L_add_sat( *( temp_ptr + j ), Mpy_32_16_r( L_sub_sat( s3, Mpy_32_16_1( s4, ALPHA ) ), gain ) );
-
+ move32();
l0++;
l1++;
@@ -1309,9 +1339,10 @@ void tcx_ltp_post(
}
filtIdx = 0; /* just to avoid comilation warnings */
+ move16();
tcx_buf_len = NS2SA( st->output_Fs, TCXLTP_DELAY_NS );
SideInfoOnly = 0;
-
+ move16();
if ( GE_32( total_brate, HQ_96k ) )
{
SideInfoOnly = 1;
@@ -1327,16 +1358,17 @@ void tcx_ltp_post(
move16();
}
- IF( EQ_16( core, ACELP_CORE ) )
+ IF( core == ACELP_CORE )
{
bfi = 0;
+ move16();
pitch_int = 0;
- pitch_fr = 0;
- gain = 0;
- L_frame_core = st->L_frame_past;
move16();
+ pitch_fr = 0;
move16();
+ gain = 0;
move16();
+ L_frame_core = st->L_frame_past;
move16();
}
ELSE
@@ -1388,6 +1420,7 @@ void tcx_ltp_post(
ELSE IF( bfi == 0 )
{
/* LTP and good frame */
+ test();
IF( EQ_16( st->element_mode, EVS_MONO ) ) /* hard tunings for EVS_MONO, HQ_48k is TCX only */
{
IF( NE_16( output_frame, L_frame_core ) )
@@ -1544,29 +1577,36 @@ void tcx_ltp_post(
test();
test();
test();
- //#ifdef IVAS_CODE_TCX_LTP
+ // #ifdef IVAS_CODE_TCX_LTP
if ( st->element_mode != EVS_MONO )
{
- if ( gain == 0 && hTcxLtpDec->tcxltp_gain_post_prev == 0 )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( gain == 0 && hTcxLtpDec->tcxltp_gain_post_prev == 0 )
{
/* The filtering is deactivated, just copy input to the output */
Copy( sig_in + delay, sig_out + delay, L_transition );
}
- else if ( gain == 0 && hTcxLtpDec->tcxltp_gain_post_prev != 0 )
+ ELSE IF( gain == 0 && hTcxLtpDec->tcxltp_gain_post_prev != 0 )
{
/* Filtering with the first filter unit */
tcx_ltp_synth_filter_10( sig_out + delay, sig_in + delay, L_transition, hTcxLtpDec->tcxltp_pitch_int_post_prev, hTcxLtpDec->tcxltp_pitch_fr_post_prev, hTcxLtpDec->tcxltp_gain_post_prev, st->pit_res_max_past, hTcxLtpDec->tcxltp_filt_idx_prev );
}
- else if ( gain != 0 && hTcxLtpDec->tcxltp_gain_post_prev == 0 )
+ ELSE IF( gain != 0 && hTcxLtpDec->tcxltp_gain_post_prev == 0 )
{
/* Filtering with the second filter unit */
tcx_ltp_synth_filter_01( sig_out + delay, sig_in + delay, L_transition, pitch_int, pitch_fr, gain, st->pit_res_max, filtIdx );
}
- else if ( gain == hTcxLtpDec->tcxltp_gain_post_prev && pitch_int == hTcxLtpDec->tcxltp_pitch_int_post_prev && pitch_fr == hTcxLtpDec->tcxltp_pitch_fr_post_prev && st->pit_res_max == st->pit_res_max_past && filtIdx == hTcxLtpDec->tcxltp_filt_idx_prev )
+ ELSE IF( EQ_16( gain, hTcxLtpDec->tcxltp_gain_post_prev ) && EQ_16( pitch_int, hTcxLtpDec->tcxltp_pitch_int_post_prev ) && EQ_16( pitch_fr, hTcxLtpDec->tcxltp_pitch_fr_post_prev ) && EQ_16( st->pit_res_max, st->pit_res_max_past ) && EQ_16( filtIdx, hTcxLtpDec->tcxltp_filt_idx_prev ) )
{
tcx_ltp_synth_filter( sig_out + delay, sig_in + delay, L_transition, pitch_int, pitch_fr, gain, st->pit_res_max, NULL, 0, filtIdx );
}
- else
+ ELSE
{
/* Filtering with the first filter unit, followed by the filtering with the second filter unit */
tcx_ltp_synth_filter_11_unequal_pitch( sig_out + delay, sig_in + delay, L_transition, pitch_int, pitch_fr, gain, st->pit_res_max, filtIdx,
@@ -1574,8 +1614,12 @@ void tcx_ltp_post(
}
}
ELSE
- //#endif
+ // #endif
{
+ test();
+ test();
+ test();
+ test();
IF( gain == 0 && hTcxLtpDec->tcxltp_gain_post_prev == 0 )
{
Copy( sig_in + delay, sig_out + delay, L_transition );
@@ -1626,6 +1670,7 @@ void tcx_ltp_post(
hTcxLtpDec->tcxltp_filt_idx_prev = filtIdx;
move16();
st->pit_res_max_past = st->pit_res_max;
+ move16();
Copy( sig_out, hTcxLtpDec->tcxltp_mem_out, output_frame );
}
@@ -1653,14 +1698,16 @@ void tcx_ltp_post32(
move32();
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- total_brate = st->bits_frame_nominal * FRAMES_PER_SEC;
+ total_brate = st->bits_frame_nominal * FRAMES_PER_SEC; // TDO
move32();
}
filtIdx = 0; /* just to avoid comilation warnings */
+ move16();
tcx_buf_len = NS2SA_fx2( st->output_Fs, TCXLTP_DELAY_NS );
+ move16();
SideInfoOnly = 0;
-
+ move16();
if ( GE_32( total_brate, HQ_96k ) )
{
SideInfoOnly = 1;
@@ -1745,7 +1792,7 @@ void tcx_ltp_post32(
pitch_int = idiv1616U( tmp, st->pit_res_max );
pitch_fr = sub( tmp, imult1616( pitch_int, st->pit_res_max ) );
}
- IF( EQ_16( st->element_mode, EVS_MONO ) ) /* hard tunings for EVS_MONO, HQ_48k is TCX only */
+ IF( st->element_mode == EVS_MONO ) /* hard tunings for EVS_MONO, HQ_48k is TCX only */
{
test();
test();
@@ -1893,7 +1940,7 @@ void tcx_ltp_post32(
test();
test();
test();
- //#ifdef IVAS_CODE_TCX_LTP
+ // #ifdef IVAS_CODE_TCX_LTP
if ( st->element_mode != EVS_MONO )
{
if ( gain == 0 && hTcxLtpDec->tcxltp_gain_post_prev == 0 )
@@ -1923,7 +1970,7 @@ void tcx_ltp_post32(
}
}
ELSE
- //#endif
+ // #endif
{
IF( gain == 0 && hTcxLtpDec->tcxltp_gain_post_prev == 0 )
{
diff --git a/lib_com/tcx_mdct_fx.c b/lib_com/tcx_mdct_fx.c
index 76f8e414ae432665390c09b4123fbb1cde003eb8..474f8779bf69aeaaa277a085b36fa97d759cc863 100644
--- a/lib_com/tcx_mdct_fx.c
+++ b/lib_com/tcx_mdct_fx.c
@@ -5,8 +5,7 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
static Word16 TCX_MDCT_GetScaleFactor(
@@ -30,7 +29,7 @@ static Word16 TCX_MDCT_GetScaleFactor(
*factor_e = 0;
move16();
}
- ELSE IF( EQ_16( L, 4 * NORM_MDCT_FACTOR ) )
+ ELSE IF( EQ_16( L, shl( NORM_MDCT_FACTOR, 2 ) ) )
{
factor = 16384;
move16();
@@ -109,6 +108,7 @@ void TCX_MDCT(
#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
factor = TCX_MDCT_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &factor_e );
*y_e = add( *y_e, factor_e );
@@ -119,13 +119,13 @@ void TCX_MDCT(
/* Init */
FOR( i = 0; i < m / 2; i++ )
{
- y[m / 2 + r / 2 + i] = L_mult( x[l + m / 2 - 1 - i], neg_factor );
+ y[add( add( shr( m, 1 ), shr( r, 1 ) ), i )] = L_mult( x[sub( sub( add( l, shr( m, 1 ) ), 1 ), i )], neg_factor );
move32();
}
FOR( i = 0; i < l / 2; i++ )
{
#ifdef BASOP_NOGLOB
- y[m / 2 + r / 2 + m / 2 + i] = L_msu_o( L_mult( x[i], factor ), x[l - 1 - i], factor, &Overflow );
+ y[add( add( add( shr( m, 1 ), shr( r, 1 ) ), shr( m, 1 ) ), i )] = L_msu_o( L_mult( x[i], factor ), x[sub( sub( l, 1 ), i )], factor, &Overflow );
#else /* BASOP_NOGLOB */
y[m / 2 + r / 2 + m / 2 + i] = L_msu( L_mult( x[i], factor ), x[l - 1 - i], factor );
#endif /* BASOP_NOGLOB */
@@ -133,13 +133,13 @@ void TCX_MDCT(
}
FOR( i = 0; i < m / 2; i++ )
{
- y[m / 2 + r / 2 - 1 - i] = L_mult( x[l + m / 2 + i], neg_factor );
+ y[sub( sub( add( shr( m, 1 ), shr( r, 1 ) ), 1 ), i )] = L_mult( x[add( add( l, shr( m, 1 ) ), i )], neg_factor );
move32();
}
FOR( i = 0; i < r / 2; i++ )
{
#ifdef BASOP_NOGLOB
- y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac_o( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], neg_factor, &Overflow );
+ y[sub( sub( sub( add( shr( m, 1 ), shr( r, 1 ) ), 1 ), shr( m, 1 ) ), i )] = L_mac_o( L_mult( x[add( add( l, m ), i )], neg_factor ), x[sub( sub( add( add( l, m ), r ), 1 ), i )], neg_factor, &Overflow );
#else /* BASOP_NOGLOB */
y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], neg_factor );
#endif /* BASOP_NOGLOB */
@@ -147,8 +147,10 @@ void TCX_MDCT(
}
*y_e = sub( 15, *y_e );
+ move16();
edct_fx( y, y, l / 2 + m + r / 2, y_e );
*y_e = sub( 15 - 1, *y_e );
+ move16();
return;
}
@@ -170,6 +172,7 @@ void TCX_MDST(
#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
factor = TCX_MDCT_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &factor_e );
*y_e = add( *y_e, factor_e );
@@ -179,13 +182,13 @@ void TCX_MDST(
/* Init */
FOR( i = 0; i < m / 2; i++ )
{
- y[m / 2 + r / 2 + i] = L_mult( x[l + m / 2 - 1 - i], neg_factor );
+ y[add( add( shr( m, 1 ), shr( r, 1 ) ), i )] = L_mult( x[sub( sub( add( l, shr( m, 1 ) ), 1 ), i )], neg_factor );
move32();
}
FOR( i = 0; i < l / 2; i++ )
{
#ifdef BASOP_NOGLOB
- y[m / 2 + r / 2 + m / 2 + i] = L_msu_o( L_mult( x[i], neg_factor ), x[l - 1 - i], factor, &Overflow );
+ y[add( add( add( shr( m, 1 ), shr( r, 1 ) ), shr( m, 1 ) ), i )] = L_msu_o( L_mult( x[i], neg_factor ), x[sub( sub( l, 1 ), i )], factor, &Overflow );
#else /* BASOP_NOGLOB */
y[m / 2 + r / 2 + m / 2 + i] = L_msu( L_mult( x[i], neg_factor ), x[l - 1 - i], factor );
#endif
@@ -193,13 +196,13 @@ void TCX_MDST(
}
FOR( i = 0; i < m / 2; i++ )
{
- y[m / 2 + r / 2 - 1 - i] = L_mult( x[l + m / 2 + i], neg_factor );
+ y[sub( sub( add( shr( m, 1 ), shr( r, 1 ) ), 1 ), i )] = L_mult( x[add( add( l, shr( m, 1 ) ), i )], neg_factor );
move32();
}
FOR( i = 0; i < r / 2; i++ )
{
#ifdef BASOP_NOGLOB
- y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac_sat( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], factor );
+ y[sub( sub( sub( add( shr( m, 1 ), shr( r, 1 ) ), 1 ), m / 2 ), i )] = L_mac_sat( L_mult( x[add( add( l, m ), i )], neg_factor ), x[sub( sub( add( add( l, m ), r ), 1 ), i )], factor );
#else
y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], factor );
#endif
@@ -207,7 +210,7 @@ void TCX_MDST(
}
*y_e = sub( 15, *y_e );
- edst_fx( y, y, l / 2 + m + r / 2, y_e );
+ edst_fx( y, y, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), y_e );
*y_e = sub( 15 - 1, *y_e );
return;
}
@@ -233,7 +236,7 @@ void TCX_MDCT_Inverse(
R2 = shr( r, 1 );
x_e = sub( 15, x_e );
- edct_fx( x, tmp_buf + L2, l / 2 + m + r / 2, &x_e );
+ edct_fx( x, tmp_buf + L2, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &x_e );
x_e = sub( 15, x_e );
fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e );
@@ -247,19 +250,22 @@ void TCX_MDCT_Inverse(
FOR( i = 0; i < R2; i++ )
{
#ifdef BASOP_NOGLOB
- y[l + m + R2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); /* fold out right end of DCT */
+ y[add( add( add( l, m ), R2 ), i )] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[add( L2, i )], negfac ), s ) ); /* fold out right end of DCT */
#else
y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); /* fold out right end of DCT */
#endif
+
+ move16();
}
FOR( i = 0; i < L2; i++ )
{
#ifdef BASOP_NOGLOB
- y[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], fac ), s ) ); /* negate, fold out left end of DCT */
+ y[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[add( add( add( L2, m ), R2 ), i )], fac ), s ) ); /* negate, fold out left end of DCT */
#else
y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], fac ), s ) ); /* negate, fold out left end of DCT */
#endif
+ move16();
}
FOR( i = 0; i < shr( add( L2, add( m, R2 ) ), 1 ); i++ )
@@ -267,14 +273,15 @@ void TCX_MDCT_Inverse(
Word16 f;
#ifdef BASOP_NOGLOB
- f = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) );
- y[L2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT */
+ f = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[add( L2, i )], negfac ), s ) );
+ y[add( L2, i )] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[sub( sub( add( add( l, m ), R2 ), 1 ), i )], negfac ), s ) ); /* time-reverse mid of DCT */
#else
f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) );
y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT */
#endif
move16();
- y[l + m + R2 - 1 - i] = f;
+ y[sub( sub( add( add( l, m ), R2 ), 1 ), i )] = f;
+ move16();
}
}
@@ -290,6 +297,8 @@ void TCX_MDST_Inverse_fx(
Word16 i, fac, negfac, s;
Word16 L2 = l, R2 = r;
+ move16();
+ move16();
Word32 tmp_buf[N_MAX + L_MDCT_OVLP_MAX / 2];
Word16 fac_e;
@@ -297,7 +306,7 @@ void TCX_MDST_Inverse_fx(
R2 = shr( r, 1 );
x_e = sub( 15, x_e );
- edst_fx( x, tmp_buf + L2, l / 2 + m + r / 2, &x_e );
+ edst_fx( x, tmp_buf + L2, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &x_e );
x_e = sub( 15, x_e );
fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e );
@@ -310,23 +319,26 @@ void TCX_MDST_Inverse_fx(
FOR( i = 0; i < R2; i++ )
{
- y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); /* fold out right end of DCT */
+ y[add( add( add( l, m ), R2 ), i )] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[add( L2, i )], fac ), s ) ); /* fold out right end of DCT */
+ move16();
}
FOR( i = 0; i < L2; i++ )
{
- y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], negfac ), s ) ); /* negate, fold out left end of DCT */
+ y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[add( add( add( L2, m ), R2 ), i )], negfac ), s ) ); /* negate, fold out left end of DCT */
+ move16();
}
FOR( i = 0; i < shr( add( L2, add( m, R2 ) ), 1 ); i++ )
{
Word16 f;
- f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) );
+ f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[add( L2, i )], fac ), s ) );
- y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT */
+ y[add( L2, i )] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[sub( sub( add( add( l, m ), R2 ), 1 ), i )], negfac ), s ) ); /* time-reverse mid of DCT */
+ move16();
+ y[sub( sub( add( add( l, m ), R2 ), 1 ), i )] = negate( f );
move16();
- y[l + m + R2 - 1 - i] = negate( f );
}
}
@@ -354,37 +366,54 @@ void TCX_MDXT_Inverse_fx(
set32_fx( tmp_buf, 0, N_MAX + L_MDCT_OVLP_MAX / 2 );
- edxt_fx( x, tmp_buf + L2, L2 + m + R2, kernel_type, TRUE );
+ edxt_fx( x, tmp_buf + L2, add( add( L2, m ), R2 ), kernel_type, TRUE );
fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e );
x_e = add( x_e, fac_e );
negfac = negate( fac );
- signLeft = ( kernel_type >= MDCT_II ? negfac : fac );
- signRight = ( kernel_type & 1 ? fac : negfac );
+ IF( GE_16( kernel_type, MDCT_II ) )
+ {
+ signLeft = negfac;
+ }
+ ELSE
+ {
+ signLeft = fac;
+ }
+ // signRight = ( kernel_type & 1 ? fac : negfac );
+ IF( L_and( kernel_type, 1 ) )
+ {
+ signRight = fac;
+ }
+ ELSE
+ {
+ signRight = negfac;
+ }
s = x_e;
move16();
FOR( i = 0; i < L2; i++ )
{
- y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], signLeft ), s ) ); /* fold out the left end */
+ y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[add( add( add( L2, m ), R2 ), i )], signLeft ), s ) ); /* fold out the left end */
}
FOR( i = 0; i < R2; i++ )
{
- y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], signRight ), s ) ); /* ...and right end */
+ y[add( add( add( l, m ), R2 ), i )] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[add( L2, i )], signRight ), s ) ); /* ...and right end */
+ move16();
}
- FOR( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ )
+ FOR( i = 0; i < ( ( add( add( L2, m ), R2 ) ) >> 1 ); i++ )
{
- f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) );
+ f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[add( L2, i )], negfac ), s ) );
- y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT */
+ y[add( L2, i )] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[sub( sub( add( add( l, m ), R2 ), 1 ), i )], negfac ), s ) ); /* time-reverse mid of DCT */
+ move16();
+ y[sub( sub( add( add( l, m ), R2 ), 1 ), i )] = f;
move16();
- y[l + m + R2 - 1 - i] = f;
}
return;
diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window.c
index 87333ccd4119fa6b3d1a10ecf471fd93ecdc0352..65fb6a1a0217a4e94f797dfa7f7d681239fea5e9 100644
--- a/lib_com/tcx_mdct_window.c
+++ b/lib_com/tcx_mdct_window.c
@@ -40,8 +40,7 @@
#include
#include "cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "wmc_auto.h"
@@ -55,13 +54,13 @@ const PWord16 *getSineWindowTable( Word16 length );
void mdct_window_sine_flt(
float *window,
const int32_t Fs,
- const int16_t n,
- const int16_t window_type,
- const int16_t element_mode )
+ const Word16 n,
+ const Word16 window_type,
+ const Word16 element_mode )
{
if ( element_mode == EVS_MONO )
{
- int16_t i;
+ Word16 i;
float c;
c = EVS_PI / ( 2.0f * (float) n );
@@ -74,26 +73,26 @@ void mdct_window_sine_flt(
else
{
const float *window_table = 0;
- int16_t buf_in_size = 0;
+ Word16 buf_in_size = 0;
switch ( window_type )
{
case FULL_OVERLAP:
window_table = tcx_mdct_window_48;
buf_in_size = 420;
- break;
+ BREAK;
case HALF_OVERLAP:
window_table = tcx_mdct_window_half_48;
buf_in_size = 180;
- break;
+ BREAK;
case TRANSITION_OVERLAP:
case MIN_OVERLAP:
window_table = tcx_mdct_window_trans_48;
buf_in_size = 60;
- break;
+ BREAK;
default:
assert( 0 && "Unsupported window type" );
- break;
+ BREAK;
}
if ( Fs == 48000 )
@@ -116,56 +115,64 @@ void mdct_window_sine_IVAS_updated(
const Word16 window_type,
const Word16 element_mode )
{
- if ( element_mode == EVS_MONO )
+ IF( EQ_16( element_mode, EVS_MONO ) )
{
const PWord16 *table;
table = getSineWindowTable( n );
- for ( int i = 0; i < n / 2; i++ )
+ FOR( Word32 i = 0; i < shr( n, 1 ); i++ )
{
window[i].v.re = table[i].v.re;
+ move16();
window[i].v.im = table[i].v.im;
+ move16();
}
// PMT("getSineWindowTable needs to be updated for IVAS")
}
- else
+ ELSE
{
const Word16 *window_table = 0;
- int16_t buf_in_size = 0;
- Word16 temp[420] = { 0 };
- switch ( window_type )
+ Word16 buf_in_size = 0;
+ move16();
+ Word16 temp[420];
+ set16_fx( temp, 0, 420 );
+ SWITCH( window_type )
{
case FULL_OVERLAP:
window_table = tcx_mdct_window_48_fx;
buf_in_size = 420;
- break;
+ move16();
+ BREAK;
case HALF_OVERLAP:
window_table = tcx_mdct_window_half_48_fx;
buf_in_size = 180;
- break;
+ BREAK;
case TRANSITION_OVERLAP:
case MIN_OVERLAP:
window_table = tcx_mdct_window_trans_48_fx;
buf_in_size = 60;
- break;
+ move16();
+ BREAK;
default:
assert( 0 && "Unsupported window type" );
- break;
+ BREAK;
}
- if ( Fs == 48000 )
+ IF( EQ_32( Fs, 48000 ) )
{
Copy( window_table, temp, n );
}
- else
+ ELSE
{
lerp( window_table, temp, n, buf_in_size );
}
- for ( int i = 0; i < n / 2; i++ )
+ FOR( Word32 i = 0; i < shr( n, 1 ); i++ )
{
window[i].v.re = temp[n - 1 - i];
+ move16();
window[i].v.im = temp[i];
+ move16();
}
}
}
@@ -179,10 +186,12 @@ void mdct_window_sine( PWord16 *window, Word16 n )
{
const PWord16 *table;
table = getSineWindowTable( n );
- for ( int i = 0; i < n / 2; i++ )
+ FOR( Word32 i = 0; i < shr( n, 1 ); i++ )
{
window[i].v.re = table[i].v.re;
+ move16();
window[i].v.im = table[i].v.im;
+ move16();
}
// PMT("getSineWindowTable needs to be updated for IVAS")
}
@@ -190,7 +199,7 @@ void mdct_window_sine( PWord16 *window, Word16 n )
else
{
const float *window_table = 0;
- int16_t buf_in_size = 0;
+ Word16 buf_in_size = 0;
switch ( window_type )
{
case FULL_OVERLAP:
@@ -233,9 +242,9 @@ void mdct_window_sine( PWord16 *window, Word16 n )
void mdct_window_aldo_flt(
float *window1,
float *window2,
- const int16_t n )
+ const Word16 n )
{
- int16_t i, n1, n2, d;
+ Word16 i, n1, n2, d;
const float *p1, *p2;
/* set table pointers and decimation factor */
@@ -394,6 +403,7 @@ void mdct_window_aldo(
p1 = window_48kHz_fx + 2;
p2 = window_48kHz_fx + 1110 - 3;
d = 6;
+ move16();
BREAK;
case 512 / 2:
p1 = window_256kHz;
@@ -404,11 +414,13 @@ void mdct_window_aldo(
p1 = window_48kHz_fx + 1;
p2 = window_48kHz_fx + 1110 - 2;
d = 3;
+ move16();
BREAK;
case 1024 / 2:
p1 = window_256kHz;
p2 = window_256kHz + 592 - 1;
d = 1;
+ move16();
BREAK;
case 1280 / 2:
p1 = window_48kHz_fx + 1;
@@ -419,6 +431,7 @@ void mdct_window_aldo(
p1 = window_48kHz_fx;
p2 = window_48kHz_fx + 1110 - 1;
d = 1;
+ move16();
BREAK;
default:
assert( 0 );
diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c
index 74149f2bea571b767536bc948bced51dd3c12d00..e7987d0cecad106e440145d9e91f34acfbaa391a 100644
--- a/lib_com/tcx_utils_fx.c
+++ b/lib_com/tcx_utils_fx.c
@@ -5,8 +5,7 @@
#include
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "rom_basop_util.h"
#include "basop_util.h"
@@ -75,7 +74,6 @@ static void tcx_get_windows(
*left_overlap = hTcxCfg->tcx_mdct_window_length;
move16();
*left_win = hTcxCfg->tcx_aldo_window_1_trunc;
- move16();
BREAK;
default:
assert( !"Not supported overlap" );
@@ -98,7 +96,6 @@ static void tcx_get_windows(
*right_overlap = hTcxCfg->tcx_mdct_window_delay;
move16();
*right_win = hTcxCfg->tcx_aldo_window_2;
- move16();
BREAK;
default:
assert( !"Not supported overlap" );
@@ -131,10 +128,8 @@ static void tcx_get_windows(
BREAK;
case FULL_OVERLAP:
*left_overlap = hTcxCfg->tcx_mdct_window_lengthFB;
- *left_win = hTcxCfg->tcx_aldo_window_1_FB_trunc;
- move16();
move16();
-
+ *left_win = hTcxCfg->tcx_aldo_window_1_FB_trunc;
BREAK;
default:
assert( !"Not supported overlap" );
@@ -161,7 +156,6 @@ static void tcx_get_windows(
case FULL_OVERLAP:
*right_overlap = hTcxCfg->tcx_mdct_window_delayFB;
move16();
- move16();
*right_win = hTcxCfg->tcx_aldo_window_2_FB;
BREAK;
default:
@@ -366,8 +360,8 @@ void tcx_windowing_synthesis_current_frame(
{
/*signal[i] *= (float)(i)/(float)(acelp_zir_len);
signal[i] += acelp_zir[i]*(float)(acelp_zir_len-i)/(float)(acelp_zir_len);*/
- move16();
signal[i] = add( mult_r( signal[i], div_s( i, acelp_zir_len ) ), mult_r( acelp_zir[i], div_s( sub( acelp_zir_len, i ), acelp_zir_len ) ) );
+ move16();
}
}
/* Rectangular window (past-frame is ACELP) */
@@ -706,8 +700,8 @@ void lpc2mdct(
Word16 *mdct_gains_exp,
Word16 *mdct_inv_gains,
Word16 *mdct_inv_gains_exp,
- const int16_t length,
- const int16_t noInverse )
+ const Word16 length,
+ const Word16 noInverse )
{
Word32 ComplexData[2 * FDNS_NPTS];
Word16 i, j, k, sizeN, step, scale, s, tmp16;
@@ -739,7 +733,9 @@ void lpc2mdct(
FOR( ; i < FDNS_NPTS; i++ )
{
ComplexData[2 * i] = L_deposit_l( 0 );
+ move32();
ComplexData[2 * i + 1] = L_deposit_l( 0 );
+ move32();
}
move16();
@@ -873,14 +869,18 @@ void lpc2mdct_2(
FOR( i = 0; i < lpcOrder + 1; i++ )
{
RealData_fx[i] = L_mult( lpcCoeffs[i], ptwiddle->v.re );
+ move32();
ImagData_fx[i] = L_negate( L_mult( lpcCoeffs[i], ptwiddle->v.im ) );
+ move32();
ptwiddle += step;
}
FOR( ; i < sizeN; i++ )
{
RealData_fx[i] = L_deposit_l( 0 );
+ move32();
ImagData_fx[i] = L_deposit_l( 0 );
+ move32();
}
/* half length FFT */
@@ -888,7 +888,8 @@ void lpc2mdct_2(
BASOP_cfft_ivas( RealData_fx, ImagData_fx, 1, &scale );
/*Get amplitude*/
- j = FDNS_NPTS - 1;
+ j = sub( FDNS_NPTS, 1 );
+ move16();
k = 0;
move16();
@@ -1172,11 +1173,13 @@ void mdct_noiseShaping_ivas_fx(
Word16 m, n, k1, k2;
j = 0;
+ move16();
/* FDNS_NPTS = 64 */
k = shr( lg, 6 );
m = s_and( lg, 0x3F );
Word16 max_e = MIN16B;
+ move16();
FOR( i = 0; i < FDNS_NPTS; i++ )
{
max_e = s_max( max_e, add( *x_e, gains_exp[i] ) );
@@ -1223,7 +1226,9 @@ void mdct_noiseShaping_ivas_fx(
FOR( l = 0; l < k; l++ )
{
x_fx[i] = Mpy_32_16_1( x_fx[i], gains_fx[j] );
+ move32();
x_fx[i] = L_shr( x_fx[i], sub( max_e, add( *x_e, gains_exp[j] ) ) );
+ move32();
i = add( i, 1 );
}
j = add( j, 1 );
@@ -1236,7 +1241,9 @@ void mdct_noiseShaping_ivas_fx(
FOR( l = 0; l < k; l++ )
{
x_fx[i] = Mpy_32_16_1( x_fx[i], gains_fx[j] );
+ move32();
x_fx[i] = L_shr( x_fx[i], sub( max_e, add( *x_e, gains_exp[j] ) ) );
+ move32();
i = add( i, 1 );
}
j = add( j, 1 );
@@ -1739,7 +1746,6 @@ void tcx_noise_filling(
nrg = L_deposit_l( 1 );
win = 0;
move16();
- move16();
FOR( ; i < lowpassLine; i++ )
{
@@ -1882,11 +1888,11 @@ void tcx_noise_filling_with_shift(
}
i = add( i, 1 );
segmentOffset = i;
+ move16();
}
nrg = L_deposit_l( 1 );
win = 0;
move16();
- move16();
FOR( ; i < lowpassLine; i++ )
{
@@ -1909,13 +1915,15 @@ void tcx_noise_filling_with_shift(
FOR( m = segmentOffset; m < tmp2; m++ )
{
Word16 nrm = 31;
-
+ move16();
Q[m] = Mpy_32_16_1( Q[m], tmp1 );
+ move32();
IF( Q[m] )
{
nrm = norm_l( Q[m] );
}
Q[m] = L_shl( Q[m], nrm );
+ move32();
new_Q_e[m] = sub( add( new_Q_e[m], s ), nrm );
move32();
}
@@ -1928,11 +1936,13 @@ void tcx_noise_filling_with_shift(
Word16 nrm = 31;
Q[m] = Mpy_32_16_1( Q[m], tmp1 );
+ move32();
IF( Q[m] )
{
nrm = norm_l( Q[m] );
}
Q[m] = L_shl( Q[m], nrm );
+ move32();
new_Q_e[m] = sub( add( new_Q_e[m], s ), nrm );
move32();
win = sub( win, 1 );
@@ -1951,16 +1961,18 @@ void tcx_noise_filling_with_shift(
}
Word16 nrm = 31;
+ move16();
Random( &seed );
Q[i] = L_mult0( mult( seed, fac_ns ), win );
+ move32();
IF( Q[i] )
{
nrm = norm_l( Q[i] );
}
Q[i] = L_shl( Q[i], nrm );
- new_Q_e[i] = 31 - nrm;
move32();
+ new_Q_e[i] = sub( 31, nrm );
tmp1 = shr( seed, 4 );
nrg = L_mac0( nrg, tmp1, tmp1 ); /* sum up energy of current noise segment */
@@ -1985,24 +1997,27 @@ void tcx_noise_filling_with_shift(
FOR( m = segmentOffset; m < lowpassLine; m++ )
{
Word16 nrm = 31;
-
+ move16();
/*
at this point:
- flt Q[m] = (Q[m] * 2^(new_Q_e[m] - 31)) / (nTransWidth*nTransWidth)
- flt tmp1 = (tmp1 * 2^(s - 15)) * (nTransWidth*nTransWidth)
*/
Q[m] = Mpy_32_16_1( Q[m], tmp1 );
+ move32();
IF( Q[m] )
{
nrm = norm_l( Q[m] );
}
Q[m] = L_shl( Q[m], nrm );
+ move32();
new_Q_e[m] = add( new_Q_e[m], s - nrm );
move32();
}
}
Word16 max_e = 0;
+ move16();
FOR( i = 0; i < lowpassLine; i++ )
{
max_e = s_max( max_e, new_Q_e[i] );
@@ -2011,6 +2026,7 @@ void tcx_noise_filling_with_shift(
FOR( i = 0; i < lowpassLine; i++ )
{
Q[i] = L_shr( Q[i], sub( max_e, new_Q_e[i] ) );
+ move32();
}
*Q_e = max_e;
@@ -2028,8 +2044,8 @@ void InitTnsConfigs(
STnsConfig tnsConfig[2][2],
const Word16 igfStopFreq,
const Word32 total_brate,
- const int16_t element_mode,
- const int16_t MCT_flag )
+ const Word16 element_mode,
+ const Word16 MCT_flag )
{
IF( GT_32( total_brate, ACELP_32k ) )
{
@@ -2063,10 +2079,13 @@ void SetAllowTnsOnWhite(
)
{
tnsConfig[0][0].allowTnsOnWhite = allowTnsOnWhite;
+ move16();
tnsConfig[0][1].allowTnsOnWhite = allowTnsOnWhite;
+ move16();
tnsConfig[1][0].allowTnsOnWhite = allowTnsOnWhite;
+ move16();
tnsConfig[1][1].allowTnsOnWhite = allowTnsOnWhite;
-
+ move16();
return;
}
#endif
@@ -2216,27 +2235,31 @@ void init_TCX_config(
{
/* Initialize the TCX MDCT windows */
hTcxCfg->tcx_mdct_window_length = extract_l( L_shr( L_mult0( L_LOOK_12k8, fscale ), LD_FSCALE_DENOM ) );
+ move16();
hTcxCfg->tcx_mdct_window_delay = hTcxCfg->tcx_mdct_window_length;
move16();
hTcxCfg->tcx_mdct_window_half_length = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA( 12800, 5000000L ), fscale ), LD_FSCALE_DENOM ) );
-
- hTcxCfg->tcx_mdct_window_min_length = shr( L_frame, 4 ); /* 1.25ms */
+ move16();
+ hTcxCfg->tcx_mdct_window_min_length = shr( L_frame, 4 ); /* 1.25ms */
+ move16();
hTcxCfg->tcx_mdct_window_trans_length = shr( L_frame, 4 ); /* 1.25ms */
-
+ move16();
hTcxCfg->tcx5Size = shr( L_frame, 2 ); /* 5ms */
-
+ move16();
hTcxCfg->tcx_mdct_window_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8, fscaleFB ), LD_FSCALE_DENOM ) );
+ move16();
hTcxCfg->tcx_mdct_window_delayFB = hTcxCfg->tcx_mdct_window_lengthFB;
move16();
hTcxCfg->tcx_mdct_window_half_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA( 12800, 5000000L ), fscaleFB ), LD_FSCALE_DENOM ) );
-
- hTcxCfg->tcx_mdct_window_min_lengthFB = shr( L_frameTCX, 4 ); /* 1.25ms */
+ move16();
+ hTcxCfg->tcx_mdct_window_min_lengthFB = shr( L_frameTCX, 4 ); /* 1.25ms */
+ move16();
hTcxCfg->tcx_mdct_window_trans_lengthFB = shr( L_frameTCX, 4 ); /* 1.25ms */
-
+ move16();
hTcxCfg->tcx5SizeFB = shr( L_frameTCX, 2 ); /* 5ms */
-
+ move16();
mdct_window_sine( hTcxCfg->tcx_mdct_window, hTcxCfg->tcx_mdct_window_length );
mdct_window_sine( hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_half_length );
mdct_window_sine( hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_min_length );
diff --git a/lib_com/tec_com.c b/lib_com/tec_com.c
index 5e32b842b2bad659208a06ff9b7b91e9875fa281..32c6e9fef23a75214a4490e13f24856c26f10198 100644
--- a/lib_com/tec_com.c
+++ b/lib_com/tec_com.c
@@ -5,8 +5,7 @@
#include
#include "options.h"
#include "basop_util.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "cnst.h"
#include "rom_com.h"
@@ -80,6 +79,7 @@ static Word32 calcVar_Fix(
xx = L_deposit_l( 0 );
*x = L_deposit_l( 0 );
+ move32();
FOR( i = 0; i < len; i++ )
{
@@ -88,6 +88,7 @@ static Word32 calcVar_Fix(
tmpX = L_shr( Mpy_32_32( L_shl( in[i], exp1 ), L_shl( in[i], exp1 ) ), r_sft );
xx = L_add( xx, tmpX );
*x = L_add( *x, in[i] );
+ move32();
}
ans = L_deposit_l( 0 );
@@ -213,11 +214,13 @@ static Word32 calcCorrelationCoefficient2_Fix(
r_sft = sub( 8, sub( exp2, exp1 ) );
tmpCor = L_shr( tmpCor, r_sft );
ans = tmpCor;
+ move16();
}
}
ELSE
{
ans = 0;
+ move16();
}
@@ -256,7 +259,6 @@ static void calcLoBufferEnc_Fx(
li = TecLowBandTable[lb];
move16();
ui = sub( TecLowBandTable[lb + 1], 1 );
- move16();
assert( ( ui - li ) == 1 );
@@ -283,6 +285,7 @@ static void calcLoBufferEnc_Fx(
/* 0.50171665944 = 10 * log10(2.0) / NbTecLowBand / 2.0 */
loBuffer[slot] = extract_h( L_shl( Mpy_32_16_1( tmp, 16440 /*0.50171665944 Q15*/ ), 1 ) );
+ move16();
}
}
/*-------------------------------------------------------------------
@@ -318,7 +321,6 @@ static void calcHiTempEnv_Fx(
normFac = getNormReciprocalWord16( bwHigh );
scale = sub( scale, s1 );
- move16();
FOR( timeIndex = startPos; timeIndex < stopPos; timeIndex++ )
{
@@ -350,6 +352,7 @@ static void calcHiTempEnv_Fx(
/* 0.75257498916 = 10 * log10(2.0) / 4.0 */
hiTempEnv[timeIndex] = extract_h( L_shr( L_shl( Mpy_32_16_1( nrgLog, 24660 /*0.75257498916 Q15*/ ), 2 ), 1 ) );
+ move16();
}
}
/*-------------------------------------------------------------------
@@ -433,6 +436,7 @@ static void calcLoBufferDec_Fx(
/* 0.50171665944 = 10 * log10(2.0) / NbTecLowBand / 2.0 */
loBuffer[slot] = extract_h( L_shl( Mpy_32_16_1( tmp, 16440 /*0.50171665944 Q15*/ ), 1 ) );
+ move16();
}
ELSE
{
@@ -468,6 +472,7 @@ static void calcLoTempEnv_Fx(
}
/* adjFac is scaled by factor 0.5 */
loTempEnv_Fx[slot] = extract_h( Mpy_32_16_1( accu, adjFac_Fx ) );
+ move16();
}
}
/*-------------------------------------------------------------------
@@ -506,6 +511,7 @@ static void calcLoTempEnv_TBE_Fx(
Word16 slot;
Word32 accu;
Word16 delay = 1;
+ move16();
/* TecSC_Fx values are scaled by factor 2.0 */
FOR( slot = 0; slot < noCols; slot++ )
@@ -517,6 +523,7 @@ static void calcLoTempEnv_TBE_Fx(
}
/* adjFac is scaled by factor 0.5 */
loTempEnv_Fx[slot] = extract_h( Mpy_32_16_1( accu, adjFac_Fx ) );
+ move16();
}
}
/*-------------------------------------------------------------------
@@ -534,6 +541,7 @@ static void calcLoTempEnv_ns_TBE_Fx(
Word16 slot;
Word16 delay = 1;
Word16 fac = 22938 /*1.4f * 0.5f Q15*/;
+ move16();
FOR( slot = 0; slot < noCols; slot++ )
{
@@ -605,7 +613,9 @@ static void calcGainLinear_TBE_Fx(
s2 = norm_l( tmp32 );
pGainTemp_m[slot] = extract_h( L_shl( tmp32, s2 ) );
+ move16();
pGainTemp_e[slot] = sub( s, s2 );
+ move16();
}
}
/*-------------------------------------------------------------------
@@ -629,10 +639,11 @@ void calcGainTemp_TBE_Fx(
Word16 loTempEnv_Fx[16];
const Word16 BW_LO = TecLowBandTable[NBTECLOWBAND];
+ move16();
Word16 slot;
- Word16 noCols = stopPos - startPos;
- Word16 bandOffset = lowSubband - BW_LO;
+ Word16 noCols = sub( stopPos, startPos );
+ Word16 bandOffset = sub( lowSubband, BW_LO );
assert( lowSubband >= BW_LO );
@@ -643,7 +654,7 @@ void calcGainTemp_TBE_Fx(
startPos,
stopPos,
bandOffset,
- 15 - cldfb_exp );
+ sub( 15, cldfb_exp ) );
IF( code > 0 )
{
@@ -680,7 +691,9 @@ static void setSubfrConfig_Fix(
const Word16 l_subfr )
{
*n_subfr = sub( (Word16) N_TEC_TFA_SUBFR, i_offset );
+ move16();
*k_offset = i_mult( i_offset, l_subfr );
+ move16();
}
/*-------------------------------------------------------------------
* calcSum_Fx()
@@ -699,7 +712,9 @@ static Word16 calcSum_Fx(
Word16 sum16_e; /* Q0 */
*sum16_m = 0;
+ move16();
sum16_e = 0;
+ move16();
FOR( slot = 0; slot < len; slot++ )
{
sum16_e = BASOP_Util_Add_MantExp(
@@ -731,8 +746,10 @@ static Word16 calcSubfrNrg_Fx(
Word16 s;
Word16 sum16_e;
Word16 s2 = 1; /* headroom for a summatoin of length l_subfr ( < 2^s2 = 64 ) */
+ move16();
k = k_offset;
+ move16();
FOR( i = i_offset; i < N_TEC_TFA_SUBFR; i++ )
{
Word32 nrg32;
@@ -771,7 +788,9 @@ static Word16 calcSubfrNrg_Fx(
}
sum16_e = enr_e[i_offset];
+ move16();
*sum16_m = enr_m[i_offset];
+ move16();
FOR( i = i_offset + 1; i < N_TEC_TFA_SUBFR; i++ )
{
@@ -868,6 +887,7 @@ static Word16 procTec_Fx(
gain_ave_e = sub( gain_ave_e, 3 );
k = k_offset;
+ move16();
FOR( i = i_offset; i < N_TEC_TFA_SUBFR; i++ )
{
IF( enr_m[i] > 0 )
@@ -943,7 +963,6 @@ static Word16 procTec_Fx(
lower_limit_gain_m = min_curr_enr_m;
move16();
lower_limit_gain_e = sub( min_curr_enr_e, 1 );
- move16();
}
/* upper_limit_gain */
@@ -977,7 +996,9 @@ static Word16 procTec_Fx(
}
gain_m[i] = mult_r( gain_m[i], inv_curr_enr_m[i] );
+ move16();
gain_e[i] = add( gain_e[i], inv_curr_enr_e[i] );
+ move16();
s = norm_s( gain_m[i] );
gain_m[i] = shl( gain_m[i], s );
@@ -1009,8 +1030,7 @@ static Word16 procTec_Fx(
s = norm_s( hb_synth_Fx[k] );
hb_synth_Fx[k] = mult_r( gain_m[i], shl( hb_synth_Fx[k], s ) );
move16();
- shift[k] = s - gain_e[i];
- move16();
+ shift[k] = sub( s, gain_e[i] );
if ( GT_16( min_shift, shift[k] ) )
{
@@ -1040,6 +1060,7 @@ static Word16 procTec_Fx(
min_shift = sub( s, exp_syn ); /* exp_syn(old) - exp_syn(new) */
k = k_offset;
+ move16();
FOR( i = i_offset; i < N_TEC_TFA_SUBFR; i++ )
{
FOR( j = 0; j < l_subfr; j++ )
@@ -1203,6 +1224,7 @@ Word16 procTecTfa_TBE_Fx(
Word16 code )
{
Word16 i_offset = 0;
+ move16();
Word16 exp_syn_frame = sub( 15, hb_synth_fx_exp );
@@ -1252,8 +1274,11 @@ void calcHiEnvLoBuff_Fix(
Word16 pCldfbPow_FixScale )
{
const Word16 BW_LO = TecLowBandTable[NBTECLOWBAND];
+ move16();
const Word16 lowSubband = pFreqBandTable[0];
+ move16();
const Word16 highSubband = pFreqBandTable[nSfb];
+ move16();
Word16 bandOffsetBottom;
@@ -1300,7 +1325,9 @@ void calcLoEnvCheckCorrHiLo_Fix(
)
{
const Word16 BW_LO = TecLowBandTable[NBTECLOWBAND];
+ move16();
const Word16 lowSubband = pFreqBandTable[0];
+ move16();
Word16 i;
Word16 bandOffsetBottom;
@@ -1317,6 +1344,7 @@ void calcLoEnvCheckCorrHiLo_Fix(
Word32 EQ4, EQ5, EQ6;
Word16 code = 0; /* SET TENTATIVELY */
+ move16();
Word32 loVar_ns_Fix;
Word32 diff_hi_lo_sum_Fix;
Word32 loSum_ns_Fix;
@@ -1335,6 +1363,7 @@ void calcLoEnvCheckCorrHiLo_Fix(
FOR( i = 0; i < noCols + DELAY_TEMP_ENV_BUFF_TEC; i++ )
{
hiTempEnv32_Fix[i] = L_deposit_l( hiTempEnv[i] );
+ move32();
}
hiVar_Fix = calcVar_Fix( hiTempEnv32_Fix, (Word32) noCols, &hiSum_Fix );
@@ -1355,6 +1384,7 @@ void calcLoEnvCheckCorrHiLo_Fix(
FOR( i = 0; i < noCols; i++ )
{
loTempEnv32_ns_Fix[i] = L_deposit_l( loTempEnv_ns_Fix[i] );
+ move32();
}
loVar_ns_Fix = calcVar_Fix( loTempEnv32_ns_Fix, noCols, &loSum_ns_Fix );
@@ -1362,9 +1392,9 @@ void calcLoEnvCheckCorrHiLo_Fix(
EQ4 = L_sub( L_shr( hiVar_Fix, 7 ), 800 );
EQ5 = L_sub( L_shr( loVar_ns_Fix, 7 ), 720 );
- ;
+
EQ6 = L_sub( L_shr( diff_hi_lo_sum_Fix, 7 ), 100 );
- ;
+
test();
test();
if ( EQ4 > 0 && EQ5 > 0 && EQ6 < 0 )
@@ -1393,6 +1423,7 @@ void calcLoEnvCheckCorrHiLo_Fix(
move16();
maxPosHi = maxPosLo = 0;
move16();
+ move16();
FOR( i = 1; i < noCols; i++ )
{
if ( LT_16( maxHiFix, hiTempEnv[i] ) )
@@ -1419,12 +1450,14 @@ void calcLoEnvCheckCorrHiLo_Fix(
{
Word16 feature_max_Fix = 0;
+ move16();
Word16 pos_feature_max = 0;
+ move16();
Word16 feature_Fix[16];
Word16 min_local_Fix, max_local_Fix;
Word16 j;
Word16 len_window = EXT_DELAY_HI_TEMP_ENV + 1;
-
+ move16();
Word16 *curr_pos_Fix = hiTempEnv;
move16();
@@ -1458,6 +1491,7 @@ void calcLoEnvCheckCorrHiLo_Fix(
}
}
feature_Fix[i] = sub( max_local_Fix, min_local_Fix );
+ move16();
if ( LT_16( feature_max_Fix, feature_Fix[i] ) )
{
@@ -1492,6 +1526,7 @@ void calcLoEnvCheckCorrHiLo_Fix(
FOR( i = 0; i < noCols; i++ )
{
loTempEnv32_Fix[i] = L_deposit_l( loTempEnv_Fix[i] );
+ move32();
}
loVar_Fix = calcVar_Fix( loTempEnv32_Fix, noCols, &loSum_Fix );
/* = = */
diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c
index f89bf8e07bbf57d895b42b5a30401e6c159f331f..9aafaddba7f50183987e6caa30003352c92469dc 100644
--- a/lib_com/tns_base.c
+++ b/lib_com/tns_base.c
@@ -10,8 +10,7 @@
#include "stat_com.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
/*----------------------------------------------------------------------------
@@ -90,6 +89,7 @@ void InitTnsConfiguration(
const int16_t is_mct )
{
Word16 iFilter = 0;
+ move16();
Word16 *startLineFilter;
Word32 L_tmp;
Word32 nSampleRate;
@@ -105,7 +105,9 @@ void InitTnsConfiguration(
/* Sanity checks */
assert( ( nSampleRate > 0 ) && ( frameLength > 0 ) && ( pTnsConfig != NULL ) );
- if ( ( nSampleRate <= 0 ) || ( frameLength <= 0 ) || ( pTnsConfig == NULL ) )
+ test();
+ test();
+ IF( ( nSampleRate <= 0 ) || ( frameLength <= 0 ) || ( pTnsConfig == NULL ) )
{
return /*TNS_FATAL_ERROR*/;
}
@@ -250,8 +252,6 @@ void ApplyTnsFilter(
Word16 parCoeff[TNS_MAX_FILTER_ORDER];
const STnsFilter *pFilter;
-
- move16();
move16();
move16();
pFilter = &pTnsData->filter[iFilter];
@@ -309,6 +309,7 @@ Word16 ITF_Detect_fx(
Word16 spectrumLength;
Word16 const nSubdivisions = MAX_SUBDIVISIONS;
+ move16();
Word16 iSubdivisions;
Word16 iStartLine;
Word16 iEndLine;
@@ -323,6 +324,7 @@ Word16 ITF_Detect_fx(
Word16 n, i;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
move16();
@@ -357,7 +359,7 @@ Word16 ITF_Detect_fx(
/* Check threshold HLM_MIN_NRG */
BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef BASOP_NOGLOB
- tmp32 = L_sub( L_shl_o( L_tmp, sub( shift, 24 - Q ), &Overflow ), 4194304l /*HLM_MIN_NRG Q7*/ );
+ tmp32 = L_sub( L_shl_o( L_tmp, sub( shift, sub( 24, Q ) ), &Overflow ), 4194304l /*HLM_MIN_NRG Q7*/ );
#else /* BASOP_NOGLOB */
tmp32 = L_sub( L_shl( L_tmp, sub( shift, 24 - Q ) ), 4194304l /*HLM_MIN_NRG Q7*/ );
#endif
@@ -435,6 +437,7 @@ Word16 ITF_Detect_fx(
FOR( i = 0; i < n; i++ )
{
tmpbuf[i] = round_fx( L_shl( pSpectrum[iStartLine + i - IGF_START_MN], shift ) );
+ move16();
}
FOR( lag = 0; lag <= maxOrder; lag++ )
@@ -464,6 +467,7 @@ Word16 ITF_Detect_fx(
ITF_GetFilterParameters_fx( rxx, s_min( maxOrder, shr( spectrumLength, 2 ) ), A, Q_A, predictionGain );
*curr_order = maxOrder;
+ move16();
}
return 1;
@@ -483,6 +487,7 @@ Word16 ITF_Detect_ivas_fx(
Word16 spectrumLength;
Word16 const nSubdivisions = MAX_SUBDIVISIONS;
+ move16();
Word16 iSubdivisions;
Word16 iStartLine;
Word16 iEndLine;
@@ -497,6 +502,7 @@ Word16 ITF_Detect_ivas_fx(
Word16 n, i;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
move16();
@@ -605,6 +611,7 @@ Word16 ITF_Detect_ivas_fx(
FOR( i = 0; i < n; i++ )
{
tmpbuf[i] = round_fx_o( L_shl( pSpectrum[iStartLine + i - IGF_START_MN], shift ), &Overflow );
+ move16();
}
FOR( lag = 0; lag <= maxOrder; lag++ )
@@ -634,6 +641,7 @@ Word16 ITF_Detect_ivas_fx(
ITF_GetFilterParameters_fx( rxx, s_min( maxOrder, shr( spectrumLength, 2 ) ), A, Q_A, predictionGain );
*curr_order = maxOrder;
+ move16();
}
return 1;
@@ -672,6 +680,8 @@ static Word16 DecodeUsingTable( Decoder_State *st, Word16 *pValue, const Coding
{
Word16 code = 0;
Word16 nBits = 0;
+ move16();
+ move16();
Word16 valueIndex;
assert( ( nSize >= 0 ) && ( nSize <= 256 ) );
@@ -688,7 +698,9 @@ static Word16 DecodeUsingTable( Decoder_State *st, Word16 *pValue, const Coding
if ( nBits > nSize || nBits > 16 )
{
st->BER_detect = 1;
+ move16();
*pValue = 0;
+ move16();
return -1;
}
@@ -705,12 +717,14 @@ static Word16 DecodeUsingTable( Decoder_State *st, Word16 *pValue, const Coding
if ( valueIndex < nSize )
{
*pValue = (Word16) codes[valueIndex].value;
+ move16();
}
else
{
st->BER_detect = 1;
+ move16();
*pValue = 0;
-
+ move16();
return -1;
}
@@ -723,12 +737,14 @@ static Word16 DecodeUsingTable( Decoder_State *st, Word16 *pValue, const Coding
void const *GetTnsFilterCoeff( void const *p, const Word16 index, Word16 *pValue )
{
*pValue = ( (Word16 const *) p )[index] + INDEX_SHIFT;
+ move16();
return NULL;
}
void *SetTnsFilterCoeff( void *p, const Word16 index, const Word16 value )
{
( (Word16 *) p )[index] = sub( value, INDEX_SHIFT );
+ move16();
return NULL;
}
@@ -884,15 +900,17 @@ Word16 DecodeTnsFilterOrder( Decoder_State *st, const Word16 index, Word16 *pVal
void const *GetNumOfTnsFilters( void const *p, const Word16 index, Word16 *pValue )
{
+ move16();
*pValue = ( (STnsData const *) p )[index].nFilters;
-
+ move16();
return ( (STnsData const *) p )[index].filter;
}
void *SetNumOfTnsFilters( void *p, const Word16 index, Word16 value )
{
+ move16();
( (STnsData *) p )[index].nFilters = value;
-
+ move16();
return ( (STnsData *) p )[index].filter;
}
@@ -951,7 +969,9 @@ void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16
void *SetTnsEnabledSingleFilter( void *p, const Word16 index, const Word16 value )
{
+ move16();
( (STnsData *) p )[index].nFilters = value;
+ move16();
return ( (STnsData *) p )[index].filter;
}
@@ -966,13 +986,18 @@ void ResetTnsData( STnsData *pTnsData )
pTnsData->nFilters = 0;
+ move16();
pTnsData->tnsOnWhitenedSpectra = 0;
+ move16();
FOR( iFilter = 0; iFilter < (Word16) ( sizeof( pTnsData->filter ) / sizeof( pTnsData->filter[0] ) ); iFilter++ )
{
STnsFilter *const pTnsFilter = &pTnsData->filter[iFilter];
pTnsFilter->spectrumLength = 0;
+ move16();
pTnsFilter->predictionGain = ONE_IN_Q7;
+ move16();
pTnsFilter->avgSqrCoef = 0;
+ move16();
/* TODO: remove float _flt dependencies */
pTnsFilter->predictionGain_flt = 1.0f;
pTnsFilter->avgSqrCoef_flt = 0;
@@ -990,6 +1015,7 @@ void ClearTnsFilterCoefficients(
{
move16();
pTnsFilter->order = 0;
+ move16();
assert( TNS_MAX_FILTER_ORDER == 8 );
move16();
move16();
@@ -1070,12 +1096,12 @@ static Word32 IIRLattice( Word16 order, const Word16 *parCoeff, Word32 *state, W
/* first stage: no need to calculate state[order-1] */
- x = L_sub( x, Mpy_32_16_1( state[order - 1], parCoeff[order - 1] ) );
+ x = Msub_32_16( x, state[order - 1], parCoeff[order - 1] );
FOR( i = order - 2; i >= 0; i-- )
{
- x = L_sub( x, Mpy_32_16_1( state[i], parCoeff[i] ) );
- state[i + 1] = L_add( state[i], Mpy_32_16_1( x, parCoeff[i] ) );
+ x = Msub_32_16( x, state[i], parCoeff[i] );
+ state[i + 1] = Madd_32_16( state[i], x, parCoeff[i] );
move32();
}
@@ -1194,6 +1220,7 @@ static void ITF_GetFilterParameters_fx(
L_tmp = E_LPC_schur( rxx, parCoeff, epsP, maxOrder );
BASOP_SATURATE_WARNING_OFF_EVS /* Allow saturation, this value is compared against a threshold. */
*predictionGain = divide3232( L_shr( epsP[0], PRED_GAIN_E ), L_tmp );
+ move16();
BASOP_SATURATE_WARNING_ON_EVS
{
@@ -1202,8 +1229,9 @@ static void ITF_GetFilterParameters_fx(
/* Convert ParCor / reflection coefficients to LPC */
A32[0] = 134217728l /*1.0 Q27*/;
- move16(); /* Q11+16 */
+ move32(); /* Q11+16 */
A32[1] = L_shr( L_deposit_h( parCoeff[0] ), 4 ); /* Q11+16 */
+ move32();
FOR( i = 1; i < maxOrder; i++ )
{
@@ -1239,8 +1267,10 @@ static void ITF_GetFilterParameters_fx(
FOR( i = 0; i < maxOrder; i++ )
{
A[i] = round_fx( L_shl( A32[i], tmp ) ); /* Q11+tmp */
+ move16();
}
*Q_A = add( 11, tmp );
+ move16();
}
return;
}
diff --git a/lib_com/tools.c b/lib_com/tools.c
index 6a6ea3d4239289efcfbda7dde1cbcff078abf72e..dc2ee58fbe214aa87e167d822d892dba95a593ef 100644
--- a/lib_com/tools.c
+++ b/lib_com/tools.c
@@ -38,9 +38,8 @@
#include "options.h"
#include
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
/*------------------------------------------------------------------*
* own_random()
@@ -185,10 +184,11 @@ Word32 sum2_f_16_fx(
const Word16 lvec /* i : length of input vector */
)
{
- int16_t i;
+ Word16 i;
Word32 tmp;
tmp = 0;
+ move32();
FOR( i = 0; i < lvec; i++ )
{
tmp = L_add( tmp, L_mult0( vec[i], vec[i] ) );
@@ -196,6 +196,22 @@ Word32 sum2_f_16_fx(
return tmp;
}
+Word32 sum2_f_16_gb_fx(
+ const Word16 *vec, /* i : input vector */
+ const Word16 lvec, /* i : length of input vector */
+ Word16 gb )
+{
+ int16_t i;
+ Word32 tmp;
+
+ tmp = 0;
+ FOR( i = 0; i < lvec; i++ )
+ {
+ tmp = L_add( tmp, L_shr( L_mult0( vec[i], vec[i] ), gb ) );
+ }
+
+ return tmp;
+}
#endif
float sum2_f(
const float *vec, /* i : input vector */
@@ -215,17 +231,50 @@ float sum2_f(
}
#ifdef IVAS_FLOAT_FIXED
-Word32 sum2_f_32_fx(
- const Word32 *vec, /* i : input vector */
- const int16_t lvec, /* i : length of input vector */
- Word16 gb )
+Word32 sum2_32_exp_fx(
+ const Word32 *vec, /* i : input vector, Qx */
+ const Word16 lvec, /* i : length of input vector */
+ Word16 *exp, /* i/o: exponent of vector */
+ Word16 gb /* i : guard bits */
+)
{
- int16_t i;
+ Word16 i, s;
+ Word64 W_tmp;
+
+ W_tmp = 0;
+ Word64 var_a = 0;
+ move64();
+ move64();
+ FOR( i = 0; i < lvec; i++ )
+ {
+ var_a = W_mult0_32_32( vec[i], vec[i] ); // 2x
+ W_tmp = W_add( W_tmp, W_shr( var_a, gb ) ); // 2x-gb
+ }
+
+ s = W_norm( W_tmp );
+ W_tmp = W_shl( W_tmp, s ); // 2x - gb + s
+
+ //*exp = 31 - (2*(31 - *exp) - gb + s) + 32;
+ *exp = add( sub( add( shl( *exp, 1 ), gb ), s ), 1 );
+ move16();
+
+ return W_extract_h( W_tmp );
+}
+
+Word32 sum2_f_32_fx( /* o : Q(2x - 31 - gb) */
+ const Word32 *vec, /* i : input vector, Qx */
+ const Word16 lvec, /* i : length of input vector */
+ Word16 gb /* i : guard bits */
+)
+{
+ Word16 i;
Word32 tmp;
tmp = 0;
Word32 var_a = 0;
- for ( i = 0; i < lvec; i++ )
+ move32();
+ move32();
+ FOR( i = 0; i < lvec; i++ )
{
var_a = Mpy_32_32( vec[i], vec[i] ); // 2x-31
tmp = L_add( tmp, L_shr( var_a, gb ) ); // 2x-31-gb
@@ -239,12 +288,15 @@ Word32 sum2_32_fx(
const Word16 lvec, /* i : length of input vector */
Word16 *e )
{
- int16_t i;
+ Word16 i;
Word32 tmp;
tmp = 0;
Word32 var_a = 0;
Word16 exp = 0, exp_tmp;
+ move32();
+ move32();
+ move16();
FOR( i = 0; i < lvec; i++ )
{
exp_tmp = norm_l( vec[i] );
@@ -254,6 +306,7 @@ Word32 sum2_32_fx(
tmp = BASOP_Util_Add_Mant32Exp( tmp, exp, var_a, exp_tmp, &exp );
}
*e = exp;
+ move16();
return tmp;
}
@@ -351,6 +404,7 @@ void set_zero_fx(
FOR( i = 0; i < lvec; i++ )
{
*vec++ = 0;
+ move32();
}
return;
@@ -516,7 +570,7 @@ uint32_t mvr2s(
}
#ifdef IVAS_FLOAT_FIXED
-uint32_t mvl2s_r(
+UWord32 mvl2s_r(
const Word32 x[], /* i : input vector */
const Word16 q_x,
Word16 y[], /* o : output vector */
@@ -525,7 +579,8 @@ uint32_t mvl2s_r(
{
Word16 i;
Word32 temp;
- uint32_t noClipping = 0;
+ UWord32 noClipping = 0;
+ move32();
IF( n <= 0 )
{
@@ -537,21 +592,24 @@ uint32_t mvl2s_r(
{
FOR( i = 0; i < n; i++ )
{
- temp = L_shr( x[i], q_x - 1 );
+ temp = L_shr( x[i], sub( q_x, 1 ) );
temp = L_shr( L_add( temp, 1 ), 1 );
- IF( temp > MAX16B )
+ IF( GT_32( temp, MAX16B ) )
{
temp = MAX16B;
- noClipping++;
+ move32();
+ noClipping = L_add( (Word32) noClipping, 1 );
}
- ELSE IF( temp < MIN16B )
+ ELSE IF( LT_32( temp, MIN16B ) )
{
temp = MIN16B;
- noClipping++;
+ move32();
+ noClipping = L_add( (Word32) noClipping, 1 );
}
- y[i] = (Word16) temp;
+ y[i] = extract_l( temp );
+ move16();
}
}
ELSE
@@ -561,18 +619,21 @@ uint32_t mvl2s_r(
temp = L_shr( x[i], q_x - 1 );
temp = L_shr( L_add( temp, 1 ), 1 );
- IF( temp > MAX16B )
+ IF( GT_32( temp, MAX16B ) )
{
temp = MAX16B;
- noClipping++;
+ move32();
+ noClipping = L_add( (Word32) noClipping, 1 );
}
- ELSE IF( temp < MIN16B )
+ ELSE IF( LT_32( temp, MIN16B ) )
{
temp = MIN16B;
- noClipping++;
+ move32();
+ noClipping = L_add( (Word32) noClipping, 1 );
}
- y[i] = (Word16) temp;
+ y[i] = extract_l( temp );
+ move16();
}
}
@@ -710,7 +771,7 @@ Word16 maximum_s(
}
}
- IF( max != NULL )
+ if ( max != NULL )
{
*max = tmp;
move16();
@@ -761,19 +822,23 @@ Word16 maximum_l(
ind = 0;
tmp = vec[0];
-
+ move16();
+ move32();
FOR( i = 1; i < lvec; i++ )
{
IF( GT_32( vec[i], tmp ) )
{
ind = i;
tmp = vec[i];
+ move16();
+ move32();
}
}
IF( max_val != NULL )
{
*max_val = tmp;
+ move32();
}
return ind;
@@ -883,7 +948,7 @@ Word16 minimum_s(
}
}
- IF( min_val != NULL )
+ if ( min_val != NULL )
{
*min_val = tmp;
move16();
@@ -939,19 +1004,24 @@ Word16 minimum_l(
ind = 0;
tmp = vec[0];
+ move16();
+ move32();
- for ( i = 1; i < lvec; i++ )
+ FOR( i = 1; i < lvec; i++ )
{
- if ( LT_32( vec[i], tmp ) )
+ IF( LT_32( vec[i], tmp ) )
{
ind = i;
tmp = vec[i];
+ move16();
+ move32();
}
}
if ( min_val != NULL )
{
*min_val = tmp;
+ move32();
}
return ind;
@@ -1063,6 +1133,28 @@ Word32 dotp_fixed(
}
#ifdef IVAS_FLOAT_FIXED
+Word32 dotp_me_fx(
+ const Word32 x[], /* i : vector x[] */
+ const Word32 y[], /* i : vector y[] */
+ const Word16 n, /* i : vector length */
+ Word16 exp_x,
+ Word16 exp_y,
+ Word16 *exp_suma )
+{
+ Word16 i;
+ Word32 suma;
+ Word32 mul;
+ Word16 mul_exp = add( exp_x, exp_y );
+ suma = Mpy_32_32( x[0], y[0] );
+ *exp_suma = mul_exp;
+ FOR( i = 1; i < n; i++ )
+ {
+ mul = Mpy_32_32( x[i], y[i] );
+ suma = BASOP_Util_Add_Mant32Exp( suma, *exp_suma, mul, mul_exp, exp_suma ); // exp_x+exp_A
+ }
+
+ return suma;
+}
Word32 dotp_fixed_guarded(
const Word32 x[], /* i : vector x[] */
const Word32 y[], /* i : vector y[] */
@@ -1102,13 +1194,48 @@ Word32 dotp_fixed_o(
suma = W_add( suma, W_shr( W_mult_32_32( x[i], y[i] ), log_len ) );
}
*res_q = add( sub( *res_q, log_len ), 1 );
- WHILE( GT_64( suma, MAX_32 ) || GT_16( *res_q, 31 ) )
+ move16();
+ test();
+ test();
+ WHILE( GT_64( suma, MAX_32 ) || LT_64( suma, MIN_32 ) || GT_16( *res_q, 31 ) )
+ {
+ suma = W_shr( suma, 1 );
+ *res_q = sub( *res_q, 1 );
+ move16();
+ }
+ return W_extract_l( suma );
+}
+
+Word32 dotp_fixed_32(
+ const Word32 x[], /* i : vector x[] */
+ const Word32 y[], /* i : vector y[] */
+ const Word16 n, /* i : vector length */
+ const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */
+ Word16 *res_q /*stores resultant Q*/
+)
+{
+ Word16 i;
+ Word64 suma; /*resultant q= q(x)+q(y)-9-x such that q<=31*/
+
+ suma = W_shr( W_mult_32_32( x[0], y[0] ), log_len );
+
+ FOR( i = 1; i < n; i++ )
+ {
+ suma = W_add( suma, W_shr( W_mult_32_32( x[i], y[i] ), log_len ) );
+ }
+ *res_q = add( *res_q, add( sub( *res_q, log_len ), 1 ) );
+ move16();
+ test();
+ test();
+ WHILE( GT_64( suma, MAX_32 ) || LT_64( suma, MIN_32 ) || GT_16( *res_q, 31 ) )
{
suma = W_shr( suma, 1 );
*res_q = sub( *res_q, 1 );
+ move16();
}
- return (Word32) suma;
+ return W_extract_l( suma );
}
+
/*---------------------------------------------------------------------*
* inv_sqrt()
*
@@ -1249,6 +1376,7 @@ void v_add_fixed(
FOR( i = 0; i < N; i++ )
{
y[i] = L_add( L_shr( x1[i], hdrm ), L_shr( x2[i], hdrm ) );
+ move32();
}
return;
@@ -1266,15 +1394,17 @@ void v_add_fixed_me(
)
{
Word16 i;
- Word16 x1_shift = s_max( x1_e, x2_e ) - x1_e;
- Word16 x2_shift = s_max( x1_e, x2_e ) - x2_e;
+ Word16 x1_shift = sub( s_max( x1_e, x2_e ), x1_e );
+ Word16 x2_shift = sub( s_max( x1_e, x2_e ), x2_e );
FOR( i = 0; i < N; i++ )
{
y[i] = L_add( L_shr( x1[i], hdrm + x1_shift ), L_shr( x2[i], hdrm + x2_shift ) );
+ move32();
}
- *y_e = s_max( x1_e, x2_e ) + hdrm;
+ *y_e = add( s_max( x1_e, x2_e ), hdrm );
+ move16();
return;
}
@@ -1299,6 +1429,7 @@ void v_add_w64(
FOR( i = 0; i < N; i++ )
{
y[i] = W_add( W_shr( x1[i], hdrm ), W_shr( x2[i], hdrm ) );
+ move64();
}
return;
@@ -1347,6 +1478,7 @@ void v_sub_fixed(
FOR( i = 0; i < N; i++ )
{
y[i] = L_sub( L_shr( x1[i], hdrm ), L_shr( x2[i], hdrm ) );
+ move32();
}
return;
@@ -1370,6 +1502,7 @@ void v_mult_fixed(
FOR( i = 0; i < N; i++ )
{
y[i] = Mpy_32_32( x1[i], x2[i] );
+ move32();
}
return;
@@ -1434,6 +1567,7 @@ void v_multc_fixed(
FOR( i = 0; i < N; i++ )
{
y[i] = Mpy_32_32( c, x[i] );
+ move32();
}
return;
@@ -1451,6 +1585,7 @@ void v_multc_fixed_16(
FOR( i = 0; i < N; i++ )
{
y[i] = Mpy_32_16_1( x[i], c );
+ move32();
}
return;
@@ -1468,6 +1603,7 @@ void v_multc_fixed_16_16(
FOR( i = 0; i < N; i++ )
{
y[i] = mult_r( x[i], c );
+ move16();
}
return;
@@ -1838,8 +1974,10 @@ void sort_l(
FOR( j = i + 1; ( j < len ) && ( tempr > x[j] ); j++ )
{
x[j - 1] = x[j];
+ move32();
}
x[j - 1] = tempr;
+ move32();
}
return;
@@ -2235,7 +2373,14 @@ Word32 anint_fixed( Word32 x, Word16 exp )
{
return 0;
}
- return GE_32( x, 0 ) ? L_add( x, L_shl( 1, exp - 1 ) ) : L_sub( x, L_shl( 1, exp - 1 ) );
+ IF( GE_32( x, 0 ) )
+ {
+ return L_add( x, L_shl( 1, exp - 1 ) );
+ }
+ ELSE
+ {
+ return L_sub( x, L_shl( 1, exp - 1 ) );
+ }
}
/*-------------------------------------------------------------------*
@@ -2246,10 +2391,11 @@ Word32 anint_fixed( Word32 x, Word16 exp )
Word32 ceil_fixed( Word32 x, Word16 exp )
{
Word32 step;
- step = x / L_shl( 1, exp );
- IF( GT_32( x % L_shl( 1, exp ), 0 ) )
+ // step = x / L_shl( 1, exp );
+ step = L_shr( x, exp );
+ if ( ( x % L_shl( 1, exp ) ) > 0 )
{
- step++;
+ step = L_add( step, 1 );
}
return L_shl( step, exp );
}
diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c
index bba84cdb92117c2cfdd33af36359f3df616a44ad..919da71e3a743788c9a00a29d6d997f08e834049 100644
--- a/lib_com/tools_fx.c
+++ b/lib_com/tools_fx.c
@@ -45,8 +45,7 @@
#include "stl.h"
#include
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "basop32.h"
#include "wmc_auto.h"
@@ -308,6 +307,7 @@ Word16 usquant_fx( /* o: index of the winning codeword */
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* idx = (short)( (x - qlow)/delta + 0.5f); */
@@ -351,6 +351,7 @@ Word32 Dot_product( /* o : Sum */
Word64 L64_sum;
L64_sum = 1;
+ move64();
FOR( i = 0; i < lg; i++ )
{
L64_sum = W_mac_16_16( L64_sum, x[i], y[i] );
@@ -398,6 +399,7 @@ Word32 sum2_fx( /* o : sum of all squared vector elements
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
L_tmp = L_deposit_l( 0 );
FOR( i = 0; i < lvec; i++ )
@@ -421,6 +423,7 @@ Word32 sum2_fx_mod( /* o : sum of all squared vector element
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
L_tmp = L_deposit_l( 0 );
@@ -526,6 +529,7 @@ void Copy_pword(
y[i].v.im = x[i].v.im;
y[i].v.re = x[i].v.re;
move16();
+ move16();
}
}
ELSE
@@ -535,6 +539,7 @@ void Copy_pword(
y[i].v.im = x[i].v.im;
y[i].v.re = x[i].v.re;
move16();
+ move16();
}
}
}
@@ -567,6 +572,24 @@ void Copy32(
}
}
}
+
+void set8_fx(
+ Word8 y[], /* i/o: Vector to set */
+ const Word8 a, /* i : Value to set the vector to */
+ const Word16 N /* i : Lenght of the vector */
+)
+{
+ Word16 i;
+
+ FOR( i = 0; i < N; i++ )
+ {
+ y[i] = a;
+ move16();
+ }
+
+ return;
+}
+
/*-------------------------------------------------------------------*
* set16_fx()
* set32_fx()
@@ -603,6 +626,7 @@ void set32_fx(
FOR( i = 0; i < N; i++ )
{
y[i] = L_deposit_l( tmp );
+ move32();
}
}
ELSE
@@ -632,6 +656,7 @@ void Copy_Scale_sig(
Word16 tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
IF( exp0 == 0 )
{
@@ -678,6 +703,7 @@ void Copy_Scale_sig_16_32(
Word16 tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -686,6 +712,7 @@ void Copy_Scale_sig_16_32(
FOR( i = 0; i < lg; i++ )
{
y[i] = L_deposit_l( x[i] );
+ move32();
}
return;
}
@@ -699,6 +726,7 @@ void Copy_Scale_sig_16_32(
#else
y[i] = L_deposit_l( shl( x[i], exp0 ) );
#endif
+ move32();
}
return;
}
@@ -725,6 +753,7 @@ void Copy_Scale_sig_16_32_no_sat(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -733,6 +762,7 @@ void Copy_Scale_sig_16_32_no_sat(
FOR( i = 0; i < lg; i++ )
{
y[i] = L_deposit_l( x[i] );
+ move32();
}
return;
}
@@ -746,6 +776,7 @@ void Copy_Scale_sig_16_32_no_sat(
#else
y[i] = L_deposit_l( shl( x[i], exp0 ) );
#endif
+ move32();
}
return;
}
@@ -773,6 +804,7 @@ void Copy_Scale_sig_32_16(
Word16 tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
tmp = add( 16, exp0 );
@@ -785,6 +817,7 @@ void Copy_Scale_sig_32_16(
#else
y[i] = round_fx( L_shl( x[i], tmp ) );
#endif
+ move16();
}
}
ELSE
@@ -796,6 +829,7 @@ void Copy_Scale_sig_32_16(
#else
y[i] = round_fx( x[i] );
#endif
+ move16();
}
}
}
@@ -814,6 +848,7 @@ void Scale_sig32(
Word16 i;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
FOR( i = 0; i < lg; i++ )
@@ -1177,7 +1212,6 @@ Word16 maximum_abs_32_fx( /* o : index of the maximum abs va
ind = 0;
move16();
tmp = L_abs( vec[0] );
- move16();
FOR( j = 1; j < lvec; j++ )
{
@@ -1347,6 +1381,7 @@ void conv_fx(
Word32 L_sum;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
y[0] = mult_r( x[0], h[0] );
move16();
@@ -1427,6 +1462,7 @@ Word16 var_fx( /* o: variance of vector Qx*/
Word32 L_tmp;
L_tmp = x[0];
+ move32();
FOR( i = 1; i < len; i++ )
{
L_tmp = L_add( L_tmp, x[i] ); /*Qx */
@@ -1591,7 +1627,7 @@ Word16 vquant_fx( /* o: index of the winning codevector
FOR( c = 0; c < cbsize; c++ )
{
L_dist = 0;
- move16();
+ move32();
FOR( d = 0; d < dim; d++ )
{
@@ -1655,6 +1691,7 @@ Word16 w_vquant_fx(
Word32 dist, minDist;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -1874,12 +1911,16 @@ Word16 emaximum_32fx( /* o : return index with max energy va
{
W_tmp = W_mult0_32_32( vec[j], vec[j] );
W_tmp1 = W_sub( W_tmp, emax );
- IF( GT_64( W_tmp1, 0 ) )
+ if ( W_tmp1 > 0 )
{
ind = j;
move16();
}
- emax = GT_64( emax, W_tmp ) ? emax : W_tmp;
+ if ( LE_64( emax, W_tmp ) )
+ {
+ emax = W_tmp;
+ move64();
+ }
}
#ifdef BASOP_NOGLOB
@@ -1887,7 +1928,7 @@ Word16 emaximum_32fx( /* o : return index with max energy va
#else /* BASOP_NOGLOB */
*ener_max = L_shr( emax, add( Qvec, Qvec ) );
#endif /* BASOP_NOGLOB */
- move64();
+ move32();
return ind;
}
@@ -1969,7 +2010,7 @@ Word16 Random( /* o : output random value */
)
{
*seed = extract_l( L_mac0( 13849L, *seed, 31821 ) );
-
+ move16();
return *seed;
}
@@ -2205,6 +2246,7 @@ void pz_filter_sp_fx(
Ltemp1 = L_add( L_shr( Lacc, s ), 0x08000 ); /* Ltemp1 in Qc+Qa+Qn=Q(Qn) */
#endif
y[i] = extract_h( Ltemp1 ); /* y[i] in Qn */
+ move16();
}
}
@@ -2217,9 +2259,10 @@ Word32 root_a_fx(
Word16 exp, tmp;
Word32 L_tmp;
- if ( a <= 0 )
+ IF( a <= 0 )
{
*exp_out = 0;
+ move16();
return 0;
}
@@ -2249,9 +2292,10 @@ Word32 root_a_over_b_fx(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
test();
- if ( ( a <= 0 ) || ( b <= 0 ) )
+ IF( ( a <= 0 ) || ( b <= 0 ) )
{
*exp_out = 0;
move16();
@@ -2334,6 +2378,7 @@ void fir_fx( const Word16 x[], /* i : input vector
Word32 s;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* prepare the input buffer (copy and update memory) */
Copy( mem, buf_in, K );
@@ -2365,6 +2410,7 @@ void fir_fx( const Word16 x[], /* i : input vector
s = L_shl( s, shift );
y[i] = round_fx( s ); /*Qx */
#endif
+ move16();
}
}
@@ -2386,6 +2432,7 @@ void v_add_32(
for ( i = 0; i < N; i++ )
{
y[i] = L_add( x1[i], x2[i] );
+ move32();
}
return;
@@ -2403,6 +2450,7 @@ void v_shr_32(
for ( i = 0; i < N; i++ )
{
y[i] = L_shr( x1[i], shift );
+ move32();
}
return;
@@ -2424,9 +2472,10 @@ void v_sub_32(
{
Word16 i;
- for ( i = 0; i < N; i++ )
+ FOR( i = 0; i < N; i++ )
{
- y[i] = x1[i] - x2[i];
+ y[i] = L_sub( x1[i], x2[i] );
+ move32();
}
return;
@@ -2450,7 +2499,8 @@ void v_add_16(
for ( i = 0; i < N; i++ )
{
- y[i] = x1[i] + x2[i];
+ y[i] = add_sat( x1[i], x2[i] );
+ move16();
}
return;
@@ -2474,7 +2524,8 @@ void v_sub_16(
for ( i = 0; i < N; i++ )
{
- y[i] = x1[i] - x2[i];
+ y[i] = sub_sat( x1[i], x2[i] );
+ move16();
}
return;
@@ -2613,6 +2664,7 @@ void pz_filter_dp_fx(
Ltemp1 = L_shr( Lacc, s ); /* Ltemp1 in Qc+Qa+Qn=Q(16+Qn) */
#endif
y[i] = extract_h( Ltemp1 ); /* y[i] in Qn */
+ move16();
}
}
@@ -2639,6 +2691,7 @@ void Copy_Scale_sig32_16(
#else
*dst++ = round_fx( *src++ );
#endif
+ move16();
}
return;
}
@@ -2654,6 +2707,7 @@ void Copy_Scale_sig32_16(
*dst++ = round_fx( L_temp );
#endif
+ move16();
}
}
@@ -2745,6 +2799,7 @@ void v_L_mult_1616(
for ( i = 0; i < N; i++ )
{
y[i] = L_mult( x1[i], x2[i] );
+ move32();
}
return;
@@ -2768,6 +2823,7 @@ void v_L_mult_3216(
for ( i = 0; i < N; i++ )
{
y[i] = Mpy_32_16_1( x1[i], x2[i] );
+ move32();
}
return;
@@ -2792,6 +2848,7 @@ void add_vec_fx(
Word16 i, Qyx1, Qyx2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
Qyx1 = sub( Qx1, Qy );
Qyx2 = sub( Qx2, Qy );
@@ -2929,6 +2986,7 @@ Word32 Calc_Energy_Autoscaled( /* o: Result (Energy)
Word16 i, j;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
Overflow = 0;
@@ -3158,6 +3216,7 @@ Word16 find_rem( Word16 n, Word16 m, Word16 *r )
q1 = extract_l( Lacc );
Ltemp2 = L_shr( Lacc, q2 );
*r = extract_h( Ltemp2 );
+ move16();
return ( q1 );
}
@@ -3205,6 +3264,7 @@ Word32 find_remd( Word32 n, Word32 m, Word32 *r )
}
}
*r = L_shr( Lacc, q2 );
+ move16();
return ( qo );
}
@@ -3224,11 +3284,11 @@ Word16 rint_new_fx(
{
a = add( extract_h( x ), 1 );
- if ( s_and( a, 1 ) == 0 )
+ IF( s_and( a, 1 ) == 0 )
{
return a;
}
- if ( s_and( a, 1 ) != 0 )
+ IF( s_and( a, 1 ) != 0 )
{
return extract_h( x );
}
@@ -3381,6 +3441,8 @@ void Acelp_dec_total_exc(
L_tmp = L_add( L_tmp, L_shl( L_mult( gain_code16, code_fx[i] ), 6 ) ); /*Q16+Q_exc*/
exc_fx[i + i_subfr] = round_fx( L_tmp ); /*Q_exc*/
#endif
+ move16();
+ move16();
}
}
@@ -3394,9 +3456,11 @@ UWord32 UL_inverse( const UWord32 UL_val, Word16 *exp )
UWord32 UL_tmp;
*exp = norm_ul( UL_val );
+ move16();
UL_tmp = UL_lshl( UL_val, *exp ); /* Q32 */
*exp = add( 32, sub( 31, *exp ) );
+ move16();
return UL_div( 0x80000000, UL_tmp );
}
@@ -3446,7 +3510,7 @@ Word16 ratio( const Word32 numer, const Word32 denom, Word16 *expo )
quotient = div_s( manNumer, manDenom ); /* in Q14 */
*expo = sub( expNumer, expDenom );
-
+ move16();
return quotient; /* Q14 */
}
@@ -3494,7 +3558,7 @@ void hp400_12k8_fx(
L_tmp3 = L_mult( mem[4], b_hp400_fx[2] );
mem[5] = signal[lg - 2];
-
+ move16();
FOR( i = 1; i < lg; i++ )
{
/* y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2] */
@@ -3520,6 +3584,7 @@ void hp400_12k8_fx(
/* signal is divided by 16 to avoid overflow in energy computation */
*signal++ = round_fx( L_tmp );
+ move16();
}
/* y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2] */
@@ -3541,11 +3606,12 @@ void hp400_12k8_fx(
/* signal is divided by 16 to avoid overflow in energy computation */
*signal++ = round_fx( L_tmp );
+ move16();
return;
}
-#ifdef IVAS_FLOAT_FIXED
+#if 0
void hp400_12k8_ivas_fx(
Word16 signal[], /* i/o: input signal / output is divided by 16 */
const Word16 lg, /* i : lenght of signal */
@@ -3631,6 +3697,7 @@ Word16 dot_prod_satcontr( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy
Word16 *pt1, *pt2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -3675,7 +3742,7 @@ Word16 dot_prod_satcontr( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy
ener = extract_h( L_tmp ); /*Q(qx+qy-shift+q-16) */
q = add( q, add( qx, qy ) );
*qo = sub( q, add( shift, 16 ) );
-
+ move16();
return ener;
}
@@ -3706,12 +3773,14 @@ void E_UTIL_f_convolve( const Word16 x[], const Word16 h[], Word16 y[], const Wo
FOR( n = 0; n < size; n++ )
{
L64_sum = 0;
+ move64();
FOR( i = 0; i < n; i++ )
{
L64_sum = W_mac_16_16( L64_sum, x[i], h[n - i] );
}
L_sum = W_sat_l( L64_sum );
y[n] = mac_r( L_sum, x[i], h[0] );
+ move16();
}
return;
}
@@ -3737,7 +3806,7 @@ void floating_point_add(
accY = L_shr( my, 1 );
/* First, align the Q-points of the two operands. Then, add. */
align = sub( *ex, ey );
- test();
+
IF( align < 0 )
{
accX = L_add( accX, L_shl( accY, align ) );
@@ -3752,6 +3821,8 @@ void floating_point_add(
expo = norm_l( accX );
*mx = L_shl( accX, expo );
*ex = sub( add( *ex, expo ), 1 ); /* Subtract 1 due to 1-bit down-shift above ensuring 1 bit headroom before addition. */
+ move32();
+ move16();
return;
}
/*-------------------------------------------------------------------*
@@ -3770,36 +3841,36 @@ void delay_signal(
Word16 tmp_buffer[L_FRAME48k];
Copy( mem, tmp_buffer, delay );
- Copy( x + len - delay, mem, delay );
- Copy( x, x + delay, len - delay );
+ Copy( x + sub( len, delay ), mem, delay );
+ Copy( x, x + delay, sub( len, delay ) );
Copy( tmp_buffer, x, delay );
return;
}
void delay_signal_fx(
- Word32 x[], /* i/o: signal to be delayed */
- const Word16 len, /* i : length of the input signal */
- Word32 mem[], /* i/o: synchronization memory */
- const int16_t delay /* i : delay in samples */
+ Word32 x[], /* i/o: signal to be delayed */
+ const Word16 len, /* i : length of the input signal */
+ Word32 mem[], /* i/o: synchronization memory */
+ const Word16 delay /* i : delay in samples */
)
{
Word32 tmp_buffer[L_FRAME48k];
Copy32( mem, tmp_buffer, delay );
- Copy32( x + len - delay, mem, delay );
- Copy32( x, x + delay, len - delay );
+ Copy32( x + sub( len, delay ), mem, delay );
+ Copy32( x, x + delay, sub( len, delay ) );
Copy32( tmp_buffer, x, delay );
return;
}
#ifdef IVAS_FLOAT_FIXED
void delay_signal_q_adj_fx(
- Word32 x[], /* i/o: signal to be delayed */
- const int16_t len, /* i : length of the input signal */
- Word32 mem[], /* i/o: synchronization memory */
- const int16_t delay, /* i : delay in samples */
+ Word32 x[], /* i/o: signal to be delayed */
+ const Word16 len, /* i : length of the input signal */
+ Word32 mem[], /* i/o: synchronization memory */
+ const Word16 delay, /* i : delay in samples */
const Word16 q_x,
const Word16 q_mem )
{
@@ -3807,8 +3878,8 @@ void delay_signal_q_adj_fx(
Word32 tmp_buffer[L_FRAME48k];
Copy32( mem, tmp_buffer, delay );
- Copy32( x + len - delay, mem, delay );
- Copy32( x, x + delay, len - delay );
+ Copy32( x + sub( len, delay ), mem, delay );
+ Copy32( x, x + delay, sub( len, delay ) );
IF( EQ_16( q_x, q_mem ) )
@@ -3828,55 +3899,66 @@ void v_add_fx(
const Word32 x1[], /* i : Input vector 1 */
const Word32 x2[], /* i : Input vector 2 */
Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */
- const int16_t N /* i : Vector length */
+ const Word16 N /* i : Vector length */
)
{
- int16_t i;
+ Word16 i;
- for ( i = 0; i < N; i++ )
+ FOR( i = 0; i < N; i++ )
{
y[i] = L_add_sat( x1[i], x2[i] );
+ move32();
}
return;
}
Word16 floor_log_2( Word32 num )
{
- return num < 2 ? 0 : num < 4 ? 1
- : num < 8 ? 2
- : num < 16 ? 3
- : num < 32 ? 4
- : num < 64 ? 5
- : num < 128 ? 6
- : num < 256 ? 7
- : num < 512 ? 8
- : num < 1024 ? 9
- : num < 2048 ? 10
- : num < 4096 ? 11
- : num < 8192 ? 12
- : num < 16384 ? 13
- : num < 32768 ? 14
- : num < 65536 ? 15
- : num < 131072 ? 16
- : num < 262144 ? 17
- : num < 524288 ? 18
- : num < 1048576 ? 19
- : num < 2097152 ? 20
- : 21;
+#if 0
+ return num < 2 ? 0 : num < 4 ? 1
+ : num < 8 ? 2
+ : num < 16 ? 3
+ : num < 32 ? 4
+ : num < 64 ? 5
+ : num < 128 ? 6
+ : num < 256 ? 7
+ : num < 512 ? 8
+ : num < 1024 ? 9
+ : num < 2048 ? 10
+ : num < 4096 ? 11
+ : num < 8192 ? 12
+ : num < 16384 ? 13
+ : num < 32768 ? 14
+ : num < 65536 ? 15
+ : num < 131072 ? 16
+ : num < 262144 ? 17
+ : num < 524288 ? 18
+ : num < 1048576 ? 19
+ : num < 2097152 ? 20
+ : 21;
+#endif
+
+ IF( EQ_32( num, 0 ) )
+ {
+ return 0;
+ }
+
+ return ( sub( 30, norm_l( num ) ) );
}
void v_shr(
const Word32 x[], /* i : Input vector */
const Word16 shift, /* i : Constant */
- Word32 y[], /* o : Output vector that contains x >> shift */
+ Word32 y[], /* o : Output vector that contains x >> shift */
const Word16 N /* i : Vector length */
)
{
Word16 i;
- for ( i = 0; i < N; i++ )
+ FOR( i = 0; i < N; i++ )
{
y[i] = L_shr( x[i], shift );
+ move32();
}
return;
@@ -3891,9 +3973,10 @@ void v_shr_16(
{
Word16 i;
- for ( i = 0; i < N; i++ )
+ FOR( i = 0; i < N; i++ )
{
y[i] = shr( x[i], shift );
+ move16();
}
return;
@@ -3915,8 +3998,8 @@ void delay_signal32(
Word32 tmp_buffer[L_FRAME48k];
Copy32( mem, tmp_buffer, delay );
- Copy32( x + len - delay, mem, delay );
- Copy32( x, x + delay, len - delay );
+ Copy32( x + sub( len, delay ), mem, delay );
+ Copy32( x, x + delay, sub( len, delay ) );
Copy32( tmp_buffer, x, delay );
return;
@@ -3939,7 +4022,7 @@ Word16 lin_interp_fx(
const Word16 flag_sat /* i : flag to indicate whether to apply saturation */
)
{
- IF( EQ_16( sub( x2, x1 ), 0 ) )
+ IF( sub( x2, x1 ) == 0 )
{
return y1;
}
@@ -3947,11 +4030,25 @@ Word16 lin_interp_fx(
{
IF( GE_16( x, s_max( x1, x2 ) ) )
{
- return GT_16( x1, x2 ) ? y1 : y2;
+ IF( GT_16( x1, x2 ) )
+ {
+ return y1;
+ }
+ ELSE
+ {
+ return y2;
+ }
}
ELSE IF( LE_16( x, s_min( x1, x2 ) ) )
{
- return LT_16( x1, x2 ) ? y1 : y2;
+ IF( LT_16( x1, x2 ) )
+ {
+ return y1;
+ }
+ ELSE
+ {
+ return y2;
+ }
}
}
@@ -3969,7 +4066,7 @@ Word32 sign_l(
const Word32 x /* i : input value of x */
)
{
- IF( LT_32( x, 0 ) )
+ IF( x < 0 )
{
return MIN_32;
}
@@ -3991,6 +4088,7 @@ void v_mult16_fixed(
FOR( i = 0; i < N; i++ )
{
y[i] = mult_r( x1[i], x2[i] );
+ move16();
}
return;
diff --git a/lib_com/trans_direct_fx.c b/lib_com/trans_direct_fx.c
index b088be832192bf2cb655e621f37417e4b7a50e45..82e2c981c7d80f4f60d45183e7a58ab5240b7fb2 100644
--- a/lib_com/trans_direct_fx.c
+++ b/lib_com/trans_direct_fx.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common FX constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common FX constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Function prototypes */
/*-------------------------------------------------------------------
* direct_transform()
@@ -44,6 +43,7 @@ void direct_transform_fx(
#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
(void) ( element_mode );
#endif
+ move16();
segment_length = shr( L, 1 );
segment_length2 = shr( segment_length, 1 );
@@ -68,10 +68,8 @@ void direct_transform_fx(
win_fx = wscw16q15_16_fx;
}
- sh_fx = &in32_fx[L - 1];
- add( 0, 0 );
- sl_fx = &in32_r16_fx[L - 1];
- add( 0, 0 );
+ sh_fx = &in32_fx[sub( L, 1 )];
+ sl_fx = &in32_r16_fx[sub( L, 1 )];
FOR( i = 0; i < segment_length; i++ )
{
in32_r16_fx[i] = ( *sh_fx-- );
@@ -81,16 +79,13 @@ void direct_transform_fx(
}
iseg_fx = &in32_r16_fx[-segment_length4];
- add( 0, 0 );
oseg_fx = out32_fx;
wh_fx = &win_fx[segment_length4];
- add( 0, 0 );
wl_fx = wh_fx - 1;
shift = extract_l( L_mult0( 3, segment_length4 ) );
sh_fx = &iseg_fx[shift];
- add( 0, 0 );
sl_fx2 = sh_fx - 1;
@@ -101,8 +96,7 @@ void direct_transform_fx(
move32(); /*Q */
}
- sl_fx2 = &iseg_fx[segment_length2 - 1];
- add( 0, 0 );
+ sl_fx2 = &iseg_fx[sub( segment_length2, 1 )];
FOR( i = segment_length4; i < segment_length2; i++ )
{
@@ -116,17 +110,13 @@ void direct_transform_fx(
Qmin = s_min( Qs[0], Qmin );
iseg_fx += segment_length2;
- add( 0, 0 );
oseg_fx += segment_length2;
- add( 0, 0 );
FOR( seg = 1; seg < NUM_TIME_SWITCHING_BLOCKS - 1; seg++ )
{
wh_fx = &win_fx[segment_length4];
- add( 0, 0 );
wl_fx = wh_fx - 1;
sh_fx = &iseg_fx[shift];
- add( 0, 0 );
sl_fx2 = sh_fx - 1;
FOR( i = 0; i < segment_length4; i++ )
{
@@ -136,10 +126,8 @@ void direct_transform_fx(
}
sh_fx = iseg_fx;
- sl_fx2 = &iseg_fx[segment_length2 - 1];
- add( 0, 0 );
- wh_fx = &win_fx[segment_length2 - 1];
- add( 0, 0 );
+ sl_fx2 = &iseg_fx[sub( segment_length2, 1 )];
+ wh_fx = &win_fx[sub( segment_length2, 1 )];
wl_fx = win_fx;
FOR( i = segment_length4; i < segment_length2; i++ )
@@ -155,13 +143,10 @@ void direct_transform_fx(
Qmin = s_min( Qs[seg], Qmin );
iseg_fx += segment_length2;
- add( 0, 0 );
oseg_fx += segment_length2;
- add( 0, 0 );
}
- sh_fx = &iseg_fx[shift - 1];
- add( 0, 0 );
+ sh_fx = &iseg_fx[sub( shift, 1 )];
FOR( i = 0; i < segment_length4; i++ )
{
dctin32_fx[i] = L_negate( *sh_fx-- );
@@ -170,10 +155,8 @@ void direct_transform_fx(
sh_fx = iseg_fx;
- sl_fx2 = &iseg_fx[segment_length2 - 1];
- add( 0, 0 );
- wh_fx = &win_fx[segment_length2 - 1];
- add( 0, 0 );
+ sl_fx2 = &iseg_fx[sub( segment_length2, 1 )];
+ wh_fx = &win_fx[sub( segment_length2, 1 )];
wl_fx = win_fx;
FOR( i = segment_length4; i < segment_length2; i++ )
diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c
index 2cc68314e210f41d6f483d0962da57b0ea3dd0b0..f79443862199a7cacad0a6d5ae65e7108b9cc579 100644
--- a/lib_com/trans_inv_fx.c
+++ b/lib_com/trans_inv_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Function prototypes */
#include "rom_dec.h"
@@ -104,7 +103,7 @@ void preecho_sb_fx(
framelength_m1 = sub( framelength, 1 );
nb_flag = 0;
move16();
- if ( EQ_16( bwidth, NB ) )
+ if ( ( bwidth == NB ) )
{
nb_flag = 1;
move16();
diff --git a/lib_com/vlpc_2st_com_fx.c b/lib_com/vlpc_2st_com_fx.c
index f25e8bbf048244fbeae7fbbafd5af961fb882225..c54e5632f07a3861ef9b52211c3c6cd69ac719ce 100644
--- a/lib_com/vlpc_2st_com_fx.c
+++ b/lib_com/vlpc_2st_com_fx.c
@@ -5,8 +5,7 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "control.h"
#include "basop_util.h"
diff --git a/lib_com/weight_a_fx.c b/lib_com/weight_a_fx.c
index 3177fea34bcfb3425f366cd7e192ad65592da3ef..99b621fa57c95f4d79abd591a675deeb03639141 100644
--- a/lib_com/weight_a_fx.c
+++ b/lib_com/weight_a_fx.c
@@ -4,8 +4,7 @@
#include
#include "options.h" /* Compilation switches */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include
/*------------------------------------------------------------------
@@ -29,7 +28,7 @@ void weight_a_subfr_fx(
orderp1 = add( order, 1 );
FOR( k = 0; k < nb_subfr; k++ )
{
- weight_a_fx( &A[k * ( orderp1 )], &Aw[k * ( orderp1 )], gamma, order );
+ weight_a_fx( &A[imult1616( k, ( orderp1 ) )], &Aw[imult1616( k, ( orderp1 ) )], gamma, order );
}
return;
@@ -78,8 +77,10 @@ void weight_a_lc_fx(
FOR( i = 1; i < m; i++ )
{
ap[i] = round_fx( L_shl( L_mult0( a[i], *ptr_gamma++ ), shift ) );
+ move16();
}
ap[m] = round_fx( L_shl( L_mult0( a[m], *ptr_gamma++ ), shift ) );
+ move16();
return;
}
@@ -100,7 +101,9 @@ void weight_a_fx(
Word32 Amax;
Word16 shift;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
+ Flag Overflow;
+ Overflow = 0;
+ move32();
#endif
fac = gamma;
@@ -124,9 +127,11 @@ void weight_a_fx(
#else /* BASOP_NOGLOB */
ap[i] = round_fx( L_shl( L_mult0( a[i], fac ), shift ) );
#endif
+ move16();
fac = mult_r( fac, gamma );
}
ap[m] = round_fx( L_shl( L_mult0( a[m], fac ), shift ) );
+ move16();
return;
}
@@ -157,13 +162,46 @@ void E_LPC_a_weight_inv(
17350, 18859, 20499, 22281, 24219, 26325, 28614, 31102 }; /* Q13 */
static const Word16 inv_gamma_tab_16k[16] = { 17430, 18542, 19726, 20985, 22324, 23749, 25265, 26878, /* Q14 */
14297, 15209, 16180, 17213, 18312, 19480, 20724, 22047 }; /* Q13 */
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+
const Word16 *inv_gamma_tab;
Word32 L_tmp;
Word32 Amax;
Word16 shift;
- IF( inv_gamma == 16384 )
+ IF( EQ_16( inv_gamma, 16384 ) )
{
FOR( i = 0; i <= m; i++ )
{
@@ -177,11 +215,9 @@ void E_LPC_a_weight_inv(
assert( m == 16 );
inv_gamma_tab = inv_gamma_tab_12k8;
- move16();
if ( EQ_16( inv_gamma, GAMMA16k_INV ) )
{
inv_gamma_tab = inv_gamma_tab_16k;
- move16();
}
@@ -201,12 +237,14 @@ void E_LPC_a_weight_inv(
{
L_tmp = L_mult( a[i], inv_gamma_tab[i - 1] );
ap[i] = round_fx( L_shl( L_tmp, shift ) );
+ move16();
}
shift = add( shift, 1 );
FOR( i = 9; i < 17; i++ )
{
L_tmp = L_mult( a[i], inv_gamma_tab[i - 1] );
ap[i] = round_fx( L_shl( L_tmp, shift ) );
+ move16();
}
diff --git a/lib_com/weight_fx.c b/lib_com/weight_fx.c
index 5b5005fafd94af10259b225ef5e0ae8867a74612..6c123cbf2f14822ffe53631b3646ab11f26edea0 100644
--- a/lib_com/weight_fx.c
+++ b/lib_com/weight_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*--------------------------------------------------------------------------*
* sfm2mqb_fx()
diff --git a/lib_com/wi_fx.c b/lib_com/wi_fx.c
index 602487f7199b893963bad38e35e33e98ca29348d..233a2f6ba4ae518d937c1e5625a8a76466068bda 100644
--- a/lib_com/wi_fx.c
+++ b/lib_com/wi_fx.c
@@ -4,8 +4,7 @@
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "log2.h"
@@ -160,8 +159,11 @@ void DTFS_sub_fx(
move16();
}
tmp->lag_fx = s_max( X1.lag_fx, X2.lag_fx );
+ move16();
tmp->nH_fx = s_max( X1.nH_fx, X2.nH_fx );
+ move16();
tmp->nH_4kHz_fx = s_max( X1.nH_4kHz_fx, X2.nH_4kHz_fx );
+ move16();
tmp->upper_cut_off_freq_of_interest_fx = X1.upper_cut_off_freq_of_interest_fx;
move16();
tmp->upper_cut_off_freq_fx = X1.upper_cut_off_freq_fx;
@@ -180,7 +182,6 @@ static void DTFS_fast_fs_inv_fx( DTFS_STRUCTURE *X_fx, Word16 *out_fx, Word16 N_
Word16 dbuf_fx[256 + 1];
M_2 = s_min( shr( X_fx->lag_fx, 1 ), X_fx->nH_fx );
- move16();
N_2 = shr( N_fx, 1 );
s = negate( X_fx->Q );
@@ -193,7 +194,7 @@ static void DTFS_fast_fs_inv_fx( DTFS_STRUCTURE *X_fx, Word16 *out_fx, Word16 N_
{
dbuf_fx[2 * i] = shl_r( X_fx->a_fx[i], s );
move16();
- dbuf_fx[2 * i + 1] = shl_r( X_fx->b_fx[i], s );
+ dbuf_fx[add( 2 * i, 1 )] = shl_r( X_fx->b_fx[i], s );
move16();
}
@@ -201,7 +202,7 @@ static void DTFS_fast_fs_inv_fx( DTFS_STRUCTURE *X_fx, Word16 *out_fx, Word16 N_
{
dbuf_fx[2 * i] = 0;
move16();
- dbuf_fx[2 * i + 1] = 0;
+ dbuf_fx[add( 2 * i, 1 )] = 0;
move16();
}
@@ -265,6 +266,7 @@ static Word16 DTFS_alignment_weight_fx(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
diff_fx = 0; /* to avoid compilation warnings */
@@ -278,6 +280,7 @@ static Word16 DTFS_alignment_weight_fx(
FOR( k = 0; k < M + 1; k++ )
{
tmplpc_fx[k] = mult_r( LPC1[k], pwf_fx[k] ); /* Q12 */
+ move16();
}
DTFS_zeroFilter_fx( &X1, tmplpc_fx, M + 1, S_fx, C_fx );
@@ -287,6 +290,7 @@ static Word16 DTFS_alignment_weight_fx(
FOR( k = 0; k < M + 1; k++ )
{
tmplpc_fx[k] = mult_r( LPC2[k], pwf_fx[k] ); /* Q12 */
+ move16();
}
DTFS_zeroFilter_fx( &X2, tmplpc_fx, M + 1, S_fx, C_fx );
@@ -295,7 +299,7 @@ static Word16 DTFS_alignment_weight_fx(
move16();
fshift_fx = Eshift;
move16();
- Adiff_fx = (Word16) s_max( 768, mult_r( 4915, shl( X2.lag_fx, 7 ) ) ); /* Q7, 768=6*128, 4915 = 0.15*32768 */
+ Adiff_fx = s_max( 768, mult_r( 4915, shl( X2.lag_fx, 7 ) ) ); /* Q7, 768=6*128, 4915 = 0.15*32768 */
if ( LT_16( X2.lag_fx, 60 ) )
{
@@ -311,7 +315,7 @@ static Word16 DTFS_alignment_weight_fx(
HalfLag = s_min( shr( X2.lag_fx, 1 ), X2.nH_4kHz_fx );
exp = norm_s( X2.lag_fx );
tmp = div_s( shl( 1, sub( 14, exp ) ), X2.lag_fx );
- L_tmp = L_shl( tmp, exp + 6 );
+ L_tmp = L_shl( tmp, add( exp, 6 ) );
inv_lag = round_fx( L_tmp );
FOR( k = 0; k <= HalfLag; k++ )
@@ -323,6 +327,8 @@ static Word16 DTFS_alignment_weight_fx(
ab1[k] = round_fx( L_mac0( L_mult0( X1.a_fx[k], X2.a_fx[k] ), X1.b_fx[k], X2.b_fx[k] ) ); /* Q(-15) */
ab2[k] = round_fx( L_msu0( L_mult0( X1.a_fx[k], X2.b_fx[k] ), X1.b_fx[k], X2.a_fx[k] ) ); /* Q(-15) */
#endif
+ move16();
+ move16();
}
start = sub( Eshift, Adiff_fx );
@@ -345,11 +351,13 @@ static Word16 DTFS_alignment_weight_fx(
{
#ifdef BASOP_NOGLOB
corr_fx = L_mac0_o( corr_fx, ab1[k], cos_table[s_and( temp, 511 )], &Overflow );
- corr_fx = L_mac0_o( corr_fx, ab2[k], cos_table[s_and( ( temp + 128 ), 511 )], &Overflow );
+ corr_fx = L_mac0_o( corr_fx, ab2[k], cos_table[s_and( add( temp, 128 ), 511 )], &Overflow );
#else
corr_fx = L_mac0( corr_fx, ab1[k], cos_table[s_and( temp, 511 )] );
- corr_fx = L_mac0( corr_fx, ab2[k], cos_table[s_and( ( temp + 128 ), 511 )] );
+ corr_fx = L_mac0( corr_fx, ab2[k], cos_table[s_and( add( temp, 128 ), 511 )] );
#endif
+ move32();
+ move32();
temp = add( temp, temp1 );
}
temp = sub( 8192, mult_r( 20972, abs_s( sub( n_fx, Eshift ) ) ) ); /* Q13, 20972 = Q21 of 0.01. */
@@ -384,7 +392,7 @@ static Word16 DTFS_alignment_weight_fx(
#endif
}
- if ( diff_corr > 0 )
+ IF( diff_corr > 0 )
{
fshift_fx = n_fx;
move16();
@@ -434,6 +442,7 @@ Word16 DTFS_alignment_full_fx(
Word16 Eshift, Adiff_fx;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* Calculating the expected alignment shift */
@@ -570,7 +579,9 @@ void DTFS_phaseShift_fx( DTFS_STRUCTURE *X_fx, Word16 ph, Word16 Lag, Word16 *S_
temp = X_fx->a_fx[k];
L_temp = L_shr( L_temp2, 5 ); /* Q2 */
X_fx->a_fx[k] = round_fx( L_msu( L_mult( temp, C_fx[L_temp % ( 4 * Lag )] ), X_fx->b_fx[k], S_fx[L_temp % ( 4 * Lag )] ) ); /* X.Q */
+ move16();
X_fx->b_fx[k] = round_fx( L_mac( L_mult( X_fx->b_fx[k], C_fx[L_temp % ( 4 * Lag )] ), temp, S_fx[L_temp % ( 4 * Lag )] ) );
+ move16();
L_temp2 = L_add( L_temp2, ph );
}
}
@@ -582,7 +593,9 @@ void DTFS_phaseShift_fx( DTFS_STRUCTURE *X_fx, Word16 ph, Word16 Lag, Word16 *S_
temp = X_fx->a_fx[k];
L_temp = L_shr( L_negate( L_temp2 ), 5 ); /* Q2 */
X_fx->a_fx[k] = round_fx( L_mac( L_mult( temp, C_fx[L_temp % ( 4 * Lag )] ), X_fx->b_fx[k], S_fx[L_temp % ( 4 * Lag )] ) ); /* X.Q */
+ move16();
X_fx->b_fx[k] = round_fx( L_msu( L_mult( X_fx->b_fx[k], C_fx[L_temp % ( 4 * Lag )] ), temp, S_fx[L_temp % ( 4 * Lag )] ) );
+ move16();
L_temp2 = L_add( L_temp2, ph );
}
}
@@ -623,6 +636,7 @@ void Q2phaseShift_fx(
Word32 temp2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
temp2 = L_deposit_l( 0 );
@@ -643,6 +657,8 @@ void Q2phaseShift_fx(
X_fx->b_fx[k] = round_fx( L_mac( L_mult( X_fx->b_fx[k], C_fx[temp2 % ( 4 * Lag )] ), temp, S_fx[temp2 % ( 4 * Lag )] ) );
temp2 = L_add( temp2, (Word32) ph );
#endif
+ move16();
+ move16();
}
}
@@ -661,6 +677,8 @@ void Q2phaseShift_fx(
X_fx->b_fx[k] = round_fx( L_msu( L_mult( X_fx->b_fx[k], C_fx[temp2 % ( 4 * Lag )] ), temp, S_fx[temp2 % ( 4 * Lag )] ) );
temp2 = add( (Word16) temp2, negate( ph ) );
#endif
+ move16();
+ move16();
}
}
}
@@ -712,10 +730,12 @@ void DTFS_zeroPadd_fx(
/* recompute nH for new lag */
diff_fx = find_rem( 12800, X_fx->lag_fx, &rem_fx );
X_fx->nH_fx = find_rem( X_fx->upper_cut_off_freq_fx, diff_fx, &rem_fx );
+ move16();
if ( GE_16( sub( X_fx->upper_cut_off_freq_fx, shr( (Word16) L_mult( diff_fx, X_fx->nH_fx ), 1 ) ), diff_fx ) )
{
X_fx->nH_fx = add( X_fx->nH_fx, 1 );
+ move16();
}
}
/*===================================================================*/
@@ -762,6 +782,7 @@ void DTFS_to_fs_fx(
Word32 L_tmp1;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
IF( !FR_flag )
@@ -869,19 +890,23 @@ void DTFS_to_fs_fx(
sum = add( sum, temp );
}
La[k] = L_shr( L_a, 6 ); /* Q8 of a[k]*2.0 */
+ move32();
Lb[k] = L_shr( L_b, 6 ); /* Q8 of b[k]*2.0 */
+ move32();
L_temp = L_abs( La[k] );
if ( GT_32( L_temp, Labmax ) )
{
Labmax = L_temp;
+ move32();
}
L_temp = L_abs( Lb[k] );
if ( GT_32( L_temp, Labmax ) )
{
Labmax = L_temp;
+ move32();
}
}
@@ -942,16 +967,20 @@ void DTFS_to_fs_fx(
{
#ifdef BASOP_NOGLOB
X_fx->a_fx[k] = round_fx_o( L_shl_o( La[k], temp, &Overflow ), &Overflow ); /* Q(8+temp-16)=Q(temp-8) */
+ move16();
X_fx->a_fx[k] = mult_ro( X_fx->a_fx[k], inv_lag, &Overflow );
move16(); /* Q(temp-8+19+1-16)=Q(temp-4) of a[k]*2.0/N */
X_fx->b_fx[k] = round_fx_o( L_shl_o( Lb[k], temp, &Overflow ), &Overflow ); /* Q(8+temp-16)=Q(temp-8) */
+ move16();
X_fx->b_fx[k] = mult_ro( X_fx->b_fx[k], inv_lag, &Overflow );
move16(); /* Q(temp-8+19+1-16)=Q(temp-4) of b[k]*2.0/N */
#else
X_fx->a_fx[k] = round_fx( L_shl( La[k], temp ) ); /* Q(8+temp-16)=Q(temp-8) */
+ move16();
X_fx->a_fx[k] = mult_r( X_fx->a_fx[k], inv_lag );
move16(); /* Q(temp-8+19+1-16)=Q(temp-4) of a[k]*2.0/N */
X_fx->b_fx[k] = round_fx( L_shl( Lb[k], temp ) ); /* Q(8+temp-16)=Q(temp-8) */
+ move16();
X_fx->b_fx[k] = mult_r( X_fx->b_fx[k], inv_lag );
move16(); /* Q(temp-8+19+1-16)=Q(temp-4) of b[k]*2.0/N */
#endif
@@ -967,12 +996,14 @@ void DTFS_to_fs_fx(
X_fx->a_fx[k] = round_fx( L_shl( La[k], temp ) ); /* Q(8+temp-16)=Q(temp-8) */
X_fx->a_fx[k] = mult_r( X_fx->a_fx[k], inv_lag );
#endif
+ move16();
move16(); /* Q(temp-8+19+1-16)=Q(temp-4) of a[k]*1.0/N */
X_fx->b_fx[k] = 0;
move16();
}
X_fx->Q = sub( temp, 4 );
+ move16();
tmp = s_min( shr( X_fx->lag_fx, 1 ), sub( MAXLAG_WI, 1 ) );
FOR( k = add( nH_band, 1 ); k <= tmp; k++ )
@@ -1028,11 +1059,12 @@ static void DTFS_transform_fx(
Word32 Lw_fx, temp32_fx;
Word16 x2_256_fx[256], x1_256_fx[256];
Word16 k, m, l1;
- Word32 x_r_fx[256] = { 0 };
+ Word32 x_r_fx[256];
Word32 tmptmp3_40_fx;
Word16 temp_w;
Word16 N1;
Word16 nrg_flag = 0;
+ move16();
Word32 L_tmp;
Word16 tmp, tmp1, tmp2, frac, exp1, exp2;
Word16 expa, expb, fraca, fracb, scale;
@@ -1044,6 +1076,8 @@ static void DTFS_transform_fx(
DTFS_STRUCTURE *tmp3_dtfs_fx;
error = IVAS_ERR_OK;
+ move16();
+ set32_fx( x_r_fx, 0, 256 );
IF( ( error = DTFS_new_fx( &tmp1_dtfs_fx ) ) != IVAS_ERR_OK )
{
@@ -1062,7 +1096,7 @@ static void DTFS_transform_fx(
DTFS_copy_fx( tmp2_dtfs_fx, X2_fx );
tmp2 = 0; /* to avoid compilation warnings */
-
+ move16();
DTFS_fast_fs_inv_fx( tmp1_dtfs_fx, x1_256_fx, 256, 8 );
DTFS_fast_fs_inv_fx( tmp2_dtfs_fx, x2_256_fx, 256, 8 );
@@ -1082,7 +1116,7 @@ static void DTFS_transform_fx(
{
tmp2 = negate( tmp1 );
}
- tmp = div_s( shl( 1, ( 14 - exp2 ) ), tmp2 ); /* 29-exp2 */
+ tmp = div_s( shl( 1, sub( 14, exp2 ) ), tmp2 ); /* 29-exp2 */
L_tmp = L_shl( tmp, 16 );
if ( tmp1 < 0 )
@@ -1169,11 +1203,12 @@ static void DTFS_transform_fx(
w_fx = div_s( fracb, fraca );
exp1 = sub( expb, expa );
- w_fx = shl( w_fx, exp1 - 1 ); /*Q14*/
+ w_fx = shl( w_fx, sub( exp1, 1 ) ); /*Q14*/
}
ELSE
{
w_fx = 0;
+ move16();
}
Lw_fx = L_deposit_h( w_fx );
@@ -1189,6 +1224,7 @@ static void DTFS_transform_fx(
Lw_fx = L_add( Lw_fx, inv_fx ); /* (i+1)*inv */
/* mapping phase to 8x256 length signal */
temp32_fx = phase_fx[i]; /* Q(27-11)=Q16 due to multiplication by pow(2.0,11) */
+ move32();
j = rint_new_fx( temp32_fx );
j = s_and( j, 0x07ff );
@@ -1201,15 +1237,16 @@ static void DTFS_transform_fx(
FOR( j = 0; j < 12; j++ )
{
- m = ( 1000 * LL + l1 - OSLENGTH / 2 + j ) % LL; /* use circular addressing */
+ m = L_add( 1000 * LL - OSLENGTH / 2, add( l1, j ) ) % LL; /* use circular addressing */
x_r_fx[m] = L_mac( L_mult( x1_256_fx[m], temp_w ), x2_256_fx[m], w_fx );
+ move32();
}
tmptmp3_40_fx = L_deposit_l( 0 );
FOR( j = 0; j < 12; j++ )
{
- m = ( 1000 * LL + l1 - OSLENGTH / 2 + j ) % LL; /* use circular addressing */
+ m = L_add( 1000 * LL - OSLENGTH / 2, add( l1, j ) ) % LL; /* use circular addressing */
tmptmp3_40_fx = L_add( tmptmp3_40_fx, Mult_32_16( x_r_fx[m], sinc_fx[k][j] ) );
}
#ifdef BASOP_NOGLOB
@@ -1217,6 +1254,7 @@ static void DTFS_transform_fx(
#else
out_fx[i] = round_fx( L_shl( tmptmp3_40_fx, 2 ) );
#endif
+ move16();
}
@@ -1264,6 +1302,7 @@ void DTFS_zeroFilter_fx(
Word16 Qmin, Qab[MAXLAG_WI], na, nb;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
Qmin = 32767;
move16();
@@ -1282,11 +1321,11 @@ void DTFS_zeroFilter_fx(
FOR( n = 0; n < N; n++ )
{
#ifdef BASOP_NOGLOB
- sum1_fx = L_mac_o( sum1_fx, LPC[n], C_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )], &Overflow ); /* Q(12+15+1) */
+ sum1_fx = L_mac_o( sum1_fx, LPC[n], C_fx[i_mult( 4, temp2 ) % i_mult( 4, X_fx->lag_fx )], &Overflow ); /* Q(12+15+1) */
sum2_fx = L_mac_o( sum2_fx, LPC[n], S_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )], &Overflow );
#else
- sum1_fx = L_mac( sum1_fx, LPC[n], C_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )] ); /* Q(12+15+1) */
- sum2_fx = L_mac( sum2_fx, LPC[n], S_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )] );
+ sum1_fx = L_mac( sum1_fx, LPC[n], C_fx[i_mult( 4, temp2 ) % i_mult( 4, X_fx->lag_fx )] ); /* Q(12+15+1) */
+ sum2_fx = L_mac( sum2_fx, LPC[n], S_fx[i_mult( 4, temp2 ) % i_mult( 4, X_fx->lag_fx )] );
#endif
temp2 = add( temp2, temp );
}
@@ -1336,8 +1375,11 @@ void DTFS_zeroFilter_fx(
X_fx->a_fx[k] = round_fx( (Word32) L_shl( L_temp1, nb ) ); /* Q(13+Q+nb-16)=Q(Q+nb-3) */
X_fx->b_fx[k] = round_fx( (Word32) L_shl( L_temp2, nb ) ); /* Q(Q+nb-3) */
#endif
+ move32();
+ move32();
Qab[k] = sub( nb, 3 );
+ move16();
if ( LT_16( Qab[k], Qmin ) )
{
@@ -1455,9 +1497,12 @@ void DTFS_poleFilter_fx_9(
}
nb = sub( nb, 1 ); /* leave one more sign bit */
X_fx->a_fx[k] = round_fx( (Word32) L_shl( sum1_fx, nb ) ); /* Q(-3+n2+Q+exp+nb ) */
+ move16();
X_fx->b_fx[k] = round_fx( (Word32) L_shl( sum2_fx, nb ) );
+ move16();
Qab[k] = add( sub( nb, 3 ), n2_temp1 );
+ move16();
if ( LT_16( Qab[k], Qmin ) )
{
@@ -1466,7 +1511,7 @@ void DTFS_poleFilter_fx_9(
}
}
/* bring to the same Q */
- move16();
+
FOR( k = 0; k <= HalfLag; k++ )
{
X_fx->a_fx[k] = shl( X_fx->a_fx[k], sub( Qmin, Qab[k] ) );
@@ -1476,6 +1521,7 @@ void DTFS_poleFilter_fx_9(
}
X_fx->Q = add( X_fx->Q, Qmin );
+ move16();
return;
}
/*===================================================================*/
@@ -1539,20 +1585,21 @@ void DTFS_adjustLag_fx(
tmp = div_s( shl( 1, sub( 14, exp ) ), X_DTFS_FX->lag_fx ); /* 29 - exp */
L_tmp = L_mult0( 12800, tmp );
temp32_fx = L_shl( L_tmp, sub( exp, 23 ) );
- diff_fx = (Word16) L_shl( L_tmp, sub( exp, 29 ) );
+ diff_fx = extract_l( L_shl( L_tmp, sub( exp, 29 ) ) );
exp = norm_s( diff_fx );
tmp = div_s( shl( 1, sub( 14, exp ) ), diff_fx ); /* 29 - exp */
L_tmp = L_mult0( X_DTFS_FX->upper_cut_off_freq_fx, tmp );
- X_DTFS_FX->nH_fx = (Word16) L_shl( L_tmp, sub( exp, 29 ) );
+ X_DTFS_FX->nH_fx = extract_l( L_shl( L_tmp, sub( exp, 29 ) ) );
+ move16();
L_tmp = L_mult0( 4000, tmp );
tempnH_fx = L_shl( L_tmp, sub( exp, 23 ) );
X_DTFS_FX->nH_4kHz_fx = extract_l( L_shl( L_tmp, sub( exp, 29 ) ) );
+ move16();
-
- if ( GE_16( sub( X_DTFS_FX->upper_cut_off_freq_fx, shr( (Word16) L_mult( diff_fx, X_DTFS_FX->nH_fx ), 1 ) ), diff_fx ) )
+ if ( GE_16( sub( X_DTFS_FX->upper_cut_off_freq_fx, shr( extract_l( L_mult( diff_fx, X_DTFS_FX->nH_fx ) ), 1 ) ), diff_fx ) )
{
X_DTFS_FX->nH_fx = add( X_DTFS_FX->nH_fx, 1 );
move16();
@@ -1595,9 +1642,11 @@ Word32 DTFS_getEngy_fx(
{
Word16 k, HalfLag_fx;
Word32 en_fx = 0;
+ move32();
Word16 temp_a_fx, temp_b_fx;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
HalfLag_fx = shr( sub( X_fx->lag_fx, 1 ), 1 );
HalfLag_fx = s_min( HalfLag_fx, X_fx->nH_fx );
@@ -1619,6 +1668,7 @@ Word32 DTFS_getEngy_fx(
en_fx = L_shr( en_fx, 1 );
temp_a_fx = X_fx->a_fx[0];
+ move16();
#ifdef BASOP_NOGLOB
en_fx = L_mac0_o( en_fx, temp_a_fx, temp_a_fx, &Overflow );
#else
@@ -1668,8 +1718,10 @@ Word32 DTFS_getEngy_P2A_fx(
{
Word16 k, HalfLag_fx;
Word32 en_fx = 0;
+ move32();
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
HalfLag_fx = shr( sub( X_fx->lag_fx, 1 ), 1 );
HalfLag_fx = s_min( HalfLag_fx, X_fx->nH_fx );
@@ -1740,7 +1792,7 @@ static Word32 DTFS_setEngy_fx(
en1_fx = DTFS_getEngy_fx( X_DTFS_FX );
move16();
- if ( en1_fx == 0 )
+ IF( en1_fx == 0 )
{
return 0;
}
@@ -1748,6 +1800,7 @@ static Word32 DTFS_setEngy_fx(
IF( en2_fx == 0 )
{
factor_fx = 0;
+ move32();
}
ELSE
{
@@ -1780,9 +1833,11 @@ static Word32 DTFS_setEngy_fx(
{
L_temp_fx = Mult_32_16( factor_fx, X_DTFS_FX->a_fx[k] ); /* Q(temp+X1.Q-15) */
X_DTFS_FX->a_fx[k] = round_fx( L_temp_fx ); /* Q(temp+X1.Q-15-16)=Q(temp+X1.Q-31); */
+ move16();
L_temp_fx = Mult_32_16( factor_fx, X_DTFS_FX->b_fx[k] ); /* Q(temp+X1.Q-15) */
X_DTFS_FX->b_fx[k] = round_fx( L_temp_fx ); /* Q(temp+X1.Q-15-16)=Q(temp+X1.Q-31); */
+ move16();
}
@@ -1830,6 +1885,7 @@ void DTFS_car2pol_fx(
Word16 exp, tmp, frac;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
HalfLag_fx = s_min( shr( sub( X_fx->lag_fx, 1 ), 1 ), X_fx->nH_fx );
FOR( k = 1; k <= HalfLag_fx; k++ )
@@ -1853,6 +1909,7 @@ void DTFS_car2pol_fx(
Ltemp_fx = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */
X_fx->a_fx[k] = extract_h( L_shl( Ltemp_fx, sub( add( X_fx->Q, exp ), 15 ) ) ); /* Q */
+ move16();
}
ELSE
{
@@ -1880,6 +1937,7 @@ void DTFS_car2pol_fx(
Ltemp_fx = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */
X_fx->a_fx[k] = extract_h( L_shl( Ltemp_fx, sub( add( X_fx->Q, exp ), 15 ) ) ); /* Q */
+ move16();
}
ELSE
{
@@ -1943,9 +2001,12 @@ Word32 DTFS_setEngyHarm_fx(
Word16 exp, tmp, expa, expb, fraca, fracb, scale;
Word32 L_tmp;
Word32 Lacc_max = 0;
+ move32();
Word16 expp = 0;
+ move16();
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -2058,15 +2119,18 @@ Word32 DTFS_setEngyHarm_fx(
#else
X_fx->a_fx[k] = round_fx( L_temp_fx ); /* Q(temp+X1.Q-15-16)=Q(temp+X1.Q-31); */
#endif
+ move16();
}
if ( GE_32( Lacc_max, 2147483647 ) )
{
*Qa_fx = sub( sub( X_fx->Q, add( 1, s_min( 2, expp ) ) ), exp );
+ move16();
}
else
{
*Qa_fx = sub( sub( X_fx->Q, 1 ), exp );
+ move16();
}
return en1_fx; /* Q(2*X1.Q) */
@@ -2120,20 +2184,23 @@ static void cubicPhase_fx(
Word16 dbgshft;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
num_flag = 0;
+ move16();
den_flag = 0;
+ move16();
N = sub( N, L2 );
exp = norm_s( L1 );
tmp = div_s( shl( 1, sub( 14, exp ) ), L1 );
- L_tmp = L_shl( tmp, exp + 6 );
+ L_tmp = L_shl( tmp, add( exp, 6 ) );
f1 = round_fx( L_tmp );
exp = norm_s( L2 );
tmp = div_s( shl( 1, sub( 14, exp ) ), L2 );
- L_tmp = L_shl( tmp, exp + 6 );
+ L_tmp = L_shl( tmp, add( exp, 6 ) );
Ltemp4 = inverse_table[L2];
f2 = round_fx( L_tmp );
@@ -2173,7 +2240,7 @@ static void cubicPhase_fx(
Ltemp2 = L_shl( Mult_32_16( Ltemp2, N ), 1 );
/* IF(N%2) */
- if ( s_and( N, 1 ) == 1 )
+ if ( EQ_16( s_and( N, 1 ), 1 ) )
{
Ltemp2 = L_add( Ltemp2, 1 );
}
@@ -2326,7 +2393,7 @@ static void cubicPhase_fx(
tmp = negate( tmp );
}
- Lacc = L_shl( tmp, exp + 27 );
+ Lacc = L_shl( tmp, add( exp, 27 ) );
Lacc = L_add( Lacc, 0x08000 );
c1 = extract_h( Lacc ); /* c1 in Q27 */
@@ -2384,7 +2451,7 @@ static void cubicPhase_fx(
N2 = L_shl( L_mult0( n, n ), 14 );
Ltemp3 = L_shl( Mult_32_16( N2, n ), 1 );
- if ( s_and( N, 1 ) == 1 )
+ if ( EQ_16( s_and( N, 1 ), 1 ) )
{
Ltemp3 = L_add( Ltemp3, 1 );
}
@@ -2453,6 +2520,7 @@ void DTFS_to_erb_fx(
Word16 expa, expb, fraca, fracb, scale;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
const Word16 *erb_fx = NULL;
num_erb_fx = NUM_ERB_NB;
@@ -2556,6 +2624,7 @@ void DTFS_to_erb_fx(
out_fx[i] = round_fx( L_tmp );
#endif
+ move16();
}
}
return;
@@ -2599,6 +2668,7 @@ void erb_slot_fx(
Word16 fraca, fracb, expa, expb, scale;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
const Word16 *erb_fx = NULL; /*move16(); */
@@ -2610,14 +2680,12 @@ void erb_slot_fx(
upper_cut_off_freq_fx = 4000;
move16();
erb_fx = &( erb_NB_fx[0] );
- move16();
}
ELSE IF( EQ_16( num_erb_fx, NUM_ERB_WB ) )
{
upper_cut_off_freq_fx = 6400;
move16();
erb_fx = &( erb_WB_fx[0] );
- move16();
}
exp = norm_s( lag_fx );
@@ -2688,6 +2756,7 @@ void erb_slot_fx(
#else
mfreq_fx[j] = round_fx( L_shl( mf_fx[j], 11 ) ); /* Q15 */
#endif
+ move16();
IF( GT_16( out_fx[j], 1 ) )
{
expb = norm_l( mf_fx[j] );
@@ -2771,6 +2840,7 @@ void DTFS_erb_inv_fx(
Word16 exp, tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
IF( EQ_16( num_erb_fx, NUM_ERB_NB ) )
@@ -2809,7 +2879,7 @@ void DTFS_erb_inv_fx(
exp = norm_s( X_fx->lag_fx );
tmp = div_s( shl( 1, sub( 14, exp ) ), X_fx->lag_fx ); /* 29-exp */
- diff_fx = shl( tmp, exp - 10 ); /* Q19 */
+ diff_fx = shl( tmp, sub( exp, 10 ) ); /* Q19 */
min_q = EVS_SW_MAX;
move16();
@@ -2861,7 +2931,9 @@ void DTFS_erb_inv_fx(
#else
X_fx->a_fx[i] = round_fx( L_shl( Ltemp_fx, d2h ) ); /* Q(28-n+d2h) */
#endif
+ move16();
q[i] = add( sub( 28, n ), d2h );
+ move16();
min_q = s_min( min_q, q[i] );
BREAK;
@@ -2876,6 +2948,7 @@ void DTFS_erb_inv_fx(
}
X_fx->Q = min_q;
+ move16();
return;
}
@@ -2987,8 +3060,10 @@ void erb_add_fx(
move16();
}
ELSE
+ {
curr_erb_fx[i] = 0;
- move16();
+ move16();
+ }
}
tmp_fx = add( shl( index_fx[1], 3 ), index_fx[1] ); /* tmp=9*index[1] */
@@ -3002,19 +3077,23 @@ void erb_add_fx(
IF( EQ_16( num_erb_fx, NUM_ERB_NB ) )
{
curr_erb_fx[i] = add( AmpCB2_NB_fx[sub( add( tmp_fx, i ), 11 )], t_prev_erb_fx[i] ); /* Q13+Q13=Q13 */
+ move16();
curr_erb_fx[i] = s_max( 0, curr_erb_fx[i] );
move16();
}
ELSE IF( EQ_16( num_erb_fx, NUM_ERB_WB ) )
{
curr_erb_fx[i] = add( AmpCB2_WB_fx[sub( add( tmp2_fx, i ), 11 )], t_prev_erb_fx[i] ); /* Q13 */
+ move16();
curr_erb_fx[i] = s_max( 0, curr_erb_fx[i] );
move16();
}
}
ELSE
+ {
curr_erb_fx[i] = 0;
- move16();
+ move16();
+ }
}
return;
}
@@ -3075,17 +3154,24 @@ void quant_target_fx( DTFS_STRUCTURE *X_fx, const Word16 *curr_lpc, Word16 *w, W
tmp = round_fx( L_shl( Lacc, exp ) );
exp = sub( sub( 30, exp ), 23 );
IF( tmp )
- tmp = div_s( 16384, tmp ); /* 15+exp1 */
+ {
+ tmp = div_s( 16384, tmp ); /* 15+exp1 */
+ }
ELSE
+ {
tmp = 0;
+ move16();
+ }
Ltemp = L_deposit_h( tmp );
tmp = round_fx( Ltemp ); /* tmp in Q(22-n) */
Ltemp1 = Mult_32_16( Ltemp1, tmp ); /* Q(30-n) */
n = sub( 8, exp );
w[0] = round_fx( L_shl( Ltemp1, n ) ); /* w[0] in Q15 */
+ move16();
Ltemp2 = Mult_32_16( Ltemp2, tmp );
w[1] = round_fx( L_shl( Ltemp2, n ) ); /* w[1] in Q15 */
+ move16();
logLag = log10_fx( X_fx->lag_fx ); /* logLag=10*log10(lag), Q23 */
Ltemp3 = L_shl( L_mult( shl( X_fx->Q, 1 ), 24660 ), 9 ); /* Ltemp3=2Q*10log10(2), Q23 */
@@ -3096,20 +3182,28 @@ void quant_target_fx( DTFS_STRUCTURE *X_fx, const Word16 *curr_lpc, Word16 *w, W
Ltemp = L_add( L_sub( Ltemp, Ltemp3 ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */
target[0] = round_fx( L_shl( Mult_32_16( Ltemp, 0x6666 ), 1 ) ); /* Q11 */
+ move16();
/* Process high band */
Ltemp = DTFS_setEngyHarm_fx( 2828, X_fx->upper_cut_off_freq_of_interest_fx, 2828, X_fx->upper_cut_off_freq_fx, 1, 0, &Qh, X_fx );
Ltemp = log10_fx( Ltemp );
Ltemp = L_add( L_sub( Ltemp, Ltemp3 ), logLag ); /* Ltemp=10*log10(lag*eng), Q23 */
target[1] = round_fx( L_shl( Mult_32_16( Ltemp, 0x6666 ), 1 ) ); /* Q11 */
+ move16();
/* Need to unify the Q factors of both bands */
X_fx->Q = s_min( Ql, Qh ); /* set Q factor to be the smaller one */
- n = sub( Ql, Qh ); /* compare band Q factors */
+ move16();
+ n = sub( Ql, Qh ); /* compare band Q factors */
IF( n < 0 )
- rshiftHarmBand_fx( X_fx, 2828, X_fx->upper_cut_off_freq_fx, n );
- ELSE IF( n > 0 ) rshiftHarmBand_fx( X_fx, 0, 2828, sub( Qh, Ql ) );
+ {
+ rshiftHarmBand_fx( X_fx, 2828, X_fx->upper_cut_off_freq_fx, n );
+ }
+ ELSE IF( n > 0 )
+ {
+ rshiftHarmBand_fx( X_fx, 0, 2828, sub( Qh, Ql ) );
+ }
}
/*==========================================================================*/
@@ -3152,6 +3246,8 @@ ivas_error WIsyn_fx(
{
Word16 i;
UWord16 I = 1, flag = 0;
+ move16();
+ move16();
/* Word16 *phase_fx = (Word16*)malloc(sizeof(Word16) * (2*N)); new operator used size 2*N */
Word32 phase_fx[WI_FX_phase_fx];
Word16 alignment_fx;
@@ -3166,6 +3262,7 @@ ivas_error WIsyn_fx(
ivas_error error;
error = IVAS_ERR_OK;
+ move16();
IF( ( error = DTFS_new_fx( &CURRCW_DTFS_FX ) ) != IVAS_ERR_OK )
{
@@ -3217,7 +3314,9 @@ ivas_error WIsyn_fx(
IF( temp < 0 )
- temp = add( temp, shl( CURRCW_DTFS_FX->lag_fx, 7 ) ); /* Q7 */
+ {
+ temp = add( temp, shl( CURRCW_DTFS_FX->lag_fx, 7 ) ); /* Q7 */
+ }
find_rem( temp, shl( CURRCW_DTFS_FX->lag_fx, 7 ), &tmp_fx ); /* Q7 */
IF( FR_flag == 0 )
@@ -3241,7 +3340,7 @@ ivas_error WIsyn_fx(
tmp = shl( CURRCW_DTFS_FX->lag_fx, 7 );
exp = norm_s( tmp );
tmp = div_s( shl( 1, sub( 14, exp ) ), tmp ); /* 22-exp */
- L_tmp = L_shl( L_mult( temp, tmp ), exp + 1 );
+ L_tmp = L_shl( L_mult( temp, tmp ), add( exp, 1 ) );
tmp_fx = round_fx( L_tmp );
}
ELSE IF( alignment_fx < 0 )
@@ -3250,7 +3349,7 @@ ivas_error WIsyn_fx(
tmp = shl( CURRCW_DTFS_FX->lag_fx, 7 );
exp = norm_s( tmp );
tmp = div_s( shl( 1, sub( 14, exp ) ), tmp ); /* 22-exp */
- L_tmp = L_shl( L_mult( temp, tmp ), exp + 1 );
+ L_tmp = L_shl( L_mult( temp, tmp ), add( exp, 1 ) );
tmp_fx = negate( round_fx( L_tmp ) );
}
ELSE
@@ -3260,7 +3359,7 @@ ivas_error WIsyn_fx(
tmp = shl( CURRCW_DTFS_FX->lag_fx, 7 );
exp = norm_s( tmp );
tmp = div_s( shl( 1, sub( 14, exp ) ), tmp ); /* 22-exp */
- L_tmp = L_shl( L_mult( temp, tmp ), exp + 1 );
+ L_tmp = L_shl( L_mult( temp, tmp ), add( exp, 1 ) );
tmp_fx = round_fx( L_tmp );
}
@@ -3301,9 +3400,10 @@ ivas_error WIsyn_fx(
{
/* empty loop */
}
- L_temp = L_temp & 0x7fff;
+ L_temp = L_and( L_temp, 0x7fff );
move16(); /* fraction part */
*ph_offset_fx = extract_l( L_temp );
+ move16();
/* free(phase_fx) ; */
free( CURRCW_DTFS_FX );
@@ -3342,12 +3442,18 @@ Word16 ppp_extract_pitch_period_fx(
{
Word16 i, j, k;
Word16 spike = 0, range;
+ move16();
Word16 max = 0;
+ move16();
const Word16 *ptr = in + L_FRAME - l;
Word32 en1 = 0, Lacc, L_tmp;
+ move32();
Word16 spike_near_edge = 0, scale;
+ move16();
Word16 pos_max, neg_max;
Word16 spike_pos = 0, spike_neg = 0;
+ move16();
+ move16();
Word16 x, tmp, expa, fraca, expb, fracb, scale1, exp;
pos_max = -0x8000L;
@@ -3362,7 +3468,7 @@ Word16 ppp_extract_pitch_period_fx(
{
x = abs_s( ptr[i] );
- if ( GT_16( x, max ) )
+ IF( GT_16( x, max ) )
{
max = x;
move16();
@@ -3383,9 +3489,10 @@ Word16 ppp_extract_pitch_period_fx(
/* search for neg spike around the pos spike */
FOR( j = spike - 10; j < spike + 10; j++ )
{
- k = ( j + l ) % l;
+ k = add( j, l ) % l;
+ move16();
- if ( LT_16( ptr[k], neg_max ) )
+ IF( LT_16( ptr[k], neg_max ) )
{
neg_max = ptr[k];
move16();
@@ -3401,9 +3508,10 @@ Word16 ppp_extract_pitch_period_fx(
/* search for pos spike around the neg spike */
FOR( j = spike - 10; j < spike + 10; j++ )
{
- k = ( j + l ) % l;
+ k = add( j, l ) % l;
+ move16();
- if ( GT_16( ptr[k], pos_max ) )
+ IF( GT_16( ptr[k], pos_max ) )
{
pos_max = ptr[k];
move16();
@@ -3414,7 +3522,7 @@ Word16 ppp_extract_pitch_period_fx(
}
test();
- IF( ( LE_16( ( l - 1 - s_max( spike_pos, spike_neg ) ), 2 ) ) || ( LE_16( s_min( spike_pos, spike_neg ), 2 ) ) )
+ IF( ( LE_16( sub( sub( l, 1 ), s_max( spike_pos, spike_neg ) ), 2 ) ) || ( LE_16( s_min( spike_pos, spike_neg ), 2 ) ) )
{
*out_of_bound = 1;
move16();
@@ -3425,10 +3533,14 @@ Word16 ppp_extract_pitch_period_fx(
tmp = (Word16) ( L_max( L_mult( CUTFREE_REL_RANGE_Q2, l ), CUTFREE_ABS_RANGE_Q3 ) ); /* Q3 */
IF( tmp > 0 )
- tmp = add( tmp, 4 ); /* Q3 */
+ {
+ tmp = add( tmp, 4 ); /* Q3 */
+ }
ELSE
+ {
tmp = sub( tmp, 4 ); /* Q3 */
- range = shr( tmp, 3 ); /* Q0 */
+ }
+ range = shr( tmp, 3 ); /* Q0 */
test();
IF( ( LT_16( spike, range ) ) || ( GE_16( add( spike, range ), l ) ) )
@@ -3566,6 +3678,8 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W
{
Word32 L_sum;
Word32 maxPosEn_fx = 0, maxNegEn_fx = 0, L_temp;
+ move32();
+ move32();
Word16 i;
Word16 time_fx[256];
Word16 expa, expb, fraca, fracb, scale;
@@ -3573,6 +3687,7 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
L_sum = DTFS_getEngy_P2A_fx( &X_fx ); /* 2Q */
DTFS_fast_fs_inv_fx( &X_fx, time_fx, 256, 8 );
@@ -3589,6 +3704,7 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W
if ( GT_32( L_temp, maxPosEn_fx ) )
{
maxPosEn_fx = L_temp; /* Q(1) */
+ move32();
}
}
ELSE
@@ -3596,6 +3712,7 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W
if ( GT_32( L_temp, maxNegEn_fx ) )
{
maxNegEn_fx = L_temp; /* Q(1) */
+ move32();
}
}
}
@@ -3604,15 +3721,17 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W
IF( L_sum == 0 )
{
*pos_fx = *neg_fx = 0;
- move16();
- move16();
+ move32();
+ move32();
}
ELSE
{
IF( maxPosEn_fx == 0 )
{
*pos_fx = 0;
+ move32();
*Qpos = 31;
+ move16();
}
ELSE
{
@@ -3647,13 +3766,17 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W
L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */
*pos_fx = L_tmp;
+ move32();
*Qpos = sub( 31, exp );
+ move16();
}
IF( maxNegEn_fx == 0 )
{
*neg_fx = 0;
+ move32();
*Qneg = 31;
+ move16();
}
ELSE
{
@@ -3664,7 +3787,7 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W
#else
fraca = extract_h( L_shl( maxNegEn_fx, expa ) );
#endif
- expa = 30 - expa - 1;
+ expa = sub( Q29, expa ); // 30 - expa - 1;
expb = norm_l( L_sum );
@@ -3673,7 +3796,7 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W
#else
fracb = round_fx( L_shl( L_sum, expb ) );
#endif
- expb = 30 - expb - ( 2 * X_fx.Q );
+ expb = sub( 30, add( expb, shl( X_fx.Q, 1 ) ) );
scale = shr( sub( fraca, fracb ), 15 );
@@ -3689,7 +3812,9 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W
L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */
*neg_fx = L_tmp;
- *Qneg = 31 - exp;
+ move32();
+ *Qneg = sub( Q31, exp );
+ move16();
}
}
}
@@ -3777,19 +3902,19 @@ void GetSinCosTab_fx( Word16 L, Word16 *sinTab, Word16 *cosTab )
w = extract_h( Lw ); /* w in Q9 */
dl = extract_l( Lw ); /* dl has 16 bits left-over */
w = s_and( w, 511 );
- move16();
- move16();
/* t1=cos_table[w%512]; */
t1 = cos_table[w];
+ move16();
/* t2=cos_table[add(w,1)%512]; */
dt = cos_diff_table[w];
+ move16();
/*t2=cos_table[s_and(add(w,1),511)]; */
/*dt = sub(t2,t1); */ /* Q15 */
IF( dl < 0 )
{
L_tmp = L_add( 65536, dl );
- Ltemp = ( L_tmp * dt );
+ Ltemp = imult3216( L_tmp, dt );
}
ELSE
{
@@ -3809,13 +3934,14 @@ void GetSinCosTab_fx( Word16 L, Word16 *sinTab, Word16 *cosTab )
move16();
/* t2=cos_table[add(w,1)%512]; */
dt = cos_diff_table[w];
+ move16();
/*t2=cos_table[s_and(add(w,1),511)];move16(); */
/*dt = sub(t2,t1); */ /* dt=t2-t1, Q15 */
IF( dl < 0 )
{
L_tmp = L_add( 65536, dl );
- Ltemp = ( L_tmp * dt );
+ Ltemp = imult3216( L_tmp, dt );
}
ELSE
{
@@ -3844,11 +3970,8 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1
Word16 n_2, K;
Word16 ii_table[8];
-
- move16();
- move16();
-
K = 0;
+ move16();
FOR( k = 256; k > 0; k -= size )
{
@@ -3856,45 +3979,47 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1
}
n_2 = shr( size, 1 );
FOR( i = 1; i <= stage; i++ )
- ii_table[i - 1] = shr( size, i );
+ {
+ ii_table[i - 1] = shr( size, i );
+ }
/* Rearrange the input array in bit reversed order */
j = 0;
move16();
FOR( i = 0; i < size - 2; i = i + 2 )
{
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
IF( GT_16( j, i ) )
{
ftmp_fx = *( farray_ptr_fx + i );
*( farray_ptr_fx + i ) = *( farray_ptr_fx + j );
*( farray_ptr_fx + j ) = (Word16) ftmp_fx;
+ move32();
+ move16();
+ move16();
- ftmp_fx = *( farray_ptr_fx + i + 1 );
- *( farray_ptr_fx + i + 1 ) = *( farray_ptr_fx + j + 1 );
- *( farray_ptr_fx + j + 1 ) = (Word16) ftmp_fx;
+ ftmp_fx = *( farray_ptr_fx + add( i, 1 ) );
+ *( farray_ptr_fx + add( i, 1 ) ) = *( farray_ptr_fx + add( j, 1 ) );
+ *( farray_ptr_fx + add( j, 1 ) ) = (Word16) ftmp_fx;
+ move32();
+ move16();
+ move16();
}
k = n_2;
move16();
- WHILE( j >= k )
+ WHILE( GE_16( j, k ) )
{
j = sub( j, k );
k = shr( k, 1 );
}
- j += k;
+ j = add( j, k );
}
/* The FFT part */
- IF( isign == 1 )
+ IF( EQ_16( isign, 1 ) )
{
FOR( i = 0; i < stage; i++ ) /* i is stage counter */
{
@@ -3907,21 +4032,21 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1
FOR( j = 0; j < jj; j = j + 2 ) /* j is sample counter */
{
- ji = j * ii; /* ji is phase table index */
+ ji = i_mult( j, ii ); /* ji is phase table index */
FOR( k = j; k < size; k = k + kk ) /* k is butterfly top */
{
kj = add( k, jj ); /* kj is butterfly bottom */
- temp_sand = s_and( ( ji * K + 384 ), 511 );
+ temp_sand = s_and( ( add( i_mult( ji, K ), 384 ) ), 511 );
/* Butterfly computations */
/* ftmp_real_fx = L_sub(L_mult(*(farray_ptr_fx + kj), cos_table[ji*K]), */
/* L_mult(*(farray_ptr_fx + kj + 1), cos_table[(ji*K+384)%512])); */
- ftmp_real_fx = L_msu( L_mult( *( farray_ptr_fx + kj ), cos_table[ji * K] ),
- *( farray_ptr_fx + kj + 1 ), cos_table[temp_sand] );
+ ftmp_real_fx = L_msu( L_mult( *( farray_ptr_fx + kj ), cos_table[i_mult( ji, K )] ),
+ *( farray_ptr_fx + add( kj, 1 ) ), cos_table[temp_sand] );
/* ftmp_imag_fx = L_add(L_mult(*(farray_ptr_fx + kj + 1), cos_table[ji*K]), */
/* L_mult(*(farray_ptr_fx + kj), cos_table[(ji*K+384)%512])); */
- ftmp_imag_fx = L_mac( L_mult( *( farray_ptr_fx + kj + 1 ), cos_table[ji * K] ),
+ ftmp_imag_fx = L_mac( L_mult( *( farray_ptr_fx + add( kj, 1 ) ), cos_table[i_mult( ji, K )] ),
*( farray_ptr_fx + kj ), cos_table[temp_sand] );
tmp1 = round_fx( ftmp_real_fx );
@@ -3931,16 +4056,16 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1
*( farray_ptr_fx + kj ) = shr( tmp, 1 );
move16();
- tmp = sub( *( farray_ptr_fx + k + 1 ), tmp2 );
- *( farray_ptr_fx + kj + 1 ) = shr( tmp, 1 );
+ tmp = sub( *( farray_ptr_fx + add( k, 1 ) ), tmp2 );
+ *( farray_ptr_fx + add( kj, 1 ) ) = shr( tmp, 1 );
move16();
tmp = add( *( farray_ptr_fx + k ), tmp1 );
*( farray_ptr_fx + k ) = shr( tmp, 1 );
move16();
- tmp = add( *( farray_ptr_fx + k + 1 ), tmp2 );
- *( farray_ptr_fx + k + 1 ) = shr( tmp, 1 );
+ tmp = add( *( farray_ptr_fx + add( k, 1 ) ), tmp2 );
+ *( farray_ptr_fx + add( k, 1 ) ) = shr( tmp, 1 );
move16();
}
}
@@ -3958,21 +4083,21 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1
FOR( j = 0; j < jj; j = j + 2 ) /* j is sample counter */
{
- ji = j * ii; /* ji is phase table index */
+ ji = i_mult( j, ii ); /* ji is phase table index */
FOR( k = j; k < size; k = k + kk ) /* k is butterfly top */
{
kj = add( k, jj ); /* kj is butterfly bottom */
- temp_sand = s_and( ( ji * K + 384 ), 511 );
+ temp_sand = s_and( ( add( i_mult( ji, K ), 384 ) ), 511 );
/* Butterfly computations */
/* ftmp_real_fx = L_add(L_mult(*(farray_ptr_fx + kj), cos_table[ji*K]), */
/* L_mult(*(farray_ptr_fx + kj + 1), cos_table[(ji*K+384)%512])); */
- ftmp_real_fx = L_mac( L_mult( *( farray_ptr_fx + kj ), cos_table[ji * K] ),
+ ftmp_real_fx = L_mac( L_mult( *( farray_ptr_fx + kj ), cos_table[i_mult( ji, K )] ),
*( farray_ptr_fx + kj + 1 ), cos_table[temp_sand] );
/* ftmp_imag_fx = L_sub(L_mult(*(farray_ptr_fx + kj + 1), cos_table[ji*K]), */
/* L_mult(*(farray_ptr_fx + kj), cos_table[(ji*K+384)%512])); */
- ftmp_imag_fx = L_msu( L_mult( *( farray_ptr_fx + kj + 1 ), cos_table[ji * K] ),
+ ftmp_imag_fx = L_msu( L_mult( *( farray_ptr_fx + add( kj, 1 ) ), cos_table[i_mult( ji, K )] ),
*( farray_ptr_fx + kj ), cos_table[temp_sand] );
tmp1 = round_fx( ftmp_real_fx );
@@ -4024,7 +4149,7 @@ void r_fft_4_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word16 isign
}
/* The FFT part */
- IF( isign == 1 )
+ IF( EQ_16( isign, 1 ) )
{
/* Perform the complex FFT */
c_fft_wi_fx( farray_ptr_fx, size, stage, isign );
@@ -4033,10 +4158,12 @@ void r_fft_4_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word16 isign
ftmp1_real_fx = *farray_ptr_fx;
ftmp2_real_fx = *( farray_ptr_fx + 1 );
*farray_ptr_fx = add( ftmp1_real_fx, ftmp2_real_fx );
+ move16();
*( farray_ptr_fx + 1 ) = sub( ftmp1_real_fx, ftmp2_real_fx );
+ move16();
/* Now, handle the remaining positive frequencies */
- j = size - 2;
+ j = sub( size, 2 );
FOR( i = 2; i <= n_2; i = i + 2 )
{
ftmp1_real_fx = add( *( farray_ptr_fx + i ), *( farray_ptr_fx + j ) );
@@ -4046,24 +4173,28 @@ void r_fft_4_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word16 isign
Lftmp1_real_fx = L_deposit_h( ftmp1_real_fx );
Lftmp1_imag_fx = L_deposit_h( ftmp1_imag_fx );
- temp_sand = s_and( ( i * K + 384 ), 511 );
+ temp_sand = s_and( add( i_mult( i, K ), 384 ), 511 );
/* Ltmp1_fx = L_sub(L_mult(ftmp2_real_fx, cos_table[i*K]), L_mult(ftmp2_imag_fx, cos_table[(i*K+384)%512])); */
- Ltmp1_fx = L_msu( L_mult( ftmp2_real_fx, cos_table[i * K] ), ftmp2_imag_fx, cos_table[temp_sand] );
+ Ltmp1_fx = L_msu( L_mult( ftmp2_real_fx, cos_table[i_mult( i, K )] ), ftmp2_imag_fx, cos_table[temp_sand] );
*( farray_ptr_fx + i ) = round_fx( L_shr( L_add( Lftmp1_real_fx, Ltmp1_fx ), 1 ) );
+ move16();
/* Ltmp1_fx = L_add(L_mult(ftmp2_imag_fx, cos_table[i*K]), L_mult(ftmp2_real_fx, cos_table[(i*K+384)%512])); */
- Ltmp1_fx = L_mac( L_mult( ftmp2_imag_fx, cos_table[i * K] ), ftmp2_real_fx, cos_table[temp_sand] );
+ Ltmp1_fx = L_mac( L_mult( ftmp2_imag_fx, cos_table[i_mult( i, K )] ), ftmp2_real_fx, cos_table[temp_sand] );
*( farray_ptr_fx + i + 1 ) = round_fx( L_shr( L_add( Lftmp1_imag_fx, Ltmp1_fx ), 1 ) );
+ move16();
/* Ltmp1_fx = L_add(L_mult(ftmp2_real_fx, cos_table[j*K]), L_mult(ftmp2_imag_fx, cos_table[(j*K+384)%512])); */
- Ltmp1_fx = L_mac( L_mult( ftmp2_real_fx, cos_table[j * K] ), ftmp2_imag_fx, cos_table[temp_sand] );
+ Ltmp1_fx = L_mac( L_mult( ftmp2_real_fx, cos_table[i_mult( j, K )] ), ftmp2_imag_fx, cos_table[temp_sand] );
*( farray_ptr_fx + j ) = round_fx( L_shr( L_add( Lftmp1_real_fx, Ltmp1_fx ), 1 ) );
+ move16();
/* Ltmp1_fx = L_add(L_negate(L_mult(ftmp2_imag_fx, cos_table[j*K])), L_mult(ftmp2_real_fx, cos_table[(j*K+384)%512])); */
- Ltmp1_fx = L_msu( L_mult( ftmp2_real_fx, cos_table[temp_sand] ), ftmp2_imag_fx, cos_table[j * K] );
+ Ltmp1_fx = L_msu( L_mult( ftmp2_real_fx, cos_table[temp_sand] ), ftmp2_imag_fx, cos_table[i_mult( j, K )] );
Ltmp2_fx = L_sub( Ltmp1_fx, Lftmp1_imag_fx );
*( farray_ptr_fx + j + 1 ) = round_fx( L_shr( Ltmp2_fx, 1 ) );
- j = size - i;
+ move16();
+ j = sub( size, i );
}
}
ELSE
@@ -4093,23 +4224,27 @@ void r_fft_4_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word16 isign
Lftmp1_real_fx = L_deposit_h( ftmp1_real_fx );
Lftmp1_imag_fx = L_deposit_h( ftmp1_imag_fx );
- temp_sand = s_and( ( i * K + 384 ), 511 );
+ temp_sand = s_and( ( add( i_mult( i, K ), 384 ) ), 511 );
/* Ltmp1_fx = L_add(L_mult(ftmp2_real_fx, cos_table[i*K]), L_mult(ftmp2_imag_fx, cos_table[(i*K+384)%512])); */
- Ltmp1_fx = L_mac( L_mult( ftmp2_real_fx, cos_table[i * K] ), ftmp2_imag_fx, cos_table[temp_sand] );
+ Ltmp1_fx = L_mac( L_mult( ftmp2_real_fx, cos_table[i_mult( i, K )] ), ftmp2_imag_fx, cos_table[temp_sand] );
*( farray_ptr_fx + i ) = round_fx( L_shr( L_add( Lftmp1_real_fx, Ltmp1_fx ), 1 ) );
+ move16();
/* Ltmp1_fx = L_sub(L_mult(ftmp2_imag_fx, cos_table[i*K]), L_mult(ftmp2_real_fx, cos_table[(i*K+384)%512])); */
- Ltmp1_fx = L_msu( L_mult( ftmp2_imag_fx, cos_table[i * K] ), ftmp2_real_fx, cos_table[temp_sand] );
+ Ltmp1_fx = L_msu( L_mult( ftmp2_imag_fx, cos_table[i_mult( i, K )] ), ftmp2_real_fx, cos_table[temp_sand] );
*( farray_ptr_fx + i + 1 ) = round_fx( L_shr( L_add( Lftmp1_imag_fx, Ltmp1_fx ), 1 ) );
+ move16();
/* Ltmp1_fx = L_sub(L_mult(ftmp2_real_fx, cos_table[j*K]), L_mult(ftmp2_imag_fx, cos_table[(j*K+384)%512])); */
- Ltmp1_fx = L_msu( L_mult( ftmp2_real_fx, cos_table[j * K] ), ftmp2_imag_fx, cos_table[temp_sand] );
+ Ltmp1_fx = L_msu( L_mult( ftmp2_real_fx, cos_table[i_mult( j, K )] ), ftmp2_imag_fx, cos_table[temp_sand] );
*( farray_ptr_fx + j ) = round_fx( L_shr( L_add( Lftmp1_real_fx, Ltmp1_fx ), 1 ) );
+ move16();
/* Ltmp1_fx = L_negate(L_add(L_mult(ftmp2_imag_fx, cos_table[j*K]), L_mult(ftmp2_real_fx, cos_table[(j*K+384)%512]))); */
- Ltmp1_fx = L_negate( L_mac( L_mult( ftmp2_imag_fx, cos_table[j * K] ), ftmp2_real_fx, cos_table[temp_sand] ) );
+ Ltmp1_fx = L_negate( L_mac( L_mult( ftmp2_imag_fx, cos_table[i_mult( j, K )] ), ftmp2_real_fx, cos_table[temp_sand] ) );
Ltmp2_fx = L_sub( Ltmp1_fx, Lftmp1_imag_fx );
*( farray_ptr_fx + j + 1 ) = round_fx( L_shr( Ltmp2_fx, 1 ) );
+ move16();
}
/* Perform the complex IFFT */
@@ -4162,13 +4297,15 @@ void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE
Word16 exp, tmp, exp1;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
- move16();
retX_fx->lag_fx = X1_fx->lag_fx;
+ move16();
retX_fx->Q = sub( X2_fx.Q, 1 ); /* equivalent to 2x MIN_FX(shr(sub(X_fx->lag_fx,1),1),X_fx->nH_fx) */
- HalfLag = s_min( shr( X1_fx->lag_fx, 1 ), X1_fx->nH_fx );
move16();
+ HalfLag = s_min( shr( X1_fx->lag_fx, 1 ), X1_fx->nH_fx );
+
FOR( k = 1; k <= HalfLag; k++ )
{
#ifdef BASOP_NOGLOB
@@ -4184,11 +4321,15 @@ void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE
exp1 = sub( sub( 30, exp ), 2 * X1_fx->Q + 1 );
IF( tmp )
- tmp = div_s( 16384, tmp ); /* 15+exp1 */
+ {
+ tmp = div_s( 16384, tmp ); /* 15+exp1 */
+ }
ELSE
+ {
tmp = 0;
+ }
tmp = shr( tmp, 1 );
- q = 15 + exp1 + 16 - 1;
+ q = sub( add( add( 15, exp1 ), 16 ), 1 );
IF( tmp )
{
@@ -4199,10 +4340,15 @@ void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE
Ltemp_fx = Isqrt_lc( L_tmp, &exp ); /* Q(31-exp) */
}
ELSE
+ {
Ltemp_fx = 0;
+ move32();
+ }
- if ( s_and( q, 1 ) )
+ IF( s_and( q, 1 ) )
+ {
Ltemp_fx = Mult_32_16( Ltemp_fx, 23170 ); /* 23170 is 1/sqrt(2) in Q15 */
+ }
q = shr( q, 1 ); /* Ltemp_fx in Q(q+16) */
@@ -4213,21 +4359,25 @@ void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE
Ltemp_fx = L_add_o( L_shr( Ltemp_fx, 15 ), L_mult_o( X1_fx->b_fx[k], d1h, &Overflow ), &Overflow ); /* sin(w) in Q(q+16+Q-15) */
sn = round_fx_o( L_shl_o( Ltemp_fx, sub( 30, add( q, X1_fx->Q ) ), &Overflow ), &Overflow ); /* Q15 */
retX_fx->b_fx[k] = mult_ro( X2_fx.a_fx[k], sn, &Overflow ); /* X2_fx.Q */
+ move16();
Ltemp_fx = L_mult0( X1_fx->a_fx[k], d1l );
Ltemp_fx = L_add_o( L_shr( Ltemp_fx, 15 ), L_mult_o( X1_fx->a_fx[k], d1h, &Overflow ), &Overflow ); /* cos(w) in Q(q+Q+1) */
cn = round_fx_o( L_shl_o( Ltemp_fx, sub( 30, add( q, X1_fx->Q ) ), &Overflow ), &Overflow ); /* Q15 */
retX_fx->a_fx[k] = mult_ro( X2_fx.a_fx[k], cn, &Overflow ); /* X2_fx.Q */
+ move16();
#else
Ltemp_fx = L_mult0( X1_fx->b_fx[k], d1l );
Ltemp_fx = L_add( L_shr( Ltemp_fx, 15 ), L_mult( X1_fx->b_fx[k], d1h ) ); /* sin(w) in Q(q+16+Q-15) */
sn = round_fx( L_shl( Ltemp_fx, sub( 30, add( q, X1_fx->Q ) ) ) ); /* Q15 */
retX_fx->b_fx[k] = mult_r( X2_fx.a_fx[k], sn ); /* X2_fx.Q */
+ move16();
Ltemp_fx = L_mult0( X1_fx->a_fx[k], d1l );
Ltemp_fx = L_add( L_shr( Ltemp_fx, 15 ), L_mult( X1_fx->a_fx[k], d1h ) ); /* cos(w) in Q(q+Q+1) */
cn = round_fx( L_shl( Ltemp_fx, sub( 30, add( q, X1_fx->Q ) ) ) ); /* Q15 */
retX_fx->a_fx[k] = mult_r( X2_fx.a_fx[k], cn ); /* X2_fx.Q */
+ move16();
#endif
}
k = sub( k, 1 );
@@ -4283,6 +4433,7 @@ Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE *X_fx, Word16 lband, Word16 hband,
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
en = L_deposit_l( 0 );
@@ -4321,7 +4472,7 @@ Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE *X_fx, Word16 lband, Word16 hband,
#ifdef BASOP_NOGLOB
Lacc = L_mac_o( Lacc, curr_lpc[i], cos_tab[n % M_fx], &Overflow ); /* Q28 */
#else
- Lacc = L_mac( Lacc, curr_lpc[i], cos_tab[n % M_fx] ); /* Q28 */
+ Lacc = L_mac( Lacc, curr_lpc[i], cos_tab[n % M_fx] ); /* Q28 */
#endif
n = add( n, k4 ); /* n=4*i*k */
}
@@ -4336,7 +4487,7 @@ Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE *X_fx, Word16 lband, Word16 hband,
#ifdef BASOP_NOGLOB
Lacc = L_msu_o( Lacc, curr_lpc[i], sin_tab[n % M_fx], &Overflow ); /* Q28 */
#else
- Lacc = L_msu( Lacc, curr_lpc[i], sin_tab[n % M_fx] ); /* Q28 */
+ Lacc = L_msu( Lacc, curr_lpc[i], sin_tab[n % M_fx] ); /* Q28 */
#endif
n = add( n, k4 ); /* n=4*i*k */
}
@@ -4345,7 +4496,7 @@ Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE *X_fx, Word16 lband, Word16 hband,
#ifdef BASOP_NOGLOB
Lacc = L_add_o( Mult_32_32( Re, Re ), Mult_32_32( Im, Im ), &Overflow ); /* Lacc=Re^2+Im^2 in Q23 */
#else
- Lacc = L_add( Mult_32_32( Re, Re ), Mult_32_32( Im, Im ) ); /* Lacc=Re^2+Im^2 in Q23 */
+ Lacc = L_add( Mult_32_32( Re, Re ), Mult_32_32( Im, Im ) ); /* Lacc=Re^2+Im^2 in Q23 */
#endif
Ltemp = L_mult0( X_fx->a_fx[k], X_fx->a_fx[k] ); /* 2*a[k]^2 in 2Q */
/* Ltemp=(Word32)L_sat32_40(divide_dp(Ltemp,Lacc,-19,1)); : Ltemp in Q(2Q-13) */
@@ -4428,6 +4579,7 @@ void DTFS_poleFilter_fx( DTFS_STRUCTURE *X_fx, Word16 *LPC, Word16 N, Word16 *S_
Word16 exp, tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
Qmin = 32767;
move16();
@@ -4443,8 +4595,8 @@ void DTFS_poleFilter_fx( DTFS_STRUCTURE *X_fx, Word16 *LPC, Word16 N, Word16 *S_
FOR( n = 0; n < N; n++ )
{
#ifdef BASOP_NOGLOB
- sum1_fx = L_mac_o( sum1_fx, LPC[n], C_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )], &Overflow ); /* Q(12+15+1) */
- sum2_fx = L_mac_o( sum2_fx, LPC[n], S_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )], &Overflow ); /* Q(12+15+1) */
+ sum1_fx = L_mac_o( sum1_fx, LPC[n], C_fx[shl( temp2, 2 ) % shl( X_fx->lag_fx, 2 )], &Overflow ); /* Q(12+15+1) */
+ sum2_fx = L_mac_o( sum2_fx, LPC[n], S_fx[shl( temp2, 2 ) % shl( X_fx->lag_fx, 2 )], &Overflow ); /* Q(12+15+1) */
#else
sum1_fx = L_mac( sum1_fx, LPC[n], C_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )] ); /* Q(12+15+1) */
sum2_fx = L_mac( sum2_fx, LPC[n], S_fx[( 4 * temp2 ) % ( 4 * X_fx->lag_fx )] ); /* Q(12+15+1) */
@@ -4520,7 +4672,9 @@ void DTFS_poleFilter_fx( DTFS_STRUCTURE *X_fx, Word16 *LPC, Word16 N, Word16 *S_
}
nb = sub( nb, 1 ); /* leave one more sign bit */
X_fx->a_fx[k] = round_fx( L_shl( sum1_fx, nb ) ); /* Q(Q-temp1+22+nb-16)=Q(Q-temp1+nb+2) */
+ move16();
X_fx->b_fx[k] = round_fx( L_shl( sum2_fx, nb ) ); /* Q(Q-temp1+nb+2) */
+ move16();
Qab[k] = add( sub( add( nb, 2 ), temp1 ), X_fx->Q );
@@ -4540,6 +4694,7 @@ void DTFS_poleFilter_fx( DTFS_STRUCTURE *X_fx, Word16 *LPC, Word16 N, Word16 *S_
}
X_fx->Q = Qmin;
+ move16();
}
/*===================================================================*/
/* FUNCTION : poleFilter_setup_fx() */
@@ -4574,6 +4729,7 @@ void poleFilter_setup_fx( const Word16 *LPC, Word16 N, DTFS_STRUCTURE X_fx, Word
Word16 exp, tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
HalfLag = s_min( shr( X_fx.lag_fx, 1 ), X_fx.nH_fx );
@@ -4618,7 +4774,11 @@ void poleFilter_setup_fx( const Word16 *LPC, Word16 N, DTFS_STRUCTURE X_fx, Word
}
n2 = sub( n2, 1 );
temp1 = pf_temp1[k] = round_fx( (Word32) L_shl( sum1_fx, n2 ) ); /* Q(12+15+1+n2-16)=Q(12+n2) */
+ move16();
+ move16();
temp2 = pf_temp2[k] = round_fx( (Word32) L_shl( sum2_fx, n2 ) ); /* Q(12+n2) */
+ move16();
+ move16();
/* Calculate the circular convolution */
sum = L_mac( L_mult( temp1, temp1 ), temp2, temp2 ); /* Q(12+n2+12+n2+1)=Q(25+2*n2) */
@@ -4677,7 +4837,7 @@ Word32 DTFS_getEngy_band_wb_fx( DTFS_STRUCTURE X_fx, Word16 lband, Word16 hband
{
freq_fx = L_mult( k, 12800 );
- if ( GE_32( freq_fx, L_lband ) )
+ IF( GE_32( freq_fx, L_lband ) )
{
BREAK;
}
@@ -4687,7 +4847,7 @@ Word32 DTFS_getEngy_band_wb_fx( DTFS_STRUCTURE X_fx, Word16 lband, Word16 hband
FOR( k = 1; k <= HalfLag; k++ )
{
freq_fx = L_mult( k, 12800 );
- if ( GE_32( freq_fx, L_hband ) )
+ IF( GE_32( freq_fx, L_hband ) )
{
BREAK;
}
@@ -4702,14 +4862,14 @@ Word32 DTFS_getEngy_band_wb_fx( DTFS_STRUCTURE X_fx, Word16 lband, Word16 hband
}
en_fx = L_shr( en_fx, 1 ); /* 2*X1.Q+1 */
- if ( lband == 0 )
+ IF( lband == 0 )
{
en_fx = L_mac0( en_fx, X_fx.a_fx[0], X_fx.a_fx[0] ); /* 2*X1.Q+1 */
}
/* IF ((X_fx.lag_fx%2 == 0) && (hband == X_fx.upper_cut_off_freq_fx)) */
test();
- IF( ( s_and( X_fx.lag_fx, 1 ) == 0 ) && ( hband == X_fx.upper_cut_off_freq_fx ) )
+ IF( ( s_and( X_fx.lag_fx, 1 ) == 0 ) && EQ_16( hband, X_fx.upper_cut_off_freq_fx ) )
{
en_fx = L_mac0( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] );
en_fx = L_mac0( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] );
diff --git a/lib_com/window_fx.c b/lib_com/window_fx.c
index d848b2dd38998370f39b718fafb097111395bfd0..97443e3b594aadfa39b35e1efaf58a0cdfd67e73 100644
--- a/lib_com/window_fx.c
+++ b/lib_com/window_fx.c
@@ -7,7 +7,6 @@
#include "options.h"
#include
#include "basop_util.h"
-#include "prot_fx1.h"
#define PI_HALF_0Q15 51472 /* ~=round(pi/2*2^15) */
#define PI2_15Q16 0x0006487F /* ~=round(2*PI*2^16) */
@@ -19,7 +18,7 @@
#define P92_0Q15 30147 /* ~=round(0.92*2^15) */
#include "options.h"
#include "rom_basop_util.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
void ham_cos_window(
@@ -32,16 +31,17 @@ void ham_cos_window(
Word32 cte, cc;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move16();
#endif
assert( n1 >= 102 ); /* if n1 is too low -> overflow in div_l */
/* cte = PI2/(Float32)(2*n1 - 1); */
BASOP_SATURATE_WARNING_OFF_EVS
- move16();
cte = L_deposit_l( div_l( PI2_10Q21, sub( shl( n1, 1 ), 1 ) ) ); /*0Q15*/
BASOP_SATURATE_WARNING_ON_EVS
cc = 0;
+ move32();
FOR( i = 0; i < n1; i++ )
{
/* fh_f[i] = 0.54f - 0.46f * (Float32)cos(cc); */
@@ -61,7 +61,7 @@ void ham_cos_window(
/* cte = PI2/(Float32)(4*n2 - 1); */
cte = L_deposit_l( div_l( PI2_11Q20, sub( shl( n2, 2 ), 1 ) ) ); /*0Q15*/
cc = 0;
- move16();
+ move32();
add( n1, n2 );
BASOP_SATURATE_WARNING_OFF_EVS
@@ -96,9 +96,10 @@ void ham_cos_window_ivas(
// cte_fx = div_s(1, sub(shl(n1, 1), 1));
cc_fx = 0;
move16();
- for ( i = 0; i < n1; i++ )
+ FOR( i = 0; i < n1; i++ )
{
*fh++ = sub( 17694, mult( getCosWord16R2( cc_fx ), 15073 ) );
+ move16();
cc_fx = div_s( add( i, 1 ), sub( shl( n1, 1 ), 1 ) ); // add(cc_fx, cte_fx);
}
@@ -109,8 +110,8 @@ void ham_cos_window_ivas(
for ( i = 0; i < n2; i++ )
{
*fh++ = getCosWord16R2( cc_fx );
+ move16();
cc_fx = div_s( add( i, 1 ), sub( shl( n1, 2 ), 1 ) );
- ;
}
return;
diff --git a/lib_com/window_ola_fx.c b/lib_com/window_ola_fx.c
index 32ae48d50392969cfbf442082bfadc76cf8cc985..40c31f8fd9d7d4eeee81b0e24a634b2e8cd0cbf8 100644
--- a/lib_com/window_ola_fx.c
+++ b/lib_com/window_ola_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Function prototypes */
#include "stl.h"
void sinq_fx(
@@ -32,7 +31,7 @@ void sinq_fx(
#ifdef BASOP_NOGLOB
tmp1 = add_sat( shl_sat( tmp, 1 ), phi ); /*Q15 */
#else
- tmp1 = add( shl( tmp, 1 ), phi ); /*Q15 */
+ tmp1 = add( shl( tmp, 1 ), phi ); /*Q15 */
#endif
L_tmp = L_mult( tmp1, tmp1 ); /*Q31 */
L_tmp = Mult_32_16( L_tmp, tmp1 ); /*Q31 */
@@ -67,9 +66,10 @@ void sinq_fx(
tmp_old = L_shl_sat( L_tmp, 1 ); /*Q31 */
x[i] = round_fx_sat( tmp_old ); /*Q15 */
#else
- tmp_old = L_shl( L_tmp, 1 ); /*Q31 */
- x[i] = round_fx( tmp_old ); /*Q15 */
+ tmp_old = L_shl( L_tmp, 1 ); /*Q31 */
+ x[i] = round_fx( tmp_old ); /*Q15 */
#endif
+ move16();
}
return;
@@ -130,6 +130,7 @@ void window_ola_fx(
move32();
}
*Q_sig = add( *Q_sig, temp );
+ move16();
/* rescaling for overlapp add */
@@ -137,14 +138,17 @@ void window_ola_fx(
{
Copy_Scale_sig( OldauOut, OldauOut, L, sub( *Q_sig, add( *Q_old, 15 ) ) );
*Q_old = sub( *Q_sig, 15 );
+ move16();
}
ELSE IF( LT_16( add( *Q_old, 15 ), *Q_sig ) )
{
Scale_sig32( ImdctOut, L, sub( add( *Q_old, 15 ), *Q_sig ) );
*Q_sig = add( *Q_old, 15 );
+ move16();
}
*Q_sig = *Q_old; /*fixing output to new Q_old */
+ move16();
decimate = 1;
@@ -285,6 +289,7 @@ void window_ola_fx(
FOR( i = 0; i < temp_len; i++ )
{
*p1++ = round_fx( L_shl( *pa++, 1 ) );
+ move16();
}
/*p1=paout+shr(L,1);*/
@@ -293,6 +298,7 @@ void window_ola_fx(
FOR( i = 0; i < temp_len; i++ )
{
*p1++ = round_fx( L_negate( L_shl( *pa--, 1 ) ) );
+ move16();
}
@@ -323,11 +329,10 @@ void window_ola_fx(
{
#ifdef BASOP_NOGLOB
*p1 = add_sat( mult( *p1, *p2 ), shl_sat( mult( *p4, *p3 ), 5 ) ); /*auOut[i]*SS2[i]+ OldauOut[i+n]*(SS2[L-n-i-1])/(wret2[i]+0.01f);;*/
- move16();
#else
- *p1 = add( mult( *p1, *p2 ), shl( mult( *p4, *p3 ), 5 ) ); /*auOut[i]*SS2[i]+ OldauOut[i+n]*(SS2[L-n-i-1])/(wret2[i]+0.01f);;*/
- move16();
+ *p1 = add( mult( *p1, *p2 ), shl( mult( *p4, *p3 ), 5 ) ); /*auOut[i]*SS2[i]+ OldauOut[i+n]*(SS2[L-n-i-1])/(wret2[i]+0.01f);;*/
#endif
+ move16();
p1++;
p2++;
p3++;
@@ -362,6 +367,7 @@ void window_ola_fx(
p3 -= decimate;
*p1++ = round_fx( L_add( L_shl( Mult_32_16( *pa++, *p5-- ), 1 ), L_deposit_h( *p4++ ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */
#endif
+ move16();
/* paout[i] = ImdctOut[L/2 + i] * win_right[(2*L_FRAME16k-(n16+(i-n)/2))*decimate-1-decay-windecay48]+OldauOut[i];
paout[i+1] = ImdctOut[L/2 + i +1] * win_int_right[2*L_FRAME16k-(n16+(i-n)/2)-1-windecay16]+OldauOut[i+1];*/
}
@@ -380,6 +386,7 @@ void window_ola_fx(
*p1++ = round_fx( L_sub( L_deposit_h( *p4++ ), L_shl( Mult_32_16( *pa--, *p5-- ), 1 ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */
*p1++ = round_fx( L_sub( L_deposit_h( *p4++ ), L_shl( Mult_32_16( *pa--, *p3 ), 1 ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */
#endif
+ move16();
p3 -= decimate;
/* paout[L/2 + i ] = -ImdctOut[L - 1 - i] * win_int_right[(3*L_FRAME16k/2-1-i/2)-windecay16]+OldauOut[i+L/2];
paout[L/2 + i +1] = -ImdctOut[L - 1 - (i+1)] * win_right[(3*L_FRAME16k/2-1-i/2)*decimate+decay-windecay48]+OldauOut[i+L/2+1]; */
@@ -387,7 +394,9 @@ void window_ola_fx(
FOR( i = 0; i < n; i += 2 )
{
*p1++ = round_fx_sat( L_sub_sat( L_deposit_h( *p4++ ), L_shl( *pa--, 1 ) ) );
+ move16();
*p1++ = round_fx_sat( L_sub_sat( L_deposit_h( *p4++ ), L_shl( *pa--, 1 ) ) );
+ move16();
/* paout[L/2 + i +1] = -ImdctOut[L - 1 - (i+1)]+OldauOut[i+L/2+1] ;
paout[L/2 + i ] = -ImdctOut[L - 1 - i]+OldauOut[i+L/2]; */
}
@@ -402,7 +411,9 @@ void window_ola_fx(
FOR( i = 0; i < temp_len; i += 2 )
{
*p1++ = round_fx( L_negate( L_shl( Mult_32_16( *pa++, *p2-- ), 1 ) ) );
+ move16();
*p1++ = round_fx( L_negate( L_shl( Mult_32_16( *pa++, *p3 ), 1 ) ) );
+ move16();
p3 -= decimate;
/* OldauOut[L/2 + i] = -ImdctOut[i] * win_int_left[(L_FRAME16k/2-i/2-1)];
OldauOut[L/2 + i +1] = -ImdctOut[i+1] * win_left[(L_FRAME16k/2-i/2-1)*decimate+decay]*/
@@ -417,7 +428,9 @@ void window_ola_fx(
FOR( i = 0; i < temp_len; i += 2 )
{
*p1++ = round_fx( L_negate( L_shl( Mult_32_16( *pa--, *p2 ), 1 ) ) );
+ move16();
*p1++ = round_fx( L_negate( L_shl( Mult_32_16( *pa--, *p3-- ), 1 ) ) );
+ move16();
p2 -= decimate;
/* OldauOut[ i] = -ImdctOut[L/2 - 1 - i] *win_left[(L_FRAME16k-i/2)*decimate-decay-1];
OldauOut[ i +1] = -ImdctOut[L/2 - 1 - (i +1)] * win_int_left[L_FRAME16k-(i/2)-1];; */
@@ -441,6 +454,7 @@ void window_ola_fx(
#else
*p1++ = round_fx( L_add( L_shl( Mult_32_16( *pa++, *p3 ), 1 ), L_deposit_h( *p4++ ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */
#endif
+ move16();
p3 -= decimate;
/*paout[i] = ImdctOut[L/2 + i] * win_right[(2*L-i)*decimate-1-decay-windecay48]+OldauOut[i];*/
}
@@ -456,12 +470,14 @@ void window_ola_fx(
#else
*p1++ = round_fx( L_sub( L_deposit_h( *p4++ ), L_shl( Mult_32_16( *pa--, *p3 ), 1 ) ) ); /* (( Qin + Q15 -15)+1 + ( Qin - 15 + 16))-1 */
#endif
+ move16();
p3 -= decimate;
/* paout[L/2 + i] = -ImdctOut[L - 1 - i] * win_right[(3*L/2-1-i)*decimate+decay-windecay48]+OldauOut[i+L/2]; */
}
FOR( i = 0; i < n; i++ )
{
*p1++ = round_fx_sat( L_sub_sat( L_deposit_h( *p4++ ), L_shl( *pa--, 1 ) ) );
+ move16();
/* paout[L/2 + i] = -ImdctOut[L - 1 - i] + OldauOut[i+L/2]; */
}
}
@@ -475,6 +491,7 @@ void window_ola_fx(
FOR( i = 0; i < temp_len; i++ )
{
*p1++ = round_fx( L_negate( L_shl( Mult_32_16( *pa++, *p2 ), 1 ) ) );
+ move16();
p2 -= decimate;
/*OldauOut[L/2 + i] = -ImdctOut[i] * win_left[(L/2-i-1)*decimate+decay]; */
}
@@ -486,6 +503,7 @@ void window_ola_fx(
FOR( i = 0; i < temp_len; i++ )
{
*p1++ = round_fx( L_negate( L_shl( Mult_32_16( *pa--, *p2 ), 1 ) ) );
+ move16();
p2 -= decimate;
/* OldauOut[ i] = -ImdctOut[L/2 - 1 - i] * win_left[(L-i)*decimate-decay-1]; */
}
@@ -498,7 +516,9 @@ void window_ola_fx(
FOR( i = 0; i < n; i++ )
{
*p1 = round_fx( L_negate( L_shl( *pa--, 1 ) ) );
+ move16();
*p2++ = *p1++;
+ move16();
}
return;
@@ -532,35 +552,51 @@ void window_ola_ext_fx(
n = shr( mult( shl( L, Q5 ), N_ZERO_BY_FS ), Q5 );
n16 = N16_CORE_SW;
+ move16();
windecay48 = WINDECAY48;
+ move16();
windecay16 = WINDECAY16;
+ move16();
decimate = 1;
+ move16();
decay = 0;
+ move16();
tcx_get_windows_mode1( left_mode, right_mode, win_left, win_right, win_int_left, win_int_right, L );
+ test();
IF( EQ_16( L, L_FRAME32k ) || EQ_16( L, L_FRAME16k ) )
{
decimate = 3;
+ move16();
decay = 1;
+ move16();
}
ELSE IF( EQ_16( L, L_FRAME8k ) )
{
decimate = 6;
+ move16();
decay = 2;
+ move16();
}
ELSE IF( EQ_16( L, 512 ) )
{
windecay48 = WINDECAY48_256;
+ move16();
decimate = 1;
+ move16();
decay = 0;
+ move16();
}
ELSE IF( EQ_16( L, 256 ) )
{
windecay48 = WINDECAY48_256;
+ move16();
decimate = 2;
+ move16();
decay = 0;
+ move16();
}
paout = auOut - n;
@@ -569,71 +605,88 @@ void window_ola_ext_fx(
{
FOR( i = n; i < shr( L, 1 ); i += 2 )
{
- paout[i] = L_add_sat( Mpy_32_16_1( Mpy_32_16_1( ImdstOut[shr( L, 1 ) + i], sign_right ), win_right[( 2 * L_FRAME16k - ( n16 + ( i - n ) / 2 ) ) * decimate - 1 - decay - windecay48] ), OldauOut[i] );
- paout[i + 1] = L_add_sat( Mpy_32_16_1( Mpy_32_16_1( ImdstOut[shr( L, 1 ) + i + 1], sign_right ), win_int_right[2 * L_FRAME16k - ( n16 + ( i - n ) / 2 ) - 1 - windecay16] ), OldauOut[i + 1] );
+ paout[i] = L_add_sat( Mpy_32_16_1( Mpy_32_16_1( ImdstOut[add( shr( L, 1 ), i )], sign_right ), win_right[sub( sub( sub( i_mult( ( sub( 2 * L_FRAME16k, add( n16, shr( sub( i, n ), 1 ) ) ) ), decimate ), 1 ), decay ), windecay48 )] ), OldauOut[i] );
+ move32();
+ paout[i + 1] = L_add_sat( Mpy_32_16_1( Mpy_32_16_1( ImdstOut[add( add( shr( L, 1 ), i ), 1 )], sign_right ), win_int_right[sub( sub( sub( 2 * L_FRAME16k, add( n16, shr( sub( i, n ), 1 ) ) ), 1 ), windecay16 )] ), OldauOut[i + 1] );
+ move32();
}
FOR( i = 0; i < shr( L, 1 ) - n; i += 2 )
{
- paout[shr( L, 1 ) + i + 1] = L_add_sat( Mpy_32_16_1( L_negate( ImdstOut[L - 1 - ( i + 1 )] ), win_right[( 3 * L_FRAME16k / 2 - 1 - i / 2 ) * decimate + decay - windecay48] ), OldauOut[i + shr( L, 1 ) + 1] );
- paout[shr( L, 1 ) + i] = L_add_sat( Mpy_32_16_1( L_negate( ImdstOut[L - 1 - i] ), win_int_right[( 3 * L_FRAME16k / 2 - 1 - i / 2 ) - windecay16] ), OldauOut[i + shr( L, 1 )] );
+ paout[add( add( shr( L, 1 ), i ), 1 )] = L_add_sat( Mpy_32_16_1( L_negate( ImdstOut[sub( sub( L, 1 ), add( i, 1 ) )] ), win_right[sub( add( i_mult( ( sub( 3 * L_FRAME16k / 2 - 1, shr( i, 1 ) ) ), decimate ), decay ), windecay48 )] ), OldauOut[add( add( i, shr( L, 1 ) ), 1 )] );
+ move32();
+ paout[add( shr( L, 1 ), i )] = L_add_sat( Mpy_32_16_1( L_negate( ImdstOut[sub( sub( L, 1 ), i )] ), win_int_right[sub( sub( 3 * L_FRAME16k / 2 - 1, shr( i, 1 ) ), windecay16 )] ), OldauOut[add( i, shr( L, 1 ) )] );
+ move32();
}
FOR( i = sub( shr( L, 1 ), n ); i < shr( L, 1 ); i += 2 )
{
- paout[shr( L, 1 ) + i + 1] = L_add_sat( L_negate( ImdstOut[L - 1 - ( i + 1 )] ), OldauOut[i + shr( L, 1 ) + 1] );
- paout[shr( L, 1 ) + i] = L_add_sat( L_negate( ImdstOut[L - 1 - i] ), OldauOut[i + shr( L, 1 )] );
+ paout[add( add( shr( L, 1 ), i ), 1 )] = L_add_sat( L_negate( ImdstOut[sub( sub( L, 1 ), add( i, 1 ) )] ), OldauOut[add( add( i, shr( L, 1 ) ), 1 )] );
+ move32();
+ paout[add( shr( L, 1 ), i )] = L_add_sat( L_negate( ImdstOut[sub( L, add( 1, i ) )] ), OldauOut[add( i, shr( L, 1 ) )] );
+ move32();
}
FOR( i = 0; i < shr( L, 1 ); i += 2 )
{
- OldauOut[shr( L, 1 ) + i + 1] = Mpy_32_16_1( Mpy_32_16_1( ImdstOut[i + 1], sign_left ), win_left[( L_FRAME16k / 2 - i / 2 - 1 ) * decimate + decay] );
- OldauOut[shr( L, 1 ) + i] = Mpy_32_16_1( Mpy_32_16_1( ImdstOut[i], sign_left ), win_int_left[( L_FRAME16k / 2 - i / 2 - 1 )] );
+ OldauOut[add( add( shr( L, 1 ), i ), 1 )] = Mpy_32_16_1( Mpy_32_16_1( ImdstOut[i + 1], sign_left ), win_left[add( i_mult( sub( L_FRAME16k / 2 - 1, shr( i, 1 ) ), decimate ), decay )] );
+ move32();
+ OldauOut[add( shr( L, 1 ), i )] = Mpy_32_16_1( Mpy_32_16_1( ImdstOut[i], sign_left ), win_int_left[sub( L_FRAME16k / 2 - 1, shr( i, 1 ) )] );
+ move32();
}
FOR( i = n; i < shr( L, 1 ); i += 2 )
{
- OldauOut[i] = Mpy_32_16_1( L_negate( ImdstOut[shr( L, 1 ) - 1 - i] ), win_left[( L_FRAME16k - i / 2 ) * decimate - decay - 1] );
- OldauOut[i + 1] = Mpy_32_16_1( L_negate( ImdstOut[shr( L, 1 ) - 1 - ( i + 1 )] ), win_int_left[L_FRAME16k - i / 2 - 1] );
+ OldauOut[i] = Mpy_32_16_1( L_negate( ImdstOut[sub( sub( shr( L, 1 ), 1 ), i )] ), win_left[sub( sub( i_mult( sub( L_FRAME16k, shr( i, 1 ) ), decimate ), decay ), 1 )] );
+ move32();
+ OldauOut[i + 1] = Mpy_32_16_1( L_negate( ImdstOut[sub( sub( shr( L, 1 ), 1 ), add( i, 1 ) )] ), win_int_left[sub( L_FRAME16k - 1, shr( i, 1 ) )] );
+ move32();
}
}
ELSE
{
FOR( i = n; i < shr( L, 1 ); i++ )
{
- paout[i] = L_add_sat( Mpy_32_16_1( Mpy_32_16_1( ImdstOut[shr( L, 1 ) + i], sign_right ), win_right[( 2 * L - i ) * decimate - 1 - decay - windecay48] ), OldauOut[i] );
+ paout[i] = L_add_sat( Mpy_32_16_1( Mpy_32_16_1( ImdstOut[add( shr( L, 1 ), i )], sign_right ), win_right[sub( sub( sub( i_mult( ( sub( shl( L, 1 ), i ) ), decimate ), 1 ), decay ), windecay48 )] ), OldauOut[i] );
+ move32();
}
FOR( i = 0; i < shr( L, 1 ) - n; i++ )
{
- paout[shr( L, 1 ) + i] = L_add_sat( Mpy_32_16_1( L_negate( ImdstOut[L - 1 - i] ), win_right[( 3 * shr( L, 1 ) - 1 - i ) * decimate + decay - windecay48] ), OldauOut[i + shr( L, 1 )] );
+ paout[add( shr( L, 1 ), i )] = L_add_sat( Mpy_32_16_1( L_negate( ImdstOut[sub( L, add( 1, i ) )] ), win_right[sub( add( i_mult( ( sub( sub( i_mult( 3, shr( L, 1 ) ), 1 ), i ) ), decimate ), decay ), windecay48 )] ), OldauOut[add( i, shr( L, 1 ) )] );
+ move32();
}
FOR( i = sub( shr( L, 1 ), n ); i < shr( L, 1 ); i++ )
{
- paout[shr( L, 1 ) + i] = L_add_sat( L_negate( ImdstOut[L - 1 - i] ), OldauOut[i + shr( L, 1 )] );
+ paout[add( shr( L, 1 ), i )] = L_add_sat( L_negate( ImdstOut[sub( L, add( 1, i ) )] ), OldauOut[add( i, shr( L, 1 ) )] );
+ move32();
}
FOR( i = 0; i < shr( L, 1 ); i++ )
{
- OldauOut[shr( L, 1 ) + i] = Mpy_32_16_1( Mpy_32_16_1( ImdstOut[i], sign_left ), win_left[( shr( L, 1 ) - i - 1 ) * decimate + decay] );
+ OldauOut[add( shr( L, 1 ), i )] = Mpy_32_16_1( Mpy_32_16_1( ImdstOut[i], sign_left ), win_left[add( i_mult( ( sub( shr( L, 1 ), add( i, 1 ) ) ), decimate ), decay )] );
+ move32();
}
FOR( i = n; i < shr( L, 1 ); i++ )
{
- OldauOut[i] = Mpy_32_16_1( L_negate( ImdstOut[shr( L, 1 ) - 1 - i] ), win_left[( L - i ) * decimate - decay - 1] );
+ OldauOut[i] = Mpy_32_16_1( L_negate( ImdstOut[sub( shr( L, 1 ), add( 1, i ) )] ), win_left[sub( sub( i_mult( sub( L, i ), decimate ), decay ), 1 )] );
+ move32();
}
}
FOR( i = 0; i < n; i++ )
{
- OldauOut[i] = L_negate( ImdstOut[shr( L, 1 ) - 1 - i] );
+ OldauOut[i] = L_negate( ImdstOut[sub( shr( L, 1 ), add( 1, i ) )] );
+ move32();
}
FOR( i = 0; i < n; i++ )
{
- paout[L + i] = OldauOut[i];
+ paout[add( L, i )] = OldauOut[i];
+ move32();
}
return;
@@ -665,6 +718,8 @@ void core_switching_OLA_fx(
const Word16 *pt4, *pt5;
Word16 tmp, tmp2, temp_len;
Word16 decimate = 0, delta = 0; /* initialize just to avoid compiler warnings */
+ move16();
+ move16();
const Word16 *on_win, *on_win_int;
Word16 a, b, divisor, buf_offset;
Word32 L_tmp;
diff --git a/lib_com/wtda.c b/lib_com/wtda.c
index 053e892f1b985850165859e0a949f9f201768a24..f1b47ee6c06df5a4f7e40ab03fc49588644e515b 100644
--- a/lib_com/wtda.c
+++ b/lib_com/wtda.c
@@ -42,7 +42,7 @@
#include
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif // IVAS_FLOAT_FIXED
/*--------------------------------------------------------------------------*
@@ -374,127 +374,153 @@ void wtda_fx32(
tcx_get_windows_mode1( left_mode, right_mode, win_left, win_right, win_int_left, win_int_right, L );
decimate = 1; /* L_FRAME 48k */
+ move16();
decay = 0;
+ move16();
windecay48 = (Word16) WINDECAY48; // (int16_t)(2 * ((float)L_FRAME48k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_48
+ move16();
IF( EQ_16( L, L_FRAME32k ) || EQ_16( L, L_FRAME16k ) )
{
decimate = 3;
+ move16();
decay = 1;
+ move16();
}
ELSE IF( EQ_16( L, L_FRAME8k ) )
{
decimate = 6;
+ move16();
decay = 2;
+ move16();
}
- switch ( L ) // (int16_t)((float)L * N_ZERO_MDCT_NS / FRAME_SIZE_NS)
+ SWITCH( L ) // (int16_t)((float)L * N_ZERO_MDCT_NS / FRAME_SIZE_NS)
{
case L_FRAME16k:
n = 90;
- break;
+ move16();
+ BREAK;
case L_FRAME32k:
n = 180;
- break;
+ move16();
+ BREAK;
case L_FRAME48k:
n = 270;
- break;
+ move16();
+ BREAK;
default:
n = (Word16) ( ( L * N_ZERO_MDCT_NS ) / FRAME_SIZE_NS );
- break;
+ move16();
+ BREAK;
}
windecay16 = (Word16) WINDECAY16; // (int16_t)(2 * ((float)L_FRAME16k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_16;
/* algorithmic delay reduction */
i = 0;
+ move16();
- if ( old_wtda == NULL )
+ IF( old_wtda == NULL )
{
allsig_r = new_audio + n;
allsig_l = new_audio + n - L;
}
- else
+ ELSE
{
allsig_r = new_audio + n;
allsig_l = old_wtda + n;
}
- if ( EQ_16( L, L_FRAME32k ) )
+ IF( EQ_16( L, L_FRAME32k ) )
{
- for ( i = 0; i < L / 2 - n; i += 2 )
+ FOR( i = 0; i < sub( L / 2, n ); i += 2 )
{
- idx1 = L / 2 - i - 1;
- idx2 = 3 * L_FRAME16k / 2 - i / 2 - 1 - windecay16;
- idx3 = L / 2 + i;
- idx4 = 3 * L_FRAME16k / 2 + i / 2 - windecay16;
+ idx1 = sub( sub( shr( L, 1 ), i ), 1 );
+ idx2 = sub( sub( 3 * L_FRAME16k / 2 - 1, shr( i, 1 ) ), windecay16 );
+ idx3 = add( shr( L, 1 ), i );
+ idx4 = sub( add( 3 * L_FRAME16k / 2, shr( i, 1 ) ), windecay16 );
wtda_audio[i] = L_sub_sat( Mpy_32_16_1( -allsig_r[idx1], win_int_right[idx2] ), Mpy_32_16_1( allsig_r[idx3], win_int_right[idx4] ) );
+ move32();
- idx1 = L / 2 - ( i + 1 ) - 1;
- idx2 = ( 3 * L_FRAME16k / 2 - i / 2 - 1 ) * decimate + decay - windecay48;
- idx3 = L / 2 + i + 1;
- idx4 = ( 3 * L_FRAME16k / 2 + 1 + i / 2 ) * decimate - decay - 1 - windecay48;
+ idx1 = sub( sub( shr( L, 1 ), add( i, 1 ) ), 1 );
+ idx2 = sub( add( i_mult( ( sub( sub( 3 * L_FRAME16k / 2, shr( i, 1 ) ), 1 ) ), decimate ), decay ), windecay48 );
+ idx3 = add( add( shr( L, 1 ), i ), 1 );
+ idx4 = sub( sub( sub( i_mult( ( add( 3 * L_FRAME16k / 2 + 1, shr( i, 1 ) ) ), decimate ), decay ), 1 ), windecay48 );
wtda_audio[i + 1] = L_sub_sat( Mpy_32_16_1( -allsig_r[idx1], win_right[idx2] ), Mpy_32_16_1( allsig_r[idx3], win_right[idx4] ) );
+ move32();
}
- for ( i = L / 2 - n; i < L / 2; i += 2 )
+ FOR( i = L / 2 - n; i < L / 2; i += 2 )
{
- wtda_audio[i] = -allsig_r[L / 2 - i - 1];
- wtda_audio[i + 1] = -allsig_r[L / 2 - ( i + 1 ) - 1];
+ wtda_audio[i] = L_negate( allsig_r[sub( sub( shr( L, 1 ), i ), 1 )] );
+ move32();
+ wtda_audio[i + 1] = L_negate( allsig_r[sub( sub( shr( L, 1 ), add( i, 1 ) ), 1 )] );
+ move32();
}
- for ( i = 0; i < n; i += 2 )
+ FOR( i = 0; i < n; i += 2 )
{
- wtda_audio[i + L / 2] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[( i / 2 ) * decimate + decay] ), new_audio[n - i - 1] );
- wtda_audio[i + L / 2 + 1] = L_sub_sat( Mpy_32_16_1( allsig_l[i + 1], win_int_left[i / 2] ), new_audio[n - ( i + 1 ) - 1] );
+ wtda_audio[add( i, shr( L, 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[add( i_mult( shr( i, 1 ), decimate ), decay )] ), new_audio[sub( sub( n, i ), 1 )] );
+ move32();
+ wtda_audio[add( add( i, shr( L, 1 ) ), 1 )] = L_sub_sat( Mpy_32_16_1( allsig_l[i + 1], win_int_left[i / 2] ), new_audio[sub( sub( n, add( i, 1 ) ), 1 )] );
+ move32();
}
- for ( i = n; i < L / 2; i += 2 )
+ FOR( i = n; i < L / 2; i += 2 )
{
idx1 = i;
- idx2 = ( i / 2 ) * decimate + decay;
- idx3 = L - i - 1;
- idx4 = ( L / 2 - i / 2 ) * decimate - 1 - decay;
- wtda_audio[i + L / 2] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) );
-
- idx1 = i + 1;
- idx2 = i / 2;
- idx3 = L - ( i + 1 ) - 1;
- idx4 = L / 2 - i / 2 - 1;
- wtda_audio[i + L / 2 + 1] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_int_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_int_left[idx4] ) );
+ move16();
+ idx2 = add( i_mult( shr( i, 1 ), decimate ), decay );
+ idx3 = sub( sub( L, i ), 1 );
+ idx4 = sub( sub( i_mult( sub( shr( L, 1 ), shr( i, 1 ) ), decimate ), 1 ), decay );
+ wtda_audio[add( i, shr( L, 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) );
+ move32();
+
+ idx1 = add( i, 1 );
+ idx2 = shr( i, 1 );
+ idx3 = sub( sub( L, add( i, 1 ) ), 1 );
+ idx4 = sub( sub( shr( L, 1 ), shr( i, 1 ) ), 1 );
+ wtda_audio[add( add( i, shr( L, 1 ) ), 1 )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_int_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_int_left[idx4] ) );
+ move32();
}
}
- else
+ ELSE
{
- for ( i = 0; i < L / 2 - n; i++ )
+ FOR( i = 0; i < L / 2 - n; i++ )
{
- idx1 = L / 2 - i - 1;
- idx2 = 3 * L / 2 * decimate - ( i + 1 ) * decimate + decay - windecay48;
- idx3 = L / 2 + i;
- idx4 = 3 * L / 2 * decimate - 1 + ( i + 1 ) * decimate - decay - windecay48;
+ idx1 = sub( sub( shr( L, 1 ), i ), 1 );
+ idx2 = sub( add( sub( i_mult( i_mult( 3, shr( L, 1 ) ), decimate ), i_mult( add( i, 1 ), decimate ) ), decay ), windecay48 );
+ idx3 = add( shr( L, 1 ), i );
+ idx4 = sub( sub( add( sub( i_mult( i_mult( 3, shr( L, 1 ) ), decimate ), 1 ), i_mult( add( i, 1 ), decimate ) ), decay ), windecay48 );
wtda_audio[i] = L_sub_sat( Mpy_32_16_1( -allsig_r[idx1], win_right[idx2] ), Mpy_32_16_1( allsig_r[idx3], win_right[idx4] ) );
+ move32();
}
- for ( i = L / 2 - n; i < L / 2; i++ )
+ FOR( i = L / 2 - n; i < L / 2; i++ )
{
- wtda_audio[i] = -allsig_r[L / 2 - i - 1];
+ wtda_audio[i] = L_negate( allsig_r[sub( sub( shr( L, 1 ), i ), 1 )] );
+ move32();
}
- for ( i = 0; i < n; i++ )
+ FOR( i = 0; i < n; i++ )
{
- wtda_audio[i + L / 2] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[i * decimate + decay] ), new_audio[n - i - 1] );
+ wtda_audio[add( i, shr( L, 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[add( i_mult( i, decimate ), decay )] ), new_audio[sub( sub( n, i ), 1 )] );
+ move32();
}
- for ( i = n; i < L / 2; i++ )
+ FOR( i = n; i < L / 2; i++ )
{
idx1 = i;
- idx2 = i * decimate + decay;
- idx3 = L - i - 1;
- idx4 = L * decimate - i * decimate - 1 - decay;
- wtda_audio[i + L / 2] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) );
+ move16();
+ idx2 = add( i_mult( i, decimate ), decay );
+ idx3 = sub( sub( L, i ), 1 );
+ idx4 = sub( sub( sub( i_mult( L, decimate ), i_mult( i, decimate ) ), 1 ), decay );
+ wtda_audio[add( i, shr( L, 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) );
+ move32();
}
}
- if ( old_wtda != NULL )
+ IF( old_wtda != NULL )
{
Copy32( new_audio, old_wtda, L );
}
diff --git a/lib_com/wtda_fx.c b/lib_com/wtda_fx.c
index dcc9b8229106403b6b422d325bf896b652faef6b..b20771f8cec8d7bb6f612290256471ea1d07161e 100644
--- a/lib_com/wtda_fx.c
+++ b/lib_com/wtda_fx.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* required by wmc_tool */
-#include "prot_fx2.h" /* required by wmc_tool */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* required by wmc_tool */
#include "stat_com.h"
/*--------------------------------------------------------------------------*
* mvr2r_inv()
@@ -284,7 +283,7 @@ void wtda_fx(
}
- IF( L == L_FRAME32k )
+ IF( EQ_16( L, L_FRAME32k ) )
{
/* decimate = 3 */
@@ -403,8 +402,9 @@ void wtda_fx(
}
*Q = add( *Q, 15 ); /* output Q */
+ move16();
- if ( old_wtda != NULL )
+ IF( old_wtda != NULL )
{
Copy( new_audio, old_wtda, L );
diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c
index 01298f6ddb2f3eb99d434673f8fc6b3af43f862e..92dddd54fa1de4e115fddb27348f923624e3fe52 100644
--- a/lib_dec/ACcontextMapping_dec_fx.c
+++ b/lib_dec/ACcontextMapping_dec_fx.c
@@ -9,8 +9,7 @@
#include "rom_dec.h"
#include "basop_util.h"
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_rom_com.h"
diff --git a/lib_dec/FEC_HQ_core.c b/lib_dec/FEC_HQ_core.c
index 23b587ac1dbe2f6a5cecfe407b8084ecad7e995c..5dd3351aace8647f9f7e9a86153354ef4d89727d 100644
--- a/lib_dec/FEC_HQ_core.c
+++ b/lib_dec/FEC_HQ_core.c
@@ -43,8 +43,7 @@
#include "prot.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif
#ifndef IVAS_FLOAT_FIXED
@@ -1551,68 +1550,79 @@ void save_synthesis_hq_fec_fx(
{
case EVS_MONO:
post_hq_delay = NS2SA( st->output_Fs, POST_HQ_DELAY_NS );
+ move16();
BREAK;
case IVAS_SCE:
post_hq_delay = NS2SA( st->output_Fs, DELAY_CLDFB_NS );
+ move16();
BREAK;
case IVAS_CPE_DFT:
- IF( hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF )
+ IF( EQ_16( hCPE->nchan_out, 1 ) && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF )
{
post_hq_delay = NS2SA( st->output_Fs, DELAY_CLDFB_NS );
+ move16();
}
ELSE
{
post_hq_delay = 0;
+ move16();
}
BREAK;
default:
post_hq_delay = 0;
+ move16();
BREAK;
}
+ test();
+ test();
+ test();
+ test();
+ test();
IF( ( EQ_16( st->codec_mode, MODE1 ) && st->hTcxDec != NULL ) && ( ( EQ_16( st->core, ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) )
{
- Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, output_frame - post_hq_delay + NS2SA( st->output_Fs, PH_ECU_MEM_NS ) );
- FOR( int i = 0; i < output_frame; i++ )
+ Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ) );
+ FOR( Word16 i = 0; i < output_frame; i++ )
{
- st->hTcxDec->old_synthFB_fx[i + output_frame - post_hq_delay] = extract_h( output_fx[i] );
+ st->hTcxDec->old_synthFB_fx[sub( add( i, output_frame ), post_hq_delay )] = extract_h( output_fx[i] );
+ move16();
}
- IF( EQ_16( st->element_mode, EVS_MONO ) )
+ IF( st->element_mode == EVS_MONO )
{
/* reset the remaining buffer, which is read in TCX concealment the necessary samples to fill
this buffer are not available for all cases, the impact on the output is limited */
- set16_fx( st->hTcxDec->old_synthFB_fx + 2 * output_frame - post_hq_delay, 0, post_hq_delay );
+ set16_fx( st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), 0, post_hq_delay );
IF( GE_16( output_frame, L_FRAME16k ) )
{
- Copy( st->prev_synth_buffer_fx, st->hTcxDec->old_synthFB_fx + 2 * output_frame - NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS ), NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) );
+ Copy( st->prev_synth_buffer_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) );
}
ELSE
{
- Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + 2 * output_frame, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
+ Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
}
- IF( NE_16( st->core, ACELP_CORE ) )
+ IF( st->core != ACELP_CORE )
{
IF( GE_16( output_frame, L_FRAME16k ) )
{
- Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + 2 * output_frame - NS2SA( st->output_Fs, DELAY_CLDFB_NS ), NS2SA( st->output_Fs, DELAY_CLDFB_NS ) );
- Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + 2 * output_frame, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
+ Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA( st->output_Fs, DELAY_CLDFB_NS ) );
+ Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
}
ELSE
{
- Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + 2 * output_frame - NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS ), NS2SA( st->output_Fs, DELAY_CLDFB_NS ) );
- Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + 2 * output_frame - NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
+ Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA( st->output_Fs, DELAY_CLDFB_NS ) );
+ Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
}
}
}
ELSE
{
- IF( NE_16( st->core, ACELP_CORE ) )
+ IF( st->core != ACELP_CORE )
{
- Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + 2 * output_frame - post_hq_delay, post_hq_delay );
- Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + 2 * output_frame, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
+ Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), post_hq_delay );
+ Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
}
}
}
diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c
index 6d709b728c2e4df0c883de89835d0541ebceace5..3a5b71cff6db35db2eefd5992aafa17ee8581395 100644
--- a/lib_dec/FEC_HQ_core_fx.c
+++ b/lib_dec/FEC_HQ_core_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
@@ -49,10 +48,11 @@ static void Regression_Anal_fx(
Word32 b_p_fx[MAX_PGF + 1];
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* Initialize */
- FOR( i = 0; i < num_pgf + 1; i++ )
+ FOR( i = 0; i < add( num_pgf, 1 ); i++ )
{
aindex_fx[i] = 0;
move16();
@@ -69,19 +69,24 @@ static void Regression_Anal_fx(
/*aindex[0]=num_pgf; */
aindex_fx[0] = num_pgf;
move16();
- FOR( i = 1; i < num_pgf + 1; i++ )
+ FOR( i = 1; i < add( num_pgf, 1 ); i++ )
{
aindex_fx[1] = add( aindex_fx[1], i );
+ move16();
aindex_fx[2] = add( aindex_fx[2], i_mult( i, i ) );
+ move16();
}
/* Calculate b[] */
FOR( i = 0; i < num_pgf; i++ )
{
b_p_fx[0] = L_add( b_p_fx[0], L_shr( values_fx[i], 2 ) ); /*10 */
+ move32();
#ifdef BASOP_NOGLOB
b_p_fx[1] = L_add( b_p_fx[1], Mult_32_16( values_fx[i], shl_o( sub( num_pgf, i ), 13, &Overflow ) ) ); /*10 */
+ move32();
#else
b_p_fx[1] = L_add( b_p_fx[1], Mult_32_16( values_fx[i], shl( sub( num_pgf, i ), 13 ) ) ); /*10 */
+ move32();
#endif
}
@@ -91,7 +96,9 @@ static void Regression_Anal_fx(
L_tmp1 = L_sub( Mult_32_16( b_p_fx[0], shl( aindex_fx[2], 10 ) ), Mult_32_16( b_p_fx[1], shl( aindex_fx[1], 10 ) ) ); /*5 */
L_tmp2 = L_sub( Mult_32_16( b_p_fx[1], shl( aindex_fx[0], 10 ) ), Mult_32_16( b_p_fx[0], shl( aindex_fx[1], 10 ) ) ); /*5 */
r_p_fx[0] = Mult_32_16( L_tmp1, tmp );
+ move32();
r_p_fx[1] = Mult_32_16( L_tmp2, tmp );
+ move32();
return;
}
@@ -112,6 +119,7 @@ static void FEC_scaling_fx(
FOR( j = start_band[i]; j < end_band[i]; j++ )
{
t_audio_q_fx[j] = Mult_32_16( old_coeffs_fx[j], Norm_gain_fx[i] ); /*12 */
+ move32();
}
}
@@ -122,10 +130,12 @@ static void FEC_scaling_fx(
IF( Random( HQ_FEC_seed ) < 0 )
{
t_audio_q_fx[j] = Mult_32_16( L_negate( old_coeffs_fx[j] ), Norm_gain_fx[i] ); /*12*/
+ move32();
}
ELSE
{
t_audio_q_fx[j] = Mult_32_16( old_coeffs_fx[j], Norm_gain_fx[i] ); /*12*/
+ move32();
}
}
}
@@ -159,6 +169,7 @@ void HQ_FEC_processing_fx(
HQ_DEC_HANDLE hHQ_core;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
hHQ_nbfec = st_fx->hHQ_nbfec;
hHQ_core = st_fx->hHQ_core;
@@ -186,9 +197,10 @@ void HQ_FEC_processing_fx(
}
test();
test();
- if ( EQ_16( st_fx->prev_old_bfi, 1 ) && EQ_16( st_fx->nbLostCmpt, 1 ) && EQ_16( output_frame, L_FRAME8k ) )
+ IF( EQ_16( st_fx->prev_old_bfi, 1 ) && EQ_16( st_fx->nbLostCmpt, 1 ) && EQ_16( output_frame, L_FRAME8k ) )
{
st_fx->nbLostCmpt = add( st_fx->nbLostCmpt, 1 );
+ move32();
}
/* Frequency-domain FEC */
@@ -209,6 +221,7 @@ void HQ_FEC_processing_fx(
FOR( i = 0; i < output_frame; i++ )
{
hHQ_nbfec->old_coeffs_fx[i] = Mult_32_16( hHQ_nbfec->old_coeffs_fx[i], 23170 ); /*23170, 3dB, Q15*/
+ move32();
t_audio_q_fx[i] = hHQ_nbfec->old_coeffs_fx[i];
move32();
}
@@ -225,7 +238,7 @@ void HQ_FEC_processing_fx(
{
FOR( i = 0; i < HQ_FEC_BAND_SIZE; i++ )
{
- t_audio_q_fx[i + sfm * HQ_FEC_BAND_SIZE] = L_negate( t_audio_q_fx[i + sfm * HQ_FEC_BAND_SIZE] );
+ t_audio_q_fx[add( i, imult1616( sfm, HQ_FEC_BAND_SIZE ) )] = L_negate( t_audio_q_fx[add( i, imult1616( sfm, HQ_FEC_BAND_SIZE ) )] );
move32();
}
}
@@ -239,7 +252,7 @@ void HQ_FEC_processing_fx(
{
FOR( i = 0; i < HQ_FEC_BAND_SIZE; i++ )
{
- t_audio_q_fx[i + sfm * HQ_FEC_BAND_SIZE] = L_negate( t_audio_q_fx[i + sfm * HQ_FEC_BAND_SIZE] );
+ t_audio_q_fx[add( i, imult1616( sfm, HQ_FEC_BAND_SIZE ) )] = L_negate( t_audio_q_fx[add( i, imult1616( sfm, HQ_FEC_BAND_SIZE ) )] );
move32();
}
}
@@ -265,6 +278,7 @@ void HQ_FEC_processing_fx(
FOR( i = 0; i < output_frame; i++ )
{
hHQ_nbfec->old_coeffs_fx[i] = Mult_32_16( hHQ_nbfec->old_coeffs_fx[i], 23170 );
+ move32();
t_audio_q_fx[i] = hHQ_nbfec->old_coeffs_fx[i];
move32();
}
@@ -274,6 +288,7 @@ void HQ_FEC_processing_fx(
FOR( i = 0; i < RANDOM_START * 8; i++ )
{
hHQ_nbfec->old_coeffs_fx[i] = Mult_32_16( hHQ_nbfec->old_coeffs_fx[i], 23170 );
+ move32();
t_audio_q_fx[i] = hHQ_nbfec->old_coeffs_fx[i];
move32();
}
@@ -281,6 +296,7 @@ void HQ_FEC_processing_fx(
FOR( i = RANDOM_START * 8; i < output_frame; i++ )
{
hHQ_nbfec->old_coeffs_fx[i] = Mult_32_16( hHQ_nbfec->old_coeffs_fx[i], 23170 );
+ move32();
IF( Random( &hHQ_nbfec->HQ_FEC_seed ) < 0 )
{
t_audio_q_fx[i] = L_negate( hHQ_nbfec->old_coeffs_fx[i] );
@@ -345,12 +361,14 @@ void HQ_FEC_processing_fx(
IF( r_p_fx[1] > 0 )
{
r_p_fx[1] = L_deposit_l( 0 );
+ move32();
norm_p_fx[i] = L_shr( norm_values_fx[0], 7 ); /*5*/
move32();
}
ELSE
{
norm_p_fx[i] = L_add( r_p_fx[0], L_mult0( extract_l( r_p_fx[1] ), sub( add( st_fx->nbLostCmpt, num_pgf ), 1 ) ) );
+ move32();
}
test();
@@ -363,7 +381,7 @@ void HQ_FEC_processing_fx(
#ifdef BASOP_NOGLOB
tmp_fx = shl_sat( tmp_fx, add( 6, sub( exp2, exp1 ) ) ); /*14*/
#else
- tmp_fx = shl( tmp_fx, add( 6, sub( exp2, exp1 ) ) ); /*14*/
+ tmp_fx = shl( tmp_fx, add( 6, sub( exp2, exp1 ) ) ); /*14*/
#endif
if ( GT_16( tmp_fx, 16384 ) )
{
@@ -374,7 +392,9 @@ void HQ_FEC_processing_fx(
FOR( j = 0; j < Num_bands_p[i]; j++ )
{
#ifdef BASOP_NOGLOB
- hHQ_nbfec->Norm_gain_fx[k++] = shl_o( tmp_fx, 1, &Overflow );
+ hHQ_nbfec->Norm_gain_fx[k] = shl_o( tmp_fx, 1, &Overflow );
+ move16();
+ k = add( k, 1 );
#else
hHQ_nbfec->Norm_gain_fx[k++] = shl( tmp_fx, 1 );
#endif
@@ -388,7 +408,7 @@ void HQ_FEC_processing_fx(
{
hHQ_nbfec->Norm_gain_fx[k] = mult_r( hHQ_nbfec->Norm_gain_fx[k], 23170 );
move16();
- k++;
+ k = add( k, 1 );
}
}
}
@@ -435,7 +455,9 @@ void ivas_HQ_FEC_Mem_update_fx(
hHQ_core = st_fx->hHQ_core;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
+ move32(); // for tmp_energy_fx
IF( EQ_16( output_frame, L_FRAME8k ) )
{
@@ -458,7 +480,7 @@ void ivas_HQ_FEC_Mem_update_fx(
test();
test();
test();
- IF( ( GT_32( hHQ_nbfec->old_coeffs_fx[i + j * HQ_FEC_BAND_SIZE], 0 ) && LT_32( t_audio_q_fx[i + j * HQ_FEC_BAND_SIZE], 0 ) ) || ( LT_32( hHQ_nbfec->old_coeffs_fx[i + j * HQ_FEC_BAND_SIZE], 0 ) && GT_32( t_audio_q_fx[i + j * HQ_FEC_BAND_SIZE], 0 ) ) )
+ IF( ( hHQ_nbfec->old_coeffs_fx[add( i, imult1616( j, HQ_FEC_BAND_SIZE ) )] > 0 && t_audio_q_fx[add( i, imult1616( j, HQ_FEC_BAND_SIZE ) )] < 0 ) || ( hHQ_nbfec->old_coeffs_fx[add( i, imult1616( j, HQ_FEC_BAND_SIZE ) )] < 0 && t_audio_q_fx[add( i, imult1616( j, HQ_FEC_BAND_SIZE ) )] > 0 ) )
{
hHQ_nbfec->prev_sign_switch[j] = add( hHQ_nbfec->prev_sign_switch[j], 1 );
move16();
@@ -473,7 +495,7 @@ void ivas_HQ_FEC_Mem_update_fx(
IF( ( EQ_16( hqswb_clas, HQ_HVQ ) ) || ( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) )
{
/* First group */
- logqnorm_fx( t_audio_q_fx, 12, ynrm, 32, WID_G1, ( hqswb_clas == HQ_HVQ ) );
+ logqnorm_fx( t_audio_q_fx, 12, ynrm, 32, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
j = ynrm[0];
move16();
offset = WID_G1;
@@ -481,17 +503,15 @@ void ivas_HQ_FEC_Mem_update_fx(
FOR( i = 1; i < SFM_G1; i++ )
{
- logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G1, ( hqswb_clas == HQ_HVQ ) );
- offset += WID_G1;
- move16();
+ logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
+ offset = add( offset, WID_G1 );
}
/* Second group */
FOR( i = SFM_G1; i < SFM_G1 + 2; i++ )
{
- logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G2, ( hqswb_clas == HQ_HVQ ) );
- offset += WID_G2;
- move16();
+ logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G2, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
+ offset = add( offset, WID_G2 );
}
}
@@ -511,7 +531,8 @@ void ivas_HQ_FEC_Mem_update_fx(
L_tmp = L_deposit_l( 0 );
FOR( j = 0; j < Num_bands_p[i]; j++ )
{
- L_tmp = L_add( L_tmp, L_shr( normq_fx[k++], 3 ) ); /*11*/
+ L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/
+ k = add( k, 1 );
}
#ifdef BASOP_NOGLOB
tmp_fx = shl_o( inv_tbl_fx[Num_bands_p[i]], 1, &Overflow ); /*16*/
@@ -524,7 +545,7 @@ void ivas_HQ_FEC_Mem_update_fx(
}
test();
test();
- IF( ( c_switching_flag ) || ( ( EQ_16( st_fx->last_core, ACELP_CORE ) ) && ( EQ_16( st_fx->core, HQ_CORE ) ) ) )
+ IF( ( c_switching_flag ) || ( ( st_fx->last_core == ACELP_CORE ) && ( EQ_16( st_fx->core, HQ_CORE ) ) ) )
{
FOR( i = 0; i < MAX_SB_NB; i++ )
{
@@ -549,11 +570,14 @@ void ivas_HQ_FEC_Mem_update_fx(
/*st->diff_energy = (float)fabs((st->energy_MA_Curr[1] - st->energy_MA_Curr[0])/st->energy_MA_Curr[0]); */
hHQ_nbfec->diff_energy_fx = abs_s( sub( hHQ_nbfec->energy_MA_Curr_fx[1], hHQ_nbfec->energy_MA_Curr_fx[0] ) );
+ move16();
exp1 = sub( norm_l( hHQ_nbfec->diff_energy_fx ), 1 );
exp2 = norm_l( hHQ_nbfec->energy_MA_Curr_fx[0] );
hHQ_nbfec->diff_energy_fx = div_s( extract_h( L_shl( hHQ_nbfec->diff_energy_fx, exp1 ) ), extract_h( L_shl( hHQ_nbfec->energy_MA_Curr_fx[0], exp2 ) ) );
+ move16();
exp = add( 15, sub( exp1, exp2 ) );
hHQ_nbfec->diff_energy_fx = shl( hHQ_nbfec->diff_energy_fx, sub( 11, exp ) ); /*11*/
+ move16();
/* Classify the stationary mode : 12% */
IF( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_12P_fx ) )
@@ -568,7 +592,7 @@ void ivas_HQ_FEC_Mem_update_fx(
}
/* Apply Hysteresis to prevent frequent mode changing */
- IF( EQ_16( hHQ_nbfec->stat_mode_old, stat_mode_curr ) )
+ if ( EQ_16( hHQ_nbfec->stat_mode_old, stat_mode_curr ) )
{
hHQ_nbfec->stat_mode_out = stat_mode_curr;
move16();
@@ -595,7 +619,7 @@ void ivas_HQ_FEC_Mem_update_fx(
/* Find max. coeff in band 0 */
Max_ind = 0;
move16();
- IF( EQ_16( Min_ind, 0 ) )
+ IF( Min_ind == 0 )
{
Max_coeff_fx = L_deposit_l( 0 );
FOR( i = 0; i < 8; i++ )
@@ -617,6 +641,7 @@ void ivas_HQ_FEC_Mem_update_fx(
FOR( i = k; i < num_Sb; i++ )
{
en_high_fx[i] = L_deposit_l( 0 );
+ move32();
FOR( j = 0; j < 2; j++ )
{
/*en_high[i] += 0.5f*st->ynrm_values[i][j+1];*/
@@ -639,8 +664,10 @@ void ivas_HQ_FEC_Mem_update_fx(
#else
*mean_en_high_fx = add( *mean_en_high_fx, shr( tmp_fx, sub( exp, 5 ) ) );
#endif
+ move16();
}
- *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[num_Sb - k] );
+ *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] );
+ move16();
test();
test();
@@ -656,7 +683,7 @@ void ivas_HQ_FEC_Mem_update_fx(
hHQ_nbfec->phase_mat_flag = 1;
move16();
test();
- IF( ( EQ_16( Min_ind, 0 ) ) && ( LT_16( Max_ind, 3 ) ) )
+ if ( ( Min_ind == 0 ) && ( LT_16( Max_ind, 3 ) ) )
{
hHQ_nbfec->phase_mat_flag = 0;
move16();
@@ -722,7 +749,9 @@ void HQ_FEC_Mem_update_fx(
hHQ_core = st_fx->hHQ_core;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
+ move32(); // tmp_energy_fx
#ifdef ADD_IVAS_HQ_CODE_FEC
IF( EQ_16( output_frame, L_FRAME8k ) )
{
@@ -747,7 +776,7 @@ void HQ_FEC_Mem_update_fx(
test();
test();
test();
- IF( ( hHQ_nbfec->old_coeffs_fx[i + j * HQ_FEC_BAND_SIZE] > 0 && t_audio_q_fx[i + j * HQ_FEC_BAND_SIZE] < 0 ) || ( hHQ_nbfec->old_coeffs_fx[i + j * HQ_FEC_BAND_SIZE] < 0 && t_audio_q_fx[i + j * HQ_FEC_BAND_SIZE] > 0 ) )
+ IF( ( hHQ_nbfec->old_coeffs_fx[add( i, imult1616( j, HQ_FEC_BAND_SIZE ) )] > 0 && t_audio_q_fx[add( i, imult1616( j, HQ_FEC_BAND_SIZE ) )] < 0 ) || ( hHQ_nbfec->old_coeffs_fx[add( i, imult1616( j, HQ_FEC_BAND_SIZE ) )] < 0 && t_audio_q_fx[add( i, imult1616( j, HQ_FEC_BAND_SIZE ) )] > 0 ) )
{
hHQ_nbfec->prev_sign_switch[j] = add( hHQ_nbfec->prev_sign_switch[j], 1 );
move16();
@@ -758,7 +787,7 @@ void HQ_FEC_Mem_update_fx(
}
}
#ifndef ADD_IVAS_HQ_CODE_FEC
- IF( EQ_16( output_frame, L_FRAME8k ) )
+ if ( EQ_16( output_frame, L_FRAME8k ) )
{
#endif
/* if LR MDCT core is used, recalculate norms from decoded MDCT spectrum (using code from hq_hr_enc_fx()) */
@@ -766,7 +795,7 @@ void HQ_FEC_Mem_update_fx(
IF( ( EQ_16( hqswb_clas, HQ_HVQ ) ) || ( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) )
{
/* First group */
- logqnorm_fx( t_audio_q_fx, 12, ynrm, 32, WID_G1, ( hqswb_clas == HQ_HVQ ) );
+ logqnorm_fx( t_audio_q_fx, 12, ynrm, 32, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
j = ynrm[0];
move16();
offset = WID_G1;
@@ -774,17 +803,15 @@ void HQ_FEC_Mem_update_fx(
FOR( i = 1; i < SFM_G1; i++ )
{
- logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G1, ( hqswb_clas == HQ_HVQ ) );
- offset += WID_G1;
- move16();
+ logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
+ offset = add( offset, WID_G1 );
}
/* Second group */
FOR( i = SFM_G1; i < SFM_G1 + 2; i++ )
{
- logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G2, ( hqswb_clas == HQ_HVQ ) );
- offset += WID_G2;
- move16();
+ logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G2, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
+ offset = add( offset, WID_G2 );
}
}
@@ -804,7 +831,8 @@ void HQ_FEC_Mem_update_fx(
L_tmp = L_deposit_l( 0 );
FOR( j = 0; j < Num_bands_p[i]; j++ )
{
- L_tmp = L_add( L_tmp, L_shr( normq_fx[k++], 3 ) ); /*11*/
+ L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/
+ k = add( k, 1 );
}
#ifdef BASOP_NOGLOB
tmp_fx = shl_o( inv_tbl_fx[Num_bands_p[i]], 1, &Overflow ); /*16*/
@@ -817,7 +845,7 @@ void HQ_FEC_Mem_update_fx(
}
test();
test();
- IF( ( c_switching_flag ) || ( ( EQ_16( st_fx->last_core, ACELP_CORE ) ) && ( EQ_16( st_fx->core, HQ_CORE ) ) ) )
+ IF( ( c_switching_flag ) || ( ( st_fx->last_core == ACELP_CORE ) && ( EQ_16( st_fx->core, HQ_CORE ) ) ) )
{
FOR( i = 0; i < MAX_SB_NB; i++ )
{
@@ -836,19 +864,24 @@ void HQ_FEC_Mem_update_fx(
#ifdef BASOP_NOGLOB
hHQ_nbfec->energy_MA_Curr_fx[1] = extract_h( L_shl_sat( L_tmp, 16 - 8 ) );
+ move16();
#else
hHQ_nbfec->energy_MA_Curr_fx[1] = extract_h( L_shl( L_tmp, 16 - 8 ) );
#endif
/* Moving Average */
hHQ_nbfec->energy_MA_Curr_fx[0] = s_max( 1, add( mult_r( 26214, hHQ_nbfec->energy_MA_Curr_fx[0] ), mult_r( 6554, hHQ_nbfec->energy_MA_Curr_fx[1] ) ) );
+ move16();
/*st->diff_energy = (float)fabs((st->energy_MA_Curr[1] - st->energy_MA_Curr[0])/st->energy_MA_Curr[0]); */
hHQ_nbfec->diff_energy_fx = abs_s( sub( hHQ_nbfec->energy_MA_Curr_fx[1], hHQ_nbfec->energy_MA_Curr_fx[0] ) );
+ move16();
exp1 = sub( norm_l( hHQ_nbfec->diff_energy_fx ), 1 );
exp2 = norm_l( hHQ_nbfec->energy_MA_Curr_fx[0] );
hHQ_nbfec->diff_energy_fx = div_s( extract_h( L_shl( hHQ_nbfec->diff_energy_fx, exp1 ) ), extract_h( L_shl( hHQ_nbfec->energy_MA_Curr_fx[0], exp2 ) ) );
+ move16();
exp = add( 15, sub( exp1, exp2 ) );
hHQ_nbfec->diff_energy_fx = shl( hHQ_nbfec->diff_energy_fx, sub( 11, exp ) ); /*11*/
+ move16();
/* Classify the stationary mode : 12% */
IF( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_12P_fx ) )
@@ -863,7 +896,7 @@ void HQ_FEC_Mem_update_fx(
}
/* Apply Hysteresis to prevent frequent mode changing */
- IF( EQ_16( hHQ_nbfec->stat_mode_old, stat_mode_curr ) )
+ if ( EQ_16( hHQ_nbfec->stat_mode_old, stat_mode_curr ) )
{
hHQ_nbfec->stat_mode_out = stat_mode_curr;
move16();
@@ -912,6 +945,7 @@ void HQ_FEC_Mem_update_fx(
FOR( i = k; i < num_Sb; i++ )
{
en_high_fx[i] = L_deposit_l( 0 );
+ move16();
FOR( j = 0; j < 2; j++ )
{
/*en_high[i] += 0.5f*st->ynrm_values[i][j+1];*/
@@ -934,8 +968,10 @@ void HQ_FEC_Mem_update_fx(
#else
*mean_en_high_fx = add( *mean_en_high_fx, shr( tmp_fx, sub( exp, 5 ) ) );
#endif
+ move16();
}
- *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[num_Sb - k] );
+ *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] );
+ move16();
test();
test();
@@ -946,12 +982,12 @@ void HQ_FEC_Mem_update_fx(
test();
test();
test();
- IF( ( LT_16( Min_ind, 5 ) ) && ( LT_16( abs_s( sub( Min_ind, hHQ_nbfec->old_Min_ind ) ), 2 ) ) && ( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_90P_fx ) ) && ( !st_fx->bfi ) && ( !st_fx->prev_bfi ) && ( !st_fx->prev_old_bfi ) && ( !is_transient ) && ( !hHQ_core->old_is_transient[1] ) && ( hHQ_nbfec->prev_last_core == HQ_CORE ) && ( st_fx->last_core == HQ_CORE ) )
+ IF( ( LT_16( Min_ind, 5 ) ) && ( LT_16( abs_s( sub( Min_ind, hHQ_nbfec->old_Min_ind ) ), 2 ) ) && ( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_90P_fx ) ) && ( !st_fx->bfi ) && ( !st_fx->prev_bfi ) && ( !st_fx->prev_old_bfi ) && ( !is_transient ) && ( !hHQ_core->old_is_transient[1] ) && EQ_16( hHQ_nbfec->prev_last_core, HQ_CORE ) && EQ_16( st_fx->last_core, HQ_CORE ) )
{
hHQ_nbfec->phase_mat_flag = 1;
move16();
test();
- if ( ( Min_ind == 0 ) && ( LT_16( Max_ind, 3 ) ) )
+ if ( Min_ind == 0 && ( LT_16( Max_ind, 3 ) ) )
{
hHQ_nbfec->phase_mat_flag = 0;
move16();
@@ -1005,20 +1041,22 @@ void HQ_FEC_Mem_update_fx(
Word32 Rxy_fx[MAXDELAY_FEC], Ryy_fx[MAXDELAY_FEC];
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
+ move16(); // d1m
d1 = mind1;
move16();
- FOR( k = 0; k < ( maxd1 - mind1 ) / delta; k++ )
+ FOR( k = 0; k < idiv1616( sub( maxd1, mind1 ), delta ); k++ )
{
accA_fx = L_deposit_l( 0 );
accB_fx = L_deposit_l( 0 );
FOR( i = 0; i < lin; i += delta )
{
#ifdef BASOP_NOGLOB
- accA_fx = L_add_sat( accA_fx, L_shr( L_mult_sat( mu_o_fx[d1 + i], mu_o_fx[d1 + i] ), 2 ) );
- accB_fx = L_add_sat( accB_fx, L_shr( L_mult_sat( mu_o_fx[d1 + i], in_fx[i] ), 2 ) );
+ accA_fx = L_add_sat( accA_fx, L_shr( L_mult_sat( mu_o_fx[add( d1, i )], mu_o_fx[add( d1, i )] ), 2 ) );
+ accB_fx = L_add_sat( accB_fx, L_shr( L_mult_sat( mu_o_fx[add( d1, i )], in_fx[i] ), 2 ) );
#else
accA_fx = L_add( accA_fx, L_shr( L_mult( mu_o_fx[d1 + i], mu_o_fx[d1 + i] ), 2 ) );
accB_fx = L_add( accB_fx, L_shr( L_mult( mu_o_fx[d1 + i], in_fx[i] ), 2 ) );
@@ -1041,7 +1079,7 @@ void HQ_FEC_Mem_update_fx(
move16();
FOR( d1 = 0; d1 < ( maxd1 - mind1 ) / delta; d1++ )
{
- IF( L_abs( Rxy_fx[d1] ) > L_abs( Ryy_fx[d1] ) )
+ IF( GT_32( L_abs( Rxy_fx[d1] ), L_abs( Ryy_fx[d1] ) ) )
exp1 = norm_l( Rxy_fx[d1] );
ELSE
exp1 = norm_l( Ryy_fx[d1] );
@@ -1120,7 +1158,7 @@ void HQ_FEC_Mem_update_fx(
maxd1 = mult_r( L, 19661 ); /* max value of delay d1 to search for */
/*in = mu_o + 2*L -lin; */
- in_fx = mu_o_fx + 2 * L - lin;
+ in_fx = mu_o_fx + sub( shl( L, 1 ), lin );
move16();
/* generate correlation */
@@ -1158,7 +1196,7 @@ void HQ_FEC_Mem_update_fx(
lin = mult_r( L, 9830 );
mind1 = mult_r( L, 14746 ); /* min value of delay d1 to search for */
maxd1 = mult_r( L, 22938 ); /* max value of delay d1 to search for */
- in_fx = mu_o_fx + 2 * L - lin;
+ in_fx = mu_o_fx + sub( shl( L, 1 ), lin );
move16();
/* generate correlation */
@@ -1216,23 +1254,23 @@ void HQ_FEC_Mem_update_fx(
L = L_FRAME8k;
move16();
- ol_size = 2 * L / 20;
+ ol_size = idiv1616( shl( L, 1 ), 20 );
move16();
- L_overlap = 3 * L / 20;
+ L_overlap = idiv1616( imult1616( 3, L ), 20 );
move16();
FOR( i = 0; i < L_overlap; i++ )
{
- SmoothingWin_NB3_fx[i] = SmoothingWin_NB875_fx[i * 3];
+ SmoothingWin_NB3_fx[i] = SmoothingWin_NB875_fx[imult1616( i, 3 )];
move16();
}
- FOR( i = 0; i < L + 25; i++ )
+ FOR( i = 0; i < add( L, 25 ); i++ )
{
- win_NB_fx[i] = window_48kHz_fx[i * 6 + 3];
+ win_NB_fx[i] = window_48kHz_fx[add( imult1616( i, 6 ), 3 )];
move16();
}
- set16_fx( ImdctOutWin_fx, 0, 2 * L );
+ set16_fx( ImdctOutWin_fx, 0, shl( L, 1 ) );
pos = Search_Max_Corr_fx( st_fx->old_auOut_2fr_fx, st_fx->old_Min_ind, L );
@@ -1242,27 +1280,28 @@ void HQ_FEC_Mem_update_fx(
}
/* Repetition */
- remain = L + N_Z_L_NB - ( ( 2 * L ) - pos );
- move16();
- Copy( &st_fx->old_auOut_2fr_fx[pos], &ImdctOutWin_fx[N_ZERO_NB], ( 2 * L ) - pos );
+ remain = sub( add( L, N_Z_L_NB ), sub( shl( L, 1 ), pos ) );
+ Copy( &st_fx->old_auOut_2fr_fx[pos], &ImdctOutWin_fx[N_ZERO_NB], sub( shl( L, 1 ), pos ) );
/* OldauOut without windowing */
- FOR( i = N_ZERO_NB; i < L / 2; i++ )
+ FOR( i = N_ZERO_NB; i < shr( L, 1 ); i++ )
{
- OldauOutnoWin_fx[i - N_ZERO_NB] = extract_l( L_shr( L_negate( st_fx->oldIMDCTout_fx[L / 2 - 1 - i] ), 6 ) );
+ OldauOutnoWin_fx[i - N_ZERO_NB] = extract_l( L_shr( L_negate( st_fx->oldIMDCTout_fx[sub( sub( shr( L, 1 ), 1 ), i )] ), 6 ) );
+ move16();
}
- FOR( i = 0; i < L / 2; i++ )
+ FOR( i = 0; i < shr( L, 1 ); i++ )
{
OldauOutnoWin_fx[i + N_ZERO_O_NB] = extract_l( L_shr( L_negate( st_fx->oldIMDCTout_fx[i] ), 6 ) );
+ move16();
}
- Copy( OldauOutnoWin_fx, &ImdctOutWin_fx[N_ZERO_NB + ( 2 * L ) - pos], remain );
+ Copy( OldauOutnoWin_fx, &ImdctOutWin_fx[add( N_ZERO_NB, sub( shl( L, 1 ), pos ) )], remain );
pow1_fx = L_deposit_l( 0 );
pow22_fx = L_deposit_l( 0 );
FOR( i = 0; i < L; i++ )
{
- pow1_fx = L_add( pow1_fx, shr( abs_s( st_fx->old_auOut_2fr_fx[L + i] ), 1 ) );
+ pow1_fx = L_add( pow1_fx, shr( abs_s( st_fx->old_auOut_2fr_fx[add( L, i )] ), 1 ) );
pow22_fx = L_add( pow22_fx, shr( abs_s( ImdctOutWin_fx[N_ZERO_NB + i] ), 1 ) );
}
IF( pow22_fx != 0 )
@@ -1271,40 +1310,43 @@ void HQ_FEC_Mem_update_fx(
exp2 = norm_l( pow22_fx );
tmp = div_s( extract_h( L_shl( pow1_fx, exp1 ) ), extract_h( L_shl( pow22_fx, exp2 ) ) ); /*15 + exp1 - exp2*/
tmp = shl( tmp, sub( sub( exp2, exp1 ), 1 ) ); /*14*/
- FOR( i = N_ZERO_NB; i < 2 * L; i++ )
+ FOR( i = N_ZERO_NB; i < shl( L, 1 ); i++ )
{
#ifdef BASOP_NOGLOB
ImdctOutWin_fx[i] = shl_sat( mult( ImdctOutWin_fx[i], tmp ), 1 );
#else
ImdctOutWin_fx[i] = shl( mult( ImdctOutWin_fx[i], tmp ), 1 );
#endif
+ move16();
}
}
Smoothing_vector_NB_fx( OldauOutnoWin_fx, &ImdctOutWin_fx[N_ZERO_NB], SmoothingWin_NB2_fx, auOut_fx, ol_size );
- FOR( i = 0; i < L / 2; i++ )
+ FOR( i = 0; i < shr( L, 1 ); i++ )
{
/*ImdctOutWin[3*L/2 + i] *= win_NB[L/2-i-1];*/
- ImdctOutWin_fx[3 * L / 2 + i] = mult( ImdctOutWin_fx[3 * L / 2 + i], win_NB_fx[L / 2 - i - 1] );
+ ImdctOutWin_fx[add( shr( imult1616( 3, L ), 1 ), i )] = mult( ImdctOutWin_fx[add( shr( imult1616( 3, L ), 1 ), i )], win_NB_fx[sub( sub( shr( L, 1 ), i ), 1 )] );
move16();
}
- FOR( i = N_ZERO_NB; i < L / 2; i++ )
+ FOR( i = N_ZERO_NB; i < shr( L, 1 ); i++ )
{
/*ImdctOutWin_fx[L + i] *= win_NB_fx[(L-1-i)];*/
- ImdctOutWin_fx[L + i] = mult( ImdctOutWin_fx[L + i], win_NB_fx[( L - 1 - i )] );
+ ImdctOutWin_fx[add( L, i )] = mult( ImdctOutWin_fx[add( L, i )], win_NB_fx[sub( sub( L, 1 ), i )] );
move16();
}
Copy( &ImdctOutWin_fx[N_Z_L_O_NB], &OldauOut_pha_fx[0][0], N_LEAD_NB );
- Copy( &ImdctOutWin_fx[ol_size + N_ZERO_NB], &auOut_fx[ol_size], N_Z_L_NB - ol_size );
+ Copy( &ImdctOutWin_fx[add( ol_size, N_ZERO_NB )], &auOut_fx[ol_size], sub( N_Z_L_NB, ol_size ) );
Copy( &ImdctOutWin_fx[L], &auOut_fx[N_Z_L_NB], N_ZERO_NB );
Copy( &ImdctOutWin_fx[L], OldauOut_fx, L );
- FOR( i = 0; i < L / 2; i++ )
+ FOR( i = 0; i < shr( L, 1 ); i++ )
{
- OldauOut2_fx[i] = extract_l( L_shr( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), 6 ) );
- OldauOut2_fx[L / 2 + i] = extract_l( L_shr( L_negate( ImdctOut_fx[i] ), 6 ) );
+ OldauOut2_fx[i] = extract_l( L_shr( L_negate( ImdctOut_fx[sub( sub( shr( L, 1 ), 1 ), i )] ), 6 ) );
+ move16();
+ OldauOut2_fx[add( shr( L, 1 ), i )] = extract_l( L_shr( L_negate( ImdctOut_fx[i] ), 6 ) );
+ move16();
}
Smoothing_vector_NB_fx( &ImdctOutWin_fx[N_Z_L_O_NB], &OldauOut2_fx[N_ZERO_NB], SmoothingWin_NB3_fx, &OldauOut_pha_fx[1][0], L_overlap );
@@ -1338,7 +1380,7 @@ void HQ_FEC_Mem_update_fx(
FOR( i = 0; i < L + 25; i++ )
{
/* win_NB[i] = window_48kHz[i*6+3]; */
- win_NB_fx[i] = window_48kHz_fx[i * 6 + 3];
+ win_NB_fx[i] = window_48kHz_fx[add( imult1616( i, 6 ), 3 )];
move16();
}
@@ -1361,7 +1403,7 @@ void HQ_FEC_Mem_update_fx(
FOR( i = 0; i < N_LEAD_NB; i++ )
{
/* OldOut_pha[i] *= SmoothingWin_NB875[L_overlap-i-1]; */
- OldOut_pha_fx[i] = mult( OldOut_pha_fx[i], SmoothingWin_NB875_fx[L_overlap - i - 1] );
+ OldOut_pha_fx[i] = mult( OldOut_pha_fx[i], SmoothingWin_NB875_fx[sub( sub( L_overlap, i ), 1 )] );
move16();
}
@@ -1408,7 +1450,7 @@ void HQ_FEC_Mem_update_fx(
L = L_FRAME8k;
move16();
- L_overlap = 3 * L / 20;
+ L_overlap = idiv1616( imult1616( 3, L ), 20 );
move16();
FOR( i = 0; i < L_overlap; i++ )
@@ -1417,9 +1459,9 @@ void HQ_FEC_Mem_update_fx(
move16();
}
- FOR( i = 0; i < L + 25; i++ )
+ FOR( i = 0; i < add( L, 25 ); i++ )
{
- win_NB_fx[i] = window_48kHz_fx[i * 6 + 3];
+ win_NB_fx[i] = window_48kHz_fx[add( imult1616( i, 6 ), 3 )];
move16();
}
@@ -1439,12 +1481,14 @@ void HQ_FEC_Mem_update_fx(
Copy( &ImdctOutWin_fx[L], OldauOut_fx, L );
Scaledown_fx( prev_oldauOut_fx, prev_oldauOut_fx, 23170, L );
- FOR( i = 0; i < L / 2; i++ )
+ FOR( i = 0; i < shr( L, 1 ); i++ )
{
/* OldauOut2[i] = -ImdctOut[L/2 - 1 - i];*/
/* OldauOut2[L/2+i] = -ImdctOut[i];*/
- OldauOut2_fx[i] = extract_l( L_shr( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), 6 ) );
- OldauOut2_fx[L / 2 + i] = extract_l( L_shr( L_negate( ImdctOut_fx[i] ), 6 ) );
+ OldauOut2_fx[i] = extract_l( L_shr( L_negate( ImdctOut_fx[sub( sub( shr( L, 1 ), 1 ), i )] ), 6 ) );
+ move16();
+ OldauOut2_fx[add( shr( L, 1 ), i )] = extract_l( L_shr( L_negate( ImdctOut_fx[i] ), 6 ) );
+ move16();
}
Smoothing_vector_NB_fx( &ImdctOutWin_fx[N_Z_L_O_NB], &OldauOut2_fx[N_ZERO_NB], SmoothingWin_NB3_fx, &OldauOut_pha_fx[1][0], L_overlap );
@@ -1480,19 +1524,21 @@ void HQ_FEC_Mem_update_fx(
FOR( i = 0; i < L_FRAME8k + 25; i++ )
{
/*win_NB[i] = window_48kHz[i*6+3];*/
- win_NB_fx[i] = window_48kHz_fx[i * 6 + 3];
+ win_NB_fx[i] = window_48kHz_fx[add( imult1616( i, 6 ), 3 )];
move16();
}
- FOR( i = N_ZERO_NB; i < L / 2; i++ )
+ FOR( i = N_ZERO_NB; i < shr( L, 1 ); i++ )
{
/*OldauOut[i-N_ZERO_NB] = -OldImdctOut[L/2 - 1 - i];*/
- OldauOut_fx[i - N_ZERO_NB] = extract_l( L_shr( L_negate( OldImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); /* Q6 -> Q0 */
+ OldauOut_fx[i - N_ZERO_NB] = extract_l( L_shr( L_negate( OldImdctOut_fx[sub( sub( shr( L, 1 ), 1 ), i )] ), 6 ) ); /* Q6 -> Q0 */
+ move16();
}
- FOR( i = 0; i < L / 2; i++ )
+ FOR( i = 0; i < shr( L, 2 ); i++ )
{
/*OldauOut[i+N_ZERO_O_NB] = -OldImdctOut[i];*/
OldauOut_fx[i + N_ZERO_O_NB] = extract_l( L_shr( L_negate( OldImdctOut_fx[i] ), 6 ) ); /* Q6 -> Q0 */
+ move16();
}
/* Overlapping with next good frame : Overlapping to remove the discontinuity */
@@ -1501,21 +1547,23 @@ void HQ_FEC_Mem_update_fx(
ol_size = N_LEAD_NB;
move16();
- FOR( i = N_ZERO_NB; i < L / 2; i++ )
+ FOR( i = N_ZERO_NB; i < shr( L, 1 ); i++ )
{
/* ImdctOutWin[i+L] = -ImdctOut[L/2 - 1 - i]; */
- ImdctOutWin_fx[i + L] = extract_l( L_shr( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), 6 ) );
+ ImdctOutWin_fx[add( i, L )] = extract_l( L_shr( L_negate( ImdctOut_fx[sub( sub( shr( L, 1 ), 1 ), i )] ), 6 ) );
+ move16();
}
- FOR( i = 0; i < L / 2; i++ )
+ FOR( i = 0; i < shr( L, 1 ); i++ )
{
- ImdctOutWin_fx[i + 3 * L / 2] = extract_l( L_shr( L_negate( ImdctOut_fx[i] ), 6 ) );
+ ImdctOutWin_fx[add( i, shr( imult1616( 3, L ), 1 ) )] = extract_l( L_shr( L_negate( ImdctOut_fx[i] ), 6 ) );
+ move16();
}
/*a = (float)(1./(float)(ol_size)); y = ax */
Smoothing_vector_scaledown_NB_fx( OldauOut_fx, &ImdctOutWin_fx[N_Z_L_O_NB], SmoothingWin_NB875_fx, OldauOut_fx, ol_size );
/* Scale down the overlapped signal */
- Scaledown_fx( &ImdctOutWin_fx[ol_size + N_Z_L_O_NB], &OldauOut_fx[ol_size], 23170, N_Z_L_NB - ol_size );
+ Scaledown_fx( &ImdctOutWin_fx[add( ol_size, N_Z_L_O_NB )], &OldauOut_fx[ol_size], 23170, sub( N_Z_L_NB, ol_size ) );
}
L_overlap = overlap_time;
@@ -1523,7 +1571,7 @@ void HQ_FEC_Mem_update_fx(
FOR( i = 0; i < L_overlap; i++ )
{
/*OldauOut[i] *= SmoothingWin_NB875[L_overlap-i-1];*/
- OldauOut_fx[i] = mult( OldauOut_fx[i], SmoothingWin_NB875_fx[L_overlap - i - 1] );
+ OldauOut_fx[i] = mult( OldauOut_fx[i], SmoothingWin_NB875_fx[sub( sub( L_overlap, i ), 1 )] );
move16();
}
FOR( i = L_overlap; i < L; i++ )
@@ -1574,7 +1622,7 @@ void HQ_FEC_Mem_update_fx(
FOR( i = 0; i < L_FRAME8k + 25; i++ )
{
/*win_NB[i] = window_48kHz[i*6+3];*/
- win_NB_fx[i] = window_48kHz_fx[i * 6 + 3];
+ win_NB_fx[i] = window_48kHz_fx[add( imult1616( i, 6 ), 3 )];
move16();
}
@@ -1586,13 +1634,15 @@ void HQ_FEC_Mem_update_fx(
common_overlapping_fx( auOut_fx, ImdctOutWin_fx, prev_oldauOut_fx, N_Z_L_NB, 0, N_Z_L_NB, L, N_ZERO_NB, 0 );
/* OldauOut without windowing */
- FOR( i = N_ZERO_NB; i < L / 2; i++ )
+ FOR( i = N_ZERO_NB; i < shr( L, 1 ); i++ )
{
- OldauOutnoWin_fx[i - N_ZERO_NB] = extract_l( L_shr( L_negate( OldImdctOut_fx[L / 2 - 1 - i] ), 6 ) );
+ OldauOutnoWin_fx[i - N_ZERO_NB] = extract_l( L_shr( L_negate( OldImdctOut_fx[sub( sub( shr( L, 1 ), 1 ), i )] ), 6 ) );
+ move16();
}
- FOR( i = 0; i < L / 2; i++ )
+ FOR( i = 0; i < shr( L, 1 ); i++ )
{
OldauOutnoWin_fx[i + N_ZERO_O_NB] = extract_l( L_shr( L_negate( OldImdctOut_fx[i] ), 6 ) );
+ move16();
}
/* data transition from OldauOut to auOut using smoothing win*/
@@ -1600,14 +1650,14 @@ void HQ_FEC_Mem_update_fx(
pow1_fx = L_deposit_l( 0 );
pow22_fx = L_deposit_l( 0 );
- FOR( i = 0; i < 4 * L / 20; i++ )
+ FOR( i = 0; i < idiv1616( imult1616( 4, L ), 20 ); i++ )
{
- pow1_fx = L_add( pow1_fx, Mult_32_32( L_shl( (Word32) auOut_fx[1 * L / 20 + i], 6 ), L_shl( (Word32) auOut_fx[1 * L / 20 + i], 6 ) ) );
+ pow1_fx = L_add( pow1_fx, Mult_32_32( L_shl( (Word32) auOut_fx[add( idiv1616( L, 20 ), i )], 6 ), L_shl( (Word32) auOut_fx[add( idiv1616( L, 20 ), i )], 6 ) ) );
pow22_fx = L_add( pow22_fx, Mult_32_32( L_shl( (Word32) auOut_fx[N_LEAD_NB + i], 6 ), L_shl( (Word32) auOut_fx[N_LEAD_NB + i], 6 ) ) );
}
- IF( pow22_fx > L_add( pow1_fx, L_shl( pow1_fx, 1 ) ) )
+ IF( GT_32( pow22_fx, L_add( pow1_fx, L_shl( pow1_fx, 1 ) ) ) )
{
return 1;
}
@@ -1637,7 +1687,7 @@ void HQ_FEC_Mem_update_fx(
{
/*auOut_fx[i] = L_add(ImdctOutWin_fx[i+7*L/20], OldauOut_fx[i+offset1]);*/
#ifdef BASOP_NOGLOB
- auOut_fx[i] = add_sat( ImdctOutWin_fx[i + N_ZERO_NB], OldauOut_fx[i + offset1] );
+ auOut_fx[i] = add_sat( ImdctOutWin_fx[i + N_ZERO_NB], OldauOut_fx[add( i, offset1 )] );
#else
auOut_fx[i] = add( ImdctOutWin_fx[i + N_ZERO_NB], OldauOut_fx[i + offset1] );
#endif
@@ -1646,7 +1696,7 @@ void HQ_FEC_Mem_update_fx(
FOR( i = start2; i < end2; i++ )
{
/*auOut_fx[i+offset2] = ImdctOutWin_fx[i+offset_i2]; move32();*/
- auOut_fx[i + offset2] = ImdctOutWin_fx[i + offset_i2];
+ auOut_fx[add( i, offset2 )] = ImdctOutWin_fx[add( i, offset_i2 )];
move16();
}
@@ -1692,34 +1742,40 @@ void HQ_FEC_Mem_update_fx(
move16();
IF( smoothing_flag == 0 )
{
- FOR( i = N_ZERO_NB; i < L / 2; i++ )
+ FOR( i = N_ZERO_NB; i < shr( L, 1 ); i++ )
{
/*ImdctOutWin[i] = ImdctOut[L/2 + i] * win[(2*L-1-i)-N_LEAD_O_NB];*/
- ImdctOutWin_fx[i] = extract_l( L_shr( Mult_32_16( ImdctOut_fx[L / 2 + i], win_fx[( 2 * L - 1 - i ) - N_LEAD_O_NB] ), 6 ) );
+ ImdctOutWin_fx[i] = extract_l( L_shr( Mult_32_16( ImdctOut_fx[add( shr( L, 1 ), i )], win_fx[sub( sub( sub( shl( L, 1 ), 1 ), i ), N_LEAD_O_NB )] ), 6 ) );
+ move16();
}
FOR( i = 0; i < N_ZERO_O_NB; i++ )
{
/*ImdctOutWin[L/2 + i] = -ImdctOut[L - 1 - i] * win[(3*L/2-1-i)-N_LEAD_O_NB];*/
/*ImdctOutWin[3*L/2 + i] = -ImdctOut[i] * win[(L/2-i-1)];*/
- ImdctOutWin_fx[L / 2 + i] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[L - 1 - i] ), win_fx[( 3 * L / 2 - 1 - i ) - N_LEAD_O_NB] ), 6 ) );
- ImdctOutWin_fx[3 * L / 2 + i] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[i] ), win_fx[( L / 2 - i - 1 )] ), 6 ) );
+ ImdctOutWin_fx[add( shr( L, 1 ), i )] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[sub( sub( L, 1 ), i )] ), win_fx[sub( ( sub( sub( shr( imult1616( 3, L ), 1 ), 1 ), i ) ), N_LEAD_O_NB )] ), 6 ) );
+ move16();
+ ImdctOutWin_fx[add( idiv1616( imult1616( 3, L ), 2 ), i )] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[i] ), win_fx[sub( sub( shr( L, 1 ), i ), 1 )] ), 6 ) );
+ move16();
}
}
ELSE
{
- FOR( i = N_ZERO_NB; i < L / 2; i++ )
+ FOR( i = N_ZERO_NB; i < shr( L, 1 ); i++ )
{
- /*ImdctOutWin[i] = ImdctOut[L/2 + i] * smoothingWin[(i-N_ZERO_NB)];*/ /*win[(2*L-i)*decimate-1-decay-14*L_FRAME48k/20];*/
- ImdctOutWin_fx[i] = extract_l( L_shr( Mult_32_16( ImdctOut_fx[L / 2 + i], smoothingWin_fx[( i - N_ZERO_NB )] ), 6 ) ); /*win[(2*L-i)*decimate-1-decay-14*L_FRAME48k/20];*/
+ /*ImdctOutWin[i] = ImdctOut[L/2 + i] * smoothingWin[(i-N_ZERO_NB)];*/ /*win[(2*L-i)*decimate-1-decay-14*L_FRAME48k/20];*/
+ ImdctOutWin_fx[i] = extract_l( L_shr( Mult_32_16( ImdctOut_fx[add( shr( L, 1 ), i )], smoothingWin_fx[sub( i, N_ZERO_NB )] ), 6 ) ); /*win[(2*L-i)*decimate-1-decay-14*L_FRAME48k/20];*/
+ move16();
}
FOR( i = 0; i < N_ZERO_O_NB; i++ )
{
/*ImdctOutWin[L/2 + i] = -ImdctOut[L - 1 - i] * smoothingWin[(i+N_ZERO_O_NB)];*/ /*win[(3*L/2-1-i)*decimate+decay-L_FRAME48k*14/20];*/
/*ImdctOutWin[3*L/2 + i] = -ImdctOut[i] * win[(L/2-i-1)];*/
- ImdctOutWin_fx[L / 2 + i] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[L - 1 - i] ), smoothingWin_fx[( i + N_ZERO_O_NB )] ), 6 ) ); /*win[(3*L/2-1-i)*decimate+decay-L_FRAME48k*14/20];*/
- ImdctOutWin_fx[3 * L / 2 + i] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[i] ), win_fx[( L / 2 - i - 1 )] ), 6 ) );
+ ImdctOutWin_fx[add( shr( L, 1 ), i )] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[sub( sub( L, 1 ), i )] ), smoothingWin_fx[add( i, N_ZERO_O_NB )] ), 6 ) ); /*win[(3*L/2-1-i)*decimate+decay-L_FRAME48k*14/20];*/
+ move16();
+ ImdctOutWin_fx[add( shr( imult1616( 3, L ), 1 ), i )] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[i] ), win_fx[sub( sub( shr( L, 1 ), i ), 1 )] ), 6 ) );
+ move16();
}
}
@@ -1736,24 +1792,28 @@ void HQ_FEC_Mem_update_fx(
L = L_FRAME8k;
move16();
- FOR( i = N_ZERO_O_NB; i < L / 2; i++ )
+ FOR( i = N_ZERO_O_NB; i < shr( L, 1 ); i++ )
{
/*ImdctOutWin[L/2 + i] = -ImdctOut[L - 1 - i];*/
/*ImdctOutWin[3*L/2 + i] = -ImdctOut[i] * win[L/2-i-1];*/
- ImdctOutWin_fx[L / 2 + i] = extract_l( L_shr( L_negate( ImdctOut_fx[L - 1 - i] ), 6 ) );
- ImdctOutWin_fx[3 * L / 2 + i] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[i] ), win_fx[L / 2 - i - 1] ), 6 ) );
+ ImdctOutWin_fx[add( shr( L, 1 ), i )] = extract_l( L_shr( L_negate( ImdctOut_fx[sub( sub( L, 1 ), i )] ), 6 ) );
+ move16();
+ ImdctOutWin_fx[add( shr( imult1616( 3, L ), 1 ), i )] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[i] ), win_fx[sub( sub( shr( L, 1 ), i ), 1 )] ), 6 ) );
+ move16();
}
FOR( i = 0; i < N_ZERO_NB; i++ )
{
/*ImdctOutWin[L + i] = -ImdctOut[L/2 - 1 - i];*/
- ImdctOutWin_fx[L + i] = extract_l( L_shr( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), 6 ) );
+ ImdctOutWin_fx[add( L, i )] = extract_l( L_shr( L_negate( ImdctOut_fx[sub( sub( shr( L, 1 ), 1 ), i )] ), 6 ) );
+ move16();
}
- FOR( i = N_ZERO_NB; i < L / 2; i++ )
+ FOR( i = N_ZERO_NB; i < shr( L, 1 ); i++ )
{
/*ImdctOutWin[L + i] = -ImdctOut[L/2 - 1 - i] * win[L - 1 - i];*/
- ImdctOutWin_fx[L + i] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), win_fx[L - 1 - i] ), 6 ) );
+ ImdctOutWin_fx[add( L, i )] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[sub( sub( shr( L, 1 ), 1 ), i )] ), win_fx[sub( sub( L, 1 ), i )] ), 6 ) );
+ move16();
}
return;
@@ -1828,7 +1888,7 @@ void HQ_FEC_Mem_update_fx(
test();
test();
test();
- IF( ( EQ_16( st_fx->nbLostCmpt, 1 ) ) && ( EQ_16( hHQ_nbfec->phase_mat_flag, 1 ) ) && ( EQ_16( hHQ_nbfec->phase_mat_next, 0 ) ) )
+ IF( ( EQ_16( st_fx->nbLostCmpt, 1 ) ) && ( EQ_16( hHQ_nbfec->phase_mat_flag, 1 ) ) && ( hHQ_nbfec->phase_mat_next == 0 ) )
{
IF( FEC_phase_matching_fx( hHQ_nbfec, wtda_audio_fx, out_fx, hHQ_core->old_out_fx, hHQ_nbfec->old_out_pha_fx ) )
{
@@ -1874,9 +1934,11 @@ void HQ_FEC_Mem_update_fx(
Word16 tmp;
tmp = 0;
+ move16();
if ( GT_16( st_fx->old_bfi_cnt, 1 ) )
{
tmp = 1;
+ move16();
}
Repetition_smoothing_nextgood_fx( wtda_audio_fx, out_fx, hHQ_nbfec->oldIMDCTout_fx, hHQ_core->old_out_fx, tmp, N_LEAD_NB );
*Q_synth = 0;
@@ -1939,9 +2001,9 @@ void HQ_FEC_Mem_update_fx(
L = L_FRAME8k;
move16();
- FOR( i = 0; i < L + 25; i++ )
+ FOR( i = 0; i < add( L, 25 ); i++ )
{
- win_NB_fx[i] = window_48kHz_fx[i * 6 + 3];
+ win_NB_fx[i] = window_48kHz_fx[add( imult1616( i, 6 ), 3 )];
move16();
}
@@ -1953,7 +2015,7 @@ void HQ_FEC_Mem_update_fx(
Smoothing_vector_scaledown_NB_fx( &OldauOut_fx[N_ZERO_NB], &ImdctOutWin_fx[N_Z_L_O_NB], SmoothingWin_NB875_fx, &OldauOut_fx[N_ZERO_NB], ol_size );
/* Scale down the overlapped signal */
- Scaledown_fx( &ImdctOutWin_fx[ol_size + N_Z_L_O_NB], &OldauOut_fx[ol_size + N_ZERO_NB], 23170, N_Z_L_NB - ol_size );
+ Scaledown_fx( &ImdctOutWin_fx[add( ol_size, N_Z_L_O_NB )], &OldauOut_fx[add( ol_size, N_ZERO_NB )], 23170, sub( N_Z_L_NB, ol_size ) );
/* Common Overlapping */
common_overlapping_fx( auOut_fx, ImdctOutWin_fx, OldauOut_fx, N_Z_L_NB, N_ZERO_NB, 0, N_ZERO_NB, L, N_Z_L_NB );
diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c
index e43cf7f25c08a08096f04a7f1f6b73e8100c18e1..972e7f4f8a0bad887d749ebe2f44bed7eb4b27d5 100644
--- a/lib_dec/FEC_HQ_phase_ecu_fx.c
+++ b/lib_dec/FEC_HQ_phase_ecu_fx.c
@@ -6,8 +6,7 @@
#include "options.h" /* Compilation switches */
#include "rom_dec.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
@@ -193,7 +192,7 @@ static Word16 ivas_imax2_jacobsen_mag_fx(
denom = L_add( L_mult0( D_re, D_re ), L_mult0( D_im, D_im ) );
test();
- IF( NE_32( numer, 0 ) && NE_32( denom, 0 ) )
+ IF( numer != 0 && denom != 0 )
{
tmp = BASOP_Util_Divide3232_Scale( numer, denom, &tmp_e );
tmp = shl_sat( tmp, tmp_e ); // Q15
@@ -202,6 +201,7 @@ static Word16 ivas_imax2_jacobsen_mag_fx(
ELSE
{
posi = 0; /* flat top, division is not possible choose center freq */
+ move16();
}
return posi;
@@ -296,6 +296,7 @@ static void fft_spec2_fx(
pMagSq = &xMagSq[0];
pRe = &x[0];
*pMagSq++ = L_mult0( *pRe, *pRe );
+ move32();
pRe++; /* Non-fractional multiply gives subsequent group power accumulation a bit headroom. */
/* From 1 to (N/2 - 1). */
@@ -357,7 +358,16 @@ static void trans_ana_fx(
Word32 acc;
Lgw = 0;
+ move16();
LtranaLogMinus1 = 0;
+ move16();
+
+ move16(); // att_always
+ move16(); // burst_phdith_thresh
+ move16(); // burst_att_thresh
+ move16(); // att_per_frame
+ move16(); // burst_phdith_rampup_len
+
pFftTbl = NULL;
/* Initialisation to prevent warnings */
@@ -385,13 +395,11 @@ static void trans_ana_fx(
oneOverFrame = 51; /* 1/640 in Q15 */
move16();
w_hamm = w_hamm32k_2_fx;
- move16();
Lgw = LGW32K;
move16();
Lprot = 1024;
move16();
pFftTbl = FFT_W128; /* Table for 256 real input radix-2 FFT */
- move16();
LtranaLogMinus1 = LTRANALOG32K - 1;
move16();
}
@@ -400,13 +408,11 @@ static void trans_ana_fx(
oneOverFrame = 102; /* 1/320 in Q15 */
move16();
w_hamm = w_hamm16k_2_fx;
- move16();
Lgw = LGW16K;
move16();
Lprot = 512;
move16();
pFftTbl = FFT_W64; /* Table for 128 real input radix-2 FFT */
- move16();
LtranaLogMinus1 = LTRANALOG16K - 1;
move16();
}
@@ -516,7 +522,9 @@ static void trans_ana_fx(
/* band powers in frequency groups
* exclude bin at PI from calculation */
magSqLeft[Ltrana_2] = L_deposit_l( 0 );
+ move32();
magSqRight[Ltrana_2] = L_deposit_l( 0 );
+ move32();
}
pGrPowLeft = &gr_pow_left[0];
@@ -536,7 +544,9 @@ static void trans_ana_fx(
pLeft = magSqLeft + lowerEdge;
pRight = magSqRight + lowerEdge;
*pGrPowLeft = L_deposit_l( 0 );
+ move32();
*pGrPowRight = L_deposit_l( 0 );
+ move32();
FOR( i = 0; i < l; i++ )
{
acc = L_shr( *pLeft++, headroom ); /* Scale down to prevent from saturation. */
@@ -561,6 +571,7 @@ static void trans_ana_fx(
expo = shr( expo, 1 );
Xavg[k] = round_fx( L_shl( acc, sub( sub( 16, expo ), 2 ) ) ); /* Q0, additional right shift by 2 to account for that Xavg is
calculated using lenght N/4 fft but is applied on a fft of length N */
+ move16();
/*dither phase in case of transient */
/* separate transition detection and application of forced burst dithering */
@@ -598,7 +609,7 @@ static void trans_ana_fx(
#endif
att_val = 32767;
move16();
- IF( GT_32( *pGrPowRight, 0 ) )
+ IF( *pGrPowRight > 0 )
{
IF( LT_32( *pGrPowRight, *pGrPowLeft ) ) /* i.e., (gr_pow_right/gr_pow_left) < 1.0 */
{
@@ -652,10 +663,12 @@ static void trans_ana_fx(
move16();
}
mag_chg[k] = mult_r( mag_chg_1st[k], att_val ); /* Q15 */
+ move16();
- if ( GT_16( burst_len, BETA_MUTE_THR ) )
+ IF( GT_16( burst_len, BETA_MUTE_THR ) )
{
*beta_mute = shr( *beta_mute, 1 );
+ move16();
}
alpha[k] = mag_chg[k];
move16();
@@ -674,10 +687,12 @@ static void trans_ana_fx(
IF( GE_16( k, LGW32K - 1 ) )
{
beta[k] = mult_r( beta[k], 3277 ); /* 0.1 in Q15 */
+ move16();
}
ELSE IF( GE_16( k, LGW16K - 1 ) )
{
beta[k] = mult_r( beta[k], 16384 ); /* 0.5 in Q15 */
+ move16();
}
}
pGrPowLeft++;
@@ -721,7 +736,7 @@ static void ivas_peakfinder_fx(
FOR( i = 0; i < len0Minus1; i++ )
{
- IF( EQ_16( dx0[i], 0 ) )
+ if ( dx0[i] == 0 )
{
dx0[i] = -1;
move16();
@@ -756,6 +771,7 @@ static void ivas_peakfinder_fx(
IF( s_xor( *pDx01++, *pDx0++ ) < 0 ) /* Detect sign change. */
{
*pInd++ = add( i, 1 );
+ move16();
*pX++ = *pX0;
move16();
len = add( len, 1 );
@@ -775,7 +791,7 @@ static void ivas_peakfinder_fx(
pInd = indarr;
test();
test();
- IF( GT_16( len, 2 ) || ( !endpoints && ( GT_16( len, 0 ) ) ) )
+ IF( GT_16( len, 2 ) || ( !endpoints && ( len > 0 ) ) )
{
/* Set initial parameters for loop */
tempMag = minMag;
@@ -786,7 +802,7 @@ static void ivas_peakfinder_fx(
move16();
threshold = add( leftMin, sel );
- IF( GT_16( len, 0 ) )
+ IF( len > 0 )
{
/* Deal with first point a little differently since tacked it on
Calculate the sign of the derivative since we took the first point
@@ -819,6 +835,7 @@ static void ivas_peakfinder_fx(
ELSE /* First point is smaller than the second */
{
ii = 0;
+ move16();
IF( LT_16( xAt1, xAt2 ) ) /* x[1] is not extremum -> overwrite with x[0] */
{
*pX = xAt0; /* x[1] = x[0] */
@@ -836,11 +853,13 @@ static void ivas_peakfinder_fx(
{
// PMTE ()
ii = -1; /* First point is a peak */
+ move16();
IF( GE_16( len, 2 ) )
{
- IF( GE_16( x[1], x[0] ) )
+ if ( GE_16( x[1], x[0] ) )
{
ii = 0; /* First point is a valley, skip it */
+ move16();
}
}
}
@@ -860,7 +879,7 @@ static void ivas_peakfinder_fx(
/*Reset peak finding if we had a peak and the next peak is bigger
than the last or the left min was small enough to reset.*/
- IF( GT_16( foundPeak, 0 ) )
+ IF( foundPeak > 0 )
{
tempMag = minMag;
move16();
@@ -885,7 +904,7 @@ static void ivas_peakfinder_fx(
pX++;
/* Come down at least sel from peak */
- IF( EQ_16( foundPeak, 0 ) )
+ IF( foundPeak == 0 )
{
IF( GT_16( tempMag, add( sel, *pX ) ) )
{
@@ -899,9 +918,10 @@ static void ivas_peakfinder_fx(
peakMag[*cInd] = tempMag;
move16();
*cInd = add( *cInd, 1 );
+ move16();
}
}
- IF( EQ_16( foundPeak, 0 ) ) /* The above IF-block has not found the peak yet. */
+ IF( foundPeak == 0 ) /* The above IF-block has not found the peak yet. */
{
IF( LT_16( *pX, leftMin ) ) /* New left minimum */
{
@@ -922,11 +942,12 @@ static void ivas_peakfinder_fx(
peakMag[*cInd] = x[lenMinus1];
move16();
*cInd = add( *cInd, 1 );
+ move16();
foundPeak = 1;
move16();
}
}
- IF( EQ_16( foundPeak, 0 ) ) /* Check if we still need to add the last point */
+ IF( foundPeak == 0 ) /* Check if we still need to add the last point */
{
IF( GT_16( tempMag, minMag ) )
{
@@ -935,6 +956,7 @@ static void ivas_peakfinder_fx(
peakMag[*cInd] = tempMag;
move16();
*cInd = add( *cInd, 1 );
+ move16();
}
}
@@ -943,7 +965,6 @@ static void ivas_peakfinder_fx(
{
plocs[i] = *( indarr + peakLoc[i] );
move16();
- move16();
}
}
ELSE /* This is a monotone function where an endpoint is the only peak */
@@ -952,7 +973,7 @@ static void ivas_peakfinder_fx(
{
xInd = 1;
move16();
- IF( GT_16( x[0], x[1] ) )
+ if ( GT_16( x[0], x[1] ) )
{
xInd = 0;
move16();
@@ -1004,6 +1025,7 @@ static void peakfinder_fx(
Word16 *pInd;
tempLoc = 0;
+ move16();
/* Find derivative */
len0Minus1 = sub( len0, 1 );
@@ -1049,6 +1071,7 @@ static void peakfinder_fx(
IF( s_xor( *pDx01++, *pDx0++ ) < 0 ) /* Detect sign change. */
{
*pInd++ = add( i, 1 );
+ move16();
*pX++ = *pX0;
move16();
len = add( len, 1 );
@@ -1120,6 +1143,7 @@ static void peakfinder_fx(
ELSE /* First point is smaller than the second */
{
ii = 0;
+ move16();
IF( LT_16( xAt1, xAt2 ) ) /* x[1] is not extremum -> overwrite with x[0] */
{
*pX = xAt0; /* x[1] = x[0] */
@@ -1163,7 +1187,7 @@ static void peakfinder_fx(
/*Reset peak finding if we had a peak and the next peak is bigger
than the last or the left min was small enough to reset.*/
- IF( GT_16( foundPeak, 0 ) )
+ IF( foundPeak > 0 )
{
tempMag = minMag;
move16();
@@ -1202,6 +1226,7 @@ static void peakfinder_fx(
peakMag[*cInd] = tempMag;
move16();
*cInd = add( *cInd, 1 );
+ move16();
}
}
IF( foundPeak == 0 ) /* The above IF-block has not found the peak yet. */
@@ -1238,6 +1263,7 @@ static void peakfinder_fx(
peakMag[*cInd] = tempMag;
move16();
*cInd = add( *cInd, 1 );
+ move16();
}
}
@@ -1246,7 +1272,6 @@ static void peakfinder_fx(
{
plocs[i] = *( indarr + peakLoc[i] );
move16();
- move16();
}
}
ELSE /* This is a monotone function where an endpoint is the only peak */
@@ -1304,6 +1329,7 @@ static Word16 imax_fx( /* o: The location, relative to the
Word32 numer, denom, sign, acc, y3_y1;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* Seek the extremum of the parabola P(x) defined by 3 consecutive points
so that P([-1 0 1]) = [y1 y2 y3] */
@@ -1350,11 +1376,11 @@ static Word16 imax_fx( /* o: The location, relative to the
/* For both edges (left and right), the extremum found above may be minimum.
* It needs to reject the minimum. */
- IF( NE_16( special, 0 ) ) /* Either edge specical case. */
+ IF( special != 0 ) /* Either edge specical case. */
{
edge = 0x7fff; /* 1 in Q15 for the right edge special case */
move16();
- if ( LT_16( special, 0 ) )
+ if ( special < 0 )
{
edge = 0; /* Left edge special case */
move16();
@@ -1366,7 +1392,7 @@ static Word16 imax_fx( /* o: The location, relative to the
* Therefore, the slope at y=0 is simply B. Use this slope to determine
* if the parabola is concave upward or downward.
*/
- IF( GT_16( posi, 0 ) ) /* The extremum is in between the middle and the right given data points. */
+ IF( posi > 0 ) /* The extremum is in between the middle and the right given data points. */
{
IF( LE_16( y3, y1 ) ) /* Check the slope at y=0, i.e., at the middle given data point. */
{
@@ -1430,10 +1456,13 @@ static void ivas_spec_ana_fx(
Word16 currPlocs, endPlocs, nJacob, k, i;
Word32 sig, noise, st_point, end_point;
+ move16(); // LprotLog2Minus1
+ move16(); // hamm_len2
Lprot = 512; /* 1536=(2*output_frame)*1024/1280; */
move16();
sinTblOffset = 0;
+ move16();
IF( EQ_16( output_frame, L_FRAME48k ) )
{
@@ -1482,7 +1511,7 @@ static void ivas_spec_ana_fx(
IF( EQ_16( output_frame, L_FRAME48k ) )
{
/* Apply hamming-rect window */
- IF( EQ_16( element_mode, EVS_MONO ) )
+ IF( element_mode == EVS_MONO )
{
windowing( xfp, xfp, w_hamm_sana48k_2_fx, rectLength, hamm_len2 );
}
@@ -1490,12 +1519,13 @@ static void ivas_spec_ana_fx(
{
// PMTE()
window_corr = w_hamm[0];
- window_corr_step = w_hamm[0] / hamm_len2;
+ move16();
+ window_corr_step = idiv1616( w_hamm[0], hamm_len2 );
FOR( i = 0; i < hamm_len2; i++ )
{
xfp[i] = mult_r( shl( prevsynth[i], *Q ), sub( w_hamm[i], window_corr ) );
move16();
- xfp[Lprot - i - 1] = mult_r( shl( prevsynth[Lprot - i - 1], *Q ), sub( w_hamm[i], window_corr ) );
+ xfp[sub( sub( Lprot, i ), 1 )] = mult_r( shl( prevsynth[sub( sub( Lprot, i ), 1 )], *Q ), sub( w_hamm[i], window_corr ) );
move16();
window_corr = sub( window_corr, window_corr_step );
}
@@ -1505,7 +1535,7 @@ static void ivas_spec_ana_fx(
}
ELSE
{
- IF( EQ_16( element_mode, EVS_MONO ) )
+ IF( element_mode == EVS_MONO )
{
/* Apply hamming-rect window */
windowing_ROM_optimized( xfp, xfp, sinTblOffset, rectLength, hamm_len2 );
@@ -1514,12 +1544,13 @@ static void ivas_spec_ana_fx(
{
// PMTE()
window_corr = w_hamm[0];
- window_corr_step = w_hamm[0] / hamm_len2;
+ move16();
+ window_corr_step = idiv1616( w_hamm[0], hamm_len2 );
FOR( i = 0; i < hamm_len2; i++ )
{
xfp[i] = mult_r( shl( prevsynth[i], *Q ), sub( w_hamm[i], window_corr ) );
move16();
- xfp[Lprot - i - 1] = mult_r( shl( prevsynth[Lprot - i - 1], *Q ), sub( w_hamm[i], window_corr ) );
+ xfp[sub( sub( Lprot, i ), 1 )] = mult_r( shl( prevsynth[sub( sub( Lprot, i ), 1 )], *Q ), sub( w_hamm[i], window_corr ) );
move16();
window_corr = sub( window_corr, window_corr_step );
}
@@ -1557,6 +1588,7 @@ static void ivas_spec_ana_fx(
IF( *pMagSq == 0 )
{
*pXfp++ = extract_l( *pMagSq++ ); /* magSq[] is zero */
+ move16();
}
ELSE
{
@@ -1577,7 +1609,7 @@ static void ivas_spec_ana_fx(
/* Find maximum and minimum. */
maximum_fx( xfp, Lprot2_1, &Xmax );
minimum_fx( xfp, Lprot2_1, &Xmin );
- IF( EQ_16( element_mode, EVS_MONO ) )
+ IF( element_mode == EVS_MONO )
{
sel = mult_r( sub( Xmax, Xmin ), CMPLMNT_PFIND_SENS_FX );
}
@@ -1589,12 +1621,13 @@ static void ivas_spec_ana_fx(
/* Currently not the pitch correlation but some LF correlation */
- IF( element_mode != EVS_MONO && *num_plocs > 50 && pcorr < 19661 /* 0.6f in Q15 */ )
+ if ( element_mode != EVS_MONO && *num_plocs > 50 && pcorr < 19661 /* 0.6f in Q15 */ )
{
*num_plocs = 0;
+ move16();
}
- IF( EQ_16( element_mode, EVS_MONO ) )
+ IF( element_mode == EVS_MONO )
{
/* Refine peaks */
@@ -1602,7 +1635,7 @@ static void ivas_spec_ana_fx(
pPlocs = plocs;
n = sub( *num_plocs, 1 ); /* -1 so as to exclude the very last peak. */
/* Special case-- The very 1st peak if it is at 0 index position */
- IF( EQ_16( *pPlocs, 0 ) ) /* Only the very 1st peak is possible the peak at 0 index position. */
+ IF( *pPlocs == 0 ) /* Only the very 1st peak is possible the peak at 0 index position. */
{
fraction = imax_fx( xfp, -1 ); /* -1 signifies special left edge case. */
acc = L_deposit_h( *pPlocs++ ); /* N.B., (*pPlocs) must be zero here. */
@@ -1656,7 +1689,7 @@ static void ivas_spec_ana_fx(
/* With DELTA_CORR_F0_INT == 2 one needs to handle both *pPlocs==0 and *pPlocs==1 */
// IF( n > 0 && *pPlocs == 0 ) /* Very 1st peak position possible to have a peak at 0/DC index position. */
test();
- IF( GT_16( n, 0 ) && EQ_16( *pPlocs, 0 ) ) /* Very 1st peak position possible to have a peak at 0/DC index position. */
+ IF( n > 0 && *pPlocs == 0 ) /* Very 1st peak position possible to have a peak at 0/DC index position. */
{
fraction = imax_fx( &xfp[*pPlocs], -1 ); /* in Q15 */
acc = L_deposit_h( *pPlocs );
@@ -1667,7 +1700,7 @@ static void ivas_spec_ana_fx(
}
test();
- IF( GT_16( n, 0 ) && EQ_16( *pPlocs, 1 ) ) /* Also 2nd peak position uses DC which makes jacobsen unsuitable. */
+ IF( n > 0 && EQ_16( *pPlocs, 1 ) ) /* Also 2nd peak position uses DC which makes jacobsen unsuitable. */
{
fraction = imax_fx( &xfp[*pPlocs - 1], -1 ); /* in Q15 */
acc = L_deposit_h( *pPlocs - 1 );
@@ -1684,18 +1717,18 @@ static void ivas_spec_ana_fx(
endPlocs = sub( Lprot2_1, DELTA_CORR_F0_INT ); /* last *pPlocs position for Jacobsen */
/* precompute number of turns based on endpoint integer location and make into a proper for loop */
- IF( GT_16( n, 0 ) )
+ IF( n > 0 )
{
nJacob = n;
move16();
- IF( LE_16( sub( endPlocs, plocs[sub( *num_plocs, 1 )] ), 0 ) )
+ if ( sub( endPlocs, plocs[sub( *num_plocs, 1 )] <= 0 ) )
{
nJacob = sub( nJacob, 1 );
}
FOR( k = 0; k < nJacob; k++ )
{
- fraction = ivas_imax2_jacobsen_mag_fx( &( X_sav[currPlocs - 1] ), &( X_sav[Lprot - 1 - currPlocs] ) ); /* in Q15 */
+ fraction = ivas_imax2_jacobsen_mag_fx( &( X_sav[currPlocs - 1] ), &( X_sav[sub( sub( Lprot, 1 ), currPlocs )] ) ); /* in Q15 */
acc = L_deposit_h( currPlocs );
*pPlocsi++ = L_mac( acc, fraction, 1 );
move32();
@@ -1707,7 +1740,7 @@ static void ivas_spec_ana_fx(
/* At this point there should at most two plocs left to process */
/* the position before fs/2 and fs/2 both use the same magnitude points */
- IF( GT_16( n, 0 ) )
+ IF( n > 0 )
{
/* [ . . . . . . . ] Lprot/2+1 positions */
/* | | | */
@@ -1716,7 +1749,7 @@ static void ivas_spec_ana_fx(
IF( EQ_16( currPlocs, ( sub( Lprot2_1, DELTA_CORR_F0_INT ) ) ) ) /* Also 2nd last peak position uses fs/2 which makes jacobsen less suitable. */
{
fraction = imax_fx( &xfp[currPlocs - 1], 0 ); /* in Q15 */
- acc = L_deposit_h( currPlocs - 1 );
+ acc = L_deposit_h( sub( currPlocs, 1 ) );
*pPlocsi++ = L_mac( acc, fraction, 1 );
move32();
currPlocs = *pPlocs++;
@@ -1727,10 +1760,10 @@ static void ivas_spec_ana_fx(
/* Here the only remaining point would be a fs/2 plocs */
/* pXfp = xfp + sub(Lprot2,1); already set just a reminder where it
* whould point */
- IF( GT_16( n, 0 ) ) /* fs/2 which makes special case . */
+ IF( n > 0 ) /* fs/2 which makes special case . */
{
fraction = imax_fx( &xfp[currPlocs - 2], 0 ); /* in Q15 */
- acc = L_deposit_h( currPlocs - 2 );
+ acc = L_deposit_h( sub( currPlocs, 2 ) );
*pPlocsi++ = L_mac( acc, fraction, 1 );
move32();
currPlocs = *pPlocs++;
@@ -1741,18 +1774,18 @@ static void ivas_spec_ana_fx(
/* For few peaks decide noise floor attenuation */
test();
- IF( LT_16( *num_plocs, 3 ) && GT_16( *num_plocs, 0 ) )
+ IF( LT_16( *num_plocs, 3 ) && *num_plocs > 0 )
{
- sig = sum16_32_fx( xfp, Lprot2_1 ) + 1;
+ sig = L_add( sum16_32_fx( xfp, Lprot2_1 ), 1 );
/*excluding peaks and neighboring bins*/
FOR( i = 0; i < *num_plocs; i++ )
{
- st_point = s_max( 0, plocs[i] - DELTA_CORR );
- end_point = s_min( Lprot2_1 - 1, plocs[i] + DELTA_CORR );
- set16_fx( &xfp[st_point], 0, (Word16) ( end_point - st_point + 1 ) );
+ st_point = s_max( 0, sub( plocs[i], DELTA_CORR ) );
+ end_point = s_min( sub( Lprot2_1, 1 ), add( plocs[i], DELTA_CORR ) );
+ set16_fx( &xfp[st_point], 0, extract_l( L_add( L_sub( end_point, st_point ), 1 ) ) );
}
- noise = sum16_32_fx( xfp, Lprot2_1 ) + 1;
+ noise = L_add( sum16_32_fx( xfp, Lprot2_1 ), 1 );
IF( LT_32( noise, Mpy_32_32( 64424509 /* 0.03 in Q31 */, sig ) ) )
{
@@ -1798,10 +1831,13 @@ static void spec_ana_fx(
Word16 stop_band_start;
Word16 stop_band_length;
+ move16(); // LprotLog2Minus1
+ move16(); // hamm_len2
Lprot = 512; /* 1536=(2*output_frame)*1024/1280; */
move16();
sinTblOffset = 0;
+ move16();
IF( EQ_16( output_frame, L_FRAME48k ) )
{
@@ -1984,7 +2020,7 @@ static void spec_ana_fx(
pPlocs = plocs;
n = sub( *num_plocs, 1 ); /* -1 so as to exclude the very last peak. */
/* Special case-- The very 1st peak if it is at 0 index position */
- IF( EQ_16( *pPlocs, 0 ) ) /* Only the very 1st peak is possible the peak at 0 index position. */
+ IF( *pPlocs == 0 ) /* Only the very 1st peak is possible the peak at 0 index position. */
{
fraction = imax_fx( xfp, -1 ); /* -1 signifies special left edge case. */
acc = L_deposit_h( *pPlocs++ ); /* N.B., (*pPlocs) must be zero here. */
@@ -2210,6 +2246,7 @@ static void ivas_subst_spec_fx(
{
// tmp = NS2SA(output_frame*50,PH_ECU_ALDO_OLP2_NS-PH_ECU_LOOKAHEAD_NS);
tmp = NS2SA( output_frame * 50, PH_ECU_ALDO_OLP2_NS );
+ move16();
tmp = sub( tmp, ph_ecu_lookahead );
tmp = add( tmp, sub( Lecu, shr( sub( Lecu, Lprot ), 1 ) ) );
tmp = sub( tmp, shr( output_frame, 1 ) );
@@ -2228,19 +2265,19 @@ static void ivas_subst_spec_fx(
}
one_peak_flag_mask = 32767 /* 1.0f in Q15 */; /* all ones mask -> keep */
move16();
- IF( NE_16( element_mode, EVS_MONO ) )
+ IF( element_mode != EVS_MONO )
{
test();
- IF( ( GT_16( *num_plocs, 0 ) ) && LT_16( sub( *num_plocs, 3 ), 0 ) )
+ if ( ( *num_plocs > 0 ) && ( sub( *num_plocs, 3 ) < 0 ) )
{
one_peak_flag_mask = noise_fac; /* all zeroes mask -> zero */
move16();
}
- IF( EQ_16( *num_plocs, 0 ) )
+ IF( *num_plocs == 0 )
{
X[0] = 0; /* reset DC if there are no peaks */
move16();
- X[shr( Lprot, 1 )] = 0; /* also reset fs/2 if there are no peaks */
+ X[Lprot / 2] = 0; /* also reset fs/2 if there are no peaks */
move16();
}
}
@@ -2273,10 +2310,10 @@ static void ivas_subst_spec_fx(
move16();
pkLocation1 = *pPlocs++; /* plocs[m + 1] */
move16();
- IF( GT_16( m, 0 ) )
+ IF( m > 0 )
{
delta_tmp = shr( sub( sub( pkLocation, pkLocation_1 ), 1 ), 1 );
- IF( LT_16( delta_tmp, DELTA_CORR ) )
+ if ( LT_16( delta_tmp, DELTA_CORR ) )
{
delta_corr_dn = delta_tmp;
move16();
@@ -2286,7 +2323,7 @@ static void ivas_subst_spec_fx(
IF( LT_16( m, lastPeak ) )
{
delta_tmp = shr( sub( sub( pkLocation1, pkLocation ), 1 ), 1 );
- IF( LT_16( delta_tmp, DELTA_CORR ) )
+ if ( LT_16( delta_tmp, DELTA_CORR ) )
{
delta_corr_up = delta_tmp;
move16();
@@ -2304,7 +2341,7 @@ static void ivas_subst_spec_fx(
move16();
im = *pImX;
move16();
- IF( EQ_16( element_mode, EVS_MONO ) )
+ IF( element_mode == EVS_MONO )
{
tmp = sub( mult_r( re, cos_F ), mult_r( im, sin_F ) );
im = add( mult_r( re, sin_F ), mult_r( im, cos_F ) );
@@ -2317,6 +2354,7 @@ static void ivas_subst_spec_fx(
IF( LT_16( alpha[k], 32766 ) )
{
*seed = rand_phase_fx( *seed, &sin_F, &cos_F );
+ move16();
tmp2 = mult_r( beta[k], Xavg[k] );
*pReX++ = add( mult_r( alpha[k], tmp ), mult_r( tmp2, cos_F ) );
move16();
@@ -2331,20 +2369,21 @@ static void ivas_subst_spec_fx(
move16();
}
i = add( i, 1 );
- IF( GE_16( i, ivas_gwlpr[k + 1] ) )
+ if ( GE_16( i, ivas_gwlpr[k + 1] ) )
{
k = add( k, 1 );
}
}
e = add( pkLocation, delta_corr_up );
- IF( GT_16( e, lprotBy2Minus1 ) )
+ if ( GT_16( e, lprotBy2Minus1 ) )
{
e = lprotBy2Minus1;
move16();
}
Xph = *pCorrPhase;
+ move32();
Xph_short = s_and( extract_l( L_shr( Xph, 16 - 10 ) ), 0x3ff ); /* 10 bits precision after radix point */
IF( GE_16( Xph_short, 512 ) )
{
@@ -2380,15 +2419,16 @@ static void ivas_subst_spec_fx(
{
mag_chg_local = mag_chg[k];
move16();
- IF( NE_16( ph_dith, 0 ) )
+ IF( ph_dith != 0 )
{
- Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */
+ Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */
+ move32();
Random( seed ); /* in Q0 */
acc = L_mult( *seed, ph_dith ); /* N.B. ph_dith[i] is in Q15, i.e., in between 0 and 1.0 (2*PI not included) */
acc = L_shr( acc, PHASE_DITH_SCALE_SHIFT );
Xph = L_add( Xph, acc ); /* in Q16. */
- IF( GT_16( ph_dith, 0 ) ) /* up to 6 dB additional att of peaks in non_transient longer bursts, (when peak phase is randomized ) */
+ IF( ph_dith > 0 ) /* up to 6 dB additional att of peaks in non_transient longer bursts, (when peak phase is randomized ) */
{
/* mag_chg_local *= 0.5 + (1.0 - ph_dith[i])/2 where 0.5~= sqrt((float)pow(10.0,-6/10.0)) and ph_dith=0..1.0--> scale=1.0 ...5 */
mag_chg_local = mult_r( mag_chg_local, sub( 32767, shr( ph_dith, 1 ) ) );
@@ -2437,7 +2477,7 @@ static void ivas_subst_spec_fx(
acc = L_sub( 1073741824L, L_mult0( alpha_local, alpha_local ) );
acc = Sqrt_l( acc, &expo );
expo = add( 30, add( 31, expo ) );
- IF( EQ_16( s_and( expo, 1 ), 1 ) )
+ if ( EQ_16( s_and( expo, 1 ), 1 ) )
{
acc = Mult_32_16( acc, 23170 ); /* 1/sqrt(2) in Q15 */
}
@@ -2454,6 +2494,7 @@ static void ivas_subst_spec_fx(
}
*seed = rand_phase_fx( *seed, &sin_F, &cos_F );
+ move16();
tmp2 = mult_r( beta_local, Xavg[k] );
*pReX++ = add( mult_r( alpha_local, tmp ), mult_r( tmp2, cos_F ) );
move16();
@@ -2469,7 +2510,7 @@ static void ivas_subst_spec_fx(
}
i = add( i, 1 );
- IF( GE_16( i, ivas_gwlpr[k + 1] ) )
+ if ( GE_16( i, ivas_gwlpr[k + 1] ) )
{
k = add( k, 1 );
}
@@ -2481,6 +2522,7 @@ static void ivas_subst_spec_fx(
FOR( j = 0; j < segmentLen; j++ )
{
*seed = rand_phase_fx( *seed, &sin_F, &cos_F );
+ move16();
re = *pReX;
move16();
@@ -2488,7 +2530,7 @@ static void ivas_subst_spec_fx(
move16();
- IF( EQ_16( element_mode, EVS_MONO ) )
+ IF( element_mode == EVS_MONO )
{
tmp = sub( mult_r( re, cos_F ), mult_r( im, sin_F ) );
im = add( mult_r( re, sin_F ), mult_r( im, cos_F ) );
@@ -2501,6 +2543,7 @@ static void ivas_subst_spec_fx(
IF( LT_16( alpha[k], 32766 ) )
{
*seed = rand_phase_fx( *seed, &sin_F, &cos_F );
+ move16();
tmp2 = mult_r( beta[k], Xavg[k] );
*pReX++ = add( mult_r( alpha[k], tmp ), mult_r( tmp2, cos_F ) );
move16();
@@ -2516,7 +2559,7 @@ static void ivas_subst_spec_fx(
}
i = add( i, 1 );
- IF( GE_16( i, ivas_gwlpr[k + 1] ) )
+ if ( GE_16( i, ivas_gwlpr[k + 1] ) )
{
k = add( k, 1 );
}
@@ -2609,6 +2652,7 @@ static void subst_spec_fx(
ELSE
{
tmp = NS2SA( output_frame * 50, PH_ECU_ALDO_OLP2_NS - PH_ECU_LOOKAHEAD_NS );
+ move16();
tmp = add( tmp, sub( Lecu, shr( sub( Lecu, Lprot ), 1 ) ) );
tmp = sub( tmp, shr( output_frame, 1 ) );
tmp = add( tmp, time_offs );
@@ -2717,6 +2761,7 @@ static void subst_spec_fx(
IF( LT_16( alpha[k], 32766 ) )
{
*seed = rand_phase_fx( *seed, &sin_F, &cos_F );
+ move16();
tmp2 = mult_r( beta[k], Xavg[k] );
*pReX++ = add( mult_r( alpha[k], tmp ), mult_r( tmp2, cos_F ) );
move16();
@@ -2745,6 +2790,7 @@ static void subst_spec_fx(
}
Xph = *pCorrPhase;
+ move32();
Xph_short = s_and( extract_l( L_shr( Xph, 16 - 10 ) ), 0x3ff ); /* 10 bits precision after radix point */
IF( GE_16( Xph_short, 512 ) )
{
@@ -2782,7 +2828,8 @@ static void subst_spec_fx(
move16();
IF( ph_dith != 0 )
{
- Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */
+ Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */
+ move32();
Random( seed ); /* in Q0 */
acc = L_mult( *seed, ph_dith ); /* N.B. ph_dith[i] is in Q15, i.e., in between 0 and 1.0 (2*PI not included) */
acc = L_shr( acc, PHASE_DITH_SCALE_SHIFT );
@@ -2866,12 +2913,13 @@ static void subst_spec_fx(
{
beta_local = mult_r( beta_local, 3277 ); /* 0.1 in Q15 */
}
- ELSE if ( GE_16( k, LGW16K - 1 ) )
+ ELSE IF( GE_16( k, LGW16K - 1 ) )
{
beta_local = mult_r( beta_local, 16384 ); /* 0.5 in Q15 */
}
*seed = rand_phase_fx( *seed, &sin_F, &cos_F );
+ move16();
tmp2 = mult_r( beta_local, Xavg[k] );
*pReX++ = add( mult_r( alpha_local, tmp ), mult_r( tmp2, cos_F ) );
move16();
@@ -2899,6 +2947,7 @@ static void subst_spec_fx(
FOR( j = 0; j < segmentLen; j++ )
{
*seed = rand_phase_fx( *seed, &sin_F, &cos_F );
+ move16();
re = *pReX;
move16();
@@ -2909,6 +2958,7 @@ static void subst_spec_fx(
IF( LT_16( alpha[k], 32766 ) )
{
*seed = rand_phase_fx( *seed, &sin_F, &cos_F );
+ move16();
tmp2 = mult_r( beta[k], Xavg[k] );
*pReX++ = add( mult_r( alpha[k], tmp ), mult_r( tmp2, cos_F ) );
move16();
@@ -2968,8 +3018,10 @@ static void ivas_rec_wtda_fx(
Word16 copy_len;
Word16 ola_len;
- copy_len = NS2SA( output_frame * FRAMES_PER_SEC, ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* prototype fill on each side of xsubst to fill MDCT Frame */
+ copy_len = NS2SA( output_frame * FRAMES_PER_SEC, ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* prototype fill on each side of xsubst to fill MDCT Frame */
+ move16();
ola_len = NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS - ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* remaining lengt of LA_ZEROS to overlap add decoded with xsubst */
+ move16();
xf_len = 26;
move16();
@@ -2979,6 +3031,7 @@ static void ivas_rec_wtda_fx(
{
w_hamm = w_hamm_sana48k_2_fx;
hamm_len2 = L_PROT_HAMM_LEN2_48k;
+ move16();
xf_len = 78;
move16();
tbl_delta = 3361; /* Q12 */
@@ -2988,6 +3041,7 @@ static void ivas_rec_wtda_fx(
{
w_hamm = w_hamm_sana32k_2_fx;
hamm_len2 = L_PROT_HAMM_LEN2_32k;
+ move16();
xf_len = 52;
move16();
tbl_delta = 5041; /* Q12 */
@@ -2997,15 +3051,16 @@ static void ivas_rec_wtda_fx(
{
w_hamm = w_hamm_sana16k_2_fx;
hamm_len2 = L_PROT_HAMM_LEN2_16k;
+ move16();
}
test();
test();
- IF( NE_16( element_mode, EVS_MONO ) && GT_16( *num_p, 0 ) && GT_16( plocs[0], 3 ) )
+ IF( element_mode != EVS_MONO && *num_p > 0 && GT_16( plocs[0], 3 ) )
{
/* Perform inverse windowing of hammrect */
pX_start = X;
- pX_end = X + Lprot - 1;
+ pX_end = X + sub( Lprot, 1 );
FOR( i = 0; i < hamm_len2; i++ )
{
tmp = BASOP_Util_Divide1616_Scale( 1, *w_hamm, &tmp_e );
@@ -3021,22 +3076,22 @@ static void ivas_rec_wtda_fx(
}
/* extract reconstructed frame with aldo window */
- timesh = NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ) - ( 2 * output_frame - Lprot ) / 2;
+ timesh = sub( NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ), shr( sub( shl( output_frame, 1 ), Lprot ), 1 ) );
- set16_fx( xsubst_, 0, 2 * output_frame - Lprot + timesh );
- Copy( X, xsubst_ + 2 * output_frame - Lprot + timesh, Lprot - timesh );
+ set16_fx( xsubst_, 0, add( sub( shl( output_frame, 1 ), Lprot ), timesh ) );
+ Copy( X, xsubst_ + add( sub( shl( output_frame, 1 ), Lprot ), timesh ), sub( Lprot, timesh ) );
/* Copy and OLA look ahead zero part of MDCT window from decoded signal */
- IF( NE_16( element_mode, EVS_MONO ) )
+ IF( element_mode != EVS_MONO )
{
Copy( old_dec, xsubst_ + NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ), copy_len ); /* also need to scale to Q0 ?? */
pOld = old_dec + copy_len;
- pNew = xsubst_ + copy_len + NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS );
+ pNew = xsubst_ + add( copy_len, NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ) );
tmp = div_s( 1, shl( ola_len, 1 ) ); // Q15
tmp = round_fx( L_shl( L_mult( tmp, EVS_PI_FX ), 2 ) ); // Q15
sinq_fx( tmp, 0, ola_len, xfwin );
v_mult16_fixed( xfwin, xfwin, xfwin, ola_len ); /* xfwin = sin^2 of 0..pi/4 */
- pOldW = xfwin + ola_len - 1;
+ pOldW = xfwin + sub( ola_len, 1 );
pNewW = xfwin;
FOR( i = 0; i < ola_len; i++ )
{
@@ -3051,11 +3106,12 @@ static void ivas_rec_wtda_fx(
ELSE
{
/* Smoothen onset of ECU frame */
- p_ecu = xsubst_ + 2 * output_frame - Lprot + timesh;
+ p_ecu = xsubst_ + add( sub( shl( output_frame, 1 ), Lprot ), timesh );
FOR( i = 0; i < xf_len; ( i++, p_ecu++ ) )
{
idx = extract_l( L_shr( L_mult0( i, tbl_delta ), 12 ) );
g = sincos_t_fx[idx];
+ move16();
g = mult( g, g );
*p_ecu = mult( g, ( *p_ecu ) );
move16();
@@ -3211,11 +3267,12 @@ static void rec_wtda_fx(
set16_fx( xsubst_ + add( output_frame, Lprot2 ), 0, l );
/* Smoothen onset of ECU frame */
- p_ecu = xsubst_ + ( output_frame - Lprot2 );
+ p_ecu = xsubst_ + sub( output_frame, Lprot2 );
FOR( i = 0; i < xf_len; i++ )
{
idx = extract_l( L_shr( L_mult0( i, tbl_delta ), 12 ) );
g = sincos_t_fx[idx];
+ move16();
g = mult( g, g );
*p_ecu = mult( g, ( *p_ecu ) );
move16();
@@ -3223,9 +3280,11 @@ static void rec_wtda_fx(
}
timesh = NS2SA_fx2( fs, 10000000L - PH_ECU_ALDO_OLP2_NS );
+ move16();
set16_fx( rec_buf, 0, output_frame );
Qin = 0;
+ move16();
out_ptr = rec_buf + sub( shl( output_frame, 1 ), timesh );
wtda_fx( out_ptr, &Qin, ecu_rec, NULL, 0, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */
output_frame );
@@ -3353,11 +3412,12 @@ static Word32 mult_32_32_q( const Word32 a, const Word32 b, const Word16 q )
UWord32 lo;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
Mpy_32_32_ss( a, b, &hi, &lo );
#ifdef BASOP_NOGLOB
- return L_or( L_shl_o( hi, 32 - q - 1, &Overflow ), L_lshr( lo, q + 1 ) );
+ return L_or( L_shl_o( hi, sub( 32 - 1, q ), &Overflow ), L_lshr( lo, add( q, 1 ) ) );
#else
return L_or( L_shl( hi, 32 - q - 1 ), L_lshr( lo, q + 1 ) );
#endif
@@ -3390,8 +3450,7 @@ static void fir_dwn_fx(
{
s = L_deposit_l( 0 );
ptr_h = h + 1;
- ptr_x = x + i - 1;
- move16();
+ ptr_x = x + sub( i, 1 );
FOR( j = 1; j <= i; j++ )
{
@@ -3404,6 +3463,7 @@ static void fir_dwn_fx(
#ifdef BASOP_NOGLOB
*ptr_y++ = extract_h( L_shl_sat( s, centering ) );
+ move16();
#else
*ptr_y++ = extract_h( L_shl( s, centering ) );
#endif
@@ -3412,7 +3472,7 @@ static void fir_dwn_fx(
{
s = L_deposit_l( 0 );
ptr_h = h + 1;
- ptr_x = x + i - 1;
+ ptr_x = x + sub( i, 1 );
move16();
FOR( j = 1; j <= K; j++ )
@@ -3426,6 +3486,7 @@ static void fir_dwn_fx(
#ifdef BASOP_NOGLOB
*ptr_y++ = extract_h( L_shl_sat( s, centering ) );
+ move16();
#else
*ptr_y++ = extract_h( L_shl( s, centering ) );
#endif
@@ -3434,9 +3495,9 @@ static void fir_dwn_fx(
FOR( i = i; i < tmp; i += decimation )
{
s = L_deposit_l( 0 );
- ptr_h = h + i - L + 1;
+ ptr_h = h + add( sub( i, L ), 1 );
move16();
- ptr_x = x + L - 1;
+ ptr_x = x + sub( L, 1 );
move16();
FOR( j = add( sub( i, L ), 1 ); j <= K; j++ )
@@ -3450,6 +3511,7 @@ static void fir_dwn_fx(
#ifdef BASOP_NOGLOB
*ptr_y++ = extract_h( L_shl_sat( s, centering ) );
+ move16();
#else
*ptr_y++ = extract_h( L_shl( s, centering ) );
#endif
@@ -3590,26 +3652,34 @@ static void fec_ecu_pitch_fx(
}
- IF( HqVoicing == 1 )
+ IF( EQ_16( HqVoicing, 1 ) )
{
cb_start = 0;
+ move16();
cb_end = Lon20mul33;
+ move16();
}
ELSE
{
cb_start = 0;
+ move16();
cb_end = Lon20mul28;
+ move16();
}
accB = 0;
+ move16();
delay_ind = cb_start;
+ move16();
FOR( i = cb_start; i < cb_end; i++ ) /* cb_end = 35 let 6 ms min of loop size */
{
accA = 0;
- IF( i == cb_start )
+ move16();
+ IF( EQ_16( i, cb_start ) )
{
accB = 0;
+ move16();
ptr_LP = prevsynth_LP_fx;
ptr_LP2 = prevsynth_LP_fx + Lon20mul34;
FOR( k = 0; k < Lon20mul6; k++ )
@@ -3646,26 +3716,28 @@ static void fec_ecu_pitch_fx(
accCisqrt = Isqrt( accC ); /* Q31 - 3 + tmpQLP*/
- Ryytmp = mult_32_32_q( accA, accCisqrt, 16 + 3 - tmpQLP ); /*Q 6 -2*tmpQLP + Q31 - 3 + tmpQLP -16 -3 +tmpQLP = Q15*/
- Ryytmp = mult_32_32_q( Ryytmp, accBisqrt, 15 - 3 + tmpQLP ); /*Q15 + Q31 - 3 + tmpQLP -15 + 3- tmpQLP = Q31*/
- Ryy = extract_h( Ryytmp ); /* Q15 */
+ Ryytmp = mult_32_32_q( accA, accCisqrt, sub( 16 + 3, tmpQLP ) ); /*Q 6 -2*tmpQLP + Q31 - 3 + tmpQLP -16 -3 +tmpQLP = Q15*/
+ Ryytmp = mult_32_32_q( Ryytmp, accBisqrt, add( 15 - 3, tmpQLP ) ); /*Q15 + Q31 - 3 + tmpQLP -15 + 3- tmpQLP = Q31*/
+ Ryy = extract_h( Ryytmp ); /* Q15 */
- IF( Ryy > *min_corr_fx )
+ IF( GT_16( Ryy, *min_corr_fx ) )
{
*min_corr_fx = Ryy;
+ move16();
delay_ind = i;
+ move16();
}
test();
- IF( HqVoicing == 0 && *min_corr_fx > 31130 )
+ IF( HqVoicing == 0 && GT_16( *min_corr_fx, 31130 ) )
{
BREAK;
}
}
*N = sub( Lon20mul34, delay_ind );
-
+ move16();
Scale_sig( prevsynth_LP_fx, 320, negate( sub( tmpQLP, 3 ) ) );
return;
@@ -3710,7 +3782,9 @@ static void sin_cos_est_fx( Word32 phi, Word16 *cosfreq, Word16 *sinfreq )
#endif
#ifdef BASOP_NOGLOB
*sinfreq = round_fx_sat( sinv );
+ move16();
*cosfreq = round_fx_sat( cosv );
+ move16();
#else
*sinfreq = round_fx( sinv );
*cosfreq = round_fx( cosv );
@@ -3802,7 +3876,7 @@ static void ivas_fec_ecu_dft_fx(
Lon20 = 8;
move16();
- IF( EQ_16( element_mode, EVS_MONO ) )
+ IF( element_mode == EVS_MONO )
{
alignment_point = sub( shl( 160, 1 ), i_mult( 3, Lon20 ) );
}
@@ -3821,6 +3895,7 @@ static void ivas_fec_ecu_dft_fx(
L_tmp = L_shl( L_tmp, 1 );
}
*Nfft = shl( 1, sub( 15, tmp ) );
+ move16();
set32_fx( Tfr32, 0, *Nfft );
set32_fx( Tfi32, 0, *Nfft );
@@ -3831,7 +3906,7 @@ static void ivas_fec_ecu_dft_fx(
IF( EQ_16( *Nfft, N ) )
{
- Copy( &target[1], &Tfr16[1], *Nfft - 2 );
+ Copy( &target[1], &Tfr16[1], sub( *Nfft, 2 ) );
}
ELSE
{
@@ -3860,6 +3935,7 @@ static void ivas_fec_ecu_dft_fx(
/*to avoid overflow in DoRTFTn_fx() */
tmp = Exp16Array( *Nfft, Tfr16 );
*exp = add( tmp, add( 2, norm_s( *Nfft ) ) );
+ move16();
Copy_Scale_sig_16_32( Tfr16, Tfr32, *Nfft, *exp ); /*Qin+exp; */
DoRTFTn_fx( Tfr32, Tfi32, *Nfft );
@@ -3876,7 +3952,9 @@ static void ivas_fec_ecu_dft_fx(
FOR( i = 0; i < N_LP; i++ )
{
*pt1 = extract_h( *Pt1 ); /*Qin+exp-16 */
+ move16();
*pt2 = extract_h( *Pt2 ); /*Qin+exp-16 */
+ move16();
*pt3 = abs_iter_fx( Tfr[i], Tfi[i], 5 );
move16(); /*Qin+exp-16 */
L_tmp = L_mac0( L_tmp, *pt3, 1 ); /*Qin+exp-16 */
@@ -3889,6 +3967,7 @@ static void ivas_fec_ecu_dft_fx(
*sum_Tf_abs = L_tmp;
move32();
*exp = sub( *exp, 16 );
+ move16();
return;
}
#endif
@@ -3936,6 +4015,7 @@ static void fec_ecu_dft_fx(
L_tmp = L_shl( L_tmp, 1 );
}
*Nfft = shl( 1, sub( 15, tmp ) );
+ move16();
set32_fx( Tfr32, 0, *Nfft );
@@ -3947,7 +4027,7 @@ static void fec_ecu_dft_fx(
IF( EQ_16( *Nfft, N ) )
{
- Copy( &target[1], &Tfr16[1], *Nfft - 2 );
+ Copy( &target[1], &Tfr16[1], sub( *Nfft, 2 ) );
}
ELSE
{
@@ -3976,6 +4056,7 @@ static void fec_ecu_dft_fx(
/*to avoid overflow in DoRTFTn_fx() */
tmp = Exp16Array( *Nfft, Tfr16 );
*exp = add( tmp, add( 2, norm_s( *Nfft ) ) );
+ move16();
Copy_Scale_sig_16_32( Tfr16, Tfr32, *Nfft, *exp ); /*Qin+exp; */
DoRTFTn_fx( Tfr32, Tfi32, *Nfft );
@@ -3992,7 +4073,9 @@ static void fec_ecu_dft_fx(
FOR( i = 0; i < N_LP; i++ )
{
*pt1 = extract_h( *Pt1 ); /*Qin+exp-16 */
+ move16();
*pt2 = extract_h( *Pt2 ); /*Qin+exp-16 */
+ move16();
*pt3 = abs_iter_fx( Tfr[i], Tfi[i], 5 );
move16(); /*Qin+exp-16 */
L_tmp = L_mac0( L_tmp, *pt3, 1 ); /*Qin+exp-16 */
@@ -4005,6 +4088,7 @@ static void fec_ecu_dft_fx(
*sum_Tf_abs = L_tmp;
move32();
*exp = sub( *exp, 16 );
+ move16();
return;
}
@@ -4108,6 +4192,8 @@ static void sinusoidal_synthesis_fx(
Word32 synthesis_fx[2 * L_FRAME48k];
Word16 *pt1, *pt2, *pt3, *pt4;
+ move16(); // indmax
+ move16(); // Lon20_10
flag = HqVoicing;
move16();
if ( GT_16( N, Lon20_10 ) )
@@ -4331,7 +4417,7 @@ static void ivas_fec_noise_filling_fx(
Word16 alignment_point;
// PMTE()
L20 = extract_h( L_mult( 1639, L ) ); /*L/20 */
- IF( EQ_16( element_mode, EVS_MONO ) )
+ IF( element_mode == EVS_MONO )
{
alignment_point = sub( shl( L, 1 ), i_mult2( 3, L20 ) );
}
@@ -4353,7 +4439,7 @@ static void ivas_fec_noise_filling_fx(
sinq_tab = sinq_16k;
}
- Copy( prevsynth_fx + alignment_point - N, noisevect_fx, N );
+ Copy( prevsynth_fx + sub( alignment_point, N ), noisevect_fx, N );
/* Noise addition on full band */
/* residual */
@@ -4392,7 +4478,7 @@ static void ivas_fec_noise_filling_fx(
flag = ind;
move16();
pt5 = synthesis_fx;
- WHILE( GT_16( flag, 0 ) )
+ WHILE( flag > 0 )
{
tmp_fx = Random( ni_seed_forfec );
@@ -4433,7 +4519,7 @@ static void ivas_fec_noise_filling_fx(
flag = sub( flag, tmp_fx );
}
- IF( EQ_16( element_mode, EVS_MONO ) )
+ IF( element_mode == EVS_MONO )
{
kk = i_mult2( 7, L20 );
tmp_fx = i_mult2( 37, L20 );
@@ -4458,11 +4544,12 @@ static void ivas_fec_noise_filling_fx(
L_tmp = L_mult( ( *pt1 ), q1 ); /*Qsynth+16 */
L_tmp = L_mac( L_tmp, ( *pt6++ ), q2 ); /*Qsynth+16 */
( *pt1++ ) = round_fx( L_tmp ); /*Qsynth */
+ move16();
}
- Copy( synthesis_fx, synthesis_fx + kk, 2 * L - kk );
+ Copy( synthesis_fx, synthesis_fx + kk, sub( 2 * L, kk ) );
Copy( synthesis_fx + L, gapsynth_fx, L );
- Copy( prevsynth_fx + alignment_point - kk, synthesis_fx, kk );
+ Copy( prevsynth_fx + sub( alignment_point, kk ), synthesis_fx, kk );
}
#endif
@@ -4644,6 +4731,7 @@ static void fec_noise_filling_fx(
L_tmp = L_mult( ( *pt1 ), q1 ); /*Qsynth+16 */
L_tmp = L_mac( L_tmp, ( *pt6++ ), q2 ); /*Qsynth+16 */
( *pt1++ ) = round_fx( L_tmp ); /*Qsynth */
+ move16();
}
}
@@ -4685,7 +4773,7 @@ static void ivas_fec_alg_fx(
n = R1_16 - R2_16;
move16();
- IF( EQ_16( output_frame, L_FRAME32k ) )
+ if ( EQ_16( output_frame, L_FRAME32k ) )
{
n = 2 * N16_CORE_SW;
move16();
@@ -4809,9 +4897,10 @@ static void ivas_hq_phase_ecu_fx(
noise_fac = 32767; /* 1.0f in Q15 */
move16();
- IF( EQ_16( element_mode, EVS_MONO ) )
+ IF( element_mode == EVS_MONO )
{
ph_ecu_lookahead = NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS );
+ move16();
}
ELSE
{
@@ -4828,7 +4917,7 @@ static void ivas_hq_phase_ecu_fx(
lprot = L_PROT32k; /* 1024 */
move16();
}
- ELSE IF( output_frame == L_FRAME16k )
+ ELSE IF( EQ_16( output_frame, L_FRAME16k ) )
{
lprot = 512;
move16();
@@ -4842,11 +4931,12 @@ static void ivas_hq_phase_ecu_fx(
test();
test();
test();
- IF( EQ_16( prev_bfi, 0 ) || ( NE_16( prev_bfi, 0 ) && NE_16( *last_fec, 0 ) && ( EQ_16( *time_offs, output_frame ) ) ) )
+ IF( prev_bfi == 0 || ( prev_bfi != 0 && *last_fec != 0 && ( EQ_16( *time_offs, output_frame ) ) ) )
{
+ test();
test();
// PMT("verify condition compared to float")
- IF( !( NE_16( prev_bfi, 0 ) && NE_16( *last_fec, 0 ) && EQ_16( element_mode, EVS_MONO ) ) )
+ if ( !( prev_bfi != 0 && *last_fec != 0 && element_mode == EVS_MONO ) )
{
*time_offs = 0;
move16();
@@ -4859,15 +4949,16 @@ static void ivas_hq_phase_ecu_fx(
ivas_spec_ana_fx( prevsynth + offset, plocs, plocsi, num_p, X_sav, output_frame, bwidth_fx, Q_spec, element_mode, &noise_fac, pcorr );
test();
- IF( NE_16( prev_bfi, 0 ) && NE_16( *last_fec, 0 ) )
+ IF( prev_bfi != 0 && *last_fec != 0 )
{
*time_offs = add( *time_offs, output_frame );
+ move16();
}
}
ELSE
{
*time_offs = add( *time_offs, output_frame );
-
+ move16();
offset = sub( shl( output_frame, 1 ), lprot );
trans_ana_fx( prevsynth + offset, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab,
0, alpha, beta, beta_mute, Xavg );
@@ -4878,16 +4969,16 @@ static void ivas_hq_phase_ecu_fx(
/* seed for own_rand2 */
seed = *time_offs;
move16();
- IF( GT_16( *num_p, 0 ) )
+ IF( *num_p > 0 )
{
- seed = add( seed, plocs[*num_p - 1] );
+ seed = add( seed, plocs[sub( *num_p, 1 )] );
}
ivas_subst_spec_fx( plocs, plocsi, num_p, *time_offs, X, mag_chg, ph_dith, old_is_transient, output_frame, &seed,
alpha, beta, *beta_mute, Xavg, element_mode, ph_ecu_lookahead, noise_fac );
/* reconstructed frame in tda domain */
- old_dec = prevsynth + 2 * output_frame - NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS );
+ old_dec = prevsynth + sub( shl( output_frame, 1 ), NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ) );
ivas_rec_frame_fx( X, ecu_rec, output_frame, *Q_spec, old_dec, element_mode, num_p, plocs );
*last_fec = 0;
@@ -4975,7 +5066,7 @@ static void hq_phase_ecu_fx(
#ifdef IVAS_FEC_ECU_TO_COMPLETE
IF( !( prev_bfi != 0 && *last_fec != 0 ) && EQ_16( element_mode == EVS_MONO ) )
#else
- IF( !( prev_bfi != 0 && *last_fec != 0 ) )
+ if ( !( prev_bfi != 0 && *last_fec != 0 ) )
#endif
{
*time_offs = 0;
@@ -5001,11 +5092,13 @@ static void hq_phase_ecu_fx(
IF( prev_bfi != 0 && *last_fec != 0 )
{
*time_offs = add( *time_offs, output_frame );
+ move16();
}
}
ELSE
{
*time_offs = add( *time_offs, output_frame );
+ move16();
offset = sub( shl( output_frame, 1 ), lprot );
trans_ana_fx( prevsynth + offset, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab,
@@ -5017,9 +5110,9 @@ static void hq_phase_ecu_fx(
/* seed for own_rand2 */
seed = *time_offs;
move16();
- if ( *num_p > 0 )
+ IF( *num_p > 0 )
{
- seed = add( seed, plocs[*num_p - 1] );
+ seed = add( seed, plocs[sub( *num_p, 1 )] );
}
subst_spec_fx( plocs, plocsi, num_p, *time_offs, X, mag_chg, ph_dith, old_is_transient, output_frame, &seed,
@@ -5042,6 +5135,7 @@ static void hq_phase_ecu_fx(
);
*last_fec = 0;
+ move16();
*ph_ecu_active = 1;
move16();
}
@@ -5139,8 +5233,8 @@ void ivas_hq_ecu_fx(
test();
test();
test();
- IF( ( ( EQ_16( st_fx->element_mode, EVS_MONO ) ) && evs_mode_selection ) ||
- ( ( NE_16( st_fx->element_mode, EVS_MONO ) ) && evs_mode_selection && ivas_mode_selection ) )
+ IF( ( ( st_fx->element_mode == EVS_MONO ) && evs_mode_selection ) ||
+ ( ( st_fx->element_mode != EVS_MONO ) && evs_mode_selection && ivas_mode_selection ) )
{
ivas_fec_alg_fx( fec_alg_input, prevsynth_LP, &st_fx->hHQ_core->ni_seed_forfec, ecu_rec, output_frame, N, decimatefactor, ph_ecu_HqVoicing, gapsynth, st_fx->element_mode, st_fx->hHQ_core->old_out_fx );
*last_fec = 1;
@@ -5210,6 +5304,7 @@ void hq_ecu_fx(
#endif
/* init (values ar changed after) */
decimatefactor = 4;
+ move16();
N = shr( output_frame, 2 );
@@ -5277,6 +5372,7 @@ void hq_ecu_fx(
fec_alg_fx( prevsynth + NS2SA( output_frame * 50, ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, &st_fx->hHQ_core->ni_seed_forfec, ecu_rec, output_frame, N, decimatefactor, ph_ecu_HqVoicing, gapsynth );
*last_fec = 1;
+ move16();
*ph_ecu_active = 0;
move16();
*time_offs = output_frame;
diff --git a/lib_dec/FEC_adapt_codebook_fx.c b/lib_dec/FEC_adapt_codebook_fx.c
index 63c5559c055275cea9a579ceae4c14e6e716b477..71717bd4101e6ffc190b183032561a3a9af9cd7d 100644
--- a/lib_dec/FEC_adapt_codebook_fx.c
+++ b/lib_dec/FEC_adapt_codebook_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_dec.h" /* Decoder static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_dec.h" /* Decoder static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*---------------------------------------------------------------------*
diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c
index 9591807b7559a4f48a47878fe845663dc16d00b8..0c668df55ed762c801f29b4473adc0b24dde0e97 100644
--- a/lib_dec/FEC_clas_estim_fx.c
+++ b/lib_dec/FEC_clas_estim_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "basop_util.h"
/*-------------------------------------------------------------------*
diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c
index a029f1dfd771fb32e053bcceef31cdf482391749..7353f8f83b03b8a852ab8800343b0a060b26ec17 100644
--- a/lib_dec/FEC_fx.c
+++ b/lib_dec/FEC_fx.c
@@ -3,12 +3,11 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Common static table prototypes */
-#include "rom_dec.h" /* Decoder static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Common static table prototypes */
+#include "rom_dec.h" /* Decoder static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "basop_util.h"
#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
diff --git a/lib_dec/FEC_lsf_estim_fx.c b/lib_dec/FEC_lsf_estim_fx.c
index 21efc90e7cc38a906e3bb821e2441909ea3c7243..d79d90c8512625ce85c5a9e3e8664736befcb40e 100644
--- a/lib_dec/FEC_lsf_estim_fx.c
+++ b/lib_dec/FEC_lsf_estim_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*-------------------------------------------------------------------*
diff --git a/lib_dec/FEC_pitch_estim_fx.c b/lib_dec/FEC_pitch_estim_fx.c
index 4fa36e5b84cea42c8be5badc2c0f222b2d89afe3..d12c4b30ac591fc9af7de282ee0ebbe9cfbf5a53 100644
--- a/lib_dec/FEC_pitch_estim_fx.c
+++ b/lib_dec/FEC_pitch_estim_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
#include "stl.h"
@@ -69,9 +68,12 @@ void FEC_pitch_estim_fx(
test();
test();
- IF( ( EQ_16( element_mode, EVS_MONO ) && EQ_16( last_core, HQ_CORE ) ) || ( NE_16( element_mode, EVS_MONO ) && ( EQ_16( last_core, HQ_CORE ) || EQ_16( last_core, TCX_20_CORE ) || EQ_16( last_core, TCX_10_CORE ) ) ) )
+ test();
+ test();
+ test();
+ IF( ( ( element_mode == EVS_MONO ) && EQ_16( last_core, HQ_CORE ) ) || ( element_mode != EVS_MONO && ( EQ_16( last_core, HQ_CORE ) || EQ_16( last_core, TCX_20_CORE ) || EQ_16( last_core, TCX_10_CORE ) ) ) )
{
- *bfi_pitch = pitch_buf[shr( L_frame, 6 ) - 1];
+ *bfi_pitch = pitch_buf[sub( shr( L_frame, 6 ), 1 )];
move16();
*bfi_pitch_frame = L_frame;
move16();
@@ -102,7 +104,7 @@ void FEC_pitch_estim_fx(
( EQ_16( L_frame, L_FRAME16k ) ) ) ||
( EQ_16( coder_type, TRANSITION ) ) )
{
- *bfi_pitch = pitch_buf[shr( L_frame, 6 ) - 1];
+ *bfi_pitch = pitch_buf[sub( shr( L_frame, 6 ), 1 )];
move16();
*bfi_pitch_frame = L_frame;
move16();
diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c
index 24fca62db75ea9d0976dbb92e246b3f471a9e114..8448695c1fc517838e124cb175bcefee213d3d2e 100644
--- a/lib_dec/FEC_scale_syn_fx.c
+++ b/lib_dec/FEC_scale_syn_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
/*-------------------------------------------------------------------*
* Local constants
@@ -163,6 +162,7 @@ void FEC_scale_syn_fx(
ELSE IF( *scaling_flag > 0 )
{
( *scaling_flag ) = sub( *scaling_flag, 1 ); /* If scaling flag was equal to 2, add one control frame to account for the LSF interpolation */
+ move16();
}
scaling = 32767; /*2.0 Q14*/
move16();
@@ -175,7 +175,9 @@ void FEC_scale_syn_fx(
/*fer_energy( L_frame, clas, synth, pitch[(L_frame>>6)-1], &enr2, L_frame );*/
frame_ener_fx( L_frame, clas, synth, pitch[sub( shr( L_frame, 6 ), 1 )], &L_enr2 /*Q0*/, 1, Q_syn, 3, 0 );
- if ( bfi || ( EQ_32( total_brate, ACELP_7k20 ) ) || ( EQ_32( total_brate, ACELP_8k00 ) ) )
+ test();
+ test();
+ IF( bfi || ( EQ_32( total_brate, ACELP_7k20 ) ) || ( EQ_32( total_brate, ACELP_8k00 ) ) )
{
/* previous frame erased and no TC frame */
IF( *scaling_flag > 0 )
@@ -236,7 +238,6 @@ void FEC_scale_syn_fx(
pitch_dist = 0;
move16();
L_mean_pitch = L_mult( pitch[0], 8192 );
- move32();
FOR( k = 0; k < ( NB_SUBFR - 1 ); k++ )
{
pitch_dist = add( pitch_dist, abs_s( sub( pitch[k + 1], pitch[k] ) ) );
@@ -301,8 +302,8 @@ void FEC_scale_syn_fx(
test();
test();
test();
- IF( ( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && ( EQ_16( clas, UNVOICED_CLAS ) || EQ_16( clas, INACTIVE_CLAS ) ) ) ||
- EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, SID_2k40 ) || EQ_32( last_core_brate, FRAME_NO_DATA ) ) &&
+ IF( ( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && ( clas == UNVOICED_CLAS || EQ_16( clas, INACTIVE_CLAS ) ) ) ||
+ EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, SID_2k40 ) || last_core_brate == FRAME_NO_DATA ) &&
prev_bfi )
{
/* voiced -> unvoiced signal transition */
@@ -405,8 +406,8 @@ void FEC_scale_syn_fx(
test();
IF( ( ( ( EQ_32( total_brate, ACELP_13k20 ) ) || ( EQ_32( total_brate, ACELP_12k85 ) ) || ( EQ_32( total_brate, ACELP_12k15 ) ) || ( EQ_32( total_brate, ACELP_11k60 ) ) ||
( EQ_32( total_brate, ACELP_9k60 ) ) ) &&
- ( GT_16( tilt, 22938 ) ) && /* HF resonnant filter */
- ( ( EQ_16( clas, UNVOICED_CLAS ) ) || ( EQ_16( clas, INACTIVE_CLAS ) ) ) ) ) /* unvoiced classification */
+ ( GT_16( tilt, 22938 ) ) && /* HF resonnant filter */
+ ( ( ( clas == UNVOICED_CLAS ) ) || ( EQ_16( clas, INACTIVE_CLAS ) ) ) ) ) /* unvoiced classification */
{
/*if( enr_q > scaling * enr_old )enr_q = scaling * enr_old;*/
#ifdef BASOP_NOGLOB
@@ -457,6 +458,7 @@ void FEC_scale_syn_fx(
exp2 = 7;
move16();
tmp2 = 160 << 7; /* 160 = 20.0f in Q3 */
+ move16();
exp = sub( exp2, exp );
IF( GT_16( tmp, tmp2 ) )
@@ -474,6 +476,7 @@ void FEC_scale_syn_fx(
test();
test();
test();
+ test();
IF( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) || force_scaling )
{
@@ -538,8 +541,8 @@ void FEC_scale_syn_fx(
/*------------------------------------------------------------*
* voiced->unvoiced transition recovery
*------------------------------------------------------------*/
- ELSE IF( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && ( EQ_16( clas, UNVOICED_CLAS ) || EQ_16( clas, INACTIVE_CLAS ) ) ) || /* voiced->unvoiced transition recovery */
- EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, SID_2k40 ) || EQ_32( last_core_brate, FRAME_NO_DATA ) ) /* CNG -> active signal transition */
+ ELSE IF( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && ( clas == UNVOICED_CLAS || EQ_16( clas, INACTIVE_CLAS ) ) ) || /* voiced->unvoiced transition recovery */
+ EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, SID_2k40 ) || last_core_brate == FRAME_NO_DATA ) /* CNG -> active signal transition */
{
gain1 = gain2;
move16();
diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c
index 454e59ddd3d4d1c9e089575bad50bb03dd558381..02f6293176830b9018a5289d75d72703444ea0aa 100644
--- a/lib_dec/LD_music_post_filter_fx.c
+++ b/lib_dec/LD_music_post_filter_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*-------------------------------------------------------------------*
diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c
index c3224a0998d1adb968a05a4bf0b4a5c22ef40f15..6ef4f65da364e4cd6b7a4f479fb62d64efcb53af 100644
--- a/lib_dec/TonalComponentDetection_fx.c
+++ b/lib_dec/TonalComponentDetection_fx.c
@@ -7,16 +7,12 @@
#include
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
#include "cnst.h"
#include "rom_basop_util.h"
#include "rom_com.h"
#include "basop_util.h"
-#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
-#endif
/*---------------------------------------------------------------------*
diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c
index c0267b47f93660e6582e0dafb32b07ec19550508..75c61452a904df7c8794776453d04d659c2c253d 100644
--- a/lib_dec/acelp_core_dec.c
+++ b/lib_dec/acelp_core_dec.c
@@ -42,8 +42,7 @@
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
-#include "prot_fx2.h"
-#include "prot_fx1.h"
+#include "prot_fx.h"
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "ivas_rom_com.h"
@@ -233,7 +232,11 @@ ivas_error acelp_core_dec(
st->hGSCDec->Last_frame_ener = (float) MAX_32;
}
+#ifdef NON_BE_FIX_807_MASA_DTX_BRSW
+ if ( st->hFdCngDec != NULL && ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) )
+#else
if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) )
+#endif
{
set_zero( st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, FFTLEN );
set_zero( hStereoCng->olapBufferSynth22, FFTLEN );
diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c
index c3cf9be3b05ec2c1dd87855be901d29e1bff9399..c0c0777e4ab587a35bb60c12292f73c078fdd8e6 100644
--- a/lib_dec/acelp_core_dec_fx.c
+++ b/lib_dec/acelp_core_dec_fx.c
@@ -4,10 +4,9 @@
#include
#include
-#include "options.h" /* Compilation switches */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "ivas_prot_fx.h"
#include "ivas_cnst.h" /* Common constants */
#include "cnst.h" /* Common constants */
@@ -265,7 +264,11 @@ ivas_error acelp_core_dec_fx(
move32();
}
#ifdef IVAS_CODE
+#ifdef NON_BE_FIX_807_MASA_DTX_BRSW
+ if ( st->hFdCngDec != NULL && ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) )
+#else
if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) )
+#endif
{
set_zero( st->hFdCngDec->hFdCngCom->olapBufferSynth2, FFTLEN );
set_zero( hStereoCng->olapBufferSynth22, FFTLEN );
@@ -985,7 +988,7 @@ ivas_error acelp_core_dec_fx(
Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, -st_fx->Q_exc );
st_fx->Q_exc = 0;
/* SC-VBR - PPP frames */
- IF( ( error = decod_ppp_fx( st_fx, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st_fx->bfi, gain_buf, voice_factors, bwe_exc_fx ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = decod_ppp_fx( st_fx, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st_fx->bfi, gain_buf, voice_factors, bwe_exc_fx ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1008,7 +1011,7 @@ ivas_error acelp_core_dec_fx(
}
ELSE
{
- IF( ( error = decod_gen_voic_fx( st_fx, st_fx->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf /*, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf*/ ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = decod_gen_voic_fx( st_fx, st_fx->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf /*, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf*/ ) ), IVAS_ERR_OK ) )
{
return error;
}
diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c
index 905db1091f9d46f81613c803a14e11d537251de5..270b9a5bc1f83497177ee107478658d6a2fb8daa 100644
--- a/lib_dec/acelp_core_dec_ivas_fx.c
+++ b/lib_dec/acelp_core_dec_ivas_fx.c
@@ -40,8 +40,7 @@
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "ivas_rom_com.h"
@@ -133,8 +132,6 @@ ivas_error acelp_core_dec_ivas_fx(
Word16 *old_exc_s_fx; /* Start of last excitation frame */
Word16 *p_tdm_Pri_pitch_buf_fx;
Word16 local_element_mode;
- Word16 tmp_e = 0;
- move16();
ivas_error error;
Word32 bpf_error_signal_fx[L_FRAME16k];
@@ -143,7 +140,7 @@ ivas_error acelp_core_dec_ivas_fx(
#endif
Word16 bpf_error_signal_16fx[L_FRAME16k];
#ifdef MSAN_FIX
- set_s( bpf_error_signal_16fx, 0, L_FRAME16k );
+ set16_fx( bpf_error_signal_16fx, 0, L_FRAME16k );
#endif
Word16 tmp;
@@ -158,9 +155,10 @@ ivas_error acelp_core_dec_ivas_fx(
}
push_wmops( "acelp_core_dec" );
- tmp = BASOP_Util_Divide3232_Scale( st->output_Fs, FRAMES_PER_SEC, &tmp_e );
- output_frame = shr( tmp, sub( 15, tmp_e ) );
- // output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC );
+
+ /* output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); */
+ output_frame = extract_l( Mpy_32_32( st->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+
/*----------------------------------------------------------------*
* stereo SID and CNG frames processing
*----------------------------------------------------------------*/
@@ -178,16 +176,24 @@ ivas_error acelp_core_dec_ivas_fx(
FdCng_decodeSID_ivas_fx( st );
rescale_fdCngDec( st->hFdCngDec, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) );
}
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ FOR( i = 0; i < NPART; i++ )
+ {
+ st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ),
+ STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] );
+ move32();
+ }
+#else
FOR( i = 0; i < NPART; i++ )
{
st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = L_add( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ),
Mpy_32_32( STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ) );
move32();
}
-
+#endif
ApplyFdCng_ivas_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 );
- IF( LT_16( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 0 ) )
+ IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 )
{
Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp );
st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0;
@@ -211,8 +217,8 @@ ivas_error acelp_core_dec_ivas_fx(
Copy( lsp_new_fx, st->lsp_old_fx, M );
}
- set_s( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */
- set_s( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */
+ set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */
+ set16_fx( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */
/* CN generation done in DFT domain */
pop_wmops();
@@ -240,7 +246,7 @@ ivas_error acelp_core_dec_ivas_fx(
LSF_Q_prediction = -1;
move16();
- set_s( syn_tmp_fx, 0, L_SUBFR );
+ set16_fx( syn_tmp_fx, 0, L_SUBFR );
psyn_fx = syn_tmp_fx + L_SUBFR;
syn1_tmp_fx[0] = 0;
move16();
@@ -254,7 +260,9 @@ ivas_error acelp_core_dec_ivas_fx(
test();
test();
test();
- IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && st->last_core_brate <= SID_2k40 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->last_core_brate, SID_2k40 ) ) )
+ test();
+ test();
+ IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->last_core_brate, SID_2k40 ) ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->last_core_brate, SID_2k40 ) ) )
{
/* in case of HQ->ACELP switching, do not apply BPF */
st->bpf_off = 1;
@@ -274,6 +282,7 @@ ivas_error acelp_core_dec_ivas_fx(
}
}
+ test();
IF( st->hGSCDec != NULL && ( st->prev_bfi > 0 ) )
{
/* reset the GSC pre echo energy threshold in case of FEC */
@@ -283,10 +292,15 @@ ivas_error acelp_core_dec_ivas_fx(
test();
test();
test();
- IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( EQ_32( st->last_core_brate, SID_2k40 ) || EQ_32( st->last_core_brate, FRAME_NO_DATA ) ) )
+#ifdef NON_BE_FIX_807_MASA_DTX_BRSW
+ test();
+ IF( st->hFdCngDec != NULL && ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( EQ_32( st->last_core_brate, SID_2k40 ) || st->last_core_brate == FRAME_NO_DATA ) )
+#else
+ IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( EQ_32( st->last_core_brate, SID_2k40 ) || st->last_core_brate == FRAME_NO_DATA ) )
+#endif
{
- set_s( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, FFTLEN );
- set_s( hStereoCng->olapBufferSynth22_fx, 0, FFTLEN );
+ set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, FFTLEN );
+ set16_fx( hStereoCng->olapBufferSynth22_fx, 0, FFTLEN );
}
st->clas_dec = st->last_good;
@@ -306,7 +320,7 @@ ivas_error acelp_core_dec_ivas_fx(
}
ELSE
{
- set_s( old_exc2_fx, 0, L_EXC_MEM );
+ set16_fx( old_exc2_fx, 0, L_EXC_MEM );
}
exc2_fx = old_exc2_fx + L_EXC_MEM;
@@ -328,7 +342,7 @@ ivas_error acelp_core_dec_ivas_fx(
move16();
st->relax_prev_lsf_interp = 0;
move16();
- set_s( gain_buf_fx, 0, NB_SUBFR16k );
+ set16_fx( gain_buf_fx, 0, NB_SUBFR16k );
IF( EQ_16( st->L_frame, L_FRAME ) )
{
@@ -354,7 +368,7 @@ ivas_error acelp_core_dec_ivas_fx(
}
test();
/* reset post-filter in case of switching */
- IF( st->hPFstat != NULL && ( st->hPFstat->on == 0 ) )
+ if ( st->hPFstat != NULL && ( st->hPFstat->on == 0 ) )
{
st->hPFstat->reset = 1;
move16();
@@ -364,7 +378,7 @@ ivas_error acelp_core_dec_ivas_fx(
move16();
test();
test();
- IF( st->last_con_tcx && NE_16( st->L_frameTCX_past, st->L_frame ) && ( st->last_core != 0 ) )
+ if ( st->last_con_tcx && NE_16( st->L_frameTCX_past, st->L_frame ) && ( st->last_core != 0 ) )
{
avoid_lpc_burst_on_recovery = 1;
move16();
@@ -388,7 +402,7 @@ ivas_error acelp_core_dec_ivas_fx(
tdm_low_rate_mode = 0;
move16();
test();
- IF( EQ_16( st->element_mode, IVAS_SCE ) && st->low_rate_mode )
+ if ( EQ_16( st->element_mode, IVAS_SCE ) && st->low_rate_mode )
{
tdm_low_rate_mode = 1;
move16();
@@ -403,7 +417,7 @@ ivas_error acelp_core_dec_ivas_fx(
*----------------------------------------------------------------*/
test();
test();
- IF( NE_16( st->last_L_frame, st->L_frame ) && ( EQ_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) ) )
+ IF( NE_16( st->last_L_frame, st->L_frame ) && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) )
{
Word16 dec;
@@ -436,12 +450,12 @@ ivas_error acelp_core_dec_ivas_fx(
{
Copy( GEWB_Ave_fx, st->mem_AR_fx, M );
}
- set_s( st->mem_MA_fx, 0, M );
+ set16_fx( st->mem_MA_fx, 0, M );
/* update synthesis filter memories */
dec = DEC;
move16();
- IF( NE_16( st->element_mode, EVS_MONO ) )
+ if ( st->element_mode != EVS_MONO )
{
dec = DEC_IVAS;
move16();
@@ -487,23 +501,25 @@ ivas_error acelp_core_dec_ivas_fx(
}
ELSE
{
- move16();
Word16 exp = 0;
+ move16();
IF( EQ_16( st->last_L_frame, L_FRAME32k ) )
{
tmpF_fx = 16384;
+ move16();
}
ELSE IF( EQ_16( st->last_L_frame, 512 ) )
{
tmpF_fx = 20480;
+ move16();
}
ELSE /* st->last_L_frame == L_FRAME12k8 */
{
tmpF_fx = 20480; // Q14
+ move16();
exp = 1;
move16();
}
- move16();
FOR( i = 2 * NB_SUBFR - 1; i >= NB_SUBFR; i-- )
{
st->old_pitch_buf_fx[i + 2] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx );
@@ -526,50 +542,56 @@ ivas_error acelp_core_dec_ivas_fx(
{
IF( EQ_16( st->L_frame, L_FRAME ) )
{
- move16();
IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) )
{
tmpF_fx = 13107;
+ move16();
}
ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) )
{
tmpF_fx = 16384;
+ move16();
}
ELSE /* st->bfi_pitch_frame == L_FRAME16k */
{
tmpF_fx = 26214;
+ move16();
}
st->bfi_pitch_fx = mult_r( st->bfi_pitch_fx, tmpF_fx );
+ move16();
st->bfi_pitch_frame = L_FRAME;
move16();
}
ELSE
{
- move16();
Word16 exp = 0;
+ move16();
IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) )
{
tmpF_fx = 16384;
+ move16();
}
ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) )
{
tmpF_fx = 20480;
+ move16();
}
ELSE /* st->bfi_pitch_frame == L_FRAME12k8 */
{
tmpF_fx = 20480; // Q14
+ move16();
exp = 1;
move16();
}
- move16();
st->bfi_pitch_fx = mult_r( shl_sat( st->bfi_pitch_fx, exp ), tmpF_fx );
+ move16();
st->bfi_pitch_frame = L_FRAME16k;
move16();
}
}
test();
test();
- IF( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && ( st->ini_frame != 0 ) )
+ if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && ( st->ini_frame != 0 ) )
{
st->rate_switching_reset = 1;
move16();
@@ -600,13 +622,14 @@ ivas_error acelp_core_dec_ivas_fx(
test();
test();
test();
- IF( GT_16( st->element_mode, EVS_MONO ) && EQ_16( st->idchan, 0 ) && !( EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && !tdm_low_rate_mode )
+ IF( GT_16( st->element_mode, EVS_MONO ) && st->idchan == 0 && !( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && !tdm_low_rate_mode )
{
test();
test();
- IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && LE_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) ) )
+ if ( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && LE_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) ) )
{
st->GSC_IVAS_mode = get_next_indice( st, 2 );
+ move16();
}
}
@@ -614,10 +637,10 @@ ivas_error acelp_core_dec_ivas_fx(
* Decoding of inactive CNG frames
*----------------------------------------------------------------*/
test();
- IF( EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) )
+ IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) )
{
/* decode CNG parameters */
- IF( EQ_16( st->cng_type, LP_CNG ) )
+ IF( st->cng_type == LP_CNG )
{
CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx );
FOR( Word32 nsf = 0; nsf < NB_SUBFR16k; nsf++ )
@@ -633,7 +656,7 @@ ivas_error acelp_core_dec_ivas_fx(
move16();
test();
test();
- IF( ( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st->masa_sid_format, 1 ) )
+ if ( ( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st->masa_sid_format, 1 ) )
{
local_element_mode = IVAS_SCE; /* For DFT Stereo mono decoding, run CNG_exc as in SCE */
move16();
@@ -642,10 +665,11 @@ ivas_error acelp_core_dec_ivas_fx(
}
ELSE
{
-
+ test();
IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp;
+ move16();
FdCng_decodeSID_ivas_fx( st );
rescale_fdCngDec( st->hFdCngDec, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) );
Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) );
@@ -657,23 +681,36 @@ ivas_error acelp_core_dec_ivas_fx(
{
assert( nchan_out == 1 );
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ FOR( i = 0; i < NPART; i++ )
+ {
+ st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ),
+ STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] );
+ move32();
+ }
+#else
FOR( i = 0; i < NPART; i++ )
{
st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = L_add( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ),
Mpy_32_32( STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ) );
move32();
}
+#endif
Word16 new_sidNoiseEstExp = 31 - Q4;
- Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, st->hFdCngDec->hFdCngCom->sidNoiseEstExp - new_sidNoiseEstExp );
- Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, st->hFdCngDec->hFdCngCom->sidNoiseEstExp - new_sidNoiseEstExp );
+ move16();
+ Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) );
+ Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) );
st->hFdCngDec->hFdCngCom->sidNoiseEstExp = new_sidNoiseEstExp;
+ move16();
Word16 new_cngNoiseLevelExp = 31 - Q4;
+ move16();
Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp - new_cngNoiseLevelExp );
st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = new_cngNoiseLevelExp;
+ move16();
ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
- IF( LT_16( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 0 ) )
+ IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 )
{
Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp );
st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0;
@@ -685,7 +722,8 @@ ivas_error acelp_core_dec_ivas_fx(
{
Word32 noise_lvl_highest_fx;
- noise_lvl_highest_fx = st->hFdCngDec->hFdCngCom->cngNoiseLevel[st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand - 1];
+ noise_lvl_highest_fx = st->hFdCngDec->hFdCngCom->cngNoiseLevel[sub( sub( st->hFdCngDec->hFdCngCom->stopFFTbin, st->hFdCngDec->hFdCngCom->startBand ), 1 )];
+ move32();
FOR( Word16 b = st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand; b < st->hFdCngDec->hFdCngCom->stopBand; b++ )
{
st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest_fx;
@@ -693,7 +731,7 @@ ivas_error acelp_core_dec_ivas_fx(
}
}
- generate_comfort_noise_dec_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out );
+ generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out );
FdCng_exc( st->hFdCngDec->hFdCngCom, &st->CNG_mode, st->L_frame, st->lsp_old_fx, st->first_CNG, st->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
@@ -821,7 +859,7 @@ ivas_error acelp_core_dec_ivas_fx(
test();
test();
test();
- IF( st->hTdCngDec != NULL && ( EQ_32( st->last_core_brate, FRAME_NO_DATA ) || EQ_32( st->last_core_brate, SID_2k40 ) ) )
+ IF( st->hTdCngDec != NULL && ( st->last_core_brate == FRAME_NO_DATA || EQ_32( st->last_core_brate, SID_2k40 ) ) )
{
Copy( st->lspCNG_fx, st->lsp_old_fx, M );
lsp2lsf_fx( st->lspCNG_fx, st->lsf_old_fx, M, int_fs );
@@ -834,10 +872,10 @@ ivas_error acelp_core_dec_ivas_fx(
IF( !st->use_acelp_preq )
{
st->mem_preemp_preQ_fx = 0;
- st->last_nq_preQ = 0;
- st->last_code_preq = 0;
move16();
+ st->last_nq_preQ = 0;
move16();
+ st->last_code_preq = 0;
move16();
}
st->use_acelp_preq = 0;
@@ -879,12 +917,10 @@ ivas_error acelp_core_dec_ivas_fx(
}
pt_interp_2_fx = interpol_frac_fx;
- move16();
test();
- IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( st->coder_type, UNVOICED ) )
+ if ( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( st->coder_type, UNVOICED ) )
{
pt_interp_2_fx = interpol_frac2_fx;
- move16();
}
IF( EQ_16( st->active_cnt, 1 ) )
@@ -897,1096 +933,1039 @@ ivas_error acelp_core_dec_ivas_fx(
int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new_fx, Aq_fx, M, pt_interp_2_fx, 0 );
/* Check LSF stability (distance between old LSFs and current LSFs) */
st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame );
+ move16();
}
#ifndef MSAN_FIX
for ( int nsf = 0; nsf < NB_SUBFR16k; nsf++ )
- {
#else
FOR( Word32 nsf = 0; nsf < st->nb_subfr; nsf++ )
#endif
- {
- Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, add( M, 1 ) )] ), Q2 ) );
- Aq_fx[imult3216( nsf, add( M, 1 ) )] = ONE_IN_Q12;
- move16();
- }
- test();
- IF( EQ_16( st->last_core, HQ_CORE ) && GT_16( st->element_mode, EVS_MONO ) )
- {
- /* Prepare ACB memory from last HQ frame */
- old_exc_s_fx = st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame;
- tmpF_fx = *old_exc_s_fx;
- st->mem_deemph_fx = old_exc_s_fx[st->L_frame - 1];
- preemph_fx( old_exc_s_fx, st->preemph_fac, L_FRAME16k, &tmpF_fx );
- Copy( old_exc_s_fx + st->L_frame - M, st->mem_syn2_fx, M );
- Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, 0 );
+ {
+ Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, M + 1 )] ), Q2 ) );
+ Aq_fx[imult3216( nsf, M + 1 )] = ONE_IN_Q12;
+ move16();
+ }
+ test();
+ IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory from last HQ frame */
+ old_exc_s_fx = st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame;
+ tmpF_fx = *old_exc_s_fx;
+ st->mem_deemph_fx = old_exc_s_fx[sub( st->L_frame, 1 )];
+ move16();
+ preemph_fx( old_exc_s_fx, st->preemph_fac, L_FRAME16k, &tmpF_fx );
+ Copy( old_exc_s_fx + st->L_frame - M, st->mem_syn2_fx, M );
+ Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, 0 );
#ifdef FIX_737_HQ_ACELP_SWITCH_SCALING_ERROR
- Scale_sig( old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, st->Q_exc );
+ Scale_sig( old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, st->Q_exc );
#endif
+ }
+ 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 );
}
- test();
- IF( NE_16( st->last_core, ACELP_CORE ) && GT_16( st->element_mode, EVS_MONO ) )
+ ELSE
{
- /* 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, shl( L_EXC_MEM_DEC, 1 ), L_EXC_MEM_DEC );
- }
+ lerp( old_exc_fx, old_bwe_exc_fx, shl( L_EXC_MEM_DEC, 1 ), L_EXC_MEM_DEC );
}
+ }
- /*-----------------------------------------------------------------*
- * FEC - first good frame after lost frame(s) (possibility to correct the ACB)
- *-----------------------------------------------------------------*/
+ /*-----------------------------------------------------------------*
+ * FEC - first good frame after lost frame(s) (possibility to correct the ACB)
+ *-----------------------------------------------------------------*/
- IF( st->acelp_cfg.FEC_mode > 0 )
+ IF( st->acelp_cfg.FEC_mode > 0 )
+ {
+ last_pulse_pos = 0;
+ move16();
+ /* decode the last glottal pulse position */
+ T0_tmp = FEC_pos_dec_fx( st, &last_pulse_pos, &enr_q_fx, nb_bits );
+ test();
+ test();
+ IF( NE_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, HQ_CORE ) && st->last_con_tcx ) )
{
- last_pulse_pos = 0;
- move16();
- /* decode the last glottal pulse position */
- T0_tmp = FEC_pos_dec_fx( st, &last_pulse_pos, &enr_q_fx, nb_bits );
test();
test();
- IF( NE_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, HQ_CORE ) && st->last_con_tcx ) )
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( st->clas_dec, SIN_ONSET ) && last_pulse_pos != 0 && EQ_16( st->prev_bfi, 1 ) )
{
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st->clas_dec, SIN_ONSET ) && NE_16( last_pulse_pos, 0 ) && EQ_16( st->prev_bfi, 1 ) )
- {
- FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st->L_frame, st->Q_exc );
- }
- ELSE IF( ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) ) && NE_16( last_pulse_pos, 0 ) && EQ_16( st->old_bfi_cnt, 1 ) && st->hWIDec != NULL )
- {
- do_WI = FEC_enhACB_fx( st->L_frame, st->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch_fx );
- }
+ FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st->L_frame, st->Q_exc );
+ }
+ ELSE IF( ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) ) && last_pulse_pos != 0 && EQ_16( st->old_bfi_cnt, 1 ) && st->hWIDec != NULL )
+ {
+ do_WI = FEC_enhACB_fx( st->L_frame, st->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch_fx );
}
}
+ }
- /*------------------------------------------------------------*
- * In case of first frame after an erasure and transition from voiced to unvoiced or inactive
- * redo the LPC interpolation
- *------------------------------------------------------------*/
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( st->stab_fac_fx == 0 ) && ( st->old_bfi_cnt > 0 ) && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && ( st->relax_prev_lsf_interp == 0 ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) )
- {
- int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 );
- }
+ /*------------------------------------------------------------*
+ * In case of first frame after an erasure and transition from voiced to unvoiced or inactive
+ * redo the LPC interpolation
+ *------------------------------------------------------------*/
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( st->stab_fac_fx == 0 ) && ( st->old_bfi_cnt > 0 ) && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && ( st->relax_prev_lsf_interp == 0 ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) )
+ {
+ int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 );
+ }
+
+ /*---------------------------------------------------------------*
+ * Decoding of the scaled predicted innovation energy
+ *---------------------------------------------------------------*/
- /*---------------------------------------------------------------*
- * Decoding of the scaled predicted innovation energy
- *---------------------------------------------------------------*/
+ IF( nb_bits > 0 )
+ {
+ indice = get_next_indice( st, nb_bits );
+ Es_pred_dec_fx( &Es_pred_fx, indice, nb_bits, uc_two_stage_flag );
+ }
- IF( GT_16( nb_bits, 0 ) )
+ /*------------------------------------------------------------*
+ * Decode excitation according to coding type
+ *------------------------------------------------------------*/
+ test();
+ test();
+ IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */
+ {
+ IF( LE_16( st->coder_type, UNVOICED ) )
{
- indice = get_next_indice( st, nb_bits );
- Es_pred_dec_fx( &Es_pred_fx, indice, nb_bits, uc_two_stage_flag );
+ tdm_low_rate_dec_fx( st, dct_exc_tmp_fx /*, &tmp_noise*/, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx );
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
}
-
- /*------------------------------------------------------------*
- * Decode excitation according to coding type
- *------------------------------------------------------------*/
- test();
- test();
- IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */
+ ELSE /* GENERIC */
{
- IF( LE_16( st->coder_type, UNVOICED ) )
+ decod_gen_2sbfr_ivas_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx );
+
+ if ( EQ_16( st->element_mode, IVAS_CPE_TD ) )
{
- tdm_low_rate_dec_fx( st, dct_exc_tmp_fx /*, &tmp_noise*/, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx );
tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
}
- ELSE /* GENERIC */
- {
- decod_gen_2sbfr_ivas_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx );
-
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- }
- }
- }
- ELSE IF( st->nelp_mode_dec )
- {
- /* SC-VBR - NELP frames */
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, -st->Q_exc );
- st->Q_exc = 0;
- move16();
- /* SC-VBR - NELP frames */
- decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx );
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
}
- ELSE IF( EQ_16( st->coder_type, UNVOICED ) )
+ }
+ ELSE IF( st->nelp_mode_dec )
+ {
+ /* SC-VBR - NELP frames */
+ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) );
+ st->Q_exc = 0;
+ move16();
+ /* SC-VBR - NELP frames */
+ decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx );
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
+ }
+ ELSE IF( EQ_16( st->coder_type, UNVOICED ) )
+ {
+ /* UNVOICED frames */
+ decod_unvoiced_ivas_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx );
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
+ }
+ ELSE IF( st->ppp_mode_dec )
+ {
+ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) );
+ st->Q_exc = 0;
+ move16();
+ /* SC-VBR - PPP frames */
+ IF( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ) != IVAS_ERR_OK )
{
- /* UNVOICED frames */
- decod_unvoiced_ivas_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx );
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
+ return error;
}
- ELSE IF( st->ppp_mode_dec )
- {
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, -st->Q_exc );
- st->Q_exc = 0;
- move16();
- /* SC-VBR - PPP frames */
- IF( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ) != IVAS_ERR_OK )
- {
- return error;
- }
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
- }
- ELSE IF( EQ_16( st->coder_type, TRANSITION ) )
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
+ }
+ ELSE IF( EQ_16( st->coder_type, TRANSITION ) )
+ {
+ decod_tran_fx( st, st->L_frame, tc_subfr, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf_fx );
+ }
+ ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && st->inactive_coder_type_flag ) )
+ {
+ /* AUDIO and INACTIVE frames (coded by GSC technology) */
+ decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx
+#if 1 // def ADD_LRTD
+ ,
+ tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx
+#endif
+ );
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
+ }
+ ELSE
+ {
+ /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
+ IF( ( error = decod_gen_voic_ivas_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ) ) != IVAS_ERR_OK )
{
- decod_tran_fx( st, st->L_frame, tc_subfr, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf_fx );
+ return error;
}
- ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && st->inactive_coder_type_flag ) )
+
+ if ( EQ_16( st->element_mode, IVAS_CPE_TD ) )
{
- /* AUDIO and INACTIVE frames (coded by GSC technology) */
- decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx
-#if 1 // def ADD_LRTD
- ,
- tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx
-#endif
- );
tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
}
- ELSE
- {
- /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
- IF( ( error = decod_gen_voic_ivas_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ) ) != IVAS_ERR_OK )
- {
- return error;
- }
+ }
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- }
- }
+ /* synthesis for ACELP core switching and SWB BWE */
+ syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 );
- /* synthesis for ACELP core switching and SWB BWE */
- syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 );
+ /* save and delay synthesis to be used by SWB BWE */
+ IF( st->hBWE_FD != NULL )
+ {
+ save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
+ }
- /* save and delay synthesis to be used by SWB BWE */
- IF( st->hBWE_FD != NULL )
- {
- save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
- }
+ /*-----------------------------------------------------------------*
+ * Apply energy matching when switching to inactive frames
+ *-----------------------------------------------------------------*/
+
+ Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->L_frame, st->total_brate, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
- /*-----------------------------------------------------------------*
- * Apply energy matching when switching to inactive frames
- *-----------------------------------------------------------------*/
+ /*------------------------------------------------------------*
+ * Decode information and modify the excitation signal of stationary unvoiced frames
+ *------------------------------------------------------------*/
+ test();
+ test();
+ test();
+ test();
+ IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( st->nelp_mode_dec, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
+ {
+ stat_noise_uv_dec_fx( st, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag );
+ }
- Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->L_frame, st->total_brate, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
+ /*------------------------------------------------------------*
+ * Save filter memory in case the synthesis is redone after scaling
+ * Synthesis at 12k8 Hz sampling rate
+ *------------------------------------------------------------*/
- /*------------------------------------------------------------*
- * Decode information and modify the excitation signal of stationary unvoiced frames
- *------------------------------------------------------------*/
- test();
+ /* update past excitation signals for LD music post-filter */
+ IF( st->hMusicPF != NULL )
+ {
+ Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
+ Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+ Copy( st->hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 );
+ }
+
+ test();
+ test();
+ test();
+ IF( ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && EQ_16( st->L_frame, L_FRAME ) ) )
+ {
+ Word16 last_coder_type = st->last_coder_type;
+ move16();
test();
test();
test();
- IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( st->nelp_mode_dec, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
+ if ( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && ( st->GSC_noisy_speech == 0 ) ) )
{
- stat_noise_uv_dec_fx( st, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag );
+ last_coder_type = AUDIO;
+ move16();
}
- /*------------------------------------------------------------*
- * Save filter memory in case the synthesis is redone after scaling
- * Synthesis at 12k8 Hz sampling rate
- *------------------------------------------------------------*/
+ Word16 qdct = 0;
+ move16();
+ /* Extrapolation of the last future part, windowing and high resolution DCT transform */
+ Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct );
+
+ /* LD music post-filter */
+ LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct );
- /* update past excitation signals for LD music post-filter */
- IF( st->hMusicPF != NULL )
+ /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */
+ Copy( st->mem_syn2_fx, mem_tmp_fx, M );
+ Post_music_postP_fx( dct_buffer_fx, exc2_fx, st->mem_syn2_fx, st->mem_syn2_fx, Aq_fx, psyn_fx, &st->Q_exc, &st->prev_Q_syn,
+ &st->Q_syn, st->mem_syn_clas_estim_fx, 0, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx,
+ &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, temp_buf_fx, mem_tmp_fx );
+ }
+ ELSE
+ {
+ /* Core synthesis at 12.8kHz or 16kHz */
+ i = 1;
+ move16();
+ if ( st->coder_type == INACTIVE )
{
- Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, sub( sub( DCT_L_POST, L_FRAME ), OFFSET2 ) );
- Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
- Copy( st->hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, sub( DCT_L_POST, OFFSET2 ) );
+ i = 0;
+ move16();
}
+ /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */
+ Word16 k = 0;
+ move16();
test();
test();
- test();
-
- IF( ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && EQ_16( st->L_frame, L_FRAME ) ) )
+ if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) )
{
- Word16 last_coder_type = st->last_coder_type;
+ k = 1;
move16();
- test();
- test();
- test();
- IF( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && ( st->GSC_noisy_speech == 0 ) ) )
- {
- last_coder_type = AUDIO;
- move16();
- }
+ }
- Word16 qdct = 0;
- move16();
- /* Extrapolation of the last future part, windowing and high resolution DCT transform */
- Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct );
+ Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx,
+ st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, i, k, temp_buf_fx );
- /* LD music post-filter */
- LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct );
+ Copy( st->mem_syn2_fx, mem_tmp_fx, M );
+ syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
- /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */
- Copy( st->mem_syn2_fx, mem_tmp_fx, M );
- Post_music_postP_fx( dct_buffer_fx, exc2_fx, st->mem_syn2_fx, st->mem_syn2_fx, Aq_fx, psyn_fx, &st->Q_exc, &st->prev_Q_syn,
- &st->Q_syn, st->mem_syn_clas_estim_fx, 0, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx,
- &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, temp_buf_fx, mem_tmp_fx );
- }
- ELSE
+ IF( st->hMusicPF != NULL )
{
- /* Core synthesis at 12.8kHz or 16kHz */
- i = 1;
- move16();
- if ( EQ_16( st->coder_type, INACTIVE ) )
- {
- i = 0;
- move16();
- }
- /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */
- Word16 k = 0;
- move16();
- test();
- test();
- IF( EQ_16( st->coder_type, INACTIVE ) && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) )
+ FOR( i = 0; i < DCT_L_POST; i++ )
{
- k = 1;
+ st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) );
move16();
}
+ }
+ }
- Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx,
- st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, i, k, temp_buf_fx );
+ /*------------------------------------------------------------*
+ * FEC - Estimate the classification information
+ *------------------------------------------------------------*/
- Copy( st->mem_syn2_fx, mem_tmp_fx, M );
- syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
+ FEC_clas_estim_fx( st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx,
+ psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst,
+ NULL, NULL, NULL, NULL, 0, NULL, st->core_brate, st->Q_syn, temp_buf_fx,
+ st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn,
+ 0, 0, 0, st->last_core_brate, st->acelp_cfg.FEC_mode );
+ /*------------------------------------------------------------*
+ * FEC - Estimate pitch
+ *------------------------------------------------------------*/
- IF( st->hMusicPF != NULL )
- {
- FOR( i = 0; i < DCT_L_POST; i++ )
- {
- st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) );
- }
- }
- }
-
- /*------------------------------------------------------------*
- * FEC - Estimate the classification information
- *------------------------------------------------------------*/
-
- FEC_clas_estim_fx( st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx,
- psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst,
- NULL, NULL, NULL, NULL, 0, NULL, st->core_brate, st->Q_syn, temp_buf_fx,
- st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn,
- 0, 0, 0, st->last_core_brate, st->acelp_cfg.FEC_mode );
- /*------------------------------------------------------------*
- * FEC - Estimate pitch
- *------------------------------------------------------------*/
-
- FEC_pitch_estim_fx( st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good, pitch_buf_fx, st->old_pitch_buf_fx,
- &st->bfi_pitch_fx, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type, st->element_mode );
-
- /*------------------------------------------------------------*
- * FEC - Smooth the speech energy evolution when recovering after a BAD frame
- * (smoothing is performed in the excitation domain and signal is resynthesized after)
- *------------------------------------------------------------*/
-
- move16();
- Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6 );
- FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
- &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
- exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 );
- test();
- test();
- test();
- /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
- IF( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && LE_32( st->total_brate, ACELP_7k20 ) ) || EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
- {
- frame_ener_fx( st->L_frame, st->clas_dec, psyn_fx, pitch_buf_tmp[sub( shr( st->L_frame, 6 ), 1 )], &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 );
- }
- }
+ FEC_pitch_estim_fx( st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good, pitch_buf_fx, st->old_pitch_buf_fx,
+ &st->bfi_pitch_fx, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type, st->element_mode );
- } /* End of GOOD FRAME */
-
- /*----------------------------------------------------------------*
- * BAD frame
- *----------------------------------------------------------------*/
+ /*------------------------------------------------------------*
+ * FEC - Smooth the speech energy evolution when recovering after a BAD frame
+ * (smoothing is performed in the excitation domain and signal is resynthesized after)
+ *------------------------------------------------------------*/
- ELSE
- {
- /* SC-VBR */
- if ( EQ_16( st->last_nelp_mode_dec, 1 ) )
- {
- st->nelp_mode_dec = 1;
- move16();
- }
+ move16();
+ Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6 );
+ FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
+ &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
+ exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 );
+ test();
test();
test();
test();
- /* long burst frame erasures */
- IF( GT_16( st->nbLostCmpt, 5 ) && GE_16( st->clas_dec, VOICED_CLAS ) && LT_16( st->clas_dec, INACTIVE_CLAS ) )
+ /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
+ IF( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && LE_32( st->total_brate, ACELP_7k20 ) ) || EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
{
- st->last_good = VOICED_TRANSITION;
- move16();
+ frame_ener_fx( st->L_frame, st->clas_dec, psyn_fx, pitch_buf_tmp[sub( shr( st->L_frame, 6 ), 1 )], &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 );
}
+ }
+
+ } /* End of GOOD FRAME */
- /* LSF estimation and A(z) calculation */
- lsf_dec_bfi( MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, 0, st->bwidth );
+ /*----------------------------------------------------------------*
+ * BAD frame
+ *----------------------------------------------------------------*/
- FEC_lsf2lsp_interp( st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx );
+ ELSE
+ {
+ /* SC-VBR */
+ if ( EQ_16( st->last_nelp_mode_dec, 1 ) )
+ {
+ st->nelp_mode_dec = 1;
+ move16();
+ }
+ test();
+ test();
+ /* long burst frame erasures */
+ if ( GT_16( st->nbLostCmpt, 5 ) && GE_16( st->clas_dec, VOICED_CLAS ) && LT_16( st->clas_dec, INACTIVE_CLAS ) )
+ {
+ st->last_good = VOICED_TRANSITION;
+ move16();
+ }
+
+ /* LSF estimation and A(z) calculation */
+ lsf_dec_bfi( MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, 0, st->bwidth );
+
+ FEC_lsf2lsp_interp( st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx );
#ifndef MSAN_FIX
- for ( int nsf = 0; nsf < NB_SUBFR16k; nsf++ )
- {
+ for ( int nsf = 0; nsf < NB_SUBFR16k; nsf++ )
+ {
#else
FOR( Word32 nsf = 0; nsf < st->nb_subfr; nsf++ )
{
#endif
- Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, add( M, 1 ) )] ), Q2 ) );
- Aq_fx[imult3216( nsf, add( M, 1 ) )] = ONE_IN_Q12;
- move16();
- }
- IF( EQ_16( st->nelp_mode_dec, 1 ) )
- {
- /* SC-VBR */
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, -st->Q_exc );
- st->Q_exc = 0;
- move16();
-
- decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx );
- FEC_pitch_fx = pitch_buf_fx[3];
- move16();
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
- }
- ELSE
- {
- /* calculation of excitation signal */
- FEC_exc_estim_fx( st, st->L_frame, exc_fx, exc2_fx, dct_exc_tmp_fx, pitch_buf_fx, voice_factors_fx, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st->Q_exc, &tmp_noise_fx );
+ Scale_sig( Aq_fx + ( nsf * ( M + 1 ) ), M + 1, sub( norm_s( Aq_fx[imult3216( nsf, M + 1 )] ), Q2 ) );
+ Aq_fx[imult3216( nsf, M + 1 )] = ONE_IN_Q12;
+ move16();
+ }
+ IF( EQ_16( st->nelp_mode_dec, 1 ) )
+ {
+ /* SC-VBR */
+ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) );
+ st->Q_exc = 0;
+ move16();
- Rescale_exc( NULL, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, L_FRAME32k, (Word32) 0,
- &( st->Q_exc ), st->Q_subfr, exc2_fx, st->L_frame, st->last_coder_type );
+ decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx );
+ FEC_pitch_fx = pitch_buf_fx[3];
+ move16();
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
+ }
+ ELSE
+ {
+ /* calculation of excitation signal */
+ FEC_exc_estim_fx( st, st->L_frame, exc_fx, exc2_fx, dct_exc_tmp_fx, pitch_buf_fx, voice_factors_fx, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st->Q_exc, &tmp_noise_fx );
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
+ Rescale_exc( NULL, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, L_FRAME32k, (Word32) 0,
+ &( st->Q_exc ), st->Q_subfr, exc2_fx, st->L_frame, st->last_coder_type );
- /* SC-VBR */
- st->prev_gain_pit_dec_fx = st->lp_gainp_fx;
- move16();
- }
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- /* synthesis for ACELP core switching and SWB BWE */
- syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 );
+ /* SC-VBR */
+ st->prev_gain_pit_dec_fx = st->lp_gainp_fx;
+ move16();
+ }
- /* save and delay synthesis to be used by SWB BWE */
- IF( st->hBWE_FD != NULL )
- {
- save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
- }
+ /* synthesis for ACELP core switching and SWB BWE */
+ syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 );
- /* Apply energy matching when switching to inactive frames */
- Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->L_frame, st->total_brate, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
+ /* save and delay synthesis to be used by SWB BWE */
+ IF( st->hBWE_FD != NULL )
+ {
+ save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
+ }
- /* update past excitation signals for LD music post-filter */
- IF( st->hMusicPF != NULL )
- {
- Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+ /* Apply energy matching when switching to inactive frames */
+ Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->L_frame, st->total_brate, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
- /* Update music post processing values */
- /* Filter energies update */
- FOR( i = 0; i < DCT_L_POST; i++ )
- {
- st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( L_shl( 1228, ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) );
- move16();
- }
- /* Update circular buffer, keep last energy difference unchanged */
- FOR( i = 1; i < MAX_LT; i++ )
- {
- st->hMusicPF->LDm_lt_diff_etot_fx[i - 1] = st->hMusicPF->LDm_lt_diff_etot_fx[i];
- move16();
- }
- }
+ /* update past excitation signals for LD music post-filter */
+ IF( st->hMusicPF != NULL )
+ {
+ Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
+ Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
- /* synthesis at 12k8 Hz sampling rate */
- /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */
- Word16 k = 0;
- move16();
- test();
- test();
- IF( EQ_16( st->coder_type, INACTIVE ) && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) )
+ /* Update music post processing values */
+ /* Filter energies update */
+ FOR( i = 0; i < DCT_L_POST; i++ )
{
- k = 1;
+ st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( L_shl( 1228, ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) );
move16();
}
-
- Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx,
- st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 1, k, temp_buf_fx );
- test();
- IF( ( st->total_brate == ACELP_7k20 ) || ( st->total_brate == ACELP_8k00 ) )
+ /* Update circular buffer, keep last energy difference unchanged */
+ FOR( i = 1; i < MAX_LT; i++ )
{
- Copy( st->mem_syn2_fx, mem_tmp_fx, M );
+ st->hMusicPF->LDm_lt_diff_etot_fx[i - 1] = st->hMusicPF->LDm_lt_diff_etot_fx[i];
+ move16();
}
- syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
+ }
- /* update buffer for classifier */
- IF( st->hWIDec != NULL )
- {
- Copy( exc2_fx + st->L_frame - L_EXC_MEM, st->hWIDec->old_exc2_fx, L_EXC_MEM );
- Copy( psyn_fx + st->L_frame - L_EXC_MEM, st->hWIDec->old_syn2_fx, L_EXC_MEM );
- }
- st->prev_Q_exc_fr = st->Q_exc;
- st->prev_Q_syn_fr = st->Q_syn;
- move16();
+ /* synthesis at 12k8 Hz sampling rate */
+ /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */
+ Word16 k = 0;
+ move16();
+ test();
+ test();
+ if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) )
+ {
+ k = 1;
move16();
- Copy( psyn_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
+ }
- /*------------------------------------------------------------*
- * FEC - Smooth the speech energy evolution when recovering after a BAD frame
- * (smoothing is performed in the excitation domain and signal is resynthesized after)
- *------------------------------------------------------------*/
- test();
- IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
- {
- Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6 );
+ Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx,
+ st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 1, k, temp_buf_fx );
+ test();
+ IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
+ {
+ Copy( st->mem_syn2_fx, mem_tmp_fx, M );
+ }
+ syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
- FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
- &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
- exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 );
- }
+ /* update buffer for classifier */
+ IF( st->hWIDec != NULL )
+ {
+ Copy( exc2_fx + st->L_frame - L_EXC_MEM, st->hWIDec->old_exc2_fx, L_EXC_MEM );
+ Copy( psyn_fx + st->L_frame - L_EXC_MEM, st->hWIDec->old_syn2_fx, L_EXC_MEM );
+ }
+ st->prev_Q_exc_fr = st->Q_exc;
+ move16();
+ st->prev_Q_syn_fr = st->Q_syn;
+ move16();
+ Copy( psyn_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
- /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
- frame_ener_fx( st->L_frame, st->last_good, psyn_fx, shr( add( FEC_pitch_fx, 32 ), 6 ), &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 );
+ /*------------------------------------------------------------*
+ * FEC - Smooth the speech energy evolution when recovering after a BAD frame
+ * (smoothing is performed in the excitation domain and signal is resynthesized after)
+ *------------------------------------------------------------*/
+ test();
+ IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
+ {
+ Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6 );
- IF( NE_16( st->nelp_mode_dec, 1 ) )
- {
- /* modify the excitation signal of stationary unvoiced frames */
- stat_noise_uv_mod_fx( st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx,
- &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx,
- &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge );
- }
+ FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
+ &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
+ exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 );
}
- IF( st->hBWE_TD != NULL )
+ /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
+ frame_ener_fx( st->L_frame, st->last_good, psyn_fx, shr( add( FEC_pitch_fx, 32 ), 6 ), &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 );
+
+ IF( NE_16( st->nelp_mode_dec, 1 ) )
{
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- Copy( Aq_fx + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
- }
- ELSE
- {
- Copy( Aq_fx + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
- }
+ /* modify the excitation signal of stationary unvoiced frames */
+ stat_noise_uv_mod_fx( st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx,
+ &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx,
+ &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge );
}
+ }
- /*--------------------------------------------------------*
- * Apply NB postfilter in case of 8kHz output
- *--------------------------------------------------------*/
- test();
- IF( EQ_16( st->last_bwidth, NB ) && st->hPFstat != NULL )
+ IF( st->hBWE_TD != NULL )
+ {
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
- Copy( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k );
- IF( EQ_16( st->bwidth, NB ) )
- {
- st->hPFstat->on = 1;
- move16();
- nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0 );
- }
- ELSE
- {
- st->hPFstat->on = 0;
- move16();
- nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st->BER_detect, 0 );
- }
+ Copy( Aq_fx + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
}
ELSE
{
- st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) );
+ Copy( Aq_fx + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
}
+ }
- /*------------------------------------------------------------------*
- * Perform fixed deemphasis through 1/(1 - g*z^-1)
- *-----------------------------------------------------------------*/
-
- /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( psyn_fx + st->L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM );
- deemph_fx( psyn_fx, st->preemph_fac, st->L_frame, &( st->mem_deemph_fx ) );
- unscale_AGC( psyn_fx, st->Q_syn, syn_fx_tmp2, st->agc_mem_fx, st->L_frame );
- Copy( syn_fx_tmp2, psyn_fx, st->L_frame );
- IF( st->hTcxDec != NULL )
+ /*--------------------------------------------------------*
+ * Apply NB postfilter in case of 8kHz output
+ *--------------------------------------------------------*/
+ test();
+ IF( EQ_16( st->last_bwidth, NB ) && st->hPFstat != NULL )
+ {
+ Copy( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k );
+ IF( EQ_16( st->bwidth, NB ) )
{
- Copy_Scale_sig( psyn_fx + st->L_frame / 2, st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/
+ st->hPFstat->on = 1;
+ move16();
+ nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0 );
}
- Copy_Scale_sig( psyn_fx + st->L_frame - M - 1, st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/
-
- /*------------------------------------------------------------------*
- * Formant post-filter
- *-----------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) && ( GT_32( st->core_brate, ACELP_24k40 ) || GT_16( st->element_mode, EVS_MONO ) ) && LE_32( st->core_brate, ACELP_32k ) )
+ ELSE
{
- st->hPFstat->on = 1;
+ st->hPFstat->on = 0;
move16();
- /*----ftf conversions---*/
- Copy( psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k );
+ nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st->BER_detect, 0 );
+ }
+ }
+ ELSE
+ {
+ st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) );
+ move16();
+ }
- set16_fx( st->hPFstat->mem_zero, 0, M );
+ /*------------------------------------------------------------------*
+ * Perform fixed deemphasis through 1/(1 - g*z^-1)
+ *-----------------------------------------------------------------*/
- formant_post_filt_ivas_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 );
- }
- ELSE IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) )
- {
- IF( st->hPFstat->on )
- {
+ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
+ Copy( psyn_fx + st->L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM );
+ deemph_fx( psyn_fx, st->preemph_fac, st->L_frame, &( st->mem_deemph_fx ) );
+ unscale_AGC( psyn_fx, st->Q_syn, syn_fx_tmp2, st->agc_mem_fx, st->L_frame );
+ Copy( syn_fx_tmp2, psyn_fx, st->L_frame );
+ IF( st->hTcxDec != NULL )
+ {
+ Copy_Scale_sig( psyn_fx + st->L_frame / 2, st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/
+ }
+ Copy_Scale_sig( psyn_fx + st->L_frame - M - 1, st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/
- Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf_fx, M );
- Copy( psyn_fx, temp_buf_fx + M, L_SUBFR );
+ /*------------------------------------------------------------------*
+ * Formant post-filter
+ *-----------------------------------------------------------------*/
- Residu3_fx( Aq_fx, temp_buf_fx + M, temp_buf_fx + M + L_SUBFR, L_SUBFR, 1 );
- E_UTIL_synthesis( 1, Aq_fx, temp_buf_fx + M + L_SUBFR, temp_buf_fx, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M );
- scale_st_fx( psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR );
- Copy( temp_buf_fx, psyn_fx, ( L_SUBFR >> 1 ) );
- blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2 );
- }
- st->hPFstat->on = 0;
- move16();
+ test();
+ test();
+ test();
+ test();
+ IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) && ( GT_32( st->core_brate, ACELP_24k40 ) || st->element_mode > EVS_MONO ) && LE_32( st->core_brate, ACELP_32k ) )
+ {
+ st->hPFstat->on = 1;
+ move16();
+ /*----ftf conversions---*/
+ Copy( psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k );
+
+ set16_fx( st->hPFstat->mem_zero, 0, M );
+
+ formant_post_filt_ivas_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 );
+ }
+ ELSE IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) )
+ {
+ IF( st->hPFstat->on )
+ {
+ Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf_fx, M );
+ Copy( psyn_fx, temp_buf_fx + M, L_SUBFR );
+
+ Residu3_fx( Aq_fx, temp_buf_fx + M, temp_buf_fx + M + L_SUBFR, L_SUBFR, 1 );
+ E_UTIL_synthesis( 1, Aq_fx, temp_buf_fx + M + L_SUBFR, temp_buf_fx, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M );
+ scale_st_fx( psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR );
+ Copy( temp_buf_fx, psyn_fx, ( L_SUBFR >> 1 ) );
+ blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2 );
}
+ st->hPFstat->on = 0;
+ move16();
+ }
- /*----------------------------------------------------------------*
- * Comfort noise addition
- *----------------------------------------------------------------*/
+ /*----------------------------------------------------------------*
+ * Comfort noise addition
+ *----------------------------------------------------------------*/
+ test();
+ test();
+ IF( ( st->hFdCngDec != NULL || EQ_16( st->idchan, 1 ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+ test();
test();
test();
- IF( ( st->hFdCngDec != NULL || EQ_16( st->idchan, 1 ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
+ test();
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) )
{
+ /*VAD only for non inactive frame*/
+ st->VAD = st->VAD && st->coder_type != INACTIVE;
test();
test();
test();
test();
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( EQ_16( st->cng_type, LP_CNG ) && LE_32( st->core_brate, SID_2k40 ) ) )
+ test();
+ IF( st->idchan == 0 && ( st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) ) )
{
- /*VAD only for non inactive frame*/
- st->VAD = st->VAD && NE_16( st->coder_type, INACTIVE );
- test();
- test();
- test();
- test();
- IF( EQ_16( st->idchan, 0 ) && ( st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( EQ_16( st->cng_type, LP_CNG ) && LE_32( st->core_brate, SID_2k40 ) ) ) )
- {
- /*Noisy speech detector*/
- noisy_speech_detection_fx( st->hFdCngDec, st->VAD, psyn_fx, st->Q_syn );
+ /*Noisy speech detector*/
+ noisy_speech_detection_fx( st->hFdCngDec, st->VAD, psyn_fx, st->Q_syn );
- st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ );
- IF( NE_16( st->hFdCngDec->hFdCngCom->flag_noisy_speech, 0 ) )
- {
- st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ );
- move16();
- }
- st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = L_deposit_h( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech );
+ st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ );
+ move16();
+ IF( st->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 )
+ {
+ st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ );
+ move16();
}
+ st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = L_deposit_h( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech );
+ move32();
+ }
+
+ if ( st->idchan == 0 )
+ {
+ st->lp_noise = st->hFdCngDec->lp_noise;
+ move32();
+ }
+ test();
+ IF( NE_16( st->element_mode, IVAS_CPE_TD ) && !st->cng_ism_flag )
+ {
+ /*Noise estimate*/
- if ( st->idchan == 0 )
+ Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, sub( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, Q27 ) );
+ st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 31 - Q4; // Q4
+ move16();
+
+ Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, Q27 ) );
+ Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, Q27 ) );
+ st->hFdCngDec->hFdCngCom->sidNoiseEstExp = 31 - Q4; // Q4
+ move16();
+ /*==========================================================*/
+ ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
+ /*==========================================================*/
+ IF( st->hFdCngDec->partNoiseShape_exp < 0 )
{
- st->lp_noise = st->hFdCngDec->lp_noise;
- move32();
+ Scale_sig32( st->hFdCngDec->partNoiseShape, NPART, st->hFdCngDec->partNoiseShape_exp );
+ st->hFdCngDec->partNoiseShape_exp = 0;
+ move16();
}
- test();
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && !st->cng_ism_flag )
+ IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 )
{
- /*Noise estimate*/
-
- Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp - Q27 );
- st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 31 - Q4; // Q4
-
- Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, st->hFdCngDec->hFdCngCom->sidNoiseEstExp - Q27 );
- Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, st->hFdCngDec->hFdCngCom->sidNoiseEstExp - Q27 );
- st->hFdCngDec->hFdCngCom->sidNoiseEstExp = 31 - Q4; // Q4
- /*==========================================================*/
- ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
- /*==========================================================*/
- IF( st->hFdCngDec->partNoiseShape_exp < 0 )
- {
- Scale_sig32( st->hFdCngDec->partNoiseShape, NPART, st->hFdCngDec->partNoiseShape_exp );
- st->hFdCngDec->partNoiseShape_exp = 0;
- }
- IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 )
- {
- Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp );
- st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0;
- }
+ Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp );
+ st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0;
+ move16();
}
+ }
- IF( !st->cna_dirac_flag )
+ IF( !st->cna_dirac_flag )
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ /* CNA: Generate additional comfort noise to mask potential coding artefacts */
+ IF( st->flag_cna && !( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) )
{
test();
- test();
- /* CNA: Generate additional comfort noise to mask potential coding artefacts */
- IF( st->flag_cna && !( EQ_16( st->coder_type, AUDIO ) && !( GT_16( st->element_mode, EVS_MONO ) && st->GSC_noisy_speech ) ) )
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) )
{
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) )
+ IF( hStereoCng->flag_cna_fade )
{
- IF( hStereoCng->flag_cna_fade )
- {
- generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
- hStereoCng->flag_cna_fade = 0;
- }
- ELSE
- {
- IF( NE_16( st->element_mode, last_element_mode ) && ( st->idchan == 0 ) )
- {
- /* Clear memory for secondary channel CNA */
- set_s( hStereoCng->olapBufferSynth22_fx, 0, shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ) );
- }
-
- generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out );
- }
+ generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
+ hStereoCng->flag_cna_fade = 0;
+ move16();
}
- ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) )
+ ELSE
{
- IF( st->idchan == 0 )
+ IF( NE_16( st->element_mode, last_element_mode ) && ( st->idchan == 0 ) )
{
- IF( NE_16( st->element_mode, last_element_mode ) )
- {
- set_s( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen );
- }
- generate_masking_noise_fx( psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0 /*, 0, 0, st->element_mode, hStereoCng, nchan_out*/ );
+ /* Clear memory for secondary channel CNA */
+ set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ) );
}
+
+ generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out );
}
}
- ELSE IF( st->flag_cna && EQ_16( st->coder_type, AUDIO ) && ( ( EQ_16( st->last_core, ACELP_CORE ) && !( EQ_16( st->last_coder_type, AUDIO ) && !( GT_16( st->element_mode, EVS_MONO ) && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, TCX_20_CORE ) ) )
+ ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) )
{
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) )
+ IF( st->idchan == 0 )
{
- generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
- hStereoCng->flag_cna_fade = 1;
- move16();
- }
- ELSE
- {
- FOR( i = 0; i < shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ); i++ )
+ IF( NE_16( st->element_mode, last_element_mode ) )
{
- psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + imult1616( 5, shr( st->hFdCngDec->hFdCngCom->frameSize, 2 ) )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) );
- move16();
+ set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen );
}
+ generate_masking_noise_fx( psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0 /*, 0, 0, st->element_mode, hStereoCng, nchan_out*/ );
}
}
- ELSE
+ }
+ ELSE IF( st->flag_cna && EQ_16( st->coder_type, AUDIO ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, TCX_20_CORE ) ) )
+ {
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) )
{
- if ( hStereoCng != NULL )
- {
- hStereoCng->flag_cna_fade = 1;
- hStereoCng->enableSecCNA = 0;
- move16();
- move16();
- }
+ generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
+ hStereoCng->flag_cna_fade = 1;
+ move16();
}
-
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
+ ELSE
{
- /*Noise estimate*/
- IF( ( st->idchan == 0 ) && ( EQ_16( nchan_out, 2 ) || ( NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) ) ) )
+ FOR( i = 0; i < shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ); i++ )
{
- ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
- IF( st->hFdCngDec->partNoiseShape_exp < 0 )
- {
- Scale_sig32( st->hFdCngDec->partNoiseShape, NPART, -st->hFdCngDec->partNoiseShape_exp );
- st->hFdCngDec->partNoiseShape_exp = 0;
- }
- IF( st->hFdCngDec->partNoiseShape_exp < 0 )
- {
- Scale_sig32( st->hFdCngDec->partNoiseShape, NPART, st->hFdCngDec->partNoiseShape_exp );
- st->hFdCngDec->partNoiseShape_exp = 0;
- }
- IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 )
- {
- Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp );
- st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0;
- }
+ psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + imult1616( 5, shr( st->hFdCngDec->hFdCngCom->frameSize, 2 ) )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) );
move16();
}
}
}
- }
-
- IF( !st->cna_dirac_flag )
- {
- IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( EQ_16( st->last_core, ACELP_CORE ) && !( EQ_16( st->last_coder_type, AUDIO ) && !( GT_16( st->element_mode, EVS_MONO ) && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) )
+ ELSE
{
- FOR( i = 0; i < shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ); i++ )
+ if ( hStereoCng != NULL )
{
- psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + imult1616( 5, shr( st->hFdCngDec->hFdCngCom->frameSize, 2 ) )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) );
+ hStereoCng->flag_cna_fade = 1;
+ move16();
+ hStereoCng->enableSecCNA = 0;
move16();
}
}
- IF( ( st->flag_cna == 0 ) || ( EQ_16( st->coder_type, AUDIO ) && !( GT_16( st->element_mode, EVS_MONO ) && st->GSC_noisy_speech ) ) )
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
{
- IF( st->idchan == 0 )
- {
- set_s( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen );
- }
- IF( hStereoCng != NULL && ( st->idchan == 0 ) )
+ test();
+ test();
+ test();
+ /*Noise estimate*/
+ IF( ( st->idchan == 0 ) && ( EQ_16( nchan_out, 2 ) || ( st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) ) ) )
{
- set_s( hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->fftlen );
+ ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
+ IF( st->hFdCngDec->partNoiseShape_exp < 0 )
+ {
+ Scale_sig32( st->hFdCngDec->partNoiseShape, NPART, -st->hFdCngDec->partNoiseShape_exp );
+ st->hFdCngDec->partNoiseShape_exp = 0;
+ move16();
+ }
+ IF( st->hFdCngDec->partNoiseShape_exp < 0 )
+ {
+ Scale_sig32( st->hFdCngDec->partNoiseShape, NPART, st->hFdCngDec->partNoiseShape_exp );
+ st->hFdCngDec->partNoiseShape_exp = 0;
+ move16();
+ }
+ IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 )
+ {
+ Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp );
+ st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0;
+ move16();
+ }
}
}
}
}
- /*----------------------------------------------------------------*
- * Resample to the output sampling rate (8/16/32/48 kHz)
- * Bass post-filter
- *----------------------------------------------------------------*/
-
- /* check if the CLDFB works on the right sample rate */
- IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) )
+ IF( !st->cna_dirac_flag )
{
- resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) );
- resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) );
-
- IF( st->ini_frame > 0 )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) )
{
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
+ FOR( i = 0; i < shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ); i++ )
+ {
+ psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + imult1616( 5, shr( st->hFdCngDec->hFdCngCom->frameSize, 2 ) )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) );
+ move16();
+ }
}
- }
-
- /* analyze pitch coherence for bass post-filter */
- Word32 pitch_buf_fx_q20[12];
-
- Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 );
- Word16 lim = shr( st->L_frame, 6 );
- FOR( Word16 lp = 0; lp < lim; lp++ )
- {
- pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 );
- move32();
- }
- bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 );
- Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 );
-
-
- IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) )
- {
test();
- IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) )
+ test();
+ test();
+ IF( ( st->flag_cna == 0 ) || ( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) )
{
- IF( EQ_16( st->L_frame, L_FRAME ) )
+ IF( st->idchan == 0 )
{
- retro_interp5_4_fx( st->hBPF->pst_old_syn_fx );
+ set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen );
}
- ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) )
+ IF( hStereoCng != NULL && ( st->idchan == 0 ) )
{
- retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx );
+ set16_fx( hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->fftlen );
}
}
+ }
+ }
+
+ /*----------------------------------------------------------------*
+ * Resample to the output sampling rate (8/16/32/48 kHz)
+ * Bass post-filter
+ *----------------------------------------------------------------*/
+
+ /* check if the CLDFB works on the right sample rate */
+ IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) )
+ {
+ resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) );
+ resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) );
- bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off,
- st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx );
+ IF( st->ini_frame > 0 )
+ {
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
+ move16();
}
+ }
+
+ /* analyze pitch coherence for bass post-filter */
+
+ Word32 pitch_buf_fx_q20[12];
+
+ Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 );
+ Word16 lim = shr( st->L_frame, 6 );
+ FOR( Word16 lp = 0; lp < lim; lp++ )
+ {
+ pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 );
+ move32();
+ }
+ bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 );
+ Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 );
- Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx;
- set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR );
- syn_32_fx = syn_tmp_32_fx + L_SUBFR;
+ test();
+ IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) )
+ {
test();
- IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft )
+ IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) )
{
- /* analysis of the synthesis at internal sampling rate */
- Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX];
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
- pRealSave_fx[i] = realBufferSave_fx[i];
- pImagSave_fx[i] = imagBufferSave_fx[i];
+ retro_interp5_4_fx( st->hBPF->pst_old_syn_fx );
}
+ ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) )
+ {
+ retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx );
+ }
+ }
+
+ bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off,
+ st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx );
+ }
+
+ Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx;
+ set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR );
+ syn_32_fx = syn_tmp_32_fx + L_SUBFR;
+ test();
+ IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft )
+ {
+ /* analysis of the synthesis at internal sampling rate */
+ Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX];
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ pRealSave_fx[i] = realBufferSave_fx[i];
+ pImagSave_fx[i] = imagBufferSave_fx[i];
+ }
#ifndef MSAN_FIX
- Copy_Scale_sig_16_32( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
+ Copy_Scale_sig_16_32( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
#endif
- IF( st->p_bpf_noise_buf_32 )
- {
+ IF( st->p_bpf_noise_buf_32 )
+ {
#ifdef MSAN_FIX
- Copy_Scale_sig_16_32( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
+ Copy_Scale_sig_16_32( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
#endif
- Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame );
- Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) );
- }
+ Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame );
+ Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) );
+ }
#ifdef MSAN_FIX
- FOR( i = 0; i < st->L_frame; i++ )
+ FOR( i = 0; i < st->L_frame; i++ )
#else
for ( i = 0; i < L_FRAME16k; i++ )
#endif
- {
- syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12
- move32();
- }
+ {
+ syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12
+ move32();
+ }
- Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
- Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12
- st->cldfbAna->Q_cldfb_state = Q12;
- move16();
- cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna );
- Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11
- st->cldfbAna->Q_cldfb_state = Q11;
- move16();
- /* analysis and add the BPF error signal */
- Word32 tmp_bpf_error_signal_fx[L_FRAME16k];
- Word16 q_bpf_error_signal;
- Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels );
+ Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
+ Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12
+ st->cldfbAna->Q_cldfb_state = Q12;
+ move16();
+ cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna );
+ Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11
+ st->cldfbAna->Q_cldfb_state = Q11;
+ move16();
+ /* analysis and add the BPF error signal */
+ Word32 tmp_bpf_error_signal_fx[L_FRAME16k];
+ Word16 q_bpf_error_signal;
+ Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels );
- q_bpf_error_signal = Q6;
- move16();
+ q_bpf_error_signal = Q6;
+ move16();
#ifdef MSAN_FIX
- Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, q_bpf_error_signal - st->Q_syn ); // Q6
+ Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, q_bpf_error_signal - st->Q_syn ); // Q6
#else
Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, q_bpf_error_signal - st->Q_syn ); // Q6
#endif
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
- Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
- }
- Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, q_bpf_error_signal - Q10 ); // q_bpf_error_signal (Q6)
- st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal;
- move16();
- tmp = -1;
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ }
+ Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, q_bpf_error_signal - Q10 ); // q_bpf_error_signal (Q6)
+ st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal;
+ move16();
+ tmp = -1;
+ move16();
+ if ( st->bpf_off )
+ {
+ tmp = 0;
move16();
- IF( st->bpf_off )
- {
- tmp = 0;
- move16();
- }
+ }
- addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
- Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -( sub( q_bpf_error_signal, Q10 ) ) ); // Q10
- st->cldfbBPF->Q_cldfb_state = Q10;
+ addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
+ Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -( sub( q_bpf_error_signal, Q10 ) ) ); // Q10
+ st->cldfbBPF->Q_cldfb_state = Q10;
+ move16();
+ /* set output mask for upsampling */
+ IF( EQ_16( st->bwidth, NB ) )
+ {
+ /* set NB mask for upsampling */
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 );
move16();
- /* set output mask for upsampling */
- IF( EQ_16( st->bwidth, NB ) )
- {
- /* set NB mask for upsampling */
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 );
- }
- ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) )
- {
- /* in case of BW switching, re-init to default */
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
- }
- test();
- IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
- test();
- test();
- test();
- /*WB/SWB-FD_CNG*/
- IF( ( EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LE_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) )
- {
- Word16 tmpBufferScale = 0;
- move16();
- generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag );
-
- /* Fixed to float */
- FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ )
- {
- Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0
- Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0
- }
-
- IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) )
- {
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand );
- }
- ELSE
- {
- st->cldfbSyn->bandsToZero = 0;
- move16();
- }
- }
- }
-
- IF( save_hb_synth_fx16 != NULL )
- {
- /* save and then zero-out lowband */
- Word16 Q_real = 0, Q_imag = 0;
- Word32 max_real = 0, max_imag = 0;
- move16();
- move16();
- move32();
- move32();
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- max_real = max( max_real, L_abs( realBuffer_fx[i][j] ) );
- max_imag = max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
- }
- }
- Word32 max_val = max( max_real, max_imag );
- Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */;
- Q_real = Q_imag;
- move16();
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real );
- scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag );
- }
- scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1)
- st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
- Scale_sig32( save_hb_synth_fx, L_FRAME48k, sub( Q_real, 1 ) );
-
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- realBufferSave_fx[i][j] = realBuffer_fx[i][j];
- imagBufferSave_fx[i][j] = imagBuffer_fx[i][j];
- move32();
- move32();
- IF( j < st->hFdCngDec->hFdCngCom->numCoreBands && i < st->hFdCngDec->hFdCngCom->numSlots )
- {
- realBuffer_fx[i][j] = 0;
- imagBuffer_fx[i][j] = 0;
- move32();
- move32();
- }
- }
- }
-
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, st->cldfbSynHB );
-
- Scale_sig32( save_hb_synth_fx, L_FRAME48k, -( sub( Q_real, 1 ) ) ); // Q0
- Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
- st->cldfbSynHB->Q_cldfb_state = Q10;
- move16();
- /* restore lowband */
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- realBuffer_fx[i][j] = realBufferSave_fx[i][j];
- imagBuffer_fx[i][j] = imagBufferSave_fx[i][j];
- move32();
- move32();
- }
- }
- Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1
- st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
- cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, st->cldfbSyn );
- Scale_sig32( synth_fx, L_FRAME48k, -sub( Q_real, 1 ) );
- Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
- st->cldfbSynHB->Q_cldfb_state = Q10;
- move16();
- }
- ELSE
+ }
+ ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) )
+ {
+ /* in case of BW switching, re-init to default */
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
+ move16();
+ }
+ test();
+ IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+ test();
+ test();
+ test();
+ /*WB/SWB-FD_CNG*/
+ IF( ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) )
{
- /* synthesis of the combined signal */
- Word16 Q_real = 0, Q_imag = 0;
- Word32 max_real = 0, max_imag = 0;
+ Word16 tmpBufferScale = 0;
move16();
- move16();
- move32();
- move32();
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag );
+
+ /* Fixed to float */
+ FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ )
{
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- max_real = max( max_real, L_abs( realBuffer_fx[i][j] ) );
- max_imag = max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
- }
+ Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0
+ Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0
}
- Word32 max_val = max( max_real, max_imag );
- Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */;
- Q_real = Q_imag;
- move16();
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+
+ IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) )
{
- scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real );
- scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real );
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand );
+ move16();
+ }
+ ELSE
+ {
+ st->cldfbSyn->bandsToZero = 0;
+ move16();
}
- scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
- st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 );
-#ifndef MSAN_FIX
- Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 );
-#endif
-
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, st->cldfbSyn );
-#ifdef MSAN_FIX
- scale_sig32( synth_fx, output_frame, -sub( Q_real, 1 ) );
-#else
- Scale_sig32( synth_fx, L_FRAME48k, -( Q_real - 1 ) );
-#endif
- scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
- st->cldfbSyn->Q_cldfb_state = Q10;
- move16();
}
-
- /* save synthesis - needed in case of core switching */
- Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0
}
- ELSE
- {
- Word16 nSamples = NS2SA( st->L_frame * FRAMES_PER_SEC, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */
-
- /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */
-#ifndef MSAN_FIX
- for ( i = 0; i < L_FRAME16k; i++ )
-#else
- FOR( i = 0; i < st->L_frame; i++ )
-#endif
- {
- syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) );
- move32();
- }
- Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
- Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12
- st->cldfbAna->Q_cldfb_state = Q12;
+ IF( save_hb_synth_fx16 != NULL )
+ {
+ /* save and then zero-out lowband */
+ Word16 Q_real = 0, Q_imag = 0;
+ Word32 max_real = 0, max_imag = 0;
move16();
- cldfbAnalysis_ivas_fx( syn_32_fx + st->L_frame - nSamples, realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna );
-
- Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11
- st->cldfbAna->Q_cldfb_state = Q11;
- move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */
- Word32 tmp_bpf_error_signal_fx[L_FRAME16k];
- Word16 q_bpf_error_signal;
- Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels );
-
- // Get Q-factor
- q_bpf_error_signal = Q6;
move16();
- Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6
+ move32();
+ move32();
FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
{
- Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
- Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
+ max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
+ }
}
- Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6)
- st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal;
+ Word32 max_val = L_max( max_real, max_imag );
+ Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */;
+ Q_real = Q_imag;
move16();
- tmp = 0;
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real );
+ scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag );
+ }
+ scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1)
+ st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
move16();
- if ( !st->bpf_off )
+ Scale_sig32( save_hb_synth_fx, L_FRAME48k, sub( Q_real, 1 ) );
+
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
{
- tmp = nSamples;
- move16();
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ realBufferSave_fx[i][j] = realBuffer_fx[i][j];
+ imagBufferSave_fx[i][j] = imagBuffer_fx[i][j];
+ move32();
+ move32();
+ IF( LT_16( j, st->hFdCngDec->hFdCngCom->numCoreBands ) && LT_16( i, st->hFdCngDec->hFdCngCom->numSlots ) )
+ {
+ realBuffer_fx[i][j] = 0;
+ imagBuffer_fx[i][j] = 0;
+ move32();
+ move32();
+ }
+ }
}
- addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + st->L_frame - nSamples, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, st->cldfbSynHB );
- Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -sub( q_bpf_error_signal, Q10 ) ); // Q10
- st->cldfbBPF->Q_cldfb_state = Q10;
- /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */
+ Scale_sig32( save_hb_synth_fx, L_FRAME48k, -( sub( Q_real, 1 ) ) ); // Q0
+ Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
+ st->cldfbSynHB->Q_cldfb_state = Q10;
+ move16();
+ /* restore lowband */
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ realBuffer_fx[i][j] = realBufferSave_fx[i][j];
+ imagBuffer_fx[i][j] = imagBufferSave_fx[i][j];
+ move32();
+ move32();
+ }
+ }
+ Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1
+ st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
+ move16();
+ cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, st->cldfbSyn );
+ Scale_sig32( synth_fx, L_FRAME48k, -sub( Q_real, 1 ) );
+ Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
+ st->cldfbSynHB->Q_cldfb_state = Q10;
+ move16();
+ }
+ ELSE
+ {
+ /* synthesis of the combined signal */
Word16 Q_real = 0, Q_imag = 0;
Word32 max_real = 0, max_imag = 0;
move16();
@@ -1997,11 +1976,11 @@ ivas_error acelp_core_dec_ivas_fx(
{
FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
{
- max_real = max( max_real, L_abs( realBuffer_fx[i][j] ) );
- max_imag = max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
+ max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
+ max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
}
}
- Word32 max_val = max( max_real, max_imag );
+ Word32 max_val = L_max( max_real, max_imag );
Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */;
Q_real = Q_imag;
move16();
@@ -2011,192 +1990,293 @@ ivas_error acelp_core_dec_ivas_fx(
scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real );
}
scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
+ st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 );
+ move16();
#ifndef MSAN_FIX
Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 );
#endif
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn );
-
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, st->cldfbSyn );
#ifdef MSAN_FIX
- Scale_sig32( synth_fx, output_frame, -sub( Q_real, 1 ) );
+ scale_sig32( synth_fx, output_frame, -sub( Q_real, 1 ) );
#else
- Scale_sig32( synth_fx, L_FRAME48k, -( Q_real - 1 ) );
+ Scale_sig32( synth_fx, L_FRAME48k, -( Q_real - 1 ) );
#endif
- Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) );
+ scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
st->cldfbSyn->Q_cldfb_state = Q10;
move16();
- IF( st->p_bpf_noise_buf_32 )
- {
- Copy_Scale_sig_16_32( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
- Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame );
-
- Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) );
- }
-
- set_l( synth_fx, 0, output_frame );
}
- /* Copy output signal */
+ /* save synthesis - needed in case of core switching */
+ Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0
+ }
+ ELSE
+ {
+ Word16 nSamples = NS2SA( st->L_frame * FRAMES_PER_SEC, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */
+
+ /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */
#ifndef MSAN_FIX
- Scale_sig( syn_tmp_fx, L_FRAME16k + L_SUBFR, -st->Q_syn );
+ for ( i = 0; i < L_FRAME16k; i++ )
#else
- Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), -st->Q_syn );
+ FOR( i = 0; i < st->L_frame; i++ )
#endif
- IF( GT_16( st->element_mode, EVS_MONO ) )
{
- Copy( psyn_fx, output_fx, st->L_frame );
+ syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) );
+ move32();
+ }
+
+ Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
+ Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12
+ st->cldfbAna->Q_cldfb_state = Q12;
+ move16();
+ cldfbAnalysis_ivas_fx( syn_32_fx + st->L_frame - nSamples, realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna );
+
+ Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11
+ st->cldfbAna->Q_cldfb_state = Q11;
+ move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */
+ Word32 tmp_bpf_error_signal_fx[L_FRAME16k];
+ Word16 q_bpf_error_signal;
+ Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels );
+
+ // Get Q-factor
+ q_bpf_error_signal = Q6;
+ move16();
+ Copy_Scale_sig_16_32( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ }
+ Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6)
+ st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal;
+ move16();
+ tmp = 0;
+ move16();
+ if ( !st->bpf_off )
+ {
+ tmp = nSamples;
+ move16();
}
+ addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + st->L_frame - nSamples, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
+
- st->Q_syn2 = 0;
+ Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, -sub( q_bpf_error_signal, Q10 ) ); // Q10
+ st->cldfbBPF->Q_cldfb_state = Q10;
move16();
- /*-----------------------------------------------------------------*
- * Bandwidth extension 6kHz-7kHz
- *-----------------------------------------------------------------*/
- IF( st->hBWE_zero != NULL )
+ /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */
+ Word16 Q_real = 0, Q_imag = 0;
+ Word32 max_real = 0, max_imag = 0;
+ move16();
+ move16();
+ move32();
+ move32();
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
{
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( EQ_16( st->L_frame, L_FRAME ) && NE_16( st->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) &&
- ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) )
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
{
+ max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
+ max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
+ }
+ }
+ Word32 max_val = L_max( max_real, max_imag );
+ Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */;
+ Q_real = Q_imag;
+ move16();
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real );
+ scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real );
+ }
+ scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
+#ifndef MSAN_FIX
+ Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 );
+#endif
+
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn );
+
+#ifdef MSAN_FIX
+ Scale_sig32( synth_fx, output_frame, -sub( Q_real, 1 ) );
+#else
+ Scale_sig32( synth_fx, L_FRAME48k, -( Q_real - 1 ) );
+#endif
+ Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) );
+ st->cldfbSyn->Q_cldfb_state = Q10;
+ move16();
+ IF( st->p_bpf_noise_buf_32 )
+ {
+ Copy_Scale_sig_16_32( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
+ Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame );
+
+ Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) );
+ }
+
+ set32_fx( synth_fx, 0, output_frame );
+ }
+
+ /* Copy output signal */
+#ifndef MSAN_FIX
+ Scale_sig( syn_tmp_fx, L_FRAME16k + L_SUBFR, -st->Q_syn );
+#else
+ Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), -st->Q_syn );
+#endif
+ IF( st->element_mode > EVS_MONO )
+ {
+ Copy( psyn_fx, output_fx, st->L_frame );
+ }
+
+ st->Q_syn2 = 0;
+ move16();
+ /*-----------------------------------------------------------------*
+ * Bandwidth extension 6kHz-7kHz
+ *-----------------------------------------------------------------*/
+ IF( st->hBWE_zero != NULL )
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( EQ_16( st->L_frame, L_FRAME ) && NE_16( st->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) &&
+ ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) )
+ {
#ifndef FIX_774_ENERGY_BURST
- Word16 tmp_exp = 0;
- move16();
+ Word16 tmp_exp = 0;
+ move16();
#endif
#ifdef MSAN_FIX
- Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 );
+ Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 );
#else
Copy_Scale_sig_32_16( synth_fx, synth_fx16, L_FRAME48k, 0 );
#endif
#ifdef FIX_774_ENERGY_BURST
- hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc_fx,
- psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &st->hBWE_zero->memExp1,
- st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode );
+ hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc_fx,
+ psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &st->hBWE_zero->memExp1,
+ st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode );
#else
hf_synth_ivas_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc_fx,
psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &tmp_exp,
st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode, st->element_mode );
#endif
#ifdef MSAN_FIX
- Copy_Scale_sig_16_32( synth_fx16, synth_fx, output_frame, 0 );
+ Copy_Scale_sig_16_32( synth_fx16, synth_fx, output_frame, 0 );
#else
Copy_Scale_sig_16_32( synth_fx16, synth_fx, L_FRAME48k, 0 );
#endif
#ifndef FIX_774_ENERGY_BURST
- IF( st->hBWE_FD != NULL )
- {
- st->hBWE_FD->memExp1 = tmp_exp;
- move16();
- }
- ELSE
- {
- Scale_sig( st->hBWE_zero->mem_hf_fx, sub( L_FIR, 1 ), -tmp_exp );
- }
-#endif
+ IF( st->hBWE_FD != NULL )
+ {
+ st->hBWE_FD->memExp1 = tmp_exp;
+ move16();
}
ELSE
{
- hf_synth_reset_fx( st->hBWE_zero );
+ Scale_sig( st->hBWE_zero->mem_hf_fx, sub( L_FIR, 1 ), -tmp_exp );
+ }
+#endif
+ }
+ ELSE
+ {
+ hf_synth_reset_fx( st->hBWE_zero );
#ifdef MSAN_FIX
- set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
+ set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
#endif
- }
}
+ }
- /*-----------------------------------------------------------------*
- * Populate parameters for SWB TBE
- *-----------------------------------------------------------------*/
+ /*-----------------------------------------------------------------*
+ * Populate parameters for SWB TBE
+ *-----------------------------------------------------------------*/
- IF( st->hBWE_TD != NULL )
+ IF( st->hBWE_TD != NULL )
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( !st->bfi && st->prev_bfi ) || ( EQ_16( st->last_vbr_hw_BWE_disable_dec, 1 ) && ( st->vbr_hw_BWE_disable_dec == 0 ) ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) )
{
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( !st->bfi && st->prev_bfi ) || ( EQ_16( st->last_vbr_hw_BWE_disable_dec, 1 ) && ( st->vbr_hw_BWE_disable_dec == 0 ) ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) )
- {
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move32();
- set_s( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
- }
- test();
- test();
- test();
- test();
- test();
- IF( !st->ppp_mode_dec && ( EQ_16( st->idchan, 0 ) || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) )
- {
- Copy_Scale_sig_16_32( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( 2 * st->Q_exc - ( st->prev_Q_bwe_exc - 16 ) ) );
- non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
- Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, -( 2 * st->Q_exc - ( st->prev_Q_bwe_exc - 16 ) ) );
- }
- test();
- IF( EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) )
- {
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move32();
- }
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ move32();
+ set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
+ }
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( !st->ppp_mode_dec && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) )
+ {
+ Copy_Scale_sig_16_32( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( 2 * st->Q_exc - ( st->prev_Q_bwe_exc - 16 ) ) );
+ non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
+ Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, -( 2 * st->Q_exc - ( st->prev_Q_bwe_exc - 16 ) ) );
}
- /*----------------------------------------------------------------------*
- * Updates
- *----------------------------------------------------------------------*/
-
- updt_dec_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, old_bwe_exc_fx, gain_buf_fx );
test();
- IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL )
+ if ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) )
{
- /* update CNG parameters in active frames */
- cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size,
- st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode,
- st->hFdCngDec->hFdCngCom->CngBandwidth );
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ move32();
+ }
+ }
+ /*----------------------------------------------------------------------*
+ * Updates
+ *----------------------------------------------------------------------*/
+
+ updt_dec_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, old_bwe_exc_fx, gain_buf_fx );
+ test();
+ test();
+ IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL )
+ {
+ /* update CNG parameters in active frames */
+ cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size,
+ st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode,
+ st->hFdCngDec->hFdCngCom->CngBandwidth );
- /* Set 16k LSP flag for CNG buffer */
- st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0;
+ /* Set 16k LSP flag for CNG buffer */
+ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0;
+ move16();
+ if ( NE_16( st->L_frame, L_FRAME ) )
+ {
+ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1;
move16();
- if ( NE_16( st->L_frame, L_FRAME ) )
- {
- st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1;
- move16();
- }
}
+ }
+ {
+ IF( save_hb_synth_fx16 )
{
- IF( save_hb_synth_fx16 )
- {
- Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 );
- }
+ Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 );
+ }
#ifdef MSAN_FIX
- Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 );
+ Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 );
#else
Copy_Scale_sig_32_16( synth_fx, synth_fx16, L_FRAME48k, 0 );
#endif
- if ( st->hFdCngDec )
- {
- st->hFdCngDec->hFdCngCom->A_cng[0] = ONE_IN_Q12;
- move16();
- }
+ if ( st->hFdCngDec )
+ {
+ st->hFdCngDec->hFdCngCom->A_cng[0] = ONE_IN_Q12;
+ move16();
}
-
- pop_wmops();
- return error;
}
+ pop_wmops();
+ return error;
+}
- static void rescale_fdCngDec( HANDLE_FD_CNG_DEC hFdCngDec, Word16 Exp_diff )
- {
- Scale_sig32( hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, Exp_diff );
- }
+
+static void rescale_fdCngDec( HANDLE_FD_CNG_DEC hFdCngDec, Word16 Exp_diff )
+{
+ Scale_sig32( hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, Exp_diff );
+}
#endif
diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c
index 31af985cbddfb2e7b1c9e507c1243b315b2070e7..d2a81d11b760df8590371ea5a27218f04ebf8b12 100644
--- a/lib_dec/acelp_core_switch_dec_fx.c
+++ b/lib_dec/acelp_core_switch_dec_fx.c
@@ -3,12 +3,11 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "prot.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "prot.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
/*---------------------------------------------------------------------*
* Local function prototypes
@@ -52,6 +51,7 @@ ivas_error acelp_core_switch_dec_fx(
ivas_error error;
error = IVAS_ERR_OK;
+ move32();
FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ )
{
@@ -72,7 +72,7 @@ ivas_error acelp_core_switch_dec_fx(
Copy( st_fx->old_Aq_12_8_fx, Aq, M + 1 );
Copy( st_fx->old_Aq_12_8_fx, Aq + ( M + 1 ), M + 1 );
- set16_fx( mem_synth, 0, add( NS2SA( 16000, DELAY_CLDFB_NS ), 2 ) );
+ set16_fx( mem_synth, 0, NS2SA( 16000, DELAY_CLDFB_NS ) + 2 );
set16_fx( synth_subfr_out, 0, SWITCH_MAX_GAP ); /* avoid valgrind complaining about uninitialized memory in core_switching_OLA_fx() */
/* set multiplication factor according to the sampling rate */
@@ -90,7 +90,7 @@ ivas_error acelp_core_switch_dec_fx(
test();
test();
test();
- IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( ( EQ_16( st_fx->last_core, ACELP_CORE ) ) || ( EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) )
+ IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( ( ( st_fx->last_core == ACELP_CORE ) ) || ( EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) )
{
exc = old_exc + L_EXC_MEM_DEC;
Copy( st_fx->old_exc_fx, old_exc, L_EXC_MEM_DEC ); /*scaling of exc from previous frame*/
@@ -139,7 +139,7 @@ ivas_error acelp_core_switch_dec_fx(
Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx,
4, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, 0, NULL );
- syn_12k8_fx( shl( L_SUBFR, 1 ), Aq, exc, synth_intFreq, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
+ syn_12k8_fx( 2 * L_SUBFR, Aq, exc, synth_intFreq, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
IF( st_fx->hPFstat->on && ( EQ_16( st_fx->last_bwidth, NB ) ) )
{
@@ -150,20 +150,20 @@ ivas_error acelp_core_switch_dec_fx(
pitch_buf_tmp[i] = L_SUBFR;
move16();
}
- nb_post_filt_fx( shl( L_SUBFR, 1 ), st_fx->hPFstat, &tmp_noise, 0, synth_intFreq, Aq, pitch_buf_tmp, AUDIO, st_fx->BER_detect, 0 );
+ nb_post_filt_fx( 2 * L_SUBFR, st_fx->hPFstat, &tmp_noise, 0, synth_intFreq, Aq, pitch_buf_tmp, AUDIO, st_fx->BER_detect, 0 );
}
IF( EQ_16( L_frame_for_cs, L_FRAME ) )
{
- deemph_fx( synth_intFreq, PREEMPH_FAC, shl( L_SUBFR, 1 ), &( st_fx->mem_deemph_fx ) );
+ deemph_fx( synth_intFreq, PREEMPH_FAC, 2 * L_SUBFR, &( st_fx->mem_deemph_fx ) );
}
ELSE
{
- deemph_fx( synth_intFreq, PREEMPH_FAC_16k, shl( L_SUBFR, 1 ), &( st_fx->mem_deemph_fx ) );
+ deemph_fx( synth_intFreq, PREEMPH_FAC_16k, 2 * L_SUBFR, &( st_fx->mem_deemph_fx ) );
}
- unscale_AGC( synth_intFreq, st_fx->Q_syn, syn_fx_tmp + M, st_fx->agc_mem_fx, shl( L_SUBFR, 1 ) );
- Copy( syn_fx_tmp + M, synth_intFreq, shl( L_SUBFR, 1 ) );
+ unscale_AGC( synth_intFreq, st_fx->Q_syn, syn_fx_tmp + M, st_fx->agc_mem_fx, 2 * L_SUBFR );
+ Copy( syn_fx_tmp + M, synth_intFreq, 2 * L_SUBFR );
test();
IF( st_fx->hPFstat->on && ( NE_16( st_fx->last_bwidth, NB ) ) )
@@ -173,16 +173,16 @@ ivas_error acelp_core_switch_dec_fx(
Residu3_fx( Aq, bpf_error_signal + M, exc, L_SUBFR, 1 );
E_UTIL_synthesis( 1, Aq, exc, bpf_error_signal, L_SUBFR, st_fx->hPFstat->mem_stp + L_SYN_MEM - M, 0, M );
scale_st_fx( synth_intFreq, bpf_error_signal, &st_fx->hPFstat->gain_prec, L_SUBFR );
- Copy( bpf_error_signal, synth_intFreq, shr( L_SUBFR, 1 ) );
- blend_subfr2_fx( bpf_error_signal + shr( L_SUBFR, 1 ), synth_intFreq + shr( L_SUBFR, 1 ), synth_intFreq + shr( L_SUBFR, 1 ) );
+ Copy( bpf_error_signal, synth_intFreq, L_SUBFR / 2 );
+ blend_subfr2_fx( bpf_error_signal + L_SUBFR / 2, synth_intFreq + L_SUBFR / 2, synth_intFreq + L_SUBFR / 2 );
}
st_fx->hPFstat->on = 0;
move16();
- IF( NE_16( st_fx->flag_cna, 0 ) )
+ IF( st_fx->flag_cna )
{
- generate_masking_noise_fx( synth_intFreq, st_fx->Q_syn, st_fx->hFdCngDec->hFdCngCom, shl( L_SUBFR, 1 ), 0 );
+ generate_masking_noise_fx( synth_intFreq, st_fx->Q_syn, st_fx->hFdCngDec->hFdCngCom, 2 * L_SUBFR, 0 );
}
/*----------------------------------------------------------------*
@@ -190,11 +190,11 @@ ivas_error acelp_core_switch_dec_fx(
* Bass post-filter
*----------------------------------------------------------------*/
- bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, synth_intFreq, shl( L_SUBFR, 1 ), NULL,
+ bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, synth_intFreq, 2 * L_SUBFR, NULL,
st_fx->bpf_off, st_fx->stab_fac_fx, &st_fx->stab_fac_smooth_fx,
GENERIC, st_fx->Q_syn, bpf_error_signal );
- IF( ( error = cldfb_save_memory( st_fx->cldfbAna ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbAna ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -207,13 +207,13 @@ ivas_error acelp_core_switch_dec_fx(
move16();
/* CLDFB analysis and add the BPF error signal */
- IF( ( error = cldfb_save_memory( st_fx->cldfbBPF ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbBPF ) ), IVAS_ERR_OK ) )
{
return error;
}
i = 0;
move16();
- IF( EQ_16( st_fx->bpf_off, 0 ) )
+ if ( st_fx->bpf_off == 0 )
{
i = CLDFB_NO_COL_MAX_SWITCH;
move16();
@@ -226,7 +226,7 @@ ivas_error acelp_core_switch_dec_fx(
scaleFactor.hb_scale = scaleFactor.lb_scale;
move16();
- IF( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -249,7 +249,9 @@ ivas_error acelp_core_switch_dec_fx(
{
/* Decoding of BWE */
d1m = (Word16) get_next_indice( st_fx, AUDIODELAYBITS );
+ move16();
ind1 = (Word16) get_next_indice( st_fx, NOOFGAINBITS1 );
+ move16();
gain = usdequant_fx( ind1, MINVALUEOFFIRSTGAIN_FX, shr( DELTAOFFIRSTGAIN_FX, 3 ) ); /*Q13*/
decode_bwe = 1;
move16();
@@ -260,7 +262,7 @@ ivas_error acelp_core_switch_dec_fx(
test();
IF( decode_bwe && !( ( EQ_16( output_frame, L_FRAME16k ) && EQ_16( st_fx->last_L_frame, L_FRAME16k ) ) || EQ_16( output_frame, L_FRAME8k ) ) )
{
- set16_fx( tmp_mem2, 0, shl( L_FILT48k, 1 ) );
+ set16_fx( tmp_mem2, 0, 2 * L_FILT48k );
hp_filter = hp16000_48000_fx;
fdelay = 48;
@@ -299,7 +301,7 @@ ivas_error acelp_core_switch_dec_fx(
/* safety check in case of bit errors */
i = MAX_D1M_16k;
move16();
- IF( EQ_16( st_fx->last_L_frame, L_FRAME ) )
+ if ( EQ_16( st_fx->last_L_frame, L_FRAME ) )
{
i = MAX_D1M_12k8;
move16();
@@ -314,7 +316,7 @@ ivas_error acelp_core_switch_dec_fx(
move16();
}
- i = NS2SA_fx2( st_fx->output_Fs, L_sub( FRAME_SIZE_NS, L_add( ACELP_LOOK_NS, DELAY_BWE_TOTAL_NS ) ) );
+ i = NS2SA_fx2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS );
move16();
Copy( st_fx->old_synth_sw_fx, hb_synth_tmp, i );
set16_fx( hb_synth_tmp + i, 0, NS2SA_fx2( st_fx->output_Fs, 10000000L ) - i );
@@ -331,6 +333,7 @@ ivas_error acelp_core_switch_dec_fx(
{
#ifdef BASOP_NOGLOB
*pt1++ = round_fx_sat( L_shl_sat( L_mult_sat( ( *pt2++ ), gain ), 2 ) );
+ move16();
#else
*pt1++ = round_fx( L_shl( L_mult( ( *pt2++ ), gain ), 2 ) );
#endif
@@ -391,6 +394,7 @@ ivas_error acelp_core_switch_dec_bfi_fx(
hMusicPF = st_fx->hMusicPF;
hBPF = st_fx->hBPF;
error = IVAS_ERR_OK;
+ move32();
FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH_BFI; i++ )
{
@@ -425,8 +429,8 @@ ivas_error acelp_core_switch_dec_bfi_fx(
exc2 = old_exc2 + L_EXC_MEM;
IF( st_fx->hBWE_TD != NULL )
{
- Copy( st_fx->hBWE_TD->old_bwe_exc_fx, old_bwe_exc, shl( PIT16k_MAX, 1 ) );
- bwe_exc = old_bwe_exc + shl( PIT16k_MAX, 1 );
+ Copy( st_fx->hBWE_TD->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 );
+ bwe_exc = old_bwe_exc + PIT16k_MAX * 2;
}
ELSE
{
@@ -439,7 +443,7 @@ ivas_error acelp_core_switch_dec_bfi_fx(
move16();
/* SC-VBR */
- IF( EQ_16( st_fx->last_nelp_mode_dec, 1 ) )
+ if ( EQ_16( st_fx->last_nelp_mode_dec, 1 ) )
{
st_fx->nelp_mode_dec = 1;
move16();
@@ -568,7 +572,7 @@ ivas_error acelp_core_switch_dec_bfi_fx(
* Resamping to the output sampling frequency
*----------------------------------------------------------------*/
/* CLDFB analysis of the synthesis at internal sampling rate */
- IF( ( error = cldfb_save_memory( st_fx->cldfbAna ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbAna ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -580,7 +584,7 @@ ivas_error acelp_core_switch_dec_bfi_fx(
move16();
/* CLDFB synthesis of the combined signal */
- IF( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -637,6 +641,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
hMusicPF = st_fx->hMusicPF;
hBPF = st_fx->hBPF;
error = IVAS_ERR_OK;
+ move16();
FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH_BFI; i++ )
{
@@ -685,7 +690,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
move16();
/* SC-VBR */
- IF( EQ_16( st_fx->last_nelp_mode_dec, 1 ) )
+ if ( EQ_16( st_fx->last_nelp_mode_dec, 1 ) )
{
st_fx->nelp_mode_dec = 1;
move16();
@@ -815,7 +820,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
/* CLDFB analysis of the synthesis at internal sampling rate */
Qtmp = sub( 11, st_fx->Q_syn );
Copy_Scale_sig_16_32( syn, syn32, L_FRAME16k, Qtmp );
- IF( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbAna ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbAna ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -827,7 +832,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
// scaleFactor.hb_scale = scaleFactor.lb_scale;
/* CLDFB synthesis of the combined signal */
- IF( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbSyn ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -916,7 +921,7 @@ static void decod_gen_voic_core_switch_fx(
* Find the adaptive codebook vector.
*--------------------------------------------------------------*/
- pred_lt4( &exc[0], &exc[0], T0, T0_frac, add( L_SUBFR, 1 ), pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
/*--------------------------------------------------------------*
* LP filtering of the adaptive excitation
@@ -949,6 +954,7 @@ static void decod_gen_voic_core_switch_fx(
/* _ (Word16*) gain_inov : gain of the innovation (used for normalization) (Q12) */
/* _ (Word32*) norm_gain_code : norm. gain of the codebook excitation (Q16) */
st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc ); /*Q15*/
+ move16();
/*----------------------------------------------------------------------*
* Find the total excitation
@@ -982,6 +988,7 @@ static void decod_gen_voic_core_switch_fx(
/*exc2_fx[i+i_subfr] = round_fx(L_tmp);*/ /*Q_exc*/
L_tmp = L_add( L_tmp, L_shl( L_mult( gain_code16, code[i] ), 6 ) ); /*Q16+Q_exc*/
exc[i] = round_fx( L_tmp ); /*Q_exc*/
+ move16();
}
/*-----------------------------------------------------------------*
@@ -994,6 +1001,7 @@ static void decod_gen_voic_core_switch_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
( *pt1 ) = round_fx( L_shl( L_mult( *pt1, gain_pit ), 1 ) ); /*Q_exc + Q14 +1 +1 -16*/
+ move16();
pt1++;
}
diff --git a/lib_dec/amr_wb_dec.c b/lib_dec/amr_wb_dec.c
index 895af08609696bfc74683c1b503a75dbc68dc0d8..29b2e5a265eb496118a239e4552a41477825b33a 100644
--- a/lib_dec/amr_wb_dec.c
+++ b/lib_dec/amr_wb_dec.c
@@ -43,7 +43,7 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif
#ifndef IVAS_FLOAT_FIXED
diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c
index 616b760937d89250b0b8b6df7da66e7b1335b901..b5d194c6dbcc4f4f127b833cfb7355eee9ac1167 100644
--- a/lib_dec/amr_wb_dec_fx.c
+++ b/lib_dec/amr_wb_dec_fx.c
@@ -6,8 +6,7 @@
#include "options.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
@@ -72,6 +71,7 @@ ivas_error amr_wb_dec_fx(
Word8 flag_cna;
Word8 waveadj_rec = 0;
+ move16();
Word16 avoid_lpc_burst_on_recovery;
Word16 delta_mem_scale;
@@ -155,7 +155,7 @@ ivas_error amr_wb_dec_fx(
st_fx->fscale = sr2fscale_fx( st_fx->sr_core );
/* Initialization in case that the first frame is the good received AMR-WB (IO) frame */
- IF( EQ_16( st_fx->ini_frame, 0 ) )
+ IF( st_fx->ini_frame == 0 )
{
st_fx->last_core = AMR_WB_CORE;
move16();
@@ -170,7 +170,7 @@ ivas_error amr_wb_dec_fx(
}
/* Updates in case of EVS -> AMR-WB IO switching */
- IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -188,14 +188,15 @@ ivas_error amr_wb_dec_fx(
Copy( st_fx->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC );
exc_fx = old_exc_fx + L_EXC_MEM_DEC;
/* reset post-filter in case of switching */
- IF( EQ_16( st_fx->hPFstat->on, 0 ) )
+ if ( st_fx->hPFstat->on == 0 )
{
st_fx->hPFstat->reset = 1;
move16();
}
- IF( GT_16( st_fx->bfi, 0 ) )
+ IF( st_fx->bfi > 0 )
{
st_fx->nbLostCmpt = add( st_fx->nbLostCmpt, 1 );
+ move16();
}
ELSE
{
@@ -216,6 +217,7 @@ ivas_error amr_wb_dec_fx(
FOR( i = 0; i < hTcxDec->L_frameTCX; i++ )
{
hHQ_core->old_out_fx[i] = shl( mult_r( hHQ_core->old_out_fx[i], st_fx->plcInfo.recovery_gain ), 1 );
+ move16();
}
}
@@ -223,7 +225,7 @@ ivas_error amr_wb_dec_fx(
move16();
test();
test();
- IF( st_fx->last_con_tcx && ( NE_16( st_fx->L_frameTCX_past, st_fx->L_frame ) ) && ( NE_16( st_fx->last_core, 0 ) ) )
+ if ( st_fx->last_con_tcx && ( NE_16( st_fx->L_frameTCX_past, st_fx->L_frame ) ) && ( st_fx->last_core != 0 ) )
{
avoid_lpc_burst_on_recovery = 1;
move16();
@@ -241,8 +243,7 @@ ivas_error amr_wb_dec_fx(
/* in case of switching, do not apply BPF */
st_fx->bpf_off = 1;
move16();
-
- IF( NE_16( st_fx->hPFstat->on, 0 ) )
+ IF( st_fx->hPFstat->on )
{
Word16 mem_syn_r_size_old, mem_syn_r_size_new;
@@ -300,13 +301,13 @@ ivas_error amr_wb_dec_fx(
FOR( i = sub( NB_SUBFR16k, NB_SUBFR ); i < NB_SUBFR16k; i++ )
{
- st_fx->old_pitch_buf_fx[sub( i, 1 )] = Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], tmp16 );
+ st_fx->old_pitch_buf_fx[i - 1] = Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], tmp16 );
move32();
}
FOR( i = sub( shl( NB_SUBFR16k, 1 ), NB_SUBFR ); i < shl( NB_SUBFR16k, 1 ); i++ )
{
- st_fx->old_pitch_buf_fx[sub( i, 2 )] = Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], tmp16 );
+ st_fx->old_pitch_buf_fx[i - 2] = Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], tmp16 );
move32();
}
}
@@ -333,6 +334,7 @@ ivas_error amr_wb_dec_fx(
move16();
}
st_fx->bfi_pitch_fx = mult_r( tmp16, st_fx->bfi_pitch_fx );
+ move16();
st_fx->bfi_pitch_frame = L_FRAME;
move16();
}
@@ -343,13 +345,13 @@ ivas_error amr_wb_dec_fx(
{
/* reset the unvoiced/audio signal improvement memories */
E_LPC_f_isp_a_conversion( st_fx->lsp_old_fx, st_fx->hAmrwb_IO->old_Aq_fx, M );
- Copy( st_fx->hAmrwb_IO->old_Aq_fx, st_fx->hAmrwb_IO->old_Aq_fx + add( M, 1 ), add( M, 1 ) );
- Copy( st_fx->hAmrwb_IO->old_Aq_fx, st_fx->hAmrwb_IO->old_Aq_fx + i_mult( 2, add( M, 1 ) ), add( M, 1 ) );
- Copy( st_fx->hAmrwb_IO->old_Aq_fx, st_fx->hAmrwb_IO->old_Aq_fx + i_mult( 3, add( M, 1 ) ), add( M, 1 ) );
+ Copy( st_fx->hAmrwb_IO->old_Aq_fx, st_fx->hAmrwb_IO->old_Aq_fx + M + 1, M + 1 );
+ Copy( st_fx->hAmrwb_IO->old_Aq_fx, st_fx->hAmrwb_IO->old_Aq_fx + i_mult( 2, M + 1 ), M + 1 );
+ Copy( st_fx->hAmrwb_IO->old_Aq_fx, st_fx->hAmrwb_IO->old_Aq_fx + i_mult( 3, M + 1 ), M + 1 );
}
/*End of _DIFF_FLOAT_FIX_*/
test();
- IF( EQ_16( st_fx->last_bwidth, NB ) && NE_16( st_fx->ini_frame, 0 ) )
+ if ( EQ_16( st_fx->last_bwidth, NB ) && st_fx->ini_frame != 0 )
{
st_fx->rate_switching_reset = 1;
move16();
@@ -381,16 +383,10 @@ ivas_error amr_wb_dec_fx(
class_para_fx = 0;
move16();
- // has been moved to updt_dec_common_fx()
- // if( st_fx->first_CNG == 0 )
- //{
- // st_fx->first_CNG = 1;
- // move16();
- //}
-
delta_mem_scale = 3;
move16();
- IF( LT_32( st_fx->lp_ener_fx, 40 ) ) /* very low energy frames, less than 0.3125 */
+
+ if ( LT_32( st_fx->lp_ener_fx, 40 ) ) /* very low energy frames, less than 0.3125 */
{
delta_mem_scale = 0;
move16();
@@ -405,8 +401,8 @@ ivas_error amr_wb_dec_fx(
Copy_Scale_sig( exc2_fx, exc2_fx, st_fx->L_frame, sub( st_fx->Q_exc, i ) );
/* update past excitation signals for LD music post-filter */
- Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, sub( DCT_L_POST, add( L_FRAME, OFFSET2 ) ) );
- Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + sub( DCT_L_POST, add( L_FRAME, OFFSET2 ) ), L_FRAME );
+ Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
+ Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
/* synthesis at 12k8 Hz sampling rate */
syn_12k8_fx( L_FRAME, Aq_fx, exc2_fx, syn_fx, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
@@ -427,9 +423,10 @@ ivas_error amr_wb_dec_fx(
frame_energy_fx( L_FRAME, pitch_temp, syn_fx, 0, &frame_e_fx, st_fx->Q_syn );
/*st->psf_lp_noise = 0.99f * st->psf_lp_noise + 0.01f * frame_e; */
st_fx->psf_lp_noise_fx = round_fx( L_mac( L_mult( 32440, st_fx->psf_lp_noise_fx ), 328, frame_e_fx ) ); /*Q8*/
+ move16();
}
/* update old synthesis for classification */
- Copy( syn_fx + sub( L_FRAME, L_SYN_MEM_CLAS_ESTIM ), st_fx->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
+ Copy( syn_fx + L_FRAME - L_SYN_MEM_CLAS_ESTIM, st_fx->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
/* Update music post processing values */
/* Filter energies update */
@@ -466,10 +463,11 @@ ivas_error amr_wb_dec_fx(
*------------------------------------------------------------*/
vad_flag = (Word16) get_next_indice( st_fx, 1 );
+ move16();
st_fx->coder_type = GENERIC;
move16();
- IF( EQ_16( vad_flag, 0 ) )
+ if ( vad_flag == 0 )
{
st_fx->coder_type = INACTIVE;
move16();
@@ -504,15 +502,18 @@ ivas_error amr_wb_dec_fx(
/*st->lp_ener = 0.7f * st->lp_ener + 0.3f * ftmp;*/
L_tmp = Mult_32_16( st_fx->lp_ener_fx, 22938 );
st_fx->lp_ener_fx = L_add( L_tmp, Mult_32_16( L_tmp1, 9830 ) ); /*Q6 + Q6*/
+ move32();
FOR( i = 0; i < M; i++ )
{
L_tmp = L_mult( 3277, lsp_new_fx[i] );
st_fx->lspCNG_fx[i] = round_fx( L_mac( L_tmp, 29491, st_fx->lspCNG_fx[i] ) );
+ move16();
}
}
ELSE
{
st_fx->unv_cnt = add( st_fx->unv_cnt, 1 );
+ move16();
}
}
ELSE
@@ -531,7 +532,7 @@ ivas_error amr_wb_dec_fx(
move16();
test();
test();
- IF( EQ_16( st_fx->coder_type, INACTIVE ) && st_fx->flag_cna && GE_16( st_fx->psf_lp_noise_fx, shl( 15, 7 ) ) )
+ if ( EQ_16( st_fx->coder_type, INACTIVE ) && st_fx->flag_cna && GE_16( st_fx->psf_lp_noise_fx, shl( 15, 7 ) ) )
{
tmp16 = 1;
move16();
@@ -552,9 +553,9 @@ ivas_error amr_wb_dec_fx(
0, 0, 0, st_fx->last_core_brate, -1 );
/* update past excitation signals for LD music post-filter */
- Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, sub( DCT_L_POST, add( L_FRAME, OFFSET2 ) ) );
- Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + sub( DCT_L_POST, add( L_FRAME, OFFSET2 ) ), L_FRAME );
- Copy( hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, sub( DCT_L_POST, OFFSET2 ) );
+ Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
+ Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+ Copy( hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 );
IF( NE_16( output_frame, L_FRAME8k ) )
{
@@ -563,17 +564,18 @@ ivas_error amr_wb_dec_fx(
frame_energy_fx( L_FRAME, pitch_buf_fx, syn_fx, 0, &frame_e_fx, st_fx->Q_syn );
/*st->psf_lp_noise = 0.99f * st->psf_lp_noise + 0.01f * frame_e; */
st_fx->psf_lp_noise_fx = round_fx( L_mac( L_mult( 32440, st_fx->psf_lp_noise_fx ), 328, frame_e_fx ) ); /*Q8*/
+ move16();
}
}
test();
test();
- IF( NE_16( amr_io_class, UNVOICED_CLAS ) && NE_16( st_fx->coder_type, INACTIVE ) && LT_16( st_fx->psf_lp_noise_fx, shl( 15, 8 ) ) )
+ IF( NE_16( amr_io_class, UNVOICED_CLAS ) && NE_16( st_fx->coder_type, INACTIVE ) && LT_16( st_fx->psf_lp_noise_fx, 15 << 8 ) )
{
tmp_coder_type = AUDIO;
move16();
test();
- IF( EQ_16( st_fx->last_coder_type, INACTIVE ) || EQ_16( st_fx->last_coder_type, UNVOICED ) )
+ if ( EQ_16( st_fx->last_coder_type, INACTIVE ) || EQ_16( st_fx->last_coder_type, UNVOICED ) )
{
tmp_coder_type = INACTIVE;
move16();
@@ -602,6 +604,7 @@ ivas_error amr_wb_dec_fx(
{
/*st->filt_lfE[i] = 0.3f + 0.7f * st->filt_lfE[i] ;*/
hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( L_deposit_h( 1229 ), 22938, hMusicPF->filt_lfE_fx[i] ) );
+ move16();
}
}
@@ -639,7 +642,7 @@ ivas_error amr_wb_dec_fx(
{
/* long burst frame erasures */
test();
- IF( GT_16( st_fx->nbLostCmpt, 5 ) && GE_16( st_fx->clas_dec, VOICED_CLAS ) )
+ if ( GT_16( st_fx->nbLostCmpt, 5 ) && GE_16( st_fx->clas_dec, VOICED_CLAS ) )
{
st_fx->last_good = VOICED_TRANSITION;
move16();
@@ -672,7 +675,7 @@ ivas_error amr_wb_dec_fx(
/* Update circular buffer, keep last energy difference unchanged */
FOR( i = 1; i < MAX_LT; i++ )
{
- hMusicPF->LDm_lt_diff_etot_fx[sub( i, 1 )] = hMusicPF->LDm_lt_diff_etot_fx[i];
+ hMusicPF->LDm_lt_diff_etot_fx[i - 1] = hMusicPF->LDm_lt_diff_etot_fx[i];
move16();
}
/* Filter energies update */
@@ -680,6 +683,7 @@ ivas_error amr_wb_dec_fx(
{
/*st->filt_lfE[i] = 0.3f + 0.7f * st->filt_lfE[i];*/
hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( L_deposit_h( 1229 ), 22938, hMusicPF->filt_lfE_fx[i] ) );
+ move16();
}
Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx,
@@ -689,7 +693,7 @@ ivas_error amr_wb_dec_fx(
syn_12k8_fx( L_FRAME, Aq_fx, exc2_fx, syn_fx, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
/* update old synthesis for classification */
- Copy( syn_fx + sub( L_FRAME, L_SYN_MEM_CLAS_ESTIM ), st_fx->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
+ Copy( syn_fx + L_FRAME - L_SYN_MEM_CLAS_ESTIM, st_fx->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
FOR( i = 0; i < NB_SUBFR; i++ )
@@ -742,7 +746,7 @@ ivas_error amr_wb_dec_fx(
*-----------------------------------------------------------------*/
/* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( syn_fx + sub( L_FRAME, L_SYN_MEM ), st_fx->mem_syn_r, L_SYN_MEM );
+ Copy( syn_fx + L_FRAME - L_SYN_MEM, st_fx->mem_syn_r, L_SYN_MEM );
deemph_fx( syn_fx, PREEMPH_FAC, L_FRAME, &( st_fx->mem_deemph_fx ) );
@@ -750,8 +754,8 @@ ivas_error amr_wb_dec_fx(
Copy( syn_fx_tmp2, syn_fx, L_FRAME );
/* TCX=Q-1, ACELP2 Q0 */
- Copy_Scale_sig( syn_fx + shr( L_FRAME, 1 ), hTcxDec->old_syn_Overl, shr( L_FRAME, 1 ), sub( -1, st_fx->Q_syn ) ); /*Q_syn*/
- Copy_Scale_sig( syn_fx + sub( L_FRAME, add( M, 1 ) ), st_fx->syn, add( M, 1 ), sub( 0, st_fx->Q_syn ) ); /*Q0*/
+ Copy_Scale_sig( syn_fx + L_FRAME / 2, hTcxDec->old_syn_Overl, L_FRAME / 2, sub( -1, st_fx->Q_syn ) ); /*Q_syn*/
+ Copy_Scale_sig( syn_fx + L_FRAME - M - 1, st_fx->syn, M + 1, sub( 0, st_fx->Q_syn ) ); /*Q0*/
/*------------------------------------------------------------------*
* Formant post-filter
@@ -763,7 +767,7 @@ ivas_error amr_wb_dec_fx(
st_fx->hPFstat->on = 1;
move16();
test();
- formant_post_filt_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl( st_fx->psf_lp_noise_fx, 15 ), st_fx->total_brate, (Word16) EQ_16( sub( amr_io_class, AUDIO_CLAS ), 0 ) );
+ formant_post_filt_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl( st_fx->psf_lp_noise_fx, 15 ), st_fx->total_brate, sub( amr_io_class, AUDIO_CLAS ) == 0 );
}
/*----------------------------------------------------------------*
@@ -773,11 +777,11 @@ ivas_error amr_wb_dec_fx(
flag_cna = 0;
move16();
test();
- IF( ( GE_16( st_fx->psf_lp_noise_fx, shl( 15, 8 ) ) ) || EQ_16( st_fx->coder_type, INACTIVE ) )
+ IF( ( GE_16( st_fx->psf_lp_noise_fx, ( 15 * ONE_IN_Q8 ) ) ) || EQ_16( st_fx->coder_type, INACTIVE ) )
{
/*VAD only for non inactive frame*/
test();
- IF( EQ_16( st_fx->VAD, 1 ) && NE_16( st_fx->coder_type, INACTIVE ) )
+ IF( EQ_16( st_fx->VAD, 1 ) && st_fx->coder_type != INACTIVE )
{
st_fx->VAD = 1;
move16();
@@ -800,7 +804,7 @@ ivas_error amr_wb_dec_fx(
noisy_speech_detection_fx( st_fx->hFdCngDec, st_fx->VAD, syn_fx, st_fx->Q_syn );
st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ );
- IF( NE_16( st_fx->hFdCngDec->hFdCngCom->flag_noisy_speech, 0 ) )
+ IF( st_fx->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 )
{
st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ );
move16();
@@ -809,7 +813,7 @@ ivas_error amr_wb_dec_fx(
move16();
test();
- IF( st_fx->flag_cna && GE_16( st_fx->psf_lp_noise_fx, shl( 15, 8 ) ) )
+ IF( st_fx->flag_cna && GE_16( st_fx->psf_lp_noise_fx, 15 << 8 ) )
{
flag_cna = 1;
move16();
@@ -827,15 +831,14 @@ ivas_error amr_wb_dec_fx(
generate_masking_noise_update_seed_fx( st_fx->hFdCngDec->hFdCngCom );
}
-
- IF( EQ_16( flag_cna, 0 ) )
+ IF( !flag_cna )
{
test();
test();
test();
IF( EQ_16( st_fx->last_flag_cna, 1 ) && ( ( EQ_16( st_fx->last_core, ACELP_CORE ) && NE_16( st_fx->last_coder_type, AUDIO ) ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) )
{
- FOR( i = 0; i < shr( L_FRAME, 1 ); i++ )
+ FOR( i = 0; i < L_FRAME / 2; i++ )
{
syn_fx[i] = add( syn_fx[i], shr_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[add( i, shr( i_mult( 5, L_FRAME ), 2 ) )], -st_fx->Q_syn ) );
move16();
@@ -858,9 +861,10 @@ ivas_error amr_wb_dec_fx(
resampleCldfb( st_fx->cldfbAna, newCldfbBands, L_FRAME, 0 );
resampleCldfb( st_fx->cldfbBPF, newCldfbBands, L_FRAME, 0 );
- IF( GT_16( st_fx->ini_frame, 0 ) )
+ IF( st_fx->ini_frame > 0 )
{
st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels );
+ move16();
}
}
@@ -876,7 +880,7 @@ ivas_error amr_wb_dec_fx(
/* CLDFB analysis and add the BPF error signal */
i = 0;
move16();
- IF( EQ_16( st_fx->bpf_off, 0 ) )
+ if ( st_fx->bpf_off == 0 )
{
i = CLDFB_NO_COL_MAX;
move16();
@@ -890,6 +894,7 @@ ivas_error amr_wb_dec_fx(
{
/* in case of BW switching, re-init to default */
st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels );
+ move16();
}
cldfb_synth_set_bandsToZero( st_fx, realBuffer, imagBuffer, CLDFB_NO_COL_MAX, scaleFactor );
/* CLDFB synthesis of the combined signal */
@@ -947,7 +952,7 @@ ivas_error amr_wb_dec_fx(
updt_dec_fx( st_fx, old_exc_fx, pitch_buf_fx, 0, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, dummy_buf_fx, gain_buf );
/* update old_Aq[] - needed in improv_amr_wb_gs_fx() */
- Copy( Aq_fx, st_fx->hAmrwb_IO->old_Aq_fx, NB_SUBFR * add( M, 1 ) );
+ Copy( Aq_fx, st_fx->hAmrwb_IO->old_Aq_fx, NB_SUBFR * ( M + 1 ) );
test();
test();
@@ -956,8 +961,8 @@ ivas_error amr_wb_dec_fx(
test();
test();
test();
- test();
- IF( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->plcInfo.concealment_method, TCX_NONTONAL ) && LT_32( st_fx->plcInfo.nbLostCmpt, 4 ) )
+
+ if ( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->plcInfo.concealment_method, TCX_NONTONAL ) && LT_32( st_fx->plcInfo.nbLostCmpt, 4 ) )
{
waveadj_rec = 1;
move16();
@@ -1003,7 +1008,7 @@ ivas_error amr_wb_dec_fx(
IF( st_fx->bfi )
{
/* calculate another loss frame to fill gap in case of switching frame loss */
- IF( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1041,7 +1046,7 @@ ivas_error amr_wb_dec_fx(
FOR( i = 0; i < tmps; i++ )
{
#ifdef BASOP_NOGLOB
- synth_out_fx[i + delay_comp] = msu_r_sat( L_mult( synth_out_fx[i + delay_comp], alpha ), hHQ_core->old_out_fx[i + nz], add( alpha, -32768 ) );
+ synth_out_fx[add( i, delay_comp )] = msu_r_sat( L_mult( synth_out_fx[add( i, delay_comp )], alpha ), hHQ_core->old_out_fx[add( i, nz )], add( alpha, -32768 ) );
#else
synth_out_fx[i + delay_comp] = msu_r( L_mult( synth_out_fx[i + delay_comp], alpha ), hHQ_core->old_out_fx[i + nz], add( alpha, -32768 ) );
#endif
@@ -1058,7 +1063,7 @@ ivas_error amr_wb_dec_fx(
/* Delay ACELP synthesis by DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS delay */
IF( GE_16( output_frame, L_FRAME16k ) )
{
- tmps = NS2SA_fx2( st_fx->output_Fs, L_sub( DELAY_BWE_TOTAL_NS, DELAY_CLDFB_NS ) );
+ tmps = NS2SA_fx2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS );
Scale_sig( st_fx->prev_synth_buffer_fx, tmps, sub( st_fx->Q_syn2, st_fx->Qprev_synth_buffer_fx ) );
delay_signal( synth_out_fx, output_frame, st_fx->prev_synth_buffer_fx, tmps );
}
@@ -1081,10 +1086,11 @@ ivas_error amr_wb_dec_fx(
/* HP filter */
Scale_sig32( st_fx->L_mem_hp_out_fx, 4, sub( st_fx->Q_syn2, st_fx->Qprev_synth_buffer_fx ) );
st_fx->Qprev_synth_buffer_fx = st_fx->Q_syn2;
+ move16();
hp20( synth_out_fx, 1 /*stride*/, output_frame, st_fx->L_mem_hp_out_fx, L_mult0( output_frame, 50 ) );
/* save synthesis for core switching */
- Copy_Scale_sig( synth_out_fx + NS2SA_fx2( st_fx->output_Fs, L_add( ACELP_LOOK_NS, DELAY_BWE_TOTAL_NS ) ), st_fx->old_synth_sw_fx, NS2SA_fx2( st_fx->output_Fs, L_sub( FRAME_SIZE_NS, L_add( ACELP_LOOK_NS, DELAY_BWE_TOTAL_NS ) ) ), sub( hHQ_core->Q_old_postdec, st_fx->Q_syn2 ) );
+ Copy_Scale_sig( synth_out_fx + NS2SA_fx2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_fx2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), sub( hHQ_core->Q_old_postdec, st_fx->Q_syn2 ) );
{
/* TCX-LTP Postfilter: used in AMR-WB IO to update memories and to avoid discontinuities when the past frame was TCX */
@@ -1121,17 +1127,17 @@ void amr_wb_dec_init_fx(
/* Improvement of unvoiced and audio signals in AMR-WB IO mode */
hAmrwb_IO->UV_cnt_fx = 30;
move16();
- hAmrwb_IO->LT_UV_cnt_fx = shl( 60, 6 );
+ hAmrwb_IO->LT_UV_cnt_fx = ( 60 << 6 );
move16();
set16_fx( hAmrwb_IO->lt_diff_etot_fx, 0, MAX_LT );
hAmrwb_IO->Last_ener_fx = 0;
move16();
- set16_fx( hAmrwb_IO->old_Aq_fx, 0, i_mult( NB_SUBFR, add( M, 1 ) ) );
+ set16_fx( hAmrwb_IO->old_Aq_fx, 0, i_mult( NB_SUBFR, M + 1 ) );
hAmrwb_IO->old_Aq_fx[0] = 16384;
- hAmrwb_IO->old_Aq_fx[add( M, 1 )] = 16384;
- hAmrwb_IO->old_Aq_fx[i_mult( 2, add( M, 1 ) )] = 16384;
- hAmrwb_IO->old_Aq_fx[i_mult( 3, add( M, 1 ) )] = 16384;
+ hAmrwb_IO->old_Aq_fx[M + 1] = 16384;
+ hAmrwb_IO->old_Aq_fx[2 * ( M + 1 )] = 16384;
+ hAmrwb_IO->old_Aq_fx[3 * ( M + 1 )] = 16384;
move16();
move16();
move16();
diff --git a/lib_dec/ari_dec.c b/lib_dec/ari_dec.c
index 334e2419594e315e200da434ad9fd96059d08044..51badb5bce951cde503991e95db31e683f1b8b98 100644
--- a/lib_dec/ari_dec.c
+++ b/lib_dec/ari_dec.c
@@ -39,6 +39,7 @@
#include "options.h"
#include "cnst.h"
#include "prot.h"
+#include "prot_fx.h"
#include "stat_com.h"
#include "basop_util.h"
#include "wmc_auto.h"
diff --git a/lib_dec/ari_dec_fx.c b/lib_dec/ari_dec_fx.c
index 26390d6e0987048fc16d3ae410e083ded3d416e0..8a310b8b882e2e8a723188748f5645337a0bc212 100644
--- a/lib_dec/ari_dec_fx.c
+++ b/lib_dec/ari_dec_fx.c
@@ -7,8 +7,7 @@
#include "options.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*---------------------------------------------------------------
* Ari decode 14 bits routines
@@ -34,6 +33,7 @@ void ari_start_decoding_14bits_fx(
val = L_and( L_deposit_l( get_next_indice( st, cbitsnew ) ), 0xffffL );
s->low = L_deposit_l( 0 );
+ move32();
s->high = L_add( ari_q4new, 1 );
move32();
s->value = val;
@@ -62,6 +62,7 @@ Word16 ari_start_decoding_14bits_prm_fx(
}
}
s->low = L_deposit_l( 0 );
+ move32();
s->high = L_add( ari_q4new, 1 );
move32();
s->value = val;
@@ -354,7 +355,7 @@ static Word16 ari_lookup_pow_fx( Tastat *s, Word16 base )
Word16 k;
range = L_sub( s->high, s->low );
- cum = L_add( L_shl( L_sub( s->value, s->low ), stat_bitsnew ), sub( shl( 1, stat_bitsnew ), 1 ) );
+ cum = L_add( L_shl( L_sub( s->value, s->low ), stat_bitsnew ), ( ( 1 << stat_bitsnew ) - 1 ) );
range_h = extract_l( L_shr( range, 15 ) );
range_l = extract_l( L_and( range, 0x7FFF ) );
@@ -377,11 +378,11 @@ static Word16 ari_lookup_pow_fx( Tastat *s, Word16 base )
{
highlim = testval;
move16();
- pows[k] = mult_r( pows[sub( k, 1 )], pows[sub( k, 1 )] );
+ pows[k] = mult_r( pows[k - 1], pows[k - 1] );
move16();
testval = mult_r( pows[k], base );
- IF( LE_32( L_multi31x16_X2( range_h, range_l, shr( testval, 1 ) ), cum ) ) /* found! big range is [lowlim,testval], (now narrow it down) */
+ IF( LE_32( L_multi31x16_X2( range_h, range_l, testval >> 1 ), cum ) ) /* found! big range is [lowlim,testval], (now narrow it down) */
{
lowlim = testval;
move16();
@@ -397,7 +398,7 @@ static Word16 ari_lookup_pow_fx( Tastat *s, Word16 base )
{
testval = mult_r( highlim, pows[k + 1] );
- IF( LE_32( L_multi31x16_X2( range_h, range_l, shr( testval, 1 ) ), cum ) )
+ IF( LE_32( L_multi31x16_X2( range_h, range_l, testval >> 1 ), cum ) )
{
lowlim = testval;
move16();
diff --git a/lib_dec/ari_hm_dec.c b/lib_dec/ari_hm_dec.c
index e2d5e8de7603ac33715507017bf83b26e7f332c2..fbd863d6fc2d4592f125665a97613d1890bb9053 100644
--- a/lib_dec/ari_hm_dec.c
+++ b/lib_dec/ari_hm_dec.c
@@ -43,7 +43,7 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#ifndef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
* DecodeIndex()
@@ -99,6 +99,7 @@ DecodeIndex_fx(
*PeriodicityIndex = kLtpHmFlag;
move16();
*PeriodicityIndex = s_or( *PeriodicityIndex, get_next_indice_fx( st, NumRatioBits[Bandwidth][LtpPitchIndex] ) );
+ move16();
*PeriodicityIndex = add( *PeriodicityIndex, 1 );
move16();
*PeriodicityIndex = s_or( *PeriodicityIndex, shl( LtpPitchIndex, 9 ) );
@@ -155,9 +156,10 @@ static Word16 tcx_hm_dequantize_gain_fx(
/* safety check in case of bit errors */
test();
- IF( !( LE_16( 0, gain_idx ) && LT_16( gain_idx, shl( 1, kTcxHmNumGainBits ) ) ) )
+ IF( !( 0 <= gain_idx && LT_16( gain_idx, ( 1 << kTcxHmNumGainBits ) ) ) )
{
*gain = 0;
+ move16();
return 1;
}
diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c
index 36710096533d9e2169e90de6382a096e74a37cb3..1d23d827d4d34cec79faa7706e2cca1f9699f447 100644
--- a/lib_dec/arith_coder_dec.c
+++ b/lib_dec/arith_coder_dec.c
@@ -43,8 +43,7 @@
#include "basop_util.h"
#include "basop_proto_func.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------*
* tcx_arith_decode()
@@ -157,17 +156,20 @@ static Word16 tcx_arith_decode_ivas_fx(
/* decode line magnitude */
bp = ari_decode_14bits_pow_ivas( prm, bp, target_bits, &q, &as, exp_k );
- IF( NE_16( q, 0 ) )
+ IF( q )
{
/* line is non-zero, decode sign */
bp = ari_decode_14bits_sign_ivas( prm, bp, target_bits, &s, &as );
q_spectrum[k] = L_mult( q, sub( 3, shl( s, 1 ) ) );
+ move32();
q_spectrum[k] = L_shl( q_spectrum[k], 30 - SPEC_EXP_DEC );
+ move32();
}
ELSE
{
/* line is zero, no sign needed */
q_spectrum[k] = L_deposit_l( 0 );
+ move32();
}
IF( LE_32( as.high, as.low ) )
@@ -242,7 +244,7 @@ void tcx_arith_decode_envelope(
gamma_uw = 1.0f / st->gamma_float;
#define WMC_TOOL_SKIP
- tcx_arith_render_envelope_flt( A_ind, L_frame, L_spec, FL2WORD16( hTcxCfg->preemph_fac_flt ), FL2WORD16( gamma_w ), FL2WORD16( 0.5f * gamma_uw ), env );
+ tcx_arith_render_envelope_ivas( A_ind, L_frame, L_spec, FL2WORD16( hTcxCfg->preemph_fac_flt ), FL2WORD16( gamma_w ), FL2WORD16( 0.5f * gamma_uw ), env );
#undef WMC_TOOL_SKIP
if ( use_hm )
@@ -275,7 +277,7 @@ void tcx_arith_decode_envelope(
}
envelope = (Word16 *) env;
- tcx_arith_scale_envelope_flt( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e );
+ tcx_arith_scale_envelope_ivas( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e );
*arith_bits = tcx_arith_decode( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum );
@@ -331,7 +333,7 @@ void tcx_arith_decode_envelope_ivas_fx(
IF( GT_16( L_spec, N_MAX_ARI ) || ( EQ_16( st->element_mode, EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) ||
( EQ_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE / FRAMES_PER_SEC ) ) ) ) ||
( GT_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE_CPE / FRAMES_PER_SEC ) ) ) ) ||
- ( LE_16( target_bits, 0 ) ) )
+ ( target_bits <= 0 ) )
{
/* this could happen in case of bit errors */
st->BER_detect = 1;
@@ -359,16 +361,16 @@ void tcx_arith_decode_envelope_ivas_fx(
move16();
#define WMC_TOOL_SKIP
- tcx_arith_render_envelope_flt( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env );
+ tcx_arith_render_envelope_ivas( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env );
#undef WMC_TOOL_SKIP
- IF( NE_16( use_hm, 0 ) )
+ IF( use_hm != 0 )
{
IF( NE_16( prm_hm[0], 0 ) )
{
tcx_hm_decode( L_spec, env, target_bits, st->coder_type, prm_hm, tcxltp_pitch, &hm_bits );
- IF( LT_16( hm_bits, 0 ) )
+ IF( hm_bits < 0 )
{
st->BER_detect = 1;
move16();
@@ -381,7 +383,7 @@ void tcx_arith_decode_envelope_ivas_fx(
return;
}
}
- else
+ ELSE
{
hm_bits = 1;
move16();
@@ -404,7 +406,7 @@ void tcx_arith_decode_envelope_ivas_fx(
move16();
/* safety check in case of bit errors */
- IF( LT_16( *arith_bits, 0 ) )
+ IF( *arith_bits < 0 )
{
st->BER_detect = 1;
move16();
diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c
index ee9208b4e9ead5e9844b6d0f43fdee04a922f47e..61bb24b663c8ef8b2e7c0740b4b687290926c4e9 100644
--- a/lib_dec/arith_coder_dec_fx.c
+++ b/lib_dec/arith_coder_dec_fx.c
@@ -7,8 +7,7 @@
#include "options.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/* Returns: number of bits consumed */
#ifdef IVAS_FLOAT_FIXED
@@ -42,7 +41,7 @@ static Word16 tcx_arith_decode_fx(
L_tmp = L_deposit_l( 0 );
FOR( k = 0; k < L_frame; k++ )
{
- IF( EQ_16( envelope[k], 0 ) ) /* safety check in case of bit errors */
+ IF( envelope[k] == 0 ) /* safety check in case of bit errors */
{
set32_fx( q_spectrum, 0, L_frame );
return -1;
@@ -54,11 +53,12 @@ static Word16 tcx_arith_decode_fx(
/* decode line magnitude */
bp = ari_decode_14bits_pow_fx( prm, bp, target_bits, &q, &as, exp_k );
- IF( EQ_16( q, 0 ) )
+ IF( q == 0 )
{
q_spectrum[k] = L_deposit_l( 0 );
+ move32();
}
- IF( NE_16( q, 0 ) ) /* line is non-zero, decode sign */
+ IF( q != 0 ) /* line is non-zero, decode sign */
{
bp = ari_decode_14bits_sign_fx( prm, bp, target_bits, &s, &as );
@@ -77,7 +77,7 @@ static Word16 tcx_arith_decode_fx(
IF( ari_decode_overflow_fx( &as ) )
{
- IF( LT_16( bp, target_bits ) ) /* safety check in case of bit errors */
+ if ( LT_16( bp, target_bits ) ) /* safety check in case of bit errors */
{
bp = -1;
move16();
@@ -92,7 +92,7 @@ static Word16 tcx_arith_decode_fx(
/* noise filling seed */
*nf_seed = extract_l( L_tmp );
-
+ move16();
return bp;
}
@@ -137,7 +137,7 @@ void tcx_arith_decode_envelope_fx(
IF( GT_16( L_spec, N_MAX_ARI ) || ( EQ_16( st->element_mode, EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) ||
( EQ_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE / FRAMES_PER_SEC ) ) ) ) ||
( GT_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE_CPE / FRAMES_PER_SEC ) ) ) ) ||
- LE_16( target_bits, 0 ) )
+ ( target_bits <= 0 ) )
{
/* this could happen in case of bit errors */
st->BER_detect = 1;
@@ -165,13 +165,13 @@ void tcx_arith_decode_envelope_fx(
tcx_arith_render_envelope( A_ind, L_frame, L_spec, tcx_cfg->preemph_fac, gamma_w, gamma_uw, env );
- IF( NE_16( use_hm, 0 ) )
+ IF( use_hm )
{
- IF( NE_16( prm_hm[0], 0 ) )
+ IF( prm_hm[0] )
{
tcx_hm_decode( L_spec, env, target_bits, tcx_cfg->coder_type, prm_hm, tcxltp_pitch, &hm_bits );
- IF( LT_16( hm_bits, 0 ) )
+ IF( hm_bits < 0 )
{
st->BER_detect = 1;
move16();
@@ -211,7 +211,7 @@ void tcx_arith_decode_envelope_fx(
move16();
/* safety check in case of bit errors */
- IF( LT_16( *arith_bits, 0 ) )
+ IF( *arith_bits < 0 )
{
st->BER_detect = 1;
move16();
diff --git a/lib_dec/avq_dec_fx.c b/lib_dec/avq_dec_fx.c
index 68d3e9549cccd2b3915223db003c4b1448e80bf0..e739484b698d4f8af9cab22fb7572f8119ed88c5 100644
--- a/lib_dec/avq_dec_fx.c
+++ b/lib_dec/avq_dec_fx.c
@@ -4,12 +4,11 @@
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*-------------------------------------------------------------------*
* Local prototypes
@@ -60,7 +59,7 @@ void AVQ_demuxdec_fx(
move16();
dummy_bits = 0;
move16();
- svOrder[Nsv - 1] = trgtSvPos;
+ svOrder[sub( Nsv, 1 )] = trgtSvPos;
move16();
svOrder[0] = 0;
move16();
@@ -133,6 +132,7 @@ void AVQ_demuxdec_fx(
DO
{
nq[k] = add( nq[k], 1 );
+ move16();
// IF ( 5 * nq[k] + 4 == bits )
IF( EQ_16( add( add( shl( nq[k], 2 ), nq[k] ), 4 ), bits ) )
@@ -142,7 +142,7 @@ void AVQ_demuxdec_fx(
}
WHILE( get_next_indice_1( st ) );
- IF( EQ_16( add( add( shl( nq[k], 2 ), nq[k] ), 4 ), bits ) ) /* check the overflow */
+ if ( EQ_16( add( add( shl( nq[k], 2 ), nq[k] ), 4 ), bits ) ) /* check the overflow */
{
bits = add( bits, 1 ); /* overflow stop bit */
}
@@ -166,6 +166,7 @@ void AVQ_demuxdec_fx(
IF( GT_16( nq[k], 0 ) )
{
nq[k] = add( nq[k], 1 );
+ move16();
}
/* read codebook indices (rank I and event. Voronoi index kv) */
@@ -174,9 +175,9 @@ void AVQ_demuxdec_fx(
} /* for */
/* Bit Saving Solution */
- IF( GT_16( avq_bit_sFlag, 0 ) && GT_16( bits, 8 ) )
+ IF( ( avq_bit_sFlag > 0 ) && GT_16( bits, 8 ) )
{
- i = svOrder[Nsv - 1];
+ i = svOrder[sub( Nsv, 1 )];
nq[i] = 0;
move16();
bitsMod = bits % 5;
@@ -186,7 +187,7 @@ void AVQ_demuxdec_fx(
move16();
FOR( j = i; j < sub( Nsv, 1 ); j++ )
{
- IF( EQ_16( nq[svOrder[j]], 0 ) )
+ if ( ( nq[svOrder[j]] == 0 ) )
{
nullVec = add( nullVec, 1 );
}
@@ -204,14 +205,14 @@ void AVQ_demuxdec_fx(
test();
test();
test();
- IF( ( GT_16( 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 ) ) ) && EQ_16( nq[svOrder[sub( Nsv, 2 )]], 0 ) ) /* dummy bits */
+ 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 ) ) ) && ( nq[svOrder[sub( Nsv, 2 )]] == 0 ) ) /* dummy bits */
{
dummy_bits = sub( 5, bitsMod );
bits = add( bits, dummy_bits ); /* add dummy bits */
bitsMod = 0;
move16();
}
- ELSE IF( GT_16( nq_est, 4 ) && ( ( EQ_16( bitsMod, 0 ) && GT_16( nullVec, 3 ) && LT_16( nullVec, 6 ) ) || ( EQ_16( bitsMod, 4 ) && EQ_16( nullVec, 5 ) ) ) && EQ_16( nq[svOrder[sub( Nsv, 2 )]], 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[Nsv - 2]] == 0 ) ) /* wasted bits 4, 5 for nq 6,7..*/
{
underflow = 0;
move16();
@@ -252,13 +253,13 @@ void AVQ_demuxdec_fx(
unusedbitsFlag = 0;
move16();
- IF( EQ_16( dummy_bits, 0 ) )
+ IF( ( dummy_bits == 0 ) )
{
test();
test();
test();
test();
- IF( EQ_16( unused_bits_idx, 0 ) && GT_16( bits, BIT_SAVING_LOW_THR ) )
+ IF( ( unused_bits_idx == 0 ) && GT_16( bits, BIT_SAVING_LOW_THR ) )
{
unusedbitsFlag = 1;
move16();
@@ -273,7 +274,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( EQ_16( ( tmp % 5 ), 0 ) )
+ IF( ( ( tmp % 5 ) == 0 ) )
{
nq_est = nq_est;
move16();
@@ -282,7 +283,7 @@ void AVQ_demuxdec_fx(
{
nq_est = add( nq_est, 1 );
}
- IF( EQ_16( nq_est, 1 ) )
+ if ( EQ_16( nq_est, 1 ) )
{
nq_est = 0;
move16();
@@ -291,7 +292,7 @@ void AVQ_demuxdec_fx(
bits = sub( bits, unused_bits_idx );
- IF( NE_16( nq_est, 0 ) )
+ if ( ( nq_est != 0 ) )
{
bits = sub( bits, 1 );
}
@@ -299,11 +300,11 @@ void AVQ_demuxdec_fx(
nq[i] = nq_est;
move16();
/* read codebook indices (rank I and event. Voronoi index kv) */
- read_cv_fx( st, &I[i], &kv[shl( i, 3 )], nq[i], &bits );
+ read_cv_fx( st, &I[i], &kv[i * 8], nq[i], &bits );
bits = sub( bits, dummy_bits );
- IF( NE_16( bitsMod, 4 ) )
+ if ( NE_16( bitsMod, 4 ) )
{
bits = add( bits, bitsMod );
}
@@ -318,7 +319,8 @@ void AVQ_demuxdec_fx(
/* write decoded RE8 vector to decoded subvector #i */
FOR( j = 0; j < 8; j++ )
{
- xriq[add( shl( i, 3 ), j )] = code[j];
+ xriq[add( i * 8, j )] = code[j];
+ move16();
}
}
move16();
@@ -357,7 +359,7 @@ void AVQ_dec_lpc(
/* decode all subvectors */
- FOR( l = sub( Nsv, 1 ); l >= 0; l-- )
+ FOR( l = Nsv - 1; l >= 0; l-- )
{
nq = indx[l]; /* quantizer number (0,2,3..n) */
move16();
@@ -389,8 +391,7 @@ void AVQ_dec_lpc(
FOR( i = 7; i >= 0; i-- )
{
- kv[i] = shl( kv[i], 1 );
- kv[i] = add( kv[i], s_and( ival, 0x01 ) );
+ kv[i] = add( ( kv[i] << 1 ), s_and( ival, 0x01 ) );
move16();
ival = shr( ival, 1 );
}
@@ -442,40 +443,47 @@ static void read_cv_fx(
bits = *nbits;
move16();
/* read codebook indices (rank I and event. Voronoi index kv) */
- IF( EQ_16( nq, 0 ) ) /* Q0 */
+ IF( ( nq == 0 ) ) /* Q0 */
{
/* nothing to read */
}
ELSE IF( LT_16( nq, 5 ) ) /* Q2, Q3, Q4 */
{
*I = get_next_indice( st, shl( nq, 2 ) );
+ move32();
bits = sub( bits, shl( nq, 2 ) );
}
- ELSE IF( EQ_16( s_and( nq, 1 ), 0 ) ) /* Q4 + Voronoi extensions r=1,2,3,... */
+ ELSE IF( ( s_and( nq, 1 ) == 0 ) ) /* Q4 + Voronoi extensions r=1,2,3,... */
{
*I = get_next_indice( st, 16 );
+ move32();
bits = sub( bits, 16 );
order_v = (Word16) sub( shr( nq, 1 ), 2 );
+ move32();
FOR( j = 0; j < 8; j++ )
{
kv[j] = get_next_indice( st, order_v );
+ move16();
}
- bits = sub( bits, shl( order_v, 3 ) );
+ bits = sub( bits, ( shl( order_v, 3 ) ) );
}
ELSE /* Q3 + Voronoi extensions r=1,2,3,... */
{
*I = get_next_indice( st, 12 );
+ move32();
bits = sub( bits, 12 );
order_v = (Word16) sub( shr( nq, 1 ), 1 );
FOR( j = 0; j < 8; j++ )
{
kv[j] = get_next_indice( st, order_v );
+ move32();
}
bits = sub( bits, shl( order_v, 3 ) );
}
*nbits = bits;
+ move16();
return;
}
diff --git a/lib_dec/bass_psfilter.c b/lib_dec/bass_psfilter.c
index b721487fbad77d166dfefe70d090fca0244ecb0b..63e304417487c1c270e297c350d122e1cc935c32 100644
--- a/lib_dec/bass_psfilter.c
+++ b/lib_dec/bass_psfilter.c
@@ -38,8 +38,7 @@
#include "options.h"
#include
#include "prot.h"
-#include "prot_fx2.h"
-#include "prot_fx1.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "cnst.h"
#include "stat_dec.h"
@@ -572,6 +571,20 @@ void addBassPostFilter_ivas_fx(
cldfbAnalysis_ivas_fx( harm_timeIn_fx, tmp_R_fx, tmp_I_fx, samplesToProcess, cldfb );
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ /* now do the subtraction */
+ FOR( i = 0; i < nColToProcess; i++ )
+ {
+ /* loop over low frequency bands */
+ FOR( b = 0; b < maxBand; b++ )
+ {
+ rAnalysis_fx[i][b] = Msub_32_32( rAnalysis_fx[i][b], tmp_R_fx[i][b], weights_fx[b] ); // Qx - 6
+ move32();
+ iAnalysis_fx[i][b] = Msub_32_32( iAnalysis_fx[i][b], tmp_I_fx[i][b], weights_fx[b] ); // Qx - 6
+ move32();
+ }
+ }
+#else
/* now do the subtraction */
FOR( i = 0; i < nColToProcess; i++ )
{
@@ -584,6 +597,7 @@ void addBassPostFilter_ivas_fx(
move32();
}
}
+#endif
return;
}
@@ -715,11 +729,7 @@ Word16 res_bpf_adapt_ivas_fx(
shift = W_norm( W_tmp );
W_tmp = W_shl( W_tmp, shift );
res_hb_nrg = W_extract_h( W_tmp );
- IF( GT_16( add( Q24, shift ), 32 ) )
- {
- res_hb_nrg = L_shr( res_hb_nrg, sub( add( Q24, shift ), 32 ) ); // Q0
- }
-
+ res_hb_nrg = L_shr( res_hb_nrg, sub( add( Q24, shift ), 32 ) ); // Q0
res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv );
res_hb_nrg = L_add( Mpy_32_16_1( res_hb_nrg, STEREO_DFT_BPF_ADAPT_ALPHA_FX ), Mpy_32_16_1( hStereoDft->res_hb_nrg_mem_fx, sub( MAX_16, STEREO_DFT_BPF_ADAPT_ALPHA_FX ) ) );
hStereoDft->res_hb_nrg_mem_fx = res_hb_nrg;
@@ -732,26 +742,29 @@ Word16 res_bpf_adapt_ivas_fx(
{
tmp = L_sub( bpf_error_signal_8k[i], hStereoDft->bpf_error_signal_last_fx );
error_nrg = Madd_32_32( error_nrg, tmp, tmp );
- hStereoDft->bpf_error_signal_last_fx = bpf_error_signal_8k[add( i, sub( STEREO_DFT_L_SUBFR_8k, 1 ) )];
+ hStereoDft->bpf_error_signal_last_fx = bpf_error_signal_8k[add( i, ( STEREO_DFT_L_SUBFR_8k - 1 ) )];
move32();
}
- error_nrg = L_shr( error_nrg, 1 ); // Q0
+ error_nrg = L_shl( error_nrg, 1 ); // Q0
error_nrg = Mpy_32_16_1( error_nrg, 6553 /* 0.2f in Q15 */ ); /* Division by 5 for average value */
/* Form decision variable and apply limit */
IF( LT_32( ( L_shr( error_nrg, 1 ) ), res_hb_nrg ) )
{
- bpf_error_ratio = (Word16) ( L_shl( ( L_shl( error_nrg, Q5 ) / res_hb_nrg ), Q8 ) );
- move16();
+ Word16 temp;
+ bpf_error_ratio = BASOP_Util_Divide3232_Scale( error_nrg, res_hb_nrg, &temp );
+ bpf_error_ratio = shl( bpf_error_ratio, sub( 13, sub( 15, temp ) ) );
}
ELSE
{
- bpf_error_ratio = shl( ONE_IN_Q12, 1 );
+ bpf_error_ratio = ONE_IN_Q14; // Q13
+ move16();
}
- bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( sub( MAX_16, STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) );
+ bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) );
hStereoDft->bpf_error_ratio_mem_fx = bpf_error_ratio;
move16();
res_bpf_flag = (Word16) LT_16( bpf_error_ratio, ONE_IN_Q13 );
+ move16();
return res_bpf_flag;
}
@@ -848,17 +861,17 @@ void bpf_pitch_coherence_ivas_fx(
test();
IF( GT_16( st->clas_dec, UNVOICED_CLAS ) && NE_16( st->element_mode, EVS_MONO ) )
{
- pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[add( nb_subfr, 3 )], st->old_pitch_buf_fx[add( nb_subfr, 2 )] ), L_add( st->old_pitch_buf_fx[nb_subfr], st->old_pitch_buf_fx[add( nb_subfr, 1 )] ) ) );
+ pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( st->old_pitch_buf_fx[nb_subfr], st->old_pitch_buf_fx[nb_subfr + 1] ) ) );
pc = Mpy_32_32( pc, scaled_inv_L_frame );
pcn1 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX );
pcn1 = L_max( L_min( pcn1, 4096 ), 0 );
- pc = L_abs( L_sub( L_add( pitch_buf[sub( nb_subfr, 1 )], pitch_buf[sub( nb_subfr, 2 )] ), L_add( pitch_buf[1], pitch_buf[0] ) ) );
+ pc = L_abs( L_sub( L_add( pitch_buf[nb_subfr - 1], pitch_buf[nb_subfr - 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) );
pc = Mpy_32_32( pc, scaled_inv_L_frame );
pcn2 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX );
pcn2 = L_max( L_min( pcn2, 4096 ), 0 );
- pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[add( nb_subfr, 3 )], st->old_pitch_buf_fx[add( nb_subfr, 2 )] ), L_add( pitch_buf[1], pitch_buf[0] ) ) );
+ pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) );
pc = Mpy_32_32( pc, scaled_inv_L_frame );
pcn3 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX );
pcn3 = L_max( L_min( pcn3, 4096 ), 0 );
diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c
index c8287c00c3afa585800f3b2b1ea72f122d616f3e..3620495a89021918f149668011f652e7f828e026 100644
--- a/lib_dec/bass_psfilter_fx.c
+++ b/lib_dec/bass_psfilter_fx.c
@@ -4,12 +4,11 @@
#include
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "rom_dec.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "rom_dec.h" /* Static table prototypes */
#include "basop_util.h"
/*---------------------------------------------------------------------*
@@ -107,6 +106,7 @@ void bass_psfilter_fx(
Word16 nb_subfr;
Word16 delta_v_stab;
Word16 T_update = 0;
+ move16();
Word16 dist_pit_diff, idx_pit_min, idx_pit_max, vibrato, Track_on;
Word16 loc_pit_max, loc_pit_min, diff_pit;
Word16 TrackOnR, vibratR, alp_tmp;
@@ -158,7 +158,7 @@ void bass_psfilter_fx(
{
FOR( i = L_TRACK_HIST - 1; i > 0; i-- )
{
- hBPF->mem_mean_pit_fx[i] = hBPF->mem_mean_pit_fx[sub( i, 1 )];
+ hBPF->mem_mean_pit_fx[i] = hBPF->mem_mean_pit_fx[i - 1];
move16(); /*Q6 */
}
Ltmp = L_deposit_l( 0 );
@@ -190,7 +190,7 @@ void bass_psfilter_fx(
test();
test();
test();
- IF( NE_16( coder_type, INACTIVE ) && GE_16( diff_pit, shl( 2, 4 ) ) && LT_16( diff_pit, shl( 10, 4 ) ) && GE_16( dist_pit_diff, 3 ) )
+ IF( ( coder_type != INACTIVE ) && GE_16( diff_pit, ( 2 << 4 ) ) && LT_16( diff_pit, ( 10 << 4 ) ) && GE_16( dist_pit_diff, 3 ) )
{
vibrato = 1;
move16();
@@ -221,18 +221,21 @@ void bass_psfilter_fx(
{
/**psf_att = add(mult_r(1638,alp_tmp),mult_r(31130,*psf_att)); //Q15 */
hBPF->psf_att_fx = round_fx( L_mac( L_mult( 1638, alp_tmp ), 31130, hBPF->psf_att_fx ) ); /*Q15 */
+ move16();
}
ELSE
{
/**psf_att = add(mult_r(13107,alp_tmp),mult_r(19661,*psf_att)); //Q15 */
hBPF->psf_att_fx = round_fx( L_mac( L_mult( 13107, alp_tmp ), 19661, hBPF->psf_att_fx ) ); /*Q15 */
+ move16();
}
test();
IF( pitch_buf_fx == NULL || bpf_off )
{
/* do not use BPF for HQ core */
T_update = 80;
- IF( EQ_16( L_frame, L_FRAME8k ) )
+ move16();
+ if ( EQ_16( L_frame, L_FRAME8k ) )
{
T_update = 40;
move16();
@@ -260,6 +263,7 @@ void bass_psfilter_fx(
tmp = add( shr( pitch_buf_fx[i], 1 ), 32 );
}
T_sf[i] = shr( tmp, 6 );
+ move16();
test();
IF( EQ_16( L_frame, L_FRAME16k ) || EQ_16( L_frame, L_FRAME8k ) )
{
@@ -273,7 +277,7 @@ void bass_psfilter_fx(
}
}
- T = T_sf[sub( i, 1 )];
+ T = T_sf[i - 1];
move16();
syn_fx = &syn_buf_fx[add( nbpsf_pit_max, L_frame )];
sigPtr = syn_fx - T;
@@ -295,14 +299,14 @@ void bass_psfilter_fx(
syn_fx = &syn_buf_fx[add( nbpsf_pit_max, i_subfr )];
syn2_fx = &syn2_buf_fx[i_subfr];
- IF( NE_16( T, 0 ) )
+ IF( T )
{
test();
IF( GE_16( T, PIT_MIN ) && Opt_AMR_WB )
{
T = Pit_track_fx( syn_fx, T );
- IF( NE_16( T, T_sf[subfr_pos] ) )
+ if ( NE_16( T, T_sf[subfr_pos] ) )
{
Track_on = 1;
move16();
@@ -366,14 +370,14 @@ void bass_psfilter_fx(
#else
tmp2 = round_fx( L_shl( Lener, exp2 ) );
#endif
- IF( GT_16( tmp, tmp2 ) )
+ if ( GT_16( tmp, tmp2 ) )
{
exp = sub( exp, 1 );
}
exp2 = sub( exp, exp2 ); /* exponent num - exponent denom */
/* gain = corr / ener */
gain = div_s( round_fx( L_shl( Ltmp, exp ) ), tmp2 );
- IF( LT_32( Lcorr, 0 ) )
+ if ( Lcorr < 0 )
{
gain = sub( 0, gain );
}
@@ -416,7 +420,7 @@ void bass_psfilter_fx(
#else
tmp2 = round_fx( L_shl( Lener, exp2 ) );
#endif
- IF( GT_16( tmp, tmp2 ) )
+ if ( GT_16( tmp, tmp2 ) )
{
exp = sub( exp, 1 );
}
@@ -427,7 +431,7 @@ void bass_psfilter_fx(
#else
alpha = shr( div_s( round_fx( L_shl( Ltmp, exp ) ), tmp2 ), exp2 ); /*Q15 */
#endif
- IF( LT_32( Lcorr, 0 ) )
+ if ( Lcorr < 0 )
{
alpha = sub( 0, alpha );
}
@@ -499,7 +503,7 @@ void bass_psfilter_fx(
Lener = L_mac0( Lener, err[i], err[i] );
#endif
}
- exp2 = sub( -1, 2 );
+ exp2 = -1 - 2;
move16();
/* 'Lener' is divided by 2 */
IF( EQ_32( Lener, 2147483647L ) )
@@ -548,7 +552,7 @@ void bass_psfilter_fx(
Track_on = 0;
move16();
- IF( EQ_16( coder_type, AUDIO ) ) /* GSC mode without temporal component */
+ if ( EQ_16( coder_type, AUDIO ) ) /* GSC mode without temporal component */
{
Track_on = 1;
move16();
@@ -601,14 +605,14 @@ void bass_psfilter_fx(
exp2 = norm_l( Lener );
tmp2 = round_fx( L_shl( Lener, exp2 ) );
#endif
- IF( GT_16( tmp, tmp2 ) )
+ if ( GT_16( tmp, tmp2 ) )
{
exp = sub( exp, 1 );
}
exp2 = sub( exp, exp2 ); /* exponent num - exponent denom */
/* gain = corr / ener */
gain = div_s( round_fx( L_shl( Ltmp, exp ) ), tmp2 );
- IF( LT_32( Lcorr, 0 ) )
+ if ( Lcorr < 0 )
{
gain = sub( 0, gain );
}
@@ -647,7 +651,7 @@ void bass_psfilter_fx(
#else
tmp2 = round_fx( L_shl( Lener, exp2 ) );
#endif
- IF( GT_16( tmp, tmp2 ) )
+ if ( GT_16( tmp, tmp2 ) )
{
exp = sub( exp, 1 );
}
@@ -684,14 +688,14 @@ void bass_psfilter_fx(
Lener = L_mac0( Lener, err[i], err[i] );
#endif
}
- exp2 = sub( -1, 2 );
+ exp2 = -1 - 2;
move16();
/* 'Lener' is divided by 2 */
IF( EQ_32( Lener, 2147483647L ) )
{
Lener = L_deposit_h( -32768 );
- sigPtr = err + shr( subfr_len, 1 );
- FOR( i = 0; i < shr( subfr_len, 1 ); i++ )
+ sigPtr = err + subfr_len / 2;
+ FOR( i = 0; i < subfr_len / 2; i++ )
{
Lener0 = L_mult0( sigPtr[i], sigPtr[i] );
#ifdef BASOP_NOGLOB
@@ -729,11 +733,11 @@ void bass_psfilter_fx(
* update memory for next frame
*-------------------------------------------------------*/
- FOR( i = sub( L_TRACK_HIST, 1 ); i > 0; i-- )
+ FOR( i = L_TRACK_HIST - 1; i > 0; i-- )
{
- hBPF->Track_on_hist[i] = hBPF->Track_on_hist[sub( i, 1 )];
+ hBPF->Track_on_hist[i] = hBPF->Track_on_hist[i - 1];
move16();
- hBPF->vibrato_hist[i] = hBPF->vibrato_hist[sub( i, 1 )];
+ hBPF->vibrato_hist[i] = hBPF->vibrato_hist[i - 1];
move16();
}
@@ -801,7 +805,7 @@ static Word16 Pit_track_fx( /* o : Pitch
Lener0 = L_mult0( *v1, *v1 );
Ltmp0 = L_mult0( *v2, *v2 );
Lcorr0 = L_mult0( *v1++, *v2++ );
- FOR( i = 1; i < idiv1616( add( L_HALFR16k, NBPSF_L_EXTRA ), 14 ); i++ )
+ FOR( i = 1; i < ( ( L_HALFR16k + NBPSF_L_EXTRA ) / 14 ); i++ )
{
#ifdef BASOP_NOGLOB
Lener0 = L_mac0_sat( Lener0, *v1, *v1 );
@@ -819,7 +823,7 @@ static Word16 Pit_track_fx( /* o : Pitch
test();
IF( EQ_32( Lener0, 2147483647L ) ||
EQ_32( Ltmp0, 2147483647L ) ||
- EQ_32( Lcorr0, 2147483647L ) || EQ_32( Lcorr0, L_add( -2147483647, -1L ) ) )
+ EQ_32( Lcorr0, 2147483647L ) || EQ_32( Lcorr0, ( -2147483647 - 1L ) ) )
{
v1 -= i;
move16();
@@ -879,7 +883,7 @@ static Word16 Pit_track_fx( /* o : Pitch
Ltmp = L_shl( Ltmp, exp1 );
#endif
/* cn = normalized correlation of pitch/2 */
- IF( GT_32( Ltmp, 2040109466L ) ) /* 0.95f in Q31 */
+ if ( GT_32( Ltmp, 2040109466L ) ) /* 0.95f in Q31 */
{
T = T2;
move16();
@@ -920,6 +924,7 @@ void addBassPostFilter_fx(
Word32 cldfbBufferImag[CLDFB_NO_COL_MAX][20];
nChan = cldfbBank_bpf_Fx->no_channels;
+ move16();
scale1 = scale2 = 0;
move16();
move16();
@@ -947,7 +952,7 @@ void addBassPostFilter_fx(
/* now do the subtraction */
- IF( GT_16( nTimeSlots, 0 ) )
+ IF( nTimeSlots > 0 )
{
/* Find common scale. */
b = s_max( cldfb_scale->lb_scale, scale.lb_scale );
diff --git a/lib_dec/cng_dec.c b/lib_dec/cng_dec.c
index cb202f38b0bfbf68b4e37dbfc060551dfc9ce49e..83854f3aed83cd0b758347800f8cb9d2ffbe4b98 100644
--- a/lib_dec/cng_dec.c
+++ b/lib_dec/cng_dec.c
@@ -39,7 +39,6 @@
#include
#include "ivas_cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
#include "rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c
index d6b5984a61f95175b1656d6a95a200f4677a136d..b612638f95efb0bd592ab0ed810074e75140817b 100644
--- a/lib_dec/cng_dec_fx.c
+++ b/lib_dec/cng_dec_fx.c
@@ -7,8 +7,7 @@
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_cnst.h"
/*Temporary location to be move in prot* when merge is done*/
@@ -83,6 +82,7 @@ void CNG_dec_fx(
TD_CNG_DEC_HANDLE hTdCngDec;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
hTdCngDec = st_fx->hTdCngDec;
@@ -95,16 +95,16 @@ void CNG_dec_fx(
IF( EQ_32( st_fx->core_brate, SID_1k75 ) || EQ_32( st_fx->core_brate, SID_2k40 ) )
{
/* de-quantize the LSF vector */
- IF( NE_16( st_fx->Opt_AMR_WB, 0 ) )
+ IF( st_fx->Opt_AMR_WB != 0 )
{
/* Flt function */
isf_dec_amr_wb_fx( st_fx, Aq, lsf_new, lsp_new );
/* check IF ISPs may trigger too much synthesis energy */
E_LPC_f_isp_a_conversion( lsp_new, Aq_tmp, M );
- enr_new = Enr_1_Az_fx( Aq_tmp, shl( L_SUBFR, 1 ) );
+ enr_new = Enr_1_Az_fx( Aq_tmp, 2 * L_SUBFR );
- IF( GT_16( shr( enr_new, 14 ), 0 ) )
+ IF( ( shr( enr_new, 14 ) > 0 ) )
{
/* Use old LSP vector */
Copy( st_fx->lsp_old_fx, lsp_new, M );
@@ -122,9 +122,9 @@ void CNG_dec_fx(
/* check IF LSPs may trigger too much synthesis energy */
E_LPC_f_lsp_a_conversion( lsp_new, Aq_tmp, M );
- enr_new = Enr_1_Az_fx( Aq_tmp, shl( L_SUBFR, 1 ) );
+ enr_new = Enr_1_Az_fx( Aq_tmp, 2 * L_SUBFR );
- IF( GT_16( shr( enr_new, 14 ), 0 ) )
+ IF( shr( enr_new, 14 ) > 0 )
{
/* Use old LSP vector */
Copy( st_fx->lsp_old_fx, lsp_new, M );
@@ -140,7 +140,7 @@ void CNG_dec_fx(
}
/* Initialize the CNG spectral envelope in case of the very first CNG frame */
- IF( EQ_16( st_fx->first_CNG, 0 ) )
+ IF( st_fx->first_CNG == 0 )
{
Copy( st_fx->lsp_old_fx, st_fx->lspCNG_fx, M );
}
@@ -156,7 +156,7 @@ void CNG_dec_fx(
{
istep = ISTEP_AMR_WB_SID_FX;
move16();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
+ if ( EQ_32( st_fx->core_brate, SID_2k40 ) )
{
istep = ISTEP_SID_FX;
move16();
@@ -165,7 +165,7 @@ void CNG_dec_fx(
/* initialize the energy quantization parameters */
num_bits = 6;
move16();
- IF( EQ_16( st_fx->Opt_AMR_WB, 0 ) )
+ if ( st_fx->Opt_AMR_WB == 0 )
{
num_bits = 7;
move16();
@@ -187,7 +187,7 @@ void CNG_dec_fx(
L_enr_index = tmp1;
move16();
L_enr_index = s_min( L_enr_index, 127 );
- IF( NE_16( st_fx->Opt_AMR_WB, 0 ) )
+ IF( st_fx->Opt_AMR_WB )
{
L_enr_index = s_min( L_enr_index, 63 );
}
@@ -207,7 +207,7 @@ void CNG_dec_fx(
hTdCngDec->old_enr_index = L_enr_index;
move16();
- IF( EQ_16( L_enr_index, 0 ) )
+ if ( !L_enr_index )
{
L_enr_index = -5;
move16();
@@ -222,13 +222,15 @@ void CNG_dec_fx(
/* find the new energy value */
hTdCngDec->Enew_fx = Pow2( ener_int, ener_fra );
+ move32();
IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
{
burst_ho_cnt = get_next_indice( st_fx, 3 ); /* 3bit */
*sid_bw = get_next_indice( st_fx, 1 );
- IF( EQ_16( *sid_bw, 0 ) )
+ move16();
+ IF( *sid_bw == 0 )
{
env_idx[0] = get_next_indice( st_fx, 6 );
move16();
@@ -237,6 +239,7 @@ void CNG_dec_fx(
FOR( i = 0; i < NUM_ENV_CNG; i++ )
{
q_env[i] = L_deposit_l( CNG_details_codebook_fx[env_idx[0]][i] );
+ move32();
}
}
}
@@ -259,8 +262,8 @@ void CNG_dec_fx(
test();
IF( LE_32( st_fx->last_core_brate, SID_2k40 ) )
{
- /* Reset hangover counter IF not first SID period */
- IF( GT_32( st_fx->core_brate, FRAME_NO_DATA ) )
+ /* Reset hangover counter if not first SID period */
+ if ( GT_32( st_fx->core_brate, FRAME_NO_DATA ) )
{
hTdCngDec->num_ho = 0;
move16();
@@ -272,7 +275,7 @@ void CNG_dec_fx(
FOR( i = 0; i < M; i++ )
{
/* AR low-pass filter */
- st_fx->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, st_fx->lspCNG_fx[i] ), 3277, lsp_new[i] );
+ st_fx->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, st_fx->lspCNG_fx[i] ), 32768 - CNG_ISF_FACT_FX, lsp_new[i] );
move16(); /* Q15 (15+15+1-16) */
}
}
@@ -303,7 +306,7 @@ void CNG_dec_fx(
move16();
s_ptr = add( sub( hTdCngDec->ho_circ_ptr, burst_ho_cnt ), 1 );
move16();
- IF( LT_16( s_ptr, 0 ) )
+ IF( s_ptr < 0 )
{
s_ptr = add( s_ptr, hTdCngDec->ho_circ_size );
}
@@ -311,7 +314,8 @@ void CNG_dec_fx(
FOR( ll = burst_ho_cnt; ll > 0; ll-- )
{
hTdCngDec->ho_hist_ptr = add( hTdCngDec->ho_hist_ptr, 1 );
- IF( EQ_16( hTdCngDec->ho_hist_ptr, HO_HIST_SIZE ) )
+ move16();
+ if ( EQ_16( hTdCngDec->ho_hist_ptr, HO_HIST_SIZE ) )
{
hTdCngDec->ho_hist_ptr = 0;
move16();
@@ -330,25 +334,27 @@ void CNG_dec_fx(
Copy( &( hTdCngDec->ho_lsp_circ_fx[i_mult( s_ptr, M )] ), &( hTdCngDec->ho_lsp_hist_fx[i_mult( hTdCngDec->ho_hist_ptr, M )] ), M );
Copy32( &( hTdCngDec->ho_ener_circ_fx[s_ptr] ), &( hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr] ), 1 );
hTdCngDec->ho_sid_bw = L_shl( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
+ move32();
Copy32( &( hTdCngDec->ho_env_circ_fx[i_mult( s_ptr, NUM_ENV_CNG )] ), &( hTdCngDec->ho_env_hist_fx[i_mult( hTdCngDec->ho_hist_ptr, NUM_ENV_CNG )] ), NUM_ENV_CNG );
hTdCngDec->ho_hist_size = add( hTdCngDec->ho_hist_size, 1 );
+ move16();
- IF( GT_16( hTdCngDec->ho_hist_size, HO_HIST_SIZE ) )
+ if ( GT_16( hTdCngDec->ho_hist_size, HO_HIST_SIZE ) )
{
hTdCngDec->ho_hist_size = HO_HIST_SIZE;
move16();
}
s_ptr = add( s_ptr, 1 );
- IF( EQ_16( s_ptr, hTdCngDec->ho_circ_size ) )
+ if ( EQ_16( s_ptr, hTdCngDec->ho_circ_size ) )
{
s_ptr = 0;
move16();
}
}
- IF( GT_16( hTdCngDec->ho_hist_size, 0 ) ) /* can be -1 at init MODE1_DTX_IN_CODEC_B_FIX */
+ IF( hTdCngDec->ho_hist_size > 0 ) /* can be -1 at init MODE1_DTX_IN_CODEC_B_FIX */
{
/* *allow_cn_step |= ( st_fx->ho_ener_hist[st_fx->ho_hist_ptr] > 4.0f * st_fx->lp_ener );*/
L_tmp1 = L_shr( hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr], 2 );
@@ -359,6 +365,7 @@ void CNG_dec_fx(
IF( ( GT_32( L_tmp1, 0 ) && ( st_fx->first_CNG || EQ_16( st_fx->element_mode, EVS_MONO ) ) ) )
{
*allow_cn_step = s_or( *allow_cn_step, 1 );
+ move16();
}
}
IF( EQ_16( last_element_mode, IVAS_CPE_TD ) )
@@ -375,7 +382,7 @@ void CNG_dec_fx(
Copy( &( hTdCngDec->ho_lsp_hist_fx[i_mult( ptr, M )] ), tmp, M );
m1 = 0;
move16();
- IF( EQ_32( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x1 ), 0 ) )
+ IF( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x1 ) == 0 )
{
Copy32( &hTdCngDec->ho_env_hist_fx[i_mult( ptr, NUM_ENV_CNG )], tmp_env, NUM_ENV_CNG );
m1 = 1;
@@ -390,7 +397,7 @@ void CNG_dec_fx(
FOR( k = 1; k < hTdCngDec->ho_hist_size; k++ )
{
ptr = sub( ptr, 1 );
- IF( LT_16( ptr, 0 ) )
+ if ( ptr < 0 )
{
ptr = sub( HO_HIST_SIZE, 1 );
move16();
@@ -424,7 +431,7 @@ void CNG_dec_fx(
L_enr = L_shl( L_tmp1, add( exp, 1 ) ); /* Q6 */
st_fx->lp_ener_fx = L_enr; /* Q6 */
-
+ move32();
set32_fx( max_val, 0, 2 );
set16_fx( max_idx, 0, 2 );
@@ -434,9 +441,9 @@ void CNG_dec_fx(
{
lsp2lsf_fx( &tmp[i_mult( i, M )], lsf_tmp, M, INT_FS_FX );
ftmp_fx = 964;
- move16(); /*X2.56 */
- tmpv = sub( 16384, add( lsf_tmp[sub( M, 1 )], ftmp_fx ) ); /*QX2.56*/
- L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536*/
+ move16(); /*X2.56 */
+ tmpv = sub( 16384, add( lsf_tmp[( M - 1 )], ftmp_fx ) ); /*QX2.56*/
+ L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536*/
}
ELSE
{
@@ -449,10 +456,10 @@ void CNG_dec_fx(
tmpv = sub( lsf_tmp[0], ftmp_fx ); /*QX2.56*/
L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536*/
- FOR( j = 0; j < sub( M, 1 ); j++ )
+ FOR( j = 0; j < M - 1; j++ )
{
- tmpv = sub( sub( lsf_tmp[add( j, 1 )], lsf_tmp[j] ), ftmp_fx ); /*QX2.56*/
- L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536*/
+ tmpv = sub( sub( lsf_tmp[j + 1], lsf_tmp[j] ), ftmp_fx ); /*QX2.56*/
+ L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536*/
}
C[i] = Mpy_32_16_1( L_tmp, 1928 ); /*QX6.5536*/
@@ -496,6 +503,7 @@ void CNG_dec_fx(
tmpv = div_s( 1, sub( m, 1 ) ); /*Q15*/
L_tmp1 = Mpy_32_16_1( L_tmp1, tmpv ); /*Q15*/
lsp_tmp[i] = extract_l( L_tmp1 ); /*Q15*/
+ move16();
}
}
ELSE
@@ -513,6 +521,7 @@ void CNG_dec_fx(
tmpv = div_s( 1, sub( m, 2 ) ); /*Q15*/
L_tmp1 = Mpy_32_16_1( L_tmp1, tmpv ); /*Q15*/
lsp_tmp[i] = extract_l( L_tmp1 ); /*Q15*/
+ move16();
}
}
@@ -528,7 +537,7 @@ void CNG_dec_fx(
#else
dist = add( dist, dev ); /*Q15*/
#endif
- IF( GT_16( dev, max_dev ) )
+ if ( GT_16( dev, max_dev ) )
{
max_dev = dev;
move16();
@@ -550,9 +559,10 @@ void CNG_dec_fx(
{
/* AR low-pass filter */
st_fx->lspCNG_fx[i] = add( mult_r( 26214, lsp_tmp[i] ), mult_r( 6554, lsp_new[i] ) );
+ move16();
}
}
- IF( GT_16( m1, 0 ) )
+ IF( m1 > 0 )
{
FOR( i = 0; i < NUM_ENV_CNG; i++ )
{
@@ -605,14 +615,15 @@ void CNG_dec_fx(
/* Update hangover memory during CNG */
test();
#ifdef BASOP_NOGLOB
- IF( EQ_16( *allow_cn_step, 0 ) && LT_32( hTdCngDec->Enew_fx, L_add_sat( st_fx->lp_ener_fx, L_shr( st_fx->lp_ener_fx, 1 ) ) ) )
+ IF( ( *allow_cn_step == 0 ) && LT_32( hTdCngDec->Enew_fx, L_add_sat( st_fx->lp_ener_fx, L_shr( st_fx->lp_ener_fx, 1 ) ) ) )
#else
IF( *allow_cn_step == 0 && LT_32( hTdCngDec->Enew_fx, L_add( st_fx->lp_ener_fx, L_shr( st_fx->lp_ener_fx, 1 ) ) ) )
#endif
{
/* update the pointer to circular buffer of old LSP vectors */
hTdCngDec->ho_hist_ptr = add( hTdCngDec->ho_hist_ptr, 1 );
- IF( EQ_16( hTdCngDec->ho_hist_ptr, HO_HIST_SIZE ) )
+ move16();
+ if ( EQ_16( hTdCngDec->ho_hist_ptr, HO_HIST_SIZE ) )
{
hTdCngDec->ho_hist_ptr = 0;
move16();
@@ -625,7 +636,7 @@ void CNG_dec_fx(
hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr] = hTdCngDec->Enew_fx;
move32();
test();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) && EQ_16( *sid_bw, 0 ) )
+ IF( EQ_32( st_fx->core_brate, SID_2k40 ) && ( *sid_bw == 0 ) )
{
/* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/
exp = norm_l( hTdCngDec->Enew_fx );
@@ -658,16 +669,20 @@ void CNG_dec_fx(
move32();
}
hTdCngDec->ho_sid_bw = L_shl( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
+ move32();
Copy32( env, &( hTdCngDec->ho_env_hist_fx[i_mult( hTdCngDec->ho_hist_ptr, NUM_ENV_CNG )] ), NUM_ENV_CNG );
}
- ELSE IF( NE_16( *sid_bw, 0 ) )
+ ELSE IF( ( *sid_bw != 0 ) )
{
hTdCngDec->ho_sid_bw = L_shl( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
+ move32();
hTdCngDec->ho_sid_bw = L_or( hTdCngDec->ho_sid_bw, 0x1L );
+ move32();
}
hTdCngDec->ho_hist_size = add( hTdCngDec->ho_hist_size, 1 );
- IF( GT_16( hTdCngDec->ho_hist_size, HO_HIST_SIZE ) )
+ move16();
+ if ( GT_16( hTdCngDec->ho_hist_size, HO_HIST_SIZE ) )
{
hTdCngDec->ho_hist_size = HO_HIST_SIZE;
move16();
@@ -677,7 +692,7 @@ void CNG_dec_fx(
st_fx->last_CNG_L_frame = st_fx->L_frame;
move16();
- IF( NE_32( st_fx->core_brate, SID_1k75 ) )
+ if ( NE_32( st_fx->core_brate, SID_1k75 ) )
{
hTdCngDec->num_ho = m;
move16();
@@ -748,7 +763,8 @@ void swb_CNG_dec_fx(
st_fx->last_vad_fx = 1;
move16();
st_fx->hTdCngDec->burst_cnt = add( st_fx->hTdCngDec->burst_cnt, 1 );
- IF( GT_16( st_fx->hTdCngDec->burst_cnt, 10 ) )
+ move16();
+ if ( GT_16( st_fx->hTdCngDec->burst_cnt, 10 ) )
{
st_fx->hTdCngDec->burst_cnt = 0;
move16();
@@ -788,7 +804,7 @@ void swb_CNG_dec_ivas_fx(
st_fx->last_vad_fx = 1;
move16();
st_fx->hTdCngDec->burst_cnt = add_sat( st_fx->hTdCngDec->burst_cnt, 1 ); // saturation reached?
- IF( GT_16( st_fx->hTdCngDec->burst_cnt, 10 ) )
+ if ( GT_16( st_fx->hTdCngDec->burst_cnt, 10 ) )
{
st_fx->hTdCngDec->burst_cnt = 0;
move16();
@@ -836,18 +852,19 @@ static void shb_CNG_decod_fx(
Word32 L_tmp;
Word16 tmp2;
Word16 allow_cn_step_fx = 0;
+ move16();
Word16 q;
TD_BWE_DEC_HANDLE hBWE_TD;
hBWE_TD = st_fx->hBWE_TD;
- IF( EQ_16( st_fx->bfi, 0 ) )
+ IF( st_fx->bfi == 0 )
{
test();
IF( EQ_32( st_fx->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) )
{
idx_ener_fx = get_next_indice( st_fx, 4 );
- IF( EQ_16( idx_ener_fx, 0 ) )
+ if ( !idx_ener_fx )
{
idx_ener_fx = -15;
move16();
@@ -857,6 +874,7 @@ static void shb_CNG_decod_fx(
/* de-quantization of SHB CNG parameters */
L_tmp = L_mult( idx_ener_fx, 27400 ); /*Q14 */
st_fx->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 295924 ), 6 ) ); /*Q8 */
+ move16();
}
ELSE
{
@@ -864,6 +882,7 @@ static void shb_CNG_decod_fx(
/* de-quantization of SHB CNG parameters */ To be verified
L_tmp = L_mult( idx_ener_fx, 17615 ); /*Q13*/
st_fx->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 147962 ), 5 ) ); /*Q8 */
+ move16();
#endif
}
}
@@ -888,15 +907,16 @@ static void shb_CNG_decod_fx(
IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) )
{
- IF( LT_16( st_fx->shb_dtx_count_fx, 1000 ) )
+ if ( LT_16( st_fx->shb_dtx_count_fx, 1000 ) )
{
st_fx->shb_dtx_count_fx = add( st_fx->shb_dtx_count_fx, 1 );
+ move16();
}
}
E_LPC_lsf_lsp_conversion( shb_lspCNG_fx, tmp_lsp, LPC_SHB_ORDER ); /*Q14*/
E_LPC_f_lsp_a_conversion( tmp_lsp, shb_lpcCNG_fx, LPC_SHB_ORDER );
- Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, add( LPC_SHB_ORDER, 1 ), sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */
+ Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */
#ifdef IVAS_CODE_CNG
// mvr2r(shb_lpcCNG, st->hTdCngDec->shb_lpcCNG, LPC_SHB_ORDER + 1);
@@ -912,12 +932,12 @@ static void shb_CNG_decod_fx(
exp = sub( 30, add( exp, shl( Qsyn, 1 ) ) );
wb_ener_fx = Mpy_32_16( exp, fra, LG10 );
wb_ener16_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /*wb_ener_fx in Q8 */
- IF( EQ_16( st_fx->first_CNG, 0 ) )
+ if ( !st_fx->first_CNG )
{
st_fx->wb_cng_ener_fx = wb_ener16_fx;
move16(); /*Q8 */
}
- IF( GT_16( abs_s( sub( wb_ener16_fx, st_fx->wb_cng_ener_fx ) ), 3072 ) )
+ if ( GT_16( abs_s( sub( wb_ener16_fx, st_fx->wb_cng_ener_fx ) ), 3072 ) )
{
allow_cn_step_fx = 1;
move16();
@@ -936,12 +956,12 @@ static void shb_CNG_decod_fx(
}
test();
test();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && EQ_16( st_fx->bfi, 0 ) )
+ IF( EQ_32( st_fx->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && ( st_fx->bfi == 0 ) )
{
st_fx->last_wb_cng_ener_fx = st_fx->wb_cng_ener_fx;
move16();
- IF( EQ_16( st_fx->first_CNG, 0 ) )
+ if ( !st_fx->first_CNG )
{
st_fx->shb_cng_ener_fx = st_fx->last_shb_cng_ener_fx;
move16();
@@ -949,7 +969,7 @@ static void shb_CNG_decod_fx(
}
gain_fx = sub( st_fx->wb_cng_ener_fx, st_fx->last_wb_cng_ener_fx ); /*8 */
- IF( GT_16( gain_fx, 15 ) )
+ if ( GT_16( gain_fx, 15 ) )
{
gain_fx = 15;
move16();
@@ -959,10 +979,12 @@ static void shb_CNG_decod_fx(
IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st_fx->last_core_brate, SID_2k40 ) )
{
st_fx->shb_cng_ener_fx = add( st_fx->shb_cng_ener_fx, step_fx );
+ move16();
}
ELSE
{
st_fx->shb_cng_ener_fx = add( st_fx->shb_cng_ener_fx, mult( 8192, step_fx ) ); /*Q8 */
+ move16();
}
/* generate white noise excitation */
FOR( i = 0; i < L_FRAME16k; i++ )
@@ -1000,7 +1022,7 @@ static void shb_CNG_decod_fx(
ener_fx = st_fx->shb_cng_ener_fx;
move16(); /*Q8 */
- IF( GT_16( st_fx->trans_cnt_fx, 0 ) )
+ IF( st_fx->trans_cnt_fx > 0 )
{
i = extract_l( L_mult0( st_fx->trans_cnt_fx, 17 ) ); /*Q0 */
#ifdef BASOP_NOGLOB
@@ -1009,13 +1031,14 @@ static void shb_CNG_decod_fx(
ener_fx = add( st_fx->shb_cng_ener_fx, mult( sin_table256_fx[i], sub( st_fx->last_shb_ener_fx, st_fx->shb_cng_ener_fx ) ) ); /*Q8 */
#endif
st_fx->trans_cnt_fx = sub( st_fx->trans_cnt_fx, 1 );
+ move16();
}
tmp = mult( 3277, ener_fx ); /*Q8 */
L_tmp = L_mult( 27213, tmp ); /*Q22, 27213=3.321928 in Q13 */
L_tmp = L_shr( L_tmp, 6 ); /*Q16 */
L_tmp = L_add( L_tmp, 10 << 16 );
- IF( LT_32( L_tmp, 0 ) )
+ if ( L_tmp < 0 )
{
L_tmp = 0;
move32();
@@ -1027,7 +1050,7 @@ static void shb_CNG_decod_fx(
L_tmp = L_shl( Pow2( exp, fra ), 5 ); /*Q5 */
#endif
L_tmp = L_shr( L_tmp, 10 );
- IF( EQ_32( L_tmp, 0 ) )
+ if ( !L_tmp )
{
L_tmp = 1; /*Q5 */
}
@@ -1046,14 +1069,15 @@ static void shb_CNG_decod_fx(
tmp = div_s( fra, tmp ); /*Q15*/
L_tmp = L_deposit_h( tmp ); /*Q31 */
- tmp = -( q + exp1 ) + ( 5 + exp );
+ tmp = sub( add( 5, exp ), add( q, exp1 ) );
L_gain_fx = Isqrt_lc( L_tmp, &tmp ); /*Q31-Qtmp */
#ifdef IVAS_CODE_CNG
st->hTdCngDec->shb_cng_gain = ener_fx;
#endif
FOR( i = 0; i < L_FRAME16k; i++ )
{
- shb_syn16k_fx[i] = extract_l( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), 5 - tmp ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */
+ shb_syn16k_fx[i] = extract_l( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), sub( 5, tmp ) ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */
+ move16();
}
test();
@@ -1066,9 +1090,10 @@ static void shb_CNG_decod_fx(
move32();
}
- FOR( i = 0; i < shl( ALLPASSSECTIONS_STEEP, 1 ); i++ )
+ FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
{
hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i] = shr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i], st_fx->prev_Q_bwe_syn2 );
+ move16();
}
}
GenSHBSynth_fx( shb_syn16k_fx, shb_synth_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, st_fx->L_frame, &( hBWE_TD->syn_dm_phase ) );
@@ -1116,6 +1141,7 @@ static void shb_CNG_decod_ivas_fx(
Word16 fra;
Word32 L_tmp;
Word16 allow_cn_step_fx = 0;
+ move16();
Word16 q;
TD_BWE_DEC_HANDLE hBWE_TD;
hBWE_TD = st->hBWE_TD;
@@ -1136,10 +1162,12 @@ static void shb_CNG_decod_ivas_fx(
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
st->hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 6850 ), 36991 ); // Q11
+ move32();
}
ELSE
{
st->hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 8807 ), 36991 ); // Q11
+ move32();
}
}
}
@@ -1155,11 +1183,13 @@ static void shb_CNG_decod_ivas_fx(
FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
shb_lspCNG_fx[i] = add( mult_r( interp_fx, st->hTdCngDec->lsp_shb_prev_fx[i] ), mult_r( sub( 32767, interp_fx ), st->hTdCngDec->lsp_shb_prev_prev_fx[i] ) ); // Q14
+ move16();
}
IF( LE_16( st->hTdCngDec->shb_dtx_count, 1000 ) )
{
st->hTdCngDec->shb_dtx_count = add( st->hTdCngDec->shb_dtx_count, 1 );
+ move16();
}
E_LPC_lsf_lsp_conversion( shb_lspCNG_fx, tmp_lsp, LPC_SHB_ORDER ); /*Q14*/
@@ -1186,12 +1216,12 @@ static void shb_CNG_decod_ivas_fx(
wb_ener_fx = Mpy_32_16( exp, fra, LG10 );
wb_ener16_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /*wb_ener_fx in Q8 */
Word32 wb_ener32_fx = L_shl( wb_ener16_fx, 3 ); /*wb_ener_fx in Q11 */
- IF( EQ_16( st->first_CNG, 0 ) )
+ if ( EQ_16( st->first_CNG, 0 ) )
{
st->hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx;
move32(); /*Q11 */
}
- IF( GT_32( L_abs( L_sub( wb_ener32_fx, st->hTdCngDec->wb_cng_ener_fx_32 ) ), 24576 ) )
+ if ( GT_32( L_abs( L_sub( wb_ener32_fx, st->hTdCngDec->wb_cng_ener_fx_32 ) ), 24576 ) )
{
allow_cn_step_fx = 1;
move16();
@@ -1207,6 +1237,7 @@ static void shb_CNG_decod_ivas_fx(
tmp = L_sub( wb_ener32_fx, st->hTdCngDec->wb_cng_ener_fx_32 ); /*Q11 */
tmp = Mpy_32_16_1( tmp, 29491 ); /*Q11 */
st->hTdCngDec->wb_cng_ener_fx_32 = L_add( st->hTdCngDec->wb_cng_ener_fx_32, tmp ); /*Q11 */
+ move32();
}
test();
test();
@@ -1215,7 +1246,7 @@ static void shb_CNG_decod_ivas_fx(
st->hTdCngDec->last_wb_cng_ener_fx_32 = st->hTdCngDec->wb_cng_ener_fx_32;
move32();
- IF( EQ_16( st->first_CNG, 0 ) )
+ if ( !st->first_CNG )
{
st->hTdCngDec->shb_cng_ener_fx_32 = st->hTdCngDec->last_shb_cng_ener_fx_32;
move32();
@@ -1223,7 +1254,7 @@ static void shb_CNG_decod_ivas_fx(
}
gain_fx = L_sub( st->hTdCngDec->wb_cng_ener_fx_32, st->hTdCngDec->last_wb_cng_ener_fx_32 ); /*Q11 */
- IF( GT_32( gain_fx, 30720 ) )
+ if ( GT_32( gain_fx, 30720 ) )
{
gain_fx = 30720;
move32();
@@ -1233,10 +1264,12 @@ static void shb_CNG_decod_ivas_fx(
IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st->last_core_brate, SID_2k40 ) )
{
st->hTdCngDec->shb_cng_ener_fx_32 = L_add( st->hTdCngDec->shb_cng_ener_fx_32, step_fx );
+ move32();
}
ELSE
{
st->hTdCngDec->shb_cng_ener_fx_32 = L_add( st->hTdCngDec->shb_cng_ener_fx_32, L_shr( step_fx, 2 ) ); /*Q11 */
+ move32();
}
/* generate white noise excitation */
FOR( i = 0; i < L_FRAME16k; i++ )
@@ -1269,7 +1302,7 @@ static void shb_CNG_decod_ivas_fx(
st->hTdCngDec->trans_cnt = 0;
move16();
test();
- IF( GT_16( st->hTdCngDec->burst_cnt, 3 ) && NE_16( st->last_core, HQ_CORE ) )
+ if ( GT_16( st->hTdCngDec->burst_cnt, 3 ) && NE_16( st->last_core, HQ_CORE ) )
{
st->hTdCngDec->trans_cnt = 5;
move16();
@@ -1283,6 +1316,7 @@ static void shb_CNG_decod_ivas_fx(
i = extract_l( L_mult0( st->hTdCngDec->trans_cnt, 17 ) ); /*Q0 */
ener_fx = L_add( st->hTdCngDec->shb_cng_ener_fx_32, Mpy_32_16_1( L_sub( st->hTdCngDec->last_shb_ener_fx, st->hTdCngDec->shb_cng_ener_fx_32 ), sin_table256_fx[i] ) ); /*Q11 */
st->hTdCngDec->trans_cnt = sub( st->hTdCngDec->trans_cnt, 1 );
+ move16();
}
tmp = L_shr( Mpy_32_16_1( ener_fx, 3277 ), 3 ); /*Q8 */
@@ -1292,7 +1326,7 @@ static void shb_CNG_decod_ivas_fx(
L_tmp = L_mult( 27213, tmp_16 ); /*Q22, 27213=3.321928 in Q13 */
L_tmp = L_shr( L_tmp, 6 ); /*Q16 */
L_tmp = L_add( L_tmp, L_shl( 10, 16 ) );
- IF( LT_32( L_tmp, 0 ) )
+ if ( ( L_tmp < 0 ) )
{
L_tmp = 0;
move32();
@@ -1300,7 +1334,7 @@ static void shb_CNG_decod_ivas_fx(
fra = L_Extract_lc( L_tmp, &exp );
L_tmp = L_shl( Pow2( exp, fra ), 5 ); /*Q5 */
L_tmp = L_shr( L_tmp, 10 );
- IF( EQ_32( L_tmp, 0 ) )
+ if ( !L_tmp )
{
L_tmp = 1;
move32(); /*Q5 */
@@ -1320,13 +1354,14 @@ static void shb_CNG_decod_ivas_fx(
tmp_16 = div_s( fra, tmp_16 ); /*Q15*/
L_tmp = L_deposit_h( tmp_16 ); /*Q31 */
- tmp_16 = -( q + exp1 ) + ( 5 + exp );
+ tmp_16 = sub( add( 5, exp ), add( q, exp1 ) );
L_gain_fx = Isqrt_lc( L_tmp, &tmp_16 ); /*Q31-Qtmp */
st->hTdCngDec->shb_cng_gain_fx_32 = ener_fx;
move32();
FOR( i = 0; i < L_FRAME16k; i++ )
{
- shb_syn16k_fx[i] = extract_l( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), 5 - tmp_16 ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */
+ shb_syn16k_fx[i] = extract_l( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), sub( 5, tmp_16 ) ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */
+ move16();
}
test();
@@ -1342,6 +1377,7 @@ static void shb_CNG_decod_ivas_fx(
FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
{
hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i] = shr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i], st->prev_Q_bwe_syn2 );
+ move16();
}
}
GenSHBSynth_fx( shb_syn16k_fx, shb_synth_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, st->L_frame, &( hBWE_TD->syn_dm_phase ) );
@@ -1381,6 +1417,7 @@ void td_cng_dec_init_fx(
hTdCngDec->old_enr_index = -1;
move16();
hTdCngDec->Enew_fx = L_deposit_l( 0 );
+ move16();
hTdCngDec->last_allow_cn_step = 0;
move16();
#ifdef IVAS_CODE_CNG
@@ -1400,6 +1437,7 @@ void td_cng_dec_init_fx(
hTdCngDec->ho_hist_ptr = -1;
move16();
hTdCngDec->ho_sid_bw = L_deposit_l( 0 );
+ move16();
set16_fx( hTdCngDec->ho_lsp_hist_fx, 0, HO_HIST_SIZE * M );
set32_fx( hTdCngDec->ho_ener_hist_fx, 0, HO_HIST_SIZE );
set32_fx( hTdCngDec->ho_env_hist_fx, 0, HO_HIST_SIZE * NUM_ENV_CNG );
@@ -1530,11 +1568,13 @@ void td_cng_dec_init_ivas_fx(
{
IF( NE_16( st->element_mode, EVS_MONO ) )
{
- hTdCngDec->lsp_shb_prev_fx[i] = div_s( shr( add( i, 1 ), 1 ), LPC_SHB_ORDER + 1 );
+ hTdCngDec->lsp_shb_prev_fx[i] = ivas_lsp_shb_prev_tbl_fx[i];
+ move16();
}
ELSE
{
- hTdCngDec->lsp_shb_prev_fx[i] = div_s( shr( i, 1 ), LPC_SHB_ORDER );
+ hTdCngDec->lsp_shb_prev_fx[i] = lsp_shb_prev_tbl_fx[i];
+ move16();
}
hTdCngDec->lsp_shb_prev_prev_fx[i] = hTdCngDec->lsp_shb_prev_fx[i];
move16();
diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c
index d8c00803e354bee1203f80f1c33751fa38228da4..2ae22c470d57756f157b5c5d56346953ea860f51 100644
--- a/lib_dec/core_dec_init.c
+++ b/lib_dec/core_dec_init.c
@@ -41,7 +41,7 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-----------------------------------------------------------------------*
* open_decoder_LPD()
*
diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c
index 7acc450f9b4f9586521c0fccfbb4a8fce5547c19..960ef827d928e779f6a4cc90ba941acd834e2d4d 100644
--- a/lib_dec/core_dec_init_fx.c
+++ b/lib_dec/core_dec_init_fx.c
@@ -7,9 +7,8 @@
#include
#include
#include "options.h"
-#include "prot_fx1.h"
#include "prot.h" //Can be removed later
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "rom_com.h"
#include "cnst.h" /* for MIN_CNG_LEV */
@@ -55,23 +54,29 @@ void open_decoder_LPD_fx(
#ifndef NEW_IVAS_OPEN_DEC
st->total_brate = total_brate;
+ move32();
#endif
- IF( NE_16( st->codec_mode, MODE1 ) ) /*already updated in MODE1*/
+ if ( NE_16( st->codec_mode, MODE1 ) ) /*already updated in MODE1*/
{
st->fscale_old = st->fscale;
+ move16();
}
st->sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format );
+ move32();
st->fscale = sr2fscale_fx( st->sr_core );
+ move16();
fscaleFB = sr2fscale_fx( st->output_Fs );
/* initializing variables for frame lengths etc. right in the beginning */
st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) );
+ move16();
#ifndef NEW_IVAS_OPEN_DEC
hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) );
+ move16();
#endif
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( st->ini_frame == 0 )
{
st->last_L_frame = st->L_frame_past = st->L_frame;
move16();
@@ -85,9 +90,10 @@ void open_decoder_LPD_fx(
IF( st->hTcxDec != NULL )
{
hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) );
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( st->ini_frame == 0 )
{
st->L_frameTCX_past = st->hTcxDec->L_frameTCX;
+ move16();
}
}
#endif
@@ -114,7 +120,7 @@ void open_decoder_LPD_fx(
IF( ( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, 32000 ) ) ||
( GT_16( st->element_mode, EVS_MONO ) && EQ_16( st->L_frame, L_FRAME16k ) && LE_32( total_brate, MAX_ACELP_BRATE ) ) ||
- ( NE_16( st->tcxonly, 0 ) && ( EQ_32( st->sr_core, 32000 ) || EQ_32( st->sr_core, 16000 ) ) ) )
+ ( ( st->tcxonly != 0 ) && ( EQ_32( st->sr_core, 32000 ) || EQ_32( st->sr_core, 16000 ) ) ) )
{
st->nb_subfr = NB_SUBFR16k;
move16();
@@ -122,15 +128,17 @@ void open_decoder_LPD_fx(
/* (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->total_brate */
st->bits_frame = extract_l( L_shr( Mpy_32_16_1( L_shl( st->total_brate, 1 ), 20972 ), 6 ) ); /* 20972 = 0.01 * 64 * 32768 */
+ move16();
assert( FSCALE_DENOM == 512 );
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 */
assert( st->bits_frame == (int) ( (float) st->L_frame / (float) st->fscale * (float) FSCALE_DENOM / 128.0f * (float) st->total_brate / 100.0f + 0.49f ) );
st->TcxBandwidth = getTcxBandwidth( bwidth );
+ move16();
st->narrowBand = 0;
move16();
- IF( EQ_16( bwidth, NB ) )
+ if ( EQ_16( bwidth, NB ) )
{
st->narrowBand = 1;
move16();
@@ -149,22 +157,28 @@ void open_decoder_LPD_fx(
#endif
i = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( L_FRAME ) );
hTcxDec->pit_max_TCX = extract_l( L_shr( L_mult( st->pit_max, i ), 7 ) );
+ move16();
hTcxDec->pit_min_TCX = extract_l( L_shr( L_mult( st->pit_min, i ), 7 ) );
+ move16();
}
}
ELSE
{
st->pit_res_max = initPitchLagParameters( st->sr_core, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max );
+ move16();
IF( hTcxDec != NULL )
{
i = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( st->L_frame ) );
hTcxDec->pit_max_TCX = extract_l( L_shr( L_mult( st->pit_max, i ), 7 ) );
+ move16();
hTcxDec->pit_min_TCX = extract_l( L_shr( L_mult( st->pit_min, i ), 7 ) );
+ move16();
}
}
- IF( EQ_16( st->ini_frame, 0 ) )
+ if ( !st->ini_frame )
{
st->pit_res_max_past = st->pit_res_max;
+ move16();
}
/*Preemphasis param*/
@@ -200,14 +214,15 @@ void open_decoder_LPD_fx(
st->lpcQuantization = 0;
move16();
test();
- IF( EQ_16( st->tcxonly, 0 ) && LE_32( st->sr_core, INT_FS_16k ) )
+ if ( ( st->tcxonly == 0 ) && LE_32( st->sr_core, INT_FS_16k ) )
{
st->lpcQuantization = 1;
+ move16();
}
st->numlpc = 2;
move16();
- IF( EQ_16( st->tcxonly, 0 ) )
+ if ( st->tcxonly == 0 )
{
st->numlpc = 1;
move16();
@@ -215,11 +230,13 @@ void open_decoder_LPD_fx(
/* Initialize TBE */
st->prev_coder_type = GENERIC;
+ move16();
IF( st->hBWE_TD != NULL )
{
- set16_fx( hBWE_TD->prev_lsf_diff_fx, 16384, sub( LPC_SHB_ORDER, 2 ) );
+ set16_fx( hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 );
hBWE_TD->prev_tilt_para_fx = 0;
- set16_fx( hBWE_TD->cur_sub_Aq_fx, 0, add( M, 1 ) );
+ move16();
+ set16_fx( hBWE_TD->cur_sub_Aq_fx, 0, M + 1 );
}
/*TCX config*/
@@ -229,7 +246,7 @@ void open_decoder_LPD_fx(
st->hTcxCfg->tcx_mdct_window_length_old = st->hTcxCfg->tcx_mdct_window_length;
move16();
init_TCX_config( st->hTcxCfg, st->L_frame, st->fscale, hTcxDec->L_frameTCX, fscaleFB ); // TEMPORARY should be rename to init_TCX_config
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( st->ini_frame == 0 )
{
st->hTcxCfg->tcx_last_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW;
move16();
@@ -238,25 +255,31 @@ void open_decoder_LPD_fx(
/* TCX Offset */
st->hTcxCfg->tcx_offset = shr( st->hTcxCfg->tcx_mdct_window_delay, 1 );
+ move16();
st->hTcxCfg->tcx_offsetFB = shr( st->hTcxCfg->tcx_mdct_window_delayFB, 1 );
+ move16();
/* Initialize FAC */
st->hTcxCfg->lfacNext = sub( st->hTcxCfg->tcx_offset, shr( st->L_frame, 2 ) );
+ move16();
st->hTcxCfg->lfacNextFB = sub( st->hTcxCfg->tcx_offsetFB, shr( hTcxDec->L_frameTCX, 2 ) );
+ move16();
/* set number of coded lines */
st->hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( st->bwidth );
+ move16();
/* TNS in TCX */
st->hTcxCfg->pCurrentTnsConfig = NULL;
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->hIGFDec->infoIGFStopFreq, st->total_brate, st->element_mode, 0 /*is_mct*/ );
}
/*Constraint for adaptive BPF, otherwise parameter estimation and post-processing not time aligned*/
- IF( EQ_16( st->tcxonly, 0 ) )
+ if ( st->tcxonly == 0 )
{
assert( 0 == ( st->hTcxCfg->lfacNext > 0 ? st->hTcxCfg->lfacNext : 0 ) );
}
@@ -280,7 +303,8 @@ void open_decoder_LPD_fx(
#else
- IF( st->hIGFDec != NULL ){
+ if ( st->hIGFDec != NULL )
+ {
PMT( "To be done" )
// IF (!is_init || st->element_mode != IVAS_CPE_MDCT)
//{
@@ -308,20 +332,21 @@ void open_decoder_LPD_fx(
/* Initialize decoder delay */
- IF( NE_16( st->element_mode, IVAS_SCE ) )
+ if ( NE_16( st->element_mode, IVAS_SCE ) )
{
st->flag_cna = 0;
move16();
}
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( st->ini_frame == 0 )
{
st->flag_cna = 0;
st->last_flag_cna = 0;
move16();
+ move16();
}
/* Static vectors to zero */
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( st->ini_frame == 0 )
{
st->last_is_cng = 0;
@@ -360,6 +385,7 @@ void open_decoder_LPD_fx(
{
/* Reset old_synth in case of core sampling rate switching and codec switching*/
test();
+ test();
IF( st->hTcxDec != NULL && ( ( NE_16( st->L_frame, st->last_L_frame ) ) || ( EQ_16( st->last_codec_mode, MODE1 ) ) ) )
{
set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC );
@@ -407,14 +433,14 @@ void open_decoder_LPD_fx(
test();
test();
test();
- IF( ( NE_16( st->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && st->prev_bfi ) ) && EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->last_core, ACELP_CORE ) )
+ IF( ( NE_16( st->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && st->prev_bfi ) ) && EQ_16( st->last_codec_mode, MODE1 ) && ( st->last_core == ACELP_CORE ) )
{
st->last_core_bfi = ACELP_CORE;
move16();
/*PLC*/
#ifndef NEW_IVAS_OPEN_DEC
- IF( NE_16( st->prev_bfi, 0 ) )
+ IF( st->prev_bfi != 0 )
{
PWord16 const *w;
Word16 W1, W2, nz, delay_comp;
@@ -423,7 +449,6 @@ void open_decoder_LPD_fx(
move16();
W2 = shr( st->hTcxCfg->tcx_mdct_window_lengthFB, 1 );
w = st->hTcxCfg->tcx_mdct_windowFB; /*pointer - no need to instrument*/
- move16();
nz = NS2SA_fx2( st->output_Fs, N_ZERO_MDCT_NS );
move16();
@@ -442,13 +467,15 @@ void open_decoder_LPD_fx(
FOR( i = 0; i < W2; i++ )
{
- hHQ_core->old_out_fx[add( i, nz )] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_fx[add( i, nz )] ) );
+ hHQ_core->old_out_fx[i + nz] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), hHQ_core->old_out_fx[i + nz] ) );
+ move16();
}
FOR( ; i < W1; i++ )
{
- hHQ_core->old_out_fx[add( i, nz )] = round_fx( Mpy_32_16_1( L_mult( w[sub( W2, add( 1, sub( i, W2 ) ) )].v.im, w[sub( W2, add( 1, sub( i, W2 ) ) )].v.im ), hHQ_core->old_out_fx[add( i, nz )] ) );
+ hHQ_core->old_out_fx[i + nz] = round_fx( Mpy_32_16_1( L_mult( w[sub( W2, add( 1, sub( i, W2 ) ) )].v.im, w[sub( W2, add( 1, sub( i, W2 ) ) )].v.im ), hHQ_core->old_out_fx[i + nz] ) );
+ move16();
}
- set16_fx( &hHQ_core->old_out_fx[add( W1, nz )], 0, nz );
+ set16_fx( &hHQ_core->old_out_fx[W1 + nz], 0, nz );
lerp( hHQ_core->old_out_fx, hHQ_core->old_out_LB_fx, st->L_frame, hTcxDec->L_frameTCX );
@@ -474,8 +501,8 @@ void open_decoder_LPD_fx(
test();
IF( EQ_16( st->last_codec_mode, MODE2 ) &&
NE_16( st->L_frame, st->last_L_frame ) &&
- ( ( EQ_16( st->m_frame_type, SID_FRAME ) && GT_16( st->last_core, ACELP_CORE ) ) ||
- ( GT_16( st->last_core, ACELP_CORE ) && GT_16( st->core, ACELP_CORE ) ) ||
+ ( ( EQ_16( st->m_frame_type, SID_FRAME ) && ( st->last_core > ACELP_CORE ) ) ||
+ ( ( st->last_core > ACELP_CORE ) && ( st->core > ACELP_CORE ) ) ||
st->prev_bfi ) )
{
lerp( hHQ_core->old_out_LB_fx, hHQ_core->old_out_LB_fx, st->L_frame, st->last_L_frame );
@@ -501,10 +528,10 @@ void open_decoder_LPD_fx(
/*OLA -> zero */
IF( st->hTcxDec != NULL )
{
- set16_fx( hTcxDec->old_syn_Overl, 0, shr( L_FRAME32k, 1 ) ); /*HQ-CORE(bfi)->TCX don't need it*/
- set16_fx( hTcxDec->syn_Overl_TDAC, 0, shr( L_FRAME32k, 1 ) ); /*HQ-CORE(bfi)->TCX don't need it*/
- set16_fx( hTcxDec->syn_Overl_TDACFB, 0, shr( L_FRAME_MAX, 1 ) ); /*HQ-CORE(bfi)->TCX don't need it*/
- set16_fx( hTcxDec->syn_Overl, 0, shr( L_FRAME32k, 1 ) ); /*HQ-CORE(bfi)->TCX don't need it*/
+ set16_fx( hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/
+ set16_fx( hTcxDec->syn_Overl_TDAC, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/
+ set16_fx( hTcxDec->syn_Overl_TDACFB, 0, L_FRAME_MAX / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/
+ set16_fx( hTcxDec->syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/
#if 0
PMT("to be moved to reset_tcx_overl_buf")
#endif
@@ -552,7 +579,7 @@ void open_decoder_LPD_fx(
/* convert quantized LSP vector */
st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 );
- IF( EQ_16( st->tcxonly, 0 ) )
+ IF( st->tcxonly == 0 )
{
lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core );
}
@@ -586,12 +613,12 @@ void open_decoder_LPD_fx(
{
set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC );
}
- set16_fx( st->old_Aq_12_8_fx, 0, add( M, 1 ) );
+ set16_fx( st->old_Aq_12_8_fx, 0, M + 1 );
/*Resamp others memories*/
/*Size of LPC syn memory*/
lerp( st->mem_syn_r + sub( L_SYN_MEM, mem_syn_r_size_old ), st->mem_syn_r + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
- Copy( st->mem_syn_r + sub( L_SYN_MEM, M ), st->mem_syn2_fx, M );
+ Copy( st->mem_syn_r + L_SYN_MEM - M, st->mem_syn2_fx, M );
/*Untouched memories : st->syn */
}
@@ -611,7 +638,9 @@ void open_decoder_LPD_fx(
IF( st->hTcxDec != NULL )
{
hTcxDec->old_synth_len = shl( st->L_frame, 1 );
+ move16();
hTcxDec->old_synth_lenFB = shl( hTcxDec->L_frameTCX, 1 );
+ move16();
}
/* bass pf reset */
st->bpf_gain_param = 0;
@@ -621,18 +650,18 @@ void open_decoder_LPD_fx(
set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX );
}
/* Formant postfilter */
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( st->ini_frame == 0 )
{
/*do nothing*/
}
ELSE IF( EQ_16( st->last_codec_mode, MODE2 ) )
{
- IF( EQ_16( st->tcxonly, 0 ) )
+ IF( st->tcxonly == 0 )
{
- IF( NE_16( st->hPFstat->on, 0 ) )
+ IF( st->hPFstat->on != 0 )
{
- lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
- lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
}
ELSE
{
@@ -644,10 +673,10 @@ void open_decoder_LPD_fx(
move16();
}
}
- ELSE IF( NE_16( st->hPFstat->on, 0 ) )
+ ELSE IF( st->hPFstat->on != 0 )
{
- lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
- lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
}
}
ELSE
@@ -660,14 +689,14 @@ void open_decoder_LPD_fx(
{
st->hPFstat->reset = 1;
move16();
- IF( NE_16( st->hPFstat->on, 0 ) )
+ IF( st->hPFstat->on != 0 )
{
st->hPFstat->reset = 0;
move16();
Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, negate( st->Q_syn ) ); /* WB post_filter mem */
Scale_sig( st->hPFstat->mem_stp, L_SUBFR, negate( st->Q_syn ) ); /* WB post_filter mem */
- lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
- lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
}
}
}
@@ -680,21 +709,21 @@ void open_decoder_LPD_fx(
Scale_sig( st->hPFstat->mem_stp, L_SUBFR, negate( st->Q_syn ) ); /* NB post_filter mem */
}
/*feed last value old_synth as it is used for pre-emphasis mem*/
- IF( st->hTcxDec != NULL )
+ if ( st->hTcxDec != NULL )
{
- hTcxDec->old_synth[sub( hTcxDec->old_synth_len, 1 )] = st->syn[M];
+ hTcxDec->old_synth[hTcxDec->old_synth_len - 1] = st->syn[M];
+ move16();
}
- move16();
- IF( st->hBPF != NULL )
+ if ( st->hBPF != NULL )
{
- hBPF->pst_old_syn_fx[sub( NBPSF_PIT_MAX, 1 )] = st->syn[M];
+ hBPF->pst_old_syn_fx[NBPSF_PIT_MAX - 1] = st->syn[M];
+ move16();
}
- move16();
}
}
/* lsf and lsp initialization */
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( st->ini_frame == 0 )
{
Copy( st->lsp_old_fx, st->lspold_uw, M );
Copy( st->lsf_old_fx, st->lsfold_uw, M );
@@ -707,7 +736,9 @@ void open_decoder_LPD_fx(
st->past_gpit = 0;
move16();
st->past_gcode = L_deposit_l( 0 );
+ move32();
st->gc_threshold_fx = L_deposit_l( 0 );
+ move32();
E_LPC_lsf_lsp_conversion( st->lsf_cng, st->lspold_cng, M );
E_LPC_f_lsp_a_conversion( st->lspold_cng, st->Aq_cng, M );
@@ -719,31 +750,31 @@ void open_decoder_LPD_fx(
Copy( st->lsp_old_fx, st->old_lsp_q_cng, M );
set16_fx( st->mem_syn_unv_back, 0, M );
- st->last_gain_syn_deemph = 16384;
+ st->last_gain_syn_deemph = 32768 / 2;
move16();
st->last_gain_syn_deemph_e = 1;
move16();
test();
- IF( EQ_16( st->last_codec_mode, MODE1 ) || EQ_16( st->ini_frame, 0 ) )
+ IF( EQ_16( st->last_codec_mode, MODE1 ) || st->ini_frame == 0 )
{
/* this assumes that MODE1 fades out in the frequency domain -
otherwise some data from MODE1 would be needed here */
- st->last_concealed_gain_syn_deemph = 16384;
+ st->last_concealed_gain_syn_deemph = 32768 / 2;
move16();
st->last_concealed_gain_syn_deemph_e = 1;
move16();
- IF( hTcxDec != NULL )
+ if ( hTcxDec != NULL )
{
- hTcxDec->conceal_eof_gain = 16384; /*Q14*/
+ hTcxDec->conceal_eof_gain = 32768 / 2; /*Q14*/
move16();
}
}
/* Post processing */
- set16_fx( st->mem_Aq, 0, i_mult( NB_SUBFR16k, add( M, 1 ) ) );
+ set16_fx( st->mem_Aq, 0, i_mult( NB_SUBFR16k, ( M + 1 ) ) );
st->lp_ener_FER_fx = 15360;
move16(); /*60 in Q8*/
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( st->ini_frame == 0 )
{
st->prev_bfi = 0;
move16();
@@ -762,7 +793,7 @@ void open_decoder_LPD_fx(
st->clas_dec = UNVOICED_CLAS;
move16();
move16();
- IF( !st->last_con_tcx )
+ if ( !st->last_con_tcx )
{
move16();
st->old_enr_LP = 0; /* LP filter E of last good voiced frame or local LP filter E in TD TCX PLC */
@@ -786,13 +817,16 @@ void open_decoder_LPD_fx(
st->last_good = UNVOICED_CLAS; /* last good received frame for concealment */
move16();
st->enr_old_fx = L_deposit_l( 0 ); /* energy at the end of the previous frame */
+ move32();
}
st->Mode2_lp_gainc = L_deposit_l( 0 );
+ move32();
st->Mode2_lp_gainp = L_deposit_l( 0 );
+ move32();
st->prev_widow_left_rect = 0;
move16();
- IF( st->hTcxDec != NULL )
+ if ( st->hTcxDec != NULL )
{
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
/* Todo: should be considered for other stereo modes as well */
@@ -810,7 +844,8 @@ void open_decoder_LPD_fx(
#else
hTcxDec->conCngLevelBackgroundTrace = PLC_MIN_CNG_LEV_Q21; /*Q21*/
move16();
- hTcxDec->conNoiseLevelIndex = sub( PLC_MIN_STAT_BUFF_SIZE, 1 );
+ hTcxDec->conNoiseLevelIndex = PLC_MIN_STAT_BUFF_SIZE - 1;
+ move16();
hTcxDec->conCurrLevelIndex = 0;
move16();
hTcxDec->conLastFrameLevel = PLC_MIN_CNG_LEV; /*Q15*/
@@ -823,18 +858,20 @@ void open_decoder_LPD_fx(
move16();
hTcxDec->cummulative_damping_tcx = 32767 /*1.0f Q15*/;
+ move16();
#endif
}
move16();
st->cummulative_damping = 32767 /*1.0f Q15*/;
move16();
- FOR( i = 0; i < add( shl( NB_SUBFR16k, 1 ), 2 ); i++ )
+ FOR( i = 0; i < 2 * NB_SUBFR16k + 2; i++ )
{
st->old_pitch_buf_fx[i] = L_deposit_h( st->pit_min );
+ move16();
}
- FOR( i = 0; i < add( shl( NB_SUBFR16k, 1 ), 2 ); i++ )
+ FOR( i = 0; i < 2 * NB_SUBFR16k + 2; i++ )
{
st->mem_pitch_gain[i] = 16384 /*1.f Q14*/; /*Q14*/
move16();
@@ -842,8 +879,10 @@ void open_decoder_LPD_fx(
st->old_fpitch = L_deposit_h( st->pit_min );
+ move32();
#ifndef NEW_IVAS_OPEN_DEC
st->old_fpitchFB = L_deposit_h( hTcxDec->pit_min_TCX );
+ move32();
#endif
st->rate_switching_init = 1;
move16();
@@ -853,6 +892,7 @@ void open_decoder_LPD_fx(
/* For phase dispersion */
st->dm_fx.prev_gain_code = L_deposit_l( 0 );
+ move32();
set16_fx( st->dm_fx.prev_gain_pit, 0, 6 );
st->dm_fx.prev_state = 0;
move16();
@@ -861,9 +901,10 @@ void open_decoder_LPD_fx(
move16();
/* TCX-LTP */
- IF( hTcxLtpDec != NULL )
+ if ( hTcxLtpDec != NULL )
{
hTcxLtpDec->tcxltp = getTcxLtp( st->sr_core );
+ move16();
}
move16();
@@ -878,12 +919,13 @@ void open_decoder_LPD_fx(
move16();
hTcxLtpDec->tcxltp_pitch_fr = 0;
move16();
- IF( hTcxDec != NULL )
+ if ( hTcxDec != NULL )
{
hTcxDec->tcxltp_last_gain_unmodified = 0;
+ move16();
}
move16();
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( st->ini_frame == 0 )
{
set16_fx( hTcxLtpDec->tcxltp_mem_in, 0, TCXLTP_MAX_DELAY );
set16_fx( hTcxLtpDec->tcxltp_mem_out, 0, L_FRAME48k );
@@ -903,6 +945,7 @@ void open_decoder_LPD_fx(
{
st->lp_error_ener = Mpy_32_16_1( L_shl( hBPF->pst_lp_ener_fx, 8 ), 0x2a86 ); /* convert from 7Q8 10*log10 -> 15Q16, log2 */
+ move32();
}
ELSE
{
@@ -910,7 +953,9 @@ void open_decoder_LPD_fx(
move16();
}
st->mem_error = L_deposit_l( 0 );
+ move32();
st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, total_brate, st->rf_flag );
+ move16();
st->last_ctx_hm_enabled = 0;
move16();
@@ -922,13 +967,13 @@ void open_decoder_LPD_fx(
IF( hTcxDec != NULL )
{
hTcxDec->tcx_lpc_shaped_ari = getTcxLpcShapedAri( total_brate, st->rf_flag, st->element_mode );
-
+ move16();
hTcxDec->envWeighted = 0;
+ move16();
}
- move16();
st->p_bpf_noise_buf = NULL;
- IF( EQ_16( st->tcxonly, 0 ) )
+ if ( st->tcxonly == 0 )
{
st->p_bpf_noise_buf = st->bpf_noise_buf;
}
@@ -964,6 +1009,8 @@ void open_decoder_LPD_fx(
st->enablePlcWaveadjust = 0;
move16();
+ test();
+ test();
IF( st->hTcxDec != NULL && GE_32( st->total_brate, 48000 ) && EQ_16( st->element_mode, EVS_MONO ) )
{
st->enablePlcWaveadjust = 1;
@@ -982,6 +1029,8 @@ void open_decoder_LPD_fx(
PMT("handle to tonalMDCTconceal is missing")
#endif
//#ifdef ADD_IVAS_HTONALMDCTCONC
+ test();
+ test();
IF( /*st->ADD_IVAS_HTONALMDCTCONC != NULL &&*/ !( GT_16( st->element_mode, EVS_MONO ) && NE_16( st->ini_frame, 0 ) && EQ_16( st->tonalMDCTconceal.nSamples, st->hTcxDec->L_frameTCX ) ) )
{
st->tonalMDCTconceal.nScaleFactors = 0;
@@ -998,8 +1047,11 @@ void open_decoder_LPD_fx(
TonalMDCTConceal_Init_ivas_fx( &st->tonalMDCTconceal, hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg );
}
st->last_tns_active = 0;
+ move16();
st->second_last_tns_active = 0;
+ move16();
st->second_last_core = -1;
+ move16();
#ifdef NEW_IVAS_OPEN_DEC
IF( st->hTcxCfg != NULL && NE_16( st->element_mode, EVS_MONO ) )
{
@@ -1050,7 +1102,7 @@ void open_decoder_LPD_fx(
st->hTcxCfg->na_scale = 32767 /*1.0f Q15*/;
move16();
#endif
- IF( hTcxLtpDec != NULL )
+ if ( hTcxLtpDec != NULL )
{
hTcxLtpDec->tcxltp_gain = 0;
move16();
@@ -1080,7 +1132,7 @@ void tcxltp_dec_init_fx(
hTcxLtpDec->tcxltp_pitch_fr = 0;
move16();
- IF( EQ_16( ini_frame, 0 ) )
+ IF( ini_frame == 0 )
{
set16_fx( hTcxLtpDec->tcxltp_mem_in, 0, TCXLTP_MAX_DELAY );
set16_fx( hTcxLtpDec->tcxltp_mem_out, 0, L_FRAME48k );
@@ -1111,8 +1163,7 @@ void acelp_plc_mdct_transition_fx(
Word16 i;
/*PLC*/
- test();
- IF( NE_16( st->prev_bfi, 0 ) && st->hTcxCfg != NULL )
+ IF( st->prev_bfi != 0 && st->hTcxCfg != NULL )
{
W1 = st->hTcxCfg->tcx_mdct_window_lengthFB;
move16();
@@ -1134,13 +1185,15 @@ void acelp_plc_mdct_transition_fx(
FOR( i = 0; i < W2; i++ )
{
- st->hHQ_core->old_out_fx[add( i, nz )] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), st->hHQ_core->old_out_fx[add( i, nz )] ) );
+ st->hHQ_core->old_out_fx[i + nz] = round_fx( Mpy_32_16_1( L_mult( w[i].v.re, w[i].v.re ), st->hHQ_core->old_out_fx[i + nz] ) );
+ move16();
}
FOR( ; i < W1; i++ )
{
- st->hHQ_core->old_out_fx[add( i, nz )] = round_fx( Mpy_32_16_1( L_mult( w[sub( W2, add( 1, sub( i, W2 ) ) )].v.im, w[sub( W2, add( 1, sub( i, W2 ) ) )].v.im ), st->hHQ_core->old_out_fx[add( i, nz )] ) );
+ st->hHQ_core->old_out_fx[i + nz] = round_fx( Mpy_32_16_1( L_mult( w[W2 - 1 - ( i - W2 )].v.im, w[W2 - 1 - ( i - W2 )].v.im ), st->hHQ_core->old_out_fx[i + nz] ) );
+ move16();
}
- set16_fx( &st->hHQ_core->old_out_fx[add( W1, nz )], 0, nz );
+ set16_fx( &st->hHQ_core->old_out_fx[W1 + nz], 0, nz );
lerp( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, st->hTcxDec->L_frameTCX );
Copy( st->hHQ_core->old_out_fx + nz, st->hTcxDec->syn_Overl_TDACFB, shr( st->hTcxDec->L_frameTCX, 1 ) );
@@ -1149,6 +1202,7 @@ void acelp_plc_mdct_transition_fx(
move16();
Copy( st->hHQ_core->old_out_LB_fx + nz, st->hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ) );
st->hHQ_core->Q_old_wtda_LB = st->hHQ_core->Q_old_wtda;
+ move16();
}
return;
@@ -1189,29 +1243,35 @@ void open_decoder_LPD_ivas_fx(
hTcxLtpDec = st->hTcxLtpDec;
hTcxDec = st->hTcxDec;
- IF( NE_16( st->codec_mode, MODE1 ) ) /*already updated in MODE1*/
+ if ( NE_16( st->codec_mode, MODE1 ) ) /*already updated in MODE1*/
{
st->fscale_old = st->fscale;
move16();
}
st->sr_core = getCoreSamplerateMode2( st->element_mode, total_brate, bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format );
+ move16();
st->fscale = sr2fscale_fx( st->sr_core );
+ move16();
fscaleFB = sr2fscale_fx( st->output_Fs );
+ move16();
/* initializing variables for frame lengths etc. right in the beginning */
st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) );
- IF( EQ_16( st->ini_frame, 0 ) )
+ move16();
+ if ( st->ini_frame == 0 )
{
st->last_L_frame = st->L_frame_past = st->L_frame;
move16();
+ move16();
}
IF( st->hTcxDec != NULL )
{
st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) );
+ move16();
st->output_frame_fx = st->hTcxDec->L_frameTCX;
move16();
- IF( EQ_16( st->ini_frame, 0 ) )
+ if ( ( st->ini_frame == 0 ) )
{
st->L_frameTCX_past = st->hTcxDec->L_frameTCX;
move16();
@@ -1233,7 +1293,7 @@ void open_decoder_LPD_ivas_fx(
test();
IF( ( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, 32000 ) ) ||
( GT_16( st->element_mode, EVS_MONO ) && EQ_16( st->L_frame, L_FRAME16k ) && LE_32( total_brate, MAX_ACELP_BRATE ) ) ||
- ( NE_16( st->tcxonly, 0 ) && ( EQ_32( st->sr_core, 32000 ) || EQ_32( st->sr_core, 16000 ) ) ) )
+ ( ( st->tcxonly != 0 ) && ( EQ_32( st->sr_core, 32000 ) || EQ_32( st->sr_core, 16000 ) ) ) )
{
st->nb_subfr = NB_SUBFR16k;
move16();
@@ -1243,14 +1303,16 @@ void open_decoder_LPD_ivas_fx(
st->nb_subfr = NB_SUBFR;
move16();
}
+ move16();
st->bits_frame = extract_l( L_shr( Mpy_32_16_1( L_shl( st->total_brate, 1 ), 20972 ), 6 ) ); /* 20972 = 0.01 * 64 * 32768 */
// assert(FSCALE_DENOM == 512);
// 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 */
// assert(st->bits_frame == (int16_t)(((float)st->L_frame / (float)st->fscale) * (float)FSCALE_DENOM / 128.0f * (float)total_brate / 100.0f + 0.49f));
st->TcxBandwidth = getTcxBandwidth( bwidth );
+ move16();
st->narrowBand = 0;
move16();
- IF( EQ_16( bwidth, NB ) )
+ if ( EQ_16( bwidth, NB ) )
{
st->narrowBand = 1;
move16();
@@ -1259,11 +1321,14 @@ void open_decoder_LPD_ivas_fx(
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
{
st->pit_res_max = initPitchLagParameters( INT_FS_12k8, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max );
+ move16();
IF( hTcxDec != NULL )
{
i = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( L_FRAME ) );
hTcxDec->pit_max_TCX = extract_l( L_shr( L_mult( st->pit_max, i ), 7 ) );
+ move16();
hTcxDec->pit_min_TCX = extract_l( L_shr( L_mult( st->pit_min, i ), 7 ) );
+ move16();
}
}
ELSE
@@ -1277,7 +1342,7 @@ void open_decoder_LPD_ivas_fx(
}
}
- IF( EQ_16( st->ini_frame, 0 ) )
+ if ( ( st->ini_frame == 0 ) )
{
st->pit_res_max_past = st->pit_res_max;
move16();
@@ -1337,7 +1402,7 @@ void open_decoder_LPD_ivas_fx(
move16();
}
- IF( EQ_16( st->tcxonly, 0 ) )
+ IF( ( st->tcxonly == 0 ) )
{
st->numlpc = 1;
move16();
@@ -1353,10 +1418,9 @@ void open_decoder_LPD_ivas_fx(
move16();
IF( st->hBWE_TD != NULL )
{
- set16_fx( hBWE_TD->prev_lsf_diff_fx, 16384, sub( LPC_SHB_ORDER, 2 ) );
+ set16_fx( hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 );
hBWE_TD->prev_tilt_para_fx = 0;
- move16();
- set16_fx( hBWE_TD->cur_sub_Aq_fx, 0, add( M, 1 ) );
+ set16_fx( hBWE_TD->cur_sub_Aq_fx, 0, M + 1 );
}
IF( st->hIGFDec != NULL )
@@ -1378,7 +1442,7 @@ void open_decoder_LPD_ivas_fx(
IF( st->hTECDec != NULL )
{
/*constraint for adaptive bpf, otherwise parameter estimation and post-processing not time aligned*/
- IF( EQ_16( st->tcxonly, 0 ) )
+ if ( ( st->tcxonly == 0 ) )
{
// To be added later
// assert(0 == (st->hTcxCfg->lfacnext > 0 ? st->hTcxCfg->lfacnext : 0));
@@ -1387,12 +1451,12 @@ void open_decoder_LPD_ivas_fx(
resetTecDec_Fx( st->hTECDec );
}
- IF( NE_16( st->element_mode, IVAS_SCE ) )
+ if ( NE_16( st->element_mode, IVAS_SCE ) )
{
st->flag_cna = 0;
move16();
}
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( st->ini_frame == 0 )
{
st->flag_cna = 0;
move16();
@@ -1401,7 +1465,7 @@ void open_decoder_LPD_ivas_fx(
}
/* Static vectors to zero */
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( ( st->ini_frame == 0 ) )
{
st->last_is_cng = 0;
move16();
@@ -1412,13 +1476,13 @@ void open_decoder_LPD_ivas_fx(
IF( st->hTcxDec != NULL )
{
reset_tcx_overl_buf_fx( st->hTcxDec );
- set16_fx( hTcxDec->syn_OverlFB, 0, shr( L_FRAME_MAX, 1 ) );
+ set16_fx( hTcxDec->syn_OverlFB, 0, L_FRAME_MAX / 2 );
set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC );
- set16_fx( hTcxDec->synth_history_fx, 0, add( L_PROT48k, L_FRAME_MAX ) );
+ set16_fx( hTcxDec->synth_history_fx, 0, L_PROT48k + L_FRAME_MAX );
hTcxDec->q_synth_history_fx = 0;
move16();
}
- set16_fx( st->syn, 0, add( M, 1 ) );
+ set16_fx( st->syn, 0, M + 1 );
set16_fx( st->mem_syn_r, 0, L_SYN_MEM );
mem_syn_r_size_old = 0; /* just to avoid MSVC warnings */
@@ -1433,6 +1497,7 @@ void open_decoder_LPD_ivas_fx(
{
/* Reset old_synth in case of core sampling rate switching and Mode 1/2 switching*/
test();
+ test();
IF( st->hTcxDec != NULL && ( NE_16( st->L_frame, st->last_L_frame ) || ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ) )
{
set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC );
@@ -1480,7 +1545,7 @@ void open_decoder_LPD_ivas_fx(
test();
test();
test();
- IF( ( NE_16( st->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && st->prev_bfi ) ) && EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->last_core, ACELP_CORE ) )
+ IF( ( NE_16( st->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && st->prev_bfi ) ) && EQ_16( st->last_codec_mode, MODE1 ) && ( st->last_core == ACELP_CORE ) )
{
/* Switching from Mode 1 ACELP */
st->last_core_bfi = ACELP_CORE;
@@ -1489,13 +1554,17 @@ void open_decoder_LPD_ivas_fx(
{
acelp_plc_mdct_transition_fx( st );
*Q_syn_Overl_TDAC = sub( *Q_fer_samples, 1 );
+ move16();
*Q_syn_Overl = *Q_fer_samples;
move16();
*Q_syn_Overl_TDACFB = sub( *Q_fer_samples, 1 );
+ move16();
*Q_syn_OverlFB = *Q_fer_samples;
move16();
*Q_old_out = sub( *Q_fer_samples, 1 );
+ move16();
*Q_old_outLB = sub( *Q_fer_samples, 1 );
+ move16();
}
}
test();
@@ -1504,8 +1573,8 @@ void open_decoder_LPD_ivas_fx(
test();
test();
IF( EQ_16( st->last_codec_mode, MODE2 ) && NE_16( st->L_frame, st->last_L_frame ) &&
- ( ( EQ_16( st->m_frame_type, SID_FRAME ) && GT_16( st->last_core, ACELP_CORE ) ) ||
- ( GT_16( st->last_core, ACELP_CORE ) && GT_16( st->core, ACELP_CORE ) ) || st->prev_bfi ) )
+ ( ( EQ_16( st->m_frame_type, SID_FRAME ) && ( st->last_core > ACELP_CORE ) ) ||
+ ( ( st->last_core > ACELP_CORE ) && ( st->core > ACELP_CORE ) ) || st->prev_bfi ) )
{
lerp( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, st->last_L_frame );
}
@@ -1527,7 +1596,7 @@ void open_decoder_LPD_ivas_fx(
st->tilt_code_fx = TILT_CODE;
move16();
set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC );
- set16_fx( st->syn, 0, add( 1, M ) );
+ set16_fx( st->syn, 0, 1 + M );
set16_fx( st->mem_syn2_fx, 0, M );
/*OLA -> zero */
@@ -1579,6 +1648,7 @@ void open_decoder_LPD_ivas_fx(
/* convert quantized LSP vector */
st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 );
+ move16();
IF( EQ_16( st->tcxonly, 0 ) )
{
lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core );
@@ -1612,12 +1682,12 @@ void open_decoder_LPD_ivas_fx(
{
set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC );
}
- set16_fx( st->old_Aq_12_8_fx, 0, add( M, 1 ) );
+ set16_fx( st->old_Aq_12_8_fx, 0, M + 1 );
/*Resamp others memories*/
/*Size of LPC syn memory*/
lerp( st->mem_syn_r + sub( L_SYN_MEM, mem_syn_r_size_old ), st->mem_syn_r + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
- Copy( st->mem_syn_r + sub( L_SYN_MEM, M ), st->mem_syn2_fx, M );
+ Copy( st->mem_syn_r + L_SYN_MEM - M, st->mem_syn2_fx, M );
}
/* update of lsf_old only needed in BASOP */
/* ELSE IF( !st->tcxonly && (st->L_frame == L_FRAME16k) && (st->last_total_brate > ACELP_32k) ) */
@@ -1627,7 +1697,7 @@ void open_decoder_LPD_ivas_fx(
}
test();
test();
- IF( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && NE_16( st->ini_frame, 0 ) )
+ if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && ( st->ini_frame != 0 ) )
{
st->rate_switching_reset = 1;
move16();
@@ -1648,7 +1718,7 @@ void open_decoder_LPD_ivas_fx(
}
/* Formant postfilter */
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( ( st->ini_frame == 0 ) )
{
/* do nothing */
}
@@ -1658,8 +1728,8 @@ void open_decoder_LPD_ivas_fx(
{
IF( st->hPFstat->on )
{
- lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
- lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
}
ELSE
{
@@ -1672,8 +1742,8 @@ void open_decoder_LPD_ivas_fx(
}
ELSE IF( st->hPFstat->on )
{
- lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
- lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
}
}
ELSE
@@ -1687,7 +1757,7 @@ void open_decoder_LPD_ivas_fx(
{
st->hPFstat->reset = 1;
move16();
- IF( NE_16( st->hPFstat->on, 0 ) )
+ IF( st->hPFstat->on != 0 )
{
st->hPFstat->reset = 0;
move16();
@@ -1695,8 +1765,8 @@ void open_decoder_LPD_ivas_fx(
// Scale_sig(st->hPFstat->mem_pf_in, L_SUBFR, negate(st->Q_syn)); /* WB post_filter mem */
// Scale_sig(st->hPFstat->mem_stp, L_SUBFR, negate(st->Q_syn)); /* WB post_filter mem */
//--------------
- lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
- lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
}
}
}
@@ -1711,19 +1781,21 @@ void open_decoder_LPD_ivas_fx(
//}
//------------------
/*feed last value old_synth as it is used for pre-emphasis mem*/
- IF( st->hTcxDec != NULL )
+ if ( st->hTcxDec != NULL )
{
- st->hTcxDec->old_synth[sub( st->hTcxDec->old_synth_len, 1 )] = st->syn[M];
+ st->hTcxDec->old_synth[st->hTcxDec->old_synth_len - 1] = st->syn[M];
+ move16();
}
- IF( st->hBPF != NULL )
+ if ( st->hBPF != NULL )
{
- st->hBPF->pst_old_syn_fx[sub( NBPSF_PIT_MAX, 1 )] = st->syn[M];
+ st->hBPF->pst_old_syn_fx[NBPSF_PIT_MAX - 1] = st->syn[M];
+ move16();
}
}
}
/* lsf and lsp initialization */
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( ( st->ini_frame == 0 ) )
{
Copy( st->lsp_old_fx, st->lspold_uw, M );
Copy( st->lsf_old_fx, st->lsfold_uw, M );
@@ -1735,7 +1807,9 @@ void open_decoder_LPD_ivas_fx(
st->past_gpit = 0;
move16();
st->past_gcode = L_deposit_l( 0 );
+ move32();
st->gc_threshold_fx = L_deposit_l( 0 );
+ move32();
E_LPC_lsf_lsp_conversion( st->lsf_cng, st->lspold_cng, M );
E_LPC_f_lsp_a_conversion( st->lspold_cng, st->Aq_cng, M );
@@ -1746,22 +1820,23 @@ void open_decoder_LPD_ivas_fx(
Copy( st->lsp_old_fx, st->lsp_q_cng, M );
Copy( st->lsp_old_fx, st->old_lsp_q_cng, M );
set16_fx( st->mem_syn_unv_back, 0, M );
- st->last_gain_syn_deemph = 16384; /* 1.f Q14*/
- test();
- IF( EQ_16( st->last_codec_mode, MODE1 ) || EQ_16( st->ini_frame, 0 ) )
+ st->last_gain_syn_deemph = 32768 / 2; /* 1.f Q14*/
+
+ IF( EQ_16( st->last_codec_mode, MODE1 ) || ( st->ini_frame == 0 ) )
{
/* this assumes that MODE1 fades out in the frequency domain -
otherwise some data from MODE1 would be needed here */
- st->last_concealed_gain_syn_deemph = 16384;
+ st->last_concealed_gain_syn_deemph = 32768 / 2;
+ move16();
st->last_concealed_gain_syn_deemph_e = 1;
move16();
- IF( hTcxDec != NULL )
+ if ( hTcxDec != NULL )
{
- hTcxDec->conceal_eof_gain = 16384; /*Q14*/
+ hTcxDec->conceal_eof_gain = 32768 / 2; /*Q14*/
}
}
/* Post processing */
- set16_fx( st->mem_Aq, 0, i_mult( NB_SUBFR16k, add( M, 1 ) ) );
+ set16_fx( st->mem_Aq, 0, i_mult( NB_SUBFR16k, ( M + 1 ) ) );
st->lp_ener_FER_fx = 15360; /*60.0f Q8*/
move16();
@@ -1771,7 +1846,7 @@ void open_decoder_LPD_ivas_fx(
move16();
st->last_core_bfi = -1;
move16();
- IF( st->hTcxDec != NULL )
+ if ( st->hTcxDec != NULL )
{
hTcxDec->tcxConceal_recalc_exc = 0;
move16();
@@ -1798,7 +1873,7 @@ void open_decoder_LPD_ivas_fx(
st->clas_dec = UNVOICED_CLAS;
move16();
- IF( !st->last_con_tcx )
+ if ( !st->last_con_tcx )
{
st->old_enr_LP = 0;
move16(); /* LP filter E of last good voiced frame or local LP filter E in TD TCX PLC */
@@ -1819,11 +1894,16 @@ void open_decoder_LPD_ivas_fx(
st->last_good = UNVOICED_CLAS;
move16(); /* last good received frame for concealment */
st->enr_old_fx = L_deposit_l( 0 ); /* energy at the end of the previous frame */
+ move32();
}
st->Mode2_lp_gainc = L_deposit_l( 0 );
+ move32();
st->Mode2_lp_gainp = L_deposit_l( 0 );
+ move32();
st->lp_gainc_fx = (Word16) L_deposit_l( 0 );
+ move16();
st->lp_gainp_fx = (Word16) L_deposit_l( 0 );
+ move16();
IF( st->hTcxDec != NULL )
{
@@ -1834,17 +1914,20 @@ void open_decoder_LPD_ivas_fx(
test();
IF( is_init || MCT_flag || !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( st->element_mode, last_element_mode ) ) )
{
- st->hTcxDec->NoiseLevelIndex_bfi = sub( PLC_MIN_STAT_BUFF_SIZE, 1 );
+ st->hTcxDec->NoiseLevelIndex_bfi = PLC_MIN_STAT_BUFF_SIZE - 1;
+ move16();
st->hTcxDec->CurrLevelIndex_bfi = 0;
+ move16();
st->hTcxDec->LastFrameLevel_bfi_fx = PLC_MIN_CNG_LEV;
+ move16();
set16_fx( st->hTcxDec->conNoiseLevelMemory, PLC_MIN_CNG_LEV, PLC_MIN_STAT_BUFF_SIZE );
set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE );
st->hTcxDec->cummulative_damping_tcx = 32767 /*1.0f Q15*/;
-
+ move16();
hTcxDec->conCngLevelBackgroundTrace = PLC_MIN_CNG_LEV_Q21; /*Q21*/
move16();
- hTcxDec->conNoiseLevelIndex = sub( PLC_MIN_STAT_BUFF_SIZE, 1 );
+ hTcxDec->conNoiseLevelIndex = PLC_MIN_STAT_BUFF_SIZE - 1;
move16();
hTcxDec->conCurrLevelIndex = 0;
move16();
@@ -1864,17 +1947,19 @@ void open_decoder_LPD_ivas_fx(
st->cummulative_damping = 32767 /*1.0f Q15*/;
move16();
- FOR( i = 0; i < add( shl( NB_SUBFR16k, 1 ), 2 ); i++ )
+ FOR( i = 0; i < 2 * NB_SUBFR16k + 2; i++ )
{
st->old_pitch_buf_fx[i] = L_deposit_h( st->pit_min );
+ move32();
}
- FOR( i = 0; i < add( shl( NB_SUBFR16k, 1 ), 2 ); i++ )
+ FOR( i = 0; i < 2 * NB_SUBFR16k + 2; i++ )
{
- st->mem_pitch_gain[i] = 16384 /*1.f Q14*/;
- move16(); /*Q14*/
+ st->mem_pitch_gain[i] = 16384 /*1.f Q14*/; /*Q14*/
+ move16();
}
st->old_fpitch = L_deposit_h( st->pit_min );
+ move32();
st->rate_switching_init = 1;
move16();
@@ -1883,10 +1968,12 @@ void open_decoder_LPD_ivas_fx(
/* For phase dispersion */
st->dm_fx.prev_gain_code = L_deposit_l( 0 );
+ move32();
set16_fx( st->dm_fx.prev_gain_pit, 0, 6 );
st->dm_fx.prev_state = 0;
move16();
st->voice_fac = -1;
+ move16();
/* TCX-LTP */
IF( hTcxLtpDec != NULL )
@@ -1898,9 +1985,10 @@ void open_decoder_LPD_ivas_fx(
IF( hTcxDec != NULL )
{
st->old_fpitchFB = L_deposit_h( hTcxDec->pit_min_TCX );
+ move32();
test();
test();
- IF( EQ_16( st->ini_frame, 0 ) || ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) )
+ IF( ( st->ini_frame == 0 ) || ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) )
{
hTcxDec->tcxltp_last_gain_unmodified = 0;
move16();
@@ -1908,7 +1996,7 @@ void open_decoder_LPD_ivas_fx(
/* TCX */
hTcxDec->tcx_lpc_shaped_ari = getTcxLpcShapedAri( total_brate, st->rf_flag, st->element_mode );
-
+ move16();
hTcxDec->envWeighted = 0;
move16();
}
@@ -1916,6 +2004,7 @@ void open_decoder_LPD_ivas_fx(
IF( st->hBPF != NULL )
{
st->lp_error_ener = Mpy_32_16_1( L_shl( hBPF->pst_lp_ener_fx, 8 ), 0x2a86 ); /* convert from 7Q8 10*log10 -> 15Q16, log2 */
+ move32();
hBPF->pst_mem_deemp_err_fx = 0;
move16();
}
@@ -1990,7 +2079,7 @@ void open_decoder_LPD_ivas_fx(
test();
test();
test();
- IF( st->hTonalMDCTConc != NULL && !( GT_16( st->element_mode, EVS_MONO ) && NE_16( st->ini_frame, 0 ) && EQ_16( st->hTonalMDCTConc->nSamples, st->hTcxDec->L_frameTCX ) ) )
+ IF( st->hTonalMDCTConc != NULL && !( GT_16( st->element_mode, EVS_MONO ) && ( st->ini_frame != 0 ) && EQ_16( st->hTonalMDCTConc->nSamples, st->hTcxDec->L_frameTCX ) ) )
{
st->hTonalMDCTConc->nScaleFactors = 0;
move16();
@@ -2014,7 +2103,18 @@ void open_decoder_LPD_ivas_fx(
IF( st->hTcxCfg != NULL && NE_16( st->element_mode, EVS_MONO ) )
{
- st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( is_init ? total_brate : L_mult( st->bits_frame_nominal, ( FRAMES_PER_SEC >> 1 ) ), st->igf, st->element_mode );
+ Word32 gettns_temp;
+ IF( is_init )
+ {
+ gettns_temp = total_brate;
+ move32();
+ }
+ ELSE
+ {
+ gettns_temp = L_mult( st->bits_frame_nominal, ( FRAMES_PER_SEC >> 1 ) );
+ }
+ st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( gettns_temp, st->igf, st->element_mode );
+ move16();
}
IF( hTcxDec != NULL )
{
diff --git a/lib_dec/core_dec_reconf.c b/lib_dec/core_dec_reconf.c
index 13aa708dc4a76c26a3fbcdf0cd7f358ca3b36178..2599303f315b8e5562b5c9759096cbbfa1e67466 100644
--- a/lib_dec/core_dec_reconf.c
+++ b/lib_dec/core_dec_reconf.c
@@ -40,7 +40,7 @@
#include "rom_com.h"
#include "rom_dec.h"
#include "wmc_auto.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#ifndef IVAS_FLOAT_FIXED
/*---------------------------------------------------------------------*
* reconfig_decoder_LPD_ivas()
diff --git a/lib_dec/core_dec_reconf_fx.c b/lib_dec/core_dec_reconf_fx.c
index 5682809484e7700f131eb4c1c3bb02c6649e6e13..13ddbe6f23606e918cc97fb9194f1ddf86c9930e 100644
--- a/lib_dec/core_dec_reconf_fx.c
+++ b/lib_dec/core_dec_reconf_fx.c
@@ -6,8 +6,7 @@
#include
#include "options.h"
#include "basop_util.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
@@ -65,20 +64,22 @@ void reconfig_decoder_LPD_ivas_fx(
IF( NE_16( st->element_mode, IVAS_SCE ) )
{
st->flag_cna = getCnaPresent_fx( st->element_mode, st->element_brate, total_brate, bwidth );
+ move16();
}
/* TCX-LTP */
IF( hTcxLtpDec != NULL )
{
hTcxLtpDec->tcxltp = getTcxLtp( st->sr_core );
+ move16();
}
- move16();
/*Scale TCX for non-active frames to adjust loudness with ACELP*/
IF( st->hTcxCfg != NULL )
{
Word16 i;
st->hTcxCfg->na_scale = 32767 /*1.0f Q15*/;
+ move16();
test();
IF( ( LT_16( bwidth, SWB ) ) && !( st->tcxonly ) )
{
@@ -90,7 +91,7 @@ void reconfig_decoder_LPD_ivas_fx(
( GE_32( total_brate, scaleTcxTable[i].bitrateFrom ) ) &&
( LT_32( total_brate, scaleTcxTable[i].bitrateTo ) ) )
{
- IF( st->rf_flag )
+ if ( st->rf_flag )
{
i = sub( i, 1 );
}
@@ -102,7 +103,7 @@ void reconfig_decoder_LPD_ivas_fx(
}
}
/*if its not the first frame resample overlap buffer to new sampling rate */
- IF( NE_16( st->ini_frame, 0 ) )
+ IF( ( st->ini_frame != 0 ) )
{
test();
test();
@@ -135,7 +136,7 @@ void reconfig_decoder_LPD_ivas_fx(
lerp( hTcxDec->syn_Overl, hTcxDec->syn_Overl, newLen, oldLen );
test();
- IF( st->prev_bfi && EQ_16( st->last_core_bfi, ACELP_CORE ) )
+ IF( st->prev_bfi && ( st->last_core_bfi == ACELP_CORE ) )
{
lerp( hTcxDec->syn_Overl_TDAC, hTcxDec->syn_Overl_TDAC, newLen, oldLen );
}
@@ -177,14 +178,15 @@ void reconfig_decoder_LPD_ivas_fx(
IF( GT_16( st->element_mode, IVAS_SCE ) )
{
lowrate_tcxlpc_max_br = LOWRATE_TCXLPC_MAX_BR_CPE;
+ move32();
}
hTcxDec->enableTcxLpc = EQ_16( st->numlpc, 1 ) && EQ_16( st->lpcQuantization, 1 ) && ( LE_32( total_brate, lowrate_tcxlpc_max_br ) /*LOWRATE_TCXLPC_MAX_BR*/ || st->rf_flag );
+ move16();
- IF( EQ_16( st->ini_frame, 0 ) )
+ IF( ( st->ini_frame == 0 ) )
{
hTcxDec->envWeighted = 0;
move16();
- move16();
}
return;
@@ -250,15 +252,15 @@ void reconfig_decoder_LPD_fx(
IF( NE_16( st->element_mode, IVAS_SCE ) )
{
st->flag_cna = (Word8) getCnaPresent_fx( st->element_mode, st->element_brate, total_brate, bwidth );
+ move16();
}
- move16();
/* TCX-LTP */
IF( hTcxLtpDec != NULL )
{
hTcxLtpDec->tcxltp = getTcxLtp( st->sr_core );
+ move16();
}
- move16();
IF( st->hTcxCfg != NULL )
{
@@ -282,6 +284,7 @@ void reconfig_decoder_LPD_fx(
IF( st->rf_flag )
{
i = sub( i, 1 );
+ move16();
}
st->hTcxCfg->na_scale = scaleTcxTable[i].scale;
move16();
@@ -292,7 +295,7 @@ void reconfig_decoder_LPD_fx(
}
/*if its not the first frame resample overlap buffer to new sampling rate */
- IF( NE_16( st->ini_frame, 0 ) )
+ IF( ( st->ini_frame != 0 ) )
{
test();
test();
@@ -372,6 +375,7 @@ void reconfig_decoder_LPD_fx(
move16();
}
hTcxDec->enableTcxLpc = EQ_16( st->numlpc, 1 ) && EQ_16( st->lpcQuantization, 1 ) && ( LE_32( total_brate, lowrate_tcxlpc_max_br ) /*LOWRATE_TCXLPC_MAX_BR*/ || st->rf_flag );
+ move16();
IF( EQ_16( st->ini_frame, 0 ) )
{
hTcxDec->envWeighted = 0;
diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c
index 2316e9c096a242e91f89b3700f40f46aadab2afa..835b930979f92a40ba5b5da56854fe5a7c981c80 100644
--- a/lib_dec/core_dec_switch_fx.c
+++ b/lib_dec/core_dec_switch_fx.c
@@ -6,8 +6,7 @@
#include
#include "options.h"
#include "basop_util.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
// Temporarily added
@@ -47,7 +46,7 @@ void mode_switch_decoder_LPD_fx(
bSwitchFromAmrwbIO = 0;
move16();
- IF( EQ_16( st->last_core, AMR_WB_CORE ) )
+ if ( EQ_16( st->last_core, AMR_WB_CORE ) )
{
bSwitchFromAmrwbIO = 1;
move16();
@@ -60,6 +59,7 @@ void mode_switch_decoder_LPD_fx(
/* set number of coded lines */
st->hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( bwidth );
+ move16();
test();
test();
IF( ( ( GE_16( bwidth, WB ) ) && ( EQ_16( fscale, 640 ) ) && ( EQ_16( fscale, st->fscale ) ) ) )
@@ -67,7 +67,7 @@ void mode_switch_decoder_LPD_fx(
test();
test();
test();
- IF( ( ( GT_32( total_brate, 32000 ) ) && ( EQ_16( st->tcxonly, 0 ) ) ) || ( ( LE_32( total_brate, 32000 ) ) && ( NE_16( st->tcxonly, 0 ) ) ) )
+ IF( ( ( GT_32( total_brate, 32000 ) ) && ( ( st->tcxonly == 0 ) ) ) || ( ( LE_32( total_brate, 32000 ) ) && ( ( st->tcxonly != 0 ) ) ) )
{
switchWB = 1;
move16();
@@ -75,17 +75,19 @@ void mode_switch_decoder_LPD_fx(
}
test();
- IF( GT_16( st->last_L_frame, L_FRAME16k ) && LE_32( total_brate, ACELP_32k ) )
+ if ( GT_16( st->last_L_frame, L_FRAME16k ) && LE_32( total_brate, ACELP_32k ) )
{
switchWB = 1;
move16();
}
st->igf = getIgfPresent_fx( st->element_mode, total_brate, bwidth, st->rf_flag );
+ move16();
IF( st->hIGFDec != NULL )
{
st->hIGFDec->infoIGFStopFreq = -1;
+ move16();
}
move16();
test();
@@ -100,7 +102,7 @@ void mode_switch_decoder_LPD_fx(
test();
test();
test();
- IF( NE_16( fscale, st->fscale ) || NE_16( switchWB, 0 ) || NE_16( bSwitchFromAmrwbIO, 0 ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset )
+ IF( NE_16( fscale, st->fscale ) || ( switchWB != 0 ) || ( bSwitchFromAmrwbIO != 0 ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset )
{
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
open_decoder_LPD_fx( st, total_brate, last_total_brate, bwidth, MCT_flag, last_element_mode, 0 );
@@ -124,11 +126,14 @@ void mode_switch_decoder_LPD_fx(
IF( hTcxDec != NULL )
{
hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) );
+ move16();
}
IF( st->hTcxCfg != NULL )
{
st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, total_brate, st->rf_flag );
+ move16();
st->hTcxCfg->resq = getResq( total_brate );
+ move16();
}
move16();
@@ -136,20 +141,20 @@ void mode_switch_decoder_LPD_fx(
st->narrowBand = 0;
move16();
- IF( EQ_16( bwidth, NB ) )
+ if ( EQ_16( bwidth, NB ) )
{
st->narrowBand = 1;
move16();
}
st->TcxBandwidth = getTcxBandwidth( bwidth );
-
+ move16();
IF( st->hTcxCfg != NULL )
{
st->hTcxCfg->pCurrentTnsConfig = NULL;
st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( total_brate, st->igf, st->element_mode );
move16();
- IF( NE_16( st->hTcxCfg->fIsTNSAllowed, 0 ) && st->hIGFDec != NULL )
+ IF( ( st->hTcxCfg->fIsTNSAllowed != 0 ) && st->hIGFDec != NULL )
{
InitTnsConfigs( bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFDec->infoIGFStopFreq, total_brate, st->element_mode, 0 /* 0 should be replaced with MCT_flag*/ );
#ifdef IVAS_CODE
@@ -165,7 +170,7 @@ void mode_switch_decoder_LPD_fx(
reconfig_decoder_LPD_fx( st, frame_size, bwidth, total_brate, st->last_L_frame );
test();
- IF( NE_16( hTcxDec->envWeighted, 0 ) && EQ_16( hTcxDec->enableTcxLpc, 0 ) )
+ IF( hTcxDec->envWeighted != 0 && hTcxDec->enableTcxLpc == 0 )
{
Copy( st->lspold_uw, st->lsp_old_fx, M );
Copy( st->lsfold_uw, st->lsf_old_fx, M );
@@ -174,7 +179,7 @@ void mode_switch_decoder_LPD_fx(
}
/* update PLC LSF memories */
- IF( EQ_16( st->tcxonly, 0 ) )
+ IF( st->tcxonly == 0 )
{
lsp2lsf_fx( st->lsp_old_fx, st->lsfoldbfi1_fx, M, extract_l( st->sr_core ) );
}
@@ -185,7 +190,7 @@ void mode_switch_decoder_LPD_fx(
Copy( st->lsfoldbfi1_fx, st->lsfoldbfi0_fx, M );
Copy( st->lsfoldbfi1_fx, st->lsf_adaptive_mean_fx, M );
- IF( NE_16( st->igf, 0 ) && hBWE_TD != NULL )
+ IF( st->igf != 0 && hBWE_TD != NULL )
{
test();
test();
@@ -213,11 +218,12 @@ void mode_switch_decoder_LPD_fx(
}
}
+ test();
test();
test();
IF( ( EQ_16( bwidth, SWB ) ) && ( EQ_32( total_brate, ACELP_16k40 ) || EQ_32( total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) )
{
- IF( EQ_16( st->tec_tfa, 0 ) )
+ if ( st->tec_tfa == 0 )
{
set16_fx( st->hTECDec->loBuffer, 0, MAX_TEC_SMOOTHING_DEG );
}
@@ -309,7 +315,7 @@ void mode_switch_decoder_LPD_ivas_fx(
test();
test();
test();
- IF( ( ( GT_32( total_brate, ACELP_32k ) ) && ( EQ_16( st->tcxonly, 0 ) ) ) || ( ( LE_32( total_brate, ACELP_32k ) ) && EQ_16( st->tcxonly, 1 ) ) )
+ IF( ( ( GT_32( total_brate, ACELP_32k ) ) && ( ( st->tcxonly == 0 ) ) ) || ( ( LE_32( total_brate, ACELP_32k ) ) && EQ_16( st->tcxonly, 1 ) ) )
{
switchWB = 1;
move16();
@@ -324,6 +330,7 @@ void mode_switch_decoder_LPD_ivas_fx(
}
st->igf = getIgfPresent_fx( st->element_mode, total_brate, bwidth, st->rf_flag );
+ move16();
IF( st->hIGFDec != NULL )
{
@@ -334,7 +341,7 @@ void mode_switch_decoder_LPD_ivas_fx(
move16();
test();
test();
- IF( st->igf && ( EQ_16( st->idchan, 0 ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) )
+ IF( st->igf && ( ( st->idchan == 0 ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) )
{
/* switch IGF configuration */
IGFDecSetMode_ivas_fx( st->hIGFDec, total_brate, bwidth, st->element_mode, -1, -1, st->rf_flag );
@@ -357,9 +364,11 @@ void mode_switch_decoder_LPD_ivas_fx(
st->fscale = fscale;
move16();
st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) );
+ move16();
IF( st->hTcxDec != NULL )
{
st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) );
+ move16();
st->output_frame_fx = st->hTcxDec->L_frameTCX;
move16();
}
@@ -367,7 +376,9 @@ void mode_switch_decoder_LPD_ivas_fx(
IF( st->hTcxCfg != NULL )
{
st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, total_brate, st->rf_flag );
+ move16();
st->hTcxCfg->resq = getResq( total_brate );
+ move16();
}
move16();
@@ -383,8 +394,10 @@ void mode_switch_decoder_LPD_ivas_fx(
ELSE
{
st->narrowBand = 0;
+ move16();
}
st->TcxBandwidth = getTcxBandwidth( bwidth );
+ move16();
IF( st->hTcxCfg != NULL )
{
@@ -451,6 +464,7 @@ void mode_switch_decoder_LPD_ivas_fx(
}
test();
test();
+ test();
IF( EQ_16( bwidth, SWB ) && ( EQ_32( total_brate, ACELP_16k40 ) || EQ_32( total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) )
{
IF( EQ_16( st->tec_tfa, 0 ) && st->hTECDec != NULL )
diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c
index 7e7bfbd6c5bdca8b817f8b010584d70e548dc9c9..43431ba309c92bce579a28ec6e655b7fd55592ae 100644
--- a/lib_dec/core_switching_dec.c
+++ b/lib_dec/core_switching_dec.c
@@ -40,8 +40,7 @@
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
-#include "prot_fx2.h"
-#include "prot_fx1.h"
+#include "prot_fx.h"
#include "ivas_cnst.h"
#include "wmc_auto.h"
diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c
index 4f8854d7c540e86310c66fa7fec1b595eeda032f..b6f6f7276f13fb2068e6199e348b9a2ed88af1ad 100644
--- a/lib_dec/core_switching_dec_fx.c
+++ b/lib_dec/core_switching_dec_fx.c
@@ -6,8 +6,7 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
diff --git a/lib_dec/d_gain2p_fx.c b/lib_dec/d_gain2p_fx.c
index 7ab2dec98be6bc31f2d3af95961eadf48ae68bf9..63eff5413795ce52a79bc6208eaf96deb046e82f 100644
--- a/lib_dec/d_gain2p_fx.c
+++ b/lib_dec/d_gain2p_fx.c
@@ -4,8 +4,7 @@
#include
#include
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "stl.h"
#include "rom_com.h"
@@ -106,7 +105,7 @@ static void Mode2_gain_dec_mless_fx(
/*-----------------------------------------------------------------*
* decode pitch gain
*-----------------------------------------------------------------*/
- *gain_pit = t_qua_gain[index * 2];
+ *gain_pit = t_qua_gain[shl( index, 1 )];
move16();
/*-----------------------------------------------------------------*
* calculate the predicted gain code
diff --git a/lib_dec/dec2t32_fx.c b/lib_dec/dec2t32_fx.c
index e62814cc65f6fa7da9dcd60bf55b999986de4b70..b6e1c2053e62f1a9bb51bc4028d4b7a895048572 100644
--- a/lib_dec/dec2t32_fx.c
+++ b/lib_dec/dec2t32_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
/*==========================================================================*/
diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c
index 10e9b5b13a0918b7c12ab8f75bfa3039c45eace8..47c481dc493142f075c5908e7b35ca459ab9ee9c 100644
--- a/lib_dec/dec4t64_fx.c
+++ b/lib_dec/dec4t64_fx.c
@@ -2,12 +2,11 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
-#include "assert.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
+#include "assert.h" /* Static table prototypes */
#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
* Local functions
diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c
index 746e18e38bae66c088e3d10069d0821390bf81d7..e45e44b471c4835c7c2ac3f3ea6e92c8c032efeb 100644
--- a/lib_dec/dec_LPD.c
+++ b/lib_dec/dec_LPD.c
@@ -44,7 +44,7 @@
#include "basop_proto_func.h"
#include "stat_com.h"
#include "wmc_auto.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c
index 11afd0184baebf196ddbaa1a6ca8ec74306e5d4c..3b840fc5e735bcf6509e29a36cc11bbdb577ded8 100644
--- a/lib_dec/dec_LPD_fx.c
+++ b/lib_dec/dec_LPD_fx.c
@@ -6,8 +6,7 @@
#include
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "rom_com.h"
#ifdef IVAS_FLOAT_FIXED
diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c
index 8764b1d2a139c04a8fbba1a2a15d8a1de7bade44..7c3de901a83a4eacd7d7b6d651bbba86ee3a4308 100644
--- a/lib_dec/dec_ace_fx.c
+++ b/lib_dec/dec_ace_fx.c
@@ -8,8 +8,7 @@
#include
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "stl.h"
#include "rom_com.h"
diff --git a/lib_dec/dec_acelp_fx.c b/lib_dec/dec_acelp_fx.c
index b560f7beae8300edbcfb724f8f1a361fa8db28ea..b05086d9fc61e0d4c4b36f77b5c023ca97500028 100644
--- a/lib_dec/dec_acelp_fx.c
+++ b/lib_dec/dec_acelp_fx.c
@@ -7,8 +7,7 @@
#include
#include "options.h"
#include "basop_util.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "rom_basop_util.h"
#ifdef IVAS_FLOAT_FIXED
diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c
index 93eb4605f15c77fd86f593bc1688f205ec902e4e..ad7117763bc403b7c06164a2ec87687ed92e5c78 100644
--- a/lib_dec/dec_acelp_tcx_main_fx.c
+++ b/lib_dec/dec_acelp_tcx_main_fx.c
@@ -8,8 +8,7 @@
#include "options.h"
#include "rom_com.h"
#include "stat_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#ifdef IVAS_FLOAT_FIXED
static void decode_frame_type_fx( Decoder_State *st
diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c
index 9682b152b87ab07c0971313aa315129ce5f9b257..03ae965aabbbe968eff0187734c4b68253de0e5a 100644
--- a/lib_dec/dec_amr_wb_fx.c
+++ b/lib_dec/dec_amr_wb_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
/*---------------------------------------------------------------------*
diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c
index 1fd514e1ccfe28bd1dbbc1eb47182b366915395e..597cfea19e0f902101761e944803f8bceb692b6c 100644
--- a/lib_dec/dec_gen_voic_fx.c
+++ b/lib_dec/dec_gen_voic_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "stl.h"
#include "basop_util.h"
#ifdef IVAS_FLOAT_FIXED
@@ -708,7 +707,7 @@ ivas_error decod_gen_voic_ivas_fx(
}
/* update LP filtered gains for the case of frame erasures */
- lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame );
+ lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame );
/*----------------------------------------------------------------------*
* Find the total excitation
diff --git a/lib_dec/dec_higher_acelp.c b/lib_dec/dec_higher_acelp.c
index 304884e714e1f54d084e74f97bbbfe7fbdfc1227..962bbc686747e3968b608b719ea5981b07f176eb 100644
--- a/lib_dec/dec_higher_acelp.c
+++ b/lib_dec/dec_higher_acelp.c
@@ -42,7 +42,7 @@
#include "rom_com.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif // IVAS_FLOAT_FIXED
/*-----------------------------------------------------------------*
diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c
index 0bc9665d804906bacd705e9f9ef1f94e1afa90a3..eea2c8a62c346981f10e4292efb1d7728b630576 100644
--- a/lib_dec/dec_higher_acelp_fx.c
+++ b/lib_dec/dec_higher_acelp_fx.c
@@ -4,10 +4,9 @@
#include
#include "options.h" /* Compilation switches */
#include
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
#define IVAS_CODE
#define IVAS_CODE_AVQ
diff --git a/lib_dec/dec_nelp_fx.c b/lib_dec/dec_nelp_fx.c
index 9732ce9f1a5c88d5606fc7a85bab5a3e3cbce770..7083919c455c76ab46d32ad1489d3669eb8d42c8 100644
--- a/lib_dec/dec_nelp_fx.c
+++ b/lib_dec/dec_nelp_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
/*======================================================================*/
/* FUNCTION : decod_nelp_fx() */
diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c
index aba8af9b22b2e1004f6187a95059512864ddd2da..27abc3ddfeeea1d1bceb3bad297a15a4c9330904 100644
--- a/lib_dec/dec_pit_exc_fx.c
+++ b/lib_dec/dec_pit_exc_fx.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
/*==========================================================================*/
@@ -864,7 +863,7 @@ void dec_pit_exc_ivas_fx(
move16();
pt_gain++;
- lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame );
+ lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame );
}
}
diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c
index 2552a15ec37180c6986db410547cd13b75fbd45c..a8580c8ce001282d59201985c57c58a938dc661c 100644
--- a/lib_dec/dec_post_fx.c
+++ b/lib_dec/dec_post_fx.c
@@ -3,8 +3,7 @@
====================================================================================*/
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "rom_dec.h"
#include "rom_com.h"
diff --git a/lib_dec/dec_ppp_fx.c b/lib_dec/dec_ppp_fx.c
index cd4d6462f6be21a92c0ecdb8806199ef5b5b7777..d37efa4c7d80b2ca92d6f92813f7b6185644999e 100644
--- a/lib_dec/dec_ppp_fx.c
+++ b/lib_dec/dec_ppp_fx.c
@@ -4,9 +4,8 @@
#include
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
/*===================================================================*/
/* FUNCTION : void decod_ppp_fx () */
diff --git a/lib_dec/dec_prm.c b/lib_dec/dec_prm.c
index c10b3f587295bcf8e77e5885aa93cc0a5c3d6e4d..b6a2b7d82af34b2cebb9486865b511d699f3264c 100644
--- a/lib_dec/dec_prm.c
+++ b/lib_dec/dec_prm.c
@@ -41,7 +41,7 @@
#include "rom_com.h"
#include "prot.h"
#include "wmc_auto.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
* getTCXMode_ivas()
diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c
index f238f3e3a5136bc1c12fef6dd9acd44db1c54e9a..22b0c7047f309b1617fa0edf47e745cc218b1f3c 100644
--- a/lib_dec/dec_prm_fx.c
+++ b/lib_dec/dec_prm_fx.c
@@ -9,8 +9,7 @@
#include
#include "rom_com.h"
#include "stl.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c
index 921e84976d7eaaeb324e6af7cbe9189d821f861b..ab45587913294d18ec7ba70e4afa9910d387da44 100644
--- a/lib_dec/dec_tcx.c
+++ b/lib_dec/dec_tcx.c
@@ -37,7 +37,7 @@
#include
#include "prot.h"
#include "ivas_prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include
#include "options.h"
#include
@@ -45,8 +45,6 @@
#include "cnst.h"
#include "wmc_auto.h"
#include "ivas_rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
#include "ivas_prot_fx.h"
#ifndef IVAS_FLOAT_FIXED_UNIT_TESTING
#include "debug.h"
@@ -1568,9 +1566,10 @@ void decoder_tcx_tns_fx(
STnsData *tnsData,
const Word16 bfi, /* i : Bad frame indicator */
const Word16 frame_cnt, /* i : frame counter in the super frame */
- const Word16 whitenedDomain )
+ const Word16 whitenedDomain,
+ Word16 *length )
{
- Word16 index, isTCX5, L;
+ Word16 index, isTCX5, L, tmp;
TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg;
index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */
@@ -1580,9 +1579,14 @@ void decoder_tcx_tns_fx(
move16();
L = L_frameTCX;
move16();
+ tmp = L;
+ move16();
+ test();
IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) )
{
+ test();
+ test();
IF( NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) )
{
/* fix sub-window overlap */
@@ -1590,12 +1594,24 @@ void decoder_tcx_tns_fx(
move16();
}
+ test();
+ test();
+ test();
IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) )
{
L = L_spec;
move16();
+ tmp = L;
+ move16();
}
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
IF( ( EQ_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) ||
( EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) && EQ_16( frame_cnt, 0 ) && EQ_16( index, 0 ) ) ) ) ||
( NE_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) &&
@@ -1613,11 +1629,16 @@ void decoder_tcx_tns_fx(
*-----------------------------------------------------------*/
+ test();
+ test();
+ test();
IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) )
{
/* Apply TNS to get the reconstructed signal */
SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) );
+ test();
+ test();
IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) )
{
tcx5TnsGrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx );
@@ -1625,11 +1646,16 @@ void decoder_tcx_tns_fx(
ApplyTnsFilter( hTcxCfg->pCurrentTnsConfig, tnsData, x_fx, 0 );
+ test();
+ test();
IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) )
{
+ test();
IF( EQ_16( st->element_mode, EVS_MONO ) || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */
{
tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC );
+ tmp = L_frameTCX;
+ move16();
}
ELSE
{
@@ -1637,12 +1663,17 @@ void decoder_tcx_tns_fx(
}
}
}
+ test();
IF( NE_16( whitenedDomain, 0 ) && NE_16( isTCX5, 0 ) )
{
tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx );
}
/* restore index */
+ test();
+ test();
+ test();
+ test();
IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) )
{
/* restore sub-window overlap */
@@ -1650,6 +1681,12 @@ void decoder_tcx_tns_fx(
move16();
}
+ if ( length != NULL )
+ {
+ *length = tmp;
+ move16();
+ }
+
return;
}
#endif
diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c
index cc2de505299ae6b03da19bb37c720869898ce0bf..485308d6cf0a2e64f31e94ba1d5da8a0cdc27539 100644
--- a/lib_dec/dec_tcx_fx.c
+++ b/lib_dec/dec_tcx_fx.c
@@ -5,8 +5,7 @@
#include
#include
#include
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "stl.h"
#include "options.h"
@@ -1784,11 +1783,9 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx,
}
ELSE IF( GT_16( st_fx->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) )
{
- Word16 tmp, q_tmp;
- tmp = BASOP_Util_Divide1616_Scale( sub( st_fx->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ), MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN, &q_tmp );
- q_tmp = sub( 15, q_tmp );
- gainCNG = extract_l( L_shr( L_mult0( gainCNG, sub( shl( 1, q_tmp ), tmp ) ), q_tmp ) );
// gainCNG *= 1.f - (float) sub( st_fx->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN;
+ tmp32 = L_sub( ONE_IN_Q31, imult3216( 107374182 /* 1 / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN in Q31*/, sub( st_fx->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) ) ); /* Q31 */
+ gainCNG = extract_l( Mpy_32_32( gainCNG, tmp32 ) );
}
}
}
@@ -3227,7 +3224,7 @@ void IMDCT_ivas_fx(
{
FOR( i = 0; i < overlap; i++ )
{
- xn_buf_fx[i] = add( xn_buf_fx[i], old_syn_overl_fx[i] );
+ xn_buf_fx[i] = add_sat( xn_buf_fx[i], old_syn_overl_fx[i] );
move16();
}
}
@@ -3295,7 +3292,7 @@ void IMDCT_ivas_fx(
FOR( i = 0; i < shr( tcx_mdct_window_half_length, 1 ); i++ )
{
xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = mult_r( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], tcx_mdct_window_half_fx[i].v.im );
- xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_OverlFB[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) );
+ xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_OverlFB[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) );
move16();
move16();
}
@@ -3728,7 +3725,7 @@ void decoder_tcx_ivas_fx(
x_e = sub( x_e, shift );
move16();
- decoder_tcx_tns_fx( st, L_frame_glob, L_spec, L_frame, L_frameTCX, x_fx, fUseTns, &tnsData, bfi, frame_cnt, 0 );
+ decoder_tcx_tns_fx( st, L_frame_glob, L_spec, L_frame, L_frameTCX, x_fx, fUseTns, &tnsData, bfi, frame_cnt, 0, NULL );
Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11
Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( st->Q_syn, 14 ) ); // Scaling xn_buf_fx to Q_syn
@@ -4484,7 +4481,7 @@ void decoder_tcx_noisefilling_fx(
#else
if ( st->igf )
{
- pInfoTCXNoise = st->hIGFDec->infoTCXNoise_evs;
+ pInfoTCXNoise = st->hIGFDec->infoTCXNoise_ptr;
move16();
}
#endif
diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c
index 85497cc849dd6070f132d72c3083c513d719b0b4..4d8767e475e737c6a2eb2e4fd98c2667483d9683 100644
--- a/lib_dec/dec_tran_fx.c
+++ b/lib_dec/dec_tran_fx.c
@@ -2,11 +2,18 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
+
+#ifdef FIX_810_PREVENT_UNECESSARY_SAT_IN_TC
+#define Q3_4 ( 4 << Q3 )
+#define Q3_17 ( 17 << Q3 )
+#define Q16_8 ( 8 << Q16 )
+#define Q16_30 ( 30 << Q16 )
+#endif
+
/*======================================================================*/
/* FUNCTION : decod_tran_fx() */
/*----------------------------------------------------------------------*/
@@ -160,15 +167,17 @@ void decod_tran_fx(
}
/* update LP filtered gains for the case of frame erasures */
- lp_gain_updt_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx );
-
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
+ lp_gain_updt_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx );
+
st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc );
move16();
}
ELSE
{
+ lp_gain_updt_ivas_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx );
+
st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 );
move16();
}
@@ -176,10 +185,29 @@ void decod_tran_fx(
/*----------------------------------------------------------------------*
* Find the total excitation
*----------------------------------------------------------------------*/
-
+#ifdef FIX_810_PREVENT_UNECESSARY_SAT_IN_TC
+ test();
+ test();
+ test();
+ IF( GT_16( st_fx->element_mode, EVS_MONO ) && ( GE_16( add( i_subfr, L_SUBFR ), tc_subfr_fx ) && LT_16( i_subfr, tc_subfr_fx ) && GT_16( st_fx->Q_subfr[0], 4 ) ) )
+ {
+ test();
+ test();
+ test();
+ IF( GE_16( st_fx->Q_subfr[0], 7 ) && LE_32( st_fx->lp_gainc_fx, Q3_4 ) && LE_32( norm_gain_code_fx, Q16_8 ) )
+ {
+ st_fx->Q_subfr[0] = s_min( st_fx->Q_subfr[0], 4 );
+ move16();
+ }
+ ELSE IF( LE_32( st_fx->lp_gainc_fx, Q3_17 ) && LE_32( L_sub( gain_code_fx, norm_gain_code_fx ), Q16_30 ) )
+ {
+ st_fx->Q_subfr[0] = s_min( 4, sub( st_fx->Q_subfr[0], 2 ) );
+ move16();
+ }
+ }
+#endif
IF( EQ_16( L_frame_fx, L_FRAME ) ) /* Rescaling for 12.8k core */
{
-
Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr], &bwe_exc_fx[shr( imult1616( i_subfr, 2 * HIBND_ACB_L_FAC ), 1 )], hGSCDec->last_exc_dct_in_fx,
L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, i_subfr, st_fx->coder_type );
}
diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c
index cbdb9407ff4dff93ea3f26a5a9b1280e23ac42c0..8a4f4c05e888ef869b54ae1cbfcf5e934ff1c7f3 100644
--- a/lib_dec/dec_uv_fx.c
+++ b/lib_dec/dec_uv_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
static void gain_dec_gacelp_uv_fx(
Word16 index, /* i : Quantization index vector Q0 */
@@ -205,7 +204,7 @@ void decod_unvoiced_ivas_fx(
/* update LP filtered gains for the case of frame erasures */
// lp_gain_updt(i_subfr, gain_pit, norm_gain_code, &st->lp_gainp, &st->lp_gainc, L_FRAME);
- lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME );
+ lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME );
/*-------------------------------------------------------*
* - Find the total excitation. *
@@ -364,7 +363,11 @@ static void gain_dec_gacelp_uv_fx(
*past_gcode = L_shl( L_tmp1, sub( exp_L_tmp1, 15 ) ); /* Q16 */
move32();
+#ifdef BASOP_NOGLOB
+ *gain_code = L_shl_sat( Mpy_32_16_1( *past_gcode, *gain_inov ), 3 );
+#else
*gain_code = L_shl( Mpy_32_16_1( *past_gcode, *gain_inov ), 3 );
+#endif
move32();
diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c
index 8c9a12b69c14b8dc511450251fb3a5951bd2adcf..7362cb20b68fe64f9512ae7ee2b662f836904d42 100644
--- a/lib_dec/decision_matrix_dec_fx.c
+++ b/lib_dec/decision_matrix_dec_fx.c
@@ -4,8 +4,7 @@
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "stat_dec.h"
#include "rom_com.h"
#include "stl.h"
diff --git a/lib_dec/dlpc_avq_fx.c b/lib_dec/dlpc_avq_fx.c
index 07f20ce6a3c00742ba4f434a879eefa7dd0c5359..1cb91e22f84a98734ccc9e1ab180c378bee6faab 100644
--- a/lib_dec/dlpc_avq_fx.c
+++ b/lib_dec/dlpc_avq_fx.c
@@ -6,8 +6,7 @@
#include
#include "options.h"
#include
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#ifdef IVAS_FLOAT_FIXED
/* Constants */
diff --git a/lib_dec/dlpc_stoch_fx.c b/lib_dec/dlpc_stoch_fx.c
index 742f76dd3ea3438763f1a96dc0a31eeb336c83c9..f42d7d45708c5ea53faeedc570f7d10bac02fb0a 100644
--- a/lib_dec/dlpc_stoch_fx.c
+++ b/lib_dec/dlpc_stoch_fx.c
@@ -8,8 +8,7 @@
#include
#include "options.h"
#include "basop_util.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#ifdef IVAS_FLOAT_FIXED
/* Constants */
#define M 16
diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c
index ca23584a1b1098c75bd9a05a7af29bab79f97d68..3a8a3de62bc5e9a0cb93a9569798e54f1035b696 100644
--- a/lib_dec/er_dec_acelp_fx.c
+++ b/lib_dec/er_dec_acelp_fx.c
@@ -8,8 +8,7 @@
#include
#include "options.h"
#include
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "rom_dec.h"
#ifdef IVAS_FLOAT_FIXED
diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c
index 8849f7b63ab1129dad72e1b6ba62947c30a8967b..a4102230e7be1e006315c74dd87f465123ab815d 100644
--- a/lib_dec/er_dec_tcx_fx.c
+++ b/lib_dec/er_dec_tcx_fx.c
@@ -6,8 +6,7 @@
#include
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "rom_dec.h"
#ifdef IVAS_FLOAT_FIXED
@@ -1780,11 +1779,9 @@ void con_tcx_ivas_fx(
}
ELSE IF( GT_16( st->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) )
{
- Word16 tmp, q_tmp;
- tmp = BASOP_Util_Divide1616_Scale( sub( st->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ), MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN, &q_tmp );
- q_tmp = sub( 15, q_tmp );
- gainCNG = extract_l( L_shr( L_mult0( gainCNG, sub( shl( 1, q_tmp ), tmp ) ), q_tmp ) );
// gainCNG *= 1.f - (float)(st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN;
+ L_tmp = L_sub( ONE_IN_Q31, imult3216( 107374182 /* 1 / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN in Q31*/, sub( st->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) ) ); /* Q31 */
+ gainCNG = extract_l( Mpy_32_32( gainCNG, L_tmp ) );
}
}
#endif
diff --git a/lib_dec/er_scale_syn_fx.c b/lib_dec/er_scale_syn_fx.c
index ed78d88429c32c52dc3f04be491cf32ef849460a..652041e6717b2572ef49833799c2ba03ccb0c3ac 100644
--- a/lib_dec/er_scale_syn_fx.c
+++ b/lib_dec/er_scale_syn_fx.c
@@ -6,8 +6,7 @@
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "cnst.h"
#ifdef IVAS_FLOAT_FIXED
diff --git a/lib_dec/er_sync_exc_fx.c b/lib_dec/er_sync_exc_fx.c
index f4535152f3647126423204922d08166cf95fa9f1..48f811e71d26c990432a3e27605e4d9582d6d445 100644
--- a/lib_dec/er_sync_exc_fx.c
+++ b/lib_dec/er_sync_exc_fx.c
@@ -8,8 +8,7 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop32.h"
#include "basop_util.h"
#ifdef IVAS_FLOAT_FIXED
diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c
index ee0c52b8ea09c1d2a3a991d8033d80bc23e03949..93ccaed26d8be53dd3e2740f13cd14c6fcfe8c5a 100644
--- a/lib_dec/er_util_fx.c
+++ b/lib_dec/er_util_fx.c
@@ -5,8 +5,7 @@
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include
#ifdef IVAS_FLOAT_FIXED
diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c
index 96c3b57928b31659d1f135f695bc94e022e15328..d5498c622a1f4988018a0e8ae59ef80b3abd4338 100644
--- a/lib_dec/evs_dec.c
+++ b/lib_dec/evs_dec.c
@@ -42,8 +42,7 @@
#include "prot.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
#ifndef IVAS_FLOAT_FIXED
diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c
index e258c68e9af358a69e3dadfd9f231b199ec720f8..ee9bc103ce190190f4066605488d3b88e88a00d9 100644
--- a/lib_dec/evs_dec_fx.c
+++ b/lib_dec/evs_dec_fx.c
@@ -6,8 +6,7 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c
index 063a912690fe82eef270bc1d2ffc7224bd056cde..e5a7bb6669b7e1ae51972aba6c9b21cd0f065a20 100644
--- a/lib_dec/fd_cng_dec.c
+++ b/lib_dec/fd_cng_dec.c
@@ -45,8 +45,7 @@
#include "ivas_prot.h"
#include "ivas_rom_dec.h"
#include "ivas_rom_com_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#include "basop_util.h"
#include "rom_basop_util.h"
@@ -552,12 +551,7 @@ void configureFdCngDec_ivas_fx(
hsCom->startBand = 2;
move16();
hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[sub( hsCom->FdCngSetup.numPartitions, 1 )], 1 );
-#ifndef IVAS_FLOAT_FIXED
- /* remove floating point dependency */
- initPartitions_flt( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize_flt, hsCom->psize_inv_flt, 0 );
-#else // IVAS_FLOAT_FIXED
initPartitions( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_norm, &hsCom->psize_norm_exp, hsCom->psize_inv, 0 );
-#endif // IVAS_FLOAT_FIXED
IF( EQ_16( hsCom->stopFFTbin, 160 ) )
{
@@ -578,9 +572,6 @@ void configureFdCngDec_ivas_fx(
FOR( j = 0; j < hsCom->nCLDFBpart; j++ )
{
hsCom->CLDFBpart[j] = sub( hsCom->part[add( j, hsCom->nFFTpart )], sub( hsCom->stopFFTbin, hsCom->startBand ) );
-#ifndef IVAS_FLOAT_FIXED
- hsCom->CLDFBpsize_inv_flt[j] = hsCom->psize_inv_flt[j + hsCom->nFFTpart]; // TODO remove floating point dependency
-#endif
move16();
hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[add( j, hsCom->nFFTpart )];
move16();
@@ -594,12 +585,7 @@ void configureFdCngDec_ivas_fx(
move16();
}
-#ifdef IVAS_FLOAT_FIXED
initPartitions( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions, hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping, hFdCngDec->psize_shaping, hFdCngDec->psize_shaping_norm, &hFdCngDec->psize_shaping_norm_exp, hFdCngDec->psize_inv_shaping, stopBandFR );
-#else // IVAS_FLOAT_FIXED
- /* remove floating point dependency */
- initPartitions_flt( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions, hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping, hFdCngDec->psize_shaping_float, hFdCngDec->psize_inv_shaping_float, stopBandFR );
-#endif // IVAS_FLOAT_FIXED
hFdCngDec->nFFTpart_shaping = hFdCngDec->npart_shaping;
move16();
@@ -1338,7 +1324,7 @@ void FdCng_decodeSID_ivas_fx(
Decoder_State *st /* i/o: decoder state structure */
)
{
- int16_t N;
+ Word16 N;
Word32 *sidNoiseEst;
Word32 gain;
Word16 i, index;
@@ -1370,6 +1356,7 @@ void FdCng_decodeSID_ivas_fx(
sidNoiseEst = hFdCngCom->sidNoiseEst;
N = hFdCngCom->npart;
+ move16();
gain = 0;
move32();
hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 );
@@ -1993,6 +1980,7 @@ void generate_masking_noise_ivas_fx(
Word32 *ptr_r_fx;
Word32 *ptr_i_fx;
Word16 startBand = hFdCngCom->startBand;
+ move16();
Word16 *seed = &( hFdCngCom->seed );
Word32 scale_fx = 0x40000000; // 1.0 in Q30
move32();
@@ -2004,6 +1992,7 @@ void generate_masking_noise_ivas_fx(
}
scale_sig32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift );
hFdCngCom->cngNoiseLevelExp = sub( hFdCngCom->cngNoiseLevelExp, shift );
+ move16();
/* skip noise generating if level is very low, to avoid problems with possibly running into denormals */
*exp_out = Q15;
@@ -2054,7 +2043,7 @@ void generate_masking_noise_ivas_fx(
/* Generate Gaussian random noise in real and imaginary parts of the FFT bins
Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */
- IF( EQ_16( startBand, 0 ) )
+ IF( startBand == 0 )
{
rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out ); // Q15
ptr_r_fx = fftBuffer_fx + 2;
@@ -2104,13 +2093,14 @@ void generate_masking_noise_ivas_fx(
/* Perform STFT synthesis */
IF( secondary )
{
- SynthesisSTFT_fx( fftBuffer_fx, *exp_out, maskingNoise_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out );
+ SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out );
}
ELSE
{
- SynthesisSTFT_fx( fftBuffer_fx, *exp_out, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out );
+ SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out );
}
*exp_out = sub( *exp_out, Q9 );
+ move16();
/* Add some comfort noise on top of decoded signal */
IF( return_noise )
@@ -2390,10 +2380,10 @@ void generate_stereo_masking_noise_fx(
Word16 Q_syn,
Decoder_State *st, /* i/o: decoder state structure */
STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */
- const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */
- const int16_t fadeOut, /* i : only fade out of previous state */
+ const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */
+ const Word16 fadeOut, /* i : only fade out of previous state */
STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */
- const int16_t nchan_out /* i : number of output channels */
+ const Word16 nchan_out /* i : number of output channels */
)
{
HANDLE_FD_CNG_COM hFdCngCom;
@@ -2403,7 +2393,7 @@ void generate_stereo_masking_noise_fx(
Word32 N1_fx[L_FRAME16k];
Word32 N2_fx[L_FRAME16k];
Word16 N1_fx_exp, N2_fx_exp;
- int16_t i;
+ Word16 i;
IF( st->idchan == 0 )
{
@@ -2556,6 +2546,7 @@ void generate_stereo_masking_noise_fx(
move16();
}
hStereoTD->prevSP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx );
+ move16();
}
return;
@@ -2708,6 +2699,7 @@ void generate_masking_noise_lb_dirac_fx(
n_samples_out = i_mult( shr( hFdCngCom->frameSize, 4 ), nCldfbTs );
n_samples_start = 0;
Word16 exp_out = Q15;
+ move16();
/*LB CLDFB - CNA from STFT*/
IF( cna_flag )
{
@@ -2727,14 +2719,8 @@ void generate_masking_noise_lb_dirac_fx(
}
}
- Word16 exp;
- Word16 div1 = BASOP_Util_Divide1616_Scale( negate( scaleTable_cn_dirac[i].scale_ivas ), shl( 10, Q11 ), &exp );
- exp = add( exp, sub( sub( 15, 13 ), sub( 15, 11 ) ) );
- Word32 scale_temp = BASOP_util_Pow2( Mpy_32_16_1( LOG_10_BASE_2, div1 ), add( exp, 2 ), &exp );
- scale_temp = L_sub( scale_temp, L_shl( 1, sub( Q31, exp ) ) );
- scale = L_shl( scale_temp, sub( exp, Q1 ) ); // Q30
-
- scale = Mpy_32_32( scale, hFdCngCom->likelihood_noisy_speech_32fx ); // Q30
+ scale = L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ); /* Q30 */
+ scale = Mpy_32_32( scale, hFdCngCom->likelihood_noisy_speech_32fx ); /* Q30 */
}
}
@@ -2805,7 +2791,7 @@ void generate_masking_noise_lb_dirac_fx(
/* Perform STFT synthesis */
SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom );
}
- hFdCngCom->fftBuffer_exp = sub( 31, 15 );
+ hFdCngCom->fftBuffer_exp = 31 - 15;
n_samples_out = sub( n_samples_out, hFdCngCom->frameSize );
n_samples_start = add( n_samples_start, hFdCngCom->frameSize );
}
@@ -2968,7 +2954,7 @@ void generate_masking_noise_dirac_ivas_fx(
}
}
- scale_fx = L_sub( pow_10_q11[shr( negate( scaleTable_cn_dirac[i].scale_ivas ) / 10, 13 - 7 )], 2048 ); // Q11
+ scale_fx = L_shr( scaleTable_cn_dirac[i].scale_ivas, Q3 ); /* Q11 */
scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech );
}
}
@@ -3423,7 +3409,7 @@ void FdCngDecodeDiracMDCTStereoSID_fx(
exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp );
FOR( p = 0; p < N; p++ )
{
- IF( GT_16( exp_diff, 0 ) )
+ IF( exp_diff > 0 )
{
sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) );
move32();
@@ -3434,7 +3420,7 @@ void FdCngDecodeDiracMDCTStereoSID_fx(
move32();
}
}
- IF( LT_16( exp_diff, 0 ) )
+ IF( exp_diff < 0 )
{
sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) );
}
diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c
index 4c0e5b1d71a3c5383b5413555f2dce1845e0699c..4e93acdfb048f572512c8b253ecab32f59850c0f 100644
--- a/lib_dec/fd_cng_dec_fx.c
+++ b/lib_dec/fd_cng_dec_fx.c
@@ -9,8 +9,7 @@
#include "options.h"
#include "rom_com.h"
#include "stat_dec.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#include "basop_util.h"
#include "rom_basop_util.h"
@@ -1905,7 +1904,7 @@ Word16 ApplyFdCng_ivas_fx(
IF( EQ_16( st->codec_mode, MODE2 ) )
{
/* Generate comfort noise during SID or zero frames */
- generate_comfort_noise_dec_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 );
+ generate_comfort_noise_dec_ivas_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 );
}
BREAK;
@@ -2680,8 +2679,11 @@ void perform_noise_estimation_dec_ivas_fx(
{
temp = L_shr( temp, sub( hFdCngDec->msPeriodog_ST_exp, hFdCngDec->hFdCngCom->periodog_exp ) );
}
-
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ hFdCngDec->msPeriodog_ST_fx[p] = Madd_32_16( Mpy_32_16_1( hFdCngDec->msPeriodog_ST_fx[p], ST_PERIODOG_FACT_Q15 ), temp, sub( MAX_16, ST_PERIODOG_FACT_Q15 ) );
+#else
hFdCngDec->msPeriodog_ST_fx[p] = L_add( Mpy_32_16_1( hFdCngDec->msPeriodog_ST_fx[p], ST_PERIODOG_FACT_Q15 ), Mpy_32_16_1( temp, sub( MAX_16, ST_PERIODOG_FACT_Q15 ) ) );
+#endif
move32();
}
}
@@ -2762,7 +2764,11 @@ void perform_noise_estimation_dec_ivas_fx(
temp = msPeriodog[p];
move32();
temp = L_shr( temp, sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_exp ) );
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], sub( shl_sat( 1, sub( 15, e ) ), alpha ) ), temp, alpha );
+#else
msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], sub( shl_sat( 1, sub( 15, e ) ), alpha ) ), Mpy_32_16_1( temp, alpha ) );
+#endif
move32();
}
}
@@ -2833,7 +2839,11 @@ void perform_noise_estimation_dec_ivas_fx(
L_tmp = L_shr( msPeriodog[p], sub( sub( 31, hFdCngDec->hFdCngCom->periodog_exp ), 4 ) );
IF( LT_32( L_tmp, msNoiseEst[p] ) )
{
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], wght ), L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) );
+#else
msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], wght ), Mpy_32_16_1( L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) ) );
+#endif
move32();
temp_q_msNoiseEst[p] = sub( add( hFdCngDec->msNoiseEst_exp, scale ), 15 );
move16();
@@ -2853,10 +2863,14 @@ void perform_noise_estimation_dec_ivas_fx(
/* energy significantly decreases in one of the larger partitions during active frames -> downward update */
FOR( p = CNA_ACT_DN_LARGE_PARTITION; p < npart; p++ )
{
- L_tmp = L_shr( hFdCngDec->msPeriodog_ST_fx[p], sub( sub( 31, hFdCngDec->msPeriodog_ST_exp ), 4 ) );
- IF( LT_32( hFdCngDec->msPeriodog_ST_fx[p], msNoiseEst[p] ) )
+ L_tmp = L_shr( hFdCngDec->msPeriodog_ST_fx[p], sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_ST_exp ) );
+ IF( LT_32( L_tmp, msNoiseEst[p] ) )
{
- msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), Mpy_32_16_1( L_tmp, (Word16) L_sub( ONE_IN_Q15, CNA_ACT_DN_FACT_Q15 ) ) );
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 );
+#else
+ msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), Mpy_32_16_1( L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 ) );
+#endif
move32();
}
}
@@ -2907,8 +2921,27 @@ void perform_noise_estimation_dec_ivas_fx(
}
/* IIR smoothing */
- *ptr_per = Mpy_32_16_1( ( *ptr_per ), alpha );
+ test();
+ IF( *ptr_per != 0 && alpha != 0 )
+ {
+ *ptr_per = Mpy_32_16_1( ( *ptr_per ), alpha );
+ move32();
+ IF( *ptr_per == 0 )
+ {
+ *ptr_per = 1;
+ move32();
+ }
+ }
+ ELSE
+ {
+ *ptr_per = 0;
+ move32();
+ }
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ *ptr_per = Madd_32_16( ( *ptr_per ), temp, sub( MAX_16, alpha ) );
+#else
*ptr_per = L_add( ( *ptr_per ), Mpy_32_16_1( temp, sub( MAX_16, alpha ) ) );
+#endif
ptr_per++;
}
@@ -3788,6 +3821,549 @@ void generate_comfort_noise_dec_fx(
}
}
+void generate_comfort_noise_dec_ivas_fx(
+ Word32 **bufferReal, /* o : Real part of input bands */
+ Word32 **bufferImag, /* o : Imaginary part of input bands */
+ Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of input bands */
+ Decoder_State *st, /* i/o: decoder state structure */
+ Word16 *Q_new,
+ Word16 gen_exc,
+ const Word16 nchan_out /* i : number of output channels */
+)
+{
+ Word16 i, j, s;
+ Word32 *ptr_r, *ptr_i;
+ HANDLE_FD_CNG_DEC hFdCngDec = st->hFdCngDec;
+ HANDLE_FD_CNG_COM hFdCngCom = hFdCngDec->hFdCngCom;
+ Word32 *cngNoiseLevel = hFdCngCom->cngNoiseLevel;
+ Word16 cngNoiseLevel_exp = hFdCngCom->cngNoiseLevelExp;
+
+ Word32 *ptr_level = cngNoiseLevel;
+ Word16 *seed = &( hFdCngCom->seed );
+ Word16 *seed2;
+ Word16 c1, c2;
+ Word32 tmp1, tmp2;
+ Word16 scaleCldfb;
+ Word32 *fftBuffer = hFdCngCom->fftBuffer;
+ Word16 fftBuffer_exp = hFdCngCom->fftBuffer_exp;
+ Word16 fftBuffer_temp_exp[FFTLEN];
+ Word16 *timeDomainOutput = hFdCngCom->timeDomainBuffer;
+ Word16 temp;
+ Word32 sqrtNoiseLevel;
+ Word16 sqrtNoiseLevel_exp;
+ Word16 idx = 0;
+ move16();
+ Word16 preemph_fac;
+ Word16 old_syn_pe_tmp[16];
+ Word16 tcx_transition = 0;
+ TCX_DEC_HANDLE hTcxDec;
+ move16();
+
+ hTcxDec = st->hTcxDec;
+
+ scaleCldfb = mult( hFdCngCom->invScalingFactor, CLDFB_SCALING );
+
+ temp = 0;
+ move16();
+ c1 = Sqrt16( hFdCngCom->coherence_fx, &temp );
+ c1 = shl( c1, temp );
+ temp = 0;
+ move16();
+ c2 = Sqrt16( sub( MAX_16, hFdCngCom->coherence_fx ), &temp );
+ c2 = shl( c2, temp );
+
+ temp = getScaleFactor32( fftBuffer, FFTLEN );
+ scale_sig32( fftBuffer, FFTLEN, temp );
+ fftBuffer_exp = sub( fftBuffer_exp, temp );
+ hFdCngCom->fftBuffer_exp = fftBuffer_exp;
+ move16();
+ set16_fx( fftBuffer_temp_exp, fftBuffer_exp, FFTLEN );
+ fftBuffer_exp = 0;
+ move16();
+
+ seed2 = &( hFdCngCom->seed2 );
+ if ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( st->idchan, 1 ) )
+ {
+ seed2 = &( hFdCngCom->seed3 );
+ }
+
+ /* Generate Gaussian random noise in real and imaginary parts of the FFT bins
+ Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */
+
+ IF( hFdCngCom->startBand == 0 )
+ {
+ test();
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) )
+ {
+ rand_gauss_fx( &tmp1, seed, Q15 );
+ rand_gauss_fx( &tmp2, seed2, Q15 );
+ fftBuffer[0] = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) );
+ move32();
+ fftBuffer_temp_exp[0] = Q16 + Q15;
+ }
+ ELSE
+ {
+ rand_gauss_fx( &fftBuffer[0], seed, Q15 );
+ fftBuffer_temp_exp[0] = Q16;
+ move16();
+ }
+ sqrtNoiseLevel_exp = cngNoiseLevel_exp;
+ move16();
+ sqrtNoiseLevel = Sqrt32( *ptr_level, &sqrtNoiseLevel_exp );
+ fftBuffer[0] = Mpy_32_32( fftBuffer[0], sqrtNoiseLevel );
+ move32();
+ fftBuffer_temp_exp[0] = add( sqrtNoiseLevel_exp, fftBuffer_temp_exp[0] );
+ move16();
+ ptr_level++;
+ ptr_r = fftBuffer + 2;
+ idx = 2;
+ }
+ ELSE
+ {
+ fftBuffer[0] = 0;
+ move16();
+ set32_fx( fftBuffer + 2, 0, shl( sub( hFdCngCom->startBand, 1 ), 1 ) );
+ ptr_r = fftBuffer + shl( hFdCngCom->startBand, 1 );
+ idx = shl( hFdCngCom->startBand, 1 );
+ }
+
+ ptr_i = ptr_r + 1;
+ FOR( ; ptr_level < cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); ptr_level++ )
+ {
+ /* Real part in FFT bins */
+ test();
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) )
+ {
+ rand_gauss_fx( &tmp1, seed, Q15 );
+ rand_gauss_fx( &tmp2, seed2, Q15 );
+ *ptr_r = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) );
+ move32();
+ fftBuffer_temp_exp[idx] = Q16;
+ move16();
+ }
+ ELSE
+ {
+ rand_gauss_fx( ptr_r, seed, Q15 );
+ fftBuffer_temp_exp[idx] = Q16;
+ move16();
+ }
+
+ sqrtNoiseLevel_exp = sub( cngNoiseLevel_exp, 1 );
+ sqrtNoiseLevel = Sqrt32( *ptr_level, &sqrtNoiseLevel_exp );
+ ( *ptr_r ) = Mpy_32_32( ( *ptr_r ), sqrtNoiseLevel );
+ move32();
+ fftBuffer_temp_exp[idx] = add( fftBuffer_temp_exp[idx], sqrtNoiseLevel_exp );
+ move16();
+ idx = add( idx, 1 );
+ ptr_r += 2;
+
+ /* Imaginary part in FFT bins */
+ test();
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) )
+ {
+ rand_gauss_fx( &tmp1, seed, Q15 );
+ rand_gauss_fx( &tmp2, seed2, Q15 );
+ *ptr_i = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) );
+ move32();
+ fftBuffer_temp_exp[idx] = Q16;
+ move16();
+ }
+ ELSE
+ {
+ rand_gauss_fx( ptr_i, seed, Q15 );
+ fftBuffer_temp_exp[idx] = Q16;
+ move16();
+ }
+ sqrtNoiseLevel_exp = sub( cngNoiseLevel_exp, 1 );
+ sqrtNoiseLevel = Sqrt32( *ptr_level, &sqrtNoiseLevel_exp );
+ ( *ptr_i ) = Mpy_32_32( ( *ptr_i ), sqrtNoiseLevel );
+ move32();
+ fftBuffer_temp_exp[idx] = add( fftBuffer_temp_exp[idx], sqrtNoiseLevel_exp );
+ move16();
+ idx = add( idx, 1 );
+ ptr_i += 2;
+ }
+
+ /* Remaining FFT bins are set to zero */
+ set32_fx( fftBuffer + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) );
+ set16_fx( fftBuffer_temp_exp + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) );
+
+ /* Nyquist frequency is discarded */
+ fftBuffer[1] = 0;
+ move32();
+
+ fftBuffer_exp = MAX_16;
+ move16();
+ FOR( i = 0; i < FFTLEN; i++ )
+ {
+ if ( fftBuffer[i] != 0 )
+ {
+ fftBuffer_exp = s_min( fftBuffer_exp, add( sub( 31, fftBuffer_temp_exp[i] ), norm_l( fftBuffer[i] ) ) );
+ }
+ }
+ if ( EQ_16( fftBuffer_exp, MAX_16 ) )
+ {
+ fftBuffer_exp = 0;
+ move16();
+ }
+ fftBuffer_exp = sub( 31, fftBuffer_exp );
+ FOR( i = 0; i < FFTLEN; i++ )
+ {
+ fftBuffer[i] = L_shr( fftBuffer[i], sub( fftBuffer_exp, fftBuffer_temp_exp[i] ) );
+ move32();
+ }
+
+ /* If previous frame is active, reset the overlap-add buffer */
+ tcx_transition = 0;
+ move16();
+ IF( EQ_16( hFdCngCom->frame_type_previous, ACTIVE_FRAME ) )
+ {
+ set16_fx( hFdCngCom->olapBufferSynth, 0, hFdCngCom->fftlen );
+ test();
+ test();
+ if ( ( st->last_core_bfi > ACELP_CORE && EQ_16( st->codec_mode, MODE2 ) ) || EQ_16( st->codec_mode, MODE1 ) )
+ {
+ tcx_transition = 1;
+ move16();
+ }
+ }
+
+ /* Perform STFT synthesis */
+ SynthesisSTFT( fftBuffer, fftBuffer_exp, timeDomainOutput, hFdCngCom->olapBufferSynth, hFdCngCom->olapWinSyn,
+ tcx_transition, hFdCngCom, gen_exc, Q_new, st->element_mode, nchan_out );
+ scale_sig32( fftBuffer + hFdCngCom->fftlen, sub( FFTLEN, hFdCngCom->fftlen ), sub( fftBuffer_exp, hFdCngCom->fftBuffer_exp ) );
+
+ {
+ Word32 Lener, att;
+ Word16 exp;
+ /* update CNG excitation energy for LP_CNG */
+
+ /* calculate the residual signal energy */
+ /*enr = dotp( hFdCngCom->exc_cng, hFdCngCom->exc_cng, hFdCngCom->frameSize ) / hFdCngCom->frameSize;*/
+ Lener = Dot_productSq16HQ( 1, hFdCngCom->exc_cng, st->L_frame, &exp );
+ exp = add( sub( shl( sub( 15, *Q_new ), 1 ), 8 ), exp ); /*8 = log2(256)*/
+
+ /* convert log2 of residual signal energy */
+ /*(float)log10( enr + 0.1f ) / (float)log10( 2.0f );*/
+ Lener = BASOP_Util_Log2( Lener );
+ Lener = L_add( Lener, L_shl( L_deposit_l( exp ), WORD32_BITS - 1 - LD_DATA_SCALE ) ); /*Q25*/
+ if ( EQ_16( st->L_frame, L_FRAME16k ) )
+ {
+ Lener = L_sub( Lener, 10802114l /*0.3219280949f Q25*/ ); /*log2(320) = 8.3219280949f*/
+ }
+ /* decrease the energy in case of WB input */
+ IF( st->bwidth != NB )
+ {
+ IF( EQ_16( st->bwidth, WB ) )
+ {
+ IF( st->CNG_mode >= 0 )
+ {
+ /* Bitrate adapted attenuation */
+ att = L_shl( L_deposit_l( ENR_ATT_fx[st->CNG_mode] ), 17 );
+ }
+ ELSE
+ {
+ /* Use least attenuation for higher bitrates */
+ att = L_shl( L_deposit_l( ENR_ATT_fx[4] ), 17 );
+ }
+ }
+ ELSE
+ {
+ att = 384 << 17;
+ move16(); /*1.5 Q8<<17=Q25*/
+ }
+ Lener = L_sub( Lener, att );
+ }
+ /*st->lp_ener = 0.8f * stcod->lp_ener + 0.2f * pow( 2.0f, enr );*/
+ Lener = BASOP_util_Pow2( Lener, 6, &exp );
+ Lener = Mult_32_16( Lener, 6554 /*0.2f Q15*/ );
+ exp = sub( 25, exp );
+ Lener = L_shr( Lener, exp ); /*Q6*/
+ st->lp_ener_fx = L_add( Mult_32_16( st->lp_ener_fx, 26214 /*0.8f Q15*/ ), Lener ); /*Q6*/
+ }
+
+ /* Generate Gaussian random noise in real and imaginary parts of the CLDFB bands
+ Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each band */
+
+ test();
+ IF( bufferReal != NULL && ( LT_16( hFdCngCom->numCoreBands, hFdCngCom->regularStopBand ) ) )
+ {
+ Word16 bufferReal_exp[CLDFB_NO_COL_MAX];
+ Word16 bufferImag_exp[CLDFB_NO_COL_MAX];
+ *bufferScale = 0;
+ move16();
+ FOR( j = hFdCngCom->numCoreBands; j < hFdCngCom->regularStopBand; j++ )
+ {
+ sqrtNoiseLevel_exp = add( CLDFBinvScalingFactor_EXP, sub( cngNoiseLevel_exp, 1 ) );
+ sqrtNoiseLevel = Sqrt32( Mpy_32_16_1( *ptr_level, scaleCldfb ), &sqrtNoiseLevel_exp );
+
+ FOR( i = 0; i < hFdCngCom->numSlots; i++ )
+ {
+ /* Real part in CLDFB band */
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) )
+ {
+ rand_gauss_fx( &tmp1, seed, Q15 );
+ rand_gauss_fx( &tmp2, seed2, Q15 );
+ bufferReal[i][j] = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) );
+ move32();
+ bufferReal_exp[j] = Q16;
+ move16();
+ }
+ ELSE
+ {
+ rand_gauss_fx( &bufferReal[i][j], seed, Q15 );
+ move32();
+ bufferReal_exp[j] = Q16;
+ move16();
+ }
+
+ bufferReal[i][j] = Mpy_32_32( bufferReal[i][j], sqrtNoiseLevel );
+ move32();
+ bufferReal_exp[j] = add( bufferReal_exp[j], sqrtNoiseLevel_exp );
+ move16();
+
+ /* Imaginary part in CLDFB band */
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) )
+ {
+ rand_gauss_fx( &tmp1, seed, Q15 );
+ rand_gauss_fx( &tmp2, seed2, Q15 );
+ bufferImag[i][j] = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) );
+ move32();
+ bufferImag_exp[j] = Q16;
+ move16();
+ }
+ ELSE
+ {
+ rand_gauss_fx( &bufferImag[i][j], seed, Q15 );
+ bufferImag_exp[j] = Q16;
+ move16();
+ }
+ bufferImag[i][j] = Mpy_32_32( bufferImag[i][j], sqrtNoiseLevel );
+ bufferImag_exp[j] = add( bufferImag_exp[j], sqrtNoiseLevel_exp );
+ move16();
+
+ move32();
+ }
+ ptr_level++;
+ }
+
+ FOR( j = hFdCngCom->numCoreBands; j < hFdCngCom->regularStopBand; j++ )
+ {
+ *bufferScale = s_max( *bufferScale, bufferReal_exp[j] );
+ move16();
+ *bufferScale = s_max( *bufferScale, bufferImag_exp[j] );
+ move16();
+ }
+
+ FOR( j = hFdCngCom->numCoreBands; j < hFdCngCom->regularStopBand; j++ )
+ {
+ FOR( i = 0; i < hFdCngCom->numSlots; i++ )
+ {
+ bufferImag[i][j] = L_shr( bufferImag[i][j], sub( *bufferScale, bufferImag_exp[j] ) );
+ move32();
+ bufferReal[i][j] = L_shr( bufferReal[i][j], sub( *bufferScale, bufferReal_exp[j] ) );
+ move32();
+ }
+ }
+ }
+
+ test();
+ IF( EQ_16( hFdCngCom->frame_type_previous, ACTIVE_FRAME ) && EQ_16( st->codec_mode, MODE2 ) )
+ {
+ Word32 old_exc_ener, gain, noise32;
+ Word16 seed_loc, lpcorder, old_syn, tmp, gain16, N, N2, N4, N8;
+ Word16 old_exc_ener_exp, gain_exp;
+ Word16 normFacE, normShiftE, normShiftEM1;
+ Word16 normFacG, normShiftG, normShiftGM1;
+ Word16 noiseExp, *old_exc, *old_Aq, *old_syn_pe;
+ Word16 noise[640], normShiftP2;
+ Word16 Q_exc, Q_syn;
+
+
+ assert( hFdCngCom->frameSize <= 640 );
+
+ seed_loc = hFdCngCom->seed;
+ move16();
+ N = hFdCngCom->frameSize;
+ move16();
+ N2 = shr( hFdCngCom->frameSize, 1 );
+
+ IF( st->last_core_bfi > ACELP_CORE )
+ {
+ Word16 left_overlap_mode;
+ left_overlap_mode = st->hTcxCfg->tcx_last_overlap_mode;
+ move16();
+ if ( EQ_16( left_overlap_mode, ALDO_WINDOW ) )
+ {
+ left_overlap_mode = FULL_OVERLAP;
+ move16();
+ }
+ tcx_windowing_synthesis_current_frame( timeDomainOutput, st->hTcxCfg->tcx_mdct_window, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_half_length,
+ st->hTcxCfg->tcx_mdct_window_min_length, 0, left_overlap_mode, NULL, NULL, NULL, NULL, NULL, shr( N, 1 ), shr( sub( abs_s( st->hTcxCfg->tcx_offset ), st->hTcxCfg->tcx_offset ), 1 ), 1, 0, 0 );
+
+ IF( st->hTcxCfg->last_aldo != 0 )
+ {
+ FOR( i = 0; i < sub( hFdCngCom->frameSize, NS2SA( st->sr_core, N_ZERO_MDCT_NS ) ); i++ )
+ {
+ timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) );
+ move16();
+ }
+ }
+ ELSE
+ {
+ tcx_windowing_synthesis_past_frame( hTcxDec->syn_Overl, st->hTcxCfg->tcx_mdct_window, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum,
+ st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->hTcxCfg->tcx_last_overlap_mode );
+
+ FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_length; i++ )
+ {
+ timeDomainOutput[i] = add( timeDomainOutput[i], shl( hTcxDec->syn_Overl[i], TCX_IMDCT_HEADROOM ) );
+ move16();
+ }
+ }
+ }
+ ELSE
+ {
+
+ /*
+ - the scaling of the LPCs (e.g. old_Aq) is always Q12 (encoder or decoder)
+
+ - the scaling of the deemphasized signals (e.g. old_syn) is always Q0 (encoder or decoder)
+
+ - the scaling of the excitation signals in the encoder (e.g. old_exc) is Q_new
+ - the scaling of the preemphasized signals in the encoder (e.g. old_syn_pe) is Q_new-1
+
+ - the scaling of the excitation signals in the decoder (e.g. old_exc) is Q_exc (or stdec->Q_exc)
+ - the scaling of the preemphasized signals in the decoder (e.g. old_syn_pe) is Q_syn (or stdec->Q_syn)
+ */
+
+ lpcorder = M;
+ move16();
+ old_Aq = st->old_Aq_12_8_fx;
+ old_exc = st->old_exc_fx + sub( L_EXC_MEM_DEC, N2 );
+ old_syn_pe = st->mem_syn2_fx;
+ old_syn = st->syn[lpcorder];
+ move16();
+ preemph_fac = st->preemph_fac;
+ move16();
+ Q_exc = st->Q_exc;
+ move16();
+ Q_syn = st->Q_syn;
+ move16();
+
+ /* shift to be in the range of values supported by getNormReciprocalWord16() */
+ N8 = shr( N2, CNG_NORM_RECIPROCAL_RANGE_SHIFT );
+
+ assert( N2 == ( N8 << CNG_NORM_RECIPROCAL_RANGE_SHIFT ) );
+
+ normFacE = getNormReciprocalWord16( N8 );
+ normShiftE = BASOP_util_norm_s_bands2shift( N8 );
+ normShiftEM1 = sub( normShiftE, 1 );
+ normShiftP2 = add( normShiftE, CNG_NORM_RECIPROCAL_RANGE_SHIFT );
+
+ old_exc_ener = L_shr( L_mult( old_exc[0], old_exc[0] ), normShiftP2 );
+ FOR( i = 1; i < N2; i++ )
+ {
+ old_exc_ener = L_add( old_exc_ener, L_shr( L_mult( old_exc[i], old_exc[i] ), normShiftP2 ) );
+ }
+ old_exc_ener = L_shl( Mpy_32_16_1( old_exc_ener, shl( normFacE, normShiftEM1 ) ), 1 );
+
+ old_exc_ener_exp = 0;
+ move16();
+ old_exc_ener = Sqrt32( old_exc_ener, &old_exc_ener_exp );
+ old_exc_ener_exp = add( old_exc_ener_exp, ( sub( 15, Q_exc ) ) );
+
+ /* shift to be in the range of values supported by getNormReciprocalWord16() */
+ N4 = shr( N, CNG_NORM_RECIPROCAL_RANGE_SHIFT );
+
+ assert( N == ( N4 << CNG_NORM_RECIPROCAL_RANGE_SHIFT ) );
+
+ normFacG = getNormReciprocalWord16( N4 );
+ normShiftG = BASOP_util_norm_s_bands2shift( N4 );
+ normShiftGM1 = sub( normShiftG, 1 );
+ normShiftP2 = add( normShiftG, CNG_NORM_RECIPROCAL_RANGE_SHIFT );
+
+ gain = L_deposit_l( 0 );
+ FOR( i = 0; i < N; i++ )
+ {
+ noise32 = rand_gauss( &seed_loc );
+ noise[i] = extract_h( noise32 );
+ move16();
+ gain = L_add( gain, L_shr( L_mult( noise[i], noise[i] ), normShiftP2 ) );
+ }
+ gain = L_shl( Mpy_32_16_1( gain, shl( normFacG, normShiftGM1 ) ), 1 );
+
+ gain_exp = 2 * CNG_RAND_GAUSS_SHIFT;
+ move16();
+ gain = ISqrt32( gain, &gain_exp );
+
+ gain = Mpy_32_32( old_exc_ener, gain );
+ gain16 = extract_h( gain );
+
+ gain_exp = add( old_exc_ener_exp, gain_exp );
+ noiseExp = add( CNG_RAND_GAUSS_SHIFT, gain_exp );
+
+ s = sub( 15 - NOISE_HEADROOM, noiseExp );
+ FOR( i = 0; i < N; i++ )
+ {
+#ifdef BASOP_NOGLOB
+ noise[i] = shr_sat( mult( noise[i], gain16 ), s );
+#else
+ noise[i] = shr( mult( noise[i], gain16 ), s );
+#endif
+ move16();
+ }
+
+ assert( lpcorder <= 16 );
+
+ s = sub( 15 - NOISE_HEADROOM, ( sub( 15, Q_syn ) ) );
+ FOR( i = 0; i < lpcorder; i++ )
+ {
+#ifdef BASOP_NOGLOB
+ old_syn_pe_tmp[i] = shr_sat( old_syn_pe[i], s );
+#else
+ old_syn_pe_tmp[i] = shr( old_syn_pe[i], s );
+#endif
+ move16();
+ }
+
+ E_UTIL_synthesis(
+ 0, /* i : scaling to apply for a[0] Q0 */
+ old_Aq, /* i : LP filter coefficients Q12 */
+ noise, /* i : input signal Qx */
+ noise, /* o : output signal Qx-s */
+ N, /* i : size of filtering Q0 */
+ old_syn_pe_tmp, /* i/o: memory associated with this filtering. Q0 */
+ 0, /* i : 0=no update, 1=update of memory. Q0 */
+ lpcorder /* i : order of LP filter Q0 */
+ );
+
+ tmp = old_syn;
+ move16();
+
+ E_UTIL_deemph2(
+ NOISE_HEADROOM,
+ noise, /* I/O: signal Qx */
+ preemph_fac, /* I: deemphasis factor Qx */
+ N, /* I: vector size */
+ &tmp /* I/O: memory (signal[-1]) Qx */
+ );
+
+ FOR( i = 0; i < N4; i++ )
+ {
+ tmp = mult( noise[i], hFdCngCom->olapWinSyn[i].v.re );
+ timeDomainOutput[i] = add( timeDomainOutput[i], tmp );
+ move16();
+ tmp = mult( noise[add( i, N4 )], hFdCngCom->olapWinSyn[sub( sub( N4, 1 ), i )].v.im );
+ timeDomainOutput[add( i, N4 )] = add( timeDomainOutput[add( i, N4 )], tmp );
+ move16();
+ }
+ }
+ }
+ return;
+}
void generate_comfort_noise_dec_hf_fx(
Word32 **bufferReal, /* o : matrix to real part of input bands */
@@ -3922,7 +4498,7 @@ void generate_comfort_noise_dec_hf_ivas_fx(
move16();
}
- randGaussExp = CNG_RAND_GAUSS_SHIFT;
+ randGaussExp = add( CNG_RAND_GAUSS_SHIFT, 1 );
move16();
/*
@@ -3946,16 +4522,16 @@ void generate_comfort_noise_dec_hf_ivas_fx(
IF( cng_coh_flag )
{
- tmp1 = rand_gauss( seed );
- tmp2 = rand_gauss( seed2 );
+ rand_gauss_fx( &tmp1, seed, Q28 );
+ rand_gauss_fx( &tmp2, seed2, Q28 );
bufferReal[i][j] = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) );
move32();
bufferReal[i][j] = L_shl( Mpy_32_32( bufferReal[i][j], sqrtNoiseLevel ), s );
move32();
- tmp1 = rand_gauss( seed );
- tmp2 = rand_gauss( seed2 );
+ rand_gauss_fx( &tmp1, seed, Q28 );
+ rand_gauss_fx( &tmp2, seed2, Q28 );
bufferImag[i][j] = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) );
move32();
@@ -3965,11 +4541,11 @@ void generate_comfort_noise_dec_hf_ivas_fx(
ELSE
{
/* Real part in CLDFB band */
- bufferReal[i][j] = L_shl( Mpy_32_32( rand_gauss( seed ), sqrtNoiseLevel ), s );
+ bufferReal[i][j] = L_shl( Mpy_32_32( L_shr( rand_gauss( seed ), 1 ), sqrtNoiseLevel ), s );
move32();
/* Imaginary part in CLDFB band */
- bufferImag[i][j] = L_shl( Mpy_32_32( rand_gauss( seed ), sqrtNoiseLevel ), s );
+ bufferImag[i][j] = L_shl( Mpy_32_32( L_shr( rand_gauss( seed ), 1 ), sqrtNoiseLevel ), s );
move32();
}
}
diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c
index dd8b57681624f4aa2fff3799b68a6d3222b91a87..ab561a354e5cc78c7a5cd117709aeaf898df1124 100644
--- a/lib_dec/gain_dec_fx.c
+++ b/lib_dec/gain_dec_fx.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*===========================================================================*/
@@ -63,6 +62,7 @@ void Es_pred_dec_fx(
ELSE
{
*Es_pred = Es_pred_qua_4b_no_ltp_fx[enr_idx];
+ move16();
}
}
/*======================================================================================*/
@@ -117,6 +117,7 @@ void gain_dec_tc_fx(
* find number of bits for gain dequantization
*----------------------------------------------------------------*/
nBits = st_fx->acelp_cfg.gains_mode[shr( i_subfr_fx, 6 )];
+ move16();
/*-----------------------------------------------------------------*
* calculate the predicted gain code
*-----------------------------------------------------------------*/
@@ -256,6 +257,7 @@ void gain_dec_tc_ivas_fx(
* find number of bits for gain dequantization
*----------------------------------------------------------------*/
nBits = st_fx->acelp_cfg.gains_mode[shr( i_subfr_fx, 6 )];
+ move16();
/*-----------------------------------------------------------------*
* calculate the predicted gain code
*-----------------------------------------------------------------*/
@@ -301,7 +303,6 @@ void gain_dec_tc_ivas_fx(
/* index = (Word16)get_indice( st_fx,"gain_code", i_subfr_fx, ACELP_CORE);move16();*/
index = (Word16) get_next_indice( st_fx, nBits );
- move16();
IF( GT_16( nBits, 3 ) )
@@ -388,6 +389,8 @@ void gain_dec_mless_fx(
* decode pitch gain
*-----------------------------------------------------------------*/
nBits = st_fx->acelp_cfg.gains_mode[shr( i_subfr_fx, 6 )];
+ move16();
+
test();
test();
test();
@@ -398,7 +401,6 @@ void gain_dec_mless_fx(
{
/* decode pitch gain */
index = (Word16) get_next_indice( st_fx, shr( nBits, 1 ) );
- move16();
/*Ei = (G_PITCH_MAX_TC192 - G_PITCH_MIN_TC192) / ((1 << (nBits>>1)) - 1);*/ /* set quantization step */
tmp_fx = div_s( 1, sub( shl( 1, shr( nBits, 1 ) ), 1 ) ); /*Q15*/
@@ -420,6 +422,7 @@ void gain_dec_mless_fx(
L_tmp = Isqrt_lc( L_tmp, &expg );
*gain_inov_fx = extract_h( L_shl( L_tmp, sub( expg, 3 ) ) ); /* gain_inov in Q12 */
+ move16();
/*Ei = 10 * (float)log10( Ecode );*/
e_tmp = norm_l( L_tmp1 );
@@ -452,11 +455,9 @@ void gain_dec_mless_fx(
/* decode normalized codebook gain */
/*index = (short)get_indice( st_fx, "gain_code", i_subfr_fx, ACELP_CORE );move16();*/
index = (Word16) get_next_indice( st_fx, shr( add( nBits, 1 ), 1 ) );
- move16();
/**gain_code = gain_dequant( index, G_CODE_MIN_TC192, G_CODE_MAX_TC192, (nBits+1)>>1 );*/
gain_code16 = gain_dequant_fx( index, G_CODE_MIN_TC192_Q15, G_CODE_MAX_TC192_Q0, shr( add( nBits, 1 ), 1 ), &expg );
- move16();
/**gain_code *= gcode0;*/
L_tmp = L_mult( gain_code16, gcode0_fx ); /*Q0*Q0 -> Q1*/
@@ -474,14 +475,12 @@ void gain_dec_mless_fx(
case 7:
{
qua_table_fx = gain_qua_mless_7b_fx;
- move16();
BREAK;
}
case 6:
{
qua_table_fx = gain_qua_mless_6b_fx;
- move16();
- IF( GT_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode > EVS_MONO )
{
// PMT("gain_qua_mless_6b_stereo to fixed point")
qua_table_fx = gain_qua_mless_6b_stereo_fx;
@@ -491,25 +490,22 @@ void gain_dec_mless_fx(
case 5:
{
qua_table_fx = gain_qua_mless_5b_fx;
- move16();
BREAK;
}
default:
{
qua_table_fx = gain_qua_mless_6b_fx;
- move16();
BREAK;
}
}
test();
- if ( EQ_16( coder_type, INACTIVE ) && EQ_16( nBits, 6 ) )
+ if ( coder_type == INACTIVE && EQ_16( nBits, 6 ) )
{
nBits = sub( nBits, 1 );
}
index = (Word16) get_next_indice( st_fx, nBits );
- move16();
*gain_pit_fx = qua_table_fx[index * 2];
move16();
@@ -526,6 +522,7 @@ void gain_dec_mless_fx(
L_tmp = Isqrt_lc( L_tmp, &expg );
*gain_inov_fx = extract_h( L_shl( L_tmp, sub( expg, 3 ) ) ); /* gain_inov in Q12 */
+ move16();
/*Ei = 10 * (float)log10( Ecode );*/
e_tmp = norm_l( L_tmp1 );
@@ -629,8 +626,9 @@ void gain_dec_lbr_fx(
*gain_inov = 1.0f / (float)sqrt(Ecode); */
Word16 shift_L_subfr;
shift_L_subfr = 6;
+ move16(); // for *cdbk_fx
move16();
- IF( GT_16( L_subfr, L_SUBFR ) )
+ if ( GT_16( L_subfr, L_SUBFR ) )
{
shift_L_subfr = add( shift_L_subfr, 1 );
}
@@ -644,7 +642,7 @@ void gain_dec_lbr_fx(
L_tmp = Isqrt_lc( L_tmp, &expg );
*gain_inov_fx = extract_h( L_shl_sat( L_tmp, sub( expg, 3 ) ) ); /* gain_inov in Q12 */
-
+ move16();
/*-----------------------------------------------------------------*
* select the codebook, size and number of bits
@@ -671,19 +669,16 @@ void gain_dec_lbr_fx(
case 8:
{
cdbk_fx = gp_gamma_1sfr_8b_fx; /* Q14/Q9*/
- move16();
BREAK;
}
case 7:
{
cdbk_fx = gp_gamma_1sfr_7b_fx; /* Q14/Q9*/
- move16();
BREAK;
}
case 6:
{
cdbk_fx = gp_gamma_1sfr_6b_fx; /* Q14/Q9*/
- move16();
BREAK;
}
}
@@ -692,6 +687,7 @@ void gain_dec_lbr_fx(
aux_fx[0] = 4096;
move16();
aux_fx[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));
@@ -727,7 +723,6 @@ void gain_dec_lbr_fx(
/* retrieve the codebook index and calculate both gains */
/*index = (Word16)get_indice( st_fx,"gain", i_subfr, ACELP_CORE);move16();*/
index = (Word16) get_next_indice( st_fx, nBits );
- move16();
*gain_pit_fx = cdbk_fx[index * 2];
move16();
@@ -758,13 +753,11 @@ void gain_dec_lbr_fx(
case 7:
{
cdbk_fx = gp_gamma_2sfr_7b_fx; /* Q14/Q9*/
- move16();
BREAK;
}
case 6:
{
cdbk_fx = gp_gamma_2sfr_6b_fx; /* Q14/Q9*/
- move16();
BREAK;
}
}
@@ -773,6 +766,7 @@ void gain_dec_lbr_fx(
aux_fx[0] = 4096;
move16();
aux_fx[1] = shl( ctype, 12 );
+ move16();
/*aux_fx[2] = (float)log10(gc_mem[0]);
= log2(gc_mem[0])*log10(2);*/
@@ -781,8 +775,10 @@ void gain_dec_lbr_fx(
e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[0])=16*/
L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
aux_fx[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
aux_fx[3] = shr( gp_mem[0], 2 ); /*Q12*/
+ move16();
/*-----------------------------------------------------------------*
* gcode0 = pow(10.0, dotp(b, aux, n_pred)
@@ -800,7 +796,6 @@ void gain_dec_lbr_fx(
/* retrieve the codebook index and calculate both gains */
index = (Word16) get_next_indice( st_fx, nBits );
- move16();
*gain_pit_fx = cdbk_fx[index * 2];
move16();
@@ -827,12 +822,11 @@ void gain_dec_lbr_fx(
cdbk_fx = gp_gamma_3sfr_6b_fx;
- IF( EQ_16( nBits, 7 ) )
+ if ( EQ_16( nBits, 7 ) )
{
cdbk_fx = gp_gamma_3sfr_7b_fx;
// PMT("verify if gp_gamma_3sfr_7b_fx is correct")
}
- move16(); /* Q14/Q9*/
/* calculate predicted gain */
aux_fx[0] = 4096;
@@ -847,6 +841,7 @@ void gain_dec_lbr_fx(
e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[0])=16*/
L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
aux_fx[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
/*aux[3] = (float)log10(gc_mem[1]);
= log2(gc_mem[1])*log10(2);*/
@@ -855,6 +850,7 @@ void gain_dec_lbr_fx(
e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[1])=16*/
L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
aux_fx[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
aux_fx[4] = shr( gp_mem[0], 2 );
move16();
@@ -877,9 +873,8 @@ void gain_dec_lbr_fx(
/* retrieve the codebook index and calculate both gains */
index = (Word16) get_next_indice( st_fx, nBits );
- move16();
- *gain_pit_fx = cdbk_fx[index * 2];
+ *gain_pit_fx = cdbk_fx[shl( index, 1 )];
move16();
L_tmp = L_mult( cdbk_fx[add( shl( index, 1 ), 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */
@@ -896,7 +891,6 @@ void gain_dec_lbr_fx(
ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) )
{
b_fx = b_4sfr_fx;
- move16();
n_pred = 8;
move16();
@@ -909,7 +903,6 @@ void gain_dec_lbr_fx(
PMT( "verify if gp_gamma_4sfr_7b_fx is correct" )
}
#endif
- move16(); /* Q14/Q9*/
/* calculate predicted gain */
aux_fx[0] = 4096;
@@ -924,6 +917,7 @@ void gain_dec_lbr_fx(
e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[0])=16*/
L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
aux_fx[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
/*aux[3] = (float)log10(gc_mem[1]);
= log2(gc_mem[1])*log10(2);*/
@@ -932,6 +926,7 @@ void gain_dec_lbr_fx(
e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[1])=16*/
L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
aux_fx[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
/*aux[4] = (float)log10(gc_mem[2]);
= log2(gc_mem[2])*log10(2);*/
@@ -940,6 +935,7 @@ void gain_dec_lbr_fx(
e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[2])=16*/
L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
aux_fx[4] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
+ move16();
aux_fx[5] = shr( gp_mem[0], 2 ); /*Q12*/
move16();
@@ -965,7 +961,7 @@ void gain_dec_lbr_fx(
/* retrieve the codebook index and calculate both gains */
index = (Word16) get_next_indice( st_fx, nBits );
move16();
- *gain_pit_fx = cdbk_fx[index * 2];
+ *gain_pit_fx = cdbk_fx[shl( index, 1 )];
move16();
L_tmp = L_mult( cdbk_fx[add( shl( index, 1 ), 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */
@@ -1033,8 +1029,140 @@ void lp_gain_updt_fx(
tmp = extract_h( L_shl( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/
#endif
IF( EQ_16( L_frame, L_FRAME ) )
+ {
+ IF( EQ_16( i_subfr, 0 ) )
+ {
+ *lp_gainp = mult( 3277, gain_pit );
+ move16(); /*0.1 in Q15 = 3277 , (15+14)-15 -> Q14*/
+ *lp_gainc = mult_r( 3277, tmp );
+ move16(); /* (15+3)-15 -> Q3*/
+ }
+ ELSE IF( EQ_16( i_subfr, L_SUBFR ) )
+ {
+ *lp_gainp = add( *lp_gainp, mult( 6554, gain_pit ) );
+ move16(); /*Q14 (0.2 in Q15 = 6554)*/
+ *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 6554, tmp );
+ move16(); /*Q3*/
+ }
+ ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) )
+ {
+ *lp_gainp = add( *lp_gainp, mult( 9830, gain_pit ) );
+ move16(); /*Q14 (0.3 in Q15 = 9830)*/
+ *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 9830, tmp );
+ move16(); /*Q3*/
+ }
+ ELSE /* i_subfr == 3*L_SUBFR */
+ {
+ *lp_gainp = add( *lp_gainp, mult( 13107, gain_pit ) );
+ move16(); /*Q14 (0.4 in Q15 = 13107)*/
+#ifdef BASOP_NOGLOB
+ *lp_gainc = mac_r_sat( L_deposit_h( *lp_gainc ), 13107, tmp );
+#else
+ *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 13107, tmp );
+#endif
+ move16(); /*Q3*/
+ }
+ }
+ ELSE
{
IF( i_subfr == 0 )
+ {
+ *lp_gainp = mult( 2185, gain_pit );
+ move16(); /*(1.0/15.0) in Q15 = 2185 , (15+14)-15 -> Q14*/
+ *lp_gainc = mult_r( 2185, tmp );
+ move16(); /* (15+3)-15 -> Q3*/
+ }
+ ELSE IF( EQ_16( i_subfr, L_SUBFR ) )
+ {
+ *lp_gainp = add( *lp_gainp, mult( 4369, gain_pit ) );
+ move16(); /*Q14 (2.0/15.0 in Q15 = 4369)*/
+ *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 4369, tmp );
+ move16(); /*Q3*/
+ }
+ ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) )
+ {
+ *lp_gainp = add( *lp_gainp, mult( 6554, gain_pit ) );
+ move16(); /*Q14 (3.0/15.0 in Q15 = 6554)*/
+ *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 6554, tmp );
+ move16(); /*Q3*/
+ }
+ ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) )
+ {
+ *lp_gainp = add( *lp_gainp, mult( 8738, gain_pit ) );
+ move16(); /*Q14 (4.0/15.0 in Q15 = 8738)*/
+ *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 8738, tmp );
+ move16(); /*Q3*/
+ }
+ ELSE /* i_subfr == 4*L_SUBFR */
+ {
+ *lp_gainp = add( *lp_gainp, mult( 10923, gain_pit ) );
+ move16(); /*Q14 (5.0/15.0 in Q15 = 10923)*/
+#ifdef BASOP_NOGLOB
+ *lp_gainc = mac_r_sat( L_deposit_h( *lp_gainc ), 10923, tmp );
+#else
+ *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 10923, tmp );
+#endif
+ move16(); /*Q3*/
+ }
+ }
+ return;
+}
+
+/*====================================================================== */
+/* FUNCTION : lp_gain_updt_ivas_fx() */
+/*-----------------------------------------------------------------------*/
+/* PURPOSE : Update of LP pitch and code gains (FEC) */
+/* */
+/*-----------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) i_subfr : subframe number Q0 */
+/* _ (Word16) gain_pit : Decoded gain pitch Q14 */
+/* _ (Word32) norm_gain_code : Normalised gain code Q16 */
+/* _ (Word16) L_frame : length of the frame Q0 */
+/*-----------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16 *) T0 : close loop integer pitch */
+/* _ (Word16 *) T0_frac : close loop fractional part of the pitch */
+/* _ (Word16 ) pitch : pitch value Q6 */
+/*-----------------------------------------------------------------------*/
+/* INPUT OUTPUT ARGUMENTS */
+/* _ (Word16 *) lp_gainp : LP-filtered pitch gain(FEC) Q14 */
+/* _ (Word16 *) lp_gainc : LP-filtered code gain (FEC) Q3 */
+/*-----------------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*=======================================================================*/
+
+
+void lp_gain_updt_ivas_fx(
+ const Word16 i_subfr, /* i : subframe number Q0 */
+ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */
+ const Word32 norm_gain_code, /* i : Normalised gain code Q16 */
+ Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */
+ Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */
+ const Word16 L_frame /* i : length of the frame */
+)
+{
+ Word16 tmp;
+
+#ifdef BASOP_NOGLOB
+ tmp = extract_h( L_shl_sat( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/
+#else
+ tmp = extract_h( L_shl( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/
+#endif
+ /* To handle extremely low values */
+ test();
+ if ( norm_gain_code != 0 && tmp == 0 )
+ {
+ tmp = 1;
+ move16();
+ }
+
+ IF( EQ_16( L_frame, L_FRAME ) )
+ {
+ IF( EQ_16( i_subfr, 0 ) )
{
*lp_gainp = mult( 3277, gain_pit );
move16(); /*0.1 in Q15 = 3277 , (15+14)-15 -> Q14*/
@@ -1109,6 +1237,15 @@ void lp_gain_updt_fx(
move16(); /*Q3*/
}
}
+
+ /* To handle extremely low values */
+ test();
+ if ( tmp != 0 && *lp_gainc == 0 )
+ {
+ *lp_gainc = 1;
+ move16();
+ }
+
return;
}
@@ -1239,6 +1376,7 @@ void gain_dec_SQ_fx(
L_tmp = Isqrt_lc( L_tmp, &expg );
*gain_inov = extract_h( L_shl( L_tmp, sub( expg, 3 ) ) ); /* gain_inov in Q12 */
+ move16();
/*Ei = 10 * (float)log10( Ecode );*/
e_tmp = norm_l( L_tmp1 );
@@ -1313,6 +1451,7 @@ void gain_dec_amr_wb_fx(
Word16 expg, exp_gcode0, fracg;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -1323,6 +1462,7 @@ void gain_dec_amr_wb_fx(
L_tmp = Isqrt_lc( L_tmp, &expg );
*gain_inov = extract_h( L_shl( L_tmp, sub( expg, 3 ) ) ); /* gain_inov in Q12 */
+ move16();
/*-----------------------------------------------------------------*
* Select the gain quantization table
@@ -1331,7 +1471,7 @@ void gain_dec_amr_wb_fx(
move16();
t_qua_gain = t_qua_gain7b_fx;
- IF( LT_32( core_brate, ACELP_12k65 ) )
+ if ( LT_32( core_brate, ACELP_12k65 ) )
{
nbits = 6;
move16();
diff --git a/lib_dec/gaus_dec_fx.c b/lib_dec/gaus_dec_fx.c
index 0dec8dbf632830dba87690961414f2c9e7eef50d..9cd2214bc92228b3b0d252401c515be4834d6914 100644
--- a/lib_dec/gaus_dec_fx.c
+++ b/lib_dec/gaus_dec_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*---------------------------------------------------------------------*
* Local function prototypes
@@ -67,14 +66,15 @@ void gaus_dec_fx(
exp = sub( exp, 18 /*24*/ + 6 ); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */
L_tmp = Isqrt_lc( L_tmp, &exp );
*inv_gain_inov = extract_h( L_shl( L_tmp, sub( exp, 3 ) ) ); /* inv_gain_inov in Q12 */
+ move16();
nb_bits = st_fx->acelp_cfg.gains_mode[shr( i_subfr, 6 )];
move16();
idx = (Word16) get_next_indice( st_fx, nb_bits );
- move16();
/* safety check in case of bit errors */
- IF( GT_16( idx, 78 ) && EQ_16( st_fx->element_mode, EVS_MONO ) )
+ test();
+ IF( GT_16( idx, 78 ) && st_fx->element_mode == EVS_MONO )
{
idx = 78;
move16();
@@ -83,9 +83,17 @@ void gaus_dec_fx(
}
*L_gain_code = gain_dec_gaus_fx( idx, nb_bits, -30, 190, *inv_gain_inov, L_norm_gain_code );
+ move32();
/* update LP filtered gains for the case of frame erasures */
- lp_gain_updt_fx( i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ lp_gain_updt_fx( i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */
+ }
+ ELSE
+ {
+ lp_gain_updt_ivas_fx( i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */
+ }
/*------------------------------------------------------------------------------------------*
* Updates
@@ -122,7 +130,8 @@ void gaus_dec_fx(
FOR( i = 0; i < L_SUBFR; i++ )
{
L_tmp = L_shl( L_mult( gain_code, code[i] ), 6 /*3*/ );
- exc[i + i_subfr] = round_fx( L_tmp );
+ exc[add( i, i_subfr )] = round_fx( L_tmp );
+ move16();
}
return;
@@ -174,6 +183,7 @@ void gaus_dec2v_fx(
/* gaus_dico2[i] = (gaus_dico_fx[i] - delta*gaus_dico_fx[i-1])/(1+delta*delta) */
tmp16 = msu_r( L_deposit_h( gaus_dico_fx[i] ), delta, gaus_dico_fx[i - 1] );
gaus_dico2_fx[i] = mult_r( tmp16, inv_delta );
+ move16();
}
}
ELSE
@@ -186,15 +196,14 @@ void gaus_dec2v_fx(
}
pt1 = &gaus_dico2_fx[i_mult2( ind1, step )];
- move16();
pt2 = &gaus_dico2_fx[i_mult2( ind2, step )];
- move16();
FOR( i = 0; i < lg; i++ )
{
/* code is Q9, Gaussian codebook is Q12 */
/* code[i] = pt1[i] * sign1 + pt2[i] * sign2 */
code[i] = add( mult( pt1[i], sign1 ), mult( pt2[i], sign2 ) );
+ move16();
}
return;
@@ -236,7 +245,7 @@ static void dec_2pos_fx(
move16();
*sign2 = *sign1;
move16();
- if ( GT_16( *ind1, *ind2 ) )
+ IF( GT_16( *ind1, *ind2 ) )
{
*sign2 = negate( *sign1 );
move16();
diff --git a/lib_dec/gs_dec_amr_wb_fx.c b/lib_dec/gs_dec_amr_wb_fx.c
index f55b5e87766a95d4d9bbdd6b2debaf102013bb4f..5864c697cc2caae3420577ab2bcdaee58a45d50a 100644
--- a/lib_dec/gs_dec_amr_wb_fx.c
+++ b/lib_dec/gs_dec_amr_wb_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*-------------------------------------------------------------------*
@@ -71,6 +70,7 @@ static void NoiseFill_fx(
L_temp = L_mult( Random( seed_tcx ), fact );
L_temp = L_msu( L_temp, exc_diffQ_fx[CurBin], -32768 );
exc_diffQ_fx[CurBin] = round_fx( L_temp );
+ move16();
}
}
@@ -175,6 +175,7 @@ static void Apply_gain_fx(
L_temp = L_mult( exc_diffQ_fx[CurBin], y_gain_fx );
L_temp = L_shr( L_temp, y_gain_exp );
exc_diffQ_fx[CurBin] = round_fx( L_temp );
+ move16();
}
}
}
@@ -212,6 +213,7 @@ static void normalize_spec_fx(
FOR( j = 0; j < L_frame; j++ )
{
fy_norm_fx[j] = round_fx( Mult_32_16( L_temp, fy_norm_fx[j] ) );
+ move16();
}
return;
@@ -300,7 +302,7 @@ static void gs_dec_amr_wb_fx(
test();
IF( L_temp <= CONTR_LIMIT && ( VeryLowRateSTflag || GE_32( core_brate, ACELP_12k65 ) ) )
#else
- IF( GE_32( core_brate, ACELP_12k65 ) )
+ if ( GE_32( core_brate, ACELP_12k65 ) )
#endif
{
L_temp = L_shl( L_temp, 1 );
@@ -361,6 +363,7 @@ static void gs_dec_amr_wb_fx(
temp2 = mult_r( temp2, temp ); /* Q15*Q9+1-16 -> Q9 */
L_temp = L_mult( exc_diffQ_fx[i], s_max( temp2, 512 ) ); /*Q(Qexc_diffQ+10) */
exc_diffQ_fx[i] = round_fx( L_shl( L_temp, 16 - 10 ) ); /*Qexc_diffQ */
+ move16();
}
/*--------------------------------------------------------------------------------------*
@@ -412,6 +415,7 @@ void improv_amr_wb_gs_fx(
Word16 Aq_orig[NB_SUBFR * ( M + 1 )], enr_LP_old, enr_LP_new;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*------------------------------------------------------------*
@@ -435,8 +439,8 @@ void improv_amr_wb_gs_fx(
#else
IF( ( locattack == 0 && LE_32( core_brate, ACELP_12k65 ) ) &&
( ( LT_32( core_brate, ACELP_8k85 ) && NE_16( clas, AUDIO_CLAS ) &&
- ( EQ_16( clas, UNVOICED_CLAS ) || EQ_16( clas, VOICED_TRANSITION ) ) ) ||
- EQ_16( coder_type, INACTIVE ) ) )
+ ( clas == UNVOICED_CLAS || EQ_16( clas, VOICED_TRANSITION ) ) ) ||
+ ( coder_type == INACTIVE ) ) )
#endif
{
/*------------------------------------------------------------*
@@ -446,32 +450,34 @@ void improv_amr_wb_gs_fx(
* LP filter smoothing for inactive parts
*------------------------------------------------------------*/
*seed_tcx = extract_l( L_mult0( pitch_buf_fx[0], pitch_buf_fx[3] ) );
+ move16();
/* last_coder_type == UNVOICED should be understand as INACTIVE, but it is forced to UNVOICED in update_dec */
test();
test();
test();
- IF( EQ_16( coder_type, INACTIVE ) && GT_16( Last_ener_fx, -3 * 256 ) && EQ_16( last_coder_type, UNVOICED ) && rate_switching_reset == 0 ) /* 3.0 x 256 to Go to Q8 */
+ IF( coder_type == INACTIVE && GT_16( Last_ener_fx, -3 * 256 ) && EQ_16( last_coder_type, UNVOICED ) && rate_switching_reset == 0 ) /* 3.0 x 256 to Go to Q8 */
{
FOR( i = 0; i < NB_SUBFR; i++ )
{
Copy( Aq_fx, Aq_orig, NB_SUBFR * ( M + 1 ) );
- exp_a = norm_s( Aq_fx[i * ( M + 1 )] );
- exp_b = norm_s( old_Aq_fx[i * ( M + 1 )] );
+ exp_a = norm_s( Aq_fx[imult1616( i, ( M + 1 ) )] );
+ exp_b = norm_s( old_Aq_fx[imult1616( i, ( M + 1 ) )] );
exp_diff = sub( exp_a, exp_b );
IF( exp_diff > 0 )
{
- Scale_sig( &old_Aq_fx[i * ( M + 1 )], ( M + 1 ), negate( exp_diff ) );
+ Scale_sig( &old_Aq_fx[imult1616( i, ( M + 1 ) )], ( M + 1 ), negate( exp_diff ) );
}
ELSE
{
- Scale_sig( &Aq_fx[i * ( M + 1 )], ( M + 1 ), exp_diff );
+ Scale_sig( &Aq_fx[imult1616( i, ( M + 1 ) )], ( M + 1 ), exp_diff );
}
- FOR( j = i * ( M + 1 ); j < ( i + 1 ) * ( M + 1 ); j++ )
+ FOR( j = imult1616( i, ( M + 1 ) ); j < imult1616( add( i, 1 ), ( M + 1 ) ); j++ )
{
Aq_fx[j] = round_fx( L_mac( L_mult( ALP_FX, old_Aq_fx[j] ), MALP_FX, Aq_fx[j] ) );
+ move16();
}
}
@@ -483,11 +489,12 @@ void improv_amr_wb_gs_fx(
FOR( i = 0; i < NB_SUBFR; i++ )
{
#ifdef BASOP_NOGLOB
- enr_LP_new = Enr_1_Az_fx_o( Aq_fx + i * ( M + 1 ), L_SUBFR, &Overflow );
+ enr_LP_new = Enr_1_Az_fx_o( Aq_fx + imult1616( i, ( M + 1 ) ), L_SUBFR, &Overflow );
#else
enr_LP_new = Enr_1_Az_fx( Aq_fx + i * ( M + 1 ), L_SUBFR );
#endif
- IF( ( shr( enr_LP_new, 7 ) > enr_LP_old ) || Overflow )
+ test();
+ IF( GT_16( shr( enr_LP_new, 7 ), enr_LP_old ) || Overflow )
{
/* filter is unstable, do not modify the excitation */
Copy( Aq_orig, Aq_fx, NB_SUBFR * ( M + 1 ) );
diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c
index 4c292536984760d224b67407bb15d953482f25c4..9bd541bc95d48403b87bf7e63ae254af94a68c8f 100644
--- a/lib_dec/gs_dec_fx.c
+++ b/lib_dec/gs_dec_fx.c
@@ -7,8 +7,7 @@
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_cnst.h"
#ifdef IVAS_FLOAT_FIXED
/*=========================================================================*/
@@ -67,6 +66,7 @@ void decod_audio_fx(
/*---------------------------------------------------------------*
* Initialization
*---------------------------------------------------------------*/
+ move16(); // corresponding to initialization of Es_pred
Diff_len = 0;
move16();
@@ -76,17 +76,19 @@ void decod_audio_fx(
/* decode GSC SWB speech flag */
test();
#if !defined ADD_LRTD
- IF( NE_16( st_fx->coder_type, INACTIVE ) && GE_32( st_fx->total_brate, ACELP_13k20 ) )
+ IF( st_fx->coder_type != INACTIVE && GE_32( st_fx->total_brate, ACELP_13k20 ) )
#else
if ( st_fx->GSC_IVAS_mode >= 1 || ( st_fx->coder_type != INACTIVE && ( ( st_fx->element_mode == EVS_MONO && st_fx->total_brate >= ACELP_13k20 ) ||
( st_fx->element_mode > EVS_MONO && st_fx->total_brate > MIN_BRATE_GSC_NOISY_FLAG && st_fx->bwidth >= SWB && !st_fx->flag_ACELP16k ) ) ) )
#endif
{
st_fx->GSC_noisy_speech = (Word16) get_next_indice( st_fx, 1 );
+ move16();
}
/* safety check in case of bit errors */
test();
+ test();
IF( st_fx->GSC_noisy_speech && LT_16( st_fx->bwidth, SWB ) && st_fx->GSC_IVAS_mode == 0 )
{
st_fx->BER_detect = 1;
@@ -142,10 +144,12 @@ void decod_audio_fx(
IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
{
hGSCDec->noise_lev = add( (Word16) get_next_indice( st_fx, 2 ), NOISE_LEVEL_SP2 );
+ move16();
}
ELSE
{
hGSCDec->noise_lev = add( (Word16) get_next_indice( st_fx, 3 ), NOISE_LEVEL_SP0 );
+ move16();
}
/*---------------------------------------------------------------*
@@ -177,7 +181,7 @@ void decod_audio_fx(
#endif
nb_frame_flg = (Word16) get_next_indice( st_fx, nbits );
- IF( s_and( nb_frame_flg, 0x1 ) == 0 )
+ if ( s_and( nb_frame_flg, 0x1 ) == 0 )
{
nb_subfr = 2 * SWNB_SUBFR;
move16();
@@ -213,7 +217,7 @@ void decod_audio_fx(
nbits = 3;
move16();
test();
- if ( LT_32( st_fx->core_brate, ACELP_9k60 ) && ( EQ_16( st_fx->coder_type, INACTIVE ) ) )
+ IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type == INACTIVE )
{
nbits = 1;
move16();
@@ -225,7 +229,7 @@ void decod_audio_fx(
move16();
}
test();
- IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && NE_16( st_fx->coder_type, INACTIVE ) )
+ IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type != INACTIVE )
{
pit_band_idx = 1;
move16();
@@ -235,7 +239,7 @@ void decod_audio_fx(
pit_band_idx = (Word16) get_next_indice( st_fx, nbits );
}
- IF( pit_band_idx != 0 )
+ if ( pit_band_idx != 0 )
{
IF( LT_32( st_fx->core_brate, ACELP_9k60 ) )
{
@@ -248,7 +252,7 @@ void decod_audio_fx(
}
/* detect bit errors in the bitstream */
- IF( GT_16( pit_band_idx, 13 ) ) /* The maximum decodable index is 10 + BAND1k2 (3) = 13 */
+ if ( GT_16( pit_band_idx, 13 ) ) /* The maximum decodable index is 10 + BAND1k2 (3) = 13 */
{
pit_band_idx = 13;
move16();
@@ -283,7 +287,7 @@ void decod_audio_fx(
Word16 indice;
nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )];
move16();
- IF( GT_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode > EVS_MONO )
{
nbits = 5;
move16();
@@ -307,7 +311,7 @@ void decod_audio_fx(
{
pit_band_idx = 9 + BAND1k2;
move16();
- if ( EQ_16( st_fx->bwidth, NB ) )
+ if ( st_fx->bwidth == NB )
{
pit_band_idx = 7 + BAND1k2;
move16();
@@ -341,14 +345,14 @@ void decod_audio_fx(
max_len = sub( st_fx->L_frame, Diff_len );
- if ( EQ_16( st_fx->bwidth, NB ) )
+ if ( st_fx->bwidth == NB )
{
max_len = sub( 160, Diff_len );
}
Len = 80;
move16();
- if ( max_len < 80 )
+ if ( LT_16( max_len, 80 ) )
{
Len = max_len;
move16();
@@ -359,7 +363,7 @@ void decod_audio_fx(
{
FOR( i = 0; i < max_len; i++ )
{
- dct_epit[i + Diff_len] = 0;
+ dct_epit[add( i, Diff_len )] = 0;
move16();
}
}
@@ -367,13 +371,13 @@ void decod_audio_fx(
{
FOR( i = 0; i < Len; i++ )
{
- dct_epit[i + Diff_len] = mult_r( dct_epit[i + Diff_len], sm_table_fx[i] );
+ dct_epit[add( i, Diff_len )] = mult_r( dct_epit[add( i, Diff_len )], sm_table_fx[i] );
move16();
}
FOR( ; i < max_len; i++ )
{
- dct_epit[i + Diff_len] = 0;
+ dct_epit[add( i, Diff_len )] = 0;
move16();
}
}
@@ -406,6 +410,7 @@ void decod_audio_fx(
set16_fx( gain_buf, 0, NB_SUBFR16k );
st_fx->bfi_pitch_fx = shl( L_SUBFR, 6 );
+ move16();
st_fx->bfi_pitch_frame = st_fx->L_frame;
move16();
st_fx->lp_gainp_fx = 0;
@@ -444,7 +449,8 @@ void decod_audio_fx(
test();
if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 )
#else
- if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) )
+ test();
+ if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) )
#endif
{
tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 );
@@ -477,7 +483,7 @@ void decod_audio_fx(
* Update BWE excitation
*--------------------------------------------------------------------------------------*/
- if ( st_fx->hBWE_TD != NULL )
+ IF( st_fx->hBWE_TD != NULL )
{
set16_fx( voice_factors, 0, NB_SUBFR16k );
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
@@ -561,6 +567,7 @@ void decod_audio_ivas_fx(
GSC_DEC_HANDLE hGSCDec;
hGSCDec = st_fx->hGSCDec;
+ move16(); // Es_pred
/*---------------------------------------------------------------*
* Initialization
@@ -576,15 +583,23 @@ void decod_audio_ivas_fx(
#if 0 // !defined ADD_LRTD
IF(NE_16(st_fx->coder_type, INACTIVE) && GE_32(st_fx->total_brate, ACELP_13k20))
#else
- if ( st_fx->GSC_IVAS_mode >= 1 || ( st_fx->coder_type != INACTIVE && ( ( st_fx->element_mode == EVS_MONO && st_fx->total_brate >= ACELP_13k20 ) ||
- ( st_fx->element_mode > EVS_MONO && st_fx->total_brate > MIN_BRATE_GSC_NOISY_FLAG && st_fx->bwidth >= SWB && !st_fx->flag_ACELP16k ) ) ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( st_fx->coder_type != INACTIVE && ( ( st_fx->element_mode == EVS_MONO && GE_32( st_fx->total_brate, ACELP_13k20 ) ) ||
+ ( st_fx->element_mode > EVS_MONO && GT_32( st_fx->total_brate, MIN_BRATE_GSC_NOISY_FLAG ) && GE_16( st_fx->bwidth, SWB ) && !st_fx->flag_ACELP16k ) ) ) )
#endif
{
st_fx->GSC_noisy_speech = (Word16) get_next_indice( st_fx, 1 );
+ move16();
}
/* safety check in case of bit errors */
test();
+ test();
IF( st_fx->GSC_noisy_speech && LT_16( st_fx->bwidth, SWB ) && st_fx->GSC_IVAS_mode == 0 )
{
st_fx->BER_detect = 1;
@@ -604,7 +619,7 @@ void decod_audio_ivas_fx(
#if 1 // defined ADD_LRTD
test();
test();
- IF( st_fx->GSC_IVAS_mode >= 1 || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && st_fx->GSC_IVAS_mode == 0 ) )
+ IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && st_fx->GSC_IVAS_mode == 0 ) )
#else
IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) )
#endif
@@ -616,21 +631,26 @@ void decod_audio_ivas_fx(
hGSCDec->noise_lev = NOISE_LEVEL_SP3;
move16();
#if 1 // def ADD_LRTD
- if ( st_fx->GSC_IVAS_mode >= 1 )
+ IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) )
{
- if ( st_fx->core_brate < GSC_L_RATE_STG && st_fx->GSC_IVAS_mode < 3 )
+ test();
+ if ( LT_32( st_fx->core_brate, GSC_L_RATE_STG ) && LT_32( st_fx->GSC_IVAS_mode, 3 ) )
{
nb_subfr = 2;
+ move16();
}
hGSCDec->noise_lev = NOISE_LEVEL_SP2;
+ move16();
- if ( st_fx->GSC_IVAS_mode == 3 ) /* Music like */
+ IF( EQ_16( st_fx->GSC_IVAS_mode, 3 ) ) /* Music like */
{
hGSCDec->noise_lev = NOISE_LEVEL_SP0;
+ move16();
}
- else if ( st_fx->GSC_noisy_speech == 0 ) /* speech like but not noisy */
+ ELSE IF( st_fx->GSC_noisy_speech == 0 ) /* speech like but not noisy */
{
hGSCDec->noise_lev = NOISE_LEVEL_SP3;
+ move16();
}
}
#endif
@@ -640,22 +660,28 @@ void decod_audio_ivas_fx(
IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
{
hGSCDec->noise_lev = add( (Word16) get_next_indice( st_fx, 2 ), NOISE_LEVEL_SP2 );
+ move16();
}
ELSE
{
hGSCDec->noise_lev = add( (Word16) get_next_indice( st_fx, 3 ), NOISE_LEVEL_SP0 );
+ move16();
}
/*---------------------------------------------------------------*
* Decode number of subframes
*---------------------------------------------------------------*/
#if 1 // def ADD_LRTD
- if ( st_fx->L_frame == L_FRAME16k && ( st_fx->core_brate <= ACELP_13k20 || st_fx->coder_type == INACTIVE ) )
+ test();
+ test();
+ IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && ( LE_32( st_fx->core_brate, ACELP_13k20 ) || st_fx->coder_type == INACTIVE ) )
{
hGSCDec->cor_strong_limit = 0;
+ move16();
nb_subfr = 1;
+ move16();
}
- else
+ ELSE
#endif
{
hGSCDec->cor_strong_limit = 1;
@@ -668,13 +694,16 @@ void decod_audio_ivas_fx(
nbits = 1;
move16();
#if 1 // def ADD_LRTD
- if ( st_fx->L_frame == L_FRAME16k && st_fx->core_brate >= MIN_RATE_4SBFR )
+ test();
+ if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) )
{
nbits = 2;
+ move16();
}
#endif
nb_frame_flg = (Word16) get_next_indice( st_fx, nbits );
+ test();
IF( s_and( nb_frame_flg, 0x1 ) == 0 )
{
nb_subfr = 2 * SWNB_SUBFR;
@@ -683,23 +712,26 @@ void decod_audio_ivas_fx(
move16();
}
#if 1 // def ADD_LRTD
- else if ( st_fx->L_frame == L_FRAME16k && st_fx->core_brate >= MIN_RATE_4SBFR )
+ ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) )
{
nb_subfr = 2 * SWNB_SUBFR; /* cor_strong already set to 1 */
+ move16();
}
- if ( ( nb_frame_flg >> 1 ) == 1 )
+ if ( EQ_16( shr( nb_frame_flg, 1 ), 1 ) )
{
- nb_subfr *= 2;
+ nb_subfr = shl( nb_subfr, 1 );
}
#endif
}
}
}
#if 1
- if ( st_fx->L_frame == L_FRAME16k && nb_subfr == NB_SUBFR )
+ test();
+ if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( nb_subfr, NB_SUBFR ) )
{
nb_subfr = NB_SUBFR16k;
+ move16();
}
#endif
/*---------------------------------------------------------------*
@@ -711,7 +743,7 @@ void decod_audio_ivas_fx(
nbits = 3;
move16();
test();
- if ( LT_32( st_fx->core_brate, ACELP_9k60 ) && ( EQ_16( st_fx->coder_type, INACTIVE ) ) )
+ if ( LT_32( st_fx->core_brate, ACELP_9k60 ) && ( st_fx->coder_type == INACTIVE ) )
{
nbits = 1;
move16();
@@ -723,7 +755,7 @@ void decod_audio_ivas_fx(
move16();
}
test();
- IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && NE_16( st_fx->coder_type, INACTIVE ) )
+ IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type != INACTIVE )
{
pit_band_idx = 1;
move16();
@@ -771,9 +803,16 @@ void decod_audio_ivas_fx(
*---------------------------------------------------------------*/
test();
#if 1 // def ADD_LRTD
- if ( !( st_fx->GSC_IVAS_mode > 0 && st_fx->L_frame / nb_subfr == 2 * L_SUBFR && st_fx->GSC_IVAS_mode < 3 ) &&
- ( ( st_fx->core_brate >= MIN_RATE_FCB || st_fx->GSC_noisy_speech ) &&
- ( ( nb_subfr == NB_SUBFR && st_fx->L_frame == L_FRAME ) || ( nb_subfr == NB_SUBFR16k && st_fx->L_frame == L_FRAME16k ) ) ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( !( ( st_fx->GSC_IVAS_mode > 0 ) && EQ_16( idiv1616( st_fx->L_frame, nb_subfr ), 2 * L_SUBFR ) && LT_16( st_fx->GSC_IVAS_mode, 3 ) ) &&
+ ( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || st_fx->GSC_noisy_speech ) &&
+ ( ( EQ_16( nb_subfr, NB_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && EQ_16( st_fx->L_frame, L_FRAME16k ) ) ) ) )
#else
IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) && EQ_16( nb_subfr, NB_SUBFR ) )
#endif
@@ -781,7 +820,7 @@ void decod_audio_ivas_fx(
Word16 indice;
nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )];
move16();
- IF( GT_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode > EVS_MONO )
{
nbits = 5;
move16();
@@ -805,7 +844,7 @@ void decod_audio_ivas_fx(
{
pit_band_idx = 9 + BAND1k2;
move16();
- if ( EQ_16( st_fx->bwidth, NB ) )
+ if ( st_fx->bwidth == NB )
{
pit_band_idx = 7 + BAND1k2;
move16();
@@ -839,25 +878,25 @@ void decod_audio_ivas_fx(
max_len = sub( st_fx->L_frame, Diff_len );
- if ( EQ_16( st_fx->bwidth, NB ) )
+ if ( st_fx->bwidth == NB )
{
max_len = sub( 160, Diff_len );
}
Len = 80;
move16();
- if ( max_len < 80 )
+ if ( LT_16( max_len, 80 ) )
{
Len = max_len;
move16();
}
test();
- IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && NE_16( st_fx->bwidth, NB ) )
+ IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB )
{
FOR( i = 0; i < max_len; i++ )
{
- dct_epit[i + Diff_len] = 0;
+ dct_epit[add( i, Diff_len )] = 0;
move16();
}
}
@@ -865,13 +904,13 @@ void decod_audio_ivas_fx(
{
FOR( i = 0; i < Len; i++ )
{
- dct_epit[i + Diff_len] = mult_r( dct_epit[i + Diff_len], sm_table_fx[i] );
+ dct_epit[add( i, Diff_len )] = mult_r( dct_epit[add( i, Diff_len )], sm_table_fx[i] );
move16();
}
FOR( ; i < max_len; i++ )
{
- dct_epit[i + Diff_len] = 0;
+ dct_epit[add( i, Diff_len )] = 0;
move16();
}
}
@@ -904,6 +943,7 @@ void decod_audio_ivas_fx(
set16_fx( gain_buf, 0, NB_SUBFR16k );
st_fx->bfi_pitch_fx = shl( L_SUBFR, 6 );
+ move16();
st_fx->bfi_pitch_frame = st_fx->L_frame;
move16();
st_fx->lp_gainp_fx = 0;
@@ -940,7 +980,7 @@ void decod_audio_ivas_fx(
test();
#if 1 // defined ADD_LRTD
test();
- if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 )
+ if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 )
#else
if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) )
#endif
@@ -952,7 +992,7 @@ void decod_audio_ivas_fx(
IF( EQ_16( st_fx->idchan, 1 ) )
{
tmp_nb_bits_tot = add( tmp_nb_bits_tot, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS );
- IF( EQ_16( st_fx->tdm_LRTD_flag, 1 ) )
+ if ( EQ_16( st_fx->tdm_LRTD_flag, 1 ) )
{
tmp_nb_bits_tot = sub( tmp_nb_bits_tot, STEREO_BITS_TCA );
}
@@ -976,7 +1016,7 @@ void decod_audio_ivas_fx(
* Update BWE excitation
*--------------------------------------------------------------------------------------*/
- if ( st_fx->hBWE_TD != NULL )
+ IF( st_fx->hBWE_TD != NULL )
{
set16_fx( voice_factors, 0, NB_SUBFR16k );
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
@@ -1069,6 +1109,8 @@ void gsc_dec_fx(
GSC_DEC_HANDLE hGSCDec;
hGSCDec = st_fx->hGSCDec;
+ move16(); // for Mbands_gn
+ move16(); // for Qexc_diffQ
set16_fx( inpulses_fx, 0, NB_SFM );
set16_fx( imaxpulse_fx, 0, NB_SFM );
@@ -1112,6 +1154,7 @@ void gsc_dec_fx(
}
st_fx->lp_gainc_fx = mult_r( st_fx->lp_gainc_fx, 32112 ); /*Q3*/
+ move16();
}
ELSE
{
@@ -1143,12 +1186,13 @@ void gsc_dec_fx(
mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth );
#endif
st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */
+ move16();
}
*last_bin = 0;
move16();
test();
- IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && NE_16( st_fx->bwidth, NB ) )
+ IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB )
{
bitallocation_exc[0] = 0;
move16();
@@ -1178,6 +1222,7 @@ void gsc_dec_fx(
L_tmp = L_shr( L_mult( Random( &hGSCDec->seed_tcx ), 26214 ), 5 ); /*Q10*/
L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 );
hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp ); /*Q10*/
+ move16();
}
}
@@ -1246,7 +1291,7 @@ void gsc_dec_fx(
{
seed_init = extract_l( L_shl( seed_init, 3 ) );
}
- IF( concat_out[j] < 0 )
+ if ( concat_out[j] < 0 )
{
seed_init = add( seed_init, 3 );
move16();
@@ -1257,7 +1302,7 @@ void gsc_dec_fx(
move16();
}
test();
- IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && NE_16( st_fx->bwidth, NB ) )
+ IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB )
{
if ( exc_diffQ[L_FRAME8k - 2] != 0 )
{
@@ -1390,6 +1435,8 @@ void gsc_dec_ivas_fx(
GSC_DEC_HANDLE hGSCDec;
hGSCDec = st_fx->hGSCDec;
+ move16(); // for Mbands_gn
+ move16(); // for Qexc_diffQ
set16_fx( inpulses_fx, 0, NB_SFM );
set16_fx( imaxpulse_fx, 0, NB_SFM );
@@ -1402,13 +1449,12 @@ void gsc_dec_ivas_fx(
test();
test();
test();
- test();
- IF( EQ_16( coder_type, INACTIVE ) && ( EQ_16( st_fx->tdm_LRTD_flag, 1 ) || EQ_16( st_fx->element_mode, IVAS_SCE ) ) && LE_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) )
+ if ( coder_type == INACTIVE && ( EQ_16( st_fx->tdm_LRTD_flag, 1 ) || EQ_16( st_fx->element_mode, IVAS_SCE ) ) && LE_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) )
{
bit = add( bit, GSC_LRES_NB_NITS );
}
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
+ if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
Mbands_gn = MBANDS_GN16k;
move16();
@@ -1433,6 +1479,7 @@ void gsc_dec_ivas_fx(
}
st_fx->lp_gainc_fx = mult_r( st_fx->lp_gainc_fx, 32112 ); /*Q3*/
+ move16();
}
ELSE
{
@@ -1452,11 +1499,10 @@ void gsc_dec_ivas_fx(
test();
test();
test();
- test();
- IF( GT_16( st_fx->element_mode, EVS_MONO ) && EQ_16( coder_type, AUDIO ) &&
+ IF( st_fx->element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) &&
LE_32( st_fx->core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation is mapped to 8 kb/s instead of 9.6 kb/s in this case */
{
- i--;
+ i = sub( i, 1 );
}
mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth );
@@ -1464,12 +1510,13 @@ void gsc_dec_ivas_fx(
mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth );
#endif
st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */
+ move16();
}
*last_bin = 0;
move16();
test();
- IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && NE_16( st_fx->bwidth, NB ) )
+ IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB )
{
bitallocation_exc[0] = 0;
move16();
@@ -1499,6 +1546,7 @@ void gsc_dec_ivas_fx(
L_tmp = L_shr( L_mult( Random( &hGSCDec->seed_tcx ), 26214 ), 5 ); /*Q10*/
L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 );
hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp ); /*Q10*/
+ move16();
}
}
@@ -1536,20 +1584,27 @@ void gsc_dec_ivas_fx(
#if 1 // def ADD_LRTD
max_eq = 0;
+ move16();
max_eq_val = 32767;
+ move16();
- IF( ( ( st_fx->core_brate < ACELP_7k20 && st_fx->GSC_noisy_speech == 1 ) || st_fx->core_brate < 6000 ) && coder_type <= UNVOICED )
+ test();
+ test();
+ test();
+ IF( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( coder_type, UNVOICED ) )
{
- j = maximum_fx( concat_out, nb_subbands * 16, &max_eq );
+ j = maximum_fx( concat_out, imult1616( nb_subbands, 16 ), &max_eq );
// max_eq = max_eq_val / (abs_s(concat_out[j]) + 328 /*0.01f*/ );
- Word16 temp_max_eq = abs_s( concat_out[j] ) + 10 /*0.01f in Q10*/;
+ Word16 temp_max_eq = add( abs_s( concat_out[j] ), 10 ) /*0.01f in Q10*/;
IF( LE_16( temp_max_eq, ONE_IN_Q10 ) )
{
max_eq = max_eq_val;
+ move16();
}
ELSE
{
Word16 exp = 5;
+ move16();
max_eq = Inv16( temp_max_eq, &exp );
max_eq = shl( max_eq, exp );
}
@@ -1578,14 +1633,13 @@ void gsc_dec_ivas_fx(
{
seed_init = extract_l( L_shl( seed_init, 3 ) );
}
- IF( concat_out[j] < 0 )
+ if ( concat_out[j] < 0 )
{
#ifdef BASOP_NOGLOB_TMP_715
seed_init = add_sat( seed_init, 3 );
#else
seed_init = add( seed_init, 3 );
#endif
- move16();
}
}
@@ -1593,15 +1647,15 @@ void gsc_dec_ivas_fx(
move16();
}
test();
- IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && NE_16( st_fx->bwidth, NB ) )
+ IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB )
{
- IF( exc_diffQ[L_FRAME8k - 2] != 0 )
+ if ( exc_diffQ[L_FRAME8k - 2] != 0 )
{
bitallocation_exc[0] = 1;
move16();
}
- IF( exc_diffQ[L_FRAME8k - 1] != 0 )
+ if ( exc_diffQ[L_FRAME8k - 1] != 0 )
{
bitallocation_exc[1] = 1;
move16();
@@ -1620,8 +1674,6 @@ void gsc_dec_ivas_fx(
test();
test();
test();
- test();
- test();
IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) )
{
FOR( i = 64; i < st_fx->L_frame; i++ )
@@ -1629,6 +1681,7 @@ void gsc_dec_ivas_fx(
// PMT("GSC FIX point to be done here")
// exc_diffQ[i] *= max_eq;
exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq );
+ move16();
}
}
ELSE IF( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( st_fx->coder_type, UNVOICED ) )
@@ -1638,6 +1691,7 @@ void gsc_dec_ivas_fx(
// PMT("GSC FIX point to be done here")
// exc_diffQ[i] *= max_eq;
exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq );
+ move16();
}
}
ELSE
diff --git a/lib_dec/hdecnrm_fx.c b/lib_dec/hdecnrm_fx.c
index 40946cb204c511a084ff92ef87278d511a35eb3e..c97344274270556c5beb67c7efebbb026810afba 100644
--- a/lib_dec/hdecnrm_fx.c
+++ b/lib_dec/hdecnrm_fx.c
@@ -3,8 +3,7 @@
====================================================================================*/
#include
#include "options.h" /* Compilation switches */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_dec.h"
/*--------------------------------------------------------------------------*/
@@ -55,7 +54,7 @@ void hdecnrm_fx(
move16();
if ( get_next_indice_1( st_fx ) != 0 )
{
- j = (Word16) 1;
+ j = 1;
move16();
}
temp = add( 8, n );
@@ -110,6 +109,7 @@ Word16 decode_huff_context_fx(
tmp_h = shr( hufftab[hufftab_idx], 4 );
tmp_l = sub( hufftab[hufftab_idx], shl( tmp_h, 4 ) );
*rbits = add( *rbits, tmp_l );
+ move16();
hufftab_idx = L_add( hufftab_idx, L_add( L_deposit_l( tmp_h ), get_next_indice( st_fx, tmp_l ) ) );
}
return negate( hufftab[hufftab_idx] );
@@ -218,7 +218,6 @@ void hdecnrm_resize_fx(
ELSE{
IF( get_next_indice_1( st_fx ) != 0 ){
temp = add( 16, k );
- move16();
}
ELSE
{
@@ -282,6 +281,7 @@ void huff_dec_fx(
/* Put back unused bits */
st_fx->next_bit_pos = sub( st_fx->next_bit_pos, j );
+ move16();
return;
}
@@ -304,7 +304,6 @@ void hdecnrm_tran_fx(
Word16 l;
pidx = index;
- move16();
m = sub( N, 1 );
FOR( i = 0; i < m; i++ )
diff --git a/lib_dec/hf_synth.c b/lib_dec/hf_synth.c
index 38aaab11ffe715db0edd2c8805e101619e797728..b2589a9bc600874872e006f9bb64e9a4cc5fe309 100644
--- a/lib_dec/hf_synth.c
+++ b/lib_dec/hf_synth.c
@@ -42,8 +42,7 @@
#include "rom_com.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
-#include "prot_fx1.h"
+#include "prot_fx.h"
#include "basop32.h"
#endif
diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c
index c63636e23e503ea23e4e742bec22182941f7dca4..cee42b0ca04ff1a1117570370a21b384a6eefc1d 100644
--- a/lib_dec/hf_synth_fx.c
+++ b/lib_dec/hf_synth_fx.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
#include "basop32.h"
#include "prot.h"
@@ -48,6 +47,7 @@ void hf_synth_init_fx(
)
{
hBWE_zero->seed2 = RANDOM_INITSEED;
+ move16();
set16_fx( hBWE_zero->mem_hf_fx, 0, ( L_FIR - 1 ) );
set16_fx( hBWE_zero->mem_syn_hf_fx, 0, M );
set16_fx( hBWE_zero->mem_hp400_fx, 0, 4 );
@@ -113,14 +113,12 @@ void hf_synth_fx(
move16();
p_Aq = Aq;
- move16();
FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR )
{
- hf_synthesis_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[i_subfr * output_subfr / L_SUBFR],
+ hf_synthesis_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[imult3216( (Word32) i_subfr, output_subfr ) / L_SUBFR],
Q_syn2, delay_syn_hf, memExp1, mem_hp_interp, extl, CNG_mode );
p_Aq += ( M + 1 );
- move16();
}
return;
@@ -241,7 +239,6 @@ static void hf_synthesis_fx(
scale = round_fx( L_tmp ); /* Q18 when Q_exc=-1, HF_exc in Q-3 */
exp2 = sub( *memExp1, exp1 );
- move16();
*memExp1 = exp1;
move16();
@@ -303,7 +300,7 @@ static void hf_synthesis_fx(
tmp = add( 1, sub( 32767, tmp ) );
#endif
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 ) )
{
/* emphasize HF noise in CNG */
/*fac *= 2.0f;*/
@@ -349,8 +346,8 @@ static void hf_synthesis_fx(
/* delay by 5 samples @16kHz to compensate CLDFB resampling delay (20samples) and HP filtering delay (roughly 15 samples) */
delay = NS2SA( 16000, DELAY_CLDFB_NS ) - 15;
- Copy( HF_syn + L_SUBFR16k - delay, temp_buffer, delay );
- Copy( HF_syn, HF_syn + delay, L_SUBFR16k - delay );
+ Copy( HF_syn + sub( L_SUBFR16k, delay ), temp_buffer, delay );
+ Copy( HF_syn, HF_syn + delay, sub( L_SUBFR16k, delay ) );
Copy( delay_syn_hf, HF_syn, delay );
Copy( temp_buffer, delay_syn_hf, delay );
@@ -643,6 +640,7 @@ static void filt_6k_7k_scale_fx(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
Copy_Scale_sig( mem, x, L_FIR - 1, exp );
@@ -657,7 +655,7 @@ static void filt_6k_7k_scale_fx(
Word16 j;
L_tmp = 0;
move32();
- for ( j = 0; j < 31; j++ )
+ FOR( j = 0; j < 31; j++ )
{
#ifdef BASOP_NOGLOB
L_tmp = L_mac_o( L_tmp, x[i + j], fir_6k_7k_fx[j], &Overflow );
@@ -668,6 +666,7 @@ static void filt_6k_7k_scale_fx(
#ifdef BASOP_NOGLOB
signal[i] = round_fx_o( L_tmp, &Overflow );
+ move16();
#else
signal[i] = round_fx( L_tmp );
#endif
@@ -844,6 +843,7 @@ void hf_synth_amr_wb_fx(
tmp1 = div_s( shl( 1, sub( 14, exp ) ), tmp1 ); /*Q(29-exp-2*(Q_syn-3)-1) */
L_tmp = L_mult( tmp2, tmp1 ); /*30-exp-2*(Q_syn-3)-1+2*(Q_syn-3)+1 - >30-exp */
*pt3 = round_fx( L_shl( L_tmp, sub( exp, 1 ) ) ); /*13 */
+ move16();
*pt4++ = *pt3++;
move16();
@@ -879,10 +879,12 @@ void hf_synth_amr_wb_fx(
}
ELSE
{
- move16();
hAmrwb_IO->frame_count_fx = s_min( hAmrwb_IO->frame_count_fx, 2 * FRAME_COUNT_HF_SYNTH - 1 );
+ move16();
hAmrwb_IO->frame_count_fx = add( hAmrwb_IO->frame_count_fx, 1 );
+ move16();
hAmrwb_IO->ne_min_fx = s_min( hAmrwb_IO->ne_min_fx, ng_ener_ST );
+ move16();
}
pt6 = voice_factors;
@@ -912,6 +914,7 @@ void hf_synth_amr_wb_fx(
fmerit_w = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */
/**fmerit_w_sm = add(mult_r(*fmerit_w_sm, 29491), mult_r(fmerit_w, 3277)); //Q14 */
hAmrwb_IO->fmerit_w_sm_fx = round_fx( L_mac( L_mult( hAmrwb_IO->fmerit_w_sm_fx, 29491 ), fmerit_w, 3277 ) ); /*Q14 */
+ move16();
fmerit_w = hAmrwb_IO->fmerit_w_sm_fx;
move16();
@@ -925,6 +928,7 @@ void hf_synth_amr_wb_fx(
}
fmerit_m = negate( add( -32768, tmp1 ) );
hAmrwb_IO->fmerit_m_sm_fx = add( shr( hAmrwb_IO->fmerit_m_sm_fx, 1 ), shr( fmerit_m, 1 ) ); /*Q14 */
+ move16();
fmerit_m = hAmrwb_IO->fmerit_m_sm_fx;
move16();
@@ -949,6 +953,7 @@ void hf_synth_amr_wb_fx(
L_tmp = L_mult0( *pt1, fmerit_m ); /*Q13+14 */
*pt1++ = extract_l( L_shr( L_tmp, 14 ) ); /*Q13 */
+ move16();
}
/* predict LPC coefficents and calculate sub-frame gains */
p_Aq = Aq;
@@ -1032,6 +1037,7 @@ void hf_synth_amr_wb_fx(
IF( LT_16( beta, 16384 ) )
{
L_tmp = 1; /*variable for tonal energy*/
+ move32();
pt1 = hb_amb;
pt2 = hb_tonal;
@@ -1052,6 +1058,7 @@ void hf_synth_amr_wb_fx(
#endif
}
*pt1 = round_fx( L_shl( L_mult( tmp, tmp1 ), 2 ) ); /*qdct */
+ move16();
*pt2 = sub( *pt3, *pt1 );
move16();
IF( *pt2 > 0 )
@@ -1067,6 +1074,7 @@ void hf_synth_amr_wb_fx(
fb = sub( i, 7 );
fn = add( fb, 15 );
tmp = 0;
+ move16();
pt4 = &dct_hb[fb + 240];
FOR( j = fb; j < fn; j++ )
{
@@ -1109,6 +1117,7 @@ void hf_synth_amr_wb_fx(
#endif
}
*pt1 = round_fx( L_shl( L_mult( tmp, tmp1 ), 2 ) ); /*qdct */
+ move16();
*pt2 = sub( *pt3, *pt1 );
move16();
IF( *pt2 > 0 )
@@ -1140,20 +1149,22 @@ void hf_synth_amr_wb_fx(
pt4 = signum;
FOR( i = 0; i < L_SUBFR16k; i++ )
{
- if ( *pt1 > 0 )
+ IF( *pt1 > 0 )
{
*pt1 = mult_r( *pt1, g ); /*qdct */
move16();
}
#ifdef BASOP_NOGLOB
*pt2 = round_fx_sat( L_shl_sat( L_mult( *pt2, inv_g ), 3 ) ); /*qdct */
+ move16();
*pt3 = add_sat( *pt1, *pt2 );
+ move16();
#else
*pt2 = round_fx( L_shl( L_mult( *pt2, inv_g ), 3 ) ); /*qdct */
*pt3 = add( *pt1, *pt2 );
#endif
- move16();
*pt3 = extract_l( L_mult0( *pt3, *pt4 ) ); /*qdct */
+ move16();
pt1++;
pt2++;
pt3++;
@@ -1221,6 +1232,7 @@ void hf_synth_amr_wb_fx(
IF( GE_16( i, sub( L_FRAME16k, filt_weight_coeff ) ) )
{
*pt1 = round_fx( L_shl( L_mult( *pt3, *pt1 ), 1 ) ); /*qdct */
+ move16();
}
pt1++;
pt3++;
@@ -1260,6 +1272,7 @@ void hf_synth_amr_wb_fx(
IF( GE_16( i, sub( L_FRAME16k, filt_weight_coeff ) ) )
{
*pt1 = round_fx( L_shl( L_mult( *pt3, *pt1 ), 1 ) ); /*qdct */
+ move16();
}
pt1++;
pt3++;
@@ -1334,6 +1347,7 @@ void hf_synth_amr_wb_fx(
{
#ifdef BASOP_NOGLOB
*pt2 = round_fx_sat( L_shl_sat( L_mult( *pt2, scale ), 2 ) ); /*qhf-1 */
+ move16();
#else
*pt2 = round_fx( L_shl( L_mult( *pt2, scale ), 2 ) ); /*qhf-1 */
#endif
@@ -1418,6 +1432,7 @@ static void hf_synthesis_amr_wb_fx(
L_tmp = L_mult( *pt1++, HF_corr_gain ); /*qhf+15*/
L_tmp = Mult_32_16( L_tmp, scale ); /*qhf-1+12+1*/
*pt2++ = round_fx( L_shl( L_tmp, 1 ) ); /*qhf-3*/
+ move16();
}
pt1 = exc16k;
@@ -1468,6 +1483,7 @@ static void hf_synthesis_amr_wb_fx(
tmp = s_min( tmp, 4096 );
tmp = s_max( tmp, scale );
*pt1++ = round_fx( L_shl( L_mult( *pt2++, tmp ), 3 ) ) /*qhf*/;
+ move16();
}
}
}
@@ -1555,6 +1571,7 @@ static Word16 EnhanceClass_fx(
/* Decide (*unvoicing_flag) to allow BWE enhancement when qq>pp */
/**voice_fac_fx = add(mult_r(*voice_fac_fx, 24576), mult_r(voice_factor_fx, 8192)); //Q15 */
*voice_fac_fx = round_fx( L_mac( L_mult( *voice_fac_fx, 24576 ), voice_factor_fx, 8192 ) ); /*Q15 */
+ move16();
tmp = mult_r( sub( 8192, tilt0_fx ), 16384 ); /*Q13 */
@@ -1571,16 +1588,19 @@ static Word16 EnhanceClass_fx(
/**unvoicing_fx = add(mult_r(16384, *unvoicing_fx), mult_r(16384, unvoicing_tmp_fx)); //Q15 */
*unvoicing_fx = round_fx( L_mac( L_mult( 16384, *unvoicing_fx ), 16384, unvoicing_tmp_fx ) ); /*Q15 */
+ move16();
IF( GT_16( *unvoicing_sm_fx, *unvoicing_fx ) )
{
/**unvoicing_sm_fx = add(mult_r(29491, *unvoicing_sm_fx), mult_r(3277, *unvoicing_fx)); //Q15 */
*unvoicing_sm_fx = round_fx( L_mac( L_mult( 29491, *unvoicing_sm_fx ), 3277, *unvoicing_fx ) ); /*Q15 */
+ move16();
}
ELSE
{
/**unvoicing_sm_fx = add(mult_r(32440, *unvoicing_sm_fx), mult_r(328, *unvoicing_fx)); //Q15 */
*unvoicing_sm_fx = round_fx( L_mac( L_mult( 32440, *unvoicing_sm_fx ), 328, *unvoicing_fx ) ); /*Q15 */
+ move16();
}
#ifdef BASOP_NOGLOB
@@ -1590,6 +1610,7 @@ static Word16 EnhanceClass_fx(
#endif
{
*unvoicing_flag = 1;
+ move16();
}
#ifdef BASOP_NOGLOB
@@ -1599,6 +1620,7 @@ static Word16 EnhanceClass_fx(
#endif
{
*unvoicing_flag = 0;
+ move16();
}
test();
return ( *unvoicing_flag && GT_16( qq_fx, pp_fx ) );
@@ -1651,7 +1673,8 @@ static void envelope_fx(
}
/* LPC envelope level estimate */
- L_tmp = L_deposit_l( 0 );
+ L_tmp = 0;
+ move32();
pt1 = Ap;
pt2 = exp_tab_p_fx;
FOR( i = 0; i <= M; i++ )
@@ -1766,7 +1789,6 @@ static void envelope_fx(
if ( k1 < 0 )
{
tmp = negate( tmp );
- move16();
}
L_tmp = L_mult( As[1], tmp ); /*Q(42-q1) */
@@ -1803,6 +1825,7 @@ static void envelope_fx(
move16();
L_tmp = L_mult( As[1], k1 ); /*Q25 */
As[1] = round_fx( L_shl( L_tmp, 3 ) ); /*Q12 */
+ move16();
As[2] = k2;
move16(); /*Q12 */
@@ -1926,6 +1949,7 @@ static void envelope_fx(
#ifdef BASOP_NOGLOB
*sub_gain = s_min( 20480, round_fx_sat( L_shl_sat( L_tmp, sub( q1, 2 ) ) ) ); /*Q12 */
+ move16();
#else
*sub_gain = s_min( 20480, round_fx( L_shl( L_tmp, sub( q1, 2 ) ) ) ); /*Q12 */
#endif
@@ -1958,8 +1982,10 @@ void AdaptiveStartBand_fx(
Word16 *pt1, flag;
const Word16 *pt2, *pt3;
+ move32(); // corresponding to initialization of OptCrit_fx
/*voicing switching flag : to avoid switching start band frequently in VOICED or AUDIO area*/
voicing_flag_old = *voicing_flag;
+ move16();
test();
test();
test();
@@ -2045,6 +2071,7 @@ void AdaptiveStartBand_fx(
tmp1 = add( mult_r( lsf_fx[pos - 1], 256 ), mult_r( lsf_fx[pos], 256 ) );
*start_band = s_min( s_max( sub( tmp1, 40 ), 40 ), 160 );
+ move16();
L_tmp = Mult_32_16( *OptCrit_old_fx, 22938 ); /* Q11+2.56+2.56 */
test();
@@ -2052,7 +2079,7 @@ void AdaptiveStartBand_fx(
test();
test();
IF( NE_16( voicing_flag_old, *voicing_flag ) || ( *voicing_flag == 0 && LT_32( OptCrit_fx, *OptCrit_old_fx ) ) ||
- ( LT_32( OptCrit_fx, L_tmp ) && GT_32( *OptCrit_old_fx, 858993 ) > 0 ) )
+ ( LT_32( OptCrit_fx, L_tmp ) && GT_32( *OptCrit_old_fx, 858993 ) ) )
{
*OptCrit_old_fx = OptCrit_fx;
move16();
diff --git a/lib_dec/hq_classifier_dec_fx.c b/lib_dec/hq_classifier_dec_fx.c
index d8ce93970598817f53da5f5742cbaf7203cb1c8e..430c27cd7dc910d1df6a68f49790721ec19d37d3 100644
--- a/lib_dec/hq_classifier_dec_fx.c
+++ b/lib_dec/hq_classifier_dec_fx.c
@@ -2,9 +2,8 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
@@ -29,7 +28,7 @@ Word16 ivas_hq_classifier_dec_fx( /* o : Consumed bits
max_brate = HQ_32k;
move32();
- IF( GT_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode > EVS_MONO )
{
max_brate = HQ_48k;
move32();
@@ -39,7 +38,8 @@ Word16 ivas_hq_classifier_dec_fx( /* o : Consumed bits
test();
IF( ( EQ_16( length, L_SPEC32k ) || EQ_16( length, L_SPEC48k ) ) && LE_32( core_brate, max_brate ) )
{
- *hqswb_clas = get_next_indice( st_fx, 2 );
+ *hqswb_clas = (Word16) get_next_indice( st_fx, 2 );
+ move16();
bits = 2;
move16();
}
@@ -53,22 +53,22 @@ Word16 ivas_hq_classifier_dec_fx( /* o : Consumed bits
ELSE
{
*hqswb_clas = get_next_indice( st_fx, 1 );
+ move16();
bits = 1;
move16();
}
*is_transient = 0;
move16();
- IF( EQ_16( *hqswb_clas, HQ_TRANSIENT ) )
+ if ( EQ_16( *hqswb_clas, HQ_TRANSIENT ) )
{
*is_transient = 1;
move16();
}
test();
- IF( LE_32( st_fx->core_brate, HQ_32k ) && EQ_16( *hqswb_clas, HQ_NORMAL ) )
+ IF( LE_32( st_fx->core_brate, HQ_32k ) && *hqswb_clas == HQ_NORMAL )
{
- move16();
IF( EQ_16( length, L_SPEC32k ) )
{
*hqswb_clas = HQ_GEN_SWB;
@@ -99,12 +99,16 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits
max_brate = HQ_32k;
move32();
- if ( GT_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st_fx->element_mode > EVS_MONO )
{
max_brate = HQ_48k;
move32();
}
#ifndef SOLVED_COMP_ENC_DEC
+ test();
+ test();
+ test();
+ test();
IF( ( EQ_16( length, L_SPEC32k ) || EQ_16( length, L_FRAME48k ) ) && LE_32( core_brate, max_brate ) )
#else
/*_DIFF_FLOAT_FIX_ -> could this modification break the interoperability with EVS ?? */
@@ -113,6 +117,7 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits
#endif
{
*hqswb_clas = get_next_indice( st_fx, 2 );
+ move16();
bits = 2;
move16();
}
@@ -126,6 +131,7 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits
ELSE
{
*hqswb_clas = get_next_indice( st_fx, 1 );
+ move16();
bits = 1;
move16();
}
@@ -139,9 +145,8 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits
}
test();
- IF( LE_32( st_fx->core_brate, HQ_32k ) && EQ_16( *hqswb_clas, HQ_NORMAL ) )
+ IF( LE_32( st_fx->core_brate, HQ_32k ) && *hqswb_clas == HQ_NORMAL )
{
- move16();
IF( EQ_16( length, L_SPEC32k ) )
{
*hqswb_clas = HQ_GEN_SWB;
diff --git a/lib_dec/hq_conf_fec_fx.c b/lib_dec/hq_conf_fec_fx.c
index dacd23a76b6e7260b16ad05d0f6e5db86d485ee2..dfc19c542dae9ad137e032b0afd4ae1a6cd7ed1f 100644
--- a/lib_dec/hq_conf_fec_fx.c
+++ b/lib_dec/hq_conf_fec_fx.c
@@ -5,8 +5,7 @@
#include
#include "options.h"
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "cnst.h"
diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c
index e13071294bda57345961f48c0d020ea271fea082..d629365f3231c8eb79900ca3bff2c6f4563fadd5 100644
--- a/lib_dec/hq_core_dec_fx.c
+++ b/lib_dec/hq_core_dec_fx.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
#ifdef IVAS_FLOAT_FIXED
#include "prot.h"
#include "ivas_prot_fx.h"
@@ -131,7 +130,7 @@ void hq_core_dec_fx(
{
hHQ_core->HqVoicing = 0;
move16();
- IF( GT_32( st_fx->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) )
+ if ( GT_32( st_fx->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) )
{
hHQ_core->HqVoicing = 1;
move16();
@@ -146,6 +145,7 @@ void hq_core_dec_fx(
/* set inner frame (== coded bandwidth) length */
inner_frame = inner_frame_tbl[st_fx->bwidth];
+ move16();
#ifndef ADD_IVAS_HQ_CODE_L_SPEC
L_spec = inner_frame;
#endif
@@ -252,6 +252,7 @@ void hq_core_dec_fx(
{
tmp = mult_r( output_frame, 410 / 2 ); /* 1/8000 in Q15 */
ener_match = hq_nominal_scaling_inv[tmp];
+ move16();
FOR( i = 0; i < inner_frame; i++ )
{
/*t_audio_q[i] *= ener_match;*/
@@ -500,6 +501,7 @@ void hq_core_dec_fx(
st_fx->plcInfo.recovery_gain = shl_sat( st_fx->plcInfo.recovery_gain, *Q_synth );
#else
st_fx->plcInfo.recovery_gain = shl( st_fx->plcInfo.recovery_gain, *Q_synth );
+ move16();
#endif
waveform_adj2_fix( st_fx->tonalMDCTconceal.secondLastPcmOut,
synth,
@@ -555,6 +557,7 @@ void hq_core_dec_fx(
Word16 nbsubfr;
/*nbsubfr = extract_l(L_mult0(st_fx->L_frame,FL2WORD16(1/L_SUBFR)));*/
nbsubfr = 4;
+ move16();
if ( EQ_16( st_fx->L_frame, 320 ) )
{
nbsubfr = 5;
@@ -660,6 +663,8 @@ void ivas_hq_core_dec_fx(
}
st_fx->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW;
move16();
+ test();
+ test();
hq_recovery_flag = ( EQ_16( st_fx->last_core, ACELP_CORE ) ) && st_fx->prev_bfi && ( GT_16( st_fx->element_mode, EVS_MONO ) ); /* ACELP -> HQtrans -> HQ; with HQtrans lost */
/*--------------------------------------------------------------------------
* Find the number of bits for transform-domain coding
@@ -865,7 +870,7 @@ void ivas_hq_core_dec_fx(
}
ELSE
{
- ener_match = div_s( st_fx->bws_cnt1, N_NS2W_FRAMES ); /*Q15*/
+ ener_match = imult1616( st_fx->bws_cnt1, ONE_BY_N_NS2W_FRAMES_Q15 ); /*Q15*/
}
IF( is_transient )
diff --git a/lib_dec/hq_env_dec_fx.c b/lib_dec/hq_env_dec_fx.c
index 14037b5f6fd20fe6917f2deedccc6835abf928c1..df1635e37bf97fce7b9352dd7ed6ee0bdf4c7f3e 100644
--- a/lib_dec/hq_env_dec_fx.c
+++ b/lib_dec/hq_env_dec_fx.c
@@ -3,10 +3,9 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
#ifdef IVAS_FLOAT_FIXED
/*------------------------------------------------------------------------*
@@ -67,7 +66,7 @@ Word16 decode_envelope_indices_fx( /* o : Number of b
{
hcode_l = 0;
move16();
- IF( EQ_16( LCmode, 0 ) )
+ IF( LCmode == 0 )
{
hdecnrm_context_fx( st_fx, num_sfm, &difidx[start_norm], &hcode_l );
}
@@ -93,17 +92,19 @@ Word16 decode_envelope_indices_fx( /* o : Number of b
{
pDifidx = pDifidx1++;
move16();
- IF( *pDifidx > 17 )
+ IF( GT_16( *pDifidx, 17 ) )
{
offset = sub( *pDifidx, 17 );
offset = s_min( offset, 3 );
*pDifidx1 = sub( *pDifidx1, offset );
+ move16();
}
- ELSE IF( *pDifidx < 13 )
+ ELSE IF( LT_16( *pDifidx, 13 ) )
{
offset = sub( *pDifidx, 13 );
offset = s_max( offset, -3 );
*pDifidx1 = sub( *pDifidx1, offset );
+ move16();
}
}
}
diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c
index d42acd11bde6ea877da0fbd31892f66f2eadb654..4814b86e528eacc20ffe2d52de337f38e7fc6bdb 100644
--- a/lib_dec/hq_hr_dec_fx.c
+++ b/lib_dec/hq_hr_dec_fx.c
@@ -2,10 +2,9 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
diff --git a/lib_dec/hq_lr_dec_fx.c b/lib_dec/hq_lr_dec_fx.c
index 8a014d817dd03a9f3349223628b743bddbf1ae3e..a954f98aa5fe94342c3bc7857ed0d782926bb006 100644
--- a/lib_dec/hq_lr_dec_fx.c
+++ b/lib_dec/hq_lr_dec_fx.c
@@ -7,8 +7,7 @@
#include "options.h"
#include "cnst.h"
#include "rom_dec.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
/*--------------------------------------------------------------------------*
@@ -240,7 +239,7 @@ void hq_lr_dec_fx(
{
num_bits = sub( num_bits, get_usebit_npswb_fx( hqswb_clas_fx ) );
}
- IF( EQ_16( hqswb_clas_fx, HQ_NORMAL ) )
+ if ( EQ_16( hqswb_clas_fx, HQ_NORMAL ) )
{
flag_spt_fx = 1;
move16();
@@ -333,6 +332,7 @@ void hq_lr_dec_fx(
}
Q_band_energy = SWB_BWE_LR_Qbe;
+ move16();
FOR( i = 0; i < bands_fx; i++ )
{
L_tmp = L_shl( L_band_energy[i], sub( 16, Q_band_energy ) ); /*Q16 */
@@ -342,6 +342,7 @@ void hq_lr_dec_fx(
exp = sub( exp, 30 );
#ifdef BASOP_NOGLOB
Ep_fx[i] = L_shl_sat( L_tmp, s_max( sub( exp, 6 ), -31 ) ); /* Q -6 */
+ move32();
#else
Ep_fx[i] = L_shl( L_tmp, s_max( sub( exp, 6 ), -31 ) ); /* Q -6 */
#endif
@@ -389,6 +390,7 @@ void hq_lr_dec_fx(
FOR( i = 0; i < 2; i++ )
{
last_bitalloc_max_band[i] = get_next_indice( st_fx, 1 );
+ move16();
}
lowband = 6;
move16();
@@ -435,7 +437,7 @@ void hq_lr_dec_fx(
#else
Ep_avrgL_fx = L_add( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */
#endif
- IF( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) )
+ if ( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) )
{
Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q15 */
}
@@ -564,7 +566,7 @@ void hq_lr_dec_fx(
ELSE
{
Ep_avrgL_fx = L_add( Ep_avrgL_fx, L_shr( Ep_tmp_fx[i], 1 ) ); /*Q12 */
- IF( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) )
+ if ( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) )
{
Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q13 */
}
@@ -798,7 +800,7 @@ void hq_lr_dec_fx(
#else
Ep_avrgL_fx = L_add( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */
#endif
- IF( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) )
+ if ( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) )
{
Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q15 */
}
@@ -1043,10 +1045,11 @@ static Word16 decode_huff_8s_fx(
{
Word16 bit;
- WHILE( GT_16( *hufftab, 0 ) )
+ WHILE( *hufftab > 0 )
{
*rbits = add( *rbits, s_and( *hufftab, 0xf ) );
bit = get_next_indice( st_fx, s_and( *hufftab, 0xf ) );
+ move16();
hufftab += add( shr( *hufftab, 4 ), bit );
}
@@ -1069,13 +1072,13 @@ static Word16 large_symbol_dec_fx( /* o : bits
move16();
ns2mode = get_next_indice( st_fx, BITS_DE_8SMODE );
- IF( EQ_16( ns2mode, 0 ) )
+ IF( ns2mode == 0 )
{
ns2mode0 = get_next_indice( st_fx, BITS_DE_8SMODE_N0 );
ns2mode1 = get_next_indice( st_fx, BITS_DE_8SMODE_N1 );
cntbits = add( cntbits, BITS_DE_8SMODE_N0 + BITS_DE_8SMODE_N1 );
- IF( EQ_16( ns2mode0, 0 ) )
+ IF( ns2mode0 == 0 )
{
IF( EQ_16( ns2mode1, 1 ) )
{
@@ -1160,6 +1163,7 @@ static Word16 large_symbol_dec_fx( /* o : bits
bits = 0;
move16();
qbidx[i] = sub( decode_huff_8s_fx( st_fx, hestable, &bits ), 4 );
+ move16();
qbidx[i] = shl( qbidx[i], basic_shift );
move16();
cntbits = add( cntbits, bits );
@@ -1210,7 +1214,7 @@ static Word16 band_energy_dequant_fx(
/* parsing energy difference coding mode */
deng_cmode = get_next_indice( st_fx, BITS_DE_CMODE );
- IF( EQ_16( deng_cmode, 0 ) )
+ IF( deng_cmode == 0 )
{
deng_bits = large_symbol_dec_fx( st_fx, bq2_fx, bands_fx );
@@ -1369,6 +1373,7 @@ static void mdct_spectrum_fine_gain_dec_fx(
IF( L_y2[i] >= 0x0 )
{
L_y2[i] = L_shl( Mpy_32_16_1( L_y2[i], gamma_fx ), 1 );
+ move32();
}
ELSE
{
diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c
index c6d72f5d8370a2dbc070f5f9186e347e148c4163..451b7e29b4efbef64de34d96fa653d7b4af8dc7e 100644
--- a/lib_dec/igf_dec.c
+++ b/lib_dec/igf_dec.c
@@ -44,7 +44,7 @@
#include "ivas_prot.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif
diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c
index d2c4670b37a20b2c9577d6208f3b41b115982f73..c2acb5be50c1ba5aff843b9c2404cd32e3e0f08e 100644
--- a/lib_dec/igf_dec_fx.c
+++ b/lib_dec/igf_dec_fx.c
@@ -11,8 +11,7 @@
#include "prot.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "cnst.h"
#include "stat_dec.h"
#include "basop_util.h"
@@ -48,17 +47,17 @@ static Word16 IGF_getScaleFactor32Cond( /**< ou
{
tmp32 = L_add( x[i], 0 ); /*L_and(x[i], cond[i]);*/
- IF( EQ_16( cond[i], 0 ) )
+ if ( cond[i] == 0 )
{
tmp32 = L_deposit_h( 0 );
}
- IF( GE_32( tmp32, 0 ) )
+ if ( tmp32 >= 0 )
{
x_max = L_max( x_max, tmp32 );
}
- IF( LT_32( tmp32, 0 ) )
+ if ( tmp32 < 0 )
{
x_min = L_min( x_min, tmp32 );
}
@@ -69,11 +68,11 @@ static Word16 IGF_getScaleFactor32Cond( /**< ou
i_min = 0x20;
move16();
- IF( NE_32( x_max, 0 ) )
+ if ( x_max != 0 )
{
i_max = norm_l( x_max );
}
- IF( NE_32( x_min, 0 ) )
+ if ( x_min != 0 )
{
i_min = norm_l( x_min );
}
@@ -109,24 +108,26 @@ static Word16 IGF_replaceTCXNoise_1( /**< ou
nE = 0;
move32();
- FOR( sb = start; sb < stop; sb++ ){
- IF( TCXNoise[sb] ){
+ FOR( sb = start; sb < stop; sb++ )
+ {
+ if ( TCXNoise[sb] )
+ {
tmp16 = extract_h( L_shl( in[sb], s_l ) );
-}
-IF( TCXNoise[sb] )
-{
- nE = L_mac( nE, tmp16, tmp16 );
-}
-IF( TCXNoise[sb] )
-{
- noise = add( noise, 1 );
-}
-}
+ }
+ if ( TCXNoise[sb] )
+ {
+ nE = L_mac( nE, tmp16, tmp16 );
+ }
+ if ( TCXNoise[sb] )
+ {
+ noise = add( noise, 1 );
+ }
+ }
-*totalNoiseNrg = nE;
-move32();
+ *totalNoiseNrg = nE;
+ move32();
-return noise;
+ return noise;
}
/**********************************************************************/ /*
@@ -177,20 +178,20 @@ static void IGF_replaceTCXNoise_2( Word32 *in, /**< in
/* make sure that rE is never 0 */
- IF( EQ_32( rE, 0 ) )
+ IF( rE == 0 )
{
rE = L_add( totalNoiseNrg, 0 ); /* save move32() -> use L_add(x, 0) = x; */
}
/* if totalNoiseNrg == 0, then rE must be at least 0x00010000, otherwise division by 0 will occur */
- IF( EQ_32( totalNoiseNrg, 0 ) )
+ if ( totalNoiseNrg == 0 )
{
rE = L_max( rE, 0x00010000 );
}
/* make sure that rE is never smaller than totalNoiseNrg */
L_tmp = L_sub( rE, totalNoiseNrg );
- IF( LT_32( L_tmp, 0 ) )
+ if ( L_tmp < 0 )
{
rE = totalNoiseNrg; /* save move32() -> use L_add(x, 0) = x; */
move32();
@@ -254,18 +255,18 @@ static void IGF_replaceTCXNoise_2_new_ivas( Word32 *in, /**< in
}
- IF( NE_16( n_noise_bands_tile, 0 ) )
+ IF( n_noise_bands_tile != 0 )
{
noise_band_ratio = div_s( n_noise_bands_tile, n_noise_bands ); // Q15
/* make sure that rE is never 0 */
- IF( EQ_32( rE, 0 ) )
+ if ( rE == 0 )
{
rE = L_add( totalNoiseNrg, 0 ); /* save move32() -> use L_add(x, 0) = x; */
}
/* if totalNoiseNrg == 0, then rE must be at least 0x00010000, otherwise division by 0 will occur */
- IF( EQ_32( totalNoiseNrg, 0 ) )
+ if ( totalNoiseNrg == 0 )
{
rE = L_max( rE, 0x00010000 );
}
@@ -281,9 +282,9 @@ static void IGF_replaceTCXNoise_2_new_ivas( Word32 *in, /**< in
IF( TCXNoise[sb] )
{
Word16 nrm = norm_l( in[sb] );
- in[sb] = L_shl( in[sb], nrm ); // exp: 31 - tmp
- in[sb] = Mpy_32_16_1( in[sb], g ); // exp: 31 - tmp + tmp_e
- in[sb] = L_shr( in[sb], sub( in_e, 31 - nrm + tmp_e ) ); // Making the exponent same as original
+ in[sb] = L_shl( in[sb], nrm ); // exp: 31 - tmp
+ in[sb] = Mpy_32_16_1( in[sb], g ); // exp: 31 - tmp + tmp_e
+ in[sb] = L_shr( in[sb], sub( in_e, sub( add( 31, tmp_e ), nrm ) ) ); // Making the exponent same as original
move32();
}
}
@@ -336,18 +337,18 @@ static void IGF_replaceTCXNoise_2_new_ivas_with_var_shift( Word32 *in,
}
- IF( NE_16( n_noise_bands_tile, 0 ) )
+ IF( n_noise_bands_tile != 0 )
{
noise_band_ratio = div_s( n_noise_bands_tile, n_noise_bands ); // Q15
/* make sure that rE is never 0 */
- IF( EQ_32( rE, 0 ) )
+ IF( rE == 0 )
{
rE = L_add( totalNoiseNrg, 0 ); /* save move32() -> use L_add(x, 0) = x; */
}
/* if totalNoiseNrg == 0, then rE must be at least 0x00010000, otherwise division by 0 will occur */
- IF( EQ_32( totalNoiseNrg, 0 ) )
+ IF( totalNoiseNrg == 0 )
{
rE = L_max( rE, 0x00010000 );
}
@@ -389,7 +390,7 @@ static void IGF_decode_whitening_level( Decoder_State *st,
tmp = get_next_indice( st, 1 );
- IF( EQ_16( tmp, 0 ) )
+ IF( tmp == 0 )
{
hPrivateData->currWhiteningLevel[p] = IGF_WHITENING_MID;
move16();
@@ -401,7 +402,7 @@ static void IGF_decode_whitening_level( Decoder_State *st,
hPrivateData->currWhiteningLevel[p] = IGF_WHITENING_STRONG;
move16();
- IF( EQ_16( tmp, 0 ) )
+ if ( tmp == 0 )
{
hPrivateData->currWhiteningLevel[p] = IGF_WHITENING_OFF;
move16();
@@ -434,9 +435,10 @@ static void IGF_setLinesToZero( const Word16 startLine, /**< in
if there is content in the original MDCT spectrum */
FOR( i = startLine; i < stopLine; i++ )
{
- IF( NE_32( pSpectralData[i], 0 ) )
+ if ( pSpectralData[i] != 0 )
{
pPowerSpecIGF[i] = L_deposit_l( 0 );
+ move32();
}
}
}
@@ -545,7 +547,7 @@ static void IGF_prep( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
tb = hGrid->swb_offset[hGrid->sfbWrap[tile_idx]];
move16();
- IF( NE_32( abs_sum, 0 ) )
+ IF( abs_sum != 0 )
{
FOR( i = strt_cpy; i < startLine; i++ )
{
@@ -570,7 +572,7 @@ static void IGF_prep( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/* medium whitening detected */
IF( EQ_16( IGF_WHITENING_MID, hPrivateData->currWhiteningLevel[tile_idx] ) )
{
- IF( NE_16( n_noise_bands, 0 ) )
+ IF( n_noise_bands != 0 )
{
IGF_replaceTCXNoise_2( igf_spec,
TCXNoise,
@@ -593,7 +595,7 @@ static void IGF_prep( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/* off whitening detectded */
ELSE
{
- IF( NE_16( n_noise_bands_off, 0 ) )
+ IF( n_noise_bands_off != 0 )
{
IGF_replaceTCXNoise_2( hPrivateData->pSpecFlat,
TCXNoise,
@@ -715,11 +717,12 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
tb = hGrid->swb_offset[hGrid->sfbWrap[tile_idx]];
move16();
- IF( NE_32( abs_sum, 0 ) )
+ IF( abs_sum != 0 )
{
FOR( i = strt_cpy; i < stop; i++ )
{
igf_spec[tb++] = L_deposit_l( Random( hInfo->nfSeed ) ); /* 31Q0, fill LSBs */
+ move32();
}
}
ELSE
@@ -742,7 +745,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
{
IF( GT_16( element_mode, EVS_MONO ) )
{
- IF( NE_16( n_noise_bands, 0 ) )
+ IF( n_noise_bands != 0 )
{
IGF_replaceTCXNoise_2_new_ivas( igf_spec,
specMed_e,
@@ -757,7 +760,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
}
ELSE
{
- IF( NE_16( n_noise_bands, 0 ) )
+ IF( n_noise_bands != 0 )
{
IGF_replaceTCXNoise_2( igf_spec,
TCXNoise,
@@ -783,7 +786,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
IF( GT_16( element_mode, EVS_MONO ) )
{
- IF( NE_16( n_noise_bands_off, 0 ) )
+ IF( n_noise_bands_off != 0 )
{
IGF_replaceTCXNoise_2_new_ivas( src_spec,
src_spec_e,
@@ -798,7 +801,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
}
ELSE
{
- IF( NE_16( n_noise_bands_off, 0 ) )
+ IF( n_noise_bands_off != 0 )
{
IGF_replaceTCXNoise_2( src_spec,
TCXNoise,
@@ -1040,6 +1043,7 @@ static void IGF_prepStereo(
IF( EQ_16( IGF_WHITENING_STRONG, hPrivateDataR->currWhiteningLevel[tile_idx] ) )
{
tb = swb_offset[hGrid->sfbWrap[tile_idx]];
+ move16();
FOR( tb = swb_offset[hGrid->sfbWrap[tile_idx]]; tb < swb_offset[hGrid->sfbWrap[tile_idx + 1]]; tb++ )
{
@@ -1156,7 +1160,7 @@ static void IGF_prepStereo(
move16();
}
- IF( EQ_16( coreMsMask[tb], 0 ) )
+ IF( ( coreMsMask[tb] == 0 ) )
{
IF( EQ_16( coreMsMask[strt_cpy], 0 ) ) /* LR->LR */
{
@@ -1510,6 +1514,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
FOR( tb = 0; tb < 24; tb++ )
{
Carry = 0;
+ move16();
#ifdef BASOP_NOGLOB /* Critical Carry/Overflow*/
L_tmp = L_add_co( L_tmp, energyTmp[tb], &Carry, &Overflow );
Overflow = 0;
@@ -1531,12 +1536,12 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/* select correct hopsize for envelope refinement */
hopsize = 2;
move16();
- IF( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF ) )
+ if ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF ) )
{
hopsize = 4;
move16();
}
- IF( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG ) )
+ if ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG ) )
{
hopsize = 1;
move16();
@@ -1563,13 +1568,15 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
&pN_e[sfb] );
move32();
sN[tb] = L_deposit_l( 0 );
+ move32();
pN[tb] = L_deposit_l( 0 );
+ move32();
}
}
}
/* IGF_rescale_SCF */
- IF( NE_16( hGrid->infoIsRefined, 0 ) )
+ IF( hGrid->infoIsRefined != 0 )
{
FOR( sfb = start_sfb; sfb < stop_sfb; sfb += 2 )
{
@@ -1626,7 +1633,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
#endif
BASOP_SATURATE_WARNING_ON_EVS
- IF( LT_32( L_tmp2, 0 ) )
+ IF( L_tmp2 < 0 )
{
L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ );
L_tmp_e = sNlocal_e;
@@ -1637,8 +1644,10 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
L_tmp = Sqrt32( L_tmp, &L_tmp_e );
#ifdef BASOP_NOGLOB
dN[sfb] = round_fx_sat( L_tmp );
+ move16();
#else
dN[sfb] = round_fx( L_tmp );
+ move16();
#endif
dN_e[sfb] = L_tmp_e;
move16();
@@ -1704,7 +1713,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
#endif
BASOP_SATURATE_WARNING_ON_EVS
- IF( LT_32( L_tmp2, 0 ) )
+ IF( L_tmp2 < 0 )
{
L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ );
L_tmp_e = sNlocal_e;
@@ -1713,6 +1722,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/* calc square root of L_tmp and store result in dN */
L_tmp = Sqrt32( L_tmp, &L_tmp_e );
dN[sfb] = round_fx( L_tmp );
+ move16();
dN_e[sfb] = L_tmp_e;
move16();
}
@@ -1729,7 +1739,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
negate( dN[start_sfb] ),
dN_e[start_sfb],
&tmp ); /* float: tmp = dE - dN[start_sfb] */
- IF( LT_16( tmp, 0 ) )
+ IF( tmp < 0 )
{
/* float: dS[start_sfb] = dN[start_sfb] + fFactor * (dE-dN[start_sfb]); basop: */
L_tmp = L_mult( fFactor, tmp );
@@ -1750,7 +1760,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
sfb_p1 = add( start_sfb, 1 );
sfb_m1 = sub( stop_sfb, 1 );
test();
- IF( NE_16( hGrid->infoIsRefined, 0 ) && EQ_16( hopsize, 1 ) )
+ IF( hGrid->infoIsRefined != 0 && EQ_16( hopsize, 1 ) )
{
/* apply filter to absolute energy values: */
FOR( sfb = sfb_p1; sfb < sfb_m1; sfb++ )
@@ -1880,7 +1890,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/* gain calculation */
gain[sfb] = 0;
move16();
- IF( NE_32( pN[sfb], 0 ) )
+ IF( pN[sfb] != 0 )
{
tmp = BASOP_Util_Divide3232_Scale( dNlocal, pN[sfb], &s );
s = sub( add( s, dNlocal_e ), pN_e[sfb] );
@@ -1905,7 +1915,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/*--- check gains /spectrum exponents for possible overflows --- */
/* get tile index */
- IF( LE_16( hGrid->sfbWrap[tileIdx + 1], sfb ) )
+ if ( LE_16( hGrid->sfbWrap[add( tileIdx, 1 )], sfb ) )
{
tileIdx = add( tileIdx, 1 );
}
@@ -1915,7 +1925,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/*check whether overflow would occur and calculate Headroom, needed*/
shift = sub( L_tmp_e, *spectrum_e );
tmp = sub( shift, sub( norm_l( L_tmp ), TCX_IMDCT_HEADROOM ) );
- IF( GT_16( tmp, 0 ) )
+ if ( tmp > 0 )
{
Hr = s_max( Hr, tmp );
}
@@ -1923,7 +1933,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/* disable rescaling if gain is smaler than 1 */
/* gain < 1, if norm_s(gain[sfb]) >= gain_e[sfb] */
tmp = sub( norm_s( gain[sfb] ), gain_e[sfb] );
- IF( GE_16( tmp, 0 ) )
+ if ( tmp >= 0 )
{
Hr = 0;
move16();
@@ -1933,7 +1943,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/* Rescale spectrum if overflow may occur */
tileIdx = -1;
move16();
- IF( GT_16( Hr, 0 ) )
+ IF( Hr > 0 )
{
/* rescale virtual Spec, cheap and easy: reset scalingfactor */
*virtualSpec_e = add( *virtualSpec_e, Hr );
@@ -1955,7 +1965,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
FOR( sfb = start_sfb; sfb < stop_sfb; sfb++ )
{
/* get tile index */
- IF( EQ_16( hGrid->sfbWrap[tileIdx + 1], sfb ) )
+ if ( EQ_16( hGrid->sfbWrap[tileIdx + 1], sfb ) )
{
tileIdx = add( tileIdx, 1 );
}
@@ -1965,7 +1975,9 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/* normalize gain */
tmp = norm_s( gain[sfb] );
gain[sfb] = shl( gain[sfb], tmp );
+ move16();
gain_e[sfb] = sub( gain_e[sfb], tmp );
+ move16();
/* gain[sfb] = min(gain[sfb], 12.f); */
BASOP_SATURATE_WARNING_OFF_EVS /* threshold, may overflow */
@@ -2032,8 +2044,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
IF( spectrum[tb] == 0 )
{
shift = sub( L_tmp_e, *spectrum_e );
- tmp = norm_l( L_tmp ) - shift - 32;
- IF( LT_16( tmp, 0 ) )
+ tmp = sub( sub( norm_l( L_tmp ), shift ), 32 );
+ if ( tmp < 0 )
{
L_tmp2 = L_shl( L_tmp, shift );
}
@@ -2045,8 +2057,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
ELSE
{
shift = sub( L_tmp_e, *virtualSpec_e );
- tmp = norm_l( L_tmp ) - shift - 32;
- IF( LT_16( tmp, 0 ) )
+ tmp = sub( sub( norm_l( L_tmp ), shift ), 32 );
+ if ( tmp < 0 )
{
L_tmp2 = L_shl( L_tmp, shift );
}
@@ -2129,7 +2141,9 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
Word16 vspec_e_arr[N_MAX_TCX - IGF_START_MN];
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move16();
Flag Carry = 0;
+ move16();
#endif
@@ -2213,6 +2227,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
FOR( tb = 0; tb < 24; tb++ )
{
Carry = 0;
+ move16();
#ifdef BASOP_NOGLOB /* Critical Carry/Overflow*/
L_tmp = L_add_co( L_tmp, energyTmp[tb], &Carry, &Overflow );
Overflow = 0;
@@ -2234,12 +2249,12 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/* select correct hopsize for envelope refinement */
hopsize = 2;
move16();
- IF( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF ) )
+ if ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_OFF ) )
{
hopsize = 4;
move16();
}
- IF( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG ) )
+ if ( EQ_16( hPrivateData->currWhiteningLevel[0], IGF_WHITENING_STRONG ) )
{
hopsize = 1;
move16();
@@ -2270,13 +2285,15 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
&pN_e[sfb] );
move32();
sN[tb] = L_deposit_l( 0 );
+ move32();
pN[tb] = L_deposit_l( 0 );
+ move32();
}
}
}
/* IGF_rescale_SCF */
- IF( NE_16( hGrid->infoIsRefined, 0 ) )
+ IF( hGrid->infoIsRefined != 0 )
{
FOR( sfb = start_sfb; sfb < stop_sfb; sfb += 2 )
{
@@ -2333,7 +2350,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
#endif
BASOP_SATURATE_WARNING_ON_EVS
- IF( LT_32( L_tmp2, 0 ) )
+ IF( L_tmp2 < 0 )
{
L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ );
L_tmp_e = sNlocal_e;
@@ -2343,6 +2360,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/* calc square root of L_tmp and store result in dN */
L_tmp = Sqrt32( L_tmp, &L_tmp_e );
dN[sfb] = extract_h( L_tmp );
+ move16();
dN_e[sfb] = L_tmp_e;
move16();
dN[sfb + 1] = dN[sfb];
@@ -2400,15 +2418,17 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
L_tmp2 = L_shl_sat( L_negate( Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ ) ), sub( sNlocal_e, L_tmp_e ) );
L_tmp2 = L_sub_sat( L_tmp2, L_negate( L_tmp ) );
- IF( LT_32( L_tmp2, 0 ) )
+ IF( L_tmp2 < 0 )
{
L_tmp = Mpy_32_16_1( sNlocal, 33 /*0.001f Q15*/ );
L_tmp_e = sNlocal_e;
+ move16();
}
/* calc square root of L_tmp and store result in dN */
L_tmp = Sqrt32( L_tmp, &L_tmp_e );
dN[sfb] = round_fx( L_tmp );
+ move16();
dN_e[sfb] = L_tmp_e;
move16();
}
@@ -2425,7 +2445,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
negate( dN[start_sfb] ),
dN_e[start_sfb],
&tmp ); /* float: tmp = dE - dN[start_sfb] */
- IF( LT_16( tmp, 0 ) )
+ IF( tmp < 0 )
{
/* float: dS[start_sfb] = dN[start_sfb] + fFactor * (dE-dN[start_sfb]); basop: */
L_tmp = L_mult( fFactor, tmp );
@@ -2446,7 +2466,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
sfb_p1 = add( start_sfb, 1 );
sfb_m1 = sub( stop_sfb, 1 );
test();
- IF( NE_16( hGrid->infoIsRefined, 0 ) && EQ_16( hopsize, 1 ) )
+ IF( hGrid->infoIsRefined != 0 && EQ_16( hopsize, 1 ) )
{
/* apply filter to absolute energy values: */
FOR( sfb = sfb_p1; sfb < sfb_m1; sfb++ )
@@ -2456,6 +2476,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
dS[sfb] = round_fx( L_tmp );
move16();
dS_e[sfb] = dN_e[sfb - 1]; /* w0 is Q15, so no need to add an exponent */
+ move16();
L_tmp = L_mult( w1, dN[sfb] );
dS_e[sfb] = BASOP_Util_Add_MantExp( dS[sfb],
dS_e[sfb],
@@ -2543,6 +2564,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/* take the square root and store the result in dS */
L_tmp = Sqrt32( L_tmp, &L_tmp_e );
dS[sfb] = round_fx( L_tmp );
+ move16();
dS_e[sfb] = L_tmp_e;
move16();
@@ -2604,7 +2626,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
FOR( sfb = start_sfb; sfb < stop_sfb; sfb++ )
{
/* get tile index */
- IF( EQ_16( hGrid->sfbWrap[tileIdx + 1], sfb ) )
+ if ( EQ_16( hGrid->sfbWrap[tileIdx + 1], sfb ) )
{
tileIdx = add( tileIdx, 1 );
}
@@ -2615,7 +2637,9 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
/* normalize gain */
tmp = norm_s( gain[sfb] );
gain[sfb] = shl( gain[sfb], tmp );
+ move16();
gain_e[sfb] = sub( gain_e[sfb], tmp );
+ move16();
/* gain[sfb] = min(gain[sfb], 12.f); */
BASOP_SATURATE_WARNING_OFF_EVS /* threshold, may overflow */
@@ -2768,7 +2792,7 @@ static void IGF_getWhiteSpectralData( const Word32 *in, /**< in
ak_norm = Mpy_32_16_r( ak, 2185 );
tmp_16 = sub( 31, norm_l( ak_norm ) );
- IF( EQ_32( ak, 0 ) )
+ if ( ak == 0 )
{
tmp_16 = 0;
move16();
@@ -2791,7 +2815,7 @@ static void IGF_getWhiteSpectralData( const Word32 *in, /**< in
ak_norm = Mpy_32_16_r( ak, nrm_tab[nrm_i++] );
tmp_16 = sub( 31, norm_l( ak_norm ) );
- IF( EQ_32( ak, 0 ) )
+ if ( ak == 0 )
{
tmp_16 = 0;
move16();
@@ -2800,7 +2824,7 @@ static void IGF_getWhiteSpectralData( const Word32 *in, /**< in
tmp_16 = s_min( 14, sub( 15, shr( tmp_16, 1 ) ) );
div = shl( 1, tmp_16 );
- IF( LT_32( ak, 16 ) )
+ if ( LT_32( ak, 16 ) )
{
div = 1;
move16();
@@ -2857,7 +2881,9 @@ static void IGF_getWhiteSpectralData_ivas(
FOR( i = start; i < stop - level; i++ )
{
ak = 0;
+ move32();
ak_e = 0;
+ move32();
FOR( j = i - level; j < i + level + 1; j++ )
{
tmp_16 = extract_h( L_shl( in[j], s_l ) );
@@ -2919,6 +2945,7 @@ static void IGF_RefineGrid( H_IGF_GRID hGrid /**< in
Word16 delta;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move16();
#endif
set16_fx( a, 0, IGF_MAX_SFB + 1 );
@@ -2969,6 +2996,7 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han
Word16 delta;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move16();
#endif
set16_fx( a, 0, IGF_MAX_SFB + 1 );
@@ -2994,6 +3022,7 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han
IF( GE_16( sub( delta, shl( shr( delta, 6 ), 6 ) ), MID ) )
{
a[tmp] = add( a[tmp], 1 );
+ move16();
}
move16();
IF( s_and( a[tmp], 1 ) != 0 )
@@ -3048,12 +3077,12 @@ void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
move16();
}
- IF( EQ_16( isIndepFrame, 0 ) )
+ IF( isIndepFrame == 0 )
{
tmp = get_next_indice( st, 1 );
}
- IF( EQ_16( tmp, 1 ) )
+ IF( tmp == 1 )
{
FOR( p = 0; p < nT; p++ )
{
@@ -3065,7 +3094,7 @@ void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
{
IGF_decode_whitening_level( st, hPrivateData, 0 );
test();
- IF( hPrivateData->igfInfo.bitRateIndex == IGF_BITRATE_SWB_48000_CPE || hPrivateData->igfInfo.bitRateIndex == IGF_BITRATE_FB_48000_CPE )
+ IF( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) )
{
tmp = 0;
move16();
@@ -3133,7 +3162,7 @@ void IGFDecReadData( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | ins
move16();
}
- IF( EQ_16( isIndepFrame, 0 ) )
+ IF( isIndepFrame == 0 )
{
tmp = get_next_indice( st, 1 );
}
@@ -3205,7 +3234,7 @@ void IGFDecReadLevel( /**< ou
move16();
IGFAllZero = get_next_indice( st, 1 );
- IF( EQ_16( IGFAllZero, 0 ) )
+ IF( IGFAllZero == 0 )
{
Copy( hPrivateData->igf_curr, hPrivateData->igf_prev, hGrid->stopSfb );
IGFSCFDecoderDecode( &hPrivateData->hArithSCFdec, st, &hPrivateData->igf_curr[m_igfSfbStart], /* 0Q15, hPrivateData->igf_curr = [0, 91] */ igfGridIdx, isIndepFrame );
@@ -3266,7 +3295,7 @@ void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
set16_fx( igf_spec_e, 0, IGF_MAX_TILES );
/* concealment counter */
- IF( NE_16( bfi, 0 ) )
+ IF( bfi != 0 )
{
hPrivateData->frameLossCounter = add( hPrivateData->frameLossCounter, 1 );
}
@@ -3277,7 +3306,7 @@ void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
}
/* skip IGF processing if all IGF levels are zero */
- IF( EQ_16( hInstance->infoIGFAllZero, 0 ) )
+ IF( hInstance->infoIGFAllZero == 0 )
{
@@ -3434,7 +3463,7 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
set16_fx( igf_spec_e, 0, IGF_MAX_TILES );
/* concealment counter */
- IF( NE_16( bfi, 0 ) )
+ IF( bfi != 0 )
{
hPrivateData->frameLossCounter = add( hPrivateData->frameLossCounter, 1 );
}
@@ -3445,7 +3474,7 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
}
/* skip IGF processing if all IGF levels are zero */
- IF( EQ_16( hInstance->infoIGFAllZero, 0 ) )
+ IF( hInstance->infoIGFAllZero == 0 )
{
FOR( i = 0; i < hGrid->nTiles; i++ )
{
@@ -3477,12 +3506,12 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
/*14 seems to be precise enough*/
hPrivateData->headroom_TCX_noise_white = IGF_getScaleFactor32Cond(
- hInstance->infoTCXNoise_evs + hGrid->minSrcSubband,
+ hInstance->infoTCXNoise_ptr,
igf_spec + hGrid->minSrcSubband,
sub( hGrid->startLine, hGrid->minSrcSubband ) );
hPrivateData->n_noise_bands = IGF_replaceTCXNoise_1( igf_spec,
hPrivateData->headroom_TCX_noise_white,
- hInstance->infoTCXNoise_evs,
+ hInstance->infoTCXNoise_ptr,
hGrid->minSrcSubband,
hGrid->startLine,
&hPrivateData->totalNoiseNrg );
@@ -3499,13 +3528,13 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
IF( EQ_16( hPrivateData->currWhiteningLevel[i], IGF_WHITENING_OFF ) )
{
hPrivateData->headroom_TCX_noise = IGF_getScaleFactor32Cond(
- hInstance->infoTCXNoise_evs + hGrid->minSrcSubband,
+ hInstance->infoTCXNoise_ptr,
hPrivateData->pSpecFlat + hGrid->minSrcSubband,
sub( hGrid->startLine, hGrid->minSrcSubband ) );
hPrivateData->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateData->pSpecFlat,
hPrivateData->headroom_TCX_noise,
- hInstance->infoTCXNoise_evs,
+ hInstance->infoTCXNoise_ptr,
hGrid->minSrcSubband,
hGrid->startLine,
&hPrivateData->totalNoiseNrg_off );
@@ -3516,7 +3545,7 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
IGF_prep_ivas( hPrivateData,
igfGridIdx,
- hInstance->infoTCXNoise_evs,
+ hInstance->infoTCXNoise_ptr,
igf_spec,
igf_spec_e,
hPrivateData->pSpecFlat,
@@ -3544,11 +3573,11 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
/* reset TCX noise indicator vector */
IF( EQ_16( igfGridIdx, IGF_GRID_LB_SHORT ) )
{
- set16_fx( hInstance->infoTCXNoise_evs, 0, IGF_START_MX / 2 );
+ set16_fx( hInstance->infoTCXNoise_ptr, 0, IGF_START_MX / 2 );
}
ELSE
{
- set16_fx( hInstance->infoTCXNoise_evs, 0, IGF_START_MX );
+ set16_fx( hInstance->infoTCXNoise_ptr, 0, IGF_START_MX );
}
}
@@ -3696,12 +3725,12 @@ void IGFDecApplyStereo(
move16();
}
- hPrivateDataL->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecL->infoTCXNoise_evs + hGrid->minSrcSubband,
+ hPrivateDataL->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecL->infoTCXNoise_ptr + hGrid->minSrcSubband,
igf_specL_fx + hGrid->minSrcSubband,
sub( hGrid->startLine, hGrid->minSrcSubband ) );
hPrivateDataL->n_noise_bands = IGF_replaceTCXNoise_1( igf_specL_fx,
hPrivateDataL->headroom_TCX_noise_white,
- hIGFDecL->infoTCXNoise_evs,
+ hIGFDecL->infoTCXNoise_ptr,
hGrid->minSrcSubband,
hGrid->startLine,
&hPrivateDataL->totalNoiseNrg );
@@ -3728,12 +3757,12 @@ void IGFDecApplyStereo(
move16();
}
- hPrivateDataR->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecR->infoTCXNoise_evs + hGrid->minSrcSubband,
+ hPrivateDataR->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecR->infoTCXNoise_ptr,
igf_specR_fx + hGrid->minSrcSubband,
sub( hGrid->startLine, hGrid->minSrcSubband ) );
hPrivateDataR->n_noise_bands = IGF_replaceTCXNoise_1( igf_specR_fx,
hPrivateDataR->headroom_TCX_noise_white,
- hIGFDecR->infoTCXNoise_evs,
+ hIGFDecR->infoTCXNoise_ptr,
hGrid->minSrcSubband,
hGrid->startLine,
&hPrivateDataR->totalNoiseNrg );
@@ -3748,23 +3777,23 @@ void IGFDecApplyStereo(
test();
IF( EQ_16( hPrivateDataL->currWhiteningLevel[i], IGF_WHITENING_OFF ) || EQ_16( hPrivateDataR->currWhiteningLevel[i], IGF_WHITENING_OFF ) )
{
- hPrivateDataL->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecL->infoTCXNoise_evs + hGrid->minSrcSubband,
+ hPrivateDataL->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecL->infoTCXNoise_ptr + hGrid->minSrcSubband,
hPrivateDataL->pSpecFlat + hGrid->minSrcSubband,
sub( hGrid->startLine, hGrid->minSrcSubband ) );
hPrivateDataL->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateDataL->pSpecFlat,
hPrivateDataL->headroom_TCX_noise_white,
- hIGFDecL->infoTCXNoise_evs,
+ hIGFDecL->infoTCXNoise_ptr,
hGrid->minSrcSubband,
hGrid->startLine,
&hPrivateDataL->totalNoiseNrg_off );
hPrivateDataL->totalNoiseNrg_off_exp = shl( sub( hPrivateDataL->pSpecFlat_exp, sub( hPrivateDataL->headroom_TCX_noise_white, 5 ) ), 1 );
- hPrivateDataR->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecR->infoTCXNoise_evs + hGrid->minSrcSubband,
+ hPrivateDataR->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hIGFDecR->infoTCXNoise_ptr,
hPrivateDataR->pSpecFlat + hGrid->minSrcSubband,
sub( hGrid->startLine, hGrid->minSrcSubband ) );
hPrivateDataR->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateDataR->pSpecFlat,
hPrivateDataR->headroom_TCX_noise_white,
- hIGFDecR->infoTCXNoise_evs,
+ hIGFDecR->infoTCXNoise_ptr,
hGrid->minSrcSubband,
hGrid->startLine,
&hPrivateDataR->totalNoiseNrg_off );
@@ -3788,8 +3817,8 @@ void IGFDecApplyStereo(
IGF_prepStereo( hPrivateDataL,
hPrivateDataR,
igfGridIdx,
- hIGFDecL->infoTCXNoise_evs,
- hIGFDecR->infoTCXNoise_evs,
+ hIGFDecL->infoTCXNoise_ptr,
+ hIGFDecR->infoTCXNoise_ptr,
igf_specL_fx,
igf_specL_e_arr,
igf_specR_fx,
@@ -3857,13 +3886,13 @@ void IGFDecApplyStereo(
/* reset TCX noise indicator vector */
IF( EQ_16( igfGridIdx, IGF_GRID_LB_SHORT ) )
{
- set16_fx( hIGFDecL->infoTCXNoise_evs, 0, IGF_START_MX / 2 );
- set16_fx( hIGFDecR->infoTCXNoise_evs, 0, IGF_START_MX / 2 );
+ set16_fx( hIGFDecL->infoTCXNoise_ptr, 0, IGF_START_MX / 2 );
+ set16_fx( hIGFDecR->infoTCXNoise_ptr, 0, IGF_START_MX / 2 );
}
ELSE
{
- set16_fx( hIGFDecL->infoTCXNoise_evs, 0, IGF_START_MX );
- set16_fx( hIGFDecR->infoTCXNoise_evs, 0, IGF_START_MX );
+ set16_fx( hIGFDecL->infoTCXNoise_ptr, 0, IGF_START_MX );
+ set16_fx( hIGFDecR->infoTCXNoise_ptr, 0, IGF_START_MX );
}
return;
@@ -4262,9 +4291,9 @@ Word16 get_igf_startline(
{
Word16 igf_startline;
- IF( EQ_16( st->igf, 0 ) )
+ IF( st->igf == 0 )
{
- IF( EQ_16( st->narrowBand, 0 ) )
+ IF( st->narrowBand == 0 )
{
/* minimum needed for output with sampling rates lower then the
nominal sampling rate */
diff --git a/lib_dec/igf_scf_dec_fx.c b/lib_dec/igf_scf_dec_fx.c
index cda1bb3b8aa08ff4350ac0c51682d196d7ef4e14..221b9b7a4981e17944331cf6875eafc25a4bd080 100644
--- a/lib_dec/igf_scf_dec_fx.c
+++ b/lib_dec/igf_scf_dec_fx.c
@@ -8,8 +8,7 @@
#include
#include "options.h"
#include "stl.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "stat_dec.h"
#include "basop_util.h"
@@ -54,7 +53,7 @@ static Word16 quant_ctx_fx(
result = s_min( abs_s( ctx ), IGF_CTX_OFFSET ); /* limit the absolute value to IGF_CTX_OFFSET */
- IF( LT_16( ctx, 0 ) ) /* add the sign back, if needed */
+ if ( ctx < 0 ) /* add the sign back, if needed */
{
result = negate( result );
}
@@ -80,7 +79,7 @@ static Word16 arith_decode_bits_fx(
x = lshl( x, 1 );
/* decode one bit using the new raw AC function */
bit = ari_decode_14bits_bit_ext_fx( st, &hPrivateData->acState );
- IF( NE_16( bit, 0 ) )
+ if ( bit != 0 )
{
x = s_or( x, 1 );
}
@@ -107,7 +106,7 @@ static Word16 arith_decode_residual_fx(
/* meaning of the values of val: */
/* esc_{0} IGF_MIN_ENC_SEPARATE ... IGF_MAX_ENC_SEPARATE esc_{IGF_SYMBOLS_IN_TABLE - 1} */
test();
- IF( ( NE_16( val, 0 ) ) && ( NE_16( val, IGF_SYMBOLS_IN_TABLE - 1 ) ) )
+ IF( ( val != 0 ) && ( NE_16( val, IGF_SYMBOLS_IN_TABLE - 1 ) ) )
{
x = add( val, -1 + IGF_MIN_ENC_SEPARATE ); /* (val - 1) + IGF_MIN_ENC_SEPARATE */
@@ -133,12 +132,12 @@ static Word16 arith_decode_residual_fx(
extra = add( 15, extra );
}
- IF( EQ_16( val, 0 ) )
+ if ( val == 0 )
{
/* escape code 0 to indicate x <= IGF_MIN_ENC_SEPARATE - 1 */
x = sub( IGF_MIN_ENC_SEPARATE - 1, extra );
}
- IF( EQ_16( val, IGF_SYMBOLS_IN_TABLE - 1 ) )
+ if ( EQ_16( val, IGF_SYMBOLS_IN_TABLE - 1 ) )
{
/* escape code (IGF_SYMBOLS_IN_TABLE - 1) to indicate x >= IGF_MAX_ENC_SEPARATE + 1 */
x = add( IGF_MAX_ENC_SEPARATE + 1, extra );
@@ -186,9 +185,9 @@ static void decode_sfe_vector_fx(
FOR( f = 0; f < length; ++f )
{
- IF( EQ_16( t, 0 ) )
+ IF( t == 0 )
{
- IF( EQ_16( f, 0 ) )
+ IF( f == 0 )
{
/* (t == 0) && (f == 0) */
/* decode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */
@@ -228,7 +227,7 @@ static void decode_sfe_vector_fx(
ELSE
{
/* t == 1 */
- IF( EQ_16( f, 0 ) )
+ IF( f == 0 )
{
/* (t == 1) && (f == 0) */
res = arith_decode_residual_fx( hPrivateData,
@@ -264,7 +263,7 @@ static void decode_sfe_vector_fx(
}
}
- IF( LT_16( x[f], 0 ) )
+ IF( x[f] < 0 )
{
x[f] = 0;
move16();
@@ -315,7 +314,7 @@ void IGFSCFDecoderDecode(
ari_start_decoding_14bits_fx( st, &hPublicData->acState ); /* start AC decoding */
/* check if coder needs a reset and do it if necessary */
- IF( NE_16( indepFlag, 0 ) )
+ IF( indepFlag != 0 )
{
/* reset of coder */
IGFSCFDecoderReset( hPublicData );
diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c
index 3a56b99e54f42c4d30e836e57b91e706890c602e..908738df38be464283726ae416d55ca9a586924e 100644
--- a/lib_dec/init_dec.c
+++ b/lib_dec/init_dec.c
@@ -40,12 +40,9 @@
#include "ivas_cnst.h"
#include "rom_com.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c
index ad5c524c136379f1a5cf7528f600ce7107c514f1..05cda5a462822b22c9dfaac3233946b827832b4e 100644
--- a/lib_dec/init_dec_fx.c
+++ b/lib_dec/init_dec_fx.c
@@ -3,8 +3,7 @@
====================================================================================*/
#include "options.h" /* Compilation switches */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
#include "stl.h" /* required for wmc_tool */
@@ -130,7 +129,7 @@ ivas_error init_decoder_fx(
*-----------------------------------------------------------------*/
test();
- IF( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st_fx->hBWE_FD = (FD_BWE_DEC_HANDLE) count_malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL )
{
@@ -149,7 +148,7 @@ ivas_error init_decoder_fx(
*-----------------------------------------------------------------*/
test();
- IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
+ IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st_fx->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) count_malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL )
{
@@ -209,7 +208,7 @@ ivas_error init_decoder_fx(
test();
test();
- IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
+ IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
IF( ( st_fx->hGSCDec = (GSC_DEC_HANDLE) count_malloc( sizeof( GSC_DEC_DATA ) ) ) == NULL )
{
@@ -227,7 +226,7 @@ ivas_error init_decoder_fx(
* parameters for fast recovery (WI)
*-----------------------------------------------------------------*/
test();
- IF( EQ_32( st_fx->output_Fs, 16000 ) && EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( EQ_32( st_fx->output_Fs, 16000 ) && ( st_fx->element_mode == EVS_MONO ) )
{
IF( ( st_fx->hWIDec = (WI_DEC_HANDLE) count_malloc( sizeof( WI_DEC_DATA ) ) ) == NULL )
{
@@ -354,7 +353,7 @@ ivas_error init_decoder_fx(
test();
test();
test();
- IF( EQ_16( idchan, 0 ) && ( EQ_16( st_fx->element_mode, EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) )
+ IF( idchan == 0 && ( ( st_fx->element_mode == EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) )
{
IF( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) count_malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL )
{
@@ -368,6 +367,7 @@ ivas_error init_decoder_fx(
st_fx->hTdCngDec = NULL;
}
st_fx->cng_type = -1;
+ move16();
st_fx->CNG_fx = 0;
move16(); /* RTXDTX handler CNG=1 nonCNG= 0,*/
st_fx->prev_ft_speech_fx = 1;
@@ -397,7 +397,9 @@ ivas_error init_decoder_fx(
FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
st_fx->lsp_shb_prev_fx[i] = lsp_shb_prev_tbl_fx[i];
+ move16();
st_fx->lsp_shb_prev_prev_fx[i] = st_fx->lsp_shb_prev_fx[i];
+ move16();
}
st_fx->shb_dtx_count_fx = 0;
@@ -428,7 +430,7 @@ ivas_error init_decoder_fx(
test();
test();
test();
- IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) )
+ IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || ( st_fx->element_mode == EVS_MONO ) ) )
{
IF( ( st_fx->hHQ_core = (HQ_DEC_HANDLE) count_malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL )
{
@@ -438,7 +440,7 @@ ivas_error init_decoder_fx(
/* HQ core initialization */
HQ_core_dec_init_fx( st_fx->hHQ_core );
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
/* HQ NB FEC initialization */
IF( ( st_fx->hHQ_nbfec = (HQ_NBFEC_HANDLE) count_malloc( sizeof( HQ_NBFEC_DATA ) ) ) == NULL )
@@ -468,7 +470,7 @@ ivas_error init_decoder_fx(
move16();
set16_fx( st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP );
set16_fx( st_fx->previoussynth_fx, 0, L_FRAME48k );
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
set16_fx( st_fx->old_synth_sw_fx, 0, NS2SA( 48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ) );
}
@@ -477,7 +479,7 @@ ivas_error init_decoder_fx(
*-----------------------------------------------------------------*/
/* TCX-LTP */
- IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
+ IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
{
IF( ( st_fx->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) count_malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL )
{
@@ -491,7 +493,7 @@ ivas_error init_decoder_fx(
/* TCX core */
// VE: reduction possible for MCT_CHAN_MODE_LFE channel - see I1-172
- IF( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) count_malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL )
{
@@ -508,7 +510,7 @@ ivas_error init_decoder_fx(
st_fx->hTcxDec = NULL;
}
/* TCX config. data structure */
- IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
+ IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) count_malloc( sizeof( TCX_config ) ) ) == NULL )
{
@@ -536,7 +538,7 @@ ivas_error init_decoder_fx(
*-----------------------------------------------------------------*/
test();
- IF( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) count_malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL )
{
@@ -623,7 +625,7 @@ ivas_error init_decoder_fx(
* AMR-WB IO mode parameters
*----------------------------------------------------------------------------------*/
test();
- IF( st_fx->Opt_AMR_WB || EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->Opt_AMR_WB || st_fx->element_mode == EVS_MONO )
{
IF( ( st_fx->hAmrwb_IO = (AMRWB_IO_DEC_HANDLE) count_malloc( sizeof( AMRWB_IO_DEC_DATA ) ) ) == NULL )
{
@@ -645,7 +647,7 @@ ivas_error init_decoder_fx(
*-----------------------------------------------------------------*/
test();
test();
- IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
+ IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
IF( ( st_fx->hBWE_zero = (ZERO_BWE_DEC_HANDLE) count_malloc( sizeof( ZERO_BWE_DEC_DATA ) ) ) == NULL )
{
@@ -672,7 +674,7 @@ ivas_error init_decoder_fx(
*-----------------------------------------------------------------*/
test();
test();
- IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
+ IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
IF( ( st_fx->hBPF = (BPF_DEC_HANDLE) count_malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL )
{
@@ -689,18 +691,18 @@ ivas_error init_decoder_fx(
* FD BPF & resampling tools parameters
*-----------------------------------------------------------------*/
/* open analysis for max. SR 48kHz */
- IF( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, CLDFB_getNumChannels( 48000 ), 320 ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, CLDFB_getNumChannels( 48000 ), 320 ) ), IVAS_ERR_OK ) )
{
return error;
}
/* open analysis BPF for max. SR 16kHz */
- IF( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, CLDFB_getNumChannels( 16000 ), 320 ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, CLDFB_getNumChannels( 16000 ), 320 ) ), IVAS_ERR_OK ) )
{
return error;
}
/* open synthesis for output SR */
- IF( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, CLDFB_getNumChannels( st_fx->output_Fs ), st_fx->output_frame_fx ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, CLDFB_getNumChannels( st_fx->output_Fs ), st_fx->output_frame_fx ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -731,7 +733,7 @@ ivas_error init_decoder_fx(
* SC-VBR parameters
*-----------------------------------------------------------------*/
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
IF( ( st_fx->hSC_VBR = (SC_VBR_DEC_HANDLE) count_malloc( sizeof( SC_VBR_DEC_DATA ) ) ) == NULL )
{
@@ -788,12 +790,12 @@ ivas_error init_decoder_fx(
#ifdef IVAS_CODE
IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) ) // TBV Fixed point missing
#else
- IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( idchan, 0 ) ) /*&& mc_mode != MC_MODE_MCT && mc_mode != MC_MODE_PARAMUPMIX*/ )
+ IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) /*&& mc_mode != MC_MODE_MCT && mc_mode != MC_MODE_PARAMUPMIX*/ )
#endif
{
/* Create FD_CNG instance */
- IF( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -942,6 +944,7 @@ ivas_error init_decoder_ivas_fx(
move16();
st_fx->flag_ACELP16k = set_ACELP_flag( st_fx->element_mode, st_fx->total_brate, st_fx->total_brate, idchan, 0, -1, -1 );
+ move16();
/*-----------------------------------------------------------------*
* ACELP core parameters
@@ -1109,7 +1112,7 @@ ivas_error init_decoder_ivas_fx(
test();
test();
- IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
+ IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
IF( ( st_fx->hGSCDec = (GSC_DEC_HANDLE) count_malloc( sizeof( GSC_DEC_DATA ) ) ) == NULL )
{
@@ -1128,7 +1131,7 @@ ivas_error init_decoder_ivas_fx(
*-----------------------------------------------------------------*/
test();
- IF( EQ_32( st_fx->output_Fs, 16000 ) && EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( EQ_32( st_fx->output_Fs, 16000 ) && ( st_fx->element_mode == EVS_MONO ) )
{
IF( ( st_fx->hWIDec = (WI_DEC_HANDLE) count_malloc( sizeof( WI_DEC_DATA ) ) ) == NULL )
{
@@ -1148,7 +1151,7 @@ ivas_error init_decoder_ivas_fx(
*-----------------------------------------------------------------*/
test();
test();
- IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
+ IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
IF( ( st_fx->hPFstat = (PFSTAT_HANDLE) count_malloc( sizeof( PFSTAT ) ) ) == NULL )
{
@@ -1170,7 +1173,7 @@ ivas_error init_decoder_ivas_fx(
test();
test();
- IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
+ IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
IF( ( st_fx->hBWE_zero = (ZERO_BWE_DEC_HANDLE) malloc( sizeof( ZERO_BWE_DEC_DATA ) ) ) == NULL )
{
@@ -1192,7 +1195,7 @@ ivas_error init_decoder_ivas_fx(
*-----------------------------------------------------------------*/
test();
test();
- IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
+ IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
IF( ( st_fx->hMusicPF = (MUSIC_POSTFILT_HANDLE) count_malloc( sizeof( MUSIC_POSTFILT_DATA ) ) ) == NULL )
{
@@ -1226,7 +1229,7 @@ ivas_error init_decoder_ivas_fx(
test();
test();
test();
- IF( EQ_16( idchan, 0 ) && ( EQ_16( st_fx->element_mode, EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) )
+ IF( idchan == 0 && ( EQ_16( st_fx->element_mode, EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) )
{
IF( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) count_malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL )
{
@@ -1266,7 +1269,7 @@ ivas_error init_decoder_ivas_fx(
test();
test();
test();
- IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) )
+ IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) )
{
IF( ( st_fx->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL )
{
@@ -1302,7 +1305,7 @@ ivas_error init_decoder_ivas_fx(
*-----------------------------------------------------------------*/
test();
- IF( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL )
{
@@ -1328,7 +1331,7 @@ ivas_error init_decoder_ivas_fx(
* SWB BWE parameters
*-----------------------------------------------------------------*/
test();
- IF( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st_fx->hBWE_FD = (FD_BWE_DEC_HANDLE) malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL )
{
@@ -1373,7 +1376,7 @@ ivas_error init_decoder_ivas_fx(
* HR SWB BWE parameters
*-----------------------------------------------------------------*/
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( ( st_fx->element_mode == EVS_MONO ) )
{
IF( ( st_fx->hBWE_FD_HR = (HR_BWE_DEC_HANDLE) count_malloc( sizeof( HR_BWE_DEC_DATA ) ) ) == NULL )
{
@@ -1448,7 +1451,7 @@ ivas_error init_decoder_ivas_fx(
test();
test();
- IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
+ IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
IF( ( st_fx->hBPF = (BPF_DEC_HANDLE) malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL )
{
@@ -1467,16 +1470,16 @@ ivas_error init_decoder_ivas_fx(
*-----------------------------------------------------------------*/
test();
test();
- IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
+ IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
/* open analysis for max. SR 48kHz */
- IF( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
{
return error;
}
/* open analysis BPF for max. SR 16kHz */
- IF( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1488,7 +1491,7 @@ ivas_error init_decoder_ivas_fx(
}
/* open synthesis for output SR */
- IF( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1566,7 +1569,7 @@ ivas_error init_decoder_ivas_fx(
/* TCX-LTP */
test();
- IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
+ IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
{
IF( ( st_fx->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) count_malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL )
{
@@ -1580,7 +1583,7 @@ ivas_error init_decoder_ivas_fx(
/* TCX core */
test();
- IF( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL )
{
@@ -1589,8 +1592,8 @@ ivas_error init_decoder_ivas_fx(
set32_fx( st_fx->hTcxDec->FBTCXdelayBuf_32, 0, 111 );
- st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA( st_fx->output_Fs, PH_ECU_MEM_NS );
- st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS );
+ st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA_fx2( st_fx->output_Fs, PH_ECU_MEM_NS );
+ st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA_fx2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS );
}
ELSE
{
@@ -1599,7 +1602,7 @@ ivas_error init_decoder_ivas_fx(
/* TCX config. data structure */
test();
- IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
+ IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
{
IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) count_malloc( sizeof( TCX_config ) ) ) == NULL )
{
@@ -1613,7 +1616,7 @@ ivas_error init_decoder_ivas_fx(
/* Tonal MDCT concealment data structure */
test();
- IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
+ IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
{
IF( ( st_fx->hTonalMDCTConc = (TonalMDCTConcealPtr) malloc( sizeof( TonalMDCTConceal_INSTANCE ) ) ) == NULL )
{
@@ -1630,7 +1633,7 @@ ivas_error init_decoder_ivas_fx(
*-----------------------------------------------------------------*/
test();
- IF( ( EQ_16( idchan, 0 ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
+ IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
{
IF( ( st_fx->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL )
{
@@ -1649,7 +1652,7 @@ ivas_error init_decoder_ivas_fx(
/*-----------------------------------------------------------------*
* Mode 2 initialization
*-----------------------------------------------------------------*/
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( ( st_fx->element_mode == EVS_MONO ) )
{
IF( ( st_fx->hPlcInfo = (T_PLCInfo_HANDLE) malloc( sizeof( T_PLCInfo ) ) ) == NULL )
{
@@ -1697,7 +1700,7 @@ ivas_error init_decoder_ivas_fx(
move16();
test();
- IF( ( EQ_16( idchan, 0 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
+ IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
{
resampleCldfb_ivas_fx( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) );
resampleCldfb_ivas_fx( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) );
@@ -1710,11 +1713,11 @@ ivas_error init_decoder_ivas_fx(
test();
test();
test();
- IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( idchan, 0 ) ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) )
+ IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) )
{
/* Create FD_CNG instance */
- IF( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ), IVAS_ERR_OK ) )
{
return error;
}
diff --git a/lib_dec/inov_dec.c b/lib_dec/inov_dec.c
index ad5df5d4abeb3af4c0e97ea076c7895c633c2a7d..03831b28c66bf4eb251d370c71328bafb4d3a8a3 100644
--- a/lib_dec/inov_dec.c
+++ b/lib_dec/inov_dec.c
@@ -38,7 +38,7 @@
#include "options.h"
#include "cnst.h"
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c
index 9531a05be38cfca22d145739e9d20900af856953..b917241253b12533b67ac9dd63d4aa4d43df4f4c 100644
--- a/lib_dec/inov_dec_fx.c
+++ b/lib_dec/inov_dec_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
#ifdef IVAS_FLOAT_FIXED
/*======================================================================*/
/* FUNCTION : inov_decode_fx() */
@@ -82,7 +81,7 @@ void inov_decode_fx(
test();
test();
test();
- IF( GE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr], 0 ) )
+ IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] >= 0 )
{
IF( EQ_16( L_subfr, 2 * L_SUBFR ) )
{
@@ -100,9 +99,9 @@ void inov_decode_fx(
dec_acelp_fast_fx( st_fx, nBits, code, L_subfr );
}
}
- ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 7 ) ) || ( EQ_16( st_fx->idchan, 0 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 3 ) ) )
+ ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 7 ) ) || ( ( st_fx->idchan == 0 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 3 ) ) )
{
- IF( EQ_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 0 ) )
+ IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 )
{
// dec_acelp_1t64(st_fx, code, L_SUBFR);
dec_acelp_1t64_fx( st_fx, code, L_SUBFR );
@@ -115,18 +114,20 @@ void inov_decode_fx(
}
ELSE
{
- wordcnt = ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) >> 4;
+ wordcnt = shr( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 4 );
move16();
- bitcnt = ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) & 15;
+ bitcnt = s_and( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 15 );
move16();
// PMT("CONDITION above is missing -> idchan")
FOR( i = 0; i < wordcnt; i++ )
{
indexing_indices[i] = get_next_indice( st_fx, 16 );
+ move16();
}
IF( bitcnt )
{
indexing_indices[i] = get_next_indice( st_fx, bitcnt );
+ move16();
}
config = PulseConfTable[st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]];
D_ACELP_indexing_fx( code, config, NB_TRACK_FCB_4T, indexing_indices, &st_fx->BER_detect );
@@ -271,7 +272,7 @@ void inov_decode_ivas_fx(
test();
test();
test();
- IF( GE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr], 0 ) )
+ IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] >= 0 )
{
IF( EQ_16( L_subfr, 2 * L_SUBFR ) )
{
@@ -290,7 +291,7 @@ void inov_decode_ivas_fx(
}
ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 7 ) ) || ( EQ_16( st_fx->idchan, 0 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 3 ) ) )
{
- IF( EQ_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 0 ) )
+ IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 )
{
// dec_acelp_1t64(st_fx, code, L_SUBFR);
dec_acelp_1t64_fx( st_fx, code, L_SUBFR );
diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c
index 6043e082c5fc0684741d634b6428ffbbc53aa08d..26aad59c178910ac2b7c85a4cf5935e7690e59ce 100644
--- a/lib_dec/ivas_agc_dec_fx.c
+++ b/lib_dec/ivas_agc_dec_fx.c
@@ -35,7 +35,7 @@
#ifdef IVAS_FLOAT_FIXED
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include
@@ -210,7 +210,7 @@ void ivas_agc_dec_process_fx(
// gainLast = 1.f / pState->gain_state[i].lastGain;
tmp = negate( sub( pState->gain_data[i].absGainExp, pState->agc_com.absEmin ) );
- IF( LT_16( tmp, 0 ) )
+ IF( tmp < 0 )
{
tmp_2 = MAX_16;
move16();
@@ -233,7 +233,7 @@ void ivas_agc_dec_process_fx(
move16();
gainLast = div_l( ONE_IN_Q29, pState->gain_state[i].lastGain_fx ); // Q13
- IF( NE_16( pState->gain_state[i].gainExpVal, 0 ) )
+ IF( pState->gain_state[i].gainExpVal != 0 )
{
FOR( idx = 0; idx < output_frame; idx++ )
{
@@ -242,8 +242,7 @@ void ivas_agc_dec_process_fx(
// gain = powf( pState->agc_com.winFunc[idx - pState->agc_com.in_delay], (float) ( -1 * pState->gain_state[i].gainExpVal ) ) * gainLast;
tmp = negate( pState->gain_state[i].gainExpVal );
- move16();
- IF( LT_16( tmp, 0 ) )
+ IF( tmp < 0 )
{
tmp_2 = MAX_16;
move16();
@@ -251,7 +250,7 @@ void ivas_agc_dec_process_fx(
{
tmp_2 = mult( pState->agc_com.winFunc_fx[idx - pState->agc_com.in_delay], tmp_2 );
}
- IF( LT_16( tmp_2, 0 ) )
+ IF( tmp_2 < 0 )
{
tmp_2 = div_l( ONE_IN_Q30, negate( tmp_2 ) ); // Q14
tmp_2 = negate( tmp_2 );
@@ -267,7 +266,7 @@ void ivas_agc_dec_process_fx(
move16();
FOR( j = 0; j < ( tmp ); j++ )
{
- tmp_2 = mult( pState->agc_com.winFunc_fx[idx - pState->agc_com.in_delay], tmp_2 );
+ tmp_2 = mult( pState->agc_com.winFunc_fx[sub( idx, pState->agc_com.in_delay )], tmp_2 );
}
tmp_2 = shr( tmp_2, 1 ); // Q14
}
@@ -284,7 +283,7 @@ void ivas_agc_dec_process_fx(
// pState->gain_state[i].lastGain *= powf( pState->agc_com.winFunc[offset - 1], (float) pState->gain_state[i].gainExpVal );
tmp = pState->gain_state[i].gainExpVal;
move16();
- IF( LT_16( tmp, 0 ) )
+ IF( tmp < 0 )
{
tmp_2 = MAX_16;
move16();
@@ -357,6 +356,7 @@ void ivas_agc_read_bits_fx(
ELSE
{
pState->gain_data[i].absGainExpCurr = (Word32) pState->agc_com.absEmin;
+ move32();
}
}
}
@@ -365,6 +365,7 @@ void ivas_agc_read_bits_fx(
FOR( i = 0; i < n_channels; i++ )
{
pState->gain_data[i].absGainExpCurr = (Word32) pState->agc_com.absEmin;
+ move32();
}
}
diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c
index 0f92acf2d646b5745ec95ebf22170e1dc2bffd0e..191bea1c1f3ea81f26707ade0e327fb09f84b58d 100644
--- a/lib_dec/ivas_binRenderer_internal.c
+++ b/lib_dec/ivas_binRenderer_internal.c
@@ -44,8 +44,7 @@
#include "ivas_rom_binauralRenderer.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_rom_com_fx.h"
#include "debug.h"
#endif
diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c
index 4ee545e4923c21dc398826f47350f8350a45520e..9d2aa6d7e64a0294a02fa4ac858b3d60a5a62580 100644
--- a/lib_dec/ivas_core_dec.c
+++ b/lib_dec/ivas_core_dec.c
@@ -42,8 +42,7 @@
#include "ivas_rom_com.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
@@ -53,7 +52,7 @@
* Principal IVAS core decoder routine, where number of core channels is 1 or 2
*-------------------------------------------------------------------*/
#ifdef IVAS_FLOAT_FIXED
-ivas_error ivas_core_dec(
+ivas_error ivas_core_dec_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
@@ -279,7 +278,12 @@ ivas_error ivas_core_dec(
test();
test();
test();
+ test();
+#ifdef NONBE_MDCT_ST_PLC_DO_NOT_SCALE_OLD_OUT_IF_FIRST_GOOD_IS_SID
+ IF( !st->bfi && st->prev_bfi && GT_32( st->total_brate, SID_2k40 ) && ( EQ_16( st->last_core_bfi, TCX_20_CORE ) || EQ_16( st->last_core_bfi, TCX_10_CORE ) ) && st->hTcxDec != NULL )
+#else
IF( !st->bfi && st->prev_bfi && ( EQ_16( st->last_core_bfi, TCX_20_CORE ) || EQ_16( st->last_core_bfi, TCX_10_CORE ) ) && st->hTcxDec != NULL )
+#endif
{
conceal_eof_gain32 = L_shl( L_deposit_l( st->hTcxDec->conceal_eof_gain ), 1 );
@@ -795,10 +799,18 @@ ivas_error ivas_core_dec(
sts[1]->hHQ_core->Q_old_wtda = sub( 15, sts[1]->hHQ_core->exp_old_out );
}
}
+
+ test();
test();
+#ifdef NONBE_MDCT_ST_DTX_SKIP_DEWHITENING_OF_NOISE_SHAPES_ON_SID_FRAMES
+ /* On first good active frame after frameloss undo the whitening of the bg noise shape */
+ IF( GT_32( sts[0]->core_brate, SID_2k40 ) && sts[0]->bfi == 0 && EQ_16( sts[0]->prev_bfi, 1 ) )
+ {
+#else
IF( sts[0]->bfi == 0 && EQ_16( sts[0]->prev_bfi, 1 ) )
{
/* On first good frame after frameloss undo the whitening of the bg noise shape */
+#endif
FOR( n = 0; n < n_channels; ++n )
{
IF( NE_16( sts[n]->last_core_bfi, ACELP_CORE ) )
@@ -1754,7 +1766,11 @@ ivas_error ivas_core_dec(
st->flagGuidedAcelp = 0;
}
+#ifdef NONBE_MDCT_ST_PLC_DO_NOT_SCALE_OLD_OUT_IF_FIRST_GOOD_IS_SID
+ if ( !st->bfi && st->prev_bfi && st->total_brate > SID_2k40 && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && st->hTcxDec != NULL )
+#else
if ( !st->bfi && st->prev_bfi && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && st->hTcxDec != NULL )
+#endif
{
v_multc( st->hHQ_core->old_out, st->hTcxDec->conceal_eof_gain_float * st->last_concealed_gain_syn_deemph_float, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX );
v_multc( st->hHQ_core->old_outLB, st->hTcxDec->conceal_eof_gain_float * st->last_concealed_gain_syn_deemph_float, st->hHQ_core->old_outLB, st->L_frame );
@@ -1968,9 +1984,16 @@ ivas_error ivas_core_dec(
updateBuffersForDmxMdctStereo( hCPE, output_frame, output, synth );
}
+#ifdef NONBE_MDCT_ST_DTX_SKIP_DEWHITENING_OF_NOISE_SHAPES_ON_SID_FRAMES
+
+ /* On first good active frame after frameloss undo the whitening of the bg noise shape */
+ if ( sts[0]->core_brate > SID_2k40 && sts[0]->bfi == 0 && sts[0]->prev_bfi == 1 )
+ {
+#else
if ( sts[0]->bfi == 0 && sts[0]->prev_bfi == 1 )
{
/* On first good frame after frameloss undo the whitening of the bg noise shape */
+#endif
for ( n = 0; n < n_channels; ++n )
{
if ( sts[n]->last_core_bfi != ACELP_CORE )
diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c
index ccb39cadf82506a8dc582450739dc44dadeb7c58..1ab53f387da149f684e6bddfbb513c066d77b17e 100644
--- a/lib_dec/ivas_corecoder_dec_reconfig.c
+++ b/lib_dec/ivas_corecoder_dec_reconfig.c
@@ -35,8 +35,7 @@
#include "ivas_prot.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif // IVAS_FLOAT_FIXED
#include "prot.h"
#include
@@ -978,7 +977,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx(
test();
IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && EQ_16( nchan_transport_old, 1 ) && EQ_16( numCldfbAnalyses_old, 2 ) && GT_16( st_ivas->nchan_transport, 1 ) )
{
- deleteCldfb_ivas( &( st_ivas->cldfbAnaDec[1] ) );
+ deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[1] ) );
numCldfbAnalyses_old = sub( numCldfbAnalyses_old, 1 );
}
/* resample CLDFB analysis instances */
@@ -996,7 +995,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx(
/* delete superfluous CLDFB synthesis instances */
FOR( i = numCldfbAnalyses; i < numCldfbAnalyses_old; i++ )
{
- deleteCldfb_ivas( &( st_ivas->cldfbAnaDec[i] ) );
+ deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ) );
}
}
ELSE IF( LT_16( numCldfbAnalyses_old, numCldfbAnalyses ) )
@@ -1016,7 +1015,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx(
/* delete superfluous CLDFB synthesis instances */
FOR( i = numCldfbSyntheses; i < numCldfbSyntheses_old; i++ )
{
- deleteCldfb_ivas( &( st_ivas->cldfbSynDec[i] ) );
+ deleteCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ) );
}
}
ELSE IF( LT_16( numCldfbSyntheses_old, numCldfbSyntheses ) )
diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c
index 4faab3eb7afb2021d00e358d8f3fcfe0aaf80e87..f0e4bfeceee5d2622d72aad2f5a6a3f2dcd5f41e 100644
--- a/lib_dec/ivas_cpe_dec.c
+++ b/lib_dec/ivas_cpe_dec.c
@@ -38,7 +38,7 @@
#include "rom_com.h"
#include "prot.h"
#include "ivas_prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
#include
diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c
index e0ac57446c165ddca7789cb16608827411dd9057..59969dba291362003faaafd6ae2ee18607d24279 100644
--- a/lib_dec/ivas_cpe_dec_fx.c
+++ b/lib_dec/ivas_cpe_dec_fx.c
@@ -40,14 +40,11 @@
#include "prot.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
#include
-/* NOTE: Temporary macro for computation happening in floating point. This macro and code active under this is to be removed once the intermediate conversions to float are not required */
-#define IVAS_FLOAT_FIXED_TO_BE_REMOVED
/*--------------------------------------------------------------------------*
* Local function prototypes
@@ -586,7 +583,7 @@ ivas_error ivas_cpe_dec_fx(
test();
IF( NE_16( hCPE->element_mode, IVAS_CPE_DFT ) || ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) )
{
- IF( NE_32( ( error = ivas_core_dec( st_ivas, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB_fx, NULL, st_ivas->sba_dirac_stereo_flag ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_core_dec_fx( st_ivas, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB_fx, NULL, st_ivas->sba_dirac_stereo_flag ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -611,7 +608,7 @@ ivas_error ivas_cpe_dec_fx(
set32_fx( DFT_fx[1], 0, STEREO_DFT_BUF_MAX );
/* core decoder */
- IF( NE_32( ( error = ivas_core_dec( NULL, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB_fx, DFT_fx, 0 ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_core_dec_fx( NULL, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB_fx, DFT_fx, 0 ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1322,14 +1319,12 @@ void destroy_cpe_dec(
{
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
-#ifdef IVAS_FLOAT_FIXED
free( hCPE->input_mem_LB_fx[n] );
hCPE->input_mem_LB_fx[n] = NULL;
free( hCPE->input_mem_fx[n] );
hCPE->input_mem_fx[n] = NULL;
free( hCPE->output_mem_fx[n] );
hCPE->output_mem_fx[n] = NULL;
-#endif
IF( hCPE->prev_synth_chs_fx[n] != NULL )
{
@@ -1337,10 +1332,8 @@ void destroy_cpe_dec(
hCPE->prev_synth_chs_fx[n] = NULL;
}
}
-#ifdef IVAS_FLOAT_FIXED
free( hCPE->input_mem_BPF_fx[0] );
hCPE->input_mem_BPF_fx[0] = NULL;
-#endif
}
IF( hCPE->hStereoCng != NULL )
diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c
index c5c65c8d17e30f418a90916916664cdf47674776..2d84e7604b3c3039f867316da6c2aa557b3cbe2a 100644
--- a/lib_dec/ivas_dirac_dec.c
+++ b/lib_dec/ivas_dirac_dec.c
@@ -36,8 +36,6 @@
#include
#include "cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
#include "ivas_cnst.h"
@@ -46,8 +44,7 @@
#include "ivas_rom_rend.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "ivas_rom_com_fx.h"
#include "ivas_prot_fx.h"
#endif
@@ -107,7 +104,7 @@ static ivas_error ivas_dirac_dec_config_internal_fx(
* DirAC main configuration
*-----------------------------------------------------------------*/
- IF( NE_32( ( error = ivas_dirac_config( (void *) st_ivas, DEC ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_dirac_config_fx( (void *) st_ivas, DEC ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1005,7 +1002,7 @@ static ivas_error ivas_dirac_rend_config_fx(
{
ivas_dirac_free_mem_fx( &( hDirACRend->stack_mem ) );
}
- IF( NE_32( ( error = ivas_dirac_alloc_mem( hDirACRend, st_ivas->renderer_type, hSpatParamRendCom->num_freq_bands, &( hDirACRend->stack_mem ), hodirac_flag ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_dirac_alloc_mem_fx( hDirACRend, st_ivas->renderer_type, hSpatParamRendCom->num_freq_bands, &( hDirACRend->stack_mem ), hodirac_flag ) ), IVAS_ERR_OK ) )
{
return error;
}
diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c
index c11dda7ccb99db4414f70fc1982705e6e8030985..10660be2da70d3f5c6291bb9fc9bc4cb8b4c20ad 100644
--- a/lib_dec/ivas_dirac_output_synthesis_cov.c
+++ b/lib_dec/ivas_dirac_output_synthesis_cov.c
@@ -49,8 +49,7 @@
#include "wmc_auto.h"
#include "rom_dec.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
diff --git a/lib_dec/ivas_entropy_decoder.c b/lib_dec/ivas_entropy_decoder.c
index af8e4082afc9aefcddf041985670c7edec3c551b..9c769bf5719c8fe70e6d208cd6423d123b3f92eb 100644
--- a/lib_dec/ivas_entropy_decoder.c
+++ b/lib_dec/ivas_entropy_decoder.c
@@ -66,14 +66,16 @@ static void ivas_arith_decode_array(
Word16 *pCum_freq = NULL;
Tastat as;
Word16 extra_bits_read = 0;
+ move16();
- IF( GT_16( in_len, 0 ) && GT_16( pArith->range, 1 ) )
+ test();
+ IF( ( in_len > 0 ) && GT_16( pArith->range, 1 ) )
{
- IF( GT_16( pArith->dyn_model_bits, 0 ) )
+ IF( pArith->dyn_model_bits > 0 )
{
model_idx = get_next_indice( st0, pArith->dyn_model_bits );
- IF( GT_16( model_idx, 0 ) )
+ IF( model_idx > 0 )
{
pCum_freq = pArith->cum_freq[model_idx];
}
@@ -94,15 +96,18 @@ static void ivas_arith_decode_array(
ind = ivas_ari_decode_14bits_bit_ext_1_lfe( st0, &as, (const UWord16 *) pCum_freq, &extra_bits_read );
pSymbols[i] = pArith->vals[ind];
+ move16();
}
ivas_ari_done_decoding_14bits_ext_1_lfe( st0, extra_bits_read );
}
ELSE
{
+
FOR( i = 0; i < in_len; i++ )
{
pSymbols[i] = 0;
+ move16();
}
}
@@ -126,8 +131,9 @@ static void ivas_arithCoder_decode_array_diff(
{
Word16 n;
Word16 offset = pArith->vals[0];
+ move16();
- IF( GT_16( length, 0 ) )
+ IF( length > 0 )
{
ivas_arith_decode_array( pArith_diff, st0, length, pOutput_arr );
}
@@ -135,6 +141,7 @@ static void ivas_arithCoder_decode_array_diff(
FOR( n = 0; n < length; n++ )
{
pOutput_arr[n] = add( sub( pSymbol_old[n], offset ), pOutput_arr[n] );
+ move16();
}
#ifndef IVAS_FLOAT_FIXED
@@ -146,6 +153,7 @@ static void ivas_arithCoder_decode_array_diff(
FOR( n = 0; n < length; n++ )
{
pOutput_arr[n] = pArith->vals[pOutput_arr[n]];
+ move16();
}
return;
@@ -166,19 +174,25 @@ static Word16 ivas_huffman_code_bits_present(
{
Word16 index = add( len, 1 );
Word16 i = 0;
+ move16();
Word16 ind_t, code_t, bits_t;
WHILE( LT_16( i, len ) )
{
ind_t = codebook[0];
+ move16();
bits_t = codebook[1];
+ move16();
code_t = codebook[2];
+ move16();
+
+ test();
IF( ( EQ_16( code, code_t ) ) && ( EQ_16( bits, bits_t ) ) )
{
return ind_t;
}
codebook = codebook + 3;
- i++;
+ i = add( i, 1 );
}
return index;
@@ -200,6 +214,7 @@ ivas_error ivas_huffman_decode(
code = get_next_indice( st0, huff_cfg->min_len );
num_bits_read = huff_cfg->min_len;
+ move16();
ind = ivas_huffman_code_bits_present( huff_cfg->codebook, code, num_bits_read, huff_cfg->sym_len );
@@ -207,7 +222,7 @@ ivas_error ivas_huffman_decode(
{
bit = get_next_indice( st0, 1 );
num_bits_read = add( num_bits_read, 1 );
- code = code << 1 | bit;
+ code = s_or( shl( code, 1 ), bit );
ind = ivas_huffman_code_bits_present( huff_cfg->codebook, code, num_bits_read, huff_cfg->sym_len );
IF( GT_16( num_bits_read, huff_cfg->max_len ) )
{
@@ -215,6 +230,7 @@ ivas_error ivas_huffman_decode(
}
}
*dec_out = ind;
+ move16();
return IVAS_ERR_OK;
}
@@ -234,11 +250,12 @@ static void arith_decode_cell_array(
Word16 *pSymbol )
{
Word16 total_symbol_len = 0;
+ move16();
Word16 i;
FOR( i = 0; i < num_bands; i++ )
{
- total_symbol_len += ( pCell_dims[i].dim1 * pCell_dims[i].dim2 );
+ total_symbol_len = add( total_symbol_len, imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) );
}
assert( LE_16( total_symbol_len, IVAS_MAX_INPUT_LEN ) );
@@ -265,11 +282,12 @@ static void arith_decode_cell_array_diff(
Word16 *pSymbol_old )
{
Word16 total_symbol_len = 0;
+ move16();
Word16 i;
FOR( i = 0; i < num_bands; i++ )
{
- total_symbol_len += ( pCell_dims[i].dim1 * pCell_dims[i].dim2 );
+ total_symbol_len = add( total_symbol_len, imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 ) );
}
assert( LE_16( total_symbol_len, IVAS_MAX_INPUT_LEN ) );
@@ -300,16 +318,19 @@ void ivas_arith_decode_cmplx_cell_array(
Word16 cell_arr_no_diff[IVAS_MAX_INPUT_LEN];
Word16 cell_arr_diff_out[IVAS_MAX_INPUT_LEN];
Word16 idx2 = 0;
+ move16();
FOR( i = 0; i < num_bands; i++ )
{
- IF( NE_16( pDo_diff[i], 0 ) )
+ IF( pDo_diff[i] != 0 )
{
any_diff = 1;
+ move16();
}
ELSE
{
all_diff = 0;
+ move16();
}
}
@@ -324,35 +345,49 @@ void ivas_arith_decode_cmplx_cell_array(
ivas_cell_dim_t cell_dims[IVAS_MAX_NUM_BANDS];
ivas_cell_dim_t cell_dims_diff[IVAS_MAX_NUM_BANDS];
Word16 idx1 = 0, idx = 0;
+ move16();
+ move16();
FOR( i = 0; i < num_bands; i++ )
{
- len = pCell_dims[i].dim1 * pCell_dims[i].dim2;
- IF( NE_16( pDo_diff[i], 0 ) )
+ len = imult1616( pCell_dims[i].dim1, pCell_dims[i].dim2 );
+ IF( pDo_diff[i] != 0 )
{
cell_dims[i].dim1 = 0;
+ move16();
cell_dims[i].dim2 = 0;
+ move16();
FOR( j = 0; j < len; j++ )
{
- cell_arr_diff[idx++] = pSymbol_re_old[idx1++];
+ cell_arr_diff[idx] = pSymbol_re_old[idx1];
+ move16();
+ idx = add( idx, 1 );
+ idx1 = add( idx1, 1 );
}
cell_dims_diff[i].dim1 = pCell_dims[i].dim1;
+ move16();
cell_dims_diff[i].dim2 = pCell_dims[i].dim2;
+ move16();
}
ELSE
{
FOR( j = 0; j < len; j++ )
{
cell_arr_diff[idx] = 0;
- idx1++;
+ move16();
+ idx1 = add( idx1, 1 );
}
cell_dims[i].dim1 = pCell_dims[i].dim1;
+ move16();
cell_dims[i].dim2 = pCell_dims[i].dim2;
+ move16();
cell_dims_diff[i].dim1 = 0;
+ move16();
cell_dims_diff[i].dim2 = 0;
+ move16();
}
}
@@ -361,21 +396,30 @@ void ivas_arith_decode_cmplx_cell_array(
arith_decode_cell_array_diff( cell_dims_diff, st0, num_bands, pArith_re, pArith_re_diff, cell_arr_diff_out, cell_arr_diff );
idx = 0;
+ move16();
idx1 = 0;
+ move16();
+
FOR( i = 0; i < num_bands; i++ )
{
- IF( NE_16( pDo_diff[i], 0 ) )
+ IF( pDo_diff[i] != 0 )
{
- FOR( j = 0; j < cell_dims_diff[i].dim1 * cell_dims_diff[i].dim2; j++ )
+ FOR( j = 0; j < imult1616( cell_dims_diff[i].dim1, cell_dims_diff[i].dim2 ); j++ )
{
- pSymbol_re[idx++] = cell_arr_diff_out[idx2++];
+ pSymbol_re[idx] = cell_arr_diff_out[idx2];
+ move16();
+ idx = add( idx, 1 );
+ idx2 = add( idx2, 1 );
}
}
ELSE
{
- FOR( j = 0; j < cell_dims[i].dim1 * cell_dims[i].dim2; j++ )
+ FOR( j = 0; j < imult1616( cell_dims[i].dim1, cell_dims[i].dim2 ); j++ )
{
- pSymbol_re[idx++] = cell_arr_no_diff[idx1++];
+ pSymbol_re[idx] = cell_arr_no_diff[idx1];
+ move16();
+ idx = add( idx, 1 );
+ idx1 = add( idx1, 1 );
}
}
}
diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c
index 214c004fae34f64d1d853761bb31e26b678c28fa..0640c495f7720ab1446842194521f03a0d097a7b 100644
--- a/lib_dec/ivas_init_dec.c
+++ b/lib_dec/ivas_init_dec.c
@@ -42,8 +42,7 @@
#include
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#define IVAS_FLOAT_FIXED_TO_BE_REMOVED
#endif // IVAS_FLOAT_FIXED
@@ -83,11 +82,14 @@ ivas_error ivas_dec_setup(
ivas_error error;
error = IVAS_ERR_OK;
-
+ move32();
num_bits_read = 0;
+ move16();
element_mode_flag = 0;
+ move16();
ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
+ move16();
/*-------------------------------------------------------------------*
* Read IVAS format
@@ -97,12 +99,13 @@ ivas_error ivas_dec_setup(
Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
Word16 num_src = 0;
+ move16();
/*-------------------------------------------------------------------*
* Read other signling (ISM/MC mode, number of channels, etc.)
*-------------------------------------------------------------------*/
- IF( EQ_16( is_DTXrate( ivas_total_brate ), 0 ) )
+ IF( is_DTXrate( ivas_total_brate ) == 0 )
{
/*-------------------------------------------------------------------*
* Read IVAS format related signaling:
@@ -112,45 +115,55 @@ ivas_error ivas_dec_setup(
* - in MC : read LS setup
*-------------------------------------------------------------------*/
- IF( st_ivas->ivas_format == STEREO_FORMAT )
+ IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
{
element_mode_flag = 1;
+ move16();
}
- ELSE IF( st_ivas->ivas_format == ISM_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
{
/* read the number of objects */
st_ivas->nchan_transport = 1;
+ move16();
nchan_ism = 1;
- k = (Word16) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 );
+ move16();
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ k = extract_l( L_sub( res_dec, 1 ) );
+
+ test();
WHILE( st_ivas->bit_stream[k] && LT_16( nchan_ism, MAX_NUM_OBJECTS ) )
{
- nchan_ism++;
- k--;
+ nchan_ism = add( nchan_ism, 1 );
+ k = sub( k, 1 );
}
st_ivas->nchan_ism = nchan_ism;
+ move16();
- IF( ( error = ivas_ism_dec_config_fx( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ism_dec_config_fx( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- ELSE IF( st_ivas->ivas_format == SBA_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
{
/* read Ambisonic (SBA) planar flag */
st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read];
-
+ move16();
num_bits_read = add( num_bits_read, SBA_PLANAR_BITS );
/* read Ambisonic (SBA) order */
st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1];
- st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read];
-
-
+ move16();
+ st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) );
+ move16();
num_bits_read = add( num_bits_read, SBA_ORDER_BITS );
- IF( GT_16( st_ivas->ini_frame, 0 ) && NE_32( ivas_total_brate, st_ivas->last_active_ivas_total_brate ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) )
+ test();
+ test();
+ IF( st_ivas->ini_frame > 0 && NE_32( ivas_total_brate, st_ivas->last_active_ivas_total_brate ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) )
{
- IF( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -159,36 +172,48 @@ ivas_error ivas_dec_setup(
{
/* set Ambisonic (SBA) order used for analysis and coding */
st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order );
+ move16();
ivas_sba_config_fx( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init );
}
}
- ELSE IF( st_ivas->ivas_format == MASA_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
{
/* read number of MASA transport channels */
- IF( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 1] )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ IF( st_ivas->bit_stream[res_dec - 1] )
{
st_ivas->nchan_transport = 2;
+ move16();
element_mode_flag = 1;
+ move16();
}
ELSE
{
st_ivas->nchan_transport = 1;
+ move16();
}
- IF( GT_16( st_ivas->ini_frame, 0 ) )
+ IF( st_ivas->ini_frame > 0 )
{
/* reconfigure in case a change of operation mode is detected */
- IF( ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) || EQ_16( st_ivas->ini_active_frame, 0 ) )
+ test();
+ test();
+ IF( ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) || ( st_ivas->ini_active_frame == 0 ) )
{
- IF( st_ivas->last_ivas_format == MASA_FORMAT )
+ IF( EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) )
{
- IF( EQ_16( st_ivas->ini_active_frame, 0 ) && NE_32( ivas_total_brate, FRAME_NO_DATA ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && EQ_16( st_ivas->nCPE, 1 ) )
+ test();
+ test();
+ test();
+ IF( ( st_ivas->ini_active_frame == 0 ) && NE_32( ivas_total_brate, FRAME_NO_DATA ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && EQ_16( st_ivas->nCPE, 1 ) )
{
st_ivas->hCPE[0]->nchan_out = 1;
+ move16();
}
ELSE
{
- IF( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -196,7 +221,7 @@ ivas_error ivas_dec_setup(
}
ELSE
{
- IF( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -204,52 +229,66 @@ ivas_error ivas_dec_setup(
}
}
}
- ELSE IF( st_ivas->ivas_format == MASA_ISM_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */
-
+ move16();
/* for the DISC mode the number of objects are written at the end of the bitstream, in the MASA metadata */
- st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1;
- st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, st_ivas->nchan_ism );
- move32();
- IF( GT_16( st_ivas->ini_frame, 0 ) )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ st_ivas->nchan_ism = add( add( shl( st_ivas->bit_stream[L_sub( res_dec, 1 )], 1 ), st_ivas->bit_stream[L_sub( res_dec, 2 )] ), 1 );
+ move16();
+ st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, st_ivas->nchan_ism );
+ move16();
+ IF( st_ivas->ini_frame > 0 )
{
/* reconfigure in case a change of operation mode is detected */
- IF( ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) || EQ_16( st_ivas->ini_active_frame, 0 ) )
+ test();
+ test();
+ IF( ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) || ( st_ivas->ini_active_frame == 0 ) )
{
- IF( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ), IVAS_ERR_OK ) )
{
return error;
}
}
}
}
- ELSE IF( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
/* the number of objects is written at the end of the bitstream, in the SBA metadata */
- st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1;
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ st_ivas->nchan_ism = add( add( shl( st_ivas->bit_stream[L_sub( res_dec, 1 )], 1 ), st_ivas->bit_stream[L_sub( res_dec, 2 )] ), 1 );
+ move16();
+ test();
IF( LT_32( ivas_total_brate, IVAS_24k4 ) || GE_32( ivas_total_brate, IVAS_256k ) )
{
/* read Ambisonic (SBA) planar flag */
st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read];
+ move16();
num_bits_read = add( num_bits_read, SBA_PLANAR_BITS );
}
st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1];
- st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read];
+ move16();
+ st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) );
+ move16();
num_bits_read = add( num_bits_read, SBA_ORDER_BITS );
/* read Ambisonic (SBA) order */
- IF( LT_32( ivas_total_brate, IVAS_256k ) )
+ if ( LT_32( ivas_total_brate, IVAS_256k ) )
{
st_ivas->sba_order = 3;
+ move16();
}
- IF( GT_16( st_ivas->ini_frame, 0 ) && NE_32( ivas_total_brate, st_ivas->last_active_ivas_total_brate ) )
+ test();
+ IF( st_ivas->ini_frame > 0 && NE_32( ivas_total_brate, st_ivas->last_active_ivas_total_brate ) )
{
- IF( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -258,40 +297,46 @@ ivas_error ivas_dec_setup(
{
/* set Ambisonic (SBA) order used for analysis and coding */
st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order );
+ move16();
ivas_sba_config_fx( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init );
/*correct number of CPEs for discrete ISM coding*/
- IF( GT_16( st_ivas->ini_frame, 0 ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ test();
+ IF( st_ivas->ini_frame > 0 && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
- st_ivas->nCPE += add( st_ivas->nchan_ism, 1 ) >> 1;
+ st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) );
+ move16();
}
}
IF( GE_32( ivas_total_brate, IVAS_256k ) )
{
st_ivas->ism_mode = ISM_SBA_MODE_DISC;
+ move32();
}
ELSE
{
st_ivas->ism_mode = ISM_MODE_NONE;
+ move32();
}
}
- ELSE IF( st_ivas->ivas_format == MC_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
{
/* read MC configuration */
idx = 0;
+ move16();
FOR( k = 0; k < MC_LS_SETUP_BITS; k++ )
{
- IF( st_ivas->bit_stream[num_bits_read + k] )
+ IF( st_ivas->bit_stream[add( num_bits_read, k )] )
{
- idx += 1 << ( MC_LS_SETUP_BITS - 1 - k );
+ idx = add( idx, shl( 1, sub( ( MC_LS_SETUP_BITS - 1 ), k ) ) );
}
}
num_bits_read = add( num_bits_read, MC_LS_SETUP_BITS );
/* select MC format mode; reconfigure the MC format decoder */
- IF( ( error = ivas_mc_dec_config_fx( st_ivas, idx, nSamplesRendered, data ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_mc_dec_config_fx( st_ivas, idx, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -301,7 +346,7 @@ ivas_error ivas_dec_setup(
* Read element mode
*-------------------------------------------------------------------*/
- IF( EQ_16( st_ivas->ini_frame, 0 ) && element_mode_flag )
+ IF( st_ivas->ini_frame == 0 && element_mode_flag )
{
/* read stereo technology info */
IF( LT_32( ivas_total_brate, MIN_BRATE_MDCT_STEREO ) )
@@ -310,15 +355,18 @@ ivas_error ivas_dec_setup(
IF( st_ivas->bit_stream[num_bits_read] )
{
st_ivas->element_mode_init = add( 1, IVAS_CPE_DFT );
+ move16();
}
ELSE
{
st_ivas->element_mode_init = add( 0, IVAS_CPE_DFT );
+ move16();
}
}
ELSE
{
st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
}
}
}
@@ -328,101 +376,139 @@ ivas_error ivas_dec_setup(
{
case SID_DFT_STEREO:
st_ivas->element_mode_init = IVAS_CPE_DFT;
+ move16();
BREAK;
case SID_MDCT_STEREO:
st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
BREAK;
case SID_ISM:
st_ivas->element_mode_init = IVAS_SCE;
+ move16();
BREAK;
case SID_MASA_1TC:
st_ivas->element_mode_init = IVAS_SCE;
+ move16();
st_ivas->nchan_transport = 1;
+ move16();
BREAK;
- case SID_MASA_2TC:
- IF( st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1 - SID_FORMAT_NBITS] == 1 )
+ case SID_MASA_2TC:; // empyt statement for declaration
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ IF( EQ_16( st_ivas->bit_stream[L_sub( L_sub( res_dec, 1 ), SID_FORMAT_NBITS )], 1 ) )
{
st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
}
ELSE
{
st_ivas->element_mode_init = IVAS_CPE_DFT;
+ move16();
}
st_ivas->nchan_transport = 2;
+ move16();
BREAK;
case SID_SBA_1TC:
st_ivas->element_mode_init = IVAS_SCE;
+ move16();
BREAK;
case SID_SBA_2TC:
st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
BREAK;
}
- IF( GT_16( st_ivas->ini_frame, 0 ) && st_ivas->ivas_format == SBA_FORMAT )
+ test();
+ IF( st_ivas->ini_frame > 0 && EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
{
Word16 nchan_transport_old, nchan_transport;
nchan_transport_old = st_ivas->nchan_transport;
- nchan_transport = ( EQ_16( st_ivas->sid_format, SID_SBA_2TC ) ) ? 2 : 1;
+ move16();
+ IF( ( EQ_16( st_ivas->sid_format, SID_SBA_2TC ) ) )
+ {
+ nchan_transport = 2;
+ }
+ ELSE
+ {
+ nchan_transport = 1;
+ }
+ move16();
- IF( ( nchan_transport_old != nchan_transport ) )
+ IF( NE_16( nchan_transport_old, nchan_transport ) )
{
/*Setting the default bitrate for the reconfig function*/
IF( EQ_16( st_ivas->sid_format, SID_SBA_2TC ) )
{
st_ivas->hDecoderConfig->ivas_total_brate = IVAS_48k;
+ move16();
}
ELSE
{
st_ivas->hDecoderConfig->ivas_total_brate = IVAS_24k4;
+ move16();
}
- IF( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
{
return error;
}
st_ivas->last_active_ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
+ move32();
st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
+ move32();
}
}
- IF( st_ivas->ivas_format == ISM_FORMAT )
+ IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
{
ISM_MODE last_ism_mode = st_ivas->ism_mode;
-
+ move32();
/* read the number of objects */
st_ivas->nchan_transport = 1;
+ move16();
nchan_ism = 1;
- k = (Word16) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS;
+ move16();
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ k = extract_l( L_sub( L_sub( res_dec, 1 ), SID_FORMAT_NBITS ) );
+ move16();
+ test();
WHILE( st_ivas->bit_stream[k] && LT_16( nchan_ism, MAX_NUM_OBJECTS ) )
{
- nchan_ism++;
- k--;
+ nchan_ism = add( nchan_ism, 1 );
+ k = sub( k, 1 );
}
- k--;
+ k = sub( k, 1 );
- if ( st_ivas->ini_frame > 0 && nchan_ism != st_ivas->nchan_ism )
+ test();
+ if ( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong number of objects signalled!" );
}
st_ivas->nchan_ism = nchan_ism;
-
+ move16();
/* read ism_mode */
st_ivas->ism_mode = ISM_MODE_DISC;
- IF( GT_16( nchan_ism, 2 ) )
+ move32();
+ if ( GT_16( nchan_ism, 2 ) )
{
k -= nchan_ism; /* SID metadata flags */
+ move16();
idx = st_ivas->bit_stream[k];
+ move16();
st_ivas->ism_mode = (ISM_MODE) add( idx, 1 );
+ move32();
}
IF( st_ivas->ini_frame == 0 )
{
last_ism_mode = st_ivas->ism_mode;
+ move32();
}
- IF( ( error = ivas_ism_dec_config_fx( st_ivas, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ism_dec_config_fx( st_ivas, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -434,14 +520,14 @@ ivas_error ivas_dec_setup(
* and number of transport channels
*-------------------------------------------------------------------*/
- IF( EQ_16( st_ivas->ini_frame, 0 ) && st_ivas->ivas_format != UNDEFINED_FORMAT )
+ IF( st_ivas->ini_frame == 0 && st_ivas->ivas_format != UNDEFINED_FORMAT )
{
- IF( ( error = doSanityChecks_IVAS( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = doSanityChecks_IVAS( st_ivas ) ), IVAS_ERR_OK ) )
{
return IVAS_ERROR( error, "Sanity checks failed" );
}
- IF( ( error = ivas_init_decoder_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_init_decoder_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -457,11 +543,21 @@ ivas_error ivas_dec_setup(
reset_elements( st_ivas );
/* update bitstream buffer pointer -> take into account already read bits */
- IF( ( GT_16( st_ivas->nSCE, 0 ) ) || ( GT_16( st_ivas->nCPE, 0 ) ) )
+ test();
+ IF( ( st_ivas->nSCE > 0 ) || ( st_ivas->nCPE > 0 ) )
{
- st = GT_16( st_ivas->nSCE, 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0];
+ IF( st_ivas->nSCE > 0 )
+ {
+ st = st_ivas->hSCE[0]->hCoreCoder[0];
+ }
+ ELSE
+ {
+ st = st_ivas->hCPE[0]->hCoreCoder[0];
+ }
st->next_bit_pos = num_bits_read;
+ move16();
st->total_brate = ACELP_8k00; /* only temporary initialization - this is needed for get_next_indice() in the frame following NO_DATA frame */
+ move32();
}
return error;
@@ -865,7 +961,6 @@ ivas_error ivas_dec_setup(
#endif
-// ivas_param_ism_dec
/*-------------------------------------------------------------------*
* ivas_read_format()
*
@@ -883,129 +978,162 @@ static ivas_error ivas_read_format(
ivas_error error;
error = IVAS_ERR_OK;
+ move32();
ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
move32();
*num_bits_read = 0;
move16();
-
+ test();
IF( !st_ivas->bfi && is_DTXrate( ivas_total_brate ) == 0 )
{
/* read IVAS format */
k = 0;
- IF( st_ivas->bit_stream[*num_bits_read] )
+ move16();
+ if ( st_ivas->bit_stream[*num_bits_read] )
{
k = 1;
+ move16();
}
- k <<= 1;
- ( *num_bits_read )++;
-
- IF( st_ivas->bit_stream[*num_bits_read] )
+ k = shl( k, 1 );
+ ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
+ move16();
+ if ( st_ivas->bit_stream[*num_bits_read] )
{
- k += 1;
+ k = add( k, 1 );
}
- ( *num_bits_read )++;
-
+ ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
+ move16();
SWITCH( k )
{
case 0:
st_ivas->ivas_format = STEREO_FORMAT;
+ move32();
BREAK;
case 1:
st_ivas->ivas_format = MC_FORMAT;
+ move32();
BREAK;
case 2:
st_ivas->ivas_format = ISM_FORMAT;
+ move32();
- IF( ivas_total_brate >= IVAS_24k4 )
+ IF( GE_32( ivas_total_brate, IVAS_24k4 ) )
{
IF( st_ivas->bit_stream[*num_bits_read] )
{
- ( *num_bits_read )++;
+ ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
+ move16();
IF( st_ivas->bit_stream[*num_bits_read] )
{
st_ivas->ivas_format = SBA_ISM_FORMAT;
+ move32();
}
ELSE
{
st_ivas->ivas_format = MASA_ISM_FORMAT;
+ move32();
}
}
- ( *num_bits_read )++;
+ ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
+ move16();
}
BREAK;
case 3:
IF( st_ivas->bit_stream[*num_bits_read] )
{
st_ivas->ivas_format = MASA_FORMAT;
+ move32();
}
ELSE
{
st_ivas->ivas_format = SBA_FORMAT;
+ move32();
/* read Ambisonic (SBA) planar flag */
- st_ivas->sba_planar = st_ivas->bit_stream[( *num_bits_read ) + 1];
+ st_ivas->sba_planar = st_ivas->bit_stream[add( ( *num_bits_read ), 1 )];
+ move16();
/* read Ambisonic (SBA) order */
- st_ivas->sba_order = st_ivas->bit_stream[( *num_bits_read ) + 2 + SBA_PLANAR_BITS];
- st_ivas->sba_order += 2 * st_ivas->bit_stream[( *num_bits_read ) + 1 + SBA_PLANAR_BITS];
- IF( st_ivas->sba_order == 0 )
+ st_ivas->sba_order = st_ivas->bit_stream[add( add( ( *num_bits_read ), 2 ), SBA_PLANAR_BITS )];
+ move16();
+ st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[add( add( ( *num_bits_read ), 1 ), SBA_PLANAR_BITS )], 1 ) );
+ move16();
+ if ( st_ivas->sba_order == 0 )
{
st_ivas->ivas_format = SBA_ISM_FORMAT;
+ move32();
}
}
- ( *num_bits_read )++;
+ ( *num_bits_read ) = add( ( *num_bits_read ), 1 );
+ move16();
BREAK;
}
}
- ELSE IF( EQ_16( st_ivas->bfi, 0 ) && ivas_total_brate == IVAS_SID_5k2 )
+ ELSE IF( ( st_ivas->bfi == 0 ) && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
{
/* read IVAS format in SID frame */
idx = 0;
+ move16();
FOR( k = 0; k < SID_FORMAT_NBITS; k++ )
{
- idx += st_ivas->bit_stream[k] << ( SID_FORMAT_NBITS - 1 - k );
+ idx = add( idx, shl( st_ivas->bit_stream[k], sub( sub( SID_FORMAT_NBITS, 1 ), k ) ) );
}
( *num_bits_read ) = add( *num_bits_read, SID_FORMAT_NBITS );
+ move16();
st_ivas->sid_format = idx;
+ move16();
SWITCH( idx )
{
case SID_DFT_STEREO:
case SID_MDCT_STEREO:
st_ivas->ivas_format = STEREO_FORMAT;
+ move32();
BREAK;
case SID_ISM:
st_ivas->ivas_format = ISM_FORMAT;
-
+ move32();
BREAK;
case SID_MULTICHANNEL:
st_ivas->ivas_format = MC_FORMAT;
+ move32();
BREAK;
case SID_SBA_1TC:
st_ivas->ivas_format = SBA_FORMAT;
+ move32();
st_ivas->element_mode_init = IVAS_SCE;
+ move16();
BREAK;
case SID_SBA_2TC:
st_ivas->ivas_format = SBA_FORMAT;
+ move32();
st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
BREAK;
case SID_MASA_1TC:
st_ivas->ivas_format = MASA_FORMAT;
+ move32();
st_ivas->element_mode_init = IVAS_SCE;
+ move16();
BREAK;
case SID_MASA_2TC:
st_ivas->ivas_format = MASA_FORMAT;
- IF( st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] == 1 )
+ move32();
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ IF( EQ_32( st_ivas->bit_stream[res_dec - 1], 1 ) )
{
st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
}
ELSE
{
st_ivas->element_mode_init = IVAS_CPE_DFT;
+ move16();
}
BREAK;
default:
@@ -1013,17 +1141,19 @@ static ivas_error ivas_read_format(
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Invalid value %c found in SID format field.", st_ivas->sid_format );
}
- IF( st_ivas->ivas_format == SBA_FORMAT )
+ IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
{
- IF( st_ivas->sba_analysis_order == 0 )
+ if ( st_ivas->sba_analysis_order == 0 )
{
st_ivas->sba_analysis_order = SBA_FOA_ORDER;
+ move16();
}
}
/* reset bitstream handle to avoid BER detection after reading the 2400 kbps for ch0 */
- st_ivas->bit_stream += ( *num_bits_read );
+ st_ivas->bit_stream = st_ivas->bit_stream + ( *num_bits_read );
( *num_bits_read ) = 0;
+ move16();
}
ELSE
{
@@ -1211,27 +1341,30 @@ Word16 getNumChanSynthesis(
Word16 n;
n = add( st_ivas->nSCE, imult1616( CPE_CHANNELS, st_ivas->nCPE ) );
-
+ test();
+ test();
IF( st_ivas->sba_dirac_stereo_flag )
{
n = CPE_CHANNELS;
+ move16();
}
- ELSE IF( ( st_ivas->hMCT != NULL || EQ_16( st_ivas->ivas_format, SBA_FORMAT ) ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ ELSE IF( ( st_ivas->hMCT != NULL || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) && NE_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
n = st_ivas->nchan_transport;
+ move16();
}
- ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
- IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
n = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
}
ELSE
{
n = st_ivas->nchan_transport;
+ move16();
}
}
- move16();
return n;
}
@@ -1336,7 +1469,7 @@ ivas_error ivas_init_decoder_front(
ivas_error error;
error = IVAS_ERR_OK;
-
+ move32();
/*-----------------------------------------------------------------*
* Resets
*-----------------------------------------------------------------*/
@@ -1347,10 +1480,10 @@ ivas_error ivas_init_decoder_front(
move16();
st_ivas->nchan_transport = -1;
move16();
-
st_ivas->ism_mode = ISM_MODE_NONE;
+ move32();
st_ivas->mc_mode = MC_MODE_NONE;
-
+ move32();
st_ivas->sba_dirac_stereo_flag = 0;
move32();
@@ -1364,7 +1497,7 @@ ivas_error ivas_init_decoder_front(
IF( st_ivas->hDecoderConfig->Opt_LsCustom )
{
- IF( ( error = ivas_ls_custom_open_fx( &( st_ivas->hLsSetupCustom ) ) ) == IVAS_ERR_OK )
+ IF( EQ_32( ( error = ivas_ls_custom_open_fx( &( st_ivas->hLsSetupCustom ) ) ), IVAS_ERR_OK ) )
{
#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED
set_zero( ( st_ivas->hLsSetupCustom )->ls_azimuth, MAX_OUTPUT_CHANNELS );
@@ -1385,12 +1518,12 @@ ivas_error ivas_init_decoder_front(
IF( st_ivas->hDecoderConfig->Opt_Headrotation )
{
- IF( ( error = ivas_headTrack_open_fx( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_headTrack_open_fx( &( st_ivas->hHeadTrackData ) ) ), IVAS_ERR_OK ) )
{
return error;
}
error = ivas_orient_trk_SetTrackingType_fx( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking );
- IF( ( error ) != IVAS_ERR_OK )
+ IF( NE_32( ( error ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1401,7 +1534,7 @@ ivas_error ivas_init_decoder_front(
IF( st_ivas->hDecoderConfig->Opt_ExternalOrientation )
{
- IF( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1420,10 +1553,10 @@ ivas_error ivas_init_decoder_front(
/*-------------------------------------------------------------------*
* Allocate and initialize combined orientation handle
*--------------------------------------------------------------------*/
-
+ test();
IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation )
{
- IF( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1448,22 +1581,22 @@ ivas_error ivas_init_decoder_front(
IF( st_ivas->hDecoderConfig->Opt_HRTF_binary )
{
- IF( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_HRTF_CRend_binary_open_fx( &( st_ivas->hSetOfHRTF ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_HRTF_CRend_binary_open_fx( &( st_ivas->hSetOfHRTF ) ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_HRTF_fastconv_binary_open_fx( &st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_HRTF_fastconv_binary_open_fx( &st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_HRTF_parambin_binary_open_fx( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_HRTF_parambin_binary_open_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1473,21 +1606,21 @@ ivas_error ivas_init_decoder_front(
* Allocate and initialize Binaural Renderer configuration handle
*--------------------------------------------------------------------*/
- IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
+ IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
- IF( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_render_config_init_from_rom_fx( &st_ivas->hRenderConfig ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_render_config_init_from_rom_fx( &st_ivas->hRenderConfig ) ), IVAS_ERR_OK ) )
{
return error;
}
#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED
/*FLOAT CODE*/
- IF( ( error = ivas_render_config_init_from_rom( &st_ivas->hRenderConfig ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_render_config_init_from_rom( &st_ivas->hRenderConfig ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1644,36 +1777,43 @@ ivas_error ivas_init_decoder_fx(
Word32 ism_total_brate;
error = IVAS_ERR_OK;
-
+ move32();
output_Fs = st_ivas->hDecoderConfig->output_Fs;
+ move32();
hDecoderConfig = st_ivas->hDecoderConfig;
output_config = hDecoderConfig->output_config;
ivas_total_brate = hDecoderConfig->ivas_total_brate;
-
+ move32();
hDecoderConfig->last_ivas_total_brate = ivas_total_brate;
+ move32();
st_ivas->last_active_ivas_total_brate = ivas_total_brate;
-
+ move32();
/*-----------------------------------------------------------------*
* Set number of output channels for EXTERNAL output config.
*-----------------------------------------------------------------*/
- IF( output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
- IF( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 );
- hDecoderConfig->nchan_out += st_ivas->nchan_ism;
+ move16();
+ hDecoderConfig->nchan_out = add( hDecoderConfig->nchan_out, st_ivas->nchan_ism );
+ move16();
}
- ELSE IF( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- hDecoderConfig->nchan_out = st_ivas->nchan_transport + st_ivas->nchan_ism;
+ hDecoderConfig->nchan_out = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
+ move16();
}
- ELSE IF( !( st_ivas->ism_mode == ISM_MODE_PARAM ) )
+ ELSE IF( !EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
hDecoderConfig->nchan_out = st_ivas->nchan_transport;
+ move32();
}
st_ivas->hOutSetup.nchan_out_woLFE = hDecoderConfig->nchan_out;
+ move32();
}
/*-----------------------------------------------------------------*
@@ -1681,32 +1821,40 @@ ivas_error ivas_init_decoder_fx(
*-----------------------------------------------------------------*/
st_ivas->intern_config = output_config;
-
+ move32();
ivas_output_init( &( st_ivas->hOutSetup ), output_config );
-
- IF( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
{
st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER;
+ move32();
st_ivas->intern_config = IVAS_AUDIO_CONFIG_7_1_4;
+ move32();
st_ivas->hOutSetup.output_config = st_ivas->intern_config;
+ move32();
st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config );
}
-
- IF( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER;
+ move32();
st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3;
+ move32();
st_ivas->hOutSetup.output_config = IVAS_AUDIO_CONFIG_HOA3;
+ move32();
st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 );
+ move16();
}
/* Only initialize transport setup if it is used */
- IF( st_ivas->transport_config != IVAS_AUDIO_CONFIG_INVALID )
+ IF( NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_INVALID ) )
{
ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config );
}
- IF( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA )
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
{
ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate );
@@ -1715,14 +1863,18 @@ ivas_error ivas_init_decoder_fx(
ivas_renderer_select( st_ivas );
- IF( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
{
- IF( ( error = ivas_ls_custom_output_init_fx( st_ivas ) ) == IVAS_ERR_OK )
+ IF( EQ_16( ( error = ivas_ls_custom_output_init_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
st_ivas->hOutSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx;
+ move32();
st_ivas->hOutSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx;
+ move32();
st_ivas->hIntSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx;
+ move32();
st_ivas->hIntSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx;
+ move32();
}
ELSE
{
@@ -1732,19 +1884,23 @@ ivas_error ivas_init_decoder_fx(
ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
- IF( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA )
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
{
ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate );
- IF( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled )
+ test();
+ IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.separateChannelEnabled )
{
st_ivas->hLsSetupCustom->separate_ch_found = 0;
- IF( st_ivas->hOutSetup.nchan_out_woLFE >= MCMASA_MIN_SPEAKERS_SEPARATE_CENTER )
+ move16();
+ IF( GE_16( st_ivas->hOutSetup.nchan_out_woLFE, MCMASA_MIN_SPEAKERS_SEPARATE_CENTER ) )
{
/* check for a speaker at (0, 0) if minimum speaker count is available */
FOR( i = 0; i < st_ivas->hOutSetup.nchan_out_woLFE; i++ )
{
- IF( L_shr( st_ivas->hOutSetup.ls_azimuth_fx[i], Q22 ) == 0 && L_shr( st_ivas->hOutSetup.ls_elevation_fx[i], Q22 ) == 0 )
+ test();
+ IF( ( L_shr( st_ivas->hOutSetup.ls_azimuth_fx[i], Q22 ) == 0 ) && ( L_shr( st_ivas->hOutSetup.ls_elevation_fx[i], Q22 ) == 0 ) )
{
st_ivas->hIntSetup.separateChannelIndex = i;
move16();
@@ -1765,36 +1921,36 @@ ivas_error ivas_init_decoder_fx(
IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
{
st_ivas->nSCE = 1; /* in mono, there is always only one SCE */
- st_ivas->nCPE = 0;
- st_ivas->nchan_transport = 1;
- sce_id = 0;
move16();
+ st_ivas->nCPE = 0;
move16();
+ st_ivas->nchan_transport = 1;
move16();
+ sce_id = 0;
move16();
- IF( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
{
return error;
}
reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
}
- ELSE IF( st_ivas->ivas_format == STEREO_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
{
st_ivas->nchan_transport = CPE_CHANNELS;
+ move16();
st_ivas->intern_config = IVAS_AUDIO_CONFIG_STEREO;
+ move32();
st_ivas->nSCE = 0;
- st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */
- cpe_id = 0;
- move16();
- move16();
move16();
+ st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */
move16();
+ cpe_id = 0;
move16();
- IF( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1805,9 +1961,9 @@ ivas_error ivas_init_decoder_fx(
}
/* init EFAP for custom LS output and set hTransSetup */
- IF( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
{
- IF( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hOutSetup.ls_azimuth_fx, st_ivas->hOutSetup.ls_elevation_fx, st_ivas->hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hOutSetup.ls_azimuth_fx, st_ivas->hOutSetup.ls_elevation_fx, st_ivas->hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1815,40 +1971,39 @@ ivas_error ivas_init_decoder_fx(
ivas_output_init( &( st_ivas->hTransSetup ), IVAS_AUDIO_CONFIG_STEREO );
}
}
- ELSE IF( st_ivas->ivas_format == ISM_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
{
Word32 element_brate_tmp[MAX_NUM_OBJECTS];
st_ivas->nSCE = st_ivas->nchan_transport; /* "st_ivas->nchan_transport" is known from ivas_dec_setup */
- st_ivas->nCPE = 0;
- st_ivas->ism_extmeta_active = -1;
- st_ivas->ism_extmeta_cnt = 0;
-
move16();
+ st_ivas->nCPE = 0;
move16();
+ st_ivas->ism_extmeta_active = -1;
move16();
+ st_ivas->ism_extmeta_cnt = 0;
move16();
- IF( st_ivas->ism_mode == ISM_MODE_PARAM )
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE;
move16();
st_ivas->nSCE = MAX_PARAM_ISM_WAVE;
move16();
- IF( ( error = ivas_param_ism_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_param_ism_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nSCE, element_brate_tmp ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nSCE, element_brate_tmp ) ), IVAS_ERR_OK ) )
{
return error;
}
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- IF( ( error = create_sce_dec( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = create_sce_dec( st_ivas, sce_id, element_brate_tmp[sce_id] ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1856,6 +2011,7 @@ ivas_error ivas_init_decoder_fx(
reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
st_ivas->hSCE[sce_id]->hCoreCoder[0]->is_ism_format = 1;
+ move16();
}
st_ivas->hISMDTX.sce_id_dtx = 0;
@@ -1864,23 +2020,25 @@ ivas_error ivas_init_decoder_fx(
IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3;
+ move16();
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) )
{
FOR( sce_id = 0; sce_id < st_ivas->nSCE; ++sce_id )
{
- st_ivas->hSCE[sce_id]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = 2 + sce_id;
+ st_ivas->hSCE[sce_id]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = add( 2, sce_id );
+ move16();
}
}
}
ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
{
- IF( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_spar_dec_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_spar_dec_open_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1888,50 +2046,69 @@ ivas_error ivas_init_decoder_fx(
set_f( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, 0.f, CLDFB_NO_COL_MAX );
set_s( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 0, CLDFB_NO_COL_MAX );
#endif
-
- IF( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup )
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) && st_ivas->hOutSetup.is_loudspeaker_setup )
{
- IF( ( error = ivas_sba_get_hoa_dec_matrix_fx( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ) != IVAS_ERR_OK )
+ Word16 hodirac_flag = ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order );
+ IF( hodirac_flag )
{
- return error;
+ IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, IVAS_MAX_NUM_BANDS, st_ivas->ivas_format ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
}
+ ELSE
+ {
+ IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
- IF( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO )
+ test();
+ test();
+ IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) )
{
- IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
{
return error;
}
st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
+ move16();
}
ELSE
{
Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1];
- st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
- IF( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) )
+ st_ivas->hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
+ move16();
+ IF( ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) )
{
st_ivas->hSpar->enc_param_start_band = 0;
-
- set_c( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands );
+ move16();
+ set8_fx( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands );
st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands;
+ move16();
}
- ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ),
+ ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ),
st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
}
st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
-
+ move16();
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- IF( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != 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( NE_32( ( error = create_sce_dec( st_ivas, sce_id, res_dec ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1941,7 +2118,9 @@ ivas_error ivas_init_decoder_fx(
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- IF( ( error = create_cpe_dec( 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( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, (res_dec) *CPE_CHANNELS ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1953,9 +2132,13 @@ ivas_error ivas_init_decoder_fx(
}
/* create CPE element for DFT Stereo like upmix */
- IF( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 )
+ test();
+ IF( st_ivas->sba_dirac_stereo_flag && ( st_ivas->nCPE == 0 ) )
{
- IF( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &res_dec, &res_frac, 0 );
+
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1964,9 +2147,9 @@ ivas_error ivas_init_decoder_fx(
st_ivas->hCPE[0]->hCoreCoder[1] = NULL;
}
- IF( st_ivas->nCPE > 1 )
+ IF( GT_16( st_ivas->nCPE, 1 ) )
{
- IF( ( error = create_mct_dec_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1975,26 +2158,29 @@ ivas_error ivas_init_decoder_fx(
/* set CNA/CNG flags */
ivas_sba_set_cna_cng_flag( st_ivas );
}
- ELSE IF( st_ivas->ivas_format == MASA_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
{
/* if we start in ISM_MODE_NONE in MASA_ISM, that appears as normal MASA, but we may change to a mode with ISMs */
st_ivas->ism_extmeta_active = -1;
- st_ivas->ism_extmeta_cnt = 0;
move16();
+ st_ivas->ism_extmeta_cnt = 0;
move16();
- IF( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_masa_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_masa_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
{
- IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2002,7 +2188,9 @@ ivas_error ivas_init_decoder_fx(
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- IF( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != 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( NE_32( ( error = create_sce_dec( st_ivas, sce_id, res_dec ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2012,7 +2200,9 @@ ivas_error ivas_init_decoder_fx(
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- IF( ( error = create_cpe_dec( 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( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, L_shl( res_dec, 1 ) ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2026,7 +2216,7 @@ ivas_error ivas_init_decoder_fx(
/* set CNA/CNG flags */
ivas_sba_set_cna_cng_flag( st_ivas );
}
- ELSE IF( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
Word32 temp_brate[MAX_SCE];
st_ivas->ism_extmeta_active = -1;
@@ -2035,59 +2225,80 @@ ivas_error ivas_init_decoder_fx(
move16();
st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
-
- IF( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
+ move16();
+ IF( NE_32( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_spar_dec_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_spar_dec_open_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup )
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) && st_ivas->hOutSetup.is_loudspeaker_setup )
{
- IF( ( error = ivas_sba_get_hoa_dec_matrix_fx( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ) != IVAS_ERR_OK )
+ Word16 hodirac_flag = ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order );
+ IF( hodirac_flag )
{
- return error;
+ IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, IVAS_MAX_NUM_BANDS, st_ivas->ivas_format ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE
+ {
+ IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
}
- IF( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO )
+
+ test();
+ test();
+ test();
+ IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) )
{
- IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
{
return error;
}
st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
+ move16();
}
ELSE
{
Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1];
- st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
- IF( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) )
+ st_ivas->hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
+ move16();
+ IF( ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) )
{
st_ivas->hSpar->enc_param_start_band = 0;
-
- set_c( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands );
+ move16();
+ set8_fx( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands );
st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands;
+ move16();
}
- ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ),
- st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
+ ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ),
+ st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
}
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- IF( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != 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( NE_32( ( error = create_sce_dec( st_ivas, sce_id, res_dec ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2095,15 +2306,19 @@ ivas_error ivas_init_decoder_fx(
reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
}
- IF( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
- st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1;
+ st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) );
+ move16();
st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ move16();
}
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- IF( ( error = create_cpe_dec( 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( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, L_shl( res_dec, 1 ) ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2117,7 +2332,9 @@ ivas_error ivas_init_decoder_fx(
/* create CPE element for DFT Stereo like upmix */
IF( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 )
{
- IF( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &res_dec, &res_frac, 0 );
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2126,22 +2343,22 @@ ivas_error ivas_init_decoder_fx(
st_ivas->hCPE[0]->hCoreCoder[1] = NULL;
}
- IF( st_ivas->nCPE > 1 )
+ IF( GT_16( st_ivas->nCPE, 1 ) )
{
- IF( ( error = create_mct_dec_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
- IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_osba_data_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_osba_data_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2150,52 +2367,59 @@ ivas_error ivas_init_decoder_fx(
/* set CNA/CNG flags */
ivas_sba_set_cna_cng_flag( st_ivas );
}
- ELSE IF( st_ivas->ivas_format == MASA_ISM_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
st_ivas->ism_extmeta_active = -1;
+ move16();
st_ivas->ism_extmeta_cnt = 0;
+ move16();
- IF( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
{
return error;
}
k = 0;
+ move16();
ism_total_brate = 0;
+ move16();
+ test();
WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( ivas_total_brate, ivas_brate_tbl[k] ) )
{
- k++;
+ k = add( k, 1 );
}
-
- IF( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
+ test();
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
{
/* one separated object */
st_ivas->nSCE = 1;
-
+ move16();
ism_total_brate = sep_object_brate[k - 2][0];
- IF( ( error = create_sce_dec( st_ivas, 0, ism_total_brate ) ) != IVAS_ERR_OK )
+ move32();
+ IF( NE_32( ( error = create_sce_dec( st_ivas, 0, ism_total_brate ) ), IVAS_ERR_OK ) )
{
return error;
}
reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] );
- IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, 1, NULL ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, 1, NULL ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- ELSE IF( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
Word32 temp_brate[MAX_SCE];
st_ivas->nSCE = st_ivas->nchan_ism; /* number of objects */
-
+ move16();
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
temp_brate[sce_id] = sep_object_brate[k - 2][st_ivas->nSCE - 1];
- ism_total_brate += temp_brate[sce_id];
+ move16();
+ ism_total_brate = L_add( ism_total_brate, temp_brate[sce_id] );
- IF( ( error = create_sce_dec( st_ivas, sce_id, temp_brate[sce_id] ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = create_sce_dec( st_ivas, sce_id, temp_brate[sce_id] ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2203,31 +2427,34 @@ ivas_error ivas_init_decoder_fx(
reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
}
- IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( ( error = ivas_masa_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_masa_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_omasa_data_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
{
- IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate - ism_total_brate ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate - ism_total_brate ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2237,32 +2464,36 @@ ivas_error ivas_init_decoder_fx(
reset_indices_dec( st_ivas->hCPE[0]->hCoreCoder[n] );
}
}
- ELSE IF( st_ivas->ivas_format == MC_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
{
- IF( st_ivas->mc_mode == MC_MODE_MCT )
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) )
{
/* init EFAP for custom LS setup */
- IF( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
{
/*float2fix block: to be removed*/
floatToFixed_arrL( st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_azimuth_fx, Q22, st_ivas->hLsSetupCustom->num_spk );
floatToFixed_arrL( st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->ls_elevation_fx, Q22, st_ivas->hLsSetupCustom->num_spk );
/*float2fix block end*/
- IF( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
{
return error;
}
}
st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ) );
+ move16();
st_ivas->nSCE = 0;
- st_ivas->nCPE = st_ivas->nchan_transport / CPE_CHANNELS;
-
+ move16();
+ st_ivas->nCPE = shr( st_ivas->nchan_transport, 1 );
+ move16();
st_ivas->element_mode_init = IVAS_CPE_MDCT;
-
+ move16();
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- IF( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, sub( st_ivas->nchan_transport, 1 ), &res_dec, &res_frac, 0 );
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, L_shl( res_dec, 1 ) ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2273,33 +2504,34 @@ ivas_error ivas_init_decoder_fx(
}
}
- IF( ( error = create_mct_dec_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- ELSE IF( st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
{
/* init EFAP for custom LS setup */
- IF( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
{
/*float2fix block: to be removed*/
floatToFixed_arrL( st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_azimuth_fx, Q22, st_ivas->hLsSetupCustom->num_spk );
floatToFixed_arrL( st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->ls_elevation_fx, Q22, st_ivas->hLsSetupCustom->num_spk );
/*float2fix block end*/
- IF( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
{
return error;
}
}
st_ivas->nSCE = 0;
- st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / CPE_CHANNELS;
- st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS;
move16();
+ st_ivas->nCPE = shr( MC_PARAMUPMIX_MAX_TRANSPORT_CHANS, 1 );
move16();
+ st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS;
move16();
- IF( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ) != IVAS_ERR_OK )
+
+ IF( NE_32( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2308,7 +2540,9 @@ ivas_error ivas_init_decoder_fx(
move16();
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- IF( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, sub( st_ivas->nchan_transport, 1 ), &res_dec, &res_frac, 0 );
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, L_shl( res_dec, 1 ) ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2319,22 +2553,22 @@ ivas_error ivas_init_decoder_fx(
}
}
- IF( ( error = create_mct_dec_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), 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 ) )
{
/* init EFAP for custom LS setup */
- IF( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
{
- IF( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( ( error = ivas_param_mc_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_param_mc_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2343,7 +2577,10 @@ ivas_error ivas_init_decoder_fx(
move16();
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
- IF( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &res_dec, &res_frac, 0 );
+
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2356,56 +2593,60 @@ ivas_error ivas_init_decoder_fx(
IF( GT_16( st_ivas->nCPE, 1 ) )
{
- IF( ( error = create_mct_dec_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
}
}
- ELSE IF( st_ivas->mc_mode == MC_MODE_MCMASA )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
{
Word32 brate_sce, brate_cpe;
ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate );
- IF( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_masa_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_masa_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
-
- IF( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_MCMASA_MONO_STEREO )
+ move16();
+ test();
+ IF( st_ivas->renderer_type != RENDERER_DISABLE && NE_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) )
{
- IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled && !st_ivas->hLsSetupCustom->separate_ch_found )
+ test();
+ IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.separateChannelEnabled && !st_ivas->hLsSetupCustom->separate_ch_found )
{
/* If no speaker matching the separated channel, compute panning gains for the separated channel. */
IF( st_ivas->hVBAPdata == NULL )
{
/* Distribute signal to all channels if VBAP is not properly initialized. */
Word16 inv_sqr, sqr, exp = 15, exp_sqr;
+ move16();
IF( EQ_16( st_ivas->hLsSetupCustom->num_spk, 1 ) )
{
inv_sqr = 32767;
+ move16();
}
ELSE
{
sqr = Sqrt16( st_ivas->hLsSetupCustom->num_spk, &exp );
inv_sqr = BASOP_Util_Divide1616_Scale( 32767, sqr, &exp_sqr );
exp_sqr = sub( exp_sqr, exp );
- IF( LT_16( exp, 0 ) )
+ IF( ( exp < 0 ) )
{
inv_sqr = shr( inv_sqr, exp );
}
@@ -2423,7 +2664,7 @@ ivas_error ivas_init_decoder_fx(
FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
- IF( ( error = create_sce_dec( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = create_sce_dec( st_ivas, sce_id, brate_sce ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2434,8 +2675,8 @@ ivas_error ivas_init_decoder_fx(
FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
st_ivas->element_mode_init = IVAS_CPE_MDCT; /* element_mode_init was IVAS_SCE for SCE initialization */
-
- IF( ( error = create_cpe_dec( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK )
+ move16();
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, brate_cpe ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2449,7 +2690,9 @@ ivas_error ivas_init_decoder_fx(
/* create CPE element for DFT Stereo like upmix */
IF( st_ivas->sba_dirac_stereo_flag )
{
- IF( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &res_dec, &res_frac, 0 );
+ IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, res_dec ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2459,10 +2702,12 @@ ivas_error ivas_init_decoder_fx(
}
/* set CNA/CNG flags */
- IF( EQ_16( st_ivas->nchan_transport, 1 ) && ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) )
+ IF( EQ_16( st_ivas->nchan_transport, 1 ) && ( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) )
{
st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 1;
+ move16();
st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 1;
+ move16();
}
}
}
@@ -2475,7 +2720,7 @@ ivas_error ivas_init_decoder_fx(
/* set number of output channels used for synthesis/decoding */
n = getNumChanSynthesis( st_ivas );
- IF( GT_16( n, 0 ) )
+ IF( n > 0 )
{
IF( ( st_ivas->mem_hp20_out_fx = (Word32 **) malloc( n * sizeof( Word32 * ) ) ) == NULL )
{
@@ -2499,43 +2744,49 @@ ivas_error ivas_init_decoder_fx(
/*-------------------------------------------------------------------*
* Allocate and initialize rendering handles
*--------------------------------------------------------------------*/
-
- IF( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
{
- IF( ( error = ivas_binRenderer_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_binRenderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
}
-
/* ParamISM is handled separately from other common config */
- ELSE IF( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) )
+ ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) )
{
- IF( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC )
+ IF( NE_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
{
- IF( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- ELSE IF( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) )
{
Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
Word16 num_src;
- IF( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
{
return error;
}
Word16 nchan_rend = num_src;
- IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ move16();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
{
- nchan_rend--; /* Skip LFE channel -- added to the others */
+ nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */
}
FOR( Word16 nS = 0; nS < nchan_rend; nS++ )
{
@@ -2543,69 +2794,77 @@ ivas_error ivas_init_decoder_fx(
IF( Src_p->SrcSpatial_p != NULL )
{
Src_p->SrcSpatial_p->q_Pos_p = Q31;
+ move16();
}
TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p;
SrcSpatial_p->q_Pos_p = Q31;
+ move16();
}
IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
- IF( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
{
return error;
}
}
granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES );
-
+ move16();
n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
- IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- ELSE IF( st_ivas->renderer_type == RENDERER_MC )
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
{
- IF( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- ELSE IF( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX )
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
{
- IF( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- ELSE IF( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
{
- IF( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) )
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) )
{
- IF( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config,
- st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config,
+ st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ),
+ IVAS_ERR_OK ) )
{
return error;
}
st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns;
+ move32();
- IF( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) )
+ test();
+ IF( ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) && ( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) )
{
granularity = NS2SA( output_Fs, CLDFB_SLOT_NS );
-
+ move16();
n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
- IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, MC_PARAMUPMIX_MAX_INPUT_CHANS, MC_PARAMUPMIX_MAX_INPUT_CHANS, granularity ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, MC_PARAMUPMIX_MAX_INPUT_CHANS, MC_PARAMUPMIX_MAX_INPUT_CHANS, granularity ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2613,31 +2872,35 @@ ivas_error ivas_init_decoder_fx(
ELSE
{
granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES );
-
+ move16();
n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
- IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ), IVAS_ERR_OK ) )
{
return error;
}
}
}
- IF( st_ivas->ivas_format == MASA_ISM_FORMAT )
+ IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
- IF( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC )
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
/* Allocate TD renderer for the objects in DISC mode */
Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
Word16 num_src;
- IF( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
{
return error;
}
Word16 nchan_rend = num_src;
- IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ move16();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
{
- nchan_rend--; /* Skip LFE channel -- added to the others */
+ nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */
+ move16();
}
FOR( Word16 nS = 0; nS < nchan_rend; nS++ )
{
@@ -2645,71 +2908,95 @@ ivas_error ivas_init_decoder_fx(
IF( Src_p->SrcSpatial_p != NULL )
{
Src_p->SrcSpatial_p->q_Pos_p = Q31;
+ move16();
}
TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p;
SrcSpatial_p->q_Pos_p = Q31;
+ move16();
}
/* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
- IF( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( st_ivas->renderer_type == RENDERER_DIRAC && ( 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_32( st_ivas->renderer_type, RENDERER_DIRAC ) && ( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) )
{
/* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
- IF( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
}
}
- IF( ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) &&
- ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) &&
- ( st_ivas->renderer_type == RENDERER_TD_PANNING ||
- st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ||
- st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ||
- st_ivas->renderer_type == RENDERER_OSBA_STEREO ||
- st_ivas->renderer_type == RENDERER_OSBA_AMBI ||
- st_ivas->renderer_type == RENDERER_OSBA_LS ||
- st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ||
- st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ||
- st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
- {
- IF( ( error = ivas_ism_renderer_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) &&
+ ( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) &&
+ ( EQ_32( st_ivas->renderer_type, RENDERER_TD_PANNING ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ||
+ EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) )
+ {
+ IF( NE_32( ( error = ivas_ism_renderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
- IF( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ test();
+ test();
+ IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
/* Allocate TD renderer for the objects in DISC mode */
Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
Word16 num_src;
- IF( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
{
return error;
}
Word16 nchan_rend = num_src;
- IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ move16();
+
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
{
- nchan_rend--; /* Skip LFE channel -- added to the others */
+ nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */
}
FOR( Word16 nS = 0; nS < nchan_rend; nS++ )
{
TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]];
- IF( Src_p->SrcSpatial_p != NULL )
+ if ( Src_p->SrcSpatial_p != NULL )
{
Src_p->SrcSpatial_p->q_Pos_p = Q31;
+ move16();
}
TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p;
SrcSpatial_p->q_Pos_p = Q31;
+ move16();
}
}
}
@@ -2717,10 +3004,11 @@ ivas_error ivas_init_decoder_fx(
/*-----------------------------------------------------------------*
* LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay
*-----------------------------------------------------------------*/
-
- IF( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
+ test();
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
{
binauralization_delay_ns = st_ivas->binaural_latency_ns;
+ move32();
IF( st_ivas->hBinRenderer != NULL )
{
IF( st_ivas->hBinRenderer->render_lfe )
@@ -2737,7 +3025,7 @@ ivas_error ivas_init_decoder_fx(
}
}
- IF( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, output_Fs, binauralization_delay_ns ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2754,7 +3042,7 @@ ivas_error ivas_init_decoder_fx(
FOR( i = 0; i < numCldfbAnalyses; i++ )
{
- IF( ( error = openCldfb_ivas( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2766,7 +3054,7 @@ ivas_error ivas_init_decoder_fx(
FOR( i = 0; i < numCldfbSyntheses; i++ )
{
- IF( ( error = openCldfb_ivas( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2777,11 +3065,15 @@ ivas_error ivas_init_decoder_fx(
}
/* CLDFB Interpolation weights */
- IF( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 )
+ test();
+ test();
+ test();
+ IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !st_ivas->sba_dirac_stereo_flag && NE_16( st_ivas->hDecoderConfig->nchan_out, 1 ) )
{
#ifdef IVAS_FLOAT_FIXED
#if 1
Word16 Q_cldfbSynDec = Q11;
+ move16();
#ifndef MSAN_FIX
IF( st_ivas->hSpar )
{
@@ -2793,11 +3085,19 @@ ivas_error ivas_init_decoder_fx(
ivas_spar_get_cldfb_gains_fx( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig );
#if 1
FOR( i = 0; i < st_ivas->cldfbAnaDec[0]->cldfb_state_length; i++ )
- st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i], 16 ); // Scaling down from 27 to 11
+ {
+ st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i], 16 ); // Scaling down from 27 to 11
+ move16();
+ }
st_ivas->cldfbAnaDec[0]->Q_cldfb_state = Q11;
+ move16();
FOR( i = 0; i < st_ivas->cldfbSynDec[0]->cldfb_state_length; i++ )
- st_ivas->cldfbSynDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbSynDec[0]->cldfb_state_fx[i], 21 - Q_cldfbSynDec ); // Scaling down from 21 to Q_cldfbSynDec
+ {
+ st_ivas->cldfbSynDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbSynDec[0]->cldfb_state_fx[i], sub( 21, Q_cldfbSynDec ) ); // Scaling down from 21 to Q_cldfbSynDec
+ move16();
+ }
st_ivas->cldfbSynDec[0]->Q_cldfb_state = Q11;
+ move16();
IF( st_ivas->hSpar )
{
fixedToFloat_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, st_ivas->hSpar->hFbMixer->cldfb_cross_fade, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q, 16 );
@@ -2812,7 +3112,7 @@ ivas_error ivas_init_decoder_fx(
* Allocate and initialize limiter struct
*-----------------------------------------------------------------*/
- IF( ( error = ivas_limiter_open( &st_ivas->hLimiter, hDecoderConfig->nchan_out, output_Fs ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_limiter_open_fx( &st_ivas->hLimiter, hDecoderConfig->nchan_out, output_Fs ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2827,16 +3127,17 @@ ivas_error ivas_init_decoder_fx(
/* no module has yet open the TC buffer, open a default one */
n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
- IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) )
{
return error;
}
+ move16(); // For NS2SA
}
IF( st_ivas->hTcBuffer == NULL )
{
/* we need the handle anyway, but without the buffer*/
- IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2844,9 +3145,9 @@ ivas_error ivas_init_decoder_fx(
IF( st_ivas->hJbmMetadata == NULL )
{
- IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
+ IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
- IF( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2857,7 +3158,7 @@ ivas_error ivas_init_decoder_fx(
* Allocate floating-point output audio buffers
*-----------------------------------------------------------------*/
st_ivas->p_out_len = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
-
+ move16();
FOR( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ )
{
/* note: these are intra-frame heap memories */
@@ -4490,7 +4791,7 @@ void ivas_destroy_dec_fx(
{
IF( st_ivas->cldfbAnaDec[i] != NULL )
{
- deleteCldfb_ivas( &( st_ivas->cldfbAnaDec[i] ) );
+ deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ) );
}
}
@@ -4498,7 +4799,7 @@ void ivas_destroy_dec_fx(
{
IF( st_ivas->cldfbSynDec[i] != NULL )
{
- deleteCldfb_ivas( &( st_ivas->cldfbSynDec[i] ) );
+ deleteCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ) );
}
}
@@ -4547,7 +4848,7 @@ void ivas_destroy_dec_fx(
ivas_ism_renderer_close( &( st_ivas->hIsmRendererData ) );
/* DirAC handle */
- IF( st_ivas->ivas_format == ISM_FORMAT )
+ IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
{
ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config );
}
@@ -4559,7 +4860,7 @@ void ivas_destroy_dec_fx(
}
/* SPAR handle */
- ivas_spar_dec_close( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 );
+ ivas_spar_dec_close_fx( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 );
/* HOA decoder matrix */
IF( st_ivas->hoa_dec_mtx != NULL )
@@ -4587,7 +4888,7 @@ void ivas_destroy_dec_fx(
ivas_param_mc_dec_close_fx( &st_ivas->hParamMC );
/* EFAP handle */
- efap_free_data( &st_ivas->hEFAPdata );
+ efap_free_data_fx( &st_ivas->hEFAPdata );
/* VBAP handle */
vbap_free_data_fx( &( st_ivas->hVBAPdata ) );
@@ -4659,7 +4960,7 @@ void ivas_destroy_dec_fx(
ivas_render_config_close( &( st_ivas->hRenderConfig ) );
/* Limiter struct */
- ivas_limiter_close( &( st_ivas->hLimiter ) );
+ ivas_limiter_close_fx( &( st_ivas->hLimiter ) );
IF( st_ivas->hDecoderConfig != NULL )
{
@@ -4933,85 +5234,118 @@ void ivas_init_dec_get_num_cldfb_instances(
{
IVAS_FORMAT ivas_format;
*numCldfbAnalyses = st_ivas->nchan_transport;
+ move16();
*numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out;
+ move16();
- ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */
+ test();
+ IF( ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_NONE ) ) )
+ {
+ ivas_format = SBA_FORMAT;
+ move32();
+ }
+ ELSE
+ {
+ ivas_format = st_ivas->ivas_format;
+ move32();
+ }
SWITCH( st_ivas->renderer_type )
{
case RENDERER_BINAURAL_PARAMETRIC:
case RENDERER_BINAURAL_PARAMETRIC_ROOM:
case RENDERER_STEREO_PARAMETRIC:
- IF( st_ivas->nchan_transport == 1 )
+ IF( EQ_16( st_ivas->nchan_transport, 1 ) )
{
- *numCldfbAnalyses = st_ivas->nchan_transport + 1;
+ *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
}
- IF( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hOutSetup.separateChannelEnabled )
+ test();
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->hOutSetup.separateChannelEnabled )
{
- *numCldfbAnalyses = st_ivas->nchan_transport + 1;
+ *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
}
IF( ivas_format == SBA_ISM_FORMAT )
{
- IF( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
- *numCldfbAnalyses += st_ivas->nchan_ism;
+ *numCldfbAnalyses = add( *numCldfbAnalyses, st_ivas->nchan_ism );
+ move16();
}
}
- IF( ivas_format == MASA_ISM_FORMAT )
+ IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) )
{
- IF( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
+ test();
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
- *numCldfbAnalyses += st_ivas->nchan_ism;
+ *numCldfbAnalyses = add( *numCldfbAnalyses, st_ivas->nchan_ism );
+ move16();
}
- ELSE IF( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
{
- *numCldfbAnalyses = st_ivas->nchan_transport + 1;
+ *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
}
}
IF( st_ivas->hDiracDecBin->useTdDecorr )
{
- *numCldfbAnalyses += 2;
+ *numCldfbAnalyses = add( *numCldfbAnalyses, 2 );
+ move16();
}
BREAK;
case RENDERER_NON_DIEGETIC_DOWNMIX:
case RENDERER_MONO_DOWNMIX:
- IF( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT || ivas_format == SBA_ISM_FORMAT )
+ test();
+ test();
+ IF( EQ_32( ivas_format, ISM_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
+ move16();
*numCldfbSyntheses = 0;
+ move16();
}
BREAK;
case RENDERER_DIRAC:
- IF( ivas_format == SBA_FORMAT )
+ IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
*numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans;
+ move16();
- IF( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC )
+ test();
+ IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
{
*numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE;
+ move16();
}
- ELSE IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA )
+ ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
{
*numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans;
+ move16();
}
ELSE
{
*numCldfbSyntheses = MAX_OUTPUT_CHANNELS;
+ move16();
}
}
- IF( ivas_format != SBA_FORMAT )
+ IF( NE_32( ivas_format, SBA_FORMAT ) )
{
- IF( GT_16( st_ivas->nchan_transport, 2 ) && NE_16( st_ivas->sba_planar, 0 ) )
+ test();
+ test();
+ IF( GT_16( st_ivas->nchan_transport, 2 ) && ( st_ivas->sba_planar != 0 ) )
{
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
}
- ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD )
+ ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) )
{
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
}
}
BREAK;
@@ -5020,11 +5354,14 @@ void ivas_init_dec_get_num_cldfb_instances(
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
+ move16();
*numCldfbSyntheses = 0;
+ move16();
}
ELSE
{
*numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_fx( st_ivas );
+ move16();
}
BREAK;
case RENDERER_PARAM_ISM:
@@ -5033,7 +5370,9 @@ void ivas_init_dec_get_num_cldfb_instances(
case RENDERER_DISABLE:
/* CLDFB not used */
*numCldfbAnalyses = 0;
+ move16();
*numCldfbSyntheses = 0;
+ move16();
BREAK;
case RENDERER_MC:
case RENDERER_SBA_LINEAR_DEC:
@@ -5047,37 +5386,46 @@ void ivas_init_dec_get_num_cldfb_instances(
case RENDERER_OSBA_STEREO:
case RENDERER_OSBA_AMBI:
case RENDERER_OSBA_LS:
- IF( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
+ test();
+ IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
- IF( NE_16( st_ivas->sba_dirac_stereo_flag, 0 ) )
+ IF( st_ivas->sba_dirac_stereo_flag != 0 )
{
*numCldfbAnalyses = 0;
+ move16();
*numCldfbSyntheses = 0;
+ move16();
}
ELSE
{
*numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans;
+ move16();
- IF( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC )
+ test();
+ IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
{
*numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE;
+ move16();
}
- ELSE IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA )
+ ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
{
*numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans;
+ move16();
}
ELSE
{
*numCldfbSyntheses = MAX_OUTPUT_CHANNELS;
+ move16();
}
-
- IF( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
{
- *numCldfbAnalyses = st_ivas->nchan_ism + st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans;
+ *numCldfbAnalyses = add( st_ivas->nchan_ism, st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans );
+ move16();
}
}
}
- ELSE IF( st_ivas->mc_mode == MC_MODE_PARAMMC )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
{
/* do nothing for ParamMC */
}
@@ -5085,45 +5433,59 @@ void ivas_init_dec_get_num_cldfb_instances(
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
+ move16();
*numCldfbSyntheses = 0;
+ move16();
}
BREAK;
case RENDERER_SBA_LINEAR_ENC:
- IF( st_ivas->mc_mode == MC_MODE_PARAMMC )
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
{
*numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_fx( st_ivas );
+ move16();
}
- ELSE IF( st_ivas->ism_mode == ISM_MODE_PARAM )
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
- *numCldfbSyntheses = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
+ *numCldfbSyntheses = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
+ move16();
}
- ELSE IF( st_ivas->mc_mode == MC_MODE_MCMASA )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
{
*numCldfbAnalyses = st_ivas->nchan_transport;
- *numCldfbSyntheses = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
+ move16();
+ *numCldfbSyntheses = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
+ move16();
}
ELSE
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
+ move16();
*numCldfbSyntheses = 0;
+ move16();
}
BREAK;
default:
assert( 0 && "Renderer not handled for CLDFB reservation." );
}
-
- IF( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO )
+ test();
+ test();
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) )
{
- IF( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
{
- *numCldfbAnalyses = max( MC_PARAMUPMIX_MAX_INPUT_CHANS, *numCldfbAnalyses );
+ *numCldfbAnalyses = s_max( MC_PARAMUPMIX_MAX_INPUT_CHANS, *numCldfbAnalyses );
+ move16();
}
ELSE
{
- *numCldfbAnalyses = max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbAnalyses );
+ *numCldfbAnalyses = s_max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbAnalyses );
+ move16();
}
- *numCldfbSyntheses = max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbSyntheses );
+ *numCldfbSyntheses = s_max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbSyntheses );
+ move16();
}
return;
@@ -5354,12 +5716,12 @@ static ivas_error doSanityChecks_IVAS(
output_Fs = st_ivas->hDecoderConfig->output_Fs;
move32();
output_config = st_ivas->hDecoderConfig->output_config;
-
+ move32();
/*-----------------------------------------------------------------*
* Sanity checks
*-----------------------------------------------------------------*/
- IF( output_Fs == 8000 )
+ IF( EQ_32( output_Fs, 8000 ) )
{
return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "8kHz output sampling rate is not supported in IVAS." );
}
@@ -5368,46 +5730,56 @@ static ivas_error doSanityChecks_IVAS(
assert( st_ivas->ivas_format != MONO_FORMAT && "\n Wrong IVAS format: MONO" );
/* Verify output configuration compatible with non-diegetic panning */
+ test();
+ test();
IF( st_ivas->hDecoderConfig->Opt_non_diegetic_pan && ( st_ivas->ivas_format != MONO_FORMAT ) && ( st_ivas->transport_config != IVAS_AUDIO_CONFIG_ISM1 ) )
{
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Non-diegetic panning not supported in this IVAS format" );
}
/* Verify stereo output configuration */
- IF( st_ivas->ivas_format == STEREO_FORMAT )
+ IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
{
- IF( output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO && output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( NE_32( output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
{
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Wrong output configuration specified for Stereo!" );
}
}
- ELSE IF( st_ivas->ivas_format == ISM_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
{
/* Verify ISM output configuration */
- IF( output_config == IVAS_AUDIO_CONFIG_INVALID )
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) )
{
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for ISM" );
}
}
- ELSE IF( st_ivas->ivas_format == SBA_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
{
/* Verify SBA output coniguration */
- IF( output_config == IVAS_AUDIO_CONFIG_INVALID )
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) )
{
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for SBA" );
}
}
- ELSE IF( st_ivas->ivas_format == MASA_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
{
- IF( output_config == IVAS_AUDIO_CONFIG_INVALID )
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) )
{
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for MASA!" );
}
}
- ELSE IF( st_ivas->ivas_format == MC_FORMAT )
+ ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
{
/* Verify MC output configuration */
- IF( output_config == IVAS_AUDIO_CONFIG_INVALID || output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
+ test();
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for Multi-channel" );
}
@@ -5416,7 +5788,9 @@ static ivas_error doSanityChecks_IVAS(
IF( st_ivas->hDecoderConfig->Opt_Headrotation )
{
- IF( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
+ test();
+ test();
+ IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) )
{
return IVAS_ERROR( IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED, "Wrong set-up: Head-rotation not supported in this configuration" );
}
@@ -5424,7 +5798,9 @@ static ivas_error doSanityChecks_IVAS(
IF( st_ivas->hDecoderConfig->Opt_ExternalOrientation )
{
- IF( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
+ test();
+ test();
+ IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) )
{
return IVAS_ERROR( IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED, "Wrong set-up: External orientation not supported in this configuration" );
}
@@ -5432,7 +5808,8 @@ static ivas_error doSanityChecks_IVAS(
IF( st_ivas->hDecoderConfig->Opt_dpid_on )
{
- IF( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
+ test();
+ IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) )
{
return IVAS_ERROR( IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED, "Wrong set-up: Directivity is not supported in this output configuration." );
}
@@ -5440,16 +5817,18 @@ static ivas_error doSanityChecks_IVAS(
IF( st_ivas->hDecoderConfig->Opt_aeid_on )
{
- IF( output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
+ IF( NE_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
return IVAS_ERROR( IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, "Wrong set-up: Acoustic environment is not supported in this output configuration." );
}
}
- IF( st_ivas->ivas_format == MASA_ISM_FORMAT )
+ IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
- IF( st_ivas->ism_mode != ISM_MASA_MODE_DISC && output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
+ test();
+ IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
+
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" );
}
}
diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c
index 7d4820c145ac5f26a42cee1027eb7c1a53e0ee75..1d56a3412e86b03a52294fba3dd6e16c2df54a39 100644
--- a/lib_dec/ivas_init_dec_fx.c
+++ b/lib_dec/ivas_init_dec_fx.c
@@ -8,12 +8,17 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx(
{
IVAS_FORMAT ivas_format;
*numCldfbAnalyses = st_ivas->nchan_transport;
+ move16();
*numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out;
-
+ move16();
ivas_format = st_ivas->ivas_format;
+ move32();
+
+ test();
IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MODE_NONE ) )
{
ivas_format = SBA_FORMAT; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */
+ move32();
}
SWITCH( st_ivas->renderer_type )
@@ -24,73 +29,94 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx(
IF( EQ_16( st_ivas->nchan_transport, 1 ) )
{
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
}
-
+ test();
IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->hOutSetup.separateChannelEnabled )
{
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
}
- IF( EQ_16( ivas_format, SBA_ISM_FORMAT ) )
+ IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
- IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
*numCldfbAnalyses = add( *numCldfbAnalyses, st_ivas->nchan_ism );
+ move16();
}
}
- IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) )
+ IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) )
{
- IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
+ test();
+ test();
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
*numCldfbAnalyses = add( *numCldfbAnalyses, st_ivas->nchan_ism );
+ move16();
}
- ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
{
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
}
}
IF( st_ivas->hDiracDecBin->useTdDecorr )
{
*numCldfbAnalyses = add( *numCldfbAnalyses, 2 );
+ move16();
}
BREAK;
case RENDERER_NON_DIEGETIC_DOWNMIX:
case RENDERER_MONO_DOWNMIX:
- IF( EQ_16( ivas_format, ISM_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) )
+ test();
+ test();
+ test();
+ IF( EQ_32( ivas_format, ISM_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
+ move16();
*numCldfbSyntheses = 0;
+ move16();
}
BREAK;
case RENDERER_DIRAC:
- IF( EQ_16( ivas_format, SBA_FORMAT ) )
+ IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
*numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans;
-
- IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) )
+ move16();
+ test();
+ IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
{
*numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE;
+ move16();
}
- ELSE IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
+ ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
{
*numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans;
+ move16();
}
ELSE
{
*numCldfbSyntheses = MAX_OUTPUT_CHANNELS;
+ move16();
}
}
- IF( NE_16( ivas_format, SBA_FORMAT ) )
+ IF( NE_32( ivas_format, SBA_FORMAT ) )
{
- IF( GT_16( st_ivas->nchan_transport, 2 ) && NE_16( st_ivas->sba_planar, 0 ) )
+ test();
+ test();
+ IF( GT_16( st_ivas->nchan_transport, 2 ) && ( st_ivas->sba_planar != 0 ) )
{
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
}
- ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( st_ivas->hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) )
+ ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) )
{
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
+ move16();
}
}
BREAK;
@@ -99,11 +125,14 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx(
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
+ move16();
*numCldfbSyntheses = 0;
+ move16();
}
ELSE
{
*numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_ivas_fx( st_ivas );
+ move16();
}
BREAK;
case RENDERER_PARAM_ISM:
@@ -112,7 +141,9 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx(
case RENDERER_DISABLE:
/* CLDFB not used */
*numCldfbAnalyses = 0;
+ move16();
*numCldfbSyntheses = 0;
+ move16();
BREAK;
case RENDERER_MC:
case RENDERER_SBA_LINEAR_DEC:
@@ -126,37 +157,47 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx(
case RENDERER_OSBA_STEREO:
case RENDERER_OSBA_AMBI:
case RENDERER_OSBA_LS:
- IF( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) )
+ test();
+ IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
- IF( NE_16( st_ivas->sba_dirac_stereo_flag, 0 ) )
+ IF( st_ivas->sba_dirac_stereo_flag != 0 )
{
*numCldfbAnalyses = 0;
+ move16();
*numCldfbSyntheses = 0;
+ move16();
}
ELSE
{
*numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans;
+ move16();
- IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) )
+ test();
+ IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
{
*numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE;
+ move16();
}
- ELSE IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
+ ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
{
*numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans;
+ move16();
}
ELSE
{
*numCldfbSyntheses = MAX_OUTPUT_CHANNELS;
+ move16();
}
- IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
{
*numCldfbAnalyses = add( st_ivas->nchan_ism, st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans );
+ move16();
}
}
}
- ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
{
/* do nothing for ParamMC */
}
@@ -164,45 +205,60 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx(
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
+ move16();
*numCldfbSyntheses = 0;
+ move16();
}
BREAK;
case RENDERER_SBA_LINEAR_ENC:
- IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
{
*numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_ivas_fx( st_ivas );
+ move16();
}
- ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
*numCldfbSyntheses = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
+ move16();
}
- ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
{
*numCldfbAnalyses = st_ivas->nchan_transport;
+ move16();
*numCldfbSyntheses = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
+ move16();
}
ELSE
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
+ move16();
*numCldfbSyntheses = 0;
+ move16();
}
BREAK;
default:
assert( 0 && "Renderer not handled for CLDFB reservation." );
}
- IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) )
+ test();
+ test();
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) )
{
- IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
{
*numCldfbAnalyses = s_max( MC_PARAMUPMIX_MAX_INPUT_CHANS, *numCldfbAnalyses );
+ move16();
}
ELSE
{
*numCldfbAnalyses = s_max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbAnalyses );
+ move16();
}
*numCldfbSyntheses = s_max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbSyntheses );
+ move16();
}
return;
diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c
index e15b3a4213c7c10af2bdeb2c1a9bafc36fc2ca79..71a9514d80f817532a53f20685f92ae3b9945d1c 100644
--- a/lib_dec/ivas_ism_dec.c
+++ b/lib_dec/ivas_ism_dec.c
@@ -39,7 +39,7 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif // IVAS_FLOAT_FIXED
#define IVAS_FLOAT_FIXED_TO_BE_REMOVED
@@ -73,7 +73,9 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
error = IVAS_ERR_OK;
nCPE_old = st_ivas->nCPE;
+ move16();
nSCE_old = st_ivas->nSCE;
+ move16();
/* temporarily set the ism mode back to the old one, otherwise this can give wrong results*/
ism_mode = st_ivas->ism_mode;
@@ -85,7 +87,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
move16();
nchan_out_buff_old = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 );
- IF( ( error = ivas_ism_config_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ism_config_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -97,7 +99,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
* Allocate, initialize, and configure SCE/CPE/MCT handles
*-----------------------------------------------------------------*/
- IF( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, 0, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, 0, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -105,7 +107,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
/*-----------------------------------------------------------------*
* HP20 memories
*-----------------------------------------------------------------*/
- IF( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_transport_old ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_transport_old ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -155,7 +157,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
{
- IF( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -163,7 +165,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
/* JBM: when granularity goes up set samples to discard at the beginning of the frame */
ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
{
- IF( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -173,7 +175,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
IF( NE_16( st_ivas->ism_mode, last_ism_mode ) )
{
/* EFAP handle */
- efap_free_data( &st_ivas->hEFAPdata );
+ efap_free_data_fx( &st_ivas->hEFAPdata );
}
/*-----------------------------------------------------------------*
@@ -181,27 +183,30 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
*-----------------------------------------------------------------*/
/* switching from ParamISM to DiscISM */
+ test();
IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) && EQ_32( last_ism_mode, ISM_MODE_PARAM ) )
{
/* Deallocate the ParamISM struct */
ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config );
+ test();
IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
/* close the parametric binaural renderer */
ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
/* Open the TD Binaural renderer */
+ test();
IF( st_ivas->hHrtfTD == NULL || st_ivas->hBinRendererTd == NULL )
{
Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
Word16 num_src;
- IF( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
+ IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
- IF( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -212,19 +217,19 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
{
/* close the ISM renderer and reinitialize */
ivas_ism_renderer_close( &st_ivas->hIsmRendererData );
- IF( ( error = ivas_ism_renderer_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ism_renderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- IF( EQ_16( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
+ IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
{
/* close the parametric binaural renderer */
ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
/* Open Crend Binaural renderer */
- IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -235,23 +240,25 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
}
/* switching from Discrete ISM to ParamISM */
+ test();
IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && EQ_32( last_ism_mode, ISM_MODE_DISC ) )
{
/* Allocate and initialize the ParamISM struct */
- IF( ( error = ivas_param_ism_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_param_ism_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
+ test();
IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
/* open the parametric binaural renderer */
- IF( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -262,7 +269,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
st_ivas->hHrtfTD = NULL;
- IF( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
+ IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
ivas_reverb_close( &st_ivas->hReverb );
}
@@ -277,12 +284,12 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
{
/* open the parametric binaural renderer */
- IF( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -296,7 +303,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
* CLDFB instances
*-----------------------------------------------------------------*/
- IF( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -308,12 +315,12 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
{
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
- IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) )
{
return error;
}
#if 1 /* TODO: remove float code */
- if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
+ if ( NE_32( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -335,6 +342,8 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
tc_nchan_full_new = tc_nchan_tc_new;
move16();
+ test();
+ test();
IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
{
tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS;
@@ -343,6 +352,10 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
move16();
}
+ test();
+ test();
+ test();
+ test();
IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) )
{
tc_nchan_full_new = 0;
@@ -350,10 +363,13 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
}
/* reconfigure buffer */
+ test();
+ test();
+ test();
IF( NE_32( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_jbm, tc_nchan_tc_new ) ||
NE_16( hTcBuffer->nchan_buffer_full, tc_nchan_full_new ) || NE_16( hTcBuffer->nchan_transport_internal, tc_nchan_allocate_new ) )
{
- IF( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -701,34 +717,42 @@ ivas_error ivas_ism_dec_config_fx(
error = IVAS_ERR_OK;
ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
-
+ move32();
/* Assumes that num of input objects are constant */
nchan_transport_old = st_ivas->nchan_ism;
+ move16();
- IF( EQ_16( last_ism_mode, ISM_MODE_PARAM ) )
+ if ( EQ_32( last_ism_mode, ISM_MODE_PARAM ) )
{
nchan_transport_old = MAX_PARAM_ISM_WAVE;
+ move16();
}
+ test();
IF( !st_ivas->bfi && NE_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, FRAME_NO_DATA ) )
{
/* select ISM format mode */
st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->nchan_ism, ivas_total_brate );
-
+ move32();
st_ivas->nchan_transport = st_ivas->nchan_ism;
- IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ move16();
+
+ if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE;
- IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ move16();
+ if ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
st_ivas->hDecoderConfig->nchan_out = st_ivas->nchan_ism;
+ move16();
}
}
- IF( NE_16( st_ivas->ini_active_frame, 0 ) )
+ if ( st_ivas->ini_active_frame != 0 )
{
/* ISM bit-rate switching */
{
+ test();
IF( ( NE_16( st_ivas->ism_mode, last_ism_mode ) ) || ( NE_32( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) )
{
IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered,
@@ -744,17 +768,20 @@ ivas_error ivas_ism_dec_config_fx(
ELSE IF( !st_ivas->bfi && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
{
st_ivas->nchan_transport = st_ivas->nchan_ism;
- IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ move16();
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE;
- IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ move16();
+ IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
st_ivas->hDecoderConfig->nchan_out = st_ivas->nchan_ism;
+ move16();
}
}
/* ISM mode switching */
- IF( NE_16( st_ivas->ism_mode, last_ism_mode ) )
+ IF( NE_32( st_ivas->ism_mode, last_ism_mode ) )
{
IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered,
data ) ),
@@ -769,21 +796,25 @@ ivas_error ivas_ism_dec_config_fx(
{
case 1:
st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM1;
+ move32();
BREAK;
case 2:
st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM2;
+ move32();
BREAK;
case 3:
st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM3;
+ move32();
BREAK;
case 4:
st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM4;
+ move32();
BREAK;
default:
st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID;
+ move32();
BREAK;
}
-
return error;
}
#else
diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c
index 2fd8bf77b3b8177ca68ee4be2c15efdc9102599b..7a14947649abfb8232e30f4215723c0ef850f471 100644
--- a/lib_dec/ivas_ism_dtx_dec.c
+++ b/lib_dec/ivas_ism_dtx_dec.c
@@ -39,7 +39,7 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif
/*-------------------------------------------------------------------*
@@ -65,6 +65,7 @@ void ivas_ism_dtx_dec_fx(
nchan_ism_prev = st_ivas->nchan_ism;
move16();
+ test();
IF( !st_ivas->bfi && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
{
/* 'nchan_ism' was read in ivas_dec_setup() */
@@ -82,6 +83,7 @@ void ivas_ism_dtx_dec_fx(
ivas_ism_metadata_sid_dec_fx( st_ivas->hSCE, ivas_total_brate, st_ivas->bfi, nchan_ism, st_ivas->nchan_transport, st_ivas->ism_mode,
&flag_noisy_speech, &sce_id_dtx, st_ivas->hIsmMetaData, nb_bits_metadata );
+ test();
IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) && !st_ivas->bfi )
{
IF( st_ivas->hParamIsmDec != NULL )
@@ -96,7 +98,7 @@ void ivas_ism_dtx_dec_fx(
set16_fx( md_diff_flag, 1, nchan_ism );
- IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
FOR( ch = 0; ch < nchan_ism; ch++ )
{
@@ -107,7 +109,7 @@ void ivas_ism_dtx_dec_fx(
}
}
/* synch common seed between SCEs */
- IF( EQ_16( st_ivas->ism_mode, ISM_MODE_DISC ) )
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) )
{
FOR( ch = 0; ch < nchan_ism; ++ch )
{
@@ -121,6 +123,7 @@ void ivas_ism_dtx_dec_fx(
st_ivas->hISMDTX.ism_dtx_hangover_cnt = 0;
move16();
+ test();
IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) && !st_ivas->bfi )
{
FOR( ch = 0; ch < st_ivas->nchan_transport; ch++ )
@@ -137,10 +140,11 @@ void ivas_ism_dtx_dec_fx(
st = st_ivas->hSCE[ch]->hCoreCoder[0];
st->bit_stream = st_ivas->hSCE[0]->hCoreCoder[0]->bit_stream;
st->next_bit_pos = 0; /* note: needed in paramISM -> discISM switching */
- st->cng_ism_flag = 1;
move16();
+ st->cng_ism_flag = 1;
move16();
st->L_frame = s_min( st->L_frame, L_FRAME16k ); /* note: needed for switching from active frame with L_frame=640 to CNG in object with no SID */
+ move16();
}
}
diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c
index 0543b1519fe3f9391d2b9ccfbab8c90a4e5d1b45..e28a1214aef41047542358984d574657b9bec2ac 100644
--- a/lib_dec/ivas_ism_metadata_dec.c
+++ b/lib_dec/ivas_ism_metadata_dec.c
@@ -38,8 +38,7 @@
#include "ivas_rom_com.h"
#include "ivas_rom_com_fx.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_stat_enc.h"
#include
#include "wmc_auto.h"
@@ -161,6 +160,7 @@ static void ism_metadata_smooth_fx(
{
diff_fx = L_sub( diff_fx, ( ISM_AZIMUTH_MAX_FX - ISM_AZIMUTH_MIN_FX ) );
hIsmMetaData->last_azimuth_fx = L_add( hIsmMetaData->last_azimuth_fx, ( ISM_AZIMUTH_MAX_FX - ISM_AZIMUTH_MIN_FX ) );
+ move32();
}
ELSE IF( LT_32( diff_fx, ISM_AZIMUTH_MIN_FX ) )
{
@@ -174,9 +174,19 @@ static void ism_metadata_smooth_fx(
}
ELSE IF( GT_32( L_abs( diff_fx ), L_shl( CNG_MD_MAX_DIFF_AZIMUTH, Q22 ) ) )
{
- hIsmMetaData->azimuth_fx = L_add( hIsmMetaData->last_azimuth_fx, ( GE_32( diff_fx, 0 ) ? 1 : -1 ) * L_shl( CNG_MD_MAX_DIFF_AZIMUTH, Q22 ) );
+ Word32 temp;
+ IF( ( diff_fx > 0 ) )
+ {
+ temp = L_shl( CNG_MD_MAX_DIFF_AZIMUTH, Q22 );
+ }
+ ELSE
+ {
+ temp = L_negate( L_shl( CNG_MD_MAX_DIFF_AZIMUTH, Q22 ) );
+ }
+ hIsmMetaData->azimuth_fx = L_add( hIsmMetaData->last_azimuth_fx, temp );
+ move32();
}
- ELSE IF( NE_32( diff_fx, 0 ) )
+ ELSE IF( diff_fx != 0 )
{
hIsmMetaData->azimuth_fx = hIsmMetaData->last_true_azimuth_fx;
move32();
@@ -185,6 +195,7 @@ static void ism_metadata_smooth_fx(
IF( GT_32( hIsmMetaData->azimuth_fx, ISM_AZIMUTH_MAX_FX ) )
{
hIsmMetaData->azimuth_fx = L_sub( hIsmMetaData->azimuth_fx, ( ISM_AZIMUTH_MAX_FX - ISM_AZIMUTH_MIN_FX ) );
+ move32();
}
/* smooth elevation */
@@ -197,7 +208,17 @@ static void ism_metadata_smooth_fx(
}
ELSE IF( GT_32( L_abs( diff_fx ), L_shl( CNG_MD_MAX_DIFF_ELEVATION, Q22 ) ) )
{
- hIsmMetaData->elevation_fx = L_add( hIsmMetaData->last_elevation_fx, ( GE_32( diff_fx, 0 ) ? 1 : -1 ) * L_shl( CNG_MD_MAX_DIFF_ELEVATION, Q22 ) );
+ Word32 temp;
+ IF( ( diff_fx > 0 ) )
+ {
+ temp = L_shl( CNG_MD_MAX_DIFF_ELEVATION, Q22 );
+ }
+ ELSE
+ {
+ temp = L_negate( L_shl( CNG_MD_MAX_DIFF_ELEVATION, Q22 ) );
+ }
+ hIsmMetaData->elevation_fx = L_add( hIsmMetaData->last_elevation_fx, temp );
+ move32();
}
}
@@ -753,6 +774,7 @@ ivas_error ivas_ism_metadata_dec_fx(
Word16 nbands, nblocks;
Word16 md_diff_flag[MAX_NUM_OBJECTS];
ivas_error error;
+ Word32 res_dec, res_frac;
move16();
push_wmops( "ism_meta_dec" );
@@ -762,10 +784,9 @@ ivas_error ivas_ism_metadata_dec_fx(
move16();
nchan_transport_prev = *nchan_transport;
move16();
-
- last_bit_pos = extract_l( L_sub( ( ism_total_brate / FRAMES_PER_SEC ), 1 ) );
+ iDiv_and_mod_32( ism_total_brate, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ last_bit_pos = extract_l( L_sub( res_dec, 1 ) );
bstr_orig = st0->bit_stream;
- move16();
next_bit_pos_orig = st0->next_bit_pos;
move16();
st0->next_bit_pos = 0;
@@ -780,7 +801,7 @@ ivas_error ivas_ism_metadata_dec_fx(
/* reverse the bitstream for easier reading of indices */
FOR( i = 0; i < s_min( MAX_BITS_ISM_METADATA, last_bit_pos ); i++ )
{
- bstr_meta[i] = st0->bit_stream[last_bit_pos - i];
+ bstr_meta[i] = st0->bit_stream[sub( last_bit_pos, i )];
move16();
}
st0->bit_stream = bstr_meta;
@@ -797,13 +818,16 @@ ivas_error ivas_ism_metadata_dec_fx(
{
/* number of objects was read in ivas_dec_setup() */
st0->next_bit_pos = add( st0->next_bit_pos, NO_BITS_MASA_ISM_NO_OBJ );
+ move32();
}
ELSE IF( NE_32( ism_mode, ISM_MASA_MODE_DISC ) && NE_32( ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
{
/* number of objects was read in ivas_dec_setup() */
st0->next_bit_pos = add( st0->next_bit_pos, nchan_ism );
+ move16();
ism_mode = ivas_ism_mode_select( nchan_ism, ism_total_brate );
+ move16();
}
IF( EQ_32( ism_mode, ISM_MODE_PARAM ) )
@@ -932,7 +956,7 @@ ivas_error ivas_ism_metadata_dec_fx(
lowrate_metadata_flag[ch] = hIsmMeta[ch]->ism_md_lowrate_flag;
move16();
- IF( EQ_16( null_metadata_flag[ch], 0 ) )
+ IF( null_metadata_flag[ch] == 0 )
{
ism_metadata_flag_global = s_or( ism_metadata_flag_global, lowrate_metadata_flag[ch] );
}
@@ -1072,7 +1096,7 @@ ivas_error ivas_ism_metadata_dec_fx(
}
ELSE
{
- IF( EQ_16( *ism_extmeta_active, 0 ) )
+ IF( *ism_extmeta_active == 0 )
{
hIsmMetaData->yaw_fx = 0;
move32();
@@ -1187,6 +1211,7 @@ ivas_error ivas_ism_metadata_dec_fx(
{
ism_metadata_smooth_fx( hIsmMeta, ism_total_brate, nchan_ism );
hISMDTX.ism_dtx_hangover_cnt = add( hISMDTX.ism_dtx_hangover_cnt, 1 );
+ move16();
}
IF( EQ_32( ism_mode, ISM_SBA_MODE_DISC ) )
@@ -1481,7 +1506,7 @@ static void decode_angle_indices_fx(
sgn = 1;
move16();
- IF( EQ_16( get_next_indice_fx( st0, 1 ), 0 ) )
+ IF( get_next_indice_fx( st0, 1 ) == 0 )
{
nbits_diff_angle1 = 1;
move16();
@@ -1497,19 +1522,19 @@ static void decode_angle_indices_fx(
move16();
}
- nbits_diff_angle1++;
+ nbits_diff_angle1 = add( nbits_diff_angle1, 1 );
/* read until the stop bit */
WHILE( LT_16( nbits_diff_angle1, sub( ISM_AZIMUTH_NBITS, 1 ) ) && EQ_16( get_next_indice_fx( st0, 1 ), 1 ) )
{
- diff++;
- nbits_diff_angle1++;
+ diff = add( diff, 1 );
+ nbits_diff_angle1 = add( nbits_diff_angle1, 1 );
}
IF( LT_16( nbits_diff_angle1, sub( ISM_AZIMUTH_NBITS, 1 ) ) )
{
/* count stop bit */
- nbits_diff_angle1++;
+ nbits_diff_angle1 = add( nbits_diff_angle1, 1 );
}
}
idx_angle1 = add( angle->last_angle1_idx, i_mult2( sgn, diff ) );
@@ -1520,7 +1545,7 @@ static void decode_angle_indices_fx(
{
idx_angle1 = sub( idx_angle1, sub( shl( 1, ISM_AZIMUTH_NBITS ), 1 ) ); /* +180° -> -180° */
}
- ELSE IF( LT_16( idx_angle1, 0 ) )
+ ELSE IF( idx_angle1 < 0 )
{
idx_angle1 = add( idx_angle1, sub( shl( 1, ISM_AZIMUTH_NBITS ), 1 ) ); /* -180° -> +180° */
}
@@ -1534,7 +1559,7 @@ static void decode_angle_indices_fx(
/* sanity check in case of FER or BER */
test();
- IF( LT_16( idx_angle1, 0 ) || GT_16( idx_angle1, sub( shl( 1, ISM_AZIMUTH_NBITS ), 1 ) ) )
+ IF( ( idx_angle1 < 0 ) || GT_16( idx_angle1, sub( shl( 1, ISM_AZIMUTH_NBITS ), 1 ) ) )
{
idx_angle1 = angle->last_angle1_idx;
move16();
@@ -1544,11 +1569,11 @@ static void decode_angle_indices_fx(
* Elevation/pitch decoding and dequantization
*----------------------------------------------------------------*/
- IF( EQ_16( non_diegetic_flag, 0 ) )
+ IF( non_diegetic_flag == 0 )
{
/* Decode elevation/pitch index */
test();
- IF( EQ_16( *flag_abs_angle1, 0 ) && EQ_16( get_next_indice_fx( st0, 1 ), 1 ) ) /* elevation_abs_flag */
+ IF( ( *flag_abs_angle1 == 0 ) && EQ_16( get_next_indice_fx( st0, 1 ), 1 ) ) /* elevation_abs_flag */
{
idx_angle2 = get_next_indice_fx( st0, ISM_ELEVATION_NBITS );
}
@@ -1559,7 +1584,7 @@ static void decode_angle_indices_fx(
sgn = 1;
move16();
- IF( EQ_16( get_next_indice_fx( st0, 1 ), 0 ) )
+ IF( get_next_indice_fx( st0, 1 ) == 0 )
{
nbits_diff_angle2 = 1;
move16();
@@ -1596,7 +1621,7 @@ static void decode_angle_indices_fx(
/* sanity check in case of FER or BER */
test();
- IF( LT_16( idx_angle2, 0 ) || GT_16( idx_angle2, sub( shl( 1, ISM_ELEVATION_NBITS ), 1 ) ) )
+ IF( ( idx_angle2 < 0 ) || GT_16( idx_angle2, sub( shl( 1, ISM_ELEVATION_NBITS ), 1 ) ) )
{
idx_angle2 = angle->last_angle2_idx;
move16();
@@ -1798,7 +1823,7 @@ static Word16 decode_radius_fx(
sgn = 1;
move16();
- IF( EQ_16( get_next_indice_fx( st0, 1 ), 0 ) )
+ IF( get_next_indice_fx( st0, 1 ) == 0 )
{
nbits_diff_radius = 1;
move16();
@@ -1814,19 +1839,19 @@ static Word16 decode_radius_fx(
move16();
}
- nbits_diff_radius++;
+ nbits_diff_radius = add( nbits_diff_radius, 1 );
/* read until the stop bit */
WHILE( LT_16( nbits_diff_radius, ISM_RADIUS_NBITS ) && EQ_16( get_next_indice_fx( st0, 1 ), 1 ) )
{
- diff++;
- nbits_diff_radius++;
+ diff = add( diff, 1 );
+ nbits_diff_radius = add( nbits_diff_radius, 1 );
}
IF( LT_16( nbits_diff_radius, ISM_RADIUS_NBITS ) )
{
/* count stop bit */
- nbits_diff_radius++;
+ nbits_diff_radius = add( nbits_diff_radius, 1 );
}
}
idx_radius = add( *last_radius_idx, i_mult2( sgn, diff ) );
@@ -1834,7 +1859,7 @@ static Word16 decode_radius_fx(
/* sanity check in case of FER or BER */
test();
- IF( LT_16( idx_radius, 0 ) || GT_16( idx_radius, sub( shl( 1, ISM_RADIUS_NBITS ), 1 ) ) )
+ IF( ( idx_radius < 0 ) || GT_16( idx_radius, sub( shl( 1, ISM_RADIUS_NBITS ), 1 ) ) )
{
idx_radius = *last_radius_idx;
move16();
@@ -2197,7 +2222,8 @@ void ivas_ism_metadata_sid_dec_fx(
}
idx = get_next_indice_fx( st0, nBits_coh );
- hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx = div_s( idx, ( ( 1 << nBits_coh ) - 1 ) );
+ hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx = div_s( idx, sub( ( shl( 1, nBits_coh ) ), 1 ) );
+ move16();
}
}
@@ -2245,7 +2271,9 @@ void ivas_ism_metadata_sid_dec_fx(
}
/* take into account padding bits as metadata bits to keep later bitrate checks valid */
- nb_bits_metadata[*sce_id_dtx] = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC;
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( sub( IVAS_SID_5k2, SID_2k40 ), FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ nb_bits_metadata[*sce_id_dtx] = (Word16) res_dec;
move16();
/* set the bitstream pointer to its original position */
diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c
index 1d3614c37b736bf3054aa640f985cd1e71a3584a..e6d2085b38304f49c8e7ba058df22cebdda49b08 100644
--- a/lib_dec/ivas_ism_param_dec.c
+++ b/lib_dec/ivas_ism_param_dec.c
@@ -41,8 +41,7 @@
#include "ivas_rom_dec.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "debug.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_rom_com_fx.h"
@@ -70,9 +69,9 @@ static void ivas_param_ism_dec_dequant_DOA_fx(
FOR( i = 0; i < nchan_ism; i++ )
{
hParamIsmDec->azimuth_values_fx[i] = ism_dequant_meta_fx( hParamIsm->azi_index[i], ism_azimuth_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, 1 << ISM_AZIMUTH_NBITS );
- move32();
+ move16();
hParamIsmDec->elevation_values_fx[i] = ism_dequant_meta_fx( hParamIsm->ele_index[i], ism_elevation_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, 1 << ISM_ELEVATION_NBITS );
- move32();
+ move16();
}
return;
@@ -115,7 +114,7 @@ static void ivas_param_ism_dec_dequant_powrat_fx(
{
FOR( slot_idx = 0; slot_idx < hParamIsm->nblocks[band_idx]; slot_idx++ )
{
- hParamIsmDec->power_ratios_fx[band_idx][slot_idx][0] = add( shr( div_s( ( hParamIsm->power_ratios_idx[band_idx][slot_idx] ), ( ( 1 << PARAM_ISM_POW_RATIO_NBITS ) - 1 ) ), 1 ), 16384 );
+ hParamIsmDec->power_ratios_fx[band_idx][slot_idx][0] = add( shr( imult1616( hParamIsm->power_ratios_idx[band_idx][slot_idx], 4681 /* ( ( 1 << PARAM_ISM_POW_RATIO_NBITS ) - 1 ) in Q15 */ ), 1 ), 16384 ); /* Q15 */
move16();
hParamIsmDec->power_ratios_fx[band_idx][slot_idx][1] = sub( 32767, hParamIsmDec->power_ratios_fx[band_idx][slot_idx][0] );
move16();
@@ -198,14 +197,14 @@ static void ivas_ism_get_proto_matrix_fx(
{
FOR( idx = 0; idx < hOutSetup.nchan_out_woLFE; idx++ )
{
- IF( GT_32( hOutSetup.ls_azimuth_fx[idx], 0 ) )
+ IF( hOutSetup.ls_azimuth_fx[idx] > 0 )
{
proto_matrix[idx] = shl_sat( ONE_IN_Q14, 1 );
move16();
- proto_matrix[idx + hOutSetup.nchan_out_woLFE] = 0;
+ proto_matrix[add( idx, hOutSetup.nchan_out_woLFE )] = 0;
move16();
}
- ELSE IF( LT_32( hOutSetup.ls_azimuth_fx[idx], 0 ) )
+ ELSE IF( hOutSetup.ls_azimuth_fx[idx] < 0 )
{
proto_matrix[idx] = 0;
move16();
@@ -307,7 +306,7 @@ static void ivas_param_ism_collect_slot_fx(
Word16 exp_ref_power_buf[CLDFB_NO_CHANNELS_MAX];
Word16 exp_cx_diag_buf[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX];
set16_fx( exp_ref_power_buf, *exp_ref_power, CLDFB_NO_CHANNELS_MAX );
- for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ )
+ FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ )
{
set16_fx( exp_cx_diag_buf[i], *exp_cx_diag, PARAM_ISM_MAX_DMX );
}
@@ -320,17 +319,21 @@ static void ivas_param_ism_collect_slot_fx(
FOR( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ )
{
tmp_fx = 0;
+ move32();
exp_tmp = 0;
+ move32();
Word32 var1 = Mpy_32_32( Cldfb_RealBuffer_in_fx[bin_idx], Cldfb_RealBuffer_in_fx[bin_idx] ); // 2 * exp_real
Word32 var2 = Mpy_32_32( Cldfb_ImagBuffer_in_fx[bin_idx], Cldfb_ImagBuffer_in_fx[bin_idx] ); // 2 * exp_imag
tmp_fx = BASOP_Util_Add_Mant32Exp( tmp_fx, exp_tmp, var1, add( exp_real, exp_real ), &exp_tmp );
tmp_fx = BASOP_Util_Add_Mant32Exp( tmp_fx, exp_tmp, var2, add( exp_imag, exp_imag ), &exp_tmp );
Word16 exp_cx_diag_new = 0, exp_ref_power_new = 0;
+ move16();
+ move16();
cx_diag_fx[bin_idx][ch] = BASOP_Util_Add_Mant32Exp( cx_diag_fx[bin_idx][ch], exp_cx_diag_buf[bin_idx][ch], tmp_fx, exp_tmp, &exp_cx_diag_new );
- move32();
+ move16();
ref_power_fx[bin_idx] = BASOP_Util_Add_Mant32Exp( ref_power_fx[bin_idx], exp_ref_power_buf[bin_idx], tmp_fx, exp_tmp, &exp_ref_power_new );
- move32();
+ move16();
exp_cx_diag_buf[bin_idx][ch] = exp_cx_diag_new;
move16();
exp_ref_power_buf[bin_idx] = exp_ref_power_new;
@@ -340,6 +343,8 @@ static void ivas_param_ism_collect_slot_fx(
/*make common exponent*/
Word16 max_exp_cx_diag = exp_cx_diag_buf[0][0], max_exp_ref_power = exp_ref_power_buf[0];
+ move16();
+ move16();
FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ )
{
FOR( j = 0; j < PARAM_ISM_MAX_DMX; j++ )
@@ -354,12 +359,16 @@ static void ivas_param_ism_collect_slot_fx(
FOR( j = 0; j < PARAM_ISM_MAX_DMX; j++ )
{
cx_diag_fx[i][j] = L_shr_r( cx_diag_fx[i][j], sub( max_exp_cx_diag, exp_cx_diag_buf[i][j] ) );
+ move16();
}
ref_power_fx[i] = L_shr_r( ref_power_fx[i], sub( max_exp_ref_power, exp_ref_power_buf[i] ) );
+ move16();
}
*exp_cx_diag = max_exp_cx_diag;
+ move16();
*exp_ref_power = max_exp_ref_power;
+ move16();
return;
}
@@ -429,28 +438,34 @@ static void ivas_param_ism_compute_mixing_matrix_fx(
assert( ( nchan_ism == 3 ) || ( nchan_ism == 4 ) );
assert( nchan_transport == 2 );
+ test();
IF( hParamIsmDec->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag )
{
num_wave = nchan_ism;
+ move16();
}
ELSE
{
num_wave = MAX_PARAM_ISM_WAVE;
+ move16();
}
set32_fx( response_matrix_fx, 0, PARAM_ISM_MAX_CHAN * MAX_NUM_OBJECTS );
response_matrix_e = 0;
+ move16();
/* loop over parameter bands to compute the mixing matrix */
FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ )
{
brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx];
+ move16();
brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1];
+ move16();
/* Compute covaraince matrix from direct response*/
FOR( w = 0; w < num_wave; w++ )
{
set32_fx( cy_diag_tmp_fx[w], 0, nchan_out_woLFE );
-
+ test();
IF( hParamIsmDec->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag )
{
dir_res_ptr_fx = direct_response_fx[w];
@@ -458,11 +473,14 @@ static void ivas_param_ism_compute_mixing_matrix_fx(
ELSE
{
obj_indx = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][w];
+ move16();
dir_res_ptr_fx = direct_response_fx[obj_indx];
}
Copy32( dir_res_ptr_fx, response_matrix_fx + w * nchan_out_woLFE, nchan_out_woLFE ); // Q30
dir_res_ptr_e = 1;
+ move16();
response_matrix_e = 1;
+ move16();
/* we only need the diagonal of Cy*/
matrix_product_diag_fx( dir_res_ptr_fx, dir_res_ptr_e, nchan_out_woLFE, 1, 0, dir_res_ptr_fx, dir_res_ptr_e, 1, nchan_out_woLFE, 0, cy_diag_tmp_fx[w], &cy_diag_tmp_e[w] );
}
@@ -474,6 +492,7 @@ static void ivas_param_ism_compute_mixing_matrix_fx(
set16_fx( cy_diag_e_arr, 0, nchan_out_woLFE );
FOR( w = 0; w < num_wave; w++ )
{
+ test();
IF( hParamIsmDec->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag )
{
// direct_power[w] = ( 1.0f / nchan_ism ) * ref_power[bin_idx];
@@ -495,7 +514,8 @@ static void ivas_param_ism_compute_mixing_matrix_fx(
direct_power_fx[w] = Mpy_32_16_1( ref_power_fx[bin_idx], hParamIsmDec->power_ratios_fx[band_idx][0][w] );
}
direct_power_e = ref_power_e;
- IF( NE_32( direct_power_fx[w], 0 ) )
+ move16();
+ IF( direct_power_fx[w] != 0 )
{
FOR( i = 0; i < nchan_out_woLFE; i++ )
{
@@ -503,9 +523,11 @@ static void ivas_param_ism_compute_mixing_matrix_fx(
}
}
temp_e[w] = direct_power_e;
+ move16();
direct_power_fx[w] = Sqrt32( direct_power_fx[w], &temp_e[w] );
}
cy_diag_e = cy_diag_e_arr[0];
+ move16();
FOR( i = 1; i < nchan_out_woLFE; i++ )
{
cy_diag_e = s_max( cy_diag_e, cy_diag_e_arr[i] );
@@ -516,6 +538,7 @@ static void ivas_param_ism_compute_mixing_matrix_fx(
}
direct_power_e = temp_e[0];
+ move16();
FOR( w = 1; w < num_wave; w++ )
{
direct_power_e = s_max( direct_power_e, temp_e[w] );
@@ -653,12 +676,12 @@ static void ivas_param_ism_render_slot_fx(
tmp_1_fx = L_deposit_h( hParamIsmDec->hParamIsmRendering->interpolator_fx[interpolator_idx] ); /* Q31 */
Word16 res_exp = 0;
- Word16 real_buf_exp = hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp;
- Word16 imag_buf_exp = hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp;
- Word16 i, j, k;
move16();
+ Word16 real_buf_exp = hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp;
move16();
+ Word16 imag_buf_exp = hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp;
move16();
+ Word16 i, j, k;
/*exponent buffers to handle variable exp*/
Word16 exp_buf_real[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
@@ -696,7 +719,6 @@ static void ivas_param_ism_render_slot_fx(
Cldfb_ImagBuffer_fx[outchIdx][out_slot_idx][bin_idx] = BASOP_Util_Add_Mant32Exp( Cldfb_ImagBuffer_fx[outchIdx][out_slot_idx][bin_idx], imag_buf_exp,
tmp_5, res_exp + hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp, &imag_buf_exp );
move32();
-
exp_buf_real[outchIdx][out_slot_idx][bin_idx] = real_buf_exp;
move16();
exp_buf_imag[outchIdx][out_slot_idx][bin_idx] = imag_buf_exp;
@@ -932,7 +954,6 @@ static void ivas_param_ism_update_mixing_matrix_fx(
}
Copy( mixing_matrix_exp, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_old_fx, CLDFB_NO_CHANNELS_MAX );
- move16();
return;
}
@@ -978,7 +999,7 @@ ivas_error ivas_param_ism_dec_open_fx(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
)
{
- Word16 i, scale, tmp;
+ Word16 i;
PARAM_ISM_DEC_HANDLE hParamIsmDec;
IVAS_OUTPUT_SETUP hOutSetup;
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
@@ -987,7 +1008,7 @@ ivas_error ivas_param_ism_dec_open_fx(
ivas_error error;
error = IVAS_ERR_OK;
-
+ move32();
push_wmops( "ivas_param_ism_dec_open" );
/*-----------------------------------------------------------------*
@@ -1018,15 +1039,16 @@ ivas_error ivas_param_ism_dec_open_fx(
output_Fs = st_ivas->hDecoderConfig->output_Fs;
move32();
output_config = st_ivas->hDecoderConfig->output_config;
-
+ move32();
ivas_param_ism_config_fx( hParamIsmDec->hParamIsm, st_ivas->nchan_ism ); // assuming Q14 for gains;
/*-----------------------------------------------------------------*
* set input parameters
*-----------------------------------------------------------------*/
- tmp = BASOP_Util_Divide3232_Scale( output_Fs, CLDFB_BANDWIDTH, &scale ); // FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX );
- hSpatParamRendCom->slot_size = shr( tmp, 15 - scale );
+ /* hSpatParamRendCom->slot_size = (int16_t) ( ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX ); */
+ hSpatParamRendCom->slot_size = extract_l( L_shr( Mpy_32_32( output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ), 4 ) );
+ move16();
set_s( hSpatParamRendCom->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
set_s( hSpatParamRendCom->subframe_nbslots, JBM_CLDFB_SLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS );
hSpatParamRendCom->nb_subframes = DEFAULT_JBM_SUBFRAMES_5MS;
@@ -1034,12 +1056,14 @@ ivas_error ivas_param_ism_dec_open_fx(
move16();
hSpatParamRendCom->slots_rendered = 0;
move16();
-
hSpatParamRendCom->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME;
- tmp = BASOP_Util_Divide3232_Scale( output_Fs, CLDFB_BANDWIDTH, &scale );
- hSpatParamRendCom->num_freq_bands = shr( tmp, 15 - scale );
+ move16();
+ /* hSpatParamRendCom->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); */
+ hSpatParamRendCom->num_freq_bands = extract_l( Mpy_32_32( output_Fs, 2684355 /* INV_CLDFB_BANDWIDTH in Q31 */ ) );
+ move16();
hParamIsmDec->hParamIsm->nbands = MAX_PARAM_ISM_NBANDS;
+ move16();
FOR( i = 0; i < ( hParamIsmDec->hParamIsm->nbands + 1 ); i++ )
{
@@ -1058,12 +1082,13 @@ ivas_error ivas_param_ism_dec_open_fx(
*-----------------------------------------------------------------*/
/* hIntSetup and hOutSetup differs only for Binaural rendering */
- IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
/* nchan_out is essential for memory initialization for CLDFB Synthesis */
st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->nchan_ism;
move16();
st_ivas->hIntSetup.is_loudspeaker_setup = 1;
+ move16();
}
hOutSetup = st_ivas->hIntSetup;
@@ -1093,8 +1118,8 @@ ivas_error ivas_param_ism_dec_open_fx(
test();
test();
test();
- IF( !( output_config == IVAS_AUDIO_CONFIG_EXTERNAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ||
- output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) )
+ IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ||
+ EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
{
/* Initialize efap handle */
IF( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), hOutSetup.ls_azimuth_fx, hOutSetup.ls_elevation_fx, hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK )
@@ -1149,7 +1174,7 @@ ivas_error ivas_param_ism_dec_open_fx(
IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
{
nchan_full = nchan_transport;
-
+ move16();
hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx = NULL;
hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx = NULL;
}
@@ -1182,7 +1207,8 @@ ivas_error ivas_param_ism_dec_open_fx(
IF( st_ivas->hTcBuffer == NULL )
{
- IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK )
+ move16(); // NS2SA
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) )
{
return error;
@@ -1197,7 +1223,8 @@ ivas_error ivas_param_ism_dec_open_fx(
{
Word16 nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out;
move16();
- IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK )
+ move16(); // NS2SA
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1425,6 +1452,7 @@ void ivas_param_ism_dec_close_fx(
AUDIO_CONFIG output_config /* i : output audio configuration */
)
{
+ test();
IF( hParamIsmDec_out != NULL && *hParamIsmDec_out != NULL )
{
PARAM_ISM_DEC_HANDLE hParamIsmDec;
@@ -1437,7 +1465,8 @@ void ivas_param_ism_dec_close_fx(
hParamIsmDec->hParamIsm = NULL;
}
- IF( !( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
+ test();
+ IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
{
/* Param ISM Rendering */
IF( hParamIsmDec->hParamIsmRendering->interpolator_fx != NULL )
@@ -1471,9 +1500,12 @@ void ivas_param_ism_dec_close_fx(
*hParamIsmDec_out = NULL;
}
+ test();
IF( hSpatParamRendCom_out != NULL && *hSpatParamRendCom_out != NULL )
{
- IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
+ test();
+ test();
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
ivas_dirac_deallocate_parameters_fx( *hSpatParamRendCom_out, 1 );
ivas_dirac_deallocate_parameters_fx( *hSpatParamRendCom_out, 2 );
@@ -1838,9 +1870,11 @@ void ivas_ism_dec_digest_tc_fx(
/* we have a full frame interpolator, adapt it */
/* for BE testing */
- IF( EQ_16( extract_l( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available ) )
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ IF( EQ_32( extract_l( res_dec ), st_ivas->hTcBuffer->n_samples_available ) )
{
- Word16 interpolator_length = extract_l( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
+ Word16 interpolator_length = extract_l( res_dec );
test();
test();
@@ -1869,6 +1903,7 @@ void ivas_ism_dec_digest_tc_fx(
ELSE
{
ivas_jbm_dec_get_adapted_linear_interpolator_fx( (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator_fx );
+ move16();
}
/* also get the gains here */
@@ -1878,14 +1913,14 @@ void ivas_ism_dec_digest_tc_fx(
{
Copy32( st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmRendererData->prev_gains_fx[i], MAX_OUTPUT_CHANNELS );
- IF( st_ivas->intern_config == IVAS_AUDIO_CONFIG_STEREO )
+ IF( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_STEREO ) )
{
Word16 gains_fx[2];
ivas_ism_get_stereo_gains_fx( (Word16) L_shr( st_ivas->hIsmMetaData[i]->azimuth_fx, 22 ), (Word16) L_shr( st_ivas->hIsmMetaData[i]->elevation_fx, 22 ), &gains_fx[0], &gains_fx[1] );
st_ivas->hIsmRendererData->gains_fx[i][0] = L_shr( L_deposit_h( gains_fx[0] ), 1 );
- move32();
+ move16();
st_ivas->hIsmRendererData->gains_fx[i][1] = L_shr( L_deposit_h( gains_fx[1] ), 1 );
- move32();
+ move16();
}
ELSE
{
@@ -2039,9 +2074,14 @@ void ivas_param_ism_dec_digest_tc_fx(
{
Word16 exp_ref_power = 31, exp_cx_diag = 31;
Word16 exp_real_tmp = 0, exp_imag_tmp = 0;
+ move16();
+ move16();
+ move16();
+ move16();
Word32 ref_power_fx[CLDFB_NO_CHANNELS_MAX];
Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX];
Word16 q_tc = q_tc_in;
+ move16();
Word16 ch, nchan_transport, nchan_out, nchan_out_woLFE, i;
Word16 slot_idx, bin_idx;
Word32 ivas_total_brate;
@@ -2061,20 +2101,28 @@ void ivas_param_ism_dec_digest_tc_fx(
fade_len = shr( output_frame, 2 );
nchan_transport = st_ivas->nchan_transport;
+ move16();
ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
+ move32();
hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp = 25;
+ move16();
hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = 25;
- IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ move16();
+ IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
nchan_out = st_ivas->nchan_ism;
+ move16();
nchan_out_woLFE = nchan_out;
+ move16();
st_ivas->hDecoderConfig->nchan_out = nchan_out;
+ move16();
}
ELSE
{
- nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
+ nchan_out = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE;
+ move16();
}
push_wmops( "ivas_param_ism_dec" );
@@ -2090,24 +2138,29 @@ void ivas_param_ism_dec_digest_tc_fx(
set_zero_fx( cx_diag_fx[bin_idx], PARAM_ISM_MAX_DMX );
}
exp_cx_diag = 0;
+ move16();
set_zero_fx( ref_power_fx, CLDFB_NO_CHANNELS_MAX );
exp_ref_power = 0;
+ move16();
/* Frame-level Processing */
/* De-quantization */
+ test();
IF( !( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) )
{
ivas_param_ism_dec_dequant_DOA_fx( hParamIsmDec, st_ivas->nchan_ism );
ivas_param_ism_dec_dequant_powrat_fx( hParamIsmDec );
st_ivas->hISMDTX.dtx_flag = 0;
+ move16();
}
ELSE
{
st_ivas->hISMDTX.dtx_flag = 1;
+ move16();
}
/* obtain the direct response using EFAP */
- IF( !( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) )
+ IF( !( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) )
{
FOR( i = 0; i < st_ivas->nchan_ism; i++ )
{
@@ -2125,10 +2178,12 @@ void ivas_param_ism_dec_digest_tc_fx(
IF( EQ_16( i, j ) )
{
direct_response_fx[i][j] = ONE_IN_Q30;
+ move32();
}
ELSE
{
direct_response_fx[i][j] = 0;
+ move32();
}
}
}
@@ -2138,19 +2193,25 @@ void ivas_param_ism_dec_digest_tc_fx(
IF( GT_32( hParamIsmDec->azimuth_values_fx[j], 0 ) )
{
hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j] = 32767;
+ move16();
hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j] = 0;
+ move16();
}
ELSE
{
IF( LT_32( hParamIsmDec->azimuth_values_fx[j], 0 ) )
{
hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j] = 0;
+ move16();
hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j] = 32767;
+ move16();
}
ELSE /* == 0.0f */
{
hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j] = ONE_IN_Q14;
+ move16();
hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j] = ONE_IN_Q14;
+ move16();
}
}
}
@@ -2167,6 +2228,7 @@ void ivas_param_ism_dec_digest_tc_fx(
scale_sig32( transport_channels[i], output_frame, sub( q_tc_in, q_tc ) );
}
q_tc = q_tc_in;
+ move16();
}
}
@@ -2180,6 +2242,7 @@ void ivas_param_ism_dec_digest_tc_fx(
Word32 RealBuffer_fx[CLDFB_NO_CHANNELS_MAX];
Word32 ImagBuffer_fx[CLDFB_NO_CHANNELS_MAX];
q_tc = q_tc_in;
+ move16();
cldfbAnalysis_ts_fx_fixed_q( &( transport_channels[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch], &q_tc );
Copy32( RealBuffer_fx, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands );
Copy32( ImagBuffer_fx, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands );
@@ -2187,27 +2250,30 @@ void ivas_param_ism_dec_digest_tc_fx(
hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = sub( 31, q_tc );
}
Word16 scale_factor_real, scale_factor_imag;
-
+ Word16 current_idx;
exp_real_tmp = hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp;
+ move16();
exp_imag_tmp = hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp;
- scale_factor_real = getScaleFactor32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands );
- scale_factor_imag = getScaleFactor32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands );
- scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands, scale_factor_real );
- scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands, scale_factor_imag );
- exp_real_tmp -= scale_factor_real;
- exp_imag_tmp -= scale_factor_imag;
+ move16();
+ current_idx = add( imult1616( imult1616( slot_idx, hSpatParamRendCom->num_freq_bands ), nchan_transport ), imult1616( ch, hSpatParamRendCom->num_freq_bands ) );
+ scale_factor_real = getScaleFactor32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands );
+ scale_factor_imag = getScaleFactor32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands );
+ scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, scale_factor_real );
+ scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, scale_factor_imag );
+ exp_real_tmp = sub( exp_real_tmp, scale_factor_real );
+ exp_imag_tmp = sub( exp_imag_tmp, scale_factor_imag );
ivas_param_ism_collect_slot_fx( hParamIsmDec,
- &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands],
+ &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx],
exp_real_tmp,
- &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands],
+ &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx],
exp_imag_tmp,
ch,
ref_power_fx, &exp_ref_power, cx_diag_fx, &exp_cx_diag );
- exp_real_tmp += scale_factor_real;
- exp_imag_tmp += scale_factor_imag;
- scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands, -scale_factor_real );
- scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands, -scale_factor_imag );
+ exp_real_tmp = add( exp_real_tmp, scale_factor_real );
+ exp_imag_tmp = add( exp_imag_tmp, scale_factor_imag );
+ scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, -scale_factor_real );
+ scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx], hSpatParamRendCom->num_freq_bands, -scale_factor_imag );
}
}
/* Obtain Mixing Matrix on a frame-level */
@@ -2492,9 +2558,13 @@ void ivas_ism_param_dec_tc_gain_ajust_fx(
FOR( i = 0; i < nSamples; i++ )
{
ch0_e = 0;
+ move16();
ch1_e = 0;
+ move16();
ch0 = transport_channels_f[0][i];
+ move16();
ch1 = transport_channels_f[1][i];
+ move16();
ch0 = BASOP_Util_Add_Mant32Exp( ch0, ch0_e, 0, 0, &ch0_e );
ch1 = BASOP_Util_Add_Mant32Exp( ch1, ch1_e, 0, 0, &ch1_e );
@@ -2521,11 +2591,20 @@ void ivas_ism_param_dec_tc_gain_ajust_fx(
}
ELSE
{
- /*handling denominator equals to zero*/
- gain_fx = 1;
- move16();
- tmp_e1 = -32767;
- move16();
+ IF( ene_tc_fx == 0 ) /*handling numerator equals to zero*/
+ {
+ gain_fx = 0;
+ move16();
+ tmp_e1 = 31;
+ move16();
+ }
+ ELSE
+ { /*handling denominator equals to zero*/
+ gain_fx = 1;
+ move16();
+ tmp_e1 = -32767;
+ move16();
+ }
}
tmp_e1 = add( tmp_e1, sub( ene_tc_e, ene_sum_e ) ); /* tmp_e1 + (ene_tc_e - ene_sum_e)*/
gain_fx = Sqrt16( gain_fx, &tmp_e1 );
@@ -2590,7 +2669,7 @@ void ivas_ism_param_dec_tc_gain_ajust_fx(
move16();
*Q_tc = sub( *Q_tc, tmp_e1 );
-
+ move16();
return;
}
#endif
@@ -2626,8 +2705,9 @@ static void ivas_ism_param_dec_render_sf_fx(
hParamIsmDec = st_ivas->hParamIsmDec;
hSpatParamRendCom = st_ivas->hSpatParamRendCom;
slot_idx_start = hSpatParamRendCom->slots_rendered;
+ move16();
subframe_idx = hSpatParamRendCom->subframes_rendered;
-
+ move16();
/* Set some memories to zero */
FOR( ch = 0; ch < nchan_out_woLFE; ch++ )
{
@@ -2644,16 +2724,20 @@ static void ivas_ism_param_dec_render_sf_fx(
FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ )
{
index_slot = slot_idx_start + slot_idx;
+ move16();
FOR( ch = 0; ch < nchan_transport; ch++ )
{
- Cldfb_RealBuffer_in_fx[ch] = &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[index_slot * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands]; // Q11
- Cldfb_ImagBuffer_in_fx[ch] = &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[index_slot * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands]; // Q11
+ Word16 cldfb_idx = add( imult1616( imult1616( index_slot, hSpatParamRendCom->num_freq_bands ), nchan_transport ), imult1616( ch, hSpatParamRendCom->num_freq_bands ) );
+ Cldfb_RealBuffer_in_fx[ch] = &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[cldfb_idx]; // Q11
+ Cldfb_ImagBuffer_in_fx[ch] = &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[cldfb_idx]; // Q11
}
/* Compute bandwise rendering to target LS using covariance rendering */
real_exp[slot_idx] = 0;
+ move16();
imag_exp[slot_idx] = 0;
+ move16();
ivas_param_ism_render_slot_fx( hParamIsmDec, hSpatParamRendCom,
Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &real_exp[slot_idx], &imag_exp[slot_idx],
hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx,
@@ -2662,20 +2746,22 @@ static void ivas_ism_param_dec_render_sf_fx(
/* CLDFB Synthesis */
idx_in = 0;
+ move16();
idx_lfe = 0;
+ move16();
// Word16 tmp_buff_Q[MAX_OUTPUT_CHANNELS];
FOR( ch = 0; ch < nchan_out; ch++ )
{
- IF( ( hSetup.num_lfe > 0 ) && ( hSetup.index_lfe[idx_lfe] == ch ) )
+ test();
+ IF( ( hSetup.num_lfe > 0 ) && EQ_16( hSetup.index_lfe[idx_lfe], ch ) )
{
set32_fx( output_f_fx[ch], 0, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->num_freq_bands ) );
- IF( idx_lfe < sub( hSetup.num_lfe, 1 ) )
+ IF( LT_16( idx_lfe, sub( hSetup.num_lfe, 1 ) ) )
{
idx_lfe = add( idx_lfe, 1 );
}
- // tmp_buff_Q[ch] = 0;
}
ELSE
{
@@ -2684,6 +2770,7 @@ static void ivas_ism_param_dec_render_sf_fx(
Word32 *ImagBuffer_fx[16];
Word16 Q_real = 31;
+ move16();
FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ )
{
@@ -2702,30 +2789,38 @@ static void ivas_ism_param_dec_render_sf_fx(
}
Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( sub( Q_real, 1 ), Q11 ) );
- st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q_real - 1;
+ st_ivas->cldfbSynDec[ch]->Q_cldfb_state = sub( Q_real, 1 );
+ move16();
cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_f_fx[ch], hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] );
Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( Q11, sub( Q_real, 1 ) ) );
st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11;
+ move16();
/*scaling the output_f buffer to have common Q accross the buffer*/
- samplesProcessed = hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx];
+ samplesProcessed = imult1616( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] );
no_col_cldfb = st_ivas->cldfbSynDec[ch]->no_col;
+ move16();
IF( GT_16( samplesProcessed, -1 ) )
{
- no_col_cldfb = min( no_col_cldfb, ( samplesProcessed + st_ivas->cldfbSynDec[ch]->no_channels - 1 ) / st_ivas->cldfbSynDec[ch]->no_channels );
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( sub( add( samplesProcessed, st_ivas->cldfbSynDec[ch]->no_channels ), 1 ), st_ivas->cldfbSynDec[ch]->no_channels, &res_dec, &res_frac, 0 );
+ no_col_cldfb = s_min( no_col_cldfb, extract_l( res_dec ) );
move16();
}
- size_cldfb = st_ivas->cldfbSynDec[ch]->no_channels * no_col_cldfb;
+ size_cldfb = imult1616( st_ivas->cldfbSynDec[ch]->no_channels, no_col_cldfb );
Scale_sig32( output_f_fx[ch], size_cldfb, sub( Q11, sub( Q_real, 1 ) ) );
Q_output[ch] = sub( Q_real, 1 );
+ move16();
idx_in = add( idx_in, 1 );
}
}
hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe_idx] );
+ move16();
hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 );
+ move16();
return;
}
@@ -2850,25 +2945,37 @@ void ivas_param_ism_dec_render_fx(
hSpatParamRendCom = st_ivas->hSpatParamRendCom;
hSetup = st_ivas->hIntSetup;
nchan_transport = st_ivas->nchan_transport;
+ move16();
- IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
+ IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
nchan_out = st_ivas->nchan_ism;
+ move16();
nchan_out_woLFE = nchan_out;
+ move16();
st_ivas->hDecoderConfig->nchan_out = nchan_out;
+ move16();
}
ELSE
{
nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
+ move16();
nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE;
+ move16();
}
slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
-
+ move16();
/* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
- slots_to_render = min( hSpatParamRendCom->num_slots - hSpatParamRendCom->slots_rendered, nSamplesAsked / slot_size );
- *nSamplesRendered = slots_to_render * slot_size;
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( nSamplesAsked, slot_size, &res_dec, &res_frac, 0 );
+
+ slots_to_render = s_min( sub( hSpatParamRendCom->num_slots, hSpatParamRendCom->slots_rendered ), extract_l( res_dec ) );
+ *nSamplesRendered = imult1616( slots_to_render, extract_l( slot_size ) );
+ move16();
first_sf = hSpatParamRendCom->subframes_rendered;
+ move16();
last_sf = first_sf;
+ move16();
WHILE( slots_to_render > 0 )
{
@@ -2892,7 +2999,7 @@ void ivas_param_ism_dec_render_fx(
}
}
- IF( hSpatParamRendCom->slots_rendered == hSpatParamRendCom->num_slots )
+ IF( EQ_16( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->num_slots ) )
{
/* copy the memories */
/* store mixing matrix for next subframe */
@@ -2901,20 +3008,24 @@ void ivas_param_ism_dec_render_fx(
/* store MetaData parameters */
FOR( ch = 0; ch < st_ivas->nchan_ism; ch++ )
{
- IF( st_ivas->hParamIsmDec->azimuth_values_fx[ch] > 754974720 /*180.f in Q22*/ )
+ IF( GT_32( st_ivas->hParamIsmDec->azimuth_values_fx[ch], 754974720 ) /*180.f in Q22*/ )
{
st_ivas->hIsmMetaData[ch]->azimuth_fx = L_sub( st_ivas->hParamIsmDec->azimuth_values_fx[ch], 1509949440 ) /*360.0F in Q22*/;
+ move32();
}
ELSE
{
st_ivas->hIsmMetaData[ch]->azimuth_fx = st_ivas->hParamIsmDec->azimuth_values_fx[ch];
+ move32();
}
st_ivas->hIsmMetaData[ch]->elevation_fx = st_ivas->hParamIsmDec->elevation_values_fx[ch];
+ move32();
}
}
- *nSamplesAvailableNext = ( hSpatParamRendCom->num_slots - hSpatParamRendCom->slots_rendered ) * slot_size;
+ *nSamplesAvailableNext = imult1616( sub( hSpatParamRendCom->num_slots, hSpatParamRendCom->slots_rendered ), (Word16) slot_size );
+ move16();
return;
}
@@ -3030,11 +3141,11 @@ void ivas_param_ism_params_to_masa_param_mapping_fx(
hParamIsmDec = st_ivas->hParamIsmDec;
hSpatParamRendCom = st_ivas->hSpatParamRendCom;
nBins = hSpatParamRendCom->num_freq_bands;
-
move16();
ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
move32();
+ test();
IF( !( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) )
{
ivas_param_ism_dec_dequant_DOA_fx( hParamIsmDec, st_ivas->nchan_ism );
@@ -3057,24 +3168,24 @@ void ivas_param_ism_params_to_masa_param_mapping_fx(
hSpatParamRendCom->numSimultaneousDirections = 1;
move16();
- azimuth[0] = (Word16) L_shr( ( hParamIsmDec->azimuth_values_fx[0] + ( 1 << 21 ) ), 22 );
- elevation[0] = (Word16) L_shr( ( hParamIsmDec->elevation_values_fx[0] + ( 1 << 21 ) ), 22 );
+ azimuth[0] = (Word16) L_shr( L_add( hParamIsmDec->azimuth_values_fx[0], ONE_IN_Q21 ), 22 );
+ move16();
+ elevation[0] = (Word16) L_shr( L_add( hParamIsmDec->elevation_values_fx[0], ONE_IN_Q21 ), 22 );
+ move16();
FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
{
FOR( bin_idx = 0; bin_idx < nBins; bin_idx++ )
{
hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0];
+ move16();
hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0];
-
- hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = energy_ratio_fx;
-
- hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = 0;
- hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0;
move16();
+ hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = energy_ratio_fx;
move16();
- move32();
+ hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = 0;
move16();
+ hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0;
move16();
}
}
@@ -3086,19 +3197,21 @@ void ivas_param_ism_params_to_masa_param_mapping_fx(
FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ )
{
brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx];
- brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1];
-
move16();
+ brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1];
move16();
+
azimuth[0] = (Word16) L_shr( hParamIsmDec->azimuth_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] + ( 1 << 21 ), 22 );
+ move16();
elevation[0] = (Word16) L_shr( hParamIsmDec->elevation_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] + ( 1 << 21 ), 22 );
-
+ move16();
power_ratio_fx[0] = hParamIsmDec->power_ratios_fx[band_idx][0][0];
move16();
azimuth[1] = (Word16) L_shr( hParamIsmDec->azimuth_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] + ( 1 << 21 ), 22 );
+ move16();
elevation[1] = (Word16) L_shr( hParamIsmDec->elevation_values_fx[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] + ( 1 << 21 ), 22 );
+ move16();
power_ratio_fx[1] = hParamIsmDec->power_ratios_fx[band_idx][0][1];
-
move16();
FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
@@ -3106,16 +3219,16 @@ void ivas_param_ism_params_to_masa_param_mapping_fx(
FOR( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ )
{
hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0];
+ move16();
hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0];
+ move16();
hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = L_shl( power_ratio_fx[0], Q15 );
+ move32();
hSpatParamRendCom->azimuth2[sf_idx][bin_idx] = azimuth[1];
- hSpatParamRendCom->elevation2[sf_idx][bin_idx] = elevation[1];
- hSpatParamRendCom->energy_ratio2_fx[sf_idx][bin_idx] = L_shl( power_ratio_fx[1], Q15 );
- move16();
- move16();
move16();
+ hSpatParamRendCom->elevation2[sf_idx][bin_idx] = elevation[1];
move16();
- move32();
+ hSpatParamRendCom->energy_ratio2_fx[sf_idx][bin_idx] = L_shl( power_ratio_fx[1], Q15 );
move32();
}
}
@@ -3126,10 +3239,10 @@ void ivas_param_ism_params_to_masa_param_mapping_fx(
FOR( bin_idx = 0; bin_idx < nBins; bin_idx++ )
{
hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = 0;
- hSpatParamRendCom->spreadCoherence2_fx[sf_idx][bin_idx] = 0;
- hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0;
move16();
+ hSpatParamRendCom->spreadCoherence2_fx[sf_idx][bin_idx] = 0;
move16();
+ hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0;
move16();
}
}
@@ -3140,21 +3253,23 @@ void ivas_param_ism_params_to_masa_param_mapping_fx(
hSpatParamRendCom->numSimultaneousDirections = 1;
move16();
azimuth[0] = (Word16) L_shr( ( hParamIsmDec->azimuth_values_fx[0] + ( 1 << 21 ) ), 22 );
+ move16();
elevation[0] = (Word16) L_shr( hParamIsmDec->elevation_values_fx[0] + ( 1 << 21 ), 22 );
+ move16();
FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
{
FOR( bin_idx = 0; bin_idx < nBins; bin_idx++ )
{
hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0];
- hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0];
- hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = ONE_IN_Q30; /* 1.0f in Q30 */
- hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = 0;
- hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0;
move16();
+ hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0];
move16();
+ hSpatParamRendCom->energy_ratio1_fx[sf_idx][bin_idx] = ONE_IN_Q30; /* 1.0f in Q30 */
move32();
+ hSpatParamRendCom->spreadCoherence_fx[sf_idx][bin_idx] = 0;
move16();
+ hSpatParamRendCom->surroundingCoherence_fx[sf_idx][bin_idx] = 0;
move16();
}
}
diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c
index f766a5b959c7f4505fe064683d7186fef73812a7..7950e6db5d308a27e3753be85c1c5daa211cd8ef 100644
--- a/lib_dec/ivas_ism_renderer.c
+++ b/lib_dec/ivas_ism_renderer.c
@@ -34,7 +34,7 @@
#include "options.h"
#include "ivas_cnst.h"
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "ivas_prot_rend.h"
@@ -127,9 +127,12 @@ ivas_error ivas_ism_renderer_open_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISM renderer\n" ) );
}
+ test();
+ test();
+ test();
IF( st_ivas->hIntSetup.is_loudspeaker_setup && st_ivas->hIntSetup.ls_azimuth_fx != NULL && st_ivas->hIntSetup.ls_elevation_fx != NULL && st_ivas->hEFAPdata == NULL )
{
- IF( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -143,14 +146,18 @@ ivas_error ivas_ism_renderer_open_fx(
IF( st_ivas->hDecoderConfig->Opt_tsm )
{
+ Word32 res_dec, res_frac;
init_interpolator_length = NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_CLDFB_TIMESLOTS * CLDFB_SLOT_NS );
move16();
- interpolator_length = (UWord16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
+ iDiv_and_mod_32( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ interpolator_length = (UWord16) ( res_dec );
move16();
}
ELSE
{
- init_interpolator_length = (UWord16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
+ Word32 res_dec, res_frac;
+ iDiv_and_mod_32( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC, &res_dec, &res_frac, 0 );
+ init_interpolator_length = (UWord16) ( res_dec );
move16();
interpolator_length = init_interpolator_length;
move16();
@@ -163,11 +170,13 @@ ivas_error ivas_ism_renderer_open_fx(
st_ivas->hIsmRendererData->interpolator_len = init_interpolator_length;
move16();
- FOR( i = 0; i < interpolator_length - 1; i++ )
+ FOR( i = 0; i < sub( interpolator_length, 1 ); i++ )
{
st_ivas->hIsmRendererData->interpolator_fx[i] = div_s( i, sub( interpolator_length, 1 ) );
+ move16();
}
- st_ivas->hIsmRendererData->interpolator_fx[interpolator_length - 1] = 32767;
+ st_ivas->hIsmRendererData->interpolator_fx[sub( interpolator_length, 1 )] = 32767;
+ move16();
return IVAS_ERR_OK;
}
@@ -205,6 +214,7 @@ void ivas_ism_renderer_close(
ISM_RENDERER_HANDLE *hIsmRendererData /* i/o: ISM renderer handle */
)
{
+ test();
IF( hIsmRendererData == NULL || *hIsmRendererData == NULL )
{
return;
@@ -378,7 +388,7 @@ void ivas_ism_render_sf_fx(
num_objects = st_ivas->nchan_transport;
move16();
- IF( st_ivas->ivas_format == SBA_ISM_FORMAT )
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
num_objects = st_ivas->nchan_ism;
move16();
@@ -397,7 +407,6 @@ void ivas_ism_render_sf_fx(
FOR( i = 0; i < num_objects; i++ )
{
p_tc_fx[i] = &st_ivas->hTcBuffer->tc_fx[i][tc_offset];
- move16();
}
}
ELSE
@@ -406,7 +415,6 @@ void ivas_ism_render_sf_fx(
{
mvl2l( &output_fx[i][tc_offset], tc_local_fx[i], n_samples_to_render );
p_tc_fx[i] = tc_local_fx[i];
- move16();
}
}
@@ -415,7 +423,8 @@ void ivas_ism_render_sf_fx(
set32_fx( output_fx[i], 0, n_samples_to_render );
}
- IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 )
+ test();
+ IF( st_ivas->hCombinedOrientationData && EQ_16( st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx], 1 ) )
{
ivas_jbm_dec_get_adapted_linear_interpolator_fx( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator_fx );
interp_offset = 0;
@@ -425,11 +434,12 @@ void ivas_ism_render_sf_fx(
FOR( i = 0; i < num_objects; i++ )
{
/* Combined rotation: rotate the object positions depending the head and external orientations */
- IF( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 )
+ test();
+ IF( st_ivas->hCombinedOrientationData != NULL && EQ_16( st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx], 1 ) )
{
rotateAziEle_fx( (Word16) L_shr( st_ivas->hIsmMetaData[i]->azimuth_fx, 22 ), (Word16) L_shr( st_ivas->hIsmMetaData[i]->elevation_fx, 22 ), &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat_fx[0], st_ivas->hIntSetup.is_planar_setup );
- move32();
- move32();
+ move16();
+ move16();
IF( st_ivas->hEFAPdata != NULL )
{
@@ -441,18 +451,27 @@ void ivas_ism_render_sf_fx(
move16();
FOR( ( j = 0, j2 = 0 ); j < nchan_out_woLFE; ( j++, j2++ ) )
{
- IF( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( st_ivas->hIntSetup.index_lfe[lfe_index] == j ) )
+ test();
+ IF( ( st_ivas->hIntSetup.num_lfe > 0 ) && EQ_16( st_ivas->hIntSetup.index_lfe[lfe_index], j ) )
{
- ( lfe_index < ( st_ivas->hIntSetup.num_lfe - 1 ) ) ? ( lfe_index++, j2++ ) : j2++;
- move16();
- move16();
+ IF( LE_16( lfe_index, sub( st_ivas->hIntSetup.num_lfe, 1 ) ) )
+ {
+ lfe_index = add( lfe_index, 1 );
+ j2 = add( j2, 1 );
+ }
+ ELSE
+ {
+ j2 = add( j2, 1 );
+ }
}
gain_fx = st_ivas->hIsmRendererData->gains_fx[i][j];
move32();
prev_gain_fx = st_ivas->hIsmRendererData->prev_gains_fx[i][j];
move32();
- IF( GT_32( L_abs( gain_fx ), 0 ) || GT_32( L_abs( prev_gain_fx ), 0 ) )
+
+ test();
+ IF( ( L_abs( gain_fx ) > 0 ) || ( L_abs( prev_gain_fx ) > 0 ) )
{
g1_fx = &st_ivas->hIsmRendererData->interpolator_fx[interp_offset];
tc_fx = p_tc_fx[i];
@@ -460,10 +479,12 @@ void ivas_ism_render_sf_fx(
{
g2_fx = sub( 32767, *g1_fx );
output_fx[j2][k] = L_add( output_fx[j2][k], L_shl( Mpy_32_32( L_add( Mpy_32_16_1( gain_fx, *( g1_fx++ ) ), Mpy_32_16_1( prev_gain_fx, g2_fx ) ), *( tc_fx++ ) ), 1 ) );
+ move16();
}
}
/* update here only in case of head rotation */
+ test();
IF( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 )
{
st_ivas->hIsmRendererData->prev_gains_fx[i][j] = gain_fx;
@@ -593,7 +614,6 @@ void ivas_ism_get_stereo_gains(
}
#endif
-
/*-------------------------------------------------------------------------*
* ivas_masa_oism_separate_object_renderer_open()
*
@@ -675,9 +695,11 @@ ivas_error ivas_omasa_separate_object_renderer_open(
{
set32_fx( st_ivas->hIsmRendererData->prev_gains_fx[i], 0, MAX_OUTPUT_CHANNELS );
}
-
- init_interpolator_length = (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES );
- move32();
+ Word32 res_dec1, res_frac1;
+ Word32 res_dec2, res_frac2;
+ iDiv_and_mod_32( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC, &res_dec1, &res_frac1, 0 );
+ iDiv_and_mod_32( res_dec1, MAX_PARAM_SPATIAL_SUBFRAMES, &res_dec2, &res_frac2, 0 );
+ init_interpolator_length = extract_l( res_dec2 );
interpolator_length = init_interpolator_length;
move16();
@@ -685,18 +707,21 @@ ivas_error ivas_omasa_separate_object_renderer_open(
#if 1 /*TODO: To be removed later: Stores length of interpolator_fx*/
st_ivas->hIsmRendererData->interpolator_len = init_interpolator_length;
+ move16();
#endif
FOR( i = 0; i < interpolator_length; i++ )
{
st_ivas->hIsmRendererData->interpolator_fx[i] = div_s( i, interpolator_length );
+ move16();
}
st_ivas->hIsmRendererData->interpolator_len = interpolator_length;
move16();
- st_ivas->hMasaIsmData->delayBuffer_size = (Word16) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES );
+ st_ivas->hMasaIsmData->delayBuffer_size = extract_l( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES );
move16();
- IF( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
+ 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 ) )
{
st_ivas->hMasaIsmData->delayBuffer_nchan = 1;
move16();
@@ -1000,22 +1025,25 @@ void ivas_omasa_separate_object_render_jbm_fx(
lfe_index = hDirACRend->hOutSetup.index_lfe[0];
move16();
- IF( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
+ 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 ) )
{
single_separated = 1;
+ move16();
num_objects = 1;
move16();
}
ELSE
{
single_separated = 0;
+ move16();
num_objects = st_ivas->nchan_ism;
move16();
}
offsetSamples = i_mult( slots_rendered, hSpatParamRendCom->slot_size );
- FOR( j = 0; j < nchan_out_woLFE + num_lfe; j++ )
+ FOR( j = 0; j < add( nchan_out_woLFE, num_lfe ); j++ )
{
output_fx_local[j] = output_fx[j];
}
@@ -1035,8 +1063,7 @@ void ivas_omasa_separate_object_render_jbm_fx(
}
}
- slots_to_render = nSamplesRendered / hSpatParamRendCom->slot_size;
- move16();
+ slots_to_render = idiv1616( nSamplesRendered, hSpatParamRendCom->slot_size );
first_sf = subframes_rendered;
move16();
last_sf = first_sf;
@@ -1059,6 +1086,7 @@ void ivas_omasa_separate_object_render_jbm_fx(
delay_signal_fx( input_fx[obj], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer_fx[obj], st_ivas->hMasaIsmData->delayBuffer_size );
}
offsetSamples = 0;
+ move16();
FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ )
{
@@ -1091,7 +1119,7 @@ void ivas_omasa_separate_object_render_jbm_fx(
move16();
}
- IF( st_ivas->hOutSetup.is_planar_setup )
+ if ( st_ivas->hOutSetup.is_planar_setup )
{
/* If no elevation support in output format, then rendering should be done with zero elevation */
elevation = 0;
@@ -1109,7 +1137,7 @@ void ivas_omasa_separate_object_render_jbm_fx(
FOR( j = 0; j < nchan_out_woLFE; j++ )
{
- IF( GT_16( hDirACRend->hOutSetup.num_lfe, 0 ) )
+ IF( hDirACRend->hOutSetup.num_lfe > 0 )
{
j2 = add( j, (Word16) GE_16( j, lfe_index ) );
}
@@ -1119,15 +1147,16 @@ void ivas_omasa_separate_object_render_jbm_fx(
move16();
}
- IF( GT_32( L_abs( gains_fx[j] ), 0 ) || GT_32( L_abs( hRendererData->prev_gains_fx[obj][j] ), 0 ) )
+ test();
+ IF( ( L_abs( gains_fx[j] ) > 0 ) || ( L_abs( hRendererData->prev_gains_fx[obj][j] ) > 0 ) )
{
FOR( k = 0; k < n_samples_sf; k++ )
{
g1_fx = hRendererData->interpolator_fx[k];
move16();
g2_fx = sub( 32767, g1_fx );
- move16();
- output_fx_local[j2][k + offsetSamples] = L_add( output_fx_local[j2][k + offsetSamples], L_add( L_shl( Mpy_32_32( Mpy_32_16_1( input_fx[obj][k + offsetSamples], g1_fx ), gains_fx[j] ), 2 ), L_shl( Mpy_32_32( Mpy_32_16_1( input_fx[obj][k + offsetSamples], g2_fx ), hRendererData->prev_gains_fx[obj][j] ), 2 ) ) );
+
+ output_fx_local[j2][k + offsetSamples] = L_add( output_fx_local[j2][add( k, offsetSamples )], L_add( L_shl( Mpy_32_32( Mpy_32_16_1( input_fx[obj][k + offsetSamples], g1_fx ), gains_fx[j] ), 2 ), L_shl( Mpy_32_32( Mpy_32_16_1( input_fx[obj][add( k, offsetSamples )], g2_fx ), hRendererData->prev_gains_fx[obj][j] ), 2 ) ) );
}
}
hRendererData->prev_gains_fx[obj][j] = gains_fx[j];
diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c
index 7891c7baa0df8cea4e5e5365fddd2f307d73d9eb..42605102d49f808fde851cef2c99daa509b75f85 100644
--- a/lib_dec/ivas_jbm_dec.c
+++ b/lib_dec/ivas_jbm_dec.c
@@ -46,8 +46,7 @@
#ifdef DUMPS_ENABLED
#include "debug.h"
#endif // DUMPS_ENABLED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#define float_to_fixed( n, factor ) ( round( n * ( 1 << factor ) ) )
#define fixed_to_float( n, factor ) ( (float) n / ( 1 << factor ) )
@@ -3039,6 +3038,16 @@ ivas_error ivas_jbm_dec_render_fx(
{
return error;
}
+
+ test();
+ IF( st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) )
+ {
+ FOR( i = 0; i < nchan_in; i++ )
+ {
+ scale_sig32( p_tc_fx[i], *nSamplesRendered, -Q2 );
+ }
+ }
+
ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx );
FOR( i = 0; i < nchan_in; i++ )
@@ -5455,8 +5464,8 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx(
}
ELSE
{
- tmp = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC, &tmp_e );
- n_samp_full = shr( tmp, sub( 15, tmp_e ) ); // Q0
+ /* n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); */
+ n_samp_full = extract_l( Mpy_32_32( st_ivas->hDecoderConfig->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
n_samp_residual = 0;
move16();
}
@@ -5926,19 +5935,18 @@ void ivas_jbm_dec_td_renderers_adapt_subframes(
Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, exp, tmp1, tmp2, s1, s2;
UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe;
- // nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity;
- tmp = BASOP_Util_Divide3216_Scale( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &exp );
- tmp = shr( tmp, -1 - exp );
+ /* nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; */
+ tmp = extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) );
tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &exp );
nMaxSlotsPerSubframe = shr( tmp, ( 15 - exp ) );
- // nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity;
+ /* nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; */
tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &exp );
nSlotsAvailable = shr( tmp, ( 15 - exp ) );
st_ivas->hTcBuffer->num_slots = nSlotsAvailable;
move16();
- // st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity;
+ /* st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; */
st_ivas->hTcBuffer->n_samples_available = i_mult( nSlotsAvailable, st_ivas->hTcBuffer->n_samples_granularity );
nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] );
st_ivas->hTcBuffer->nb_subframes = 0;
diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c
index f615bbd1ea4f1b8c5e8b8c3d52dfae635b6dc4b4..775535614d42349a64ab1695f074b4d5400e257a 100644
--- a/lib_dec/ivas_lfe_dec_fx.c
+++ b/lib_dec/ivas_lfe_dec_fx.c
@@ -34,8 +34,7 @@
#include "options.h"
#ifdef IVAS_FLOAT_FIXED
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "ivas_rom_com.h"
diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c
index 7c1d59d5d24ef1d882ae8d6ec691fd40434ad4b7..6a65839b8cfcaa72b7c3eec8e7e5de5376025641 100644
--- a/lib_dec/ivas_lfe_plc_fx.c
+++ b/lib_dec/ivas_lfe_plc_fx.c
@@ -33,8 +33,7 @@
#include
#include "options.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include
@@ -42,6 +41,9 @@
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*------------------------------------------------------------------------------------------*
* Local constants
@@ -930,7 +932,7 @@ void ivas_lfe_tdplc_fx(
const Word32 *pWindow_coeffs_fx;
Word32 output_Fs;
Word16 i, fade_len, full_len, dct_len, zero_pad_len, plc_fdel, rec_frame_len;
- Word16 fdel_dsf_ratio, prevsynth_q_fx, rec_frame_q, temp, temp_q, idx, exp;
+ Word16 prevsynth_q_fx, rec_frame_q, temp_q, idx, exp;
output_Fs = L_mult0( output_frame, FRAMES_PER_SEC );
fade_len = hLFE->pWindow_state->fade_len;
@@ -943,11 +945,10 @@ void ivas_lfe_tdplc_fx(
move16();
pWindow_coeffs_fx = hLFE->pWindow_state->pWindow_coeffs_fx;
- temp = BASOP_Util_Divide3232_Scale( Mpy_32_32( L_shl( LFE_PLC_FDEL, 22 ), L_shl( output_Fs, 9 ) ), 48000, &temp_q );
- plc_fdel = shr( temp, sub( 15, temp_q ) );
-
- temp = BASOP_Util_Divide3232_Scale( output_Fs, 48000, &temp_q );
- rec_frame_len = shl( mult( LFE_PLC_RECLEN_48K, temp ), temp_q );
+ /* plc_fdel = (int16_t) ( LFE_PLC_FDEL * output_Fs / 48000 ); */
+ plc_fdel = extract_l( Mpy_32_32( output_Fs, 13421773 /* ( LFE_PLC_FDEL / 48000 ) in Q31 */ ) );
+ /* rec_frame_len = (int16_t) ( LFE_PLC_RECLEN_48K * output_Fs / 48000 ); */
+ rec_frame_len = extract_l( Mpy_32_32_r( output_Fs, 77846282 /* LFE_PLC_RECLEN_48K / 48000 in Q31 */ ) );
Copy32( prevsynth, prevsynth_fx, LFE_PLC_BUFLEN );
exp = L_norm_arr( prevsynth_fx, LFE_PLC_BUFLEN );
@@ -957,14 +958,14 @@ void ivas_lfe_tdplc_fx(
recover_samples_fx( hLFE->bfi_count, prevsynth_fx, prevsynth_q_fx, rec_frame_fx, &rec_frame_q );
- fdel_dsf_ratio = shl( div_l( LFE_PLC_FDEL, LFE_PLC_DSF ), 1 );
- set_s( mem_fx, 0, shl( fdel_dsf_ratio, 1 ) );
+ set16_fx( mem_fx, 0, 2 * LFE_PLC_FDEL / LFE_PLC_DSF );
Copy_Scale_sig_32_16( prevsynth_fx, prevsynth_16_fx, LFE_PLC_BUFLEN, -16 ); // Q5 = Q21 - Q16
Copy_Scale_sig_32_16( rec_frame_fx, rec_frame_16_fx, LFE_PLC_RECLEN, 0 ); // Q5
- modify_Fs_fx( prevsynth_16_fx + LFE_PLC_BUFLEN - LFE_PLC_FDEL / LFE_PLC_DSF, LFE_PLC_FDEL / LFE_PLC_DSF, LFE_PLC_FS, rec_frame_us_16_fx, 48000, mem_fx, 0 );
- modify_Fs_fx( rec_frame_16_fx, LFE_PLC_RECLEN, LFE_PLC_FS, rec_frame_us_16_fx, 48000, mem_fx, 0 );
+ Word16 Q_new_inp, mem_decim_size; // TO be removed
+ modify_Fs_fx( prevsynth_16_fx + LFE_PLC_BUFLEN - LFE_PLC_FDEL / LFE_PLC_DSF, LFE_PLC_FDEL / LFE_PLC_DSF, LFE_PLC_FS, rec_frame_us_16_fx, 48000, mem_fx, 0, &Q_new_inp, &mem_decim_size );
+ modify_Fs_fx( rec_frame_16_fx, LFE_PLC_RECLEN, LFE_PLC_FS, rec_frame_us_16_fx, 48000, mem_fx, 0, &Q_new_inp, &mem_decim_size );
/*samples are generated with 48k sampling rate
and then converted to required sampling rate by simple decimation
as signal is already bandlimited*/
diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c
index 86414d84aa5a00f78af2850cba6cc9e7b208c1e8..f87889e277889811a5936e0953f3e3f8fc96e11a 100644
--- a/lib_dec/ivas_ls_custom_dec.c
+++ b/lib_dec/ivas_ls_custom_dec.c
@@ -36,7 +36,7 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
+#include "prot_fx.h"
#endif
diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c
index a6f797e0a303ccbae6a8e36f9694f15c1cda2765..78aa9867bd6e2a2ce5200ce43373c70c391be0cc 100644
--- a/lib_dec/ivas_masa_dec.c
+++ b/lib_dec/ivas_masa_dec.c
@@ -39,12 +39,9 @@
#include "ivas_rom_com.h"
#include "ivas_stat_dec.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
#include "ivas_prot_fx.h"
#include "ivas_rom_com_fx.h"
@@ -606,7 +603,7 @@ ivas_error ivas_masa_decode_fx(
ivas_error error;
Word16 obj;
Word16 i, ch, ism_imp;
- Word16 dirac_bs_md_write_idx;
+ Word16 dirac_bs_md_write_idx, tmp;
Word32 masa_total_brate;
dirac_bs_md_write_idx = 0;
@@ -653,10 +650,8 @@ ivas_error ivas_masa_decode_fx(
next_bit_pos_orig = st->next_bit_pos;
move16();
- Word16 tmp, tmp_e;
- tmp = BASOP_Util_Divide3232_Scale( masa_brate, FRAMES_PER_SEC, &tmp_e );
- tmp = shr( tmp, sub( 15, tmp_e ) );
- assert( masa_brate / FRAMES_PER_SEC == tmp );
+ /* masa_brate / FRAMES_PER_SEC */
+ tmp = extract_l( Mpy_32_32( masa_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
IF( EQ_32( masa_brate, IVAS_SID_5k2 ) )
{
@@ -2312,12 +2307,11 @@ static ivas_error init_lfe_synth_data_fx(
Word16 bufferSize;
Word16 i;
Word16 slot_size;
- Word16 tmp, tmp_e;
/* Ring buffer for the filterbank of the LFE synthesis.
* The filterbank is using moving average lowpass filter with the crossover of 120 Hz. */
- tmp = BASOP_Util_Divide3232_Scale( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &tmp_e );
- bufferSize = shr( tmp, sub( 15, tmp_e ) ); // Q0
+ /* bufferSize = (int16_t) ( ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES ); */
+ bufferSize = extract_l( Mpy_32_32_r( output_Fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) );
IF( ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer_fx = (Word32 *) malloc( bufferSize * sizeof( Word32 ) ) ) == NULL )
{
@@ -2376,8 +2370,8 @@ static ivas_error init_lfe_synth_data_fx(
hMasa->hMasaLfeSynth->transportGainPrev_fx = MAX_WORD16;
move16();
- tmp = BASOP_Util_Divide3232_Scale( output_Fs, FRAMES_PER_SEC * CLDFB_NO_COL_MAX, &tmp_e );
- slot_size = shr( tmp, sub( 15, tmp_e ) ); // Q0
+ /* slot_size = (int16_t) ( ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX ); */
+ slot_size = extract_l( Mpy_32_32( output_Fs, 2684355 /* 1 / ( FRAMES_PER_SEC * CLDFB_NO_COL_MAX ) */ ) );
FOR( i = 0; i < slot_size; i++ )
{
@@ -3042,8 +3036,7 @@ ivas_error ivas_masa_dec_reconfigure_fx(
sts[0]->bit_stream = bit_stream + num_bits;
// num_bits += (int16_t)(st_ivas->hSCE[sce_id]->element_brate / FRAMES_PER_SEC);
- tmp = BASOP_Util_Divide3216_Scale( st_ivas->hSCE[sce_id]->element_brate, FRAMES_PER_SEC, &tmp_e );
- tmp = shr( tmp, negate( add( 1, tmp_e ) ) );
+ tmp = extract_l( Mpy_32_32( st_ivas->hSCE[sce_id]->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
num_bits = add( num_bits, tmp );
test();
@@ -3086,8 +3079,7 @@ ivas_error ivas_masa_dec_reconfigure_fx(
sts[0]->bit_stream = bit_stream + num_bits;
// num_bits += (int16_t) ( st_ivas->hCPE[cpe_id]->element_brate / FRAMES_PER_SEC );
- tmp = BASOP_Util_Divide3216_Scale( st_ivas->hCPE[cpe_id]->element_brate, FRAMES_PER_SEC, &tmp_e );
- tmp = shr( tmp, negate( add( 1, tmp_e ) ) );
+ tmp = extract_l( Mpy_32_32( st_ivas->hCPE[cpe_id]->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
num_bits = add( num_bits, tmp );
test();
diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c
index d25fff5f886ffb672a70bafc522e4c34d091a79a..c57261bbf57ad5e2186ae3fdb08beba2418a6187 100644
--- a/lib_dec/ivas_mc_param_dec.c
+++ b/lib_dec/ivas_mc_param_dec.c
@@ -46,8 +46,7 @@
#include "wmc_auto.h"
#include "rom_dec.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#define IVAS_FLOAT_FIXED_TO_BE_REMOVED
#endif
@@ -3305,93 +3304,7 @@ void ivas_param_mc_dec_digest_tc(
}
if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex )
{
-#ifdef IVAS_FLOAT_FIXED
- Word32( *cx_fx )[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
- Word16 cx_e;
- Word32( *cx_imag_fx )[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
- Word16 cx_imag_e;
- Word16 cldfb_slots;
-
- cx_fx = malloc( sizeof( Word32[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS] ) );
- cx_imag_fx = malloc( sizeof( Word32[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS] ) );
-
- for ( int lp = 0; lp < PARAM_MC_MAX_PARAMETER_BANDS; lp++ )
- {
- set32_fx( cx_fx[lp], 0, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS );
- set32_fx( cx_imag_fx[lp], 0, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS );
- }
-
- cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS;
- if ( st_ivas->hDecoderConfig->Opt_tsm )
- {
- cldfb_slots = MAX_JBM_CLDFB_TIMESLOTS;
- }
-
- f2me_buf( hParamMC->Cldfb_RealBuffer_tc, hParamMC->Cldfb_RealBuffer_tc_fx, &hParamMC->Cldfb_RealBuffer_tc_e, cldfb_slots * st_ivas->nchan_transport * hParamMC->num_freq_bands );
- f2me_buf( hParamMC->Cldfb_ImagBuffer_tc, hParamMC->Cldfb_ImagBuffer_tc_fx, &hParamMC->Cldfb_ImagBuffer_tc_e, cldfb_slots * st_ivas->nchan_transport * hParamMC->num_freq_bands );
-
- Word16 max_e = 0;
- cx_e;
- for ( int lp = 0; lp < PARAM_MC_MAX_PARAMETER_BANDS; lp++ )
- {
- for ( int lp2 = 0; lp2 < PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS; lp2++ )
- {
- f2me( cx[lp][lp2], &cx_fx[lp][lp2], &cx_e );
- max_e = s_max( cx_e, max_e );
- }
- }
-
- for ( int lp = 0; lp < PARAM_MC_MAX_PARAMETER_BANDS; lp++ )
- {
- for ( int lp2 = 0; lp2 < PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS; lp2++ )
- {
- f2me( cx[lp][lp2], &cx_fx[lp][lp2], &cx_e );
- cx_fx[lp][lp2] = L_shr( cx_fx[lp][lp2], max_e - cx_e );
- }
- }
- cx_e = max_e;
-
- max_e = 0;
- for ( int lp = 0; lp < PARAM_MC_MAX_PARAMETER_BANDS; lp++ )
- {
- for ( int lp2 = 0; lp2 < PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS; lp2++ )
- {
- f2me( cx_imag[lp][lp2], &cx_imag_fx[lp][lp2], &cx_imag_e );
- max_e = s_max( cx_imag_e, max_e );
- }
- }
-
- for ( int lp = 0; lp < PARAM_MC_MAX_PARAMETER_BANDS; lp++ )
- {
- for ( int lp2 = 0; lp2 < PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS; lp2++ )
- {
- f2me( cx_imag[lp][lp2], &cx_imag_fx[lp][lp2], &cx_imag_e );
- cx_imag_fx[lp][lp2] = L_shr( cx_imag_fx[lp][lp2], max_e - cx_imag_e );
- }
- }
- cx_imag_e = max_e;
-
- ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport],
- hParamMC->Cldfb_RealBuffer_tc_e,
- &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport],
- hParamMC->Cldfb_ImagBuffer_tc_e,
- cx_fx,
- &cx_e,
- cx_imag_fx,
- &cx_imag_e,
- hParamMC,
- nchan_transport );
-
- for ( int lp = 0; lp < PARAM_MC_MAX_PARAMETER_BANDS; lp++ )
- {
- me2f_buf( cx_fx[lp], cx_e, cx[lp], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS );
- me2f_buf( cx_imag_fx[lp], cx_imag_e, cx_imag[lp], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS );
- }
- free( cx_fx );
- free( cx_imag_fx );
-#else
ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], cx, cx_imag, hParamMC, nchan_transport );
-#endif
}
}
@@ -6208,7 +6121,7 @@ static void ivas_param_mc_dequantize_cov_fx(
tmp_e = Cp_buf_e[add( k, imult1616( nY_int, k ) )];
move16();
- IF( NE_32( Cproto_fx[add( k, imult1616( nY_int, k ) )], 0 ) )
+ IF( Cproto_fx[add( k, imult1616( nY_int, k ) )] != 0 )
{
L_tmp = ISqrt32( Cproto_fx[add( k, imult1616( nY_int, k ) )], &tmp_e );
}
@@ -6269,13 +6182,13 @@ static void ivas_param_mc_dequantize_cov_fx(
Cy_state_int_e[hParamMC->hMetadataPMC->icc_mapping[param_frame_idx][k][1] + nY_int * hParamMC->hMetadataPMC->icc_mapping[param_frame_idx][k][0]] = tmp;
move16();
#else
- Cy_state_int_fx[hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][0] + nY_int * hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][1]] = L_shr( L_deposit_h( icc_q_fx[k] ), tmp );
+ Cy_state_int_fx[add( hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][0], imult1616( nY_int, hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][1] ) )] = L_shr( L_deposit_h( icc_q_fx[k] ), tmp );
move32();
- Cy_state_int_e[hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][0] + nY_int * hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][1]] = tmp;
+ Cy_state_int_e[add( hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][0], imult1616( nY_int, hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][1] ) )] = tmp;
move16();
- Cy_state_int_fx[hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][1] + nY_int * hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][0]] = L_shr( L_deposit_h( icc_q_fx[k] ), tmp );
+ Cy_state_int_fx[add( hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][1], imult1616( nY_int, hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][0] ) )] = L_shr( L_deposit_h( icc_q_fx[k] ), tmp );
move32();
- Cy_state_int_e[hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][1] + nY_int * hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][0]] = tmp;
+ Cy_state_int_e[add( hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][1], imult1616( nY_int, hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][0] ) )] = tmp;
move16();
#endif
}
@@ -6339,7 +6252,7 @@ static void ivas_param_mc_dequantize_cov_fx(
}
}
- IF( synth_conf == PARAM_MC_SYNTH_LS_CONV_COV )
+ IF( EQ_32( synth_conf, PARAM_MC_SYNTH_LS_CONV_COV ) )
{
/* Cy = dmx*Cy*dmx' */
Word32 mat_mult_buffer1_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS];
diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c
index f3faac41b5f9013acf89e546a4a245ebd8b6d19f..56635af0db8cb7c47e386b807a5eddfe3a71aa1f 100644
--- a/lib_dec/ivas_mc_param_dec_fx.c
+++ b/lib_dec/ivas_mc_param_dec_fx.c
@@ -8,6 +8,7 @@ Word16 param_mc_get_num_cldfb_syntheses_ivas_fx(
Word16 num_cldfb_syntheses;
num_cldfb_syntheses = 0;
+ move16();
/* sanity check*/
IF( st_ivas->hParamMC == NULL )
@@ -15,9 +16,11 @@ Word16 param_mc_get_num_cldfb_syntheses_ivas_fx(
assert( 0 && "ParamMC handle does not exist!\n" );
}
+ test();
IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
{
num_cldfb_syntheses = 2;
+ move16();
}
ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
{
diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c
index b8d3fac665c03af8dcb19ba140227b4acbd2c496..240dae544ce199467ae6ccea44c756ffc3a9f825 100644
--- a/lib_dec/ivas_mc_paramupmix_dec.c
+++ b/lib_dec/ivas_mc_paramupmix_dec.c
@@ -35,10 +35,8 @@
#include
#include "cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
#include "ivas_prot.h"
@@ -49,6 +47,9 @@
#include "math.h"
#include "wmc_auto.h"
#include "rom_dec.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
#ifdef IVAS_FLOAT_FIXED
/*-----------------------------------------------------------------------*
@@ -684,7 +685,7 @@ static void ps_pred_process_sf(
res_a = L_shl_sat( Mpy_32_32( alpha_smp_fx, vmim_fx ), Q31 - Q28 );
res_b = L_shl_sat( Mpy_32_32( beta_smp_fx, vsim_fx ), Q31 - Q28 );
- qmf_side_re_fx[ismp][iqmf] = L_add_sat( res_a, res_b );
+ qmf_side_im_fx[ismp][iqmf] = L_add_sat( res_a, res_b );
ismp = add( ismp, 1 );
}
diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c
index 7bd948ad61cab35a479d5e6fee8bb08eb28ac0b7..cc014dd76ebd112cfa75b0eb5c741ffe1e460f99 100644
--- a/lib_dec/ivas_mct_core_dec.c
+++ b/lib_dec/ivas_mct_core_dec.c
@@ -43,8 +43,7 @@
#include "ivas_stat_dec.h"
#include "ivas_stat_com.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c
index 235543277fee39a3951e2ed040d8b8e88a21de3e..34ab57de5becca1d57cec2ab3f71f2e26cb74f00 100644
--- a/lib_dec/ivas_mct_dec.c
+++ b/lib_dec/ivas_mct_dec.c
@@ -37,14 +37,13 @@
#include "cnst.h"
#include "ivas_cnst.h"
#include "rom_com.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "prot.h"
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
#include "ivas_prot_fx.h"
#endif // IVAS_FLOAT_FIXED
@@ -314,7 +313,9 @@ ivas_error ivas_mct_dec_fx(
Word32 *x_fx[CPE_CHANNELS][NB_DIV];
Word16 x_e[MAX_CICP_CHANNELS][NB_DIV];
- Word16 x_len[CPE_CHANNELS][NB_DIV] = { 0 };
+ Word16 x_len[CPE_CHANNELS][NB_DIV];
+ set16_fx( x_len[0], 0, NB_DIV );
+ set16_fx( x_len[1], 0, NB_DIV );
Decoder_State **sts;
Word16 synth_fx[CPE_CHANNELS][L_FRAME_PLUS];
int32_t ivas_total_brate;
@@ -517,7 +518,11 @@ ivas_error ivas_mct_dec_fx(
}
ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
{
- Word16 x_all_e[MAX_CICP_CHANNELS][NB_DIV] = { 0 };
+ Word16 x_all_e[MAX_CICP_CHANNELS][NB_DIV];
+ FOR( i = 0; i < MAX_CICP_CHANNELS; i++ )
+ {
+ set16_fx( x_all_e[i], 0, NB_DIV );
+ }
Word32 *x_all_fx[MAX_CICP_CHANNELS][NB_DIV];
FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
@@ -1059,8 +1064,8 @@ ivas_error mct_dec_reconfigure_fx(
IF( NE_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
- tmp = BASOP_Util_Divide3232_Scale( st_ivas->hCPE[cpe_id]->element_brate, FRAMES_PER_SEC, &tmp_exp );
- st->bits_frame_nominal = shr( tmp, sub( 15, tmp_exp ) );
+ /* st->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[cpe_id]->element_brate / FRAMES_PER_SEC ); */
+ st->bits_frame_nominal = extract_l( Mpy_32_32( st_ivas->hCPE[cpe_id]->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
move16();
st->igf = getIgfPresent_fx( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag ); // no floating point so directly pluggable
move16();
@@ -1074,8 +1079,8 @@ ivas_error mct_dec_reconfigure_fx(
}
/*Initialize MCT block data */
- tmp = BASOP_Util_Divide1616_Scale( hMCT->nchan_out_woLFE, CPE_CHANNELS, &tmp_exp );
- max_blocks = shr( tmp, sub( 15, tmp_exp ) );
+ /* max_blocks = hMCT->nchan_out_woLFE / 2; */
+ max_blocks = shr( hMCT->nchan_out_woLFE, 1 );
FOR( n = 0; n < max_blocks; n++ )
{
diff --git a/lib_dec/ivas_mct_dec_mct_fx.c b/lib_dec/ivas_mct_dec_mct_fx.c
index 9c3dced3353eb41da9cc277be6c9c8673e0bc1a9..29685d898c85cf9c9c892823571a64189ed0b5af 100644
--- a/lib_dec/ivas_mct_dec_mct_fx.c
+++ b/lib_dec/ivas_mct_dec_mct_fx.c
@@ -39,8 +39,7 @@
#include
#include "stat_enc.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
/*----------------------------------------------------------*
@@ -197,8 +196,8 @@ static void applyGlobalILD_fx(
{
IF( hMCT->lowE_ch[ch] )
{
- tmp = BASOP_Util_Divide3216_Scale( L_shl( hMCT->mc_global_ild[ch], Q26 ), SMDCT_ILD_RANGE, &tmp_e ); // Q26
- qratio = L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) );
+ /* qratio = (float) hMCT->mc_global_ild[ch] / SMDCT_ILD_RANGE; */
+ qratio = L_shl( hMCT->mc_global_ild[ch], Q26 - SMDCT_GLOBAL_ILD_BITS ); /* Q26 */
}
ELSE
{
diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c
index 61c5be3b1d17a377bcad9eecbe1e3e2d0931e640..36c68e3cf4507ca86365653cea5ea4e3844df257 100644
--- a/lib_dec/ivas_mdct_core_dec.c
+++ b/lib_dec/ivas_mdct_core_dec.c
@@ -45,10 +45,8 @@
#include "ivas_stat_com.h"
#include
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
#endif // IVAS_FLOAT_FIXED
@@ -64,36 +62,57 @@ void mdct_read_IGF_bits_fx(
Decoder_State *st0 /* i : pointer to handle where bitstream is read */
)
{
- int16_t k, start;
+ Word16 k, start, temp;
start = st0->next_bit_pos;
+ move16();
- IF( st->core == TCX_20_CORE )
+ IF( EQ_16( st->core, TCX_20_CORE ) )
{
+ IF( st->last_core == ACELP_CORE )
+ {
+ temp = IGF_GRID_LB_TRAN;
+ move16();
+ }
+ ELSE
+ {
+ temp = IGF_GRID_LB_NORM;
+ move16();
+ }
/* read IGF payload */
- IGFDecReadLevel( st->hIGFDec, st0, ( st->last_core == ACELP_CORE ) ? IGF_GRID_LB_TRAN : IGF_GRID_LB_NORM, 1 );
+ IGFDecReadLevel( st->hIGFDec, st0, temp, 1 );
- IGFDecReadData_ivas_fx( st->hIGFDec, st0, ( st->last_core == ACELP_CORE ) ? IGF_GRID_LB_TRAN : IGF_GRID_LB_NORM, 1 );
+ IGFDecReadData_ivas_fx( st->hIGFDec, st0, temp, 1 );
}
- IF( st->core == TCX_10_CORE )
+ IF( EQ_16( st->core, TCX_10_CORE ) )
{
FOR( k = 0; k < 2; k++ )
{
- IGFDecReadLevel( st->hIGFDec, st0, IGF_GRID_LB_SHORT, k == 0 ? 1 : 0 );
+ IF( k == 0 )
+ {
+ temp = 1;
+ move16();
+ }
+ ELSE
+ {
+ temp = 0;
+ move16();
+ }
+ IGFDecReadLevel( st->hIGFDec, st0, IGF_GRID_LB_SHORT, temp );
- IGFDecReadData_ivas_fx( st->hIGFDec, st0, IGF_GRID_LB_SHORT, k == 0 ? 1 : 0 );
+ IGFDecReadData_ivas_fx( st->hIGFDec, st0, IGF_GRID_LB_SHORT, temp );
IGFDecStoreTCX10SubFrameData( st->hIGFDec, k );
}
}
- st->side_bits_frame_channel += ( st0->next_bit_pos - start );
+ st->side_bits_frame_channel = add( st->side_bits_frame_channel, sub( st0->next_bit_pos, start ) );
+ move16();
return;
}
-#endif
-#ifndef IVAS_FLOAT_FIXED
+#else // IVAS_FLOAT_FIXED
void mdct_read_IGF_bits(
Decoder_State *st, /* i/o: Decoder state handle */
Decoder_State *st0 /* i : pointer to handle where bitstream is read */
@@ -129,6 +148,7 @@ void mdct_read_IGF_bits(
}
#endif
+
/*-----------------------------------------------------------------*
* Function dec_prm_tcx_sidebits()
*
@@ -157,10 +177,13 @@ static void dec_prm_tcx_sidebits_fx(
hm_cfg.indexBuffer = NULL;
start_bit_pos = st0->next_bit_pos;
+ move16();
/* Init LTP data */
st->hTcxDec->tcx_hm_LtpPitchLag = -1;
+ move16();
st->hTcxLtpDec->tcxltp_gain = 0;
+ move16();
/*--------------------------------------------------------------------------------*
* Header
@@ -170,57 +193,85 @@ static void dec_prm_tcx_sidebits_fx(
getTCXMode_ivas_fx( st, st0, MCT_flag );
st->flagGuidedAcelp = 0;
+ move16();
- IF( st->dec_glr )
+ if ( st->dec_glr )
{
st->dec_glr_idx = -1;
+ move16();
}
/* last_core for core switching and error concealment */
- IF( ( st->last_core == ACELP_CORE && st->last_total_brate == FRAME_NO_DATA ) || st->prev_bfi )
+ test();
+ test();
+ IF( ( ( st->last_core == ACELP_CORE ) && ( st->last_total_brate == FRAME_NO_DATA ) ) || st->prev_bfi )
{
/* needed for cases where first TCX frame after a certain transition (e.g. inactive SID/zero frame -> active or stereo switching) is lost */
st->last_core_from_bs = get_next_indice( st0, 1 );
+ move16();
/* ACELP -> TCX_10 transitions are forbidden */
- IF( st->core == TCX_10_CORE && st->last_core == ACELP_CORE )
+ test();
+ if ( EQ_16( st->core, TCX_10_CORE ) && ( st->last_core == ACELP_CORE ) )
{
st->last_core = TCX_20_CORE;
+ move16();
}
}
ELSE
{
st->last_core = get_next_indice( st0, 1 );
+ move16();
st->last_core_from_bs = st->last_core;
+ move16();
}
getTCXWindowing_ivas_fx( st->core, st->last_core, st->element_mode, st->hTcxCfg, st0 );
st->hTcxDec->kernel_type[0] = st->hTcxDec->kernel_type[1] = MDCT_IV;
- st->hTcxDec->kernel_type[0] = get_next_indice( st0, st->last_core_from_bs != ACELP_CORE ? 2 : 1 );
- IF( st->core == TCX_10_CORE )
+ move16();
+ move16();
+ IF( st->last_core_from_bs != ACELP_CORE )
{
- st->hTcxDec->kernel_type[1] = 2 * ( st->hTcxDec->kernel_type[0] & 1 ) + get_next_indice( st0, 1 );
+ st->hTcxDec->kernel_type[0] = get_next_indice( st0, 2 );
}
- IF( st->core == TCX_20_CORE )
+ ELSE
+ {
+ st->hTcxDec->kernel_type[0] = get_next_indice( st0, 1 );
+ }
+ move16();
+ IF( EQ_16( st->core, TCX_10_CORE ) )
+ {
+ st->hTcxDec->kernel_type[1] = add( shl( s_and( st->hTcxDec->kernel_type[0], 1 ), 1 ), get_next_indice( st0, 1 ) );
+ move16();
+ }
+ IF( EQ_16( st->core, TCX_20_CORE ) )
{
st->transform_type[0] = st->transform_type[1] = TCX_20;
+ move16();
+ move16();
}
ELSE
{
- IF( st->hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP )
+ IF( EQ_16( st->hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) )
{
st->transform_type[0] = TCX_5;
+ move16();
st->transform_type[1] = TCX_10;
+ move16();
}
- ELSE IF( st->hTcxCfg->tcx_last_overlap_mode == FULL_OVERLAP )
+ ELSE IF( EQ_16( st->hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) )
{
st->transform_type[0] = TCX_10;
+ move16();
st->transform_type[1] = TCX_5;
+ move16();
}
ELSE
{
st->transform_type[0] = st->transform_type[1] = TCX_5;
+ move16();
+ move16();
}
}
@@ -228,14 +279,23 @@ static void dec_prm_tcx_sidebits_fx(
* TCX20/TCX10 parameters
*--------------------------------------------------------------------------------*/
- getTCXparam_fx( st, st0, hm_cfg, param, 0, 0, ( ( ch > 0 ) && ( tnsSize ) && ( tnsSize[0] + tnsSize[1] > 0 ) ? tnsSize : NULL ), p_param, nTnsBitsTCX10, 0 );
+ test();
+ test();
+ IF( ( ch > 0 ) && tnsSize && ( add( tnsSize[0], tnsSize[1] ) > 0 ) )
+ {
+ getTCXparam_fx( st, st0, hm_cfg, param, 0, 0, tnsSize, p_param, nTnsBitsTCX10, 0 );
+ }
+ ELSE
+ {
+ getTCXparam_fx( st, st0, hm_cfg, param, 0, 0, NULL, p_param, nTnsBitsTCX10, 0 );
+ }
- st->side_bits_frame_channel = st0->next_bit_pos - start_bit_pos;
+ st->side_bits_frame_channel = sub( st0->next_bit_pos, start_bit_pos );
+ move16();
return;
}
-#endif
-#ifndef IVAS_FLOAT_FIXED
+#else
static void dec_prm_tcx_sidebits(
int16_t param[], /* o : decoded parameters */
Decoder_State *st, /* i/o: decoder memory state */
@@ -336,11 +396,13 @@ static void dec_prm_tcx_sidebits(
}
#endif
+
/*-----------------------------------------------------------------*
* Function dec_prm_tcx_spec()
*
* decode TCX core parameters
*-----------------------------------------------------------------*/
+
#ifdef IVAS_FLOAT_FIXED
static void dec_prm_tcx_spec_fx(
Decoder_State *st, /* i/o: decoder memory state */
@@ -373,10 +435,18 @@ static void dec_prm_tcx_spec_fx(
nbits_tcx = 0;
move16();
- nSubframes = ( EQ_16( st->core, TCX_10_CORE ) ) ? NB_DIV : 1;
+ IF( EQ_16( st->core, TCX_10_CORE ) )
+ {
+ nSubframes = NB_DIV;
+ }
+ ELSE
+ {
+ nSubframes = 1;
+ }
move16();
/*calculate TCX10 target bits before to assure minimum amount is distributed between subframes*/
+ test();
IF( EQ_16( st->core, TCX_10_CORE ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
{
Word16 nTnsBitsTCX10Tmp[NB_DIV];
@@ -386,7 +456,7 @@ static void dec_prm_tcx_spec_fx(
move16();
/*compute target bits */
- tmp = i_mult2( nSubframes, add( NBITS_TCX_GAIN, i_mult2( NOISE_FILL_RANGES, NBITS_NOISE_FILL_LEVEL ) ) );
+ tmp = i_mult2( nSubframes, NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL );
nbits_tcx = add( add( add( st->bits_frame_channel, nTnsBitsTCX10[0] ), nTnsBitsTCX10[1] ), tmp );
ivas_mdct_tcx10_bit_distribution_fx( target_bitsTCX10, nbits_tcx, nTnsBitsTCX10Tmp );
}
@@ -397,13 +467,14 @@ static void dec_prm_tcx_spec_fx(
getTCXparam_fx( st, st, hm_cfg, param, 0, 0, NULL, p_param, target_bitsTCX10, 1 );
- nf_bits = i_mult2( nSubframes, ( add( NBITS_TCX_GAIN, i_mult2( NOISE_FILL_RANGES, NBITS_NOISE_FILL_LEVEL ) ) ) );
+ nf_bits = i_mult2( nSubframes, NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL );
IF( LT_16( add( sub( *total_nbbits, bitsRead[0] ), nf_bits ), sub( st->next_bit_pos, start_bit_pos ) ) )
{
st->BER_detect = 1;
move16();
st->next_bit_pos = add( start_bit_pos, sub( *total_nbbits, bitsRead[0] ) );
+ move16();
}
bitsRead[0] = sub( st->next_bit_pos, start_bit_pos );
@@ -411,8 +482,7 @@ static void dec_prm_tcx_spec_fx(
return;
}
-#endif
-#ifndef IVAS_FLOAT_FIXED
+#else
static void dec_prm_tcx_spec(
Decoder_State *st, /* i/o: decoder memory state */
int16_t param[], /* o : decoded parameters */
@@ -474,6 +544,7 @@ static void dec_prm_tcx_spec(
}
#endif
+
/*-----------------------------------------------------------------*
* Function ivas_mdct_dec_side_bits_frame_channel()
*
@@ -503,9 +574,10 @@ void ivas_mdct_dec_side_bits_frame_channel_fx(
sts = hCPE->hCoreCoder;
bfi = sts[0]->bfi;
+ move16();
- set_s( total_nbbits, 0, MCT_MAX_CHANNELS );
- set_s( bitsRead, 0, MCT_MAX_CHANNELS );
+ set16_fx( total_nbbits, 0, MCT_MAX_CHANNELS );
+ set16_fx( bitsRead, 0, MCT_MAX_CHANNELS );
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
@@ -515,6 +587,7 @@ void ivas_mdct_dec_side_bits_frame_channel_fx(
stereo_tcx_init_dec_fx( sts[ch], 1, hCPE->last_element_mode );
}
sts[ch]->enablePlcWaveadjust = 0;
+ move16();
}
IF( !bfi )
@@ -522,9 +595,10 @@ void ivas_mdct_dec_side_bits_frame_channel_fx(
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
/* disguard reading second channel of odd transport channels, mct_chan_mode is set by default*/
+ test();
IF( odd_channel_cpe && ch == 1 )
{
- continue;
+ CONTINUE;
}
st = sts[ch];
@@ -539,6 +613,7 @@ void ivas_mdct_dec_side_bits_frame_channel_fx(
{
st->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
}
+ move16();
}
}
@@ -546,21 +621,33 @@ void ivas_mdct_dec_side_bits_frame_channel_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 ) )
{
sts[ch]->coder_type = INACTIVE;
+ move16();
sts[ch]->side_bits_frame_channel = 0;
- continue;
+ move16();
+ CONTINUE;
}
tmp = ch;
- IF( ch == 1 && param_lpc[0][0] == 2 )
+ move16();
+ test();
+ if ( EQ_16( ch, 1 ) && EQ_16( param_lpc[0][0], 2 ) )
{
tmp = 3;
+ move16();
}
- dec_prm_tcx_sidebits_fx( param[ch], st, ( ( st->element_mode == IVAS_CPE_MDCT && !MCT_flag ) ? sts[0]->hTcxDec->tnsActive : NULL ), p_param[ch], nTnsBitsTCX10[ch], st0, MCT_flag, tmp );
-
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag )
+ {
+ dec_prm_tcx_sidebits_fx( param[ch], st, sts[0]->hTcxDec->tnsActive, p_param[ch], nTnsBitsTCX10[ch], st0, MCT_flag, tmp );
+ }
+ ELSE
+ {
+ dec_prm_tcx_sidebits_fx( param[ch], st, NULL, p_param[ch], nTnsBitsTCX10[ch], st0, MCT_flag, tmp );
+ }
assert( st->BER_detect != 1 );
}
@@ -569,110 +656,166 @@ void ivas_mdct_dec_side_bits_frame_channel_fx(
*--------------------------------------------------------------------------------*/
sns_low_br_mode = 0;
+ move16();
skipped_first_channel = 0;
- IF( !MCT_flag && sts[0]->sr_core == 25600 && ( ( hCPE->element_brate == IVAS_48k || hCPE->element_brate == IVAS_64k ) ) )
+ move16();
+
+ test();
+ test();
+ test();
+ IF( !MCT_flag && EQ_32( sts[0]->sr_core, 25600 ) && ( EQ_32( hCPE->element_brate, IVAS_48k ) || EQ_32( hCPE->element_brate, IVAS_64k ) ) )
{
param_lpc[0][0] = SNS_STEREO_MODE_LR;
+ move16();
param_lpc[0][1] = SNS_STEREO_MODE_LR;
+ move16();
param_lpc[0][2] = 0;
+ move16();
param_lpc[0][3] = 0;
- IF( sts[0]->core == sts[1]->core )
+ move16();
+ IF( EQ_16( sts[0]->core, sts[1]->core ) )
{
Word16 nSubframes;
- nSubframes = ( sts[0]->core == TCX_20_CORE ) ? 1 : NB_DIV;
+ IF( EQ_16( sts[0]->core, TCX_20_CORE ) )
+ {
+ nSubframes = 1;
+ }
+ ELSE
+ {
+ nSubframes = NB_DIV;
+ }
+ move16();
- for ( Word16 n = 0; n < nSubframes; ++n )
+ FOR( Word16 n = 0; n < nSubframes; ++n )
{
param_lpc[0][n] = get_next_indice( st0, 1 );
+ move16();
}
/* zero side flags only get transmitted if needed */
- for ( Word16 n = 0; n < nSubframes; ++n )
+ FOR( Word16 n = 0; n < nSubframes; ++n )
{
- if ( param_lpc[0][n] == SNS_STEREO_MODE_MS )
+ IF( EQ_16( param_lpc[0][n], SNS_STEREO_MODE_MS ) )
{
- param_lpc[0][n + SNS_STEREO_MODE_OFFSET_INDICES / 2] = get_next_indice( st0, 1 );
+ param_lpc[0][n + ( SNS_STEREO_MODE_OFFSET_INDICES / 2 )] = get_next_indice( st0, 1 );
+ move16();
}
}
}
- for ( ch = 0; ch < CPE_CHANNELS; ++ch )
+ FOR( ch = 0; ch < CPE_CHANNELS; ++ch )
{
Word16 nSubframes;
Word16 idxIndices;
st = sts[ch];
- nSubframes = ( st->core == TCX_20_CORE ) ? 1 : NB_DIV;
+ IF( EQ_16( st->core, TCX_20_CORE ) )
+ {
+ nSubframes = 1;
+ }
+ ELSE
+ {
+ nSubframes = NB_DIV;
+ }
+ move16();
idxIndices = 0;
+ move16();
- for ( Word16 n = 0; n < nSubframes; ++n )
+ FOR( Word16 n = 0; n < nSubframes; ++n )
{
- const Word16 is_side = ch == 1 && param_lpc[0][n] == SNS_STEREO_MODE_MS;
- const Word16 *bits = ( nSubframes == 1 ) ? ivas_sns_cdbks_tcx20_bits : ivas_sns_cdbks_tcx10_bits;
- Word16 nStages = ( ( nSubframes == 1 ) ? SNS_MSVQ_NSTAGES_TCX20 : SNS_MSVQ_NSTAGES_TCX10 );
-
- if ( is_side )
+ const Word16 is_side = (Word16) L_and( EQ_16( ch, 1 ), EQ_16( param_lpc[0][n], SNS_STEREO_MODE_MS ) );
+ const Word16 *bits;
+ Word16 nStages;
+ IF( EQ_16( nSubframes, 1 ) )
+ {
+ bits = ivas_sns_cdbks_tcx20_bits;
+ nStages = SNS_MSVQ_NSTAGES_TCX20;
+ }
+ ELSE
+ {
+ bits = ivas_sns_cdbks_tcx10_bits;
+ nStages = SNS_MSVQ_NSTAGES_TCX10;
+ }
+ move16();
+ IF( is_side )
{
/* check for zero-side flag */
- if ( param_lpc[0][n + SNS_STEREO_MODE_OFFSET_INDICES / 2] )
+ IF( param_lpc[0][n + ( SNS_STEREO_MODE_OFFSET_INDICES / 2 )] )
{
- continue;
+ CONTINUE;
}
nStages = SNS_MSVQ_NSTAGES_SIDE;
- bits = ( nSubframes == 1 ) ? ivas_sns_cdbks_side_tcx20_bits : ivas_sns_cdbks_side_tcx10_bits;
+ move16();
+ IF( EQ_16( nSubframes, 1 ) )
+ {
+ bits = ivas_sns_cdbks_side_tcx20_bits;
+ }
+ ELSE
+ {
+ bits = ivas_sns_cdbks_side_tcx10_bits;
+ }
}
- for ( Word16 j = 0; j < nStages; ++j )
+ FOR( Word16 j = 0; j < nStages; ++j )
{
/* plus one in index for stereo mode storage! */
- param_lpc[ch][j + idxIndices + SNS_STEREO_MODE_OFFSET_INDICES] = get_next_indice_fx( st0, bits[j] );
+ param_lpc[ch][add( add( j, idxIndices ), SNS_STEREO_MODE_OFFSET_INDICES )] = get_next_indice_fx( st0, bits[j] );
+ move16();
}
- idxIndices += nStages;
+ idxIndices = add( idxIndices, nStages );
}
}
}
- else
+ ELSE
{
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
+ 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 ) )
{
skipped_first_channel = 1;
- continue;
+ move16();
+ CONTINUE;
}
start_bit_pos_sns = st0->next_bit_pos;
- if ( ch == 0 || skipped_first_channel )
+ test();
+ IF( ( ch == 0 ) || skipped_first_channel )
{
/* read SNS stereo mode */
- param_lpc[0][0] = get_next_indice( st0, 1 ) << 1;
+ param_lpc[0][0] = shl( (Word16) get_next_indice( st0, 1 ), 1 );
/* read low br mode flag (if it is possible to be non-zero) */
- if ( sts[0]->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) ) )
+ test();
+ test();
+ IF( EQ_32( sts[0]->element_brate, IVAS_48k ) && !( EQ_16( sts[0]->core, TCX_20 ) && EQ_16( sts[1]->core, TCX_20 ) ) )
{
sns_low_br_mode = get_next_indice( st0, 1 );
}
}
tmp = ch;
- if ( ch == 1 && param_lpc[0][0] == 2 )
+ move16();
+
+ test();
+ if ( EQ_16( ch, 1 ) && EQ_16( param_lpc[0][0], 2 ) )
{
tmp = 3;
+ move16();
}
- getLPCparam_fx( st, ¶m_lpc[ch][0], st0, tmp, sns_low_br_mode && !( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) );
+ getLPCparam_fx( st, ¶m_lpc[ch][0], st0, tmp, sns_low_br_mode && !( EQ_16( sts[0]->core, TCX_20 ) && EQ_16( sts[1]->core, TCX_20 ) ) );
- st->side_bits_frame_channel += st0->next_bit_pos - start_bit_pos_sns;
+ st->side_bits_frame_channel = add( st->side_bits_frame_channel, sub( st0->next_bit_pos, start_bit_pos_sns ) );
+ move16();
}
}
}
return;
}
-#endif
-#ifndef IVAS_FLOAT_FIXED
+#else
void ivas_mdct_dec_side_bits_frame_channel(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* o : lpc_parameters */
@@ -704,16 +847,7 @@ void ivas_mdct_dec_side_bits_frame_channel(
if ( MCT_flag )
{
/* Initialization or re-configuration of Stereo TCX */
-#ifdef IVAS_FLOAT_FIXED
- /* stereo_tcx_dec_mode_switch_reconf_To_fixed is for intermediatery conversions which is needed to be removed */
- stereo_tcx_dec_mode_switch_reconf_To_fixed( sts[ch], 1, hCPE->last_element_mode );
- /*============*/
- stereo_tcx_init_dec_fx( sts[ch], 1, hCPE->last_element_mode );
- /*============*/
- stereo_tcx_dec_mode_switch_reconf_To_fixed( sts[ch], 0, hCPE->last_element_mode );
-#else
stereo_tcx_init_dec( sts[ch], 1, hCPE->last_element_mode );
-#endif // IVAS_FLOAT_FIXED
}
sts[ch]->enablePlcWaveadjust = 0;
}
@@ -874,11 +1008,13 @@ void ivas_mdct_dec_side_bits_frame_channel(
}
#endif
+
/*-----------------------------------------------------------------*
* ivas_mdct_core_invQ()
*
* Inverse processing steps up to inverse quantization
*-----------------------------------------------------------------*/
+
#ifdef IVAS_FLOAT_FIXED
void ivas_mdct_core_invQ_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */
@@ -917,20 +1053,27 @@ void ivas_mdct_core_invQ_fx(
Word16 L_frame[CPE_CHANNELS], nSubframes[CPE_CHANNELS], L_frameTCX[CPE_CHANNELS];
Word16 tmp_concealment_method;
Word16 gain_tcx = 0, gain_tcx_e = 0;
+ move16();
+ move16();
Word16 nf_seed;
const Word16 *prm_sqQ;
Word16 L_frameTCX_global[CPE_CHANNELS];
Word16 tmp_ms_sig[CPE_CHANNELS][N_MAX];
Word16 tmp_ms_sig_e[CPE_CHANNELS];
Word32 concealment_noise_fx[CPE_CHANNELS][L_FRAME48k];
- Word16 concealment_noise_e[CPE_CHANNELS] = { 0 };
+ Word16 concealment_noise_e[CPE_CHANNELS];
+ set16_fx( concealment_noise_e, 0, CPE_CHANNELS );
TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode_bfi;
Word16 q_l = 0, q_r = 0;
+ move16();
+ move16();
Word16 q_snsq = 0;
+ move16();
Word32 *spectralData_tmp[CPE_CHANNELS];
Word16 shift;
Word16 common_exp = 0;
+ move16();
FOR( k = 0; k < CPE_CHANNELS; ++k )
{
@@ -949,8 +1092,8 @@ void ivas_mdct_core_invQ_fx(
move32();
set16_fx( xn_buf, 0, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX );
- set_s( total_nbbits, 0, CPE_CHANNELS );
- set_s( bitsRead, 0, CPE_CHANNELS );
+ set16_fx( total_nbbits, 0, CPE_CHANNELS );
+ set16_fx( bitsRead, 0, CPE_CHANNELS );
tmp_concealment_method = 0;
move16();
@@ -964,7 +1107,7 @@ void ivas_mdct_core_invQ_fx(
test();
test();
test();
- IF( bfi && !MCT_flag && ( GT_16( hCPE->hStereoMdct->mdct_stereo_mode[0], SMDCT_DUAL_MONO ) || GT_16( hCPE->hStereoMdct->mdct_stereo_mode[1], SMDCT_DUAL_MONO ) ) )
+ IF( bfi && !MCT_flag && ( ( hCPE->hStereoMdct->mdct_stereo_mode[0] > SMDCT_DUAL_MONO ) || ( hCPE->hStereoMdct->mdct_stereo_mode[1] > SMDCT_DUAL_MONO ) ) )
{
L_frameTCX[0] = sts[0]->L_frameTCX_past;
move16();
@@ -981,8 +1124,8 @@ void ivas_mdct_core_invQ_fx(
common_exp = s_max( sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp, sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp );
#ifdef MSAN_FIX
- Copy_Scale_sig_16_32( sts[0]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[0], L_frameTCX[0], 15 - ( common_exp - sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ); // 30 - spectral_exp1
- Copy_Scale_sig_16_32( sts[1]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[1], L_frameTCX[1], 15 - ( common_exp - sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ); // 30 - spectral_exp2
+ Copy_Scale_sig_16_32( sts[0]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[0], L_frameTCX[0], sub( 15, sub( common_exp, sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ) ); // 30 - spectral_exp1
+ Copy_Scale_sig_16_32( sts[1]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[1], L_frameTCX[1], sub( 15, sub( common_exp, sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ) ); // 30 - spectral_exp2
#else
Copy_Scale_sig_16_32( sts[0]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[0], L_FRAME_MAX, 15 - ( common_exp - sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ); // 30 - spectral_exp1
Copy_Scale_sig_16_32( sts[1]->hTonalMDCTConc->lastBlockData.spectralData, spectralData_tmp[1], L_FRAME_MAX, 15 - ( common_exp - sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp ) ); // 30 - spectral_exp2
@@ -1007,6 +1150,8 @@ void ivas_mdct_core_invQ_fx(
#endif
sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp = sub( 30, q_l );
sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp = sub( 30, q_r );
+ move16();
+ move16();
}
IF( bfi )
@@ -1050,6 +1195,7 @@ void ivas_mdct_core_invQ_fx(
move16();
sts[ch]->total_brate = L_mult0( add( sts[ch]->bits_frame_channel, add( sts[ch]->side_bits_frame_channel, i_mult( sts[ch]->core, NF_GAIN_BITS ) ) ), FRAMES_PER_SEC );
+ move32();
}
/* Framing parameters */
@@ -1068,14 +1214,16 @@ void ivas_mdct_core_invQ_fx(
st->second_last_core = st->last_core;
move16();
test();
- IF( EQ_16( hCPE->cpe_id, 0 ) && EQ_16( ch, 0 ) )
+ IF( ( hCPE->cpe_id == 0 ) && ( ch == 0 ) )
{
/* add mct and side bits to first handle bitrate to avoid false BER detection */
st->total_brate = L_add( st->total_brate, L_mult0( st->next_bit_pos, FRAMES_PER_SEC ) );
+ move32();
dec_prm_tcx_spec_fx( st, param[ch], &total_nbbits[ch], &bitsRead[ch], p_param[ch], nTnsBitsTCX10[ch] );
/*revert to actual total bitrate assigned to ch0 */
sts[ch]->total_brate = L_mult0( add( add( sts[ch]->bits_frame_channel, sts[ch]->side_bits_frame_channel ), i_mult2( sts[ch]->core, NF_GAIN_BITS ) ), FRAMES_PER_SEC );
+ move32();
}
ELSE
{
@@ -1086,7 +1234,7 @@ void ivas_mdct_core_invQ_fx(
}
ELSE
{
- IF( GT_16( st->nbLostCmpt, 1 ) )
+ if ( GT_16( st->nbLostCmpt, 1 ) )
{
st->flagGuidedAcelp = 0;
move16();
@@ -1100,10 +1248,11 @@ void ivas_mdct_core_invQ_fx(
test();
test();
- IF( ( !st->bfi || st->hTcxCfg->psychParamsCurrent == NULL ) && GT_16( st->core, ACELP_CORE ) )
+ IF( ( !st->bfi || st->hTcxCfg->psychParamsCurrent == NULL ) && ( st->core > ACELP_CORE ) )
{
Word16 last_frame_was_concealed_cng;
- last_frame_was_concealed_cng = ( EQ_16( st->last_core, ACELP_CORE ) ) && ( NE_16( st->last_core, st->last_core_from_bs ) );
+ test();
+ last_frame_was_concealed_cng = ( st->last_core == ACELP_CORE ) && NE_16( st->last_core, st->last_core_from_bs );
SetCurrentPsychParams( st->core, last_frame_was_concealed_cng, st->hTcxCfg );
}
@@ -1135,14 +1284,14 @@ void ivas_mdct_core_invQ_fx(
/* avoid using TD-PLC in only one channel when stereo mode isn't dual mono */
test();
test();
- IF( NE_16( sts[0]->core, sts[1]->core ) && ( EQ_16( sts[0]->core, ACELP_CORE ) || EQ_16( sts[1]->core, ACELP_CORE ) ) )
+ IF( NE_16( sts[0]->core, sts[1]->core ) && ( ( sts[0]->core == ACELP_CORE ) || ( sts[1]->core == ACELP_CORE ) ) )
{
- IF( EQ_16( sts[0]->core, ACELP_CORE ) )
+ IF( sts[0]->core == ACELP_CORE )
{
sts[0]->core = sts[0]->last_core;
move16();
}
- ELSE IF( EQ_16( sts[1]->core, ACELP_CORE ) )
+ ELSE IF( sts[1]->core == ACELP_CORE )
{
sts[1]->core = sts[1]->last_core;
move16();
@@ -1161,7 +1310,7 @@ void ivas_mdct_core_invQ_fx(
* LPC PARAMETERS
*--------------------------------------------------------------------------------*/
- IF( EQ_16( bfi, 0 ) )
+ IF( bfi == 0 )
{
test();
test();
@@ -1237,9 +1386,16 @@ void ivas_mdct_core_invQ_fx(
test();
test();
- IF( !bfi || ( bfi && NE_16( st->core, ACELP_CORE ) ) )
+ IF( !bfi || ( bfi && ( st->core != ACELP_CORE ) ) )
{
- nSubframes[ch] = ( EQ_16( st->core, TCX_10_CORE ) ) ? NB_DIV : 1;
+ IF( EQ_16( st->core, TCX_10_CORE ) )
+ {
+ nSubframes[ch] = NB_DIV;
+ }
+ ELSE
+ {
+ nSubframes[ch] = 1;
+ }
move16();
FOR( k = 0; k < nSubframes[ch]; k++ )
@@ -1256,13 +1412,13 @@ void ivas_mdct_core_invQ_fx(
}
/* Set pointer to parameters */
- prm[ch] = param[ch] + ( k * DEC_NPRM_DIV );
- L_frameTCX_global[ch] = st->hTcxDec->L_frameTCX / nSubframes[ch];
+ prm[ch] = param[ch] + L_mult0( k, DEC_NPRM_DIV );
+ L_frameTCX_global[ch] = idiv1616( st->hTcxDec->L_frameTCX, nSubframes[ch] );
move16();
- L_spec[ch] = st->hTcxCfg->tcx_coded_lines / nSubframes[ch];
+ L_spec[ch] = idiv1616( st->hTcxCfg->tcx_coded_lines, nSubframes[ch] );
move16();
- init_tcx_info_fx( st, st->L_frame / nSubframes[ch], st->hTcxDec->L_frameTCX / nSubframes[ch], k, bfi, &tcx_offset[ch], &tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] );
+ init_tcx_info_fx( st, idiv1616( st->L_frame, nSubframes[ch] ), idiv1616( st->hTcxDec->L_frameTCX, nSubframes[ch] ), k, bfi, &tcx_offset[ch], &tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] );
tmp_concealment_method = 0;
move16();
@@ -1271,9 +1427,9 @@ void ivas_mdct_core_invQ_fx(
test();
test();
test();
- IF( !bfi && st->hTcxCfg->fIsTNSAllowed && GT_16( ch, 0 ) && LT_16( nf_seed, 0 ) )
+ IF( !bfi && st->hTcxCfg->fIsTNSAllowed && ( ch > 0 ) && ( nf_seed < 0 ) )
{
- mvs2s( param[0] + k * DEC_NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, prm[ch] + 1 + NOISE_FILL_RANGES + LTPSIZE, nf_seed * -1 );
+ Copy( param[0] + k * DEC_NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, prm[ch] + 1 + NOISE_FILL_RANGES + LTPSIZE, negate( nf_seed ) );
}
nf_seed = 0;
move16();
@@ -1830,7 +1986,9 @@ void ivas_mdct_core_reconstruct_fx(
Word16 synth_bufFB_fx[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M];
Word16 *synthFB_fx;
Word16 q_syn = 0;
+ move16();
Word16 q_win = -2;
+ move16();
/* TCX */
Word16 xn_buf_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX];
Word16 tcx_offset[CPE_CHANNELS];
@@ -1847,6 +2005,7 @@ void ivas_mdct_core_reconstruct_fx(
/* Initializations */
sts = hCPE->hCoreCoder;
bfi = sts[0]->bfi;
+ move16();
/* TNS, ITF, IMDCT and updates */
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
@@ -1854,12 +2013,21 @@ void ivas_mdct_core_reconstruct_fx(
st = sts[ch];
skip_decoding = 0;
- IF( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
+ if ( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
skip_decoding = 1;
+ move16();
}
- nSubframes[ch] = ( st->core == TCX_20_CORE ) ? 1 : NB_DIV;
+ IF( EQ_16( st->core, TCX_20_CORE ) )
+ {
+ nSubframes[ch] = 1;
+ }
+ ELSE
+ {
+ nSubframes[ch] = NB_DIV;
+ }
+ move16();
synth_fx = synth_buf_fx + st->hTcxDec->old_synth_len;
synthFB_fx = synth_bufFB_fx + st->hTcxDec->old_synth_lenFB;
@@ -1867,11 +2035,11 @@ void ivas_mdct_core_reconstruct_fx(
Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( q_syn, st->Q_syn ) );
set16_fx( synth_fx, 0, L_FRAME_PLUS + M );
set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M );
- IF( NE_16( st->core, ACELP_CORE ) )
+ IF( st->core != ACELP_CORE )
{
- Scale_sig( st->hTcxDec->syn_Overl_TDACFB, shr( L_FRAME_MAX, 1 ), sub( q_win, -1 - st->Q_syn ) );
- Scale_sig( st->hTcxDec->syn_Overl_TDAC, shr( L_FRAME32k, 1 ), sub( q_win, -1 - st->Q_syn ) );
- Scale_sig( st->hTcxDec->old_syn_Overl, shr( L_FRAME32k, 1 ), sub( q_win, -1 - st->Q_syn ) );
+ Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( q_win, sub( -1, st->Q_syn ) ) );
+ Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, sub( -1, st->Q_syn ) ) );
+ Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, sub( -1, st->Q_syn ) ) );
Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) );
Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) );
Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->Q_syn ) );
@@ -1883,30 +2051,49 @@ void ivas_mdct_core_reconstruct_fx(
Scale_sig( synth_buf_fx, 3136, sub( q_win, q_syn ) );
Scale_sig( synth_bufFB_fx, 3136, sub( q_win, q_syn ) );
#endif
- Scale_sig( st->syn, M + 1, q_win - st->Q_syn );
+ Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) );
FOR( k = 0; k < nSubframes[ch]; k++ )
{
- L_spec[ch] = st->hTcxCfg->tcx_coded_lines / nSubframes[ch];
- L_frame_global[ch] = st->L_frame / nSubframes[ch];
- L_frame_globalTCX[ch] = st->hTcxDec->L_frameTCX / nSubframes[ch];
+ Word16 temp_e;
+ Word16 temp = BASOP_Util_Divide1616_Scale( st->hTcxCfg->tcx_coded_lines, nSubframes[ch], &temp_e );
+ temp = shr( temp, sub( 15, temp_e ) );
+ L_spec[ch] = temp;
+ move16();
+ temp = BASOP_Util_Divide1616_Scale( st->L_frame, nSubframes[ch], &temp_e );
+ temp = shr( temp, sub( 15, temp_e ) );
+ L_frame_global[ch] = temp;
+ move16();
+ temp = BASOP_Util_Divide1616_Scale( st->hTcxDec->L_frameTCX, nSubframes[ch], &temp_e );
+ temp = shr( temp, sub( 15, temp_e ) );
+ L_frame_globalTCX[ch] = temp;
+ move16();
init_tcx_info_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], k, bfi, &tcx_offset[ch],
&tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] );
IF( !skip_decoding )
{
- decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, q_win,
- ( ( hCPE->nchan_out == 1 && st->hTcxDec->kernel_type[k] == MDST_IV ) || st->hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) ? MDCT_IV : st->hTcxDec->kernel_type[k],
- fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 );
+ test();
+ test();
+ IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) )
+ {
+ decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, q_win,
+ MDCT_IV, fUseTns[ch][k], &synth_fx[L_mult0( k, L_frame[ch] )], &synthFB_fx[L_mult0( k, L_frameTCX[ch] )], bfi, k, 0 );
+ }
+ ELSE
+ {
+ decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, q_win,
+ st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[L_mult0( k, L_frame[ch] )], &synthFB_fx[L_mult0( k, L_frameTCX[ch] )], bfi, k, 0 );
+ }
}
ELSE
{
- set16_fx( &synth_fx[k * L_frame[ch]], 0, L_frame[ch] );
- set16_fx( &synthFB_fx[k * L_frame[ch]], 0, L_frameTCX[ch] );
+ set16_fx( &synth_fx[L_mult0( k, L_frame[ch] )], 0, L_frame[ch] );
+ set16_fx( &synthFB_fx[L_mult0( k, L_frame[ch] )], 0, L_frameTCX[ch] );
}
}
- IF( EQ_16( bfi, 0 ) && st->hTonalMDCTConc != NULL )
+ IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL )
{
Word16 synth_tmp[L_FRAME48k];
Copy_Scale_sig( synthFB_fx, synth_tmp, st->hTonalMDCTConc->nSamples, 2 );
@@ -1914,9 +2101,9 @@ void ivas_mdct_core_reconstruct_fx(
}
decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, NULL, bfi, MCT_flag );
- Scale_sig( st->hTcxDec->syn_Overl_TDACFB, shr( L_FRAME_MAX, 1 ), sub( -1 - st->Q_syn, q_win ) );
- Scale_sig( st->hTcxDec->syn_Overl_TDAC, shr( L_FRAME32k, 1 ), sub( -1 - st->Q_syn, q_win ) );
- Scale_sig( st->hTcxDec->old_syn_Overl, shr( L_FRAME32k, 1 ), sub( -1 - st->Q_syn, q_win ) );
+ Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( sub( -1, st->Q_syn ), q_win ) );
+ Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), q_win ) );
+ Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), q_win ) );
#ifdef MSAN_FIX
Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) );
Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) );
@@ -1924,9 +2111,9 @@ void ivas_mdct_core_reconstruct_fx(
Scale_sig( synth_buf_fx, 3136, sub( q_syn, q_win ) );
Scale_sig( synth_bufFB_fx, 3136, sub( q_syn, q_win ) );
#endif
- Scale_sig( st->syn, M + 1, st->Q_syn + 2 );
- Scale_sig( st->hTcxDec->syn_OverlFB, shr( L_FRAME_MAX, 1 ), sub( st->Q_syn, q_win ) );
- Scale_sig( st->hTcxDec->syn_Overl, shr( L_FRAME32k, 1 ), sub( st->Q_syn, q_win ) );
+ Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) );
+ Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, q_win ) );
+ Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) );
Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) );
Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) );
}
@@ -1934,28 +2121,36 @@ void ivas_mdct_core_reconstruct_fx(
{
assert( EQ_16( st->bfi, 1 ) );
/* PLC: [TCX: TD PLC] */
- IF( NE_16( MCT_flag, 0 ) )
+ IF( MCT_flag != 0 )
{
con_tcx_fx( st, &synthFB_fx[0] /*, -1.f, NULL, 0, NULL */ );
}
ELSE
{
- Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] - 1 ) );
- con_tcx_ivas_fx( st, &synthFB_fx[0], hCPE->hStereoMdct->lastCoh_fx, &sts[0]->seed_acelp, ( sts[1]->core != ACELP_CORE ) ? 1 : 0, &st->hFdCngDec->hFdCngCom->A_cng[0] );
+ Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, norm_s( sub( st->hFdCngDec->hFdCngCom->A_cng[0], 1 ) ) );
+ IF( sts[1]->core != ACELP_CORE )
+ {
+ con_tcx_ivas_fx( st, &synthFB_fx[0], hCPE->hStereoMdct->lastCoh_fx, &sts[0]->seed_acelp, 1, &st->hFdCngDec->hFdCngCom->A_cng[0] );
+ }
+ ELSE
+ {
+ con_tcx_ivas_fx( st, &synthFB_fx[0], hCPE->hStereoMdct->lastCoh_fx, &sts[0]->seed_acelp, 0, &st->hFdCngDec->hFdCngCom->A_cng[0] );
+ }
}
Scale_sig( synthFB_fx, st->hTcxDec->L_frameTCX, q_syn );
- IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || NE_16( st->hTcxDec->tcxConceal_recalc_exc, 0 ) )
+ IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) )
{
- Scale_sig( synthFB_fx - ( st->hTcxDec->L_frameTCX / 2 + st->hTcxDec->pit_max_TCX + 2 * M ), sub( q_syn, st->Q_exc - 1 ), st->hTcxDec->L_frameTCX / 2 + st->hTcxDec->pit_max_TCX + 2 * M );
+ Scale_sig( synthFB_fx - add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), sub( q_syn, sub( st->Q_exc, 1 ) ), add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ) );
}
ELSE
{
- Scale_sig( synthFB_fx - st->hTcxDec->L_frameTCX, sub( q_syn, st->Q_exc - 1 ), st->hTcxDec->L_frameTCX );
+ Scale_sig( synthFB_fx - st->hTcxDec->L_frameTCX, sub( q_syn, sub( st->Q_exc, 1 ) ), st->hTcxDec->L_frameTCX );
}
lerp( synthFB_fx, synth_fx, st->L_frame, st->hTcxDec->L_frameTCX );
st->con_tcx = 1;
+ move16();
set16_fx( &st->mem_pitch_gain[2], st->lp_gainp_fx, st->nb_subfr );
/* PLC: [TCX: Tonal Concealment] */
@@ -1974,10 +2169,12 @@ void ivas_mdct_core_reconstruct_fx(
st = sts[ch];
- IF( NE_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) && EQ_16( st->core, ACELP_CORE ) )
+ test();
+ test();
+ IF( ( bfi != 0 ) && ( st->last_core != ACELP_CORE ) && ( st->core == ACELP_CORE ) )
{
/* Update FEC_scale_syn parameters */
- IF( EQ_16( st->hTcxLtpDec->tcxltp_gain, 0 ) )
+ IF( st->hTcxLtpDec->tcxltp_gain == 0 )
{
frame_ener_fx( st->L_frame, UNVOICED, synth_fx, shr( st->L_frame, 1 ), &st->enr_old_fx, st->L_frame, 0, 0, 0 );
}
@@ -1990,23 +2187,24 @@ void ivas_mdct_core_reconstruct_fx(
/* Update */
Copy( synth_buf_fx + st->L_frame, st->hTcxDec->old_synth, st->hTcxDec->old_synth_len );
Copy( st->hTcxDec->old_synthFB_fx + st->hTcxDec->L_frameTCX - NS2SA( st->output_Fs, PH_ECU_MEM_NS ), st->hTcxDec->synth_history_fx, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) );
- mvs2s( synth_bufFB_fx + st->hTcxDec->L_frameTCX, st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB );
+ Copy( synth_bufFB_fx + st->hTcxDec->L_frameTCX, st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB );
Scale_sig( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->Q_syn, q_syn ) );
IF( st->hHQ_core != NULL )
{
- mvs2s( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + st->hTcxDec->old_synth_lenFB, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
+ Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + st->hTcxDec->old_synth_lenFB, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) );
}
- mvs2s( st->lsp_q_cng, st->old_lsp_q_cng, M );
- mvs2s( st->lsf_q_cng, st->old_lsf_q_cng, M );
+ Copy( st->lsp_q_cng, st->old_lsp_q_cng, M );
+ Copy( st->lsf_q_cng, st->old_lsf_q_cng, M );
st->last_is_cng = 0;
+ move16();
/* Postfiltering */
Word16 x_fx_16[1200];
Copy_Scale_sig_32_16( x_fx[ch][0], x_fx_16, st->L_frame, sub( 0, q_x ) );
IF( st->p_bpf_noise_buf_32 )
{
- Copy_Scale_sig_32_16( st->p_bpf_noise_buf_32, st->p_bpf_noise_buf, st->L_frame, negate( Q11 ) );
+ Copy_Scale_sig_32_16( st->p_bpf_noise_buf_32, st->p_bpf_noise_buf, st->L_frame, -Q11 );
}
post_decoder_ivas_fx( st, synth_buf_fx, pit_gain_fx[ch], pitch[ch], x_fx_16, st->p_bpf_noise_buf );
@@ -2023,13 +2221,17 @@ void ivas_mdct_core_reconstruct_fx(
/* updates */
st->last_voice_factor_fx = 0;
+ move16();
st->last_coder_type = st->coder_type;
+ move16();
- Copy_Scale_sig_16_32( x_fx_16, x_fx[ch][0], st->L_frame, sub( q_x, 0 ) );
+ Copy_Scale_sig_16_32( x_fx_16, x_fx[ch][0], st->L_frame, q_x - 0 );
}
/* calculate coherence of signal needed when next frame is lost */
- IF( EQ_16( bfi, 0 ) && EQ_16( MCT_flag, 0 ) && EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
+ test();
+ test();
+ IF( ( bfi == 0 ) && ( MCT_flag == 0 ) && EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
Word16 i;
Word64 nrgL_fx, nrgR_fx, xcorr_fx;
@@ -2068,7 +2270,9 @@ void ivas_mdct_core_reconstruct_fx(
e_tmp = add( e_nrgL, e_nrgR );
L_tmp = ISqrt32( L_tmp, &e_tmp );
hCPE->hStereoMdct->lastCoh_fx = extract_l( L_shr( Mpy_32_32( L_abs( W_extract_h( xcorr_fx ) ), L_tmp ), sub( 17, add( e_xcorr, e_tmp ) ) ) );
+ move16();
hCPE->hStereoMdct->lastCoh_fx = s_min( hCPE->hStereoMdct->lastCoh_fx, 16384 );
+ move16();
}
return;
@@ -2076,13 +2280,13 @@ void ivas_mdct_core_reconstruct_fx(
#endif
-#ifndef IVAS_FLOAT_FIXED
/*-----------------------------------------------------------------*
* ivas_mdct_core_tns_ns()
*
* reconstruct time signal
*-----------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
void ivas_mdct_core_tns_ns(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : two entries for each channel in TCX10 */
@@ -2140,55 +2344,11 @@ void ivas_mdct_core_tns_ns(
if ( !bfi )
{
-#ifdef IVAS_FLOAT_FIXED
- Word32 sns_int_scf_fx[FDNS_NPTS], Aq_fx[SNS_NPTS];
- FOR( int c = 0; c < SNS_NPTS; c++ )
- {
- Aq_fx[c] = (Word32) ( Aq[ch][k * M + c] * ONE_IN_Q16 );
- }
-
- sns_interpolate_scalefactors_fx( sns_int_scf_fx, Aq_fx, DEC );
-
- FOR( int c = 0; c < FDNS_NPTS; c++ )
- {
- sns_int_scf[c] = ( (float) sns_int_scf_fx[c] / ONE_IN_Q16 );
- }
-#else
sns_interpolate_scalefactors( &sns_int_scf[0], &Aq[ch][k * M], DEC );
-#endif // IVAS_FLOAT_FIXED
if ( MCT_flag && st->hTonalMDCTConc != NULL && ( ( k + 1 ) == nSubframes[ch] ) )
{
-#ifdef IVAS_FLOAT_FIXED
- Word32 x_fx[N_MAX];
- Word16 x_e, scf_fx[FDNS_NPTS], scf_e[FDNS_NPTS];
- f2me_buf( x[ch][k], x_fx, &x_e, L_frameTCX[ch] );
- /*for ( int j = 0; j < st->hTonalMDCTConc->nScaleFactors; j++ )
- {
- f2me_16( sns_int_scf[j], &scf_fx[j], &scf_e[j] );
- }*/
- Word16 q_shift;
- FOR( Word16 ind = 0; ind < st->hTonalMDCTConc->nScaleFactors; ind++ )
- {
- q_shift = norm_l( sns_int_scf_fx[ind] );
- scf_fx[ind] = extract_h( L_shl( sns_int_scf_fx[ind], q_shift ) );
- scf_e[ind] = 15 - q_shift;
- }
- /*float maxim = 0;
- FOR(Word16 ind = 0; ind < L_frameTCX[ch]; ind++) {
- maxim = fmaxf(maxim, fabsf(x[ch][k][ind]));
- }
- if (maxim >= 1) q_x = norm_l((Word32)maxim);
- FOR(Word16 ind = 0; ind < L_frameTCX[ch]; ind++) {
- x_fx[ind] = (Word32)(x[ch][k][ind] * (1 << q_x));
- }
- x_e = 31 - q_x;*/
-
- TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x_fx, x_e, L_frameTCX[ch], L_frame[ch], &scf_fx[0], scf_e, 0, get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) );
- // st->hTonalMDCTConc->last_block_nrg_flt = me2f( st->hTonalMDCTConc->last_block_nrg, st->hTonalMDCTConc->last_block_nrg_exp );
-#else
TonalMDCTConceal_SaveFreqSignal_ivas( st->hTonalMDCTConc, x[ch][k], L_frameTCX[ch], L_frame[ch], &sns_int_scf[0], get_igf_startline_flt( st, L_frame[ch], L_frameTCX[ch] ) );
-#endif
}
}
else
@@ -2197,6 +2357,7 @@ void ivas_mdct_core_tns_ns(
{
if ( !MCT_flag && st->hTcxDec->cummulative_damping_tcx_float < 0.99f )
// if ( !MCT_flag && st->hTcxDec->cummulative_damping_tcx_float != 1.f )
+
{
float *scf_last, *scf_bg;
float fade_in, fade_out;
@@ -2222,66 +2383,9 @@ void ivas_mdct_core_tns_ns(
}
}
-#ifdef IVAS_FLOAT_FIXED
- Word32 x_fx_[1200];
- Word16 q = 26;
- float maximum = 0;
- FOR( Word16 ind = 0; ind < st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0]; ind++ )
- maximum = fmaxf( maximum, fabsf( x[ch][k][ind] ) );
- if ( maximum >= 1.f )
- q = norm_l( (Word32) maximum ) - 5;
- FOR( Word16 ind = 0; ind < s_max( s_max( L_frameTCX[ch], L_spec[ch] ), st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0] ); ind++ )
- x_fx_[ind] = (Word32) ( x[ch][k][ind] * ( 1 << q ) );
- decoder_tcx_tns_fx( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x_fx_, fUseTns[ch][k], &tnsData[ch][k], bfi, k, 1 );
- FOR( Word16 ind = 0; ind < s_max( s_max( L_frameTCX[ch], L_spec[ch] ), st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0] ); ind++ )
- x[ch][k][ind] = (float) ( x_fx_[ind] ) / (float) ( 1 << q );
-#else
decoder_tcx_tns( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 1 );
-#endif
-
-#ifdef IVAS_FLOAT_FIXED
- Word32 x_fx[L_FRAME48k], sns_int_scf_fx[FDNS_NPTS];
- Word16 q_x = 31, q_sns_int_scf = 31;
- FOR( Word16 c = 0; c < L_FRAME16k; c++ )
- {
- if ( abs( (Word32) x[ch][k][c] ) != 0 )
- q_x = s_min( q_x, norm_l( (Word32) x[ch][k][c] ) );
- }
- FOR( Word16 c = 0; c < FDNS_NPTS; c++ )
- {
- if ( abs( (Word32) sns_int_scf[c] ) != 0 )
- q_sns_int_scf = s_min( q_sns_int_scf, norm_l( (Word32) sns_int_scf[c] ) );
- }
- q_x -= 1;
- q_sns_int_scf -= 1;
- FOR( Word16 c = 0; c < st->hTcxCfg->psychParamsCurrent->nBins; c++ )
- {
- x_fx[c] = (Word32) ( x[ch][k][c] * ( 1 << q_x ) );
- }
- FOR( Word16 c = 0; c < FDNS_NPTS; c++ )
- {
- sns_int_scf_fx[c] = (Word32) ( sns_int_scf[c] * ( 1 << q_sns_int_scf ) );
- }
-
- sns_shape_spectrum_fx( x_fx, &q_x, st->hTcxCfg->psychParamsCurrent, sns_int_scf_fx, q_sns_int_scf, st->hTcxCfg->psychParamsCurrent->nBins );
- IF( q_x + 1 < 31 )
- {
- FOR( Word16 c = 0; c < st->hTcxCfg->psychParamsCurrent->nBins; c++ )
- {
- x[ch][k][c] = ( (float) x_fx[c] / ( 1 << ( q_x + 1 ) ) );
- }
- }
- ELSE
- {
- FOR( Word16 c = 0; c < st->hTcxCfg->psychParamsCurrent->nBins; c++ )
- {
- x[ch][k][c] = ( (float) x_fx[c] / ONE_IN_Q31 );
- }
- }
-#else
sns_shape_spectrum( x[ch][k], st->hTcxCfg->psychParamsCurrent, &sns_int_scf[0], st->hTcxCfg->psychParamsCurrent->nBins );
-#endif // IVAS_FLOAT_FIXED
v_multc( x[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf[FDNS_NPTS - 1], x[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, L_spec[ch] - st->hTcxCfg->psychParamsCurrent->nBins );
decoder_tcx_tns( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0 );
@@ -2300,8 +2404,7 @@ void ivas_mdct_core_tns_ns(
return;
}
-#endif
-#ifdef IVAS_FLOAT_FIXED
+#else
/* Has a missing dependency: TonalMDCTConceal_Apply. Currently not used anywhere and untested.*/
void ivas_mdct_core_tns_ns_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
@@ -2325,7 +2428,7 @@ void ivas_mdct_core_tns_ns_fx(
Word16 left_rect[CPE_CHANNELS];
Word16 L_spec[CPE_CHANNELS];
Word32 sns_int_scf_fx[FDNS_NPTS];
- Word16 exp;
+ Word16 exp, length;
/* Initializations */
sts = hCPE->hCoreCoder;
@@ -2339,19 +2442,34 @@ void ivas_mdct_core_tns_ns_fx(
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
st = sts[ch];
- nSubframes[ch] = EQ_16( st->core, TCX_20_CORE ) ? 1 : NB_DIV;
+ IF( EQ_16( st->core, TCX_20_CORE ) )
+ {
+ nSubframes[ch] = 1;
+ }
+ ELSE
+ {
+ nSubframes[ch] = NB_DIV;
+ }
move16();
L_frame_global[ch] = BASOP_Util_Divide3216_Scale( st->L_frame, nSubframes[ch], &exp );
- L_frame_global[ch] = shl( L_frame_global[ch], exp + 1 );
+ move16();
+ L_frame_global[ch] = shl( L_frame_global[ch], add( exp, 1 ) );
+ move16();
L_frameTCX_glob[ch] = BASOP_Util_Divide3216_Scale( st->hTcxDec->L_frameTCX, nSubframes[ch], &exp );
- L_frameTCX_glob[ch] = shl( L_frameTCX_glob[ch], exp + 1 );
+ move16();
+ L_frameTCX_glob[ch] = shl( L_frameTCX_glob[ch], add( exp, 1 ) );
+ move16();
L_spec[ch] = BASOP_Util_Divide3216_Scale( st->hTcxCfg->tcx_coded_lines, nSubframes[ch], &exp );
- L_spec[ch] = shl( L_spec[ch], exp + 1 );
+ move16();
+ L_spec[ch] = shl( L_spec[ch], add( exp, 1 ) );
+ move16();
- IF( ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) || ( NE_16( st->bfi, 0 ) && EQ_16( st->core, ACELP_CORE ) ) ) /* indicates LFE with no content, or odd number of channels */
+ test();
+ test();
+ IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) || ( ( st->bfi != 0 ) && ( st->core == ACELP_CORE ) ) ) /* indicates LFE with no content, or odd number of channels */
{
IF( st->hTonalMDCTConc != NULL )
{
@@ -2369,11 +2487,11 @@ void ivas_mdct_core_tns_ns_fx(
Word16 q_x;
q_x = sub( 31, x_e[ch][k] );
- IF( EQ_16( bfi, 0 ) )
+ IF( bfi == 0 )
{
sns_interpolate_scalefactors_fx( sns_int_scf_fx, &Aq_fx[ch][k * M], DEC );
- IF( NE_16( MCT_flag, 0 ) && st->hTonalMDCTConc != NULL && EQ_16( add( k, 1 ), nSubframes[ch] ) )
+ IF( ( MCT_flag != 0 ) && st->hTonalMDCTConc != NULL && EQ_16( add( k, 1 ), nSubframes[ch] ) )
{
Word16 scf_fx[FDNS_NPTS], scf_e[FDNS_NPTS];
Word16 q_shift;
@@ -2381,7 +2499,9 @@ void ivas_mdct_core_tns_ns_fx(
{
q_shift = norm_l( sns_int_scf_fx[ind] );
scf_fx[ind] = extract_h( L_shl( sns_int_scf_fx[ind], q_shift ) );
+ move16();
scf_e[ind] = sub( 15, q_shift );
+ move16();
}
TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x_fx[ch][k], x_e[ch][k], L_frameTCX[ch], L_frame[ch], &scf_fx[0], scf_e, 0, get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) );
}
@@ -2390,7 +2510,7 @@ void ivas_mdct_core_tns_ns_fx(
{
IF( st->hTonalMDCTConc != NULL )
{
- IF( EQ_16( MCT_flag, 0 ) && LT_16( st->hTcxDec->cummulative_damping_tcx, 32440 ) )
+ IF( ( MCT_flag == 0 ) && LT_16( st->hTcxDec->cummulative_damping_tcx, 32440 ) )
{
Word16 *scf_last_m, *scf_last_e;
Word32 *scf_bg;
@@ -2401,73 +2521,110 @@ void ivas_mdct_core_tns_ns_fx(
scf_bg = &st->hTonalMDCTConc->scaleFactorsBackground_fx[0];
st->hTonalMDCTConc->scf_fadeout = mult( st->hTonalMDCTConc->scf_fadeout, 31130 ); // 0.95 in Q15 = 31130
+ move16();
fade_out = st->hTonalMDCTConc->scf_fadeout;
+ move16();
fade_in = sub( 32767, fade_out );
FOR( Word16 i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ )
{
- sns_int_scf_fx[i] = L_add( Mpy_32_16_1( L_shl( scf_last_m[i], 1 + scf_last_e[i] ), fade_out ), Mpy_32_16_1( L_shl( scf_bg[i], 1 ), fade_in ) );
+ sns_int_scf_fx[i] = Madd_32_16( Mpy_32_16_1( L_shl( scf_last_m[i], add( 1, scf_last_e[i] ) ), fade_out ), L_shl( scf_bg[i], 1 ), fade_in );
+ move32();
}
}
ELSE
{
st->hTonalMDCTConc->scf_fadeout = 32767;
+ move16();
FOR( Word16 i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ )
{
- sns_int_scf_fx[i] = L_shl( st->hTonalMDCTConc->lastBlockData.scaleFactors[i], 1 + st->hTonalMDCTConc->lastBlockData.scaleFactors_exp[i] );
+ sns_int_scf_fx[i] = L_shl( st->hTonalMDCTConc->lastBlockData.scaleFactors[i], add( 1, st->hTonalMDCTConc->lastBlockData.scaleFactors_exp[i] ) );
+ move32();
}
}
}
}
Word16 norm_x;
q_x = sub( q_x, 5 );
- Scale_sig32( &x_fx[ch][k][0], L_spec[ch], -5 );
- decoder_tcx_tns_fx( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x_fx[ch][k], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 1 );
- norm_x = getScaleFactor32( &x_fx[ch][k][0], L_spec[ch] );
- Scale_sig32( &x_fx[ch][k][0], L_spec[ch], norm_x );
+ length = L_frameTCX[ch];
+ move16();
+ test();
+ test();
+ test();
+ test();
+ test();
+ if ( EQ_16( L_frame[ch], shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && ( ( NE_16( st->hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns[ch][k], 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec[ch], L_frameTCX[ch] ) ) )
+ {
+ length = L_spec[ch];
+ move16();
+ }
+ Scale_sig32( &x_fx[ch][k][0], length, -5 );
+ decoder_tcx_tns_fx( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x_fx[ch][k], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 1, &length );
+ norm_x = getScaleFactor32( &x_fx[ch][k][0], length );
+ Scale_sig32( &x_fx[ch][k][0], length, norm_x );
q_x = add( q_x, norm_x );
x_e[ch][k] = sub( 31, q_x );
+ move16();
Word16 q_sns_int_scf;
- Word16 q_2, length;
+ Word16 q_2;
q_sns_int_scf = add( 16 - 1, getScaleFactor32( sns_int_scf_fx, FDNS_NPTS ) );
// q_sns_int_scf -= 1;
FOR( Word16 c = 0; c < FDNS_NPTS; c++ )
{
- sns_int_scf_fx[c] = L_shl( sns_int_scf_fx[c], q_sns_int_scf - 16 );
+ sns_int_scf_fx[c] = L_shl( sns_int_scf_fx[c], sub( q_sns_int_scf, 16 ) );
+ move32();
}
q_2 = q_x;
+ move16();
sns_shape_spectrum_fx( x_fx[ch][k], &q_x, st->hTcxCfg->psychParamsCurrent, sns_int_scf_fx, q_sns_int_scf, st->hTcxCfg->psychParamsCurrent->nBins, &length );
IF( LT_16( q_2, add( q_x, 1 ) ) ) /*scaling to q_2*/
{
Scale_sig32( &x_fx[ch][k][0], length, q_2 - q_x - 1 );
q_x = q_2;
+ move16();
}
ELSE /*scaling to q_x+1*/
{
- Scale_sig32( &x_fx[ch][k][0] + length, L_spec[ch] - length, q_x + 1 - q_2 );
+ Scale_sig32( &x_fx[ch][k][0] + length, sub( L_spec[ch], length ), sub( add( q_x, 1 ), q_2 ) );
q_x = add( q_x, 1 );
}
x_e[ch][k] = sub( 31, q_x );
+ move16();
- v_multc_fixed( x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf_fx[FDNS_NPTS - 1], x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, L_spec[ch] - st->hTcxCfg->psychParamsCurrent->nBins );
+ v_multc_fixed( x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf_fx[FDNS_NPTS - 1], x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sub( L_spec[ch], st->hTcxCfg->psychParamsCurrent->nBins ) );
q_2 = sub( add( q_x, q_sns_int_scf ), 31 );
- Scale_sig32( &x_fx[ch][k][0], st->hTcxCfg->psychParamsCurrent->nBins, q_2 - q_x );
+ Scale_sig32( &x_fx[ch][k][0], st->hTcxCfg->psychParamsCurrent->nBins, sub( q_2, q_x ) );
q_x = q_2;
+ move16();
x_e[ch][k] = sub( 31, q_x );
+ move16();
q_x = sub( q_x, 5 );
- Scale_sig32( &x_fx[ch][k][0], L_spec[ch], -5 );
- decoder_tcx_tns_fx( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x_fx[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0 );
- norm_x = getScaleFactor32( &x_fx[ch][k][0], L_spec[ch] );
- Scale_sig32( &x_fx[ch][k][0], L_spec[ch], norm_x );
+ length = L_frameTCX[ch];
+ move16();
+ test();
+ test();
+ test();
+ test();
+ test();
+ if ( EQ_16( L_frame[ch], shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && ( ( NE_16( st->hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns[ch][k], 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec[ch], L_frameTCX[ch] ) ) )
+ {
+ length = L_spec[ch];
+ move16();
+ }
+ Scale_sig32( &x_fx[ch][k][0], length, -5 );
+ decoder_tcx_tns_fx( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x_fx[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0, &length );
+ norm_x = getScaleFactor32( &x_fx[ch][k][0], length );
+ Scale_sig32( &x_fx[ch][k][0], length, norm_x );
q_x = add( q_x, norm_x );
x_e[ch][k] = sub( 31, q_x );
+ move16();
}
- IF( NE_16( bfi, 0 ) && NE_16( st->tonal_mdct_plc_active, 0 ) )
+ IF( ( bfi != 0 ) && ( st->tonal_mdct_plc_active != 0 ) )
{
Word16 q_x, q_x_old;
FOR( Word16 i = 0; i < FDNS_NPTS; i++ )
@@ -2481,34 +2638,48 @@ void ivas_mdct_core_tns_ns_fx(
IF( LT_16( q_x_old, q_x ) )
{
x_e[ch][0] = sub( 31, q_x_old );
+ move16();
FOR( Word16 i = 0; i < st->hTonalMDCTConc->pTCI->numIndexes; i++ )
{
FOR( Word16 l = st->hTonalMDCTConc->pTCI->lowerIndex[i]; l <= st->hTonalMDCTConc->pTCI->upperIndex[i]; l++ )
{
- x_fx[ch][0][l] = L_shr( x_fx[ch][0][l], q_x - q_x_old );
+ x_fx[ch][0][l] = L_shr( x_fx[ch][0][l], sub( q_x, q_x_old ) );
+ move32();
}
}
}
ELSE
{
x_e[ch][0] = sub( 31, q_x );
+ move16();
FOR( Word16 i = 0; i < st->hTonalMDCTConc->pTCI->numIndexes; i++ )
{
FOR( Word16 l = 0; l < st->hTonalMDCTConc->pTCI->lowerIndex[i]; l++ )
{
x_fx[ch][0][l] = L_shr( x_fx[ch][0][l], sub( q_x_old, q_x ) );
+ move32();
}
FOR( Word16 l = st->hTonalMDCTConc->pTCI->upperIndex[i] + 1; l < L_spec[ch]; l++ )
{
x_fx[ch][0][l] = L_shr( x_fx[ch][0][l], sub( q_x_old, q_x ) );
+ move32();
}
}
}
}
+ test();
+ test();
IF( ( bfi || MCT_flag ) && st->hTonalMDCTConc != NULL )
{
- TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX[ch], ( st->hTcxDec->tcxltp_last_gain_unmodified > 0 ) ? st->old_fpitch : 0, bfi, bfi && st->tonal_mdct_plc_active );
+ IF( st->hTcxDec->tcxltp_last_gain_unmodified > 0 )
+ {
+ TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX[ch], st->old_fpitch, bfi, (Word8) s_and( bfi, st->tonal_mdct_plc_active ) );
+ }
+ ELSE
+ {
+ TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX[ch], 0, bfi, (Word8) s_and( bfi, st->tonal_mdct_plc_active ) );
+ }
}
}
diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c
index 75d42d5ec179ba90db4990ee4cbc00292e36e293..fabd897f50f26fb2238b9deecbc18ad7d80e39ae 100644
--- a/lib_dec/ivas_mono_dmx_renderer.c
+++ b/lib_dec/ivas_mono_dmx_renderer.c
@@ -35,8 +35,7 @@
#include
#include "cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "ivas_cnst.h"
@@ -73,9 +72,13 @@ ivas_error ivas_mono_dmx_renderer_open(
}
hDownmix->inputEnergy_fx = 0;
+ move16();
hDownmix->protoEnergy_fx = 0;
+ move16();
hDownmix->Q_inputEner = 0;
+ move16();
hDownmix->Q_protoEner = 0;
+ move16();
st_ivas->hMonoDmxRenderer = hDownmix;
@@ -112,6 +115,7 @@ void ivas_mono_dmx_renderer_close(
MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */
)
{
+ test();
IF( hMonoDmxRenderer == NULL || *hMonoDmxRenderer == NULL )
{
return;
@@ -219,14 +223,17 @@ void ivas_mono_downmix_render_passive_fx(
Word16 diff_shift, div, div_sqrt;
Word32 protoEner_pre, inputEner_pre;
numInputChannels = st_ivas->nSCE;
- IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) SBA_ISM_FORMAT ) )
+ move16();
+ if ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
numInputChannels = st_ivas->nchan_ism;
+ move16();
}
- IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) MASA_ISM_FORMAT ) )
+ IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
- IF( EQ_16( (Word16) st_ivas->ism_mode, (Word16) ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( (Word16) st_ivas->ism_mode, (Word16) ISM_MASA_MODE_PARAM_ONE_OBJ ) )
+ 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 ) )
{
numInputChannels = add( st_ivas->nchan_transport, 1 );
}
@@ -240,10 +247,11 @@ void ivas_mono_downmix_render_passive_fx(
set32_fx( proto_signal_fx, 0, output_frame );
Word16 Output_norm = 32;
- FOR( int lp = 0; lp < numInputChannels; lp++ )
+ move16();
+ FOR( Word16 lp = 0; lp < numInputChannels; lp++ )
{
Word16 norm = L_norm_arr( output_f_fx[lp], output_frame );
- Output_norm = min( Output_norm, norm );
+ Output_norm = s_min( Output_norm, norm );
}
Q_shift = sub( Output_norm, find_guarded_bits_fx( numInputChannels ) );
@@ -256,7 +264,9 @@ void ivas_mono_downmix_render_passive_fx(
/* compute the input energy, proto energy after smoothing */
hDownmix->inputEnergy_fx = Mpy_32_16_1( hDownmix->inputEnergy_fx, DOWNMIX_ALPHA_FX );
+ move32();
hDownmix->protoEnergy_fx = Mpy_32_16_1( hDownmix->protoEnergy_fx, DOWNMIX_ALPHA_FX );
+ move32();
proto_norm = L_norm_arr( proto_signal_fx, output_frame );
@@ -279,7 +289,7 @@ void ivas_mono_downmix_render_passive_fx(
/* compute the eq factor */
- IF( EQ_32( hDownmix->protoEnergy_fx, 0 ) )
+ IF( hDownmix->protoEnergy_fx == 0 )
{
norm_protoEner = add( 31, hDownmix->Q_protoEner );
}
@@ -287,7 +297,7 @@ void ivas_mono_downmix_render_passive_fx(
{
norm_protoEner = add( norm_l( hDownmix->protoEnergy_fx ), hDownmix->Q_protoEner );
}
- IF( EQ_32( hDownmix->inputEnergy_fx, 0 ) )
+ IF( hDownmix->inputEnergy_fx == 0 )
{
norm_inputEner = add( 31, hDownmix->Q_inputEner );
}
@@ -296,31 +306,41 @@ void ivas_mono_downmix_render_passive_fx(
norm_inputEner = add( norm_l( hDownmix->inputEnergy_fx ), hDownmix->Q_inputEner );
}
- norm_protoEner = min( norm_protoEner, sub( shl( add( add( 11, Q_shift ), proto_shift ), 1 ), 31 ) ) - 1;
- norm_inputEner = min( norm_inputEner, sub( shl( add( 11, input_shift ), 1 ), 31 ) ) - 1;
+ norm_protoEner = sub( s_min( norm_protoEner, sub( shl( add( add( 11, Q_shift ), proto_shift ), 1 ), 31 ) ), 1 );
+ norm_inputEner = sub( s_min( norm_inputEner, sub( shl( add( 11, input_shift ), 1 ), 31 ) ), 1 );
hDownmix->protoEnergy_fx = L_shl( hDownmix->protoEnergy_fx, sub( norm_protoEner, hDownmix->Q_protoEner ) );
+ move32();
hDownmix->inputEnergy_fx = L_shl( hDownmix->inputEnergy_fx, sub( norm_inputEner, hDownmix->Q_inputEner ) );
+ move32();
hDownmix->Q_protoEner = norm_protoEner;
+ move16();
hDownmix->Q_inputEner = norm_inputEner;
+ move16();
protoEner_pre = L_shl( protoEner_pre, sub( norm_protoEner, sub( shl( add( add( 11, Q_shift ), proto_shift ), 1 ), 31 ) ) );
inputEner_pre = L_shl( inputEner_pre, sub( norm_inputEner, sub( shl( add( 11, input_shift ), 1 ), 31 ) ) );
hDownmix->protoEnergy_fx = L_add( hDownmix->protoEnergy_fx, protoEner_pre );
+ move32();
hDownmix->inputEnergy_fx = L_add( hDownmix->inputEnergy_fx, inputEner_pre );
+ move32();
diff_shift = sub( hDownmix->Q_inputEner, hDownmix->Q_protoEner );
- IF( GT_16( diff_shift, 0 ) )
+ IF( diff_shift > 0 )
{
hDownmix->inputEnergy_fx = L_shr( hDownmix->inputEnergy_fx, diff_shift );
+ move32();
hDownmix->Q_inputEner = sub( hDownmix->Q_inputEner, diff_shift );
+ move16();
}
ELSE
{
hDownmix->protoEnergy_fx = L_shr( hDownmix->protoEnergy_fx, -diff_shift );
+ move32();
hDownmix->Q_protoEner = add( hDownmix->Q_protoEner, diff_shift );
+ move16();
}
IF( GE_32( hDownmix->protoEnergy_fx, L_shr( hDownmix->inputEnergy_fx, 2 ) ) )
{
@@ -349,6 +369,7 @@ void ivas_mono_downmix_render_passive_fx(
* Downmix process in McMASA
*------------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
void ivas_mono_stereo_downmix_mcmasa(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
float *output_f[], /* i/o: synthesized core-coder transport channels/mono or stereo output */
@@ -388,7 +409,7 @@ void ivas_mono_stereo_downmix_mcmasa(
return;
}
-#ifdef IVAS_FLOAT_FIXED
+#else
void ivas_mono_stereo_downmix_mcmasa_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
Word32 *output_f_fx[], /* i/o: synthesized core-coder transport channels/mono or stereo output */
@@ -402,21 +423,22 @@ void ivas_mono_stereo_downmix_mcmasa_fx(
set32_fx( dmx_tmp_fx, 0, output_frame );
/* Dowmix center channel to L and R */
- if ( st_ivas->hDecoderConfig->nchan_out == 2 && st_ivas->hOutSetup.separateChannelEnabled )
+ test();
+ IF( EQ_16( st_ivas->hDecoderConfig->nchan_out, 2 ) && st_ivas->hOutSetup.separateChannelEnabled )
{
v_multc_acc_32_16( output_f_fx[st_ivas->hOutSetup.separateChannelIndex], INV_SQRT2_FX_Q15, output_f_fx[0], output_frame );
v_multc_acc_32_16( output_f_fx[st_ivas->hOutSetup.separateChannelIndex], INV_SQRT2_FX_Q15, output_f_fx[1], output_frame );
}
/* Mono downmix */
- else if ( st_ivas->hDecoderConfig->nchan_out == 1 )
+ ELSE IF( EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) )
{
/* Downmix L and R to dmx_tmp */
- for ( i = 0; i < st_ivas->nchan_transport; i++ )
+ FOR( i = 0; i < st_ivas->nchan_transport; i++ )
{
v_multc_acc_32_16( output_f_fx[i], INV_SQRT2_FX_Q15, dmx_tmp_fx, output_frame );
}
/* Add center channel */
- if ( st_ivas->hOutSetup.separateChannelEnabled )
+ IF( st_ivas->hOutSetup.separateChannelEnabled )
{
v_add_32( output_f_fx[st_ivas->hOutSetup.separateChannelIndex], dmx_tmp_fx, dmx_tmp_fx, output_frame );
}
@@ -437,6 +459,7 @@ void ivas_mono_stereo_downmix_mcmasa_fx(
* Apply non-diegetic panning
*------------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
void ivas_apply_non_diegetic_panning(
float *output_f[], /* i/o: core-coder transport mono channel/stereo output */
const float non_diegetic_pan_gain, /* i : non-diegetic panning gain */
@@ -454,7 +477,7 @@ void ivas_apply_non_diegetic_panning(
return;
}
-#ifdef IVAS_FLOAT_FIXED
+#else
void ivas_apply_non_diegetic_panning_fx(
Word32 *output_f_fx[], /* i/o: core-coder transport mono channel/stereo output */
const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain */
@@ -463,8 +486,8 @@ void ivas_apply_non_diegetic_panning_fx(
{
Word16 pan_left_fx, pan_right_fx;
- pan_left_fx = mult( non_diegetic_pan_gain_fx, 16348 ) + 16348;
- pan_right_fx = 32767 - pan_left_fx;
+ pan_left_fx = add( mult( non_diegetic_pan_gain_fx, 16348 ), 16348 );
+ pan_right_fx = sub( 32767, pan_left_fx );
v_multc_fixed( output_f_fx[0], L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame );
v_multc_fixed( output_f_fx[0], L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame );
diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c
index aeb119af8f30baf540649e04ba9fde972830e08f..d6f965c8fc206980724099fb5392bc21c76983b9 100644
--- a/lib_dec/ivas_objectRenderer_internal.c
+++ b/lib_dec/ivas_objectRenderer_internal.c
@@ -40,11 +40,8 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "debug.h"
-#define float_to_fixed( n, factor ) ( round( n * ( 1 << factor ) ) )
-#define fixed_to_float( n, factor ) ( (float) n / ( 1 << factor ) )
#endif
@@ -61,7 +58,8 @@ ivas_error ivas_td_binaural_open_fx(
{
*num_src = st_ivas->nchan_transport;
move16();
- IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ test();
+ if ( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
*num_src = st_ivas->nchan_ism;
move16();
@@ -104,7 +102,15 @@ ivas_error ivas_td_binaural_renderer_fx(
Word16 ism_md_subframe_update;
Word16 nchan_transport;
test();
- nchan_transport = ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) ? st_ivas->nchan_ism : st_ivas->nchan_transport;
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ {
+ nchan_transport = st_ivas->nchan_ism;
+ }
+ ELSE
+ {
+ nchan_transport = st_ivas->nchan_transport;
+ }
+ move16();
IF( st_ivas->hDecoderConfig->Opt_delay_comp )
{
@@ -114,12 +120,13 @@ ivas_error ivas_td_binaural_renderer_fx(
{
ism_md_subframe_update = 2;
}
+ move16();
- IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ if ( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
ism_md_subframe_update = 2;
+ move16();
}
-
return ivas_td_binaural_renderer_unwrap_fx( st_ivas->hReverb, st_ivas->transport_config, st_ivas->hBinRendererTd, nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, st_ivas->hCombinedOrientationData, ism_md_subframe_update, output, output_frame, MAX_PARAM_SPATIAL_SUBFRAMES );
}
#else
@@ -186,7 +193,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
Word16 enableCombinedOrientation;
/* Set the number of ISMs */
- IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
nchan_ism_internal = st_ivas->nchan_ism;
move16();
@@ -195,7 +202,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
ch_offset = 2;
move16();
}
- ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
nchan_ism_internal = st_ivas->nchan_ism;
move16();
@@ -224,7 +231,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
ism_md_subframe_update_jbm = sub( st_ivas->hTcBuffer->nb_subframes, 2 );
}
- IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
ism_md_subframe_update_jbm = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 2 ) );
}
@@ -248,6 +255,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
/* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
tmp = 0;
+ move16();
IF( n_samples_granularity != 0 )
{
tmp = idiv1616( n_samples_granularity, slot_size );
@@ -258,6 +266,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
last_sf = first_sf;
move16();
st_ivas->hTcBuffer->slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, slots_to_render );
+ move16();
WHILE( slots_to_render > 0 )
{
@@ -275,7 +284,8 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
FOR( nS = 0; nS < nchan_ism; nS++ )
{
- IF( !( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( nS, LFE_CHANNEL ) ) ) /* Skip LFE for MC */
+ test();
+ IF( !( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( nS, LFE_CHANNEL ) ) ) /* Skip LFE for MC */
{
st_ivas->hBinRendererTd->Sources[c_indx]->InputFrame_p_fx = tc_local_fx[nS]; /* Q11 */
st_ivas->hBinRendererTd->Sources[c_indx]->SrcRend_p->InputAvailable = TRUE;
@@ -298,6 +308,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
tmp_Quaternion_fx = &st_ivas->hCombinedOrientationData->Quaternions[st_ivas->hCombinedOrientationData->subframe_idx];
tmp_vector_fx = &st_ivas->hCombinedOrientationData->listenerPos[st_ivas->hCombinedOrientationData->subframe_idx];
enableCombinedOrientation = st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx];
+ move16();
/* Shifting x_fx, y_fx, z_fx to the same Q-factor as Listener_p->Pos_q (usually Q25) */
Word16 pos_q = st_ivas->hBinRendererTd->Listener_p->Pos_q;
@@ -306,6 +317,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
tmp_vector_fx->y_fx = L_shr( tmp_vector_fx->y_fx, sub( tmp_vector_fx->q_fact, pos_q ) );
tmp_vector_fx->z_fx = L_shr( tmp_vector_fx->z_fx, sub( tmp_vector_fx->q_fact, pos_q ) );
tmp_vector_fx->q_fact = pos_q;
+ move16();
}
ELSE
{
@@ -315,17 +327,19 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
move16();
}
- IF( ( error = TDREND_Update_listener_orientation_fx( st_ivas->hBinRendererTd,
- enableCombinedOrientation,
- tmp_Quaternion_fx,
- tmp_vector_fx ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = TDREND_Update_listener_orientation_fx( st_ivas->hBinRendererTd,
+ enableCombinedOrientation,
+ tmp_Quaternion_fx,
+ tmp_vector_fx ) ),
+ IVAS_ERR_OK ) )
{
return error;
}
- IF( st_ivas->hRenderConfig != NULL && st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
+ test();
+ IF( st_ivas->hRenderConfig != NULL && EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
- IF( ( error = ivas_reverb_process_fx( st_ivas->hReverb, st_ivas->transport_config, 0, tc_local_fx, p_reverb_signal_fx, 0 ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_reverb_process_fx( st_ivas->hReverb, st_ivas->transport_config, 0, tc_local_fx, p_reverb_signal_fx, 0 ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -334,12 +348,13 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
/* Render subframe */
/* ism_md_subframe_update_jbm != subframe_idx: trigger update only for ism_md_subframe_update_jbm == subframe_idx,
where then the two TDREND_GetMix()-arguments subframe_idx and ism_md_subframe_update are equal, and we want to enforce the update inside TDREND_GetMix to use subframe_idx == 0 */
- IF( ( error = TDREND_GetMix_fx( st_ivas->hBinRendererTd, output_fx_local, output_frame, 0, ism_md_subframe_update_jbm != subframe_idx ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = TDREND_GetMix_fx( st_ivas->hBinRendererTd, output_fx_local, output_frame, 0, ism_md_subframe_update_jbm != subframe_idx ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( st_ivas->hRenderConfig != NULL && st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
+ test();
+ IF( st_ivas->hRenderConfig != NULL && EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
/* add reverb to rendered signals */
v_add_32( reverb_signal_fx[0], output_fx_local[0], output_fx_local[0], output_frame );
diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c
index d239baccc9d718c2df27ef202e26a7557ee3c5eb..bc136eb1a8586a8be89073c19a800161ba8355da 100644
--- a/lib_dec/ivas_omasa_dec.c
+++ b/lib_dec/ivas_omasa_dec.c
@@ -40,7 +40,7 @@
#include "ivas_rom_com.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#ifdef IVAS_FLOAT_FIXED
#include "math.h" // temporary (for fabs)
#endif
@@ -147,11 +147,13 @@ ivas_error ivas_omasa_data_open_fx(
}
hMasaIsmData->objectsMoved = 0;
+ move16();
hMasaIsmData->delayBuffer_fx = NULL;
FOR( ch = 0; ch < MAX_NUM_OBJECTS; ch++ )
{
hMasaIsmData->ism_is_edited[ch] = 0;
+ move16();
hMasaIsmData->q_elevation_old_fx[ch] = 0;
move32();
hMasaIsmData->q_azimuth_old_fx[ch] = 0;
@@ -302,6 +304,7 @@ ivas_error ivas_omasa_dec_config_fx(
*-----------------------------------------------------------------*/
old_renderer_type = st_ivas->renderer_type;
+ move32();
/* MASA reconfig. */
cpe_brate = calculate_cpe_brate_MASA_ISM_fx( st_ivas->ism_mode, ivas_total_brate, st_ivas->nchan_ism );
@@ -309,14 +312,14 @@ ivas_error ivas_omasa_dec_config_fx(
test();
test();
test();
- IF( st_ivas->ini_active_frame == 0 && NE_32( ivas_total_brate, FRAME_NO_DATA ) && LT_32( cpe_brate, MASA_STEREO_MIN_BITRATE ) && EQ_16( st_ivas->nCPE, 1 ) )
+ IF( ( st_ivas->ini_active_frame == 0 ) && ( ivas_total_brate != FRAME_NO_DATA ) && LT_32( cpe_brate, MASA_STEREO_MIN_BITRATE ) && EQ_16( st_ivas->nCPE, 1 ) )
{
st_ivas->hCPE[0]->nchan_out = 1;
move16();
}
ELSE
{
- IF( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -335,9 +338,9 @@ ivas_error ivas_omasa_dec_config_fx(
/* OMASA reconfig. */
test();
- IF( st_ivas->hMasaIsmData == NULL && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ IF( st_ivas->hMasaIsmData == NULL && EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
- IF( ( error = ivas_omasa_data_open_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_omasa_data_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -346,7 +349,7 @@ ivas_error ivas_omasa_dec_config_fx(
ivas_set_omasa_TC_fx( st_ivas->ism_mode, st_ivas->nchan_ism, &st_ivas->nSCE, &st_ivas->nCPE );
/* re-configure hp20 memories */
- IF( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -361,28 +364,22 @@ ivas_error ivas_omasa_dec_config_fx(
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] );
+ ism_total_brate = L_add( ism_total_brate, sep_object_brate[sub( k, 2 )][sub( st_ivas->nSCE, 1 )] );
}
brate_SCE = 0;
move32();
- IF( GT_16( st_ivas->nSCE, 0 ) )
+ IF( st_ivas->nSCE > 0 )
{
- brate_SCE = sep_object_brate[k - 2][st_ivas->nSCE - 1];
+ brate_SCE = sep_object_brate[sub( k, 2 )][sub( st_ivas->nSCE, 1 )];
move32();
}
brate_CPE = L_sub( ivas_total_brate, ism_total_brate );
-#ifdef IVAS_FLOAT_FIXED
- IF( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, 1, 2, 0, brate_SCE, brate_CPE ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-#else
- IF( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, 1, 2, 0, brate_SCE, brate_CPE ) ) != IVAS_ERR_OK )
+
+ IF( NE_32( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, 1, 2, 0, brate_SCE, brate_CPE ) ), IVAS_ERR_OK ) )
{
return error;
}
-#endif
IF( NE_16( ism_mode_old, st_ivas->ism_mode ) )
{
@@ -391,27 +388,27 @@ ivas_error ivas_omasa_dec_config_fx(
move16();
test();
- IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
+ 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 ) )
{
n_MD = 1;
move16();
IF( st_ivas->hIsmMetaData[0] == NULL )
{
- IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, 1, NULL ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, 1, NULL ) ), IVAS_ERR_OK ) )
{
return error;
}
}
}
- ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
n_MD = st_ivas->nchan_ism;
move16();
ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
- IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -433,9 +430,9 @@ ivas_error ivas_omasa_dec_config_fx(
IF( NE_16( old_renderer_type, st_ivas->renderer_type ) )
{
- IF( EQ_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
{
- IF( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -452,16 +449,16 @@ ivas_error ivas_omasa_dec_config_fx(
ivas_omasa_separate_object_renderer_close( st_ivas );
}
- IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) )
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) )
{
- IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
/* Allocate TD renderer for the objects in DISC mode */
#ifdef FIX_1033_MEMORY_LEAK_OMASA
IF( st_ivas->hBinRendererTd == NULL )
{
#endif
- IF( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, num_src ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, num_src ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -470,7 +467,7 @@ ivas_error ivas_omasa_dec_config_fx(
#endif
/* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
- IF( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -479,7 +476,8 @@ ivas_error ivas_omasa_dec_config_fx(
{
/* TD renderer handle */
#ifdef FIX_1033_MEMORY_LEAK_OMASA
- IF( st_ivas->hBinRendererTd != NULL && st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE )
+ test();
+ IF( st_ivas->hBinRendererTd != NULL && EQ_16( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM, TRUE ) )
{
#endif
ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
@@ -494,17 +492,19 @@ ivas_error ivas_omasa_dec_config_fx(
}
}
- IF( st_ivas->renderer_type == RENDERER_DIRAC )
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
{
- IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) )
{
return error;
}
- 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 )
+ 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 ) )
{
/* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
- IF( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -522,7 +522,7 @@ ivas_error ivas_omasa_dec_config_fx(
IF( st_ivas->hDiracDecBin != NULL )
{
- IF( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) )
{
return error;
@@ -533,7 +533,7 @@ ivas_error ivas_omasa_dec_config_fx(
* CLDFB instances
*-----------------------------------------------------------------*/
- IF( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, 2, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, 2, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -543,12 +543,12 @@ ivas_error ivas_omasa_dec_config_fx(
*-----------------------------------------------------------------*/
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
- IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) )
{
return error;
}
#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED
- IF( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -919,6 +919,7 @@ void ivas_set_surplus_brate_dec(
move32();
st_ivas->hCPE[0]->brate_surplus = L_sub( st_ivas->hSCE[0]->element_brate, *ism_total_brate );
+ move32();
/* set 'st->total_brate'; there are no meta-data in ISM_MASA_MODE_PARAM_ONE_OBJ mode */
st_ivas->hSCE[0]->hCoreCoder[0]->total_brate = *ism_total_brate;
@@ -926,7 +927,7 @@ void ivas_set_surplus_brate_dec(
st_ivas->hSCE[0]->hCoreCoder[0]->low_rate_mode = 0;
move16();
- IF( EQ_16( st_ivas->hIsmMetaData[0]->ism_imp, ISM_NO_META ) )
+ if ( EQ_16( st_ivas->hIsmMetaData[0]->ism_imp, ISM_NO_META ) )
{
st_ivas->hSCE[0]->hCoreCoder[0]->low_rate_mode = 1;
move16();
@@ -951,8 +952,8 @@ void ivas_set_surplus_brate_dec(
ism_total_brate_ref = L_add( ism_total_brate_ref, st_ivas->hSCE[n]->element_brate );
}
- bits_ism = BASOP_Util_Divide3216_Scale( ism_total_brate_ref, FRAMES_PER_SEC, &tmp );
- bits_ism = shr( bits_ism, negate( add( tmp, 1 ) ) ); // bring down to Q0.
+ /* bits_ism = (int16_t) ( ism_total_brate_ref / FRAMES_PER_SEC ); */
+ bits_ism = extract_l( Mpy_32_32( ism_total_brate_ref, ONE_BY_FRAMES_PER_SEC_Q31 ) );
tmp = 0;
move16();
@@ -961,7 +962,7 @@ void ivas_set_surplus_brate_dec(
tmp = idiv1616( bits_ism, st_ivas->nchan_ism );
}
set16_fx( bits_element, tmp, st_ivas->nchan_ism );
- bits_element[st_ivas->nchan_ism - 1] = add( bits_element[st_ivas->nchan_ism - 1], bits_ism % st_ivas->nchan_ism );
+ bits_element[sub( st_ivas->nchan_ism, 1 )] = add( bits_element[sub( st_ivas->nchan_ism, 1 )], bits_ism % st_ivas->nchan_ism );
move16();
bitbudget_to_brate( bits_element, element_brate, st_ivas->nchan_ism );
@@ -980,16 +981,20 @@ void ivas_set_surplus_brate_dec(
IF( GT_16( ism_imp[n], 1 ) && EQ_16( st_ivas->flag_omasa_brate, 1 ) && brate_limit_flag >= 0 )
{
*ism_total_brate = L_sub( *ism_total_brate, ADJUST_ISM_BRATE_NEG );
+ move32();
}
+ test();
test();
test();
IF( EQ_16( brate_limit_flag, -1 ) && GE_16( ism_imp[n], 1 ) && GE_16( st_ivas->nchan_ism, 3 ) && GT_32( L_sub( ism_total_brate_ref, *ism_total_brate ), IVAS_48k ) )
{
*ism_total_brate = L_add( *ism_total_brate, ADJUST_ISM_BRATE_POS );
+ move32();
}
}
st_ivas->hCPE[0]->brate_surplus = L_sub( ism_total_brate_ref, *ism_total_brate );
+ move32();
/* 'st->total_brate' is set in ivas_ism_config */
}
@@ -1124,8 +1129,9 @@ ivas_error ivas_omasa_ism_metadata_dec_fx(
IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
{
/* decode ISM metadata */
- IF( ( error = ivas_ism_metadata_dec_fx( ism_total_brate, *nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi,
- nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ism_total_brate, *nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi,
+ nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ),
+ IVAS_ERR_OK ) )
{
return error;
}
@@ -1138,8 +1144,16 @@ ivas_error ivas_omasa_ism_metadata_dec_fx(
{
// azimuth_ism = (int16_t) ( st_ivas->hIsmMetaData[n]->azimuth + 0.5f );
// elevation_ism = (int16_t) ( st_ivas->hIsmMetaData[n]->elevation + 0.5f );
- azimuth_ism = extract_l( L_shr( L_add( st_ivas->hIsmMetaData[n]->azimuth_fx, ONE_IN_Q21 ), 21 ) / 2 ); // using "/ 2" here because it rounds towards 0, whereas L_shr rounds towards -inf
- elevation_ism = extract_l( L_shr( L_add( st_ivas->hIsmMetaData[n]->elevation_fx, ONE_IN_Q21 ), 21 ) / 2 );
+ azimuth_ism = extract_l( L_shr_r( L_abs( st_ivas->hIsmMetaData[n]->azimuth_fx ), 22 ) );
+ if ( st_ivas->hIsmMetaData[n]->azimuth_fx < 0 )
+ {
+ azimuth_ism = negate( azimuth_ism );
+ }
+ elevation_ism = extract_l( L_shr_r( L_abs( st_ivas->hIsmMetaData[n]->elevation_fx ), 22 ) );
+ if ( st_ivas->hIsmMetaData[n]->elevation_fx < 0 )
+ {
+ elevation_ism = negate( elevation_ism );
+ }
FOR( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ )
{
@@ -1154,8 +1168,16 @@ ivas_error ivas_omasa_ism_metadata_dec_fx(
}
ELSE /* ISM_MASA_MODE_MASA_ONE_OBJ */
{
- azimuth_ism = extract_l( L_shr( L_add( st_ivas->hIsmMetaData[0]->azimuth_fx, ONE_IN_Q21 ), 21 ) / 2 ); // using "/ 2" here because it rounds towards 0, whereas L_shr rounds towards -inf
- elevation_ism = extract_l( L_shr( L_add( st_ivas->hIsmMetaData[0]->elevation_fx, ONE_IN_Q21 ), 21 ) / 2 );
+ azimuth_ism = extract_l( L_shr_r( L_abs( st_ivas->hIsmMetaData[0]->azimuth_fx ), 22 ) );
+ if ( st_ivas->hIsmMetaData[0]->azimuth_fx < 0 )
+ {
+ azimuth_ism = negate( azimuth_ism );
+ }
+ elevation_ism = extract_l( L_shr_r( L_abs( st_ivas->hIsmMetaData[0]->elevation_fx ), 22 ) );
+ if ( st_ivas->hIsmMetaData[0]->elevation_fx < 0 )
+ {
+ elevation_ism = negate( elevation_ism );
+ }
FOR( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ )
{
@@ -1237,6 +1259,7 @@ void ivas_omasa_dirac_rend_jbm_fx(
Word16 n;
Word32 data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k];
+ 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 ) )
{
Copy32( output_f[CPE_CHANNELS], data_separated_objects[0], nSamplesAsked );
@@ -1371,7 +1394,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx(
}
/* Delay the object signals to match the CLDFB delay. Delay the whole buffer with the first rendering call of the stretched buffer. */
- IF( EQ_16( st_ivas->hSpatParamRendCom->slots_rendered, 0 ) )
+ IF( st_ivas->hSpatParamRendCom->slots_rendered == 0 )
{
Word16 tcBufferSize;
@@ -1391,7 +1414,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx(
/* reset combined orientation access index before calling the td renderer */
ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData );
- IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_sepobj_fx, q_factor, *nSamplesRendered ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_sepobj_fx, q_factor, *nSamplesRendered ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1411,6 +1434,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx(
* in case of external rendering, rearrange the channels order
*--------------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
void ivas_omasa_rearrange_channels(
float *output[], /* o : output synthesis signal */
const int16_t nchan_transport_ism, /* o : number of ISM TCs */
@@ -1432,8 +1456,7 @@ void ivas_omasa_rearrange_channels(
return;
}
-
-#ifdef IVAS_FLOAT_FIXED
+#else
void ivas_omasa_rearrange_channels_fx(
Word32 *output[], /* o : output synthesis signal */
const Word16 nchan_transport_ism, /* o : number of ISM TCs */
@@ -1451,7 +1474,7 @@ void ivas_omasa_rearrange_channels_fx(
Copy32( output[CPE_CHANNELS + n], output[n], output_frame );
}
Copy32( tmp_buff[0], output[n], output_frame );
- Copy32( tmp_buff[1], output[n + 1], output_frame );
+ Copy32( tmp_buff[1], output[add( n, 1 )], output_frame );
return;
}
diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c
index fff163ccda3552179391dded0ee7012d560fb0f3..4b9951065695502679ba43dc60d7b6628c75e4ac 100644
--- a/lib_dec/ivas_osba_dec.c
+++ b/lib_dec/ivas_osba_dec.c
@@ -40,10 +40,7 @@
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
-#include "math.h" // temporary (for fabs)
-#define IVAS_FLOAT_FIXED_TO_BE_REMOVED
+#include "prot_fx.h"
#endif // IVAS_FLOAT_FIXED
@@ -93,24 +90,26 @@ ivas_error ivas_osba_data_open_fx(
)
{
SBA_ISM_DATA_HANDLE hSbaIsmData;
- int16_t i;
+ Word16 i;
- if ( ( hSbaIsmData = (SBA_ISM_DATA_HANDLE) malloc( sizeof( SBA_ISM_DATA ) ) ) == NULL )
+ IF( ( hSbaIsmData = (SBA_ISM_DATA_HANDLE) malloc( sizeof( SBA_ISM_DATA ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OSBA data\n" ) );
}
hSbaIsmData->delayBuffer_nchan = st_ivas->nchan_ism;
- hSbaIsmData->delayBuffer_size = (int16_t) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES );
+ move16();
+ hSbaIsmData->delayBuffer_size = shr( div_l( st_ivas->hDecoderConfig->output_Fs, 50 / 2 ), 2 /* / MAX_PARAM_SPATIAL_SUBFRAMES*/ );
+ move16();
- if ( ( hSbaIsmData->delayBuffer_fx = (Word32 **) malloc( hSbaIsmData->delayBuffer_nchan * sizeof( Word32 * ) ) ) == NULL )
+ IF( ( hSbaIsmData->delayBuffer_fx = (Word32 **) malloc( hSbaIsmData->delayBuffer_nchan * sizeof( Word32 * ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for OSBA delay buffer \n" ) );
}
- for ( i = 0; i < hSbaIsmData->delayBuffer_nchan; i++ )
+ FOR( i = 0; i < hSbaIsmData->delayBuffer_nchan; i++ )
{
- if ( ( hSbaIsmData->delayBuffer_fx[i] = (Word32 *) malloc( hSbaIsmData->delayBuffer_size * sizeof( Word32 ) ) ) == NULL )
+ IF( ( hSbaIsmData->delayBuffer_fx[i] = (Word32 *) malloc( hSbaIsmData->delayBuffer_size * sizeof( Word32 ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for OSBA delay buffer \n" ) );
}
@@ -162,16 +161,17 @@ void ivas_osba_data_close_fx(
SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */
)
{
- int16_t i;
+ Word16 i;
- if ( hSbaIsmData == NULL || *hSbaIsmData == NULL )
+ test();
+ IF( hSbaIsmData == NULL || *hSbaIsmData == NULL )
{
return;
}
- if ( ( *hSbaIsmData )->delayBuffer_fx != NULL )
+ IF( ( *hSbaIsmData )->delayBuffer_fx != NULL )
{
- for ( i = 0; i < ( *hSbaIsmData )->delayBuffer_nchan; i++ )
+ FOR( i = 0; i < ( *hSbaIsmData )->delayBuffer_nchan; i++ )
{
free( ( *hSbaIsmData )->delayBuffer_fx[i] );
}
@@ -208,7 +208,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx(
ivas_error error;
Word32 output_separated_objects_fx[BINAURAL_CHANNELS][L_FRAME48k]; // VE2SB: TBV
Word32 *p_sepobj_fx[BINAURAL_CHANNELS];
- int16_t channel_offset;
+ Word16 channel_offset;
FOR( n = 0; n < BINAURAL_CHANNELS; n++ )
{
@@ -218,12 +218,12 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx(
channel_offset = st_ivas->nchan_ism;
move16();
- IF( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_fx[channel_offset], out_len ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_fx[channel_offset], out_len ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_sepobj_fx, q_factor, *nSamplesRendered ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_sepobj_fx, q_factor, *nSamplesRendered ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -233,7 +233,8 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx(
Word16 i;
FOR( i = 0; i < nSamplesAsked; i++ )
{
- output_fx[n][i] = L_add( L_shr( output_fx[channel_offset + n][i], 1 ), L_shr( p_sepobj_fx[n][i], 1 ) );
+ output_fx[n][i] = L_add( L_shr( output_fx[add( channel_offset, n )][i], 1 ), L_shr( p_sepobj_fx[n][i], 1 ) );
+ move32();
}
}
return IVAS_ERR_OK;
@@ -302,11 +303,14 @@ ivas_error ivas_osba_ism_metadata_dec_fx(
/* set ISM parameters */
nchan_transport_ism = st_ivas->nchan_ism;
+ move16();
*nchan_ism = st_ivas->nchan_ism;
+ move16();
/* decode ISM metadata */
- IF( ( error = ivas_ism_metadata_dec_fx( ism_total_brate, *nchan_ism, &nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi,
- nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ism_total_brate, *nchan_ism, &nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi,
+ nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0] ) ),
+ IVAS_ERR_OK ) )
{
return error;
}
@@ -367,22 +371,22 @@ ivas_error ivas_osba_render_sf_fx(
FOR( n = 0; n < st_ivas->nchan_ism; n++ )
{
- v_shr( p_output[n], sub( Q11, Q11 ), output_ism[n], nSamplesAsked );
+ v_shr( p_output[n], Q11 - Q11, output_ism[n], nSamplesAsked );
}
- IF( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output, 960 ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output, 960 ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM )
+ IF( NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
{
ivas_ism_render_sf_fx( st_ivas, p_output_ism, *nSamplesRendered );
}
FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ )
{
- IF( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM )
+ IF( NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
{
v_add_fixed( p_output[n], p_output_ism[n], p_output[n], *nSamplesRendered, 1 ); // takes care of downscaling by 0.5f
}
diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c
index 60f3f81580c673743f0dc80c52e491de03e3a666..2764b640b3a9af0f5a8132585ac15530026567cc 100644
--- a/lib_dec/ivas_out_setup_conversion.c
+++ b/lib_dec/ivas_out_setup_conversion.c
@@ -41,8 +41,7 @@
#include "ivas_rom_rend.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
@@ -1691,11 +1690,13 @@ void ivas_ls_setup_conversion_process_mdct(
}
#endif
+
/*-------------------------------------------------------------------------
* ivas_ls_setup_conversion_process_mdct_param_mc()
*
* Equalization in MDCT Domain
*-------------------------------------------------------------------------*/
+
#ifdef IVAS_FLOAT_FIXED
void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
@@ -2076,7 +2077,6 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
return;
}
#else
-
void ivas_ls_setup_conversion_process_mdct_param_mc(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
float *x[][NB_DIV] /* i/o: output synthesis signal */
@@ -2238,49 +2238,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc(
}
}
-#ifdef IVAS_FLOAT_FIXED
- Word32 real_in_buffer_fx[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS];
- Word32 imag_in_buffer_fx[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS];
- Word32 real_buffer_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
- Word32 imag_buffer_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
- Word16 real_exp, imag_exp, input_exp, output_exp;
- Word16 shift = find_guarded_bits_fx( num_bands + 1 );
-
- f2me_buf( real_in_buffer, real_in_buffer_fx, &real_exp, num_bands * nchan_transport );
- f2me_buf( imag_in_buffer, imag_in_buffer_fx, &imag_exp, num_bands * nchan_transport );
-
- IF( real_exp > imag_exp )
- {
- FOR( i = 0; i < num_bands * nchan_transport; ++i )
- {
- imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], real_exp - imag_exp );
- }
- input_exp = real_exp;
- }
- ELSE
- {
- FOR( i = 0; i < num_bands * nchan_transport; ++i )
- {
- real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], imag_exp - real_exp );
- }
- input_exp = imag_exp;
- }
-
- FOR( i = 0; i < num_bands * nchan_transport; ++i )
- {
- real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], shift );
- imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], shift );
- }
-
- input_exp += shift;
-
- cmplx_matrix_square_fx( real_in_buffer_fx, imag_in_buffer_fx, num_bands, nchan_transport, real_buffer_fx, imag_buffer_fx, input_exp, &output_exp );
-
- me2f_buf( real_buffer_fx, output_exp, real_buffer, nchan_transport * nchan_transport );
- me2f_buf( imag_buffer_fx, output_exp, imag_buffer, nchan_transport * nchan_transport );
-#else
cmplx_matrix_square( real_in_buffer, imag_in_buffer, num_bands, nchan_transport, real_buffer, imag_buffer );
-#endif
v_add( cx[bandIdx], real_buffer, cx[bandIdx], nchan_transport * nchan_transport );
@@ -2446,6 +2404,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc(
}
#endif
+
/*-------------------------------------------------------------------------
* ivas_ls_setup_conversion_process_param_mc()
*
diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c
index 2e34c3508269ee4a092d84009088da6e837f5b8f..9b9d1b4023e1e232f94df4e667b7fe9d23324a38 100644
--- a/lib_dec/ivas_output_config.c
+++ b/lib_dec/ivas_output_config.c
@@ -176,18 +176,22 @@ void ivas_renderer_select(
IF( EQ_16( nchan_internal, 2 ) )
{
st_ivas->hCombinedOrientationData->shd_rot_max_order = 1;
+ move16();
}
ELSE IF( EQ_16( nchan_internal, 4 ) || EQ_16( nchan_internal, 3 ) )
{
st_ivas->hCombinedOrientationData->shd_rot_max_order = 0;
+ move16();
}
ELSE IF( EQ_16( nchan_internal, 6 ) || EQ_16( nchan_internal, 5 ) )
{
st_ivas->hCombinedOrientationData->shd_rot_max_order = 2;
+ move16();
}
ELSE IF( EQ_16( nchan_internal, 8 ) || EQ_16( nchan_internal, 7 ) )
{
st_ivas->hCombinedOrientationData->shd_rot_max_order = 3;
+ move16();
}
}
}
@@ -357,7 +361,17 @@ void ivas_renderer_select(
IVAS_FORMAT ivas_format;
*renderer_type = RENDERER_DIRAC;
move16();
- ivas_format = ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_NONE ) ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */
+
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_NONE ) )
+ {
+ ivas_format = SBA_FORMAT; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */
+ }
+ ELSE
+ {
+ ivas_format = st_ivas->ivas_format;
+ }
+ move16();
test();
test();
@@ -410,6 +424,7 @@ void ivas_renderer_select(
move16();
}
st_ivas->renderer_type = RENDERER_SBA_LINEAR_DEC;
+ move16();
}
ELSE IF( ( EQ_32( ivas_format, MASA_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) && EQ_16( st_ivas->nchan_transport, 1 ) ) ||
( EQ_32( ivas_format, SBA_FORMAT ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) ) ) )
@@ -487,6 +502,7 @@ void ivas_renderer_select(
ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
{
*internal_config = transport_config;
+ move16();
test();
IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) && NE_32( *internal_config, output_config ) )
{
@@ -506,6 +522,7 @@ void ivas_renderer_select(
ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
{
*internal_config = transport_config;
+ move16();
IF( NE_32( *internal_config, output_config ) )
{
test();
diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c
index 40052469b6fd0d01719718c35de10cfc0c8f8fb7..7dd2e334c09251ae4c900102458e07e262057dd4 100644
--- a/lib_dec/ivas_pca_dec_fx.c
+++ b/lib_dec/ivas_pca_dec_fx.c
@@ -38,7 +38,7 @@
#include
#include "ivas_cnst.h"
#include "wmc_auto.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "math.h"
/*-----------------------------------------------------------------------*
diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c
index 694bc53201e4d7faee0fa1d3ddf552b1f9e94375..c2decb8c5bbee17c0a16a746efa079ee5bc85af2 100644
--- a/lib_dec/ivas_post_proc.c
+++ b/lib_dec/ivas_post_proc.c
@@ -36,8 +36,7 @@
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "ivas_cnst.h"
diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c
index cb1460ea2e7fa06db32ad8f707ffc697ea656f6a..c80e1dbfb4f1d40c4d7866d55cf5b06784bf927d 100644
--- a/lib_dec/ivas_qmetadata_dec.c
+++ b/lib_dec/ivas_qmetadata_dec.c
@@ -41,9 +41,11 @@
#include "wmc_auto.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*-----------------------------------------------------------------------*
* Local function prototypes
diff --git a/lib_dec/ivas_qspherical_dec.c b/lib_dec/ivas_qspherical_dec.c
index 40fdbdc5e110950185f986581d140ea2319d10fc..f64051f188fc05cfb4a3310e23f2de133d88f33e 100644
--- a/lib_dec/ivas_qspherical_dec.c
+++ b/lib_dec/ivas_qspherical_dec.c
@@ -38,6 +38,9 @@
#include "ivas_stat_dec.h"
#include "wmc_auto.h"
#include "prot.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*-------------------------------------------------------------------*
diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c
index 5dda982b86d99a50798f59bda2126aceaba47a6b..42ff82c70d422fe27a060439c50b9cb70b597ad8 100644
--- a/lib_dec/ivas_sba_dec.c
+++ b/lib_dec/ivas_sba_dec.c
@@ -43,7 +43,7 @@
#include
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
* ivas_sba_set_cna_cng_flag()
*
@@ -328,11 +328,7 @@ ivas_error ivas_sba_dec_reconfigure(
{
ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 );
-#ifdef IVAS_FLOAT_FIXED
- if ( ( error = ivas_spar_dec_open_fx( st_ivas, 1 ) ) != IVAS_ERR_OK )
-#else
if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK )
-#endif
{
return error;
}
@@ -357,20 +353,13 @@ ivas_error ivas_sba_dec_reconfigure(
}
ivas_pca_dec_init( hSpar->hPCA );
-#ifdef IVAS_FLOAT_FIXED
- ivas_pca_dec_init_fx( hSpar->hPCA );
-#endif
}
ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format );
}
else
{
-#ifdef IVAS_FLOAT_FIXED
- if ( ( error = ivas_spar_dec_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
-#else
if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK )
-#endif
{
return error;
}
@@ -448,11 +437,7 @@ ivas_error ivas_sba_dec_reconfigure(
flag_config = DIRAC_RECONFIGURE_MODE;
}
-#ifdef IVAS_FLOAT_FIXED
- if ( ( error = ivas_dirac_dec_config_fx( st_ivas, flag_config ) ) != IVAS_ERR_OK )
-#else
if ( ( error = ivas_dirac_dec_config( st_ivas, flag_config ) ) != IVAS_ERR_OK )
-#endif
{
return error;
}
@@ -481,17 +466,10 @@ ivas_error ivas_sba_dec_reconfigure(
if ( st_ivas->renderer_type == RENDERER_DISABLE )
{
-#ifdef IVAS_FLOAT_FIXED
- ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) );
- ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) );
- ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) );
- vbap_free_data_fx( &( st_ivas->hVBAPdata ) );
-#else
ivas_dirac_rend_close( &( st_ivas->hDirACRend ) );
ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) );
ivas_dirac_dec_close( &( st_ivas->hDirAC ) );
vbap_free_data( &( st_ivas->hVBAPdata ) );
-#endif
}
if ( st_ivas->hDirAC != NULL )
@@ -510,11 +488,7 @@ ivas_error ivas_sba_dec_reconfigure(
int32_t temp_brate[MAX_SCE];
st_ivas->ism_mode = ISM_SBA_MODE_DISC;
-#ifdef IVAS_FLOAT_FIXED
- IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK )
-#else
if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK )
-#endif
{
return error;
}
@@ -529,17 +503,10 @@ ivas_error ivas_sba_dec_reconfigure(
st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ||
st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
{
-#ifdef IVAS_FLOAT_FIXED
- IF( ( error = ivas_ism_renderer_open_fx( st_ivas ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-#else
if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
-#endif
}
if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX )
@@ -605,32 +572,20 @@ ivas_error ivas_sba_dec_reconfigure(
}
}
-#ifdef IVAS_FLOAT_FIXED
- IF( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-#else
if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
{
return error;
}
-#endif
/*-----------------------------------------------------------------*
* HP20 memories
*-----------------------------------------------------------------*/
-#ifdef IVAS_FLOAT_FIXED
- if ( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-#else
+
if ( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK )
{
return error;
}
-#endif
+
/*-----------------------------------------------------------------*
* TD Decorrelator
*-----------------------------------------------------------------*/
@@ -740,12 +695,6 @@ ivas_error ivas_sba_dec_reconfigure(
{
return error;
}
-#ifdef IVAS_FLOAT_FIXED
- if ( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-#endif // IVAS_FLOAT_FIXED
return error;
}
@@ -977,7 +926,7 @@ ivas_error ivas_sba_dec_reconfigure_fx(
test();
IF( NE_16( nchan_transport_old, ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) ) || ( GE_32( last_ivas_total_brate, IVAS_512k ) && LT_32( ivas_total_brate, IVAS_512k ) ) || ( LT_32( last_ivas_total_brate, IVAS_512k ) && GE_32( ivas_total_brate, IVAS_512k ) ) )
{
- ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 );
+ ivas_spar_dec_close_fx( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 );
if ( NE_32( ( error = ivas_spar_dec_open_fx( st_ivas, 1 ) ), IVAS_ERR_OK ) )
{
@@ -1010,7 +959,11 @@ ivas_error ivas_sba_dec_reconfigure_fx(
ivas_pca_dec_init_fx( hSpar->hPCA );
}
+#ifdef IVAS_FLOAT_FIXED
+ ivas_spar_config_fx( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format );
+#else
ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format );
+#endif
}
ELSE
{
@@ -1084,8 +1037,8 @@ ivas_error ivas_sba_dec_reconfigure_fx(
ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer );
}
- if ( NE_32( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ),
- st_ivas->ivas_format ) ),
+ if ( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ),
+ st_ivas->ivas_format ) ),
IVAS_ERR_OK ) )
{
return error;
@@ -1122,8 +1075,8 @@ ivas_error ivas_sba_dec_reconfigure_fx(
move16();
}
- ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( L_add( st_ivas->hDecoderConfig->output_Fs, 400 ) / CLDFB_BANDWIDTH ),
- st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
+ ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( L_add( st_ivas->hDecoderConfig->output_Fs, 400 ) / CLDFB_BANDWIDTH ),
+ st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
if ( st_ivas->hDirAC )
{
@@ -1743,10 +1696,10 @@ void ivas_sba_dec_digest_tc_fx(
Word32 *decorr_signal[BINAURAL_CHANNELS];
Word32 *p_tc[2 * BINAURAL_CHANNELS];
Word16 q_format = 14;
- Word16 exp = 0;
move16();
- default_frame = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC, &exp );
- default_frame = shr( default_frame, sub( Q15, exp ) );
+
+ /* default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); */
+ default_frame = extract_l( Mpy_32_32( st_ivas->hDecoderConfig->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
nSamplesLeftForTD = nSamplesForRendering;
move16();
diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c
index 2ad1c081be820629d4cf4f70e67a010578aaf974..16e93aeb6856b6e6a466d8d268302b9eb8f7cb7d 100644
--- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c
+++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c
@@ -34,8 +34,7 @@
#include "options.h"
#include "cnst.h"
#include "ivas_cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "ivas_rom_com.h"
diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c
index 03b5eb85c4615f727f07f89c3adfb9537f275d2a..b30b8533c1b86b6b2e14bd89a0aeaa404481b2fe 100644
--- a/lib_dec/ivas_sba_rendering_internal.c
+++ b/lib_dec/ivas_sba_rendering_internal.c
@@ -41,7 +41,7 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif // IVAS_FLOAT_FIXED
#ifdef DUMPS_ENABLED
#include "debug.h"
@@ -200,6 +200,7 @@ void ivas_sba2mc_cldfb_fixed(
*
* MC signals transformed into SBA in TD domain
*-------------------------------------------------------------------------*/
+
#ifdef IVAS_FLOAT_FIXED
void ivas_mc2sba_fx(
IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */
@@ -233,6 +234,7 @@ void ivas_mc2sba_fx(
move16();
FOR( i = 0; i < add( hIntSetup.nchan_out_woLFE, hIntSetup.num_lfe ); i++ )
{
+ test();
IF( ( hIntSetup.num_lfe > 0 ) && EQ_16( i, hIntSetup.index_lfe[idx_lfe] ) )
{
IF( gain_lfe_fx > 0 )
@@ -245,16 +247,16 @@ void ivas_mc2sba_fx(
}
}
- IF( LT_16( idx_lfe, sub( hIntSetup.num_lfe, 1 ) ) )
+ if ( LT_16( idx_lfe, sub( hIntSetup.num_lfe, 1 ) ) )
{
idx_lfe = add( idx_lfe, 1 );
}
}
ELSE
{
- azimuth = (Word16) L_shr( hIntSetup.ls_azimuth_fx[idx_in], 22 );
+ azimuth = extract_l( L_shr( hIntSetup.ls_azimuth_fx[idx_in], Q22 ) );
move16();
- elevation = (Word16) L_shr( hIntSetup.ls_elevation_fx[idx_in], 22 );
+ elevation = extract_l( L_shr( hIntSetup.ls_elevation_fx[idx_in], Q22 ) );
move16();
idx_in = add( idx_in, 1 );
ivas_dirac_dec_get_response_fx(
@@ -284,7 +286,6 @@ void ivas_mc2sba_fx(
return;
}
#else
-
void ivas_mc2sba(
IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */
float *in_buffer_td[], /* i : MC signals (on input) and the HOA3 (on output) */
@@ -362,6 +363,7 @@ void ivas_mc2sba(
}
#endif
+
/*-------------------------------------------------------------------------*
* ivas_param_mc_mc2sba_cldfb()
*
@@ -402,6 +404,7 @@ void ivas_param_mc_mc2sba_cldfb_fx(
FOR( idx_ch = 0; idx_ch < add( hTransSetup.nchan_out_woLFE, hTransSetup.num_lfe ); idx_ch++ )
{
+ test();
IF( ( hTransSetup.num_lfe > 0 ) && EQ_16( idx_ch, hTransSetup.index_lfe[idx_lfe] ) )
{
IF( gain_lfe_fx > 0 )
@@ -413,7 +416,7 @@ void ivas_param_mc_mc2sba_cldfb_fx(
move32();
}
- IF( LT_16( idx_lfe, sub( hTransSetup.num_lfe, 1 ) ) )
+ if ( LT_16( idx_lfe, sub( hTransSetup.num_lfe, 1 ) ) )
{
idx_lfe = add( idx_lfe, 1 );
}
@@ -652,6 +655,17 @@ void ivas_ism2sba_sf_fx(
move32();
prev_gain_fx = hIsmRendererData->prev_gains_fx[i][j];
move32();
+#ifdef IVAS_ENH32_CADENCE_CHANGES
+ FOR( k = 0; k < n_samples_to_render; k++ )
+ {
+ g1_fx = sub( 32767, *g2_fx );
+ *( out_fx ) = Madd_32_32( *( out_fx ), Madd_32_16( Mult_32_16( gain_fx, ( *( g2_fx ) ) ), prev_gain_fx, g1_fx ), ( *( tc_fx ) ) ); /*Q_buffer_in + 29 - 31*/
+ move32();
+ g2_fx++;
+ tc_fx++;
+ out_fx++;
+ }
+#else
FOR( k = 0; k < n_samples_to_render; k++ )
{
g1_fx = sub( 32767, *g2_fx );
@@ -661,6 +675,7 @@ void ivas_ism2sba_sf_fx(
tc_fx++;
out_fx++;
}
+#endif
}
}
FOR( j = 0; j < sba_num_chans; j++ )
@@ -858,7 +873,7 @@ void ivas_sba_mix_matrix_determiner_fx(
const Word16 nchan_remapped, /* i : num channels after remapping of TCs */
const Word16 output_frame, /* i : output frame length */
const Word16 num_md_sub_frames, /* i : number of subframes in mixing matrix*/
- const Word16 Q_output /* i : number of subframes in mixing matrix*/
+ const Word16 Q_output /* i : Q of transport/output audio channels */
)
{
Word16 i, ch;
@@ -896,6 +911,7 @@ void ivas_sba_mix_matrix_determiner_fx(
nchan_out = nchan_transport;
move16();
ivas_agc_dec_process_fx( hSpar->hAgcDec, ( output_fx ), ( output_fx ), nchan_transport, output_frame );
+ Q_p_output = sub( Q_p_output, 3 );
#ifdef DUMPS_ENABLED
dbgwrite_txt( &output[0][0], output_frame, "fix_ivas_agc_dec_process_output.txt", NULL );
#endif // DUMPS_ENABLED
@@ -905,7 +921,7 @@ void ivas_sba_mix_matrix_determiner_fx(
{
FOR( i = 0; i < output_frame; i++ )
{
- output_fx[ch][i] = Mult_32_32( L_shl_sat( output_fx[ch][i], sub( 18, Q_p_output ) ), L_shl_sat( PCM16_TO_FLT_FAC_FX, 16 ) ); /*Q-0*/
+ output_fx[ch][i] = Mult_32_32( L_shl_sat( output_fx[ch][i], sub( 15, Q_p_output ) ), L_shl_sat( PCM16_TO_FLT_FAC_FX, 16 ) ); /* Q0 */
}
}
diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c
index 7c30d30328c77caebe7c29333fbffaa7935ccb1d..8c2ee04ba43e3e3ce1b7f2faace2505513451799 100644
--- a/lib_dec/ivas_sce_dec.c
+++ b/lib_dec/ivas_sce_dec.c
@@ -37,8 +37,7 @@
#include "ivas_cnst.h"
#include "rom_com.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c
index 78ce1a71ab3f75504ae36c46a077ba6c724a0d5b..8e1b5d1403e04fddcf4ca94196ae8688709f2d04 100644
--- a/lib_dec/ivas_sce_dec_fx.c
+++ b/lib_dec/ivas_sce_dec_fx.c
@@ -38,8 +38,7 @@
#include "ivas_cnst.h"
#include "rom_com.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "ivas_rom_com.h"
@@ -298,7 +297,7 @@ ivas_error ivas_sce_dec_fx(
set32_fx( output[0], 0, L_FRAME48k );
- IF( NE_32( ( error = ivas_core_dec( st_ivas, hSCE, NULL, NULL, 1, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_core_dec_fx( st_ivas, hSCE, NULL, NULL, 1, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ), IVAS_ERR_OK ) )
{
return error;
}
diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c
index 8d5e1f007c38105182f43ccffccef6b68ee6a970..ff96b6c0611fd85938f3069d9f47b21a1d8f9c2c 100644
--- a/lib_dec/ivas_sns_dec_fx.c
+++ b/lib_dec/ivas_sns_dec_fx.c
@@ -40,8 +40,10 @@
#include
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
/*-------------------------------------------------------------------
* sns_1st_dec_fx()
diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c
index f18e474e4faa9b20c7e2c05e0bea0f9ea04f49b3..37bcdbea0bec2ccb8bead0ebdd117e0733164065 100644
--- a/lib_dec/ivas_spar_decoder.c
+++ b/lib_dec/ivas_spar_decoder.c
@@ -34,7 +34,6 @@
#include "options.h"
#include "ivas_stat_dec.h"
#include "prot.h"
-#include "prot_fx2.h"
#include "string.h"
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
@@ -46,8 +45,7 @@
#include
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif // IVAS_FLOAT_FIXED
#ifdef DUMPS_ENABLED
@@ -66,13 +64,13 @@ static ivas_error ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0
#endif
-#ifndef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------------
* ivas_spar_dec_open()
*
* Allocate and initialize SPAR decoder handle and sub-handles
*------------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
ivas_error ivas_spar_dec_open(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */
@@ -280,222 +278,250 @@ ivas_error ivas_spar_dec_open(
#else
ivas_error ivas_spar_dec_open_fx(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
+ const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */
)
{
SPAR_DEC_HANDLE hSpar;
ivas_error error;
- int16_t sba_order_internal, num_channels_internal;
+ Word16 sba_order_internal, num_channels_internal;
IVAS_FB_CFG *fb_cfg;
- int16_t i, j, b, active_w_mixing;
- int32_t output_Fs;
- int16_t num_decor_chs, map_idx;
+ Word16 i, j, b, active_w_mixing;
+ Word32 output_Fs;
+ Word16 num_decor_chs, map_idx;
error = IVAS_ERR_OK;
+ move32();
sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER );
+ move16();
num_channels_internal = ivas_sba_get_nchan_metadata_fx( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate );
hSpar = st_ivas->hSpar;
- if ( !spar_reconfig_flag )
+ IF( !spar_reconfig_flag )
{
/* SPAR decoder handle */
- if ( ( hSpar = (SPAR_DEC_HANDLE) malloc( sizeof( SPAR_DEC_DATA ) ) ) == NULL )
+ IF( ( hSpar = (SPAR_DEC_HANDLE) malloc( sizeof( SPAR_DEC_DATA ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder" );
}
}
output_Fs = st_ivas->hDecoderConfig->output_Fs;
- if ( num_channels_internal > ( SBA_HOA2_ORDER + 1 ) * ( SBA_HOA2_ORDER + 1 ) )
+ move32();
+ IF( GT_16( num_channels_internal, ( SBA_HOA2_ORDER + 1 ) * ( SBA_HOA2_ORDER + 1 ) ) )
{
num_decor_chs = IVAS_HBR_MAX_DECOR_CHS;
+ move16();
}
- else
+ ELSE
{
- num_decor_chs = num_channels_internal - 1;
+ num_decor_chs = sub( num_channels_internal, 1 );
}
/* TD decorr. */
- if ( ( st_ivas->ivas_format == SBA_FORMAT ) && ( ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) || ( st_ivas->hDecoderConfig->ivas_total_brate >= IVAS_256k && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA ) ) )
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) && ( ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) || ( GE_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_256k ) && EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) ) ) )
{
hSpar->hTdDecorr = NULL;
}
- else
+ ELSE
{
-#ifdef IVAS_FLOAT_FIXED
- if ( ( error = ivas_td_decorr_dec_open_fx( &hSpar->hTdDecorr, output_Fs, num_decor_chs + 1, 1 ) ) != IVAS_ERR_OK )
-#else
- if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, num_decor_chs + 1, 1 ) ) != IVAS_ERR_OK )
-#endif
+ IF( NE_32( ( error = ivas_td_decorr_dec_open_fx( &hSpar->hTdDecorr, output_Fs, add( num_decor_chs, 1 ), 1 ) ), IVAS_ERR_OK ) )
{
return error;
}
}
/* MD handle */
- if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format, st_ivas->last_active_ivas_total_brate ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format, st_ivas->last_active_ivas_total_brate ) ), IVAS_ERR_OK ) )
{
return error;
}
hSpar->hMdDec->td_decorr_flag = 1;
+ move16();
if ( hSpar->hTdDecorr )
{
hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[hSpar->hMdDec->table_idx].td_ducking;
+ move16();
}
/* set FB config. */
active_w_mixing = -1;
- if ( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, num_channels_internal, num_channels_internal, active_w_mixing, output_Fs, 0 ) ) != IVAS_ERR_OK )
+ move16();
+ IF( NE_32( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, num_channels_internal, num_channels_internal, active_w_mixing, output_Fs, 0 ) ), IVAS_ERR_OK ) )
{
return error;
}
fb_cfg->pcm_offset = NS2SA( output_Fs, DELAY_FB_1_NS + IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS );
+ move16();
fb_cfg->remix_order = remix_order_set[hSpar->hMdDec->spar_md_cfg.remix_unmix_order];
+ move16();
/* FB mixer handle */
-#ifdef IVAS_FLOAT_FIXED
- IF( ( error = ivas_FB_mixer_open_fx( &hSpar->hFbMixer, output_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-#else
- if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, output_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_FB_mixer_open_fx( &hSpar->hFbMixer, output_Fs, fb_cfg, spar_reconfig_flag ) ), IVAS_ERR_OK ) )
{
return error;
}
-#endif
/* AGC handle */
-#ifdef IVAS_FLOAT_FIXED
- if ( ( error = ivas_spar_agc_dec_open_fx( &hSpar->hAgcDec, output_Fs ) ) != IVAS_ERR_OK )
-#else
- if ( ( error = ivas_spar_agc_dec_open( &hSpar->hAgcDec, output_Fs ) ) != IVAS_ERR_OK )
-#endif // IVAS_FLOAT_FIXED
+ IF( NE_32( ( error = ivas_spar_agc_dec_open_fx( &hSpar->hAgcDec, output_Fs ) ), IVAS_ERR_OK ) )
{
return error;
}
/* PCA handle */
hSpar->hPCA = NULL;
- if ( st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order_internal == 1 )
+ test();
+ IF( EQ_32( st_ivas->hDecoderConfig->ivas_total_brate, PCA_BRATE ) && EQ_16( sba_order_internal, 1 ) )
{
- if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL )
+ IF( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" );
}
- // ivas_pca_dec_init( hSpar->hPCA );
-#ifdef IVAS_FLOAT_FIXED
ivas_pca_dec_init_fx( hSpar->hPCA );
-#endif
}
/* mixer_mat intitialization */
- for ( i = 0; i < num_channels_internal; i++ )
+ FOR( i = 0; i < num_channels_internal; i++ )
{
- for ( j = 0; j < num_channels_internal; j++ )
+ FOR( j = 0; j < num_channels_internal; j++ )
{
- for ( b = 0; b < IVAS_MAX_NUM_BANDS; b++ )
+ FOR( b = 0; b < IVAS_MAX_NUM_BANDS; b++ )
{
hSpar->hMdDec->mixer_mat_fx[i][j][b] = 0;
- for ( int16_t i_ts = 0; i_ts < ( MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); i_ts++ )
+ move32();
+ FOR( Word16 i_ts = 0; i_ts < ( MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); i_ts++ )
{
hSpar->hMdDec->mixer_mat_prev_fx[i_ts][i][j][b] = 0;
+ move32();
}
}
}
}
hSpar->i_subframe = 0;
+ move16();
hSpar->AGC_flag = 0;
+ move16();
/*-----------------------------------------------------------------*
* Configuration - set SPAR high-level parameters
*-----------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+ ivas_spar_config_fx( st_ivas->hDecoderConfig->ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format );
+#else
ivas_spar_config( st_ivas->hDecoderConfig->ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format );
+#endif
- switch ( sba_order_internal )
+ SWITCH( sba_order_internal )
{
case 1:
st_ivas->transport_config = IVAS_AUDIO_CONFIG_FOA;
- break;
+ move32();
+ BREAK;
case 2:
st_ivas->transport_config = IVAS_AUDIO_CONFIG_HOA2;
- break;
+ move32();
+ BREAK;
case 3:
st_ivas->transport_config = IVAS_AUDIO_CONFIG_HOA3;
- break;
+ move32();
+ BREAK;
}
ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config );
- set_s( hSpar->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
- set_s( hSpar->subframe_nbslots, JBM_CLDFB_SLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS );
+ set16_fx( hSpar->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
+ set16_fx( hSpar->subframe_nbslots, JBM_CLDFB_SLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS );
hSpar->nb_subframes = DEFAULT_JBM_SUBFRAMES_5MS;
+ move16();
hSpar->subframes_rendered = 0;
+ move16();
hSpar->slots_rendered = 0;
+ move16();
hSpar->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME;
+ move16();
/* init render timeslot mapping */
- set_s( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME );
- for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ )
+ set16_fx( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME );
+ FOR( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ )
{
hSpar->render_to_md_map[map_idx] = map_idx;
+ move16();
}
/* allocate transport channels*/
- if ( st_ivas->hTcBuffer == NULL )
+ IF( st_ivas->hTcBuffer == NULL )
{
- int16_t nchan_to_allocate;
- int16_t nchan_tc;
+ Word16 nchan_to_allocate;
+ Word16 nchan_tc;
TC_BUFFER_MODE buffer_mode;
- int16_t granularity;
+ Word16 granularity;
buffer_mode = TC_BUFFER_MODE_RENDERER;
+ move32();
nchan_tc = ivas_jbm_dec_get_num_tc_channels( st_ivas );
nchan_to_allocate = num_channels_internal;
+ move16();
- if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ test();
+ if ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
- nchan_to_allocate += st_ivas->nchan_ism;
+ nchan_to_allocate = add( nchan_to_allocate, st_ivas->nchan_ism );
}
granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
+ move16();
- if ( ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) )
+ test();
+ test();
+ test();
+ IF( ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) ) )
{
- if ( ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) )
+ test();
+ test();
+ IF( ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
{
- nchan_tc = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism;
+ nchan_tc = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism );
nchan_to_allocate = nchan_tc;
+ move16();
}
- else
+ ELSE
{
buffer_mode = TC_BUFFER_MODE_BUFFER;
+ move32();
nchan_tc = st_ivas->hDecoderConfig->nchan_out;
+ move16();
nchan_to_allocate = nchan_tc;
+ move16();
}
}
- else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
{
nchan_to_allocate = 2 * BINAURAL_CHANNELS;
+ move16();
}
- if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
/* get correct granularity in case of binaural rendering of the discrete objects with the td obj renderer */
- granularity = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) );
+ Word32 quo, rem;
+ iDiv_and_mod_32( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &quo, &rem, 0 );
+ granularity = extract_l( quo );
+ move16();
}
-#ifdef IVAS_FLOAT_FIXED
- if ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK )
-#else
- if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK )
-#endif
+ IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -507,12 +533,14 @@ ivas_error ivas_spar_dec_open_fx(
}
#endif
+
/*-------------------------------------------------------------------------
* ivas_spar_dec_close()
*
* Deallocate SPAR handle
*------------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
void ivas_spar_dec_close(
SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */
const int32_t output_Fs, /* i : output sampling rate */
@@ -531,18 +559,10 @@ void ivas_spar_dec_close(
ivas_td_decorr_dec_close( &( *hSpar )->hTdDecorr );
/* FB mixer handle */
-#ifdef IVAS_FLOAT_FIXED
- ivas_FB_mixer_close_fx( &( *hSpar )->hFbMixer, output_Fs, spar_reconfig_flag );
-#else
ivas_FB_mixer_close( &( *hSpar )->hFbMixer, output_Fs, spar_reconfig_flag );
-#endif
/* AGC */
-#ifdef IVAS_FLOAT_FIXED
- ivas_spar_agc_dec_close_fx( &( *hSpar )->hAgcDec );
-#else
ivas_spar_agc_dec_close( &( *hSpar )->hAgcDec );
-#endif // IVAS_FLOAT_FIXED
/* PCA */
if ( ( *hSpar )->hPCA != NULL )
@@ -559,6 +579,47 @@ void ivas_spar_dec_close(
return;
}
+#else
+void ivas_spar_dec_close_fx(
+ SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */
+ const Word32 output_Fs, /* i : output sampling rate */
+ const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */
+)
+{
+ test();
+ IF( hSpar == NULL || *hSpar == NULL )
+ {
+ return;
+ }
+
+ /* MD handle */
+ ivas_spar_md_dec_close( &( *hSpar )->hMdDec );
+
+ /* TD decorrelator handle */
+ ivas_td_decorr_dec_close( &( *hSpar )->hTdDecorr );
+
+ /* FB mixer handle */
+ ivas_FB_mixer_close_fx( &( *hSpar )->hFbMixer, output_Fs, spar_reconfig_flag );
+
+ /* AGC */
+ ivas_spar_agc_dec_close_fx( &( *hSpar )->hAgcDec );
+
+ /* PCA */
+ IF( ( *hSpar )->hPCA != NULL )
+ {
+ free( ( *hSpar )->hPCA );
+ ( *hSpar )->hPCA = NULL;
+ }
+
+ IF( !spar_reconfig_flag )
+ {
+ free( ( *hSpar ) );
+ ( *hSpar ) = NULL;
+ }
+
+ return;
+}
+#endif
/*-------------------------------------------------------------------*
@@ -579,20 +640,31 @@ ivas_error ivas_spar_dec_fx(
Word16 next_bit_pos_orig, last_bit_pos;
UWord16 bstr_meta[MAX_BITS_METADATA], *bit_stream_orig;
ivas_error error;
+ Word32 quo, rem;
push_wmops( "ivas_spar_decode" );
error = IVAS_ERR_OK;
+ move32();
hDecoderConfig = st_ivas->hDecoderConfig;
- st0 = GT_16( st_ivas->nSCE, 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0];
+ st0 = NULL;
+ IF( st_ivas->nSCE > 0 )
+ {
+ st0 = st_ivas->hSCE[0]->hCoreCoder[0];
+ }
+ ELSE
+ {
+ st0 = st_ivas->hCPE[0]->hCoreCoder[0];
+ }
+
bit_stream_orig = st0->bit_stream;
- move16();
next_bit_pos_orig = st0->next_bit_pos;
move16();
IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
- last_bit_pos = sub( extract_l( L_sub( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ), 1 ) ), nb_bits_read[1] );
+ iDiv_and_mod_32( hDecoderConfig->ivas_total_brate, FRAMES_PER_SEC, &quo, &rem, 0 );
+ last_bit_pos = sub( extract_l( L_sub( quo, 1 ) ), nb_bits_read[1] );
}
ELSE
{
@@ -610,15 +682,17 @@ ivas_error ivas_spar_dec_fx(
IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
- last_bit_pos = sub( extract_l( L_sub( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ), 1 ) ), nb_bits_read[1] );
+ iDiv_and_mod_32( hDecoderConfig->ivas_total_brate, FRAMES_PER_SEC, &quo, &rem, 0 );
+ last_bit_pos = sub( extract_l( L_sub( quo, 1 ) ), nb_bits_read[1] );
}
ELSE
{
- last_bit_pos = extract_l( L_sub( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ), 1 ) );
+ iDiv_and_mod_32( hDecoderConfig->ivas_total_brate, FRAMES_PER_SEC, &quo, &rem, 0 );
+ last_bit_pos = extract_l( L_sub( quo, 1 ) );
}
test();
- IF( !st0->bfi && EQ_32( hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) )
+ if ( !st0->bfi && EQ_32( hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) )
{
last_bit_pos = sub( last_bit_pos, SID_FORMAT_NBITS );
}
@@ -629,16 +703,16 @@ ivas_error ivas_spar_dec_fx(
/* reverse the bitstream for easier reading of indices */
FOR( i = 0; i < s_min( MAX_BITS_METADATA, last_bit_pos ); i++ )
{
- bstr_meta[i] = st_ivas->bit_stream[last_bit_pos - i];
+ bstr_meta[i] = st_ivas->bit_stream[sub( last_bit_pos, i )];
move16();
}
st0->bit_stream = bstr_meta;
- move16();
st0->next_bit_pos = 0;
move16();
st0->bits_frame = s_min( MAX_BITS_METADATA, add( last_bit_pos, 1 ) );
+ move16();
- IF( !st0->bfi )
+ if ( !st0->bfi )
{
st0->total_brate = hDecoderConfig->ivas_total_brate; /* to avoid BER detect */
move32();
@@ -648,22 +722,27 @@ ivas_error ivas_spar_dec_fx(
* Decode SPAR metadata
*---------------------------------------------------------------------*/
- IF( ( error = ivas_spar_dec_MD_fx( st_ivas, st0 ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_spar_dec_MD_fx( st_ivas, st0 ) ), IVAS_ERR_OK ) )
{
return error;
}
- *nb_bits_read = st0->next_bit_pos + nb_bits_read_orig;
+ *nb_bits_read = add( st0->next_bit_pos, nb_bits_read_orig );
+ move16();
st0->bit_stream = bit_stream_orig;
st0->next_bit_pos = next_bit_pos_orig;
+ move16();
- IF( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 )
+ test();
+ IF( !st0->bfi && EQ_32( hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) )
{
Word16 zero_pad_bits;
- *nb_bits_read += SID_FORMAT_NBITS;
- zero_pad_bits = (Word16) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - *nb_bits_read;
+ *nb_bits_read = add( *nb_bits_read, SID_FORMAT_NBITS );
+ move16();
+ zero_pad_bits = sub( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC, *nb_bits_read );
assert( zero_pad_bits <= 1 );
- *nb_bits_read += zero_pad_bits;
+ *nb_bits_read = add( *nb_bits_read, zero_pad_bits );
+ move16();
}
pop_wmops();
@@ -792,13 +871,15 @@ static Word16 ivas_get_spar_table_idx_from_coded_idx(
test();
IF( EQ_32( ivas_spar_br_table_consts[i].ivas_total_brate, ivas_total_brate ) && EQ_16( ivas_spar_br_table_consts[i].sba_order, sba_order ) )
{
- ind1[j++] = i;
+ ind1[j] = i;
move16();
+ j = add( j, 1 );
}
}
assert( j > 0 );
- *bitlen = ivas_get_bits_to_encode( j - 1 );
+ *bitlen = ivas_get_bits_to_encode( sub( j, 1 ) );
+ move16();
ind2 = get_next_indice_fx( st0, *bitlen );
@@ -856,6 +937,7 @@ static Word16 ivas_parse_spar_header(
Word16 bitlen, bwidth;
*table_idx = ivas_get_spar_table_idx_from_coded_idx( ivas_total_brate, sba_order, st0, &bitlen );
+ move16();
bwidth = ivas_spar_br_table_consts[( *table_idx )].bwidth;
move16();
@@ -879,6 +961,7 @@ static int16_t ivas_parse_spar_header(
}
#endif
+
#ifdef IVAS_FLOAT_FIXED
static Word16 get_random_number_fx(
Word16 *seed )
@@ -895,6 +978,7 @@ static float get_random_number(
}
#endif // IVAS_FLOAT_FIXED
+
#ifdef IVAS_FLOAT_FIXED
static Word32 matrix_det_fx(
const Word32 a00,
@@ -904,9 +988,7 @@ static Word32 matrix_det_fx(
{
return L_sub( Mpy_32_32( a00, a11 ), Mpy_32_32( a01, a10 ) );
}
-#endif
-
-#ifndef IVAS_FLOAT_FIXED
+#else
static float matrix_det(
const float a00,
const float a01,
@@ -917,6 +999,7 @@ static float matrix_det(
}
#endif
+
#ifdef IVAS_FLOAT_FIXED
static void matrix_inverse_fx(
Word32 in[3][3],
@@ -938,6 +1021,7 @@ static void matrix_inverse_fx(
out[0][0] = L_shl( tmp_32, shift );
move32();
*out_q = add( shift, sub( Q15, tmp_e ) );
+ move16();
return;
}
@@ -960,6 +1044,7 @@ static void matrix_inverse_fx(
move32();
*out_q = add( Q27, sub( q_fac, 31 ) );
+ move16();
return;
}
@@ -992,12 +1077,11 @@ static void matrix_inverse_fx(
move32();
*out_q = add( Q23, sub( q_fac, 31 ) );
+ move16();
return;
}
-#endif
-
-#ifndef IVAS_FLOAT_FIXED
+#else
static void matrix_inverse(
float in[3][3],
float out[3][3],
@@ -1051,6 +1135,7 @@ static void matrix_inverse(
*
*
*---------------------------------------------------------------------*/
+
#ifdef IVAS_FLOAT_FIXED
void ivas_spar_get_cldfb_gains_fx(
SPAR_DEC_HANDLE hSpar,
@@ -1077,7 +1162,9 @@ void ivas_spar_get_cldfb_gains_fx(
Word16 seed, split_band, slot_row, slot_col, slot, tmp_idx;
pt_len = cldfbAnaDec0->p_filter_length;
+ move16();
num_cldfb_bands = cldfbAnaDec0->no_channels;
+ move16();
stride = NS2SA_fx2( output_Fs_fx, DELAY_CLDFB_NS );
encfb_delay = NS2SA_fx2( output_Fs_fx, IVAS_FB_ENC_DELAY_NS );
@@ -1087,28 +1174,37 @@ void ivas_spar_get_cldfb_gains_fx(
cf_end = add( sub( hSpar->hFbMixer->cross_fade_end_offset, encfb_delay ), decfb_delay );
cf_len = sub( cf_end, cf_start );
weights_fx = hSpar->hFbMixer->cldfb_cross_fade_fx;
- cf_cldfb_start = shr( (Word16) ceil_fixed( sub( divide1616( sub( cf_start, shr( decfb_delay, 1 ) ), shl( stride, 9 ) ), 32 ), 6 ), 6 );
+ cf_cldfb_start = shr( extract_l( ceil_fixed( sub( divide1616( sub( cf_start, shr( decfb_delay, 1 ) ), shl( stride, 9 ) ), 32 ), 6 ) ), 6 );
cf_cldfb_end = shr( divide1616( add( sub( cf_start, shr( decfb_delay, 1 ) ), cf_len ), shl( stride, 9 ) ), 6 ); /*q-factor of stride is 9(as max value is 60)*/
num_cf_slots = add( sub( cf_cldfb_end, cf_cldfb_start ), 1 );
num_samples = add( imult1616( num_cf_slots, stride ), sub( pt_len, stride ) );
seed = RANDOM_INITSEED;
+ move16();
split_band = SPAR_DIRAC_SPLIT_START_BAND;
+ move16();
pp_ts_im_fx[0] = ts_im_fx;
pp_ts_re_fx[0] = ts_re_fx;
set32_fx( tgt_fx, 0, ( 3 - 1 ) * CLDFB_NO_CHANNELS_MAX + 10 * CLDFB_NO_CHANNELS_MAX );
cf_start_s_fx = divide3232( ( sub( cf_start, shr( decfb_delay, 1 ) ) ), output_Fs_fx );
cf_len_s_fx = divide3232( sub( hSpar->hFbMixer->cross_fade_end_offset, hSpar->hFbMixer->cross_fade_start_offset ), output_Fs_fx );
- Word16 Q_cf_start_s = norm_s( cf_start_s_fx ) - 1;
+ Word16 Q_cf_start_s = sub( norm_s( cf_start_s_fx ), 1 );
Word16 Q_cf_len_s = norm_s( cf_len_s_fx );
- Word16 Q_weights = 15 + Q_cf_start_s - Q_cf_len_s;
+ Word16 Q_weights = add( 15, sub( Q_cf_start_s, Q_cf_len_s ) );
FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ )
{
weights_fx[ts] = divide1616( shl( sub( divide3232( L_mult0( add( shl( ts, 1 ), 1 ), shr( stride, 1 ) ), output_Fs_fx ), cf_start_s_fx ), Q_cf_start_s ), shl( cf_len_s_fx, Q_cf_len_s ) );
+ move16();
weights_fx[ts] = s_max( s_min( weights_fx[ts], shl( 1, Q_weights ) ), 0 );
+ move16();
}
hSpar->hFbMixer->cldfb_cross_fade_start = cf_cldfb_start;
+ move16();
hSpar->hFbMixer->cldfb_cross_fade_end = cf_cldfb_end;
+ move16();
+ test();
+ test();
+ test();
IF( GT_16( num_cf_slots, 3 ) || GT_16( pt_len, 10 * CLDFB_NO_CHANNELS_MAX ) || GT_16( stride, CLDFB_NO_CHANNELS_MAX ) || EQ_16( split_band, IVAS_MAX_NUM_BANDS ) )
{
return;
@@ -1121,34 +1217,44 @@ void ivas_spar_get_cldfb_gains_fx(
// floatToFixed_arrL( (float *)hSpar->hFbMixer->pFilterbank_cross_fade, pFilterbank_cross_fade_fx, Q31, cf_len );
FOR( sample = 0; sample < cf_len; sample++ )
{
- tgt_fx[tmp_idx++] = L_deposit_h( hSpar->hFbMixer->pFilterbank_cross_fade_fx[sample] );
+ tgt_fx[tmp_idx] = L_deposit_h( hSpar->hFbMixer->pFilterbank_cross_fade_fx[sample] );
+ move32();
+ tmp_idx = add( tmp_idx, 1 );
/* increasing window function */
}
FOR( ; tmp_idx < num_samples; tmp_idx++ )
{
/* fill up with ones*/
tgt_fx[tmp_idx] = MAX_32;
+ move32();
}
FOR( sample = 0; sample < num_samples; sample++ )
{
/* initialize trasnform matrix with zeros*/
T_fx[sample][0] = T_fx[sample][1] = T_fx[sample][2] = 0;
+ move32();
+ move32();
+ move32();
}
- FOR( sample = 0; sample < pt_len - stride; sample++ )
+ FOR( sample = 0; sample < sub( pt_len, stride ); sample++ )
{
/* fill internal CLDFB analysis time buffer with data*/
Word16 x_fx = get_random_number_fx( &seed );
cldfbAnaDec0->cldfb_state_fx[sample] = L_shl( x_fx, 12 );
+ move32();
}
Word16 q_cldfb = 27;
+ move16();
cldfbAnaDec0->Q_cldfb_state = q_cldfb;
+ move16();
FOR( slot = 0; slot < num_cf_slots; slot++ )
{
FOR( sample = 0; sample < stride; sample++ )
{
Word16 x_fx = get_random_number_fx( &seed );
ts_inout_fx[sample] = L_shl( x_fx, 12 ); /*Q-27*/
+ move32();
}
cldfbAnalysis_ts_fx_fixed_q( ts_inout_fx, ts_re_fx, ts_im_fx, num_cldfb_bands, cldfbAnaDec0, &q_cldfb );
@@ -1157,19 +1263,23 @@ void ivas_spar_get_cldfb_gains_fx(
FOR( sample = 0; sample < stride; sample++ )
{
- T_fx[slot * stride + sample][slot] = ts_inout_fx[sample];
+ T_fx[add( imult1616( slot, stride ), sample )][slot] = ts_inout_fx[sample];
+ move32();
}
tmp_idx = sub( pt_len, 1 );
FOR( sample = stride; sample < pt_len; sample++ )
{
- T_fx[add( imult1616( slot, stride ), sample )][slot] = cldfbSynDec0->cldfb_state_fx[tmp_idx--];
+ T_fx[add( imult1616( slot, stride ), sample )][slot] = cldfbSynDec0->cldfb_state_fx[tmp_idx];
+ move32();
+ tmp_idx = sub( tmp_idx, 1 );
}
}
/* target is synthesis output times the cross-fade window*/
FOR( sample = 0; sample < num_samples; sample++ )
{
- tgt_fx[sample] = L_shl( Mult_32_32( tgt_fx[sample], L_add( T_fx[sample][0], L_add( T_fx[sample][1], T_fx[sample][2] ) ) ), 10 ); /*Q31*/
+ tgt_fx[sample] = L_shl( Mpy_32_32( tgt_fx[sample], L_add( T_fx[sample][0], L_add( T_fx[sample][1], T_fx[sample][2] ) ) ), 10 ); /*Q31*/
+ move32();
}
/* compute matrices */
FOR( slot_row = 0; slot_row < num_cf_slots; slot_row++ )
@@ -1177,37 +1287,48 @@ void ivas_spar_get_cldfb_gains_fx(
FOR( slot_col = slot_row; slot_col < num_cf_slots; slot_col++ )
{
Tt_T_fx[slot_row][slot_col] = 0;
+ move32();
FOR( sample = 0; sample < num_samples; sample++ )
{
- Tt_T_fx[slot_row][slot_col] = L_add( Tt_T_fx[slot_row][slot_col], Mult_32_32( L_shl( T_fx[sample][slot_row], 8 ), L_shl( T_fx[sample][slot_col], 8 ) ) ); /*Q58-Q31*/
+ Tt_T_fx[slot_row][slot_col] = L_add( Tt_T_fx[slot_row][slot_col], Mpy_32_32( L_shl( T_fx[sample][slot_row], 8 ), L_shl( T_fx[sample][slot_col], 8 ) ) ); /*Q58-Q31*/
+ move32();
}
}
}
Tt_T_fx[1][0] = Tt_T_fx[0][1];
+ move32();
Tt_T_fx[2][0] = Tt_T_fx[0][2];
+ move32();
Tt_T_fx[2][1] = Tt_T_fx[1][2];
+ move32();
FOR( slot_row = 0; slot_row < num_cf_slots; slot_row++ )
{
Tt_tgt_fx[slot_row] = 0;
+ move32();
FOR( sample = 0; sample < num_samples; sample++ )
{
- Tt_tgt_fx[slot_row] = L_add( Tt_tgt_fx[slot_row], Mult_32_32( T_fx[sample][slot_row], tgt_fx[sample] ) );
+ Tt_tgt_fx[slot_row] = L_add( Tt_tgt_fx[slot_row], Mpy_32_32( T_fx[sample][slot_row], tgt_fx[sample] ) );
+ move32();
}
}
Word16 output_q = 27;
+ move16();
matrix_inverse_fx( Tt_T_fx, Tt_T_inv_fx, num_cf_slots, &output_q );
/* compute the optimal coefficients */
FOR( slot_row = 0; slot_row < num_cf_slots; slot_row++ )
{
Word32 tmp = 0;
+ move32();
FOR( slot_col = 0; slot_col < num_cf_slots; slot_col++ )
{
- tmp = L_add( tmp, Mult_32_32( Tt_T_inv_fx[slot_row][slot_col], Tt_tgt_fx[slot_col] ) );
+ tmp = L_add( tmp, Mpy_32_32( Tt_T_inv_fx[slot_row][slot_col], Tt_tgt_fx[slot_col] ) );
}
- weights_fx[add( cf_cldfb_start, slot_row )] = extract_l( L_shr( L_max( L_min( tmp, L_shl( 1, ( output_q - 10 ) ) ), 0 ), output_q - 10 - Q_weights ) ); /*Q_weights*/
+ weights_fx[add( cf_cldfb_start, slot_row )] = extract_l( L_shr( L_max( L_min( tmp, L_shl( 1, sub( output_q, 10 ) ) ), 0 ), sub( sub( output_q, 10 ), Q_weights ) ) ); /*Q_weights*/
+ move16();
}
hSpar->hFbMixer->cldfb_cross_fade_q = Q_weights;
+ move16();
cldfb_reset_memory_fx( cldfbSynDec0 );
cldfb_reset_memory_fx( cldfbAnaDec0 );
@@ -1465,7 +1586,7 @@ static ivas_error ivas_spar_dec_MD_fx(
move16();
test();
- IF( GT_32( ivas_total_brate, FRAME_NO_DATA ) && !bfi )
+ IF( ( ivas_total_brate > FRAME_NO_DATA ) && !bfi )
{
IF( GT_32( ivas_total_brate, IVAS_SID_5k2 ) )
{
@@ -1479,19 +1600,20 @@ static ivas_error ivas_spar_dec_MD_fx(
ELSE
{
hSpar->hMdDec->spar_md.num_bands = s_min( SPAR_DIRAC_SPLIT_START_BAND, IVAS_MAX_NUM_BANDS );
+ move16();
}
IF( NE_16( hSpar->hMdDec->table_idx, table_idx ) )
{
hSpar->hMdDec->table_idx = table_idx;
move16();
- IF( hSpar->hTdDecorr )
+ if ( hSpar->hTdDecorr )
{
hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking;
move16();
}
- IF( ( error = ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1524,6 +1646,7 @@ static ivas_error ivas_spar_dec_MD_fx(
IF( EQ_16( hSpar->hMdDec->spar_md_cfg.nchan_transport, 1 ) )
{
hSpar->AGC_flag = get_next_indice_fx( st0, 1 );
+ move16();
}
ivas_agc_read_bits_fx( hSpar->hAgcDec, st0, hSpar->hMdDec->spar_md_cfg.nchan_transport, hSpar->AGC_flag );
@@ -1536,7 +1659,7 @@ static ivas_error ivas_spar_dec_MD_fx(
test();
test();
test();
- IF( EQ_16( st0->m_old_frame_type, ZERO_FRAME ) && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) && EQ_16( st0->prev_bfi, 0 ) && EQ_16( hSpar->hMdDec->spar_md_cfg.nchan_transport, 1 ) )
+ IF( EQ_16( st0->m_old_frame_type, ZERO_FRAME ) && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) && ( st0->prev_bfi == 0 ) && EQ_16( hSpar->hMdDec->spar_md_cfg.nchan_transport, 1 ) )
{
ivas_spar_setup_md_smoothing_fx( hSpar->hMdDec, num_bands_out, num_md_sub_frames );
}
@@ -1552,7 +1675,7 @@ static ivas_error ivas_spar_dec_MD_fx(
ivas_spar_smooth_md_dtx_fx( hSpar->hMdDec, num_bands_out, num_md_sub_frames );
}
- set_s( hSpar->hMdDec->valid_bands, 0, IVAS_MAX_NUM_BANDS );
+ set16_fx( hSpar->hMdDec->valid_bands, 0, IVAS_MAX_NUM_BANDS );
}
pop_wmops();
@@ -1678,87 +1801,109 @@ static ivas_error ivas_spar_dec_MD(
*
*
*-------------------------------------------------------------------*/
+
#ifdef IVAS_FLOAT_FIXED
static Word16 ivas_spar_get_cldfb_slot_gain_fx(
SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */
const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
- const int16_t time_slot_idx,
- int16_t *time_slot_idx0,
- int16_t *time_slot_idx1,
+ const Word16 time_slot_idx,
+ Word16 *time_slot_idx0,
+ Word16 *time_slot_idx1,
Word16 *weight_lowfreq_fx )
{
Word16 weight_fx;
Word32 encfb_delay_fx, decfb_delay_fx;
Word32 xfade_start_ns_fx;
- int16_t xfade_delay_subframes;
- int16_t i_hist;
- int16_t split_band;
+ Word16 xfade_delay_subframes;
+ Word16 i_hist;
+ Word16 split_band;
*weight_lowfreq_fx = hSpar->hFbMixer->cldfb_cross_fade_fx[time_slot_idx];
+ move16();
encfb_delay_fx = IVAS_FB_ENC_DELAY_NS;
+ move32();
decfb_delay_fx = IVAS_FB_DEC_DELAY_NS;
+ move32();
Word32 one_by_outfs = 0; // q15
- switch ( hDecoderConfig->output_Fs )
+ move32();
+ SWITCH( hDecoderConfig->output_Fs )
{
case 16000:
one_by_outfs = 2048000000;
- break;
+ move32();
+ BREAK;
case 32000:
one_by_outfs = 1024000000;
- break;
+ move32();
+ BREAK;
case 48000:
one_by_outfs = 682666688;
- break;
+ move32();
+ BREAK;
default:
assert( 0 );
}
- Word64 fade_start = (Word64) one_by_outfs * hSpar->hFbMixer->cross_fade_start_offset;
+ Word64 fade_start = W_mult0_32_32( one_by_outfs, hSpar->hFbMixer->cross_fade_start_offset );
+ move64();
fade_start = W_shr( fade_start, 15 );
- xfade_start_ns_fx = ( (Word32) fade_start - encfb_delay_fx + L_shr( decfb_delay_fx, 1 ) );
- xfade_delay_subframes = (int16_t) ( xfade_start_ns_fx / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) );
+ xfade_start_ns_fx = L_add( L_sub( W_extract_l( fade_start ), encfb_delay_fx ), L_shr( decfb_delay_fx, 1 ) );
+ xfade_delay_subframes = extract_l( Mpy_32_32( xfade_start_ns_fx, 429 /* 1 / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 -> 429 */ ) );
- i_hist = 4 - xfade_delay_subframes;
+ i_hist = sub( 4, xfade_delay_subframes );
split_band = SPAR_DIRAC_SPLIT_START_BAND;
+ move16();
- if ( split_band < IVAS_MAX_NUM_BANDS )
+ IF( LT_16( split_band, IVAS_MAX_NUM_BANDS ) )
{
- if ( hSpar->i_subframe > 3 )
+ IF( GT_16( hSpar->i_subframe, 3 ) )
{
Word16 mod_res = time_slot_idx % MAX_PARAM_SPATIAL_SUBFRAMES;
- switch ( mod_res )
+ move16();
+ SWITCH( mod_res )
{
case 0:
weight_fx = 0;
- break;
+ move16();
+ BREAK;
case 1:
weight_fx = 8191;
- break;
+ move16();
+ BREAK;
case 2:
weight_fx = 16383;
- break;
+ move16();
+ BREAK;
case 3:
weight_fx = 24575;
- break;
+ move16();
+ BREAK;
default:
weight_fx = 0;
- break;
+ move16();
+ BREAK;
}
}
- else
+ ELSE
{
weight_fx = 0;
+ move16();
}
*time_slot_idx0 = i_hist;
- *time_slot_idx1 = i_hist + 1;
+ move16();
+ *time_slot_idx1 = add( i_hist, 1 );
+ move16();
}
- else
+ ELSE
{
/* determine cross-fade gain for current frame Parameters*/
*time_slot_idx0 = hSpar->hFbMixer->cldfb_cross_fade_start;
+ move16();
*time_slot_idx1 = hSpar->hFbMixer->cldfb_cross_fade_end;
+ move16();
weight_fx = *weight_lowfreq_fx;
+ move16();
}
return weight_fx;
@@ -1822,54 +1967,61 @@ static float ivas_spar_get_cldfb_slot_gain(
*
*
*-------------------------------------------------------------------*/
+
#ifdef IVAS_FLOAT_FIXED
void ivas_spar_get_parameters_fx(
SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */
const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
- const int16_t ts,
- const int16_t num_ch_out,
- const int16_t num_ch_in,
- const int16_t num_spar_bands,
+ const Word16 ts,
+ const Word16 num_ch_out,
+ const Word16 num_ch_in,
+ const Word16 num_spar_bands,
Word32 par_mat_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] )
{
- int16_t spar_band, out_ch, in_ch;
+ Word16 spar_band, out_ch, in_ch;
Word16 weight_fx, weight_20ms_fx;
- int16_t ts0, ts1, split_band;
+ Word16 ts0, ts1, split_band;
// weight = ivas_spar_get_cldfb_slot_gain(hSpar, hDecoderConfig, ts, &ts0, &ts1, &weight_20ms);
weight_fx = ivas_spar_get_cldfb_slot_gain_fx( hSpar, hDecoderConfig, ts, &ts0, &ts1, &weight_20ms_fx );
split_band = SPAR_DIRAC_SPLIT_START_BAND;
- for ( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
+ move16();
+ FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
{
- for ( out_ch = 0; out_ch < num_ch_out; out_ch++ )
+ FOR( out_ch = 0; out_ch < num_ch_out; out_ch++ )
{
- if ( split_band < IVAS_MAX_NUM_BANDS
- /* 20ms cross-fade for Transport channels in all frequency bands */
- && ( 0 == ivas_is_res_channel( out_ch, hSpar->hMdDec->spar_md_cfg.nchan_transport ) ) /* sub-frame processing for missing channels in all frequency bands*/
+ test();
+ IF( LT_16( split_band, IVAS_MAX_NUM_BANDS )
+ /* 20ms cross-fade for Transport channels in all frequency bands */
+ && ( 0 == ivas_is_res_channel( out_ch, hSpar->hMdDec->spar_md_cfg.nchan_transport ) ) /* sub-frame processing for missing channels in all frequency bands*/
)
{
- for ( in_ch = 0; in_ch < num_ch_in; in_ch++ )
+ FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ )
{
- if ( hSpar->i_subframe > 3 )
+ IF( GT_16( hSpar->i_subframe, 3 ) )
{
par_mat_fx[out_ch][in_ch][spar_band] = L_add_sat( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[ts0][out_ch][in_ch][spar_band], sub( MAX_WORD16, weight_fx ) ),
Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[ts1][out_ch][in_ch][spar_band], weight_fx ) );
+ move32();
}
- else
+ ELSE
{
par_mat_fx[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band];
+ move32();
}
}
}
- else
+ ELSE
{
- for ( in_ch = 0; in_ch < num_ch_in; in_ch++ )
+ FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ )
{
/* 20ms Transport channel reconstruction with matching encoder/decoder processing */
- int16_t prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */
+ Word16 prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */
+ move16();
par_mat_fx[out_ch][in_ch][spar_band] = L_add_sat( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[prev_idx][out_ch][in_ch][spar_band], sub( MAX_WORD16, weight_20ms_fx ) ), Mpy_32_16_1( hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band], weight_20ms_fx ) );
+ move32();
}
}
}
@@ -1878,7 +2030,6 @@ void ivas_spar_get_parameters_fx(
return;
}
#else
-
void ivas_spar_get_parameters(
SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */
const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
@@ -1933,6 +2084,7 @@ void ivas_spar_get_parameters(
}
#endif
+
/*-------------------------------------------------------------------*
* ivas_spar_get_skip_mat()
*
@@ -2018,7 +2170,9 @@ static void ivas_spar_get_skip_mat_fx(
FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ )
{
skip_mat[out_ch][in_ch] = 1;
+ move16();
skip_flag = 1;
+ move16();
FOR( i_ts = 0; i_ts < MAX_PARAM_SPATIAL_SUBFRAMES; i_ts++ )
{
FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
@@ -2026,6 +2180,7 @@ static void ivas_spar_get_skip_mat_fx(
IF( hSpar->hMdDec->mixer_mat_prev_fx[1 + i_ts][out_ch][in_ch][spar_band] != 0 )
{
skip_flag = 0;
+ move16();
BREAK;
}
}
@@ -2033,19 +2188,21 @@ static void ivas_spar_get_skip_mat_fx(
IF( skip_flag == 0 )
{
skip_mat[out_ch][in_ch] = 0;
+ move16();
BREAK;
}
}
- IF( skip_mat[out_ch][in_ch] == 1 )
+ IF( EQ_16( skip_mat[out_ch][in_ch], 1 ) )
{
FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ )
{
FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
{
- IF( hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band + i_ts * IVAS_MAX_NUM_BANDS] != 0 )
+ IF( hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][add( spar_band, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] != 0 )
{
skip_flag = 0;
+ move16();
BREAK;
}
}
@@ -2053,6 +2210,7 @@ static void ivas_spar_get_skip_mat_fx(
IF( skip_flag == 0 )
{
skip_mat[out_ch][in_ch] = 0;
+ move16();
BREAK;
}
}
@@ -2064,6 +2222,7 @@ static void ivas_spar_get_skip_mat_fx(
}
#endif
+
#ifdef IVAS_FLOAT_FIXED
static void ivas_spar_calc_smooth_facs_fx(
Word32 *cldfb_in_ts_re_fx[CLDFB_NO_COL_MAX], // i
@@ -2083,89 +2242,118 @@ static void ivas_spar_calc_smooth_facs_fx(
Word32 L_temp;
Word16 exp_tmp, q_tmp;
bin = 0;
+ move16();
FOR( b = 0; b < nbands_spar; b++ )
{
- IF( GE_16( bin, CLDFB_NO_CHANNELS_MAX ) || ( GT_16( b, 0 ) && LT_16( bin2band->p_cldfb_map_to_spar_band[bin], bin2band->p_cldfb_map_to_spar_band[bin - 1] ) ) )
+ test();
+ test();
+ IF( GE_16( bin, CLDFB_NO_CHANNELS_MAX ) || ( ( b > 0 ) && LT_16( bin2band->p_cldfb_map_to_spar_band[bin], bin2band->p_cldfb_map_to_spar_band[bin - 1] ) ) )
{
BREAK;
}
/* calculate band-wise subframe energies */
subframe_band_nrg_fx[b] = 0;
+ move32();
WHILE( LT_16( bin, CLDFB_NO_CHANNELS_MAX ) && EQ_16( b, bin2band->p_cldfb_map_to_spar_band[bin] ) )
{
+ test();
FOR( ts = 0; ts < nSlots; ts++ )
{
L_temp = L_add( L_shr( Mpy_32_32( cldfb_in_ts_re_fx[ts][bin], cldfb_in_ts_re_fx[ts][bin] ), 4 ), L_shr( Mpy_32_32( cldfb_in_ts_im_fx[ts][bin], cldfb_in_ts_im_fx[ts][bin] ), 4 ) ); // 2*q_cldfb - 35
subframe_band_nrg_fx[b] = L_add_sat( subframe_band_nrg_fx[b], L_temp ); // 2*q_cldfb - 35 (saturation reached in 1 orig pytest)
+ move32();
}
- bin++;
+ bin = add( bin, 1 );
}
- exp_tmp = sub( 66, i_mult( 2, q_cldfb ) );
+ exp_tmp = sub( 66, shl( q_cldfb, 1 ) );
subframe_band_nrg_fx[b] = Sqrt32( subframe_band_nrg_fx[b], &exp_tmp );
- q_tmp = 31 - exp_tmp;
+ move32();
+ q_tmp = sub( 31, exp_tmp );
+ test();
IF( isFirstSubframe && LT_16( nSlots, MAX_PARAM_SPATIAL_SUBFRAMES ) )
{
/* fill up to full 5ms subframe */
smooth_buf_fx[b][0] = L_add( smooth_buf_fx[b][0], L_shr( subframe_band_nrg_fx[b], q_tmp ) ); // Q0
+ move32();
}
ELSE
{
smooth_buf_fx[b][0] = L_shr( subframe_band_nrg_fx[b], q_tmp ); // Q0
+ move32();
}
/* calculate short and long energy averages */
smooth_short_avg_fx[b] = 0;
+ move32();
FOR( i = 0; i < 2 * SBA_DIRAC_NRG_SMOOTH_SHORT; i++ )
{
smooth_short_avg_fx[b] = L_add( smooth_short_avg_fx[b], smooth_buf_fx[b][i] ); // Q0
+ move32();
}
smooth_long_avg_fx[b] = smooth_short_avg_fx[b]; // Q0
+ move32();
FOR( i = 2 * SBA_DIRAC_NRG_SMOOTH_SHORT; i < 2 * SBA_DIRAC_NRG_SMOOTH_LONG; i++ )
{
smooth_long_avg_fx[b] = L_add( smooth_long_avg_fx[b], smooth_buf_fx[b][i] ); // Q0
+ move32();
}
smooth_short_avg_fx[b] = Mpy_32_16_1( smooth_short_avg_fx[b], 5461 /*(1/6 in Q15)*/ ); // Q0
- smooth_long_avg_fx[b] = Mpy_32_16_1( smooth_long_avg_fx[b], 1639 /*(1/20 in Q15)*/ ); // Q0
+ move32();
+ smooth_long_avg_fx[b] = Mpy_32_16_1( smooth_long_avg_fx[b], 1639 /*(1/20 in Q15)*/ ); // Q0
+ move32();
/* calculate smoothing factor based on energy averages */
/* reduce factor for higher short-term energy */
IF( smooth_long_avg_fx[b] <= 0 )
{
smooth_fac_fx[b] = 0;
+ move16();
}
- ELSE IF( smooth_long_avg_fx[b] >= smooth_short_avg_fx[b] )
+ ELSE IF( GE_32( smooth_long_avg_fx[b], smooth_short_avg_fx[b] ) )
{
smooth_fac_fx[b] = MAX_16; // 1.0f in Q15
+ move16();
}
ELSE
{
smooth_fac_fx[b] = divide3232( smooth_long_avg_fx[b], smooth_short_avg_fx[b] ); // Q15
+ move16();
}
/* map factor to range [0;1] */
smooth_fac_fx[b] = shl( mult_r( s_max( 0, sub( smooth_fac_fx[b], 9830 ) ), 23405 /*Q14*/ ), 1 ); // Q15
+ move16();
/* compress factor (higher compression in lowest bands) */
IF( LT_16( b, 2 ) )
{
exp_tmp = 0;
+ move16();
smooth_fac_fx[b] = Sqrt16( smooth_fac_fx[b], &exp_tmp );
+ move16();
smooth_fac_fx[b] = Sqrt16( smooth_fac_fx[b], &exp_tmp );
+ move16();
smooth_fac_fx[b] = shl( smooth_fac_fx[b], exp_tmp ); // Q15
+ move16();
}
ELSE
{
exp_tmp = 0;
+ move16();
smooth_fac_fx[b] = Sqrt16( smooth_fac_fx[b], &exp_tmp );
+ move16();
smooth_fac_fx[b] = shl( smooth_fac_fx[b], exp_tmp ); // Q15
+ move16();
}
/* apply upper bounds depending on band */
smooth_fac_fx[b] = s_max( min_smooth_gains1_fx[b], s_min( max_smooth_gains2_fx[b], smooth_fac_fx[b] ) );
+ move16();
}
/* only update if we collected a full 5ms worth of energies for the buffer */
+ test();
IF( isFirstSubframe || EQ_16( nSlots, MAX_PARAM_SPATIAL_SUBFRAMES ) )
{
FOR( b = 0; b < nbands_spar; b++ )
@@ -2173,6 +2361,7 @@ static void ivas_spar_calc_smooth_facs_fx(
FOR( i = 2 * SBA_DIRAC_NRG_SMOOTH_LONG; i > 0; i-- )
{
smooth_buf_fx[b][i] = smooth_buf_fx[b][i - 1];
+ move32();
}
}
}
@@ -2273,6 +2462,7 @@ static void ivas_spar_calc_smooth_facs(
}
#endif
+
/*-------------------------------------------------------------------*
* ivas_spar_dec_agc_pca()
*
@@ -2372,7 +2562,6 @@ void ivas_spar_dec_agc_pca_fx(
IF( hSpar->hMdDec->td_decorr_flag )
{
num_in_ingest = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
- move16();
}
ELSE
{
@@ -2396,11 +2585,13 @@ void ivas_spar_dec_agc_pca_fx(
}
#endif
+
/*-------------------------------------------------------------------*
* ivas_spar_dec_set_render_map()
*
*
*-------------------------------------------------------------------*/
+
#ifndef IVAS_FLOAT_FIXED
void ivas_spar_dec_set_render_map(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
@@ -2454,7 +2645,8 @@ void ivas_spar_dec_set_render_map_fx(
/* copy also to tc buffer */
/* only for non-combined formats and combinded formats w/o discrete objects */
- IF( !( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) )
+ test();
+ IF( !( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) )
{
st_ivas->hTcBuffer->nb_subframes = hSpar->nb_subframes;
move16();
@@ -2467,13 +2659,14 @@ void ivas_spar_dec_set_render_map_fx(
}
#endif
-#ifndef IVAS_FLOAT_FIXED
+
/*-------------------------------------------------------------------*
* ivas_spar_dec_upmixer()
*
* IVAS SPAR upmixer
*-------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
void ivas_spar_dec_set_render_params(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */
@@ -2504,7 +2697,9 @@ void ivas_spar_dec_set_render_params_fx(
hSpar = st_ivas->hSpar;
nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
+ move16();
num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands;
+ move16();
ivas_spar_dec_gen_umx_mat_fx( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) );
ivas_spar_dec_set_render_map_fx( st_ivas, n_cldfb_slots );
@@ -2513,11 +2708,13 @@ void ivas_spar_dec_set_render_params_fx(
}
#endif
+
/*-------------------------------------------------------------------*
* ivas_spar_dec_digest_tc()
*
*
*-------------------------------------------------------------------*/
+
#ifndef IVAS_FLOAT_FIXED
void ivas_spar_dec_digest_tc(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
@@ -2610,7 +2807,7 @@ void ivas_spar_dec_digest_tc_fx(
hSpar = st_ivas->hSpar;
test();
test();
- IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) )
+ IF( hSpar->hMdDec->td_decorr_flag && !( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) )
{
Word16 nchan_internal, ch;
Word16 ch_sba_idx;
@@ -2619,12 +2816,13 @@ void ivas_spar_dec_digest_tc_fx(
Word32 *p_tc[MAX_SPAR_INTERNAL_CHANNELS];
Word32 Pcm_tmp[MAX_SPAR_INTERNAL_CHANNELS][L_FRAME48k];
Word16 q_format = Q11;
+ move16();
ch_sba_idx = 0;
move16();
- IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
- IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ if ( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
ch_sba_idx = st_ivas->nchan_ism;
move16();
@@ -2632,15 +2830,17 @@ void ivas_spar_dec_digest_tc_fx(
}
/* TD decorrelator */
- default_frame = (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
+ Word32 quo, rem;
+ iDiv_and_mod_32( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC, &quo, &rem, 0 );
+ default_frame = extract_l( quo );
nSamplesLeftForTD = nSamplesForRendering;
+ move16();
nchan_internal = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
FOR( ch = 0; ch < nchan_internal; ch++ )
{
pPcm_tmp[ch] = Pcm_tmp[ch];
- p_tc[ch] = st_ivas->hTcBuffer->tc_fx[ch + ch_sba_idx];
- move32();
+ p_tc[ch] = st_ivas->hTcBuffer->tc_fx[add( ch, ch_sba_idx )];
}
WHILE( nSamplesLeftForTD )
@@ -2652,22 +2852,23 @@ void ivas_spar_dec_digest_tc_fx(
ivas_td_decorr_process_fx( hSpar->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr, &q_format );
st_ivas->hTcBuffer->q_tc_fx = s_min( st_ivas->hTcBuffer->q_tc_fx, q_format );
+ move16();
IF( GE_16( hSpar->hTdDecorr->num_apd_outputs, sub( nchan_internal, nchan_transport ) ) )
{
FOR( ch = 0; ch < sub( nchan_internal, nchan_transport ); ch++ )
{
- Copy32( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - ch], p_tc[nchan_internal - 1 - ch], nSamplesToDecorr );
+ Copy32( pPcm_tmp[sub( sub( hSpar->hTdDecorr->num_apd_outputs, 1 ), ch )], p_tc[sub( sub( nchan_internal, 1 ), ch )], nSamplesToDecorr );
}
}
ELSE
{
FOR( ch = 0; ch < sub( nchan_internal, nchan_transport ); ch++ )
{
- set32_fx( p_tc[nchan_internal - 1 - ch], 0, nSamplesToDecorr );
+ set32_fx( p_tc[sub( sub( nchan_internal, 1 ), ch )], 0, nSamplesToDecorr );
}
FOR( ch = 0; ch < hSpar->hTdDecorr->num_apd_outputs; ch++ )
{
- Copy32( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - ch], p_tc[nchan_internal - 1 - ch], nSamplesToDecorr );
+ Copy32( pPcm_tmp[sub( sub( hSpar->hTdDecorr->num_apd_outputs, 1 ), ch )], p_tc[sub( sub( nchan_internal, 1 ), ch )], nSamplesToDecorr );
}
}
}
@@ -2686,6 +2887,7 @@ void ivas_spar_dec_digest_tc_fx(
}
#endif
+
#ifndef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
* ivas_spar_dec_upmixer()
@@ -2812,6 +3014,14 @@ void ivas_spar_dec_upmixer(
return;
}
#endif
+
+
+/*-------------------------------------------------------------------*
+ * ivas_spar_dec_upmixer_sf()
+ *
+ * IVAS SPAR upmixer
+ *-------------------------------------------------------------------*/
+
#ifdef IVAS_FLOAT_FIXED
void ivas_spar_dec_upmixer_sf_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
@@ -2828,7 +3038,7 @@ void ivas_spar_dec_upmixer_sf_fx(
Word16 slot_size, slot_idx_start;
Word16 md_idx;
Word32 *p_tc_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
- Word32 Pcm_tmp_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k] = { 0 };
+ Word32 Pcm_tmp_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k];
Word16 numch_out_dirac;
Word32 mixer_mat_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS];
Word16 b_skip_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
@@ -2836,34 +3046,45 @@ void ivas_spar_dec_upmixer_sf_fx(
SPAR_DEC_HANDLE hSpar;
Word16 num_md_sub_frames;
Word16 q1 = 30;
+ move16();
push_wmops( "ivas_spar_dec_upmixer_sf" );
hSpar = st_ivas->hSpar;
hDecoderConfig = st_ivas->hDecoderConfig;
nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
+ move16();
num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands;
+ move16();
numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans;
+ move16();
numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans;
+ move16();
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate );
slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );
+ move16();
slot_idx_start = hSpar->slots_rendered;
+ move16();
- IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
Word16 nchan_ism;
nchan_ism = st_ivas->nchan_ism;
+ move16();
FOR( i = 0; i < nchan_internal; i++ )
{
- p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[i + nchan_ism] + slot_idx_start * slot_size;
+ p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[add( i, nchan_ism )] + i_mult( slot_idx_start, slot_size );
}
- IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
+ test();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
{
FOR( i = 0; i < nchan_ism; i++ )
{
- p_tc_fx[i + nchan_internal] = st_ivas->hTcBuffer->tc_fx[i] + slot_idx_start * slot_size;
+ p_tc_fx[add( i, nchan_internal )] = st_ivas->hTcBuffer->tc_fx[i] + i_mult( slot_idx_start, slot_size );
}
}
}
@@ -2871,7 +3092,7 @@ void ivas_spar_dec_upmixer_sf_fx(
{
FOR( i = 0; i < nchan_internal; i++ )
{
- p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[i] + slot_idx_start * slot_size;
+ p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[i] + i_mult( slot_idx_start, slot_size );
}
}
@@ -2883,10 +3104,12 @@ void ivas_spar_dec_upmixer_sf_fx(
IF( hSpar->hMdDec->td_decorr_flag )
{
num_in_ingest = nchan_internal;
+ move16();
}
ELSE
{
num_in_ingest = nchan_transport;
+ move16();
}
/*---------------------------------------------------------------------*
@@ -2894,22 +3117,26 @@ void ivas_spar_dec_upmixer_sf_fx(
*---------------------------------------------------------------------*/
hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest;
+ move16();
/*---------------------------------------------------------------------*
* Prepare CLDFB buffers
*---------------------------------------------------------------------*/
+#ifdef MSAN_FIX
+ set_zero_fx( &Pcm_tmp_fx[0][0], ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ) * L_FRAME48k );
+#endif // MSAN_FIX
/* set-up pointers */
- IF( NE_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
+ IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
{
/* at this point, output channels are used as intermediate procesing buffers */
FOR( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; in_ch++ )
{
FOR( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ )
{
- cldfb_in_ts_re_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][ts * num_cldfb_bands];
- cldfb_in_ts_im_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][ts * num_cldfb_bands + 4 * num_cldfb_bands];
+ cldfb_in_ts_re_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][i_mult( ts, num_cldfb_bands )];
+ cldfb_in_ts_im_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][add( i_mult( ts, num_cldfb_bands ), ( 4 * num_cldfb_bands ) )];
}
}
}
@@ -2919,8 +3146,8 @@ void ivas_spar_dec_upmixer_sf_fx(
{
FOR( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ )
{
- cldfb_in_ts_re_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][ts * num_cldfb_bands];
- cldfb_in_ts_im_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][ts * num_cldfb_bands + 4 * num_cldfb_bands];
+ cldfb_in_ts_re_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][i_mult( ts, num_cldfb_bands )];
+ cldfb_in_ts_im_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][add( i_mult( ts, num_cldfb_bands ), ( 4 * num_cldfb_bands ) )];
}
}
}
@@ -2930,12 +3157,14 @@ void ivas_spar_dec_upmixer_sf_fx(
*---------------------------------------------------------------------*/
num_spar_bands = hSpar->hFbMixer->pFb->filterbank_num_bands;
+ move16();
/* apply parameters */
/* determine if we can skip certain data */
ivas_spar_get_skip_mat_fx( hSpar, numch_out, numch_in, num_spar_bands, b_skip_mat, num_md_sub_frames ); /* this can be precomputed based on bitrate and format*/
numch_out_dirac = hDecoderConfig->nchan_out;
+ move16();
/* CLDFB analysis of incoming frame */
@@ -2944,35 +3173,45 @@ void ivas_spar_dec_upmixer_sf_fx(
FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ )
{
Word16 q_cldfb = 11;
- cldfbAnalysis_ts_fx_fixed_q( &p_tc_fx[in_ch][ts * num_cldfb_bands], cldfb_in_ts_re_fx[in_ch][ts], cldfb_in_ts_im_fx[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch], &q_cldfb );
+ move16();
+ cldfbAnalysis_ts_fx_fixed_q( &p_tc_fx[in_ch][i_mult( ts, num_cldfb_bands )], cldfb_in_ts_re_fx[in_ch][ts], cldfb_in_ts_im_fx[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch], &q_cldfb );
}
}
- IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
+ test();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
{
- FOR( ; in_ch < st_ivas->nchan_ism + numch_in; in_ch++ )
+ FOR( ; in_ch < add( st_ivas->nchan_ism, numch_in ); in_ch++ )
{
FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ )
{
Word16 q_cldfb = 11;
- cldfbAnalysis_ts_fx_fixed_q( &p_tc_fx[in_ch][ts * num_cldfb_bands], cldfb_in_ts_re_fx[in_ch][ts], cldfb_in_ts_im_fx[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch], &q_cldfb );
+ move16();
+ cldfbAnalysis_ts_fx_fixed_q( &p_tc_fx[in_ch][i_mult( ts, num_cldfb_bands )], cldfb_in_ts_re_fx[in_ch][ts], cldfb_in_ts_im_fx[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch], &q_cldfb );
}
}
}
- IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) )
+ test();
+ test();
+ IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) )
{
Word16 q_cldfb = 6;
+ move16();
ivas_spar_calc_smooth_facs_fx( cldfb_in_ts_re_fx[0], cldfb_in_ts_im_fx[0], q_cldfb, num_spar_bands, hSpar->subframe_nbslots[hSpar->subframes_rendered],
hSpar->subframes_rendered == 0, &hSpar->hFbMixer->pFb->fb_bin_to_band, hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_buf_fx );
}
FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ )
{
- md_idx = hSpar->render_to_md_map[ts + slot_idx_start];
+ md_idx = hSpar->render_to_md_map[add( ts, slot_idx_start )];
+ move16();
floatToFixed_arr( hSpar->hFbMixer->cldfb_cross_fade, hSpar->hFbMixer->cldfb_cross_fade_fx, Q15, CLDFB_NO_COL_MAX );
ivas_spar_get_parameters_fx( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat_fx );
- IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) )
+ test();
+ test();
+ IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) )
{
FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
{
@@ -2980,8 +3219,10 @@ void ivas_spar_dec_upmixer_sf_fx(
{
FOR( in_ch = 0; in_ch < numch_in; in_ch++ )
{
- mixer_mat_fx[out_ch][in_ch][spar_band] = L_add( Mult_32_16( mixer_mat_fx[out_ch][in_ch][spar_band], sub( 32767, hSpar->hMdDec->smooth_fac_fx[spar_band] ) ), Mult_32_16( hSpar->hMdDec->mixer_mat_prev2_fx[out_ch][in_ch][spar_band], hSpar->hMdDec->smooth_fac_fx[spar_band] ) ); /*q1*/
+ mixer_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( mixer_mat_fx[out_ch][in_ch][spar_band], sub( 32767, hSpar->hMdDec->smooth_fac_fx[spar_band] ) ), hSpar->hMdDec->mixer_mat_prev2_fx[out_ch][in_ch][spar_band], hSpar->hMdDec->smooth_fac_fx[spar_band] ); /*q1*/
+ move32();
hSpar->hMdDec->mixer_mat_prev2_fx[out_ch][in_ch][spar_band] = mixer_mat_fx[out_ch][in_ch][spar_band];
+ move32();
}
}
}
@@ -2997,29 +3238,36 @@ void ivas_spar_dec_upmixer_sf_fx(
FOR( out_ch = 0; out_ch < numch_out; out_ch++ )
{
out_re_fx[out_ch] = 0;
+ move32();
out_im_fx[out_ch] = 0;
+ move32();
FOR( in_ch = 0; in_ch < numch_in; in_ch++ )
{
- IF( EQ_16( b_skip_mat[out_ch][in_ch], 0 ) )
+ IF( b_skip_mat[out_ch][in_ch] == 0 )
{
IF( LT_16( cldfb_band, CLDFB_PAR_WEIGHT_START_BAND ) ) /* tuning parameter, depends on how much SPAR Filters overlap for the CLDFB bands */
{
spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band];
+ move16();
cldfb_par_fx = mixer_mat_fx[out_ch][in_ch][spar_band];
+ move32();
}
ELSE
{
cldfb_par_fx = 0;
+ move32();
FOR( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ )
{
/* accumulate contributions from all SPAR bands */
Word16 tmp = extract_l( L_shr( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 7 ) );
- cldfb_par_fx = L_add_sat( cldfb_par_fx, Mult_32_16( mixer_mat_fx[out_ch][in_ch][spar_band], tmp ) ); /*q1*/
+ cldfb_par_fx = L_add_sat( cldfb_par_fx, Mpy_32_16_1( mixer_mat_fx[out_ch][in_ch][spar_band], tmp ) ); /*q1*/
}
}
- out_re_fx[out_ch] = L_add( out_re_fx[out_ch], Mult_32_32( cldfb_in_ts_re_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); /*q1-25*/
- out_im_fx[out_ch] = L_add( out_im_fx[out_ch], Mult_32_32( cldfb_in_ts_im_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); /*q1-25*/
+ out_re_fx[out_ch] = Madd_32_32( out_re_fx[out_ch], cldfb_in_ts_re_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); /*q1-25*/
+ move32();
+ out_im_fx[out_ch] = Madd_32_32( out_im_fx[out_ch], cldfb_in_ts_im_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); /*q1-25*/
+ move32();
}
}
}
@@ -3027,16 +3275,25 @@ void ivas_spar_dec_upmixer_sf_fx(
/*update CLDFB data with the parameter-modified data*/
FOR( out_ch = 0; out_ch < numch_out; out_ch++ )
{
- cldfb_in_ts_re_fx[out_ch][ts][cldfb_band] = L_shl( out_re_fx[out_ch], 31 - q1 ); /*Q=6*/
- cldfb_in_ts_im_fx[out_ch][ts][cldfb_band] = L_shl( out_im_fx[out_ch], 31 - q1 ); /*Q=6*/
+ cldfb_in_ts_re_fx[out_ch][ts][cldfb_band] = L_shl( out_re_fx[out_ch], sub( 31, q1 ) ); /*Q=6*/
+ move32();
+ cldfb_in_ts_im_fx[out_ch][ts][cldfb_band] = L_shl( out_im_fx[out_ch], sub( 31, q1 ) ); /*Q=6*/
+ move32();
}
}
- IF( ( EQ_16( ( add( add( slot_idx_start, ts ), 1 ) ), hSpar->num_slots ) ) || ( NE_16( ( md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME ), ( hSpar->render_to_md_map[ts + slot_idx_start + 1] / JBM_CLDFB_SLOTS_IN_SUBFRAME ) ) ) )
+
+ test();
+ IF( ( EQ_16( ( add( add( slot_idx_start, ts ), 1 ) ), hSpar->num_slots ) ) || ( NE_16( ( shr( md_idx, 2 ) /* md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME */ ), ( hSpar->render_to_md_map[add( add( slot_idx_start, ts ), 1 )] / JBM_CLDFB_SLOTS_IN_SUBFRAME /*It's value is 4*/ ) ) ) )
{
/* we have crossed an unadapted parameter sf border, update previous mixing matrices */
- Word16 md_sf = md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME;
+ Word16 md_sf = shr( md_idx, 2 ) /* md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME */;
split_band = SPAR_DIRAC_SPLIT_START_BAND;
- md_sf = ( num_md_sub_frames == MAX_PARAM_SPATIAL_SUBFRAMES ) ? md_sf : 0;
+ move16();
+ if ( NE_16( num_md_sub_frames, MAX_PARAM_SPATIAL_SUBFRAMES ) )
+ {
+ md_sf = 0;
+ move16();
+ }
IF( LT_16( split_band, IVAS_MAX_NUM_BANDS ) )
{
Copy32( hSpar->hMdDec->mixer_mat_prev_fx[1][0][0], hSpar->hMdDec->mixer_mat_prev_fx[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS );
@@ -3050,17 +3307,22 @@ void ivas_spar_dec_upmixer_sf_fx(
{
FOR( b = 0; b < num_spar_bands; b++ )
{
- hSpar->hMdDec->mixer_mat_prev_fx[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][b + md_sf * IVAS_MAX_NUM_BANDS];
+ hSpar->hMdDec->mixer_mat_prev_fx[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][add( b, i_mult( md_sf, IVAS_MAX_NUM_BANDS ) )];
+ move32();
}
}
}
- hSpar->i_subframe++;
+ hSpar->i_subframe = add( hSpar->i_subframe, 1 );
+ move16();
hSpar->i_subframe = s_min( hSpar->i_subframe, MAX_PARAM_SPATIAL_SUBFRAMES );
+ move16();
}
}
}
- IF( NE_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) )
+ test();
+ test();
+ IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) )
{
ivas_dirac_dec_render_sf_fx( st_ivas, output_fx, nchan_internal, cldfb_in_ts_re_fx, cldfb_in_ts_im_fx );
}
@@ -3069,38 +3331,49 @@ void ivas_spar_dec_upmixer_sf_fx(
{
Word16 outchannels, idx_in, idx_lfe, ch;
idx_in = 0;
+ move16();
idx_lfe = 0;
+ move16();
outchannels = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe );
FOR( ch = 0; ch < outchannels; ch++ )
{
- IF( ( GT_16( st_ivas->hOutSetup.num_lfe, 0 ) ) && ( EQ_16( st_ivas->hOutSetup.index_lfe[idx_lfe], ch ) ) )
+ test();
+ IF( ( st_ivas->hOutSetup.num_lfe > 0 ) && ( EQ_16( st_ivas->hOutSetup.index_lfe[idx_lfe], ch ) ) )
{
- set_zero_fx( output_fx[ch], hSpar->subframe_nbslots[hSpar->subframes_rendered] * num_cldfb_bands );
- IF( LT_16( idx_lfe, ( sub( st_ivas->hDirACRend->hOutSetup.num_lfe, 1 ) ) ) )
+ set_zero_fx( output_fx[ch], i_mult( hSpar->subframe_nbslots[hSpar->subframes_rendered], num_cldfb_bands ) );
+ if ( LT_16( idx_lfe, ( sub( st_ivas->hDirACRend->hOutSetup.num_lfe, 1 ) ) ) )
{
- idx_lfe++;
+ idx_lfe = add( idx_lfe, 1 );
}
}
ELSE
{
- IF( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || !( EQ_16( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) &&
- !( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || !( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) &&
+ !( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) )
{
Scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, -6 );
st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = sub( st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, 6 );
+ move16();
Scale_sig32( output_fx[ch], out_len, -6 );
FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ )
{
- cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][ts * num_cldfb_bands], num_cldfb_bands, st_ivas->cldfbSynDec[idx_in] );
+ cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, st_ivas->cldfbSynDec[idx_in] );
}
Scale_sig32( output_fx[ch], out_len, 6 );
Scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, 6 );
st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = add( st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, 6 );
+ move16();
}
- idx_in++;
+ idx_in = add( idx_in, 1 );
}
}
}
@@ -3111,26 +3384,29 @@ void ivas_spar_dec_upmixer_sf_fx(
{
Scale_sig32( st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx, st_ivas->cldfbSynDec[out_ch]->p_filter_length, -6 );
st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state = sub( st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state, 6 );
+ move16();
Scale_sig32( output_fx[out_ch], out_len, -6 );
FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ )
{
- cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][ts * num_cldfb_bands], num_cldfb_bands, st_ivas->cldfbSynDec[out_ch] );
+ cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, st_ivas->cldfbSynDec[out_ch] );
}
Scale_sig32( output_fx[out_ch], out_len, 6 );
Scale_sig32( st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx, st_ivas->cldfbSynDec[out_ch]->p_filter_length, 6 );
st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state = add( st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state, 6 );
+ move16();
}
}
hSpar->slots_rendered = add( hSpar->slots_rendered, hSpar->subframe_nbslots[hSpar->subframes_rendered] );
- hSpar->subframes_rendered++;
+ move16();
+ hSpar->subframes_rendered = add( hSpar->subframes_rendered, 1 );
+ move16();
pop_wmops();
return;
}
#else
-
void ivas_spar_dec_upmixer_sf(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
float *output[], /* o : output audio channels */
diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c
index 44a771249cb699d3131618f7ff47998a285817d1..bf72059f0588df7492ce4c3ca519334c7a89acd6 100644
--- a/lib_dec/ivas_spar_md_dec.c
+++ b/lib_dec/ivas_spar_md_dec.c
@@ -34,18 +34,19 @@
#include "options.h"
#include "math.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include
#include "wmc_auto.h"
#include "ivas_stat_dec.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif // IVAS_FLOAT_FIXED
#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
+#ifdef IVAS_FLOAT_FIXED
/*------------------------------------------------------------------------------------------*
* Local constants
@@ -55,7 +56,7 @@
/* PLC constants */
static const int16_t ivas_spar_dec_plc_num_frames_keep = 9;
-static const int16_t ivas_spar_dec_plc_num_frames_fade_out = 9;
+// static const int16_t ivas_spar_dec_plc_num_frames_fade_out = 9;
static const int16_t ivas_spar_dec_plc_per_frame_ramp_down_gain_dB = 3;
static const int16_t ivas_spar_dec_plc_max_num_frames_ramp_down = 33;
static const int16_t ivas_spar_dec_plc_spatial_target[IVAS_SPAR_MAX_CH] = { 1, 0, 0, 0, 0, 0, 0, 0 };
@@ -66,7 +67,7 @@ static const int16_t ivas_spar_dec_plc_spatial_target[IVAS_SPAR_MAX_CH] = { 1, 0
*------------------------------------------------------------------------------------------*/
#ifdef IVAS_FLOAT_FIXED
-static void ivas_get_spar_matrices_fx( ivas_spar_md_dec_state_t *hMdDec, const int16_t num_bands_out, const int16_t n_ts, const int16_t bw, const int16_t dtx_vad, const int16_t nB, const int16_t numch_out, const int16_t active_w_vlbr, const int16_t dyn_active_w_flag );
+static void ivas_get_spar_matrices_fx( ivas_spar_md_dec_state_t *hMdDec, const Word16 num_bands_out, const Word16 n_ts, const Word16 bw, const Word16 dtx_vad, const Word16 nB, const Word16 numch_out, const Word16 active_w_vlbr, const Word16 dyn_active_w_flag );
#else
static void ivas_get_spar_matrices( ivas_spar_md_dec_state_t *hMdDec, const int16_t num_bands_out, const int16_t n_ts, const int16_t bw, const int16_t dtx_vad, const int16_t nB, const int16_t numch_out, const int16_t active_w_vlbr, const int16_t dyn_active_w_flag );
#endif
@@ -80,7 +81,7 @@ static void ivas_fill_band_coeffs_idx( ivas_band_coeffs_ind_t *pBands_idx, const
#ifndef IVAS_FLOAT_FIXED
static void ivas_mat_col_rearrange( float in_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t order[IVAS_SPAR_MAX_CH], const int16_t i_ts, float ***mixer_mat, const int16_t bands, const int16_t num_ch );
#else
-static void ivas_mat_col_rearrange_fx( Word32 in_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t order[IVAS_SPAR_MAX_CH], const int16_t i_ts, Word32 ***mixer_mat, const int16_t bands, const int16_t num_ch );
+static void ivas_mat_col_rearrange_fx( Word32 in_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const Word16 order[IVAS_SPAR_MAX_CH], const Word16 i_ts, Word32 ***mixer_mat, const Word16 bands, const Word16 num_ch );
#endif
#ifndef IVAS_FLOAT_FIXED
@@ -98,24 +99,33 @@ static void ivas_spar_md_fill_invalid_bands_fx( ivas_spar_dec_matrices_t *pSpar_
static void ivas_spar_md_fill_invalid_bands( ivas_spar_dec_matrices_t *pSpar_coeffs, ivas_spar_dec_matrices_t *pSpar_coeffs_prev, const int16_t *valid_bands, int16_t *base_band_age, const int16_t num_bands, const int16_t numch_out, const int16_t num_md_sub_frames );
#endif
+#ifdef IVAS_FLOAT_FIXED
+static void ivas_spar_md_fill_invalid_bandcoeffs( ivas_band_coeffs_t *pBand_coeffs, ivas_band_coeffs_t *pBand_coeffs_prev, const Word16 *valid_bands, Word16 *base_band_age, Word16 *first_valid_frame, const Word16 num_bands );
+#else
static void ivas_spar_md_fill_invalid_bandcoeffs( ivas_band_coeffs_t *pBand_coeffs, ivas_band_coeffs_t *pBand_coeffs_prev, const int16_t *valid_bands, int16_t *base_band_age, int16_t *first_valid_frame, const int16_t num_bands );
+#endif
+
#ifdef IVAS_FLOAT_FIXED
-static ivas_error ivas_spar_set_dec_config( ivas_spar_md_dec_state_t *hMdDec, const int16_t nchan_transport, Word32 *pFC );
+static ivas_error ivas_spar_set_dec_config( ivas_spar_md_dec_state_t *hMdDec, const Word16 nchan_transport, Word32 *pFC );
#else
static ivas_error ivas_spar_set_dec_config( ivas_spar_md_dec_state_t *hMdDec, const int16_t nchan_transport, float *pFC );
#endif
+#ifdef IVAS_FLOAT_FIXED
+static void ivas_parse_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, Decoder_State *st, const Word16 bw, const Word16 num_bands, Word16 *num_dmx_per_band, Word16 *num_dec_per_band );
+#else
static void ivas_parse_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, Decoder_State *st, const int16_t bw, const int16_t num_bands, int16_t *num_dmx_per_band, int16_t *num_dec_per_band );
+#endif
#ifndef IVAS_FLOAT_FIXED
static ivas_error ivas_deindex_real_index( const int16_t *index, const int16_t q_levels, const float min_value, const float max_value, float *quant, const int16_t num_ch_dim2 );
#endif
#ifdef IVAS_FLOAT_FIXED
-static ivas_error ivas_deindex_real_index_fx( const int16_t *index, const int16_t q_levels, const Word32 min_value, const Word32 max_value, Word32 *quant, const int16_t num_ch_dim2 );
+static ivas_error ivas_deindex_real_index_fx( const Word16 *index, const Word16 q_levels, const Word32 min_value, const Word32 max_value, Word32 *quant, const Word16 num_ch_dim2 );
#endif
#ifdef IVAS_FLOAT_FIXED
-static void ivas_spar_dec_parse_md_bs_fx( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, int16_t *nB, int16_t *bands_bw, int16_t *dtx_vad, const int32_t ivas_total_brate, const int16_t sba_inactive_mode );
+static void ivas_spar_dec_parse_md_bs_fx( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, Word16 *nB, Word16 *bands_bw, Word16 *dtx_vad, const Word32 ivas_total_brate, const Word16 sba_inactive_mode );
#else
static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, int16_t *nB, int16_t *bands_bw, int16_t *dtx_vad, const int32_t ivas_total_brate, const int16_t sba_inactive_mode );
#endif
@@ -296,90 +306,90 @@ ivas_error ivas_spar_md_dec_matrix_open(
#else
ivas_error ivas_spar_md_dec_matrix_open_fx(
ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
- const int16_t num_channels, /* i : number of internal channels */
- const int16_t num_md_sub_frames /* i : number of MD subframes */
+ const Word16 num_channels, /* i : number of internal channels */
+ const Word16 num_md_sub_frames /* i : number of MD subframes */
)
{
- int16_t i, j;
- int16_t k;
- if ( ( hMdDec->spar_md.band_coeffs = (ivas_band_coeffs_t *) malloc( IVAS_MAX_NUM_BANDS * num_md_sub_frames * sizeof( ivas_band_coeffs_t ) ) ) == NULL )
+ Word16 i, j;
+ Word16 k;
+ IF( ( hMdDec->spar_md.band_coeffs = (ivas_band_coeffs_t *) malloc( i_mult( i_mult( IVAS_MAX_NUM_BANDS, num_md_sub_frames ), sizeof( ivas_band_coeffs_t ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for band_coeffs in SPAR MD" );
}
- if ( ( hMdDec->band_coeffs_prev = (ivas_band_coeffs_t *) malloc( IVAS_MAX_NUM_BANDS * sizeof( ivas_band_coeffs_t ) ) ) == NULL )
+ IF( ( hMdDec->band_coeffs_prev = (ivas_band_coeffs_t *) malloc( IVAS_MAX_NUM_BANDS * sizeof( ivas_band_coeffs_t ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for band_coeffs in SPAR MD" );
}
- if ( ( hMdDec->mixer_mat_fx = (Word32 ***) malloc( num_channels * sizeof( Word32 ** ) ) ) == NULL )
+ IF( ( hMdDec->mixer_mat_fx = (Word32 ***) malloc( i_mult( num_channels, sizeof( Word32 ** ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- if ( ( hMdDec->mixer_mat_fx[i] = (Word32 **) malloc( num_channels * sizeof( Word32 * ) ) ) == NULL )
+ IF( ( hMdDec->mixer_mat_fx[i] = (Word32 **) malloc( i_mult( num_channels, sizeof( Word32 * ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
- if ( ( hMdDec->mixer_mat_fx[i][j] = (Word32 *) malloc( num_md_sub_frames * IVAS_MAX_NUM_BANDS * sizeof( Word32 ) ) ) == NULL )
+ IF( ( hMdDec->mixer_mat_fx[i][j] = (Word32 *) malloc( i_mult( i_mult( num_md_sub_frames, IVAS_MAX_NUM_BANDS ), sizeof( Word32 ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
}
}
- if ( ( hMdDec->spar_coeffs.C_re_fx = (Word32 ***) malloc( num_channels * sizeof( Word32 ** ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs.C_re_fx = (Word32 ***) malloc( i_mult( num_channels, sizeof( Word32 ** ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- if ( ( hMdDec->spar_coeffs.C_re_fx[i] = (Word32 **) malloc( num_channels * sizeof( Word32 * ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs.C_re_fx[i] = (Word32 **) malloc( i_mult( num_channels, sizeof( Word32 * ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
- if ( ( hMdDec->spar_coeffs.C_re_fx[i][j] = (Word32 *) malloc( num_md_sub_frames * IVAS_MAX_NUM_BANDS * sizeof( Word32 ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs.C_re_fx[i][j] = (Word32 *) malloc( i_mult( i_mult( num_md_sub_frames, IVAS_MAX_NUM_BANDS ), sizeof( Word32 ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
}
}
- if ( ( hMdDec->spar_coeffs.P_re_fx = (Word32 ***) malloc( num_channels * sizeof( Word32 ** ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs.P_re_fx = (Word32 ***) malloc( i_mult( num_channels, sizeof( Word32 ** ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- if ( ( hMdDec->spar_coeffs.P_re_fx[i] = (Word32 **) malloc( num_channels * sizeof( Word32 * ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs.P_re_fx[i] = (Word32 **) malloc( i_mult( num_channels, sizeof( Word32 * ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
- if ( ( hMdDec->spar_coeffs.P_re_fx[i][j] = (Word32 *) malloc( num_md_sub_frames * IVAS_MAX_NUM_BANDS * sizeof( Word32 ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs.P_re_fx[i][j] = (Word32 *) malloc( i_mult( num_md_sub_frames, IVAS_MAX_NUM_BANDS * sizeof( Word32 ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
}
}
- if ( ( hMdDec->spar_coeffs_prev.C_re_fx = (Word32 ***) malloc( num_channels * sizeof( Word32 ** ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs_prev.C_re_fx = (Word32 ***) malloc( i_mult( num_channels, sizeof( Word32 ** ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- if ( ( hMdDec->spar_coeffs_prev.C_re_fx[i] = (Word32 **) malloc( num_channels * sizeof( Word32 * ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs_prev.C_re_fx[i] = (Word32 **) malloc( i_mult( num_channels, sizeof( Word32 * ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
- if ( ( hMdDec->spar_coeffs_prev.C_re_fx[i][j] = (Word32 *) malloc( IVAS_MAX_NUM_BANDS * sizeof( Word32 ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs_prev.C_re_fx[i][j] = (Word32 *) malloc( IVAS_MAX_NUM_BANDS * sizeof( Word32 ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
@@ -387,73 +397,77 @@ ivas_error ivas_spar_md_dec_matrix_open_fx(
}
// Fix Memory
- if ( ( hMdDec->spar_coeffs_prev.P_re_fx = (Word32 ***) malloc( num_channels * sizeof( Word32 ** ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs_prev.P_re_fx = (Word32 ***) malloc( i_mult( num_channels, sizeof( Word32 ** ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- if ( ( hMdDec->spar_coeffs_prev.P_re_fx[i] = (Word32 **) malloc( num_channels * sizeof( Word32 * ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs_prev.P_re_fx[i] = (Word32 **) malloc( i_mult( num_channels, sizeof( Word32 * ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
- if ( ( hMdDec->spar_coeffs_prev.P_re_fx[i][j] = (Word32 *) malloc( IVAS_MAX_NUM_BANDS * sizeof( Word32 ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs_prev.P_re_fx[i][j] = (Word32 *) malloc( IVAS_MAX_NUM_BANDS * sizeof( Word32 ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
}
}
// Fix Memory
- if ( ( hMdDec->spar_coeffs_tar.C_re_fx = (Word32 ***) malloc( num_channels * sizeof( Word32 ** ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs_tar.C_re_fx = (Word32 ***) malloc( i_mult( num_channels, sizeof( Word32 ** ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- if ( ( hMdDec->spar_coeffs_tar.C_re_fx[i] = (Word32 **) malloc( num_channels * sizeof( Word32 * ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs_tar.C_re_fx[i] = (Word32 **) malloc( i_mult( num_channels, sizeof( Word32 * ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
- if ( ( hMdDec->spar_coeffs_tar.C_re_fx[i][j] = (Word32 *) malloc( IVAS_MAX_NUM_BANDS * sizeof( Word32 ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs_tar.C_re_fx[i][j] = (Word32 *) malloc( IVAS_MAX_NUM_BANDS * sizeof( Word32 ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
}
}
// Fix Memory
- if ( ( hMdDec->spar_coeffs_tar.P_re_fx = (Word32 ***) malloc( num_channels * sizeof( Word32 ** ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs_tar.P_re_fx = (Word32 ***) malloc( i_mult( num_channels, sizeof( Word32 ** ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- if ( ( hMdDec->spar_coeffs_tar.P_re_fx[i] = (Word32 **) malloc( num_channels * sizeof( Word32 * ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs_tar.P_re_fx[i] = (Word32 **) malloc( i_mult( num_channels, sizeof( Word32 * ) ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
- if ( ( hMdDec->spar_coeffs_tar.P_re_fx[i][j] = (Word32 *) malloc( IVAS_MAX_NUM_BANDS * sizeof( Word32 ) ) ) == NULL )
+ IF( ( hMdDec->spar_coeffs_tar.P_re_fx[i][j] = (Word32 *) malloc( IVAS_MAX_NUM_BANDS * sizeof( Word32 ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD matrix" );
}
}
}
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
- for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ )
+ FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ )
{
hMdDec->spar_coeffs_prev.C_re_fx[i][j][k] = 0;
+ move32();
hMdDec->spar_coeffs_prev.P_re_fx[i][j][k] = 0;
+ move32();
hMdDec->spar_coeffs_tar.C_re_fx[i][j][k] = 0;
+ move32();
hMdDec->spar_coeffs_tar.P_re_fx[i][j][k] = 0;
+ move32();
}
}
}
@@ -482,7 +496,7 @@ Word16 ivas_get_spar_dec_md_num_subframes(
move16();
IF( GT_16( sba_order, SBA_FOA_ORDER ) )
{
- IF( GE_32( ivas_total_brate, IVAS_512k ) )
+ if ( GE_32( ivas_total_brate, IVAS_512k ) )
{
num_subframes = 1;
move16();
@@ -492,7 +506,7 @@ Word16 ivas_get_spar_dec_md_num_subframes(
test();
test();
test();
- IF( ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && LT_32( ivas_last_active_brate, IVAS_24k4 ) ) || ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && LT_32( ivas_total_brate, IVAS_24k4 ) ) )
+ if ( ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && LT_32( ivas_last_active_brate, IVAS_24k4 ) ) || ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && LT_32( ivas_total_brate, IVAS_24k4 ) ) )
{
num_subframes = 1;
move16();
@@ -538,51 +552,51 @@ int16_t ivas_get_spar_dec_md_num_subframes(
ivas_error ivas_spar_md_dec_open(
ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */
const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
- const int16_t num_channels, /* i : number of internal channels */
- const int16_t sba_order, /* i : SBA order */
- const int16_t sid_format, /* i : SID format */
- const int32_t last_active_ivas_total_brate /* i : IVAS last active bitrate */
+ const Word16 num_channels, /* i : number of internal channels */
+ const Word16 sba_order, /* i : SBA order */
+ const Word16 sid_format, /* i : SID format */
+ const Word32 last_active_ivas_total_brate /* i : IVAS last active bitrate */
)
{
ivas_spar_md_dec_state_t *hMdDec;
ivas_error error;
- int16_t num_md_sub_frames;
+ Word16 num_md_sub_frames;
error = IVAS_ERR_OK;
+ move32();
- if ( ( hMdDec = (ivas_spar_md_dec_state_t *) malloc( sizeof( ivas_spar_md_dec_state_t ) ) ) == NULL )
+ IF( ( hMdDec = (ivas_spar_md_dec_state_t *) malloc( sizeof( ivas_spar_md_dec_state_t ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD decoder" );
}
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate, last_active_ivas_total_brate );
-#ifndef IVAS_FLOAT_FIXED
- if ( ( error = ivas_spar_md_dec_matrix_open( hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK )
-#else
- if ( ( error = ivas_spar_md_dec_matrix_open_fx( hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK )
-#endif
+ IF( NE_32( ( error = ivas_spar_md_dec_matrix_open_fx( hMdDec, num_channels, num_md_sub_frames ) ), IVAS_ERR_OK ) )
{
return error;
}
- if ( hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 )
+ IF( EQ_32( hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) )
{
- if ( sid_format == SID_SBA_2TC )
+ IF( EQ_16( sid_format, SID_SBA_2TC ) )
{
hMdDec->table_idx = ivas_get_spar_table_idx( IVAS_48k, sba_order, SPAR_CONFIG_BW, NULL, NULL );
+ move16();
}
- else
+ ELSE
{
hMdDec->table_idx = ivas_get_spar_table_idx( IVAS_24k4, sba_order, SPAR_CONFIG_BW, NULL, NULL );
+ move16();
}
}
- else
+ ELSE
{
hMdDec->table_idx = ivas_get_spar_table_idx( hDecoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL );
+ move16();
}
- if ( ( error = ivas_spar_md_dec_init( hMdDec, hDecoderConfig, num_channels, sba_order ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = ivas_spar_md_dec_init( hMdDec, hDecoderConfig, num_channels, sba_order ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -715,27 +729,27 @@ void ivas_spar_md_dec_matrix_close(
#else
void ivas_spar_md_dec_matrix_close_fx(
ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */
- const int16_t num_channels /* i : number of internal channels */
+ const Word16 num_channels /* i : number of internal channels */
)
{
- int16_t i, j;
+ Word16 i, j;
- if ( hMdDecoder->spar_md.band_coeffs != NULL )
+ IF( hMdDecoder->spar_md.band_coeffs != NULL )
{
free( hMdDecoder->spar_md.band_coeffs );
hMdDecoder->spar_md.band_coeffs = NULL;
}
- if ( hMdDecoder->band_coeffs_prev != NULL )
+ IF( hMdDecoder->band_coeffs_prev != NULL )
{
free( hMdDecoder->band_coeffs_prev );
hMdDecoder->band_coeffs_prev = NULL;
}
- if ( hMdDecoder->mixer_mat_fx != NULL )
+ IF( hMdDecoder->mixer_mat_fx != NULL )
{
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
free( hMdDecoder->mixer_mat_fx[i][j] );
}
@@ -743,11 +757,11 @@ void ivas_spar_md_dec_matrix_close_fx(
}
free( hMdDecoder->mixer_mat_fx );
}
- if ( hMdDecoder->spar_coeffs.C_re_fx != NULL )
+ IF( hMdDecoder->spar_coeffs.C_re_fx != NULL )
{
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
free( hMdDecoder->spar_coeffs.C_re_fx[i][j] );
}
@@ -755,11 +769,11 @@ void ivas_spar_md_dec_matrix_close_fx(
}
free( hMdDecoder->spar_coeffs.C_re_fx );
}
- if ( hMdDecoder->spar_coeffs.P_re_fx != NULL )
+ IF( hMdDecoder->spar_coeffs.P_re_fx != NULL )
{
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
free( hMdDecoder->spar_coeffs.P_re_fx[i][j] );
}
@@ -768,11 +782,11 @@ void ivas_spar_md_dec_matrix_close_fx(
free( hMdDecoder->spar_coeffs.P_re_fx );
}
- if ( hMdDecoder->spar_coeffs_prev.C_re_fx != NULL )
+ IF( hMdDecoder->spar_coeffs_prev.C_re_fx != NULL )
{
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
free( hMdDecoder->spar_coeffs_prev.C_re_fx[i][j] );
}
@@ -781,11 +795,11 @@ void ivas_spar_md_dec_matrix_close_fx(
free( hMdDecoder->spar_coeffs_prev.C_re_fx );
}
- if ( hMdDecoder->spar_coeffs_prev.P_re_fx != NULL )
+ IF( hMdDecoder->spar_coeffs_prev.P_re_fx != NULL )
{
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
free( hMdDecoder->spar_coeffs_prev.P_re_fx[i][j] );
}
@@ -794,11 +808,11 @@ void ivas_spar_md_dec_matrix_close_fx(
free( hMdDecoder->spar_coeffs_prev.P_re_fx );
}
- if ( hMdDecoder->spar_coeffs_tar.C_re_fx != NULL )
+ IF( hMdDecoder->spar_coeffs_tar.C_re_fx != NULL )
{
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
free( hMdDecoder->spar_coeffs_tar.C_re_fx[i][j] );
}
@@ -806,11 +820,11 @@ void ivas_spar_md_dec_matrix_close_fx(
}
free( hMdDecoder->spar_coeffs_tar.C_re_fx );
}
- if ( hMdDecoder->spar_coeffs_tar.P_re_fx != NULL )
+ IF( hMdDecoder->spar_coeffs_tar.P_re_fx != NULL )
{
- for ( i = 0; i < num_channels; i++ )
+ FOR( i = 0; i < num_channels; i++ )
{
- for ( j = 0; j < num_channels; j++ )
+ FOR( j = 0; j < num_channels; j++ )
{
free( hMdDecoder->spar_coeffs_tar.P_re_fx[i][j] );
}
@@ -834,16 +848,13 @@ void ivas_spar_md_dec_close(
)
{
ivas_spar_md_dec_state_t *hMdDecoder;
- int16_t num_channels;
+ Word16 num_channels;
hMdDecoder = *hMdDec;
num_channels = hMdDecoder->spar_md_cfg.num_umx_chs;
+ move16();
-#ifndef IVAS_FLOAT_FIXED
- ivas_spar_md_dec_matrix_close( hMdDecoder, num_channels );
-#else
ivas_spar_md_dec_matrix_close_fx( hMdDecoder, num_channels );
-#endif
free( *hMdDec );
*hMdDec = NULL;
@@ -958,15 +969,12 @@ ivas_error ivas_spar_md_dec_init(
ivas_error ivas_spar_md_dec_init(
ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
- const int16_t num_channels, /* i : number of internal channels */
- const int16_t sba_order /* i : SBA order */
+ const Word16 num_channels, /* i : number of internal channels */
+ const Word16 sba_order /* i : SBA order */
)
{
- int16_t i, j;
- int16_t nchan_transport;
-#ifndef IVAS_FLOAT_FIXED
- Word32 pFC[IVAS_MAX_NUM_BANDS];
-#endif
+ Word16 i, j;
+ Word16 nchan_transport;
Word32 *pFC_fx = NULL, PR_minmax_fx[2];
ivas_error error;
@@ -974,20 +982,21 @@ ivas_error ivas_spar_md_dec_init(
ivas_sba_get_spar_hoa_ch_ind_fx( num_channels, hDecoderConfig->ivas_total_brate, hMdDec->HOA_md_ind );
- hMdDec->spar_md.num_bands = ( hMdDec->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
+ IF( hMdDec->spar_hoa_md_flag )
+ {
+ hMdDec->spar_md.num_bands = IVAS_MAX_NUM_BANDS;
+ move16();
+ }
+ ELSE
+ {
+ hMdDec->spar_md.num_bands = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
+ move16();
+ }
ivas_spar_set_bitrate_config_fx( &hMdDec->spar_md_cfg, hMdDec->table_idx, hMdDec->spar_md.num_bands, hMdDec->spar_hoa_dirac2spar_md_flag, 0, 0, 0 );
nchan_transport = hMdDec->spar_md_cfg.nchan_transport;
-
-
-#ifndef IVAS_FLOAT_FIXED
- /* get FB coefficients */
- FOR( i = 0; i < IVAS_MAX_NUM_BANDS; i++ )
- {
- pFC[i] = L_shr( Mpy_32_32( ivas_fb_fcs_12band_1ms_fx[i], hDecoderConfig->output_Fs ), 1 ); // Q0
- }
-#endif
+ move16();
IF( EQ_32( hDecoderConfig->output_Fs, 8000 ) )
{
@@ -1009,86 +1018,78 @@ ivas_error ivas_spar_md_dec_init(
{
pFC_fx = pFC_48k;
}
- else
+ ELSE
{
assert( 0 ); // update sample rate
}
-#ifdef IVAS_FLOAT_FIXED
- if ( ( error = ivas_spar_set_dec_config( hMdDec, nchan_transport, pFC_fx ) ) != IVAS_ERR_OK )
-#else
- if ( ( error = ivas_spar_set_dec_config( hMdDec, nchan_transport, pFC ) ) != IVAS_ERR_OK )
-#endif
+ IF( NE_32( ( error = ivas_spar_set_dec_config( hMdDec, nchan_transport, pFC_fx ) ), IVAS_ERR_OK ) )
{
return error;
}
- if ( nchan_transport != 2 && ( ( hMdDec->spar_md_cfg.remix_unmix_order == 2 ) || ( hMdDec->spar_md_cfg.remix_unmix_order == 1 ) ) )
+ test();
+ test();
+ IF( NE_16( nchan_transport, 2 ) && ( EQ_16( hMdDec->spar_md_cfg.remix_unmix_order, 2 ) || EQ_16( hMdDec->spar_md_cfg.remix_unmix_order, 1 ) ) )
{
return IVAS_ERR_INTERNAL;
}
/* DTX quant init */
PR_minmax_fx[0] = hMdDec->spar_md_cfg.quant_strat[0].PR.min_fx;
+ move32();
PR_minmax_fx[1] = hMdDec->spar_md_cfg.quant_strat[0].PR.max_fx;
+ move32();
ivas_spar_quant_dtx_init_fx( &hMdDec->spar_md, PR_minmax_fx );
ivas_spar_arith_coeffs_com_init_fx( &hMdDec->arith_coeffs, &hMdDec->spar_md_cfg, hMdDec->table_idx, DEC );
ivas_spar_huff_coeffs_com_init_fx( &hMdDec->huff_coeffs, &hMdDec->spar_md_cfg, hMdDec->table_idx, DEC );
hMdDec->spar_md_cfg.prev_quant_idx = -1;
+ move16();
/* initialize PLC state */
- set_s( hMdDec->valid_bands, 0, IVAS_MAX_NUM_BANDS );
- set_s( hMdDec->base_band_age, 0, IVAS_MAX_NUM_BANDS );
- set_s( hMdDec->base_band_coeffs_age, 0, IVAS_MAX_NUM_BANDS );
+ set16_fx( hMdDec->valid_bands, 0, IVAS_MAX_NUM_BANDS );
+ set16_fx( hMdDec->base_band_age, 0, IVAS_MAX_NUM_BANDS );
+ set16_fx( hMdDec->base_band_coeffs_age, 0, IVAS_MAX_NUM_BANDS );
hMdDec->spar_plc_num_lost_frames = 0;
+ move16();
hMdDec->spar_plc_enable_fadeout_flag = 1;
+ move16();
hMdDec->dtx_md_smoothing_cntr = 1;
+ move16();
-#ifndef IVAS_FLOAT_FIXED
- ivas_clear_band_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS );
- ivas_clear_band_coeffs( hMdDec->band_coeffs_prev, IVAS_MAX_NUM_BANDS );
-#else
ivas_clear_band_coeffs_fx( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS );
ivas_clear_band_coeffs_fx( hMdDec->band_coeffs_prev, IVAS_MAX_NUM_BANDS );
-#endif
+
ivas_clear_band_coeff_idx( hMdDec->spar_md.band_coeffs_idx, IVAS_MAX_NUM_BANDS );
ivas_clear_band_coeff_idx( hMdDec->spar_md_prev.band_coeffs_idx, IVAS_MAX_NUM_BANDS );
ivas_clear_band_coeff_idx( hMdDec->spar_md_prev.band_coeffs_idx_mapped, IVAS_MAX_NUM_BANDS );
hMdDec->spar_md.dtx_vad = 0;
+ move16();
hMdDec->td_decorr_flag = 1;
+ move16();
set32_fx( hMdDec->spar_md.en_ratio_slow_fx, 0, IVAS_MAX_NUM_BANDS );
set32_fx( hMdDec->spar_md.ref_pow_slow_fx, 0, IVAS_MAX_NUM_BANDS );
set16_fx( hMdDec->smooth_fac_fx, 0, IVAS_MAX_NUM_BANDS );
-#ifndef IVAS_FLOAT_FIXED
- set_f( hMdDec->spar_md.en_ratio_slow, 0.0f, IVAS_MAX_NUM_BANDS );
- set_f( hMdDec->spar_md.ref_pow_slow, 0.0f, IVAS_MAX_NUM_BANDS );
- set_zero( hMdDec->smooth_fac, IVAS_MAX_NUM_BANDS );
-#endif
- for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ )
+ FOR( i = 0; i < IVAS_MAX_NUM_BANDS; i++ )
{
set32_fx( hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 );
-#ifndef IVAS_FLOAT_FIXED
- set_zero( hMdDec->smooth_buf[i], 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 );
-#endif
}
- for ( i = 0; i < IVAS_SPAR_MAX_CH; i++ )
+ FOR( i = 0; i < IVAS_SPAR_MAX_CH; i++ )
{
- for ( j = 0; j < IVAS_SPAR_MAX_CH; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH; j++ )
{
set32_fx( hMdDec->mixer_mat_prev2_fx[i][j], 0, IVAS_MAX_NUM_BANDS );
-#ifndef IVAS_FLOAT_FIXED
- set_zero( hMdDec->mixer_mat_prev2[i][j], IVAS_MAX_NUM_BANDS );
-#endif
}
}
hMdDec->first_valid_frame = 1;
+ move16();
return IVAS_ERR_OK;
}
@@ -1104,53 +1105,64 @@ ivas_error ivas_spar_md_dec_init(
#ifdef IVAS_FLOAT_FIXED
static ivas_error ivas_spar_set_dec_config(
ivas_spar_md_dec_state_t *hMdDec,
- const int16_t nchan_transport,
+ const Word16 nchan_transport,
Word32 *pFC )
{
- int16_t i, j, nchan, dmx_ch;
+ Word16 i, j, nchan, dmx_ch;
- for ( i = 0; i < nchan_transport; i++ )
+ FOR( i = 0; i < nchan_transport; i++ )
{
hMdDec->spar_md_cfg.max_freq_per_chan[i] = ivas_spar_br_table_consts[hMdDec->table_idx].fpcs;
+ move16();
}
nchan = ivas_sba_get_nchan_metadata_fx( ivas_spar_br_table_consts[hMdDec->table_idx].sba_order, ivas_spar_br_table_consts[hMdDec->table_idx].ivas_total_brate );
- switch ( nchan )
+ SWITCH( nchan )
{
case 4: /* FOA_CHANNELS */
hMdDec->num_decorr = IVAS_TD_DECORR_OUT_3CH;
- break;
+ move16();
+ BREAK;
case 9: /* IVAS_HOA_2_CH */
hMdDec->num_decorr = IVAS_TD_DECORR_OUT_5CH;
- break;
+ move16();
+ BREAK;
case 6: /* IVAS_HOA_2_CH */
hMdDec->num_decorr = IVAS_TD_DECORR_OUT_2CH;
- break;
+ move16();
+ BREAK;
case 8: /* IVAS_HOA_3_CH */
hMdDec->num_decorr = IVAS_TD_DECORR_OUT_4CH;
- break;
+ move16();
+ BREAK;
}
hMdDec->spar_md_cfg.num_umx_chs = nchan;
+ move16();
dmx_ch = 0;
- for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ )
+ move16();
+ FOR( i = 0; i < IVAS_MAX_NUM_BANDS; i++ )
{
dmx_ch = 0;
- for ( j = 0; j < nchan_transport; j++ )
+ move16();
+ FOR( j = 0; j < nchan_transport; j++ )
{
- if ( pFC[i] < hMdDec->spar_md_cfg.max_freq_per_chan[j] )
+ if ( LT_32( pFC[i], hMdDec->spar_md_cfg.max_freq_per_chan[j] ) )
{
- dmx_ch += 1;
+ dmx_ch = add( dmx_ch, 1 );
}
}
hMdDec->spar_md_cfg.num_dmx_chans_per_band[i] = hMdDec->spar_md_cfg.nchan_transport;
- hMdDec->spar_md_cfg.num_decorr_per_band[i] = nchan - hMdDec->spar_md_cfg.nchan_transport;
+ move16();
+ hMdDec->spar_md_cfg.num_decorr_per_band[i] = sub( nchan, hMdDec->spar_md_cfg.nchan_transport );
+ move16();
}
hMdDec->spar_md_cfg.nchan_transport = dmx_ch;
+ move16();
return IVAS_ERR_OK;
}
@@ -1293,9 +1305,9 @@ static void ivas_dec_mono_sba_handling_fx(
test();
test();
- IF(
- ( NE_32( azimuth_fx, 0 ) ) ||
- ( NE_32( elevation_fx, 0 ) ) ||
+ if (
+ ( ( azimuth_fx != 0 ) ) ||
+ ( ( elevation_fx != 0 ) ) ||
( GT_32( energy_ratio_fx, 161061274 /* 0.15f in Q30 */ ) ) ) /* 0.15f is just above the lowest quantised value. */
{
mono_flag = 0;
@@ -1305,6 +1317,7 @@ static void ivas_dec_mono_sba_handling_fx(
}
/* Combine the SPAR prediction coefs flag with the azimuth, elevation and energy ratio flag.*/
+ test();
mono_flag = mono_flag && ivas_spar_chk_zero_coefs_fx( st_ivas );
IF( mono_flag )
@@ -1358,7 +1371,16 @@ void ivas_spar_md_dec_process_fx(
hMdDec = st_ivas->hSpar->hMdDec;
- active_w_vlbr = ( st_ivas->hDecoderConfig->ivas_total_brate < IVAS_24k4 ) ? 1 : 0;
+ IF( LT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_24k4 ) )
+ {
+ active_w_vlbr = 1;
+ move16();
+ }
+ ELSE
+ {
+ active_w_vlbr = 0;
+ move16();
+ }
num_md_chs = ivas_sba_get_nchan_metadata_fx( sba_order, st_ivas->hDecoderConfig->ivas_total_brate );
@@ -1386,7 +1408,7 @@ void ivas_spar_md_dec_process_fx(
}
}
}
- else
+ ELSE
{
dyn_active_w_flag = 0;
move16();
@@ -1396,23 +1418,6 @@ void ivas_spar_md_dec_process_fx(
}
}
-#if 0 // ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED
- FOR (Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++)
- {
- FOR (Word16 ii = 0; ii < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; ii++)
- {
- FOR (Word16 jj = 0; jj < IVAS_SPAR_MAX_DMX_CHS - 1; jj++)
- {
- hMdDec->spar_md.band_coeffs[i].C_re_fx[ii][jj] = (Word32)(hMdDec->spar_md.band_coeffs[i].C_re[ii][jj] * (1 << 22));
- }
- }
- FOR (Word16 jj = 0; jj < IVAS_SPAR_MAX_DMX_CHS - 1; jj++)
- {
- hMdDec->spar_md.band_coeffs[i].pred_re_fx[jj] = (Word32)(hMdDec->spar_md.band_coeffs[i].pred_re[jj] * (1 << 22));
- hMdDec->spar_md.band_coeffs[i].P_re_fx[jj] = (Word32)(hMdDec->spar_md.band_coeffs[i].P_re[jj] * (1 << 22));
- }
- }
-#endif
ivas_spar_dec_parse_md_bs_fx( hMdDec, st0, &nB, &bw, &dtx_vad, st_ivas->hDecoderConfig->ivas_total_brate,
st_ivas->hQMetaData->sba_inactive_mode );
@@ -1425,23 +1430,7 @@ void ivas_spar_md_dec_process_fx(
&hMdDec->base_band_coeffs_age[0],
&hMdDec->first_valid_frame,
nB );
-#if 0 // ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED
- for (int i = 0; i < IVAS_MAX_NUM_BANDS; i++)
- {
- for (int ii = 0; ii < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; ii++)
- {
- for (int jj = 0; jj < IVAS_SPAR_MAX_DMX_CHS - 1; jj++)
- {
- hMdDec->spar_md.band_coeffs[i].C_re[ii][jj] = (float)hMdDec->spar_md.band_coeffs[i].C_re_fx[ii][jj] / (1 << 22);
- }
- }
- for (int jj = 0; jj < IVAS_SPAR_MAX_DMX_CHS - 1; jj++)
- {
- hMdDec->spar_md.band_coeffs[i].pred_re[jj] = (float)hMdDec->spar_md.band_coeffs[i].pred_re_fx[jj] / (1 << 22);
- hMdDec->spar_md.band_coeffs[i].P_re[jj] = (float)hMdDec->spar_md.band_coeffs[i].P_re_fx[jj] / (1 << 22);
- }
- }
-#endif
+
ivas_dec_mono_sba_handling_fx( st_ivas );
/* SPAR to DirAC conversion */
@@ -1455,37 +1444,28 @@ void ivas_spar_md_dec_process_fx(
move16();
/* expand DirAC MD to all time slots */
- for ( i_ts = 1; i_ts < num_md_sub_frames; i_ts++ )
+ FOR( i_ts = 1; i_ts < num_md_sub_frames; i_ts++ )
{
- for ( b = 0; b < hMdDec->spar_md.num_bands; b++ )
+ FOR( b = 0; b < hMdDec->spar_md.num_bands; b++ )
{
- for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
{
-#if 0 // ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED
- hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re[j] = hMdDec->spar_md.band_coeffs[b].pred_re[j];
-#endif
- hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re_fx[j] = hMdDec->spar_md.band_coeffs[b].pred_re_fx[j];
+ hMdDec->spar_md.band_coeffs[add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )].pred_re_fx[j] = hMdDec->spar_md.band_coeffs[b].pred_re_fx[j];
move32();
}
- for ( j = 0; j < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; j++ )
{
- for ( k = 0; k < IVAS_SPAR_MAX_DMX_CHS - 1; k++ )
+ FOR( k = 0; k < IVAS_SPAR_MAX_DMX_CHS - 1; k++ )
{
-#if 0 // ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED
- hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re[j][k] = hMdDec->spar_md.band_coeffs[b].C_re[j][k];
-#endif
- hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re_fx[j][k] = hMdDec->spar_md.band_coeffs[b].C_re_fx[j][k];
+ hMdDec->spar_md.band_coeffs[add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )].C_re_fx[j][k] = hMdDec->spar_md.band_coeffs[b].C_re_fx[j][k];
move32();
}
}
- for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
{
-#if 0 // ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED
- hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].P_re[j] = hMdDec->spar_md.band_coeffs[b].P_re[j];
-#endif
- hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].P_re_fx[j] = hMdDec->spar_md.band_coeffs[b].P_re_fx[j];
+ hMdDec->spar_md.band_coeffs[add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )].P_re_fx[j] = hMdDec->spar_md.band_coeffs[b].P_re_fx[j];
move32();
}
}
@@ -1508,6 +1488,7 @@ void ivas_spar_md_dec_process_fx(
hMdDec->dtx_md_smoothing_cntr = 1;
+ move16();
return;
}
@@ -1697,36 +1678,42 @@ Word16 ivas_spar_chk_zero_coefs_fx(
Word16 j, k, b;
ivas_spar_md_dec_state_t *hMdDec;
Word16 mono = 1;
+ move16();
Word16 ndec, ndm;
hMdDec = st_ivas->hSpar->hMdDec;
ndec = hMdDec->spar_md_cfg.num_decorr_per_band[0];
+ move16();
ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[0];
+ move16();
FOR( b = 0; b < min( hMdDec->spar_md.num_bands, SPAR_DIRAC_SPLIT_START_BAND ); b++ )
{
- FOR( j = 0; j < ndm + ndec - 1; j++ )
+ FOR( j = 0; j < sub( add( ndm, ndec ), 1 ); j++ )
{
- IF( NE_32( hMdDec->spar_md.band_coeffs[b].pred_re_fx[j], 0 ) )
+ if ( hMdDec->spar_md.band_coeffs[b].pred_re_fx[j] != 0 )
{
mono = 0;
+ move16();
}
}
FOR( j = 0; j < ndec; j++ )
{
- FOR( k = 0; k < ndm - 1; k++ )
+ FOR( k = 0; k < sub( ndm, 1 ); k++ )
{
- IF( NE_32( hMdDec->spar_md.band_coeffs[b].C_re_fx[j][k], 0 ) )
+ if ( hMdDec->spar_md.band_coeffs[b].C_re_fx[j][k] != 0 )
{
mono = 0;
+ move16();
}
}
}
FOR( j = 0; j < ndec; j++ )
{
- IF( NE_32( hMdDec->spar_md.band_coeffs[b].P_re_fx[j], 0 ) )
+ if ( hMdDec->spar_md.band_coeffs[b].P_re_fx[j] != 0 )
{
mono = 0;
+ move16();
}
}
}
@@ -1752,10 +1739,9 @@ void ivas_spar_smooth_md_dtx_fx(
Word16 j, k, b, dmx_ch;
Word16 ramp_fx;
Word32 tar_fx, prev_fx, new_val_fx;
- Word16 tmp, tmp_e;
- tmp = BASOP_Util_Divide1616_Scale( hMdDec->dtx_md_smoothing_cntr, IVAS_DEFAULT_DTX_CNG_RAMP, &tmp_e );
- ramp_fx = shl_sat( tmp, tmp_e ); /* Q15 */
+ /* ramp = (float)hMdDec->dtx_md_smoothing_cntr / IVAS_DEFAULT_DTX_CNG_RAMP; */
+ ramp_fx = i_mult_sat( hMdDec->dtx_md_smoothing_cntr, 4096 /* 1 / IVAS_DEFAULT_DTX_CNG_RAMP in Q15 */ ); /* Q15 */
FOR( b = 0; b < num_bands_out; b++ )
{
@@ -1803,7 +1789,7 @@ void ivas_spar_smooth_md_dtx_fx(
{
FOR( k = dmx_ch; k < FOA_CHANNELS; k++ )
{
- hMdDec->spar_coeffs.P_re_fx[j][k][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.P_re_fx[j][k][b]; /* Q22 */
+ hMdDec->spar_coeffs.P_re_fx[j][k][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = hMdDec->spar_coeffs.P_re_fx[j][k][b]; /* Q22 */
move32();
}
}
@@ -1812,7 +1798,7 @@ void ivas_spar_smooth_md_dtx_fx(
{
FOR( k = 0; k < dmx_ch; k++ )
{
- hMdDec->spar_coeffs.C_re_fx[j][k][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.C_re_fx[j][k][b]; /* Q22 */
+ hMdDec->spar_coeffs.C_re_fx[j][k][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = hMdDec->spar_coeffs.C_re_fx[j][k][b]; /* Q22 */
move32();
}
}
@@ -1820,6 +1806,7 @@ void ivas_spar_smooth_md_dtx_fx(
}
hMdDec->dtx_md_smoothing_cntr = s_min( add( hMdDec->dtx_md_smoothing_cntr, 1 ), IVAS_DEFAULT_DTX_CNG_RAMP );
+ move16();
return;
}
@@ -2388,14 +2375,14 @@ static void ivas_get_spar_matrices(
static void ivas_get_spar_matrices_fx(
ivas_spar_md_dec_state_t *hMdDec,
- const int16_t num_bands_out,
- const int16_t n_ts,
- const int16_t bw,
- const int16_t dtx_vad,
- const int16_t nB,
- const int16_t numch_out,
- const int16_t active_w_vlbr,
- const int16_t dyn_active_w_flag )
+ const Word16 num_bands_out,
+ const Word16 n_ts,
+ const Word16 bw,
+ const Word16 dtx_vad,
+ const Word16 nB,
+ const Word16 numch_out,
+ const Word16 active_w_vlbr,
+ const Word16 dyn_active_w_flag )
{
Word16 num_bands, dmx_ch, split_band;
Word16 i, j, k, m, b, i_ts, active_w;
@@ -2403,9 +2390,11 @@ static void ivas_get_spar_matrices_fx(
Word32 active_w_dm_fac_fx, re_fx, re_fx1;
num_bands = num_bands_out;
+ move16();
order = remix_order_set[hMdDec->spar_md_cfg.remix_unmix_order];
split_band = SPAR_DIRAC_SPLIT_START_BAND;
+ move16();
// Dead code as SPAR_DIRAC_SPLIT_START_BAND = 8 and IVAS_MAX_NUM_BANDS = 12
IF( GE_16( split_band, IVAS_MAX_NUM_BANDS ) )
@@ -2425,15 +2414,30 @@ static void ivas_get_spar_matrices_fx(
}
}
- IF( bw == IVAS_RED_BAND_FACT )
+ if ( EQ_16( bw, IVAS_RED_BAND_FACT ) )
{
num_bands = shl( num_bands, 1 );
}
+ test();
active_w = EQ_16( dyn_active_w_flag, 1 ) || EQ_16( hMdDec->spar_md_cfg.active_w, 1 );
- active_w_dm_fac_fx = EQ_16( dtx_vad, 0 ) ? IVAS_ACTIVEW_DM_F_SCALE_DTX_FX : ( EQ_16( active_w_vlbr, 1 ) ? IVAS_ACTIVEW_DM_F_SCALE_VLBR_FX : IVAS_ACTIVEW_DM_F_SCALE_FX );
- move16();
+ IF( dtx_vad == 0 )
+ {
+ active_w_dm_fac_fx = IVAS_ACTIVEW_DM_F_SCALE_DTX_FX;
+ move32();
+ }
+ ELSE IF( EQ_16( active_w_vlbr, 1 ) )
+ {
+ active_w_dm_fac_fx = IVAS_ACTIVEW_DM_F_SCALE_VLBR_FX;
+ move32();
+ }
+ ELSE
+ {
+ active_w_dm_fac_fx = IVAS_ACTIVEW_DM_F_SCALE_FX;
+ move32();
+ }
+
FOR( i_ts = 0; i_ts < n_ts; i_ts++ )
{
FOR( i = 0; i < numch_out; i++ )
@@ -2441,18 +2445,20 @@ static void ivas_get_spar_matrices_fx(
FOR( j = 0; j < numch_out; j++ )
{
- set32_fx( &hMdDec->spar_coeffs.C_re_fx[i][j][i_ts * IVAS_MAX_NUM_BANDS], 0, IVAS_MAX_NUM_BANDS );
- set32_fx( &hMdDec->spar_coeffs.P_re_fx[i][j][i_ts * IVAS_MAX_NUM_BANDS], 0, IVAS_MAX_NUM_BANDS );
+ set32_fx( &hMdDec->spar_coeffs.C_re_fx[i][j][i_mult( i_ts, IVAS_MAX_NUM_BANDS )], 0, IVAS_MAX_NUM_BANDS );
+ set32_fx( &hMdDec->spar_coeffs.P_re_fx[i][j][i_mult( i_ts, IVAS_MAX_NUM_BANDS )], 0, IVAS_MAX_NUM_BANDS );
}
}
num_bands = min( num_bands, nB );
+ move16();
FOR( b = 0; b < num_bands; b++ )
{
Word32 tmp_C1_re_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
Word32 tmp_C2_re_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
Word32 tmp_dm_re_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
- dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[bw * b];
+ dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[i_mult( bw, b )];
+ move16();
FOR( j = 0; j < numch_out; j++ )
{
@@ -2470,7 +2476,7 @@ static void ivas_get_spar_matrices_fx(
FOR( j = 1; j < numch_out; j++ )
{
- tmp_C1_re_fx[j][0] = hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re_fx[j - 1]; // Q.22
+ tmp_C1_re_fx[j][0] = hMdDec->spar_md.band_coeffs[add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )].pred_re_fx[j - 1]; // Q.22
move32();
}
@@ -2479,7 +2485,7 @@ static void ivas_get_spar_matrices_fx(
FOR( j = 1; j < numch_out; j++ )
{
- tmp_C2_re_fx[0][j] = Mpy_32_32( active_w_dm_fac_fx, -hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re_fx[j - 1] ); // Q31 *Q22=Q22
+ tmp_C2_re_fx[0][j] = Mpy_32_32( active_w_dm_fac_fx, L_negate( hMdDec->spar_md.band_coeffs[add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )].pred_re_fx[j - 1] ) ); // Q31 *Q22=Q22
move32();
}
re_fx = Mpy_32_32( tmp_C2_re_fx[0][1], tmp_C1_re_fx[1][0] ); // Q22 *Q22 =Q13
@@ -2492,23 +2498,29 @@ static void ivas_get_spar_matrices_fx(
tmp_dm_re_fx[0][0] = L_shl( L_add( re_fx1, re_fx ), Q9 ); // (Q13+Q13) << Q9 = Q22;
move32();
- if ( EQ_16( dyn_active_w_flag, 1 ) )
+ IF( EQ_16( dyn_active_w_flag, 1 ) )
{
tmp_dm_re_fx[0][0] = L_shl( Mpy_32_32( tmp_dm_re_fx[0][0], IVAS_SPAR_DYN_ACTIVEW_THRESH_FX ), Q9 ); // Q13 *Q31 =Q13 << Q9=Q.22
move32();
}
tmp_dm_re_fx[0][1] = tmp_C2_re_fx[0][1];
+ move32();
tmp_dm_re_fx[0][2] = tmp_C2_re_fx[0][2];
+ move32();
tmp_dm_re_fx[0][3] = tmp_C2_re_fx[0][3];
+ move32();
tmp_dm_re_fx[1][0] = tmp_C1_re_fx[1][0];
+ move32();
tmp_dm_re_fx[2][0] = tmp_C1_re_fx[2][0];
+ move32();
tmp_dm_re_fx[3][0] = tmp_C1_re_fx[3][0];
+ move32();
IF( NE_16( hMdDec->spar_md_cfg.remix_unmix_order, 3 ) )
{
@@ -2519,12 +2531,11 @@ static void ivas_get_spar_matrices_fx(
{
IF( NE_16( hMdDec->spar_md_cfg.remix_unmix_order, 3 ) )
{
-
ivas_mat_col_rearrange_fx( tmp_C1_re_fx, order, i_ts, hMdDec->mixer_mat_fx, b, numch_out );
}
}
- IF( GT_16( dmx_ch, 0 ) )
+ IF( dmx_ch > 0 )
{
Word32 tmpC_re_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
Word32 tmpP_re_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
@@ -2550,7 +2561,7 @@ static void ivas_get_spar_matrices_fx(
{
FOR( k = 1; k < dmx_ch; k++ )
{
- tmpC_re_fx[j][k] = hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re_fx[j - dmx_ch][k - 1]; // Q22
+ tmpC_re_fx[j][k] = hMdDec->spar_md.band_coeffs[add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )].C_re_fx[sub( j, dmx_ch )][k - 1]; // Q22
move32();
}
}
@@ -2561,7 +2572,7 @@ static void ivas_get_spar_matrices_fx(
{
IF( EQ_16( sub( j, dmx_ch ), sub( k, dmx_ch ) ) )
{
- tmpP_re_fx[j][k] = hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].P_re_fx[k - dmx_ch]; // Q22
+ tmpP_re_fx[j][k] = hMdDec->spar_md.band_coeffs[add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )].P_re_fx[sub( k, dmx_ch )]; // Q22
move32();
}
ELSE
@@ -2579,9 +2590,9 @@ static void ivas_get_spar_matrices_fx(
{
FOR( m = 0; m < numch_out; m++ )
{
- re_fx = Mpy_32_32( hMdDec->mixer_mat_fx[j][m][b + i_ts * IVAS_MAX_NUM_BANDS], tmpP_re_fx[m][k] ); // Q30*Q22
+ re_fx = Mpy_32_32( hMdDec->mixer_mat_fx[j][m][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )], tmpP_re_fx[m][k] ); // Q30*Q22
re_fx = L_shl( re_fx, 1 );
- hMdDec->spar_coeffs.P_re_fx[j][k][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] = L_add( hMdDec->spar_coeffs.P_re_fx[j][k][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS], re_fx );
+ hMdDec->spar_coeffs.P_re_fx[j][k][add( i_mult( b, bw ), i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = L_add( hMdDec->spar_coeffs.P_re_fx[j][k][add( i_mult( b, bw ), i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )], re_fx );
move32();
}
}
@@ -2594,23 +2605,24 @@ static void ivas_get_spar_matrices_fx(
{
FOR( m = 0; m < numch_out; m++ )
{
- re_fx = Mpy_32_32( hMdDec->mixer_mat_fx[j][m][b + i_ts * IVAS_MAX_NUM_BANDS], tmpC_re_fx[m][k] ); // Q30* Q22
+ re_fx = Mpy_32_32( hMdDec->mixer_mat_fx[j][m][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )], tmpC_re_fx[m][k] ); // Q30* Q22
re_fx = L_shl( re_fx, 1 );
- hMdDec->spar_coeffs.C_re_fx[j][k][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] = L_add( hMdDec->spar_coeffs.C_re_fx[j][k][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS], re_fx );
+ hMdDec->spar_coeffs.C_re_fx[j][k][add( i_mult( b, bw ), i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = L_add( hMdDec->spar_coeffs.C_re_fx[j][k][add( i_mult( b, bw ), i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )], re_fx );
move32();
}
}
}
- hMdDec->spar_coeffs.C_re_fx[0][0][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] =
- max( 0, hMdDec->spar_coeffs.C_re_fx[0][0][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] );
+ hMdDec->spar_coeffs.C_re_fx[0][0][add( i_mult( b, bw ), i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] =
+ max( 0, hMdDec->spar_coeffs.C_re_fx[0][0][add( i_mult( b, bw ), i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] );
+ move32();
}
}
/* band mixing */
IF( EQ_16( bw, IVAS_RED_BAND_FACT ) )
{
- FOR( b = 0; b < num_bands_out; b = b + bw )
+ FOR( b = 0; b < num_bands_out; b = add( b, bw ) )
{
dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b];
move16();
@@ -2618,8 +2630,7 @@ static void ivas_get_spar_matrices_fx(
{
FOR( k = dmx_ch; k < numch_out; k++ )
{
-
- hMdDec->spar_coeffs.P_re_fx[j][k][( b + 1 ) + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.P_re_fx[j][k][b + i_ts * IVAS_MAX_NUM_BANDS];
+ hMdDec->spar_coeffs.P_re_fx[j][k][add( add( b, 1 ), i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = hMdDec->spar_coeffs.P_re_fx[j][k][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )];
move32();
}
}
@@ -2628,9 +2639,7 @@ static void ivas_get_spar_matrices_fx(
{
FOR( k = 0; k < dmx_ch; k++ )
{
-
- hMdDec->spar_coeffs.C_re_fx[j][k][( b + 1 ) + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.C_re_fx[j][k][b + i_ts * IVAS_MAX_NUM_BANDS];
-
+ hMdDec->spar_coeffs.C_re_fx[j][k][add( add( b, 1 ), i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = hMdDec->spar_coeffs.C_re_fx[j][k][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )];
move32();
}
}
@@ -2695,7 +2704,7 @@ static void ivas_mat_col_rearrange_fx(
FOR( j = 0; j < num_ch; j++ )
{
- mixer_mat[j][i][bands + i_ts * IVAS_MAX_NUM_BANDS] = L_shl_sat( in_re[j][idx], Q8 );
+ mixer_mat[j][i][add( bands, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = L_shl_sat( in_re[j][idx], Q8 );
move32();
}
}
@@ -2730,7 +2739,7 @@ void ivas_spar_dec_gen_umx_mat_fx(
{
FOR( b = 0; b < num_bands_out; b++ )
{
- hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = L_shl_sat( hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], Q8 );
+ hMdDec->mixer_mat_fx[i][j][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = L_shl_sat( hMdDec->spar_coeffs.C_re_fx[i][j][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )], Q8 );
move32();
}
}
@@ -2741,7 +2750,7 @@ void ivas_spar_dec_gen_umx_mat_fx(
{
FOR( b = 0; b < num_bands_out; b++ )
{
- hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = L_shl_sat( hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], Q8 );
+ hMdDec->mixer_mat_fx[i][j][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = L_shl_sat( hMdDec->spar_coeffs.P_re_fx[i][j][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )], Q8 );
move32();
}
}
@@ -2755,7 +2764,7 @@ void ivas_spar_dec_gen_umx_mat_fx(
{
FOR( b = 0; b < num_bands_out; b++ )
{
- hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = L_shl_sat( hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], Q8 );
+ hMdDec->mixer_mat_fx[i][j][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = L_shl_sat( hMdDec->spar_coeffs.C_re_fx[i][j][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )], Q8 );
move32();
}
}
@@ -2827,51 +2836,48 @@ void ivas_spar_dec_gen_umx_mat(
static void ivas_spar_md_band_upmix(
ivas_band_coeffs_t *band_coeffs,
- int16_t *nB,
- int16_t *bands_bw,
- int16_t *valid_bands,
- int16_t bw_final,
- int16_t ndec,
- int16_t ndm )
+ Word16 *nB,
+ Word16 *bands_bw,
+ Word16 *valid_bands,
+ Word16 bw_final,
+ Word16 ndec,
+ Word16 ndm )
{
- int16_t i, ii, jj, b, idx, bw_fact;
+ Word16 i, ii, jj, b, idx, bw_fact;
- bw_fact = *bands_bw / bw_final;
- for ( i = *nB - 1; i >= 0; i-- )
+ bw_fact = idiv1616( *bands_bw, bw_final );
+ FOR( i = sub( *nB, 1 ); i >= 0; i-- )
{
- for ( b = bw_fact - 1; b >= 0; b-- )
+ FOR( b = sub( bw_fact, 1 ); b >= 0; b-- )
{
- idx = i * bw_fact + b;
- for ( ii = 0; ii < ndec + ndm - 1; ii++ )
+ idx = add( i_mult( i, bw_fact ), b );
+ FOR( ii = 0; ii < sub( add( ndec, ndm ), 1 ); ii++ )
{
-#if 0 // ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED
- band_coeffs[idx].pred_re[ii] = band_coeffs[i].pred_re[ii];
-#endif
band_coeffs[idx].pred_re_fx[ii] = band_coeffs[i].pred_re_fx[ii];
+ move32();
}
- for ( ii = 0; ii < ndec; ii++ )
+ FOR( ii = 0; ii < ndec; ii++ )
{
- for ( jj = 0; jj < ndm - 1; jj++ )
+ FOR( jj = 0; jj < sub( ndm, 1 ); jj++ )
{
-#if 0 // ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED
- band_coeffs[idx].C_re[ii][jj] = band_coeffs[i].C_re[ii][jj];
-#endif
band_coeffs[idx].C_re_fx[ii][jj] = band_coeffs[i].C_re_fx[ii][jj];
+ move32();
}
}
- for ( jj = 0; jj < ndec; jj++ )
+ FOR( jj = 0; jj < ndec; jj++ )
{
-#if 0 // ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED
- band_coeffs[idx].P_re[jj] = band_coeffs[i].P_re[jj];
-#endif
band_coeffs[idx].P_re_fx[jj] = band_coeffs[i].P_re_fx[jj];
+ move32();
}
valid_bands[idx] = valid_bands[i];
+ move16();
}
}
- *nB = ( *nB ) * ( *bands_bw ) / bw_final;
+ *nB = idiv1616( i_mult( ( *nB ), ( *bands_bw ) ), bw_final );
+ move16();
*bands_bw = bw_final;
+ move16();
return;
}
@@ -3120,99 +3126,112 @@ static void ivas_spar_dec_parse_md_bs(
static void ivas_spar_dec_parse_md_bs_fx(
ivas_spar_md_dec_state_t *hMdDec,
Decoder_State *st0,
- int16_t *nB,
- int16_t *bands_bw,
- int16_t *dtx_vad,
- const int32_t ivas_total_brate,
- const int16_t sba_inactive_mode )
+ Word16 *nB,
+ Word16 *bands_bw,
+ Word16 *dtx_vad,
+ const Word32 ivas_total_brate,
+ const Word16 sba_inactive_mode )
{
- int16_t i, j, k, num_bands;
- int16_t ii, jj, ndec, ndm;
- uint16_t qsi;
+ Word16 i, j, k, num_bands;
+ Word16 ii, jj, ndec, ndm;
+ UWord16 qsi;
ivas_quant_strat_t qs;
- int16_t strat, no_ec;
- int16_t do_diff[IVAS_MAX_NUM_BANDS];
- // float quant[IVAS_SPAR_MAX_C_COEFF];
+ Word16 strat, no_ec;
+ Word16 do_diff[IVAS_MAX_NUM_BANDS];
Word32 quant_fx[IVAS_SPAR_MAX_C_COEFF];
- int16_t do_repeat[IVAS_MAX_NUM_BANDS];
+ Word16 do_repeat[IVAS_MAX_NUM_BANDS];
*dtx_vad = 1;
+ move16();
*bands_bw = 1;
+ move16();
qsi = 0;
+ move16();
num_bands = hMdDec->spar_md.num_bands;
+ move16();
- if ( ivas_total_brate > IVAS_SID_5k2 )
+ IF( GT_32( ivas_total_brate, IVAS_SID_5k2 ) )
{
- if ( hMdDec->spar_md_cfg.quant_strat_bits > 0 )
+ IF( hMdDec->spar_md_cfg.quant_strat_bits > 0 )
{
- if ( ivas_total_brate >= BRATE_SPAR_Q_STRAT )
+ IF( GE_32( ivas_total_brate, BRATE_SPAR_Q_STRAT ) )
{
/*only one bit written for quantization strategy to indicate either a fixed quantization strategy or dtx_vad==0 */
qsi = get_next_indice( st0, 1 );
- if ( qsi == 1 )
+ if ( EQ_32( qsi, 1 ) )
{
*dtx_vad = 0;
+ move16();
}
}
- else
+ ELSE
{
- if ( sba_inactive_mode == 1 )
+ IF( EQ_16( sba_inactive_mode, 1 ) )
{
*dtx_vad = 0;
- qsi = hMdDec->spar_md_cfg.quant_strat_bits + 1;
+ move16();
+ qsi = add( hMdDec->spar_md_cfg.quant_strat_bits, 1 );
}
- else
+ ELSE
{
qsi = get_next_indice( st0, hMdDec->spar_md_cfg.quant_strat_bits );
}
}
}
- else
+ ELSE
{
qsi = 0;
+ move16();
}
}
- else
+ ELSE
{
*dtx_vad = 0;
+ move16();
}
hMdDec->dtx_vad = *dtx_vad;
+ move16();
- if ( *dtx_vad == 0 )
+ IF( *dtx_vad == 0 )
{
*nB = SPAR_DTX_BANDS;
- *bands_bw = num_bands / *nB;
+ move16();
+ *bands_bw = idiv1616( num_bands, *nB );
+ move16();
- for ( i = 0; i < *nB; i++ )
+ FOR( i = 0; i < *nB; i++ )
{
- for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
{
- // hMdDec->spar_md.band_coeffs[i].pred_re[j] = 0;
hMdDec->spar_md.band_coeffs[i].pred_re_fx[j] = 0;
- // hMdDec->spar_md.band_coeffs[i].P_re[j] = 0;
+ move32();
hMdDec->spar_md.band_coeffs[i].P_re_fx[j] = 0;
+ move32();
}
hMdDec->valid_bands[i] = 1;
+ move16();
}
- for ( i = 0; i < num_bands; i++ )
+ FOR( i = 0; i < num_bands; i++ )
{
- for ( j = 0; j < ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ); j++ )
+ FOR( j = 0; j < ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ); j++ )
{
- for ( k = 0; k < ( IVAS_SPAR_MAX_DMX_CHS - 1 ); k++ )
+ FOR( k = 0; k < ( IVAS_SPAR_MAX_DMX_CHS - 1 ); k++ )
{
- // hMdDec->spar_md.band_coeffs[i].C_re[j][k] = 0;
hMdDec->spar_md.band_coeffs[i].C_re_fx[j][k] = 0;
+ move32();
}
}
}
ivas_parse_parameter_bitstream_dtx( &hMdDec->spar_md, st0, *bands_bw, *nB, hMdDec->spar_md_cfg.num_dmx_chans_per_band, hMdDec->spar_md_cfg.num_decorr_per_band );
- if ( *bands_bw != 1 )
+ IF( NE_16( *bands_bw, 1 ) )
{
ndec = hMdDec->spar_md_cfg.num_decorr_per_band[0];
+ move16();
ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[0];
+ move16();
ivas_spar_md_band_upmix(
hMdDec->spar_md.band_coeffs,
nB,
@@ -3227,124 +3246,175 @@ static void ivas_spar_dec_parse_md_bs_fx(
}
qs = hMdDec->spar_md_cfg.quant_strat[qsi];
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
strat = get_next_indice( st0, 3 );
no_ec = 0;
+ move16();
- if ( strat < 2 )
+ IF( LT_16( strat, 2 ) )
{
- *bands_bw = strat + 1;
- *nB = num_bands / *bands_bw;
- for ( i = 0; i < *nB; i++ )
+ *bands_bw = add( strat, 1 );
+ move16();
+ *nB = idiv1616( num_bands, *bands_bw );
+ move16();
+ FOR( i = 0; i < *nB; i++ )
{
do_diff[i] = 0;
+ move16();
do_repeat[i] = 0;
+ move16();
}
}
- else if ( strat < 4 )
+ ELSE IF( LT_16( strat, 4 ) )
{
- *bands_bw = strat - 1;
- *nB = num_bands / *bands_bw;
- for ( i = 0; i < *nB; i++ )
+ *bands_bw = sub( strat, 1 );
+ move16();
+ *nB = idiv1616( num_bands, *bands_bw );
+ move16();
+ FOR( i = 0; i < *nB; i++ )
{
do_diff[i] = 0;
+ move16();
do_repeat[i] = 0;
+ move16();
}
no_ec = 1;
+ move16();
}
- else if ( ivas_total_brate < IVAS_24k4 )
+ ELSE IF( LT_32( ivas_total_brate, IVAS_24k4 ) )
{
*bands_bw = 2;
- *nB = num_bands / *bands_bw;
+ move16();
+ *nB = idiv1616( num_bands, *bands_bw );
+ move16();
- for ( i = 0; i < *nB; i++ )
+ FOR( i = 0; i < *nB; i++ )
{
do_diff[i] = 0;
- do_repeat[i] = ( ( strat % 2 ) == ( ( i + 1 ) % 2 ) );
+ move16();
+ do_repeat[i] = extract_l( EQ_16( ( strat % 2 ), ( add( i, 1 ) % 2 ) ) );
+ move16();
}
}
- else
+ ELSE
{
*bands_bw = 1;
+ move16();
*nB = num_bands;
+ move16();
- for ( i = 0; i < *nB; i++ )
+ FOR( i = 0; i < *nB; i++ )
{
- do_diff[i] = ( ( ( i + 1 ) & 3 ) != strat - 4 );
+ do_diff[i] = extract_l( NE_16( s_and( add( i, 1 ), 3 ), sub( strat, 4 ) ) );
+ move16();
do_repeat[i] = 0;
+ move16();
}
- if ( hMdDec->spar_md_cfg.prev_quant_idx >= 0 )
+ IF( hMdDec->spar_md_cfg.prev_quant_idx >= 0 )
{
ivas_map_prior_coeffs_quant( &hMdDec->spar_md_prev, &hMdDec->spar_md_cfg, qsi, *nB );
}
}
hMdDec->spar_md_cfg.prev_quant_idx = qsi;
+ move16();
- if ( no_ec == 0 )
+ IF( no_ec == 0 )
{
ivas_decode_arith_bs( hMdDec, st0, qsi, *nB, *bands_bw, do_diff, strat, ivas_total_brate );
}
- else
+ ELSE
{
ivas_decode_huffman_bs( hMdDec, st0, qsi, *nB, *bands_bw );
}
- for ( i = 0; i < *nB; i++ )
+ FOR( i = 0; i < *nB; i++ )
{
- ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i];
- ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * i];
+ ndec = hMdDec->spar_md_cfg.num_decorr_per_band[i_mult( ( *bands_bw ), i )];
+ move16();
+ ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[i_mult( ( *bands_bw ), i )];
+ move16();
- // ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].pred_index_re, qs.PR.q_levels[0], qs.PR.min, qs.PR.max, hMdDec->spar_md.band_coeffs[i].pred_re, ndm + ndec - 1 );
- ivas_deindex_real_index_fx( hMdDec->spar_md.band_coeffs_idx[i].pred_index_re, qs.PR.q_levels[0], qs.PR.min_fx, qs.PR.max_fx, hMdDec->spar_md.band_coeffs[i].pred_re_fx, ndm + ndec - 1 );
+ ivas_deindex_real_index_fx( hMdDec->spar_md.band_coeffs_idx[i].pred_index_re, qs.PR.q_levels[0], qs.PR.min_fx, qs.PR.max_fx, hMdDec->spar_md.band_coeffs[i].pred_re_fx, sub( add( ndm, ndec ), 1 ) );
j = 0;
- for ( ii = 0; ii < ndec; ii++ )
+ move16();
+ FOR( ii = 0; ii < ndec; ii++ )
{
- for ( jj = 0; jj < ndm - 1; jj++ )
+ FOR( jj = 0; jj < sub( ndm, 1 ); jj++ )
{
- // quant[j] = hMdDec->spar_md.band_coeffs[i].C_re[ii][jj];
quant_fx[j] = hMdDec->spar_md.band_coeffs[i].C_re_fx[ii][jj];
- j++;
+ move32();
+ j = add( j, 1 );
}
}
- // ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].drct_index_re, qs.C.q_levels[0], qs.C.min, qs.C.max, quant, ndec * ( ndm - 1 ) );
- ivas_deindex_real_index_fx( hMdDec->spar_md.band_coeffs_idx[i].drct_index_re, qs.C.q_levels[0], qs.C.min_fx, qs.C.max_fx, quant_fx, ndec * ( ndm - 1 ) );
+ ivas_deindex_real_index_fx( hMdDec->spar_md.band_coeffs_idx[i].drct_index_re, qs.C.q_levels[0], qs.C.min_fx, qs.C.max_fx, quant_fx, i_mult( ndec, sub( ndm, 1 ) ) );
j = 0;
- for ( ii = 0; ii < ndec; ii++ )
+ move16();
+ FOR( ii = 0; ii < ndec; ii++ )
{
- for ( jj = 0; jj < ndm - 1; jj++ )
+ FOR( jj = 0; jj < sub( ndm, 1 ); jj++ )
{
- // hMdDec->spar_md.band_coeffs[i].C_re[ii][jj] = quant[j];
hMdDec->spar_md.band_coeffs[i].C_re_fx[ii][jj] = quant_fx[j];
- j++;
+ move32();
+ j = add( j, 1 );
}
}
- // ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].decd_index_re, qs.P_r.q_levels[0], qs.P_r.min, qs.P_r.max, hMdDec->spar_md.band_coeffs[i].P_re, ndm + ndec - 1 );
- ivas_deindex_real_index_fx( hMdDec->spar_md.band_coeffs_idx[i].decd_index_re, qs.P_r.q_levels[0], qs.P_r.min_fx, qs.P_r.max_fx, hMdDec->spar_md.band_coeffs[i].P_re_fx, ndm + ndec - 1 );
+ ivas_deindex_real_index_fx( hMdDec->spar_md.band_coeffs_idx[i].decd_index_re, qs.P_r.q_levels[0], qs.P_r.min_fx, qs.P_r.max_fx, hMdDec->spar_md.band_coeffs[i].P_re_fx, sub( add( ndm, ndec ), 1 ) );
/* Store prior coefficient indices */
- for ( j = 0; j < ndm + ndec - 1; j++ )
+ FOR( j = 0; j < sub( add( ndm, ndec ), 1 ); j++ )
{
hMdDec->spar_md_prev.band_coeffs_idx[i].pred_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j];
+ move16();
}
- for ( j = 0; j < ndec * ( ndm - 1 ); j++ )
+ FOR( j = 0; j < i_mult( ndec, sub( ndm, 1 ) ); j++ )
{
hMdDec->spar_md_prev.band_coeffs_idx[i].drct_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j];
+ move16();
}
- for ( j = 0; j < ndec; j++ )
+ FOR( j = 0; j < ndec; j++ )
{
hMdDec->spar_md_prev.band_coeffs_idx[i].decd_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j];
+ move16();
+ }
+ test();
+ IF( ( do_diff[i] == 0 ) && ( do_repeat[i] == 0 ) )
+ {
+ hMdDec->valid_bands[i] = s_or( hMdDec->valid_bands[i], 1 );
+ move16();
+ }
+ ELSE
+ {
+ hMdDec->valid_bands[i] = s_or( hMdDec->valid_bands[i], 0 );
+ move16();
}
- hMdDec->valid_bands[i] |= ( do_diff[i] == 0 && do_repeat[i] == 0 ) ? 1 : 0;
}
ndec = hMdDec->spar_md_cfg.num_decorr_per_band[0];
+ move16();
ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[0];
- if ( *bands_bw != 1 )
+ move16();
+ IF( NE_16( *bands_bw, 1 ) )
{
ivas_spar_md_band_upmix(
hMdDec->spar_md.band_coeffs,
@@ -3700,37 +3770,47 @@ static void ivas_spar_get_plc_interp_weights(
#endif
static void ivas_spar_get_plc_interp_weights_fx(
- int16_t valid_band_idx[IVAS_MAX_NUM_BANDS],
- int16_t last_valid_band_idx,
- int16_t idx,
- int16_t b,
+ Word16 valid_band_idx[IVAS_MAX_NUM_BANDS],
+ Word16 last_valid_band_idx,
+ Word16 idx,
+ Word16 b,
Word16 *w,
- int16_t *id0,
- int16_t *id1 )
+ Word16 *id0,
+ Word16 *id1 )
{
- if ( last_valid_band_idx < 0 ) /* Extrapolation */
+ IF( last_valid_band_idx < 0 ) /* Extrapolation */
{
*id1 = valid_band_idx[0];
+ move16();
*id0 = 0;
+ move16();
*w = MAX_WORD16;
+ move16();
}
- else if ( last_valid_band_idx == idx ) /* Extrapolation */
+ ELSE IF( EQ_16( last_valid_band_idx, idx ) ) /* Extrapolation */
{
*id1 = valid_band_idx[last_valid_band_idx];
+ move16();
*id0 = valid_band_idx[last_valid_band_idx];
+ move16();
*w = 0;
+ move16();
}
- else /* Interpolation */
+ ELSE /* Interpolation */
{
*id0 = valid_band_idx[last_valid_band_idx];
+ move16();
*id1 = valid_band_idx[last_valid_band_idx + 1];
- if ( ( b - *id0 ) == 0 )
+ move16();
+ IF( sub( b, *id0 ) == 0 )
{
*w = 0;
+ move16();
}
- else
+ ELSE
{
- *w = divide3232( ( b - *id0 ), ( *id1 - *id0 ) );
+ *w = divide3232( sub( b, *id0 ), sub( *id1, *id0 ) );
+ move16();
}
}
return;
@@ -3754,13 +3834,15 @@ static void ivas_spar_md_fill_invalid_bands_fx(
{
Word16 i, j, b, all_valid;
Word16 valid_band_idx[IVAS_MAX_NUM_BANDS], idx = -1;
+ move16();
Word16 last_valid_band_idx[IVAS_MAX_NUM_BANDS];
Word16 w_fx = 0;
+ move16();
ivas_spar_plc_get_band_age( valid_bands, base_band_age, num_bands,
last_valid_band_idx, valid_band_idx, &all_valid, &idx );
assert( idx > 0 ); /* some bands should be valid */
- IF( EQ_16( all_valid, 0 ) )
+ IF( all_valid == 0 )
{
FOR( b = 0; b < num_bands; b++ )
{
@@ -3784,7 +3866,7 @@ static void ivas_spar_md_fill_invalid_bands_fx(
}
ELSE /* young invalid bands */
{
- IF( EQ_16( valid_bands[b], 0 ) )
+ IF( valid_bands[b] == 0 )
{
FOR( i = 0; i < num_channels; i++ )
{
@@ -3799,7 +3881,7 @@ static void ivas_spar_md_fill_invalid_bands_fx(
}
}
- IF( EQ_16( valid_bands[b], 0 ) )
+ IF( valid_bands[b] == 0 )
{
Word16 i_ts;
FOR( i = 0; i < num_channels; i++ )
@@ -3808,9 +3890,9 @@ static void ivas_spar_md_fill_invalid_bands_fx(
{
FOR( i_ts = 1; i_ts < num_md_sub_frames; i_ts++ )
{
- pSpar_coeffs->C_re_fx[i][j][add( b, i_ts * IVAS_MAX_NUM_BANDS )] = pSpar_coeffs->C_re_fx[i][j][b];
+ pSpar_coeffs->C_re_fx[i][j][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = pSpar_coeffs->C_re_fx[i][j][b];
move32();
- pSpar_coeffs->P_re_fx[i][j][add( b, i_ts * IVAS_MAX_NUM_BANDS )] = pSpar_coeffs->P_re_fx[i][j][b];
+ pSpar_coeffs->P_re_fx[i][j][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = pSpar_coeffs->P_re_fx[i][j][b];
move32();
}
}
@@ -3905,87 +3987,89 @@ static void ivas_spar_md_fill_invalid_bands(
static void ivas_spar_md_fill_invalid_bandcoeffs(
ivas_band_coeffs_t *pBand_coeffs,
ivas_band_coeffs_t *pBand_coeffs_prev,
- const int16_t *valid_bands,
- int16_t *base_band_age,
- int16_t *first_valid_frame,
- const int16_t num_bands )
+ const Word16 *valid_bands,
+ Word16 *base_band_age,
+ Word16 *first_valid_frame,
+ const Word16 num_bands )
{
- int16_t j, k, b, all_valid;
- int16_t valid_band_idx[IVAS_MAX_NUM_BANDS], idx = -1;
- int16_t last_valid_band_idx[IVAS_MAX_NUM_BANDS];
- // float w = 0;
+ Word16 j, k, b, all_valid;
+ Word16 valid_band_idx[IVAS_MAX_NUM_BANDS], idx = -1;
+ move16();
+ Word16 last_valid_band_idx[IVAS_MAX_NUM_BANDS];
Word16 w_fx = 0;
+ move16();
ivas_spar_plc_get_band_age( valid_bands, base_band_age, num_bands,
last_valid_band_idx, valid_band_idx, &all_valid, &idx );
assert( idx > 0 ); /* some bands should be valid */
- if ( all_valid == 0 )
+ IF( all_valid == 0 )
{
- for ( b = 0; b < num_bands; b++ )
+ FOR( b = 0; b < num_bands; b++ )
{
/* check against non zero in if and else if */
- if ( ( base_band_age[b] > 3 ) || ( *first_valid_frame == 0 ) ) /* old invalid bands */
+ test();
+ IF( GT_16( base_band_age[b], 3 ) || ( *first_valid_frame == 0 ) ) /* old invalid bands */
{
- int16_t id0, id1;
- // ivas_spar_get_plc_interp_weights( valid_band_idx, last_valid_band_idx[b],
- // idx, b, &w, &id0, &id1 );
+ Word16 id0, id1;
+
ivas_spar_get_plc_interp_weights_fx( valid_band_idx, last_valid_band_idx[b],
idx, b, &w_fx, &id0, &id1 );
- for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
{
- // pBand_coeffs[b].pred_re[j] = ( 1 - w ) * pBand_coeffs[id0].pred_re[j] + w * pBand_coeffs[id1].pred_re[j];
pBand_coeffs[b].pred_re_fx[j] = L_add( Mpy_32_16_1( pBand_coeffs[id0].pred_re_fx[j], sub( MAX_WORD16, w_fx ) ), Mpy_32_16_1( pBand_coeffs[id1].pred_re_fx[j], w_fx ) );
+ move32();
}
- for ( j = 0; j < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; j++ )
{
- for ( k = 0; k < IVAS_SPAR_MAX_DMX_CHS - 1; k++ )
+ FOR( k = 0; k < IVAS_SPAR_MAX_DMX_CHS - 1; k++ )
{
- // pBand_coeffs[b].C_re[j][k] = ( 1 - w ) * pBand_coeffs[id0].C_re[j][k] + w * pBand_coeffs[id1].C_re[j][k];
pBand_coeffs[b].C_re_fx[j][k] = L_add( Mpy_32_16_1( pBand_coeffs[id0].C_re_fx[j][k], sub( MAX_WORD16, w_fx ) ), Mpy_32_16_1( pBand_coeffs[id1].C_re_fx[j][k], w_fx ) );
+ move32();
}
}
- for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
{
- // pBand_coeffs[b].P_re[j] = ( 1 - w ) * pBand_coeffs[id0].P_re[j] + w * pBand_coeffs[id1].P_re[j];
pBand_coeffs[b].P_re_fx[j] = L_add( Mpy_32_16_1( pBand_coeffs[id0].P_re_fx[j], sub( MAX_WORD16, w_fx ) ), Mpy_32_16_1( pBand_coeffs[id1].P_re_fx[j], w_fx ) );
+ move32();
}
}
- else /* young invalid bands */
+ ELSE /* young invalid bands */
{
- if ( valid_bands[b] == 0 )
+ IF( valid_bands[b] == 0 )
{
- for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
{
- // pBand_coeffs[b].pred_re[j] = pBand_coeffs_prev[b].pred_re[j];
pBand_coeffs[b].pred_re_fx[j] = pBand_coeffs_prev[b].pred_re_fx[j];
+ move32();
}
- for ( j = 0; j < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; j++ )
{
- for ( k = 0; k < IVAS_SPAR_MAX_DMX_CHS - 1; k++ )
+ FOR( k = 0; k < IVAS_SPAR_MAX_DMX_CHS - 1; k++ )
{
- // pBand_coeffs[b].C_re[j][k] = pBand_coeffs_prev[b].C_re[j][k];
pBand_coeffs[b].C_re_fx[j][k] = pBand_coeffs_prev[b].C_re_fx[j][k];
+ move32();
}
}
- for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
+ FOR( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ )
{
- // pBand_coeffs[b].P_re[j] = pBand_coeffs_prev[b].P_re[j];
pBand_coeffs[b].P_re_fx[j] = pBand_coeffs_prev[b].P_re_fx[j];
+ move32();
}
}
}
}
}
- else
+ ELSE
{
*first_valid_frame = 1;
+ move16();
}
return;
@@ -4077,6 +4161,7 @@ static void ivas_spar_md_fill_invalid_bandcoeffs(
*
*
*-----------------------------------------------------------------------------------------*/
+
#ifdef IVAS_FLOAT_FIXED
static void ivas_spar_dec_compute_ramp_down_post_matrix_fx(
ivas_spar_md_dec_state_t *hMdDec,
@@ -4089,20 +4174,22 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix_fx(
num_out_ch = hMdDec->spar_md_cfg.num_umx_chs;
move16();
move16();
- IF( EQ_16( bfi, 0 ) )
+ IF( bfi == 0 )
{
hMdDec->spar_plc_num_lost_frames = 0;
move16();
}
ELSE
{
- IF( EQ_16( hMdDec->td_decorr_flag, 0 ) )
+ IF( hMdDec->td_decorr_flag == 0 )
{
assert( 0 );
}
hMdDec->spar_plc_num_lost_frames = add( hMdDec->spar_plc_num_lost_frames, 1 );
+ move16();
hMdDec->spar_plc_num_lost_frames = s_min( hMdDec->spar_plc_num_lost_frames, 100 ); /*hMdDec->spar_plc_num_lost_frames is always <=100*/
+ move16();
IF( GT_16( hMdDec->spar_plc_num_lost_frames, ivas_spar_dec_plc_num_frames_keep ) ) /*if control enters then ivas_spar_dec_plc_num_frames_keep<100 */
{
@@ -4115,14 +4202,17 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix_fx(
Word16 norm_nff; /*norm of num_fade_frames*/
num_fade_frames = s_max( sub( hMdDec->spar_plc_num_lost_frames, ivas_spar_dec_plc_num_frames_keep ), 0 );
norm_nff = norm_s( num_fade_frames );
- gain_dB = -imult1616( s_min( num_fade_frames, ivas_spar_dec_plc_max_num_frames_ramp_down ), ivas_spar_dec_plc_per_frame_ramp_down_gain_dB ); /*abs(gain_dB)<99*/ /*Q(gain_dB)=7Q24*/
- Word16 exp_gain = 0; /*stores exponent for gain_fx*/
+ gain_dB = negate( imult1616( s_min( num_fade_frames, ivas_spar_dec_plc_max_num_frames_ramp_down ), ivas_spar_dec_plc_per_frame_ramp_down_gain_dB ) ); /*abs(gain_dB)<99*/ /*Q(gain_dB)=7Q24*/
+ Word16 exp_gain = 0;
+ move16(); /*stores exponent for gain_fx*/
gain_fx = BASOP_util_Pow2( Mult_32_16( imult3216( 13421773 /*=2^28/20*/, gain_dB ), 27213 /*=log2(10)*2^13*/ ), 5, &exp_gain );
Q_gain = sub( 31, exp_gain );
FOR( i = 0; i < IVAS_SPAR_MAX_CH; i++ )
{
- post_matrix_fx[i] = add( shl( 1, norm_nff ), mult( s_min( mult( shl( num_fade_frames, norm_nff ), div_s( 1, ivas_spar_dec_plc_num_frames_fade_out ) ), shl( 1, norm_nff ) ), shl( sub( ivas_spar_dec_plc_spatial_target[i], 1 ), 15 ) ) ); /*Q=norm_nff*/
- post_matrix_fx[i] = Mult_32_16( gain_fx, (Word16) post_matrix_fx[i] ); /*Q_gain+norm_nff-15*/
+ post_matrix_fx[i] = add( shl( 1, norm_nff ), mult( s_min( mult( shl( num_fade_frames, norm_nff ), 3640 /* 1 / ivas_spar_dec_plc_num_frames_fade_out in Q15 */ ), shl( 1, norm_nff ) ), shl( sub( ivas_spar_dec_plc_spatial_target[i], 1 ), 15 ) ) ); /*Q=norm_nff*/
+ move32();
+ post_matrix_fx[i] = Mult_32_16( gain_fx, extract_l( post_matrix_fx[i] ) ); /*Q_gain+norm_nff-15*/
+ move32();
}
Q_post_matrix = sub( add( Q_gain, norm_nff ), 15 );
/* apply the post matrix */
@@ -4134,19 +4224,20 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix_fx(
{
FOR( b = 0; b < num_bands_out; b++ )
{
- hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = Mult_32_32( hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], post_matrix_fx[i] );
+ hMdDec->mixer_mat_fx[i][j][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] = Mult_32_32( hMdDec->mixer_mat_fx[i][j][add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )], post_matrix_fx[i] );
+ move32();
}
}
}
}
hMdDec->Q_mixer_mat = sub( add( Q_post_matrix, hMdDec->Q_mixer_mat ), 31 );
+ move16();
}
}
return;
}
#else
-
static void ivas_spar_dec_compute_ramp_down_post_matrix(
ivas_spar_md_dec_state_t *hMdDec,
const int16_t num_bands_out,
@@ -4219,56 +4310,47 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix(
#ifdef IVAS_FLOAT_FIXED
static void ivas_spar_unquant_dtx_indicies(
ivas_spar_md_t *pSpar_md,
- const int16_t nB,
- const int16_t bw,
- int16_t *ndm_per_band )
+ const Word16 nB,
+ const Word16 bw,
+ Word16 *ndm_per_band )
{
- int16_t i, b;
- int16_t q_lvl;
+ Word16 i, b;
+ Word16 q_lvl;
// float val;
Word32 val_fx;
- int16_t idx;
+ Word16 idx;
// float pr_min_max[2];
Word32 pr_min_max_fx[2];
- // pr_min_max[0] = pSpar_md->min_max[0];
- // pr_min_max[1] = pSpar_md->min_max[1];
-
pr_min_max_fx[0] = pSpar_md->min_max_fx[0];
+ move32();
pr_min_max_fx[1] = pSpar_md->min_max_fx[1];
+ move32();
- for ( b = 0; b < nB; b++ )
+ FOR( b = 0; b < nB; b++ )
{
- for ( i = 0; i < FOA_CHANNELS - 1; i++ )
+ FOR( i = 0; i < FOA_CHANNELS - 1; i++ )
{
- q_lvl = dtx_pr_real_q_levels[ndm_per_band[bw * b] - 1][i];
- // idx = pSpar_md->band_coeffs_idx[b].pred_index_re[i];
- // ivas_deindex_real_index( &idx, q_lvl, pr_min_max[0], pr_min_max[1], &val, 1 );
- // pSpar_md->band_coeffs[b].pred_re[i] = val;
- // pSpar_md->band_coeffs[b].pred_re_fx[i] = val * (1 << 22);
+ q_lvl = dtx_pr_real_q_levels[sub( ndm_per_band[i_mult( bw, b )], 1 )][i];
+ move16();
idx = pSpar_md->band_coeffs_idx[b].pred_index_re[i];
+ move16();
ivas_deindex_real_index_fx( &idx, q_lvl, pr_min_max_fx[0], pr_min_max_fx[1], &val_fx, 1 );
pSpar_md->band_coeffs[b].pred_re_fx[i] = val_fx;
-#if 0 // ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED
- pSpar_md->band_coeffs[b].pred_re[i] = (float)val_fx / (1 << 22);
-#endif
+ move32();
}
- for ( i = 0; i < FOA_CHANNELS - ndm_per_band[bw * b]; i++ )
+ FOR( i = 0; i < sub( FOA_CHANNELS, ndm_per_band[i_mult( bw, b )] ); i++ )
{
- q_lvl = dtx_pd_real_q_levels[ndm_per_band[bw * b] - 1][i];
- // idx = pSpar_md->band_coeffs_idx[b].decd_index_re[i];
- // ivas_deindex_real_index( &idx, q_lvl, dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], &val, 1 );
- // pSpar_md->band_coeffs[b].P_re[i] = val;
- // pSpar_md->band_coeffs[b].P_re_fx[i] = val*(1<<22);
+ q_lvl = dtx_pd_real_q_levels[sub( ndm_per_band[i_mult( bw, b )], 1 )][i];
+ move16();
idx = pSpar_md->band_coeffs_idx[b].decd_index_re[i];
+ move16();
ivas_deindex_real_index_fx( &idx, q_lvl, dtx_pd_real_min_max_fx[0], dtx_pd_real_min_max_fx[1], &val_fx, 1 );
pSpar_md->band_coeffs[b].P_re_fx[i] = val_fx;
-#if 0 // ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED
- pSpar_md->band_coeffs[b].P_re[i] = (float)val_fx / (1 << 22);
-#endif
+ move32();
}
}
@@ -4322,91 +4404,110 @@ static void ivas_spar_unquant_dtx_indicies(
static void ivas_parse_parameter_bitstream_dtx(
ivas_spar_md_t *pSpar_md,
Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/
- const int16_t bw,
- const int16_t num_bands,
- int16_t *num_dmx_per_band,
- int16_t *num_dec_per_band )
+ const Word16 bw,
+ const Word16 num_bands,
+ Word16 *num_dmx_per_band,
+ Word16 *num_dec_per_band )
{
- int16_t i, j, ndec, ndm;
- // float val;
+ Word16 i, j, ndec, ndm;
Word32 val_fx;
- int16_t idx;
- // float pr_min_max[2];
+ Word16 idx;
Word32 pr_min_max_fx[2];
- int16_t pr_q_lvls, pr, pd, pd_q_lvls, pr_pd_bits;
- int16_t zero_pad_bits, sid_bits_len;
+ Word16 pr_q_lvls, pr, pd, pd_q_lvls, pr_pd_bits;
+ Word16 zero_pad_bits, sid_bits_len;
sid_bits_len = st0->next_bit_pos;
- // pr_min_max[0] = pSpar_md->min_max[0];
+ move16();
pr_min_max_fx[0] = pSpar_md->min_max_fx[0];
- // pr_min_max[1] = pSpar_md->min_max[1];
+ move32();
pr_min_max_fx[1] = pSpar_md->min_max_fx[1];
+ move32();
- for ( i = 0; i < num_bands; i++ )
+ FOR( i = 0; i < num_bands; i++ )
{
- ndec = num_dec_per_band[bw * i];
- ndm = num_dmx_per_band[bw * i];
+ ndec = num_dec_per_band[i_mult( bw, i )];
+ move16();
+ ndm = num_dmx_per_band[i_mult( bw, i )];
+ move16();
- for ( j = 0; j < FOA_CHANNELS - 1; j++ )
+ FOR( j = 0; j < FOA_CHANNELS - 1; j++ )
{
- int16_t pr_idx_1, pr_idx_2, pd_idx_1, pd_idx_2;
- uint16_t value;
+ Word16 pr_idx_1, pr_idx_2, pd_idx_1, pd_idx_2;
+ UWord16 value;
pr_idx_1 = pr_pr_idx_pairs[ndm - 1][j][0];
+ move16();
pr_idx_2 = pr_pr_idx_pairs[ndm - 1][j][1];
+ move16();
pd_idx_1 = pr_pd_idx_pairs[ndm - 1][j][0];
+ move16();
pd_idx_2 = pr_pd_idx_pairs[ndm - 1][j][1];
+ move16();
- if ( pr_idx_1 != 0 || pd_idx_1 != 0 || pr_idx_2 != 0 || pd_idx_2 != 0 )
+ test();
+ test();
+ test();
+ IF( pr_idx_1 != 0 || pd_idx_1 != 0 || pr_idx_2 != 0 || pd_idx_2 != 0 )
{
pr_q_lvls = dtx_pr_real_q_levels[ndm - 1][pd_idx_1 - 1];
+ move16();
- if ( ( j + 1 ) > ndec )
+ IF( GT_16( add( j, 1 ), ndec ) )
{
pd_q_lvls = 1;
+ move16();
}
- else
+ ELSE
{
pd_q_lvls = dtx_pd_real_q_levels[ndm - 1][pd_idx_2 - 1];
+ move16();
}
- pr_pd_bits = ivas_get_bits_to_encode( pd_q_lvls * pr_q_lvls );
+ pr_pd_bits = ivas_get_bits_to_encode( L_mult0( pd_q_lvls, pr_q_lvls ) );
value = get_next_indice( st0, pr_pd_bits );
- pr = (int16_t) floor( value / pd_q_lvls );
- pd = value - pr * pd_q_lvls;
- // val = dtx_pd_real_min_max[0];
+ IF( value != 0 )
+ {
+ pr = idiv1616( value, pd_q_lvls );
+ }
+ ELSE
+ {
+ pr = 0;
+ move16();
+ }
+ pd = extract_l( L_sub( value, i_mult( pr, pd_q_lvls ) ) );
val_fx = dtx_pd_real_min_max_fx[0];
- // ivas_quantise_real_values( &val, pd_q_lvls, dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], &idx, &val, 1 );
+ move32();
ivas_quantise_real_values_fx( &val_fx, pd_q_lvls, dtx_pd_real_min_max_fx[0], dtx_pd_real_min_max_fx[1], &idx, &val_fx, 1 );
- pd = pd + idx;
+ pd = add( pd, idx );
- // val = pr_min_max[0];
val_fx = pr_min_max_fx[0];
- // ivas_quantise_real_values( &val, pr_q_lvls, pr_min_max[0], pr_min_max[1], &idx, &val, 1 );
+ move32();
ivas_quantise_real_values_fx( &val_fx, pr_q_lvls, pr_min_max_fx[0], pr_min_max_fx[1], &idx, &val_fx, 1 );
- pr = pr + idx;
+ pr = add( pr, idx );
- if ( ( j + 1 ) <= ndec )
+ if ( LE_16( add( j, 1 ), ndec ) )
{
pSpar_md->band_coeffs_idx[i].decd_index_re[pd_idx_2 - 1] = pd;
+ move16();
}
pSpar_md->band_coeffs_idx[i].pred_index_re[pd_idx_1 - 1] = pr;
+ move16();
}
}
}
- sid_bits_len = st0->next_bit_pos - sid_bits_len;
- zero_pad_bits = ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - sid_bits_len;
+ sid_bits_len = sub( st0->next_bit_pos, sid_bits_len );
+ zero_pad_bits = sub( ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ), sid_bits_len );
assert( zero_pad_bits >= 0 );
- if ( num_dmx_per_band[0] == 2 )
+ if ( EQ_16( num_dmx_per_band[0], 2 ) )
{
- zero_pad_bits -= 1;
+ zero_pad_bits = sub( zero_pad_bits, 1 );
}
- for ( j = 0; j < zero_pad_bits; j++ )
+ FOR( j = 0; j < zero_pad_bits; j++ )
{
get_next_indice( st0, 1 );
}
@@ -4550,34 +4651,36 @@ static ivas_error ivas_deindex_real_index(
#else
static ivas_error ivas_deindex_real_index_fx(
- const int16_t *index,
- const int16_t q_levels,
+ const Word16 *index,
+ const Word16 q_levels,
const Word32 min_value,
const Word32 max_value,
Word32 *quant,
- const int16_t dim )
+ const Word16 dim )
{
- int16_t i;
+ Word16 i;
Word32 q_step_fx;
- if ( q_levels == 0 )
+ IF( q_levels == 0 )
{
return IVAS_ERR_INTERNAL;
}
- if ( q_levels == 1 )
+ IF( EQ_16( q_levels, 1 ) )
{
- for ( i = 0; i < dim; i++ )
+ FOR( i = 0; i < dim; i++ )
{
quant[i] = 0;
+ move32();
}
}
- else
+ ELSE
{
q_step_fx = L_sub( max_value, min_value );
- q_step_fx = Mpy_32_32( q_step_fx, one_by_q_level[( q_levels - 1 )] );
- for ( i = 0; i < dim; i++ )
+ q_step_fx = Mpy_32_32( q_step_fx, one_by_q_level[q_levels - 1] );
+ FOR( i = 0; i < dim; i++ )
{
quant[i] = Mpy_32_32( L_shl( index[i], 31 - 6 ), q_step_fx ); //(25+28)-31 = 22
+ move32();
}
}
@@ -4865,122 +4968,157 @@ void ivas_spar_to_dirac(
void ivas_spar_to_dirac_fx(
Decoder_Struct *st_ivas,
ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
- const int16_t dtx_vad, /* i : DTX frame flag */
- const int16_t num_bands_out, /* i : number of output bands */
- const int16_t bw, /* i : band joining factor */
- const int16_t dyn_active_w_flag )
+ const Word16 dtx_vad, /* i : DTX frame flag */
+ const Word16 num_bands_out, /* i : number of output bands */
+ const Word16 bw, /* i : band joining factor */
+ const Word16 dyn_active_w_flag )
{
DIRAC_DEC_HANDLE hDirAC;
- int16_t start_band, end_band, band, qmf_band_start, qmf_band_end;
- int16_t block, b;
- int16_t *band_grouping;
- // float diffuseness[IVAS_MAX_NUM_BANDS];
+ Word16 start_band, end_band, band, qmf_band_start, qmf_band_end;
+ Word16 block, b;
+ Word16 *band_grouping;
+
Word32 diffuseness_fx[IVAS_MAX_NUM_BANDS];
- int16_t sba_order_internal;
- // float azi_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES];
+ Word16 sba_order_internal;
+
Word32 azi_dirac_fx[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES];
- // float ele_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES];
+
Word32 ele_dirac_fx[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES];
- int16_t azi[IVAS_MAX_NUM_BANDS];
- int16_t ele[IVAS_MAX_NUM_BANDS];
- // float dvx[IVAS_MAX_NUM_BANDS], dvy[IVAS_MAX_NUM_BANDS], dvz[IVAS_MAX_NUM_BANDS];
+ Word16 azi[IVAS_MAX_NUM_BANDS];
+ Word16 ele[IVAS_MAX_NUM_BANDS];
+
Word32 dvx_fx[IVAS_MAX_NUM_BANDS], dvy_fx[IVAS_MAX_NUM_BANDS], dvz_fx[IVAS_MAX_NUM_BANDS];
- // float radius;
+
Word32 radius_fx;
- // float en_ratio, res_pow;
+
Word32 en_ratio_fx, res_pow_fx;
Word16 en_ratio_q;
- int16_t num_slots_in_subfr;
- int16_t tmp_write_idx_param_band;
- int16_t tmp_write_idx_band;
- // float pred_re_20ms[IVAS_MAX_NUM_BANDS][IVAS_SPAR_MAX_CH - 1];
+ Word16 num_slots_in_subfr;
+ Word16 tmp_write_idx_param_band;
+ Word16 tmp_write_idx_band;
+
Word32 pred_re_20ms_fx[IVAS_MAX_NUM_BANDS][IVAS_SPAR_MAX_CH - 1];
- int16_t pred_idx;
- int16_t *dirac_to_spar_md_bands;
- int16_t enc_param_start_band;
- int16_t active_w_vlbr;
- int16_t i, num_subframes;
- int16_t active_w;
+ Word16 pred_idx;
+ Word16 *dirac_to_spar_md_bands;
+ Word16 enc_param_start_band;
+ Word16 active_w_vlbr;
+ Word16 i, num_subframes;
+ Word16 active_w;
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
- active_w = ( dyn_active_w_flag == 1 ) || ( hMdDec->spar_md_cfg.active_w == 1 );
+ test();
+ active_w = EQ_16( dyn_active_w_flag, 1 ) || EQ_16( hMdDec->spar_md_cfg.active_w, 1 );
sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER );
+ move16();
start_band = 0;
- end_band = min( num_bands_out, SPAR_DIRAC_SPLIT_START_BAND ) / bw;
+ move16();
+ end_band = idiv1616( min( num_bands_out, SPAR_DIRAC_SPLIT_START_BAND ), bw );
hDirAC = st_ivas->hDirAC;
hSpatParamRendCom = st_ivas->hSpatParamRendCom;
dirac_to_spar_md_bands = st_ivas->hSpar->dirac_to_spar_md_bands;
- enc_param_start_band = st_ivas->hSpar->enc_param_start_band / bw;
- active_w_vlbr = ( st_ivas->hDecoderConfig->ivas_total_brate < IVAS_24k4 ) ? 1 : 0;
- if ( hDirAC != NULL && ivas_get_hodirac_flag( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ) == 0 )
+ IF( st_ivas->hSpar->enc_param_start_band > 0 )
+ {
+ enc_param_start_band = idiv1616( st_ivas->hSpar->enc_param_start_band, bw );
+ }
+ ELSE
+ {
+ enc_param_start_band = 0;
+ move16();
+ }
+
+ IF( LT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_24k4 ) )
+ {
+ active_w_vlbr = 1;
+ move16();
+ }
+ ELSE
+ {
+ active_w_vlbr = 0;
+ move16();
+ }
+
+ test();
+ IF( hDirAC != NULL && ivas_get_hodirac_flag_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ) == 0 )
{
band_grouping = hDirAC->band_grouping;
- num_slots_in_subfr = st_ivas->hDirAC->hConfig->dec_param_estim ? CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES : 1;
- for ( band = start_band; band < end_band; band++ )
+ IF( st_ivas->hDirAC->hConfig->dec_param_estim )
+ {
+ num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES;
+ move16();
+ }
+ ELSE
+ {
+ num_slots_in_subfr = 1;
+ move16();
+ }
+
+ FOR( band = start_band; band < end_band; band++ )
{
- // float PR[3], Pd[3], dvnorm, g_pred;
Word32 PR_fx[3], Pd_fx[3], dvnorm_fx, g_pred_fx;
Word16 q_g_pred;
Word16 q_dvnorm;
- // PR[0] = hMdDec->spar_md.band_coeffs[band].pred_re[2];
PR_fx[0] = hMdDec->spar_md.band_coeffs[band].pred_re_fx[2];
- // PR[1] = hMdDec->spar_md.band_coeffs[band].pred_re[0];
+ move32();
PR_fx[1] = hMdDec->spar_md.band_coeffs[band].pred_re_fx[0];
- // PR[2] = hMdDec->spar_md.band_coeffs[band].pred_re[1];
+ move32();
PR_fx[2] = hMdDec->spar_md.band_coeffs[band].pred_re_fx[1];
- // g_pred = PR[0] * PR[0] + PR[1] * PR[1] + PR[2] * PR[2];
- g_pred_fx = Mpy_32_32( PR_fx[0], PR_fx[0] ) + Mpy_32_32( PR_fx[1], PR_fx[1] ) + Mpy_32_32( PR_fx[2], PR_fx[2] );
+ move32();
+ g_pred_fx = L_add( L_add( Mpy_32_32( PR_fx[0], PR_fx[0] ), Mpy_32_32( PR_fx[1], PR_fx[1] ) ), Mpy_32_32( PR_fx[2], PR_fx[2] ) );
q_g_pred = Q22 + Q22 - Q31;
- q_dvnorm = Q31 - q_g_pred;
+ move16();
+ q_dvnorm = sub( Q31, q_g_pred );
q_g_pred = q_dvnorm;
+ move16();
IF( LE_32( g_pred_fx, EPSILON_FIX ) )
{
dvx_fx[band] = ONE_IN_Q22;
+ move32();
dvy_fx[band] = 0;
+ move32();
dvz_fx[band] = 0;
+ move32();
azi[band] = 0;
+ move16();
ele[band] = 0;
+ move16();
q_g_pred = Q22;
+ move16();
q_dvnorm = Q22;
+ move16();
}
- else
+ ELSE
{
- // g_pred = Sqrt32( g_pred, );
- // dvnorm = 1.0f / g_pred;
dvnorm_fx = ISqrt32( g_pred_fx, &q_dvnorm );
g_pred_fx = Sqrt32( g_pred_fx, &q_g_pred );
- if ( q_g_pred < 0 )
+ IF( q_g_pred < 0 )
{
- g_pred_fx = L_shr( g_pred_fx, ( -1 * q_g_pred ) );
+ g_pred_fx = L_shr( g_pred_fx, negate( q_g_pred ) );
q_g_pred = 0;
+ move16();
}
- /*dvx[band] = PR[0] * dvnorm;
-dvy[band] = PR[1] * dvnorm;
- dvz[band] = PR[2] * dvnorm;*/
-
dvx_fx[band] = Mpy_32_32( PR_fx[0], dvnorm_fx );
+ move32();
dvy_fx[band] = Mpy_32_32( PR_fx[1], dvnorm_fx );
+ move32();
dvz_fx[band] = Mpy_32_32( PR_fx[2], dvnorm_fx );
- Word16 q_1 = ( 22 ) + ( 31 - q_dvnorm ) - 31;
+ move32();
+ Word16 q_1 = sub( add( 22, sub( 31, q_dvnorm ) ), 31 );
- Word32 temp = Mpy_32_32( dvx_fx[band], dvx_fx[band] ) + Mpy_32_32( dvy_fx[band], dvy_fx[band] );
- Word16 q2 = q_1 + q_1 - 31;
- Word16 q_temp = 31 - q2;
+ Word32 temp = L_add( Mpy_32_32( dvx_fx[band], dvx_fx[band] ), Mpy_32_32( dvy_fx[band], dvy_fx[band] ) );
+ Word16 q2 = sub( add( q_1, q_1 ), 31 );
+ Word16 q_temp = sub( 31, q2 );
radius_fx = Sqrt32( temp, &q_temp );
- // radius = sqrtf(dvx[band] * dvx[band] + dvy[band] * dvy[band]);
-
- // float check_qzi = atan2f(dvy[band], dvx[band]);
Word16 check_azi_fx = BASOP_util_atan2( dvy_fx[band], dvx_fx[band], 0 );
Word32 check_azi_fx_32 = L_shl( check_azi_fx, 16 );
Word16 check_azi_fx_res;
- IF( LT_32( check_azi_fx_32, 0 ) )
+ IF( check_azi_fx_32 < 0 )
{
check_azi_fx_res = negate( divide3232( L_negate( check_azi_fx_32 ), 1686629760 ) );
}
@@ -4989,314 +5127,376 @@ dvy[band] = PR[1] * dvnorm;
check_azi_fx_res = divide3232( check_azi_fx_32, 1686629760 );
}
Word32 azi_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_azi_fx_res );
- azi_intermediate = azi_intermediate + ONE_IN_Q21;
- // Word16 azi_res = L_shr_r(azi_intermediate, 22);
- Word16 azi_res = extract_l( azi_intermediate / ( 1 << 22 ) );
+ azi_intermediate = L_add( azi_intermediate, ONE_IN_Q21 );
+
+ Word16 azi_res;
+ IF( azi_intermediate < 0 )
+ {
+ azi_res = negate( extract_l( L_shr( L_negate( azi_intermediate ), 22 ) ) );
+ }
+ ELSE
+ {
+ azi_res = extract_l( L_shr( azi_intermediate, 22 ) );
+ }
- Word16 check_ele_fx = BASOP_util_atan2( dvz_fx[band], radius_fx, ( 9 + q_dvnorm ) - q_temp );
+ Word16 check_ele_fx = BASOP_util_atan2( dvz_fx[band], radius_fx, sub( add( 9, q_dvnorm ), q_temp ) );
Word32 check_ele_fx_32 = L_shl( check_ele_fx, 16 );
Word16 check_ele_fx_res;
- IF( LT_32( check_azi_fx_32, 0 ) )
+ IF( check_azi_fx_32 < 0 )
{
check_ele_fx_res = negate( divide3232( L_negate( check_ele_fx_32 ), 1686629760 ) );
}
- else
+ ELSE
{
check_ele_fx_res = divide3232( check_ele_fx_32, 1686629760 );
}
Word32 ele_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_ele_fx_res );
- ele_intermediate = ele_intermediate + ONE_IN_Q21;
- // Word16 ele_res = L_shr_r(ele_intermediate, 22);
- Word16 ele_res = extract_l( ele_intermediate / ( 1 << 22 ) );
+ ele_intermediate = L_add( ele_intermediate, ONE_IN_Q21 );
+ Word16 ele_res;
+ IF( ele_intermediate < 0 )
+ {
+ ele_res = negate( extract_l( L_shr( L_negate( ele_intermediate ), 22 ) ) );
+ }
+ ELSE
+ {
+ ele_res = extract_l( L_shr( ele_intermediate, 22 ) );
+ }
- // azi[band] = (int16_t)(max(-180.0f, min(180.0f, atan2f(dvy[band], dvx[band]) / EVS_PI * 180.0f)) + 0.5f);
azi[band] = max( -180, min( 180, azi_res ) );
- // ele[band] = (int16_t)(max(-90.0f, min(180.0f, atan2f(dvz[band], radius) / EVS_PI * 180.0f)) + 0.5f);
+ move16();
ele[band] = max( -90, min( 180, ele_res ) );
+ move16();
}
- if ( st_ivas->nchan_transport == 1 )
+ IF( EQ_16( st_ivas->nchan_transport, 1 ) )
{
// float w_en_norm, f_scale;
Word32 w_en_norm_fx, f_scale_fx;
Word16 q_w_en_norm_fx;
- if ( active_w )
+ IF( active_w )
{
- if ( dtx_vad == 0 )
+ IF( dtx_vad == 0 )
{
- // f_scale = IVAS_ACTIVEW_DM_F_SCALE_DTX;
f_scale_fx = IVAS_ACTIVEW_DM_F_SCALE_DTX_FX;
+ move32();
}
- else
+ ELSE
{
- // f_scale = ( active_w_vlbr ) ? IVAS_ACTIVEW_DM_F_SCALE_VLBR : IVAS_ACTIVEW_DM_F_SCALE;
- f_scale_fx = ( active_w_vlbr ) ? IVAS_ACTIVEW_DM_F_SCALE_VLBR_FX : IVAS_ACTIVEW_DM_F_SCALE_FX;
+ IF( active_w_vlbr )
+ {
+ f_scale_fx = IVAS_ACTIVEW_DM_F_SCALE_VLBR_FX;
+ move32();
+ }
+ ELSE
+ {
+ f_scale_fx = IVAS_ACTIVEW_DM_F_SCALE_FX;
+ move32();
+ }
}
}
- else
+ ELSE
{
- // f_scale = 0.0f;
f_scale_fx = 0;
+ move32();
}
- // w_en_norm = ( 1.0f - ( f_scale * g_pred * g_pred ) );
Word32 temp_result = Mpy_32_32( Mpy_32_32( f_scale_fx, g_pred_fx ), g_pred_fx );
temp_result = L_sub( L_shr( ONE_IN_Q31, q_g_pred ), temp_result );
- // w_en_norm *= w_en_norm;
+
w_en_norm_fx = Mpy_32_32( temp_result, temp_result );
- q_w_en_norm_fx = q_g_pred + q_g_pred;
- // Pd[0] = hMdDec->spar_md.band_coeffs[band].P_re[1];
- // Pd[1] = hMdDec->spar_md.band_coeffs[band].P_re[0];
- // Pd[2] = hMdDec->spar_md.band_coeffs[band].P_re[2];
+ q_w_en_norm_fx = add( q_g_pred, q_g_pred );
+
Pd_fx[0] = hMdDec->spar_md.band_coeffs[band].P_re_fx[1];
+ move32();
Pd_fx[1] = hMdDec->spar_md.band_coeffs[band].P_re_fx[0];
+ move32();
Pd_fx[2] = hMdDec->spar_md.band_coeffs[band].P_re_fx[2];
- // en_ratio = PR[0] * PR[0] + PR[1] * PR[1] + PR[2] * PR[2];
- en_ratio_fx = Mpy_32_32( PR_fx[0], PR_fx[0] ) + Mpy_32_32( PR_fx[1], PR_fx[1] ) + Mpy_32_32( PR_fx[2], PR_fx[2] ); // 22+22-31 = 13
- Word32 Pd_temp_res = Mpy_32_32( Pd_fx[0], Pd_fx[0] ) + Mpy_32_32( Pd_fx[1], Pd_fx[1] ) + Mpy_32_32( Pd_fx[2], Pd_fx[2] ); // q = 22+22-31 = 13
- // res_pow = w_en_norm + en_ratio + ( Pd[0] * Pd[0] + Pd[1] * Pd[1] + Pd[2] * Pd[2] );
- res_pow_fx = L_shr( w_en_norm_fx, ( 31 - q_w_en_norm_fx ) - 13 ) + en_ratio_fx + Pd_temp_res;
- // res_pow_q = 13;
+ move32();
+
+ en_ratio_fx = L_add( L_add( Mpy_32_32( PR_fx[0], PR_fx[0] ), Mpy_32_32( PR_fx[1], PR_fx[1] ) ), Mpy_32_32( PR_fx[2], PR_fx[2] ) ); // 22+22-31 = 13
+ Word32 Pd_temp_res = L_add( L_add( Mpy_32_32( Pd_fx[0], Pd_fx[0] ), Mpy_32_32( Pd_fx[1], Pd_fx[1] ) ), Mpy_32_32( Pd_fx[2], Pd_fx[2] ) ); // q = 22+22-31 = 13
+
+ res_pow_fx = L_add( L_shr( w_en_norm_fx, sub( sub( 31, q_w_en_norm_fx ), 13 ) ), L_add( en_ratio_fx, Pd_temp_res ) );
+
res_pow_fx = L_shr( res_pow_fx, 1 );
- // res_pow *= 0.5f;
- // hMdDec->spar_md.en_ratio_slow[band] = 0.75f * hMdDec->spar_md.en_ratio_slow[band] + 0.25f * en_ratio;
- hMdDec->spar_md.en_ratio_slow_fx[band] = Mpy_32_32( 1610612736, hMdDec->spar_md.en_ratio_slow_fx[band] ) + Mpy_32_32( 536870912, en_ratio_fx );
- // hMdDec->spar_md.ref_pow_slow[band] = 0.75f * hMdDec->spar_md.ref_pow_slow[band] + 0.25f * res_pow;
- hMdDec->spar_md.ref_pow_slow_fx[band] = Mpy_32_32( 1610612736, hMdDec->spar_md.ref_pow_slow_fx[band] ) + Mpy_32_32( 536870912, res_pow_fx );
- // en_ratio = sqrtf( hMdDec->spar_md.en_ratio_slow[band] ) / ( hMdDec->spar_md.ref_pow_slow[band] + EPSILON );
+
+ hMdDec->spar_md.en_ratio_slow_fx[band] = L_add( Mpy_32_32( 1610612736, hMdDec->spar_md.en_ratio_slow_fx[band] ), Mpy_32_32( 536870912, en_ratio_fx ) );
+ move32();
+
+ hMdDec->spar_md.ref_pow_slow_fx[band] = L_add( Mpy_32_32( 1610612736, hMdDec->spar_md.ref_pow_slow_fx[band] ), Mpy_32_32( 536870912, res_pow_fx ) );
+ move32();
+
en_ratio_q = 31 - 13;
+ move16();
en_ratio_fx = Sqrt32( hMdDec->spar_md.en_ratio_slow_fx[band], &en_ratio_q );
- if ( en_ratio_q < 0 )
+ IF( en_ratio_q < 0 )
{
- en_ratio_fx = L_shr( en_ratio_fx, -1 * ( en_ratio_q ) );
+ en_ratio_fx = L_shr( en_ratio_fx, negate( en_ratio_q ) );
en_ratio_q = 0;
+ move16();
}
- Word32 en_ratio_fx_scaled = L_shr( en_ratio_fx, ( 31 - en_ratio_q - 13 ) );
- if ( en_ratio_fx_scaled > hMdDec->spar_md.ref_pow_slow_fx[band] )
+ Word32 en_ratio_fx_scaled = L_shr( en_ratio_fx, ( sub( sub( 31, en_ratio_q ), 13 ) ) );
+ IF( GT_32( en_ratio_fx_scaled, hMdDec->spar_md.ref_pow_slow_fx[band] ) )
{
diffuseness_fx[band] = 0;
+ move32();
}
- else if ( en_ratio_fx_scaled == 0 )
+ ELSE IF( en_ratio_fx_scaled == 0 )
{
diffuseness_fx[band] = ONE_IN_Q30;
+ move32();
}
- else if ( en_ratio_fx_scaled == hMdDec->spar_md.ref_pow_slow_fx[band] )
+ ELSE IF( EQ_32( en_ratio_fx_scaled, hMdDec->spar_md.ref_pow_slow_fx[band] ) )
{
diffuseness_fx[band] = ONE_IN_Q30;
+ move32();
}
- else
+ ELSE
{
- en_ratio_fx = divide3232( en_ratio_fx_scaled, ( hMdDec->spar_md.ref_pow_slow_fx[band] + EPSILON_FX ) );
+ en_ratio_fx = divide3232( en_ratio_fx_scaled, L_add( hMdDec->spar_md.ref_pow_slow_fx[band], EPSILON_FX ) );
en_ratio_fx = L_shl( en_ratio_fx, 15 );
- diffuseness_fx[band] = ONE_IN_Q30 - en_ratio_fx;
+ diffuseness_fx[band] = L_sub( ONE_IN_Q30, en_ratio_fx );
+ move32();
}
}
- else
+ ELSE
{
- // en_ratio = PR[0] * PR[0] + PR[1] * PR[1] + PR[2] * PR[2];
- en_ratio_fx = Mpy_32_32( PR_fx[0], PR_fx[0] ) + Mpy_32_32( PR_fx[1], PR_fx[1] ) + Mpy_32_32( PR_fx[2], PR_fx[2] );
- // hMdDec->spar_md.en_ratio_slow[band] = 0.75f * hMdDec->spar_md.en_ratio_slow[band] + 0.25f * en_ratio;
- hMdDec->spar_md.en_ratio_slow_fx[band] = Mpy_32_32( 1610612736, hMdDec->spar_md.en_ratio_slow_fx[band] ) + Mpy_32_32( 536870912, en_ratio_fx );
- // en_ratio = sqrtf( hMdDec->spar_md.en_ratio_slow[band] );
+ en_ratio_fx = L_add( L_add( Mpy_32_32( PR_fx[0], PR_fx[0] ), Mpy_32_32( PR_fx[1], PR_fx[1] ) ), Mpy_32_32( PR_fx[2], PR_fx[2] ) );
+
+ hMdDec->spar_md.en_ratio_slow_fx[band] = L_add( Mpy_32_32( 1610612736, hMdDec->spar_md.en_ratio_slow_fx[band] ), Mpy_32_32( 536870912, en_ratio_fx ) );
+ move32();
+
en_ratio_q = 31 - 13;
+ move16();
en_ratio_fx = Sqrt32( hMdDec->spar_md.en_ratio_slow_fx[band], &en_ratio_q );
- if ( en_ratio_q < 0 )
+ IF( en_ratio_q < 0 )
{
- en_ratio_fx = L_shr( en_ratio_fx, -1 * ( en_ratio_q ) );
+ en_ratio_fx = L_shr( en_ratio_fx, ( -en_ratio_q ) );
en_ratio_q = 0;
+ move16();
}
Word32 en_ratio_fx_scaled = L_shr( en_ratio_fx, 1 );
- if ( en_ratio_fx_scaled > ONE_IN_Q30 )
+ IF( GT_32( en_ratio_fx_scaled, ONE_IN_Q30 ) )
{
diffuseness_fx[band] = 0;
+ move32();
}
- else
+ ELSE
{
- diffuseness_fx[band] = ONE_IN_Q30 - en_ratio_fx_scaled;
+ diffuseness_fx[band] = L_sub( ONE_IN_Q30, en_ratio_fx_scaled );
+ move32();
}
}
- // diffuseness[band] = 1.0f - en_ratio; /*compute diffuseness*/
- // diffuseness[band] = ( ( diffuseness[band] < 1.0f ) ? ( ( diffuseness[band] < 0.0f ) ? 0.f : diffuseness[band] ) : 1.0f );
- // diffuseness[band] = (float)diffuseness_fx[band] / (1 << 30);
}
- for ( band = start_band; band < end_band; band++ )
+ FOR( band = start_band; band < end_band; band++ )
{
- int16_t azi_dith, ele_dith;
+ Word16 azi_dith, ele_dith;
tmp_write_idx_param_band = hDirAC->spar_to_dirac_write_idx;
+ move16();
+
+ en_ratio_fx = L_sub( ONE_IN_Q30, diffuseness_fx[band] );
+
+ masa_sq_fx( L_sub( ONE_IN_Q30, en_ratio_fx ), diffuseness_thresholds_fx, DIRAC_DIFFUSE_LEVELS );
- // en_ratio = 1.0f - diffuseness[band];
- en_ratio_fx = ONE_IN_Q30 - diffuseness_fx[band];
- // en_ratio = (float)en_ratio_fx / (1 << 30);
- // cam delete the below function call
- // masa_sq( 1.0f - en_ratio, diffuseness_thresholds, DIRAC_DIFFUSE_LEVELS );
- //#ifdef IVAS_FLOAT_FIXED
- masa_sq_fx( ONE_IN_Q30 - en_ratio_fx, diffuseness_thresholds_fx, DIRAC_DIFFUSE_LEVELS );
- //#endif
qmf_band_start = band_grouping[band];
+ move16();
qmf_band_end = band_grouping[band + 1];
+ move16();
- for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ )
+ FOR( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ )
{
- int16_t ts_start, ts_end, ts;
+ Word16 ts_start, ts_end, ts;
ts_start = DirAC_block_grouping[block];
+ move16();
ts_end = DirAC_block_grouping[block + 1];
- for ( b = qmf_band_start; b < qmf_band_end; b++ )
+ move16();
+ FOR( b = qmf_band_start; b < qmf_band_end; b++ )
{
azi_dith = azi[band];
+ move16();
ele_dith = ele[band];
+ move16();
hSpatParamRendCom->energy_ratio1_fx[block][b] = en_ratio_fx;
+ move32();
tmp_write_idx_band = tmp_write_idx_param_band;
+ move16();
- if ( hDirAC->hConfig->dec_param_estim == FALSE )
+ IF( hDirAC->hConfig->dec_param_estim == FALSE )
{
hSpatParamRendCom->elevation[tmp_write_idx_band][b] = ele_dith;
+ move16();
hSpatParamRendCom->azimuth[tmp_write_idx_band][b] = azi_dith;
+ move16();
hSpatParamRendCom->diffuseness_vector_fx[tmp_write_idx_band][b] = diffuseness_fx[band];
+ move32();
}
- else
+ ELSE
{
- for ( ts = ts_start; ts < ts_end; ts++ )
+ FOR( ts = ts_start; ts < ts_end; ts++ )
{
hSpatParamRendCom->elevation[tmp_write_idx_band][b] = ele_dith;
+ move16();
hSpatParamRendCom->azimuth[tmp_write_idx_band][b] = azi_dith;
+ move16();
hSpatParamRendCom->diffuseness_vector_fx[tmp_write_idx_band][b] = diffuseness_fx[band];
- tmp_write_idx_band = ( tmp_write_idx_band + 1 ) % hSpatParamRendCom->dirac_md_buffer_length;
+ move32();
+ tmp_write_idx_band = add( tmp_write_idx_band, 1 ) % hSpatParamRendCom->dirac_md_buffer_length;
+ move16();
}
}
}
- tmp_write_idx_param_band = ( tmp_write_idx_param_band + num_slots_in_subfr ) % hSpatParamRendCom->dirac_md_buffer_length;
+ tmp_write_idx_param_band = add( tmp_write_idx_param_band, num_slots_in_subfr ) % hSpatParamRendCom->dirac_md_buffer_length;
+ move16();
}
}
/* update buffer write index */
- if ( hDirAC->hConfig->dec_param_estim == FALSE )
+ IF( hDirAC->hConfig->dec_param_estim == FALSE )
{
- hDirAC->spar_to_dirac_write_idx = ( hDirAC->spar_to_dirac_write_idx + MAX_PARAM_SPATIAL_SUBFRAMES ) % hSpatParamRendCom->dirac_md_buffer_length;
+ hDirAC->spar_to_dirac_write_idx = add( hDirAC->spar_to_dirac_write_idx, MAX_PARAM_SPATIAL_SUBFRAMES ) % hSpatParamRendCom->dirac_md_buffer_length;
+ move16();
}
- else
+ ELSE
{
- hDirAC->spar_to_dirac_write_idx = ( hDirAC->spar_to_dirac_write_idx + CLDFB_NO_COL_MAX ) % hSpatParamRendCom->dirac_md_buffer_length;
+ hDirAC->spar_to_dirac_write_idx = add( hDirAC->spar_to_dirac_write_idx, CLDFB_NO_COL_MAX ) % hSpatParamRendCom->dirac_md_buffer_length;
+ move16();
}
}
- else
+ ELSE
{
band = end_band;
+ move16();
}
/*read DirAC metadata, convert DirAC to SPAR*/
- for ( ; band < num_bands_out / bw; band++ )
+ FOR( ; band < idiv1616( num_bands_out, bw ); band++ )
{
- int16_t dirac_band_idx;
+ Word16 dirac_band_idx;
- dirac_band_idx = dirac_to_spar_md_bands[band] - enc_param_start_band;
+ dirac_band_idx = sub( dirac_to_spar_md_bands[band], enc_param_start_band );
num_subframes = MAX_PARAM_SPATIAL_SUBFRAMES;
+ move16();
if ( st_ivas->hQMetaData->useLowerRes )
{
num_subframes = 1;
+ move16();
}
- for ( block = 0; block < num_subframes; block++ )
+ FOR( block = 0; block < num_subframes; block++ )
{
- // if ( st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].azimuth[block] < 0.f )
- //{
- // st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].azimuth[block] += 360.f;
- // }
- if ( st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].azimuth_fx[block] < 0 )
+
+ IF( st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].azimuth_fx[block] < 0 )
{
st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].azimuth_fx[block] =
L_add( L_shl( 360, 22 ), st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].azimuth_fx[block] );
+ move32();
}
- // azi_dirac[band][block] = st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].azimuth[block];
- // ele_dirac[band][block] = st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].elevation[block];
- //#ifdef IVAS_FLOAT_FIXED
+
azi_dirac_fx[band][block] = st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].azimuth_fx[block];
+ move32();
ele_dirac_fx[band][block] = st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].elevation_fx[block];
- //#endif
+ move32();
}
- // diffuseness[band] = 1.0f - st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].energy_ratio[0];
- //#ifdef IVAS_FLOAT_FIXED
- diffuseness_fx[band] = ONE_IN_Q30 - st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].energy_ratio_fx[0];
- //#endif
+ diffuseness_fx[band] = L_sub( ONE_IN_Q30, st_ivas->hQMetaData->q_direction->band_data[dirac_band_idx].energy_ratio_fx[0] );
+ move32();
}
/* DirAC MD averaged over 4 subframes and converted to SPAR format similar to encoder processing */
- if ( hMdDec->spar_md_cfg.nchan_transport > 1 )
+ IF( GT_16( hMdDec->spar_md_cfg.nchan_transport, 1 ) )
{
-#ifdef IVAS_FLOAT_FIXED
- ivas_get_spar_md_from_dirac_fx( azi_dirac_fx, ele_dirac_fx, diffuseness_fx, 1, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr, dyn_active_w_flag );
-#else
- ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr, dyn_active_w_flag );
-#endif
+ Word16 order;
+ IF( hMdDec->spar_hoa_md_flag )
+ {
+ order = 1;
+ move16();
+ }
+ ELSE
+ {
+ order = sba_order_internal;
+ move16();
+ }
+ ivas_get_spar_md_from_dirac_fx( azi_dirac_fx, ele_dirac_fx, diffuseness_fx, 1, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out, order, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr, dyn_active_w_flag );
/* temporarily copy frame-wise prediction coefficients in DirAC bands*/
- for ( pred_idx = 0; pred_idx < FOA_CHANNELS - 1; pred_idx++ )
+ FOR( pred_idx = 0; pred_idx < FOA_CHANNELS - 1; pred_idx++ )
{
- for ( band = SPAR_DIRAC_SPLIT_START_BAND; band < IVAS_MAX_NUM_BANDS; band++ )
+ FOR( band = SPAR_DIRAC_SPLIT_START_BAND; band < IVAS_MAX_NUM_BANDS; band++ )
{
- // pred_re_20ms[band][pred_idx] = hMdDec->spar_md.band_coeffs[band].pred_re[pred_idx];
pred_re_20ms_fx[band][pred_idx] = hMdDec->spar_md.band_coeffs[band].pred_re_fx[pred_idx];
+ move32();
}
}
}
- int16_t num_md_sub_frames;
+ Word16 num_md_sub_frames;
num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate );
- //#ifdef IVAS_FLOAT_FIXED
- ivas_get_spar_md_from_dirac_fx( azi_dirac_fx, ele_dirac_fx, diffuseness_fx, num_md_sub_frames, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr, dyn_active_w_flag );
- //#else
- // ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, num_md_sub_frames, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr, dyn_active_w_flag );
- //#endif
- if ( st_ivas->hQMetaData->useLowerRes && dtx_vad )
+
+ Word16 order;
+ IF( hMdDec->spar_hoa_md_flag )
{
- for ( band = SPAR_DIRAC_SPLIT_START_BAND; band < IVAS_MAX_NUM_BANDS; band++ )
+ order = 1;
+ move16();
+ }
+ ELSE
+ {
+ order = sba_order_internal;
+ move16();
+ }
+ ivas_get_spar_md_from_dirac_fx( azi_dirac_fx, ele_dirac_fx, diffuseness_fx, num_md_sub_frames, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, idiv1616( num_bands_out, bw ), order, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr, dyn_active_w_flag );
+
+ test();
+ IF( st_ivas->hQMetaData->useLowerRes && dtx_vad )
+ {
+ FOR( band = SPAR_DIRAC_SPLIT_START_BAND; band < IVAS_MAX_NUM_BANDS; band++ )
{
- for ( block = 1; block < num_md_sub_frames; block++ )
+ FOR( block = 1; block < num_md_sub_frames; block++ )
{
- for ( i = 0; i < FOA_CHANNELS - 1; i++ ) /* pred coefficient index (index 0, 1, 2 predicts Y, Z, X respectively) */
+ FOR( i = 0; i < FOA_CHANNELS - 1; i++ ) /* pred coefficient index (index 0, 1, 2 predicts Y, Z, X respectively) */
{
- // hMdDec->spar_md.band_coeffs[band + block * IVAS_MAX_NUM_BANDS].pred_re[i] = hMdDec->spar_md.band_coeffs[band].pred_re[i];
- hMdDec->spar_md.band_coeffs[band + block * IVAS_MAX_NUM_BANDS].pred_re_fx[i] = hMdDec->spar_md.band_coeffs[band].pred_re_fx[i];
+ hMdDec->spar_md.band_coeffs[add( band, i_mult( block, IVAS_MAX_NUM_BANDS ) )].pred_re_fx[i] = hMdDec->spar_md.band_coeffs[band].pred_re_fx[i];
+ move32();
}
- for ( i = 0; i < FOA_CHANNELS - 1; i++ ) /* pred coefficient index (index 0, 1, 2 predicts Y, Z, X respectively) */
+ FOR( i = 0; i < FOA_CHANNELS - 1; i++ ) /* pred coefficient index (index 0, 1, 2 predicts Y, Z, X respectively) */
{
- // hMdDec->spar_md.band_coeffs[band + block * IVAS_MAX_NUM_BANDS].P_re[i] = hMdDec->spar_md.band_coeffs[band].P_re[i];
- hMdDec->spar_md.band_coeffs[band + block * IVAS_MAX_NUM_BANDS].P_re_fx[i] = hMdDec->spar_md.band_coeffs[band].P_re_fx[i];
+ hMdDec->spar_md.band_coeffs[add( band, i_mult( block, IVAS_MAX_NUM_BANDS ) )].P_re_fx[i] = hMdDec->spar_md.band_coeffs[band].P_re_fx[i];
+ move32();
}
}
}
}
/* expand DirAC TC 20ms MD for residual channels to all subframes*/
- for ( block = 0; block < num_md_sub_frames; block++ )
+ FOR( block = 0; block < num_md_sub_frames; block++ )
{
- for ( band = SPAR_DIRAC_SPLIT_START_BAND; band < IVAS_MAX_NUM_BANDS; band++ )
+ FOR( band = SPAR_DIRAC_SPLIT_START_BAND; band < IVAS_MAX_NUM_BANDS; band++ )
{
- for ( pred_idx = 0; pred_idx < FOA_CHANNELS - 1; pred_idx++ ) /* pred coefficient index (index 0, 1, 2 predicts Y, Z, X respectively) */
+ FOR( pred_idx = 0; pred_idx < FOA_CHANNELS - 1; pred_idx++ ) /* pred coefficient index (index 0, 1, 2 predicts Y, Z, X respectively) */
{
- if ( ivas_is_res_channel( pred_idx + 1, hMdDec->spar_md_cfg.nchan_transport ) )
+ IF( ivas_is_res_channel( add( pred_idx, 1 ), hMdDec->spar_md_cfg.nchan_transport ) )
{
/* use 20ms coefficients only for residual channels */
- // hMdDec->spar_md.band_coeffs[band + block * IVAS_MAX_NUM_BANDS].pred_re[pred_idx] = pred_re_20ms[band][pred_idx];
- hMdDec->spar_md.band_coeffs[band + block * IVAS_MAX_NUM_BANDS].pred_re_fx[pred_idx] = pred_re_20ms_fx[band][pred_idx];
+ hMdDec->spar_md.band_coeffs[add( band, i_mult( block, IVAS_MAX_NUM_BANDS ) )].pred_re_fx[pred_idx] = pred_re_20ms_fx[band][pred_idx];
+ move32();
}
}
}
}
- for ( b = end_band * bw; b < num_bands_out; b++ )
+ FOR( b = i_mult( end_band, bw ); b < num_bands_out; b++ )
{
hMdDec->valid_bands[b] = 1;
+ move16();
}
return;
diff --git a/lib_dec/ivas_stereo_adapt_GR_dec.c b/lib_dec/ivas_stereo_adapt_GR_dec.c
index 79b9d272f23bf36bced4fc77fba3066803073de1..6eaef9c9e295b4678a442ef35e01b31acc529538 100644
--- a/lib_dec/ivas_stereo_adapt_GR_dec.c
+++ b/lib_dec/ivas_stereo_adapt_GR_dec.c
@@ -61,28 +61,35 @@ static Word16 read_GR2(
p = bit_stream;
nb = 0;
+ move16();
FOR( i = 0; i < len; i++ )
{
ready = 0;
+ move16();
temp = 0;
+ move16();
DO
{
b = *p++;
- IF( EQ_16( (Word16) b, 0 ) )
+ move16();
+ IF( b == 0 )
{
ready = 1;
+ move16();
}
ELSE
{
- temp = add( (Word16) temp, 1 );
+ temp = (UWord16) ( L_add( temp, 1 ) );
}
}
- WHILE( EQ_16( (Word16) ready, 0 ) );
+ WHILE( ready == 0 );
b = *p++;
- b = (UWord16) add( shl( (Word16) b, 1 ), (Word16) *p++ );
- ind[i] = add( shl( (Word16) temp, 2 ), (Word16) b );
- nb = (UWord16) add( (Word16) nb, add( (Word16) temp, 3 ) );
+ move16();
+ b = (UWord16) L_add( L_shl( b, 1 ), *p++ );
+ ind[i] = extract_l( L_add( L_shl( temp, 2 ), b ) );
+ move16();
+ nb = (UWord16) L_add( nb, L_add( temp, 3 ) );
}
return nb;
@@ -108,28 +115,35 @@ static Word16 read_GR1(
p = bit_stream;
nb = 0;
+ move16();
FOR( i = 0; i < len; i++ )
{
ready = 0;
+ move16();
temp = 0;
+ move16();
DO
{
b = *p++;
- IF( EQ_16( (Word16) b, 0 ) )
+ move16();
+ IF( b == 0 )
{
ready = 1;
+ move16();
}
ELSE
{
- temp = add( (Word16) temp, 1 );
+ temp = (UWord16) ( L_add( temp, 1 ) );
}
}
- WHILE( EQ_16( (Word16) ready, 0 ) );
+ WHILE( ready == 0 );
b = *p++;
- ind[i] = add( shl( (Word16) temp, 1 ), (Word16) b );
- nb = (UWord16) add( (Word16) nb, add( (Word16) temp, 2 ) );
+ move16();
+ ind[i] = extract_l( L_add( L_shl( temp, 1 ), b ) );
+ move16();
+ nb = (UWord16) L_add( nb, L_add( temp, 2 ) );
}
return nb;
@@ -155,26 +169,32 @@ Word16 read_GR0(
p = bit_stream;
nb = 0;
+ move16();
FOR( i = 0; i < len; i++ )
{
ready = 0;
+ move16();
temp = 0;
+ move16();
DO
{
b = *p++;
- IF( EQ_16( (Word16) b, 0 ) )
+ move16();
+ IF( b == 0 )
{
ready = 1;
+ move16();
}
ELSE
{
- temp = add( (Word16) temp, 1 );
+ temp = (UWord16) L_add( temp, 1 );
}
}
- WHILE( EQ_16( (Word16) ready, 0 ) );
+ WHILE( ready == 0 );
ind[i] = temp;
- nb = (UWord16) add( (Word16) nb, add( (Word16) temp, 1 ) );
+ move16();
+ nb = (UWord16) L_add( nb, L_add( temp, 1 ) );
}
return nb;
@@ -196,10 +216,13 @@ static ivas_error find_map(
)
{
*map_idx = 0;
+ move16();
WHILE( ( NE_16( map[*map_idx], val ) ) && ( NE_16( *map_idx, len ) ) )
{
- ( *map_idx )++;
+ test();
+ *map_idx = add( *map_idx, 1 );
+ move16();
}
@@ -226,7 +249,7 @@ static void decode_adapt_GR_indices1(
IF( EQ_16( no_symb, NO_SYMB_GR_SIDE_G ) )
{
- map = &map0[15 * no_symb];
+ map = &map0[i_mult( 15, no_symb )];
}
ELSE
{
@@ -236,8 +259,9 @@ static void decode_adapt_GR_indices1(
FOR( i = 0; i < len; i++ )
{
map_symb = ind[i];
+ move16();
find_map( out + i, map, map_symb, no_symb );
- map = &( map0[out[i] * no_symb] );
+ map = &( map0[i_mult( out[i], no_symb )] );
}
return;
@@ -258,11 +282,13 @@ Word16 get_value(
{
Word16 i;
UWord16 mask = 0, val = 0;
+ move16();
+ move16();
- FOR( i = nbits - 1; i >= 0; i-- )
+ FOR( i = sub( nbits, 1 ); i >= 0; i-- )
{
- val = (UWord16) add( (Word16) val, shl( bit_stream[i], mask ) );
- mask = add( mask, 1 );
+ val = (UWord16) L_add( val, L_shl( bit_stream[i], mask ) );
+ mask = (UWord16) L_add( mask, 1 );
}
return val;
@@ -287,27 +313,31 @@ Word16 read_BS_GR(
Word16 b, ind1_tmp[STEREO_DFT_BAND_MAX], tmp, i;
*GR_ord = bit_stream[nb];
+ move16();
b = 1;
+ move16();
- IF( EQ_16( *GR_ord, 0 ) )
+ IF( *GR_ord == 0 )
{
- b = add( b, read_GR0( &bit_stream[nb + b], ind1_tmp, len ) );
+ b = add( b, read_GR0( &bit_stream[add( nb, b )], ind1_tmp, len ) );
}
ELSE
{
- b = add( b, read_GR1( &bit_stream[nb + b], ind1_tmp, len ) );
+ b = add( b, read_GR1( &bit_stream[add( nb, b )], ind1_tmp, len ) );
}
FOR( i = 0; i < len; i++ )
{
tmp = add( ind1_tmp[i], 1 );
- IF( tmp & 1 ) /* if odd number */
+ IF( s_and( tmp, 1 ) ) /* if odd number */
{
ind1[i] = negate( shr( ind1_tmp[i], 1 ) );
+ move16();
}
ELSE
{
ind1[i] = shr( tmp, 1 );
+ move16();
}
}
@@ -335,30 +365,36 @@ Word16 read_BS_adapt_GR_sg(
/* read first component */
b = 0;
+ move16();
b = add( b, read_GR1( &bit_stream[nb], ind1_tmp, 1 ) );
/* read GR ord */
- ord = bit_stream[nb + b];
+ ord = bit_stream[add( nb, b )];
+ move16();
b = add( b, 1 );
- IF( EQ_16( ord, 0 ) )
+ IF( ord == 0 )
{
*GR_ord = 1;
- b = add( b, read_GR1( &bit_stream[nb + b], &ind1_tmp[1], len - 1 ) );
+ move16();
+ b = add( b, read_GR1( &bit_stream[add( nb, b )], &ind1_tmp[1], sub( len, 1 ) ) );
}
ELSE
{
- ord = bit_stream[nb + b];
+ ord = bit_stream[add( nb, b )];
+ move16();
b = add( b, 1 );
- IF( EQ_16( ord, 0 ) )
+ IF( ord == 0 )
{
*GR_ord = 0;
+ move16();
- b = add( b, read_GR0( &bit_stream[nb + b], &ind1_tmp[1], len - 1 ) );
+ b = add( b, read_GR0( &bit_stream[add( nb, b )], &ind1_tmp[1], sub( len, 1 ) ) );
}
ELSE
{
*GR_ord = 2;
- b = add( b, read_GR2( &bit_stream[nb + b], &ind1_tmp[1], len - 1 ) );
+ move16();
+ b = add( b, read_GR2( &bit_stream[add( nb, b )], &ind1_tmp[1], sub( len, 1 ) ) );
}
}
@@ -381,6 +417,7 @@ Word16 read_itd(
)
{
Word16 huff_flag, sign_flag, I, i, nb = 0, ready;
+ move16();
huff_flag = (Word16) get_next_indice( st, 1 );
sign_flag = (Word16) get_next_indice( st, 1 );
@@ -389,24 +426,30 @@ Word16 read_itd(
IF( EQ_16( huff_flag, 1 ) )
{
ready = 0;
+ move16();
I = 0;
+ move16();
- WHILE( ( EQ_16( ready, 0 ) ) && ( LT_16( nb, 10 ) ) )
+ WHILE( ( ready == 0 ) && ( LT_16( nb, 10 ) ) )
{
+ test();
I = add( shl( I, 1 ), (Word16) get_next_indice( st, 1 ) );
nb = add( nb, 1 );
FOR( i = 0; i < 20; i++ )
{
+ test();
IF( ( EQ_16( I, dft_code_itd[i] ) ) && ( EQ_16( dft_len_itd[i], ( sub( nb, 2 ) ) ) ) )
{
I = i;
+ move16();
ready = 1;
+ move16();
BREAK;
}
}
}
- IF( EQ_16( ready, 0 ) )
+ IF( ready == 0 )
{
printf( "Error reading Huffman code for ITD: \n" );
}
@@ -419,6 +462,7 @@ Word16 read_itd(
I = add( I, shl( sign_flag, 8 ) );
*pI = I;
+ move16();
return nb;
}
@@ -451,22 +495,24 @@ Word16 read_BS_adapt_GR_rpg(
FOR( i = start; i < total_no; i++ )
{
ind1_pred[i] = 0;
+ move16();
}
}
ELSE
{
- *GR_ord = bit_stream[nb + b]; /* GR order */
+ *GR_ord = bit_stream[add( nb, b )]; /* GR order */
+ move16();
b = add( b, 1 );
- IF( EQ_16( *GR_ord, 0 ) )
+ IF( *GR_ord == 0 )
{
- b = add( b, read_GR0( &bit_stream[nb + b], &ind1_tmp[1], len - 1 ) );
+ b = add( b, read_GR0( &bit_stream[add( nb, b )], &ind1_tmp[1], sub( len, 1 ) ) );
}
ELSE
{
/* GR ord 1 */
- b = add( b, read_GR1( &bit_stream[nb + b], &ind1_tmp[1], len - 1 ) );
+ b = add( b, read_GR1( &bit_stream[add( nb, b )], &ind1_tmp[1], sub( len, 1 ) ) );
}
- decode_adapt_GR_indices1( ind1_tmp, total_no - start, NO_SYMB_GR_PRED_G, &ind1_pred[start], dft_maps_rpg );
+ decode_adapt_GR_indices1( ind1_tmp, sub( total_no, start ), NO_SYMB_GR_PRED_G, &ind1_pred[start], dft_maps_rpg );
}
return b;
@@ -488,14 +534,17 @@ Word16 read_flag_EC_DFT(
Word16 flg;
flg = bit_stream[0];
- IF( EQ_16( flg, 0 ) )
+ move16();
+ IF( flg == 0 )
{
*flag = flg;
+ move16();
return 1;
}
ELSE
{
*flag = add( 2, bit_stream[1] );
+ move16();
return 2;
}
}
diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c
index 0c08c549fe6253ccbe0bfcdbb580a087fe975178..f4464f79cf1f91287d9f98276889774894527d2d 100644
--- a/lib_dec/ivas_stereo_cng_dec.c
+++ b/lib_dec/ivas_stereo_cng_dec.c
@@ -41,9 +41,10 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
+#include "ivas_rom_com_fx.h"
#endif
+
/*-------------------------------------------------------------------
* Local constants
*-------------------------------------------------------------------*/
@@ -723,6 +724,7 @@ static void stereo_dft_generate_comfort_noise_fx(
q_shift = s_min( getScaleFactor32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ), sub( hFdCngCom->cngNoiseLevelExp, 27 ) );
scale_sig32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, q_shift );
hFdCngCom->cngNoiseLevelExp = sub( hFdCngCom->cngNoiseLevelExp, q_shift );
+ move16();
enr = 0; /* Eliminates compiler warning. They are always set before they are used */
move32();
@@ -737,25 +739,29 @@ static void stereo_dft_generate_comfort_noise_fx(
q_shb_shape = 0;
move16();
- IF( EQ_16( chan, 0 ) )
+ IF( chan == 0 )
{
- pSideGain = hStereoDft->side_gain_fx + i_mult( STEREO_DFT_NBDIV, STEREO_DFT_BAND_MAX );
+ pSideGain = hStereoDft->side_gain_fx + STEREO_DFT_NBDIV * STEREO_DFT_BAND_MAX;
FOR( b = 0; b < hStereoDft->nbands; b++ )
{
- IF( EQ_16( hStereoCng->xfade_frame_counter, 0 ) )
+ IF( hStereoCng->xfade_frame_counter == 0 )
{
hStereoDft->g_state_fx[b] = extract_h( *pSideGain++ );
+ move16();
}
ELSE
{
hStereoDft->g_state_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, extract_h( *pSideGain++ ) ), mult( A_GFILT_FX, hStereoDft->g_state_fx[b] ) );
+ move16();
}
+ test();
IF( hStereoCng->first_SID )
{
IF( hStereoCng->first_SID_after_TD )
{
hStereoCng->cm_fx[b] = extract_h( Mpy_32_32( hStereoCng->c_LR_LT_fx, hStereoCng->c_LR_LT_fx ) );
+ move16();
}
ELSE
{
@@ -768,15 +774,18 @@ static void stereo_dft_generate_comfort_noise_fx(
IF( GT_16( hStereoCng->nr_corr_frames, CORR_INIT ) )
{
hStereoCng->cm_fx[b] = extract_h( Mpy_32_32( hStereoCng->c_LR_LT_fx, hStereoCng->c_LR_LT_fx ) );
+ move16();
}
ELSE
{
hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) );
+ move16();
}
}
ELSE
{
hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) );
+ move16();
}
}
@@ -790,8 +799,8 @@ static void stereo_dft_generate_comfort_noise_fx(
{
gamma = hStereoCng->cm_fx[b]; /* Q15 */
move16();
- gamma = BASOP_Util_Divide1616_Scale( gamma, 32767 - gamma, &q_div ); /* e(q_div) */
- q_sqrt2 = q_div + 16;
+ gamma = BASOP_Util_Divide1616_Scale( gamma, sub( 32767, gamma ), &q_div ); /* e(q_div) */
+ q_sqrt2 = add( q_div, 16 );
tmp32_1 = BASOP_Util_Add_Mant32Exp( gamma, add( q_div, 16 ), sub( 32767, mult_r( hStereoDft->g_state_fx[b], hStereoDft->g_state_fx[b] ) ), 16, &q_sqrt1 ); /* e(q_sqrt1) */
tmp32_1 = Sqrt32( tmp32_1, &q_sqrt1 ); /* e(q_sqrt1) */
tmp32_2 = Sqrt32( gamma, &q_sqrt2 ); /* e(q_sqrt2) */
@@ -834,10 +843,11 @@ static void stereo_dft_generate_comfort_noise_fx(
}
scaleAvg = BASOP_Util_Divide1616_Scale( scaleAvg, hStereoDft->nbands, &q_div );
hStereoDft->scale_fx = shl_sat( scaleAvg, q_div );
+ move16();
}
}
- IF( EQ_16( st->cng_type, LP_CNG ) )
+ IF( st->cng_type == LP_CNG )
{
set32_fx( cngNoiseLevel_upd, 0, st->L_frame );
@@ -846,26 +856,31 @@ static void stereo_dft_generate_comfort_noise_fx(
move16();
dmpf[1] = negate( st->preemph_fac );
move16();
- mvs2s( st->Aq_cng, Atmp, M + 1 );
+ Copy( st->Aq_cng, Atmp, M + 1 );
conv_fx_32( Atmp, dmpf, cngNoiseLevel_upd, M + 2 );
IF( EQ_16( st->L_frame, L_FRAME ) )
{
pTrigo = hStereoDft->dft_trigo_12k8_fx;
trigo_step = STEREO_DFT_TRIGO_SRATE_12k8_STEP * STEREO_DFT_TRIGO_DEC_STEP;
+ move16();
}
ELSE
{
pTrigo = hStereoDft->dft_trigo_16k_fx;
trigo_step = STEREO_DFT_TRIGO_SRATE_16k_STEP * STEREO_DFT_TRIGO_DEC_STEP;
+ move16();
}
- FOR( i = 0; i < st->L_frame / 4; i++ )
+ FOR( i = 0; i < shr( st->L_frame, 2 ); i++ )
{
trigo_dec[i] = pTrigo[i_mult( i, trigo_step )];
- trigo_dec[sub( shr( st->L_frame, 1 ), i )] = pTrigo[i_mult( i, trigo_step )];
+ move16();
+ trigo_dec[sub( st->L_frame / 2, i )] = pTrigo[i_mult( i, trigo_step )];
+ move16();
}
- trigo_dec[shr( st->L_frame, 2 )] = pTrigo[i_mult( shr( st->L_frame, 2 ), trigo_step )];
+ trigo_dec[st->L_frame / 4] = pTrigo[i_mult( st->L_frame / 4, trigo_step )];
+ move16();
Word16 rshift_cng = sub( find_guarded_bits_fx( st->L_frame ), getScaleFactor32( cngNoiseLevel_upd, st->L_frame ) );
v_shr_32( cngNoiseLevel_upd, cngNoiseLevel_upd, st->L_frame, rshift_cng );
@@ -882,7 +897,7 @@ static void stereo_dft_generate_comfort_noise_fx(
ptr0 = cngNoiseLevel_upd;
ptr1 = ptr0 + 2;
ptr2 = ptr1 + 1;
- assert( GT_32( st->lp_ener_fx, 0 ) );
+ assert( st->lp_ener_fx > 0 );
// lp_ener_fx will be in Q6 at this point.
// So applying appropriate left shift on the denominator.
@@ -894,30 +909,34 @@ static void stereo_dft_generate_comfort_noise_fx(
FOR( i = 0; i < sub( shr( st->L_frame, 1 ), 1 ); i++ )
{
ftmp = Madd_32_32( Mpy_32_32( *ptr1, *ptr1 ), *ptr2, *ptr2 );
- assert( GT_32( ftmp, 0 ) );
+ assert( ftmp > 0 );
q_sqrt = sub( 62, shl( q_cngNoiseLevel_upd, 1 ) );
- IF( EQ_32( ftmp, 0 ) )
+ IF( ftmp == 0 )
{
ftmp = EPSILLON_FX;
+ move32();
q_sqrt = s_max( 0, q_sqrt );
}
tmp = ISqrt32( ftmp, &q_sqrt );
e_norm_temp[i] = sub( 31, add( q_sqrt, q_div ) );
+ move16();
*ptr0++ = Mpy_32_32( factor, tmp );
+ move32();
ptr1 += 2;
ptr2 += 2;
}
FOR( i = 0; i < sub( shr( st->L_frame, 1 ), 1 ); i++ )
{
- q_cngNoiseLevel_upd = s_min( q_cngNoiseLevel_upd, e_norm_temp[i] + norm_l( cngNoiseLevel_upd[i] ) );
+ q_cngNoiseLevel_upd = s_min( q_cngNoiseLevel_upd, add( e_norm_temp[i], norm_l( cngNoiseLevel_upd[i] ) ) );
}
FOR( i = 0; i < st->L_frame; i++ )
{
cngNoiseLevel_upd[i] = L_shl( cngNoiseLevel_upd[i], sub( q_cngNoiseLevel_upd, e_norm_temp[i] ) );
+ move32();
}
- IF( GT_16( sub( s_min( output_frame, L_FRAME32k ), hFdCngCom->stopFFTbin ), 0 ) )
+ IF( sub( s_min( output_frame, L_FRAME32k ), hFdCngCom->stopFFTbin ) > 0 )
{
/* Transform shb LP spectrum */
set32_fx( shb_shape, 0, L_FRAME16k );
@@ -926,14 +945,18 @@ static void stereo_dft_generate_comfort_noise_fx(
IF( NE_16( st->L_frame, L_FRAME16k ) )
{
pTrigo = hStereoDft->dft_trigo_16k_fx;
- trigo_step = i_mult( STEREO_DFT_TRIGO_SRATE_16k_STEP, STEREO_DFT_TRIGO_DEC_STEP );
+ trigo_step = STEREO_DFT_TRIGO_SRATE_16k_STEP * STEREO_DFT_TRIGO_DEC_STEP;
+ move16();
FOR( i = 0; i < L_FRAME16k / 4; i++ )
{
trigo_dec[i] = pTrigo[i_mult( i, trigo_step )];
- trigo_dec[sub( shr( L_FRAME16k, 1 ), i )] = pTrigo[i_mult( i, trigo_step )];
+ move16();
+ trigo_dec[sub( L_FRAME16k / 2, i )] = pTrigo[i_mult( i, trigo_step )];
+ move16();
}
- trigo_dec[shr( L_FRAME16k, 2 )] = pTrigo[i_mult( shr( L_FRAME16k, 2 ), trigo_step )];
+ trigo_dec[L_FRAME16k / 4] = pTrigo[i_mult( L_FRAME16k / 4, trigo_step )];
+ move16();
}
Word16 rshift_shb = sub( find_guarded_bits_fx( L_FRAME16k ), getScaleFactor32( shb_shape, L_FRAME16k ) );
@@ -958,8 +981,9 @@ static void stereo_dft_generate_comfort_noise_fx(
{
ftmp = Madd_32_32( Mpy_32_32( *ptr1, *ptr1 ), *ptr2, *ptr2 );
q_tmp = sub( shl( q_shb_shape, 1 ), 31 );
- assert( GT_32( ftmp, 0 ) );
+ assert( ftmp > 0 );
q_div = 0;
+ move16();
ftmp = BASOP_Util_Divide3232_Scale_cadence( L_shl( 1, q_tmp ), ftmp, &q_div );
/* in float:
both a = "div"=(1/(x^2+y^2) and sqrt(a) is used and summed up in the same loop.
@@ -970,11 +994,14 @@ static void stereo_dft_generate_comfort_noise_fx(
enr = BASOP_Util_Add_Mant32Exp( enr, q_enr, ftmp, q_div, &q_enr );
tmp32_1 = Sqrt32( ftmp, &q_div );
*ptr0++ = tmp32_1;
+ move32();
e_norm_temp[i] = sub( 31, q_div );
+ move16();
ptr1 += 2;
ptr2 += 2;
}
q_shb_shape = MAX_16;
+ move16();
FOR( i = 0; i < L_FRAME16k; i++ )
{
@@ -983,20 +1010,25 @@ static void stereo_dft_generate_comfort_noise_fx(
FOR( i = 0; i < L_FRAME16k; i++ )
{
shb_shape[i] = L_shl( shb_shape[i], sub( q_shb_shape, e_norm_temp[i] ) );
+ move32();
}
}
/* Update CNG noise level from MS noise estimation */
- mvl2l( st->hFdCngDec->bandNoiseShape, cngNoiseLevel_hist, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) );
+ Copy32( st->hFdCngDec->bandNoiseShape, cngNoiseLevel_hist, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) );
ptr_cng = cngNoiseLevel_hist;
- FOR( i = 0; i < sub( st->last_L_frame, hFdCngCom->startBand ) / 2; i++ )
+ FOR( i = 0; i < shr( sub( st->last_L_frame, hFdCngCom->startBand ), 1 ); i++ )
{
tmp = *( cngNoiseLevel_hist + shl( i, 1 ) );
tmp = L_add( tmp, *( cngNoiseLevel_hist + add( shl( i, 1 ), 1 ) ) );
*ptr_cng++ = L_shr( tmp, 1 );
+ move32();
}
- IF( EQ_16( last_element_mode, IVAS_CPE_TD ) && EQ_16( chan, 0 ) && EQ_16( hStereoCng->xfade_frame_counter, 0 ) && GE_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) )
+ test();
+ test();
+ test();
+ IF( EQ_16( last_element_mode, IVAS_CPE_TD ) && ( chan == 0 ) && ( hStereoCng->xfade_frame_counter == 0 ) && GE_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) )
{
ptr_cng = cngNoiseLevel_hist + hFdCngCom->startBand;
ptr_tmp = cngNoiseLevel_upd + hFdCngCom->startBand;
@@ -1013,6 +1045,7 @@ static void stereo_dft_generate_comfort_noise_fx(
{
tmp_16 = shl( tmp_16, q_div );
hStereoCng->xfade_length = sub( MAX_XFADE_FX, extract_l( L_shr( imult3216( MAX_XFADE_FX, tmp_16 ), Q15 ) ) );
+ move16();
}
ELSE
{
@@ -1020,6 +1053,7 @@ static void stereo_dft_generate_comfort_noise_fx(
tmp_16 = Invert16( tmp_16, &q_inv );
tmp_16 = shl( tmp_16, add( q_inv, q_div ) );
hStereoCng->xfade_length = sub( MAX_XFADE_FX, extract_l( L_shr( imult3216( MAX_XFADE_FX, tmp_16 ), Q15 ) ) );
+ move16();
}
}
@@ -1027,7 +1061,7 @@ static void stereo_dft_generate_comfort_noise_fx(
{
ptr_cng = cngNoiseLevel_hist + hFdCngCom->startBand;
ptr_tmp = cngNoiseLevel_upd + hFdCngCom->startBand;
- FOR( i = 0; i < ( st->last_L_frame - hFdCngCom->startBand ) / 2; i++ )
+ FOR( i = 0; i < shr( sub( st->last_L_frame, hFdCngCom->startBand ), 1 ); i++ )
{
tmp_16 = BASOP_Util_Divide1616_Scale( hStereoCng->xfade_frame_counter, hStereoCng->xfade_length, &q_div );
tmp_16 = shl( tmp_16, q_div );
@@ -1047,13 +1081,13 @@ static void stereo_dft_generate_comfort_noise_fx(
ptr_i = ptr_r + 1;
scale = shr( output_frame, 1 );
- FOR( i = 0; i < ( hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / 2; i++ )
+ FOR( i = 0; i < shr( sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), 1 ); i++ )
{
/* Real part in FFT bins */
rand_gauss_fx( ptr_r, &st->hTdCngDec->cng_seed, q_dft );
tmp32_1 = Mpy_32_16_1( *ptr_level, scale ); // Q(q_cngNoiseLevel_upd - 15)
q_shift = norm_l( tmp32_1 );
- IF( GT_16( q_shift, sub( 46, q_cngNoiseLevel_upd ) ) )
+ if ( GT_16( q_shift, sub( 46, q_cngNoiseLevel_upd ) ) )
{
q_shift = sub( 46, q_cngNoiseLevel_upd );
}
@@ -1061,21 +1095,23 @@ static void stereo_dft_generate_comfort_noise_fx(
q_shift = sub( sub( 46, q_cngNoiseLevel_upd ), q_shift );
( *ptr_r ) = L_shl( Mpy_32_32( ( *ptr_r ), tmp32_1 ), q_shift );
+ move32();
ptr_r += 2;
/* Imaginary part in FFT bins */
rand_gauss_fx( ptr_i, &st->hTdCngDec->cng_seed, q_dft );
( *ptr_i ) = L_shl( Mpy_32_32( ( *ptr_i ), tmp32_1 ), q_shift );
+ move32();
ptr_i += 2;
ptr_level++;
}
- IF( GT_16( sub( s_min( output_frame, L_FRAME32k ), hFdCngCom->stopFFTbin ), 0 ) )
+ IF( sub( s_min( output_frame, L_FRAME32k ), hFdCngCom->stopFFTbin ) > 0 )
{
Word32 scale_32;
Word16 q_res;
/* high band generation, flipped spectrum */
- assert( NE_32( enr, 0 ) );
+ assert( enr != 0 );
// 10 ^ (0.1 * st->hTdCngDec->shb_cng_gain)
// Above expression equivalent to 2 ^ (3.321928094 * 0.1 * st->hTdCngDec->shb_cng_gain)
// 3.321928094 * 0.1 = 0.3321928094
@@ -1087,19 +1123,23 @@ static void stereo_dft_generate_comfort_noise_fx(
move16();
scale = BASOP_Util_Divide3232_Scale( scale_32, enr, &q_div );
// q_res = add(q_div, sub( q_enr, sub(Q31, q_res))); move16();
- q_res = q_res - q_enr + q_div;
+ q_res = add( sub( q_res, q_enr ), q_div );
// q_div = sub(Q15, q_res); move16();
q_div = q_res;
+ move16();
inv_scale = ISqrt16( scale, &q_res );
scale = Sqrt16( scale, &q_div );
- ptr_shb = shb_shape + sub( shr( L_FRAME16k, 1 ), 1 );
+ ptr_shb = shb_shape + ( L_FRAME16k / 2 - 1 );
/* Averaging for Nyquist frequency */
Word16 q1, q2;
tmp32_1 = Mpy_32_16_1( cngNoiseLevel_upd[sub( shr( sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), 1 ), 1 )], inv_scale );
tmp32_2 = *( ptr_shb - 1 );
+ move32();
q1 = sub( add( q_cngNoiseLevel_upd, 1 ), q_res );
q2 = q_shb_shape;
+ move16();
*ptr_shb = BASOP_Util_Add_Mant32Exp( tmp32_1, sub( Q31, q1 ), tmp32_2, sub( Q31, q2 ), &q_tmp );
+ move32();
q_tmp = sub( q_tmp, 1 );
IF( LT_16( sub( Q31, q_tmp ), q_shb_shape ) )
{
@@ -1108,19 +1148,21 @@ static void stereo_dft_generate_comfort_noise_fx(
}
*ptr_shb = L_shl( *ptr_shb, sub( q_shb_shape, sub( Q31, q_tmp ) ) );
+ move32();
// *ptr_shb = 0.5f * ( cngNoiseLevel_upd[( hFdCngCom->stopFFTbin - hFdCngCom->startBand ) / 2 - 1] / scale + *( ptr_shb - 1 ) );
- ptr_r = DFT[chan] + hFdCngCom->stopFFTbin + i_mult( k, STEREO_DFT32MS_N_MAX );
+ ptr_r = DFT[chan] + add( hFdCngCom->stopFFTbin, i_mult( k, STEREO_DFT32MS_N_MAX ) );
ptr_i = ptr_r + 1;
- FOR( i = 0; i < shr( sub( s_min( output_frame, i_mult( hFdCngCom->regularStopBand, 16 ) ), hFdCngCom->stopFFTbin ), 1 ); i++ )
+ FOR( i = 0; i < shr( sub( s_min( output_frame, shl( hFdCngCom->regularStopBand, 4 ) ), hFdCngCom->stopFFTbin ), 1 ); i++ )
{
/* Real part in FFT bins */
rand_gauss_fx( ptr_r, &st->hTdCngDec->cng_seed, q_dft );
tmp32_1 = *ptr_shb;
+ move32();
q_shift = norm_l( tmp32_1 );
- IF( GT_16( q_shift, sub( 31, q_shb_shape ) ) )
+ if ( GT_16( q_shift, sub( 31, q_shb_shape ) ) )
{
q_shift = sub( 31, q_shb_shape );
}
@@ -1128,10 +1170,12 @@ static void stereo_dft_generate_comfort_noise_fx(
q_shift = sub( sub( 31, q_shb_shape ), q_shift );
( *ptr_r ) = L_shl( Mpy_32_32( ( *ptr_r ), tmp32_1 ), q_shift );
+ move32();
ptr_r += 2;
/* Imaginary part in FFT bins */
rand_gauss_fx( ptr_i, &st->hTdCngDec->cng_seed, q_dft );
( *ptr_i ) = L_shl( Mpy_32_32( ( *ptr_i ), tmp32_1 ), q_shift );
+ move32();
ptr_i += 2;
ptr_shb--;
}
@@ -1139,7 +1183,7 @@ static void stereo_dft_generate_comfort_noise_fx(
/* rescale */
tmp32_1 = L_mult0( scale, shr( output_frame, 1 ) );
q_shift = norm_l( tmp32_1 );
- IF( GT_16( q_shift, add( Q16, q_div ) ) )
+ if ( GT_16( q_shift, add( Q16, q_div ) ) )
{
q_shift = add( Q16, q_div );
}
@@ -1148,10 +1192,12 @@ static void stereo_dft_generate_comfort_noise_fx(
ptr_r = DFT[chan] + add( hFdCngCom->stopFFTbin, i_mult( k, STEREO_DFT32MS_N_MAX ) );
ptr_i = ptr_r + 1;
- FOR( i = 0; i < ( min( output_frame, hFdCngCom->regularStopBand * 16 ) - hFdCngCom->stopFFTbin ) / 2; i++ )
+ FOR( i = 0; i < shr( sub( min( output_frame, shl( hFdCngCom->regularStopBand, 4 ) ), hFdCngCom->stopFFTbin ), 1 ); i++ )
{
( *ptr_r ) = L_shl( Mpy_32_32( ( *ptr_r ), tmp32_1 ), q_shift );
+ move32();
( *ptr_i ) = L_shl( Mpy_32_32( ( *ptr_i ), tmp32_1 ), q_shift );
+ move32();
ptr_r += 2;
ptr_i += 2;
}
@@ -1167,29 +1213,33 @@ static void stereo_dft_generate_comfort_noise_fx(
q_tmp = s_max( hFdCngCom->cngNoiseLevelExp, shl( sub( Q31, q_cngNoiseLevel_upd ), 1 ) );
scale_sig32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, sub( hFdCngCom->cngNoiseLevelExp, q_tmp ) );
hFdCngCom->cngNoiseLevelExp = q_tmp;
+ move16();
FOR( i = 0; i < shr( sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), 1 ); i++ )
{
*ptr_level-- = L_shl( Mpy_32_32( *ptr_tmp, *ptr_tmp ), sub( shl( sub( Q31, q_cngNoiseLevel_upd ), 1 ), hFdCngCom->cngNoiseLevelExp ) );
+ move32();
ptr_tmp--;
*ptr_level = *( ptr_level + 1 );
move32();
- lp_noise = L_add( lp_noise, L_shl( *ptr_level--, add( 1, sub( Q6, sub( Q31, hFdCngCom->cngNoiseLevelExp ) ) ) ) );
+ lp_noise = L_add( lp_noise, L_shl( *ptr_level--, 1 ) );
}
}
ELSE
{
/* FD-CNG */
- IF( !( hFdCngCom->msFrCnt_init_counter < hFdCngCom->msFrCnt_init_thresh ) )
+ IF( !LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) )
{
- IF( hStereoCng->xfade_frame_counter <= MAX_K && hStereoCng->last_act_element_mode == IVAS_CPE_TD && chan == 0 )
+ test();
+ test();
+ IF( LE_16( hStereoCng->xfade_frame_counter, (Word16) MAX_K ) && EQ_16( hStereoCng->last_act_element_mode, IVAS_CPE_TD ) && ( chan == 0 ) )
{
/* Fade MS -> SID/MS */
j = 0;
move16();
- FOR( k = 0; k < ( hFdCngCom->nFFTpart - 2 ); k++ )
+ FOR( k = 0; k < sub( hFdCngCom->nFFTpart, 2 ); k++ )
{
- factor = BASOP_Util_Divide3232_Scale_cadence( ( hFdCngCom->sidNoiseEstLp[k] + DELTA_FX ), ( st->hFdCngDec->partNoiseShape[k] + DELTA_FX ), &q_div );
+ factor = BASOP_Util_Divide3232_Scale_cadence( L_add( hFdCngCom->sidNoiseEstLp[k], DELTA_FX ), L_add( st->hFdCngDec->partNoiseShape[k], DELTA_FX ), &q_div );
factor = s_min( add( hStereoDft->scale_fx, extract_l( Mpy_32_16_1( L_mult( sub( extract_h( factor ), hStereoDft->scale_fx ), hStereoCng->xfade_frame_counter ), ONE_BY_MAX_K ) ) ), extract_h( factor ) );
FOR( ; j <= hFdCngCom->part[k]; j++ )
{
@@ -1204,7 +1254,7 @@ static void stereo_dft_generate_comfort_noise_fx(
FOR( k = 0; k < STEREO_DFT_NBDIV; k++ )
{
ptr_level = hFdCngCom->cngNoiseLevel;
- ptr_r = DFT[chan] + hFdCngCom->startBand + k * STEREO_DFT32MS_N_MAX;
+ ptr_r = DFT[chan] + add( hFdCngCom->startBand, i_mult( k, STEREO_DFT32MS_N_MAX ) );
ptr_i = ptr_r + 1;
q_cngNoiseLevel = sub( Q31, hFdCngCom->cngNoiseLevelExp );
FOR( i = 0; i < shr( sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), 1 ); i++ )
@@ -1218,6 +1268,7 @@ static void stereo_dft_generate_comfort_noise_fx(
q_sqrt = sub( Q31, q_cngNoiseLevel );
tmp = Sqrt32( tmp, &q_sqrt );
*( ptr_r ) = imult3216( Mpy_32_32( *( ptr_r ), tmp ), scale );
+ move32();
( *ptr_r ) = L_shl( ( *ptr_r ), q_sqrt );
move32();
ptr_r += 2;
@@ -1227,8 +1278,8 @@ static void stereo_dft_generate_comfort_noise_fx(
move32();
ptr_i += 2;
}
- ptr_level = hFdCngCom->cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand;
- ptr_r = DFT[chan] + hFdCngCom->stopFFTbin + k * STEREO_DFT32MS_N_MAX;
+ ptr_level = hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
+ ptr_r = DFT[chan] + add( hFdCngCom->stopFFTbin, i_mult( k, STEREO_DFT32MS_N_MAX ) );
ptr_i = ptr_r + 1;
FOR( j = hFdCngCom->numCoreBands; j < hFdCngCom->regularStopBand; j++ )
{
@@ -1260,37 +1311,39 @@ static void stereo_dft_generate_comfort_noise_fx(
}
}
- IF( hStereoCng->last_act_element_mode == IVAS_CPE_TD && chan > 0 )
+ test();
+ IF( EQ_16( hStereoCng->last_act_element_mode, IVAS_CPE_TD ) && ( chan > 0 ) )
{
- Word32 log_lp_noise = L_add( L_shl( hFdCngCom->cngNoiseLevelExp, Q25 ), BASOP_Util_Log2( lp_noise + DELTA_FX ) );
+ Word32 log_lp_noise = L_add( L_shl( hFdCngCom->cngNoiseLevelExp, Q25 ), BASOP_Util_Log2( L_add( lp_noise, DELTA_FX ) ) );
// log10(x) is computed as log2(x) * log10(2)
// log_lp_noise at this stage is in Q25. where as the structure value is in Q23
// Hence the 16-bit constant log10(2) will be stored in Q13
- log_lp_noise = Mpy_32_16_1( log_lp_noise, (Word16) 0x09A2 );
- st1->lp_noise = L_add( Mpy_32_16_1( st1->lp_noise, (Word16) ( 0x7333 ) ), log_lp_noise );
+ log_lp_noise = Mpy_32_16_1( log_lp_noise, 2466 /* log10(2) in Q13 */ );
+ st1->lp_noise = L_add( Mpy_32_16_1( st1->lp_noise, 29491 /* 0.9f in Q15 */ ), log_lp_noise );
move32();
}
- ELSE IF( EQ_16( chan, 0 ) )
+ ELSE IF( ( chan == 0 ) )
{
Word16 q_lp_noise = 0; // st->hFdCngDec->q_lp_noise; // to be populated appropriately.
- Word32 log_lp_noise = L_add( L_shl( hFdCngCom->cngNoiseLevelExp, Q25 ), BASOP_Util_Log2( lp_noise + DELTA_FX ) );
move16();
+ Word32 log_lp_noise = L_add( L_shl( hFdCngCom->cngNoiseLevelExp, Q25 ), BASOP_Util_Log2( L_add( lp_noise, DELTA_FX ) ) );
// log10(x) is computed as log2(x) * log10(2)
// log_lp_noise at this stage is in Q25. where as the structure value is in Q23
// Hence the 16-bit constant log10(2) will be stored in Q13
- log_lp_noise = Mpy_32_16_1( log_lp_noise, (Word16) 0x09A2 );
- st->hFdCngDec->lp_noise = L_add( Mpy_32_16_1( st->hFdCngDec->lp_noise, (Word16) ( 0x7333 ) ), log_lp_noise );
+ log_lp_noise = Mpy_32_16_1( log_lp_noise, 2466 /* log10(2) in Q13 */ );
+ st->hFdCngDec->lp_noise = L_add( Mpy_32_16_1( st->hFdCngDec->lp_noise, 29491 /* 0.9f in Q15 */ ), log_lp_noise );
move32();
st->lp_noise = st->hFdCngDec->lp_noise;
move32();
- st->hFdCngDec->hFdCngCom->flag_noisy_speech = (Word16) LT_32( L_shr( L_sub( st->hFdCngDec->lp_speech, st->hFdCngDec->lp_noise ), q_lp_noise ), 28 );
+ st->hFdCngDec->hFdCngCom->flag_noisy_speech = extract_l( LT_32( L_shr( L_sub( st->hFdCngDec->lp_speech, st->hFdCngDec->lp_noise ), q_lp_noise ), 28 ) );
move16();
st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = L_add( Mpy_32_32( Q31_0_99, st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx ),
imult3216( Q31_0_01, st->hFdCngDec->hFdCngCom->flag_noisy_speech ) );
move32();
}
- IF( EQ_16( chan, 0 ) && LE_32( st->core_brate, SID_2k40 ) )
+ test();
+ IF( ( chan == 0 ) && LE_32( st->core_brate, SID_2k40 ) )
{
Word32 max_smoothed_psd = 0;
move32();
@@ -1299,9 +1352,14 @@ static void stereo_dft_generate_comfort_noise_fx(
FOR( i = hFdCngCom->startBand; i < hFdCngCom->stopFFTbin; i++ )
{
Word16 l_shift_val = sub( st->hFdCngDec->q_smoothed_psd, sub( Q31, hFdCngCom->cngNoiseLevelExp ) );
- move16();
- l_shift_val = max_smoothed_psd == 0 ? 0 : l_shift_val;
- ftmp = hFdCngCom->cngNoiseLevel[i - hFdCngCom->startBand];
+
+ if ( max_smoothed_psd == 0 )
+ {
+ l_shift_val = 0;
+ move16();
+ }
+
+ ftmp = hFdCngCom->cngNoiseLevel[sub( i, hFdCngCom->startBand )];
move32();
IF( !st->hFdCngDec->first_cna_noise_updated )
{
@@ -1313,10 +1371,10 @@ static void stereo_dft_generate_comfort_noise_fx(
{
alpha = (Word16) ( 0x799A );
move16();
- IF( GT_32( st->hFdCngDec->smoothed_psd_fx[i], 0 ) && GT_32( Mpy_32_16_1( ftmp, (Word16) 0x3333 ), L_shr_sat( st->hFdCngDec->smoothed_psd_fx[i], l_shift_val ) ) )
+ IF( ( st->hFdCngDec->smoothed_psd_fx[i] > 0 ) && GT_32( Mpy_32_16_1( ftmp, (Word16) 0x3333 ), L_shr_sat( st->hFdCngDec->smoothed_psd_fx[i], l_shift_val ) ) )
{
/* prevent abrupt upward update steps */
- ftmp = L_add( L_shl( st->hFdCngDec->smoothed_psd_fx[i], 2 ), L_shr( st->hFdCngDec->smoothed_psd_fx[i], 1 ) );
+ ftmp = L_add( L_shl( st->hFdCngDec->smoothed_psd_fx[i], 1 ), L_shr( st->hFdCngDec->smoothed_psd_fx[i], 1 ) );
l_shift_val = 0;
move16();
}
@@ -1334,9 +1392,10 @@ static void stereo_dft_generate_comfort_noise_fx(
}
/* update msNoiseEst in SID and NO_DATA frames */
- bandcombinepow( &st->hFdCngDec->smoothed_psd_fx[hFdCngCom->startBand], ( Q31 - st->hFdCngDec->q_smoothed_psd ), hFdCngCom->stopFFTbin - hFdCngCom->startBand, st->hFdCngDec->part_shaping, st->hFdCngDec->nFFTpart_shaping, st->hFdCngDec->psize_inv_shaping, st->hFdCngDec->msNoiseEst, &st->hFdCngDec->msNoiseEst_exp );
+ bandcombinepow( &st->hFdCngDec->smoothed_psd_fx[hFdCngCom->startBand], sub( Q31, st->hFdCngDec->q_smoothed_psd ), sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), st->hFdCngDec->part_shaping, st->hFdCngDec->nFFTpart_shaping, st->hFdCngDec->psize_inv_shaping, st->hFdCngDec->msNoiseEst, &st->hFdCngDec->msNoiseEst_exp );
Scale_sig32( st->hFdCngDec->msNoiseEst, NPART_SHAPING, sub( st->hFdCngDec->msNoiseEst_exp, 27 ) );
st->hFdCngDec->msNoiseEst_exp = 27;
+ move16();
st->hFdCngDec->first_cna_noise_updated = 1;
move16();
Copy32( st->hFdCngDec->msNoiseEst, st->hFdCngDec->msPeriodog_ST_fx, st->hFdCngDec->nFFTpart_shaping );
@@ -1408,7 +1467,8 @@ void stereo_dtf_cng_fx(
{
IF( LT_16( hCPE->hStereoCng->nr_dft_frames, CM_INIT ) )
{
- hCPE->hStereoCng->nr_dft_frames++;
+ hCPE->hStereoCng->nr_dft_frames = add( hCPE->hStereoCng->nr_dft_frames, 1 );
+ move16();
}
IF( LE_32( ivas_total_brate, IVAS_SID_5k2 ) )
@@ -1416,7 +1476,8 @@ void stereo_dtf_cng_fx(
test();
IF( LT_16( hCPE->hStereoCng->nr_sid_frames, SID_INIT ) && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
{
- hCPE->hStereoCng->nr_sid_frames++;
+ hCPE->hStereoCng->nr_sid_frames = add( hCPE->hStereoCng->nr_sid_frames, 1 );
+ move16();
}
FOR( n = 0; n < CPE_CHANNELS; n++ )
@@ -1455,7 +1516,8 @@ void stereo_cng_dec_update(
}
IF( LT_16( hCPE->hStereoCng->active_frame_counter, MAX_FRAME_COUNTER ) )
{
- hCPE->hStereoCng->active_frame_counter++;
+ hCPE->hStereoCng->active_frame_counter = add( hCPE->hStereoCng->active_frame_counter, 1 );
+ move16();
}
}
ELSE
@@ -1464,14 +1526,15 @@ void stereo_cng_dec_update(
move16();
IF( LT_16( hCPE->hStereoCng->xfade_frame_counter, MAX_FRAME_COUNTER ) )
{
- hCPE->hStereoCng->xfade_frame_counter++;
+ hCPE->hStereoCng->xfade_frame_counter = add( hCPE->hStereoCng->xfade_frame_counter, 1 );
+ move16();
}
}
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
test();
- IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) )
+ IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || ( ivas_total_brate == FRAME_NO_DATA ) )
{
hCPE->hStereoCng->prev_sid_nodata = 1;
move16();
@@ -1508,36 +1571,50 @@ void stereo_cng_compute_PScorr_fx(
{
Word16 i;
Word32 enrP_fx = 0, enrS_fx = 0, dotPS_fx = 0, c_PS_fx;
+ move32();
+ move32();
+ move32();
Word32 outputResamp_fx[L_FRAME16k];
Word32 *outputPptr_fx, *outputSptr_fx;
Word16 outputPptr_Q = 0, outputSptr_Q = 0;
+ move16();
+ move16();
Word32 tmp1 = 0, tmp2 = 0, tmp3 = 0;
+ move32();
+ move32();
+ move32();
IF( GT_16( L_frame_0, L_frame_1 ) )
{
outputPptr_fx = output_fx0;
L_lerp_fx( output_fx1, outputResamp_fx, L_frame_0, L_frame_1, output_Q );
outputPptr_Q = *output_Q;
+ move16();
outputSptr_fx = outputResamp_fx;
outputSptr_Q = 1;
+ move16();
}
ELSE IF( GT_16( L_frame_1, L_frame_0 ) )
{
outputSptr_fx = output_fx1;
L_lerp_fx( output_fx0, outputResamp_fx, L_frame_1, L_frame_0, output_Q );
outputSptr_Q = *output_Q;
+ move16();
outputPptr_fx = outputResamp_fx;
outputPptr_Q = 1;
+ move16();
}
ELSE
{
outputPptr_fx = output_fx0;
outputSptr_fx = output_fx1;
outputPptr_Q = *output_Q;
+ move16();
outputSptr_Q = *output_Q;
+ move16();
}
- Word16 guard_bits = (Word16) find_guarded_bits_fx( L_frame_0 );
+ Word16 guard_bits = find_guarded_bits_fx( L_frame_0 );
FOR( i = 0; i < L_frame_0; i++ )
{
@@ -1549,16 +1626,17 @@ void stereo_cng_compute_PScorr_fx(
enrS_fx = L_add( enrS_fx, tmp2 );
tmp3 = Mpy_32_32( *outputPptr_fx++, *outputSptr_fx++ ); // outputSptr_Q + outputPptr_Q - 31
- tmp3 = L_shr( tmp3, guard_bits + 1 ); // outputSptr_Q + outputPptr_Q - 31 - guard_bits
+ tmp3 = L_shr( tmp3, add( guard_bits, 1 ) ); // outputSptr_Q + outputPptr_Q - 31 - guard_bits
dotPS_fx = L_add( dotPS_fx, tmp3 );
}
Word32 Var1 = Mpy_32_32( enrP_fx, enrS_fx ); // 2*( outputPptr_Q - 31 - guard_bits + outputSptr_Q - 31 - guard_bits )
- Word16 exp = 31 - ( 2 * ( outputPptr_Q - 31 - guard_bits + outputSptr_Q - 31 - guard_bits ) );
+ Word16 exp = sub( 31, shl( add( sub( sub( outputPptr_Q, 31 ), guard_bits ), sub( sub( outputSptr_Q, 31 ), guard_bits ) ), 1 ) );
- IF( Var1 == 0 )
+ if ( Var1 == 0 )
{
Var1 = 1;
+ move32();
}
Word32 Var2, Var3;
@@ -1566,26 +1644,37 @@ void stereo_cng_compute_PScorr_fx(
Var3 = L_add( dotPS_fx, 1 ); /*adding one in order to make temp non-zero. q = Q_outputSptr + Q_outputPptr - guard_bits*/
c_PS_fx = Mpy_32_32( Var3, Var2 ); /* outputSptr_Q + outputPptr_Q - guard_bits - exp */
- Word16 c_PS_fx_Q = outputSptr_Q + outputPptr_Q - guard_bits - exp - 31;
+ Word16 c_PS_fx_Q = add( outputSptr_Q, sub( sub( sub( outputPptr_Q, guard_bits ), exp ), 31 ) );
Word32 a = 0, b = 0;
+ move32();
+ move32();
Word16 a_q = 0, b_q = 0, ab_q = 0;
+ move16();
+ move16();
+ move16();
a = Mpy_32_32( c_PS_fx, ONE_MINUS_STEREO_TD_PS_CORR_FILT_Q31 ); // Q(c_PS_fx_Q)
a_q = c_PS_fx_Q;
+ move16();
b = Mpy_32_32( STEREO_TD_PS_CORR_FILT_Q31, *c_PS_LT_fx ); // Q(Q_c_PS_LT_fx)
b_q = Q_c_PS_LT_fx;
+ move16();
IF( GT_16( a_q, b_q ) )
{
- ab_q = a_q - b_q;
- *c_PS_LT_fx = L_add( L_shr( a, (Word16) ab_q ), b );
+ ab_q = sub( a_q, b_q );
+ *c_PS_LT_fx = L_add( L_shr( a, ab_q ), b );
+ move32();
Q_c_PS_LT_fx = b_q;
+ move16();
}
ELSE IF( LT_16( b_q, a_q ) )
{
- ab_q = b_q - a_q;
- *c_PS_LT_fx = L_add( a, L_shr( b, (Word16) ab_q ) );
+ ab_q = sub( b_q, a_q );
+ *c_PS_LT_fx = L_add( a, L_shr( b, ab_q ) );
+ move32();
Q_c_PS_LT_fx = a_q;
+ move16();
}
return;
@@ -1696,8 +1785,8 @@ static void stereo_cng_compute_LRcorr(
static void stereo_cng_compute_LRcorr_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */
Word32 *output_fx[CPE_CHANNELS], /* i : Output signal */
- const int16_t output_frame, /* i : Output frame length */
- const int16_t tdm_ratio_idx /* i : TDM ratio index */
+ const Word16 output_frame, /* i : Output frame length */
+ const Word16 tdm_ratio_idx /* i : TDM ratio index */
)
{
Word16 i;
@@ -1719,139 +1808,169 @@ static void stereo_cng_compute_LRcorr_fx(
beta_fx = tdm_ratio_tabl_fx[tdm_ratio_idx];
enrL_fx = 0;
+ move64();
enrR_fx = 0;
+ move64();
dotLR_fx = 0;
+ move64();
FOR( i = 0; i < output_frame; i++ )
{
-
- enrL_fx += ( (Word64) output_fx[0][i] ) * ( output_fx[0][i] );
- enrR_fx += ( (Word64) output_fx[1][i] ) * ( output_fx[1][i] );
- dotLR_fx += ( ( (Word64) output_fx[0][i] ) * ( output_fx[1][i] ) );
+ enrL_fx = W_add( enrL_fx, W_mult0_32_32( output_fx[0][i], output_fx[0][i] ) );
+ enrR_fx = W_add( enrR_fx, W_mult0_32_32( output_fx[1][i], output_fx[1][i] ) );
+ dotLR_fx = W_add( dotLR_fx, W_mult0_32_32( output_fx[0][i], output_fx[1][i] ) );
}
- dotLR_fx = dotLR_fx + EPSILON_FX_SMALL;
- IF( dotLR_fx < 0 )
+ dotLR_fx = W_add( dotLR_fx, EPSILON_FX_SMALL );
+ if ( dotLR_fx < 0 )
{
dotLR_fx = W_neg( dotLR_fx );
}
- enrL_fx = enrL_fx + EPSILON_FX_SMALL;
- enrR_fx = enrR_fx + EPSILON_FX_SMALL;
+ enrL_fx = W_add( enrL_fx, EPSILON_FX_SMALL );
+ enrR_fx = W_add( enrR_fx, EPSILON_FX_SMALL );
headroom_left_enrL = W_norm( enrL_fx );
headroom_left_enrR = W_norm( enrR_fx );
{
- IF( headroom_left_enrL < 32 )
+ IF( LT_16( headroom_left_enrL, 32 ) )
{
- enrL_fx = W_shr( enrL_fx, ( 32 - headroom_left_enrL ) );
- enrL_q = ( 31 - ( ( 2 * OUTPUT_Q ) - ( 32 - headroom_left_enrL ) ) );
+ enrL_fx = W_shr( enrL_fx, sub( 32, headroom_left_enrL ) );
+ enrL_q = sub( 31, sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_enrL ) ) );
}
ELSE
{
- enrL_q = 31 - ( 2 * OUTPUT_Q );
+ enrL_q = sub( 31, ( 2 * OUTPUT_Q ) );
}
- IF( headroom_left_enrR < 32 )
+ IF( LT_16( headroom_left_enrR, 32 ) )
{
- enrR_fx = W_shr( enrR_fx, ( 32 - headroom_left_enrR ) );
- enrR_q = ( 31 - ( ( 2 * OUTPUT_Q ) - ( 32 - headroom_left_enrR ) ) );
+ enrR_fx = W_shr( enrR_fx, sub( 32, headroom_left_enrR ) );
+ enrR_q = sub( 31, sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_enrR ) ) );
}
ELSE
{
- enrR_q = 31 - ( 2 * OUTPUT_Q );
+ enrR_q = sub( 31, ( 2 * OUTPUT_Q ) );
}
enrL_inv_q = enrL_q;
+ move16();
enrR_inv_q = enrR_q;
+ move16();
- temp_x_inv = ISqrt32( (Word32) enrL_fx, &enrL_inv_q );
- temp_y_inv = ISqrt32( (Word32) enrR_fx, &enrR_inv_q );
+ temp_x_inv = ISqrt32( W_extract_l( enrL_fx ), &enrL_inv_q );
+ temp_y_inv = ISqrt32( W_extract_l( enrR_fx ), &enrR_inv_q );
energy_xy_fx = Mpy_32_32( temp_x_inv, temp_y_inv );
- res_q = enrL_inv_q + enrR_inv_q;
+ res_q = add( enrL_inv_q, enrR_inv_q );
headroom_left_dotLR = W_norm( dotLR_fx );
dotLR_q = OUTPUT_Q * 2;
- IF( headroom_left_dotLR < 32 )
+ move16();
+ IF( LT_16( headroom_left_dotLR, 32 ) )
{
- dotLR_fx = W_shr( dotLR_fx, 32 - headroom_left_dotLR );
- dotLR_q = dotLR_q - ( 32 - headroom_left_dotLR );
+ dotLR_fx = W_shr( dotLR_fx, sub( 32, headroom_left_dotLR ) );
+ dotLR_q = sub( dotLR_q, sub( 32, headroom_left_dotLR ) );
}
- dotLR_fx = Mpy_32_32( (Word32) dotLR_fx, energy_xy_fx );
- dotLR_q = dotLR_q + ( 31 - res_q ) - 31;
- dotLR_fx = W_shl( dotLR_fx, 31 - dotLR_q );
+ dotLR_fx = Mpy_32_32( W_extract_l( dotLR_fx ), energy_xy_fx );
+ dotLR_q = add( dotLR_q, sub( sub( 31, res_q ), 31 ) );
+ dotLR_fx = W_shl( dotLR_fx, sub( 31, dotLR_q ) );
}
- c_LR_fx = extract_h( (Word32) dotLR_fx );
+ c_LR_fx = extract_h( W_extract_l( dotLR_fx ) );
Word16 div_q = 0;
- c_fx = BASOP_Util_Divide3232_Scale( (Word32) enrL_fx, (Word32) enrR_fx, &div_q );
- c_q = 15 - div_q + ( enrR_q - enrL_q );
+ move16();
+ c_fx = BASOP_Util_Divide3232_Scale( W_extract_l( enrL_fx ), W_extract_l( enrR_fx ), &div_q );
+ c_q = add( sub( 15, div_q ), sub( enrR_q, enrL_q ) );
hCPE->hStereoTD->c_LR_LT_fx = L_add( Mpy_32_32( STEREO_TD_PS_CORR_FILT_FX, hCPE->hStereoTD->c_LR_LT_fx ),
- Mpy_32_32( L_sub( ONE_IN_Q31, STEREO_TD_PS_CORR_FILT_FX ), L_deposit_h( (Word16) c_LR_fx ) ) );
+ Mpy_32_32( L_sub( ONE_IN_Q31, STEREO_TD_PS_CORR_FILT_FX ), L_deposit_h( extract_l( c_LR_fx ) ) ) );
+ move32();
hCPE->hStereoCng->c_LR_LT_fx = hCPE->hStereoTD->c_LR_LT_fx;
+ move32();
- Word16 sqrt_q = 31 - c_q;
+ Word16 sqrt_q = sub( 31, c_q );
Word32 sqrt_res = Sqrt32( c_fx, &sqrt_q );
tmp_fx = Mpy_32_32( beta_fx, L_sub( ONE_IN_Q31, beta_fx ) );
tmp_fx = Mpy_32_32( tmp_fx, hCPE->hStereoTD->c_LR_LT_fx );
tmp_fx = Mpy_32_32( tmp_fx, sqrt_res );
- Word16 tmp_q = ( 31 - sqrt_q ) - 1; // *2 handled with q reduction
+ Word16 tmp_q = sub( sub( 31, sqrt_q ), 1 ); // *2 handled with q reduction
beta_sqr = Mpy_32_32( beta_fx, beta_fx );
one_minus_beta_sqr = Mpy_32_32( L_sub( ONE_IN_Q31, beta_fx ), L_sub( ONE_IN_Q31, beta_fx ) );
- numer_1 = Mpy_32_16_1( one_minus_beta_sqr, (Word16) c_fx ); // c_q+31-15
- numer_1_q = c_q + 31 - 15;
+ numer_1 = Mpy_32_16_1( one_minus_beta_sqr, extract_l( c_fx ) ); // c_q+31-15
+ numer_1_q = add( c_q, 31 - 15 );
numer_2 = beta_sqr; // 31
+ move32();
numer_2_q = 31;
+ move16();
numer_3 = tmp_fx; // tmp_q
+ move32();
numer_3_q = tmp_q;
+ move16();
num_q = 31;
- num_q = num_q < numer_1_q ? num_q : numer_1_q;
- num_q = num_q < numer_2_q ? num_q : numer_2_q;
- num_q = num_q < numer_3_q ? num_q : numer_3_q;
+ move16();
+
+ num_q = s_min( num_q, numer_1_q );
+ num_q = s_min( num_q, numer_2_q );
- denom_1 = Mpy_32_16_1( beta_sqr, (Word16) c_fx ); // c_q+31-15;
- denom_1_q = c_q + 31 - 15;
+ num_q = s_min( num_q, numer_3_q );
+
+ denom_1 = Mpy_32_16_1( beta_sqr, extract_l( c_fx ) ); // c_q+31-15;
+ denom_1_q = add( c_q, 31 - 15 );
denom_2 = one_minus_beta_sqr; // 31
+ move32();
denom_2_q = 31;
+ move16();
denom_3 = tmp_fx; // tmp_q
+ move32();
denom_3_q = tmp_q;
+ move16();
denom_q = 31;
- denom_q = denom_q < denom_1_q ? denom_q : denom_1_q;
- denom_q = denom_q < denom_2_q ? denom_q : denom_2_q;
- denom_q = denom_q < denom_3_q ? denom_q : denom_3_q;
+ move16();
+
+ denom_q = s_min( denom_q, denom_1_q );
+
+ denom_q = s_min( denom_q, denom_2_q );
- num = L_add( L_shr( numer_1, numer_1_q - num_q ), L_sub( L_shr( numer_2, numer_2_q - num_q ), L_shr( numer_3, numer_3_q - num_q ) ) ) + DELTA_FX;
- denom = L_add( L_shr( denom_1, denom_1_q - denom_q ), L_add( L_shr( denom_2, denom_2_q - denom_q ), L_shr( denom_3, denom_3_q - denom_q ) ) ) + DELTA_FX;
+ denom_q = s_min( denom_q, denom_3_q );
+
+ num = L_add( L_add( L_shr( numer_1, sub( numer_1_q, num_q ) ), L_sub( L_shr( numer_2, sub( numer_2_q, num_q ) ), L_shr( numer_3, sub( numer_3_q, num_q ) ) ) ), DELTA_FX );
+ denom = L_add( L_add( L_shr( denom_1, sub( denom_1_q, denom_q ) ), L_add( L_shr( denom_2, sub( denom_2_q, denom_q ) ), L_shr( denom_3, sub( denom_3_q, denom_q ) ) ) ), DELTA_FX );
Word16 q = 0;
+ move16();
sc_fx = BASOP_Util_Divide3232_Scale( num, denom, &q );
- sc_q = 15 - ( num_q - denom_q ) - q;
+ sc_q = sub( sub( 15, sub( num_q, denom_q ) ), q );
Word32 sc_thr = L_shr( sc_fx, sc_q );
- IF( sc_thr > 4 )
+ IF( GT_32( sc_thr, 4 ) )
{
sc_fx = MAX_WORD16;
+ move32();
}
ELSE
{
- sc_fx = L_shr( sc_fx, sc_q - 13 );
+ sc_fx = L_shr( sc_fx, sub( sc_q, 13 ) );
}
sqrt_q = 2;
+ move16();
sqrt_res = Sqrt32( L_shl_sat( sc_fx, 16 ), &sqrt_q );
IF( sqrt_q < 0 )
{
- sqrt_res = L_shr( sqrt_res, -1 * sqrt_q );
+ sqrt_res = L_shr( sqrt_res, ( -sqrt_q ) );
sqrt_q = 0;
+ move16();
}
hCPE->hStereoTD->SP_ratio_LT_fx = L_add_sat( Mpy_32_32( 1932735283, hCPE->hStereoTD->SP_ratio_LT_fx ),
L_shl_sat( Mpy_32_32( 214748364, sqrt_res ), sqrt_q ) );
+ move32();
- IF( hCPE->hStereoCng->nr_corr_frames < CM_INIT )
+ IF( LT_16( hCPE->hStereoCng->nr_corr_frames, CM_INIT ) )
{
- hCPE->hStereoCng->nr_corr_frames++;
+ hCPE->hStereoCng->nr_corr_frames = add( hCPE->hStereoCng->nr_corr_frames, 1 );
+ move16();
}
hCPE->hStereoCng->nr_dft_frames = 0;
+ move16();
return;
}
@@ -1912,51 +2031,58 @@ static void FindEmEs_fx(
Word16 headroom_left_ener_fx, headroom_left_ener_side_fx;
Word16 ener_q, ener_side_q;
ener_fx = 1;
+ move64();
ener_side_fx = 1;
+ move64();
Word32 square_res, log_res, division_res;
Word16 temp_q = 0;
- for ( i = 0; i < len; i++ )
+ move16();
+ FOR( i = 0; i < len; i++ )
{
mono_i_fx = L_add( L_shr( ch1_fx[i], 1 ), L_shr( ch2_fx[i], 1 ) );
- ener_fx = W_add( ener_fx, ( (Word64) mono_i_fx * mono_i_fx ) );
+ ener_fx = W_add( ener_fx, W_mult0_32_32( mono_i_fx, mono_i_fx ) );
side_i_fx = L_sub( L_shr( ch1_fx[i], 1 ), L_shr( ch2_fx[i], 1 ) );
- ener_side_fx = W_add( ener_side_fx, ( (Word64) side_i_fx * side_i_fx ) );
+ ener_side_fx = W_add( ener_side_fx, W_mult0_32_32( side_i_fx, side_i_fx ) );
}
headroom_left_ener_fx = W_norm( ener_fx );
headroom_left_ener_side_fx = W_norm( ener_side_fx );
- IF( headroom_left_ener_fx < 32 )
+ IF( LT_16( headroom_left_ener_fx, 32 ) )
{
- ener_fx = W_shr( ener_fx, ( 32 - headroom_left_ener_fx ) );
- ener_q = ( ( 2 * OUTPUT_Q ) - ( 32 - headroom_left_ener_fx ) );
+ ener_fx = W_shr( ener_fx, sub( 32, headroom_left_ener_fx ) );
+ ener_q = sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_ener_fx ) );
}
ELSE
{
ener_q = ( 2 * OUTPUT_Q );
+ move16();
}
- IF( headroom_left_ener_side_fx < 32 )
+ IF( LT_16( headroom_left_ener_side_fx, 32 ) )
{
- ener_side_fx = W_shr( ener_side_fx, ( 32 - headroom_left_ener_side_fx ) );
- ener_side_q = ( ( 2 * OUTPUT_Q ) - ( 32 - headroom_left_ener_side_fx ) );
+ ener_side_fx = W_shr( ener_side_fx, sub( 32, headroom_left_ener_side_fx ) );
+ ener_side_q = sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_ener_side_fx ) );
}
ELSE
{
ener_side_q = ( 2 * OUTPUT_Q );
+ move16();
}
/**es_em = 10 * ( log10( sqrt( ener_side / len ) ) - log10( sqrt( ener / len ) ) ); */
- division_res = BASOP_Util_Divide3232_Scale( (Word32) ener_side_fx, (Word32) ener_fx, &temp_q );
- temp_q = temp_q - ( ener_side_q - ener_q );
- square_res = Sqrt32( L_deposit_h( (Word16) division_res ), &temp_q );
+ division_res = BASOP_Util_Divide3232_Scale( W_extract_l( ener_side_fx ), W_extract_l( ener_fx ), &temp_q );
+ temp_q = sub( temp_q, sub( ener_side_q, ener_q ) );
+ square_res = Sqrt32( L_deposit_h( extract_l( division_res ) ), &temp_q );
IF( temp_q < 0 )
{
- square_res = L_shr( square_res, -1 * temp_q );
+ square_res = L_shr( square_res, ( -temp_q ) );
temp_q = 0;
+ move16();
}
log_res = BASOP_Util_Log2( square_res );
es_em_fx = Mpy_32_32( log_res, 1616107501 ); // 25+30
/* long-term estimate */
*lt_es_em_fx = L_add( Mpy_32_32( 858993459, *lt_es_em_fx ), Mpy_32_32( 1288490188, es_em_fx ) );
+ move32();
return;
}
#endif
@@ -2082,11 +2208,11 @@ void stereo_cna_update_params(
void stereo_cna_update_params_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
Word32 *output_fx[CPE_CHANNELS], /* i : Output signal */
- const int16_t output_frame, /* i : Output frame length */
- const int16_t tdm_ratio_idx /* i : TDM ratio index */
+ const Word16 output_frame, /* i : Output frame length */
+ const Word16 tdm_ratio_idx /* i : TDM ratio index */
)
{
- int16_t i;
+ Word16 i;
Word64 enrL_fx, enrR_fx, dotLR_fx;
Word32 c_fx, c_LR_fx, c_ILD_fx;
Decoder_State **sts;
@@ -2109,110 +2235,124 @@ void stereo_cna_update_params_fx(
/////
- if ( hCPE->element_mode == IVAS_CPE_DFT )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- if ( hCPE->nchan_out > 1 )
+ IF( GT_16( hCPE->nchan_out, 1 ) )
{
FindEmEs_fx( output_fx[0], output_fx[1], output_frame, &hCPE->lt_es_em_fx );
}
- else
+ ELSE
{
hCPE->lt_es_em_fx = 0;
+ move32();
}
}
- else if ( hCPE->element_mode == IVAS_CPE_TD )
+ ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
FindEmEs_fx( output_fx[0], output_fx[1], output_frame, &hCPE->lt_es_em_fx );
hCPE->hStereoCng->first_SID_after_TD = 1;
+ move16();
stereo_cng_compute_LRcorr_fx( hCPE, output_fx, output_frame, tdm_ratio_idx );
}
- else
+ ELSE
{
return;
}
enrL_fx = 0;
+ move64();
enrR_fx = 0;
+ move64();
dotLR_fx = 0;
+ move64();
-
- if ( hCPE->element_mode == IVAS_CPE_TD || ( hCPE->element_mode == IVAS_CPE_DFT && sts[0]->core_brate > SID_2k40 && sts[0]->VAD == 0 ) )
+ test();
+ test();
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && GT_32( sts[0]->core_brate, SID_2k40 ) && ( sts[0]->VAD == 0 ) ) )
{
- if ( hCPE->nchan_out == 1 )
+ IF( EQ_16( hCPE->nchan_out, 1 ) )
{
c_LR_fx = MAX_WORD16;
+ move32();
c_ILD_fx = 0;
+ move32();
}
- else
+ ELSE
{
FOR( i = 0; i < output_frame; i++ )
{
-
- enrL_fx += ( (Word64) output_fx[0][i] ) * ( output_fx[0][i] );
- enrR_fx += ( (Word64) output_fx[1][i] ) * ( output_fx[1][i] );
- dotLR_fx += ( ( (Word64) output_fx[0][i] ) * ( output_fx[1][i] ) );
+ enrL_fx = W_add( enrL_fx, W_mult0_32_32( output_fx[0][i], output_fx[0][i] ) );
+ enrR_fx = W_add( enrR_fx, W_mult0_32_32( output_fx[1][i], output_fx[1][i] ) );
+ dotLR_fx = W_add( dotLR_fx, W_mult0_32_32( output_fx[0][i], output_fx[1][i] ) );
}
- dotLR_fx = dotLR_fx + EPSILON_FX_SMALL;
+ dotLR_fx = W_add( dotLR_fx, EPSILON_FX_SMALL );
if ( dotLR_fx < 0 )
{
dotLR_fx = W_neg( dotLR_fx );
}
- enrL_fx = enrL_fx + EPSILON_FX_SMALL;
- enrR_fx = enrR_fx + EPSILON_FX_SMALL;
+ enrL_fx = W_add( enrL_fx, EPSILON_FX_SMALL );
+ enrR_fx = W_add( enrR_fx, EPSILON_FX_SMALL );
headroom_left_x = W_norm( enrL_fx );
headroom_left_y = W_norm( enrR_fx );
- IF( headroom_left_x < 32 )
+ IF( LT_16( headroom_left_x, 32 ) )
{
- enrL_fx = W_shr( enrL_fx, ( 32 - headroom_left_x ) );
- x_q = ( 31 - ( ( 2 * OUTPUT_Q ) - ( 32 - headroom_left_x ) ) );
+ enrL_fx = W_shr( enrL_fx, sub( 32, headroom_left_x ) );
+ x_q = sub( 31, sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_x ) ) );
}
ELSE
{
- x_q = 31 - ( 2 * OUTPUT_Q );
+ x_q = sub( 31, ( 2 * OUTPUT_Q ) );
}
- IF( headroom_left_y < 32 )
+ IF( LT_16( headroom_left_y, 32 ) )
{
- enrR_fx = W_shr( enrR_fx, ( 32 - headroom_left_y ) );
- y_q = ( 31 - ( ( 2 * OUTPUT_Q ) - ( 32 - headroom_left_y ) ) );
+ enrR_fx = W_shr( enrR_fx, sub( 32, headroom_left_y ) );
+ y_q = sub( 31, sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_y ) ) );
}
ELSE
{
- y_q = 31 - ( 2 * OUTPUT_Q );
+ y_q = sub( 31, ( 2 * OUTPUT_Q ) );
}
x_inv_q = x_q;
+ move16();
y_inv_q = y_q;
+ move16();
- temp_x_inv = ISqrt32( (Word32) enrL_fx, &x_inv_q );
- temp_y_inv = ISqrt32( (Word32) enrR_fx, &y_inv_q );
+ temp_x_inv = ISqrt32( W_extract_l( enrL_fx ), &x_inv_q );
+ temp_y_inv = ISqrt32( W_extract_l( enrR_fx ), &y_inv_q );
energy_xy_fx = Mpy_32_32( temp_x_inv, temp_y_inv );
- temp_res_q = x_inv_q + y_inv_q;
+ temp_res_q = add( x_inv_q, y_inv_q );
headroom_left_dotLR_fx = W_norm( dotLR_fx );
dotLR_fx_q = OUTPUT_Q * 2;
- IF( headroom_left_dotLR_fx < 32 )
+ move16();
+ IF( LT_16( headroom_left_dotLR_fx, 32 ) )
{
- dotLR_fx = W_shr( dotLR_fx, 32 - headroom_left_dotLR_fx );
- dotLR_fx_q = dotLR_fx_q - ( 32 - headroom_left_dotLR_fx );
+ dotLR_fx = W_shr( dotLR_fx, sub( 32, headroom_left_dotLR_fx ) );
+ dotLR_fx_q = sub( dotLR_fx_q, sub( 32, headroom_left_dotLR_fx ) );
}
- dotLR_fx = Mpy_32_32( (Word32) dotLR_fx, energy_xy_fx );
- dotLR_fx_q = dotLR_fx_q + ( 31 - temp_res_q ) - 31;
- dotLR_fx = (Word64) L_shl_sat( (Word32) dotLR_fx, 31 - dotLR_fx_q );
+ dotLR_fx = Mpy_32_32( W_extract_l( dotLR_fx ), energy_xy_fx );
+ dotLR_fx_q = add( dotLR_fx_q, sub( sub( 31, temp_res_q ), 31 ) );
+ dotLR_fx = W_deposit32_l( L_shl_sat( W_extract_l( dotLR_fx ), sub( 31, dotLR_fx_q ) ) );
/* estimate L/R correlation factor and ILD in time domain */
- c_LR_fx = extract_h( (Word32) dotLR_fx );
+ c_LR_fx = extract_h( W_extract_l( dotLR_fx ) );
temp_res_q = 0;
- c_fx = BASOP_Util_Divide3232_Scale( (Word32) enrL_fx, (Word32) enrR_fx, &temp_res_q );
- c_q = 15 - temp_res_q + ( y_q - x_q );
+ move16();
+ c_fx = BASOP_Util_Divide3232_Scale( W_extract_l( enrL_fx ), W_extract_l( enrR_fx ), &temp_res_q );
+ c_q = add( sub( 15, temp_res_q ), sub( y_q, x_q ) );
Word32 one_in_c_q;
IF( GT_16( c_q, 31 ) )
{
c_q = 31;
- c_fx = L_shr_sat( c_fx, c_q - 31 );
+ move16();
+ c_fx = L_shr_sat( c_fx, sub( c_q, 31 ) );
one_in_c_q = ONE_IN_Q31;
+ move32();
}
ELSE
{
@@ -2223,28 +2363,34 @@ void stereo_cna_update_params_fx(
Word32 denom_c_fx = L_add_sat( c_fx, one_in_c_q );
Word16 num_c_headroom = norm_l( L_sub_sat( c_fx, one_in_c_q ) );
Word16 denom_c_headroom = norm_l( L_add_sat( c_fx, one_in_c_q ) );
- Word16 min_headroom_left = num_c_headroom < denom_c_headroom ? num_c_headroom : denom_c_headroom;
+ Word16 min_headroom_left = s_min( num_c_headroom, denom_c_headroom );
+ move16();
temp_res_q = 0;
+ move16();
c_ILD_fx = BASOP_Util_Divide3232_Scale( L_shl_sat( num_c_fx, min_headroom_left ), L_shl_sat( denom_c_fx, min_headroom_left ), &temp_res_q );
- if ( temp_res_q < 0 )
+ IF( temp_res_q < 0 )
{
- c_ILD_fx = L_shr( c_ILD_fx, -1 * temp_res_q );
+ c_ILD_fx = L_shr( c_ILD_fx, negate( temp_res_q ) );
}
}
/* update of long-term ILD and LR correlation factors for stereo CNA */
- if ( !hFdCngDec->first_cna_noise_updated )
+ IF( !hFdCngDec->first_cna_noise_updated )
{
- hFdCngDec->cna_LR_LT_fx = (Word16) c_LR_fx;
- hFdCngDec->cna_ILD_LT_fx = (Word16) c_ILD_fx;
+ hFdCngDec->cna_LR_LT_fx = extract_l( c_LR_fx );
+ move16();
+ hFdCngDec->cna_ILD_LT_fx = extract_l( c_ILD_fx );
+ move16();
}
- else
+ ELSE
{
hFdCngDec->cna_LR_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_LR_CORR_LT_FILT_FX, hFdCngDec->cna_LR_LT_fx ),
- Mpy_32_16_1( L_sub( ONE_IN_Q31, STEREO_CNA_LR_CORR_LT_FILT_FX ), (Word16) c_LR_fx ) ) );
+ Mpy_32_16_1( L_sub( ONE_IN_Q31, STEREO_CNA_LR_CORR_LT_FILT_FX ), extract_l( c_LR_fx ) ) ) );
+ move16();
hFdCngDec->cna_ILD_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_ILD_LT_FILT_FX, hFdCngDec->cna_ILD_LT_fx ),
- Mpy_32_16_1( L_sub( ONE_IN_Q31, STEREO_CNA_ILD_LT_FILT_FX ), (Word16) c_ILD_fx ) ) );
+ Mpy_32_16_1( L_sub( ONE_IN_Q31, STEREO_CNA_ILD_LT_FILT_FX ), extract_l( c_ILD_fx ) ) ) );
+ move16();
}
set16_fx( hFdCngDec->cna_g_state_fx, hFdCngDec->cna_ILD_LT_fx, hFdCngDec->cna_nbands );
@@ -2253,33 +2399,37 @@ void stereo_cna_update_params_fx(
/* Soft VAD for stereo CNA */
- if ( hCPE->element_mode == IVAS_CPE_TD || hCPE->element_mode == IVAS_CPE_DFT )
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) || EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- if ( !hFdCngDec->first_cna_noise_updated )
+ IF( !hFdCngDec->first_cna_noise_updated )
{
hFdCngDec->cna_act_fact_fx = 0;
+ move16();
}
- else
+ ELSE
{
- if ( hCPE->element_mode == IVAS_CPE_TD )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
/* quickly decrease in TD stereo mode */
hFdCngDec->cna_act_fact_fx = extract_h( Mpy_32_16_1( 1503238553, hFdCngDec->cna_act_fact_fx ) );
+ move16();
}
- else if ( ( sts[0]->VAD * MAX_WORD16 ) > hFdCngDec->cna_act_fact_fx ) // VAD is one bit
+ ELSE IF( GT_32( L_mult0( sts[0]->VAD, MAX_WORD16 ), hFdCngDec->cna_act_fact_fx ) ) // VAD is one bit
{
/* quickly increase during active frames in DFT stereo mode */
- hFdCngDec->cna_act_fact_fx = extract_h( Mpy_32_16_1( 1503238553, hFdCngDec->cna_act_fact_fx ) + ( 644245094 * sts[0]->VAD ) );
+ hFdCngDec->cna_act_fact_fx = extract_h( L_add( Mpy_32_16_1( 1503238553, hFdCngDec->cna_act_fact_fx ), ( 644245094 * sts[0]->VAD ) ) );
+ move16();
}
- else
+ ELSE
{
/* slowly decrease during inactive frames in DFT stereo mode */
- hFdCngDec->cna_act_fact_fx = extract_h( Mpy_32_16_1( 2040109440, hFdCngDec->cna_act_fact_fx ) + ( 107374184 * sts[0]->VAD ) );
+ hFdCngDec->cna_act_fact_fx = extract_h( L_add( Mpy_32_16_1( 2040109440, hFdCngDec->cna_act_fact_fx ), ( 107374184 * sts[0]->VAD ) ) );
+ move16();
}
}
}
-
return;
}
#endif
@@ -2351,8 +2501,8 @@ void stereo_cng_init_dec_fx(
hStereoCng->enableSecCNA = 0;
move16();
hStereoCng->c_PS_LT_fx = 16384; /* 0.5 in Q15 */
- hStereoCng->frameSize = frameSize;
move16();
+ hStereoCng->frameSize = frameSize;
hStereoCng->last_act_element_mode = IVAS_CPE_DFT;
move16();
diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c
index daa92a594b572c8c919b5236c3a4e987e89ed8e1..09fc9f2fd95b16876554ac6c29924ceeeb83b250 100644
--- a/lib_dec/ivas_stereo_dft_dec.c
+++ b/lib_dec/ivas_stereo_dft_dec.c
@@ -38,7 +38,7 @@
#include "rom_com.h"
#include "rom_dec.h"
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_cnst.h"
#include "ivas_rom_com.h"
@@ -695,20 +695,21 @@ void stereo_dft_dec_analyze_fx(
* Initialization
*-----------------------------------------------------------------*/
- IF( input_frame == output_frame )
+ IF( EQ_16( input_frame, output_frame ) )
{
trigo_fx = hStereoDft->dft_trigo_fx;
- trigo_step = hStereoDft->dft_trigo_step * STEREO_DFT_TRIGO_DEC_STEP;
+ trigo_step = i_mult( hStereoDft->dft_trigo_step, STEREO_DFT_TRIGO_DEC_STEP );
win_right_fx = hStereoDft->win32ms_fx;
win_left_fx = hStereoDft->win32ms_fx;
win2_fx = hStereoDft->win232ms_fx;
- IF( ana_type == DFT_STEREO_DEC_ANA_BPF )
+ test();
+ IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_BPF ) )
{
assert( ( chan == 0 ) && "DFT stereo: BPF memory only FOR M channel" );
mem_fx = hCPE->input_mem_BPF_fx[chan];
}
- ELSE IF( ana_type == DFT_STEREO_DEC_ANA_LB || ana_type == DFT_STEREO_DEC_ANA_LB_ADD )
+ ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB_ADD ) )
{
mem_fx = hCPE->input_mem_LB_fx[chan];
}
@@ -717,20 +718,22 @@ void stereo_dft_dec_analyze_fx(
mem_fx = hCPE->input_mem_fx[chan];
}
}
- ELSE IF( input_frame == L_FRAME )
+ ELSE IF( EQ_16( input_frame, L_FRAME ) )
{
trigo_fx = hStereoDft->dft_trigo_12k8_fx;
trigo_step = STEREO_DFT_TRIGO_SRATE_12k8_STEP * STEREO_DFT_TRIGO_DEC_STEP;
+ move16();
win_right_fx = hStereoDft->win32ms_12k8_fx;
win_left_fx = hStereoDft->win32ms_12k8_fx;
win2_fx = hStereoDft->win232ms_12k8_fx;
- IF( ana_type == DFT_STEREO_DEC_ANA_BPF )
+ test();
+ IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_BPF ) )
{
assert( ( chan == 0 ) && "DFT stereo: BPF memory only FOR M channel" );
mem_fx = hCPE->input_mem_BPF_fx[chan];
}
- ELSE IF( ana_type == DFT_STEREO_DEC_ANA_LB || ana_type == DFT_STEREO_DEC_ANA_LB_ADD )
+ ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB_ADD ) )
{
mem_fx = hCPE->input_mem_LB_fx[chan];
}
@@ -740,34 +743,37 @@ void stereo_dft_dec_analyze_fx(
mem_fx = hCPE->input_mem_fx[chan];
}
}
- ELSE IF( input_frame == L_FRAME16k )
+ ELSE IF( EQ_16( input_frame, L_FRAME16k ) )
{
trigo_fx = hStereoDft->dft_trigo_16k_fx;
trigo_step = STEREO_DFT_TRIGO_SRATE_16k_STEP * STEREO_DFT_TRIGO_DEC_STEP;
+ move16();
win_right_fx = hStereoDft->win32ms_16k_fx;
win_left_fx = hStereoDft->win32ms_16k_fx;
win2_fx = hStereoDft->win232ms_16k_fx;
- IF( ana_type == DFT_STEREO_DEC_ANA_BPF )
+ test();
+ IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_BPF ) )
{
assert( ( chan == 0 ) && "DFT stereo: BPF memory only FOR M channel" );
mem_fx = hCPE->input_mem_BPF_fx[chan];
}
- ELSE IF( ana_type == DFT_STEREO_DEC_ANA_LB || ana_type == DFT_STEREO_DEC_ANA_LB_ADD )
+ ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB_ADD ) )
{
mem_fx = hCPE->input_mem_LB_fx[chan];
}
ELSE
{
- assert( ( chan == 1 ) && hCPE->hStereoDft->hConfig->res_pred_mode == STEREO_DFT_RESPRED_ESF && "16kHz sampling rate only FOR second channel with allpass signal" );
+ assert( ( chan == 1 ) && ( hCPE->hStereoDft->hConfig->res_pred_mode == STEREO_DFT_RESPRED_ESF ) && "16kHz sampling rate only FOR second channel with allpass signal" );
mem_fx = hCPE->input_mem_fx[chan];
}
}
- ELSE IF( input_frame == L_FRAME8k )
+ ELSE IF( EQ_16( input_frame, L_FRAME8k ) )
{
assert( ( chan == 1 ) && "DFT stereo: 8kHz analysis only FOR residual coding" );
trigo_fx = hStereoDft->dft_trigo_8k_fx;
trigo_step = STEREO_DFT_TRIGO_SRATE_8k_STEP * STEREO_DFT_TRIGO_DEC_STEP;
+ move16();
win_right_fx = hStereoDft->win32ms_8k_fx;
win_left_fx = hStereoDft->win32ms_8k_fx;
win2_fx = hStereoDft->win232ms_8k_fx;
@@ -776,27 +782,32 @@ void stereo_dft_dec_analyze_fx(
ELSE
{
IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error in DFT stereo: sampling rate not supported" );
- mem_fx = NULL; /* to avoid compilation warning */
- trigo_fx = NULL; /* to avoid compilation warning */
- trigo_step = -1; /* to avoid compilation warning */
+ mem_fx = NULL; /* to avoid compilation warning */
+ trigo_fx = NULL; /* to avoid compilation warning */
+ trigo_step = -1; /* to avoid compilation warning */
+ move16();
win_right_fx = NULL; /* to avoid compilation warning */
win_left_fx = NULL; /* to avoid compilation warning */
win2_fx = NULL; /* to avoid compilation warning */
}
- inputFs = input_frame * FRAMES_PER_SEC;
+ inputFs = L_mult0( input_frame, FRAMES_PER_SEC );
delay_dec = NS2SA( inputFs, STEREO_DFT32MS_OVL_NS );
+ move16();
zp = NS2SA( inputFs, STEREO_DFT32MS_ZP_NS );
+ move16();
ovl = NS2SA( inputFs, STEREO_DFT32MS_OVL_NS );
+ move16();
NFFT = NS2SA( inputFs, STEREO_DFT32MS_N_NS );
Word16 qfac_fx;
fac_fx = BASOP_Util_Divide3232_Scale_cadence( hStereoDft->NFFT, NFFT, &qfac_fx );
qfac_fx = sub( 31, qfac_fx );
ovl2 = NS2SA( inputFs, STEREO_DFT32MS_OVL2_NS );
+ move16();
/* Offset FOR the time buffers */
- assert( ( delay >= -NS2SA( input_frame * FRAMES_PER_SEC, STEREO_DFT_DELAY_DEC_BWE_NS + STEREO_DFT_OVL_NS / 2 ) ) && ( delay <= NS2SA( input_frame * FRAMES_PER_SEC, STEREO_DFT_OVL_NS ) ) );
- mem_size = delay_dec + delay;
+ assert( ( delay >= -NS2SA( ( input_frame * FRAMES_PER_SEC ), STEREO_DFT_DELAY_DEC_BWE_NS + STEREO_DFT_OVL_NS / 2 ) ) && ( delay <= NS2SA( ( input_frame * FRAMES_PER_SEC ), STEREO_DFT_OVL_NS ) ) );
+ mem_size = add( delay_dec, delay );
/* Update buffers */
Copy32( mem_fx, input_buff_fx, mem_size );
@@ -804,7 +815,8 @@ void stereo_dft_dec_analyze_fx(
Copy32( input_buff_fx + input_frame, mem_fx, mem_size );
pInput_buff_fx = input_buff_fx;
- IF( hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF )
+ test();
+ IF( EQ_16( hCPE->nchan_out, 1 ) && ( hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) )
{
pop_wmops();
return;
@@ -815,145 +827,176 @@ void stereo_dft_dec_analyze_fx(
* DFT Analysis: loop over frame
*-----------------------------------------------------------------*/
- assert( k_offset <= STEREO_DFT_NBDIV );
+ assert( ( k_offset <= STEREO_DFT_NBDIV ) );
- FOR( i = 0; i < NFFT / 4; i++ )
+ FOR( i = 0; i < shr( NFFT, 2 ); i++ )
{
- trigo_dec_fx[i] = trigo_fx[i * trigo_step];
- trigo_dec_fx[NFFT / 2 - i] = trigo_fx[i * trigo_step];
+ trigo_dec_fx[i] = trigo_fx[i_mult( i, trigo_step )];
+ move16();
+ trigo_dec_fx[sub( NFFT / 2, i )] = trigo_fx[i_mult( i, trigo_step )];
+ move16();
}
- trigo_dec_fx[NFFT / 4] = trigo_fx[NFFT / 4 * trigo_step];
+ trigo_dec_fx[NFFT / 4] = trigo_fx[i_mult( NFFT / 4, trigo_step )];
+ move16();
- FOR( k = 0; k < STEREO_DFT_NBDIV - k_offset; k++ )
+ FOR( k = 0; k < sub( STEREO_DFT_NBDIV, k_offset ); k++ )
{
set32_fx( DFT_fx, 0, STEREO_DFT32MS_N_MAX );
IF( k == 0 )
{
offset = 0;
+ move16();
}
ELSE
{
/* If OVL2 = OVL offset = 10ms */
offset = NS2SA( inputFs, STEREO_DFT32MS_WIN_CENTER_NS - STEREO_DFT32MS_OVL2_NS / 2 );
+ move16();
}
pInput_fx = pInput_buff_fx + offset;
- pDFT_out_fx = out_DFT_fx[chan] + k * STEREO_DFT32MS_N_MAX;
+ pDFT_out_fx = out_DFT_fx[chan] + i_mult( k, STEREO_DFT32MS_N_MAX );
/*Forwards FFT: L and R*/
/* Zero Padding & Flat Portion */
- Copy32( pInput_fx, DFT_fx + zp, NFFT - 2 * zp );
+ Copy32( pInput_fx, DFT_fx + zp, sub( NFFT, i_mult( 2, zp ) ) );
/* Overlapping portions */
IF( k == 0 )
{
FOR( i = 0; i < ovl; i++ )
{
- DFT_fx[i + zp] = Mpy_32_16_1( DFT_fx[i + zp], win_left_fx[STEREO_DFT32MS_STEP * i] );
+ DFT_fx[add( i, zp )] = Mpy_32_16_1( DFT_fx[add( i, zp )], win_left_fx[i_mult( STEREO_DFT32MS_STEP, i )] );
+ move32();
}
FOR( i = 0; i < ovl2; i++ )
{
- DFT_fx[NFFT - zp - 1 - i] = Mpy_32_16_1( DFT_fx[NFFT - zp - 1 - i], win2_fx[i] );
+ DFT_fx[sub( sub( sub( NFFT, zp ), 1 ), i )] = Mpy_32_16_1( DFT_fx[sub( sub( sub( NFFT, zp ), 1 ), i )], win2_fx[i] );
+ move32();
}
}
ELSE
{
FOR( i = 0; i < ovl2; i++ )
{
- DFT_fx[i + zp] = Mpy_32_16_1( DFT_fx[i + zp], win2_fx[i] );
+ DFT_fx[add( i, zp )] = Mpy_32_16_1( DFT_fx[add( i, zp )], win2_fx[i] );
+ move32();
}
FOR( i = 0; i < ovl; i++ )
{
- DFT_fx[NFFT - zp - i - 1] = Mpy_32_16_1( DFT_fx[NFFT - zp - i - 1], win_right_fx[STEREO_DFT32MS_STEP * i] );
+ DFT_fx[sub( sub( sub( NFFT, zp ), i ), 1 )] = Mpy_32_16_1( DFT_fx[sub( sub( sub( NFFT, zp ), i ), 1 )], win_right_fx[i_mult( STEREO_DFT32MS_STEP, i )] );
+ move32();
}
}
Word16 q_DFT, q_shift, guarded_bits;
q_DFT = *q;
+ move16();
guarded_bits = find_guarded_bits_fx( NFFT );
- q_shift = L_norm_arr( DFT_fx, NFFT ) - guarded_bits;
+ q_shift = sub( L_norm_arr( DFT_fx, NFFT ), guarded_bits );
FOR( Word16 j = 0; j < NFFT; j++ )
{
DFT_fx[j] = L_shl( DFT_fx[j], q_shift );
+ move32();
}
- q_DFT += q_shift;
+ q_DFT = add( q_DFT, q_shift );
rfft_fx( DFT_fx, trigo_dec_fx, NFFT, -1 );
- q_shift = L_norm_arr( DFT_fx, NFFT ) - ( 31 - qfac_fx );
+ q_shift = sub( L_norm_arr( DFT_fx, NFFT ), sub( 31, qfac_fx ) );
FOR( Word16 j = 0; j < NFFT; j++ )
{
DFT_fx[j] = L_shl( DFT_fx[j], q_shift );
+ move32();
}
- q_DFT += q_shift;
- IF( q_out_DFT[chan] - q_DFT > 0 )
+ q_DFT = add( q_DFT, q_shift );
+ IF( sub( q_out_DFT[chan], q_DFT ) > 0 )
{
FOR( int j = 0; j < NFFT; j++ )
{
- out_DFT_fx[chan][j] = L_shr( out_DFT_fx[chan][j], q_out_DFT[chan] - q_DFT );
+ out_DFT_fx[chan][j] = L_shr( out_DFT_fx[chan][j], sub( q_out_DFT[chan], q_DFT ) );
+ move32();
}
q_out_DFT[chan] = q_DFT;
+ move16();
}
ELSE
{
FOR( int j = 0; j < NFFT; j++ )
{
- DFT_fx[j] = L_shr( DFT_fx[j], q_DFT - q_out_DFT[chan] );
+ DFT_fx[j] = L_shr( DFT_fx[j], sub( q_DFT, q_out_DFT[chan] ) );
+ move32();
}
q_DFT = q_out_DFT[chan];
+ move16();
}
/*Resampling: filtering+scaling*/
- IF( ana_type == DFT_STEREO_DEC_ANA_FB || ana_type == DFT_STEREO_DEC_ANA_LB || ana_type == DFT_STEREO_DEC_ANA_NOCORE )
+ test();
+ test();
+ IF( ( ana_type == DFT_STEREO_DEC_ANA_FB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_LB ) || EQ_32( ana_type, DFT_STEREO_DEC_ANA_NOCORE ) )
{
- pDFT_out_fx[0] = L_shl( Mpy_32_32( DFT_fx[0], fac_fx ), 31 - qfac_fx ); /*DC*/
- IF( NFFT == hStereoDft->NFFT ) /*Nyquist*/
+ pDFT_out_fx[0] = L_shl( Mpy_32_32( DFT_fx[0], fac_fx ), sub( 31, qfac_fx ) ); /*DC*/
+ move32();
+ IF( EQ_16( NFFT, hStereoDft->NFFT ) ) /*Nyquist*/
{
- pDFT_out_fx[1] = L_shl( Mpy_32_32( DFT_fx[1], fac_fx ), 31 - qfac_fx );
+ pDFT_out_fx[1] = L_shl( Mpy_32_32( DFT_fx[1], fac_fx ), sub( 31, qfac_fx ) );
+ move32();
}
ELSE
{
pDFT_out_fx[1] = 0;
+ move32();
}
FOR( i = 2; i < NFFT; i++ )
{
- pDFT_out_fx[i] = L_shl( Mpy_32_32( DFT_fx[i], fac_fx ), 31 - qfac_fx );
+ pDFT_out_fx[i] = L_shl( Mpy_32_32( DFT_fx[i], fac_fx ), sub( 31, qfac_fx ) );
+ move32();
}
FOR( i = NFFT; i < hStereoDft->NFFT; i++ )
{
pDFT_out_fx[i] = 0;
+ move32();
}
}
- ELSE IF( ana_type == DFT_STEREO_DEC_ANA_BPF )
+ ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_BPF ) )
{
- pDFT_out_fx[0] = L_sub( pDFT_out_fx[0], L_shl( Mpy_32_32( Mpy_32_32( DFT_fx[0], fac_fx ), dft_bpf_weights_fx[0] ), 32 - qfac_fx ) );
+ pDFT_out_fx[0] = L_sub( pDFT_out_fx[0], L_shl( Mpy_32_32( Mpy_32_32( DFT_fx[0], fac_fx ), dft_bpf_weights_fx[0] ), sub( 32, qfac_fx ) ) );
+ move32();
FOR( i = 1; i < STEREO_DFT_BPF_SIZE; i++ )
{
- pDFT_out_fx[2 * i] = L_sub( pDFT_out_fx[2 * i], L_shl( Mpy_32_32( Mpy_32_32( DFT_fx[2 * i], fac_fx ), dft_bpf_weights_fx[i] ), 32 - qfac_fx ) );
- pDFT_out_fx[2 * i + 1] = L_sub( pDFT_out_fx[2 * i + 1], L_shl( Mpy_32_32( Mpy_32_32( DFT_fx[2 * i + 1], fac_fx ), dft_bpf_weights_fx[i] ), 32 - qfac_fx ) );
+ pDFT_out_fx[2 * i] = L_sub( pDFT_out_fx[2 * i], L_shl( Mpy_32_32( Mpy_32_32( DFT_fx[2 * i], fac_fx ), dft_bpf_weights_fx[i] ), sub( 32, qfac_fx ) ) );
+ move32();
+ pDFT_out_fx[add( 2 * i, 1 )] = L_sub( pDFT_out_fx[add( 2 * i, 1 )], L_shl( Mpy_32_32( Mpy_32_32( DFT_fx[add( 2 * i, 1 )], fac_fx ), dft_bpf_weights_fx[i] ), sub( 32, qfac_fx ) ) );
+ move32();
}
}
- ELSE IF( ana_type == DFT_STEREO_DEC_ANA_HB_ADD )
+ ELSE IF( EQ_32( ana_type, DFT_STEREO_DEC_ANA_HB_ADD ) )
{
- NFFT_core = NS2SA( hCPE->hCoreCoder[0]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_N_NS );
+ NFFT_core = NS2SA( L_mult0( hCPE->hCoreCoder[0]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_N_NS );
+ move16();
FOR( i = NFFT_core; i < NFFT; i++ )
{
- pDFT_out_fx[i] = L_add( L_shl( Mpy_32_32( DFT_fx[i], fac_fx ), 31 - qfac_fx ), pDFT_out_fx[i] );
+ pDFT_out_fx[i] = L_add( L_shl( Mpy_32_32( DFT_fx[i], fac_fx ), sub( 31, qfac_fx ) ), pDFT_out_fx[i] );
+ move32();
}
}
ELSE
{
- pDFT_out_fx[0] = L_add( pDFT_out_fx[0], L_shl( Mpy_32_32( DFT_fx[0], fac_fx ), 31 - qfac_fx ) ); /*DC*/
- IF( NFFT == hStereoDft->NFFT ) /*Nyquist*/
+ pDFT_out_fx[0] = L_add( pDFT_out_fx[0], L_shl( Mpy_32_32( DFT_fx[0], fac_fx ), sub( 31, qfac_fx ) ) ); /*DC*/
+ move32();
+ IF( EQ_16( NFFT, hStereoDft->NFFT ) ) /*Nyquist*/
{
- pDFT_out_fx[1] = L_add( L_shl( Mpy_32_32( DFT_fx[1], fac_fx ), 31 - qfac_fx ), pDFT_out_fx[1] );
+ pDFT_out_fx[1] = L_add( L_shl( Mpy_32_32( DFT_fx[1], fac_fx ), sub( 31, qfac_fx ) ), pDFT_out_fx[1] );
+ move32();
}
FOR( i = 2; i < NFFT; i++ )
{
- pDFT_out_fx[i] = L_add( L_shl( Mpy_32_32( DFT_fx[i], fac_fx ), 31 - qfac_fx ), pDFT_out_fx[i] );
+ pDFT_out_fx[i] = L_add( L_shl( Mpy_32_32( DFT_fx[i], fac_fx ), sub( 31, qfac_fx ) ), pDFT_out_fx[i] );
+ move32();
}
}
}
@@ -2505,10 +2548,6 @@ void stereo_dft_dec_read_BS(
hStereoDft->res_global_gain = ECSQ_dequantize_gain( I );
-#ifdef DUMPS_ENABLED
- dbgwrite_txt( &hStereoDft->res_global_gain, 1, "float_res_global_gain.txt", NULL );
-#endif // DUMPS_ENABLED
-
ecsq_inst.config_index = 2 * hStereoDft->res_cod_mode[k_offset] - 1;
ECSQ_decode( &ecsq_inst, hStereoDft->res_cod_line_max, dec );
@@ -2517,10 +2556,6 @@ void stereo_dft_dec_read_BS(
set_zero( res_buf, STEREO_DFT_N_8k );
ECSQ_dequantize_vector( dec, hStereoDft->res_global_gain, hStereoDft->res_cod_line_max, res_buf );
-
-#ifdef DUMPS_ENABLED
- dbgwrite_txt( res_buf, hStereoDft->res_cod_line_max, "float_res_buf.txt", NULL );
-#endif // DUMPS_ENABLED
}
else
{
diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx.c
index 27ee4f81728fe71125dbb72888ac3667422e40a0..bacc5a0abdaba8f318a3fafcb150bb3a67cf0e35 100644
--- a/lib_dec/ivas_stereo_dft_dec_dmx.c
+++ b/lib_dec/ivas_stereo_dft_dec_dmx.c
@@ -44,8 +44,7 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
-#include "prot_fx2.h"
-#include "prot_fx1.h"
+#include "prot_fx.h"
#endif
@@ -184,7 +183,7 @@ void stereo_dft_unify_dmx_fx(
pSideGain = hStereoDft->side_gain_fx + i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX );
/* Stereo residual PLC */
- IF( GT_16( hStereoDft->res_cod_band_max, 0 ) )
+ IF( hStereoDft->res_cod_band_max > 0 )
{
IF( !st0->bfi )
{
@@ -192,6 +191,7 @@ void stereo_dft_unify_dmx_fx(
{
Copy32( pDFT_RES, hStereoDft->res_mem_fx, shl( hStereoDft->band_limits[hStereoDft->res_cod_band_max], 1 ) );
hStereoDft->q_res_mem = hStereoDft->q_dft;
+ move16();
hStereoDft->time_offs = 0;
move16();
}
@@ -202,16 +202,20 @@ void stereo_dft_unify_dmx_fx(
move16();
pPredGain = hStereoDft->res_pred_gain_fx + i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX );
hStereoDft->past_DMX_pos = ( sub( add( hStereoDft->past_DMX_pos, STEREO_DFT_PAST_MAX ), 1 ) ) % STEREO_DFT_PAST_MAX;
+ move16();
stereo_dft_generate_res_pred_fx( hStereoDft, samp_ratio, pDFT_DMX, DFT_PRED_RES, pPredGain, k, DFT[1] + k * STEREO_DFT32MS_N_MAX, &stop, st0->bfi );
stereo_dft_res_ecu_fx( hStereoDft, pDFT_RES, DFT_PRED_RES, k, output_frame, prev_bfi, dmx_nrg, &num_plocs, plocs, plocsi, input_mem );
hStereoDft->q_res_cod_mem_fx = hStereoDft->q_dft;
+ move16();
}
}
/* Apply active DMX */
DFT_L[0] = pDFT_DMX[0];
+ move32();
DFT_R[0] = pDFT_DMX[0];
+ move32();
/* upmix residual part */
FOR( b = 0; b < hStereoDft->res_cod_band_max; b++ )
@@ -224,12 +228,16 @@ void stereo_dft_unify_dmx_fx(
tmp = Madd_32_16( pDFT_RES[2 * i], pDFT_DMX[2 * i], g );
DFT_L[2 * i] = L_add( pDFT_DMX[2 * i], tmp );
+ move32();
DFT_R[2 * i] = L_sub( pDFT_DMX[2 * i], tmp );
+ move32();
tmp = Madd_32_16( pDFT_RES[2 * i + 1], pDFT_DMX[2 * i + 1], g );
DFT_L[2 * i + 1] = L_add( pDFT_DMX[2 * i + 1], tmp );
+ move32();
DFT_R[2 * i + 1] = L_sub( pDFT_DMX[2 * i + 1], tmp );
+ move32();
}
}
@@ -243,15 +251,19 @@ void stereo_dft_unify_dmx_fx(
Word16 exp_sum_nrg_l, exp_sum_nrg_R, exp_dot_prod_abs, exp_sum_nrg_Mid;
Word32 sum_nrg_L_32, sum_nrg_R_32, dot_prod_real_32, dot_prod_img_32;
Word64 sum_nrg_L = 0, sum_nrg_R = 0;
+ move64();
+ move64();
Word64 dot_prod_real = 0, dot_prod_img = 0;
+ move64();
+ move64();
FOR( j = hStereoDft->band_limits[b]; j < hStereoDft->band_limits[b + 1]; j++ )
{
- sum_nrg_L = W_add( sum_nrg_L, W_add( W_mult_32_32( DFT_L[2 * j], DFT_L[2 * j] ), W_mult_32_32( DFT_L[2 * j + 1], DFT_L[2 * j + 1] ) ) );
- sum_nrg_R = W_add( sum_nrg_R, W_add( W_mult_32_32( DFT_R[2 * j], DFT_R[2 * j] ), W_mult_32_32( DFT_R[2 * j + 1], DFT_R[2 * j + 1] ) ) );
+ sum_nrg_L = W_add( sum_nrg_L, W_add( W_mult_32_32( DFT_L[2 * j], DFT_L[2 * j] ), W_mult_32_32( DFT_L[add( shl( j, 1 ), 1 )], DFT_L[add( shl( j, 1 ), 1 )] ) ) );
+ sum_nrg_R = W_add( sum_nrg_R, W_add( W_mult_32_32( DFT_R[2 * j], DFT_R[2 * j] ), W_mult_32_32( DFT_R[add( shl( j, 1 ), 1 )], DFT_R[add( shl( j, 1 ), 1 )] ) ) );
- dot_prod_real = W_add( dot_prod_real, W_add( W_mult_32_32( DFT_L[2 * j], DFT_R[2 * j] ), W_mult_32_32( DFT_L[2 * j + 1], DFT_R[2 * j + 1] ) ) );
- dot_prod_img = W_add( dot_prod_img, W_sub( W_mult_32_32( DFT_L[2 * j + 1], DFT_R[2 * j] ), W_mult_32_32( DFT_L[2 * j], DFT_R[2 * j + 1] ) ) );
+ dot_prod_real = W_add( dot_prod_real, W_add( W_mult_32_32( DFT_L[2 * j], DFT_R[2 * j] ), W_mult_32_32( DFT_L[2 * j + 1], DFT_R[add( shl( j, 1 ), 1 )] ) ) );
+ dot_prod_img = W_add( dot_prod_img, W_sub( W_mult_32_32( DFT_L[add( shl( j, 1 ), 1 )], DFT_R[2 * j] ), W_mult_32_32( DFT_L[2 * j], DFT_R[add( shl( j, 1 ), 1 )] ) ) );
}
norm_sum_nrg_L = W_norm( sum_nrg_L );
@@ -280,28 +292,31 @@ void stereo_dft_unify_dmx_fx(
Word32 tmp_nrg_L = Sqrt32( sum_nrg_L_32, &exp_sum_nrg_l );
Word32 tmp_nrg_R = Sqrt32( sum_nrg_R_32, &exp_sum_nrg_R );
Word16 exp_sum_abs = exp_sum_nrg_l;
+ move16();
- IF( GT_16( exp_sum_nrg_R, exp_sum_nrg_l ) )
+ if ( GT_16( exp_sum_nrg_R, exp_sum_nrg_l ) )
{
exp_sum_abs = exp_sum_nrg_R;
move16();
}
exp_sum_abs = add( exp_sum_abs, 1 );
- sum_abs = L_add( L_shr( tmp_nrg_L, exp_sum_abs - exp_sum_nrg_l ), L_shr( tmp_nrg_R, exp_sum_abs - exp_sum_nrg_R ) );
+ sum_abs = L_add( L_shr( tmp_nrg_L, sub( exp_sum_abs, exp_sum_nrg_l ) ), L_shr( tmp_nrg_R, sub( exp_sum_abs, exp_sum_nrg_R ) ) );
dot_prod_abs = Sqrt32( L_add( Mpy_32_32( dot_prod_real_32, dot_prod_real_32 ), Mpy_32_32( dot_prod_img_32, dot_prod_img_32 ) ), &exp_dot_prod_abs );
- Word32 num = L_add( L_shr( L_add( sum_nrg_L_32, sum_nrg_R_32 ), 1 ), L_shr( dot_prod_abs, ( 31 - exp_dot_prod_abs ) - q_sum_nrg_L ) );
+ Word32 num = L_add( L_shr( L_add( sum_nrg_L_32, sum_nrg_R_32 ), 1 ), L_shr( dot_prod_abs, sub( sub( 31, exp_dot_prod_abs ), q_sum_nrg_L ) ) );
Word16 E_num = sub( 31, q_sum_nrg_L );
Word32 num_sqrt = Sqrt32( num, &E_num );
Word16 exp_wR = exp_sum_abs;
move16();
- IF( LT_16( exp_sum_abs, E_num ) )
+ if ( LT_16( exp_sum_abs, E_num ) )
{
exp_wR = E_num;
move16();
}
Word16 wR_temp;
- IF( EQ_32( num_sqrt, 0 ) && EQ_32( sum_abs, 0 ) )
+ test();
+ test();
+ IF( num_sqrt == 0 && sum_abs == 0 )
{
wR_temp = 6364; // 0.776887059 in Q13
move16();
@@ -313,19 +328,22 @@ void stereo_dft_unify_dmx_fx(
}
ELSE
{
- wR_temp = shr( divide3232( L_shr( num_sqrt, exp_wR - E_num ), L_shr( sum_abs, exp_wR - exp_sum_abs ) ), 2 );
+ wR_temp = shr( divide3232( L_shr( num_sqrt, sub( exp_wR, E_num ) ), L_shr( sum_abs, sub( exp_wR, exp_sum_abs ) ) ), 2 );
}
Word32 sum_nrg_Mid_sqrt = Sqrt32( sum_nrg_Mid, &exp_sum_nrg_Mid );
Word16 exp_wL = exp_sum_abs;
- IF( LT_16( exp_sum_abs, exp_sum_nrg_Mid ) )
+ move16();
+ if ( LT_16( exp_sum_abs, exp_sum_nrg_Mid ) )
{
exp_wL = exp_sum_nrg_Mid;
move16();
}
Word16 wL_temp;
- IF( EQ_32( sum_nrg_Mid_sqrt, 0 ) && EQ_32( sum_abs, 0 ) )
+ test();
+ test();
+ IF( sum_nrg_Mid_sqrt == 0 && sum_abs == 0 )
{
wL_temp = 6364;
move16();
@@ -337,7 +355,7 @@ void stereo_dft_unify_dmx_fx(
}
ELSE
{
- wL_temp = shr( divide3232( L_shr( sum_nrg_Mid_sqrt, exp_wL - exp_sum_nrg_Mid ), L_shr( sum_abs, exp_wL - exp_sum_abs ) ), 1 );
+ wL_temp = shr( divide3232( L_shr( sum_nrg_Mid_sqrt, sub( exp_wL, exp_sum_nrg_Mid ) ), L_shr( sum_abs, sub( exp_wL, exp_sum_abs ) ) ), 1 );
}
wR = wR_temp; /* Q13 */
@@ -347,23 +365,29 @@ void stereo_dft_unify_dmx_fx(
FOR( i = hStereoDft->band_limits[b]; i < hStereoDft->band_limits[b + 1]; i++ )
{
/*DMX Mapping*/
- pDFT_DMX[2 * i] = L_shl( Mpy_32_32( L_add( Mpy_32_16_1( DFT_L[2 * i], wL ), Mpy_32_16_1( DFT_R[2 * i], wR ) ), INV_SQRT_2_Q31 ), Q2 ); /* Q(hStereoDft->q_dft) */
+ pDFT_DMX[2 * i] = L_shl( Mpy_32_32( L_add( Mpy_32_16_1( DFT_L[2 * i], wL ), Mpy_32_16_1( DFT_R[2 * i], wR ) ), INV_SQRT_2_Q31 ), Q2 ); /* Q(hStereoDft->q_dft) */
+ move32();
pDFT_DMX[2 * i + 1] = L_shl( Mpy_32_32( L_add( Mpy_32_16_1( DFT_L[2 * i + 1], wL ), Mpy_32_16_1( DFT_R[2 * i + 1], wR ) ), INV_SQRT_2_Q31 ), Q2 ); /* Q(hStereoDft->q_dft) */
+ move32();
}
}
Copy32( pDFT_DMX, DFT[0] + i_mult( k, STEREO_DFT32MS_N_MAX ), hStereoDft->NFFT );
/* Update DFT_past_DMX, needed for stereo filling used by stereo residual PLC */
hStereoDft->past_DMX_pos = ( hStereoDft->past_DMX_pos + 1 ) % STEREO_DFT_PAST_MAX;
+ move16();
Copy32( pDFT_DMX, hStereoDft->DFT_past_DMX_fx[hStereoDft->past_DMX_pos], s_min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ) );
hStereoDft->q_DFT_past_DMX_fx[hStereoDft->past_DMX_pos] = hStereoDft->q_dft;
+ test();
IF( st0->bfi && !prev_bfi )
{
Word16 idx_k0, idx_k1;
Word16 q_shift0;
Word16 q_shift1;
idx_k0 = ( add( hStereoDft->past_DMX_pos, 1 ) ) % STEREO_DFT_PAST_MAX;
+ move16();
idx_k1 = ( add( idx_k0, 1 ) ) % STEREO_DFT_PAST_MAX;
+ move16();
q_shift0 = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[idx_k0] );
q_shift1 = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[idx_k1] );
@@ -656,6 +680,7 @@ void add_HB_to_mono_dmx_fx(
Word32 temp_fx[L_FRAME48k + NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )];
Word32 winSlope_fx = 0;
+ move32();
Word32 alpha_fx;
const Word16 *win_dft_fx;
int32_t output_Fs;
@@ -674,41 +699,51 @@ void add_HB_to_mono_dmx_fx(
memTransitionHB_fx = hCPE->hStereoDftDmx->memTransitionHB_fx;
memOffset = NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS );
+ move16();
- IF( EQ_16( hCPE->hCoreCoder[0]->core, ACELP_CORE ) && GT_32( hCPE->hCoreCoder[0]->extl_brate, 0 ) )
+ test();
+ IF( hCPE->hCoreCoder[0]->core == ACELP_CORE && GT_32( hCPE->hCoreCoder[0]->extl_brate, 0 ) )
{
/* Resampled LB and HB offset */
- Copy32( outputHB, temp_fx + memOffset, output_frame - memOffset );
+ Copy32( outputHB, temp_fx + memOffset, sub( output_frame, memOffset ) );
decoderDelay = NS2SA( output_Fs, IVAS_DEC_DELAY_NS );
+ move16();
- IF( NE_16( last_core, ACELP_CORE ) )
+ IF( last_core != ACELP_CORE )
{
/* hb_synth of mid band is faded out in the 1.25 ms prior to DFT analysis and the icbwe is faded in time domain */
icbweOLASize = NS2SA( output_Fs, STEREO_DFT_DELAY_DEC_BWE_NS );
+ move16();
FOR( i = 0; i < decoderDelay; i++ )
{
temp_fx[i] = 0;
+ move32();
}
assert( icbweOLASize > 0 );
- switch ( output_Fs )
+ SWITCH( output_Fs )
{
case 48000:
winSlope_fx = 17895698; // Q30
- break;
+ move32();
+ BREAK;
case 32000:
winSlope_fx = 26843546;
- break;
+ move32();
+ BREAK;
case 16000:
winSlope_fx = 53687092;
- break;
+ move32();
+ BREAK;
}
alpha_fx = winSlope_fx; // Q30
- FOR( ; i < decoderDelay + icbweOLASize; i++ )
+ move32();
+ FOR( ; i < add( decoderDelay, icbweOLASize ); i++ )
{
temp_fx[i] = L_shl( Mpy_32_32( temp_fx[i], alpha_fx ), 1 );
+ move32();
alpha_fx = L_add_sat( alpha_fx, winSlope_fx );
}
}
@@ -719,29 +754,35 @@ void add_HB_to_mono_dmx_fx(
v_add_32( temp_fx, output, output, output_frame );
- Copy32( outputHB + output_frame - memOffset, memOutHB_fx, memOffset );
+ Copy32( outputHB + sub( output_frame, memOffset ), memOutHB_fx, memOffset );
win_dft_fx = hCPE->hStereoDft->win32ms_fx;
dftOvlLen = hCPE->hStereoDft->dft32ms_ovl;
+ move16();
/* Preparing buffers in anticipation of an ACELP to TCX switch */
j = 0;
+ move16();
FOR( i = 0; i < memOffset; i++ )
{
- memTransitionHB_fx[i] = Mpy_32_16_1( memOutHB_fx[i], win_dft_fx[STEREO_DFT32MS_STEP * ( dftOvlLen - 1 - j )] );
- j++;
+ memTransitionHB_fx[i] = Mpy_32_16_1( memOutHB_fx[i], win_dft_fx[i_mult( STEREO_DFT32MS_STEP, ( sub( dftOvlLen, add( 1, j ) ) ) )] );
+ move32();
+ j = add( j, 1 );
}
FOR( i = 0; j < dftOvlLen; i++ )
{
- memTransitionHB_fx[memOffset + i] = Mpy_32_16_1( outputHB[output_frame - i - 1], win_dft_fx[STEREO_DFT32MS_STEP * ( dftOvlLen - 1 - j )] );
- j++;
+ memTransitionHB_fx[add( memOffset, i )] = Mpy_32_16_1( outputHB[sub( output_frame, i ) - 1], win_dft_fx[i_mult( STEREO_DFT32MS_STEP, ( sub( dftOvlLen, add( 1, j ) ) ) )] );
+ move32();
+ j = add( j, 1 );
}
}
ELSE
{
- IF( EQ_16( last_core, ACELP_CORE ) )
+ IF( last_core == ACELP_CORE )
{
+ test();
+ test();
/* This is generated in the ACELP frame and windowed. This process is akin to GenTransition for IC-BWE */
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) )
{
diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c
index 2238d768f35a95e24be6bd67c9a412c29d38c1b5..ea5f56998f8a86861153efe1993b69a1c6b4e234 100644
--- a/lib_dec/ivas_stereo_dft_dec_fx.c
+++ b/lib_dec/ivas_stereo_dft_dec_fx.c
@@ -38,7 +38,7 @@
#include "rom_com.h"
#include "rom_dec.h"
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "ivas_cnst.h"
@@ -49,7 +49,6 @@
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#include "basop_util.h"
-#include "prot_fx1.h"
/*-------------------------------------------------------------------*
* Local constants
@@ -102,14 +101,14 @@ void stereo_dft_dec_reset_fx(
#endif
/*Configuration*/
- set_s( hStereoDft->prm_res, hStereoDft->hConfig->prm_res, STEREO_DFT_DEC_DFT_NB );
+ set16_fx( hStereoDft->prm_res, hStereoDft->hConfig->prm_res, STEREO_DFT_DEC_DFT_NB );
/* SIDE_GAIN */
- set_s( hStereoDft->side_gain_index, 15, STEREO_DFT_BAND_MAX );
- set_s( hStereoDft->side_gain_index_previous, 15, STEREO_DFT_BAND_MAX );
+ set16_fx( hStereoDft->side_gain_index, 15, STEREO_DFT_BAND_MAX );
+ set16_fx( hStereoDft->side_gain_index_previous, 15, STEREO_DFT_BAND_MAX );
/*residual prediction*/
- set_s( hStereoDft->res_pred_mode, hStereoDft->hConfig->res_pred_mode, STEREO_DFT_DEC_DFT_NB );
+ set16_fx( hStereoDft->res_pred_mode, hStereoDft->hConfig->res_pred_mode, STEREO_DFT_DEC_DFT_NB );
FOR( i = 0; i < STEREO_DFT_PAST_MAX; i++ )
{
set32_fx( hStereoDft->DFT_past_DMX_fx[i], 0, STEREO_DFT32MS_N_32k );
@@ -121,7 +120,7 @@ void stereo_dft_dec_reset_fx(
hStereoDft->past_DMX_pos = 0;
move16();
- set_s( hStereoDft->res_pred_index_previous, 0, STEREO_DFT_BAND_MAX );
+ set16_fx( hStereoDft->res_pred_index_previous, 0, STEREO_DFT_BAND_MAX );
FOR( i = 0; i < STEREO_DFT_BAND_MAX; i++ )
{
@@ -132,7 +131,7 @@ void stereo_dft_dec_reset_fx(
set32_fx( hStereoDft->res_gains_ind_fx[1], 0, STEREO_DFT_BAND_MAX );
/*residual coding*/
- set_s( hStereoDft->res_cod_mode, hStereoDft->hConfig->res_cod_mode, STEREO_DFT_DEC_DFT_NB );
+ set16_fx( hStereoDft->res_cod_mode, hStereoDft->hConfig->res_cod_mode, STEREO_DFT_DEC_DFT_NB );
hStereoDft->res_cod_band_max = dft_band_res_cod[hStereoDft->hConfig->band_res][hStereoDft->hConfig->res_cod_mode];
set32_fx( hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k );
hStereoDft->q_res_cod_mem_fx = Q16;
@@ -283,21 +282,24 @@ static void stereo_dft_dec_open_fx(
)
{
/*Sizes*/
- hStereoDft->N = extract_l( STEREO_DFT_HOP_MAX * output_Fs / 48000 );
+ // hStereoDft->N = (Word16) ( STEREO_DFT_HOP_MAX * output_Fs / 48000 );
+ hStereoDft->N = extract_l( Mpy_32_32( imult3216( output_Fs, STEREO_DFT_HOP_MAX ), 44740 ) );
+ move16();
/*Init. DFT sizes*/
- hStereoDft->NFFT = extract_l( STEREO_DFT32MS_N_MAX * output_Fs / 48000 );
+ hStereoDft->NFFT = extract_l( Mpy_32_32( imult3216( output_Fs, STEREO_DFT32MS_N_MAX ), 44740 ) );
+ move16();
hStereoDft->dft_trigo_8k_fx = dft_trigo_32k_fx;
hStereoDft->dft_trigo_12k8_fx = dft_trigo_12k8_fx;
hStereoDft->dft_trigo_16k_fx = dft_trigo_32k_fx;
- hStereoDft->dft32ms_ovl = extract_l( ( STEREO_DFT32MS_OVL_MAX * output_Fs ) / 48000 );
+ hStereoDft->dft32ms_ovl = extract_l( Mpy_32_32( imult3216( output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) );
hStereoDft->win232ms_8k_fx = dft_win232ms_8k_fx;
hStereoDft->win232ms_12k8_fx = dft_win232ms_12k8_fx;
hStereoDft->win232ms_16k_fx = dft_win232ms_16k_fx;
- hStereoDft->dft32ms_ovl2 = extract_l( ( STEREO_DFT32MS_OVL2_MAX * output_Fs ) / 48000 );
+ hStereoDft->dft32ms_ovl2 = extract_l( Mpy_32_32( imult3216( output_Fs, STEREO_DFT32MS_OVL2_MAX ), 44740 ) );
hStereoDft->win32ms_8k_fx = dft_win232ms_8k_fx + 1;
hStereoDft->win32ms_12k8_fx = dft_win232ms_12k8_fx + 1;
hStereoDft->win32ms_16k_fx = dft_win232ms_16k_fx + 1;
@@ -439,6 +441,7 @@ static void stereo_dft_dequantize_res_gains_fx(
const Word16 N )
{
Word16 i, index;
+ Word16 tmp;
FOR( i = 0; i < N; i++ )
{
@@ -447,10 +450,27 @@ static void stereo_dft_dequantize_res_gains_fx(
move16();
ind2[i] = check_bounds_s( ind2[i], 0, 7 );
move16();
- index = add( shl( LE_16( ind1[i], 15 ) ? sub( 15, ind1[i] ) : sub( ind1[i], 15 ), 3 ), ind2[i] );
- move16();
- gout[i] = LE_16( ind1[i], 15 ) ? L_negate( dft_res_gains_q_fx[index][0] ) : dft_res_gains_q_fx[index][0];
- move16();
+ IF( LE_16( ind1[i], 15 ) )
+ {
+ tmp = sub( 15, ind1[i] );
+ }
+ ELSE
+ {
+ tmp = sub( ind1[i], 15 );
+ }
+ // index = add( shl( LE_16( ind1[i], 15 ) ? sub( 15, ind1[i] ) : sub( ind1[i], 15 ), 3 ), ind2[i] );
+ index = add( shl( tmp, 3 ), ind2[i] );
+ // gout[i] = LE_16( ind1[i], 15 ) ? L_negate( dft_res_gains_q_fx[index][0] ) : dft_res_gains_q_fx[index][0];
+ IF( LE_16( ind1[i], 15 ) )
+ {
+ gout[i] = L_negate( dft_res_gains_q_fx[index][0] );
+ move16();
+ }
+ ELSE
+ {
+ gout[i] = dft_res_gains_q_fx[index][0];
+ move16();
+ }
rout[i] = dft_res_gains_q_fx[index][1];
move16();
}
@@ -472,6 +492,7 @@ static void stereo_dft_dequantize_res_gains_f_fx(
const Word16 N )
{
Word16 i, i1, j1, sign, ji, ij;
+ Word32 L_tmp;
Word32 fi, fj;
FOR( i = 0; i < N; i++ )
@@ -483,22 +504,64 @@ static void stereo_dft_dequantize_res_gains_f_fx(
move32();
/* compensate for the offset and extract/remove sign of first index */
- sign = LT_32( ind1[i], L_shl( 15, Q26 ) ) ? -1 : 1;
- move16();
- i1 = extract_l( L_shr( ( LT_32( ind1[i], L_shl( 15, Q26 ) ) ? L_sub( L_shl( 15, Q26 ), ind1[i] ) : L_sub( ind1[i], L_shl( 15, Q26 ) ) ), Q26 ) );
- fi = L_sub( ( LT_32( ind1[i], L_shl( 15, Q26 ) ) ? L_sub( L_shl( 15, Q26 ), ind1[i] ) : L_sub( ind1[i], L_shl( 15, Q26 ) ) ), L_shl( i1, Q26 ) );
+ // sign = LT_32( ind1[i], L_shl( 15, Q26 ) ) ? -1 : 1;
+ IF( LT_32( ind1[i], L_shl( 15, Q26 ) ) )
+ {
+ sign = -1;
+ move16();
+ }
+ ELSE
+ {
+ sign = 1;
+ move16();
+ }
+ IF( LT_32( ind1[i], L_shl( 15, Q26 ) ) )
+ {
+ L_tmp = L_sub( L_shl( 15, Q26 ), ind1[i] );
+ }
+ ELSE
+ {
+ L_tmp = L_sub( ind1[i], L_shl( 15, Q26 ) );
+ }
+ i1 = extract_l( L_shr( ( L_tmp ), Q26 ) );
+ IF( LT_32( ind1[i], L_shl( 15, Q26 ) ) )
+ {
+ L_tmp = L_sub( L_shl( 15, Q26 ), ind1[i] );
+ }
+ ELSE
+ {
+ L_tmp = L_sub( ind1[i], L_shl( 15, Q26 ) );
+ }
+ fi = L_sub( ( L_tmp ), L_shl( i1, Q26 ) );
move16();
j1 = extract_l( L_shr( ind2[i], Q26 ) );
fj = L_sub( ind2[i], L_shl( j1, Q26 ) );
/* choose base indices for interpolation */
- ji = extract_l( L_min( fj < ONE_IN_Q25 ? j1 : j1 + 1, 7 ) );
- ij = extract_l( L_min( fi < ONE_IN_Q25 ? i1 : i1 + 1, 15 ) );
+ // ji = extract_l( L_min( fj < ONE_IN_Q25 ? j1 : j1 + 1, 7 ) );
+ IF( LT_32( fj, ONE_IN_Q25 ) )
+ {
+ ji = extract_l( L_min( j1, 7 ) );
+ }
+ ELSE
+ {
+ ji = extract_l( L_min( add( j1, 1 ), 7 ) );
+ }
+
+ // ij = extract_l( L_min( fi < ONE_IN_Q25 ? i1 : i1 + 1, 15 ) );
+ IF( LT_32( fi, ONE_IN_Q25 ) )
+ {
+ ij = extract_l( L_min( i1, 15 ) );
+ }
+ ELSE
+ {
+ ij = extract_l( L_min( add( i1, 1 ), 15 ) );
+ }
/* interpolate values from table */
IF( LT_16( i1, 15 ) )
{
- gout[i] = Madd_32_32( Mpy_32_32( L_sub( MAX_32, L_shl( fi, Q5 ) ), dft_res_gains_q_fx[( i1 << 3 ) + ji][0] ), dft_res_gains_q_fx[( ( i1 + 1 ) << 3 ) + ji][0], L_shl( fi, Q5 ) );
+ gout[i] = Madd_32_32( Mpy_32_32( L_sub( MAX_32, L_shl( fi, Q5 ) ), dft_res_gains_q_fx[add( shl( i1, 3 ), ji )][0] ), dft_res_gains_q_fx[add( shl( add( i1, 1 ), 3 ), ji )][0], L_shl( fi, Q5 ) );
move32();
IF( EQ_16( sign, -1 ) )
{
@@ -519,12 +582,12 @@ static void stereo_dft_dequantize_res_gains_f_fx(
IF( LT_16( j1, 7 ) )
{
- rout[i] = Madd_32_32( Mpy_32_32( L_sub( MAX_32, L_shl( fj, Q5 ) ), dft_res_gains_q_fx[( ij << 3 ) + j1][1] ), L_shl( fj, Q5 ), dft_res_gains_q_fx[( ij << 3 ) + j1 + 1][1] );
+ rout[i] = Madd_32_32( Mpy_32_32( L_sub( MAX_32, L_shl( fj, Q5 ) ), dft_res_gains_q_fx[add( shl( ij, 3 ), j1 )][1] ), L_shl( fj, Q5 ), dft_res_gains_q_fx[add( add( shl( ij, 3 ), j1 ), 1 )][1] );
move32();
}
ELSE
{
- rout[i] = dft_res_gains_q_fx[( ij << 3 ) + 7][1];
+ rout[i] = dft_res_gains_q_fx[add( shl( ij, 3 ), 7 )][1];
move32();
}
}
@@ -579,10 +642,10 @@ void stereo_dft_dec_update_fx(
}
/* Load new configurations */
- set_s( hStereoDft->band_res + k_offset, hStereoDft->hConfig->band_res, STEREO_DFT_NBDIV );
- set_s( hStereoDft->prm_res + k_offset, hStereoDft->hConfig->prm_res, STEREO_DFT_NBDIV );
- set_s( hStereoDft->res_pred_mode + k_offset, hStereoDft->hConfig->res_pred_mode, STEREO_DFT_NBDIV );
- set_s( hStereoDft->res_cod_mode + k_offset, hStereoDft->hConfig->res_cod_mode, STEREO_DFT_NBDIV );
+ set16_fx( hStereoDft->band_res + k_offset, hStereoDft->hConfig->band_res, STEREO_DFT_NBDIV );
+ set16_fx( hStereoDft->prm_res + k_offset, hStereoDft->hConfig->prm_res, STEREO_DFT_NBDIV );
+ set16_fx( hStereoDft->res_pred_mode + k_offset, hStereoDft->hConfig->res_pred_mode, STEREO_DFT_NBDIV );
+ set16_fx( hStereoDft->res_cod_mode + k_offset, hStereoDft->hConfig->res_cod_mode, STEREO_DFT_NBDIV );
/*Update attack info*/
IF( hStereoDft->attackPresent )
@@ -679,7 +742,10 @@ void stereo_dft_dec_synthesize_fx(
set_val_Word32( output, 0, NS2SA( outputFs, FRAME_SIZE_NS ) );
/* deactivating the spectrum scrambling on active speech */
- IF( ( EQ_16( chan, 0 ) && GT_16( hCPE->hCoreCoder[0]->last_coder_type, UNVOICED ) ) || EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) || LT_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
+ test();
+ test();
+ test();
+ if ( ( EQ_16( chan, 0 ) && GT_16( hCPE->hCoreCoder[0]->last_coder_type, UNVOICED ) ) || EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) || LT_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
hCPE->stereo_switching_counter = 10;
move16();
@@ -691,7 +757,7 @@ void stereo_dft_dec_synthesize_fx(
Word16 tmp = extract_l( L_max( (Word16) 0xF333, L_min( (Word16) 0x3333, hCPE->lt_es_em_fx ) ) );
hCPE->NbFrameMod = extract_h( L_add( L_mult0( 12, tmp ), 0x0000D99A ) ); /* -0.1: -0.4 ; -0.1 -> 0, 0.4 -> 6*/
}
- moffset = max( 0, 6 - hCPE->NbFrameMod );
+ moffset = s_max( 0, sub( 6, hCPE->NbFrameMod ) );
/*-----------------------------------------------------------------*
* Synthesis
@@ -700,7 +766,7 @@ void stereo_dft_dec_synthesize_fx(
trigo_step = i_mult( hStereoDft->dft_trigo_step, STEREO_DFT_TRIGO_DEC_STEP );
FOR( i = 0; i < shr( NFFT, 2 ); i++ )
{
- trigo_dec[i] = hStereoDft->dft_trigo_fx[i * trigo_step];
+ trigo_dec[i] = hStereoDft->dft_trigo_fx[i_mult( i, trigo_step )];
move16();
trigo_dec[sub( shr( NFFT, 1 ), i )] = hStereoDft->dft_trigo_fx[i * trigo_step];
move16();
@@ -711,11 +777,16 @@ void stereo_dft_dec_synthesize_fx(
FOR( k = 0; k < STEREO_DFT_NBDIV; k++ )
{
/* scrambling the spectrum */
+ test();
+ test();
+ test();
+ test();
+ test();
IF( LE_16( hCPE->stereo_switching_counter, 6 ) && EQ_16( chan, 1 ) && ( GT_32( hCPE->lt_es_em_fx, (Word16) 0xCCCD ) || GT_16( hCPE->NbFrameMod, 4 ) ) )
{
- FOR( i = 3; i < NFFT - moffset - 1; i++ )
+ FOR( i = 3; i < sub( sub( NFFT, moffset ), 1 ); i++ )
{
- p_DFT[i] = L_negate( p_DFT[i + moffset + 1] );
+ p_DFT[i] = L_negate( p_DFT[add( add( i, moffset ), 1 )] );
move32();
}
}
@@ -723,19 +794,19 @@ void stereo_dft_dec_synthesize_fx(
{
FOR( i = sub( 16, hCPE->NbFrameMod ); i < sub( NFFT, add( moffset, 1 ) ); i++ )
{
- p_DFT[i - 2] = L_negate( p_DFT[i + moffset + 1] );
+ p_DFT[i - 2] = L_negate( p_DFT[add( add( i, moffset ), 1 )] );
move32();
}
}
/*IFFT*/
scale_dft = getScaleFactor32( p_DFT, NFFT );
- scale_dft = find_guarded_bits_fx( NFFT ) - scale_dft;
+ scale_dft = sub( find_guarded_bits_fx( NFFT ), scale_dft );
v_shr( p_DFT, scale_dft, p_DFT, NFFT );
- rfft_fx( p_DFT, trigo_dec, NFFT, +1 );
+ rfft_fx( p_DFT, trigo_dec, NFFT, 1 );
v_shr( p_DFT, negate( scale_dft ), p_DFT, NFFT );
- IF( EQ_16( k, 0 ) )
+ IF( k == 0 )
{
offset = 0;
move16();
@@ -743,19 +814,19 @@ void stereo_dft_dec_synthesize_fx(
/* Left OLA - 3.125ms */
FOR( i = 0; i < ovl; i++ )
{
- output[offset + i] = Madd_32_16( L_shr( hCPE->output_mem_fx[chan][i], sub( hCPE->q_output_mem_fx[chan], hCPE->hStereoDft->q_dft ) ), p_DFT[zp + i], win[STEREO_DFT32MS_STEP * i] );
+ output[add( offset, i )] = Madd_32_16( L_shr( hCPE->output_mem_fx[chan][i], sub( hCPE->q_output_mem_fx[chan], hCPE->hStereoDft->q_dft ) ), p_DFT[add( zp, i )], win[STEREO_DFT32MS_STEP * i] );
move32();
}
/* Flat Portion */
FOR( i = ovl; i < flat_portion_end; i++ )
{
- output[offset + i] = p_DFT[zp + i];
+ output[add( offset, i )] = p_DFT[add( zp, i )];
move32();
}
/* Right OLA */
FOR( i = 0; i < ovl2; i++ )
{
- ola_buff[i] = Mpy_32_16_1( p_DFT[NFFT - zp - ovl2 + i], win2[ovl2 - 1 - i] );
+ ola_buff[i] = Mpy_32_16_1( p_DFT[add( sub( NFFT, add( zp, ovl2 ) ), i )], win2[sub( sub( ovl2, i ), 1 )] );
move32();
}
}
@@ -767,22 +838,23 @@ void stereo_dft_dec_synthesize_fx(
/* Left OLA */
FOR( i = 0; i < ovl2; i++ )
{
- output[offset + i] = Madd_32_16( ola_buff[i], p_DFT[zp + i], win2[i] );
+ output[add( offset, i )] = Madd_32_16( ola_buff[i], p_DFT[add( zp, i )], win2[i] );
move32();
}
/* Flat Portion */
- FOR( i = ovl2; i < NFFT - 2 * zp - ovl; i++ )
+ FOR( i = ovl2; i < sub( NFFT, add( shl( zp, 1 ), ovl ) ); i++ )
{
- output[offset + i] = p_DFT[zp + i];
+ output[add( offset, i )] = p_DFT[add( zp, i )];
move32();
}
/* Right OLA - 3.125ms */
FOR( i = 0; i < ovl; i++ )
{
- hCPE->output_mem_fx[chan][i] = Mpy_32_16_1( p_DFT[NFFT - zp - ovl + i], win[STEREO_DFT32MS_STEP * ( ovl - 1 - i )] );
+ hCPE->output_mem_fx[chan][i] = Mpy_32_16_1( p_DFT[add( sub( NFFT, add( zp, ovl ) ), i )], win[i_mult( STEREO_DFT32MS_STEP, ( sub( sub( ovl, i ), 1 ) ) )] );
move32();
}
hCPE->q_output_mem_fx[chan] = hCPE->hStereoDft->q_dft;
+ move16();
}
p_DFT += STEREO_DFT32MS_N_MAX;
}
@@ -819,12 +891,13 @@ void stereo_dft_dec_smooth_parameters_fx(
k_offset = STEREO_DFT_OFFSET;
move16();
+ test();
IF( hStereoDft->frame_sid_nodata || prev_sid_nodata )
{
k = 1;
FOR( b = 0; b < hStereoDft->nbands; b++ )
{
- *( hStereoDft->side_gain_fx + ( ( add( k, k_offset ) ) - 1 ) * STEREO_DFT_BAND_MAX + b ) = *( hStereoDft->side_gain_fx + ( add( k, k_offset ) ) * STEREO_DFT_BAND_MAX + b );
+ *( hStereoDft->side_gain_fx + add( i_mult( sub( add( k, k_offset ), 1 ), STEREO_DFT_BAND_MAX ), b ) ) = *( hStereoDft->side_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ) );
move32();
}
@@ -889,13 +962,15 @@ void stereo_dft_dec_smooth_parameters_fx(
}
/* xfade */
+ test();
+ test();
IF( NE_32( hStereoDft->ipd_xfade_prev_fx, hStereoDft->ipd_xfade_target_fx ) && LT_16( hStereoDft->ipd_xfade_counter, STEREO_DFT_ITD_CNG_XFADE ) && LE_32( hStereoDft->last_active_element_brate, 24400 ) )
{
hStereoDft->gipd_fx[add( k, k_offset )] = L_add( hStereoDft->ipd_xfade_prev_fx, hStereoDft->ipd_xfade_step_fx );
move32();
hStereoDft->ipd_xfade_prev_fx = hStereoDft->gipd_fx[add( k, k_offset )];
move32();
- hStereoDft->ipd_xfade_counter++;
+ hStereoDft->ipd_xfade_counter = add( hStereoDft->ipd_xfade_counter, 1 );
}
}
ELSE
@@ -914,7 +989,7 @@ void stereo_dft_dec_smooth_parameters_fx(
FOR( k2 = 1; k2 < hStereoDft->prm_res[add( k, k_offset )]; k2++ )
{
- hStereoDft->gipd_fx[( add( k, k_offset ) ) - k2] = hStereoDft->gipd_fx[add( k, k_offset )];
+ hStereoDft->gipd_fx[sub( add( k, k_offset ), k2 )] = hStereoDft->gipd_fx[add( k, k_offset )];
move32();
}
@@ -970,7 +1045,7 @@ void stereo_dft_dec_smooth_parameters_fx(
}
FOR( k2 = 1; k2 < hStereoDft->prm_res[add( k, k_offset )]; k2++ )
{
- hStereoDft->itd_fx[( add( k, k_offset ) ) - k2] = hStereoDft->itd_fx[add( k, k_offset )];
+ hStereoDft->itd_fx[sub( add( k, k_offset ), k2 )] = hStereoDft->itd_fx[add( k, k_offset )];
move32();
}
@@ -1049,14 +1124,16 @@ void stereo_dft_dec_smooth_parameters_fx(
move16();
tmps2 = (Word16) L_shr( hStereoDft->res_gains_ind_fx[1][b + STEREO_DFT_BAND_MAX], Q26 );
move16();
- stereo_dft_dequantize_res_gains_fx( &tmps1, &tmps2, hStereoDft->side_gain_fx + ( add( k, k_offset ) ) * STEREO_DFT_BAND_MAX + b, hStereoDft->res_pred_gain_fx + ( add( k, k_offset ) ) * STEREO_DFT_BAND_MAX + b, 1 );
+ stereo_dft_dequantize_res_gains_fx( &tmps1, &tmps2, hStereoDft->side_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), hStereoDft->res_pred_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), 1 );
+ test();
+ test();
IF( hStereoDft->attackPresent )
{
hStereoDft->res_gains_ind_fx[1][b] = Mpy_32_16_1( hStereoDft->res_gains_ind_fx[1][b], (Word16) 0x6666 );
move32();
}
- ELSE IF( hStereoDft->trans || ( hStereoDft->res_pred_mode[k] && ( hStereoDft->res_gains_ind_fx[1][b + STEREO_DFT_BAND_MAX] < ONE_IN_Q27 ) ) ) /* Assuming Maximum Q of res_gains_ind_fx is Q26 */
+ ELSE IF( hStereoDft->trans || ( hStereoDft->res_pred_mode[k] && ( LT_32( hStereoDft->res_gains_ind_fx[1][b + STEREO_DFT_BAND_MAX], ONE_IN_Q27 ) ) ) ) /* Assuming Maximum Q of res_gains_ind_fx is Q26 */
{
hStereoDft->res_gains_ind_fx[1][b] = Madd_32_16( Mpy_32_16_1( hStereoDft->res_gains_ind_fx[1][b], (Word16) 0x4CCD ),
hStereoDft->res_gains_ind_fx[1][b + STEREO_DFT_BAND_MAX], (Word16) 0x3333 );
@@ -1070,12 +1147,14 @@ void stereo_dft_dec_smooth_parameters_fx(
move32();
}
- stereo_dft_dequantize_res_gains_f_fx( &hStereoDft->res_gains_ind_fx[0][b], &hStereoDft->res_gains_ind_fx[1][b], &tmp, hStereoDft->res_pred_gain_fx + ( add( k, k_offset ) ) * STEREO_DFT_BAND_MAX + b, 1 );
+ stereo_dft_dequantize_res_gains_f_fx( &hStereoDft->res_gains_ind_fx[0][b], &hStereoDft->res_gains_ind_fx[1][b], &tmp, hStereoDft->res_pred_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), 1 );
}
/* Smoothing of prediction gains between ftrames */
FOR( ; b < hStereoDft->nbands; b++ )
{
+ test();
+ test();
IF( hStereoDft->attackPresent )
{
hStereoDft->res_gains_ind_fx[0][b] = hStereoDft->res_gains_ind_fx[0][b + STEREO_DFT_BAND_MAX];
@@ -1128,7 +1207,7 @@ void stereo_dft_dec_smooth_parameters_fx(
IF( !hStereoDft->recovery_flg )
{
- stereo_dft_dequantize_res_gains_f_fx( &hStereoDft->res_gains_ind_fx[0][b], &hStereoDft->res_gains_ind_fx[1][b], hStereoDft->side_gain_fx + ( add( k, k_offset ) ) * STEREO_DFT_BAND_MAX + b, hStereoDft->res_pred_gain_fx + ( add( k, k_offset ) ) * STEREO_DFT_BAND_MAX + b, 1 );
+ stereo_dft_dequantize_res_gains_f_fx( &hStereoDft->res_gains_ind_fx[0][b], &hStereoDft->res_gains_ind_fx[1][b], hStereoDft->side_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), hStereoDft->res_pred_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), 1 );
}
}
@@ -1138,10 +1217,12 @@ void stereo_dft_dec_smooth_parameters_fx(
IF( LT_32( diff_ipd, -EVS_PI_FX_Q27 ) )
{
pgIpd[0] = L_add( pgIpd[0], EVS_2PI_FX_Q27 );
+ move32();
}
ELSE IF( GT_32( diff_ipd, EVS_PI_FX_Q27 ) )
{
pgIpd[0] = L_sub( pgIpd[0], EVS_2PI_FX_Q27 );
+ move32();
}
IF( !hStereoDft->attackPresent )
@@ -1149,23 +1230,23 @@ void stereo_dft_dec_smooth_parameters_fx(
IF( hStereoDft->wasTransient )
{
pgIpd[0] = L_add( Mpy_32_16_1( pgIpd[0], (Word16) 0x6666 ), Mpy_32_16_1( pgIpd[-hStereoDft->prm_res[add( k, k_offset )]], (Word16) ( 0x199A ) ) );
- move16();
+ move32();
}
ELSE
{
pgIpd[0] = L_add( L_shr( pgIpd[0], 1 ), L_shr( pgIpd[-hStereoDft->prm_res[add( k, k_offset )]], 1 ) );
- move16();
+ move32();
}
}
IF( !hStereoDft->attackPresent )
{
- pSideGain = hStereoDft->side_gain_fx + ( add( k, k_offset ) ) * STEREO_DFT_BAND_MAX;
+ pSideGain = hStereoDft->side_gain_fx + i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX );
FOR( b = 0; b < hStereoDft->res_cod_band_max; b++ )
{
pSideGain[b] = Madd_32_16( Mpy_32_16_1( pSideGain[b], dft_res_cod_alpha_fx[b] ),
- pSideGain[b - hStereoDft->prm_res[add( k, k_offset )] * STEREO_DFT_BAND_MAX],
+ pSideGain[sub( b, i_mult( hStereoDft->prm_res[add( k, k_offset )], STEREO_DFT_BAND_MAX ) )],
sub( (Word16) 0x7FFF, dft_res_cod_alpha_fx[b] ) );
move32();
}
@@ -1183,27 +1264,31 @@ void stereo_dft_dec_smooth_parameters_fx(
}
ELSE
{
- *( pInterpol ) = *( hStereoDft->gipd_fx + ( add( k, k_offset ) - hStereoDft->prm_res[add( k, k_offset )] ) );
+ *( pInterpol ) = *( hStereoDft->gipd_fx + sub( add( k, k_offset ), hStereoDft->prm_res[add( k, k_offset )] ) );
move32();
}
FOR( b = 0; b < hStereoDft->nbands; b++ )
{
- *( hStereoDft->res_pred_gain_fx + sub( add( k, k_offset ), k2 ) * STEREO_DFT_BAND_MAX + b ) = *( hStereoDft->res_pred_gain_fx + ( add( k, k_offset ) - hStereoDft->prm_res[add( k, k_offset )] ) * STEREO_DFT_BAND_MAX + b );
+ *( hStereoDft->res_pred_gain_fx + add( i_mult( sub( add( k, k_offset ), k2 ), STEREO_DFT_BAND_MAX ), b ) ) = *( hStereoDft->res_pred_gain_fx + add( i_mult( sub( add( k, k_offset ), hStereoDft->prm_res[add( k, k_offset )] ), STEREO_DFT_BAND_MAX ), b ) );
move32();
+ test();
+ test();
+ test();
+ test();
IF( b < hStereoDft->res_cod_band_max || hStereoDft->attackPresent || hStereoDft->trans || ( hStereoDft->res_pred_mode[k] && LT_32( hStereoDft->res_gains_ind_fx[1][b + STEREO_DFT_BAND_MAX], ONE_IN_Q27 ) ) )
{
- *( hStereoDft->side_gain_fx + sub( add( k, k_offset ), k2 ) * STEREO_DFT_BAND_MAX + b ) = *( hStereoDft->side_gain_fx + ( add( k, k_offset ) ) * STEREO_DFT_BAND_MAX + b );
+ *( hStereoDft->side_gain_fx + add( i_mult( sub( add( k, k_offset ), k2 ), STEREO_DFT_BAND_MAX ), b ) ) = *( hStereoDft->side_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ) );
move32();
}
ELSE
{
- *( hStereoDft->side_gain_fx + sub( add( k, k_offset ), k2 ) * STEREO_DFT_BAND_MAX + b ) = *( hStereoDft->side_gain_fx + ( add( k, k_offset ) - hStereoDft->prm_res[add( k, k_offset )] ) * STEREO_DFT_BAND_MAX + b );
+ *( hStereoDft->side_gain_fx + add( i_mult( sub( add( k, k_offset ), k2 ), STEREO_DFT_BAND_MAX ), b ) ) = *( hStereoDft->side_gain_fx + add( i_mult( sub( add( k, k_offset ), hStereoDft->prm_res[add( k, k_offset )] ), STEREO_DFT_BAND_MAX ), b ) );
move32();
}
}
- hStereoDft->itd_fx[( add( k, k_offset ) ) - k2] = hStereoDft->itd_fx[add( k, k_offset )];
+ hStereoDft->itd_fx[sub( add( k, k_offset ), k2 )] = hStereoDft->itd_fx[add( k, k_offset )];
move32();
} /*end of interpolation*/
}
@@ -1242,6 +1327,7 @@ void stereo_dft_dec_res_fx(
{
set_val_Word32( hCPE->hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k );
hCPE->hStereoDft->q_res_cod_mem_fx = Q16;
+ move16();
set_val_Word32( hCPE->input_mem_fx[1], 0, NS2SA( 8000, STEREO_DFT32MS_OVL_NS ) );
set_val_Word16( hCPE->hStereoDft->hBpf->pst_old_syn_fx, 0, STEREO_DFT_NBPSF_PIT_MAX_8k );
hCPE->hStereoDft->hBpf->pst_mem_deemp_err_fx = 0;
@@ -1256,7 +1342,6 @@ void stereo_dft_dec_res_fx(
/*OLA*/
/*overlapping parts*/
Word16 q_shift = sub( hCPE->hStereoDft->q_res_cod_mem_fx, Q16 );
- move16();
FOR( i = 0; i < STEREO_DFT_OVL_8k; i++ )
{
win[i] = extract_h( L_add( hCPE->hStereoDft->res_cod_mem_fx[i], L_shl( L_mult( win[i], hCPE->hStereoDft->win_8k_fx[i] ), q_shift ) ) );
@@ -1264,7 +1349,7 @@ void stereo_dft_dec_res_fx(
hCPE->hStereoDft->res_cod_mem_fx[i] = L_mult( win[L_FRAME8k + i], hCPE->hStereoDft->win_8k_fx[STEREO_DFT_OVL_8k - 1 - i] );
move32();
}
- IF( NE_16( q_shift, 0 ) )
+ IF( q_shift != 0 )
{
v_shr_16( &win[STEREO_DFT_OVL_8k], negate( q_shift ), &win[STEREO_DFT_OVL_8k], L_FRAME8k );
}
@@ -1273,13 +1358,9 @@ void stereo_dft_dec_res_fx(
}
ELSE
{
- Word16 q_div;
/* For first good frame, ola memory contains extended ECU buffer -- need to crossfade instead of OLA */
- step = BASOP_Util_Divide3232_Scale( 1, STEREO_DFT_OVL_8k, &q_div );
- IF( NE_16( q_div, 0 ) )
- {
- step = shl( step, q_div );
- }
+ step = 468; /* 1 / STEREO_DFT_OVL_8k in Q15 */
+ move16();
fac = 0;
move16();
FOR( i = 0; i < STEREO_DFT_OVL_8k; i++ )
@@ -1296,7 +1377,7 @@ void stereo_dft_dec_res_fx(
Copy( win, out_16, L_FRAME8k );
- IF( EQ_16( hCPE->hCoreCoder[0]->core, ACELP_CORE ) )
+ IF( hCPE->hCoreCoder[0]->core == ACELP_CORE )
{
/* bass post-filter */
bass_psfilter_fx( hCPE->hStereoDft->hBpf, hCPE->hCoreCoder[0]->Opt_AMR_WB, out_16, L_FRAME8k, hCPE->hCoreCoder[0]->old_pitch_buf_16_fx + ( L_FRAME8k / STEREO_DFT_L_SUBFR_8k ), hCPE->hCoreCoder[0]->bpf_off,
@@ -1323,7 +1404,7 @@ void stereo_dft_dec_res_fx(
v_sub_32( output, bpf_error_signal_8k, output, L_FRAME8k );
}
}
- ELSE IF( EQ_16( hCPE->hCoreCoder[0]->last_core, ACELP_CORE ) )
+ ELSE IF( hCPE->hCoreCoder[0]->last_core == ACELP_CORE )
{
set_val_Word16( hCPE->hStereoDft->hBpf->pst_old_syn_fx, 0, STEREO_DFT_NBPSF_PIT_MAX_8k );
hCPE->hStereoDft->hBpf->pst_mem_deemp_err_fx = 0;
@@ -1409,6 +1490,14 @@ void stereo_dft_dec_fx(
stop = shr( STEREO_DFT32MS_N_32k, 1 );
/* Analyze nature of current frame */
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
hStereoDft->trans = (Word16) ( ( EQ_16( st0->clas_dec, ONSET ) || EQ_16( st0->clas_dec, SIN_ONSET ) || EQ_16( st0->clas_dec, UNVOICED_CLAS ) || EQ_16( st0->clas_dec, UNVOICED_TRANSITION ) ) || LE_16( st0->stab_fac_fx, (Word16) 0x2000 ) ) ||
( ( EQ_16( st0->core, TCX_20_CORE ) && ( EQ_16( st0->hTcxCfg->tcx_last_overlap_mode, MIN_OVERLAP ) || EQ_16( st0->hTcxCfg->tcx_last_overlap_mode, HALF_OVERLAP ) ) ) || EQ_16( st0->core, TCX_10_CORE ) );
move16();
@@ -1422,12 +1511,13 @@ void stereo_dft_dec_fx(
The prev_old_bfi still holds the prev_bfi for the current frame. */
/* make sure number of bands corresponds to output bwidth in case it is lower than parameter bwidth */
move16();
- IF( LT_16( output_frame, inner_frame_tbl[st0->bwidth] ) && EQ_16( sba_dirac_stereo_flag, 0 ) )
+ test();
+ IF( LT_16( output_frame, inner_frame_tbl[st0->bwidth] ) && ( sba_dirac_stereo_flag == 0 ) )
{
hStereoDft->nbands = stereo_dft_band_config_fx( hStereoDft->band_limits, hStereoDft->band_res[k_offset], hStereoDft->NFFT, DEC );
}
- IF( EQ_16( st0->bfi, 0 ) )
+ IF( st0->bfi == 0 )
{
/* Smoothing for the current frame */
IF( sba_dirac_stereo_flag )
@@ -1444,7 +1534,7 @@ void stereo_dft_dec_fx(
move32();
IF( prev_bfi )
{
- dmx_nrg = stereo_dft_dmx_swb_nrg_fx( DFT[0], DFT[0] + STEREO_DFT32MS_N_MAX, min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ), 0, 0 );
+ dmx_nrg = stereo_dft_dmx_swb_nrg_fx( DFT[0], DFT[0] + STEREO_DFT32MS_N_MAX, s_min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ), 0, 0 );
}
@@ -1494,6 +1584,7 @@ void stereo_dft_dec_fx(
#endif
/* Use coarse band partition in inactive frames */
+ test();
IF( hStereoDft->frame_sid_nodata && !sba_dirac_stereo_flag )
{
NFFT_inner = i_mult( ( STEREO_DFT32MS_N_MAX / L_FRAME48k ), inner_frame_tbl[st0->bwidth] );
@@ -1506,18 +1597,19 @@ void stereo_dft_dec_fx(
hStereoDft->past_DMX_pos = ( hStereoDft->past_DMX_pos + STEREO_DFT_PAST_MAX - 1 ) % STEREO_DFT_PAST_MAX;
}
+ test();
IF( !( sba_dirac_stereo_flag && GE_16( nchan_transport, 2 ) ) )
{
- stereo_dft_generate_res_pred_fx( hStereoDft, samp_ratio, pDFT_DMX, DFT_PRED_RES, pPredGain, k, DFT[1] + k * STEREO_DFT32MS_N_MAX, &stop, st0->bfi );
+ stereo_dft_generate_res_pred_fx( hStereoDft, samp_ratio, pDFT_DMX, DFT_PRED_RES, pPredGain, k, DFT[1] + i_mult( k, STEREO_DFT32MS_N_MAX ), &stop, st0->bfi );
}
- IF( GT_16( hStereoDft->res_cod_band_max, 0 ) )
+ IF( hStereoDft->res_cod_band_max > 0 )
{
IF( !st0->bfi )
{
IF( EQ_16( k, 1 ) )
{
- Copy32( pDFT_RES, hStereoDft->res_mem_fx, 2 * hStereoDft->band_limits[hStereoDft->res_cod_band_max] );
+ Copy32( pDFT_RES, hStereoDft->res_mem_fx, shl( hStereoDft->band_limits[hStereoDft->res_cod_band_max], 1 ) );
hStereoDft->time_offs = 0;
move16();
}
@@ -1530,6 +1622,7 @@ void stereo_dft_dec_fx(
/* Apply active DMX */
/* pDFT_RES is used for the second channel in inactive frames */
+ test();
IF( hStereoDft->frame_sid_nodata && !sba_dirac_stereo_flag )
{
DFT_L[0] = pDFT_DMX[0];
@@ -1545,7 +1638,8 @@ void stereo_dft_dec_fx(
move32();
}
- IF( hStereoDft->frame_sid_nodata || EQ_16( st0->VAD, 0 ) )
+ test();
+ if ( hStereoDft->frame_sid_nodata || ( st0->VAD == 0 ) )
{
hFdCngDec->cna_nbands = 0;
move16();
@@ -1555,6 +1649,7 @@ void stereo_dft_dec_fx(
{
g = extract_h( pSideGain[b] );
move16();
+ test();
IF( hStereoDft->frame_sid_nodata && !sba_dirac_stereo_flag )
{
g = hStereoDft->g_state_fx[b];
@@ -1562,7 +1657,9 @@ void stereo_dft_dec_fx(
}
/* store side gains from inactive frames for later use by the stereo CNA */
- IF( LT_16( hStereoDft->band_limits[b], L_FRAME16k ) && ( hStereoDft->frame_sid_nodata || EQ_16( st0->VAD, 0 ) ) )
+ test();
+ test();
+ IF( LT_16( hStereoDft->band_limits[b], L_FRAME16k ) && ( hStereoDft->frame_sid_nodata || ( st0->VAD == 0 ) ) )
{
hFdCngDec->cna_nbands = add( b, 1 );
move16();
@@ -1573,6 +1670,8 @@ void stereo_dft_dec_fx(
}
/* No residual coding in inactive frames, instead pDFT_RES is used for the second channel */
+ test();
+ test();
IF( GE_16( b, hStereoDft->res_cod_band_max ) && !hStereoDft->frame_sid_nodata && !( sba_dirac_stereo_flag && hMdDec ) )
{
/*filter non-coded frequencies. It removes some MDCT frequency aliasing*/
@@ -1585,6 +1684,8 @@ void stereo_dft_dec_fx(
}
}
+ test();
+ test();
IF( hStereoDft->frame_sid_nodata && !sba_dirac_stereo_flag )
{
/* Low pass filter coherence */
@@ -1602,7 +1703,7 @@ void stereo_dft_dec_fx(
gamma = BASOP_Util_Divide3232_Scale( gamma, sub( MAX_16, gamma ), &q_loc1 );
l_gamma = L_deposit_l( gamma );
op1 = L_add( l_gamma, L_shr( L_deposit_l( sub( MAX_16, mult( g, g ) ) ), q_loc1 ) );
- q_loc1 = Q16 + q_loc1;
+ q_loc1 = add( Q16, q_loc1 );
q_loc2 = q_loc1;
op1 = Sqrt32( op1, &q_loc1 );
op2 = Sqrt32( l_gamma, &q_loc2 );
@@ -1628,9 +1729,9 @@ void stereo_dft_dec_fx(
DFT_R[2 * i] = Msub_32_16( Msub_32_16( pDFT_DMX[2 * i], pDFT_DMX[2 * i], g ), pDFT_RES[2 * i], gamma );
move32();
- DFT_L[2 * i + 1] = Madd_32_16( Madd_32_16( pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1], g ), pDFT_RES[2 * i + 1], gamma );
+ DFT_L[add( shl( i, 1 ), 1 )] = Madd_32_16( Madd_32_16( pDFT_DMX[add( shl( i, 1 ), 1 )], pDFT_DMX[add( shl( i, 1 ), 1 )], g ), pDFT_RES[add( shl( i, 1 ), 1 )], gamma );
move32();
- DFT_R[2 * i + 1] = Msub_32_16( Msub_32_16( pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1], g ), pDFT_RES[2 * i + 1], gamma );
+ DFT_R[add( shl( i, 1 ), 1 )] = Msub_32_16( Msub_32_16( pDFT_DMX[add( shl( i, 1 ), 1 )], pDFT_DMX[add( shl( i, 1 ), 1 )], g ), pDFT_RES[add( shl( i, 1 ), 1 )], gamma );
move32();
}
@@ -1657,6 +1758,7 @@ void stereo_dft_dec_fx(
IF( EQ_16( c0, ONE_IN_Q14 ) )
{
c0 = MAX_16;
+ move16();
}
ELSE
{
@@ -1666,8 +1768,8 @@ void stereo_dft_dec_fx(
FOR( i = hStereoDft->band_limits[b]; i < hStereoDft->band_limits[b + 1]; i++ )
{
/*rotate L*/
- tmp = Msub_32_16( Mpy_32_16_1( DFT_L[2 * i], c0 ), DFT_L[2 * i + 1], s0 );
- DFT_L[2 * i + 1] = Madd_32_16( Mpy_32_16_1( DFT_L[2 * i], s0 ), DFT_L[2 * i + 1], c0 );
+ tmp = Msub_32_16( Mpy_32_16_1( DFT_L[2 * i], c0 ), DFT_L[add( shl( i, 1 ), 1 )], s0 );
+ DFT_L[add( shl( i, 1 ), 1 )] = Madd_32_16( Mpy_32_16_1( DFT_L[2 * i], s0 ), DFT_L[add( shl( i, 1 ), 1 )], c0 );
move32();
DFT_L[2 * i] = tmp;
move32();
@@ -1691,47 +1793,47 @@ void stereo_dft_dec_fx(
move32();
DFT_R[2 * i] = 0;
move32();
- DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i + 1] );
+ DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[add( shl( i, 1 ), 1 )] );
move32();
- DFT_L[2 * i + 1] = DFT_W;
+ DFT_L[add( shl( i, 1 ), 1 )] = DFT_W;
move32();
- DFT_R[2 * i + 1] = 0;
+ DFT_R[add( shl( i, 1 ), 1 )] = 0;
move32();
}
FOR( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ )
{
- DFT_W = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i] ),
- L_add( hStereoDft->mixer_mat_smooth_fx[0][1][b + k * IVAS_MAX_NUM_BANDS],
- L_add( hStereoDft->mixer_mat_smooth_fx[0][2][b + k * IVAS_MAX_NUM_BANDS],
- hStereoDft->mixer_mat_smooth_fx[0][3][b + k * IVAS_MAX_NUM_BANDS] ) ),
+ DFT_W = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[2 * i] ),
+ L_add( hStereoDft->mixer_mat_smooth_fx[0][1][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )],
+ L_add( hStereoDft->mixer_mat_smooth_fx[0][2][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )],
+ hStereoDft->mixer_mat_smooth_fx[0][3][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )] ) ),
DFT_PRED_RES[2 * i] );
DFT_L[2 * i] = DFT_W;
move32();
DFT_R[2 * i] = 0;
move32();
- DFT_W = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i + 1] ),
- L_add( hStereoDft->mixer_mat_smooth_fx[0][1][b + k * IVAS_MAX_NUM_BANDS],
- L_add( hStereoDft->mixer_mat_smooth_fx[0][2][b + k * IVAS_MAX_NUM_BANDS],
- hStereoDft->mixer_mat_smooth_fx[0][3][b + k * IVAS_MAX_NUM_BANDS] ) ),
- DFT_PRED_RES[2 * i + 1] );
- DFT_L[2 * i + 1] = DFT_W;
+ DFT_W = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[add( shl( i, 1 ), 1 )] ),
+ L_add( hStereoDft->mixer_mat_smooth_fx[0][1][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )],
+ L_add( hStereoDft->mixer_mat_smooth_fx[0][2][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )],
+ hStereoDft->mixer_mat_smooth_fx[0][3][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )] ) ),
+ DFT_PRED_RES[add( shl( i, 1 ), 1 )] );
+ DFT_L[add( shl( i, 1 ), 1 )] = DFT_W;
move32();
- DFT_R[2 * i + 1] = 0;
+ DFT_R[add( shl( i, 1 ), 1 )] = 0;
move32();
}
FOR( ; i < hStereoDft->band_limits[b + 1]; i++ )
{
- DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i] );
+ DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[2 * i] );
DFT_L[2 * i] = DFT_W;
move32();
DFT_R[2 * i] = 0;
move32();
- DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i + 1] );
- DFT_L[2 * i + 1] = DFT_W;
+ DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[add( shl( i, 1 ), 1 )] );
+ DFT_L[add( shl( i, 1 ), 1 )] = DFT_W;
move32();
- DFT_R[2 * i + 1] = 0;
+ DFT_R[add( shl( i, 1 ), 1 )] = 0;
move32();
}
}
@@ -1741,16 +1843,16 @@ void stereo_dft_dec_fx(
{
i = 0;
move16();
- DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i] );
- DFT_Y = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[1][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i] );
+ DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[2 * i] );
+ DFT_Y = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[1][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[2 * i] );
DFT_L[2 * i] = L_add( DFT_W, DFT_Y );
move32();
DFT_R[2 * i] = L_sub( DFT_W, DFT_Y );
move32();
- DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i + 1] );
- DFT_Y = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[1][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i + 1] );
+ DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[add( shl( i, 1 ), 1 )] );
+ DFT_Y = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[1][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[add( shl( i, 1 ), 1 )] );
DFT_L[2 * i + 1] = L_add( DFT_W, DFT_Y );
move32();
@@ -1759,15 +1861,15 @@ void stereo_dft_dec_fx(
}
FOR( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ )
{
- DFT_W = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i] ),
- L_add( hStereoDft->mixer_mat_smooth_fx[0][1][b + k * IVAS_MAX_NUM_BANDS],
- L_add( hStereoDft->mixer_mat_smooth_fx[0][2][b + k * IVAS_MAX_NUM_BANDS],
- hStereoDft->mixer_mat_smooth_fx[0][3][b + k * IVAS_MAX_NUM_BANDS] ) ),
+ DFT_W = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[2 * i] ),
+ L_add( hStereoDft->mixer_mat_smooth_fx[0][1][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )],
+ L_add( hStereoDft->mixer_mat_smooth_fx[0][2][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )],
+ hStereoDft->mixer_mat_smooth_fx[0][3][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )] ) ),
DFT_PRED_RES[2 * i] );
- DFT_Y = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[1][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i] ),
- L_add( hStereoDft->mixer_mat_smooth_fx[1][1][b + k * IVAS_MAX_NUM_BANDS],
- L_add( hStereoDft->mixer_mat_smooth_fx[1][2][b + k * IVAS_MAX_NUM_BANDS],
- hStereoDft->mixer_mat_smooth_fx[1][3][b + k * IVAS_MAX_NUM_BANDS] ) ),
+ DFT_Y = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[1][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[2 * i] ),
+ L_add( hStereoDft->mixer_mat_smooth_fx[1][1][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )],
+ L_add( hStereoDft->mixer_mat_smooth_fx[1][2][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )],
+ hStereoDft->mixer_mat_smooth_fx[1][3][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )] ) ),
DFT_PRED_RES[2 * i] );
DFT_L[2 * i] = L_add( DFT_W, DFT_Y );
@@ -1775,38 +1877,38 @@ void stereo_dft_dec_fx(
DFT_R[2 * i] = L_sub( DFT_W, DFT_Y );
move32();
- DFT_W = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i + 1] ),
- L_add( hStereoDft->mixer_mat_smooth_fx[0][1][b + k * IVAS_MAX_NUM_BANDS],
- L_add( hStereoDft->mixer_mat_smooth_fx[0][2][b + k * IVAS_MAX_NUM_BANDS],
- hStereoDft->mixer_mat_smooth_fx[0][3][b + k * IVAS_MAX_NUM_BANDS] ) ),
- DFT_PRED_RES[2 * i + 1] );
- DFT_Y = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[1][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i + 1] ),
- L_add( hStereoDft->mixer_mat_smooth_fx[1][1][b + k * IVAS_MAX_NUM_BANDS],
- L_add( hStereoDft->mixer_mat_smooth_fx[1][2][b + k * IVAS_MAX_NUM_BANDS],
- hStereoDft->mixer_mat_smooth_fx[1][3][b + k * IVAS_MAX_NUM_BANDS] ) ),
- DFT_PRED_RES[2 * i + 1] );
-
- DFT_L[2 * i + 1] = L_add( DFT_W, DFT_Y );
+ DFT_W = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[add( shl( i, 1 ), 1 )] ),
+ L_add( hStereoDft->mixer_mat_smooth_fx[0][1][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )],
+ L_add( hStereoDft->mixer_mat_smooth_fx[0][2][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )],
+ hStereoDft->mixer_mat_smooth_fx[0][3][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )] ) ),
+ DFT_PRED_RES[add( shl( i, 1 ), 1 )] );
+ DFT_Y = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[1][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[add( shl( i, 1 ), 1 )] ),
+ L_add( hStereoDft->mixer_mat_smooth_fx[1][1][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )],
+ L_add( hStereoDft->mixer_mat_smooth_fx[1][2][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )],
+ hStereoDft->mixer_mat_smooth_fx[1][3][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )] ) ),
+ DFT_PRED_RES[add( shl( i, 1 ), 1 )] );
+
+ DFT_L[add( shl( i, 1 ), 1 )] = L_add( DFT_W, DFT_Y );
move32();
- DFT_R[2 * i + 1] = L_sub( DFT_W, DFT_Y );
+ DFT_R[add( shl( i, 1 ), 1 )] = L_sub( DFT_W, DFT_Y );
move32();
}
FOR( ; i < hStereoDft->band_limits[b + 1]; i++ )
{
- DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i] );
- DFT_Y = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[1][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i] );
+ DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[2 * i] );
+ DFT_Y = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[1][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[2 * i] );
DFT_L[2 * i] = L_add( DFT_W, DFT_Y );
move32();
DFT_R[2 * i] = L_sub( DFT_W, DFT_Y );
move32();
- DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i + 1] );
- DFT_Y = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[1][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i + 1] );
+ DFT_W = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[add( shl( i, 1 ), 1 )] );
+ DFT_Y = Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[1][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[add( shl( i, 1 ), 1 )] );
- DFT_L[2 * i + 1] = L_add( DFT_W, DFT_Y );
+ DFT_L[add( shl( i, 1 ), 1 )] = L_add( DFT_W, DFT_Y );
move32();
- DFT_R[2 * i + 1] = L_sub( DFT_W, DFT_Y );
+ DFT_R[add( shl( i, 1 ), 1 )] = L_sub( DFT_W, DFT_Y );
move32();
}
}
@@ -1820,40 +1922,40 @@ void stereo_dft_dec_fx(
DFT_W = pDFT_DMX[2 * i];
move32();
- DFT_Y = Madd_32_32( pDFT_DMX1[2 * i], hStereoDft->mixer_mat_smooth_fx[1][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i] );
+ DFT_Y = Madd_32_32( pDFT_DMX1[2 * i], hStereoDft->mixer_mat_smooth_fx[1][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[2 * i] );
DFT_L[2 * i] = L_add( DFT_W, DFT_Y );
move32();
DFT_R[2 * i] = L_sub( DFT_W, DFT_Y );
move32();
- DFT_W = pDFT_DMX[2 * i + 1];
+ DFT_W = pDFT_DMX[add( shl( i, 1 ), 1 )];
move32();
- DFT_Y = Madd_32_32( pDFT_DMX1[2 * i + 1], hStereoDft->mixer_mat_smooth_fx[1][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i + 1] );
+ DFT_Y = Madd_32_32( pDFT_DMX1[add( shl( i, 1 ), 1 )], hStereoDft->mixer_mat_smooth_fx[1][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[add( shl( i, 1 ), 1 )] );
- DFT_L[2 * i + 1] = L_add( DFT_W, DFT_Y );
+ DFT_L[add( shl( i, 1 ), 1 )] = L_add( DFT_W, DFT_Y );
move32();
- DFT_R[2 * i + 1] = L_sub( DFT_W, DFT_Y );
+ DFT_R[add( shl( i, 1 ), 1 )] = L_sub( DFT_W, DFT_Y );
move32();
}
FOR( i = hStereoDft->band_limits[b]; i < hStereoDft->band_limits[b + 1]; i++ )
{
DFT_W = pDFT_DMX[2 * i];
move32();
- DFT_Y = Madd_32_32( pDFT_DMX1[2 * i], hStereoDft->mixer_mat_smooth_fx[1][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i] );
+ DFT_Y = Madd_32_32( pDFT_DMX1[2 * i], hStereoDft->mixer_mat_smooth_fx[1][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[2 * i] );
DFT_L[2 * i] = L_add( DFT_W, DFT_Y );
move32();
DFT_R[2 * i] = L_sub( DFT_W, DFT_Y );
move32();
- DFT_W = pDFT_DMX[2 * i + 1];
+ DFT_W = pDFT_DMX[add( shl( i, 1 ), 1 )];
move32();
- DFT_Y = Madd_32_32( pDFT_DMX1[2 * i + 1], hStereoDft->mixer_mat_smooth_fx[1][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i + 1] );
+ DFT_Y = Madd_32_32( pDFT_DMX1[add( shl( i, 1 ), 1 )], hStereoDft->mixer_mat_smooth_fx[1][0][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], pDFT_DMX[add( shl( i, 1 ), 1 )] );
- DFT_L[2 * i + 1] = L_add( DFT_W, DFT_Y );
+ DFT_L[add( shl( i, 1 ), 1 )] = L_add( DFT_W, DFT_Y );
move32();
- DFT_R[2 * i + 1] = L_sub( DFT_W, DFT_Y );
+ DFT_R[add( shl( i, 1 ), 1 )] = L_sub( DFT_W, DFT_Y );
move32();
}
}
@@ -1873,11 +1975,11 @@ void stereo_dft_dec_fx(
DFT_R[2 * i] = L_sub( pDFT_DMX[2 * i], tmp );
move32();
- tmp = L_add( Madd_32_16( pDFT_RES[2 * i + 1], pDFT_DMX[2 * i + 1], g ), DFT_PRED_RES[2 * i + 1] );
+ tmp = L_add( Madd_32_16( pDFT_RES[add( shl( i, 1 ), 1 )], pDFT_DMX[add( shl( i, 1 ), 1 )], g ), DFT_PRED_RES[add( shl( i, 1 ), 1 )] );
- DFT_L[2 * i + 1] = L_add( pDFT_DMX[2 * i + 1], tmp );
+ DFT_L[add( shl( i, 1 ), 1 )] = L_add( pDFT_DMX[add( shl( i, 1 ), 1 )], tmp );
move32();
- DFT_R[2 * i + 1] = L_sub( pDFT_DMX[2 * i + 1], tmp );
+ DFT_R[add( shl( i, 1 ), 1 )] = L_sub( pDFT_DMX[add( shl( i, 1 ), 1 )], tmp );
move32();
}
@@ -1892,16 +1994,17 @@ void stereo_dft_dec_fx(
tmp = Madd_32_16( pDFT_RES[2 * i + 1], pDFT_DMX[2 * i + 1], g );
- DFT_L[2 * i + 1] = L_add( pDFT_DMX[2 * i + 1], tmp );
+ DFT_L[add( shl( i, 1 ), 1 )] = L_add( pDFT_DMX[add( shl( i, 1 ), 1 )], tmp );
move32();
- DFT_R[2 * i + 1] = L_sub( pDFT_DMX[2 * i + 1], tmp );
+ DFT_R[add( shl( i, 1 ), 1 )] = L_sub( pDFT_DMX[add( shl( i, 1 ), 1 )], tmp );
move32();
}
/* Active Upmix */
- IF( NE_32( pgIpd[0], 0 ) )
+ IF( pgIpd[0] != 0 )
{
Word32 theta = pgIpd[0];
+ move32();
WHILE( GT_32( theta, EVS_2PI_FX_Q27 ) )
{
theta = L_sub( theta, EVS_2PI_FX_Q27 );
@@ -1922,6 +2025,7 @@ void stereo_dft_dec_fx(
IF( EQ_16( c0, ONE_IN_Q14 ) )
{
c0 = MAX_16;
+ move16();
}
ELSE
{
@@ -1931,8 +2035,8 @@ void stereo_dft_dec_fx(
FOR( i = hStereoDft->band_limits[b]; i < hStereoDft->band_limits[b + 1]; i++ )
{
/*rotate L*/
- tmp = Msub_32_16( Mpy_32_16_1( DFT_L[2 * i], c0 ), DFT_L[2 * i + 1], s0 );
- DFT_L[2 * i + 1] = Madd_32_16( Mpy_32_16_1( DFT_L[2 * i], s0 ), DFT_L[2 * i + 1], c0 );
+ tmp = Msub_32_16( Mpy_32_16_1( DFT_L[2 * i], c0 ), DFT_L[add( shl( i, 1 ), 1 )], s0 );
+ DFT_L[add( shl( i, 1 ), 1 )] = Madd_32_16( Mpy_32_16_1( DFT_L[2 * i], s0 ), DFT_L[add( shl( i, 1 ), 1 )], c0 );
move32();
DFT_L[2 * i] = tmp;
move32();
@@ -1941,12 +2045,14 @@ void stereo_dft_dec_fx(
}
}
- IF( hStereoDft->frame_sid_nodata || EQ_16( st0->VAD, 0 ) )
+ test();
+ if ( hStereoDft->frame_sid_nodata || ( st0->VAD == 0 ) )
{
hFdCngDec->cna_band_limits[hFdCngDec->cna_nbands] = hStereoDft->band_limits[hFdCngDec->cna_nbands];
move16();
}
+ test();
IF( hStereoDft->frame_sid_nodata && !sba_dirac_stereo_flag )
{
hStereoCng->first_SID = 0;
@@ -2012,6 +2118,7 @@ void stereo_dft_dec_fx(
IF( GT_16( hFdCngDec->cna_rescale_fact_fx, 0 ) )
{
Word16 q_scale_fact0 = 0;
+ move16();
Word16 op = Sqrt16( shr( hFdCngDec->cna_rescale_fact_fx, 1 ), &q_scale_fact0 );
move16();
scale_fact0 = L_mult0( shr( output_frame, 1 ), op );
@@ -2039,22 +2146,25 @@ void stereo_dft_dec_fx(
gamma = coh;
move16();
gamma = BASOP_Util_Divide3232_Scale( gamma, sub( (Word16) 0x7FFF, gamma ), &q_gamma );
- IF( EQ_16( gamma, 0 ) )
+ if ( gamma == 0 )
{
q_gamma = 0;
+ move16();
}
l_gamma = L_deposit_l( gamma );
- op1 = L_add( l_gamma, L_shr( L_deposit_l( sub( MAX_16, mult( g, g ) ) ), q_gamma ) );
- q_loc2 = Q16 + q_gamma;
+ op1 = L_add( l_gamma, L_shr( L_deposit_l( sub( MAX_16, mult_sat( g, g ) ) ), q_gamma ) ); /*The mult_sat function is needed because -0.999979973 is being mapped to -32768. This value, when multiplied by -32768, is causing a crash.*/
+ q_loc2 = add( Q16, q_gamma );
q_loc1 = q_loc2;
+ move16();
op1 = Sqrt32( op1, &q_loc1 );
op2 = Sqrt32( l_gamma, &q_loc2 );
- IF( NE_32( op2, 0 ) )
+ IF( op2 != 0 )
{
IF( NE_16( q_loc1, q_loc2 ) )
{
op2 = L_shl( op2, sub( q_loc2, q_loc1 ) );
q_loc2 = q_loc1;
+ move16();
}
gamma = extract_h( L_sub( op1, op2 ) );
gamma = shl( gamma, q_loc2 );
@@ -2067,6 +2177,7 @@ void stereo_dft_dec_fx(
ELSE
{
gamma = 0;
+ move16();
}
FOR( i = s_max( hFdCngDec->cna_band_limits[b], shr( hFdCngCom->startBand, 1 ) ); i < s_min( hFdCngDec->cna_band_limits[b + 1], ( L_FRAME16k ) >> 1 ); i++ )
@@ -2077,7 +2188,9 @@ void stereo_dft_dec_fx(
lev2 = *ptr_per++;
move32();
- IF( GT_32( lev1, 0 ) && GT_32( lev2, 0 ) && GT_32( Mpy_32_16_1( L_max( lev1, lev2 ), (Word16) 0x6AAB ), L_min( lev1, lev2 ) ) )
+ test();
+ test();
+ IF( ( lev1 > 0 ) && ( lev2 > 0 ) && GT_32( Mpy_32_16_1( L_max( lev1, lev2 ), (Word16) 0x6AAB ), L_min( lev1, lev2 ) ) )
{
/* take the minimum of two adjacent frequency bins */
cna_level = L_min( lev1, lev2 );
@@ -2132,9 +2245,11 @@ void stereo_dft_dec_fx(
}
/* Update memories */
- hStereoDft->past_DMX_pos = ( hStereoDft->past_DMX_pos + 1 ) & ( STEREO_DFT_PAST_MAX - 1 );
+ hStereoDft->past_DMX_pos = s_and( ( add( hStereoDft->past_DMX_pos, 1 ) ), ( STEREO_DFT_PAST_MAX - 1 ) );
+ move16();
Copy32( pDFT_DMX, hStereoDft->DFT_past_DMX_fx[hStereoDft->past_DMX_pos], s_min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ) );
hStereoDft->q_DFT_past_DMX_fx[hStereoDft->past_DMX_pos] = hStereoDft->q_dft;
+ move16();
IF( pPredGain )
{
stereo_dft_adapt_sf_delay_fx( hStereoDft, pPredGain );
@@ -2192,7 +2307,8 @@ static void stereo_dft_compute_td_stefi_params_fx(
bres = hStereoDft->band_res[1];
move16();
- IF( NE_16( hStereoDft->core_hist[1], ACELP_CORE ) || hStereoDft->wasTransient )
+ test();
+ IF( ( hStereoDft->core_hist[1] != ACELP_CORE ) || hStereoDft->wasTransient )
{
hStereoDft->td_gain_fx[0] = 0;
move32();
@@ -2208,9 +2324,10 @@ static void stereo_dft_compute_td_stefi_params_fx(
move16();
WHILE( GT_16( hStereoDft->band_limits[b], bin0 ) )
{
- b--;
+ b = sub( b, 1 );
}
band0 = b;
+ move16();
/* calculate averages over high bands */
pred_g = pred_gain_avg = 0;
@@ -2220,7 +2337,7 @@ static void stereo_dft_compute_td_stefi_params_fx(
move16();
wsum = 0;
move32();
- shift_g = Q15 - norm_s( sub( hStereoDft->nbands, band0 ) );
+ shift_g = sub( Q15, norm_s( sub( hStereoDft->nbands, band0 ) ) );
FOR( b = band0; b < hStereoDft->nbands; b++ )
{
IF( LT_32( L_min( hStereoDft->past_res_pred_gain_fx[STEFI_DELAY_IND( STEREO_DFT_TD_STEFI_SUBFR_DELAY + 1, pdmx_ind )][b], hStereoDft->past_res_pred_gain_fx[STEFI_DELAY_IND( STEREO_DFT_TD_STEFI_SUBFR_DELAY + 2, pdmx_ind )][b] ), 0 ) )
@@ -2240,7 +2357,7 @@ static void stereo_dft_compute_td_stefi_params_fx(
dft_res_pred_weights_fx[bres][b - band0] ),
shift_g ) );
- nbands++;
+ nbands = add( nbands, 1 );
wsum = L_add( wsum, dft_res_pred_weights_fx[bres][b - band0] );
#ifdef DBG_TD_STEFI
printf( "frame: %d\tband: %-2d\tpred_gain1: %f\tpred_gain2: %f\tppg1: %f\tppg2: %f\n", frame, b, hStereoDft->res_pred_gain[b + STEREO_DFT_BAND_MAX], hStereoDft->res_pred_gain[b + 2 * STEREO_DFT_BAND_MAX], hStereoDft->past_res_pred_gain[STEREO_DFT_TD_STEFI_SUBFR_DELAY - 2][b], hStereoDft->past_res_pred_gain[d_short - 1][b] );
@@ -2272,29 +2389,33 @@ static void stereo_dft_compute_td_stefi_params_fx(
{
pred_gain_avg = L_shl( pred_gain_avg, q_div );
q_pred_gain_avg = 15;
+ move16();
}
ELSE
{
q_pred_gain_avg = sub( 15, q_div );
- ;
}
nrg_DMX = hStereoDft->hb_nrg_fx[0];
+ move32();
nrg_pred_DMX = hStereoDft->hb_nrg_fx[1];
+ move32();
op1 = BASOP_Util_Divide3232_Scale( L_add( EPSILON_FIX, nrg_DMX ), L_add( EPSILON_FIX, nrg_pred_DMX ), &q_div );
- q_sqrt = Q16 + q_div;
+ q_sqrt = add( Q16, q_div );
op1 = Sqrt32( op1, &q_sqrt );
g2 = Mpy_32_32( pred_g, op1 );
IF( LT_16( q_sqrt, 0 ) )
{
g2 = L_shl( g2, q_sqrt );
q_sqrt = 0;
+ move16();
}
- ELSE IF( NE_16( q_sqrt, 0 ) )
+ ELSE IF( q_sqrt != 0 )
{
IF( LT_32( L_shr( pred_gain_avg, q_sqrt ), g2 ) )
{
g2 = pred_gain_avg;
+ move32();
}
ELSE
{
@@ -2339,18 +2460,22 @@ static void stereo_dft_dequantize_ipd_fx(
IF( EQ_16( bits, 2 ) ) /* 2-bit phase quantization for the highest frequency band only */
{
delta_fx = ( EVS_PI_FX ) >> 1;
+ move16();
}
ELSE IF( EQ_16( bits, 3 ) )
{
delta_fx = ( EVS_PI_FX ) >> 2;
+ move16();
}
ELSE IF( EQ_16( bits, 4 ) )
{
delta_fx = ( EVS_PI_FX ) >> 3;
+ move16();
}
ELSE
{
delta_fx = ( EVS_PI_FX ) >> 2;
+ move16();
assert( 0 );
}
@@ -2358,6 +2483,7 @@ static void stereo_dft_dequantize_ipd_fx(
{
temp_out = L_sub( L_mult0( ind[i], delta_fx ), ( EVS_PI_FX ) );
*out_fx = L_shl( temp_out, 14 );
+ move32();
}
return;
}
@@ -2387,6 +2513,7 @@ void stereo_dft_generate_res_pred_fx(
/* variables for enhanced stereo filling */
Word16 norm_fac, q_norm_fac = 0, lim_norm_fac;
+ move16();
Word16 q_sqrt;
Word16 alpha; // gain_limit;
@@ -2402,9 +2529,18 @@ void stereo_dft_generate_res_pred_fx(
push_wmops( "gen_respred" );
/* smoothing and limiting parameters */
- alpha = hStereoDft->wasTransient ? 0 : (Word16) ( 0x199A ); /* no smoothing after transients */
+ // alpha = hStereoDft->wasTransient ? 0 : (Word16) ( 0x199A ); /* no smoothing after transients */
+ IF( hStereoDft->wasTransient )
+ {
+ alpha = 0;
+ move16();
+ }
+ ELSE
+ {
+ alpha = (Word16) ( 0x199A );
+ move16();
+ }
// gain_limit = 0x7FFF; // 2.0 in Q14
- move16();
/* residual prediction only used up to 16 kHz (SWB) */
nbands_respred = s_min( hStereoDft->nbands, STEREO_DFT_RES_PRED_BAND_MAX );
@@ -2418,7 +2554,7 @@ void stereo_dft_generate_res_pred_fx(
move16();
WHILE( GE_16( hStereoDft->band_limits[b], bin0 ) )
{
- b--;
+ b = sub( b, 1 );
}
band0 = b;
move16();
@@ -2458,10 +2594,10 @@ void stereo_dft_generate_res_pred_fx(
/* Saturating below calculations (to be rechecked?) */
dmx_nrg = L_add_sat( dmx_nrg,
Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ),
- pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) );
+ pDFT_DMX[add( shl( i, 1 ), 1 )], pDFT_DMX[add( shl( i, 1 ), 1 )] ) );
rev_nrg = L_add_sat( rev_nrg,
Madd_32_32( Mpy_32_32( ap_filt_DMX[2 * i], ap_filt_DMX[2 * i] ),
- ap_filt_DMX[2 * i + 1], ap_filt_DMX[2 * i + 1] ) );
+ ap_filt_DMX[add( shl( i, 1 ), 1 )], ap_filt_DMX[add( shl( i, 1 ), 1 )] ) );
}
IF( LT_16( hStereoDft->q_smoothed_nrg, hStereoDft->q_dft ) )
{
@@ -2486,39 +2622,56 @@ void stereo_dft_generate_res_pred_fx(
{
norm_fac = BASOP_Util_Divide3232_Scale( hStereoDft->smooth_dmx_nrg_fx[b], hStereoDft->smooth_res_nrg_fx[b], &q_norm_fac );
norm_fac = Sqrt16( norm_fac, &q_norm_fac );
- IF( NE_16( norm_fac, 0 ) )
+ IF( norm_fac != 0 )
{
/* gain compressor */
- IF( LE_16( q_norm_fac, -Q1 ) || ( EQ_16( q_norm_fac, Q1 ) && GT_16( (Word16) 0x3333, norm_fac ) ) || ( EQ_16( q_norm_fac, 0 ) && GT_16( (Word16) 0x6666, norm_fac ) ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( LE_16( q_norm_fac, -Q1 ) || ( EQ_16( q_norm_fac, Q1 ) && GT_16( (Word16) 0x3333, norm_fac ) ) || ( ( q_norm_fac == 0 ) && GT_16( (Word16) 0x6666, norm_fac ) ) )
{
lim_norm_fac = (Word16) 0x5000;
+ move16();
}
- ELSE IF( GT_16( q_norm_fac, Q1 ) || ( EQ_16( q_norm_fac, Q1 ) && LT_16( (Word16) 0x5000, norm_fac ) ) || ( EQ_16( q_norm_fac, 0 ) && GT_16( (Word16) 0x6666, norm_fac ) ) )
+ ELSE IF( GT_16( q_norm_fac, Q1 ) || ( EQ_16( q_norm_fac, Q1 ) && LT_16( (Word16) 0x5000, norm_fac ) ) || ( ( q_norm_fac == 0 ) && GT_16( (Word16) 0x6666, norm_fac ) ) )
{
lim_norm_fac = (Word16) 0x3333;
+ move16();
}
ELSE
{
lim_norm_fac = norm_fac;
+ move16();
}
IF( EQ_16( lim_norm_fac, norm_fac ) )
{
norm_fac = ONE_IN_Q14;
+ move16();
q_norm_fac = Q1;
+ move16();
}
ELSE
{
norm_fac = extract_l( L_shr( L_mult0( norm_fac, lim_norm_fac ), Q15 ) );
q_norm_fac = add( q_norm_fac, 1 );
- IF( LT_16( q_norm_fac, 0 ) )
+ test();
+ IF( q_norm_fac < 0 )
{
norm_fac = shl( norm_fac, q_norm_fac );
q_norm_fac = 0;
+ move16();
}
ELSE IF( GT_16( q_norm_fac, 2 ) && LT_16( norm_s( norm_fac ), sub( q_norm_fac, Q1 ) ) )
{
norm_fac = MAX_16;
+ move16();
q_norm_fac = Q1;
+ move16();
}
}
}
@@ -2526,14 +2679,16 @@ void stereo_dft_generate_res_pred_fx(
ELSE
{
norm_fac = MAX_16;
+ move16();
q_norm_fac = Q1;
+ move16();
}
FOR( i = hStereoDft->band_limits[b]; i < s_min( hStereoDft->band_limits[b + 1], bin0 ); i++ )
{
DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), q_norm_fac );
move32();
- DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i + 1] ), q_norm_fac );
+ DFT_PRED_RES[add( shl( i, 1 ), 1 )] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[add( shl( i, 1 ), 1 )] ), q_norm_fac );
move32();
}
}
@@ -2541,13 +2696,14 @@ void stereo_dft_generate_res_pred_fx(
IF( GT_16( hStereoDft->q_smoothed_nrg, hStereoDft->q_dft ) )
{
hStereoDft->q_smoothed_nrg = hStereoDft->q_dft;
+ move16();
}
#endif
}
ELSE IF( EQ_16( hStereoDft->res_pred_mode[k + STEREO_DFT_OFFSET], STEREO_DFT_RESPRED_STEFI ) )
{
/* stefi in lowband */
- set_l( DFT_PRED_RES, 0, 2 * hStereoDft->band_limits[lb_stefi_start_band] );
+ set32_fx( DFT_PRED_RES, 0, shl( hStereoDft->band_limits[lb_stefi_start_band], 1 ) );
FOR( b = lb_stefi_start_band; b <= band0; b++ )
{
@@ -2557,7 +2713,7 @@ void stereo_dft_generate_res_pred_fx(
move16();
/* make sure d_short really corresponds to a shorter or equally long delay than d_long (e.g. not always the case for
* STEREO_DFT_STEFFI_DELAY_SHORT=3 and STEREO_DFT_STEFFI_DELAY_LONG=4)*/
- d_short_ind = max( d_short_ind, d_long_ind );
+ d_short_ind = s_max( d_short_ind, d_long_ind );
move16();
/* Even number of window sliding (assymmetric OLA) */
@@ -2568,7 +2724,9 @@ void stereo_dft_generate_res_pred_fx(
d_long = sub( STEREO_DFT_PAST_MAX, d_long_ind );
d_short_ind = add( add( d_short_ind, hStereoDft->past_DMX_pos ), 1 ) % STEREO_DFT_PAST_MAX;
+ move16();
d_long_ind = add( add( d_long_ind, hStereoDft->past_DMX_pos ), 1 ) % STEREO_DFT_PAST_MAX;
+ move16();
g_short = hStereoDft->stefi_short_gain_fx;
move16();
@@ -2585,6 +2743,7 @@ void stereo_dft_generate_res_pred_fx(
}
/* Avoid transient components */
+ test();
IF( EQ_32( hStereoDft->past_res_pred_gain_fx[d_short_ind][b], EVS_LW_MIN ) && EQ_32( hStereoDft->past_res_pred_gain_fx[d_long_ind][b], EVS_LW_MIN ) )
{
g_long = 0;
@@ -2607,7 +2766,7 @@ void stereo_dft_generate_res_pred_fx(
move16();
}
- IF( GT_16( s_max( g_short, g_long ), 0 ) )
+ IF( s_max( g_short, g_long ) > 0 )
{
Word16 q_shift0 = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[d_short_ind] );
Word16 q_shift1 = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[d_long_ind] );
@@ -2617,20 +2776,21 @@ void stereo_dft_generate_res_pred_fx(
move32();
FOR( i = hStereoDft->band_limits[b]; i < min( bin0, hStereoDft->band_limits[b + 1] ); i++ )
{
- dmx_nrg = Madd_32_32( Madd_32_32( dmx_nrg, pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] );
+ dmx_nrg = Madd_32_32( Madd_32_32( dmx_nrg, pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[add( shl( i, 1 ), 1 )], pDFT_DMX[add( shl( i, 1 ), 1 )] );
DFT_PRED_RES[2 * i] = L_add( L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i], g_short ), q_shift0 ), L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_long_ind][2 * i], g_long ), q_shift1 ) );
move32();
- DFT_PRED_RES[2 * i + 1] = L_add( L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i + 1], g_short ), q_shift0 ), L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_long_ind][2 * i + 1], g_long ), q_shift1 ) );
+ DFT_PRED_RES[add( shl( i, 1 ), 1 )] = L_add( L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_short_ind][add( shl( i, 1 ), 1 )], g_short ), q_shift0 ), L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_long_ind][add( shl( i, 1 ), 1 )], g_long ), q_shift1 ) );
move32();
- past_dmx_nrg = Madd_32_32( Madd_32_32( past_dmx_nrg, DFT_PRED_RES[2 * i], DFT_PRED_RES[2 * i] ), DFT_PRED_RES[2 * i + 1], DFT_PRED_RES[2 * i + 1] );
+ past_dmx_nrg = Madd_32_32( Madd_32_32( past_dmx_nrg, DFT_PRED_RES[2 * i], DFT_PRED_RES[2 * i] ), DFT_PRED_RES[add( shl( i, 1 ), 1 )], DFT_PRED_RES[add( shl( i, 1 ), 1 )] );
}
IF( !bfi || GE_16( b, hStereoDft->res_cod_band_max ) )
{
Word16 q_div;
Word16 op;
- op = BASOP_Util_Divide3232_Scale( ( 1 + dmx_nrg ), ( 1 + past_dmx_nrg ), &q_div );
+ op = BASOP_Util_Divide3232_Scale( L_add( 1, dmx_nrg ), L_add( 1, past_dmx_nrg ), &q_div );
q_sqrt = q_div;
+ move16();
norm_fac = Sqrt16( op, &q_sqrt );
g2 = Mpy_32_16_1( pPredGain[b], norm_fac );
IF( LE_32( q_sqrt, norm_l( g2 ) ) )
@@ -2643,6 +2803,7 @@ void stereo_dft_generate_res_pred_fx(
Madd_32_16( Mpy_32_16_1( pred_gain_avg, sub( MAX_16, STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ),
g2, STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) );
q_sqrt = 0;
+ move16();
}
ELSE
{
@@ -2651,13 +2812,14 @@ void stereo_dft_generate_res_pred_fx(
g2 = Madd_32_16( Mpy_32_16_1( hStereoDft->past_res_pred_gain_fx[d_short_ind][b], g_short ),
hStereoDft->past_res_pred_gain_fx[d_long_ind][b], g_long );
q_sqrt = 0;
+ move16();
}
FOR( i = hStereoDft->band_limits[b]; i < min( bin0, hStereoDft->band_limits[b + 1] ); i++ )
{
DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( g2, DFT_PRED_RES[2 * i] ), q_sqrt );
move32();
- DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( g2, DFT_PRED_RES[2 * i + 1] ), q_sqrt );
+ DFT_PRED_RES[add( shl( i, 1 ), 1 )] = L_shl( Mpy_32_32( g2, DFT_PRED_RES[add( shl( i, 1 ), 1 )] ), q_sqrt );
move32();
}
}
@@ -2672,13 +2834,14 @@ void stereo_dft_generate_res_pred_fx(
IF( GT_16( hStereoDft->band_limits[nbands_respred], bin0 ) )
{
/* apply stereo filling in ACELP BWE region */
- IF( EQ_16( hStereoDft->core_hist[0], ACELP_CORE ) && EQ_16( hStereoDft->core_hist[STEREO_DFT_STEFFI_DELAY_SHORT / 2], ACELP_CORE ) )
+ test();
+ IF( ( hStereoDft->core_hist[0] == ACELP_CORE ) && ( hStereoDft->core_hist[STEREO_DFT_STEFFI_DELAY_SHORT / 2] == ACELP_CORE ) )
{
/* ACELP -> ACELP: nothing to do */
*stop = bin0;
move16();
}
- ELSE IF( EQ_16( hStereoDft->core_hist[STEREO_DFT_STEFFI_DELAY_SHORT / 2], ACELP_CORE ) )
+ ELSE IF( hStereoDft->core_hist[STEREO_DFT_STEFFI_DELAY_SHORT / 2] == ACELP_CORE )
{
/* ACELP -> TCX/HQ core transition */
/* calculate high band energy only */
@@ -2686,57 +2849,73 @@ void stereo_dft_generate_res_pred_fx(
move32();
FOR( i = bin0; i < shr( hStereoDft->NFFT, 1 ); i++ )
{
- dmx_nrg = L_add( dmx_nrg, Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) );
+ dmx_nrg = L_add( dmx_nrg, Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[add( shl( i, 1 ), 1 )], pDFT_DMX[add( shl( i, 1 ), 1 )] ) );
}
- hStereoDft->hb_nrg_fx[0] = dmx_nrg, L_shr( hStereoDft->NFFT, 1 );
+ hStereoDft->hb_nrg_fx[0] = L_add( hStereoDft->hb_nrg_fx[0], div_l( dmx_nrg, shr( hStereoDft->NFFT, 2 ) ) );
+ move32();
*stop = bin0;
move16();
}
- ELSE IF( EQ_16( hStereoDft->core_hist[0], ACELP_CORE ) )
+ ELSE IF( hStereoDft->core_hist[0] == ACELP_CORE )
{
/* TCX/HQ core -> ACELP transition */
/* apply short delay only and blend to long/short gain */
dmx_nrg = hStereoDft->hb_nrg_subr_fx[k];
+ move32();
d_short_ind = STEREO_DFT_PAST_MAX - STEREO_DFT_TD_STEFI_SUBFR_DELAY;
+ move16();
- d_short_ind = add( d_short_ind, add( hStereoDft->past_DMX_pos, 1 ) ) & ( STEREO_DFT_PAST_MAX - 1 );
+ d_short_ind = s_and( add( d_short_ind, add( hStereoDft->past_DMX_pos, 1 ) ), ( STEREO_DFT_PAST_MAX - 1 ) );
/* calculate high band energy of past dmx */
// past_dmx_nrg = EPSILON_FIX;
past_dmx_nrg = 0;
+ move32();
FOR( i = bin0; i < s_min( shr( hStereoDft->NFFT, 1 ), STEREO_DFT32MS_N_32k / 2 ); i++ )
{
- past_dmx_nrg = L_add( past_dmx_nrg, Madd_32_32( Mpy_32_32( hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i], hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i] ), hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i + 1], hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i + 1] ) );
+ past_dmx_nrg = L_add( past_dmx_nrg, Madd_32_32( Mpy_32_32( hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i], hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i] ), hStereoDft->DFT_past_DMX_fx[d_short_ind][add( shl( i, 1 ), 1 )], hStereoDft->DFT_past_DMX_fx[d_short_ind][add( shl( i, 1 ), 1 )] ) );
}
past_dmx_nrg = L_shl( past_dmx_nrg, shl( sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[d_short_ind] ), 1 ) );
- IF( EQ_32( past_dmx_nrg, 0 ) )
+ IF( past_dmx_nrg == 0 )
{
past_dmx_nrg = EPSILON_FX;
+ move32();
}
FOR( b = band0; b < nbands_respred; b++ )
{
- g_short = LT_32( hStereoDft->past_res_pred_gain_fx[d_short_ind][b], 0 ) ? 0 : add( ONE_IN_Q14, shr( hStereoDft->stefi_short_gain_fx, 1 ) );
+ // g_short = LT_32( hStereoDft->past_res_pred_gain_fx[d_short_ind][b], 0 ) ? 0 : add( ONE_IN_Q14, shr( hStereoDft->stefi_short_gain_fx, 1 ) );
+ IF( hStereoDft->past_res_pred_gain_fx[d_short_ind][b] < 0 )
+ {
+ g_short = 0;
+ move16();
+ }
+ ELSE
+ {
+ g_short = add( ONE_IN_Q14, shr( hStereoDft->stefi_short_gain_fx, 1 ) );
+ }
- IF( GT_16( g_short, 0 ) )
+ IF( g_short > 0 )
{
Word16 q_divide, q_shift;
- Word32 op = BASOP_Util_Divide3232_Scale( ( EPSILON_FIX + dmx_nrg ), ( EPSILON_FIX + past_dmx_nrg ), &q_divide );
- q_norm_fac = Q16 + q_divide + hStereoDft->q_hb_nrg_subr;
+ Word32 op = BASOP_Util_Divide3232_Scale( L_add( EPSILON_FIX, dmx_nrg ), L_add( EPSILON_FIX, past_dmx_nrg ), &q_divide );
+ q_norm_fac = add( add( Q16, q_divide ), hStereoDft->q_hb_nrg_subr );
op = Sqrt32( op, &q_norm_fac );
g2 = Mpy_32_32( pPredGain[b], op );
pred_gain_avg = Mpy_32_16_1( hStereoDft->past_res_pred_gain_fx[d_short_ind][b], g_short );
- IF( LT_16( q_norm_fac, 0 ) )
+ IF( q_norm_fac < 0 )
{
g2 = L_shl( g2, q_norm_fac );
q_norm_fac = 0;
+ move16();
}
- ELSE IF( NE_16( q_norm_fac, 0 ) )
+ ELSE IF( q_norm_fac != 0 )
{
IF( LT_32( L_shr( pred_gain_avg, q_norm_fac ), g2 ) )
{
g2 = pred_gain_avg;
+ move32();
}
ELSE
{
@@ -2758,7 +2937,7 @@ void stereo_dft_generate_res_pred_fx(
{
DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( g2, hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i] ), q_shift );
move32();
- DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( g2, hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i + 1] ), q_shift );
+ DFT_PRED_RES[add( shl( i, 1 ), 1 )] = L_shl( Mpy_32_32( g2, hStereoDft->DFT_past_DMX_fx[d_short_ind][add( shl( i, 1 ), 1 )] ), q_shift );
move32();
}
}
@@ -2768,7 +2947,7 @@ void stereo_dft_generate_res_pred_fx(
move16();
end = min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 );
move16();
- set_l( DFT_PRED_RES + 2 * begin, 0, 2 * ( end - begin ) );
+ set32_fx( DFT_PRED_RES + shl( begin, 1 ), 0, shl( sub( end, begin ), 1 ) );
}
}
}
@@ -2862,17 +3041,18 @@ void stereo_dft_generate_res_pred_fx(
move32();
FOR( i = max( hStereoDft->band_limits[b], bin0 ); i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ )
{
- dmx_nrg = L_add( dmx_nrg, Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) );
+ dmx_nrg = L_add( dmx_nrg, Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[add( shl( i, 1 ), 1 )], pDFT_DMX[add( shl( i, 1 ), 1 )] ) );
DFT_PRED_RES[2 * i] = L_add( L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i], g_short ), q_shift0 ), L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_long_ind][2 * i], g_long ), q_shift1 ) );
move32();
- DFT_PRED_RES[2 * i + 1] = L_add( L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i + 1], g_short ), q_shift0 ), L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_long_ind][2 * i + 1], g_long ), q_shift1 ) );
+ DFT_PRED_RES[add( shl( i, 1 ), 1 )] = L_add( L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_short_ind][add( shl( i, 1 ), 1 )], g_short ), q_shift0 ), L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_long_ind][add( shl( i, 1 ), 1 )], g_long ), q_shift1 ) );
move32();
past_dmx_nrg = L_add( past_dmx_nrg, Madd_32_32( Mpy_32_32( DFT_PRED_RES[2 * i], DFT_PRED_RES[2 * i] ), DFT_PRED_RES[2 * i + 1], DFT_PRED_RES[2 * i + 1] ) );
}
op1 = L_deposit_h( BASOP_Util_Divide3232_Scale( ( EPSILON_FIX + dmx_nrg ), ( EPSILON_FIX + past_dmx_nrg ), &q_div ) );
q_norm_fac = q_div;
+ move16();
op1 = Sqrt32( op1, &q_norm_fac );
IF( GT_16( q_norm_fac, 16 ) )
{
@@ -2890,7 +3070,7 @@ void stereo_dft_generate_res_pred_fx(
{
DFT_PRED_RES[2 * i] = Mpy_32_32( g2, DFT_PRED_RES[2 * i] );
move32();
- DFT_PRED_RES[2 * i + 1] = Mpy_32_32( g2, DFT_PRED_RES[2 * i + 1] );
+ DFT_PRED_RES[add( shl( i, 1 ), 1 )] = Mpy_32_32( g2, DFT_PRED_RES[add( shl( i, 1 ), 1 )] );
move32();
}
}
@@ -2898,7 +3078,7 @@ void stereo_dft_generate_res_pred_fx(
{
begin = s_max( hStereoDft->band_limits[b], bin0 );
end = s_min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 );
- set_l( DFT_PRED_RES + 2 * begin, 0, 2 * ( end - begin ) );
+ set32_fx( DFT_PRED_RES + shl( begin, 1 ), 0, shl( sub( end, begin ), 1 ) );
}
}
}
@@ -2907,14 +3087,15 @@ void stereo_dft_generate_res_pred_fx(
/* update buffers */
FOR( b = hStereoDft->res_pred_band_min; b < hStereoDft->nbands; b++ )
{
+ test();
IF( hStereoDft->attackPresent || hStereoDft->wasTransient )
{
- hStereoDft->past_res_pred_gain_fx[( hStereoDft->past_DMX_pos + 1 ) & ( STEREO_DFT_PAST_MAX - 1 )][b] = MIN_32;
+ hStereoDft->past_res_pred_gain_fx[s_and( add( hStereoDft->past_DMX_pos, 1 ), ( STEREO_DFT_PAST_MAX - 1 ) )][b] = MIN_32;
move32();
}
ELSE
{
- hStereoDft->past_res_pred_gain_fx[( hStereoDft->past_DMX_pos + 1 ) & ( STEREO_DFT_PAST_MAX - 1 )][b] = pPredGain[b];
+ hStereoDft->past_res_pred_gain_fx[s_and( add( hStereoDft->past_DMX_pos, 1 ), ( STEREO_DFT_PAST_MAX - 1 ) )][b] = pPredGain[b];
move32();
}
}
@@ -2966,13 +3147,15 @@ static void stereo_dft_adapt_sf_delay_fx(
{
hStereoDft->lt_pred_gain_fx = L_shr( hStereoDft->lt_pred_gain_fx, sub( q_guard, hStereoDft->q_lt_pred_gain ) );
hStereoDft->q_lt_pred_gain = q_guard;
+ move16();
}
ELSE
{
sum_pg = L_shr( sum_pg, sub( hStereoDft->q_lt_pred_gain, q_guard ) );
q_guard = hStereoDft->q_lt_pred_gain;
+ move16();
}
- IF( GT_32( sum_pg, 0 ) )
+ IF( sum_pg > 0 )
{
/* Calculate mean of the prediction gain */
hStereoDft->lt_pred_gain_fx = Madd_32_16( Mpy_32_16_1( sum_pg, STEREO_DFT_LT_PREDGAIN_UPD_FX ), hStereoDft->lt_pred_gain_fx, sub( MAX_16, STEREO_DFT_LT_PREDGAIN_UPD_FX ) );
@@ -2989,7 +3172,7 @@ static void stereo_dft_adapt_sf_delay_fx(
IF( GT_32( hStereoDft->lt_pred_gain_fx, 0 ) )
{
Word32 opr2 = L_deposit_h( BASOP_Util_Divide3232_Scale( hStereoDft->lt_pred_gain_variation_fx, hStereoDft->lt_pred_gain_fx, &q_div ) );
- IF( LT_16( q_div, 0 ) )
+ IF( q_div < 0 )
{
opr2 = L_shl( opr2, q_div );
q_div = 0;
@@ -2998,6 +3181,7 @@ static void stereo_dft_adapt_sf_delay_fx(
IF( LT_32( L_shr( STEREO_DFT_RES_RATIO_LIMIT_FX_3_BY_2, q_div ), opr2 ) )
{
var_mean_ratio = STEREO_DFT_RES_RATIO_LIMIT_FX_3_BY_2;
+ move32();
}
ELSE
{
@@ -3049,16 +3233,20 @@ static void stereo_dft_adapt_sf_delay_fx(
/* Adapt the stereo filling delay by interpolating between two delay taps, one at the shortest delay and one at the longest delay */
hStereoDft->stefi_short_gain_fx = extract_l( L_shr( L_sub( L_shl( STEREO_DFT_STEFFI_DELAY_LONG, Q15 ), target_delay ), 1 ) );
q_sqrt = 0;
+ move16();
IF( hStereoDft->stefi_short_gain_fx == MIN_16 )
{
hStereoDft->stefi_short_gain_fx = MAX_16;
+ move16();
hStereoDft->stefi_long_gain_fx = 0;
+ move16();
}
ELSE
{
op = hStereoDft->stefi_short_gain_fx;
+ move16();
hStereoDft->stefi_long_gain_fx = Sqrt16( sub( MAX_16, mult( op, op ) ), &q_sqrt );
- IF( NE_16( q_sqrt, 0 ) )
+ IF( q_sqrt != 0 )
{
hStereoDft->stefi_long_gain_fx = shl( hStereoDft->stefi_long_gain_fx, q_sqrt );
}
@@ -3110,6 +3298,7 @@ void stereo_dft_dec_sid_coh_fx(
}
}
alpha_fx = dft_cng_alpha_bits_fx[alpha_step][alpha_index]; /*Q-15*/
+ move16();
}
ELSE
{
@@ -3120,7 +3309,7 @@ void stereo_dft_dec_sid_coh_fx(
FOR( i = *nb_bits; i < nr_of_sid_stereo_bits; i++ )
{
get_next_indice_fx( st, 1 );
- ( *nb_bits )++;
+ ( *nb_bits ) = add( ( *nb_bits ), 1 );
}
}
@@ -3162,7 +3351,7 @@ void stereo_dft_dec_sid_coh_fx(
cohBandq_fx[b] = 8192;
move16();
}
- ELSE IF( LT_16( cohBandq_fx[b], 0 ) )
+ ELSE IF( cohBandq_fx[b] < 0 )
{
cohBandq_fx[b] = 0;
move16();
@@ -3177,7 +3366,7 @@ void stereo_dft_dec_sid_coh_fx(
FOR( i = *nb_bits; i < nr_of_sid_stereo_bits; i++ )
{
get_next_indice_fx( st, 1 );
- ( *nb_bits )++;
+ ( *nb_bits ) = add( ( *nb_bits ), 1 );
}
return;
}
@@ -3340,24 +3529,26 @@ void stereo_dft_dec_read_BS_fx(
ELSE
{
hStereoDft->attackPresent = get_next_indice_fx( st, 1 );
- ( *nb_bits )++;
+ ( *nb_bits ) = add( ( *nb_bits ), 1 );
}
/* read res_cod_mode from bitstream */
+ test();
IF( EQ_16( bwidth, WB ) && hStereoDft->hConfig->ada_wb_res_cod_mode )
{
hStereoDft->res_cod_mode[k_offset] = get_next_indice_fx( st, 1 );
- ( *nb_bits )++;
+ move16();
+ ( *nb_bits ) = add( ( *nb_bits ), 1 );
}
/* read number of bands in the bitstream - depends on the audio bandwidth and not to output_Fs */
IF( hStereoDft->frame_sid )
{
- NFFT_inner = mult_r( inner_frame_tbl[bwidth], divide1616( STEREO_DFT32MS_N_MAX, L_FRAME48k ) );
+ NFFT_inner = imult1616( inner_frame_tbl[bwidth], STEREO_DFT32MS_N_MAX / L_FRAME48k );
}
ELSE
{
- NFFT_inner = mult_r( inner_frame_tbl[st->bwidth], divide1616( STEREO_DFT32MS_N_MAX, L_FRAME48k ) );
+ NFFT_inner = imult1616( inner_frame_tbl[st->bwidth], STEREO_DFT32MS_N_MAX / L_FRAME48k );
}
/* Use coarse band partition in inactive frames */
@@ -3385,16 +3576,19 @@ void stereo_dft_dec_read_BS_fx(
hStereoDft->res_cod_band_max = dft_band_res_cod[hStereoDft->band_res[k_offset]][hStereoDft->res_cod_mode[k_offset]];
move16();
- hStereoDft->res_cod_line_max = (Word16) L_shr( ( ( 1 << Q13 ) /*0.5f Q-14*/ + L_shl( L_mult0( sub( hStereoDft->band_limits[hStereoDft->res_cod_band_max], 1 ), divide1616( shr( output_frame, 1 ), ( hStereoDft->NFFT ) ) ) /*Q-14*/, 1 ) ), Q14 );
+ hStereoDft->res_cod_line_max = (Word16) L_shr( L_add( ( 1 << Q13 ) /*0.5f Q-14*/, L_shl( L_mult0( sub( hStereoDft->band_limits[hStereoDft->res_cod_band_max], 1 ), divide1616( shr( output_frame, 1 ), ( hStereoDft->NFFT ) ) ) /*Q-14*/, 1 ) ), Q14 );
+ move16();
hStereoDft->res_cod_line_max = shl( shr( hStereoDft->res_cod_line_max, 3 ), 3 );
+ move16();
hStereoDft->res_pred_band_min = s_max( STEREO_DFT_RES_PRED_BAND_MIN, hStereoDft->res_cod_band_max );
+ move16();
/*Copy config. for all DFT frames*/
- set16_fx( hStereoDft->band_res + k_offset + 1, hStereoDft->band_res[k_offset], N_div - 1 );
- set16_fx( hStereoDft->prm_res + k_offset + 1, hStereoDft->prm_res[k_offset], N_div - 1 );
- set16_fx( hStereoDft->res_pred_mode + k_offset + 1, hStereoDft->res_pred_mode[k_offset], N_div - 1 );
- set16_fx( hStereoDft->res_cod_mode + k_offset + 1, hStereoDft->res_cod_mode[k_offset], N_div - 1 );
+ set16_fx( hStereoDft->band_res + add( k_offset, 1 ), hStereoDft->band_res[k_offset], sub( N_div, 1 ) );
+ set16_fx( hStereoDft->prm_res + add( k_offset, 1 ), hStereoDft->prm_res[k_offset], sub( N_div, 1 ) );
+ set16_fx( hStereoDft->res_pred_mode + add( k_offset, 1 ), hStereoDft->res_pred_mode[k_offset], sub( N_div, 1 ) );
+ set16_fx( hStereoDft->res_cod_mode + add( k_offset, 1 ), hStereoDft->res_cod_mode[k_offset], sub( N_div, 1 ) );
/*------------------------------------------------------------------*
* Read DFT stereo parameters
@@ -3404,11 +3598,12 @@ void stereo_dft_dec_read_BS_fx(
FOR( k = hStereoDft->prm_res[k_offset] - 1; k < N_div; k += hStereoDft->prm_res[k + k_offset] )
{
/* reset parameters */
- set_zero_fx( hStereoDft->side_gain_fx + ( k + k_offset ) * STEREO_DFT_BAND_MAX, STEREO_DFT_BAND_MAX );
+ set_zero_fx( hStereoDft->side_gain_fx + i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), STEREO_DFT_BAND_MAX );
hStereoDft->gipd_fx[k + k_offset] = 0;
move32();
- set_zero_fx( hStereoDft->res_pred_gain_fx + ( k + k_offset ) * STEREO_DFT_BAND_MAX, STEREO_DFT_BAND_MAX );
+ set_zero_fx( hStereoDft->res_pred_gain_fx + i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), STEREO_DFT_BAND_MAX );
+ test();
IF( !( EQ_16( ivas_format, MASA_FORMAT ) && LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) )
{
/*------------------------------------------------------------------*
@@ -3427,7 +3622,7 @@ void stereo_dft_dec_read_BS_fx(
n_bits = read_flag_EC_DFT( &st->bit_stream[nb], &hStereoDft->side_gain_flag_1 );
nb = add( nb, n_bits );
- IF( EQ_16( hStereoDft->side_gain_flag_1, 0 ) )
+ IF( hStereoDft->side_gain_flag_1 == 0 )
{
b = read_BS_adapt_GR_sg( st->bit_stream, nb, ind1, hStereoDft->nbands, &hStereoDft->side_gain_flag_2, dft_maps_sg );
n_bits = add( n_bits, b );
@@ -3459,6 +3654,7 @@ void stereo_dft_dec_read_BS_fx(
hStereoDft->side_gain_index_previous[b] = ind1[b];
move16();
hStereoDft->res_gains_ind_fx[0][b + STEREO_DFT_BAND_MAX] = L_shl( ind1[b], 26 );
+ move32();
}
st->next_bit_pos = add( st->next_bit_pos, n_bits );
@@ -3479,7 +3675,7 @@ void stereo_dft_dec_read_BS_fx(
IF( itd_mode )
{
( *nb_bits ) = add( ( *nb_bits ), read_itd( st, &I ) );
- stereo_dft_dequantize_itd_fx( &I, hStereoDft->itd_fx + k + k_offset, st->output_Fs );
+ stereo_dft_dequantize_itd_fx( &I, hStereoDft->itd_fx + add( k, k_offset ), st->output_Fs );
}
}
ELSE IF( LE_16( *nb_bits, ( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - STEREO_DFT_ITD_MODE_NBITS - STEREO_DFT_SID_ITD_NBITS - 1 - SID_FORMAT_NBITS ) ) )
@@ -3487,7 +3683,7 @@ void stereo_dft_dec_read_BS_fx(
itd_mode = get_next_indice_fx( st, STEREO_DFT_ITD_MODE_NBITS );
( *nb_bits ) = add( ( *nb_bits ), STEREO_DFT_ITD_MODE_NBITS ); /*ITD mode flag: 1bit*/
- hStereoDft->itd_fx[k + k_offset] = 0;
+ hStereoDft->itd_fx[add( k, k_offset )] = 0;
move32();
IF( itd_mode )
{
@@ -3496,7 +3692,7 @@ void stereo_dft_dec_read_BS_fx(
( *nb_bits ) = add( ( *nb_bits ), STEREO_DFT_SID_ITD_NBITS + 1 );
I = shl( I, STEREO_DFT_SID_ITD_FAC );
I = add( I, shl( sign_flag, 8 ) );
- stereo_dft_dequantize_itd_fx( &I, hStereoDft->itd_fx + k + k_offset, st->output_Fs );
+ stereo_dft_dequantize_itd_fx( &I, hStereoDft->itd_fx + add( k, k_offset ), st->output_Fs );
}
}
@@ -3516,12 +3712,13 @@ void stereo_dft_dec_read_BS_fx(
move16();
nb = add( nb, 1 );
n_bits = add( n_bits, 1 );
- IF( EQ_16( hStereoDft->no_ipd_flag, 0 ) )
+ IF( hStereoDft->no_ipd_flag == 0 )
{
ind1_ipd[0] = get_value( &st->bit_stream[nb], STEREO_DFT_GIPD_NBITS );
+ move16();
nb = add( nb, STEREO_DFT_GIPD_NBITS );
n_bits = add( n_bits, STEREO_DFT_GIPD_NBITS );
- stereo_dft_dequantize_ipd_fx( &ind1_ipd[0], hStereoDft->gipd_fx + ( k + k_offset ), 1, STEREO_DFT_GIPD_NBITS );
+ stereo_dft_dequantize_ipd_fx( &ind1_ipd[0], hStereoDft->gipd_fx + add( k, k_offset ), 1, STEREO_DFT_GIPD_NBITS );
}
}
ELSE IF( LE_16( *nb_bits, ( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - STEREO_DFT_FLAG_BITS - STEREO_DFT_SID_GIPD_NBITS - SID_FORMAT_NBITS ) ) )
@@ -3531,12 +3728,13 @@ void stereo_dft_dec_read_BS_fx(
move16();
nb = add( nb, 1 );
n_bits = add( n_bits, 1 );
- IF( EQ_16( hStereoDft->no_ipd_flag, 0 ) )
+ IF( hStereoDft->no_ipd_flag == 0 )
{
ind1_ipd[0] = get_value( &st->bit_stream[nb], STEREO_DFT_SID_GIPD_NBITS );
+ move16();
nb = add( nb, STEREO_DFT_SID_GIPD_NBITS );
n_bits = add( n_bits, STEREO_DFT_SID_GIPD_NBITS );
- stereo_dft_dequantize_ipd_fx( &ind1_ipd[0], hStereoDft->gipd_fx + ( k + k_offset ), 1, STEREO_DFT_SID_GIPD_NBITS );
+ stereo_dft_dequantize_ipd_fx( &ind1_ipd[0], hStereoDft->gipd_fx + add( k, k_offset ), 1, STEREO_DFT_SID_GIPD_NBITS );
}
}
ELSE
@@ -3561,7 +3759,8 @@ void stereo_dft_dec_read_BS_fx(
/* Not used in inactive frames */
IF( !hStereoDft->frame_sid_nodata )
{
- IF( hStereoDft->res_pred_mode[k + k_offset] && EQ_16( hStereoDft->attackPresent, 0 ) )
+ test();
+ IF( hStereoDft->res_pred_mode[add( k, k_offset )] && hStereoDft->attackPresent == 0 )
{
nbands = s_min( hStereoDft->nbands, STEREO_DFT_RES_PRED_BAND_MAX );
@@ -3587,7 +3786,7 @@ void stereo_dft_dec_read_BS_fx(
nb = add( nb, b );
n_bits = add( n_bits, b );
- IF( EQ_16( hStereoDft->res_pred_flag_0, 0 ) )
+ IF( hStereoDft->res_pred_flag_0 == 0 )
{
b = read_BS_adapt_GR_rpg( st->bit_stream, nb, ind1_pred, hStereoDft->res_pred_band_min, nbands, &hStereoDft->res_pred_flag_1 );
n_bits = add( n_bits, b );
@@ -3602,6 +3801,7 @@ void stereo_dft_dec_read_BS_fx(
FOR( b = hStereoDft->res_pred_band_min; b < nbands; b++ )
{
ind1_pred[b] = add( ind1_pred[b], hStereoDft->res_pred_index_previous[b] );
+ move16();
}
}
ELSE
@@ -3609,6 +3809,7 @@ void stereo_dft_dec_read_BS_fx(
FOR( b = hStereoDft->res_pred_band_min; b < nbands; b++ )
{
ind1_pred[b] = get_value( &st->bit_stream[nb], STEREO_DFT_RES_GAINS_BITS );
+ move16();
nb = add( nb, STEREO_DFT_RES_GAINS_BITS );
n_bits = add( n_bits, STEREO_DFT_RES_GAINS_BITS );
}
@@ -3619,7 +3820,7 @@ void stereo_dft_dec_read_BS_fx(
{
I = 0;
move16();
- stereo_dft_dequantize_res_gains_fx( ind1 + b, &I, hStereoDft->side_gain_fx + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, hStereoDft->res_pred_gain_fx + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, 1 );
+ stereo_dft_dequantize_res_gains_fx( ind1 + b, &I, hStereoDft->side_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), hStereoDft->res_pred_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), 1 );
hStereoDft->res_pred_index_previous[b] = I;
move16();
hStereoDft->res_gains_ind_fx[1][b + STEREO_DFT_BAND_MAX] = 0;
@@ -3630,19 +3831,21 @@ void stereo_dft_dec_read_BS_fx(
{
I = ind1_pred[b];
move16();
- stereo_dft_dequantize_res_gains_fx( ind1 + b, &I, hStereoDft->side_gain_fx + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, hStereoDft->res_pred_gain_fx + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, 1 );
+ stereo_dft_dequantize_res_gains_fx( ind1 + b, &I, hStereoDft->side_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), hStereoDft->res_pred_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), 1 );
hStereoDft->res_pred_index_previous[b] = I;
move16();
hStereoDft->res_gains_ind_fx[1][b + STEREO_DFT_BAND_MAX] = L_shl( I, 26 );
+ move32();
}
FOR( ; b < hStereoDft->nbands; b++ )
{
I = 0;
move16();
- stereo_dft_dequantize_res_gains_fx( ind1 + b, &I, hStereoDft->side_gain_fx + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, hStereoDft->res_pred_gain_fx + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, 1 );
+ stereo_dft_dequantize_res_gains_fx( ind1 + b, &I, hStereoDft->side_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), hStereoDft->res_pred_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), 1 );
move16();
hStereoDft->res_pred_index_previous[b] = I;
+ move16();
hStereoDft->res_gains_ind_fx[1][b + STEREO_DFT_BAND_MAX] = 0;
move32();
}
@@ -3653,10 +3856,11 @@ void stereo_dft_dec_read_BS_fx(
{
I = 0;
move16();
- stereo_dft_dequantize_res_gains_fx( ind1 + b, &I, hStereoDft->side_gain_fx + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, hStereoDft->res_pred_gain_fx + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, 1 );
+ stereo_dft_dequantize_res_gains_fx( ind1 + b, &I, hStereoDft->side_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), hStereoDft->res_pred_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), 1 );
hStereoDft->res_pred_index_previous[b] = I;
move16();
hStereoDft->res_gains_ind_fx[1][b + STEREO_DFT_BAND_MAX] = L_shl( I, 26 );
+ move32();
}
}
@@ -3672,13 +3876,14 @@ void stereo_dft_dec_read_BS_fx(
{
I = 0;
move16();
- stereo_dft_dequantize_res_gains_fx( ind1 + b, &I, hStereoDft->side_gain_fx + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, hStereoDft->res_pred_gain_fx + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, 1 );
+ stereo_dft_dequantize_res_gains_fx( ind1 + b, &I, hStereoDft->side_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), hStereoDft->res_pred_gain_fx + add( i_mult( add( k, k_offset ), STEREO_DFT_BAND_MAX ), b ), 1 );
}
}
}
}
}
+ test();
IF( !( EQ_16( ivas_format, MASA_FORMAT ) && LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) )
{
IF( NE_16( hStereoDft->side_gain_flag_1, 2 ) )
@@ -3736,6 +3941,7 @@ void stereo_dft_dec_read_BS_fx(
FOR( Word16 c = 0; c < hStereoDft->res_cod_line_max; c++ )
{
dec[c] = shl_sat( dec[c], 8 );
+ move16();
}
ECSQ_dequantize_vector_fx( dec, hStereoDft->res_global_gain_fx, hStereoDft->res_cod_line_max, res_buf_fx );
@@ -3758,11 +3964,14 @@ void stereo_dft_dec_read_BS_fx(
pop_wmops();
}
+ test();
+ test();
IF( hStereoDft->frame_sid && !( EQ_16( ivas_format, MASA_FORMAT ) && LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) )
{
stereo_dft_dec_sid_coh_fx( st, hStereoDft->nbands, coh_fx, nb_bits );
}
+ test();
IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_16( ivas_format, MASA_FORMAT ) )
{
*nb_bits = (Word16) Mult_32_16( L_sub( element_brate, SID_2k40 ), INV_FRAME_PER_SEC_Q15 ); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; */
diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c
index 3023b40e903de3ff1f9e3dd937fdbc0a2ba3e6e5..e0cd69ef6f5d22cc03908bec7b40616ea8130326 100644
--- a/lib_dec/ivas_stereo_dft_plc_fx.c
+++ b/lib_dec/ivas_stereo_dft_plc_fx.c
@@ -34,8 +34,7 @@
#include "options.h"
#include "cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
@@ -85,7 +84,7 @@ void stereo_dft_res_ecu_fx(
Word16 trigo_step;
Word16 q_fac;
- set_l( pDFT_RES, 0, L_FRAME8k );
+ set32_fx( pDFT_RES, 0, L_FRAME8k );
L_res = hStereoDft->band_limits[hStereoDft->res_cod_band_max];
move16();
@@ -93,7 +92,7 @@ void stereo_dft_res_ecu_fx(
stereo_dft_res_subst_spec_fx( hStereoDft, pDFT_RES, DFT_PRED_RES, hStereoDft->time_offs, L_res, L_FRAME8k, k, num_plocs, plocs, plocsi, k == 0 );
fac = BASOP_Util_Divide3232_Scale( L_FRAME8k, hStereoDft->NFFT, &q_fac );
- IF( GT_16( q_fac, 0 ) )
+ IF( q_fac > 0 )
{
assert( 0 );
}
@@ -102,7 +101,7 @@ void stereo_dft_res_ecu_fx(
fac = shl( fac, q_fac );
}
- IF( EQ_16( hStereoDft->core_hist[0], ACELP_CORE ) )
+ IF( hStereoDft->core_hist[0] == ACELP_CORE )
{
fac = extract_l( L_shr( L_mult0( fac, 0x2000 ), 15 ) );
}
@@ -111,16 +110,16 @@ void stereo_dft_res_ecu_fx(
move16();
FOR( i = 0; i < STEREO_DFT32MS_N_8k / 4; i++ )
{
- trigo_dec[i] = hStereoDft->dft_trigo_8k_fx[i * trigo_step];
+ trigo_dec[i] = hStereoDft->dft_trigo_8k_fx[i_mult( i, trigo_step )];
move16();
- trigo_dec[STEREO_DFT32MS_N_8k / 2 - i] = hStereoDft->dft_trigo_8k_fx[i * trigo_step];
+ trigo_dec[STEREO_DFT32MS_N_8k / 2 - i] = hStereoDft->dft_trigo_8k_fx[i_mult( i, trigo_step )];
move16();
}
- trigo_dec[STEREO_DFT32MS_N_8k / 4] = hStereoDft->dft_trigo_8k_fx[STEREO_DFT32MS_N_8k / 4 * trigo_step];
+ trigo_dec[STEREO_DFT32MS_N_8k / 4] = hStereoDft->dft_trigo_8k_fx[i_mult( STEREO_DFT32MS_N_8k / 4, trigo_step )];
move16();
/* estimation of res_cod_mem (ola part in imdct residual signal) and input_mem (memory for buffer in DFT analysis)*/
- IF( EQ_16( k, 0 ) )
+ IF( k == 0 )
{
Copy32( pDFT_RES, res_buf, L_FRAME8k );
stereo_dft_res_subst_spec_fx( hStereoDft, res_buf, DFT_PRED_RES, hStereoDft->time_offs + output_frame, L_res, L_FRAME8k, k, num_plocs, plocs, plocsi, FALSE );
@@ -130,6 +129,7 @@ void stereo_dft_res_ecu_fx(
v_multc_fixed_16( res_buf, fac, res_buf, L_FRAME8k );
Copy32( res_buf + ( OFFSET8k - ZP8k ), &hStereoDft->res_cod_mem_fx[0], STEREO_DFT_OVL_8k );
hStereoDft->q_res_cod_mem_fx = hStereoDft->q_dft;
+ move16();
Copy32( res_buf + ZP8k, input_mem, NS2SA( 8000, STEREO_DFT32MS_OVL_NS ) ); /* Store memory for cross-fade to next frame, in case of good frame */
hStereoDft->q_ip_mem = hStereoDft->q_dft;
@@ -138,7 +138,8 @@ void stereo_dft_res_ecu_fx(
ELSE
{
Word16 scale_fac = getScaleFactor32( res_buf, L_FRAME8k );
- Word16 q_shift = 8 - scale_fac;
+ Word16 q_shift = sub( 8, scale_fac );
+ move16();
// Copy32( pDFT_RES, res_buf, L_FRAME8k );
v_shr_32( pDFT_RES, res_buf, L_FRAME8k, q_shift );
@@ -164,7 +165,7 @@ void stereo_dft_res_ecu_fx(
hStereoDft->time_offs = add( hStereoDft->time_offs, L_FRAME8k );
}
- set_l( DFT_PRED_RES, 0, 2 * L_res );
+ set32_fx( DFT_PRED_RES, 0, shl( L_res, 1 ) );
IF( prev_bfi )
{
@@ -200,7 +201,7 @@ Word32 imax_pos_fx(
ftmp_den2 = L_shl( L_sub( L_sub( L_shl( y2, 1 ), y1 ), y3 ), 1 );
test();
- IF( EQ_32( ftmp_den2, 0 ) || EQ_32( ftmp_den1, 0 ) )
+ IF( ( ftmp_den2 == 0 ) || ( ftmp_den1 == 0 ) )
{
return ( 0 ); /* early exit with left-most value */
}
@@ -219,7 +220,7 @@ Word32 imax_pos_fx(
}
/* their corresponding normalized locations */
posi = BASOP_Util_Divide3232_Scale( y3_y1, ( ftmp_den2 ), &q_div_posi );
- IF( NE_16( q_div_posi, 0 ) )
+ IF( ( q_div_posi != 0 ) )
{
posi = L_shl( posi, q_div_posi );
q_div_posi = 0;
@@ -229,14 +230,33 @@ Word32 imax_pos_fx(
test();
IF( GE_32( posi, L_shr( ONE_IN_Q15, q_div_posi ) ) || LE_32( posi, L_shr( MIN_16, q_div_posi ) ) )
{
- posi = GT_32( y3, y1 ) ? ONE_IN_Q15 : MIN_16;
- move16();
+ // posi = GT_32( y3, y1 ) ? ONE_IN_Q15 : MIN_16;
+ IF( GT_32( y3, y1 ) )
+ {
+ posi = ONE_IN_Q15;
+ move32();
+ }
+ ELSE
+ {
+ posi = MIN_16;
+ move32();
+ }
}
ELSE
{
IF( GE_32( L_shr( y1, q_div_2i ), y2i ) )
{
- posi = GT_32( y1, y3 ) ? MIN_16 : ONE_IN_Q15;
+ // posi = GT_32( y1, y3 ) ? MIN_16 : ONE_IN_Q15;
+ IF( GT_32( y1, y3 ) )
+ {
+ posi = MIN_16;
+ move32();
+ }
+ ELSE
+ {
+ posi = ONE_IN_Q15;
+ move32();
+ }
move16();
}
ELSE IF( GE_32( L_shr( y3, q_div_2i ), y2i ) )
@@ -262,17 +282,18 @@ static void ivas_peakfinder_fx(
Word32 dx0[L_PROT48k_2], x[L_PROT48k_2 + 1], peakMag[MAX_PLOCS];
Word16 k, i, len, tempLoc = 0, foundPeak, ii, xInd;
Word16 *ind, indarr[L_PROT48k_2 + 1], peakLoc[MAX_PLOCS];
+ move16();
ind = indarr;
move16();
/* Find derivative */
- v_sub_32( x0 + 1, x0, dx0, len0 - 1 );
+ v_sub_32( x0 + 1, x0, dx0, sub( len0, 1 ) );
/* This is so we find the first of repeated values */
- FOR( i = 0; i < len0 - 1; i++ )
+ FOR( i = 0; i < sub( len0, 1 ); i++ )
{
- IF( EQ_32( dx0[i], 0 ) )
+ IF( dx0[i] == 0 )
{
dx0[i] = -EPSILON_FX;
move32();
@@ -288,13 +309,14 @@ static void ivas_peakfinder_fx(
{
x[k] = x0[0];
move32();
- ind[k++] = 0;
+ ind[k] = 0;
move16();
+ k = add( k, 1 );
}
- FOR( i = 1; i < len0 - 1; i++ )
+ FOR( i = 1; i < sub( len0, 1 ); i++ )
{
- IF( LT_32( L_xor( dx0[i - 1], dx0[i] ), 0 ) )
+ IF( L_xor( dx0[i - 1], dx0[i] ) < 0 )
{
ind[k] = i;
move16();
@@ -307,8 +329,9 @@ static void ivas_peakfinder_fx(
{
ind[k] = sub( len0, 1 );
move16();
- x[k++] = x0[len0 - 1];
+ x[k] = x0[sub( len0, 1 )];
move32();
+ k = add( k, 1 );
}
/* x only has the peaks, valleys, and endpoints */
len = k;
@@ -317,7 +340,7 @@ static void ivas_peakfinder_fx(
test();
test();
- IF( GT_16( len, 2 ) || ( !endpoints && GT_16( len, 0 ) ) )
+ IF( GT_16( len, 2 ) || ( !endpoints && ( len > 0 ) ) )
{
/* Set initial parameters for loop */
tempMag = minMag;
@@ -411,7 +434,7 @@ static void ivas_peakfinder_fx(
move32();
}
- ii++; /* Move onto the valley */
+ ii = add( ii, 1 ); /* Move onto the valley */
/* Come down at least sel from peak */
test();
@@ -425,7 +448,8 @@ static void ivas_peakfinder_fx(
move16();
peakMag[*cInd] = tempMag;
move32();
- ( *cInd )++;
+ ( *cInd ) = add( *( cInd ), 1 );
+ move16();
}
ELSE IF( LT_32( x[ii], leftMin ) ) /* New left minimum */
{
@@ -451,7 +475,8 @@ static void ivas_peakfinder_fx(
move16();
peakMag[*cInd] = tempMag;
move32();
- ( *cInd )++;
+ ( *cInd ) = add( *( cInd ), 1 );
+ move16();
}
/* Create output */
@@ -466,7 +491,17 @@ static void ivas_peakfinder_fx(
IF( endpoints )
{
/* This is a monotone function where an endpoint is the only peak */
- xInd = GT_32( x[0], x[1] ) ? 0 : 1;
+ // xInd = GT_32( x[0], x[1] ) ? 0 : 1;
+ IF( GT_32( x[0], x[1] ) )
+ {
+ xInd = 0;
+ move16();
+ }
+ ELSE
+ {
+ xInd = 1;
+ move16();
+ }
move16();
peakMag[0] = x[xInd];
move32();
@@ -546,7 +581,7 @@ void stereo_dft_res_subst_spec_fx(
FOR( i = 1; i < L_res; i++ )
{
Word32 r = L_shl( p_mem[2 * i], q_res );
- Word32 l = L_shl( p_mem[2 * i + 1], q_res );
+ Word32 l = L_shl( p_mem[add( shl( i, 1 ), 1 )], q_res );
abs_res[i] = Madd_32_32( Mpy_32_32( r, r ), l, l );
move32();
}
@@ -582,11 +617,11 @@ void stereo_dft_res_subst_spec_fx(
FOR( i = 1; i < L_res; i++ )
{
s1 = sign_l( pDFT_RES[2 * i] );
- s2 = sign_l( pDFT_RES[2 * i + 1] );
+ s2 = sign_l( pDFT_RES[add( shl( i, 1 ), 1 )] );
abs1 = L_abs( pDFT_RES[2 * i] );
- abs2 = L_abs( pDFT_RES[2 * i + 1] );
+ abs2 = L_abs( pDFT_RES[add( shl( i, 1 ), 1 )] );
abs3 = L_abs( p_mem[2 * i] );
- abs4 = L_abs( p_mem[2 * i + 1] );
+ abs4 = L_abs( p_mem[add( shl( i, 1 ), 1 )] );
// fac = MAX_16;
move16();
@@ -598,14 +633,14 @@ void stereo_dft_res_subst_spec_fx(
{
pDFT_RES[2 * i] = Mpy_32_32( s1, abs4 );
move32();
- pDFT_RES[2 * i + 1] = Mpy_32_32( s2, abs3 );
+ pDFT_RES[add( shl( i, 1 ), 1 )] = Mpy_32_32( s2, abs3 );
move32();
}
ELSE
{
pDFT_RES[2 * i] = Mpy_32_32( s1, abs3 );
move32();
- pDFT_RES[2 * i + 1] = Mpy_32_32( s2, abs4 );
+ pDFT_RES[add( shl( i, 1 ), 1 )] = Mpy_32_32( s2, abs4 );
move32();
}
}
@@ -658,14 +693,14 @@ void stereo_dft_res_subst_spec_fx(
cos_F = shl_o( getCosWord16( extract_l( corr_phase ) ), 1, &flg_ov );
sin_F = getSinWord16( extract_l( corr_phase ) );
- idx = s_max( 0, plocs[i] - Np ); /* Iterate over plocs[i]-1:plocs[i]+1, considering the edges of the spectrum */
+ idx = s_max( 0, sub( plocs[i], Np ) ); /* Iterate over plocs[i]-1:plocs[i]+1, considering the edges of the spectrum */
WHILE( ( idx < add( add( plocs[i], Np ), 1 ) ) && LT_16( idx, L_res ) )
{
- pDFT_RES[2 * idx] = Msub_32_16( Mpy_32_16_1( p_mem[2 * idx], cos_F ), p_mem[2 * idx + 1], sin_F );
+ pDFT_RES[2 * idx] = Msub_32_16( Mpy_32_16_1( p_mem[2 * idx], cos_F ), p_mem[add( shl( idx, 1 ), 1 )], sin_F );
move32();
- pDFT_RES[2 * idx + 1] = Mpy_32_32( conj_sign, Madd_32_16( Mpy_32_16_1( p_mem[2 * idx], sin_F ), p_mem[2 * idx + 1], cos_F ) );
+ pDFT_RES[add( shl( idx, 1 ), 1 )] = Mpy_32_32( conj_sign, Madd_32_16( Mpy_32_16_1( p_mem[2 * idx], sin_F ), p_mem[add( shl( idx, 1 ), 1 )], cos_F ) );
move32();
- idx++;
+ idx = add( idx, 1 );
}
}
return;
@@ -696,7 +731,7 @@ void stereo_dft_res_ecu_burst_att_fx(
move16();
/* attenuation of residual; follow attenuation of DMX */
- IF( EQ_16( hStereoDft->core_hist[0], ACELP_CORE ) )
+ IF( hStereoDft->core_hist[0] == ACELP_CORE )
{
fac = Mpy_32_16_1( Sqrt32( L_deposit_h( BASOP_Util_Divide3232_Scale( dmx_nrg, hStereoDft->past_dmx_nrg_fx, &q_fac ) ), &exponent ), (Word16) ( 0x0CCD ) );
}
@@ -724,13 +759,13 @@ Word32 stereo_dft_dmx_swb_nrg_fx(
const Word16 q0,
const Word16 q1 )
{
- int16_t i;
+ Word16 i;
Word32 dmx_nrg;
dmx_nrg = EPSILON_FIX;
move32();
test();
- IF( EQ_16( q0, 0 ) && EQ_16( q1, 0 ) )
+ IF( q0 == 0 && q1 == 0 )
{
FOR( i = 0; i < shr( frame_length, 1 ); i++ )
{
diff --git a/lib_dec/ivas_stereo_eclvq_dec.c b/lib_dec/ivas_stereo_eclvq_dec.c
index 4094ced1ae04ffbca7aff1efcade89b2019d1ccd..eb43309924b8253cf4f2d17a98254b3b7429797a 100644
--- a/lib_dec/ivas_stereo_eclvq_dec.c
+++ b/lib_dec/ivas_stereo_eclvq_dec.c
@@ -89,22 +89,24 @@ static Word16 arith_decode_elias_mod(
Word16 n, n_bits, bit;
n_bits = 0;
+ move16();
bit = rc_uni_dec_read_bit( rc_st_dec );
- WHILE( EQ_16( bit, 0 ) )
+ WHILE( bit == 0 )
{
bit = rc_uni_dec_read_bit( rc_st_dec );
- ++n_bits;
+ n_bits = add( n_bits, 1 );
IF( EQ_16( n_bits, 17 ) )
{
/* bitstream error encountered */
rc_st_dec->bit_error_detected = 1;
+ move16();
return 0;
}
}
- IF( EQ_16( n_bits, 0 ) )
+ IF( n_bits == 0 )
{
/* code for 0 is 10 and code for 1 is 11 */
n = rc_uni_dec_read_bit( rc_st_dec );
@@ -316,9 +318,9 @@ void ECSQ_decode(
{
sym = arith_decode_prob_escape( rc_st_dec, tab_vals_cum_freq, tab_vals_sym_freq, ECSQ_TAB_VALS_SIZE );
- IF( NE_16( shift, 0 ) )
+ IF( shift != 0 )
{
- IF( GT_16( sym, 0 ) || GT_16( shift, 4 ) )
+ IF( ( sym > 0 ) || ( shift > 4 ) )
{
lsbs = rc_uni_dec_read_bits( rc_st_dec, shift );
}
@@ -329,7 +331,7 @@ void ECSQ_decode(
sym = s_or( shl( sym, shift ), lsbs );
}
- IF( NE_16( sym, 0 ) )
+ IF( sym != 0 )
{
/* map the sign bit to +1 or -1 and then multiply */
IF( rc_uni_dec_read_bit( rc_st_dec ) )
@@ -339,6 +341,7 @@ void ECSQ_decode(
}
output[i] = sym;
+ move16();
}
}
ELSE
@@ -347,17 +350,20 @@ void ECSQ_decode(
nonzero = rc_uni_dec_read_bits( rc_st_dec, 2 );
left1 = nonzero;
+ move16();
left0 = sub( add( sub( seg_stop, seg_start ), 1 ), nonzero );
FOR( i = seg_start; i <= seg_stop; ++i )
{
- IF( EQ_16( left1, 0 ) )
+ IF( left1 == 0 )
{
sym = 0;
+ move16();
}
- ELSE IF( EQ_16( left0, 0 ) )
+ ELSE IF( left0 == 0 )
{
sym = 1;
+ move16();
}
ELSE
{
@@ -365,21 +371,22 @@ void ECSQ_decode(
sym = rc_uni_dec_read_bit_prob_fast( rc_st_dec, count0, ECSQ_PROB_BITS );
}
- IF( NE_16( sym, 0 ) )
+ IF( sym != 0 )
{
/* map the sign bit to +1 or -1 and then multiply */
IF( rc_uni_dec_read_bit( rc_st_dec ) )
{
sym = negate( sym );
}
- --left1;
+ left1 = sub( left1, 1 );
}
ELSE
{
- --left0;
+ left0 = sub( left0, 1 );
}
output[i] = sym;
+ move16();
}
}
}
diff --git a/lib_dec/ivas_stereo_ica_dec.c b/lib_dec/ivas_stereo_ica_dec.c
index 804a5a68f660f82f496a0c8e5a5a22229ed77027..e96f22c03dee22d9fbeec2842ad8a3de81c12cc3 100644
--- a/lib_dec/ivas_stereo_ica_dec.c
+++ b/lib_dec/ivas_stereo_ica_dec.c
@@ -41,7 +41,7 @@
#include "wmc_auto.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#include "basop32.h"
#include "ivas_stat_dec.h"
@@ -142,7 +142,16 @@ void stereo_tca_dec_fx(
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
hStereoTCA->corrLagStats = extract_l( L_abs( L_shr( hCPE->hStereoDft->itd_fx[1], Q15 ) ) );
- hStereoTCA->refChanIndx = GE_32( hCPE->hStereoDft->itd_fx[1], 0 ) ? ( L_CH_INDX ) : ( R_CH_INDX );
+ // hStereoTCA->refChanIndx = GE_32( hCPE->hStereoDft->itd_fx[1], 0 ) ? ( L_CH_INDX ) : ( R_CH_INDX );
+ IF( hCPE->hStereoDft->itd_fx[1] >= 0 )
+ {
+ hStereoTCA->refChanIndx = ( L_CH_INDX );
+ }
+ ELSE
+ {
+ hStereoTCA->refChanIndx = ( R_CH_INDX );
+ }
+ move16();
move16();
}
ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
@@ -152,12 +161,20 @@ void stereo_tca_dec_fx(
itd = hCPE->hStereoMdct->itd_fx;
move32();
hStereoTCA->corrLagStats = extract_l( L_abs( L_shr( itd, Q15 ) ) );
- hStereoTCA->refChanIndx = GE_32( itd, 0 ) ? ( L_CH_INDX ) : ( R_CH_INDX );
+ // hStereoTCA->refChanIndx = GE_32( itd, 0 ) ? ( L_CH_INDX ) : ( R_CH_INDX );
+ IF( GE_32( itd, 0 ) )
+ {
+ hStereoTCA->refChanIndx = ( L_CH_INDX );
+ }
+ ELSE
+ {
+ hStereoTCA->refChanIndx = ( R_CH_INDX );
+ }
move16();
}
test();
- IF( NE_16( hStereoTCA->refChanIndx, hStereoTCA->prevRefChanIndx ) && NE_16( hStereoTCA->corrLagStats, 0 ) )
+ IF( NE_16( hStereoTCA->refChanIndx, hStereoTCA->prevRefChanIndx ) && ( hStereoTCA->corrLagStats != 0 ) )
{
bothChannelShift = 1;
move16();
@@ -182,7 +199,7 @@ void stereo_tca_dec_fx(
move16();
}
- IF( NE_16( currentNCShift, 0 ) )
+ IF( currentNCShift != 0 )
{
currentNCShift = add( mult( 19660 /* 0.6 in Q15 */, prevNCShift ), mult( 13106 /* 0.4 in Q15 */, currentNCShift ) );
}
@@ -207,8 +224,7 @@ void stereo_tca_dec_fx(
/* identify target signal to adjust for shift variations */
test();
test();
- test();
- IF( ( EQ_16( prevNCShift, 0 ) && EQ_16( hStereoTCA->refChanIndx, R_CH_INDX ) ) || EQ_16( hStereoTCA->prevRefChanIndx, R_CH_INDX ) )
+ IF( ( ( prevNCShift == 0 ) && EQ_16( hStereoTCA->refChanIndx, R_CH_INDX ) ) || EQ_16( hStereoTCA->prevRefChanIndx, R_CH_INDX ) )
{
ref_fx = ptrChanR_fx;
target_fx = ptrChanL_fx;
@@ -645,8 +661,9 @@ void stereo_tca_scale_R_channel_fx(
{
Word16 temp_a = (Word16) L_shr( hCPE->hStereoDftDmx->targetGain_fx, (Word16) 16 );
Word16 temp_a_q = 2;
+ move16();
tempF1_fx = Inv16( temp_a, &temp_a_q );
- tempF1_fx = L_shl( tempF1_fx, ( 31 - 4 ) - ( 15 - temp_a_q ) );
+ tempF1_fx = L_shl( tempF1_fx, sub( ( 31 - 4 ), sub( 15, temp_a_q ) ) );
}
IF( EQ_32( hCPE->hStereoDftDmx->prevTargetGain_fx, ONE_IN_Q29 ) )
@@ -658,8 +675,9 @@ void stereo_tca_scale_R_channel_fx(
{
Word16 temp_b = (Word16) L_shr( hCPE->hStereoDftDmx->prevTargetGain_fx, 16 );
Word16 temp_b_q = 2;
+ move16();
tempF_fx = Inv16( temp_b, &temp_b_q );
- tempF_fx = L_shl( tempF_fx, ( 31 - 4 ) - ( 15 - temp_b_q ) );
+ tempF_fx = L_shl( tempF_fx, sub( ( 31 - 4 ), sub( 15, temp_b_q ) ) );
}
}
ELSE
@@ -674,8 +692,9 @@ void stereo_tca_scale_R_channel_fx(
{
Word16 temp_a = (Word16) L_shr( hStereoTCA->targetGain_fx, (Word16) 16 );
Word16 temp_a_q = 2;
+ move16();
tempF1_fx = Inv16( temp_a, &temp_a_q );
- tempF1_fx = L_shl( tempF1_fx, ( 31 - 4 ) - ( 15 - temp_a_q ) );
+ tempF1_fx = L_shl( tempF1_fx, sub( ( 31 - 4 ), sub( 15, temp_a_q ) ) );
}
@@ -688,8 +707,9 @@ void stereo_tca_scale_R_channel_fx(
{
Word16 temp_b = (Word16) L_shr( hStereoTCA->prevTargetGain_fx, (Word16) 16 );
Word16 temp_b_q = 2;
+ move16();
tempF_fx = Inv16( temp_b, &temp_b_q );
- tempF_fx = L_shl( tempF_fx, ( 31 - 4 ) - ( 15 - temp_b_q ) );
+ tempF_fx = L_shl( tempF_fx, sub( ( 31 - 4 ), sub( 15, temp_b_q ) ) );
}
}
SWITCH( output_Fs )
@@ -734,7 +754,7 @@ void stereo_tca_scale_R_channel_fx(
Word32 slope_gain_ascend = ( j * winSlope_fx );
Word32 left_res = Mpy_32_32( slope_gain_decend, output_fx[i_fx] );
Word32 right_res = Mpy_32_32( slope_gain_ascend, output_fx[i_fx] );
- output_fx[i_fx] = left_res + right_res;
+ output_fx[i_fx] = L_add( left_res, right_res );
move32();
}
}
@@ -743,7 +763,7 @@ void stereo_tca_scale_R_channel_fx(
FOR( j = 0; i_fx < flat_old + l_ica_ovl; ( i_fx++, j++ ) )
{
Word32 slope_gain_decend = L_sub( ONE_IN_Q31, j * winSlope_fx );
- Word32 slope_gain_ascend = ( j * winSlope_fx );
+ Word32 slope_gain_ascend = imult3216( winSlope_fx, j );
Word32 left_res = Mpy_32_32( slope_gain_decend, output_fx[i_fx] );
Word32 right_res = Mpy_32_32( slope_gain_ascend, output_fx[i_fx] );
output_fx[i_fx] = L_add_sat( L_shl_sat( Mpy_32_32( tempF_fx, left_res ), 4 ), L_shl_sat( Mpy_32_32( right_res, tempF1_fx ), 4 ) );
diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c
index 199647063d914fd381e9a33902af09fdf232a3b3..95d43ad4816d120ba38d701f8ccdd8e2df75ecee 100644
--- a/lib_dec/ivas_stereo_icbwe_dec.c
+++ b/lib_dec/ivas_stereo_icbwe_dec.c
@@ -37,13 +37,15 @@
#include "cnst.h"
#include "ivas_cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "wmc_auto.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
#define Q_icBWE 16
@@ -538,7 +540,7 @@ static Word16 FindScale(
maximum_abs_32_fx( buff, len, &maxVal );
norm_shift = norm_l( maxVal );
- IF( EQ_32( maxVal, 0 ) )
+ if ( maxVal == 0 )
{
norm_shift = 31;
move16();
@@ -628,14 +630,14 @@ void stereo_icBWE_dec_fx(
move32();
maximum_abs_32_fx( synthRef_fx, output_frame, &maxVal );
synthRef_shift = norm_l( maxVal );
- IF( EQ_32( maxVal, 0 ) )
+ if ( maxVal == 0 )
{
synthRef_shift = 31;
move16();
}
synthRef_shift = sub( synthRef_shift, shr( add( find_guarded_bits_fx( output_frame ), 1 ), 1 ) );
test();
- IF( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->last_core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE || st->last_core == ACELP_CORE )
{
FOR( i = 0; i < output_frame / 2; i++ )
{
@@ -670,7 +672,9 @@ void stereo_icBWE_dec_fx(
set32_fx( hCPE->hStereoDft->hb_stefi_sig_fx + hCPE->hStereoDft->hb_stefi_delay, 0, output_frame );
#ifdef MSAN_FIX
hCPE->hStereoDft->hb_nrg_subr_fx[0] = 0;
+ move32();
hCPE->hStereoDft->hb_nrg_subr_fx[1] = 0;
+ move32();
#endif // MSAN_FIX
}
hCPE->hStereoDft->hb_nrg_subr_fx[0] = ( Mpy_32_16_1( hCPE->hStereoDft->hb_nrg_subr_fx[0], shl( hCPE->hStereoDft->NFFT / 2, 6 ) ) ); // 2 * (Qx + SynthRef_shift) - 40 // 2 * (Qx + SynthRef_shift) - 31 - 15
@@ -693,7 +697,7 @@ void stereo_icBWE_dec_fx(
test();
test();
test();
- IF( NE_16( st->core, ACELP_CORE ) || EQ_16( st->extl, -1 ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( hCPE->hCoreCoder[0]->tdm_LRTD_flag, 0 ) ) )
+ IF( st->core != ACELP_CORE || EQ_16( st->extl, -1 ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( hCPE->hCoreCoder[0]->tdm_LRTD_flag, 0 ) ) )
{
return;
}
@@ -708,11 +712,11 @@ void stereo_icBWE_dec_fx(
/* core switching reset */
test();
- IF( NE_16( st->last_core, ACELP_CORE ) || EQ_16( st->bwidth, (Word16) WB ) )
+ IF( st->last_core != ACELP_CORE || EQ_16( st->bwidth, (Word16) WB ) )
{
ic_bwe_dec_reset_fx( hStereoICBWE );
- IF( NE_16( st->last_core, ACELP_CORE ) )
+ IF( st->last_core != ACELP_CORE )
{
hStereoICBWE->prevSpecMapping_fx = 0;
move16();
@@ -789,7 +793,7 @@ void stereo_icBWE_dec_fx(
}
}
- IF( EQ_16( st->bfi, 0 ) )
+ IF( st->bfi == 0 )
{
hStereoICBWE->refChanIndx_bwe = get_next_indice_fx( st, STEREO_ICBWE_REFBITS );
IF( EQ_16( st->flag_ACELP16k, 1 ) )
@@ -876,7 +880,7 @@ void stereo_icBWE_dec_fx(
}
// nbSubFr = ( st->flag_ACELP16k == 0 ) ? NB_SUBFR : NB_SUBFR16k;
- IF( EQ_16( st->flag_ACELP16k, 0 ) )
+ IF( st->flag_ACELP16k == 0 )
{
nbSubFr = NB_SUBFR;
move16();
@@ -920,11 +924,11 @@ void stereo_icBWE_dec_fx(
// common Q for addition
L_nlExc16k = L_deposit_l( hStereoICBWE->nlExc16k_fx[k] ); // prev_q_bwe_exc - 16
L_mixExc16k = L_deposit_l( hStereoICBWE->mixExc16k_fx[k] ); // Q_exc
- L_nlExc16k = L_shl( L_nlExc16k, Q_icBWE - ( st->prev_Q_bwe_exc - 16 ) ); // Q_icBWE
+ L_nlExc16k = L_shl( L_nlExc16k, sub( Q_icBWE, ( sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // Q_icBWE
#ifndef FIX_736_BWE_SECT_C
L_mixExc16k = L_shl( L_mixExc16k, Q_icBWE - st->Q_exc ); // Q_icBWE
#else
- L_mixExc16k = L_shl( L_mixExc16k, Q_icBWE - ( st->prev_Q_bwe_exc - 25 ) ); // Q_icBWE
+ L_mixExc16k = L_shl( L_mixExc16k, sub( Q_icBWE, ( sub( st->prev_Q_bwe_exc, 25 ) ) ) ); // Q_icBWE
#endif
excSHB_nonref_fx[k] = L_add( Mpy_32_16_1( L_nlExc16k, temp1_fx ), Mpy_32_16_1( L_mixExc16k, temp2_fx ) ); // Q_icBWE
move32();
@@ -1043,7 +1047,7 @@ void stereo_icBWE_dec_fx(
tmp = sub( tmp, 9 );
Scale_sig32( shb_synth_nonref_fx, L_FRAME16k + L_SHB_LAHEAD, tmp - Q_syn_shb );
- hStereoICBWE->memShbSpecMapping_fx = L_shl( hStereoICBWE->memShbSpecMapping_fx, tmp - hStereoICBWE->prev_Q_memshbspec );
+ hStereoICBWE->memShbSpecMapping_fx = L_shl( hStereoICBWE->memShbSpecMapping_fx, sub( tmp, hStereoICBWE->prev_Q_memshbspec ) );
hStereoICBWE->prev_Q_memshbspec = tmp;
move16();
@@ -1126,7 +1130,7 @@ void stereo_icBWE_dec_fx(
icbweM2Ref_fx = gsMapping_fx;
move16();
- IF( EQ_16( hStereoICBWE->refChanIndx_bwe, L_CH_INDX ) )
+ IF( hStereoICBWE->refChanIndx_bwe == L_CH_INDX )
{
IF( GE_16( ratio_L_fx, 3276 ) )
@@ -1159,7 +1163,7 @@ void stereo_icBWE_dec_fx(
#ifdef FIX_TMP_714
tmp = mult_r( ratio_L_fx, ratio_L_fx ); // Q15
#else
- tmp = mult_r( sub( 32767, ratio_L_fx ), sub( 32767, ratio_L_fx ) ); // Q15
+ tmp = mult_r( sub( 32767, ratio_L_fx ), sub( 32767, ratio_L_fx ) ); // Q15
#endif
tmp = mult_r( tmp, gsMapping_fx ); // Q14
tmp = mult_r( tmp, gsMapping_fx ); // Q13
@@ -1290,7 +1294,7 @@ void stereo_icBWE_dec_fx(
icbweM2Ref_fx = gsMapping_fx;
move16();
- IF( EQ_16( hStereoICBWE->refChanIndx_bwe, L_CH_INDX ) )
+ IF( hStereoICBWE->refChanIndx_bwe == L_CH_INDX )
{
IF( GE_16( ratio_L_fx, 3276 ) )
{
@@ -1680,6 +1684,7 @@ void stereo_icBWE_decproc_fx(
Word32 temp0_fx[L_FRAME48k + NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )], temp1_fx[L_FRAME48k + NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )];
Word32 winSlope_fx = 0, alpha_fx;
+ move32();
const Word16 *win_dft_fx;
Word32 extl_brate, output_Fs;
@@ -1789,7 +1794,7 @@ void stereo_icBWE_decproc_fx(
}
test();
- IF( EQ_16( core, ACELP_CORE ) && GT_32( extl_brate, 0 ) )
+ IF( EQ_16( core, ACELP_CORE ) && extl_brate > 0 )
{
refChanIndx_bwe = hStereoICBWE->refChanIndx_bwe;
move16();
@@ -1833,13 +1838,13 @@ void stereo_icBWE_decproc_fx(
}
}
/* Resampled LB and HB offset */
- Copy32( outputHB[refChanIndx_bwe], temp0_fx + memOffset, output_frame - memOffset );
- Copy32( outputHB[!refChanIndx_bwe], temp1_fx + memOffset, output_frame - memOffset );
+ Copy32( outputHB[refChanIndx_bwe], temp0_fx + memOffset, sub( output_frame, memOffset ) );
+ Copy32( outputHB[!refChanIndx_bwe], temp1_fx + memOffset, sub( output_frame, memOffset ) );
decoderDelay = NS2SA( output_Fs, IVAS_DEC_DELAY_NS );
test();
- IF( NE_16( last_core, ACELP_CORE ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
+ IF( last_core != ACELP_CORE && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
/* hb_synth of mid band is faded out in the 1.25 ms prior to DFT analysis and the icbwe is faded in time domain */
icbweOLASize = NS2SA( output_Fs, STEREO_DFT_DELAY_DEC_BWE_NS );
@@ -1870,7 +1875,7 @@ void stereo_icBWE_decproc_fx(
}
alpha_fx = winSlope_fx; // Q30
move32();
- FOR( ; i < decoderDelay + icbweOLASize; i++ )
+ FOR( ; i < add( decoderDelay, icbweOLASize ); i++ )
{
temp0_fx[i] = L_shl_sat( Mpy_32_32( temp0_fx[i], alpha_fx ), 1 ); // Q11
move32();
@@ -1883,18 +1888,21 @@ void stereo_icBWE_decproc_fx(
{
IF( NE_16( refChanIndx_bwe, hStereoICBWE->prev_refChanIndx_bwe ) )
{
- IF( GT_16( memOffset, 0 ) )
+ IF( memOffset > 0 )
{
SWITCH( memOffset )
{
case 15:
winSlope_fx = 71582792;
+ move32();
BREAK;
case 30:
winSlope_fx = 35791396;
+ move32();
BREAK;
case 45:
winSlope_fx = 23860930; // Q30
+ move32();
BREAK;
}
// memOffset for 16K 32K 48K are 15 30 45 respectively.camera
@@ -1961,7 +1969,7 @@ void stereo_icBWE_decproc_fx(
move32();
hStereoICBWE->memTransitionHB_fx[1][i] = Mpy_32_16_1( hStereoICBWE->memOutHB_fx[1][i], win_dft_fx[tmp_mul] );
move32();
- j++;
+ j = add( j, 1 );
}
FOR( i = 0; j < dftOvlLen; i++ )
@@ -1971,7 +1979,7 @@ void stereo_icBWE_decproc_fx(
move32();
hStereoICBWE->memTransitionHB_fx[1][memOffset + i] = Mpy_32_16_1( outputHB[1][output_frame - i - 1], win_dft_fx[tmp_mul] );
move32();
- j++;
+ j = add( j, 1 );
}
}
@@ -1980,7 +1988,7 @@ void stereo_icBWE_decproc_fx(
}
ELSE
{
- IF( EQ_16( last_core, ACELP_CORE ) )
+ IF( last_core == ACELP_CORE )
{
IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c
index 3248c93237194e8d8551dd7e54d785a44244e733..273a4c097f429cd67f9f024e2159d370343b8980 100644
--- a/lib_dec/ivas_stereo_mdct_core_dec.c
+++ b/lib_dec/ivas_stereo_mdct_core_dec.c
@@ -40,23 +40,17 @@
#include "ivas_prot.h"
#include "ivas_stat_dec.h"
#include "wmc_auto.h"
-#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
-#include "ivas_prot_fx.h"
-#endif // IVAS_FLOAT_FIXED
+#ifndef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------------
* Local function prototypes
*-------------------------------------------------------------------------*/
-#ifndef IVAS_FLOAT_FIXED
static void apply_dmx_weights( CPE_DEC_HANDLE hCPE, float *x[CPE_CHANNELS][NB_DIV], int16_t transform_type_left[NB_DIV], int16_t transform_type_right[NB_DIV] );
-#endif
-#ifndef IVAS_FLOAT_FIXED
static void run_min_stats( Decoder_State **sts, float *x[CPE_CHANNELS][NB_DIV] );
-#endif
+
/*-------------------------------------------------------------------*
* convert_coeffs_to_higher_res()
@@ -65,47 +59,6 @@ static void run_min_stats( Decoder_State **sts, float *x[CPE_CHANNELS][NB_DIV] )
* by applying high- and lowpass filters to subdivide bins
*-------------------------------------------------------------------*/
-#ifdef IVAS_FLOAT_FIXED
-#define POINT_5_Q31 ONE_IN_Q30
-
-void convert_coeffs_to_higher_res_fx(
- const Word32 *in1, /* i : first subframe input */
- const Word32 *in2, /* i : second subframe input */
- Word32 *out, /* o : converted output */
- const Word16 len /* i : length of subframes */
-)
-{
- Word16 i;
- Word32 tmp1, tmp2;
-
- IF( in1 == out )
- {
- FOR( i = 0; i < len; i += 2 )
- {
- tmp1 = Mpy_32_32( POINT_5_Q31, ( L_add( in2[i], in1[i] ) ) );
- tmp2 = Mpy_32_32( POINT_5_Q31, ( L_sub( in2[i], in1[i] ) ) );
- out[2 * i] = tmp1;
- out[2 * i + 1] = tmp2;
- tmp1 = Mpy_32_32( POINT_5_Q31, ( L_sub( in2[i], in1[i] ) ) );
- tmp2 = Mpy_32_32( POINT_5_Q31, ( L_add( in2[i], in1[i] ) ) );
- out[2 * i + 2] = tmp1;
- out[2 * i + 3] = tmp2;
- }
- }
- ELSE
- {
- FOR( i = 0; i < len; i += 2 )
- {
- out[2 * i] = Mpy_32_32( POINT_5_Q31, ( L_add( in2[i], in1[i] ) ) );
- out[2 * i + 1] = Mpy_32_32( POINT_5_Q31, ( L_sub( in2[i], in1[i] ) ) );
- out[2 * i + 2] = Mpy_32_32( POINT_5_Q31, ( L_sub( in2[i + 1], in1[i + 1] ) ) );
- out[2 * i + 3] = Mpy_32_32( POINT_5_Q31, ( L_add( in2[i + 1], in1[i + 1] ) ) );
- }
- }
-
- return;
-}
-#endif
void convert_coeffs_to_higher_res(
const float *in1, /* i : first subframe input */
const float *in2, /* i : second subframe input */
@@ -151,7 +104,6 @@ void convert_coeffs_to_higher_res(
* decode core and MDCT stereo information
*-------------------------------------------------------------------*/
-#ifndef IVAS_FLOAT_FIXED
static void stereo_mdct_dec_stereo(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
int16_t ms_mask[2][MAX_SFB] /* o : bandwise MS mask */
@@ -176,9 +128,8 @@ static void stereo_mdct_dec_stereo(
return;
}
-#endif
-#ifndef IVAS_FLOAT_FIXED
+
/*-------------------------------------------------------------------*
* stereo_mdct_core_dec()
*
@@ -200,11 +151,6 @@ void stereo_mdct_core_dec(
int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW];
float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )];
-#ifdef IVAS_FLOAT_FIXED
- /* NOTE: temporary fix to avoid garbage values while calculating its
- q-factor when not initialised. */
- set_zero( (float *) Aq, CPE_CHANNELS * ( NB_SUBFR16k + 1 ) * ( M + 1 ) );
-#endif
float *x[CPE_CHANNELS][NB_DIV];
/*needed to allocate N_MAX to prevent stereo switching crash */
@@ -232,11 +178,6 @@ void stereo_mdct_core_dec(
int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV];
float signal_outFB_tmp[CPE_CHANNELS][L_FRAME_PLUS];
float signal_out_tmp[CPE_CHANNELS][L_FRAME_PLUS];
-#ifdef IVAS_FLOAT_FIXED
- Word32 signal_out_tmp_fx[CPE_CHANNELS][L_FRAME_PLUS];
- Word32 *x_fx[CPE_CHANNELS][NB_DIV];
-#endif
-
push_wmops( "stereo_mdct_core_dec" );
/*--------------------------------------------------------------------------------*
@@ -252,26 +193,12 @@ void stereo_mdct_core_dec(
for ( ch = 0; ch < nChannels; ch++ )
{
/* Initialization or re-configuration of Stereo TCX */
-#ifdef IVAS_FLOAT_FIXED
- /* stereo_tcx_dec_mode_switch_reconf_To_fixed is for intermediatery conversions which is needed to be removed */
- stereo_tcx_dec_mode_switch_reconf_To_fixed( sts[ch], 1, hCPE->last_element_mode );
- /*============*/
- stereo_tcx_init_dec_fx( sts[ch], 0, hCPE->last_element_mode );
- /*============*/
- stereo_tcx_dec_mode_switch_reconf_To_fixed( sts[ch], 0, hCPE->last_element_mode );
-#else
stereo_tcx_init_dec( sts[ch], 0, hCPE->last_element_mode );
-#endif // IVAS_FLOAT_FIXED
sts[ch]->hTcxDec->tnsActive[0] = sts[ch]->hTcxDec->tnsActive[1] = 0;
sts[ch]->enablePlcWaveadjust = 0;
set_zero( signal_out_tmp[ch], L_FRAME_PLUS );
x[ch][0] = &signal_out_tmp[ch][0];
x[ch][1] = &signal_out_tmp[ch][0] + L_FRAME_PLUS / 2;
-#ifdef IVAS_FLOAT_FIXED
- set32_fx( signal_out_tmp_fx[ch], 0, L_FRAME_PLUS );
- x_fx[ch][0] = &signal_out_tmp_fx[ch][0];
- x_fx[ch][1] = &signal_out_tmp_fx[ch][0] + L_FRAME_PLUS / 2;
-#endif
set_zero( x_0_buf[ch], N_MAX );
x_0[ch][0] = &x_0_buf[ch][0];
@@ -389,38 +316,11 @@ void stereo_mdct_core_dec(
{
float sns_int_scf[FDNS_NPTS];
-#ifdef IVAS_FLOAT_FIXED
- Word32 sns_int_scf_fx[FDNS_NPTS], Aq_fx[SNS_NPTS];
- FOR( int c = 0; c < SNS_NPTS; c++ )
- {
- Aq_fx[c] = (Word32) ( Aq[ch][k * M + c] * ONE_IN_Q16 );
- }
-
- sns_interpolate_scalefactors_fx( sns_int_scf_fx, Aq_fx, DEC );
-
- FOR( int c = 0; c < FDNS_NPTS; c++ )
- {
- sns_int_scf[c] = ( (float) sns_int_scf_fx[c] / ONE_IN_Q16 );
- }
-#else
sns_interpolate_scalefactors( &sns_int_scf[0], &Aq[ch][k * M], DEC );
-#endif // IVAS_FLOAT_FIXED
if ( st->hTonalMDCTConc != NULL && ( ( k + 1 ) == nSubframes[ch] ) )
{
-#ifdef IVAS_FLOAT_FIXED
- Word32 x_fx_[N_MAX];
- Word16 x_e, scf_fx[FDNS_NPTS], scf_e[FDNS_NPTS];
- f2me_buf( x[ch][k], x_fx_, &x_e, L_frameTCX[ch] );
- for ( int j = 0; j < st->hTonalMDCTConc->nScaleFactors; j++ )
- {
- f2me_16( sns_int_scf[j], &scf_fx[j], &scf_e[j] );
- }
- TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x_fx_, x_e, L_frameTCX[ch], L_frame[ch], &scf_fx[0], scf_e, 0, get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) );
- // st->hTonalMDCTConc->last_block_nrg_flt = me2f( st->hTonalMDCTConc->last_block_nrg, st->hTonalMDCTConc->last_block_nrg_exp );
-#else
TonalMDCTConceal_SaveFreqSignal_ivas( st->hTonalMDCTConc, x[ch][k], L_frameTCX[ch], L_frame[ch], &sns_int_scf[0], get_igf_startline_flt( st, L_frame[ch], L_frameTCX[ch] ) );
-#endif
}
}
@@ -436,41 +336,7 @@ void stereo_mdct_core_dec(
stereo_decoder_tcx( hCPE->hStereoMdct, ms_mask, x_0[1], x[0], x[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0 );
}
-#ifdef IVAS_FLOAT_FIXED1
- Word32 Aq_fx[2][102];
- Word16 x_e[2][2];
- FOR( Word16 ind = 0; ind < 2; ind++ )
- {
- FOR( Word16 ind2 = 0; ind2 < 102; ind2++ )
- {
- Aq_fx[ind][ind2] = (Word32) ( Aq[ind][ind2] * ( ONE_IN_Q16 ) );
- }
- FOR( Word16 ind2 = 0; ind2 < 2; ind2++ )
- {
- f2me_buf( x[ind][ind2], x_fx[ind][ind2], &x_e[ind][ind2], L_frameTCX[ind] );
- }
- }
- st->hTcxDec->cummulative_damping_tcx = (Word16) ( st->hTcxDec->cummulative_damping_tcx * ( ONE_IN_Q15 ) );
- FOR( Word16 ind = 0; ind < st->hTonalMDCTConc->nScaleFactors; ind++ )
- {
- f2me_16( st->hTonalMDCTConc->lastBlockData.scaleFactors_float[ind], &st->hTonalMDCTConc->lastBlockData.scaleFactors[ind], &st->hTonalMDCTConc->lastBlockData.scaleFactors_exp[ind] );
- }
- FOR( Word16 ind = 0; ind < st->hTonalMDCTConc->nScaleFactors; ind++ )
- {
- f2me_16( st->hTonalMDCTConc->lastBlockData.scaleFactors_float[ind], &st->hTonalMDCTConc->lastBlockData.scaleFactors[ind], &st->hTonalMDCTConc->lastBlockData.scaleFactors_exp[ind] );
- }
- FOR( Word16 i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ )
- {
- st->hTonalMDCTConc->scaleFactorsBackground[i] = float_to_fix16( st->hTonalMDCTConc->scaleFactorsBackground_flt[i], 15 );
- }
- st->hTonalMDCTConc->scf_fadeout = float_to_fix16( st->hTonalMDCTConc->scf_fadeout_flt, 15 );
- st->old_fpitch = float_to_fix( st->old_fpitch_float, 16 );
- st->hTcxDec->tcxltp_last_gain_unmodified = float_to_fix16( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 );
-
- ivas_mdct_core_tns_ns_fx( hCPE, fUseTns, tnsData, x_fx, Aq_fx, 0, x_e );
-#else
ivas_mdct_core_tns_ns( hCPE, fUseTns, tnsData, x, Aq, 0 );
-#endif
if ( st_ivas->renderer_type == RENDERER_MC_PARAMMC && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) )
{
@@ -763,10 +629,7 @@ static void run_min_stats(
noisy_speech_detection( st->hFdCngDec, st->VAD && st->m_frame_type == ACTIVE_FRAME, power_spec );
st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt = 0.99f * st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_flt + 0.01f * (float) st->hFdCngDec->hFdCngCom->flag_noisy_speech;
-#ifdef IVAS_FLOAT_FIXED
- st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx = L_add( Mpy_32_32( Q31_0_99, st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx ),
- st->hFdCngDec->hFdCngCom->flag_noisy_speech * Q31_0_01 );
-#endif
+
st->lp_noise_float = st->hFdCngDec->lp_noise_float;
}
diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c
index 37f8c7983b18f321e0a77a5332e333ba503351bf..48850cf1b224d0302ebf270cad475e9f7a9111ba 100644
--- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c
+++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c
@@ -41,33 +41,92 @@
#include "ivas_prot.h"
#include "ivas_stat_dec.h"
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
+
+/*---------------------------------------------------------------------*
+ * Local constants
+ *---------------------------------------------------------------------*/
+
+#define POINT_5_Q31 ONE_IN_Q30
+
+
/*-------------------------------------------------------------------------
* Local function prototypes
*-------------------------------------------------------------------------*/
static void apply_dmx_weights_fx( CPE_DEC_HANDLE hCPE, Word32 *x[CPE_CHANNELS][NB_DIV], int16_t transform_type_left[NB_DIV], int16_t transform_type_right[NB_DIV] );
-#ifndef IVAS_FLOAT_FIXED
-static void apply_dmx_weights( CPE_DEC_HANDLE hCPE, float *x[CPE_CHANNELS][NB_DIV], int16_t transform_type_left[NB_DIV], int16_t transform_type_right[NB_DIV] );
-#endif
static void run_min_stats_fx( Decoder_State **sts, Word32 *x[CPE_CHANNELS][NB_DIV], Word16 x_e[CPE_CHANNELS][NB_DIV] );
+
/*-------------------------------------------------------------------*
- * stereo_mdct_dec_stereo()
+ * convert_coeffs_to_higher_res_fx()
+ *
+ * convert MDCT coefficients to higher frequency resolution
+ * by applying high- and lowpass filters to subdivide bins
+ *-------------------------------------------------------------------*/
+
+void convert_coeffs_to_higher_res_fx(
+ const Word32 *in1, /* i : first subframe input */
+ const Word32 *in2, /* i : second subframe input */
+ Word32 *out, /* o : converted output */
+ const Word16 len /* i : length of subframes */
+)
+{
+ Word16 i;
+ Word32 tmp1, tmp2;
+
+ IF( in1 == out )
+ {
+ FOR( i = 0; i < len; i += 2 )
+ {
+ tmp1 = Mpy_32_32( POINT_5_Q31, ( L_add( in2[i], in1[i] ) ) );
+ tmp2 = Mpy_32_32( POINT_5_Q31, ( L_sub( in2[i], in1[i] ) ) );
+ out[2 * i] = tmp1;
+ move32();
+ out[2 * i + 1] = tmp2;
+ move32();
+ tmp1 = Mpy_32_32( POINT_5_Q31, ( L_sub( in2[i], in1[i] ) ) );
+ tmp2 = Mpy_32_32( POINT_5_Q31, ( L_add( in2[i], in1[i] ) ) );
+ out[2 * i + 2] = tmp1;
+ move32();
+ out[2 * i + 3] = tmp2;
+ move32();
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < len; i += 2 )
+ {
+ out[2 * i] = Mpy_32_32( POINT_5_Q31, ( L_add( in2[i], in1[i] ) ) );
+ move32();
+ out[2 * i + 1] = Mpy_32_32( POINT_5_Q31, ( L_sub( in2[i], in1[i] ) ) );
+ move32();
+ out[2 * i + 2] = Mpy_32_32( POINT_5_Q31, ( L_sub( in2[i + 1], in1[i + 1] ) ) );
+ move32();
+ out[2 * i + 3] = Mpy_32_32( POINT_5_Q31, ( L_add( in2[i + 1], in1[i + 1] ) ) );
+ move32();
+ }
+ }
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * stereo_mdct_dec_stereo_fx()
*
* decode core and MDCT stereo information
*-------------------------------------------------------------------*/
static void stereo_mdct_dec_stereo_fx(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- int16_t ms_mask[2][MAX_SFB] /* o : bandwise MS mask */
+ CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
+ Word16 ms_mask[2][MAX_SFB] /* o : bandwise MS mask */
)
{
- int16_t availableBits;
+ Word16 availableBits;
Decoder_State **sts;
sts = hCPE->hCoreCoder;
@@ -75,21 +134,23 @@ static void stereo_mdct_dec_stereo_fx(
parse_stereo_from_bitstream( hCPE->hStereoMdct, hCPE->hCoreCoder, 0, hCPE->hStereoMdct->isSBAStereoMode, hCPE->hCoreCoder[0], ms_mask );
/*Split available bits between channels */
- availableBits = sts[0]->bits_frame_channel + sts[1]->bits_frame_channel - sts[0]->next_bit_pos - sts[0]->core * ( NF_GAIN_BITS + SMDCT_MINIMUM_ARITH_BITS ) - sts[1]->core * ( NF_GAIN_BITS + SMDCT_MINIMUM_ARITH_BITS );
+ availableBits = sub( sub( sub( add( sts[0]->bits_frame_channel, sts[1]->bits_frame_channel ), sts[0]->next_bit_pos ), i_mult( sts[0]->core, ( NF_GAIN_BITS + SMDCT_MINIMUM_ARITH_BITS ) ) ), i_mult( sts[1]->core, ( NF_GAIN_BITS + SMDCT_MINIMUM_ARITH_BITS ) ) );
splitAvailableBits_fx( availableBits, hCPE->hStereoMdct->split_ratio, hCPE->hStereoMdct->isSBAStereoMode, &sts[0]->bits_frame_channel, &sts[1]->bits_frame_channel );
- sts[0]->bits_frame_channel += sts[0]->core * SMDCT_MINIMUM_ARITH_BITS;
- sts[1]->bits_frame_channel += sts[1]->core * SMDCT_MINIMUM_ARITH_BITS;
+ sts[0]->bits_frame_channel = add( sts[0]->bits_frame_channel, i_mult( sts[0]->core, SMDCT_MINIMUM_ARITH_BITS ) );
+ move16();
+ sts[1]->bits_frame_channel = add( sts[1]->bits_frame_channel, i_mult( sts[1]->core, SMDCT_MINIMUM_ARITH_BITS ) );
+ move16();
- sts[1]->bit_stream = &sts[0]->bit_stream[sts[0]->next_bit_pos + sts[0]->bits_frame_channel + sts[0]->core * NF_GAIN_BITS];
+ sts[1]->bit_stream = &sts[0]->bit_stream[add( add( sts[0]->next_bit_pos, sts[0]->bits_frame_channel ), i_mult( sts[0]->core, NF_GAIN_BITS ) )];
return;
}
/*-------------------------------------------------------------------*
- * stereo_mdct_core_dec()
+ * stereo_mdct_core_dec_fx()
*
* MDCT stereo core/stereo decoder
*--------------------------------------------------------------------*/
@@ -179,18 +240,18 @@ void stereo_mdct_core_dec_fx(
set_s( param_lpc[ch], 0, NPRM_LPC_NEW );
}
- set_s( ms_mask[0], 0, MAX_SFB );
- set_s( ms_mask[1], 0, MAX_SFB );
+ set16_fx( ms_mask[0], 0, MAX_SFB );
+ set16_fx( ms_mask[1], 0, MAX_SFB );
initMdctStereoDecData_fx( hCPE->hStereoMdct, sts[0]->igf, sts[0]->hIGFDec->igfData.igfInfo.grid, hCPE->element_brate, sts[0]->bwidth );
hCPE->hStereoMdct->isSBAStereoMode = ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && EQ_16( st_ivas->nchan_transport, 2 ) );
move16();
- IF( EQ_16( bfi, 0 ) )
+ IF( bfi == 0 )
{
ivas_mdct_dec_side_bits_frame_channel_fx( hCPE, param_lpc, p_param, hCPE->hCoreCoder[0], nTnsBitsTCX10, param, 0, 0 );
- IF( NE_16( sts[0]->igf, 0 ) )
+ IF( sts[0]->igf != 0 )
{
FOR( ch = 0; ch < nChannels; ch++ )
{
@@ -203,9 +264,11 @@ void stereo_mdct_core_dec_fx(
}
ELSE
{
- mvs2s( hCPE->hStereoMdct->prev_ms_mask[0], ms_mask[0], MAX_SFB );
- mvs2s( hCPE->hStereoMdct->prev_ms_mask[1], ms_mask[1], MAX_SFB );
+ Copy( hCPE->hStereoMdct->prev_ms_mask[0], ms_mask[0], MAX_SFB );
+ Copy( hCPE->hStereoMdct->prev_ms_mask[1], ms_mask[1], MAX_SFB );
+ test();
+ test();
IF( NE_16( sts[0]->core, TCX_10_CORE ) && NE_16( sts[1]->core, TCX_10_CORE ) )
{
hCPE->hStereoMdct->mdct_stereo_mode[1] = SMDCT_DUAL_MONO;
@@ -241,7 +304,17 @@ void stereo_mdct_core_dec_fx(
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- Word16 subFrames = ( hCPE->hCoreCoder[ch]->core == TCX_10_CORE ) ? NB_DIV : 1;
+ Word16 subFrames;
+ // Word16 subFrames = ( hCPE->hCoreCoder[ch]->core == TCX_10_CORE ) ? NB_DIV : 1;
+ IF( ( hCPE->hCoreCoder[ch]->core == TCX_10_CORE ) )
+ {
+ subFrames = NB_DIV;
+ }
+ ELSE
+ {
+ subFrames = 1;
+ }
+ move16();
FOR( k = 0; k < subFrames; ++k )
{
Scale_sig32( x_fx[ch][k], x_len[ch][k], sub( x_e[ch][k], 20 ) );
@@ -261,19 +334,23 @@ void stereo_mdct_core_dec_fx(
FOR( k = 0; k < nSubframes[ch]; k++ )
{
L_spec[ch] = idiv1616( sts[ch]->hTcxCfg->tcx_coded_lines, nSubframes[ch] );
+ move16();
init_tcx_info_fx( sts[ch], sts[ch]->L_frame / nSubframes[ch], sts[ch]->hTcxDec->L_frameTCX / nSubframes[ch], k, bfi, &tcx_offset[ch], &tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] );
}
}
/* IGF decoding */
- IF( NE_16( sts[0]->igf, 0 ) || NE_16( sts[1]->igf, 0 ) )
+ test();
+ IF( sts[0]->igf || sts[1]->igf )
{
IF( NE_16( sts[0]->core, sts[1]->core ) )
{
FOR( ch = 0; ch < nChannels; ch++ )
{
st = sts[ch];
+ test();
+ test();
IF( !bfi || ( bfi && NE_16( st->core, ACELP_CORE ) ) )
{
FOR( k = 0; k < nSubframes[ch]; k++ )
@@ -287,15 +364,17 @@ void stereo_mdct_core_dec_fx(
}
}
}
- ELSE IF( NE_16( sts[0]->core, ACELP_CORE ) )
+ ELSE IF( sts[0]->core != ACELP_CORE )
{
assert( EQ_16( nSubframes[0], nSubframes[1] ) );
FOR( k = 0; k < nSubframes[0]; k++ )
{
- IF( ( NE_16( hCPE->hStereoMdct->IGFStereoMode[k], SMDCT_DUAL_MONO ) || NE_16( hCPE->hStereoMdct->mdct_stereo_mode[k], SMDCT_DUAL_MONO ) ) && EQ_16( hCPE->hStereoMdct->isSBAStereoMode, 0 ) )
+ test();
+ test();
+ IF( ( NE_16( hCPE->hStereoMdct->IGFStereoMode[k], SMDCT_DUAL_MONO ) || NE_16( hCPE->hStereoMdct->mdct_stereo_mode[k], SMDCT_DUAL_MONO ) ) && hCPE->hStereoMdct->isSBAStereoMode == 0 )
{
- assert( ( EQ_16( sts[0]->core, sts[1]->core ) ) || ( EQ_16( hCPE->hStereoMdct->mdct_stereo_mode[0], SMDCT_DUAL_MONO ) ) );
+ assert( ( EQ_16( sts[0]->core, sts[1]->core ) ) || ( hCPE->hStereoMdct->mdct_stereo_mode[0] == SMDCT_DUAL_MONO ) );
/* stereo IGF decoding */
decoder_tcx_IGF_stereo_fx( sts, hCPE->hStereoMdct, ms_mask, x_fx, x_e, x_len, L_frame[0], left_rect[0], k, bfi, 0 /* MCT_flag */ );
@@ -331,19 +410,21 @@ void stereo_mdct_core_dec_fx(
* Stereo processing
*--------------------------------------------------------------------------------*/
- IF( EQ_16( bfi, 0 ) )
+ IF( !bfi )
{
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
Word32 sns_int_scf_fx[FDNS_NPTS];
Word16 scf_fx[FDNS_NPTS], scf_e[FDNS_NPTS];
Word16 norm;
+ Word32 L_tmp;
st = sts[ch];
FOR( k = 0; k < nSubframes[ch]; k++ )
{
sns_interpolate_scalefactors_fx( sns_int_scf_fx, &Aq_fx_32[ch][k * M], DEC );
+ test();
IF( st->hTonalMDCTConc != NULL && EQ_16( add( k, 1 ), nSubframes[ch] ) )
{
x_e[ch][k] = 20;
@@ -352,7 +433,9 @@ void stereo_mdct_core_dec_fx(
{
norm = norm_l( sns_int_scf_fx[j] );
scf_e[j] = sub( 15, norm );
+ move16();
scf_fx[j] = extract_h( L_shl( sns_int_scf_fx[j], norm ) );
+ move16();
}
Word16 s = getScaleFactor32( x_fx[ch][k], L_frameTCX[ch] );
Scale_sig32( x_fx[ch][k], L_frameTCX[ch], s );
@@ -361,16 +444,32 @@ void stereo_mdct_core_dec_fx(
}
}
- TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX[ch], ( st->hTcxDec->tcxltp_last_gain_unmodified > 0 ) ? st->old_fpitch : 0, bfi, bfi && st->tonal_mdct_plc_active );
+ IF( ( st->hTcxDec->tcxltp_last_gain_unmodified > 0 ) )
+ {
+ L_tmp = st->old_fpitch;
+ }
+ ELSE
+ {
+ L_tmp = 0;
+ }
+ move32();
+
+ // TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX[ch], ( st->hTcxDec->tcxltp_last_gain_unmodified > 0 ) ? st->old_fpitch : 0, bfi, bfi && st->tonal_mdct_plc_active );
+ TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX[ch], L_tmp, bfi, bfi && st->tonal_mdct_plc_active );
}
- mvs2s( ms_mask[0], hCPE->hStereoMdct->prev_ms_mask[0], MAX_SFB );
- mvs2s( ms_mask[1], hCPE->hStereoMdct->prev_ms_mask[1], MAX_SFB );
+ Copy( ms_mask[0], hCPE->hStereoMdct->prev_ms_mask[0], MAX_SFB );
+ Copy( ms_mask[1], hCPE->hStereoMdct->prev_ms_mask[1], MAX_SFB );
}
- IF( ( EQ_16( bfi, 0 ) || ( NE_16( sts[0]->core, ACELP_CORE ) || NE_16( sts[1]->core, ACELP_CORE ) ) ) && EQ_16( hCPE->hStereoMdct->isSBAStereoMode, 0 ) )
+ test();
+ test();
+ test();
+ IF( ( !bfi || ( sts[0]->core != ACELP_CORE || sts[1]->core != ACELP_CORE ) ) && !hCPE->hStereoMdct->isSBAStereoMode )
{
Word16 q_x_1 = 11, q_x_0 = 11;
+ move16();
+ move16();
stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0_fx[1], x_fx[0], x_fx[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0, &q_x_1, &q_x_0 );
}
@@ -379,11 +478,21 @@ void stereo_mdct_core_dec_fx(
FOR( Word16 ind = 0; ind < 2; ind++ )
{
- Word16 nSubFrames = EQ_16( hCPE->hCoreCoder[ind]->core, TCX_20_CORE ) ? 1 : NB_DIV;
+ Word16 nSubFrames;
+ // Word16 nSubFrames = EQ_16( hCPE->hCoreCoder[ind]->core, TCX_20_CORE ) ? 1 : NB_DIV;
+ IF( EQ_16( hCPE->hCoreCoder[ind]->core, TCX_20_CORE ) )
+ {
+ nSubFrames = 1;
+ }
+ ELSE
+ {
+ nSubFrames = NB_DIV;
+ }
+ move16();
Scale_sig32( x_fx[ind][0], shr( L_FRAME_MAX, sub( nSubFrames, 1 ) ), sub( x_e[ind][0], 20 ) );
x_e[ind][0] = 20;
move16();
- IF( nSubFrames == 2 )
+ IF( EQ_16( nSubFrames, 2 ) )
{
Scale_sig32( x_fx[ind][1], shr( L_FRAME_MAX, 1 ), sub( x_e[ind][1], 20 ) );
x_e[ind][1] = 20;
@@ -391,6 +500,8 @@ void stereo_mdct_core_dec_fx(
}
}
+ test();
+ test();
IF( EQ_16( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
{
ivas_ls_setup_conversion_process_mdct_param_mc_fx( st_ivas, x_fx, x_e );
@@ -398,6 +509,10 @@ void stereo_mdct_core_dec_fx(
run_min_stats_fx( sts, x_fx, x_e );
+ test();
+ test();
+ test();
+ test();
IF( EQ_16( hCPE->nchan_out, 1 ) && ( EQ_16( bfi, 0 ) || ( NE_16( bfi, 0 ) && NE_16( sts[0]->core, ACELP_CORE ) && NE_16( sts[1]->core, ACELP_CORE ) ) ) )
{
apply_dmx_weights_fx( hCPE, x_fx, sts[0]->transform_type, sts[1]->transform_type );
@@ -406,6 +521,7 @@ void stereo_mdct_core_dec_fx(
Word16 s;
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
+ test();
IF( sts[ch]->hFdCngDec && sts[ch]->hFdCngDec->hFdCngCom )
{
s = getScaleFactor32( sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
@@ -417,6 +533,7 @@ void stereo_mdct_core_dec_fx(
scale_sig32( sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, s );
sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( sts[ch]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, s );
}
+ test();
IF( sts[ch]->hFdCngDec && sts[ch]->hFdCngDec->hFdCngCom )
{
sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech = extract_h( sts[ch]->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx );
@@ -436,214 +553,19 @@ void stereo_mdct_core_dec_fx(
ivas_mdct_core_reconstruct_fx( hCPE, x_fx, signal_outFB_tmp_fx, fUseTns, 0, Q11, 17 );
- mvl2l( signal_out_tmp_fx[0], signal_out_fx[0], L_FRAME48k );
- mvl2l( signal_out_tmp_fx[1], signal_out_fx[1], L_FRAME48k );
+ Copy32( signal_out_tmp_fx[0], signal_out_fx[0], L_FRAME48k );
+ Copy32( signal_out_tmp_fx[1], signal_out_fx[1], L_FRAME48k );
- mvs2s( signal_outFB_tmp_fx[0], signal_outFB_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX );
- mvs2s( signal_outFB_tmp_fx[1], signal_outFB_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX );
+ Copy( signal_outFB_tmp_fx[0], signal_outFB_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX );
+ Copy( signal_outFB_tmp_fx[1], signal_outFB_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX );
pop_wmops();
return;
}
-#ifndef IVAS_FLOAT_FIXED
-static void apply_dmx_weights(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *x[CPE_CHANNELS][NB_DIV], /* i/o: MDCT Spectrum */
- int16_t transform_type_left[NB_DIV], /* i : indicate TCX5 for left ch */
- int16_t transform_type_right[NB_DIV] /* i : indicate TCX5 for right ch */
-)
-{
- int16_t b, k, l, i, ch;
- int16_t nsub, nsub2[2], nChannels;
- int16_t transform_type[2][2];
- int16_t numCoeffs[2], frameSize;
- int16_t tcx_10_only, w_idx;
- int16_t start, stop, start_tcx5, stop_tcx5;
- STEREO_MDCT_BAND_PARAMETERS *sfbConf = NULL;
- float mdst[CPE_CHANNELS][NB_DIV][L_FRAME48k];
- float convertRes[CPE_CHANNELS][L_FRAME48k];
- float *sig[CPE_CHANNELS][NB_DIV], *pTmp[CPE_CHANNELS][NB_DIV];
-
- nChannels = CPE_CHANNELS;
- frameSize = hCPE->hStereoMdct->stbParamsTCX20.sfbOffset[hCPE->hStereoMdct->stbParamsTCX20.sfbCnt];
-
- transform_type[0][0] = transform_type_left[0];
- transform_type[0][1] = transform_type_left[1];
- transform_type[1][0] = transform_type_right[0];
- transform_type[1][1] = transform_type_right[1];
-
- /* set overall frequency resolution of (sub)frame to maximum of (sub)frame, requires conversion if both channels are not the same */
- if ( transform_type[0][0] == TCX_20 || transform_type[1][0] == TCX_20 )
- {
- /* use TCX20 band config for TCX20 in both channels and mixed frames */
- sfbConf = &hCPE->hStereoMdct->stbParamsTCX20;
- nsub = nsub2[0] = nsub2[1] = 1; /* overall TCX 20 */
- tcx_10_only = 0;
- }
- else
- {
- /* use TCX10 band config only if none of the channels is TCX20 */
- sfbConf = &hCPE->hStereoMdct->stbParamsTCX10;
- nsub = 2;
- /* set resolution per subframe, subdivide again if subframe is TCX5 in both channels */
- nsub2[0] = ( transform_type[0][0] == TCX_5 && transform_type[1][0] == TCX_5 ) ? 2 : 1;
- nsub2[1] = ( transform_type[0][1] == TCX_5 && transform_type[1][1] == TCX_5 ) ? 2 : 1;
- tcx_10_only = 1;
- }
-
- /* for subframes with only TCX5 in both channels number of coefficients is only half (in 2 quarterframes) */
- numCoeffs[0] = ( nsub2[0] == 1 ) ? sfbConf->sfbOffset[sfbConf->sfbCnt] : sfbConf->sfbOffset[sfbConf->sfbCnt] / 2;
- numCoeffs[1] = ( nsub2[1] == 1 ) ? sfbConf->sfbOffset[sfbConf->sfbCnt] : sfbConf->sfbOffset[sfbConf->sfbCnt] / 2;
-
- /* initially, set pointers to input; if conversion occurs in (sub)frame, set to convertRes */
- sig[0][0] = pTmp[0][0] = x[0][0];
- sig[0][1] = pTmp[0][1] = x[0][1];
- sig[1][0] = pTmp[1][0] = x[1][0];
- sig[1][1] = pTmp[1][1] = x[1][1];
-
- /* convert (sub)frames to higher frequency resolution */
- for ( ch = 0; ch < nChannels; ch++ )
- {
- for ( k = 0; k < NB_DIV; k++ )
- {
- if ( transform_type[ch][k] == TCX_5 && nsub2[k] == 1 )
- {
- /* subframe is TCX5, but TCX10 or TCX20 in other channel -> convert channel with TCX5 to TCX10 resolution */
- pTmp[ch][k] = sig[ch][k] = convertRes[ch] + k * frameSize / 2;
- convert_coeffs_to_higher_res( x[ch][k], x[ch][k] + frameSize / 4, pTmp[ch][k], frameSize / 4 );
- }
- }
-
- if ( transform_type[ch][0] != TCX_20 && nsub == 1 )
- {
- /* TCX20 and TCX10 in same frame -> convert channel with TCX10 to TCX20 resolution */
- sig[ch][0] = convertRes[ch];
- convert_coeffs_to_higher_res( pTmp[ch][0], pTmp[ch][1], sig[ch][0], frameSize / 2 );
- }
- }
-
- /* MDST estimate */
- for ( ch = 0; ch < nChannels; ch++ )
- {
- for ( k = 0; k < nsub; k++ )
- {
- for ( l = 0; l < nsub2[k]; l++ )
- {
- mdst[ch][k][l * numCoeffs[k]] = mdst[ch][k][( l + 1 ) * numCoeffs[k] - 1] = 0.f;
- for ( i = l * numCoeffs[k] + 1; i < ( l + 1 ) * numCoeffs[k] - 1; i++ )
- {
- mdst[ch][k][i] = sig[ch][k][i + 1] - sig[ch][k][i - 1];
- }
- }
- }
- }
-
- /* compute and apply bandwise weigths for active downmix (similar to DFT Stereo) */
- stop_tcx5 = 0;
- for ( b = 0; b < sfbConf->sfbCnt; b++ )
- {
- float w[CPE_CHANNELS][4];
-
- for ( k = 0; k < nsub; k++ )
- {
- for ( l = 0; l < nsub2[k]; l++ )
- {
- float sum_nrg_L = EPSILON, sum_nrg_R = EPSILON;
- float dot_prod_real = EPSILON, dot_prod_imag = EPSILON;
- float sum_nrg_Mid, sum_abs, dot_prod_abs;
-
- start = l * numCoeffs[k] + sfbConf->sfbOffset[b] / nsub2[k];
- stop = l * numCoeffs[k] + sfbConf->sfbOffset[b + 1] / nsub2[k];
-
- /* compute band energies and cross correlation */
- for ( i = start; i < stop; i++ )
- {
- sum_nrg_L += sig[0][k][i] * sig[0][k][i] + mdst[0][k][i] * mdst[0][k][i];
- sum_nrg_R += sig[1][k][i] * sig[1][k][i] + mdst[1][k][i] * mdst[1][k][i];
- dot_prod_real += sig[0][k][i] * sig[1][k][i] + mdst[0][k][i] * mdst[1][k][i];
- dot_prod_imag += mdst[0][k][i] * sig[1][k][i] - sig[0][k][i] * mdst[1][k][i];
- }
- sum_nrg_Mid = max( 0.f, sum_nrg_L + sum_nrg_R + 2.f * dot_prod_real );
- sum_abs = sqrtf( sum_nrg_L ) + sqrtf( sum_nrg_R ) + EPSILON;
- dot_prod_abs = sqrtf( dot_prod_real * dot_prod_real + dot_prod_imag * dot_prod_imag );
-
- /* calculate weights */
- if ( hCPE->hStereoMdct->reverse_dmx == 0 )
- {
- w[1][2 * k + l] = sqrtf( 0.5f * ( sum_nrg_L + sum_nrg_R ) + dot_prod_abs ) / sum_abs;
- w[0][2 * k + l] = w[1][2 * k + l] + sqrtf( 2.f ) * ( 1.f - sqrtf( sum_nrg_Mid ) / sum_abs );
- }
- else
- {
- w[0][2 * k + l] = sqrtf( 0.5f * ( sum_nrg_L + sum_nrg_R ) + dot_prod_abs ) / sum_abs;
- w[1][2 * k + l] = w[0][2 * k + l] + sqrtf( 2.f ) * ( 1.f - sqrtf( sum_nrg_Mid ) / sum_abs );
- }
- }
- }
-
- /* apply weights to channels with their original frequency resolutions */
- for ( ch = 0; ch < CPE_CHANNELS; ch++ )
- {
- if ( transform_type[ch][0] == TCX_20 )
- {
- for ( i = sfbConf->sfbOffset[b]; i < sfbConf->sfbOffset[b + 1]; i++ )
- {
- x[ch][0][i] *= w[ch][0];
- }
- }
- else
- {
- start = sfbConf->sfbOffset[b];
- stop = sfbConf->sfbOffset[b + 1];
- if ( !tcx_10_only ) /* TCX20 band config is used */
- {
- start /= 2;
- stop /= 2;
- }
-
- for ( k = 0; k < NB_DIV; k++ )
- {
- w_idx = ( nsub == 1 ) ? 0 : 2 * k;
- if ( transform_type[ch][k] == TCX_10 )
- {
- for ( i = start; i < stop; i++ )
- {
- x[ch][k][i] *= w[ch][w_idx];
- }
- }
- else /* TCX_5 */
- {
- start_tcx5 = stop_tcx5;
- stop_tcx5 = ( stop + 1 ) / 2;
-
- for ( i = start_tcx5; i < stop_tcx5; i++ )
- {
- x[ch][k][i] *= w[ch][w_idx];
- }
-
- if ( nsub2[k] == 2 )
- {
- w_idx++;
- }
-
- for ( i = start_tcx5; i < stop_tcx5; i++ )
- {
- x[ch][k][i + ( frameSize >> 2 )] *= w[ch][w_idx];
- }
- }
- }
- }
- }
- }
-
- return;
-}
-#endif
-
/*-------------------------------------------------------------------*
- * apply_dmx_weights()
+ * apply_dmx_weights_fx()
*
* apply bandwise weighting for later dmx in case of mono output
*--------------------------------------------------------------------*/
@@ -667,36 +589,87 @@ static void apply_dmx_weights_fx(
Word32 *sig[CPE_CHANNELS][NB_DIV], *pTmp[CPE_CHANNELS][NB_DIV];
nChannels = CPE_CHANNELS;
+ move16();
frameSize = hCPE->hStereoMdct->stbParamsTCX20.sfbOffset[hCPE->hStereoMdct->stbParamsTCX20.sfbCnt];
+ move16();
transform_type[0][0] = transform_type_left[0];
+ move16();
transform_type[0][1] = transform_type_left[1];
+ move16();
transform_type[1][0] = transform_type_right[0];
+ move16();
transform_type[1][1] = transform_type_right[1];
+ move16();
/* set overall frequency resolution of (sub)frame to maximum of (sub)frame, requires conversion if both channels are not the same */
- IF( transform_type[0][0] == TCX_20 || transform_type[1][0] == TCX_20 )
+ test();
+ test();
+ IF( EQ_16( transform_type[0][0], TCX_20 ) || EQ_16( transform_type[1][0], TCX_20 ) )
{
/* use TCX20 band config for TCX20 in both channels and mixed frames */
sfbConf = &hCPE->hStereoMdct->stbParamsTCX20;
nsub = nsub2[0] = nsub2[1] = 1; /* overall TCX 20 */
+ move16();
+ move16();
+ move16();
tcx_10_only = 0;
+ move16();
}
ELSE
{
/* use TCX10 band config only if none of the channels is TCX20 */
sfbConf = &hCPE->hStereoMdct->stbParamsTCX10;
nsub = 2;
+ move16();
/* set resolution per subframe, subdivide again if subframe is TCX5 in both channels */
- nsub2[0] = ( transform_type[0][0] == TCX_5 && transform_type[1][0] == TCX_5 ) ? 2 : 1;
- nsub2[1] = ( transform_type[0][1] == TCX_5 && transform_type[1][1] == TCX_5 ) ? 2 : 1;
+ // nsub2[0] = ( transform_type[0][0] == TCX_5 && transform_type[1][0] == TCX_5 ) ? 2 : 1;
+ test();
+ IF( EQ_16( transform_type[0][0], TCX_5 ) && EQ_16( transform_type[1][0], TCX_5 ) )
+ {
+ nsub2[0] = 2;
+ move16();
+ }
+ ELSE
+ {
+ nsub2[0] = 1;
+ move16();
+ }
+ // nsub2[1] = ( transform_type[0][1] == TCX_5 && transform_type[1][1] == TCX_5 ) ? 2 : 1;
+ test();
+ IF( EQ_16( transform_type[0][1], TCX_5 ) && EQ_16( transform_type[1][1], TCX_5 ) )
+ {
+ nsub2[1] = 2;
+ move16();
+ }
+ ELSE
+ {
+ nsub2[1] = 1;
+ move16();
+ }
tcx_10_only = 1;
+ move16();
}
/* for subframes with only TCX5 in both channels number of coefficients is only half (in 2 quarterframes) */
- numCoeffs[0] = ( nsub2[0] == 1 ) ? sfbConf->sfbOffset[sfbConf->sfbCnt] : sfbConf->sfbOffset[sfbConf->sfbCnt] / 2;
- numCoeffs[1] = ( nsub2[1] == 1 ) ? sfbConf->sfbOffset[sfbConf->sfbCnt] : sfbConf->sfbOffset[sfbConf->sfbCnt] / 2;
-
+ // numCoeffs[0] = ( nsub2[0] == 1 ) ? sfbConf->sfbOffset[sfbConf->sfbCnt] : sfbConf->sfbOffset[sfbConf->sfbCnt] / 2;
+ IF( EQ_16( nsub2[0], 1 ) )
+ {
+ numCoeffs[0] = sfbConf->sfbOffset[sfbConf->sfbCnt];
+ }
+ ELSE
+ {
+ numCoeffs[0] = shr( sfbConf->sfbOffset[sfbConf->sfbCnt], 1 );
+ }
+ // numCoeffs[1] = ( nsub2[1] == 1 ) ? sfbConf->sfbOffset[sfbConf->sfbCnt] : sfbConf->sfbOffset[sfbConf->sfbCnt] / 2;
+ IF( EQ_16( nsub2[1], 1 ) )
+ {
+ numCoeffs[1] = sfbConf->sfbOffset[sfbConf->sfbCnt];
+ }
+ ELSE
+ {
+ numCoeffs[1] = shr( sfbConf->sfbOffset[sfbConf->sfbCnt], 1 );
+ }
/* initially, set pointers to input; if conversion occurs in (sub)frame, set to convertRes */
sig[0][0] = pTmp[0][0] = x[0][0];
sig[0][1] = pTmp[0][1] = x[0][1];
@@ -708,19 +681,21 @@ static void apply_dmx_weights_fx(
{
FOR( k = 0; k < NB_DIV; k++ )
{
- IF( transform_type[ch][k] == TCX_5 && nsub2[k] == 1 )
+ test();
+ IF( EQ_16( transform_type[ch][k], TCX_5 ) && EQ_16( nsub2[k], 1 ) )
{
/* subframe is TCX5, but TCX10 or TCX20 in other channel -> convert channel with TCX5 to TCX10 resolution */
- pTmp[ch][k] = sig[ch][k] = convertRes[ch] + k * frameSize / 2;
- convert_coeffs_to_higher_res_fx( x[ch][k], x[ch][k] + frameSize / 4, pTmp[ch][k], frameSize / 4 );
+ pTmp[ch][k] = sig[ch][k] = convertRes[ch] + i_mult( k, shr( frameSize, 1 ) );
+ convert_coeffs_to_higher_res_fx( x[ch][k], x[ch][k] + shr( frameSize, 2 ), pTmp[ch][k], shr( frameSize, 2 ) );
}
}
- IF( transform_type[ch][0] != TCX_20 && nsub == 1 )
+ test();
+ IF( NE_16( transform_type[ch][0], TCX_20 ) && EQ_16( nsub, 1 ) )
{
/* TCX20 and TCX10 in same frame -> convert channel with TCX10 to TCX20 resolution */
sig[ch][0] = convertRes[ch];
- convert_coeffs_to_higher_res_fx( pTmp[ch][0], pTmp[ch][1], sig[ch][0], frameSize / 2 );
+ convert_coeffs_to_higher_res_fx( pTmp[ch][0], pTmp[ch][1], sig[ch][0], shr( frameSize, 1 ) );
}
}
@@ -732,10 +707,13 @@ static void apply_dmx_weights_fx(
FOR( l = 0; l < nsub2[k]; l++ )
{
// mdst[ch][k][l * numCoeffs[k]] = mdst[ch][k][( l + 1 ) * numCoeffs[k] - 1] = 0.f;
- mdst[ch][k][l * numCoeffs[k]] = mdst[ch][k][( l + 1 ) * numCoeffs[k] - 1] = 0;
+ mdst[ch][k][i_mult( l, numCoeffs[k] )] = mdst[ch][k][sub( i_mult( add( l, 1 ), numCoeffs[k] ), 1 )] = 0;
+ move32();
+ move32();
FOR( i = l * numCoeffs[k] + 1; i < ( l + 1 ) * numCoeffs[k] - 1; i++ )
{
- mdst[ch][k][i] = sig[ch][k][i + 1] - sig[ch][k][i - 1];
+ mdst[ch][k][i] = L_sub( sig[ch][k][i + 1], sig[ch][k][i - 1] );
+ move32();
}
}
}
@@ -743,6 +721,7 @@ static void apply_dmx_weights_fx(
/* compute and apply bandwise weigths for active downmix (similar to DFT Stereo) */
stop_tcx5 = 0;
+ move16();
FOR( b = 0; b < sfbConf->sfbCnt; b++ )
{
Word16 w[CPE_CHANNELS][4];
@@ -752,11 +731,38 @@ static void apply_dmx_weights_fx(
FOR( l = 0; l < nsub2[k]; l++ )
{
Word64 sum_nrg_L = 0, sum_nrg_R = 0;
+ move64();
+ move64();
Word64 dot_prod_real = 0, dot_prod_imag = 0;
+ move64();
+ move64();
Word32 sum_nrg_Mid, sum_abs, dot_prod_abs;
+ Word16 val_div = 0;
- start = l * numCoeffs[k] + sfbConf->sfbOffset[b] / nsub2[k];
- stop = l * numCoeffs[k] + sfbConf->sfbOffset[b + 1] / nsub2[k];
+ IF( sfbConf->sfbOffset[b] == 0 )
+ {
+ val_div = 0;
+ move16();
+ }
+ ELSE
+ {
+ val_div = idiv1616( sfbConf->sfbOffset[b], nsub2[k] );
+ move16();
+ }
+ start = add( i_mult( l, numCoeffs[k] ), val_div );
+
+ IF( sfbConf->sfbOffset[b + 1] == 0 )
+ {
+ val_div = 0;
+ move16();
+ }
+ ELSE
+ {
+ val_div = idiv1616( sfbConf->sfbOffset[b + 1], nsub2[k] );
+ move16();
+ }
+
+ stop = add( i_mult( l, numCoeffs[k] ), val_div );
/* compute band energies and cross correlation */
FOR( i = start; i < stop; i++ )
@@ -773,84 +779,102 @@ static void apply_dmx_weights_fx(
Word16 norm_dot_prod_imag = W_norm( dot_prod_imag );
Word16 guard_bit = find_guarded_bits_fx( 4 );
- Word16 min_norm = min( min( min( norm_sum_nrg_L, norm_sum_nrg_R ), norm_dot_prod_real ), norm_dot_prod_imag ) - guard_bit;
+ Word16 min_norm = sub( s_min( s_min( s_min( norm_sum_nrg_L, norm_sum_nrg_R ), norm_dot_prod_real ), norm_dot_prod_imag ), guard_bit );
Word32 sum_nrg_L_32 = W_extract_h( W_shl( sum_nrg_L, min_norm ) );
Word32 sum_nrg_R_32 = W_extract_h( W_shl( sum_nrg_R, min_norm ) );
Word32 dot_prod_real_32 = W_extract_h( W_shl( dot_prod_real, min_norm ) );
Word32 dot_prod_imag_32 = W_extract_h( W_shl( dot_prod_imag, min_norm ) );
- Word16 q_sum_nrg_L = 23 + min_norm - 32;
- Word16 q_sum_nrg_R = 23 + min_norm - 32;
- Word16 q_dot_prod_real = 23 + min_norm - 32;
+ Word16 q_sum_nrg_L = sub( add( 23, min_norm ), 32 );
+ Word16 q_sum_nrg_R = sub( add( 23, min_norm ), 32 );
+ Word16 q_dot_prod_real = sub( add( 23, min_norm ), 32 );
- Word16 E_sum_nrg_l = 31 - q_sum_nrg_L;
- Word16 E_sum_nrg_R = 31 - q_sum_nrg_R;
- Word16 E_dot_prod_abs = 31 - ( q_dot_prod_real * 2 - 31 );
- Word16 E_sum_nrg_Mid = 31 - q_sum_nrg_L;
- sum_nrg_Mid = max( 0, L_add( L_add( sum_nrg_L_32, sum_nrg_R_32 ), L_shl( dot_prod_real_32, 1 ) ) );
+ Word16 E_sum_nrg_l = sub( 31, q_sum_nrg_L );
+ Word16 E_sum_nrg_R = sub( 31, q_sum_nrg_R );
+ Word16 E_dot_prod_abs = sub( 31, sub( shl( q_dot_prod_real, 1 ), 31 ) );
+ Word16 E_sum_nrg_Mid = sub( 31, q_sum_nrg_L );
+ sum_nrg_Mid = L_max( 0, L_add( L_add( sum_nrg_L_32, sum_nrg_R_32 ), L_shl( dot_prod_real_32, 1 ) ) );
Word32 tmp_nrg_L = Sqrt32( sum_nrg_L_32, &E_sum_nrg_l );
Word32 tmp_nrg_R = Sqrt32( sum_nrg_R_32, &E_sum_nrg_R );
Word16 max_e_sum_abs = E_sum_nrg_l;
- IF( E_sum_nrg_R > E_sum_nrg_l )
+ move16();
+ IF( GT_16( E_sum_nrg_R, E_sum_nrg_l ) )
{
max_e_sum_abs = E_sum_nrg_R;
+ move16();
}
- max_e_sum_abs = max_e_sum_abs + 1;
+ max_e_sum_abs = add( max_e_sum_abs, 1 );
sum_abs = L_add( L_shr( tmp_nrg_L, max_e_sum_abs - E_sum_nrg_l ), L_shr( tmp_nrg_R, max_e_sum_abs - E_sum_nrg_R ) );
dot_prod_abs = Sqrt32( L_add( Mpy_32_32( dot_prod_real_32, dot_prod_real_32 ), Mpy_32_32( dot_prod_imag_32, dot_prod_imag_32 ) ), &E_dot_prod_abs );
Word32 num = L_add( L_shr( L_add( sum_nrg_L_32, sum_nrg_R_32 ), 1 ), L_shr( dot_prod_abs, ( 31 - E_dot_prod_abs ) - q_sum_nrg_L ) );
- Word16 E_num = 31 - q_sum_nrg_L;
+ Word16 E_num = sub( 31, q_sum_nrg_L );
Word32 num_sqrt = Sqrt32( num, &E_num );
Word16 e_full_w = max_e_sum_abs;
- IF( max_e_sum_abs < E_num )
+ move16();
+ IF( LT_16( max_e_sum_abs, E_num ) )
{
e_full_w = E_num;
+ move16();
}
Word16 full_w_up;
+ test();
+ test();
IF( num_sqrt == 0 && sum_abs == 0 )
{
full_w_up = 6364; // 0.776887059 in Q13
+ move16();
}
ELSE IF( num_sqrt == 0 && sum_abs != 0 )
{
full_w_up = 5793; // 0.707106769 in Q13
+ move16();
}
ELSE
{
- full_w_up = shr( divide3232( L_shr( num_sqrt, e_full_w - E_num ), L_shr( sum_abs, e_full_w - max_e_sum_abs ) ), 2 );
+ full_w_up = shr( divide3232( L_shr( num_sqrt, sub( e_full_w, E_num ) ), L_shr( sum_abs, sub( e_full_w, max_e_sum_abs ) ) ), 2 );
}
Word32 sum_nrg_Mid_sqrt = Sqrt32( sum_nrg_Mid, &E_sum_nrg_Mid );
Word16 e_full_down = max_e_sum_abs;
- IF( max_e_sum_abs < E_sum_nrg_Mid )
+ move16();
+ IF( LT_16( max_e_sum_abs, E_sum_nrg_Mid ) )
{
e_full_down = E_sum_nrg_Mid;
+ move16();
}
Word16 full_w_down;
+ test();
+ test();
IF( sum_nrg_Mid_sqrt == 0 && sum_abs == 0 )
{
full_w_down = 6364;
+ move16();
}
ELSE IF( sum_nrg_Mid_sqrt == 0 && sum_abs != 0 )
{
full_w_down = 5793;
+ move16();
}
ELSE
{
- full_w_down = shr( divide3232( L_shr( sum_nrg_Mid_sqrt, e_full_down - E_sum_nrg_Mid ), L_shr( sum_abs, e_full_down - max_e_sum_abs ) ), 1 );
+ full_w_down = shr( divide3232( L_shr( sum_nrg_Mid_sqrt, sub( e_full_down, E_sum_nrg_Mid ) ), L_shr( sum_abs, sub( e_full_down, max_e_sum_abs ) ) ), 1 );
}
IF( hCPE->hStereoMdct->reverse_dmx == 0 )
{
- w[1][2 * k + l] = full_w_up;
- w[0][2 * k + l] = add( w[1][2 * k + l], mult( 23170 /*sqrt(2.0f in Q14)*/, sub( 16384 /* 1.0f in Q14 */, full_w_down ) ) );
+ w[1][add( 2 * k, l )] = full_w_up;
+ move16();
+ w[0][add( 2 * k, l )] = add( w[1][add( 2 * k, l )], mult( 23170 /*sqrt(2.0f in Q14)*/, sub( 16384 /* 1.0f in Q14 */, full_w_down ) ) );
+ move16();
}
ELSE
{
- w[0][2 * k + l] = full_w_up;
- w[1][2 * k + l] = add( w[0][2 * k + l], mult( 23170 /*sqrt(2.0f in Q14)*/, sub( 16384 /* 1.0f in Q14 */, full_w_down ) ) );
+ w[0][add( 2 * k, l )] = full_w_up;
+ move16();
+ w[1][add( 2 * k, l )] = add( w[0][add( 2 * k, l )], mult( 23170 /*sqrt(2.0f in Q14)*/, sub( 16384 /* 1.0f in Q14 */, full_w_down ) ) );
+ move16();
}
}
}
@@ -858,51 +882,69 @@ static void apply_dmx_weights_fx(
/* apply weights to channels with their original frequency resolutions */
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
- IF( transform_type[ch][0] == TCX_20 )
+ IF( EQ_16( transform_type[ch][0], TCX_20 ) )
{
FOR( i = sfbConf->sfbOffset[b]; i < sfbConf->sfbOffset[b + 1]; i++ )
{
x[ch][0][i] = L_shl( Mpy_32_16_1( x[ch][0][i], w[ch][0] ), 2 );
+ move32();
}
}
ELSE
{
start = sfbConf->sfbOffset[b];
+ move16();
stop = sfbConf->sfbOffset[b + 1];
+ move16();
IF( !tcx_10_only ) /* TCX20 band config is used */
{
- start /= 2;
- stop /= 2;
+ start = shr( start, 1 );
+ stop = shr( stop, 1 );
}
FOR( k = 0; k < NB_DIV; k++ )
{
- w_idx = ( nsub == 1 ) ? 0 : 2 * k;
- IF( transform_type[ch][k] == TCX_10 )
+ // w_idx = ( nsub == 1 ) ? 0 : 2 * k;
+ IF( EQ_16( nsub, 1 ) )
+ {
+ w_idx = 0;
+ move16();
+ }
+ ELSE
+ {
+ w_idx = shl( k, 1 );
+ move16();
+ }
+
+ IF( EQ_16( transform_type[ch][k], TCX_10 ) )
{
FOR( i = start; i < stop; i++ )
{
x[ch][k][i] = L_shl( Mpy_32_16_1( x[ch][k][i], w[ch][w_idx] ), 2 );
+ move32();
}
}
ELSE /* TCX_5 */
{
start_tcx5 = stop_tcx5;
- stop_tcx5 = ( stop + 1 ) / 2;
+ move16();
+ stop_tcx5 = shr( add( stop, 1 ), 1 );
FOR( i = start_tcx5; i < stop_tcx5; i++ )
{
x[ch][k][i] = L_shl( Mpy_32_16_1( x[ch][k][i], w[ch][w_idx] ), 2 );
+ move32();
}
- IF( nsub2[k] == 2 )
+ IF( EQ_16( nsub2[k], 2 ) )
{
- w_idx++;
+ w_idx = add( w_idx, 1 );
}
FOR( i = start_tcx5; i < stop_tcx5; i++ )
{
- x[ch][k][i + ( frameSize >> 2 )] = L_shl( Mpy_32_16_1( x[ch][k][i + ( frameSize >> 2 )], w[ch][w_idx] ), 2 );
+ x[ch][k][add( i, shr( frameSize, 2 ) )] = L_shl( Mpy_32_16_1( x[ch][k][add( i, shr( frameSize, 2 ) )], w[ch][w_idx] ), 2 );
+ move32();
}
}
}
@@ -915,7 +957,7 @@ static void apply_dmx_weights_fx(
/*-------------------------------------------------------------------*
- * run_min_stats()
+ * run_min_stats_fx()
*
* run the minimum statistics noise estimation algorithm
* directly on the MDCT spectrum
@@ -926,17 +968,26 @@ static void run_min_stats_fx(
Word32 *x[CPE_CHANNELS][NB_DIV], /* i/o: MDCT Spectrum */
Word16 x_e[CPE_CHANNELS][NB_DIV] )
{
- int16_t ch, will_estimate_noise_on_channel[CPE_CHANNELS], save_VAD[CPE_CHANNELS];
+ Word16 ch, will_estimate_noise_on_channel[CPE_CHANNELS], save_VAD[CPE_CHANNELS];
Word32 power_spec[L_FRAME16k];
Word16 power_spec_16[L_FRAME16k], power_spec_e = 0;
+ move16();
Word32 *spec_in;
Word16 spec_e;
/* Check if the minimum statistics would run on the respective channels. They are run on inactive TCX20 channels */
- will_estimate_noise_on_channel[0] = sts[0]->core == TCX_20_CORE && !sts[0]->VAD;
- will_estimate_noise_on_channel[1] = sts[1]->core == TCX_20_CORE && !sts[1]->VAD;
+ test();
+ test();
+ will_estimate_noise_on_channel[0] = EQ_16( sts[0]->core, TCX_20_CORE ) && !sts[0]->VAD;
+ will_estimate_noise_on_channel[1] = EQ_16( sts[1]->core, TCX_20_CORE ) && !sts[1]->VAD;
+ test();
+ test();
+ move16();
+ move16();
save_VAD[0] = sts[0]->VAD;
+ move16();
save_VAD[1] = sts[1]->VAD;
+ move16();
/* The first loop calculates the power spectra needed in the minimum statistics (MS) noise estimation. This is only needed if the MS
would run at all on at least one of the channels. If they run on both channels, we need to calculate two distinct power spectra
@@ -948,6 +999,8 @@ static void run_min_stats_fx(
Decoder_State *st;
st = sts[ch];
+ test();
+ test();
IF( !sts[0]->bfi && ( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] ) )
{
/* if noise estimation is expected to run on this channel, compute power spectrum from it,
@@ -963,6 +1016,7 @@ static void run_min_stats_fx(
spec_e = x_e[( ch + 1 ) % 2][0];
/* patch VAD to zero so that estimation runs, will later be restored */
st->VAD = 0;
+ move16();
}
/* Compute power spectrum twice if estimation will run on both channels. If only on one channel, it is
@@ -971,15 +1025,16 @@ static void run_min_stats_fx(
{
Word16 tmp16 = getScaleFactor32( spec_in, L_FRAME16k );
/* calculate power spectrum from MDCT coefficients and estimated MDST coeffs */
- power_spec[0] = W_extract_h( W_shl( W_mult_32_32( spec_in[0], spec_in[0] ), tmp16 - 4 ) ); /* 2 * (Q31 - x_e) + tmp16 - Q4 - Q31 */
- power_spec[L_FRAME16k - 1] = W_extract_h( W_shl( W_mult_32_32( spec_in[L_FRAME16k - 1], spec_in[L_FRAME16k - 1] ), tmp16 - 4 ) ); /* 2 * (Q31 - x_e) + tmp16 - Q4 - Q31 */
+ power_spec[0] = W_extract_h( W_shl( W_mult_32_32( spec_in[0], spec_in[0] ), sub( tmp16, 4 ) ) ); /* 2 * (Q31 - x_e) + tmp16 - Q4 - Q31 */
+ power_spec[L_FRAME16k - 1] = W_extract_h( W_shl( W_mult_32_32( spec_in[L_FRAME16k - 1], spec_in[L_FRAME16k - 1] ), sub( tmp16, 4 ) ) ); /* 2 * (Q31 - x_e) + tmp16 - Q4 - Q31 */
FOR( Word16 i = 1; i < L_FRAME16k - 1; i++ )
{
Word32 mdst;
- mdst = L_sub( spec_in[i + 1], spec_in[i - 1] ); /* Q31 - x_e */
- power_spec[i] = L_add( W_extract_h( W_shl( W_mult_32_32( spec_in[i], spec_in[i] ), tmp16 - 4 ) ), W_extract_h( W_shl( W_mult_32_32( mdst, mdst ), tmp16 - 4 ) ) ); /* 2 * (Q31 - x_e) + tmp16 - Q4 - Q31*/
+ mdst = L_sub( spec_in[i + 1], spec_in[i - 1] ); /* Q31 - x_e */
+ power_spec[i] = L_add( W_extract_h( W_shl( W_mult_32_32( spec_in[i], spec_in[i] ), sub( tmp16, 4 ) ) ), W_extract_h( W_shl( W_mult_32_32( mdst, mdst ), sub( tmp16, 4 ) ) ) ); /* 2 * (Q31 - x_e) + tmp16 - Q4 - Q31*/
+ move32();
}
- power_spec_e = add( 4, shl( spec_e, 1 ) ) - tmp16;
+ power_spec_e = sub( add( 4, shl( spec_e, 1 ) ), tmp16 );
}
Copy_Scale_sig32_16( power_spec, power_spec_16, L_FRAME16k, 0 );
@@ -990,8 +1045,11 @@ static void run_min_stats_fx(
st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = extract_h( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech_32fx );
st->lp_noise = st->hFdCngDec->lp_noise;
+ move32();
}
+ test();
+ test();
IF( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] || st->bfi )
{
// for ( int p = 0; p < FFTCLDFBLEN; p++ )
@@ -1005,7 +1063,16 @@ static void run_min_stats_fx(
// Scale_sig32(power_spec, L_FRAME16k, sub(power_spec_e, 31));
// power_spec_e = 31;
/*=================================================*/
- ApplyFdCng_ivas_fx( NULL, 0, st->bfi ? NULL : power_spec, sub( 31, power_spec_e ), NULL, NULL, NULL, st, st->bfi, 0 );
+ Word32 *arr_tmp;
+ IF( st->bfi )
+ {
+ arr_tmp = NULL;
+ }
+ ELSE
+ {
+ arr_tmp = power_spec;
+ }
+ ApplyFdCng_ivas_fx( NULL, 0, arr_tmp, sub( 31, power_spec_e ), NULL, NULL, NULL, st, st->bfi, 0 );
/*=================================================*/
}
diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c
index b6a4240933602b470d42b1fab3a2dad1fad4b683..9177bf69ca1653f7e7aa2b9923d5744a05cb8e0c 100644
--- a/lib_dec/ivas_stereo_mdct_stereo_dec.c
+++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c
@@ -39,8 +39,7 @@
#include "prot.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif // IVAS_FLOAT_FIXED
@@ -360,10 +359,29 @@ void parse_stereo_from_bitstream(
IF( !isSBAStereoMode )
{
- nSubframes = ( EQ_16( sts[0]->core, TCX_10_CORE ) || ( NE_16( sts[0]->core, sts[1]->core ) ) ) ? NB_DIV : 1;
+ // nSubframes = ( EQ_16( sts[0]->core, TCX_10_CORE ) || ( NE_16( sts[0]->core, sts[1]->core ) ) ) ? NB_DIV : 1;
+ test();
+ IF( ( EQ_16( sts[0]->core, TCX_10_CORE ) || ( NE_16( sts[0]->core, sts[1]->core ) ) ) )
+ {
+ nSubframes = NB_DIV;
+ move16();
+ }
+ ELSE
+ {
+ nSubframes = 1;
+ move16();
+ }
move16();
- sfbConf = ( EQ_16( sts[0]->core, TCX_20_CORE ) ) ? &hStereoMdct->stbParamsTCX20 : &hStereoMdct->stbParamsTCX10;
- IF( EQ_16( sts[0]->last_core_from_bs, ACELP_CORE ) )
+ // sfbConf = ( EQ_16( sts[0]->core, TCX_20_CORE ) ) ? &hStereoMdct->stbParamsTCX20 : &hStereoMdct->stbParamsTCX10;
+ IF( ( EQ_16( sts[0]->core, TCX_20_CORE ) ) )
+ {
+ sfbConf = &hStereoMdct->stbParamsTCX20;
+ }
+ ELSE
+ {
+ sfbConf = &hStereoMdct->stbParamsTCX10;
+ }
+ if ( sts[0]->last_core_from_bs == ACELP_CORE )
{
sfbConf = &hStereoMdct->stbParamsTCX20afterACELP;
}
@@ -412,7 +430,7 @@ void parse_stereo_from_bitstream(
IF( !mct_on )
{
test();
- IF( EQ_16( sts[0]->core, sts[1]->core ) || EQ_16( k, 0 ) )
+ IF( EQ_16( sts[0]->core, sts[1]->core ) || k == 0 )
{
hStereoMdct->global_ild[k] = extract_l( get_next_indice_fx( st0, SMDCT_GLOBAL_ILD_BITS ) );
move16();
@@ -425,7 +443,15 @@ void parse_stereo_from_bitstream(
}
}
- set16_fx( ms_mask[k], ( EQ_16( hStereoMdct->mdct_stereo_mode[k], SMDCT_MS_FULL ) ) ? 1 : 0, sfbConf->nBandsStereoCore );
+ // set16_fx( ms_mask[k], ( EQ_16( hStereoMdct->mdct_stereo_mode[k], SMDCT_MS_FULL ) ) ? 1 : 0, sfbConf->nBandsStereoCore );
+ IF( ( EQ_16( hStereoMdct->mdct_stereo_mode[k], SMDCT_MS_FULL ) ) )
+ {
+ set16_fx( ms_mask[k], 1, sfbConf->nBandsStereoCore );
+ }
+ ELSE
+ {
+ set16_fx( ms_mask[k], 0, sfbConf->nBandsStereoCore );
+ }
IF( EQ_16( hStereoMdct->mdct_stereo_mode[k], SMDCT_BW_MS ) )
{
@@ -462,7 +488,15 @@ void parse_stereo_from_bitstream(
assert( !"Not supported stereo mode\n" );
}
- set16_fx( &ms_mask[k][sfbConf->nBandsStereoCore], ( EQ_16( hStereoMdct->IGFStereoMode[k], SMDCT_MS_FULL ) ) ? 1 : 0, sub( sfbConf->sfbCnt, sfbConf->nBandsStereoCore ) );
+ // set16_fx( &ms_mask[k][sfbConf->nBandsStereoCore], ( EQ_16( hStereoMdct->IGFStereoMode[k], SMDCT_MS_FULL ) ) ? 1 : 0, sub( sfbConf->sfbCnt, sfbConf->nBandsStereoCore ) );
+ IF( ( EQ_16( hStereoMdct->IGFStereoMode[k], SMDCT_MS_FULL ) ) )
+ {
+ set16_fx( &ms_mask[k][sfbConf->nBandsStereoCore], 1, sub( sfbConf->sfbCnt, sfbConf->nBandsStereoCore ) );
+ }
+ ELSE
+ {
+ set16_fx( &ms_mask[k][sfbConf->nBandsStereoCore], 0, sub( sfbConf->sfbCnt, sfbConf->nBandsStereoCore ) );
+ }
IF( EQ_16( hStereoMdct->IGFStereoMode[k], SMDCT_BW_MS ) )
{
@@ -576,7 +610,7 @@ void stereo_decoder_tcx_fx(
move16();
test();
test();
- IF( ( LE_16( core_l, TCX_20_CORE ) && LE_16( core_r, TCX_20_CORE ) ) || tmp_plc_upmix )
+ if ( ( LE_16( core_l, TCX_20_CORE ) && LE_16( core_r, TCX_20_CORE ) ) || tmp_plc_upmix )
{
nSubframes = 1;
move16();
@@ -584,10 +618,18 @@ void stereo_decoder_tcx_fx(
FOR( k = 0; k < nSubframes; k++ )
{
- sfbConf = ( EQ_16( core_l, TCX_20_CORE ) ) ? &hStereoMdct->stbParamsTCX20 : &hStereoMdct->stbParamsTCX10;
+ // sfbConf = ( EQ_16( core_l, TCX_20_CORE ) ) ? &hStereoMdct->stbParamsTCX20 : &hStereoMdct->stbParamsTCX10;
+ IF( ( EQ_16( core_l, TCX_20_CORE ) ) )
+ {
+ sfbConf = &hStereoMdct->stbParamsTCX20;
+ }
+ ELSE
+ {
+ sfbConf = &hStereoMdct->stbParamsTCX10;
+ }
test();
- IF( EQ_16( last_core_l, ACELP_CORE ) || EQ_16( last_core_r, ACELP_CORE ) )
+ if ( last_core_l == ACELP_CORE || last_core_r == ACELP_CORE )
{
sfbConf = &hStereoMdct->stbParamsTCX20afterACELP;
}
@@ -643,7 +685,7 @@ void stereo_decoder_tcx_fx(
move32();
}
}
- inverseMS_fx( sfbConf->sfbOffset[sfbConf->sfbCnt] - sfbConf->sfbOffset[sfbConf->nBandsStereoCore], &spec_l[k][sfbConf->sfbOffset[sfbConf->nBandsStereoCore]], &spec_r[k][sfbConf->sfbOffset[sfbConf->nBandsStereoCore]], SQRT2_OVER_2_FIXED );
+ inverseMS_fx( sub( sfbConf->sfbOffset[sfbConf->sfbCnt], sfbConf->sfbOffset[sfbConf->nBandsStereoCore] ), &spec_l[k][sfbConf->sfbOffset[sfbConf->nBandsStereoCore]], &spec_r[k][sfbConf->sfbOffset[sfbConf->nBandsStereoCore]], SQRT2_OVER_2_FIXED );
*q_x_ch2 = *q_x_ch2;
move16();
*q_x_ch1 = *q_x_ch1;
@@ -692,9 +734,33 @@ void stereo_decoder_tcx_fx(
move16();
}
+ Word16 tmp1, tmp2 = 0;
+
+ IF( EQ_16( core_r, TCX_10_CORE ) )
+ {
+ tmp1 = NB_DIV;
+ move16();
+ }
+ ELSE
+ {
+ tmp1 = 1;
+ move16();
+ }
+
+ IF( EQ_16( core_l, TCX_10_CORE ) )
+ {
+ tmp2 = NB_DIV;
+ move16();
+ }
+ ELSE
+ {
+ tmp2 = 1;
+ move16();
+ }
+
test();
test();
- IF( ( GT_32( nrgRatio, ONE_IN_Q26 ) ) && ( LT_16( k, ( ( EQ_16( core_r, TCX_10_CORE ) ) ? NB_DIV : 1 ) ) ) )
+ IF( ( GT_32( nrgRatio, ONE_IN_Q26 ) ) && ( LT_16( k, tmp1 ) ) )
{
shift = norm_l( nrgRatio );
nrgRatio = L_shl( nrgRatio, shift );
@@ -703,11 +769,11 @@ void stereo_decoder_tcx_fx(
*q_x_ch2 = *q_x_ch2;
move16();
}
- ELSE IF( ( LT_32( nrgRatio, ONE_IN_Q26 ) ) && ( LT_16( k, ( ( EQ_16( core_l, TCX_10_CORE ) ) ? NB_DIV : 1 ) ) ) )
+ ELSE IF( ( LT_32( nrgRatio, ONE_IN_Q26 ) ) && ( LT_16( k, tmp2 ) ) )
{
tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q26, nrgRatio, &tmp_e );
inv_nrgRatio = L_deposit_h( tmp );
- shift = 5 - tmp_e;
+ shift = sub( 5, tmp_e );
v_multc_fixed( spec_l[k], inv_nrgRatio, spec_l[k], L_frameTCX_l );
Scale_sig32( spec_l[k], L_frameTCX_l, sub( 5, shift ) );
*q_x_ch1 = *q_x_ch1;
@@ -891,7 +957,7 @@ ivas_error initMdctStereoDtxData_fx(
IF( st->hFdCngDec == NULL )
{
/* Create FD_CNG instance */
- IF( ( error = createFdCngDec_fx( &st->hFdCngDec ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = createFdCngDec_fx( &st->hFdCngDec ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -903,18 +969,20 @@ ivas_error initMdctStereoDtxData_fx(
initFdCngDec_ivas_fx( st, st->cldfbSyn->scale );
}
- IF( EQ_16( st->first_CNG, 0 ) )
+ IF( st->first_CNG == 0 )
{
+ test();
IF( EQ_16( ch, 1 ) && st->cng_sba_flag )
{
st->hFdCngDec->hFdCngCom->seed = add( st->hFdCngDec->hFdCngCom->seed, 3 );
+ move16();
}
}
IF( st->cldfbAna == NULL )
{
/* open analysis for max. sampling rate 48kHz */
- IF( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -923,7 +991,7 @@ ivas_error initMdctStereoDtxData_fx(
IF( st->cldfbBPF == NULL )
{
/* open analysis BPF for max. internal sampling rate 16kHz */
- IF( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1036,7 +1104,7 @@ void synchonize_channels_mdct_sid_fx(
}
}
- IF( EQ_16( sts[0]->first_CNG, 0 ) )
+ IF( sts[0]->first_CNG == 0 )
{
/* configure CNG after reading first side info from SID to get correct values for L_frame and bwidth if first SID is also first valid frame */
configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->element_brate, st->L_frame, st->last_L_frame, st->element_mode );
@@ -1100,35 +1168,41 @@ static void update_exp( Word16 *a_exp, Word16 *b_exp, Word16 *buff_a, Word16 *bu
static void update_exp( Word16 *a_exp, Word16 *b_exp, Word16 *buff_a, Word16 *buff_b, Word16 legth )
{
Word16 diff = 0;
- if ( *a_exp > *b_exp )
+ move16();
+ IF( GT_16( *a_exp, *b_exp ) )
{
- diff = *a_exp - *b_exp;
- for ( int j = 0; j < legth; j++ )
+ diff = sub( *a_exp, *b_exp );
+ FOR( Word16 j = 0; j < legth; j++ )
{
buff_b[j] = shr( buff_b[j], diff );
+ move16();
}
*b_exp = *a_exp;
+ move16();
}
- else if ( *a_exp < *b_exp )
+ ELSE IF( LT_16( *a_exp, *b_exp ) )
{
- diff = *b_exp - *a_exp;
+ diff = sub( *b_exp, *a_exp );
- for ( int j = 0; j < legth; j++ )
+ FOR( Word16 j = 0; j < legth; j++ )
{
buff_a[j] = shr( buff_a[j], diff );
+ move16();
}
*a_exp = *b_exp;
+ move16();
}
return;
}
-static Word16 norm_arr( Word16 *arr, int size )
+static Word16 norm_arr( Word16 *arr, Word32 size )
{
Word16 q = 15;
- for ( int i = 0; i < size; i++ )
- if ( arr[i] != 0 )
- {
- q = min( q, norm_s( arr[i] ) );
- }
+ 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(
@@ -1153,36 +1227,49 @@ void updateBuffersForDmxMdctStereo_fx(
}
Word32 Var1 = 0;
+ move16();
Word16 diff_sidNoiseEst = 0;
+ move16();
Word16 exp_sidNoiseEst0 = sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp;
+ move16();
Word16 exp_sidNoiseEst1 = sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp;
- if ( exp_sidNoiseEst0 > exp_sidNoiseEst1 )
+ move16();
+ IF( GT_16( exp_sidNoiseEst0, exp_sidNoiseEst1 ) )
{
- diff_sidNoiseEst = exp_sidNoiseEst0 - exp_sidNoiseEst1;
- for ( int j = 0; j < NPART; j++ )
+ diff_sidNoiseEst = sub( exp_sidNoiseEst0, exp_sidNoiseEst1 );
+ FOR( Word32 j = 0; j < NPART; j++ )
{
sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[j] = L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[j], diff_sidNoiseEst );
+ move16();
}
exp_sidNoiseEst1 = exp_sidNoiseEst0;
+ move16();
}
- else if ( exp_sidNoiseEst0 < exp_sidNoiseEst1 )
+ ELSE IF( LT_16( exp_sidNoiseEst0, exp_sidNoiseEst1 ) )
{
- diff_sidNoiseEst = exp_sidNoiseEst1 - exp_sidNoiseEst0;
- for ( int j = 0; j < NPART; j++ )
+ diff_sidNoiseEst = sub( exp_sidNoiseEst1, exp_sidNoiseEst0 );
+ FOR( Word32 j = 0; j < NPART; j++ )
{
sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[j] = L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[j], diff_sidNoiseEst );
+ move16();
}
exp_sidNoiseEst0 = exp_sidNoiseEst1;
+ move16();
}
sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = exp_sidNoiseEst0;
+ move16();
sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp = exp_sidNoiseEst1;
+ move16();
+ test();
+ test();
IF( EQ_32( hCPE->element_brate, IVAS_SID_5k2 ) && GT_32( hCPE->last_element_brate, IVAS_SID_5k2 ) )
{
/* in the first SID frame after an active frame, create mid noise shape here, in SID frames that follow inactive frames, it is done directly in the SID decoding since the mid shape is being used in CNG then */
FOR( int16_t p = 0; p < sts[0]->hFdCngDec->hFdCngCom->npart; p++ )
{
- Var1 = L_add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] >> 1, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p] >> 1 ); // exp_sidNoiseEst0 - 1
- sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = Mpy_32_32( float_to_fix( 0.5f, 31 ), Var1 ); // 31 - exp_sidNoiseEst0 - 1 + 31 - 31
+ Var1 = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); // exp_sidNoiseEst0 - 1
+ sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = Mpy_32_32( ONE_IN_Q30, Var1 ); // 31 - exp_sidNoiseEst0 - 1 + 31 - 31
+ move32();
}
}
@@ -1190,25 +1277,34 @@ void updateBuffersForDmxMdctStereo_fx(
IF( LE_32( hCPE->last_element_brate, IVAS_SID_5k2 ) )
{
delta = 1;
+ move16();
IF( EQ_16( output_frame, L_FRAME16k ) )
{
delta = 2;
+ move16();
}
ELSE IF( EQ_16( output_frame, L_FRAME32k ) )
{
delta = 4;
+ move16();
}
ELSE IF( EQ_16( output_frame, L_FRAME48k ) )
{
delta = 6;
+ move16();
}
delay_buf_out_len = i_mult( delta, HQ_DELAY_COMP );
tcxltp_mem_in_len = NS2SA_fx2( sts[0]->output_Fs, TCXLTP_DELAY_NS );
+ move16();
assert( delay_buf_out_len > tcxltp_mem_in_len );
Word16 sum_tcx_ltp = 0, sum_delay_buf = 0, sum_tcx_ltp_out = 0, sum_old_out = 0;
+ move16();
+ move16();
+ move16();
+ move16();
Copy_Scale_sig_32_16( &sts[0]->hTcxLtpDec->tcxltp_mem_in_32[0], &sts[0]->hTcxLtpDec->tcxltp_mem_in[0], TCXLTP_MAX_DELAY, -11 );
Copy_Scale_sig_32_16( &sts[1]->hTcxLtpDec->tcxltp_mem_in_32[0], &sts[1]->hTcxLtpDec->tcxltp_mem_in[0], TCXLTP_MAX_DELAY, -11 );
@@ -1216,11 +1312,15 @@ void updateBuffersForDmxMdctStereo_fx(
Copy_Scale_sig_32_16( &sts[0]->hTcxLtpDec->tcxltp_mem_out_32[0], &sts[0]->hTcxLtpDec->tcxltp_mem_out[0], L_FRAME48k, -11 );
Copy_Scale_sig_32_16( &sts[1]->hTcxLtpDec->tcxltp_mem_out_32[0], &sts[1]->hTcxLtpDec->tcxltp_mem_out[0], L_FRAME48k, -11 );
- sts[0]->hTcxLtpDec->exp_tcxltp_mem_in = 15 - norm_arr( sts[0]->hTcxLtpDec->tcxltp_mem_in, TCXLTP_MAX_DELAY );
- sts[1]->hTcxLtpDec->exp_tcxltp_mem_in = 15 - norm_arr( sts[1]->hTcxLtpDec->tcxltp_mem_in, TCXLTP_MAX_DELAY );
+ sts[0]->hTcxLtpDec->exp_tcxltp_mem_in = sub( 15, norm_arr( sts[0]->hTcxLtpDec->tcxltp_mem_in, TCXLTP_MAX_DELAY ) );
+ move16();
+ sts[1]->hTcxLtpDec->exp_tcxltp_mem_in = sub( 15, norm_arr( sts[1]->hTcxLtpDec->tcxltp_mem_in, TCXLTP_MAX_DELAY ) );
+ move16();
- sts[0]->hTcxLtpDec->exp_tcxltp_mem_out = 15 - norm_arr( sts[0]->hTcxLtpDec->tcxltp_mem_out, L_FRAME48k );
- sts[1]->hTcxLtpDec->exp_tcxltp_mem_out = 15 - norm_arr( sts[1]->hTcxLtpDec->tcxltp_mem_out, L_FRAME48k );
+ sts[0]->hTcxLtpDec->exp_tcxltp_mem_out = sub( 15, norm_arr( sts[0]->hTcxLtpDec->tcxltp_mem_out, L_FRAME48k ) );
+ move16();
+ sts[1]->hTcxLtpDec->exp_tcxltp_mem_out = sub( 15, norm_arr( sts[1]->hTcxLtpDec->tcxltp_mem_out, L_FRAME48k ) );
+ move16();
Scale_sig( &sts[0]->hTcxLtpDec->tcxltp_mem_in[0], TCXLTP_MAX_DELAY, sub( 15, sts[0]->hTcxLtpDec->exp_tcxltp_mem_in ) );
@@ -1243,15 +1343,19 @@ void updateBuffersForDmxMdctStereo_fx(
{
sum_tcx_ltp = add( shr( sts[0]->hTcxLtpDec->tcxltp_mem_in[i], 1 ), shr( sts[1]->hTcxLtpDec->tcxltp_mem_in[i], 1 ) ); // exp_tcxltp_mem_in + 1
sts[0]->hTcxLtpDec->tcxltp_mem_in[i] = mult( INV_SQRT2_FX_Q15, sum_tcx_ltp ); // 14 - exp_tcxltp_mem_in - 1
+ move16();
sum_delay_buf = add( sts[0]->delay_buf_out_fx[i], sts[1]->delay_buf_out_fx[i] );
sts[0]->delay_buf_out_fx[i] = mult( INV_SQRT2_FX_Q15, sum_delay_buf ); // exp_delay_buf_sum
+ move16();
sum_old_out = add( shr( sts[0]->hHQ_core->old_out_fx[i], 1 ), shr( sts[1]->hHQ_core->old_out_fx[i], 1 ) );
sts[0]->hHQ_core->old_out_fx[i] = mult( INV_SQRT2_FX_Q15, sum_old_out ); // exp_old_out_sum
+ move16();
sum_tcx_ltp_out = add( shr( sts[0]->hTcxLtpDec->tcxltp_mem_out[i], 1 ), shr( sts[1]->hTcxLtpDec->tcxltp_mem_out[i], 1 ) );
sts[0]->hTcxLtpDec->tcxltp_mem_out[i] = mult( INV_SQRT2_FX_Q15, sum_tcx_ltp_out ); // exp_tcs_ltp_out_sm
+ move16();
}
@@ -1259,25 +1363,33 @@ void updateBuffersForDmxMdctStereo_fx(
{
sum_delay_buf = add( sts[0]->delay_buf_out_fx[i], sts[1]->delay_buf_out_fx[i] );
sts[0]->delay_buf_out_fx[i] = mult( INV_SQRT2_FX_Q15, sum_delay_buf ); // exp_delay_buf_sum
+ move16();
sum_old_out = add( shr( sts[0]->hHQ_core->old_out_fx[i], 1 ), shr( sts[1]->hHQ_core->old_out_fx[i], 1 ) );
sts[0]->hHQ_core->old_out_fx[i] = mult( INV_SQRT2_FX_Q15, sum_old_out );
+ move16();
sum_tcx_ltp_out = add( shr( sts[0]->hTcxLtpDec->tcxltp_mem_out[i], 1 ), shr( sts[1]->hTcxLtpDec->tcxltp_mem_out[i], 1 ) );
sts[0]->hTcxLtpDec->tcxltp_mem_out[i] = mult( INV_SQRT2_FX_Q15, sum_tcx_ltp_out ); // exp_tcs_ltp_out_sm
+ move16();
}
FOR( ; i < output_frame; i++ )
{
sum_old_out = add( shr( sts[0]->hHQ_core->old_out_fx[i], 1 ), shr( sts[1]->hHQ_core->old_out_fx[i], 1 ) );
sts[0]->hHQ_core->old_out_fx[i] = mult( INV_SQRT2_FX_Q15, sum_old_out ); // exp_old_out_sum
+ move16();
sum_tcx_ltp_out = add( shr( sts[0]->hTcxLtpDec->tcxltp_mem_out[i], 1 ), shr( sts[1]->hTcxLtpDec->tcxltp_mem_out[i], 1 ) );
sts[0]->hTcxLtpDec->tcxltp_mem_out[i] = mult( INV_SQRT2_FX_Q15, sum_tcx_ltp_out ); // 15 + exp_tcs_ltp_out_sm - 15
+ move16();
}
sts[0]->hTcxLtpDec->exp_tcxltp_mem_in = add( sts[0]->hTcxLtpDec->exp_tcxltp_mem_in, 1 );
+ move16();
sts[0]->hHQ_core->exp_old_out = add( sts[0]->hHQ_core->exp_old_out, 1 );
+ move16();
sts[0]->hTcxLtpDec->exp_tcxltp_mem_out = add( sts[0]->hTcxLtpDec->exp_tcxltp_mem_out, 1 );
+ move16();
Copy_Scale_sig_16_32( &sts[0]->hTcxLtpDec->tcxltp_mem_in[0], &sts[0]->hTcxLtpDec->tcxltp_mem_in_32[0], TCXLTP_MAX_DELAY, sub( 11, sub( 15, sts[0]->hTcxLtpDec->exp_tcxltp_mem_in ) ) );
Copy_Scale_sig_16_32( &sts[0]->hTcxLtpDec->tcxltp_mem_out[0], &sts[0]->hTcxLtpDec->tcxltp_mem_out_32[0], TCXLTP_MAX_DELAY, sub( 11, sub( 15, sts[0]->hTcxLtpDec->exp_tcxltp_mem_out ) ) );
@@ -1445,6 +1557,7 @@ void applyDmxMdctStereo_fx(
IF( LE_32( hCPE->last_element_brate, IVAS_SID_5k2 ) )
{
crossfade_len = NS2SA( hCPE->hCoreCoder[0]->output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS );
+ move16();
SWITCH( hCPE->hCoreCoder[0]->output_Fs )
{
case 48000:
@@ -1491,6 +1604,7 @@ void applyDmxMdctStereo_fx(
ELSE IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && LE_32( hCPE->last_element_brate, IVAS_32k ) )
{
crossfade_len = NS2SA( hCPE->hCoreCoder[0]->output_Fs, DELAY_CLDFB_NS );
+ move16();
SWITCH( hCPE->hCoreCoder[0]->output_Fs )
{
case 48000:
diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c
index f3253d728de8297b87f1f4d88e42706bf4be7c2d..6ec395ccc3799bab7da70e3035c3f061c5d64699 100644
--- a/lib_dec/ivas_stereo_switching_dec.c
+++ b/lib_dec/ivas_stereo_switching_dec.c
@@ -35,16 +35,17 @@
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "ivas_rom_com.h"
#include "assert.h"
#include "wmc_auto.h"
#include
-#include "prot_fx2.h"
#include "ivas_prot_fx.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "prot_fx.h"
+#include "ivas_rom_com_fx.h"
+#endif
/*-------------------------------------------------------------------*
* Local constants
@@ -384,7 +385,7 @@ static ivas_error allocate_CoreCoder_fx(
IF( st->cldfbAna == NULL )
{
/* open analysis for max. sampling rate 48kHz */
- IF( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -393,7 +394,7 @@ static ivas_error allocate_CoreCoder_fx(
IF( st->cldfbBPF == NULL )
{
/* open analysis BPF for max. internal sampling rate 16kHz */
- IF( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -579,7 +580,7 @@ static void cpy_tcx_ltp_data_fx(
const int32_t output_Fs /* i : output sampling rate */
)
{
- Word16 sz, e;
+ Word16 sz;
hTcxLtpDecNew->tcxltp_pitch_int_post_prev = hTcxLtpDecOld->tcxltp_pitch_int_post_prev;
move16();
hTcxLtpDecNew->tcxltp_pitch_fr_post_prev = hTcxLtpDecOld->tcxltp_pitch_fr_post_prev;
@@ -588,14 +589,14 @@ static void cpy_tcx_ltp_data_fx(
move16();
hTcxLtpDecNew->tcxltp_filt_idx_prev = hTcxLtpDecOld->tcxltp_filt_idx_prev;
move16();
- sz = BASOP_Util_Divide3232_Scale( TCXLTP_MAX_DELAY * output_Fs, 48000, &e );
- sz = shr( sz, sub( 15, e ) );
- mvs2s( hTcxLtpDecOld->tcxltp_mem_in, hTcxLtpDecNew->tcxltp_mem_in, sz ); // TODO: One of these will be removed later
- mvl2l( hTcxLtpDecOld->tcxltp_mem_in_32, hTcxLtpDecNew->tcxltp_mem_in_32, sz );
- sz = BASOP_Util_Divide3232_Scale( ( L_FRAME48k * output_Fs ), 48000, &e );
- sz = shr( sz, sub( 15, e ) );
- mvs2s( hTcxLtpDecOld->tcxltp_mem_out, hTcxLtpDecNew->tcxltp_mem_out, sz ); // TODO: One of these will be removed later
- mvl2l( hTcxLtpDecOld->tcxltp_mem_out_32, hTcxLtpDecNew->tcxltp_mem_out_32, sz );
+ /* (int16_t) ( ( TCXLTP_MAX_DELAY * output_Fs ) / 48000 ) */
+ sz = extract_l( Mpy_32_32_r( TCXLTP_MAX_DELAY * output_Fs, 44739 /* 1 / 48000 in Q31 */ ) );
+ Copy( hTcxLtpDecOld->tcxltp_mem_in, hTcxLtpDecNew->tcxltp_mem_in, sz ); // TODO: One of these will be removed later
+ Copy32( hTcxLtpDecOld->tcxltp_mem_in_32, hTcxLtpDecNew->tcxltp_mem_in_32, sz );
+ /* (int16_t) ( ( L_FRAME48k * output_Fs ) / 48000 ) */
+ sz = extract_l( Mpy_32_32_r( L_FRAME48k * output_Fs, 44739 /* 1 / 48000 in Q31 */ ) );
+ Copy( hTcxLtpDecOld->tcxltp_mem_out, hTcxLtpDecNew->tcxltp_mem_out, sz ); // TODO: One of these will be removed later
+ Copy32( hTcxLtpDecOld->tcxltp_mem_out_32, hTcxLtpDecNew->tcxltp_mem_out_32, sz );
return;
}
@@ -1279,7 +1280,7 @@ ivas_error stereo_memory_dec_fx(
DEC_CORE_HANDLE st;
Word16 i, n, delay_comp_DFT;
ivas_error error;
- Word16 div_m, div_e;
+ Word16 div_m, div_e, tmp16;
error = IVAS_ERR_OK;
@@ -1296,6 +1297,8 @@ ivas_error stereo_memory_dec_fx(
*---------------------------------------------------------------*/
/* handling of DFT->TD switching */
+ test();
+ test();
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) )
{
delay_comp_DFT = NS2SA( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS );
@@ -1308,20 +1311,22 @@ ivas_error stereo_memory_dec_fx(
{
div_m = BASOP_Util_Divide3216_Scale( hCPE->output_mem_fx[n][sub( i, delay_comp_DFT )], hCPE->hStereoDft->win32ms_fx[i_mult( STEREO_DFT32MS_STEP, ( sub( add( sub( hCPE->hStereoDft->dft32ms_ovl, 1 ), delay_comp_DFT ), i ) ) )], &div_e );
hCPE->output_mem_fx[n][sub( i, delay_comp_DFT )] = L_shl( div_m, add( div_e, 16 ) );
+ move32();
// hCPE->output_mem_fx[n][sub(i, delay_comp_DFT)] = hCPE->hStereoDft->win32ms_fx[i_mult(STEREO_DFT32MS_STEP, ( sub(add(sub(hCPE->hStereoDft->dft32ms_ovl, 1), delay_comp_DFT), i) ))];
}
}
- IF( NE_16( hCPE->hCoreCoder[0]->last_core, ACELP_CORE ) )
+ IF( hCPE->hCoreCoder[0]->last_core != ACELP_CORE )
{
- mvl2l( hCPE->hStereoDft->buff_LBTCX_mem_fx, hCPE->input_mem_LB_fx[0], NS2SA( i_mult( hCPE->hCoreCoder[0]->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) );
+ Copy32( hCPE->hStereoDft->buff_LBTCX_mem_fx, hCPE->input_mem_LB_fx[0], NS2SA( i_mult( hCPE->hCoreCoder[0]->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) );
}
}
+ test();
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- v_add_32( hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, hCPE->hCoreCoder[1]->hHQ_core->oldOut_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, (int16_t) ( output_Fs / FRAMES_PER_SEC ) );
- v_multc_fixed_16( hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, 16384 /* 0.5 in Q15 */, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, (int16_t) ( output_Fs / FRAMES_PER_SEC ) );
+ v_add_32( hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, hCPE->hCoreCoder[1]->hHQ_core->oldOut_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) );
+ v_multc_fixed_16( hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, 16384 /* 0.5 in Q15 */, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) );
v_add_32( hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, hCPE->hCoreCoder[1]->hHQ_core->old_outLB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k );
v_multc_fixed_16( hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, 16384, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k );
@@ -1356,7 +1361,7 @@ ivas_error stereo_memory_dec_fx(
deallocate_CoreCoder_fx( hCPE->hCoreCoder[1] );
/* allocate DFT stereo data structure */
- IF( NE_16( ( error = stereo_dft_dec_create_fx( &( hCPE->hStereoDft ), hCPE->element_brate, output_Fs, 0, nchan_transport ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = stereo_dft_dec_create_fx( &( hCPE->hStereoDft ), hCPE->element_brate, output_Fs, 0, nchan_transport ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1368,7 +1373,7 @@ ivas_error stereo_memory_dec_fx(
}
/* memory update - needed in TD stereo, TCX/HQ frame -> DFT stereo, ACELP frame switching */
- mvl2l( hCPE->input_mem_LB_fx[0], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( s_min( hCPE->hCoreCoder[0]->last_L_frame * FRAMES_PER_SEC, 16000 ), STEREO_DFT32MS_OVL_NS ) );
+ Copy32( hCPE->input_mem_LB_fx[0], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( s_min( i_mult( hCPE->hCoreCoder[0]->last_L_frame, FRAMES_PER_SEC ), 16000 ), STEREO_DFT32MS_OVL_NS ) );
/* allocate ICBWE structure */
IF( hCPE->hStereoICBWE == NULL )
@@ -1449,7 +1454,7 @@ ivas_error stereo_memory_dec_fx(
stereo_td_init_dec_fx( hCPE->hStereoTD, hCPE->last_element_mode );
/* allocate CoreCoder secondary channel */
- IF( NE_16( ( error = allocate_CoreCoder_fx( hCPE->hCoreCoder[1] ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = allocate_CoreCoder_fx( hCPE->hCoreCoder[1] ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1459,6 +1464,8 @@ ivas_error stereo_memory_dec_fx(
* allocate DFT/TD stereo structures after MDCT stereo frame
*---------------------------------------------------------------*/
+ test();
+ test();
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) && ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) || EQ_16( hCPE->element_mode, IVAS_CPE_TD ) ) )
{
/* deallocated TCX-LTP for second channel */
@@ -1473,11 +1480,11 @@ ivas_error stereo_memory_dec_fx(
{
/* re-use an existing buffer for MDCT->TD stereo switching */
Word16 nZeros, len;
- nZeros = (Word16) ( NS2SA( st->output_Fs, N_ZERO_MDCT_NS ) );
+ nZeros = extract_l( NS2SA( st->output_Fs, N_ZERO_MDCT_NS ) );
move16();
len = NS2SA( st->output_Fs, 3000000 );
move16();
- mvl2l( st->hHQ_core->oldOut_fx + nZeros, hCPE->output_mem_fx[1], len );
+ Copy32( st->hHQ_core->oldOut_fx + nZeros, hCPE->output_mem_fx[1], len );
}
/* deallocated HQ-core for second channel */
@@ -1488,6 +1495,7 @@ ivas_error stereo_memory_dec_fx(
}
/* allocate DFT stereo mono DMX data structure */
+ test();
IF( EQ_16( hCPE->nchan_out, 1 ) && hCPE->hStereoDftDmx == NULL )
{
IF( ( hCPE->hStereoDftDmx = (STEREO_DFT_DMX_DATA_HANDLE) malloc( sizeof( STEREO_DFT_DMX_DATA ) ) ) == NULL )
@@ -1499,6 +1507,7 @@ ivas_error stereo_memory_dec_fx(
}
/* allocate TCA data structure */
+ test();
IF( NE_16( hCPE->nchan_out, 1 ) && hCPE->hStereoTCA == NULL )
{
IF( ( hCPE->hStereoTCA = (STEREO_TCA_DEC_HANDLE) malloc( sizeof( STEREO_TCA_DEC_DATA ) ) ) == NULL )
@@ -1512,7 +1521,7 @@ ivas_error stereo_memory_dec_fx(
st = hCPE->hCoreCoder[0];
/* allocate primary channel substructures */
- IF( NE_16( ( error = allocate_CoreCoder_fx( st ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = allocate_CoreCoder_fx( st ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1528,9 +1537,13 @@ ivas_error stereo_memory_dec_fx(
td_bwe_dec_init_ivas_fx( st, st->hBWE_TD, st->output_Fs );
st->prev_Q_bwe_exc = 31;
+ move16();
st->prev_Qx = 0;
+ move16();
st->prev_ener_fx_Q = 31;
+ move16();
st->prev_frame_pow_exp = 0;
+ move16();
IF( ( st->hBWE_FD = (FD_BWE_DEC_HANDLE) malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL )
{
@@ -1549,15 +1562,18 @@ ivas_error stereo_memory_dec_fx(
#endif
fd_bwe_dec_init( st, st->hBWE_FD );
st->hBWE_FD->old_wtda_swb_fx_exp = 0;
+ move16();
st->hBWE_FD->mem_imdct_exp_fx = 0;
+ move16();
st->prev_Q_synth = 0;
+ move16();
}
/* Allocated FD_CNG instance for primary channel*/
IF( st->hFdCngDec == NULL )
{
/* Create FD_CNG instance */
- IF( ( error = createFdCngDec_fx( &st->hFdCngDec ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = createFdCngDec_fx( &st->hFdCngDec ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1589,7 +1605,7 @@ ivas_error stereo_memory_dec_fx(
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_TD ) )
{
- mvl2l( hCPE->hStereoTD->TCX_old_syn_Overl_fx, tmpF_buff, L_FRAME16k / 2 );
+ Copy32( hCPE->hStereoTD->TCX_old_syn_Overl_fx, tmpF_buff, L_FRAME16k / 2 );
}
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
@@ -1647,7 +1663,7 @@ ivas_error stereo_memory_dec_fx(
IF( st->cldfbAna == NULL )
{
- IF( NE_16( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1656,14 +1672,14 @@ ivas_error stereo_memory_dec_fx(
IF( st->cldfbBPF == NULL )
{
/* open analysis BPF for max. internal sampling rate 16kHz */
- IF( NE_16( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
{
return error;
}
}
/* allocate Fd-Cng structure for second channel */
- IF( NE_16( ( error = createFdCngDec_fx( &st->hFdCngDec ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = createFdCngDec_fx( &st->hFdCngDec ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1674,13 +1690,14 @@ ivas_error stereo_memory_dec_fx(
initFdCngDec( st );
#endif
- IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
+ if ( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
st->last_core = ACELP_CORE; /* needed to set-up TCX core in SetTCXModeInfo() */
+ move16();
}
/*Allocate CoreCoder TCX modules for second channel */
- IF( NE_16( ( error = allocate_CoreCoder_TCX_fx( hCPE->hCoreCoder[1] ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = allocate_CoreCoder_TCX_fx( hCPE->hCoreCoder[1] ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1699,7 +1716,7 @@ ivas_error stereo_memory_dec_fx(
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_TD ) )
{
- mvl2l( tmpF_buff, st->hTcxDec->old_syn_Overl_32, L_FRAME16k / 2 );
+ Copy32( tmpF_buff, st->hTcxDec->old_syn_Overl_32, L_FRAME16k / 2 );
Copy_Scale_sig32_16( st->hTcxDec->old_syn_Overl_32, st->hTcxDec->old_syn_Overl, L_FRAME16k / 2, add( st->Q_syn, 5 ) ); //(st->Qsyn - (11 - 16))
}
@@ -1742,12 +1759,22 @@ ivas_error stereo_memory_dec_fx(
IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
{
- IF( EQ_16( hCPE->hCoreCoder[0]->bfi, 0 ) )
+ IF( hCPE->hCoreCoder[0]->bfi == 0 )
{
st = hCPE->hCoreCoder[1];
- hCPE->hStereoTD->tdm_LRTD_flag = get_indice_st( hCPE->hCoreCoder[0], hCPE->element_brate + hCPE->brate_surplus, (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata + ( hCPE->brate_surplus / FRAMES_PER_SEC ) - TDM_SECONDARY_SIGNALLING - TDM_RATIO_BITS - TDM_LP_REUSE_BITS - TDM_LR_CONTENT_BITS ), TDM_LR_CONTENT_BITS );
+ IF( hCPE->brate_surplus < 0 )
+ {
+ tmp16 = extract_l( L_negate( Mpy_32_32( L_abs( hCPE->brate_surplus ), ONE_BY_FRAMES_PER_SEC_Q31 ) ) );
+ }
+ ELSE
+ {
+ tmp16 = extract_l( Mpy_32_32( hCPE->brate_surplus, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+ }
+
+ hCPE->hStereoTD->tdm_LRTD_flag = get_indice_st( hCPE->hCoreCoder[0], L_add( hCPE->element_brate, hCPE->brate_surplus ), ( sub( add( sub( extract_l( Mpy_32_16_1( hCPE->element_brate, INV_FRAME_PER_SEC_Q15 ) ), nb_bits_metadata ), tmp16 ), ( TDM_SECONDARY_SIGNALLING + TDM_RATIO_BITS + TDM_LP_REUSE_BITS + TDM_LR_CONTENT_BITS ) ) ), TDM_LR_CONTENT_BITS );
+ move16();
- IF( NE_16( hCPE->hStereoTD->tdm_LRTD_flag, 0 ) )
+ IF( hCPE->hStereoTD->tdm_LRTD_flag != 0 )
{
/* deallocate ICBWE structure */
IF( hCPE->hStereoICBWE != NULL )
@@ -1767,9 +1794,13 @@ ivas_error stereo_memory_dec_fx(
td_bwe_dec_init_ivas_fx( st, st->hBWE_TD, st->output_Fs );
st->prev_Q_bwe_exc = 31;
+ move16();
st->prev_Qx = 0;
+ move16();
st->prev_ener_fx_Q = 31;
+ move16();
st->prev_frame_pow_exp = 0;
+ move16();
IF( ( st->hBWE_FD = (FD_BWE_DEC_HANDLE) malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL )
{
@@ -1788,8 +1819,11 @@ ivas_error stereo_memory_dec_fx(
#endif
fd_bwe_dec_init( st, st->hBWE_FD );
st->hBWE_FD->old_wtda_swb_fx_exp = 0;
+ move16();
st->hBWE_FD->mem_imdct_exp_fx = 0;
+ move16();
st->prev_Q_synth = 0;
+ move16();
}
}
ELSE /* tdm_LRTD_flag == 0 */
@@ -1828,11 +1862,13 @@ ivas_error stereo_memory_dec_fx(
* MDCT stereo bitrate switching
*---------------------------------------------------------------*/
+ test();
IF( EQ_16( ivas_format, STEREO_FORMAT ) && EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
+ test();
IF( LE_32( hCPE->element_brate, MAX_MDCT_ITD_BRATE ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) )
{
- IF( EQ_16( hCPE->hStereoMdct->use_itd, 0 ) )
+ IF( hCPE->hStereoMdct->use_itd == 0 )
{
IF( hCPE->hStereoTCA == NULL )
{
@@ -1852,14 +1888,17 @@ ivas_error stereo_memory_dec_fx(
ELSE
{
/* de-allocate TCA data structure */
- IF( hCPE->hStereoMdct->use_itd == 1 && ivas_total_brate > IVAS_SID_5k2 && hCPE->hStereoTCA != NULL )
+ test();
+ test();
+ test();
+ IF( EQ_16( hCPE->hStereoMdct->use_itd, 1 ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) && hCPE->hStereoTCA != NULL )
{
free( hCPE->hStereoTCA );
hCPE->hStereoTCA = NULL;
hCPE->hStereoMdct->use_itd = 0;
move16();
}
- ELSE IF( hCPE->hStereoMdct->use_itd == 1 && ivas_total_brate <= IVAS_SID_5k2 )
+ ELSE IF( EQ_16( hCPE->hStereoMdct->use_itd, 1 ) && LE_32( ivas_total_brate, IVAS_SID_5k2 ) )
{
hCPE->hStereoMdct->itd_fx = 0;
move32();
@@ -1876,6 +1915,8 @@ ivas_error stereo_memory_dec_fx(
* Bitrate switching in MASA format
*---------------------------------------------------------------*/
+ test();
+ test();
IF( ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) && EQ_16( nchan_transport, 2 ) )
{
IF( EQ_16( hCPE->nchan_out, 1 ) )
@@ -1962,8 +2003,10 @@ ivas_error stereo_memory_dec_fx(
* Bitrate switching in MASA format
*---------------------------------------------------------------*/
+ test();
IF( EQ_16( ivas_format, MC_FORMAT ) && EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
+ test();
IF( EQ_16( mc_mode, MC_MODE_MCT ) || EQ_16( mc_mode, MC_MODE_PARAMUPMIX ) )
{
/* deallocate the FdCNG handle */
@@ -1979,7 +2022,7 @@ ivas_error stereo_memory_dec_fx(
{
IF( hCPE->hCoreCoder[i]->cldfbSyn == NULL ) /* could be NULL when we had the MCT LFE channel */
{
- IF( NE_16( ( error = openCldfb_ivas_fx( &hCPE->hCoreCoder[i]->cldfbSyn, CLDFB_SYNTHESIS, hCPE->hCoreCoder[i]->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = openCldfb_ivas_fx( &hCPE->hCoreCoder[i]->cldfbSyn, CLDFB_SYNTHESIS, hCPE->hCoreCoder[i]->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1987,7 +2030,7 @@ ivas_error stereo_memory_dec_fx(
IF( hCPE->hCoreCoder[i]->hFdCngDec == NULL )
{
- IF( NE_16( ( error = createFdCngDec_fx( &hCPE->hCoreCoder[i]->hFdCngDec ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = createFdCngDec_fx( &hCPE->hCoreCoder[i]->hFdCngDec ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2388,34 +2431,55 @@ void synchro_synthesis_fx(
Word16 dft_mono_brate_switch;
Word16 delay_diff;
Word32 tmpF_fx = 0;
+ move32();
Word16 nChannels;
sts = hCPE->hCoreCoder;
output_Fs = sts[0]->output_Fs;
use_cldfb_for_last_dft = 0;
- IF( ( hCPE->element_mode != IVAS_CPE_DFT && hCPE->nchan_out == 1 && hCPE->last_element_brate <= IVAS_24k4 ) /* note: this is to mimic the DFT stereo condition "hCPE->hStereoDft->hConfig->res_cod_mode == 0" in last frame */
- || ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) )
+ move16();
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ if ( ( NE_16( hCPE->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && LE_32( hCPE->last_element_brate, IVAS_24k4 ) ) /* note: this is to mimic the DFT stereo condition "hCPE->hStereoDft->hConfig->res_cod_mode == 0" in last frame */
+ || ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) )
{
use_cldfb_for_last_dft = 1;
+ move16();
}
dft_mono_brate_switch = 0;
- IF( hCPE->element_mode == IVAS_CPE_DFT && ( hCPE->last_element_mode == IVAS_CPE_DFT || hCPE->last_element_mode == IVAS_CPE_MDCT ) && hCPE->nchan_out == 1 && hCPE->element_brate != hCPE->last_element_brate )
+ move16();
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && ( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) || EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) ) && EQ_16( hCPE->nchan_out, 1 ) && NE_32( hCPE->element_brate, hCPE->last_element_brate ) )
{
- IF( hCPE->last_element_brate >= IVAS_32k && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF )
+ test();
+ test();
+ IF( GE_32( hCPE->last_element_brate, IVAS_32k ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) )
{
dft_mono_brate_switch = -1; /* switch from residual coding mode or MDCT Stereo */
+ move16();
}
- ELSE IF( hCPE->last_element_brate <= IVAS_24k4 && hCPE->hStereoDft->hConfig->res_cod_mode > STEREO_DFT_RES_COD_OFF )
+ ELSE IF( LE_32( hCPE->last_element_brate, IVAS_24k4 ) && GT_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) )
{
dft_mono_brate_switch = 1; /* switch to residual coding mode*/
+ move16();
}
}
IF( use_cldfb_for_last_dft )
{
- IF( hCPE->element_mode == IVAS_CPE_DFT && hCPE->last_element_mode == IVAS_CPE_TD && ( ivas_total_brate > IVAS_SID_5k2 || hCPE->nchan_out == 2 ) )
+ test();
+ test();
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_TD ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_16( hCPE->nchan_out, 2 ) ) )
{
stereo_tca_scale_R_channel_fx( hCPE, output_fx[0], output_frame );
}
@@ -2423,14 +2487,18 @@ void synchro_synthesis_fx(
/* set delays */
delay_comp_DFT = NS2SA( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS );
+ move16();
delay_comp_TD = NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS );
- delay_diff = delay_comp_TD - delay_comp_DFT;
+ move16();
+ delay_diff = sub( delay_comp_TD, delay_comp_DFT );
- dft32ms_ovl = (Word16) ( ( STEREO_DFT32MS_OVL_MAX * output_Fs ) / 48000 );
+ dft32ms_ovl = extract_l( Mpy_32_32( imult3216( output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) );
delay_cldfb = NS2SA( output_Fs, DELAY_CLDFB_NS );
+ move16();
/* initialize pointers */
- IF( hCPE->element_mode >= IVAS_CPE_DFT && hCPE->output_mem_fx[0] != NULL )
+ test();
+ IF( GE_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->output_mem_fx[0] != NULL )
{
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
@@ -2442,28 +2510,33 @@ void synchro_synthesis_fx(
* DFT stereo synchro
*----------------------------------------------------------------*/
- IF( hCPE->element_mode == IVAS_CPE_DFT || sba_dirac_stereo_flag )
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) || sba_dirac_stereo_flag )
{
/* handling of bitrate switching from residual (using DFT) to non-residual mode (using CLDFB) FOR mono output - as in DFT->TD switching */
- IF( dft_mono_brate_switch == -1 )
+ IF( EQ_16( dft_mono_brate_switch, -1 ) )
{
FOR( i = delay_comp_DFT; i < delay_comp_TD; i++ )
{
- sts[0]->prev_synth_buffer32_fx[i] = p_output_mem_fx[0][i - delay_comp_DFT];
+ sts[0]->prev_synth_buffer32_fx[i] = p_output_mem_fx[0][sub( i, delay_comp_DFT )];
+ move32();
}
- FOR( i = delay_comp_TD; i < delay_comp_TD + delay_cldfb; i++ )
+ FOR( i = delay_comp_TD; i < add( delay_comp_TD, delay_cldfb ); i++ )
{
- tmp_out_fx[0][i - delay_comp_TD] = p_output_mem_fx[0][i - delay_comp_DFT];
+ tmp_out_fx[0][sub( i, delay_comp_TD )] = p_output_mem_fx[0][sub( i, delay_comp_DFT )];
+ move32();
}
}
- IF( hCPE->nchan_out == 1 && hCPE->last_element_mode == IVAS_CPE_MDCT )
+ test();
+ IF( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
{
FOR( Word32 ind = 0; ind < delay_comp_DFT; ind++ )
{
- Word32 temp = sts[0]->prev_synth_buffer32_fx[ind] + sts[1]->prev_synth_buffer32_fx[ind];
+ Word32 temp = L_add( sts[0]->prev_synth_buffer32_fx[ind], sts[1]->prev_synth_buffer32_fx[ind] );
sts[0]->prev_synth_buffer32_fx[ind] = Mpy_32_32( temp, INV_SQRT2_FX );
+ move32();
}
}
@@ -2474,7 +2547,7 @@ void synchro_synthesis_fx(
delay_signal_fx( output_fx[0], output_frame, hCPE->hCoreCoder[0]->hTcxDec->FBTCXdelayBuf_32, delay_diff );
}
- IF( hCPE->element_mode != IVAS_CPE_MDCT )
+ IF( NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
ivas_post_proc_fx( NULL, hCPE, 0, output_fx[0], output_fx, output_frame, sba_dirac_stereo_flag );
}
@@ -2491,9 +2564,10 @@ void synchro_synthesis_fx(
delay_signal_fx( output_fx[n], output_frame, sts[n]->prev_synth_buffer32_fx, delay_comp_DFT );
}
}
- IF( sba_dirac_stereo_flag )
+ if ( sba_dirac_stereo_flag )
{
hCPE->q_prev_synth_fx = hCPE->hStereoDft->q_dft;
+ move16();
}
IF( use_cldfb_for_last_dft )
{
@@ -2503,20 +2577,27 @@ void synchro_synthesis_fx(
/* handling of TD->DFT switching */
FOR( n = 0; n < hCPE->nchan_out; n++ )
{
- IF( ( hCPE->last_element_mode != IVAS_CPE_DFT && !sba_dirac_stereo_flag && dft_mono_brate_switch != -1 ) || dft_mono_brate_switch == 1 )
+ test();
+ test();
+ test();
+ IF( ( NE_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && !sba_dirac_stereo_flag && NE_16( dft_mono_brate_switch, -1 ) ) || EQ_16( dft_mono_brate_switch, 1 ) )
{
Word32 *pPrev_synth_fx;
Word32 inv_fade_len_fx = 0;
+ move32();
SWITCH( output_Fs )
{
case 16000:
inv_fade_len_fx = 71582792;
+ move32();
BREAK;
case 32000:
inv_fade_len_fx = 35791396;
+ move32();
BREAK;
case 48000:
inv_fade_len_fx = 23860930;
+ move32();
BREAK;
default:
assert( 0 );
@@ -2526,63 +2607,79 @@ void synchro_synthesis_fx(
IF( sba_dirac_stereo_flag )
{
pPrev_synth_fx = hCPE->prev_synth_fx[n];
+ move32();
}
ELSE
{
pPrev_synth_fx = sts[n]->prev_synth_buffer32_fx;
+ move32();
}
- IF( hCPE->last_element_mode != IVAS_CPE_MDCT )
+ IF( NE_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
{
FOR( i = delay_comp_DFT; i < delay_comp_TD; i++ )
{
- Word64 res1 = (Word64) pPrev_synth_fx[i] * ( delay_comp_TD - i );
- Word64 res2 = (Word64) output_fx[n][i] * ( i - delay_comp_DFT );
- Word64 res = W_shr( res1, 6 ) + W_shr( res2, 6 );
+ Word64 res1 = W_mult0_32_32( pPrev_synth_fx[i], ( sub( delay_comp_TD, i ) ) );
+ Word64 res2 = W_mult0_32_32( output_fx[n][i], ( sub( i, delay_comp_DFT ) ) );
+ Word64 res = W_add( W_shr( res1, 6 ), W_shr( res2, 6 ) );
res = res * inv_fade_len_fx;
- output_fx[n][i] = (Word32) W_shr( res, 31 - 6 );
+ move64();
+ output_fx[n][i] = W_extract_l( W_shr( res, 31 - 6 ) );
+ move32();
// change 6 to less number to get better precision
}
}
}
- ELSE IF( dft_mono_brate_switch == -1 )
+ ELSE IF( EQ_16( dft_mono_brate_switch, -1 ) )
{
Word32 inv_fade_len_1_fx = 0;
+ move32();
Word32 inv_fade_len_2_fx = 0;
+ move32();
SWITCH( output_Fs )
{
case 16000:
inv_fade_len_1_fx = 71582792;
+ move32();
inv_fade_len_2_fx = 107374184;
+ move32();
BREAK;
case 32000:
inv_fade_len_1_fx = 35791396;
+ move32();
inv_fade_len_2_fx = 53687092;
+ move32();
BREAK;
case 48000:
inv_fade_len_1_fx = 23860930;
+ move32();
inv_fade_len_2_fx = 35791396;
+ move32();
BREAK;
default:
assert( 0 );
}
FOR( i = 0; i < delay_diff; i++ )
{
- Word64 res1 = (Word64) output_fx[0][i + delay_comp_DFT] * ( delay_diff - i );
- Word64 res2 = (Word64) p_output_mem_fx[0][i] * i;
- Word64 res = W_shr( res1, 6 ) + W_shr( res2, 6 );
+ Word64 res1 = W_mult0_32_32( output_fx[0][add( i, delay_comp_DFT )], ( sub( delay_diff, i ) ) );
+ Word64 res2 = W_mult0_32_32( p_output_mem_fx[0][i], i );
+ Word64 res = W_add( W_shr( res1, 6 ), W_shr( res2, 6 ) );
res = res * inv_fade_len_1_fx;
- output_fx[0][i + delay_comp_DFT] = (Word32) W_shr( res, 31 - 6 );
+ move64();
+ output_fx[0][add( i, delay_comp_DFT )] = W_extract_l( W_shr( res, 31 - 6 ) );
+ move32();
}
FOR( i = 0; i < delay_cldfb; i++ )
{
- Word64 res1 = (Word64) tmp_out_fx[0][i] * ( delay_cldfb - i );
- Word64 res2 = (Word64) output_fx[0][i + delay_comp_TD] * i;
- Word64 res = W_shr( res1, 6 ) + W_shr( res2, 6 );
+ Word64 res1 = W_mult0_32_32( tmp_out_fx[0][i], ( sub( delay_cldfb, i ) ) );
+ Word64 res2 = W_mult0_32_32( output_fx[0][add( i, delay_comp_TD )], i );
+ Word64 res = W_add( W_shr( res1, 6 ), W_shr( res2, 6 ) );
res = res * inv_fade_len_2_fx;
- output_fx[0][i + delay_comp_TD] = (Word32) W_shr( res, 31 - 6 );
+ move64();
+ output_fx[0][add( i, delay_comp_TD )] = W_extract_l( W_shr( res, 31 - 6 ) );
+ move32();
}
}
}
@@ -2597,28 +2694,35 @@ void synchro_synthesis_fx(
return;
}
- IF( hCPE->element_mode == IVAS_CPE_TD || hCPE->element_mode == IVAS_CPE_MDCT )
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
/* handling of DFT->TD switching */
- IF( hCPE->last_element_mode == IVAS_CPE_DFT && !use_cldfb_for_last_dft && hCPE->output_mem_fx[0] != NULL )
+ test();
+ test();
+ IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_last_dft && hCPE->output_mem_fx[0] != NULL )
{
/* use redressed DFT stereo OLA part to reconstruct the TD stereo synchro memory */
FOR( n = 0; n < hCPE->nchan_out; n++ )
{
FOR( i = delay_comp_DFT; i < delay_comp_TD; i++ )
{
- sts[n]->prev_synth_buffer32_fx[i] = p_output_mem_fx[n][i - delay_comp_DFT];
+ sts[n]->prev_synth_buffer32_fx[i] = p_output_mem_fx[n][sub( i, delay_comp_DFT )];
+ move32();
}
- FOR( i = delay_comp_TD; i < delay_comp_TD + delay_cldfb; i++ )
+ FOR( i = delay_comp_TD; i < add( delay_comp_TD, delay_cldfb ); i++ )
{
- tmp_out_fx[n][i - delay_comp_TD] = p_output_mem_fx[n][i - delay_comp_DFT];
+ tmp_out_fx[n][sub( i, delay_comp_TD )] = p_output_mem_fx[n][sub( i, delay_comp_DFT )];
+ move32();
}
}
}
/* IF previous frame had only one channel copy buffers to other channel */
- IF( hCPE->nchan_out == 1 && hCPE->element_mode == IVAS_CPE_MDCT && hCPE->last_element_mode == IVAS_CPE_DFT )
+ test();
+ test();
+ IF( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
Copy32( sts[0]->prev_synth_buffer32_fx, sts[1]->prev_synth_buffer32_fx, delay_comp_TD );
Copy32( tmp_out_fx[0], tmp_out_fx[1], delay_cldfb );
@@ -2630,11 +2734,12 @@ void synchro_synthesis_fx(
*----------------------------------------------------------------*/
/* resample LB synthesis to output_Fs */
- IF( hCPE->element_mode != IVAS_CPE_MDCT && !use_cldfb_for_last_dft )
+ test();
+ IF( NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) && !use_cldfb_for_last_dft )
{
FOR( n = 0; n < hCPE->nchan_out; n++ )
{
- IF( sts[n]->core == ACELP_CORE )
+ IF( EQ_16( sts[n]->core, ACELP_CORE ) )
{
L_lerp_fx_q11( hCPE->input_mem_LB_fx[n], tmp_out_TD_fx[n], dft32ms_ovl, NS2SA( sts[n]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) );
}
@@ -2645,12 +2750,13 @@ void synchro_synthesis_fx(
/* use TCX synchro memory (perfect signal is available) */
FOR( i = delay_diff; i < dft32ms_ovl; i++ )
{
- tmp_out_TD_fx[n][i] = sts[n]->delay_buf_out32_fx[i - delay_diff];
+ tmp_out_TD_fx[n][i] = sts[n]->delay_buf_out32_fx[sub( i, delay_diff )];
+ move32();
}
}
}
- IF( hCPE->nchan_out == CPE_CHANNELS )
+ IF( EQ_16( hCPE->nchan_out, CPE_CHANNELS ) )
{
/* upmix the resampled LB / the TCX synchro memory */
tdm_upmix_plain_fx( tmp_out_TD2_fx[0], tmp_out_TD2_fx[1], tmp_out_TD_fx[0], tmp_out_TD_fx[1], tdm_ratio_tabl_fx[hCPE->hStereoTD->tdm_last_ratio_idx], tdm_den_ratio_tabl_fx[hCPE->hStereoTD->tdm_last_ratio_idx], 0, dft32ms_ovl, 1 );
@@ -2668,12 +2774,15 @@ void synchro_synthesis_fx(
{
case 16000:
tmpF_fx = 71582792;
+ move32();
BREAK;
case 32000:
tmpF_fx = 35791396;
+ move32();
BREAK;
case 48000:
tmpF_fx = 23860930;
+ move32();
BREAK;
default:
assert( 0 );
@@ -2682,11 +2791,12 @@ void synchro_synthesis_fx(
FOR( i = 0; i < delay_diff; i++ )
{
- Word64 res1 = (Word64) output_fx[n][output_frame - dft32ms_ovl + delay_cldfb + i] * ( delay_diff - i );
- Word64 res2 = (Word64) tmp_out_TD2_fx[n][i] * i;
- Word64 res = W_shr( res1, 6 ) + W_shr( res2, 6 );
+ Word64 res1 = W_mult0_32_32( output_fx[n][add( add( sub( output_frame, dft32ms_ovl ), delay_cldfb ), i )], ( sub( delay_diff, i ) ) );
+ Word64 res2 = W_mult0_32_32( tmp_out_TD2_fx[n][i], i );
+ Word64 res = W_add( W_shr( res1, 6 ), W_shr( res2, 6 ) );
res = res * tmpF_fx;
- p_output_mem_fx[n][i] = (Word32) W_shr( res, 31 - 6 );
+ move64();
+ p_output_mem_fx[n][i] = W_extract_l( W_shr( res, 31 - 6 ) );
}
}
ELSE /* TCX core */
@@ -2695,6 +2805,7 @@ void synchro_synthesis_fx(
FOR( i = 0; i < delay_diff; i++ )
{
p_output_mem_fx[n][i] = output_fx[n][output_frame - dft32ms_ovl + delay_cldfb + i];
+ move32();
}
}
@@ -2702,6 +2813,7 @@ void synchro_synthesis_fx(
FOR( i = delay_diff; i < dft32ms_ovl; i++ )
{
p_output_mem_fx[n][i] = tmp_out_TD2_fx[n][i];
+ move32();
}
}
}
@@ -2711,20 +2823,28 @@ void synchro_synthesis_fx(
* the upmixed TD/MDCT stereo synthesis with the DFT stereo synthesis
*----------------------------------------------------------------*/
- IF( hCPE->element_mode == IVAS_CPE_TD && hCPE->stereo_switching_counter == 0 && hCPE->nchan_out == 1 && hCPE->last_element_brate <= IVAS_24k4 )
+ test();
+ test();
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && hCPE->stereo_switching_counter == 0 && EQ_16( hCPE->nchan_out, 1 ) && LE_32( hCPE->last_element_brate, IVAS_24k4 ) )
{
Word32 step_fx = 0;
+ move32();
tmpF_fx = ONE_IN_Q31;
+ move32();
SWITCH( output_Fs )
{
case 16000:
step_fx = 33554432;
+ move32();
BREAK;
case 32000:
step_fx = 16777216;
+ move32();
BREAK;
case 48000:
step_fx = 11184811;
+ move32();
BREAK;
default:
assert( 0 );
@@ -2733,19 +2853,33 @@ void synchro_synthesis_fx(
FOR( n = 0; n < delay_comp_TD; n++ )
{
sts[0]->prev_synth_buffer32_fx[n] = Mpy_32_32( sts[0]->prev_synth_buffer32_fx[n], tmpF_fx );
+ move32();
tmpF_fx = L_sub_sat( tmpF_fx, step_fx );
}
}
- IF( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->nchan_out == 1 && !is_DTXrate( hCPE->element_brate ) && is_DTXrate( hCPE->last_element_brate ) )
+ test();
+ test();
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->nchan_out, 1 ) && !is_DTXrate( hCPE->element_brate ) && is_DTXrate( hCPE->last_element_brate ) )
{
Copy32( sts[0]->prev_synth_buffer32_fx, sts[1]->prev_synth_buffer32_fx, delay_comp_TD );
}
- nChannels = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? 2 : hCPE->nchan_out;
+ // nChannels = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? 2 : hCPE->nchan_out;
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
+ {
+ nChannels = 2;
+ move16();
+ }
+ ELSE
+ {
+ nChannels = hCPE->nchan_out;
+ move16();
+ }
FOR( n = 0; n < nChannels; n++ )
{
- IF( hCPE->element_mode == IVAS_CPE_MDCT )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
Copy32( sts[n]->prev_synth_buffer32_fx + delay_comp_DFT, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, delay_diff );
delay_signal_fx( output_fx[n], output_frame, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, delay_diff );
@@ -2761,9 +2895,11 @@ void synchro_synthesis_fx(
}
/* handling of DFT->TD switching */
- IF( hCPE->last_element_mode == IVAS_CPE_DFT && !use_cldfb_for_last_dft )
+ test();
+ IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_last_dft )
{
- IF( hCPE->element_mode == IVAS_CPE_TD && hCPE->hStereoCng->prev_sid_nodata )
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && hCPE->hStereoCng->prev_sid_nodata )
{
FOR( n = 0; n < hCPE->nchan_out; n++ )
{
@@ -2771,19 +2907,23 @@ void synchro_synthesis_fx(
{
case 16000:
tmpF_fx = 107374184;
+ move32();
BREAK;
case 32000:
tmpF_fx = 53687092;
+ move32();
BREAK;
case 48000:
tmpF_fx = 35791396;
+ move32();
BREAK;
default:
assert( 0 );
}
FOR( i = 0; i < delay_cldfb; i++ )
{
- tmp_out_fx[n][i] = Mpy_32_32( tmp_out_fx[n][i], tmpF_fx ) * ( delay_cldfb - i );
+ tmp_out_fx[n][i] = W_extract_l( W_mult0_32_32( Mpy_32_32( tmp_out_fx[n][i], tmpF_fx ), ( sub( delay_cldfb, i ) ) ) );
+ move32();
}
}
}
@@ -2791,18 +2931,21 @@ void synchro_synthesis_fx(
/* cross-fading between DFT OLA memory and TD output */
FOR( n = 0; n < nChannels; n++ )
{
- IF( hCPE->element_mode == IVAS_CPE_MDCT )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
SWITCH( output_Fs )
{
case 16000:
tmpF_fx = 71582792;
+ move32();
BREAK;
case 32000:
tmpF_fx = 35791396;
+ move32();
BREAK;
case 48000:
tmpF_fx = 23860930;
+ move32();
BREAK;
default:
assert( 0 );
@@ -2810,34 +2953,41 @@ void synchro_synthesis_fx(
FOR( i = 0; i < delay_diff; i++ )
{
- Word64 res1 = (Word64) output_fx[n][i + delay_comp_DFT] * ( delay_diff - i );
- Word64 res2 = (Word64) p_output_mem_fx[n][i] * i;
- Word64 res = W_shr( res1, 6 ) + W_shr( res2, 6 );
+ Word64 res1 = W_mult0_32_32( output_fx[n][i + delay_comp_DFT], ( sub( delay_diff, i ) ) );
+ Word64 res2 = W_mult0_32_32( p_output_mem_fx[n][i], i );
+ Word64 res = W_add( W_shr( res1, 6 ), W_shr( res2, 6 ) );
res = res * tmpF_fx;
- output_fx[n][i + delay_comp_DFT] = (Word32) W_shr( res, 31 - 6 );
+ move64();
+ output_fx[n][add( i, delay_comp_DFT )] = W_extract_l( W_shr( res, 31 - 6 ) );
+ move32();
}
}
SWITCH( output_Fs )
{
case 16000:
tmpF_fx = 107374184;
+ move32();
BREAK;
case 32000:
tmpF_fx = 53687092;
+ move32();
BREAK;
case 48000:
tmpF_fx = 35791396;
+ move32();
BREAK;
default:
assert( 0 );
}
FOR( i = 0; i < delay_cldfb; i++ )
{
- Word64 res1 = (Word64) tmp_out_fx[n][i] * ( delay_cldfb - i );
- Word64 res2 = (Word64) output_fx[n][i + delay_comp_TD] * i;
- Word64 res = W_shr( res1, 6 ) + W_shr( res2, 6 );
+ Word64 res1 = W_mult0_32_32( tmp_out_fx[n][i], ( sub( delay_cldfb, i ) ) );
+ Word64 res2 = W_mult0_32_32( output_fx[n][add( i, delay_comp_TD )], i );
+ Word64 res = W_add( W_shr( res1, 6 ), W_shr( res2, 6 ) );
res = res * tmpF_fx;
- output_fx[n][i + delay_comp_TD] = (Word32) W_shr( res, 31 - 6 );
+ move64();
+ output_fx[n][add( i, delay_comp_TD )] = W_extract_l( W_shr( res, 31 - 6 ) );
+ move32();
}
}
}
@@ -2902,66 +3052,83 @@ void stereo_switching_dec(
sts = hCPE->hCoreCoder;
delay_comp_TD = NS2SA( sts[0]->output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS );
+ move16();
/* prevent CPE mode switching in the first received frame */
IF( sts[0]->ini_frame == 0 )
{
hCPE->last_element_mode = hCPE->element_mode;
+ move16();
hCPE->stereo_switching_counter = 10;
+ move16();
hCPE->NbFrameMod = 7;
+ move16();
hCPE->lt_es_em_fx = 0;
+ move16();
}
- IF( hCPE->element_mode == hCPE->last_element_mode )
+ IF( EQ_16( hCPE->element_mode, hCPE->last_element_mode ) )
{
- hCPE->stereo_switching_counter++;
- hCPE->stereo_switching_counter = min( 10, hCPE->stereo_switching_counter );
+ hCPE->stereo_switching_counter = add( hCPE->stereo_switching_counter, 1 );
+ hCPE->stereo_switching_counter = s_min( 10, hCPE->stereo_switching_counter );
}
ELSE
{
hCPE->stereo_switching_counter = 0;
+ move16();
}
- IF( hCPE->element_mode == IVAS_CPE_DFT && hCPE->nchan_out == 1 && hCPE->element_brate >= IVAS_32k && hCPE->last_element_brate <= IVAS_24k4 )
+ test();
+ test();
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && GE_32( hCPE->element_brate, IVAS_32k ) && LE_32( hCPE->last_element_brate, IVAS_24k4 ) )
{
- dft32ms_ovl = (Word16) ( ( STEREO_DFT32MS_OVL_MAX * sts[0]->output_Fs ) / 48000 );
+ dft32ms_ovl = extract_l( Mpy_32_32( imult3216( sts[0]->output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) ); // 1/48000 = 44740 (Q31)
set32_fx( hCPE->output_mem_fx[0], 0, dft32ms_ovl );
}
- IF( hCPE->element_mode == IVAS_CPE_DFT && hCPE->last_element_mode != IVAS_CPE_DFT && hCPE->hCoreCoder[0]->ini_frame > 0 )
+ test();
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && NE_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && hCPE->hCoreCoder[0]->ini_frame > 0 )
{
/* windowing the OLA memory */
- dft32ms_ovl = (Word16) ( ( STEREO_DFT32MS_OVL_MAX * sts[0]->output_Fs ) / 48000 );
+ dft32ms_ovl = extract_l( Mpy_32_32( imult3216( sts[0]->output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) ); // 1/48000 = 44740 (Q31)
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
- IF( hCPE->last_element_mode == IVAS_CPE_MDCT )
+ IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
{
/* copy memories from previous MDCT Stereo frame to output_mem */
Copy32( hCPE->input_mem_fx[n], hCPE->output_mem_fx[n], dft32ms_ovl );
}
- IF( ivas_total_brate > IVAS_SID_5k2 || n == 0 || hCPE->last_element_mode != IVAS_CPE_TD || hCPE->nchan_out == 1 )
+ test();
+ test();
+ test();
+ IF( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || n == 0 || NE_16( hCPE->last_element_mode, IVAS_CPE_TD ) || EQ_16( hCPE->nchan_out, 1 ) )
{
FOR( i = 0; i < dft32ms_ovl; i++ )
{
- hCPE->output_mem_fx[n][i] = Mpy_32_16_1( hCPE->output_mem_fx[n][i], hCPE->hStereoDft->win32ms_fx[STEREO_DFT32MS_STEP * ( dft32ms_ovl - 1 - i )] );
+ hCPE->output_mem_fx[n][i] = Mpy_32_16_1( hCPE->output_mem_fx[n][i], hCPE->hStereoDft->win32ms_fx[i_mult( STEREO_DFT32MS_STEP, ( sub( sub( dft32ms_ovl, 1 ), i ) ) )] );
+ move32();
}
}
ELSE
{
- IF( hCPE->hStereoTCA->prevTargetGain_fx == ONE_IN_Q29 )
+ IF( EQ_32( hCPE->hStereoTCA->prevTargetGain_fx, ONE_IN_Q29 ) )
{
tmpF_fx = ONE_IN_Q27;
+ move32();
}
ELSE
{
- Word16 temp_b = (Word16) L_shr( hCPE->hStereoTCA->prevTargetGain_fx, 16 );
+ Word16 temp_b = extract_l( L_shr( hCPE->hStereoTCA->prevTargetGain_fx, 16 ) );
Word16 temp_b_q = 2;
+ move16();
tmpF_fx = Inv16( temp_b, &temp_b_q );
- tmpF_fx = L_shl( tmpF_fx, ( 31 - 4 ) - ( 15 - temp_b_q ) );
+ tmpF_fx = L_shl( tmpF_fx, sub( ( 31 - 4 ), sub( 15, temp_b_q ) ) );
}
FOR( i = 0; i < dft32ms_ovl; i++ )
{
- Word32 temp_result = Mpy_32_16_1( tmpF_fx, hCPE->hStereoDft->win32ms_fx[STEREO_DFT32MS_STEP * ( dft32ms_ovl - 1 - i )] );
+ Word32 temp_result = Mpy_32_16_1( tmpF_fx, hCPE->hStereoDft->win32ms_fx[i_mult( STEREO_DFT32MS_STEP, sub( dft32ms_ovl, 1 + i ) )] );
hCPE->output_mem_fx[n][i] = L_shl_sat( Mpy_32_32( hCPE->output_mem_fx[n][i], temp_result ), 4 );
}
FOR( i = 0; i < delay_comp_TD; i++ )
@@ -2971,48 +3138,55 @@ void stereo_switching_dec(
// temp_result = (Word64) hCPE->hCoreCoder[1]->prev_synth_buffer_fx[i] * tmpF_fx;
// hCPE->hCoreCoder[1]->prev_synth_buffer_fx[i] = saturate( W_extract_l(W_shr( temp_result, 27 )) );
// 32bit buffer
- temp_result = (Word64) hCPE->hCoreCoder[1]->prev_synth_buffer32_fx[i] * tmpF_fx;
+ temp_result = W_mult0_32_32( hCPE->hCoreCoder[1]->prev_synth_buffer32_fx[i], tmpF_fx );
hCPE->hCoreCoder[1]->prev_synth_buffer32_fx[i] = W_sat_l( W_shr( temp_result, 27 ) );
+ move32();
}
FOR( i = 0; i < L_DEC_MEM_LEN_ICA; i++ )
{
hCPE->hStereoTCA->memChanR_fx[i] = L_shl_sat( Mpy_32_32( hCPE->hStereoTCA->memChanR_fx[i], tmpF_fx ), 4 );
+ move32();
}
}
}
- IF( hCPE->last_element_mode == IVAS_CPE_MDCT )
+ IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
{
/* create passive downmix of MDCT Stereo memories FOR DFT input memory */
- FOR( int ind = 0; ind < STEREO_DFT32MS_OVL_16k; ind++ )
+ FOR( Word32 ind = 0; ind < STEREO_DFT32MS_OVL_16k; ind++ )
{
Word32 result_int = L_add_sat( hCPE->input_mem_LB_fx[0][ind], hCPE->input_mem_LB_fx[1][ind] );
hCPE->input_mem_LB_fx[0][ind] = L_shr( result_int, 1 );
+ move32();
}
- FOR( int ind = 0; ind < dft32ms_ovl; ind++ )
+ FOR( Word32 ind = 0; ind < dft32ms_ovl; ind++ )
{
Word32 result_int = L_add_sat( hCPE->input_mem_fx[0][ind], hCPE->input_mem_fx[1][ind] );
hCPE->input_mem_fx[0][ind] = L_shr( result_int, 1 );
+ move32();
}
- IF( hCPE->nchan_out == 1 )
+ IF( EQ_16( hCPE->nchan_out, 1 ) )
{
- FOR( int ind = 0; ind < dft32ms_ovl; ind++ )
+ FOR( Word32 ind = 0; ind < dft32ms_ovl; ind++ )
{
Word32 result_int = L_add_sat( hCPE->output_mem_fx[0][ind], hCPE->output_mem_fx[1][ind] );
hCPE->output_mem_fx[0][ind] = Mpy_32_32( result_int, INV_SQRT_2_Q31 );
+ move32();
}
}
}
/* Update the side_gain[] parameters */
- IF( hCPE->last_element_mode != IVAS_CPE_MDCT )
+ IF( NE_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
{
tmpF_fx = 0;
- IF( hCPE->hStereoTCA != NULL )
+ move32();
+ if ( hCPE->hStereoTCA != NULL )
{
tmpF_fx = side_gain_table[hCPE->hStereoTCA->indx_ica_gD];
+ move32();
}
set32_fx( hCPE->hStereoDft->side_gain_fx + STEREO_DFT_NBDIV * STEREO_DFT_BAND_MAX, tmpF_fx, STEREO_DFT_BAND_MAX );
}
@@ -3020,33 +3194,43 @@ void stereo_switching_dec(
/* reset residual coding / ESF (secondary channel) */
set32_fx( hCPE->hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k );
hCPE->hStereoDft->q_res_cod_mem_fx = Q16;
+ move16();
set32_fx( hCPE->input_mem_fx[1], 0, NS2SA( sts[0]->output_Fs, STEREO_DFT32MS_OVL_NS ) );
}
- IF( hCPE->element_mode == IVAS_CPE_TD && hCPE->last_element_mode != IVAS_CPE_TD && hCPE->hCoreCoder[0]->ini_frame > 0 )
+ test();
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( hCPE->last_element_mode, IVAS_CPE_TD ) && hCPE->hCoreCoder[0]->ini_frame > 0 )
{
hCPE->hStereoTD->tdm_last_ratio_idx = LRTD_STEREO_MID_IS_PRIM;
+ move16();
hCPE->hStereoTD->tdm_last_SM_flag = 0;
+ move16();
hCPE->hStereoTD->tdm_prev_last_SM_flag = 0;
+ move16();
/* First frame after DFT frame AND the content is uncorrelated or xtalk -> the primary channel is forced to left */
- IF( hCPE->hStereoTD->tdm_LRTD_flag == 1 )
+ if ( EQ_16( hCPE->hStereoTD->tdm_LRTD_flag, 1 ) )
{
hCPE->hStereoTD->tdm_last_ratio_idx = LRTD_STEREO_LEFT_IS_PRIM;
+ move16();
}
}
/* no secondary channel in the previous frame -> memory resets */
- IF( hCPE->element_mode > IVAS_CPE_DFT && hCPE->last_element_mode == IVAS_CPE_DFT )
+ test();
+ test();
+ IF( GT_16( hCPE->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
- IF( hCPE->last_element_brate <= IVAS_SID_5k2 && hCPE->nchan_out == 2 )
+ test();
+ IF( LE_32( hCPE->last_element_brate, IVAS_SID_5k2 ) && EQ_16( hCPE->nchan_out, 2 ) )
{
/* reset CLDFB memories */
#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED
- cldfb_reset_memory_ivas( sts[0]->cldfbAna );
- cldfb_reset_memory_ivas( sts[0]->cldfbBPF );
- cldfb_reset_memory_ivas( sts[0]->cldfbSyn );
+ // cldfb_reset_memory_ivas( sts[0]->cldfbAna );
+ // cldfb_reset_memory_ivas( sts[0]->cldfbBPF );
+ // cldfb_reset_memory_ivas( sts[0]->cldfbSyn );
#endif
cldfb_reset_memory_fx( sts[0]->cldfbAna );
@@ -3055,6 +3239,7 @@ void stereo_switching_dec(
// sts[0]->mem_deemph = 0;
sts[0]->mem_deemph_fx = 0;
+ move16();
#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED
// sts[0]->tilt_code = 0.0f;
@@ -3062,7 +3247,9 @@ void stereo_switching_dec(
#endif
sts[0]->tilt_code_fx = 0;
+ move16();
sts[0]->gc_threshold_fx = 0;
+ move16();
#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED
// set_f( sts[0]->mem_syn1, 0, M );
@@ -3077,6 +3264,7 @@ void stereo_switching_dec(
set16_fx( sts[0]->mem_syn_r, 0, L_SYN_MEM );
sts[1]->last_L_frame = sts[0]->last_L_frame;
+ move16();
#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED
/* reset PCh memories */
@@ -3090,8 +3278,10 @@ void stereo_switching_dec(
set16_fx( sts[0]->lsp_old_fx, 0, M );
}
sts[1]->last_extl = -1;
+ move16();
sts[1]->prev_bfi = sts[0]->prev_bfi;
+ move16();
#ifndef IVAS_FLOAT_FIXED
set_f( sts[1]->old_pitch_buf, (float) L_SUBFR, 2 * NB_SUBFR16k );
@@ -3101,12 +3291,13 @@ void stereo_switching_dec(
// fix need to do correctly
set32_fx( sts[1]->old_pitch_buf_fx, L_deposit_h( L_SUBFR ), 2 * NB_SUBFR16k );
sts[1]->old_fpitchFB = 2 * L_SUBFR;
+ move32();
/* reset CLDFB memories */
#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED
- cldfb_reset_memory_ivas( sts[1]->cldfbAna );
- cldfb_reset_memory_ivas( sts[1]->cldfbBPF );
- cldfb_reset_memory_ivas( sts[1]->cldfbSyn );
+ // cldfb_reset_memory_ivas( sts[1]->cldfbAna );
+ // cldfb_reset_memory_ivas( sts[1]->cldfbBPF );
+ // cldfb_reset_memory_ivas( sts[1]->cldfbSyn );
#endif
cldfb_reset_memory_fx( sts[1]->cldfbAna );
@@ -3115,13 +3306,16 @@ void stereo_switching_dec(
// sts[1]->mem_deemph = 0;
sts[1]->mem_deemph_fx = 0;
+ move16();
#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED
// sts[1]->tilt_code = 0.0f;
// sts[1]->gc_threshold = 0.0f;
#endif
sts[1]->tilt_code_fx = 0;
+ move16();
sts[1]->gc_threshold_fx = 0;
+ move16();
#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED
// set_f( sts[1]->mem_syn1, 0, M );
@@ -3136,14 +3330,17 @@ void stereo_switching_dec(
set16_fx( sts[1]->mem_syn_r, 0, L_SYN_MEM );
sts[1]->last_L_frame = sts[0]->last_L_frame;
+ move16();
Copy_Scale_sig( sts[0]->old_exc_fx, sts[1]->old_exc_fx, L_EXC_MEM_DEC, sub( sts[1]->Q_exc, sts[0]->Q_exc ) );
Copy( sts[0]->lsf_old_fx, sts[1]->lsf_old_fx, M );
Copy( sts[0]->lsp_old_fx, sts[1]->lsp_old_fx, M );
- IF( hCPE->element_mode == IVAS_CPE_MDCT )
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
sts[1]->last_core = sts[0]->last_core;
+ move16();
sts[1]->last_coder_type = sts[0]->last_coder_type;
+ move16();
#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED
// mvr2r( sts[0]->hHQ_core->old_out, sts[1]->hHQ_core->old_out, L_FRAME48k );
@@ -3163,7 +3360,7 @@ void stereo_switching_dec(
Copy( sts[0]->hTcxDec->old_syn_Overl, sts[1]->hTcxDec->old_syn_Overl, 256 );
}
}
- ELSE IF( hCPE->element_mode == IVAS_CPE_TD && hCPE->last_element_mode == IVAS_CPE_MDCT )
+ ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
{
#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED
// set_f( sts[0]->old_exc, 0.0f, L_EXC_MEM_DEC );
@@ -3174,19 +3371,27 @@ void stereo_switching_dec(
}
/* TD/DFT -> MDCT stereo switching (there is no TCX in the TD stereo secondary channel, or DFT stereo) */
- IF( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->last_element_mode != IVAS_CPE_MDCT )
+ 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;
+ move16();
sts[1]->hTcxCfg->tcx_curr_overlap_mode = sts[0]->hTcxCfg->tcx_curr_overlap_mode;
+ move16();
sts[1]->fscale = sts[0]->fscale;
+ move16();
sts[1]->hTcxCfg->tcx_mdct_window_length = sts[0]->hTcxCfg->tcx_mdct_window_length;
+ move16();
sts[1]->pit_res_max = sts[0]->pit_res_max;
+ move16();
sts[1]->pit_res_max_past = sts[0]->pit_res_max_past;
+ move16();
sts[1]->hTcxDec->L_frameTCX = sts[0]->hTcxDec->L_frameTCX;
+ move16();
#ifndef IVAS_FLOAT_FIXED
sts[1]->hTcxDec->conceal_eof_gain_float = sts[0]->hTcxDec->conceal_eof_gain_float;
#endif
sts[1]->hTcxDec->conceal_eof_gain = sts[0]->hTcxDec->conceal_eof_gain;
+ move16();
}
return;
@@ -3548,11 +3753,16 @@ void stereo_td2dft_update_fx(
/* initialization */
sts = hCPE->hCoreCoder;
- ovl = NS2SA( sts[n]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS );
- dft32ms_ovl = (Word16) ( ( STEREO_DFT32MS_OVL_MAX * sts[0]->output_Fs ) / 48000 );
+ ovl = NS2SA( i_mult( sts[n]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS );
+ move16();
+ dft32ms_ovl = extract_l( Mpy_32_32( imult3216( sts[0]->output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) ); // 1/48000 = 44740 (Q31)
+ move16();
hq_delay_comp = NS2SA( sts[0]->output_Fs, DELAY_CLDFB_NS );
+ move16();
- IF( hCPE->element_mode >= IVAS_CPE_DFT && hCPE->element_mode != IVAS_CPE_MDCT )
+ test();
+ test();
+ IF( GE_16( hCPE->element_mode, IVAS_CPE_DFT ) && NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
{
IF( sts[n]->core == ACELP_CORE )
{
@@ -3564,64 +3774,72 @@ void stereo_td2dft_update_fx(
/* update DFT analysis overlap memory @internal_fs: BPF */
IF( sts[n]->p_bpf_noise_buf_32 )
{
- Copy32( sts[n]->p_bpf_noise_buf_32 + sts[n]->L_frame - ovl, hCPE->input_mem_BPF_fx[n], ovl );
+ Copy32( sts[n]->p_bpf_noise_buf_32 + sub( sts[n]->L_frame, ovl ), hCPE->input_mem_BPF_fx[n], ovl );
}
/* update DFT analysis overlap memory @output_Fs: BWE */
- IF( sts[n]->extl != -1 || ( sts[n]->bws_cnt > 0 && sts[n]->core == ACELP_CORE ) )
+ test();
+ test();
+ IF( NE_16( sts[n]->extl, -1 ) || ( sts[n]->bws_cnt > 0 && sts[n]->core == ACELP_CORE ) )
{
- Copy32( hb_synth_fx + output_frame - dft32ms_ovl, hCPE->input_mem_fx[n], dft32ms_ovl );
+ Copy32( hb_synth_fx + sub( output_frame, dft32ms_ovl ), hCPE->input_mem_fx[n], dft32ms_ovl );
}
}
ELSE
{
/* update DFT analysis overlap memory @internal_fs: core synthesis, secondary channel */
- Copy32( output_fx + sts[n]->L_frame - ovl, hCPE->input_mem_LB_fx[n], ovl );
+ Copy32( output_fx + sub( sts[n]->L_frame, ovl ), hCPE->input_mem_LB_fx[n], ovl );
}
}
ELSE /* TCX core */
{
/* LB-TCX synthesis */
- Copy32( output_fx + sts[n]->L_frame - ovl, hCPE->input_mem_LB_fx[n], ovl );
+ Copy32( output_fx + sub( sts[n]->L_frame, ovl ), hCPE->input_mem_LB_fx[n], ovl );
/* BPF */
IF( n == 0 && sts[n]->p_bpf_noise_buf_32 )
{
- Copy32( sts[n]->p_bpf_noise_buf_32 + sts[n]->L_frame - ovl, hCPE->input_mem_BPF_fx[n], ovl );
+ Copy32( sts[n]->p_bpf_noise_buf_32 + sub( sts[n]->L_frame, ovl ), hCPE->input_mem_BPF_fx[n], ovl );
}
/* TCX synthesis (it was already delayed in TD stereo in core_switching_post_dec()) */
IF( sts[n]->hTcxDec != NULL )
{
ovl_TCX = NS2SA( sts[n]->hTcxDec->L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS );
+ move16();
Copy32( synth_fx + sts[n]->hTcxDec->L_frameTCX + hq_delay_comp - ovl_TCX, hCPE->input_mem_fx[n], ovl_TCX - hq_delay_comp );
Copy32( sts[n]->delay_buf_out32_fx, hCPE->input_mem_fx[n] + ovl_TCX - hq_delay_comp, hq_delay_comp );
}
}
}
- ELSE IF( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->input_mem_fx[0] != NULL )
+ ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && hCPE->input_mem_fx[0] != NULL )
{
/* update DFT stereo OLA memories */
/*set_zero( hCPE->input_mem_LB[n], STEREO_DFT32MS_OVL_16k );*/
- L_lerp_fx_q11( output_fx + sts[n]->L_frame - ovl, hCPE->input_mem_LB_fx[n], STEREO_DFT32MS_OVL_16k, ovl );
+ L_lerp_fx_q11( output_fx + sub( sts[n]->L_frame, ovl ), hCPE->input_mem_LB_fx[n], STEREO_DFT32MS_OVL_16k, ovl );
/* TCX synthesis (it was already delayed in TD stereo in core_switching_post_dec()) */
IF( sts[n]->hTcxDec != NULL )
{
ovl_TCX = NS2SA( sts[n]->hTcxDec->L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS );
- Copy32( synth_fx + sts[n]->hTcxDec->L_frameTCX + hq_delay_comp - ovl_TCX, hCPE->input_mem_fx[n], ovl_TCX - hq_delay_comp );
- Copy32( sts[n]->delay_buf_out32_fx, hCPE->input_mem_fx[n] + ovl_TCX - hq_delay_comp, hq_delay_comp );
+ move16();
+ Copy32( synth_fx + add( sts[n]->hTcxDec->L_frameTCX, sub( hq_delay_comp, ovl_TCX ) ), hCPE->input_mem_fx[n], sub( ovl_TCX, hq_delay_comp ) );
+ Copy32( sts[n]->delay_buf_out32_fx, hCPE->input_mem_fx[n] + sub( ovl_TCX, hq_delay_comp ), hq_delay_comp );
}
- IF( n == 1 )
+ IF( EQ_16( n, 1 ) )
{
- nsLB = NS2SA( sts[n]->L_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS );
+ nsLB = NS2SA( L_mult0( sts[n]->L_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS );
+ move16();
ns = NS2SA( sts[n]->output_Fs, N_ZERO_MDCT_NS );
- old_outLB_len = (Word16) ( ( 3 * STEREO_MDCT2DFT_FADE_LEN_48k * sts[0]->L_frame * FRAMES_PER_SEC ) / 48000 );
- old_out_len = (Word16) ( ( STEREO_MDCT2DFT_FADE_LEN_48k * sts[0]->output_Fs ) / 48000 );
+ move16();
+ old_outLB_len = extract_l( Mpy_32_32( ( L_mult0( STEREO_MDCT2DFT_FADE_LEN_48k * FRAMES_PER_SEC, i_mult( 3, sts[0]->L_frame ) ) ), 44740 ) );
+ move16();
+ old_out_len = extract_l( Mpy_32_32( imult3216( sts[0]->output_Fs, STEREO_MDCT2DFT_FADE_LEN_48k ), 44740 ) );
+ move16();
/* update buffers used for fading when switching to DFT Stereo */
v_add_fx( sts[0]->hHQ_core->old_outLB_fx + nsLB, sts[1]->hHQ_core->old_outLB_fx + nsLB, hCPE->old_outLB_mdct_fx, old_outLB_len );
@@ -3629,19 +3847,21 @@ void stereo_td2dft_update_fx(
#ifndef MSAN_FIX
for ( int i = 0; i < STEREO_MDCT2DFT_FADE_LEN_48k; i++ )
#else
- FOR( int i = 0; i < old_outLB_len; i++ )
+ FOR( Word32 i = 0; i < old_outLB_len; i++ )
#endif
{
hCPE->old_outLB_mdct_fx[i] = L_shr( hCPE->old_outLB_mdct_fx[i], 1 );
+ move32();
}
v_add_fx( sts[0]->hHQ_core->oldOut_fx + ns, sts[1]->hHQ_core->oldOut_fx + ns, hCPE->old_out_mdct_fx, old_out_len );
#ifndef MSAN_FIX
for ( int i = 0; i < STEREO_MDCT2DFT_FADE_LEN_48k; i++ )
#else
- FOR( int i = 0; i < old_out_len; i++ )
+ FOR( Word32 i = 0; i < old_out_len; i++ )
#endif
{
hCPE->old_out_mdct_fx[i] = L_shr( hCPE->old_out_mdct_fx[i], 1 );
+ move32();
}
}
@@ -3652,9 +3872,11 @@ void stereo_td2dft_update_fx(
}
/* update ovl buffer for possible switching from TD stereo SCh ACELP frame to MDCT stereo TCX frame */
- IF( hCPE->element_mode == IVAS_CPE_TD && n == 1 && sts[n]->hTcxDec == NULL )
+ test();
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && EQ_16( n, 1 ) && sts[n]->hTcxDec == NULL )
{
- Copy32( output_fx + sts[n]->L_frame / 2, hCPE->hStereoTD->TCX_old_syn_Overl_fx, sts[n]->L_frame / 2 );
+ Copy32( output_fx + shr( sts[n]->L_frame, 1 ), hCPE->hStereoTD->TCX_old_syn_Overl_fx, shr( sts[n]->L_frame, 1 ) );
}
return;
@@ -3708,89 +3930,102 @@ void stereo_mdct2dft_update_fx(
Word32 synth0_fx[] /* i/o: synthesis @output Fs, ch0 */
)
{
- int16_t i;
- int16_t fade_len, fade_len_LB;
+ Word16 i;
+ Word16 fade_len, fade_len_LB;
Word32 tmpF_fx = 0;
Decoder_State *st;
- if ( hCPE == NULL )
+ IF( hCPE == NULL )
{
return;
}
st = hCPE->hCoreCoder[0];
- fade_len = (int16_t) ( ( STEREO_MDCT2DFT_FADE_LEN_48k * st->output_Fs ) / 48000 );
- fade_len_LB = (int16_t) ( 3 * ( STEREO_MDCT2DFT_FADE_LEN_48k * st->L_frame * FRAMES_PER_SEC ) / 48000 );
- switch ( st->output_Fs )
+ fade_len = extract_l( Mpy_32_32( imult3216( st->output_Fs, STEREO_MDCT2DFT_FADE_LEN_48k ), 44740 ) ); // 1/48000 = 44740 (Q31)
+ fade_len_LB = extract_l( Mpy_32_32( imult3216( 3 * STEREO_MDCT2DFT_FADE_LEN_48k * FRAMES_PER_SEC, st->L_frame ), 44740 ) ); // 1/48000 = 44740 (Q31)
+ SWITCH( st->output_Fs )
{
case 16000:
tmpF_fx = 53687092;
+ move32();
BREAK;
case 32000:
tmpF_fx = 26843546;
+ move32();
BREAK;
case 48000:
tmpF_fx = 17895698;
+ move32();
BREAK;
}
- for ( i = 0; i < fade_len; i++ )
+ FOR( i = 0; i < fade_len; i++ )
{
Word32 descen_gain;
- if ( i == 0 )
+ IF( EQ_16( i, 0 ) )
{
descen_gain = ONE_IN_Q31;
+ move32();
}
- else
+ ELSE
{
- descen_gain = ( fade_len - i ) * tmpF_fx;
+ descen_gain = W_extract_l( W_mult0_32_32( ( sub( fade_len, i ) ), tmpF_fx ) );
}
Word32 temp_a = Mpy_32_32( hCPE->old_out_mdct_fx[i], descen_gain );
- Word32 ascend_gain = i * tmpF_fx;
+ Word32 ascend_gain = W_extract_l( W_mult0_32_32( i, tmpF_fx ) );
Word32 temp_b = Mpy_32_32( synth0_fx[i], ascend_gain );
synth0_fx[i] = L_add_sat( temp_a, temp_b );
+ move32();
}
- switch ( st->L_frame )
+ SWITCH( st->L_frame )
{
case 80:
tmpF_fx = 71582792;
+ move32();
BREAK;
case 160:
tmpF_fx = 35791396;
+ move32();
BREAK;
case 256:
tmpF_fx = 22369622;
+ move32();
BREAK;
case 320:
tmpF_fx = 17895698;
+ move32();
BREAK;
case 512:
tmpF_fx = 11184811;
+ move32();
BREAK;
case 640:
tmpF_fx = 8947849;
+ move32();
BREAK;
case 960:
tmpF_fx = 5965232;
+ move32();
BREAK;
default:
assert( 0 );
}
- for ( i = 0; i < fade_len_LB; i++ )
+ FOR( i = 0; i < fade_len_LB; i++ )
{
Word32 descen_gain;
- if ( i == 0 )
+ IF( i == 0 )
{
descen_gain = ONE_IN_Q31;
+ move32();
}
- else
+ ELSE
{
- descen_gain = ( fade_len_LB - i ) * tmpF_fx;
+ descen_gain = W_extract_l( W_mult0_32_32( sub( fade_len_LB, i ), tmpF_fx ) );
}
Word32 temp_a = Mpy_32_32( hCPE->old_outLB_mdct_fx[i], descen_gain );
- Word32 ascend_gain = i * tmpF_fx;
+ Word32 ascend_gain = W_extract_l( W_mult0_32_32( i, tmpF_fx ) );
Word32 temp_b = Mpy_32_32( output0_fx[i], ascend_gain );
output0_fx[i] = L_add_sat( temp_a, temp_b );
}
@@ -3865,26 +4100,26 @@ static Word32 ncross_corr_self_fx(
signal_b_fx = &signal_fx[y];
FOR( j = 0; j < corr_len; j += subsampling )
{
- c_c_fx += ( (Word64) ( signal_a_fx[j] ) * ( signal_b_fx[j] ) );
- energy_x_fx += (Word64) ( signal_a_fx[j] ) * ( signal_a_fx[j] );
- energy_y_fx += (Word64) ( signal_b_fx[j] ) * ( signal_b_fx[j] );
+ c_c_fx = W_add( c_c_fx, W_mult0_32_32( ( signal_a_fx[j] ), ( signal_b_fx[j] ) ) );
+ energy_x_fx = W_add( energy_x_fx, W_mult0_32_32( ( signal_a_fx[j] ), ( signal_a_fx[j] ) ) );
+ energy_y_fx = W_add( energy_y_fx, W_mult0_32_32( ( signal_b_fx[j] ), ( signal_b_fx[j] ) ) );
}
headroom_left_x = W_norm( energy_x_fx );
headroom_left_y = W_norm( energy_y_fx );
- IF( headroom_left_x < 32 )
+ IF( LT_16( headroom_left_x, 32 ) )
{
- energy_x_fx = W_shr( energy_x_fx, (Word16) ( 32 - headroom_left_x ) );
- x_q = (Word16) ( 31 - ( ( 2 * OUTPUT_Q ) - ( 32 - headroom_left_x ) ) );
+ energy_x_fx = W_shr( energy_x_fx, sub( 32, headroom_left_x ) );
+ x_q = sub( 31, ( sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_x ) ) ) );
}
ELSE
{
x_q = 31 - ( 2 * OUTPUT_Q );
}
- IF( headroom_left_y < 32 )
+ IF( LT_16( headroom_left_y, 32 ) )
{
- energy_y_fx = W_shr( energy_y_fx, (Word16) ( 32 - headroom_left_y ) );
- y_q = (Word16) ( 31 - ( ( 2 * OUTPUT_Q ) - ( 32 - headroom_left_y ) ) );
+ energy_y_fx = W_shr( energy_y_fx, sub( 32, headroom_left_y ) );
+ y_q = sub( 31, ( sub( ( 2 * OUTPUT_Q ), ( sub( 32, headroom_left_y ) ) ) ) );
}
ELSE
{
@@ -3892,26 +4127,30 @@ static Word32 ncross_corr_self_fx(
}
x_inv_q = x_q;
+ move16();
y_inv_q = y_q;
+ move16();
- temp_x = Sqrt32( (Word32) energy_x_fx, &x_q );
+ temp_x = Sqrt32( W_extract_l( energy_x_fx ), &x_q );
IF( x_q < 0 )
{
- temp_x = L_shr( temp_x, -1 * x_q );
+ temp_x = L_shr( temp_x, i_mult( -1, x_q ) );
x_q = 0;
+ move16();
}
- temp_y = Sqrt32( (Word32) energy_y_fx, &y_q );
+ temp_y = Sqrt32( W_extract_l( energy_y_fx ), &y_q );
IF( y_q < 0 )
{
- temp_y = L_shr( temp_y, -1 * y_q );
+ temp_y = L_shr( temp_y, i_mult( -1, y_q ) );
y_q = 0;
+ move16();
}
energy_xy_fx = Mpy_32_32( temp_x, temp_y );
- res_q = y_q + x_q;
+ res_q = add( y_q, x_q );
- IF( ( energy_xy_fx < L_shr( ONE_IN_Q31, (Word16) res_q ) ) || energy_xy_fx == 0 )
+ IF( ( energy_xy_fx < L_shr( ONE_IN_Q31, res_q ) ) || energy_xy_fx == 0 )
{
energy_xy_fx = ONE_IN_Q31; /* conceal silent frames */
res_q = 0;
@@ -3919,24 +4158,26 @@ static Word32 ncross_corr_self_fx(
}
ELSE
{
- Word32 temp_x_inv = ISqrt32( (Word32) energy_x_fx, &x_inv_q );
- Word32 temp_y_inv = ISqrt32( (Word32) energy_y_fx, &y_inv_q );
+ Word32 temp_x_inv = ISqrt32( W_extract_l( energy_x_fx ), &x_inv_q );
+ Word32 temp_y_inv = ISqrt32( W_extract_l( energy_y_fx ), &y_inv_q );
Word16 headroom_left_c_c;
- energy_xy_fx = (Word32) Mpy_32_32( temp_x_inv, temp_y_inv );
- res_q = x_inv_q + y_inv_q;
+ energy_xy_fx = Mpy_32_32( temp_x_inv, temp_y_inv );
+ res_q = add( x_inv_q, y_inv_q );
headroom_left_c_c = W_norm( c_c_fx );
c_c_fx_q = OUTPUT_Q * 2;
- IF( headroom_left_c_c < 32 )
+ move16();
+ IF( LT_16( headroom_left_c_c, 32 ) )
{
- c_c_fx = W_shr( c_c_fx, (Word16) ( 32 - headroom_left_c_c ) );
- c_c_fx_q = c_c_fx_q - ( 32 - headroom_left_c_c );
+ c_c_fx = W_shr( c_c_fx, extract_l( sub( 32, headroom_left_c_c ) ) );
+ c_c_fx_q = sub( c_c_fx_q, sub( 32, headroom_left_c_c ) );
}
- c_c_fx = (Word64) Mpy_32_32( (Word32) c_c_fx, (Word32) energy_xy_fx );
- c_c_fx_q = (Word16) c_c_fx_q + ( 31 - res_q ) - 31;
- c_c_fx = (Word32) W_shl_sat_l( c_c_fx, (Word16) ( 31 - c_c_fx_q ) );
+ c_c_fx = W_deposit32_l( Mpy_32_32( W_extract_l( c_c_fx ), W_extract_l( energy_xy_fx ) ) );
+ c_c_fx_q = add( c_c_fx_q, sub( sub( 31, res_q ), 31 ) );
+ c_c_fx = W_extract_l( W_shl_sat_l( c_c_fx, extract_l( sub( 31, c_c_fx_q ) ) ) );
}
- c_c_fx_return = (Word32) c_c_fx;
+ c_c_fx_return = W_extract_l( c_c_fx );
+ move32();
return c_c_fx_return;
}
#endif
@@ -4128,7 +4369,7 @@ void smooth_dft2td_transition_fx(
ilen = shr( output_frame, 1 );
/* correlation length */
- corr_len = output_frame / 20;
+ corr_len = idiv1616( output_frame, 20 );
subsampl = 4;
FOR( ch = 0; ch < hCPE->nchan_out; ch++ )
@@ -4136,10 +4377,10 @@ void smooth_dft2td_transition_fx(
/* core to external sampling frequency ratio */
Word16 q = norm_l( output_frame );
Word32 check = BASOP_Util_Divide3232_Scale( output_frame, sts[ch]->L_frame, &q );
- fac_fs_fx = check * ( 1 << ( 26 - ( 15 - q ) ) );
+ fac_fs_fx = imult3216( check, shl( 1, add( 26 - 15, q ) ) );
/* Find minimum and maximum pitch*/
- ipit_min = minimum_32_fx( sts[ch]->old_pitch_buf_fx + 4, 4, &flen_fx ) + 4;
- ipit_max = maximum_32_fx( sts[ch]->old_pitch_buf_fx + 4, 4, &flen_fx ) + 4;
+ ipit_min = add( minimum_32_fx( sts[ch]->old_pitch_buf_fx + 4, 4, &flen_fx ), 4 );
+ ipit_max = add( maximum_32_fx( sts[ch]->old_pitch_buf_fx + 4, 4, &flen_fx ), 4 );
ipit_min = (Word16) L_shr( L_add( Mpy_32_32( sts[ch]->old_pitch_buf_fx[ipit_min], fac_fs_fx ), ONE_IN_Q10 ), 11 );
ipit_max = (Word16) L_shr( L_add( Mpy_32_32( sts[ch]->old_pitch_buf_fx[ipit_max], fac_fs_fx ), ONE_IN_Q10 ), 11 );
@@ -4152,7 +4393,7 @@ void smooth_dft2td_transition_fx(
lsearch = s_min( lsearch, shr( output_frame, 2 ) );
/* ptr init for search of the best correlation in the past frame */
- ptE_fx = hCPE->prev_synth_chs_fx[ch] + output_frame - ipit_max - corr_len;
+ ptE_fx = hCPE->prev_synth_chs_fx[ch] + sub( output_frame, add( ipit_max, corr_len ) );
idiff = 0;
move16();
@@ -4190,11 +4431,11 @@ void smooth_dft2td_transition_fx(
}
/* Set buffer for the reserved buffer of the current frame */
- ptO2_fx = tmp_out2_fx + output_frame - ilen;
- set32_fx( tmp_out2_fx + output_frame - ilen, 0, ilen );
+ ptO2_fx = tmp_out2_fx + sub( output_frame, ilen );
+ set32_fx( tmp_out2_fx + sub( output_frame, ilen ), 0, ilen );
FOR( i = 0; i < output_frame; i++ )
{
- tmp_out2_fx[i] = output_fx[ch][output_frame - 1 - i];
+ tmp_out2_fx[i] = output_fx[ch][sub( output_frame, ( 1 + i ) )];
move32();
}
/* ptr init for search of the best correlation of the current frame */
@@ -4221,7 +4462,7 @@ void smooth_dft2td_transition_fx(
/* If the correlation is too low, don't use the prediction */
IF( GT_32( fmaxcorr_fx, DFT2TD_CORR_THRESH_FX ) )
{
- pt1_fx = tmp_out2_fx + output_frame - ilen - ipit;
+ pt1_fx = tmp_out2_fx + sub( output_frame, add( ilen, ipit ) );
FOR( i = 0; i < ilen; i++ )
{
ptO2_fx[i] = pt1_fx[i];
@@ -4250,16 +4491,17 @@ void smooth_dft2td_transition_fx(
}
FOR( i = 0; i < 4; i++ )
{
- Word64 temp_a = W_shr( ( ( 4 - i ) * (Word64) output_fx[ch][i] + i * ptO_fx[i] ), 2 ) * ( ilen - i );
- Word64 temp_b = tmp_out2_fx[output_frame - 1 - i] * i;
- output_fx[ch][i] = (Word32) W_shr( ( W_add( temp_a, temp_b ) * flen_fx ), 31 );
+ Word64 temp_a = W_shr( W_add( W_mult0_32_32( sub( 4, i ), output_fx[ch][i] ), W_mult0_32_32( i, ptO_fx[i] ) ), 2 ) * ( ilen - i );
+ move64();
+ Word64 temp_b = W_mult0_32_32( tmp_out2_fx[sub( output_frame, add( 1, i ) )], i );
+ output_fx[ch][i] = W_extract_l( W_shr( ( W_add( temp_a, temp_b ) * flen_fx ), 31 ) );
move32();
}
- FOR( ; i < ilen - 4; i++ )
+ FOR( ; i < sub( ilen, 4 ); i++ )
{
- Word64 temp_a = (Word64) ptO_fx[i] * ( ilen - i );
- Word64 temp_b = (Word64) tmp_out2_fx[output_frame - 1 - i] * i;
- output_fx[ch][i] = (Word32) W_shr( ( W_add( temp_a, temp_b ) * flen_fx ), 31 );
+ Word64 temp_a = W_mult0_32_32( ptO_fx[i], sub( ilen, i ) );
+ Word64 temp_b = W_mult0_32_32( tmp_out2_fx[sub( output_frame, add( 1, i ) )], i );
+ output_fx[ch][i] = W_extract_l( W_shr( ( W_add( temp_a, temp_b ) * flen_fx ), 31 ) );
move32();
}
j = 0;
@@ -4267,10 +4509,10 @@ void smooth_dft2td_transition_fx(
FOR( ; i < ilen; i++ )
{
Word64 temp_a = (Word64) ptO_fx[i] * ( ilen - i );
- Word64 temp_b = W_shr( ( W_add( (Word64) ( 4 - j ) * tmp_out2_fx[output_frame - 1 - i], (Word64) j * output_fx[ch][i] ) * i ), 2 );
- output_fx[ch][i] = (Word32) W_shr( ( W_add( temp_a, temp_b ) * flen_fx ), 31 );
+ Word64 temp_b = W_shr( ( W_add( W_mult0_32_32( sub( 4, j ), tmp_out2_fx[sub( output_frame, add( 1, i ) )] ), W_mult0_32_32( j, output_fx[ch][i] ) ) * i ), 2 );
+ output_fx[ch][i] = W_extract_l( W_shr( ( W_add( temp_a, temp_b ) * flen_fx ), 31 ) );
move32();
- j++;
+ j = add( j, 1 );
}
}
}
diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c
index ffb63c5ce67a68584e32a756499e5f5f7e7d58ba..79eac072c051164d0c788e9aec19d4adf75011b4 100644
--- a/lib_dec/ivas_stereo_td_dec.c
+++ b/lib_dec/ivas_stereo_td_dec.c
@@ -36,12 +36,14 @@
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include "ivas_cnst.h"
#include "wmc_auto.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "ivas_rom_com_fx.h"
+#endif
#ifndef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
@@ -85,23 +87,34 @@ void stereo_td_init_dec_fx(
)
{
hStereoTD->tdm_SM_flag = 0;
+ move16();
hStereoTD->tdm_last_SM_flag = 0;
+ move16();
hStereoTD->tdm_last_ratio_idx = LRTD_STEREO_MID_IS_PRIM;
+ move16();
hStereoTD->tdm_prev_last_SM_flag = 0;
+ move16();
hStereoTD->tdm_LRTD_flag = 0;
+ move16();
// hStereoTD->prevSP_ratio = 0.5f;
hStereoTD->prevSP_ratio_fx = ONE_IN_Q14; //.5
+ move16();
// hStereoTD->SP_ratio_LT = 0.0f;
hStereoTD->SP_ratio_LT_fx = 0;
+ move32();
// hStereoTD->c_LR_LT = 0.5f;
hStereoTD->c_LR_LT_fx = ONE_IN_Q30; //.5
+ move32();
hStereoTD->flag_skip_DMX = 0;
+ move16();
- if ( last_element_mode == IVAS_CPE_MDCT )
+ IF( EQ_16( last_element_mode, IVAS_CPE_MDCT ) )
{
hStereoTD->tdm_last_ratio_idx = LRTD_STEREO_LEFT_IS_PRIM;
+ move16();
hStereoTD->tdm_LRTD_flag = 1;
+ move16();
}
set32_fx( hStereoTD->TCX_old_syn_Overl_fx, 0, L_FRAME16k / 2 );
@@ -137,13 +150,22 @@ void tdm_configure_dec(
Word16 mod_ct, core, bits_offset;
Word16 idx_LRTD_pri_side, tdm_inst_ratio_idx;
Word32 element_brate_adapt;
- Word16 bstr_last_pos;
+ Word16 bstr_last_pos, temp;
hStereoTD = hCPE->hStereoTD;
sts = hCPE->hCoreCoder;
- element_brate_adapt = hCPE->element_brate + hCPE->brate_surplus;
- bstr_last_pos = (Word16) ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata + (Word16) ( hCPE->brate_surplus / FRAMES_PER_SEC );
+ element_brate_adapt = L_add( hCPE->element_brate, hCPE->brate_surplus );
+
+ IF( hCPE->brate_surplus < 0 )
+ {
+ temp = extract_l( L_negate( Mpy_32_32( L_abs( hCPE->brate_surplus ), ONE_BY_FRAMES_PER_SEC_Q31 ) ) );
+ }
+ ELSE
+ {
+ temp = extract_l( Mpy_32_32( hCPE->brate_surplus, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+ }
+ bstr_last_pos = add( sub( div_l( hCPE->element_brate, FRAMES_PER_SEC / 2 ), nb_bits_metadata ), temp );
/*----------------------------------------------------------------*
* Decode CoreCoder signaling
@@ -151,45 +173,55 @@ void tdm_configure_dec(
/* temporarily decode PCh signaling */
bits_offset = sts[0]->next_bit_pos;
+ move16();
core = get_indice_st( sts[0], hCPE->element_brate, bits_offset, 1 );
- bits_offset += 1;
+ bits_offset = add( bits_offset, 1 );
- IF( core == ACELP_CORE && hCPE->element_brate < IVAS_24k4 )
+ IF( core == ACELP_CORE && LT_32( hCPE->element_brate, IVAS_24k4 ) )
{
mod_ct = get_indice_st( sts[0], hCPE->element_brate, bits_offset, 3 );
/* Only transition mode is important to decoder, otherwise mod_ct is set to AUDIO only to easy debugging IF needed */
- IF( mod_ct != TRANSITION )
+ if ( NE_16( mod_ct, TRANSITION ) )
{
mod_ct = AUDIO;
+ move16();
}
}
ELSE /* core != ACELP_CORE */
{
mod_ct = AUDIO; /* coder_type == VOICED || coder_type == GENERIC */
+ move16();
}
/* Get few parameters needed to decode the bitrate allocated to each channel */
/* Get the coder_type of the secondary channel (last parameter on 2 bits) */
sts[1]->coder_type = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SECONDARY_SIGNALLING, TDM_SECONDARY_SIGNALLING );
+ move16();
/* Get the LRTD config flag: 1 = LRTD configuration, favor closer bitrate per channel;
0 = Pri/Sec configuration, bitrates linked wrt. the mono */
- tdm_tmp_SM_LRTD_flag = sts[1]->coder_type & 0x1;
- sts[1]->coder_type >>= 1;
+ tdm_tmp_SM_LRTD_flag = s_and( sts[1]->coder_type, 0x1 );
+ sts[1]->coder_type = shr( sts[1]->coder_type, 1 );
+ move16();
hStereoTD->tdm_Pitch_reuse_flag = 0;
+ move16();
- IF( sts[1]->coder_type == 2 )
+ IF( EQ_16( sts[1]->coder_type, 2 ) )
{
sts[1]->coder_type = GENERIC;
+ move16();
}
- ELSE IF( sts[1]->coder_type == 3 )
+ ELSE IF( EQ_16( sts[1]->coder_type, 3 ) )
{
sts[1]->coder_type = AUDIO;
+ move16();
- IF( hCPE->element_brate <= IVAS_24k4 )
+ IF( LE_32( hCPE->element_brate, IVAS_24k4 ) )
{
hStereoTD->tdm_Pitch_reuse_flag = 1;
+ move16();
sts[1]->coder_type = GENERIC;
+ move16();
}
}
@@ -198,104 +230,140 @@ void tdm_configure_dec(
*----------------------------------------------------------------*/
/* Get the correlation ratio */
- *tdm_ratio_idx = get_indice_st( sts[0], element_brate_adapt, (Word16) ( bstr_last_pos - TDM_SECONDARY_SIGNALLING - TDM_RATIO_BITS ), TDM_RATIO_BITS );
+ *tdm_ratio_idx = get_indice_st( sts[0], element_brate_adapt, ( sub( bstr_last_pos, ( TDM_SECONDARY_SIGNALLING + TDM_RATIO_BITS ) ) ), TDM_RATIO_BITS );
+ move16();
hStereoTD->tdm_use_IAWB_Ave_lpc = 0;
+ move16();
IF( sts[1]->coder_type == INACTIVE )
{
/* Get the flag on the LPC reusage type (primary channel of ave LPC */
- hStereoTD->tdm_use_IAWB_Ave_lpc = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SECONDARY_SIGNALLING - TDM_RATIO_BITS - TDM_LP_REUSE_BITS, TDM_LP_REUSE_BITS );
+ hStereoTD->tdm_use_IAWB_Ave_lpc = get_indice_st( sts[0], element_brate_adapt, sub( bstr_last_pos, TDM_SECONDARY_SIGNALLING + TDM_RATIO_BITS + TDM_LP_REUSE_BITS ), TDM_LP_REUSE_BITS );
+ move16();
hStereoTD->tdm_lp_reuse_flag = 1;
+ move16();
}
ELSE
{
/* Get the flag on the LPC reusage */
- hStereoTD->tdm_lp_reuse_flag = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SECONDARY_SIGNALLING - TDM_RATIO_BITS - TDM_LP_REUSE_BITS, TDM_LP_REUSE_BITS );
+ hStereoTD->tdm_lp_reuse_flag = get_indice_st( sts[0], element_brate_adapt, sub( bstr_last_pos, TDM_SECONDARY_SIGNALLING + TDM_RATIO_BITS + TDM_LP_REUSE_BITS ), TDM_LP_REUSE_BITS );
+ move16();
}
sts[0]->tdm_LRTD_flag = hStereoTD->tdm_LRTD_flag; /* the flag was already read in function stereo_memory_dec() */
+ move16();
sts[1]->tdm_LRTD_flag = hStereoTD->tdm_LRTD_flag;
+ move16();
tdm_inst_ratio_idx = *tdm_ratio_idx;
+ move16();
/* update past tdm_SM_flag */
hStereoTD->tdm_prev_last_SM_flag = hStereoTD->tdm_last_SM_flag;
+ move16();
hStereoTD->tdm_last_SM_flag = hStereoTD->tdm_SM_flag;
+ move16();
idx_LRTD_pri_side = -1;
- IF( hStereoTD->tdm_LRTD_flag == 1 )
+ move16();
+ IF( EQ_16( hStereoTD->tdm_LRTD_flag, 1 ) )
{
idx_LRTD_pri_side = tdm_tmp_SM_LRTD_flag;
+ move16();
hStereoTD->tdm_SM_flag = 0;
+ move16();
IF( tdm_inst_ratio_idx == TDM_NQ )
{
hStereoTD->flag_skip_DMX = 1;
+ move16();
}
ELSE
{
hStereoTD->flag_skip_DMX = 0;
+ move16();
}
/* Set primary channel */
*tdm_ratio_idx = LRTD_STEREO_RIGHT_IS_PRIM;
- IF( idx_LRTD_pri_side == 1 )
+ move16();
+ if ( EQ_16( idx_LRTD_pri_side, 1 ) )
{
*tdm_ratio_idx = LRTD_STEREO_LEFT_IS_PRIM;
+ move16();
}
}
ELSE
{
hStereoTD->tdm_SM_flag = tdm_tmp_SM_LRTD_flag;
- IF( hCPE->nchan_out == 1 )
+ move16();
+ if ( EQ_16( hCPE->nchan_out, 1 ) )
{
/* in case of mono output, use exclusively the YX upmixing scheme in order to deal with NOOP signals */
hStereoTD->tdm_SM_flag = 0;
+ move16();
}
}
- IF( sts[1]->coder_type == INACTIVE && ( *tdm_ratio_idx >= 29 || *tdm_ratio_idx <= 1 ) )
+ test();
+ test();
+ IF( sts[1]->coder_type == INACTIVE && ( GE_16( *tdm_ratio_idx, 29 ) || LE_16( *tdm_ratio_idx, 1 ) ) )
{
hStereoTD->tdm_lp_reuse_flag = hStereoTD->tdm_use_IAWB_Ave_lpc;
+ move16();
hStereoTD->tdm_use_IAWB_Ave_lpc = 0;
+ move16();
}
/*sts[1]->tdm_inst_ratio_idx = sts[0]->tdm_inst_ratio_idx;*/
- IF( hCPE->nchan_out == 1 && hCPE->hStereoDftDmx != NULL )
+ test();
+ test();
+ IF( EQ_16( hCPE->nchan_out, 1 ) && hCPE->hStereoDftDmx != NULL )
{
/* in mono DMX, only targetGain is needed */
Word16 tmpS = 20;
+ move16();
IF( hStereoTD->tdm_LRTD_flag == 0 )
{
- tmpS = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + STEREO_BITS_TCA_CHAN + STEREO_BITS_TCA_CORRSTATS, STEREO_BITS_TCA_GD );
+ tmpS = get_indice_st( sts[0], element_brate_adapt, add( sub( bstr_last_pos, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ), STEREO_BITS_TCA_CHAN + STEREO_BITS_TCA_CORRSTATS ), STEREO_BITS_TCA_GD );
}
hCPE->hStereoDftDmx->targetGain_fx = power_table[tmpS];
+ move32();
}
ELSE
{
IF( hStereoTD->tdm_LRTD_flag == 0 )
{
- hCPE->hStereoTCA->refChanIndx = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS, STEREO_BITS_TCA_CHAN );
- hCPE->hStereoTCA->indx_ica_NCShift = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + STEREO_BITS_TCA_CHAN, STEREO_BITS_TCA_CORRSTATS );
- hCPE->hStereoTCA->indx_ica_gD = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + STEREO_BITS_TCA_CHAN + STEREO_BITS_TCA_CORRSTATS, STEREO_BITS_TCA_GD );
+ hCPE->hStereoTCA->refChanIndx = get_indice_st( sts[0], element_brate_adapt, sub( bstr_last_pos, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ), STEREO_BITS_TCA_CHAN );
+ move16();
+ hCPE->hStereoTCA->indx_ica_NCShift = get_indice_st( sts[0], element_brate_adapt, add( sub( bstr_last_pos, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ), STEREO_BITS_TCA_CHAN ), STEREO_BITS_TCA_CORRSTATS );
+ move16();
+ hCPE->hStereoTCA->indx_ica_gD = get_indice_st( sts[0], element_brate_adapt, add( sub( bstr_last_pos, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ), STEREO_BITS_TCA_CHAN + STEREO_BITS_TCA_CORRSTATS ), STEREO_BITS_TCA_GD );
+ move16();
}
ELSE
{
hCPE->hStereoTCA->refChanIndx = L_CH_INDX;
+ move16();
hCPE->hStereoTCA->indx_ica_NCShift = 0;
+ move16();
hCPE->hStereoTCA->indx_ica_gD = 20;
+ move16();
}
hCPE->hStereoTCA->targetGain_fx = power_table[hCPE->hStereoTCA->indx_ica_gD];
+ move32();
}
/* set the BW of the secondary channel */
- IF( hStereoTD->tdm_LRTD_flag && sts[1]->bits_frame_channel >= IVAS_16k4 / FRAMES_PER_SEC )
+ IF( hStereoTD->tdm_LRTD_flag && GE_16( sts[1]->bits_frame_channel, IVAS_16k4 / FRAMES_PER_SEC ) )
{
/* set BW of the secondary channel in LRTD stereo mode as the BW of the primary channel at higher bitrates */
sts[1]->bwidth = sts[0]->bwidth;
+ move16();
}
ELSE
{
/* limit BW of the secondary channel in LRTD mode to WB for low bitrates */
sts[1]->bwidth = WB;
+ move16();
}
/*----------------------------------------------------------------*
@@ -553,14 +621,16 @@ void tdm_upmix_plain_fx(
{
Word16 i;
- IF( plus_minus_flag == 1 )
+ IF( EQ_16( plus_minus_flag, 1 ) )
{
FOR( i = start_index; i < end_index; i++ )
{
Word32 temp_left = L_add( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] );
Left_fx[i] = L_shl_sat( Mpy_32_32( temp_left, inv_den_LR_ratio_fx ), 1 );
+ move32();
Word32 temp_right = L_add( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), L_negate( LR_ratio_fx ) ), PCh_2_L_fx[i] );
Right_fx[i] = L_shl_sat( Mpy_32_32( temp_right, inv_den_LR_ratio_fx ), 1 );
+ move32();
}
}
ELSE
@@ -569,8 +639,10 @@ void tdm_upmix_plain_fx(
{
Word32 temp_left = L_sub( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] );
Left_fx[i] = L_shl_sat( Mpy_32_32( temp_left, inv_den_LR_ratio_fx ), 1 );
+ move32();
Word32 temp_right = L_sub( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), PCh_2_L_fx[i] );
Right_fx[i] = L_shl_sat( Mpy_32_32( temp_right, inv_den_LR_ratio_fx ), 1 );
+ move32();
}
}
@@ -799,7 +871,9 @@ static void tdm_upmix_fade_fx(
step_fx = inv_time[end_index - start_index];
fade_out_fx = ONE_IN_Q31;
+ move32();
fade_in_fx = 0;
+ move32();
fade_out_fx = Mpy_32_32( fade_out_fx, inv_den_LR_ratio_mem_fx );
fade_in_fx = Mpy_32_32( fade_in_fx, inv_den_LR_ratio_fx );
@@ -813,57 +887,65 @@ static void tdm_upmix_fade_fx(
Word32 temp_left1 = Mpy_32_32( L_add( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_mem_fx ), SCh_2_R_fx[i] ), fade_out_fx );
Word32 temp_left2 = Mpy_32_32( L_sub( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] ), fade_in_fx );
Left_fx[i] = L_shl_sat( L_add( temp_left1, temp_left2 ), 1 );
+ move32();
Word32 temp_right1 = Mpy_32_32( L_add( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), L_negate( LR_ratio_mem_fx ) ), PCh_2_L_fx[i] ), fade_out_fx );
Word32 temp_right2 = Mpy_32_32( L_sub( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), PCh_2_L_fx[i] ), fade_in_fx );
Right_fx[i] = L_shl_sat( L_add( temp_right1, temp_right2 ), 1 );
+ move32();
fade_in_fx = L_add( fade_in_fx, step2_fx );
fade_out_fx = L_sub( fade_out_fx, step_fx );
}
}
- ELSE IF( fading_type == 1 ) /* SM scheme */
+ ELSE IF( EQ_16( fading_type, 1 ) ) /* SM scheme */
{
FOR( i = start_index; i < end_index; i++ )
{
Word32 temp_left1 = Mpy_32_32( L_sub( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_mem_fx ), SCh_2_R_fx[i] ), fade_out_fx );
Word32 temp_left2 = Mpy_32_32( L_sub( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] ), fade_in_fx );
Left_fx[i] = L_shl_sat( L_add( temp_left1, temp_left2 ), 1 );
+ move32();
Word32 temp_right1 = Mpy_32_32( L_sub( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_mem_fx ), PCh_2_L_fx[i] ), fade_out_fx );
Word32 temp_right2 = Mpy_32_32( L_sub( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), PCh_2_L_fx[i] ), fade_in_fx );
Right_fx[i] = L_shl_sat( L_add( temp_right1, temp_right2 ), 1 );
+ move32();
fade_in_fx = L_add( fade_in_fx, step2_fx );
fade_out_fx = L_sub( fade_out_fx, step_fx );
}
}
- ELSE IF( fading_type == 2 ) /* Switching from SM scheme to YX scheme */
+ ELSE IF( EQ_16( fading_type, 2 ) ) /* Switching from SM scheme to YX scheme */
{
FOR( i = start_index; i < end_index; i++ )
{
Word32 temp_left1 = Mpy_32_32( L_sub( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_mem_fx ), SCh_2_R_fx[i] ), fade_out_fx );
Word32 temp_left2 = Mpy_32_32( L_add( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] ), fade_in_fx );
Left_fx[i] = L_shl_sat( L_add( temp_left1, temp_left2 ), 1 );
+ move32();
Word32 temp_right1 = Mpy_32_32( L_sub( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_mem_fx ), PCh_2_L_fx[i] ), fade_out_fx );
Word32 temp_right2 = Mpy_32_32( L_add( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), L_negate( LR_ratio_fx ) ), PCh_2_L_fx[i] ), fade_in_fx );
Right_fx[i] = L_shl_sat( L_add( temp_right1, temp_right2 ), 1 );
+ move32();
fade_in_fx = L_add( fade_in_fx, step2_fx );
fade_out_fx = L_sub( fade_out_fx, step_fx );
}
}
- ELSE IF( fading_type == 3 ) /* YX scheme */
+ ELSE IF( EQ_16( fading_type, 3 ) ) /* YX scheme */
{
FOR( i = start_index; i < end_index; i++ )
{
Word32 temp_left1 = Mpy_32_32( L_add( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_mem_fx ), SCh_2_R_fx[i] ), fade_out_fx );
Word32 temp_left2 = Mpy_32_32( L_add( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] ), fade_in_fx );
Left_fx[i] = L_shl_sat( L_add( temp_left1, temp_left2 ), 1 );
+ move32();
Word32 temp_right1 = Mpy_32_32( L_add( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), L_negate( LR_ratio_mem_fx ) ), PCh_2_L_fx[i] ), fade_out_fx );
Word32 temp_right2 = Mpy_32_32( L_add( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), L_negate( LR_ratio_fx ) ), PCh_2_L_fx[i] ), fade_in_fx );
Right_fx[i] = L_shl_sat( L_add( temp_right1, temp_right2 ), 1 );
+ move32();
fade_in_fx = L_add( fade_in_fx, step2_fx );
fade_out_fx = L_sub( fade_out_fx, step_fx );
@@ -1090,7 +1172,7 @@ void stereo_tdm_combine_fx(
}
ELSE IF( EQ_16( hCPE->hStereoTD->tdm_last_SM_flag, 1 ) )
{
- IF( EQ_16( hCPE->hStereoTD->tdm_prev_last_SM_flag, 0 ) )
+ IF( hCPE->hStereoTD->tdm_prev_last_SM_flag == 0 )
{
stereo_tdm_coder_type = 0; /* mode 1 : Switching from YX scheme to SM scheme*/
move16();
@@ -1123,10 +1205,10 @@ void stereo_tdm_combine_fx(
tdm_upmix_plain_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_mem_fx, tdm_den_ratio_tabl_fx[tdm_last_ratio_idx], 0, upmixing_delay, 1 );
/* Switching from YX scheme to SM scheme */
- tdm_upmix_fade_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_mem_fx, tdm_den_ratio_tabl_fx[tdm_last_ratio_idx], LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], upmixing_delay, upmixing_delay + tdm_n_OVA, 0 );
+ tdm_upmix_fade_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_mem_fx, tdm_den_ratio_tabl_fx[tdm_last_ratio_idx], LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], upmixing_delay, add( upmixing_delay, tdm_n_OVA ), 0 );
/* Do the upmixing of the other samples with the new coefficient and formular for SM scheme */
- tdm_upmix_plain_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], upmixing_delay + tdm_n_OVA, output_frame, 0 );
+ tdm_upmix_plain_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], add( upmixing_delay, tdm_n_OVA ), output_frame, 0 );
}
BREAK;
case ( 1 ):
@@ -1141,7 +1223,7 @@ void stereo_tdm_combine_fx(
}
ELSE
{
- tdm_upmix_fade_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_mem_fx, tdm_den_ratio_tabl_fx[tdm_last_ratio_idx], LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], upmixing_delay, upmixing_delay + tdm_n_OVA, 1 );
+ tdm_upmix_fade_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_mem_fx, tdm_den_ratio_tabl_fx[tdm_last_ratio_idx], LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], upmixing_delay, add( upmixing_delay, tdm_n_OVA ), 1 );
tdm_upmix_plain_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], upmixing_delay + tdm_n_OVA, output_frame, 0 );
}
}
@@ -1152,7 +1234,7 @@ void stereo_tdm_combine_fx(
tdm_upmix_plain_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_mem_fx, tdm_den_ratio_tabl_fx[tdm_last_ratio_idx], 0, upmixing_delay, 0 );
/* Switching from SM scheme to YX scheme */
- tdm_upmix_fade_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_mem_fx, tdm_den_ratio_tabl_fx[tdm_last_ratio_idx], LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], upmixing_delay, upmixing_delay + tdm_n_OVA, 2 );
+ tdm_upmix_fade_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_mem_fx, tdm_den_ratio_tabl_fx[tdm_last_ratio_idx], LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], upmixing_delay, add( upmixing_delay, tdm_n_OVA ), 2 );
/* Do the upmixing of the other samples with the new coefficient and formular for YX scheme */
tdm_upmix_plain_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], upmixing_delay + tdm_n_OVA, output_frame, 1 );
@@ -1170,7 +1252,7 @@ void stereo_tdm_combine_fx(
}
ELSE
{
- tdm_upmix_fade_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_mem_fx, tdm_den_ratio_tabl_fx[tdm_last_ratio_idx], LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], upmixing_delay, upmixing_delay + tdm_n_OVA, 3 );
+ tdm_upmix_fade_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_mem_fx, tdm_den_ratio_tabl_fx[tdm_last_ratio_idx], LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], upmixing_delay, add( upmixing_delay, tdm_n_OVA ), 3 );
tdm_upmix_plain_fx( Left_fx, Right_fx, PCh_2_L_fx, SCh_2_R_fx, LR_ratio_fx, tdm_den_ratio_tabl_fx[tdm_ratio_idx], upmixing_delay + tdm_n_OVA, output_frame, 1 );
}
}
diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c
index 218be76403458facef2ad088b6d5bda5a63d0b03..9156aa7180b1b50b99c907d55a22652226c227b9 100644
--- a/lib_dec/ivas_svd_dec.c
+++ b/lib_dec/ivas_svd_dec.c
@@ -38,8 +38,7 @@
#include "ivas_cnst.h"
#include
#include "wmc_auto.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-----------------------------------------------------------------------*
@@ -52,7 +51,7 @@
#ifdef NONBE_FIX_1069_SVD_TUNING
#define SVD_MINIMUM_VALUE 1e-32f /* minimum value */
#define CONVERGENCE_FACTOR 1.0e-04f /* factor for SVD convergence */
-#define SVD_ZERO_FLUSH_THRESHOLD 0.0f
+#define SVD_ZERO_FLUSH_THRESHOLD 1.0e-20f
#else
#define SVD_MINIMUM_VALUE 1e-32f /* minimum value */
#define CONVERGENCE_FACTOR 1.19209290e-07f /* factor for SVD convergence */
@@ -236,7 +235,8 @@ void mat2svdMat_fx(
{
FOR( j = 0; j < nRows; j++ )
{
- svdMat[i][j] = mat[j + nRows * i];
+ svdMat[i][j] = mat[add( j, i_mult( nRows, i ) )];
+ move32();
}
set_zero_fx( &svdMat[i][mCols], MAX_OUTPUT_CHANNELS - nRows );
@@ -253,7 +253,8 @@ void mat2svdMat_fx(
{
FOR( j = 0; j < mCols; j++ )
{
- svdMat[i][j] = mat[i + nRows * j];
+ svdMat[i][j] = mat[add( i, i_mult( nRows, j ) )];
+ move32();
}
set_zero_fx( &svdMat[i][mCols], MAX_OUTPUT_CHANNELS - mCols );
@@ -288,7 +289,8 @@ void svdMat2mat_fx(
{
FOR( j = 0; j < mCols; j++ )
{
- mat[i + nRows * j] = svdMat[i][j];
+ mat[add( i, i_mult( nRows, j ) )] = svdMat[i][j];
+ move32();
}
}
@@ -405,8 +407,11 @@ Word16 svd_fx(
// int16_t max_length = ((nChannelsL > nChannelsC) ? nChannelsL : nChannelsC);
Word32 secDiag_fx[MAX_OUTPUT_CHANNELS];
Word16 secDiag_fx_e = 0;
+ move16();
Word32 eps_x_fx = 0, temp_fx;
+ move16();
Word16 eps_x_fx_e = 0;
+ move16();
push_wmops( "svd_fx" );
set32_fx( secDiag_fx, 0, MAX_OUTPUT_CHANNELS );
@@ -417,10 +422,12 @@ Word16 svd_fx(
FOR( jCh = 0; jCh < nChannelsC; jCh++ )
{
singularVectors_Left_fx[iCh][jCh] = InputMatrix[iCh][jCh];
+ move32();
}
}
*singularValues_fx_e = 0;
+ move16();
/* Householder reduction */
HouseholderReduction_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Right_fx, secDiag_fx, InputMatrix_e, singularValues_fx_e, &secDiag_fx_e, nChannelsL, nChannelsC, &eps_x_fx, &eps_x_fx_e );
@@ -439,27 +446,38 @@ Word16 svd_fx(
DO
{
condition = 0;
- FOR( iCh = 0; iCh < lengthSingularValues - 1; iCh++ )
+ move16();
+ FOR( iCh = 0; iCh < sub( lengthSingularValues, 1 ); iCh++ )
{
IF( LT_32( singularValues_fx[iCh], singularValues_fx[iCh + 1] ) )
{
condition = 1;
+ move16();
temp_fx = singularValues_fx[iCh];
+ move32();
singularValues_fx[iCh] = singularValues_fx[iCh + 1];
+ move32();
singularValues_fx[iCh + 1] = temp_fx;
+ move32();
FOR( jCh = 0; jCh < nChannelsL; ++jCh )
{
temp_fx = singularVectors_Left_fx[jCh][iCh];
+ move32();
singularVectors_Left_fx[jCh][iCh] = singularVectors_Left_fx[jCh][iCh + 1];
+ move32();
singularVectors_Left_fx[jCh][iCh + 1] = temp_fx;
+ move32();
}
FOR( jCh = 0; jCh < nChannelsC; ++jCh )
{
temp_fx = singularVectors_Right_fx[jCh][iCh];
+ move32();
singularVectors_Right_fx[jCh][iCh] = singularVectors_Right_fx[jCh][iCh + 1];
+ move32();
singularVectors_Right_fx[jCh][iCh + 1] = temp_fx;
+ move32();
}
}
}
@@ -577,11 +595,16 @@ static Word16 BidagonalDiagonalisation_fx(
Word32 c, s, f1, f2;
Word16 c_e, s_e, f1_e, f2_e;
Word16 x11_e = 0, x12_e = 0;
+ move16();
+ move16();
Word16 temp_exp;
Word32 g = 0;
+ move16();
Word16 g_e = 0;
+ move16();
Word16 convergence, iteration, found_split;
Word16 error = 0;
+ move16();
Word16 singularValues_new_e[MAX_OUTPUT_CHANNELS], secDiag_new_e[MAX_OUTPUT_CHANNELS];
set16_fx( singularValues_new_e, *singularValues_fx_e, MAX_OUTPUT_CHANNELS );
set16_fx( secDiag_new_e, *secDiag_fx_e, MAX_OUTPUT_CHANNELS );
@@ -589,20 +612,25 @@ static Word16 BidagonalDiagonalisation_fx(
FOR( iCh = nChannelsC - 1; iCh >= 0; iCh-- ) /* nChannelsC */
{
convergence = 0;
+ move16();
iteration = 0;
+ move16();
split = iCh - 1;
+ move16();
WHILE( EQ_16( convergence, 0 ) )
{
- iteration++;
+ iteration = add( iteration, 1 );
found_split = 1;
+ move16();
FOR( jCh = iCh; jCh >= 0; jCh-- )
{
- split = jCh - 1;
+ split = sub( jCh, 1 );
IF( LE_16( BASOP_Util_Cmp_Mant32Exp( L_abs( secDiag_fx[jCh] ), secDiag_new_e[jCh], Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), eps_x_e ), 0 ) ) /* is secDiag[ch] vanishing compared to eps_x */
{
found_split = 0;
+ move16();
BREAK;
}
IF( LE_16( BASOP_Util_Cmp_Mant32Exp( L_abs( singularValues_fx[split] ), singularValues_new_e[split], Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), eps_x_e ), 0 ) ) /* is singularValues[split] vanishing compared to eps_x */
@@ -611,14 +639,28 @@ static Word16 BidagonalDiagonalisation_fx(
}
}
- convergence = ( jCh == iCh ) ? 1 : 0;
+ // convergence = ( jCh == iCh ) ? 1 : 0;
+ IF( EQ_16( jCh, iCh ) )
+ {
+ convergence = 1;
+ move16();
+ }
+ ELSE
+ {
+ convergence = 0;
+ move16();
+ }
IF( found_split )
{
s = MAX_32;
+ move32();
s_e = 0;
+ move16();
c = 0;
+ move32();
c_e = 0;
+ move16();
FOR( kCh = jCh; kCh <= iCh; kCh++ )
{
@@ -636,17 +678,19 @@ static Word16 BidagonalDiagonalisation_fx(
singularValues_fx[kCh] = GivensRotation_fx( g, g_e, singularValues_fx[kCh], singularValues_new_e[kCh], &singularValues_new_e[kCh] );
c = BASOP_Util_Divide3232_Scale_cadence( c, maxWithSign_fx( singularValues_fx[kCh] ), &temp_exp );
c_e = add( temp_exp, sub( c_e, singularValues_new_e[kCh] ) );
- IF( GT_16( c_e, 0 ) )
+ IF( c_e > 0 )
{
c = L_shl_sat( c, c_e ); // Q31
c_e = 0;
+ move16();
}
s = BASOP_Util_Divide3232_Scale_cadence( -g, maxWithSign_fx( singularValues_fx[kCh] ), &temp_exp );
s_e = add( temp_exp, sub( g_e, singularValues_new_e[kCh] ) );
- IF( GT_16( s_e, 0 ) )
+ IF( s_e > 0 )
{
s = L_shl_sat( s, s_e ); // Q31
s_e = 0;
+ move16();
}
ApplyRotation_fx( singularVectors_Left_fx, c, c_e, s, s_e, 0, x11_e, 0, x12_e, &f1, &f1_e, &f2, &f2_e, kCh, split, nChannelsL ); /* nChannelsL */
@@ -655,13 +699,16 @@ static Word16 BidagonalDiagonalisation_fx(
IF( convergence )
{
- singularValues_fx[iCh] = (Word32) singularValues_fx[iCh];
- IF( LT_32( singularValues_fx[iCh], 0 ) )
+ singularValues_fx[iCh] = singularValues_fx[iCh];
+ move32();
+ IF( singularValues_fx[iCh] < 0 )
{
singularValues_fx[iCh] = L_negate( singularValues_fx[iCh] );
+ move32();
FOR( nCh = 0; nCh < nChannelsC; nCh++ ) /* nChannelsC */
{
singularVectors_Right_fx[nCh][iCh] = L_negate( singularVectors_Right_fx[nCh][iCh] );
+ move32();
}
}
}
@@ -672,14 +719,18 @@ static Word16 BidagonalDiagonalisation_fx(
IF( LT_32( singularValues_fx[iCh], 0 ) )
{
singularValues_fx[iCh] = L_negate( singularValues_fx[iCh] );
+ move32();
FOR( nCh = 0; nCh < nChannelsC; nCh++ ) /* nChannelsC */
{
singularVectors_Right_fx[nCh][iCh] = L_negate( singularVectors_Right_fx[nCh][iCh] );
+ move32();
}
}
error = 1;
+ move16();
convergence = 1;
+ move16();
}
ELSE
{
@@ -691,30 +742,40 @@ static Word16 BidagonalDiagonalisation_fx(
// rescaling block
Word16 max_exp = -31;
- FOR( iCh = 0; iCh < nChannelsC; iCh++ ){
- IF( singularValues_fx[iCh] ){
+ move16();
+ FOR( iCh = 0; iCh < nChannelsC; iCh++ )
+ {
+ if ( singularValues_fx[iCh] )
+ {
max_exp = s_max( max_exp, singularValues_new_e[iCh] );
-}
-}
-*singularValues_fx_e = max_exp;
-FOR( iCh = 0; iCh < nChannelsC; iCh++ )
-{
- singularValues_fx[iCh] = L_shr_r( singularValues_fx[iCh], sub( *singularValues_fx_e, singularValues_new_e[iCh] ) );
-}
+ }
+ }
+ *singularValues_fx_e = max_exp;
+ move16();
+ FOR( iCh = 0; iCh < nChannelsC; iCh++ )
+ {
+ singularValues_fx[iCh] = L_shr_r( singularValues_fx[iCh], sub( *singularValues_fx_e, singularValues_new_e[iCh] ) );
+ move32();
+ }
-max_exp = -31;
-FOR( iCh = 0; iCh < nChannelsC; iCh++ ){
- IF( secDiag_fx[iCh] ){
- max_exp = s_max( max_exp, secDiag_new_e[iCh] );
-}
-}
-*secDiag_fx_e = max_exp;
-FOR( iCh = 0; iCh < nChannelsC; iCh++ )
-{
- secDiag_fx[iCh] = L_shr_r( secDiag_fx[iCh], sub( *secDiag_fx_e, secDiag_new_e[iCh] ) );
-}
+ max_exp = -31;
+ move16();
+ FOR( iCh = 0; iCh < nChannelsC; iCh++ )
+ {
+ if ( secDiag_fx[iCh] )
+ {
+ max_exp = s_max( max_exp, secDiag_new_e[iCh] );
+ }
+ }
+ *secDiag_fx_e = max_exp;
+ move16();
+ FOR( iCh = 0; iCh < nChannelsC; iCh++ )
+ {
+ secDiag_fx[iCh] = L_shr_r( secDiag_fx[iCh], sub( *secDiag_fx_e, secDiag_new_e[iCh] ) );
+ move32();
+ }
-return ( error );
+ return ( error );
}
#else
static int16_t BidagonalDiagonalisation(
@@ -845,26 +906,57 @@ static void ApplyQRTransform_fx(
{
Word16 ch, split;
Word32 d = 0, g = 0, r = 0, x_ii = 0, x_split = 0, x_kk = 0, mu = 0, aux = 0;
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
Word16 d_e = 0, g_e = 0, r_e = 0, x_ii_e = 0, x_split_e = 0, x_kk_e = 0, mu_e = 0, aux_e = 0;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
Word32 L_temp1, L_temp2, L_temp3, L_temp4;
Word16 L_temp1_e, L_temp2_e, L_temp3_e, L_temp4_e, temp_exp;
Word32 c = MAX_32;
+ move32();
Word16 c_e = 0;
+ move16();
Word32 s = MAX_32;
+ move32();
Word16 s_e = 0;
+ move16();
x_kk = singularValues[currentIndex];
+ move32();
x_kk_e = singularValues_e[currentIndex];
+ move16();
x_ii = singularValues[startIndex];
+ move32();
x_ii_e = singularValues_e[startIndex];
- split = currentIndex - 1;
+ move16();
+ split = sub( currentIndex, 1 );
+ move16();
x_split = singularValues[split];
+ move32();
x_split_e = singularValues_e[split];
+ move16();
g = secDiag[split];
+ move32();
g_e = secDiag_e[split];
+ move16();
r = secDiag[currentIndex];
+ move32();
r_e = secDiag_e[currentIndex];
+ move16();
// d = (x_split + x_kk) * (x_split - x_kk) + (g + r) * (g - r);
L_temp1 = BASOP_Util_Add_Mant32Exp( x_split, x_split_e, x_kk, x_kk_e, &L_temp1_e );
@@ -883,8 +975,17 @@ static void ApplyQRTransform_fx(
g = GivensRotation_fx( MAX_32, 0, d, d_e, &g_e );
// mu = x_split / maxWithSign(d + (d >= 0.0f ? 1 : (-1)) * fabsf(g)) - r;
- L_temp1 = d >= 0 ? L_abs( g ) : -L_abs( g );
+ // L_temp1 = d >= 0 ? L_abs( g ) : -L_abs( g );
+ IF( d >= 0 )
+ {
+ L_temp1 = L_abs( g );
+ }
+ ELSE
+ {
+ L_temp1 = L_negate( L_abs( g ) );
+ }
L_temp1_e = g_e;
+ move16();
L_temp2 = maxWithSign_fx( BASOP_Util_Add_Mant32Exp( d, d_e, L_temp1, L_temp1_e, &L_temp2_e ) );
mu = BASOP_Util_Divide3232_Scale_cadence( x_split, L_temp2, &mu_e );
mu_e = add( mu_e, sub( x_split_e, L_temp2_e ) );
@@ -906,19 +1007,22 @@ static void ApplyQRTransform_fx(
g_e = add( c_e, secDiag_e[ch + 1] );
secDiag[ch] = GivensRotation_fx( d, d_e, r, r_e, &secDiag_e[ch] );
+ move32();
c = BASOP_Util_Divide3232_Scale_cadence( d, maxWithSign_fx( secDiag[ch] ), &c_e );
c_e = add( c_e, sub( d_e, secDiag_e[ch] ) );
- IF( GT_16( c_e, 0 ) )
+ IF( c_e > 0 )
{
c = L_shl_sat( c, c_e ); // Q31
c_e = 0;
+ move16();
}
s = BASOP_Util_Divide3232_Scale_cadence( r, maxWithSign_fx( secDiag[ch] ), &s_e );
s_e = add( s_e, sub( r_e, secDiag_e[ch] ) );
- IF( GT_16( s_e, 0 ) )
+ IF( s_e > 0 )
{
s = L_shl_sat( s, s_e ); // Q31
s_e = 0;
+ move16();
}
r = Mpy_32_32( s, singularValues[ch + 1] );
@@ -927,12 +1031,15 @@ static void ApplyQRTransform_fx(
x_split_e = add( c_e, singularValues_e[ch + 1] );
aux = g;
+ move32();
aux_e = g_e;
+ move16();
// ApplyRotation(singularVectors_Right, c, s, x_ii, aux, &d, &g, ch + 1, ch, nChannelsC);
ApplyRotation_fx( singularVectors_Right, c, c_e, s, s_e, x_ii, x_ii_e, aux, aux_e, &d, &d_e, &g, &g_e, ch + 1, ch, nChannelsC );
singularValues[ch] = GivensRotation_fx( d, d_e, r, r_e, &singularValues_e[ch] );
+ move32();
IF( GT_32( L_abs( singularValues[ch] ), Mpy_32_32( CONVERGENCE_FACTOR_FX, L_abs( singularValues[ch] ) ) ) )
{
aux = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, singularValues[ch], &aux_e );
@@ -940,18 +1047,20 @@ static void ApplyQRTransform_fx(
c = Mpy_32_32( d, aux );
c_e = add( d_e, aux_e );
- IF( GT_16( c_e, 0 ) )
+ IF( c_e > 0 )
{
c = L_shl_sat( c, c_e ); // Q31
c_e = 0;
+ move16();
}
s = Mpy_32_32( r, aux );
s_e = add( r_e, aux_e );
- IF( GT_16( s_e, 0 ) )
+ IF( s_e > 0 )
{
s = L_shl_sat( s, s_e ); // Q31
s_e = 0;
+ move16();
}
}
@@ -960,10 +1069,15 @@ static void ApplyQRTransform_fx(
}
secDiag[startIndex] = 0;
+ move32();
secDiag[currentIndex] = d;
+ move32();
secDiag_e[currentIndex] = d_e;
+ move16();
singularValues[currentIndex] = x_ii;
+ move32();
singularValues_e[currentIndex] = x_ii_e;
+ move16();
return;
}
@@ -1062,16 +1176,24 @@ static void ApplyRotation_fx(
Word16 temp_exp;
*d = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x11 ), add( c_e, x11_e ), Mpy_32_32( s, x12 ), add( s_e, x12_e ), d_e );
+ move32();
*g = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), add( c_e, x12_e ), Mpy_32_32( -s, x11 ), add( s_e, x11_e ), g_e );
+ move32();
FOR( ch = 0; ch < nChannels; ch++ )
{
x11 = singularVector[ch][currentIndex2];
+ move32();
x12 = singularVector[ch][currentIndex1];
+ move32();
singularVector[ch][currentIndex2] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x11 ), c_e, Mpy_32_32( s, x12 ), s_e, &temp_exp );
+ move32();
singularVector[ch][currentIndex2] = L_shl_sat( singularVector[ch][currentIndex2], temp_exp );
+ move32();
singularVector[ch][currentIndex1] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), c_e, Mpy_32_32( -s, x11 ), s_e, &temp_exp );
+ move32();
singularVector[ch][currentIndex1] = L_shl_sat( singularVector[ch][currentIndex1], temp_exp );
+ move32();
}
return;
@@ -1121,15 +1243,18 @@ static void HouseholderReduction_fx(
Word16 singularVectors_Left_e,
Word16 *singularValues_fx_e,
Word16 *secDiag_fx_e,
- const int16_t nChannelsL,
- const int16_t nChannelsC,
+ const Word16 nChannelsL,
+ const Word16 nChannelsC,
Word32 *eps_x_fx,
Word16 *eps_x_fx_e )
{
- int16_t nCh;
+ Word16 nCh;
// float g = 0.0f, sig_x = 0.0f;// to be removed
Word32 g_fx = 0, sig_x_fx = 0;
+ move32();
+ move32();
Word16 sig_x_fx_e = 0;
+ move16();
/* Bidiagonal Reduction for every channel */
FOR( nCh = 0; nCh < nChannelsC; nCh++ ) /* nChannelsC */
@@ -1142,7 +1267,9 @@ static void HouseholderReduction_fx(
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_temp, L_temp_e, *eps_x_fx, *eps_x_fx_e ), 1 ) )
{
*eps_x_fx = L_temp;
+ move32();
*eps_x_fx_e = L_temp_e;
+ move32();
}
}
@@ -1212,32 +1339,39 @@ static void biDiagonalReductionLeft_fx(
Word16 L_temp_e;
FOR( jCh = 0; jCh < MAX_OUTPUT_CHANNELS; jCh++ )
{
- set_s( sing_exp2[jCh], *singularVectors_e, MAX_OUTPUT_CHANNELS );
+ set16_fx( sing_exp2[jCh], *singularVectors_e, MAX_OUTPUT_CHANNELS );
}
secDiag[currChannel] = Mpy_32_32( *sig_x, *g );
+ move32();
// rescaling block
IF( GT_16( *sig_x_e, *secDiag_e ) )
{
FOR( Word16 i = 0; i < MAX_OUTPUT_CHANNELS; i++ ){
IF( NE_16( i, currChannel ) ){
secDiag[i] = L_shl( secDiag[i], sub( *secDiag_e, *sig_x_e ) );
+ move32();
}
}
*secDiag_e = *sig_x_e;
+move16();
}
ELSE IF( LT_16( *sig_x_e, *secDiag_e ) )
{
secDiag[currChannel] = L_shr_r( secDiag[currChannel], sub( *secDiag_e, *sig_x_e ) );
+ move32();
}
/* Setting values to 0 */
( *sig_x ) = 0;
+move32();
( *g ) = 0;
+move32();
IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */
{
idx = currChannel;
+ move16();
FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */
{
@@ -1247,30 +1381,50 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */
IF( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */
{
norm_x = 0;
+ move32();
norm_x_e = 0;
+ move16();
FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */
{
singularVectors[jCh][currChannel] = BASOP_Util_Divide3232_Scale_cadence( singularVectors[jCh][currChannel], maxWithSign_fx( *sig_x ), &sing_exp[jCh] );
+ move32();
sing_exp[jCh] = add( sing_exp[jCh], sub( *singularVectors_e, *sig_x_e ) );
+ move16();
norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sing_exp[jCh], 1 ), &norm_x_e );
}
IF( GT_16( norm_x_e, 0 ) )
{
norm_x = MAX_32;
+ move32();
norm_x_e = 0;
+ move16();
}
L_temp_e = norm_x_e;
+ move16();
L_temp = Sqrt32( norm_x, &L_temp_e );
L_temp = L_shl_r( L_temp, L_temp_e ); // Q31
- ( *g ) = L_negate( GE_32( singularVectors[currChannel][idx], 0 ) ? L_temp : L_negate( L_temp ) );
+ //( *g ) = L_negate( GE_32( singularVectors[currChannel][idx], 0 ) ? L_temp : L_negate( L_temp ) );
+ IF( singularVectors[currChannel][idx] >= 0 )
+ {
+ ( *g ) = L_negate( L_temp );
+ move32();
+ }
+ ELSE
+ {
+ ( *g ) = L_negate( L_negate( L_temp ) );
+ move32();
+ }
r = BASOP_Util_Add_Mant32Exp( Mpy_32_32( ( *g ), singularVectors[currChannel][idx] ), sing_exp[currChannel], -norm_x, norm_x_e, &r_e );
singularVectors[currChannel][idx] = BASOP_Util_Add_Mant32Exp( singularVectors[currChannel][idx], sing_exp[idx], -( *g ), 0, &sing_exp[currChannel] );
+ move32();
FOR( iCh = currChannel + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */
{
norm_x = 0;
+ move32();
norm_x_e = 0;
+ move16();
FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */
{
norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][iCh] ), add( sing_exp[jCh], *singularVectors_e ), &norm_x_e );
@@ -1282,6 +1436,7 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */
FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */
{
singularVectors[jCh][iCh] = BASOP_Util_Add_Mant32Exp( singularVectors[jCh][iCh], *singularVectors_e, Mpy_32_32( f, singularVectors[jCh][currChannel] ), add( f_e, sing_exp[jCh] ), &sing_exp2[jCh][iCh] );
+ move32();
}
}
@@ -1289,11 +1444,14 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */
FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */
{
singularVectors[jCh][currChannel] = Mpy_32_32( singularVectors[jCh][currChannel], ( *sig_x ) );
+ move32();
sing_exp2[jCh][currChannel] = add( sing_exp[jCh], *sig_x_e );
+ move16();
}
// rescaling block
Word16 exp_max = *singularVectors_e;
+ move16();
FOR( iCh = 0; iCh < nChannelsC; iCh++ )
{
FOR( jCh = 0; jCh < nChannelsL; jCh++ )
@@ -1307,25 +1465,31 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */
FOR( jCh = 0; jCh < nChannelsL; jCh++ )
{
singularVectors[jCh][iCh] = L_shr_r( singularVectors[jCh][iCh], sub( exp_max, sing_exp2[jCh][iCh] ) );
+ move32();
}
}
*singularVectors_e = exp_max;
+ move16();
}
// rescaling block
singularValues[currChannel] = Mpy_32_32( ( *sig_x ), ( *g ) );
+ move32();
IF( GT_16( *sig_x_e, *singularValues_e ) )
{
FOR( Word16 i = 0; i < MAX_OUTPUT_CHANNELS; i++ ){
IF( NE_16( i, currChannel ) ){
singularValues[i] = L_shl( singularValues[i], sub( *singularValues_e, *sig_x_e ) );
+ move32();
}
}
*singularValues_e = *sig_x_e;
+move16();
}
ELSE IF( LT_16( *sig_x_e, *singularValues_e ) )
{
singularValues[currChannel] = L_shr_r( singularValues[currChannel], sub( *singularValues_e, *sig_x_e ) );
+ move32();
}
}
@@ -1433,13 +1597,15 @@ static void biDiagonalReductionRight_fx(
Word16 L_temp_e;
FOR( jCh = 0; jCh < MAX_OUTPUT_CHANNELS; jCh++ )
{
- set_s( sing_exp2[jCh], *singularVectors_e, MAX_OUTPUT_CHANNELS );
+ set16_fx( sing_exp2[jCh], *singularVectors_e, MAX_OUTPUT_CHANNELS );
}
- set_s( secDiag_exp, *secDiag_e, MAX_OUTPUT_CHANNELS );
+ set16_fx( secDiag_exp, *secDiag_e, MAX_OUTPUT_CHANNELS );
/* Setting values to 0 */
( *sig_x ) = 0;
+ move32();
( *g ) = 0;
+ move32();
IF( LT_16( currChannel, nChannelsL ) && NE_16( currChannel, sub( nChannelsC, 1 ) ) ) /* i <=m && i !=n */
{
@@ -1453,37 +1619,58 @@ static void biDiagonalReductionRight_fx(
IF( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */
{
norm_x = 0;
+ move32();
norm_x_e = 0;
+ move16();
FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /*nChannelsC */
{
singularVectors[currChannel][jCh] = BASOP_Util_Divide3232_Scale_cadence( singularVectors[currChannel][jCh], maxWithSign_fx( *sig_x ), &sing_exp[jCh] );
+ move32();
sing_exp[jCh] = add( sing_exp[jCh], sub( *singularVectors_e, *sig_x_e ) );
+ move16();
norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[currChannel][jCh], singularVectors[currChannel][jCh] ), shl( sing_exp[jCh], 1 ), &norm_x_e );
}
IF( GT_16( norm_x_e, 0 ) )
{
norm_x = MAX_32;
+ move32();
norm_x_e = 0;
+ move16();
}
L_temp_e = norm_x_e;
+ move16();
L_temp = Sqrt32( norm_x, &L_temp_e );
L_temp = L_shl_r( L_temp, L_temp_e ); // Q31
- ( *g ) = L_negate( GE_32( singularVectors[currChannel][idx], 0 ) ? L_temp : L_negate( L_temp ) );
+ IF( singularVectors[currChannel][idx] >= 0 )
+ {
+ ( *g ) = L_negate( L_temp );
+ move32();
+ }
+ ELSE
+ {
+ ( *g ) = L_negate( L_negate( L_temp ) );
+ move32();
+ }
r = BASOP_Util_Add_Mant32Exp( Mpy_32_32( ( *g ), singularVectors[currChannel][idx] ), sing_exp[idx], -norm_x, norm_x_e, &r_e );
singularVectors[currChannel][idx] = BASOP_Util_Add_Mant32Exp( singularVectors[currChannel][idx], sing_exp[idx], -( *g ), 0, &sing_exp[idx] );
+ move32();
FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */
{
secDiag[jCh] = BASOP_Util_Divide3232_Scale_cadence( singularVectors[currChannel][jCh], maxWithSign_fx( r ), &secDiag_exp[jCh] );
+ move32();
secDiag_exp[jCh] = add( secDiag_exp[jCh], sub( sing_exp[jCh], r_e ) );
+ move32();
}
FOR( iCh = currChannel + 1; iCh < nChannelsL; iCh++ ) /* nChannelsL */
{
norm_x = 0;
+ move32();
norm_x_e = 0;
+ move16();
FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */
{
norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[iCh][jCh], singularVectors[currChannel][jCh] ), add( *singularVectors_e, sing_exp[jCh] ), &norm_x_e );
@@ -1492,17 +1679,21 @@ static void biDiagonalReductionRight_fx(
FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */
{
singularVectors[iCh][jCh] = BASOP_Util_Add_Mant32Exp( singularVectors[iCh][jCh], *singularVectors_e, Mpy_32_32( norm_x, secDiag[jCh] ), add( norm_x_e, secDiag_exp[jCh] ), &sing_exp2[iCh][jCh] );
+ move32();
}
}
FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */
{
singularVectors[currChannel][jCh] = Mpy_32_32( singularVectors[currChannel][jCh], ( *sig_x ) );
+ move32();
sing_exp2[currChannel][jCh] = add( sing_exp[jCh], *sig_x_e );
+ move16();
}
/*rescaling block*/
Word16 exp_max = *secDiag_e;
+ move16();
FOR( jCh = 0; jCh < nChannelsC; jCh++ )
{
exp_max = s_max( exp_max, secDiag_exp[jCh] );
@@ -1510,10 +1701,12 @@ static void biDiagonalReductionRight_fx(
FOR( jCh = 0; jCh < nChannelsC; jCh++ )
{
secDiag[jCh] = L_shr_r( secDiag[jCh], sub( exp_max, secDiag_exp[jCh] ) );
+ move32();
}
exp_max = *singularVectors_e;
+ move16();
FOR( iCh = 0; iCh < nChannelsL; iCh++ )
{
FOR( jCh = 0; jCh < nChannelsC; jCh++ )
@@ -1527,9 +1720,11 @@ static void biDiagonalReductionRight_fx(
FOR( jCh = 0; jCh < nChannelsC; jCh++ )
{
singularVectors[iCh][jCh] = L_shr_r( singularVectors[iCh][jCh], sub( exp_max, sing_exp2[iCh][jCh] ) );
+ move32();
}
}
*singularVectors_e = exp_max;
+ move16();
}
}
@@ -1626,7 +1821,7 @@ static void singularVectorsAccumulationLeft_fx(
Word16 sing_exp2[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS] = { 0 };
FOR( nCh = 0; nCh < MAX_OUTPUT_CHANNELS; nCh++ )
{
- set_s( sing_exp2[nCh], singularVectors_e, MAX_OUTPUT_CHANNELS );
+ set16_fx( sing_exp2[nCh], singularVectors_e, MAX_OUTPUT_CHANNELS );
}
/* Processing */
@@ -1635,11 +1830,14 @@ static void singularVectorsAccumulationLeft_fx(
FOR( nCh = nChannels - 1; nCh >= 0; nCh-- ) /* min(nChannelsL,ChannelsC) */
{
t_ii = singularValues[nCh];
+ move32();
t_ii_e = singularValues_e;
+ move16();
FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */
{
singularVectors_Left[nCh][iCh] = 0;
+ move32();
}
IF( t_ii ) /*if (fabsf(t_ii) > EPSILON *fabsf(t_ii)) {*/
@@ -1650,7 +1848,9 @@ static void singularVectorsAccumulationLeft_fx(
FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */
{
norm_y = 0;
+ move32();
norm_y_e = 0;
+ move16();
FOR( k = nCh + 1; k < nChannelsL; k++ ) /* nChannelsL */
{
norm_y = BASOP_Util_Add_Mant32Exp( norm_y, norm_y_e, Mpy_32_32( singularVectors_Left[k][nCh], singularVectors_Left[k][iCh] ), add( sing_exp2[k][nCh], sing_exp2[k][iCh] ), &norm_y_e );
@@ -1661,13 +1861,16 @@ static void singularVectorsAccumulationLeft_fx(
FOR( k = nCh; k < nChannelsL; k++ ) /* nChannelsL */
{
singularVectors_Left[k][iCh] = BASOP_Util_Add_Mant32Exp( singularVectors_Left[k][iCh], sing_exp2[k][iCh], Mpy_32_32( t_jj, singularVectors_Left[k][nCh] ), add( t_jj_e, sing_exp2[k][nCh] ), &sing_exp2[k][iCh] );
+ move32();
}
}
FOR( iCh = nCh; iCh < nChannelsL; iCh++ ) /* nChannelsL */
{
singularVectors_Left[iCh][nCh] = Mpy_32_32( singularVectors_Left[iCh][nCh], t_ii );
+ move32();
sing_exp2[iCh][nCh] = add( sing_exp2[iCh][nCh], t_ii_e );
+ move16();
}
}
ELSE
@@ -1675,10 +1878,12 @@ static void singularVectorsAccumulationLeft_fx(
FOR( iCh = nCh; iCh < nChannelsL; iCh++ ) /* nChannelsL */
{
singularVectors_Left[iCh][nCh] = 0;
+ move32();
}
}
singularVectors_Left[nCh][nCh] = BASOP_Util_Add_Mant32Exp( singularVectors_Left[nCh][nCh], sing_exp2[nCh][nCh], ONE_IN_Q30, 1, &sing_exp2[nCh][nCh] );
+ move32();
}
// fclose(fp);
FOR( nCh = 0; nCh < nChannelsL; nCh++ )
@@ -1686,6 +1891,7 @@ static void singularVectorsAccumulationLeft_fx(
FOR( iCh = 0; iCh < nChannelsC; iCh++ )
{
singularVectors_Left[nCh][iCh] = L_shl_sat( singularVectors_Left[nCh][iCh], sing_exp2[nCh][iCh] );
+ move32();
}
}
@@ -1779,6 +1985,7 @@ static void singularVectorsAccumulationRight_fx(
/* avoid compiler warning */
t_ii = secDiag[nChannels - 1];
+ move32();
FOR( nCh = nChannels - 1; nCh >= 0; nCh-- ) /* nChannelsC, min(nChannelsLmnChannelsC) otherwise */
{
@@ -1792,14 +1999,18 @@ static void singularVectorsAccumulationRight_fx(
{
ratio_float = BASOP_Util_Divide3232_Scale_cadence( singularVectors_Left[nCh][iCh], maxWithSign_fx( singularVectors_Left[nCh][nCh + 1] ), &temp_exp1 );
singularVectors_Right[iCh][nCh] = BASOP_Util_Divide3232_Scale_cadence( ratio_float, maxWithSign_fx( t_ii ), &sing_right_exp[iCh][nCh] );
+ move32();
sing_right_exp[iCh][nCh] = add( sing_right_exp[iCh][nCh], sub( temp_exp1, secDiag_e ) );
+ move16();
// singularVectors_Right[iCh][nCh] = L_shl_sat( singularVectors_Right[iCh][nCh], temp_exp2 );
}
FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */
{
norm_y = 0;
+ move32();
norm_y_e = 0;
+ move16();
FOR( k = nCh + 1; k < nChannelsC; k++ ) /* nChannelsC */
{
@@ -1809,8 +2020,11 @@ static void singularVectorsAccumulationRight_fx(
FOR( k = nCh + 1; k < nChannelsC; k++ ) /* nChannelsC */
{
singularVectors_Right[k][iCh] = BASOP_Util_Add_Mant32Exp( singularVectors_Right[k][iCh], sing_right_exp[k][iCh], Mpy_32_32( norm_y, singularVectors_Right[k][nCh] ), add( norm_y_e, sing_right_exp[k][nCh] ), &sing_right_exp[k][iCh] );
+ move32();
singularVectors_Right[k][iCh] = L_shl_sat( singularVectors_Right[k][iCh], sing_right_exp[k][iCh] );
+ move32();
sing_right_exp[k][iCh] = 0;
+ move16();
}
}
}
@@ -1818,10 +2032,14 @@ static void singularVectorsAccumulationRight_fx(
FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */
{
singularVectors_Right[nCh][iCh] = singularVectors_Right[iCh][nCh] = 0;
+ move32();
+ move32();
}
}
singularVectors_Right[nCh][nCh] = MAX_32;
+ move32();
t_ii = secDiag[nCh];
+ move32();
}
return;
}
@@ -1905,15 +2123,18 @@ static Word32 GivensRotation_fx(
Word32 L_temp;
x_abs = L_abs( x );
z_abs = L_abs( z );
+ test();
IF( LE_32( x_abs, Mpy_32_32( CONVERGENCE_FACTOR_FX, x_abs ) ) && LE_32( z_abs, Mpy_32_32( CONVERGENCE_FACTOR_FX, z_abs ) ) )
{
r = 0;
+ move32();
}
- ELSE IF( GE_16( BASOP_Util_Cmp_Mant32Exp( x_abs, x_e, z_abs, z_e ), 0 ) )
+ ELSE IF( BASOP_Util_Cmp_Mant32Exp( x_abs, x_e, z_abs, z_e ) >= 0 )
{
IF( LE_32( x_abs, SVD_MINIMUM_VALUE_FX ) )
{
r = 0;
+ move32();
}
ELSE
{
@@ -1930,12 +2151,13 @@ static Word32 GivensRotation_fx(
IF( LE_32( z_abs, SVD_MINIMUM_VALUE_FX ) )
{
r = 0;
+ move32();
}
ELSE
{
tan = BASOP_Util_Divide3232_Scale_cadence( x_abs, z_abs, &temp_exp );
temp_exp = add( temp_exp, sub( x_e, z_e ) );
- L_temp = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, 1, Mpy_32_32( tan, tan ), 2 * temp_exp, &temp_exp );
+ L_temp = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, 1, Mpy_32_32( tan, tan ), shl( temp_exp, 1 ), &temp_exp );
L_temp = Sqrt32( L_temp, &temp_exp );
r = Mpy_32_32( z_abs, L_temp );
*out_e = add( z_e, temp_exp );
@@ -2000,7 +2222,7 @@ static Word32 maxWithSign_fx(
{
return a;
}
- ELSE IF( LT_32( a, 0 ) )
+ ELSE IF( a < 0 )
{
return -SVD_MINIMUM_VALUE_FX;
}
diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c
index 342c69d71ab32d952f55ad896544c39a11963605..922f6e3694a411ae92e9be5d4ab0ffa6d934f555 100644
--- a/lib_dec/ivas_tcx_core_dec.c
+++ b/lib_dec/ivas_tcx_core_dec.c
@@ -35,14 +35,13 @@
#include "options.h"
#include
#include "prot.h"
-#include "prot_fx1.h"
#include "rom_com.h"
#include "stat_dec.h"
#include "wmc_auto.h"
#include "basop_proto_func.h"
#include "stat_com.h"
#include "ivas_prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
/*-------------------------------------------------------------*
@@ -77,16 +76,16 @@ void stereo_tcx_init_dec_fx(
TCX_DEC_HANDLE hTcxDec = st->hTcxDec;
st->rate_switching_init = 0;
- st->m_frame_type = ACTIVE_FRAME;
- st->core_brate = st->total_brate;
move16();
+ st->m_frame_type = ACTIVE_FRAME;
move16();
+ st->core_brate = st->total_brate;
move32();
/*sampling rate*/
st->sr_core = getCoreSamplerateMode2( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format );
- st->fscale = sr2fscale( st->sr_core );
move32();
+ st->fscale = sr2fscale( st->sr_core );
move16();
/*frame size*/
@@ -99,27 +98,29 @@ void stereo_tcx_init_dec_fx(
test();
test();
test();
- IF( ( EQ_16( st->L_frame, L_FRAME16k ) && LE_32( ( L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ), MAX_ACELP_BRATE ) ) || ( st->tcxonly && ( EQ_32( st->sr_core, 32000 ) || EQ_32( st->sr_core, INT_FS_16k ) ) ) )
+ IF( ( EQ_16( st->L_frame, L_FRAME16k ) && LE_32( L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), MAX_ACELP_BRATE ) ) || ( st->tcxonly && ( EQ_32( st->sr_core, 32000 ) || EQ_32( st->sr_core, INT_FS_16k ) ) ) )
{
st->nb_subfr = NB_SUBFR16k;
+ move16();
}
ELSE
{
st->nb_subfr = NB_SUBFR;
+ move16();
}
move16();
/*TCX tools*/
st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->rf_flag );
- st->hTcxCfg->resq = getResq( L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) );
- hTcxDec->tcx_lpc_shaped_ari = getTcxLpcShapedAri( L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->rf_flag, st->element_mode );
- st->igf = getIgfPresent_fx( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->bwidth, st->rf_flag );
move16();
+ st->hTcxCfg->resq = getResq( L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) );
move16();
+ hTcxDec->tcx_lpc_shaped_ari = getTcxLpcShapedAri( L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->rf_flag, st->element_mode );
move16();
+ st->igf = getIgfPresent_fx( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->bwidth, st->rf_flag );
move16();
- IF( NE_16( st->element_mode, EVS_MONO ) )
+ IF( st->element_mode != EVS_MONO )
{
st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->igf, st->element_mode );
move16();
@@ -135,25 +136,29 @@ void stereo_tcx_init_dec_fx(
st->tcxonly = getTcxonly_fx( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), MCT_flag, st->is_ism_format );
move16();
- test();
/* LPC quantization */
+ test();
IF( LE_32( st->sr_core, INT_FS_16k ) && st->tcxonly == 0 )
{
st->lpcQuantization = 1;
+ move16();
}
ELSE
{
st->lpcQuantization = 0;
+ move16();
}
move16();
IF( st->tcxonly == 0 )
{
st->numlpc = 1;
+ move16();
}
ELSE
{
st->numlpc = 2;
+ move16();
}
move16();
}
@@ -169,7 +174,7 @@ void stereo_tcx_init_dec_fx(
test();
IF( ( NE_32( st->bits_frame_nominal, st->last_bits_frame_nominal ) ) ||
( NE_16( st->bwidth, st->last_bwidth ) ) ||
- ( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) && !( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) ||
+ ( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) && !( EQ_16( st->prev_bfi, 1 ) && st->last_core == ACELP_CORE && EQ_16( st->last_con_tcx, 1 ) ) ) ||
( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( last_element_mode, IVAS_CPE_MDCT ) ) )
{
/*re-initialization*/
@@ -356,24 +361,24 @@ void stereo_tcx_core_dec_fx(
iDiv_and_mod_32( st->total_brate, FRAMES_PER_SEC, &L_tmp, &mod, 0 );
total_nbbits = extract_l( L_tmp );
bitsRead = 0;
- LSF_Q_prediction = -1; /* to avoid compilation warnings */
-
move16();
+ LSF_Q_prediction = -1; /* to avoid compilation warnings */
move16();
- IF( EQ_32( frameMode, FRAMEMODE_NORMAL ) )
+
+ IF( frameMode == FRAMEMODE_NORMAL )
{
st->m_decodeMode = DEC_NO_FRAM_LOSS;
+ move32();
bfi = 0;
move16();
- move16();
}
IF( EQ_32( frameMode, FRAMEMODE_MISSING ) )
{
st->m_decodeMode = DEC_CONCEALMENT_EXT;
+ move32();
bfi = 1;
move16();
- move16();
}
/* for bass postfilter */
IF( st->tcxonly )
@@ -403,6 +408,7 @@ void stereo_tcx_core_dec_fx(
IF( !bfi )
{
st->second_last_core = st->last_core;
+ move16();
move16();
dec_prm_tcx_ivas_fx( st, param, param_lpc, &total_nbbits, last_element_mode, &bitsRead );
@@ -439,10 +445,12 @@ void stereo_tcx_core_dec_fx(
IF( bfi && st->use_partial_copy && EQ_16( st->rf_frame_type, RF_TCXFD ) )
{
tcx_lpc_cdk = tcxlpc_get_cdk( GENERIC );
+ move16();
}
ELSE
{
tcx_lpc_cdk = tcxlpc_get_cdk( st->coder_type );
+ move16();
}
Copy( st->lsf_old_fx, &lsf_fx[0], M );
@@ -455,6 +463,7 @@ void stereo_tcx_core_dec_fx(
lsf_update_memory( st->narrowBand, &lsf_fx[M], st->mem_MA_fx, st->mem_MA_fx, M );
Copy( &lsf_fx[M], st->mem_AR_fx, M );
hTcxDec->envWeighted = 1;
+ move16();
move16();
E_LPC_lsp_unweight( &lsp_fx[M], lspnew_uw_fx, lsfnew_uw_fx, st->inv_gamma /*1.0f / st->gamma_float*/, M );
@@ -483,11 +492,11 @@ void stereo_tcx_core_dec_fx(
{
FOR( i = 0; i < M; i++ )
{
- st->lsf_adaptive_mean_fx[i] = add( add( mult_r( st->lsfoldbfi1_fx[i], ONE_BY_THREE_Q15 ), mult_r( st->lsfoldbfi0_fx[i], ONE_BY_THREE_Q15 ) ), mult_r( lsfnew_uw_fx[add( imult1616( k, M ), i )], ONE_BY_THREE_Q15 ) );
- st->lsfoldbfi1_fx[i] = st->lsfoldbfi0_fx[i];
- st->lsfoldbfi0_fx[i] = lsfnew_uw_fx[add( imult1616( k, M ), i )];
+ st->lsf_adaptive_mean_fx[i] = add( add( mult_r( st->lsfoldbfi1_fx[i], ONE_BY_THREE_Q15 ), mult_r( st->lsfoldbfi0_fx[i], ONE_BY_THREE_Q15 ) ), mult_r( lsfnew_uw_fx[add( i_mult( k, M ), i )], ONE_BY_THREE_Q15 ) );
move16();
+ st->lsfoldbfi1_fx[i] = st->lsfoldbfi0_fx[i];
move16();
+ st->lsfoldbfi0_fx[i] = lsfnew_uw_fx[add( i_mult( k, M ), i )];
move16();
}
}
@@ -501,10 +510,12 @@ void stereo_tcx_core_dec_fx(
IF( st->tcxonly == 0 || LT_16( st->core, TCX_10_CORE ) )
{
st->numlpc = 1;
+ move16();
}
ELSE
{
st->numlpc = 2;
+ move16();
}
move16();
@@ -550,6 +561,7 @@ void stereo_tcx_core_dec_fx(
E_LPC_f_lsp_a_conversion( st->lsp_old_fx, st->old_Aq_12_8_fx, M );
}
+ test();
if ( st->enablePlcWaveadjust && bfi )
{
st->hPlcInfo->nbLostCmpt = add( st->hPlcInfo->nbLostCmpt, 1 );
@@ -560,7 +572,7 @@ void stereo_tcx_core_dec_fx(
* TD-TCX concealment
*--------------------------------------------------------------------------------*/
- IF( EQ_16( st->core, ACELP_CORE ) )
+ IF( st->core == ACELP_CORE )
{
assert( bfi ); /*must only happen in BFI*/
@@ -594,7 +606,7 @@ void stereo_tcx_core_dec_fx(
test();
IF( st->narrowBand || EQ_32( st->sr_core, INT_FS_12k8 ) || EQ_32( st->sr_core, INT_FS_16k ) )
{
- Copy( Aq_fx, st->mem_Aq, imult1616( st->nb_subfr, ( M + 1 ) ) );
+ Copy( Aq_fx, st->mem_Aq, i_mult( st->nb_subfr, ( M + 1 ) ) );
}
/* PLC: [TCX: Tonal Concealment] */
@@ -618,6 +630,7 @@ void stereo_tcx_core_dec_fx(
IF( !bfi )
{
st->stab_fac_fx = lsf_stab_fx( &lsf_fx[M], &lsf_fx[0], 0, st->L_frame );
+ move16();
}
IF( hTcxDec->enableTcxLpc )
@@ -733,7 +746,7 @@ void stereo_tcx_core_dec_fx(
IF( st->narrowBand || EQ_32( st->sr_core, INT_FS_12k8 ) || EQ_32( st->sr_core, INT_FS_16k ) )
{
int_lsp_fx( st->L_frame, st->lspold_uw, lspnew_uw_fx, Aq_fx, M, interpol_frac_fx, 0 );
- Copy( Aq_fx, st->mem_Aq, imult1616( st->nb_subfr, ( M + 1 ) ) );
+ Copy( Aq_fx, st->mem_Aq, i_mult( st->nb_subfr, ( M + 1 ) ) );
}
}
}
@@ -755,10 +768,17 @@ void stereo_tcx_core_dec_fx(
/* note: codec_mode is forced to MODE2, since FEC_clas_estim() considers only TCX being in Mode2*/
Word16 prev_codec_mode = st->codec_mode;
- st->codec_mode = MODE2;
move16();
+ st->codec_mode = MODE2;
move16();
- FEC_clas_estim_fx( st, 0, st->L_frame, &st->clas_dec, st->tcxonly ? GENERIC : st->core_ext_mode, pitch_C, synth_fx, &st->lp_ener_FER_fx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 /*st->core_brate*/, st->Q_syn, NULL, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified : MIN_16, CLASSIFIER_TCX, bfi, st->last_core_brate, -1 );
+ IF( st->tcxonly )
+ {
+ FEC_clas_estim_fx( st, 0, st->L_frame, &st->clas_dec, GENERIC, pitch_C, synth_fx, &st->lp_ener_FER_fx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 /*st->core_brate*/, st->Q_syn, NULL, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified : MIN_16, CLASSIFIER_TCX, bfi, st->last_core_brate, -1 );
+ }
+ ELSE
+ {
+ FEC_clas_estim_fx( st, 0, st->L_frame, &st->clas_dec, st->core_ext_mode, pitch_C, synth_fx, &st->lp_ener_FER_fx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 /*st->core_brate*/, st->Q_syn, NULL, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified : MIN_16, CLASSIFIER_TCX, bfi, st->last_core_brate, -1 );
+ }
st->codec_mode = prev_codec_mode;
move16();
}
@@ -770,7 +790,7 @@ void stereo_tcx_core_dec_fx(
*--------------------------------------------------------------------------------*/
test();
- IF( bfi && NE_16( st->last_core, ACELP_CORE ) )
+ IF( bfi && st->last_core != ACELP_CORE )
{
/* Update FEC_scale_syn parameters */
IF( hTcxLtpDec->tcxltp_gain == 0 )
@@ -808,8 +828,8 @@ void stereo_tcx_core_dec_fx(
}
ELSE
{
- Copy( &lsp_fx[st->numlpc * M], st->lsp_old_fx, M );
- Copy( &lsf_fx[st->numlpc * M], st->lsf_old_fx, M );
+ Copy( &lsp_fx[i_mult( st->numlpc, M )], st->lsp_old_fx, M );
+ Copy( &lsf_fx[i_mult( st->numlpc, M )], st->lsf_old_fx, M );
}
Copy( st->lsp_q_cng, st->old_lsp_q_cng, M );
Copy( st->lsf_q_cng, st->old_lsf_q_cng, M );
@@ -821,7 +841,7 @@ void stereo_tcx_core_dec_fx(
/* update CNG parameters in active frames */
test();
test();
- IF( EQ_16( st->bwidth, NB ) && hTcxDec->enableTcxLpc && NE_16( st->core, ACELP_CORE ) )
+ IF( EQ_16( st->bwidth, NB ) && hTcxDec->enableTcxLpc && st->core != ACELP_CORE )
{
Word16 buf[L_LP], res[L_FRAME], A[M + 1], r_h[M + 1], r_l[M + 1], tmp, lsptmp[M], q_r;
assert( EQ_16( st->L_frame, L_FRAME ) );
@@ -846,15 +866,17 @@ void stereo_tcx_core_dec_fx(
cng_params_upd_ivas_fx( &lsp_fx[M], st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth );
}
/* Set 16k LSP flag for CNG buffer */
+ // st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = ( st->L_frame == L_FRAME ? 0 : 1 );
IF( EQ_16( st->L_frame, L_FRAME ) )
{
st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0;
+ move16();
}
ELSE
{
st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1;
+ move16();
}
- move16();
}
st->last_is_cng = 0;
@@ -913,8 +935,8 @@ void stereo_tcx_core_dec_fx(
/* updates */
st->last_voice_factor_fx = 0;
- st->last_coder_type = st->coder_type;
move16();
+ st->last_coder_type = st->coder_type;
move16();
/* -------------------------------------------------------------- *
@@ -952,7 +974,6 @@ void stereo_tcx_core_dec_fx(
/* Generate additional comfort noise to mask potential coding artefacts */
test();
- test();
IF( EQ_16( st->m_frame_type, ACTIVE_FRAME ) && st->flag_cna && !st->cna_dirac_flag )
{
test();
@@ -1808,12 +1829,12 @@ static void dec_prm_tcx_ivas_fx(
move16();
}
start_bit_pos = st->next_bit_pos;
+ move16();
/* Init LTP data */
st->hTcxDec->tcx_hm_LtpPitchLag = -1;
- st->hTcxLtpDec->tcxltp_gain = 0;
- move16();
move16();
+ st->hTcxLtpDec->tcxltp_gain = 0;
move16();
/*--------------------------------------------------------------------------------*
@@ -1829,8 +1850,9 @@ static void dec_prm_tcx_ivas_fx(
{
st->last_core_from_bs = get_next_indice_fx( st, 1 ); /* Store decoder memory of last_core */
move16();
+
test();
- IF( EQ_16( st->last_core, ACELP_CORE ) && NE_16( st->last_core_from_bs, ACELP_CORE ) )
+ IF( st->last_core == ACELP_CORE && st->last_core_from_bs != ACELP_CORE )
{
/* A mismatch between the memory and the last_core
from the bitstream indicates a frame was lost. If prev_bfi is
@@ -1845,7 +1867,7 @@ static void dec_prm_tcx_ivas_fx(
test();
test();
test();
- IF( NE_16( st->last_core, st->last_core_from_bs ) && ( NE_16( st->last_core_from_bs, TCX_20_CORE ) && NE_16( st->last_core_from_bs, TCX_10_CORE ) && !( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core_from_bs, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) )
+ IF( NE_16( st->last_core, st->last_core_from_bs ) && ( NE_16( st->last_core_from_bs, TCX_20_CORE ) && NE_16( st->last_core_from_bs, TCX_10_CORE ) && !( EQ_16( st->prev_bfi, 1 ) && st->last_core_from_bs == ACELP_CORE && EQ_16( st->last_con_tcx, 1 ) ) ) )
{
Word16 Q_old_Aq_12_8 = Q12;
move16();
diff --git a/lib_dec/ivas_td_low_rate_dec.c b/lib_dec/ivas_td_low_rate_dec.c
index 4731bf883ae645f25f18d3a2e1cf099a75ebb67e..e1eaca3d3256429b99fcf3f9ac68f86add0fb6c2 100644
--- a/lib_dec/ivas_td_low_rate_dec.c
+++ b/lib_dec/ivas_td_low_rate_dec.c
@@ -38,8 +38,7 @@
#include "ivas_rom_com.h"
#include "ivas_cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
#include "wmc_auto.h"
#ifndef IVAS_FLOAT_FIXED
@@ -249,10 +248,10 @@ void tdm_low_rate_dec_fx(
move16();
st->GSC_IVAS_mode = 0;
- st->GSC_noisy_speech = 1;
- hGSCDec->noise_lev = 14;
move16();
+ st->GSC_noisy_speech = 1;
move16();
+ hGSCDec->noise_lev = 14;
move16();
pit_band_idx = 10 + BAND1k2;
@@ -266,18 +265,22 @@ void tdm_low_rate_dec_fx(
// set_f(exc, 0, L_FRAME);
// set_f(dct_epit, 0, L_FRAME);
// set_f(pitch_buf, L_SUBFR, NB_SUBFR);
- set_s( exc, 0, L_FRAME );
- set_s( dct_epit, 0, L_FRAME );
- set_s( pitch_buf, shl( L_SUBFR, Q6 ), NB_SUBFR );
+ set16_fx( exc, 0, L_FRAME );
+ set16_fx( dct_epit, 0, L_FRAME );
+ set16_fx( pitch_buf, shl( L_SUBFR, Q6 ), NB_SUBFR );
st->bpf_off = 1;
move16();
st->bfi_pitch_fx = mean_fx( pitch_buf, 4 );
move16();
st->bfi_pitch_frame = L_FRAME;
+ move16();
Diff_len = L_FRAME / 2;
+ move16();
st->bpf_off = 0;
+ move16();
attack_flag = 0;
+ move16();
move16();
move16();
@@ -289,6 +292,7 @@ void tdm_low_rate_dec_fx(
/* find the current total number of bits used */
tmp_nb_bits_tot = st->next_bit_pos;
+ move16();
move16();
if ( EQ_16( st->element_mode, IVAS_CPE_TD ) )
@@ -333,7 +337,7 @@ void tdm_low_rate_dec_fx(
*--------------------------------------------------------------------------------------*/
// set_f(voice_factors, 0.0f, NB_SUBFR16k);
- set_s( voice_factors, 0, NB_SUBFR16k );
+ set16_fx( voice_factors, 0, NB_SUBFR16k );
IF( st->hBWE_TD != NULL )
{
@@ -345,7 +349,7 @@ void tdm_low_rate_dec_fx(
ELSE
{
// set_f(bwe_exc, 0, L_FRAME32k);
- set_s( bwe_exc, 0, L_FRAME32k );
+ set16_fx( bwe_exc, 0, L_FRAME32k );
}
}
@@ -362,7 +366,7 @@ void tdm_low_rate_dec_fx(
* Channel aware mode parameters
*--------------------------------------------------------------------------------------*/
- set_s( st->tilt_code_dec_fx, 0, NB_SUBFR16k );
+ set16_fx( st->tilt_code_dec_fx, 0, NB_SUBFR16k );
return;
}
@@ -536,13 +540,13 @@ void decod_gen_2sbfr_ivas_fx(
// float code[2 * L_SUBFR]; /* algebraic codevector */
// const float *p_Aq; /* Pointer to frame LP coefficient */
// float *pt_pitch; /* pointer to floating pitch */
- Word16 gain_pit = 0; /* pitch gain */
- Word32 gain_code = 0; /* gain/normalized gain of the algebraic excitation */
- Word32 norm_gain_code = 0; /* normalized gain of the algebraic excitation */
- Word16 gain_inov = 0; /* Innovation gain */
+ Word16 gain_pit = 0; /* pitch gain */
move16();
+ Word32 gain_code = 0; /* gain/normalized gain of the algebraic excitation */
move32();
+ Word32 norm_gain_code = 0; /* normalized gain of the algebraic excitation */
move32();
+ Word16 gain_inov = 0; /* Innovation gain */
move16();
// Word16 gains_mem[2 * (NB_SUBFR - 1)]; /* pitch gain and code gain from previous subframes */
Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
@@ -565,8 +569,11 @@ void decod_gen_2sbfr_ivas_fx(
move16();
T0 = PIT_MIN;
+ move16();
T0_frac = 0;
+ move16();
error = 0;
+ move16();
move16();
move16();
@@ -631,8 +638,8 @@ void decod_gen_2sbfr_ivas_fx(
/* update LP filtered gains for the case of frame erasures */
// lp_gain_updt(i_subfr, gain_pit, norm_gain_code, &st->lp_gainp, &st->lp_gainc, L_frame);
// lp_gain_updt(i_subfr + L_SUBFR, gain_pit, norm_gain_code, &st->lp_gainp, &st->lp_gainc, L_frame);
- lp_gain_updt_fx( i_subfr, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame );
- lp_gain_updt_fx( i_subfr + L_SUBFR, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame );
+ lp_gain_updt_ivas_fx( i_subfr, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame );
+ lp_gain_updt_ivas_fx( i_subfr + L_SUBFR, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame );
/*----------------------------------------------------------------------*
* Find the total excitation
@@ -695,15 +702,16 @@ void decod_gen_2sbfr_ivas_fx(
pt_pitch++;
*pt_pitch = *( pt_pitch - 1 );
+ move16();
pt_pitch++;
gain_buf[i_subfr / L_SUBFR /*i_subfr / L_SUBFR*/] = gain_pit;
- gain_buf[shr( add( i_subfr, L_SUBFR ), 6 ) /*(i_subfr+L_SUBFR) / L_SUBFR*/] = gain_pit;
- st->tilt_code_dec_fx[i_subfr / L_SUBFR /*i_subfr / L_SUBFR*/] = st->tilt_code_fx;
- st->tilt_code_dec_fx[shr( add( i_subfr, L_SUBFR ), 6 ) /*( i_subfr + L_SUBFR ) / L_SUBFR*/] = st->tilt_code_fx;
move16();
+ gain_buf[shr( add( i_subfr, L_SUBFR ), 6 ) /*(i_subfr+L_SUBFR) / L_SUBFR*/] = gain_pit;
move16();
+ st->tilt_code_dec_fx[i_subfr / L_SUBFR /*i_subfr / L_SUBFR*/] = st->tilt_code_fx;
move16();
+ st->tilt_code_dec_fx[shr( add( i_subfr, L_SUBFR ), 6 ) /*( i_subfr + L_SUBFR ) / L_SUBFR*/] = st->tilt_code_fx;
move16();
// st->tilt_code_dec[i_subfr / L_SUBFR] = st->tilt_code;
// st->tilt_code_dec[( i_subfr + L_SUBFR ) / L_SUBFR] = st->tilt_code;
diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c
index fb4a65206504804ad4784f31c266218c37648f0f..3ba8a4331423dc812037643a8719e3ef9af3491c 100644
--- a/lib_dec/jbm_jb4sb.c
+++ b/lib_dec/jbm_jb4sb.c
@@ -49,7 +49,7 @@
#include "jbm_jb4_jmf.h"
#include "jbm_jb4sb.h"
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#define WMC_TOOL_SKIP
#define INV_500_Q31 4294967 /*1/500 IN Q_31*/
@@ -1432,7 +1432,7 @@ static void JB4_popFromBuffer(
test();
IF( !tempDataUnit->partial_frame && !h->lastPoppedWasSilence )
{
- frameoffset = Mult_32_32( JB4_rtpTimeStampDiff( h->nextExpectedTs, tempDataUnit->timeStamp ), INV_20_Q31 );
+ frameoffset = extract_l( Mult_32_32( JB4_rtpTimeStampDiff( h->nextExpectedTs, tempDataUnit->timeStamp ), INV_20_Q31 ) );
test();
IF( frameoffset > 0 && LT_16( frameoffset, MAXOFFSET ) )
{
@@ -1490,7 +1490,7 @@ static void JB4_popFromBuffer(
partialCopyDu = (JB4_DATAUNIT_HANDLE) JB4_INPUTBUFFER_Element( h->inputBuffer, searchpos );
IF( EQ_64( partialCopyDu->timeStamp, W_add( nextDataUnit->timeStamp, partialCopyDu->duration ) ) )
{
- get_NextCoderType( partialCopyDu->data, &nextDataUnit->nextCoderType );
+ get_NextCoderType_fx( partialCopyDu->data, &nextDataUnit->nextCoderType );
BREAK;
}
}
@@ -1509,7 +1509,7 @@ static void JB4_popFromBuffer(
test();
IF( !tempDataUnit->partial_frame && !h->lastPoppedWasSilence )
{
- frameoffset = Mult_32_32( JB4_rtpTimeStampDiff( h->nextExpectedTs, tempDataUnit->timeStamp ), INV_20_Q31 );
+ frameoffset = extract_l( Mult_32_32( JB4_rtpTimeStampDiff( h->nextExpectedTs, tempDataUnit->timeStamp ), INV_20_Q31 ) );
test();
IF( ( frameoffset > 0 ) && LT_16( frameoffset, MAXOFFSET ) )
{
diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c
index 72e57c5b5bb1094b96a7275a7c3609870826063d..9e11f8085aa8b436e9e9da6a671a3e72dd197e26 100644
--- a/lib_dec/jbm_pcmdsp_apa.c
+++ b/lib_dec/jbm_pcmdsp_apa.c
@@ -54,7 +54,7 @@
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#define INV_100_Q15 328
#define INV_400_Q15 82
#define INV_80_Q15 410
diff --git a/lib_dec/lead_deindexing_fx.c b/lib_dec/lead_deindexing_fx.c
index 2e9ea383f9e968291a44d88b8e2e04c663d1aded..80508277f5bf2e0d84c14e7856d75dfa056cdd85 100644
--- a/lib_dec/lead_deindexing_fx.c
+++ b/lib_dec/lead_deindexing_fx.c
@@ -7,8 +7,7 @@
#include "cnst.h"
#include "rom_com.h"
#include "rom_dec.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
* Local function prototype
diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c
index 2b66b10845fe6656680aae962027b4444a0b7d2a..44e0c0770c93204b79fbb9041e1cb69385f3cdcf 100644
--- a/lib_dec/lib_dec.c
+++ b/lib_dec/lib_dec.c
@@ -36,8 +36,7 @@
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "jbm_jb4sb.h"
#include "jbm_pcmdsp_apa.h"
#include "jbm_pcmdsp_fifo.h"
diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c
index 900aa4d5413fdb8c1594eb79a795485eae8d0d3f..18a062f60dd69f4cb6f56a2ad057a2302c2c795f 100644
--- a/lib_dec/lib_dec_fx.c
+++ b/lib_dec/lib_dec_fx.c
@@ -36,8 +36,7 @@
#include "ivas_prot_rend.h"
#include "prot.h"
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "jbm_jb4sb.h"
#include "jbm_pcmdsp_apa.h"
#include "jbm_pcmdsp_fifo.h"
@@ -2871,7 +2870,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame(
}
/* check if frame contains a partial copy and get its offset */
- evs_dec_previewFrame_float( au, auSize, &partialCopyFrameType, &partialCopyOffset );
+ evs_dec_previewFrame( au, auSize, &partialCopyFrameType, &partialCopyOffset );
/* create data unit for primary copy in the frame */
dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM );
diff --git a/lib_dec/lp_exc_d_fx.c b/lib_dec/lp_exc_d_fx.c
index 40318b376206ce1c9ff0a02eee4e89cb701247fa..76d4b4676e0577a8424a7f8232076b5a02c41a89 100644
--- a/lib_dec/lp_exc_d_fx.c
+++ b/lib_dec/lp_exc_d_fx.c
@@ -3,10 +3,9 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
/*======================================================================*/
/* FUNCTION : lp_filt_exc_dec_fx() */
diff --git a/lib_dec/lsf_dec.c b/lib_dec/lsf_dec.c
index 2fb00b693aa48b4b70326384d4a4736bb07a91db..0628ccd33da84a4ccb9aa00ee1fffd99ba07e3a1 100644
--- a/lib_dec/lsf_dec.c
+++ b/lib_dec/lsf_dec.c
@@ -39,7 +39,7 @@
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_proto_func.h"
#include "ivas_prot.h"
#include "ivas_rom_com.h"
diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c
index 39466c34bd2aeab8cc71d26bfeb7ded58416afc6..5db4869995bff9c3f434939cd3c46f4e6ba42435 100644
--- a/lib_dec/lsf_dec_fx.c
+++ b/lib_dec/lsf_dec_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE
#include "ivas_prot.h"
//#include "ivas_rom_com.h"
@@ -46,7 +45,7 @@ static void dqlsf_CNG_fx(
move16();
/* deindex_lvq_cng decoder does not need to know the sampling rate, the sampling rate data is embedded inside the LSF coefficients */
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
ber_flag =
deindex_lvq_cng_fx( &indice[1], lsf_q, indice[0], LSF_BITS_CNG - 4, &st_fx->offset_scale1_fx[0][0], &st_fx->offset_scale2_fx[0][0], &st_fx->no_scales_fx[0][0] );
@@ -57,6 +56,7 @@ static void dqlsf_CNG_fx(
deindex_lvq_cng_ivas_fx( &indice[1], lsf_q, indice[0], LSF_BITS_CNG - 4 );
}
st_fx->BER_detect = s_or( ber_flag, st_fx->BER_detect );
+ move16();
/* The sampling frequency of the LP-CNG frame can be determined by checking the value of the highest order LSF coefficient (last coefficient).
If the last decoded LSF coefficient is larger than 6350 the decoded frame is WB2 with sampling rate of 16 kHz
@@ -122,8 +122,11 @@ void lsf_dec_fx(
Word16 param_lpc[NPRM_LPC_NEW];
Word32 L_tmp;
Word16 nBits = 0;
+ move16();
Word16 tmp_old[M + 1], tmp_new[M + 1];
Word16 enr_old = 0, enr_new = 0;
+ move16();
+ move16();
Word16 lsf_diff, coder_type;
/* initialize */
@@ -134,7 +137,7 @@ void lsf_dec_fx(
move16();
}
test();
- if ( EQ_16( coder_type, AUDIO ) && GT_16( st_fx->GSC_IVAS_mode, 0 ) )
+ if ( EQ_16( coder_type, AUDIO ) && st_fx->GSC_IVAS_mode > 0 )
{
coder_type = GENERIC;
move16();
@@ -164,7 +167,7 @@ void lsf_dec_fx(
{
nBits = 30;
move16();
- if ( EQ_16( st_fx->bwidth, NB ) )
+ if ( st_fx->bwidth == NB )
{
nBits = 32;
move16();
@@ -195,10 +198,11 @@ void lsf_dec_fx(
{
st_fx->seed_acelp = 0;
move16();
- FOR( i = no_param_lpc - 1; i >= 0; i-- )
+ FOR( i = sub( no_param_lpc, 1 ); i >= 0; i-- )
{
/* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/
- st_fx->seed_acelp = (int16_t) ( ( ( ( st_fx->seed_acelp ) >> 1 ) + param_lpc[i] ) * 31821L + 13849L );
+ st_fx->seed_acelp = extract_l( L_add( imult3216( 31821L, add( shr( ( st_fx->seed_acelp ), 1 ), param_lpc[i] ) ), 13849L ) );
+ move16();
// PMTE() /*IVAS_CODE to be completed */
}
}
@@ -218,6 +222,7 @@ void lsf_dec_fx(
L_tmp = L_mac( L_tmp, st_fx->lsfoldbfi1_fx[i], 10922 ); /*Q(x2.56+16)*/
L_tmp = L_mac( L_tmp, st_fx->lsfoldbfi0_fx[i], 10922 ); /*Q(x2.56+16)*/
st_fx->lsf_adaptive_mean_fx[i] = round_fx( L_tmp ); /*Q(x2.56)*/
+ move16();
}
test();
@@ -245,7 +250,7 @@ void lsf_dec_fx(
* Mid-frame LSF decoding
* LSP interpolation and conversion of LSPs to A(z)
*-------------------------------------------------------------------------------------*/
- if ( st_fx->rate_switching_reset )
+ IF( st_fx->rate_switching_reset )
{
/*extrapolation in case of unstable LSF convert*/
Copy( lsp_new, st_fx->lsp_old_fx, M );
@@ -277,7 +282,7 @@ void lsf_dec_fx(
test();
test();
test();
- if ( EQ_16( st_fx->clas_dec, UNVOICED_CLAS ) || EQ_16( st_fx->clas_dec, SIN_ONSET ) || EQ_16( st_fx->clas_dec, INACTIVE_CLAS ) || EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) )
+ if ( st_fx->clas_dec == UNVOICED_CLAS || EQ_16( st_fx->clas_dec, SIN_ONSET ) || st_fx->clas_dec == INACTIVE_CLAS || EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) )
{
st_fx->relax_prev_lsf_interp = 1;
move16();
@@ -286,12 +291,13 @@ void lsf_dec_fx(
}
}
test();
- IF( EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->core, ACELP_CORE ) )
+ IF( EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->core == ACELP_CORE )
{
/* update old LSPs/LSFs in case of HQ->ACELP core switching */
Copy( lsp_mid, st_fx->lsp_old_fx, M );
lsp2lsf_fx( lsp_mid, st_fx->lsf_old_fx, M, st_fx->sr_core );
}
+ test();
IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( coder_type, UNVOICED ) )
{
// PMT("To be verified")
@@ -314,13 +320,15 @@ void lsf_dec_fx(
* Check LSF stability (distance between old LSFs and current LSFs)
*------------------------------------------------------------------*/
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); /*Q15*/
+ move16();
}
- else
+ ELSE
{
st_fx->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame );
+ move16();
}
return;
@@ -413,6 +421,7 @@ void lsf_end_dec_fx(
test();
test();
#ifdef LSF_RE_USE_SECONDARY_CHANNEL
+ test();
IF( ( EQ_16( coder_type_org, GENERIC ) ) && ( EQ_32( st->sr_core, INT_FS_16k ) ) && ( mode2_flag == 0 ) && ( st->idchan == 0 ) )
#else
IF( ( EQ_16( coder_type_org, GENERIC ) ) && ( EQ_32( st->sr_core, INT_FS_16k ) ) && ( mode2_flag == 0 ) )
@@ -461,6 +470,8 @@ void lsf_end_dec_fx(
* Select safety_net or predictive mode
*--------------------------------------------------------------------------*/
#if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE
+ test();
+ test();
IF( st->tdm_LRTD_flag == 0 && EQ_16( st->idchan, 1 ) && tdm_lsfQ_PCh != NULL )
{
/* if secondary channel predmode is set to be > 2 */
@@ -484,6 +495,8 @@ void lsf_end_dec_fx(
}
ELSE
{
+ test();
+ test();
IF( EQ_16( mode2_flag, 1 ) || EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) )
{
/* read from param_lpc */
@@ -505,11 +518,12 @@ void lsf_end_dec_fx(
* Read indices from array
*--------------------------------------------------------------------------*/
#if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE
+ test();
/* Make sure there are the correct bit allocations */
IF( EQ_16( st->idchan, 1 ) && GT_16( predmode, 2 ) )
{
/* use same AR prediction bit allocation for intra and inter modes*/
- lsf_allocate_fx( nBits - 1, mode_lvq, 9, &stages0, &stages1, levels0, levels1, bits0, bits1 );
+ lsf_allocate_fx( sub( nBits, 1 ), mode_lvq, 9, &stages0, &stages1, levels0, levels1, bits0, bits1 );
stages0 = stages1;
Copy( levels1, levels0, stages0 );
Copy( bits1, bits0, stages0 );
@@ -527,8 +541,8 @@ void lsf_end_dec_fx(
{
*nb_indices = 10;
move16();
- move16();
TCQIdx[0] = safety_net;
+ move16();
FOR( i = 1; i < *nb_indices; i++ )
{
TCQIdx[i] = *p_lpc_param++;
@@ -571,7 +585,7 @@ void lsf_end_dec_fx(
test();
IF( EQ_16( mode2_flag, 1 ) || EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) )
{
- FOR( i = 0; i < stages - 1; i++ )
+ FOR( i = 0; i < sub( stages, 1 ); i++ )
{
num_bits = bits[i];
move16();
@@ -607,6 +621,7 @@ void lsf_end_dec_fx(
num_bits = bits[i];
move16();
lindice[i + 1] = (Word16) get_next_indice( st, num_bits );
+ move16();
}
cumleft = levels[sub( stages, 1 )];
@@ -627,6 +642,7 @@ void lsf_end_dec_fx(
}
lindice[i + 1] = (Word16) get_next_indice( st, num_bits );
+ move16();
i = add( i, 1 );
}
}
@@ -639,6 +655,7 @@ void lsf_end_dec_fx(
move16();
}
st->reset_mem_AR = 0;
+ move16();
}
/*------------------------------------------------------------------------------------------*
@@ -653,7 +670,7 @@ void lsf_end_dec_fx(
IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, VOICED ) && flag_1bit_gran == 0 )
{
/* BC-TCVQ decoder */
- safety_net = qlsf_ARSN_tcvq_Dec_16k_fx( qlsf, TCQIdx, nBits - 1 );
+ safety_net = qlsf_ARSN_tcvq_Dec_16k_fx( qlsf, TCQIdx, sub( nBits, 1 ) );
/* Update mem_MA */
Copy( qlsf, st->mem_MA_fx, M );
@@ -667,6 +684,7 @@ void lsf_end_dec_fx(
FOR( i = 0; i < M; i++ )
{
pred0[i] = add( ModeMeans_fx[mode_lvq][i], mult( Predictors_fx[mode_lvq_p][i], ( sub( st->mem_AR_fx[i], ModeMeans_fx[mode_lvq][i] ) ) ) ); /* Q(x2.56)*/
+ move16();
}
*LSF_Q_prediction = AUTO_REGRESSIVE;
move16();
@@ -682,10 +700,11 @@ void lsf_end_dec_fx(
FOR( i = 0; i < M; i++ )
{
pred1[i] = add( pred0[i], mult_r( MU_MA_FX, st->mem_MA_fx[i] ) );
+ move16();
}
#if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE
/* TD stereo SCh: perform intra-frame prediction with pulling-to-mean */
- if ( st->tdm_LRTD_flag == 0 && EQ_16( st->idchan, 1 ) && tdm_lsfQ_PCh != NULL )
+ IF( st->tdm_LRTD_flag == 0 && EQ_16( st->idchan, 1 ) && tdm_lsfQ_PCh != NULL )
{
tdm_SCh_LSF_intra_pred_fx( st->element_brate, tdm_lsfQ_PCh, pred3 );
}
@@ -694,30 +713,34 @@ void lsf_end_dec_fx(
{
/* LVQ */
#if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE
- if ( st->tdm_LRTD_flag == 0 && EQ_16( st->idchan, 1 ) && tdm_lsfQ_PCh != NULL )
+ test();
+ test();
+ IF( st->tdm_LRTD_flag == 0 && EQ_16( st->idchan, 1 ) && tdm_lsfQ_PCh != NULL )
{
/* intra mode*/
- st->BER_detect = st->BER_detect |
- vq_dec_lvq_ivas_fx( 0, qlsf, &lindice[1], stages0, M, 9, levels0[stages0 - 1] );
+ st->BER_detect = s_or( st->BER_detect,
+ vq_dec_lvq_ivas_fx( 0, qlsf, &lindice[1], stages0, M, 9, levels0[stages0 - 1] ) );
+ move16();
Vr_add( qlsf, pred3, qlsf, M );
Vr_subt( qlsf, pred1, st->mem_MA_fx, M );
}
- else
+ ELSE
#endif
{
- if ( st->element_mode != EVS_MONO )
+ IF( st->element_mode != EVS_MONO )
{
ber_flag = vq_dec_lvq_ivas_fx( 1, qlsf, &lindice[1], stages0, M, mode_lvq, levels0[stages0 - 1] );
}
- else
+ ELSE
{
ber_flag = vq_dec_lvq_fx( 1, qlsf, &lindice[1], stages0, M, mode_lvq, levels0[stages0 - 1],
&st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0],
&st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] );
}
st->BER_detect = s_or( st->BER_detect, ber_flag );
+ move16();
Vr_add( qlsf, pred0, qlsf, M );
Vr_subt( qlsf, pred1, st->mem_MA_fx, M );
}
@@ -733,17 +756,18 @@ void lsf_end_dec_fx(
move16();
}
#endif
- if ( st->element_mode != EVS_MONO )
+ IF( st->element_mode != EVS_MONO )
{
ber_flag = vq_dec_lvq_ivas_fx( 0, qlsf, &lindice[1], stages1, M, mode_lvq_p, levels1[stages1 - 1] );
}
- else
+ ELSE
{
ber_flag = vq_dec_lvq_fx( 0, qlsf, &lindice[1], stages1, M, mode_lvq_p, levels1[stages1 - 1],
&st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0],
&st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] );
}
st->BER_detect = s_or( st->BER_detect, ber_flag );
+ move16();
#if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE
test();
IF( EQ_16( predmode, 1 ) || EQ_16( predmode, 4 ) ) /* MA only */
@@ -762,6 +786,7 @@ void lsf_end_dec_fx(
FOR( i = 0; i < M; i++ )
{
pred2[i] = add( pred0[i], mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ) );
+ move16();
}
Vr_add( qlsf, pred2, qlsf, M );
Vr_subt( qlsf, pred1, st->mem_MA_fx, M );
@@ -910,9 +935,10 @@ void lsf_mid_dec_fx(
/* Calculation of mid-LSF vector */
FOR( j = 0; j < M; j++ )
{
- L_tmp = L_mult( sub( 0x2000, ratio[idx * M + j] ), qlsf0[j] ); /*Q(x2.56+13+1)->Q(x2.56+14)*/
- L_tmp = L_mac( L_tmp, ratio[idx * M + j], qlsf1[j] ); /*Q(x2.56+14)*/
- qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); /*Q(x2.56)*/
+ L_tmp = L_mult( sub( 0x2000, ratio[add( i_mult( idx, M ), j )] ), qlsf0[j] ); /*Q(x2.56+13+1)->Q(x2.56+14)*/
+ L_tmp = L_mac( L_tmp, ratio[add( i_mult( idx, M ), j )], qlsf1[j] ); /*Q(x2.56+14)*/
+ qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); /*Q(x2.56)*/
+ move16();
}
/* check for incorrect LSF ordering */
diff --git a/lib_dec/lsf_msvq_ma_dec_fx.c b/lib_dec/lsf_msvq_ma_dec_fx.c
index 13e41a8d2890746007fb71c1c05e5e254f1625fd..3fc69d5884f1afe86b4e685e25e226274d678606 100644
--- a/lib_dec/lsf_msvq_ma_dec_fx.c
+++ b/lib_dec/lsf_msvq_ma_dec_fx.c
@@ -6,8 +6,7 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "rom_com.h"
@@ -42,19 +41,16 @@ Word16 lsf_msvq_ma_decprm( Decoder_State *st, Word16 *param_lpc )
{
find_pred_mode( &predmode, GENERIC, sub( 1, st->narrowBand ) /*st->bwidth*/, st->sr_core,
&mode_lvq, &mode_lvq_p, st->total_brate );
- move16();
}
ELSE
{
IF( EQ_16( st->core, TCX_20_CORE ) )
{
find_pred_mode( &predmode, AUDIO, sub( 1, st->narrowBand ) /*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate );
- move16();
}
ELSE
{
find_pred_mode( &predmode, st->coder_type, sub( 1, st->narrowBand ) /*st->bwidth*/, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate );
- move16();
}
}
lsf_allocate_fx( sub( ENDLSF_NBITS, shr( predmode, 1 ) ), mode_lvq, mode_lvq_p, &stages0, &stages1, levels0, levels1, bits0, bits1 );
@@ -100,15 +96,18 @@ Word16 lsf_msvq_ma_decprm( Decoder_State *st, Word16 *param_lpc )
FOR( i = 0; i < tmp; i++ )
{
*param_lpc = get_next_indice_fx( st, bits[i] );
+ move16();
param_lpc++;
nbits_lpc = add( nbits_lpc, bits[i] );
}
*param_lpc = get_next_indice_fx( st, LEN_INDICE );
+ move16();
param_lpc++;
nbits_lpc = add( nbits_lpc, LEN_INDICE );
- *param_lpc = get_next_indice_fx( st, bits[i] - LEN_INDICE );
+ *param_lpc = get_next_indice_fx( st, sub( bits[i], LEN_INDICE ) );
+ move16();
param_lpc++;
nbits_lpc = add( nbits_lpc, sub( bits[i], LEN_INDICE ) );
@@ -119,6 +118,7 @@ Word16 lsf_msvq_ma_decprm( Decoder_State *st, Word16 *param_lpc )
{
*param_lpc = get_next_indice_fx( st, bits_midlpc );
+ move16();
nbits_lpc = add( nbits_lpc, bits_midlpc );
}
@@ -135,14 +135,17 @@ Word16 lsf_bctcvq_decprm(
const Word16 *bits1;
num_par = 10;
+ move16();
bits1 = BC_TCVQ_BIT_ALLOC_40B;
nbits_lpc = 0;
+ move16();
FOR( i = 0; i < num_par; i++ )
{
*param_lpc = get_next_indice_fx( st, bits1[i] );
+ move16();
param_lpc++;
nbits_lpc = add( nbits_lpc, bits1[i] );
}
diff --git a/lib_dec/nelp_dec_fx.c b/lib_dec/nelp_dec_fx.c
index dfafc8d09e2a9ec5d067089ad82e213d9671a656..6943e0b82a35fbf7dad72d7a1972c2fbbe0b3fb6 100644
--- a/lib_dec/nelp_dec_fx.c
+++ b/lib_dec/nelp_dec_fx.c
@@ -3,9 +3,8 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h"
/*===================================================================*/
@@ -32,6 +31,7 @@ static void normalize_arr( Word16 *arr, Word16 *qf, Word16 size, Word16 hdr )
{
Word16 i;
Word16 max_s = 0;
+ move16();
FOR( i = 0; i < size; i++ )
{
@@ -46,7 +46,8 @@ static void normalize_arr( Word16 *arr, Word16 *qf, Word16 size, Word16 hdr )
move16();
}
- *qf = *qf - hdr;
+ *qf = sub( *qf, hdr );
+ move16();
FOR( i = 0; i < size; i++ )
{
@@ -88,10 +89,12 @@ static void normalize_arr( Word16 *arr, Word16 *qf, Word16 size, Word16 hdr )
void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word16 *Q_exc, Word16 bfi, const Word16 coder_type, Word16 *gain_buf )
{
Word16 i, fid = 0;
+ move16();
Word16 ptr[L_FRAME], filtRes[L_FRAME], gain_fac; /*ptr, filtRes - Q0, gain_fac - Q14 */
Word16 Gains[10]; /* Q0 */
Word32 Gain, E3, E2;
Word16 BP1_ORDER = 4;
+ move16();
Word16 ptr_tmp[L_FRAME]; /* Q0 */
Word16 iG1, iG2[2];
Word16 exp_E2, exp_E3, frac_E2, frac_E3;
@@ -101,20 +104,25 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1
Word32 max_exc_sqr;
Word16 n;
Word16 max_val = 0, norm_val = 0;
+ move16();
+ move16();
Word16 qGain = 0;
+ move16();
SC_VBR_DEC_HANDLE hSC_VBR;
hSC_VBR = st_fx->hSC_VBR;
+ test();
if ( EQ_16( st_fx->last_nelp_mode_dec, 1 ) && NE_16( st_fx->bwidth, st_fx->last_bwidth ) )
{
st_fx->last_nelp_mode_dec = 0;
+ move16();
}
test();
test();
test();
- IF( EQ_16( coder_type, UNVOICED ) && EQ_16( st_fx->bwidth, NB ) )
+ IF( EQ_16( coder_type, UNVOICED ) && st_fx->bwidth == NB )
{
IF( NE_16( st_fx->last_nelp_mode_dec, 1 ) )
{
@@ -130,7 +138,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1
move16();
IF( NE_16( st_fx->last_nelp_mode_dec, 1 ) )
{
- set16_fx( hSC_VBR->bp1_filt_mem_wb_dec_fx, 0, BP1_ORDER * 2 );
+ set16_fx( hSC_VBR->bp1_filt_mem_wb_dec_fx, 0, shl( BP1_ORDER, 1 ) );
}
}
@@ -147,8 +155,11 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1
IF( EQ_16( st_fx->rf_frame_type, RF_NELP ) && EQ_16( st_fx->use_partial_copy, 1 ) )
{
iG1 = st_fx->rf_indx_nelp_iG1;
+ move16();
iG2[0] = st_fx->rf_indx_nelp_iG2[0];
+ move16();
iG2[1] = st_fx->rf_indx_nelp_iG2[1];
+ move16();
}
ELSE
{
@@ -169,6 +180,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1
IF( EQ_16( st_fx->rf_frame_type, RF_NELP ) && EQ_16( st_fx->use_partial_copy, 1 ) )
{
fid = st_fx->rf_indx_nelp_fid;
+ move16();
}
ELSE
{
@@ -220,8 +232,8 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1
frac = round_fx( L_shl( Gain, n ) );
n = sub( add( n, 24 ), 30 );
frac = div_s( 16384, frac );
- Gain = Isqrt_lc( L_deposit_h( frac ), &n ); /*Q(31-n-exp) */
- tmp = round_fx( L_shl( Gain, sub( n + exp, 15 ) ) ); /*Q0 */
+ Gain = Isqrt_lc( L_deposit_h( frac ), &n ); /*Q(31-n-exp) */
+ tmp = round_fx( L_shl( Gain, sub( add( n, exp ), 15 ) ) ); /*Q0 */
}
ELSE
{
@@ -245,6 +257,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1
move16(); /* 1.16f - Q14 */
}
+ test();
IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) )
{
/* Normalize Gains[10] with headroom 4, qGain is the new Q value os Gains, not Q0*/
@@ -261,17 +274,17 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1
{
BP1_ORDER = 4;
move16();
- Scale_sig( hSC_VBR->bp1_filt_mem_wb_dec_fx, 2 * BP1_ORDER, qGain ); /* bring filter prev memory from Q0 to qGain */
+ Scale_sig( hSC_VBR->bp1_filt_mem_wb_dec_fx, shl( BP1_ORDER, 1 ), qGain ); /* bring filter prev memory from Q0 to qGain */
pz_filter_sp_fx( bp1_num_coef_wb_fx, bp1_den_coef_wb_fx, ptr, ptr_tmp, hSC_VBR->bp1_filt_mem_wb_dec_fx,
BP1_ORDER, BP1_ORDER, L_FRAME, ( sub( 16, BP1_COEF_WB_QF ) ) );
- Scale_sig( hSC_VBR->bp1_filt_mem_wb_dec_fx, 2 * BP1_ORDER, -qGain ); /* bring filter prev memory from qGain to Q0 */
- Scale_sig( ptr_tmp, L_FRAME, -qGain ); /* bring nelp_exc to Q0 */
+ Scale_sig( hSC_VBR->bp1_filt_mem_wb_dec_fx, shl( BP1_ORDER, 1 ), negate( qGain ) ); /* bring filter prev memory from qGain to Q0 */
+ Scale_sig( ptr_tmp, L_FRAME, -qGain ); /* bring nelp_exc to Q0 */
Copy( ptr_tmp, ptr, L_FRAME );
}
test();
- IF( EQ_16( coder_type, UNVOICED ) && ( EQ_16( st_fx->bwidth, NB ) ) )
+ IF( EQ_16( coder_type, UNVOICED ) && ( st_fx->bwidth == NB ) )
{
BP1_ORDER = 7;
move16();
@@ -296,6 +309,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1
Scale_sig32( hSC_VBR->bp1_filt_mem_nb_dec_fx, shl( BP1_ORDER, 1 ), norm_val );
Scale_sig( ptr, L_FRAME, norm_val );
*Q_exc = add( norm_val, *Q_exc );
+ move16();
}
BP1_ORDER = 7;
@@ -306,7 +320,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1
IF( norm_val > 0 )
{
- Scale_sig32( hSC_VBR->bp1_filt_mem_nb_dec_fx, shl( BP1_ORDER, 1 ), -norm_val );
+ Scale_sig32( hSC_VBR->bp1_filt_mem_nb_dec_fx, shl( BP1_ORDER, 1 ), negate( norm_val ) );
}
Copy( ptr_tmp, ptr, L_FRAME ); /*Q_exc */
@@ -387,7 +401,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1
#else
frac_E2 = round_fx( L_shl( E2, exp_E2 ) );
#endif
- exp_E2 = sub( 30, add( exp_E2, 2 * ( *Q_exc ) ) );
+ exp_E2 = sub( 30, add( exp_E2, shl( ( *Q_exc ), 1 ) ) );
scale = shr( sub( frac_E3, frac_E2 ), 15 );
frac_E2 = shl( frac_E2, scale );
@@ -402,6 +416,7 @@ void nelp_decoder_fx( Decoder_State *st_fx, Word16 *exc_nelp, Word16 *exc, Word1
{
L_tmp = Mult_32_16( L_tmp1, ptr[i] ); /*Q(16-exp+Q_exc) */
ptr[i] = round_fx( L_shl( L_tmp, exp ) ); /*Q_exc */
+ move16();
}
}
diff --git a/lib_dec/peak_vq_dec_fx.c b/lib_dec/peak_vq_dec_fx.c
index cb93bdd7c34099e1762509661ca7b91413b85be4..a23ff76b41accf67bbd4fed1e4cc0c9924a78f3c 100644
--- a/lib_dec/peak_vq_dec_fx.c
+++ b/lib_dec/peak_vq_dec_fx.c
@@ -4,8 +4,7 @@
#include
#include "options.h" /* Compilation switches */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "enh64.h"
@@ -43,6 +42,7 @@ void hvq_dec_fx(
Word16 noise_level_idx;
bits = num_bits;
+ move16();
FOR( i = 0; i < HVQ_BWE_NOISE_BANDS; i++ )
{
@@ -114,7 +114,7 @@ static void peak_vq_dec_fx(
assert( ( core_brate > HQ_16k40 && core_brate <= HQ_48k ) && "HVQ rate not supported" );
// PMT("max_peaks equation needs to be converted")
- max_peaks = (Word16) ( ( core_brate * HVQ_PEAKS_PER_DELTA + HVQ_PEAKS_PER_DELTA_OFFS ) / HVQ_PEAKS_BPS_DELTA );
+ max_peaks = extract_l( Mpy_32_32( ( L_add( imult3216( core_brate, HVQ_PEAKS_PER_DELTA ), HVQ_PEAKS_PER_DELTA_OFFS ) ), 282564 ) ); /* 1 / HVQ_PEAKS_BPS_DELTA in Q31 = 282564*/
/*max_peaks = ((core_brate * HVQ_PEAKS_PER_DELTA / HVQ_PEAKS_BPS_DELTA + HVQ_PEAKS_PER_DELTA_OFFS / HVQ_PEAKS_BPS_DELTA) );*/
#if 0
{
@@ -126,10 +126,13 @@ static void peak_vq_dec_fx(
}
#endif
bin_th = HVQ_THRES_BIN_24k;
+ move16();
bin_th2 = HVQ_THRES_BIN_24k / HVQ_NF_GROUPS;
+ move16();
IF( GE_32( core_brate, HQ_BWE_CROSSOVER_BRATE ) )
{
bin_th = HVQ_THRES_BIN_32k;
+ move16();
bin_th2 = HVQ_THRES_BIN_32k / HVQ_NF_GROUPS;
move16();
}
@@ -169,10 +172,12 @@ static void peak_vq_dec_fx(
test();
FOR( i = 0; i < bin_th && j < vq_peaks; i++ ) /* safety check in case of bit errors */
{
+ test();
IF( res_vec[i] != 0 )
{
- vq_peak_idx[j++] = i;
+ vq_peak_idx[j] = i;
move16();
+ j = add( j, 1 );
}
}
@@ -183,6 +188,7 @@ static void peak_vq_dec_fx(
move16();
vq_peaks = sub( j, 1 );
*Npeaks = sub( j, 1 );
+ move16();
}
/* Huffman or differential coding */
@@ -190,6 +196,7 @@ static void peak_vq_dec_fx(
/* De-quantize peak gains */
pgain_difidx[0] = get_next_indice( st_fx, GAIN0_BITS );
+ move16();
/* safety check in case of bit errors */
IF( GT_16( pgain_difidx[0], 44 ) )
@@ -211,7 +218,7 @@ static void peak_vq_dec_fx(
move16();
IF( FlagN )
{
- huff_dec_fx( st_fx, vq_peaks - 1, MAX_PG_HUFFLEN, NUM_PG_HUFFLEN, hvq_pg_huff_thres, hvq_pg_huff_offset, hvq_pg_huff_tab, &pgain_difidx[1] );
+ huff_dec_fx( st_fx, sub( vq_peaks, 1 ), MAX_PG_HUFFLEN, NUM_PG_HUFFLEN, hvq_pg_huff_thres, hvq_pg_huff_offset, hvq_pg_huff_tab, &pgain_difidx[1] );
FOR( i = 1; i < vq_peaks; i++ )
{
@@ -298,7 +305,7 @@ static void peak_vq_dec_fx(
/* safety check in case of bit errors */
test();
- if ( pvq_bands == 0 && EQ_16( st_fx->element_mode, EVS_MONO ) ) /* PVQ bands may be zero for IVAS */
+ if ( pvq_bands == 0 && st_fx->element_mode == EVS_MONO ) /* PVQ bands may be zero for IVAS */
{
st_fx->BER_detect = 1;
move16();
@@ -328,11 +335,10 @@ static void peak_vq_dec_fx(
pPvqVector = pvq_vector;
pCoefsOut = coefs_out;
pSelBnds = sel_bnds;
- move16();
FOR( k = 0; k < pvq_bands; k++ )
{
- pvq_norm[k] = get_next_indice( st_fx, HVQ_PVQ_GAIN_BITS );
- pvq_norm[k] = add( pvq_norm[k], 8 );
+ pvq_norm[k] = add( get_next_indice( st_fx, HVQ_PVQ_GAIN_BITS ), 8 );
+ // pvq_norm[k] = add( pvq_norm[k], 8 );
move16();
diff = add( diff, HVQ_PVQ_GAIN_BITS );
@@ -343,13 +349,12 @@ static void peak_vq_dec_fx(
{
i = band_start_harm[*pSelBnds++];
move16();
- move16();
pCoefsOut = coefs_out + i;
}
normq = L_add( dicn_fx[pvq_norm[k]], 0 );
WHILE( LT_16( j, hvq_band_width[k] ) )
{
- IF( EQ_32( *pCoefsOut, 0 ) )
+ IF( *pCoefsOut == 0 )
{
Mpy_32_16_ss( normq, *pPvqVector++, &acc, &dontCare ); /* acc(Q11), normq(Q14), pvq_vector(Q12) */
*pCoefsOut = L_shl( acc, 12 - 11 ); /* Q12 */
@@ -439,6 +444,7 @@ static void dequant_peaks_fx(
}
ELSE
{
+ test();
IF( vect_out[1] == 0 || ( LE_32( absPeakGain1, absPeakGain ) ) )
{
Mpy_32_16_ss( *peak_gain, xq[1], &vect_out[1], &dontCare );
@@ -446,6 +452,7 @@ static void dequant_peaks_fx(
}
}
vect_out[2] = *peak_gain; /* vect_out in Q12 */
+ move16();
Mpy_32_16_ss( *peak_gain, xq[2], &vect_out[3], &dontCare );
Mpy_32_16_ss( *peak_gain, xq[3], &vect_out[4], &dontCare );
@@ -491,6 +498,7 @@ static Word16 hvq_dec_pos_fx(
}
peak_idx[0] = sub( delta[0], HVQ_CP_HUFF_OFFSET );
+ move16();
/* safety check in case of bit errors */
IF( peak_idx[0] < 2 )
{
diff --git a/lib_dec/pit_dec.c b/lib_dec/pit_dec.c
index 25057151119bfeadd750ed0447628395d35db983..3574218f34da7d4f0ad4075ff7628bd5167c45e1 100644
--- a/lib_dec/pit_dec.c
+++ b/lib_dec/pit_dec.c
@@ -41,6 +41,7 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
+#ifndef IVAS_FLOAT_FIXED
/*----------------------------------------------------------*
* pit_decode_flt()
@@ -837,3 +838,4 @@ void Mode2_delta_pit_dec_flt(
return;
}
+#endif
diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c
index e4e6f48066cdbca4b010d0c67bc709578e8c71e9..f99c8ac16fba3786da924733a214432c14a7d29f 100644
--- a/lib_dec/pit_dec_fx.c
+++ b/lib_dec/pit_dec_fx.c
@@ -6,8 +6,7 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#define inv_T0_res InvIntTable
@@ -80,6 +79,7 @@ Word32 Mode2_pit_decode( /* o: floating pitch value
ELSE IF( EQ_16( coder_type, 3 ) ) /* 9/6/6/6 (HRs- VC) */
{
Word16 pit_res_max2 = pit_res_max;
+ move16();
if ( EQ_16( pit_min, PIT_MIN_16k ) )
{
pit_res_max2 = shr( pit_res_max, 1 );
@@ -100,6 +100,7 @@ Word32 Mode2_pit_decode( /* o: floating pitch value
ELSE IF( EQ_16( coder_type, 4 ) ) /* 9/6/9/6 (AMRWB) */
{
Word16 pit_res_max2 = pit_res_max;
+ move16();
if ( EQ_16( pit_min, PIT_MIN_16k ) )
{
pit_res_max2 = shr( pit_res_max, 1 );
@@ -127,6 +128,7 @@ Word32 Mode2_pit_decode( /* o: floating pitch value
{
limit_T0_voiced( 5, shr( pit_res_max, 1 ), *T0, *T0_frac, *T0_res, T0_min, T0_min_frac, T0_max, T0_max_frac, pit_min, pit_max );
*T0_res = shr( pit_res_max, 1 );
+ move16();
Mode2_delta_pit_dec( T0, T0_frac, *T0_res, T0_min, T0_min_frac, pt_indice );
}
}
@@ -140,6 +142,7 @@ Word32 Mode2_pit_decode( /* o: floating pitch value
{
limit_T0_voiced( 4, shr( pit_res_max, 1 ), *T0, *T0_frac, *T0_res, T0_min, T0_min_frac, T0_max, T0_max_frac, pit_min, pit_max );
*T0_res = shr( pit_res_max, 1 );
+ move16();
Mode2_delta_pit_dec( T0, T0_frac, *T0_res, T0_min, T0_min_frac, pt_indice );
}
}
@@ -183,6 +186,7 @@ void Mode2_abs_pit_dec(
index = **pt_indice;
move16();
( *pt_indice )++;
+ move16();
pit_res_max_half = shr( pit_res_max, 1 );
tmp1 = i_mult( sub( pit_fr2, pit_min ), pit_res_max );
@@ -199,9 +203,11 @@ void Mode2_abs_pit_dec(
}
*T0 = mult( index, inv_T0_res[res] );
+ move16();
if ( EQ_16( pit_res_max, 6 ) )
{
*T0 = shr( *T0, 1 );
+ move16();
}
*T0 = add( pit_min, *T0 );
@@ -266,18 +272,22 @@ void Mode2_delta_pit_dec(
index = **pt_indice;
move16();
( *pt_indice )++;
+ move16();
*T0 = mult( add( index, *T0_min_frac ), inv_T0_res[res] );
+ move16();
if ( EQ_16( T0_res, 6 ) )
{
*T0 = shr( *T0, 1 );
+ move16();
}
*T0 = add( *T0_min, *T0 );
move16();
*T0_frac = add( index, sub( *T0_min_frac, i_mult( sub( *T0, *T0_min ), T0_res ) ) );
+ move16();
return;
}
@@ -335,6 +345,7 @@ Word16 pit_decode_fx( /* o : floating pitch value
Word16 pitch_index, nBits, pit_flag;
pitch_index = 0;
+ move16();
/*----------------------------------------------------------------*
* Set pit_flag = 0 for every subframe with absolute pitch search
@@ -395,8 +406,7 @@ Word16 pit_decode_fx( /* o : floating pitch value
/* find the number of bits */
nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )];
move16();
- pitch_index = (Word16) get_next_indice( st_fx, nBits );
- move16();
+ pitch_index = (Word16) get_next_indice_fx( st_fx, nBits );
}
/*-------------------------------------------------------*
@@ -422,15 +432,13 @@ Word16 pit_decode_fx( /* o : floating pitch value
move16();
}
- pitch_index = (Word16) get_next_indice( st_fx, nBits );
- move16();
+ pitch_index = (Word16) get_next_indice_fx( st_fx, nBits );
test();
test();
IF( EQ_16( L_subfr, L_FRAME / 2 ) && i_subfr != 0 && GE_16( pitch_index, 32 ) ) /* safety check in case of bit errors */
{
pitch_index = shr( pitch_index, 1 );
- move16();
st_fx->BER_detect = 1;
move16();
}
@@ -551,7 +559,7 @@ Word16 pit_decode_fx( /* o : floating pitch value
}
}
- pitch_index = (Word16) get_next_indice( st_fx, nBits );
+ pitch_index = (Word16) get_next_indice_fx( st_fx, nBits );
pit_Q_dec_fx( 1, pitch_index, nBits, 8, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
}
@@ -617,6 +625,7 @@ Word16 pit_decode_ivas_fx( /* o : floating pitch value
Word16 pitch_index, nBits, pit_flag;
pitch_index = 0;
+ move16();
/*----------------------------------------------------------------*
* Set pit_flag = 0 for every subframe with absolute pitch search
@@ -675,16 +684,24 @@ Word16 pit_decode_ivas_fx( /* o : floating pitch value
IF( NE_16( coder_type, AUDIO ) )
{
/* find the number of bits */
- nBits = st_fx->acelp_cfg.pitch_bits[i_subfr / L_subfr];
- move16();
- pitch_index = (Word16) get_next_indice( st_fx, nBits );
+ IF( i_subfr )
+ {
+ nBits = st_fx->acelp_cfg.pitch_bits[idiv1616( i_subfr, L_subfr )];
+ }
+ ELSE
+ {
+ nBits = st_fx->acelp_cfg.pitch_bits[0];
+ }
move16();
+ pitch_index = (Word16) get_next_indice_fx( st_fx, nBits );
}
/*-------------------------------------------------------*
* Pitch decoding in AUDIO mode
* (both ACELP@12k8 and ACELP@16k cores)
*-------------------------------------------------------*/
+ test();
+ test();
IF( EQ_16( coder_type, AUDIO ) )
{
test();
@@ -704,15 +721,13 @@ Word16 pit_decode_ivas_fx( /* o : floating pitch value
move16();
}
- pitch_index = (Word16) get_next_indice( st_fx, nBits );
- move16();
+ pitch_index = (Word16) get_next_indice_fx( st_fx, nBits );
test();
test();
IF( EQ_16( L_subfr, L_FRAME / 2 ) && i_subfr != 0 && GE_16( pitch_index, 32 ) ) /* safety check in case of bit errors */
{
pitch_index = shr( pitch_index, 1 );
- move16();
st_fx->BER_detect = 1;
move16();
}
@@ -736,8 +751,6 @@ Word16 pit_decode_ivas_fx( /* o : floating pitch value
#if 1 // def ADD_LRTD
ELSE IF( EQ_16( st_fx->idchan, 1 ) && ( EQ_16( tdm_Pitch_reuse_flag, 1 ) || EQ_16( nBits, 4 ) ) )
{
- test();
- test();
/*-------------------------------------------------------*
* Pitch decoding with reusing of primary channel information
*-------------------------------------------------------*/
@@ -832,7 +845,7 @@ Word16 pit_decode_ivas_fx( /* o : floating pitch value
}
}
- pitch_index = (Word16) get_next_indice( st_fx, nBits );
+ pitch_index = (Word16) get_next_indice_fx( st_fx, nBits );
pit_Q_dec_fx( 1, pitch_index, nBits, 8, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
}
@@ -872,17 +885,23 @@ void pit_Q_dec_fx(
IF( limit_flag == 0 )
{
*T0 = add( PIT_MIN, shr( pitch_index, 2 ) );
+ move16();
*T0_frac = sub( pitch_index, shl( sub( *T0, PIT_MIN ), 2 ) );
+ move16();
}
ELSE IF( EQ_16( limit_flag, 1 ) )
{
*T0 = add( PIT_MIN_EXTEND, shr( pitch_index, 2 ) );
+ move16();
*T0_frac = sub( pitch_index, shl( sub( *T0, PIT_MIN_EXTEND ), 2 ) );
+ move16();
}
ELSE /* limit_flag == 2 */
{
*T0 = add( PIT_MIN_DOUBLEEXTEND, shr( pitch_index, 2 ) );
+ move16();
*T0_frac = sub( pitch_index, shl( sub( *T0, PIT_MIN_DOUBLEEXTEND ), 2 ) );
+ move16();
}
}
ELSE IF( EQ_16( nBits, 9 ) ) /* absolute decoding with 9 bits */
@@ -935,7 +954,7 @@ void pit_Q_dec_fx(
/* biterror detection mechanism */
test();
test();
- IF( GT_16( add( ( *T0 << 2 ), *T0_frac ), add( ( PIT_MAX << 2 ), 2 ) ) && pit_flag == 0 && !Opt_AMR_WB )
+ IF( GT_16( add( shl( *T0, 2 ), *T0_frac ), ( PIT_MAX << 2 ) + 2 ) && pit_flag == 0 && !Opt_AMR_WB )
{
*T0 = L_SUBFR;
move16();
@@ -988,9 +1007,11 @@ void pit16k_Q_dec_fx(
{
index = sub( pitch_index, shl( ( PIT16k_FR2_EXTEND_10b - PIT16k_MIN_EXTEND ), 2 ) );
*T0 = add( PIT16k_FR2_EXTEND_10b, shr( index, 1 ) );
+ move16();
*T0_frac = sub( index, shl( sub( *T0, PIT16k_FR2_EXTEND_10b ), 1 ) );
/*(*T0_frac) *= 2;*/
( *T0_frac ) = shl( *T0_frac, 1 );
+ move16();
}
}
}
@@ -1011,7 +1032,8 @@ void pit16k_Q_dec_fx(
move16();
*T0_frac = sub( index, shl( sub( *T0, PIT16k_FR2_EXTEND_9b ), 1 ) );
move16();
- ( *T0_frac ) *= shl( ( *T0_frac ), 1 );
+ ( *T0_frac ) = imult1616( ( *T0_frac ), shl( ( *T0_frac ), 1 ) );
+ move16();
}
ELSE
{
@@ -1029,7 +1051,7 @@ void pit16k_Q_dec_fx(
/* biterror detection mechanism */
test();
- IF( GT_16( add( ( *T0 << 2 ), *T0_frac ), ( PIT16k_MAX << 2 ) ) && GE_16( nBits, 9 ) )
+ IF( GT_16( add( shl( *T0, 2 ), *T0_frac ), ( PIT16k_MAX << 2 ) ) && GE_16( nBits, 9 ) )
{
*T0 = L_SUBFR;
move16();
@@ -1122,6 +1144,7 @@ void abs_pit_dec_fx(
*T0 = add( PIT_MIN_EXTEND, shr( pitch_index, 1 ) );
move16();
*T0_frac = sub( pitch_index, shl( sub( *T0, PIT_MIN_EXTEND ), 1 ) );
+ move16();
*T0_frac = shl( *T0_frac, 1 );
move16();
}
@@ -1149,7 +1172,9 @@ void abs_pit_dec_fx(
/*pitch_index -= (PIT_FR2_EXTEND_9b-PIT_MIN_EXTEND)*4;*/
pitch_index = sub( pitch_index, PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4 );
*T0 = add( PIT_FR2_EXTEND_9b, shr( pitch_index, 1 ) );
+ move16();
*T0_frac = sub( pitch_index, shl( sub( *T0, PIT_FR2_EXTEND_9b ), 1 ) );
+ move16();
( *T0_frac ) = shl( *T0_frac, 1 );
move16();
}
diff --git a/lib_dec/pitch_extr_fx.c b/lib_dec/pitch_extr_fx.c
index 78d0fc1f0fa1bc1fd1d7276ed1762884731ad880..9b42a9b576a2a44e7dc711d03f8f249bed584d4f 100644
--- a/lib_dec/pitch_extr_fx.c
+++ b/lib_dec/pitch_extr_fx.c
@@ -7,8 +7,7 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
@@ -61,6 +60,11 @@ void pitch_pred_linear_fit(
Word16 pg[8]; /* local buffer for pitch gain*/
Word32 ml[8]; /* local buffer for mem_lag*/
Word16 const timeWeight[5] = { 20480 /*1.25f Q14*/, 18432 /*1.125f Q14*/, 16384 /*1.f Q14*/, 14336 /*0.875f Q14*/, 12288 /*.75f Q14*/ }; /*Q14*/
+ move16();
+ move16();
+ move16();
+ move16();
+ move16(); /*timeweight*/
Word16 no_subfr_pred;
Word16 a1, a2, a3, a4, a5, tmpa, tmpb, b1, b2, b3, b4, b5;
Word16 a_e, b_e, sum0_q;
@@ -84,16 +88,13 @@ void pitch_pred_linear_fit(
move32();
}
}
- move16();
- move16();
- move16();
- move16();
- move16(); /*timeweight*/
IF( LT_16( pit_max, extract_h( *old_fpitch ) ) )
{
*extrapolationFailed = 1;
+ move16();
*T0_out = pit_max;
+ move16();
return;
}
@@ -114,8 +115,8 @@ void pitch_pred_linear_fit(
}
/* copy to local buffers, depending on availability of info about future subframes */
- Copy( mem_pitch_gain + no_subfr_pred - 2, pg, 8 );
- Copy32( mem_lag + no_subfr_pred - 2, ml, 8 );
+ Copy( mem_pitch_gain + sub( no_subfr_pred, 2 ), pg, 8 );
+ Copy32( mem_lag + sub( no_subfr_pred, 2 ), ml, 8 );
mdy = L_deposit_l( 0 );
@@ -164,6 +165,7 @@ void pitch_pred_linear_fit(
Word16 e1, e2, e3, e4, e5, e6, e7;
t1 = L_mult0( pg[4], pg[3] ); /*Q24*/ /* t1 = pg[4]*pg[3] */
e1 = 7;
+ move16();
t2 = L_add( L_deposit_l( pg[3] ), L_shl( L_deposit_l( pg[4] ), 2 ) ); /*Q12*/
e2 = norm_l( t2 );
t2 = L_shl( t2, e2 ); /*Q12,-e2*/
@@ -339,6 +341,7 @@ void get_subframe_pitch(
pitchDelta = L_deposit_l( BASOP_Util_Divide3216_Scale( L_sub( pitchEnd, pitchStart ), nSubframes, &s ) ); /*Q15*/
pitchDelta = L_shl( pitchDelta, add( s, 1 ) ); /*Q16*/
pitchBuf[0] = L_add( pitchStart, pitchDelta );
+ move32();
FOR( i = 1; i < nSubframes; i++ )
{
pitchBuf[i] = L_add( pitchBuf[i - 1], pitchDelta );
diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c
index 1071b23892a7324ff40524f6858408fa6fb7022e..071bc51886135681fde867ec44e9a3095d6a600e 100644
--- a/lib_dec/post_dec_fx.c
+++ b/lib_dec/post_dec_fx.c
@@ -5,8 +5,7 @@
#include
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#ifdef IVAS_FLOAT_FIXED
@@ -61,7 +60,7 @@ void post_decoder(
move16();
bitrate = L_add( st->total_brate, 0 );
- if ( st->core_brate <= SID_2k40 )
+ if ( LE_32( st->core_brate, SID_2k40 ) )
{
bitrate = L_add( st->last_active_brate, 0 );
}
@@ -89,7 +88,7 @@ void post_decoder(
ELSE
{
/*Formant enhancement*/
- IF( EQ_16( st->last_bwidth, NB ) )
+ IF( st->last_bwidth == NB )
{
Copy( synth, synth2_pe, L_frame );
tmp = synth[-1];
@@ -114,11 +113,12 @@ void post_decoder(
st->hPFstat->reset = 1;
move16();
}
- IF( EQ_16( st->bwidth, NB ) )
+ IF( st->bwidth == NB )
{
st->hPFstat->on = 1;
move16();
tmp_noise = 0;
+ move16();
nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, GENERIC, st->BER_detect, tmp );
}
ELSE
@@ -126,6 +126,7 @@ void post_decoder(
st->hPFstat->on = 0;
move16();
tmp_noise = 0;
+ move16();
nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, AUDIO, st->BER_detect, tmp );
}
Copy( synth2_pe, synth2, L_frame );
@@ -217,7 +218,7 @@ void post_decoder_ivas_fx(
}
bitrate = L_add( st->total_brate, 0 );
- IF( LE_32( st->core_brate, SID_2k40 ) )
+ if ( LE_32( st->core_brate, SID_2k40 ) )
{
bitrate = L_add( st->last_active_brate, 0 );
}
@@ -240,17 +241,17 @@ void post_decoder_ivas_fx(
IF( pfstat_on_previous )
{
Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, synth - M, M );
- Word16 L_subfr = st->L_frame / st->nb_subfr;
+ Word16 L_subfr = idiv1616( st->L_frame, st->nb_subfr );
Residu3_fx( st->old_Aq_12_8_fx, synth, synth_buf, L_subfr, 1 );
E_UTIL_synthesis( 1, st->old_Aq_12_8_fx, synth_buf, synth2, L_subfr, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M );
scale_st_fx( synth, synth2, &st->hPFstat->gain_prec, L_subfr );
- blend_subfr2_fx( synth2 + L_subfr / 2, synth + L_subfr / 2, synth2 + L_subfr / 2 );
+ blend_subfr2_fx( synth2 + shr( L_subfr, 1 ), synth + shr( L_subfr, 1 ), synth2 + shr( L_subfr, 1 ) );
}
}
ELSE
{
/*Formant enhancement*/
- IF( EQ_16( st->last_bwidth, NB ) )
+ IF( st->last_bwidth == NB )
{
Copy( synth, synth2_pe, L_frame );
tmp = synth[-1];
@@ -270,16 +271,17 @@ void post_decoder_ivas_fx(
move16();
}
- IF( EQ_16( pfstat_on_previous, 0 ) )
+ if ( pfstat_on_previous == 0 )
{
st->hPFstat->reset = 1;
move16();
}
- IF( EQ_16( st->bwidth, NB ) )
+ IF( st->bwidth == NB )
{
st->hPFstat->on = 1;
move16();
tmp_noise = 0;
+ move16();
nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, GENERIC, st->BER_detect, tmp );
}
ELSE
@@ -287,6 +289,7 @@ void post_decoder_ivas_fx(
st->hPFstat->on = 0;
move16();
tmp_noise = 0;
+ move16();
nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, AUDIO, st->BER_detect, tmp );
}
Copy( synth2_pe, synth2, L_frame );
@@ -297,7 +300,7 @@ void post_decoder_ivas_fx(
}
ELSE
{
- IF( EQ_16( pfstat_on_previous, 0 ) )
+ if ( pfstat_on_previous == 0 )
{
st->hPFstat->reset = 1;
move16();
@@ -383,7 +386,7 @@ static void bass_pf_1sf_delay(
lg = 0;
move16();
}
- if ( lg > l_subfr )
+ if ( GT_16( lg, l_subfr ) )
{
lg = l_subfr;
move16();
@@ -412,12 +415,12 @@ static void bass_pf_1sf_delay(
Word64 nrg64 = W_deposit32_l( nrg );
FOR( i = 0; i < lg; i++ )
{
- tmp32 = L_mult( syn[i + i_subfr - T], 0x4000 );
- tmp32 = L_mac( tmp32, syn[i + i_subfr + T], 0x4000 );
+ tmp32 = L_mult( syn[sub( add( i, i_subfr ), T )], 0x4000 );
+ tmp32 = L_mac( tmp32, syn[add( add( i, i_subfr ), T )], 0x4000 );
tmp16 = round_fx( L_shl( tmp32, s1 ) ); /* Q0+s1 */
- tmp64 = W_mac0_16_16( tmp64, shl( syn[i + i_subfr], s1 ), tmp16 ); /* Q0+2*s1 */
- nrg64 = W_mac0_16_16( nrg64, tmp16, tmp16 ); /* Q0+2*s1 */
+ tmp64 = W_mac0_16_16( tmp64, shl( syn[add( i, i_subfr )], s1 ), tmp16 ); /* Q0+2*s1 */
+ nrg64 = W_mac0_16_16( nrg64, tmp16, tmp16 ); /* Q0+2*s1 */
}
tmp = W_sat_l( tmp64 );
nrg = W_sat_l( nrg64 );
@@ -432,9 +435,9 @@ static void bass_pf_1sf_delay(
Word64 nrg64 = W_deposit32_l( nrg );
FOR( i = lg; i < l_subfr; i++ )
{
- tmp16 = shl( syn[i + i_subfr - T], s1 ); /* Q0+s1 */
- tmp64 = W_mac0_16_16( tmp64, shl( syn[i + i_subfr], s1 ), tmp16 ); /* Q0+2*s1 */
- nrg64 = W_mac0_16_16( nrg64, tmp16, tmp16 ); /* Q0+2*s1 */
+ tmp16 = shl( syn[sub( add( i, i_subfr ), T )], s1 ); /* Q0+s1 */
+ tmp64 = W_mac0_16_16( tmp64, shl( syn[add( i, i_subfr )], s1 ), tmp16 ); /* Q0+2*s1 */
+ nrg64 = W_mac0_16_16( nrg64, tmp16, tmp16 ); /* Q0+2*s1 */
}
tmp = W_sat_l( tmp64 );
nrg = W_sat_l( nrg64 );
@@ -474,10 +477,10 @@ static void bass_pf_1sf_delay(
Word64 ener2_64 = W_deposit32_l( ener2 );
FOR( i = 0; i < lg; i++ )
{
- tmp32 = L_msu0( 0, gain, syn[i + i_subfr - T] );
- tmp32 = L_msu0( tmp32, gain, syn[i + i_subfr + T] );
+ tmp32 = L_msu0( 0, gain, syn[sub( add( i, i_subfr ), T )] );
+ tmp32 = L_msu0( tmp32, gain, syn[add( add( i, i_subfr ), T )] );
#ifdef BASOP_NOGLOB
- tmp16 = mac_r_sat( tmp32, gain, syn[i + i_subfr] ); /* Q0 */
+ tmp16 = mac_r_sat( tmp32, gain, syn[add( i, i_subfr )] ); /* Q0 */
#else
tmp16 = mac_r( tmp32, gain, syn[i + i_subfr] ); /* Q0 */
#endif
@@ -504,8 +507,8 @@ static void bass_pf_1sf_delay(
FOR( i = lg; i < l_subfr; i++ )
{
#ifdef BASOP_NOGLOB
- tmp32 = L_mult0( gain, syn[i + i_subfr] );
- tmp32 = L_msu0_sat( tmp32, gain, syn[i + i_subfr - T] ); /* Q0 */
+ tmp32 = L_mult0( gain, syn[add( i, i_subfr )] );
+ tmp32 = L_msu0_sat( tmp32, gain, syn[sub( add( i, i_subfr ), T )] ); /* Q0 */
tmp16 = round_fx_sat( tmp32 );
lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ );
@@ -541,6 +544,7 @@ static void bass_pf_1sf_delay(
}
*lp_error_ener = L_add( Mpy_32_16_1( L_sub( *lp_error_ener, ener2 ), 32440 /*0.99f Q15*/ ), ener2 ); /* 15Q16 */
+ move32();
st = add( st, 6 );
ener2 = L_sub( *lp_error_ener, L_deposit_h( sub( 31, st ) ) );
@@ -587,11 +591,12 @@ static void bass_pf_1sf_delay(
{
FOR( i = 0; i < lg; i++ )
{
- tmp32 = L_msu0( 0, tmp16, syn[i + i_subfr - T] );
+ tmp32 = L_msu0( 0, tmp16, syn[sub( add( i, i_subfr ), T )] );
#ifdef BASOP_NOGLOB
- tmp32 = L_msu0_sat( tmp32, tmp16, syn[i + i_subfr + T] );
- tmp32 = L_mac_sat( tmp32, tmp16, syn[i + i_subfr] );
- bpf_noise_buf[i + i_subfr] = round_fx_sat( tmp32 ); /* Q0 */
+ tmp32 = L_msu0_sat( tmp32, tmp16, syn[add( add( i, i_subfr ), T )] );
+ tmp32 = L_mac_sat( tmp32, tmp16, syn[add( i, i_subfr )] );
+ bpf_noise_buf[add( i, i_subfr )] = round_fx_sat( tmp32 ); /* Q0 */
+ move16();
#else
tmp32 = L_msu0( tmp32, tmp16, syn[i + i_subfr + T] );
tmp32 = L_mac( tmp32, tmp16, syn[i + i_subfr] );
@@ -604,10 +609,11 @@ static void bass_pf_1sf_delay(
{
FOR( i = lg; i < l_subfr; i++ )
{
- tmp32 = L_mult0( tmp16, syn[i + i_subfr] );
+ tmp32 = L_mult0( tmp16, syn[add( i, i_subfr )] );
#ifdef BASOP_NOGLOB
- tmp32 = L_msu0_sat( tmp32, tmp16, syn[i + i_subfr - T] );
- bpf_noise_buf[i + i_subfr] = round_fx_sat( tmp32 ); /* Q0 */
+ tmp32 = L_msu0_sat( tmp32, tmp16, syn[sub( add( i, i_subfr ), T )] );
+ bpf_noise_buf[add( i, i_subfr )] = round_fx_sat( tmp32 ); /* Q0 */
+ move16();
#else
tmp32 = L_msu0( tmp32, tmp16, syn[i + i_subfr - T] );
bpf_noise_buf[i + i_subfr] = round_fx( tmp32 ); /* Q0 */
@@ -650,6 +656,7 @@ void cldfb_synth_set_bandsToZero(
Word16 i, k, tmp1, tmp2, tmp3, tmp, update_perc;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
@@ -660,16 +667,23 @@ void cldfb_synth_set_bandsToZero(
set32_fx( nrg_band, 0, CLDFB_NO_CHANNELS_MAX );
max_nrg = 0;
+ move32();
offset = 250;
+ move16();
WBcnt = 20;
- perc_miss = 13107; /*0.80 in Q14*/
+ move16();
+ perc_miss = 13107; /*0.80 in Q14*/
+ move16();
perc_detect = 14746; /*0.90 in Q14*/
+ move16();
IF( EQ_16( st->VAD, 1 ) )
{
st->active_frame_cnt_bwddec = add( st->active_frame_cnt_bwddec, 1 );
+ move16();
st->total_frame_cnt_bwddec = add( st->total_frame_cnt_bwddec, 1 );
+ move16();
if ( GT_16( st->active_frame_cnt_bwddec, 99 ) )
{
st->active_frame_cnt_bwddec = 100;
@@ -681,15 +695,15 @@ void cldfb_synth_set_bandsToZero(
move16();
}
- FOR( i = 0; i < ( st->cldfbSyn->no_channels - st->cldfbSyn->bandsToZero ); i++ )
+ FOR( i = 0; i < sub( st->cldfbSyn->no_channels, st->cldfbSyn->bandsToZero ); i++ )
{
nrgQ31 = 0;
move32();
FOR( k = 0; k < nTimeSlots; k++ )
{
/* use 16-bit precision of real and imag buffers */
- realQ1 = extract_l( L_shr( rAnalysis[k][i], 31 - ( 15 + scaleFactor.lb_scale ) + 3 ) );
- imagQ1 = extract_l( L_shr( iAnalysis[k][i], 31 - ( 15 + scaleFactor.lb_scale ) + 3 ) ); /* Q(-3), headroom */
+ realQ1 = extract_l( L_shr( rAnalysis[k][i], sub( 31 + 3 - 15, scaleFactor.lb_scale ) ) ); /*31 - (15 + scaleFactor.lb_scale) + 3 )*/
+ imagQ1 = extract_l( L_shr( iAnalysis[k][i], sub( 31 + 3 - 15, scaleFactor.lb_scale ) ) ); /* Q(-3), headroom */
#ifdef BASOP_NOGLOB
nrgQ31 = L_mac0_o( nrgQ31, realQ1, realQ1, &Overflow );
nrgQ31 = L_mac0_o( nrgQ31, imagQ1, imagQ1, &Overflow ); /* keep in Q(-6) */
@@ -723,6 +737,7 @@ void cldfb_synth_set_bandsToZero(
tempQ31 = L_shr( nrgQ31, 9 );
st->avg_nrg_LT = L_add( Mult_32_16( st->avg_nrg_LT, 32440 ), Mult_32_16( tempQ31, 327 ) ); /*0.99*avg_nrg_LT + 0.01*tempQ31*/
+ move32();
update_perc = 1;
move16();
if ( st->ini_frame >= 25 && tempQ31 < Mult_32_16( st->avg_nrg_LT, 164 ) )
@@ -739,7 +754,7 @@ void cldfb_synth_set_bandsToZero(
move16();
}
- FOR( i = 0; i < WBcnt - 1; i++ )
+ FOR( i = 0; i < sub( WBcnt, 1 ); i++ )
{
st->flag_buffer[i] = st->flag_buffer[i + 1];
move16();
@@ -753,6 +768,7 @@ void cldfb_synth_set_bandsToZero(
IF( flag != 0 )
{
tmp1 = sub( 16384, st->perc_bwddec ); /*Q14*/
+ move16();
tmp = norm_s( st->active_frame_cnt_bwddec );
tmp3 = shl( st->active_frame_cnt_bwddec, tmp ); /*Qtmp*/
@@ -760,10 +776,12 @@ void cldfb_synth_set_bandsToZero(
tmp2 = div_s( 16384, tmp3 ); /* 1/active_frames in Q15 + Q14 - Qtmp = Q29 - Qtmp */
tmp2 = mult_r( tmp2, tmp1 ); /*(1-perc)*(1/active_frames) in Q14 + Q29 - Qtmp - Q15 = Q28 - Qtmp*/
st->perc_bwddec = add( st->perc_bwddec, shl( tmp2, sub( tmp, 14 ) ) ); /* Q14 */
+ move16();
}
ELSE
{
tmp1 = ( st->perc_bwddec ); /*Q14*/
+ move16();
tmp = norm_s( st->active_frame_cnt_bwddec );
tmp3 = shl( st->active_frame_cnt_bwddec, tmp ); /*Qtmp*/
@@ -771,11 +789,14 @@ void cldfb_synth_set_bandsToZero(
tmp2 = div_s( 16384, tmp3 ); /* 1/active_frames in Q15 + Q14 - Qtmp = Q29 - Qtmp */
tmp2 = mult_r( tmp2, tmp1 ); /*(perc)*(1/active_frames) in Q14 + Q29 - Qtmp - Q15 = Q28 - Qtmp*/
st->perc_bwddec = sub( st->perc_bwddec, shl( tmp2, sub( tmp, 14 ) ) ); /* Q14 */
+ move16();
}
}
test();
IF( GT_16( st->total_frame_cnt_bwddec, offset ) && GT_16( st->active_frame_cnt_bwddec, 50 ) )
{
+ test();
+ test();
IF( ( st->perc_bwddec >= perc_detect || ( st->perc_bwddec >= perc_miss && st->last_flag_filter_NB ) ) && ( sum16_fx( st->flag_buffer, WBcnt ) != 0 ) ) /*decision hysterysis*/
{
st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 );
@@ -797,6 +818,7 @@ void cldfb_synth_set_bandsToZero(
IF( sum16_fx( st->flag_buffer, WBcnt ) == 0 )
{
st->perc_bwddec = 0;
+ move16();
st->active_frame_cnt_bwddec = 0;
move16();
st->total_frame_cnt_bwddec = 0;
@@ -807,12 +829,13 @@ void cldfb_synth_set_bandsToZero(
}
ELSE
{
- IF( st->last_flag_filter_NB == 1 )
+ if ( EQ_16( st->last_flag_filter_NB, 1 ) )
{
st->cldfbSyn->bandsToZero = st->last_active_bandsToZero_bwdec;
move16();
}
st->total_frame_cnt_bwddec = add( st->total_frame_cnt_bwddec, 1 );
+ move16();
if ( GT_16( st->total_frame_cnt_bwddec, 500 ) )
{
st->total_frame_cnt_bwddec = 500;
@@ -821,6 +844,7 @@ void cldfb_synth_set_bandsToZero(
}
st->last_active_bandsToZero_bwdec = st->cldfbSyn->bandsToZero;
+ move16();
return;
}
diff --git a/lib_dec/ppp_dec_fx.c b/lib_dec/ppp_dec_fx.c
index 24461a7fb5ce7becb26309088bcdaa41c972b9a1..275229e36d0cfe308e8d0b866f8b6e4c68909b56 100644
--- a/lib_dec/ppp_dec_fx.c
+++ b/lib_dec/ppp_dec_fx.c
@@ -4,8 +4,7 @@
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
/*===================================================================*/
@@ -58,12 +57,12 @@ static void DTFS_dequant_cw_fx(
Word32 L_tmp, L_temp;
Word32 L_tmp2;
- IF( num_erb_fx == NUM_ERB_NB )
+ IF( EQ_16( num_erb_fx, NUM_ERB_NB ) )
{
PowerCB_fx = PowerCB_NB_fx;
move16();
}
- ELSE IF( num_erb_fx == NUM_ERB_WB )
+ ELSE IF( EQ_16( num_erb_fx, NUM_ERB_WB ) )
{
PowerCB_fx = PowerCB_WB_fx;
move16();
@@ -73,12 +72,14 @@ static void DTFS_dequant_cw_fx(
erb_add_fx( curr_erb_fx, X_fx->lag_fx, lasterbD_fx, pl_fx, AMP_IDX_fx, num_erb_fx );
- curr_erb_fx[0] = mult_r( curr_erb_fx[1], 9830 ); /* 0.3 inQ15 leaves curr_erb in Q13 */
+ curr_erb_fx[0] = mult_r( curr_erb_fx[1], 9830 ); /* 0.3 inQ15 leaves curr_erb in Q13 */
+ move16();
curr_erb_fx[sub( num_erb_fx, 2 )] = mult_r( curr_erb_fx[sub( num_erb_fx, 3 )], 9830 ); /* Q13 */
-
move16();
+
curr_erb_fx[sub( num_erb_fx, 1 )] = 0;
+ move16();
erb_slot_fx( X_fx->lag_fx, slot_fx, mfreq_fx, num_erb_fx );
@@ -93,7 +94,8 @@ static void DTFS_dequant_cw_fx(
/* Need to unify the Q factors of both bands */
X_fx->Q = s_min( Ql, Qh ); /* set Q factor to be the smaller one */
- n = sub( Ql, Qh ); /* compare band Q factors */
+ move16();
+ n = sub( Ql, Qh ); /* compare band Q factors */
/* This logic adjusts difference between Q formats of both bands */
@@ -115,6 +117,8 @@ static void DTFS_dequant_cw_fx(
*lastLgainD_fx = add( *lastLgainD_fx, PowerCB_fx[tmp_fx] ); /* Q11 */
*lastHgainD_fx = add( *lastHgainD_fx, PowerCB_fx[tmp_fx + 1] ); /* Q11 */
#endif
+ move16();
+ move16();
L_tmp = L_deposit_h( X_fx->lag_fx ); /* Q16 */
exp = norm_l( L_tmp );
L_tmp = L_shl( L_tmp, exp );
@@ -171,6 +175,7 @@ static void DTFS_dequant_cw_fx(
L_temp = L_shl( L_tmp, exp1 + 15 ); /* Q15 */
#endif
L_tmp2 = L_temp;
+ move32();
if ( GE_32( L_temp, 2147483647 ) )
{
L_temp = L_shl( L_tmp, 15 ); /*Q(15-exp1) */
@@ -192,7 +197,8 @@ static void DTFS_dequant_cw_fx(
/* Need to unify the Q factors of both bands */
X_fx->Q = s_min( Ql, Qh ); /* set Q factor to be the smaller one */
- n = sub( Ql, Qh ); /* compare band Q factors */
+ move16();
+ n = sub( Ql, Qh ); /* compare band Q factors */
IF( n < 0 )
@@ -255,11 +261,16 @@ ivas_error ppp_quarter_decoder_fx(
DTFS_STRUCTURE *PREVDTFS_FX;
Word16 AMP_IDX_fx[2];
Word16 temp_pl_fx = prevCW_lag_fx, temp_l_fx = CURRCW_Q_DTFS_FX->lag_fx;
+ move16();
+ move16();
Word16 temp_fx;
Word16 l_fx = CURRCW_Q_DTFS_FX->lag_fx;
+ move16();
Word16 POWER_IDX_fx;
Word16 Erot_fx = 0;
+ move16();
Word16 num_erb_fx = 24;
+ move16();
Word32 temp32d_fx, temp32n_fx;
Word32 L_tmp, L_tmp1;
Word16 tmp, exp;
@@ -267,7 +278,7 @@ ivas_error ppp_quarter_decoder_fx(
error = IVAS_ERR_OK;
move16();
- IF( ( error = DTFS_new_fx( &PREVDTFS_FX ) ) != IVAS_ERR_OK )
+ IF( NE_32( ( error = DTFS_new_fx( &PREVDTFS_FX ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -287,7 +298,6 @@ ivas_error ppp_quarter_decoder_fx(
IF( bfi == 0 )
{
POWER_IDX_fx = (Word16) get_next_indice( st_fx, 6 );
- move16();
AMP_IDX_fx[0] = (Word16) get_next_indice( st_fx, 6 );
move16();
AMP_IDX_fx[1] = (Word16) get_next_indice( st_fx, 6 );
@@ -299,18 +309,22 @@ ivas_error ppp_quarter_decoder_fx(
This logic of normalisation is not employed in adjustlag, hence denormalisation is necessury.*/
/*As the upper cut of freqencies are normalized to 12800, we have to multiply upper cut off freq by
2.56(1/12800 in Q15) */
- temp32n_fx = L_mult( CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx, 10486 ); /* Q0+Q27 = Q28 */
- CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx = (Word16) L_shr( temp32n_fx, 13 ); /*Q15 */
- temp32n_fx = L_mult( CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx, 10486 ); /* Q0+Q27 = Q28 */
- CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx = (Word16) L_shr( temp32n_fx, 13 ); /*Q15 */
+ temp32n_fx = L_mult( CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx, 10486 ); /* Q0+Q27 = Q28 */
+ CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx = extract_l( L_shr( temp32n_fx, 13 ) ); /*Q15 */
+ move16();
+ temp32n_fx = L_mult( CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx, 10486 ); /* Q0+Q27 = Q28 */
+ CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx = extract_l( L_shr( temp32n_fx, 13 ) ); /*Q15 */
+ move16();
DTFS_dequant_cw_fx( prevCW_lag_fx, POWER_IDX_fx, AMP_IDX_fx, lastLgainD_fx, lastHgainD_fx, lasterbD_fx, CURRCW_Q_DTFS_FX, num_erb_fx );
/*De-normalize cut off frequencies */
- temp32n_fx = L_shl( (Word32) CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx, 13 ); /*Q28 */
- CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx = (Word16) find_remd( temp32n_fx, 20971, &temp32d_fx );
- temp32n_fx = L_shl( (Word32) CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx, 13 ); /*Q28 */
- CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx = (Word16) find_remd( temp32n_fx, 20971, &temp32d_fx );
+ temp32n_fx = L_shl( L_deposit_l( CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx ), 13 ); /*Q28 */
+ CURRCW_Q_DTFS_FX->upper_cut_off_freq_fx = extract_l( find_remd( temp32n_fx, 20971, &temp32d_fx ) );
+ move16();
+ temp32n_fx = L_shl( L_deposit_l( CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx ), 13 ); /*Q28 */
+ CURRCW_Q_DTFS_FX->upper_cut_off_freq_of_interest_fx = extract_l( find_remd( temp32n_fx, 20971, &temp32d_fx ) );
+ move16();
}
/* Copying phase spectrum over */
diff --git a/lib_dec/pvq_core_dec_fx.c b/lib_dec/pvq_core_dec_fx.c
index 65f94c31742942cdea1ffa76a2a713a1fc5bdabd..cf904fac67d7c8b4920f6946e7b860d9a2a23c0c 100644
--- a/lib_dec/pvq_core_dec_fx.c
+++ b/lib_dec/pvq_core_dec_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif
diff --git a/lib_dec/pvq_decode_fx.c b/lib_dec/pvq_decode_fx.c
index 1ae7b0988433d98d4cd1b43a63709103b0fc5d9d..24aa0cfac335eadccd4b666f93925e8481083323 100644
--- a/lib_dec/pvq_decode_fx.c
+++ b/lib_dec/pvq_decode_fx.c
@@ -4,8 +4,7 @@
#include
#include "options.h" /* Compilation switches */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
/*-------------------------------------------------------------------*
diff --git a/lib_dec/range_dec_fx.c b/lib_dec/range_dec_fx.c
index 440137a9595fdf8b0a330add1285fb992ccf5bdd..a516258921bce4ca826be375b0384e0074866ea8 100644
--- a/lib_dec/range_dec_fx.c
+++ b/lib_dec/range_dec_fx.c
@@ -3,11 +3,10 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*-------------------------------------------------------------------*
diff --git a/lib_dec/re8_dec_fx.c b/lib_dec/re8_dec_fx.c
index e1177d1ec19595a381976fe446d638ef100a1386..e6c35e29339fc8dc0f9080434b1ab8ed19f6f9e9 100644
--- a/lib_dec/re8_dec_fx.c
+++ b/lib_dec/re8_dec_fx.c
@@ -3,9 +3,8 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
/*--------------------------------------------------------------------------
* re8_dec_fx()
diff --git a/lib_dec/rst_dec_fx.c b/lib_dec/rst_dec_fx.c
index ad750273bf2eb49c5948abfba9d45244accc4016..50aa1b9068f66daeaafbc8cf25e9e16ecb29e42b 100644
--- a/lib_dec/rst_dec_fx.c
+++ b/lib_dec/rst_dec_fx.c
@@ -4,10 +4,9 @@
#include "options.h" /* Compilation switches */
#include "stl.h"
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*----------------------------------------------------------------------------------*
* CNG_reset_dec()
@@ -28,6 +27,7 @@ void CNG_reset_dec_fx(
/*set16_fx( st_fx->dispMem_fx, 0, 8 );*/
set16_fx( st_fx->dm_fx.prev_gain_pit, 0, 6 );
st_fx->dm_fx.prev_gain_code = L_deposit_l( 0 );
+ move32();
st_fx->dm_fx.prev_state = 0;
move16();
@@ -66,6 +66,7 @@ void CNG_reset_dec_fx(
#else
st_fx->lp_gainc_fx = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */
#endif
+ move16();
}
/* reset the pitch buffer in case of FRAME_NO_DATA or SID frames */
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
@@ -86,8 +87,8 @@ void CNG_reset_dec_fx(
if ( st_fx->hTdCngDec != NULL )
{
st_fx->hTdCngDec->act_cnt2 = 0;
+ move16();
}
- move16();
return;
}
diff --git a/lib_dec/stat_noise_uv_dec_fx.c b/lib_dec/stat_noise_uv_dec_fx.c
index 39b56fa7f5d498b9f7601406c03859d510a6bb32..651fb179e169d46c5484ed3413496eef34f48c11 100644
--- a/lib_dec/stat_noise_uv_dec_fx.c
+++ b/lib_dec/stat_noise_uv_dec_fx.c
@@ -3,9 +3,8 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
/*---------------------------------------------------------*
@@ -14,18 +13,19 @@
* Modifies excitation signal in UC mode when the noise is stationary
*---------------------------------------------------------*/
void stat_noise_uv_dec_fx(
- Decoder_State *st_fx, /* i/o: Decoder static memory */
- Word16 *lsp_new, /* i : end-frame LSP vector */
- Word16 *lsp_mid, /* i : mid-frame LSP vector */
- Word16 *Aq, /* o : A(z) quantized for the 4 subframes */
- Word16 *exc2 /* i/o: excitation buffer */
- ,
+ Decoder_State *st_fx, /* i/o: Decoder static memory */
+ Word16 *lsp_new, /* i : end-frame LSP vector */
+ Word16 *lsp_mid, /* i : mid-frame LSP vector */
+ Word16 *Aq, /* o : A(z) quantized for the 4 subframes */
+ Word16 *exc2, /* i/o: excitation buffer */
const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */
)
{
Word16 noisiness = 0, i;
+ move16();
Word32 L_tmp;
Word16 coder_type = st_fx->coder_type;
+ move16();
/*-----------------------------------------------------------------*
@@ -33,18 +33,18 @@ void stat_noise_uv_dec_fx(
*-----------------------------------------------------------------*/
test();
test();
- IF( ( EQ_16( coder_type, UNVOICED ) && !uc_two_stage_flag ) || ( EQ_16( coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) ) )
+ test();
+ IF( ( EQ_16( coder_type, UNVOICED ) && !uc_two_stage_flag ) || ( coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) ) )
{
/* read the noisiness parameter */
noisiness = (Word16) get_next_indice( st_fx, 5 );
- move16();
}
/*-----------------------------------------------------------------*
* Update long-term energies for FEC
* Update LSP vector for CNG
*-----------------------------------------------------------------*/
- IF( EQ_16( coder_type, INACTIVE ) )
+ IF( coder_type == INACTIVE )
{
IF( GT_16( st_fx->unv_cnt, 20 ) )
{
@@ -52,8 +52,8 @@ void stat_noise_uv_dec_fx(
L_tmp = L_mult0( st_fx->lp_gainc_fx, st_fx->lp_gainc_fx ); /*Q3 * Q3 ->Q6*/
/*st->lp_ener = 0.7f * st->lp_ener + 0.3f * ftmp;*/
L_tmp = Mult_32_16( L_tmp, 9830 );
- st_fx->lp_ener_fx = L_add( Mult_32_16( st_fx->lp_ener_fx, 22938 ), L_tmp );
- move16(); /*Q6 + Q6*/
+ st_fx->lp_ener_fx = L_add( Mult_32_16( st_fx->lp_ener_fx, 22938 ), L_tmp ); /*Q6 + Q6*/
+ move32();
FOR( i = 0; i < M; i++ ) /* AR Low pass filter */
{
@@ -66,6 +66,7 @@ void stat_noise_uv_dec_fx(
ELSE
{
st_fx->unv_cnt = add( st_fx->unv_cnt, 1 );
+ move16();
}
}
ELSE
diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c
index bcee869822b3c5ff5eb1a666bbf2603157a77b9f..a1b61cdc6e464411339b146ddeaa6ca58d1e600d 100644
--- a/lib_dec/swb_bwe_dec.c
+++ b/lib_dec/swb_bwe_dec.c
@@ -39,14 +39,13 @@
#include
#include "cnst.h"
#include "prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "basop_util.h"
#include "basop_proto_func.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
#endif // IVAS_FLOAT_FIXED
#ifndef IVAS_FLOAT_FIXED
@@ -239,6 +238,7 @@ static Word16 para_pred_bws_fx(
Word32 avrg1_fx, avrg2_fx, min_fx;
Word16 att_fx;
Word16 coder_type = st_fx->coder_type;
+ move16();
mode = NORMAL;
move16();
@@ -246,7 +246,6 @@ static Word16 para_pred_bws_fx(
k = 0;
move16();
input_hi_fx = &signal_wb_fx[SHARP_WIDTH];
- move16();
FOR( i = 0; i < 7; i++ )
{
peak_fx = 0;
@@ -266,7 +265,7 @@ static Word16 para_pred_bws_fx(
input_hi_fx++;
}
- IF( Q_syn < 11 )
+ IF( LT_16( Q_syn, 11 ) )
{
tmp = 1;
move16();
@@ -343,6 +342,7 @@ static Word16 para_pred_bws_fx(
IF( GT_16( st_fx->tilt_wb_fx, 30720 ) )
{
min_fx = peak_32_fx;
+ move32();
}
ELSE
{
@@ -380,34 +380,30 @@ static Word16 para_pred_bws_fx(
j = 0;
move16();
mea = &mean_fx[4];
- move16();
L_tmp_max = L_shl( 32767, add( Q_syn, 5 ) );
FOR( i = 0; i < SWB_FENV; i++ )
{
- IF( j == 5 )
+ if ( EQ_16( j, 5 ) )
{
mea++;
- move16();
j = 0;
move16();
}
- j++;
- move16();
+ j = add( j, 1 );
L_tmp = L_min( Mult_32_16( *mea, tmp ), L_tmp_max );
SWB_fenv_fx[i] = extract_l( L_shr( L_tmp, add( Q_syn, 5 ) ) );
+ move16();
}
}
j = 0;
move16();
- FOR( i = shr( SWB_FENV, 1 ); i < SWB_FENV; i++ )
+ FOR( i = SWB_FENV / 2; i < SWB_FENV; i++ )
{
tmp = sub( 32767, i_mult( j, 2341 ) );
- move16();
SWB_fenv_fx[i] = mult_r( SWB_fenv_fx[i], tmp );
move16();
- j++;
- move16();
+ j = add( j, 1 );
}
IF( GT_32( avrg1_fx, L_shl( avrg2_fx, 3 ) ) )
@@ -435,11 +431,13 @@ static Word16 para_pred_bws_fx(
{
/*SWB_fenv_fx[i] = add(mult_r(SWB_fenv_fx[i], 3277), mult_r(st_fx->prev_SWB_fenv_fx[i], 29491)); */
SWB_fenv_fx[i] = round_fx( L_mac( L_mult( SWB_fenv_fx[i], 3277 ), st_fx->prev_SWB_fenv_fx[i], 29491 ) );
+ move16();
}
ELSE
{
/*SWB_fenv_fx[i] = add(mult_r(SWB_fenv_fx[i], st_fx->attenu_fx), mult_r(st_fx->prev_SWB_fenv_fx[i], sub(32767, st_fx->attenu_fx))); */
SWB_fenv_fx[i] = round_fx( L_mac( L_mult( SWB_fenv_fx[i], st_fx->attenu_fx ), st_fx->prev_SWB_fenv_fx[i], sub( 32767, st_fx->attenu_fx ) ) );
+ move16();
}
}
@@ -472,6 +470,7 @@ static Word16 para_pred_bws_fx(
{
/*SWB_fenv_fx[i] = add(mult_r(SWB_fenv_fx[i], 29491), mult_r(st_fx->prev_SWB_fenv_fx[i], 3277)); */
SWB_fenv_fx[i] = round_fx( L_mac( L_mult( SWB_fenv_fx[i], 29491 ), st_fx->prev_SWB_fenv_fx[i], 3277 ) );
+ move16();
}
st_fx->attenu_fx = 3277;
move16();
@@ -484,8 +483,7 @@ static Word16 para_pred_bws_fx(
}
- att_fx = i_mult( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 819 );
- move16(); /*15 */
+ att_fx = i_mult( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 819 ); /*15 */
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
FOR( i = 0; i < 4; i++ )
@@ -1072,8 +1070,10 @@ Word16 swb_bwe_dec_fx32(
Word16 i, j, l_subfr;
Word16 fb_band_begin;
Word16 frica_flag = 0;
+ move16();
Word16 ener_adjust_quan_fx;
Word16 fb_ener_adjust_fx = 0;
+ move16();
Word16 scl, new_input_fx_exp, ysynth_frame_size;
Word16 Q_syn, Q_syn_hb, tmp, tmp2, q_tmp, Qsynth_fx16;
@@ -1095,7 +1095,7 @@ Word16 swb_bwe_dec_fx32(
/*---------------------------------------------------------------------*
* SWB BWE decoding
*---------------------------------------------------------------------*/
-
+ test();
IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft )
{
/* todo - wtda() does not support L_FRAME length; thus temporarily resample the signal */
@@ -1107,8 +1107,10 @@ Word16 swb_bwe_dec_fx32(
/* DCT of the ACELP core synthesis */
new_input_fx_exp = 11;
+ move16();
direct_transform_fx( wtda_synth_fx, ysynth_fx32, 0, /*st_fx->L_frame*/ L_FRAME16k, &new_input_fx_exp, st_fx->element_mode );
ysynth_frame_size = L_FRAME16k;
+ move16();
}
ELSE
{
@@ -1119,18 +1121,20 @@ Word16 swb_bwe_dec_fx32(
/* DCT of the ACELP core synthesis */
// direct_transform(wtda_synth, ysynth, 0, output_frame, st_fx->element_mode);
new_input_fx_exp = 11;
+ move16();
direct_transform_fx( wtda_synth_fx, ysynth_fx32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode );
ysynth_frame_size = output_frame;
+ move16();
}
/* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */
scl = sub( 16 + 11, new_input_fx_exp );
/* Possible to Upscale? */
- IF( GT_16( scl, 0 ) )
+ IF( scl > 0 )
{
/* Yes */
/* Calc Room to Upscale */
- Q_syn = Find_Max_Norm32( ysynth_fx32, ysynth_frame_size ) - 3;
+ Q_syn = sub( Find_Max_Norm32( ysynth_fx32, ysynth_frame_size ), 3 );
/* Stay within MAX_Q_NEW_INPUT */
scl = s_min( Q_syn, scl );
}
@@ -1140,8 +1144,10 @@ Word16 swb_bwe_dec_fx32(
FOR( i = 0; i < ysynth_frame_size; i++ )
{
ysynth_fx[i] = extract_l( ysynth_fx32[i] );
+ move16();
}
Q_syn = new_input_fx_exp;
+ move16();
}
ELSE
{
@@ -1151,7 +1157,7 @@ Word16 swb_bwe_dec_fx32(
IF( !st_fx->bfi )
{
- IF( GT_16( st_fx->bws_cnt, 0 ) )
+ IF( st_fx->bws_cnt > 0 )
{
/* estimate parameters */
mode = para_pred_bws_fx( st_fx, ysynth_fx, SWB_fenv_fx, Q_syn );
@@ -1163,12 +1169,15 @@ Word16 swb_bwe_dec_fx32(
}
L = SWB_FENV;
- IF( EQ_16( mode, TRANSIENT ) )
+ move16();
+ if ( EQ_16( mode, TRANSIENT ) )
{
L = SWB_FENV_TRANS;
+ move16();
}
L_tmp = 0;
+ move32();
FOR( i = 0; i < L; i++ )
{
L_tmp = L_add( L_tmp, L_deposit_l( SWB_fenv_fx[i] ) );
@@ -1177,6 +1186,7 @@ Word16 swb_bwe_dec_fx32(
tmp = div_s( shl( 1, sub( 14, q_tmp ) ), L ); /*Q(29-q_tmp) */
L_tmp = Mpy_32_16_1( L_tmp, tmp ); /*Q(1+29-q_tmp+1-16)->Q(15-q_tmp) */
st_fx->prev_ener_shb_fx = round_fx( L_shl( L_tmp, add( q_tmp, 2 ) ) ); /*Q1 */
+ move16();
}
ELSE
{
@@ -1185,10 +1195,12 @@ Word16 swb_bwe_dec_fx32(
IF( NE_16( hBWE_FD->prev_mode, TRANSIENT ) )
{
mode = hBWE_FD->prev_mode;
+ move16();
}
ELSE
{
mode = NORMAL;
+ move16();
}
Copy( st_fx->prev_SWB_fenv_fx, SWB_fenv_fx, SWB_FENV );
@@ -1206,18 +1218,20 @@ Word16 swb_bwe_dec_fx32(
SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl, st_fx->element_mode );
}
-
+ test();
IF( EQ_16( hBWE_FD->prev_frica_flag, 1 ) && frica_flag == 0 )
{
FOR( i = 0; i < L_SUBFR; i++ )
{
tmp = sub( 32767, extract_l( L_mult0( i, 512 ) ) ); /*Q15 */
hBWE_FD->mem_imdct_fx[i] = mult_r( hBWE_FD->mem_imdct_fx[i], tmp );
+ move16();
}
FOR( ; i < output_frame; i++ )
{
hBWE_FD->mem_imdct_fx[i] = 0;
+ move16();
}
}
@@ -1232,9 +1246,11 @@ Word16 swb_bwe_dec_fx32(
ELSE IF( st_fx->bfi )
{
fb_ener_adjust_fx = st_fx->prev_fb_ener_adjust_fx;
+ move16();
}
st_fx->prev_fb_ener_adjust_fx = fb_ener_adjust_fx;
+ move16();
IF( EQ_16( mode, TRANSIENT ) )
{
ener_adjust_quan_fx = shr( fb_ener_adjust_fx, 2 );
@@ -1249,17 +1265,21 @@ Word16 swb_bwe_dec_fx32(
ELSE
{
ener_adjust_quan_fx = 0;
+ move16();
}
}
fb_band_begin = FB_BAND_BEGIN;
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ move16();
+ if ( EQ_16( st_fx->L_frame, L_FRAME ) )
{
fb_band_begin = FB_BAND_BEGIN_12k8;
+ move16();
}
j = 0;
- FOR( i = fb_band_begin; i < fb_band_begin + DE_OFFSET1; i++ )
+ move16();
+ FOR( i = fb_band_begin; i < add( fb_band_begin, DE_OFFSET1 ); i++ )
{
tmp = sub( 32767, i_mult( j, 1024 ) );
tmp = mult_r( tmp, ener_adjust_quan_fx ); /*Q13*/
@@ -1269,11 +1289,13 @@ Word16 swb_bwe_dec_fx32(
tmp = add( tmp, tmp2 ); /*Q13*/
yerror_fx[i] = L_shl( Mpy_32_16_1( yerror_fx[i - FB_BAND_WIDTH], tmp ), 2 ); /*15+Q_syn */
+ move32();
j = add( j, 1 );
}
FOR( ; i < FB_BAND_END; i++ )
{
yerror_fx[i] = Mpy_32_16_1( yerror_fx[i - FB_BAND_WIDTH], fb_ener_adjust_fx ); /*15+Q_syn */
+ move32();
}
}
@@ -1285,11 +1307,13 @@ Word16 swb_bwe_dec_fx32(
window_ola_fx( wtda_synth_fx, hb_synth_fx16, &Q_syn_hb, hBWE_FD->mem_imdct_fx, &hBWE_FD->mem_imdct_exp_fx, output_frame, ALDO_WINDOW, ALDO_WINDOW, 0, 0, 0 );
l_subfr = mult( output_frame, 8192 );
+ test();
IF( EQ_16( mode, TRANSIENT ) )
{
FOR( i = 0; i < SWB_TENV; i++ )
{
SWB_tenv_tmp_fx[i] = L_mult0( SWB_tenv_fx[i], 26214 );
+ move32();
}
/* time envelope shaping when the current frame is TRANSIENT frame */
@@ -1297,13 +1321,14 @@ Word16 swb_bwe_dec_fx32(
Q_syn_hb = sub( Q_syn_hb, 3 );
hBWE_FD->prev_td_energy_fx = SWB_tenv_fx[3];
+ move16();
}
- ELSE IF( EQ_16( frica_flag, 1 ) && EQ_16( hBWE_FD->prev_frica_flag, 0 ) )
+ ELSE IF( EQ_16( frica_flag, 1 ) && hBWE_FD->prev_frica_flag == 0 )
{
Qsynth_fx16 = Find_Max_Norm32( synth_fx, output_frame );
Qsynth_fx16 = sub( Qsynth_fx16, shr( add( sub( 15, norm_s( l_subfr ) ), 1 ), 1 ) );
Copy_Scale_sig32_16( synth_fx, synth_fx16, output_frame, Qsynth_fx16 );
- Qsynth_fx16 = add( sub( 11, 16 ), Qsynth_fx16 );
+ Qsynth_fx16 = add( 11 - 16, Qsynth_fx16 );
/* IVAS_fmToDo: synth[] is @internal_Fs!!! */
time_reduce_pre_echo_fx( synth_fx16, hb_synth_fx16, hBWE_FD->prev_td_energy_fx, l_subfr, Qsynth_fx16, Q_syn_hb );
@@ -1315,13 +1340,14 @@ Word16 swb_bwe_dec_fx32(
FOR( i = 0; i < l_subfr; i++ )
{
- L_tmp = L_mac0_sat( L_tmp, hb_synth_fx16[tmp + i], hb_synth_fx16[tmp + i] ); /*(2*Q_syn_hb) */
+ L_tmp = L_mac0_sat( L_tmp, hb_synth_fx16[add( tmp, i )], hb_synth_fx16[add( tmp, i )] ); /*(2*Q_syn_hb) */
}
L_tmp = Mult_32_16( L_tmp, div_s( 1, l_subfr ) ); /*(2*Q_syn_hb) */
hBWE_FD->prev_td_energy_fx = 0;
+ move16();
- IF( NE_32( L_tmp, 0 ) )
+ IF( L_tmp != 0 )
{
q_tmp = norm_l( L_tmp );
tmp = extract_h( L_shl( L_tmp, q_tmp ) );
@@ -1331,12 +1357,14 @@ Word16 swb_bwe_dec_fx32(
L_tmp = L_deposit_h( tmp );
L_tmp = Isqrt_lc( L_tmp, &q_tmp ); /*Q(31-exp) */
hBWE_FD->prev_td_energy_fx = round_fx( L_shl( L_tmp, sub( q_tmp, 15 ) ) ); /*Q0 */
+ move16();
}
}
+ test();
IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft )
{
- Qsynth_fx16 = add( sub( 16, 11 ), Q_syn_hb );
+ Qsynth_fx16 = add( 16 - 11, Q_syn_hb );
Copy_Scale_sig32_16( synth_fx, synth_fx16, output_frame, Qsynth_fx16 );
/* add HB synth from hf_synth() */
@@ -1344,11 +1372,14 @@ Word16 swb_bwe_dec_fx32(
}
hBWE_FD->prev_mode = mode;
+ move16();
hBWE_FD->prev_frica_flag = frica_flag;
+ move16();
FOR( i = 0; i < output_frame; i++ )
{
hb_synth_fx[i] = L_deposit_l( hb_synth_fx16[i] );
+ move32();
}
return Q_syn_hb;
diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c
index 34167dc29ccba29d109f0225734f1086e03a2dd1..4b172de7bf8a7abe9b3931954172befa488118f3 100644
--- a/lib_dec/swb_bwe_dec_fx.c
+++ b/lib_dec/swb_bwe_dec_fx.c
@@ -5,8 +5,7 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "rom_enc.h"
#include "ivas_prot_fx.h"
@@ -38,6 +37,7 @@ static Word16 para_pred_bws_fx(
Word32 avrg1_fx, avrg2_fx, min_fx;
Word16 att_fx;
Word16 coder_type = st_fx->coder_type;
+ move16();
mode = NORMAL;
move16();
@@ -45,7 +45,6 @@ static Word16 para_pred_bws_fx(
k = 0;
move16();
input_hi_fx = &signal_wb_fx[SHARP_WIDTH];
- move16();
FOR( i = 0; i < 7; i++ )
{
peak_fx = 0;
@@ -65,7 +64,7 @@ static Word16 para_pred_bws_fx(
input_hi_fx++;
}
- IF( Q_syn < 11 )
+ IF( LT_16( Q_syn, 11 ) )
{
tmp = 1;
move16();
@@ -142,6 +141,7 @@ static Word16 para_pred_bws_fx(
IF( GT_16( st_fx->tilt_wb_fx, 30720 ) )
{
min_fx = peak_32_fx;
+ move32();
}
ELSE
{
@@ -179,34 +179,30 @@ static Word16 para_pred_bws_fx(
j = 0;
move16();
mea = &mean_fx[4];
- move16();
L_tmp_max = L_shl( 32767, add( Q_syn, 5 ) );
FOR( i = 0; i < SWB_FENV; i++ )
{
- IF( j == 5 )
+ if ( EQ_16( j, 5 ) )
{
mea++;
- move16();
j = 0;
move16();
}
- j++;
- move16();
+ j = add( j, 1 );
L_tmp = L_min( Mult_32_16( *mea, tmp ), L_tmp_max );
SWB_fenv_fx[i] = extract_l( L_shr( L_tmp, add( Q_syn, 5 ) ) );
+ move16();
}
}
j = 0;
move16();
- FOR( i = shr( SWB_FENV, 1 ); i < SWB_FENV; i++ )
+ FOR( i = SWB_FENV / 2; i < SWB_FENV; i++ )
{
tmp = sub( 32767, i_mult( j, 2341 ) );
- move16();
SWB_fenv_fx[i] = mult_r( SWB_fenv_fx[i], tmp );
move16();
- j++;
- move16();
+ j = add( j, 1 );
}
IF( GT_32( avrg1_fx, L_shl( avrg2_fx, 3 ) ) )
@@ -234,11 +230,13 @@ static Word16 para_pred_bws_fx(
{
/*SWB_fenv_fx[i] = add(mult_r(SWB_fenv_fx[i], 3277), mult_r(st_fx->prev_SWB_fenv_fx[i], 29491)); */
SWB_fenv_fx[i] = round_fx( L_mac( L_mult( SWB_fenv_fx[i], 3277 ), st_fx->prev_SWB_fenv_fx[i], 29491 ) );
+ move16();
}
ELSE
{
/*SWB_fenv_fx[i] = add(mult_r(SWB_fenv_fx[i], st_fx->attenu_fx), mult_r(st_fx->prev_SWB_fenv_fx[i], sub(32767, st_fx->attenu_fx))); */
SWB_fenv_fx[i] = round_fx( L_mac( L_mult( SWB_fenv_fx[i], st_fx->attenu_fx ), st_fx->prev_SWB_fenv_fx[i], sub( 32767, st_fx->attenu_fx ) ) );
+ move16();
}
}
@@ -271,6 +269,7 @@ static Word16 para_pred_bws_fx(
{
/*SWB_fenv_fx[i] = add(mult_r(SWB_fenv_fx[i], 29491), mult_r(st_fx->prev_SWB_fenv_fx[i], 3277)); */
SWB_fenv_fx[i] = round_fx( L_mac( L_mult( SWB_fenv_fx[i], 29491 ), st_fx->prev_SWB_fenv_fx[i], 3277 ) );
+ move16();
}
st_fx->attenu_fx = 3277;
move16();
@@ -283,8 +282,7 @@ static Word16 para_pred_bws_fx(
}
- att_fx = i_mult( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 819 );
- move16(); /*15 */
+ att_fx = i_mult( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 819 ); /*15 */
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
FOR( i = 0; i < 4; i++ )
@@ -332,7 +330,7 @@ Word16 WB_BWE_gain_deq_fx(
move16();
- L_tmp = L_shr( F_2_5_fx[add( index2, 1 )], 1 );
+ L_tmp = L_shr( F_2_5_fx[index2 + 1], 1 );
L_tmp = L_shl( L_tmp, 6 );
frac = L_Extract_lc( L_tmp, &exp );
@@ -372,6 +370,7 @@ Word16 ivas_wb_bwe_dec_fx(
FD_BWE_DEC_HANDLE hBWE_FD;
Word16 coder_type = st_fx->coder_type;
+ move16();
hBWE_FD = st_fx->hBWE_FD;
@@ -379,7 +378,8 @@ Word16 ivas_wb_bwe_dec_fx(
new_input_fx_exp = *Qpost;
move16();
- IF( st_fx->element_mode == IVAS_CPE_DFT && !use_cldfb_for_dft )
+ test();
+ IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft )
{
/* IVAS_fmToDo: wtda() does not support L_FRAME length; thus temporarily resample the signal */
/* IVAS_fmToDo: delay output[] by 1.25ms ? */
@@ -387,6 +387,7 @@ Word16 ivas_wb_bwe_dec_fx(
wtda_fx( ysynth_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, &hBWE_FD->old_wtda_swb_fx_exp, ALDO_WINDOW, ALDO_WINDOW, /*st->L_frame*/ L_FRAME16k );
*Qpost = sub( new_input_fx_exp, 15 );
+ move16();
direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, /*st->L_frame*/ L_FRAME16k, &new_input_fx_exp, st_fx->element_mode );
}
ELSE
@@ -395,6 +396,7 @@ Word16 ivas_wb_bwe_dec_fx(
&hBWE_FD->old_wtda_swb_fx_exp, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */
output_frame );
*Qpost = sub( new_input_fx_exp, 15 );
+ move16();
/* DCT of the ACELP core synthesis */
#ifdef MSAN_FIX
direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, L_FRAME16k, &new_input_fx_exp, st_fx->element_mode );
@@ -430,19 +432,21 @@ Word16 ivas_wb_bwe_dec_fx(
/* de-quantization */
mode = WB_BWE_gain_deq_fx( st_fx, WB_fenv_fx );
st_fx->last_wb_bwe_ener_fx = extract_l( Mpy_32_16_r( L_add( WB_fenv_fx[0], WB_fenv_fx[1] ), 16384 ) );
+ move16();
}
ELSE
{
Word32 tmp_brate;
tmp_brate = st_fx->last_core_brate;
+ move32();
test();
- IF( EQ_32( st_fx->last_total_brate, ACELP_9k60 ) && EQ_16( st_fx->last_extl, SWB_TBE ) )
+ if ( EQ_32( st_fx->last_total_brate, ACELP_9k60 ) && EQ_16( st_fx->last_extl, SWB_TBE ) )
{
tmp_brate = ACELP_8k00; /* this is needed in order to stay BE wrt. EVS mono */
- move16();
+ move32();
}
- IF( NE_16( st_fx->last_extl, WB_BWE ) )
+ if ( NE_16( st_fx->last_extl, WB_BWE ) )
{
st_fx->prev_SWB_fenv_fx[0] = 0;
move16();
@@ -450,7 +454,6 @@ Word16 ivas_wb_bwe_dec_fx(
mode = WB_BWE_gain_pred_fx( WB_fenv_fx, ysynth_fx, coder_type, st_fx->prev_coder_type, st_fx->prev_SWB_fenv_fx[0],
voice_factors_fx, pitch_buf_fx, tmp_brate, st_fx->last_wb_bwe_ener_fx, Q_syn, st_fx->last_extl, st_fx->tilt_wb_fx );
- move16();
}
}
ELSE
@@ -461,6 +464,7 @@ Word16 ivas_wb_bwe_dec_fx(
FOR( i = 0; i < 2; i++ )
{
WB_fenv_fx[i] = mult_r( st_fx->prev_SWB_fenv_fx[i], 24576 );
+ move16();
}
}
test();
@@ -473,11 +477,13 @@ Word16 ivas_wb_bwe_dec_fx(
IF( GT_16( add( st_fx->prev_Q_synth, exp ), Q_syn ) )
{
hBWE_FD->prev_Energy_wb_fx = L_shr( hBWE_FD->prev_Energy_wb_fx, sub( st_fx->prev_Q_synth, Q_syn ) );
+ move32();
}
ELSE
{
Q_syn = add( st_fx->prev_Q_synth, exp );
hBWE_FD->prev_Energy_wb_fx = L_shl( hBWE_FD->prev_Energy_wb_fx, exp );
+ move32();
}
WB_BWE_decoding_fx( ysynth_fx, WB_fenv_fx, ysynth_32, L_FRAME16k, mode,
st_fx->last_extl, &hBWE_FD->prev_Energy_wb_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm,
@@ -502,7 +508,9 @@ Word16 ivas_wb_bwe_dec_fx(
v_add_16( hb_synth_fx, synth_fx, hb_synth_fx, output_frame );
}
hBWE_FD->prev_mode = mode;
+ move16();
st_fx->prev_Q_synth = Q_syn;
+ move16();
return Q_syn_hb;
}
#endif
@@ -533,6 +541,7 @@ Word16 wb_bwe_dec_fx(
FD_BWE_DEC_HANDLE hBWE_FD;
Word16 coder_type = st_fx->coder_type;
+ move16();
hBWE_FD = st_fx->hBWE_FD;
@@ -557,6 +566,7 @@ Word16 wb_bwe_dec_fx(
&hBWE_FD->old_wtda_swb_fx_exp, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */
output_frame );
*Qpost = sub( new_input_fx_exp, 15 );
+ move16();
/* DCT of the ACELP core synthesis */
direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode );
}
@@ -588,18 +598,20 @@ Word16 wb_bwe_dec_fx(
#else
st_fx->last_wb_bwe_ener_fx = mult_r( add( WB_fenv_fx[0], WB_fenv_fx[1] ), 16384 );
#endif
+ move16();
}
ELSE
{
int32_t tmp_brate;
tmp_brate = st_fx->last_core_brate;
+ move32();
#if 1 // def ADD_IVAS_BWE
test();
- IF( EQ_32( st_fx->last_total_brate, ACELP_9k60 ) && EQ_16( st_fx->last_extl, SWB_TBE ) )
+ if ( EQ_32( st_fx->last_total_brate, ACELP_9k60 ) && EQ_16( st_fx->last_extl, SWB_TBE ) )
{
tmp_brate = ACELP_8k00; /* this is needed in order to stay BE wrt. EVS mono */
- move16();
+ move32();
}
#endif
if ( NE_16( st_fx->last_extl, WB_BWE ) )
@@ -610,7 +622,6 @@ Word16 wb_bwe_dec_fx(
mode = WB_BWE_gain_pred_fx( WB_fenv_fx, ysynth_fx, coder_type, st_fx->prev_coder_type, st_fx->prev_SWB_fenv_fx[0],
voice_factors_fx, pitch_buf_fx, tmp_brate, st_fx->last_wb_bwe_ener_fx, Q_syn, st_fx->last_extl, st_fx->tilt_wb_fx );
- move16();
}
}
ELSE
@@ -621,6 +632,7 @@ Word16 wb_bwe_dec_fx(
FOR( i = 0; i < 2; i++ )
{
WB_fenv_fx[i] = mult_r( st_fx->prev_SWB_fenv_fx[i], 24576 );
+ move16();
}
}
test();
@@ -633,11 +645,13 @@ Word16 wb_bwe_dec_fx(
IF( GT_16( add( st_fx->prev_Q_synth, exp ), Q_syn ) )
{
hBWE_FD->prev_Energy_wb_fx = L_shr( hBWE_FD->prev_Energy_wb_fx, sub( st_fx->prev_Q_synth, Q_syn ) );
+ move32();
}
ELSE
{
Q_syn = add( st_fx->prev_Q_synth, exp );
hBWE_FD->prev_Energy_wb_fx = L_shl( hBWE_FD->prev_Energy_wb_fx, exp );
+ move32();
}
WB_BWE_decoding_fx( ysynth_fx, WB_fenv_fx, ysynth_32, L_FRAME16k, mode,
st_fx->last_extl, &hBWE_FD->prev_Energy_wb_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm,
@@ -664,7 +678,9 @@ Word16 wb_bwe_dec_fx(
}
#endif
hBWE_FD->prev_mode = mode;
+ move16();
st_fx->prev_Q_synth = Q_syn;
+ move16();
return Q_syn_hb;
}
/*-------------------------------------------------------------------*
@@ -708,7 +724,7 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class
}
test();
- IF( EQ_16( mode, 1 ) && EQ_16( core, ACELP_CORE ) )
+ IF( EQ_16( mode, 1 ) && core == ACELP_CORE )
{
FOR( n_band = 0; n_band < SWB_TENV; n_band++ )
{
@@ -740,7 +756,7 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class
quant_tmp[1] = add( shr( add( quant_tmp[0], quant_tmp[2] ), 1 ), Env_TR_Cdbk2_fx[tmp] );
#endif
move16(); /*Q8 */
- quant_tmp[3] = add( quant_tmp[2], Env_TR_Cdbk2_fx[add( tmp, 1 )] );
+ quant_tmp[3] = add( quant_tmp[2], Env_TR_Cdbk2_fx[tmp + 1] );
move16(); /*Q8 */
FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ )
@@ -817,9 +833,9 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class
Copy( &EnvCdbk11_fx[i_mult2( indice[0], DIM11 )], quant_tmp, DIM11 );
Copy( &EnvCdbk1st_fx[i_mult2( indice[1], DIM1ST )], quant_tmp2, DIM1ST );
- Copy( &EnvCdbk2nd_fx[i_mult2( indice[2], DIM2ND )], quant_tmp2 + DIM1ST, DIM2ND );
+ Copy( &EnvCdbk2nd_fx[indice[2] * DIM2ND], quant_tmp2 + DIM1ST, DIM2ND );
- FOR( n_band = 0; n_band < DIM11 - 1; n_band++ )
+ FOR( n_band = 0; n_band < ( DIM11 - 1 ); n_band++ )
{
quant_tmp[n_band] = add( quant_tmp[n_band], quant_tmp2[n_band] );
move16(); /*Q8 */
@@ -834,13 +850,13 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class
SWB_fenv[11] = quant_tmp[6];
move16();
- Copy( &EnvCdbk3rd_fx[indice[3] * DIM3RD], quant_tmp2, DIM3RD );
- Copy( &EnvCdbk3rd_fx[indice[4] * DIM3RD], quant_tmp2 + DIM3RD, DIM3RD );
+ Copy( &EnvCdbk3rd_fx[i_mult( indice[3], DIM3RD )], quant_tmp2, DIM3RD );
+ Copy( &EnvCdbk3rd_fx[i_mult( indice[4], DIM3RD )], quant_tmp2 + DIM3RD, DIM3RD );
FOR( n_band = 0; n_band < 5; n_band++ )
{
#ifdef BASOP_NOGLOB
- SWB_fenv[add( shl( n_band, 1 ), 1 )] = add_sat( shr( add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ), 1 ), quant_tmp2[n_band + 1] );
+ SWB_fenv[add( n_band * 2, 1 )] = add_sat( shr( add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ), 1 ), quant_tmp2[n_band + 1] );
#else
SWB_fenv[add( shl( n_band, 1 ), 1 )] = add( shr( add( quant_tmp[n_band], quant_tmp[n_band + 1] ), 1 ), quant_tmp2[n_band + 1] );
#endif
@@ -858,19 +874,19 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class
move16();
Copy( &EnvCdbk3rd_fx[i_mult2( indice[3], DIM3RD )], quant_tmp2, DIM3RD );
- Copy( &EnvCdbk4th_fx[i_mult2( indice[4], DIM4TH )], quant_tmp2 + DIM3RD, DIM4TH );
+ Copy( &EnvCdbk4th_fx[indice[4] * DIM4TH], quant_tmp2 + DIM3RD, DIM4TH );
FOR( n_band = 0; n_band < DIM12 - 1; n_band++ )
{
#ifdef BASOP_NOGLOB
- SWB_fenv[add( shl( n_band, 1 ), 1 )] = add_sat( shr( add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ), 1 ), quant_tmp2[n_band] );
+ SWB_fenv[add( n_band * 2, 1 )] = add_sat( shr( add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ), 1 ), quant_tmp2[n_band] );
#else
SWB_fenv[add( shl( n_band, 1 ), 1 )] = add( shr( add( quant_tmp[n_band], quant_tmp[n_band + 1] ), 1 ), quant_tmp2[n_band] );
#endif
move16(); /*Q8 */
}
- SWB_fenv[n_band * 2 + 1] = add( quant_tmp[n_band], quant_tmp2[n_band] );
+ SWB_fenv[add( n_band * 2, 1 )] = add( quant_tmp[n_band], quant_tmp2[n_band] );
move16(); /*Q8 */
}
@@ -942,6 +958,7 @@ Word16 swb_bwe_dec_fx(
Word16 i, l_subfr;
Word16 mode;
Word16 frica_flag = 0;
+ move16();
Word16 idxGain;
Word16 Q_syn, Q_syn_hb;
Word16 ysynth_fx[L_FRAME48k];
@@ -954,9 +971,11 @@ Word16 swb_bwe_dec_fx(
Word32 L_tmp;
Word16 exp, frac;
Word16 fb_ener_adjust_fx = 0;
+ move16();
Word16 SWB_fenv_fx[SWB_FENV];
Word16 L;
Word16 j = 0;
+ move16();
Word16 ener_adjust_quan_fx;
Word16 tmp2;
Word16 fb_band_begin;
@@ -968,6 +987,7 @@ Word16 swb_bwe_dec_fx(
*---------------------------------------------------------------------*/
/* windowing of the ACELP core synthesis */
new_input_fx_exp = *Qpost;
+ move16();
#ifdef ADD_IVAS_BWE
if ( st->element_mode == IVAS_CPE_DFT && !use_cldfb_for_dft )
{
@@ -988,6 +1008,7 @@ Word16 swb_bwe_dec_fx(
ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */
output_frame );
*Qpost = sub( new_input_fx_exp, 15 );
+ move16();
/* DCT of the ACELP core synthesis */
direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode );
}
@@ -1011,13 +1032,11 @@ Word16 swb_bwe_dec_fx(
{
/* estimate parameters */
mode = para_pred_bws_fx( st_fx, ysynth_fx, SWB_fenv_fx, Q_syn );
- move16();
}
ELSE
{
/* de-quantization */
mode = swb_bwe_gain_deq_fx( st_fx, ACELP_CORE, SWB_tenv_fx, SWB_fenv_fx, 0, -1 );
- move16();
}
L = SWB_FENV;
@@ -1031,7 +1050,7 @@ Word16 swb_bwe_dec_fx(
move16();
FOR( i = 0; i < L; i++ )
{
- L_tmp = L_add( L_tmp, (Word32) SWB_fenv_fx[i] );
+ L_tmp = L_add( L_tmp, L_deposit_l( SWB_fenv_fx[i] ) );
}
exp = norm_s( L );
@@ -1039,6 +1058,7 @@ Word16 swb_bwe_dec_fx(
L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(1+29-exp+1-16)->Q(15-exp) */
st_fx->prev_ener_shb_fx = round_fx( L_shl( L_tmp, add( exp, 2 ) ) ); /*Q1 */
+ move16();
}
ELSE
{
@@ -1096,7 +1116,7 @@ Word16 swb_bwe_dec_fx(
idxGain = (Word16) get_next_indice( st_fx, NUM_BITS_FB_FRAMEGAIN );
fb_ener_adjust_fx = usdequant_fx( idxGain, FB_GAIN_QLOW_FX, FB_GAIN_QDELTA_FX ); /*Q15 */
}
- ELSE if ( st_fx->bfi )
+ ELSE IF( st_fx->bfi )
{
fb_ener_adjust_fx = st_fx->prev_fb_ener_adjust_fx;
move16();
@@ -1106,8 +1126,7 @@ Word16 swb_bwe_dec_fx(
move16();
IF( EQ_16( mode, TRANSIENT ) )
{
- ener_adjust_quan_fx = shr( fb_ener_adjust_fx, 2 );
- move16(); /*Q13*/
+ ener_adjust_quan_fx = shr( fb_ener_adjust_fx, 2 ); /*Q13*/
}
ELSE
{
@@ -1116,11 +1135,10 @@ Word16 swb_bwe_dec_fx(
tmp = div_s( 1, SWB_fenv_fx[7] );
move16(); /*Q14*/
#ifdef BASOP_NOGLOB
- ener_adjust_quan_fx = s_min( shr( i_mult_sat( SWB_fenv_fx[13], tmp ), 2 ), 32767 );
+ ener_adjust_quan_fx = s_min( shr( i_mult_sat( SWB_fenv_fx[13], tmp ), 2 ), 32767 ); /*Q13*/
#else
ener_adjust_quan_fx = s_min( shr( i_mult( SWB_fenv_fx[13], tmp ), 2 ), 32767 );
#endif
- move16(); /*Q13*/
}
ELSE
{
@@ -1129,13 +1147,14 @@ Word16 swb_bwe_dec_fx(
}
}
fb_band_begin = FB_BAND_BEGIN;
+ move16();
#ifdef ADD_IVAS_BWE
IF( st_fx->L_frame == L_FRAME )
{
fb_band_begin = FB_BAND_BEGIN_12k8;
}
#endif
- FOR( i = fb_band_begin; i < fb_band_begin + DE_OFFSET1; i++ )
+ FOR( i = fb_band_begin; i < add( fb_band_begin, DE_OFFSET1 ); i++ )
{
tmp = sub( 32767, i_mult( j, 1024 ) );
tmp = mult_r( tmp, ener_adjust_quan_fx ); /*Q13*/
@@ -1192,7 +1211,7 @@ Word16 swb_bwe_dec_fx(
FOR( i = 0; i < l_subfr; i++ )
{
#ifdef BASOP_NOGLOB
- L_tmp = L_mac0_sat( L_tmp, hb_synth_fx[tmp + i], hb_synth_fx[tmp + i] ); /*(2*Q_syn_hb) */
+ L_tmp = L_mac0_sat( L_tmp, hb_synth_fx[add( tmp, i )], hb_synth_fx[add( tmp, i )] ); /*(2*Q_syn_hb) */
#else
L_tmp = L_mac0( L_tmp, hb_synth_fx[tmp + i], hb_synth_fx[tmp + i] ); /*(2*Q_syn_hb) */
#endif
@@ -1211,6 +1230,7 @@ Word16 swb_bwe_dec_fx(
L_tmp = L_deposit_h( tmp );
L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp) */
hBWE_FD->prev_td_energy_fx = round_fx( L_shl( L_tmp, sub( exp, 15 ) ) ); /*Q0 */
+ move16();
}
}
#ifdef ADD_IVAS_BWE
@@ -1271,6 +1291,7 @@ void fd_bwe_dec_init(
st_fx->last_wb_bwe_ener_fx = 0;
move16();
hBWE_FD->prev_Energy_wb_fx = L_deposit_l( 0 );
+ move32();
hBWE_FD->memExp1 = 0;
move16();
@@ -1279,7 +1300,9 @@ void fd_bwe_dec_init(
move16();
hBWE_FD->mem_deemph_old_syn_fx = 0;
+ move16();
st_fx->prev_fb_ener_adjust_fx = 0;
+ move16();
return;
}
diff --git a/lib_dec/swb_bwe_dec_hr.c b/lib_dec/swb_bwe_dec_hr.c
index 5d090e7088ccab3ec7ab946dd07d6e71eed2062c..1332bec6043bf51c1e74dd34ae23bc06ac862875 100644
--- a/lib_dec/swb_bwe_dec_hr.c
+++ b/lib_dec/swb_bwe_dec_hr.c
@@ -41,7 +41,7 @@
#include "rom_com.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif // IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
diff --git a/lib_dec/swb_bwe_dec_hr_fx.c b/lib_dec/swb_bwe_dec_hr_fx.c
index 3276cf9903ab363bdefdbab7b54a111bbdf7a296..2ff8997052470a4cec24577d663fecfcc226d016 100644
--- a/lib_dec/swb_bwe_dec_hr_fx.c
+++ b/lib_dec/swb_bwe_dec_hr_fx.c
@@ -2,12 +2,11 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "rom_com.h" /* Static table prototypes */
-#include "rom_dec.h" /* Static table prototypes */
-#include "cnst.h" /* Static table prototypes */
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com.h" /* Static table prototypes */
+#include "rom_dec.h" /* Static table prototypes */
+#include "cnst.h" /* Static table prototypes */
#define Q_GUARD 1
#define Q_32_BITS 14 /* scaling of 't_audio32' */
@@ -47,27 +46,37 @@ static Word16 Gain_Dequant_HR( /* o: decoded gain (Q13)
IF( EQ_16( min, G_AVQ_MIN_FX ) )
{
L_mini = MAKE_PSEUDO_FLT( 26214, 15 ); /* 0.8 in Q15 */
+ move32();
L_fact = MAKE_PSEUDO_FLT( 14145, 11 ); /* Log2(96) - Log2(0.8) in Q11 */
+ move32();
}
ELSE IF( EQ_16( min, G_AVQ_MIN_DIV10_FX ) )
{
L_mini = MAKE_PSEUDO_FLT( 20972, 18 ); /* 0.8*0.1 in Q18 */
+ move32();
L_fact = MAKE_PSEUDO_FLT( 20949, 11 ); /* Log2(96) - Log2(0.8*0.1) in Q11 */
+ move32();
}
ELSE IF( EQ_16( min, G_CODE_MIN_FX ) )
{
L_mini = MAKE_PSEUDO_FLT( 20972, 20 ); /* 0.02 in Q20 */
+ move32();
L_fact = MAKE_PSEUDO_FLT( 32628, 12 ); /* Log2(5) - Log2(0.02) in Q12 */
+ move32();
}
ELSE IF( EQ_16( min, G_CODE_MIN_TC192_FX ) )
{
L_mini = MAKE_PSEUDO_FLT( 19661, 15 ); /* 0.6 in Q15 */
+ move32();
L_fact = MAKE_PSEUDO_FLT( 24963, 12 ); /* Log2(41) - Log2(0.6) in Q12 */
+ move32();
}
ELSE IF( EQ_16( min, MIN_GLOB_GAIN_BWE_HR_FX ) )
{
L_mini = MAKE_PSEUDO_FLT( 24576, 13 ); /* 3.0 in Q13 */
+ move32();
L_fact = MAKE_PSEUDO_FLT( 30232, 12 ); /* Log2(500) - Log2(3) in Q12 */
+ move32();
}
/* levels = 1<bwe_highrate_seed_fx = extract_l( L_mult0( pitch_buf[0], pitch_buf[3] ) );
+ move16();
/*---------------------------------------------------------------------*
@@ -308,7 +320,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
ind2 = 0;
move16();
L_ener_saved = 0;
- move16();
+ move32();
ener_saved_exp = 0;
move16();
@@ -331,7 +343,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
* calculate tilt of the core synthesis
*---------------------------------------------------------------------*/
L_tilt_wb = calc_tilt_bwe_fx( syn_12k8_16k_fx, exp, L_FRAME16k );
- L_temp = L_mac( 1L, 8192, pitch_buf[0] );
+ L_temp = L_mac( 1, 8192, pitch_buf[0] );
FOR( i = 1; i < NB_SUBFR16k - 1; i++ )
{
L_temp = L_mac( L_temp, 8192, pitch_buf[i] );
@@ -401,9 +413,9 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
temp4 = add( temp4, t_audio_exp );
FOR( i = 0; i < tmpS; i++ )
{
- L_temp = L_mult( alpha, hBWE_FD_HR->t_audio_prev_fx[i + ind1] );
+ L_temp = L_mult( alpha, hBWE_FD_HR->t_audio_prev_fx[add( i, ind1 )] );
L_temp = L_shr( L_temp, temp4 );
- t_audio32[pos + i] = L_temp;
+ t_audio32[add( pos, i )] = L_temp;
move32();
}
ind1 = add( ind1, tmpS );
@@ -457,6 +469,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
hBWE_FD_HR->L_mem_EnergyLT_fx = Mul_flt32_Q15( hBWE_FD_HR->L_mem_EnergyLT_fx, &hBWE_FD_HR->mem_EnergyLT_fx_exp, alpha );
move32();
hBWE_FD_HR->mem_EnergyLT_fx_exp = add( hBWE_FD_HR->mem_EnergyLT_fx_exp, t_audio_exp );
+ move16();
/* Set Exponent */
t_audio_exp = Q_32_BITS;
@@ -557,7 +570,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
temp = shl( ind1, 1 );
en_band[0] = swb_hr_env_code3_fx[temp];
move16();
- en_band[1] = swb_hr_env_code3_fx[add( temp, 1 )];
+ en_band[1] = swb_hr_env_code3_fx[temp + 1];
move16();
/*env = add(shr(en_band[0], 1), shr(en_band[1], 1));*/
@@ -606,9 +619,9 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
/* 't_audio' in Q8 */
t_audio_exp = 8;
move16();
- FOR( i = 0; i < Nsv * WIDTH_BAND; i++ )
+ FOR( i = 0; i < i_mult( Nsv, WIDTH_BAND ); i++ )
{
- t_audio[temp + i] = shl( x_norm[i], t_audio_exp );
+ t_audio[add( temp, i )] = shl( x_norm[i], t_audio_exp );
move16();
}
@@ -623,7 +636,6 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
/* Go from Q't_audio_exp' on 16 Bits to 'Q_32_BITS' on 32 bits */
temp2 = i_mult2( WIDTH_BAND, Nsv );
ptr16 = &t_audio[temp];
- move16();
ptr32 = &t_audio32[temp];
j = shl( 1, sub( Q_32_BITS, t_audio_exp ) );
FOR( i = 0; i < temp2; i++ )
@@ -644,7 +656,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
/* reconstruct 14-16(20) kHz spectrum */
FOR( j = 0; j < tmpS; j++ )
{
- *ptr32++ = L_shr( t_audio32[pos + j], 1 );
+ *ptr32++ = L_shr( t_audio32[add( pos, j )], 1 );
move32();
}
@@ -667,7 +679,6 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
temp2 = add( NUM_TRANS_END_FREQ_COEF_EFF, temp );
j = sub( tmpS, width_noncoded );
ptr16 = &t_audio[add( temp2, j )];
- move16();
ptr32 = &t_audio32[add( temp2, j )];
/* envelope denormalization of 14.4-16(20) kHz spectrum */
FOR( ; j < tmpS; j++ )
@@ -680,15 +691,14 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
temp2 = add( NUM_TRANS_START_FREQ_COEF, temp );
ptr16 = &t_audio[temp2];
- move16();
ptr32 = &t_audio32[temp2];
- temp4 = i_mult2( NSV_OVERLAP, shr( WIDTH_BAND, 2 ) );
+ temp4 = NSV_OVERLAP * ( WIDTH_BAND >> 2 );
/* overlap region */
IF( EQ_16( output_frame, L_FRAME48k ) )
{
FOR( i = 0; i < temp4; i++ )
{
- L_temp = Mult_32_16( *ptr32, overlap_coefs_48kHz_fx[shl( i, 2 )] ); /* overlap_coefs_fx in Q15 */
+ L_temp = Mult_32_16( *ptr32, overlap_coefs_48kHz_fx[i * 4] ); /* overlap_coefs_fx in Q15 */
*ptr32++ = L_temp;
move32();
}
@@ -697,7 +707,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
{
FOR( i = 0; i < temp4; i++ )
{
- L_temp = Mult_32_16( *ptr32, overlap_coefs_fx[shl( i, 2 )] ); /* overlap_coefs_fx in Q15 */
+ L_temp = Mult_32_16( *ptr32, overlap_coefs_fx[i * 4] ); /* overlap_coefs_fx in Q15 */
*ptr32++ = L_temp;
move32();
}
@@ -705,9 +715,8 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
temp2 = add( NUM_TRANS_START_FREQ_COEF, temp );
ptr16 = &t_audio[temp2];
- move16();
ptr32 = &t_audio32[temp2];
- temp4 = add( i_mult2( WIDTH_TRANS_FREQ_COEF, N_BANDS_TRANS_BWE_HR ), width_noncoded );
+ temp4 = add( WIDTH_TRANS_FREQ_COEF * N_BANDS_TRANS_BWE_HR, width_noncoded );
temp3 = sub( 15, exp1 );
/* apply global gain */
FOR( i = 0; i < temp4; i++ )
@@ -720,7 +729,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
/* save transform coefficients for the next frame (needed in case of frame erasures) */
temp = add( NUM_TRANS_START_FREQ_COEF, len );
- IF( output_frame == L_FRAME32k )
+ IF( EQ_16( output_frame, L_FRAME32k ) )
{
pos = L_FRAME32k / NUM_TIME_SWITCHING_BLOCKS - NUM_TRANS_START_FREQ_COEF;
move16();
@@ -728,6 +737,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
ELSE /* output_frame == L_FRAME48k */
{
pos = ( 2 * END_FREQ_BWE_FULL_FB / 50 ) / NUM_TIME_SWITCHING_BLOCKS - NUM_TRANS_START_FREQ_COEF;
+ move16();
}
temp4 = Find_Max_Norm32( t_audio32 + temp, pos );
Copy_Scale_sig32_16( t_audio32 + temp, hBWE_FD_HR->t_audio_prev_fx + i_mult2( k, pos ), pos, temp4 );
@@ -745,7 +755,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
j = ( 2 * END_FREQ_BWE_FULL_FB / 50 ) / NUM_TIME_SWITCHING_BLOCKS - NUM_TRANS_START_FREQ_COEF;
move16();
- if ( output_frame == L_FRAME32k )
+ if ( EQ_16( output_frame, L_FRAME32k ) )
{
j = L_FRAME32k / NUM_TIME_SWITCHING_BLOCKS - NUM_TRANS_START_FREQ_COEF;
move16();
@@ -753,7 +763,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
FOR( i = 0; i < j; i++ )
{
- t_audio[temp + i] = mult_r( t_audio[temp + i], temp2 );
+ t_audio[add( temp, i )] = mult_r( t_audio[add( temp, i )], temp2 );
move16();
}
}
@@ -779,12 +789,12 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
temp = shl( ind1, 1 );
en_band[0] = swb_hr_env_code1_fx[temp];
move16();
- en_band[1] = swb_hr_env_code1_fx[add( temp, 1 )];
+ en_band[1] = swb_hr_env_code1_fx[temp + 1];
move16();
temp = shl( ind2, 1 );
en_band[2] = swb_hr_env_code2_fx[temp];
move16();
- en_band[3] = swb_hr_env_code2_fx[add( temp, 1 )];
+ en_band[3] = swb_hr_env_code2_fx[temp + 1];
move16();
/*env = add(add(shr(en_band[0], 2), shr(en_band[1], 2)), add(shr(en_band[2], 2), shr(en_band[3], 2)));*/
@@ -892,7 +902,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
/* Nsv2 * 12 <= nBits (Nsv2 is not too high) AND */
/* nBits - Nsv2 * 12 < 12 (Nsv2 is the highest divisor) */
L_temp = L_msu0( L_deposit_l( nBits ), 12, Nsv2 );
- if ( GE_32( L_temp, 12L ) )
+ if ( GE_32( L_temp, 12 ) )
Nsv2 = add( Nsv2, 1 );
if ( L_temp < 0 )
Nsv2 = sub( Nsv2, 1 );
@@ -913,7 +923,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
/* set 't_audio' exp */
t_audio_exp = 10;
move16();
- FOR( i = 0; i < Nsv * WIDTH_BAND; i++ )
+ FOR( i = 0; i < i_mult( Nsv, WIDTH_BAND ); i++ )
{
#ifdef BASOP_NOGLOB
t_audio_tmp[i] = shl_sat( x_norm[i], t_audio_exp );
@@ -944,7 +954,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
{
L_temp = L_mult( gain2_fx, *ptr16++ );
L_temp = L_shr( L_temp, temp2 ); /* go to Q't_audio' */
- t_audio_tmp[temp + j] = round_fx( L_temp );
+ t_audio_tmp[add( temp, j )] = round_fx( L_temp );
}
/* 'nq[i] = add(nq[i], nq2[incr])' replaced by 'nq[i] = nq2[incr]' because 'nq[i] == 0' */
nq[i] = nq2[incr];
@@ -968,9 +978,9 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
FOR( j = 0; j < WIDTH_BAND; j++ )
{
L_temp = L_mult( gain2_fx, *ptr16++ );
- L_temp = L_msu( L_temp, t_audio_tmp[temp + j], temp3 ); /* go to -Q't_audio' */
- L_temp = L_shr( L_temp, temp2 ); /* go to Q't_audio' */
- t_audio_tmp[temp + j] = round_fx( L_temp );
+ L_temp = L_msu( L_temp, t_audio_tmp[add( temp, j )], temp3 ); /* go to -Q't_audio' */
+ L_temp = L_shr( L_temp, temp2 ); /* go to Q't_audio' */
+ t_audio_tmp[add( temp, j )] = round_fx( L_temp );
}
nq[i] = add( nq[i], nq2[incr] );
move16();
@@ -989,6 +999,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
Copy( t_audio_tmp, ptr16, NUM_NONTRANS_END_FREQ_COEF - NUM_NONTRANS_START_FREQ_COEF );
/* Update Maximum Written Location (from t_audio + NUM_NONTRANS_START_FREQ_COEF) */
temp4 = NUM_NONTRANS_END_FREQ_COEF - NUM_NONTRANS_START_FREQ_COEF;
+ move16();
}
ELSE
{
@@ -997,12 +1008,14 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
/* Update Maximum Written Location (from t_audio + NUM_NONTRANS_START_FREQ_COEF) */
temp4 = ind1;
+ move16();
temp = add( pos, 1 );
ind2 = add( shl( temp, 6 ), i_mult2( shr( temp, 1 ), WIDTH_BAND ) );
- Copy( t_audio_tmp + ind1, ptr16 + ind2, NUM_NONTRANS_END_FREQ_COEF - NUM_NONTRANS_START_FREQ_COEF - ind2 );
+ Copy( t_audio_tmp + ind1, ptr16 + ind2, sub( NUM_NONTRANS_END_FREQ_COEF - NUM_NONTRANS_START_FREQ_COEF, ind2 ) );
/* Update Maximum Written Location (from t_audio + NUM_NONTRANS_START_FREQ_COEF) */
temp4 = s_max( temp4, NUM_NONTRANS_END_FREQ_COEF - NUM_NONTRANS_START_FREQ_COEF );
+ move16();
/* reconstruct non-encoded subband */
IF( EQ_16( pos, 3 ) )
@@ -1030,7 +1043,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
{
nq[j] = nq[i];
move16();
- j = sub( j, 1 );
+ j = j - 1;
}
Copy( nq + ind2, nq + ind1, add( WIDTH_BAND, pos ) );
@@ -1069,14 +1082,14 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
IF( EQ_16( pos, 3 ) && LE_16( nBits_total, 400 ) )
{
ptr16 = &t_audio[NUM_NONTRANS_START_FREQ_COEF + 200 - WIDTH_BAND];
- L_temp = L_mac0( 1L /* EPSILON */, *ptr16, *ptr16 );
+ L_temp = L_mac0( 1 /* EPSILON */, *ptr16, *ptr16 );
FOR( i = 1; i < WIDTH_BAND; i++ )
{
ptr16++;
L_temp = L_mac0( L_temp, *ptr16, *ptr16 );
}
ptr16++;
- L_temp2 = L_mac0( 1L /* EPSILON */, *ptr16, *ptr16 );
+ L_temp2 = L_mac0( 1 /* EPSILON */, *ptr16, *ptr16 );
FOR( i = 1; i < WIDTH_BAND; i++ )
{
ptr16++;
@@ -1088,7 +1101,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
temp2 = s_min( 0, temp );
L_temp = L_shl( L_temp, temp2 );
/* Energy_flt - i*(Energy_flt-1.0)/8.0 */
- L_temp2 = L_add( L_temp, L_shr( -2147483647L - 1L, s_max( 0, temp ) ) ); /* 1.0 in same Q as Sqrt minus the Guard */
+ L_temp2 = L_add( L_temp, L_shr( -2147483647 - 1, s_max( 0, temp ) ) ); /* 1.0 in same Q as Sqrt minus the Guard */
/* / 8.0 */
L_temp2 = L_shr( L_temp2, 3 + Q_GUARD );
/* Add Guard */
@@ -1112,22 +1125,22 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
width_noncoded = 2 * END_FREQ_BWE_FULL_FB / 50 - NUM_NONTRANS_END_FREQ_COEF;
move16(); /* st->extl == FB_BWE_HIGHRATE */
test();
- if ( EQ_16( st_fx->extl, SWB_BWE_HIGHRATE ) || EQ_16( output_frame, L_FRAME32k ) )
+ IF( EQ_16( st_fx->extl, SWB_BWE_HIGHRATE ) || EQ_16( output_frame, L_FRAME32k ) )
{
width_noncoded = L_FRAME32k - NUM_NONTRANS_END_FREQ_COEF;
move16();
}
ptr16 = &t_audio[NUM_NONTRANS_END_FREQ_COEF - WIDTH_BAND];
- L_temp = L_mac0( 1L /* EPSILON */, *ptr16, *ptr16 );
+ L_temp = L_mac0( 1 /* EPSILON */, *ptr16, *ptr16 );
FOR( i = 1; i < WIDTH_BAND; i++ )
{
ptr16++;
L_temp = L_mac0( L_temp, *ptr16, *ptr16 );
}
- ptr16 = &t_audio[sub( NUM_NONTRANS_END_FREQ_COEF, width_noncoded )];
- L_temp2 = L_mac0( 1L /* EPSILON */, *ptr16, *ptr16 );
+ ptr16 = &t_audio[NUM_NONTRANS_END_FREQ_COEF - width_noncoded];
+ L_temp2 = L_mac0( 1 /* EPSILON */, *ptr16, *ptr16 );
FOR( i = 1; i < WIDTH_BAND; i++ )
{
ptr16++;
@@ -1143,7 +1156,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
t_audio32 + NUM_NONTRANS_END_FREQ_COEF + WIDTH_BAND, sub( width_noncoded, WIDTH_BAND ) );
/* smoothing 14.4-14.8kHz */
- ptr16 = &t_audio[sub( NUM_NONTRANS_END_FREQ_COEF, width_noncoded )];
+ ptr16 = &t_audio[NUM_NONTRANS_END_FREQ_COEF - width_noncoded];
ptr32 = &t_audio32[NUM_NONTRANS_END_FREQ_COEF];
temp = sub( temp, add( t_audio_exp, 16 - Q_32_BITS ) );
FOR( i = 0; i < WIDTH_BAND; i++ )
@@ -1186,7 +1199,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
/* in L_temp/L_temp2, value in Q16+9 */
FOR( j = 0; j < WIDTH_BAND; j++ )
{
- *ptr32 = L_shl( Mult_32_16( *ptr32, round_fx( L_temp ) ), 15 - 9 );
+ *ptr32 = L_shl( Mult_32_16( *ptr32, round_fx( L_temp ) ), ( 15 - 9 ) );
move32();
ptr32++;
L_temp = L_sub( L_temp, L_temp2 );
@@ -1216,7 +1229,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
FOR( j = 0; j < tmpS; j++ )
{
/* t_audio[NUM_NONTRANS_END_FREQ_COEF + j] *= 2.2f * en_noncoded * (1-(float)k/(float)160); */
- *ptr32 = L_shl( Mult_32_16( *ptr32, round_fx( L_temp ) ), 31 - 23 );
+ *ptr32 = L_shl( Mult_32_16( *ptr32, round_fx( L_temp ) ), ( 31 - 23 ) );
move32();
ptr32++;
L_temp = L_sub( L_temp, L_temp2 );
@@ -1227,7 +1240,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
FOR( ; j < width_noncoded; j++ )
{
/* t_audio[NUM_NONTRANS_END_FREQ_COEF + j] *= 0.65f * en_noncoded * (1-(float)k/(float)320); */
- *ptr32 = L_shl( Mult_32_16( *ptr32, round_fx( L_temp ) ), 31 - 25 );
+ *ptr32 = L_shl( Mult_32_16( *ptr32, round_fx( L_temp ) ), ( 31 - 25 ) );
move32();
ptr32++;
L_temp = L_sub( L_temp, L_temp2 );
@@ -1279,13 +1292,15 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
/* Save transform coefficients for the next frame (needed in case of frame erasures) */
temp = NUM_NONTRANS_START_FREQ_COEF;
move16(); /* not necessary but improves readability and allows a larger common code path */
- IF( output_frame == L_FRAME32k )
+ IF( EQ_16( output_frame, L_FRAME32k ) )
{
pos = L_FRAME32k - NUM_NONTRANS_START_FREQ_COEF;
+ move16();
}
ELSE /* output_frame == L_FRAME48k */
{
pos = 2 * END_FREQ_BWE_FULL_FB / 50 - NUM_NONTRANS_START_FREQ_COEF;
+ move16();
}
temp4 = Find_Max_Norm32( t_audio32 + temp, pos );
Copy_Scale_sig32_16( t_audio32 + temp, hBWE_FD_HR->t_audio_prev_fx, pos, temp4 );
@@ -1299,7 +1314,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
j = 2 * END_FREQ_BWE_FULL_FB / 50 - NUM_NONTRANS_START_FREQ_COEF;
move16();
- if ( output_frame == L_FRAME32k )
+ if ( EQ_16( output_frame, L_FRAME32k ) )
{
j = L_FRAME32k - NUM_NONTRANS_START_FREQ_COEF;
move16();
@@ -1317,10 +1332,12 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
IF( gain_fx < 0 )
{
st_fx->prev_ener_shb_fx = extract_h( L_shr( L_mult0( 32767, env ), 7 ) );
+ move16();
}
ELSE
{
st_fx->prev_ener_shb_fx = extract_h( L_shr( L_mult0( gain_fx, env ), 7 ) );
+ move16();
}
FOR( i = 0; i < SWB_FENV; i++ )
{
@@ -1333,6 +1350,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
*---------------------------------------------------------------------*/
t_audio_exp = Q_32_BITS;
+ move16();
Inverse_Transform( t_audio32, &t_audio_exp, t_audio32_tmp, is_transient, output_frame, output_frame, st_fx->element_mode );
window_ola_fx( t_audio32_tmp, hb_synth_fx, &t_audio_exp, hBWE_FD->L_old_wtda_swb_fx, &st_fx->hHQ_core->Q_old_wtda, output_frame, ALDO_WINDOW, ALDO_WINDOW, 0, 0, 0 );
@@ -1354,7 +1372,6 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
move16();
ptr16 = hb_synth_fx;
- move16();
len = shr( output_frame, 2 ); /* Divide Frame Len by 4, all (160, 320, 640, 960) are divisible by 4 */
L_ener_all = L_deposit_l( 0 );
@@ -1365,7 +1382,6 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
{
L_Energy = Calc_Energy_Autoscaled( ptr16, hb_synth_fx_exp, len, &temp2 );
ptr16 += len;
- move16();
/* Normalize Energy */
temp = norm_l( L_Energy );
L_Energy = L_shl( L_Energy, temp );
@@ -1414,11 +1430,12 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
test();
test();
test();
- IF( IsTransient != 0 && pos > 0 && LT_32( L_tilt_wb, 16777216L * 3 /*tilt_wb in Q24*/ ) && GT_16( pitch, 500 * 16 /*Q4*/ ) )
+ IF( IsTransient != 0 && pos > 0 && LT_32( L_tilt_wb, 50331648 /* (16777216L * 3) */ /*tilt_wb in Q24*/ ) && GT_16( pitch, ( 500 * 16 ) /*Q4*/ ) )
{
Nsv = i_mult2( pos, shr( output_frame, 2 ) );
gain_fx = 16384; /* sqrt(1.0) in Q14 */
+ move16();
/* pos is 1,2 or 3 */
temp3 = sub( pos, 2 );
if ( temp3 == 0 )
@@ -1456,7 +1473,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
* +1: Because of L_mult'0'
* and the normalization
*/
- exp2 = add( exp1, +16 - 16 - 15 + 1 );
+ exp2 = add( exp1, 16 - 16 - 15 + 1 );
temp = norm_l( L_temp );
L_temp = L_shl( L_temp, temp );
exp2 = add( exp2, temp );
@@ -1466,6 +1483,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
L_temp2 = L_mult( temp, hb_synth_fx[i] );
L_temp2 = L_shr( L_temp2, exp2 );
hb_synth_fx[i] = round_fx( L_temp2 );
+ move16();
}
len = shr( output_frame, 3 ); /* all frame length are divisible by 8 */
@@ -1484,7 +1502,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
/* Put to Q30 */
L_temp2 = L_shr( L_temp2, exp2 );
/* 1/frame_len in Q30 */
- L_temp2 = L_msu( L_temp2, swb_hr_inv_frm_len[temp], 32768L >> ( 19 - 15 + 1 ) ); /* 19-15+1 to Bring to Q30 */
+ L_temp2 = L_msu( L_temp2, swb_hr_inv_frm_len[temp], 1024 /*(32768L >> ( 19 - 15 + 1 )*/ ); /* 19-15+1 to Bring to Q30 */
FOR( i = 0; i < len; i++ )
{
/* hb_synth[i+Nsv] *= (gain_flt - i*8.0f*(1.0f/output_frame*gain_flt - 1.0f/output_frame)) */
@@ -1506,7 +1524,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB
test();
IF( EQ_16( st_fx->last_core, HQ_CORE ) || NE_16( st_fx->last_extl, st_fx->extl ) )
{
- IF( LT_32( L_tilt_wb, 16777216L * 3 /*tilt_wb in Q24*/ ) )
+ IF( LT_32( L_tilt_wb, 50331648 /* (16777216L * 3) */ /*tilt_wb in Q24*/ ) )
{
temp = TD_Postprocess( hb_synth_fx, hb_synth_fx_exp, output_frame, st_fx->last_extl );
@@ -1553,6 +1571,7 @@ void hr_bwe_dec_init(
move16();
hBWE_FD_HR->L_mem_EnergyLT_fx = L_deposit_h( 16384 );
+ move32();
hBWE_FD_HR->mem_EnergyLT_fx_exp = 40;
move16(); /* set to a high exponent */
diff --git a/lib_dec/swb_bwe_dec_lr_fx.c b/lib_dec/swb_bwe_dec_lr_fx.c
index 689029be428b52115b0c22008e885a614a6403f5..485bbe6e2fafcd742a6315fd1bbf9d02765dd507 100644
--- a/lib_dec/swb_bwe_dec_lr_fx.c
+++ b/lib_dec/swb_bwe_dec_lr_fx.c
@@ -4,8 +4,7 @@
#include "options.h"
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
/*-------------------------------------------------------------------*
@@ -30,14 +29,14 @@ static void DecodeSWBGenericParameters_fx(
{
IF( EQ_16( hq_swb_clas_fx, HQ_HARMONIC ) )
{
- lagIndices_fx[sb] = get_next_indice( st_fx, bits_lagIndices_mode0_Har[sb] );
+ lagIndices_fx[sb] = (Word16) get_next_indice( st_fx, bits_lagIndices_mode0_Har[sb] );
move16();
}
ELSE
{
- IF( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + sb] == 0 )
+ IF( p2a_flags_fx[add( sub( BANDS_fx, NB_SWB_SUBBANDS ), sb )] == 0 )
{
- lagIndices_fx[sb] = get_next_indice( st_fx, bits_lagIndices_modeNormal[sb] );
+ lagIndices_fx[sb] = (Word16) get_next_indice( st_fx, bits_lagIndices_modeNormal[sb] );
move16();
}
ELSE
@@ -144,8 +143,7 @@ static void DecodeSWBSubbands_fx(
/* Generate HF noise */
genhf_noise_fx( sspectra_diff_fx, Qss, L_xSynth_har, QsL, sspectra_fx, BANDS_fx, har_bands_fx, har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx, fLenLow_fx, fLenHigh_fx, sbWidth_fx, lagIndices_fx, subband_offsets_fx, subband_search_offset_fx );
- imin_fx = get_next_indice( st_fx, 2 );
- move16();
+ imin_fx = (Word16) get_next_indice( st_fx, 2 );
/* g= pow(10.0f, gain_table_SWB_BWE[imin]) */
L_temp = L_mult( gain_table_SWB_BWE_fx[imin_fx], 27213 ); /* Q14+Q13+1=Q28 log(10)/log(2)=3.3219 27213.23(Q13) */
L_temp = L_shr( L_temp, 12 ); /* Q28-Q12 -> Q16 */
@@ -180,12 +178,12 @@ static void DecodeSWBSubbands_fx(
{
FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ )
{
- L_spectra[i] = L_xSynth_har[i - fLenLow_fx];
+ L_spectra[i] = L_xSynth_har[sub( i, fLenLow_fx )];
move32(); /* QsL */
}
}
}
- ELSE IF( EQ_16( hqswb_clas_fx, HQ_NORMAL ) )
+ ELSE IF( hqswb_clas_fx == HQ_NORMAL )
{
ss_min_fx = spectrumsmooth_noiseton_fx(
L_spectra, /*QsL,*/ L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, &Qss, fLenLow_fx, ni_seed_fx );
@@ -193,7 +191,7 @@ static void DecodeSWBSubbands_fx(
convert_lagIndices_pls2smp_fx( lagIndices_fx, nBands_fx, lagIndices_real_fx, sspectra_fx, sbWidth_fx, fLenLow_fx );
FOR( k = 0; k < nBands_fx; k++ )
{
- if ( EQ_16( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k], 1 ) )
+ if ( EQ_16( p2a_flags_fx[add( BANDS_fx - NB_SWB_SUBBANDS, k )], 1 ) )
{
lagIndices_real_fx[k] = 0;
move16();
@@ -201,12 +199,12 @@ static void DecodeSWBSubbands_fx(
}
GetlagGains_fx( sspectra_ni_fx, Qss,
- &L_band_energy[BANDS_fx - NB_SWB_SUBBANDS], Qbe,
+ &L_band_energy[sub( BANDS_fx, NB_SWB_SUBBANDS )], Qbe,
nBands_fx, sbWidth_fx, lagIndices_real_fx, fLenLow_fx, lagGains_fx, QlagGains );
FOR( k = 0; k < nBands_fx; k++ )
{
- IF( EQ_16( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k], 1 ) )
+ IF( EQ_16( p2a_flags_fx[add( BANDS_fx - NB_SWB_SUBBANDS, k )], 1 ) )
{
lagGains_fx[k] = 0;
move16();
@@ -216,15 +214,18 @@ static void DecodeSWBSubbands_fx(
ELSE
{
lagGains_fx[k] = mult_r( lagGains_fx[k], 29491 ); /* lagGains[k]*0.9f; */
+ move16();
}
}
FOR( k = 0; k < NB_SWB_SUBBANDS; k++ )
{
- L_th_g[k] = L_deposit_l( 0 );
- IF( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k] == 0 )
+ L_th_g[k] = 0;
+ move32();
+ IF( p2a_flags_fx[add( BANDS_fx - NB_SWB_SUBBANDS, k )] == 0 )
{
L_th_g[k] = L_shl( L_mult( lagGains_fx[k], ss_min_fx ), sub( QsL, add( add( QlagGains[k], Qss ), 1 ) ) ); /* QlagGain+Qss -> Qs */
+ move32();
}
}
@@ -242,7 +243,7 @@ static void DecodeSWBSubbands_fx(
{
FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ )
{
- L_spectra[i] = L_xSynth_har[i - fLenLow_fx];
+ L_spectra[i] = L_xSynth_har[sub( i, fLenLow_fx )];
move32(); /* QsL */
}
}
@@ -313,7 +314,7 @@ void swb_bwe_dec_lr_fx(
DecodeSWBGenericParameters_fx( st_fx, lagIndices_fx, nBands_search_fx, BANDS_fx, p2a_flags_fx, hqswb_clas_fx );
/* Copy WB synthesis for SWB decoding */
- Copy32( L_m_core, L_m, swb_lowband_fx + swb_highband_fx );
+ Copy32( L_m_core, L_m, add( swb_lowband_fx, swb_highband_fx ) );
/* Generic subband processing */
DecodeSWBSubbands_fx( st_fx, st_fx->hHQ_core, L_m, QsL, swb_lowband_fx, swb_highband_fx, nBands_fx, wBands_fx, subband_offsets_fx,
@@ -321,7 +322,7 @@ void swb_bwe_dec_lr_fx(
L_band_energy, Qbe, p2a_flags_fx, hqswb_clas_fx, har_bands_fx, subband_search_offset_fx,
prev_frm_hfe2, prev_stab_hfe2, band_width_fx, L_y2_ni, ni_seed_fx );
- p_L_m = &L_m[sub( allband_fx, 1 )];
+ p_L_m = &L_m[allband_fx - 1];
*p_L_m = Mult_32_16( *p_L_m, 2028 );
move32();
p_L_m--; /* 0.0625 = 2028 (Q15) */
@@ -339,6 +340,7 @@ void swb_bwe_dec_lr_fx(
FOR( k = 0; k < swb_lowband_fx; k++ )
{
L_m[k] = L_deposit_l( 0 );
+ move32();
}
return;
diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c
index 70c57bff2a11eb747ee1c10f9cd267390818f1c1..bf05a9b2bc58da6c5f0c0b5c1ff3a42088d82b56 100644
--- a/lib_dec/swb_tbe_dec.c
+++ b/lib_dec/swb_tbe_dec.c
@@ -39,8 +39,7 @@
#include
#include "cnst.h"
#include "prot.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "rom_dec.h"
#include "wmc_auto.h"
@@ -338,6 +337,15 @@ void wb_tbe_dec(
prev_pow = sum2_f( shaped_wb_excitation, L_SHB_LAHEAD / 4 );
curr_pow = sum2_f( shaped_wb_excitation + L_SHB_LAHEAD / 4, L_SHB_LAHEAD / 4 );
+#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE
+ if ( st->element_mode > EVS_MONO )
+ {
+ /* prevent too low values of energy */
+ prev_pow = max( 0.00001f, prev_pow );
+ curr_pow = max( 0.00001f, curr_pow );
+ }
+#endif
+
if ( voice_factors[0] > 0.75f )
{
curr_pow *= 0.25;
@@ -468,54 +476,72 @@ static void calc_tilt_bwe_fx_loc(
Word64 r0_fx, r1_fx;
r0_fx = EPSILON_FX_SMALL;
+ move64();
FOR( i = 0; i < N; i++ )
{
- r0_fx += ( (Word64) sp_fx[i] ) * ( sp_fx[i] );
+ r0_fx = W_add( r0_fx, W_shr( W_mult_32_32( sp_fx[i], sp_fx[i] ), 1 ) );
}
- r1_fx = abs( sp_fx[1] - sp_fx[0] );
+ r1_fx = W_deposit32_l( abs( L_sub( sp_fx[1], sp_fx[0] ) ) );
FOR( i = 2; i < N; i++ )
{
- IF( ( (Word64) ( sp_fx[i] - sp_fx[i - 1] ) ) * ( sp_fx[i - 1] - sp_fx[i - 2] ) < 0 )
+ IF( W_mult_32_32( L_sub( sp_fx[i], sp_fx[i - 1] ), L_sub( sp_fx[i - 1], sp_fx[i - 2] ) ) < 0 )
{
- r1_fx += abs( sp_fx[i] - sp_fx[i - 1] );
+ r1_fx = W_add( r1_fx, W_deposit32_l( abs( L_sub( sp_fx[i], sp_fx[i - 1] ) ) ) );
}
}
Word16 headroom_left_r0 = W_norm( r0_fx );
Word16 headroom_left_r1 = W_norm( r1_fx );
Word16 r0_q = 0, r1_q = 0;
+ move16();
+ move16();
// Word16 r0_bits_occ = 0, r1_bits_occ = 0;
- IF( headroom_left_r0 < 32 )
+ IF( LT_16( headroom_left_r0, 32 ) )
{
- r0_fx = W_shr( r0_fx, ( 32 - headroom_left_r0 ) );
- r0_q = ( 31 - ( ( 2 * OUTPUT_Q ) - ( 32 - headroom_left_r0 ) ) );
+ r0_fx = W_shr( r0_fx, sub( 32, headroom_left_r0 ) );
+ r0_q = sub( 31, sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_r0 ) ) );
}
ELSE
{
r0_q = 31 - ( 2 * OUTPUT_Q );
+ move16();
}
- IF( headroom_left_r1 < 32 )
+ IF( LT_16( headroom_left_r1, 32 ) )
{
- r1_fx = W_shr( r1_fx, ( 32 - headroom_left_r1 ) );
- r1_q = ( OUTPUT_Q - ( 32 - headroom_left_r1 ) );
+ r1_fx = W_shr( r1_fx, sub( 32, headroom_left_r1 ) );
+ r1_q = sub( OUTPUT_Q, sub( 32, headroom_left_r1 ) );
}
ELSE
{
r1_q = OUTPUT_Q;
+ move16();
+ }
+ Word32 temp_r0_inv = ISqrt32( W_extract_l( r0_fx ), &r0_q );
+ Word32 res = Mpy_32_32( W_extract_l( r1_fx ), temp_r0_inv );
+ // Word16 res_q = r1_q + ( r0_q < 0 ? ( 31 + ( -1 * r0_q ) ) : r0_q ) - 31;
+ Word16 res_q;
+ IF( r0_q < 0 )
+ {
+ res_q = add( r1_q, sub( add( 31, -r0_q ), 31 ) );
+ }
+ ELSE
+ {
+ res_q = add( r1_q, sub( r0_q, 31 ) );
}
- Word32 temp_r0_inv = ISqrt32( (Word32) r0_fx, &r0_q );
- Word32 res = Mpy_32_32( (Word32) r1_fx, temp_r0_inv );
- Word16 res_q = r1_q + ( r0_q < 0 ? ( 31 + ( -1 * r0_q ) ) : r0_q ) - 31;
Word16 norm_res = norm_l( res );
IF( norm_res > 0 )
{
*tilt_fx = L_shl_sat( res, norm_res );
- *tilt_fx_q = res_q + norm_res;
+ move32();
+ *tilt_fx_q = add( res_q, norm_res );
+ move16();
}
ELSE
{
*tilt_fx = res;
+ move32();
*tilt_fx_q = res_q;
+ move16();
}
return;
}
@@ -561,7 +587,7 @@ static void rescale_genSHB_mem_dec(
}
}
- IF( EQ_16( st_fx->extl, FB_TBE ) )
+ if ( EQ_16( st_fx->extl, FB_TBE ) )
{
}
hBWE_TD->mem_csfilt_fx[0] = L_shl( hBWE_TD->mem_csfilt_fx[0], sf );
@@ -619,7 +645,7 @@ static void gradientGainShape(
/* get the first gainshape template */
test();
test();
- IF( ( st_fx->prev_coder_type == UNVOICED || st_fx->last_good == UNVOICED_CLAS ) && GainGradFEC[0] > 0 )
+ IF( ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) ) && ( GainGradFEC[0] > 0 ) )
{
GainShapeTemp[0] = add( shr( st_fx->GainShape_Delay[7], 1 ), GainGradFEC[0] );
move16();
@@ -641,7 +667,7 @@ static void gradientGainShape(
tmp = mult_r( tmp, 26214 ); /* 0.8 in Q15 tmp*(8/10) */
test();
- IF( ( GT_16( tmp, GainGrad1[1] ) ) && GainGrad1[1] > 0 )
+ IF( ( GT_16( tmp, GainGrad1[1] ) ) && ( GainGrad1[1] > 0 ) )
{
FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ )
{
@@ -654,7 +680,7 @@ static void gradientGainShape(
ELSE
{
test();
- IF( ( GT_16( tmp, GainGrad1[1] ) ) && GainGrad1[1] < 0 )
+ IF( ( GT_16( tmp, GainGrad1[1] ) ) && ( GainGrad1[1] < 0 ) )
{
FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ )
{
@@ -680,7 +706,7 @@ static void gradientGainShape(
test();
test();
test();
- IF( ( st_fx->prev_coder_type == UNVOICED || st_fx->last_good == UNVOICED_CLAS ) && st_fx->nbLostCmpt == 1 )
+ IF( ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) ) && EQ_16( st_fx->nbLostCmpt, 1 ) )
{
FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ )
{
@@ -690,19 +716,20 @@ static void gradientGainShape(
IF( GT_16( 8192, tmp ) )
{
- GainShape_fx[i * 4 + j] = shl( tmp, 2 );
+ GainShape_fx[add( i * 4, j )] = shl( tmp, 2 );
move16(); /* (GainShapeTemp[i]*0.6)>>1 */
}
ELSE
{
- GainShape_fx[i * 4 + j] = 32767;
+ GainShape_fx[add( i * 4, j )] = 32767;
move16(); /* Clipping here to avoid the a huge change of the code due to gain shape change */
}
}
}
hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 31129 );
+ move16();
}
- ELSE IF( st_fx->prev_coder_type == UNVOICED || st_fx->last_good == UNVOICED_CLAS )
+ ELSE IF( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) )
{
FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ )
{
@@ -710,29 +737,31 @@ static void gradientGainShape(
{
IF( LT_16( GainShapeTemp[i], 16384 ) )
{
- GainShape_fx[i * 4 + j] = shl( GainShapeTemp[i], 1 );
+ GainShape_fx[add( i * 4, j )] = shl( GainShapeTemp[i], 1 );
move16();
}
ELSE
{
- GainShape_fx[i * 4 + j] = 32767;
+ GainShape_fx[add( i * 4, j )] = 32767;
move16();
}
}
}
hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 31129 );
+ move16();
}
- ELSE IF( st_fx->nbLostCmpt > 1 )
+ ELSE IF( GT_16( st_fx->nbLostCmpt, 1 ) )
{
FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ )
{
FOR( j = 0; j < 4; j++ )
{
- GainShape_fx[i * 4 + j] = GainShapeTemp[i];
+ GainShape_fx[add( i * 4, j )] = GainShapeTemp[i];
move16();
}
}
hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 16384 );
+ move16();
}
ELSE
{
@@ -742,20 +771,22 @@ static void gradientGainShape(
{
IF( LT_16( GainShapeTemp[i], 16384 ) )
{
- GainShape_fx[i * 4 + j] = shl( GainShapeTemp[i], 1 );
+ GainShape_fx[add( i * 4, j )] = shl( GainShapeTemp[i], 1 );
move16();
}
ELSE
{
- GainShape_fx[i * 4 + j] = 32767;
+ GainShape_fx[add( i * 4, j )] = 32767;
move16();
}
}
}
hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 27852 );
+ move16();
}
*GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, hBWE_TD->GainAttn_fx ); /* Q18 */
+ move32();
}
static void find_max_mem_dec(
@@ -767,8 +798,11 @@ static void find_max_mem_dec(
Word16 i;
Word16 n_mem_32;
Word16 max = 0;
+ move16();
Word32 Lmax = 0;
+ move32();
Word16 tempQ15, max2 = 0;
+ move16();
Word16 max3;
Word32 tempQ32, Lmax3;
TD_BWE_DEC_HANDLE hBWE_TD;
@@ -813,9 +847,14 @@ static void find_max_mem_dec(
/* for total_brate > 16.4kbps, use n_mem2; else account for the max2 for n_mem calculation */
*n_mem2 = norm_s( max2 );
- IF( max2 == 0 ) *n_mem2 = 15;
+ move16();
+ if ( max2 == 0 )
+ {
+ *n_mem2 = 15;
+ move16();
+ }
- IF( LT_32( st_fx->total_brate, ACELP_24k40 ) )
+ if ( LT_32( st_fx->total_brate, ACELP_24k40 ) )
{
max = s_max( max, max2 );
}
@@ -840,22 +879,26 @@ static void find_max_mem_dec(
}
/* estimate the norm for 16-bit memories */
*n_mem = norm_s( max );
- IF( max == 0 )
+ move16();
+ if ( max == 0 )
{
*n_mem = 15;
+ move16();
}
/* estimate the norm for 32-bit memories */
Lmax = L_abs( hBWE_TD->mem_csfilt_fx[0] ); /* only element [0] is used in env. shaping */
n_mem_32 = norm_l( Lmax );
- IF( Lmax == 0 )
+ if ( Lmax == 0 )
{
n_mem_32 = 31;
+ move16();
}
tempQ15 = sub( s_min( *n_mem, n_mem_32 ), 1 );
*n_mem = s_max( tempQ15, 0 );
+ move16();
/* --------------------------------------------------------------*/
/* Find headroom for synthesis stage associated with these memories:
@@ -863,6 +906,7 @@ static void find_max_mem_dec(
2. st_fx->genSHBsynth_state_lsyn_filt_shb_local
3. st_fx->genSHBsynth_Hilbert_Mem_fx (32-bit) */
max3 = 0;
+ move16();
/* find max in prev overlapSyn */
FOR( i = 0; i < L_SHB_LAHEAD; i++ )
{
@@ -894,9 +938,15 @@ static void find_max_mem_dec(
}
/* estimate the norm for 16-bit memories */
*n_mem3 = norm_s( max3 );
- IF( max3 == 0 ) *n_mem3 = 15;
+ move16();
+ if ( max3 == 0 )
+ {
+ *n_mem3 = 15;
+ move16();
+ }
Lmax3 = 0;
+ move32();
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
/* find max in prev genSHBsynth_Hilbert_Mem_fx */
@@ -909,12 +959,16 @@ static void find_max_mem_dec(
/* estimate the norm for 32-bit memories */
n_mem_32 = norm_l( Lmax3 );
- IF( Lmax3 == 0 )
- n_mem_32 = 31;
+ if ( Lmax3 == 0 )
+ {
+ n_mem_32 = 31;
+ move16();
+ }
tempQ15 = sub( s_min( *n_mem3, n_mem_32 ), 2 ); /* very important leave at least 2 bit head room
because of the Hilber transform and Q14 coeffs */
*n_mem3 = s_max( tempQ15, 0 );
+ move16();
/* --------------------------------------------------------------*/
}
#endif // IVAS_FLOAT_FIXED
@@ -935,6 +989,7 @@ void find_max_mem_dec_m3(
/* Find headroom for synthesis stage associated with these memories:
1. st->syn_overlap_fx*/
max3 = 0;
+ move16();
/* find max in prev overlapSyn */
FOR( i = 0; i < L_SHB_LAHEAD; i++ )
{
@@ -966,7 +1021,12 @@ void find_max_mem_dec_m3(
// }
/* estimate the norm for 16-bit memories */
*n_mem3 = norm_s( max3 );
- IF( max3 == 0 ) *n_mem3 = 15;
+ move16();
+ if ( max3 == 0 )
+ {
+ *n_mem3 = 15;
+ move16();
+ }
// Lmax3 = 0;
// IF(EQ_16(st->L_frame, L_FRAME))
@@ -1080,7 +1140,7 @@ void ivas_swb_tbe_dec_fx(
shb_ener_sf_32 = 0;
move32();
set16_fx( shaped_shb_excitationTemp_fx, 0, L_FRAME16k );
- IF( st->hTdCngDec != NULL )
+ if ( st->hTdCngDec != NULL )
{
st->hTdCngDec->shb_dtx_count = 0;
move16();
@@ -1105,16 +1165,19 @@ void ivas_swb_tbe_dec_fx(
/* find tilt */
calc_tilt_bwe_fx_loc( old_syn_12k8_16k_fx, &tilt_swb_fec_32_fx, &tilt_swb_fec_fx_q, L_FRAME );
- tilt_swb_fec_fx = extract_l( L_shr( tilt_swb_fec_32_fx, ( tilt_swb_fec_fx_q - 11 ) ) );
+ tilt_swb_fec_fx = extract_l( L_shr( tilt_swb_fec_32_fx, sub( tilt_swb_fec_fx_q, 11 ) ) );
- IF( st->bfi && st->clas_dec != UNVOICED_CLAS )
+ test();
+ if ( st->bfi && st->clas_dec != UNVOICED_CLAS )
{
tilt_swb_fec_fx = hBWE_TD->tilt_swb_fec_fx;
move16();
}
/* WB/SWB bandwidth switching */
- IF( ( st->tilt_wb_fx > 10240 && st->clas_dec == UNVOICED_CLAS ) || st->tilt_wb_fx > 20480 )
+ test();
+ test();
+ IF( ( GT_16( st->tilt_wb_fx, 10240 ) && ( st->clas_dec == UNVOICED_CLAS ) ) || GT_16( st->tilt_wb_fx, 20480 ) )
{
test();
test();
@@ -1123,7 +1186,8 @@ void ivas_swb_tbe_dec_fx(
test();
test();
test();
- IF( ( st->prev_fractive == 0 &&
+ test();
+ IF( ( ( st->prev_fractive == 0 ) &&
( LT_32( st->prev_enerLH_fx, L_shl( st->enerLH_fx, 1 ) ) && GT_32( st->prev_enerLH_fx, L_shr( st->enerLH_fx, 1 ) ) && LT_32( st->prev_enerLL_fx, L_shl( st->enerLL_fx, 1 ) ) && GT_32( st->prev_enerLL_fx, L_shr( st->enerLL_fx, 1 ) ) ) ) ||
( EQ_16( st->prev_fractive, 1 ) &&
GT_32( L_shr( st->prev_enerLH_fx, 2 ), Mult_32_16( st->enerLH_fx, 24576 ) ) ) /* 24576 in Q13*/
@@ -1149,7 +1213,7 @@ void ivas_swb_tbe_dec_fx(
inc_fx = 1489; /*Q15*/
move16();
- IF( is_fractive == 1 )
+ IF( EQ_16( is_fractive, 1 ) )
{
Copy( lsf_tab_fx, hBWE_TD->lsp_prevfrm_fx, LPC_SHB_ORDER );
}
@@ -1162,13 +1226,20 @@ void ivas_swb_tbe_dec_fx(
f_fx = add( f_fx, inc_fx );
}
}
- IF( ( st->last_extl != SWB_TBE && st->last_extl != FB_TBE && !( L_sub( L_shr( st->prev_enerLH_fx, 1 ), st->enerLH_fx ) < 0 && L_sub( st->prev_enerLH_fx, L_shr( st->enerLH_fx, 1 ) > 0 ) ) ) || st->last_core != ACELP_CORE || ( st->last_core == ACELP_CORE && labs( st->last_core_brate - st->core_brate ) > 3600 ) || ( is_fractive ^ st->prev_fractive ) == 1 )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && !( ( L_sub( L_shr( st->prev_enerLH_fx, 1 ), st->enerLH_fx ) < 0 ) && L_sub( st->prev_enerLH_fx, ( L_shr( st->enerLH_fx, 1 ) > 0 ) ) ) ) || st->last_core != ACELP_CORE || ( ( st->last_core == ACELP_CORE ) && GT_32( abs( L_sub( st->last_core_brate, st->core_brate ) ), 3600 ) ) || EQ_16( s_xor( is_fractive, st->prev_fractive ), 1 ) )
{
set16_fx( GainShape_fx, 11587, NUM_SHB_SUBFR );
}
ELSE
{
- IF( GT_16( hBWE_TD->prev_GainShape_fx, 11587 ) )
+ if ( GT_16( hBWE_TD->prev_GainShape_fx, 11587 ) )
{
hBWE_TD->prev_GainShape_fx = 11587;
move16();
@@ -1181,7 +1252,8 @@ void ivas_swb_tbe_dec_fx(
}
ELSE
{
- IF( st->last_extl != SWB_TBE && st->last_extl != FB_TBE )
+ test();
+ IF( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) )
{
f_fx = 1489; /*Q15*/
move16();
@@ -1199,7 +1271,7 @@ void ivas_swb_tbe_dec_fx(
{
IF( st->use_partial_copy )
{
- IF( st->last_extl != SWB_TBE )
+ IF( NE_16( st->last_extl, SWB_TBE ) )
{
hBWE_TD->GainFrame_prevfrm_fx = 0;
move32();
@@ -1217,7 +1289,7 @@ void ivas_swb_tbe_dec_fx(
Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER );
set16_fx( GainShape_fx, RECIP_ROOT_EIGHT_FX, NUM_SHB_SUBFR );
- IF( st->rf_frame_type == RF_NELP )
+ IF( EQ_16( st->rf_frame_type, RF_NELP ) )
{
/* Frame gain */
@@ -1228,7 +1300,13 @@ void ivas_swb_tbe_dec_fx(
L_tmp = Pow2( 30, frac );
GainFrame_fx = L_shl( L_tmp, sub( exp, 12 ) ); /*Q18*/
- IF( st->core == ACELP_CORE && st->last_core == ACELP_CORE && !st->prev_use_partial_copy && st->prev_coder_type == UNVOICED && NE_32( GainFrame_fx, hBWE_TD->GainFrame_prevfrm_fx ) && st->next_coder_type != GENERIC && st->last_extl == SWB_TBE )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( st->core == ACELP_CORE ) && ( st->last_core == ACELP_CORE ) && !st->prev_use_partial_copy && EQ_16( st->prev_coder_type, UNVOICED ) && NE_32( GainFrame_fx, hBWE_TD->GainFrame_prevfrm_fx ) && NE_16( st->next_coder_type, GENERIC ) && EQ_16( st->last_extl, SWB_TBE ) )
{
GainFrame_fx = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 26214 ), Mult_32_16( GainFrame_fx, 6553 ) );
}
@@ -1243,33 +1321,41 @@ void ivas_swb_tbe_dec_fx(
case 0:
GainFrame_fx = 131072; /* 0.5f in Q18 */
move32();
- IF( LE_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) )
- temp_fx = 26214 /*0.8 Q15*/;
- move16();
+ if ( LE_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) )
+ {
+ temp_fx = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
case 1:
GainFrame_fx = 524288; /* 2.0f in Q18 */
move32();
- IF( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) )
- temp_fx = 26214 /*0.8 Q15*/;
- move16();
test();
+ if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) )
+ {
+ temp_fx = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
case 2:
GainFrame_fx = 1048576; /* 4.0f in Q18 */
move32();
- IF( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) )
- temp_fx = 26214 /*0.8 Q15*/;
- move16();
test();
+ if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) )
+ {
+ temp_fx = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
case 3:
GainFrame_fx = 2097152; /* 8.0f in Q18 */
move32();
- IF( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 4194304l /*16Q18*/ ) )
- temp_fx = 26214 /*0.8 Q15*/;
- move16();
test();
+ if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 4194304l /*16Q18*/ ) )
+ {
+ temp_fx = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
default:
fprintf( stderr, "RF SWB-TBE gain bits not supported." );
@@ -1280,9 +1366,9 @@ void ivas_swb_tbe_dec_fx(
GainFrame_fx = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, temp_fx ), Mult_32_16( GainFrame_fx, sub( 32767, temp_fx ) ) );
}
- IF( st->core == ACELP_CORE && st->last_core == ACELP_CORE )
+ IF( ( st->core == ACELP_CORE ) && ( st->last_core == ACELP_CORE ) )
{
- IF( !st->prev_use_partial_copy && st->last_coder_type == VOICED && st->rf_frame_type == RF_GENPRED && GT_32( GainFrame_fx, 2097152 ) && LT_32( GainFrame_fx, 3059606 ) )
+ if ( !st->prev_use_partial_copy && EQ_16( st->last_coder_type, VOICED ) && EQ_16( st->rf_frame_type, RF_GENPRED ) && GT_32( GainFrame_fx, 2097152 ) && LT_32( GainFrame_fx, 3059606 ) )
{
GainFrame_fx = Mult_32_16( GainFrame_fx, 9830 );
}
@@ -1294,7 +1380,7 @@ void ivas_swb_tbe_dec_fx(
/* de-quantization */
ivas_dequantizeSHBparams_fx_9_1( st, st->extl, st->extl_brate, lsf_shb_fx, GainShape_fx, &GainFrame_fx, &stemp,
&shb_ener_sf_32, shb_res_gshape_fx, &mixFactors_fx, &MSFlag );
- IF( hStereoICBWE != NULL )
+ if ( hStereoICBWE != NULL )
{
hStereoICBWE->MSFlag = MSFlag;
move16();
@@ -1304,8 +1390,8 @@ void ivas_swb_tbe_dec_fx(
ELSE
{
Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER );
-
- IF( st->codec_mode == MODE1 && st->element_mode == EVS_MONO )
+ test();
+ IF( EQ_16( st->codec_mode, MODE1 ) && ( st->element_mode == EVS_MONO ) )
{
gradientGainShape( st, GainShape_fx, &GainFrame_fx );
}
@@ -1315,11 +1401,11 @@ void ivas_swb_tbe_dec_fx(
{
FOR( j = 0; j < 4; j++ )
{
- GainShape_fx[i * 4 + j] = mult_r( st->cummulative_damping, st->GainShape_Delay[4 + i] );
+ GainShape_fx[add( i * 4, j )] = mult_r( st->cummulative_damping, st->GainShape_Delay[4 + i] );
move16();
}
}
- IF( GT_16( tilt_swb_fec_fx, 8 << 11 ) ) /* tilt_swb_fec_fx in Q11 */
+ IF( GT_16( tilt_swb_fec_fx, ( 8 << 11 ) ) ) /* tilt_swb_fec_fx in Q11 */
{
IF( EQ_16( st->nbLostCmpt, 1 ) )
{
@@ -1342,9 +1428,10 @@ void ivas_swb_tbe_dec_fx(
}
}
- IF( st->extl_brate >= SWB_TBE_2k8 )
+ IF( GE_32( st->extl_brate, SWB_TBE_2k8 ) )
{
- IF( st->codec_mode == MODE1 && st->element_mode == EVS_MONO )
+ test();
+ IF( EQ_16( st->codec_mode, MODE1 ) && ( st->element_mode == EVS_MONO ) )
{
L_tmp = L_mult( extract_l( hBWE_TD->prev2_shb_ener_sf_fx ), extract_l( hBWE_TD->prev3_shb_ener_sf_fx ) ); /*Q1*/
tmp = round_fx( root_a_fx( L_tmp, 1, &exp ) ); /* Q = 15-exp */
@@ -1361,19 +1448,19 @@ void ivas_swb_tbe_dec_fx(
scale_fx = div_s( tmp1, tmp ); /* Q15 - Q(15-exp) + Qi = Qexp+i */
scale_fx = s_max( scale_fx, 0 );
#ifdef BASOP_NOGLOB
- tmp = shl_sat( scale_fx, 15 - exp - i ); /*Q15*/
+ tmp = shl_sat( scale_fx, sub( sub( 15, exp ), i ) ); /*Q15*/
#else
tmp = shl( scale, 15 - exp - i ); /*Q15*/
#endif
}
scale_fx = mult_r( hBWE_TD->prev_res_shb_gshape_fx, tmp ); /* Q14 */
-
+ test();
IF( GT_32( L_shr( hBWE_TD->prev2_shb_ener_sf_fx, 1 ), hBWE_TD->prev1_shb_ener_sf_fx ) ||
GT_32( L_shr( hBWE_TD->prev3_shb_ener_sf_fx, 1 ), hBWE_TD->prev2_shb_ener_sf_fx ) )
{
shb_ener_sf_32 = Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, scale_fx );
- IF( GT_16( st->nbLostCmpt, 1 ) )
+ if ( GT_16( st->nbLostCmpt, 1 ) )
{
shb_ener_sf_32 = L_shr( shb_ener_sf_32, 1 );
}
@@ -1386,6 +1473,7 @@ void ivas_swb_tbe_dec_fx(
}
ELSE
{
+ test();
IF( GT_32( L_shr( hBWE_TD->prev2_shb_ener_sf_fx, 1 ), hBWE_TD->prev1_shb_ener_sf_fx ) ||
GT_32( L_shr( hBWE_TD->prev3_shb_ener_sf_fx, 1 ), hBWE_TD->prev2_shb_ener_sf_fx ) )
{
@@ -1428,6 +1516,7 @@ void ivas_swb_tbe_dec_fx(
Copy( voice_factors_fx, vf_modified_fx, NB_SUBFR16k );
+ test();
IF( EQ_16( st->coder_type, VOICED ) || GT_16( mean_vf, 13107 /*0.4f Q15*/ ) )
{
FOR( i = 1; i < NB_SUBFR; i++ )
@@ -1445,6 +1534,7 @@ void ivas_swb_tbe_dec_fx(
}
}
+ test();
IF( st->use_partial_copy && st->nelp_mode_dec )
{
set16_fx( vf_modified_fx, 0, NB_SUBFR16k );
@@ -1453,7 +1543,8 @@ void ivas_swb_tbe_dec_fx(
/* SHB LSF from current frame; and convert to LSP for interpolation */
E_LPC_lsf_lsp_conversion( lsf_shb_fx, lsp_shb_2_fx, LPC_SHB_ORDER );
- IF( st->last_extl == SWB_TBE || st->last_extl == FB_TBE )
+ test();
+ IF( EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) )
{
/* SHB LSP values from prev. frame for interpolation */
Copy( hBWE_TD->swb_lsp_prev_interp_fx, lsp_shb_1_fx, LPC_SHB_ORDER );
@@ -1464,15 +1555,18 @@ void ivas_swb_tbe_dec_fx(
Copy( lsp_shb_2_fx, lsp_shb_1_fx, LPC_SHB_ORDER );
}
- IF( st->bws_cnt == 0 && st->bws_cnt1 == 0 && st->prev_use_partial_copy == 0 && st->use_partial_copy == 0 )
+ test();
+ test();
+ test();
+ IF( ( st->bws_cnt == 0 ) && ( st->bws_cnt1 == 0 ) && ( st->prev_use_partial_copy == 0 ) && ( st->use_partial_copy == 0 ) )
{
lsf_diff_fx[0] = 16384;
move16(); /*Q15*/
- lsf_diff_fx[sub( LPC_SHB_ORDER, 1 )] = 16384;
+ lsf_diff_fx[LPC_SHB_ORDER - 1] = 16384;
move16(); /*Q15*/
FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ )
{
- lsf_diff_fx[i] = sub( lsf_shb_fx[i], lsf_shb_fx[sub( i, 1 )] );
+ lsf_diff_fx[i] = sub( lsf_shb_fx[i], lsf_shb_fx[i - 1] );
move16();
}
@@ -1483,7 +1577,8 @@ void ivas_swb_tbe_dec_fx(
tmp2 = shr( mult( 31715, tmp ), 2 ); /*Q10*/
tilt_para_fx = add( sub( tmp1, tmp2 ), 1335 ); /*Q10*/
- IF( st->last_extl != SWB_TBE && st->last_extl != FB_TBE )
+ test();
+ IF( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) )
{
FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ )
{
@@ -1492,8 +1587,13 @@ void ivas_swb_tbe_dec_fx(
}
}
- IF( st->extl_brate <= FB_TBE_1k8 )
+ IF( LE_32( st->extl_brate, FB_TBE_1k8 ) )
{
+ test();
+ test();
+ test();
+ test();
+ test();
IF( !( GT_16( hBWE_TD->prev_tilt_para_fx, 5120 ) && ( EQ_16( st->coder_type, TRANSITION ) || LT_16( tilt_para_fx, 1024 ) ) ) &&
!( ( ( LT_16( hBWE_TD->prev_tilt_para_fx, 3072 ) && GE_16( st->prev_coder_type, VOICED ) ) ) && GT_16( tilt_para_fx, 5120 ) ) )
{
@@ -1504,7 +1604,7 @@ void ivas_swb_tbe_dec_fx(
tmp = mult( 26214, lsf_diff_fx[i] );
test();
- IF( hBWE_TD->prev_lsf_diff_fx[i - 1] <= 0 || tmp < 0 ) /* safety check in case of bit errors */
+ IF( ( hBWE_TD->prev_lsf_diff_fx[i - 1] <= 0 ) || ( tmp < 0 ) ) /* safety check in case of bit errors */
{
st->BER_detect = 1;
move16();
@@ -1525,7 +1625,7 @@ void ivas_swb_tbe_dec_fx(
tmp = mult( 26214, hBWE_TD->prev_lsf_diff_fx[i - 1] );
test();
- IF( lsf_diff_fx[i] <= 0 || tmp < 0 ) /* safety check in case of bit errors */
+ IF( ( lsf_diff_fx[i] <= 0 ) || ( tmp < 0 ) ) /* safety check in case of bit errors */
{
st->BER_detect = 1;
move16();
@@ -1544,7 +1644,7 @@ void ivas_swb_tbe_dec_fx(
}
w_fx[0] = w_fx[1];
move16();
- w_fx[sub( LPC_SHB_ORDER, 1 )] = w_fx[sub( LPC_SHB_ORDER, 2 )];
+ w_fx[LPC_SHB_ORDER - 1] = w_fx[LPC_SHB_ORDER - 2];
move16();
FOR( i = 0; i < LPC_SHB_ORDER; i++ )
@@ -1566,13 +1666,14 @@ void ivas_swb_tbe_dec_fx(
Copy( lsf_diff_fx + 1, hBWE_TD->prev_lsf_diff_fx, LPC_SHB_ORDER - 2 );
hBWE_TD->prev_tilt_para_fx = tilt_para_fx;
+ move16();
}
ELSE
{
Copy( lsp_shb_2_fx, lsp_temp_fx, LPC_SHB_ORDER );
}
- IF( st->extl_brate >= SWB_TBE_2k8 )
+ IF( GE_32( st->extl_brate, SWB_TBE_2k8 ) )
{
/* SHB LSP interpolation */
ptr_lsp_interp_coef_fx = interpol_frac_shb; /*Q15*/
@@ -1591,7 +1692,8 @@ void ivas_swb_tbe_dec_fx(
E_LPC_f_lsp_a_conversion( lsp_temp_fx, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER );
/* 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[j * ( LPC_SHB_ORDER + 1 )] = ONE_IN_Q12; // recheck this
+ lpc_shb_sf_fx[i_mult( j, ( LPC_SHB_ORDER + 1 ) )] = ONE_IN_Q12; // recheck this
+ move16();
}
}
@@ -1623,10 +1725,11 @@ void ivas_swb_tbe_dec_fx(
lpc_shb_fx[0] = ONE_IN_Q12;
move16();
- IF( st->extl_brate == SWB_TBE_1k10 || st->extl_brate == SWB_TBE_1k75 )
+ test();
+ IF( EQ_32( st->extl_brate, SWB_TBE_1k10 ) || EQ_32( st->extl_brate, SWB_TBE_1k75 ) )
{
- Word32 vind_temp = ( L_add( mixFactors_fx, 1 ) * ( ( 1 << NUM_BITS_SHB_VF ) - 1 ) ); // check addition of 1
- vind = extract_l( L_shr( vind_temp, 15 ) ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*7*/
+ Word32 vind_temp = Mpy_32_32( L_shl( L_add( L_deposit_l( mixFactors_fx ), 1 ), 15 ), ( ( ( 1 << NUM_BITS_SHB_VF ) - 1 ) << 16 ) ); // check addition of 1
+ vind = extract_l( L_shr( vind_temp, 15 ) ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*7*/
/* i: mixFactors_fx in Q15 */
/* o: vind in Q0 */
}
@@ -1640,11 +1743,11 @@ void ivas_swb_tbe_dec_fx(
/* Determine formant PF strength */
formant_fac_fx = swb_formant_fac_fx( lpc_shb_fx[1], &hBWE_TD->tilt_mem_fx );
/* i:lpc_shb_fx Q12, o:formant_fac_fx Q15 */
- IF( st->total_brate > ACELP_32k )
+ IF( GT_32( st->total_brate, ACELP_32k ) )
{
FOR( j = 0; j < 4; j++ )
{
- Copy( lpc_shb_fx, &lpc_shb_sf_fx[j * ( LPC_SHB_ORDER + 1 )], LPC_SHB_ORDER + 1 );
+ Copy( lpc_shb_fx, &lpc_shb_sf_fx[i_mult( j, ( LPC_SHB_ORDER + 1 ) )], LPC_SHB_ORDER + 1 );
}
}
@@ -1659,7 +1762,7 @@ void ivas_swb_tbe_dec_fx(
Lmax = L_max( Lmax, L_abs( bwe_exc_extended_fx[cnt] ) );
}
Q_bwe_exc = norm_l( Lmax );
- IF( Lmax == 0 )
+ if ( Lmax == 0 )
{
Q_bwe_exc = 31;
move16();
@@ -1668,7 +1771,7 @@ void ivas_swb_tbe_dec_fx(
find_max_mem_dec( st, &n_mem, &n_mem2, &n_mem3 ); /* for >=24.4, use n_mem2 lpc_syn, shb_20sample, and mem_stp_swb_fx memory */
tmp = add( st->prev_Q_bwe_exc, n_mem );
- IF( GT_16( Q_bwe_exc, tmp ) )
+ if ( GT_16( Q_bwe_exc, tmp ) )
{
Q_bwe_exc = tmp;
move16();
@@ -1691,6 +1794,7 @@ void ivas_swb_tbe_dec_fx(
#else
bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx( L_shl( bwe_exc_extended[cnt], sc ) );
#endif
+ move16();
}
/* state_syn_shbexc_fx is kept at (st_fx->prev_Q_bwe_syn) for 24.4/32kbps or is kept at Q_bwe_exc for 13.2/16.4kbps */
@@ -1738,12 +1842,14 @@ void ivas_swb_tbe_dec_fx(
/* rescale the TBE post proc memory */
FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
- hBWE_TD->mem_stp_swb_fx[i] = shl( hBWE_TD->mem_stp_swb_fx[i], Q_bwe_exc - st->prev_Q_bwe_syn );
+ hBWE_TD->mem_stp_swb_fx[i] = shl( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, st->prev_Q_bwe_syn ) );
move16();
}
#endif
/* fill-in missing SHB excitation */
- IF( ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) && st->last_core_brate <= SID_2k40 )
+ test();
+ test();
+ IF( ( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) && LE_32( st->last_core_brate, SID_2k40 ) )
{
Copy( shaped_shb_excitation_fx + L_SHB_LAHEAD, shaped_shb_excitation_fx, L_SHB_LAHEAD );
}
@@ -1753,7 +1859,8 @@ void ivas_swb_tbe_dec_fx(
Copy( shaped_shb_excitation_fx + L_SHB_LAHEAD, hStereoICBWE->shbSynthRef_fx, L_FRAME16k );
}
- IF( st->extl_brate != SWB_TBE_1k10 && st->extl_brate != SWB_TBE_1k75 )
+ test();
+ IF( NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) )
{
FOR( i = 0; i < L_FRAME16k; i += L_SUBFR16k )
{
@@ -1783,7 +1890,7 @@ void ivas_swb_tbe_dec_fx(
#endif
}
- IF( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) )
+ if ( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) )
{
curr_pow_fx = L_shr( curr_pow_fx, 2 ); /* Q(2*Q_bwe_exc) */
}
@@ -1804,6 +1911,7 @@ void ivas_swb_tbe_dec_fx(
{
Lscale = L_shl( Lscale, exp );
exp = 0;
+ move16();
}
FOR( ; i < L_SHB_LAHEAD + 10; i++ )
{
@@ -1833,6 +1941,7 @@ void ivas_swb_tbe_dec_fx(
/* Update SHB excitation */
Copy( shaped_shb_excitation_fx + L_FRAME16k, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD ); /* Q_bwe_exc */
l_subframe = L_FRAME16k / NUM_SHB_SUBGAINS;
+ move16();
L_ener = EPSILON_FX_SMALL;
move32();
@@ -1847,7 +1956,7 @@ void ivas_swb_tbe_dec_fx(
move64();
FOR( j = 0; j < l_subframe; j++ )
{
- tmp64 = W_mac0_16_16( tmp64, shaped_shb_excitation_fx[i * l_subframe + j], shaped_shb_excitation_fx[i * l_subframe + j] ); /* 2*Q_bwe_exc */
+ tmp64 = W_mac0_16_16( tmp64, shaped_shb_excitation_fx[add( i_mult( i, l_subframe ), j )], shaped_shb_excitation_fx[add( i_mult( i, l_subframe ), j )] ); /* 2*Q_bwe_exc */
}
L_tmp = W_sat_l( tmp64 );
@@ -1856,7 +1965,7 @@ void ivas_swb_tbe_dec_fx(
{
exp = norm_l( L_tmp );
tmp = extract_h( L_shl( L_tmp, exp ) );
- exp = sub( exp, 30 - ( 2 * Q_bwe_exc ) );
+ exp = sub( exp, sub( 30, i_mult( 2, Q_bwe_exc ) ) );
tmp = div_s( 16384, tmp );
L_tmp = L_deposit_h( tmp );
@@ -1872,8 +1981,11 @@ void ivas_swb_tbe_dec_fx(
#endif
}
}
- ener_fx = s_max( 1, round_fx( L_shl( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */
-
+#ifdef BASOP_NOGLOB /* Saturation fix taken from EVS*/
+ ener_fx = s_max( 1, round_fx_sat( L_shl_sat( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */
+#else
+ ener_fx = s_max( 1, round_fx( L_shl( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */
+#endif
/* WB/SWB bandwidth switching */
IF( st->bws_cnt > 0 )
{
@@ -1890,7 +2002,7 @@ void ivas_swb_tbe_dec_fx(
move16();
}
test();
- IF( st->prev_fractive == 1 && GT_16( st->tilt_wb_fx, 1024 ) )
+ if ( EQ_16( st->prev_fractive, 1 ) && GT_16( st->tilt_wb_fx, 1024 ) )
{
st->tilt_wb_fx = 1024;
move16();
@@ -1914,6 +2026,7 @@ void ivas_swb_tbe_dec_fx(
ELSE
{
st->tilt_wb_fx = shl( st->tilt_wb_fx, 2 );
+ move16();
}
}
@@ -1932,6 +2045,7 @@ void ivas_swb_tbe_dec_fx(
#else
st->tilt_wb_fx = extract_h( L_shr( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 16 ) ) ); /*Q11*/
#endif
+ move16();
/*st->Q_syn2 -1 + 26- exp_ener -15 -(st->Q_syn2 -exp_ener -16 ) -16 +1 -1 = (11) *0.5*/
}
ELSE IF( LT_32( L_tmp, Mult_32_16( st->enerLH_fx, 1638 ) ) && EQ_16( is_fractive, 1 ) )
@@ -1941,6 +2055,7 @@ void ivas_swb_tbe_dec_fx(
#else
st->tilt_wb_fx = extract_h( L_shr( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 15 ) ) ); /*Q11*/
#endif
+ move16();
/*st->Q_syn2 -1 + 26- exp_ener -15 -(st->Q_syn2 -exp_ener -15 ) -16 = (11) 0.25*/
}
L_tmp = L_mult0( st->prev_ener_shb_fx, inv_ener ); /*Q(1+15+14-3-exp_ener) = 27 -exp_ener*/
@@ -1954,11 +2069,11 @@ void ivas_swb_tbe_dec_fx(
IF( EQ_16( is_fractive, 1 ) )
{
- GainFrame_fx = L_shl( (Word32) st->tilt_wb_fx, 10 );
+ GainFrame_fx = L_shl( L_deposit_l( st->tilt_wb_fx ), 10 );
}
ELSE
{
- GainFrame_fx = L_shl( (Word32) st->tilt_wb_fx, 8 );
+ GainFrame_fx = L_shl( L_deposit_l( st->tilt_wb_fx ), 8 );
}
test();
@@ -1972,14 +2087,14 @@ void ivas_swb_tbe_dec_fx(
test();
test();
test();
- IF( ( LT_32( L_shr( st->prev_enerLH_fx, 1 ), st->enerLH_fx ) && GT_32( st->prev_enerLH_fx, L_shr( st->enerLH_fx, 1 ) ) ) && ( LT_32( L_shr( st->prev_enerLL_fx, 1 ), st->enerLL_fx ) && GT_32( st->prev_enerLL_fx, L_shr( st->enerLL_fx, 1 ) ) ) && ( is_fractive ^ st->prev_fractive ) == 0 )
+ IF( ( LT_32( L_shr( st->prev_enerLH_fx, 1 ), st->enerLH_fx ) && GT_32( st->prev_enerLH_fx, L_shr( st->enerLH_fx, 1 ) ) ) && ( LT_32( L_shr( st->prev_enerLL_fx, 1 ), st->enerLL_fx ) && GT_32( st->prev_enerLL_fx, L_shr( st->enerLL_fx, 1 ) ) ) && ( s_xor( is_fractive, st->prev_fractive ) == 0 ) )
{
GainFrame_fx = L_add( L_shr( GainFrame_fx, 1 ), L_shr( GainFrame_prevfrm_fx, 1 ) );
}
ELSE
{
test();
- IF( is_fractive == 0 && EQ_16( st->prev_fractive, 1 ) )
+ IF( ( is_fractive == 0 ) && EQ_16( st->prev_fractive, 1 ) )
{
L_tmp1 = L_shl( Mult_32_16( GainFrame_fx, 3277 ), 13 ); /* 31 */
L_tmp = L_sub( 2147483647, L_tmp1 ); /* 31 */
@@ -2009,9 +2124,19 @@ void ivas_swb_tbe_dec_fx(
prev_ener_ratio_fx = L_shr( L_mult0( st->prev_ener_shb_fx, inv_ener ), add( sub( 9, exp_ener ), 1 ) ); /*Q: 1+27-exp-9+exp-1 = 18 */
}
- IF( st->nbLostCmpt == 1 )
+ IF( EQ_16( st->nbLostCmpt, 1 ) )
{
- IF( NE_16( st->clas_dec, UNVOICED_CLAS ) && NE_16( st->clas_dec, UNVOICED_TRANSITION ) && LT_16( hBWE_TD->tilt_swb_fec_fx, 16384 ) &&
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( st->clas_dec != UNVOICED_CLAS ) && NE_16( st->clas_dec, UNVOICED_TRANSITION ) && LT_16( hBWE_TD->tilt_swb_fec_fx, 16384 ) &&
( ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) && LT_32( L_shr( st->enerLL_fx, 1 ), st->prev_enerLL_fx ) ) || ( GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) && LT_32( L_shr( st->enerLH_fx, 1 ), st->prev_enerLH_fx ) ) ) )
{
IF( GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) ) /*18*/
@@ -2028,7 +2153,7 @@ void ivas_swb_tbe_dec_fx(
}
test();
- IF( GT_16( tilt_swb_fec_fx, hBWE_TD->tilt_swb_fec_fx ) && hBWE_TD->tilt_swb_fec_fx > 0 )
+ IF( GT_16( tilt_swb_fec_fx, hBWE_TD->tilt_swb_fec_fx ) && ( hBWE_TD->tilt_swb_fec_fx > 0 ) )
{
exp = norm_s( hBWE_TD->tilt_swb_fec_fx );
tmp = shl( hBWE_TD->tilt_swb_fec_fx, exp ); /*Q(11+exp)*/
@@ -2037,14 +2162,22 @@ void ivas_swb_tbe_dec_fx(
GainFrame_fx = L_shl( Mult_32_16( GainFrame_fx, s_min( tmp, 20480 ) ), 3 ); /*Q18 = 18 +12 -15 +3 */
}
}
- ELSE IF( ( NE_16( st->clas_dec, UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 4096 ) ) && GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) &&
+ ELSE IF( ( ( st->clas_dec != UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 4096 ) ) && GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) &&
( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) )
{
GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 ), Mult_32_16( GainFrame_fx, 26214 ) );
}
}
- ELSE IF( st->nbLostCmpt > 1 )
+ ELSE IF( GT_16( st->nbLostCmpt, 1 ) )
{
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
IF( GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) && ( ( EQ_16( st->codec_mode, MODE1 ) && GT_32( st->enerLL_fx, st->prev_enerLL_fx ) && GT_32( st->enerLH_fx, st->prev_enerLH_fx ) ) || EQ_16( st->codec_mode, MODE2 ) ) )
{
test();
@@ -2077,7 +2210,7 @@ void ivas_swb_tbe_dec_fx(
/* Adjust the subframe and frame gain of the synthesized shb signal */
/* Scale the shaped excitation */
- IF( st->L_frame == L_FRAME )
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
L_tmp = L_mult( pitch_buf_fx[0], 8192 );
FOR( i = 1; i < NB_SUBFR; i++ )
@@ -2096,11 +2229,23 @@ void ivas_swb_tbe_dec_fx(
pitch_fx = round_fx( L_tmp ); /* Q6 */
}
- IF( ( ( st->extl_brate >= SWB_TBE_2k8 && st->prev_coder_type == st->coder_type && st->coder_type != UNVOICED ) || ( st->extl_brate < SWB_TBE_2k8 && ( st->prev_coder_type == st->coder_type || ( st->prev_coder_type == VOICED && st->coder_type == GENERIC ) || ( st->prev_coder_type == GENERIC && st->coder_type == VOICED ) ) ) ) && GT_16( pitch_fx, 4480 /*70 in Q6*/ ) && st->extl < FB_TBE && st->extl_brate != SWB_TBE_1k10 && st->extl_brate != SWB_TBE_1k75 )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( ( GE_32( st->extl_brate, SWB_TBE_2k8 ) && EQ_16( st->prev_coder_type, st->coder_type ) && NE_16( st->coder_type, UNVOICED ) ) || ( LT_32( st->extl_brate, SWB_TBE_2k8 ) && ( EQ_16( st->prev_coder_type, st->coder_type ) || ( EQ_16( st->prev_coder_type, VOICED ) && EQ_16( st->coder_type, GENERIC ) ) || ( EQ_16( st->prev_coder_type, GENERIC ) && EQ_16( st->coder_type, VOICED ) ) ) ) ) && GT_16( pitch_fx, 4480 /*70 in Q6*/ ) && LT_16( st->extl, FB_TBE ) && NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) )
{
FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ )
{
- GainShape_tmp_fx[i] = GainShape_fx[shl( i, 2 )]; /* Q15 */
+ GainShape_tmp_fx[i] = GainShape_fx[i * 4]; /* Q15 */
move16();
}
@@ -2118,7 +2263,7 @@ void ivas_swb_tbe_dec_fx(
{
L_tmp = L_tmp2;
move32();
- IF( L_tmp2 < 0 )
+ if ( L_tmp2 < 0 )
{
L_tmp = L_negate( L_tmp2 );
}
@@ -2129,11 +2274,11 @@ void ivas_swb_tbe_dec_fx(
#else
fracb = round_fx( L_shl( L_tmp, expb ) );
#endif
- expb = 30 - expb; /* - (2*Q_bwe_exc_ext); */
+ expb = sub( 30, expb ); /* - (2*Q_bwe_exc_ext); */
expa = norm_l( ener_tmp_fx[i] );
fraca = extract_h( L_shl( ener_tmp_fx[i], expa ) );
- expa = 30 - expa;
+ expa = sub( 30, expa );
scale_fx = shr( sub( fraca, fracb ), 15 );
fracb = shl( fracb, scale_fx );
@@ -2156,7 +2301,13 @@ void ivas_swb_tbe_dec_fx(
FOR( i = 0; i < NUM_SHB_SUBFR; i++ )
{
- GainShape_fx[i] = GainShape_tmp_fx[i * NUM_SHB_SUBGAINS / NUM_SHB_SUBFR];
+ Word16 idx = 0;
+ move16();
+ IF( i != 0 )
+ {
+ idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR );
+ }
+ GainShape_fx[i] = GainShape_tmp_fx[idx];
move16();
}
}
@@ -2170,7 +2321,8 @@ void ivas_swb_tbe_dec_fx(
/* Gain shape smoothing after quantization */
- IF( st->extl_brate == SWB_TBE_1k10 || st->extl_brate == SWB_TBE_1k75 )
+ test();
+ IF( EQ_32( st->extl_brate, SWB_TBE_1k10 ) || EQ_32( st->extl_brate, SWB_TBE_1k75 ) )
{
FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ )
{
@@ -2180,37 +2332,47 @@ void ivas_swb_tbe_dec_fx(
lls_interp_n_fx( GainShape_tmp_fx, NUM_SHB_SUBGAINS, &GainShape_tilt_fx, &temp_fx, 1 );
- IF( vind >= 6 && abs( GainShape_tilt_fx ) < 3932 )
+ test();
+ IF( GE_16( vind, 6 ) && LT_16( abs_s( GainShape_tilt_fx ), 3932 ) )
{
feedback_fx = 9830;
move16();
FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ )
{
- GainShape_fx[i] = add_sat( mult( ( 32767 - feedback_fx ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), mult( feedback_fx, GainShape_tmp_fx[i] ) );
+ GainShape_fx[i] = add_sat( mult( sub( 32767, feedback_fx ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), mult( feedback_fx, GainShape_tmp_fx[i] ) );
move16();
}
FOR( i = NUM_SHB_SUBFR - 1; i > 0; i-- )
{
- GainShape_fx[i] = GainShape_fx[i * NUM_SHB_SUBGAINS / NUM_SHB_SUBFR];
+ Word16 idx = 0;
+ move16();
+ IF( i != 0 )
+ {
+ idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR );
+ }
+ GainShape_fx[i] = GainShape_fx[idx];
move16();
}
}
}
/* fil-in missing memory */
- IF( ( st->element_mode == IVAS_CPE_TD || st->element_mode == IVAS_CPE_DFT ) && st->last_core_brate <= SID_2k40 )
+ test();
+ test();
+ IF( ( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) && LE_32( st->last_core_brate, SID_2k40 ) )
{
FOR( i = 0; i < L_SHB_LAHEAD; i++ )
{
Word16 intermediate = mult( shaped_shb_excitation_fx[i], subwin_shb_fx[L_SHB_LAHEAD - i] );
Word32 intermediate_32 = Mpy_32_16_1( Mpy_32_16_1( GainFrame_fx, window_shb_fx[L_SHB_LAHEAD - 1 - i] ), intermediate );
- hBWE_TD->syn_overlap_fx[i] = (Word16) round_fx( L_shl_sat( intermediate_32, 16 - ( Q_bwe_exc + 18 - 15 ) ) );
+ hBWE_TD->syn_overlap_fx[i] = round_fx( L_shl_sat( intermediate_32, sub( 16, ( add( Q_bwe_exc, 18 - 15 ) ) ) ) );
move16();
}
}
Word16 n_mem3_new = 0;
+ move16();
find_max_mem_dec_m3( st, &n_mem3_new );
ScaleShapedSHB_fx( SHB_OVERLAP_LEN,
@@ -2233,6 +2395,7 @@ void ivas_swb_tbe_dec_fx(
}
max_val = 0;
+ move16();
FOR( i = 0; i < L_FRAME16k; i++ )
{
max_val = s_max( max_val, shaped_shb_excitation_fx[i] ); /* Q0 */
@@ -2275,10 +2438,12 @@ void ivas_swb_tbe_dec_fx(
IF( GT_16( tmp, 32 ) )
{
st->prev_frame_pow_exp = add( curr_frame_pow_exp, 32 );
+ move16();
tmp = 32;
move16();
}
hBWE_TD->prev_swb_bwe_frame_pow_fx = L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, tmp );
+ move32();
st->prev_frame_pow_exp = curr_frame_pow_exp;
move16();
}
@@ -2294,18 +2459,21 @@ void ivas_swb_tbe_dec_fx(
curr_frame_pow_exp = st->prev_frame_pow_exp;
move16();
}
-
+ test();
+ test();
IF( !st->bfi && ( st->prev_bfi || st->prev_use_partial_copy ) )
{
+ test();
+ test();
IF( ( GT_32( L_shr( curr_frame_pow_fx, 1 ), hBWE_TD->prev_swb_bwe_frame_pow_fx ) ) &&
( GT_32( hBWE_TD->prev_swb_bwe_frame_pow_fx, L_tmp ) ) && EQ_16( st->prev_coder_type, UNVOICED ) )
{
L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp );
scale_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
temp_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/
}
ELSE
@@ -2319,11 +2487,11 @@ void ivas_swb_tbe_dec_fx(
{
GainShape_fx[2 * j] = mult_r( GainShape_fx[2 * j], scale_fx );
move16();
- GainShape_fx[2 * j + 1] = mult_r( GainShape_fx[2 * j + 1], scale_fx );
+ GainShape_fx[add( 2 * j, 1 )] = mult_r( GainShape_fx[add( 2 * j, 1 )], scale_fx );
move16();
FOR( i = 0; i < L_FRAME16k / 8; i++ )
{
- shaped_shb_excitation_fx[i + j * L_FRAME16k / 8] = mult_r( shaped_shb_excitation_fx[i + j * L_FRAME16k / 8], scale_fx );
+ shaped_shb_excitation_fx[add( i, j * ( L_FRAME16k / 8 ) )] = mult_r( shaped_shb_excitation_fx[add( i, j * ( L_FRAME16k / 8 ) )], scale_fx );
move16();
}
@@ -2355,7 +2523,7 @@ void ivas_swb_tbe_dec_fx(
scale_fx = temp_fx = 4096;
move16(); /*Q12*/
move16();
- IF( st->nbLostCmpt == 1 )
+ IF( EQ_16( st->nbLostCmpt, 1 ) )
{
test();
test();
@@ -2367,18 +2535,18 @@ void ivas_swb_tbe_dec_fx(
test();
IF( GT_32( curr_frame_pow_fx, hBWE_TD->prev_swb_bwe_frame_pow_fx ) &&
NE_16( st->prev_coder_type, UNVOICED ) &&
- NE_16( st->last_good, UNVOICED_CLAS ) )
+ ( st->last_good != UNVOICED_CLAS ) )
{
L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); /*31 - exp*/
scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
}
ELSE IF( LT_32( curr_frame_pow_fx, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) && EQ_16( st->nbLostCmpt, 1 ) &&
( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) &&
- ( EQ_16( st->prev_coder_type, UNVOICED ) || EQ_16( st->last_good, UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) )
+ ( EQ_16( st->prev_coder_type, UNVOICED ) || ( st->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) )
{
L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp );
#ifdef BASOP_NOGLOB
@@ -2386,21 +2554,26 @@ void ivas_swb_tbe_dec_fx(
#else
scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
#endif
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
}
}
- ELSE IF( st->nbLostCmpt > 1 )
+ ELSE IF( GT_16( st->nbLostCmpt, 1 ) )
{
+ test();
+ test();
+ test();
+ test();
+ test();
IF( GT_32( curr_frame_pow_fx, hBWE_TD->prev_swb_bwe_frame_pow_fx ) )
{
L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp );
scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
#ifdef BASOP_NOGLOB
temp_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
#else
@@ -2409,18 +2582,18 @@ void ivas_swb_tbe_dec_fx(
}
ELSE IF( LT_32( curr_frame_pow_fx, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) &&
( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) &&
- ( st->prev_coder_type == UNVOICED || st->last_good == UNVOICED_CLAS || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) )
+ ( EQ_16( st->prev_coder_type, UNVOICED ) || ( st->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) )
{
L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp );
#ifdef BASOP_NOGLOB
- L_tmp = L_min( L_tmp, L_shl_sat( 2, ( 31 - exp ) ) ); /*31 - exp*/
+ L_tmp = L_min( L_tmp, L_shl_sat( 2, sub( 31, exp ) ) ); /*31 - exp*/
#else
L_tmp = L_min( L_tmp, L_shl( 2, ( 31 - exp ) ) ); /*31 - exp*/
#endif
scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
}
}
@@ -2434,14 +2607,14 @@ void ivas_swb_tbe_dec_fx(
#endif
move16(); /* 15 +12 +3-15 =15*/
#ifdef BASOP_NOGLOB
- GainShape_fx[2 * j + 1] = shl_sat( mult_r( GainShape_fx[2 * j + 1], scale_fx ), 3 );
+ GainShape_fx[add( 2 * j, 1 )] = shl_sat( mult_r( GainShape_fx[add( 2 * j, 1 )], scale_fx ), 3 );
#else
GainShape_fx[2 * j + 1] = shl( mult_r( GainShape_fx[2 * j + 1], scale_fx ), 3 );
#endif
move16();
FOR( i = 0; i < 40; i++ )
{
- shaped_shb_excitation_fx[add( i, i_mult( j, 40 ) )] = shl( mult_r( shaped_shb_excitation_fx[add( i, i_mult( j, 40 ) )], scale_fx ), 3 );
+ shaped_shb_excitation_fx[add( i, j * 40 )] = shl( mult_r( shaped_shb_excitation_fx[add( i, j * 40 )], scale_fx ), 3 );
move16(); /* Q_bwe_exc +12+3 -15 =Q_bwe_exc*/
}
@@ -2487,12 +2660,17 @@ void ivas_swb_tbe_dec_fx(
{
exp = norm_l( L_prev_ener_shb );
tmp = extract_h( L_shl( L_prev_ener_shb, exp ) );
- exp = sub( exp, 30 - ( 2 * Q_bwe_exc + 8 ) );
+ exp = sub( exp, sub( 30, ( add( i_mult( 2, Q_bwe_exc ), 8 ) ) ) );
tmp = div_s( 16384, tmp );
L_tmp = L_deposit_h( tmp );
L_tmp = Isqrt_lc( L_tmp, &exp );
+#ifdef BASOP_NOGLOB /* Saturation fix taken from EVS*/
+ st->prev_ener_shb_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */
+#else
st->prev_ener_shb_fx = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */
+#endif
+ move16();
}
IF( st->hBWE_FD != NULL )
@@ -2504,19 +2682,23 @@ void ivas_swb_tbe_dec_fx(
{
exp = norm_l( L_tmp );
tmp = extract_h( L_shl( L_tmp, exp ) );
- exp = sub( exp, 30 - ( curr_frame_pow_exp + 8 ) );
+ exp = sub( exp, sub( 30, add( curr_frame_pow_exp, 8 ) ) );
tmp = div_s( 16384, tmp );
L_tmp = L_deposit_h( tmp );
L_tmp = Isqrt_lc( L_tmp, &exp );
- tmp = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */
+#ifdef BASOP_NOGLOB /* Saturation fix taken from EVS*/
+ tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */
+#else
+ tmp = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */
+#endif
}
set16_fx( st->prev_SWB_fenv_fx, tmp, SWB_FENV ); /* Q1 */
}
FOR( i = 0; i < L_FRAME16k; i++ )
{
- shaped_shb_excitation_fx_32[i] = L_shl( shaped_shb_excitation_fx[i], Q11 - Q_bwe_exc );
+ shaped_shb_excitation_fx_32[i] = L_shl( shaped_shb_excitation_fx[i], sub( Q11, Q_bwe_exc ) );
move32();
}
@@ -2528,18 +2710,18 @@ void ivas_swb_tbe_dec_fx(
/* resample SHB synthesis (if needed) and scale down */
synth_scale_fx = 32767;
move16(); /* 1.0 in Q15 */
- IF( EQ_16( st->codec_mode, MODE1 ) )
+ if ( EQ_16( st->codec_mode, MODE1 ) )
{
synth_scale_fx = 29491;
move16(); /* 0.9 in Q15 */
}
- IF( st->output_Fs == 48000 )
+ IF( EQ_32( st->output_Fs, 48000 ) )
{
- IF( st->extl == FB_TBE )
+ IF( EQ_16( st->extl, FB_TBE ) )
{
tmp = norm_l( GainFrame_fx );
- IF( GainFrame_fx == 0 )
+ if ( GainFrame_fx == 0 )
{
tmp = 31;
move16();
@@ -2550,14 +2732,22 @@ void ivas_swb_tbe_dec_fx(
move16();
FOR( i = 0; i < L_FRAME16k; i++ )
{
- L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[NUM_SHB_SUBFR * i / L_FRAME16k] ); /* Q : 18 + tmp +15 -15*/
- White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */
+ Word16 idx = 0;
+ move16();
+ IF( i != 0 )
+ {
+ idx = idiv1616( i_mult( NUM_SHB_SUBFR, i ), L_FRAME16k );
+ }
+ L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[idx] ); /* Q : 18 + tmp +15 -15*/
+ White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */
+ move16();
tmp1 = s_max( tmp1, abs_s( White_exc16k_fx[i] ) );
}
*Q_white_exc = sub( add( *Q_white_exc, tmp ), 13 ); /* *Q_white_exc + 18 + tmp -15 -16 */
+ move16();
tmp = norm_s( tmp1 );
- IF( tmp1 == 0 )
+ if ( tmp1 == 0 )
{
tmp = 15;
move16();
@@ -2569,6 +2759,7 @@ void ivas_swb_tbe_dec_fx(
move16();
}
*Q_white_exc = sub( add( *Q_white_exc, tmp ), 1 );
+ move16();
}
IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */
@@ -2581,7 +2772,7 @@ void ivas_swb_tbe_dec_fx(
}
interpolate_3_over_2_allpass_32( error_fx, L_FRAME32k, synth_fx, hBWE_TD->int_3_over_2_tbemem_dec_fx_32 );
}
- ELSE IF( st->output_Fs == 32000 )
+ ELSE IF( EQ_32( st->output_Fs, 32000 ) )
{
IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */
{
@@ -2596,7 +2787,7 @@ void ivas_swb_tbe_dec_fx(
Copy32( error_fx, synth_fx, L_FRAME32k );
}
}
- ELSE IF( st->output_Fs == 16000 )
+ ELSE IF( EQ_32( st->output_Fs, 16000 ) )
{
IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */
{
@@ -2612,14 +2803,14 @@ void ivas_swb_tbe_dec_fx(
/* Update previous frame parameters for FEC */
- IF( st->codec_mode == MODE1 )
+ IF( EQ_16( st->codec_mode, MODE1 ) )
{
hBWE_TD->GainFrame_prevfrm_fx = GainFrame_fx;
move32(); /*Q18*/
hBWE_TD->tilt_swb_fec_fx = tilt_swb_fec_fx;
move16();
- IF( !st->bfi )
+ if ( !st->bfi )
{
hBWE_TD->GainAttn_fx = 32767;
move16();
@@ -3266,6 +3457,15 @@ void swb_tbe_dec(
prev_pow = sum2_f( shaped_shb_excitation, L_SHB_LAHEAD + 10 );
curr_pow = sum2_f( shaped_shb_excitation + L_SHB_LAHEAD + 10, L_SHB_LAHEAD + 10 );
+#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE
+ if ( st->element_mode > EVS_MONO )
+ {
+ /* prevent too low values of energy */
+ prev_pow = max( 0.00001f, prev_pow );
+ curr_pow = max( 0.00001f, curr_pow );
+ }
+#endif
+
if ( voice_factors[0] > 0.75f )
{
curr_pow *= 0.25;
@@ -4247,7 +4447,7 @@ void fb_tbe_dec(
}
#endif
-
+#ifndef IVAS_FLOAT_FIXED
/*---------------------------------------------------------------------*
* tbe_read_bitstream()
*
@@ -4335,7 +4535,7 @@ void tbe_read_bitstream(
return;
}
-
+#endif
#ifndef IVAS_FLOAT_FIXED
/*---------------------------------------------------------------------*
@@ -4418,13 +4618,17 @@ void GenTransition_fixed(
Word32 syn_overlap_32k_fx[2 * SHB_OVERLAP_LEN];
/* set targeted length of transition signal */
- length = 2 * NS2SA( output_Fs, DELAY_BWE_TOTAL_NS );
+ length = i_mult( 2, NS2SA( output_Fs, DELAY_BWE_TOTAL_NS ) );
/* upsample overlap snippet */
Interpolate_allpass_steep_32( hBWE_TD->syn_overlap_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, SHB_OVERLAP_LEN, syn_overlap_32k_fx );
/* perFORm spectral flip and downmix with overlap snippet to match HB synth */
- IF( ( element_mode == EVS_MONO && ( rf_flag || total_brate == ACELP_9k60 ) ) || ( element_mode > EVS_MONO && L_frame == L_FRAME ) )
+ test();
+ test();
+ test();
+ test();
+ IF( ( ( element_mode == EVS_MONO ) && ( rf_flag || EQ_32( total_brate, ACELP_9k60 ) ) ) || ( ( element_mode > EVS_MONO ) && EQ_16( L_frame, L_FRAME ) ) )
{
flip_and_downmix_generic_fx_32( syn_overlap_32k_fx, syn_overlap_32k_fx, 2 * SHB_OVERLAP_LEN, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx + HILBERT_ORDER1, hBWE_TD->genSHBsynth_Hilbert_Mem_fx + ( HILBERT_ORDER1 + 2 * HILBERT_ORDER2 ), &( hBWE_TD->syn_dm_phase ) );
}
@@ -4432,7 +4636,16 @@ void GenTransition_fixed(
{
FOR( i = 0; i < 2 * SHB_OVERLAP_LEN; i++ )
{
- syn_overlap_32k_fx[i] = ( ( i % 2 ) == 0 ) ? ( -syn_overlap_32k_fx[i] ) : ( syn_overlap_32k_fx[i] );
+ IF( i % 2 == 0 )
+ {
+ syn_overlap_32k_fx[i] = L_negate( syn_overlap_32k_fx[i] );
+ move32();
+ }
+ ELSE
+ {
+ syn_overlap_32k_fx[i] = syn_overlap_32k_fx[i];
+ move32();
+ }
}
}
@@ -4440,19 +4653,21 @@ void GenTransition_fixed(
FOR( i = 0; i < 2 * L_SHB_LAHEAD; i++ )
{
outputHB_fx[i] = L_add_sat( Mpy_32_16_1( hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i], window_shb_32k_fx[i] ), Mpy_32_16_1( syn_overlap_32k_fx[i], window_shb_32k_fx[2 * L_SHB_LAHEAD - 1 - i] ) );
+ move32();
}
/* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */
FOR( ; i < length; i++ )
{
outputHB_fx[i] = hBWE_TD->old_tbe_synth_fx[L_SHB_TRANSITION_LENGTH - 1 - i];
+ move32();
}
- IF( output_Fs == 48000 )
+ IF( EQ_32( output_Fs, 48000 ) )
{
interpolate_3_over_2_allpass_32( outputHB_fx, length, outputHB_fx, hBWE_TD->int_3_over_2_tbemem_dec_fx_32 );
}
- ELSE IF( output_Fs == 16000 )
+ ELSE IF( EQ_32( output_Fs, 16000 ) )
{
Decimate_allpass_steep_fx32( outputHB_fx, hBWE_TD->mem_resamp_HB_32k_fx_32, L_FRAME32k, outputHB_fx );
}
@@ -4531,7 +4746,7 @@ void GenTransition_WB_fixed(
Word32 upsampled_synth_fx[L_FRAME48k];
/* set targeted length of transition signal */
- length = 2 * NS2SA( output_Fs, DELAY_BWE_TOTAL_NS );
+ length = i_mult( 2, NS2SA( output_Fs, DELAY_BWE_TOTAL_NS ) );
/* upsample overlap snippet */
Interpolate_allpass_steep_32( hBWE_TD->syn_overlap_fx_32, hBWE_TD->state_lsyn_filt_shb_fx_32, SHB_OVERLAP_LEN / 2, speech_buf_16k1_fx );
@@ -4540,30 +4755,43 @@ void GenTransition_WB_fixed(
/* perform spectral flip and downmix with overlap snippet to match HB synth */
FOR( i = 0; i < SHB_OVERLAP_LEN; i++ )
{
- speech_buf_16k2_fx[i] = ( ( i % 2 ) == 0 ) ? ( -speech_buf_16k2_fx[i] ) : ( speech_buf_16k2_fx[i] );
+ IF( i % 2 == 0 )
+ {
+ speech_buf_16k2_fx[i] = L_negate( speech_buf_16k2_fx[i] );
+ move32();
+ }
+ ELSE
+ {
+ speech_buf_16k2_fx[i] = speech_buf_16k2_fx[i];
+ move32();
+ }
}
/* cross fade of overlap snippet and mirrored HB synth from previous frame */
FOR( i = 0; i < L_SHB_LAHEAD; i++ )
{
outputHB_fx[i] = L_add( Mpy_32_16_1( hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i], window_shb_fx[i] ), Mpy_32_16_1( speech_buf_16k2_fx[i], window_shb_fx[L_SHB_LAHEAD - 1 - i] ) );
+ move32();
outputHB_fx[i] = Mpy_32_16_1( outputHB_fx[i], 21299 );
+ move32();
}
/* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */
FOR( ; i < length; i++ )
{
outputHB_fx[i] = hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i];
+ move32();
outputHB_fx[i] = Mpy_32_16_1( outputHB_fx[i], 21299 );
+ move32();
}
/* upsampling if necessary */
- IF( output_Fs == 32000 )
+ IF( EQ_32( output_Fs, 32000 ) )
{
Interpolate_allpass_steep_32( outputHB_fx, hBWE_TD->mem_resamp_HB_fx_32, L_FRAME16k, upsampled_synth_fx );
Copy32( upsampled_synth_fx, outputHB_fx, L_FRAME32k );
}
- ELSE IF( output_Fs == 48000 )
+ ELSE IF( EQ_32( output_Fs, 48000 ) )
{
interpolate_3_over_1_allpass_32( outputHB_fx, L_FRAME16k, upsampled_synth_fx, hBWE_TD->mem_resamp_HB_fx_32 );
Copy32( upsampled_synth_fx, outputHB_fx, L_FRAME48k );
diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c
index 11421e1e1d0acb9401a32fd2e2db1c73f77c3b74..b986d136bfb3a01bc5a6d824092fb11648271f73 100644
--- a/lib_dec/swb_tbe_dec_fx.c
+++ b/lib_dec/swb_tbe_dec_fx.c
@@ -6,8 +6,7 @@
#include
#include "options.h"
#include "rom_com.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_dec.h"
#include "stl.h"
@@ -52,8 +51,11 @@ static void find_max_mem_dec(
Word16 i;
Word16 n_mem_32;
Word16 max = 0;
+ move16();
Word32 Lmax = 0;
+ move32();
Word16 tempQ15, max2 = 0;
+ move16();
Word16 max3;
Word32 tempQ32, Lmax3;
TD_BWE_DEC_HANDLE hBWE_TD;
@@ -98,8 +100,12 @@ static void find_max_mem_dec(
/* for total_brate > 16.4kbps, use n_mem2; else account for the max2 for n_mem calculation */
*n_mem2 = norm_s( max2 );
+ move16();
if ( max2 == 0 )
+ {
*n_mem2 = 15;
+ move16();
+ }
if ( LT_32( st_fx->total_brate, ACELP_24k40 ) )
{
@@ -126,9 +132,11 @@ static void find_max_mem_dec(
}
/* estimate the norm for 16-bit memories */
*n_mem = norm_s( max );
+ move16();
if ( max == 0 )
{
*n_mem = 15;
+ move16();
}
/* estimate the norm for 32-bit memories */
@@ -138,10 +146,12 @@ static void find_max_mem_dec(
if ( Lmax == 0 )
{
n_mem_32 = 31;
+ move16();
}
tempQ15 = sub( s_min( *n_mem, n_mem_32 ), 1 );
*n_mem = s_max( tempQ15, 0 );
+ move16();
/* --------------------------------------------------------------*/
/* Find headroom for synthesis stage associated with these memories:
@@ -149,6 +159,7 @@ static void find_max_mem_dec(
2. st_fx->genSHBsynth_state_lsyn_filt_shb_local
3. st_fx->genSHBsynth_Hilbert_Mem_fx (32-bit) */
max3 = 0;
+ move16();
/* find max in prev overlapSyn */
FOR( i = 0; i < L_SHB_LAHEAD; i++ )
{
@@ -180,10 +191,15 @@ static void find_max_mem_dec(
}
/* estimate the norm for 16-bit memories */
*n_mem3 = norm_s( max3 );
+ move16();
if ( max3 == 0 )
+ {
*n_mem3 = 15;
+ move16();
+ }
Lmax3 = 0;
+ move32();
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
/* find max in prev genSHBsynth_Hilbert_Mem_fx */
@@ -197,11 +213,15 @@ static void find_max_mem_dec(
/* estimate the norm for 32-bit memories */
n_mem_32 = norm_l( Lmax3 );
if ( Lmax3 == 0 )
+ {
n_mem_32 = 31;
+ move16();
+ }
tempQ15 = sub( s_min( *n_mem3, n_mem_32 ), 2 ); /* very important leave at least 2 bit head room
because of the Hilber transform and Q14 coeffs */
*n_mem3 = s_max( tempQ15, 0 );
+ move16();
/* --------------------------------------------------------------*/
}
@@ -246,7 +266,7 @@ static void rescale_genSHB_mem_dec(
}
}
- IF( EQ_16( st_fx->extl, FB_TBE ) )
+ if ( EQ_16( st_fx->extl, FB_TBE ) )
{
}
hBWE_TD->mem_csfilt_fx[0] = L_shl( hBWE_TD->mem_csfilt_fx[0], sf );
@@ -262,7 +282,9 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )
{
Word16 i;
Word16 max = 0;
+ move16();
Word32 Lmax = 0;
+ move32();
Word16 n_mem_32;
TD_BWE_DEC_HANDLE hBWE_TD;
hBWE_TD = st_fx->hBWE_TD;
@@ -274,34 +296,34 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )
FOR( i = 0; i < 7; i++ )
{
- if ( abs_s( hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i] ) > max )
+ if ( GT_16( abs_s( hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i] ), max ) )
max = abs_s( hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i] );
}
FOR( i = 0; i < 7; i++ )
{
- if ( abs_s( hBWE_TD->mem_genSHBexc_filt_down_wb2_fx[i] ) > max )
+ if ( GT_16( abs_s( hBWE_TD->mem_genSHBexc_filt_down_wb2_fx[i] ), max ) )
max = abs_s( hBWE_TD->mem_genSHBexc_filt_down_wb2_fx[i] );
}
FOR( i = 0; i < 7; i++ )
{
- if ( abs_s( hBWE_TD->mem_genSHBexc_filt_down_wb3_fx[i] ) > max )
+ if ( GT_16( abs_s( hBWE_TD->mem_genSHBexc_filt_down_wb3_fx[i] ), max ) )
max = abs_s( hBWE_TD->mem_genSHBexc_filt_down_wb3_fx[i] );
}
FOR( i = 0; i < 10; i++ )
{
- if ( abs_s( hBWE_TD->state_lpc_syn_fx[i] ) > max )
+ if ( GT_16( abs_s( hBWE_TD->state_lpc_syn_fx[i] ), max ) )
max = abs_s( hBWE_TD->state_lpc_syn_fx[i] );
}
FOR( i = 0; i < 5; i++ )
{
- if ( abs_s( hBWE_TD->state_syn_shbexc_fx[i] ) > max )
+ if ( GT_16( abs_s( hBWE_TD->state_syn_shbexc_fx[i] ), max ) )
max = abs_s( hBWE_TD->state_syn_shbexc_fx[i] );
}
@@ -320,7 +342,7 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )
FOR( i = 0; i < 2; i++ )
{
- if ( L_abs( hBWE_TD->mem_csfilt_fx[i] ) > Lmax )
+ if ( GT_32( L_abs( hBWE_TD->mem_csfilt_fx[i] ), Lmax ) )
Lmax = L_abs( hBWE_TD->mem_csfilt_fx[i] );
}
@@ -335,7 +357,9 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )
}
*n_mem = sub( s_min( *n_mem, n_mem_32 ), 1 );
+ move16();
*n_mem = s_max( *n_mem, 0 );
+ move16();
}
void rescale_genWB_mem( Decoder_State *st_fx, Word16 sf )
@@ -413,10 +437,13 @@ void InitSWBdecBuffer_ivas_fx(
hBWE_TD->syn_dm_phase = 0;
move16();
hBWE_TD->prev_fbbwe_ratio_fx = 32767 /*1.0f Q15*/;
+ move16();
/* these are fd-bwe constants */
- hBWE_TD->prev_wb_bwe_frame_pow_fx = 4194l /*0.001f Q22*/; /* Q22 */
+ hBWE_TD->prev_wb_bwe_frame_pow_fx = 4194l /*0.001f Q22*/; /* Q22 */
+ move32();
hBWE_TD->prev_swb_bwe_frame_pow_fx = 4194l /*0.001f Q22*/; /* Q22 */
+ move32();
st_fx->prev_Q_bwe_exc = 31;
move16();
st_fx->prev_ener_fx_Q = 31;
@@ -455,10 +482,13 @@ void InitSWBdecBuffer_fx(
hBWE_TD->syn_dm_phase = 0;
move16();
hBWE_TD->prev_fbbwe_ratio_fx = 32767 /*1.0f Q15*/;
+ move16();
/* these are fd-bwe constants */
- hBWE_TD->prev_wb_bwe_frame_pow_fx = 4194l /*0.001f Q22*/; /* Q22 */
+ hBWE_TD->prev_wb_bwe_frame_pow_fx = 4194l /*0.001f Q22*/; /* Q22 */
+ move32();
hBWE_TD->prev_swb_bwe_frame_pow_fx = 4194l /*0.001f Q22*/; /* Q22 */
+ move32();
st_fx->prev_Q_bwe_exc = 31;
move16();
st_fx->prev_ener_fx_Q = 31;
@@ -483,7 +513,7 @@ void ResetSHBbuffer_Dec_fx( Decoder_State *st_fx /* i/o: SHB encoder structure *
TD_BWE_DEC_HANDLE hBWE_TD;
hBWE_TD = st_fx->hBWE_TD;
- IF( st_fx->extl != WB_TBE )
+ IF( NE_16( st_fx->extl, WB_TBE ) )
{
f = 1489;
move16(); /* Q15 */
@@ -528,7 +558,7 @@ void ResetSHBbuffer_Dec_fx( Decoder_State *st_fx /* i/o: SHB encoder structure *
/* States for FEC */
- IF( st_fx->extl != WB_TBE )
+ IF( NE_16( st_fx->extl, WB_TBE ) )
{
FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
@@ -558,12 +588,17 @@ void ResetSHBbuffer_Dec_fx( Decoder_State *st_fx /* i/o: SHB encoder structure *
hBWE_TD->GainAttn_fx = 32767;
move16(); /*Q15*/
hBWE_TD->tbe_demph_fx = 0;
+ move16();
hBWE_TD->tbe_premph_fx = 0;
+ move16();
set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER );
hBWE_TD->gain_prec_swb_fx = 16384; /*Q14 =1*/
+ move16();
set16_fx( &st_fx->GainShape_Delay[0], 0, NUM_SHB_SUBFR / 2 );
hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */
- hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 1.f*/
+ move32();
+ hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 1.f*/
+ move16();
set16_fx( hBWE_TD->old_core_synth_fx, 0, L_FRAME16k );
set16_fx( hBWE_TD->old_tbe_synth_fx, 0, L_SHB_TRANSITION_LENGTH );
@@ -625,24 +660,30 @@ void ivas_wb_tbe_dec_fx(
Word16 Q_bwe_exc, Q_bwe_exc_ext, Qx;
Word16 n_mem, cnt;
Word16 max = 0;
+ move16();
Word32 L_tmp, Lacc, Lscale, Lmax = 0;
+ move32();
Word16 tmp, exp, sc;
Word16 vf_modified[NB_SUBFR16k];
Word16 uv_flag = 0;
+ move16();
Word16 dummy = 0;
- Word32 dummy2[HILBERT_MEM_SIZE] = { 0 };
+ move16();
+ Word32 dummy2[HILBERT_MEM_SIZE];
Word16 f, inc;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
TD_BWE_DEC_HANDLE hBWE_TD;
hBWE_TD = st_fx->hBWE_TD;
-
+ set_val_Word32( &dummy2[0], 0, HILBERT_MEM_SIZE );
IF( st_fx->bws_cnt == 0 )
{
/* Initialization */
set16_fx( GainShape, 11469 /*0.35f Q15*/, NUM_SHB_SUBFR );
GainFrame = 1;
+ move32();
IF( !st_fx->bfi )
{
@@ -651,11 +692,13 @@ void ivas_wb_tbe_dec_fx(
IF( NE_16( st_fx->last_extl, WB_TBE ) )
{
hBWE_TD->GainFrame_prevfrm_fx = 0;
+ move32();
hBWE_TD->lsp_prevfrm_fx[0] = 3277 /*0.1f Q15*/;
move16();
FOR( i = 1; i < LPC_SHB_ORDER_LBR_WB; i++ )
{
hBWE_TD->lsp_prevfrm_fx[i] = add( hBWE_TD->lsp_prevfrm_fx[i - i], 3277 /*0.1f Q15*/ );
+ move16();
}
}
Copy( hBWE_TD->lsp_prevfrm_fx, lsf_wb, LPC_SHB_ORDER_LBR_WB );
@@ -665,8 +708,14 @@ void ivas_wb_tbe_dec_fx(
{
/* Frame gain */
st_fx->rf_indx_tbeGainFr = s_and( st_fx->rf_indx_tbeGainFr, 0xF ); /* only four LSBs are valid */
+ move16();
Copy32( SHBCB_FrameGain16_fx + st_fx->rf_indx_tbeGainFr, &GainFrame, 1 );
- IF( EQ_16( st_fx->core, ACELP_CORE ) && EQ_16( st_fx->last_core, ACELP_CORE ) && !st_fx->prev_use_partial_copy && EQ_16( st_fx->prev_coder_type, UNVOICED ) && NE_32( GainFrame, hBWE_TD->GainFrame_prevfrm_fx ) && EQ_16( st_fx->last_extl, WB_TBE ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( st_fx->core == ACELP_CORE ) && ( st_fx->last_core == ACELP_CORE ) && !st_fx->prev_use_partial_copy && EQ_16( st_fx->prev_coder_type, UNVOICED ) && NE_32( GainFrame, hBWE_TD->GainFrame_prevfrm_fx ) && EQ_16( st_fx->last_extl, WB_TBE ) )
{
/*GainFrame = 0.2f*GainFrame + 0.8f*st_fx->GainFrame_prevfrm_fx;*/
GainFrame = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 26214 ), Mult_32_16( GainFrame, 6553 ) );
@@ -681,30 +730,42 @@ void ivas_wb_tbe_dec_fx(
{
case 0:
GainFrame = 131072; /* 0.5f in Q18 */
- IF( LE_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) )
- temp = 26214 /*0.8 Q15*/;
- move16();
+ move32();
+ if ( LE_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) )
+ {
+ temp = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
case 1:
GainFrame = 524288; /* 2.0f in Q18 */
- IF( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) )
- temp = 26214 /*0.8 Q15*/;
- move16();
+ move32();
test();
+ if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) )
+ {
+ temp = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
case 2:
GainFrame = 1048576; /* 4.0f in Q18 */
- IF( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) )
- temp = 26214 /*0.8 Q15*/;
- move16();
+ move32();
test();
+ if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) )
+ {
+ temp = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
case 3:
GainFrame = 2097152; /* 8.0f in Q18 */
- IF( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 4194304l /*16 Q18*/ ) )
- temp = 26214 /*0.8 Q15*/;
- move16();
+ move32();
test();
+ if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 4194304l /*16 Q18*/ ) )
+ {
+ temp = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
default:
fprintf( stderr, "RF SWB-TBE gain bits not supported." );
@@ -714,8 +775,13 @@ void ivas_wb_tbe_dec_fx(
GainFrame = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, temp ), Mult_32_16( GainFrame, sub( 32767, temp ) ) );
}
- IF( EQ_16( st_fx->core, ACELP_CORE ) && EQ_16( st_fx->last_core, ACELP_CORE ) )
+ test();
+ IF( ( st_fx->core == ACELP_CORE ) && ( st_fx->last_core == ACELP_CORE ) )
{
+ test();
+ test();
+ test();
+ test();
IF( !st_fx->prev_use_partial_copy && EQ_16( st_fx->last_coder_type, VOICED ) && EQ_16( st_fx->rf_frame_type, RF_GENPRED ) && LT_16( st_fx->prev_tilt_code_dec_fx, 1497 ) && GT_16( st_fx->prev_tilt_code_dec_fx, 200 ) )
{
GainFrame = Mult_32_16( GainFrame, 9830 );
@@ -752,10 +818,11 @@ void ivas_wb_tbe_dec_fx(
ELSE
{
GainFrame = hBWE_TD->GainFrame_prevfrm_fx; /*Q18*/
+ move32();
}
}
- IF( st_fx->extl_brate == WB_TBE_0k35 )
+ IF( EQ_32( st_fx->extl_brate, WB_TBE_0k35 ) )
{
/* convert LSPs back into LP coeffs */
lsp2lpc_fx( lpc_wb + 1, lsf_wb, st_fx->prev_lpc_wb_fx, LPC_SHB_ORDER_LBR_WB );
@@ -792,14 +859,14 @@ void ivas_wb_tbe_dec_fx(
}
Copy( voice_factors, vf_modified, NB_SUBFR16k );
- IF( coder_type == VOICED )
+ IF( EQ_16( coder_type, VOICED ) )
{
FOR( i = 1; i < NB_SUBFR; i++ )
{
vf_modified[i] = add( mult_r( 26214, voice_factors[i] ), mult_r( 6554, voice_factors[i - 1] ) ); /* Q15 */
move16();
}
- IF( st_fx->L_frame != L_FRAME )
+ IF( NE_16( st_fx->L_frame, L_FRAME ) )
{
vf_modified[4] = add( mult_r( 26214, voice_factors[4] ), mult_r( 6554, voice_factors[3] ) ); /* Q15 */
move16();
@@ -808,29 +875,50 @@ void ivas_wb_tbe_dec_fx(
/* From low band excitation, generate highband excitation */
Lmax = 0;
+ move32();
FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ )
{
Lmax = L_max( Lmax, L_abs( bwe_exc_extended[cnt] ) );
}
- Q_bwe_exc = ( Lmax == 0 ) ? 31 : norm_l( Lmax );
+ IF( Lmax == 0 )
+ {
+ Q_bwe_exc = 31;
+ move16();
+ }
+ ELSE
+ {
+ Q_bwe_exc = norm_l( Lmax );
+ }
Q_bwe_exc = sub( Q_bwe_exc, 3 );
Q_bwe_exc = add( Q_bwe_exc, add( Q_exc, Q_exc ) );
find_max_mem_wb( st_fx, &n_mem );
- IF( sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) > n_mem )
+ if ( GT_16( sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ), n_mem ) )
{
Q_bwe_exc = add( st_fx->prev_Q_bwe_exc, n_mem );
}
test();
- IF( uv_flag && GT_16( Q_bwe_exc, 20 ) )
+ if ( uv_flag && GT_16( Q_bwe_exc, 20 ) )
{
Q_bwe_exc = 20;
move16(); /* restrict this to 21 due to the Q factor requireemnt of the random number generator (keep 1 bit headroom) */
}
prev_pow = 0;
+ move32();
+#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE
+ IF( st_fx->element_mode > EVS_MONO )
+ {
+ tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 );
+#ifdef BASOP_NOGLOB
+ prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
+#else
+ prev_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
+#endif
+ }
+#endif
FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
{
prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
@@ -842,6 +930,7 @@ void ivas_wb_tbe_dec_fx(
FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ )
{
bwe_exc_extended_16[cnt] = round_fx( L_shl( bwe_exc_extended[cnt], sc ) );
+ move16();
}
Copy( hBWE_TD->state_syn_shbexc_fx, shaped_wb_excitation, L_SHB_LAHEAD / 4 );
@@ -854,12 +943,24 @@ void ivas_wb_tbe_dec_fx(
bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf );
curr_pow = 0;
+ move32();
+#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE
+ IF( st_fx->element_mode > EVS_MONO )
+ {
+ tmp = sub( shl( Q_bwe_exc_ext, 1 ), 31 + 16 );
+#ifdef BASOP_NOGLOB
+ curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(Q_bwe_exc_ext))*/
+#else
+ curr_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc_ext) */
+#endif
+ }
+#endif
FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
{
curr_pow = L_mac0( curr_pow, shaped_wb_excitation[i + L_SHB_LAHEAD / 4], shaped_wb_excitation[i + L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */
}
- IF( GT_16( voice_factors[0], 24576 ) )
+ if ( GT_16( voice_factors[0], 24576 ) )
{
curr_pow = L_shr( curr_pow, 2 ); /* Q(2*Q_bwe_exc_ext) */
}
@@ -871,10 +972,12 @@ void ivas_wb_tbe_dec_fx(
{
L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */
shaped_wb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc_ext */
+ move16();
}
- Lscale = root_a_fx( Lscale, 31 - exp, &exp );
+ Lscale = root_a_fx( Lscale, sub( 31, exp ), &exp );
L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] ); /* Q(16-exp+Q_bwe_exc_ext) */
shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc_ext */
+ move16();
/* Update SHB excitation */
Copy( shaped_wb_excitation + L_FRAME16k / 4, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 );
@@ -887,6 +990,7 @@ void ivas_wb_tbe_dec_fx(
Q_bwe_exc_ext, st_fx->L_frame, 0, &dummy, dummy, dummy2 );
max = 0;
+ move16();
FOR( i = 0; i < L_FRAME16k / 4; i++ )
{
max = s_max( max, abs_s( shaped_wb_excitation[i] ) );
@@ -914,6 +1018,7 @@ void ivas_wb_tbe_dec_fx(
}
n = sub( 14, n );
curr_frame_pow = 1;
+ move32();
FOR( i = 0; i < L_FRAME16k / 4; i++ )
{
#ifdef BASOP_NOGLOB
@@ -931,12 +1036,15 @@ void ivas_wb_tbe_dec_fx(
{
curr_frame_pow = L_shr( curr_frame_pow, sub( st_fx->prev_frame_pow_exp, curr_frame_pow_exp ) );
curr_frame_pow_exp = st_fx->prev_frame_pow_exp;
+ move16();
}
ELSE
{
hBWE_TD->prev_wb_bwe_frame_pow_fx = L_shr( hBWE_TD->prev_wb_bwe_frame_pow_fx, sub( curr_frame_pow_exp, st_fx->prev_frame_pow_exp ) );
+ move32();
}
+ test();
test();
IF( !st_fx->bfi && ( st_fx->prev_bfi || st_fx->prev_use_partial_copy ) )
{
@@ -945,24 +1053,26 @@ void ivas_wb_tbe_dec_fx(
L_tmp = root_a_over_b_fx( hBWE_TD->prev_wb_bwe_frame_pow_fx, 22, curr_frame_pow, 22, &exp );
scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
temp = round_fx( L_shl( L_tmp, exp ) ); /* Q15 */
}
ELSE
{
scale = temp = 32767;
move16(); /* Q15 */
+ move16();
}
FOR( j = 0; j < 8; j++ )
{
GainShape[2 * j] = mult_r( GainShape[2 * j], scale );
- GainShape[2 * j + 1] = mult_r( GainShape[2 * j + 1], scale );
+ GainShape[add( 2 * j, 1 )] = mult_r( GainShape[add( 2 * j, 1 )], scale );
FOR( i = 0; i < L_FRAME16k / ( 4 * 8 ); i++ )
{
- shaped_wb_excitation[i + j * L_FRAME16k / ( 4 * 8 )] = mult_r( shaped_wb_excitation[i + j * L_FRAME16k / ( 4 * 8 )], scale );
+ shaped_wb_excitation[add( i, j * ( L_FRAME16k / ( 4 * 8 ) ) )] = mult_r( shaped_wb_excitation[add( i, j * ( L_FRAME16k / ( 4 * 8 ) ) )], scale );
+ move16();
}
IF( temp > 0 )
{
@@ -994,13 +1104,13 @@ void ivas_wb_tbe_dec_fx(
move16();
FOR( cnt = 0; cnt < ( L_FRAME16k + L_SHB_LAHEAD ) / 4; cnt++ )
{
- IF( abs_s( shaped_wb_excitation[cnt] ) > max )
+ if ( GT_16( abs_s( shaped_wb_excitation[cnt] ), max ) )
{
max = abs_s( shaped_wb_excitation[cnt] );
}
}
Qx = norm_s( max );
- IF( max == 0 )
+ if ( max == 0 )
{
Qx = 15;
move16();
@@ -1012,14 +1122,14 @@ void ivas_wb_tbe_dec_fx(
move16();
FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
{
- IF( abs_s( hBWE_TD->state_lsyn_filt_shb_fx[i] ) > max )
- max = abs_s( hBWE_TD->state_lsyn_filt_shb_fx[i] );
+ if ( GT_16( abs_s( hBWE_TD->state_lsyn_filt_shb_fx[i] ), max ) )
+ max = abs_s( hBWE_TD->state_lsyn_filt_shb_fx[i] );
}
FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
{
- IF( abs_s( hBWE_TD->state_lsyn_filt_dwn_shb_fx[i] ) > max )
- max = abs_s( hBWE_TD->state_lsyn_filt_dwn_shb_fx[i] );
+ if ( GT_16( abs_s( hBWE_TD->state_lsyn_filt_dwn_shb_fx[i] ), max ) )
+ max = abs_s( hBWE_TD->state_lsyn_filt_dwn_shb_fx[i] );
}
IF( EQ_32( st_fx->output_Fs, 32000 ) )
@@ -1037,14 +1147,15 @@ void ivas_wb_tbe_dec_fx(
}
}
n_mem = 15;
- IF( max != 0 )
+ move16();
+ if ( max != 0 )
{
n_mem = norm_s( max );
}
n_mem = s_max( n_mem, 0 );
- IF( sub( Qx, st_fx->prev_Qx ) > n_mem )
- Qx = add( st_fx->prev_Qx, n_mem );
+ if ( GT_16( sub( Qx, st_fx->prev_Qx ), n_mem ) )
+ Qx = add( st_fx->prev_Qx, n_mem );
FOR( i = 0; i < ( L_FRAME16k + L_SHB_LAHEAD ) / 4; i++ )
{
@@ -1097,6 +1208,7 @@ void ivas_wb_tbe_dec_fx(
n = sub( sub( 14, n ), Qx );
Lacc = 0;
+ move32();
FOR( i = 0; i < L_FRAME16k; i++ )
{
L_tmp = L_mult( synth_frac[i], synth_frac[i] ); /* Q29 */
@@ -1112,8 +1224,9 @@ void ivas_wb_tbe_dec_fx(
#endif
exp = sub( add( exp, 22 ), 30 );
tmp = div_s( 16384, tmp );
- L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */
- st_fx->last_wb_bwe_ener_fx = round_fx( L_shl( L_tmp, add( exp, n - 12 ) ) ); /* Q3 */
+ L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */
+ st_fx->last_wb_bwe_ener_fx = round_fx( L_shl( L_tmp, add( exp, sub( n, 12 ) ) ) ); /* Q3 */
+ move16();
}
@@ -1148,9 +1261,13 @@ void ivas_wb_tbe_dec_fx(
move16();
}
GainFrame = 0; /* Q18 */
+ move32();
Qx = 0;
+ move16();
Q_bwe_exc = 31;
+ move16();
hBWE_TD->prev_wb_bwe_frame_pow_fx = 4194l /*0.001f Q22*/; /* Q22 */
+ move32();
st_fx->prev_frame_pow_exp = 0;
move16();
}
@@ -1165,8 +1282,9 @@ void ivas_wb_tbe_dec_fx(
Copy( lsf_wb, hBWE_TD->lsp_prevfrm_fx, LPC_SHB_ORDER_WB );
}
hBWE_TD->GainFrame_prevfrm_fx = GainFrame; /* Q18 */
+ move32();
- IF( !st_fx->bfi )
+ if ( !st_fx->bfi )
{
hBWE_TD->GainAttn_fx = 32767;
move16();
@@ -1211,24 +1329,30 @@ void wb_tbe_dec_fx(
Word16 Q_bwe_exc, Q_bwe_exc_ext, Qx;
Word16 n_mem, cnt;
Word16 max = 0;
+ move16();
Word32 L_tmp, Lacc, Lscale, Lmax = 0;
+ move32();
Word16 tmp, exp, sc;
Word16 vf_modified[NB_SUBFR16k];
Word16 uv_flag = 0;
+ move16();
Word16 dummy = 0;
- Word32 dummy2[HILBERT_MEM_SIZE] = { 0 };
+ move16();
+ Word32 dummy2[HILBERT_MEM_SIZE];
Word16 f, inc;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
TD_BWE_DEC_HANDLE hBWE_TD;
hBWE_TD = st_fx->hBWE_TD;
-
+ set_val_Word32( &dummy2[0], 0, HILBERT_MEM_SIZE );
IF( st_fx->bws_cnt == 0 )
{
/* Initialization */
set16_fx( GainShape, 11469 /*0.35f Q15*/, NUM_SHB_SUBFR );
GainFrame = 1;
+ move32();
IF( !st_fx->bfi )
{
@@ -1237,11 +1361,13 @@ void wb_tbe_dec_fx(
IF( NE_16( st_fx->last_extl, WB_TBE ) )
{
hBWE_TD->GainFrame_prevfrm_fx = 0;
+ move32();
hBWE_TD->lsp_prevfrm_fx[0] = 3277 /*0.1f Q15*/;
move16();
FOR( i = 1; i < LPC_SHB_ORDER_LBR_WB; i++ )
{
hBWE_TD->lsp_prevfrm_fx[i] = add( hBWE_TD->lsp_prevfrm_fx[i - i], 3277 /*0.1f Q15*/ );
+ move16();
}
}
Copy( hBWE_TD->lsp_prevfrm_fx, lsf_wb, LPC_SHB_ORDER_LBR_WB );
@@ -1251,8 +1377,14 @@ void wb_tbe_dec_fx(
{
/* Frame gain */
st_fx->rf_indx_tbeGainFr = s_and( st_fx->rf_indx_tbeGainFr, 0xF ); /* only four LSBs are valid */
+ move16();
Copy32( SHBCB_FrameGain16_fx + st_fx->rf_indx_tbeGainFr, &GainFrame, 1 );
- IF( EQ_16( st_fx->core, ACELP_CORE ) && EQ_16( st_fx->last_core, ACELP_CORE ) && !st_fx->prev_use_partial_copy && EQ_16( st_fx->prev_coder_type, UNVOICED ) && NE_32( GainFrame, hBWE_TD->GainFrame_prevfrm_fx ) && EQ_16( st_fx->last_extl, WB_TBE ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( st_fx->core == ACELP_CORE ) && ( st_fx->last_core == ACELP_CORE ) && !st_fx->prev_use_partial_copy && EQ_16( st_fx->prev_coder_type, UNVOICED ) && NE_32( GainFrame, hBWE_TD->GainFrame_prevfrm_fx ) && EQ_16( st_fx->last_extl, WB_TBE ) )
{
/*GainFrame = 0.2f*GainFrame + 0.8f*st_fx->GainFrame_prevfrm_fx;*/
GainFrame = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 26214 ), Mult_32_16( GainFrame, 6553 ) );
@@ -1267,30 +1399,42 @@ void wb_tbe_dec_fx(
{
case 0:
GainFrame = 131072; /* 0.5f in Q18 */
- IF( LE_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) )
- temp = 26214 /*0.8 Q15*/;
- move16();
+ move32();
+ if ( LE_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) )
+ {
+ temp = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
case 1:
GainFrame = 524288; /* 2.0f in Q18 */
- IF( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) )
- temp = 26214 /*0.8 Q15*/;
- move16();
+ move32();
test();
+ if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) )
+ {
+ temp = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
case 2:
GainFrame = 1048576; /* 4.0f in Q18 */
- IF( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) )
- temp = 26214 /*0.8 Q15*/;
- move16();
+ move32();
test();
+ if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) )
+ {
+ temp = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
case 3:
GainFrame = 2097152; /* 8.0f in Q18 */
- IF( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 4194304l /*16 Q18*/ ) )
- temp = 26214 /*0.8 Q15*/;
- move16();
+ move32();
test();
+ if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 4194304l /*16 Q18*/ ) )
+ {
+ temp = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
default:
fprintf( stderr, "RF SWB-TBE gain bits not supported." );
@@ -1300,8 +1444,13 @@ void wb_tbe_dec_fx(
GainFrame = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, temp ), Mult_32_16( GainFrame, sub( 32767, temp ) ) );
}
- IF( EQ_16( st_fx->core, ACELP_CORE ) && EQ_16( st_fx->last_core, ACELP_CORE ) )
+ test();
+ IF( ( st_fx->core == ACELP_CORE ) && ( st_fx->last_core == ACELP_CORE ) )
{
+ test();
+ test();
+ test();
+ test();
IF( !st_fx->prev_use_partial_copy && EQ_16( st_fx->last_coder_type, VOICED ) && EQ_16( st_fx->rf_frame_type, RF_GENPRED ) && LT_16( st_fx->prev_tilt_code_dec_fx, 1497 ) && GT_16( st_fx->prev_tilt_code_dec_fx, 200 ) )
{
GainFrame = Mult_32_16( GainFrame, 9830 );
@@ -1337,14 +1486,15 @@ void wb_tbe_dec_fx(
ELSE
{
GainFrame = hBWE_TD->GainFrame_prevfrm_fx; /*Q18*/
+ move32();
}
}
- IF( st_fx->extl_brate == WB_TBE_0k35 )
+ IF( EQ_32( st_fx->extl_brate, WB_TBE_0k35 ) )
{
/* convert LSPs back into LP coeffs */
lsp2lpc_fx( lpc_wb + 1, lsf_wb, st_fx->prev_lpc_wb_fx, LPC_SHB_ORDER_LBR_WB );
- set16_fx( lpc_wb + LPC_SHB_ORDER_LBR_WB + 1, 0, ( LPC_SHB_ORDER_WB - LPC_SHB_ORDER_LBR_WB ) );
+ set16_fx( lpc_wb + LPC_SHB_ORDER_LBR_WB + 1, 0, LPC_SHB_ORDER_WB - LPC_SHB_ORDER_LBR_WB );
FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ )
{
st_fx->prev_lpc_wb_fx[i] = lpc_wb[i + 1];
@@ -1377,14 +1527,14 @@ void wb_tbe_dec_fx(
}
Copy( voice_factors, vf_modified, NB_SUBFR16k );
- IF( coder_type == VOICED )
+ IF( EQ_16( coder_type, VOICED ) )
{
FOR( i = 1; i < NB_SUBFR; i++ )
{
vf_modified[i] = add( mult_r( 26214, voice_factors[i] ), mult_r( 6554, voice_factors[i - 1] ) ); /* Q15 */
move16();
}
- IF( st_fx->L_frame != L_FRAME )
+ IF( NE_16( st_fx->L_frame, L_FRAME ) )
{
vf_modified[4] = add( mult_r( 26214, voice_factors[4] ), mult_r( 6554, voice_factors[3] ) ); /* Q15 */
move16();
@@ -1393,17 +1543,26 @@ void wb_tbe_dec_fx(
/* From low band excitation, generate highband excitation */
Lmax = 0;
+ move32();
FOR( cnt = 0; cnt < L_FRAME32k; cnt++ )
{
Lmax = L_max( Lmax, L_abs( bwe_exc_extended[cnt] ) );
}
- Q_bwe_exc = ( Lmax == 0 ) ? 31 : norm_l( Lmax );
+ IF( Lmax == 0 )
+ {
+ Q_bwe_exc = 31;
+ move16();
+ }
+ ELSE
+ {
+ Q_bwe_exc = norm_l( Lmax );
+ }
Q_bwe_exc = sub( Q_bwe_exc, 1 );
Q_bwe_exc = add( Q_bwe_exc, add( Q_exc, Q_exc ) );
find_max_mem_wb( st_fx, &n_mem );
- if ( sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) > n_mem )
+ if ( GT_16( sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ), n_mem ) )
{
Q_bwe_exc = add( st_fx->prev_Q_bwe_exc, n_mem );
}
@@ -1416,6 +1575,18 @@ void wb_tbe_dec_fx(
}
prev_pow = 0;
+ move32();
+#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE
+ IF( st_fx->element_mode > EVS_MONO )
+ {
+ tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 );
+#ifdef BASOP_NOGLOB
+ prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
+#else
+ prev_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
+#endif
+ }
+#endif
FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
{
#ifdef BASOP_NOGLOB
@@ -1449,6 +1620,18 @@ void wb_tbe_dec_fx(
bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf );
curr_pow = 0;
+ move32();
+#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE
+ IF( st_fx->element_mode > EVS_MONO )
+ {
+ tmp = sub( shl( Q_bwe_exc_ext, 1 ), 31 + 16 );
+#ifdef BASOP_NOGLOB
+ curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(Q_bwe_exc_ext))*/
+#else
+ curr_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc_ext) */
+#endif
+ }
+#endif
FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
{
#ifdef BASOP_NOGLOB
@@ -1474,8 +1657,9 @@ void wb_tbe_dec_fx(
#else
shaped_wb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc_ext */
#endif
+ move16();
}
- Lscale = root_a_fx( Lscale, 31 - exp, &exp );
+ Lscale = root_a_fx( Lscale, sub( 31, exp ), &exp );
L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] ); /* Q(16-exp+Q_bwe_exc_ext) */
shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc_ext */
@@ -1490,6 +1674,7 @@ void wb_tbe_dec_fx(
Q_bwe_exc_ext, st_fx->L_frame, 0, &dummy, dummy, dummy2 );
max = 0;
+ move16();
FOR( i = 0; i < L_FRAME16k / 4; i++ )
{
max = s_max( max, shaped_wb_excitation[i] ); /*Q0*/
@@ -1498,7 +1683,7 @@ void wb_tbe_dec_fx(
IF( max == 0 )
{
curr_frame_pow = 1;
- move16();
+ move32();
n = 0;
move16();
}
@@ -1517,6 +1702,7 @@ void wb_tbe_dec_fx(
}
n = sub( 14, n );
curr_frame_pow = 1;
+ move32();
FOR( i = 0; i < L_FRAME16k / 4; i++ )
{
#ifdef BASOP_NOGLOB
@@ -1534,10 +1720,12 @@ void wb_tbe_dec_fx(
{
curr_frame_pow = L_shr( curr_frame_pow, sub( st_fx->prev_frame_pow_exp, curr_frame_pow_exp ) );
curr_frame_pow_exp = st_fx->prev_frame_pow_exp;
+ move16();
}
ELSE
{
hBWE_TD->prev_wb_bwe_frame_pow_fx = L_shr( hBWE_TD->prev_wb_bwe_frame_pow_fx, sub( curr_frame_pow_exp, st_fx->prev_frame_pow_exp ) );
+ move32();
}
test();
@@ -1548,24 +1736,25 @@ void wb_tbe_dec_fx(
L_tmp = root_a_over_b_fx( hBWE_TD->prev_wb_bwe_frame_pow_fx, 22, curr_frame_pow, 22, &exp );
scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
temp = round_fx( L_shl( L_tmp, exp ) ); /* Q15 */
}
ELSE
{
scale = temp = 32767;
move16(); /* Q15 */
+ move16();
}
FOR( j = 0; j < 8; j++ )
{
GainShape[2 * j] = mult_r( GainShape[2 * j], scale );
- GainShape[2 * j + 1] = mult_r( GainShape[2 * j + 1], scale );
+ GainShape[add( 2 * j, 1 )] = mult_r( GainShape[add( 2 * j, 1 )], scale );
FOR( i = 0; i < L_FRAME16k / ( 4 * 8 ); i++ )
{
- shaped_wb_excitation[i + j * L_FRAME16k / ( 4 * 8 )] = mult_r( shaped_wb_excitation[i + j * L_FRAME16k / ( 4 * 8 )], scale );
+ shaped_wb_excitation[add( i, j * ( L_FRAME16k / ( 4 * 8 ) ) )] = mult_r( shaped_wb_excitation[add( i, j * ( L_FRAME16k / ( 4 * 8 ) ) )], scale );
}
IF( temp > 0 )
{
@@ -1597,7 +1786,7 @@ void wb_tbe_dec_fx(
move16();
FOR( cnt = 0; cnt < ( L_FRAME16k + L_SHB_LAHEAD ) / 4; cnt++ )
{
- if ( abs_s( shaped_wb_excitation[cnt] ) > max )
+ if ( GT_16( abs_s( shaped_wb_excitation[cnt] ), max ) )
{
max = abs_s( shaped_wb_excitation[cnt] );
}
@@ -1615,13 +1804,13 @@ void wb_tbe_dec_fx(
move16();
FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
{
- if ( abs_s( hBWE_TD->state_lsyn_filt_shb_fx[i] ) > max )
+ if ( GT_16( abs_s( hBWE_TD->state_lsyn_filt_shb_fx[i] ), max ) )
max = abs_s( hBWE_TD->state_lsyn_filt_shb_fx[i] );
}
FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
{
- if ( abs_s( hBWE_TD->state_lsyn_filt_dwn_shb_fx[i] ) > max )
+ if ( GT_16( abs_s( hBWE_TD->state_lsyn_filt_dwn_shb_fx[i] ), max ) )
max = abs_s( hBWE_TD->state_lsyn_filt_dwn_shb_fx[i] );
}
@@ -1640,13 +1829,14 @@ void wb_tbe_dec_fx(
}
}
n_mem = 15;
+ move16();
if ( max != 0 )
{
n_mem = norm_s( max );
}
n_mem = s_max( n_mem, 0 );
- if ( sub( Qx, st_fx->prev_Qx ) > n_mem )
+ if ( GT_16( sub( Qx, st_fx->prev_Qx ), n_mem ) )
Qx = add( st_fx->prev_Qx, n_mem );
FOR( i = 0; i < ( L_FRAME16k + L_SHB_LAHEAD ) / 4; i++ )
@@ -1700,6 +1890,7 @@ void wb_tbe_dec_fx(
n = sub( sub( 14, n ), Qx );
Lacc = 0;
+ move32();
FOR( i = 0; i < L_FRAME16k; i++ )
{
L_tmp = L_mult( synth_frac[i], synth_frac[i] ); /* Q29 */
@@ -1717,10 +1908,11 @@ void wb_tbe_dec_fx(
tmp = div_s( 16384, tmp );
L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* Q(31-exp) */
#ifdef BASOP_NOGLOB
- st_fx->last_wb_bwe_ener_fx = round_fx_sat( L_shl_sat( L_tmp, add( exp, n - 12 ) ) ); /* Q3 */
+ st_fx->last_wb_bwe_ener_fx = round_fx_sat( L_shl_sat( L_tmp, add( exp, sub( n, 12 ) ) ) ); /* Q3 */
#else
st_fx->last_wb_bwe_ener_fx = round_fx( L_shl( L_tmp, add( exp, n - 12 ) ) ); /* Q3 */
#endif
+ move16();
}
@@ -1755,9 +1947,13 @@ void wb_tbe_dec_fx(
move16();
}
GainFrame = 0; /* Q18 */
+ move32();
Qx = 0;
+ move16();
Q_bwe_exc = 31;
+ move16();
hBWE_TD->prev_wb_bwe_frame_pow_fx = 4194l /*0.001f Q22*/; /* Q22 */
+ move32();
st_fx->prev_frame_pow_exp = 0;
move16();
}
@@ -1772,8 +1968,9 @@ void wb_tbe_dec_fx(
Copy( lsf_wb, hBWE_TD->lsp_prevfrm_fx, LPC_SHB_ORDER_WB );
}
hBWE_TD->GainFrame_prevfrm_fx = GainFrame; /* Q18 */
+ move32();
- if ( !st_fx->bfi )
+ IF( !st_fx->bfi )
{
hBWE_TD->GainAttn_fx = 32767;
move16();
@@ -1883,6 +2080,7 @@ void swb_tbe_dec_fx(
Word16 mean_vf;
Word16 exp_ener, inv_ener;
Word32 prev_ener_ratio_fx = 0; /* initialize just to avoid compiler warning */
+ move32();
Word16 max, n, temp, shaped_shb_excitation_frac[L_FRAME16k + L_SHB_LAHEAD];
Word32 curr_frame_pow;
Word16 curr_frame_pow_exp;
@@ -1902,7 +2100,7 @@ void swb_tbe_dec_fx(
move16();
set16_fx( shb_res_gshape, 1638 /*0.1f Q14*/, NB_SUBFR16k ); /* Q14 */
Q_shb = 0; /* high band target Q factor set to zero */
-
+ move16();
L_tmp = calc_tilt_bwe_fx( old_syn_12k8_16k, st_fx->Q_syn2, st_fx->L_frame );
#ifdef BASOP_NOGLOB
tilt_swb_fec = round_fx_sat( L_shl_sat( L_tmp, 3 ) );
@@ -1912,7 +2110,7 @@ void swb_tbe_dec_fx(
/* i: old_syn_12k8_16k in st_fx->Q_syn2 */
/* o: tilt_swb_fec in Q11 */
test();
- IF( st_fx->bfi && NE_16( st_fx->clas_dec, UNVOICED_CLAS ) )
+ if ( st_fx->bfi && st_fx->clas_dec != UNVOICED_CLAS )
{
tilt_swb_fec = hBWE_TD->tilt_swb_fec_fx;
move16();
@@ -1921,7 +2119,7 @@ void swb_tbe_dec_fx(
/* WB/SWB bandwidth switching */
test();
test();
- IF( ( GT_16( st_fx->tilt_wb_fx, 10240 ) && EQ_16( st_fx->clas_dec, UNVOICED_CLAS ) ) || GT_16( st_fx->tilt_wb_fx, 20480 ) )
+ IF( ( GT_16( st_fx->tilt_wb_fx, 10240 ) && ( st_fx->clas_dec == UNVOICED_CLAS ) ) || GT_16( st_fx->tilt_wb_fx, 20480 ) )
{
test();
test();
@@ -1930,7 +2128,8 @@ void swb_tbe_dec_fx(
test();
test();
test();
- IF( ( st_fx->prev_fractive == 0 &&
+ test();
+ IF( ( ( st_fx->prev_fractive == 0 ) &&
( LT_32( st_fx->prev_enerLH_fx, L_shl( st_fx->enerLH_fx, 1 ) ) && GT_32( st_fx->prev_enerLH_fx, L_shr( st_fx->enerLH_fx, 1 ) ) && LT_32( st_fx->prev_enerLL_fx, L_shl( st_fx->enerLL_fx, 1 ) ) && GT_32( st_fx->prev_enerLL_fx, L_shr( st_fx->enerLL_fx, 1 ) ) ) ) ||
( EQ_16( st_fx->prev_fractive, 1 ) &&
GT_32( L_shr( st_fx->prev_enerLH_fx, 2 ), Mult_32_16( st_fx->enerLH_fx, 24576 ) ) ) /* 24576 in Q13*/
@@ -1951,8 +2150,10 @@ void swb_tbe_dec_fx(
/* WB/SWB bandwidth switching */
IF( st_fx->bws_cnt > 0 )
{
- f_fx = 1489; /*Q15*/
+ f_fx = 1489; /*Q15*/
+ move16();
inc_fx = 1489; /*Q15*/
+ move16();
IF( EQ_16( is_fractive, 1 ) )
{
Copy( lsf_tab_fx, hBWE_TD->lsp_prevfrm_fx, LPC_SHB_ORDER );
@@ -1974,8 +2175,8 @@ void swb_tbe_dec_fx(
test();
test();
IF( ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) &&
- !( L_sub( L_shr( st_fx->prev_enerLH_fx, 1 ), st_fx->enerLH_fx ) < 0 && L_sub( st_fx->prev_enerLH_fx, L_shr( st_fx->enerLH_fx, 1 ) > 0 ) ) ) ||
- sub( st_fx->last_core, ACELP_CORE ) != 0 || ( sub( st_fx->last_core, ACELP_CORE ) == 0 && L_sub( L_abs( L_sub( st_fx->last_core_brate, st_fx->core_brate ) ), 3600 ) > 0 ) || sub( ( is_fractive ^ st_fx->prev_fractive ), 1 ) == 0 )
+ !( ( L_sub( L_shr( st_fx->prev_enerLH_fx, 1 ), st_fx->enerLH_fx ) < 0 ) && L_sub( st_fx->prev_enerLH_fx, ( L_shr( st_fx->enerLH_fx, 1 ) > 0 ) ) ) ) ||
+ ( sub( st_fx->last_core, ACELP_CORE ) != 0 ) || ( ( sub( st_fx->last_core, ACELP_CORE ) == 0 ) && ( L_sub( L_abs( L_sub( st_fx->last_core_brate, st_fx->core_brate ) ), 3600 ) > 0 ) ) || ( sub( s_xor( is_fractive, st_fx->prev_fractive ), 1 ) == 0 ) )
{
set16_fx( GainShape, 11587, NUM_SHB_SUBFR );
}
@@ -2017,11 +2218,10 @@ void swb_tbe_dec_fx(
{
hBWE_TD->GainFrame_prevfrm_fx = 0;
move16();
+ f_fx = 1489 /*0.045454f Q15*/;
move16();
- move16();
- f_fx = 1489 /*0.045454f Q15*/; /*Q15*/
inc_fx = 1489 /*0.045454f Q15*/;
- ; /*Q15*/
+ move16();
FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
hBWE_TD->lsp_prevfrm_fx[i] = f_fx;
@@ -2042,7 +2242,13 @@ void swb_tbe_dec_fx(
frac = L_Extract_lc( L_tmp, &exp );
L_tmp = Pow2( 30, frac );
GainFrame = L_shl( L_tmp, sub( exp, 12 ) ); /*Q18*/
- IF( EQ_16( st_fx->core, ACELP_CORE ) && EQ_16( st_fx->last_core, ACELP_CORE ) && !st_fx->prev_use_partial_copy && EQ_16( st_fx->prev_coder_type, UNVOICED ) && NE_32( GainFrame, hBWE_TD->GainFrame_prevfrm_fx ) && NE_16( st_fx->next_coder_type, GENERIC ) && EQ_16( st_fx->last_extl, SWB_TBE ) )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( st_fx->core == ACELP_CORE ) && ( st_fx->last_core == ACELP_CORE ) && !st_fx->prev_use_partial_copy && EQ_16( st_fx->prev_coder_type, UNVOICED ) && NE_32( GainFrame, hBWE_TD->GainFrame_prevfrm_fx ) && NE_16( st_fx->next_coder_type, GENERIC ) && EQ_16( st_fx->last_extl, SWB_TBE ) )
{
/*GainFrame = 0.2f*GainFrame + 0.8f*st_fx->GainFrame_prevfrm_fx;*/
GainFrame = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 26214 ), Mult_32_16( GainFrame, 6553 ) );
@@ -2057,30 +2263,42 @@ void swb_tbe_dec_fx(
{
case 0:
GainFrame = 131072; /* 0.5f in Q18 */
- IF( LE_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) )
- temp = 26214 /*0.8 Q15*/;
- move16();
+ move32();
+ if ( LE_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) )
+ {
+ temp = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
case 1:
GainFrame = 524288; /* 2.0f in Q18 */
- IF( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) )
- temp = 26214 /*0.8 Q15*/;
- move16();
+ move32();
test();
+ if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) )
+ {
+ temp = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
case 2:
GainFrame = 1048576; /* 4.0f in Q18 */
- IF( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) )
- temp = 26214 /*0.8 Q15*/;
- move16();
+ move32();
test();
+ if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) )
+ {
+ temp = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
case 3:
GainFrame = 2097152; /* 8.0f in Q18 */
- IF( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 4194304l /*16Q18*/ ) )
- temp = 26214 /*0.8 Q15*/;
- move16();
+ move32();
test();
+ if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 4194304l /*16Q18*/ ) )
+ {
+ temp = 26214 /*0.8 Q15*/;
+ move16();
+ }
BREAK;
default:
fprintf( stderr, "RF SWB-TBE gain bits not supported." );
@@ -2089,9 +2307,14 @@ void swb_tbe_dec_fx(
{
GainFrame = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, temp ), Mult_32_16( GainFrame, sub( 32767, temp ) ) );
}
- IF( EQ_16( st_fx->core, ACELP_CORE ) && EQ_16( st_fx->last_core, ACELP_CORE ) )
+ test();
+ IF( ( st_fx->core == ACELP_CORE ) && ( st_fx->last_core == ACELP_CORE ) )
{
- IF( !st_fx->prev_use_partial_copy && EQ_16( st_fx->last_coder_type, VOICED ) && EQ_16( st_fx->rf_frame_type, RF_GENPRED ) && GT_32( GainFrame, 2097152 ) && LT_32( GainFrame, 3059606 ) )
+ test();
+ test();
+ test();
+ test();
+ if ( !st_fx->prev_use_partial_copy && EQ_16( st_fx->last_coder_type, VOICED ) && EQ_16( st_fx->rf_frame_type, RF_GENPRED ) && GT_32( GainFrame, 2097152 ) && LT_32( GainFrame, 3059606 ) )
{
GainFrame = Mult_32_16( GainFrame, 9830 );
}
@@ -2130,11 +2353,11 @@ void swb_tbe_dec_fx(
{
FOR( j = 0; j < 4; j++ )
{
- GainShape[i * 4 + j] = mult_r( st_fx->cummulative_damping, st_fx->GainShape_Delay[4 + i] );
+ GainShape[add( i * 4, j )] = mult_r( st_fx->cummulative_damping, st_fx->GainShape_Delay[4 + i] );
move16();
}
}
- IF( GT_16( tilt_swb_fec, 8 << 11 ) ) /* tilt_swb_fec in Q11 */
+ IF( GT_16( tilt_swb_fec, ( 8 << 11 ) ) ) /* tilt_swb_fec in Q11 */
{
IF( EQ_16( st_fx->nbLostCmpt, 1 ) )
{
@@ -2169,7 +2392,7 @@ void swb_tbe_dec_fx(
tmp1 = extract_l( hBWE_TD->prev1_shb_ener_sf_fx ); /*Q0*/
i = sub( norm_s( tmp1 ), 1 );
tmp1 = shl( tmp1, i ); /* Qi */
- if ( tmp == 0 )
+ IF( tmp == 0 )
{
tmp = 32767 /*1.0f Q15*/;
move16(); /*Q15*/
@@ -2180,7 +2403,7 @@ void swb_tbe_dec_fx(
scale = s_max( scale, 0 );
/*scale = st->prev_res_shb_gshape * min(scale, 1.0f); */
#ifdef BASOP_NOGLOB
- tmp = shl_sat( scale, 15 - exp - i ); /*Q15*/
+ tmp = shl_sat( scale, sub( sub( 15, exp ), i ) ); /*Q15*/
#else
tmp = shl( scale, 15 - exp - i ); /*Q15*/
#endif
@@ -2225,6 +2448,7 @@ void swb_tbe_dec_fx(
shb_ener_sf_32 = L_max( shb_ener_sf_32, 1l /*1.0f Q0*/ );
mixFactors = hBWE_TD->prev_mixFactors_fx;
+ move16();
IF( EQ_16( st_fx->codec_mode, MODE1 ) )
{
@@ -2300,15 +2524,15 @@ void swb_tbe_dec_fx(
test();
test();
test();
- IF( st_fx->bws_cnt == 0 && st_fx->bws_cnt1 == 0 && st_fx->prev_use_partial_copy == 0 && st_fx->use_partial_copy == 0 )
+ IF( ( st_fx->bws_cnt == 0 ) && ( st_fx->bws_cnt1 == 0 ) && ( st_fx->prev_use_partial_copy == 0 ) && ( st_fx->use_partial_copy == 0 ) )
{
lsf_diff[0] = 16384;
move16(); /*Q15*/
- lsf_diff[sub( LPC_SHB_ORDER, 1 )] = 16384;
+ lsf_diff[LPC_SHB_ORDER - 1] = 16384;
move16(); /*Q15*/
FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ )
{
- lsf_diff[i] = sub( lsf_shb[i], lsf_shb[sub( i, 1 )] );
+ lsf_diff[i] = sub( lsf_shb[i], lsf_shb[i - 1] );
move16();
}
@@ -2346,11 +2570,12 @@ void swb_tbe_dec_fx(
tmp = mult( 26214, lsf_diff[i] );
test();
- IF( hBWE_TD->prev_lsf_diff_fx[i - 1] <= 0 || tmp < 0 ) /* safety check in case of bit errors */
+ IF( ( hBWE_TD->prev_lsf_diff_fx[i - 1] <= 0 ) || ( tmp < 0 ) ) /* safety check in case of bit errors */
{
st_fx->BER_detect = 1;
move16();
tmp = 0;
+ move16();
}
ELSE
{
@@ -2366,11 +2591,12 @@ void swb_tbe_dec_fx(
tmp = mult( 26214, hBWE_TD->prev_lsf_diff_fx[i - 1] );
test();
- IF( lsf_diff[i] <= 0 || tmp < 0 ) /* safety check in case of bit errors */
+ IF( ( lsf_diff[i] <= 0 ) || ( tmp < 0 ) ) /* safety check in case of bit errors */
{
st_fx->BER_detect = 1;
move16();
tmp = 0;
+ move16();
}
ELSE
{
@@ -2383,7 +2609,9 @@ void swb_tbe_dec_fx(
}
}
w[0] = w[1];
- w[sub( LPC_SHB_ORDER, 1 )] = w[sub( LPC_SHB_ORDER, 2 )];
+ move16();
+ w[LPC_SHB_ORDER - 1] = w[LPC_SHB_ORDER - 2];
+ move16();
FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
@@ -2401,6 +2629,7 @@ void swb_tbe_dec_fx(
Copy( lsf_diff + 1, hBWE_TD->prev_lsf_diff_fx, LPC_SHB_ORDER - 2 );
hBWE_TD->prev_tilt_para_fx = tilt_para;
+ move16();
}
ELSE
{
@@ -2427,7 +2656,7 @@ void swb_tbe_dec_fx(
/* convert from lsp to lsf */
/*old code: lsp2lsf_fx(lsp_temp, lsp_temp, LPC_SHB_ORDER, INT_FS_FX); */ /* input lsp_temp_fx in Q15*/
- tmp = i_mult( j, ( LPC_SHB_ORDER + 1 ) );
+ tmp = i_mult( j, LPC_SHB_ORDER + 1 );
/* convert LSPs to LP coefficients */
E_LPC_f_lsp_a_conversion( lsp_temp, lpc_shb_sf + tmp, LPC_SHB_ORDER );
/* Bring the LPCs to Q12 */
@@ -2447,10 +2676,15 @@ void swb_tbe_dec_fx(
/* save the shb_ener Q18, prev_resgainshape Q14, and mixFactor Q15 values */
hBWE_TD->prev3_shb_ener_sf_fx = hBWE_TD->prev2_shb_ener_sf_fx;
+ move32();
hBWE_TD->prev2_shb_ener_sf_fx = hBWE_TD->prev1_shb_ener_sf_fx;
+ move32();
hBWE_TD->prev1_shb_ener_sf_fx = shb_ener_sf_32;
+ move32();
hBWE_TD->prev_res_shb_gshape_fx = shb_res_gshape[4];
+ move16();
hBWE_TD->prev_mixFactors_fx = mixFactors;
+ move16();
/* SWB CNG/DTX - update memories */
Copy( st_fx->lsp_shb_prev_fx, st_fx->lsp_shb_prev_prev_fx, LPC_SHB_ORDER ); /* Q15 */
@@ -2468,6 +2702,7 @@ void swb_tbe_dec_fx(
/* -------- start of memory rescaling -------- */
/* ----- calculate optimum Q_bwe_exc and rescale memories accordingly ----- */
Lmax = 0;
+ move32();
FOR( cnt = 0; cnt < L_FRAME32k; cnt++ )
{
Lmax = L_max( Lmax, L_abs( bwe_exc_extended[cnt] ) );
@@ -2476,6 +2711,7 @@ void swb_tbe_dec_fx(
if ( Lmax == 0 )
{
Q_bwe_exc = 31;
+ move16();
}
Q_bwe_exc = add( Q_bwe_exc, add( Q_exc, Q_exc ) );
@@ -2486,6 +2722,7 @@ void swb_tbe_dec_fx(
if ( GT_16( Q_bwe_exc, tmp ) )
{
Q_bwe_exc = tmp;
+ move16();
}
/* rescale the memories if Q_bwe_exc is different from previous frame */
@@ -2526,7 +2763,7 @@ void swb_tbe_dec_fx(
{
FOR( j = 0; j < 4; j++ )
{
- Copy( lpc_shb, &lpc_shb_sf[j * ( LPC_SHB_ORDER + 1 )], LPC_SHB_ORDER + 1 );
+ Copy( lpc_shb, &lpc_shb_sf[i_mult( j, LPC_SHB_ORDER + 1 )], LPC_SHB_ORDER + 1 );
}
}
@@ -2539,6 +2776,7 @@ void swb_tbe_dec_fx(
&( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate, st_fx->prev_bfi );
*Q_white_exc = Q_bwe_exc_fb;
+ move16();
IF( EQ_16( st_fx->extl, FB_TBE ) )
{
st_fx->prev_Q_bwe_exc_fb = Q_bwe_exc_fb;
@@ -2554,7 +2792,7 @@ void swb_tbe_dec_fx(
/* rescale the TBE post proc memory */
FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
- hBWE_TD->mem_stp_swb_fx[i] = shl( hBWE_TD->mem_stp_swb_fx[i], Q_bwe_exc - st_fx->prev_Q_bwe_syn );
+ hBWE_TD->mem_stp_swb_fx[i] = shl( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, st_fx->prev_Q_bwe_syn ) );
move16();
}
@@ -2600,11 +2838,13 @@ void swb_tbe_dec_fx(
{
L_tmp = Mult_32_16( Lscale, shaped_shb_excitation[i] ); /* Q_bwe_exc + (31-exp) - 15 */
shaped_shb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */
+ move16();
}
IF( exp < 0 )
{
Lscale = L_shl( Lscale, exp );
exp = 0;
+ move16();
}
FOR( ; i < L_SHB_LAHEAD + 10; i++ )
{
@@ -2619,6 +2859,7 @@ void swb_tbe_dec_fx(
Lscale = L_add( Mult_32_16( Lscale, temp ), L_tmp1 );
L_tmp = Mult_32_16( Lscale, shaped_shb_excitation[i] ); /* Q_bwe_exc + (31-exp) - 15 */
shaped_shb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */
+ move16();
}
/* Update SHB excitation */
@@ -2626,17 +2867,19 @@ void swb_tbe_dec_fx(
l_subframe_fx = L_FRAME16k / NUM_SHB_SUBGAINS;
L_ener = 0;
+ move32();
FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ )
{
L_tmp = 0;
+ move32();
ener_tmp[i] = 0;
-
+ move32();
{
Word64 tmp64 = 0;
move64();
FOR( j = 0; j < l_subframe_fx; j++ )
{
- tmp64 = W_mac0_16_16( tmp64, shaped_shb_excitation[i * l_subframe_fx + j], shaped_shb_excitation[i * l_subframe_fx + j] ); /* 2*Q_bwe_exc */
+ tmp64 = W_mac0_16_16( tmp64, shaped_shb_excitation[add( i_mult( i, l_subframe_fx ), j )], shaped_shb_excitation[add( i_mult( i, l_subframe_fx ), j )] ); /* 2*Q_bwe_exc */
}
L_tmp = W_sat_l( tmp64 );
}
@@ -2646,7 +2889,7 @@ void swb_tbe_dec_fx(
{
exp = norm_l( L_tmp );
tmp = extract_h( L_shl( L_tmp, exp ) );
- exp = sub( exp, 30 - ( 2 * Q_bwe_exc ) );
+ exp = sub( exp, sub( 30, i_mult( 2, Q_bwe_exc ) ) );
tmp = div_s( 16384, tmp );
L_tmp = L_deposit_h( tmp );
@@ -2691,7 +2934,7 @@ void swb_tbe_dec_fx(
move16();
}
test();
- if ( st_fx->prev_fractive == 1 && GT_16( st_fx->tilt_wb_fx, 1024 ) )
+ if ( EQ_16( st_fx->prev_fractive, 1 ) && GT_16( st_fx->tilt_wb_fx, 1024 ) )
{
st_fx->tilt_wb_fx = 1024;
move16();
@@ -2704,15 +2947,18 @@ void swb_tbe_dec_fx(
IF( st_fx->prev_fractive == 0 )
{
st_fx->tilt_wb_fx = 8192;
+ move16();
}
ELSE
{
st_fx->tilt_wb_fx = 16384;
+ move16();
}
}
ELSE
{
st_fx->tilt_wb_fx = shl( st_fx->tilt_wb_fx, 2 );
+ move16();
}
}
@@ -2731,6 +2977,7 @@ void swb_tbe_dec_fx(
#else
st_fx->tilt_wb_fx = extract_h( L_shr( Mult_32_16( st_fx->enerLH_fx, inv_ener ), sub( sub( st_fx->Q_syn2, exp_ener ), 16 ) ) ); /*Q11*/
#endif
+ move16();
/*st_fx->Q_syn2 -1 + 26- exp_ener -15 -(st_fx->Q_syn2 -exp_ener -16 ) -16 +1 -1 = (11) *0.5*/
}
ELSE IF( LT_32( L_tmp, Mult_32_16( st_fx->enerLH_fx, 1638 ) ) && EQ_16( is_fractive, 1 ) )
@@ -2740,6 +2987,7 @@ void swb_tbe_dec_fx(
#else
st_fx->tilt_wb_fx = extract_h( L_shr( Mult_32_16( st_fx->enerLH_fx, inv_ener ), sub( sub( st_fx->Q_syn2, exp_ener ), 15 ) ) ); /*Q11*/
#endif
+ move16();
/*st_fx->Q_syn2 -1 + 26- exp_ener -15 -(st_fx->Q_syn2 -exp_ener -15 ) -16 = (11) 0.25*/
}
L_tmp = L_mult0( st_fx->prev_ener_shb_fx, inv_ener ); /*Q(1+15+14-3-exp_ener) = 27 -exp_ener*/
@@ -2752,19 +3000,20 @@ void swb_tbe_dec_fx(
ELSE
{
GainFrame_prevfrm_fx = 0;
+ move32();
}
IF( EQ_16( is_fractive, 1 ) )
{
- GainFrame = L_shl( (Word32) st_fx->tilt_wb_fx, 10 );
+ GainFrame = L_shl( L_deposit_l( st_fx->tilt_wb_fx ), 10 );
}
ELSE
{
- GainFrame = L_shl( (Word32) st_fx->tilt_wb_fx, 8 );
+ GainFrame = L_shl( L_deposit_l( st_fx->tilt_wb_fx ), 8 );
}
test();
- IF( EQ_16( ( is_fractive & st_fx->prev_fractive ), 1 ) && GT_32( GainFrame, GainFrame_prevfrm_fx ) )
+ IF( EQ_16( s_and( is_fractive, st_fx->prev_fractive ), 1 ) && GT_32( GainFrame, GainFrame_prevfrm_fx ) )
{
GainFrame = L_add( Mult_32_16( GainFrame_prevfrm_fx, 26214 ), Mult_32_16( GainFrame, 6554 ) ); /* 18 +15 -15 = 18*/
}
@@ -2774,14 +3023,14 @@ void swb_tbe_dec_fx(
test();
test();
test();
- IF( ( LT_32( L_shr( st_fx->prev_enerLH_fx, 1 ), st_fx->enerLH_fx ) && GT_32( st_fx->prev_enerLH_fx, L_shr( st_fx->enerLH_fx, 1 ) ) ) && ( LT_32( L_shr( st_fx->prev_enerLL_fx, 1 ), st_fx->enerLL_fx ) && GT_32( st_fx->prev_enerLL_fx, L_shr( st_fx->enerLL_fx, 1 ) ) ) && ( is_fractive ^ st_fx->prev_fractive ) == 0 )
+ IF( ( LT_32( L_shr( st_fx->prev_enerLH_fx, 1 ), st_fx->enerLH_fx ) && GT_32( st_fx->prev_enerLH_fx, L_shr( st_fx->enerLH_fx, 1 ) ) ) && ( LT_32( L_shr( st_fx->prev_enerLL_fx, 1 ), st_fx->enerLL_fx ) && GT_32( st_fx->prev_enerLL_fx, L_shr( st_fx->enerLL_fx, 1 ) ) ) && ( s_xor( is_fractive, st_fx->prev_fractive ) == 0 ) )
{
GainFrame = L_add( L_shr( GainFrame, 1 ), L_shr( GainFrame_prevfrm_fx, 1 ) );
}
ELSE
{
test();
- IF( is_fractive == 0 && EQ_16( st_fx->prev_fractive, 1 ) )
+ IF( ( is_fractive == 0 ) && EQ_16( st_fx->prev_fractive, 1 ) )
{
L_tmp1 = L_shl( Mult_32_16( GainFrame, 3277 ), 13 ); /* 31 */
L_tmp = L_sub( 2147483647, L_tmp1 ); /* 31 */
@@ -2798,7 +3047,7 @@ void swb_tbe_dec_fx(
}
ELSE
{
- IF( st_fx->bws_cnt1 > 0 )
+ if ( st_fx->bws_cnt1 > 0 )
{
GainFrame = Mult_32_16( GainFrame, i_mult( st_fx->bws_cnt1, 819 ) ); /*Q18*/
}
@@ -2827,7 +3076,7 @@ void swb_tbe_dec_fx(
test();
test();
test();
- IF( NE_16( st_fx->clas_dec, UNVOICED_CLAS ) && NE_16( st_fx->clas_dec, UNVOICED_TRANSITION ) && LT_16( hBWE_TD->tilt_swb_fec_fx, 16384 ) &&
+ IF( ( st_fx->clas_dec != UNVOICED_CLAS ) && NE_16( st_fx->clas_dec, UNVOICED_TRANSITION ) && LT_16( hBWE_TD->tilt_swb_fec_fx, 16384 ) &&
( ( GT_32( st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx, 1 ) ) && LT_32( L_shr( st_fx->enerLL_fx, 1 ), st_fx->prev_enerLL_fx ) ) || ( GT_32( st_fx->enerLH_fx, L_shr( st_fx->prev_enerLH_fx, 1 ) ) && LT_32( L_shr( st_fx->enerLH_fx, 1 ), st_fx->prev_enerLH_fx ) ) ) )
{
IF( GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame ) ) /*18*/
@@ -2844,7 +3093,7 @@ void swb_tbe_dec_fx(
}
test();
- IF( GT_16( tilt_swb_fec, hBWE_TD->tilt_swb_fec_fx ) && hBWE_TD->tilt_swb_fec_fx > 0 )
+ IF( GT_16( tilt_swb_fec, hBWE_TD->tilt_swb_fec_fx ) && ( hBWE_TD->tilt_swb_fec_fx > 0 ) )
{
exp = norm_s( hBWE_TD->tilt_swb_fec_fx );
tmp = shl( hBWE_TD->tilt_swb_fec_fx, exp ); /*Q(11+exp)*/
@@ -2853,7 +3102,7 @@ void swb_tbe_dec_fx(
GainFrame = L_shl( Mult_32_16( GainFrame, s_min( tmp, 20480 ) ), 3 ); /*Q18 = 18 +12 -15 +3 */
}
}
- ELSE IF( ( NE_16( st_fx->clas_dec, UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 16384 ) ) && GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame ) &&
+ ELSE IF( ( ( st_fx->clas_dec != UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 16384 ) ) && GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame ) &&
( GT_32( st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx, 1 ) ) || GT_32( st_fx->enerLH_fx, L_shr( st_fx->prev_enerLH_fx, 1 ) ) ) )
{
GainFrame = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 ), Mult_32_16( GainFrame, 26214 ) );
@@ -2934,7 +3183,7 @@ void swb_tbe_dec_fx(
{
FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ )
{
- GainShape_tmp[i] = GainShape[shl( i, 2 )]; /* Q15 */
+ GainShape_tmp[i] = GainShape[i * 4]; /* Q15 */
move16();
}
@@ -2954,6 +3203,7 @@ void swb_tbe_dec_fx(
/*GainShape_tmp_fx[i] = 0.5f*(L_tmp2/ener_tmp_fx[i] + GainShape_tmp_fx[i]);*/
/* tmp = L_tmp2/ener_tmp_fx[i]*/
L_tmp = L_tmp2;
+ move32();
if ( L_tmp2 < 0 )
{
L_tmp = L_negate( L_tmp2 );
@@ -2965,11 +3215,11 @@ void swb_tbe_dec_fx(
#else
fracb = round_fx( L_shl( L_tmp, expb ) );
#endif
- expb = 30 - expb; /* - (2*Q_bwe_exc_ext); */
+ expb = sub( 30, expb ); /* - (2*Q_bwe_exc_ext); */
expa = norm_l( ener_tmp[i] );
fraca = extract_h( L_shl( ener_tmp[i], expa ) );
- expa = 30 - expa;
+ expa = sub( 30, expa );
scale = shr( sub( fraca, fracb ), 15 );
fracb = shl( fracb, scale );
@@ -2979,15 +3229,25 @@ void swb_tbe_dec_fx(
exp = sub( sub( expb, expa ), 1 );
tmp = shl( tmp, exp );
GainShape_tmp[i] = add( tmp, shr( GainShape_tmp[i], 1 ) ); /* Q15 */
+ move16();
}
hBWE_TD->prev_ener_fx = ener_tmp[i];
+ move32();
hBWE_TD->prev_GainShape_fx = GainShape_tmp[i];
+ move16();
st_fx->prev_ener_fx_Q = Q_bwe_exc;
+ move16();
}
FOR( i = 0; i < NUM_SHB_SUBFR; i++ )
{
- GainShape[i] = GainShape_tmp[i * NUM_SHB_SUBGAINS / NUM_SHB_SUBFR];
+ Word16 idx = 0;
+ move16();
+ IF( i != 0 )
+ {
+ idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR );
+ }
+ GainShape[i] = GainShape_tmp[idx];
move16();
}
}
@@ -3019,6 +3279,7 @@ void swb_tbe_dec_fx(
max = 0;
+ move16();
FOR( i = 0; i < L_FRAME16k; i++ )
{
max = s_max( max, shaped_shb_excitation[i] ); /* Q0 */
@@ -3035,6 +3296,7 @@ void swb_tbe_dec_fx(
{
n = norm_s( max );
max = 0;
+ move16();
FOR( i = 0; i < L_FRAME16k; i++ )
{
#ifdef BASOP_NOGLOB
@@ -3047,6 +3309,7 @@ void swb_tbe_dec_fx(
}
curr_frame_pow = 0;
+ move32();
FOR( i = 0; i < L_FRAME16k; i++ )
{
L_tmp = L_mult0( shaped_shb_excitation_frac[i], shaped_shb_excitation_frac[i] ); /*2*(Q_bwe_exc+n)*/
@@ -3062,9 +3325,12 @@ void swb_tbe_dec_fx(
IF( GT_16( tmp, 32 ) )
{
st_fx->prev_frame_pow_exp = add( curr_frame_pow_exp, 32 );
+ move16();
tmp = 32;
+ move16();
}
hBWE_TD->prev_swb_bwe_frame_pow_fx = L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, tmp );
+ move32();
st_fx->prev_frame_pow_exp = curr_frame_pow_exp;
move16();
}
@@ -3074,9 +3340,11 @@ void swb_tbe_dec_fx(
{
curr_frame_pow_exp = sub( st_fx->prev_frame_pow_exp, 32 );
tmp = -32;
+ move16();
}
curr_frame_pow = L_shr( curr_frame_pow, -tmp );
curr_frame_pow_exp = st_fx->prev_frame_pow_exp;
+ move16();
}
test();
IF( !st_fx->bfi && st_fx->prev_bfi )
@@ -3092,9 +3360,9 @@ void swb_tbe_dec_fx(
L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp );
scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
temp = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/
}
ELSE
@@ -3106,11 +3374,11 @@ void swb_tbe_dec_fx(
{
GainShape[2 * j] = mult_r( GainShape[2 * j], scale );
move16();
- GainShape[2 * j + 1] = mult_r( GainShape[2 * j + 1], scale );
+ GainShape[add( 2 * j, 1 )] = mult_r( GainShape[add( 2 * j, 1 )], scale );
move16();
FOR( i = 0; i < L_FRAME16k / 8; i++ )
{
- shaped_shb_excitation[i + j * L_FRAME16k / 8] = mult_r( shaped_shb_excitation[i + j * L_FRAME16k / 8], scale );
+ shaped_shb_excitation[add( i, j * ( L_FRAME16k / 8 ) )] = mult_r( shaped_shb_excitation[add( i, j * ( L_FRAME16k / 8 ) )], scale );
move16();
}
@@ -3154,18 +3422,18 @@ void swb_tbe_dec_fx(
test();
IF( GT_32( curr_frame_pow, hBWE_TD->prev_swb_bwe_frame_pow_fx ) &&
NE_16( st_fx->prev_coder_type, UNVOICED ) &&
- NE_16( st_fx->last_good, UNVOICED_CLAS ) )
+ ( st_fx->last_good != UNVOICED_CLAS ) )
{
L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp ); /*31 - exp*/
scale = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
temp = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
}
ELSE IF( LT_32( curr_frame_pow, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) && EQ_16( st_fx->nbLostCmpt, 1 ) &&
( GT_32( st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx, 1 ) ) || GT_32( st_fx->enerLH_fx, L_shr( st_fx->prev_enerLH_fx, 1 ) ) ) &&
- ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || EQ_16( st_fx->last_good, UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) )
+ ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) )
{
L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp );
#ifdef BASOP_NOGLOB
@@ -3173,9 +3441,9 @@ void swb_tbe_dec_fx(
#else
scale = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
#endif
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
temp = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
}
}
@@ -3190,9 +3458,9 @@ void swb_tbe_dec_fx(
{
L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp );
scale = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
#ifdef BASOP_NOGLOB
temp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
#else
@@ -3201,18 +3469,18 @@ void swb_tbe_dec_fx(
}
ELSE IF( LT_32( curr_frame_pow, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) &&
( GT_32( st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx, 1 ) ) || GT_32( st_fx->enerLH_fx, L_shr( st_fx->prev_enerLH_fx, 1 ) ) ) &&
- ( st_fx->prev_coder_type == UNVOICED || st_fx->last_good == UNVOICED_CLAS || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) )
+ ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) )
{
L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow, curr_frame_pow_exp, &exp );
#ifdef BASOP_NOGLOB
- L_tmp = L_min( L_tmp, L_shl_sat( 2, ( 31 - exp ) ) ); /*31 - exp*/
+ L_tmp = L_min( L_tmp, L_shl_sat( 2, sub( 31, exp ) ) ); /*31 - exp*/
#else
L_tmp = L_min( L_tmp, L_shl( 2, ( 31 - exp ) ) ); /*31 - exp*/
#endif
scale = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
- L_tmp = root_a_fx( L_tmp, 31 - exp, &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
+ L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp );
temp = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/
}
}
@@ -3225,7 +3493,7 @@ void swb_tbe_dec_fx(
#endif
move16(); /* 15 +12 +3-15 =15*/
#ifdef BASOP_NOGLOB
- GainShape[2 * j + 1] = shl_sat( mult_r( GainShape[2 * j + 1], scale ), 3 );
+ GainShape[add( 2 * j, 1 )] = shl_sat( mult_r( GainShape[add( 2 * j, 1 )], scale ), 3 );
#else
GainShape[2 * j + 1] = shl( mult_r( GainShape[2 * j + 1], scale ), 3 );
#endif
@@ -3233,7 +3501,7 @@ void swb_tbe_dec_fx(
FOR( i = 0; i < 40; i++ )
{
#ifdef BASOP_NOGLOB
- shaped_shb_excitation[add( i, i_mult( j, 40 ) )] = shl_sat( mult_r( shaped_shb_excitation[add( i, i_mult( j, 40 ) )], scale ), 3 );
+ shaped_shb_excitation[add( i, j * 40 )] = shl_sat( mult_r( shaped_shb_excitation[add( i, j * 40 )], scale ), 3 );
#else
shaped_shb_excitation[add( i, i_mult( j, 40 ) )] = shl( mult_r( shaped_shb_excitation[add( i, i_mult( j, 40 ) )], scale ), 3 );
#endif
@@ -3288,7 +3556,7 @@ void swb_tbe_dec_fx(
{
exp = norm_l( L_prev_ener_shb );
tmp = extract_h( L_shl( L_prev_ener_shb, exp ) );
- exp = sub( exp, 30 - ( 2 * Q_bwe_exc + 8 ) );
+ exp = sub( exp, sub( 30, ( add( i_mult( 2, Q_bwe_exc ), 8 ) ) ) );
tmp = div_s( 16384, tmp );
L_tmp = L_deposit_h( tmp );
@@ -3298,15 +3566,17 @@ void swb_tbe_dec_fx(
#else
st_fx->prev_ener_shb_fx = round_fx( L_shl( L_tmp, sub( exp, 14 ) ) ); /* Q1 */
#endif
+ move16();
}
/* st->prev_SWB_fenv[i] = sqrt(curr_frame_pow/L_FRAME16k); */
L_tmp = Mult_32_16( curr_frame_pow, 26214 ); /* curr_frame_pow_exp+8; 26214=(1/L_FRAME16k) in Q23 */
tmp = 0;
+ move16();
IF( L_tmp != 0 )
{
exp = norm_l( L_tmp );
tmp = extract_h( L_shl( L_tmp, exp ) );
- exp = sub( exp, 30 - ( curr_frame_pow_exp + 8 ) );
+ exp = sub( exp, sub( 30, add( curr_frame_pow_exp, 8 ) ) );
tmp = div_s( 16384, tmp );
L_tmp = L_deposit_h( tmp );
@@ -3338,11 +3608,11 @@ void swb_tbe_dec_fx(
move32();
}
}
- IF( st_fx->output_Fs == 48000 )
+ IF( EQ_32( st_fx->output_Fs, 48000 ) )
{
Scale_sig( hBWE_TD->int_3_over_2_tbemem_dec_fx, INTERP_3_2_MEM_LEN, sc );
}
- IF( st_fx->output_Fs == 16000 )
+ IF( EQ_32( st_fx->output_Fs, 16000 ) )
{
Scale_sig( hBWE_TD->mem_resamp_HB_32k_fx, 2 * ALLPASSSECTIONS_STEEP + 1, sc );
}
@@ -3373,22 +3643,32 @@ void swb_tbe_dec_fx(
if ( GainFrame == 0 )
{
tmp = 31;
+ move16();
}
L_tmp = L_shl( GainFrame, tmp ); /* 18 + tmp */
tmp1 = 0;
+ move16();
FOR( i = 0; i < L_FRAME16k; i++ )
{
- L_tmp1 = Mult_32_16( L_tmp, GainShape[NUM_SHB_SUBFR * i / L_FRAME16k] ); /* Q : 18 + tmp +15 -15*/
- White_exc16k[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */
+ Word16 idx = 0;
+ IF( i != 0 )
+ {
+ idx = idiv1616( i_mult( NUM_SHB_SUBFR, i ), L_FRAME16k );
+ }
+ L_tmp1 = Mult_32_16( L_tmp, GainShape[idx] ); /* Q : 18 + tmp +15 -15*/
+ White_exc16k[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */
+ move16();
tmp1 = s_max( tmp1, abs_s( White_exc16k[i] ) );
}
*Q_white_exc = sub( add( *Q_white_exc, tmp ), 13 ); /* *Q_white_exc + 18 + tmp -15 -16 */
+ move16();
tmp = norm_s( tmp1 );
if ( tmp1 == 0 )
{
tmp = 15;
+ move16();
}
FOR( i = 0; i < L_FRAME16k; i++ )
@@ -3447,6 +3727,7 @@ void swb_tbe_dec_fx(
hBWE_TD->GainFrame_prevfrm_fx = GainFrame;
move16(); /*Q18*/
hBWE_TD->tilt_swb_fec_fx = tilt_swb_fec;
+ move16();
if ( !st_fx->bfi )
{
@@ -3468,7 +3749,9 @@ void swb_tbe_dec_fx(
}
hBWE_TD->prev_ener_fx = ener_tmp[NUM_SHB_SUBGAINS - 1];
+ move32();
hBWE_TD->prev_GainShape_fx = GainShape[NUM_SHB_SUBFR - 1];
+ move32();
*Q_synth = Q_bwe_exc;
move16();
st_fx->prev_Q_bwe_syn2 = Q_bwe_exc;
@@ -3523,7 +3806,7 @@ static void gradientGainShape(
/* get the first gainshape template */
test();
test();
- IF( ( st_fx->prev_coder_type == UNVOICED || st_fx->last_good == UNVOICED_CLAS ) && GainGradFEC[0] > 0 )
+ IF( ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) ) && ( GainGradFEC[0] > 0 ) )
{
GainShapeTemp[0] = add( shr( st_fx->GainShape_Delay[7], 1 ), GainGradFEC[0] );
move16();
@@ -3545,7 +3828,7 @@ static void gradientGainShape(
tmp = mult_r( tmp, 26214 ); /* 0.8 in Q15 tmp*(8/10) */
test();
- IF( ( GT_16( tmp, GainGrad1[1] ) ) && GainGrad1[1] > 0 )
+ IF( ( GT_16( tmp, GainGrad1[1] ) ) && ( GainGrad1[1] > 0 ) )
{
FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ )
{
@@ -3558,7 +3841,7 @@ static void gradientGainShape(
ELSE
{
test();
- IF( ( GT_16( tmp, GainGrad1[1] ) ) && GainGrad1[1] < 0 )
+ IF( ( GT_16( tmp, GainGrad1[1] ) ) && ( GainGrad1[1] < 0 ) )
{
FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ )
{
@@ -3584,7 +3867,7 @@ static void gradientGainShape(
test();
test();
test();
- IF( ( st_fx->prev_coder_type == UNVOICED || st_fx->last_good == UNVOICED_CLAS ) && st_fx->nbLostCmpt == 1 )
+ IF( ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) ) && EQ_16( st_fx->nbLostCmpt, 1 ) )
{
FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ )
{
@@ -3594,19 +3877,20 @@ static void gradientGainShape(
IF( GT_16( 8192, tmp ) )
{
- GainShape[i * 4 + j] = shl( tmp, 2 );
+ GainShape[add( i * 4, j )] = shl( tmp, 2 );
move16(); /* (GainShapeTemp[i]*0.6)>>1 */
}
ELSE
{
- GainShape[i * 4 + j] = 32767;
+ GainShape[add( i * 4, j )] = 32767;
move16(); /* Clipping here to avoid the a huge change of the code due to gain shape change */
}
}
}
hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 31129 );
+ move16();
}
- ELSE IF( st_fx->prev_coder_type == UNVOICED || st_fx->last_good == UNVOICED_CLAS )
+ ELSE IF( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) )
{
FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ )
{
@@ -3614,29 +3898,31 @@ static void gradientGainShape(
{
IF( LT_16( GainShapeTemp[i], 16384 ) )
{
- GainShape[i * 4 + j] = shl( GainShapeTemp[i], 1 );
+ GainShape[add( i * 4, j )] = shl( GainShapeTemp[i], 1 );
move16();
}
ELSE
{
- GainShape[i * 4 + j] = 32767;
+ GainShape[add( i * 4, j )] = 32767;
move16();
}
}
}
hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 31129 );
+ move16();
}
- ELSE IF( st_fx->nbLostCmpt > 1 )
+ ELSE IF( GT_16( st_fx->nbLostCmpt, 1 ) )
{
FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ )
{
FOR( j = 0; j < 4; j++ )
{
- GainShape[i * 4 + j] = GainShapeTemp[i];
+ GainShape[add( i * 4, j )] = GainShapeTemp[i];
move16();
}
}
hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 16384 );
+ move16();
}
ELSE
{
@@ -3646,20 +3932,22 @@ static void gradientGainShape(
{
IF( LT_16( GainShapeTemp[i], 16384 ) )
{
- GainShape[i * 4 + j] = shl( GainShapeTemp[i], 1 );
+ GainShape[add( i * 4, j )] = shl( GainShapeTemp[i], 1 );
move16();
}
ELSE
{
- GainShape[i * 4 + j] = 32767;
+ GainShape[add( i * 4, j )] = 32767;
move16();
}
}
}
hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 27852 );
+ move16();
}
*GainFrame = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, hBWE_TD->GainAttn_fx ); /* Q18 */
+ move32();
}
/*-------------------------------------------------------------------*
@@ -3813,6 +4101,7 @@ void ivas_dequantizeSHBparams_fx_9_1(
const Word16 *cb_stage;
Word16 predictor_bits;
Word16 nbits = NUM_BITS_SHB_MSLVQ;
+ move16();
hBWE_TD = st_fx->hBWE_TD;
/* LSFs */
@@ -3824,29 +4113,29 @@ void ivas_dequantizeSHBparams_fx_9_1(
IF( EQ_16( st_fx->codec_mode, MODE2 ) )
{
idxFrameGain = hBWE_TD->gFrame_WB;
+ move16();
idxLSF = hBWE_TD->lsf_WB;
+ move16();
}
ELSE
{
- idxFrameGain = get_next_indice( st_fx, NUM_BITS_SHB_FrameGain_LBR_WB );
- idxLSF = get_next_indice( st_fx, NUM_BITS_LBR_WB_LSF );
+ idxFrameGain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_FrameGain_LBR_WB );
+ idxLSF = (Word16) get_next_indice( st_fx, NUM_BITS_LBR_WB_LSF );
}
- Copy( lbr_wb_bwe_lsfvq_cbook_2bit_fx + idxLSF * LPC_SHB_ORDER_LBR_WB, Q_lsf, LPC_SHB_ORDER_LBR_WB );
+ Copy( lbr_wb_bwe_lsfvq_cbook_2bit_fx + i_mult( idxLSF, LPC_SHB_ORDER_LBR_WB ), Q_lsf, LPC_SHB_ORDER_LBR_WB );
set16_fx( Q_subgain, RECIP_ROOT_EIGHT_FX, NUM_SHB_SUBFR / 2 );
Copy32( SHBCB_FrameGain16_fx + idxFrameGain, Q_framegrain, 1 );
}
ELSE
{
*uv_flag = (Word16) get_next_indice( st_fx, 1 );
- idxSubGain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_SUBGAINS );
move16();
+ idxSubGain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_SUBGAINS );
idxFrameGain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_FrameGain );
- move16();
idxLSF = (Word16) get_next_indice( st_fx, NUM_BITS_WB_LSF );
- move16();
- Copy( wb_bwe_lsfvq_cbook_8bit_fx + idxLSF * LPC_SHB_ORDER_WB, Q_lsf, LPC_SHB_ORDER_WB );
- Copy( HBCB_SubGain5bit_fx + idxSubGain * NUM_SHB_SUBFR / 4, Q_combined_gains, NUM_SHB_SUBFR / 4 );
+ Copy( wb_bwe_lsfvq_cbook_8bit_fx + i_mult( idxLSF, LPC_SHB_ORDER_WB ), Q_lsf, LPC_SHB_ORDER_WB );
+ Copy( HBCB_SubGain5bit_fx + i_mult( idxSubGain, NUM_SHB_SUBFR / 4 ), Q_combined_gains, NUM_SHB_SUBFR / 4 );
FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ )
{
@@ -3858,6 +4147,7 @@ void ivas_dequantizeSHBparams_fx_9_1(
/* output of Pow2() will be: */
/* 16384 < Pow2() <= 32767 */
Q_combined_gains[i] = shl( tmp, add( exp, 1 ) ); /* Q15 */
+ move16();
}
FOR( i = 0; i < NUM_SHB_SUBFR / 2; i += 2 )
@@ -3877,40 +4167,47 @@ void ivas_dequantizeSHBparams_fx_9_1(
IF( EQ_16( st_fx->codec_mode, MODE2 ) )
{
idxSubGain = hBWE_TD->idxSubGains;
+ move16();
idxFrameGain = hBWE_TD->idxFrameGain;
+ move16();
}
ELSE
{
idxSubGain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_SUBGAINS );
- IF( st_fx->extl_brate == SWB_TBE_1k75 )
+ IF( EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) )
{
- idxFrameGain = get_next_indice( st_fx, NUM_BITS_SHB_FRAMEGAIN_1k75 );
+ idxFrameGain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_FRAMEGAIN_1k75 );
}
ELSE
{
- idxFrameGain = get_next_indice( st_fx, NUM_BITS_SHB_FRAMEGAIN );
+ idxFrameGain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_FRAMEGAIN );
}
}
/* Multi Source Flag */
- IF( st_fx->element_mode >= IVAS_CPE_DFT && !( st_fx->element_mode == IVAS_CPE_TD && st_fx->tdm_LRTD_flag ) )
+ test();
+ test();
+ IF( GE_16( st_fx->element_mode, IVAS_CPE_DFT ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && st_fx->tdm_LRTD_flag ) )
{
- *MSFlag = get_next_indice( st_fx, STEREO_ICBWE_MSFLAG_BITS );
+ *MSFlag = (Word16) get_next_indice( st_fx, STEREO_ICBWE_MSFLAG_BITS );
+ move16();
}
ELSE
{
*MSFlag = 0;
+ move16();
}
- test();
- IF( st_fx->extl_brate >= SWB_TBE_2k8 )
+
+ IF( GE_32( st_fx->extl_brate, SWB_TBE_2k8 ) )
{
IF( EQ_16( st_fx->codec_mode, MODE2 ) )
{
idx_shb_fr_gain = hBWE_TD->idx_shb_fr_gain;
+ move16();
}
ELSE
{
- idx_shb_fr_gain = get_next_indice( st_fx, NUM_BITS_SHB_ENER_SF );
+ idx_shb_fr_gain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_ENER_SF );
}
temp_shb_ener_sf_fx = usdequant_fx( idx_shb_fr_gain, 0, 86 ); /* 86 = 0.042f in Q11 = Qin-1 */
/* o: temp_shb_ener_sf_fx in Q12 */
@@ -3921,7 +4218,8 @@ void ivas_dequantizeSHBparams_fx_9_1(
L_tmp = L_shl( L_tmp, -10 ); /* bring L_tmp from Q26 to Q16 */
frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent */
L_tmp = Pow2( 14, frac );
- *Q_shb_ener_sf = L_shl( L_tmp, exp - 14 + 0 ); /* In Q_ener: 2*Q_shb+1, Q_shb = 0; */
+ *Q_shb_ener_sf = L_shl( L_tmp, sub( exp, 14 ) /*exp - 14 + 0 */ ); /* In Q_ener: 2*Q_shb+1, Q_shb = 0; */
+ move32();
FOR( i = 0; i < 5; i++ )
{
@@ -3932,7 +4230,7 @@ void ivas_dequantizeSHBparams_fx_9_1(
}
ELSE
{
- idx_res_gs[i] = get_next_indice( st_fx, NUM_BITS_SHB_RES_GS );
+ idx_res_gs[i] = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_RES_GS );
move16();
}
Q_shb_res_gshape[i] = usdequant_fx( idx_res_gs[i],
@@ -3959,17 +4257,20 @@ void ivas_dequantizeSHBparams_fx_9_1(
ELSE
{
*Q_shb_ener_sf = L_deposit_l( 0 );
- IF( st_fx->extl_brate == SWB_TBE_1k10 || st_fx->extl_brate == SWB_TBE_1k75 )
+ move32();
+ test();
+ IF( EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) )
{
- idx_mixFac = get_next_indice( st_fx, NUM_BITS_SHB_VF );
+ idx_mixFac = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_VF );
*Q_mixFactors = usdequant_fx( idx_mixFac, 0 /* 0.0f in Q15*/, 2341 /*1.0f / ((1 << NUM_BITS_SHB_VF) - 1) in Q14*/ );
+ move16();
}
ELSE
{
*Q_mixFactors = 0;
+ move16();
}
//*Q_mixFactors = 0;
- move16();
set16_fx( Q_shb_res_gshape, 0, 5 );
}
@@ -3981,51 +4282,61 @@ void ivas_dequantizeSHBparams_fx_9_1(
test();
test();
test();
- IF( ( st_fx->extl_brate == SWB_TBE_0k95 || st_fx->extl_brate == SWB_TBE_1k10 ) && st_fx->codec_mode == MODE1 )
+ test();
+ test();
+ test();
+ test();
+ IF( ( EQ_32( st_fx->extl_brate, SWB_TBE_0k95 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) ) && EQ_16( st_fx->codec_mode, MODE1 ) )
{
set16_fx( lsf_idx, 0, 5 );
- lsf_idx[0] = get_next_indice( st_fx, 8 );
+ lsf_idx[0] = (Word16) get_next_indice( st_fx, 8 );
+ move16();
grid_idx = 0;
+ move16();
m_idx = 0;
+ move16();
- Copy( swb_tbe_lsfvq_cbook_8b + lsf_idx[0] * LPC_SHB_ORDER, Q_lsf, LPC_SHB_ORDER );
+ Copy( swb_tbe_lsfvq_cbook_8b + i_mult( lsf_idx[0], LPC_SHB_ORDER ), Q_lsf, LPC_SHB_ORDER );
}
- ELSE IF( st_fx->rf_flag == 0 && !( ( st_fx->element_mode == EVS_MONO && st_fx->total_brate == ACELP_9k60 ) || ( st_fx->element_mode == EVS_MONO && ( st_fx->total_brate == 0 ) && ( ( st_fx->last_total_brate == ACELP_9k60 ) || ( st_fx->last_total_brate == ACELP_13k20 && st_fx->rf_flag_last ) ) ) ) )
+ ELSE IF( ( st_fx->rf_flag == 0 ) && !( ( ( st_fx->element_mode == EVS_MONO ) && EQ_32( st_fx->total_brate, ACELP_9k60 ) ) || ( ( st_fx->element_mode == EVS_MONO ) && ( ( st_fx->total_brate == 0 ) ) && ( ( EQ_32( st_fx->last_total_brate, ACELP_9k60 ) ) || ( EQ_32( st_fx->last_total_brate, ACELP_13k20 ) && st_fx->rf_flag_last ) ) ) ) )
{
- IF( st_fx->extl_brate == SWB_TBE_1k75 )
+ IF( EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) )
{
/* read multi-stage LVQ quantizer */
- IF( nbits >= 19 )
+ IF( GE_16( nbits, 19 ) )
{
cb_stage = cb_LSF_BWE_fx[0];
+ move16();
}
ELSE
{
cb_stage = cb_LSF_BWE_fx[1];
+ move16();
}
set16_fx( lsf_q, 0, LPC_SHB_ORDER );
/* VQ part */
- num_bits_lvq = config_LSF_BWE[( NUM_BITS_SHB_MSLVQ - nbits ) * 3];
+ num_bits_lvq = config_LSF_BWE[i_mult( sub( NUM_BITS_SHB_MSLVQ, nbits ), 3 )];
Idx = get_next_indice( st_fx, num_bits_lvq );
- v_add_16( lsf_q, cb_stage + Idx * 6, lsf_q, 6 );
+ v_add_16( lsf_q, cb_stage + i_mult( Idx, 6 ), lsf_q, 6 );
/* MSLVQ part */
- num_bits_lvq = nbits - num_bits_lvq - config_LSF_BWE[( NUM_BITS_SHB_MSLVQ - nbits ) * 3 + 2];
- predictor_bits = config_LSF_BWE[( NUM_BITS_SHB_MSLVQ - nbits ) * 3 + 2];
+ num_bits_lvq = sub( sub( nbits, num_bits_lvq ), config_LSF_BWE[add( i_mult( sub( NUM_BITS_SHB_MSLVQ, nbits ), 3 ), 2 )] );
+ predictor_bits = config_LSF_BWE[add( i_mult( sub( NUM_BITS_SHB_MSLVQ, nbits ), 3 ), 2 )];
Idx_pred = 0;
+ move16();
- IF( num_bits_lvq == 16 )
+ IF( EQ_16( num_bits_lvq, 16 ) )
{
/* MSLVQ part */
- Idx_lvq = get_next_indice( st_fx, num_bits_lvq - 1 ) + ( ( get_next_indice( st_fx, 1 ) ) << 15 );
+ Idx_lvq = L_add( get_next_indice( st_fx, sub( num_bits_lvq, 1 ) ), L_shl( get_next_indice( st_fx, 1 ), 15 ) );
deindex_lvq_SHB_fx( Idx_lvq, out, num_bits_lvq, 0 );
}
ELSE
{
/* MSLVQ part */
Idx_lvq = get_next_indice( st_fx, num_bits_lvq );
- deindex_lvq_SHB_fx( Idx_lvq, out, num_bits_lvq, ( nbits < 19 ) );
+ deindex_lvq_SHB_fx( Idx_lvq, out, num_bits_lvq, extract_l( LT_16( nbits, 19 ) ) );
}
/* mvr2r( mean_lsf, Q_lsfs, LPC_SHB_ORDER ); */
@@ -4035,19 +4346,22 @@ void ivas_dequantizeSHBparams_fx_9_1(
IF( predictor_bits == 0 )
{
lsf_q[LATTICE_DIM] = dotp_loc( lsf_q, LastCoefPred_0bit_fx, LATTICE_DIM );
+ move16();
lsf_q[LATTICE_DIM + 1] = dotp_loc( lsf_q, &LastCoefPred_0bit_fx[LATTICE_DIM + 1], LATTICE_DIM );
+ move16();
}
ELSE
{
- Idx_pred = get_next_indice( st_fx, 1 );
-
- lsf_q[LATTICE_DIM] = dotp_loc( lsf_q, &LastCoefPred_1bit_fx[2 * ( LATTICE_DIM + 1 ) * Idx_pred], LATTICE_DIM );
- lsf_q[LATTICE_DIM + 1] = dotp_loc( lsf_q, &LastCoefPred_1bit_fx[2 * ( LATTICE_DIM + 1 ) * Idx_pred + LATTICE_DIM + 1], LATTICE_DIM );
+ Idx_pred = (Word16) get_next_indice( st_fx, 1 );
+ lsf_q[LATTICE_DIM] = dotp_loc( lsf_q, &LastCoefPred_1bit_fx[i_mult( 2 * ( LATTICE_DIM + 1 ), Idx_pred )], LATTICE_DIM );
+ move16();
+ lsf_q[LATTICE_DIM + 1] = dotp_loc( lsf_q, &LastCoefPred_1bit_fx[add( i_mult( 2 * ( LATTICE_DIM + 1 ), Idx_pred ), LATTICE_DIM + 1 )], LATTICE_DIM );
+ move16();
}
- IF( nbits < NUM_BITS_SHB_MSLVQ )
+ IF( LT_16( nbits, NUM_BITS_SHB_MSLVQ ) )
{
- Idx_pred = get_next_indice( st_fx, NUM_BITS_SHB_MSLVQ - nbits );
+ Idx_pred = (Word16) get_next_indice( st_fx, sub( NUM_BITS_SHB_MSLVQ, nbits ) );
}
v_add_16( SHB_LSF_mean_fx, lsf_q, lsf_q, LPC_SHB_ORDER );
@@ -4083,11 +4397,11 @@ void ivas_dequantizeSHBparams_fx_9_1(
IF( EQ_16( st_fx->codec_mode, MODE2 ) )
{
m_idx = hBWE_TD->m_idx;
+ move16();
}
ELSE
{
m_idx = (Word16) get_next_indice( st_fx, MIRROR_POINT_BITS );
- move16();
}
Dequant_mirror_point_fx( lsf_q, m_idx, &m );
@@ -4096,17 +4410,19 @@ void ivas_dequantizeSHBparams_fx_9_1(
IF( GT_16( m, MAX_LSF_FX ) )
{
st_fx->BER_detect = 1;
+ move16();
m = MAX_LSF_FX - 1;
+ move16();
}
IF( EQ_16( st_fx->codec_mode, MODE2 ) )
{
grid_idx = hBWE_TD->grid_idx;
+ move16();
}
ELSE
{
grid_idx = (Word16) get_next_indice( st_fx, NUM_LSF_GRID_BITS );
- move16();
}
Map_higher_LSF_fx( lsf_q, m, lsf_grid_fx[grid_idx] );
@@ -4117,7 +4433,9 @@ void ivas_dequantizeSHBparams_fx_9_1(
IF( GT_16( lsf_q[LPC_SHB_ORDER - 1 - i], MAX_LSF_FX ) )
{
st_fx->BER_detect = 1;
+ move16();
lsf_q[LPC_SHB_ORDER - 1 - i] = MAX_LSF_FX - 1;
+ move16();
}
Q_lsf[i] = sub( 16384, lsf_q[LPC_SHB_ORDER - 1 - i] );
move16();
@@ -4128,14 +4446,16 @@ void ivas_dequantizeSHBparams_fx_9_1(
set16_fx( lsf_idx, 0, 5 );
Copy( hBWE_TD->lsf_idx, lsf_idx, 5 );
grid_idx = 0;
+ move16();
m_idx = 0;
- Copy( swb_tbe_lsfvq_cbook_8b + lsf_idx[0] * LPC_SHB_ORDER, Q_lsf, LPC_SHB_ORDER );
+ move16();
+ Copy( swb_tbe_lsfvq_cbook_8b + i_mult( lsf_idx[0], LPC_SHB_ORDER ), Q_lsf, LPC_SHB_ORDER );
}
space_lsfs_fx( Q_lsf, LPC_SHB_ORDER );
/* Dequantize subgain indices */
- j = idxSubGain * NUM_SHB_SUBGAINS;
+ j = i_mult( idxSubGain, NUM_SHB_SUBGAINS );
move16();
FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ )
{
@@ -4153,24 +4473,32 @@ void ivas_dequantizeSHBparams_fx_9_1(
FOR( i = NUM_SHB_SUBFR - 1; i >= 0; i-- )
{
- Q_subgain[i] = Q_subgain[i * NUM_SHB_SUBGAINS / NUM_SHB_SUBFR];
+ Word16 idx = 0;
+ move16();
+ IF( i != 0 )
+ {
+ idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR );
+ }
+ Q_subgain[i] = Q_subgain[idx];
move16();
}
/* Frame gain */
- IF( st_fx->extl_brate == SWB_TBE_1k75 )
+ IF( EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) )
{
*Q_framegrain = L_mac( SHB_GAIN_QLOW_1k75_FX, idxFrameGain, SHB_GAIN_QDELTA_1k75_FX );
+ move32();
}
ELSE
{
*Q_framegrain = L_mac( SHB_GAIN_QLOW_FX, idxFrameGain, SHB_GAIN_QDELTA_FX );
- }
- move32(); /*Q18*/
+ move32();
+ } /*Q18*/
L_tmp = Mult_32_16( *Q_framegrain, 27213 ); /*Q16*/ /* 3.321928 in Q13 */
frac = L_Extract_lc( L_tmp, &exp );
L_tmp = Pow2( 30, frac );
*Q_framegrain = L_shl( L_tmp, sub( exp, 12 ) ); /*Q18*/
+ move32();
}
return;
@@ -4233,23 +4561,23 @@ static void dequantizeSHBparams_fx_9_1(
IF( EQ_32( extl_brate, WB_TBE_0k35 ) )
{
idxFrameGain = hBWE_TD->gFrame_WB;
+ move16();
idxLSF = hBWE_TD->lsf_WB;
+ move16();
- Copy( lbr_wb_bwe_lsfvq_cbook_2bit_fx + idxLSF * LPC_SHB_ORDER_LBR_WB, Q_lsf, LPC_SHB_ORDER_LBR_WB );
+ Copy( lbr_wb_bwe_lsfvq_cbook_2bit_fx + i_mult( idxLSF, LPC_SHB_ORDER_LBR_WB ), Q_lsf, LPC_SHB_ORDER_LBR_WB );
set16_fx( Q_subgain, RECIP_ROOT_EIGHT_FX, NUM_SHB_SUBFR / 2 );
Copy32( SHBCB_FrameGain16_fx + idxFrameGain, Q_framegrain, 1 );
}
ELSE
{
*uv_flag = (Word16) get_next_indice( st_fx, 1 );
- idxSubGain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_SUBGAINS );
move16();
+ idxSubGain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_SUBGAINS );
idxFrameGain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_FrameGain );
- move16();
idxLSF = (Word16) get_next_indice( st_fx, NUM_BITS_WB_LSF );
- move16();
- Copy( wb_bwe_lsfvq_cbook_8bit_fx + idxLSF * LPC_SHB_ORDER_WB, Q_lsf, LPC_SHB_ORDER_WB );
- Copy( HBCB_SubGain5bit_fx + idxSubGain * NUM_SHB_SUBFR / 4, Q_combined_gains, NUM_SHB_SUBFR / 4 );
+ Copy( wb_bwe_lsfvq_cbook_8bit_fx + i_mult( idxLSF, LPC_SHB_ORDER_WB ), Q_lsf, LPC_SHB_ORDER_WB );
+ Copy( HBCB_SubGain5bit_fx + i_mult( idxSubGain, NUM_SHB_SUBFR / 4 ), Q_combined_gains, NUM_SHB_SUBFR / 4 );
FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ )
{
@@ -4261,6 +4589,7 @@ static void dequantizeSHBparams_fx_9_1(
/* output of Pow2() will be: */
/* 16384 < Pow2() <= 32767 */
Q_combined_gains[i] = shl( tmp, add( exp, 1 ) ); /* Q15 */
+ move16();
}
FOR( i = 0; i < NUM_SHB_SUBFR / 2; i += 2 )
@@ -4280,7 +4609,9 @@ static void dequantizeSHBparams_fx_9_1(
IF( EQ_16( st_fx->codec_mode, MODE2 ) )
{
idxSubGain = hBWE_TD->idxSubGains;
+ move16();
idxFrameGain = hBWE_TD->idxFrameGain;
+ move16();
}
ELSE
{
@@ -4294,10 +4625,11 @@ static void dequantizeSHBparams_fx_9_1(
IF( EQ_16( st_fx->codec_mode, MODE2 ) )
{
idx_shb_fr_gain = hBWE_TD->idx_shb_fr_gain;
+ move16();
}
ELSE
{
- idx_shb_fr_gain = get_next_indice( st_fx, NUM_BITS_SHB_ENER_SF );
+ idx_shb_fr_gain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_ENER_SF );
}
temp_shb_ener_sf_fx = usdequant_fx( idx_shb_fr_gain, 0, 86 ); /* 86 = 0.042f in Q11 = Qin-1 */
/* o: temp_shb_ener_sf_fx in Q12 */
@@ -4308,7 +4640,8 @@ static void dequantizeSHBparams_fx_9_1(
L_tmp = L_shl( L_tmp, -10 ); /* bring L_tmp from Q26 to Q16 */
frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent */
L_tmp = Pow2( 14, frac );
- *Q_shb_ener_sf = L_shl( L_tmp, exp - 14 + 0 ); /* In Q_ener: 2*Q_shb+1, Q_shb = 0; */
+ *Q_shb_ener_sf = L_shl( L_tmp, sub( exp, 14 ) /* exp - 14 + 0 */ ); /* In Q_ener: 2*Q_shb+1, Q_shb = 0; */
+ move32();
FOR( i = 0; i < 5; i++ )
{
@@ -4319,7 +4652,7 @@ static void dequantizeSHBparams_fx_9_1(
}
ELSE
{
- idx_res_gs[i] = get_next_indice( st_fx, NUM_BITS_SHB_RES_GS );
+ idx_res_gs[i] = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_RES_GS );
move16();
}
Q_shb_res_gshape[i] = usdequant_fx( idx_res_gs[i],
@@ -4346,6 +4679,7 @@ static void dequantizeSHBparams_fx_9_1(
ELSE
{
*Q_shb_ener_sf = L_deposit_l( 0 );
+ move32();
*Q_mixFactors = 0;
move16();
set16_fx( Q_shb_res_gshape, 0, 5 );
@@ -4359,7 +4693,7 @@ static void dequantizeSHBparams_fx_9_1(
test();
test();
test();
- IF( ( st_fx->rf_flag == 0 ) && !( ( EQ_32( st_fx->total_brate, ACELP_9k60 ) ) || ( ( st_fx->total_brate == 0 ) && ( ( EQ_32( st_fx->last_total_brate, ACELP_9k60 ) ) || ( EQ_32( st_fx->last_total_brate, ACELP_13k20 ) && EQ_16( st_fx->rf_flag_last, 1 ) ) ) ) ) )
+ IF( ( ( st_fx->rf_flag == 0 ) ) && !( ( EQ_32( st_fx->total_brate, ACELP_9k60 ) ) || ( ( ( st_fx->total_brate == 0 ) ) && ( ( EQ_32( st_fx->last_total_brate, ACELP_9k60 ) ) || ( EQ_32( st_fx->last_total_brate, ACELP_13k20 ) && EQ_16( st_fx->rf_flag_last, 1 ) ) ) ) ) )
{
/* LSFs */
@@ -4390,11 +4724,11 @@ static void dequantizeSHBparams_fx_9_1(
IF( EQ_16( st_fx->codec_mode, MODE2 ) )
{
m_idx = hBWE_TD->m_idx;
+ move16();
}
ELSE
{
m_idx = (Word16) get_next_indice( st_fx, MIRROR_POINT_BITS );
- move16();
}
Dequant_mirror_point_fx( lsf_q, m_idx, &m );
@@ -4403,17 +4737,19 @@ static void dequantizeSHBparams_fx_9_1(
IF( GT_16( m, MAX_LSF_FX ) )
{
st_fx->BER_detect = 1;
+ move16();
m = MAX_LSF_FX - 1;
+ move16();
}
IF( EQ_16( st_fx->codec_mode, MODE2 ) )
{
grid_idx = hBWE_TD->grid_idx;
+ move16();
}
ELSE
{
grid_idx = (Word16) get_next_indice( st_fx, NUM_LSF_GRID_BITS );
- move16();
}
Map_higher_LSF_fx( lsf_q, m, lsf_grid_fx[grid_idx] );
@@ -4424,7 +4760,9 @@ static void dequantizeSHBparams_fx_9_1(
IF( GT_16( lsf_q[LPC_SHB_ORDER - 1 - i], MAX_LSF_FX ) )
{
st_fx->BER_detect = 1;
+ move16();
lsf_q[LPC_SHB_ORDER - 1 - i] = MAX_LSF_FX - 1;
+ move16();
}
Q_lsf[i] = sub( 16384, lsf_q[LPC_SHB_ORDER - 1 - i] );
move16();
@@ -4435,20 +4773,23 @@ static void dequantizeSHBparams_fx_9_1(
set16_fx( lsf_idx, 0, 5 );
Copy( hBWE_TD->lsf_idx, lsf_idx, 5 );
grid_idx = 0;
+ move16();
m_idx = 0;
- Copy( swb_tbe_lsfvq_cbook_8b + lsf_idx[0] * LPC_SHB_ORDER, Q_lsf, LPC_SHB_ORDER );
+ move16();
+ Copy( swb_tbe_lsfvq_cbook_8b + i_mult( lsf_idx[0], LPC_SHB_ORDER ), Q_lsf, LPC_SHB_ORDER );
}
space_lsfs_fx( Q_lsf, LPC_SHB_ORDER );
/* Dequantize subgain indices */
- j = idxSubGain * NUM_SHB_SUBGAINS;
+ j = i_mult( idxSubGain, NUM_SHB_SUBGAINS );
move16();
FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ )
{
/* Q_subgain[i] = (float) pow(10.0, SHBCB_SubGain5bit[j++]); */
- L_tmp = L_mult( SHBCB_SubGain5bit_fx[j++], 27213 ); /*Q28 3.321928 in Q13 */
+ L_tmp = L_mult( SHBCB_SubGain5bit_fx[j], 27213 ); /*Q28 3.321928 in Q13 */
+ j = add( j, 1 );
L_tmp = L_shr( L_tmp, 12 );
frac = L_Extract_lc( L_tmp, &exp );
tmp = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */
@@ -4460,17 +4801,24 @@ static void dequantizeSHBparams_fx_9_1(
FOR( i = NUM_SHB_SUBFR - 1; i >= 0; i-- )
{
- Q_subgain[i] = Q_subgain[i * NUM_SHB_SUBGAINS / NUM_SHB_SUBFR];
+ Word16 idx = 0;
+ move16();
+ IF( i != 0 )
+ {
+ idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR );
+ }
+ Q_subgain[i] = Q_subgain[idx];
move16();
}
/* Frame gain */
- *Q_framegrain = L_mac( SHB_GAIN_QLOW_FX, idxFrameGain, SHB_GAIN_QDELTA_FX );
- move32(); /*Q18*/
+ *Q_framegrain = L_mac( SHB_GAIN_QLOW_FX, idxFrameGain, SHB_GAIN_QDELTA_FX ); /*Q18*/
+ move32();
L_tmp = Mult_32_16( *Q_framegrain, 27213 ); /*Q16*/ /* 3.321928 in Q13 */
frac = L_Extract_lc( L_tmp, &exp );
L_tmp = Pow2( 30, frac );
*Q_framegrain = L_shl( L_tmp, sub( exp, 12 ) ); /*Q18*/
+ move32();
}
return;
@@ -4491,7 +4839,9 @@ void fb_tbe_dec_fx(
{
Word16 i;
Word16 ratio = 0;
+ move16();
Word32 fb_exc_energy = 0;
+ move32();
Word16 fb_synth[L_FRAME48k];
TD_BWE_DEC_HANDLE hBWE_TD;
hBWE_TD = st->hBWE_TD;
@@ -4516,7 +4866,7 @@ void fb_tbe_dec_fx(
ratio = shl( 1, i );
#endif
}
- ELSE if ( EQ_16( st->extl, FB_TBE ) && st->bfi )
+ ELSE IF( EQ_16( st->extl, FB_TBE ) && st->bfi )
{
ratio = hBWE_TD->prev_fbbwe_ratio_fx;
move16();
@@ -4554,16 +4904,18 @@ void fb_tbe_dec_ivas_fx(
{
Word16 i;
Word16 ratio = 0;
+ move16();
Word32 fb_exc_energy = 0;
+ move32();
Word16 fb_synth[L_FRAME48k];
TD_BWE_DEC_HANDLE hBWE_TD;
hBWE_TD = st->hBWE_TD;
/* decode FB slope information */
- test();
- test();
- if ( output_frame == L_FRAME48k )
+ IF( EQ_16( output_frame, L_FRAME48k ) )
{
+ test();
+ test();
IF( EQ_16( st->extl, FB_TBE ) && !st->bfi )
{
IF( EQ_16( st->codec_mode, MODE2 ) )
@@ -4581,7 +4933,7 @@ void fb_tbe_dec_ivas_fx(
ratio = shl( 1, i );
#endif
}
- ELSE if ( EQ_16( st->extl, FB_TBE ) && st->bfi )
+ ELSE IF( EQ_16( st->extl, FB_TBE ) && st->bfi )
{
ratio = hBWE_TD->prev_fbbwe_ratio_fx;
move16();
@@ -4592,6 +4944,7 @@ void fb_tbe_dec_ivas_fx(
IF( !st->bfi )
{
st->next_bit_pos = add( st->next_bit_pos, NUM_BITS_FB_FRAMEGAIN );
+ move16();
}
return;
@@ -4601,7 +4954,8 @@ void fb_tbe_dec_ivas_fx(
/* FB TBE synthesis */
synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp );
- IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( st->idchan, 0 ) )
+ test();
+ IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->idchan == 0 ) )
{
Copy_Scale_sig( fb_synth, fb_synth_ref, L_FRAME48k, sub( Q_fb_synth_ref, hb_synth_exp ) ); // scaling is required
}
@@ -4632,30 +4986,33 @@ void tbe_read_bitstream_fx(
IF( ( EQ_16( st_fx->rf_flag, 1 ) || EQ_32( st_fx->total_brate, ACELP_9k60 ) ) && EQ_16( st_fx->bwidth, WB ) )
{
/* WB LSF */
- hBWE_TD->lsf_WB = get_next_indice( st_fx, NUM_BITS_LBR_WB_LSF );
+ hBWE_TD->lsf_WB = (Word16) get_next_indice( st_fx, NUM_BITS_LBR_WB_LSF );
+ move16();
/* WB frame gain */
- hBWE_TD->gFrame_WB = get_next_indice( st_fx, NUM_BITS_SHB_FrameGain_LBR_WB );
+ hBWE_TD->gFrame_WB = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_FrameGain_LBR_WB );
+ move16();
}
ELSE IF( ( GE_32( st_fx->total_brate, ACELP_9k60 ) ) && ( LE_32( st_fx->total_brate, ACELP_32k ) ) &&
( ( EQ_16( st_fx->bwidth, SWB ) ) || ( EQ_16( st_fx->bwidth, FB ) ) ) )
{
test();
- IF( ( st_fx->rf_flag == 0 ) && ( GT_32( st_fx->total_brate, ACELP_9k60 ) ) )
+ IF( ( ( st_fx->rf_flag == 0 ) ) && ( GT_32( st_fx->total_brate, ACELP_9k60 ) ) )
{
FOR( i = 0; i < NUM_Q_LSF; i++ )
{
- hBWE_TD->lsf_idx[i] = get_next_indice( st_fx, lsf_q_num_bits[i] );
+ hBWE_TD->lsf_idx[i] = (Word16) get_next_indice( st_fx, lsf_q_num_bits[i] );
move16();
}
- hBWE_TD->m_idx = get_next_indice( st_fx, MIRROR_POINT_BITS );
-
- hBWE_TD->grid_idx = get_next_indice( st_fx, NUM_LSF_GRID_BITS );
+ hBWE_TD->m_idx = (Word16) get_next_indice( st_fx, MIRROR_POINT_BITS );
+ move16();
+ hBWE_TD->grid_idx = (Word16) get_next_indice( st_fx, NUM_LSF_GRID_BITS );
+ move16();
}
ELSE
{
- hBWE_TD->lsf_idx[0] = get_next_indice( st_fx, 8 );
+ hBWE_TD->lsf_idx[0] = (Word16) get_next_indice( st_fx, 8 );
move16();
hBWE_TD->m_idx = 0;
move16();
@@ -4664,31 +5021,37 @@ void tbe_read_bitstream_fx(
}
/* shape gains */
- hBWE_TD->idxSubGains = get_next_indice( st_fx, NUM_BITS_SHB_SUBGAINS );
+ hBWE_TD->idxSubGains = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_SUBGAINS );
+ move16();
/* frame gain */
- hBWE_TD->idxFrameGain = get_next_indice( st_fx, NUM_BITS_SHB_FRAMEGAIN );
+ hBWE_TD->idxFrameGain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_FRAMEGAIN );
+ move16();
IF( GE_32( st_fx->total_brate, ACELP_24k40 ) )
{
/* sub frame energy*/
- hBWE_TD->idx_shb_fr_gain = get_next_indice( st_fx, NUM_BITS_SHB_ENER_SF );
+ hBWE_TD->idx_shb_fr_gain = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_ENER_SF );
+ move16();
/* gain shapes residual */
FOR( i = 0; i < NB_SUBFR16k; i++ )
{
- hBWE_TD->idx_res_gs[i] = get_next_indice( st_fx, NUM_BITS_SHB_RES_GS );
+ hBWE_TD->idx_res_gs[i] = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_RES_GS );
move16();
}
/* voicing factor */
- hBWE_TD->idx_mixFac = get_next_indice( st_fx, NUM_BITS_SHB_VF );
+ hBWE_TD->idx_mixFac = (Word16) get_next_indice( st_fx, NUM_BITS_SHB_VF );
+ move16();
}
IF( EQ_16( st_fx->tec_tfa, 1 ) )
{
- st_fx->tec_flag = get_next_indice( st_fx, BITS_TEC );
- st_fx->tfa_flag = get_next_indice( st_fx, BITS_TFA );
+ st_fx->tec_flag = (Word16) get_next_indice( st_fx, BITS_TEC );
+ move16();
+ st_fx->tfa_flag = (Word16) get_next_indice( st_fx, BITS_TFA );
+ move16();
test();
IF( st_fx->tfa_flag && st_fx->tec_flag )
{
@@ -4709,7 +5072,8 @@ void tbe_read_bitstream_fx(
IF( EQ_16( st_fx->bwidth, FB ) )
{
- hBWE_TD->idxGain = get_next_indice( st_fx, 4 );
+ hBWE_TD->idxGain = (Word16) get_next_indice( st_fx, 4 );
+ move16();
}
}
@@ -4767,12 +5131,14 @@ void GenTransition_fx(
{
L_tmp = L_mult( window_shb_32k_fx[i], old_hb_synth[L_SHB_TRANSITION_LENGTH - 1 - i] );
output[i] = mac_r( L_tmp, window_shb_32k_fx[2 * L_SHB_LAHEAD - 1 - i], syn_overlap_32k[i] );
+ move16();
}
/* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */
FOR( ; i < length; i++ )
{
output[i] = old_hb_synth[L_SHB_TRANSITION_LENGTH - 1 - i];
+ move16();
}
IF( EQ_32( target_fs, 48000 ) )
@@ -4872,6 +5238,7 @@ void TBEreset_dec_fx(
{
set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
+ move32();
st_fx->prev_Q_bwe_exc = 31;
move16();
}
@@ -4905,8 +5272,10 @@ void TBEreset_dec_fx(
IF( EQ_16( bandwidth, FB ) )
{
st_fx->prev_fb_ener_adjust_fx = 0;
+ move16();
set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER );
hBWE_TD->fb_tbe_demph_fx = 0;
+ move16();
fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx );
}
}
@@ -4923,10 +5292,11 @@ void TBEreset_dec_ivas_fx(
hBWE_TD = st->hBWE_TD;
- IF( NE_16( st->last_core, ACELP_CORE ) )
+ IF( st->last_core != ACELP_CORE )
{
set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
+ move32();
st->prev_Q_bwe_exc = 31;
move16();
}
@@ -4953,19 +5323,23 @@ void TBEreset_dec_ivas_fx(
set16_fx( hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1 );
set32_fx( hBWE_TD->mem_resamp_HB_32k_fx_32, 0, 2 * ALLPASSSECTIONS_STEEP + 1 );
hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */
- hBWE_TD->prev_mix_factor_fx = 32767; /* Q15 1.f */
+ move32();
+ hBWE_TD->prev_mix_factor_fx = 32767; /* Q15 1.f */
+ move16();
// swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx );
swb_tbe_reset_synth_ivas_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32 );
IF( EQ_16( st->bwidth, FB ) )
{
- IF( st->hBWE_FD != NULL )
+ if ( st->hBWE_FD != NULL )
{
st->prev_fb_ener_adjust_fx = 0;
+ move16();
}
set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER );
hBWE_TD->fb_tbe_demph_fx = 0;
+ move16();
fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx );
}
}
@@ -5049,6 +5423,7 @@ void td_bwe_dec_init_ivas_fx(
set16_fx( hBWE_TD->old_hb_synth_fx, 0, L_FRAME48k );
hBWE_TD->prev_ener_fx = L_deposit_l( 0 );
+ move32();
return;
}
@@ -5124,7 +5499,7 @@ void td_bwe_dec_init_fx(
hBWE_TD->prev_ener_fx = L_deposit_l( 0 );
-
+ move32();
return;
}
diff --git a/lib_dec/syn_outp_fx.c b/lib_dec/syn_outp_fx.c
index d291ba3e4fb92265c96fc97a614cbff875d7e258..0cdf219731e787f98811661b847a02f8d4bf9947 100644
--- a/lib_dec/syn_outp_fx.c
+++ b/lib_dec/syn_outp_fx.c
@@ -3,10 +3,9 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Debug prototypes */
-#include "prot_fx2.h" /* Debug prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "prot_fx.h" /* Debug prototypes */
/*-------------------------------------------------------------------*
* syn_output()
@@ -27,6 +26,7 @@ void syn_output_fx(
/*tmp = sub(Q_syn2, 1); */
tmp = Q_syn2;
+ move16();
/*-----------------------------------------------------------------*
* Output synthesis signal with compensation for saturation
@@ -45,6 +45,7 @@ void syn_output_fx(
#else
synth_out[i] = round_fx( L_shr( L_tmp, tmp ) );
#endif
+ move16();
}
}
ELSE
@@ -72,6 +73,7 @@ void unscale_AGC(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*----------------------------------------------------------------*
@@ -109,6 +111,7 @@ void unscale_AGC(
L_tmp = L_shr( L_tmp, -1 ); /* saturation can occur here */
y[0] = round_fx( L_tmp );
+ move16();
FOR( i = 1; i < n; i++ )
{
@@ -119,10 +122,11 @@ void unscale_AGC(
L_tmp = L_msu( L_tmp, fac, x[i] );
L_tmp = L_msu( L_tmp, fac, x[i - 1] );
y[i] = round_fx( L_tmp );
+ move16();
}
mem[0] = fac;
move16();
- mem[1] = shr( x[sub( i, 1 )], 1 );
+ mem[1] = shr( x[i - 1], 1 );
move16();
}
diff --git a/lib_dec/tcq_core_dec_fx.c b/lib_dec/tcq_core_dec_fx.c
index 894372201c74e4999e08b69604138624bbe2144e..fcfe057ba00daec6e63e55f6845695eb5412d7b4 100644
--- a/lib_dec/tcq_core_dec_fx.c
+++ b/lib_dec/tcq_core_dec_fx.c
@@ -6,8 +6,7 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*---------------------------------------------------------------------*
* tcq_core_LR_dec()
*
@@ -34,6 +33,7 @@ void tcq_core_LR_dec_fx(
Word16 i, j, k;
Word32 Rk_sort_fx[NB_SFM];
Word16 flag_wbnb = 0;
+ move16();
Word16 USQ_TCQ[NB_SFM]; /* TCQ is selected by default*/
Word16 nb_bytes, pulsesnum, nz;
@@ -45,19 +45,28 @@ void tcq_core_LR_dec_fx(
TCQ_BITSTREAM bs_fx, *pbs_fx;
Word16 nzb = 0;
+ move16();
Word16 nzbands = 0;
+ move16();
Word16 lsbtcq_bits = TCQ_AMP;
+ move16();
Word16 tcq_arbits = 2;
+ move16();
/* LSB TCQ variables*/
Word16 dpath[280];
Word16 bcount = 0;
+ move16();
Word32 bsub_fx = 0;
+ move32();
Word16 mbuffer_fx[560];
Word32 leftbits = 0;
+ move32();
Word32 sepbits = 0;
+ move32();
Word32 divider = 0;
+ move32();
#ifndef BASOP_NOGLOB_DECLARE_LOCAL
if ( Overflow == 1 )
@@ -74,7 +83,7 @@ void tcq_core_LR_dec_fx(
test();
test();
- IF( LE_16( input_frame, L_FRAME16k ) && adjustFlag == 0 && *is_transient == 0 )
+ IF( LE_16( input_frame, L_FRAME16k ) && ( adjustFlag == 0 ) && ( *is_transient == 0 ) )
{
flag_wbnb = 1;
move16();
@@ -89,7 +98,9 @@ void tcq_core_LR_dec_fx(
pbs_fx->curPos = 7;
move16();
pbs_fx->numbits = L_deposit_l( 0 );
+ move32();
pbs_fx->numByte = L_deposit_l( 0 );
+ move32();
/* Bits distribution analysis*/
FOR( i = 0; i < BANDS; i++ )
@@ -125,15 +136,17 @@ void tcq_core_LR_dec_fx(
{
bsub_fx = L_add( bsub_fx, 2048 );
}
- FOR( j = BANDS - 1; j >= 0; j-- )
+ FOR( j = sub( BANDS, 1 ); j >= 0; j-- )
{
IF( Rk_fx[j] > 0 )
{
Rk_fx[j] = L_sub( Rk_fx[j], ar_div( bsub_fx, nzb ) );
+ move32();
IF( Rk_fx[j] < 0 )
{
bsub_fx = L_sub( bsub_fx, L_add( ar_div( bsub_fx, nzb ), Rk_fx[j] ) );
Rk_fx[j] = L_deposit_l( 0 );
+ move32();
}
ELSE
{
@@ -157,8 +170,9 @@ void tcq_core_LR_dec_fx(
IF( k > 0 )
{
Word16 tmp;
- tmp = (UWord8) get_next_indice( st_fx, k );
+ tmp = (Word16) get_next_indice( st_fx, k );
pbs_fx->buf[nb_bytes] = (UWord8) shl( tmp, sub( 8, k ) );
+ move16();
/* i++;
nb_bytes++; */
i = add( i, 1 );
@@ -183,7 +197,7 @@ void tcq_core_LR_dec_fx(
test();
test();
- IF( LE_16( input_frame, L_FRAME16k ) && adjustFlag == 0 && *is_transient == 0 )
+ IF( LE_16( input_frame, L_FRAME16k ) && ( adjustFlag == 0 ) && ( *is_transient == 0 ) )
{
surplus_fx = -131072;
move32(); /*16 */
@@ -194,6 +208,7 @@ void tcq_core_LR_dec_fx(
move16();
FOR( j = 0; j < BANDS; j++ )
{
+ test();
IF( EQ_16( j, k_num[0] ) || EQ_16( j, k_num[1] ) )
{
sepbits = L_add( sepbits, Rk_fx[k_sort[j]] );
@@ -215,7 +230,7 @@ void tcq_core_LR_dec_fx(
{
test();
test();
- IF( Rk_fx[k_sort[k]] > 0 && USQ_TCQ[k_sort[k]] == 0 )
+ IF( ( Rk_fx[k_sort[k]] > 0 ) && ( USQ_TCQ[k_sort[k]] == 0 ) )
{
/* When number of bits per band is less than
arithmetic bits overhead, this band is not encoded.
@@ -228,7 +243,7 @@ void tcq_core_LR_dec_fx(
move16();
FOR( i = 0; i < band_width[k_sort[k]]; i++ )
{
- inp_vector_fx[band_start[k_sort[k]] + i] = 0;
+ inp_vector_fx[add( band_start[k_sort[k]], i )] = 0;
move16();
}
IF( surplus_fx != 0 )
@@ -253,7 +268,7 @@ void tcq_core_LR_dec_fx(
nzbands--;
move16();
}
- ELSE IF( Rk_fx[k_sort[k]] > 0 && EQ_16( USQ_TCQ[k_sort[k]], 1 ) )
+ ELSE IF( ( Rk_fx[k_sort[k]] > 0 ) && EQ_16( USQ_TCQ[k_sort[k]], 1 ) )
{
/* When number of bits per band is less than
arithmetic bits overhead, this band is not encoded.
@@ -266,7 +281,7 @@ void tcq_core_LR_dec_fx(
move16();
FOR( i = 0; i < band_width[k_sort[k]]; i++ )
{
- inp_vector_fx[band_start[k_sort[k]] + i] = 0;
+ inp_vector_fx[add( band_start[k_sort[k]], i )] = 0;
move16();
}
IF( surplus_fx != 0 )
@@ -295,7 +310,7 @@ void tcq_core_LR_dec_fx(
move16();
FOR( i = 0; i < band_width[k_sort[k]]; i++ )
{
- inp_vector_fx[band_start[k_sort[k]] + i] = 0;
+ inp_vector_fx[add( band_start[k_sort[k]], i )] = 0;
move16();
}
}
@@ -305,25 +320,28 @@ void tcq_core_LR_dec_fx(
delta_fx = L_deposit_l( 0 );
test();
- IF( Rk_fx[k_sort[k]] > 0 && surplus_fx < 0 )
+ IF( ( Rk_fx[k_sort[k]] > 0 ) && ( surplus_fx < 0 ) )
{
- IF( nzbands <= 1 )
+ IF( LE_16( nzbands, 1 ) )
{
divider = 0;
+ move32();
}
ELSE
{
divider = 2;
+ move32();
}
IF( L_add( L_add( surplus_fx, sepbits ), ar_div( leftbits, divider ) ) < 0 )
{
/* Overflow possible => start to distribute negative surplus */
- delta_fx = ar_div( surplus_fx + sepbits, nzbands );
+ delta_fx = ar_div( L_add( surplus_fx, sepbits ), nzbands );
}
- else
+ ELSE
{
delta_fx = 0;
+ move32();
}
surplus_fx = L_sub( surplus_fx, delta_fx );
}
@@ -336,13 +354,16 @@ void tcq_core_LR_dec_fx(
IF( ( GT_32( surplus_fx, 524288 ) && EQ_16( input_frame, L_FRAME8k ) ) || ( GT_32( surplus_fx, 786432 ) && EQ_16( input_frame, L_FRAME16k ) ) )
{
bit_surplus_fx[0] = Mult_32_16( surplus_fx, 24576 ); /* Q16 */
- bit_surplus_fx[1] = Mult_32_16( surplus_fx, 8192 ); /* Q16 */
+ move32();
+ bit_surplus_fx[1] = Mult_32_16( surplus_fx, 8192 ); /* Q16 */
+ move32();
}
ELSE
{
bit_surplus_fx[0] = surplus_fx;
move32();
bit_surplus_fx[1] = L_deposit_l( 0 );
+ move32();
}
FOR( k = 0; k < BANDS; k++ )
@@ -356,7 +377,7 @@ void tcq_core_LR_dec_fx(
test();
test();
- IF( Rk_fx[k_sort[k]] > 0 && USQ_TCQ[k_sort[k]] == 0 )
+ IF( ( Rk_fx[k_sort[k]] > 0 ) && ( USQ_TCQ[k_sort[k]] == 0 ) )
{
/* get number of pulses */
pulsesnum = GetScale_fx( band_width[k_sort[k]], Rk_fx[k_sort[k]], &surplus_fx );
@@ -366,7 +387,7 @@ void tcq_core_LR_dec_fx(
decode_mangitude_tcq_fx( pardec_fx, band_width[k_sort[k]], pulsesnum, nz, &positions_fx[band_start[k_sort[k]]], &inp_vector_fx[band_start[k_sort[k]]], &surplus_fx );
decode_signs_fx( pardec_fx, band_width[k_sort[k]], &inp_vector_fx[band_start[k_sort[k]]] );
}
- ELSE IF( Rk_fx[k_sort[k]] > 0 && USQ_TCQ[k_sort[k]] == 1 )
+ ELSE IF( ( Rk_fx[k_sort[k]] > 0 ) && EQ_16( USQ_TCQ[k_sort[k]], 1 ) )
{
pulsesnum = GetScale_fx( band_width[k_sort[k]], Rk_fx[k_sort[k]], &surplus_fx );
@@ -381,7 +402,7 @@ void tcq_core_LR_dec_fx(
move16();
FOR( i = 0; i < band_width[k_sort[k]]; i++ )
{
- inp_vector_fx[band_start[k_sort[k]] + i] = 0;
+ inp_vector_fx[add( band_start[k_sort[k]], i )] = 0;
move16();
}
}
@@ -398,7 +419,7 @@ void tcq_core_LR_dec_fx(
{
IF( Rk_fx[k_sort[k]] > 0 )
{
- pulsesnum = GetScale_fx( band_width[k_sort[k]], Rk_fx[k_sort[k]] + delta_fx, &surplus_fx );
+ pulsesnum = GetScale_fx( band_width[k_sort[k]], L_add( Rk_fx[k_sort[k]], delta_fx ), &surplus_fx );
decode_position_ari_fx( pardec_fx, band_width[k_sort[k]], pulsesnum, &nz, &positions_fx[band_start[k_sort[k]]] );
@@ -414,7 +435,7 @@ void tcq_core_LR_dec_fx(
move16();
FOR( i = 0; i < band_width[k_sort[k]]; i++ )
{
- inp_vector_fx[band_start[k_sort[k]] + i] = 0;
+ inp_vector_fx[add( band_start[k_sort[k]], i )] = 0;
move16();
}
}
@@ -424,7 +445,7 @@ void tcq_core_LR_dec_fx(
/* surplus distribution */
test();
- IF( surplus_fx > 0 && nzbands > 0 )
+ IF( ( surplus_fx > 0 ) && ( nzbands > 0 ) )
{
delta_fx = ar_div( surplus_fx, nzbands );
surplus_fx = L_sub( surplus_fx, delta_fx );
@@ -435,7 +456,7 @@ void tcq_core_LR_dec_fx(
/* Load TCQ path from bitstream */
LoadTCQdata_fx( pardec_fx, dpath, lsbtcq_bits );
- TCQLSBdec_fx( dpath, mbuffer_fx, 2 * lsbtcq_bits );
+ TCQLSBdec_fx( dpath, mbuffer_fx, i_mult( 2, lsbtcq_bits ) );
ar_decoder_done_fx( pardec_fx );
@@ -456,7 +477,7 @@ void tcq_core_LR_dec_fx(
{
test();
test();
- IF( Rk_fx[k_sort[k]] > 0 && k != k_num[0] && k != k_num[1] )
+ IF( ( Rk_fx[k_sort[k]] > 0 ) && NE_16( k, k_num[0] ) && NE_16( k, k_num[1] ) )
{
RestoreTCQdec_fx( &inp_vector_fx[band_start[k_sort[k]]], band_width[k_sort[k]], &bcount, mbuffer_fx );
}
@@ -466,7 +487,7 @@ void tcq_core_LR_dec_fx(
{
test();
test();
- IF( Rk_fx[k_sort[k]] > 0 && ( k == k_num[0] || k == k_num[1] ) )
+ IF( ( Rk_fx[k_sort[k]] > 0 ) && ( EQ_16( k, k_num[0] ) || EQ_16( k, k_num[1] ) ) )
{
RestoreTCQdec_fx( &inp_vector_fx[band_start[k_sort[k]]], band_width[k_sort[k]], &bcount, mbuffer_fx );
}
diff --git a/lib_dec/tcx_utils_dec_fx.c b/lib_dec/tcx_utils_dec_fx.c
index be8d5237d0e62451da096ae725b7e2a7e641296c..e6a0dd26200f7157e421ae139e283f2fc27100e2 100644
--- a/lib_dec/tcx_utils_dec_fx.c
+++ b/lib_dec/tcx_utils_dec_fx.c
@@ -1,385 +1,398 @@
-/*====================================================================================
- EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
- ====================================================================================*/
-
-
-#include
-#include
-#include
-#include
-#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
-#include "rom_basop_util.h"
-#include "basop_util.h"
-#include "rom_com.h"
-
-/*---------------------------------------------------------------
- * tcx_decoder_memory_update()
- *
- *
- *--------------------------------------------------------------*/
-void tcx_decoder_memory_update(
- Word16 *xn_buf, /* i/o: mdct output buffer used also as temporary buffer */
- Word16 *synthout, /* o: synth */
- Word16 *A, /* i: Quantized LPC coefficients */
- Decoder_State *st, /* i/o: decoder memory state */
- Word8 fb /* i: fullband flag */
-)
-{
- Word16 tmp;
- Word16 *synth;
- Word16 buf[1 + M + LFAC + L_FRAME_PLUS];
- Word16 L_frame_glob;
- Word16 preemph;
-
- L_frame_glob = st->L_frame;
- preemph = st->preemph_fac;
- move16();
-
- /* Output synth */
- Copy( xn_buf, synthout, L_frame_glob );
-
- /* Update synth */
-
- synth = buf + M + 1;
- Copy( st->syn, buf, M + 1 );
- Copy( xn_buf, synth, L_frame_glob );
- Copy( synth + sub( L_frame_glob, M + 1 ), st->syn, M + 1 );
-
-#ifndef FIX_778_STEREO_BRATE_SWITCHING
- IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
-#endif
- {
- IF( !fb ) /* TV2FhG -> Condition differs from floating point */
- {
-
- /* Emphasis of synth -> synth_pe */
- tmp = synth[-M - 1];
- move16();
-#ifdef FIX_778_STEREO_BRATE_SWITCHING
- IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
-#endif
- st->Q_syn = E_UTIL_f_preemph3( synth - M, preemph, add( M, L_frame_glob ), &tmp, 1 );
- st->prev_Q_syn = st->Q_syn = st->Q_syn - 1;
-#ifdef FIX_778_STEREO_BRATE_SWITCHING
- }
- ELSE
- {
- E_UTIL_f_preemph2( 2, synth - M, preemph, add( M, L_frame_glob ), &tmp );
- st->prev_Q_syn = st->Q_syn = 0; /* in case of MDCT, Q0 seems to be used*/
- }
-#endif
- Copy( synth + sub( L_frame_glob, M ), st->mem_syn2_fx, M );
- Copy( synth + sub( L_frame_glob, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM );
-#ifdef FIX_778_STEREO_BRATE_SWITCHING
- IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
-#endif
- test();
- IF( st->tcxonly == 0 || LE_16( L_frame_glob, L_FRAME16k ) )
- {
- /* Update excitation */
- IF( NE_16( st->Q_syn + 1, st->Q_exc ) )
- {
- Scale_sig( st->old_exc_fx, L_EXC_MEM_DEC, sub( st->Q_syn + 1, st->Q_exc ) );
- }
- st->Q_exc = st->Q_syn + 1;
- st->Q_subfr[0] = st->Q_subfr[1] = st->Q_subfr[2] = st->Q_subfr[3] = st->Q_subfr[4] = st->Q_exc;
-
- assert( L_frame_glob < L_EXC_MEM_DEC );
- Copy( st->old_exc_fx + L_frame_glob, st->old_exc_fx, sub( L_EXC_MEM_DEC, L_frame_glob ) );
- Residu3_fx( A, synth, st->old_exc_fx + sub( L_EXC_MEM_DEC, L_frame_glob ), L_frame_glob, 1 );
- }
- /* Update old_Aq */
- Copy( A, st->old_Aq_12_8_fx, M + 1 );
-#ifdef FIX_778_STEREO_BRATE_SWITCHING
- }
-#endif
- }
- }
- return;
-}
-
-/* Returns: number of bits used (including "bits") */
-Word16 tcx_ari_res_invQ_spec(
- Word32 x_Q[], /* i/o: quantized spectrum Q31-e */
- Word16 x_Q_e, /* i: quantized spectrum exponent Q0 */
- Word16 L_frame, /* i: number of lines Q0 */
- const Word16 prm[], /* i: bitstream Q0 */
- Word16 target_bits, /* i: number of bits available Q0 */
- Word16 bits, /* i: number of bits used so far Q0 */
- Word16 deadzone, /* i: quantizer deadzone Q15 */
- const Word16 x_fac[] /* i: spectrum post-quantization factors Q14 */
-)
-{
- Word16 i, j, num_zeros;
- Word16 zeros[L_FRAME_PLUS];
- Word16 fac_p, sign;
- Word32 L_tmp;
- Word16 s;
-
-
- /* Limit the number of residual bits */
- target_bits = s_min( target_bits, NPRM_RESQ );
-
-
- /* Requantize the spectrum line-by-line */
- /* fac_m = deadzone * 0.5f; */
- num_zeros = 0;
- move16();
-
- FOR( i = 0; i < L_frame; i++ )
- {
- IF( GE_16( bits, target_bits ) ) /* no bits left */
- {
- BREAK;
- }
-
- IF( x_Q[i] != 0 )
- {
- sign = x_fac[i];
- move16();
- if ( x_Q[i] < 0 )
- sign = negate( sign );
-
- /* x_Q[i] += sign*(prm[bits++] * 0.5f - fac_m); */
- x_Q[i] = L_sub( x_Q[i], L_shr( L_mult( sign, add( deadzone, lshl( prm[bits], 15 ) ) ), x_Q_e ) );
- move32();
- bits = add( bits, 1 );
- }
- ELSE
- {
- zeros[num_zeros] = i;
- move16();
- num_zeros = add( num_zeros, 1 );
- }
- }
-
- /* Requantize zeroed-lines of the spectrum */
- fac_p = msu_r( 1417339264l /*0.33f*2.0f Q31*/, deadzone, 21627 /*0.33f*2.0f Q15*/ ); /* Q15 */
- target_bits = sub( target_bits, 1 ); /* reserve 1 bit for the check below */
-
- s = sub( x_Q_e, 1 );
- FOR( j = 0; j < num_zeros; j++ )
- {
- IF( GE_16( bits, target_bits ) ) /* 1 or 0 bits left */
- {
- BREAK;
- }
-
- i = zeros[j];
- move16();
-
- IF( prm[bits] != 0 )
- {
- bits = add( bits, 1 );
- L_tmp = L_mult( fac_p, x_fac[i] ); /* Q30 */
- if ( prm[bits] == 0 )
- L_tmp = L_negate( L_tmp );
- x_Q[i] = L_shr( L_tmp, s );
- move32();
- }
- bits = add( bits, 1 );
- }
-
-
- return bits;
-}
-/*---------------------------------------------------------------
- * tcx_res_invQ_gain()
- *
- *
- *--------------------------------------------------------------*/
-Word16 tcx_res_invQ_gain(
- Word16 *gain_tcx,
- Word16 *gain_tcx_e,
- Word16 *prm,
- Word16 resQBits )
-{
- Word16 bits;
- Word16 gain, tmp1, tmp2;
-
-
- gain = *gain_tcx;
- move16();
-
- /* make sure we have a bit of headroom */
- IF( GT_16( gain, 0x7000 ) )
- {
- gain = shr( gain, 1 );
- *gain_tcx_e = add( *gain_tcx_e, 1 );
- move16();
- }
-
- /*Refine the gain quantization*/
- tmp1 = s_min( resQBits, TCX_RES_Q_BITS_GAIN );
- FOR( bits = 0; bits < tmp1; bits++ )
- {
- tmp2 = gain_corr_fac[bits];
- move16();
- if ( prm[bits] == 0 )
- {
- tmp2 = gain_corr_inv_fac[bits];
- move16();
- }
-
- gain = mult_r( gain, tmp2 );
- if ( prm[bits] != 0 )
- gain = shl( gain, 1 );
- }
-
- *gain_tcx = gain;
- move16();
-
-
- return bits;
-}
-
-/*---------------------------------------------------------------
- * tcx_res_invQ_spec()
- *
- *
- *--------------------------------------------------------------*/
-Word16 tcx_res_invQ_spec(
- Word32 *x,
- Word16 x_e,
- Word16 L_frame,
- Word16 *prm,
- Word16 resQBits,
- Word16 bits,
- Word16 sq_round,
- const Word16 lf_deemph_factors[] )
-{
- Word16 i;
- Word16 fac_m, fac_p;
- Word16 lf_deemph_factor, c, s;
- Word32 tmp;
-
-
- /* Limit the number of residual bits */
- resQBits = s_min( resQBits, NPRM_RESQ );
-
- /* Requantize the spectrum line-by-line */
- fac_m = shr( sq_round, 1 );
- fac_p = sub( 0x4000, fac_m );
-
- lf_deemph_factor = 0x4000;
- move16();
- s = sub( x_e, 1 );
-
- FOR( i = 0; i < L_frame; i++ )
- {
- IF( GE_16( bits, resQBits ) )
- {
- BREAK;
- }
-
- test();
- test();
- IF( ( x[i] != 0 ) && ( ( lf_deemph_factors == NULL ) || ( GT_16( lf_deemph_factors[i], 0x2000 ) ) ) )
- {
- if ( lf_deemph_factors != NULL )
- {
- lf_deemph_factor = lf_deemph_factors[i];
- move16();
- }
-
- IF( prm[bits] == 0 )
- {
-
- /* Debug initialization to catch illegal cases of x[i] */
- tmp = 0;
-
- if ( x[i] > 0 )
- tmp = L_mult( fac_m, lf_deemph_factor );
- if ( x[i] < 0 )
- tmp = L_mult( fac_p, lf_deemph_factor );
-
- assert( tmp != 0 );
-
- x[i] = L_sub( x[i], L_shr( tmp, s ) );
- move32();
- }
- ELSE
- {
-
- /* Debug initialization to catch illegal cases of x[i] */
- tmp = 0;
-
- if ( x[i] > 0 )
- tmp = L_mult( fac_p, lf_deemph_factor );
- if ( x[i] < 0 )
- tmp = L_mult( fac_m, lf_deemph_factor );
-
- assert( tmp != 0 );
-
- x[i] = L_add( x[i], L_shr( tmp, s ) );
- move32();
- }
- bits = add( bits, 1 );
- }
- }
-
- /*Quantize zeroed-line of the spectrum*/
- resQBits = sub( resQBits, 1 );
-
- IF( lf_deemph_factors == NULL )
- {
- FOR( i = 0; i < L_frame; i++ )
- {
- IF( GE_16( bits, resQBits ) )
- {
- BREAK;
- }
-
- IF( x[i] == 0 )
- {
- IF( prm[bits] != 0 )
- {
- bits = add( bits, 1 );
-
- tmp = L_mult( 21627 /*1.32f Q14*/, fac_p );
- if ( prm[bits] == 0 )
- tmp = L_negate( tmp );
-
- x[i] = L_shr( tmp, s );
- move32();
- }
- bits = add( bits, 1 );
- }
- }
- }
- ELSE
- {
- c = sub( 21627 /*0.66f Q15*/, mult_r( sq_round, 21627 /*0.66f Q15*/ ) );
-
- FOR( i = 0; i < L_frame; i++ )
- {
- IF( GE_16( bits, resQBits ) )
- {
- BREAK;
- }
-
- test();
- IF( ( x[i] == 0 ) && ( GT_16( lf_deemph_factors[i], 0x2000 ) ) )
- {
- IF( prm[bits] != 0 )
- {
- bits = add( bits, 1 );
-
- tmp = L_mult( c, lf_deemph_factors[i] );
- if ( prm[bits] == 0 )
- tmp = L_negate( tmp );
-
- x[i] = L_shr( tmp, s );
- move32();
- }
- bits = add( bits, 1 );
- }
- }
- }
-
- return bits;
-}
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+
+#include
+#include
+#include
+#include
+#include "options.h"
+#include "prot_fx.h"
+#include "rom_basop_util.h"
+#include "basop_util.h"
+#include "rom_com.h"
+
+/*---------------------------------------------------------------
+ * tcx_decoder_memory_update()
+ *
+ *
+ *--------------------------------------------------------------*/
+void tcx_decoder_memory_update(
+ Word16 *xn_buf, /* i/o: mdct output buffer used also as temporary buffer */
+ Word16 *synthout, /* o: synth */
+ Word16 *A, /* i: Quantized LPC coefficients */
+ Decoder_State *st, /* i/o: decoder memory state */
+ Word8 fb /* i: fullband flag */
+)
+{
+ Word16 tmp;
+ Word16 *synth;
+ Word16 buf[1 + M + LFAC + L_FRAME_PLUS];
+ Word16 L_frame_glob;
+ Word16 preemph;
+
+ L_frame_glob = st->L_frame;
+ move16();
+ preemph = st->preemph_fac;
+ move16();
+
+ /* Output synth */
+ Copy( xn_buf, synthout, L_frame_glob );
+
+ /* Update synth */
+
+ synth = buf + M + 1;
+ Copy( st->syn, buf, M + 1 );
+ Copy( xn_buf, synth, L_frame_glob );
+ Copy( synth + sub( L_frame_glob, M + 1 ), st->syn, M + 1 );
+
+#ifndef FIX_778_STEREO_BRATE_SWITCHING
+ IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
+#endif
+ {
+ IF( !fb ) /* TV2FhG -> Condition differs from floating point */
+ {
+
+ /* Emphasis of synth -> synth_pe */
+ tmp = synth[-M - 1];
+ move16();
+#ifdef FIX_778_STEREO_BRATE_SWITCHING
+ IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+#endif
+ st->Q_syn = E_UTIL_f_preemph3( synth - M, preemph, add( M, L_frame_glob ), &tmp, 1 );
+ move16();
+ st->prev_Q_syn = st->Q_syn = sub( st->Q_syn, 1 );
+ move16();
+ move16();
+#ifdef FIX_778_STEREO_BRATE_SWITCHING
+ }
+ ELSE
+ {
+ E_UTIL_f_preemph2( 2, synth - M, preemph, add( M, L_frame_glob ), &tmp );
+ st->prev_Q_syn = st->Q_syn = 0; /* in case of MDCT, Q0 seems to be used*/
+ move16();
+ move16();
+ }
+#endif
+ Copy( synth + sub( L_frame_glob, M ), st->mem_syn2_fx, M );
+ Copy( synth + sub( L_frame_glob, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM );
+#ifdef FIX_778_STEREO_BRATE_SWITCHING
+ IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+#endif
+ test();
+ IF( ( st->tcxonly == 0 ) || LE_16( L_frame_glob, L_FRAME16k ) )
+ {
+ /* Update excitation */
+ IF( NE_16( add( st->Q_syn, 1 ), st->Q_exc ) )
+ {
+ Scale_sig( st->old_exc_fx, L_EXC_MEM_DEC, sub( add( st->Q_syn, 1 ), st->Q_exc ) );
+ }
+ st->Q_exc = add( st->Q_syn, 1 );
+ move16();
+ st->Q_subfr[0] = st->Q_subfr[1] = st->Q_subfr[2] = st->Q_subfr[3] = st->Q_subfr[4] = st->Q_exc;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+
+ assert( L_frame_glob < L_EXC_MEM_DEC );
+ Copy( st->old_exc_fx + L_frame_glob, st->old_exc_fx, sub( L_EXC_MEM_DEC, L_frame_glob ) );
+ Residu3_fx( A, synth, st->old_exc_fx + sub( L_EXC_MEM_DEC, L_frame_glob ), L_frame_glob, 1 );
+ }
+ /* Update old_Aq */
+ Copy( A, st->old_Aq_12_8_fx, M + 1 );
+#ifdef FIX_778_STEREO_BRATE_SWITCHING
+ }
+#endif
+ }
+ }
+ return;
+}
+
+/* Returns: number of bits used (including "bits") */
+Word16 tcx_ari_res_invQ_spec(
+ Word32 x_Q[], /* i/o: quantized spectrum Q31-e */
+ Word16 x_Q_e, /* i: quantized spectrum exponent Q0 */
+ Word16 L_frame, /* i: number of lines Q0 */
+ const Word16 prm[], /* i: bitstream Q0 */
+ Word16 target_bits, /* i: number of bits available Q0 */
+ Word16 bits, /* i: number of bits used so far Q0 */
+ Word16 deadzone, /* i: quantizer deadzone Q15 */
+ const Word16 x_fac[] /* i: spectrum post-quantization factors Q14 */
+)
+{
+ Word16 i, j, num_zeros;
+ Word16 zeros[L_FRAME_PLUS];
+ Word16 fac_p, sign;
+ Word32 L_tmp;
+ Word16 s;
+
+
+ /* Limit the number of residual bits */
+ target_bits = s_min( target_bits, NPRM_RESQ );
+
+
+ /* Requantize the spectrum line-by-line */
+ /* fac_m = deadzone * 0.5f; */
+ num_zeros = 0;
+ move16();
+
+ FOR( i = 0; i < L_frame; i++ )
+ {
+ IF( GE_16( bits, target_bits ) ) /* no bits left */
+ {
+ BREAK;
+ }
+
+ IF( x_Q[i] != 0 )
+ {
+ sign = x_fac[i];
+ move16();
+ if ( x_Q[i] < 0 )
+ sign = negate( sign );
+
+ /* x_Q[i] += sign*(prm[bits++] * 0.5f - fac_m); */
+ x_Q[i] = L_sub( x_Q[i], L_shr( L_mult( sign, add( deadzone, lshl( prm[bits], 15 ) ) ), x_Q_e ) );
+ move32();
+ bits = add( bits, 1 );
+ }
+ ELSE
+ {
+ zeros[num_zeros] = i;
+ move16();
+ num_zeros = add( num_zeros, 1 );
+ }
+ }
+
+ /* Requantize zeroed-lines of the spectrum */
+ fac_p = msu_r( 1417339264l /*0.33f*2.0f Q31*/, deadzone, 21627 /*0.33f*2.0f Q15*/ ); /* Q15 */
+ target_bits = sub( target_bits, 1 ); /* reserve 1 bit for the check below */
+
+ s = sub( x_Q_e, 1 );
+ FOR( j = 0; j < num_zeros; j++ )
+ {
+ IF( GE_16( bits, target_bits ) ) /* 1 or 0 bits left */
+ {
+ BREAK;
+ }
+
+ i = zeros[j];
+ move16();
+
+ IF( prm[bits] != 0 )
+ {
+ bits = add( bits, 1 );
+ L_tmp = L_mult( fac_p, x_fac[i] ); /* Q30 */
+ if ( prm[bits] == 0 )
+ L_tmp = L_negate( L_tmp );
+ x_Q[i] = L_shr( L_tmp, s );
+ move32();
+ }
+ bits = add( bits, 1 );
+ }
+
+
+ return bits;
+}
+/*---------------------------------------------------------------
+ * tcx_res_invQ_gain()
+ *
+ *
+ *--------------------------------------------------------------*/
+Word16 tcx_res_invQ_gain(
+ Word16 *gain_tcx,
+ Word16 *gain_tcx_e,
+ Word16 *prm,
+ Word16 resQBits )
+{
+ Word16 bits;
+ Word16 gain, tmp1, tmp2;
+
+
+ gain = *gain_tcx;
+ move16();
+
+ /* make sure we have a bit of headroom */
+ IF( GT_16( gain, 0x7000 ) )
+ {
+ gain = shr( gain, 1 );
+ *gain_tcx_e = add( *gain_tcx_e, 1 );
+ move16();
+ }
+
+ /*Refine the gain quantization*/
+ tmp1 = s_min( resQBits, TCX_RES_Q_BITS_GAIN );
+ FOR( bits = 0; bits < tmp1; bits++ )
+ {
+ tmp2 = gain_corr_fac[bits];
+ move16();
+ if ( prm[bits] == 0 )
+ {
+ tmp2 = gain_corr_inv_fac[bits];
+ move16();
+ }
+
+ gain = mult_r( gain, tmp2 );
+ if ( prm[bits] != 0 )
+ gain = shl( gain, 1 );
+ }
+
+ *gain_tcx = gain;
+ move16();
+
+
+ return bits;
+}
+
+/*---------------------------------------------------------------
+ * tcx_res_invQ_spec()
+ *
+ *
+ *--------------------------------------------------------------*/
+Word16 tcx_res_invQ_spec(
+ Word32 *x,
+ Word16 x_e,
+ Word16 L_frame,
+ Word16 *prm,
+ Word16 resQBits,
+ Word16 bits,
+ Word16 sq_round,
+ const Word16 lf_deemph_factors[] )
+{
+ Word16 i;
+ Word16 fac_m, fac_p;
+ Word16 lf_deemph_factor, c, s;
+ Word32 tmp;
+
+
+ /* Limit the number of residual bits */
+ resQBits = s_min( resQBits, NPRM_RESQ );
+
+ /* Requantize the spectrum line-by-line */
+ fac_m = shr( sq_round, 1 );
+ fac_p = sub( 0x4000, fac_m );
+
+ lf_deemph_factor = 0x4000;
+ move16();
+ s = sub( x_e, 1 );
+
+ FOR( i = 0; i < L_frame; i++ )
+ {
+ IF( GE_16( bits, resQBits ) )
+ {
+ BREAK;
+ }
+
+ test();
+ test();
+ IF( ( x[i] != 0 ) && ( ( lf_deemph_factors == NULL ) || ( GT_16( lf_deemph_factors[i], 0x2000 ) ) ) )
+ {
+ if ( lf_deemph_factors != NULL )
+ {
+ lf_deemph_factor = lf_deemph_factors[i];
+ move16();
+ }
+
+ IF( prm[bits] == 0 )
+ {
+
+ /* Debug initialization to catch illegal cases of x[i] */
+ tmp = 0;
+ move32();
+
+ if ( x[i] > 0 )
+ tmp = L_mult( fac_m, lf_deemph_factor );
+ if ( x[i] < 0 )
+ tmp = L_mult( fac_p, lf_deemph_factor );
+
+ assert( tmp != 0 );
+
+ x[i] = L_sub( x[i], L_shr( tmp, s ) );
+ move32();
+ }
+ ELSE
+ {
+
+ /* Debug initialization to catch illegal cases of x[i] */
+ tmp = 0;
+ move32();
+
+ if ( x[i] > 0 )
+ tmp = L_mult( fac_p, lf_deemph_factor );
+ if ( x[i] < 0 )
+ tmp = L_mult( fac_m, lf_deemph_factor );
+
+ assert( tmp != 0 );
+
+ x[i] = L_add( x[i], L_shr( tmp, s ) );
+ move32();
+ }
+ bits = add( bits, 1 );
+ }
+ }
+
+ /*Quantize zeroed-line of the spectrum*/
+ resQBits = sub( resQBits, 1 );
+
+ IF( lf_deemph_factors == NULL )
+ {
+ FOR( i = 0; i < L_frame; i++ )
+ {
+ IF( GE_16( bits, resQBits ) )
+ {
+ BREAK;
+ }
+
+ IF( x[i] == 0 )
+ {
+ IF( prm[bits] != 0 )
+ {
+ bits = add( bits, 1 );
+
+ tmp = L_mult( 21627 /*1.32f Q14*/, fac_p );
+ if ( prm[bits] == 0 )
+ tmp = L_negate( tmp );
+
+ x[i] = L_shr( tmp, s );
+ move32();
+ }
+ bits = add( bits, 1 );
+ }
+ }
+ }
+ ELSE
+ {
+ c = sub( 21627 /*0.66f Q15*/, mult_r( sq_round, 21627 /*0.66f Q15*/ ) );
+
+ FOR( i = 0; i < L_frame; i++ )
+ {
+ IF( GE_16( bits, resQBits ) )
+ {
+ BREAK;
+ }
+
+ test();
+ IF( ( x[i] == 0 ) && ( GT_16( lf_deemph_factors[i], 0x2000 ) ) )
+ {
+ IF( prm[bits] != 0 )
+ {
+ bits = add( bits, 1 );
+
+ tmp = L_mult( c, lf_deemph_factors[i] );
+ if ( prm[bits] == 0 )
+ tmp = L_negate( tmp );
+
+ x[i] = L_shr( tmp, s );
+ move32();
+ }
+ bits = add( bits, 1 );
+ }
+ }
+ }
+
+ return bits;
+}
diff --git a/lib_dec/tns_base_dec_fx.c b/lib_dec/tns_base_dec_fx.c
index 5ef1756b7df69ef604f2587dc1aa4b66b8b01c0c..0631dad11f99245ea847f9793ed79ebc5f338379 100644
--- a/lib_dec/tns_base_dec_fx.c
+++ b/lib_dec/tns_base_dec_fx.c
@@ -5,8 +5,7 @@
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include
#include "rom_com.h"
diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c
index 8e2097d74fffdc8677b5e7e65e3f44c744d7859f..f3456310ad5232b9c45b87ffca39f7c427f88262 100644
--- a/lib_dec/tonalMDCTconcealment.c
+++ b/lib_dec/tonalMDCTconcealment.c
@@ -45,8 +45,7 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#endif // IVAS_FLOAT_FIXED
diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c
index 9881d47ec9bd63fb1e6694006432e47ca012f5bf..bccb9ea3f902a59bfcf791feccd29cf8fcad0802 100644
--- a/lib_dec/tonalMDCTconcealment_fx.c
+++ b/lib_dec/tonalMDCTconcealment_fx.c
@@ -12,8 +12,7 @@
#include "options.h"
#include "typedef.h"
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "stat_com.h"
#include "prot.h"
#include "ivas_prot_fx.h"
diff --git a/lib_dec/transition_dec_fx.c b/lib_dec/transition_dec_fx.c
index 46bb39bf9974d5ae801ec7b5f787f468f3982031..edb86ffd4c1382a4569a3a926497566f0e12c2bd 100644
--- a/lib_dec/transition_dec_fx.c
+++ b/lib_dec/transition_dec_fx.c
@@ -2,11 +2,10 @@
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "stl.h"
/*----------------------------------------------------------------------*
diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c
index a92130a62da642c24d702f1157b9c1a84bf18036..28de7cca5017ebd0bad10c640f58730424e5ef2a 100644
--- a/lib_dec/updt_dec_fx.c
+++ b/lib_dec/updt_dec_fx.c
@@ -5,10 +5,9 @@
#include
#include
#include "options.h"
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
/*-------------------------------------------------------------------*
* updt_dec()
diff --git a/lib_dec/vlpc_1st_dec_fx.c b/lib_dec/vlpc_1st_dec_fx.c
index 5d89a7696b5eeb67746d965cc2fb50cbe2adce0f..1ba7a64d0f188dd92a9a52d528506ac041d2fb1a 100644
--- a/lib_dec/vlpc_1st_dec_fx.c
+++ b/lib_dec/vlpc_1st_dec_fx.c
@@ -5,8 +5,7 @@
#include
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
diff --git a/lib_dec/vlpc_2st_dec_fx.c b/lib_dec/vlpc_2st_dec_fx.c
index df4d8e53e3def8608ee562b012890035011ab6d3..3aa39e86aa543aa8b5302c1d328a7f3c02912800 100644
--- a/lib_dec/vlpc_2st_dec_fx.c
+++ b/lib_dec/vlpc_2st_dec_fx.c
@@ -5,8 +5,7 @@
#include
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
//#ifdef DEBUGGING to be removed
#include
//#endif
diff --git a/lib_dec/voiced_dec_fx.c b/lib_dec/voiced_dec_fx.c
index e31032d4c867dd8674df277ee930729e1d03254f..a52332fa07db6641a544a0236737a2b329b1dc8a 100644
--- a/lib_dec/voiced_dec_fx.c
+++ b/lib_dec/voiced_dec_fx.c
@@ -4,8 +4,7 @@
#include
#include "options.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
#include "log2.h"
diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c
index e7aadde27cd978e085693c2f13d4c2fe571e08f9..095a56bc9a4f980a2172a0e2af3bce3e30a8be1e 100644
--- a/lib_dec/waveadjust_fec_dec_fx.c
+++ b/lib_dec/waveadjust_fec_dec_fx.c
@@ -6,8 +6,7 @@
#include
#include
#include
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "stat_com.h"
#include "rom_com.h"
diff --git a/lib_enc/ACcontextMapping_enc.c b/lib_enc/ACcontextMapping_enc.c
index a83ae0aca6f93e06882f85fdf322c48a86edccf8..0f37e51ded41f98065b81bd6e9cf82cdc36ea635 100644
--- a/lib_enc/ACcontextMapping_enc.c
+++ b/lib_enc/ACcontextMapping_enc.c
@@ -371,6 +371,7 @@ void ACcontextMapping_encode2_no_mem_s17_LC(
*
*-------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
static int16_t find_last_nz_pair(
const int16_t x[],
const int16_t length,
@@ -413,6 +414,53 @@ static int16_t find_last_nz_pair(
return last_nz;
}
+#else
+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;
+}
+#endif
/*-------------------------------------------------------------------*
@@ -1011,6 +1059,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS(
* Range coder bit-estimation
*-------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
int16_t *x, /* Spectral coefficients */
const int16_t nt, /* L - size of spectrum (no. of spectral coefficients) */
@@ -1366,6 +1415,426 @@ int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
return tot_bits2;
}
}
+#else
+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( ii, &p1, &idx1, hm_cfg );
+ b1_i = get_next_coeff_mapped_ivas( 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( c[p1], (int16_t) abs( x[a1_i] ) );
+ move32();
+ }
+
+ IF( s_and( idx2, 1 ) )
+ {
+ /* update second context */
+ c[p2] = update_mixed_context_ivas( c[p2], (int16_t) 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;
+}
+}
+#endif
/*-------------------------------------------------------------------*
* RCcontextMapping_encode2_estimate_bandWise_start()
@@ -1373,6 +1842,7 @@ int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
* Range coder - start bandwise bit-estimation
*-------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
int16_t RCcontextMapping_encode2_estimate_bandWise_start(
int16_t *x,
const int16_t nt,
@@ -1427,6 +1897,81 @@ int16_t RCcontextMapping_encode2_estimate_bandWise_start(
return (int16_t) hContextMem->bit_estimate;
}
+#else
+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;
+}
+#endif
/*-------------------------------------------------------------------*
* RCcontextMapping_encode2_estimate_bandWise()
@@ -1434,6 +1979,7 @@ int16_t RCcontextMapping_encode2_estimate_bandWise_start(
* Range coder - bandwise bit-estimation
*-------------------------------------------------------------------*/
+#ifndef IVAS_FLOAT_FIXED
int16_t RCcontextMapping_encode2_estimate_bandWise(
int16_t *x,
const int16_t start_line,
@@ -1515,3 +2061,94 @@ int16_t RCcontextMapping_encode2_estimate_bandWise(
return bandBits;
}
+#else
+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;
+}
+#endif
diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c
index 62516fe35a8fedda859820bdd7e11da43c2deb6e..11d60b85474b1ce6b8f1858a3168b1d2a863c6e3 100644
--- a/lib_enc/ACcontextMapping_enc_fx.c
+++ b/lib_enc/ACcontextMapping_enc_fx.c
@@ -7,8 +7,7 @@
#include "options.h"
#include "basop_util.h"
#include "cnst.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "rom_com.h"
//#include "prot_fx.h"
#include "prot_fx_enc.h"
diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c
index 8338409fb17823162cdde692407fcc0a406a885a..d35f18b61a9dcf5be4bf1727d91abeb852530913 100644
--- a/lib_enc/FEC_enc_fx.c
+++ b/lib_enc/FEC_enc_fx.c
@@ -7,8 +7,7 @@
//#include "prot_fx.h" /* Function prototypes */
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
diff --git a/lib_enc/SNR_calc_fx.c b/lib_enc/SNR_calc_fx.c
index f39bc2b866ab546b5eda0a9cc6a4aa03e1a025be..674467cf4f6b249b5805f5a9865f11aeea324d88 100644
--- a/lib_enc/SNR_calc_fx.c
+++ b/lib_enc/SNR_calc_fx.c
@@ -6,8 +6,7 @@
#include "options.h"
#include "basop_util.h"
#include "vad_basop.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "rom_enc.h"
#include "rom_com.h"
diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c
index 771e0bc9efa26efa539b5bca9bd23cd891471d72..fc418f6526d36c0c7008364841f31cf8d93c4edb 100644
--- a/lib_enc/acelp_core_enc.c
+++ b/lib_enc/acelp_core_enc.c
@@ -43,7 +43,8 @@
#include "prot.h"
#include "ivas_cnst.h"
#include "ivas_prot.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
+#include "prot_fx_enc.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
@@ -52,7 +53,1487 @@
*
* ACELP core encoder
*--------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+ivas_error acelp_core_enc(
+ Encoder_State *st, /* i/o: encoder state structure */
+ const float inp[], /* i : input signal of the current frame */
+ const float ener, /* i : residual energy from Levinson-Durbin*/
+ float A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes*/
+ float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/
+ const float epsP[M + 1], /* i : LP prediction errors */
+ float lsp_new[M], /* i : LSPs at the end of the frame */
+ float lsp_mid[M], /* i : LSPs in the middle of the frame */
+ const int16_t vad_hover_flag, /* i : VAD hangover flag */
+ const int16_t attack_flag, /* i : attack flag (GSC or TC) */
+ float bwe_exc_extended[], /* i/o: bandwidth extended excitation */
+ float *voice_factors, /* o : voicing factors */
+ float old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
+ float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */
+ int16_t *unbits, /* o : number of unused bits */
+ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
+ float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
+)
+{
+ int16_t i, nBits; /* reserved bits */
+ LPD_state_HANDLE hLPDmem; /* i/o: acelp memories */
+ float old_exc_flt[L_EXC], *exc; /* excitation signal buffer */
+ float lsf_new[M]; /* ISFs at the end of the frame */
+ float Aq[NB_SUBFR16k * ( M + 1 )]; /* A(z) quantized for the 4 subframes */
+ float syn[L_FRAME16k]; /* synthesis signal buffer */
+ float res[L_FRAME16k]; /* Residual signal for FER protection */
+ float exc2[L_FRAME16k]; /* enhanced excitation */
+ float Es_pred; /* predicited scaled innovation energy */
+ float tmp_noise; /* NB post-filter long-term noise energy*/
+ int16_t tc_subfr; /* TC sub-frame indication */
+ float old_bwe_exc[( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2]; /* excitation buffer */
+ float *bwe_exc; /* excitation for SWB TBE */
+ int16_t allow_cn_step;
+ int32_t int_fs;
+ float att;
+ int16_t nb_bits; /* parameters handling */
+
+ /* SC-VBR - back-up memories for LSF quantizer and synthesis filter */
+ int16_t pstreaklen;
+ float mem_MA[M], mem_AR[M], Bin_E[L_FFT], Bin_E_old[L_FFT / 2], lsp_new_bck[M], lsp_mid_bck[M], mem_syn_bck[M];
+ float clip_var, mem_w0_bck, streaklimit;
+
+ float q_env[NUM_ENV_CNG];
+ int16_t sid_bw = -1;
+ float exc3[L_FRAME16k];
+ float syn1[L_FRAME16k];
+
+ float tilt_code_bck;
+ float gc_threshold_bck;
+ float clip_var_bck[6];
+ int16_t next_force_sf_bck;
+ int16_t uc_two_stage_flag;
+ int16_t position;
+ float tmpF;
+ int16_t ppp_mode, nelp_mode;
+ int16_t tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag;
+ float *tdm_Pri_pitch_buf;
+
+ /* bitstream */
+ BSTR_ENC_HANDLE hBstr = st->hBstr;
+#if 0
+ //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_fx[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 tc_subfr_fx; /* TC sub-frame indication */
+ Word16 old_bwe_exc_fx[(PIT16k_MAX + (L_FRAME16k + 1) + L_SUBFR16k) * 2]; /* excitation buffer */
+ Word16 *bwe_exc_fx; /* excitation for SWB TBE */
+ Word16 allow_cn_step_fx;
+ Word16 int_fs_fx;
+ Word32 L_epsP[2];
+ /* SC-VBR - back-up memories for LSF quantizer and synthesis filter */
+ Word16 mCb1_fx, pstreaklen_fx;
+ 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;
+ Word16 indice;
+ Word16 tmp16;
+ Word16 enr_index;
+ Word16 enr;
+
+ Word16 tilt_code_bck_fx;
+ Word32 gc_threshold_bck_fx;
+ Word16 clip_var_bck_fx[6];
+ Word16 next_force_sf_bck_fx;
+ Word32 q_env_fx[NUM_ENV_CNG];
+ Word16 coder_type;
+ Word16 exc3_fx[L_FRAME16k];
+ Word16 syn1_fx[L_FRAME16k];
+ Word16* tdm_Pri_pitch_buf_fx;
+ Word16 att_fx;
+
+ 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 old_syn_12k8_16k_fx[L_FRAME16k];
+#endif
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+
+ if ( st->element_mode == IVAS_CPE_MDCT && 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 = 0;
+
+ exc = old_exc_flt + L_EXC_MEM; /* pointer to excitation signal in the current frame */
+ mvr2r( hLPDmem->old_exc_flt, old_exc_flt, L_EXC_MEM );
+
+ if ( st->hBWE_TD != NULL )
+ {
+ bwe_exc = old_bwe_exc + PIT16k_MAX * 2; /* pointer to BWE excitation signal in the current frame */
+ mvr2r( st->hBWE_TD->old_bwe_exc, old_bwe_exc, PIT16k_MAX * 2 );
+ }
+ else
+ {
+ bwe_exc = NULL;
+ }
+
+ st->bpf_off = 0;
+ if ( st->last_core == HQ_CORE || st->last_codec_mode == MODE2 || st->last_core == TCX_20_CORE || st->last_core == TCX_10_CORE )
+ {
+ /* in case of HQ->ACELP switching, do not apply BPF */
+ st->bpf_off = 1;
+ /* reset the GSC pre echo energy threshold in case of switching */
+ if ( st->hGSCEnc != NULL )
+ {
+ st->hGSCEnc->Last_frame_ener = (float) MAX_32;
+ }
+ }
+
+ /* force safety-net LSFQ in the first frames after CNG segment */
+ if ( st->last_core_brate <= SID_2k40 )
+ {
+ st->Nb_ACELP_frames = 0;
+ }
+ st->Nb_ACELP_frames++;
+
+ if ( st->L_frame == L_FRAME )
+ {
+ int_fs = INT_FS_12k8;
+ }
+ else
+ {
+ int_fs = INT_FS_16k;
+ }
+
+ tmp_noise = 0;
+ tc_subfr = -1;
+ position = -1;
+
+ /* SC-VBR temporary variables */
+ pstreaklen = 0;
+ clip_var = 0;
+ mem_w0_bck = 0;
+ streaklimit = 0;
+
+ /* channel-aware mode */
+ reset_rf_indices( st->hRF, st->L_frame, &st->rf_target_bits_write );
+
+ /* 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;
+ }
+
+ /* TD stereo */
+ if ( st->element_mode == IVAS_CPE_TD && 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 = hStereoTD->tdm_Pri_pitch_buf;
+ }
+ else
+ {
+ tdm_lp_reuse_flag = 0;
+ tdm_low_rate_mode = 0;
+ if ( st->element_mode == IVAS_SCE && st->low_rate_mode )
+ {
+ tdm_low_rate_mode = 1;
+ }
+ tdm_Pitch_reuse_flag = 0;
+ tdm_Pri_pitch_buf = NULL;
+ }
+
+ /*-----------------------------------------------------------------*
+ * ACELP@12k8 / ACELP@16k switching
+ *-----------------------------------------------------------------*/
+
+ if ( st->last_L_frame != st->L_frame && ( st->last_core == ACELP_CORE || st->last_core == AMR_WB_CORE ) )
+ {
+ /* in case of switching, do not apply BPF (flag employed also in updt_enc()) */
+ st->bpf_off = 1;
+
+ /* force safety-net LSFQ in the first frames after ACELP@12k8/ACELP@16k switching */
+ st->Nb_ACELP_frames = 1;
+
+ /* convert old quantized LSP vector */
+ if ( st->L_frame == L_FRAME )
+ {
+ st->rate_switching_reset = lsp_convert_poly( st->lsp_old, st->L_frame, 0 );
+ }
+ else
+ {
+ st->rate_switching_reset = st->rate_switching_reset_16kHz;
+ mvr2r( st->lsp_old16k, st->lsp_old, M );
+ }
+
+ /* convert old quantized LSF vector */
+ lsp2lsf( st->lsp_old, st->lsf_old, M, int_fs );
+
+ /* interpolation of unquantized ISPs */
+ if ( st->rate_switching_reset )
+ {
+ /*extrapolation in case of unstable LSP*/
+ int_lsp4( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 );
+ }
+ else
+ {
+ int_lsp4( st->L_frame, st->lsp_old, lsp_mid, lsp_new, A, M, 0 );
+ }
+
+ /* Reset LPC mem */
+ mvr2r( GEWB_Ave, st->mem_AR, M );
+ set_zero( st->mem_MA, M );
+
+ /* update synthesis filter memories */
+ synth_mem_updt2_flt( st->L_frame, st->last_L_frame, hLPDmem->old_exc_flt, hLPDmem->mem_syn_r_flt, hLPDmem->mem_syn2_flt, hLPDmem->mem_syn_flt, ENC );
+ mvr2r( hLPDmem->old_exc_flt, old_exc_flt, L_EXC_MEM );
+ mvr2r( hLPDmem->mem_syn2_flt, hLPDmem->mem_syn1_flt, M );
+ mvr2r( hLPDmem->mem_syn2_flt, hLPDmem->mem_syn3_flt, M );
+
+ /* update Aw[] coefficients */
+ weight_a_subfr( st->L_frame / L_SUBFR, A, Aw, st->gamma_flt, M );
+ }
+
+ if ( st->last_bwidth == NB && st->bwidth != NB && st->ini_frame != 0 )
+ {
+ st->rate_switching_reset = 1;
+ }
+
+ /*----------------------------------------------------------------*
+ * Encoding of CNG frames
+ *----------------------------------------------------------------*/
+
+ if ( 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( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth );
+
+ /* encode CNG parameters */
+ CNG_enc( st, Aq, inp, ener, lsp_mid, lsp_new, lsf_new, &allow_cn_step, q_env, &sid_bw );
+
+ /* comfort noise generation */
+ CNG_exc( st->core_brate, st->L_frame, &st->hTdCngEnc->Enew, &st->hTdCngEnc->cng_seed, exc, exc2, &st->hTdCngEnc->lp_ener, st->last_core_brate, &st->hDtxEnc->first_CNG, &st->hTdCngEnc->cng_ener_seed, bwe_exc, allow_cn_step, &st->hTdCngEnc->last_allow_cn_step, st->hTdCngEnc->num_ho, q_env, st->hTdCngEnc->lp_env, st->hTdCngEnc->old_env, st->hTdCngEnc->exc_mem, st->hTdCngEnc->exc_mem1, &sid_bw, &st->hTdCngEnc->cng_ener_seed1, exc3, st->Opt_AMR_WB, EVS_MONO );
+ }
+ else
+ {
+ if ( st->core_brate == SID_2k40 && st->element_mode != IVAS_CPE_MDCT )
+ {
+ FdCng_encodeSID( st );
+ st->hDtxEnc->last_CNG_L_frame = st->L_frame;
+ }
+
+ generate_comfort_noise_enc( st );
+
+ FdCng_exc_flt( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old, st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG, Aq, lsp_new, lsf_new, exc, exc2, bwe_exc );
+ mvr2r( exc2, exc3, st->L_frame );
+
+ if ( st->core_brate == SID_2k40 )
+ {
+ if ( st->hTdCngEnc != NULL )
+ {
+ tmpF = cng_energy( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att, exc, st->L_frame );
+ i = (int16_t) ( ( tmpF + 2.0f ) * STEP_SID );
+ i = min( max( i, 0 ), 127 );
+ st->hTdCngEnc->old_enr_index = i;
+ }
+ }
+ }
+
+ /* Reset HO counter in the first SID frame */
+ if ( st->hTdCngEnc != NULL )
+ {
+ st->hTdCngEnc->burst_ho_cnt = 0;
+ }
+
+ /* synthesis at 12.8kHz sampling rate */
+ syn_12k8( st->L_frame, Aq, exc3, syn1, hLPDmem->mem_syn3_flt, 1 );
+
+ /* reset the encoder */
+ CNG_reset_enc( st, pitch_buf, voice_factors, 0 );
+
+ /* update st->mem_syn1_flt for ACELP core switching */
+ mvr2r( hLPDmem->mem_syn3_flt, hLPDmem->mem_syn1_flt, M );
+
+ /* update ACELP core synthesis filter memory */
+ mvr2r( hLPDmem->mem_syn3_flt, hLPDmem->mem_syn_flt, M );
+
+ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
+ mvr2r( syn1 + st->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r_flt, L_SYN_MEM );
+
+ /* save and delay synthesis to be used by SWB BWE */
+ if ( st->hBWE_FD != NULL )
+ {
+ save_old_syn( st->L_frame, syn1, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k, st->preemph_fac_flt, &st->hBWE_FD->mem_deemph_old_syn );
+ }
+
+ /*Update MODE2 core switching memory*/
+ deemph( syn1, st->preemph_fac_flt, st->L_frame, &( hLPDmem->syn_flt[M] ) );
+ mvr2r( syn1 + st->L_frame - M - 1, hLPDmem->syn_flt, M + 1 );
+ }
+
+ /*----------------------------------------------------------------*
+ * Encoding of all other frames
+ *----------------------------------------------------------------*/
+#if 0
+ ELSE
+ {
+#if 1
+ /*-----------------------------------------------------------------*
+ * Configure ACELP bit allocation
+ *-----------------------------------------------------------------*/
+
+ nb_bits = 0;
+ st->acelp_cfg.FEC_mode = 0;
+ uc_two_stage_flag = 0;
+
+ 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
+ *-----------------------------------------------------------------*/
+
+#ifdef NON_BE_FIX_807_MASA_DTX_BRSW
+ if (st->hDtxEnc != NULL && (st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40))
+#else
+ if ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 )
+#endif
+ {
+ mvr2r( st->hDtxEnc->lspCNG, st->lsp_old, M );
+ lsp2lsf( st->hDtxEnc->lspCNG, st->lsf_old, M, int_fs );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Reset higher ACELP pre-quantizer in case of switching
+ *-----------------------------------------------------------------*/
+
+ if ( !st->use_acelp_preq )
+ {
+ st->mem_deemp_preQ = 0.0f;
+ st->mem_preemp_preQ = 0.0f;
+ st->last_code_preq = 0;
+ st->last_nq_preQ = 0;
+ }
+ st->use_acelp_preq = 0;
+
+ /*-----------------------------------------------------------------*
+ * LSF Quantization
+ * A[z] calculation
+ *-----------------------------------------------------------------*/
+
+ /* SC-VBR & channel-aware mode - back-up memories for LSF quantizer and synthesis filter */
+ lsf_syn_mem_backup( st, &tilt_code_bck, &gc_threshold_bck, clip_var_bck, &next_force_sf_bck, lsp_new, lsp_mid, &clip_var, mem_AR, mem_MA, lsp_new_bck, lsp_mid_bck, Bin_E, Bin_E_old, mem_syn_bck, &mem_w0_bck, &streaklimit, &pstreaklen );
+ Word16 tdm_lsfQ_PCh_fx[M];
+ Word16 Q_new = 0;
+ IF ( !tdm_lp_reuse_flag )
+ {
+#if 1
+ floatToFixed_arr(lsp_new, lsp_new_fx, 15, M);
+ FOR(Word16 idx = 0; idx < M; idx++)
+ {
+ st->lsf_old_fx[idx] = st->lsf_old[idx] * 2.56;
+ lsf_new_fx[idx] = lsf_new_fx[idx] * 2.56;
+ st->lsf_adaptive_mean_fx[idx] = st->lsf_adaptive_mean[idx] * 2.56;
+ st->mem_MA_fx[idx] = st->mem_MA[idx] * 2.56;
+ st->mem_AR_fx[idx] = st->mem_AR[idx] * 2.56;
+ tdm_lsfQ_PCh_fx[idx] = tdm_lsfQ_PCh[idx] * 2.56;
+ st->lsfoldbfi1_fx[idx] = st->lsfoldbfi1[idx] * 2.56;
+ st->lsfoldbfi0_fx[idx] = st->lsfoldbfi0[idx] * 2.56;
+ }
+
+ FOR(Word16 idx = 0; idx < 6; idx++)
+ {
+ st->clip_var_fx[idx] = st->clip_var[idx] * 2.56;
+ }
+
+ Q_new = Q_factor_arr(st->Bin_E, 256);
+
+ floatToFixed_arrL(st->Bin_E_old, st->Bin_E_old_fx, 0, L_FFT );
+ floatToFixed_arrL(st->Bin_E, st->Bin_E_fx, Q_new, L_FFT);
+ floatToFixed_arr(st->lsp_old, st->lsp_old_fx, 15, M);
+ floatToFixed_arr(lsp_mid, lsp_mid_fx, 15, M);
+
+ st->stab_fac_fx = st->stab_fac * (1 << 15);
+ st->streaklimit_fx = st->streaklimit * (1 << 15);
+ st->pstreaklen_fx = st->pstreaklen;
+
+ lsf_enc_ivas_fx(st, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh_fx, Q_new);
+
+ Scale_sig(Aq_fx, NB_SUBFR16k * (M + 1), 14 - norm_l(Aq_fx[0]));
+ fixedToFloat_arr(Aq_fx, Aq, 12, NB_SUBFR16k * (M + 1));
+ fixedToFloat_arr(lsp_new_fx, lsp_new, 15, M);
+ fixedToFloat_arr(lsp_mid_fx, lsp_mid, 15, M);
+ st->stab_fac = (float)st->stab_fac_fx / (1 << 15);
+ for (int i = 0; i < M; i++) {
+
+ lsf_new[i] = lsf_new_fx[i] / 2.56;
+ st->lsf_old[i] = st->lsf_old_fx[i] / 2.56;
+ st->lsf_adaptive_mean[i] = st->lsf_adaptive_mean_fx[i] / 2.56;
+ st->mem_MA[i] = st->mem_MA_fx[i] / 2.56;
+ st->mem_AR[i] = st->mem_AR_fx[i] / 2.56;
+ st->lsfoldbfi1[i] = st->lsfoldbfi1_fx[i] / 2.56;
+ st->lsfoldbfi0[i] = st->lsfoldbfi0_fx[i] / 2.56;
+ }
+ st->streaklimit = (float)st->streaklimit_fx / (1 << 15);
+ st->pstreaklen = st->pstreaklen_fx;
+#else
+ lsf_enc( st, lsf_new, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh );
+#endif
+ }
+ ELSE
+ {
+ const float *pt_interp_2;
+
+ IF ( NE_16(st->active_cnt, 1 ))
+ {
+#if 0
+ Word16 beta_index;
+ Word16 lsf_wgts[M];
+
+ /* intra_frame prediction for the LSFs */
+ lsp2lsf_fx(lsp_new_fx, lsf_new_fx, M, 12800);
+
+ Unified_weighting_fx(&st->Bin_E_fx[L_FFT / 2], Q_new, lsf_new_fx, lsf_wgts, st->bwidth == NB, st->coder_type == UNVOICED, st->sr_core, M);
+
+ tdm_SCh_lsf_reuse_fx(ENC, st->element_brate, lsf_new_fx, lsp_new_fx, tdm_lsfQ_PCh_fx, lsf_wgts, &beta_index);
+#else
+ int16_t beta_index;
+ float lsf_wgts[M];
+
+ /* intra_frame prediction for the LSFs */
+ lsp2lsf( lsp_new, lsf_new, M, 12800 );
+
+ Unified_weighting( &st->Bin_E[L_FFT / 2], lsf_new, lsf_wgts, st->bwidth == NB, st->coder_type == UNVOICED, st->sr_core, M );
+
+ tdm_SCh_lsf_reuse( ENC, st->element_brate, lsf_new, lsp_new, tdm_lsfQ_PCh, lsf_wgts, &beta_index );
+#endif
+ push_indice( hBstr, IND_IC_LSF_PRED, beta_index, TDM_IC_LSF_PRED_BITS );
+ }
+
+ pt_interp_2 = interpol_frac_12k8;
+ if ( tdm_low_rate_mode == 1 && st->coder_type > UNVOICED )
+ {
+ pt_interp_2 = interpol_frac2;
+ }
+
+ if ( st->active_cnt == 1 )
+ {
+ mvr2r( lsp_new, st->lsp_old, M );
+ lsp2lsf( lsp_new, st->lsf_old, M, st->sr_core );
+ lsp2lsf( lsp_new, lsf_new, M, st->sr_core );
+ }
+
+ /* LSP interpolation and conversion of LSPs to A(z) */
+ int_lsp( st->L_frame, st->lsp_old, lsp_new, Aq, M, pt_interp_2, 0 );
+
+ /* Check LSF stability (distance between old LSFs and current LSFs) */
+ st->stab_fac = lsf_stab( lsf_new, st->lsf_old, 0, st->L_frame );
+ }
+
+ if ( st->last_core == HQ_CORE && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory from last HQ frame */
+ tmpF = hLPDmem->old_exc_flt[0];
+ preemph( hLPDmem->old_exc_flt, st->preemph_fac_flt, st->L_frame, &tmpF );
+ mvr2r( hLPDmem->old_exc_flt + st->L_frame - M, hLPDmem->mem_syn_flt, M );
+ residu( Aq, M, hLPDmem->old_exc_flt, old_exc_flt, st->L_frame );
+ }
+
+ if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory of old_bwe_exc */
+ if ( st->L_frame == L_FRAME )
+ {
+ lerp_flt( old_exc_flt, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
+ }
+ else
+ {
+ lerp_flt( old_exc_flt, old_bwe_exc, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC );
+ }
+ }
+
+
+ /*---------------------------------------------------------------*
+ * Calculation of LP residual (filtering through A[z] filter)
+ *---------------------------------------------------------------*/
+
+ calc_residu( inp, res, Aq, st->L_frame );
+
+ calculate_hangover_attenuation_gain( st, &att, vad_hover_flag );
+ if ( att != 1.0f )
+ {
+ v_multc( res, att, res, st->L_frame );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Determine TC subframe classification
+ *-----------------------------------------------------------------*/
+
+ if ( st->coder_type == TRANSITION )
+ {
+ tc_classif_enc( st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res );
+
+ 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( &Es_pred, &i, st->L_frame, L_SUBFR, res, st->voicing, nb_bits, uc_two_stage_flag );
+ push_indice( hBstr, IND_ES_PRED, i, nb_bits );
+ }
+
+ /*------------------------------------------------------------*
+ * Encode excitation according to coding type
+ *------------------------------------------------------------*/
+
+ if ( tdm_low_rate_mode ) /* tdm stereo low rate mode */
+ {
+ if ( st->coder_type <= UNVOICED )
+ {
+ tdm_low_rate_enc( st, Aq, res, syn, exc, pitch_buf, voice_factors, bwe_exc, 0 /*attack_flag*/, lsf_new, &tmp_noise );
+ }
+ else /* GENERIC */
+ {
+ encod_gen_2sbfr( st, inp, Aw, Aq, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ }
+ }
+ else if ( nelp_mode )
+ {
+ /* SC-VBR - NELP frames */
+ encod_nelp( st, inp, Aw, Aq, res, syn, &tmp_noise, exc, exc2, pitch_buf, voice_factors, bwe_exc );
+ }
+ else if ( st->coder_type == UNVOICED )
+ {
+ /* UNVOICED frames (Gauss. excitation) */
+ encod_unvoiced( st, inp, Aw, Aq, Es_pred, uc_two_stage_flag, res, syn, &tmp_noise, exc, pitch_buf, voice_factors, bwe_exc );
+ }
+ else if ( st->coder_type == TRANSITION )
+ {
+ encod_tran( st, inp, Aw, Aq, Es_pred, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, tc_subfr, position, unbits );
+ }
+ else if ( ppp_mode )
+ {
+ /* SC-VBR - PPP frames */
+ if ( ( error = encod_ppp( st, inp, Aw, Aq, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc ) ) != 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( st, tilt_code_bck, gc_threshold_bck, clip_var_bck, next_force_sf_bck, lsp_new, lsp_mid, clip_var, mem_AR, mem_MA, lsp_new_bck, lsp_mid_bck, Bin_E, Bin_E_old, mem_syn_bck, mem_w0_bck, streaklimit, 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( st, lsf_new, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL );
+
+ /* recalculation of LP residual (filtering through A[z] filter) */
+ calc_residu( inp, res, Aq, st->L_frame );
+ st->hTdCngEnc->burst_ho_cnt = 0;
+
+ /* VOICED frames in SC-VBR */
+ encod_gen_voic( st, inp, Aw, Aq, Es_pred, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ }
+ }
+ else if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) )
+ {
+ /* AUDIO and INACTIVE frames (coded by GSC technology) */
+ encod_audio( st, inp, Aw, Aq, res, syn, exc, pitch_buf, voice_factors, bwe_exc, attack_flag, lsf_new, &tmp_noise, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ }
+ else
+ {
+ /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
+ encod_gen_voic( st, inp, Aw, Aq, Es_pred, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ }
+
+
+ /* update mem_syn1_flt for ACELP core switching */
+ mvr2r( hLPDmem->mem_syn_flt, hLPDmem->mem_syn1_flt, M );
+
+ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
+ mvr2r( syn + st->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r_flt, L_SYN_MEM );
+
+ /* save and delay synthesis to be used by SWB BWE */
+ if ( st->hBWE_FD != NULL )
+ {
+ save_old_syn( st->L_frame, syn, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k, st->preemph_fac_flt, &st->hBWE_FD->mem_deemph_old_syn );
+ }
+
+ /*Update MODE2 core switching memory*/
+ mvr2r( syn, syn1, st->L_frame );
+ deemph( syn1, st->preemph_fac_flt, st->L_frame, &( hLPDmem->syn_flt[M] ) );
+ mvr2r( syn1 + st->L_frame - M - 1, hLPDmem->syn_flt, M + 1 );
+
+ if ( st->element_mode > EVS_MONO && st->hTcxEnc != NULL )
+ {
+ mvr2r( syn1 + st->L_frame / 2, st->hTcxEnc->Txnq_flt, st->L_frame / 2 );
+ }
+
+ /*--------------------------------------------------------------------------------------*
+ * Modify the excitation signal when the noise is stationary
+ *--------------------------------------------------------------------------------------*/
+
+ if ( !( st->idchan == 1 && st->element_mode == IVAS_CPE_TD ) && nelp_mode != 1 && !( st->element_mode == IVAS_SCE && tdm_low_rate_mode ) )
+ {
+ /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */
+ mvr2r( exc, exc2, st->L_frame );
+ stat_noise_uv_enc( st, epsP, lsp_new, lsp_mid, Aq, exc2, uc_two_stage_flag );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Encode supplementary information for Frame Error Concealment
+ *-----------------------------------------------------------------*/
+
+ FEC_encode( hBstr, st->acelp_cfg, syn, st->coder_type, st->clas, pitch_buf, res, &st->Last_pulse_pos, st->L_frame, st->total_brate );
+
+ if ( st->hBWE_TD != NULL )
+ {
+ if ( st->L_frame == L_FRAME )
+ {
+ mvr2r( Aq + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq, ( M + 1 ) );
+ }
+ else
+ {
+ mvr2r( Aq + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq, ( M + 1 ) );
+ }
+ }
+#else
+ /*-----------------------------------------------------------------*
+ * Configure ACELP bit allocation
+ *-----------------------------------------------------------------*/
+
+ nb_bits = 0;
+ st->acelp_cfg.FEC_mode = 0;
+ uc_two_stage_flag = 0;
+#if 0 // Both are in fixed point, but 1st one giveing crash for one file.
+ IF ( !nelp_mode && !ppp_mode )
+ {
+ config_acelp1( 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 );
+ }
+#else
+ 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);
+ }
+#endif
+ /*-----------------------------------------------------------------*
+ * After inactive period, use the most up-to-date ISPs
+ *-----------------------------------------------------------------*/
+#if 0
+ floatToFixed_arr(st->lsp_old, st->lsp_old_fx, 15, M);
+
+#ifdef NON_BE_FIX_807_MASA_DTX_BRSW
+ IF (st->hDtxEnc != NULL && (st->last_core_brate == FRAME_NO_DATA || EQ_32(st->last_core_brate, SID_2k40)))
+#else
+ IF(EQ_32(st->last_core_brate, FRAME_NO_DATA) || EQ_32(st->last_core_brate, SID_2k40))
+#endif
+ {
+ Copy(st->hDtxEnc->lspCNG_fx, st->lsp_old_fx, M);
+ lsp2lsf_fx(st->hDtxEnc->lspCNG_fx, st->lsf_old_fx, M, int_fs);
+ }
+ for (int i = 0; i < M; i++) {
+ st->lsf_old[i] = st->lsf_old_fx[i] / 2.56;
+ }
+#else
+#ifdef NON_BE_FIX_807_MASA_DTX_BRSW
+ if (st->hDtxEnc != NULL && (st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40))
+#else
+ if ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 )
+#endif
+ {
+ mvr2r( st->hDtxEnc->lspCNG, st->lsp_old, M );
+ lsp2lsf( st->hDtxEnc->lspCNG, st->lsf_old, M, int_fs );
+ }
+#endif
+ /*-----------------------------------------------------------------*
+ * Reset higher ACELP pre-quantizer in case of switching
+ *-----------------------------------------------------------------*/
+#if 1
+ IF (!st->use_acelp_preq)
+ {
+ st->mem_deemp_preQ_fx = 0;
+ st->mem_preemp_preQ_fx = 0;
+ st->last_code_preq = 0;
+ st->last_nq_preQ = 0;
+ }
+ st->use_acelp_preq = 0;
+
+ if (!st->use_acelp_preq)
+ {
+ st->mem_deemp_preQ = 0.0f;
+ st->mem_preemp_preQ = 0.0f;
+ st->last_code_preq = 0;
+ st->last_nq_preQ = 0;
+ }
+#else
+ if ( !st->use_acelp_preq )
+ {
+ st->mem_deemp_preQ = 0.0f;
+ st->mem_preemp_preQ = 0.0f;
+ st->last_code_preq = 0;
+ st->last_nq_preQ = 0;
+ }
+ st->use_acelp_preq = 0;
+#endif
+ /*-----------------------------------------------------------------*
+ * LSF Quantization
+ * A[z] calculation
+ *-----------------------------------------------------------------*/
+
+ /* SC-VBR & channel-aware mode - back-up memories for LSF quantizer and synthesis filter */
+#if 0
+ floatToFixed_arr(lsp_new, lsp_new_fx, 15, M);
+ floatToFixed_arr(lsp_mid, lsp_mid_fx, 15, M);
+ floatToFixed_arr(st->Bin_E_old, st->Bin_E_old_fx, 15, L_FFT / 2);
+ floatToFixed_arr(st->clip_var, st->clip_var_fx, 8, 6);
+ FOR(Word16 idx = 0; idx < M; idx++)
+ {
+
+ st->lsf_old_fx[idx] = st->lsf_old[idx] * 2.56;
+ st->lsf_adaptive_mean_fx[idx] = st->lsf_adaptive_mean[idx] * 2.56;
+ st->mem_MA_fx[idx] = st->mem_MA[idx] * 2.56;
+ st->mem_AR_fx[idx] = st->mem_AR[idx] * 2.56;
+ }
+ hLPDmem->tilt_code = hLPDmem->tilt_code_flt;
+ hLPDmem->gc_threshold = hLPDmem->gc_threshold_flt;
+ st->next_force_safety_net_fx = st->next_force_safety_net;
+
+ lsf_syn_mem_backup_fx(st, &tilt_code_bck_fx, &gc_threshold_bck_fx, clip_var_bck_fx, &next_force_sf_bck, lsp_new_fx, lsf_new_fx, lsp_mid_fx, &clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsf_new_bck_fx, lsp_mid_bck_fx, &mCb1_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, &mem_w0_bck_fx, &streaklimit_fx, &pstreaklen_fx);
+
+ fixedToFloat_arr(clip_var_bck_fx, clip_var_bck, 8, 6);
+ fixedToFloat_arr(lsp_new_bck_fx, lsp_new_bck, 15, M);
+ fixedToFloat_arr(lsp_mid_bck_fx, lsp_mid_bck, 15, M);
+ fixedToFloat_arr(lsp_mid_bck_fx, lsp_mid_bck, 15, M);
+ fixedToFloat_arr(Bin_E_fx, Bin_E, 15, L_FFT);
+ fixedToFloat_arr(Bin_E_old_fx, Bin_E_old, 15, L_FFT / 2);
+ fixedToFloat_arr(mem_syn_bck_fx, mem_syn_bck, 15, M);
+
+ for (int i = 0; i < M; i++) {
+
+ lsf_new[i] = lsf_new_fx[i] / 2.56;
+ st->lsf_old[i] = st->lsf_old_fx[i] / 2.56;
+ st->lsf_adaptive_mean[i] = st->lsf_adaptive_mean_fx[i] / 2.56;
+ st->mem_MA[i] = st->mem_MA_fx[i] / 2.56;
+ st->mem_AR[i] = st->mem_AR_fx[i] / 2.56;
+ mem_MA[i] = mem_MA_fx[i] / 2.56;
+ mem_AR[i] = mem_AR_fx[i] / 2.56;
+ }
+
+ clip_var = (float)clip_var_fx / (1 << 8);
+ mem_w0_bck = mem_w0_bck_fx;
+ streaklimit = streaklimit_fx;
+ mem_w0_bck = mem_w0_bck_fx;
+#else
+ lsf_syn_mem_backup( st, &tilt_code_bck, &gc_threshold_bck, clip_var_bck, &next_force_sf_bck, lsp_new, lsp_mid, &clip_var, mem_AR, mem_MA, lsp_new_bck, lsp_mid_bck, Bin_E, Bin_E_old, mem_syn_bck, &mem_w0_bck, &streaklimit, &pstreaklen );
+#endif
+ if ( !tdm_lp_reuse_flag )
+ {
+#if 1
+ Word16 Q_new = 0;
+ Word16 tdm_lsfQ_PCh_fx[M];
+
+ floatToFixed_arr(lsp_new, lsp_new_fx, 15, M);
+ FOR(Word16 idx = 0; idx < M; idx++)
+ {
+ st->lsf_old_fx[idx] = st->lsf_old[idx] * 2.56;
+ lsf_new_fx[idx] = lsf_new_fx[idx] * 2.56;
+ st->lsf_adaptive_mean_fx[idx] = st->lsf_adaptive_mean[idx] * 2.56;
+ st->mem_MA_fx[idx] = st->mem_MA[idx] * 2.56;
+ st->mem_AR_fx[idx] = st->mem_AR[idx] * 2.56;
+ tdm_lsfQ_PCh_fx[idx] = tdm_lsfQ_PCh[idx] * 2.56;
+ }
+
+ FOR(Word16 idx = 0; idx < 6; idx++)
+ {
+ st->clip_var_fx[idx] = st->clip_var[idx] * 2.56;
+ }
+
+ floatToFixed_arrL(st->Bin_E_old, st->Bin_E_old_fx, 0, L_FFT / 2);
+ floatToFixed_arrL(st->Bin_E, st->Bin_E_fx, 0, L_FFT / 2);
+ floatToFixed_arr(st->lsp_old, st->lsp_old_fx, 15, M);
+ floatToFixed_arr(lsp_mid, lsp_mid_fx, 15, M);
+
+ st->stab_fac_fx = st->stab_fac * (1 << 15);
+
+ lsf_enc_ivas_fx(st, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh_fx, Q_new);
+
+ Scale_sig(Aq_fx, NB_SUBFR16k * (M + 1), 14 - norm_l(Aq_fx[0]));
+ fixedToFloat_arr(Aq_fx, Aq, 12, NB_SUBFR16k * (M + 1));
+ fixedToFloat_arr(lsp_new_fx, lsp_new, 15, M);
+ fixedToFloat_arr(lsp_mid_fx, lsp_mid, 15, M);
+ st->stab_fac = (float)st->stab_fac_fx / (1 << 15);
+ for (int i = 0; i < M; i++) {
+
+ lsf_new[i] = lsf_new_fx[i] / 2.56;
+ st->lsf_old[i] = st->lsf_old_fx[i] / 2.56;
+ st->lsf_adaptive_mean[i] = st->lsf_adaptive_mean_fx[i] / 2.56;
+ st->mem_MA[i] = st->mem_MA_fx[i] / 2.56;
+ st->mem_AR[i] = st->mem_AR_fx[i] / 2.56;
+ }
+#else
+ lsf_enc( st, lsf_new, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh );
+#endif
+ }
+ else
+ {
+ const float *pt_interp_2;
+
+ if ( st->active_cnt != 1 )
+ {
+ int16_t beta_index;
+ float lsf_wgts[M];
+
+ /* intra_frame prediction for the LSFs */
+ lsp2lsf( lsp_new, lsf_new, M, 12800 );
+
+ Unified_weighting( &st->Bin_E[L_FFT / 2], lsf_new, lsf_wgts, st->bwidth == NB, st->coder_type == UNVOICED, st->sr_core, M );
+
+ tdm_SCh_lsf_reuse( ENC, st->element_brate, lsf_new, lsp_new, tdm_lsfQ_PCh, lsf_wgts, &beta_index );
+
+ push_indice( hBstr, IND_IC_LSF_PRED, beta_index, TDM_IC_LSF_PRED_BITS );
+ }
+
+ pt_interp_2 = interpol_frac_12k8;
+ if ( tdm_low_rate_mode == 1 && st->coder_type > UNVOICED )
+ {
+ pt_interp_2 = interpol_frac2;
+ }
+
+ if ( st->active_cnt == 1 )
+ {
+ mvr2r( lsp_new, st->lsp_old, M );
+ lsp2lsf( lsp_new, st->lsf_old, M, st->sr_core );
+ lsp2lsf( lsp_new, lsf_new, M, st->sr_core );
+ }
+
+ /* LSP interpolation and conversion of LSPs to A(z) */
+ int_lsp( st->L_frame, st->lsp_old, lsp_new, Aq, M, pt_interp_2, 0 );
+
+ /* Check LSF stability (distance between old LSFs and current LSFs) */
+ st->stab_fac = lsf_stab( lsf_new, st->lsf_old, 0, st->L_frame );
+ }
+
+ if ( st->last_core == HQ_CORE && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory from last HQ frame */
+ tmpF = hLPDmem->old_exc_flt[0];
+ preemph( hLPDmem->old_exc_flt, st->preemph_fac_flt, st->L_frame, &tmpF );
+ mvr2r( hLPDmem->old_exc_flt + st->L_frame - M, hLPDmem->mem_syn_flt, M );
+ residu( Aq, M, hLPDmem->old_exc_flt, old_exc_flt, st->L_frame );
+ }
+
+ if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory of old_bwe_exc */
+ if ( st->L_frame == L_FRAME )
+ {
+ lerp_flt( old_exc_flt, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
+ }
+ else
+ {
+ lerp_flt( old_exc_flt, old_bwe_exc, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC );
+ }
+ }
+
+
+ /*---------------------------------------------------------------*
+ * Calculation of LP residual (filtering through A[z] filter)
+ *---------------------------------------------------------------*/
+#if 0
+ floatToFixed_arr(Aq, Aq_fx, 12, NB_SUBFR16k*(M + 1));
+ calc_residu_fx(st, inp_fx, res_fx, Aq_fx);
+#else
+ calc_residu( inp, res, Aq, st->L_frame );
+#endif
+ calculate_hangover_attenuation_gain( st, &att, vad_hover_flag );
+ if ( att != 1.0f )
+ {
+ v_multc( res, att, res, st->L_frame );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Determine TC subframe classification
+ *-----------------------------------------------------------------*/
+
+ if ( st->coder_type == TRANSITION )
+ {
+ tc_classif_enc( st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res );
+
+ 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 0
+ Es_pred_fx = Es_pred * (1 << 8);
+ 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, 0);
+ push_indice(hBstr, IND_ES_PRED, i, nb_bits);
+ }
+
+ Es_pred = (float)Es_pred_fx / (1 << 8);
+#else
+ if ( nb_bits > 0 )
+ {
+ Es_pred_enc( &Es_pred, &i, st->L_frame, L_SUBFR, res, st->voicing, nb_bits, uc_two_stage_flag );
+ push_indice( hBstr, IND_ES_PRED, i, nb_bits );
+ }
+#endif
+ /*------------------------------------------------------------*
+ * Encode excitation according to coding type
+ *------------------------------------------------------------*/
+
+ if ( tdm_low_rate_mode ) /* tdm stereo low rate mode */
+ {
+ if ( st->coder_type <= UNVOICED )
+ {
+ tdm_low_rate_enc( st, Aq, res, syn, exc, pitch_buf, voice_factors, bwe_exc, 0 /*attack_flag*/, lsf_new, &tmp_noise );
+ }
+ else /* GENERIC */
+ {
+ encod_gen_2sbfr( st, inp, Aw, Aq, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ }
+ }
+ else if ( nelp_mode )
+ {
+ /* SC-VBR - NELP frames */
+ encod_nelp( st, inp, Aw, Aq, res, syn, &tmp_noise, exc, exc2, pitch_buf, voice_factors, bwe_exc );
+ }
+ else if ( st->coder_type == UNVOICED )
+ {
+ /* UNVOICED frames (Gauss. excitation) */
+ encod_unvoiced( st, inp, Aw, Aq, Es_pred, uc_two_stage_flag, res, syn, &tmp_noise, exc, pitch_buf, voice_factors, bwe_exc );
+ }
+ else if ( st->coder_type == TRANSITION )
+ {
+ encod_tran( st, inp, Aw, Aq, Es_pred, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, tc_subfr, position, unbits );
+ }
+ else if ( ppp_mode )
+ {
+ /* SC-VBR - PPP frames */
+ if ( ( error = encod_ppp( st, inp, Aw, Aq, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc ) ) != 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( st, tilt_code_bck, gc_threshold_bck, clip_var_bck, next_force_sf_bck, lsp_new, lsp_mid, clip_var, mem_AR, mem_MA, lsp_new_bck, lsp_mid_bck, Bin_E, Bin_E_old, mem_syn_bck, mem_w0_bck, streaklimit, 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( st, lsf_new, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL );
+
+ /* recalculation of LP residual (filtering through A[z] filter) */
+ calc_residu( inp, res, Aq, st->L_frame );
+ st->hTdCngEnc->burst_ho_cnt = 0;
+
+ /* VOICED frames in SC-VBR */
+ encod_gen_voic( st, inp, Aw, Aq, Es_pred, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ }
+ }
+ else if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) )
+ {
+ /* AUDIO and INACTIVE frames (coded by GSC technology) */
+ encod_audio( st, inp, Aw, Aq, res, syn, exc, pitch_buf, voice_factors, bwe_exc, attack_flag, lsf_new, &tmp_noise, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ }
+ else
+ {
+ /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
+ encod_gen_voic( st, inp, Aw, Aq, Es_pred, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ }
+
+ /* update mem_syn1_flt for ACELP core switching */
+ mvr2r( hLPDmem->mem_syn_flt, hLPDmem->mem_syn1_flt, M );
+
+ Copy(hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M);
+
+ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
+ mvr2r( syn + st->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r_flt, L_SYN_MEM );
+
+ Copy(syn_fx + st->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r, L_SYN_MEM);
+ /* save and delay synthesis to be used by SWB BWE */
+#if 1
+ floatToFixed_arr(hLPDmem->mem_syn_r, hLPDmem->mem_syn_r_flt, 0, L_SYN_MEM);
+ floatToFixed_arr(hLPDmem->mem_syn1_fx, hLPDmem->mem_syn1_flt, 0, M);
+#endif
+#if 0
+ floatToFixed_arr(st->hBWE_FD->old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k_fx, 0, 36);
+ floatToFixed_arr(syn, syn_fx, -1, L_FRAME16k);
+ st->hBWE_FD->mem_deemph_old_syn_fx = st->hBWE_FD->mem_deemph_old_syn;
+ st->preemph_fac = st->preemph_fac_flt * (1 << 15);
+
+ save_old_syn_fx(st->L_frame, syn_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx);
+
+ fixedToFloat_arr(old_syn_12k8_16k_fx, old_syn_12k8_16k, -1, 320);
+ fixedToFloat_arr(st->hBWE_FD->old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k, 0, 36);
+ st->hBWE_FD->mem_deemph_old_syn = st->hBWE_FD->mem_deemph_old_syn_fx;
+#else
+ if ( st->hBWE_FD != NULL )
+ {
+ save_old_syn( st->L_frame, syn, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k, st->preemph_fac_flt, &st->hBWE_FD->mem_deemph_old_syn );
+ }
+#endif
+ /*Update MODE2 core switching memory*/
+ mvr2r( syn, syn1, st->L_frame );
+#if 0
+ deemph(syn1, st->preemph_fac_flt, st->L_frame, &(hLPDmem->syn_flt[M]));
+#else
+ deemph( syn1, st->preemph_fac_flt, st->L_frame, &( hLPDmem->syn_flt[M] ) );
+#endif
+ mvr2r( syn1 + st->L_frame - M - 1, hLPDmem->syn_flt, M + 1 );
+
+ if ( st->element_mode > EVS_MONO && st->hTcxEnc != NULL )
+ {
+ mvr2r( syn1 + st->L_frame / 2, st->hTcxEnc->Txnq_flt, st->L_frame / 2 );
+ }
+
+ /*--------------------------------------------------------------------------------------*
+ * Modify the excitation signal when the noise is stationary
+ *--------------------------------------------------------------------------------------*/
+
+ if ( !( st->idchan == 1 && st->element_mode == IVAS_CPE_TD ) && nelp_mode != 1 && !( st->element_mode == IVAS_SCE && tdm_low_rate_mode ) )
+ {
+ /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */
+ mvr2r( exc, exc2, st->L_frame );
+ stat_noise_uv_enc( st, epsP, lsp_new, lsp_mid, Aq, exc2, uc_two_stage_flag );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Encode supplementary information for Frame Error Concealment
+ *-----------------------------------------------------------------*/
+
+ FEC_encode( hBstr, st->acelp_cfg, syn, st->coder_type, st->clas, pitch_buf, res, &st->Last_pulse_pos, st->L_frame, st->total_brate );
+
+ if ( st->hBWE_TD != NULL )
+ {
+ if ( st->L_frame == L_FRAME )
+ {
+ mvr2r( Aq + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq, ( M + 1 ) );
+ }
+ else
+ {
+ mvr2r( Aq + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq, ( M + 1 ) );
+ }
+ }
+
+#endif
+ } /* end of active inp coding */
+#else
+ else
+ {
+ /*-----------------------------------------------------------------*
+ * Configure ACELP bit allocation
+ *-----------------------------------------------------------------*/
+
+ nb_bits = 0;
+ st->acelp_cfg.FEC_mode = 0;
+ uc_two_stage_flag = 0;
+
+ 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
+ *-----------------------------------------------------------------*/
+
+#ifdef NON_BE_FIX_807_MASA_DTX_BRSW
+ if ( st->hDtxEnc != NULL && ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) )
+#else
+ if ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 )
+#endif
+ {
+ mvr2r( st->hDtxEnc->lspCNG, st->lsp_old, M );
+ lsp2lsf( st->hDtxEnc->lspCNG, st->lsf_old, M, int_fs );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Reset higher ACELP pre-quantizer in case of switching
+ *-----------------------------------------------------------------*/
+
+ if ( !st->use_acelp_preq )
+ {
+ st->mem_deemp_preQ = 0.0f;
+ st->mem_preemp_preQ = 0.0f;
+ st->last_code_preq = 0;
+ st->last_nq_preQ = 0;
+ }
+ st->use_acelp_preq = 0;
+
+ /*-----------------------------------------------------------------*
+ * LSF Quantization
+ * A[z] calculation
+ *-----------------------------------------------------------------*/
+
+ /* SC-VBR & channel-aware mode - back-up memories for LSF quantizer and synthesis filter */
+ lsf_syn_mem_backup( st, &tilt_code_bck, &gc_threshold_bck, clip_var_bck, &next_force_sf_bck, lsp_new, lsp_mid, &clip_var, mem_AR, mem_MA, lsp_new_bck, lsp_mid_bck, Bin_E, Bin_E_old, mem_syn_bck, &mem_w0_bck, &streaklimit, &pstreaklen );
+
+ if ( !tdm_lp_reuse_flag )
+ {
+ lsf_enc( st, lsf_new, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh );
+ }
+ else
+ {
+ const float *pt_interp_2;
+
+ if ( st->active_cnt != 1 )
+ {
+ int16_t beta_index;
+ float lsf_wgts[M];
+
+ /* intra_frame prediction for the LSFs */
+ lsp2lsf( lsp_new, lsf_new, M, 12800 );
+
+ Unified_weighting( &st->Bin_E[L_FFT / 2], lsf_new, lsf_wgts, st->bwidth == NB, st->coder_type == UNVOICED, st->sr_core, M );
+#ifdef IVAS_FLOAT_FIXED
+ Word16 lsf_new_fx[M];
+ Word16 lsp_new_fx[M];
+ Word16 tdm_lsfQ_PCh_fx[M];
+ Word16 lsf_wgts_fx[M];
+ for ( int ii = 0; ii < M; ii++ )
+ {
+ lsf_new_fx[ii] = (Word16) ( ( lsf_new[ii] ) * 2.56f );
+ tdm_lsfQ_PCh_fx[ii] = (Word16) ( ( tdm_lsfQ_PCh[ii] ) * 2.56f );
+ lsf_wgts_fx[ii] = (Word16) ( ( lsf_wgts[ii] ) * 2.56f );
+ }
+ floatToFixed_arr( lsp_new, lsp_new_fx, 15, M );
+
+ tdm_SCh_lsf_reuse_fx( ENC, st->element_brate, lsf_new_fx, lsp_new_fx, tdm_lsfQ_PCh_fx, lsf_wgts_fx, &beta_index );
+
+ for ( int ii = 0; ii < M; ii++ )
+ {
+ lsf_new[ii] = (Word16) ( ( lsf_new_fx[ii] ) / 2.56f );
+ lsf_wgts[ii] = (Word16) ( ( lsf_wgts_fx[ii] ) / 2.56f );
+ }
+ fixedToFloat_arr( lsp_new_fx, lsp_new, 15, M );
+#else
+ tdm_SCh_lsf_reuse( ENC, st->element_brate, lsf_new, lsp_new, tdm_lsfQ_PCh, lsf_wgts, &beta_index );
+#endif
+ push_indice( hBstr, IND_IC_LSF_PRED, beta_index, TDM_IC_LSF_PRED_BITS );
+ }
+
+ pt_interp_2 = interpol_frac_12k8;
+ if ( tdm_low_rate_mode == 1 && st->coder_type > UNVOICED )
+ {
+ pt_interp_2 = interpol_frac2;
+ }
+
+ if ( st->active_cnt == 1 )
+ {
+ mvr2r( lsp_new, st->lsp_old, M );
+ lsp2lsf( lsp_new, st->lsf_old, M, st->sr_core );
+ lsp2lsf( lsp_new, lsf_new, M, st->sr_core );
+ }
+
+ /* LSP interpolation and conversion of LSPs to A(z) */
+ int_lsp( st->L_frame, st->lsp_old, lsp_new, Aq, M, pt_interp_2, 0 );
+
+ /* Check LSF stability (distance between old LSFs and current LSFs) */
+ st->stab_fac = lsf_stab( lsf_new, st->lsf_old, 0, st->L_frame );
+ }
+
+ if ( st->last_core == HQ_CORE && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory from last HQ frame */
+ tmpF = hLPDmem->old_exc_flt[0];
+ preemph( hLPDmem->old_exc_flt, st->preemph_fac_flt, st->L_frame, &tmpF );
+ mvr2r( hLPDmem->old_exc_flt + st->L_frame - M, hLPDmem->mem_syn_flt, M );
+ residu( Aq, M, hLPDmem->old_exc_flt, old_exc_flt, st->L_frame );
+ }
+
+ if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory of old_bwe_exc */
+ if ( st->L_frame == L_FRAME )
+ {
+ lerp_flt( old_exc_flt, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
+ }
+ else
+ {
+ lerp_flt( old_exc_flt, old_bwe_exc, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC );
+ }
+ }
+
+
+ /*---------------------------------------------------------------*
+ * Calculation of LP residual (filtering through A[z] filter)
+ *---------------------------------------------------------------*/
+
+ calc_residu( inp, res, Aq, st->L_frame );
+
+ calculate_hangover_attenuation_gain( st, &att, vad_hover_flag );
+ if ( att != 1.0f )
+ {
+ v_multc( res, att, res, st->L_frame );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Determine TC subframe classification
+ *-----------------------------------------------------------------*/
+
+ if ( st->coder_type == TRANSITION )
+ {
+ tc_classif_enc( st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res );
+
+ 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( &Es_pred, &i, st->L_frame, L_SUBFR, res, st->voicing, nb_bits, uc_two_stage_flag );
+ push_indice( hBstr, IND_ES_PRED, i, nb_bits );
+ }
+
+ /*------------------------------------------------------------*
+ * Encode excitation according to coding type
+ *------------------------------------------------------------*/
+
+ if ( tdm_low_rate_mode ) /* tdm stereo low rate mode */
+ {
+ if ( st->coder_type <= UNVOICED )
+ {
+ tdm_low_rate_enc( st, Aq, res, syn, exc, pitch_buf, voice_factors, bwe_exc, 0 /*attack_flag*/, lsf_new, &tmp_noise );
+ }
+ else /* GENERIC */
+ {
+ encod_gen_2sbfr( st, inp, Aw, Aq, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ }
+ }
+ else if ( nelp_mode )
+ {
+ /* SC-VBR - NELP frames */
+ encod_nelp( st, inp, Aw, Aq, res, syn, &tmp_noise, exc, exc2, pitch_buf, voice_factors, bwe_exc );
+ }
+ else if ( st->coder_type == UNVOICED )
+ {
+ /* UNVOICED frames (Gauss. excitation) */
+ encod_unvoiced( st, inp, Aw, Aq, Es_pred, uc_two_stage_flag, res, syn, &tmp_noise, exc, pitch_buf, voice_factors, bwe_exc );
+ }
+ else if ( st->coder_type == TRANSITION )
+ {
+ encod_tran( st, inp, Aw, Aq, Es_pred, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, tc_subfr, position, unbits );
+ }
+ else if ( ppp_mode )
+ {
+ /* SC-VBR - PPP frames */
+ if ( ( error = encod_ppp( st, inp, Aw, Aq, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc ) ) != 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( st, tilt_code_bck, gc_threshold_bck, clip_var_bck, next_force_sf_bck, lsp_new, lsp_mid, clip_var, mem_AR, mem_MA, lsp_new_bck, lsp_mid_bck, Bin_E, Bin_E_old, mem_syn_bck, mem_w0_bck, streaklimit, 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( st, lsf_new, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL );
+
+ /* recalculation of LP residual (filtering through A[z] filter) */
+ calc_residu( inp, res, Aq, st->L_frame );
+ st->hTdCngEnc->burst_ho_cnt = 0;
+
+ /* VOICED frames in SC-VBR */
+ encod_gen_voic( st, inp, Aw, Aq, Es_pred, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ }
+ }
+ else if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) )
+ {
+ /* AUDIO and INACTIVE frames (coded by GSC technology) */
+ encod_audio( st, inp, Aw, Aq, res, syn, exc, pitch_buf, voice_factors, bwe_exc, attack_flag, lsf_new, &tmp_noise, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ }
+ else
+ {
+ /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
+ encod_gen_voic( st, inp, Aw, Aq, Es_pred, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ }
+
+
+ /* update mem_syn1_flt for ACELP core switching */
+ mvr2r( hLPDmem->mem_syn_flt, hLPDmem->mem_syn1_flt, M );
+
+ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
+ mvr2r( syn + st->L_frame - L_SYN_MEM, hLPDmem->mem_syn_r_flt, L_SYN_MEM );
+
+ /* save and delay synthesis to be used by SWB BWE */
+ if ( st->hBWE_FD != NULL )
+ {
+ save_old_syn( st->L_frame, syn, old_syn_12k8_16k, st->hBWE_FD->old_syn_12k8_16k, st->preemph_fac_flt, &st->hBWE_FD->mem_deemph_old_syn );
+ }
+ /*Update MODE2 core switching memory*/
+ mvr2r( syn, syn1, st->L_frame );
+ deemph( syn1, st->preemph_fac_flt, st->L_frame, &( hLPDmem->syn_flt[M] ) );
+ mvr2r( syn1 + st->L_frame - M - 1, hLPDmem->syn_flt, M + 1 );
+
+ if ( st->element_mode > EVS_MONO && st->hTcxEnc != NULL )
+ {
+ mvr2r( syn1 + st->L_frame / 2, st->hTcxEnc->Txnq_flt, st->L_frame / 2 );
+ }
+
+ /*--------------------------------------------------------------------------------------*
+ * Modify the excitation signal when the noise is stationary
+ *--------------------------------------------------------------------------------------*/
+
+ if ( !( st->idchan == 1 && st->element_mode == IVAS_CPE_TD ) && nelp_mode != 1 && !( st->element_mode == IVAS_SCE && tdm_low_rate_mode ) )
+ {
+ /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */
+ mvr2r( exc, exc2, st->L_frame );
+ stat_noise_uv_enc( st, epsP, lsp_new, lsp_mid, Aq, exc2, uc_two_stage_flag );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Encode supplementary information for Frame Error Concealment
+ *-----------------------------------------------------------------*/
+
+ FEC_encode( hBstr, st->acelp_cfg, syn, st->coder_type, st->clas, pitch_buf, res, &st->Last_pulse_pos, st->L_frame, st->total_brate );
+
+ if ( st->hBWE_TD != NULL )
+ {
+ if ( st->L_frame == L_FRAME )
+ {
+ mvr2r( Aq + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq, ( M + 1 ) );
+ }
+ else
+ {
+ mvr2r( Aq + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq, ( M + 1 ) );
+ }
+ }
+
+
+ } /* end of active inp coding */
+#endif
+
+ /*-----------------------------------------------------------------*
+ * Write ACELP unused bits
+ *-----------------------------------------------------------------*/
+
+ if ( st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA && st->core_brate != PPP_NELP_2k80 )
+ {
+ nBits = st->acelp_cfg.ubits;
+
+ while ( nBits > 0 )
+ {
+ i = min( nBits, 16 );
+ push_indice( hBstr, IND_UNUSED, 0, i );
+ nBits -= i;
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Apply non linearity in case of SWB TBE
+ *-----------------------------------------------------------------*/
+
+ if ( st->hBWE_TD != NULL )
+ {
+ if ( ( st->last_Opt_SC_VBR == 1 && st->Opt_SC_VBR == 0 ) || ( ( st->extl == SWB_TBE || st->extl == WB_TBE || st->extl == FB_TBE ) && st->last_extl != SWB_TBE && st->last_extl != WB_TBE && st->last_extl != FB_TBE ) || ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD && !st->tdm_LRTD_flag ) )
+ {
+ st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f;
+ set_f( st->hBWE_TD->old_bwe_exc_extended, 0.0f, NL_BUFF_OFFSET );
+ }
+
+ if ( !st->Opt_SC_VBR && ( st->idchan == 0 || st->element_mode != IVAS_CPE_TD || ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag ) ) )
+ {
+ /* Apply a non linearity to the SHB excitation */
+ non_linearity( bwe_exc, bwe_exc_extended, st->hBWE_TD->old_bwe_exc_extended, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale, st->coder_type, voice_factors, st->L_frame );
+ }
+
+ if ( st->core_brate == SID_2k40 || st->core_brate == FRAME_NO_DATA )
+ {
+ st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f;
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Updates
+ *-----------------------------------------------------------------*/
+
+ updt_enc( st, old_exc_flt, pitch_buf, Es_pred, Aq, lsf_new, lsp_new, old_bwe_exc );
+
+ if ( st->hTdCngEnc != NULL && st->Opt_DTX_ON && st->core_brate > SID_2k40 )
+ {
+ /* update CNG parameters in active frames */
+ cng_params_upd( lsp_new, exc, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ, ENC, st->hTdCngEnc->ho_env_circ, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth );
+
+ if ( st->L_frame == L_FRAME )
+ {
+ /* store LSPs@16k, potentially to be used in CNG@16k */
+ mvr2r( st->lsp_old16k, &( st->hTdCngEnc->ho_lsp_circ2[( st->hTdCngEnc->ho_circ_ptr ) * M] ), M );
+ }
+
+ /* set LSP@16k flag for the first buffer */
+ st->hTdCngEnc->ho_16k_lsp[st->hTdCngEnc->ho_circ_ptr] = ( st->L_frame == L_FRAME ? 0 : 1 );
+
+ /* efficient DTX hangover control */
+ if ( st->hTdCngEnc->burst_ho_cnt > 1 )
+ {
+ dtx_hangover_control( st, lsp_new );
+ }
+ }
+
+ /* SC-VBR update of average data rate */
+ if ( st->vad_flag == 1 )
+ {
+ /* reset in case of bitrate switching in EVS */
+ if ( st->hSC_VBR != NULL )
+ {
+ update_average_rate( st->hSC_VBR, st->core_brate );
+ }
+ }
+
+ pop_wmops();
+
+ return error;
+}
+#else
ivas_error acelp_core_enc(
Encoder_State *st, /* i/o: encoder state structure */
const float inp[], /* i : input signal of the current frame */
@@ -373,7 +1854,11 @@ ivas_error acelp_core_enc(
* After inactive period, use the most up-to-date ISPs
*-----------------------------------------------------------------*/
+#ifdef NON_BE_FIX_807_MASA_DTX_BRSW
+ if ( st->hDtxEnc != NULL && ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) )
+#else
if ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 )
+#endif
{
mvr2r( st->hDtxEnc->lspCNG, st->lsp_old, M );
lsp2lsf( st->hDtxEnc->lspCNG, st->lsf_old, M, int_fs );
@@ -726,3 +2211,4 @@ ivas_error acelp_core_enc(
return error;
}
+#endif
diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c
index 3d4eda605e42c66ec845bb9ec0e55bf527a00c4a..a21f4adbb08c9233c87999f3dcf7a8c561252f26 100644
--- a/lib_enc/acelp_core_enc_fx.c
+++ b/lib_enc/acelp_core_enc_fx.c
@@ -6,8 +6,7 @@
#include
#include "options.h" /* Compilation switches */
#include "cnst.h"
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "stat_enc.h"
#include "rom_com.h"
#include "rom_enc.h" /* Encoder static table prototypes */
@@ -396,7 +395,7 @@ ivas_error acelp_core_enc_fx(
IF( !nelp_mode && !ppp_mode )
{
config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
- st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot_fx, st_fx->coder_type,
+ st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type,
tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx,
tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
}
@@ -406,7 +405,12 @@ ivas_error acelp_core_enc_fx(
*-----------------------------------------------------------------*/
test();
+#ifdef NON_BE_FIX_807_MASA_DTX_BRSW
+ test();
+ IF( st_fx->hDtxEnc != NULL && ( st_fx->last_core_brate == FRAME_NO_DATA || EQ_32( st_fx->last_core_brate, SID_2k40 ) ) )
+#else
IF( EQ_32( st_fx->last_core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->last_core_brate, SID_2k40 ) )
+#endif
{
Copy( hDtxEnc->lspCNG_fx, st_fx->lsp_old_fx, M );
@@ -528,10 +532,10 @@ ivas_error acelp_core_enc_fx(
IF( EQ_16( st_fx->coder_type, TRANSITION ) )
{
- tc_classif_enc_fx( Q_new, st_fx->L_frame, &tc_subfr_fx, &position, attack_flag, st_fx->pitch_fx[0], res_fx );
+ tc_classif_enc_fx( Q_new, st_fx->L_frame, &tc_subfr_fx, &position, attack_flag, st_fx->pitch[0], res_fx );
config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
- -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot_fx, st_fx->coder_type, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag,
+ -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag,
tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
}
@@ -599,7 +603,7 @@ ivas_error acelp_core_enc_fx(
/* Configure ACELP bit allocation */
config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
- -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot_fx, st_fx->coder_type, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0,
+ -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0,
st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
/* redo LSF quantization */
diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c
index e71900fc295c6cf7cdaa7352fb630b6450788469..f2558851bd7bab39c835fb0dc63302cc6bc07695 100644
--- a/lib_enc/acelp_core_switch_enc_fx.c
+++ b/lib_enc/acelp_core_switch_enc_fx.c
@@ -8,8 +8,7 @@
#include "rom_com_fx.h"
//#include "prot_fx.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
@@ -63,9 +62,9 @@ void acelp_core_switch_enc_fx(
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_fx[0];
+ T_op[0] = st_fx->pitch[0];
move16();
- T_op[1] = st_fx->pitch_fx[1];
+ T_op[1] = st_fx->pitch[1];
move16();
/*----------------------------------------------------------------*
@@ -138,7 +137,7 @@ void acelp_core_switch_enc_fx(
/*----------------------------------------------------------------*
* Excitation encoding
*----------------------------------------------------------------*/
- config_acelp1( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot_fx,
+ config_acelp1( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
GENERIC, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new );
@@ -160,11 +159,11 @@ void acelp_core_switch_enc_fx(
#else
FOR( i = 0; i < 20; i++ )
{
- hBstr->ind_list_fx[IND_CORE_SWITCHING_CELP_SUBFRAME + i].value = hBstr->ind_list_fx[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;
move16();
- hBstr->ind_list_fx[IND_CORE_SWITCHING_CELP_SUBFRAME + i].nb_bits = hBstr->ind_list_fx[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;
move16();
- hBstr->ind_list_fx[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1;
+ hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1;
move16();
}
#endif
diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c
index 8dde5a31946e9da10aa854ee06f07476adffe9c1..ffdf837c4ee090fe1ff596ceb0a61a9e3395b058 100644
--- a/lib_enc/acelp_enc_util_fx.c
+++ b/lib_enc/acelp_enc_util_fx.c
@@ -9,8 +9,7 @@
//#include "prot_fx.h"
#include "basop_util.h"
#include "cnst.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "stat_enc.h"
#include "rom_com.h"
diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c
index 535123e4569abaa194274de1212779394b37d48d..3b68f8be1aaadc0af20ed498d6f16dd01966aa80 100644
--- a/lib_enc/amr_wb_enc_fx.c
+++ b/lib_enc/amr_wb_enc_fx.c
@@ -10,8 +10,7 @@
//#include "prot_fx.h" /* Function prototypes */
#include "basop_util.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
#include "prot_fx_enc.h"
@@ -255,8 +254,8 @@ void amr_wb_enc_fx(
/*----------------------------------------------------------------*
* Change the sampling frequency to 12.8 kHz
*----------------------------------------------------------------*/
-
- modify_Fs_fx( st->input_fx, input_frame, st->input_Fs, new_inp, 12800, st->mem_decim_fx, 0 );
+ Word16 Q_new_inp, mem_decim_size; // TO be removed
+ 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 );
@@ -400,7 +399,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_fx[1];
+ old_pitch1 = st->pitch[1];
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 );
@@ -422,8 +421,8 @@ void amr_wb_enc_fx(
shift = -1;
move16();
}
- pitch_ol_fx( st->pitch_fx, 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_fx[2];
+ 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];
move16();
st->old_voicing_la = st->voicing_fx[2];
move16();
@@ -459,7 +458,7 @@ void amr_wb_enc_fx(
}
ELSE IF( EQ_32( st->input_Fs, 32000 ) || EQ_32( st->input_Fs, 48000 ) )
{
- modify_Fs_fx( st->input_fx, input_frame, st->input_Fs, new_inp_16k, 16000, st->mem_decim16k_fx, 0 );
+ modify_Fs_fx( st->input_fx, input_frame, st->input_Fs, new_inp_16k, 16000, st->mem_decim16k_fx, 0, &Q_new_inp, &mem_decim_size );
}
/*----------------------------------------------------------------*
diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c
index 51c40ec5ec11dc44f28d8084f864f7912341c2b8..b8582d2710cb861ce71d567486d957e0ce760af2 100644
--- a/lib_enc/analy_lp_fx.c
+++ b/lib_enc/analy_lp_fx.c
@@ -9,8 +9,7 @@
#include "rom_com.h" /* Static table prototypes */
#include "rom_enc.h" /* Static table prototypes */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c
index fd96bfe4e7b43d590b3f46c4de6d1a8feaa2543c..e23c9b9a5eb4701391cfe37e7c43a7149f6ca0b5 100644
--- a/lib_enc/analy_sp_fx.c
+++ b/lib_enc/analy_sp_fx.c
@@ -7,8 +7,7 @@
#include "cnst.h"
#include "basop_util.h"
//#include "prot_fx.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "rom_enc.h"
#include "rom_com.h"
diff --git a/lib_enc/ari_enc.c b/lib_enc/ari_enc.c
index 2908310f8b3336ff601a1a745eae981624162d69..8481d6c94a0a7228fd23a8b30f264bc622c9d9c5 100644
--- a/lib_enc/ari_enc.c
+++ b/lib_enc/ari_enc.c
@@ -39,6 +39,7 @@
#include "options.h"
#include "cnst.h"
#include "prot.h"
+#include "prot_fx.h"
#include "stat_com.h"
#include "basop_util.h"
#include "wmc_auto.h"
@@ -81,7 +82,21 @@ void ari_start_encoding_14bits(
return;
}
+#ifdef IVAS_FLOAT_FIXED
+void ari_start_encoding_14bits_ivas_fx(
+ Tastat *s )
+{
+ /* : addressing is made with walking pointer s */
+ s->low = 0;
+ s->high = ari_q4new;
+ s->bits_to_follow = 0;
+ move32();
+ move32();
+ move32();
+ return;
+}
+#endif
/*---------------------------------------------------------------
* ari_done_encoding_14bits()
diff --git a/lib_enc/ari_enc_fx.c b/lib_enc/ari_enc_fx.c
index 5e01f8f3589ecf0c65fb0db6787275f5cdbb73ed..54c21c9d1f6a29f2cfc3dbfaf3272d6139731def 100644
--- a/lib_enc/ari_enc_fx.c
+++ b/lib_enc/ari_enc_fx.c
@@ -9,8 +9,7 @@
#include "cnst.h"
#include "rom_com.h"
//#include "prot_fx.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*---------------------------------------------------------------
diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c
index bc4c225df9676f7a97bf93c7df1617f49fcae932..8414c56daa0ef4f918647baca5fb7deb4d38b42c 100644
--- a/lib_enc/ari_hm_enc_fx.c
+++ b/lib_enc/ari_hm_enc_fx.c
@@ -12,8 +12,7 @@
#include "rom_enc.h"
#include "prot.h"
//#include "prot_fx.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
diff --git a/lib_enc/arith_coder_enc.c b/lib_enc/arith_coder_enc.c
index eedd260ee011e983310327d02ac85da4e594319e..3b5c8dea9a3967142cc744009efc352d49bde169 100644
--- a/lib_enc/arith_coder_enc.c
+++ b/lib_enc/arith_coder_enc.c
@@ -248,11 +248,11 @@ static float tcx_arith_find_max_scale(
/*! r: index of highest freq. nonzero line (-1 if all zeros) */
static int16_t tcx_arith_find_kMax(
- const float abs_spectrum[], /* i : absolute MDCT coefficients */
- const int16_t L_frame, /* i : number of spectral lines */
- const float scale, /* i : scalar quantizer scale */
- const float deadzone, /* i : deadzone (0.5f = no deadzone) */
- const int16_t deadzone_flags[] /* i : line-wise deadzone control */
+ const float abs_spectrum[], /* i : absolute MDCT coefficients */
+ const int16_t L_frame, /* i : number of spectral lines */
+ const float scale, /* i : scalar quantizer scale */
+ const float deadzone, /* i : deadzone (0.5f = no deadzone) */
+ const int8_t deadzone_flags[] /* i : line-wise deadzone control */
)
{
int16_t kMax;
@@ -275,15 +275,15 @@ static int16_t tcx_arith_find_kMax(
/*! r: best scale */
static float tcx_arith_rateloop(
- const float abs_spectrum[], /* i : absolute MDCT coefficients */
- const int16_t L_frame, /* i : number of spectral lines */
- const Word16 envelope[], /* i : scaled envelope (Q15-e) */
- const Word16 envelope_e, /* i : scaled envelope exponent (Q0) */
- const Word16 exps[], /* i : expfp_evs(-(integer)envelope[]/2) */
- const int16_t target_bits, /* i : target bit budget */
- const float deadzone, /* i : deadzone (0.5f = no deadzone) */
- const int16_t deadzone_flags[], /* i : line-wise deadzone control */
- float *target_bits_fac /* i/o: scale estimator compensation */
+ const float abs_spectrum[], /* i : absolute MDCT coefficients */
+ const int16_t L_frame, /* i : number of spectral lines */
+ const Word16 envelope[], /* i : scaled envelope (Q15-e) */
+ const Word16 envelope_e, /* i : scaled envelope exponent (Q0) */
+ const Word16 exps[], /* i : expfp_evs(-(integer)envelope[]/2) */
+ const int16_t target_bits, /* i : target bit budget */
+ const float deadzone, /* i : deadzone (0.5f = no deadzone) */
+ const int8_t deadzone_flags[], /* i : line-wise deadzone control */
+ float *target_bits_fac /* i/o: scale estimator compensation */
)
{
int16_t k, idx, kMax, q;
@@ -594,7 +594,7 @@ void tcx_arith_encode_envelope(
float scale;
int16_t k, kMax;
float deadzone;
- const int16_t *deadzone_flags;
+ const int8_t *deadzone_flags;
float gamma_w, gamma_uw;
int16_t hm_bits;
@@ -609,7 +609,7 @@ void tcx_arith_encode_envelope(
gamma_uw = 1.0f / st->gamma_flt;
#define WMC_TOOL_SKIP
- tcx_arith_render_envelope_flt( A_ind, L_frame, L_spec, FL2WORD16( hTcxCfg->preemph_fac_flt ), FL2WORD16( gamma_w ), FL2WORD16( 0.5f * gamma_uw ), env );
+ tcx_arith_render_envelope_ivas( A_ind, L_frame, L_spec, FL2WORD16( hTcxCfg->preemph_fac_flt ), FL2WORD16( gamma_w ), FL2WORD16( 0.5f * gamma_uw ), env );
#undef WMC_TOOL_SKIP
for ( k = 0; k < L_spec; ++k )
@@ -644,7 +644,7 @@ void tcx_arith_encode_envelope(
L_spec_core = min( L_spec_core, st->hIGFEnc->infoStartLine );
}
envelope = (Word16 *) env;
- tcx_arith_scale_envelope_flt( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e );
+ tcx_arith_scale_envelope_ivas( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e );
#define WMC_TOOL_SKIP
tmp = sub( envelope_e, 1 );
diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c
index 5c96532bea9756db06a95d8f9270ce0a65977a71..6b137f31e1b30c7a61fc9386be150537360c3a62 100644
--- a/lib_enc/arith_coder_enc_fx.c
+++ b/lib_enc/arith_coder_enc_fx.c
@@ -6,8 +6,7 @@
#include
#include "options.h"
#include "cnst.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h"
#include "rom_com.h"
@@ -716,7 +715,7 @@ void tcx_arith_encode_envelope_fx(
hTcxCfg = st->hTcxCfg;
deadzone = hTcxCfg->sq_rounding;
move16();
- deadzone_flags = hTcxEnc->memQuantZeros_fx;
+ deadzone_flags = hTcxEnc->memQuantZeros;
*signaling_bits = 0;
move16();
diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c
index 5b1756bfdd8f1ae9331dc881e051a5d6a37421fe..ece84e4e95cd46448e961427e032bc582020773f 100644
--- a/lib_enc/avq_cod_fx.c
+++ b/lib_enc/avq_cod_fx.c
@@ -8,8 +8,7 @@
#include /* Compilation switches */
#include "prot.h" /* Function prototypes */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "rom_com.h" /* Static table prototypes */
diff --git a/lib_enc/bass_psfilter_enc_fx.c b/lib_enc/bass_psfilter_enc_fx.c
index c8ea49bf33f8f48fc87718baf8b060875e12bca2..df52213c2bdc3d56ff7cbb9302ceaae8b3d78479 100644
--- a/lib_enc/bass_psfilter_enc_fx.c
+++ b/lib_enc/bass_psfilter_enc_fx.c
@@ -7,8 +7,7 @@
#include "options.h"
#include "cnst.h"
#include "rom_com.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h"
diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c
index eb3e62ddf06092200ba91466c495288752e7d520..3cc6784de9b795e56998411f326094f11979fb4e 100644
--- a/lib_enc/bw_detect_fx.c
+++ b/lib_enc/bw_detect_fx.c
@@ -5,14 +5,13 @@
#include
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
-//#include "prot_fx.h" /* Function prototypes */
#include "rom_enc.h" /* Encoder static table prototypes */
#include "rom_com.h"
#include "basop_util.h"
#include "ivas_cnst.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
-#include "prot_fx_enc.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "ivas_prot_fx.h" /* Function prototypes */
+#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
* Local constants
@@ -312,16 +311,14 @@ void bw_detect_fx(
}
ELSE
{
-#ifdef IVAS_CODE_DFT
- l_frame = (int16_t) ( st->input_Fs / FRAMES_PER_SEC );
- if ( st->core == TCX_10_CORE )
+ Word16 l_frame = (int16_t) ( st->input_Fs / FRAMES_PER_SEC );
+ IF( EQ_16( st->core, TCX_10_CORE ) )
{
- l_frame /= 2;
+ l_frame = shr( l_frame, 1 );
}
- bin_width *= ( l_frame / BWD_TOTAL_WIDTH );
- mvr2r( spectrum, spect, l_frame );
-#endif
+ bin_width = i_mult( bin_width, l_frame / BWD_TOTAL_WIDTH );
+ Copy( spectrum, spect, l_frame );
}
/*---------------------------------------------------------------------*
* compute energy per spectral bins
@@ -1070,7 +1067,7 @@ void set_bw_stereo(
return;
}
-
+#endif
/*-------------------------------------------------------------------*
* set_bw_mct()
*
@@ -1078,54 +1075,58 @@ void set_bw_stereo(
*-------------------------------------------------------------------*/
/*! r: flag indicating whether the coded BW has changed */
-int16_t set_bw_mct(
+Word16 set_bw_mct_fx(
CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE encoder structures */
- const int16_t nCPE /* i : number of CPEs */
+ const Word16 nCPE /* i : number of CPEs */
)
{
- Encoder_State *sts[MCT_MAX_CHANNELS];
- int16_t ch, cpe_id;
- int16_t mct_bwidth, last_mct_bwidth, bw_changed;
+ Encoder_State *st;
+ Word16 ch, cpe_id;
+ Word16 mct_bwidth, last_mct_bwidth, bw_changed;
mct_bwidth = WB; /* minimum coded audio band-width */
last_mct_bwidth = hCPE[0]->hCoreCoder[0]->last_bwidth; /* supposes that LFE is not in the first channel */
+ move16();
+ 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++ )
{
- sts[ch] = hCPE[cpe_id]->hCoreCoder[ch];
- if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
+ st = hCPE[cpe_id]->hCoreCoder[ch];
+ IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
- continue;
+ CONTINUE;
}
- mct_bwidth = max( mct_bwidth, sts[ch]->input_bwidth );
+ mct_bwidth = s_max( mct_bwidth, st->input_bwidth );
}
}
- for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
+
+ FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
- if ( hCPE[cpe_id]->element_brate > BWD_MAX_BRATE_WIDER_BW_MDCT )
+ IF( GT_32( hCPE[cpe_id]->element_brate, BWD_MAX_BRATE_WIDER_BW_MDCT ) )
{
- mct_bwidth = max( mct_bwidth, hCPE[cpe_id]->hCoreCoder[0]->max_bwidth );
+ mct_bwidth = s_max( mct_bwidth, hCPE[cpe_id]->hCoreCoder[0]->max_bwidth );
}
}
+
bw_changed = 0;
- if ( mct_bwidth != last_mct_bwidth )
+ move16();
+ IF( NE_16( mct_bwidth, last_mct_bwidth ) )
{
bw_changed = 1;
+ 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++ )
{
- sts[ch] = hCPE[cpe_id]->hCoreCoder[ch];
- sts[ch]->bwidth = mct_bwidth;
+ st = hCPE[cpe_id]->hCoreCoder[ch];
+ st->bwidth = mct_bwidth;
+ move16();
}
}
}
-
return bw_changed;
}
-
-#endif
diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c
index 401eb6412be817097b5b6be024b796e358c7ae00..e94da2f7c565401d11853a307c95ea02fbffa48e 100644
--- a/lib_enc/cng_enc_fx.c
+++ b/lib_enc/cng_enc_fx.c
@@ -7,8 +7,7 @@
#include "rom_enc.h" /* Encoder static table prototypes */
#include "rom_com.h" /* Static table prototypes */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
//#include "basop_mpy.h"
@@ -759,7 +758,8 @@ void CNG_enc_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
- modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, hTdCngEnc->exc_mem2_fx, 0 );
+ Word16 Q_new_inp, mem_decim_size; // TO be removed
+ modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, hTdCngEnc->exc_mem2_fx, 0, &Q_new_inp, &mem_decim_size );
}
fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT );
@@ -1318,8 +1318,8 @@ static void shb_CNG_encod_fx(
push_indice_fx( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4 );
push_indice_fx( hBstr, IND_SID_BW, 1, 1 );
#ifndef IVAS_CODE
- hBstr->nb_bits_tot_fx = sub( hBstr->nb_bits_tot_fx, hBstr->ind_list_fx[IND_CNG_ENV1].nb_bits );
- hBstr->ind_list_fx[IND_CNG_ENV1].nb_bits = -1;
+ 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;
#else
delete_indice( hBstr, IND_CNG_ENV1 );
#endif
diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c
index afb4d7ff3575095a38e99b755f43273a2fe98ec5..06c4d31f0dcacd6f72b95dc16bb8afd8738254f4 100644
--- a/lib_enc/cod2t32_fx.c
+++ b/lib_enc/cod2t32_fx.c
@@ -6,8 +6,7 @@
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Common constants */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c
index 43d1e643445718e753796ec1d5685e7f3991eb00..b20c94daf7d2157509a14463a5470d41ec60f68e 100644
--- a/lib_enc/cod4t64_fx.c
+++ b/lib_enc/cod4t64_fx.c
@@ -8,8 +8,7 @@
//#include "prot_fx.h" /* Function prototypes */
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c
index 667843880922ca8eda869918b337a2c5d68006f6..efa0e0d4c06c5213554cb068d28dd8850da8e43b 100644
--- a/lib_enc/cod_ace_fx.c
+++ b/lib_enc/cod_ace_fx.c
@@ -11,8 +11,7 @@
#include "options.h"
#include "rom_basop_util.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
@@ -240,7 +239,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
{
/* Adaptive Codebook (GC and VC) */
- Mode2_pit_encode_fx( acelp_cfg->ltp_mode, i_subfr, &prm, &exc[i_subfr], st->pitch_fx, &T0_min, &T0_min_frac, &T0_max, &T0_max_frac,
+ Mode2_pit_encode_fx( acelp_cfg->ltp_mode, i_subfr, &prm, &exc[i_subfr], st->pitch, &T0_min, &T0_min_frac, &T0_max, &T0_max_frac,
&T0, &T0_frac, &T0_res, h1, xn, st->pit_min, st->pit_fr1, st->pit_fr1b, st->pit_fr2, st->pit_max, st->pit_res_max );
E_ACELP_adaptive_codebook( exc, T0, T0_frac, T0_res, st->pit_res_max, acelp_cfg->ltf_mode, i_subfr, L_SUBFR, L_frame, h1, clip_gain, xn,
diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c
index 96acb8f40145e6b1bc233d723601bf0cd1b2cc5f..77da3cd29fbdec4d3f9b06be5791473340db4bc6 100644
--- a/lib_enc/cod_tcx.c
+++ b/lib_enc/cod_tcx.c
@@ -580,7 +580,7 @@ void TNSAnalysis(
TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */
const float ltp_gain, /* i : ltp gain */
STnsData *pTnsData, /* o : TNS data */
- int16_t *pfUseTns, /* o : Flag indicating if TNS is used */
+ int8_t *pfUseTns, /* o : Flag indicating if TNS is used */
float *predictionGain /* o : TNS prediction gain */
)
{
@@ -615,7 +615,7 @@ void TNSAnalysis(
}
}
- *pfUseTns = DetectTnsFilt( hTcxCfg->pCurrentTnsConfig, spectrum, hTranDet, transform_type != TCX_20, ltp_gain, pTnsData, predictionGain );
+ *pfUseTns = (Word8) DetectTnsFilt( hTcxCfg->pCurrentTnsConfig, spectrum, hTranDet, transform_type != TCX_20, ltp_gain, pTnsData, predictionGain );
/* If TNS should be used then get the residual after applying it inplace in the spectrum */
@@ -661,7 +661,7 @@ void ShapeSpectrum(
const int16_t L_frame_glob, /* i : frame length */
int16_t L_spec, /* i : length of the spectrum */
float spectrum[], /* i/o: MDCT spectrum */
- const int16_t fUseTns, /* i : Flag indicating if TNS is used */
+ const int8_t fUseTns, /* i : Flag indicating if TNS is used */
Encoder_State *st, /* i/o: encoder state structure */
float *scf /* i : scale factors */
)
diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c
index 0c3f7d4df719ed2d98a149e99aeb6a8cdc08ecec..0a747b4771c50441ccf7ef606dd8b18d784c8915 100644
--- a/lib_enc/cod_tcx_fx.c
+++ b/lib_enc/cod_tcx_fx.c
@@ -9,8 +9,7 @@
#include "rom_com.h"
#include "stat_com.h"
//#include "prot_fx.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "basop_util.h"
#include "stl.h"
//#include "basop_mpy.h"
@@ -1407,7 +1406,7 @@ void QuantizeSpectrum_fx(
L_spec,
sqGain, sqGain_e,
hTcxCfg->sq_rounding,
- hTcxEnc->memQuantZeros_fx,
+ hTcxEnc->memQuantZeros,
tcxonly );
/* Estimate original bitrate */
@@ -1501,7 +1500,7 @@ void QuantizeSpectrum_fx(
L_spec,
sqGain, sqGain_e,
hTcxCfg->sq_rounding,
- hTcxEnc->memQuantZeros_fx,
+ hTcxEnc->memQuantZeros,
tcxonly );
/* Estimate bitrate */
@@ -1567,7 +1566,7 @@ void QuantizeSpectrum_fx(
L_spec,
&sqGain, &sqGain_e,
hTcxCfg->sq_rounding,
- hTcxEnc->memQuantZeros_fx,
+ hTcxEnc->memQuantZeros,
prm_lastnz, /* lastnz */
sqTargetBits,
&nEncoded,
@@ -1699,7 +1698,7 @@ void QuantizeSpectrum_fx(
L_spec,
sqGain, sqGain_e,
hTcxCfg->sq_rounding,
- hTcxEnc->memQuantZeros_fx,
+ hTcxEnc->memQuantZeros,
tcxonly );
move16();
@@ -2886,25 +2885,25 @@ void coder_tcx_fx(
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_fx, &st->hIGFEnc->tns_predictionGain );
+ TNSAnalysis_fx( hTcxCfg, L_frame, L_spec, TCX_20, st->last_core == 0, spectrum, hTcxEnc->tnsData, hTcxEnc->fUseTns, &st->hIGFEnc->tns_predictionGain );
}
ELSE
{
- hTcxEnc->fUseTns_fx[0] = hTcxEnc->fUseTns_fx[1] = 0;
+ hTcxEnc->fUseTns[0] = hTcxEnc->fUseTns[1] = 0;
move16();
move16();
}
IF( st->igf )
{
- ProcessIGF_fx( st->hIGFEnc, st, spectrum, spectrum_e, powerSpec, &powerSpec_e, 1, hTcxEnc->fUseTns_fx[0], ( st->last_core == ACELP_CORE ), 0 );
+ ProcessIGF_fx( st->hIGFEnc, st, spectrum, spectrum_e, powerSpec, &powerSpec_e, 1, hTcxEnc->fUseTns[0], ( st->last_core == ACELP_CORE ), 0 );
}
ShapeSpectrum_fx( hTcxCfg, A, gainlpc, gainlpc_e,
L_frame_glob,
L_spec,
spectrum,
- hTcxEnc->fUseTns_fx[0],
+ hTcxEnc->fUseTns[0],
st );
if ( st->igf )
{
@@ -2927,7 +2926,7 @@ void coder_tcx_fx(
tcxonly,
spectrum, spectrum_e,
hTcxEnc->tnsData,
- hTcxEnc->fUseTns_fx[0],
+ hTcxEnc->fUseTns[0],
tnsSize,
prm,
n,
diff --git a/lib_enc/cod_uv_fx.c b/lib_enc/cod_uv_fx.c
index bf20ecfd0d467de373c1764463f122307818071a..1af9e346388cb7ec4b3a2a0d65a4e4a65a65af32 100644
--- a/lib_enc/cod_uv_fx.c
+++ b/lib_enc/cod_uv_fx.c
@@ -7,8 +7,7 @@
#include
//#include "prot_fx.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
diff --git a/lib_enc/comvad_decision_fx.c b/lib_enc/comvad_decision_fx.c
index 2fa8069f8a8215a57c4995cf91345d18fd63461a..98816e768d91e0666a6fade90f54a9201054fa04 100644
--- a/lib_enc/comvad_decision_fx.c
+++ b/lib_enc/comvad_decision_fx.c
@@ -11,8 +11,7 @@
//#include "prot_fx.h"
#include "rom_enc.h" /* Encoder static table prototypes */
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
#include "prot_fx_enc.h"
diff --git a/lib_enc/cor_shif_fx.c b/lib_enc/cor_shif_fx.c
index 6645155ef2a7ab2e1664561ce60af7669e61678c..1120235052e6863cee83f1794f0cc5697929428a 100644
--- a/lib_enc/cor_shif_fx.c
+++ b/lib_enc/cor_shif_fx.c
@@ -5,8 +5,7 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
diff --git a/lib_enc/core_enc_2div_fx.c b/lib_enc/core_enc_2div_fx.c
index 37df43e37ab2174df9a189afa44b385fdf2a23bb..151561b091bea6801e7c95d3ddd5cc9bdfba53c4 100644
--- a/lib_enc/core_enc_2div_fx.c
+++ b/lib_enc/core_enc_2div_fx.c
@@ -11,8 +11,7 @@
//#include "prot_fx.h"
#include "basop_util.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
@@ -79,7 +78,7 @@ void core_encode_twodiv_fx(
FOR( i = 0; i < 3; i++ )
{
move16();
- T_op[i] = st->pitch_fx[i];
+ T_op[i] = st->pitch[i];
/* check minimum pitch for quantization */
IF( LT_16( T_op[i], PIT_MIN_SHORTER ) )
@@ -179,7 +178,7 @@ void core_encode_twodiv_fx(
shr( st->L_frame, 1 ),
shr( st->hTcxCfg->tcx_coded_lines, 1 ),
spectrum[n],
- hTcxEnc->fUseTns_fx[n],
+ hTcxEnc->fUseTns[n],
st );
st->last_core = st->core;
@@ -239,7 +238,7 @@ void core_encode_twodiv_fx(
spectrum[n],
&spectrum_e[n],
hTcxEnc->tnsData + n,
- hTcxEnc->fUseTns_fx[n],
+ hTcxEnc->fUseTns[n],
tnsSize[n],
param_core + n * NPRM_DIV,
n,
@@ -275,7 +274,7 @@ void core_encode_twodiv_fx(
st->L_frame,
st->hTcxCfg->tcx_coded_lines,
spectrum[0],
- hTcxEnc->fUseTns_fx[0],
+ hTcxEnc->fUseTns[0],
st );
/*_DIFF_FLOAT_FIX_ -> The line below is present in float */
@@ -315,7 +314,7 @@ void core_encode_twodiv_fx(
spectrum[0],
&spectrum_e[0],
&hTcxEnc->tnsData[0],
- hTcxEnc->fUseTns_fx[0],
+ hTcxEnc->fUseTns[0],
tnsSize[0],
param_core,
0,
diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c
index 74a0f62e67d3285d1ef2d86a4eb45bbe1ea77084..855ff8e89badccf2c5f5505c71770ff6019cc745 100644
--- a/lib_enc/core_enc_init.c
+++ b/lib_enc/core_enc_init.c
@@ -255,8 +255,17 @@ static void init_tcx(
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
/* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */
+#if 1
+ hTcxEnc->spectrum_fx[0] = hTcxEnc->spectrum_long_fx;
+ hTcxEnc->spectrum_fx[1] = hTcxEnc->spectrum_long_fx + N_TCX10_MAX;
+#endif
+
hTcxEnc->spectrum[0] = hTcxEnc->spectrum_long;
hTcxEnc->spectrum[1] = hTcxEnc->spectrum_long + N_TCX10_MAX;
+#ifdef IVAS_FLOAT_FIXED
+ hTcxEnc->spectrum_fx[0] = hTcxEnc->spectrum_long_fx;
+ hTcxEnc->spectrum_fx[1] = hTcxEnc->spectrum_long_fx + N_TCX10_MAX;
+#endif
init_tcx_cfg( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, st->fscale, st->encoderLookahead_enc, st->encoderLookahead_FB, st->preemph_fac_flt, st->tcxonly, st->rf_mode, st->igf, st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag );
@@ -267,7 +276,7 @@ static void init_tcx(
hTcxEnc->noiseLevelMemory_cnt = 0;
set_f( hTcxEnc->ltpGainMemory, 0.0f, N_LTP_GAIN_MEMS );
- set_s( hTcxEnc->memQuantZeros, 0, L_FRAME_PLUS );
+ set_c( hTcxEnc->memQuantZeros, 0, L_FRAME_PLUS );
/* TCX-LTP */
hTcxEnc->tcxltp = getTcxLtp( st->sr_core );
diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c
index 938997bd4b7a99bc9e3b5253adb4fb38ea477d2f..dba3ce8359a831ccb578177274becda38cd6a886 100644
--- a/lib_enc/core_enc_init_fx.c
+++ b/lib_enc/core_enc_init_fx.c
@@ -15,8 +15,7 @@
#include
#include "rom_com.h" /* Common constants */
#include "prot.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
@@ -341,7 +340,7 @@ static void init_tcx_fx(
FOR( i = 0; i < L_FRAME_PLUS; i++ )
{
- hTcxEnc->memQuantZeros_fx[i] = 0;
+ hTcxEnc->memQuantZeros[i] = 0;
move16();
}
diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c
index 4a7db5f6925bec3d5cfd7365e261052323d5ee81..9957ccdef4d3e7d169f40b5a4a3bf175ac09a424 100644
--- a/lib_enc/core_enc_ol_fx.c
+++ b/lib_enc/core_enc_ol_fx.c
@@ -10,8 +10,7 @@
#include "basop_util.h"
#include "rom_com_fx.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
@@ -430,7 +429,7 @@ void core_encode_openloop_fx(
/* Update ACELP quantizer state */
lsf_update_memory( st->narrowBand, st->lsf_old_fx, st->mem_MA_fx, st->mem_MA_fx, M );
- st->pstreaklen_fx = 0;
+ st->pstreaklen = 0;
st->streaklimit_fx = 32767;
/* check resonance for pitch clipping algorithm */
gp_clip_test_lsf_fx( st->element_mode, st->lsf_old_fx, st->clip_var_fx, 0 );
@@ -613,7 +612,7 @@ void core_encode_openloop_fx(
IF( NE_16( 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_fx,
+ coder_acelp_rf_fx( &( hRF->acelp_cfg_rf ), coder_type, Aw, Aq_rf, st->speech_enc_pe, st->voicing_fx, st->pitch,
stab_fac_rf, st, hRF->rf_target_bits, hRF->rf_frame_type, exc_rf, syn_rf, Q_new, shift );
}
}
@@ -660,7 +659,7 @@ void core_encode_openloop_fx(
&& ( EQ_16( hTcxEnc->tcxltp_pitch_int, hRF->rf_tcxltp_pitch_int_past ) ) /*&& (st->tcxltp_pitch_int == st->rf_tcxltp_pitch_int_past)*/
&& ( hRF->rf_last_tns_active == 0 ) /*!st->rf_last_tns_active*/
&& ( hRF->rf_second_last_tns_active == 0 ) /*!st->rf_second_last_tns_active*/
- && ( ( st->hTcxCfg->fIsTNSAllowed & hTcxEnc->fUseTns_fx[0] ) == 0 ) /*!(st->hTcxCfg->fIsTNSAllowed & st->fUseTns[0])*/
+ && ( ( st->hTcxCfg->fIsTNSAllowed & hTcxEnc->fUseTns[0] ) == 0 ) /*!(st->hTcxCfg->fIsTNSAllowed & st->fUseTns[0])*/
)
{
rf_PLC_Mode = 1;
@@ -699,7 +698,7 @@ void core_encode_openloop_fx(
move16();
hRF->rf_second_last_tns_active = hRF->rf_last_tns_active;
move16();
- hRF->rf_last_tns_active = ( st->hTcxCfg->fIsTNSAllowed & hTcxEnc->fUseTns_fx[0] );
+ hRF->rf_last_tns_active = ( st->hTcxCfg->fIsTNSAllowed & hTcxEnc->fUseTns[0] );
move16();
hRF->rf_second_last_core = st->last_core;
move16();
@@ -824,7 +823,7 @@ void core_acelp_tcx20_switching_fx(
/* Check minimum pitch for quantization */
FOR( i = 0; i < 3; i++ )
{
- tmp16 = st->pitch_fx[i];
+ tmp16 = st->pitch[i];
move16();
/* check minimum pitch for quantization */
if ( LT_16( tmp16, PIT_MIN_SHORTER ) )
@@ -839,12 +838,12 @@ void core_acelp_tcx20_switching_fx(
/*pitch[i] = (short)(pitch[i] * 1.25f + 0.5f);*/
tmp16 = add( tmp16, s );
}
- st->pitch_fx[i] = tmp16;
+ st->pitch[i] = tmp16;
move16();
}
IF( st->narrowBand != 0 )
{
- pitchDoubling_det_fx( st->wspeech_enc, st->pitch_fx, pitch_fr, voicing_fr );
+ pitchDoubling_det_fx( st->wspeech_enc, st->pitch, pitch_fr, voicing_fr );
}
E_LPC_f_lsp_a_conversion( lsp_mid, A_q_tcx, M );
@@ -860,7 +859,7 @@ void core_acelp_tcx20_switching_fx(
st->speech_enc + st->encoderLookahead_enc,
hTcxEnc->speech_ltp + st->encoderLookahead_enc,
st->wspeech_enc + st->encoderLookahead_enc,
- st->pitch_fx[1],
+ st->pitch[1],
hTcxEnc->tcxltp_param,
&hTcxEnc->tcxltp_bits,
&hTcxEnc->tcxltp_pitch_int,
diff --git a/lib_enc/core_enc_reconf.c b/lib_enc/core_enc_reconf.c
index 7eab3e742a9fad3bcc0da159ae4efac861f0ca67..67238f036306394659e80ce7c6c311ca3e89117b 100644
--- a/lib_enc/core_enc_reconf.c
+++ b/lib_enc/core_enc_reconf.c
@@ -223,13 +223,13 @@ void core_coder_reconfig(
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_s( hTcxEnc->memQuantZeros, 0, hTcxEnc->nmStartLine );
+ 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_s( hTcxEnc->memQuantZeros, 0, st->L_frame );
+ set_c( hTcxEnc->memQuantZeros, 0, st->L_frame );
}
}
}
diff --git a/lib_enc/core_enc_reconf_fx.c b/lib_enc/core_enc_reconf_fx.c
index 49631b17808cecb1a81945c1f1af753090493a29..c4e4b16cd6a9694998664d9b34fa9cd1802c6f00 100644
--- a/lib_enc/core_enc_reconf_fx.c
+++ b/lib_enc/core_enc_reconf_fx.c
@@ -9,8 +9,7 @@
#include "rom_com_fx.h"
#include "rom_enc.h" /* Encoder static table prototypes */
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
@@ -311,7 +310,7 @@ void core_coder_reconfig_fx(
/* low-freq memQuantZeros_fx must be reset partially if bitrate increased */
FOR( i = 0; i < hTcxEnc->nmStartLine; i++ )
{
- hTcxEnc->memQuantZeros_fx[i] = 0;
+ hTcxEnc->memQuantZeros[i] = 0;
move16();
}
}
@@ -319,7 +318,7 @@ void core_coder_reconfig_fx(
{
FOR( i = 0; i < st->L_frame; i++ ) /* memQuantZeros_fx won't be updated */
{
- hTcxEnc->memQuantZeros_fx[i] = 0;
+ hTcxEnc->memQuantZeros[i] = 0;
move16();
}
}
diff --git a/lib_enc/core_enc_switch_fx.c b/lib_enc/core_enc_switch_fx.c
index 0eede724a6cf61e01465ed7d318687c934694ae3..268bd58ac41688fb95ff719de1bd70fa71522808 100644
--- a/lib_enc/core_enc_switch_fx.c
+++ b/lib_enc/core_enc_switch_fx.c
@@ -11,8 +11,7 @@
#include "ivas_cnst.h"
#include "rom_com_fx.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
diff --git a/lib_enc/core_enc_updt_fx.c b/lib_enc/core_enc_updt_fx.c
index 9fa4f0ff3a53cb4d3d996d7b0215a182a88b7e48..bd6f5b5482e700c59c0be1cca2375df718a2e21f 100644
--- a/lib_enc/core_enc_updt_fx.c
+++ b/lib_enc/core_enc_updt_fx.c
@@ -8,8 +8,7 @@
#include "cnst.h" /* Common constants */
#include "basop_util.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c
index 457d93bd8d40d96d8473bd82d01daf8e6acdcb47..4494f01040b1e5e76d240eba091d7aaf690a2cbe 100644
--- a/lib_enc/core_switching_enc_fx.c
+++ b/lib_enc/core_switching_enc_fx.c
@@ -8,8 +8,7 @@
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c
index 698d14830dd4af944d4aed8ad83cf73171eaa4bd..86ba92c7a7c28d0cd2e92e551d1b6d195ab784c7 100644
--- a/lib_enc/corr_xh_fx.c
+++ b/lib_enc/corr_xh_fx.c
@@ -5,8 +5,7 @@
#include "options.h"
#include "cnst.h"
//#include "prot_fx.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
diff --git a/lib_enc/decision_matrix_enc_fx.c b/lib_enc/decision_matrix_enc_fx.c
index 5f0eaf0cd43c927ccc9dd676356657bc4b9504d6..922883ffc4b46ffb89a5e85986cf8a4f489b95ae 100644
--- a/lib_enc/decision_matrix_enc_fx.c
+++ b/lib_enc/decision_matrix_enc_fx.c
@@ -10,8 +10,7 @@
#include "stat_enc.h"
#include "rom_com_fx.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c
index 0d86e3aabecd436a0c3c62a8eb9614855d4af965..e21579cd0acce22f264bab94c352c0bb40480af5 100644
--- a/lib_enc/detect_transient_fx.c
+++ b/lib_enc/detect_transient_fx.c
@@ -37,8 +37,7 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*--------------------------------------------------------------------------*/
diff --git a/lib_enc/diffcod_fx.c b/lib_enc/diffcod_fx.c
index 5fd01046a8a462d16d2c4fd8ad2130cb72cf8aac..7ff48d81667335768cc737aa75033fd6b998d258 100644
--- a/lib_enc/diffcod_fx.c
+++ b/lib_enc/diffcod_fx.c
@@ -6,8 +6,7 @@
#include "cnst.h" /* Compilation switches */
#include "rom_com_fx.h" /* Static table prototypes */
//#include "prot_fx.h" /* Function Prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*--------------------------------------------------------------------------*/
diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c
index 2043d082f958035427f2ab5121333b7ec2dc1619..afc6fbe38c21d881a7a4d2600fe2e4c1dc11e412 100644
--- a/lib_enc/dtx_fx.c
+++ b/lib_enc/dtx_fx.c
@@ -4,14 +4,13 @@
#include
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
-//#include "prot_fx.h" /* Function prototypes */
#include "rom_com_fx.h"
#include "rom_com.h"
-//#include "basop_mpy.h"
+// #include "basop_mpy.h"
#include
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
+#include "prot.h"
/*-------------------------------------------------------------------*
* Local constants
@@ -34,6 +33,7 @@
/* _DIFF_FLOAT_FIX_ : lp_noise_fx threshold is different between float (15) and fix (5*256) */
#define LP_NOISE_LV 5 /* LP_NOISE level */
+
#define MAX_BRATE_DTX_EVS ACELP_24k40 /* maximum bitrate to which the default DTX is applied in EVS; otherwise DTX is applied only in silence */
#define MAX_BRATE_DTX_IVAS IVAS_64k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */
@@ -42,7 +42,511 @@
*-------------------------------------------------------------------*/
static void update_SID_cnt( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, const Word16 Opt_AMR_WB );
+/*==================================================================================*/
+/* FUNCTION : dtx_ivas_fx() */
+/*----------------------------------------------------------------------------------*/
+/* PURPOSE : Discontinuous transmission operation */
+/*----------------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Encoder_State_Fx) st_fx : encoder state structure */
+/* _ (Word16) vad : vad flag Q0 */
+/* _ (Word16[]) speech_fx : Pointer to the speech frame qSpeech */
+/* _ (Word16) qSpeech : speech buffer qformat value */
+/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */
+/*----------------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */
+/* _ (Encoder_State_Fx) st_fx : encoder state structure */
+/*----------------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*==================================================================================*/
+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 */
+
+)
+{
+ Word16 alpha;
+ Word32 L_tmp;
+ DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
+ TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
+
+ Word16 last_br_cng_flag, last_br_flag, br_dtx_flag;
+
+ IF( st_fx->dtx_sce_sba != 0 )
+ {
+ last_br_cng_flag = 1;
+ last_br_flag = 1;
+ br_dtx_flag = 1;
+ move16();
+ move16();
+ move16();
+ }
+ ELSE
+ {
+ /* _DIFF_FLOAT_FIX_ : lp_noise_fx threshold is different between float (15) and fix (5*256) */
+ last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, ACELP_32k ) );
+
+ last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) );
+ br_dtx_flag = 0;
+ move16();
+ }
+ /* Initialization */
+ IF( st_fx->ini_frame == 0 )
+ {
+ st_fx->active_fr_cnt_fx = CNG_TYPE_HO;
+ move16();
+
+ 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 ) )
+ {
+ st_fx->cng_type = LP_CNG;
+ move16();
+ }
+ }
+ test();
+ test();
+ IF( st_fx->Opt_DTX_ON && vad == 0 &&
+ GT_16( st_fx->ini_frame, 2 ) && /* CNG coding starts after 2 frames */
+ st_fx->fd_cng_reset_flag == 0 &&
+ NE_16( st_fx->last_core, AMR_WB_CORE ) &&
+ st_fx->Opt_AMR_WB == 0 )
+ {
+ test();
+ test();
+ test();
+ IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) &&
+ NE_32( st_fx->last_total_brate_cng, st_fx->total_brate ) && last_br_cng_flag )
+ {
+ 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 ) )
+ {
+ st_fx->Opt_SC_VBR = 0;
+ move16();
+ }
+ st_fx->rf_mode = st_fx->last_rf_mode_cng;
+ move16();
+ st_fx->bwidth = st_fx->last_bwidth_cng;
+ move16();
+ st_fx->codec_mode = st_fx->last_codec_mode_cng;
+ move16();
+ }
+ test();
+ test();
+ IF( LE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) && last_br_flag )
+
+ {
+ 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 ) )
+ {
+ st_fx->Opt_SC_VBR = 0;
+ move16();
+ }
+
+ st_fx->Opt_RF_ON = 0;
+ move16();
+ 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 ) )
+ {
+ st_fx->Opt_RF_ON = 1;
+ move16();
+ }
+ st_fx->rf_mode = st_fx->Opt_RF_ON;
+ move16();
+ st_fx->bwidth = st_fx->last_bwidth;
+ move32();
+ IF( GT_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ st_fx->codec_mode = MODE1;
+ move16();
+ }
+ ELSE
+ {
+ st_fx->codec_mode = get_codec_mode( st_fx->total_brate );
+ }
+ }
+ }
+
+ /*------------------------------------------------------------------------*
+ * Select SID or FRAME_NO_DATA frame if DTX is enabled
+ *------------------------------------------------------------------------*/
+ if ( st_fx->dtx_sce_sba == 0 )
+ {
+#if 0
+ br_dtx_flag = LE_32( st_fx->total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ||
+ EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st_fx->element_brate, IVAS_64k ) || LT_16( st_fx->lp_noise_fx, 15 * 256 ) ) );
+#else
+ br_dtx_flag = ( EQ_16( st_fx->element_mode, EVS_MONO ) && LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) ) ||
+ ( NE_16( st_fx->element_mode, EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ||
+ LT_16( st_fx->lp_noise_fx, shl( 15, Q8 ) );
+#endif
+ }
+ test();
+ test();
+ test();
+ test();
+ IF( st_fx->Opt_DTX_ON && vad == 0 &&
+ GT_16( st_fx->ini_frame, 2 ) && /* CNG coding starts after 2 frames */
+ br_dtx_flag &&
+ st_fx->fd_cng_reset_flag == 0 )
+ {
+ /* reset counter */
+ st_fx->active_fr_cnt_fx = 0;
+ move16();
+
+ IF( st_fx->Opt_AMR_WB )
+ {
+ st_fx->last_total_brate_cng = -1;
+ st_fx->last_rf_mode_cng = st_fx->rf_mode;
+ move16();
+ }
+ ELSE
+ {
+ 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;
+ }
+
+ IF( hDtxEnc->cnt_SID == 0 )
+ {
+ /* this will be a SID frame */
+ IF( st_fx->Opt_AMR_WB )
+ {
+ st_fx->core_brate = SID_1k75;
+ move32();
+ }
+ ELSE
+ {
+ st_fx->core_brate = SID_2k40;
+ move32();
+ }
+ }
+ ELSE
+ {
+ /* this will be a no data frame */
+ st_fx->core_brate = FRAME_NO_DATA;
+ move32();
+ }
+
+ 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 )
+ {
+ /* 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;
+ move32();
+ }
+ // PMT("dtx_sce_sba code is missing")
+ IF( ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->cng_type, FD_CNG ) ) && EQ_16( st_fx->dtx_sce_sba, 1 ) )
+ {
+ st_fx->cng_type = FD_CNG;
+ move16();
+ if ( EQ_16( 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();
+ }
+ }
+ ELSE
+ {
+ test();
+ 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 */
+ {
+ test();
+ test();
+ IF( EQ_16( 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();
+ }
+ }
+ ELSE
+ {
+ st_fx->cng_type = LP_CNG;
+ move16();
+ IF( st_fx->codec_mode == MODE2 )
+ {
+ hTdCngEnc->lp_cng_mode2 = 1;
+ move16();
+ }
+ st_fx->codec_mode = MODE1;
+ move16();
+ }
+ }
+ /* reset the bitstream (IVAS format signalling was already written) */
+ IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL )
+ {
+ reset_indices_enc( st_fx->hBstr, st_fx->hBstr->nb_ind_tot );
+ }
+ }
+
+ /*------------------------------------------------------------------------*
+ * Reset counters when in active frame (not in SID or FRAME_NO_DATA frame)
+ *------------------------------------------------------------------------*/
+ /* 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( hDtxEnc != NULL )
+ {
+ hDtxEnc->cnt_SID = 0;
+ move16();
+
+ /* change SID update rate */
+ /* first SID update is only 8 (3) frames after the active speech end */
+ IF( !st_fx->Opt_AMR_WB )
+ {
+ hDtxEnc->max_SID = FIXED_SID_RATE;
+ move16();
+ }
+ ELSE
+ {
+ hDtxEnc->max_SID = 3;
+ move16(); /* first SID update is only 3 frames after the active speech end */
+ }
+
+ IF( LT_16( hDtxEnc->interval_SID, hDtxEnc->max_SID ) )
+ {
+ hDtxEnc->max_SID = hDtxEnc->interval_SID;
+ move16(); /* change SID update rate */
+ }
+
+ hDtxEnc->cng_cnt = 0;
+ move16(); /* reset the counter of CNG frames for averaging */
+ }
+ test();
+ IF( GE_16( st_fx->active_fr_cnt_fx, CNG_TYPE_HO ) && st_fx->Opt_AMR_WB == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ {
+ IF( EQ_16( st_fx->element_mode, IVAS_SCE ) )
+ {
+ Word32 lp_thresh, fd_thresh;
+ // PMT( "lp_thresh scaling is to be found" )
+ test();
+ IF( st_fx->Opt_DTX_ON && EQ_16( st_fx->dtx_sce_sba, 1 ) )
+ {
+ lp_thresh = L_shl( 5, Q27 );
+ fd_thresh = L_shl( 2, Q27 );
+ }
+ ELSE
+
+ {
+ lp_thresh = L_shl( 10, Q27 );
+ fd_thresh = L_shl( 5, Q27 );
+ }
+
+ /*More conservative selection of LP-CNG for SCE*/
+ if ( st_fx->cng_type == LP_CNG && ( st_fx->bckr_tilt_lt > lp_thresh ) )
+ {
+ st_fx->cng_type = FD_CNG;
+ }
+ else if ( st_fx->cng_type == FD_CNG && ( st_fx->bckr_tilt_lt < fd_thresh ) && ( st_fx->lp_noise > L_shl( 2, Q27 ) ) )
+ {
+ st_fx->cng_type = LP_CNG;
+ }
+ }
+ ELSE
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( st_fx->cng_type, LP_CNG ) && ( ( EQ_16( st_fx->input_bwidth, NB ) && GT_32( st_fx->bckr_tilt_lt, 589824l /*9.f Q16*/ ) ) || ( GT_16( st_fx->input_bwidth, NB ) && GT_32( st_fx->bckr_tilt_lt, 2949120l /*45.f Q16*/ ) ) ) )
+ {
+ st_fx->cng_type = FD_CNG;
+ move16();
+ }
+ ELSE IF( EQ_16( st_fx->cng_type, FD_CNG ) && ( ( EQ_16( st_fx->input_bwidth, NB ) && LT_32( st_fx->bckr_tilt_lt, 131072l /*2.f Q16*/ ) ) || ( GT_16( st_fx->input_bwidth, NB ) && LT_32( st_fx->bckr_tilt_lt, 655360l /*10.f Q16*/ ) ) ) )
+ {
+ st_fx->cng_type = LP_CNG;
+ move16();
+ }
+ }
+ st_fx->last_total_brate_cng = -1;
+ }
+ ELSE IF( st_fx->Opt_AMR_WB )
+ {
+ st_fx->cng_type = LP_CNG;
+ move16();
+ }
+ st_fx->active_fr_cnt_fx = add( st_fx->active_fr_cnt_fx, 1 );
+ st_fx->active_fr_cnt_fx = s_min( st_fx->active_fr_cnt_fx, 200 );
+ }
+
+ /*------------------------------------------------------------------------*
+ * Update speech and background noise long-term energy
+ *------------------------------------------------------------------------*/
+ IF( hDtxEnc != NULL )
+ {
+ hDtxEnc->frame_ener_fx = L_deposit_l( 0 );
+
+ IF( st_fx->Opt_DTX_ON )
+ {
+#if 0
+ Q_speech2 = add( shl( Q_speech, 1 ), 7 );
+ FOR( j = 0; j < 16; j++ )
+ {
+ L_tmp = L_mult0( *speech, *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( L_tmp, *speech, *speech );
+#endif /* BASOP_NOGLOB */
+ speech++;
+ }
+ hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /*Q(-7) */
+
+ }
+#endif
+ // hDtxEnc->frame_ener = sum2_f( speech, L_FRAME );
+ Word16 guard_bits = find_guarded_bits_fx( L_FRAME );
+ // Word16 Q_frame_ener = 2 * Q_speech;
+ hDtxEnc->frame_ener_fx = sum2_f_16_gb_fx( speech, L_FRAME, guard_bits ); // 2*Q_speech-guard_bits
+
+ /* Active speech (voiced) */
+
+ IF( EQ_16( st_fx->clas, VOICED_CLAS ) )
+ {
+ alpha = ALPHA_ENER_SLOW_FX;
+ move16();
+ if ( GT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_voiced_fx ) )
+ {
+ alpha = ALPHA_ENER_FAST_FX;
+ move16(); /*Q15 */
+ }
+
+ /*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 ); /*2*Q_speech-guard_bits */
+
+ hDtxEnc->VarDTX_cnt_voiced = add( hDtxEnc->VarDTX_cnt_voiced, 1 );
+
+ hDtxEnc->VarDTX_cnt_voiced = s_min( hDtxEnc->VarDTX_cnt_voiced, MIN_CNT );
+ }
+ /* Background noise */
+ ELSE IF( !st_fx->Opt_AMR_WB )
+ {
+ alpha = ALPHA_ENER_SLOW_FX;
+ move16();
+ if ( LT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_noise_fx ) )
+ {
+ alpha = ALPHA_ENER_FAST_FX;
+ 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(); /*2*Q_speech-guard_bits */
+
+ hDtxEnc->VarDTX_cnt_noise = add( hDtxEnc->VarDTX_cnt_noise, 1 );
+
+ hDtxEnc->VarDTX_cnt_noise = s_min( hDtxEnc->VarDTX_cnt_noise, MIN_CNT );
+ }
+ }
+ }
+
+ /* Update of the SID counter */
+ update_SID_cnt( hDtxEnc, st_fx->core_brate, st_fx->Opt_AMR_WB );
+
+ /* Update encoded bandwidth */
+ test();
+ test();
+ IF( st_fx->Opt_DTX_ON && ( st_fx->core_brate == SID_2k40 || st_fx->core_brate == FRAME_NO_DATA ) )
+ {
+
+ 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 ) )
+ {
+ st_fx->bwidth = st_fx->last_bwidth_cng;
+ move16();
+ }
+
+ test();
+ test();
+ IF( st_fx->Opt_RF_ON && ( EQ_32( st_fx->total_brate, ACELP_13k20 ) ) && ( EQ_16( st_fx->bwidth, NB ) ) )
+ {
+ st_fx->codec_mode = MODE1;
+ move16();
+ reset_rf_indices_fx( st_fx );
+ st_fx->Opt_RF_ON = 0;
+ move16();
+ st_fx->rf_mode = 0;
+ move16();
+ }
+
+ test();
+ test();
+ IF( st_fx->Opt_RF_ON && NE_32( st_fx->total_brate, ACELP_13k20 ) )
+ {
+ reset_rf_indices_fx( st_fx );
+ move16();
+ st_fx->Opt_RF_ON = 0;
+ move16();
+ st_fx->rf_mode = 0;
+ }
+
+ /* Set and limit the encoded bandwidth */
+ IF( EQ_16( st_fx->codec_mode, MODE2 ) )
+ {
+ Word16 n, bits_frame_nominal;
+
+ UWord16 lsb;
+ Word16 tmpbandwidthMin;
+
+ Mpy_32_16_ss( st_fx->total_brate, 5243, &L_tmp, &lsb ); /* 5243 is 1/50 in Q18. (0+18-15=3) */
+ bits_frame_nominal = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */
+
+ FOR( n = 0; n < FRAME_SIZE_NB; n++ )
+ {
+ IF( EQ_16( FrameSizeConfig[n].frame_bits, bits_frame_nominal ) )
+ {
+ BREAK;
+ }
+ }
+ if ( n == FRAME_SIZE_NB )
+ {
+ assert( !"Bitrate not supported: not part of EVS" );
+ }
+ tmpbandwidthMin = FrameSizeConfig[n].bandwidth_min;
+ if ( EQ_16( st_fx->rf_mode, 1 ) )
+ {
+ tmpbandwidthMin = WB;
+ }
+ st_fx->bwidth = s_max( s_min( st_fx->bwidth, FrameSizeConfig[n].bandwidth_max ), tmpbandwidthMin );
+ }
+ }
+
+ return;
+}
/*==================================================================================*/
/* FUNCTION : dtx_fx() */
diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c
index b8aacc9982b3cf6430fe9286c812bb16140bd6b9..a601728279d581792ef508ec6de55c86d601b63e 100644
--- a/lib_enc/enc_acelp_fx.c
+++ b/lib_enc/enc_acelp_fx.c
@@ -12,8 +12,7 @@
#include "rom_com_fx.h"
#include "rom_com.h"
#include "rom_enc.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
diff --git a/lib_enc/enc_acelp_tcx_main_fx.c b/lib_enc/enc_acelp_tcx_main_fx.c
index 0688f731132085b7655f9c11539cf3d28fda72de..0ee3c51856af219d536d57f65af0ff536d9fa766 100644
--- a/lib_enc/enc_acelp_tcx_main_fx.c
+++ b/lib_enc/enc_acelp_tcx_main_fx.c
@@ -7,8 +7,7 @@
//#include "prot_fx.h"
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c
index b24bcd066bf9250d5e6e8fa74da46e10d76f0e67..cac1c81edd1f42f47732c45a6ee66f5c2061200d 100644
--- a/lib_enc/enc_acelpx_fx.c
+++ b/lib_enc/enc_acelpx_fx.c
@@ -8,8 +8,7 @@
#include "basop_util.h"
#include "options.h"
#include "rom_enc.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*--------------------------------------------------------------------------------------*
diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c
index 492dd620dec27b40671ed1f7642b6f70a24221b1..5d5ee6c48af075fa34ded5aadf29b936f275607e 100644
--- a/lib_enc/enc_amr_wb_fx.c
+++ b/lib_enc/enc_amr_wb_fx.c
@@ -7,8 +7,7 @@
//#include "prot_fx.h" /* Function prototypes */
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
@@ -90,7 +89,7 @@ void encod_amr_wb_fx(
pt_pitch = pitch_buf;
shift_wsp = add( Q_new, shift );
- Copy( st->pitch_fx, T_op, 2 );
+ Copy( st->pitch, T_op, 2 );
if ( LE_16( T_op[0], PIT_MIN ) )
{
T_op[0] = shl( T_op[0], 1 );
diff --git a/lib_enc/enc_gain_fx.c b/lib_enc/enc_gain_fx.c
index 8cd87ad1038660cd250d60c41abde351c4c2bba0..3bf3db1aa705c07972ac8d67bb437604ce668cdb 100644
--- a/lib_enc/enc_gain_fx.c
+++ b/lib_enc/enc_gain_fx.c
@@ -11,8 +11,7 @@
#include "rom_com.h"
#include "rom_enc.h"
#include "basop_util.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#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 );
diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c
index 1b9823e7320deb8eae7c3df67adaf7a9ab5e6f6a..8b7d12fba23ed41a6c85162c0459da449bffc0cd 100644
--- a/lib_enc/enc_gen_voic_fx.c
+++ b/lib_enc/enc_gen_voic_fx.c
@@ -7,8 +7,7 @@
//#include "prot_fx.h" /* Function prototypes */
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
@@ -200,7 +199,7 @@ void encod_gen_voic_fx(
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_fx, &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 );
tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx );
diff --git a/lib_enc/enc_gen_voic_rf.c b/lib_enc/enc_gen_voic_rf.c
index ae4458960f4be4807d15335a2e319d749a3c707c..7c38a433dbf59f39d705f1fcd026970252dc57dc 100644
--- a/lib_enc/enc_gen_voic_rf.c
+++ b/lib_enc/enc_gen_voic_rf.c
@@ -40,7 +40,7 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
* reset_rf_indices()
diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c
index c60767394e538c16d247d2fcfa6b12cc6d1daab7..a4d506291546539e6790ade2018ec2cacb862d50 100644
--- a/lib_enc/enc_gen_voic_rf_fx.c
+++ b/lib_enc/enc_gen_voic_rf_fx.c
@@ -11,8 +11,7 @@
#include "rom_basop_util.h"
//#include "basop_mpy.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c
index a67071533f4bb35a8ac16e624e864906431d4696..59e2a359e0009de2e98cb776d8c363d26fb43138 100644
--- a/lib_enc/enc_higher_acelp_fx.c
+++ b/lib_enc/enc_higher_acelp_fx.c
@@ -7,8 +7,7 @@
//#include "prot_fx.h" /* Function prototypes */
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "prot_fx_enc.h"
/*---------------------------------------------------------------------*
diff --git a/lib_enc/enc_nelp_fx.c b/lib_enc/enc_nelp_fx.c
index bca4d2a772d9ae6c34cc4f2c007a0f302c2e2e3a..4be45c7e9d7ca2dce71cc0f1ea4620d6df486c69 100644
--- a/lib_enc/enc_nelp_fx.c
+++ b/lib_enc/enc_nelp_fx.c
@@ -7,8 +7,7 @@
#include "cnst.h" /* Common constants */
//#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h"
diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c
index f8d6eb8a4e0e08a6c488a398f508f44a20a8c018..6385420fe81a161f1a934be3fe2cf9a131ddb0c0 100644
--- a/lib_enc/enc_pit_exc_fx.c
+++ b/lib_enc/enc_pit_exc_fx.c
@@ -7,8 +7,7 @@
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*======================================================================*/
@@ -266,7 +265,7 @@ void enc_pit_exc_fx(
* 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_fx, &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 );
/*-----------------------------------------------------------------*
* Find adaptive exitation
*-----------------------------------------------------------------*/
diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c
index 31cdc0a5c993f09dbe5fb11fc9906d3bcc3edd60..1070bcc49fbe43cab4cfecad8f46ef24462e5fd1 100644
--- a/lib_enc/enc_ppp_fx.c
+++ b/lib_enc/enc_ppp_fx.c
@@ -6,8 +6,7 @@
#include "cnst.h" /* Common constants */
//#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
@@ -126,7 +125,7 @@ ivas_error encod_ppp_fx(
/* last frame-end lpc and curr frame-end lpc */
IF( ( error = ppp_voiced_encoder_fx( hBstr, hSC_VBR, st_fx->bwidth, st_fx->last_coder_type_raw, st_fx->old_pitch_buf_fx, res_fx,
- excQ_ppp_fx, st_fx->pitch_fx[1], LPC_de_old_fx, LPC_de_curr_fx, exc_fx, pitch_fx, Q_new ) ) != IVAS_ERR_OK )
+ excQ_ppp_fx, st_fx->pitch[1], LPC_de_old_fx, LPC_de_curr_fx, exc_fx, pitch_fx, Q_new ) ) != IVAS_ERR_OK )
{
return error;
}
diff --git a/lib_enc/enc_prm.c b/lib_enc/enc_prm.c
index d3c52faec12fd4a9189edf4cbecbd37f93af48be..7c58087d982bfd70386641a6141d4185fc129c4b 100644
--- a/lib_enc/enc_prm.c
+++ b/lib_enc/enc_prm.c
@@ -49,6 +49,159 @@
* write TCX mode
*--------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+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 */
+)
+{
+ UWord16 index;
+ Word16 idx, start_idx;
+ Word16 nBits;
+
+ IF( st->tcxonly )
+ {
+ push_next_indice( hBstr, (UWord16) EQ_16( st->core, TCX_10_CORE ), 1 );
+
+ test();
+ IF( EQ_16( st->clas, UNVOICED_CLAS ) )
+ {
+ index = 0;
+ move16();
+ }
+ ELSE IF( EQ_16( st->clas, VOICED_TRANSITION ) || EQ_16( st->clas, UNVOICED_TRANSITION ) )
+ {
+ index = 1;
+ move16();
+ }
+ ELSE IF( EQ_16( st->clas, VOICED_CLAS ) )
+ {
+ index = 2;
+ move16();
+ }
+ ELSE
+ {
+ index = 3;
+ move16();
+ }
+
+ push_next_indice( hBstr, index, 2 );
+
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag )
+ {
+ push_next_indice( hBstr, st->vad_flag, 1 );
+ }
+ }
+ ELSE
+ {
+ IF( EQ_16( st->core, ACELP_CORE ) )
+ {
+ /* write the RF signaling information */
+ IF( EQ_16( st->rf_mode, 1 ) )
+ {
+ /* find the section in the ACELP signaling table corresponding to bitrate */
+ idx = 0;
+ move16();
+ WHILE( NE_32( acelp_sig_tbl[idx], st->total_brate ) ) /* total bitrate is kept at 13.2kbps */
+ {
+ idx = add( idx, 1 );
+ }
+
+ /* retrieve the number of bits for signaling */
+ idx = add( idx, 1 );
+ nBits = extract_l( acelp_sig_tbl[idx] );
+
+ /* retrieve the signaling index */
+ idx = add( idx, 1 );
+ start_idx = idx;
+ move16();
+ WHILE( NE_32( acelp_sig_tbl[idx], SIG2IND( st->coder_type, st->bwidth, st->sharpFlag, st->rf_mode ) ) )
+ {
+ idx = add( idx, 1 );
+ }
+ push_next_indice( hBstr, sub( idx, start_idx ), nBits );
+ push_next_indice( hBstr, 0, 1 ); /* Indicate to the decoder that the core is ACELP*/
+ *nbits_start = 3;
+ move16();
+ }
+ ELSE
+ {
+ push_next_indice( hBstr, st->coder_type, 3 );
+ }
+ }
+ ELSE
+ {
+ IF( EQ_16( st->mdct_sw, MODE1 ) )
+ {
+ /* 2 bits instead of 3 as TCX is already signaled */
+ push_next_indice( hBstr, st->hTcxCfg->coder_type, 2 );
+ }
+ ELSE
+ {
+ IF( EQ_16( st->mdct_sw_enable, MODE2 ) )
+ {
+ push_next_indice( hBstr, 1, 1 ); /* TCX */
+ push_next_indice( hBstr, 0, 1 ); /* not HQ_CORE */
+ push_next_indice( hBstr, st->hTcxCfg->coder_type, 2 );
+ }
+ ELSE
+ {
+ /*write the RF signaling information*/
+ IF( EQ_16( st->rf_mode, 1 ) )
+ {
+ /* find the section in the ACELP signaling table corresponding to bitrate */
+ idx = 0;
+ move16();
+ WHILE( NE_32( acelp_sig_tbl[idx], st->total_brate ) )
+ {
+ idx = add( idx, 1 );
+ }
+
+ /* retrieve the number of bits for signaling */
+ idx = add( idx, 1 );
+ nBits = extract_l( acelp_sig_tbl[idx] );
+
+ test();
+ test();
+ IF( EQ_16( st->hTcxCfg->coder_type, VOICED ) || EQ_16( st->hTcxCfg->coder_type, GENERIC ) || EQ_16( st->hTcxCfg->coder_type, TRANSITION ) )
+ {
+ st->sharpFlag = 1;
+ move16();
+ }
+ ELSE
+ {
+ st->sharpFlag = 0;
+ move16();
+ }
+
+ /* retrieve the signaling index */
+ idx = add( idx, 1 );
+ start_idx = idx;
+ move16();
+ WHILE( NE_32( acelp_sig_tbl[idx], SIG2IND( st->hTcxCfg->coder_type, st->bwidth, st->sharpFlag, st->rf_mode ) ) )
+ {
+ idx = add( idx, 1 );
+ }
+ push_next_indice( hBstr, sub( idx, start_idx ), nBits );
+ push_next_indice( hBstr, 1, 1 ); /* Indicate to the decoder that the core is TCX*/
+ *nbits_start = 3;
+ move16();
+ }
+ ELSE
+ {
+ push_next_indice( hBstr, add( ACELP_MODE_MAX, st->hTcxCfg->coder_type ), 3 );
+ }
+ }
+ }
+ }
+ }
+
+ return;
+}
+#else
void writeTCXMode(
Encoder_State *st, /* i/o: encoder state structure */
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
@@ -180,6 +333,7 @@ void writeTCXMode(
return;
}
+#endif
/*-------------------------------------------------------------------*
@@ -188,6 +342,29 @@ void writeTCXMode(
* write TCX transform type
*-------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+void writeTCXWindowing(
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ const Word16 overlap_mode /* i : overlap mode */
+)
+{
+
+ IF( EQ_16( overlap_mode, MIN_OVERLAP ) )
+ {
+ push_next_indice( hBstr, 2, 2 );
+ }
+ ELSE IF( EQ_16( overlap_mode, HALF_OVERLAP ) )
+ {
+ push_next_indice( hBstr, 3, 2 );
+ }
+ ELSE
+ {
+ push_next_indice( hBstr, 0, 1 );
+ }
+
+ return;
+}
+#else
void writeTCXWindowing(
BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
const int16_t overlap_mode /* i : overlap mode */
@@ -209,6 +386,7 @@ void writeTCXWindowing(
return;
}
+#endif
/*-------------------------------------------------------------------*
diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c
index 93b4698fc45eab10263473af9848a73e42b6f1ed..f59fdf08f3b96ee1a2136183fb6f6911e167d742 100644
--- a/lib_enc/enc_prm_fx.c
+++ b/lib_enc/enc_prm_fx.c
@@ -12,8 +12,7 @@
#include "rom_com.h"
#include "stl.h"
//#include "prot_fx.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
@@ -301,7 +300,7 @@ void enc_prm_fx(
move16();
move16();
j = 0;
- nbits_start = hBstr->nb_bits_tot_fx;
+ nbits_start = hBstr->nb_bits_tot;
/*--------------------------------------------------------------------------------*
@@ -514,7 +513,7 @@ void enc_prm_fx(
st->glr_reset = 0;
move16();
- nbits_header = sub( hBstr->nb_bits_tot_fx, nbits_start );
+ nbits_header = sub( hBstr->nb_bits_tot, nbits_start );
/*--------------------------------------------------------------------------------*
@@ -744,7 +743,7 @@ void enc_prm_fx(
IGFEncWriteBitstream_fx( st->hIGFEnc, hBstr, &st->hIGFEnc->infoTotalBitsPerFrameWritten, IGF_GRID_LB_NORM, 1 );
}
}
- total_nbbits = sub( hBstr->nb_bits_tot_fx, nbits_start );
+ total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
if ( EQ_16( st->rf_mode, 1 ) )
{
total_nbbits = add( total_nbbits, st->rf_target_bits_write );
@@ -798,7 +797,7 @@ void enc_prm_fx(
j = 0;
move16();
- nbits_tcx = total_nbbits = sub( hBstr->nb_bits_tot_fx, nbits_start );
+ nbits_tcx = total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
test();
IF( st->enablePlcWaveadjust && k )
@@ -878,7 +877,7 @@ void enc_prm_fx(
}
j = add( j, NPRM_CTX_HM );
- total_nbbits = sub( hBstr->nb_bits_tot_fx, nbits_start );
+ total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
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 ) );
@@ -903,7 +902,7 @@ void enc_prm_fx(
*--------------------------------------------------------------------------------*/
- total_nbbits = sub( hBstr->nb_bits_tot_fx, nbits_start );
+ total_nbbits = sub( hBstr->nb_bits_tot, nbits_start );
/* Check if total encoded bits does not exceed CBR target bits (->this must never happen) */
diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c
index a0a9ff9021f03f4780bd59d0bdeb0f1da3c25a45..d3127ccda1e79619dae577f0381a8fff783ef81b 100644
--- a/lib_enc/enc_tran_fx.c
+++ b/lib_enc/enc_tran_fx.c
@@ -7,8 +7,7 @@
//#include "prot_fx.h" /* Function prototypes */
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*=================================================================================*/
diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c
index c67a5781e7cef9d19972fe81009a0171e68044d5..981d02a868bfe60a1a220de6e22de478ff260342 100644
--- a/lib_enc/enc_uv_fx.c
+++ b/lib_enc/enc_uv_fx.c
@@ -7,8 +7,7 @@
#include "cnst.h" /* Common constants */
//#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c
index f14e0b407ae8430d009ff205bf3abd344bb2e1b3..4bd16df2e21b8f85a1bf87ca66e6e568b0ef80fd 100644
--- a/lib_enc/energy_fx.c
+++ b/lib_enc/energy_fx.c
@@ -9,8 +9,7 @@
#include "rom_enc.h"
#include "vad_basop.h"
//#include "prot_fx.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
* est_energy_fx()
diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c
index 308f3ec4eedc354821a95790f03e29a1057e6d93..f1cc5460619b07d9c50026ef6388f2a21bcbb1a1 100644
--- a/lib_enc/eval_pit_contr_fx.c
+++ b/lib_enc/eval_pit_contr_fx.c
@@ -7,8 +7,7 @@
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
@@ -382,10 +381,10 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
FOR( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ )
{
#ifndef IVAS_CODE_BITSTREAM
- IF( hBstr->ind_list_fx[i].nb_bits != -1 )
+ IF( hBstr->ind_list[i].nb_bits != -1 )
{
- hBstr->nb_bits_tot_fx = sub( hBstr->nb_bits_tot_fx, hBstr->ind_list_fx[i].nb_bits );
- hBstr->ind_list_fx[i].nb_bits = -1;
+ hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[i].nb_bits );
+ hBstr->ind_list[i].nb_bits = -1;
move16();
}
#else
@@ -394,10 +393,10 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit
}
#ifndef IVAS_CODE_BITSTREAM
- IF( hBstr->ind_list_fx[IND_ES_PRED].nb_bits != -1 )
+ IF( hBstr->ind_list[IND_ES_PRED].nb_bits != -1 )
{
- hBstr->nb_bits_tot_fx = sub( hBstr->nb_bits_tot_fx, hBstr->ind_list_fx[IND_ES_PRED].nb_bits );
- hBstr->ind_list_fx[IND_ES_PRED].nb_bits = -1;
+ hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_ES_PRED].nb_bits );
+ hBstr->ind_list[IND_ES_PRED].nb_bits = -1;
move16();
}
#else
diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c
index 0032784cd0d1072abb329c8fed155a7ce3c8d277..27d4b96e3f247fa8fa26792f29f8d4ec3dfe8a66 100644
--- a/lib_enc/evs_enc_fx.c
+++ b/lib_enc/evs_enc_fx.c
@@ -7,8 +7,7 @@
#include "prot.h"
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
#include "prot_fx_enc.h"
@@ -301,7 +300,7 @@ ivas_error evs_enc_fx(
#ifndef FIX_I4_OL_PITCH
IF( EQ_16( st->core, HQ_CORE ) )
{
- Copy( pitch_orig, st->pitch_fx, 3 ); /* original open-loop pitch values might be altered in core_acelp_tcx20_switching_fx() */
+ Copy( pitch_orig, st->pitch, 3 ); /* original open-loop pitch values might be altered in core_acelp_tcx20_switching_fx() */
}
#endif
}
@@ -328,7 +327,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_fx, 3 ); /* populate the original OL pitch values back */
+ Copy( pitch_orig, st->pitch, 3 ); /* populate the original OL pitch values back */
#endif
/*---------------------------------------------------------------------*
@@ -410,13 +409,13 @@ ivas_error evs_enc_fx(
{
/* 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_fx ), tmp );
+ padBits = sub( sub( shl( shr( add( st->bits_frame, 7 ), 3 ), 3 ), hBstr->nb_bits_tot ), tmp );
}
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_fx, tmp ) );
+ padBits = sub( shl( shr( add( st->bits_frame, 7 ), 3 ), 3 ), add( hBstr->nb_bits_tot, tmp ) );
}
FOR( i = 0; i < padBits; i++ )
diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c
index a24b15f881f3309eb25dcf99a7397e8b0767376b..e8db91a74f2ee8e38ad45f8c92b35eeb19ecaf46 100644
--- a/lib_enc/ext_sig_ana_fx.c
+++ b/lib_enc/ext_sig_ana_fx.c
@@ -9,8 +9,7 @@
//#include "prot_fx.h"
#include "rom_com.h"
#include "basop_util.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
@@ -175,9 +174,9 @@ void core_signal_analysis_high_bitrate_fx(
{
lsp[0] = lsp_new;
lsp[1] = lsp_mid;
- alw_pitch_lag_12k8[0] = st->pitch_fx[0];
+ alw_pitch_lag_12k8[0] = st->pitch[0];
move16();
- alw_pitch_lag_12k8[1] = st->pitch_fx[1];
+ alw_pitch_lag_12k8[1] = st->pitch[1];
move16();
alw_voicing[0] = st->voicing_fx[0];
move16();
@@ -561,7 +560,7 @@ void core_signal_analysis_high_bitrate_fx(
TNSAnalysis_fx( st->hTcxCfg, L_frameTCX,
st->hTcxCfg->tcx_coded_lines,
transform_type[frameno], ( frameno == 0 ) && ( st->last_core == ACELP_CORE ),
- spectrum[frameno], &hTcxEnc->tnsData[frameno], &hTcxEnc->fUseTns_fx[frameno], NULL );
+ spectrum[frameno], &hTcxEnc->tnsData[frameno], &hTcxEnc->fUseTns[frameno], NULL );
#ifdef IVAS_CODE
IF( st->hTcxCfg->fIsTNSAllowed )
#endif
@@ -608,7 +607,7 @@ void core_signal_analysis_high_bitrate_fx(
}
IF( st->igf )
{
- ProcessIGF_fx( st->hIGFEnc, st, spectrum[frameno], &( spectrum_e[frameno] ), powerSpec, &powerSpec_e, transform_type[frameno] == TCX_20, hTcxEnc->fUseTns_fx[frameno], ( st->last_core == ACELP_CORE ), frameno );
+ ProcessIGF_fx( st->hIGFEnc, st, spectrum[frameno], &( spectrum_e[frameno] ), powerSpec, &powerSpec_e, transform_type[frameno] == TCX_20, hTcxEnc->fUseTns[frameno], ( st->last_core == ACELP_CORE ), frameno );
}
/* Copy memory */
diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c
index fad93012f130ac1cbcbb79d506166f1c0ef56394..38803594fbbff31f413528e27f94f77be9fa3458 100644
--- a/lib_enc/fd_cng_enc.c
+++ b/lib_enc/fd_cng_enc.c
@@ -41,7 +41,9 @@
#include "rom_enc.h"
#include "rom_com.h"
#include "prot.h"
+#include "prot_fx.h"
#include "ivas_prot.h"
+#include "ivas_prot_fx.h"
#include "stat_enc.h"
#include "wmc_auto.h"
@@ -1036,7 +1038,19 @@ void FdCngEncodeMDCTStereoSID(
/* M/S transform on log envelopes */
if ( is_inp_ms == 0 )
{
+#ifndef IVAS_FLOAT_FIXED
convertToMS( N, ms_ptr[0], ms_ptr[1], 0.5f );
+#else
+ Word32 ms_ptr_fx[2][NPART];
+ Word16 q = s_min( Q_factor_arrL( ms_ptr[0], N ), Q_factor_arrL( ms_ptr[1], N ) ) - 1;
+ floatToFixed_arrL( ms_ptr[0], ms_ptr_fx[0], q, N );
+ floatToFixed_arrL( ms_ptr[1], ms_ptr_fx[1], q, N );
+
+ convertToMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q30 );
+
+ fixedToFloat_arrL( ms_ptr_fx[0], ms_ptr[0], q, N );
+ fixedToFloat_arrL( ms_ptr_fx[1], ms_ptr[1], q, N );
+#endif
}
side_energy = sum2_f( ms_ptr[1], N );
@@ -1125,7 +1139,19 @@ void FdCngEncodeMDCTStereoSID(
/* undo M/S */
if ( is_inp_ms == 0 )
{
+#ifndef IVAS_FLOAT_FIXED
convertToMS( N, ms_ptr[0], ms_ptr[1], 1.0f );
+#else
+ Word32 ms_ptr_fx[2][NPART];
+ Word16 q = s_min( Q_factor_arrL( ms_ptr[0], N ), Q_factor_arrL( ms_ptr[1], N ) ) - 1;
+ floatToFixed_arrL( ms_ptr[0], ms_ptr_fx[0], q, N );
+ floatToFixed_arrL( ms_ptr[1], ms_ptr_fx[1], q, N );
+
+ convertToMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 );
+
+ fixedToFloat_arrL( ms_ptr_fx[0], ms_ptr[0], q, N );
+ fixedToFloat_arrL( ms_ptr_fx[1], ms_ptr[1], q, N );
+#endif
}
/* Compute gain against original left and right channels */
@@ -1260,7 +1286,19 @@ void FdCngEncodeDiracMDCTStereoSID(
}
/* M/S transform on log envelopes */
+#ifndef IVAS_FLOAT_FIXED
convertToMS( N[0], ms_ptr[0], ms_ptr[1], 0.5f );
+#else
+ Word32 ms_ptr_fx[2][NPART];
+ Word16 q = s_min( Q_factor_arrL( ms_ptr[0], N[0] ), Q_factor_arrL( ms_ptr[1], N[0] ) ) - 1;
+ floatToFixed_arrL( ms_ptr[0], ms_ptr_fx[0], q, N[0] );
+ floatToFixed_arrL( ms_ptr[1], ms_ptr_fx[1], q, N[0] );
+
+ convertToMS_fx( N[0], ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q30 );
+
+ fixedToFloat_arrL( ms_ptr_fx[0], ms_ptr[0], q, N[0] );
+ fixedToFloat_arrL( ms_ptr_fx[1], ms_ptr[1], q, N[0] );
+#endif
E[0] = sum_f( ms_ptr[0], N[0] );
@@ -1309,7 +1347,18 @@ void FdCngEncodeDiracMDCTStereoSID(
gain[1] = gain[0];
/* undo M/S */
+#ifndef IVAS_FLOAT_FIXED
convertToMS( NPART, ms_ptr[0], ms_ptr[1], 1.0f );
+#else
+ q = s_min( Q_factor_arrL( ms_ptr[0], NPART ), Q_factor_arrL( ms_ptr[1], NPART ) ) - 1;
+ floatToFixed_arrL( ms_ptr[0], ms_ptr_fx[0], q, NPART );
+ floatToFixed_arrL( ms_ptr[1], ms_ptr_fx[1], q, NPART );
+
+ convertToMS_fx( NPART, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 );
+
+ fixedToFloat_arrL( ms_ptr_fx[0], ms_ptr[0], q, NPART );
+ fixedToFloat_arrL( ms_ptr_fx[1], ms_ptr[1], q, NPART );
+#endif
/* restore channel noise envelopes */
for ( ch = 0; ch < CPE_CHANNELS; ch++ )
diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c
index 410cec20268f1fd2f96e62991231942f8dc75e8b..33f693d4b0ea22a9d2ea1f7e1e3c71582d9a1afc 100644
--- a/lib_enc/fd_cng_enc_fx.c
+++ b/lib_enc/fd_cng_enc_fx.c
@@ -12,8 +12,7 @@
#include "rom_com.h"
#include "rom_enc.h"
//#include "prot_fx.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "prot_fx_enc.h"
#include "basop_util.h"
#include "rom_basop_util.h"
diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c
index 14de5fe44c22a797af3d524c23158649469ee925..1fb28ca9752e1f632da001ddde6abae13863cd33 100644
--- a/lib_enc/find_tar_fx.c
+++ b/lib_enc/find_tar_fx.c
@@ -4,8 +4,7 @@
#include
#include "options.h" /* Compilation switches */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "cnst.h" /* Common constants */
#include "basop_util.h"
diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c
index 11106323e07568151398a0b2c69e28ca00bc91ed..f0c39eee21dafe9fe30de6bee54dbdd2d4a6854c 100644
--- a/lib_enc/find_tilt_fx.c
+++ b/lib_enc/find_tilt_fx.c
@@ -5,8 +5,7 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h"
diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c
index dbe7714c96f22fe2268938044bb2eea1b4cf5c7c..ec934ad9c5ee93bac3e3c267bf815d480831d0c6 100644
--- a/lib_enc/find_uv_fx.c
+++ b/lib_enc/find_uv_fx.c
@@ -6,8 +6,7 @@
#include "cnst.h" /* Common constants */
//#include "prot_fx.h" /* Function prototypes */
#include "rom_com.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
diff --git a/lib_enc/find_wsp.c b/lib_enc/find_wsp.c
index d38fd99d8dc2a254cdfc47249842ae50ac5d6cf2..97df5db897a0ec12625d376e68a48b5cd4fb4554 100644
--- a/lib_enc/find_wsp.c
+++ b/lib_enc/find_wsp.c
@@ -39,13 +39,12 @@
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
-
+#include "prot_fx.h"
/*-------------------------------------------------------------------*
* find_wsp()
*
* Compute weighted speech used in open-loop pitch search
*-------------------------------------------------------------------*/
-
void find_wsp(
const int16_t L_frame, /* i : length of the frame */
const int16_t L_subfr, /* i : length of subframe */
@@ -93,3 +92,47 @@ void find_wsp(
return;
}
+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 */
+)
+{
+ Word16 *p_Aw_fx, tmp_fx;
+ Word16 i_subfr;
+
+
+ /*-----------------------------------------------------------------*
+ * Compute weighted A(z) unquantized for subframes
+ *-----------------------------------------------------------------*/
+ weight_a_subfr_fx( nb_subfr, A_fx, Aw_fx, gamma, M );
+
+ /*-----------------------------------------------------------------*
+ * Compute weighted speech for all subframes
+ *-----------------------------------------------------------------*/
+ p_Aw_fx = Aw_fx;
+ 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 );
+ }
+ p_Aw_fx -= ( M + 1 );
+
+ /*-----------------------------------------------------------------*
+ * Weighted speech computation is extended on look-ahead
+ *-----------------------------------------------------------------*/
+
+ deemph_fx( wsp_fx, tilt_fact, L_frame, mem_wsp_fx );
+ Residu3_fx( p_Aw_fx, &speech_fx[L_frame], &wsp_fx[L_frame], L_look, 0 );
+ tmp_fx = *mem_wsp_fx;
+ deemph_fx( &wsp_fx[L_frame], tilt_fact, L_look, &tmp_fx );
+ return;
+}
diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c
index 21be0073b0ab8b58cd9c9e819f7cb9cc82674491..de81f19214e626801376295422c993120a79672c 100644
--- a/lib_enc/find_wsp_fx.c
+++ b/lib_enc/find_wsp_fx.c
@@ -7,8 +7,7 @@
#include "options.h"
#include "cnst.h"
//#include "prot_fx.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
diff --git a/lib_enc/frame_spec_dif_cor_rate_fx.c b/lib_enc/frame_spec_dif_cor_rate_fx.c
index fb0930579bec9e9de0543202c3904b17363e23e1..c7fa5eb1cab5d0ca8b4c15038cb232529d6ffc05 100644
--- a/lib_enc/frame_spec_dif_cor_rate_fx.c
+++ b/lib_enc/frame_spec_dif_cor_rate_fx.c
@@ -10,8 +10,7 @@
#include "vad_basop.h"
//#include "prot_fx.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c
index ad366278c3be1641c8fd0a5147debcb1c9dae785..abb66a8b899578dc0ad57e6b4db41bedec9d0e72 100644
--- a/lib_enc/gain_enc_fx.c
+++ b/lib_enc/gain_enc_fx.c
@@ -7,8 +7,7 @@
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c
index 56ac45f26aa4e9eb1f5ac9b00f35d1a6afab918b..57a336ec25f80eb161e363fbd6b232fe4ef512f7 100644
--- a/lib_enc/gaus_enc_fx.c
+++ b/lib_enc/gaus_enc_fx.c
@@ -8,8 +8,7 @@
#include "rom_com.h" /* Static table prototypes */
#include "rom_enc.h" /* Static table prototypes */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
//#include "basop_mpy.h"
diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c
index 1a1f1debfec6e8d3a4f339094832cce889f6131b..73a5c35ea29ce16c5128b2b367ca005e69b75671 100644
--- a/lib_enc/gp_clip_fx.c
+++ b/lib_enc/gp_clip_fx.c
@@ -37,8 +37,7 @@
#include
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h"
diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c
index a0396a97f31b3456cce21c521bf7b1f67653007b..e2d1f4aa9233138ef1fddfc9d493a4d14466b89d 100644
--- a/lib_enc/gs_enc_fx.c
+++ b/lib_enc/gs_enc_fx.c
@@ -7,8 +7,7 @@
#include "rom_com_fx.h"
#include "rom_com.h"
//#include "prot_fx.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
@@ -303,7 +302,7 @@ void encod_audio_fx(
*--------------------------------------------------------------------------------------*/
/* Find the current total number of bits used */
- tmp_nb_bits_tot = hBstr->nb_bits_tot_fx;
+ tmp_nb_bits_tot = hBstr->nb_bits_tot;
move16();
diff --git a/lib_enc/guided_plc_enc_fx.c b/lib_enc/guided_plc_enc_fx.c
index aebdfb748e773b68f5be71bb97180bf9e41c41a5..6470e0a3c88fa8bcf420af79d496ecb0f73d570b 100644
--- a/lib_enc/guided_plc_enc_fx.c
+++ b/lib_enc/guided_plc_enc_fx.c
@@ -7,8 +7,7 @@
#include "options.h"
#include "cnst.h"
//#include "prot_fx.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "stat_enc.h"
#include "basop_util.h"
diff --git a/lib_enc/hf_cod_amrwb_fx.c b/lib_enc/hf_cod_amrwb_fx.c
index 0fa53be5155d81f61b1ec4cf268ffe646901caa7..7c2060fa8663df927207db78e0a59227df997424 100644
--- a/lib_enc/hf_cod_amrwb_fx.c
+++ b/lib_enc/hf_cod_amrwb_fx.c
@@ -8,8 +8,7 @@
#include "rom_com_fx.h"
#include "cnst.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c
index ebf3855ee9c41c5ca56521ee82bdb792addb3648..842f2029ed253cfdb0bb3dc8c0444e292b5c69cd 100644
--- a/lib_enc/hq_classifier_enc_fx.c
+++ b/lib_enc/hq_classifier_enc_fx.c
@@ -7,8 +7,7 @@
//#include "prot_fx.h" /* Function prototypes */
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-----------------------------------------------------------------*
diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c
index 700ac87264c8fafaa7a39f3f6d14c91a04baff6b..55e37a3b55db153f6adb30bd2d56a16434d451ba 100644
--- a/lib_enc/hq_core_enc_fx.c
+++ b/lib_enc/hq_core_enc_fx.c
@@ -7,8 +7,7 @@
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
//#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*--------------------------------------------------------------------------
@@ -147,7 +146,7 @@ void hq_core_enc_fx(
}
#ifndef ADD_IVAS_HQ_CODE
/* subtract signalling bits */
- num_bits = sub( num_bits, hBstr->nb_bits_tot_fx );
+ num_bits = sub( num_bits, hBstr->nb_bits_tot );
#endif
direct_transform_fx( wtda_audio, t_audio, is_transient, input_frame, &Q_audio, st_fx->element_mode );
diff --git a/lib_enc/hq_env_enc_fx.c b/lib_enc/hq_env_enc_fx.c
index d64685ddabf1384cbbb4c978b770bd12c4cd873a..bfb9836412263025dc8ff7188884c53698fba089 100644
--- a/lib_enc/hq_env_enc_fx.c
+++ b/lib_enc/hq_env_enc_fx.c
@@ -8,8 +8,7 @@
#include "rom_enc.h"
#include "rom_com.h"
#include "stl.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*--------------------------------------------------------------------------------------*
diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c
index 3049e6c21c37a4dcf40999d6199579ff7d3dc478..ca7d941eecb1ed2e97a238e9382ab4e5cf993f99 100644
--- a/lib_enc/hq_hr_enc_fx.c
+++ b/lib_enc/hq_hr_enc_fx.c
@@ -7,8 +7,7 @@
//#include "prot_fx.h" /* Function prototypes */
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*--------------------------------------------------------------------------*
diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c
index d1f3520570e646758db955b49f76eaa71205192b..85827b9a1d619dfb291e469458548a84271758f1 100644
--- a/lib_enc/hq_lr_enc_fx.c
+++ b/lib_enc/hq_lr_enc_fx.c
@@ -9,8 +9,7 @@
#include "rom_enc.h"
//#include "basop_mpy.h"
#include "rom_com.h" /* Common constants */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c
index 107905ccbff764c39835817144fb89492be5432d..b2adfef24cd5adf5d658e1900c966b5bc79a4520 100644
--- a/lib_enc/hvq_enc_fx.c
+++ b/lib_enc/hvq_enc_fx.c
@@ -7,8 +7,7 @@
#include "cnst.h"
//#include "prot_fx.h"
#include "rom_com.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#define HVQ_ENC_NOISE_DELTA ( (Word16) 3277 ) /* 0.1 in Q15 */
diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c
index 230df02486440b6009c3e125876c2ce3c6e0ec56..dcc61747dc51197603fc56a9a3f29c056f659c32 100644
--- a/lib_enc/igf_enc.c
+++ b/lib_enc/igf_enc.c
@@ -43,14 +43,37 @@
#include "cnst.h"
#include "stat_enc.h"
#include "wmc_auto.h"
+#ifdef IVAS_FLOAT_FIXED
+#include "prot_fx_enc.h"
+#include "prot_fx.h"
+#endif // IVAS_FLOAT_FIXED
+#define INV_Log2_10_Q15 9864 /*1/log2(10) in Q15*/
+#define INV_Log2_e_Q15 22713 /*1/log2(e) in Q15*/
/*-------------------------------------------------------------------*
* IGF_write_bit()
*
* write single bit to stream
*-------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+static void IGF_write_bit(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ Word16 *bitCount, /* i/o: bit counter */
+ const Word16 value /* i : value */
+)
+{
+ IF( hBstr )
+ {
+ push_next_indice( hBstr, value, 1 );
+ }
+
+ ( *bitCount ) = add( ( *bitCount ), 1 );
+ move16();
+ return;
+}
+#else
static void IGF_write_bit(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
int16_t *bitCount, /* i/o: bit counter */
@@ -67,13 +90,36 @@ static void IGF_write_bit(
return;
}
+#endif
/*-------------------------------------------------------------------*
* IGF_write_bits()
*
* write bits to stream
*-------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+static void IGF_write_bits(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ Word16 *bitCount, /* i/o: bit counter */
+ const Word16 value, /* i/o: value */
+ Word16 bits /* i : number of bits */
+)
+{
+ WHILE( bits-- )
+ {
+ IF( s_and( value, shl( 1, bits ) ) == 0 )
+ {
+ IGF_write_bit( hBstr, bitCount, 0 );
+ }
+ ELSE
+ {
+ IGF_write_bit( hBstr, bitCount, 1 );
+ }
+ }
+ return;
+}
+#else
static void IGF_write_bits(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
int16_t *bitCount, /* i/o: bit counter */
@@ -88,6 +134,7 @@ static void IGF_write_bits(
return;
}
+#endif // IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
@@ -97,6 +144,67 @@ static void IGF_write_bits(
*-------------------------------------------------------------------*/
/*! r: crest factor */
+#ifdef IVAS_FLOAT_FIXED
+static Word16 IGF_getCrest_new_fx(
+ const Word16 *logSpec, /* i : power spectrum */
+ const Word16 start, /* i : start subband index */
+ const Word16 stop, /* i : stop subband index */
+ Word16 *crest_exp /*Stores the exponent of the result(return value)*/
+)
+{
+ Word16 i;
+ Word16 x;
+ Word32 x_eff;
+ Word16 x_max;
+ Word16 exp;
+ Word16 temp;
+ Word16 temp_e;
+ Word16 crest; /*1.0f in Q15*/
+ x_eff = 0;
+ x_max = 0;
+ exp = 0;
+ temp = 0;
+ crest = 32767; /*1.0f in Q15*/
+ move32();
+ move16();
+ move16();
+ move16();
+ move16();
+
+ FOR( i = start; i < stop; i++ )
+ {
+ x = logSpec[i];
+ move16();
+ x_eff = L_add( x_eff, L_mult0( x, x ) );
+
+ IF( GT_16( x, x_max ) )
+ {
+ x_max = x;
+ move16();
+ }
+ }
+
+ x_eff = BASOP_Util_Divide3216_Scale( x_eff, sub( stop, start ), &temp_e );
+ temp_e = add( temp_e, 16 ); /*exp += 31 - 15 + 16(because x_eff is word32)*/
+ temp = Sqrt16( extract_l( x_eff ), &temp_e );
+
+ IF( x_eff > 0 && x_max > 0 )
+ {
+ temp = BASOP_Util_Divide1616_Scale( x_max, temp, &exp );
+ exp = add( exp, sub( 15, temp_e ) );
+ IF( exp < 0 )
+ {
+ temp = shl( temp, exp );
+ exp = 0;
+ move16();
+ }
+ crest = s_max( shl_sat( 1, sub( 15, exp ) ), temp );
+ }
+ *crest_exp = exp;
+ move16();
+ return crest;
+}
+#endif
static float IGF_getCrest_new(
const int16_t *logSpec, /* i : power spectrum */
const int16_t start, /* i : start subband index */
@@ -138,6 +246,61 @@ static float IGF_getCrest_new(
*-------------------------------------------------------------------*/
/*! r: SFM value */
+#ifdef IVAS_FLOAT_FIXED
+static Word16 IGF_getSFM_new_fx(
+ const Word32 *powerSpectrum, /* i : power spectrum */
+ 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 n;
+ Word16 i;
+ Word16 num;
+ Word32 denom;
+ Word16 numf;
+ Word32 tmp;
+ Word16 sfm;
+ Word16 sfm_e;
+ Word16 denom_e;
+ Word16 numf_e; /*stores exponent for numf*/
+ Word16 tmp_e;
+
+ num = 0;
+ denom = 1;
+ denom_e = 31;
+ sfm = 1;
+ move16();
+ move32();
+ move16();
+ move16();
+
+ FOR( i = start; i < stop; i++ )
+ {
+ tmp = powerSpectrum[i];
+ n = logSpec[i /*-start*/];
+ move32();
+ move16();
+ num = add( num, n );
+ denom = BASOP_Util_Add_Mant32Exp( tmp, e_ps, denom, denom_e, &denom_e );
+ }
+
+ numf = BASOP_Util_Divide1616_Scale( num, sub( stop, start ), &numf_e );
+ denom = BASOP_Util_Divide3216_Scale( denom, sub( stop, start ), &tmp_e );
+ denom_e = add( add( denom_e, tmp_e ), 1 ); /*denom_e+tmp_e-15 +16(because type of denom is word32)*/
+
+ IF( denom != 0 )
+ {
+ tmp = BASOP_util_Pow2( L_add( numf, shl_sat( 1, sub( 14, numf_e ) ) ), 16 + numf_e, &tmp_e );
+ sfm = BASOP_Util_Divide3232_Scale( tmp, denom, &sfm_e );
+ sfm_e = add( sfm_e, sub( tmp_e, denom_e ) );
+ sfm = shl_sat( extract_l( L_min( sfm, L_shl( 1, 15 - sfm_e ) ) ), sfm_e );
+ }
+
+ return sfm;
+}
+#endif
static float IGF_getSFM_new(
const float *powerSpectrum, /* i : power spectrum */
const int16_t *logSpec, /* i : log of power spectrum */
@@ -184,6 +347,64 @@ static float IGF_getSFM_new(
*-------------------------------------------------------------------*/
/*! r: spectral tilt value */
+#if 0
+#ifdef IVAS_FLOAT_FIXED
+static Word16 IGF_getTilt_fx(
+ const Word32 *powerSpectrum, /* i : energies */
+ const Word16 start, /* i : start subband index */
+ const Word16 stop, /* i : stop subband index */
+ Word16 q_powerSpectrum, /*Stores q reated to powerSpectrum*/
+ Word16 *slope_e /*stores the exponent of returned slope value*/
+)
+{
+ Word16 i;
+ Word16 x;
+ Word16 width;
+ Word32 y;
+ Word32 mean_x, mean_y, mean_xy, mean_x2;
+ Word32 max_mean_x_e;
+ Word16 mean_x_e, mean_y_e, mean_xy_e, mean_x2_e;
+ Word16 slope;
+ Word16 slope_e;
+
+ x = 1;
+ mean_x = mean_y = mean_xy = mean_x2 = 0;
+ move16();
+ move32();
+ move32();
+ move32();
+ move32();
+
+ width = sub( stop, start );
+ for ( i = start; i < stop; i++ )
+ {
+ mean_x = L_add( mean_x, x ); /*Q0*/
+ mean_x2 = L_add( mean_x2, L_mult0( x, x ) ); /*Q0*/
+ y = imult3216( Mult_32_16( L_add( BASOP_Util_Log2( L_max( L_shl( 1, q_powerSpectrum ), powerSpectrum[i] ) ), L_shl( sub( 31, q_powerSpectrum ), Q25 ) ) /*Q25*/, INV_Log2_10_Q15 ) /*Q25*/, 20 ); /*Q25*/
+ mean_y = L_add( mean_y, y ); /*Q25*/
+ mean_xy = L_add( mean_xy, Mult_32_16( y, x ) ); /*Q25+0-Q15=>Q10*/
+
+ x = add( x, 1 ); /*Q0*/
+ }
+ mean_y = BASOP_Util_Divide3216_Scale( mean_y, width, &mean_y_e );
+ mean_y_e = add( mean_y_e, -9 ) /*6 -15*/;
+ mean_x = BASOP_Util_Divide3216_Scale( mean_x, width, &mean_x_e );
+ mean_x_e = add( mean_x_e, 16 ) /*31 -15*/;
+ mean_xy = BASOP_Util_Divide3216_Scale( mean_xy, width, mean_xy_e );
+ mean_xy_e = add( mean_xy_e, 6 ) /*21 -15*/;
+ mean_x2 = BASOP_Util_Divide3216_Scale( mean_x2, width, mean_x2_e );
+ mean_x2_e = add( mean_x2_e, 16 ) /*31 -15*/;
+ max_mean_x_e = s_max( mean_x_e, s_max( mean_xy_e, mean_x2_e ) );
+ mean_x = shr( mean_x, sub( mean_x_e, max_mean_x_e ) ); /*mean_x_e=max_mean_x_e*/
+ mean_xy = shr( mean_xy, sub( mean_xy_e, max_mean_x_e ) ); /*mean_xy_e=max_mean_x_e*/
+ mean_x2 = shr( mean_x2, sub( mean_x2_e, max_mean_x_e ) ); /*mean_x2_e=mean_x2_e*/
+ slope = BASOP_Util_Divide3232_Scale( L_mult0( extract_l( L_sub( mean_xy, mean_x ) ), extract_l( mean_y ) ) /*max_mean_x_e+mean_y_e*/, L_mult0( extract_l( L_sub( mean_x2, mean_x ) ), extract_l( mean_x ) ) /*2*max_mean_x_e*/, slope_e ); /*q_powerSpectrum-15*/
+ *slope_e = add( *slope_e, sub( mean_y_e, max_mean_x_e ) );
+ move16();
+ return slope;
+}
+#endif
+#endif
static float IGF_getTilt(
const float *powerSpectrum, /* i : energies */
const int16_t start, /* i : start subband index */
@@ -228,6 +449,90 @@ static float IGF_getTilt(
*-------------------------------------------------------------------*/
/*! r: spectral tilt value */
+#ifdef IVAS_FLOAT_FIXED
+/* Returns value with exponent as 9 and Q as 22*/
+static Word32 IGF_getTNR_fx(
+ const Word32 *powerSpectrum, /* i : energies */
+ const Word16 start, /* i : start subband index */
+ const Word16 stop, /* i : stop subband index */
+ const Word16 adap, /* i : SFB width adaptation */
+ Word16 e_ps, /*Stores exponent for powerSpectrum*/
+ Word16 e_adap /*Stores exponent for adap*/
+)
+{
+ Word16 i;
+ Word16 width;
+ Word32 avg;
+ Word32 tonal;
+ Word16 tonal_e; /* holds exp for tonal*/
+ Word32 noise;
+ Word16 noise_e; /* holds exp for noise*/
+ Word32 tonalToNoise;
+ Word32 rootSpec[300];
+ Word16 rootSpec_e[300]; /*rootSpec_e[i] holds exp for rootSpec[i]*/
+ Word16 avg_e; /* holds exp for avg*/
+ Word16 tmp_e;
+ avg = 0;
+ tonal = 0;
+ noise = EPSILON_FX;
+ tonal_e = 0;
+ noise_e = 0;
+ avg_e = 0;
+ tmp_e = 0;
+ move32();
+ move32();
+ move32();
+ move16();
+ move16();
+ move16();
+ move16();
+
+ set32_fx( rootSpec, 0, 300 );
+ set16_fx( rootSpec_e, 0, 300 );
+
+ width = sub( stop, start );
+ FOR( i = start; i < stop; i++ )
+ {
+ rootSpec_e[sub( i, start )] = e_ps;
+ move16();
+ rootSpec[sub( i, start )] = Sqrt32( powerSpectrum[i], &rootSpec_e[sub( i, start )] ); /*rootSpec[i - start] = sqrtf( powerSpectrum[i] );*/
+ move32();
+ avg = BASOP_Util_Add_Mant32Exp( avg, avg_e, rootSpec[sub( i, start )], rootSpec_e[sub( i, start )], &avg_e ); /*avg += rootSpec[i - start];resultant exponent is avg_e*/
+ }
+ avg = BASOP_Util_Divide3216_Scale( avg, width, &tmp_e ); /*avg /= width;*/
+ avg_e = add( 16, sub( add( avg_e, tmp_e ), 15 ) );
+
+ FOR( i = start; i < stop; i++ )
+ {
+ Word16 normSpec_e; /*stores resultant exponent for normSpec*/
+ Word16 normSpec = BASOP_Util_Divide3232_Scale( rootSpec[sub( i, start )], avg, &normSpec_e ); /*rootSpec[i - start] / avg;*/
+ normSpec_e = add( normSpec_e, sub( rootSpec_e[sub( i, start )], avg_e ) );
+ IF( GT_32( normSpec, L_add( L_shl( 1, sub( 15, normSpec_e ) ), L_shl( adap, sub( e_adap, normSpec_e ) ) ) ) )
+ {
+ tonal = BASOP_Util_Add_Mant32Exp( tonal, tonal_e, rootSpec[sub( i, start )], rootSpec_e[sub( i, start )], &tonal_e ); /*tonal += rootSpec[i - start];*/
+ }
+ ELSE IF( LT_32( normSpec, L_shl( 1, sub( 15, normSpec_e ) ) ) )
+ {
+ noise = BASOP_Util_Add_Mant32Exp( noise, noise_e, rootSpec[sub( i, start )], rootSpec_e[sub( i, start )], &noise_e ); /*noise += rootSpec[i - start];*/
+ }
+ }
+
+ /*tonalToNoise=20.f * log10f( max( 1e-018f, tonal / noise ) )*/
+ 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 = L_shr( imult3216( Mult_32_16( L_add( BASOP_Util_Log2( temp ), L_shl( add( 16, tmp_e ), Q25 ) ) /*Q25*/, INV_Log2_10_Q15 ) /*25+15-15*/, 20 ) /*25*/, 3 ); /*Q22*/
+ }
+ ELSE
+ {
+ tonalToNoise = -1509949440; /*-360.f Q22*/
+ move32();
+ }
+
+ return tonalToNoise;
+}
+#endif // IVAS_FLOAT_FIXED
static float IGF_getTNR(
const float *powerSpectrum, /* i : energies */
const int16_t start, /* i : start subband index */
@@ -279,7 +584,7 @@ static float IGF_getTNR(
*-------------------------------------------------------------------*/
/*! r: crest factor */
-static float IGF_getCrest(
+static float IGF_getCrest_ivas(
const float *powerSpectrum, /* i : power spectrum */
const int16_t start, /* i : start subband index */
const int16_t stop /* i : stop subband index */
@@ -320,7 +625,7 @@ static float IGF_getCrest(
*-------------------------------------------------------------------*/
/*! r: SFM value */
-static float IGF_getSFM(
+static float IGF_getSFM_ivas(
const float *powerSpectrum, /* i : energies */
const int16_t start, /* i : start subband index */
const int16_t stop /* i : stop subband index */
@@ -595,11 +900,495 @@ static void IGF_CalculateEnvelope(
/*-------------------------------------------------------------------*
- * IGF_CalculateStereoEnvelope()
+ * IGF_CalculateStereoEnvelope_fx()
*
* envelope estimation
+
*-------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+static void IGF_CalculateStereoEnvelope_fx(
+ const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
+ const Word32 *pMDCTSpectrum_fx, /* i : MDCT spectrum */
+ Word16 pMDCTSpectrum_e, /* i : exponent for pMDCTSpectrum_fx */
+ const Word32 *pMDCTSpectrumMsInv_fx, /* i : MDCT spectrum */
+ Word16 pMDCTSpectrumMsInv_e, /* i : expontent for pMDCTSpectrumMsInv_fx */
+ const Word32 *pPowerSpectrum_fx, /* i : MDCT^2 + MDST^2 spectrum, or estimate */
+ Word16 pPowerSpectrum_e, /* i : exponent for pPowerSpectrum_fx */
+ const Word32 *pPowerSpectrumMsInv_fx, /* i : inverse power spectrum */
+ Word16 pPowerSpectrumMsInv_e, /* i : exponent for pPowerSpectrumMsInv_fx */
+ const Word16 igfGridIdx, /* i : IGF grid index */
+ const Word16 coreMsMask[N_MAX], /* i : line wise ms Mask */
+ const Word16 isTransient, /* i : flag indicating if transient is detected */
+ const Word16 last_core_acelp /* i : indicator if last frame was ACELP core */
+)
+{
+ IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData;
+ H_IGF_GRID hGrid;
+ Word16 *swb_offset;
+ Word16 sfb; /* this is the actual scalefactor band */
+ Word16 width; /* this is width in subbands of the actual scalefactor band */
+ Word16 tile_idx;
+ Word16 strt_cpy;
+ Word32 gain_fx; /* the gain which has to be applied to the source tile to get the destination energy */
+ Word16 sb;
+ Word16 sfbEnergyR_fx;
+ Word32 sfbEnergyC_fx; /* the energy of the destination region of the tile */
+ Word32 sfbEnergyTileR_fx;
+ Word32 sfbEnergyTileC_fx; /* the energy of the destination region of the tile */
+ Word16 tmp, x, y;
+ Word16 mean_x_fx, mean_y_fx;
+ Word32 mean_xy_fx, mean_x2_fx;
+ Word16 slope_fx;
+ Word16 tmp_tb_fx;
+ Word16 tmp_sb_fx;
+ Word16 sfbCnt;
+ Word32 tileSrcSpec_fx[MAX_IGF_SFB_LEN];
+ Word16 sfm;
+ Word16 crest;
+ Word16 temp;
+ Word16 mean_x_e, mean_y_e; /*Stores exponent for mean_x and mean_y respectively*/
+ Word16 mean_xy_e, mean_x2_e; /*stores exponent for mean_xy and mean_x2 respectively*/
+ Word16 tileSrcSpec_e; /*Exponent for tileSrcSpec_fx*/
+ Word16 sfbEnergyTileR_e; /*Exponent for sfbEnergyTileR_fx*/
+ Word16 sfbEnergyTileC_e; /*Exponent for sfbEnergyTileC_fx*/
+ Word16 sfbEnergyC_e; /*Exponent for sfbEnergyC_fx*/
+ Word16 gain_e; /*exponent for gain_fx*/
+ Word16 crest_exp; /*stores exponent for output from crest*/
+ Word16 sfm_exp; /*stores exponent for ouput from sfm*/
+ Word16 tmp_tb_e; /*Stores exponent for tmp_tb_fx*/
+ Word16 tmp_sb_e; /*stores exponent for tmp_sb_fx*/
+ Word16 slope_e; /*stores exponent for slope_fx*/
+ Word16 sfbEnergyR_e; /*stores exponent for sfbEnergyR*/
+ Word16 tmp_e;
+ hPrivateData = &hIGFEnc->igfData;
+ hGrid = &hPrivateData->igfInfo.grid[(Word16) igfGridIdx];
+ swb_offset = hGrid->swb_offset;
+ move16();
+
+ IF( NE_16( igfGridIdx, IGF_GRID_LB_NORM ) )
+ {
+ FOR( sfbCnt = 0; sfbCnt < sub( hGrid->sfbWrap[hGrid->nTiles], hGrid->sfbWrap[0] ); sfbCnt++ )
+ {
+ /* reset filter */
+ hPrivateData->prevSFM_FIR_SFB_TB_fx[sfbCnt] = 0; /* Exponent is hPrivateData->sfb_tb_e*/
+ hPrivateData->prevSFM_IIR_SFB_TB_fx[sfbCnt] = 0; /* Exponent is hPrivateData->sfb_tb_e*/
+ hPrivateData->prevSFM_FIR_SFB_SB_fx[sfbCnt] = 0; /* Exponent is hPrivateData->sfb_sb_e*/
+ hPrivateData->prevSFM_IIR_SFB_SB_fx[sfbCnt] = 0; /* Exponent is hPrivateData->sfb_sb_e*/
+ hPrivateData->sfb_sb_e[sfbCnt] = 0;
+ hPrivateData->sfb_tb_e[sfbCnt] = 0;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ }
+ }
+
+ IF( pPowerSpectrum_fx )
+ {
+ FOR( sb = hGrid->sbWrap[0]; sb < swb_offset[hGrid->sfbWrap[hGrid->nTiles]]; sb++ )
+ {
+ /*hPrivateData->logSpec[sb] = max( 0, (int16_t) ( logf( max( FLT_MIN, pPowerSpectrum[sb] ) ) * INV_LOG_2 ) );*/
+ IF( LE_32( 1, pPowerSpectrum_fx[sb] ) )
+ {
+ hPrivateData->logSpec[sb] = s_max( 0, (Word16) L_shr( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e, Q25 ) ), 25 ) );
+ }
+ ELSE
+ {
+ hPrivateData->logSpec[sb] = 0; /*max(0,-126) is always 0*/
+ }
+ move16();
+ }
+ }
+
+ FOR( tile_idx = 0; tile_idx < hGrid->nTiles; tile_idx++ )
+ {
+ strt_cpy = hGrid->sbWrap[tile_idx];
+ move16();
+
+ FOR( sfb = hGrid->sfbWrap[tile_idx]; sfb < hGrid->sfbWrap[tile_idx + 1]; sfb++ )
+ {
+ width = sub( swb_offset[sfb + 1], swb_offset[sfb] );
+ sfbEnergyTileR_fx = EPSILON_FX;
+ sfbEnergyTileC_fx = EPSILON_FX;
+ sfbEnergyC_fx = EPSILON_FX;
+ sfbEnergyTileR_e = 0;
+ sfbEnergyTileC_e = 0;
+ sfbEnergyC_e = 0;
+ move16();
+ move16();
+ move16();
+ move32();
+ move32();
+ move32();
+ IF( pPowerSpectrum_fx )
+ {
+ Word16 final_exp;
+ Word16 norm_exp;
+ Word32 scaled_value;
+ tmp = strt_cpy;
+ move16();
+
+ FOR( sb = swb_offset[sfb]; sb < swb_offset[sfb + 1]; sb++ )
+ {
+ IF( NE_16( coreMsMask[sb], coreMsMask[strt_cpy] ) )
+ {
+ sfbEnergyC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyC_fx, sfbEnergyC_e, pPowerSpectrum_fx[sb], pPowerSpectrum_e, &sfbEnergyC_e ); /*resultant exponent is stored in sfbEnergyC_e*/
+ norm_exp = norm_l( pMDCTSpectrumMsInv_fx[strt_cpy] );
+ final_exp = sub( pMDCTSpectrumMsInv_e, norm_exp );
+ scaled_value = L_shl( pMDCTSpectrumMsInv_fx[strt_cpy], norm_exp );
+ sfbEnergyTileR_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileR_fx, sfbEnergyTileR_e, Mult_32_32( scaled_value, scaled_value ), shl( final_exp, 1 ), &sfbEnergyTileR_e ); /*resultant exponent is stored in sfbEnergyTileR_e*/
+ sfbEnergyTileC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC_fx, sfbEnergyTileC_e, pPowerSpectrumMsInv_fx[strt_cpy], pPowerSpectrumMsInv_e, &sfbEnergyTileC_e ); /*resultant exponent is stored in sfbEnergyTileC_e*/
+ tileSrcSpec_fx[sub( strt_cpy, tmp )] = pPowerSpectrumMsInv_fx[strt_cpy]; /*resultant exponent is stored in tileSrcSpec_e*/
+ tileSrcSpec_e = pPowerSpectrumMsInv_e;
+ }
+ ELSE
+ {
+ sfbEnergyC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyC_fx, sfbEnergyC_e, pPowerSpectrum_fx[sb], pPowerSpectrum_e, &sfbEnergyC_e ); /*resultant exponent is stored in sfbEnergyC_e*/
+ norm_exp = norm_l( pMDCTSpectrum_fx[strt_cpy] );
+ final_exp = sub( pMDCTSpectrum_e, norm_exp );
+ scaled_value = L_shl( pMDCTSpectrum_fx[strt_cpy], norm_exp );
+ sfbEnergyTileR_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileR_fx, sfbEnergyTileR_e, Mult_32_32( scaled_value, scaled_value ), shl( final_exp, 1 ), &sfbEnergyTileR_e ); /*resultant exponent is stored in sfbEnergyTileR_e*/
+ sfbEnergyTileC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC_fx, sfbEnergyTileC_e, pPowerSpectrum_fx[strt_cpy], pPowerSpectrum_e, &sfbEnergyTileC_e ); /*resultant exponent is stored in sfbEnergyTileC_e*/
+ tileSrcSpec_fx[sub( strt_cpy, tmp )] = pPowerSpectrum_fx[strt_cpy]; /*resultant exponent is stored in tileSrcSpec_e*/
+ tileSrcSpec_e = pPowerSpectrum_e;
+ }
+ move32();
+ strt_cpy = add( strt_cpy, 1 );
+ }
+
+ sfbEnergyTileR_fx = BASOP_Util_Divide3216_Scale( sfbEnergyTileR_fx, width, &tmp_e );
+ sfbEnergyTileR_e = sub( add( sfbEnergyTileR_e, tmp_e ), 15 ); /*stores the resultant exponent for sfbEnergyTileR_fx*/
+
+ /*gain = (float) ( sfbEnergyTileR * ( sfbEnergyC / sfbEnergyTileC ) );*/
+ temp = BASOP_Util_Divide3232_Scale( sfbEnergyC_fx, L_add( sfbEnergyTileC_fx, EPSILON_FX ), &tmp_e );
+ gain_e = add( tmp_e, sub( sfbEnergyC_e, sfbEnergyTileC_e ) );
+ gain_fx = Mult_32_16( sfbEnergyTileR_fx, temp );
+ gain_e = add( 16, add( gain_e, sfbEnergyTileR_e ) ); /*stores the resultant exponent for gain_fx*/
+
+ IF( !isTransient )
+ {
+ Word16 diffSFM_fx;
+ Word16 diffSFM_e;
+ Word16 shiftedSFM_fx;
+ Word16 shiftedSFM_e; /*stores the resultant exponent for shiftedSFM_fx*/
+ shiftedSFM_fx = 0;
+ shiftedSFM_e = 0;
+ move16();
+ move16();
+
+ // tmp_tb = IGF_getSFM_ivas(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]) / IGF_getCrest_ivas(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]);
+ sfm = IGF_getSFM( &sfm_exp, pPowerSpectrum_fx, &pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1] );
+ crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1] );
+ tmp_tb_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e );
+ tmp_tb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); /*stores the resultant exponent for tmp_tb_fx*/
+
+ // tmp_sb = IGF_getSFM_ivas(tileSrcSpec, 0, strt_cpy - tmp) / IGF_getCrest_ivas(tileSrcSpec, 0, strt_cpy - tmp);
+ sfm = IGF_getSFM( &sfm_exp, tileSrcSpec_fx, &tileSrcSpec_e, 0, sub( strt_cpy, tmp ) );
+ crest = IGF_getCrest( &crest_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ) );
+ tmp_sb_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e );
+ tmp_sb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); /*stores the resultant exponent for tmp_sb_fx*/
+
+ IF( last_core_acelp || hPrivateData->wasTransient )
+ {
+ hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb] = hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb] = tmp_tb_fx; /*Exponent for hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb] and hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb] values stored in hPrivateData->sfb_tb_e[sfb] */
+ hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb] = hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb] = tmp_sb_fx; /*Exponent for hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb] and hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb] values stored in hPrivateData->sfb_sb_e[sfb]*/
+ hPrivateData->sfb_tb_e[sfb] = tmp_tb_e;
+ hPrivateData->sfb_sb_e[sfb] = tmp_sb_e;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ }
+ ELSE
+ {
+ /* Purpose of this block:
+ -to make the exponent of hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb] and hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb] equal to that of tmp_tb_fx
+ -to make the exponent of hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb] and hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb] equal to that of tmp_sb_fx
+ */
+ Word16 diff_sb_e; /*stores the difference of exponents for sb*/
+ Word16 diff_tb_e; /*stores the difference of exponents for tb*/
+ diff_sb_e = sub( tmp_sb_e, hPrivateData->sfb_sb_e[sfb] );
+ diff_tb_e = sub( tmp_tb_e, hPrivateData->sfb_tb_e[sfb] );
+ IF( LE_16( tmp_tb_e, hPrivateData->sfb_tb_e[sfb] ) )
+ {
+ tmp_tb_fx = shl( tmp_tb_fx, diff_tb_e );
+ tmp_tb_e = hPrivateData->sfb_tb_e[sfb];
+ move16();
+ }
+ ELSE
+ {
+ hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb] = shr( hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb], diff_tb_e );
+ hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb] = shr( hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb], diff_tb_e );
+ hPrivateData->sfb_tb_e[sfb] = tmp_tb_e;
+ move16();
+ move16();
+ move16();
+ }
+ IF( LE_16( tmp_sb_e, hPrivateData->sfb_sb_e[sfb] ) )
+ {
+ tmp_sb_fx = shl( tmp_sb_fx, diff_sb_e );
+ tmp_sb_e = hPrivateData->sfb_sb_e[sfb];
+ move16();
+ }
+ ELSE
+ {
+ hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb] = shr( hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb], diff_sb_e );
+ hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb] = shr( hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb], diff_sb_e );
+ hPrivateData->sfb_sb_e[sfb] = tmp_sb_e;
+ move16();
+ move16();
+ move16();
+ }
+ }
+ tmp_tb_fx = shr( tmp_tb_fx, 2 ); /*taking 2 guard bits so it's exponent tmp_sb_e=+2*/
+ tmp_sb_fx = shr( tmp_sb_fx, 2 ); /*taking 2 guard bits so it's exponent tmp_tb_e=+2 */
+ tmp_sb_e = add( tmp_sb_e, 2 );
+ tmp_tb_e = add( tmp_tb_e, 2 );
+ hPrivateData->SFM_tb_fx[sfb] = add( tmp_tb_fx, add( shr( hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb], 2 ), shr( hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb], 3 ) ) );
+ hPrivateData->SFM_tb_fx[sfb] = extract_l( L_min( L_shl( 22118 /*2.7f Q13*/, sub( 2, tmp_tb_e ) ), hPrivateData->SFM_tb_fx[sfb] ) ); /* resultant exponent stored in hPrivateData->sfb_sb_e[sfb]*/
+ hPrivateData->SFM_sb_fx[sfb] = add( tmp_sb_fx, add( shr( hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb], 2 ), shr( hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb], 3 ) ) );
+ hPrivateData->SFM_sb_fx[sfb] = extract_l( L_min( L_shl( 22118 /*2.7f Q13*/, sub( 2, tmp_sb_e ) ), hPrivateData->SFM_sb_fx[sfb] ) ); /*resultant exponent stores in hPrivateData->sfb_tb_e[sfb]*/
+ hPrivateData->sfb_sb_e[sfb] = tmp_sb_e;
+ hPrivateData->sfb_tb_e[sfb] = tmp_tb_e;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+
+ diffSFM_e = BASOP_Util_Add_MantExp( hPrivateData->SFM_sb_fx[sfb], tmp_sb_e, negate( hPrivateData->SFM_tb_fx[sfb] ), tmp_tb_e, &diffSFM_fx ); /*stores the resultant exponent for diffSFM_fx*/
+
+ UNUSED_PARAM( diffSFM_e );
+
+ IF( diffSFM_fx > 0 && LT_32( hPrivateData->SFM_tb_fx[sfb], L_shr( 3277 /*0.1 Q15*/, tmp_tb_e ) ) ) /* check whether target SFB is more tonal than source SFB */
+ {
+ Word16 currDampingFactor_fx, dampingFactor_fx, alpha_fx;
+ Word16 threshold_e, threshold_fx, alpha_e, currDampingFactor_e, dampingFactor_e;
+ /* calculate spectral tilt to detect sudden drops (or increases) in energy in the current SFB */
+ x = 1;
+ mean_x_fx = mean_y_fx = 0;
+ mean_xy_fx = mean_x2_fx = 0;
+ mean_x_e = mean_y_e = 15;
+ mean_xy_e = mean_x2_e = 31;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ FOR( sb = swb_offset[sfb]; sb < swb_offset[sfb + 1]; sb++ )
+ {
+ mean_x_fx = add( mean_x_fx, x ); /*Q0*/
+ mean_x2_fx = L_add( mean_x2_fx, L_mult0( x, x ) ); /*Q0*/
+
+ /*y = 20 * (int16_t) log10f( max( 1e-018f, pPowerSpectrum[sb] ) );*/
+ IF( LT_32( pPowerSpectrum_fx[sb], 1 ) )
+ {
+ y = 20 * ( -18 );
+ }
+ ELSE
+ {
+ y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e, Q25 ) ) ), INV_Log2_10_Q15 ), 25 ) ) ); /*Q0*/
+ }
+ mean_y_fx = add( mean_y_fx, y ); /*Q0*/
+ mean_xy_fx = L_add( mean_xy_fx, L_mult0( y, x ) ); /*Q0*/
+
+ x = add( x, 1 );
+ }
+ mean_y_fx = BASOP_Util_Divide1616_Scale( mean_y_fx, width, &tmp_e ); /* resultant exp stores in mean_y_e*/
+ mean_y_e = add( mean_y_e, sub( tmp_e, 15 ) );
+ mean_x_fx = BASOP_Util_Divide1616_Scale( mean_x_fx, width, &tmp_e ); /* resultant exp stores in mean_x_e*/
+ mean_x_e = add( mean_x_e, sub( tmp_e, 15 ) );
+ mean_xy_fx = BASOP_Util_Divide3216_Scale( mean_xy_fx, width, &tmp_e ); /* resultant exp stores in mean_xy_e*/
+ mean_xy_e = add( mean_xy_e, sub( tmp_e, 15 ) );
+ mean_x2_fx = BASOP_Util_Divide3216_Scale( mean_x2_fx, width, &tmp_e ); /* resultant exp stores in mean_x2_e*/
+ mean_x2_e = add( mean_x2_e, sub( tmp_e, 15 ) );
+
+ /*slope = ( mean_xy - mean_x * mean_y ) / ( mean_x2 - mean_x * mean_x );*/
+ slope_fx = BASOP_Util_Divide3232_Scale( ( L_sub( mean_xy_fx, L_shl( mult( mean_x_fx, mean_y_fx ), sub( add( mean_x_e, mean_y_e ), mean_xy_e ) ) ) ), ( L_sub( mean_x2_fx, L_shl( mult( mean_x_fx, mean_x_fx ), sub( add( mean_x_e, mean_x_e ), mean_x2_e ) ) ) ), &slope_e );
+ slope_e = add( slope_e, sub( mean_xy_e, mean_x2_e ) ); /*stores resultant exponent for slope_fx*/
+
+ /* determine whether strong tilt is due to a step in the spectrum (e.g. band limitation, no damping)
+ or a tonal component close the band border (apply damping) by calculating SFM for a shift of 1/2 SFB width*/
+ threshold_fx = BASOP_Util_Divide1616_Scale( 60, width, &threshold_e ); /*stores resultant exponent for threshold_fx*/
+
+ IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( slope_fx, add( slope_e, 16 ), negate( threshold_fx ), add( threshold_e, 16 ) ), -1 ) )
+ {
+ Word16 shift = shr( width, 1 );
+ // shiftedSFM = IGF_getSFM_ivas( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ) / IGF_getCrest_ivas( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift );
+ sfm = IGF_getSFM( &sfm_exp, pPowerSpectrum_fx, &pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ) );
+ crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ) );
+ shiftedSFM_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e );
+ }
+ ELSE IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( slope_fx, add( slope_e, 16 ), threshold_fx, add( threshold_e, 16 ) ), 1 ) && ( NE_16( sfb, sub( hGrid->sfbWrap[hGrid->nTiles], 1 ) ) ) )
+ {
+ Word16 shift;
+ shift = shr( width, 1 );
+ // shiftedSFM = IGF_getSFM_ivas( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ) / IGF_getCrest_ivas( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift );
+ sfm = IGF_getSFM( &sfm_exp, pPowerSpectrum_fx, &pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ) );
+ crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ) );
+ shiftedSFM_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e );
+ }
+ shiftedSFM_e = add( shiftedSFM_e, sub( sfm_exp, crest_exp ) ); /* stores resultant exponent for shiftedSFM_fx*/
+
+ // alpha = min( 320.f / (float) swb_offset[sfb + 1], 1.25f );
+ temp = BASOP_Util_Divide1616_Scale( 320, swb_offset[sfb + 1], &alpha_e );
+ alpha_fx = extract_l( L_min( temp, L_shl( 20480 /*1.25 Q14*/, sub( 1, alpha_e ) ) ) ); /* exponent is alpha_e*/
+ temp = BASOP_Util_Divide1616_Scale( hPrivateData->SFM_tb_fx[sfb], hPrivateData->SFM_sb_fx[sfb], &tmp_e );
+ tmp_e = add( tmp_e, sub( hPrivateData->sfb_tb_e[sfb], hPrivateData->sfb_sb_e[sfb] ) ); /* stores resultant exponent for temp */
+
+ // currDampingFactor = expf( alpha * logf( hPrivateData->SFM_tb[sfb] / hPrivateData->SFM_sb[sfb] ) );
+ currDampingFactor_fx = round_fx( BASOP_util_Pow2( Mpy_32_16_1( L_add( BASOP_Util_Log2( temp ), L_shl( add( 16, tmp_e ), 25 ) ), alpha_fx ), add( alpha_e, 6 ), &currDampingFactor_e ) ); /*exp is currDampingFactor_e*/
+
+ IF( GT_32( shiftedSFM_fx, L_shl( 1311 /*0.04f Q15*/, negate( shiftedSFM_e ) ) ) )
+ {
+ currDampingFactor_fx = 32767; /*1.f Q15*/
+ currDampingFactor_e = 0;
+ move16();
+ move16();
+ }
+
+ IF( last_core_acelp || hPrivateData->wasTransient || EQ_32( hPrivateData->prevDampingFactor_IIR_fx[sfb], L_shl( -1, sub( 15, hPrivateData->prevDampingFactor_IIR_e[sfb] ) ) ) )
+ {
+ hPrivateData->prevDampingFactor_IIR_fx[sfb] = s_max( currDampingFactor_fx, shr( 3277 /*0.1f * 32767*/, currDampingFactor_e ) ); /*resultant exponent stored in hPrivateData->prevDampingFactor_IIR_e[sfb]*/
+ hPrivateData->prevDampingFactor_IIR_e[sfb] = currDampingFactor_e;
+ move16();
+ move16();
+ }
+
+ {
+ Word32 tonalToNoise;
+ Word16 adap;
+ Word16 adap_e; /*stores exp for adap*/
+ Word16 tonalToNoise_e; /*stores exponent for tonalToNoise*/
+ tonalToNoise_e = 9; /*stores exponent for tonalToNoise*/
+ move16();
+ adap = BASOP_Util_Divide1616_Scale( width, 30, &adap_e );
+ tonalToNoise = IGF_getTNR_fx( pPowerSpectrum_fx, swb_offset[sfb], swb_offset[sfb + 1], adap, pPowerSpectrum_e, adap_e ); /*Q22*/
+ IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( tonalToNoise, tonalToNoise_e, L_add( L_shl( 10, sub( 15, adap_e ) ), adap ), add( 16, adap_e ) ), -1 ) )
+ {
+ // currDampingFactor += 0.1f * ( ( 10 + adap ) - tonalToNoise );
+ Word32 temp2 = BASOP_Util_Add_Mant32Exp( L_add( L_shl( 10, sub( 15, adap_e ) ) /*exp:adap_e*/, adap ), add( adap_e, 16 ), L_negate( tonalToNoise ), tonalToNoise_e, &tmp_e ); /* resultant exp is tmp_e*/
+ currDampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor_fx, currDampingFactor_e, extract_l( Mult_32_32( 3277 /*0.1f Q15*/, temp2 ) ), tmp_e, &currDampingFactor_fx ); /*stores resultant exp for currDampingFactor_fx*/
+ }
+ }
+
+ dampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor_fx, currDampingFactor_e, hPrivateData->prevDampingFactor_IIR_fx[sfb], hPrivateData->prevDampingFactor_IIR_e[sfb], &dampingFactor_fx );
+ dampingFactor_fx = shr( dampingFactor_fx, 1 ); /* resultant exponent is dampingFactor_e*/
+ IF( NE_16( BASOP_Util_Cmp_Mant32Exp( dampingFactor_fx, add( dampingFactor_e, 16 ), shr( hPrivateData->prevDampingFactor_IIR_fx[sfb], 1 ), add( hPrivateData->prevDampingFactor_IIR_e[sfb], 16 ) ), -1 ) )
+ {
+ // do nothing
+ }
+ ELSE
+ {
+ dampingFactor_fx = shr( hPrivateData->prevDampingFactor_IIR_fx[sfb], 1 ); /* resultant exponent is hPrivateData->prevDampingFactor_IIR_e[sfb]*/
+ dampingFactor_e = hPrivateData->prevDampingFactor_IIR_e[sfb];
+ move16();
+ }
+ IF( dampingFactor_e < 0 )
+ {
+ dampingFactor_fx = shl( dampingFactor_fx, dampingFactor_e );
+ dampingFactor_e = 0;
+ move16();
+ }
+ gain_fx = Mult_32_16( gain_fx, shl_sat( extract_l( L_min( L_add( dampingFactor_fx, Mult_32_16( L_shl( hPrivateData->dampingFactorSmoothing[sfb], sub( 15, dampingFactor_e ) ) /*Q:15-dampingFactor_e*/, 3277 /*0.1f Q15*/ ) /*Q:15-dampingFactor_e*/ ), shl_sat( 1, sub( 15, dampingFactor_e ) ) ) ), dampingFactor_e ) /*Q15*/ );
+
+ hPrivateData->prevDampingFactor_IIR_fx[sfb] = dampingFactor_fx;
+ hPrivateData->prevDampingFactor_IIR_e[sfb] = dampingFactor_e;
+ move16();
+ move16();
+ if ( hPrivateData->dampingFactorSmoothing[sfb] > 0 )
+ {
+ hPrivateData->dampingFactorSmoothing[sfb] = sub( hPrivateData->dampingFactorSmoothing[sfb], 1 );
+ move16();
+ }
+ }
+ ELSE
+ {
+ hPrivateData->prevDampingFactor_IIR_fx[sfb] = -( 1 << 15 ); /* resultant exp which is 0 stores in hPrivateData->prevDampingFactor_IIR_e[sfb]*/
+ hPrivateData->prevDampingFactor_IIR_e[sfb] = 0;
+ hPrivateData->dampingFactorSmoothing[sfb] = 1;
+ move16();
+ move16();
+ move16();
+ }
+
+ hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb] = tmp_tb_fx;
+ hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb] = hPrivateData->SFM_tb_fx[sfb];
+ hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb] = tmp_sb_fx;
+ hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb] = hPrivateData->SFM_sb_fx[sfb];
+ move16();
+ move16();
+ move16();
+ move16();
+ }
+ ELSE
+ {
+ hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb] = 0;
+ hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb] = 0;
+ hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb] = 0;
+ hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb] = 0;
+
+ hPrivateData->dampingFactorSmoothing[sfb] = 2;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ }
+ }
+ ELSE
+ {
+ tmp_e = pMDCTSpectrum_e;
+ sfbEnergyR_fx = add_sat( EPSILON_FX, BASOP_Util_Divide3216_Scale( sum2_32_fx( pMDCTSpectrum_fx + swb_offset[sfb], width, &tmp_e ) /*exp: tmp_e*/, width, &sfbEnergyR_e ) );
+ sfbEnergyR_e = add( sfbEnergyR_e, add( tmp_e, -15 ) ); /* stores resultant exponent for sfbEnergyR_fx*/
+ gain_fx = sfbEnergyR_fx; /*resultant exponent stored in gain_e=sfbEnergyR_e*/
+ gain_e = add( sfbEnergyR_e, 16 ); /* because gain_fx is word32;only after adding 16 q of gain_fx is 15-sfbEnergyR_e*/
+
+ hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb] = 0;
+ hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb] = 0;
+ hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb] = 0;
+ hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb] = 0;
+ move16();
+ move16();
+ move16();
+ move16();
+ }
+ /*gain=0.5f+log2f(gain)*2+16 becuase 2.885390081777927f=2*1/loge(2) so 2*1/loge(2)*loge(x) can be written as 2*log2(x)*/
+ gain_fx = L_add( ONE_IN_Q22, L_add( L_add( L_shr( BASOP_Util_Log2( gain_fx ), 1 ), L_shl( gain_e, Q24 ) ), L_shl( 16, Q23 ) ) ); /*Q23*/
+ IF( !isTransient && ( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) )
+ {
+ gain_fx = L_add( gain_fx, ONE_IN_Q21 ); /* better preservation of original HF band energy */
+ }
+ IF( !isTransient && ( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_64000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_64000_CPE ) ) )
+ {
+ gain_fx = L_add( gain_fx, ONE_IN_Q20 );
+ }
+ gain_fx = L_min( gain_fx, 91 << Q23 ); /* 13+15+63, see arithcode encode residual */
+ gain_fx = L_max( gain_fx, 0 );
+ gain_e = 8; /* stores exponent for gain_fx*/
+ move16();
+ hPrivateData->igfScfQuantized[sfb] = (Word16) ( L_shr( gain_fx, 23 ) ); /*Q0*/
+ }
+ }
+
+ return;
+}
+#endif
+/*-------------------------------------------------------------------*
+ * IGF_CalculateStereoEnvelope()
+ *
+ * envelope estimation
+ *-------------------------------------------------------------------*/
static void IGF_CalculateStereoEnvelope(
const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
const float *pMDCTSpectrum, /* i : MDCT spectrum */
@@ -699,8 +1488,8 @@ static void IGF_CalculateStereoEnvelope(
float diffSFM;
float shiftedSFM = 0.f;
- tmp_tb = IGF_getSFM( pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1] ) / IGF_getCrest( pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1] );
- tmp_sb = IGF_getSFM( tileSrcSpec, 0, strt_cpy - tmp ) / IGF_getCrest( tileSrcSpec, 0, strt_cpy - tmp );
+ tmp_tb = IGF_getSFM_ivas( pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1] ) / IGF_getCrest_ivas( pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1] );
+ tmp_sb = IGF_getSFM_ivas( tileSrcSpec, 0, strt_cpy - tmp ) / IGF_getCrest_ivas( tileSrcSpec, 0, strt_cpy - tmp );
if ( last_core_acelp || hPrivateData->wasTransient )
{
@@ -744,12 +1533,12 @@ static void IGF_CalculateStereoEnvelope(
if ( slope < -threshold )
{
int16_t shift = width >> 1;
- shiftedSFM = IGF_getSFM( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ) / IGF_getCrest( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift );
+ shiftedSFM = IGF_getSFM_ivas( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ) / IGF_getCrest_ivas( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift );
}
else if ( ( slope > 1.f * threshold ) && ( sfb != hGrid->sfbWrap[hGrid->nTiles] - 1 ) )
{
int16_t shift = width >> 1;
- shiftedSFM = IGF_getSFM( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ) / IGF_getCrest( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift );
+ shiftedSFM = IGF_getSFM_ivas( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ) / IGF_getCrest_ivas( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift );
}
alpha = min( 320.f / (float) swb_offset[sfb + 1], 1.25f );
@@ -920,7 +1709,7 @@ static int16_t IGF_WriteEnvelope(
*-------------------------------------------------------------------*/
/*! r: highPassEnergy */
-static float IGF_ErodeSpectrum(
+static float IGF_ErodeSpectrum_ivas(
const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
float *pSpectrum, /* i/o: MDCT spectrum */
float *pPowerSpectrum, /* i/o: power spectrum */
@@ -1049,6 +1838,453 @@ static float IGF_ErodeSpectrum(
*
* calculates the IGF whitening levels by SFM and crest
*-------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+static void IGF_Whitening_ivas_fx(
+ const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : | instance handle of IGF Encoder */
+ Word32 *powerSpectrum, /* i : Q31 | MDCT/MDST power spectrum */
+ Word16 *powerSpectrum_e, /* i : Q31 | MDCT/MDST power spectrum */
+ const Word16 igfGridIdx, /* i : Q0 | IGF grid index */
+ const Word16 isTransient, /* i : Q0 | flag indicating if transient is detected */
+ const Word16 last_core_acelp, /* i : Q0 | indicator if last frame was ACELP core */
+ const Word16 isTNSActive, /* i : Q0 | indicator if TNS is active */
+ const Word16 sp_aud_decision0, /* i : Q0 | first stage classifier decision */
+ const Word32 brate, /* i : Q0 | bitrate */
+ const Word16 element_mode /* i : Q0 | element mode */
+)
+{
+ IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData;
+ H_IGF_GRID hGrid;
+ Word16 p; /*Q0*/
+ Word16 tmp;
+ Word16 tmp_e;
+ Word16 SFM_src;
+ Word16 SFM_tar;
+ Word16 SFM_src_e;
+ Word16 SFM_tar_e;
+ Word16 num_Tiles;
+ Word16 SFM;
+ Word16 crest_e;
+
+ SFM = -ONE_IN_Q13; /*1.0f Q13*/
+ move16();
+
+ hPrivateData = &hIGFEnc->igfData;
+ hGrid = &hPrivateData->igfInfo.grid[(Word16) igfGridIdx];
+
+ IF( NE_16( igfGridIdx, IGF_GRID_LB_NORM ) )
+ {
+ FOR( p = 0; p < hGrid->nTiles; p++ )
+ {
+ /* reset filter */
+ hPrivateData->prevSFM_FIR[p] = L_deposit_l( 0 );
+ hPrivateData->prevSFM_IIR[p] = 0;
+ move16();
+
+ /* preset values: */
+ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_OFF;
+ move16();
+ }
+ }
+
+ FOR( p = 0; p < IGF_MAX_TILES; p++ )
+ {
+ /* update prev data: */
+ hPrivateData->igfPrevWhiteningLevel[p] = hPrivateData->igfCurrWhiteningLevel[p];
+ /* preset values: */
+ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_OFF;
+ move16();
+ move16();
+ }
+
+ test();
+ IF( !( isTransient || hPrivateData->wasTransient ) )
+ {
+ IF( powerSpectrum )
+ {
+ FOR( p = 0; p < hGrid->nTiles; p++ )
+ {
+ Word16 sb;
+
+ IF( isTNSActive )
+ {
+ FOR( sb = hGrid->tile[p]; sb < hGrid->tile[p + 1]; sb++ )
+ {
+ 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 ) ) );
+ move16();
+ }
+ }
+
+ /* if current tile contains only a single SFB, reuse already computed SFM values */
+ test();
+ IF( GT_16( element_mode, EVS_MONO ) && EQ_16( sub( hGrid->sfbWrap[p + 1], hGrid->sfbWrap[p] ), 1 ) )
+ {
+ tmp = hPrivateData->SFM_tb_fx[p];
+ tmp_e = hPrivateData->sfb_tb_e[p];
+ move16();
+ move16();
+ }
+ 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_e = sub( tmp_e, crest_e );
+ }
+
+ test();
+ IF( last_core_acelp || hPrivateData->wasTransient )
+ {
+ hPrivateData->prevSFM_FIR[p] = L_shl( tmp, add( 1, tmp_e ) ); /*16-(15-exp)=>15Q16*/
+ hPrivateData->prevSFM_IIR[p] = shl( tmp, sub( tmp_e, 2 ) ); /*13-(15-exp)=>2Q13*/
+ move32();
+ move16();
+ }
+
+ test();
+ IF( LE_32( brate, IVAS_48k ) && EQ_16( element_mode, IVAS_CPE_MDCT ) )
+ {
+ Word16 temp;
+ num_Tiles = 0;
+ SFM_src = 0;
+ SFM_tar = 0;
+ SFM_src_e = 0;
+ SFM_tar_e = 0;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+
+ FOR( sb = hGrid->sfbWrap[p]; sb < hGrid->sfbWrap[p + 1]; sb++ )
+ {
+ num_Tiles = add( num_Tiles, 1 );
+ SFM_src_e = BASOP_Util_Add_MantExp( hPrivateData->SFM_sb_fx[sb], hPrivateData->sfb_sb_e[sb], SFM_src, SFM_src_e, &SFM_src );
+ SFM_tar_e = BASOP_Util_Add_MantExp( hPrivateData->SFM_tb_fx[sb], hPrivateData->sfb_tb_e[sb], SFM_tar, SFM_tar_e, &SFM_tar );
+ }
+
+ /* compute the average */
+ SFM_src = shr( BASOP_Util_Divide1616_Scale( SFM_src, num_Tiles, &temp ), 2 );
+ SFM_src_e = add( SFM_src_e, sub( temp, 13 ) ); /*temp-15+2:because right shifted by 2 which are the guard bits*/
+ SFM_tar = shr( BASOP_Util_Divide1616_Scale( SFM_tar, num_Tiles, &temp ), 2 );
+ SFM_tar_e = add( SFM_tar_e, sub( temp, 13 ) ); /*temp-15+2:because right shifted by 2 which are the guard bits*/
+
+ IF( LT_16( SFM_tar_e, SFM_src_e ) )
+ {
+ SFM_tar = shl( SFM_tar, sub( SFM_tar_e, SFM_src_e ) ); /*making the q for SFM_tar and SFM_src equal with 2 as guard bits*/
+ SFM_tar_e = SFM_src_e;
+ }
+ ELSE
+ {
+ SFM_src = shr( SFM_src, sub( SFM_tar_e, SFM_src_e ) ); /*making the q for SFM_tar and SFM_src equal with 2 as guard bits*/
+ SFM_src_e = SFM_tar_e;
+ }
+ move16();
+
+ test();
+ test();
+ IF( ( p > 0 ) && ( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) )
+ {
+ test();
+ if ( EQ_16( p, 1 ) && EQ_16( abs_s( sub( hPrivateData->igfCurrWhiteningLevel[0], hPrivateData->igfCurrWhiteningLevel[1] ) ), 2 ) ) /* OFF vs. STRONG */
+ {
+ hPrivateData->igfCurrWhiteningLevel[0] = IGF_WHITENING_MID;
+ move16();
+ }
+ hPrivateData->igfCurrWhiteningLevel[p] = hPrivateData->igfCurrWhiteningLevel[p - 1];
+ move16();
+ }
+ ELSE IF( sp_aud_decision0 )
+ {
+ /* Music */
+ /* whitening Off: when tonality of target is more than source or tonality of target is close to that of source */
+ test();
+ if ( LE_16( SFM_tar, SFM_src ) || LE_32( SFM_tar, L_add( SFM_src, L_shl( 1, sub( 14, SFM_src_e /*0.5 with exponent SFM_src_e*/ ) ) ) ) )
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_OFF;
+ move16();
+ }
+
+ /* whitening mid: */
+ test();
+ if ( GT_32( SFM_tar, L_add( SFM_src, L_shl( 1, sub( 14, SFM_src_e /*0.5 with exponent SFM_src_e*/ ) ) ) ) && LE_32( SFM_tar, L_add( SFM_src, L_shl( 5, sub( 13, SFM_src_e ) ) /*1.25 with exponent SFM_src_e*/ ) ) )
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_MID;
+ move16();
+ }
+
+ /* whitening strong */
+ if ( GT_32( SFM_tar, L_add( SFM_src, L_shl( 5, sub( 13, SFM_src_e ) ) /*1.25 with exponent SFM_src_e*/ ) ) )
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_STRONG;
+ move16();
+ }
+ }
+ ELSE
+ {
+ /* Speech */
+ /* whitening Off: when tonality of target is more than source or tonality of target is close to that of source */
+ test();
+ if ( LE_16( SFM_tar, SFM_src ) || LE_32( SFM_tar, L_add( SFM_src, L_shr( 3277 /*0.1 Q15*/, SFM_src_e ) ) ) )
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_OFF;
+ move16();
+ }
+
+ /* whitening mid: */
+ test();
+ if ( GT_32( SFM_tar, L_add( SFM_src, L_shr( 3277 /*0.1 Q15*/, SFM_src_e ) ) ) && LE_32( SFM_tar, L_add( SFM_src, L_shl( 1, sub( 14, SFM_src_e /*0.5 with exponent SFM_src_e*/ ) ) ) ) )
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_MID;
+ move16();
+ }
+
+ /* whitening strong */
+ if ( GT_32( SFM_tar, L_add( SFM_src, L_shl( 1, sub( 14, SFM_src_e /*0.5 with exponent SFM_src_e*/ ) ) ) ) )
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_STRONG;
+ move16();
+ }
+ }
+
+ SFM = shl( SFM_tar, sub( SFM_tar_e, 2 ) ); /*2Q13*/
+ }
+ ELSE
+ {
+ test();
+ IF( GT_16( element_mode, EVS_MONO ) && EQ_16( sub( hGrid->sfbWrap[p + 1], hGrid->sfbWrap[p] ), 1 ) )
+ {
+ SFM = shl( tmp, sub( tmp_e, 2 ) ); /*2Q13*/
+ }
+ ELSE
+ {
+ Word32 temp;
+ temp = L_add( L_shl( tmp, sub( tmp_e, 2 ) ), L_add( L_shr( hPrivateData->prevSFM_FIR[p], 3 ), L_shr( hPrivateData->prevSFM_IIR[p], 1 ) ) );
+ SFM = extract_l( L_min( 22118 /*2.7*/, temp ) ); /*2Q13*/
+ }
+ hPrivateData->prevSFM_FIR[p] = L_shl( tmp, add( 1, tmp_e ) ); /*15Q16*/
+ hPrivateData->prevSFM_IIR[p] = SFM;
+ move32();
+ move16();
+
+ IF( GT_16( SFM, hGrid->whiteningThreshold[1][p] ) )
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_STRONG;
+ move16();
+ }
+ ELSE IF( GT_16( SFM, hGrid->whiteningThreshold[0][p] ) )
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_MID;
+ move16();
+ }
+ ELSE
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_OFF;
+ move16();
+ }
+ }
+
+ IF( GT_16( element_mode, EVS_MONO ) )
+ {
+ IF( last_core_acelp ) /* reset */
+ {
+ set16_fx( hPrivateData->igfPastSFM_fx[p], -ONE_IN_Q13, IGF_PAST_SFM_LEN );
+ hPrivateData->igfWhiteningHangoverCnt[p] = 2;
+ move16();
+ }
+ ELSE
+ {
+ test();
+ test();
+ test();
+ test();
+ /* check whether change in whitening level should be allowed or not (if SFM is inside a certain margin around thresholds) */
+ IF( NE_16( hPrivateData->igfCurrWhiteningLevel[p], hPrivateData->igfPrevWhiteningLevel[p] ) &&
+ ( ( GT_32( SFM, L_sub( hGrid->whiteningThreshold[0][p], 1229 /*0.15f Q13*/ ) ) && LT_32( SFM, L_add( hGrid->whiteningThreshold[0][p], 1229 ) ) ) ||
+ ( GT_32( SFM, L_sub( hGrid->whiteningThreshold[1][p], 1229 ) ) && LT_32( SFM, L_add( hGrid->whiteningThreshold[1][p], 1229 ) ) ) ) )
+ {
+ Word16 mean_past_SFM;
+ Word16 mean_past_SFM_e;
+ Word16 countable;
+ Word16 i;
+ mean_past_SFM = 0;
+ mean_past_SFM_e = 0;
+ countable = 0;
+ move16();
+ move16();
+ move16();
+
+ /* compute mean of last (available) SFM values */
+ FOR( i = 0; i < IGF_PAST_SFM_LEN; i++ )
+ {
+ IF( hPrivateData->igfPastSFM_fx[p][i] >= 0 )
+ {
+ mean_past_SFM_e = BASOP_Util_Add_MantExp( mean_past_SFM, mean_past_SFM_e, hPrivateData->igfPastSFM_fx[p][i], 2, &mean_past_SFM );
+ countable = add( countable, 1 );
+ }
+ }
+ IF( countable )
+ {
+ Word16 temp;
+ mean_past_SFM = BASOP_Util_Divide1616_Scale( mean_past_SFM, countable, &temp );
+ mean_past_SFM_e = add( mean_past_SFM_e, sub( temp, 15 ) );
+ mean_past_SFM = shl( mean_past_SFM, sub( mean_past_SFM_e, 2 ) ); /*mean_past_SFM_e=2*/
+ /* deny change in whitening level for small deviations from mean SFM */
+ if ( LT_16( abs_s( sub( SFM, mean_past_SFM ) ), 1638 ) /*0.2 in Q13*/ )
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = hPrivateData->igfPrevWhiteningLevel[p];
+ move16();
+ }
+ }
+ }
+ }
+
+ hPrivateData->igfPastSFM_fx[p][hPrivateData->igfPastSFM_pos] = SFM; /*2Q13*/
+ move16();
+ }
+ }
+
+ SWITCH( hPrivateData->igfInfo.bitRateIndex )
+ {
+ case IGF_BITRATE_WB_9600:
+ case IGF_BITRATE_RF_WB_13200:
+ case IGF_BITRATE_WB_13200_CPE:
+ case IGF_BITRATE_WB_16400_CPE:
+ case IGF_BITRATE_RF_SWB_13200:
+ case IGF_BITRATE_SWB_9600:
+ case IGF_BITRATE_SWB_13200_CPE:
+ case IGF_BITRATE_SWB_16400:
+ case IGF_BITRATE_SWB_24400:
+ case IGF_BITRATE_SWB_24400_CPE:
+ case IGF_BITRATE_SWB_32000_CPE:
+ case IGF_BITRATE_SWB_32000:
+ case IGF_BITRATE_FB_16400:
+ case IGF_BITRATE_FB_24400:
+ case IGF_BITRATE_FB_24400_CPE:
+ case IGF_BITRATE_FB_32000_CPE:
+ case IGF_BITRATE_FB_32000:
+ hPrivateData->igfCurrWhiteningLevel[hGrid->nTiles - 1] = hPrivateData->igfCurrWhiteningLevel[hGrid->nTiles - 2];
+ move16();
+ break;
+ default:
+ break;
+ }
+ }
+ ELSE
+ {
+ FOR( p = 0; p < hGrid->nTiles; p++ )
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = IGF_WHITENING_MID;
+ move16();
+ }
+ }
+ }
+ ELSE
+ {
+ /* reset filter */
+ FOR( p = 0; p < IGF_MAX_TILES; p++ )
+ {
+ hPrivateData->prevSFM_FIR[p] = L_deposit_l( 0 );
+ hPrivateData->prevSFM_IIR[p] = 0;
+ move32();
+ move16();
+ }
+ }
+
+ IF( GT_16( element_mode, EVS_MONO ) )
+ {
+ IF( EQ_16( SFM, -ONE_IN_Q13 /*1.0f 2Q13*/ ) ) /* reset */
+ {
+ FOR( p = 0; p < hGrid->nTiles; p++ )
+ {
+ set16_fx( hPrivateData->igfPastSFM_fx[p], -ONE_IN_Q13, IGF_PAST_SFM_LEN );
+ hPrivateData->igfWhiteningHangoverCnt[p] = 2;
+ move16();
+ }
+ }
+
+ /* vibrato handling */
+ FOR( p = 0; p < hGrid->nTiles; p = p + 2 )
+ {
+ test();
+ test();
+ test();
+ IF( ( EQ_16( hPrivateData->igfPrevWhiteningLevel[p], IGF_WHITENING_OFF ) && NE_16( hPrivateData->igfCurrWhiteningLevel[p], IGF_WHITENING_OFF ) ) ||
+ ( EQ_16( hPrivateData->igfPrevWhiteningLevel[p + 1], IGF_WHITENING_OFF ) && NE_16( hPrivateData->igfCurrWhiteningLevel[p + 1], IGF_WHITENING_OFF ) ) )
+ {
+ Word16 i;
+ Word16 pastSfm_a[4], pastSfm_b[4];
+ Word16 pastSfmDiffSum_a, pastSfmDiffSum_b;
+
+ FOR( i = 0; i < 4; i++ )
+ {
+ pastSfm_a[i] = hPrivateData->igfPastSFM_fx[p][add( hPrivateData->igfPastSFM_pos, sub( 4, i ) ) % IGF_PAST_SFM_LEN];
+ pastSfm_b[i] = hPrivateData->igfPastSFM_fx[p + 1][add( hPrivateData->igfPastSFM_pos, sub( 4, i ) ) % IGF_PAST_SFM_LEN];
+ move16();
+ move16();
+ }
+ pastSfmDiffSum_a = pastSfmDiffSum_b = 0;
+ move16();
+ move16();
+ FOR( i = 0; i < 3; i++ )
+ {
+ IF( NE_16( pastSfm_a[i + 1], -ONE_IN_Q13 ) )
+ {
+ pastSfmDiffSum_a = add( pastSfmDiffSum_a, sub( pastSfm_a[i], pastSfm_a[i + 1] ) );
+ pastSfmDiffSum_b = add( pastSfmDiffSum_b, sub( pastSfm_b[i], pastSfm_b[i + 1] ) );
+ }
+ ELSE
+ {
+ break;
+ }
+ }
+
+ /* if tonality oscillates between two tiles, turn whitening off in both */
+ IF( ( ( pastSfmDiffSum_a > 0 && pastSfmDiffSum_b < 0 ) ||
+ ( pastSfmDiffSum_a < 0 && pastSfmDiffSum_b > 0 ) ) &&
+ ( GT_16( abs_s( sub( pastSfmDiffSum_a, pastSfmDiffSum_b ) ), ONE_IN_Q13 ) ) )
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = hPrivateData->igfCurrWhiteningLevel[p + 1] = IGF_WHITENING_OFF;
+ move16();
+ move16();
+ }
+ }
+ }
+
+ /* hangover */
+ FOR( p = 0; p < hGrid->nTiles; p++ )
+ {
+ IF( NE_16( hPrivateData->igfCurrWhiteningLevel[p], hPrivateData->igfPrevWhiteningLevel[p] ) )
+ {
+ hPrivateData->igfWhiteningHangoverCnt[p] = add( hPrivateData->igfWhiteningHangoverCnt[p], 1 );
+ IF( EQ_16( hPrivateData->igfWhiteningHangoverCnt[p], 3 ) )
+ {
+ hPrivateData->igfWhiteningHangoverCnt[p] = 0;
+ }
+ ELSE
+ {
+ hPrivateData->igfCurrWhiteningLevel[p] = hPrivateData->igfPrevWhiteningLevel[p];
+ }
+ move16();
+ move16();
+ }
+ ELSE
+ {
+ hPrivateData->igfWhiteningHangoverCnt[p] = 0;
+ move16();
+ }
+ }
+
+ hPrivateData->igfPastSFM_pos = add( hPrivateData->igfPastSFM_pos, 1 ) % IGF_PAST_SFM_LEN;
+ move16();
+ }
+
+ hPrivateData->wasTransient = isTransient;
+ move16();
+
+ return;
+}
+#endif // IVAS_FLOAT_FIXED
static void IGF_Whitening(
const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : | instance handle of IGF Encoder */
@@ -1056,7 +2292,7 @@ static void IGF_Whitening(
const int16_t igfGridIdx, /* i : Q0 | IGF grid index */
const int16_t isTransient, /* i : Q0 | flag indicating if transient is detected */
const int16_t last_core_acelp, /* i : Q0 | indicator if last frame was ACELP core */
- const int16_t isTNSActive, /* i : Q0 | indicator if TNS is active */
+ const int8_t isTNSActive, /* i : Q0 | indicator if TNS is active */
const int16_t sp_aud_decision0, /* i : Q0 | first stage classifier decision */
const int32_t brate, /* i : Q0 | bitrate */
const int16_t element_mode /* i : Q0 | element mode */
@@ -1567,7 +2803,7 @@ static int16_t IGF_WriteFlatteningTrigger(
* updates the start/stop frequency of IGF according to igfGridIdx
*-------------------------------------------------------------------*/
-static void IGF_UpdateInfo(
+static void IGF_UpdateInfo_ivas(
const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
const int16_t igfGridIdx /* i : IGF grid index */
)
@@ -1864,7 +3100,7 @@ void IGFEncApplyMono(
float *pMDCTSpectrum, /* i/o: MDCT spectrum */
float *pPowerSpectrum, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
- const int16_t isTNSActive, /* i : flag indicating if the TNS is active */
+ const int8_t isTNSActive, /* i : flag indicating if the TNS is active */
const int16_t sp_aud_decision0, /* i : first stage switching decision */
const int16_t vad_hover_flag /* i : VAD hangover flag */
)
@@ -1877,7 +3113,7 @@ void IGFEncApplyMono(
pPowerSpectrumParameter = !isTNSActive && isTCX20 ? pPowerSpectrum : NULL;
- IGF_UpdateInfo( st->hIGFEnc, igfGridIdx );
+ IGF_UpdateInfo_ivas( st->hIGFEnc, igfGridIdx );
if ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD )
{
@@ -1891,7 +3127,7 @@ void IGFEncApplyMono(
IGF_Whitening( st->hIGFEnc, pPowerSpectrumParameter, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, ( st->element_mode == IVAS_CPE_MDCT ? st->element_brate : st->total_brate ), st->element_mode );
- IGF_ErodeSpectrum( st->hIGFEnc, pMDCTSpectrum, pPowerSpectrumParameter, igfGridIdx, 0 );
+ IGF_ErodeSpectrum_ivas( st->hIGFEnc, pMDCTSpectrum, pPowerSpectrumParameter, igfGridIdx, 0 );
return;
}
@@ -1902,6 +3138,99 @@ void IGFEncApplyMono(
*
* apply the IGF encoder, main encoder interface
*-------------------------------------------------------------------*/
+#ifdef IVAS_FLOAT_FIXED
+void IGFEncApplyStereo_fx(
+ STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */
+ Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */
+ const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */
+ const Word16 igfGridIdx, /* i : IGF grid index */
+ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */
+ Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */
+ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */
+ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */
+ const Word16 frameno, /* i : flag indicating index of current subfr. */
+ const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */
+ const Word32 element_brate, /* i : element bitrate */
+ const Word16 mct_on /* i : flag mct block (1) or stereo (0) */
+)
+{
+ UNUSED_PARAM( mct_on );
+ Word16 highPassEner_exp;
+ Word32 *pPowerSpectrumParameter_fx[NB_DIV]; /* If it is NULL it informs a function that specific handling is needed */
+ Word32 *pPowerSpectrumParameterMsInv_fx[NB_DIV];
+ Word16 coreMsMask[N_MAX];
+ Word16 sfb, ch, last_core_acelp;
+ STEREO_MDCT_BAND_PARAMETERS *sfbConf;
+
+ /* 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)
+ * for residual bands with stereo filling infoTcxNoise is set to zero
+ * both channels have the same IGF configuration
+ */
+
+ /* sanity checks: check if both channels have the same configuration...*/
+ assert( ( sts[0]->core == sts[1]->core ) );
+
+ /* initialization */
+ IF( EQ_16( sts[0]->core, TCX_20_CORE ) )
+ {
+ sfbConf = &hStereoMdct->stbParamsTCX20;
+ }
+ ELSE
+ {
+ sfbConf = &hStereoMdct->stbParamsTCX10;
+ }
+ if ( EQ_16( sts[0]->last_core, ACELP_CORE ) )
+ {
+ sfbConf = &hStereoMdct->stbParamsTCX20afterACELP;
+ }
+
+ /* create line wise ms mask for the core bands */
+ set16_fx( coreMsMask, 0, N_MAX );
+ FOR( sfb = 0; sfb < sfbConf->sfbCnt; sfb++ )
+ {
+ set16_fx( &coreMsMask[sfbConf->sfbOffset[sfb]], ms_mask[frameno][sfb], sub( sfbConf->sfbOffset[sfb + 1], sfbConf->sfbOffset[sfb] ) );
+ }
+
+ test();
+ test();
+ IF( EQ_16( sts[0]->core, TCX_20_CORE ) && !sts[0]->hTcxEnc->fUseTns[frameno] && !sts[1]->hTcxEnc->fUseTns[frameno] )
+ {
+ pPowerSpectrumParameter_fx[0] = &pPowerSpectrum_fx[0][0];
+ pPowerSpectrumParameter_fx[1] = &pPowerSpectrum_fx[1][0];
+ pPowerSpectrumParameterMsInv_fx[0] = pPowerSpectrumMsInv_fx[0][0];
+ pPowerSpectrumParameterMsInv_fx[1] = pPowerSpectrumMsInv_fx[1][0];
+ }
+ ELSE
+ {
+ pPowerSpectrumParameter_fx[0] = NULL;
+ pPowerSpectrumParameter_fx[1] = NULL;
+ pPowerSpectrumParameterMsInv_fx[0] = NULL;
+ pPowerSpectrumParameterMsInv_fx[1] = NULL;
+ }
+ FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
+ {
+ last_core_acelp = extract_l( EQ_16( sts[ch]->last_core, ACELP_CORE ) );
+
+ IGF_UpdateInfo( hIGFEnc[ch], igfGridIdx );
+ IGF_CalculateStereoEnvelope_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], sts[ch]->hTcxEnc->spectrum_e[frameno], inv_spectrum_fx[ch][frameno], sts[ch]->hTcxEnc->spectrum_e[frameno], pPowerSpectrumParameter_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], pPowerSpectrumParameterMsInv_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], igfGridIdx, coreMsMask, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp );
+
+ IF( EQ_16( sts[ch]->core, TCX_20_CORE ) )
+ {
+ pPowerSpectrumParameter_fx[ch] = pPowerSpectrum_fx[ch];
+ }
+ ELSE
+ {
+ 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 );
+
+ IGF_ErodeSpectrum( &highPassEner_exp, hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], igfGridIdx );
+ }
+ return;
+}
+#endif // IVAS_FLOAT_FIXED
void IGFEncApplyStereo(
STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */
@@ -1966,7 +3295,7 @@ void IGFEncApplyStereo(
{
last_core_acelp = ( sts[ch]->last_core == ACELP_CORE );
- IGF_UpdateInfo( hIGFEnc[ch], igfGridIdx );
+ IGF_UpdateInfo_ivas( hIGFEnc[ch], igfGridIdx );
IGF_CalculateStereoEnvelope( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum[frameno], inv_spectrum[ch][frameno], pPowerSpectrumParameter[ch], pPowerSpectrumParameterMsInv[ch], igfGridIdx, coreMsMask, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp );
@@ -1974,7 +3303,7 @@ void IGFEncApplyStereo(
IGF_Whitening( hIGFEnc[ch], pPowerSpectrumParameter[ch], igfGridIdx, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, ( sts[0]->hTcxEnc->fUseTns[frameno] || sts[1]->hTcxEnc->fUseTns[frameno] ), sp_aud_decision0, element_brate, sts[ch]->element_mode );
- IGF_ErodeSpectrum( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum[frameno], pPowerSpectrumParameter[ch], igfGridIdx, mct_on );
+ IGF_ErodeSpectrum_ivas( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum[frameno], pPowerSpectrumParameter[ch], igfGridIdx, mct_on );
}
return;
@@ -1993,7 +3322,7 @@ void IGFSaveSpectrumForITF(
const float *pITFSpectrum /* i : MDCT spectrum */
)
{
- IGF_UpdateInfo( hIGFEnc, igfGridIdx );
+ IGF_UpdateInfo_ivas( hIGFEnc, igfGridIdx );
mvr2r( pITFSpectrum + IGF_START_MN, hIGFEnc->spec_be_igf_flt, hIGFEnc->infoStopLine - IGF_START_MN );
diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c
index 1841bd93a809fe6189943dd6bdb7a149852d2c59..b179794af933b6cde5ab766792471f36189c274d 100644
--- a/lib_enc/igf_enc_fx.c
+++ b/lib_enc/igf_enc_fx.c
@@ -9,8 +9,7 @@
#include "cnst.h"
#include "stl.h"
//#include "prot_fx.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "stat_enc.h"
#include "basop_util.h"
@@ -366,12 +365,12 @@ static void IGF_WriteEnvelope( /**< ou
/**********************************************************************/ /*
identifies significant spectral content
**************************************************************************/
-static void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< out: | exponent of highPassEner */
- const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
- Word32 *pSpectrum, /**< in/out: | MDCT spectrum */
- Word32 *pPowerSpectrum, /**< in/out: | power spectrum */
- Word16 pPowerSpectrum_exp, /**< in: | exponent of power spectrum */
- const Word16 igfGridIdx /**< in: Q0 | IGF grid index */
+void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< out: | exponent of highPassEner */
+ const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
+ Word32 *pSpectrum, /**< in/out: | MDCT spectrum */
+ Word32 *pPowerSpectrum, /**< in/out: | power spectrum */
+ Word16 pPowerSpectrum_exp, /**< in: | exponent of power spectrum */
+ const Word16 igfGridIdx /**< in: Q0 | IGF grid index */
)
{
IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData;
@@ -566,12 +565,12 @@ static void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou
/**********************************************************************/ /*
crest factor calculation
**************************************************************************/
-static Word16 IGF_getCrest( /**< out: Q15| crest factor */
- Word16 *crest_exp, /**< out: | exponent of crest factor */
- const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */
- const Word16 powerSpectrum_exp, /**< in: | exponent of power spectrum */
- const Word16 start, /**< in: Q0 | start subband index */
- const Word16 stop /**< in: Q0 | stop subband index */
+Word16 IGF_getCrest( /**< out: Q15| crest factor */
+ Word16 *crest_exp, /**< out: | exponent of crest factor */
+ const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */
+ const Word16 powerSpectrum_exp, /**< in: | exponent of power spectrum */
+ const Word16 start, /**< in: Q0 | start subband index */
+ const Word16 stop /**< in: Q0 | stop subband index */
)
{
Word16 i;
@@ -655,12 +654,12 @@ static Word16 IGF_getCrest( /**< ou
/*************************************************************************
calculates spectral flatness measurment
**************************************************************************/
-static Word16 IGF_getSFM( /**< out: Q15| SFM value */
- Word16 *SFM_exp, /**< out: | exponent of SFM Factor */
- const Word32 *energy, /**< in: Q31| energies */
- const Word16 *energy_exp, /**< in: | exponent of energies */
- const Word16 start, /**< in: Q0 | start subband index */
- const Word16 stop /**< in: Q0 | stop subband index */
+Word16 IGF_getSFM( /**< out: Q15| SFM value */
+ Word16 *SFM_exp, /**< out: | exponent of SFM Factor */
+ const Word32 *energy, /**< in: Q31| energies */
+ const Word16 *energy_exp, /**< in: | exponent of energies */
+ const Word16 start, /**< in: Q0 | start subband index */
+ const Word16 stop /**< in: Q0 | stop subband index */
)
{
Word16 n, i, s;
@@ -1084,8 +1083,8 @@ static void IGF_WriteFlatteningTrigger(
/**********************************************************************/ /*
updates the start/stop frequency of IGF according to igfGridIdx
**************************************************************************/
-static void IGF_UpdateInfo( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
- const Word16 igfGridIdx /**< in: Q0 | IGF grid index */
+void IGF_UpdateInfo( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
+ const Word16 igfGridIdx /**< in: Q0 | IGF grid index */
)
{
IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData;
diff --git a/lib_enc/igf_scf_enc_fx.c b/lib_enc/igf_scf_enc_fx.c
index b5a74687ac5b33a8ad82fd3170b1500eff093647..58b8358037850a5a035f8b0c3d53a94c184be044 100644
--- a/lib_enc/igf_scf_enc_fx.c
+++ b/lib_enc/igf_scf_enc_fx.c
@@ -9,8 +9,7 @@
#include "stat_enc.h"
#include "stat_com.h"
#include "basop_util.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c
index c76392ff97c602c43d532d36aea0bd6b32a49a02..3a9cf28d420acfbf6eea8657b1fe4435c14fdbd6 100644
--- a/lib_enc/init_enc.c
+++ b/lib_enc/init_enc.c
@@ -41,6 +41,7 @@
#include "rom_enc.h"
#include "prot.h"
#include "ivas_prot.h"
+#include "prot_fx.h"
#include "ivas_cnst.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
@@ -162,7 +163,11 @@ ivas_error init_encoder(
st->mem_preemph = 0.0f;
st->mem_preemph16k = 0.0f;
st->mem_preemph_enc_flt = 0.0;
-
+#ifdef IVAS_FLOAT_FIXED
+ st->mem_preemph_fx = 0;
+ st->mem_preemph16k_fx = 0;
+ st->mem_preemph_enc = 0;
+#endif
/* AVQ pre-quantizer memory */
st->mem_preemp_preQ = 0.0f;
st->mem_deemp_preQ = 0.0f;
@@ -233,9 +238,13 @@ ivas_error init_encoder(
set_f( st->inp_12k8_mem_stereo_sw, 0, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT );
st->mem_preemph16k_DFT = 0.0f;
set_f( st->inp_16k_mem_stereo_sw, 0, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k );
-
+#ifdef IVAS_FLOAT_FIXED
+ st->mem_preemph_DFT_fx = 0;
+ set16_fx( st->inp_12k8_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_12k8, L_MEM_RECALC_12K8 ), L_FILT ) );
+ st->mem_preemph16k_DFT_fx = 0;
+ set16_fx( st->inp_16k_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_16k, L_MEM_RECALC_16K ), L_FILT16k ) );
st->sharpFlag = 0;
-
+#endif
/* Stationary noise UV modification */
st->ge_sm = 10;
st->uv_count = 0;
@@ -268,7 +277,13 @@ ivas_error init_encoder(
st->predecision_flag = 0;
st->diff_sm = 0;
st->energy_sm = 0;
-
+#ifdef IVAS_FLOAT_FIXED
+ st->voicing0_sm_fx = 0;
+ st->voicing_sm_fx = 0;
+ st->LF_EnergyRatio_sm_fx = ONE_IN_Q7;
+ st->diff_sm_fx = 0;
+ st->energy_sm_fx = 0;
+#endif
set_s( st->pitch, L_SUBFR, 3 );
set_f( st->voicing, 0.0f, 3 );
@@ -284,32 +299,73 @@ ivas_error init_encoder(
}
st->Bin_E_old = st->hSignalBuf->Bin_E_old_flt;
+#ifdef IVAS_FLOAT_FIXED
+ st->Bin_E_old_fx = st->hSignalBuf->Bin_E_old_fx;
+#endif
st->mem_decim = st->hSignalBuf->mem_decim_flt;
st->mem_decim16k = st->hSignalBuf->mem_decim16k_flt;
st->old_inp_12k8 = st->hSignalBuf->old_inp_12k8_flt;
st->old_inp_16k = st->hSignalBuf->old_inp_16k_flt;
+#ifdef IVAS_FLOAT_FIXED
+ st->Bin_E_old_fx = st->hSignalBuf->Bin_E_old_fx;
+ st->old_inp_12k8_fx = st->hSignalBuf->old_inp_12k8_fx;
+ st->old_inp_16k_fx = st->hSignalBuf->old_inp_16k_fx;
+ st->mem_decim_fx = st->hSignalBuf->mem_decim_fx;
+#endif
st->buf_speech_enc_pe_flt = st->hSignalBuf->buf_speech_enc_pe_flt;
st->buf_synth_flt = st->hSignalBuf->buf_synth_flt;
st->buf_speech_enc_flt = st->hSignalBuf->buf_speech_enc_flt;
st->buf_wspeech_enc_flt = st->hSignalBuf->buf_wspeech_enc_flt;
+#ifdef IVAS_FLOAT_FIXED
+ st->buf_speech_enc_pe = st->hSignalBuf->buf_speech_enc_pe;
+ st->buf_synth = st->hSignalBuf->buf_synth;
+ st->buf_speech_enc = st->hSignalBuf->buf_speech_enc;
+ st->buf_wspeech_enc = st->hSignalBuf->buf_wspeech_enc;
+#endif
/* initializations */
set_f( st->Bin_E_old, 0, L_FFT / 2 );
+#ifdef IVAS_FLOAT_FIXED
+ set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 );
+#endif
set_f( st->mem_decim, 0, 2 * L_FILT_MAX );
set_f( st->mem_decim16k, 0, 2 * L_FILT_MAX );
set_f( st->old_inp_12k8, 0, L_INP_MEM );
set_f( st->old_inp_16k, 0, L_INP_MEM );
-
+#ifdef IVAS_FLOAT_FIXED
+ set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 );
+ set16_fx( st->old_inp_12k8_fx, 0, L_INP_MEM );
+ set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM );
+ set16_fx( st->mem_decim_fx, 0, 2 * L_FILT_MAX );
+ st->input_buff_fx = st->hSignalBuf->input_buff;
+ st->input_buff32_fx = st->hSignalBuf->input_buff32;
+#endif
st->input_buff = st->hSignalBuf->input_buff_flt;
set_zero( st->input_buff, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) );
st->old_input_signal = st->input_buff;
+#ifdef IVAS_FLOAT_FIXED
+ st->input_buff_fx = st->hSignalBuf->input_buff;
+ set16_fx( st->input_buff_fx, 0, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) );
+ st->old_input_signal_fx = st->input_buff_fx;
+#endif
if ( st->element_mode == EVS_MONO )
{
+#ifdef IVAS_FLOAT_FIXED
+ st->input_fx = st->input_buff_fx + st->input_Fs / FRAMES_PER_SEC + NS2SA_fx2( st->input_Fs, DELAY_FIR_RESAMPL_NS );
+ st->input32_fx = st->input_buff32_fx + st->input_Fs / FRAMES_PER_SEC + NS2SA_fx2( st->input_Fs, DELAY_FIR_RESAMPL_NS );
+#endif // IVAS_FLOAT_FIXED
st->input = st->input_buff + st->input_Fs / FRAMES_PER_SEC + NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS );
}
else
{
+#ifdef IVAS_FLOAT_FIXED
+ st->input_fx = st->input_buff_fx + st->input_Fs / FRAMES_PER_SEC;
+ st->input32_fx = st->input_buff32_fx + st->input_Fs / FRAMES_PER_SEC;
+#endif // IVAS_FLOAT_FIXED
st->input = st->input_buff + st->input_Fs / FRAMES_PER_SEC;
+#ifdef IVAS_FLOAT_FIXED
+ st->input_fx = st->input_buff_fx + st->input_Fs / FRAMES_PER_SEC;
+#endif
}
}
else
@@ -317,12 +373,18 @@ ivas_error init_encoder(
st->hSignalBuf = NULL;
st->Bin_E_old = NULL;
st->mem_decim = NULL;
+#ifdef IVAS_FLOAT_FIXED
+ st->mem_decim_fx = NULL;
+#endif
st->mem_decim16k = NULL;
st->old_inp_12k8 = NULL;
st->old_inp_16k = NULL;
st->buf_speech_enc_pe_flt = NULL;
st->buf_synth_flt = NULL;
st->buf_speech_enc_flt = NULL;
+#ifdef IVAS_FLOAT_FIXED
+ st->buf_speech_enc = NULL;
+#endif
st->buf_wspeech_enc_flt = NULL;
st->input_buff = NULL;
}
@@ -428,10 +490,16 @@ ivas_error init_encoder(
st->lp_speech = 45.0f; /* Initialize the long-term active speech level in dB */
st->lp_noise = 0.0f;
+#ifdef IVAS_FLOAT_FIXED
+ st->lp_noise_fx = 0;
+#endif
st->flag_noisy_speech_snr = 0;
st->fd_cng_reset_flag = 0;
st->cng_type = -1;
st->bckr_tilt_lt_flt = 0.f;
+#ifdef IVAS_FLOAT_FIXED
+ st->bckr_tilt_lt = 0;
+#endif
st->active_cnt = 0;
if ( ( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO ) || ( st->element_mode == IVAS_CPE_MDCT && st->Opt_DTX_ON ) )
@@ -441,6 +509,9 @@ ivas_error init_encoder(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) );
}
dtx_enc_init( st, var_SID_rate_flag, interval_SID );
+#ifdef IVAS_FLOAT_FIXED
+ dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID );
+#endif
}
else
{
@@ -504,7 +575,11 @@ ivas_error init_encoder(
if ( ( st->element_mode != IVAS_CPE_MDCT && idchan == 0 ) || ( st->element_mode == IVAS_CPE_MDCT && st->Opt_DTX_ON ) )
{
+#ifdef IVAS_FLOAT_FIXED
+ if ( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+#else
if ( ( error = openCldfb_ivas( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+#endif
{
return error;
}
@@ -513,7 +588,10 @@ ivas_error init_encoder(
{
st->cldfbAnaEnc = NULL;
}
-
+#ifdef IVAS_FLOAT_FIXED
+ st->energyCoreLookahead_Fx = 0;
+ st->sf_energyCoreLookahead_Fx = 0;
+#endif
st->currEnergyLookAhead = 6.1e-5f;
/*-----------------------------------------------------------------*
@@ -604,8 +682,11 @@ ivas_error init_encoder(
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) );
}
-
+#ifdef IVAS_FLOAT_FIXED
+ if ( ( error = openCldfb_ivas_enc( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+#else
if ( ( error = openCldfb_ivas( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+#endif
{
return error;
}
@@ -722,6 +803,11 @@ ivas_error init_encoder(
}
/* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */
+#ifdef IVAS_FLOAT_FIXED
+ st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx;
+ st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX;
+#endif // IVAS_FLOAT_FIXED
+
st->hTcxEnc->spectrum[0] = st->hTcxEnc->spectrum_long;
st->hTcxEnc->spectrum[1] = st->hTcxEnc->spectrum_long + N_TCX10_MAX;
@@ -841,7 +927,9 @@ ivas_error init_encoder(
}
initFdCngEnc( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale_flt );
-
+#ifdef IVAS_FLOAT_FIXED
+ initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale );
+#endif
/* initialization for IVAS modes happens in first frame pre-processing */
if ( st->element_mode == EVS_MONO )
{
@@ -879,7 +967,22 @@ ivas_error init_encoder(
st->cng_sba_flag = 0;
st->bits_frame_channel = 0;
st->side_bits_frame_channel = 0;
-
+#ifdef IVAS_FLOAT_FIXED
+ st->Q_syn2 = 0;
+ move16();
+ st->Q_syn = 0;
+ move16();
+ set16_fx( st->Q_max, Q_MAX, L_Q_MEM );
+ set16_fx( st->Q_max_16k, Q_MAX, L_Q_MEM );
+ st->Q_old = 15;
+ move16();
+ st->old_wsp_max = 0;
+ move16();
+ st->old_wsp_shift = 0;
+ move16();
+ st->sharpFlag = 0;
+ move16();
+#endif
return error;
}
#ifdef IVAS_FLOAT_FIXED
@@ -1058,9 +1161,9 @@ ivas_error init_encoder_ivas_fx(
/* stereo switching memories */
st->mem_preemph_DFT_fx = 0;
- set32_fx( st->inp_12k8_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_12k8, L_MEM_RECALC_12K8 ), L_FILT ) );
+ set16_fx( st->inp_12k8_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_12k8, L_MEM_RECALC_12K8 ), L_FILT ) );
st->mem_preemph16k_DFT_fx = 0;
- set32_fx( st->inp_16k_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_16k, L_MEM_RECALC_16K ), L_FILT16k ) );
+ set16_fx( st->inp_16k_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_16k, L_MEM_RECALC_16K ), L_FILT16k ) );
st->sharpFlag = 0;
@@ -1131,8 +1234,8 @@ ivas_error init_encoder_ivas_fx(
st->input_buff_fx = st->hSignalBuf->input_buff;
set16_fx( st->input_buff_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) );
st->old_input_signal_fx = st->input_buff_fx;
- Word16 temp;
- Word16 frame_length = BASOP_Util_Divide3232_Scale( st->input_Fs, FRAMES_PER_SEC, &temp );
+ /* st->input_Fs / FRAMES_PER_SEC */
+ Word16 frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
@@ -1335,7 +1438,7 @@ ivas_error init_encoder_ivas_fx(
IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( idchan, 0 ) ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) )
{
- IF( ( error = openCldfb_ivas( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+ IF( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1436,7 +1539,7 @@ ivas_error init_encoder_ivas_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) );
}
- IF( ( error = openCldfb_ivas( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+ IF( ( error = openCldfb_ivas_enc( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1715,6 +1818,20 @@ ivas_error init_encoder_ivas_fx(
st->cng_sba_flag = 0;
st->bits_frame_channel = 0;
st->side_bits_frame_channel = 0;
+ st->Q_syn2 = 0;
+ move16();
+ st->Q_syn = 0;
+ move16();
+ set16_fx( st->Q_max, Q_MAX, L_Q_MEM );
+ set16_fx( st->Q_max_16k, Q_MAX, L_Q_MEM );
+ st->Q_old = 15;
+ move16();
+ st->old_wsp_max = 0;
+ move16();
+ st->old_wsp_shift = 0;
+ move16();
+ st->sharpFlag = 0;
+ move16();
return error;
}
diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c
index 2607c50a5f276a00daed5fe99d1771a4a46fe128..7d1f5530200f36d03e880168690b8333220fc643 100644
--- a/lib_enc/init_enc_fx.c
+++ b/lib_enc/init_enc_fx.c
@@ -10,8 +10,7 @@
#include "stl.h"
#include "ivas_cnst.h"
#include "ivas_error.h"
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
@@ -149,7 +148,7 @@ ivas_error init_encoder_fx(
{
st_fx->hBstr = NULL;
}
- st_fx->hBstr->nb_bits_tot_fx = 0;
+ st_fx->hBstr->nb_bits_tot = 0;
move16();
@@ -160,7 +159,7 @@ ivas_error init_encoder_fx(
init_lvq_fx( st_fx->offset_scale1_fx, st_fx->offset_scale2_fx, st_fx->offset_scale1_p_fx, st_fx->offset_scale2_p_fx, st_fx->no_scales_fx, st_fx->no_scales_p_fx );
st_fx->next_force_safety_net_fx = 0;
- st_fx->pstreaklen_fx = 0;
+ st_fx->pstreaklen = 0;
move16();
st_fx->streaklimit_fx = 32767;
move16(); /*1;//Q15 */
@@ -940,7 +939,7 @@ ivas_error init_encoder_fx(
st_fx->low_rate_mode = 0; /* low-rate mode flag */
// st_fx->coder_type = GENERIC; /* low-rate mode flag */
- set16_fx( st_fx->pitch_fx, L_SUBFR, 3 );
+ set16_fx( st_fx->pitch, L_SUBFR, 3 );
set16_fx( st_fx->voicing_fx, 0, 3 );
diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c
index 3b21cb7e7b94d223cb72c74438d22eed1def261b..bb573b1c421e7674dbcaeb10e8f2eea1a7dddb00 100644
--- a/lib_enc/inov_enc_fx.c
+++ b/lib_enc/inov_enc_fx.c
@@ -8,8 +8,7 @@
#include "basop_util.h"
#include "rom_com_fx.h" /* Static table prototypes */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
diff --git a/lib_enc/isf_enc_amr_wb_fx.c b/lib_enc/isf_enc_amr_wb_fx.c
index 8d19855a4b1539b9f330f91d416b9ce8c4f2e649..505d3f2903eb9f1ea7156dc154357103dd07d8be 100644
--- a/lib_enc/isf_enc_amr_wb_fx.c
+++ b/lib_enc/isf_enc_amr_wb_fx.c
@@ -34,8 +34,7 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx1.h" /* Function prototypes */
-#include "prot_fx2.h" /* Function prototypes */
+#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c
index acfd266eb4c22725620dbc3a83902285169760bc..8e70554102ff12df891f3e86c392ddd1184a17e0 100644
--- a/lib_enc/ivas_agc_enc.c
+++ b/lib_enc/ivas_agc_enc.c
@@ -39,8 +39,7 @@
#include
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
-#include "prot_fx1.h"
-#include "prot_fx2.h"
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#include "basop_util.h"
#endif
diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c
index fed8c6915f7cae92af8b5d30d8eca95b5c15ebb8..5c7009674dfbda760aeb6eba1c3f1f8826b40dab 100644
--- a/lib_enc/ivas_core_enc.c
+++ b/lib_enc/ivas_core_enc.c
@@ -40,6 +40,7 @@
#include "wmc_auto.h"
#include
#ifdef IVAS_FLOAT_FIXED
+#include "prot_fx.h"
#include "ivas_prot_fx.h"
#endif
@@ -49,7 +50,7 @@
*
* Principal IVAS core coder routine, where number of core channels is 1 or 2
*-------------------------------------------------------------------*/
-
+#ifdef IVAS_FLOAT_FIXED
ivas_error ivas_core_enc(
SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
@@ -90,6 +91,10 @@ ivas_error ivas_core_enc(
float hb_speech[L_FRAME16k / 4];
float *new_swb_speech;
float new_swb_speech_buffer[L_FRAME48k + STEREO_DFT_OVL_MAX];
+#ifdef IVAS_FLOAT_FIXED
+ Word32 *new_swb_speech_fx;
+ Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX];
+#endif
float bwe_exc_extended[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET];
float voice_factors[CPE_CHANNELS][NB_SUBFR16k];
int16_t Voicing_flag[CPE_CHANNELS];
@@ -321,6 +326,408 @@ ivas_error ivas_core_enc(
}
+ /*---------------------------------------------------------------------*
+ * Postprocessing, BWEs and Updates
+ *---------------------------------------------------------------------*/
+
+ for ( n = 0; n < n_CoreChannels; n++ )
+ {
+ st = sts[n];
+
+ /*---------------------------------------------------------------------*
+ * Postprocessing for ACELP/HQ core switching
+ *---------------------------------------------------------------------*/
+
+ core_switching_post_enc( st, old_inp_12k8[n], old_inp_16k[n], A[n] );
+
+ /*---------------------------------------------------------------------*
+ * WB TBE encoding
+ * WB BWE encoding
+ *---------------------------------------------------------------------*/
+
+ if ( input_Fs >= 16000 && st->bwidth < SWB && st->hBWE_TD != NULL )
+ {
+ /* Common pre-processing for WB TBE and WB BWE */
+ wb_pre_proc( st, last_element_mode, new_inp_resamp16k[n], hb_speech );
+ }
+
+ if ( st->extl == WB_TBE )
+ {
+ /* WB TBE encoder */
+ wb_tbe_enc( st, hb_speech, bwe_exc_extended[n], voice_factors[n], pitch_buf[n] );
+ }
+ else if ( st->extl == WB_BWE && n == 0 && st->element_mode != IVAS_CPE_MDCT )
+ {
+ /* WB BWE encoder */
+ wb_bwe_enc( st, new_inp_resamp16k[n] );
+ }
+
+ /*---------------------------------------------------------------------*
+ * SWB(FB) TBE encoding
+ * SWB(FB) BWE encoding
+ *---------------------------------------------------------------------*/
+
+ new_swb_speech = new_swb_speech_buffer + STEREO_DFT_OVL_MAX;
+#ifdef IVAS_FLOAT_FIXED
+ new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX;
+#endif
+
+ if ( !st->Opt_SC_VBR && input_Fs >= 32000 && st->hBWE_TD != NULL )
+ {
+ /* Common pre-processing for SWB(FB) TBE and SWB(FB) BWE */
+#ifdef IVAS_FLOAT_FIXED
+ swb_pre_proc_ivas_fx( st, new_swb_speech, new_swb_speech_fx, shb_speech, realBuffer[n], imagBuffer[n], hCPE );
+#else
+ swb_pre_proc( st, new_swb_speech, shb_speech, realBuffer[n], imagBuffer[n], hCPE );
+#endif
+ }
+ else if ( input_Fs >= 32000 )
+ {
+ if ( st->hBWE_TD != NULL )
+ {
+ InitSWBencBufferStates( st->hBWE_TD, shb_speech );
+ }
+ }
+
+ /* SWB TBE encoder */
+ if ( st->extl == SWB_TBE || st->extl == FB_TBE )
+ {
+ if ( st->core_brate != FRAME_NO_DATA && st->core_brate != SID_2k40 )
+ {
+ float fb_exc[L_FRAME16k];
+
+ swb_tbe_enc( st, hStereoICBWE, shb_speech, bwe_exc_extended[n], voice_factors[n], fb_exc, pitch_buf[n] );
+
+ if ( st->extl == FB_TBE )
+ {
+ /* FB TBE encoder */
+ fb_tbe_enc( st, st->input, fb_exc );
+ }
+ }
+ }
+ else if ( st->extl == SWB_BWE || st->extl == FB_BWE )
+ {
+ /* SWB(FB) BWE encoder */
+ swb_bwe_enc( st, last_element_mode, old_inp_12k8[n], old_inp_16k[n], old_syn_12k8_16k[n], new_swb_speech, shb_speech );
+ }
+
+ /*---------------------------------------------------------------------*
+ * SWB DTX/CNG encoding
+ *---------------------------------------------------------------------*/
+
+ if ( st->hTdCngEnc != NULL && st->Opt_DTX_ON && ( input_frame >= L_FRAME32k || st->element_mode == IVAS_CPE_DFT ) )
+ {
+ /* SHB DTX/CNG encoder */
+ swb_CNG_enc( st, shb_speech, old_syn_12k8_16k[n] );
+ }
+
+ /*-------------------------------------------------------------------*
+ * Inter-channel BWE encoding
+ *-------------------------------------------------------------------*/
+
+ if ( n == 0 && input_Fs >= 32000 && hStereoICBWE != NULL )
+ {
+ stereo_icBWE_preproc( hCPE, input_frame, new_swb_speech_buffer /*tmp buffer*/ );
+
+ stereo_icBWE_enc( hCPE, shb_speech, new_swb_speech_buffer, voice_factors[0] );
+ }
+
+ /*---------------------------------------------------------------------*
+ * Channel-aware mode - write signaling information into the bitstream
+ *---------------------------------------------------------------------*/
+
+ signaling_enc_rf( st );
+
+ /*---------------------------------------------------------------------*
+ * Common updates
+ *---------------------------------------------------------------------*/
+
+ 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( st );
+ }
+ }
+
+ /*------------------------------------------------------------------*
+ * Write potentially unused bits in combined format coding
+ *-----------------------------------------------------------------*/
+
+ if ( hCPE != NULL && hCPE->element_mode == IVAS_CPE_DFT && hCPE->brate_surplus > 0 )
+ {
+ while ( diff_nBits > 0 )
+ {
+ n = min( diff_nBits, 16 );
+ push_indice( sts[0]->hBstr, IND_UNUSED, 0, n );
+ diff_nBits -= n;
+ }
+ }
+
+
+ pop_wmops();
+
+ return error;
+}
+#else
+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 int16_t n_CoreChannels, /* i : number of core channels to be coded */
+ float old_inp_12k8[][L_INP_12k8], /* i : buffer of old input signal */
+ float old_inp_16k[][L_INP], /* i : buffer of old input signal */
+ float ener[], /* i : residual energy from Levinson-Durbin */
+ float A[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */
+ float Aw[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes */
+ float epsP[][M + 1], /* i : LP prediction errors */
+ float lsp_new[][M], /* i : LSPs at the end of the frame */
+ float lsp_mid[][M], /* i : LSPs in the middle of the frame */
+ const int16_t vad_hover_flag[], /* i : VAD hanglover flag */
+ int16_t attack_flag[], /* i : attack flag (GSC or TC) */
+ float realBuffer[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */
+ float imagBuffer[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */
+ float old_wsp[][L_WSP], /* i : weighted input signal buffer */
+ const int16_t loc_harm[], /* i : harmonicity flag */
+ const float cor_map_sum[], /* i : speech/music clasif. parameter */
+ const int16_t vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO */
+ float enerBuffer[][CLDFB_NO_CHANNELS_MAX], /* i : energy buffer */
+ float fft_buff[][2 * L_FFT], /* i : FFT buffer */
+ const int16_t tdm_SM_or_LRTD_Pri, /* 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 */
+)
+{
+ int16_t n, input_frame;
+ int16_t cpe_id, MCT_flag;
+ Encoder_State **sts, *st;
+ STEREO_ICBWE_ENC_HANDLE hStereoICBWE;
+ STEREO_TD_ENC_DATA_HANDLE hStereoTD;
+ float *inp[CPE_CHANNELS];
+ float new_inp_resamp16k[CPE_CHANNELS][L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
+ float old_syn_12k8_16k[CPE_CHANNELS][L_FRAME16k]; /* ACELP core synthesis at 12.8kHz or 16kHz to be used by the SWB BWE */
+ float shb_speech[L_FRAME16k];
+ float hb_speech[L_FRAME16k / 4];
+ float *new_swb_speech;
+ float new_swb_speech_buffer[L_FRAME48k + STEREO_DFT_OVL_MAX];
+ float bwe_exc_extended[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET];
+ float voice_factors[CPE_CHANNELS][NB_SUBFR16k];
+ int16_t Voicing_flag[CPE_CHANNELS];
+ float pitch_buf[CPE_CHANNELS][NB_SUBFR16k];
+ int16_t unbits[CPE_CHANNELS];
+ float tdm_lspQ_PCh[M], tdm_lsfQ_PCh[M];
+ int16_t last_element_mode, tdm_Pitch_reuse_flag;
+ int32_t element_brate, last_element_brate, input_Fs;
+ int16_t diff_nBits;
+ ivas_error error;
+ int16_t max_num_indices_BWE;
+
+ push_wmops( "ivas_core_enc" );
+
+ error = IVAS_ERR_OK;
+
+ /*------------------------------------------------------------------*
+ * General initialization
+ *-----------------------------------------------------------------*/
+
+ if ( hSCE != NULL )
+ {
+ cpe_id = -1;
+ MCT_flag = 0;
+ sts = hSCE->hCoreCoder;
+ hStereoTD = NULL;
+ hStereoICBWE = NULL;
+ element_brate = hSCE->element_brate;
+ last_element_brate = hSCE->last_element_brate;
+ last_element_mode = IVAS_SCE;
+ tdm_Pitch_reuse_flag = -1;
+ }
+ else
+ {
+ cpe_id = hCPE->cpe_id;
+ MCT_flag = 0;
+ if ( hMCT != NULL )
+ {
+ MCT_flag = 1;
+ }
+ sts = hCPE->hCoreCoder;
+ hStereoICBWE = hCPE->hStereoICBWE;
+ element_brate = hCPE->element_brate;
+ last_element_brate = hCPE->last_element_brate;
+ last_element_mode = hCPE->last_element_mode;
+
+ if ( hCPE->hStereoTD != NULL )
+ {
+ hStereoTD = hCPE->hStereoTD;
+ tdm_Pitch_reuse_flag = hCPE->hStereoTD->tdm_Pitch_reuse_flag;
+ }
+ else
+ {
+ hStereoTD = NULL;
+ tdm_Pitch_reuse_flag = -1;
+ }
+ }
+
+ input_Fs = sts[0]->input_Fs;
+ input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC );
+
+ set_f( new_swb_speech_buffer, 0, L_FRAME48k + STEREO_DFT_OVL_MAX );
+
+ for ( n = 0; n < n_CoreChannels; n++ )
+ {
+ st = sts[n];
+
+ /*------------------------------------------------------------------*
+ * Initializiation per core-coder channel
+ *-----------------------------------------------------------------*/
+
+
+ st->extl = -1;
+ unbits[n] = 0;
+
+ st->element_brate = element_brate;
+
+ /*---------------------------------------------------------------------*
+ * Pre-processing, incl. Decision matrix
+ *---------------------------------------------------------------------*/
+
+ if ( ( error = pre_proc_ivas( st, last_element_mode, element_brate, ivas_format == SBA_FORMAT ? last_element_brate : element_brate, input_frame, old_inp_12k8[n], old_inp_16k[n], &inp[n], &ener[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], new_inp_resamp16k[n], &Voicing_flag[n], old_wsp[n], loc_harm[n], cor_map_sum[n], vad_flag_dtx[n], enerBuffer[n], fft_buff[n], MCT_flag, vad_hover_flag[n], flag_16k_smc ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( st->element_mode == IVAS_CPE_MDCT || st->element_mode == IVAS_SCE )
+ {
+ st->enablePlcWaveadjust = 0;
+ }
+ }
+
+ /*------------------------------------------------------------------*
+ * Sanity check in combined format coding
+ *-----------------------------------------------------------------*/
+
+ diff_nBits = 0;
+ if ( hCPE != NULL && hCPE->element_mode == IVAS_CPE_DFT && hCPE->brate_surplus > 0 )
+ {
+ ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &diff_nBits );
+ }
+
+ /*---------------------------------------------------------------------*
+ * Core Encoding
+ *---------------------------------------------------------------------*/
+
+ for ( n = 0; n < n_CoreChannels; n++ )
+ {
+ st = sts[n];
+
+ /* update pointer to the buffer of indices of the second channel */
+ if ( n == 1 && st->element_mode == IVAS_CPE_TD )
+ {
+ /* adjust the pointer to the buffer of indices of the secondary channel (make space for BWE indices) */
+ max_num_indices_BWE = get_BWE_max_num_indices( sts[0]->extl_brate );
+ st->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot + max_num_indices_BWE;
+
+ /* 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 += hStereoTD->tdm_hBstr_tmp.nb_ind_tot;
+ st->hBstr->nb_bits_tot += hStereoTD->tdm_hBstr_tmp.nb_bits_tot;
+
+ reset_indices_enc( &hStereoTD->tdm_hBstr_tmp, MAX_IND_TDM_TMP );
+ }
+
+ /*---------------------------------------------------------------------*
+ * Write signaling info into the bitstream
+ *---------------------------------------------------------------------*/
+
+ if ( !MCT_flag || ( MCT_flag && cpe_id == 0 ) )
+ {
+ ivas_signaling_enc( st, MCT_flag, element_brate, tdm_SM_or_LRTD_Pri, tdm_Pitch_reuse_flag );
+ }
+
+ /*---------------------------------------------------------------------*
+ * Preprocessing (preparing) for ACELP/HQ core switching
+ *---------------------------------------------------------------------*/
+
+ core_switching_pre_enc( st, old_inp_12k8[n], old_inp_16k[n], sts[0]->active_cnt, last_element_mode );
+
+ /*---------------------------------------------------------------------*
+ * ACELP core encoding
+ * TCX core encoding
+ * HQ core encoding
+ *---------------------------------------------------------------------*/
+
+ if ( st->core == ACELP_CORE )
+ {
+ /* ACELP core encoder */
+ if ( ( error = acelp_core_enc( st, inp[n], ener[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], pitch_buf[n], &unbits[n], hStereoTD, tdm_lsfQ_PCh ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+ if ( ( st->core == TCX_20_CORE || st->core == TCX_10_CORE ) && st->element_mode != IVAS_CPE_MDCT )
+ {
+ /* TCX core encoder */
+ stereo_tcx_core_enc( st, old_inp_12k8[n] + L_INP_MEM, old_inp_16k[n] + L_INP_MEM, Aw[n], lsp_new[n], lsp_mid[n], pitch_buf[n], last_element_mode, vad_hover_flag[0] );
+ }
+
+ if ( st->core == HQ_CORE )
+ {
+ /* HQ core encoder */
+ hq_core_enc( st, st->input, input_frame, NORMAL_HQ_CORE, Voicing_flag[n], vad_hover_flag[0] );
+ }
+
+ /*---------------------------------------------------------------------*
+ * TD stereo updates
+ *---------------------------------------------------------------------*/
+
+ if ( st->element_mode == IVAS_CPE_TD && n == 0 )
+ {
+ td_stereo_param_updt( st->lsp_old, st->lsf_old, pitch_buf[0], tdm_lspQ_PCh, tdm_lsfQ_PCh, hStereoTD->tdm_Pri_pitch_buf, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc );
+ }
+ }
+
+
+ /*---------------------------------------------------------------------*
+ * MDCT stereo: joint TCX Core Encoding
+ *---------------------------------------------------------------------*/
+
+ if ( sts[0]->element_mode == IVAS_CPE_MDCT )
+ {
+ if ( sts[0]->core_brate > SID_2k40 && sts[1]->core_brate > SID_2k40 )
+ {
+ if ( MCT_flag )
+ {
+ ivas_mdct_core_whitening_enc( hCPE, old_inp_16k, old_wsp, pitch_buf, hMCT->p_mdst_spectrum_long[cpe_id], hMCT->tnsBits[cpe_id], hMCT->p_orig_spectrum_long[cpe_id],
+ hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], hMCT->hBstr, 1, hMCT->nchan_out_woLFE );
+ }
+ else
+ {
+ stereo_mdct_core_enc( hCPE, old_inp_16k, old_wsp, pitch_buf );
+ }
+ }
+ else if ( sts[0]->core_brate == SID_2k40 && sts[1]->core_brate == SID_2k40 )
+ {
+ /* synch CNG configs between channels */
+ for ( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ st = sts[n];
+ if ( ( st->hFdCngEnc->hFdCngCom->frameSize != st->L_frame ) || ( st->hFdCngEnc->hFdCngCom->CngBandwidth != st->bwidth ) )
+ {
+ configureFdCngEnc( st->hFdCngEnc, max( st->bwidth, WB ), st->L_frame == L_FRAME16k ? ACELP_16k40 : ACELP_9k60 );
+ }
+ }
+
+ if ( sts[0]->cng_sba_flag )
+ {
+ FdCngEncodeDiracMDCTStereoSID( hCPE );
+ }
+ else
+ {
+ FdCngEncodeMDCTStereoSID( hCPE );
+ }
+ }
+ }
+
+
/*---------------------------------------------------------------------*
* Postprocessing, BWEs and Updates
*---------------------------------------------------------------------*/
@@ -490,3 +897,4 @@ ivas_error ivas_core_enc(
return error;
}
+#endif
diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c
index 25f6959b74deab402b7d39de49ba12f1811ebcf8..239e57cfc3f805b8dcd83bf64e01b17193db6dc2 100644
--- a/lib_enc/ivas_core_pre_proc_front.c
+++ b/lib_enc/ivas_core_pre_proc_front.c
@@ -37,35 +37,820 @@
#include "rom_enc.h"
#include "rom_com.h"
#include "prot.h"
+#include "prot_fx.h"
+#include "prot_fx_enc.h"
#include "ivas_prot.h"
#include "wmc_auto.h"
#include
+#ifdef IVAS_FLOAT_FIXED
+#include "prot_fx_enc.h"
+#endif
/*---------------------------------------------------------------*
* Local constants
*---------------------------------------------------------------*/
-#define SCE_SMC_THR 16000
+#define SCE_SMC_THR 16000
+
+
+/*-------------------------------------------------------------------*
+ * Local function prototypes
+ *--------------------------------------------------------------------*/
+#if 0
+static void change_q( Word16 *buff, Word16 size, Word16 Q )
+{
+ Flag Overflow;
+ for ( Word16 i = 0; i < size; i++ )
+ {
+ buff[i] = shr_o( buff[i], Q, &Overflow );
+ }
+}
+#endif
+static void calculate_energy_buffer( CPE_ENC_HANDLE hCPE, float enerBuffer_dft[], const int16_t no_channels, const int32_t input_Fs );
+#ifdef IVAS_FIXED_ENC
+static void calculate_energy_buffer_fx( CPE_ENC_HANDLE hCPE, Word64 enerBuffer_dft_fx[], Word16 *enerBuffer_dft_q_fx, const Word16 no_channels, const Word32 input_Fs );
+#endif
+
+/*-------------------------------------------------------------------*
+ * pre_proc_front_ivas()
+ *
+ * Front Pre-processing for IVAS
+ * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification)
+ *--------------------------------------------------------------------*/
+ivas_error pre_proc_front_ivas(
+ SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ const int32_t element_brate, /* i : SCE/CPE element bitrate */
+ const int16_t nb_bits_metadata, /* i : number of metadata bits */
+ const int16_t input_frame, /* i : frame length */
+ const int16_t n, /* i : channel number */
+ float old_inp_12k8[], /* o : buffer of old input signal */
+ float old_inp_16k[], /* o : buffer of old input signal @16kHz */
+ float *ener, /* o : residual energy from Levinson-Durbin */
+ float *relE, /* o : frame relative energy */
+ float A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */
+ float Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */
+ float epsP[M + 1], /* o : LP prediction errors */
+ float lsp_new[M], /* o : LSPs at the end of the frame */
+ float lsp_mid[M], /* o : LSPs in the middle of the frame */
+ int16_t *vad_hover_flag, /* o : VAD hangover flag */
+ int16_t *attack_flag, /* o : flag signaling attack */
+ float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */
+ float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */
+ float old_wsp[], /* o : weighted input signal buffer */
+ float pitch_fr[NB_SUBFR], /* o : fractional pitch values */
+ float voicing_fr[NB_SUBFR], /* o : fractional pitch gains */
+ int16_t *loc_harm, /* o : harmonicity flag */
+ float *cor_map_sum, /* o : speech/music clasif. parameter */
+ int16_t *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO */
+ float enerBuffer[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */
+ float fft_buff[2 * L_FFT], /* o : FFT buffer */
+ const float tdm_A_PCh[M + 1], /* i : unq. LP coeff. of primary channel */
+ const float tdm_lsp_new_PCh[M], /* i : unq. LSPs of primary channel */
+ const float currFlatness, /* i : flatness parameter */
+ const int16_t tdm_ratio_idx, /* i : Current Ratio_L index */
+ float fr_bands_LR[][2 * NB_BANDS], /* i : energy in frequency bands */
+ const float Etot_LR[], /* i : total energy Left & Right channel */
+ float lf_E_LR[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */
+ const int16_t localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */
+ float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */
+ const int16_t flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */
+ const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */
+ const int16_t force_front_vad, /* i : flag to force VAD decision */
+ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/
+ const IVAS_FORMAT ivas_format, /* i : IVAS format */
+ const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
+ const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */
+)
+{
+ float *inp_12k8, *new_inp_12k8; /* pointers to current frame and new data */
+ float *wsp; /* weighted input signal buffer */
+ float Etot; /* total energy */
+ float fr_bands[2 * NB_BANDS]; /* energy in frequency bands */
+ float lf_E[2 * VOIC_BINS]; /* per bin spectrum energy in lf */
+ float tmpN[NB_BANDS]; /* Temporary noise update */
+ float tmpE[NB_BANDS]; /* Temporary averaged energy of 2 sf. */
+ float tmpN_LR[CPE_CHANNELS][NB_BANDS]; /* Temporary noise update */
+ float tmpE_LR[CPE_CHANNELS][NB_BANDS]; /* Temporary averaged energy of 2 sf. */
+ float cor_map_sum_LR[CPE_CHANNELS]; /* speech/music clasif. parameter */
+ float non_staX_LR; /* non-stationarity for sp/mus classifier */
+ float ncharX_LR; /* noise character for sp/mus classifier */
+ float sp_div_LR; /* spectral diversity feature */
+ float S_map_LR[L_FFT / 2]; /* short-term correlation map */
+ float corr_shiftL; /* correlation shift */
+ float corr_shiftR; /* correlation shift */
+ int16_t loc_harmLR[CPE_CHANNELS]; /* harmonicity flag */
+ int16_t lr_vad_enabled; /* LR VAD indicator */
+ float ee[2]; /* Spectral tilt */
+ float corr_shift; /* correlation shift */
+ float sp_div, PS[128]; /* speech/music clasif. parameters */
+ int16_t L_look; /* length of look-ahead */
+ float snr_sum_he; /* HE SAD parameters */
+ float hp_E[2]; /* Energy in HF */
+ int16_t flag_spitch;
+ int16_t high_lpn_flag;
+ float lsf_new[M];
+ float band_energies[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor E_MIN */
+ int16_t localVAD_HE_SAD;
+ float non_staX;
+ float stab_fac;
+ int16_t alw_pitch_lag_12k8[2];
+ float alw_voicing[2];
+ int16_t last_core_orig;
+ float dummy;
+ float mem_decim_dummy[2 * L_FILT_MAX]; /* dummy decimation filter memory */
+ float S_map[L_FFT / 2];
+ int16_t i, lMemRecalc, lMemRecalc_12k8;
+ int16_t smc_dec;
+ float ncharX, dE1X;
+ Encoder_State *st;
+ float *signal_in;
+ int16_t element_mode;
+ int32_t input_Fs, last_element_brate;
+ int16_t *tdm_SM_last_clas, tmpS;
+ float *res_cod_SNR_M, tmpF[STEREO_DFT_BAND_MAX];
+ STEREO_CLASSIF_HANDLE hStereoClassif;
+ float temp1F_icatdmResampBuf[L_FILT_MAX]; /* temp buffers for ICA TDM resamplers */
+ int16_t old_pitch1; /* previous frame OL pitch[1] @12.8 kHz */
+ int16_t LR_localVAD;
+ ivas_error error;
+
+ push_wmops( "pre_proc_front" );
+
+ /*------------------------------------------------------------------*
+ * Initialization
+ *------------------------------------------------------------------*/
+
+ error = IVAS_ERR_OK;
+
+ tmpS = 0;
+ tdm_SM_last_clas = &tmpS;
+ set_f( tmpF, 0, STEREO_DFT_BAND_MAX );
+ res_cod_SNR_M = tmpF;
+
+ LR_localVAD = 0;
+
+ if ( hSCE != NULL )
+ {
+ st = hSCE->hCoreCoder[n];
+ signal_in = hSCE->hCoreCoder[n]->input;
+ element_mode = IVAS_SCE;
+ last_element_brate = hSCE->last_element_brate;
+ hStereoClassif = NULL;
+ lr_vad_enabled = 0;
+ }
+ else /* CPE */
+ {
+ st = hCPE->hCoreCoder[n];
+ signal_in = hCPE->hCoreCoder[n]->input;
+ element_mode = hCPE->element_mode;
+ last_element_brate = hCPE->last_element_brate;
+ hStereoClassif = hCPE->hStereoClassif;
+ lr_vad_enabled = 0;
+ if ( hCPE->hFrontVad[0] != NULL && hCPE->element_mode != IVAS_CPE_MDCT )
+ {
+ lr_vad_enabled = 1;
+ }
+
+ if ( lr_vad_enabled && n == 0 )
+ {
+ /* Combine localVAD and vad_flag from LR processing */
+ LR_localVAD = hCPE->hCoreCoder[0]->localVAD || hCPE->hCoreCoder[1]->localVAD;
+ }
+
+ if ( hCPE->hStereoTD != NULL )
+ {
+ tdm_SM_last_clas = &hCPE->hStereoTD->tdm_SM_last_clas[n];
+ mvs2s( hCPE->hStereoTD->tdm_SM_last_clas, hCPE->hStereoTD->tdm_SM_last2_clas, CPE_CHANNELS );
+ }
+
+ if ( hCPE->hStereoDft != NULL )
+ {
+ res_cod_SNR_M = hCPE->hStereoDft->res_cod_SNR_M;
+ }
+ }
+
+ lMemRecalc_12k8 = 0;
+ lMemRecalc = 0;
+ if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_MDCT )
+ {
+ lMemRecalc = NS2SA( st->input_Fs, L_MEM_RECALC_NS );
+ lMemRecalc_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_NS );
+ }
+
+ input_Fs = st->input_Fs;
+
+ localVAD_HE_SAD = 0;
+ snr_sum_he = 0;
+
+ corr_shiftL = 0;
+ corr_shiftR = 0;
+
+ if ( hSCE != NULL )
+ {
+ *vad_hover_flag = 0;
+ }
+ st->sp_aud_decision1 = 0;
+ st->sp_aud_decision2 = 0;
+ st->coder_type = GENERIC;
+ if ( st->hGSCEnc != NULL )
+ {
+ st->hGSCEnc->noise_lev = NOISE_LEVEL_SP0;
+ }
+ *attack_flag = 0;
+
+ if ( st->Opt_SC_VBR )
+ {
+ st->hSC_VBR->bump_up = 0;
+ st->hSC_VBR->ppp_mode = 0;
+ st->hSC_VBR->nelp_mode = 0;
+ st->hSC_VBR->avoid_HQ_VBR_NB = 0;
+ }
+
+ L_look = L_LOOK_12k8; /* lookahead at 12.8kHz */
+
+ new_inp_12k8 = old_inp_12k8 + L_INP_MEM; /* pointer to new samples of the input signal in 12.8kHz core */
+ inp_12k8 = new_inp_12k8 - L_look; /* pointer to the current frame of input signal in 12.8kHz core */
+
+ if ( element_mode != IVAS_CPE_DFT )
+ {
+ new_inp_12k8 -= L_FILT;
+ }
+
+ if ( element_mode == IVAS_CPE_DFT )
+ {
+ mvr2r( st->old_inp_12k8, old_inp_12k8, L_INP_MEM - STEREO_DFT_OVL_12k8 );
+ }
+ else if ( element_mode == IVAS_CPE_TD )
+ {
+ mvr2r( st->old_inp_12k8, old_inp_12k8, L_INP_MEM - lMemRecalc_12k8 - L_FILT );
+ }
+ else
+ {
+ mvr2r( st->old_inp_12k8, old_inp_12k8, L_INP_MEM - L_FILT );
+ }
+
+ mvr2r( st->old_wsp, old_wsp, L_WSP_MEM );
+ wsp = old_wsp + L_WSP_MEM; /* pointer to the current frame of weighted signal in 12.8kHz core */
+
+ st->rf_mode = st->Opt_RF_ON;
+
+ last_core_orig = st->last_core;
+
+ /*--------------------------------------------------------------*
+ * energy analysis
+ *---------------------------------------------------------------*/
+
+ if ( element_mode == IVAS_SCE || ( element_mode == IVAS_CPE_MDCT && st->Opt_DTX_ON ) )
+ {
+ analysisCldfbEncoder_ivas( st, signal_in, input_frame, realBuffer, imagBuffer, enerBuffer );
+ }
+ else if ( ( element_mode == IVAS_CPE_TD && st->idchan == 0 ) || ( st->idchan == 1 && st->tdm_LRTD_flag ) )
+ {
+ /* cldfb analysis only for pri. channel */
+ analysisCldfbEncoder_ivas( st, signal_in - NS2SA( input_Fs, L_MEM_RECALC_TBE_NS ), input_frame, realBuffer, imagBuffer, enerBuffer );
+ }
+ else if ( element_mode == IVAS_CPE_DFT )
+ {
+ calculate_energy_buffer( hCPE, enerBuffer, st->cldfbAnaEnc->no_channels, input_Fs );
+ }
+ else
+ {
+ set_f( enerBuffer, 0, CLDFB_NO_CHANNELS_MAX );
+ }
+
+ /*----------------------------------------------------------------*
+ * Change the sampling frequency to 12.8 kHz
+ * (if not available from downsampled DMX)
+ *----------------------------------------------------------------*/
+
+ if ( element_mode == IVAS_SCE )
+ {
+ modify_Fs( signal_in, input_frame, input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim, ( st->max_bwidth == NB ) );
+
+ mvr2r( st->mem_decim, mem_decim_dummy, 2 * L_FILT_MAX );
+ set_f( temp1F_icatdmResampBuf, 0, L_FILT_MAX );
+ modify_Fs( temp1F_icatdmResampBuf, NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8 + L_FRAME, INT_FS_12k8, mem_decim_dummy, 0 );
+ }
+ else if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_MDCT )
+ {
+ /* reconstruct past segment of the Secondary channel input signal when switching from DFT stereo */
+ if ( hCPE->last_element_mode == IVAS_CPE_DFT && st->idchan == 1 )
+ {
+ int16_t length_inp = NS2SA( input_Fs, L_MEM_RECALC_SCH_NS );
+ int16_t length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS );
+
+ modify_Fs( signal_in - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_12k8 - lMemRecalc_12k8 - length_12k8, INT_FS_12k8, st->mem_decim, 0 );
+ }
+
+ modify_Fs( signal_in - lMemRecalc, input_frame, input_Fs, new_inp_12k8 - lMemRecalc_12k8, INT_FS_12k8, st->mem_decim, ( st->max_bwidth == NB ) );
+ mvr2r( st->mem_decim, mem_decim_dummy, 2 * L_FILT_MAX );
+
+ if ( lMemRecalc > 0 )
+ {
+ modify_Fs( signal_in + input_frame - lMemRecalc, lMemRecalc, input_Fs, new_inp_12k8 + L_FRAME - lMemRecalc_12k8, INT_FS_12k8, mem_decim_dummy, ( st->max_bwidth == NB ) );
+ }
+ set_f( temp1F_icatdmResampBuf, 0, L_FILT_MAX );
+ modify_Fs( temp1F_icatdmResampBuf, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8 + L_FRAME, INT_FS_12k8, mem_decim_dummy, 0 );
+ }
+ else /* DFT stereo */
+ {
+ /* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */
+ mvr2r( signal_in + input_frame - NS2SA( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) );
+ }
+
+ /* save input resampled at 12.8kHz, non-preemhasised */
+ if ( element_mode == IVAS_CPE_DFT )
+ {
+ mvr2r( new_inp_12k8 - STEREO_DFT_OVL_12k8, st->buf_speech_enc_flt + L_FRAME32k - STEREO_DFT_OVL_12k8, L_FRAME + STEREO_DFT_OVL_12k8 );
+ }
+ else if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_MDCT )
+ {
+ mvr2r( new_inp_12k8 - lMemRecalc_12k8, st->buf_speech_enc_flt + L_FRAME32k - lMemRecalc_12k8 - L_FILT, L_FRAME + lMemRecalc_12k8 + L_FILT );
+ }
+ else
+ {
+ mvr2r( new_inp_12k8, st->buf_speech_enc_flt + L_FRAME32k, L_FRAME );
+ }
+
+ /*------------------------------------------------------------------*
+ * Perform fixed preemphasis (12.8 kHz signal) through 1 - g*z^-1
+ *-----------------------------------------------------------------*/
+
+ if ( element_mode == IVAS_CPE_DFT )
+ {
+ mvr2r( new_inp_12k8 - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); /* memory for TD/DFT stereo switching */
+
+ st->mem_preemph = st->mem_preemph_DFT;
+ st->mem_preemph_DFT = old_inp_12k8[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1];
+
+ preemph( new_inp_12k8 - STEREO_DFT_OVL_12k8, PREEMPH_FAC_FLT, L_FRAME, &st->mem_preemph );
+ dummy = st->mem_preemph;
+ preemph( new_inp_12k8 - STEREO_DFT_OVL_12k8 + L_FRAME, PREEMPH_FAC_FLT, STEREO_DFT_OVL_12k8, &dummy );
+ }
+ else if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_MDCT )
+ {
+ if ( st->idchan == 0 )
+ {
+ if ( hCPE->last_element_mode == IVAS_CPE_DFT )
+ {
+ st->mem_preemph = st->mem_preemph_DFT;
+ mvr2r( st->inp_12k8_mem_stereo_sw, new_inp_12k8 - 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( new_inp_12k8 - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), PREEMPH_FAC_FLT, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph );
+ }
+
+ st->mem_preemph_DFT = old_inp_12k8[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* == inp_12k8[L_FRAME-1] */
+ }
+
+ /* preemphasise past segment of the Secondary channel input signal when switching from DFT stereo */
+ if ( hCPE->last_element_mode == IVAS_CPE_DFT && st->idchan == 1 )
+ {
+ int16_t length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS );
+ preemph( new_inp_12k8 - lMemRecalc_12k8 - length_12k8, PREEMPH_FAC_FLT, length_12k8, &st->mem_preemph );
+ }
+
+ preemph( new_inp_12k8 - lMemRecalc_12k8, PREEMPH_FAC_FLT, L_FRAME, &st->mem_preemph );
+ dummy = st->mem_preemph;
+ preemph( new_inp_12k8 - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC_FLT, lMemRecalc_12k8 + L_FILT, &dummy );
+ }
+ else /* IVAS_SCE or IVAS_CPE_MDCT */
+ {
+ preemph( new_inp_12k8, PREEMPH_FAC_FLT, L_FRAME, &st->mem_preemph );
+ dummy = st->mem_preemph;
+ preemph( new_inp_12k8 + L_FRAME, PREEMPH_FAC_FLT, L_FILT, &dummy );
+ }
+
+ /*-------------------------------------------------------------------------*
+ * Spectral analysis
+ *--------------------------------------------------------------------------*/
+
+ analy_sp( element_mode, hCPE, input_Fs, inp_12k8, st->Bin_E, st->Bin_E_old, fr_bands, lf_E, &Etot, st->min_band, st->max_band, band_energies, PS, fft_buff );
+
+ if ( hStereoClassif != NULL )
+ {
+ if ( st->lp_speech - Etot > 25 )
+ {
+ hStereoClassif->silence_flag = 2;
+ }
+ else
+ {
+ hStereoClassif->silence_flag = hStereoClassif->silence_flag - 1;
+ }
+ hStereoClassif->silence_flag = max( 0, hStereoClassif->silence_flag );
+ }
+
+ /*----------------------------------------------------------------*
+ * SAD (1-signal, 0-noise)
+ *----------------------------------------------------------------*/
+
+ noise_est_pre( Etot, st->ini_frame, st->hNoiseEst, st->idchan, element_mode, hCPE != NULL ? hCPE->last_element_mode : element_mode );
+
+ if ( element_mode == IVAS_CPE_TD && ( ( abs( hCPE->hStereoTD->tdm_last_ratio_idx - tdm_ratio_idx ) > 5 && st->idchan == 1 ) || abs( hCPE->hStereoTD->tdm_last_inst_ratio_idx - hCPE->hStereoTD->tdm_inst_ratio_idx ) > 10 ) )
+ {
+ st->ini_frame = 1;
+ }
+
+ st->vad_flag = wb_vad( st, fr_bands, &i, &i, &i, &snr_sum_he, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), NULL, NULL, -1000.0f, -1000.0f );
+
+
+ if ( force_front_vad == 1 || 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;
+ }
+ if ( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL )
+ {
+ *vad_flag_dtx = dtx_hangover_addition( st, st->vad_flag, st->lp_speech - st->lp_noise, 0, vad_hover_flag, NULL, NULL, NULL );
+ }
+ else
+ {
+ /* This only applies to st->idchan==0 now */
+ /* Add down mix stereo activity to LR vad_flag_dtx */
+ *vad_flag_dtx = *vad_flag_dtx || st->vad_flag;
+
+
+ /* Determine hangover flag status based on LR localVAD and downmix localVAD */
+ *vad_hover_flag = *vad_flag_dtx && !( LR_localVAD || st->localVAD );
+ }
+
+ if ( force_front_vad == 1 || 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;
+ }
+
+ /*----------------------------------------------------------------*
+ * NB/WB/SWB/FB bandwidth detector
+ *----------------------------------------------------------------*/
+
+ if ( st->idchan == 0 && element_mode != IVAS_CPE_MDCT )
+ {
+ bw_detect( st, st->input, NULL, enerBuffer, ivas_format, 0 );
+ }
+
+ if ( element_mode != IVAS_CPE_MDCT ) /* in MDCT stereo, set_bw_stereo() is used instead */
+ {
+ set_bw( element_mode, element_brate, st, MODE1 );
+ }
+
+ /* set the BW of the TD secondary channel in LRTD mode same as BW of the primary channel (only at higher bitrates) */
+ if ( st->idchan == 1 && element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag == 1 && st->bits_frame_channel >= IVAS_16k4 / FRAMES_PER_SEC )
+ {
+ st->bwidth = hCPE->hCoreCoder[0]->bwidth;
+ }
+
+ /*----------------------------------------------------------------*
+ * Noise energy down-ward update and total noise energy estimation
+ * Long-term energies and relative frame energy updates
+ * Correlation correction as a function of total noise level
+ *----------------------------------------------------------------*/
+
+ noise_est_down( fr_bands, st->hNoiseEst->bckr, tmpN, tmpE, st->min_band, st->max_band, &st->hNoiseEst->totalNoise, Etot, &st->hNoiseEst->Etot_last, &st->hNoiseEst->Etot_v_h2 );
+
+ if ( lr_vad_enabled && st->idchan == 0 )
+ {
+ noise_est_down( fr_bands_LR[0], hCPE->hFrontVad[0]->hNoiseEst->bckr, tmpN_LR[0], tmpE_LR[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise, Etot_LR[0], &hCPE->hFrontVad[0]->hNoiseEst->Etot_last, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2 );
+ noise_est_down( fr_bands_LR[1], hCPE->hFrontVad[1]->hNoiseEst->bckr, tmpN_LR[1], tmpE_LR[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise, Etot_LR[1], &hCPE->hFrontVad[1]->hNoiseEst->Etot_last, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2 );
+ corr_shiftL = correlation_shift( hCPE->hFrontVad[0]->hNoiseEst->totalNoise );
+ corr_shiftR = correlation_shift( hCPE->hFrontVad[1]->hNoiseEst->totalNoise );
+ }
+
+ *relE = Etot - st->lp_speech;
+
+ corr_shift = correlation_shift( st->hNoiseEst->totalNoise );
+
+ /*----------------------------------------------------------------*
+ * FD-CNG Noise Estimator
+ *----------------------------------------------------------------*/
+
+ if ( st->hFdCngEnc != NULL )
+ {
+ resetFdCngEnc( st );
+
+ if ( st->idchan == 0 || element_mode == IVAS_CPE_MDCT )
+ {
+ if ( element_mode == IVAS_CPE_TD && lr_vad_enabled && band_energies_LR != NULL )
+ {
+ perform_noise_estimation_enc( band_energies_LR, enerBuffer, st->hFdCngEnc, input_Fs, hCPE );
+ }
+ else
+ {
+ perform_noise_estimation_enc( band_energies, enerBuffer, st->hFdCngEnc, input_Fs, hCPE );
+ }
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Select SID or FRAME_NO_DATA frame if DTX enabled
+ *-----------------------------------------------------------------*/
+
+ if ( hCPE != NULL && element_mode != IVAS_CPE_DFT && element_mode != IVAS_CPE_MDCT )
+ {
+ *vad_flag_dtx = 1;
+ }
+
+ if ( st->Opt_DTX_ON == 1 && *vad_flag_dtx == 0 && element_mode == IVAS_CPE_DFT && element_brate <= ACELP_16k40 && hCPE->hStereoDft->hConfig->force_mono_transmission == 1 ) /* force LP_CNG usage for MASA DTX when mono tranmission */
+ {
+ st->cng_type = LP_CNG;
+ }
+
+ dtx( st, ivas_total_brate, *vad_flag_dtx, inp_12k8 );
+
+ if ( hCPE != NULL && hCPE->hStereoDft != NULL && st->core_brate == SID_2k40 )
+ {
+ /* Add another period of expected xcorr updates */
+ hCPE->hStereoDft->expectedNumUpdates += st->hDtxEnc->max_SID;
+ }
+
+ /*----------------------------------------------------------------*
+ * Adjust FD-CNG Noise Estimator
+ *----------------------------------------------------------------*/
+
+ if ( st->hFdCngEnc != NULL && ( st->ini_frame == 0 || last_element_brate != element_brate || st->last_bwidth != st->bwidth ) )
+ {
+ int32_t total_brate;
+
+ total_brate = ( element_mode == IVAS_SCE ) ? st->total_brate : st->bits_frame_nominal * FRAMES_PER_SEC;
+ configureFdCngEnc( st->hFdCngEnc, max( st->input_bwidth, WB ), total_brate );
+ if ( hCPE != NULL )
+ {
+ st->hFdCngEnc->hFdCngCom->CngBitrate = hCPE->element_brate - 1;
+ }
+ }
+
+ if ( st->hFdCngEnc != NULL && st->Opt_DTX_ON )
+ {
+ AdjustFirstSID( st );
+ }
+
+ /*----------------------------------------------------------------*
+ * LP analysis
+ *----------------------------------------------------------------*/
+
+ alw_pitch_lag_12k8[0] = st->old_pitch_la;
+ alw_pitch_lag_12k8[1] = st->old_pitch_la;
+ alw_voicing[0] = st->voicing[2];
+ alw_voicing[1] = st->voicing[2];
+
+ i = 0;
+ if ( element_mode == IVAS_CPE_TD && st->idchan == 1 && hCPE->hStereoTD->tdm_low_rate_mode == 1 )
+ {
+ i = 1;
+ }
+
+ analy_lp( inp_12k8, L_FRAME, L_look, ener, A, epsP, lsp_new, lsp_mid, st->lsp_old1, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, i );
+
+ lsp2lsf( lsp_new, lsf_new, M, INT_FS_12k8 );
+ stab_fac = lsf_stab( lsf_new, st->lsf_old1, 0, L_FRAME );
+ mvr2r( lsf_new, st->lsf_old1, M );
+
+ if ( element_mode == IVAS_CPE_TD && st->idchan == 1 )
+ {
+ /*----------------------------------------------------------------*
+ * Comparison of the LP coefficents to determine if it is possible
+ * to reuse the primary channel LP coefficients in the secondary channel
+ *----------------------------------------------------------------*/
+
+ hCPE->hStereoTD->tdm_lp_reuse_flag = tdm_lp_comparison( hCPE->hStereoTD, hCPE->hStereoClassif, st, inp_12k8, tdm_A_PCh, A, M, tdm_lsp_new_PCh, lsp_new, L_FRAME, element_brate - nb_bits_metadata * FRAMES_PER_SEC );
+ }
+
+ /*----------------------------------------------------------------*
+ * Compute weighted input (for OL pitch analysis)
+ * OL pitch analysis
+ * stable high pitch detection
+ * 1/4 pitch precision improvement
+ *----------------------------------------------------------------*/
+
+ find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A, Aw, inp_12k8, TILT_FAC, wsp, &st->mem_wsp, GAMMA1_FLT, L_look );
+
+ if ( st->vad_flag == 0 )
+ {
+ /* reset the OL pitch tracker memories during inactive frames */
+ pitch_ol_init( &st->old_thres, &st->old_pitch, &st->delta_pit, &st->old_corr );
+ }
+
+ old_pitch1 = st->pitch[1];
+
+ pitch_ol( st->pitch, st->voicing, &st->old_pitch, &st->old_corr, corr_shift, &st->old_thres, &st->delta_pit, st->old_wsp2, wsp, st->mem_decim2, *relE, L_look, st->clas, st->input_bwidth, st->Opt_SC_VBR );
+
+ /* Updates for adaptive lag window memory */
+ st->old_pitch_la = st->pitch[2];
+
+ /* Detection of very short stable pitch period */
+ StableHighPitchDetect( &flag_spitch, st->pitch, st->voicing, st->Bin_E, wsp, st->localVAD, &st->voicing_sm, &st->voicing0_sm, &st->LF_EnergyRatio_sm, &st->predecision_flag, &st->diff_sm, &st->energy_sm );
+
+ /* 1/4 pitch precision improvement */
+ if ( element_brate <= IVAS_32k )
+ {
+ pitch_ol2( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[0], &voicing_fr[0], 0, wsp, 7 );
+ pitch_ol2( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[1], &voicing_fr[1], L_SUBFR, wsp, 7 );
+ pitch_ol2( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[2], &voicing_fr[2], 2 * L_SUBFR, wsp, 7 );
+ pitch_ol2( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[3], &voicing_fr[3], 3 * L_SUBFR, wsp, 7 );
+ }
+ else
+ {
+ pitch_fr[0] = st->pitch[0];
+ pitch_fr[1] = st->pitch[0];
+ pitch_fr[2] = st->pitch[1];
+ pitch_fr[3] = st->pitch[1];
+
+ voicing_fr[0] = st->voicing[0];
+ voicing_fr[1] = st->voicing[0];
+ voicing_fr[2] = st->voicing[1];
+ voicing_fr[3] = st->voicing[1];
+ }
+
+ /*------------------------------------------------------------------*
+ * Update estimated noise energy and voicing cut-off frequency
+ *-----------------------------------------------------------------*/
+
+ noise_est( st, old_pitch1, tmpN, epsP, Etot, *relE, corr_shift, tmpE, fr_bands, cor_map_sum, &ncharX, &sp_div,
+ &non_staX, loc_harm, lf_E, &st->hNoiseEst->harm_cor_cnt, st->hNoiseEst->Etot_l_lp, &dummy /*sp_floor*/, S_map, hStereoClassif, NULL, st->ini_frame );
+
+ if ( lr_vad_enabled && st->idchan == 0 )
+ {
+ /* Run noise_est for Left and Right channel */
+ *loc_harmLR = *loc_harm;
+ noise_est( st, old_pitch1, tmpN_LR[0], epsP, Etot_LR[0], Etot_LR[0] - hCPE->hFrontVad[0]->lp_speech, corr_shiftL, tmpE_LR[0], fr_bands_LR[0], &cor_map_sum_LR[0], &ncharX_LR, &sp_div_LR,
+ &non_staX_LR, loc_harmLR, lf_E_LR[0], &hCPE->hFrontVad[0]->hNoiseEst->harm_cor_cnt, hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp, &dummy, S_map_LR, 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( st, old_pitch1, tmpN_LR[1], epsP, Etot_LR[1], Etot_LR[1] - hCPE->hFrontVad[1]->lp_speech, corr_shiftR, tmpE_LR[1], fr_bands_LR[1], &cor_map_sum_LR[1], &ncharX_LR, &sp_div_LR,
+ &non_staX_LR, loc_harmLR, lf_E_LR[1], &hCPE->hFrontVad[1]->hNoiseEst->harm_cor_cnt, hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp, &dummy, S_map_LR, NULL, hCPE->hFrontVad[1], hCPE->hFrontVad[0]->ini_frame );
+ }
+
+ /*------------------------------------------------------------------*
+ * Update parameters used in the VAD and DTX
+ *-----------------------------------------------------------------*/
+
+ vad_param_updt( st, corr_shift, corr_shift, A, old_pitch1, NULL, 1 );
+
+ if ( lr_vad_enabled && st->idchan == 0 )
+ {
+ vad_param_updt( st, corr_shiftL, corr_shiftR, A, old_pitch1, &hCPE->hFrontVad[0], CPE_CHANNELS );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Find spectral tilt
+ * UC and VC frame selection
+ *-----------------------------------------------------------------*/
+
+ find_tilt( fr_bands, st->hNoiseEst->bckr, ee, st->pitch, st->voicing, lf_E, corr_shift, st->input_bwidth, st->max_band, hp_E, MODE1, &( st->bckr_tilt_lt_flt ), st->Opt_SC_VBR );
+
+ st->coder_type = find_uv( st, pitch_fr, voicing_fr, inp_12k8, ee, &dE1X, corr_shift, *relE, Etot, hp_E, &flag_spitch, last_core_orig, hStereoClassif );
+
+ /*-----------------------------------------------------------------*
+ * channel aware mode configuration *
+ *-----------------------------------------------------------------*/
+
+ st->rf_mode = 0;
+ st->rf_target_bits_write = 0;
+
+ /*-----------------------------------------------------------------*
+ * Signal classification for FEC
+ * TC frame selection
+ *-----------------------------------------------------------------*/
+
+ st->clas = signal_clas( st, inp_12k8, ee, *relE, L_look, tdm_SM_last_clas );
+
+ select_TC( MODE1, st->tc_cnt, &st->coder_type, st->localVAD );
+
+ if ( st->Opt_SC_VBR )
+ {
+ st->hSC_VBR->Local_VAD = st->localVAD;
+ }
+
+ /*-----------------------------------------------------------------*
+ * Collect stereo classifier features
+ *-----------------------------------------------------------------*/
+
+ if ( hStereoClassif != NULL )
+ {
+ stereo_classifier_features( hStereoClassif, st->idchan, element_mode, localVAD_HE_SAD, lsf_new, epsP, st->pitch, st->voicing, *cor_map_sum, non_staX, sp_div, st->clas );
+ }
+
+ /*----------------------------------------------------------------*
+ * 1st stage speech/music classification (GMM model)
+ *----------------------------------------------------------------*/
+
+ smc_dec = ivas_smc_gmm( st, hStereoClassif, localVAD_HE_SAD, Etot, lsp_new, *cor_map_sum, epsP, PS, non_staX, *relE, &high_lpn_flag, flag_spitch );
+
+
+ /*----------------------------------------------------------------*
+ * VAD energy updates
+ * Update of old per-band energy spectrum
+ *----------------------------------------------------------------*/
+
+ long_enr( st, Etot, localVAD_HE_SAD, high_lpn_flag, NULL, 1, NULL, NULL );
+
+ mvr2r( fr_bands + NB_BANDS, st->hNoiseEst->enrO, NB_BANDS );
+
+ if ( lr_vad_enabled && st->idchan == 0 )
+ {
+ long_enr( st, -1, localVAD_HE_SAD, high_lpn_flag, hCPE->hFrontVad, CPE_CHANNELS, localVAD_HE_SAD_LR, Etot_LR );
+
+ mvr2r( fr_bands_LR[0] + NB_BANDS, hCPE->hFrontVad[0]->hNoiseEst->enrO, NB_BANDS );
+ mvr2r( fr_bands_LR[1] + NB_BANDS, hCPE->hFrontVad[1]->hNoiseEst->enrO, NB_BANDS );
+ }
+
+ /*----------------------------------------------------------------*
+ * SNR-based speech/music classification
+ * AC frame selection
+ *----------------------------------------------------------------*/
+
+ st->GSC_IVAS_mode = 0;
+ if ( st->idchan == 1 && element_mode == IVAS_CPE_TD )
+ {
+ /* No speech/music classification in the secondary channel of TD stereo */
+ st->sp_aud_decision1 = 0;
+ st->sp_aud_decision2 = 0;
+
+ st->GSC_noisy_speech = 0;
+ if ( st->hGSCEnc != NULL )
+ {
+ st->hGSCEnc->noise_lev = NOISE_LEVEL_SP3;
+ }
+ }
+ else if ( element_mode != IVAS_CPE_MDCT )
+ {
+ /* SNR-based speech/music classification */
+ if ( ( element_mode >= IVAS_CPE_DFT && element_brate >= IVAS_24k4 ) || ( element_mode == IVAS_SCE && element_brate >= SCE_SMC_THR ) )
+ {
+ if ( 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( st, st->bits_frame_nominal * FRAMES_PER_SEC, element_mode, MCT_flag );
+ st->sba_br_sw_while_no_data = 0;
+ }
+ else if ( ivas_format == SBA_FORMAT && st->core_brate == FRAME_NO_DATA && element_brate != last_element_brate )
+ {
+ st->sba_br_sw_while_no_data = 1;
+ }
+
+ if ( flag_16k_smc )
+ {
+ /* Compute core-coder buffers at internal sampling rate */
+ error = ivas_compute_core_buffers( st, NULL, old_inp_16k, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener, A, Aw, epsP, lsp_new, lsp_mid );
+ if ( error != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ smc_dec = ivas_acelp_tcx20_switching( st, st->speech_enc_flt, st->wspeech_enc_flt, non_staX, pitch_fr, voicing_fr, currFlatness, lsp_mid, stab_fac, res_cod_SNR_M, flag_16k_smc );
+ }
+ else
+ {
+ smc_dec = ivas_acelp_tcx20_switching( st, inp_12k8, wsp, non_staX, pitch_fr, voicing_fr, currFlatness, lsp_mid, stab_fac, res_cod_SNR_M, flag_16k_smc );
+ }
+ }
+ /* Switch to ACELP for non-harmonic transient signals */
+ else if ( ( ( element_mode >= IVAS_CPE_DFT && element_brate <= IVAS_16k4 ) || ( element_mode == IVAS_SCE && element_brate < SCE_SMC_THR ) ) && ( loc_harm[0] != 1 ) && smc_dec == MUSIC )
+ {
+ if ( element_mode == IVAS_SCE )
+ {
+ if ( transient_analysis( st->hTranDet, st->hNoiseEst->cor_map, st->hNoiseEst->multi_harm_limit ) )
+ {
+ smc_dec = SPEECH;
+ }
+ }
+ else if ( element_mode == IVAS_CPE_DFT )
+ {
+ for ( i = 0; i < CPE_CHANNELS; i++ )
+ {
+ if ( smc_dec != SPEECH && transient_analysis( hCPE->hCoreCoder[i]->hTranDet, st->hNoiseEst->cor_map, st->hNoiseEst->multi_harm_limit ) )
+ {
+ smc_dec = SPEECH; /* overwrite initial music decision, initial SPEECH_MUSIC never changed */
+ }
+ }
+ }
+ }
+
+ /* 2nd stage speech/music classification (ACELP/GSC/TCX core selection) */
+ ivas_smc_mode_selection( st, element_brate, smc_dec, *relE, Etot, attack_flag, inp_12k8, S_map, flag_spitch );
+ }
+ /*----------------------------------------------------------------*
+ * Final VAD correction (when HE-SAD is used instead of the normal VAD,
+ * rewrite the VAD flag by VAD flag with DTX hangover for further processing)
+ *----------------------------------------------------------------*/
-/*-------------------------------------------------------------------*
- * Local function prototypes
- *--------------------------------------------------------------------*/
+ if ( st->Opt_DTX_ON && element_mode != IVAS_CPE_DFT )
+ {
+ st->vad_flag = *vad_flag_dtx;
+ }
-static void calculate_energy_buffer( CPE_ENC_HANDLE hCPE, float enerBuffer_dft[], const int16_t no_channels, const int32_t input_Fs );
-#ifdef IVAS_FIXED_ENC
-static void calculate_energy_buffer_fx( CPE_ENC_HANDLE hCPE, Word64 enerBuffer_dft_fx[], Word16 *enerBuffer_dft_q_fx, const Word16 no_channels, const Word32 input_Fs );
-#endif
+ /*-----------------------------------------------------------------*
+ * Update old input signal buffer
+ *-----------------------------------------------------------------*/
-/*-------------------------------------------------------------------*
- * pre_proc_front_ivas()
- *
- * Front Pre-processing for IVAS
- * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification)
- *--------------------------------------------------------------------*/
+ mvr2r( &old_inp_12k8[L_FRAME], st->old_inp_12k8, L_INP_MEM );
-ivas_error pre_proc_front_ivas(
+ pop_wmops();
+ return error;
+}
+#ifdef IVAS_FLOAT_FIXED
+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 int32_t element_brate, /* i : SCE/CPE element bitrate */
@@ -98,7 +883,7 @@ ivas_error pre_proc_front_ivas(
const float currFlatness, /* i : flatness parameter */
const int16_t tdm_ratio_idx, /* i : Current Ratio_L index */
float fr_bands_LR[][2 * NB_BANDS], /* i : energy in frequency bands */
- const float Etot_LR[], /* i : total energy Left & Right channel */
+ const float Etot_LR[], /* i : total energy Left & Right channel Q8*/
float lf_E_LR[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */
const int16_t localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */
float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */
@@ -133,8 +918,12 @@ ivas_error pre_proc_front_ivas(
float corr_shift; /* correlation shift */
float sp_div, PS[128]; /* speech/music clasif. parameters */
int16_t L_look; /* length of look-ahead */
- float snr_sum_he; /* HE SAD parameters */
- float hp_E[2]; /* Energy in HF */
+#if 1
+ float snr_sum_he; /* HE SAD parameters */
+#endif
+ float mem_decim_dummy[2 * L_FILT_MAX]; /* dummy decimation filter memory */
+ float temp1F_icatdmResampBuf[L_FILT_MAX]; /* temp buffers for ICA TDM resamplers */
+ float hp_E[2]; /* Energy in HF */
int16_t flag_spitch;
int16_t high_lpn_flag;
float lsf_new[M];
@@ -146,7 +935,6 @@ ivas_error pre_proc_front_ivas(
float alw_voicing[2];
int16_t last_core_orig;
float dummy;
- float mem_decim_dummy[2 * L_FILT_MAX]; /* dummy decimation filter memory */
float S_map[L_FFT / 2];
int16_t i, lMemRecalc, lMemRecalc_12k8;
int16_t smc_dec;
@@ -158,13 +946,59 @@ ivas_error pre_proc_front_ivas(
int16_t *tdm_SM_last_clas, tmpS;
float *res_cod_SNR_M, tmpF[STEREO_DFT_BAND_MAX];
STEREO_CLASSIF_HANDLE hStereoClassif;
- float temp1F_icatdmResampBuf[L_FILT_MAX]; /* temp buffers for ICA TDM resamplers */
- int16_t old_pitch1; /* previous frame OL pitch[1] @12.8 kHz */
+ int16_t old_pitch1; /* previous frame OL pitch[1] @12.8 kHz */
int16_t LR_localVAD;
ivas_error error;
push_wmops( "pre_proc_front" );
+#ifdef IVAS_FLOAT_FIXED
+ Word16 *signal_in_fx;
+ Word16 *new_inp_12k8_fx; /* pointers to current frame and new data */
+ CLDFB_SCALE_FACTOR cldfbScale;
+ Word32 *enerBuffer_fx;
+ Word16 enerBuffer_exp; /*[CLDFB_NO_CHANNELS_MAX];*/
+ Word16 *temp1F_icatdmResampBuf_fx;
+ Word16 *old_inp_12k8_fx;
+ Word16 *old_inp_16k_fx;
+ Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */
+ Word32 Etot_fx; /* total energy */
+#if 0
+ Word32 fr_bands_fx[2 * NB_BANDS]; /* energy in frequency bands */
+ Word16 Q_new;
+ Word16 new_inp_out_size, mem_decim_size;
+ Word16 snr_sum_he_fx; /* HE SAD parameters */
+ Word16 Q_new_inp;
+ Word16 corr_shift_fx;
+ Word16 dummy_fx;
+ Word16 Etot_LR_fx[2];
+ Word16 Q_exp;
+ Word32 Le_min_scaled;
+ Word32 fr_bands_LR_fx[2][2 * NB_BANDS];
+ Word16 relE_fx;
+ Word32 tmpN_fx[NB_BANDS]; /* Temporary noise update */
+ Word32 tmpE_fx[NB_BANDS]; /* Temporary averaged energy of 2 sf. */
+ Word32 tmpN_LR_fx[CPE_CHANNELS][NB_BANDS]; /* Temporary noise update */
+ Word32 tmpE_LR_fx[CPE_CHANNELS][NB_BANDS]; /* Temporary averaged energy of 2 sf. */
+#endif
+
+ signal_in_fx = (Word16 *) malloc( 2 * 1965 * sizeof( Word16 * ) );
+ enerBuffer_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) );
+ old_inp_12k8_fx = (Word16 *) malloc( 496 * sizeof( Word16 * ) );
+ old_inp_16k_fx = (Word16 *) malloc( 880 * sizeof( Word16 * ) );
+ mem_decim_dummy_fx = (Word16 *) malloc( 90 * sizeof( Word16 * ) );
+ temp1F_icatdmResampBuf_fx = (Word16 *) malloc( 45 * sizeof( Word16 * ) );
+
+ Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX];
+
+#ifndef MSAN_FIX
+ floatToFixed_arr( old_inp_12k8, old_inp_12k8_fx, 0, 496 );
+#endif // MSAN_FIX
+#endif
/*------------------------------------------------------------------*
* Initialization
*------------------------------------------------------------------*/
@@ -217,10 +1051,55 @@ ivas_error pre_proc_front_ivas(
res_cod_SNR_M = hCPE->hStereoDft->res_cod_SNR_M;
}
}
+#if 0
+ set32_fx( tmpF_fx, 0, STEREO_DFT_BAND_MAX );
+ res_cod_SNR_M_fx = tmpF_fx;
+
+ LR_localVAD = 0;
+
+ IF ( hSCE != NULL )
+ {
+ st = hSCE->hCoreCoder[n];
+ signal_in_fx = hSCE->hCoreCoder[n]->input_fx;
+ element_mode = IVAS_SCE;
+ last_element_brate = hSCE->last_element_brate;
+ hStereoClassif = NULL;
+ lr_vad_enabled = 0;
+ }
+ ELSE /* CPE */
+ {
+ st = hCPE->hCoreCoder[n];
+ signal_in_fx = hCPE->hCoreCoder[n]->input_fx;
+ element_mode = hCPE->element_mode;
+ last_element_brate = hCPE->last_element_brate;
+ hStereoClassif = hCPE->hStereoClassif;
+ lr_vad_enabled = 0;
+ IF ( hCPE->hFrontVad[0] != NULL && NE_16(hCPE->element_mode, IVAS_CPE_MDCT ))
+ {
+ lr_vad_enabled = 1;
+ }
+
+ IF ( lr_vad_enabled && EQ_16(n, 0 ))
+ {
+ /* Combine localVAD and vad_flag from LR processing */
+ LR_localVAD = hCPE->hCoreCoder[0]->localVAD || hCPE->hCoreCoder[1]->localVAD;
+ }
+
+ 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 );
+ }
+ IF ( hCPE->hStereoDft != NULL )
+ {
+ res_cod_SNR_M_fx = hCPE->hStereoDft->res_cod_SNR_M_fx;
+ }
+ }
+#endif
lMemRecalc_12k8 = 0;
lMemRecalc = 0;
- if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_MDCT )
+ IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
{
lMemRecalc = NS2SA( st->input_Fs, L_MEM_RECALC_NS );
lMemRecalc_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_NS );
@@ -229,25 +1108,28 @@ ivas_error pre_proc_front_ivas(
input_Fs = st->input_Fs;
localVAD_HE_SAD = 0;
+#if 1
snr_sum_he = 0;
-
+#endif
corr_shiftL = 0;
corr_shiftR = 0;
-
- if ( hSCE != NULL )
+#if 0
+ snr_sum_he_fx = 0;
+#endif
+ IF( hSCE != NULL )
{
*vad_hover_flag = 0;
}
st->sp_aud_decision1 = 0;
st->sp_aud_decision2 = 0;
st->coder_type = GENERIC;
- if ( st->hGSCEnc != NULL )
+ IF( st->hGSCEnc != NULL )
{
st->hGSCEnc->noise_lev = NOISE_LEVEL_SP0;
}
*attack_flag = 0;
- if ( st->Opt_SC_VBR )
+ IF( st->Opt_SC_VBR )
{
st->hSC_VBR->bump_up = 0;
st->hSC_VBR->ppp_mode = 0;
@@ -259,7 +1141,12 @@ ivas_error pre_proc_front_ivas(
new_inp_12k8 = old_inp_12k8 + L_INP_MEM; /* pointer to new samples of the input signal in 12.8kHz core */
inp_12k8 = new_inp_12k8 - L_look; /* pointer to the current frame of input signal in 12.8kHz core */
-
+#ifdef IVAS_FLOAT_FIXED
+ new_inp_12k8_fx = old_inp_12k8_fx + L_INP_MEM; /* pointer to new samples of the input signal in 12.8kHz core */
+#if 0
+ inp_12k8_fx = new_inp_12k8_fx - L_look; /* pointer to the current frame of input signal in 12.8kHz core */
+#endif
+#endif
if ( element_mode != IVAS_CPE_DFT )
{
new_inp_12k8 -= L_FILT;
@@ -281,6 +1168,27 @@ ivas_error pre_proc_front_ivas(
mvr2r( st->old_wsp, old_wsp, L_WSP_MEM );
wsp = old_wsp + L_WSP_MEM; /* pointer to the current frame of weighted signal in 12.8kHz core */
+
+ IF( NE_16( element_mode, IVAS_CPE_DFT ) )
+ {
+ new_inp_12k8_fx -= L_FILT;
+ }
+#if 0
+ 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);
+ }
+ ELSE IF(EQ_16(element_mode, IVAS_CPE_TD))
+ {
+ Copy(st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - lMemRecalc_12k8 - L_FILT);
+ }
+ ELSE
+ {
+ Copy(st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - L_FILT);
+ }
+ Copy(st->old_wsp, old_wsp, L_WSP_MEM);
+ wsp = old_wsp + L_WSP_MEM; /* pointer to the current frame of weighted signal in 12.8kHz core */
+#endif
st->rf_mode = st->Opt_RF_ON;
last_core_orig = st->last_core;
@@ -289,29 +1197,114 @@ ivas_error pre_proc_front_ivas(
* energy analysis
*---------------------------------------------------------------*/
- if ( element_mode == IVAS_SCE || ( element_mode == IVAS_CPE_MDCT && st->Opt_DTX_ON ) )
+ floatToFixed_arr( signal_in - (Word16) ( input_Fs / 50 ), signal_in_fx, 0, (Word16) ( input_Fs / 25 ) );
+ signal_in_fx = signal_in_fx + input_Fs / 50;
+ IF( EQ_16( element_mode, IVAS_SCE ) || ( EQ_16( element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) )
{
- analysisCldfbEncoder_ivas( st, signal_in, input_frame, realBuffer, imagBuffer, enerBuffer );
+ analysisCldfbEncoder_ivas_fx( st, signal_in_fx, realBuffer_fx, imagBuffer_fx, realBuffer16, imagBuffer16, enerBuffer_fx, &enerBuffer_exp, &cldfbScale );
+ for ( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ for ( int j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ realBuffer[i][j] = (float) realBuffer_fx[i][j] / ( 1 << ( 16 - cldfbScale.lb_scale ) );
+ imagBuffer[i][j] = (float) imagBuffer_fx[i][j] / ( 1 << ( 16 - cldfbScale.lb_scale ) );
+ }
+ }
+ cldfbScale.hb_scale = cldfbScale.lb_scale;
+ fixedToFloat_arrL( enerBuffer_fx, enerBuffer, 31 - enerBuffer_exp, 60 );
}
- else if ( ( element_mode == IVAS_CPE_TD && st->idchan == 0 ) || ( st->idchan == 1 && st->tdm_LRTD_flag ) )
+ ELSE IF( ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 0 ) ) || ( EQ_16( st->idchan, 1 ) && st->tdm_LRTD_flag ) )
{
/* cldfb analysis only for pri. channel */
- analysisCldfbEncoder_ivas( st, signal_in - NS2SA( input_Fs, L_MEM_RECALC_TBE_NS ), input_frame, realBuffer, imagBuffer, enerBuffer );
+ analysisCldfbEncoder_ivas_fx( st, signal_in_fx - NS2SA( input_Fs, L_MEM_RECALC_TBE_NS ), realBuffer_fx, imagBuffer_fx, realBuffer16, imagBuffer16, enerBuffer_fx, &enerBuffer_exp, &cldfbScale );
+ for ( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ for ( int j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ realBuffer[i][j] = (float) realBuffer_fx[i][j] / ( 1 << ( 16 - cldfbScale.lb_scale ) );
+ imagBuffer[i][j] = (float) imagBuffer_fx[i][j] / ( 1 << ( 16 - cldfbScale.lb_scale ) );
+ }
+ }
+ cldfbScale.hb_scale = cldfbScale.lb_scale;
+ fixedToFloat_arrL( enerBuffer_fx, enerBuffer, 31 - enerBuffer_exp, 60 );
}
- else if ( element_mode == IVAS_CPE_DFT )
+ ELSE IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
calculate_energy_buffer( hCPE, enerBuffer, st->cldfbAnaEnc->no_channels, input_Fs );
+ f2me_buf( enerBuffer, enerBuffer_fx, &enerBuffer_exp, 60 );
}
- else
+ ELSE
{
- set_f( enerBuffer, 0, CLDFB_NO_CHANNELS_MAX );
+ set32_fx( enerBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX );
+ enerBuffer_exp = 31;
}
/*----------------------------------------------------------------*
* Change the sampling frequency to 12.8 kHz
* (if not available from downsampled DMX)
*----------------------------------------------------------------*/
+#if 0 // Disabled due to high mld -- Scaling needs to be handled.
+ IF( element_mode == IVAS_SCE )
+ {
+ new_inp_out_size = modify_Fs_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 );
+
+ fixedToFloat_arr( new_inp_12k8_fx, new_inp_12k8, Q_new_inp, new_inp_out_size ); // To be removed
+ fixedToFloat_arr( st->mem_decim_fx, st->mem_decim, 0, mem_decim_size ); // To be removed
+
+ change_q( new_inp_12k8_fx, new_inp_out_size, Q_new_inp );
+
+ Copy( st->mem_decim_fx, mem_decim_dummy_fx, 2 * L_FILT_MAX );
+
+ set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
+
+ new_inp_out_size = modify_Fs_fx( temp1F_icatdmResampBuf_fx, NS2SA( 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 );
+
+ fixedToFloat_arr( new_inp_12k8_fx + L_FRAME, new_inp_12k8 + L_FRAME, Q_new_inp, new_inp_out_size ); // To be removed
+ change_q( new_inp_12k8_fx + L_FRAME, new_inp_out_size, Q_new_inp );
+ }
+ ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
+ {
+ /* reconstruct past segment of the Secondary channel input signal when switching from DFT stereo */
+ IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && EQ_16( st->idchan, 1 ) )
+ {
+ Word16 length_inp = NS2SA( input_Fs, L_MEM_RECALC_SCH_NS );
+ Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS );
+
+ new_inp_out_size = modify_Fs_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 );
+
+ fixedToFloat_arr( st->mem_decim_fx, st->mem_decim, 0, mem_decim_size ); // To be removed
+ fixedToFloat_arr( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_12k8 - lMemRecalc_12k8 - length_12k8, Q_new_inp, new_inp_out_size ); // To be removed
+
+ change_q( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_out_size, Q_new_inp );
+ }
+
+ new_inp_out_size = modify_Fs_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 );
+ fixedToFloat_arr( new_inp_12k8_fx - lMemRecalc_12k8, new_inp_12k8 - lMemRecalc_12k8, Q_new_inp, new_inp_out_size ); // To be removed
+ fixedToFloat_arr( st->mem_decim_fx, st->mem_decim, 0, mem_decim_size ); // To be removed
+
+ change_q( new_inp_12k8_fx - lMemRecalc_12k8, new_inp_out_size, Q_new_inp );
+ IF( GT_16( lMemRecalc, 0 ) )
+ {
+ new_inp_out_size = modify_Fs_fx( signal_in_fx + input_frame - lMemRecalc, lMemRecalc, input_Fs, new_inp_12k8_fx + L_FRAME - lMemRecalc_12k8, INT_FS_12k8, mem_decim_dummy_fx, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size );
+ fixedToFloat_arr( new_inp_12k8_fx + L_FRAME - lMemRecalc_12k8, new_inp_12k8 + L_FRAME - lMemRecalc_12k8, Q_new_inp, new_inp_out_size ); // To be removed
+
+ change_q( new_inp_12k8_fx + L_FRAME - lMemRecalc_12k8, new_inp_out_size, Q_new_inp );
+ }
+ set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
+ new_inp_out_size = modify_Fs_fx( temp1F_icatdmResampBuf_fx, NS2SA( 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 );
+ fixedToFloat_arr( new_inp_12k8_fx + L_FRAME, new_inp_12k8 + L_FRAME, Q_new_inp, new_inp_out_size ); // To be removed
+
+ change_q( new_inp_12k8_fx + L_FRAME, new_inp_out_size, Q_new_inp );
+ }
+ ELSE /* DFT stereo */
+ {
+ /* 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_decim_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) );
+ mvr2r( signal_in + input_frame - NS2SA( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ); // To be removed
+ }
+#else
if ( element_mode == IVAS_SCE )
{
modify_Fs( signal_in, input_frame, input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim, ( st->max_bwidth == NB ) );
@@ -346,7 +1339,7 @@ ivas_error pre_proc_front_ivas(
/* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */
mvr2r( signal_in + input_frame - NS2SA( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) );
}
-
+#endif
/* save input resampled at 12.8kHz, non-preemhasised */
if ( element_mode == IVAS_CPE_DFT )
{
@@ -360,11 +1353,193 @@ ivas_error pre_proc_front_ivas(
{
mvr2r( new_inp_12k8, st->buf_speech_enc_flt + L_FRAME32k, L_FRAME );
}
-
+#ifndef MSAN_FIX /*To be enabled when updations related to new_inp_12k8_fx is enabled */
+#if 1
+ 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 );
+ Scale_sig( st->buf_speech_enc + L_FRAME32k - STEREO_DFT_OVL_12k8, L_FRAME + STEREO_DFT_OVL_12k8, 1 );
+ }
+ 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, L_FRAME + lMemRecalc_12k8 + L_FILT );
+ Scale_sig( st->buf_speech_enc + L_FRAME32k - lMemRecalc_12k8 - L_FILT, L_FRAME + lMemRecalc_12k8 + L_FILT, 1 );
+ }
+ ELSE
+ {
+ Copy( new_inp_12k8_fx, st->buf_speech_enc + L_FRAME32k, L_FRAME );
+ Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 );
+ }
+#endif
+#endif // !MSAN_FIX
/*------------------------------------------------------------------*
* Perform fixed preemphasis (12.8 kHz signal) through 1 - g*z^-1
*-----------------------------------------------------------------*/
+#if 0 // Disabled due to high mld
+#if 0 // EVS-Version
+ Word16 headroom = 1;
+ IF( ( ( EQ_16( st->bwidth, NB ) ) || ( EQ_16( st->max_bwidth, NB ) ) ) && ( GT_32( st->input_Fs, 8000 ) ) )
+ {
+ headroom = add( headroom, 1 );
+ }
+ 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 */
+
+ st->mem_preemph_fx = st->mem_preemph_DFT_fx;
+ st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1];
+
+ Preemph_scaled( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, &Q_new, &st->mem_preemph_fx, st->Q_max, PREEMPH_FAC, 0, headroom, L_Q_MEM, L_FRAME, st->last_coder_type, 1 );
+
+ fixedToFloat_arr( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, new_inp_12k8 - STEREO_DFT_OVL_12k8, Q_new, L_FRAME ); // To be removed
+ dummy_fx = st->mem_preemph_fx;
+ Preemph_scaled( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, &Q_new, &dummy_fx, st->Q_max, PREEMPH_FAC, 0, headroom, L_Q_MEM, STEREO_DFT_OVL_12k8, st->last_coder_type, 1 );
+
+ st->mem_preemph = (float) st->mem_preemph_fx;
+ fixedToFloat_arr( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, new_inp_12k8 - STEREO_DFT_OVL_12k8 + L_FRAME, Q_new, STEREO_DFT_OVL_12k8 ); // To be removed
+ }
+ ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
+ {
+ IF( EQ_16( st->idchan, 0 ) )
+ {
+ IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
+ {
+ st->mem_preemph_fx = st->mem_preemph_DFT_fx;
+ 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_scaled( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), &Q_new, &st->mem_preemph_fx, st->Q_max, PREEMPH_FAC, 0, headroom, L_Q_MEM, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, st->last_coder_type, 1 );
+
+ st->mem_preemph = (float) st->mem_preemph_fx;
+ fixedToFloat_arr( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), new_inp_12k8 - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), Q_new, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); // To be removed
+ }
+
+ st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* == inp_12k8[L_FRAME-1] */
+ }
+
+ /* preemphasise past segment of the Secondary channel input signal when switching from DFT stereo */
+ IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && EQ_16( st->idchan, 1 ) )
+ {
+ Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS );
+ Preemph_scaled( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, &Q_new, &st->mem_preemph_fx, st->Q_max, PREEMPH_FAC, 0, headroom, L_Q_MEM, length_12k8, st->last_coder_type, 1 );
+ fixedToFloat_arr( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_12k8 - lMemRecalc_12k8 - length_12k8, Q_new, length_12k8 ); // To be removed
+ }
+
+ Preemph_scaled( new_inp_12k8_fx - lMemRecalc_12k8, &Q_new, &st->mem_preemph_fx, st->Q_max, PREEMPH_FAC, 0, headroom, L_Q_MEM, L_FRAME, st->last_coder_type, 1 );
+ dummy_fx = st->mem_preemph_fx;
+
+ fixedToFloat_arr( new_inp_12k8_fx - lMemRecalc_12k8, new_inp_12k8 - lMemRecalc_12k8, Q_new, L_FRAME ); // To be removed
+
+ Preemph_scaled( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, &Q_new, &dummy_fx, st->Q_max, PREEMPH_FAC, 0, headroom, L_Q_MEM, lMemRecalc_12k8 + L_FILT, st->last_coder_type, 1 );
+
+ fixedToFloat_arr( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, new_inp_12k8 - lMemRecalc_12k8 + L_FRAME, Q_new, lMemRecalc_12k8 + L_FILT ); // To be removed
+ }
+ ELSE /* IVAS_SCE or IVAS_CPE_MDCT */
+ {
+ floatToFixed_arr( new_inp_12k8, new_inp_12k8_fx, 0, L_FRAME + L_FILT ); // To be removed
+
+ Preemph_scaled( new_inp_12k8_fx, &Q_new, &st->mem_preemph_fx, st->Q_max, PREEMPH_FAC, 0, headroom, L_Q_MEM, L_FRAME, st->last_coder_type, 1 );
+ dummy_fx = st->mem_preemph_fx;
+
+ fixedToFloat_arr( new_inp_12k8_fx, new_inp_12k8, Q_new, L_FRAME ); // To be removed
+ floatToFixed_arr( new_inp_12k8, new_inp_12k8_fx, 0, L_FRAME + L_FILT ); // To be removed
+
+ Preemph_scaled( new_inp_12k8_fx + L_FRAME, &Q_new, &dummy_fx, st->Q_max, PREEMPH_FAC, 0, headroom, L_Q_MEM, L_FILT, st->last_coder_type, 1 );
+ st->mem_preemph = (float) st->mem_preemph_fx;
+
+ fixedToFloat_arr( new_inp_12k8_fx + 256, new_inp_12k8 + 256, Q_new, 12 ); // To be removed
+ }
+
+ Q_exp = sub( Q_new, st->Q_old );
+ st->prev_Q_old = st->Q_old;
+ move16();
+ st->Q_old = Q_new;
+ move16();
+#else // IVAS-Version
+
+ IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
+ {
+ floatToFixed_arr( new_inp_12k8 - STEREO_DFT_OVL_12k8, new_inp_12k8_fx - STEREO_DFT_OVL_12k8, 0, L_FRAME + STEREO_DFT_OVL_12k8 ); // To be removed
+ st->mem_preemph_fx = (Word16) st->mem_preemph;
+ st->mem_preemph_DFT_fx = (Word16) st->mem_preemph_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 */
+#if 1 // TOBE removed later
+ mvr2r( new_inp_12k8 - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); /* memory for TD/DFT stereo switching */
+ st->mem_preemph_DFT = old_inp_12k8[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1];
+#endif
+ st->mem_preemph_fx = st->mem_preemph_DFT_fx;
+ st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1];
+
+ preemph_fx( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
+ dummy_fx = st->mem_preemph_fx;
+ preemph_fx( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, PREEMPH_FAC_FLT, STEREO_DFT_OVL_12k8, &dummy_fx );
+ fixedToFloat_arr( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, new_inp_12k8 - STEREO_DFT_OVL_12k8, 0, L_FRAME + STEREO_DFT_OVL_12k8 ); // To be removed
+ st->mem_preemph = (float) st->mem_preemph_fx;
+ st->mem_preemph_DFT = (float) st->mem_preemph_DFT_fx;
+ }
+ ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
+ {
+ IF( EQ_16( st->idchan, 0 ) )
+ {
+
+ st->mem_preemph_fx = (Word16) st->mem_preemph;
+ IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
+ {
+#if 1 // TOBE removed later
+
+ floatToFixed_arr( new_inp_12k8 - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), 0, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); // To be removed
+ st->mem_preemph_DFT_fx = (Word16) st->mem_preemph_DFT;
+
+ mvr2r( st->inp_12k8_mem_stereo_sw, new_inp_12k8 - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT );
+#endif
+ st->mem_preemph_fx = st->mem_preemph_DFT_fx;
+ 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 );
+
+ fixedToFloat_arr( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), new_inp_12k8 - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), 0, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); // To be removed
+ }
+
+ st->mem_preemph_DFT_fx = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* == inp_12k8[L_FRAME-1] */
+#if 1 // TOBE removed later
+ st->mem_preemph_DFT = old_inp_12k8[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* == inp_12k8[L_FRAME-1] */ // TO be remove later
+#endif
+ }
+
+ /* preemphasise past segment of the Secondary channel input signal when switching from DFT stereo */
+ IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && EQ_16( st->idchan, 1 ) )
+ {
+ Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS );
+
+ floatToFixed_arr( new_inp_12k8 - lMemRecalc_12k8 - length_12k8, new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, 0, length_12k8 ); // To be removed
+
+ preemph_fx( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx );
+
+ fixedToFloat_arr( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_12k8 - lMemRecalc_12k8 - length_12k8, 0, length_12k8 ); // To be removed
+ }
+
+ floatToFixed_arr( new_inp_12k8 - lMemRecalc_12k8, new_inp_12k8_fx - lMemRecalc_12k8, 0, L_FRAME + lMemRecalc_12k8 + L_FILT ); // To be removed
+
+ preemph_fx( new_inp_12k8_fx - lMemRecalc_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
+ dummy_fx = st->mem_preemph_fx;
+ preemph_fx( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx );
+
+ fixedToFloat_arr( new_inp_12k8_fx - lMemRecalc_12k8, new_inp_12k8 - lMemRecalc_12k8, 0, L_FRAME + lMemRecalc_12k8 + L_FILT ); // To be removed
+ }
+ ELSE /* IVAS_SCE or IVAS_CPE_MDCT */
+ {
+ floatToFixed_arr( new_inp_12k8, new_inp_12k8_fx, 0, L_FRAME + L_FILT ); // To be removed
+ st->mem_preemph_fx = (Word16) st->mem_preemph;
+
+ preemph_fx( new_inp_12k8_fx, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
+ dummy_fx = st->mem_preemph_fx;
+ preemph_fx( new_inp_12k8_fx + L_FRAME, PREEMPH_FAC, L_FILT, &dummy_fx );
+
+ st->mem_preemph = (float) st->mem_preemph_fx;
+ dummy = (float) dummy_fx;
+ fixedToFloat_arr( new_inp_12k8_fx, new_inp_12k8, 0, L_FRAME + L_FILT ); // To be removed
+ }
+#endif
+#else
if ( element_mode == IVAS_CPE_DFT )
{
mvr2r( new_inp_12k8 - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); /* memory for TD/DFT stereo switching */
@@ -407,11 +1582,25 @@ ivas_error pre_proc_front_ivas(
dummy = st->mem_preemph;
preemph( new_inp_12k8 + L_FRAME, PREEMPH_FAC_FLT, L_FILT, &dummy );
}
+#endif
+#if 0
+ /*------------------------------------------------------------------*
+ * Scaling of memories
+ *-----------------------------------------------------------------*/
+ Q_new = 0;
+ floatToFixed_arrL( st->hNoiseEst->bckr, st->hNoiseEst->bckr_fx, Q_new + QSCALE, 20 );
+ floatToFixed_arrL( st->hNoiseEst->enrO, st->hNoiseEst->enrO_fx, Q_new + QSCALE, 20 );
+ floatToFixed_arrL( st->hNoiseEst->ave_enr2, st->hNoiseEst->ave_enr2_fx, Q_new + QSCALE, 20 );
+ floatToFixed_arrL( st->hNoiseEst->fr_bands1, st->hNoiseEst->fr_bands1_fx, Q_new + QSCALE, 20 );
+ floatToFixed_arrL( st->hNoiseEst->fr_bands2, st->hNoiseEst->fr_bands2_fx, Q_new + QSCALE, 20 );
+
+ Le_min_scaled = Scale_mem_pre_proc( st->ini_frame, Q_exp, &Q_new, old_inp_12k8_fx, &( st->mem_wsp_fx ), st->hNoiseEst->enrO_fx, st->hNoiseEst->bckr_fx,
+ st->hNoiseEst->ave_enr_fx, st->hNoiseEst->ave_enr2_fx, st->hNoiseEst->fr_bands1_fx, st->hNoiseEst->fr_bands2_fx, st->Bin_E_old_fx );
+#endif
/*-------------------------------------------------------------------------*
* Spectral analysis
*--------------------------------------------------------------------------*/
-
analy_sp( element_mode, hCPE, input_Fs, inp_12k8, st->Bin_E, st->Bin_E_old, fr_bands, lf_E, &Etot, st->min_band, st->max_band, band_energies, PS, fft_buff );
if ( hStereoClassif != NULL )
@@ -431,27 +1620,82 @@ ivas_error pre_proc_front_ivas(
* SAD (1-signal, 0-noise)
*----------------------------------------------------------------*/
- noise_est_pre( Etot, st->ini_frame, st->hNoiseEst, st->idchan, element_mode, hCPE != NULL ? hCPE->last_element_mode : element_mode );
-
- if ( element_mode == IVAS_CPE_TD && ( ( abs( hCPE->hStereoTD->tdm_last_ratio_idx - tdm_ratio_idx ) > 5 && st->idchan == 1 ) || abs( hCPE->hStereoTD->tdm_last_inst_ratio_idx - hCPE->hStereoTD->tdm_inst_ratio_idx ) > 10 ) )
+ Etot_fx = (Word32) ( Etot * ( 1 << 24 ) );
+ st->hNoiseEst->Etot_h_32fx = (Word32) ( st->hNoiseEst->Etot_h * 16777216.0 );
+ st->hNoiseEst->Etot_l_32fx = (Word32) ( st->hNoiseEst->Etot_l * 16777216.0 );
+ st->hNoiseEst->Etot_l_lp_32fx = (Word32) ( st->hNoiseEst->Etot_l_lp * 16777216.0 );
+ st->hNoiseEst->Etot_last_32fx = (Word32) ( st->hNoiseEst->Etot_last * 16777216.0 );
+ st->hNoiseEst->Etot_v_h2_32fx = (Word32) ( st->hNoiseEst->Etot_v_h2 * 16777216.0 );
+ st->hNoiseEst->Etot_lp_32fx = (Word32) ( st->hNoiseEst->Etot_lp * 16777216.0 );
+ st->hNoiseEst->sign_dyn_lp_32fx = (Word32) ( st->hNoiseEst->sign_dyn_lp * 16777216.0 );
+
+ noise_est_pre_32fx( Etot_fx, st->ini_frame, st->hNoiseEst, st->idchan, element_mode, hCPE != NULL ? hCPE->last_element_mode : element_mode );
+
+ st->hNoiseEst->Etot_h = (float) ( st->hNoiseEst->Etot_h_32fx / 16777216.0 );
+ st->hNoiseEst->Etot_l = (float) ( st->hNoiseEst->Etot_l_32fx / 16777216.0 );
+ st->hNoiseEst->Etot_l_lp = (float) ( st->hNoiseEst->Etot_l_lp_32fx / 16777216.0 );
+ st->hNoiseEst->Etot_last = (float) ( st->hNoiseEst->Etot_last_32fx / 16777216.0 );
+ st->hNoiseEst->Etot_v_h2 = (float) ( st->hNoiseEst->Etot_v_h2_32fx / 16777216.0 );
+ st->hNoiseEst->Etot_lp = (float) ( st->hNoiseEst->Etot_lp_32fx / 16777216.0 );
+ st->hNoiseEst->sign_dyn_lp = (float) ( st->hNoiseEst->sign_dyn_lp_32fx / 16777216.0 );
+
+ IF( EQ_16( element_mode, IVAS_CPE_TD ) && ( ( abs( hCPE->hStereoTD->tdm_last_ratio_idx - tdm_ratio_idx ) > 5 && EQ_16( st->idchan, 1 ) ) || abs( hCPE->hStereoTD->tdm_last_inst_ratio_idx - hCPE->hStereoTD->tdm_inst_ratio_idx ) > 10 ) )
{
st->ini_frame = 1;
}
-
+#if 0 // Disbaled due to high MLD
+ Q_new = Q_factor_arr( fr_bands, 40 );
+ floatToFixed_arrL( fr_bands, fr_bands_fx, Q_new + QSCALE, 40 );
+ st->lp_noise_fx = (Word16) ( st->lp_noise * ( 1 << 8 ) );
+ st->lp_speech_fx = (Word16) ( st->lp_speech * ( 1 << 8 ) );
+ floatToFixed_arrL( st->hNoiseEst->bckr, st->hNoiseEst->bckr_fx, Q_new + QSCALE, 20 );
+ floatToFixed_arrL( st->hNoiseEst->enrO, st->hNoiseEst->enrO_fx, Q_new + QSCALE, 20 );
+ st->flag_noisy_speech_snr_fx = (Word8) st->flag_noisy_speech_snr;
+ st->hVAD->bcg_flux_fx = (Word16) st->hVAD->bcg_flux * ( 1 << 4 );
+ st->hNoiseEst->Etot_v_h2_fx = (Word16) ( st->hNoiseEst->Etot_v_h2 * ( 1 << 8 ) );
+ st->hNoiseEst->sign_dyn_lp_fx = (Word16) ( st->hNoiseEst->sign_dyn_lp * ( 1 << 8 ) );
+ st->hVAD->snr_sum_vad_fx = (Word16) ( st->hVAD->snr_sum_vad * 32767 );
+ st->hVAD->prim_act_quick_fx = (Word16) ( st->hVAD->prim_act_quick * 32767 );
+ st->hVAD->prim_act_slow_fx = (Word16) ( st->hVAD->prim_act_slow * 32767 );
+ st->hVAD->prim_act_fx = (Word16) ( st->hVAD->prim_act * 32767 );
+ st->hVAD->prim_act_quick_he_fx = (Word16) ( st->hVAD->prim_act_quick_he * 32767 );
+ st->hVAD->prim_act_slow_he_fx = (Word16) ( st->hVAD->prim_act_slow_he * 32767 );
+ st->hVAD->prim_act_he_fx = (Word16) ( st->hVAD->prim_act_he * 32767 );
+
+
+ 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_fx ), Q_new, NULL, NULL, -MAX_16, -MAX_16 ); //-100000f == max 16bit float
+
+ st->hNoiseEst->Etot_v_h2 = (float) ( st->hNoiseEst->Etot_v_h2_fx / ( 256.0 ) );
+ st->hNoiseEst->sign_dyn_lp = (float) ( st->hNoiseEst->sign_dyn_lp_fx / ( 256.0 ) );
+ st->hVAD->bcg_flux = (float) ( st->hVAD->bcg_flux_fx / ( 16.0 ) );
+ st->flag_noisy_speech_snr = (Word16) st->flag_noisy_speech_snr_fx;
+ st->hVAD->snr_sum_vad = (float) ( st->hVAD->snr_sum_vad_fx / 32767.0 );
+ st->hVAD->prim_act_quick = (float) ( st->hVAD->prim_act_quick_fx / 32767.0 );
+ st->hVAD->prim_act_slow = (float) ( st->hVAD->prim_act_slow_fx / 32767.0 );
+ st->hVAD->prim_act = (float) ( st->hVAD->prim_act_fx / 32767.0 );
+ st->hVAD->prim_act_quick_he = (float) ( st->hVAD->prim_act_quick_he_fx / 32767.0 );
+ st->hVAD->prim_act_slow_he = (float) ( st->hVAD->prim_act_slow_he_fx / 32767.0 );
+ st->hVAD->prim_act_he = (float) ( st->hVAD->prim_act_he_fx / 32767.0 );
+#else
st->vad_flag = wb_vad( st, fr_bands, &i, &i, &i, &snr_sum_he, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), NULL, NULL, -1000.0f, -1000.0f );
+#endif
-
- if ( force_front_vad == 1 || front_vad_flag == 1 )
+ 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;
}
- if ( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL )
+ IF( ( hCPE != NULL && !( lr_vad_enabled && EQ_16( st->idchan, 0 ) ) ) || hSCE != NULL )
{
- *vad_flag_dtx = dtx_hangover_addition( st, st->vad_flag, st->lp_speech - st->lp_noise, 0, vad_hover_flag, NULL, NULL, NULL );
+ st->lp_noise_fx = (Word16) ( st->lp_noise * ( 1 << 8 ) );
+ st->lp_speech_fx = (Word16) ( st->lp_speech * ( 1 << 8 ) );
+ st->hVAD->prim_act_he_fx = (Word16) ( st->hVAD->prim_act_he * MAX_16 );
+ st->hNoiseEst->Etot_lp_fx = (Word16) ( st->hNoiseEst->Etot_lp * ( 1 << 8 ) );
+
+ *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 );
}
- else
+ ELSE
{
/* This only applies to st->idchan==0 now */
/* Add down mix stereo activity to LR vad_flag_dtx */
@@ -462,7 +1706,7 @@ ivas_error pre_proc_front_ivas(
*vad_hover_flag = *vad_flag_dtx && !( LR_localVAD || st->localVAD );
}
- if ( force_front_vad == 1 || front_vad_dtx_flag == 1 )
+ 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;
@@ -471,19 +1715,37 @@ ivas_error pre_proc_front_ivas(
/*----------------------------------------------------------------*
* NB/WB/SWB/FB bandwidth detector
*----------------------------------------------------------------*/
+ FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ )
+ {
+ sf_energySum[i] = enerBuffer_exp;
+ move16();
+ }
- if ( st->idchan == 0 && element_mode != IVAS_CPE_MDCT )
+ IF( EQ_16( st->idchan, 0 ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
{
- bw_detect( st, st->input, NULL, enerBuffer, ivas_format, 0 );
+ st->cldfbAnaEnc->scale = (Word16) ( st->cldfbAnaEnc->scale_flt * ( 1 << 8 ) );
+ floatToFixed_arr( st->input, st->input_fx, 0, 480 );
+#ifdef MSAN_FIX
+ st->lt_mean_NB_fx = (Word16) st->lt_mean_NB * ( 1 << 11 );
+ st->lt_mean_WB_fx = (Word16) st->lt_mean_WB * ( 1 << 11 );
+ st->lt_mean_SWB_fx = (Word16) st->lt_mean_SWB * ( 1 << 11 );
+ st->lp_noise_fx = (Word16) st->lp_noise * ( 1 << 8 ); // have taken Q8 as above one functions uses Q8
+#endif
+
+ bw_detect_fx( st, st->input_fx, NULL, enerBuffer_fx, sf_energySum, ivas_format, 0 );
+
+ st->lt_mean_NB = (float) st->lt_mean_NB_fx / ( 1 << 11 );
+ st->lt_mean_WB = (float) st->lt_mean_WB_fx / ( 1 << 11 );
+ st->lt_mean_SWB = (float) st->lt_mean_SWB_fx / ( 1 << 11 );
}
- if ( element_mode != IVAS_CPE_MDCT ) /* in MDCT stereo, set_bw_stereo() is used instead */
+ IF( NE_16( element_mode, IVAS_CPE_MDCT ) ) /* in MDCT stereo, set_bw_stereo() is used instead */
{
set_bw( element_mode, element_brate, st, MODE1 );
}
/* set the BW of the TD secondary channel in LRTD mode same as BW of the primary channel (only at higher bitrates) */
- if ( st->idchan == 1 && element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag == 1 && st->bits_frame_channel >= IVAS_16k4 / FRAMES_PER_SEC )
+ IF( EQ_16( st->idchan, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->tdm_LRTD_flag, 1 ) && st->bits_frame_channel >= IVAS_16k4 / FRAMES_PER_SEC )
{
st->bwidth = hCPE->hCoreCoder[0]->bwidth;
}
@@ -511,7 +1773,6 @@ ivas_error pre_proc_front_ivas(
/*----------------------------------------------------------------*
* FD-CNG Noise Estimator
*----------------------------------------------------------------*/
-
if ( st->hFdCngEnc != NULL )
{
resetFdCngEnc( st );
@@ -833,10 +2094,18 @@ ivas_error pre_proc_front_ivas(
mvr2r( &old_inp_12k8[L_FRAME], st->old_inp_12k8, L_INP_MEM );
+#ifdef IVAS_FLOAT_FIXED
+ free( signal_in_fx - ( input_Fs / 50 ) );
+ free( enerBuffer_fx );
+ free( old_inp_12k8_fx );
+ free( old_inp_16k_fx );
+ free( mem_decim_dummy_fx );
+ free( temp1F_icatdmResampBuf_fx );
+#endif
pop_wmops();
return error;
}
-
+#endif
#ifdef IVAS_FIXED_ENC
/*-------------------------------------------------------------------*
@@ -865,7 +2134,7 @@ static void calculate_energy_buffer_fx(
Word16 temp_q2 = norm_s( hCPE->hStereoDft->NFFT );
band_res_dft_fx = div_l( L_shl( input_Fs, temp_q1 ), shl( hCPE->hStereoDft->NFFT, temp_q2 ) );
- chan_width_f_fx = div_l( 24000, CLDFB_NO_CHANNELS_MAX );
+ chan_width_f_fx = 24000 / CLDFB_NO_CHANNELS_MAX;
chan_width_bins_fx = L_shl( (Word32) div_s( chan_width_f_fx, band_res_dft_fx ), ( sub( add( temp_q1, 1 ), temp_q2 ) ) ); // Q16
pDFT_DMX_fx = hCPE->hStereoDft->DFT_fx[0];
@@ -928,8 +2197,9 @@ static void calculate_energy_buffer(
Word16 temp_q2 = norm_s( hCPE->hStereoDft->NFFT );
band_res_dft_fx = div_l( L_shl( input_Fs, temp_q1 ), shl( hCPE->hStereoDft->NFFT, temp_q2 ) );
- chan_width_f_fx = div_l( 24000, CLDFB_NO_CHANNELS_MAX );
- chan_width_bins_fx = L_shl( (Word32) div_s( chan_width_f_fx, band_res_dft_fx ), ( sub( add( temp_q1, 1 ), temp_q2 ) ) ); // Q16
+ /* chan_width_f = 24000.f / CLDFB_NO_CHANNELS_MAX; */
+ chan_width_f_fx = 24000 / CLDFB_NO_CHANNELS_MAX;
+ chan_width_bins_fx = L_shl( (Word32) div_s( chan_width_f_fx, band_res_dft_fx ), ( sub( temp_q1, temp_q2 ) ) ); // Q16
pDFT_DMX = hCPE->hStereoDft->DFT[0]; // to be removed
start = 1;
diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c
index 942acf84af190ef747ddacb213707ace4f67c349..8c8dcb799aa9a1073cb80485e66d6d05f5280f34 100644
--- a/lib_enc/ivas_cpe_enc.c
+++ b/lib_enc/ivas_cpe_enc.c
@@ -43,6 +43,7 @@
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
+#include "prot_fx.h"
#endif
@@ -58,12 +59,12 @@ static void stereo_mode_combined_format_enc( const Encoder_Struct *st_ivas, CPE_
*
* Channel Pair Element (CPE) encoding routine
*-------------------------------------------------------------------*/
-
+#ifdef IVAS_FLOAT_FIXED
ivas_error ivas_cpe_enc(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const int16_t cpe_id, /* i : CPE # identifier */
- const float data_f_ch0[], /* i : input signal for channel 0 */
- const float data_f_ch1[], /* i : input signal for channel 1 */
+ float data_f_ch0[], /* i : input signal for channel 0 */
+ float data_f_ch1[], /* i : input signal for channel 1 */
const int16_t input_frame, /* i : input frame length per channel */
const int16_t nb_bits_metadata /* i : number of metadata bits */
)
@@ -71,8 +72,14 @@ ivas_error ivas_cpe_enc(
CPE_ENC_HANDLE hCPE;
Encoder_State **sts;
int16_t n, n_CoreChannels;
- float old_inp_12k8[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 */
- float old_inp_16k[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz */
+ float old_inp_12k8[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 */
+#ifdef IVAS_FLOAT_FIXED
+ Word32 old_inp_12k8_fx[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 */
+#endif
+ float old_inp_16k[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz */
+#ifdef IVAS_FLOAT_FIXED
+ Word32 old_inp_16k_fx[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz */
+#endif
float ener[CPE_CHANNELS]; /* residual energy from Levinson-Durbin */
float relE[CPE_CHANNELS]; /* frame relative energy */
float A[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )]; /* A(z) unquantized for subframes */
@@ -155,9 +162,15 @@ ivas_error ivas_cpe_enc(
}
mvr2r( data_f_ch0, sts[0]->input, input_frame );
+#ifdef IVAS_FLOAT_FIXED
+ floatToFixed_arr16( data_f_ch0, sts[0]->input_fx, 0, input_frame );
+#endif
if ( data_f_ch1 != NULL ) /*this may happen for cases with odd number of channels*/
{
mvr2r( data_f_ch1, sts[1]->input, input_frame );
+#ifdef IVAS_FLOAT_FIXED
+ floatToFixed_arr16( data_f_ch1, sts[1]->input_fx, 0, input_frame );
+#endif
}
/*----------------------------------------------------------------*
@@ -448,6 +461,83 @@ ivas_error ivas_cpe_enc(
internal_Fs = getTcxonly_ivas( 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 );
/* iDFT at input sampling rate */
+#ifdef IVAS_FLOAT_FIXED
+ /*flt2fix*/
+ f2me_buf( hCPE->hStereoDft->DFT[0], hCPE->hStereoDft->DFT_fx[0], &hCPE->hStereoDft->DFT_fx_e[0], STEREO_DFT_N_MAX_ENC );
+ f2me_buf( hCPE->hStereoDft->DFT[1], hCPE->hStereoDft->DFT_fx[1], &hCPE->hStereoDft->DFT_fx_e[1], STEREO_DFT_N_MAX_ENC );
+ if ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
+ {
+ floatToFixed_arr( sts[1]->old_inp_12k8, sts[1]->old_inp_12k8_fx, 0, L_INP_MEM );
+ }
+ f2me( hCPE->hStereoDft->icbweRefEner, &hCPE->hStereoDft->icbweRefEner_fx, &hCPE->hStereoDft->icbweRefEner_fx_e );
+ f2me( hCPE->hStereoDft->lbEner, &hCPE->hStereoDft->lbEner_fx, &hCPE->hStereoDft->lbEner_fx_e );
+ floatToFixed_arrL( hCPE->hStereoDft->output_mem_res_8k, hCPE->hStereoDft->output_mem_res_8k_fx, 16, STEREO_DFT_OVL_8k );
+ floatToFixed_arrL( hCPE->hStereoDft->output_mem_dmx, hCPE->hStereoDft->output_mem_dmx_fx, 16, STEREO_DFT_OVL_MAX );
+ floatToFixed_arrL( hCPE->hStereoDft->output_mem_dmx_12k8, hCPE->hStereoDft->output_mem_dmx_12k8_fx, 16, STEREO_DFT_OVL_12k8 );
+ floatToFixed_arrL( hCPE->hStereoDft->output_mem_dmx_16k, hCPE->hStereoDft->output_mem_dmx_16k_fx, 16, STEREO_DFT_OVL_16k );
+ floatToFixed_arrL( hCPE->hStereoDft->output_mem_dmx_16k_shb, hCPE->hStereoDft->output_mem_dmx_16k_shb_fx, 16, STEREO_DFT_OVL_16k );
+ floatToFixed_arrL( hCPE->hStereoDft->output_mem_dmx_32k, hCPE->hStereoDft->output_mem_dmx_32k_fx, 16, STEREO_DFT_OVL_32k );
+ /*flt2fix end*/
+
+ // stereo_dft_enc_synthesize( hCPE->hStereoDft, sts[0]->input, 0, input_Fs, input_Fs, 0 );
+ Word16 out_start_ind, out_end_ind;
+ Word16 out_12k8_start_ind[CPE_CHANNELS], out_12k8_end_ind[CPE_CHANNELS];
+ Word16 out_16k_start_ind = 0, out_16k_end_ind = 0;
+ move16();
+ move16();
+ stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL );
+
+ /* iDFT & resampling to 12.8kHz internal sampling rate */
+ // stereo_dft_enc_synthesize( hCPE->hStereoDft, old_inp_12k8[0] + L_INP_MEM, 0, input_Fs, INT_FS_12k8, 0 );
+ stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[0] + L_INP_MEM, &out_12k8_start_ind[0], &out_12k8_end_ind[0], 0, input_Fs, INT_FS_12k8, 0, NULL );
+
+ /* iDFT & resampling to 16kHz internal sampling rate for M channel */
+ IF( EQ_32( input_Fs, internal_Fs ) )
+ {
+ // mvr2r( sts[0]->input - STEREO_DFT_OVL_16k, old_inp_16k[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, input_frame + STEREO_DFT_OVL_16k );
+ out_16k_start_ind = -STEREO_DFT_OVL_16k;
+ out_16k_end_ind = out_16k_start_ind + input_frame + STEREO_DFT_OVL_16k;
+ }
+ ELSE
+ {
+ // stereo_dft_enc_synthesize( hCPE->hStereoDft, old_inp_16k[0] + L_INP_MEM, 0, input_Fs, internal_Fs, 0 );
+ stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_16k_fx[0] + L_INP_MEM, &out_16k_start_ind, &out_16k_end_ind, 0, input_Fs, internal_Fs, 0, NULL );
+ }
+
+ /* DFT Stereo: iDFT of residual signal at 8kHz sampling rate */
+ test();
+ IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
+ {
+ // mvr2r( sts[1]->old_inp_12k8, old_inp_12k8[1], L_INP_MEM );
+ Copy_Scale_sig_16_32_no_sat( sts[1]->old_inp_12k8_fx, old_inp_12k8_fx[1], L_INP_MEM, 16 - 0 );
+ // stereo_dft_enc_synthesize( hCPE->hStereoDft, old_inp_12k8[1] + L_INP_MEM, 1, input_Fs, 8000, 0 );
+ 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 */
+ // mvr2r( old_inp_12k8[1] + L_FRAME8k, sts[1]->old_inp_12k8, L_INP_MEM );
+ Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_FRAME8k, sts[1]->old_inp_12k8_fx, L_INP_MEM, 0 - 16 );
+ }
+
+ /*fix2flt*/
+ hCPE->hStereoDft->icbweRefEner = me2f( hCPE->hStereoDft->icbweRefEner_fx, hCPE->hStereoDft->icbweRefEner_fx_e );
+ hCPE->hStereoDft->lbEner = me2f( hCPE->hStereoDft->lbEner_fx, hCPE->hStereoDft->lbEner_fx_e );
+ fixedToFloat_arrL( sts[0]->input32_fx + out_start_ind, sts[0]->input + out_start_ind, 16, out_end_ind - out_start_ind );
+ fixedToFloat_arrL( old_inp_12k8_fx[0] + L_INP_MEM + out_12k8_start_ind[0], old_inp_12k8[0] + L_INP_MEM + out_12k8_start_ind[0], 16, out_12k8_end_ind[0] - out_12k8_start_ind[0] );
+ fixedToFloat_arrL( old_inp_16k_fx[0] + L_INP_MEM + out_16k_start_ind, old_inp_16k[0] + L_INP_MEM + out_16k_start_ind, 16, out_16k_end_ind - out_16k_start_ind );
+ if ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
+ {
+ fixedToFloat_arr( sts[1]->old_inp_12k8_fx, sts[1]->old_inp_12k8, 0, L_INP_MEM );
+ fixedToFloat_arrL( old_inp_12k8_fx[1] + L_INP_MEM + out_12k8_start_ind[1], old_inp_12k8[1] + L_INP_MEM + out_12k8_start_ind[1], 16, out_12k8_end_ind[1] - out_12k8_start_ind[1] );
+ }
+ fixedToFloat_arrL( hCPE->hStereoDft->output_mem_res_8k_fx, hCPE->hStereoDft->output_mem_res_8k, 16, STEREO_DFT_OVL_8k );
+ fixedToFloat_arrL( hCPE->hStereoDft->output_mem_dmx_fx, hCPE->hStereoDft->output_mem_dmx, 16, STEREO_DFT_OVL_MAX );
+ fixedToFloat_arrL( hCPE->hStereoDft->output_mem_dmx_12k8_fx, hCPE->hStereoDft->output_mem_dmx_12k8, 16, STEREO_DFT_OVL_12k8 );
+ fixedToFloat_arrL( hCPE->hStereoDft->output_mem_dmx_16k_fx, hCPE->hStereoDft->output_mem_dmx_16k, 16, STEREO_DFT_OVL_16k );
+ fixedToFloat_arrL( hCPE->hStereoDft->output_mem_dmx_16k_shb_fx, hCPE->hStereoDft->output_mem_dmx_16k_shb, 16, STEREO_DFT_OVL_16k );
+ fixedToFloat_arrL( hCPE->hStereoDft->output_mem_dmx_32k_fx, hCPE->hStereoDft->output_mem_dmx_32k, 16, STEREO_DFT_OVL_32k );
+ /*fix2flt end*/
+#else
stereo_dft_enc_synthesize( hCPE->hStereoDft, sts[0]->input, 0, input_Fs, input_Fs, 0 );
/* iDFT & resampling to 12.8kHz internal sampling rate */
@@ -472,7 +562,7 @@ ivas_error ivas_cpe_enc(
/* update old input signal buffer */
mvr2r( old_inp_12k8[1] + L_FRAME8k, sts[1]->old_inp_12k8, L_INP_MEM );
}
-
+#endif
/* no iDFT at input sampling rate for Side channel -> reset the buffer */
set_zero( sts[1]->input, input_frame );
}
@@ -487,10 +577,17 @@ ivas_error ivas_cpe_enc(
for ( n = 0; n < n_CoreChannels; n++ )
{
+#ifdef IVAS_FLOAT_FIXED
+ error = pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n],
+ &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n],
+ realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n],
+ fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate );
+#else
error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n],
&ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n],
realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n],
fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate );
+#endif
if ( error != IVAS_ERR_OK )
{
return error;
@@ -778,7 +875,664 @@ ivas_error ivas_cpe_enc(
pop_wmops();
return error;
}
+#else
+ivas_error ivas_cpe_enc(
+ Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
+ const int16_t cpe_id, /* i : CPE # identifier */
+ float data_f_ch0[], /* i : input signal for channel 0 */
+ float data_f_ch1[], /* i : input signal for channel 1 */
+ const int16_t input_frame, /* i : input frame length per channel */
+ const int16_t nb_bits_metadata /* i : number of metadata bits */
+)
+{
+ CPE_ENC_HANDLE hCPE;
+ Encoder_State **sts;
+ int16_t n, n_CoreChannels;
+ float old_inp_12k8[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 */
+ float old_inp_16k[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz */
+ float ener[CPE_CHANNELS]; /* residual energy from Levinson-Durbin */
+ float relE[CPE_CHANNELS]; /* frame relative energy */
+ float A[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )]; /* A(z) unquantized for subframes */
+ float Aw[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )]; /* weighted A(z) unquantized for subframes */
+ float epsP[CPE_CHANNELS][M + 1]; /* LP prediction errors */
+ float lsp_new[CPE_CHANNELS][M]; /* LSPs at the end of the frame */
+ float lsp_mid[CPE_CHANNELS][M]; /* ISPs in the middle of the frame */
+ int16_t vad_hover_flag[CPE_CHANNELS]; /* VAD hangover flag */
+ int16_t attack_flag[CPE_CHANNELS]; /* attack flag (GSC or TC) */
+ float realBuffer[CPE_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; /* real buffer */
+ float imagBuffer[CPE_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; /* imag buffer */
+ float old_wsp[CPE_CHANNELS][L_WSP]; /* old weighted input signal */
+ float pitch_fr[CPE_CHANNELS][NB_SUBFR]; /* fractional pitch values */
+ float voicing_fr[CPE_CHANNELS][NB_SUBFR]; /* fractional pitch gains */
+ int16_t loc_harm[CPE_CHANNELS]; /* harmonicity flag */
+ float cor_map_sum[CPE_CHANNELS]; /* speech/music clasif. parameter */
+ int16_t vad_flag_dtx[CPE_CHANNELS]; /* HE-SAD flag with additional DTX HO */
+ float enerBuffer[CPE_CHANNELS][CLDFB_NO_CHANNELS_MAX]; /* energy buffer */
+ float currFlatness[CPE_CHANNELS]; /* flatness parameter */
+ float fft_buff[CPE_CHANNELS][2 * L_FFT]; /* FFT buffer */
+ int16_t tdm_ratio_idx, tdm_ratio_idx_SM; /* temp. TD stereo parameters */
+ int16_t tdm_SM_or_LRTD_Pri; /* temp. TD stereo parameters */
+ float tdm_last_ratio; /* temp. TD stereo parameters */
+ int16_t nb_bits; /* number of DFT stereo side bits */
+ float fr_bands[CPE_CHANNELS][2 * NB_BANDS]; /* energy in frequency bands */
+ float Etot_LR[CPE_CHANNELS]; /* total energy */
+ float lf_E[CPE_CHANNELS][2 * VOIC_BINS]; /* per bin spectrum energy in lf */
+ int16_t localVAD_HE_SAD[CPE_CHANNELS]; /* HE-SAD flag without hangover, LR channels */
+ float band_energies_LR[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor E_MIN */
+ float orig_input[CPE_CHANNELS][L_FRAME48k];
+ float Etot_last[CPE_CHANNELS];
+ int32_t tmp, input_Fs;
+ int16_t max_bwidth, ivas_format;
+ ENCODER_CONFIG_HANDLE hEncoderConfig;
+ int32_t ivas_total_brate;
+ ivas_error error;
+ int32_t cpe_brate;
+ int32_t element_brate_ref;
+ int16_t last_bits_frame_nominal; /* last_bits_frame_nominal for M or PCh channel */
+
+ error = IVAS_ERR_OK;
+ push_wmops( "ivas_cpe_enc" );
+
+ hCPE = st_ivas->hCPE[cpe_id];
+ sts = hCPE->hCoreCoder;
+ hEncoderConfig = st_ivas->hEncoderConfig;
+ max_bwidth = hEncoderConfig->max_bwidth;
+ ivas_format = hEncoderConfig->ivas_format;
+ input_Fs = hEncoderConfig->input_Fs;
+ ivas_total_brate = hEncoderConfig->ivas_total_brate;
+ element_brate_ref = hCPE->element_brate;
+ last_bits_frame_nominal = sts[0]->bits_frame_nominal;
+
+ /*------------------------------------------------------------------*
+ * Initialization - general
+ *-----------------------------------------------------------------*/
+
+ tdm_SM_or_LRTD_Pri = 0;
+ tdm_ratio_idx = -1;
+ tdm_ratio_idx_SM = -1;
+ tdm_last_ratio = 0;
+
+
+ /*------------------------------------------------------------------*
+ * CPE initialization - core coder
+ *-----------------------------------------------------------------*/
+
+ 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;
+ 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]->rate_switching_reset = 0;
+ }
+
+ mvr2r( data_f_ch0, sts[0]->input, input_frame );
+ if ( data_f_ch1 != NULL ) /*this may happen for cases with odd number of channels*/
+ {
+ mvr2r( data_f_ch1, sts[1]->input, input_frame );
+ }
+
+ /*----------------------------------------------------------------*
+ * Stereo technology selection
+ * Front-VAD on input L and R channels
+ *----------------------------------------------------------------*/
+
+ if ( sts[0]->ini_frame > 0 && st_ivas->hMCT == NULL )
+ {
+ hCPE->element_mode = select_stereo_mode( hCPE, ivas_format );
+ }
+
+ stereo_mode_combined_format_enc( st_ivas, hCPE );
+
+ if ( ( error = front_vad( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_LR, NULL, NULL ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ sts[0]->element_mode = hCPE->element_mode;
+ sts[1]->element_mode = hCPE->element_mode;
+
+ n_CoreChannels = 2;
+ if ( hCPE->element_mode == IVAS_CPE_DFT )
+ {
+ n_CoreChannels = 1; /* in DFT stereo, only M channel is coded */
+
+ sts[1]->vad_flag = 0;
+ }
+
+ /*----------------------------------------------------------------*
+ * dynamically allocate data structures depending on the actual stereo mode
+ *----------------------------------------------------------------*/
+
+ if ( ( error = stereo_memory_enc( hCPE, input_Fs, max_bwidth, &tdm_last_ratio, ivas_format, st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+
+ /*----------------------------------------------------------------*
+ * Set TD stereo parameters
+ *----------------------------------------------------------------*/
+
+ if ( ( error = stereo_set_tdm( hCPE, input_frame ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /*----------------------------------------------------------------*
+ * Resets/updates in case of stereo switching
+ *----------------------------------------------------------------*/
+
+ stereo_switching_enc( hCPE, sts[0]->old_input_signal, input_frame );
+ /*----------------------------------------------------------------*
+ * Temporal inter-channel alignment, stereo adjustment
+ *----------------------------------------------------------------*/
+
+ stereo_tca_enc( hCPE, input_frame );
+
+ /*----------------------------------------------------------------*
+ * Input signal buffering - needed in IC-BWE and TD ITD in MDCT stereo
+ *----------------------------------------------------------------*/
+
+ for ( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ mvr2r( sts[n]->input, orig_input[n], input_frame );
+
+ if ( hCPE->hStereoICBWE != NULL )
+ {
+ hCPE->hStereoICBWE->dataChan[n] = &orig_input[n][0];
+ }
+ }
+
+ /*---------------------------------------------------------------*
+ * Time Domain Transient Detector
+ *---------------------------------------------------------------*/
+
+ for ( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ if ( sts[n]->hTranDet == NULL )
+ {
+ currFlatness[n] = 0;
+ continue;
+ }
+
+ if ( !( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) )
+ {
+ RunTransientDetection( sts[n]->input, input_frame, sts[n]->hTranDet );
+ }
+ currFlatness[n] = GetTCXAvgTemporalFlatnessMeasure( sts[n]->hTranDet, NSUBBLOCKS, 0 );
+ }
+
+ /* Synchonize detection for downmix-based stereo */
+ if ( hCPE->element_mode == IVAS_CPE_DFT || hCPE->element_mode == IVAS_CPE_TD )
+ {
+ set_transient_stereo( hCPE, currFlatness );
+ }
+
+ /*----------------------------------------------------------------*
+ * Configuration of stereo encoder
+ *----------------------------------------------------------------*/
+
+ for ( n = 0; n < n_CoreChannels; n++ )
+ {
+ /* Force to MODE1 in IVAS */
+ sts[n]->codec_mode = MODE1;
+
+ sts[n]->element_mode = hCPE->element_mode;
+ }
+
+
+ if ( hCPE->element_mode != IVAS_CPE_MDCT && ( hCPE->element_brate != hCPE->last_element_brate || hCPE->last_element_mode != hCPE->element_mode || sts[0]->ini_frame == 0 ||
+ ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) || 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 */
+ {
+ if ( st_ivas->hQMetaData != NULL )
+ {
+ if ( ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE )
+ {
+ stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, (int32_t) ( 0.70f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
+ }
+ else
+ {
+ stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, 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( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
+ }
+ }
+
+ if ( hCPE->element_mode == IVAS_CPE_TD )
+ {
+ 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 );
+ }
+ else
+ {
+ stereo_dft_config( NULL, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
+ }
+ }
+
+ if ( 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 )
+ {
+ brate_surplus[0] = ( ( hCPE->brate_surplus / FRAMES_PER_SEC ) >> 1 ) * FRAMES_PER_SEC;
+ brate_surplus[1] = hCPE->brate_surplus - brate_surplus[0];
+ }
+
+ /* 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++ )
+ {
+ 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 );
+ }
+ 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;
+
+ /* 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 )
+ {
+ sts[n]->bits_frame_channel += (int16_t) ( brate_surplus[n] / FRAMES_PER_SEC );
+ sts[n]->total_brate += brate_surplus[n];
+ }
+ }
+ }
+
+ /* reconfiguration in case of bitrate switching */
+ if ( hCPE->element_brate != hCPE->last_element_brate && st_ivas->hMCT == NULL )
+ {
+ initMdctStereoEncData( 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 ) );
+ }
+ }
+
+ /*----------------------------------------------------------------*
+ * Stereo processing
+ * Stereo down-mix
+ *----------------------------------------------------------------*/
+
+ if ( hCPE->element_mode == IVAS_CPE_DFT )
+ {
+ stereo_dft_hybrid_ITD_flag( hCPE->hStereoDft->hConfig, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max );
+
+ /* Time Domain ITD compensation using extrapolation */
+ stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hCPE->hStereoDft->hConfig->hybrid_itd_flag, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem );
+
+ /* DFT on right and left input channels */
+ stereo_dft_enc_analyze( sts, CPE_CHANNELS, input_frame, hCPE->hStereoDft, NULL, hCPE->hStereoDft->DFT, hCPE->input_mem );
+
+ sts[0]->total_brate = ( sts[0]->bits_frame_nominal + 10 ) * FRAMES_PER_SEC; /* add small overhead; st[0]->total_brate used in coder_type_modif() */
+ /* Update DFT Stereo memories */
+ stereo_dft_enc_update( hCPE->hStereoDft, sts[0]->max_bwidth );
+
+ /* DFT stereo processing */
+ stereo_dft_enc_process( hCPE, vad_flag_dtx, vad_hover_flag, input_frame );
+ }
+ else if ( hCPE->element_mode == IVAS_CPE_TD )
+ {
+ /* Determine the energy ratio between the 2 channels */
+ tdm_ratio_idx = stereo_tdm_ener_analysis(
+ ivas_format,
+ hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM );
+
+ /* Compute the downmix signal based on the ratio index */
+ stereo_tdm_downmix( hCPE->hStereoTD, sts[0]->input, sts[1]->input, input_frame, tdm_ratio_idx, ( ( hCPE->hStereoTD->tdm_LRTD_flag == 0 ) ? tdm_SM_or_LRTD_Pri : 0 ), tdm_ratio_idx_SM );
+
+ /* signal the bitrate for BW selection in the SCh */
+ sts[0]->bits_frame_channel = 0;
+ sts[1]->bits_frame_channel = (int16_t) ( hCPE->element_brate / FRAMES_PER_SEC );
+ sts[1]->bits_frame_channel += (int16_t) ( hCPE->brate_surplus / FRAMES_PER_SEC );
+ if ( st_ivas->hQMetaData != NULL )
+ {
+ sts[1]->bits_frame_channel -= st_ivas->hQMetaData->metadata_max_bits;
+ }
+
+ Etot_last[0] = sts[0]->hNoiseEst->Etot_last;
+ Etot_last[1] = sts[1]->hNoiseEst->Etot_last;
+ }
+ else if ( hCPE->element_mode == IVAS_CPE_MDCT )
+ {
+ stereo_td_itd_mdct_stereo( hCPE, vad_flag_dtx, vad_hover_flag, input_frame );
+ }
+
+ /*----------------------------------------------------------------*
+ * DFT stereo: iDFT and resampling on both channels
+ *----------------------------------------------------------------*/
+
+ if ( hCPE->element_mode == IVAS_CPE_DFT )
+ {
+ int32_t internal_Fs;
+
+ internal_Fs = getTcxonly_ivas( 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 );
+
+ /* iDFT at input sampling rate */
+ stereo_dft_enc_synthesize( hCPE->hStereoDft, sts[0]->input, 0, input_Fs, input_Fs, 0 );
+
+ /* iDFT & resampling to 12.8kHz internal sampling rate */
+ stereo_dft_enc_synthesize( hCPE->hStereoDft, old_inp_12k8[0] + L_INP_MEM, 0, input_Fs, INT_FS_12k8, 0 );
+
+ /* iDFT & resampling to 16kHz internal sampling rate for M channel */
+ if ( input_Fs == internal_Fs )
+ {
+ mvr2r( sts[0]->input - STEREO_DFT_OVL_16k, old_inp_16k[0] + L_INP_MEM - STEREO_DFT_OVL_16k, input_frame + STEREO_DFT_OVL_16k );
+ }
+ else
+ {
+ stereo_dft_enc_synthesize( hCPE->hStereoDft, old_inp_16k[0] + L_INP_MEM, 0, input_Fs, internal_Fs, 0 );
+ }
+
+ /* DFT Stereo: iDFT of residual signal at 8kHz sampling rate */
+ if ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
+ {
+ mvr2r( sts[1]->old_inp_12k8, old_inp_12k8[1], L_INP_MEM );
+ stereo_dft_enc_synthesize( hCPE->hStereoDft, old_inp_12k8[1] + L_INP_MEM, 1, input_Fs, 8000, 0 );
+
+ /* update old input signal buffer */
+ mvr2r( old_inp_12k8[1] + L_FRAME8k, sts[1]->old_inp_12k8, L_INP_MEM );
+ }
+
+ /* no iDFT at input sampling rate for Side channel -> reset the buffer */
+ set_zero( sts[1]->input, input_frame );
+ }
+
+
+ /*----------------------------------------------------------------*
+ * Front Pre-processing
+ *----------------------------------------------------------------*/
+
+ for ( n = 0; n < n_CoreChannels; n++ )
+ {
+ error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n],
+ &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n],
+ realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n],
+ fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate );
+ if ( error != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+ /* sanity check -> DTX not supported for more than one SCEs/CPEs */
+ if ( st_ivas->nSCE + st_ivas->nCPE > 1 )
+ {
+ if ( 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;
+ }
+ }
+
+ /*----------------------------------------------------------------*
+ * Stereo DTX updates
+ *----------------------------------------------------------------*/
+
+ if ( 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 )
+ {
+ reset_metadata_spatial( 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 )
+ {
+ stereoFdCngCoherence( sts, hCPE->last_element_mode, fft_buff );
+
+ /* Reset metadata */
+ if ( sts[0]->cng_sba_flag || ( ivas_format == SBA_FORMAT ) )
+ {
+ reset_metadata_spatial( ivas_format, hCPE->hMetaData, hCPE->element_brate, &tmp, sts[0]->core_brate, nb_bits_metadata );
+ }
+ }
+
+ /*----------------------------------------------------------------*
+ * Core codec configuration
+ *----------------------------------------------------------------*/
+
+ /* IGF reconfiguration */
+ for ( n = 0; n < n_CoreChannels; n++ )
+ {
+ if ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->element_mode != hCPE->last_element_mode || ( hCPE->element_mode == IVAS_CPE_TD && sts[0]->bits_frame_nominal != last_bits_frame_nominal ) || sts[n]->last_bwidth != sts[n]->bwidth ) && ( n == 0 || hCPE->element_mode == IVAS_CPE_MDCT ) )
+ {
+ int16_t igf;
+ igf = getIgfPresent( sts[n]->element_mode, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, sts[n]->max_bwidth, sts[n]->rf_mode );
+ if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, 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 )
+ {
+ /* set coded BW for MDCT stereo */
+ set_bw_stereo( 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 ) )
+ {
+ initMdctStereoEncData( 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 )
+ {
+ if ( ( error = initMdctItdHandling( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+ }
+
+ /* set ACELP@12k8 / ACELP@16k flag for flexible ACELP core */
+ 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 )
+ {
+ 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 );
+ }
+ 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 );
+ }
+ }
+
+ /* configure TD stereo encoder */
+ if ( hCPE->element_mode == IVAS_CPE_TD )
+ {
+ tdm_ol_pitch_comparison( hCPE, pitch_fr, voicing_fr );
+
+ tdm_configure_enc( ivas_format, st_ivas->ism_mode, hCPE, Etot_last, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata );
+
+ if ( hEncoderConfig->Opt_DTX_ON )
+ {
+ stereo_cng_upd_counters( hCPE->hStereoCng, hCPE->element_mode, -1, NULL, sts[0]->hTdCngEnc->burst_ho_cnt, NULL );
+ }
+ }
+
+ /* modify the coder_type depending on the total_brate per channel */
+ for ( n = 0; n < n_CoreChannels; n++ )
+ {
+ if ( ( hCPE->element_mode != IVAS_CPE_DFT && hCPE->element_mode != IVAS_CPE_TD ) || n == 0 ) /* modify coder_type of primary channel */
+ {
+ /* limit coder_type depending on the bitrate */
+ coder_type_modif( sts[n], relE[n] );
+ }
+ }
+
+ /*----------------------------------------------------------------*
+ * Write IVAS format signaling in SID frames
+ *----------------------------------------------------------------*/
+
+ if ( sts[0]->core_brate == SID_2k40 )
+ {
+ ivas_write_format_sid( ivas_format, hCPE->element_mode, sts[0]->hBstr );
+ }
+
+ /*----------------------------------------------------------------*
+ * DFT Stereo residual coding
+ * DFT Stereo parameters writing into the bitstream
+ *----------------------------------------------------------------*/
+
+ cpe_brate = 0;
+ if ( hCPE->element_mode == IVAS_CPE_DFT )
+ {
+ if ( hEncoderConfig->Opt_DTX_ON )
+ {
+ if ( sts[0]->core_brate == SID_2k40 || sts[0]->core_brate == FRAME_NO_DATA )
+ {
+ /* Reconfigure DFT Stereo for inactive frames */
+ if ( sts[0]->core_brate == SID_2k40 )
+ {
+ stereo_dft_config( hCPE->hStereoDft->hConfig, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
+ }
+ else
+ {
+ stereo_dft_config( hCPE->hStereoDft->hConfig, FRAME_NO_DATA, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
+ }
+
+ stereo_dft_cng_side_gain( hCPE->hStereoDft, hCPE->hStereoCng, sts[0]->core_brate, sts[0]->last_core_brate, sts[0]->bwidth );
+ }
+ else
+ {
+ stereo_cng_upd_counters( hCPE->hStereoCng, hCPE->element_mode, hCPE->hStereoDft->nbands, hCPE->hStereoDft->sidSideGain, sts[0]->hTdCngEnc->burst_ho_cnt, &hCPE->hStereoDft->coh_fade_counter );
+ }
+ }
+
+ /* Write stereo bitstream */
+ cpe_brate = st_ivas->hCPE[0]->element_brate;
+
+ /* DFT stereo side bits */
+ if ( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && cpe_brate < MASA_STEREO_MIN_BITRATE && sts[0]->core_brate != SID_2k40 && sts[0]->core_brate != FRAME_NO_DATA )
+ {
+ nb_bits = 0; /* Only mono downmix is transmitted in this case */
+ }
+ else if ( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && ( sts[0]->core_brate == SID_2k40 || sts[0]->core_brate == FRAME_NO_DATA ) )
+ {
+ nb_bits = hCPE->hMetaData->nb_bits_tot;
+ }
+ else
+ {
+ stereo_dft_enc_write_BS( hCPE, &nb_bits );
+ }
+
+ /* 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 ) ) )
+ {
+ 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 )
+ {
+ max_bits -= nb_bits_metadata;
+ if ( hCPE->brate_surplus < 0 )
+ {
+ max_bits += (int16_t) ( hCPE->brate_surplus / FRAMES_PER_SEC );
+ }
+ }
+
+ stereo_dft_enc_res( hCPE->hStereoDft, old_inp_12k8[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 )
+ {
+ assert( ( nb_bits <= ( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS ) ) && "Stereo DFT CNG: bit budget is violated" );
+ }
+ else
+ {
+ /* Flexible total bitrate in M channel */
+ sts[0]->total_brate = hCPE->element_brate - ( nb_bits * FRAMES_PER_SEC );
+ }
+
+ /* subtract metadata bitbudget */
+ sts[0]->total_brate -= ( nb_bits_metadata * FRAMES_PER_SEC );
+
+ /* 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 ) )
+ {
+ sts[0]->total_brate += hCPE->brate_surplus;
+ }
+ }
+
+
+ /*----------------------------------------------------------------*
+ * Core Encoder
+ *----------------------------------------------------------------*/
+
+ if ( ( error = ivas_core_enc( NULL, hCPE, st_ivas->hMCT, n_CoreChannels, old_inp_12k8, old_inp_16k, ener, A, Aw, epsP, lsp_new, lsp_mid, vad_hover_flag, attack_flag, realBuffer, imagBuffer, old_wsp, loc_harm, cor_map_sum, vad_flag_dtx, enerBuffer, fft_buff, tdm_SM_or_LRTD_Pri, ivas_format, 0 ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /*----------------------------------------------------------------*
+ * Common updates
+ *----------------------------------------------------------------*/
+
+ hCPE->last_element_brate = hCPE->element_brate;
+ hCPE->last_element_mode = hCPE->element_mode;
+
+ if ( ivas_format == MASA_ISM_FORMAT )
+ {
+ hCPE->element_brate = element_brate_ref;
+ }
+
+ if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL )
+ {
+ /* update input samples buffer */
+ for ( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ mvr2r( orig_input[n], sts[n]->old_input_signal, input_frame );
+ }
+ }
+ else if ( hCPE->element_mode == IVAS_CPE_DFT )
+ {
+ mvr2r( sts[0]->input, sts[0]->old_input_signal, input_frame );
+ }
+ 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++ )
+ {
+ mvr2r( sts[n]->input, sts[n]->old_input_signal, input_frame );
+ }
+ }
+
+ if ( hCPE->hFrontVad[0] != NULL )
+ {
+ hCPE->hFrontVad[0]->ini_frame++;
+ hCPE->hFrontVad[0]->ini_frame = min( hCPE->hFrontVad[0]->ini_frame, MAX_FRAME_COUNTER );
+ }
+
+ /* Store previous attack detection flag */
+ for ( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ sts[n]->hTranDet->transientDetector.prev_bIsAttackPresent = sts[n]->hTranDet->transientDetector.bIsAttackPresent;
+ }
+
+
+ pop_wmops();
+ return error;
+}
+#endif
/*-------------------------------------------------------------------------
* create_cpe_enc()
@@ -1284,7 +2038,7 @@ ivas_error create_cpe_enc_fx(
IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && LE_32( element_brate, MAX_MDCT_ITD_BRATE ) && EQ_16( ivas_format, STEREO_FORMAT ) )
{
- IF( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK )
+ IF( ( error = initMdctItdHandling( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c
index 6f58a2501986d5fbb816ba7d5e7328afb667368e..61a8092ca67773bdba18e7689be0b88932ce8f3c 100644
--- a/lib_enc/ivas_dirac_enc.c
+++ b/lib_enc/ivas_dirac_enc.c
@@ -36,8 +36,7 @@
#include