Commit 46a79238 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

BASOP and instrumentation changes

[x] Added missed BASOPs and instrumentation code
[x] Few BASOPs are to be updated as per discussion with PC group.
Changes will be made through subsequent MRs.
parent c521a983
Loading
Loading
Loading
Loading
Loading
+107 −7
Original line number Diff line number Diff line
@@ -81,8 +81,12 @@ ivas_error core_switching_pre_dec_ivas_fx(
    Word16 exp = 25;

    error = IVAS_ERR_OK;
    move32();

    /* Codec mode switching */
    test();
    test();
    test();
    IF( EQ_16( st->last_codec_mode, MODE2 ) || ( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) )
    {
#ifndef FIX_770_DISCONTINUITIES_SW_TCX2ACELP
@@ -119,6 +123,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
        {
            st->hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10  */
            st->hBPF->pst_mem_deemp_err_fx = 0;
            move16();
        }
#endif
        st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) );
@@ -136,6 +141,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
        move16();
        set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) );

        test();
        IF( st->hBWE_TD != NULL && NE_16( st->last_core, ACELP_CORE ) )
        {
#ifdef MSAN_FIX
@@ -155,6 +161,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
        st->igf = 0;
        move16();

        test();
        IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
        {
            hf_synth_reset_fx( st->hBWE_zero );
@@ -196,6 +203,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
            move32();
        }

        test();
        IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) )
        {
            IF( EQ_16( st->element_mode, EVS_MONO ) )
@@ -238,6 +246,8 @@ ivas_error core_switching_pre_dec_ivas_fx(
            delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS );

            /*TODO To be tested:control not entering the block*/
            test();
            test();
            IF( !st->last_con_tcx && EQ_16( st->last_core_bfi, ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) )
            {
                /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/
@@ -281,6 +291,8 @@ ivas_error core_switching_pre_dec_ivas_fx(
                Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 );
            }

            test();
            test();
            IF( !st->last_con_tcx && EQ_16( st->last_core_bfi, ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) )
            {
                lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples_fx + delay_comp, output_frame / 2, st->last_L_frame / 2 );
@@ -298,6 +310,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
    /*FEC*/
    IF( LE_16( st->L_frame, L_FRAME16k ) )
    {
        test();
        IF( LE_16( st->last_L_frame, L_FRAME16k ) && NE_16( st->core, HQ_CORE ) )
        {
            IF( NE_16( st->L_frame, st->last_L_frame ) )
@@ -325,6 +338,8 @@ ivas_error core_switching_pre_dec_ivas_fx(

    /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores
       within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */
    test();
    test();
    IF( EQ_16( st->core, ACELP_CORE ) && ( NE_16( st->last_core, ACELP_CORE ) || NE_16( st->last_codec_mode, MODE2 ) ) )
    {
        st->last_ppp_mode_dec = 0;
@@ -334,6 +349,9 @@ ivas_error core_switching_pre_dec_ivas_fx(
    }

    /* Handle state reset of stat_noise_uv_mod memory */
    test();
    test();
    test();
    IF( EQ_16( st->core, ACELP_CORE ) && ( NE_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || LE_32( st->last_total_brate, PPP_NELP_2k80 ) ) )
    {
        st->act_count = 3;
@@ -342,9 +360,21 @@ ivas_error core_switching_pre_dec_ivas_fx(
        move16();
    }

    test();
    test();
    test();
    test();
    test();
    test();
    test();
    test();
    test();
    test();
    test();
    IF( ( ( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && EQ_16( st->last_core, HQ_CORE ) ) || ( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( nchan_out, 2 ) &&
                                                                                                                        NE_32( st->core_brate, SID_2k40 ) && NE_32( st->core_brate, FRAME_NO_DATA ) && ( EQ_32( last_core_brate_st0, FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) ) )
    {
        test();
        IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) )
        {
            st->hPFstat->reset = 1;
@@ -368,6 +398,12 @@ ivas_error core_switching_pre_dec_ivas_fx(
            lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_12k8 );
        }

        test();
        test();
        test();
        test();
        test();
        test();
        IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_16( nchan_out, 2 ) && GT_32( st->core_brate, SID_2k40 ) && ( EQ_32( last_core_brate_st0, FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) && st->hTcxDec != NULL )
        {
            /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */
@@ -430,6 +466,8 @@ ivas_error core_switching_pre_dec_ivas_fx(
        cldfb_reset_memory_fx( st->cldfbSyn );

        /* reset TBE memories */
        test();
        test();
        IF( !st->last_con_tcx && !( ( EQ_16( st->last_core, HQ_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) )
        {
            set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC );
@@ -445,6 +483,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
            set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
        }

        test();
        IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
        {
            hf_synth_reset_fx( st->hBWE_zero );
@@ -459,6 +498,9 @@ ivas_error core_switching_pre_dec_ivas_fx(
        }
    }

    test();
    test();
    test();
    IF( ( EQ_16( st->core, ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) )
    {
        IF( st->hBWE_TD != NULL )
@@ -491,6 +533,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
        move16();
        move16();

        test();
        IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
        {
            hf_synth_reset_fx( st->hBWE_zero );
@@ -504,6 +547,9 @@ ivas_error core_switching_pre_dec_ivas_fx(
            set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
        }

        test();
        test();
        test();
        IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) )
        {
            /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */
@@ -514,14 +560,19 @@ ivas_error core_switching_pre_dec_ivas_fx(
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) );
            }
            Copy_Scale_sig_16_32( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, Q10 - Q_old_synthFB );
            Copy_Scale_sig_16_32( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) );
            Copy32( old_synthFB_fx + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset );
            st->cldfbAna->Q_cldfb_state = Q10;
            move16();
            IF( old_synthFB_fx )
            free( old_synthFB_fx );
        }
    }

    test();
    test();
    test();
    test();
    IF( EQ_16( st->core, HQ_CORE ) && ( EQ_16( st->last_core, ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) || ( ( NE_16( st->element_mode, EVS_MONO ) ) && ( NE_16( st->last_core, HQ_CORE ) ) ) ) )
    {
        set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB );
@@ -545,7 +596,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
        IF( NE_16( st->element_mode, EVS_MONO ) )
        {
            /* Estimate mem_env_delta to reinit env_stab */
            tmp_fx = L_max( 0, ENV_STAB_EST1_FX + Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ) + Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ); /*Q12*/
            tmp_fx = L_max( 0, L_add( ENV_STAB_EST1_FX, L_add( Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ), Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ) ) ); /*Q12*/

            st->hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */

@@ -609,6 +660,12 @@ ivas_error core_switching_pre_dec_ivas_fx(
    /*switch on CNA on active frames*/
    IF( EQ_16( st->element_mode, EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */
    {
        test();
        test();
        test();
        test();
        test();
        test();
        IF( st->VAD && ( ( NE_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, CNA_MAX_BRATE ) ) || ( EQ_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, ACELP_8k85 ) ) ) )
        {
            st->flag_cna = 1;
@@ -628,6 +685,10 @@ ivas_error core_switching_pre_dec_ivas_fx(
    }

    /* Reconfigure CNG */
    test();
    test();
    test();
    test();
    IF( st->hFdCngDec && ( NE_16( st->last_L_frame, st->L_frame ) || NE_16( st->hFdCngDec->hFdCngCom->frameSize, st->L_frame ) || EQ_16( st->ini_frame, 0 ) || NE_16( st->bwidth, st->last_bwidth ) ) )
    {
        /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/
@@ -645,24 +706,29 @@ ivas_error core_switching_pre_dec_ivas_fx(
                move32();
            }
        }
        test();
        test();
        IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->L_frame, L_FRAME16k ) && LE_16( st->last_L_frame, L_FRAME16k ) )
        {
            test();
            IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) )
            {
                lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame );
            }

            L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->L_frame * 2, st->last_L_frame * 2, Q_olapBufferSynth2 );
            L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 );

            test();
            IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) )
            {
                L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->L_frame * 2, st->last_L_frame * 2, Q_olapBufferSynth );
                L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth );

                IF( EQ_16( st->L_frame, L_FRAME ) )
                {
                    FOR( i = 0; i < shl( st->L_frame, 1 ); i++ )
                    {
                        st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ );
                        move32();
                    }
                }
                ELSE
