Commit 1955bbec authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'ltv_crash_fixes_bug_fix_2' into 'main'

LTV crash fix by correcting Q in swb_bwe, few synthesis buffer related fixes [allow regression]

See merge request !1285
parents 9579ccab c7608e50
Loading
Loading
Loading
Loading
+24 −24
Original line number Diff line number Diff line
@@ -1769,35 +1769,35 @@ static const Word16 filter_LP30_300K_fx[LFE_PLC_FDEL + 1] =
const Resampling_cfg resampling_cfg_tbl[] =
{	
    /* fin           fout          up.fact.    den.fac. len.out     filter coefs.                           filter length/2     filter mem./2                  flags */
    {  8000,  8000,  12800, 12800,   8,     8,    5,     256,    /*filter5_39s320_120,*/ filter5_39s320_120_fx,      15,            15,                RS_INV_FAC, RS_INV_FAC    },
	{  12800, 12800, 8000,  8000,    5,     5,    8,     160,    /*filter5_39s320_120,*/ filter5_39s320_120_fx,      L_FILT_UP8k,   L_FILT_UP8k,       RS_INV_FAC, RS_INV_FAC    },
	{  16000, 16000, 8000,  8000,    6,     6,    12,    160,    /*filter_LP12_180H,*/   filter_LP12_180H_fx,        180 / 6,       180 / 6,             0,          0           },
	{  12800, 12800, 16000, 16000,   15,    15,   12,    320,    /*filter_LP15_180H,*/   filter_LP15_180H_fx,        L_FILT_UP16k,  L_FILT_UP16k,        0,          0           },
	{  12800, 12800, 32000, 32000,   15,    15,   6,     640,    /*filter_LP15_180H,*/   filter_LP15_180H_fx,        L_FILT_UP32k,  L_FILT_UP32k,        0,          0           },
	{  12800, 12800, 48000, 48000,   15,    15,   4,     960,    /*filter_LP15_180H,*/   filter_LP15_180H_fx,        L_FILT_UP48k,  L_FILT_UP48k,        0,          0           },
																								    
    {  16000, 16000, 12800, 12800,   12,     12,   15,   256,    /*filter_LP15_180H,*/   filter_LP15_180H_fx,        L_FILT16k,     L_FILT16k,           0,          0           },
	{  16000, 16000, 32000, 32000,   12,     12,   6,    640,    /*filter_LP12_180H, */  filter_LP12_180H_fx,        L_FILT16k,     L_FILT16k,           0,          0           },
	{  16000, 16000, 48000, 48000,   12,     12,   4,    960,    /*filter_LP12_180H,*/   filter_LP12_180H_fx,        L_FILT16k,     L_FILT16k,           0,          0           },
													     
    {  32000, 32000, 12800, 12800,   6,	    6,    15,    256,    /*filter_LP15_180H,*/   filter_LP15_180H_13b_fx,    L_FILT32k,     L_FILT32k,           0,          0			},
	{  32000, 32000, 16000, 16000,   6,	    6,    12,    320,    /*filter_LP12_180H,*/   filter_LP12_180H_13b_fx,    L_FILT32k,     L_FILT32k,           0,          0			},
	{  32000, 32000, 25600, 25600,   12,     12,   15,   512,    /*filter_LP15_360H,*/   filter_LP15_360H_13b_fx,    L_FILT32k,     L_FILT32k,           0,          0			},
	{  32000, 32000, 48000, 48000,   3,      3,    2,    960,    /*filter_LP3_90H,*/     filter_LP3_90H_fx,          L_FILT32k,     L_FILT32k,           0,          0			},
												  	     
    {  48000, 48000, 12800, 12800,   4,      4,    15,   256,    /*filter_LP15_180H,*/   filter_LP15_180H_13b_fx,    L_FILT48k,     L_FILT48k,           0,          0			},
	{  48000, 48000, 16000, 16000,   4,      4,    12,   320,    /*filter_LP12_180H,*/   filter_LP12_180H_13b_fx,    L_FILT48k,     L_FILT48k,           0,          0			},
	{  48000, 48000, 25600, 25600,   8,      8,    15,   512,    /*filter_LP15_360H,*/   filter_LP15_360H_13b_fx,    L_FILT48k,     L_FILT48k,		     0,          0			},
	{  48000, 48000, 32000, 32000,   2,      2,    3,    640,    /*filter_LP3_90H,*/     filter_LP3_90H_fx,          L_FILT48k,     L_FILT48k,		     0,          0			},
    {  8000,  12800,   8,    5,     256,    /*filter5_39s320_120,*/ filter5_39s320_120_fx,       15,                RS_INV_FAC    },
	{  12800, 8000,    5,    8,     160,    /*filter5_39s320_120,*/ filter5_39s320_120_fx,       L_FILT_UP8k,       RS_INV_FAC    },
	{  16000, 8000,    6,    12,    160,    /*filter_LP12_180H,*/   filter_LP12_180H_fx,         180 / 6,             0           },
	{  12800, 16000,   15,   12,    320,    /*filter_LP15_180H,*/   filter_LP15_180H_fx,         L_FILT_UP16k,        0           },
	{  12800, 32000,   15,   6,     640,    /*filter_LP15_180H,*/   filter_LP15_180H_fx,         L_FILT_UP32k,        0           },
	{  12800, 48000,   15,   4,     960,    /*filter_LP15_180H,*/   filter_LP15_180H_fx,         L_FILT_UP48k,        0           },
																								    
    {  16000, 12800,    12,    15,   256,    /*filter_LP15_180H,*/   filter_LP15_180H_fx,        L_FILT16k,           0,                 },
	{  16000, 32000,    12,    6,    640,    /*filter_LP12_180H, */  filter_LP12_180H_fx,        L_FILT16k,           0,                 },
	{  16000, 48000,    12,    4,    960,    /*filter_LP12_180H,*/   filter_LP12_180H_fx,        L_FILT16k,           0,                 },
							   
    {  32000, 12800,    6,	   15,    256,    /*filter_LP15_180H,*/   filter_LP15_180H_13b_fx,    L_FILT32k,           0,      			},
	{  32000, 16000,    6,	   12,    320,    /*filter_LP12_180H,*/   filter_LP12_180H_13b_fx,    L_FILT32k,           0,      			},
	{  32000, 25600,    12,    15,   512,    /*filter_LP15_360H,*/   filter_LP15_360H_13b_fx,    L_FILT32k,           0,       		},
	{  32000, 48000,    3,     2,    960,    /*filter_LP3_90H,*/     filter_LP3_90H_fx,          L_FILT32k,           0,       		},
							     
    {  48000, 12800,    4,     15,   256,    /*filter_LP15_180H,*/   filter_LP15_180H_13b_fx,    L_FILT48k,           0,       		},
	{  48000, 16000,    4,     12,   320,    /*filter_LP12_180H,*/   filter_LP12_180H_13b_fx,    L_FILT48k,           0,       		},
	{  48000, 25600,    8,     15,   512,    /*filter_LP15_360H,*/   filter_LP15_360H_13b_fx,    L_FILT48k,		     0,        		},
	{  48000, 32000,    2,     3,    640,    /*filter_LP3_90H,*/     filter_LP3_90H_fx,          L_FILT48k,		     0,        		},
												  
    /* configs with NB 4kHz low-pass */			  
    {  16000, 16000, 12800, 12800,   12,     12,   15,   256,    /*filter_LP24_90H,*/    filter_LP24_90H_fx,        L_FILT16k,      L_FILT16k,		     0,          0			},
	{  32000, 32000, 12800, 12800,   6,      6,    15,   256,    /*filter_LP24_90H,*/    filter_LP24_90H_13b_fx,    L_FILT32k,      L_FILT32k,           0,          0			},
	{  48000, 48000, 12800, 12800,   4,      4,    15,   256,    /*filter_LP24_90H,*/    filter_LP24_90H_13b_fx,    L_FILT48k,      L_FILT48k,           0,          0			},
    {  16000, 12800,   12,     15,   256,    /*filter_LP24_90H,*/    filter_LP24_90H_fx,         L_FILT16k,		     0,        		},
	{  32000, 12800,   6,      15,   256,    /*filter_LP24_90H,*/    filter_LP24_90H_13b_fx,     L_FILT32k,           0,       		},
	{  48000, 12800,   4,      15,   256,    /*filter_LP24_90H,*/    filter_LP24_90H_13b_fx,     L_FILT48k,           0,       		},
    /* entry for LFE PLC */
    {  1600,  1600,  48000, 48000,   30,     30,   1,     960,   /*filter_LP30_300K,*/   filter_LP30_300K_fx,       LFE_PLC_FDEL/30,LFE_PLC_FDEL / 30,   0,          0           },
    {  0,     0,      0,        0,    0,      0,   0,       0,    /*              0, */                    0,               0,           0,              0,          0           } /* trailing entry (just to calculate the length of this table) */
    {  1600,  48000,    30,      1,     960,   /*filter_LP30_300K,*/   filter_LP30_300K_fx,      LFE_PLC_FDEL / 30,   0,                 },
    {  0,      0,        0,      0,       0,    /*              0, */                    0,          0,              0,                 } /* trailing entry (just to calculate the length of this table) */
};
//den fac value for last entry is calculated as den.fac = (num.fac*fin)/fout
+4 −12
Original line number Diff line number Diff line
@@ -49,13 +49,8 @@
#define INTERP_EXP 0
typedef struct
{
    Word32 fin;    /* input frequency                   */
    Word32 fin_fx;     /* input frequency                   Q0	*/

    Word32 fout;    /* output frequency                  */
    Word32 fout_fx;    /* output frequency                  Q0	*/

    Word16 fac_num;    /* numerator of resampling factor    */
    Word16 fac_num_fx; /* numerator of resampling factor    Q0	*/

    Word16 fac_den_fx; /* denominator of resampling factor  Q0	*/
@@ -63,10 +58,7 @@ typedef struct

    const Word16 *filter_fx; /* resampling filter coefficients    Q14	*/

    Word16 filt_len;    /* number of filter coeff.           */
    Word16 filt_len_fx; /* number of filter coeff.			Q0	*/

    UWord16 flags;    /* flags from config. table          */
    UWord16 flags_fx;   /* flags from config. table          Q0	*/
                        // UNS_Word16 flags_fx;     /* flags from config. table          Q0	*/

+4 −4
Original line number Diff line number Diff line
@@ -213,14 +213,14 @@ void syn_filt_fx(

    FOR( i = 0; i < l; i++ )
    {
        s = L_mult( a0, x[i] );
        s = L_mult( a0, x[i] ); // Qx + Qa - shift + 1
        FOR( j = 1; j <= m; j++ )
        {
            s = L_msu_sat( s, shr( a[j], shift ), yy[i - j] );
            s = L_msu_sat( s, a[j], yy[i - j] ); // Qa + Qx - shift + 1
        }

        s = L_shl_sat( s, q );
        yy[i] = extract_h( s );
        s = L_shl_sat( s, q );  // Qx + (Qa + q)Q15 - shift + 1 = Qx - shift + Q16
        yy[i] = extract_h( s ); // Qx - shift
        move16();
        y[i] = extract_h( s );
        move16();
+12 −14
Original line number Diff line number Diff line
@@ -1123,7 +1123,11 @@ ivas_error acelp_core_enc_ivas_fx(
        move16();
        st->hLPDmem->q_mem_syn = st->Q_syn;
        move16();

        // Scaling Aq to Q12
        FOR( Word16 k = 0; k < NB_SUBFR16k; k++ )
        {
            Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) );
        }
        /* synthesis at 12.8kHz sampling rate */
        syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn );

@@ -1275,6 +1279,11 @@ ivas_error acelp_core_enc_ivas_fx(
            st->stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); // Q15
            move16();
        }
        // Scaling Aq to Q12
        FOR( Word16 k = 0; k < NB_SUBFR16k; k++ )
        {
            Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) );
        }
        test();
        IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
        {
@@ -1313,12 +1322,6 @@ ivas_error acelp_core_enc_ivas_fx(
            v_multc_fixed_16_16( res_fx, att_fx, res_fx, st->L_frame );
        }

        // Scaling Aq and Aw to Q12
        FOR( Word16 k = 0; k < NB_SUBFR16k; k++ )
        {
            Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) );
            Scale_sig( &Aw[( M + 1 ) * k], M + 1, sub( norm_s( Aw[( M + 1 ) * k] ), 2 ) );
        }
        /*-----------------------------------------------------------------*
         * Determine TC subframe classification
         *-----------------------------------------------------------------*/
