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

High MLD fixes for LTV, HP20 filter optimization, float code cleanup

[x] HP20 filter recoding for WMOPS optimization
[x] Fix for LTV High MLD due to old_out in ivas_core_dec, decoder_tcx_ivas_fx
[x] Apa-Exec float code cleanup
[x] Fix for high mld issue for the case - [ltv-stereo at 13.2 kbps, 32kHz in, 32kHz out, DTX on]
parent 94e7768c
Loading
Loading
Loading
Loading
Loading
+176 −0
Original line number Diff line number Diff line
@@ -436,6 +436,181 @@ void hp20( Word16 signal[], /* i/o: signal to filter any *
}


#ifdef HP20_FIX32_RECODING
void hp20_fix32(
    Word32 signal_fx[],
    const Word16 lg,
    Word32 mem_fx[],
    const Word32 Fs )
{
    Word32 i;
    Word32 a1_fx, a2_fx, b1_fx, b2_fx;
    Word32 diff_pos, diff_neg;
#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif
    Word16 prescale, prescaleOld, prescale_current_frame, diff;

    prescale = getScaleFactor32( signal_fx, lg );
    prescale_current_frame = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) );


    prescaleOld = extract_l( mem_fx[4] );

#ifdef BASOP_NOGLOB
    diff_pos = norm_l( L_shl_o( L_max( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) );
    diff_neg = norm_l( L_shl_o( L_min( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) );
#else
    diff_pos = norm_l( L_shl( L_max( mem_fx[2], mem_fx[3] ), prescaleOld ) );
    diff_neg = norm_l( L_shl( L_min( mem_fx[2], mem_fx[3] ), prescaleOld ) );
#endif

    diff = L_max( diff_pos, diff_neg );

    IF( NE_16( diff, 0 ) )
    {
        prescale = s_min( prescale, diff );
    }

    prescale = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) );

    diff = sub( prescale, prescaleOld );
#ifdef BASOP_NOGLOB
    mem_fx[0] = L_shr_o( mem_fx[0], diff, &Overflow );
    move32();
    mem_fx[1] = L_shr_o( mem_fx[1], diff, &Overflow );
    move32();
    mem_fx[2] = L_shr_o( mem_fx[2], diff, &Overflow );
    move32();
    mem_fx[3] = L_shr_o( mem_fx[3], diff, &Overflow );
    move32();
#else
    mem_fx[0] = L_shr( mem_fx[0], diff );
    move32();
    mem_fx[1] = L_shr( mem_fx[1], diff );
    move32();
    mem_fx[2] = L_shr( mem_fx[2], diff );
    move32();
    mem_fx[3] = L_shr( mem_fx[3], diff );
    move32();
#endif
    mem_fx[4] = L_deposit_l( prescale_current_frame );
    move32();

    IF( EQ_32( Fs, 8000 ) )
    {
        /* hp filter 20Hz at 3dB for 8000KHz input sampling rate
           [b,a] = butter(2, 20.0/4000.0, 'high');
           b = [0.988954248067140  -1.977908496134280   0.988954248067140]
           a =[1.000000000000000  -1.977786483776764   0.978030508491796]*/
        a1_fx = 1061816033l /* 1.977786483776764 Q29*/;
        a2_fx = -525076131l /*-0.978030508491796 Q29*/;
        b1_fx = -1061881538l /*-1.977908496134280 Q29*/;
        b2_fx = 530940769l /* 0.988954248067140 Q29*/;
    }
    ELSE IF( EQ_32( Fs, 16000 ) )
    {
        /* hp filter 20Hz at 3dB for 16000KHz sampling rate
           [b,a] = butter(2, 20.0/8000.0, 'high');
           b =[ 0.994461788958195  -1.988923577916390   0.994461788958195]
           a =[1.000000000000000  -1.988892905899653   0.988954249933127] */
        a1_fx = 1067778748l /* 1.988892905899653 Q29*/;
        a2_fx = -530940770l /*-0.988954249933127 Q29*/;
        b1_fx = -1067795215l /*-1.988923577916390 Q29*/;
        b2_fx = 533897608l /* 0.994461788958195 Q29*/;
    }
    ELSE IF( EQ_32( Fs, 32000 ) )
    {
        /* hp filter 20Hz at 3dB for 32000KHz sampling rate
           [b,a] = butter(2, 20.0/16000.0, 'high');
           b =[0.997227049904470  -1.994454099808940   0.997227049904470]
           a =[1.000000000000000  -1.994446410541927   0.994461789075954]*/
        a1_fx = 1070760263l /* 1.994446410541927 Q29*/;
        a2_fx = -533897608l /*-0.994461789075954 Q29*/;
        b1_fx = -1070764392l /*-1.994454099808940 Q29*/;
        b2_fx = 535382196l /* 0.997227049904470 Q29*/;
    }
    ELSE
    {
        /* hp filter 20Hz at 3dB for 48000KHz sampling rate
           [b,a] = butter(2, 20.0/24000.0, 'high');
           b =[ 0.998150511190452  -1.996301022380904   0.998150511190452]
           a =[1.000000000000000  -1.996297601769122   0.996304442992686]*/
        a1_fx = 1071754114l /* 1.996297601769122 Q29*/;
        a2_fx = -534886875l /*-0.996304442992686 Q29*/;
        b1_fx = -1071755951l /*-1.996301022380904 Q29*/;
        b2_fx = 535877975l /* 0.998150511190452 Q29*/;
    }
    move32();
    move32();
    move32();
    move32();
    Word64 W_sum, W_y0, W_y1, W_y2;
    Word32 x0, x1, x2;

    W_sum = W_mult_32_32( b2_fx, mem_fx[2] );       /* b2*x2 */
    W_sum = W_mac_32_32( W_sum, b1_fx, mem_fx[3] ); /* b1*x1 */
    x2 = L_shr( signal_fx[0], prescale );
    W_sum = W_mac_32_32( W_sum, b2_fx, x2 );        /* b2*x0 */
    W_sum = W_mac_32_32( W_sum, mem_fx[0], a2_fx ); /* y2*a2 */
    W_sum = W_mac_32_32( W_sum, mem_fx[1], a1_fx ); /* y1*a1 */
    W_y2 = W_shl( W_sum, HP20_COEFF_SCALE );
    signal_fx[0] = W_extract_h( W_shl( W_y2, prescale ) );
    move32();

    W_sum = W_mult_32_32( b2_fx, mem_fx[3] ); /* b2*x2 */
    W_sum = W_mac_32_32( W_sum, b1_fx, x2 );  /* b1*x1 */
    x1 = L_shr( signal_fx[1], prescale );
    W_sum = W_mac_32_32( W_sum, b2_fx, x1 );                  /* b2*x0 */
    W_sum = W_mac_32_32( W_sum, mem_fx[1], a2_fx );           /* y2*a2 */
    W_sum = W_mac_32_32( W_sum, W_extract_h( W_y2 ), a1_fx ); /* y1*a1 */
    W_y1 = W_shl( W_sum, HP20_COEFF_SCALE );
    signal_fx[1] = W_extract_h( W_shl( W_y1, prescale ) );
    move32();

    diff = sub( prescale_current_frame, prescale );
    W_y1 = W_shr( W_y1, diff );
    W_y2 = W_shr( W_y2, diff );
    x2 = L_shr( x2, diff );
    x1 = L_shr( x1, diff );

    FOR( i = 2; i < lg; i++ )
    {
        W_sum = W_mult_32_32( b2_fx, x2 );       /* b2*x2 */
        W_sum = W_mac_32_32( W_sum, b1_fx, x1 ); /* b1*x1 */
        x0 = L_shr( signal_fx[i], prescale_current_frame );
        W_sum = W_mac_32_32( W_sum, b2_fx, x0 );                  /* b2*x0 */
        W_sum = W_mac_32_32( W_sum, W_extract_h( W_y2 ), a2_fx ); /* y2*a2 */
        W_sum = W_mac_32_32( W_sum, W_extract_h( W_y1 ), a1_fx ); /* y1*a1 */
        W_y0 = W_shl( W_sum, HP20_COEFF_SCALE );

        signal_fx[i] = W_extract_h( W_shl( W_y0, prescale_current_frame ) );
        move32();

        x2 = x1;
        x1 = x0;
        W_y2 = W_y1;
        W_y1 = W_y0;

        move32();
        move32();
        move64();
        move64();
    }

    mem_fx[0] = W_extract_h( W_y2 );
    mem_fx[1] = W_extract_h( W_y1 );
    mem_fx[2] = x2;
    mem_fx[3] = x1;

    move32();
    move32();
    move32();
    move32();

    return;
}
#else
void hp20_fix32(
    Word32 signal_fx[],
    const Word16 lg,
@@ -620,3 +795,4 @@ void hp20_fix32(
    return;
}
#endif
#endif
+7 −0
Original line number Diff line number Diff line
@@ -1085,6 +1085,13 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx(
    Word32 *data                                                 /* i/o: transport channels/output synthesis signal                  */
);

void ivas_jbm_dec_feed_tc_to_renderer_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                      */
    const int16_t nSamplesForRendering,                         /* i  : number of TC samples available for rendering                */
    int16_t *nSamplesResidual,                                  /* o  : number of samples not fitting into the renderer grid and buffer for the next call*/
    Word32 *data                                                 /* i/o: transport channels/output synthesis signal                  */
);

