Commit 3a09c97f authored by Manuel Jander's avatar Manuel Jander
Browse files

Fine tune Q_new calculation, improve initial condition of q_lpd_old_exc via prev_Q_new.

parent fdc9c1a7
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -386,6 +386,7 @@ void core_coder_mode_switch_ivas_fx(
        move32();
        st->currEnergyHF_e_fx = 0;
        move16();
#ifndef NONBE_FIX_ISSUE_2518
        Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM );
        Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift );
        st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift );
@@ -394,12 +395,15 @@ void core_coder_mode_switch_ivas_fx(
        Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift );
        st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift );
        move16();
#endif
        init_coder_ace_plus_ivas_fx( st, last_total_brate, st->total_brate, MCT_flag );
#ifndef NONBE_FIX_ISSUE_2518
        if ( st->hLPDmem != NULL )
        {
            st->hLPDmem->q_lpd_old_exc = st->prev_Q_new;
            move16();
        }
#endif
    }

    test();
+7 −0
Original line number Diff line number Diff line
@@ -249,6 +249,13 @@ ivas_error init_encoder_fx(

    st->prev_Q_new = 0;
    move16();
#ifdef NONBE_FIX_ISSUE_2518
    if ( st->element_mode > EVS_MONO )
    {
        st->prev_Q_new = Q15;
        move16();
    }
#endif

    IF( EQ_32( st->input_Fs, 8000 ) )
    {
+40 −6
Original line number Diff line number Diff line
@@ -211,9 +211,15 @@ void pre_proc_front_ivas_fx(
    Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX];
    Word16 Q_inp_const = -1;
    move16();
#ifdef NONBE_FIX_ISSUE_2518
    Word16 preemp_len;
    Word16 *preemp_start_idx = NULL;
    Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */];
#else
    Word16 headroom, preemp_len, inp_max;
    Word16 *preemp_start_idx = NULL;
    Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32;
#endif

    push_wmops( "pre_proc_front" );
    /*------------------------------------------------------------------*
@@ -572,9 +578,15 @@ void pre_proc_front_ivas_fx(
#endif
    }
#ifdef NONBE_FIX_ISSUE_2206
#ifdef NONBE_FIX_ISSUE_2518
    st->q_mem_decim_fx = add( st->q_inp, norm_arr( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX ) );
    move16();
    Copy_Scale_sig_nosat( st->mem_decim_fx_q_inp, st->mem_decim_fx, 2 * L_FILT_MAX, sub( st->q_mem_decim_fx, st->q_inp ) );
#else
    Copy( st->mem_decim_fx_q_inp, st->mem_decim_fx, 2 * L_FILT_MAX );
    st->q_mem_decim_fx = st->q_inp;
    move16();
#endif

    Word16 q_buf_speech_enc;

@@ -627,6 +639,7 @@ void pre_proc_front_ivas_fx(
     * Perform fixed preemphasis (12.8 kHz signal) through 1 - g*z^-1
     *-----------------------------------------------------------------*/

#ifndef NONBE_FIX_ISSUE_2518
#ifdef NONBE_FIX_ISSUE_2206
    headroom = 0;
    move16();
@@ -638,6 +651,7 @@ void pre_proc_front_ivas_fx(
#else
    headroom = 2;
    move16();
#endif
#endif
    preemp_len = 0;
    move16();
@@ -734,6 +748,17 @@ void pre_proc_front_ivas_fx(
    move16();
    st->mem_preemph_q = st->q_inp;
    move16();
#ifdef NONBE_FIX_ISSUE_2518
    Word16 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, st->q_inp );
    if ( NE_32( input_Fs, st->sr_core ) )
    {
        shift = s_min( shift, add( st->q_mem_decim_fx, 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 );

@@ -769,19 +794,28 @@ void pre_proc_front_ivas_fx(
    st->Q_max[i] = shift;
    move16();
#endif
#endif

#ifdef NONBE_FIX_ISSUE_2206
#ifdef NONBE_FIX_ISSUE_2518
    if ( flag_16k_smc )
    {
        /* Avoid saturation of resampling decimation buffer inside ivas_compute_core_buffers_fx(). */
    *Q_new = s_min( *Q_new, st->q_mem_decim16k_fx );
        *Q_new = s_min( *Q_new, 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 */
    *Q_new = s_min( *Q_new, st->q_inp );
#endif
#ifdef NONBE_FIX_ISSUE_2518
    if ( st->hLPDmem != NULL )
    IF( st->hLPDmem != NULL )
    {
        *Q_new = s_min( *Q_new, add( st->hLPDmem->q_lpd_old_exc, 1 ) );
        *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 ) );
    }
#else
#ifdef NONBE_FIX_ISSUE_2206
    /* Avoid saturation of resampling decimation buffer inside ivas_compute_core_buffers_fx(). */
    *Q_new = s_min( *Q_new, st->q_mem_decim16k_fx );
    /* Limit Q_new here to st->q_inp because inside ivas_compute_core_buffers_fx() st->input is rescaled to Q_new */
    *Q_new = s_min( *Q_new, st->q_inp );
#endif
    *Q_new = add( *Q_new, Q_inp_const );
#endif
    move16();
+16 −2
Original line number Diff line number Diff line
@@ -806,9 +806,15 @@ void ivas_compute_core_buffers_fx(
#else
    Word16 i, shift, Q_min;
#endif
#ifdef NONBE_FIX_ISSUE_2518
    Word16 preemp_len;
    Word16 *preemp_start_idx = NULL;
    Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k + L_FILT16k];
#else
    Word16 preemp_len, inp_max;
    Word16 *preemp_start_idx = NULL;
    Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k + L_FILT16k], max_32;
#endif

#ifdef NONBE_FIX_ISSUE_2206
    assert( Q_old_inp_16k == ( *Q_new - 1 ) );
@@ -1290,6 +1296,11 @@ void ivas_compute_core_buffers_fx(
            preemp_len = L_FRAME16k + L_FILT16k;
            move16();
        }
#ifdef NONBE_FIX_ISSUE_2518
        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 );
#else
        maximum_abs_32_fx( sig_out, preemp_len, &max_32 );
        inp_max = s_max( extract_h( max_32 ), 1 );

@@ -1299,11 +1310,14 @@ 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 )
        IF( st->hLPDmem != NULL )
        {
            *Q_new = s_min( *Q_new, add( st->hLPDmem->q_lpd_old_exc, 1 ) );
            *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 );