diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj
index 1a706cfebcc68923213296a43539b02069099335..75831970efdfb8fc2a9230f03be6eba7eb990195 100644
--- a/Workspace_msvc/lib_enc.vcxproj
+++ b/Workspace_msvc/lib_enc.vcxproj
@@ -379,8 +379,6 @@
-
-
diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters
index 907b5b9451f6332fadef2da2d80d0b67e5b8a712..ac23c810ff27ac52177114f39d480d36a817c8bf 100644
--- a/Workspace_msvc/lib_enc.vcxproj.filters
+++ b/Workspace_msvc/lib_enc.vcxproj.filters
@@ -216,10 +216,6 @@
enc_all_c
-
- enc_all_c
-
-
enc_all_c
diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c
index cef466471db4f1d2d9602c057a0f60a77e888c45..19b654e5e07cecc2c85544a6cd708fed1fb1d0a8 100644
--- a/lib_com/basop_util.c
+++ b/lib_com/basop_util.c
@@ -45,9 +45,6 @@
#include "basop_settings.h"
#include "cnst.h"
-
-#define WMC_TOOL_SKIP
-
extern const Word32 SqrtTable[32]; // Q31
extern const Word16 SqrtDiffTable[32]; /* Q15 */
@@ -405,7 +402,9 @@ static Word16 ISqrt16_common( Word16 m,
/* handle even exponents */
if ( s_and( e, 1 ) == 0 )
+ {
m = mult_r( m, 0x5a82 );
+ }
return m;
}
@@ -420,8 +419,11 @@ static Word32 ISqrt32_common( Word32 m,
#endif
assert( m >= 0x40000000 );
-
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
m16 = round_fx_o( m, &Overflow );
+#else
+ m16 = round_fx( m );
+#endif
/* get table index (upper 6 bits minus 32) */
/* index = (m16 >> 25) - 32; */
@@ -435,7 +437,9 @@ static Word32 ISqrt32_common( Word32 m,
/* handle even exponents */
if ( s_and( e, 1 ) == 0 )
+ {
m = Mpy_32_16_1( m, 0x5a82 );
+ }
return m;
}
@@ -2653,6 +2657,3 @@ cmplx CL_mult_32x16( cmplx input, cmplx_s coeff )
#endif
return result;
}
-
-
-#undef WMC_TOOL_SKIP
diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c
index 83a98a85f8b00d2bfa36490cd4df6db4f98682d1..f2a074ba52262775d8bd34d2298645746b971661 100644
--- a/lib_com/bits_alloc_fx.c
+++ b/lib_com/bits_alloc_fx.c
@@ -762,17 +762,20 @@ static ivas_error acelp_FCB_allocator_ivas(
*--------------------------------------------------------------------*/
ivas_error config_acelp1(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signalling_bits, /* i : number of signalling bits */
- const Word16 coder_type, /* i : coder type */
+ const Word16 enc_dec, /* i : encoder/decoder flag */
+ const Word32 total_brate, /* i : total bitrate */
+ const Word32 core_brate_inp, /* i : core bitrate */
+ const Word16 core, /* i : core */
+ const Word16 extl, /* i : extension layer */
+ const Word32 extl_brate, /* i : extension layer bitrate */
+ const Word16 L_frame, /* i : frame length at internal Fs */
+ const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
+ ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
+ const Word16 signalling_bits, /* i : number of signalling bits */
+ const Word16 coder_type, /* i : coder type */
+#ifdef NONBE_FIX_GSC_BSTR
+ const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
+#endif
const Word16 tc_subfr, /* i : TC subfr ID */
const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
@@ -1068,14 +1071,20 @@ ivas_error config_acelp1(
{
bits = sub( bits, TDM_IC_LSF_PRED_BITS );
}
- /* gain Q bit-budget - part 1 */
+ /* gain Q bit-budget - part 1: 'Es_pred' of memory-less gain Q */
test();
test();
test();
test();
test();
test();
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( ( NE_16( coder_type, UNVOICED ) && NE_16( coder_type, AUDIO ) && coder_type != INACTIVE && !( LE_32( core_brate, ACELP_8k00 ) && NE_16( coder_type, TRANSITION ) ) ) /* mid bitrates in GC and VC, low+mid bitrates in TC */ ||
+ ( coder_type == INACTIVE && !inactive_coder_type_flag ) /* AVQ inactive */
+ )
+#else
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 ) ) )
+#endif
{
*nBits_es_Pred = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, -1, -1 )];
move16();
@@ -1196,7 +1205,11 @@ ivas_error config_acelp1(
{
test();
test();
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && inactive_coder_type_flag ) /* GSC Inactive @16kHz */
+#else
IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) /* GSC Inactive @16kHz */
+#endif
{
acelp_cfg->ltf_mode = FULL_BAND;
move16();
@@ -1414,7 +1427,14 @@ ivas_error config_acelp1(
acelp_cfg->fixed_cdk_index[3] = -1;
move16();
}
+#ifdef NONBE_FIX_GSC_BSTR
+ ELSE IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || /* @12.8kHz core except of GSC */
+ ( EQ_16( nb_subfr, NB_SUBFR16k ) && ( !inactive_coder_type_flag || coder_type != INACTIVE ) ) /* @16kHz core GC, TC, AVQ inactive */ ||
+ EQ_16( core, HQ_CORE ) /* ACELP -> HQ switching in EVS */
+ )
+#else
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 ) )
+#endif
{
/* pitch Q & gain Q bit-budget - part 2*/
FOR( i = 0; i < nb_subfr; i++ )
@@ -1478,7 +1498,13 @@ ivas_error config_acelp1(
test();
test();
test();
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( flag_hardcoded /* EVS */ ||
+ ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ ||
+ ( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ )
+#else
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 ) )
+#endif
{
FOR( i = 0; i < nb_subfr; i++ )
{
@@ -1587,7 +1613,12 @@ ivas_error config_acelp1(
test();
test();
test();
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ ||
+ ( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ )
+#else
IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) || ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) && coder_type == INACTIVE ) )
+#endif
{
FOR( i = 0; i < nb_subfr; i++ )
{
@@ -1627,7 +1658,13 @@ ivas_error config_acelp1(
}
}
}
+#ifdef NONBE_FIX_GSC_BSTR
+ ELSE IF( ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) /* LBR secondary channel in TD stereo */ ||
+ ( ( coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( nb_subfr, NB_SUBFR ) ) /* GSC @12.8kHz */ ||
+ ( coder_type == INACTIVE && inactive_coder_type_flag ) /* AVQ inactive */ )
+#else
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 ) ) )
+#endif
{
Word32 Local_BR, Pitch_BR;
Word16 Pitch_CT;
@@ -1768,7 +1805,12 @@ ivas_error config_acelp1(
test();
test();
test();
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( ( EQ_16( L_frame, L_FRAME16k ) && coder_type == INACTIVE && inactive_coder_type_flag ) /* GSC Inactive @16kHz */ ||
+ ( GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) ) /* IVAS GSC @16kHz */
+#else
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 */
+#endif
{
acelp_cfg->ubits = 0;
move16();
@@ -1877,17 +1919,20 @@ ivas_error config_acelp1(
*--------------------------------------------------------------------*/
ivas_error config_acelp1_IVAS(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signaling_bits, /* i : number of signaling bits */
- const Word16 coder_type, /* i : coder type */
+ const Word16 enc_dec, /* i : encoder/decoder flag */
+ const Word32 total_brate, /* i : total bitrate */
+ const Word32 core_brate_inp, /* i : core bitrate */
+ const Word16 core, /* i : core */
+ const Word16 extl, /* i : extension layer */
+ const Word32 extl_brate, /* i : extension layer bitrate */
+ const Word16 L_frame, /* i : frame length at internal Fs */
+ const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
+ ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
+ const Word16 signaling_bits, /* i : number of signaling bits */
+ const Word16 coder_type, /* i : coder type */
+#ifdef NONBE_FIX_GSC_BSTR
+ const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
+#endif
const Word16 tc_subfr, /* i : TC subfr ID */
const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
@@ -2168,8 +2213,13 @@ ivas_error config_acelp1_IVAS(
test();
test();
test();
- /* gain Q bit-budget - part 1 */
+ /* gain Q bit-budget - part 1: 'Es_pred' of memory-less gain Q */
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( ( NE_16( coder_type, UNVOICED ) && NE_16( coder_type, AUDIO ) && coder_type != INACTIVE && !( LE_32( core_brate, ACELP_8k00 ) && NE_16( coder_type, TRANSITION ) ) ) /* mid bitrates in GC and VC, low+mid bitrates in TC */ ||
+ ( coder_type == INACTIVE && !inactive_coder_type_flag ) /* AVQ inactive */ )
+#else
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 ) ) )
+#endif
{
*nBits_es_Pred = Es_pred_bits_tbl[BIT_ALLOC_IDX( core_brate, coder_type, -1, -1 )];
move16();
@@ -2294,7 +2344,11 @@ ivas_error config_acelp1_IVAS(
{
test();
test();
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && inactive_coder_type_flag ) /* GSC Inactive @16kHz */
+#else
IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) /* GSC Inactive @16kHz */
+#endif
{
acelp_cfg->ltf_mode = FULL_BAND;
move16();
@@ -2510,7 +2564,13 @@ ivas_error config_acelp1_IVAS(
acelp_cfg->fixed_cdk_index[3] = -1;
move16();
}
+#ifdef NONBE_FIX_GSC_BSTR
+ ELSE IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) /* @12.8kHz core except of GSC */ ||
+ ( EQ_16( nb_subfr, NB_SUBFR16k ) && ( !inactive_coder_type_flag || coder_type != INACTIVE ) ) /* @16kHz core GC, TC, AVQ inactive */ ||
+ EQ_16( core, HQ_CORE ) /* ACELP -> HQ switching in EVS */ )
+#else
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 ) )
+#endif
{
/* pitch Q & gain Q bit-budget - part 2*/
FOR( i = 0; i < nb_subfr; i++ )
@@ -2574,7 +2634,13 @@ ivas_error config_acelp1_IVAS(
test();
test();
/* algebraic codebook bit-budget */
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( flag_hardcoded /* EVS */ ||
+ ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ ||
+ ( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ )
+#else
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 ) )
+#endif
{
FOR( i = 0; i < nb_subfr; i++ )
{
@@ -2675,7 +2741,12 @@ ivas_error config_acelp1_IVAS(
test();
test();
/* AVQ codebook */
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ ||
+ ( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ )
+#else
IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) || ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) && coder_type == INACTIVE ) )
+#endif
{
FOR( i = 0; i < nb_subfr; i++ )
{
@@ -2713,7 +2784,13 @@ ivas_error config_acelp1_IVAS(
}
}
}
+#ifdef NONBE_FIX_GSC_BSTR
+ ELSE IF( ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) /* LBR secondary channel in TD stereo */ ||
+ ( ( coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( nb_subfr, NB_SUBFR ) ) /* GSC @12.8kHz */ ||
+ ( coder_type == INACTIVE && inactive_coder_type_flag ) /* AVQ inactive */ )
+#else
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 ) ) )
+#endif
{
Word32 Local_BR, Pitch_BR;
Word16 Pitch_CT;
@@ -2854,7 +2931,12 @@ ivas_error config_acelp1_IVAS(
test();
test();
test();
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( ( EQ_16( L_frame, L_FRAME16k ) && coder_type == INACTIVE && inactive_coder_type_flag ) /* GSC Inactive @16kHz */ ||
+ ( GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) ) /* IVAS GSC @16kHz */
+#else
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 */
+#endif
{
acelp_cfg->ubits = 0;
move16();
diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c
index 5a3d2e1a27b1fd60aba746579f8bc5cee346fe1e..b6eafd993ccf0ed5786ef9c075f171c8c45fad8f 100644
--- a/lib_com/cldfb.c
+++ b/lib_com/cldfb.c
@@ -1213,7 +1213,7 @@ void cldfbSynthesis_ivas_fx(
/*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] = Msub_32_32( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_re_fx[i] ), imagBuffer_fx[k][( M1 - 1 ) - ( i * 2 )], rot_vctr_im_fx[i] ); // Qx
move32();
- iBuffer_fx[2 * i + 1] = Madd_32_32( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_im_fx[i] ), imagBuffer_fx[k][( M1 - 1 ) - ( i * 2 )], rot_vctr_re_fx[i] ); // Qx
+ iBuffer_fx[2 * i + 1] = Msub_32_32( Mpy_32_32( imagBuffer_fx[k][( M1 - 1 ) - ( i * 2 )], rot_vctr_re_fx[i] ), imagBuffer_fx[k][2 * i], rot_vctr_im_fx[i] ); // Qx
move32();
}
diff --git a/lib_com/cnst.h b/lib_com/cnst.h
index 66b6dc9a15d2f74cffce30849e79c01572b3fc3f..a5030ac9c98bb3bf1f430798afe117443c43918a 100644
--- a/lib_com/cnst.h
+++ b/lib_com/cnst.h
@@ -1233,6 +1233,7 @@ enum
#define SPC 0.0234952f
#define SPC_plus SPC * 1.001f
#define ALPHA_SQ ( ( 0.5f / PI2 ) * ( 0.5f / PI2 ) )
+#define ALPHA_SQ_Q30 (6799549) /* ( ( 0.5f / PI2 ) * ( 0.5f / PI2 ) ) in Q30 */
#define NC M / 2
#define LSF_GAP 50.0f
diff --git a/lib_com/fft_rel.c b/lib_com/fft_rel.c
index 85d0ae76a6e87bc28c3ea04e27d5d26d19a4d3c6..aa3b578bdb1a0df53f8fd8541e0ff198da03d704 100644
--- a/lib_com/fft_rel.c
+++ b/lib_com/fft_rel.c
@@ -301,6 +301,168 @@ void fft_rel(
return;
}
+void fft_rel_16_32fx(
+ Word16 x[], /* i/o: input/output vector Qx */
+ Word16 *q_x, /* extra scaling added on speech buffer*/
+ Word16 i_subfr,
+ const Word16 n, /* i : vector length */
+ const Word16 m /* i : log2 of vector length */
+)
+{
+ Word16 i, j, k, n1, n2, n4;
+ Word16 step;
+ Word32 xt, t1, t2;
+ Word32 *x0, *x1, *x2;
+ const Word16 *s, *c;
+ Word32 *xi2, *xi3, *xi4, *xi1;
+
+ Word32 fft_bff32[L_FFT];
+ Copy_Scale_sig_16_32_no_sat( x, fft_bff32, L_FFT, 0 ); // copying x to fft_bff32 without scaling
+
+ /*-----------------------------------------------------------------*
+ * Digit reverse counter
+ *-----------------------------------------------------------------*/
+
+ j = 0;
+ move16();
+ x0 = &fft_bff32[0]; // Qx
+ FOR( i = 0; i < n - 1; i++ )
+ {
+ IF( LT_16( i, j ) )
+ {
+ xt = fft_bff32[j]; // Qx
+ move32();
+ fft_bff32[j] = *x0; // Qx
+ move32();
+ *x0 = xt; // Qx
+ move32();
+ }
+ x0++;
+ k = shr( n, 1 );
+ WHILE( ( k <= j ) )
+ {
+ j = sub( j, k );
+ k = shr( k, 1 );
+ }
+ j = add( j, k );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Length two butterflies
+ *-----------------------------------------------------------------*/
+
+ x0 = &fft_bff32[0];
+ x1 = &fft_bff32[1];
+ FOR( i = 0; i < ( n >> 1 ); i++ )
+ {
+ xt = *x0;
+ move32();
+ *x0 = L_add( xt, *x1 );
+ move32();
+ *x1 = L_sub( xt, *x1 );
+ move32();
+ x0++;
+ x0++;
+ x1++;
+ x1++;
+ }
+
+ /*-----------------------------------------------------------------*
+ * Other butterflies
+ *
+ * The implementation described in [1] has been changed by using
+ * table lookup for evaluating sine and cosine functions. The
+ * variable ind and its increment step are needed to access table
+ * entries. Note that this implementation assumes n4 to be so
+ * small that ind will never exceed the table. Thus the input
+ * argument n and the constant N_MAX_SAS must be set properly.
+ *-----------------------------------------------------------------*/
+
+ n2 = 1;
+ move16();
+ /* step = N_MAX_SAS/4; */
+ FOR( k = 2; k <= m; k++ )
+ {
+ n4 = n2;
+ move16();
+ n2 = shl( n4, 1 );
+ n1 = shl( n2, 1 );
+
+ step = idiv1616( N_MAX_SAS, n1 );
+
+ x0 = fft_bff32;
+ x1 = fft_bff32 + n2;
+ x2 = fft_bff32 + add( n2, n4 );
+ FOR( i = 0; i < n; i += n1 )
+ {
+ xt = *x0;
+ move32(); /* xt = x[i]; */
+ *x0 = L_add( xt, *x1 );
+ move32(); /* x[i] = xt + x[i+n2]; */
+ *x1 = L_sub( xt, *x1 );
+ move32(); /* x[i+n2] = xt - x[i+n2]; */
+ *x2 = L_negate( *x2 );
+ move32(); /* x[i+n2+n4] = -x[i+n2+n4]; */
+
+
+ s = sincos_t_fx + step; // Q15
+ c = s + 64; // Q15
+ xi1 = fft_bff32 + add( i, 1 );
+ xi3 = xi1 + n2;
+ xi2 = xi3 - 2;
+ xi4 = xi1 + sub( n1, 2 );
+
+ FOR( j = 1; j < n4; j++ )
+ {
+ t1 = L_add( Mpy_32_16_1( *xi3, *c ), Mpy_32_16_1( *xi4, *s ) ); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); Qx */
+ t2 = L_sub( Mpy_32_16_1( *xi3, *s ), Mpy_32_16_1( *xi4, *c ) ); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); Qx */
+ *xi4 = L_sub( *xi2, t2 );
+ move32();
+ *xi3 = L_negate( L_add( *xi2, t2 ) );
+ move32();
+ *xi2 = L_sub( *xi1, t1 );
+ move32();
+ *xi1 = L_add( *xi1, t1 );
+ move32();
+
+ xi4--;
+ xi2--;
+ xi3++;
+ xi1++;
+ c += step;
+ s += step; /* autoincrement by ar0 */
+ }
+
+ x0 += n1;
+ x1 += n1;
+ x2 += n1;
+ }
+ /* step = shr(step, 1); */
+ }
+ Word16 norm = L_norm_arr( fft_bff32, L_FFT );
+ IF( i_subfr == 0 )
+ {
+ Copy_Scale_sig32_16( fft_bff32, x, L_FFT, norm );
+ *q_x = sub( norm, 16 );
+ move16();
+ }
+ ELSE
+ {
+ IF( LT_16( sub( norm, 16 ), *q_x ) )
+ {
+ scale_sig( x - L_FFT, L_FFT, sub( sub( norm, 16 ), *q_x ) );
+ Copy_Scale_sig32_16( fft_bff32, x, L_FFT, norm );
+ *q_x = sub( norm, 16 );
+ move16();
+ }
+ ELSE
+ {
+ Copy_Scale_sig32_16( fft_bff32, x, L_FFT, add( 16, *q_x ) );
+ }
+ }
+
+ return;
+}
void fft_rel_fx(
Word16 x[], /* i/o: input/output vector Qx */
diff --git a/lib_com/fill_spectrum.c b/lib_com/fill_spectrum.c
index 111ac6d2fdd84f8e6d115a17a6e3aea35c131f6a..5a4f7c4bcf05136cd631454daeb55423b9a26817 100644
--- a/lib_com/fill_spectrum.c
+++ b/lib_com/fill_spectrum.c
@@ -263,7 +263,7 @@ void ivas_fill_spectrum_fx(
}
ELSE IF( EQ_16( HQ_mode, HQ_GEN_SWB ) || EQ_16( HQ_mode, HQ_GEN_FB ) )
{
- hq_bwe_fx( HQ_mode, L_coeff_out1, hq_generic_fenv, L_coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, sfm_end, num_sfm, num_env_bands, R );
+ hq_bwe_ivas_fx( HQ_mode, L_coeff_out1, hq_generic_fenv, L_coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, sfm_end, num_sfm, num_env_bands, R );
}
/*----------------------------------------------------------------*
diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c
index 5dfe6b1d60d0b91bd4af72426e6c728581063cd7..c0feb91f53993f4027fe1d1f6818023af94b5e13 100644
--- a/lib_com/gs_inact_switching_fx.c
+++ b/lib_com/gs_inact_switching_fx.c
@@ -162,15 +162,17 @@ void Inac_switch_ematch_ivas_fx(
Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
const Word16 coder_type, /* i : Coding mode */
- const Word16 L_frame, /* i : Frame lenght */
- const Word32 total_brate, /* i : total bit rate */
- const Word16 Q_exc /* i : input and output format of exc2 */
- ,
- const Word16 bfi /* i : frame lost indicator */
- ,
- const Word16 last_core, /* i : Last core used */
- const Word16 last_codec_mode /* i : Last codec mode */
- ,
+#ifdef NONBE_FIX_GSC_BSTR
+ const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
+#endif
+ const Word16 L_frame, /* i : Frame lenght */
+#ifndef NONBE_FIX_GSC_BSTR
+ const Word32 total_brate, /* i : total bit rate */
+#endif
+ const Word16 Q_exc, /* i : input and output format of exc2 */
+ const Word16 bfi, /* i : frame lost indicator */
+ const Word16 last_core, /* i : Last core used */
+ const Word16 last_codec_mode, /* i : Last codec mode */
const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
const Word16 element_mode /* i : element mode */
)
@@ -222,7 +224,11 @@ void Inac_switch_ematch_ivas_fx(
move16();
}
}
+#ifdef NONBE_FIX_GSC_BSTR
+ ELSE IF( ( coder_type == INACTIVE ) && inactive_coder_type_flag )
+#else
ELSE IF( ( coder_type == INACTIVE ) && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) )
+#endif
{
/* Find spectrum and energy per band for inactive frames */
edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode );
diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c
index 998f3f0488df977c48603fd05d53d9d829be6293..7b7da27e626cba25fe998fcf4fe5497327fd1212 100644
--- a/lib_com/hq_tools_fx.c
+++ b/lib_com/hq_tools_fx.c
@@ -2102,6 +2102,36 @@ void hq_bwe_fx(
return;
}
+void hq_bwe_ivas_fx(
+ const Word16 HQ_mode, /* i : HQ mode Q0*/
+ Word32 *coeff_out1, /* i/o: BWE input & temporary buffer Q12*/
+ const Word16 *hq_generic_fenv, /* i : SWB frequency envelopes Q1*/
+ Word32 *coeff_out, /* o : SWB signal in MDCT domain Q12*/
+ const Word16 hq_generic_offset, /* i : frequency offset for representing hq generic Q0*/
+ Word16 *prev_L_swb_norm, /* i/o: last normalize length Q0*/
+ const Word16 hq_generic_exc_clas, /* i : hq generic hf excitation class Q0*/
+ const Word16 *sfm_end, /* i : End of bands Q0*/
+ const Word16 num_sfm, /* i : Number of bands Q0*/
+ const Word16 num_env_bands, /* i : Number of coded envelope bands Q0*/
+ const Word16 *R /* i : Bit allocation Q0*/
+)
+{
+ Word16 n_swb_overlap_offset, n_swb_overlap;
+ Word32 hq_swb_overlap_buf_fx[L_FRAME32k];
+
+ n_swb_overlap_offset = add( swb_bwe_subband[0], hq_generic_offset );
+ n_swb_overlap = sub( sfm_end[( num_env_bands - 1 )], n_swb_overlap_offset ); /*Q0*/
+
+
+ Copy32( &coeff_out[n_swb_overlap_offset], hq_swb_overlap_buf_fx, sub( add( n_swb_overlap, sfm_end[( num_sfm - 1 )] ), sfm_end[( num_env_bands - 1 )] ) ); /*Q12*/
+
+ hq_generic_decoding_ivas_fx( HQ_mode, coeff_out1, hq_generic_fenv, coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, R );
+
+ overlap_hq_bwe_fx( hq_swb_overlap_buf_fx, coeff_out, n_swb_overlap_offset, n_swb_overlap, R, num_env_bands, num_sfm, sfm_end );
+
+ return;
+}
+
/*--------------------------------------------------------------------------*
* hq_wb_nf_bwe()
*
diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c
index ac47365616ae6dc38b6b80d115ebd47bb02c3e3e..cc138d070b85202a6bd91c580ff908099857281a 100644
--- a/lib_com/ivas_rom_com_fx.c
+++ b/lib_com/ivas_rom_com_fx.c
@@ -1356,6 +1356,16 @@ const UWord32 tdm_ratio_tabl_fx[TDM_NQ + 1] = {
2147483647, 2147483647, 2147483647
};
+// Q30
+const Word32 tdm_ratio_tabl_fx_Q30[] = {
+ 0, 0, 11703786, 26306674, 46385648, 71940704, 102542344, 137868448,
+ 177596896, 221298192, 268435456, 318471840, 370977792, 425201760, 480714208,
+ 536870912, 593027584, 648540032, 702764032, 755270016, 805306368, 852443648,
+ 896144896, 935873344, 971199488, 1001801152, 1027356160, 1047435136,
+ 1062038016, 1073741824, 1073741824, 1073741824
+};
+
+
// Q24
const Word32 tdm_ratio_tabl_fx_Q24[TDM_NQ + 1] = {
0, 0, 182871, 411041, 724775, 1124073, 1602224, 2154194,
diff --git a/lib_com/ivas_rom_com_fx.h b/lib_com/ivas_rom_com_fx.h
index 88bbaabbc1ff3dc34004d6192170ae7b2639044d..e1f4d0a6eb9379ced0a934c0b8c98cb714758714 100644
--- a/lib_com/ivas_rom_com_fx.h
+++ b/lib_com/ivas_rom_com_fx.h
@@ -108,6 +108,7 @@ extern const Word16 pow_10_icbwe_gsMappingDFT_tbl_fx[];
*----------------------------------------------------------------------------------*/
extern const UWord32 tdm_ratio_tabl_fx[TDM_NQ + 1];
+extern const Word32 tdm_ratio_tabl_fx_Q30[TDM_NQ + 1];
extern const Word32 tdm_ratio_tabl_fx_Q24[TDM_NQ + 1];
extern const UWord32 tdm_den_ratio_tabl_fx[];
extern const Word16 icbwe_gsMapping_tbl_fx[]; // Q12
diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c
index 9f5106e0cff9752da43bd6a24ccd2b41f30a8901..14de6cc1524c2068ce56efcaeb937e48ffac5640 100644
--- a/lib_com/ivas_spar_com.c
+++ b/lib_com/ivas_spar_com.c
@@ -2636,7 +2636,7 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
#ifdef FIX_ISSUE_1122
recon_uu_re[i][j] = L_shr( recon_uu_re[i][j], 1 ); // q_recon_uu_re[i][j] - 1
#else
- re1[m] = L_shr( re1[m], 1 ); // q_recon_uu_re[i][j]-1
+ re1[m] = L_shr( re1[m], 1 ); // q_recon_uu_re[i][j]-1
#endif
move32();
q_recon_uu_re[i][j] = sub( q_recon_uu_re[i][j], 1 );
@@ -3836,7 +3836,11 @@ void ivas_compute_spar_params_fx(
}
ELSE
{
+#ifdef FIX_11_1_IVAS_SPAR_DEC_UPMIXER_SF_RND_COEFFS
+ hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].pred_re_fx[i] = L_shr_r( hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].pred_re_fx[i], sub( tmp, 22 ) ); // q22
+#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 ) ); // q22
+#endif
move32();
}
}
diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c
index 3ebfd99c1e065ba93c7f0a8deeee608c1acb3ce0..be9f358683e12cb417e25c2e2a447f9220d4f958 100644
--- a/lib_com/ivas_stereo_ica_com_fx.c
+++ b/lib_com/ivas_stereo_ica_com_fx.c
@@ -131,17 +131,7 @@ static void interpTargetChannel_fx(
Word32 spread_factor2_fx;
Word64 tempD1_fx, tempD2_fx;
- d = negate( sub( currShift, prevShift ) );
- IF( d >= 0 )
- {
- signShift = 1;
- move16();
- }
- ELSE
- {
- signShift = -1;
- move16();
- }
+ d = sub( prevShift, currShift );
IF( d == 0 )
{
@@ -149,6 +139,15 @@ static void interpTargetChannel_fx(
return;
}
+ signShift = 1;
+ move16();
+
+ if ( d < 0 )
+ {
+ signShift = -1;
+ move16();
+ }
+
N = L_shift_adapt;
move16();
Word32 *table_pointer = NULL;
@@ -207,7 +206,7 @@ static void interpTargetChannel_fx(
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] ); // qsynth
+ ptr2_fx[i] = Madd_32_32( ptr2_fx[i], win_fx[j * INTERP_FACTOR1 - i], ptr1_fx[j] ); // qsynth
move32();
}
}
@@ -225,44 +224,31 @@ static void interpTargetChannel_fx(
tempD1_fx = W_deposit32_l( table_D1_pointer[abs( d )] ); // Q35
tempD2_fx = W_mult0_32_32( 3, table_D1_pointer[abs( d )] ); // Q35
- IF( EQ_16( signShift, 1 ) )
+ tempF1_fx = -ONE_IN_Q12; // Q12
+ move32();
+
+ if ( EQ_16( signShift, 1 ) )
{
tempF1_fx = ONE_IN_Q12; // Q12
move32();
}
- ELSE
- {
- tempF1_fx = -ONE_IN_Q12; // Q12
- move32();
- }
+
tempF1_fx = L_sub( imult3216( factor_fx, d ), tempF1_fx ); // Q12
- FOR( k = 0; k < sub( N, 1 ); k++ )
+ FOR( k = 0; k < 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 ); // 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 ) ); // Q0
+ Word32 local = Madd_32_32( -ONE_IN_Q12, tempF1_fx, spread_factor2_fx ); // Q12
+ Word32 local_int = L_shr( local, 12 ); // Q0
Word32 res_a1, res_a2, res_a3;
Word32 res_b1, res_b2, res_b3;
Word32 res_c1, res_c2, res_c3;
Word32 res_d1, res_d2, res_d3;
- Word64 local_int_scaled;
+ Word32 local_int_scaled;
Word64 res_a, res_b, res_c, res_d;
Word64 tempa, tempb;
Word64 mult_a_D1, mult_b_D2;
- local_int = W_extract_l( W_mult0_32_32( sign_local, local_int ) ); // Q0
- local_int_scaled = W_deposit32_l( L_shl( local_int, 12 ) ); // Q12
- lim1 = extract_l( local_int ); // Q0
- IF( W_sub( local_int_scaled, local ) > 0 ) // Q21
+ local_int_scaled = L_shl( local_int, 12 ); // Q12
+ lim1 = extract_l( local_int ); // Q0
+ if ( L_sub( local_int_scaled, local ) > 0 ) // Q12
{
lim1 = sub( lim1, 1 ); // Q0
}
@@ -387,7 +373,7 @@ static void targetCh_AlignStereoDFT_fx(
}
FOR( i = 0; i < L_shift_adapt; i++ )
{
- target_fx[i] = L_add( Mpy_32_32( alpha_fx, fadeInBuff_fx[i] ), Mpy_32_32( L_sub( ONE_IN_Q31, alpha_fx ), fadeOutBuff_fx[i] ) ); // qsynth
+ target_fx[i] = Madd_32_32( Mpy_32_32( alpha_fx, fadeInBuff_fx[i] ), L_sub( ONE_IN_Q31, alpha_fx ), fadeOutBuff_fx[i] ); // qsynth
move32();
alpha_fx = L_add_sat( alpha_fx, winSlope_fx ); // Q31
diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c
index 8d486df04dd62d69e843008e92faa6cc86770729..d6210dfc7d4b3c050bd77310f010c93922678654 100644
--- a/lib_com/ivas_tools.c
+++ b/lib_com/ivas_tools.c
@@ -942,6 +942,12 @@ Word16 matrix_product_mant_exp_fx(
Word16 *Zp_fx_e = out_e;
Word16 row, col;
Word16 x_idx, y_idx;
+ Word64 temp;
+ Word16 temp_e;
+ Word16 prod_e = add( X_fx_e, Y_fx_e );
+
+ Word16 max_exp = -31;
+ move16();
/* Processing */
test();
@@ -957,17 +963,28 @@ Word16 matrix_product_mant_exp_fx(
{
FOR( i = 0; i < colsX; ++i )
{
- ( *Zp_fx ) = 0;
- move32();
- ( *Zp_fx_e ) = 0;
- move16();
+ temp = 0;
+ move64();
+
FOR( k = 0; k < rowsX; ++k )
{
- 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 ); /*Q31 - Zp_fx_e*/
- move32();
+ x_idx = k + i * rowsX;
+ y_idx = k + j * rowsY;
+ temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e
}
+ /* Maximize accumulated value to 32-bit */
+ temp_e = W_norm( temp );
+ temp = W_shl( temp, temp_e );
+ if ( 0 == temp )
+ {
+ temp_e = prod_e;
+ move16();
+ }
+ *Zp_fx_e = sub( prod_e, temp_e );
+ move16();
+ ( *Zp_fx ) = W_extract_h( temp );
+ move32();
+ max_exp = s_max( max_exp, *Zp_fx_e ); // Find the max exp
Zp_fx++;
Zp_fx_e++;
}
@@ -987,17 +1004,27 @@ Word16 matrix_product_mant_exp_fx(
{
FOR( i = 0; i < rowsX; ++i )
{
- ( *Zp_fx ) = 0;
- move32();
- ( *Zp_fx_e ) = 0;
- move16();
+ temp = 0;
+ move64();
FOR( k = 0; k < colsX; ++k )
{
- 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 ); /*Q31 - Zp_fx_e*/
- move32();
+ x_idx = i + k * rowsX;
+ y_idx = j + k * rowsY;
+ temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e
+ }
+ /* Maximize accumulated value to 32-bit */
+ temp_e = W_norm( temp );
+ temp = W_shl( temp, temp_e );
+ if ( 0 == temp )
+ {
+ temp_e = prod_e;
+ move16();
}
+ *Zp_fx_e = sub( prod_e, temp_e );
+ move16();
+ ( *Zp_fx ) = W_extract_h( temp );
+ move32();
+ max_exp = s_max( max_exp, *Zp_fx_e ); // Find the max exp
Zp_fx++;
Zp_fx_e++;
}
@@ -1017,18 +1044,27 @@ Word16 matrix_product_mant_exp_fx(
{
FOR( i = 0; i < colsX; ++i )
{
- ( *Zp_fx ) = 0;
- move32();
- ( *Zp_fx_e ) = 0;
- move16();
+ temp = 0;
+ move64();
FOR( k = 0; k < colsX; ++k )
{
- 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 ); /*Q31 - Zp_fx_e*/
- move32();
+ x_idx = k + i * rowsX;
+ y_idx = j + k * rowsY;
+ temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e
}
-
+ /* Maximize accumulated value to 32-bit */
+ temp_e = W_norm( temp );
+ temp = W_shl( temp, temp_e );
+ if ( 0 == temp )
+ {
+ temp_e = prod_e;
+ move16();
+ }
+ *Zp_fx_e = sub( prod_e, temp_e );
+ move16();
+ ( *Zp_fx ) = W_extract_h( temp );
+ move32();
+ max_exp = s_max( max_exp, *Zp_fx_e ); // Find the max exp
Zp_fx++;
Zp_fx_e++;
}
@@ -1049,17 +1085,26 @@ Word16 matrix_product_mant_exp_fx(
{
FOR( i = 0; i < rowsX; ++i )
{
- ( *Zp_fx ) = 0;
- move32();
- ( *Zp_fx_e ) = 0;
- move16();
+ temp = 0;
+ move64();
FOR( k = 0; k < colsX; ++k )
{
- 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 ); /*Q31 - Zp_fx_e*/
- move32();
+ x_idx = i + k * rowsX;
+ y_idx = k + j * rowsY;
+ temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e
+ }
+ /* Maximize accumulated value to 32-bit */
+ temp_e = W_norm( temp );
+ temp = W_shl( temp, temp_e );
+ if ( 0 == temp )
+ {
+ temp_e = prod_e;
}
+ *Zp_fx_e = sub( prod_e, temp_e );
+ move16();
+ ( *Zp_fx ) = W_extract_h( temp );
+ move32();
+ max_exp = s_max( max_exp, *Zp_fx_e ); // Find the max exp
Zp_fx++;
Zp_fx_e++;
}
@@ -1070,18 +1115,11 @@ Word16 matrix_product_mant_exp_fx(
move16();
}
Zp_fx = Z_fx; /*Q31 - Zp_fx_e*/
+
Zp_fx_e = out_e;
- Word16 max_exp = -31;
move16();
- FOR( j = 0; j < row; ++j )
- {
- FOR( i = 0; i < col; ++i )
- {
- max_exp = s_max( max_exp, *Zp_fx_e );
- Zp_fx_e++;
- }
- }
- Zp_fx_e = out_e;
+
+
*Z_fx_e = max_exp;
move16();
FOR( j = 0; j < row; ++j )
diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c
index b99fc47538f9cd8cae2507f1a5d809175a1e00a3..0a8a86aee07b9f02c0ebdc231a74620231793d82 100644
--- a/lib_com/lsf_tools_fx.c
+++ b/lib_com/lsf_tools_fx.c
@@ -1505,6 +1505,80 @@ void lsp_weights_fx(
move16();
}
+void lsp_weights_ivas_fx(
+ Word16 lsp_nq_fx[],
+ Word16 w[],
+ Word16 Order,
+ Word16 *Qout )
+{
+ Word16 i;
+ Word16 q_weight[20];
+ Word32 weight[20];
+ Word16 delta1, delta2;
+ Word32 L_tmp;
+ Word16 q_min;
+
+ delta1 = lsp_nq_fx[0]; // Q15
+ move16();
+ delta2 = sub( lsp_nq_fx[1], lsp_nq_fx[0] ); // Q15
+
+ L_tmp = L_mult0( delta1, delta2 ); // Q30 // Q30
+ L_tmp = root_a_over_b_ivas_fx( ALPHA_SQ_Q30, Q30, L_tmp, Q30, &q_weight[0] ); // q_weight[0]
+
+ weight[0] = Mpy_32_16_1( L_tmp, 32000 /* 250 in Q7*/ ); // q_weight[0]-8
+ q_weight[0] = sub( q_weight[0], 8 );
+ move32();
+ move16();
+
+ q_min = q_weight[0];
+ move16();
+
+ FOR( i = 1; i < Order - 1; i++ )
+ {
+ delta1 = sub( lsp_nq_fx[i], lsp_nq_fx[i - 1] ); // Q15
+ delta2 = sub( lsp_nq_fx[i + 1], lsp_nq_fx[i] ); // Q15
+
+ L_tmp = L_mult0( delta1, delta2 ); // Q30
+ L_tmp = root_a_over_b_ivas_fx( ALPHA_SQ_Q30, Q30, L_tmp, Q30, &q_weight[i] ); // q_weight[i]
+
+ weight[i] = Mpy_32_16_1( L_tmp, 32000 /* 250 in Q7*/ ); // q_weight[i]
+ q_weight[i] = sub( q_weight[i], 8 );
+ move32();
+ move16();
+
+ q_min = s_min( q_min, q_weight[i] );
+ }
+ delta1 = sub( lsp_nq_fx[i], lsp_nq_fx[i - 1] ); // Q15
+ delta2 = sub( 16384 /* 0.5 in Q15*/, lsp_nq_fx[i] ); // Q15
+
+ L_tmp = L_mult0( delta1, delta2 ); // Q30
+ L_tmp = root_a_over_b_ivas_fx( ALPHA_SQ_Q30, Q30, L_tmp, Q30, &q_weight[i] ); // q_weight[i]
+
+ weight[i] = Mpy_32_16_1( L_tmp, 32000 /* 250 in Q7*/ ); // q_weight[i]
+ q_weight[i] = sub( q_weight[i], 8 );
+ move32();
+ move16();
+
+ q_min = s_min( q_min, q_weight[i] );
+
+ FOR( i = 0; i < Order; i++ )
+ {
+ w[i] = round_fx( L_shl( weight[i], sub( q_min, q_weight[i] ) ) ); /* q_min-16 */
+ move16();
+ }
+
+ IF( Order != LPC_SHB_ORDER_WB )
+ {
+ w[3] = round_fx( L_shl( L_mult( w[3], 18022 ), 1 ) ); /* q_min-16 */
+ w[4] = round_fx( L_shl( L_mult( w[4], 18022 ), 1 ) ); /* q_min-16 */
+ move16();
+ move16();
+ }
+
+ *Qout = sub( q_min, 16 );
+ move16();
+}
+
/*
* E_LPC_isf_isp_conversion
*
diff --git a/lib_com/options.h b/lib_com/options.h
old mode 100644
new mode 100755
index 194fab0b32a84a619f6cb8286f41fc9334050d3f..0c8105d8cabb96dade519b47aa6e7405144bdb82
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -105,6 +105,7 @@
#define FIX_1100_REMOVE_LPC_RESCALING /* VA: Remove the rescaling of LPC coefficient to Q12 as residu and syn-filt are already taking care of it*/
#define FIX_1133_IMPROVE_MC_MLD /* Ittiam: Correcting wrong updation of exponents in ivas_mc_paramupmix_param_est_enc_fx() */
#define FIX_ISSUE_1122 /* Ittiam: Fix issue 1122: corrected incorrect scaling of a buffer leading to incorrect metadata bits */
+#define FIX_ISSUE_1125 /* Ittiam: Fix issue 1125: interfering talker flag not triggered on short test vector */
#define FIX_1132_STACK_CORRUPTION /* Stack corruption issue due of extending index access*/
#define FIX_ISSUE_1092 /* Ittiam: Fix for Issue 1092: BASOP asserts in stereo fx encoder for selection test inputs*/
#define FIX_ISSUE_1135 /* Ittiam: Fix for Issue 1135: downmixing difference between float and fixed-point (DFT - stereo) */
@@ -126,6 +127,8 @@
#define FIX_ISSUE_1165 /* Ittiam: Fix for issue 1165: Assertion in lpc2lsp_fx for OMASA LTV input */
#define FIX_ISSUE_1185 /* Ittiam: Fix for issue 1185: Assertion in ivas_dirac_dec_binaural_internal_fx() for crash in decoder in fft30_with_cmplx_data()*/
#define FIX_ISSUE_1209 /* Ittiam: Fix for issue 1209: Assertion exit in BASOP encoder (stereo_dmx_evs)*/
+#define FIX_ISSUE_1218 /* Ittiam: Fix for issue 1218: Assert in stereo_dft_generate_comfort_noise_fx of BASOP decoder with BASOP MASA DTX bitstream at 32 kbps*/
+#define FIX_ISSUE_1290 /* Ittiam: Fix for issue 1218: Assert in stereo_dft_generate_comfort_noise_fx of BASOP decoder with BASOP MASA DTX bitstream at 32 kbps*/
#define IVAS_ISSUE_1188_EVS_CRASH /* Ittiam: Fix for issue 1188: Issue due to ASAN */
#define FIX_ISSUE_1155 /* Ittiam: Fix for issue 1155: Encoder crash for Stereo at 32kbps in PostShortTerm_ivas_enc_fx()*/
#define FIX_1010_OPT_DIV /* FhG: SVD complexity optimizations (non-be) */
@@ -134,9 +137,31 @@
#define FIX_1010_OPT_GIVENS_INV /* FhG: SVD complexity optimizations (non-be) */
#define FIX_1010_OPT_NORM_NOSAT /* FhG: SVD complexity optimizations (non-be) */
#define FIX_1010_OPT_SEC_SINGLE_RESCALE /* FhG: SVD complexity optimizations (non-be) */
+#define FIX_1072_SPEEDUP_matrixTransp2Mul_fx /* FhG: complexity optimization (non-be) */
+#define FIX_1072_REDUCE_DIVS /* FhG: complexity optimization (non-be) */
#define FIX_ISSUE_1230 /* Ittiam: Fix for issue 1230: Basop Enc audible differences and distortion @16kbps */
#define NONBE_1211_DTX_BR_SWITCHING /* VA: port float issue 1211: fix crash in MASA DTX bitrate switching */
#define FIX_1189_GSC_IVAS_OMASA /* VA: Fix for issue 1189: Bitstream desynchornization due to reading/writing of the GSC_IVAS_mode parameter */
+#define NONBE_1273_ISM_METADATA_COUNTER /* VA: BASOP issue 1265, FLP issue 1273: fix counter overflow in ISM metadata encoder */
+#define NONBE_FIX_GSC_BSTR /* VA: issue 1264 FLP (1189 BASOP): Fix bitstream synchronization between encoder and decoder in ACELP GSC in OMASA */
+#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF /* FhG: fix for issue 1101: complexity of spar dec upmixer */
+/* Note: each compile switch (FIX_1101_...) is independent from the other ones */
+#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_MADD_ADD_WEIGHTS /* FhG: Defines 1.0f-weight variables, uses Madd operation instead of L_add_sat */
+#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SPLIT_LOOPS /* FhG: Splits single loop with IF-statements into two low-complex loops */
+#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_HQ_CONSTANTS /* FhG: IMPROVE PRECISION: Uses 1/6 and 1/20 in full-precise Q31 constants instead of Q15 */
+#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_UNIQUE_SHL /* FhG: Uses unique shift amount in each loop iteration */
+#define FIX_11_1_IVAS_SPAR_DEC_UPMIXER_SF_RND_COEFFS /* FhG ivas_spar_com.c: Zeroes very small negative coeffs via L_shr_r (was L_shr) */
#define FIX_ISSUE_1237 /* VA: replacement of Copy_Scale_sig_16_32_DEPREC() that are doing 16 bits left shift by Copy_Scale_sig_16_32_no_sat() */
#define FIX_ISSUE_1237_KEEP_EVS_BE /* VA: Fix to keep EVS bitexactness to 26.444 */
+#define FIX_ISSUE_1214 /* Ittiam: Fix for issue 1214: Energy leakage in IGF tiles for MDCT-stereo @64kbps SWB*/
+#define FIX_881_HILBERT_FILTER /* VA: improve the precision of the Hilbert filter to remove 2kHz unwanted tone */
+#define FIX_ISSUE_1245 /* Ittiam: Fix for issue 1245: Basop Encoder: Audible noise for silent Stereo input DTX on @24.4 kbps, @32 kbps*/
+#define FIX_920_IGF_INIT_ERROR /* FhG: issue 920: fix bitrate mismatch in initial IGF config to avoid error message in same cases */
+#define FIX_MINOR_SVD_WMOPS_MR1010X /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */
+#define SVD_WMOPS_OPT /* Ittiam : SVD related optimizations */
+#define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */
+#define FIX_ISSUE_1279 /* VA: correction of wrong scaling update */
+#define FIX_ISSUE_1247
+#define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */
+#define FIX_1285_DECODER_CRASH
#endif
diff --git a/lib_com/prot.h b/lib_com/prot.h
index 9985ca978d25841413a23beec53528ddca5ac455..647a18bf127b7e4472d345941cb9f8963df33e74 100644
--- a/lib_com/prot.h
+++ b/lib_com/prot.h
@@ -7461,35 +7461,6 @@ int16_t BITS_ALLOC_config_acelp_IVAS(
const int16_t nb_subfr /* i : number of subframes */
);
-ivas_error config_acelp1_IVAS(
- const int16_t enc_dec, /* i : encoder/decoder flag */
- const int32_t total_brate, /* i : total bitrate */
- const int32_t core_brate_inp, /* i : core bitrate */
- const int16_t core, /* i : core */
- const int16_t extl, /* i : extension layer */
- const int32_t extl_brate, /* i : extension layer bitrate */
- const int16_t L_frame, /* i : frame length at internal Fs */
- const int16_t GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const int16_t signaling_bits, /* i : number of signaling bits */
- const int16_t coder_type, /* i : coder type */
- const int16_t tc_subfr, /* i : TC subfr ID */
- const int16_t tc_call, /* i : TC call number (0,1,2) */
- int16_t *nBits_es_Pred, /* o : number of bits for Es_pred Q */
- int16_t *unbits, /* o : number of unused bits */
- const int16_t element_mode, /* i : element mode */
- int16_t *uc_two_stage_flag, /* o : flag undicating two-stage UC */
- const int16_t tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel*/
- const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
- const int16_t idchan, /* i : channel id */
- const int16_t active_cnt, /* i : Active frame counter */
- const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */
-);
-
-/*! r: ACELP16k flag */
-
void FEC_clas_estim(
const float *syn,
@@ -8161,7 +8132,7 @@ void IGFEncApplyStereo(
);
-void IGFEncResetTCX10BitCounter(
+void IGFEncResetTCX10BitCounter_ivas_fx(
const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i : instance handle of IGF Encoder */
);
diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h
index 3c2b1395c80e2d1b8846683a919e75393825f98d..cf7072cf573e71726c44b82bb71c30efd502f311 100644
--- a/lib_com/prot_fx.h
+++ b/lib_com/prot_fx.h
@@ -434,6 +434,16 @@ void hq_generic_decoding_fx(
const Word16 hq_generic_exc_clas, /* i : bwe excitation class */
const Word16 *R );
+void hq_generic_decoding_ivas_fx(
+ const Word16 HQ_mode, /* i : HQ mode */
+ Word32 *coeff_out1_fx, /* i/o: BWE i & temporary buffer */
+ const Word16 *hq_generic_fenv_fx, /* i : SWB frequency envelopes */
+ Word32 *coeff_out_fx, /* o : SWB signal in MDCT domain */
+ const Word16 hq_generic_offset, /* i : frequency offset for representing hq generic*/
+ Word16 *prev_L_swb_norm, /* i/o: last normalize length */
+ const Word16 hq_generic_exc_clas, /* i : bwe excitation class */
+ const Word16 *R );
+
void save_old_syn_fx(
const Word16 L_frame, /* i : frame length */
const Word16 syn[], /* i : ACELP synthesis */
@@ -706,6 +716,19 @@ void hq_bwe_fx(
const Word16 num_env_bands,
const Word16 *R );
+void hq_bwe_ivas_fx(
+ const Word16 HQ_mode, /* i : HQ mode */
+ Word32 *coeff_out1, /* i/o: BWE i & temporary buffer */
+ const Word16 *hq_generic_fenv, /* i : SWB frequency envelopes */
+ Word32 *coeff_out, /* o : SWB signal in MDCT domain */
+ const Word16 hq_generic_offset, /* i : frequency offset for representing hq generic bwe*/
+ Word16 *prev_L_swb_norm, /*i/o : last normalize length */
+ const Word16 hq_generic_exc_clas, /* i : bwe excitation class */
+ const Word16 *sfm_end, /* i : End of bands */
+ const Word16 num_sfm,
+ const Word16 num_env_bands,
+ const Word16 *R );
+
void hq_wb_nf_bwe_fx(
const Word16 *coeff_fx, /* i : coded/noisefilled normalized spectrum */
const Word16 is_transient,
@@ -1084,6 +1107,12 @@ void lsp_weights_fx(
Word16 Order,
Word16 *Qout );
+void lsp_weights_ivas_fx(
+ Word16 lsp_nq_fx[],
+ Word16 w[],
+ Word16 Order,
+ Word16 *Qout );
+
void space_lsfs_fx(
Word16 *lsfs, /* i/o: Line spectral frequencies */
const Word16 order /* i : order of LP analysis */
@@ -1472,6 +1501,13 @@ void fft_rel_fx(
const Word16 n, /* i : vector length */
const Word16 m /* i : log2 of vector length */
);
+void fft_rel_16_32fx(
+ Word16 x[], /* i/o: input/output vector Qx */
+ Word16 *q_x, /* extra scaling added on speech buffer*/
+ Word16 i_subfr,
+ const Word16 n, /* i : vector length */
+ const Word16 m /* i : log2 of vector length */
+);
void fft_rel_fx32(
Word32 x[], /* i/o: i /output vector */
const Word16 n, /* i : vector length */
@@ -2391,6 +2427,20 @@ void syn_filt_fx(
const Word16 update_m /* i : update memory flag Q0 : 0 --> no memory update */
); /* 1 --> update of memory */
+void syn_filt_fx32(
+ const Word16 a_e, /* i : exp of LP coeffs Q0 */
+ const Word32 a[], /* i : LP filter coefficients Q12 */
+ const Word16 m, /* i : order of LP filter Q0 */
+ const Word32 x[], /* i : input signal Qx */
+ const Word16 x_e, /* i : input signal Qx */
+ Word32 y[], /* o : output signal Qx */
+ Word16 *y_e, /* o : output signal Qx */
+ const Word16 l, /* i : size of filtering Q0 */
+ Word32 mem[], /* i/o: initial filter states Qx */
+ Word16 *mem_e, /* i/o: initial filter states Qx */
+ const Word16 update_m /* i : update memory flag Q0 : 0 --> no memory update */
+);
+
void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], Word16 y[], const Word16 lg, Word16 mem[], const Word16 update, const Word16 m );
void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[], Word32 y[], const Word16 lg, Word32 mem[], const Word16 update, const Word16 m );
@@ -2866,6 +2916,11 @@ void Calc_rc0_h(
Word16 *rc0 /* o : 1st parcor */
);
+void Calc_rc0_h_ivas_enc_fx(
+ Word16 *h, /* i : impulse response of composed filter */
+ Word16 *rc0 /* o : 1st parcor */
+);
+
void PostShortTerm_fx(
Word16 *sig_in, /* i : i signal (pointer to current subframe */
Word16 *lpccoeff, /* i : LPC coefficients for current subframe */
@@ -3006,15 +3061,18 @@ void GenShapedSHBExcitation_ivas_enc_fx(
Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */
const Word32 bitrate,
const Word16 prev_bfi
-#if 1 // def ADD_IVAS_TBE_CODE
- , /* i : previous frame was concealed */
- const Word16 element_mode, /* i : element mode */
- const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */
- Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */
- Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */
- const Word32 extl_brate, /* i : extension layer bitarte */
- const Word16 MSFlag, /* i : Multi Source flag */
- Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */
+#if 1 // def ADD_IVAS_TBE_CODE
+ , /* i : previous frame was concealed */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */
+ Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */
+ Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */
+ Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */
+ Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */
+ const Word32 extl_brate, /* i : extension layer bitarte */
+ const Word16 MSFlag, /* i : Multi Source flag */
+ Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */
+ Word16 Q_EnvSHBres_4k,
Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */
Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */
Word16 *Env_error, /* o : error in SHB residual envelope modelling*/
@@ -3607,6 +3665,16 @@ Word16 ITF_Detect_fx( Word32 const pSpectrum[],
Word16 *curr_order,
Word16 Q );
+Word16 ITF_Detect_ivas_fx( Word32 const pSpectrum[],
+ const Word16 startLine,
+ const Word16 stopLine,
+ const Word16 maxOrder,
+ Word16 *A,
+ Word16 *Q_A,
+ Word16 *predictionGain,
+ Word16 *curr_order,
+ Word16 Q );
+
void ITF_Apply_fx( Word32 spectrum[],
Word16 startLine,
Word16 stopLine,
@@ -4742,17 +4810,20 @@ Word16 BITS_ALLOC_config_acelp(
const Word16 nb_subfr );
ivas_error config_acelp1(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signalling_bits, /* i : number of signalling bits */
- const Word16 coder_type, /* i : coder type */
+ const Word16 enc_dec, /* i : encoder/decoder flag */
+ const Word32 total_brate, /* i : total bitrate */
+ const Word32 core_brate_inp, /* i : core bitrate */
+ const Word16 core, /* i : core */
+ const Word16 extl, /* i : extension layer */
+ const Word32 extl_brate, /* i : extension layer bitrate */
+ const Word16 L_frame, /* i : frame length at internal Fs */
+ const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
+ ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
+ const Word16 signalling_bits, /* i : number of signalling bits */
+ const Word16 coder_type, /* i : coder type */
+#ifdef NONBE_FIX_GSC_BSTR
+ const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
+#endif
const Word16 tc_subfr, /* i : TC subfr ID */
const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
@@ -5729,16 +5800,14 @@ void tcx_ltp_post32(
// gs_inact_switching_fx.c
void Inac_swtch_ematch_fx(
- Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
- Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
- Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
- const Word16 coder_type, /* i : Coding mode */
- const Word16 L_frame, /* i : Frame lenght */
- const Word32 core_brate, /* i : Core bit rate */
- const Word16 Q_exc /* i : i and output format of exc2 */
- ,
- const Word16 bfi /* i : frame lost indicator */
- ,
+ Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
+ Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
+ Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
+ const Word16 coder_type, /* i : Coding mode */
+ const Word16 L_frame, /* i : Frame lenght */
+ const Word32 core_brate, /* i : Core bit rate */
+ const Word16 Q_exc, /* i : i and output format of exc2 */
+ const Word16 bfi, /* i : frame lost indicator */
const short last_core, /* i : Last core used */
const short last_codec_mode /* i : Last codec mode */
);
@@ -5748,15 +5817,17 @@ void Inac_switch_ematch_ivas_fx(
Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
const Word16 coder_type, /* i : Coding mode */
- const Word16 L_frame, /* i : Frame lenght */
- const Word32 core_brate, /* i : Core bit rate */
- const Word16 Q_exc /* i : input and output format of exc2 */
- ,
- const Word16 bfi /* i : frame lost indicator */
- ,
- const Word16 last_core, /* i : Last core used */
- const Word16 last_codec_mode /* i : Last codec mode */
- ,
+#ifdef NONBE_FIX_GSC_BSTR
+ const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
+#endif
+ const Word16 L_frame, /* i : Frame lenght */
+#ifndef NONBE_FIX_GSC_BSTR
+ const Word32 core_brate, /* i : Core bit rate */
+#endif
+ const Word16 Q_exc, /* i : input and output format of exc2 */
+ const Word16 bfi, /* i : frame lost indicator */
+ const Word16 last_core, /* i : Last core used */
+ const Word16 last_codec_mode, /* i : Last codec mode */
const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
const Word16 element_mode /* i : element mode */
);
@@ -6593,7 +6664,7 @@ void nb_post_filt_fx(
const Word16 tmp_noise, /* i : noise energy Q0 */
Word16 *Synth, /* i : 12k8 synthesis Qsyn */
const Word16 *Aq, /* i : LP filter coefficient Q12 */
- const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q6 */
+ const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q0 */
const Word16 coder_type, /* i : coder_type */
const Word16 BER_detect, /* i : BER detect flag */
const Word16 disable_hpf /* i : flag to diabled HPF */
@@ -10275,6 +10346,13 @@ Word32 root_a_over_b_fx(
Word16 Q_b,
Word16 *exp_out );
+Word32 root_a_over_b_ivas_fx(
+ Word32 a, /* Q(Q_a) */
+ Word16 Q_a,
+ Word32 b, /* Q(Q_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*/
@@ -10865,7 +10943,7 @@ Word16 IGFEncWriteBitstream_ivas_fx(
const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */
);
/*igf_scf_enc.c*/
-Word16 IGFSCFEncoderEncode(
+Word16 IGFSCFEncoderEncode_ivas_fx(
IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */
@@ -10948,17 +11026,20 @@ void lsf_syn_mem_backup_ivas_fx(
Word16 *pstreaklen );
ivas_error config_acelp1_IVAS(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signaling_bits, /* i : number of signaling bits */
- const Word16 coder_type, /* i : coder type */
+ const Word16 enc_dec, /* i : encoder/decoder flag */
+ const Word32 total_brate, /* i : total bitrate */
+ const Word32 core_brate_inp, /* i : core bitrate */
+ const Word16 core, /* i : core */
+ const Word16 extl, /* i : extension layer */
+ const Word32 extl_brate, /* i : extension layer bitrate */
+ const Word16 L_frame, /* i : frame length at internal Fs */
+ const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
+ ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
+ const Word16 signaling_bits, /* i : number of signaling bits */
+ const Word16 coder_type, /* i : coder type */
+#ifdef NONBE_FIX_GSC_BSTR
+ const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
+#endif
const Word16 tc_subfr, /* i : TC subfr ID */
const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
@@ -11025,7 +11106,10 @@ void calculate_hangover_attenuation_gain_ivas_fx(
void init_coder_ace_plus_ivas_fx(
Encoder_State *st, /* i : Encoder state */
const Word32 last_total_brate, /* i : last total bitrate */
- const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */
+#ifdef FIX_920_IGF_INIT_ERROR
+ const Word32 igf_brate, /* i : IGF configuration bitrate */
+#endif
+ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
void core_coder_reconfig_ivas_fx(
diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h
index 78d358be577431cdc976dc0c1702b2317a471d24..45a16dc1a5599c0458bbfca530a9fe68926a6f77 100644
--- a/lib_com/stat_com.h
+++ b/lib_com/stat_com.h
@@ -411,7 +411,7 @@ typedef struct
Word16 psize_norm[NPART]; /* Partition sizes, fractional variable Q15-psize_norm_exp*/
Word16 psize_inv[NPART]; /* Inverse of partition sizes Q15*/
// Word16 FFTscalingFactor; /* Squared ratio between core signal analysis FFT and noise estimator FFT */
- Word16 scalingFactor; // Q15
+ Word16 scalingFactor; // exp = -15
Word16 invScalingFactor; // Q15
Word16 nCLDFBpart; /* Number of CLDFB spectral partitions */
Word16 CLDFBpart[NPARTCLDFB]; /* CLDFB Partition upper boundaries (band indices starting from 0 above the core coder bands) */
diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c
index 303d453f11ff22140e1a69a05f56c7b321ba71a3..09f72b2300a32137f20e63d8063adfeb0b05c621 100644
--- a/lib_com/swb_bwe_com_fx.c
+++ b/lib_com/swb_bwe_com_fx.c
@@ -3021,6 +3021,562 @@ void hq_generic_decoding_fx(
return;
}
+void hq_generic_decoding_ivas_fx(
+ const Word16 HQ_mode, /* i : HQ mode : Q0 */
+ Word32 *coeff_out1_fx, /* i/o: BWE input & temporary buffer : Q12 */
+ const Word16 *hq_generic_fenv_fx, /* i : SWB frequency envelopes : Q1 */
+ Word32 *coeff_out_fx, /* o : SWB signal in MDCT domain : Q12 */
+ const Word16 hq_generic_offset, /* i : frequency offset for representing hq generci : Q0 */
+ Word16 *prev_L_swb_norm, /* i/o: last normalize length : Q0 */
+ const Word16 hq_generic_exc_clas, /* i : bwe excitation class " Q0 */
+ const Word16 *R )
+{
+ Word16 i, n_freq, n_band, L_swb_norm;
+ Word16 k;
+ Word16 nenv;
+ Word16 tenv;
+
+ Word16 exp, exp1, exp2, frac, tmp, tmp2, cs;
+ Word32 L_tmp, L_tmp1, L_tmp2, max_coeff_fx;
+ Word16 fenvL_fx, wfenv_fx, factor_fx;
+ Word32 *pit1_fx;
+ Word16 tmp1_fx, tmp2_fx, tmp3_fx, tmp4_fx;
+ Word32 energy_fx;
+
+ Word32 envelope_fx[L_FRAME16k];
+ Word32 mean_vector_fx[20];
+ Word16 rn_weight0_fx;
+ Word16 s;
+ Word16 blen, nband_lf, sfidx, efidx;
+ Word16 bwe_seed;
+ Word16 signum[L_FRAME16k];
+
+ nenv = sub( SWB_FENV, 2 );
+ if ( LE_16( hq_generic_offset, HQ_GENERIC_FOFFSET_24K4 ) )
+ {
+ nenv = SWB_FENV;
+ move16();
+ }
+
+ tenv = nenv;
+ move16();
+ if ( EQ_16( HQ_mode, HQ_GEN_FB ) )
+ {
+ tenv = add( nenv, DIM_FB );
+ }
+
+ max_coeff_fx = 0;
+ move16();
+ tmp = add( swb_bwe_subband[0], hq_generic_offset );
+ FOR( n_freq = add( HQ_GENERIC_ST_FREQ, hq_generic_offset ); n_freq < tmp; n_freq++ )
+ {
+ max_coeff_fx = L_max( max_coeff_fx, L_abs( coeff_out1_fx[n_freq] ) );
+ }
+ cs = norm_l( max_coeff_fx );
+
+ L_tmp = 0;
+ move16();
+ tmp2 = add( swb_bwe_subband[0], hq_generic_offset );
+ FOR( n_freq = add( HQ_GENERIC_ST_FREQ, hq_generic_offset ); n_freq < tmp2; n_freq++ )
+ {
+ tmp = extract_h( L_shl( coeff_out1_fx[n_freq], cs ) ); /*12 + cs - 16 */
+ L_tmp1 = L_mult0( tmp, tmp ); /*2*(cs-2) */
+ L_tmp = L_add( L_tmp, L_shr( L_tmp1, 5 ) ); /*2*(cs-2) - 5 */
+ }
+ cs = sub( shl( cs, 1 ), 9 );
+ fenvL_fx = 0;
+ move16();
+ IF( L_tmp != 0 )
+ {
+ exp = norm_l( L_tmp );
+#ifdef EVS_FUNC_MODIFIED
+ frac = round_fx_sat( L_shl( L_tmp, exp ) ); /*cs+exp-16 */
+#else
+ frac = round_fx( L_shl( L_tmp, exp ) ); /*cs+exp-16 */
+#endif
+ tmp = div_s( 16384, frac ); /*15 + 14 - (cs+exp-16) */
+ exp = sub( add( cs, exp ), 30 );
+ L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /*Q31 - exp */
+ fenvL_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /*Q1 */
+ }
+
+ calc_normal_length_fx_32( HQ_CORE, coeff_out1_fx, HQ_GEN_SWB, -1, &L_swb_norm, prev_L_swb_norm );
+
+ calc_norm_envelop_lf_fx( coeff_out1_fx, envelope_fx, &L_swb_norm, HQ_mode, hq_generic_offset, &sfidx, &efidx );
+
+ blen = 16;
+ move16();
+
+ IF( EQ_16( hq_generic_exc_clas, HQ_GENERIC_EXC0 ) )
+ {
+ rn_weight0_fx = 819;
+ move16(); /* 0.8 Q10 */
+ }
+ ELSE IF( EQ_16( hq_generic_exc_clas, HQ_GENERIC_EXC1 ) )
+ {
+ rn_weight0_fx = 51;
+ move16(); /* 0.05 Q10*/
+ }
+ ELSE
+ {
+ rn_weight0_fx = 205;
+ move16(); /* 0.02 Q10 */
+ }
+
+ tmp = sub( efidx, sfidx );
+ IF( tmp == 0 )
+ {
+ nband_lf = 0;
+ move16();
+ }
+ ELSE
+ {
+ exp = norm_s( tmp );
+ nband_lf = shl( tmp, sub( exp, 1 ) );
+ exp1 = norm_s( blen );
+ tmp = shl( blen, exp1 );
+ nband_lf = shr( div_s( nband_lf, tmp ), add( sub( 14, exp1 ), exp ) ); /* 15 + exp-1 - exp1, Q0*/
+ }
+
+ FOR( n_freq = sfidx; n_freq < efidx; n_freq++ )
+ {
+ IF( coeff_out1_fx[n_freq] < 0 )
+ {
+ signum[n_freq] = -1;
+ move16();
+ coeff_out1_fx[n_freq] = L_negate( coeff_out1_fx[n_freq] );
+ move32();
+ }
+ ELSE
+ {
+ signum[n_freq] = 1;
+ move16();
+ }
+ }
+
+ /* applying whitening */
+ FOR( n_freq = sfidx; n_freq < efidx; n_freq++ )
+ {
+ exp = norm_l( coeff_out1_fx[n_freq] ) - 1;
+ exp1 = norm_l( envelope_fx[n_freq] );
+
+ L_tmp = L_shl( coeff_out1_fx[n_freq], exp );
+ L_tmp1 = L_shl( envelope_fx[n_freq], exp1 );
+
+ logic16();
+ coeff_out1_fx[n_freq] = Div_32( L_tmp, extract_h( L_tmp1 ), extract_l( L_shr( L_tmp1, 1 ) ) & 0x00007fff );
+ move32(); /*31 + exp1 - exp2*/
+
+ exp = add( 31, sub( exp, exp1 ) );
+ coeff_out1_fx[n_freq] = L_shl( coeff_out1_fx[n_freq], sub( 20, exp ) );
+ move32(); /*Q12->Q20*/
+ }
+
+ /* mean vector generation for controlling dynamic range */
+ FOR( k = 0; k < nband_lf; ++k )
+ {
+ energy_fx = 1;
+ move16();
+
+ tmp = add( i_mult2( add( k, 1 ), blen ), sfidx );
+ FOR( i = add( i_mult2( k, blen ), sfidx ); i < tmp; ++i )
+ {
+ energy_fx = L_add( energy_fx, coeff_out1_fx[i] );
+ }
+ exp = sub( norm_l( energy_fx ), 1 );
+ L_tmp = L_shl( energy_fx, exp );
+ exp1 = norm_l( L_and( blen, 0x00007fff ) );
+ L_tmp1 = L_shl( blen, exp1 );
+ logic16();
+ mean_vector_fx[k] = Div_32( L_tmp, extract_h( L_tmp1 ), extract_l( L_shr( L_tmp1, 1 ) ) & 0x00007fff );
+ move32(); /*31 + 20 + exp1 - exp2*/
+ exp = add( 51, sub( exp, exp1 ) );
+ mean_vector_fx[k] = L_shl( mean_vector_fx[k], sub( 20, exp ) );
+ move32(); /*Q12->Q20*/
+ }
+
+ /* dynamics control */
+ FOR( k = 0; k < nband_lf; ++k )
+ {
+ tmp = add( i_mult2( add( k, 1 ), blen ), sfidx );
+ FOR( i = add( i_mult2( k, blen ), sfidx ); i < tmp; ++i )
+ {
+ L_tmp = L_sub( coeff_out1_fx[i], mean_vector_fx[k] );
+ exp = norm_l( L_tmp );
+ L_tmp = L_shl( L_tmp, exp ); /* exp+12*/
+ exp1 = norm_l( rn_weight0_fx );
+ L_tmp1 = L_shl( rn_weight0_fx, exp1 ); /* exp1+10*/
+ L_tmp = L_mult( extract_h( L_tmp ), extract_h( L_tmp1 ) );
+ L_tmp = L_shr( L_tmp, add( exp, sub( exp1, 21 ) ) ); /* Q20*/
+ coeff_out1_fx[i] = L_sub( coeff_out1_fx[i], L_tmp );
+ move32();
+ }
+ }
+
+ IF( EQ_16( hq_generic_exc_clas, HQ_GENERIC_EXC0 ) )
+ {
+ bwe_seed = add( add( shl( R[0], 3 ), shl( R[1], 2 ) ), add( shl( R[2], 1 ), R[3] ) );
+
+ FOR( n_freq = sfidx; n_freq < efidx; n_freq++ )
+ {
+ IF( signum[n_freq] < 0 )
+ {
+ coeff_out1_fx[n_freq] = L_negate( coeff_out1_fx[n_freq] );
+ move32();
+ }
+
+ IF( Random( &bwe_seed ) < 0 )
+ {
+ coeff_out1_fx[n_freq] = L_negate( coeff_out1_fx[n_freq] );
+ move32();
+ }
+ }
+ }
+ ELSE
+ {
+ FOR( n_freq = sfidx; n_freq < efidx; n_freq++ )
+ {
+ IF( signum[n_freq] < 0 )
+ {
+ coeff_out1_fx[n_freq] = L_negate( coeff_out1_fx[n_freq] );
+ move32();
+ }
+ }
+ }
+
+ /* normalizing modified low frequency spectrum */
+ FOR( k = 0; k < nband_lf; ++k )
+ {
+ energy_fx = 1;
+ move16();
+ tmp = add( i_mult2( add( k, 1 ), blen ), sfidx );
+ FOR( i = add( ( i_mult2( k, blen ) ), sfidx ); i < tmp; ++i )
+ {
+ exp = norm_l( coeff_out1_fx[i] );
+ L_tmp1 = L_shl( coeff_out1_fx[i], exp ); /* exp + 12*/
+
+ L_tmp = Mult_32_32( L_tmp1, L_tmp1 );
+ L_tmp = L_shr( L_tmp, sub( i_mult2( 2, exp ), 11 ) ); /*Q20 */
+ energy_fx = L_add( energy_fx, L_tmp );
+ }
+
+ exp = norm_l( energy_fx );
+ L_tmp = L_shl( energy_fx, sub( exp, 1 ) );
+ exp1 = norm_s( blen );
+ L_tmp1 = L_shl( (Word32) blen, add( exp1, 16 ) );
+
+ L_tmp = Div_32( L_tmp, extract_h( L_tmp1 ), extract_l( L_shr( L_tmp1, 1 ) ) & 0x00007fff );
+ exp = sub( add( 34, exp ), exp1 );
+ L_tmp = L_shr( L_tmp, sub( exp, 31 ) );
+ exp = 31;
+ move16();
+
+ exp = sub( 31, exp );
+ IF( exp & 0x1 )
+ {
+ L_tmp = L_shr( L_tmp, 1 );
+ exp = add( exp, 1 );
+ }
+ L_tmp = Sqrt_l( L_tmp, &exp1 );
+ exp = add( 31, sub( shr( exp1, 1 ), shr( exp, 1 ) ) );
+ energy_fx = L_shl( L_tmp, sub( 31, exp ) ); /*Q31*/
+
+ tmp = add( i_mult2( add( k, 1 ), blen ), sfidx );
+ FOR( i = add( ( i_mult2( k, blen ) ), sfidx ); i < tmp; ++i )
+ {
+ IF( NE_32( L_abs( coeff_out1_fx[i] ), coeff_out1_fx[i] ) )
+ {
+ s = -1;
+ move16();
+ coeff_out1_fx[i] = L_abs( coeff_out1_fx[i] );
+ move32();
+ }
+ ELSE
+ {
+ s = 0;
+ move16();
+ }
+ exp = norm_l( coeff_out1_fx[i] );
+ L_tmp = L_shl( coeff_out1_fx[i], sub( exp, 1 ) );
+ exp1 = norm_l( energy_fx );
+ L_tmp1 = L_shl( (Word32) energy_fx, exp1 );
+ logic16();
+ L_tmp = Div_32( L_tmp, extract_h( L_tmp1 ), extract_l( L_shr( L_tmp1, 1 ) ) & 0x00007fff );
+ exp = add( sub( 19, exp1 ), exp );
+ coeff_out1_fx[i] = L_shl( L_tmp, add( sub( 12, exp ), 15 ) );
+ move32(); /* Q12 -> Q27 */
+ IF( s )
+ {
+ coeff_out1_fx[i] = L_negate( coeff_out1_fx[i] );
+ move32();
+ }
+ }
+ }
+
+ Copy32( &coeff_out1_fx[HQ_GENERIC_OFFSET], &coeff_out_fx[HQ_GENERIC_HIGH0 + hq_generic_offset], HQ_GENERIC_LEN0 );
+ Copy32( &coeff_out1_fx[HQ_GENERIC_OFFSET], &coeff_out_fx[HQ_GENERIC_HIGH1 + hq_generic_offset], HQ_GENERIC_LEN0 );
+
+ IF( LE_16( hq_generic_offset, HQ_GENERIC_FOFFSET_24K4 ) )
+ {
+ Copy32( &coeff_out1_fx[HQ_GENERIC_LOW0], &coeff_out_fx[HQ_GENERIC_HIGH2 + hq_generic_offset], HQ_GENERIC_END_FREQ - HQ_GENERIC_HIGH2 );
+ }
+
+ IF( EQ_16( HQ_mode, HQ_GEN_FB ) )
+ {
+ IF( LE_16( hq_generic_offset, HQ_GENERIC_FOFFSET_24K4 ) )
+ {
+ Copy32( &coeff_out1_fx[HQ_GENERIC_LOW0 + HQ_GENERIC_END_FREQ - HQ_GENERIC_HIGH2], &coeff_out_fx[fb_bwe_subband[0]], 160 );
+ }
+ ELSE
+ {
+ Copy32( &coeff_out1_fx[HQ_GENERIC_OFFSET + HQ_GENERIC_LEN0], &coeff_out_fx[fb_bwe_subband[0]], 160 );
+ }
+ }
+
+
+ L_tmp1 = L_deposit_l( 0 );
+ L_tmp2 = L_deposit_l( 0 );
+ FOR( i = 0; i < 5; ++i )
+ {
+ L_tmp1 = L_add( L_tmp1, L_shr( L_abs( coeff_out_fx[HQ_GENERIC_HIGH1 + hq_generic_offset + i] ), 3 ) ); // adding guard bits
+ L_tmp2 = L_add( L_tmp2, L_shr( L_abs( coeff_out_fx[HQ_GENERIC_HIGH1 - 2 + hq_generic_offset - i] ), 3 ) ); // adding guard bits
+ }
+
+ pit1_fx = &coeff_out_fx[HQ_GENERIC_HIGH1 + hq_generic_offset];
+ L_tmp1 = L_max( L_tmp1, 1 );
+ L_tmp2 = L_max( L_tmp2, 1 );
+ exp1 = norm_l( L_tmp1 );
+ exp2 = sub( norm_l( L_tmp2 ), 1 );
+ tmp1_fx = extract_h( L_shl( L_tmp1, exp1 ) );
+ tmp2_fx = extract_h( L_shl( L_tmp2, exp2 ) );
+ tmp3_fx = div_s( tmp2_fx, tmp1_fx ); /*15 + exp2 + 15 - (exp1 + 15) */
+ tmp3_fx = shr( tmp3_fx, add( 5, sub( exp2, exp1 ) ) ); /*10 */
+
+ if ( LT_16( tmp3_fx, 307 /*0.3 in Q10 */ ) )
+ {
+ tmp3_fx = 307 /*0.3 in Q10 */;
+ move16();
+ }
+ FOR( ; tmp3_fx < 1024; tmp3_fx += 102 )
+ {
+ *pit1_fx = Mult_32_16( *pit1_fx, shl( tmp3_fx, 5 ) );
+ move32(); /*15 + 5 + 10 -15 */
+ pit1_fx++;
+ }
+
+ pit1_fx = &coeff_out_fx[HQ_GENERIC_HIGH1 - 1 + hq_generic_offset];
+
+ exp1 = sub( norm_l( L_tmp1 ), 1 );
+ exp2 = norm_l( L_tmp2 );
+ tmp1_fx = extract_h( L_shl( L_tmp1, exp1 ) );
+ tmp2_fx = extract_h( L_shl( L_tmp2, exp2 ) );
+ tmp3_fx = div_s( tmp1_fx, tmp2_fx ); /*15 + exp2 + 15 - (exp1 + 15) */
+ tmp3_fx = shr( tmp3_fx, add( 5, sub( exp1, exp2 ) ) ); /*10 */
+
+ IF( GT_16( tmp3_fx, 5120 ) )
+ {
+ FOR( tmp3_fx = 5120; tmp3_fx > 1024; tmp3_fx -= 512 )
+ {
+ /* Adding saturation suggested as fix for issue #957 */
+ L_tmp1 = L_shl_sat( Mult_32_16( *pit1_fx, tmp3_fx ), 5 ); /*15 + 5 + 10 -15 */
+ *pit1_fx-- = L_tmp1;
+ move32();
+ }
+ }
+
+ IF( LE_16( hq_generic_offset, HQ_GENERIC_FOFFSET_24K4 ) )
+ {
+ L_tmp1 = L_add( L_abs( coeff_out_fx[HQ_GENERIC_HIGH2 + hq_generic_offset] ), L_abs( coeff_out_fx[HQ_GENERIC_HIGH2 + 1 + hq_generic_offset] ) );
+ L_tmp2 = L_add( L_abs( coeff_out_fx[HQ_GENERIC_HIGH2 - 4 + hq_generic_offset] ), L_add( L_abs( coeff_out_fx[HQ_GENERIC_HIGH2 - 3 + hq_generic_offset] ),
+ L_add( L_abs( coeff_out_fx[HQ_GENERIC_HIGH2 - 2 + hq_generic_offset] ), L_abs( coeff_out_fx[HQ_GENERIC_HIGH2 - 1 + hq_generic_offset] ) ) ) );
+
+ pit1_fx = &coeff_out_fx[HQ_GENERIC_HIGH2 + hq_generic_offset];
+
+ L_tmp1 = L_max( L_tmp1, 1 );
+ L_tmp2 = L_max( L_tmp2, 1 );
+ exp1 = norm_l( L_tmp1 );
+ exp2 = sub( norm_l( L_tmp2 ), 1 );
+ tmp1_fx = extract_h( L_shl( L_tmp1, exp1 ) );
+ tmp2_fx = extract_h( L_shl( L_tmp2, exp2 ) );
+ tmp3_fx = div_s( tmp2_fx, tmp1_fx ); /*15 + exp2 + 15 - (exp1 + 15) */
+ tmp3_fx = shr_sat( tmp3_fx, add( 5, sub( exp2, exp1 ) ) ); /*10 */
+ if ( LT_16( tmp3_fx, 307 /* 0.3 in Q10*/ ) )
+ {
+ tmp3_fx = 307; /* 0.3 in Q10*/
+ move16();
+ }
+ FOR( ; tmp3_fx < 1024; tmp3_fx += 102 )
+ {
+ L_tmp = L_shl( Mult_32_16( *pit1_fx, tmp3_fx ), 5 ); /*15 + 5 + 10 -15 */
+ *pit1_fx++ = L_tmp;
+ move32();
+ }
+
+ pit1_fx = &coeff_out_fx[HQ_GENERIC_HIGH2 - 1 + hq_generic_offset];
+
+ exp1 = sub( norm_l( L_tmp1 ), 1 );
+ exp2 = norm_l( L_tmp2 );
+ tmp1_fx = extract_h( L_shl( L_tmp1, exp1 ) );
+ tmp2_fx = extract_h( L_shl( L_tmp2, exp2 ) );
+ tmp3_fx = div_s( tmp1_fx, tmp2_fx ); /*15 + exp2 + 15 - (exp1 + 15) */
+ tmp3_fx = shr( tmp3_fx, add( 5, sub( exp1, exp2 ) ) ); /*10 */
+ tmp3_fx = shr( tmp3_fx, 1 );
+ tmp4_fx = mult_r( tmp3_fx, 1638 /* 0.05 in Q15 */ );
+ WHILE( tmp3_fx > 1024 /* 1 in Q10*/ )
+ {
+#ifdef EVS_FUNC_MODIFIED
+ L_tmp1 = L_shl( Mult_32_16( *pit1_fx, tmp3_fx ), 5 ); /*15 + 5 + 10 -15 */
+#else
+ L_tmp1 = Mult_32_16( L_shl( *pit1_fx, 5 ), tmp3_fx ); /*15 + 5 + 10 -15 */
+#endif
+ *pit1_fx-- = L_tmp1;
+ move32();
+ tmp3_fx = sub( tmp3_fx, tmp4_fx );
+ }
+ }
+
+
+ wfenv_fx = hq_generic_fenv_fx[0];
+ move16(); /*1 */
+ i = 0;
+ move16();
+ tmp2 = add( add( swb_bwe_subband[0], hq_generic_offset ), 8 );
+ FOR( n_freq = add( swb_bwe_subband[0], hq_generic_offset ); n_freq < tmp2; n_freq++ )
+ {
+ factor_fx = shl( i, 12 ); /*15 */
+ L_tmp1 = L_mult( sub( 32767, factor_fx ), fenvL_fx ); /*17 */
+ L_tmp2 = L_mult( factor_fx, wfenv_fx ); /*17 */
+ L_tmp1 = L_add( L_tmp1, L_tmp2 ); /*17 */
+
+ cs = norm_l( L_tmp1 );
+ tmp = extract_h( L_shl( L_tmp1, cs ) ); /*17 + cs - 16 */
+ L_tmp = Mult_32_16( coeff_out_fx[n_freq], tmp ); /*12 + 15 + 17 + cs - 16 - 15 */
+ coeff_out_fx[n_freq] = L_shr( L_tmp, add( 1, cs ) );
+ move32(); /*12 */
+ i++;
+ move16();
+ }
+
+ k = sub( nenv, 2 );
+ FOR( n_band = 0; n_band < k; n_band++ )
+ {
+ wfenv_fx = hq_generic_fenv_fx[n_band + 1];
+ move16(); /*1 */
+
+ tmp2 = swb_bwe_sm_subband[n_band + 1] + hq_generic_offset;
+ FOR( i = 0; n_freq < tmp2; i++ )
+ {
+ L_tmp1 = L_mult( sub( wfenv_fx, hq_generic_fenv_fx[n_band] ), smooth_factor_fx[n_band] ); /*17 */
+ L_tmp1 = Mult_32_16( L_tmp1, shl( i, 10 ) ); /*17 + 10 - 15 */
+ L_tmp1 = L_add( L_tmp1, L_shl( hq_generic_fenv_fx[n_band], 11 ) ); /*12 */
+
+ cs = norm_l( L_tmp1 );
+ tmp = extract_h( L_shl( L_tmp1, cs ) ); /*12 + cs - 16 */
+ L_tmp = Mult_32_16( coeff_out_fx[n_freq], tmp ); /*12 + 15 + 12 + cs - 16 - 15 */
+ coeff_out_fx[n_freq] = L_shl( L_tmp, sub( 4, cs ) );
+ move32(); /*12 */
+ n_freq++;
+ }
+ }
+
+ wfenv_fx = hq_generic_fenv_fx[nenv - 1];
+ move16(); /*1 */
+ tmp2 = add( swb_bwe_sm_subband[nenv - 1], hq_generic_offset );
+ FOR( i = 0; n_freq < tmp2; i++ )
+ {
+ L_tmp1 = L_mult( sub( wfenv_fx, hq_generic_fenv_fx[nenv - 2] ), smooth_factor_fx[nenv - 2] ); /*17 */
+ L_tmp1 = Mult_32_16( L_tmp1, shl( i, 10 ) ); /*17 + 10 - 15 */
+ L_tmp1 = L_add( L_tmp1, L_shl( hq_generic_fenv_fx[nenv - 2], 11 ) ); /*12 */
+
+ cs = norm_l( L_tmp1 );
+ tmp = extract_h( L_shl( L_tmp1, cs ) ); /*12 + cs - 16 */
+ L_tmp = Mult_32_16( coeff_out_fx[n_freq], tmp ); /*12 + 15 + 12 + cs - 16 - 15 */
+ coeff_out_fx[n_freq] = L_shl( L_tmp, sub( 4, cs ) );
+ move32(); /*12 */
+ n_freq++;
+ }
+
+ IF( EQ_16( HQ_mode, HQ_GEN_SWB ) )
+ {
+ FOR( n_band = sub( nenv, 1 ); n_band < nenv; ++n_band )
+ {
+ wfenv_fx = hq_generic_fenv_fx[n_band];
+ move16(); /*1 */
+ tmp2 = add( swb_bwe_subband[n_band + 1], hq_generic_offset );
+ FOR( ; n_freq < tmp2; n_freq++ )
+ {
+ L_tmp = Mult_32_16( coeff_out_fx[n_freq], wfenv_fx ); /*15 + 12 + 1 - 15 */
+ coeff_out_fx[n_freq] = L_shr( L_tmp, 1 );
+ move32(); /*12 */
+ }
+ }
+ }
+ ELSE
+ {
+ test();
+ IF( GT_16( sub( hq_generic_fenv_fx[nenv - 1], hq_generic_fenv_fx[nenv] ), 30 ) || LT_16( hq_generic_fenv_fx[nenv], 10 ) )
+ {
+ wfenv_fx = hq_generic_fenv_fx[nenv - 1];
+ move16(); /*1 */
+ FOR( i = 0; n_freq < fb_bwe_subband[0]; i++ )
+ {
+ L_tmp = Mult_32_16( coeff_out_fx[n_freq], wfenv_fx ); /*15 + 12 + 1 - 15 */
+ coeff_out_fx[n_freq] = L_shr( L_tmp, 1 );
+ move32(); /*12 */
+ n_freq++;
+ }
+
+ FOR( n_band = 0; n_band < DIM_FB; n_band++ )
+ {
+ wfenv_fx = hq_generic_fenv_fx[n_band + nenv];
+ move16(); /*1 */
+ tmp2 = fb_bwe_subband[n_band + 1];
+ FOR( i = 0; n_freq < tmp2; i++ )
+ {
+ L_tmp = Mult_32_16( coeff_out_fx[n_freq], wfenv_fx ); /*15 + 12 + 1 - 15 */
+ coeff_out_fx[n_freq] = L_shr( L_tmp, 1 );
+ move32(); /*12 */
+ n_freq++;
+ }
+ }
+ }
+ ELSE
+ {
+ FOR( n_band = 0; n_band < DIM_FB; n_band++ )
+ {
+ wfenv_fx = hq_generic_fenv_fx[n_band + nenv - 1];
+ move16(); /*1 */
+
+ FOR( i = 0; n_freq < fb_bwe_sm_subband[n_band]; i++ )
+ {
+ L_tmp1 = L_mult( sub( wfenv_fx, hq_generic_fenv_fx[n_band + nenv] ), fb_smooth_factor_fx[n_band] ); /*17 */
+ L_tmp1 = Mult_32_16( L_tmp1, shl( i, 9 ) ); /*17 + 9 - 15 */
+ L_tmp1 = L_add( L_tmp1, L_shl( hq_generic_fenv_fx[n_band + nenv], 10 ) ); /*11 */
+
+ cs = norm_l( L_tmp1 );
+ tmp = extract_h( L_shl( L_tmp1, cs ) ); /*11 + cs - 16 */
+ L_tmp = Mult_32_16( coeff_out_fx[n_freq], tmp ); /*12 + 15 + 11 + cs - 16 - 15 */
+ coeff_out_fx[n_freq] = L_shl( L_tmp, sub( 5, cs ) );
+ move32(); /*12 */
+ n_freq = add( n_freq, 1 );
+ }
+ }
+
+ wfenv_fx = hq_generic_fenv_fx[tenv - 1];
+ move16(); /*1 */
+
+ FOR( ; n_freq < fb_bwe_subband[DIM_FB]; n_freq++ )
+ {
+ L_tmp = Mult_32_16( coeff_out_fx[n_freq], wfenv_fx ); /*15 + 12 + 1 - 15 */
+ coeff_out_fx[n_freq] = L_shr( L_tmp, 1 );
+ move32(); /*12 */
+ }
+ }
+ }
+
+ return;
+}
+
/*-------------------------------------------------------------------*
* save_old_syn()
diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c
index 9b20512a24e17ca91b7c39668a07e128894cf01f..105c4db1521a14414ccd68f214f4c2f619475b69 100644
--- a/lib_com/swb_tbe_com.c
+++ b/lib_com/swb_tbe_com.c
@@ -69,7 +69,45 @@ void GenSHBSynth_fx_32(
Word32 speech_buf_32k[L_FRAME32k];
Word16 i;
+#ifdef FIX_881_HILBERT_FILTER
+ Word16 shift = 0;
+ Word32 maxm32, input_synspeech_temp[L_FRAME16k];
+ move16();
+
+ /* find the maximum value and derive the shift to improve precision of the Hilber filter */
+ maxm32 = L_deposit_l( 0 );
+ FOR( i = 0; i < L_FRAME16k; i++ )
+ {
+ maxm32 = L_max( maxm32, L_abs( input_synspeech[i] ) );
+ }
+
+ FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
+ {
+ maxm32 = L_max( maxm32, L_abs( state_lsyn_filt_shb_local[i] ) );
+ }
+
+ FOR( i = 0; i < HILBERT_MEM_SIZE; i++ )
+ {
+ maxm32 = L_max( maxm32, L_abs( Hilbert_Mem[i] ) );
+ }
+
+ IF( maxm32 != 0 )
+ {
+ shift = sub( norm_l( maxm32 ), 3 );
+
+ Copy_Scale_sig32( input_synspeech, input_synspeech_temp, L_FRAME16k, shift );
+ Scale_sig32( state_lsyn_filt_shb_local, 2 * ALLPASSSECTIONS_STEEP, shift );
+ Scale_sig32( Hilbert_Mem, HILBERT_MEM_SIZE, shift );
+ }
+ ELSE
+ {
+ Copy32( input_synspeech, input_synspeech_temp, L_FRAME16k );
+ }
+
+ Interpolate_allpass_steep_32( input_synspeech_temp, state_lsyn_filt_shb_local, L_FRAME16k, speech_buf_32k );
+#else
Interpolate_allpass_steep_32( input_synspeech, state_lsyn_filt_shb_local, L_FRAME16k, speech_buf_32k );
+#endif
IF( EQ_16( L_frame, L_FRAME ) )
{
@@ -92,6 +130,15 @@ void GenSHBSynth_fx_32(
}
}
+#ifdef FIX_881_HILBERT_FILTER
+ IF( maxm32 != 0 )
+ {
+ Scale_sig32( shb_syn_speech_32k, L_FRAME32k, negate( shift ) );
+ Scale_sig32( state_lsyn_filt_shb_local, 2 * ALLPASSSECTIONS_STEEP, negate( shift ) );
+ Scale_sig32( Hilbert_Mem, HILBERT_MEM_SIZE, negate( shift ) );
+ }
+#endif
+
return;
}
void ScaleShapedSHB_32(
diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c
index aeca8dff14131d58c6155fd7045c276a833a4110..92271c1f1f56d2dd27e163c2190496e0988c4efa 100644
--- a/lib_com/swb_tbe_com_fx.c
+++ b/lib_com/swb_tbe_com_fx.c
@@ -810,6 +810,65 @@ void Calc_rc0_h(
}
}
+void Calc_rc0_h_ivas_enc_fx(
+ Word16 *h, /* i : impulse response of composed filter */
+ Word16 *rc0 /* o : 1st parcor */
+)
+{
+ Word32 L_acc;
+ Word16 *ptrs;
+ Word16 acf0, acf1;
+ Word16 temp, sh_acf, tmp2;
+ Word16 i;
+
+ /* computation of the autocorrelation function acf */
+ L_acc = L_mult( h[0], h[0] );
+ FOR( i = 1; i < LONG_H_ST; i++ )
+ {
+ tmp2 = shr( h[i], 2 );
+ L_acc = L_mac( L_acc, tmp2, tmp2 );
+ }
+ sh_acf = norm_l( L_acc );
+ L_acc = L_shl( L_acc, sh_acf );
+ acf0 = extract_h( L_acc );
+
+ ptrs = h;
+
+ temp = *ptrs++;
+ move16();
+ L_acc = L_mult( temp, *ptrs );
+ FOR( i = 1; i < LONG_H_ST - 1; i++ )
+ {
+ temp = shr( *ptrs++, 2 );
+ move16();
+ L_acc = L_mac( L_acc, temp, shr( *ptrs, 2 ) );
+ }
+ L_acc = L_shl( L_acc, sh_acf );
+ acf1 = extract_h( L_acc );
+
+ /* Compute 1st parcor */
+ IF( acf0 == 0 )
+ {
+ *rc0 = 0;
+ move16();
+ return;
+ }
+
+ IF( LT_16( acf0, abs_s( acf1 ) ) )
+ {
+ *rc0 = 0;
+ move16();
+ return;
+ }
+ *rc0 = div_s( abs_s( acf1 ), acf0 );
+ move16();
+ IF( acf1 > 0 )
+ {
+ *rc0 = negate( *rc0 );
+ move16();
+ }
+}
+
static void Calc_st_filt_tbe(
Word16 *apond2, /* i : coefficients of numerator */
Word16 *apond1, /* i : coefficients of denominator */
@@ -868,7 +927,7 @@ static void Calc_st_filt_tbe_ivas_enc_fx(
/* compute i.r. of composed filter apond2 / apond1 */
syn_filt_fx( temp, apond1, LPC_SHB_ORDER, apond2, h, LONG_H_ST, mem_zero, 0 );
/* compute 1st parcor */
- Calc_rc0_h( h, parcor0 );
+ Calc_rc0_h_ivas_enc_fx( h, parcor0 );
/* compute g0 */
L_g0 = L_mult0( 1, abs_s( h[0] ) );
@@ -2842,17 +2901,20 @@ void GenShapedSHBExcitation_ivas_enc_fx(
Word16 *Q_bwe_exc,
Word16 *Q_bwe_exc_fb,
const Word16 Q_shb,
- Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */
- Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */
- const Word32 bitrate, /* i : bitrate */
- const Word16 prev_bfi, /* i : previous frame was concealed */
- const Word16 element_mode, /* i : element mode */
- const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */
- Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */
- Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */
- const Word32 extl_brate, /* i : extension layer bitarte */
- const Word16 MSFlag, /* i : Multi Source flag */
- Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */
+ Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */
+ Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */
+ const Word32 bitrate, /* i : bitrate */
+ const Word16 prev_bfi, /* i : previous frame was concealed */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */
+ Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */
+ Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */
+ Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */
+ Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */
+ const Word32 extl_brate, /* i : extension layer bitarte */
+ const Word16 MSFlag, /* i : Multi Source flag */
+ Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */
+ Word16 Q_EnvSHBres_4k,
Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */
Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */
Word16 *Env_error, /* o : error in SHB residual envelope modelling Q0 */
@@ -2872,6 +2934,7 @@ void GenShapedSHBExcitation_ivas_enc_fx(
Word16 excTmp2[L_FRAME16k];
Word16 *White_exc16k;
+ Word16 Q_White_exc16k;
Word16 excNoisyEnv[L_FRAME16k];
Word16 csfilt_num2[1] = { 6554 }; /*0.2 in Q15 */
move16();
@@ -2899,7 +2962,6 @@ void GenShapedSHBExcitation_ivas_enc_fx(
Word16 White_exc16k_FB_temp[L_FRAME16k];
Word32 White_exc16k_32[L_FRAME16k];
Word16 White_exc16k_tmp[L_FRAME16k];
- Word16 Q_temp;
Word16 prev_Q_bwe_exc_fb;
Word16 chk1, chk2;
chk1 = 0;
@@ -3089,7 +3151,6 @@ void GenShapedSHBExcitation_ivas_enc_fx(
}
White_exc16k = exc16k;
- move16();
Word16 Q_excTmp2 = add( getScaleFactor16( excTmp2, L_FRAME16k ), *Q_bwe_exc );
IF( *mem_csfilt )
{
@@ -3168,12 +3229,12 @@ void GenShapedSHBExcitation_ivas_enc_fx(
/* generate gaussian (white) excitation */
FOR( k = 0; k < L_FRAME16k; k++ )
{
- White_exc16k[k] = own_random( &bwe_seed[0] );
+ White_exc16k[k] = own_random( &bwe_seed[0] ); // Q0
move16();
}
/* normalize the amplitude of the gaussian excitation to that of the LB exc. */
- Word32 pow22_inv = POW_EXC16k_WHTND_FX_INV_SQRT;
+ Word32 pow22_inv = POW_EXC16k_WHTND_FX_INV_SQRT; // Q31
move32();
move32();
pow22 = POW_EXC16k_WHTND_FX;
@@ -3189,27 +3250,20 @@ void GenShapedSHBExcitation_ivas_enc_fx(
// v_multc_fixed_16_16(White_exc16k, round_fx(temp_pow), White_exc16k, L_FRAME16k);
L_tmp = 0;
move32();
+ Q_White_exc16k = add( getScaleFactor16( White_exc16k, L_FRAME16k ), norm_l( temp_pow ) );
FOR( k = 0; k < L_FRAME16k; k++ )
{
- White_exc16k_32[k] = Mpy_32_16_1( temp_pow, White_exc16k[k] );
+ White_exc16k_32[k] = Mpy_32_16_1( temp_pow, White_exc16k[k] ); // Q31 + Q0 - Q15 = Q16
move32();
- White_exc16k[k] = round_fx( L_shl( White_exc16k_32[k], sub( *Q_bwe_exc, NOISE_QADJ ) ) ); // Q_bwe_exc - NOISE_QADJ
+ White_exc16k[k] = round_fx( L_shl( White_exc16k_32[k], Q_White_exc16k ) ); // Q16 + Q_White_exc16k - Q16 = Q_White_exc16k
move16();
L_tmp = L_max( L_tmp, L_abs( White_exc16k_32[k] ) );
}
- Q_temp = norm_l( L_tmp );
- IF( L_tmp == 0 )
- {
- Q_temp = 31;
- move16();
- }
}
ELSE
#endif
{
/* create a random excitation - Reuse exc16k memory */
- White_exc16k = exc16k;
- move16();
create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed ); // Q5
create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed ); // Q5
@@ -3222,12 +3276,6 @@ void GenShapedSHBExcitation_ivas_enc_fx(
move32();
L_tmp = L_max( L_tmp, L_abs( White_exc16k_32[k] ) );
}
- Q_temp = norm_l( L_tmp );
- 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 */
@@ -3235,22 +3283,23 @@ void GenShapedSHBExcitation_ivas_enc_fx(
/* pow22=0.00001f */
tmp = sub( shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1 ), 31 );
Word64 sum = W_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(*Q_bwe_exc-NOISE_QADJ) */
+ Q_White_exc16k = getScaleFactor32( White_exc16k_32, L_FRAME16k );
FOR( k = 0; k < L_FRAME16k; k++ )
{
/* White_exc16k[k] *= excNoisyEnv[k]; */
- White_exc16k[k] = mult_r( excNoisyEnv[k], shl( White_exc16k[k], 1 ) ); // Q_excTmp2 + 5 + 1 - 15 ==> Q_excTmp2 - 9
+ White_exc16k[k] = extract_h( L_shl( White_exc16k_32[k], Q_White_exc16k ) ); // Q_excTmp2 + 6 + Q_White_exc16k - 16 ==> Q_excTmp2 + Q_White_exc16k - 10
move16();
chk2 = s_or( chk2, White_exc16k[k] );
/* i: excNoisyEnv in (Q_excTmp2) */
/* i: White_exc16k in Q6 */
/* o: White_exc16k in (Q_bwe_exc-NOISE_QADJ) */
/* pow22 += White_exc16k[k] * White_exc16k[k]; */
- sum = W_mac0_16_16( sum, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_excTmp2-NOISE_QADJ)*/
+ sum = W_mac0_16_16( sum, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_excTmp2 + Q_White_exc16k - 10)*/
}
Q_pow22 = W_norm( sum );
- pow22 = W_extract_h( W_shl( sum, Q_pow22 ) ); // 2*(Q_excTmp2-NOISE_QADJ)+Q_pow22-32
- Q_pow22 = sub( add( Q_pow22, shl( sub( Q_excTmp2, NOISE_QADJ ), 1 ) ), 32 );
- Scale_sig( White_exc16k, L_FRAME16k, sub( *Q_bwe_exc, Q_excTmp2 ) );
+ pow22 = W_extract_h( W_shl( sum, Q_pow22 ) ); // 2*(Q_excTmp2 + Q_White_exc16k - 10)+Q_pow22-32
+ Q_pow22 = sub( add( Q_pow22, shl( sub( add( Q_White_exc16k, Q_excTmp2 ), 10 ), 1 ) ), 32 );
+ Q_White_exc16k = add( Q_White_exc16k, sub( Q_excTmp2, 10 ) );
}
#if 1 // def ADD_IVAS_TBE_CODE
@@ -3272,7 +3321,7 @@ void GenShapedSHBExcitation_ivas_enc_fx(
{
FOR( k = 0; k < L_FRAME16k; k++ )
{
- White_exc16k_tmp[k] = round_fx( L_shl( White_exc16k_32[k], *Q_bwe_exc ) );
+ White_exc16k_tmp[k] = shl( White_exc16k[k], sub( *Q_bwe_exc, Q_White_exc16k ) );
move16();
}
@@ -3298,8 +3347,8 @@ void GenShapedSHBExcitation_ivas_enc_fx(
move32();
temp1 = add( shl( *Q_bwe_exc, 1 ), 1 );
- temp2 = add( add( Q_shb, *Q_bwe_exc ), 1 );
- temp3 = add( shl( Q_shb, 1 ), 1 );
+ temp2 = add( add( Q_EnvSHBres_4k, *Q_bwe_exc ), 1 );
+ temp3 = add( shl( Q_EnvSHBres_4k, 1 ), 1 );
FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ )
{
// c0_part[i] = sum2_f( &EnvExc16kWhtnd_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS );
@@ -3431,6 +3480,9 @@ void GenShapedSHBExcitation_ivas_enc_fx(
{
// g = 1.0f;
g = MAX16B; /* Q15 */
+ move16();
+ g_e = 0;
+ move16();
}
// else if ( g < shl( delta, ( 15 - g_e ) - 14 ) )
ELSE IF( BASOP_Util_Cmp_Mant32Exp( g, add( 16, g_e ), delta, 17 ) < 0 )
@@ -3438,8 +3490,12 @@ void GenShapedSHBExcitation_ivas_enc_fx(
/* prevent low gains to be quantized to 0 as this is reserved for plosives */
// g = delta;
g = shl( delta, 1 ); /* Q15 */
+ g_e = 0;
+ move16();
}
+ g = shl_sat( g, g_e ); /* Q15 */
+
*vf_ind = usquant_fx( g, &mix_factor, 0, delta, cbsize );
move16();
}
@@ -3474,7 +3530,7 @@ void GenShapedSHBExcitation_ivas_enc_fx(
#endif
{
Estimate_mix_factors_fx( shb_res, Q_shb, exc16kWhtnd, *Q_bwe_exc, White_exc16k,
- ( *Q_bwe_exc - NOISE_QADJ ), pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind );
+ Q_White_exc16k, pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind );
tmp = voiceFacEst[0];
tmp2 = MAX_16;
move16();
@@ -3537,13 +3593,16 @@ void GenShapedSHBExcitation_ivas_enc_fx(
move16();
}
}
-#if 1 // def ADD_IVAS_TBE_CODE
+#if 1 // def ADD_IVAS_TBE_CODE
+ Scale_sig( White_exc16k, L_FRAME16k, sub( *Q_bwe_exc, Q_White_exc16k ) ); // Q_bwe_exc
test();
IF( GE_16( element_mode, IVAS_CPE_DFT ) && nlExc16k != NULL )
{
/* save buffers for IC-BWE */
// mvr2r(exc16kWhtnd, nlExc16k, L_FRAME16k);
Copy( exc16kWhtnd, nlExc16k, L_FRAME16k );
+ *nlExc16k_e = sub( 15, *Q_bwe_exc );
+ move16();
// v_multc(White_exc16k, (float)sqrt(pow1 / pow22), mixExc16k, L_FRAME16k);
/*Word16 temp_fac = divide3232(L_shr(pow1, Q_pow1), pow22);
Word16 temp_fac_exp = 0;
@@ -3553,24 +3612,27 @@ void GenShapedSHBExcitation_ivas_enc_fx(
// v_multc_fixed_16_16(White_exc16k,shr(temp_fac, temp_fac_exp) , mixExc16k, L_FRAME16k);
FOR( k = 0; k < L_FRAME16k; k++ )
{
- mixExc16k[k] = mult_r( White_exc16k[k], temp_fac );
+ mixExc16k[k] = mult_r( White_exc16k[k], temp_fac ); // Q_bwe_exc
move16();
}
+ *mixExc16k_e = sub( 15, *Q_bwe_exc );
+ move16();
}
#endif
- tmp = sub( Q_temp, 3 );
FOR( k = 0; k < L_FRAME16k; k++ )
{
- White_exc16k_FB[k] = White_exc16k[k]; /* Q_bwe_exc-NOISE_QADJ */
+ White_exc16k_FB[k] = White_exc16k[k]; /* Q_bwe_exc */
+ move16();
}
prev_Q_bwe_exc_fb = *Q_bwe_exc_fb;
move16();
- *Q_bwe_exc_fb = sub( *Q_bwe_exc, NOISE_QADJ );
+ *Q_bwe_exc_fb = *Q_bwe_exc;
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) */
+ /* i/o: White_exc16k (Q_bwe_exc) */
+ /* i: tbe_demph (Q_bwe_exc) */
#if 1 // def ADD_IVAS_TBE_CODE
test();
@@ -3585,34 +3647,39 @@ void GenShapedSHBExcitation_ivas_enc_fx(
// old_scale = Sqrt16(old_scale, &old_scale_exp);
// old_scale = shl(old_scale, old_scale_exp); //Q15
L_tmp = root_a_over_b_fx( *prev_pow_exc16kWhtnd, 0, pow1, Q_pow1, &exp );
- old_scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); // Q15
+ IF( exp < 0 )
+ {
+ L_tmp = L_shl( L_tmp, exp );
+ exp = 0;
+ move16();
+ }
+ old_scale = round_fx_sat( L_tmp ); // exp
// new_scale = 1.0f;
- new_scale = 32767;
- move16();
+ new_scale = shr( 32767, exp ); // exp
// step_scale = (new_scale - old_scale) / (L_FRAME16k / 2);
- step_scale = mult_r( sub( new_scale, old_scale ), 205 );
- scale = old_scale;
+ step_scale = mult_r( sub( new_scale, old_scale ), 205 ); // exp
+ scale = old_scale; // exp
move16();
/* interpolate between the old and the new value of the mixing factor */
- old_fact = *prev_mix_factor;
+ old_fact = *prev_mix_factor; // Q15
move16();
- new_fact = mix_factor;
+ new_fact = mix_factor; // Q15
move16();
// step = (new_fact - old_fact) / (L_FRAME16k / 2);
- step = mult_r( sub( new_fact, old_fact ), 205 );
- fact = old_fact;
+ step = mult_r( sub( new_fact, old_fact ), 205 ); // Q15
+ fact = old_fact; // Q15
move16();
/* mixing of LB and gaussian excitation in the first half of the frame */
FOR( k = 0; k < L_FRAME16k / 2; k++ )
{
// exc16kWhtnd[k] = (float)fact * (White_exc16k[k] * scale) + (float)(1 - fact) * exc16kWhtnd[k];
// exc16kWhtnd[k] = add(mult_r(fact, mult(shl(White_exc16k[k], *Q_bwe_exc), scale)), mult_r(sub(32767, fact), exc16kWhtnd[k]));
- 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 );
+ L_tmp = L_add_sat( L_shl_sat( L_mult( fact, mult_r( White_exc16k[k], scale ) ), exp ), // Q15 + Q_bwe_exc + (Q15-exp) - Q15 + exp + Q1
+ L_mult( sub( 32767, fact ), exc16kWhtnd[k] ) ); // Q_bwe_exc + Q16
+ exc16kWhtnd[k] = round_fx_sat( L_tmp ); // Q_bwe_exc
move16();
- fact = add_sat( fact, step );
- scale = add_sat( scale, step_scale );
+ fact = add_sat( fact, step ); // Q15
+ scale = add_sat( scale, step_scale ); // exp
}
/* mixing of LB and gaussian excitation in the second half of the frame */
@@ -3620,14 +3687,14 @@ void GenShapedSHBExcitation_ivas_enc_fx(
{
// exc16kWhtnd[k] = (float)new_fact * White_exc16k[k] + (float)(1 - new_fact) * exc16kWhtnd[k];
// exc16kWhtnd[k] = add(mult_r(new_fact, shl(White_exc16k[k], *Q_bwe_exc)), mult_r(sub(32767, new_fact), exc16kWhtnd[k]));
- 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 );
+ L_tmp = L_add( L_mult( new_fact, White_exc16k[k] ),
+ mult_r( sub( 32767, new_fact ), exc16kWhtnd[k] ) ); // Q_bwe_exc + Q15 + Q1 => Q_bwe_exc + Q16
+ exc16kWhtnd[k] = round_fx( L_tmp ); // Q_bwe_exc
move16();
}
}
// preemph(exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph);
- PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph );
+ PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc
}
ELSE
#endif
@@ -3650,13 +3717,13 @@ void GenShapedSHBExcitation_ivas_enc_fx(
FOR( k = 0; k < L_FRAME16k; k++ )
{
/* White_exc16k: (Q_bwe_exc-NOISE_QADJ), scale: Q15 */
- L_tmp = L_mult( White_exc16k[k], scale );
+ L_tmp = L_mult( White_exc16k[k], scale ); // Q_bwe_exc + Q15 + Q1 => Q_bwe_exc + Q16
/* L_tmp: (Q_bwe_exc-NOISE_QADJ) + 15 + 1 */
- exc16kWhtnd[k] = round_fx_sat( L_shl_sat( L_tmp, NOISE_QADJ ) );
+ exc16kWhtnd[k] = round_fx_sat( L_tmp ); // Q_bwe_exc
move16();
/* exc16kWhtnd: Q_bwe_exc */
}
- PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph );
+ PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc
/* i/o: exc16kWhtnd (Q_bwe_exc) */
/* i/o: tbe_premph (Q_bwe_exc) */
}
@@ -3721,9 +3788,8 @@ void GenShapedSHBExcitation_ivas_enc_fx(
FOR( j = 0; j < lSubFr; j++ )
{
/*exc16kWhtnd[k+j] = temp1 * exc16kWhtnd[k+j] + temp2 * White_exc16k[k+j]; */
- L_tmp = L_mult( temp2, White_exc16k[k + j] ); /* 16+(Q_bwe_exc-NOISE_QADJ)*/
- L_tmp = L_shl_sat( L_tmp, NOISE_QADJ ); /* 16+(Q_bwe_exc) */
- exc16kWhtnd[k + j] = mac_r_sat( L_tmp, temp1, exc16kWhtnd[k + j] );
+ L_tmp = L_mult( temp2, White_exc16k[k + j] ); /* 16+(Q_bwe_exc)*/
+ exc16kWhtnd[k + j] = mac_r_sat( L_tmp, temp1, exc16kWhtnd[k + j] ); // Q_bwe_exc
move16();
/* Q_bwe_exc */
}
@@ -3740,7 +3806,7 @@ void GenShapedSHBExcitation_ivas_enc_fx(
temp = div_s( temp, temp2 ); /* Q15 */
temp = mult_r( PREEMPH_FAC, temp );
- PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph );
+ PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_bwe_exc
/* exc16kWhtnd: Q_bwe_exc;
tbe_premph: Q_bwe_exc*/
}
@@ -3753,7 +3819,7 @@ void GenShapedSHBExcitation_ivas_enc_fx(
IF( LT_32( bitrate, ACELP_24k40 ) )
#endif
{
- Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER, exc16kWhtnd, excSHB, L_FRAME16k, state_lpc_syn, 1 );
+ syn_filt_fx( 0, lpc_shb, LPC_SHB_ORDER, exc16kWhtnd, excSHB, L_FRAME16k, state_lpc_syn, 1 );
/* i: exc16kWhtnd in Q_bwe_exc */
/* o: excSHB in Q_bwe_exc */
}
diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c
index 169ca57679e50a0239c2adc8c1b2b811bef108a9..6e0f7e716fe0805021cb84d32f99f69cb7af69a0 100644
--- a/lib_com/syn_filt_fx.c
+++ b/lib_com/syn_filt_fx.c
@@ -185,7 +185,8 @@ void syn_filt_fx(
{
Word16 i, j;
Word16 buf[L_FRAME48k + L_FRAME48k / 2 + TCXLTP_LTP_ORDER]; /* temporary synthesis buffer */
- Word16 s, *yy;
+ Word16 *yy;
+ Word32 s;
Word16 q;
Flag Overflow = 0;
move16();
@@ -212,15 +213,16 @@ void syn_filt_fx(
FOR( i = 0; i < l; i++ )
{
- s = mult_r( shl_o( a0, q, &Overflow ), x[i] );
+ s = L_mult( a0, x[i] );
FOR( j = 1; j <= m; j++ )
{
- s = msu_ro( L_deposit_h( s ), shl_o( a[j], q, &Overflow ), yy[i - j], &Overflow );
+ s = L_msu_sat( s, shr( a[j], shift ), yy[i - j] );
}
- yy[i] = s;
+ s = L_shl_sat( s, q );
+ yy[i] = extract_h( s );
move16();
- y[i] = s;
+ y[i] = extract_h( s );
move16();
}
@@ -241,6 +243,80 @@ void syn_filt_fx(
}
+void syn_filt_fx32(
+ const Word16 a_e, /* i : exp of LP coeffs Q0 */
+ const Word32 a[], /* i : LP filter coefficients Q12 */
+ const Word16 m, /* i : order of LP filter Q0 */
+ const Word32 x[], /* i : input signal Qx */
+ const Word16 x_e, /* i : input signal Qx */
+ Word32 y[], /* o : output signal Qx */
+ Word16 *y_e, /* o : output signal Qx */
+ const Word16 l, /* i : size of filtering Q0 */
+ Word32 mem[], /* i/o: initial filter states Qx */
+ Word16 *mem_e, /* i/o: initial filter states Qx */
+ const Word16 update_m /* i : update memory flag Q0 : 0 --> no memory update */
+ ) /* 1 --> update of memory */
+{
+ Word16 i, j;
+ Word64 buf[L_FRAME48k + L_FRAME48k / 2 + TCXLTP_LTP_ORDER]; /* temporary synthesis buffer */
+ Word64 s, *yy;
+
+ yy = &buf[0];
+
+ /*------------------------------------------------------------------*
+ * copy initial filter states into synthesis buffer and do synthesis
+ *------------------------------------------------------------------*/
+
+ FOR( i = 0; i < m; i++ )
+ {
+ *yy++ = W_deposit32_l( mem[i] );
+ move32();
+ }
+
+ /*-----------------------------------------------------------------------*
+ * Do the filtering
+ *-----------------------------------------------------------------------*/
+ Word64 max_val = 1;
+ FOR( i = 0; i < l; i++ )
+ {
+ s = W_deposit32_l( x[i] );
+ FOR( j = 1; j <= m; j++ )
+ {
+ s = W_sub( s, W_mult0_32_32( a[j], W_extract_l( W_shr( yy[i - j], sub( 31, a_e ) ) ) ) );
+ }
+
+ yy[i] = s;
+ move32();
+ if ( GT_64( W_abs( s ), max_val ) )
+ {
+ max_val = W_abs( s );
+ }
+ }
+
+ Word16 norm = W_norm( max_val );
+
+ FOR( i = 0; i < l; i++ )
+ {
+ y[i] = W_extract_l( W_shr( yy[i], sub( 32, norm ) ) );
+ }
+ *y_e = sub( 31, add( sub( 31, x_e ), sub( norm, 32 ) ) );
+ /*------------------------------------------------------------------*
+ * Update memory if required
+ *------------------------------------------------------------------*/
+
+ IF( update_m )
+ {
+ FOR( i = 0; i < m; i++ )
+ {
+ mem[i] = W_extract_l( W_shr( yy[l - m + i], sub( 32, norm ) ) );
+ }
+ *mem_e = sub( 31, add( sub( 31, x_e ), sub( norm, 32 ) ) );
+ }
+
+ return;
+}
+
+
/*
* E_UTIL_synthesis
*
diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c
index d4de526d629dfad34aaebc39a4693bacd6ede9a5..af4a87d34a66536ac2c68eeb5b76782e0e1ff259 100644
--- a/lib_com/tns_base.c
+++ b/lib_com/tns_base.c
@@ -602,6 +602,145 @@ Word16 ITF_Detect_fx(
return 1;
}
+
+Word16 ITF_Detect_ivas_fx(
+ const Word32 pSpectrum[], /*Q*/
+ const Word16 startLine, /*Q0*/
+ const Word16 stopLine, /*Q0*/
+ const Word16 maxOrder, /*Q0*/
+ Word16 *A, /*Q_A*/
+ Word16 *Q_A,
+ Word16 *predictionGain, /*Q7*/
+ Word16 *curr_order, /*Q0*/
+ Word16 Q )
+{
+ Word32 norms[MAX_SUBDIVISIONS];
+ Word16 num_subdivisions, i, length;
+ Word16 iStartLine, iEndLine, spectrumLength;
+ Word32 rxx[ITF_MAX_FILTER_ORDER + 1];
+ Word16 q_rxx[ITF_MAX_FILTER_ORDER + 1];
+ Word32 temp_spectrum[640];
+ const Word16 *pWindow;
+ const Word32 *ptr_spectrum1, *ptr_spectrum2;
+ Word16 iSubdivisions, lag;
+ Word16 headroom, guard_bits, shift, q_min;
+ Word64 sum;
+ Word16 fac, q_fac, exp, q_temp;
+ Word32 temp;
+
+ IF( maxOrder <= 0 )
+ {
+ return 0;
+ }
+ pWindow = tnsAcfWindow_fx;
+ set_zero_fx( norms, MAX_SUBDIVISIONS );
+ set_zero_fx( rxx, ITF_MAX_FILTER_ORDER + 1 ); /* This initialization is required */
+ set16_fx( q_rxx, Q31, ITF_MAX_FILTER_ORDER + 1 ); /* This initialization is required */
+
+ spectrumLength = sub( stopLine, startLine );
+ num_subdivisions = 0;
+ move16();
+
+ /* Calculate norms for each spectrum part */
+ FOR( iSubdivisions = 0; iSubdivisions < MAX_SUBDIVISIONS; iSubdivisions++ )
+ {
+ /* iStartLine = startLine + ( stopLine - startLine ) * iSubdivisions / nSubdivisions; */
+ iStartLine = add( startLine, mult( imult1616( spectrumLength, iSubdivisions ), 10923 /* 1/MAX_SUBDIVISIONS in Q15 */ ) ); /*Q0*/
+ /* iEndLine = startLine + ( stopLine - startLine ) * ( iSubdivisions + 1 ) / nSubdivisions; */
+ iEndLine = add( startLine, mult( imult1616( spectrumLength, add( iSubdivisions, 1 ) ), 10923 /* 1/MAX_SUBDIVISIONS in Q15 */ ) ); /*Q0*/
+
+
+ /* Variable initialization */
+ /* norms[iSubdivisions] = sum2_f(pSpectrum + iStartLine - IGF_START_MN, iEndLine - iStartLine); */
+
+ ptr_spectrum1 = pSpectrum + sub( iStartLine, IGF_START_MN );
+ length = sub( iEndLine, iStartLine );
+ headroom = L_norm_arr( ptr_spectrum1, length );
+ guard_bits = find_guarded_bits_fx( length );
+ shift = sub( headroom, guard_bits );
+
+ Copy_Scale_sig32( ptr_spectrum1, temp_spectrum, length, shift ); // Q -> Q+shift
+
+ sum = 0;
+ move64();
+ FOR( i = 0; i < length; i++ )
+ {
+ sum = W_mac_32_32( sum, temp_spectrum[i], temp_spectrum[i] ); // 2(Q+shift)+1
+ }
+
+ IF( LE_64( sum, W_shl( 32768 * 2 /* HLM_MIN_NRG in Q1 */, shl( add( Q, shift ), 1 ) ) ) )
+ {
+ BREAK;
+ }
+
+ /* fac = 1.0f / norms[iSubdivisions]; */
+ exp = W_norm( sum );
+ sum = W_shl( sum, exp ); // 2(Q+shift)+1+exp
+ fac = div_s( ONE_IN_Q14, extract_h( W_extract_h( sum ) ) ); // 15+14-(2(Q+shift)+1+exp-48) = 76-(2(Q+shift)+exp)
+ q_fac = sub( 76, add( shl( add( Q, shift ), 1 ), exp ) );
+ pWindow = tnsAcfWindow_fx;
+
+ /* For additional loop condition */
+ /* Variable initialization */
+ /*for ( lag = 1; lag <= maxOrder; lag++ )
+ {
+ rxx[lag] += fac * ( *pWindow ) * dotp( pSpectrum + iStartLine - IGF_START_MN, pSpectrum + iStartLine - IGF_START_MN + lag, iEndLine - iStartLine - lag );
+ pWindow++;
+ }*/
+
+ ptr_spectrum1 = temp_spectrum; // pSpectrum + iStartLine - IGF_START_MN;
+ FOR( lag = 1; lag <= maxOrder; lag++ )
+ {
+ /* dotp( pSpectrum + iStartLine - IGF_START_MN, pSpectrum + iStartLine - IGF_START_MN + lag, iEndLine - iStartLine - lag ) */
+ ptr_spectrum2 = temp_spectrum + lag; // pSpectrum + iStartLine - IGF_START_MN + lag;
+
+ sum = 0;
+ move64();
+ FOR( i = 0; i < iEndLine - iStartLine - lag; i++ )
+ {
+ sum = W_mac_32_32( sum, ptr_spectrum1[i], ptr_spectrum2[i] ); // 2(Q+shift)+1
+ }
+ exp = W_norm( sum );
+ sum = W_shl( sum, exp ); // 2(Q+shift)+1+exp
+ temp = Mpy_32_32( L_mult0( fac, *pWindow ), W_extract_h( sum ) ); // (q_fac+15)+(2(Q+shift)+1+exp-32)-31 = q_fac+2(Q+shift)+exp-47
+ q_temp = sub( add( q_fac, add( shl( add( Q, shift ), 1 ), exp ) ), 47 );
+
+ /* rxx[lag] += fac * (*pWindow) * dotp(pSpectrum + iStartLine - IGF_START_MN, pSpectrum + iStartLine - IGF_START_MN + lag, iEndLine - iStartLine - lag); */
+ q_min = sub( s_min( q_temp, q_rxx[lag] ), 1 );
+ rxx[lag] = L_add( L_shl( rxx[lag], sub( q_min, q_rxx[lag] ) ), L_shl( temp, sub( q_min, q_temp ) ) );
+ q_rxx[lag] = q_min;
+ move32();
+ move16();
+
+ pWindow++;
+ }
+
+ num_subdivisions = add( num_subdivisions, 1 );
+ }
+
+ minimum_s( q_rxx + 1, ITF_MAX_FILTER_ORDER, &q_min );
+ q_min = s_min( Q29, q_min );
+
+ FOR( i = 1; i < ITF_MAX_FILTER_ORDER; i++ )
+ {
+ rxx[i] = L_shl( rxx[i], sub( q_min, q_rxx[i] ) );
+ move32();
+ }
+
+ IF( EQ_16( iSubdivisions, MAX_SUBDIVISIONS ) ) /* meaning there is no subdivision with low energy */
+ {
+ rxx[0] = L_shl( MAX_SUBDIVISIONS, q_min );
+ move32();
+
+ /* Limit the maximum order to spectrum length/4 */
+ ITF_GetFilterParameters_fx( rxx, s_min( maxOrder, shr( spectrumLength, 2 ) ), A, Q_A, predictionGain );
+
+ *curr_order = maxOrder; /*Q0*/
+ move16();
+ }
+
+ return 1;
+}
/* Helper functions for Hufmann table coding */
diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c
index 704b44b8483a247d765a60d5c141cda7a6b93c34..063f49fc4e226c2b6dbc5bf7d53dfbcefe2c5bfc 100644
--- a/lib_com/tools_fx.c
+++ b/lib_com/tools_fx.c
@@ -2505,6 +2505,109 @@ Word32 root_a_over_b_fx(
return L_tmp;
}
+Word32 root_a_over_b_ivas_fx(
+ Word32 a, /* Q(Q_a) */
+ Word16 Q_a,
+ Word32 b, /* Q(Q_b) */
+ Word16 Q_b,
+ Word16 *q_out )
+{
+ Word16 shift_a, shift_b, shift;
+ Word32 mod_a, mod_b, one_in_Q_a, one_in_Q_b, half_in_Q_a, half_in_Q_b;
+ Word32 a_sqr, b_sqr, p0, p1, p2, approx;
+ Word16 exp;
+
+ test();
+ IF( ( a <= 0 ) || ( b <= 0 ) )
+ {
+ *q_out = 0;
+ move16();
+ return 0;
+ }
+
+ one_in_Q_a = L_shl( 1, Q_a ); // 1.0f in Q_a
+ one_in_Q_b = L_shl( 1, Q_b ); // 1.0f in Q_b
+ half_in_Q_a = L_shr( one_in_Q_a, 1 ); // 0.5f in Q_a
+ half_in_Q_b = L_shr( one_in_Q_b, 1 ); // 0.5f in Q_b
+
+ a = L_add( a, one_in_Q_a );
+ b = L_add( b, one_in_Q_b );
+
+ /* This next piece of code implements a "norm" function */
+ /* and returns the shift needed to scale "a" to have a */
+ /* 1 in the (MSB-1) position. This is equivalent to */
+ /* giving a value between 0.5 & 1.0. */
+
+ mod_a = a;
+ move32();
+
+ shift_a = 0;
+ move16();
+ WHILE( GT_32( mod_a, one_in_Q_a ) )
+ {
+ mod_a = L_shr( mod_a, 1 );
+ shift_a = sub( shift_a, 1 );
+ }
+
+ WHILE( LT_32( mod_a, half_in_Q_a ) )
+ {
+ mod_a = L_shl( mod_a, 1 );
+ shift_a = add( shift_a, 1 );
+ }
+
+ shift_a = s_and( shift_a, -2 );
+ mod_a = L_shl( a, shift_a ); // Q_a
+
+ /* This next piece of code implements a "norm" function */
+ /* and returns the shift needed to scale "b" to have a */
+ /* 1 in the (MSB-1) position. This is equivalent to */
+ /* giving a value between 0.5 & 1.0. */
+ mod_b = b;
+ move32();
+
+ shift_b = 0;
+ move16();
+ WHILE( GT_32( mod_b, one_in_Q_b ) )
+ {
+ mod_b = L_shr( mod_b, 1 );
+ shift_b = sub( shift_b, 1 );
+ }
+
+ WHILE( LT_32( mod_b, half_in_Q_b ) )
+ {
+ mod_b = L_shl( mod_b, 1 );
+ shift_b = add( shift_b, 1 );
+ }
+
+ shift_b = s_and( shift_b, -2 );
+ mod_b = L_shl( b, shift_b ); // Q_b
+
+ shift = shr( sub( shift_b, shift_a ), 1 );
+
+ a_sqr = W_extract_h( W_shl( W_mult0_32_32( mod_a, mod_a ), sub( 32, Q_a ) ) ); // Q_a
+ b_sqr = W_extract_h( W_shl( W_mult0_32_32( mod_b, mod_b ), sub( 32, Q_b ) ) ); // Q_b
+
+ p2 = L_shl( -408505077 /* -0.7609f in Q29 */, sub( Q_b, 31 ) ); // Qb-2
+ p1 = L_shl( 1444612250 /* 2.6908f in Q29 */, sub( Q_b, 31 ) ); // Qb-2
+ p0 = L_shl( 385258566 /* 0.7176f in Q29 */, sub( Q_b, 31 ) ); // Qb-2
+
+ p2 = Madd_32_32( Madd_32_32( p2, 501759554 /* 0.9346f in Q29*/, mod_b ), -252060893 /* -0.4695f in Q29 */, b_sqr ); // Q_b-2
+ p1 = Madd_32_32( Madd_32_32( p1, -1774680487 /* -3.3056f in Q29 */, mod_b ), 891635211 /* 1.6608f in Q29 */, b_sqr ); // Q_b-2
+ p0 = Madd_32_32( Madd_32_32( p0, -473251709 /* -0.8815f in Q29 */, mod_b ), 237780127 /* 0.4429f in Q29 */, b_sqr ); // Q_b-2
+
+ /* approx = p0 + p1 * mod_a + p2 * mod_a * mod_a; */
+ approx = Madd_32_32( Mpy_32_32( p1, mod_a ), p2, a_sqr ); // Q_a+Q_b-33
+ approx = L_add( approx, L_shl( p0, sub( Q_a, 31 ) ) ); // Q_a+Q_b-33
+
+ exp = sub( norm_l( approx ), 1 );
+ approx = L_shl( approx, exp ); // // Q_a+Q_b-33+exp
+
+ *q_out = sub( add( sub( add( Q_a, Q_b ), 33 ), exp ), shift );
+ move16();
+
+ return approx;
+}
+
/*===================================================================*/
/* FUNCTION : fir_fx () */
/*-------------------------------------------------------------------*/
diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c
index 778cc9ec32f89c906664ed647da71139c172ffd3..708fc39e6544f87830590ccc9a2c584121938d50 100644
--- a/lib_dec/FEC_HQ_phase_ecu_fx.c
+++ b/lib_dec/FEC_HQ_phase_ecu_fx.c
@@ -1591,7 +1591,7 @@ static void ivas_spec_ana_fx(
IF( n > 0 && *pPlocs == 0 ) /* Very 1st peak position possible to have a peak at 0/DC index position. */
{
#ifdef FIX_ISSUE_1237
- Copy_Scale_sig_16_32_no_sat( &xfp[*pPlocs], xfp_32, 3, Q15 ); // Q + 16
+ Copy_Scale_sig_16_32_no_sat( &xfp[*pPlocs], xfp_32, 3, Q15 ); // Q + 15
#else
Copy_Scale_sig_16_32_DEPREC( &xfp[*pPlocs], xfp_32, 3, Q16 ); // Q + 16
#endif
@@ -1606,7 +1606,7 @@ static void ivas_spec_ana_fx(
IF( n > 0 && EQ_16( *pPlocs, 1 ) ) /* Also 2nd peak position uses DC which makes jacobsen unsuitable. */
{
#ifdef FIX_ISSUE_1237
- Copy_Scale_sig_16_32_no_sat( &xfp[*pPlocs - 1], xfp_32, 3, Q15 ); // Q + 16
+ Copy_Scale_sig_16_32_no_sat( &xfp[*pPlocs - 1], xfp_32, 3, Q15 ); // Q + 15
#else
Copy_Scale_sig_16_32_DEPREC( &xfp[*pPlocs - 1], xfp_32, 3, Q16 ); // Q + 16
#endif
@@ -1656,7 +1656,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. */
{
#ifdef FIX_ISSUE_1237
- Copy_Scale_sig_16_32_no_sat( &xfp[currPlocs - 1], xfp_32, 3, Q15 ); // Q + 16
+ Copy_Scale_sig_16_32_no_sat( &xfp[currPlocs - 1], xfp_32, 3, Q15 ); // Q + 15
#else
Copy_Scale_sig_16_32_DEPREC( &xfp[currPlocs - 1], xfp_32, 3, Q16 ); // Q + 16
#endif
@@ -1674,7 +1674,7 @@ static void ivas_spec_ana_fx(
IF( n > 0 ) /* fs/2 which makes special case . */
{
#ifdef FIX_ISSUE_1237
- Copy_Scale_sig_16_32_no_sat( &xfp[currPlocs - 2], xfp_32, 3, Q15 ); // Q + 16
+ Copy_Scale_sig_16_32_no_sat( &xfp[currPlocs - 2], xfp_32, 3, Q15 ); // Q + 15
#else
Copy_Scale_sig_16_32_DEPREC( &xfp[currPlocs - 2], xfp_32, 3, Q16 ); // Q + 16
#endif
diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c
index 0686996f39a63f813179d33dd587dc0f5248530b..35bb254af835011d3ec461752e47c43ee3c7b2f3 100644
--- a/lib_dec/FEC_fx.c
+++ b/lib_dec/FEC_fx.c
@@ -504,7 +504,11 @@ void FEC_exc_estim_fx(
test();
test();
test();
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( EQ_16( st_fx->last_coder_type, AUDIO ) || ( EQ_16( st_fx->last_good, INACTIVE_CLAS ) && st_fx->inactive_coder_type_flag && !st_fx->Opt_AMR_WB ) )
+#else
IF( EQ_16( st_fx->last_coder_type, AUDIO ) || ( EQ_16( st_fx->last_good, INACTIVE_CLAS ) && LE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) && !st_fx->Opt_AMR_WB ) )
+#endif
{
st_fx->GSC_noisy_speech = st_fx->Last_GSC_noisy_speech_flag;
move16();
@@ -666,7 +670,11 @@ void FEC_exc_estim_fx(
test();
test();
test();
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( EQ_16( st_fx->last_coder_type, AUDIO ) || ( EQ_16( st_fx->last_good, INACTIVE_CLAS ) && st_fx->inactive_coder_type_flag && !st_fx->Opt_AMR_WB ) )
+#else
IF( ( EQ_16( st_fx->last_coder_type, AUDIO ) || EQ_16( st_fx->last_good, INACTIVE_CLAS ) ) && LE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) && !st_fx->Opt_AMR_WB )
+#endif
{
/* For GSC - the excitation is already computed */
Copy( exc, exc2, st_fx->L_frame );
diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c
index a41a0c813ebf50cb2a41d9fa92dcc0e33e414b91..1b2207491020bd08416ac1c78f69aeef75ab491c 100644
--- a/lib_dec/acelp_core_dec_fx.c
+++ b/lib_dec/acelp_core_dec_fx.c
@@ -777,14 +777,21 @@ ivas_error acelp_core_dec_fx(
move16();
}
+#ifdef NONBE_FIX_GSC_BSTR
+ config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+#else
config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-
+#endif
test();
test();
IF( EQ_16( st_fx->coder_type, TRANSITION ) && LT_16( tc_subfr_fx, L_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) )
{
+#ifdef NONBE_FIX_GSC_BSTR
+ config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, TRANSITION, -1, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+#else
config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+#endif
}
}
diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c
index ed32a115f33061a0d06f3bd8ea55ff9c8db9dded..e804b87555439d0f085e03aeb26f2f14a94bf4b0 100644
--- a/lib_dec/acelp_core_dec_ivas_fx.c
+++ b/lib_dec/acelp_core_dec_ivas_fx.c
@@ -180,7 +180,19 @@ ivas_error acelp_core_dec_ivas_fx(
IF( EQ_32( st->core_brate, SID_2k40 ) )
{
FdCng_decodeSID_ivas_fx( st );
+#ifdef FIX_ISSUE_1218
+ Word16 n1, n2;
+ n1 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART );
+ n2 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART );
+
+ Word16 common_e = s_max( sub( old_NoiseEstExp, n2 ), sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, n1 ) );
+ scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, common_e ) );
+ scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, common_e ) );
+ st->hFdCngDec->hFdCngCom->sidNoiseEstExp = common_e;
+ move16();
+#else
rescale_fdCngDec( st->hFdCngDec, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) );
+#endif
}
FOR( i = 0; i < NPART; i++ )
{
@@ -790,7 +802,11 @@ ivas_error acelp_core_dec_ivas_fx(
Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn
IF( st->hBWE_FD != NULL )
{
+#ifdef FIX_ISSUE_1290
+ 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 );
+#else
save_old_syn_fx( st->L_frame, syn1_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 );
+#endif
}
}
@@ -830,12 +846,21 @@ ivas_error acelp_core_dec_ivas_fx(
move16();
}
+#ifdef NONBE_FIX_GSC_BSTR
+ config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+#else
config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+#endif
+
test();
test();
IF( EQ_16( st->coder_type, TRANSITION ) && LT_16( tc_subfr, L_SUBFR ) && EQ_16( st->L_frame, L_FRAME ) )
{
+#ifdef NONBE_FIX_GSC_BSTR
+ config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+#else
config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+#endif
}
}
@@ -1106,7 +1131,11 @@ ivas_error acelp_core_dec_ivas_fx(
* Apply energy matching when switching to inactive frames
*-----------------------------------------------------------------*/
+#ifdef NONBE_FIX_GSC_BSTR
+ Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
+#else
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 );
+#endif
/*------------------------------------------------------------*
* Decode information and modify the excitation signal of stationary unvoiced frames
@@ -1222,7 +1251,7 @@ ivas_error acelp_core_dec_ivas_fx(
*------------------------------------------------------------*/
- Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6 ); // Q0
+ Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
&st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 );
@@ -1313,7 +1342,11 @@ ivas_error acelp_core_dec_ivas_fx(
}
/* Apply energy matching when switching to inactive frames */
+#ifdef NONBE_FIX_GSC_BSTR
+ Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
+#else
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 );
+#endif
/* update past excitation signals for LD music post-filter */
IF( st->hMusicPF != NULL )
@@ -1376,7 +1409,7 @@ ivas_error acelp_core_dec_ivas_fx(
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 ); // Q0
+ Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
&st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
@@ -1413,7 +1446,7 @@ ivas_error acelp_core_dec_ivas_fx(
test();
IF( st->last_bwidth == NB && st->hPFstat != NULL )
{
- Copy( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k );
+ Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
IF( st->bwidth == NB )
{
st->hPFstat->on = 1;
@@ -1874,7 +1907,9 @@ ivas_error acelp_core_dec_ivas_fx(
scale_sig32_r( 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();
+#ifndef MSAN_FIX
Scale_sig32( save_hb_synth_fx, L_FRAME48k, sub( Q_real, 1 ) ); // Q_real-1
+#endif
FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
{
diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c
index f347cdb7eb18b6a2568665d547d5caf4cb07486c..3875339571c907267d06ede6126a3022dc03d558 100644
--- a/lib_dec/acelp_core_switch_dec_fx.c
+++ b/lib_dec/acelp_core_switch_dec_fx.c
@@ -128,7 +128,13 @@ ivas_error acelp_core_switch_dec_fx(
/*----------------------------------------------------------------*
* Excitation decoding
*----------------------------------------------------------------*/
+
+#ifdef NONBE_FIX_GSC_BSTR
+ config_acelp1( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 );
+#else
config_acelp1( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 );
+#endif
+
decod_gen_voic_core_switch_fx( st_fx, L_frame_for_cs, 0, Aq, exc, cbrate, &st_fx->Q_exc );
/*----------------------------------------------------------------*
diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c
index 1abd3d58bddfe6e5bcd943b021175f46d936b7ea..bdfac224f45b0efbfee46ebfe92a8acf010a9f0f 100644
--- a/lib_dec/dec_gen_voic_fx.c
+++ b/lib_dec/dec_gen_voic_fx.c
@@ -693,7 +693,11 @@ ivas_error decod_gen_voic_ivas_fx(
* Transform domain contribution decoding
*-----------------------------------------------------------------*/
test();
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( !st_fx->inactive_coder_type_flag && st_fx->coder_type == INACTIVE )
+#else
IF( GE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) && ( st_fx->coder_type == INACTIVE ) )
+#endif
{
transf_cdbk_dec_fx( st_fx, harm_flag_acelp, i_subfr_fx, Es_pred_fx, gain_code_fx, &gain_preQ_fx, &norm_gain_preQ_fx, code_preQ_fx, unbits );
}
diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c
index a6e06db54ab14b708376a5a3cea169ef83b10e0b..a4f618a3fd751dec1eeea852d8e26230a86f39c8 100644
--- a/lib_dec/dec_post_fx.c
+++ b/lib_dec/dec_post_fx.c
@@ -86,7 +86,7 @@ void nb_post_filt_fx(
const Word16 tmp_noise, /* i : noise energy Q0 */
Word16 *Synth, /* i : 12k8 synthesis Qsyn */
const Word16 *Aq, /* i : LP filter coefficient Q12 */
- const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q6 */
+ const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q0 */
const Word16 coder_type, /* i : coder_type */
const Word16 BER_detect, /* i : BER detect flag */
const Word16 disable_hpf /* i : flag to diabled HPF */
@@ -142,7 +142,7 @@ void nb_post_filt_fx(
move16();
FOR( i = 0; i < L_frame; i += L_SUBFR )
{
- T0_first = Pitch_buf[j]; // Q6
+ T0_first = Pitch_buf[j]; // Q0
move16();
Dec_postfilt_fx( hPFstat, T0_first, &Pf_in[i], p_Aq, &Synth[i], Post_G1, Post_G2, Gain_factor, disable_hpf );
@@ -179,7 +179,7 @@ void nb_post_filt_fx(
*----------------------------------------------------------------------------*/
static void Dec_postfilt_fx(
PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
- const Word16 t0, /* i : pitch delay given by coder Q6 */
+ const Word16 t0, /* i : pitch delay given by coder Q0 */
const Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q0 */
const Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */
Word16 *sig_out, /* o : postfiltered output Q15*/
@@ -749,7 +749,7 @@ static void modify_pst_param_fx(
* Perform harmonic postfilter
*----------------------------------------------------------------------------*/
static void pst_ltp_fx(
- Word16 t0, /* i : pitch delay given by coder Q6 */
+ Word16 t0, /* i : pitch delay given by coder Q0 */
Word16 *ptr_sig_in, /* i : postfilter i filter (residu2) Qx */
Word16 *ptr_sig_pst0, /* o : harmonic postfilter o Qx */
Word16 gain_factor /* i : Gain Factor (Q15) */
diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c
index ae0474f3d987d452a00f59905bd09924038a8e21..708527df5fa21a97b807fd13f934b06c56d1cac1 100644
--- a/lib_dec/dec_tcx.c
+++ b/lib_dec/dec_tcx.c
@@ -237,6 +237,7 @@ void decoder_tcx_imdct_fx(
Word16 q_a_itf = 15;
Word16 x_e = sub( 31, q_x );
move16();
+ Word16 shift_q = sub( q_x, q_win );
/*-----------------------------------------------------------------*
* Initializations
@@ -364,9 +365,10 @@ void decoder_tcx_imdct_fx(
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
{
+ Word16 copy_len = s_min( L_FRAME48k, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) );
set32_fx( x_tmp_fx, 0, L_FRAME_PLUS );
- Copy32( x_fx, x_tmp_fx, s_min( L_FRAME48k, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ) ); // q_x
- Copy32( x_fx, xn_bufFB_fx, s_min( L_FRAME48k, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ) ); // q_x
+ Copy32( x_fx, x_tmp_fx, copy_len ); // q_x
+ Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x
}
ELSE IF( ( st->element_mode == EVS_MONO ) )
{
@@ -374,8 +376,9 @@ void decoder_tcx_imdct_fx(
}
ELSE
{
- Copy32( x_fx, x_tmp_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x
- Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x
+ Word16 copy_len = s_max( L_spec, s_max( L_frame, L_frameTCX ) );
+ Copy32( x_fx, x_tmp_fx, copy_len ); // q_x
+ Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x
}
IF( ( st->igf != 0 ) )
@@ -416,24 +419,29 @@ void decoder_tcx_imdct_fx(
FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ )
{
- xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], sub( q_x, q_win ) ) ); // q_x
+ xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x
move16();
}
+
+ Word16 ratio_e;
+ Word16 ratio = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &ratio_e ); // Q = 15-ratio_e. * FSCALE_DENOM is (1 << 9)
+ ratio = shr( ratio, sub( 6, ratio_e ) );
+
IF( st->element_mode != EVS_MONO )
{
IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB,
hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index,
- kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir_fx, q_win );
+ kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win );
}
ELSE
{
IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index,
- kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir_fx, q_win );
+ kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win );
}
FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ )
{
- xn_bufFB_fx[ind] = L_shl( xn_bufFB_fx_16[ind], sub( q_x, q_win ) ); // Q_x
+ xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // Q_x
}
IF( ( bfi == 0 ) )
@@ -453,19 +461,22 @@ void decoder_tcx_imdct_fx(
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- res_m = BASOP_Util_Divide1616_Scale( L_frame_glob, L_FRAME, &res_e );
- st->old_fpitch = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e );
+ // Using sat as a single instruction shifts and extracts
+ st->old_fpitch = W_shl_sat_l( W_mult0_32_32( st->old_fpitch, L_frame_glob ), -8 ); // Divide by 256 ==> SHR by 8
+ move32();
}
IF( GT_16( st->element_mode, EVS_MONO ) )
{
res_m = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &res_e );
st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e );
+ move32();
}
ELSE
{
res_m = BASOP_Util_Divide1616_Scale( L_frameTCX, L_frame, &res_e );
st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e );
+ move32();
}
}
@@ -475,7 +486,7 @@ void decoder_tcx_imdct_fx(
Copy( xn_buf_fx + L_frame, hTcxDec->syn_Overl, overlap ); // Q(-2)
FOR( Word16 ind = 0; ind < overlapFB; ind++ )
{
- hTcxDec->syn_OverlFB[ind] = (Word16) L_shr( xn_bufFB_fx[( ind + L_frameTCX )], sub( q_x, q_win ) ); // q_x
+ hTcxDec->syn_OverlFB[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ); // q_x
}
}
@@ -483,7 +494,7 @@ void decoder_tcx_imdct_fx(
Copy( xn_buf_fx + sub( shr( overlap, 1 ), tcx_offset ), synth_fx, L_frame_glob ); // Q(-2)
FOR( Word16 ind = 0; ind < L_frameTCX_glob; ind++ )
{
- synthFB_fx[ind] = (Word16) L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], sub( q_x, q_win ) ); // q_x
+ synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_x
}
diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c
index ffb49be38ac379865dbcfd897ab7458a1e9d73e8..aa898956a106198302bdc046458327e8f84766cf 100644
--- a/lib_dec/dec_uv_fx.c
+++ b/lib_dec/dec_uv_fx.c
@@ -255,9 +255,9 @@ void decod_unvoiced_ivas_fx(
Word16 tmp_idx;
tmp_idx = 0;
move16();
- if ( i_subfr_fx != 0 )
+ IF( i_subfr_fx != 0 )
{
- idiv1616( i_subfr_fx, L_SUBFR );
+ tmp_idx = idiv1616( i_subfr_fx, L_SUBFR );
}
voice_factors_fx[tmp_idx] = 0;
move16();
diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c
index 9c0020223150cbb48adcfa4f6497e23fbe600359..a83de038afe2e1fa2a92923f65ca270fec68b461 100644
--- a/lib_dec/decision_matrix_dec_fx.c
+++ b/lib_dec/decision_matrix_dec_fx.c
@@ -713,5 +713,20 @@ void decision_matrix_dec_fx(
move16();
}
+#ifdef NONBE_FIX_GSC_BSTR
+ /*-----------------------------------------------------------------*
+ * set inactive coder_type flag in ACELP core
+ *-----------------------------------------------------------------*/
+
+ st->inactive_coder_type_flag = 0; /* AVQ by default */
+ move16();
+
+ if ( LE_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) )
+ {
+ st->inactive_coder_type_flag = 1; /* GSC */
+ move16();
+ }
+
+#endif
return;
}
diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c
index c164d9e0667637c5bae2b7381a29abc08abf2ae0..fa7e602a54da5179a26696905633c5077bfef264 100644
--- a/lib_dec/fd_cng_dec_fx.c
+++ b/lib_dec/fd_cng_dec_fx.c
@@ -1807,7 +1807,12 @@ Word16 ApplyFdCng_ivas_fx(
{
FOR( ; j <= hFdCngCom->part[k]; j++ )
{
+#ifdef FIX_ISSUE_1218
+ /* NOTE: saturation is added here as part of issue 1218 fix. after rescaling the fdcng noise estimation buffers, due to slight precision loss, values may slightly overflow */
+ cngNoiseLevel[j] = L_shl_sat( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
+#else
cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
+#endif
move32();
}
}
@@ -2690,10 +2695,9 @@ void perform_noise_estimation_dec_ivas_fx(
}
ELSE
{
- Word16 tmp = s_max( sub( hFdCngDec->msPeriodog_exp, getScaleFactor32( msPeriodog, npart ) ), sub( hFdCngDec->msNoiseEst_exp, getScaleFactor32( &msNoiseEst[npart], sub( NPART_SHAPING, npart ) ) ) );
- Copy_Scale_sig32( msPeriodog, msNoiseEst, npart, sub( hFdCngDec->msPeriodog_exp, tmp ) ); /*Q31 - tmp*/
- scale_sig32( &msNoiseEst[npart], sub( NPART_SHAPING, npart ), sub( hFdCngDec->msNoiseEst_exp, tmp ) ); /*Q31 - tmp*/
- hFdCngDec->msNoiseEst_exp = tmp;
+ Copy32( msPeriodog, msNoiseEst, npart );
+ scale_sig32( &msNoiseEst[npart], sub( NPART_SHAPING, npart ), sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_exp ) );
+ hFdCngDec->msNoiseEst_exp = hFdCngDec->msPeriodog_exp;
move16();
}
diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c
index c237bc987c97317269ac29c9fbe6a1e23afb0825..3a39f9e3312ee58ab31739545e069199f2d2accb 100644
--- a/lib_dec/gs_dec_fx.c
+++ b/lib_dec/gs_dec_fx.c
@@ -96,12 +96,22 @@ void decod_audio_fx(
st_fx->GSC_noisy_speech = 0; /* Q0 */
move16();
}
+
/* set bit-allocation */
#ifdef ADD_LRTD
+#ifdef NONBE_FIX_GSC_BSTR
+ config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+#else
config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+#endif
+#else
+#ifdef NONBE_FIX_GSC_BSTR
+ config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
#else
config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
#endif
+#endif
+
/*---------------------------------------------------------------*
* Decode energy dynamics
*---------------------------------------------------------------*/
@@ -600,12 +610,18 @@ void decod_audio_ivas_fx(
st_fx->GSC_noisy_speech = 0;
move16();
}
+
/* set bit-allocation */
#if 1 // def ADD_LRTD
+#ifdef NONBE_FIX_GSC_BSTR
+ config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+#else
config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+#endif
#else
config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
#endif
+
/*---------------------------------------------------------------*
* Decode energy dynamics
*---------------------------------------------------------------*/
diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c
index 36246f73923c7b643e2709a7b7fc6faa71ace490..f23c0b7106036dbd7f90b8539e4b9e28c027e5f5 100644
--- a/lib_dec/ivas_binRenderer_internal.c
+++ b/lib_dec/ivas_binRenderer_internal.c
@@ -70,6 +70,7 @@ static void ivas_binRenderer_filterModule_fx(
Word32 *filterStatesLeftRealPtr_fx, *filterStatesLeftImagPtr_fx;
Word16 *Q_filterStates;
const Word32 *filterTapsLeftRealPtr_fx, *filterTapsLeftImagPtr_fx, *filterTapsRightRealPtr_fx, *filterTapsRightImagPtr_fx;
+ Word16 shift_q;
FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ )
{
@@ -87,11 +88,6 @@ static void ivas_binRenderer_filterModule_fx(
FOR( k = 0; k < numTimeSlots; k++ )
{
Word64 outRealLeft_fx = 0, outRealRight_fx = 0, outImagLeft_fx = 0, outImagRight_fx = 0;
- Word64 W_sub1 = 0, W_add1 = 0, W_sub2 = 0, W_add2 = 0;
- move64();
- move64();
- move64();
- move64();
move64();
move64();
move64();
@@ -104,31 +100,32 @@ static void ivas_binRenderer_filterModule_fx(
filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1];
move32();
- W_sub1 = W_sub( W_mult0_32_32( filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ),
- W_mult0_32_32( filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ) ); // Q29 + Q_filterStates[tapIdx - 1]
- W_add1 = W_add( W_mult0_32_32( filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ),
- W_mult0_32_32( filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ) ); // Q29 + Q_filterStates[tapIdx - 1]
- W_sub2 = W_sub( W_mult0_32_32( filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ),
- W_mult0_32_32( filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ) ); // Q29 + Q_filterStates[tapIdx - 1]
- W_add2 = W_add( W_mult0_32_32( filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ),
- W_mult0_32_32( filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ) ); // Q29 + Q_filterStates[tapIdx - 1]
+ shift_q = sub( Q_filterStates[tapIdx], Q_filterStates[tapIdx - 1] );
+ outRealLeft_fx = W_shr( outRealLeft_fx, shift_q );
+ outImagLeft_fx = W_shr( outImagLeft_fx, shift_q );
+ outRealRight_fx = W_shr( outRealRight_fx, shift_q );
+ outImagRight_fx = W_shr( outImagRight_fx, shift_q );
- outRealLeft_fx = W_shr( outRealLeft_fx, sub( Q_filterStates[tapIdx], Q_filterStates[tapIdx - 1] ) );
- outImagLeft_fx = W_shr( outImagLeft_fx, sub( Q_filterStates[tapIdx], Q_filterStates[tapIdx - 1] ) );
- outRealRight_fx = W_shr( outRealRight_fx, sub( Q_filterStates[tapIdx], Q_filterStates[tapIdx - 1] ) );
- outImagRight_fx = W_shr( outImagRight_fx, sub( Q_filterStates[tapIdx], Q_filterStates[tapIdx - 1] ) );
+ outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] );
+ outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates[tapIdx - 1]
- Q_filterStates[tapIdx] = Q_filterStates[tapIdx - 1];
- move16();
+ outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] );
+ outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] );
+
+ outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] );
+ outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsRightImagPtr_fx[tapIdx] );
- /* Left Real and Imag */
- outRealLeft_fx = W_add( outRealLeft_fx, W_sub1 ); // Q29 + Q_filterStates[1]
- outImagLeft_fx = W_add( outImagLeft_fx, W_add1 ); // Q29 + Q_filterStates[1]
+ outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] );
+ outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] );
- /* Right Real and Imag*/
- outRealRight_fx = W_add( outRealRight_fx, W_sub2 ); // Q29 + Q_filterStates[1]
- outImagRight_fx = W_add( outImagRight_fx, W_add2 ); // Q29 + Q_filterStates[1]
+ Q_filterStates[tapIdx] = Q_filterStates[tapIdx - 1];
+ move16();
}
+ shift_q = add( sub( Q_filterStates[1], Q_curr ), 1 );
+ outRealLeft_fx = W_shr( outRealLeft_fx, shift_q );
+ outImagLeft_fx = W_shr( outImagLeft_fx, shift_q );
+ outRealRight_fx = W_shr( outRealRight_fx, shift_q );
+ outImagRight_fx = W_shr( outImagRight_fx, shift_q );
filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx];
move32();
@@ -141,27 +138,29 @@ static void ivas_binRenderer_filterModule_fx(
/* Left Real and Imag */
// Q29 + Q_curr
- out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx],
- W_add( W_shr( outRealLeft_fx, sub( Q_filterStates[1], Q_curr ) ),
- W_sub( W_mult0_32_32( filterStatesLeftRealPtr_fx[0], filterTapsLeftRealPtr_fx[0] ),
- W_mult0_32_32( filterStatesLeftImagPtr_fx[0], filterTapsLeftImagPtr_fx[0] ) ) ) ); // Q29
+ Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 );
+ Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 );
+
+
+ outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] );
+ outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( temp2 ), filterTapsLeftImagPtr_fx[0] );
+ out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], outRealLeft_fx ); // Q29
move64();
- out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx],
- W_add( W_shr( outImagLeft_fx, sub( Q_filterStates[1], Q_curr ) ),
- W_add( W_mult0_32_32( filterStatesLeftRealPtr_fx[0], filterTapsLeftImagPtr_fx[0] ),
- W_mult0_32_32( filterStatesLeftImagPtr_fx[0], filterTapsLeftRealPtr_fx[0] ) ) ) ); // Q29
+
+ outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] );
+ outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] );
+ out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], outImagLeft_fx ); // Q29
move64();
/* Right Real and Imag */
- out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx],
- W_add( W_shr( outRealRight_fx, sub( Q_filterStates[1], Q_curr ) ),
- W_sub( W_mult0_32_32( filterStatesLeftRealPtr_fx[0], filterTapsRightRealPtr_fx[0] ),
- W_mult0_32_32( filterStatesLeftImagPtr_fx[0], filterTapsRightImagPtr_fx[0] ) ) ) ); // Q29
+ outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] );
+ outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( temp2 ), filterTapsRightImagPtr_fx[0] );
+ out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], outRealRight_fx ); // Q29
move64();
- out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx],
- W_add( W_shr( outImagRight_fx, sub( Q_filterStates[1], Q_curr ) ),
- W_add( W_mult0_32_32( filterStatesLeftRealPtr_fx[0], filterTapsRightImagPtr_fx[0] ),
- W_mult0_32_32( filterStatesLeftImagPtr_fx[0], filterTapsRightRealPtr_fx[0] ) ) ) ); // Q29
+
+ outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] );
+ outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] );
+ out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], outImagRight_fx ); // Q29
move64();
}
}
diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c
index c7893c88d1f66dfa58341f187344a38329ed61bc..8d88074a835df6e35864fd37d80a0641b7551910 100644
--- a/lib_dec/ivas_core_dec.c
+++ b/lib_dec/ivas_core_dec.c
@@ -574,7 +574,9 @@ ivas_error ivas_core_dec_fx(
st->cldfbSyn->Q_cldfb_state = Q11;
move16();
}
+#ifndef FIX_ISSUE_1279 /* the update of prev_Q_syn is already done inside rescale_mem( ) */
st->prev_Q_syn = st->Q_syn;
+#endif
move16();
IF( save_hb_synth_32_fx )
diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c
index 5aa649ecda5e1fe8388321724dac753b47b0d351..fd039fe965fd2a8f87867d037f31f73ec8267f3a 100644
--- a/lib_dec/ivas_dirac_output_synthesis_cov.c
+++ b/lib_dec/ivas_dirac_output_synthesis_cov.c
@@ -410,8 +410,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx(
const Word16 nchan_in /* i : number of input channels */
)
{
- Word16 cx_init_e;
- Word16 cx_init_imag_e;
Word16 band_idx, ch_idx;
Word16 brange[2];
Word32 real_in_buffer_fx[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * MAX_TRANSPORT_CHANNELS];
@@ -421,10 +419,9 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx(
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 output_e;
- Word16 i, j, tmp1, tmp2, tmp1_e, tmp2_e, shift_imag, shift_real;
- Word32 L_tmp;
+ Word16 tmp1_e, tmp2_e, shift_imag, shift_real;
Word16 band, num_bands;
-
+ Word16 cx_fx_norm, cx_imag_fx_norm;
/* estimate input covariance */
/* Already stack here instead of in the process_subframe */
@@ -451,8 +448,11 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx(
move16();
imag_in_e = ImagBuffer_e;
move16();
- shift_real = sub( L_norm_arr( real_in_buffer_fx, imult1616( num_bands, nchan_in ) ), find_guarded_bits_fx( add( num_bands, 1 ) ) );
- shift_imag = sub( L_norm_arr( imag_in_buffer_fx, imult1616( num_bands, nchan_in ) ), find_guarded_bits_fx( add( num_bands, 1 ) ) );
+
+ Word16 buf_len = imult1616( num_bands, nchan_in );
+
+ shift_real = sub( L_norm_arr( real_in_buffer_fx, buf_len ), find_guarded_bits_fx( add( num_bands, 1 ) ) );
+ shift_imag = sub( L_norm_arr( imag_in_buffer_fx, buf_len ), find_guarded_bits_fx( add( num_bands, 1 ) ) );
real_in_e = sub( real_in_e, shift_real );
imag_in_e = sub( imag_in_e, shift_imag );
@@ -460,50 +460,23 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx(
output_e = s_max( real_in_e, imag_in_e );
- FOR( i = 0; i < num_bands * nchan_in; ++i )
- {
- real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], sub( output_e, RealBuffer_e ) ); // Q(31-output_e)
- move32();
- imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], sub( output_e, ImagBuffer_e ) ); // Q(31-output_e)
- move32();
- }
+ scale_sig32( real_in_buffer_fx, buf_len, sub( RealBuffer_e, output_e ) );
+ scale_sig32( imag_in_buffer_fx, buf_len, sub( ImagBuffer_e, output_e ) );
cmplx_matrix_square_fx( real_in_buffer_fx, imag_in_buffer_fx, num_bands, nchan_in, real_buffer_fx, imag_buffer_fx, output_e, &output_e );
v_add_fixed_me( cx_fx, *cx_e, real_buffer_fx, output_e, cx_fx, &tmp1_e, imult1616( nchan_in, nchan_in ), 1 );
v_add_fixed_me( cx_imag_fx, *cx_imag_e, imag_buffer_fx, output_e, cx_imag_fx, &tmp2_e, imult1616( nchan_in, nchan_in ), 1 );
- cx_init_e = tmp1_e;
- move16();
- cx_init_imag_e = tmp2_e;
- move16();
- // normalizing both the matrices to a common exponent for a better precision
- tmp1 = 0;
- move16();
- tmp2 = 0;
- move16();
-
- FOR( j = 0; j < PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS; j++ )
- {
- L_tmp = BASOP_Util_Add_Mant32Exp( cx_fx[j], cx_init_e, 0, 0, &tmp1_e );
- L_tmp = BASOP_Util_Add_Mant32Exp( cx_imag_fx[j], cx_init_imag_e, 0, 0, &tmp2_e );
- tmp1 = s_max( tmp1, tmp1_e );
- tmp2 = s_max( tmp2, tmp2_e );
- }
+ cx_fx_norm = L_norm_arr( cx_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS );
+ cx_imag_fx_norm = L_norm_arr( cx_imag_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS );
- FOR( j = 0; j < PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS; j++ )
- {
- L_tmp = BASOP_Util_Add_Mant32Exp( cx_fx[j], cx_init_e, 0, 0, &tmp1_e );
- cx_fx[j] = L_shr( L_tmp, sub( tmp1, tmp1_e ) ); // Q(31-tmp1)
- move32();
- L_tmp = BASOP_Util_Add_Mant32Exp( cx_imag_fx[j], cx_init_imag_e, 0, 0, &tmp2_e );
- cx_imag_fx[j] = L_shr( L_tmp, sub( tmp2, tmp2_e ) ); // Q(31-tmp2)
- move32();
- }
+ scale_sig32( cx_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS, cx_fx_norm );
+ scale_sig32( cx_imag_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS, cx_imag_fx_norm );
- *cx_e = tmp1;
+ *cx_e = sub( tmp1_e, cx_fx_norm );
move16();
- *cx_imag_e = tmp2;
+ *cx_imag_e = sub( tmp2_e, cx_imag_fx_norm );
move16();
return;
diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c
index 33a71fbcfd89437da2f31bd98966ae753e502013..a8cda4e586b1a8beb122949a36bc295b0787810b 100644
--- a/lib_dec/ivas_mct_dec.c
+++ b/lib_dec/ivas_mct_dec.c
@@ -86,6 +86,10 @@ ivas_error ivas_mct_dec_fx(
set16_fx( x_len[0], 0, NB_DIV );
set16_fx( x_len[1], 0, NB_DIV );
Decoder_State **sts;
+#ifdef NONBE_FIX_1087_OOB_SBA_DTX_RS
+ Word32 *p_output_orig_fx[2];
+ Word32 synth_32_fx[CPE_CHANNELS][L_FRAME_PLUS];
+#endif
Word16 synth_fx[CPE_CHANNELS][L_FRAME_PLUS]; //(Q_synth)
Word32 ivas_total_brate;
ivas_error error;
@@ -162,6 +166,18 @@ ivas_error ivas_mct_dec_fx(
/* MCT side bits decoder */
ivas_mct_side_bits_fx( hMCT, st_ivas->hCPE, nCPE, st_ivas->hCPE[0]->hCoreCoder[0], st_ivas->bfi, st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream, ivas_total_brate, nb_bits_metadata );
+#ifdef NONBE_FIX_1087_OOB_SBA_DTX_RS
+ /* in case of switching from an SID frame (with ACELP core) to MCT, buffer of L_FRAME_PLUS samples is needed -> use synth[] as a temporary buffer */
+ IF( st_ivas->hCPE[0]->hCoreCoder[0]->last_core == ACELP_CORE )
+ {
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ p_output_orig_fx[n] = output_fx[n];
+ output_fx[n] = synth_32_fx[n];
+ }
+ }
+#endif
+
FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect = s_or( st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect, st_ivas->BER_detect );
@@ -371,6 +387,18 @@ ivas_error ivas_mct_dec_fx(
}
}
+#ifdef NONBE_FIX_1087_OOB_SBA_DTX_RS
+ /* set pointers back */
+ test();
+ IF( cpe_id == 0 && st_ivas->hCPE[0]->hCoreCoder[0]->last_core == ACELP_CORE )
+ {
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ output_fx[n] = p_output_orig_fx[n];
+ }
+ }
+
+#endif
/*----------------------------------------------------------------*
* CoreCoder Post-processing and updates
diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c
index 216888fbe0a87dbe439801dfacb57441400b2bad..5867a44b329a51b5356927c330fc8339ca9886a8 100644
--- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c
+++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c
@@ -1241,6 +1241,13 @@ void ivas_sba_dirac_stereo_dec_fx(
CPE_DEC_HANDLE hCPE;
STEREO_DFT_DEC_DATA_HANDLE hStereoDft;
+#ifdef MSAN_FIX
+ FOR( Word16 i = 0; i < CPE_CHANNELS; i++ )
+ {
+ set32_fx( DFT[i], 0, STEREO_DFT_BUF_MAX );
+ }
+#endif
+
hSCE = st_ivas->hSCE[0];
hCPE = st_ivas->hCPE[0];
hStereoDft = hCPE->hStereoDft;
diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c
index f76961ebed1d0486a52e9a4d1bb93b73d39ee082..0bdc62756cab45407c59c830e401153464d0557f 100644
--- a/lib_dec/ivas_spar_decoder.c
+++ b/lib_dec/ivas_spar_decoder.c
@@ -1160,6 +1160,10 @@ void ivas_spar_get_parameters_fx(
split_band = SPAR_DIRAC_SPLIT_START_BAND;
move16();
+#ifdef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_MADD_ADD_WEIGHTS
+ Word16 add_weight_fx = sub( MAX_WORD16, weight_fx );
+ Word16 add_weight_20ms_fx = sub( MAX_WORD16, weight_20ms_fx );
+#endif
FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
{
FOR( out_ch = 0; out_ch < num_ch_out; out_ch++ )
@@ -1174,9 +1178,13 @@ void ivas_spar_get_parameters_fx(
{
IF( GT_16( hSpar->i_subframe, 3 ) )
{
-
+#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_MADD_ADD_WEIGHTS
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 ) ); /*hSpar->hMdDec->Q_mixer_mat*/
+#else
+ par_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[ts1][out_ch][in_ch][spar_band], weight_fx ),
+ hSpar->hMdDec->mixer_mat_prev_fx[ts0][out_ch][in_ch][spar_band], add_weight_fx );
+#endif
move32();
}
ELSE
@@ -1193,7 +1201,12 @@ void ivas_spar_get_parameters_fx(
/* 20ms Transport channel reconstruction with matching encoder/decoder processing */
Word16 prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */
move16();
+#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_MADD_ADD_WEIGHTS
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 ) ); /*hSpar->hMdDec->Q_mixer_mat*/
+#else
+ par_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[prev_idx][out_ch][in_ch][spar_band], add_weight_20ms_fx ),
+ hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band], weight_20ms_fx ); /*hSpar->hMdDec->Q_mixer_mat*/
+#endif
move32();
}
}
@@ -1353,10 +1366,17 @@ static void ivas_spar_calc_smooth_facs_fx(
smooth_long_avg_fx[b] = L_add( smooth_long_avg_fx[b], smooth_buf_fx[b][i] ); // Q0
move32();
}
+#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_HQ_CONSTANTS
smooth_short_avg_fx[b] = Mpy_32_16_1( smooth_short_avg_fx[b], 5461 /*(1/6 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();
+#else
+ smooth_short_avg_fx[b] = Mpy_32_32( smooth_short_avg_fx[b], 357913941 /*(1/6 in Q31)*/ ); // Q0
+ move32();
+ smooth_long_avg_fx[b] = Mpy_32_32( smooth_long_avg_fx[b], 107374182 /*(1/20 in Q31)*/ ); // Q0
+ move32();
+#endif
/* calculate smoothing factor based on energy averages */
/* reduce factor for higher short-term energy */
@@ -1846,6 +1866,9 @@ void ivas_spar_dec_upmixer_sf_fx(
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 );
}
+#ifdef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_UNIQUE_SHL
+ Word16 sh_l = sub( 31, q1 );
+#endif
FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ )
{
md_idx = hSpar->render_to_md_map[( ts + slot_idx_start )]; /*Q0*/
@@ -1873,7 +1896,7 @@ void ivas_spar_dec_upmixer_sf_fx(
}
}
}
-
+#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SPLIT_LOOPS
FOR( cldfb_band = 0; cldfb_band < num_cldfb_bands; cldfb_band++ )
{
Word32 out_re_fx[IVAS_SPAR_MAX_CH];
@@ -1921,13 +1944,116 @@ 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++ )
{
+#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_UNIQUE_SHL
+ 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();
+#else
+ cldfb_in_ts_re_fx[out_ch][ts][cldfb_band] = L_shl( out_re_fx[out_ch], sh_l ); /*Q=6*/
+ move32();
+ cldfb_in_ts_im_fx[out_ch][ts][cldfb_band] = L_shl( out_im_fx[out_ch], sh_l ); /*Q=6*/
+ move32();
+#endif
+ }
+ }
+#else /* FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SPLIT_LOOPS */
+ /* Note: This version splits the cldfb band loop into 2 loops, removing some inner-loop IF_statements */
+ Word16 min_cldf_band = s_min( CLDFB_PAR_WEIGHT_START_BAND, num_cldfb_bands );
+ Word32 out_re_fx[IVAS_SPAR_MAX_CH];
+ Word32 out_im_fx[IVAS_SPAR_MAX_CH];
+ Word32 cldfb_par_fx; /*q1*/
+ ivas_fb_bin_to_band_data_t *bin2band = &hSpar->hFbMixer->pFb->fb_bin_to_band;
+
+ /* First loop from cldfb_band=0 till min_cldf_band (CLDFB_PAR_WEIGHT_START_BAND) */
+ FOR( cldfb_band = 0; cldfb_band < min_cldf_band; cldfb_band++ )
+ {
+ spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band]; /*Q0*/
+ move16();
+ 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( b_skip_mat[out_ch][in_ch] == 0 )
+ {
+ cldfb_par_fx = mixer_mat_fx[out_ch][in_ch][spar_band]; /*q1*/
+ move32();
+ 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();
+ }
+ }
+ }
+ /*update CLDFB data with the parameter-modified data*/
+ FOR( out_ch = 0; out_ch < numch_out; out_ch++ )
+ {
+#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_UNIQUE_SHL
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();
+#else
+ cldfb_in_ts_re_fx[out_ch][ts][cldfb_band] = L_shl( out_re_fx[out_ch], sh_l ); /*Q=6*/
+ move32();
+ cldfb_in_ts_im_fx[out_ch][ts][cldfb_band] = L_shl( out_im_fx[out_ch], sh_l ); /*Q=6*/
+ move32();
+#endif
}
}
+
+ /* Second loop from min_cldf_band (CLDFB_PAR_WEIGHT_START_BAND) till num_cldfb_bands */
+ FOR( ; cldfb_band < num_cldfb_bands; cldfb_band++ )
+ {
+ FOR( out_ch = 0; out_ch < numch_out; out_ch++ )
+ {
+ Word32 Out_re_fx = L_add( 0, 0 );
+ Word32 Out_im_fx = L_add( 0, 0 );
+ FOR( in_ch = 0; in_ch < numch_in; in_ch++ )
+ {
+ IF( b_skip_mat[out_ch][in_ch] == 0 )
+ {
+ Word64 acc = 0;
+ move64();
+
+ 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 */
+ acc = W_mac_32_32( acc, mixer_mat_fx[out_ch][in_ch][spar_band], bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band] ); // q1+ Q23
+ }
+ cldfb_par_fx = W_shl_sat_l( acc, -23 ); // q1
+ Out_re_fx = Madd_32_32( Out_re_fx, cldfb_in_ts_re_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); /*q1-25*/
+ Out_im_fx = Madd_32_32( Out_im_fx, cldfb_in_ts_im_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); /*q1-25*/
+ }
+ }
+ out_re_fx[out_ch] = Out_re_fx;
+ out_im_fx[out_ch] = Out_im_fx;
+ }
+
+ /*update CLDFB data with the parameter-modified data*/
+ FOR( out_ch = 0; out_ch < numch_out; out_ch++ )
+ {
+#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_UNIQUE_SHL
+ 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();
+#else
+ cldfb_in_ts_re_fx[out_ch][ts][cldfb_band] = L_shl( out_re_fx[out_ch], sh_l ); /*Q=6*/
+ move32();
+ cldfb_in_ts_im_fx[out_ch][ts][cldfb_band] = L_shl( out_im_fx[out_ch], sh_l ); /*Q=6*/
+ move32();
+#endif
+ }
+ }
+#endif /* FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SPLIT_LOOPS */
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[( ( slot_idx_start + ts ) + 1 )] / JBM_CLDFB_SLOTS_IN_SUBFRAME /*It's value is 4*/ ) ) ) )
{
diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c
index df5f1569642e076f3296a73ae6947e2ba680cbe6..2ad6085cacc8d56c3d07595aecc3c4c6605599f4 100644
--- a/lib_dec/ivas_stereo_cng_dec.c
+++ b/lib_dec/ivas_stereo_cng_dec.c
@@ -683,7 +683,12 @@ static void stereo_dft_generate_comfort_noise_fx(
factor = L_min( L_add( L_shl( hStereoDft->scale_fx, sub( 16, q_div ) ), W_extract_l( W_mult0_32_32( Mpy_32_16_1( L_sub( factor, L_shl( hStereoDft->scale_fx, sub( 16, q_div ) ) ), ONE_BY_MAX_K ), hStereoCng->xfade_frame_counter ) ) ), factor ); /* q_div */
FOR( ; j <= hFdCngCom->part[k]; j++ )
{
+#ifdef FIX_ISSUE_1218
+ /* NOTE: saturation is added here as part of issue 1218 fix. After rescaling the fdcng noise estimation buffers, due to slight precision loss, values may slightly overflow */
+ hFdCngCom->cngNoiseLevel[j] = L_shl_sat( Mpy_32_32( st->hFdCngDec->bandNoiseShape[j], factor ), q_div ); /* exp(st->hFdCngDec->bandNoiseShape_exp) */
+#else
hFdCngCom->cngNoiseLevel[j] = L_shl( Mpy_32_32( st->hFdCngDec->bandNoiseShape[j], factor ), q_div ); /* exp(st->hFdCngDec->bandNoiseShape_exp) */
+#endif
move32();
}
}
diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c
index bcebc8008db090785eb50caa40978f768bb0b0ad..3014dba06971afa80909ec046bd93187939fbfc9 100644
--- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c
+++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c
@@ -542,7 +542,7 @@ void stereo_mdct_core_dec_fx(
move16();
}
}
-#ifdef FIX_ISSUE_1237 // VA2ITTIAM -> This ( 28 - norm_s( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0] - 1 ) ) is not working, leads to a left shit of 25 and old_Aq_12_8_fx[0] usually takes between 10 and 14 bits; should be something like (28 - (15 - norm_s(A[0]-1))
+#ifdef FIX_ISSUE_1237
Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, M + 1, sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); /* Q28 */
Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, M + 1, sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); /* Q28 */
#else
diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c
index 5d5b38d4dfdc1cb85b342be846f66093d087bf84..ad6d58ebf5b981554a089a2a5023544c0dfda4bb 100644
--- a/lib_dec/ivas_stereo_switching_dec.c
+++ b/lib_dec/ivas_stereo_switching_dec.c
@@ -503,7 +503,7 @@ ivas_error stereo_memory_dec_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) );
}
- td_cng_dec_init_fx( st );
+ td_cng_dec_init_ivas_fx( st );
}
}
diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c
index dc1965a5bdea4de61cb93bfb53464cf6b3c7ccf9..77cf192c27a8fe3711b310e79523641be58fe99f 100644
--- a/lib_dec/ivas_svd_dec.c
+++ b/lib_dec/ivas_svd_dec.c
@@ -912,13 +912,56 @@ static void ApplyRotation_fx(
)
{
Word16 ch;
- 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 ); /* exp(d_e) */
move32();
*g = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), add( c_e, x12_e ), Mpy_32_32( L_negate( s ), x11 ), add( s_e, x11_e ), g_e ); /* exp(g_e) */
move32();
+#ifdef SVD_WMOPS_OPT
+ Word16 c_q = sub( 31, c_e );
+ Word16 s_q = sub( 31, s_e );
+ Word32 op1, op2;
+ Word16 op_e;
+
+ // Bring c and s to same Q
+ IF( GT_16( c_q, s_q ) )
+ {
+ op1 = L_shr( c, sub( c_q, s_q ) );
+ op2 = s;
+ move32();
+ op_e = s_q;
+ move16();
+ }
+ ELSE
+ {
+ op1 = c;
+ move32();
+ op2 = L_shr( s, sub( s_q, c_q ) );
+ op_e = c_q;
+ move16();
+ }
+ op_e = add( op_e, 1 ); // 64 bit mac -> +1
+
+ FOR( ch = 0; ch < nChannels; ch++ )
+ {
+ x11 = singularVector[ch][currentIndex2];
+ move32();
+ x12 = singularVector[ch][currentIndex1];
+ move32();
+
+ Word64 temp = W_mac_32_32( W_mult_32_32( op1, x11 ), op2, x12 ); // Q(singularVector) + op_e
+ temp = W_shr( temp, op_e ); // Q(singularVector)
+ singularVector[ch][currentIndex2] = W_sat_l( temp ); // Q(singularVector)
+ move32();
+
+ temp = W_mac_32_32( W_mult_32_32( op1, x12 ), L_negate( op2 ), x11 ); // Q(singularVector) + op_e
+ temp = W_shr( temp, op_e ); // Q(singularVector)
+ singularVector[ch][currentIndex1] = W_sat_l( temp ); // Q(singularVector)
+ move32();
+ }
+#else
+#ifndef FIX_MINOR_SVD_WMOPS_MR1010X
FOR( ch = 0; ch < nChannels; ch++ )
{
x11 = singularVector[ch][currentIndex2];
@@ -934,6 +977,25 @@ static void ApplyRotation_fx(
singularVector[ch][currentIndex1] = L_shl_sat( singularVector[ch][currentIndex1], temp_exp ); /* exp(temp_exp) */
move32();
}
+#else
+ Word32 s_neg = L_negate( s );
+ Word32 temp;
+ FOR( ch = 0; ch < nChannels; ch++ )
+ {
+ x11 = singularVector[ch][currentIndex2];
+ move32();
+ x12 = singularVector[ch][currentIndex1];
+ move32();
+ temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x11 ), c_e, Mpy_32_32( s, x12 ), s_e, &temp_exp ); /* exp(temp_exp) */
+ singularVector[ch][currentIndex2] = L_shl_sat( temp, temp_exp ); /* exp(temp_exp) */
+ move32();
+ temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), c_e, Mpy_32_32( s_neg, x11 ), s_e, &temp_exp ); /* exp(temp_exp) */
+ singularVector[ch][currentIndex1] = L_shl_sat( temp, temp_exp ); /* exp(temp_exp) */
+ move32();
+ }
+
+#endif
+#endif
return;
}
@@ -1140,7 +1202,7 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */
#ifndef FIX_1010_OPT_SINGLE_RESCALE
sing_exp[jCh] = sub( add( invVal_e, sub( *singularVectors_e, *sig_x_e ) ), temp_e );
move16();
- norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sing_exp[jCh], 1 ), &norm_x_e ); /* exp(norm_x_e) */
+ norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sing_exp[jCh], 1 ), &norm_x_e ); /* exp(norm_x_e) */
#else
singularVectors2_e[jCh][currChannel] = sub( add( invVal_e, sub( singularVectors2_e[jCh][currChannel], *sig_x_e ) ), temp_e );
move16();
@@ -1159,7 +1221,8 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */
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 ) );
+#ifndef FIX_MINOR_SVD_WMOPS_MR1010X
IF( singularVectors[currChannel][idx] >= 0 )
{
( *g ) = L_negate( L_temp );
@@ -1170,6 +1233,14 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */
( *g ) = L_negate( L_negate( L_temp ) );
move32();
}
+#else
+ if ( singularVectors[currChannel][idx] >= 0 )
+ {
+ L_temp = L_negate( L_temp );
+ }
+ ( *g ) = L_temp;
+ move32();
+#endif
#ifndef FIX_1010_OPT_SINGLE_RESCALE
r = BASOP_Util_Add_Mant32Exp( Mpy_32_32( ( *g ), singularVectors[currChannel][idx] ), sing_exp[currChannel], -norm_x, norm_x_e, &r_e ); /* exp(r_e) */
@@ -1577,26 +1648,43 @@ static void singularVectorsAccumulationLeft_fx(
t_ii = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, maxWithSign_fx( t_ii ), &temp_exp ); /* exp(1 + (temp_exp + tii_e)) */
t_ii_e = add( 1, sub( temp_exp, t_ii_e ) );
#endif
+ Word16 tempe;
+ Word32 temp = BASOP_Util_Divide3232_Scale_cadence( t_ii, maxWithSign_fx( singularVectors_Left[nCh][nCh] ), &tempe );
+ tempe = add( tempe, sub( t_ii_e, singularVectors_Left_e[nCh][nCh] ) );
// fprintf( fp, "%e\n", me2f( t_ii, t_ii_e ) );
FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */
{
- norm_y = 0;
- move32();
- norm_y_e = 0;
+ Word64 acc = 0;
+ move64();
+ Word64 prod[16];
+ Word16 prod_e[16];
+ Word16 max_e = -31;
move16();
FOR( k = nCh + 1; k < nChannelsL; k++ ) /* nChannelsL */
{
#ifndef FIX_1010_OPT_SINGLE_RESCALE
norm_y = BASOP_Util_Add_Mant32Exp( norm_y, norm_y_e, Mpy_32_32( singularVectors_Left[k][nCh], singularVectors_Left[k][iCh] ), add( sing_exp2[k][nCh], sing_exp2[k][iCh] ), &norm_y_e ); /* exp(norm_y_e) */
#else
- norm_y = BASOP_Util_Add_Mant32Exp( norm_y, norm_y_e, Mpy_32_32( singularVectors_Left[k][nCh], singularVectors_Left[k][iCh] ), add( singularVectors_Left_e[k][nCh], singularVectors_Left_e[k][iCh] ), &norm_y_e ); /* exp(norm_y_e) */
+ prod[k] = W_mult0_32_32( singularVectors_Left[k][nCh], singularVectors_Left[k][iCh] );
+ prod_e[k] = add( singularVectors_Left_e[k][nCh], singularVectors_Left_e[k][iCh] );
+ max_e = s_max( max_e, prod_e[k] );
#endif
}
- t_jj = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_32( t_ii, norm_y ), maxWithSign_fx( singularVectors_Left[nCh][nCh] ), &temp_exp ); // t_ii_e+norm_y_e-*singularVectors_e,
+
+ FOR( k = nCh + 1; k < nChannelsL; k++ ) /* nChannelsL */
+ {
+ acc = W_add( acc, W_shr( prod[k], sub( max_e, prod_e[k] ) ) );
+ }
+ Word16 acc_e = W_norm( acc );
+ acc = W_shl( acc, acc_e );
+
+ norm_y = W_extract_h( acc );
+ norm_y_e = add( sub( max_e, acc_e ), 1 );
+ t_jj = Mpy_32_32( temp, norm_y );
#ifndef FIX_1010_OPT_SINGLE_RESCALE
t_jj_e = add( temp_exp, sub( add( t_ii_e, norm_y_e ), sing_exp2[nCh][nCh] ) );
#else
- t_jj_e = add( temp_exp, sub( add( t_ii_e, norm_y_e ), singularVectors_Left_e[nCh][nCh] ) );
+ t_jj_e = add( tempe, norm_y_e );
#endif
FOR( k = nCh; k < nChannelsL; k++ ) /* nChannelsL */
{
@@ -1868,6 +1956,7 @@ static Word32 maxWithSign_fx(
const Word32 a /* Qx */
)
{
+#ifndef FIX_MINOR_SVD_WMOPS_MR1010X
IF( GT_32( L_abs( a ), SVD_MINIMUM_VALUE_FX ) )
{
return a;
@@ -1880,6 +1969,18 @@ static Word32 maxWithSign_fx(
{
return SVD_MINIMUM_VALUE_FX;
}
+#else
+ Word32 result;
+ IF( a >= 0 )
+ {
+ result = L_max( a, SVD_MINIMUM_VALUE_FX );
+ }
+ ELSE
+ {
+ result = L_min( a, -SVD_MINIMUM_VALUE_FX );
+ }
+ return result;
+#endif
}
/*-------------------------------------------------------------------------
diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c
index 8f63c6612dafe59660fd8fe46f204c58fea119de..a294d12da8764c3177b6097a5d046fa52f84734c 100644
--- a/lib_enc/acelp_core_enc_fx.c
+++ b/lib_enc/acelp_core_enc_fx.c
@@ -156,7 +156,7 @@ ivas_error acelp_core_enc_fx(
st_fx->Nb_ACELP_frames = 0;
move16();
}
- st_fx->Nb_ACELP_frames = add( st_fx->Nb_ACELP_frames, 1 ); // Q0
+ st_fx->Nb_ACELP_frames = add_sat( st_fx->Nb_ACELP_frames, 1 ); // Q0
move16();
int_fs_fx = INT_FS_16k_FX;
@@ -402,7 +402,11 @@ 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,
+#ifdef NONBE_FIX_GSC_BSTR
+ st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag,
+#else
st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type,
+#endif
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 );
}
@@ -538,7 +542,11 @@ ivas_error acelp_core_enc_fx(
tc_classif_enc_fx( Q_new, st_fx->L_frame, &tc_subfr_fx, &position, attack_flag, st_fx->pitch[0], res_fx );
config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
+#ifdef NONBE_FIX_GSC_BSTR
+ -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag,
+#else
-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,
+#endif
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 );
}
@@ -605,7 +613,11 @@ 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,
+#ifdef NONBE_FIX_GSC_BSTR
+ -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0,
+#else
-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,
+#endif
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 */
@@ -967,7 +979,7 @@ ivas_error acelp_core_enc_ivas_fx(
st->Nb_ACELP_frames = 0;
move16();
}
- st->Nb_ACELP_frames = add( st->Nb_ACELP_frames, 1 );
+ st->Nb_ACELP_frames = add_sat( st->Nb_ACELP_frames, 1 );
move16();
IF( EQ_16( st->L_frame, L_FRAME ) )
@@ -1102,15 +1114,6 @@ ivas_error acelp_core_enc_ivas_fx(
/* update Aw[] coefficients */
weight_a_subfr_fx( shr( st->L_frame, 6 ), A, Aw, st->gamma, M );
}
- IF( st->hLPDmem )
- {
- st->hLPDmem->q_mem_syn = sub( Q_new, 1 );
- move16();
- st->hLPDmem->q_lpd_old_exc = Q_new;
- move16();
- st->hLPDmem->q_lpd_syn = Q_new;
- move16();
- }
test();
test();
@@ -1276,7 +1279,11 @@ ivas_error acelp_core_enc_ivas_fx(
test();
IF( !nelp_mode && !ppp_mode )
{
+#ifdef NONBE_FIX_GSC_BSTR
+ config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+#else
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
}
/*-----------------------------------------------------------------*
@@ -1370,6 +1377,7 @@ ivas_error acelp_core_enc_ivas_fx(
move16();
PREEMPH_FX( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF_fx );
Copy( hLPDmem->old_exc + sub( st->L_frame, M ), hLPDmem->mem_syn, M ); /* Q_new */
+ Scale_sig( st->hLPDmem->mem_syn, M, sub( st->hLPDmem->q_mem_syn, Q_new ) );
Residu3_fx( Aq, hLPDmem->old_exc, old_exc_fx, st->L_frame, 0 );
}
@@ -1413,7 +1421,11 @@ ivas_error acelp_core_enc_ivas_fx(
{
tc_classif_enc_fx( Q_new, st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res_fx );
+#ifdef NONBE_FIX_GSC_BSTR
+ config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+#else
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 );
+#endif
}
/*---------------------------------------------------------------*
@@ -1470,8 +1482,13 @@ ivas_error acelp_core_enc_ivas_fx(
{
/* restore memories of LSF quantizer and synthesis filter */
lsf_syn_mem_restore_ivas_fx( st, tilt_code_bck_fx, gc_threshold_bck_fx, clip_var_bck_fx, next_force_sf_bck, lsp_new, lsp_mid, clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen );
+
/* Configure ACELP bit allocation */
+#ifdef NONBE_FIX_GSC_BSTR
+ config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+#else
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 );
+#endif
/* redo LSF quantization */
lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new );
diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c
index d521d85a2a936d26c414194cc94c94160004fdfd..47c735a856876adf49d14f4a286e4a2dfded2bf6 100644
--- a/lib_enc/acelp_core_switch_enc_fx.c
+++ b/lib_enc/acelp_core_switch_enc_fx.c
@@ -148,8 +148,13 @@ 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,
+#ifdef NONBE_FIX_GSC_BSTR
+ GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
+#else
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*/ );
+#endif
encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new );
@@ -271,8 +276,13 @@ void acelp_core_switch_enc_ivas_fx(
/*----------------------------------------------------------------*
* Excitation encoding
*----------------------------------------------------------------*/
+
config_acelp1_IVAS( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
+#ifdef NONBE_FIX_GSC_BSTR
+ GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
+#else
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*/ );
+#endif
encod_gen_voic_core_switch_ivas_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new );
diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c
index d31f2ff089176cd3403b5b615ac7c4d967ac75eb..c0d1a8bcae8997c2e8e67c3ac7cb7464efad5dcc 100644
--- a/lib_enc/analy_sp_fx.c
+++ b/lib_enc/analy_sp_fx.c
@@ -476,6 +476,8 @@ void ivas_analy_sp_fx(
Word32 Ltmp;
Word16 *pt_fft;
Word16 exp, tmp;
+ Word16 resultant_q;
+ Word16 exp2;
Word64 LEtot;
LEtot = 0;
move64();
@@ -508,9 +510,7 @@ void ivas_analy_sp_fx(
}
ELSE
{
- Word16 scale = norm_arr( speech + 3 * ( L_SUBFR / 2 ) - L_FFT / 2, L_FFT + 4 * ( L_SUBFR / 2 ) );
- scale = sub( scale, LOG2_L_FFT ); // guard_bits
- *q_fft_buff = add( Q_new, scale );
+ Word16 scale = 0;
move16();
FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
@@ -541,11 +541,25 @@ void ivas_analy_sp_fx(
move16();
}
- scale_sig( pt_fft, L_FFT, scale );
-
/* compute the spectrum */
- fft_rel_fx( pt_fft, L_FFT, LOG2_L_FFT );
-
+ fft_rel_16_32fx( pt_fft, &scale, i_subfr, L_FFT, LOG2_L_FFT );
+ *q_fft_buff = add( Q_new, scale ); // resultant q for fft_buff
+ move16();
+ IF( EQ_16( i_subfr, 1 ) )
+ {
+ Word16 new_q_lf_E = add( shl( *q_fft_buff, 1 ), 14 );
+ Word16 new_q_bands = new_q_lf_E;
+ IF( GT_16( new_q_bands, 39 ) )
+ {
+ new_q_bands = 39;
+ move16();
+ }
+ scale_sig32( fr_bands, NB_BANDS, sub( new_q_bands, *q_fr_bands ) );
+ scale_sig32( lf_E, VOIC_BINS, sub( new_q_lf_E, *q_lf_E ) );
+ LEtot = W_shl( LEtot, sub( new_q_bands, *q_fr_bands ) );
+ scale_sig32( Bin_E, L_FFT / 2, sub( new_q_lf_E, *q_lf_E ) );
+ scale_sig32( band_energies, NB_BANDS, sub( new_q_bands, *q_fr_bands ) );
+ }
/* find energy per critical band */
ivas_find_enr( pt_fft, *q_fft_buff, pt_bands, q_fr_bands, lf_E + i_subfr * VOIC_BINS, q_lf_E, &LEtot, min_band, max_band,
&Bin_E[i_subfr * L_FFT / 2], BIN, band_energies + i_subfr * NB_BANDS );
@@ -679,16 +693,12 @@ void ivas_analy_sp_fx(
}
exp = L_norm_arr( Bin_E, L_FFT / 2 );
- IF( GE_16( exp, sub( *q_Bin_E, Q22 ) ) )
- {
- scale_sig32( Bin_E, L_FFT / 2, sub( *q_Bin_E, Q22 ) ); // *q_Bin_E
- }
- ELSE
- {
- scale_sig32( Bin_E + L_FFT / 2, L_FFT / 2, sub( Q22, *q_Bin_E ) ); // Q22
- *q_Bin_E = Q22;
- move16();
- }
+ exp2 = L_norm_arr( Bin_E + L_FFT / 2, L_FFT / 2 );
+ resultant_q = s_min( Q22, s_min( add( *q_Bin_E, exp2 ), add( exp, Q22 ) ) ); // calculating resultant q after scaling
+ scale_sig32( Bin_E, L_FFT / 2, sub( resultant_q, Q22 ) ); // Q22=>resultant_q
+ scale_sig32( Bin_E + L_FFT / 2, L_FFT / 2, sub( resultant_q, *q_Bin_E ) ); // q_Bin_E=>resultant_q
+ *q_Bin_E = resultant_q;
+ move16();
return;
}
diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c
index b97fd7931f5cb8dc056d25b872d23698a121f1e1..98a5173f592f6f5c41fd26316bd5ec30b4d72ede 100644
--- a/lib_enc/arith_coder_enc_fx.c
+++ b/lib_enc/arith_coder_enc_fx.c
@@ -792,3 +792,134 @@ void tcx_arith_encode_envelope_fx(
*nf_seed = extract_l( L_tmp2 );
move16();
}
+
+void tcx_arith_encode_envelope_ivas_fx(
+ Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */
+ Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */
+ Word16 signs[], /* o: signs (spectrum[.]<0) Q0 */
+ const Word16 L_frame, /* i: frame or MDCT length Q0 */
+ const Word16 L_spec, /* i: frame or MDCT length Q0 */
+ Encoder_State *st, /* i/o: coder state */
+ const Word16 A_ind[], /* i: quantised LPC coefficients Q12 */
+ Word16 target_bits, /* i: number of available bits Q0 */
+ Word16 prm[], /* o: bitstream parameters Q0 */
+ const Word8 use_hm, /* i: use HM in current frame? */
+ Word16 prm_hm[], /* o: HM parameter area Q0 */
+ const Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a Q0*/
+ Word16 *arith_bits, /* o: bits used for ari. coding Q0 */
+ Word16 *signaling_bits, /* o: bits used for signaling Q0 */
+ const Word16 low_complexity /* i: low-complexity flag Q0 */
+)
+{
+ Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */
+ Word16 *envelope; /* scaled envelope (Q15-e) */
+ Word16 envelope_e;
+ Word16 exponents[N_MAX_ARI]; /* Q15 */
+ Word16 L_spec_core;
+ Word16 *q_spectrum;
+ TCX_CONFIG_HANDLE hTcxCfg;
+ Word16 scale, scale_e;
+ Word16 k, kMax;
+ Word16 deadzone;
+ const Word8 *deadzone_flags;
+ Word16 gamma_w, gamma_uw;
+ Word16 hm_bits;
+ Word32 L_tmp;
+ Word16 tmp;
+ TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
+
+ assert( L_spec <= N_MAX_ARI );
+
+ hTcxCfg = st->hTcxCfg;
+ deadzone = hTcxCfg->sq_rounding;
+ move16();
+ deadzone_flags = hTcxEnc->memQuantZeros;
+ *signaling_bits = 0;
+ move16();
+
+ assert( st->enableTcxLpc );
+ gamma_w = 32767 /*1.0f Q15*/;
+ move16();
+ gamma_uw = st->inv_gamma;
+ move16();
+
+ tcx_arith_render_envelope( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env );
+
+ FOR( k = 0; k < L_spec; k++ )
+ {
+ signs[k] = extract_l( L_lshr( spectrum[k], 31 ) );
+ move16();
+ if ( spectrum[k] < 0 )
+ {
+ spectrum[k] = L_abs( spectrum[k] );
+ move32();
+ }
+ }
+
+ IF( use_hm != 0 )
+ {
+ tcx_hm_analyse_fx( spectrum, spectrum_e, L_spec, env, target_bits, hTcxCfg->coder_type, prm_hm, tcxltp_pitch, hTcxEnc->tcxltp_gain, &hm_bits );
+
+ target_bits = sub( target_bits, hm_bits );
+ *signaling_bits = add( *signaling_bits, hm_bits );
+ move16();
+ }
+ ELSE
+ {
+ prm_hm[0] = 0; /* just to be sure */
+ move16();
+ hm_bits = 0;
+ move16();
+ }
+
+ L_spec_core = L_spec;
+ move16();
+ if ( st->igf )
+ {
+ L_spec_core = s_min( L_spec_core, st->hIGFEnc->infoStartLine );
+ }
+ envelope = (Word16 *) env;
+
+ tcx_arith_scale_envelope( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e );
+
+ tmp = sub( envelope_e, 1 + 15 );
+ FOR( k = 0; k < L_spec; k++ )
+ {
+ exponents[k] = round_fx( expfp( envelope[k], tmp ) );
+ move16();
+ }
+
+ scale = tcx_arith_rateloop( spectrum, *spectrum_e, L_spec, envelope, envelope_e, exponents, target_bits, deadzone, deadzone_flags, &( hTcxEnc->tcx_target_bits_fac ), &scale_e );
+
+ /* Final quantization */
+ kMax = tcx_arith_find_kMax( spectrum, *spectrum_e, L_spec, scale, scale_e, deadzone, deadzone_flags );
+
+ q_spectrum = (Word16 *) env; /* Reuse buffer */
+
+ L_tmp = L_mult( deadzone, 1 ); /* Q16 */
+ tmp = add( sub( *spectrum_e, 15 ), scale_e );
+ FOR( k = 0; k <= kMax; k++ )
+ {
+ /* quantise using dead-zone */
+ q_spectrum[k] = extract_h( L_add( L_shl( Mpy_32_16_1( spectrum[k], scale ), tmp ), L_tmp ) );
+ move16();
+ }
+
+ /* Final encoding */
+ *arith_bits = tcx_arith_encode( q_spectrum, signs, kMax, L_spec, exponents, target_bits, prm );
+ move16();
+
+ /* Multiply back the signs */
+ FOR( k = 0; k <= kMax; k++ )
+ {
+ if ( signs[k] != 0 )
+ L_tmp = L_mult( q_spectrum[k], -( 1 << ( 30 - SPEC_EXP_DEC ) ) );
+ if ( signs[k] == 0 )
+ L_tmp = L_mult( q_spectrum[k], 1 << ( 30 - SPEC_EXP_DEC ) );
+ spectrum[k] = L_tmp;
+ move32();
+ }
+ *spectrum_e = SPEC_EXP_DEC;
+ move16();
+ set32_fx( spectrum + k, 0, sub( s_max( L_frame, L_spec ), k ) );
+}
diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c
index 8a2495b40c88f53dc790af9667dffb3a8bd4a1e1..4cfc193ecc5785ac74d5b4e0bc75405f86d11176 100644
--- a/lib_enc/cng_enc_fx.c
+++ b/lib_enc/cng_enc_fx.c
@@ -2024,13 +2024,23 @@ void CNG_enc_ivas_fx(
/* convert log2 of residual signal energy */
/*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */
- hi = norm_l( L_ener );
- lo = Log2_norm_lc( L_shl( L_ener, hi ) );
- hi = sub( 29, hi ); /* log2 exp in Q2*Q_new */
- hi = sub( hi, shl( Q_new, 1 ) ); /* Q0 */
- L_tmp = L_Comp( hi, lo ); /* Q16 */
- enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */
+#ifdef FIX_ISSUE_1245
+ IF( L_ener == 0 )
+ {
+ enr = -850; /*log(0.1) base 2 in Q8*/
+ move16();
+ }
+ ELSE
+#endif
+ {
+ hi = norm_l( L_ener );
+ lo = Log2_norm_lc( L_shl( L_ener, hi ) );
+ hi = sub( 29, hi ); /* log2 exp in Q2*Q_new */
+ hi = sub( hi, shl( Q_new, 1 ) ); /* Q0 */
+ L_tmp = L_Comp( hi, lo ); /* Q16 */
+ enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */
+ }
/* update the circular buffer of old energies */
hTdCngEnc->cng_ener_hist_fx[hTdCngEnc->cng_hist_ptr] = enr;
move16(); /* Q8 */
diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast.c
index 93bcc1ce3ffe44ca66128e467dbf5cf03d4c98ac..e4c8124e66180c47e61f9515c82824ba5968f208 100644
--- a/lib_enc/cod4t64_fast.c
+++ b/lib_enc/cod4t64_fast.c
@@ -901,7 +901,7 @@ void acelp_fast_fx(
move16();
}
- Copy( y_tmp, y, L_subfr ); // q_H
+ Copy_Scale_sig( y_tmp, y, L_subfr, sub( 9, q_H ) ); // y in Q9
skip_track_max = skip_track[q];
move16();
}
diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c
index aaa7e4e2e13f01ee0207daa1bad4b3d412ba7824..963cc16506ba70549c08e644f989d7c1d85d9421 100644
--- a/lib_enc/cod_tcx.c
+++ b/lib_enc/cod_tcx.c
@@ -290,7 +290,7 @@ void TNSAnalysisStereo_fx(
Word16 maxEnergyChange_fx;
maxEnergyChange_fx = mac_r( L_mult( GetTCXMaxenergyChange_ivas_fx( sts[0]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ), GetTCXMaxenergyChange_ivas_fx( sts[1]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 );
- IF( GE_16( maxEnergyChange_fx, pTnsParameters[0]->minEnergyChange ) )
+ IF( GE_16( maxEnergyChange_fx, shl( pTnsParameters[0]->minEnergyChange, Q3 - Q7 ) ) )
{
sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 );
move16();
@@ -552,7 +552,7 @@ void TNSAnalysisStereo_fx(
{
Word16 maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( sts[ch]->hTranDet, isTCX10, NSUBBLOCKS, 3 );
- IF( GE_16( maxEnergyChange_fx, pTnsParameters->minEnergyChange ) )
+ IF( GE_16( maxEnergyChange_fx, shl( pTnsParameters->minEnergyChange, Q3 - Q7 ) ) )
{
sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 );
move16();
diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c
index ebec48fa75eccf67034b2c7bae809728a32582b1..b2fe04ce13f5fcb65f8a7abd6a47bba15f06a1c1 100644
--- a/lib_enc/cod_tcx_fx.c
+++ b/lib_enc/cod_tcx_fx.c
@@ -1717,6 +1717,10 @@ void EstimateStereoTCXNoiseLevel_fx(
Word16 *fac_ns_q;
Word32 total_brate;
+#ifdef MSAN_FIX
+ set32_fx( combined_q_spectrum, 0, N_MAX );
+#endif
+
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
Encoder_State *st = sts[ch];
@@ -4192,13 +4196,22 @@ void QuantizeTCXSpectrum_fx(
low_complexiety = 1;
move16();
}
- tcx_arith_encode_envelope_fx( spectrum_fx, spectrum_e, hm_cfg->indexBuffer, L_frame, L_spec, st, Aqind, sqTargetBits, sqQ, tmp8, prm_hm, /* HM parameter area */ LtpPitchLag, &sqBits, &signaling_bits, nf_seed, low_complexiety );
+ tcx_arith_encode_envelope_ivas_fx( spectrum_fx, spectrum_e, hm_cfg->indexBuffer, L_frame, L_spec, st, Aqind, sqTargetBits, sqQ, tmp8, prm_hm, /* HM parameter area */ LtpPitchLag, &sqBits, &signaling_bits, low_complexiety );
sqTargetBits = sub( sqTargetBits, signaling_bits );
*prm_target = sqTargetBits;
move16();
/* Noise filling seed */
+ Word64 seed = 0;
+ move64();
+ FOR( i = 0; i < noiseFillingBorder; ++i )
+ {
+ /* *nf_seed += (int16_t) ( abs( (int16_t) spectrum[i] ) * i * 2 ); */
+ seed = W_mac_32_32( seed, L_abs( spectrum_fx[i] ), i ); // exp: spectrum_e
+ }
+ *nf_seed = extract_l( W_extract_l( W_shr( seed, sub( 31, *spectrum_e ) ) ) ); // Q0
+ move16();
}
*hm_active = prm_hm[0];
diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c
index d82d1b7ff8654dc8f84655987e562665d7209aef..e98956efeec2bcc8ace521c9862022011d4384f1 100644
--- a/lib_enc/core_enc_init.c
+++ b/lib_enc/core_enc_init.c
@@ -63,7 +63,10 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh
void init_coder_ace_plus_ivas_fx(
Encoder_State *st, /* i : Encoder state */
const Word32 last_total_brate, /* i : last total bitrate */
- const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */
+#ifdef FIX_920_IGF_INIT_ERROR
+ const Word32 igf_brate, /* i : IGF configuration bitrate */
+#endif
+ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */
)
{
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
@@ -195,7 +198,11 @@ void init_coder_ace_plus_ivas_fx(
test();
IF( st->igf && st->hIGFEnc != NULL )
{
+#ifdef FIX_920_IGF_INIT_ERROR
+ IGFEncSetMode_ivas_fx( st->hIGFEnc, igf_brate, st->bwidth, st->element_mode, st->rf_mode );
+#else
IGFEncSetMode_ivas_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode );
+#endif
}
ELSE IF( st->hIGFEnc != NULL )
{
@@ -528,8 +535,8 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol
Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM );
// Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) );
-
- /*Resamp buffers needed only for ACELP*/
+ st->exp_buf_wspeech_enc = st->exp_old_wsp;
+ move16(); /*Resamp buffers needed only for ACELP*/
IF( EQ_16( st->L_frame, L_FRAME16k ) )
{
lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM );
diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c
index e5c3903a1789031ba9481c8f483235735965d117..b6f723c2b7dc540a1c204eb613842d4be99b98d7 100644
--- a/lib_enc/core_enc_switch.c
+++ b/lib_enc/core_enc_switch.c
@@ -229,7 +229,11 @@ void core_coder_mode_switch_ivas_fx(
Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift );
st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift );
move16();
+#ifdef FIX_920_IGF_INIT_ERROR
+ init_coder_ace_plus_ivas_fx( st, last_total_brate, st->total_brate, MCT_flag );
+#else
init_coder_ace_plus_ivas_fx( st, last_total_brate, MCT_flag );
+#endif
if ( st->hLPDmem != NULL )
{
st->hLPDmem->q_lpd_old_exc = st->prev_Q_new;
diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c
index d58a60ab26e7f55395ea3d2fc09a63364636e9b0..67c7a552fe18003cab02873410d4dd97b35b78b5 100644
--- a/lib_enc/core_switching_enc.c
+++ b/lib_enc/core_switching_enc.c
@@ -431,7 +431,9 @@ void core_switching_pre_enc_ivas_fx(
move16();
}
hBWE_FD->EnergyLF_fx = 0;
+ hBWE_FD->EnergyLF_exp = 0;
move32();
+ move16();
hBWE_FD->prev_L_swb_norm1 = 8;
move16(); /*8.0 in Q0 */
st_fx->EnergyLT_fx_exp = 30;
diff --git a/lib_enc/decision_matrix_enc_fx.c b/lib_enc/decision_matrix_enc_fx.c
index 2ebb7289a2196a79839f2a2021cec8d13b32f608..3624cf37463b4f56b24b40fb5660b567a406ced2 100644
--- a/lib_enc/decision_matrix_enc_fx.c
+++ b/lib_enc/decision_matrix_enc_fx.c
@@ -386,6 +386,21 @@ void decision_matrix_enc_fx(
move16();
}
+#ifdef NONBE_FIX_GSC_BSTR
+ /*-----------------------------------------------------------------*
+ * set inactive coder_type flag in ACELP core
+ *-----------------------------------------------------------------*/
+
+ st_fx->inactive_coder_type_flag = 0; /* AVQ by default */
+ move16();
+
+ if ( LE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) )
+ {
+ st_fx->inactive_coder_type_flag = 1; /* GSC */
+ move16();
+ }
+
+#endif
return;
}
diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c
index 6f71b8ba1c2031d4a5079a801a107efa11746e6b..96e7e274cbbda2bf53cbb7082b1f9fe126778db6 100644
--- a/lib_enc/enc_gen_voic_fx.c
+++ b/lib_enc/enc_gen_voic_fx.c
@@ -661,7 +661,11 @@ void encod_gen_voic_ivas_fx(
*-----------------------------------------------------------------*/
test();
+#ifdef NONBE_FIX_GSC_BSTR
+ IF( !st_fx->inactive_coder_type_flag && EQ_16( st_fx->coder_type, INACTIVE ) )
+#else
IF( GE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) && EQ_16( st_fx->coder_type, INACTIVE ) )
+#endif
{
transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx,
Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c
index 9e3b817b1042504d9eb995245224954bd5b992a1..e0d4f50163ee4f433de12fe5b2f507ebc8ec7eb8 100644
--- a/lib_enc/enc_pit_exc_fx.c
+++ b/lib_enc/enc_pit_exc_fx.c
@@ -579,6 +579,7 @@ void enc_pit_exc_ivas_fx(
Word16 use_fcb;
Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
+ Word16 h1_q15[PIT_EXC_L_SUBFR + ( M + 1 )];
SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
@@ -768,8 +769,9 @@ void enc_pit_exc_ivas_fx(
* Codebook target computation
* (No LP filtering of the adaptive excitation)
*-----------------------------------------------------------------*/
+ Copy_Scale_sig( h1, h1_q15, L_subfr, 1 ); // Q14 -> Q15
- lp_select = lp_filt_exc_enc_ivas_fx( MODE1, AUDIO, i_subfr, exc, h1,
+ lp_select = lp_filt_exc_enc_ivas_fx( MODE1, AUDIO, i_subfr, exc, h1_q15,
xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */
IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c
index 6d81eb82a7b8bd9dfe8261486ebf6330f1bdefbb..7dc96a4e31a73fa401bb5170f05035510b58de02 100644
--- a/lib_enc/energy_fx.c
+++ b/lib_enc/energy_fx.c
@@ -184,7 +184,7 @@ static void update_sb_bg_energy(
Word32 sb_bg_energy_ti, tmp;
Word16 tmpQ, i;
- *tbg_energy_count = add( *tbg_energy_count, 1 ); /* Q0 */
+ *tbg_energy_count = add_sat( *tbg_energy_count, 1 ); /* Q0 */
move16();
tmpQ = add( tmp_Q_add, frame_sb_energy_scale );
diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c
index f55d870201908577b1e19eb447b5033d48d81bb6..fc4a1889a8d7c78b2c8420ec9ef7c6848a5800c9 100644
--- a/lib_enc/ext_sig_ana_fx.c
+++ b/lib_enc/ext_sig_ana_fx.c
@@ -918,6 +918,8 @@ void core_signal_analysis_high_bitrate_ivas_fx(
assert( frameno == 0 );
windowed_samples[0] = L_deposit_l( overlap_mode[frameno] ); // Q0
windowed_samples[1] = L_deposit_l( overlap_mode[frameno + 1] ); // Q0
+ *q_win = 0;
+ move16();
}
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c
index 5c493876bab2caeb84ae0a6f9db36e2bcd1c5371..5fdc5e6f00283c841bd3af4d251f1515c1b5b790 100644
--- a/lib_enc/fd_cng_enc.c
+++ b/lib_enc/fd_cng_enc.c
@@ -92,10 +92,12 @@ void perform_noise_estimation_enc_ivas_fx(
move16();
assert( numSlots == 16 );
- Word32 numSlots_inv_fx = 134217728;
+ Word32 numSlots_inv_fx = 1073741824; // Q34 of .0625
move32();
Word32 *periodog = hFdCngEnc->hFdCngCom->periodog; /* exp(peridog_exp) */
Word32 *ptr_per_fx = periodog;
+ Word64 periodog_64;
+ Word16 periodog_exp[PERIODOGLEN];
Word16 npart = hFdCngEnc->hFdCngCom->npart; /* Q0 */
move16();
Word16 nFFTpart = hFdCngEnc->hFdCngCom->nFFTpart; /* Q0 */
@@ -130,19 +132,19 @@ void perform_noise_estimation_enc_ivas_fx(
SWITCH( input_Fs )
{
case 8000:
- scaleEB_fx = 62912;
+ scaleEB_fx = 251648; // Q35
move32();
BREAK;
case 16000:
- scaleEB_fx = 15728;
+ scaleEB_fx = 62912; // Q35
move32();
BREAK;
case 32000:
- scaleEB_fx = 3928;
+ scaleEB_fx = 15728; // Q35
move32();
BREAK;
case 48000:
- scaleEB_fx = 1744;
+ scaleEB_fx = 6991; // Q35
move32();
BREAK;
default:
@@ -151,8 +153,8 @@ void perform_noise_estimation_enc_ivas_fx(
}
ELSE
{
- scaleEB_fx = Mpy_32_16_1( numSlots_inv_fx, hFdCngEnc->hFdCngCom->scalingFactor );
- scaleEB_fx = L_shl( scaleEB_fx, 4 );
+ scaleEB_fx = Mpy_32_32( numSlots_inv_fx, L_deposit_l( hFdCngEnc->hFdCngCom->scalingFactor ) ); // Q34 + Q30 - Q31 = Q33
+ scaleEB_fx = L_shl( scaleEB_fx, 2 ); // Q35
}
/* preemphasis compensation and grouping of per bin energies into msPeriodog */
@@ -167,22 +169,38 @@ void perform_noise_estimation_enc_ivas_fx(
hFdCngEnc->msPeriodog_fx_exp_fft = add( band_energies_exp, PREEMPH_COMPENSATION_EXP );
move16();
+ Word16 max_exp = -31;
+ move16();
+ i = 0;
+ move16();
/* Adjust to the desired time resolution by averaging the periodograms over the time slots */
FOR( j = numCoreBands; j < regularStopBand; j++ )
{
- *ptr_per_fx = Mpy_32_32( enerBuffer[j], scaleEB_fx ); /* exp(enerBuffer_exp) */
+ periodog_64 = W_mult_32_32( enerBuffer[j], scaleEB_fx );
+ Word16 scale = W_norm( periodog_64 );
+ *ptr_per_fx = W_extract_h( W_shl( periodog_64, scale ) );
move32();
+ periodog_exp[i] = sub( Q31, add( add( sub( Q31, enerBuffer_exp ), 35 - 31 ), scale ) );
+ move16();
+ max_exp = s_max( max_exp, periodog_exp[i] );
ptr_per_fx++;
- move16();
+ i++;
}
-
/* exponent for cldfb part of msPeriodog */
- hFdCngEnc->hFdCngCom->exp_cldfb_periodog = add( sub( enerBuffer_exp, 4 ), CLDFBscalingFactor_EXP );
- move16();
+ // hFdCngEnc->hFdCngCom->exp_cldfb_periodog = add( sub( enerBuffer_exp, 4 ), CLDFBscalingFactor_EXP );
+ // move16();
numBands = sub( regularStopBand, numCoreBands ); /* Q0 */
+ FOR( i = 0; i < numBands; i++ )
+ {
+
+ periodog[i] = L_shr( periodog[i], sub( max_exp, periodog_exp[i] ) );
+ move16();
+ }
+ hFdCngEnc->hFdCngCom->exp_cldfb_periodog = max_exp;
+ move16();
IF( numBands > 0 )
{
///* Adjust CLDFB filterbank to the desired frequency resolution by averaging over spectral partitions for SID transmission */
diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c
index 5414329e2360335f49d5fbbb93d34f28d1decafb..54bc4fb5822896ff14f9e077477c4dd20dbb0f25 100644
--- a/lib_enc/hvq_enc_fx.c
+++ b/lib_enc/hvq_enc_fx.c
@@ -13,7 +13,7 @@
#define HVQ_ENC_NOISE_DELTA ( (Word16) 3277 ) /* 0.1 in Q15 */
-static Word16 quant_lc( const Word16, Word16 * );
+static Word16 quant_lc_fx( const Word16, Word16 * );
/*--------------------------------------------------------------------------*
@@ -149,7 +149,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits
adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */
noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */
move16();
- q_noise_level_idx[i] = quant_lc( noise_level[i], &q_noise_level[i] );
+ q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] );
move16();
}
ELSE
@@ -229,6 +229,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits
Word16 tmp16, adjust;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
bits_used = 0;
move16();
@@ -324,7 +325,9 @@ Word16 hvq_enc_fx( /*o : Consumed bits
/* Number of bits required to adjust to Q15 */
adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */
noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */
- q_noise_level_idx[i] = quant_lc( noise_level[i], &q_noise_level[i] );
+ move16();
+ q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] );
+ move16();
}
ELSE
{
@@ -337,6 +340,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits
bits_used = add( bits_used, 2 );
noise_level[i] = q_noise_level[i]; /* in Q15 */
+ move16();
}
FOR( i = 0; i < HVQ_NF_GROUPS; i++ )
@@ -367,6 +371,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits
}
nBits = peak_vq_enc_fx( st_fx->hBstr, st_fx->bwidth, coefs, coefs_out, core_brate, sub( hvq_bits, bits_used ),
Npeaks, ynrm, R, peaks, &nf_gains[0] );
+ move16();
bits_used = add( bits_used, nBits );
return bits_used;
}
@@ -376,7 +381,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits
*
* Quantize the noise to one of the levels in {0, 0.1, 0.2, 0.3}
*----------------------------------------------------------------------------*/
-static Word16 quant_lc( const Word16 x, Word16 *qx )
+static Word16 quant_lc_fx( const Word16 x, Word16 *qx )
{
Word16 indx;
diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c
index c15c6866657d1b7c26783976a8d66dc552edce4c..d20169e73002d69c8cb78e00026c3e61cae2eed9 100644
--- a/lib_enc/igf_enc.c
+++ b/lib_enc/igf_enc.c
@@ -51,11 +51,11 @@
#define INV_Log2_10_Q12 1233 /*1/log2(10) in Q12*/
#define INV_Log2_e_Q15 22713 /*1/log2(e) in Q15*/
/*-------------------------------------------------------------------*
- * IGF_write_bit()
+ * IGF_write_bit_fx()
*
* write single bit to stream
*-------------------------------------------------------------------*/
-static void IGF_write_bit(
+static void IGF_write_bit_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
Word16 *bitCount, /* i/o: bit counter */
const Word16 value /* i : value */
@@ -88,11 +88,11 @@ static void IGF_write_bits(
{
IF( s_and( value, shl( 1, bits ) ) == 0 )
{
- IGF_write_bit( hBstr, bitCount, 0 );
+ IGF_write_bit_fx( hBstr, bitCount, 0 );
}
ELSE
{
- IGF_write_bit( hBstr, bitCount, 1 );
+ IGF_write_bit_fx( hBstr, bitCount, 1 );
}
}
@@ -290,27 +290,27 @@ static Word32 IGF_getTNR_fx(
width = sub( stop, start );
FOR( i = start; i < stop; i++ )
{
- rootSpec_e[sub( i, start )] = e_ps;
+ rootSpec_e[i - start] = e_ps;
move16();
- rootSpec[sub( i, start )] = Sqrt32( powerSpectrum[i], &rootSpec_e[sub( i, start )] ); /*rootSpec[i - start] = sqrtf( powerSpectrum[i] );*/
+ rootSpec[i - start] = Sqrt32( powerSpectrum[i], &rootSpec_e[i - start] ); /*rootSpec[i - start] = sqrtf( powerSpectrum[i] );*/
move32();
- avg = BASOP_Util_Add_Mant32Exp( avg, avg_e, rootSpec[sub( i, start )], rootSpec_e[sub( i, start )], &avg_e ); /*avg += rootSpec[i - start];resultant exponent is avg_e*/
+ avg = BASOP_Util_Add_Mant32Exp( avg, avg_e, rootSpec[i - start], rootSpec_e[i - start], &avg_e ); /*avg += rootSpec[i - start];resultant exponent is avg_e*/
}
avg = BASOP_Util_Divide3216_Scale( avg, width, &tmp_e ); /*avg /= width;*/
avg_e = add( 16, sub( add( avg_e, tmp_e ), 15 ) );
FOR( i = start; i < stop; i++ )
{
- Word16 normSpec_e; /*stores resultant exponent for normSpec*/
- Word16 normSpec = BASOP_Util_Divide3232_Scale( rootSpec[sub( i, start )], avg, &normSpec_e ); /*rootSpec[i - start] / avg;*/
- normSpec_e = add( normSpec_e, sub( rootSpec_e[sub( i, start )], avg_e ) );
+ Word16 normSpec_e; /*stores resultant exponent for normSpec*/
+ Word16 normSpec = BASOP_Util_Divide3232_Scale( rootSpec[i - start], avg, &normSpec_e ); /*rootSpec[i - start] / avg;*/
+ normSpec_e = add( normSpec_e, sub( rootSpec_e[i - start], avg_e ) );
IF( GT_32( normSpec, L_add( L_shl( 1, sub( 15, normSpec_e ) ), L_shl( adap, sub( e_adap, normSpec_e ) ) ) ) )
{
- tonal = BASOP_Util_Add_Mant32Exp( tonal, tonal_e, rootSpec[sub( i, start )], rootSpec_e[sub( i, start )], &tonal_e ); /*tonal += rootSpec[i - start];*/
+ tonal = BASOP_Util_Add_Mant32Exp( tonal, tonal_e, rootSpec[i - start], rootSpec_e[i - start], &tonal_e ); /*tonal += rootSpec[i - start];*/
}
ELSE IF( LT_32( normSpec, L_shl( 1, sub( 15, normSpec_e ) ) ) )
{
- noise = BASOP_Util_Add_Mant32Exp( noise, noise_e, rootSpec[sub( i, start )], rootSpec_e[sub( i, start )], &noise_e ); /*noise += rootSpec[i - start];*/
+ noise = BASOP_Util_Add_Mant32Exp( noise, noise_e, rootSpec[i - start], rootSpec_e[i - start], &noise_e ); /*noise += rootSpec[i - start];*/
}
}
@@ -318,7 +318,6 @@ static Word32 IGF_getTNR_fx(
IF( noise == 0 ) // To handle condition if denom = 0
{
tonalToNoise = imult3216( L_shr( L_add( L_shl( 18 /* log10f(1e-018f) */, Q25 ), Mpy_32_16_1( L_add( BASOP_Util_Log2( tonal ), L_shl( tonal_e, Q25 ) ) /*Q25*/, INV_Log2_10_Q15 ) /*25+15-15*/ ), 3 ) /*Q22*/, 20 );
- move32();
}
ELSE
{
@@ -482,7 +481,7 @@ static void IGF_CalculateEnvelope_ivas_fx(
Word16 tmp_e;
hPrivateData = &hIGFEnc->igfData;
- hGrid = &hPrivateData->igfInfo.grid[(int16_t) igfGridIdx];
+ hGrid = &hPrivateData->igfInfo.grid[(Word16) igfGridIdx];
swb_offset = hGrid->swb_offset;
IF( element_mode > EVS_MONO )
@@ -555,7 +554,6 @@ static void IGF_CalculateEnvelope_ivas_fx(
move16();
move16();
move16();
- move16();
IF( pPowerSpectrum_fx != NULL )
{
@@ -577,8 +575,8 @@ static void IGF_CalculateEnvelope_ivas_fx(
strt_cpy = add( strt_cpy, 1 );
}
- sfbEnergyTileR = L_deposit_l( BASOP_Util_Divide3232_Scale( sfbEnergyTileR, width, &tmp_e ) );
- sfbEnergyTileR_e = add( sub( sfbEnergyTileR_e, Q15 ), tmp_e );
+ sfbEnergyTileR = L_deposit_h( BASOP_Util_Divide3232_Scale( sfbEnergyTileR, width, &tmp_e ) );
+ sfbEnergyTileR_e = add( sub( sfbEnergyTileR_e, Q31 ), tmp_e );
IF( sfbEnergyTileR == 0 )
{
@@ -613,7 +611,6 @@ static void IGF_CalculateEnvelope_ivas_fx(
gain = Mult_32_16( sfbEnergyTileR, temp ); // gain_e
gain_e = add( tmp_e, sfbEnergyTileR_e );
- test();
IF( element_mode > EVS_MONO )
{
test();
@@ -664,14 +661,17 @@ static void IGF_CalculateEnvelope_ivas_fx(
Word16 tmp0, tmp2, tmp3, tmp4;
Word16 tmp0_e, tmp2_e, tmp3_e, tmp4_e;
tmp0 = shr( hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb], 2 );
- tmp0_e = hPrivateData->prevSFB_FIR_TB_e[sfb] + 2;
+ tmp0_e = add( hPrivateData->prevSFB_FIR_TB_e[sfb], 2 );
+ move16();
tmp2 = shr( hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb], 2 );
- tmp2_e = hPrivateData->prevSFB_IIR_TB_e[sfb] + 2;
+ tmp2_e = add( hPrivateData->prevSFB_IIR_TB_e[sfb], 2 );
+ move16();
tmp3 = shr( hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb], 2 );
- tmp3_e = hPrivateData->prevSFB_FIR_SB_e[sfb] + 2;
+ tmp3_e = add( hPrivateData->prevSFB_FIR_SB_e[sfb], 2 );
+ move16();
tmp4 = shr( hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb], 2 );
- tmp4_e = hPrivateData->prevSFB_IIR_SB_e[sfb] + 2;
-
+ tmp4_e = add( hPrivateData->prevSFB_IIR_SB_e[sfb], 2 );
+ move16();
Word16 x1, x2;
Word16 x1_e = BASOP_Util_Add_MantExp( tmp0, tmp0_e, tmp2, tmp2_e - 1, &x1 );
@@ -718,8 +718,13 @@ static void IGF_CalculateEnvelope_ivas_fx(
Word32 mean_y_fx_tmp = 0;
move32();
mean_xy_fx = mean_x2_fx = 0;
+#ifdef FIX_ISSUE_1214
+ mean_x_e = 15;
+ mean_xy_e = mean_y_e = mean_x2_e = 31;
+#else
mean_x_e = mean_y_e = 15;
mean_xy_e = mean_x2_e = 31;
+#endif
move16();
move16();
move16();
@@ -730,18 +735,26 @@ static void IGF_CalculateEnvelope_ivas_fx(
move16();
move16();
- test();
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*/
- test();
+#ifdef FIX_ISSUE_1214
+ /*y = 20.f * log10f( max( 1.f, powerSpectrum[i] ) );*/
+ IF( LE_64( W_deposit32_l( pPowerSpectrum_fx[sb] ), W_shl( 1, ( sub( 31, e_ps[sb] ) ) ) ) )
+ {
+ y = 0;
+ move16();
+ }
+#else
+
/*y = 20 * (int16_t) log10f( max( 1e-018f, pPowerSpectrum[sb] ) );*/
IF( LT_32( pPowerSpectrum_fx[sb], 1 ) )
{
y = imult1616( 20, ( -18 /* log10f(1e-018f) */ ) );
}
+#endif
ELSE
{
y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps[sb], Q25 ) ) ), INV_Log2_10_Q15 ), Q25 ) ) ); /*Q0*/
@@ -864,8 +877,7 @@ static void IGF_CalculateEnvelope_ivas_fx(
move16();
hPrivateData->prevDampingFactor_IIR_e[sfb] = dampingFactor_e;
move16();
- test();
- IF( hPrivateData->dampingFactorSmoothing[sfb] > 0 )
+ if ( hPrivateData->dampingFactorSmoothing[sfb] > 0 )
{
hPrivateData->dampingFactorSmoothing[sfb] = sub( hPrivateData->dampingFactorSmoothing[sfb], 1 );
move16();
@@ -928,6 +940,7 @@ static void IGF_CalculateEnvelope_ivas_fx(
ELSE
{
tmp_e = e_mdct;
+ move16();
sfbEnergyR = 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
sfbEnergyR_e = add( sfbEnergyR_e, add( tmp_e, -15 ) );
gain = sfbEnergyR; // gain_e
@@ -1056,7 +1069,7 @@ static void IGF_CalculateStereoEnvelope_fx(
swb_offset = hGrid->swb_offset;
move16();
- IF( NE_16( igfGridIdx, IGF_GRID_LB_NORM ) )
+ IF( igfGridIdx != IGF_GRID_LB_NORM )
{
FOR( sfbCnt = 0; sfbCnt < sub( hGrid->sfbWrap[hGrid->nTiles], hGrid->sfbWrap[0] ); sfbCnt++ )
{
@@ -1084,7 +1097,7 @@ static void IGF_CalculateStereoEnvelope_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 ) );*/
+ /*hPrivateData->logSpec[sb] = max( 0, (Word16) ( logf( max( FLT_MIN, pPowerSpectrum[sb] ) ) * INV_LOG_2 ) );*/
IF( LE_32( 1, pPowerSpectrum_fx[sb] ) )
{
hPrivateData->logSpec[sb] = s_max( 0, (Word16) L_shr( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e, Q25 ) ), 25 ) );
@@ -1150,6 +1163,7 @@ static void IGF_CalculateStereoEnvelope_fx(
tileSrcSpec_e = pPowerSpectrum_e;
}
move32();
+ move16();
strt_cpy = add( strt_cpy, 1 );
}
@@ -1221,10 +1235,10 @@ static void IGF_CalculateStereoEnvelope_fx(
{
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->prevSFB_FIR_TB_e[sfb] = tmp_tb_e;
- hPrivateData->prevSFB_IIR_TB_e[sfb] = tmp_tb_e;
move16();
move16();
+ hPrivateData->prevSFB_FIR_TB_e[sfb] = tmp_tb_e;
+ hPrivateData->prevSFB_IIR_TB_e[sfb] = tmp_tb_e;
move16();
move16();
}
@@ -1238,35 +1252,42 @@ static void IGF_CalculateStereoEnvelope_fx(
{
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->prevSFB_FIR_SB_e[sfb] = tmp_sb_e;
- hPrivateData->prevSFB_IIR_SB_e[sfb] = tmp_sb_e;
move16();
move16();
+ hPrivateData->prevSFB_FIR_SB_e[sfb] = tmp_sb_e;
+ hPrivateData->prevSFB_IIR_SB_e[sfb] = tmp_sb_e;
move16();
move16();
}
}
- tmp_tb_fx = shl_sat( tmp_tb_fx, sub( 2, tmp_tb_e ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */
- tmp_sb_fx = shl_sat( tmp_sb_fx, sub( 2, tmp_sb_e ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */
-
+#ifdef FIX_ISSUE_1214
+ tmp_tb_fx = shr_sat( tmp_tb_fx, sub( 2, tmp_tb_e ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */
+ tmp_sb_fx = shr_sat( tmp_sb_fx, sub( 2, tmp_sb_e ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */
+ hPrivateData->SFM_tb_fx[sfb] = add_sat( tmp_tb_fx, add_sat( shr( hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb], sub( 2, hPrivateData->prevSFB_FIR_TB_e[sfb] ) ), shr( hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb], sub( 3, hPrivateData->prevSFB_IIR_TB_e[sfb] ) ) ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */
+ hPrivateData->SFM_tb_fx[sfb] = s_min( 22118 /*2.7f Q13*/, hPrivateData->SFM_tb_fx[sfb] ); /* resultant exponent stored in hPrivateData->sfb_sb_e[sfb]*/
+ hPrivateData->SFM_sb_fx[sfb] = add_sat( tmp_sb_fx, add_sat( shr( hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb], sub( 2, hPrivateData->prevSFB_FIR_SB_e[sfb] ) ), shr( hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb], sub( 3, hPrivateData->prevSFB_IIR_SB_e[sfb] ) ) ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */
+ hPrivateData->SFM_sb_fx[sfb] = s_min( 22118 /*2.7f Q13*/, hPrivateData->SFM_sb_fx[sfb] ); /*resultant exponent stores in hPrivateData->sfb_tb_e[sfb]*/
+#else
+ tmp_tb_fx = shl_sat( tmp_tb_fx, sub( 2, tmp_tb_e ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */
+ tmp_sb_fx = shl_sat( tmp_sb_fx, sub( 2, tmp_sb_e ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */
hPrivateData->SFM_tb_fx[sfb] = add_sat( tmp_tb_fx, add_sat( shr( hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb], sub( 2, tmp_tb_e ) ), shr( hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb], sub( 3, tmp_tb_e ) ) ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */
hPrivateData->SFM_tb_fx[sfb] = s_min( 22118 /*2.7f Q13*/, hPrivateData->SFM_tb_fx[sfb] ); /* resultant exponent stored in hPrivateData->sfb_sb_e[sfb]*/
hPrivateData->SFM_sb_fx[sfb] = add_sat( tmp_sb_fx, add_sat( shr( hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb], sub( 2, tmp_sb_e ) ), shr( hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb], sub( 3, tmp_sb_e ) ) ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */
hPrivateData->SFM_sb_fx[sfb] = s_min( 22118 /*2.7f Q13*/, hPrivateData->SFM_sb_fx[sfb] ); /*resultant exponent stores in hPrivateData->sfb_tb_e[sfb]*/
- hPrivateData->sfb_sb_e[sfb] = 2;
- hPrivateData->sfb_tb_e[sfb] = 2;
- move16();
- move16();
+#endif
move16();
move16();
move16();
move16();
+ hPrivateData->sfb_sb_e[sfb] = 2;
+ hPrivateData->sfb_tb_e[sfb] = 2;
move16();
move16();
- 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*/
+ diffSFM_fx = sub( hPrivateData->SFM_sb_fx[sfb], hPrivateData->SFM_tb_fx[sfb] ); /*Q13*/
- 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 */
+ test();
+ IF( diffSFM_fx > 0 && LT_16( hPrivateData->SFM_tb_fx[sfb], 819 /*0.1 Q13*/ ) ) /* 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;
@@ -1290,10 +1311,11 @@ static void IGF_CalculateStereoEnvelope_fx(
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] ) );*/
+ /*y = 20 * (Word16) log10f( max( 1e-018f, pPowerSpectrum[sb] ) );*/
IF( LT_32( pPowerSpectrum_fx[sb], 1 ) )
{
y = 20 * ( -18 );
+ move16();
}
ELSE
{
@@ -1320,7 +1342,7 @@ static void IGF_CalculateStereoEnvelope_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*/
-
+ test();
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 );
@@ -1359,7 +1381,8 @@ static void IGF_CalculateStereoEnvelope_fx(
move16();
move16();
}
-
+ test();
+ test();
IF( last_core_acelp || hPrivateData->wasTransient || EQ_32( hPrivateData->prevDampingFactor_IIR_fx[sfb], L_shl( -1, sub( 15, hPrivateData->prevDampingFactor_IIR_e[sfb] ) ) ) )
{
tmp = BASOP_Util_Cmp_Mant32Exp( currDampingFactor_fx, currDampingFactor_e, 3277, 0 );
@@ -1391,7 +1414,7 @@ static void IGF_CalculateStereoEnvelope_fx(
{
// 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*/
+ currDampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor_fx, currDampingFactor_e, extract_l( Mult_32_16( temp2, 3277 /*0.1f Q15*/ ) ), tmp_e, &currDampingFactor_fx ); /*stores resultant exp for currDampingFactor_fx*/
}
}
@@ -1503,11 +1526,15 @@ static void IGF_CalculateStereoEnvelope_fx(
}
/*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 ) ) )
+ test();
+ test();
+ 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 ) ) )
+ test();
+ test();
+ 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 );
}
@@ -1566,33 +1593,33 @@ static Word16 IGF_WriteEnvelope(
IF( *igfAllZero != 0 )
{
- IGF_write_bit( hBstr, pBitOffset, 1 );
+ IGF_write_bit_fx( hBstr, pBitOffset, 1 );
- IF( NULL == hBstr )
+ if ( NULL == hBstr )
{
IGFSCFEncoderSaveContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx );
}
IGFSCFEncoderReset_fx( &hPrivateData->hIGFSCFArithEnc );
- IF( NULL == hBstr )
+ if ( NULL == hBstr )
{
IGFSCFEncoderRestoreContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx );
}
}
ELSE
{
- IGF_write_bit( hBstr, pBitOffset, 0 );
+ IGF_write_bit_fx( hBstr, pBitOffset, 0 );
- IF( NULL == hBstr )
+ if ( NULL == hBstr )
{
IGFSCFEncoderSaveContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx );
}
- *pBitOffset = IGFSCFEncoderEncode( &hPrivateData->hIGFSCFArithEnc, hBstr, *pBitOffset, &hPrivateData->igfScfQuantized[hGrid->startSfb], igfGridIdx, isIndepFlag );
+ *pBitOffset = IGFSCFEncoderEncode_ivas_fx( &hPrivateData->hIGFSCFArithEnc, hBstr, *pBitOffset, &hPrivateData->igfScfQuantized[hGrid->startSfb], igfGridIdx, isIndepFlag );
move16();
- IF( NULL == hBstr )
+ if ( NULL == hBstr )
{
IGFSCFEncoderRestoreContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx );
}
@@ -1688,7 +1715,7 @@ static void IGF_Whitening_ivas_fx(
/* 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 ) )
+ IF( 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];
@@ -1821,7 +1848,7 @@ static void IGF_Whitening_ivas_fx(
ELSE
{
test();
- IF( GT_16( element_mode, EVS_MONO ) && EQ_16( sub( hGrid->sfbWrap[p + 1], hGrid->sfbWrap[p] ), 1 ) )
+ IF( element_mode > EVS_MONO && EQ_16( sub( hGrid->sfbWrap[p + 1], hGrid->sfbWrap[p] ), 1 ) )
{
SFM = shl( tmp, sub( tmp_e, 2 ) ); /*2Q13*/
}
@@ -1853,7 +1880,7 @@ static void IGF_Whitening_ivas_fx(
}
}
- IF( GT_16( element_mode, EVS_MONO ) )
+ IF( element_mode > EVS_MONO )
{
IF( last_core_acelp ) /* reset */
{
@@ -1960,7 +1987,7 @@ static void IGF_Whitening_ivas_fx(
}
}
- IF( GT_16( element_mode, EVS_MONO ) )
+ IF( element_mode > EVS_MONO )
{
IF( EQ_16( SFM, -ONE_IN_Q13 /*1.0f 2Q13*/ ) ) /* reset */
{
@@ -2007,7 +2034,10 @@ static void IGF_Whitening_ivas_fx(
break;
}
}
-
+ test();
+ test();
+ test();
+ test();
/* if tonality oscillates between two tiles, turn whitening off in both */
IF( ( ( pastSfmDiffSum_a > 0 && pastSfmDiffSum_b < 0 ) ||
( pastSfmDiffSum_a < 0 && pastSfmDiffSum_b > 0 ) ) &&
@@ -2056,16 +2086,16 @@ static void IGF_Whitening_ivas_fx(
/*-------------------------------------------------------------------*
- * IGF_WriteWhiteningTile()
+ * IGF_WriteWhiteningTile_fx()
*
* write whitening levels into bitstream
*-------------------------------------------------------------------*/
/*! r: number of bits written */
-static Word16 IGF_WriteWhiteningTile( /**< out: Q0 | number of bits written */
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */
- Word16 whiteningLevel /**< in: Q0 | whitening levels to write */
+static Word16 IGF_WriteWhiteningTile_fx( /**< out: Q0 | number of bits written */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */
+ Word16 whiteningLevel /**< in: Q0 | whitening levels to write */
)
{
Word16 totBitCount;
@@ -2099,17 +2129,17 @@ static Word16 IGF_WriteWhiteningTile( /**< out: Q0 | numb
/*-------------------------------------------------------------------*
- * IGF_WriteWhiteningLevels()
+ * IGF_WriteWhiteningLevels_fx()
*
* writes the whitening levels
*-------------------------------------------------------------------*/
-static Word16 IGF_WriteWhiteningLevels( /**< out: Q0 | total number of bits written */
- const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF encoder */
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */
- const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */
- const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */
+static Word16 IGF_WriteWhiteningLevels_fx( /**< out: Q0 | total number of bits written */
+ const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF encoder */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */
+ const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */
+ const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */
)
{
IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData;
@@ -2143,7 +2173,7 @@ static Word16 IGF_WriteWhiteningLevels(
move16();
tmp32 = 0;
move32();
-
+ test();
WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) )
{
test();
@@ -2166,11 +2196,12 @@ static Word16 IGF_WriteWhiteningLevels(
{
IGF_write_bits( hBstr, pBitOffset, 0, 1 );
}
- IGF_WriteWhiteningTile( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[0] );
+ IGF_WriteWhiteningTile_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[0] );
p = 1;
move16();
tmp32 = 0;
move32();
+ test();
IF( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) )
{
isSame = 1;
@@ -2183,7 +2214,7 @@ static Word16 IGF_WriteWhiteningLevels(
isSame = 1;
move16();
}
-
+ test();
WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) )
{
test();
@@ -2202,7 +2233,7 @@ static Word16 IGF_WriteWhiteningLevels(
IGF_write_bits( hBstr, pBitOffset, 1, 1 );
FOR( p = 1; p < nTiles; p++ )
{
- IGF_WriteWhiteningTile( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[p] );
+ IGF_WriteWhiteningTile_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[p] );
}
}
ELSE IF( NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) && NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_48000_CPE ) )
@@ -2218,16 +2249,16 @@ static Word16 IGF_WriteWhiteningLevels(
/*-------------------------------------------------------------------*
- * IGF_WriteFlatteningTrigger()
+ * IGF_WriteFlatteningTrigger_fx()
*
* write flattening trigger
*-------------------------------------------------------------------*/
/*! r: number of bits written */
-static Word16 IGF_WriteFlatteningTrigger( /**< out: | number of bits written */
- const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 *pBitOffset /**< in: | ptr to bitOffset counter */
+static Word16 IGF_WriteFlatteningTrigger_fx( /**< out: | number of bits written */
+ const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ Word16 *pBitOffset /**< in: | ptr to bitOffset counter */
)
{
Word16 flatteningTrigger;
@@ -2290,15 +2321,15 @@ Word16 IGFEncWriteBitstream_ivas_fx(
isIndepFlag, /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */
&igfAllZero ); /* o: *igfAllZero */
- IGF_WriteWhiteningLevels( hIGFEnc, /* i: instance handle of IGF Encoder */
- hBstr, /* i: encoder state */
- pBitOffset, /* i: ptr to bitOffset counter */
- igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */
- isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */
+ IGF_WriteWhiteningLevels_fx( hIGFEnc, /* i: instance handle of IGF Encoder */
+ hBstr, /* i: encoder state */
+ pBitOffset, /* i: ptr to bitOffset counter */
+ igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */
+ isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */
- IGF_WriteFlatteningTrigger( hIGFEnc, /* i: instance handle of IGF Encoder */
- hBstr, /* i: encoder state */
- pBitOffset ); /* i: ptr to bitOffset counter */
+ IGF_WriteFlatteningTrigger_fx( hIGFEnc, /* i: instance handle of IGF Encoder */
+ hBstr, /* i: encoder state */
+ pBitOffset ); /* i: ptr to bitOffset counter */
hIGFEnc->infoTotalBitsPerFrameWritten = sub( *pBitOffset, startBitCount );
hIGFEnc->infoTotalBitsWritten = add( hIGFEnc->infoTotalBitsWritten, hIGFEnc->infoTotalBitsPerFrameWritten );
@@ -2307,34 +2338,6 @@ Word16 IGFEncWriteBitstream_ivas_fx(
return hIGFEnc->infoTotalBitsPerFrameWritten;
}
-int16_t IGFEncWriteBitstream(
- const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- int16_t *pBitOffset, /* i : ptr to bitOffset counter */
- const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */
- const int16_t isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */
-)
-{
- int16_t igfAllZero;
- int16_t startBitCount = *pBitOffset;
-
- hIGFEnc->infoTotalBitsPerFrameWritten = 0;
- if ( isIndepFlag )
- {
- hIGFEnc->infoTotalBitsWritten = 0;
- }
-
- IGF_WriteEnvelope( hIGFEnc, hBstr, pBitOffset, igfGridIdx, isIndepFlag, &igfAllZero );
-
- IGF_WriteWhiteningLevels( hIGFEnc, hBstr, pBitOffset, igfGridIdx, isIndepFlag );
-
- IGF_WriteFlatteningTrigger( hIGFEnc, hBstr, pBitOffset );
-
- hIGFEnc->infoTotalBitsPerFrameWritten = ( *pBitOffset - startBitCount );
- hIGFEnc->infoTotalBitsWritten += hIGFEnc->infoTotalBitsPerFrameWritten;
-
- return hIGFEnc->infoTotalBitsPerFrameWritten;
-}
/*-------------------------------------------------------------------*
@@ -2512,12 +2515,12 @@ return;
/*-------------------------------------------------------------------*
- * IGFEncResetTCX10BitCounter()
+ * IGFEncResetTCX10BitCounter_ivas_fx()
*
* IGF reset bitstream bit counter for TCX10 modes
*-------------------------------------------------------------------*/
-void IGFEncResetTCX10BitCounter(
+void IGFEncResetTCX10BitCounter_ivas_fx(
const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i : instance handle of IGF Encoder */
)
{
@@ -2526,7 +2529,8 @@ void IGFEncResetTCX10BitCounter(
hPrivateData = &hIGFEnc->igfData;
hPrivateData->igfBitstreamBits = 0;
hIGFEnc->infoTotalBitsWritten = 0;
-
+ move16();
+ move16();
return;
}
@@ -2538,14 +2542,14 @@ void IGFEncResetTCX10BitCounter(
*-------------------------------------------------------------------*/
/*! r: total number of bits written */
-int16_t IGFEncWriteConcatenatedBitstream(
+Word16 IGFEncWriteConcatenatedBitstream(
const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */
BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
)
{
IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData;
- int16_t i;
- int16_t bitsLeft;
+ Word16 i;
+ Word16 bitsLeft;
UWord8 *pBitstream;
hPrivateData = &hIGFEnc->igfData;
@@ -2559,7 +2563,7 @@ int16_t IGFEncWriteConcatenatedBitstream(
bitsLeft = hPrivateData->igfBitstreamBits & 0x7;
if ( bitsLeft > 0 )
{
- push_next_indice( hBstr, pBitstream[i] >> ( 8 - bitsLeft ), bitsLeft );
+ push_next_indice( hBstr, shr( pBitstream[i], sub( 8, bitsLeft ) ), bitsLeft );
}
return hIGFEnc->infoTotalBitsWritten;
@@ -2589,7 +2593,6 @@ void IGFEncApplyMono_ivas_fx(
Word16 *pPowerSpectrumParameter_exp;
Word16 att_fx = MAX16B;
Word16 last_core_acelp;
- Word16 highPassEner_exp;
move16();
Word32 common_pPowerSpectrum_fx[N_MAX + L_MDCT_OVLP_MAX];
@@ -2600,7 +2603,6 @@ void IGFEncApplyMono_ivas_fx(
Word16 common_pPowerSpectrum_exp = MIN16B;
move16();
- test();
IF( st->last_core == ACELP_CORE )
{
last_core_acelp = 1;
@@ -2634,7 +2636,6 @@ void IGFEncApplyMono_ivas_fx(
IGF_CalculateEnvelope_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx );
- test();
IF( isTCX20 )
{
pPowerSpectrumParameter_fx = pPowerSpectrum_fx;
@@ -2668,7 +2669,7 @@ void IGFEncApplyMono_ivas_fx(
move16();
}
}
- IGF_ErodeSpectrum_ivas_fx( &highPassEner_exp, st->hIGFEnc, pMDCTSpectrum_fx, pPowerSpectrumParameter_fx, common_pPowerSpectrum_exp, igfGridIdx, 0 );
+ IGF_ErodeSpectrum_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, pPowerSpectrumParameter_fx, common_pPowerSpectrum_exp, igfGridIdx, 0 );
}
@@ -2692,7 +2693,6 @@ void IGFEncApplyStereo_fx(
const Word32 element_brate, /* i : element bitrate */
const Word16 mct_on )
{
- Word16 highPassEner_exp;
Word32 *pPowerSpectrumParameter_fx[NB_DIV]; /* If it is NULL it informs a function that specific handling is needed */
Word32 *pPowerSpectrumParameterMsInv_fx[NB_DIV];
Word16 coreMsMask[N_MAX];
@@ -2718,7 +2718,7 @@ void IGFEncApplyStereo_fx(
{
sfbConf = &hStereoMdct->stbParamsTCX10;
}
- if ( EQ_16( sts[0]->last_core, ACELP_CORE ) )
+ if ( sts[0]->last_core == ACELP_CORE )
{
sfbConf = &hStereoMdct->stbParamsTCX20afterACELP;
}
@@ -2766,7 +2766,7 @@ void IGFEncApplyStereo_fx(
IGF_Whitening_ivas_fx( hIGFEnc[ch], pPowerSpectrumParameter_fx[ch], &exp_pPowerSpectrum[0], igfGridIdx, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, ( sts[0]->hTcxEnc->fUseTns[frameno] || sts[1]->hTcxEnc->fUseTns[frameno] ), sp_aud_decision0, element_brate, sts[ch]->element_mode );
- IGF_ErodeSpectrum_ivas_fx( &highPassEner_exp, hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], igfGridIdx, mct_on );
+ IGF_ErodeSpectrum_ivas_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], sts[ch]->hTcxEnc->spectrum_e[frameno], igfGridIdx, mct_on );
}
return;
}
diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c
index 9e38d4d6cdefa19275cfebb90d2fd1825e568676..ca1759c89aa6215136f84a024d11028930f4fd0e 100644
--- a/lib_enc/igf_enc_fx.c
+++ b/lib_enc/igf_enc_fx.c
@@ -17,7 +17,7 @@
/**********************************************************************/ /*
write single bit to stream
**************************************************************************/
-static void IGF_write_bit(
+static void IGF_write_bit_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
Word16 *bitCount, /**< in/out: | bit counter */
Word16 bit /**< in: | value of bit */
@@ -44,11 +44,11 @@ static void IGF_write_bits(
tmp = s_and( value, shl( 1, bits ) );
IF( tmp == 0 )
{
- IGF_write_bit( hBstr, bitCount, 0 );
+ IGF_write_bit_fx( hBstr, bitCount, 0 );
}
ELSE
{
- IGF_write_bit( hBstr, bitCount, 1 );
+ IGF_write_bit_fx( hBstr, bitCount, 1 );
}
}
@@ -96,6 +96,7 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**<
Word16 shift;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/* initialize variables */
@@ -310,21 +311,21 @@ static void IGF_WriteEnvelope( /**< ou
IF( *igfAllZero != 0 )
{
- IGF_write_bit( hBstr, pBitOffset, 1 );
- IF( NULL == hBstr )
+ IGF_write_bit_fx( hBstr, pBitOffset, 1 );
+ if ( NULL == hBstr )
{
IGFSCFEncoderSaveContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx );
}
IGFSCFEncoderReset_fx( &hPrivateData->hIGFSCFArithEnc );
- IF( NULL == hBstr )
+ if ( NULL == hBstr )
{
IGFSCFEncoderRestoreContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx );
}
}
ELSE
{
- IGF_write_bit( hBstr, pBitOffset, 0 );
- IF( NULL == hBstr )
+ IGF_write_bit_fx( hBstr, pBitOffset, 0 );
+ if ( NULL == hBstr )
{
IGFSCFEncoderSaveContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx );
}
@@ -332,7 +333,7 @@ static void IGF_WriteEnvelope( /**< ou
*pBitOffset = IGFSCFEncoderEncode_fx( &hPrivateData->hIGFSCFArithEnc, hBstr, *pBitOffset, &hPrivateData->igfScfQuantized[hGrid->startSfb], igfGridIdx, isIndepFlag );
move16();
- IF( NULL == hBstr )
+ if ( NULL == hBstr )
{
IGFSCFEncoderRestoreContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx );
}
@@ -375,6 +376,8 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
Flag Carry = 0;
+ move32();
+ move32();
#endif
hPrivateData = &hInstance->igfData;
@@ -412,13 +415,16 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou
FOR( i = 0; i < igfBgn; i++ )
{
Carry = 0;
+ move32();
highPassEner = L_add_co( highPassEner, Mpy_32_16_1( pPowerSpectrum[i], shl( i, 4 ) /*Q4*/ ) /*Q20, pPowerSpectrum_exp*/, &Carry, &Overflow );
Overflow = 0;
+ move32();
L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow );
}
highPassEner = norm_llQ31( L_c, highPassEner, highPassEner_exp ); /*Q20, highPassEner_exp*/
*highPassEner_exp = add( *highPassEner_exp, pPowerSpectrum_exp );
+ move16();
test();
test();
if ( NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_9600 ) &&
@@ -477,9 +483,10 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou
BASOP_SATURATE_WARNING_OFF_EVS
L_tmp = L_add_sat( pPowerSpectrum[i], highPassEner_Ovfl );
BASOP_SATURATE_WARNING_ON_EVS
- IF( L_tmp < 0 )
+ if ( L_tmp < 0 )
{
pSpectrum[i] = L_deposit_l( 0 );
+ move32();
}
}
@@ -487,7 +494,9 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou
FOR( i = igfEnd; i < hGrid->infoGranuleLen; i++ )
{
pSpectrum[i] = L_deposit_l( 0 );
+ move32();
pPowerSpectrum[i] = L_deposit_l( 0 );
+ move32();
}
FOR( sfb = startSfb; sfb < stopSfb; sfb++ )
@@ -516,8 +525,7 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou
}
}
-void IGF_ErodeSpectrum_ivas_fx( Word16 *highPassEner_exp, /**< out: | exponent of highPassEner */
- const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
+void IGF_ErodeSpectrum_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
Word32 *pSpectrum, /**< in/out: | MDCT spectrum Qx*/
Word32 *pPowerSpectrum, /**< in/out: | power spectrum */
Word16 pPowerSpectrum_exp, /**< in: | exponent of power spectrum */
@@ -532,26 +540,17 @@ void IGF_ErodeSpectrum_ivas_fx( Word16 *highPassEner_exp, /**< ou
Word32 highPassEner; /* Q31 */
Word32 lastLine;
Word32 nextLine;
- Word32 L_c;
- Word32 highPassEner_Ovfl;
- Word16 s;
- Word16 tmploop;
Word16 *swb_offset;
Word16 sfb;
Word16 startSfb;
Word16 stopSfb;
Word16 line;
- Word16 flag;
Word16 *igfScaleF;
Word16 tmp;
- Word32 L_tmp;
-
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- Flag Carry = 0;
- move32();
- move32();
-#endif
+ Word16 factor;
+ Word16 exp1, exp2;
+ Word16 num, den;
+ Word32 temp;
hPrivateData = &hInstance->igfData;
hGrid = &hPrivateData->igfInfo.grid[igfGridIdx];
@@ -567,10 +566,6 @@ void IGF_ErodeSpectrum_ivas_fx( Word16 *highPassEner_exp, /**< ou
move16();
igfScaleF = hPrivateData->igfScfQuantized;
move16();
- *highPassEner_exp = 0;
- move16();
- highPassEner = 0;
- move32();
IF( NULL == pPowerSpectrum )
{
@@ -584,90 +579,82 @@ void IGF_ErodeSpectrum_ivas_fx( Word16 *highPassEner_exp, /**< ou
IF( igfBgn > 0 )
{
- L_c = 0;
- move32();
+ Word64 sum = 0;
+ move64();
FOR( i = 0; i < igfBgn; i++ )
{
- Carry = 0;
- highPassEner = L_add_co( highPassEner, Mpy_32_16_1( pPowerSpectrum[i], shl( i, 4 ) /*Q4*/ ) /*Q20, pPowerSpectrum_exp*/, &Carry, &Overflow );
- Overflow = 0;
- L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow );
+ sum = W_mac_32_16( sum, pPowerSpectrum[i], i ); // Q: 31-pPowerSpectrum_exp+1
}
+ exp1 = W_norm( sum );
+ sum = W_shl( sum, sub( exp1, 1 ) ); // Q: 31-pPowerSpectrum_exp+1+exp1-1
+ num = extract_h( W_extract_h( sum ) ); // Q: 31-pPowerSpectrum_exp+exp1-48 = -pPowerSpectrum_exp+exp1-17
+ exp1 = add( 32, sub( pPowerSpectrum_exp, exp1 ) ); // exp: 32+pPowerSpectrum_exp-exp1
- highPassEner = norm_llQ31( L_c, highPassEner, highPassEner_exp ); /*Q20, highPassEner_exp*/
- *highPassEner_exp = add( *highPassEner_exp, pPowerSpectrum_exp );
- test();
- test();
- test();
- test();
- test();
IF( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_9600 ) ||
EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_RF_SWB_13200 ) ||
EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_13200 ) ||
EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_16400_CPE ) )
{
- igfBgn = shl( igfBgn, 0 );
+ factor = ONE_IN_Q14; // Q14
+ move16();
}
ELSE IF( mct_on && ( EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) || EQ_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_SWB_64000_CPE ) ) )
{
- igfBgn = imult1616( igfBgn, 45 /*0.7.Q6*/ );
- igfBgn = shr( igfBgn, 7 );
+ factor = 11469; // 0.7f in Q14
+ move16();
}
ELSE
{
- igfBgn = shl( igfBgn, 1 );
+ factor = 32767; // 2.f in Q14
+ move16();
}
- highPassEner = L_deposit_l( BASOP_Util_Divide3216_Scale( highPassEner /*Q20, highPassEner_exp*/, igfBgn /*Q0*/, &s ) ); /*Q15, highPassEner_exp+11-16+s*/
- *highPassEner_exp = add( add( *highPassEner_exp, s ), 12 - 16 + ( 31 - 15 ) ); /*Q15->Q31,highPassEner_exp*/
- lastLine = pSpectrum[i - 1];
+
+ temp = L_mult( igfBgn, factor ); // exp: 16
+ exp2 = norm_l( temp );
+ den = extract_h( L_shl( temp, exp2 ) ); // exp: 16-exp2
+ exp2 = sub( 16, exp2 );
+
+ highPassEner = L_deposit_h( div_s( num, den ) ); // exp: exp1-exp2
+
+ /* highPassEner is used only for comparison, saturation doesn't effect the outcome */
+ highPassEner = L_shl_sat( highPassEner, sub( sub( exp1, exp2 ), pPowerSpectrum_exp ) ); // exp: pPowerSpectrum_exp
+
+ lastLine = pSpectrum[i - 1]; // Qx
move32();
- nextLine = 0;
+ nextLine = pSpectrum[i]; // Qx
move32();
- /* May overflow - just for threshold comparison */
- /* negate because the negated may be 1 larger in abs, */
- /* so whenever compared to the negation of a maximum possible pPowerspectrum, it is still larger */
- highPassEner_Ovfl = L_shl_o( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ), &Overflow );
- L_tmp = L_add_o( pPowerSpectrum[i - 1], highPassEner_Ovfl, &Overflow );
-
- if ( L_tmp >= 0 )
+ if ( LT_32( pPowerSpectrum[i - 1], highPassEner ) )
{
- nextLine = pSpectrum[i];
+ nextLine = 0;
move32();
}
- tmploop = sub( igfEnd, 1 );
- FOR( /*i*/; i < tmploop; i++ )
+
+ FOR( /*i*/; i < igfEnd - 1; i++ )
{
/* May overflow - just for threshold comparison */
- BASOP_SATURATE_WARNING_OFF_EVS
- L_tmp = L_add_sat( pPowerSpectrum[i], highPassEner_Ovfl );
- BASOP_SATURATE_WARNING_ON_EVS;
-
- IF( L_tmp < 0 )
+ IF( LT_32( pPowerSpectrum[i], highPassEner ) )
{
- lastLine = pSpectrum[i];
+ lastLine = pSpectrum[i]; // Qx
move32();
- pSpectrum[i] = nextLine;
+ pSpectrum[i] = nextLine; // Qx
move32();
nextLine = 0;
move32();
}
ELSE
{
- pSpectrum[i - 1] = lastLine;
+ pSpectrum[i - 1] = lastLine; // Qx
move32();
- lastLine = pSpectrum[i];
+ lastLine = pSpectrum[i]; // Qx
move32();
- nextLine = pSpectrum[i + 1];
+ nextLine = pSpectrum[i + 1]; // Qx
move32();
}
}
/* May overflow - just for threshold comparison */
- BASOP_SATURATE_WARNING_OFF_EVS
- L_tmp = L_add_sat( pPowerSpectrum[i], highPassEner_Ovfl );
- BASOP_SATURATE_WARNING_ON_EVS
- if ( L_tmp < 0 )
+ if ( LT_32( pPowerSpectrum[i], highPassEner ) )
{
pSpectrum[i] = 0;
move32();
@@ -683,27 +670,29 @@ void IGF_ErodeSpectrum_ivas_fx( Word16 *highPassEner_exp, /**< ou
move32();
}
- FOR( sfb = startSfb; sfb < stopSfb; sfb++ )
+ // Below check is present at the beginning of the function and is not required here
+ /* IF( NULL != pPowerSpectrum ) */
{
- flag = 0;
- move16();
- FOR( line = swb_offset[sfb]; line < swb_offset[sfb + 1]; line++ )
+ FOR( sfb = startSfb; sfb < stopSfb; sfb++ )
{
- if ( pSpectrum[line] != 0 )
+ tmp = 0;
+ move16();
+ FOR( line = swb_offset[sfb]; line < swb_offset[sfb + 1]; line++ )
{
- flag = 1;
- move16();
+ if ( pSpectrum[line] != 0 )
+ {
+ tmp = add( tmp, 1 );
+ }
}
- }
- tmp = igfScaleF[sfb];
- move16();
- IF( flag )
- {
- tmp = sub( igfScaleF[sfb], 1 );
- }
- if ( igfScaleF[sfb] )
- {
- igfScaleF[sfb] = tmp;
+
+ Word16 igfScaleF_cnt = igfScaleF[sfb];
+ move16();
+ test();
+ if ( tmp && igfScaleF[sfb] )
+ {
+ igfScaleF_cnt = sub( igfScaleF[sfb], 1 );
+ }
+ igfScaleF[sfb] = igfScaleF_cnt;
move16();
}
}
@@ -772,7 +761,7 @@ Word16 IGF_getCrest( /**< ou
tmp32 = L_shl( tmp32, i ); /*Q31, s-i+15*/
crest = extract_h( tmp32 );
*crest_exp = add( sub( s, i ), 15 );
-
+ move16();
/* limit crest factor to a lower bound of 1, may overflow */
BASOP_SATURATE_WARNING_OFF_EVS
tmp = shl_sat( -1, sub( 15, *crest_exp ) ); /* build negative threshold */
@@ -816,6 +805,8 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
Flag Carry = 0;
+ move32();
+ move32();
#endif
L_c = 0;
@@ -849,9 +840,10 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value
num = L_add( num, L_deposit_l( n ) ); /*Q0*/
Carry = 0;
+ move32();
denom = L_add_co( energy[i], denom, &Carry, &Overflow );
Overflow = 0;
-
+ move32();
L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow );
}
@@ -890,7 +882,7 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value
s = norm_l( SFM32 );
SFM = round_fx_sat( L_shl_sat( SFM32, s ) );
*SFM_exp = sub( *SFM_exp, s );
-
+ move16();
/**SFM_exp = s_min(*SFM_exp, 0);*/
IF( *SFM_exp > 0 )
{
@@ -936,6 +928,7 @@ static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in
{
/* reset filter */
hPrivateData->prevSFM_FIR[p] = L_deposit_l( 0 );
+ move32();
hPrivateData->prevSFM_IIR[p] = 0;
move16();
@@ -959,6 +952,7 @@ static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in
IF( powerSpectrum )
{
Word16 nT = hGrid->nTiles;
+ move16();
SWITCH( hPrivateData->igfInfo.bitRateIndex )
{
case IGF_BITRATE_WB_9600:
@@ -1054,6 +1048,7 @@ static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in
FOR( p = 0; p < IGF_MAX_TILES; p++ )
{
hPrivateData->prevSFM_FIR[p] = L_deposit_l( 0 );
+ move32();
hPrivateData->prevSFM_IIR[p] = 0;
move16();
}
@@ -1065,10 +1060,10 @@ static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in
/**********************************************************************/ /*
write whitening levels into bitstream
**************************************************************************/
-static void IGF_WriteWhiteningTile( /**< out: Q0 | number of bits written */
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */
- Word16 whiteningLevel /**< in: Q0 | whitening levels to write */
+static void IGF_WriteWhiteningTile_fx( /**< out: Q0 | number of bits written */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */
+ Word16 whiteningLevel /**< in: Q0 | whitening levels to write */
)
{
IF( EQ_32( whiteningLevel, IGF_WHITENING_MID ) )
@@ -1089,15 +1084,15 @@ static void IGF_WriteWhiteningTile( /**< ou
}
}
-/**********************************************************************/ /*
- writes the whitening levels
- **************************************************************************/
-static void IGF_WriteWhiteningLevels( /**< out: Q0 | total number of bits written */
- const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF encoder */
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */
- const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */
- const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */
+/**********************************************************************/ /*
+ writes the whitening levels
+ **************************************************************************/
+static void IGF_WriteWhiteningLevels_fx( /**< out: Q0 | total number of bits written */
+ const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF encoder */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */
+ const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */
+ const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */
)
{
IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData;
@@ -1126,7 +1121,7 @@ static void IGF_WriteWhiteningLevels( /
move16();
tmp32 = 0;
move32();
-
+ test();
WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) )
{
test();
@@ -1149,7 +1144,7 @@ static void IGF_WriteWhiteningLevels( /
{
IGF_write_bits( hBstr, pBitOffset, 0, 1 );
}
- IGF_WriteWhiteningTile( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[0] );
+ IGF_WriteWhiteningTile_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[0] );
p = 1;
move16();
tmp32 = 0;
@@ -1159,7 +1154,7 @@ static void IGF_WriteWhiteningLevels( /
isSame = 1;
move16();
}
-
+ test();
WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) )
{
test();
@@ -1177,7 +1172,7 @@ static void IGF_WriteWhiteningLevels( /
IGF_write_bits( hBstr, pBitOffset, 1, 1 );
FOR( p = 1; p < nTiles; p++ )
{
- IGF_WriteWhiteningTile( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[p] );
+ IGF_WriteWhiteningTile_fx( hBstr, pBitOffset, hPrivateData->igfCurrWhiteningLevel[p] );
}
}
ELSE
@@ -1187,13 +1182,13 @@ static void IGF_WriteWhiteningLevels( /
}
}
-/**********************************************************************/ /*
- write flattening trigger
- **************************************************************************/
-static void IGF_WriteFlatteningTrigger( /**< out: | number of bits written */
- const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 *pBitOffset /**< in: | ptr to bitOffset counter */
+/**********************************************************************/ /*
+ write flattening trigger
+ **************************************************************************/
+static void IGF_WriteFlatteningTrigger_fx( /**< out: | number of bits written */
+ const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ Word16 *pBitOffset /**< in: | ptr to bitOffset counter */
)
{
Word16 flatteningTrigger;
@@ -1263,19 +1258,20 @@ Word16 IGFEncWriteBitstream_fx( /**< ou
isIndepFlag, /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */
&igfAllZero ); /* o: *igfAllZero */
- IGF_WriteWhiteningLevels( hInstance, /* i: instance handle of IGF Encoder */
- hBstr, /* i: encoder state */
- pBitOffset, /* i: ptr to bitOffset counter */
- igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */
- isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */
+ IGF_WriteWhiteningLevels_fx( hInstance, /* i: instance handle of IGF Encoder */
+ hBstr, /* i: encoder state */
+ pBitOffset, /* i: ptr to bitOffset counter */
+ igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */
+ isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */
- IGF_WriteFlatteningTrigger( hInstance, /* i: instance handle of IGF Encoder */
- hBstr, /* i: encoder state */
- pBitOffset ); /* i: ptr to bitOffset counter */
+ IGF_WriteFlatteningTrigger_fx( hInstance, /* i: instance handle of IGF Encoder */
+ hBstr, /* i: encoder state */
+ pBitOffset ); /* i: ptr to bitOffset counter */
hInstance->infoTotalBitsPerFrameWritten = sub( *pBitOffset, startBitCount );
hInstance->infoTotalBitsWritten = add( hInstance->infoTotalBitsWritten, hInstance->infoTotalBitsPerFrameWritten );
-
+ move16();
+ move16();
return hInstance->infoTotalBitsPerFrameWritten;
}
@@ -1373,7 +1369,7 @@ static void pack_bit_ivas_fx(
move16();
}
- IF( bit != 0 )
+ if ( bit != 0 )
{
**pt = (UWord8) s_or( **pt, *omask );
move16();
@@ -1422,6 +1418,7 @@ void IGFEncConcatenateBitstream_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc,
move16();
omask = (UWord8) UL_lshr( 0x80, s_and( *pFrame_size, 0x7 ) );
+ move16();
pFrame += *pFrame_size >> 3;
/* bitstream packing (conversion of individual indices into a serial stream) */
@@ -1468,7 +1465,7 @@ void IGFEncConcatenateBitstream_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**
hPrivateData = &hInstance->igfData;
*next_ind = *next_ind - bsBits;
-
+ move16();
indices_to_serial_generic(
&ind_list_fx[*next_ind],
bsBits,
@@ -1476,7 +1473,7 @@ void IGFEncConcatenateBitstream_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**
&hPrivateData->igfBitstreamBits );
*nb_bits = sub( *nb_bits, bsBits );
-
+ move16();
return;
}
diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c
index 04ca67979f1eb2a809bf66b850d15804691b9c61..e9ef96e1a1b92580927e833e480097616817912d 100644
--- a/lib_enc/igf_scf_enc.c
+++ b/lib_enc/igf_scf_enc.c
@@ -98,6 +98,7 @@ static void arith_encode_bits(
32767, /* disable the bit count limitation */
&hPrivateData->acState,
bit );
+ move16();
}
}
@@ -133,7 +134,7 @@ static void arith_encode_residual(
&hPrivateData->acState,
x,
cumulativeFrequencyTable );
-
+ move16();
return;
}
@@ -146,6 +147,7 @@ static void arith_encode_residual(
&hPrivateData->acState,
0,
cumulativeFrequencyTable );
+ move16();
}
ELSE /* x > IGF_MAX_ENC_SEPARATE */
{
@@ -156,6 +158,7 @@ static void arith_encode_residual(
&hPrivateData->acState,
IGF_SYMBOLS_IN_TABLE - 1,
cumulativeFrequencyTable );
+ move16();
}
/* encode one of the tails of the distribution */
@@ -226,17 +229,20 @@ static void encode_sfe_vector(
&hPrivateData->acState,
shr( x[f], 2 ),
(const UWord16 *) hPrivateData->cf_se00 );
+ move16();
arith_encode_bits( hPrivateData, ptr, x[f] & 3, 2 ); /* LSBs as 2 bit raw */
}
ELSE IF( EQ_16( f, 1 ) )
{
pred = x[f - 1]; /* pred = b */
+ move16();
arith_encode_residual( hPrivateData, ptr, x[f] - pred, hPrivateData->cf_se01, hPrivateData->cf_off_se01 );
}
ELSE
{
/* f >= 2 */
- pred = x[f - 1]; /* pred = b */
+ pred = x[f - 1]; /* pred = b */
+ move16();
ctx = quant_ctx( sub( x[f - 1], x[f - 2] ) ); /* Q(b - e) */
arith_encode_residual( hPrivateData, ptr, sub( x[f], pred ), &hPrivateData->cf_se02[( IGF_SYMBOLS_IN_TABLE + 1 ) * ( IGF_CTX_OFFSET + ctx )], hPrivateData->cf_off_se02[IGF_CTX_OFFSET + ctx] );
}
@@ -267,11 +273,11 @@ static void encode_sfe_vector(
/*---------------------------------------------------------------------*
- * IGFSCFEncoderEncode()
+ * IGFSCFEncoderEncode_ivas_fx()
*
* main IGF encoder function
*---------------------------------------------------------------------*/
-Word16 IGFSCFEncoderEncode(
+Word16 IGFSCFEncoderEncode_ivas_fx(
IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */
diff --git a/lib_enc/igf_scf_enc_fx.c b/lib_enc/igf_scf_enc_fx.c
index b8125cbd6d408bd4de4d065d72e3fb8e5769580f..8659d53a166cb2a6f155bb85c4f3025c780424a7 100644
--- a/lib_enc/igf_scf_enc_fx.c
+++ b/lib_enc/igf_scf_enc_fx.c
@@ -45,8 +45,11 @@ void IGFSCFEncoderOpen_fx(
set16_fx( hPublicData->prevSave, 0, 64 );
hPublicData->scfCountLongBlock[0] = sub( hIgfInfo->grid[0].swb_offset_len, 1 );
+ move16();
hPublicData->scfCountLongBlock[1] = sub( hIgfInfo->grid[1].swb_offset_len, 1 );
+ move16();
hPublicData->scfCountLongBlock[2] = sub( hIgfInfo->grid[2].swb_offset_len, 1 );
+ move16();
hPublicData->t = 0;
move16(); /* protect against the invalid request of starting encoding with a dependent block */
@@ -124,7 +127,7 @@ static void arith_encode_residual(
&hPrivateData->acState_fx,
x,
cumulativeFrequencyTable );
-
+ move16();
return;
}
@@ -137,6 +140,7 @@ static void arith_encode_residual(
&hPrivateData->acState_fx,
0,
cumulativeFrequencyTable );
+ move16();
}
ELSE /* x > IGF_MAX_ENC_SEPARATE */
{
@@ -147,6 +151,7 @@ static void arith_encode_residual(
&hPrivateData->acState_fx,
IGF_SYMBOLS_IN_TABLE - 1,
cumulativeFrequencyTable );
+ move16();
}
/* encode one of the tails of the distribution */
@@ -216,6 +221,7 @@ static void encode_sfe_vector(
&hPrivateData->acState_fx,
shr( x[f], 2 ),
(const UWord16 *) hPrivateData->cf_se00 );
+ move16();
arith_encode_bits( hPrivateData, ptr, s_and( x[f], 3 ), 2 ); /* LSBs as 2 bit raw */
}
ELSE IF( EQ_16( f, 1 ) )
@@ -233,7 +239,6 @@ static void encode_sfe_vector(
/* (t == 0) && (f >= 2) */
prev_offset = sub( f, 1 );
res = sub( x[f], x[prev_offset] );
- move16(); /* pred = b */
ctx = quant_ctx( sub( x[prev_offset], x[sub( prev_offset, 1 )] ) ); /* Q(b - e) */
/* index1 is (IGF_SYMBOLS_IN_TABLE + 1) * (CTX_OFFSET + ctx) */
index1 = L_mac0( ( IGF_SYMBOLS_IN_TABLE + 1 ) * IGF_CTX_OFFSET, ( IGF_SYMBOLS_IN_TABLE + 1 ), ctx );
@@ -340,12 +345,13 @@ Word16 IGFSCFEncoderEncode_fx(
hPublicData->ptrBitIndex,
&hPublicData->acState_fx ); /* finish AC encoding */
hPublicData->bitCount = add( hPublicData->bitCount, hPublicData->ptrBitIndex );
-
+ move16();
+ move16();
/* advance history */
Copy( sfe, hPublicData->prev, hPublicData->scfCountLongBlock[igfGridIdx] );
hPublicData->t = add( hPublicData->t, 1 );
-
+ move16();
/* copy the bits from the temporary bit buffer, if doRealEncoding is enabled */
IF( hBstr )
diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c
index 7d046db5ff8c5601d00294cdb54ad60dd53717d3..7ce9f8ff5a3e285df92080b672cf3cb7c179e4b2 100644
--- a/lib_enc/init_enc.c
+++ b/lib_enc/init_enc.c
@@ -196,6 +196,7 @@ ivas_error init_encoder_ivas_fx(
#if 1 // TODO: Float Initializations. To be removed later
st->active_cnt = 0;
+ move16();
#endif
st->pst_mem_deemp_err_fx = 0;
@@ -387,6 +388,7 @@ ivas_error init_encoder_ivas_fx(
set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 );
st->q_Bin_E_old = Q31;
+ move16();
set16_fx( st->hSignalBuf->buf_speech_enc, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k );
st->exp_buf_speech_enc = 0;
move16();
@@ -929,10 +931,12 @@ ivas_error init_encoder_ivas_fx(
}
set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX );
st->hTcxEnc->spectrum_long_e = 0;
-
+ move16();
/* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */
st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx;
st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX;
+ move32();
+ move32();
st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0;
move16();
move16();
@@ -1010,7 +1014,7 @@ ivas_error init_encoder_ivas_fx(
igf_brate = element_brate;
}
move32();
-
+ test();
IF( EQ_16( st->codec_mode, MODE2 ) || GT_16( st->element_mode, EVS_MONO ) )
{
st->igf = getIgfPresent_fx( st->element_mode, igf_brate, st->max_bwidth, st->rf_mode );
@@ -1092,7 +1096,11 @@ ivas_error init_encoder_ivas_fx(
move16();
/* Initialize ACELP */
#endif
+#ifdef FIX_920_IGF_INIT_ERROR
+ init_coder_ace_plus_ivas_fx( st, st->last_total_brate, igf_brate, 0 );
+#else
init_coder_ace_plus_ivas_fx( st, st->last_total_brate, 0 );
+#endif
IF( st->hLPDmem != NULL )
{
diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c
index 73cade783bee614191653c6063f6cec8754593e6..89bbdc898e3e7a666aba90721a645f5f557d1d57 100644
--- a/lib_enc/init_enc_fx.c
+++ b/lib_enc/init_enc_fx.c
@@ -1,4 +1,4 @@
-/*====================================================================================
+/*====================================================================================
EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
====================================================================================*/
@@ -29,6 +29,8 @@ ivas_error init_encoder_fx(
Word16 idchan = 0; /* i : channel ID */
Word16 vad_only_flag = 0; /* i : channel ID */
+ move16();
+ move16();
ISM_MODE ism_mode = ISM_MODE_NONE;
ivas_error error;
// PMT("ism_mode, idchan, vad_only_flag to be move to function header")
@@ -97,7 +99,7 @@ ivas_error init_encoder_fx(
st_fx->last_core = -1;
move16();
- IF( st_fx->Opt_AMR_WB )
+ if ( st_fx->Opt_AMR_WB )
{
st_fx->last_core = AMR_WB_CORE;
move16();
@@ -141,7 +143,9 @@ ivas_error init_encoder_fx(
st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list;
st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices;
st->hBstr->nb_ind_tot = 0;
+ move16();
st->hBstr->nb_bits_tot = 0;
+ move16();
st->hBstr->st_ivas = st_ivas;
#endif
}
@@ -157,7 +161,7 @@ ivas_error init_encoder_fx(
Copy( GEWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M );
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 = 0;
-
+ move16();
st_fx->pstreaklen = 0;
move16();
st_fx->streaklimit_fx = 32767;
@@ -297,7 +301,7 @@ ivas_error init_encoder_fx(
// st_fx->GSC_noisy_speech = 0;
st_fx->GSC_IVAS_mode = 0;
-
+ move16();
test();
test();
IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
@@ -350,7 +354,7 @@ ivas_error init_encoder_fx(
test();
test();
test();
- IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) && ( !vad_only_flag ) )
+ IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || st_fx->element_mode == EVS_MONO ) && ( !vad_only_flag ) )
{
if ( ( st_fx->hVAD = (VAD_HANDLE) malloc( sizeof( VAD_DATA ) ) ) == NULL )
{
@@ -386,7 +390,7 @@ ivas_error init_encoder_fx(
st_fx->hVAD->L_snr_sum_vad_fx = 0;
move32();
}
- else
+ ELSE
{
st_fx->hVAD = NULL;
}
@@ -404,7 +408,9 @@ ivas_error init_encoder_fx(
* Noise estimator
*-----------------------------------------------------------------*/
// PMT("deal with idchan ")
- IF( /*idchan == 0 ||*/ EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, EVS_MONO ) )
+ test();
+ test();
+ IF( /*idchan == 0 ||*/ EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || st_fx->element_mode == EVS_MONO )
{
if ( ( st_fx->hNoiseEst = (NOISE_EST_HANDLE) malloc( sizeof( NOISE_EST_DATA ) ) ) == NULL )
{
@@ -422,7 +428,8 @@ ivas_error init_encoder_fx(
*-----------------------------------------------------------------*/
test();
test();
- IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, EVS_MONO ) )
+ test();
+ IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || st_fx->element_mode == EVS_MONO )
{
IF( ( st_fx->hSpMusClas = (SP_MUS_CLAS_HANDLE) malloc( sizeof( SP_MUS_CLAS_DATA ) ) ) == NULL )
{
@@ -472,7 +479,7 @@ ivas_error init_encoder_fx(
move16();
st_fx->coder_type_raw = VOICED;
st_fx->last_coder_type_raw = st_fx->coder_type_raw;
-
+ move16();
st_fx->is_ism_format = 0;
move16();
if ( NE_16( ism_mode, ISM_MODE_NONE ) )
@@ -531,6 +538,8 @@ ivas_error init_encoder_fx(
* LP-CNG
*-----------------------------------------------------------------*/
+ test();
+ test();
test();
test();
test();
@@ -622,7 +631,7 @@ ivas_error init_encoder_fx(
* SC-VBR parameters
*-----------------------------------------------------------------*/
test();
- IF( st_fx->Opt_SC_VBR || EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->Opt_SC_VBR || st_fx->element_mode == EVS_MONO )
{
IF( ( st_fx->hSC_VBR = (SC_VBR_ENC_HANDLE) malloc( sizeof( SC_VBR_ENC_DATA ) ) ) == NULL )
{
@@ -636,7 +645,7 @@ ivas_error init_encoder_fx(
st_fx->hSC_VBR = NULL;
}
/* PLC encoder */
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
IF( ( st_fx->hPlcExt = (PLC_ENC_EVS_HANDLE) malloc( sizeof( PLC_ENC_EVS ) ) ) == NULL )
{
@@ -710,8 +719,8 @@ ivas_error init_encoder_fx(
// st_fx->cldfbSynTd = NULL;
}
-
- IF( st_fx->Opt_RF_ON || EQ_16( st_fx->element_mode, EVS_MONO ) )
+ test();
+ IF( st_fx->Opt_RF_ON || st_fx->element_mode == EVS_MONO )
{
IF( ( st_fx->hRF = (RF_ENC_HANDLE) malloc( sizeof( RF_ENC_DATA ) ) ) == NULL )
{
@@ -752,6 +761,7 @@ ivas_error init_encoder_fx(
*-----------------------------------------------------------------*/
// VE: reduction possible for MCT_CHAN_MODE_LFE channel - see I1-172
+ test();
IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
IF( ( st_fx->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL )
@@ -768,7 +778,7 @@ ivas_error init_encoder_fx(
set16_fx( st_fx->hTcxEnc->old_out_fx, 0, L_FRAME32k );
st_fx->hTcxEnc->Q_old_out = 0;
-
+ move16();
/* MDCT selector */
MDCT_selector_reset_fx( st_fx->hTcxEnc );
st_fx->hTcxEnc->Q_old_out = 0;
@@ -782,7 +792,7 @@ ivas_error init_encoder_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) );
}
}
- else
+ ELSE
{
st_fx->hTcxEnc = NULL;
// st_fx->hTcxCfg = NULL;
@@ -838,7 +848,7 @@ ivas_error init_encoder_fx(
move16();
}
st_fx->rf_mode_last = st_fx->rf_mode;
-
+ move16();
/* initialize RF indice buffers */
reset_rf_indices_fx( st_fx );
@@ -847,12 +857,11 @@ ivas_error init_encoder_fx(
*-----------------------------------------------------------------*/
st_fx->last_sr_core = i_mult2( st_fx->last_L_frame, 50 );
-
+ move16();
/*-----------------------------------------------------------------*
* IGF
*-----------------------------------------------------------------*/
- test();
test();
IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
@@ -919,15 +928,23 @@ ivas_error init_encoder_fx(
st_fx->sharpFlag = 0;
move16();
- st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */
- st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */
- st_fx->cng_sba_flag = 0; /* CNG in SBA flag */
- st_fx->GSC_IVAS_mode = 0; /* CNG in SBA flag */
- st_fx->element_mode = EVS_MONO; /* element mode */
+ st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */
+ move16();
+ st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */
+ move16();
+ st_fx->cng_sba_flag = 0; /* CNG in SBA flag */
+ move16();
+ st_fx->GSC_IVAS_mode = 0; /* CNG in SBA flag */
+ move16();
+ st_fx->element_mode = EVS_MONO; /* element mode */
+ move16();
st_fx->last_element_mode = st_fx->element_mode; /* element mode */
- st_fx->element_brate = -1; /* element bitrate */
- // PMT("element_mode and element_brate should be initialized at a proper place in ivas_dec_init eventually")
- st_fx->low_rate_mode = 0; /* low-rate mode flag */
+ move16();
+ st_fx->element_brate = -1; /* element bitrate */
+ move32();
+ // PMT("element_mode and element_brate should be initialized at a proper place in ivas_dec_init eventually")
+ st_fx->low_rate_mode = 0; /* low-rate mode flag */
+ move16();
// st_fx->coder_type = GENERIC; /* low-rate mode flag */
set16_fx( st_fx->pitch, L_SUBFR, 3 );
@@ -936,10 +953,12 @@ ivas_error init_encoder_fx(
#ifdef DEBUGGING
st_fx->id_element = -1; /* element ID */
+ move16();
#endif
- st_fx->extl_orig = -1; /* extension layer */
+ st_fx->extl_orig = -1; /* extension layer */
+ move16();
st_fx->extl_brate_orig = 0; /* extension layer bitrate */
-
+ move32();
return error;
}
/*-----------------------------------------------------------------------*
diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c
index a2567535209f5e6777477e7da66811aa8bc78e3e..7964df4a8a55a1260460dfece8705614ceae8a2c 100644
--- a/lib_enc/inov_enc_fx.c
+++ b/lib_enc/inov_enc_fx.c
@@ -155,6 +155,7 @@ Word16 inov_encode_fx(
IF( st_fx->acelp_cfg.fcb_mode )
{
/* set number of iterations in TD stereo, secondary channel */
+ test();
if ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) )
{
cmpl_flag = 1;
@@ -245,7 +246,7 @@ Word16 inov_encode_fx(
}
}
- if ( EQ_16( coder_type, INACTIVE ) )
+ if ( coder_type == INACTIVE )
{
cmpl_flag = 4;
move16();
@@ -708,9 +709,7 @@ Word16 inov_encode_ivas_fx(
E_ACELP_4t_ivas_fx( dn, cn, h2, Rw, (Word8) acelpautoc, code, st_fx->acelp_cfg.fixed_cdk_index[idx2], prm, L_frame, last_L_frame, st_fx->total_brate, i_subfr, cmpl_flag, st_fx->element_mode );
wordcnt = shr( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[idx2] ), 4 );
- move16();
bitcnt = s_and( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[idx2] ), 15 );
- move16();
FOR( i = 0; i < wordcnt; i++ )
{
diff --git a/lib_enc/isf_enc_amr_wb_fx.c b/lib_enc/isf_enc_amr_wb_fx.c
index 505d3f2903eb9f1ea7156dc154357103dd07d8be..047a7409c35816d9c97af4eccfecb538364eb055 100644
--- a/lib_enc/isf_enc_amr_wb_fx.c
+++ b/lib_enc/isf_enc_amr_wb_fx.c
@@ -122,7 +122,7 @@ void isf_enc_amr_wb_fx(
* A(z) calculation
*-------------------------------------------------------------------------------------*/
- if ( st->rate_switching_reset )
+ IF( st->rate_switching_reset )
{
Copy( isf_new, st->lsf_old_fx, M );
Copy( isp_new, st->lsp_old_fx, M );
@@ -171,7 +171,7 @@ static void qisf_ns_28b_fx(
indice[3] = sub_VQ_fx( &isf[8], dico4_ns_28b_fx, 4, DICO4_NS_28b, &tmp );
move16();
indice[4] = add( sub_VQ_fx( &isf[12], dico5_ns_28b_fx + 4, 4, DICO5_NS_28b - 1, &tmp ), 1 ); /* First vector has a problem -> do not allow */
-
+ move16();
/* write indices to array */
push_indice_fx( hBstr, IND_ISF_0_0, indice[0], 6 );
push_indice_fx( hBstr, IND_ISF_0_1, indice[1], 6 );
@@ -241,9 +241,11 @@ static void qisf_2s_36b_fx(
}
tmp_ind[0] = sub_VQ_fx( &isf2[0], dico21_isf_36b_fx, 5, SIZE_BK21_36b, &min_err );
+ move16();
temp = L_add( min_err, 0 );
tmp_ind[1] = sub_VQ_fx( &isf2[5], dico22_isf_36b_fx, 4, SIZE_BK22_36b, &min_err );
+ move16();
temp = L_add( temp, min_err );
IF( LT_32( temp, distance ) )
@@ -369,10 +371,13 @@ static void qisf_2s_46b_fx(
}
tmp_ind[0] = sub_VQ_fx( &isf2[0], dico21_isf_46b_fx, 3, SIZE_BK21, &min_err );
+ move16();
temp = L_add( min_err, 0 );
tmp_ind[1] = sub_VQ_fx( &isf2[3], dico22_isf_46b_fx, 3, SIZE_BK22, &min_err );
+ move16();
temp = L_add( temp, min_err );
tmp_ind[2] = sub_VQ_fx( &isf2[6], dico23_isf_46b_fx, 3, SIZE_BK23, &min_err );
+ move16();
temp = L_add( temp, min_err );
IF( LT_32( temp, distance ) )
{
diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c
index a25ee85c611c5ccb05cae804d320216c8ebf5490..0c7fe9094e8c56cebde21ea2e61465923802eec0 100644
--- a/lib_enc/ivas_core_enc.c
+++ b/lib_enc/ivas_core_enc.c
@@ -328,7 +328,6 @@ ivas_error ivas_core_enc_fx(
/*---------------------------------------------------------------------*
* Preprocessing (preparing) for ACELP/HQ core switching
*---------------------------------------------------------------------*/
-
core_switching_pre_enc_ivas_fx( st, old_inp_12k8_fx[n], sub( Q_new[n], 1 ), old_inp_16k_fx[n], sub( Q_new[n], 1 ), sts[0]->active_cnt, last_element_mode );
/*---------------------------------------------------------------------*
@@ -499,14 +498,14 @@ ivas_error ivas_core_enc_fx(
IF( EQ_16( nSubframes, NB_DIV ) )
{
Word16 max_e = s_max( orig_spectrum_e[i][0], orig_spectrum_e[i][1] );
- Scale_sig32( hMCT->p_orig_spectrum_long_fx[cpe_id][i], N_TCX10_MAX, sub( orig_spectrum_e[i][0], max_e ) ); // exp(max_e)
- Scale_sig32( hMCT->p_orig_spectrum_long_fx[cpe_id][i] + N_TCX10_MAX, N_TCX10_MAX, sub( orig_spectrum_e[i][1], max_e ) ); // exp(max_e)
- hMCT->q_orig_spectrum_long_fx[cpe_id][i] = max_e;
+ scale_sig32( hMCT->p_orig_spectrum_long_fx[cpe_id][i], N_TCX10_MAX, sub( orig_spectrum_e[i][0], max_e ) ); // exp(max_e)
+ scale_sig32( hMCT->p_orig_spectrum_long_fx[cpe_id][i] + N_TCX10_MAX, N_TCX10_MAX, sub( orig_spectrum_e[i][1], max_e ) ); // exp(max_e)
+ hMCT->q_orig_spectrum_long_fx[cpe_id][i] = sub( Q31, max_e );
move16();
}
ELSE
{
- hMCT->q_orig_spectrum_long_fx[cpe_id][i] = orig_spectrum_e[i][0];
+ hMCT->q_orig_spectrum_long_fx[cpe_id][i] = sub( Q31, orig_spectrum_e[i][0] );
move16();
}
@@ -794,13 +793,8 @@ ivas_error ivas_core_enc_fx(
stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer );
q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, 16 );
-#ifdef FIX_ISSUE_1237
Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, input_frame, Q16 ); // q_new_swb_speech_buffer
- Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 );
-#else
- Copy_Scale_sig_16_32_DEPREC( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, input_frame, Q16 ); // q_new_swb_speech_buffer
- Copy_Scale_sig_16_32_DEPREC( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31
-#endif
+ Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31
stereo_icBWE_enc_ivas_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] );
diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c
index 848e26ce3d4cbeb7b247ef415be9fc40e8e26da4..31b14ed10354f25428d2cfbddc813cef66e91005 100644
--- a/lib_enc/ivas_core_pre_proc.c
+++ b/lib_enc/ivas_core_pre_proc.c
@@ -284,7 +284,11 @@ ivas_error pre_proc_ivas_fx(
}
ELSE IF( GT_32( st->total_brate, MAX_GSC_INACTIVE_BRATE ) && ( ( st->vad_flag == 0 && GE_16( st->bwidth, SWB ) && GE_16( st->max_bwidth, SWB ) ) || ( st->localVAD == 0 && ( LE_16( st->bwidth, WB ) || LE_16( st->max_bwidth, WB ) ) ) ) )
{
+#ifdef NONBE_FIX_GSC_BSTR
+ /* inactive frames will be coded by AVQ technology (exceptionally it can be later rewritten to GSC technology in ivas_combined_format_brate_sanity()) */
+#else
/* inactive frames will be coded by AVQ technology */
+#endif
st->coder_type = INACTIVE;
move16();
}
@@ -571,6 +575,8 @@ ivas_error pre_proc_ivas_fx(
st->q_inp = -1;
move16();
Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q15 - Q_old_inp_16k */
+ st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q_old_inp_16k
+ move16();
st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k );
move16();
Word16 Q_old_inp_128k = *Q_new;
diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c
index 9e09f93f662b0e7ff3d7447316fed3ae9247b2e0..6ab82420f3929edd080006a583a4531d2663dcc6 100644
--- a/lib_enc/ivas_core_pre_proc_front.c
+++ b/lib_enc/ivas_core_pre_proc_front.c
@@ -853,7 +853,7 @@ ivas_error pre_proc_front_ivas_fx(
test();
IF( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL )
{
- *vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, vad_hover_flag, NULL, NULL ); /* Q0 */
+ *vad_flag_dtx = ivas_dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */
move16();
}
ELSE
@@ -1643,6 +1643,8 @@ ivas_error pre_proc_front_ivas_fx(
st->exp_mem_preemph_enc = sub( Q15, Q_old_inp_16k );
move16();
Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q15 - Q_old_inp_16k */
+ st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q_old_inp_16k
+ move16();
st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k );
move16();
Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc_pe ) ) ); /* Q15 - Q_old_inp_16k */
@@ -1666,7 +1668,7 @@ ivas_error pre_proc_front_ivas_fx(
*epsP_fx_q = add( Q_r[0], 1 );
move16();
- st->mem_wsp_enc = shr_r( st->mem_wsp_enc, *Q_new ); // Q_new - 1 -> Q-1
+ st->mem_wsp_enc = shl( st->mem_wsp_enc, sub( 0, sub( Q15, st->exp_buf_wspeech_enc ) ) ); // Q0
move16();
*Q_new = add( *Q_new, Q_to_be_looked_into ); // actual Q_new
@@ -1676,6 +1678,9 @@ ivas_error pre_proc_front_ivas_fx(
Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( 0, sub( Q15, st->exp_buf_speech_enc ) ) ); /* Q0 */
st->exp_buf_speech_enc = Q15;
move16();
+ Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( 0, sub( Q15, st->exp_buf_wspeech_enc ) ) ); /* Q0 */
+ st->exp_buf_wspeech_enc = Q15;
+ move16();
smc_dec = ivas_acelp_tcx20_switching_fx( st, st->speech_enc, 0, st->wspeech_enc, non_staX_fx, pitch_fr_fx, voicing_fr_fx, currFlatness_fx, lsp_mid_fx, stab_fac_fx, res_cod_SNR_M_fx, res_cod_SNR_M_fx_e, flag_16k_smc ); /* Q0 */
}
ELSE
diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c
index 5f04dc87f5014d8fc121c77ce211ec344ced090b..ea42591caa22b302ef665520ef8f386cdaf01341 100644
--- a/lib_enc/ivas_cpe_enc.c
+++ b/lib_enc/ivas_cpe_enc.c
@@ -365,8 +365,8 @@ ivas_error ivas_cpe_enc_fx(
Copy_Scale_sig_16_32_no_sat( sts[1]->input_fx, sts[1]->input32_fx, input_frame, sub( Q11, sts[1]->q_inp ) ); /* Q11 */
Copy_Scale_sig_16_32_no_sat( sts[0]->input_fx, sts[0]->input32_fx, input_frame, sub( Q11, sts[0]->q_inp ) ); /* Q11 */
#else
- Copy_Scale_sig_16_32_DEPREC( sts[1]->input_fx, sts[1]->input32_fx, input_frame, sub( Q11, sts[1]->q_inp ) ); /* Q11 */
- Copy_Scale_sig_16_32_DEPREC( sts[0]->input_fx, sts[0]->input32_fx, input_frame, sub( Q11, sts[0]->q_inp ) ); /* Q11 */
+ Copy_Scale_sig_16_32_DEPREC( sts[1]->input_fx, sts[1]->input32_fx, input_frame, sub( Q11, sts[1]->q_inp ) ); /* Q11 */
+ Copy_Scale_sig_16_32_DEPREC( sts[0]->input_fx, sts[0]->input32_fx, input_frame, sub( Q11, sts[0]->q_inp ) ); /* Q11 */
#endif
Word16 shift = getScaleFactor32( sts[1]->input32_fx, input_frame );
scale_sig32( sts[1]->input32_fx, input_frame, shift ); /* Q11 + shift */
@@ -394,6 +394,25 @@ ivas_error ivas_cpe_enc_fx(
/*----------------------------------------------------------------*
* Resets/updates in case of stereo switching
*----------------------------------------------------------------*/
+#ifdef FIX_ISSUE_1247
+ shift = norm_arr( sts[1]->old_input_signal_fx, input_frame );
+ Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */
+ sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift );
+ move16();
+ shift = norm_arr( sts[1]->input_fx, input_frame );
+ Scale_sig( sts[1]->input_fx, input_frame, shift ); /* sts[1]->q_inp + shift */
+ sts[1]->q_inp = add( sts[1]->q_inp, shift );
+ move16();
+
+ shift = norm_arr( sts[0]->old_input_signal_fx, input_frame );
+ Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */
+ sts[0]->q_old_inp = add( sts[0]->q_old_inp, shift );
+ move16();
+ shift = norm_arr( sts[0]->input_fx, input_frame );
+ Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[1]->q_inp, shift */
+ sts[0]->q_inp = add( sts[0]->q_inp, shift );
+ move16();
+#else
shift = getScaleFactor16( sts[1]->old_input_signal_fx, input_frame );
Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */
sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift );
@@ -411,6 +430,7 @@ ivas_error ivas_cpe_enc_fx(
Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[1]->q_inp, shift */
sts[0]->q_inp = add( sts[0]->q_inp, shift );
move16();
+#endif
Word16 q_inp = s_min( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), s_min( sts[1]->q_inp, sts[1]->q_old_inp ) );
@@ -775,37 +795,33 @@ ivas_error ivas_cpe_enc_fx(
test();
IF( hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL )
{
-
- shift = getScaleFactor16( sts[1]->old_input_signal_fx, input_frame );
- Scale_sig( sts[1]->old_input_signal_fx, input_frame, shift ); /* sts[1]->q_old_inp + shift */
- sts[1]->q_old_inp = add( sts[1]->q_old_inp, shift );
- move16();
- shift = getScaleFactor16( sts[1]->input_fx, input_frame );
- Scale_sig( sts[1]->input_fx, input_frame, shift ); /* sts[1]->q_inp + shift */
- sts[1]->q_inp = add( sts[1]->q_inp, shift );
+ Word16 q_min;
+ q_min = sts[1]->q_old_inp;
move16();
- Scale_sig( sts[1]->input_fx, input_frame, sub( s_min( sts[1]->q_inp, sts[1]->q_old_inp ), sts[1]->q_inp ) ); /* min( sts[1]->q_inp, sts[1]->q_old_inp ) */
- Scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( s_min( sts[1]->q_old_inp, sts[1]->q_inp ), sts[1]->q_old_inp ) ); /* min( sts[1]->q_inp, sts[1]->q_old_inp ) */
- sts[1]->q_inp = s_min( sts[1]->q_inp, sts[1]->q_old_inp );
+ q_min = s_min( q_min, sts[1]->q_inp );
+ q_min = s_min( q_min, sts[0]->q_old_inp );
+ q_min = s_min( q_min, sts[0]->q_inp );
+
+ shift = norm_arr( sts[1]->old_input_signal_fx, input_frame );
+ shift = s_min( shift, norm_arr( sts[1]->input_fx, input_frame ) );
+ shift = s_min( shift, norm_arr( sts[0]->old_input_signal_fx, input_frame ) );
+ shift = s_min( shift, norm_arr( sts[0]->input_fx, input_frame ) );
+
+ q_min = add( q_min, shift );
+
+ scale_sig( sts[1]->input_fx, input_frame, sub( q_min, sts[1]->q_inp ) ); /* q_min */
+ scale_sig( sts[1]->old_input_signal_fx, input_frame, sub( q_min, sts[1]->q_old_inp ) ); /* q_min */
+ scale_sig( sts[0]->input_fx, input_frame, sub( q_min, sts[0]->q_inp ) ); /* q_min */
+ scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( q_min, sts[0]->q_old_inp ) ); /* q_min */
+
+ sts[1]->q_old_inp = q_min;
+ sts[0]->q_old_inp = q_min;
+ sts[1]->q_inp = q_min;
+ sts[0]->q_inp = q_min;
move16();
- sts[1]->q_old_inp = sts[1]->q_inp;
- move16();
-
- shift = getScaleFactor16( sts[0]->old_input_signal_fx, input_frame );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, shift ); /* sts[0]->q_old_inp + shift*/
- sts[0]->q_old_inp = add( sts[0]->q_old_inp, shift );
move16();
- shift = getScaleFactor16( sts[0]->input_fx, input_frame );
- Scale_sig( sts[0]->input_fx, input_frame, shift ); /* sts[0]->q_inp + shift */
- sts[0]->q_inp = add( sts[0]->q_inp, shift );
move16();
move16();
- Scale_sig( sts[0]->input_fx, input_frame, sub( s_min( sts[0]->q_inp, sts[0]->q_old_inp ), sts[0]->q_inp ) ); /* min( sts[0]->q_inp, sts[0]->q_old_inp ) */
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( s_min( sts[0]->q_old_inp, sts[0]->q_inp ), sts[0]->q_old_inp ) ); /* min( sts[0]->q_inp, sts[0]->q_old_inp ) */
- sts[0]->q_inp = s_min( sts[0]->q_inp, sts[0]->q_old_inp );
- move16();
- sts[0]->q_old_inp = sts[0]->q_inp;
- move16();
}
stereo_td_itd_mdct_stereo_fx( hCPE, vad_flag_dtx, vad_hover_flag, input_frame );
@@ -814,7 +830,6 @@ ivas_error ivas_cpe_enc_fx(
/*----------------------------------------------------------------*
* DFT stereo: iDFT and resampling on both channels
*----------------------------------------------------------------*/
-
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
Word32 internal_Fs;
@@ -838,11 +853,22 @@ ivas_error ivas_cpe_enc_fx(
stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL );
#ifdef FIX_ISSUE_1135
- Word16 common_q = s_min( sub( sts[0]->q_inp, 2 ), sts[0]->q_old_inp ); /* -2 from target Q-factor sts[0]->q_inp to avoid some saturations (issue 1135) */
- Word16 fir_delay_len = NS2SA( sts[0]->input_Fs, DELAY_FIR_RESAMPL_NS );
- Scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( common_q, sts[0]->q_old_inp ) ); // q_old_inp -> common_q
+ // Normalise the input buffer from Q15
+ Word16 input_norm, q_inp32, common_q, fir_delay_len;
+ input_norm = L_norm_arr( sts[0]->input32_fx + out_start_ind, sub( out_end_ind, out_start_ind ) );
+ q_inp32 = add( Q15, input_norm );
+ fir_delay_len = NS2SA( sts[0]->input_Fs, DELAY_FIR_RESAMPL_NS );
+ move16();
+
+ // Find common Q-factor between { q_inp, q_old_inp and q_inp32-16 }
+ common_q = s_min( s_min( sub( q_inp32, 16 ), sts[0]->q_inp ), sts[0]->q_old_inp );
+
+ // Rescale the old input, input and FIR delay section of input buffer
+ scale_sig( sts[0]->old_input_signal_fx, input_frame, sub( common_q, sts[0]->q_old_inp ) ); // q_old_inp -> common_q
Copy_Scale_sig32_16( sts[0]->input32_fx + out_start_ind, sts[0]->input_fx + out_start_ind, sub( out_end_ind, out_start_ind ), sub( add( Q16, common_q ), Q15 ) ); // Q15 -> common_q
- Scale_sig( sts[0]->input_fx + out_end_ind, add( sub( input_frame, out_end_ind ), fir_delay_len ), sub( common_q, sts[0]->q_inp ) ); // q_inp -> common_q
+ scale_sig( sts[0]->input_fx + out_end_ind, add( sub( input_frame, out_end_ind ), fir_delay_len ), sub( common_q, sts[0]->q_inp ) ); // q_inp -> common_q
+
+ // Update the Q-factors
sts[0]->q_inp = common_q;
move16();
sts[0]->q_old_inp = common_q;
@@ -897,13 +923,8 @@ ivas_error ivas_cpe_enc_fx(
/*----------------------------------------------------------------*
* Front Pre-processing
*----------------------------------------------------------------*/
-
FOR( n = 0; n < n_CoreChannels; n++ )
{
- FOR( Word16 i = 0; i < hCPE->hCoreCoder[n]->nb_subfr; i++ )
- {
- Scale_sig( &A_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12
- }
set16_fx( old_wsp_fx[n], 0, L_WSP );
q_old_wsp = Q15;
move16();
diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c
index 9bcc34dd8003099485b07e246bc3a98006ec4ce5..32138fabab3e4ac84a7d843fcbe19d72de65946b 100644
--- a/lib_enc/ivas_ism_metadata_enc.c
+++ b/lib_enc/ivas_ism_metadata_enc.c
@@ -317,7 +317,10 @@ ivas_error ivas_ism_metadata_enc_fx(
}
ELSE IF( EQ_16( hIsmMeta[ch]->ism_md_fec_cnt_enc, ISM_MD_FEC_CNT_MAX ) )
{
-
+#ifdef NONBE_1273_ISM_METADATA_COUNTER
+ hIsmMeta[ch]->ism_md_fec_cnt_enc = 0;
+ move16();
+#endif
lowrate_metadata_flag[ch] = 1;
move16();
hIsmMeta[ch]->position_angle.angle1_diff_cnt = ISM_FEC_MAX;
@@ -639,6 +642,10 @@ ivas_error ivas_ism_metadata_enc_fx(
{
hIsmMeta[ch]->ism_md_fec_cnt_enc = add( hIsmMeta[ch]->ism_md_fec_cnt_enc, 1 );
move16();
+#ifdef NONBE_1273_ISM_METADATA_COUNTER
+ hIsmMeta[ch]->ism_md_fec_cnt_enc = s_min( hIsmMeta[ch]->ism_md_fec_cnt_enc, ISM_MD_FEC_CNT_MAX );
+ move16();
+#endif
}
ELSE
{
@@ -806,6 +813,10 @@ ivas_error ivas_ism_metadata_enc_fx(
{
hIsmMeta[ch]->ism_md_fec_cnt_enc = add( hIsmMeta[ch]->ism_md_fec_cnt_enc, 1 );
move16();
+#ifdef NONBE_1273_ISM_METADATA_COUNTER
+ hIsmMeta[ch]->ism_md_fec_cnt_enc = s_min( hIsmMeta[ch]->ism_md_fec_cnt_enc, ISM_MD_FEC_CNT_MAX );
+ move16();
+#endif
}
ELSE
{
diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c
index 0577df3407257d03337d57a269fc8b14f6629426..43162f6debf18e4b89df36f7f56fdd7b1da31980 100644
--- a/lib_enc/ivas_mc_param_enc.c
+++ b/lib_enc/ivas_mc_param_enc.c
@@ -1011,8 +1011,6 @@ static void ivas_param_mc_param_est_enc_fx(
move16();
ref_ener_fx = BASOP_Util_Add_Mant32Exp( ref_ener_fx, ref_ener_e, Cx_sum_fx[cur_param_band][ref_channel_idx][ref_channel_idx], // ref_ener_e
Cx_sum_e[cur_param_band][ref_channel_idx][ref_channel_idx], &ref_ener_e );
- ref_ener_e = Cx_sum_e[cur_param_band][ref_channel_idx][ref_channel_idx];
- move16();
}
L_tmp = Mpy_32_16_1( ref_ener_fx, hParamMC->hMetadataPMC.ild_factors_fx[k] );
#ifdef FIX_ISSUE_1154
diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c
index 18218aa257144fde5068e0a7799cf17a9672b152..4b84ea9cb607b05c7e6cd50ab7a198d9f8795b11 100644
--- a/lib_enc/ivas_mct_enc_mct.c
+++ b/lib_enc/ivas_mct_enc_mct.c
@@ -601,6 +601,11 @@ static void getGlobalILD_fx(
{
sts[ch]->hTcxEnc->spectrum_e[k] = add( sts[ch]->hTcxEnc->spectrum_e[k], 4 ); // Updating exponent of spectrum as q_ratio is in Q11
}
+ IF( GT_16( nSubframes, 1 ) )
+ {
+ sts[ch]->hTcxEnc->spectrum_long_e = add( sts[ch]->hTcxEnc->spectrum_long_e, 4 );
+ move16();
+ }
FOR( k = 0; k < nSubframes; k++ )
{
@@ -877,10 +882,12 @@ void apply_MCT_enc_fx(
}
sts[ch]->hTcxEnc->spectrum_e[1] = add( sts[ch]->hTcxEnc->spectrum_e[0], exp );
sts[ch]->hTcxEnc->spectrum_e[0] = add( sts[ch]->hTcxEnc->spectrum_e[0], exp );
+ sts[ch]->hTcxEnc->spectrum_long_e = add( sts[ch]->hTcxEnc->spectrum_long_e, exp );
hMCT->mc_global_ild[ch] = 0;
move16();
move16();
move16();
+ move16();
}
}
}
diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c
index 734fbcf9d7c60f5f09369bd9d60015737296b1d6..18bee6777ee6ba6961bb2f7c5733b831cf25ee93 100644
--- a/lib_enc/ivas_mdct_core_enc.c
+++ b/lib_enc/ivas_mdct_core_enc.c
@@ -1628,10 +1628,14 @@ void ivas_mdct_core_whitening_enc_fx(
Scale_sig32( mdst_spectrum_fx[0][n], tcx5SizeFB, scale ); // q_com
Scale_sig32( mdst_spectrum_fx[1][n], tcx5SizeFB, scale ); // q_com
- Scale_sig32( hTcxEnc0->spectrum_fx[n] + offset1, offset2, scale ); // q_com
- Scale_sig32( hTcxEnc1->spectrum_fx[n] + offset1, offset2, scale ); // q_com
- Scale_sig32( mdst_spectrum_fx[0][n] + offset1, offset2, scale ); // q_com
- Scale_sig32( mdst_spectrum_fx[1][n] + offset1, offset2, scale ); // q_com
+ offset2 = sub( idiv1616( hTcxEnc0->L_frameTCX, nSubframes ), offset1 );
+ IF( offset2 > 0 )
+ {
+ Scale_sig32( hTcxEnc0->spectrum_fx[n] + offset1, offset2, scale ); // q_com
+ Scale_sig32( hTcxEnc1->spectrum_fx[n] + offset1, offset2, scale ); // q_com
+ Scale_sig32( mdst_spectrum_fx[0][n] + offset1, offset2, scale ); // q_com
+ Scale_sig32( mdst_spectrum_fx[1][n] + offset1, offset2, scale ); // q_com
+ }
}
mdst_spectrum_e[0][n] = sub( Q31, q_com );
hTcxEnc0->spectrum_e[n] = sub( Q31, q_com );
@@ -2104,8 +2108,13 @@ void ivas_mdct_core_whitening_enc_fx(
st->hTcxEnc->spectrum_e[n] = sub( st->hTcxEnc->spectrum_e[n], q_com );
move16();
+ Word16 exp_tmp = st->hTcxEnc->spectrum_e[n];
+ move16();
+
/* Shape spectrum */
ShapeSpectrum_ivas_fx( st->hTcxCfg, A_q_fx[ch][n], NULL, NULL, L_subframe, tcx_subframe_coded_lines, st->hTcxEnc->spectrum_fx[n], &st->hTcxEnc->spectrum_e[n], st->hTcxEnc->fUseTns[n], st, scf_q_fx[ch][n] );
+
+ Scale_sig32( st->hTcxEnc->spectrum_fx[n] + L_subframe, sub( L_subframeTCX, L_subframe ), sub( exp_tmp, st->hTcxEnc->spectrum_e[n] ) );
}
}
/*--------------------------------------------------------------*
@@ -2239,8 +2248,13 @@ void ivas_mdct_core_whitening_enc_fx(
mdst_spectrum_e[ch][n] = sub( mdst_spectrum_e[ch][n], q_com );
move16();
+ Word16 exp_tmp = mdst_spectrum_e[ch][n];
+ move16();
+
/* Shape spectrum */
ShapeSpectrum_ivas_fx( st->hTcxCfg, A_q_fx[ch][n], NULL, NULL, L_subframe, tcx_subframe_coded_lines, mdst_spectrum_fx[ch][n], &mdst_spectrum_e[ch][n], st->hTcxEnc->fUseTns[n], st, scf_q_fx[ch][n] );
+
+ Scale_sig32( mdst_spectrum_fx[ch][n] + L_subframe, sub( L_subframeTCX, L_subframe ), sub( exp_tmp, mdst_spectrum_e[ch][n] ) );
}
}
}
diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c
index 90e9752f47982a63607d4ddc347e70f6067505a3..d532a9af18fc13b40ce2c44cacc16ef3c6356c5d 100644
--- a/lib_enc/ivas_stereo_dft_enc.c
+++ b/lib_enc/ivas_stereo_dft_enc.c
@@ -1706,20 +1706,22 @@ void stereo_dft_enc_process_fx(
IF( alpha_fx >= 0 )
{
+ c_fx = shr( c_fx, 1 );
+ s_fx = shr( s_fx, 1 );
FOR( i = 1; i < hStereoDft->NFFT / 2; i++ )
{
// tmp = s * c1 + c * s1;
- tmp_fx = add_sat( mult_r( s_fx, c1_fx ), mult_r( c_fx, s1_fx ) ); // saturation expected
+ tmp_fx = add( mult_r( s_fx, c1_fx ), mult_r( c_fx, s1_fx ) );
// c = c * c1 - s * s1;
- c_fx = sub_sat( mult_r( c_fx, c1_fx ), mult_r( s_fx, s1_fx ) ); // saturation expected
+ c_fx = sub( mult_r( c_fx, c1_fx ), mult_r( s_fx, s1_fx ) );
s_fx = tmp_fx;
move16();
/*time shift of L*/
// tmp = pDFT_L[2 * i] * c - pDFT_L[2 * i + 1] * s;
- tmp_32fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pDFT_L_fx[2 * i], c_fx ), DFT_L_e_tmp[2 * i], L_negate( Mpy_32_16_1( pDFT_L_fx[2 * i + 1], s_fx ) ), DFT_L_e_tmp[2 * i + 1], &tmp_e );
+ tmp_32fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pDFT_L_fx[2 * i], c_fx ), add( DFT_L_e_tmp[2 * i], 1 ), L_negate( Mpy_32_16_1( pDFT_L_fx[2 * i + 1], s_fx ) ), add( DFT_L_e_tmp[2 * i + 1], 1 ), &tmp_e );
// pDFT_L[2 * i + 1] = pDFT_L[2 * i] * s + pDFT_L[2 * i + 1] * c;
- pDFT_L_fx[2 * i + 1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pDFT_L_fx[2 * i], s_fx ), DFT_L_e_tmp[2 * i], Mpy_32_16_1( pDFT_L_fx[2 * i + 1], c_fx ), DFT_L_e_tmp[2 * i + 1], &DFT_L_e_tmp[2 * i + 1] );
+ pDFT_L_fx[2 * i + 1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pDFT_L_fx[2 * i], s_fx ), add( DFT_L_e_tmp[2 * i], 1 ), Mpy_32_16_1( pDFT_L_fx[2 * i + 1], c_fx ), add( DFT_L_e_tmp[2 * i + 1], 1 ), &DFT_L_e_tmp[2 * i + 1] );
move32();
// pDFT_L[2 * i] = tmp;
pDFT_L_fx[2 * i] = tmp_32fx;
diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c
index 3f4696a0698e53d21ea0ef0c48f714b426e95daf..9d06a5523c8ce03a109f8aa85c19c67008243b3d 100644
--- a/lib_enc/ivas_stereo_ica_enc.c
+++ b/lib_enc/ivas_stereo_ica_enc.c
@@ -1337,17 +1337,10 @@ static void estDownmixGain_fx(
}
ELSE IF( GT_16( hStereoTCA->LRTD_G_ATT_cnt, 1 ) ) /* lrtd_mode == 1 but tdm_LRTD_flag still 0 */
{
- currentGain = BASOP_Util_Divide1616_Scale( currentGain, hStereoTCA->LRTD_G_ATT_cnt, ¤tGain_e ); // Q = 15 + 0 - (15 - exp)
- /* Division result Q has to be got back to the Q of initial currentGain hence the shift operation below */
- IF( currentGain_e != 0 )
- {
- currentGain = shr( currentGain, sub( Q15, currentGain_e ) ); /* Q15 */
- currentGain_e = 0;
- move16();
- }
+ currentGain = BASOP_Util_Divide1616_Scale( currentGain, hStereoTCA->LRTD_G_ATT_cnt, &exp );
+ currentGain_e = add( exp, sub( currentGain_e, 15 ) );
}
-
IF( GE_16( norm_s( currentGain ), sub( currentGain_e, 1 ) ) )
{
/* convert currentGain into Q14 */
@@ -1892,7 +1885,7 @@ void stereo_tca_enc_fx(
ELSE
{
v_multc_fixed( bufChanL_fx, ONE_IN_Q29, bufChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/
- Copy32( ptrChanL_fx + add( prevNCShift, sub( lMemRecalc, lMemRecalc_SCh ) ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2
+ Copy32( ptrChanL_fx + sub( prevNCShift, add( lMemRecalc, lMemRecalc_SCh ) ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2
v_multc_fixed( ptrChanR_fx - add( lMemRecalc, lMemRecalc_SCh ), hStereoTCA->prevTargetGain_fx, input_mem_loc_fx[1], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2
v_multc_fixed( bufChanR_fx, ONE_IN_Q29, bufChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/
}
@@ -2258,9 +2251,22 @@ static void unclr_calc_corr_features_fx(
corrR = BASOP_Util_Add_Mant32Exp( corrR, corrR_exp, Mpy_32_32( buf2[i], mono_i ), add( sub( 31, q_com ), exp ), &corrR_exp ); /* Q31-corrR_exp */
ener = BASOP_Util_Add_Mant32Exp( ener, ener_exp, Mpy_32_32( mono_i, mono_i ), shl( exp, 1 ), &ener_exp );
- side_i = BASOP_Util_Add_Mant32Exp( L_shr( buf1[i], 1 ), sub( 31, q_com ), L_negate( L_shr( buf2[i], 1 ) ), sub( 31, q_com ), &exp ); /* Q31-exp */
- ener_side = BASOP_Util_Add_Mant32Exp( ener_side, ener_side_exp, Mpy_32_32( side_i, side_i ), shl( exp, 1 ), &ener_side_exp ); /* Q31-ener_side_exp */
+ side_i = BASOP_Util_Add_Mant32Exp( L_shr( buf1[i], 1 ), sub( 31, q_com ), L_negate( L_shr( buf2[i], 1 ) ), sub( 31, q_com ), &exp ); /* Q31-exp */
+ ener_side = BASOP_Util_Add_Mant32Exp( ener_side, ener_side_exp, Mpy_32_32( side_i, side_i ), shl( exp, 1 ), &ener_side_exp ); /* Q31-ener_side_exp */
+
+#ifdef FIX_ISSUE_1125
+ Word16 n1, n2, prod_i_exp;
+ Word32 x, y, prod_i;
+ n1 = norm_l( buf1[i] );
+ n2 = norm_l( buf2[i] );
+ x = L_shl( buf1[i], n1 ); // q: q_com + n1
+ y = L_shl( buf2[i], n2 ); // q: q_com + n2
+ prod_i = Mpy_32_32( x, y ); // q: q_com * 2 + n1 + n2 - 31
+ prod_i_exp = sub( 62, add( shl( q_com, 1 ), add( n1, n2 ) ) );
+ sum_prod = BASOP_Util_Add_Mant32Exp( sum_prod, sum_prod_exp, prod_i, prod_i_exp, &sum_prod_exp ); /* Q31-sum_prod_exp */
+#else
sum_prod = BASOP_Util_Add_Mant32Exp( sum_prod, sum_prod_exp, Mpy_32_32( buf1[i], buf2[i] ), sub( 62, shl( q_com, 1 ) ), &sum_prod_exp ); /* Q31-sum_prod_exp */
+#endif
}
/* average energy of L and R channels */
diff --git a/lib_enc/ivas_stereo_icbwe_enc.c b/lib_enc/ivas_stereo_icbwe_enc.c
index cc5f8453a7676c6874338305c4f63a79870bd9a3..9cf899bcbe9adf56c579a6cbc76a1111c84e1f26 100644
--- a/lib_enc/ivas_stereo_icbwe_enc.c
+++ b/lib_enc/ivas_stereo_icbwe_enc.c
@@ -219,8 +219,11 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
u_fx = extract_l( *specMapping_fx );
- tmp = mult( b_fx, b_fx ); // b_e + b_e;
- tmp1 = mult( a_fx, c_fx ); // a_e + c_e + 2
+
+ /* while performing (-32768)*(-32768), overflow occurs because the result comes out as 32768 after mult. This is the only case for mult where overflow happens. In order to avoid this scenario mult_sat is used */
+
+ tmp = mult_sat( b_fx, b_fx ); // b_e + b_e;
+ tmp1 = mult_sat( a_fx, c_fx ); // a_e + c_e + 2
exp = BASOP_Util_Add_MantExp( tmp, add( b_e, b_e ), tmp1, add( a_e, add( c_e, 2 ) ), &temp_fx ); /* Q15-exp */
test();
@@ -286,7 +289,7 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
/* Quantize spec. mapping **/
Word16 specMapping16;
- idx = usquant_fx( shr( u_fx, sub( 0, u_e ) ), &specMapping16, -19660, 6553, ( 1 << STEREO_ICBWE_SPBITS ) ); // -0.6 in in Q15 -> -19660, 0.2 in Q15 -> 6553
+ idx = usquant_fx( shr( u_fx, sub( 0, u_e ) ), &specMapping16, -19660, 6553 >> 1, ( 1 << STEREO_ICBWE_SPBITS ) ); // -0.6 in in Q15 -> -19660, 0.2 in Q15 -> 6553
*specMapping_fx = L_deposit_h( specMapping16 );
move32();
@@ -347,15 +350,13 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx(
temp2_fx32 = BASOP_Util_Add_Mant32Exp( temp2_fx32, temp2_exp, L_abs( synthSHB_nonref_fx[i] ), exp2, &temp2_exp ); /* Q31-temp2_exp */
}
-
- memEner_fx[0] = temp1_fx32; /* Q31-temp1_exp */
- memEner_fx[1] = L_shr( temp2_fx32, abs_s( sub( temp1_exp, temp2_exp ) ) ); /* Q31-temp1_exp */
+ memEner_fx[0] = L_shr( temp1_fx32, sub( s_max( temp1_exp, temp2_exp ), temp1_exp ) );
+ memEner_fx[1] = L_shr( temp2_fx32, sub( s_max( temp1_exp, temp2_exp ), temp2_exp ) );
move32();
move32();
*memEner_e = s_max( temp1_exp, temp2_exp );
move16();
-
IF( temp2_fx32 == 0 )
{
*gsMapping_fx = *gsMapping_fx;
@@ -364,7 +365,7 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx(
ELSE
{
L_mult = Mpy_32_32( relG_targ_fx, temp1_fx32 ); // relG_targ_e + temp1_e
- temp1 = BASOP_Util_Divide3232_Scale( L_mult, temp1_fx32, &exp ); // exp = exp - ( relG_targ_e + temp1_e + temp2_e )
+ temp1 = BASOP_Util_Divide3232_Scale( L_mult, temp2_fx32, &exp ); // exp = exp - ( relG_targ_e + temp1_e - temp2_e )
exp = add( exp, sub( add( relG_targ_e, temp1_exp ), temp2_exp ) );
*gsMapping_fx = L_deposit_h( temp1 ); // exp
move32();
@@ -374,23 +375,44 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx(
/* quantize the IC-BWE GS mapping*/
IF( EQ_16( element_mode, IVAS_CPE_TD ) )
{
- temp2_fx = extract_l( L_shr( temp2_fx32, Q10 ) ); // Q15
+ IF( LT_32( temp2_fx32, -( 2 << 25 ) ) )
+ {
+ temp2_fx = -( 2 << 12 ); // Q12
+ move16();
+ }
+ ELSE IF( GT_32( temp2_fx32, 1 << 25 ) )
+ {
+ temp2_fx = 1 << 12; // Q12
+ move16();
+ }
+
+ temp2_fx = extract_h( L_shl_sat( temp2_fx32, Q3 ) ); // Q12
gsMapping_fx16 = 0;
move16();
idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMapping_tbl_fx, ( 1 << STEREO_ICBWE_GSBITS ) ); // Q12
- // idx = squant_fx( temp2, gsMapping, icbwe_gsMapping_tbl_fx, 1 << STEREO_ICBWE_GSBITS );
}
ELSE
{
- temp2_fx = extract_l( L_shr( temp2_fx32, Q10 ) ); // Q15
+ IF( LT_32( temp2_fx32, -( 5 << 25 ) ) )
+ {
+ temp2_fx = -( 5 << 12 ); // Q12
+ move16();
+ }
+ ELSE IF( GT_32( temp2_fx32, 1 << 25 ) )
+ {
+ temp2_fx = 1 << 12; // Q12
+ move16();
+ }
+
+ temp2_fx = extract_h( L_shl_sat( temp2_fx32, Q3 ) ); // Q12
gsMapping_fx16 = 0;
move16();
- idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMappingDFT_tbl_fx, ( 1 << STEREO_ICBWE_GSBITS ) ); // Q12
+ idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMappingDFT_tbl_fx, ( 1 << STEREO_ICBWE_GSBITS_DFT ) ); // Q12
}
*gsMapping_fx = L_deposit_h( gsMapping_fx16 ); // Q28
move32();
Word16 e;
- L_mult = Mult_32_16( *gsMapping_fx, 27213 /*=log2(10)*2^13*/ ); // Q27 + Q13 - Q15 -> Q26
+ L_mult = Mult_32_16( *gsMapping_fx, 27213 /*=log2(10)*2^13*/ ); // Q28 + Q13 - Q15 -> Q26
*gsMapping_fx = BASOP_util_Pow2( L_mult, 5, &e ); /* Q31-e */
move32();
@@ -429,25 +451,24 @@ static void icbwe_dft_stereo_param_ivas_fx(
nrg_R_fx = hStereoDft->nrg_R_fx;
nrg_DMX_fx = hStereoDft->nrg_DMX_fx;
-
- hStereoICBWE->mem_nrg_L_fx[0] = nrg_L_fx[0]; // hStereoICBWE->nrg_L_fx_e[0]
- hStereoICBWE->mem_nrg_R_fx[0] = nrg_R_fx[0]; // hStereoICBWE->nrg_R_fx_e[0]
- hStereoICBWE->mem_nrg_DMX_fx[0] = nrg_DMX_fx[0]; // hStereoICBWE->nrg_DMX_fx_e[0]
- hStereoICBWE->mem_nrg_L_fx[1] = L_shr( nrg_L_fx[1], abs_s( sub( hStereoDft->nrg_L_fx_e[0], hStereoDft->nrg_L_fx_e[1] ) ) ); // hStereoICBWE->nrg_L_fx_e[1]
- hStereoICBWE->mem_nrg_R_fx[1] = L_shr( nrg_R_fx[1], abs_s( sub( hStereoDft->nrg_R_fx_e[0], hStereoDft->nrg_R_fx_e[1] ) ) ); // hStereoICBWE-> nrg_R_fx_e[1]
- hStereoICBWE->mem_nrg_DMX_fx[1] = L_shr( nrg_DMX_fx[1], abs_s( sub( hStereoDft->nrg_DMX_fx_e[0], hStereoDft->nrg_DMX_fx_e[1] ) ) ); // hStereoICBWE->nrg_DMX_fx_e[1]
- move32();
- move32();
- move32();
- move32();
- move32();
- move32();
hStereoICBWE->mem_nrg_L_fx_e = s_max( hStereoDft->nrg_L_fx_e[0], hStereoDft->nrg_L_fx_e[1] );
hStereoICBWE->mem_nrg_R_fx_e = s_max( hStereoDft->nrg_R_fx_e[0], hStereoDft->nrg_R_fx_e[1] );
hStereoICBWE->mem_nrg_DMX_fx_e = s_max( hStereoDft->nrg_DMX_fx_e[0], hStereoDft->nrg_DMX_fx_e[1] );
move16();
move16();
move16();
+ hStereoICBWE->mem_nrg_L_fx[0] = L_shr( nrg_L_fx[0], sub( hStereoICBWE->mem_nrg_L_fx_e, hStereoDft->nrg_L_fx_e[0] ) );
+ hStereoICBWE->mem_nrg_R_fx[0] = L_shr( nrg_R_fx[0], sub( hStereoICBWE->mem_nrg_R_fx_e, hStereoDft->nrg_R_fx_e[0] ) );
+ hStereoICBWE->mem_nrg_DMX_fx[0] = L_shr( nrg_DMX_fx[0], sub( hStereoICBWE->mem_nrg_DMX_fx_e, hStereoDft->nrg_DMX_fx_e[0] ) );
+ hStereoICBWE->mem_nrg_L_fx[1] = L_shr( nrg_L_fx[1], sub( hStereoICBWE->mem_nrg_L_fx_e, hStereoDft->nrg_L_fx_e[1] ) );
+ hStereoICBWE->mem_nrg_R_fx[1] = L_shr( nrg_R_fx[1], sub( hStereoICBWE->mem_nrg_R_fx_e, hStereoDft->nrg_R_fx_e[1] ) );
+ hStereoICBWE->mem_nrg_DMX_fx[1] = L_shr( nrg_DMX_fx[1], sub( hStereoICBWE->mem_nrg_DMX_fx_e, hStereoDft->nrg_DMX_fx_e[1] ) );
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
+ move32();
Word16 sum_nrg_L_e = hStereoICBWE->mem_nrg_L_fx_e, sum_nrg_R_e = hStereoICBWE->mem_nrg_R_fx_e, sum_nrg_DMX_e = hStereoICBWE->mem_nrg_DMX_fx_e;
sum_nrg_L_fx = sum_32_fx( hStereoICBWE->mem_nrg_L_fx, 2, &sum_nrg_L_e ); // hStereoICBWE->mem_nrg_L_fx_e
@@ -510,9 +531,13 @@ static void icbwe_dft_stereo_param_ivas_fx(
hStereoICBWE->prevSpecMapping_fx = spec_table_fx[spIndx]; // q31
/* ic bwe spec mapping application */
deemph_fx_32( 0, shb_synth_nonref_fx, extract_l( L_shr( hStereoICBWE->prevSpecMapping_fx, 16 ) ), L_FRAME16k, &hStereoICBWE->memShbSpecMapping_fx ); // shb_synth_nonref_e
+ hStereoICBWE->memShbSpecMapping_e = shb_synth_nonref_e;
+ move16();
}
ELSE
{
+ hStereoICBWE->memShbSpecMapping_e = 0;
+ move16();
hStereoICBWE->memShbSpecMapping_fx = 0;
hStereoICBWE->prevSpecMapping_fx = 0;
move32();
@@ -692,6 +717,8 @@ void stereo_icBWE_enc_ivas_fx(
v_multc_fixed( voice_factors_fx, 1073741824, nlMixFac_fx, NB_SUBFR16k ); // Q31, 0.5 in Q31 -> 1073741824
}
+ Word16 L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR;
+ move16();
IF( st->flag_ACELP16k == 0 )
{
nbSubFr = NB_SUBFR;
@@ -701,6 +728,8 @@ void stereo_icBWE_enc_ivas_fx(
{
nbSubFr = NB_SUBFR16k;
move16();
+ L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR16k;
+ move16();
}
Word16 exp_buf[L_FRAME16k];
@@ -728,11 +757,9 @@ void stereo_icBWE_enc_ivas_fx(
temp2_fx = Sqrt32( L_sub( ONE_IN_Q31, nlMixFac_fx[i] ), &temp2_e ); /* Q31-temp2_e */
}
- tmp = BASOP_Util_Divide1616_Scale( L_FRAME16k, nbSubFr, &exp ); /* Q15-exp */
- tmp = shr( tmp, sub( Q15, exp ) ); /* Q0 */
- FOR( j = 0; j < tmp; ( j++, k++ ) )
+ FOR( j = 0; j < L_FRAME16k_by_nbSubFr; ( j++, k++ ) )
{
- excSHB_nonref_fx[k] = extract_l( BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, hStereoICBWE->nlExc16k_fx[k] ), add( temp1_e, hStereoICBWE->nlExc16k_e ), Mpy_32_32( temp2_fx, hStereoICBWE->mixExc16k_fx[k] ), add( temp2_e, hStereoICBWE->mixExc16k_e ), &exp_buf[k] ) ); /* Q31-exp_buf */
+ excSHB_nonref_fx[k] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, L_deposit_h( hStereoICBWE->nlExc16k_fx[k] ) ), add( temp1_e, hStereoICBWE->nlExc16k_e ), Mpy_32_32( temp2_fx, L_deposit_h( hStereoICBWE->mixExc16k_fx[k] ) ), add( temp2_e, hStereoICBWE->mixExc16k_e ), &exp_buf[k] ); /* Q31-exp_buf */
move32();
}
}
@@ -754,19 +781,13 @@ void stereo_icBWE_enc_ivas_fx(
move32();
}
/* LP synthesis */
- Word16 tmp_e = s_max( hCPE->hStereoICBWE->lpSHBRef_e, max_e );
-
- Word32 lpSHBRef_fx32[LPC_SHB_ORDER + 1];
- Copy_Scale_sig32( hCPE->hStereoICBWE->lpSHBRef_fx, lpSHBRef_fx32, LPC_SHB_ORDER + 1, negate( sub( tmp_e, hCPE->hStereoICBWE->lpSHBRef_e ) ) ); /* Q31-tmp_e */
- Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, negate( sub( tmp_e, max_e ) ) ); /* Q31-tmp_e */
- // set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, LPC_SHB_ORDER );
- E_UTIL_synthesis_fx( 0, lpSHBRef_fx32, excSHB_nonref_fx, shb_synth_nonref_fx, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 1, LPC_SHB_ORDER );
+ Copy_Scale_sig32( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, LPC_SHB_ORDER, sub( hStereoICBWE->mem_lpc_shbsynth_nonref_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */
+ Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, sub( max_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */
+ max_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e );
+ hStereoICBWE->mem_lpc_shbsynth_nonref_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e );
- shb_synth_nonref_e = tmp_e;
- hStereoICBWE->mem_lpc_shbsynth_nonref_e = tmp_e;
- move16();
- move16();
+ syn_filt_fx32( hStereoICBWE->lpSHBRef_e, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER, excSHB_nonref_fx, max_e, shb_synth_nonref_fx, &shb_synth_nonref_e, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, &hStereoICBWE->mem_lpc_shbsynth_nonref_e, 1 );
}
ELSE
{
@@ -777,11 +798,11 @@ void stereo_icBWE_enc_ivas_fx(
shb_synth_nonref_e = shb_frame_ref_e;
move16();
set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, 10 );
+ hStereoICBWE->mem_lpc_shbsynth_nonref_e = 0;
+ move16();
}
icbwe_dft_stereo_param_ivas_fx( hStereoICBWE, hStereoDft, st, shb_synth_nonref_fx, shb_synth_nonref_e );
- hStereoICBWE->memShbSpecMapping_e = shb_synth_nonref_e;
- move16();
}
ELSE
{
@@ -847,6 +868,8 @@ void stereo_icBWE_enc_ivas_fx(
IF( ( NE_16( hStereoICBWE->prev_refChanIndx_bwe, hStereoICBWE->refChanIndx_bwe ) ) || NE_16( st->last_extl, st->extl ) || NE_16( st->flag_ACELP16k, 1 ) )
{
hStereoICBWE->prevSpecMapping_fx = 0;
+ hStereoICBWE->memShbSpecMapping_e = 0;
+ move16();
hStereoICBWE->memShbSpecMapping_fx = 0;
move32();
move32();
@@ -916,6 +939,8 @@ void stereo_icBWE_enc_ivas_fx(
v_multc_fixed( voice_factors_fx, 1073741824 /*0.5 in Q31*/, nlMixFac_fx, NB_SUBFR16k ); /* Q31 */
}
+ Word16 L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR;
+ move16();
IF( st->flag_ACELP16k == 0 )
{
nbSubFr = NB_SUBFR;
@@ -925,6 +950,8 @@ void stereo_icBWE_enc_ivas_fx(
{
nbSubFr = NB_SUBFR16k;
move16();
+ L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR16k;
+ move16();
}
Word16 exp_buf[L_FRAME16k];
@@ -949,13 +976,13 @@ void stereo_icBWE_enc_ivas_fx(
temp1_e = 0, temp2_e = 0;
temp1_fx = Sqrt32( nlMixFac_fx[i], &temp1_e ); /* Q31-temp1_e */
temp2_fx = Sqrt32( L_sub( ONE_IN_Q31, nlMixFac_fx[i] ), &temp2_e ); /* Q31 */
- move32();
+ move16();
move16();
}
- FOR( j = 0; j < ( L_FRAME16k / nbSubFr ); ( j++, k++ ) )
+ FOR( j = 0; j < L_FRAME16k_by_nbSubFr; ( j++, k++ ) )
{
- excSHB_nonref_fx[k] = extract_l( BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, hStereoICBWE->nlExc16k_fx[k] ), temp1_e + hStereoICBWE->nlExc16k_e, Mpy_32_32( temp2_fx, hStereoICBWE->mixExc16k_fx[k] ), temp2_e + hStereoICBWE->mixExc16k_e, &exp_buf[k] ) ); /* Q31-exp_buf */
+ excSHB_nonref_fx[k] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( temp1_fx, L_deposit_h( hStereoICBWE->nlExc16k_fx[k] ) ), add( temp1_e, hStereoICBWE->nlExc16k_e ), Mpy_32_32( temp2_fx, L_deposit_h( hStereoICBWE->mixExc16k_fx[k] ) ), add( temp2_e, hStereoICBWE->mixExc16k_e ), &exp_buf[k] ); /* Q31-exp_buf */
move32();
}
}
@@ -977,18 +1004,12 @@ void stereo_icBWE_enc_ivas_fx(
move32();
}
/* LP synthesis */
+ Copy_Scale_sig32( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, LPC_SHB_ORDER, sub( hStereoICBWE->mem_lpc_shbsynth_nonref_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */
+ Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, sub( max_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */
+ max_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e );
+ hStereoICBWE->mem_lpc_shbsynth_nonref_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e );
- Word16 tmp_e = s_max( hCPE->hStereoICBWE->lpSHBRef_e, max_e );
-
- Word32 lpSHBRef_fx32[LPC_SHB_ORDER + 1];
-
- Copy_Scale_sig32( hCPE->hStereoICBWE->lpSHBRef_fx, lpSHBRef_fx32, LPC_SHB_ORDER + 1, negate( sub( tmp_e, hCPE->hStereoICBWE->lpSHBRef_e ) ) ); /* Q31-tmp_e */
- Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, negate( sub( tmp_e, max_e ) ) ); /* Q31-tmp_e */
-
- E_UTIL_synthesis_fx( 0, hStereoICBWE->lpSHBRef_fx, excSHB_nonref_fx, shb_synth_nonref_fx, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 1, LPC_SHB_ORDER );
- shb_synth_nonref_e = sub( 31, tmp_e );
- hStereoICBWE->mem_lpc_shbsynth_nonref_e = shb_synth_nonref_e;
- move16();
+ syn_filt_fx32( hStereoICBWE->lpSHBRef_e, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER, excSHB_nonref_fx, max_e, shb_synth_nonref_fx, &shb_synth_nonref_e, L_FRAME16k, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, &hStereoICBWE->mem_lpc_shbsynth_nonref_e, 1 );
}
ELSE
{
@@ -999,6 +1020,8 @@ void stereo_icBWE_enc_ivas_fx(
shb_synth_nonref_e = shb_frame_ref_e;
move16();
set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, 10 );
+ hStereoICBWE->mem_lpc_shbsynth_nonref_e = 0;
+ move16();
}
test();
@@ -1007,6 +1030,13 @@ void stereo_icBWE_enc_ivas_fx(
IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) )
{
/* IC BWE spectral mapping */
+ Word32 max_abs_val;
+ maximum_abs_32_fx( shb_synth_nonref_fx, L_FRAME16k, &max_abs_val );
+ IF( max_abs_val > 0 )
+ {
+ scale_sig32( shb_synth_nonref_fx, L_FRAME16k, -1 );
+ shb_synth_nonref_e = sub( shb_synth_nonref_e, -1 );
+ }
spIndx = ic_bwe_enc_specMapping_ivas_fx( shb_frame_nonref_fx, shb_frame_nonref_e, shb_synth_nonref_fx, shb_synth_nonref_e, &( hStereoICBWE->prevSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_fx ), hStereoICBWE->memShbSpecXcorr_fx, &( hStereoICBWE->memShbSpecXcorr_e ) ); /* Q0 */
}
ELSE
@@ -1072,6 +1102,8 @@ void stereo_icBWE_init_enc_fx(
/* unscaled & scaled SHB synthesis memory */
set32_fx( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, 0, LPC_SHB_ORDER );
+ hStereoICBWE->mem_lpc_shbsynth_nonref_e = 0;
+ move16();
/* inter-channel BWE spectral shape adj. */
hStereoICBWE->prevSpecMapping_fx = 0;
diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c
index 58e72c91e38992ca05fab77506bbfdfa492344d5..49ac895ef311482c64b080c6271dc01daa9abd8b 100644
--- a/lib_enc/ivas_stereo_td_analysis.c
+++ b/lib_enc/ivas_stereo_td_analysis.c
@@ -635,14 +635,23 @@ Word16 stereo_tdm_ener_analysis_fx(
hStereoTD->tdm_last_LRTD_PriCh_cnt = add( hStereoTD->tdm_last_LRTD_PriCh_cnt, 1 );
move16();
}
- ratio_L_fx = tdm_ratio_tabl_fx[idx]; // Q31
+
+#ifdef FIX_ISSUE_1125
+ ratio_L_fx = tdm_ratio_tabl_fx_Q30[idx]; // Q30
+#else
+ ratio_L_fx = tdm_ratio_tabl_fx[idx]; // Q31
+#endif
move32();
test();
IF( EQ_16( hStereoTD->tdm_SM_modi_flag, 1 ) && hStereoTD->tdm_LRTD_flag == 0 )
{
idx = shr( add( hStereoTD->tdm_last_ratio_idx, add( LRTD_STEREO_MID_IS_PRIM, 1 ) ), 1 );
+#ifdef FIX_ISSUE_1125
+ ratio_L_fx = tdm_ratio_tabl_fx_Q30[idx]; // Q30
+#else
ratio_L_fx = tdm_ratio_tabl_fx[idx]; // Q31
+#endif
move32();
}
@@ -731,8 +740,12 @@ Word16 stereo_tdm_ener_analysis_fx(
move16();
}
- hCPE->hStereoClassif->ratio_L_fx = ratio_L_fx; /* Q15 */
+ hCPE->hStereoClassif->ratio_L_fx = ratio_L_fx; /* 31 - ratio_L_e */
move32();
+#ifdef FIX_ISSUE_1125
+ hCPE->hStereoClassif->ratio_L_e = 1;
+ move16();
+#endif
return idx;
}
@@ -1709,7 +1722,6 @@ Word16 tdm_lp_comparison_fx(
Word32 dist_fx, ftmp_fx;
Word16 i;
Word32 res_fx[L_FRAME16k];
- Word16 gb1 = find_guarded_bits_fx( M );
Word16 Q_A_SCh;
Word32 *speech_fx = &speech_buff[M];
@@ -1720,8 +1732,8 @@ Word16 tdm_lp_comparison_fx(
// residu( A_SCh, m, speech, res, L_frame );
Word16 gb = find_guarded_bits_fx( L_frame );
- scale_sig32( speech_buff, L_FRAME + M, gb1 ); /* Q_speech + gb1 */
- Word16 exp = sub( 31, Q_speech );
+ scale_sig32( speech_buff, L_FRAME + M, Q4 ); /* Q_speech + 4 */
+ Word16 exp = sub( Q27, Q_speech );
Word32 sum2_value = sum2_32_exp_fx( speech_fx, L_frame, &exp, gb ); // 2*Q_speech -31-gb
IF( LT_16( exp, -5 ) ) /*maximum q to prevent 0.01 from saturating is 37, since we are adding it headroom of 1 is required*/
{
@@ -1733,7 +1745,7 @@ Word16 tdm_lp_comparison_fx(
Word32 temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) ); /* Q25 */
ener_sig_fx = Mpy_32_32( temp32_log, 646456623 ); // Q25
// ener_sig = log10f( sum2_f( speech, L_frame ) + 0.01f );
- exp = sub( 31, sub( Q_speech, gb1 ) );
+ exp = sub( Q31, Q_speech );
sum2_value = sum2_32_exp_fx( res_fx, L_frame, &exp, gb ); // 2*Q_speech -31-gb
sum2_value = BASOP_Util_Add_Mant32Exp( sum2_value, exp, 328, Q16, &exp ); /* Q31-exp */
temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) ); /* Q25 */
@@ -1744,9 +1756,9 @@ Word16 tdm_lp_comparison_fx(
/* Find prediction gain when resuing the Primary Channel LP filter */
// residu( A_PCh, m, speech, res, L_frame );
- scale_sig32( speech_buff, L_FRAME + M, negate( gb1 ) ); /* Q_speech */
+ scale_sig32( speech_buff, L_FRAME + M, -4 ); /* Q_speech */
residu_ivas_fx( A_PCh_fx, sub( 14, norm_s( A_PCh_fx[0] ) ), m, speech_fx, res_fx, L_frame );
- exp = sub( 31, sub( Q_speech, gb1 ) );
+ exp = sub( Q31, Q_speech );
sum2_value = sum2_32_exp_fx( res_fx, L_frame, &exp, gb ); // 2*Q_speech -31-gb
sum2_value = BASOP_Util_Add_Mant32Exp( sum2_value, exp, 328, Q16, &exp );
temp32_log = L_add( BASOP_Util_Log2( sum2_value ), L_shl( sub( Q31, sub( 31, exp ) ), Q25 ) ); /* Q25 */
@@ -1758,7 +1770,8 @@ Word16 tdm_lp_comparison_fx(
/* Find Euclidian distance between the 2 filters */
dist_fx = 0;
move16();
- gb = find_guarded_bits_fx( M );
+ gb = 4;
+ move16();
FOR( i = 0; i < m; i++ )
{
// ftmp = isp_SCh[i] - isp_PCh[i];
diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c
index f993c8e28b9fe8adf62dd5d298e811440cb09734..f072e54364465ce48d77825d301bc11afae1fa52 100644
--- a/lib_enc/ivas_tcx_core_enc.c
+++ b/lib_enc/ivas_tcx_core_enc.c
@@ -466,7 +466,7 @@ void stereo_tcx_core_enc(
E_LPC_lsp_lsf_conversion( lsp_fx, lsf_fx, M );
/* Quantize */
- Q_lsf_tcxlpc_fx( lsf_fx, lsf_tcx_q_fx, lspq_ind, param_lpc, M, st->narrowBand, tcx_lpc_cdk, st->mem_MA_fx, st->hTcxCfg->coder_type, st->Bin_E_fx, Q_ener );
+ Q_lsf_tcxlpc_ivas_fx( lsf_fx, lsf_tcx_q_fx, lspq_ind, param_lpc, M, st->narrowBand, tcx_lpc_cdk, st->mem_MA_fx, st->hTcxCfg->coder_type, st->Bin_E_fx, st->q_Bin_E );
/* Account for consumed bits */
nbits_lpc[0] = TCXLPC_NUMBITS;
@@ -727,10 +727,6 @@ void stereo_tcx_core_enc(
move16();
}
}
- st->q_Bin_E = Q_new + Q_SCALE - 2;
- move16();
- st->q_Bin_E_old = Q_new + Q_SCALE - 2;
- move16();
Scale_sig( st->synth, st->L_frame, -Q_new );
IF( st->tcxonly == 0 )
{
@@ -875,7 +871,7 @@ Word16 ivas_acelp_tcx20_switching_fx(
#ifdef MSAN_FIX
FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_length / 2; i++ )
{
- window_fx[st->hTcxCfg->tcx_mdct_window_length / 2 - 1 - i] = st->hTcxCfg->tcx_mdct_window[i].v.re; // Q15
+ window_fx[st->hTcxCfg->tcx_mdct_window_length - 1 - i] = st->hTcxCfg->tcx_mdct_window[i].v.re; // Q15
move16();
window_fx[i] = st->hTcxCfg->tcx_mdct_window[i].v.im; // Q15
move16();
diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c
index c78fbe10799918dfa6ad4568f8106e6a95e4d51a..319ebdf8710fc0c1473b726418a198e5597da776 100644
--- a/lib_enc/lib_enc.c
+++ b/lib_enc/lib_enc.c
@@ -1749,6 +1749,9 @@ ivas_error IVAS_ENC_EncodeFrameToSerial(
}
ELSE
{
+#ifdef DEBUG_MODE_INFO
+ dbgwrite( inputBuffer, sizeof( int16_t ), inputBufferSize, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, 1, ENC ), ".pcm" ) );
+#endif
hCoreCoder->input_frame_fx = inputBufferSize;
move32();
IF( NE_32( ( error = evs_enc_fx( hCoreCoder, inputBuffer, hCoreCoder->mem_hp20_in_fx, inputBufferSize ) ), IVAS_ERR_OK ) )
diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c
index 5afca51365058fb72e26d4760309fa7a683b8f78..0887698f78c49dc6579835076bfe83d5af9a5aac 100644
--- a/lib_enc/lp_exc_e_fx.c
+++ b/lib_enc/lp_exc_e_fx.c
@@ -260,7 +260,7 @@ Word16 lp_filt_exc_enc_ivas_fx(
}
IF( use_prev_sf_pit_gain == 1 )
{
- wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, &gain2, gain_pit, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain );
+ wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, gain_pit, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain );
}
ELSE
{
diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c
index d30f2c24903b67c4f891c7b44bcc45e1c9a7efb5..b81cc18e8486f5abdacdad2104ae288f8a0e08a4 100644
--- a/lib_enc/lsf_msvq_ma_enc_fx.c
+++ b/lib_enc/lsf_msvq_ma_enc_fx.c
@@ -652,6 +652,165 @@ Word16 Q_lsf_tcxlpc_fx(
return NumIndices;
}
+
+Word16 Q_lsf_tcxlpc_ivas_fx(
+ /* const */ Word16 lsf[], /* i : original lsf */
+ Word16 lsf_q[], /* o : quantized lsf */
+ Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */
+ Word16 indices[], /* o : VQ indices */
+ const Word16 lpcorder, /* i : LPC order */
+ const Word16 narrowband, /* i : narrowband flag */
+ const Word16 cdk, /* i : codebook selector */
+ const Word16 mem_MA[], /* i : MA memory */
+ const Word16 coder_type,
+ const Word32 *Bin_Ener,
+ const Word16 Q_ener )
+{
+ Word16 weights[M + 1];
+ Word16 pred[M16k];
+ Word16 i;
+ Word16 NumIndices;
+ Word16 lsf_q_ind[M16k];
+ const Word16 *means;
+ Word16 lsf_rem[M];
+ Word16 lsf_rem_q_ind[M];
+
+ Unified_weighting_fx( &Bin_Ener[L_FFT / 2], Q_ener, lsf, weights, narrowband, (Word16) EQ_16( coder_type, UNVOICED ), 12800, M );
+
+ move16();
+ NumIndices = 0;
+
+ /* Put disabled flag */
+ indices[NumIndices] = 0;
+ move16();
+ NumIndices = add( NumIndices, 1 );
+
+ /* Inter-frame prediction */
+
+ means = lsf_means[narrowband]; /* 14Q1 * 1.28 */
+
+ FOR( i = 0; i < lpcorder; ++i )
+ {
+ pred[i] = add( means[i], mult_r( MU_MA_FX, mem_MA[i] ) ); /* 14Q1 * 1.28 + ( 14Q1 * 1.28 * Q15 ) = 14Q1 * 1.28*/
+ move16();
+ }
+
+ /* Subtract prediction */
+
+ FOR( i = 0; i < lpcorder; ++i )
+ {
+ lsf[i] = sub( lsf[i], pred[i] ); /* 14Q1 * 1.28 */
+ move16();
+ }
+
+
+ msvq_enc_fx(
+ lsf_codebook[narrowband][cdk],
+ lsf_dims,
+ lsf_offs,
+ lsf,
+ lsf_numlevels,
+ kMaxC,
+ TCXLPC_NUMSTAGES,
+ weights,
+ lpcorder,
+ lpcorder,
+ indices + NumIndices );
+ msvq_dec(
+ lsf_codebook[narrowband][cdk],
+ lsf_dims,
+ lsf_offs,
+ TCXLPC_NUMSTAGES,
+ lpcorder,
+ lpcorder,
+ indices + NumIndices,
+#ifdef IVAS_MSVQ
+ 0, NULL,
+#endif
+ lsf_q );
+ NumIndices = add( NumIndices, TCXLPC_NUMSTAGES );
+
+ FOR( i = 0; i < lpcorder; ++i )
+ {
+ lsf_q_ind[i] = lsf_q[i];
+ move16();
+ }
+
+ /* Update flag */
+ indices[0] = lsf_ind_is_active( lsf_q_ind, lsf_means[narrowband], narrowband, cdk );
+ move16();
+
+ /* Get residual vector */
+ FOR( i = 0; i < lpcorder; ++i )
+ {
+ lsf_rem[i] = add( sub( pred[i], lsf_means[narrowband][i] ), sub( lsf[i], lsf_q_ind[i] ) );
+ move16();
+ }
+
+ /* Quantize using extra stage(s) */
+ msvq_enc_fx(
+ lsf_ind_codebook[narrowband][cdk],
+ lsf_ind_dims,
+ lsf_ind_offs,
+ lsf_rem,
+ lsf_ind_numlevels,
+ kMaxC,
+ TCXLPC_IND_NUMSTAGES,
+ weights,
+ lpcorder,
+ lpcorder,
+ indices + NumIndices );
+ /* Only add contribution if flag is enabled */
+ IF( indices[0] )
+ {
+ /* Decode */
+ msvq_dec(
+ lsf_ind_codebook[narrowband][cdk],
+ lsf_ind_dims,
+ lsf_ind_offs,
+ TCXLPC_IND_NUMSTAGES,
+ lpcorder,
+ lpcorder,
+ indices + NumIndices,
+#ifdef IVAS_MSVQ
+ 0, NULL,
+#endif
+ lsf_rem_q_ind );
+ NumIndices = add( NumIndices, TCXLPC_IND_NUMSTAGES );
+
+ /* Add to MA-removed vector */
+ FOR( i = 0; i < lpcorder; ++i )
+ {
+ lsf_q_ind[i] = add( lsf_q_ind[i], lsf_rem_q_ind[i] );
+ move16();
+ }
+ }
+
+ /* Add inter-frame prediction */
+ FOR( i = 0; i < lpcorder; ++i )
+ {
+ lsf_q[i] = add( lsf_q[i], pred[i] );
+ lsf[i] = add( lsf[i], pred[i] );
+ move16();
+ move16();
+ }
+
+ reorder_lsf_fx( lsf_q, TCXLPC_LSF_GAP, lpcorder, INT_FS_FX );
+
+ FOR( i = 0; i < lpcorder; ++i )
+ {
+ lsf_q_ind[i] = add( lsf_q_ind[i], lsf_means[narrowband][i] );
+ move16();
+ }
+ reorder_lsf_fx( lsf_q_ind, TCXLPC_LSF_GAP, lpcorder, INT_FS_FX );
+
+ IF( lsp_q_ind )
+ {
+ E_LPC_lsf_lsp_conversion /*lsf2lsp*/ ( lsf_q_ind, lsp_q_ind, lpcorder );
+ }
+
+ return NumIndices;
+}
/*--------------------------------------------------------------------------*
* enc_lsf_tcxlpc_fx()
*
diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c
index 641c3597988b9854bf2fceb800b79fac1a36dd8f..86fe541bb3b062c6f7f15737b3249a4b6374bdf1 100644
--- a/lib_enc/multi_harm_fx.c
+++ b/lib_enc/multi_harm_fx.c
@@ -379,6 +379,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni
{
Word16 i, j, k, L, stemp, N_mins, ind_mins[L_FFT / 4], *pt_mins, harm;
Word16 S[L_FFT / 2], flor, step, tmp16, tmp2, Expx2, Expy2;
+ Word32 tmp2_32;
Word16 corx2, cory2, corxy, cor, cor_map[L_FFT / 2], *pt1, *pt2, cor_strong;
Word32 L_acc;
Word32 Lcorx2, Lcory2, Lcorxy, Lcor_map_LT_sum;
@@ -621,7 +622,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni
*------------------------------------------------------------------*/
Lcor_map_LT_sum = L_deposit_l( 0 );
- tmp2 = 0;
+ tmp2_32 = 0;
move16();
cor_strong = 0;
@@ -633,7 +634,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni
FOR( i = 0; i < L; i++ )
{
/* tmp2 += S[i]; */
- tmp2 = add( tmp2, shl( S[i], 1 ) ); /* tmp2 in Q8; max value is 128) */
+ tmp2_32 = L_add( tmp2_32, cor_map[i] ); /* tmp2_32 in Q15; max value is 128) */
/* *pt1 = M_ALPHA_FX * *pt1 + (1-M_ALPHA_FX) * *pt2++ */
*pt1 = mac_r( L_mult( ONE_MINUS_M_ALPHA, *pt2 ), M_ALPHA_FX, *pt1 );
@@ -651,6 +652,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni
pt1++;
pt2++;
}
+ tmp2 = L_shr_sat( tmp2_32, 7 ); // q15-> q8
IF( EQ_16( bwidth, NB ) )
{
diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c
index a0f123b20e513b3b3c5705c03802cc7b7d6e1de5..a0ed2f523419729ebcdff1983b435b4eb7f59403 100644
--- a/lib_enc/nelp_enc_fx.c
+++ b/lib_enc/nelp_enc_fx.c
@@ -115,6 +115,7 @@ void quantize_uvg_fx( Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word1
move16(); /*(+1)=/2 in log */
L_tmp = Mpy_32_16( exp, frac, 4932 ); /*Q16 ; 0.5*log10(2) in Q15 */
G1[i] = round_fx( L_shl( L_tmp, 13 ) ); /*Q13 */
+ move16();
}
ELSE
{
@@ -147,9 +148,10 @@ void quantize_uvg_fx( Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word1
L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */
frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */
L_tmp = Pow2( 30, frac );
- exp = exp - 30; /*move16(); */
+ exp = exp - 30;
+ move16();
Lexp[0] = L_shl( L_tmp, exp + 15 );
-
+ move32();
L_tmp = L_mult0( UVG1CB_fx[*iG1][1], 27213 ); /*Q26 */
L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */
@@ -157,7 +159,7 @@ void quantize_uvg_fx( Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word1
L_tmp = Pow2( 30, frac );
exp = exp - 30; /*move16(); */
Lexp[1] = L_shl( L_tmp, exp + 15 );
-
+ move32();
FOR( i = 0; i < 2; i++ )
{
@@ -169,6 +171,7 @@ void quantize_uvg_fx( Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word1
tmp = div_s( 16384, tmp ); /*Q(15+exp) */
L_tmp = L_shr( L_mult0( G[i * 5 + j], tmp ), exp + 3 ); /*Q12 */
G2[i * 5 + j] = extract_l( L_tmp ); /*Q12 */
+ move16();
}
}
@@ -189,7 +192,7 @@ void quantize_uvg_fx( Word16 *G, Word16 *iG1, Word16 *iG2, Word16 *quantG, Word1
temp = sub_sat( G2[ind], UVG2CB1_fx[j][k] );
Lacc = L_mac0_sat( Lacc, temp, temp ); /*Q24 */
}
- ELSE IF( i == 1 )
+ ELSE IF( EQ_16( i, 1 ) )
{
/*mse += SQR(G2[i*5+k]-UVG2CB2[j][k]); */
ind = add( shr( extract_l( L_mult( i, 5 ) ), 1 ), k );
@@ -241,6 +244,7 @@ static void normalize_arr( Word16 *arr, Word16 *qf, Word16 size, Word16 hdr )
}
*qf = norm_s( (Word16) max_s );
+ move16();
test();
IF( ( *qf == 0 ) && ( ( (Word16) max_s ) == 0 ) )
{
@@ -249,7 +253,7 @@ static void normalize_arr( Word16 *arr, Word16 *qf, Word16 size, Word16 hdr )
}
*qf = *qf - hdr;
-
+ move16();
FOR( i = 0; i < size; i++ )
{
arr[i] = shl( arr[i], *qf );
@@ -299,41 +303,72 @@ void nelp_encoder_fx(
{
Word16 i, j;
Word16 *ptr_fx = exc_fx;
- Word16 lag = 25; /* to cover 25*9 + 31 */
- Word16 sqrt_inv_lag = 6554; /* sqrt(1/lag) in Q15 */
+ Word16 lag = 25; /* to cover 25*9 + 31 */
+ move16();
+ Word16 sqrt_inv_lag = 6554; /* sqrt(1/lag) in Q15 */
+ move16();
Word16 sqrt_inv_lframe_lag = 5885; /* sqrt(1/(L_FRAME-lag*9)) */
+ move16();
Word16 Gains_fx[10], gain_fac_fx;
Word16 iG1_fx, iG2_fx[2];
Word16 fid;
Word16 fdbck_fx;
Word32 var_dB_fx;
Word32 E1_fx = 0, EL1_fx = 0, EH1_fx = 0, E2_fx = 0, E3_fx = 0, EL2_fx = 0, EH2_fx = 0;
+ move32(); /*E1_fx*/
+ move32(); /*EL1_fx*/
+ move32(); /*EH1_fx*/
+ move32(); /*E2_fx*/
+ move32(); /*E3_fx*/
+ move32(); /*EL2_fx*/
+ move32(); /*EH2_fx*/
Word32 RL_fx = 0, RH_fx = 0;
+ move32(); /*RL_fx*/
+ move32(); /*RH_fx*/
Word16 R_fx = 0;
+ move16();
Word16 filtRes_fx[L_FRAME];
Word16 ptr_tmp_fx[L_FRAME];
Word16 qE1 = 0, qE2 = 0, qE3 = 0, qEL1 = 0, qEL2 = 0, qEH1 = 0, qEH2 = 0;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
Word16 qIn = 0, qGain = 0, qf = 0, qf1 = 0, qNelpGain = 0;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
Word16 exp1, exp2, tmp1, tmp2;
Word16 f_Noise, etmp, e_Noise;
Word16 max1 = 0;
+ move16();
Word32 l_nelp_gain_mem;
Word32 Ltemp = 0, Ltemp1 = 0, L_tmp = 0, L_const_1;
+ move32();
+ move32();
+ move32();
Word16 BP1_ORDER;
Word16 rf_flag;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
RF_ENC_HANDLE hRF = st_fx->hRF;
rf_flag = st_fx->rf_mode;
-
+ move16();
if ( EQ_16( hSC_VBR->last_nelp_mode, 1 ) && NE_16( st_fx->bwidth, st_fx->last_bwidth ) )
{
hSC_VBR->last_nelp_mode = 0;
+ move16();
}
qIn = *qIn1;
@@ -453,6 +488,7 @@ void nelp_encoder_fx(
Ltemp = L_shl_sat( L_tmp, sub( exp1, 12 ) ); /*Q3 */
}
Gains_fx[i] = round_fx_sat( Ltemp );
+ move16();
}
@@ -477,11 +513,13 @@ void nelp_encoder_fx(
}
Gains_fx[i] = round_fx_sat( Ltemp );
+ move16();
IF( EQ_16( reduce_gains, 1 ) )
{
FOR( i = 0; i < 10; i++ )
{
Gains_fx[i] = mult( Gains_fx[i], 19661 );
+ move16();
}
}
@@ -512,8 +550,7 @@ void nelp_encoder_fx(
L_tmp = L_max( L_tmp, 1 );
exp2 = norm_l( L_tmp );
L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */
- exp2 = 30 - exp2 - qNelpGain;
- move16();
+ exp2 = sub( 30, add( exp2, qNelpGain ) );
tmp2 = Log2_norm_lc( L_tmp );
Ltemp1 = Mpy_32_16( exp2, tmp2, 9864 ); /*log(2) in Q13 format = Q0 format */
Ltemp1 = L_sub( Ltemp, Ltemp1 ); /*Q16 */
@@ -536,8 +573,7 @@ void nelp_encoder_fx(
L_tmp = L_max( L_tmp, 1 );
exp2 = norm_l( L_tmp );
L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */
- exp2 = 30 - exp2 - qGain;
- move16();
+ exp2 = sub( 30, add( exp2, qGain ) );
tmp2 = Log2_norm_lc( L_tmp );
Ltemp1 = Mpy_32_16( exp2, tmp2, 9864 ); /*log(2) in Q13 format = Q0 format */
Ltemp1 = L_sub( Ltemp, Ltemp1 ); /*Q16 */
@@ -614,7 +650,7 @@ void nelp_encoder_fx(
}
}
- IF( exp1 == 31 )
+ IF( EQ_16( exp1, 31 ) )
{
L_const_1 = 0x7fffffff;
move32();
@@ -644,7 +680,7 @@ void nelp_encoder_fx(
}
hSC_VBR->nelp_gain_mem_fx = round_fx( L_shl( l_nelp_gain_mem, 16 ) );
-
+ move16();
Scale_sig( &hSC_VBR->nelp_gain_mem_fx, 1, -qGain );
Scale_sig( Gains_fx, 10, -qGain );
qGain = 0;
@@ -655,8 +691,11 @@ void nelp_encoder_fx(
IF( EQ_16( rf_flag, 1 ) )
{
hRF->rf_indx_nelp_iG1[0] = iG1_fx;
+ move16();
hRF->rf_indx_nelp_iG2[0][0] = iG2_fx[0];
+ move16();
hRF->rf_indx_nelp_iG2[0][1] = iG2_fx[1];
+ move16();
}
ELSE
{
@@ -686,6 +725,7 @@ void nelp_encoder_fx(
IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) )
{
BP1_ORDER = 4;
+ move16();
Scale_sig( hSC_VBR->bp1_filt_mem_wb_fx, BP1_ORDER * 2, qGain - hSC_VBR->qprevGain_fx ); /*qf-qAdj */
pz_filter_sp_fx( bp1_num_coef_wb_fx, bp1_den_coef_wb_fx, ptr_fx, ptr_tmp_fx, hSC_VBR->bp1_filt_mem_wb_fx, BP1_ORDER, BP1_ORDER, L_FRAME, 2 );
Copy( ptr_tmp_fx, ptr_fx, L_FRAME );
@@ -700,6 +740,7 @@ void nelp_encoder_fx(
Scale_sig( ptr_fx, L_FRAME, -1 ); /* bring exc to qgain-1 */
*qIn1 = qGain - 1; /* use this temp only in the parent */
+ move16();
}
E3_fx = L_deposit_l( 0 );
@@ -710,7 +751,7 @@ void nelp_encoder_fx(
qE3 = 2 * qGain + 1;
move16();
test();
- IF( st_fx->bwidth == WB || EQ_16( st_fx->bwidth, SWB ) )
+ IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) )
{
Scale_sig( hSC_VBR->shape1_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) );
pz_filter_sp_fx( shape1_num_coef_fx, shape1_den_coef_fx, ptr_fx, ptr_tmp_fx, hSC_VBR->shape1_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */
@@ -768,6 +809,7 @@ void nelp_encoder_fx(
Ltemp = L_mult0( R_fx, ptr_fx[i] );
Ltemp = L_shr_r( Ltemp, exp1 );
filtRes_fx[i] = round_fx_sat( L_shl_sat( Ltemp, 16 ) );
+ move16();
}
qf1 = qGain;
@@ -792,6 +834,7 @@ void nelp_encoder_fx(
Ltemp = L_mult0( R_fx, ptr_fx[i] );
Ltemp = L_shr_r( Ltemp, exp1 );
filtRes_fx[i] = round_fx_sat( L_shl_sat( Ltemp, 16 ) );
+ move16();
}
qf = qGain;
@@ -814,8 +857,7 @@ void nelp_encoder_fx(
{
exp2 = norm_l( EL1_fx );
L_tmp = L_shl( EL1_fx, exp2 );
- exp2 = 30 - exp2 - qEL1;
- move16();
+ exp2 = sub( 30, add( exp2, qEL1 ) );
tmp1 = Log2_norm_lc( L_tmp );
Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */
tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */
@@ -829,9 +871,8 @@ void nelp_encoder_fx(
L_tmp = Mult_32_16( EL1_fx, tmp1 ); /*qEL1+30-qEL2-exp1-15=>15+qE1-qEL2-exp1 */
exp2 = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */
- exp2 = 30 - ( 30 + qEL1 - qEL2 - exp1 + exp2 );
- move16();
+ L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */
+ exp2 = sub( add( qEL2, exp1 ), add( qEL1, exp2 ) ); /*30 - ( 30 + qEL1 - qEL2 - exp1 + exp2 )*/
tmp1 = Log2_norm_lc( L_tmp );
Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */
tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */
@@ -842,8 +883,7 @@ void nelp_encoder_fx(
{
exp2 = norm_l( EH2_fx );
L_tmp = L_shl( EH2_fx, exp2 );
- exp2 = 30 - exp2 - qEH2;
- move16();
+ exp2 = sub( 30, add( exp2, qEH2 ) );
tmp1 = Log2_norm_lc( L_tmp );
Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */
tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */
@@ -857,9 +897,8 @@ void nelp_encoder_fx(
L_tmp = Mult_32_16( EH1_fx, tmp1 ); /*15+qEH1-qEH2-exp1 */
exp2 = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp2 ); /*15+qEH1-qEH2-exp1+exp2 */
- exp2 = 30 - ( 30 + qEH1 - qEH2 - exp1 + exp2 );
- move16();
+ L_tmp = L_shl( L_tmp, exp2 ); /*15+qEH1-qEH2-exp1+exp2 */
+ exp2 = sub( add( qEH2, exp1 ), add( qEH1, exp2 ) ); /*30 - ( 30 + qEH1 - qEH2 - exp1 + exp2 )*/
tmp1 = Log2_norm_lc( L_tmp );
Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */
tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */
@@ -955,12 +994,11 @@ void nelp_encoder_fx(
L_tmp = Mult_32_16( E2_fx, tmp1 ); /*qE2+30-qE3-exp1-15=>15+qE2-qE3-exp1 */
exp2 = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp2 ); /*15+qE2-qE3-exp1+exp2 */
- exp2 = 30 - ( 15 + qE2 - qE3 - exp1 + exp2 );
- move16();
- L_tmp = Isqrt_lc( L_tmp, &exp2 ); /*Q(31+exp2) */
+ L_tmp = L_shl( L_tmp, exp2 ); /*15+qE2-qE3-exp1+exp2 */
+ exp2 = add( 15, sub( add( qE3, exp1 ), add( qE2, exp2 ) ) ); /*30 - ( 15 + qE2 - qE3 - exp1 + exp2 )*/
+ L_tmp = Isqrt_lc( L_tmp, &exp2 ); /*Q(31+exp2) */
R_fx = round_fx( L_tmp );
- exp1 = 31 - exp2 - 16 - 7;
+ exp1 = sub( 8, exp2 ); /*31 - exp2 - 16 - 7*/
move16();
}
@@ -969,6 +1007,7 @@ void nelp_encoder_fx(
L_tmp = L_mult0( R_fx, ptr_fx[i] );
L_tmp = L_shr_r( L_tmp, exp1 + 1 );
ptr_fx[i] = round_fx( L_shl( L_tmp, 16 ) );
+ move16();
}
*qIn1 = qGain - 1;
move16();
@@ -1106,7 +1145,7 @@ void nelp_encoder_ivas_fx(
IF( NE_16( hSC_VBR->last_nelp_mode, 1 ) )
{
test();
- IF( st_fx->bwidth == WB || EQ_16( st_fx->bwidth, SWB ) )
+ IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) )
{
set16_fx( hSC_VBR->shape1_filt_mem_fx, 0, 10 );
set16_fx( hSC_VBR->shape2_filt_mem_fx, 0, 10 );
@@ -1171,7 +1210,6 @@ void nelp_encoder_ivas_fx(
qGain = qIn;
move16();
qGain = shl( qGain, 1 );
- move16();
FOR( i = 0; i < 9; i++ )
{
@@ -1707,8 +1745,10 @@ void nelp_encoder_ivas_fx(
L_tmp = L_mult0( R_fx, ptr_fx[i] );
L_tmp = L_shr_r( L_tmp, exp1 + 1 );
ptr_fx[i] = round_fx( L_shl( L_tmp, 16 ) );
+ move16();
}
*qIn1 = sub( qGain, 1 );
+ move16();
}
IF( EQ_16( rf_flag, 1 ) )
diff --git a/lib_enc/nois_est.c b/lib_enc/nois_est.c
deleted file mode 100644
index 370e0aeef76d707062c56fbeca491edfb15a05aa..0000000000000000000000000000000000000000
--- a/lib_enc/nois_est.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "prot.h"
-#include "wmc_auto.h"
-
-/*-----------------------------------------------------------------*
- * Local constants
- *-----------------------------------------------------------------*/
diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c
index be86c057424913f23ea51dade79fac65582373e7..27a48652a07dcd277d616cfc00505ccc8f88bbbf 100644
--- a/lib_enc/nois_est_fx.c
+++ b/lib_enc/nois_est_fx.c
@@ -90,6 +90,7 @@ static Word16 noise_est_ln_q8_fx(
Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
L_tmp = L_add_o( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ), &Overflow ); /* +1.0f */
@@ -188,7 +189,6 @@ void noise_est_init_fx(
hNoiseEst->ave_enr_q = Q7;
move16();
- move16();
hNoiseEst->totalNoise_fx = 0;
move16();
hNoiseEst->first_noise_updt = 0;
@@ -217,7 +217,8 @@ void noise_est_init_fx(
hNoiseEst->Etot_st_est_fx = 5120; /* 20.0f in Q8 */
hNoiseEst->Etot_sq_st_est_fx = 1600; /* 400 in Q2 */
- //###
+ move16();
+ move16();
hNoiseEst->epsP_0_2_lp_fx = 4096; /*1.0 Q12*/
move16();
@@ -244,7 +245,7 @@ void noise_est_init_fx(
hNoiseEst->noise_char_fx = 0;
move16();
hNoiseEst->multi_harm_limit_fx = THR_CORR_INIT_FX;
-
+ move16();
hNoiseEst->Etot_lp_fx = 0;
hNoiseEst->Etot_h_fx = 0;
hNoiseEst->Etot_l_fx = 0;
@@ -271,12 +272,17 @@ void noise_est_init_ivas_fx(
#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
hNoiseEst->first_noise_updt = 0;
hNoiseEst->first_noise_updt_cnt = 0;
-
+ move16();
+ move16();
hNoiseEst->aEn = 6;
hNoiseEst->aEn_inac_cnt = 0;
hNoiseEst->harm_cor_cnt = 0;
hNoiseEst->bg_cnt = 0;
hNoiseEst->low_tn_track_cnt = 0;
+ move16();
+ move16();
+ move16();
+ move16();
#endif
FOR( i = 0; i < NB_BANDS; i++ )
{
@@ -331,8 +337,8 @@ void noise_est_init_ivas_fx(
hNoiseEst->Etot_st_est_fx = 5120; /* 20.0f in Q8 */
hNoiseEst->Etot_sq_st_est_fx = 1600; /* 400 in Q2 */
- //###
-
+ move16();
+ move16();
hNoiseEst->epsP_0_2_lp_fx = 4096; /*1.0 Q12*/
move16();
hNoiseEst->epsP_0_2_ad_lp_fx = 0;
@@ -358,7 +364,7 @@ void noise_est_init_ivas_fx(
hNoiseEst->noise_char_fx = 0;
move16();
hNoiseEst->multi_harm_limit_fx = THR_CORR_INIT_FX;
-
+ move16();
hNoiseEst->Etot_lp_fx = 0;
hNoiseEst->Etot_h_fx = 0;
hNoiseEst->Etot_l_fx = 0;
@@ -383,12 +389,12 @@ void noise_est_init_ivas_fx(
*-----------------------------------------------------------------*/
void noise_est_pre_fx(
- const Word16 Etot, /* i : Energy of current frame */
- const Word16 ini_frame_fx, /* i : Frame number (init) */
- NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */
- const int16_t idchan, /* i : channel ID */
- const int16_t element_mode, /* i : element mode */
- const int16_t last_element_mode /* i : last element mode */
+ const Word16 Etot, /* i : Energy of current frame */
+ const Word16 ini_frame_fx, /* i : Frame number (init) */
+ NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */
+ const Word16 idchan, /* i : channel ID */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 last_element_mode /* i : last element mode */
)
{
Word16 tmp;
@@ -455,7 +461,8 @@ void noise_est_pre_fx(
}
hNoiseEst->Etot_l_fx = s_min( hNoiseEst->Etot_l_fx, Etot );
-
+ move16();
+ test();
IF( LT_16( ini_frame_fx, 100 ) && LT_16( hNoiseEst->Etot_l_fx, hNoiseEst->Etot_l_lp_fx ) )
{
/**Etot_l_lp = 0.1f * *Etot_l + (1.0f - 0.1) * *Etot_l_lp; */
@@ -478,10 +485,12 @@ void noise_est_pre_fx(
{
/* *Etot_l_lp = 0.02f * *Etot_l + (1.0f - 0.02f) * *Etot_l_lp; */
hNoiseEst->Etot_l_lp_fx = round_fx( L_mac( L_mult( 655, hNoiseEst->Etot_l_fx ), 32113, hNoiseEst->Etot_l_lp_fx ) );
+ move16();
}
}
/**sign_dyn_lp = 0.1f * (*Etot_h - *Etot_l) + (1.0f - 0.1f) * *sign_dyn_lp;*/
hNoiseEst->sign_dyn_lp_fx = round_fx( L_mac( L_mult( 3277, sub_sat( hNoiseEst->Etot_h_fx, hNoiseEst->Etot_l_fx ) ), 29491, hNoiseEst->sign_dyn_lp_fx ) );
+ move16();
}
return;
@@ -681,7 +690,7 @@ void noise_est_down_fx(
e_Noise = sub( e_Noise, scale );
Ltmp = Mpy_32_16( e_Noise, f_Noise, LG10 );
*totalNoise = round_fx( L_shl( Ltmp, 10 ) ); /*Q8*/
-
+ move16();
/*-----------------------------------------------------------------*
* Average energy per frame for each frequency band
*-----------------------------------------------------------------*/
@@ -710,7 +719,7 @@ void noise_est_down_fx(
tmpN[i] = Madd_32_16( L_tmp, bckr[i], ALPHAM1_FX );
move32(); /*Q_new+QSCALE*/
tmpN[i] = L_max( tmpN[i], e_min ); /* handle div by zero in find_tilt_fx */
-
+ move32();
/* if( tmpN[i] < bckr[i] ) { bckr[i] = tmpN[i]; }*/
/* Defend to increase noise estimate: keep as it is or decrease */
bckr[i] = L_max( L_min( bckr[i], tmpN[i] ), e_min );
@@ -729,10 +738,10 @@ void noise_est_down_fx(
L_tmp = Mult_32_16( L_Etot_v, 655 ); /*.02 in Q15 , Q24+Q15+1 -16 ==> Q24 ) */
*Etot_v_h2 = round_fx( L_add( L_Etot_v_h2, L_tmp ) ); /*Q24->Q8*/
-
+ move16();
/* if (*Etot_v_h2 < 0.1f) { *Etot_v_h2 = 0.1f; } */
*Etot_v_h2 = s_max( *Etot_v_h2, 26 ); /* 0.1 in Q8*/
-
+ move16();
return;
}
@@ -945,6 +954,7 @@ void noise_est_fx(
GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
+ move32();
#endif
/*-----------------------------------------------------------------*
@@ -958,7 +968,7 @@ void noise_est_fx(
IF( hFrontVad == NULL )
#endif
{
- if ( hSpMusClas != NULL )
+ IF( hSpMusClas != NULL )
{
Ltmp = L_shr( lf_E[0], 3 );
FOR( i = 1; i < 8; i++ )
@@ -968,6 +978,7 @@ void noise_est_fx(
IF( LT_32( Ltmp, L_shl( 1, add( Q_new, Q_SCALE - 2 ) ) ) )
{
hSpMusClas->ener_RAT_fx = 0;
+ move16();
// PMT("hSpMusClas->ener_RAT_fx = 0, that should be validated")
}
ELSE
@@ -989,9 +1000,10 @@ void noise_est_fx(
{
hSpMusClas->ener_RAT_fx = 32767;
move16(); /*Q15*/
- if ( GE_16( wtmp1, wtmp ) )
+ IF( GE_16( wtmp1, wtmp ) )
{
hSpMusClas->ener_RAT_fx = div_s( wtmp, wtmp1 ); /*Q15*/ /* wtmp1 gte than wtmp */
+ move16();
}
}
}
@@ -1005,7 +1017,7 @@ void noise_est_fx(
* order" spectral envelope => the epsP ratio is much less effective.
*-----------------------------------------------------------------*/
- IF( NE_16( vad_bwidth_fx, NB ) ) /* WB input */
+ IF( vad_bwidth_fx != NB ) /* WB input */
{
th_eps = TH_EPS16_FX;
move16(); /*Q11*/
@@ -1052,7 +1064,7 @@ void noise_est_fx(
move16(); /* low correlation -> probably inactive signal */
}
- move16(); /* Update */
+ /* Update */
/*-----------------------------------------------------------------*
* Multi-harmonic analysis
@@ -1067,6 +1079,7 @@ void noise_est_fx(
move16();
*loc_harm = multi_harm_fx( EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate,
st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map );
+ move16();
}
}
/*-----------------------------------------------------------------*
@@ -1186,7 +1199,7 @@ void noise_est_fx(
nchar_thr = THR_NCHAR_WB_FX;
move16(); /* 1.0 Q11 */
- if ( EQ_16( vad_bwidth_fx, NB ) )
+ if ( vad_bwidth_fx == NB )
{
nchar_thr = THR_NCHAR_NB_FX;
move16(); /* 1.0 Q11 */
@@ -1336,6 +1349,7 @@ void noise_est_fx(
move16();
}
}
+ test();
IF( GE_16( i, 2 ) && LE_16( i, 16 ) )
{
IF( GE_16( ini_frame, 100 ) )
@@ -1369,7 +1383,7 @@ void noise_est_fx(
lim_Etot_fx = s_max( 5120, Etot ); /* 20.0f Q8 */
lim_Etot_sq_fx = extract_h( L_shl_r( L_mult( lim_Etot_fx, lim_Etot_fx ), 1 ) ); /* Q2 */
- if ( st_fx->ini_frame < 150 )
+ IF( LT_16( st_fx->ini_frame, 150 ) )
{
/* Allow use of quicker filter during init - if needed */
/* st->Etot_st_est = 0.25f * lim_Etot + (1.0f-0.25F) * st->Etot_st_est; */
@@ -1379,7 +1393,7 @@ void noise_est_fx(
hNoiseEst->Etot_sq_st_est_fx = mac_r( L_mult( 8192, lim_Etot_sq_fx ), 24576, hNoiseEst->Etot_sq_st_est_fx );
move16();
}
- else
+ ELSE
{
/* st->Etot_st_est = 0.25f * lim_Etot + (1.0f-0.25F) * st->Etot_st_est; */
hNoiseEst->Etot_st_est_fx = mac_r( L_mult( 8192, lim_Etot_fx ), 24576, hNoiseEst->Etot_st_est_fx );
@@ -1402,20 +1416,24 @@ void noise_est_fx(
test();
test();
*st_harm_cor_cnt = add( *st_harm_cor_cnt, 1 );
+ move16();
if ( ( Etot > 0 ) && ( ( *loc_harm > 0 ) || ( GT_16( round_fx( Ltmp ), COR_MAX_NNE_FX ) ) ) )
{
*st_harm_cor_cnt = 0;
move16();
}
-
- IF( ( GT_16( *st_harm_cor_cnt, 1 ) ) && ( ( LT_16( Etot, 3840 ) ) || /* 15 in Q8 */
- ( GT_16( st_fx->ini_frame, 10 ) &&
- GT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 ) ) ) /* 7 in Q8 */
+ test();
+ test();
+ test();
+ if ( ( GT_16( *st_harm_cor_cnt, 1 ) ) && ( ( LT_16( Etot, 3840 ) ) || /* 15 in Q8 */
+ ( GT_16( st_fx->ini_frame, 10 ) &&
+ GT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 ) ) ) /* 7 in Q8 */
)
{
*st_harm_cor_cnt = 1;
}
-
+ test();
+ test();
if ( GT_16( *st_harm_cor_cnt, 1 ) &&
GT_16( Etot, 7680 ) && /* 30.0f in Q8 */
GT_16( st_E_var_est_fx, 32 ) /* 8.0f in Q2 */
@@ -1424,6 +1442,7 @@ void noise_est_fx(
/* st->harm_cor_cnt = max(1, (short) round_f( (float) st->harm_cor_cnt / 4.0f )) ; */
*st_harm_cor_cnt = s_max( 1, shr( add( *st_harm_cor_cnt, 2 ), 1 ) );
+ move16();
}
@@ -1471,7 +1490,7 @@ void noise_est_fx(
alpha = 4915;
move16(); /*0.15 in Q15 */
hNoiseEst->epsP_0_2_lp_fx = noise_est_AR1_Qx( epsP_0_2, hNoiseEst->epsP_0_2_lp_fx, alpha );
-
+ move16();
/* epsP_0_2_ad = (float) fabs(epsP_0_2 - st->epsP_0_2_lp ); */
epsP_0_2_ad = abs_s( sub( epsP_0_2, hNoiseEst->epsP_0_2_lp_fx ) ); /* Q12 */
@@ -1487,7 +1506,7 @@ void noise_est_fx(
alpha = shr( alpha, 1 ); /* 0.1 Q15 */
}
hNoiseEst->epsP_0_2_ad_lp_fx = noise_est_AR1_Qx( epsP_0_2_ad, hNoiseEst->epsP_0_2_ad_lp_fx, alpha );
-
+ move16();
/* epsP_0_2_ad_lp_max = max(epsP_0_2_ad,st->epsP_0_2_ad_lp);*/
epsP_0_2_ad_lp_max = s_max( epsP_0_2_ad, hNoiseEst->epsP_0_2_ad_lp_fx ); /* Q12 */
@@ -1523,9 +1542,9 @@ void noise_est_fx(
move16(); /* 0.2 Q15 */
}
hNoiseEst->epsP_2_16_lp_fx = noise_est_AR1_Qx( epsP_2_16, hNoiseEst->epsP_2_16_lp_fx, alpha );
-
+ move16();
hNoiseEst->epsP_2_16_lp2_fx = noise_est_AR1_Qx( epsP_2_16, hNoiseEst->epsP_2_16_lp2_fx, 655 ); /* 0.02 */
-
+ move16();
epsP_2_16_dlp = sub( hNoiseEst->epsP_2_16_lp_fx, hNoiseEst->epsP_2_16_lp2_fx );
@@ -1542,7 +1561,7 @@ void noise_est_fx(
move16(); /* 0.02 Q15 */
}
hNoiseEst->epsP_2_16_dlp_lp2_fx = noise_est_AR1_Qx( epsP_2_16_dlp, hNoiseEst->epsP_2_16_dlp_lp2_fx, alpha );
-
+ move16();
/* epsP_2_16_dlp_max = max(epsP_2_16_dlp,st->epsP_2_16_dlp_lp2); */
epsP_2_16_dlp_max = s_max( epsP_2_16_dlp, hNoiseEst->epsP_2_16_dlp_lp2_fx );
@@ -1560,14 +1579,14 @@ void noise_est_fx(
move16();
}
hNoiseEst->lt_tn_track_fx = noise_est_AR1_Qx( tmp2, hNoiseEst->lt_tn_track_fx, 983 ); /*0.03 in Q15 ,Q15 state*/
-
+ move16();
/* st->lt_tn_dist = 0.03f* (Etot - st->totalNoise) + 0.97f*st->lt_tn_dist; */
hNoiseEst->lt_tn_dist_fx = noise_est_AR1_Qx( tmp, hNoiseEst->lt_tn_dist_fx, 983 ); /*0.03 in Q15 ,Q8 state*/
-
+ move16();
/* st->lt_Ellp_dist = 0.03f* (Etot - st->Etot_l_lp) + 0.97f*st->lt_Ellp_dist;*/
tmp = sub( Etot, hNoiseEst->Etot_l_lp_fx ); /* Q8 */
hNoiseEst->lt_Ellp_dist_fx = noise_est_AR1_Qx( tmp, hNoiseEst->lt_Ellp_dist_fx, 983 ); /*0.03 in Q15 ,Q8 state*/
-
+ move16();
/* if (st->harm_cor_cnt == 0) {
st->lt_haco_ev = 0.03f*1.0 + 0.97f*st->lt_haco_ev;
@@ -1582,7 +1601,7 @@ void noise_est_fx(
{
hNoiseEst->lt_haco_ev_fx = mult_r( 32440, hNoiseEst->lt_haco_ev_fx ); /*.99 in Q15 , Q15 state */
}
-
+ move16();
/* if (st->lt_tn_track < 0.05f) {
st->low_tn_track_cnt++;
@@ -1702,15 +1721,15 @@ void noise_est_fx(
( ( hNoiseEst->act_pred > 0.8f ) && ( non_sta2 > th_sta ) ) )
{
/* active signal present - increment counter */
- hStereoClassif->aEn_raw[st->idchan] = hStereoClassif->aEn_raw[st->idchan] + 2;
+ hStereoClassif->aEn_raw[st->idchan] = add( hStereoClassif->aEn_raw[st->idchan], 2 );
}
else
{
/* background noise present - decrement counter */
- hStereoClassif->aEn_raw[st->idchan] = hStereoClassif->aEn_raw[st->idchan] - 1;
+ hStereoClassif->aEn_raw[st->idchan] = sub( hStereoClassif->aEn_raw[st->idchan], 1 );
}
- if ( hStereoClassif->aEn_raw[st->idchan] > 6 )
+ if ( GT_16( hStereoClassif->aEn_raw[st->idchan], 6 ) )
{
hStereoClassif->aEn_raw[st->idchan] = 6;
}
@@ -1956,13 +1975,20 @@ void noise_est_fx(
test();
test();
test();
- if ( ( ( LT_16( hNoiseEst->act_pred_fx, 19333 ) ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 7537 ) ) ) /* .59 in Q15 .23 in Q15 */
- || ( LT_16( hNoiseEst->act_pred_fx, 12452 ) ) /* .38 in Q15 */
- || ( ( EQ_16( st_fx->element_mode, EVS_MONO ) && LT_16( hNoiseEst->lt_haco_ev_fx, 4915 ) ) || ( GT_16( st_fx->element_mode, EVS_MONO ) && LT_16( hNoiseEst->lt_haco_ev_fx, 2621 ) ) ) /* .15 in Q15 || 0.08 */
- || ( LT_16( non_staB, 50 * 256 ) ) /* 50.0 in Q8 */
- || aE_bgd != 0 || ( ( LT_16( Etot, 10752 ) ) /* 42 in Q8 */
- && ( GT_16( hNoiseEst->harm_cor_cnt, 10 ) ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 11469 ) ) /* 0.35 in Q15 */
- && ( LT_16( hNoiseEst->act_pred_fx, 26214 ) ) /* 0.80 in Q15 */
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ if ( ( ( LT_16( hNoiseEst->act_pred_fx, 19333 ) ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 7537 ) ) ) /* .59 in Q15 .23 in Q15 */
+ || ( LT_16( hNoiseEst->act_pred_fx, 12452 ) ) /* .38 in Q15 */
+ || ( ( st_fx->element_mode == EVS_MONO && LT_16( hNoiseEst->lt_haco_ev_fx, 4915 ) ) || ( st_fx->element_mode > EVS_MONO && LT_16( hNoiseEst->lt_haco_ev_fx, 2621 ) ) ) /* .15 in Q15 || 0.08 */
+ || ( LT_16( non_staB, 50 * 256 ) ) /* 50.0 in Q8 */
+ || aE_bgd != 0 || ( ( LT_16( Etot, 10752 ) ) /* 42 in Q8 */
+ && ( GT_16( hNoiseEst->harm_cor_cnt, 10 ) ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 11469 ) ) /* 0.35 in Q15 */
+ && ( LT_16( hNoiseEst->act_pred_fx, 26214 ) ) /* 0.80 in Q15 */
) )
{
tmp = 1;
@@ -1973,6 +1999,7 @@ void noise_est_fx(
move16();
test();
test();
+ test();
if ( ( LT_16( st_fx->ini_frame, HE_LT_CNT_INIT_FX ) ) && ( GT_16( hNoiseEst->harm_cor_cnt, 5 ) ) /* > 5 Q0 */
&& ( LT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 ) ) /* 7 in Q8 */
&& ( NE_16( tmp, 0 ) ) )
@@ -2045,8 +2072,6 @@ void noise_est_fx(
test();
test();
test();
- test();
- test();
IF( ( ( LT_16( hNoiseEst->act_pred_fx, 27853 ) ) /* 0.85 in Q15 */
&& ( NE_16( aE_bgd, 0 ) ) && ( ( LT_16( hNoiseEst->lt_Ellp_dist_fx, 10 * 256 ) ) || ( NE_16( sd1_bgd, 0 ) ) ) /* 10.0 in Q8*/
&& ( LT_16( hNoiseEst->lt_tn_dist_fx, 40 * 256 ) ) /* 40.0 in Q8*/
@@ -2061,6 +2086,7 @@ void noise_est_fx(
updt_step = 32767;
move16();
hNoiseEst->first_noise_updt = 1;
+ move16();
FOR( i = 0; i < NB_BANDS; i++ )
{
hNoiseEst->bckr_fx[i] = tmpN[i];
@@ -2130,6 +2156,7 @@ void noise_est_fx(
ELSE IF( ( aE_bgd != 0 ) || ( GT_16( hNoiseEst->harm_cor_cnt, 100 ) ) )
{
hNoiseEst->first_noise_updt = add( hNoiseEst->first_noise_updt, 1 );
+ move16();
}
}
ELSE
@@ -2162,15 +2189,17 @@ void noise_est_fx(
move16();
}
hNoiseEst->lt_aEn_zero_fx = noise_est_AR1_Qx( tmp, hNoiseEst->lt_aEn_zero_fx, 6554 ); /* alpha=0.2 , Q15 */
+ move16();
}
#ifdef IVAS_CODE
- IF( GT_16( st_fx->element_mode, EVS_MONO ) )
+ IF( st_fx->element_mode > EVS_MONO )
{
test();
- if ( hNoiseEst->first_noise_updt_cnt_fx > 0 && LT_16( hNoiseEst->first_noise_updt_cnt_fx, 100 ) )
+ IF( hNoiseEst->first_noise_updt_cnt_fx > 0 && LT_16( hNoiseEst->first_noise_updt_cnt_fx, 100 ) )
{
hNoiseEst->first_noise_updt_cnt_fx = add( hNoiseEst->first_noise_updt_cnt_fx, 1 );
+ move16();
}
}
#endif
@@ -2389,7 +2418,7 @@ void noise_est_ivas_fx(
move16(); /* low correlation -> probably inactive signal */
}
- move16(); /* Update */
+ /* Update */
/*-----------------------------------------------------------------*
* Multi-harmonic analysis
@@ -2775,7 +2804,7 @@ void noise_est_ivas_fx(
lim_Etot_fx = s_max( 5120, Etot ); /* 20.0f Q8 */
lim_Etot_sq_fx = extract_h( L_shl_r( L_mult( lim_Etot_fx, lim_Etot_fx ), 1 ) ); /* Q2 */
- IF( LT_16( st_fx->ini_frame, 150 ) )
+ IF( LT_16( ini_frame, 150 ) )
{
/* Allow use of quicker filter during init - if needed */
/* st->Etot_st_est = 0.25f * lim_Etot + (1.0f-0.25F) * st->Etot_st_est; */
@@ -2819,13 +2848,14 @@ void noise_est_ivas_fx(
test();
test();
if ( ( GT_16( *st_harm_cor_cnt, 1 ) ) && ( ( LT_16( Etot, 3840 /* 15 in Q8 */ ) ) ||
- ( GT_16( st_fx->ini_frame, 10 ) &&
+ ( GT_16( ini_frame, 10 ) &&
GT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 /* 7 in Q8 */ ) ) ) )
{
*st_harm_cor_cnt = 1;
move16();
}
-
+ test();
+ test();
IF( GT_16( *st_harm_cor_cnt, 1 ) && GT_16( Etot, 7680 /* 30.0f in Q8 */ ) && GT_16( st_E_var_est_fx, 32 /* 8.0f in Q2 */ ) )
{
/* st->harm_cor_cnt = max(1, (short) round_f( (float) st->harm_cor_cnt / 4.0f )) ; */
@@ -3083,7 +3113,7 @@ void noise_est_ivas_fx(
test();
test();
IF( ( ( LT_16( *st_harm_cor_cnt, ( 3 * HC_CNT_SLOW_FX ) ) ) && ( ( GT_32( non_sta, th_sta ) ) || ( LT_16( tmp_pc, TH_PC_FX ) ) || ( noise_char > 0 ) ) ) ||
- ( ( GT_16( st_fx->ini_frame, HE_LT_CNT_INIT_FX ) ) && ( GT_16( sub( Etot, Etot_l_lp ), 2560 ) ) ) ||
+ ( ( GT_16( ini_frame, HE_LT_CNT_INIT_FX ) ) && ( GT_16( sub( Etot, Etot_l_lp ), 2560 ) ) ) ||
( GT_16( cor_tmp, cor_max ) ) || /* Q15 */
( GT_32( LepsP, th_eps ) ) || /* Q11 */
( GT_16( *loc_harm, 0 ) ) ||
@@ -3389,7 +3419,7 @@ void noise_est_ivas_fx(
test();
test();
test();
- if ( LT_16( st_fx->ini_frame, HE_LT_CNT_INIT_FX ) && GT_16( hNoiseEst->harm_cor_cnt, 5 ) && LT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 /* 7 in Q8 */ ) &&
+ if ( LT_16( ini_frame, HE_LT_CNT_INIT_FX ) && GT_16( hNoiseEst->harm_cor_cnt, 5 ) && LT_16( sub( Etot, hNoiseEst->Etot_lp_fx ), 1792 /* 7 in Q8 */ ) &&
( ( LT_16( hNoiseEst->act_pred_fx, 19333 /* 0.59 in Q15 */ ) && LT_16( hNoiseEst->lt_haco_ev_fx, 7537 /* 0.23 in Q15 */ ) ) || LT_16( hNoiseEst->act_pred_fx, 12452 /* 0.38 in Q15 */ ) ||
( ( ( st_fx->element_mode == EVS_MONO ) && LT_16( hNoiseEst->lt_haco_ev_fx, 4915 /* 0.15 in Q15 */ ) ) || ( ( st_fx->element_mode > EVS_MONO ) && LT_16( hNoiseEst->lt_haco_ev_fx, 2621 /* 0.08 in Q15 */ ) ) ) ||
LT_16( non_staB, 50 * 256 /* 50 in Q8 */ ) || ( aE_bgd != 0 ) || ( LT_16( Etot, 10752 /* 42.0 in Q8 */ ) && GT_16( hNoiseEst->harm_cor_cnt, 10 ) && LT_16( hNoiseEst->lt_haco_ev_fx, 11469 /* 0.35 in Q8 */ ) && LT_16( hNoiseEst->act_pred_fx, 26214 /* 0.8 in Q8 */ ) ) ) )
@@ -3564,7 +3594,7 @@ void noise_est_ivas_fx(
IF( st_fx->element_mode > EVS_MONO )
{
test();
- if ( hNoiseEst->first_noise_updt > 0 && LT_16( hNoiseEst->first_noise_updt_cnt, 100 ) )
+ IF( hNoiseEst->first_noise_updt > 0 && LT_16( hNoiseEst->first_noise_updt_cnt, 100 ) )
{
hNoiseEst->first_noise_updt_cnt = add( hNoiseEst->first_noise_updt_cnt, 1 );
move16();
diff --git a/lib_enc/noise_adjust.c b/lib_enc/noise_adjust.c
deleted file mode 100644
index d441f6ead49ddcb3a6a1ffab0962633db8157cd0..0000000000000000000000000000000000000000
--- a/lib_enc/noise_adjust.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-
-#include
-#include "options.h"
-#include
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot.h"
-#include "wmc_auto.h"
diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h
index bc08aae244a8686c9681c6b2e2ed81b54fd4b2de..711d7069a55548319a63bc7918323da3574027e6 100644
--- a/lib_enc/prot_fx_enc.h
+++ b/lib_enc/prot_fx_enc.h
@@ -2432,6 +2432,24 @@ void tcx_arith_encode_envelope_fx(
const Word16 low_complexity /* i: low-complexity flag Q0 */
);
+void tcx_arith_encode_envelope_ivas_fx(
+ Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */
+ Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */
+ Word16 signs[], /* o: signs (spectrum[.]<0) Q0 */
+ const Word16 L_frame, /* i: frame or MDCT length Q0 */
+ const Word16 L_spec, /* i: frame or MDCT length Q0 */
+ Encoder_State *st, /* i/o: coder state */
+ const Word16 A_ind[], /* i: quantised LPC coefficients Q12 */
+ Word16 target_bits, /* i: number of available bits Q0 */
+ Word16 prm[], /* o: bitstream parameters Q0 */
+ const Word8 use_hm, /* i: use HM in current frame? */
+ Word16 prm_hm[], /* o: HM parameter area Q0 */
+ const Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a Q0*/
+ Word16 *arith_bits, /* o: bits used for ari. coding Q0 */
+ Word16 *signaling_bits, /* o: bits used for signaling Q0 */
+ const Word16 low_complexity /* i: low-complexity flag Q0 */
+);
+
/** Quantize gain.
* Quantize gain in range [0..127],
* @param n Length of the spectrum.
@@ -2652,6 +2670,19 @@ Word16 Q_lsf_tcxlpc_fx(
const Word32 *Bin_Ener,
const Word16 Q_ener );
+Word16 Q_lsf_tcxlpc_ivas_fx(
+ /* const */ Word16 lsf[], /* i : original lsf */
+ Word16 lsf_q[], /* o : quantized lsf */
+ Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */
+ Word16 indices[], /* o : VQ indices */
+ const Word16 lpcorder, /* i : LPC order */
+ const Word16 narrowband, /* i : narrowband flag */
+ const Word16 cdk, /* i : codebook selector */
+ const Word16 mem_MA[], /* i : MA memory */
+ const Word16 coder_type,
+ const Word32 *Bin_Ener,
+ const Word16 Q_ener );
+
Word16 signalling_mode1_tcx20_enc_fx(
Encoder_State *st, /* i : encoder state structure */
Word16 push /*Q0*/ );
@@ -3037,8 +3068,7 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< out: |
const Word16 igfGridIdx /**< in: Q0 | IGF grid index */
);
-void IGF_ErodeSpectrum_ivas_fx( Word16 *highPassEner_exp, /**< out: | exponent of highPassEner */
- const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
+void IGF_ErodeSpectrum_ivas_fx( 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 */
diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h
index 6440c1d64e1c88320f58959a4d489ca41311a1a4..0f1c2e9069819986ab12526cc04c00dc626409c1 100644
--- a/lib_enc/stat_enc.h
+++ b/lib_enc/stat_enc.h
@@ -1026,6 +1026,7 @@ typedef struct fd_bwe_enc_structure
Word32 prev_global_gain_fx; /* Q(2 * prev_Q_shb) */
Word16 modeCount;
Word32 EnergyLF_fx;
+ Word16 EnergyLF_exp;
Word16 mem_old_wtda_swb_fx; /* Q(-1) */
} FD_BWE_ENC_DATA, *FD_BWE_ENC_HANDLE;
diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c
index 60c6504a6fb909493157943e66c159d9722f0ed2..c7d99cc699ab43d0b8f5dbfacc96c3ea70c6b138 100644
--- a/lib_enc/swb_bwe_enc_fx.c
+++ b/lib_enc/swb_bwe_enc_fx.c
@@ -3113,17 +3113,19 @@ static Word16 SWB_BWE_encoding_ivas_fx(
energy_fx = L_deposit_l( 0 );
FOR( i = 0; i < L; i++ )
{
- energy_fx = L_add( energy_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*2*Q_slb_speech - 7 */
+ energy_fx = L_add( energy_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*Q = 2 * Q_insig_lp - 7 */
}
- IF( GT_32( Mult_32_16( energy_fx, 5958 ), hBWE_FD->EnergyLF_fx ) )
+ if ( BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( energy_fx, 5958 /* 1/5.5f in Q15 */ ), sub( 31 + 7, shl( Q_insig_lp, 1 ) ), hBWE_FD->EnergyLF_fx, hBWE_FD->EnergyLF_exp ) > 0 )
{
IsTransient_LF = 1;
move16();
}
hBWE_FD->EnergyLF_fx = energy_fx;
+ hBWE_FD->EnergyLF_exp = sub( 31 + 7, shl( Q_insig_lp, 1 ) );
move32();
+ move16();
}
/* tilt returned in Q24 go to Q11 */
@@ -4169,8 +4171,10 @@ void fd_bwe_enc_init_fx(
hBWE_FD->modeCount = 0;
move16();
hBWE_FD->EnergyLF_fx = 0;
+ hBWE_FD->EnergyLF_exp = 0;
hBWE_FD->mem_old_wtda_swb_fx = 0;
move32();
+ move16();
move32();
hBWE_FD->prev_Q_input_lp = 0;
diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c
index 850ae0d31a6f40d31291fdfa989ef73784e3fab9..3e9c07c230458cf42dbe330b423f6d01167e3c44 100644
--- a/lib_enc/swb_pre_proc_fx.c
+++ b/lib_enc/swb_pre_proc_fx.c
@@ -1276,7 +1276,7 @@ void swb_pre_proc_ivas_fx(
Word16 exp_t;
hCPE->hStereoICBWE->MSFlag = 0; /* Init the multi-source flag */
move16();
- v = Mpy_32_16_1( sum16_fx( st->voicing_fx, 3 ), 10923 /* 0.33333 in Q15 */ );
+ v = Mpy_32_16_1( L_add( L_deposit_l( st->voicing_fx[0] ), L_add( L_deposit_l( st->voicing_fx[1] ), L_deposit_l( st->voicing_fx[2] ) ) ), 10923 /* 0.33333 in Q15 */ );
// t = log10f( ( hCPE->hStereoICBWE->icbweRefEner + 1e-6f ) / ( lbEner + 1e-6f ) );
t = L_deposit_h( BASOP_Util_Divide3232_Scale( L_add( hCPE->hStereoICBWE->icbweRefEner_fx, EPSILON_FX ), L_add( lbEner, EPSILON_FX ), &exp_t ) );
diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c
index a2965d5dc632ca599b32848d5396e63814966bf0..f67d81c7132e58062b7ee282a686c76fbb31fd7a 100644
--- a/lib_enc/swb_tbe_enc_fx.c
+++ b/lib_enc/swb_tbe_enc_fx.c
@@ -607,9 +607,9 @@ void InitSWBencBuffer_ivas_fx(
// TV2TV IVAS_CODE -> To be verify if it has to be moved to hBWE_TD
- st_fx->prev_Q_bwe_exc = 31;
+ st_fx->prev_Q_bwe_exc = 15;
move16();
- st_fx->prev_Q_bwe_syn = 31;
+ st_fx->prev_Q_bwe_syn = 15;
move16();
set16_fx( st_fx->prev_lsp_wb_fx, 0, 6 );
set16_fx( st_fx->prev_lsp_wb_temp_fx, 0, 6 );
@@ -2940,7 +2940,7 @@ void swb_tbe_enc_ivas_fx(
Word16 formant_fac_fx;
// int16_t stab_check = 1;
Word16 MSFlag;
- Word16 *nlExc16k_fx, *mixExc16k_fx;
+ Word16 *nlExc16k_fx, *nlExc16k_e, *mixExc16k_fx, *mixExc16k_e;
Word16 shaped_shb_excitationTemp_fx[L_FRAME16k];
@@ -2948,6 +2948,9 @@ void swb_tbe_enc_ivas_fx(
Word16 acorr_EnvSHBres[ENVSHBRES_ACORR_MAX - ENVSHBRES_ACORR_MIN], *p_acorr, shb_env_tilt_fx;
Word16 buf_EnvSHBres_fx[2 * L_FRAME4k], *p_buf, EnvSHBres_fx[L_FRAME16k], EnvSHBres_4k_fx[L_FRAME4k], EnvSHBres_4k_norm_fx[L_FRAME4k], env_mean_normf_fx[L_FRAME4k];
+ Word32 tmp_buf[L_FRAME4k];
+ Word16 Q_EnvSHBres_4k_norm = Q31;
+ move16();
Word16 GainShape_Interp_fx[NUM_SHB_SUBGAINS], GainShape_tilt_fx; /* Q15 */
Word16 seg_mean[4], den_seg_mean[4], *p_env, step;
Word16 temp, scale_fx, scale_e, pow_e, tmp_e, tmp1_e;
@@ -2994,14 +2997,18 @@ void swb_tbe_enc_ivas_fx(
IF( st_fx->element_mode >= IVAS_CPE_DFT && hStereoICBWE != NULL )
{
nlExc16k_fx = hStereoICBWE->nlExc16k_fx;
+ nlExc16k_e = &hStereoICBWE->nlExc16k_e;
mixExc16k_fx = hStereoICBWE->mixExc16k_fx;
+ mixExc16k_e = &hStereoICBWE->mixExc16k_e;
MSFlag = hStereoICBWE->MSFlag;
move16();
}
ELSE
{
nlExc16k_fx = NULL;
+ nlExc16k_e = NULL;
mixExc16k_fx = NULL;
+ mixExc16k_e = NULL;
MSFlag = 0;
move16();
}
@@ -3141,7 +3148,7 @@ void swb_tbe_enc_ivas_fx(
test();
IF( st_fx->rf_mode || EQ_32( st_fx->extl_brate, SWB_TBE_0k95 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) )
{
- lsp_weights_fx( lsf_shb_fx, weights_lsp, LPC_SHB_ORDER, &Q_out );
+ lsp_weights_ivas_fx( lsf_shb_fx, weights_lsp, LPC_SHB_ORDER, &Q_out );
/* to compensate for the 1.1* weighting done inside the function lsp_weights */
/*weights_lsp[3]*=0.909091f; weights_lsp[4]*=0.909091f; */
@@ -3503,7 +3510,13 @@ void swb_tbe_enc_ivas_fx(
/* normalize residual SHB envelope with its long-term mean envelope */
FOR( k = 0; k < L_FRAME4k; k++ )
{
- EnvSHBres_4k_norm_fx[k] = mult( EnvSHBres_4k_fx[k], env_mean_normf_fx[k] );
+ tmp_buf[k] = L_mult( EnvSHBres_4k_fx[k], env_mean_normf_fx[k] ); // Q_shb + Q15 + Q1 => Q_shb + Q16
+ move32();
+ }
+ Q_EnvSHBres_4k_norm = sub( getScaleFactor32( tmp_buf, L_FRAME4k ), 1 /* Guard bit */ );
+ FOR( k = 0; k < L_FRAME4k; k++ )
+ {
+ EnvSHBres_4k_norm_fx[k] = extract_h( L_shl( tmp_buf[k], Q_EnvSHBres_4k_norm ) ); // Q_shb + Q16 + Q_EnvSHBres_4k_norm - Q16 => Q_EnvSHBres_4k_norm + Q_shb
move16();
}
@@ -3515,15 +3528,16 @@ void swb_tbe_enc_ivas_fx(
/* subtract mean value from the normalized SHB residual envelope */
p_buf = &buf_EnvSHBres_fx[L_FRAME4k];
- temp = mean_no_sat_fx( EnvSHBres_4k_norm_fx, L_FRAME4k );
+ temp = mean_no_sat_fx( EnvSHBres_4k_norm_fx, L_FRAME4k ); // Q_EnvSHBres_4k_norm + Q_shb
FOR( k = 0; k < L_FRAME4k; k++ )
{
- *p_buf++ = sub( EnvSHBres_4k_norm_fx[k], temp );
+ *p_buf++ = shr( sub( EnvSHBres_4k_norm_fx[k], temp ), Q_EnvSHBres_4k_norm ); // Q_shb
move16();
}
+ Q_EnvSHBres_4k_norm = add( Q_EnvSHBres_4k_norm, Q_shb );
/* update memory */
- Copy( &buf_EnvSHBres_fx[L_FRAME4k], hBWE_TD->old_EnvSHBres_fx, L_FRAME4k );
+ Copy( &buf_EnvSHBres_fx[L_FRAME4k], hBWE_TD->old_EnvSHBres_fx, L_FRAME4k ); // Q_shb
/* calculate energy normalization factor for the auto-correlation function */
// pow0 = sum2_f( &buf_EnvSHBres[L_FRAME4k], L_FRAME4k ) + 1.0f;
@@ -3673,7 +3687,7 @@ void swb_tbe_enc_ivas_fx(
sc = sub( Q_bwe_exc, add( Q_new, Q_new ) );
/* rescale the bwe_exc_extended and bring it to 16-bit single precision with dynamic norm */
- FOR( cnt = 0; cnt < L_FRAME32k; cnt++ )
+ FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ )
{
bwe_exc_extended_16[cnt] = round_fx_sat( L_shl_sat( bwe_exc_extended[cnt], sc ) );
move16();
@@ -3697,8 +3711,8 @@ void swb_tbe_enc_ivas_fx(
st_fx->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st_fx->extl,
&( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_Q31,
shb_res_gshape_fx, shb_res_fx, &vf_ind_fx, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_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, 0, st_fx->element_mode, st_fx->flag_ACELP16k, nlExc16k_fx, mixExc16k_fx, st_fx->extl_brate, MSFlag,
- EnvSHBres_4k_norm_fx, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), &Env_error_fx, Env_error_part_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, 0, st_fx->element_mode, st_fx->flag_ACELP16k, nlExc16k_fx, nlExc16k_e, mixExc16k_fx, mixExc16k_e, st_fx->extl_brate, MSFlag,
+ EnvSHBres_4k_norm_fx, Q_EnvSHBres_4k_norm, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), &Env_error_fx, Env_error_part_fx );
*Q_white_exc = Q_bwe_exc_fb;
move16();
@@ -3904,47 +3918,48 @@ void swb_tbe_enc_ivas_fx(
/* Gain frame adjustment factor */
/* log( (GainShape[0]) / (st->prev_wb_GainShape) )*/
- test();
- IF( GainShape_fx[0] && hBWE_TD->prev_swb_GainShape_fx )
+ IF( hBWE_TD->prev_swb_GainShape_fx == 0 )
{
- exp = norm_s( hBWE_TD->prev_swb_GainShape_fx );
- tmp = div_s( shl( 1, sub( 14, exp ) ), hBWE_TD->prev_swb_GainShape_fx );
- L_tmp = L_mult( GainShape_fx[0], tmp ); /*Q(30 - exp) */
-
- exp1 = norm_l( L_tmp );
- frac = Log2_norm_lc( L_shl( L_tmp, exp1 ) ); /*move16(); */
- exp1 = sub( exp, exp1 ); /*move16(); */
- L_tmp = Mpy_32_16( exp1, frac, 22713 );
- temp_swb_fac = round_fx( L_shl( L_tmp, 10 ) );
+ exp = 13 /* norm_s(3) */;
+ tmp = 21845 /* div_s( shl(1, sub(14, exp)), 3 /\* 0.0001 in Q15 *\/ ) */;
}
ELSE
{
- temp_swb_fac = 0;
- move16();
+ exp = norm_s( hBWE_TD->prev_swb_GainShape_fx );
+ tmp = div_s( shl( 1, sub( 14, exp ) ), hBWE_TD->prev_swb_GainShape_fx );
}
- L_feedback = L_mult0( temp_swb_fac, temp_swb_fac );
+
+ L_tmp = L_mult( GainShape_fx[0], tmp ); /*Q(30 - exp) */
+
+ exp1 = norm_l( L_tmp );
+ frac = Log2_norm_lc( L_shl( L_tmp, exp1 ) ); /*move16(); */
+ exp1 = sub( exp, exp1 ); /*move16(); */
+ L_tmp = Mpy_32_16( exp1, frac, 22713 );
+ temp_swb_fac = round_fx( L_shl( L_tmp, 10 ) );
+
+ L_feedback = L_mult( temp_swb_fac, temp_swb_fac );
FOR( i = 1; i < NUM_SHB_SUBGAINS; i++ )
{
test();
- IF( GainShape_fx[i] && GainShape_fx[i - 1] )
+ IF( GainShape_fx[i - 1] == 0 )
{
- exp = norm_s( GainShape_fx[i - 1] );
- tmp = div_s( shl( 1, sub( 14, exp ) ), GainShape_fx[i - 1] );
- L_tmp = L_mult( GainShape_fx[i], tmp ); /* Q(30 - exp) */
-
- exp1 = norm_l( L_tmp );
- frac = Log2_norm_lc( L_shl( L_tmp, exp1 ) );
- exp1 = sub( exp, exp1 );
- L_tmp = Mpy_32_16( exp1, frac, 22713 );
- temp_swb_fac = round_fx( L_shl( L_tmp, 10 ) );
+ exp = 13 /* norm_s(3) */;
+ tmp = 21845 /* div_s( shl(1, sub(14, exp)), 3 /\* 0.0001 in Q15 *\/ ) */;
}
ELSE
{
- temp_swb_fac = 0;
- move16();
+ exp = norm_s( GainShape_fx[i - 1] );
+ tmp = div_s( shl( 1, sub( 14, exp ) ), GainShape_fx[i - 1] );
}
+ L_tmp = L_mult( GainShape_fx[i], tmp ); /* Q(30 - exp) */
+
+ exp1 = norm_l( L_tmp );
+ frac = Log2_norm_lc( L_shl( L_tmp, exp1 ) );
+ exp1 = sub( exp, exp1 );
+ L_tmp = Mpy_32_16( exp1, frac, 22713 );
+ temp_swb_fac = round_fx( L_shl( L_tmp, 10 ) );
L_feedback = L_mac( L_feedback, temp_swb_fac, temp_swb_fac );
}
@@ -4034,7 +4049,9 @@ void swb_tbe_enc_ivas_fx(
{
/* Re-normalize gain shape before quantization */
// sum_gain = sum2_f(GainShape, NUM_SHB_SUBGAINS);
- sum_gain_fx = sum16_32_fx( GainShape_fx, NUM_SHB_SUBGAINS );
+ tmp = 0;
+ move16();
+ sum_gain_fx = sum2_16_exp_fx( GainShape_fx, NUM_SHB_SUBGAINS, &tmp, 2 );
IF( sum_gain_fx == 0 )
{
normFact_fx = 0;
@@ -4043,8 +4060,6 @@ void swb_tbe_enc_ivas_fx(
ELSE
{
// normFact = (float) sqrt( 1.0f / sum_gain );
- tmp = Q16;
- move16();
normFact_fx = ISqrt32( sum_gain_fx, &tmp );
}
diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c
index bafd932a3088f30bb93d3b9eaa081a4c58589816..1e35c78c4c590651080c7e4bb8877217efafdb25 100644
--- a/lib_enc/tcx_utils_enc_fx.c
+++ b/lib_enc/tcx_utils_enc_fx.c
@@ -2399,6 +2399,7 @@ void tcx_noise_factor_fx(
*fac_ns = extract_l( L_mult0( *quantized_fac_ns, shr( 24576 /*0.75f Q15*/, NBITS_NOISE_FILL_LEVEL ) ) );
}
+
void tcx_noise_factor_ivas_fx(
Word32 *x_orig, /* i: unquantized mdct coefficients */
Word16 x_orig_e, /* i: exponent */
@@ -2415,29 +2416,32 @@ void tcx_noise_factor_ivas_fx(
Word16 element_mode /* i: element mode */
)
{
- Word16 i, k = 0, maxK, segmentOffset;
- Word32 sqErrorNrg, n;
- Word16 inv_gain2, inv_gain2_e, tilt_factor, nTransWidth_1;
+ Word16 i, k, win, segmentOffset, j;
+ Word32 sqErrorNrg = 0, n;
+ move32();
+ Word16 inv_gain2, inv_gain2_e, tilt_factor, nTransWidth_1, exp_sqErrorNrg = 0;
+ move16();
Word32 accu1, accu2, tmp32;
Word16 tmp1, tmp2, s;
Word16 c1, c2;
Word16 att; /* noise level attenuation factor for transient windows */
Word32 xMax;
+ Word16 exp_spQ[N_MAX];
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
move32();
#endif
- move16();
assert( nTransWidth <= 16 );
+ set16_fx( exp_spQ, x_orig_e, N_MAX );
c1 = sub( shl( nTransWidth, 1 ), 4 );
c2 = mult( 9216 /*0.28125f Q15*/, inv_int[nTransWidth] );
nTransWidth_1 = sub( nTransWidth, 1 );
/*Adjust noise filling level*/
- sqErrorNrg = L_deposit_l( 0 );
- n = L_deposit_l( 0 );
+ n = 0;
+ move32();
/* get inverse frame length */
tmp1 = getInvFrameLen( L_frame );
@@ -2449,10 +2453,8 @@ void tcx_noise_factor_ivas_fx(
/* inv_gain2 = 1.0f / ((float)(nTransWidth * nTransWidth) * gain_tcx); */
tmp32 = L_mult( imult1616( nTransWidth, nTransWidth ), gain_tcx ); /* 15Q16 */
- tmp1 = norm_l( tmp32 );
- inv_gain2 = round_fx( L_shl( tmp32, tmp1 ) );
- inv_gain2_e = add( sub( 15, tmp1 ), gain_tcx_e );
- inv_gain2 = Inv16( inv_gain2, &inv_gain2_e );
+ inv_gain2 = BASOP_Util_Divide3232_Scale( MAX_32, tmp32, &inv_gain2_e );
+ inv_gain2_e = add( inv_gain2_e, sub( 0, add( 15, gain_tcx_e ) ) );
inv_gain2 = shr( inv_gain2, 2 ); /* 2 bits headroom */
inv_gain2_e = add( inv_gain2_e, 2 );
@@ -2463,15 +2465,13 @@ void tcx_noise_factor_ivas_fx(
IF( EQ_16( element_mode, IVAS_CPE_MDCT ) ) /* ... but only in mono or parametric stereo since it may cause binaural unmasking in discrete stereo */
{
segmentOffset = i;
- maxK = 1;
- move16();
move16();
}
ELSE
{
/* find last nonzero line below iFirstLine, use it as start offset */
tmp1 = shr( iFirstLine, 1 );
- FOR( i = iFirstLine; i > tmp1; i-- )
+ FOR( ; i > tmp1; i-- )
{
IF( sqQ[i] != 0 )
{
@@ -2484,16 +2484,6 @@ void tcx_noise_factor_ivas_fx(
inv_gain2 = shl( mult( inv_gain2, tilt_factor ), 1 );
}
- /* initialize left (k) and right (maxK) non-zero neighbor pointers */
- k = 0;
- move16();
- FOR( maxK = 1; maxK < nTransWidth; maxK++ )
- {
- IF( sqQ[i + maxK] != 0 )
- {
- BREAK;
- }
- }
i = add( i, 1 );
segmentOffset = i;
move16();
@@ -2501,17 +2491,20 @@ void tcx_noise_factor_ivas_fx(
IF( LE_16( nTransWidth, 3 ) )
{
- accu1 = L_deposit_l( 0 );
- accu2 = L_deposit_l( 0 );
- xMax = L_deposit_l( 0 );
+ accu1 = 0;
+ move32();
+ accu2 = 0;
+ move32();
+ xMax = 0;
+ move32();
- FOR( k = s_and( i, (Word16) 0xFFFE ); k < lowpassLine; k++ )
+ FOR( k = i & 0xFFFE; k < lowpassLine; k++ )
{
xMax = L_max( xMax, L_abs( x_orig[k] ) );
}
s = sub( norm_l( xMax ), 4 );
- FOR( k = s_and( i, (Word16) 0xFFFE ); k < lowpassLine; k += 2 )
+ FOR( k = i & 0xFFFE; k < lowpassLine; k += 2 )
{
/* even-index bins, left sub-win */
tmp1 = round_fx( L_shl( x_orig[k], s ) );
@@ -2524,13 +2517,15 @@ void tcx_noise_factor_ivas_fx(
k = 0;
move16();
- IF( accu1 == 0 )
+ if ( accu1 == 0 )
{
- accu1 = L_deposit_l( 1 );
+ accu1 = 1;
+ move32();
}
- IF( accu2 == 0 )
+ if ( accu2 == 0 )
{
- accu2 = L_deposit_l( 1 );
+ accu2 = 1;
+ move32();
}
att = BASOP_Util_Divide3232_Scale( L_shl( L_min( accu1, accu2 ), 1 ), L_add( accu1, accu2 ), &s );
@@ -2545,19 +2540,19 @@ void tcx_noise_factor_ivas_fx(
move16();
}
- accu1 = L_deposit_l( 0 );
+ win = 0;
+ move16();
- tmp1 = sub( lowpassLine, nTransWidth );
- FOR( ; i <= tmp1; i++ )
+ FOR( ; i < lowpassLine; i++ )
{
inv_gain2 = shl( mult( inv_gain2, tilt_factor ), 1 );
- IF( EQ_16( maxK, 1 ) ) /* current line is not zero, so reset pointers */
+ IF( sqQ[i] != 0 ) /* current line is not zero, so reset pointers */
{
- k = sub( i, segmentOffset );
-
- IF( k > 0 ) /* add segment sum to sum of segment magnitudes */
+ IF( win > 0 )
{
+ k = sub( i, segmentOffset );
+
IF( LE_16( nTransWidth, 3 ) )
{
tmp2 = sub( k, c1 );
@@ -2590,115 +2585,43 @@ void tcx_noise_factor_ivas_fx(
n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ );
}
}
- sqErrorNrg = L_add( sqErrorNrg, accu1 );
- accu1 = L_deposit_l( 0 ); /* segment ended here, so reset segment sum */
- k = 0;
- move16();
- }
-
- FOR( ; maxK < nTransWidth; maxK++ )
- {
- IF( sqQ[i + maxK] != 0 )
- {
- BREAK;
- }
- }
- segmentOffset = add( i, 1 ); /* new segment might start at next line */
- }
- ELSE /* current line is zero, so update pointers & segment sum */
- {
- IF( LT_16( k, nTransWidth ) )
- {
- k = add( k, 1 );
- }
-
- tmp2 = sub( maxK, nTransWidth );
- test();
- IF( tmp2 < 0 && NE_16( element_mode, IVAS_CPE_MDCT ) )
- {
- maxK = sub( maxK, 1 );
- }
-
- test();
- IF( ( tmp2 >= 0 ) && ( sqQ[i + sub( nTransWidth, 1 )] != 0 ) )
- {
- maxK = sub( nTransWidth, 1 );
- }
-
- /* update segment sum: magnitudes scaled by smoothing function */
- /*accu1 += (float)fabs(x_orig[i]) * inv_gain2 * (float)(k * maxK);*/
- tmp2 = mult( inv_gain2, shl( imult1616( k, maxK ), 8 ) );
- accu1 = L_add( accu1, L_abs( Mpy_32_16_1( x_orig[i], tmp2 ) ) );
- }
- }
-
- FOR( ; i < lowpassLine; i++ )
- {
- inv_gain2 = shl( mult( inv_gain2, tilt_factor ), 1 );
-
- IF( EQ_16( maxK, 1 ) ) /* current line is not zero, so reset pointers */
- {
- k = sub( i, segmentOffset );
-
- IF( k > 0 ) /* add segment sum to sum of segment magnitudes */
- {
- IF( LE_16( nTransWidth, 3 ) )
+ FOR( k = segmentOffset; k < i - win; k++ )
{
- tmp2 = sub( k, c1 );
- IF( tmp2 > 0 )
- {
- n = L_msu( n, k, (Word16) 0x8000 );
- }
- IF( tmp2 > 0 )
- {
- n = L_mac( n, nTransWidth_1, (Word16) 0x8000 );
- }
- IF( tmp2 <= 0 )
- {
- n = L_mac( n, int_sqr[k], c2 );
- }
+ tmp1 = norm_l( sqQ[k] );
+ sqErrorNrg = BASOP_Util_Add_Mant32Exp( sqErrorNrg, exp_sqErrorNrg, Mpy_32_16_1( L_shl( sqQ[k], tmp1 ), nTransWidth ), add( 15, sub( exp_spQ[k], tmp1 ) ), &exp_sqErrorNrg );
+ sqQ[k] = 0;
+ move32();
+ exp_spQ[k] = 0;
+ move16();
}
- ELSE
+ FOR( ; win > 0; win-- )
{
- tmp2 = sub( k, 12 );
- IF( tmp2 > 0 )
- {
- n = L_msu( n, k, (Word16) 0x8000 );
- }
- IF( tmp2 > 0 )
- {
- n = L_sub( n, 0x70000 );
- }
- IF( tmp2 <= 0 )
- {
- n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ );
- }
+ tmp1 = norm_l( sqQ[k] );
+ sqErrorNrg = BASOP_Util_Add_Mant32Exp( sqErrorNrg, exp_sqErrorNrg, Mpy_32_16_1( L_shl( sqQ[k], tmp1 ), win ), add( 15, sub( exp_spQ[k], tmp1 ) ), &exp_sqErrorNrg );
+ exp_spQ[k] = 0;
+ move16();
+ sqQ[k++] = 0;
+ move32();
}
- sqErrorNrg = L_add( sqErrorNrg, accu1 );
}
- segmentOffset = add( i, 1 ); /* no new segments since maxK remains 1 */
+ segmentOffset = add( i, 1 ); /* new segment might start at next line */
}
- ELSE /* current line is zero, so update pointers & energy sum */
+ ELSE /* current line is zero, so update pointers & segment sum */
{
- IF( LT_16( k, nTransWidth ) )
+ IF( LT_16( win, nTransWidth ) )
{
- k = add( k, 1 );
- }
- IF( LT_16( maxK, nTransWidth ) )
- {
- maxK = sub( maxK, 1 );
+ win = add( win, 1 );
}
-
/* update segment sum: magnitudes scaled by smoothing function */
- /*accu1 += (float)fabs(x_orig[i]) * inv_gain2 * (float)(k * maxK);*/
- tmp2 = mult( inv_gain2, shl( imult1616( k, maxK ), 8 ) );
- accu1 = L_add( accu1, L_abs( Mpy_32_16_1( x_orig[i], tmp2 ) ) );
+ sqQ[i] = Mpy_32_16_1( imult3216( L_abs( x_orig[i] ), win ), inv_gain2 );
+ move32();
+ exp_spQ[i] = add( x_orig_e, inv_gain2_e );
+ move16();
}
}
-
- k = sub( i, segmentOffset );
- IF( k > 0 ) /* add last segment sum to sum of segment magnitudes */
+ IF( win > 0 ) /* add last segment sum to sum of segment magnitudes */
{
+ k = sub( i, segmentOffset );
IF( LE_16( nTransWidth, 3 ) )
{
tmp2 = sub( k, c1 );
@@ -2731,27 +2654,47 @@ void tcx_noise_factor_ivas_fx(
n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ );
}
}
- sqErrorNrg = L_add( sqErrorNrg, accu1 );
+ FOR( k = segmentOffset; k < i - win; k++ )
+ {
+ tmp1 = norm_l( sqQ[k] );
+ sqErrorNrg = BASOP_Util_Add_Mant32Exp( sqErrorNrg, exp_sqErrorNrg, Mpy_32_16_1( L_shl( sqQ[k], tmp1 ), nTransWidth ), add( 15, sub( exp_spQ[k], tmp1 ) ), &exp_sqErrorNrg );
+ exp_spQ[k] = 0;
+ move16();
+ sqQ[k] = 0;
+ move32();
+ }
+ FOR( ; win > 0; win-- )
+ {
+ tmp1 = norm_l( sqQ[k] );
+ sqErrorNrg = BASOP_Util_Add_Mant32Exp( sqErrorNrg, exp_sqErrorNrg, Mpy_32_16_1( L_shl( sqQ[k], tmp1 ), win ), add( 15, sub( exp_spQ[k], tmp1 ) ), &exp_sqErrorNrg );
+ exp_spQ[k] = 0;
+ move16();
+ sqQ[k++] = 0;
+ move32();
+ }
}
-
+ Word32 tmp4;
/* noise level factor: average of segment magnitudes of noise bins */
IF( n > 0 )
{
- tmp1 = BASOP_Util_Divide3232_Scale( Mpy_32_16_1( sqErrorNrg, att ), n, &s );
- s = add( add( add( s, x_orig_e ), inv_gain2_e ), 7 - 15 );
+ tmp4 = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_16_1( sqErrorNrg, att ), n, &s );
+ s = add( add( exp_sqErrorNrg, -15 ), s );
BASOP_SATURATE_WARNING_OFF_EVS;
- tmp1 = shl_o( tmp1, s, &Overflow );
+ tmp4 = L_shl_o( tmp4, s, &Overflow );
BASOP_SATURATE_WARNING_ON_EVS;
}
ELSE
{
- tmp1 = 0;
+ tmp4 = 0;
move16();
}
-
+ FOR( j = 0; j < N_MAX; j++ )
+ {
+ sqQ[j] = L_shl( sqQ[j], sub( x_orig_e, exp_spQ[j] ) );
+ move32();
+ }
/* quantize, dequantize noise level factor (range 0.09375 - 0.65625) */
- tmp2 = round_fx( L_shr( L_mult( tmp1, 22016 /*1.34375f Q14*/ ), 14 - NBITS_NOISE_FILL_LEVEL ) );
-
+ tmp2 = round_fx( L_shr( Mpy_32_16_1( tmp4, 22016 /*1.34375f Q14*/ ), 14 - NBITS_NOISE_FILL_LEVEL ) );
if ( GT_16( tmp2, ( 1 << NBITS_NOISE_FILL_LEVEL ) - 1 ) )
{
tmp2 = ( 1 << NBITS_NOISE_FILL_LEVEL ) - 1;
@@ -2762,8 +2705,10 @@ void tcx_noise_factor_ivas_fx(
move16();
*fac_ns = extract_l( L_mult0( *quantized_fac_ns, shr( 24576 /*0.75f Q15*/, NBITS_NOISE_FILL_LEVEL ) ) );
+ move16();
}
+
void tcx_encoder_memory_update_fx(
Word16 *wsig, /* i : target weighted signal */
Word16 *xn_buf, /* i/o: mdct output buffer/time domain weigthed synthesis */
@@ -3894,7 +3839,7 @@ void ProcessIGF_ivas_fx(
q_A = 0;
move16();
- ITF_Detect_fx( hIGFEnc->spec_be_igf, hIGFEnc->infoStartLine, hIGFEnc->infoStopLine, 8 /*maxOrder*/, A, &q_A, &predictionGain, &curr_order, sub( 31, hIGFEnc->spec_be_igf_e ) );
+ ITF_Detect_ivas_fx( hIGFEnc->spec_be_igf, hIGFEnc->infoStartLine, hIGFEnc->infoStopLine, 8 /*maxOrder*/, A, &q_A, &predictionGain, &curr_order, sub( 31, hIGFEnc->spec_be_igf_e ) );
test();
IF( LT_32( L_deposit_l( hIGFEnc->tns_predictionGain ), 9646899 /* 1.15 in Q23 */ ) && LT_32( L_deposit_l( predictionGain ), 9646899 /* 1.15 in Q23 */ ) )
@@ -4001,7 +3946,7 @@ void ProcessStereoIGF_fx(
predictionGain = 0;
move16();
- ITF_Detect_fx( hIGFEnc[ch]->spec_be_igf, hIGFEnc[ch]->infoStartLine, hIGFEnc[ch]->infoStopLine, 8 /*maxOrder*/, A, &Q_A, &predictionGain, &curr_order, sub( 31, hIGFEnc[ch]->spec_be_igf_e ) );
+ ITF_Detect_ivas_fx( hIGFEnc[ch]->spec_be_igf, hIGFEnc[ch]->infoStartLine, hIGFEnc[ch]->infoStopLine, 8 /*maxOrder*/, A, &Q_A, &predictionGain, &curr_order, sub( 31, hIGFEnc[ch]->spec_be_igf_e ) );
test();
hIGFEnc[ch]->flatteningTrigger = LT_32( hIGFEnc[ch]->tns_predictionGain, ONE_POINT_ONE_FIVE_Q23 ) && LT_32( predictionGain, ONE_POINT_ONE_FIVE_Q7 );
diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c
index 79bb7b914d1f7b7ad5627ee359f8aaeaff37d3ce..d1763e039fc96f6e36d1e442fb510c57d1b16332 100644
--- a/lib_enc/tns_base_enc_fx.c
+++ b/lib_enc/tns_base_enc_fx.c
@@ -675,7 +675,7 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur
ELSE
{
maxEnergyChange = GetTCXMaxenergyChange_ivas_fx( hTranDet, isTCX10, NSUBBLOCKS, 3 );
- IF( sub( maxEnergyChange, pTnsParameters->minEnergyChange ) >= 0 )
+ IF( sub( maxEnergyChange, shl( pTnsParameters->minEnergyChange, Q3 - Q7 ) ) >= 0 )
{
pTnsData->nFilters = add( pTnsData->nFilters, 1 );
diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c
index 736d838c288782dfd71790efb66a1dd606405aaa..d9859a1a10ddc4685c86875295e168d118ee1ff8 100644
--- a/lib_enc/transient_detection_fx.c
+++ b/lib_enc/transient_detection_fx.c
@@ -147,6 +147,7 @@ static void GetAttackForTCXDecision_ivas_fx( Word32 const *pSubblockNrg, Word32
Word16 i;
Word16 bIsAttackPresent, attackIndex;
Word16 attackRatioThreshold_1_5;
+ Word64 W_tmp1, W_tmp2, W_tmp3;
(void) nPastSubblocks;
(void) nSubblocks;
@@ -161,8 +162,8 @@ static void GetAttackForTCXDecision_ivas_fx( Word32 const *pSubblockNrg, Word32
bIsAttackPresent = FALSE;
attackIndex = -1;
/* Search for the last attack in the subblocks */
- if ( s_or( (Word16) GT_32( L_shr( pSubblockNrg[-1], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-1], attackRatioThreshold ) ),
- L_sub( L_shr( pSubblockNrg[-2], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-2], attackRatioThreshold ) ) > 0 ) )
+ IF( s_or( (Word16) GT_32( L_shr( pSubblockNrg[-1], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-1], attackRatioThreshold ) ),
+ L_sub( L_shr( pSubblockNrg[-2], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-2], attackRatioThreshold ) ) > 0 ) )
{
move16();
bIsAttackPresent = TRUE;
@@ -172,7 +173,10 @@ static void GetAttackForTCXDecision_ivas_fx( Word32 const *pSubblockNrg, Word32
FOR( i = 0; i < NSUBBLOCKS; i++ )
{
- IF( GT_32( L_shr( pSubblockNrg[i], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[i], attackRatioThreshold ) ) )
+ W_tmp2 = W_shr( W_mult_32_16( pAccSubblockNrg[i], attackRatioThreshold ), 1 );
+ W_tmp1 = W_shl( pSubblockNrg[i], ( 15 - ATTACKTHRESHOLD_E ) );
+
+ IF( GT_64( W_tmp1, W_tmp2 ) )
{
if ( i < 6 )
{
@@ -180,22 +184,44 @@ static void GetAttackForTCXDecision_ivas_fx( Word32 const *pSubblockNrg, Word32
bIsAttackPresent = TRUE;
}
- if ( s_and( (Word16) NE_16( attackIndex, 2 ), (Word16) NE_16( attackIndex, 6 ) ) )
+ IF( s_and( (Word16) NE_16( attackIndex, 2 ), (Word16) NE_16( attackIndex, 6 ) ) )
{
move16();
attackIndex = i;
+ W_tmp2 = W_shr( W_mult_32_16( pAccSubblockNrg[i], attackRatioThreshold ), 1 );
+ W_tmp2 = W_add( W_tmp2, W_shr( W_tmp2, 3 ) ); // pAccSubblockNrg[i] * 1.125f
+ W_tmp1 = W_shl( pSubblockNrg[i], ( 15 - ATTACKTHRESHOLD_E ) );
+ if ( s_and( (Word16) LT_64( W_tmp1, W_tmp2 ), s_or( (Word16) EQ_16( i, 2 ), (Word16) EQ_16( i, 6 ) ) ) )
+ {
+ attackIndex = add( attackIndex, 1 ); /* avoid minimum overlap to prevent clicks */
+ }
}
}
ELSE /* no attack, but set index anyway in case of strong energy increase */
{
- IF( s_and( ( (Word16) GT_32( L_shr( pSubblockNrg[i], 1 + ATTACKTHRESHOLD_E ), Mpy_32_16_1( pSubblockNrg[sub( i, 1 )], attackRatioThreshold_1_5 ) ) ),
- ( L_sub( L_shr( pSubblockNrg[i], 1 + ATTACKTHRESHOLD_E ), Mpy_32_16_1( pSubblockNrg[sub( i, 2 )], attackRatioThreshold_1_5 ) ) > 0 ) ) )
+ W_tmp2 = W_shr( W_mult_32_16( pSubblockNrg[i - 1], attackRatioThreshold_1_5 ), 1 );
+ W_tmp1 = W_shl( pSubblockNrg[i], ( 15 - ( ATTACKTHRESHOLD_E + 1 ) ) );
+ W_tmp3 = W_shr( W_mult_32_16( pSubblockNrg[i - 2], attackRatioThreshold_1_5 ), 1 );
+
+ IF( s_and( ( (Word16) GT_64( W_tmp1, W_tmp2 ) ),
+ ( W_sub( W_tmp1, W_tmp3 ) > 0 ) ) )
{
- if ( s_and( (Word16) NE_16( attackIndex, 2 ), (Word16) NE_16( attackIndex, 6 ) ) )
+ IF( s_and( (Word16) NE_16( attackIndex, 2 ), (Word16) NE_16( attackIndex, 6 ) ) )
{
move16();
attackIndex = i;
+
+ W_tmp2 = W_mult_32_16( pSubblockNrg[i - 1], attackRatioThreshold );
+ W_tmp3 = W_mult_32_16( pSubblockNrg[i - 2], attackRatioThreshold );
+ W_tmp1 = W_shl( pSubblockNrg[i], ( 15 - ATTACKTHRESHOLD_E ) );
+
+ if ( s_and( (Word16) s_or( (Word16) LT_64( W_tmp1, W_tmp2 ), (Word16)
+ LT_64( W_tmp1, W_tmp3 ) ),
+ s_or( (Word16) EQ_16( i, 2 ), (Word16) EQ_16( i, 6 ) ) ) )
+ {
+ attackIndex = add( attackIndex, 1 ); /* avoid minimum overlap to prevent clicks */
+ }
}
}
}
diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c
index 02372138db1786a7c91850265391c9b46b4de1ee..0089fc745e46d2fb7a92aac9126e0ed66083faff 100644
--- a/lib_enc/transition_enc_fx.c
+++ b/lib_enc/transition_enc_fx.c
@@ -214,7 +214,11 @@ void transition_enc_fx(
{
/* this is called only to compute unused bits */
config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+#ifdef NONBE_FIX_GSC_BSTR
+ L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP,
+#else
L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, TC_0_0, 3, NULL, unbits_ACELP,
+#endif
st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/
);
}
@@ -326,7 +330,11 @@ void transition_enc_fx(
IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) )
{
config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+#ifdef NONBE_FIX_GSC_BSTR
+ st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL,
+#else
st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, *tc_subfr, 2, NULL,
+#endif
unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
}
/*-----------------------------------------------------------------*
@@ -1035,7 +1043,11 @@ void transition_enc_ivas_fx(
{
/* this is called only to compute unused bits */
config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+#ifdef NONBE_FIX_GSC_BSTR
+ L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP,
+#else
L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, TC_0_0, 3, NULL, unbits_ACELP,
+#endif
st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/
);
}
@@ -1147,7 +1159,11 @@ void transition_enc_ivas_fx(
IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) )
{
config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+#ifdef NONBE_FIX_GSC_BSTR
+ st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL,
+#else
st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, *tc_subfr, 2, NULL,
+#endif
unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
}
/*-----------------------------------------------------------------*
diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c
index 9ecca6975dc57f701a0ab3184b3ccb57800064fd..12ec319331a96478406ffe166a5b2e7a1906b949 100644
--- a/lib_enc/vad_fx.c
+++ b/lib_enc/vad_fx.c
@@ -566,7 +566,7 @@ Word16 ivas_dtx_hangover_addition_fx(
test();
test();
test();
- if ( ( GT_16( hVAD->prim_act_he_fx, 31129 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */
+ if ( ( GT_16( hVAD->prim_act_he_fx, 32113 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */
{
hVAD->hangover_cnt_music = 0;
move16();
@@ -2638,11 +2638,15 @@ Word16 wb_vad_ivas_fx(
/* DTX HANGOVER is in pre_proc_fx() */
flag_he1 = 0;
move16();
-
+ st_fx->localVAD = 0;
+ move16();
IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_mssnr, L_mssnr_e, L_vad_thr, 18 ), 1 ) )
{
flag_he1 = 1;
- move16(); /* he1 primary decision */
+ move16();
+ st_fx->localVAD = 1;
+ move16();
+ /* he1 primary decision */
hVAD->nb_active_frames_he1 = add( hVAD->nb_active_frames_he1, 1 ); /* Counter of consecutive active speech frames */
move16();
diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c
index d8cfec1d133dbcce6d623e7edda4b0229afb9811..12bc769faa915450e227b7617e096ec64e13cbca 100644
--- a/lib_rend/ivas_crend.c
+++ b/lib_rend/ivas_crend.c
@@ -1854,8 +1854,8 @@ static ivas_error ivas_rend_crendConvolver(
FOR( k = 0; k < pCrend->hHrtfCrend->pIndex_frequency_max[i][j][m]; k++ )
{
- tmp_out_re[k] = L_add( L_shl( Msub_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_re[k] ), pFreq_buf_im[k], pFreq_filt_im[k] ), 2 ), tmp_out_re[k] ); // Qx
- tmp_out_im[k] = L_add( L_shl( Madd_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_im[k] ), pFreq_buf_im[k], pFreq_filt_re[k] ), 2 ), tmp_out_im[k] ); // Qx
+ tmp_out_re[k] = L_add( Msub_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_re[k] ), pFreq_buf_im[k], pFreq_filt_im[k] ), tmp_out_re[k] ); // Qx - 2
+ tmp_out_im[k] = L_add( Madd_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_im[k] ), pFreq_buf_im[k], pFreq_filt_re[k] ), tmp_out_im[k] ); // Qx - 2
move32();
move32();
}
@@ -1879,8 +1879,8 @@ static ivas_error ivas_rend_crendConvolver(
pFreq_filt_im = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_im_fx[j][offset]; // Q31
FOR( k = 0; k < pCrend->hHrtfCrend->pIndex_frequency_max_diffuse[j][m]; k++ )
{
- tmp_out_re[k] = L_add( Msub_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_re[k] ), pFreq_buf_im[k], pFreq_filt_im[k] ), tmp_out_re[k] ); // Qx
- tmp_out_im[k] = L_add( Madd_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_im[k] ), pFreq_buf_im[k], pFreq_filt_re[k] ), tmp_out_im[k] ); // Qx
+ tmp_out_re[k] = L_add( L_shr( Msub_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_re[k] ), pFreq_buf_im[k], pFreq_filt_im[k] ), 2 ), tmp_out_re[k] ); // Qx - 2
+ tmp_out_im[k] = L_add( L_shr( Madd_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_im[k] ), pFreq_buf_im[k], pFreq_filt_re[k] ), 2 ), tmp_out_im[k] ); // Qx - 2
move32();
move32();
}
@@ -1888,7 +1888,7 @@ static ivas_error ivas_rend_crendConvolver(
}
ivas_imdft_fx( tmp_out_re, tmp_out_im, pOut, subframe_length );
-
+ scale_sig32( pOut, shl( subframe_length, 1 ), 2 );
#ifdef DEBUGGING
dbgwrite_txt( (const float *) pOut, subframe_length << 1, "Fixed_imdft_out.txt", NULL );
#endif
diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c
index d90728d588cdf5dd0173a0666a69ac7b9aa444de..71ecb5106be77e0f5381dd721bc665b3790c51d9 100644
--- a/lib_rend/ivas_dirac_dec_binaural_functions.c
+++ b/lib_rend/ivas_dirac_dec_binaural_functions.c
@@ -130,7 +130,20 @@ static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx /*q_Ein*/, Word32 Ein2_f
static void matrixMul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out );
-static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out );
+static void matrixTransp2Mul_fx(
+ Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/,
+ Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/,
+ Word16 *q_A,
+ Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/,
+ Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/,
+ Word16 *q_B,
+#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx
+ int Ascale,
+ int Bscale,
+#endif
+ Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/,
+ Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/,
+ Word16 *q_out );
/*-------------------------------------------------------------------------
* ivas_dirac_dec_init_binaural_data()
@@ -1970,7 +1983,13 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
/* Make matrix multiplication M*Cx*M' to determine resulting covariance matrix of processing input with M */
matrixMul_fx( Mre_fx, Mim_fx, &q_M, CxRe_fx, CxIm_fx, &q_Cx, tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp );
- matrixTransp2Mul_fx( tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp, Mre_fx, Mim_fx, &q_M, resultMtxRe_fx, resultMtxIm_fx, &q_res );
+ matrixTransp2Mul_fx(
+ tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp, Mre_fx, Mim_fx, &q_M,
+#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx
+ 1 /*int Ascale*/,
+ 0 /*int Bscale*/,
+#endif
+ resultMtxRe_fx, resultMtxIm_fx, &q_res );
/* When below the frequency limit where decorrelation is applied, we inject the decorrelated
* residual (or missing) signal component. The procedure is active when there are not enough independent
@@ -3791,6 +3810,10 @@ static void matrixTransp2Mul_fx(
Word32 Bre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/
Word32 Bim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/
Word16 *q_B,
+#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx
+ int Ascale,
+ int Bscale,
+#endif
Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/
Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/
Word16 *q_out )
@@ -3804,16 +3827,27 @@ static void matrixTransp2Mul_fx(
#endif
#endif
- min_q_shift = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 );
- scale_sig32( Are_fx[0], size, min_q_shift );
- scale_sig32( Aim_fx[0], size, min_q_shift );
- *q_A = add( *q_A, min_q_shift );
- move16();
- min_q_shift = sub( s_min( L_norm_arr( Bre_fx[0], size ), L_norm_arr( Bim_fx[0], size ) ), 1 );
- scale_sig32( Bre_fx[0], size, min_q_shift );
- scale_sig32( Bim_fx[0], size, min_q_shift );
- *q_B = add( *q_B, min_q_shift );
- move16();
+#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx
+ IF( Ascale == 1 )
+#endif
+ {
+ min_q_shift = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 );
+ scale_sig32( Are_fx[0], size, min_q_shift );
+ scale_sig32( Aim_fx[0], size, min_q_shift );
+ *q_A = add( *q_A, min_q_shift );
+ move16();
+ }
+
+#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx
+ IF( Bscale == 1 )
+#endif
+ {
+ min_q_shift = sub( s_min( L_norm_arr( Bre_fx[0], size ), L_norm_arr( Bim_fx[0], size ) ), 1 );
+ scale_sig32( Bre_fx[0], size, min_q_shift );
+ scale_sig32( Bim_fx[0], size, min_q_shift );
+ *q_B = add( *q_B, min_q_shift );
+ move16();
+ }
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
{
@@ -4094,6 +4128,7 @@ static void chol2x2_fx(
// 4611686 = Q62
IF( outRe[1][1] == 0 )
{
+#if !defined( FIX_1072_REDUCE_DIVS )
outRe[0][1] = BASOP_Util_Divide3232_Scale_cadence( c_re, 4611686, &exp );
move32();
q_re2 = add( sub( 31, exp ), sub( q_c, 62 ) );
@@ -4101,9 +4136,25 @@ static void chol2x2_fx(
outIm[0][1] = BASOP_Util_Divide3232_Scale_cadence( -c_im, 4611686, &exp );
move32();
q_im = add( sub( 31, exp ), sub( q_c, 62 ) );
+
+#else
+ // outRe[0][1] = BASOP_Util_Divide3232_Scale_cadence( c_re, 4611686, &exp );
+ Word32 tmp1 = 1953125005; /* 1/4611686 Q62 */
+ exp = 9;
+
+ outRe[0][1] = Mpy_32_32( tmp1, c_re );
+ move32();
+ q_re2 = add( sub( 31, exp ), sub( q_c, 62 ) );
+
+ // outIm[0][1] = BASOP_Util_Divide3232_Scale_cadence( -c_im, 4611686, &exp );
+ outIm[0][1] = Mpy_32_32( tmp1, -c_im );
+ move32();
+ q_im = add( sub( 31, exp ), sub( q_c, 62 ) );
+#endif
}
ELSE
{
+#if !defined( FIX_1072_REDUCE_DIVS )
outRe[0][1] = BASOP_Util_Divide3232_Scale_cadence( c_re, outRe[1][1], &exp );
move32();
q_re2 = add( sub( 31, exp ), sub( q_c, q_re1 ) );
@@ -4111,6 +4162,20 @@ static void chol2x2_fx(
outIm[0][1] = BASOP_Util_Divide3232_Scale_cadence( -c_im, outRe[1][1], &exp );
move32();
q_im = add( sub( 31, exp ), sub( q_c, q_re1 ) );
+#else
+ {
+ // outRe[0][1] = BASOP_Util_Divide3232_Scale_cadence( c_re, outRe[1][1], &exp );
+ Word32 tmp1 = BASOP_Util_Divide3232_Scale_cadence( 0x7FFFFFFF, outRe[1][1], &exp );
+ outRe[0][1] = Mpy_32_32( tmp1, c_re );
+ move32();
+ q_re2 = add( sub( 31, exp ), sub( q_c, q_re1 ) );
+
+ // outIm[0][1] = BASOP_Util_Divide3232_Scale_cadence( -c_im, outRe[1][1], &exp );
+ outIm[0][1] = Mpy_32_32( tmp1, -c_im );
+ move32();
+ q_im = add( sub( 31, exp ), sub( q_c, q_re1 ) );
+ }
+#endif
}
if ( outRe[0][1] == 0 )
{
@@ -4358,7 +4423,7 @@ static void formulate2x2MixingMatrix_fx(
Ghat_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp
}
#else
- BASOP_Util_Divide3232_Scale_cadence( E_out1, 4611686, &exp ); // 4611686 = Q62
+ temp = BASOP_Util_Divide3232_Scale_cadence( E_out1, 4611686, &exp ); // 4611686 = Q62
exp = sub( exp, sub( q_eout, 62 ) );
#endif
}
@@ -4395,7 +4460,7 @@ static void formulate2x2MixingMatrix_fx(
Ghat_fx[1] = Sqrt32( temp, &exp1 ); // Q = 31 - exp1
}
#else
- BASOP_Util_Divide3232_Scale_cadence( E_out2, 4611686, &exp1 ); // 4611686 = Q62
+ temp = BASOP_Util_Divide3232_Scale_cadence( E_out2, 4611686, &exp1 ); // 4611686 = Q62
exp1 = sub( exp1, sub( q_eout, 62 ) );
#endif
}
@@ -4584,7 +4649,12 @@ static void formulate2x2MixingMatrix_fx(
}
}
- matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */
+ matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U,
+#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx
+ 1 /*int Ascale*/,
+ 0 /*int Bscale*/,
+#endif
+ Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */
/* These are the final formulas of the JAES publication M = Ky P Kx^(-1) */
#if ( BINAURAL_CHANNELS != 2 )
@@ -4733,8 +4803,12 @@ static void formulate2x2MixingMatrix_fx(
matrixMul_fx( KyRe_fx, KyIm_fx, &q_ky, Pre_fx, Pim_fx, &q_P, tmpRe_fx, tmpIm_fx, &q_temp );
- matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux, Mre_fx, Mim_fx, q_M );
-
+ matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux,
+#ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx
+ 1 /*int Ascale*/,
+ 0 /*int Bscale*/,
+#endif
+ Mre_fx, Mim_fx, q_M );
return;
}
diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec.c
index c50d690c5b80f4812770e4aab2d6bbb26aabc62f..1788536e4ba8ad65fbf2ff9fa777eaff7972aef4 100644
--- a/lib_rend/ivas_dirac_decorr_dec.c
+++ b/lib_rend/ivas_dirac_decorr_dec.c
@@ -409,7 +409,7 @@ void ivas_dirac_dec_decorr_process_fx(
HANDLE_DIRAC_DECORR_STATE h_freq_domain_decorr_ap_state )
{
- Word16 ch_idx, k, l, idx_in_out, max_band_decorr;
+ Word16 ch_idx, k, l, max_band_decorr;
Word16 split_bands_idx, band_idx, decorr_buffer_len, time_idx;
Word16 offset, idx_filter, incr_aux;
Word16 k_1, k_2, num_bands, filter_length, pre_delay, decorr_buffer_step;
@@ -506,22 +506,24 @@ void ivas_dirac_dec_decorr_process_fx(
set32_fx( onset_filter_fx, ONE_IN_Q31, imult1616( num_protos_diff, num_freq_bands ) );
Word16 q_temp = s_min( q_onset_dec, q_aux_buffer );
+ Word16 shift_q = sub( q_onset_dec, q_temp );
- IF( NE_16( q_temp, q_onset_dec ) )
+ IF( shift_q != 0 )
{
- FOR( Word16 i = 0; i < imult1616( num_protos_diff, max_band_decorr_temp ); i++ )
+ FOR( Word16 i = 0; i < num_protos_diff * max_band_decorr_temp; i++ )
{
- h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx[i] = L_shr( h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx[i], sub( q_onset_dec, q_temp ) ); // q_temp
- h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx[i] = L_shr( h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx[i], sub( q_onset_dec, q_temp ) ); // q_temp
+ h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx[i] = L_shr( h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx[i], shift_q ); // q_temp
+ h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx[i] = L_shr( h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx[i], shift_q ); // q_temp
move32();
move32();
}
}
- IF( NE_16( q_temp, q_aux_buffer ) )
+ shift_q = sub( q_aux_buffer, q_temp );
+ IF( shift_q != 0 )
{
- FOR( Word16 i = 0; i < shl( imult1616( num_protos_diff, max_band_decorr_temp ), 1 ); i++ )
+ FOR( Word16 i = 0; i < 2 * num_protos_diff * max_band_decorr_temp; i++ )
{
- aux_buffer_fx[i] = L_shr( aux_buffer_fx[i], sub( q_aux_buffer, q_temp ) ); // q_temp
+ aux_buffer_fx[i] = L_shr( aux_buffer_fx[i], shift_q ); // q_temp
move32();
}
}
@@ -566,9 +568,9 @@ void ivas_dirac_dec_decorr_process_fx(
/* final phase rotation */
FOR( k = 0; k < max_band_decorr; k++ )
{
- *p_frame_dec_fx = L_sub( Mpy_32_16_1( ( *decorr_buffer_fx ), ( *phase_coeff_real_fx ) ), Mpy_32_16_1( ( *( decorr_buffer_fx + 1 ) ), ( *phase_coeff_imag_fx ) ) ); // sub( q_decorr_buf, 1 )
+ *p_frame_dec_fx = Msub_32_16( Mpy_32_16_1( *decorr_buffer_fx, ( *phase_coeff_real_fx ) ), *( decorr_buffer_fx + 1 ), ( *phase_coeff_imag_fx ) ); // sub( q_decorr_buf, 1 )
p_frame_dec_fx++;
- *p_frame_dec_fx = L_add( Mpy_32_16_1( ( *decorr_buffer_fx ), ( *phase_coeff_imag_fx ) ), Mpy_32_16_1( ( *( decorr_buffer_fx + 1 ) ), ( *phase_coeff_real_fx ) ) ); // sub( q_decorr_buf, 1 )
+ *p_frame_dec_fx = Madd_32_16( Mpy_32_16_1( *decorr_buffer_fx, ( *phase_coeff_imag_fx ) ), ( *( decorr_buffer_fx + 1 ) ), ( *phase_coeff_real_fx ) ); // sub( q_decorr_buf, 1 )
p_frame_dec_fx++;
phase_coeff_imag_fx++;
phase_coeff_real_fx++;
@@ -620,8 +622,8 @@ void ivas_dirac_dec_decorr_process_fx(
#endif
q_shift = getScaleFactor32( aux_buffer_fx, imult1616( imult1616( 2, num_protos_dir ), max_band_decorr_temp ) );
-
- FOR( Word16 j = 0; j < shl( imult1616( num_protos_dir, max_band_decorr_temp ), 1 ); j++ )
+ Word16 buf_len = shl( imult1616( num_protos_dir, max_band_decorr_temp ), 1 );
+ FOR( Word16 j = 0; j < buf_len; j++ )
{
aux_buffer_fx[j] = L_shl( aux_buffer_fx[j], q_shift ); // add( q_aux_buffer, q_shift )
move32();
@@ -674,8 +676,9 @@ void ivas_dirac_dec_decorr_process_fx(
filter_coeff_num_real_fx = &h_freq_domain_decorr_ap_params->filter_coeff_num_real_fx[idx_filter]; // Q12
filter_coeff_den_real_fx = &h_freq_domain_decorr_ap_params->filter_coeff_den_real_fx[idx_filter]; // Q12
decorr_buffer_start_ptr_fx = &h_freq_domain_decorr_ap_state->decorr_buffer_fx[2 * ( ch_idx * max_band_decorr + band_idx )];
- input_real_fx = aux_buffer_fx[shl( add( imult1616( proto_index_dir[ch_idx], max_band_decorr ), band_idx ), 1 )]; // q_aux
- input_imag_fx = aux_buffer_fx[add( shl( add( imult1616( proto_index_dir[ch_idx], max_band_decorr ), band_idx ), 1 ), 1 )]; // q_aux
+ Word16 idx = shl( add( imult1616( proto_index_dir[ch_idx], max_band_decorr ), band_idx ), 1 );
+ input_real_fx = aux_buffer_fx[idx]; // q_aux
+ input_imag_fx = aux_buffer_fx[idx + 1]; // q_aux
/* MA part of filter impulse response */
FOR( l = 0; l < filter_length; l++ )
@@ -766,14 +769,15 @@ void ivas_dirac_dec_decorr_process_fx(
#ifdef MSAN_FIX
q_shift = Q31;
move16();
+ offset = shl( max_band_decorr, 1 );
FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx )
{
q_shift = s_min( q_shift,
- L_norm_arr( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ) ) );
+ L_norm_arr( &frame_dec_fx[2 * ch_idx * num_freq_bands], offset ) );
}
FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx )
{
- Scale_sig32( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ), q_shift );
+ scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], offset, q_shift );
}
#else
q_shift = L_norm_arr( frame_dec_fx, ( 2 * max_band_decorr + incr_aux ) * num_channels );
@@ -784,13 +788,14 @@ void ivas_dirac_dec_decorr_process_fx(
IF( h_freq_domain_decorr_ap_params->use_ducker )
{
+ Word16 len1 = shl( imult1616( max_band_decorr, num_protos_dir ), 1 );
/* compute direct power w/o onsets for the energy ratio, signal is still in the aux buffer */
- v_mult_fixed( aux_buffer_fx, aux_buffer_fx, aux_buffer_fx, shl( imult1616( max_band_decorr, num_protos_dir ), 1 ) ); // 2 *q_aux -31
+ v_mult_fixed( aux_buffer_fx, aux_buffer_fx, aux_buffer_fx, len1 ); // 2 *q_aux -31
- q_aux_buffer = sub( imult1616( 2, q_aux_buffer ), 31 );
+ q_aux_buffer = sub( shl( q_aux_buffer, 1 ), 31 );
// if this scaling is eliminated overflow is happening fot v_add_inc_fix
- q_shift = sub( L_norm_arr( aux_buffer_fx, shl( imult1616( num_protos_dir, max_band_decorr ), 1 ) ), find_guarded_bits_fx( 2 ) );
+ q_shift = sub( L_norm_arr( aux_buffer_fx, len1 ), 1 /*find_guarded_bits_fx( 2 )*/ );
Scale_sig32( aux_buffer_fx, shl( imult1616( num_protos_dir, max_band_decorr_temp ), 1 ), q_shift );
q_aux_buffer = add( q_aux_buffer, q_shift );
@@ -847,18 +852,18 @@ void ivas_dirac_dec_decorr_process_fx(
}
norm = W_norm( min64 );
#endif
-
- FOR( Word16 i = 0; i < shl( imult1616( num_channels, max_band_decorr ), 1 ); i++ )
+ norm = sub( norm, 1 /*find_guarded_bits_fx( 2 )*/ );
+ FOR( Word16 i = 0; i < 2 * num_channels * max_band_decorr; i++ )
{
- aux_buffer_fx[i] = W_extract_h( W_shl( aux_64[i], sub( norm, find_guarded_bits_fx( 2 ) ) ) );
+ aux_buffer_fx[i] = W_extract_h( W_shl( aux_64[i], norm ) );
move32();
}
- q_aux_buffer = add( imult1616( 2, q_frame_f ), sub( sub( norm, 1 ), 32 ) );
+ q_aux_buffer = add( shl( q_frame_f, 1 ), sub( norm, 32 ) );
FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx )
{
- v_add_inc_fx( &aux_buffer_fx[shl( imult1616( ch_idx, max_band_decorr ), 1 )], 2, &aux_buffer_fx[add( shl( imult1616( ch_idx, max_band_decorr ), 1 ), 1 )], 2, &aux_buffer_fx[imult1616( ch_idx, max_band_decorr )], 1, max_band_decorr );
+ v_add_inc_fx( &aux_buffer_fx[2 * ch_idx * max_band_decorr], 2, &aux_buffer_fx[2 * ch_idx * max_band_decorr + 1], 2, &aux_buffer_fx[ch_idx * max_band_decorr], 1, max_band_decorr );
}
/* smooth energies */
@@ -959,7 +964,7 @@ void ivas_dirac_dec_decorr_process_fx(
FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx )
{
q_shift = s_min( q_shift,
- sub( L_norm_arr( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ) ),
+ sub( L_norm_arr( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ) ),
Q2 ) );
}
FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx )
@@ -974,7 +979,7 @@ void ivas_dirac_dec_decorr_process_fx(
FOR( ch_idx = 0; ch_idx < num_channels; ch_idx++ )
{
- Word32 *frame_dec_fx_ptr = &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )];
+ Word32 *frame_dec_fx_ptr = &frame_dec_fx[2 * ch_idx * num_freq_bands];
Word16 cur_proto_index = imult1616( proto_index_dir[ch_idx], max_band_decorr );
Word16 cur_reverb_index = imult1616( ch_idx, max_band_decorr );
Word32 *reverb_energy_smooth_ptr = &h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx[cur_reverb_index]; // q_aux
@@ -1020,22 +1025,18 @@ void ivas_dirac_dec_decorr_process_fx(
e_duck_gain = add( e_duck_gain, sub( e_direct_energy_smooth, add( e_reverb_energy_smooth, 1 ) ) );
duck_gain = Sqrt16( duck_gain, &e_duck_gain );
- Word16 comp_flag = BASOP_Util_Cmp_Mant32Exp( duck_gain, e_duck_gain, 16384, 2 );
- IF( EQ_16( comp_flag, 1 ) )
- {
- duck_gain = 16384; // 2inQ13
- move16();
- }
- ELSE
+ /* if ( duck_gain > 2.0f )
{
- duck_gain = shl( duck_gain, sub( e_duck_gain, 2 ) ); // Q13
- }
+ duck_gain = 2.0f;
+ } */
+ duck_gain = shl_sat( duck_gain, sub( e_duck_gain, 1 ) ); // Q14
+
#ifndef FIX_1110_OPTIM_DIRAC_DECORR_PROC
frame_dec_fx_ptr[2 * band_idx] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[2 * band_idx], duck_gain ), 2 ); // q_frame_dec
frame_dec_fx_ptr[add( shl( band_idx, 1 ), 1 )] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[add( shl( band_idx, 1 ), 1 )], duck_gain ), 2 ); // q_frame_dec
#else
- frame_dec_fx_ptr[2 * band_idx] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[2 * band_idx], duck_gain ), 2 ); // q_frame_dec
- frame_dec_fx_ptr[2 * band_idx + 1] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[2 * band_idx + 1], duck_gain ), 2 ); // q_frame_dec
+ frame_dec_fx_ptr[2 * band_idx] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[2 * band_idx], duck_gain ), 1 ); // q_frame_dec
+ frame_dec_fx_ptr[2 * band_idx + 1] = L_shl( Mpy_32_16_1( frame_dec_fx_ptr[2 * band_idx + 1], duck_gain ), 1 ); // q_frame_dec
#endif
move32();
move32();
@@ -1055,7 +1056,7 @@ void ivas_dirac_dec_decorr_process_fx(
Word16 sf = MAX_16;
FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx )
{
- sf = s_min( sf, getScaleFactor32( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ) ) );
+ sf = s_min( sf, getScaleFactor32( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ) ) );
}
sf = s_min( sub( sf, 1 ), q_shift );
q_if_local = sub( q_shift, sf );
@@ -1065,7 +1066,7 @@ void ivas_dirac_dec_decorr_process_fx(
#ifdef MSAN_FIX
FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx )
{
- scale_sig32( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ), q_shift );
+ scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ), q_shift );
}
#else
Scale_sig32( frame_dec_fx, ( 2 * max_band_decorr + incr_aux ) * num_channels, q_shift ); // scaling it to input q
@@ -1078,7 +1079,7 @@ void ivas_dirac_dec_decorr_process_fx(
#ifdef MSAN_FIX
FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx )
{
- scale_sig32( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ), q_shift );
+ scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ), q_shift );
}
#else
Scale_sig32( frame_dec_fx, ( 2 * max_band_decorr + incr_aux ) * num_channels, q_shift ); // scaling it to input q
@@ -1098,24 +1099,22 @@ void ivas_dirac_dec_decorr_process_fx(
FOR( k = 0; k < max_band_decorr; ++k )
{
- aux_buffer_fx[2 * k] = Mpy_32_32( L_shr_r( input_frame_fx[add( shl( offset, 1 ), shl( k, 1 ) )], q_if_local ), L_sub( ONE_IN_Q31, onset_filter_fx[add( offset, k )] ) );
- aux_buffer_fx[add( shl( k, 1 ), 1 )] = Mpy_32_32( L_shr_r( input_frame_fx[add( add( shl( offset, 1 ), shl( k, 1 ) ), 1 )], q_if_local ), L_sub( ONE_IN_Q31, onset_filter_fx[add( offset, k )] ) ); // q_frame_f
+ aux_buffer_fx[2 * k] = Mpy_32_32( L_shr_r( input_frame_fx[2 * ( offset + k )], q_if_local ), L_sub( ONE_IN_Q31, onset_filter_fx[offset + k] ) );
+ aux_buffer_fx[add( shl( k, 1 ), 1 )] = Mpy_32_32( L_shr_r( input_frame_fx[2 * ( offset + k ) + 1], q_if_local ), L_sub( ONE_IN_Q31, onset_filter_fx[offset + k] ) ); // q_frame_f
move32();
move32();
}
- v_add_fx( &frame_dec_fx[imult1616( ch_idx, shl( num_freq_bands, 1 ) )], aux_buffer_fx, &frame_dec_fx[imult1616( ch_idx, shl( num_freq_bands, 1 ) )], shl( max_band_decorr, 1 ) );
+ v_add_fx( &frame_dec_fx[2 * ch_idx * num_freq_bands], aux_buffer_fx, &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ) );
}
}
/* avoid decorrelation above maximum frequency -> set to zero the remaining frequencies*/
+ Word16 val = shl( sub( num_freq_bands, h_freq_domain_decorr_ap_params->max_band_decorr ), 1 );
FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx )
{
- /* calc output indices */
- idx_in_out = shl( ( add( imult1616( ch_idx, num_freq_bands ), h_freq_domain_decorr_ap_params->max_band_decorr ) ), 1 );
-
/* copy to output signal */
- set32_fx( &frame_dec_fx[idx_in_out], 0, shl( sub( num_freq_bands, h_freq_domain_decorr_ap_params->max_band_decorr ), 1 ) );
+ set32_fx( &frame_dec_fx[2 * ( ch_idx * num_freq_bands + h_freq_domain_decorr_ap_params->max_band_decorr )], 0, val );
}
*q_frame_dec = q_frame_f;
move16();
diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c
index ea507b4c7a49c354ab800f0bced2f10a33cacb0b..cafd709664ea23abebc12fcdbc591fdeaae9fbc0 100644
--- a/lib_rend/ivas_dirac_rend.c
+++ b/lib_rend/ivas_dirac_rend.c
@@ -4014,20 +4014,6 @@ static void ivas_masa_ext_dirac_render_sf_fx(
move16();
}
- /*Buffer Scaling*/
- FOR( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ )
- {
- FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ )
- {
- scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx],
- hSpatParamRendCom->num_freq_bands, sub( 11, q_cldfb ) ); // q11
- scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx],
- hSpatParamRendCom->num_freq_bands, sub( 11, q_cldfb ) ); // q11
- }
- }
- q_cldfb = 11;
- move16();
-
Word16 reference_power_temp_q = getScaleFactor32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len );
scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, reference_power_temp_q ); /*DirAC_mem.reference_power_q + reference_power_temp_q*/
DirAC_mem.reference_power_q = add( DirAC_mem.reference_power_q, reference_power_temp_q );
diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c
index f230cca25081cd3b3589ae76547b37051bffab7b..86eea321bc28387a7d23287cbd18943db2a10cfd 100644
--- a/lib_rend/lib_rend.c
+++ b/lib_rend/lib_rend.c
@@ -4564,40 +4564,58 @@ static void renderBufferChannelLerp_fx(
{
i = 0;
Word32 tmp = Q31_BY_SUB_FRAME_240;
+ Word32 tmp1 = 239; /* L_SUBFRAME_48k - 1 */
+ move32();
move32();
move32();
SWITCH( outAudio.config.numSamplesPerChannel )
{
case NUM_SAMPLES_960:
tmp = Q31_BY_NUM_SAMPLES_960;
+ tmp1 = 959; /* NUM_SAMPLES_960 - 1 */
+ move32();
move32();
BREAK;
case NUM_SAMPLES_720:
tmp = Q31_BY_NUM_SAMPLES_720;
+ tmp1 = 719; /* NUM_SAMPLES_720 - 1 */
+ move32();
move32();
BREAK;
case NUM_SAMPLES_320:
tmp = Q31_BY_NUM_SAMPLES_320;
+ tmp1 = 319; /* NUM_SAMPLES_320 - 1 */
+ move32();
move32();
BREAK;
case NUM_SAMPLES_160:
tmp = Q31_BY_NUM_SAMPLES_160;
+ tmp1 = 159; /* NUM_SAMPLES_160 - 1 */
+ move32();
move32();
BREAK;
case L_SUBFRAME_48k:
tmp = Q31_BY_SUB_FRAME_240;
+ tmp1 = 239; /* L_SUBFRAME_48k - 1 */
+ move32();
move32();
BREAK;
case L_SUBFRAME_32k:
tmp = Q31_BY_SUB_FRAME_180;
+ tmp1 = 179; /* L_SUBFRAME_32k - 1 */
+ move32();
move32();
BREAK;
case L_SUBFRAME_16k:
tmp = Q31_BY_SUB_FRAME_80;
+ tmp1 = 79; /* L_SUBFRAME_16k - 1 */
+ move32();
move32();
BREAK;
case L_SUBFRAME_8k:
tmp = Q31_BY_SUB_FRAME_40;
+ tmp1 = 39; /* L_SUBFRAME_8k - 1 */
+ move32();
move32();
BREAK;
default:
@@ -4606,7 +4624,15 @@ static void renderBufferChannelLerp_fx(
/* Otherwise use weighted average between previous and current gain */
DO
{
- fadeIn = UL_Mpy_32_32( i, tmp );
+ IF( EQ_32( i, tmp1 ) )
+ {
+ fadeIn = ONE_IN_Q31;
+ move32();
+ }
+ ELSE
+ {
+ fadeIn = UL_Mpy_32_32( i, tmp );
+ }
fadeOut = L_sub( ONE_IN_Q31, fadeIn );
*outSmpl = L_add( Mpy_32_32( L_add( Mpy_32_32( fadeIn, currentGain ), Mpy_32_32( fadeOut, previousGain ) ), ( *inSmpl ) ), *outSmpl );