Commit 207a173c authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'remove_redundant_code_1' into 'main'

Replaces hFdCngDec_fx with hFdCngDec handle.

See merge request !136
parents db907cfc ddbd4ee3
Loading
Loading
Loading
Loading
Loading
+17 −17
Original line number Diff line number Diff line
@@ -623,7 +623,7 @@ ivas_error acelp_core_dec_fx(
            {
                IF( EQ_32(st_fx->core_brate,SID_2k40) && NE_16(st_fx->element_mode, IVAS_CPE_MDCT) )
                {
                    FdCng_decodeSID(st_fx->hFdCngDec_fx->hFdCngCom, st_fx);
                    FdCng_decodeSID(st_fx->hFdCngDec->hFdCngCom, st_fx);
                    *sid_bw=0;
                    move16();
                }                                                                    
@@ -655,7 +655,7 @@ ivas_error acelp_core_dec_fx(
#endif
                generate_comfort_noise_dec( NULL, NULL, NULL, st_fx, &(st_fx->Q_exc), 2, -1 );

                FdCng_exc(st_fx->hFdCngDec_fx->hFdCngCom, &st_fx->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx, st_fx->first_CNG, st_fx->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx);
                FdCng_exc(st_fx->hFdCngDec->hFdCngCom, &st_fx->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx, st_fx->first_CNG, st_fx->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx);

                Copy( exc2_fx, exc3_fx, st_fx->L_frame );
            }
@@ -1402,7 +1402,7 @@ ivas_error acelp_core_dec_fx(
    test();
    test();
    test();
    IF((st_fx->hFdCngDec_fx != NULL || EQ_16(st_fx->idchan, 1)) && NE_16(st_fx->element_mode, IVAS_CPE_MDCT))
    IF((st_fx->hFdCngDec != NULL || EQ_16(st_fx->idchan, 1)) && NE_16(st_fx->element_mode, IVAS_CPE_MDCT))
    {
        IF(EQ_16(st_fx->element_mode, IVAS_CPE_TD) || st_fx->flag_cna || (EQ_16(st_fx->cng_type, FD_CNG) && LE_32(st_fx->total_brate, ACELP_32k)) || (EQ_16(st_fx->cng_type, LP_CNG) && LE_32(st_fx->total_brate, SID_2k40)))
        {
@@ -1414,18 +1414,18 @@ ivas_error acelp_core_dec_fx(
                (EQ_16(st_fx->cng_type, LP_CNG) && LE_32(st_fx->total_brate, SID_2k40))))
            {
                /*Noisy speech detector*/
                noisy_speech_detection(st_fx->hFdCngDec_fx, st_fx->VAD, syn_fx, st_fx->Q_syn);
                noisy_speech_detection(st_fx->hFdCngDec, st_fx->VAD, syn_fx, st_fx->Q_syn);

                st_fx->hFdCngDec_fx->hFdCngCom->likelihood_noisy_speech = mult_r(st_fx->hFdCngDec_fx->hFdCngCom->likelihood_noisy_speech, 32440/*0.99 Q15*/);
                IF(st_fx->hFdCngDec_fx->hFdCngCom->flag_noisy_speech != 0)
                st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r(st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440/*0.99 Q15*/);
                IF(st_fx->hFdCngDec->hFdCngCom->flag_noisy_speech != 0)
                {
                    st_fx->hFdCngDec_fx->hFdCngCom->likelihood_noisy_speech = add(st_fx->hFdCngDec_fx->hFdCngCom->likelihood_noisy_speech, 328/*0.01 Q15*/);
                    st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add(st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328/*0.01 Q15*/);
                    move16();
                }
            }
            IF(st_fx->idchan == 0)
            {
                st_fx->lp_noise = st_fx->hFdCngDec_fx->lp_noise;
                st_fx->lp_noise = st_fx->hFdCngDec->lp_noise;
                move32();
            }
            /*Noise estimate*/
@@ -1541,13 +1541,13 @@ ivas_error acelp_core_dec_fx(
#else
            IF(st_fx->flag_cna && NE_16(st_fx->coder_type_fx, AUDIO))
            {
                generate_masking_noise(syn_fx, st_fx->Q_syn, st_fx->hFdCngDec_fx->hFdCngCom, st_fx->hFdCngDec_fx->hFdCngCom->frameSize, 0);
                generate_masking_noise(syn_fx, st_fx->Q_syn, st_fx->hFdCngDec->hFdCngCom, st_fx->hFdCngDec->hFdCngCom->frameSize, 0);
            }
            ELSE IF(st_fx->flag_cna && st_fx->coder_type_fx == AUDIO && st_fx->last_core == ACELP_CORE && st_fx->last_coder_type_fx != AUDIO)
            {
                FOR(i = 0; i < st_fx->hFdCngDec_fx->hFdCngCom->frameSize / 2; i++)
                FOR(i = 0; i < st_fx->hFdCngDec->hFdCngCom->frameSize / 2; i++)
                {
                    syn_fx[i] = add(syn_fx[i], shr_r(mult_r(st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->hFdCngDec_fx->hFdCngCom->frameSize / 4], st_fx->hFdCngDec_fx->hFdCngCom->fftlenFac), -st_fx->Q_syn));
                    syn_fx[i] = add(syn_fx[i], shr_r(mult_r(st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->hFdCngDec->hFdCngCom->frameSize / 4], st_fx->hFdCngDec->hFdCngCom->fftlenFac), -st_fx->Q_syn));
                    move16();
                }
            }
@@ -1557,7 +1557,7 @@ ivas_error acelp_core_dec_fx(
        {
            FOR(i = 0; i < st_fx->L_frame / 2; i++)
            {
                syn_fx[i] = add(syn_fx[i], shr_r(st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4], -st_fx->Q_syn));
                syn_fx[i] = add(syn_fx[i], shr_r(st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4], -st_fx->Q_syn));
                move16();
            }
        }
@@ -1565,7 +1565,7 @@ ivas_error acelp_core_dec_fx(
        test();
        IF(st_fx->flag_cna == 0 || EQ_16(st_fx->coder_type_fx, AUDIO))
        {
            set16_fx(st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec_fx->hFdCngCom->fftlen);
            set16_fx(st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec->hFdCngCom->fftlen);
        }
#endif
    }
@@ -1664,15 +1664,15 @@ ivas_error acelp_core_dec_fx(
        test();
        IF(!st_fx->cng_sba_flag || EQ_16(st_fx->element_mode, IVAS_CPE_MDCT))
        {
            IF((EQ_32(st_fx->core_brate, FRAME_NO_DATA) || EQ_32(st_fx->core_brate, SID_2k40)) && (EQ_16(st_fx->cng_type, FD_CNG)) && (LT_16(st_fx->hFdCngDec_fx->hFdCngCom->numCoreBands, st_fx->cldfbSyn_fx->no_channels)))
            IF((EQ_32(st_fx->core_brate, FRAME_NO_DATA) || EQ_32(st_fx->core_brate, SID_2k40)) && (EQ_16(st_fx->cng_type, FD_CNG)) && (LT_16(st_fx->hFdCngDec->hFdCngCom->numCoreBands, st_fx->cldfbSyn_fx->no_channels)))
            {
                generate_comfort_noise_dec_hf(realBuffer, imagBuffer, &scaleFactor.hb_scale, st_fx);

                st_fx->cldfbSyn_fx->bandsToZero = 0;
                move16();
                if (LT_16(st_fx->hFdCngDec_fx->hFdCngCom->regularStopBand, st_fx->cldfbSyn_fx->no_channels))
                if (LT_16(st_fx->hFdCngDec->hFdCngCom->regularStopBand, st_fx->cldfbSyn_fx->no_channels))
                {
                    st_fx->cldfbSyn_fx->bandsToZero = sub(st_fx->cldfbSyn_fx->no_channels, st_fx->hFdCngDec_fx->hFdCngCom->regularStopBand);
                    st_fx->cldfbSyn_fx->bandsToZero = sub(st_fx->cldfbSyn_fx->no_channels, st_fx->hFdCngDec->hFdCngCom->regularStopBand);
                }
                st_fx->cldfbSyn_fx->lsb = st_fx->cldfbAna_fx->no_channels;
                move16();
@@ -1807,7 +1807,7 @@ ivas_error acelp_core_dec_fx(

    updt_dec_fx( st_fx, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors, old_bwe_exc_fx, gain_buf );

    IF( GT_32(st_fx->core_brate,SID_2k40) && st_fx->hTdCngDec != NULL && st_fx->hFdCngDec_fx != NULL)
    IF( GT_32(st_fx->core_brate,SID_2k40) && st_fx->hTdCngDec != NULL && st_fx->hFdCngDec != NULL)
    {
        /* update CNG parameters in active frames */
        cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame, &st_fx->hTdCngDec->ho_circ_ptr_fx, st_fx->hTdCngDec->ho_ener_circ_fx, &st_fx->hTdCngDec->ho_circ_size_fx, st_fx->hTdCngDec->ho_lsp_circ_fx,
+1 −1
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ ivas_error acelp_core_switch_dec_fx(

        IF ( st_fx->flag_cna != 0 )
        {
            generate_masking_noise( synth_intFreq, st_fx->Q_syn, st_fx->hFdCngDec_fx->hFdCngCom, 2*L_SUBFR, 0);
            generate_masking_noise( synth_intFreq, st_fx->Q_syn, st_fx->hFdCngDec->hFdCngCom, 2*L_SUBFR, 0);
        }

        /*----------------------------------------------------------------*
+11 −11
Original line number Diff line number Diff line
@@ -786,18 +786,18 @@ ivas_error amr_wb_dec_fx(
#else
        ApplyFdCng( syn_fx, st_fx->Q_syn, NULL, NULL, NULL, st_fx, 0, 0 );
#endif
        st_fx->hFdCngDec_fx->hFdCngCom->frame_type_previous = st_fx->m_frame_type;
        st_fx->hFdCngDec->hFdCngCom->frame_type_previous = st_fx->m_frame_type;

        /*Noisy speech detector*/
        noisy_speech_detection(st_fx->hFdCngDec_fx, st_fx->VAD, syn_fx, st_fx->Q_syn);
        noisy_speech_detection(st_fx->hFdCngDec, st_fx->VAD, syn_fx, st_fx->Q_syn);

        st_fx->hFdCngDec_fx->hFdCngCom->likelihood_noisy_speech = mult_r(st_fx->hFdCngDec_fx->hFdCngCom->likelihood_noisy_speech, 32440/*0.99 Q15*/);
        IF ( st_fx->hFdCngDec_fx->hFdCngCom->flag_noisy_speech != 0 )
        st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r(st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440/*0.99 Q15*/);
        IF ( st_fx->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 )
        {
            st_fx->hFdCngDec_fx->hFdCngCom->likelihood_noisy_speech = add(st_fx->hFdCngDec_fx->hFdCngCom->likelihood_noisy_speech, 328/*0.01 Q15*/);
            st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add(st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328/*0.01 Q15*/);
            move16();
        }
        st_fx->lp_noise = st_fx->hFdCngDec_fx->lp_noise;
        st_fx->lp_noise = st_fx->hFdCngDec->lp_noise;
        move16();

        test();
@@ -805,18 +805,18 @@ ivas_error amr_wb_dec_fx(
        {
            flag_cna = 1;
            move16();
            generate_masking_noise( syn_fx, st_fx->Q_syn, st_fx->hFdCngDec_fx->hFdCngCom, st_fx->hFdCngDec_fx->hFdCngCom->frameSize, AMR_WB_CORE );
            generate_masking_noise( syn_fx, st_fx->Q_syn, st_fx->hFdCngDec->hFdCngCom, st_fx->hFdCngDec->hFdCngCom->frameSize, AMR_WB_CORE );
        }
        ELSE IF ( st_fx->flag_cna )
        {
            generate_masking_noise_update_seed( st_fx->hFdCngDec_fx->hFdCngCom );
            generate_masking_noise_update_seed( st_fx->hFdCngDec->hFdCngCom );
        }

        /*Copy(syn+L_FRAME-M-1, st_fx->syn, M+1);*/
    }
    ELSE IF ( st_fx->flag_cna )
    {
        generate_masking_noise_update_seed( st_fx->hFdCngDec_fx->hFdCngCom );
        generate_masking_noise_update_seed( st_fx->hFdCngDec->hFdCngCom );
    }


@@ -829,11 +829,11 @@ ivas_error amr_wb_dec_fx(
        {
            FOR (i=0; i < L_FRAME/2; i++)
            {
                syn_fx[i] = add( syn_fx[i], shr_r( st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth2[i+5*L_FRAME/4], -st_fx->Q_syn ) );
                syn_fx[i] = add( syn_fx[i], shr_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i+5*L_FRAME/4], -st_fx->Q_syn ) );
                move16();
            }
        }
        set16_fx( st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth2, 0, shl(L_FRAME,1) );
        set16_fx( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, shl(L_FRAME,1) );
    }

    /*----------------------------------------------------------------*
+10 −10
Original line number Diff line number Diff line
@@ -1018,8 +1018,8 @@ ivas_error core_switching_pre_dec_fx(
    test();
    test();
    test();
    IF( st_fx->hFdCngDec_fx && ((NE_16(st_fx->last_L_frame,st_fx->L_frame))||
                                (NE_16(st_fx->hFdCngDec_fx->hFdCngCom->frameSize,st_fx->L_frame)) ||
    IF( st_fx->hFdCngDec && ((NE_16(st_fx->last_L_frame,st_fx->L_frame))||
                                (NE_16(st_fx->hFdCngDec->hFdCngCom->frameSize,st_fx->L_frame)) ||
                                st_fx->ini_frame == 0 || NE_16(st_fx->bwidth, st_fx->last_bwidth) ))
    {

@@ -1035,15 +1035,15 @@ ivas_error core_switching_pre_dec_fx(
                tmp = ACELP_9k60;
                move32();
            }
            configureFdCngDec(st_fx->hFdCngDec_fx, st_fx->bwidth, tmp, st_fx->L_frame, st_fx->last_L_frame, st_fx->element_mode );
            configureFdCngDec(st_fx->hFdCngDec, st_fx->bwidth, tmp, st_fx->L_frame, st_fx->last_L_frame, st_fx->element_mode );
        }
        ELSE
        {
            configureFdCngDec(st_fx->hFdCngDec_fx, 1, ACELP_8k00, st_fx->L_frame, st_fx->last_L_frame, st_fx->element_mode);
            configureFdCngDec(st_fx->hFdCngDec, 1, ACELP_8k00, st_fx->L_frame, st_fx->last_L_frame, st_fx->element_mode);

            if( st_fx->VAD )
            {
                st_fx->hFdCngDec_fx->hFdCngCom->CngBitrate = st_fx->total_brate;
                st_fx->hFdCngDec->hFdCngCom->CngBitrate = st_fx->total_brate;
                move32();
            }
        }
@@ -1056,26 +1056,26 @@ ivas_error core_switching_pre_dec_fx(
#ifdef IVAS_CODE_SWITCHING
            IF (EQ_16(st_fx->element_mode, IVAS_CPE_DFT) || EQ_16(st_fx->element_mode, IVAS_CPE_TD))
            {
                lerp(st_fx->hFdCngDec_fx->hFdCngCom->olapBufferAna + st_fx->last_L_frame, st_fx->hFdCngDec_fx->hFdCngCom->olapBufferAna + st_fx->L_frame, st_fx->L_frame, st_fx->last_L_frame);
                lerp(st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->last_L_frame, st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->L_frame, st_fx->L_frame, st_fx->last_L_frame);
            }
#endif
            lerp(st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth2, st_fx->L_frame * 2, st_fx->last_L_frame * 2);
            lerp(st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->L_frame * 2, st_fx->last_L_frame * 2);
            test();
            IF( LE_32(st_fx->total_brate,SID_2k40)&&LE_32(st_fx->last_total_brate,SID_2k40))
            {
                lerp( st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth, st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth, st_fx->L_frame*2, st_fx->last_L_frame*2 );
                lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth, st_fx->L_frame*2, st_fx->last_L_frame*2 );
                IF( EQ_16(st_fx->L_frame, L_FRAME))
                {
                    FOR( i=0; i < st_fx->L_frame*2; i++ )
                    {
                        st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth[i] = mult_r( st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth[i], 20480 );
                        st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i], 20480 );
                    }
                }
                ELSE
                {
                    FOR( i=0; i < st_fx->L_frame*2; i++ )
                    {
                        st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth[i] = mult_r( shl(st_fx->hFdCngDec_fx->hFdCngCom->olapBufferSynth[i],1), 26214 );
                        st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( shl(st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i],1), 26214 );
                    }
                }
            }
+9 −9
Original line number Diff line number Diff line
@@ -238,16 +238,16 @@ void decode_frame_type(Decoder_State *st
                L_tmp = ACELP_9k60;
                move32();
            }
            configureFdCngDec( st->hFdCngDec_fx, st->bwidth, L_tmp, st->L_frame, st->last_L_frame, st->element_mode);
            configureFdCngDec( st->hFdCngDec, st->bwidth, L_tmp, st->L_frame, st->last_L_frame, st->element_mode);
            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)))
            {
                lerp( st->hFdCngDec_fx->hFdCngCom->olapBufferSynth2, st->hFdCngDec_fx->hFdCngCom->olapBufferSynth2, st->L_frame*2, st->last_L_frame*2 );
                lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->L_frame*2, st->last_L_frame*2 );
                test();
                IF ( EQ_16(st->m_frame_type, SID_FRAME)&&NE_16(st->hFdCngDec_fx->hFdCngCom->frame_type_previous,ACTIVE_FRAME))
                IF ( EQ_16(st->m_frame_type, SID_FRAME)&&NE_16(st->hFdCngDec->hFdCngCom->frame_type_previous,ACTIVE_FRAME))
                {
                    lerp( st->hFdCngDec_fx->hFdCngCom->olapBufferSynth, st->hFdCngDec_fx->hFdCngCom->olapBufferSynth, st->L_frame*2, st->last_L_frame*2 );
                    lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth, st->hFdCngDec->hFdCngCom->olapBufferSynth, st->L_frame*2, st->last_L_frame*2 );
#ifdef IVAS_CODE_CNG
                    lerp(hStereoCng->olapBufferSynth22, hStereoCng->olapBufferSynth22, st->L_frame * 2, st->last_L_frame * 2);
#endif
@@ -255,22 +255,22 @@ void decode_frame_type(Decoder_State *st
                    {
                        FOR( n=0; n < st->L_frame*2; n++ )
                        {
                            st->hFdCngDec_fx->hFdCngCom->olapBufferSynth[n] = mult_r( st->hFdCngDec_fx->hFdCngCom->olapBufferSynth[n], 20480 );
                            st->hFdCngDec->hFdCngCom->olapBufferSynth[n] = mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth[n], 20480 );
                        }
                    }
                    ELSE
                    {
                        FOR( n=0; n < st->L_frame*2; n++ )
                        {
                            st->hFdCngDec_fx->hFdCngCom->olapBufferSynth[n] = mult_r( shl(st->hFdCngDec_fx->hFdCngCom->olapBufferSynth[n],1), 26214 );
                            st->hFdCngDec->hFdCngCom->olapBufferSynth[n] = mult_r( shl(st->hFdCngDec->hFdCngCom->olapBufferSynth[n],1), 26214 );
                        }
                    }
                }
            }
            IF ( NE_16(st->bwidth,st->last_bwidth))
            {
                st->hFdCngDec_fx->hFdCngCom->msFrCnt_init_counter = 0;
                st->hFdCngDec_fx->hFdCngCom->init_old = 32767;
                st->hFdCngDec->hFdCngCom->msFrCnt_init_counter = 0;
                st->hFdCngDec->hFdCngCom->init_old = 32767;
            }

            /* Reconf BPF */
@@ -516,7 +516,7 @@ Word16 dec_acelp_tcx_frame(

        IF ( EQ_16(st->m_frame_type,SID_FRAME))
        {
            FdCng_decodeSID(st->hFdCngDec_fx->hFdCngCom, st);
            FdCng_decodeSID(st->hFdCngDec->hFdCngCom, st);
        }

        /* updates */
Loading