Commit c24a0ae3 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'ltv_crash_fix_high_mld_fixes_3' into 'main'

LTV crash fixes and High MLD issue fixes

See merge request !503
parents 3c047727 f51e8abd
Loading
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -1266,7 +1266,8 @@ void stereo_mdct_core_dec_fx(
    Decoder_Struct *st_ivas,                       /* i/o: IVAS decoder structure                  */
    CPE_DEC_HANDLE hCPE,                           /* i/o: CPE decoder structure                   */
    Word32 *signal_out[CPE_CHANNELS],              /* o  : synthesis @internal_FS                  */
    Word16 signal_outFB[CPE_CHANNELS][L_FRAME48k] /* o  : synthesis @output_FS                    */
    Word16 signal_outFB[CPE_CHANNELS][L_FRAME48k], /* o  : synthesis @output_FS                    */
    Word16 e_sigFB[CPE_CHANNELS]                   /* o  : exponent of synthesis @output_FS        */
);

// ivas_stereo_mdct_stereo_com.c
+1 −1
Original line number Diff line number Diff line
@@ -9328,7 +9328,7 @@ void ivas_mdct_core_reconstruct_fx(
    Word16 fUseTns[CPE_CHANNELS][NB_DIV],          /* i  : flage TNS enabled                   */
    const Word16 MCT_flag,                         /* i  : hMCT handle allocated (1) or not (0)*/
    Word16 q_x,
    Word16 e_sig );
    Word16 e_sig[CPE_CHANNELS] );

void ari_start_encoding_14bits_ivas_fx(
    Tastat *s );
+8 −0
Original line number Diff line number Diff line
@@ -365,6 +365,8 @@ void open_decoder_LPD_fx(
            set16_fx( hTcxDec->syn_Overl, 0, shr( L_FRAME32k, 1 ) );

            set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC );
            hTcxDec->q_old_synth = 0;
            move16();
            set16_fx( hTcxDec->synth_history_fx, 0, add( L_PROT48k, L_FRAME_MAX ) );
            hTcxDec->q_synth_history_fx = 0;
            move16();
@@ -389,6 +391,8 @@ void open_decoder_LPD_fx(
        IF( st->hTcxDec != NULL && ( ( NE_16( st->L_frame, st->last_L_frame ) ) || ( EQ_16( st->last_codec_mode, MODE1 ) ) ) )
        {
            set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC );
            hTcxDec->q_old_synth = 0;
            move16();
        }

        /*Size of LPC syn memory*/
@@ -1478,6 +1482,8 @@ void open_decoder_LPD_ivas_fx(
            reset_tcx_overl_buf_fx( st->hTcxDec );
            set16_fx( hTcxDec->syn_OverlFB, 0, L_FRAME_MAX / 2 );
            set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC );
            hTcxDec->q_old_synth = 0;
            move16();
            set16_fx( hTcxDec->synth_history_fx, 0, L_PROT48k + L_FRAME_MAX );
            hTcxDec->q_synth_history_fx = 0;
            move16();
@@ -1501,6 +1507,8 @@ void open_decoder_LPD_ivas_fx(
        IF( st->hTcxDec != NULL && ( NE_16( st->L_frame, st->last_L_frame ) || ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ) )
        {
            set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC );
            hTcxDec->q_old_synth = 0;
            move16();
        }

        /*Compute size of old and new memories*/
+46 −0
Original line number Diff line number Diff line
@@ -3162,7 +3162,11 @@ void IMDCT_ivas_fx(
            {
                FOR( i = 0; i < sub( overlap, tcx_mdct_window_min_length ); i++ )
                {
#ifdef BASOP_NOGLOB
                    xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )] = add_sat( xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )], old_out_fx[add( i, nz )] );
#else
                    xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )] = add( xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )], old_out_fx[add( i, nz )] );
#endif
                    move16();
                }

@@ -3175,17 +3179,30 @@ void IMDCT_ivas_fx(
                    // tested
                    FOR( ; i < overlap; i++ ) /* perfectly reconstructing ALDO shortening */
                    {
#ifdef BASOP_NOGLOB
                        xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], old_out_fx[add( i, nz )] );
#else
                        xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], old_out_fx[add( i, nz )] );

#endif
                        move16();
                    }
                    FOR( i = 0; i < shr( tcx_mdct_window_min_length, 1 ); i++ )
                    {
#ifdef BASOP_NOGLOB
                        xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )] = add_sat( xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )], mult_r( old_out_fx[add( add( i, nz ), overlap )], tcx_mdct_window_minimum_fx[i].v.re ) );
