Commit 726fb15a authored by vaillancour's avatar vaillancour
Browse files

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

parent 7c8eaa92
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@
#define FIX_871_REMOVE_UNNECESSARY_CONDITION    /* VA: remove a condition that is not needed and prevented correct frame classification of the secondary channel of the TD stereo */
#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_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 ######################### */

+38 −0
Original line number Diff line number Diff line
@@ -442,6 +442,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 +478,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 +486,43 @@ 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( en1, 0 ) )
            {
                loc_rat = 0;
                move16();
            }
            ELSE
            {
                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, st->Q_syn );
#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 );