ivas_error ivas_jbm_dec_set_discard_samples(
    Decoder_Struct *st_ivas                                     /* i/o: main IVAS decoder structre                                  */
);
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@
#define FIX_818_COMPLEXITY_IMPROV /* Fix for issue 818 */
#define FIX_805_VERIFICATION /* Fix for issue 805 */
#define FIX_827_HIGH_MLD /* Fix for issue 827 */
#define HP20_FIX32_RECODING /* Improved hp20 filtering code */
#endif
#define ISM_DISABLE
#define FIX_TMP_714
+0 −8
Original line number Diff line number Diff line
@@ -1454,12 +1454,6 @@ void open_decoder_LPD_ivas_fx(
    IF( st->hTECDec != NULL )
    {
        /*constraint for adaptive bpf, otherwise parameter estimation and post-processing not time aligned*/
        if ( ( st->tcxonly == 0 ) )
        {
            // To be added later
            // assert(0 == (st->hTcxCfg->lfacnext > 0 ? st->hTcxCfg->lfacnext : 0));
        }

        resetTecDec_Fx( st->hTECDec );
    }

@@ -1624,8 +1618,6 @@ void open_decoder_LPD_ivas_fx(

            IF( st->hTcxCfg != NULL )
            {
                hHQ_core->Q_old_wtda = -1; /*To be removed later when hHQ_core->Q_old_wtda vaue is updated*/
                move16();
                Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->syn_OverlFB, st->hTcxCfg->tcx_mdct_window_lengthFB, negate( add( hHQ_core->Q_old_wtda, TCX_IMDCT_HEADROOM ) ) );
                *Q_syn_OverlFB = *Q_old_out;
                move16();
+8 −5
Original line number Diff line number Diff line
@@ -3826,9 +3826,12 @@ void decoder_tcx_ivas_fx(
    /* Scaling down buffers for decoder_tcx_imdct_fx*/
    Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, 1 );                              // Scaling to Q_syn
    Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, 1 );                                 // Scaling to Q_syn
    Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, negate( st->hHQ_core->Q_old_out ) );    // Scaling to Q_syn
    Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, negate( st->hHQ_core->Q_old_out ) ); // Scaling to Q_syn
    st->hHQ_core->Q_old_out = 0;
    Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, negate( st->hHQ_core->Q_old_wtda ) );       // Scaling to Q_syn
    Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, negate( st->hHQ_core->Q_old_wtda_LB ) ); // Scaling to Q_syn
    st->hHQ_core->Q_old_wtda = 0;
    move16();
    st->hHQ_core->Q_old_wtda_LB = 0;
    move16();

    Scale_sig( st->hTcxDec->old_syn_Overl, 320, 1 ); // Scaling to Q_syn
    Copy_Scale_sig_16_32_no_sat( st->old_Aq_12_8_fx, st->old_Aq_12_8_fx_32, M + 1, ( sub( 28, ( sub( 15, norm_s( sub( st->old_Aq_12_8_fx[0], 1 ) ) ) ) ) ) );
Loading