diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index c1289b8a3ffc5c5b7384b58330adb7dcf3342564..2f9c567c101b0d086a80f829fffd21a3b36c501c 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1318,13 +1318,10 @@ Word16 ApplyFdCng_ivas_fx( e_shift = sub( s, q_norm ); } } - FOR( ; k < hFdCngCom->npart; k++ ) + FOR( ; j < FFTCLDFBLEN; j++ ) { - FOR( ; j <= hFdCngCom->part[k]; j++ ) - { - cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], sub( s, e_shift ) ); /*Q: s*/ - move32(); - } + cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], sub( s, e_shift ) ); /*Q: s*/ + move32(); } *cngNoiseLevel_exp = add( add( hFdCngDec->bandNoiseShape_exp, s2 ), e_shift ); @@ -1685,14 +1682,13 @@ Word16 ApplyFdCng_ivas_fx( } /* adapt scaling for rest of the buffer */ s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) ); - FOR( ; k < hFdCngCom->npart; k++ ) + + FOR( ; j < FFTCLDFBLEN; j++ ) { - FOR( ; j <= hFdCngCom->part[k]; j++ ) - { - cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/ - move32(); - } + cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/ + move32(); } + *cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 ); move16(); } @@ -1759,15 +1755,15 @@ Word16 ApplyFdCng_ivas_fx( } /* adapt scaling for rest of the buffer */ s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) ); - FOR( ; k < hFdCngCom->npart; k++ ) + + FOR( ; j < FFTCLDFBLEN; j++ ) { - FOR( ; j <= hFdCngCom->part[k]; j++ ) - { - /* NOTE: saturation is added here as part of issue 1218 fix. after rescaling the fdcng noise estimation buffers, due to slight precision loss, values may slightly overflow */ - cngNoiseLevel[j] = L_shl_sat( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/ - move32(); - } + /* NOTE: saturation is added here as part of issue 1218 fix. after rescaling the fdcng noise estimation buffers, due to slight precision loss, values may slightly overflow */ + cngNoiseLevel[j] = L_shl_sat( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/ + move32(); } + + *cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 ); move16(); }