Commit 815719c5 authored by vaillancour's avatar vaillancour
Browse files

Merge branch '2015-low-frequency-artifacts-in-3-ism-fx-enc-at-32kbps' into 'main'

[non-BE][allow regression][split-non-BE] possible fix to 2015, reducing scaling in pre-proc to prevent saturation in preemph.

Closes #2015

See merge request !2473
parents 313d2cd8 4ec9b779
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@
#define FIX_2174_JBM_BASOP_ALIGNMENT                         /* VoiceAge, Nokia: Fixes to JBM BASOP implementation and alignment to float */

#define FIX_2176_ASSERT_DEC_MAP_PARAMS_DIRAC2STEREO          /* FhG: Reduce hStereoDft->q_smooth_buf_fx by one to prevent overflow in the subframe_band_nrg[][] calculation */

#define FIX_2015_PREMPH_SAT_ALT                              /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor, allows preemphis to get 1 more bit headroom */
/* ################### End FIXES switches ########################### */

/* #################### Start BASOP porting switches ############################ */
+28 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ void preemph_copy_fx(

    return;
}

#ifndef FIX_2015_PREMPH_SAT_ALT
void preemph_copy_32fx(
    const Word16 x[], /* i  : input signal             Qx  */
    Word32 y[],       /* o  : output signal            Qx  */
@@ -66,7 +66,34 @@ void preemph_copy_32fx(

    return;
}
#else
void preemph_copy_32fx2(
    const Word16 x[], /* i  : input signal             Qx  */
    Word32 y[],       /* o  : output signal            Qx-1*/
    const Word16 mu,  /* i  : preemphasis coefficient  Q15 */
    const Word16 lg,  /* i  : vector size              Q0  */
    Word16 *mem       /* i/o: memory (x[-1])           Qx  */
)
{
    Word16 i, temp;

    temp = x[lg - 1]; /* Qx */
    move16();

    FOR( i = lg - 1; i > 0; i-- )
    {
        y[i] = L_msu0_sat( L_mult( x[i], 16384 ), x[i - 1], mu ); /* Qx+16 */
        move16();
    }
    y[0] = L_msu0_sat( L_mult( x[0], 16384 ), *mem, mu ); /* Qx+16 */
    move16();

    *mem = temp; /* Qx */
    move16();

    return;
}
#endif
/*-------------------------------------------------------------*
 * preemph_ivas_fx()
 *
+15 −2
Original line number Diff line number Diff line
@@ -2754,8 +2754,11 @@ void lag_wind_32(
// preemp_fx.c
#define PREEMPH_FX( signal, mu, L, mem ) preemph_copy_fx( ( signal ), ( signal ), ( mu ), ( L ), ( mem ) )
#ifndef FIX_2015_PREMPH_SAT_ALT
#define PREEMPH_32FX( signal, signal_out, mu, L, mem ) preemph_copy_32fx( ( signal ), ( signal_out ), ( mu ), ( L ), ( mem ) )
#else
#define PREEMPH_32FX( signal, signal_out, mu, L, mem ) preemph_copy_32fx2( ( signal ), ( signal_out ), ( mu ), ( L ), ( mem ) )
#endif
void preemph_copy_fx(
    const Word16 x[], /* i  : i   signal             Qx  */
    Word16 y[],       /* o  : output signal            Qx  */
@@ -2764,6 +2767,7 @@ void preemph_copy_fx(
    Word16 *mem       /* i/o: memory (x[-1])           Qx  */
);
#ifndef FIX_2015_PREMPH_SAT_ALT
void preemph_copy_32fx(
    const Word16 x[], /* i  : i   signal             Qx  */
    Word32 y[],       /* o  : output signal            Qx  */
@@ -2771,6 +2775,15 @@ void preemph_copy_32fx(
    const Word16 lg,  /* i  : vector size              Q0  */
    Word16 *mem       /* i/o: memory (x[-1])           Qx  */
);
#else
void preemph_copy_32fx2(
    const Word16 x[], /* i  : i   signal             Qx  */
    Word32 y[],       /* o  : output signal            Qx  */
    const Word16 mu,  /* i  : preemphasis coefficient  Q15 */
    const Word16 lg,  /* i  : vector size              Q0  */
    Word16 *mem       /* i/o: memory (x[-1])           Qx  */
);
#endif
void E_UTIL_f_preemph2(
    Word16 shift,    /* Q0 */
+4 −2
Original line number Diff line number Diff line
@@ -714,9 +714,11 @@ ivas_error pre_proc_front_ivas_fx(

    *Q_new = add( *Q_new, Q_inp_const );
    move16();

#ifndef FIX_2015_PREMPH_SAT_ALT
    Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, sub( *Q_new, st->q_inp ) ); /* Q_new */

#else
    Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, sub( add( *Q_new, 1 ), st->q_inp ) ); /* Q_new */
#endif
    Scale_sig( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ), sub( *Q_new, st->q_inp ) ); /* Q_new */

    cldfbScale.hb_scale = cldfbScale.lb_scale;
+4 −2
Original line number Diff line number Diff line
@@ -1071,9 +1071,11 @@ ivas_error ivas_compute_core_buffers_fx(
        }
        st->Q_max_16k[i] = shift;
        move16();

#ifndef FIX_2015_PREMPH_SAT_ALT
        Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, *Q_new );

#else
        Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, add( *Q_new, 1 ) );
#endif
        Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), *Q_new );
    }
    ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */