Commit 460d55c3 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch...

Merge branch '907-lf-issue-when-switching-from-td-stereo-to-fd-stereo-during-a-fer-at-24-4-kbps' into 'main'

fix proposal for 907, LF issue when switching from TD stereo to FD stereo during a FER at 24.4 kbps [allow regression]

Closes #907

See merge request !637
parents e318c6f8 c86bdfca
Loading
Loading
Loading
Loading
+193 −192
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@
#define FIX_875_SATURATION_DURING_ROUNDING      /* VA: fix a possible saturation when rounding */
#define FIX_882_LOW_LEVEL_DISCONTINUITIES       /* VA: Fix 882, discontinuities for low level signal by adding a scaling function that uses rounding, this function is more complex than normal one, has to be used only when necessary*/
#define FIX_879_DIFF_CONCEAL_PATH               /* FhG: Fix for issue 879 and different concelalment paths that led to crash */
#define FIX_907_MEM_UPDATE_ISSUE                /* VA: fix for 907, multiples issues surrounding mem_syn_r and update of mem_syn2 when FS is changing */            

/* ################## End DEVELOPMENT switches ######################### */

+6 −2
Original line number Diff line number Diff line
@@ -2386,8 +2386,12 @@ void ivas_synth_mem_updt2_fx(
    Word16 mem_syn_r[],        /* i/o: synthesis filter memory                 */
    Word16 mem_syn2[],         /* o  : synthesis filter memory for find_target */
    Word16 mem_syn[],          /* o  : synthesis filter memory for find_target */
    const Word16 dec,          /* i  : flag for decoder indication             */
    Word16 Q );
    const Word16 dec
#ifndef FIX_907_MEM_UPDATE_ISSUE
    , /* i  : flag for decoder indication             */
    Word16 Q
#endif
);
#endif
+50 −2
Original line number Diff line number Diff line
@@ -425,12 +425,20 @@ void ivas_synth_mem_updt2_fx(
    Word16 mem_syn_r[],        /* i/o: synthesis filter memory                 */
    Word16 mem_syn2[],         /* o  : synthesis filter memory for find_target */
    Word16 mem_syn[],          /* o  : synthesis filter memory for find_target */
    const Word16 dec,          /* i  : flag for decoder indication             */
    Word16 Q )
    const Word16 dec
#ifndef FIX_907_MEM_UPDATE_ISSUE
    , /* i  : flag for decoder indication             */
    Word16 Q
#endif
)
{
    Word16 mem_syn_r_size_old, mem_syn_r_size_new;
    Word32 en1, en2;
#ifndef FIX_907_MEM_UPDATE_ISSUE
    Word16 en1_e, en2_e, loc_rat, loc_rat_e, tmp, tmp_e, i;
#else
    Word16 en1_e, en2_e, loc_rat, tmp, i;
#endif
    Word32 tmp1, tmp2;

    /* Residual and update old_exc */
@@ -442,6 +450,7 @@ void ivas_synth_mem_updt2_fx(
    {
        lerp( old_exc + L_EXC_MEM - last_L_frame, old_exc + L_EXC_MEM - L_frame, L_frame, last_L_frame );
    }
#ifndef FIX_907_MEM_UPDATE_ISSUE
    IF( EQ_16( dec, DEC_IVAS ) )
    {
        IF( EQ_16( L_frame, L_FRAME16k ) )
@@ -477,6 +486,7 @@ void ivas_synth_mem_updt2_fx(
            }
        }
    }
#endif
    /*Resamp memory*/
    /*Size of LPC syn memory*/
    /* 1.25/20.0 = 1.0/16.0 -> shift 4 to the right. */
@@ -484,7 +494,45 @@ void ivas_synth_mem_updt2_fx(
    mem_syn_r_size_new = shr( L_frame, 4 );

    lerp( mem_syn_r + L_SYN_MEM - mem_syn_r_size_old, mem_syn_r + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
#ifdef FIX_907_MEM_UPDATE_ISSUE
    IF( EQ_16( dec, DEC_IVAS ) )
    {
        IF( EQ_16( L_frame, L_FRAME16k ) )
        {
            /* find scaling factor */
            // en1 = 1.25f * sum2_f( mem_syn2, M );
            en1 = Mpy_32_32( 1342177280 /*1.25f in Q30*/, sum2_f_16_fx( mem_syn2, M ) ); /* 2 * Q - 1 */
            en2 = L_shr( sum2_f_16_fx( mem_syn_r + L_SYN_MEM - M, M ), 1 );              /* 2 * Q - 1 */

            // loc_rat = sqrtf( en2 ) / ( sqrtf( en1 ) + 0.01f );
            IF( EQ_32( en2, 0 ) )
            {
                loc_rat = 0;
                move16();
            }
            ELSE
            {

                en1 = L_max( en1, 1 );
                en2_e = norm_l( en2 );
                en1_e = sub( norm_l( en1 ), 1 );
                tmp = div_l( L_shl( en1, en1_e ), extract_h( L_shl( en2, en2_e ) ) );
                en1_e = sub( en2_e, en1_e );
                tmp1 = L_shl( tmp, sub( 16 + 1, en1_e ) );                     /* Q14 because of norm - 1 for the num */
                tmp2 = Isqrt( tmp1 );                                          /* Q16 */
                loc_rat = round_fx_sat( L_shl_sat( tmp2, sub( 16, en1_e ) ) ); /* loc_rat in Q15 */
            }

            /* scale synthesis filter memory */
            FOR( i = 0; i < M; i++ )
            {
                // mem_syn_r[L_SYN_MEM - M + i] *= loc_rat;
                mem_syn_r[L_SYN_MEM - M + i] = mult_r( mem_syn_r[L_SYN_MEM - M + i], loc_rat );
                move16();
            }
        }
    }
#endif
    Copy( mem_syn_r + L_SYN_MEM - M, mem_syn2, M );

    IF( mem_syn != NULL )
+4 −0
Original line number Diff line number Diff line
@@ -460,7 +460,11 @@ ivas_error acelp_core_dec_ivas_fx(
            dec = DEC_IVAS;
            move16();
        }
#ifndef FIX_907_MEM_UPDATE_ISSUE
        synth_mem_updt2( st->L_frame, st->last_L_frame, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, dec );
#else
        ivas_synth_mem_updt2_fx( st->L_frame, st->last_L_frame, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, dec );
#endif
        Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC );
        Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/
        Copy( st->mem_syn2_fx, st->mem_syn3_fx, M );
+10 −2
Original line number Diff line number Diff line
@@ -635,7 +635,9 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
    MUSIC_POSTFILT_HANDLE hMusicPF;
    BPF_DEC_HANDLE hBPF;
    ivas_error error;

#ifdef FIX_907_MEM_UPDATE_ISSUE
    Word16 Prev_Q_syn_r;
#endif
    hMusicPF = st_fx->hMusicPF;
    hBPF = st_fx->hBPF;
    error = IVAS_ERR_OK;
@@ -762,9 +764,15 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx(
    /*------------------------------------------------------------------*
     * Synthesis
     *-----------------------------------------------------------------*/

#ifdef FIX_907_MEM_UPDATE_ISSUE
    Prev_Q_syn_r = st_fx->Q_syn;
    move16();
#endif
    Rescale_mem( Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx,
                 hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, 0, NULL );
#ifdef FIX_907_MEM_UPDATE_ISSUE
    Scale_sig( st_fx->mem_syn_r, L_SYN_MEM, sub( st_fx->Q_syn, Prev_Q_syn_r ) );
#endif
    Copy( st_fx->mem_syn2_fx, tmp1, M );
    syn_12k8_fx( st_fx->L_frame, Aq, exc2, syn, tmp1, 1, Q_exc, st_fx->Q_syn );

Loading