@@ -670,6 +736,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
                    FOR( i = 0; i < shl( st->L_frame, 1 ); i++ )
                    {
                        st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ );
                        move32();
                    }
                }
            }
@@ -1682,6 +1749,8 @@ void bandwidth_switching_detect_ivas_fx(
    Decoder_State *st_fx /* i/o: encoder state structure */
)
{
    test();
    test();
    IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
    {
        /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */
@@ -1698,6 +1767,7 @@ void bandwidth_switching_detect_ivas_fx(
    test();
    test();
    test();
    test();
    IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) )
    {
        st_fx->bws_cnt1 = 0;
@@ -1932,6 +2002,9 @@ void ivas_bw_switching_pre_proc_fx(
        return;
    }

    test();
    test();
    test();
    IF( EQ_16( st->core, ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) )
    {
        /*----------------------------------------------------------------------*
@@ -1958,9 +2031,10 @@ void ivas_bw_switching_pre_proc_fx(

        tmp = getSqrtWord32( tmp );
        st->enerLL_fx = tmp;
        st->enerLL_fx_Q = ( Q + shift - 32 ) / 2;
        st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 );

        W_tmp = 0;
        move64();
        FOR( ; i < L_FRAME; i++ )
        {
            W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) );
@@ -1971,7 +2045,8 @@ void ivas_bw_switching_pre_proc_fx(
        tmp = L_shr( tmp, 7 );      // divide by 128
        tmp = getSqrtWord32( tmp );
        st->enerLH_fx = tmp;
        st->enerLH_fx_Q = ( Q + shift - 32 ) / 2;
        move32();
        st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 );
    }
    ELSE
    {
@@ -1985,9 +2060,12 @@ void ivas_bw_switching_pre_proc_fx(
            tmp = L_shr( L_tmp, 5 ); // divide by 32
            tmp = getSqrtWord32( tmp );
            st->enerLL_fx = tmp;
            move32();
            st->enerLL_fx_Q = Q_audio;
            move16();

            L_tmp = 0;
            move32();
            FOR( ; i < 64; i++ )
            {
                L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow );
@@ -1996,12 +2074,15 @@ void ivas_bw_switching_pre_proc_fx(
            tmp = L_shr( L_tmp, 5 ); // divide by 32
            tmp = getSqrtWord32( tmp );
            st->enerLH_fx = tmp;
            move32();
            st->enerLH_fx_Q = Q_audio;
            move16();
        }
        ELSE
        {
            Word32 tmp, L_tmp = 0;
            L_tmp = 0;
            move32();
            FOR( i = 0; i < L_FRAME / 2; i++ )
            {
                L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow );
@@ -2009,9 +2090,12 @@ void ivas_bw_switching_pre_proc_fx(
            tmp = L_shr( L_tmp, 5 ); // divide by 32
            tmp = getSqrtWord32( tmp );
            st->enerLL_fx = tmp;
            move32();
            st->enerLL_fx_Q = Q_audio;
            move16();

            L_tmp = 0;
            move32();
            FOR( ; i < L_FRAME; i++ )
            {
                L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow );
@@ -2019,15 +2103,25 @@ void ivas_bw_switching_pre_proc_fx(
            tmp = L_shr( L_tmp, 5 ); // divide by 32
            tmp = getSqrtWord32( tmp );
            st->enerLL_fx = tmp;
            move32();
            st->enerLL_fx_Q = Q_audio;
            move16();
        }
    }

    test();
    test();
    test();
    test();
    test();
    test();
    test();
    IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) )
    {
        // st->prev_ener_shb = 0.0f;

        st->prev_ener_shb_fx = 0;
        move16();
        IF( st->hBWE_FD != NULL )
        {
            // set_f( st->hBWE_FD->prev_SWB_fenv, 0, SWB_FENV );
@@ -2037,12 +2131,18 @@ void ivas_bw_switching_pre_proc_fx(
    ELSE IF( ( ( EQ_16( st->core, ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) )
    {
        st->attenu_fx = 3277;
        move16();
    }

    test();
    test();
    test();
    test();
    test();
    IF( EQ_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) )
    {
        st->prev_fractive = 0;
        st->prev_fractive = 0;
        move16();
    }

    return;
+25 −10
Original line number Diff line number Diff line
@@ -513,6 +513,9 @@ ivas_error core_switching_pre_dec_fx(
    hTcxDec = st_fx->hTcxDec;

    error = IVAS_ERR_OK;
    test();
    test();
    test();
    /* Codec switching */
    IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && GT_16( st_fx->element_mode, EVS_MONO ) ) )
    {
@@ -555,6 +558,7 @@ ivas_error core_switching_pre_dec_fx(
        move16();


        test();
        IF( hBWE_TD != NULL && NE_16( st_fx->last_core, ACELP_CORE ) )
        {
            hBWE_TD->prev_hb_synth_fx_exp = 31;
@@ -564,6 +568,7 @@ ivas_error core_switching_pre_dec_fx(
            hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
        }

        test();
        IF( GE_32( st_fx->output_Fs, 16000 ) && st_fx->hBWE_zero != NULL )
        {
            hf_synth_reset_fx( st_fx->hBWE_zero );
@@ -678,6 +683,9 @@ ivas_error core_switching_pre_dec_fx(
                cldfb_restore_memory( st_fx->cldfbSyn );
            }

            test();
            test();
            test();
            IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && EQ_16( st_fx->core, HQ_CORE ) )
            {
                lerp( hTcxDec->syn_Overl, hHQ_core->fer_samples_fx + delay_comp, shr( st_fx->output_frame_fx, 1 ), shr( st_fx->last_L_frame, 1 ) );
@@ -857,6 +865,7 @@ ivas_error core_switching_pre_dec_fx(

        /* reset TBE memories */
        test();
        test();

        IF( !st_fx->last_con_tcx && !( ( EQ_16( st_fx->last_core, HQ_CORE ) ) && GT_16( st_fx->element_mode, EVS_MONO ) ) )
        {
@@ -984,7 +993,7 @@ ivas_error core_switching_pre_dec_fx(
    /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */
    IF( hHQ_core != NULL )
    {
        hHQ_core->pastpre--;
        hHQ_core->pastpre = sub( hHQ_core->pastpre, 1 );
        IF( hHQ_core->pastpre <= 0 )
        {
            reset_preecho_dec_fx( hHQ_core );
@@ -1420,7 +1429,7 @@ ivas_error core_switching_post_dec_fx(
        set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, output_frame );

        test();
        if ( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) )
        IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) )
        {
            hBWE_FD->prev_mode = NORMAL;
            move16();
@@ -1578,7 +1587,7 @@ ivas_error core_switching_post_dec_ivas_fx(

    delta = 1;
    move16();
    if ( GE_16( output_frame, L_FRAME16k ) )
    IF( GE_16( output_frame, L_FRAME16k ) )
    {
        delta = shr( Fs_kHz, 3 );
    }
@@ -2015,7 +2024,7 @@ ivas_error core_switching_post_dec_ivas_fx(
    }

    /* reset TBE buffers */
    if ( hBWE_TD != NULL )
    IF( hBWE_TD != NULL )
    {
        /* reset SWB TBE buffers */
        test();
@@ -2143,13 +2152,13 @@ void core_switching_hq_prepare_dec_fx(
    IF( EQ_16( st_fx->last_L_frame, L_FRAME ) )
    {
        cbrate = L_add( st_fx->core_brate, 0 );
        if ( GT_32( st_fx->core_brate, ACELP_24k40 ) )
        IF( GT_32( st_fx->core_brate, ACELP_24k40 ) )
        {
            cbrate = L_add( ACELP_24k40, 0 );
        }

        /* subtract ACELP switching frame bits */
        if ( GE_32( st_fx->core_brate, ACELP_11k60 ) )
        IF( GE_32( st_fx->core_brate, ACELP_11k60 ) )
        {
            ( *num_bits ) = sub( ( *num_bits ), 1 ); /* LP_FLAG bit */
        }
@@ -2173,7 +2182,7 @@ void core_switching_hq_prepare_dec_fx(
        }

        /* subtract ACELP switching frame bits */
        if ( GE_32( st_fx->core_brate, ACELP_11k60 ) )
        IF( GE_32( st_fx->core_brate, ACELP_11k60 ) )
        {
            ( *num_bits ) = sub( ( *num_bits ), 1 ); /* LP_FLAG bit */
        }
@@ -2298,31 +2307,36 @@ static void smoothTransitionDtxToTcx_fx(
#endif

    filter_len = TRANSITION_SMOOTHING_LEN_16k;
    move16();
    IF( EQ_16( output_frame, L_FRAME32k ) )
    {
        filter_len = TRANSITION_SMOOTHING_LEN_32k;
        move16();
    }
    ELSE IF( EQ_16( output_frame, L_FRAME48k ) )
    {
        filter_len = TRANSITION_SMOOTHING_LEN_48k;
        move16();
    }

    /* prepare buffer */
    FOR( i = 0; i < filter_len / 2; i++ )
    {
        smoothing_input_buffer[i] = synth[0];
        move16();
    }
    Copy( synth, smoothing_input_buffer + filter_len / 2, add( shl( delay_comp, 1 ), shr( filter_len, 1 ) ) );
    Copy( synth, smoothing_input_buffer + shr( filter_len, 1 ), add( shl( delay_comp, 1 ), shr( filter_len, 1 ) ) );

    /* apply Mean filter */
    w = div_s( 1, filter_len );
    mem = 0;
    move32();
    FOR( i = 0; i < filter_len; i++ )
    {
        mem = L_add( mem, L_deposit_l( smoothing_input_buffer[i] ) );
    }
    // mem = sum32_fx( smoothing_input_buffer, filter_len );
    FOR( i = 0; i < 2 * delay_comp; i++ )
    FOR( i = 0; i < shl( delay_comp, 1 ); i++ )
    {
        smoothing_out_buffer[i] = extract_l( Mpy_32_16_1( mem, w ) );
        move16();
@@ -2343,7 +2357,8 @@ static void smoothTransitionDtxToTcx_fx(
    }

    fade_in = 0;
    FOR( ; i < 2 * delay_comp; i++ )
    move16();
    FOR( ; i < shl( delay_comp, 1 ); i++ )
    {
        synth[i] = add( mult_r( synth[i], fade_in ), mult_r( smoothing_out_buffer[i], sub( ONE_IN_Q15 - 1, fade_in ) ) );
        move16();
+2 −2
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ void dec_acelp_2t32_fx(

    code[i0] = -512;
    move16();
    if ( s_and( index, 0x800 ) == 0 )
    IF( s_and( index, 0x800 ) == 0 )
    {
        code[i0] = 512;
        move16();
@@ -66,7 +66,7 @@ void dec_acelp_2t32_fx(

    code[i1] = -512;
    move16();
    if ( s_and( index, 0x20 ) == 0 )
    IF( s_and( index, 0x20 ) == 0 )
    {
        code[i1] = 512;
        move16();
+34 −16
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ void dec_acelp_4t64_fx(
            FOR( k = 0; k < NB_TRACK_FCB_4T; k++ )
            {
                ind1[k] = get_next_indice( st_fx, 2 );
                move32();
            }
            FOR( k = 0; k < NB_TRACK_FCB_4T; k++ )
            {
@@ -194,10 +195,12 @@ void dec_acelp_4t64_fx(
            FOR( k = 0; k < NB_TRACK_FCB_4T - 2; k++ )
            {
                ind1[k] = get_next_indice( st_fx, 10 );
                move32();
            }
            FOR( k = 2; k < NB_TRACK_FCB_4T; k++ )
            {
                ind1[k] = get_next_indice( st_fx, 2 );
                move32();
            }
            FOR( k = 0; k < NB_TRACK_FCB_4T - 2; k++ )
            {
@@ -255,7 +258,7 @@ static void add_pulses_fx(
    {
        /* i = ((pos[k] & (NB_POS-1))*NB_TRACK) + track */
        logic16();
        i = shl( (Word16) ( pos[k] & ( NB_POS_FCB_4T - 1 ) ), 2 );
        i = shl( s_and( pos[k], ( NB_POS_FCB_4T - 1 ) ), 2 );

        logic16();
        IF( ( pos[k] & NB_POS_FCB_4T ) == 0 )
@@ -296,7 +299,7 @@ void dec_1p_N1_fx(
    /* i = ((index >> N) & 1); */
    i = L_shr( index, N ) & 1L;

    if ( i != 0 )
    IF ( i != 0 )
    {
        pos1 = add( pos1, NB_POS_FCB_4T );
    }
@@ -557,7 +560,7 @@ static void dec_6p_6N2_fx(
    offsetA = offsetB = j;
    move16();
    logic16();
    IF( ( L_shr( index, sub( n_6, 5 ) ) & 1L ) == 0 )
    IF( L_and( L_shr( index, sub( n_6, 5 ) ), 1L ) == 0 )
    {
        /* IF (((index >> ((6*N)-5)) & 1) == 0) */
        offsetA = offset;
@@ -649,7 +652,7 @@ IF( ( LT_16( pulse_pos_num, pulse_num ) ) && ( GT_16( pulse_pos_num, 1 ) ) )
        sector_6p_num[i] = 1;
        move16();
    }
    sector_6p_num[k]++;
    sector_6p_num[k] = add( sector_6p_num[k], 1 );
    move16();
}
ELSE{
@@ -690,20 +693,23 @@ static void fcb_decode_position_fx(
    FOR( i = 0; i < pos_num - 1; i++ )
    {
        /* k = PI_select_table[16-l][temp] - k ;*/
        k = L_sub( PI_select_table[16 - l][temp], k );
        k = L_sub( PI_select_table[L_sub( 16, l )][temp], k );

        FOR( ; PI_select_table[16 - l][temp] >= k; l += 2 );
        FOR( ; PI_select_table[L_sub( 16, l )][temp] >= k; l += 2 );

        if ( GT_32( k, PI_select_table[L_sub( 17, l )][temp] ) )
        IF ( GT_32( k, PI_select_table[L_sub( 17, l )][temp] ) )
        {
            l = L_sub( l, 1 );
        }

        /* k = PI_select_table[17-l][temp--] - k ;*/
        k = L_sub( PI_select_table[L_sub( 17, l )][temp--], k );
        k = L_sub( PI_select_table[L_sub( 17, l )][temp], k );
        temp = sub( temp, 1 );
        pos_vector[i] = extract_l( L_sub( l, 1 ) );
        move16();
    }
    pos_vector[i] = extract_l( L_add( l, k ) );
    move16();

    return;
}
@@ -768,10 +774,12 @@ void D_ACELP_decode_43bit_fx( UWord16 idxs[], Word16 code[], Word16 *pulsestrack
    set16_fx( code, 0, L_SUBFR );

    ps[3] = L_deposit_l( s_and( idxs[0], 0x1ff ) );
    move32();
    ps[2] = L_add( L_shl( s_and( idxs[1], 3 ), 7 ), L_shr( idxs[0], 9 ) );
    move32();
    joint_index = L_shr( L_add( L_shl( (Word32) idxs[2], 16 ), (Word32) idxs[1] ), 2 );

    if ( GE_32( joint_index, joint_offset ) )
    IF ( GE_32( joint_index, joint_offset ) )
    {
        joint_index = L_sub( joint_index, joint_offset );
    }
@@ -1052,6 +1060,7 @@ static void dec_1p_N1_L_subfr_fx(
    }

    pos[0] = pos1;
    move16();

    return;
}
@@ -1070,15 +1079,16 @@ static void add_pulses_L_subfr_fx(

    FOR( k = 0; k < nb_pulse; k++ )
    {
        i = shl( ( pos[k] & ( nb_pos - 1 ) ), 2 );
        IF( EQ_16( ( pos[k] & nb_pos ), 0 ) )
        i = shl( s_and( pos[k], sub( nb_pos, 1 ) ), 2 );
        IF( EQ_16( sub( pos[k], nb_pos ), 0 ) )
        {

            ptr[i] = add( ptr[i], 512 );
            move16();
        }
        ELSE
        {
            ptr[i] = sub( ptr[i], 512 );
            move16();
        }
    }

@@ -1097,6 +1107,7 @@ void dec_acelp_fast_fx(
    PulseConfig config;

    skip_track = -1;
    move16();
    set16_fx( code, 0, L_subfr );

    st->total_num_bits = extract_l( st->total_brate / FRAMES_PER_SEC );
@@ -1151,10 +1162,12 @@ void dec_acelp_fast_fx(
            IF( EQ_16( config.bits, 20 ) )
            {
                skip_track = -1;
                move16();
            }
            ELSE IF( EQ_16( (Word16) config.codetrackpos, (Word16) TRACKPOS_FIXED_FIRST ) )
            {
                skip_track = 0;
                move16();
            }
            ELSE IF( EQ_16( (Word16) config.codetrackpos, (Word16) TRACKPOS_FREE_ONE ) )
            {
@@ -1181,6 +1194,7 @@ void dec_acelp_fast_fx(
    ELSE /* L_subfr == 2*L_SUBFR */
    {
        config.bits = cdk_index;
        move16();

        IF( EQ_16( cdk_index, 14 ) )
        {
@@ -1190,19 +1204,23 @@ void dec_acelp_fast_fx(
            index = get_next_indice_fx( st, 14 );


            i0 = shl( shr( index, 7 ) & ( NB_POS_FCB_2T_128 - 1 ), 1 );
            i1 = add( shl( index & ( NB_POS_FCB_2T_128 - 1 ), 1 ), 1 );
            i0 = shl( s_and( shr( index, 7 ), ( NB_POS_FCB_2T_128 - 1 ) ), 1 );
            i1 = add( shl( s_and( index, ( NB_POS_FCB_2T_128 - 1 ) ), 1 ), 1 );

            code[i0] = -512;
            IF( EQ_16( ( index & 0x2000 ), 0 ) )
            move16();
            IF( EQ_16( s_and( index, 0x2000 ), 0 ) )
            {
                code[i0] = 512;
                move16();
            }

            code[i1] = -512;
            IF( EQ_16( ( index & 0x40 ), 0 ) )
            move16();
            IF( EQ_16( s_and( index, 0x40 ), 0 ) )
            {
                code[i1] = 512;
                move16();
            }
        }
        ELSE IF( EQ_16( cdk_index, 12 ) )
+65 −27

File changed.

Preview size limit exceeded, changes collapsed.

Loading