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

Correct scale of hLPDmem->mem_w0 when copied from st->wspeech_enc[-1]. Add all...

Correct scale of hLPDmem->mem_w0 when copied from st->wspeech_enc[-1]. Add all hLPDmem members into Q_new calculation to avoid ACELP saturations.
parent d51c1ff8
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -953,6 +953,7 @@ ivas_error acelp_core_enc_fx(
     * Updates
     *-----------------------------------------------------------------*/

#ifndef NONBE_FIX_ISSUE_2518
    IF( st->element_mode > EVS_MONO )
    {
        if ( st->hBWE_TD != NULL )
@@ -963,6 +964,7 @@ ivas_error acelp_core_enc_fx(
        hLPDmem->q_lpd_old_exc = Q_new;
        move16();
    }
#endif

    updt_enc_fx( st, old_exc_fx, pitch_buf, Es_pred_fx, Aq, lsf_new_fx, lsp_new, old_bwe_exc_fx );

+16 −1
Original line number Diff line number Diff line
@@ -28,7 +28,11 @@ static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const
static void init_core_sig_ana_ivas_fx( Encoder_State *st );
static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate );
static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const Word32 last_total_brate );
#ifdef NONBE_FIX_ISSUE_2518
static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, const Word32 last_total_brate );
#else
static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const Word32 last_total_brate );
#endif

/*-----------------------------------------------------------------------*
 * init_coder_ace_plus_fx()
@@ -1084,8 +1088,11 @@ void init_coder_ace_plus_ivas_fx(
    init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr, last_total_brate );

    /* Initialize ACELP */

#ifdef NONBE_FIX_ISSUE_2518
    init_acelp_ivas_fx( st, L_frame_old, last_total_brate );
#else
    init_acelp_ivas_fx( st, L_frame_old, 0, last_total_brate );
#endif

    if ( st->ini_frame == 0 )
    {
@@ -1538,7 +1545,11 @@ static void init_core_sig_ana_ivas_fx( Encoder_State *st )
 *
 *
 *-----------------------------------------------------------------------*/
#ifdef NONBE_FIX_ISSUE_2518
static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, const Word32 last_total_brate )
#else
static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const Word32 last_total_brate )
#endif
{
    Word16 mem_syn_r_size_old;
    Word16 mem_syn_r_size_new;
@@ -1722,7 +1733,11 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh
                    Copy( hLPDmem->mem_syn2, tmp_buf + 1, M );
                    deemph_fx( tmp_buf + 1, st->preemph_fac, M, &tmp );
                    Residu3_fx( Ap, tmp_buf + M, &tmp, 1, 1 );
#ifdef NONBE_FIX_ISSUE_2518
                    hLPDmem->mem_w0 = sub_sat( shl_sat( st->wspeech_enc[-1], sub( hLPDmem->q_mem_syn, sub( Q15, st->exp_buf_wspeech_enc ) ) ), tmp );
#else
                    hLPDmem->mem_w0 = sub_sat( shr_sat( st->wspeech_enc[-1], shift ), tmp );
#endif
                    move16();
                }
            }
+1 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ void core_encode_update_cng_fx(
        p_A += ( M + 1 );
    }

    assert( st->element_mode == EVS_MONO );
    tmp = sub( st->wspeech_enc[-1], shl( hLPDmem->mem_w0, shift ) );
    E_UTIL_deemph2( negate( shift ), wsyn, st->preemph_fac, st->L_frame, &tmp );
    hLPDmem->mem_w0 = sub_sat( st->wspeech_enc[st->L_frame - 1], tmp );
+4 −0
Original line number Diff line number Diff line
@@ -436,11 +436,13 @@ ivas_error ivas_core_enc_fx(
#ifndef NONBE_FIX_ISSUE_2206
                    Scale_sig( old_inp_16k_fx[n], L_INP, sub( Q1, Q_new[n] ) ); // Q0
#endif
#ifndef NONBE_FIX_ISSUE_2518
                    IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
                    {
                        st->hTcxEnc->exp_buf_speech_ltp = st->exp_buf_speech_enc;
                        move16();
                    }
#endif
                }
                Word16 Q_spec_old[2], L_spec;
                Q_spec_old[0] = hCPE->hCoreCoder[0]->hTcxEnc->spectrum_long_e;
@@ -523,12 +525,14 @@ ivas_error ivas_core_enc_fx(
                    st = sts[i];
                    Scale_sig( old_inp_16k_fx[i], L_INP, sub( Q1, Q_new[i] ) ); // Q0

#ifndef NONBE_FIX_ISSUE_2518
                    test();
                    IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
                    {
                        st->hTcxEnc->exp_buf_speech_ltp = st->exp_buf_speech_enc;
                        move16();
                    }
#endif
                    shift = norm_arr( st->input_fx, input_frame );
#ifdef NONBE_FIX_ISSUE_2206
                    Q_min = add( st->q_inp, shift );
+8 −4
Original line number Diff line number Diff line
@@ -753,14 +753,18 @@ void pre_proc_front_ivas_fx(
    shift = s_min( shift, norm_arr( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ) ) );
    shift = add( shift, st->q_inp );

    IF( flag_16k_smc )
    {
        /* Avoid saturation of resampling/delay decimation buffer. */
        shift = s_min( shift, add( st->q_mem_decim16k_fx, 1 ) );

    }
    /* Limit Q_new here to st->q_inp because inside ivas_compute_core_buffers_fx() st->input is rescaled to Q_new */
    shift = s_min( shift, st->q_inp );
    IF( st->hLPDmem != NULL )
    {
        shift = s_min( shift, add( st->hLPDmem->q_lpd_old_exc, 1 ) );
        shift = s_min( shift, add( st->hLPDmem->q_lpd_old_exc, 0 ) );
        shift = s_min( shift, add( st->hLPDmem->q_lpd_syn, 0 ) );
        shift = s_min( shift, add( st->hLPDmem->q_mem_syn, 1 ) );
    }

    *Q_new = s_min( shift, Q_MAX );
Loading