diff --git a/lib_com/options.h b/lib_com/options.h index 0cf958d03f0ea1e00be423e92f82dd91da395295..23d8ca6d11bc394705a166a31e4df8edf0eca8fb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,6 +79,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#define OPT_MCT_ENC_V2_BE #define OPT_MCH_DEC_V1_NBE #define OPT_MCT_ENC_48KB_NBE #define OPT_MCH_DEC_V1_BE diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c index 32d18d1feb543401666d751fb554240dce4e8e6f..91d0ee30a04a5f639a529a20a93d77453acd8e49 100644 --- a/lib_com/residu_fx.c +++ b/lib_com/residu_fx.c @@ -156,7 +156,7 @@ void Residu3_fx( move16(); #endif q = add( norm_s( a[0] ), 1 ); - IF( shift != 0 ) + if ( shift != 0 ) { q = add( q, shift ); } diff --git a/lib_com/tools.c b/lib_com/tools.c index 3cf11ea92167bbbae4f4f1599aa2c620d8b29e3f..0087920cd15e1ee1df384bf0d31665788c61d36d 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -688,7 +688,11 @@ Word32 dotp_fixed_o( move16(); test(); test(); +#ifdef OPT_MCT_ENC_V2_BE + FOR( ; ( suma > MAX_32 ) || ( suma < MIN_32 ) || ( *res_q > 31 ); ) +#else WHILE( GT_64( suma, MAX_32 ) || LT_64( suma, MIN_32 ) || GT_16( *res_q, 31 ) ) +#endif { suma = W_shr( suma, 1 ); *res_q = sub( *res_q, 1 ); @@ -718,7 +722,11 @@ Word32 dotp_fixed_32( move16(); test(); test(); +#ifdef OPT_MCT_ENC_V2_BE + FOR( ; ( suma > MAX_32 ) || ( suma < MIN_32 ) || ( *res_q > 31 ); ) +#else WHILE( GT_64( suma, MAX_32 ) || LT_64( suma, MIN_32 ) || GT_16( *res_q, 31 ) ) +#endif { suma = W_shr( suma, 1 ); *res_q = sub( *res_q, 1 ); diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index fe1ba10c10c84c6c39d79cab1b15c20ecdf26e40..7da9fa6cfa2608c3c955f520764f18ce653a2ea5 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -137,7 +137,7 @@ static Word16 IGF_getCrest_new_fx( move16(); x_eff = L_add( x_eff, L_mult0( x, x ) ); - IF( GT_16( x, x_max ) ) + if ( GT_16( x, x_max ) ) { x_max = x; move16(); diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index 2f1b7d6c8d6a37248247971dece778020c06e8e5..f7735e8df900b766f6d6043bd53e9b5591397c00 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -882,7 +882,7 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res move32(); en_fx[q] = Mpy_32_16_1( L_add( L_shl( e_ener, Q25 ), en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25) move32(); - i = add( i, 4 ); + i += 4; } i = 0; move16(); @@ -901,7 +901,7 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res move32(); en_fx[q] = Mpy_32_16_1( L_add( L_shl( e_ener, Q25 ), en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25) move32(); - i = add( i, 4 ); + i += 4; } /* SQ scale: 4 bits / 6 dB per quadruple */ @@ -911,6 +911,9 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res offset_fx = fac_fx; /* Q25 */ move32(); +#ifdef OPT_MCT_ENC_V2_BE + Word64 target_64_fx = W_shl( target_fx, 7 ); // Q25 +#endif /* find offset (0 to 128 dB with step of 0.125dB) */ FOR( iter = 0; iter < 10; iter++ ) { @@ -923,6 +926,20 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res { tmp_32 = L_sub( en_fx[i], offset_fx ); /* Q25 */ +#ifdef OPT_MCT_ENC_V2_BE + /* avoid SV with 1 bin of amp < 0.5f */ + if ( GT_32( tmp_32, 10066329 /*0.3 Q25*/ ) ) + { + W_tmp = W_add( W_tmp, tmp_32 ); /* Q25 */ + } + /* if ener is above target -> break and increase offset */ + IF( GT_64( W_tmp, target_64_fx ) ) + { + offset_fx = L_add( offset_fx, fac_fx ); /* Q25 */ + BREAK; + } +#else + /* avoid SV with 1 bin of amp < 0.5f */ IF( GT_32( tmp_32, 10066329 /*0.3 Q25*/ ) ) { @@ -935,6 +952,7 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res BREAK; } } +#endif } }