Commit af4daa02 authored by Manuel Jander's avatar Manuel Jander
Browse files

Rescale st->buf_speech_enc in case of IVAS_CPE_TD the same as for IVAS_CPE_DFT...

Rescale st->buf_speech_enc in case of IVAS_CPE_TD the same as for IVAS_CPE_DFT case to avoid saturation. Remove st->q_mem_decim16k_fx from Q_new calculation in case resampling was already done and its consideration does not apply anymore.
parent 2cb7815d
Loading
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1271,7 +1271,19 @@ void ivas_compute_core_buffers_fx(
            IF( EQ_16( st->L_frame, L_FRAME16k ) )
            {
#ifdef NONBE_FIX_ISSUE_2206
#ifdef NONBE_FIX_ISSUE_2569
                Word16 buf_speech_enc_q;

                buf_speech_enc_q = s_min( sub( Q15, st->exp_buf_speech_enc ), Q_old_inp_16k );
                Copy_Scale_sig_nosat( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ), sub( buf_speech_enc_q, Q_old_inp_16k ) );
                // L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k
                scale_sig( st->buf_speech_enc, sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), sub( buf_speech_enc_q, sub( Q15, st->exp_buf_speech_enc ) ) );
                scale_sig( st->buf_speech_enc + L_FRAME16k + L_FRAME16k, L_PAST_MAX_32k + L_NEXT_MAX_32k, sub( buf_speech_enc_q, sub( Q15, st->exp_buf_speech_enc ) ) );
                st->exp_buf_speech_enc = sub( Q15, buf_speech_enc_q );
                move16();
#else
                Copy_Scale_sig_nosat( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ), sub( sub( Q15, st->exp_buf_speech_enc ), Q_old_inp_16k ) ); /* Q_new - 1 */
#endif
#else
                Copy( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ) ); /* Q_new - 1 */
#endif
@@ -1320,8 +1332,10 @@ void ivas_compute_core_buffers_fx(
        shift = s_min( shift, norm_arr( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ) ) );
        shift = add( shift, Q_old_inp_16k );

#ifndef NONBE_FIX_ISSUE_2569
        /* Avoid saturation of resampling/delay decimation buffer. */
        shift = s_min( shift, add( st->q_mem_decim16k_fx, 1 ) );
#endif

        IF( st->hLPDmem != NULL )
        {