#else
                        xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )] = add( xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )], mult_r( old_out_fx[add( add( i, nz ), overlap )], tcx_mdct_window_minimum_fx[i].v.re ) );
#endif
                        move16();
                    }
                    FOR( ; i < tcx_mdct_window_min_length; i++ )
                    {
#ifdef BASOP_NOGLOB
                        xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )] = add_sat( xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )], mult_r( old_out_fx[add( add( i, nz ), overlap )], tcx_mdct_window_minimum_fx[sub( tcx_mdct_window_min_length, add( 1, i ) )].v.im ) );
#else
                        xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )] = add( xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )], mult_r( old_out_fx[add( add( i, nz ), overlap )], tcx_mdct_window_minimum_fx[sub( tcx_mdct_window_min_length, add( 1, i ) )].v.im ) );
#endif
                        move16();
                    }
                }
@@ -3193,12 +3210,20 @@ void IMDCT_ivas_fx(
                {
                    FOR( ; i < sub( overlap, shr( tcx_mdct_window_min_length, 1 ) ); i++ )
                    {
#ifdef BASOP_NOGLOB
                        xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_out_fx[add( i, nz )], tcx_mdct_window_minimum_fx[add( sub( tcx_mdct_window_min_length, overlap ), i )].v.re ) );
#else
                        xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_out_fx[add( i, nz )], tcx_mdct_window_minimum_fx[add( sub( tcx_mdct_window_min_length, overlap ), i )].v.re ) );
#endif
                        move16();
                    }
                    FOR( ; i < overlap; i++ )
                    {
#ifdef BASOP_NOGLOB
                        xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_out_fx[add( i, nz )], tcx_mdct_window_minimum_fx[sub( overlap, add( 1, i ) )].v.im ) );
#else
                        xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_out_fx[add( i, nz )], tcx_mdct_window_minimum_fx[sub( overlap, add( 1, i ) )].v.im ) );
#endif
                        move16();
                    }
                }
@@ -3211,12 +3236,21 @@ void IMDCT_ivas_fx(
                {
                    FOR( i = 0; i < shr( tcx_mdct_window_half_length, 1 ); i++ )
                    {
#ifdef BASOP_NOGLOB
                        xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[i].v.re ) );
#else
                        xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[i].v.re ) );

#endif
                        move16();
                    }
                    FOR( ; i < tcx_mdct_window_half_length; i++ )
                    {
#ifdef BASOP_NOGLOB
                        xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) );
#else
                        xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) );
#endif
                        move16();
                    }
                }
@@ -3232,7 +3266,11 @@ void IMDCT_ivas_fx(
                {
                    FOR( i = 0; i < overlap; i++ )
                    {
#ifdef BASOP_NOGLOB
                        xn_buf_fx[add( i, shr( overlap, 1 ) )] = add_sat( xn_buf_fx[add( i, shr( overlap, 1 ) )], old_syn_overl_fx[i] );
#else
                        xn_buf_fx[add( i, shr( overlap, 1 ) )] = add( xn_buf_fx[add( i, shr( overlap, 1 ) )], old_syn_overl_fx[i] );
#endif
                        move16();
                    }
                }
@@ -3309,14 +3347,22 @@ void IMDCT_ivas_fx(
            FOR( i = 0; i < shr( tcx_mdct_window_half_length, 1 ); i++ )
            {
                xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = mult_r( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], tcx_mdct_window_half_fx[i].v.im );
#ifdef BASOP_NOGLOB
                xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) );
#else
                xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) );
#endif
                move16();
                move16();
            }
            FOR( ; i < tcx_mdct_window_half_length; i++ )
            {
                xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = mult_r( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.re );
#ifdef BASOP_NOGLOB
                xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ), tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) );
#else
                xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ), tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) );
#endif
                move16();
                move16();
            }