@@ -1418,17 +1421,12 @@ ivas_error acelp_core_enc_ivas_fx(
            encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
        }

        FOR( i = 0; i < NB_SUBFR16k; i++ )
        {
            Scale_sig( &Aq[i * ( M + 1 )], ( M + 1 ), sub( Q12, sub( Q14, norm_s( Aq[i * ( M + 1 )] ) ) ) ); // Q12
        }

        /* update mem_syn1_flt for ACELP core switching */
        Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M ); // Q_syn

        /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
        Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); // st->Q_syn

        Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); // hLPDmem->q_mem_syn
        // st->Q_syn = Q_new - 1;
        Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn
        /* save and delay synthesis to be used by SWB BWE */
        IF( st->hBWE_FD != NULL )
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ void encod_unvoiced_fx(
    const Word16 Es_pred,           /* i  : predicted scaled innov. energy          Q8*/
    const Word16 uc_two_stage_flag, /* i  : flag indicating two-stage UC            Q0*/
    const Word16 *res_fx,           /* i  : residual signal                         Q_new*/
    Word16 *syn_fx,                 /* o  : core synthesis                          Q_new*/
    Word16 *syn_fx,                 /* o  : core synthesis                          Q_new -1 */
    Word16 *tmp_noise_fx,           /* o  : long-term noise energy                  Q0*/
    Word16 *exc_fx,                 /* i/o: current non-enhanced excitation         Q_new*/
    Word16 *pitch_buf_fx,           /* o  : floating pitch values for each subframe Q6*/
Loading