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/prot.h b/lib_com/prot.h
index 9985ca978d25841413a23beec53528ddca5ac455..a2a2cdac38c69592886fa331075608781b1ef7d3 100644
--- a/lib_com/prot.h
+++ b/lib_com/prot.h
@@ -8161,7 +8161,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 572241d899ab5c090486154daf21593679859116..daf2c80d5b546d3cbccfde7f9891cac059635b7d 100644
--- a/lib_com/prot_fx.h
+++ b/lib_com/prot_fx.h
@@ -10887,7 +10887,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 */
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/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 0c7badb13ec70828a52e3340408e32c325b7a871..6cccea43be08e760748c418914036e8efb0fe110 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 )
{
@@ -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 );
@@ -735,7 +735,6 @@ 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*/
@@ -749,6 +748,7 @@ static void IGF_CalculateEnvelope_ivas_fx(
move16();
}
#else
+
/*y = 20 * (int16_t) log10f( max( 1e-018f, pPowerSpectrum[sb] ) );*/
IF( LT_32( pPowerSpectrum_fx[sb], 1 ) )
{
@@ -877,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();
@@ -941,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
@@ -1069,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++ )
{
@@ -1097,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 ) );
@@ -1163,6 +1163,7 @@ static void IGF_CalculateStereoEnvelope_fx(
tileSrcSpec_e = pPowerSpectrum_e;
}
move32();
+ move16();
strt_cpy = add( strt_cpy, 1 );
}
@@ -1234,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();
}
@@ -1251,10 +1252,10 @@ 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();
}
@@ -1274,14 +1275,12 @@ static void IGF_CalculateStereoEnvelope_fx(
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]*/
#endif
- hPrivateData->sfb_sb_e[sfb] = 2;
- hPrivateData->sfb_tb_e[sfb] = 2;
- move16();
- move16();
move16();
move16();
move16();
move16();
+ hPrivateData->sfb_sb_e[sfb] = 2;
+ hPrivateData->sfb_tb_e[sfb] = 2;
move16();
move16();
@@ -1312,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
{
@@ -1342,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 );
@@ -1381,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 );
@@ -1525,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 );
}
@@ -1588,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 );
}
@@ -1710,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];
@@ -1843,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*/
}
@@ -1875,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 */
{
@@ -1982,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 */
{
@@ -2029,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 ) ) &&
@@ -2078,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;
@@ -2121,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;
@@ -2165,7 +2173,7 @@ static Word16 IGF_WriteWhiteningLevels(
move16();
tmp32 = 0;
move32();
-
+ test();
WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) )
{
test();
@@ -2188,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;
@@ -2205,7 +2214,7 @@ static Word16 IGF_WriteWhiteningLevels(
isSame = 1;
move16();
}
-
+ test();
WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) )
{
test();
@@ -2224,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 ) )
@@ -2240,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;
@@ -2312,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 );
@@ -2329,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;
-}
/*-------------------------------------------------------------------*
@@ -2534,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 */
)
{
@@ -2548,7 +2529,8 @@ void IGFEncResetTCX10BitCounter(
hPrivateData = &hIGFEnc->igfData;
hPrivateData->igfBitstreamBits = 0;
hIGFEnc->infoTotalBitsWritten = 0;
-
+ move16();
+ move16();
return;
}
@@ -2560,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;
@@ -2581,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;
@@ -2622,7 +2604,6 @@ void IGFEncApplyMono_ivas_fx(
Word16 common_pPowerSpectrum_exp = MIN16B;
move16();
- test();
IF( st->last_core == ACELP_CORE )
{
last_core_acelp = 1;
@@ -2656,7 +2637,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;
@@ -2740,7 +2720,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;
}
diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c
index 9e38d4d6cdefa19275cfebb90d2fd1825e568676..268166ba9342ba2c5e08737380e4c1b68de19405 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++ )
@@ -772,7 +781,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 +825,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 +860,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 +902,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 +948,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 +972,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 +1068,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 +1080,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 +1104,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 +1141,7 @@ static void IGF_WriteWhiteningLevels( /
move16();
tmp32 = 0;
move32();
-
+ test();
WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) )
{
test();
@@ -1149,7 +1164,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 +1174,7 @@ static void IGF_WriteWhiteningLevels( /
isSame = 1;
move16();
}
-
+ test();
WHILE( ( LT_16( p, nTiles ) ) && ( tmp32 == 0 ) )
{
test();
@@ -1177,7 +1192,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 +1202,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 +1278,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 +1389,7 @@ static void pack_bit_ivas_fx(
move16();
}
- IF( bit != 0 )
+ if ( bit != 0 )
{
**pt = (UWord8) s_or( **pt, *omask );
move16();
@@ -1422,6 +1438,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 +1485,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 +1493,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..edd887afd35fac785340ffbcd202937d47936639 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 );
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/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..1e2131b2936d388649faa22a95a58b4cca0fdbe8 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
@@ -2825,7 +2854,8 @@ void noise_est_ivas_fx(
*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 )) ; */
@@ -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/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;