+34 −25
Original line number Diff line number Diff line
@@ -108,6 +108,10 @@ ivas_error ivas_core_dec_fx(

    Word16 synth_16_fx[CPE_CHANNELS][L_FRAME48k];
    Word32 synth_32_fx[CPE_CHANNELS][L_FRAME48k];
    Word16 e_sig[CPE_CHANNELS];
    e_sig[0] = e_sig[1] = 15;
    move16();
    move16();

    FOR( i = 0; i < CPE_CHANNELS; i++ )
    {
@@ -728,10 +732,11 @@ ivas_error ivas_core_dec_fx(
            }
            ELSE
            {
                Word16 e_sig;
                Word16 ch;

                e_sig = 17;
                e_sig[0] = 17;
                e_sig[1] = 17;
                move16();
                move16();
                sts = hCPE->hCoreCoder;
                FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
@@ -767,7 +772,7 @@ ivas_error ivas_core_dec_fx(
                    }
                }

                stereo_mdct_core_dec_fx( st_ivas, hCPE, output_32_fx, synth_16_fx );
                stereo_mdct_core_dec_fx( st_ivas, hCPE, output_32_fx, synth_16_fx, e_sig );

                FOR( ch = 0; ch < 2; ch++ )
                {
@@ -777,14 +782,6 @@ ivas_error ivas_core_dec_fx(
                    st->hHQ_core->Q_old_wtda = st->Q_syn;
                    move16();
                }

#ifdef MSAN_FIX
                Scale_sig( synth_16_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, sub( e_sig, 15 ) );
                Scale_sig( synth_16_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, sub( e_sig, 15 ) );
#else
                Scale_sig( synth_16_fx[0], L_FRAME48k, sub( e_sig, 15 ) );
                Scale_sig( synth_16_fx[1], L_FRAME48k, sub( e_sig, 15 ) );
#endif
            }
        }
        /* for inactive frames with mono output, copy and (if necessary) downmix buffers */
@@ -872,13 +869,7 @@ ivas_error ivas_core_dec_fx(
         *---------------------------------------------------------------------*/

        /*core_switching_post_dec*/
        Q_synth = 0;
        move16();
        if ( st->hHQ_core != NULL )
        {
            st->hHQ_core->Q_old_postdec = 0;
            move16();
        }
        Q_synth = sub( 15, e_sig[0] );

        /*------------------fix-to-fix-end-----------------------*/

@@ -1022,21 +1013,33 @@ ivas_error ivas_core_dec_fx(

        ivas_bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n], old_syn_fx, q_audio );

        IF( st->hHQ_core == NULL )
        {
            Copy_Scale_sig_16_32( st->delay_buf_out_fx, st->delay_buf_out32_fx, imult1616( HQ_DELTA_MAX, HQ_DELAY_COMP ), Q11 );
        Scale_sig32( output_32_fx[n], L_FRAME48k, sub( Q11, Q4 ) );
        }
        ELSE
        {
            Copy_Scale_sig_16_32( st->delay_buf_out_fx, st->delay_buf_out32_fx, imult1616( HQ_DELTA_MAX, HQ_DELAY_COMP ), sub( Q11, st->hHQ_core->Q_old_postdec ) );
        }

        Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) );

        /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/

        IF( st->cldfbSyn != NULL )
        {
            scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q11, Q4 ) );
            scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, ( Q11 - Q4 ) );
            st->cldfbSyn->Q_cldfb_state = Q11;
            move16();
        }

#ifdef MSAN_FIX
        IF( Q_synth > 0 )
        {
            Scale_sig( synth_16_fx[n], output_frame, negate( Q_synth ) );
            Q_synth = 0;
            move16();
        }
#else
        Scale_sig( synth_16_fx[n], L_FRAME48k, negate( Q_synth ) );
#endif
@@ -1065,19 +1068,25 @@ ivas_error ivas_core_dec_fx(
         *---------------------------------------------------------------------*/

        Word16 Q_input, Q_hb_synth_fx, Q_synth_fx;
        Word16 Q_syn_hb;
        Word16 Q_syn_hb, sf;

        sf = getScaleFactor32( output_32_fx[n], L_FRAME48k );

        Q_input = 0;
        move16();
        if ( LT_16( sf, 5 ) )
        {
            Q_input = sub( sf, 5 );
        }
        Q_hb_synth_fx = 0;
        move16();
        Q_synth_fx = 0;
        Q_synth_fx = Q_synth;
        move16();

        FD_BWE_DEC_HANDLE hBWE_FD;
        hBWE_FD = st->hBWE_FD;

        Copy_Scale_sig_32_16( output_32_fx[n], output_16_fx[n], L_FRAME48k, negate( Q11 ) );
        Copy_Scale_sig_32_16( output_32_fx[n], output_16_fx[n], L_FRAME48k, sub( Q_input, Q11 ) );
        Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, negate( Q11 ) );
        test();
        test();
Loading