Commit 4c2c01bb authored by Manuel Jander's avatar Manuel Jander
Browse files

Undo some changes that worsened Q_new, and tidy up changes under NONBE_FIX_ISSUE_2518.

parent 12e8620e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1151,11 +1151,13 @@ ivas_error init_encoder_fx(
        init_coder_ace_plus_ivas_fx( st, st->last_total_brate, igf_brate, 0 );
    }

#ifndef NONBE_FIX_ISSUE_2518
    IF( st->hLPDmem != NULL )
    {
        st->hLPDmem->q_lpd_old_exc = st->prev_Q_new;
        move16();
    }
#endif

    /*-----------------------------------------------------------------*
     * FD-CNG encoder
+3 −11
Original line number Diff line number Diff line
@@ -752,23 +752,15 @@ void pre_proc_front_ivas_fx(
    Word16 shift = L_norm_arr( sig_out, preemp_len );
    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 ( NE_32( input_Fs, st->sr_core ) )
    {
        shift = s_min( shift, add( st->q_mem_decim_fx, 1 ) );
    }

    /* Avoid saturation of resampling decimation buffer inside ivas_compute_core_buffers_fx(). */
    shift = s_min( shift, add( st->q_mem_decim16k_fx, 2 ) );

    /* Add one bit headroom for filter overshoot in modify_Fs_fx() */
    shift = add( shift, 1 );
    /* 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, 2 ) );
        shift = s_min( shift, add( st->hLPDmem->q_lpd_syn, 1 ) );
        shift = s_min( shift, add( st->hLPDmem->q_lpd_old_exc, 1 ) );
    }

    *Q_new = s_min( shift, Q_MAX );
+11 −8
Original line number Diff line number Diff line
@@ -1300,6 +1300,16 @@ void ivas_compute_core_buffers_fx(
        shift = L_norm_arr( sig_out, preemp_len );
        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 );

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

        IF( st->hLPDmem != NULL )
        {
            shift = s_min( shift, add( st->hLPDmem->q_lpd_old_exc, 1 ) );
        }
        *Q_new = s_min( shift, Q_MAX );
        move16();
#else
        maximum_abs_32_fx( sig_out, preemp_len, &max_32 );
        inp_max = s_max( extract_h( max_32 ), 1 );
@@ -1310,16 +1320,8 @@ void ivas_compute_core_buffers_fx(
#else
        shift = sub( norm_s( inp_max ), 1 /* headroom */ );
#endif
#endif

#ifdef NONBE_FIX_ISSUE_2206
#ifdef NONBE_FIX_ISSUE_2518
        IF( st->hLPDmem != NULL )
        {
            *Q_new = s_min( *Q_new, add( st->hLPDmem->q_lpd_old_exc, 2 ) );
            *Q_new = s_min( *Q_new, add( st->hLPDmem->q_lpd_syn, 1 ) );
        }
#endif
        *Q_new = s_min( shift, Q_MAX );
        move16();
#else
@@ -1349,6 +1351,7 @@ void ivas_compute_core_buffers_fx(
        st->Q_max_16k[i] = shift;
        move16();
#endif
#endif

#ifndef NONBE_FIX_ISSUE_2206
        Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, add( *Q_new, 1 ) );