Commit ff84b4b1 authored by vaclav's avatar vaclav
Browse files

harmonize hTonalMDCTConc + remove a duplication of the handle

parent 10869930
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1075,7 +1075,7 @@ ivas_error amr_wb_dec_fx(
            move16();
        }

        waveform_adj2_fix( st_fx->hPlcInfo, st_fx->tonalMDCTconceal.secondLastPcmOut, synth_out_fx + tmps, tmps, add( extract_l( st_fx->hPlcInfo->nbLostCmpt ), 1 ), st_fx->bfi );
        waveform_adj2_fix( st_fx->hPlcInfo, st_fx->hTonalMDCTConc->secondLastPcmOut, synth_out_fx + tmps, tmps, add( extract_l( st_fx->hPlcInfo->nbLostCmpt ), 1 ), st_fx->bfi );
    }

    /* HP filter */
+8 −12
Original line number Diff line number Diff line
@@ -1034,28 +1034,24 @@ void open_decoder_LPD_fx(
    }

    /* PLC: [TCX: Tonal Concealment] */
#if 0
    PMT("handle to tonalMDCTconceal is missing")
#endif
    //#ifdef ADD_IVAS_HTONALMDCTCONC
    test();
    test();
    IF( /*st->ADD_IVAS_HTONALMDCTCONC != NULL &&*/ !( st->element_mode > EVS_MONO && NE_16( st->ini_frame, 0 ) && EQ_16( st->tonalMDCTconceal.nSamples, st->hTcxDec->L_frameTCX ) ) )
    IF( st->hTonalMDCTConc != NULL && !( st->element_mode > EVS_MONO && NE_16( st->ini_frame, 0 ) && EQ_16( st->hTonalMDCTConc->nSamples, st->hTcxDec->L_frameTCX ) ) )
    {
        st->tonalMDCTconceal.nScaleFactors = 0;
        st->hTonalMDCTConc->nScaleFactors = 0;
        move16();
        st->tonalMDCTconceal.nSamples = 0;
        st->hTonalMDCTConc->nSamples = 0;
        move16();
        st->tonalMDCTconceal.lastPcmOut = 0x0;
        st->hTonalMDCTConc->lastPcmOut = 0x0;
        move16();
        st->tonalMDCTconceal.q_lastPcmOut = Q15;
        st->hTonalMDCTConc->q_lastPcmOut = Q15;
        move16();
        st->tonalMDCTconceal.lastBlockData.tonalConcealmentActive = 0;
        st->hTonalMDCTConc->lastBlockData.tonalConcealmentActive = 0;
        move16();
        st->tonalMDCTconceal.lastBlockData.nSamples = 0;
        st->hTonalMDCTConc->lastBlockData.nSamples = 0;
        move16();

        TonalMDCTConceal_Init( &st->tonalMDCTconceal, hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg );
        TonalMDCTConceal_Init( st->hTonalMDCTConc, hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg );
    }
    st->last_tns_active = 0;
    move16();
+2 −2
Original line number Diff line number Diff line
@@ -634,7 +634,7 @@ void decoder_LPD_fx(

        /* PLC: [TCX: Tonal Concealment] */
        /* Signal that this frame is not TCX */
        TonalMDCTConceal_UpdateState( &st->tonalMDCTconceal, 0, 0, 0, 0 );
        TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, 0, 0, 0, 0 );

        IF( bfi == 0 )
        {
@@ -771,7 +771,7 @@ void decoder_LPD_fx(

        IF( !bfi )
        {
            TonalMDCTConceal_SaveTimeSignal( &st->tonalMDCTconceal, synthFB, L_frameTCX );
            TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, L_frameTCX );
        }
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
        decoder_tcx_post_fx( st, synth, synthFB, Aq, bfi, 0 );
+10 −13
Original line number Diff line number Diff line
@@ -821,8 +821,7 @@ void decoder_tcx_fx(

    IF( bfi == 0 )
    {
        TonalMDCTConceal_SaveFreqSignal( &st->tonalMDCTconceal, x, x_e, L_frameTCX,
                                         L_frame, gainlpc2, gainlpc2_e, gain_tcx_e );
        TonalMDCTConceal_SaveFreqSignal( st->hTonalMDCTConc, x, x_e, L_frameTCX, L_frame, gainlpc2, gainlpc2_e, gain_tcx_e );
    }
    ELSE
    {
@@ -852,8 +851,8 @@ void decoder_tcx_fx(
                Word16 exp1, exp2;
                Word32 E_2ndlast, E_last;

                E_2ndlast = CalculateAbsEnergy_fx( 1, &( st->tonalMDCTconceal.lastBlockData.spectralData[0] ), infoIGFStartLine, &exp2 );
                E_last = CalculateAbsEnergy_fx( 1, &( st->tonalMDCTconceal.lastBlockData.spectralData[1] ), infoIGFStartLine, &exp1 );
                E_2ndlast = CalculateAbsEnergy_fx( 1, &( st->hTonalMDCTConc->lastBlockData.spectralData[0] ), infoIGFStartLine, &exp2 );
                E_last = CalculateAbsEnergy_fx( 1, &( st->hTonalMDCTConc->lastBlockData.spectralData[1] ), infoIGFStartLine, &exp1 );

                BASOP_Util_Divide_MantExp( extract_h( E_2ndlast ), exp2, extract_h( E_last ), exp1, &tmp1, &tmp2 );

@@ -865,7 +864,7 @@ void decoder_tcx_fx(
                    FOR( i = 0; i < infoIGFStartLine; i += 2 )
                    {
                        move32();
                        st->tonalMDCTconceal.lastBlockData.spectralData[i] = st->tonalMDCTconceal.lastBlockData.spectralData[i + 1];
                        st->hTonalMDCTConc->lastBlockData.spectralData[i] = st->hTonalMDCTConc->lastBlockData.spectralData[i + 1];
                    }
                }
                ELSE IF( LT_16( tmp1, 4096 /*0.5 in Q13*/ ) )
@@ -873,7 +872,7 @@ void decoder_tcx_fx(
                    FOR( i = 0; i < infoIGFStartLine; i += 2 )
                    {
                        move32();
                        st->tonalMDCTconceal.lastBlockData.spectralData[i + 1] = st->tonalMDCTconceal.lastBlockData.spectralData[i];
                        st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData[i];
                    }
                }
            }
@@ -892,7 +891,7 @@ void decoder_tcx_fx(

            tcxGetNoiseFillingTilt( A, M, L_frame, tmp, &noiseTiltFactor );

            TonalMDCTConceal_InsertNoise( &st->tonalMDCTconceal, x, &x_e, st->tonal_mdct_plc_active, &st->seed_tcx_plc,
            TonalMDCTConceal_InsertNoise( st->hTonalMDCTConc, x, &x_e, st->tonal_mdct_plc_active, &st->seed_tcx_plc,
                                          noiseTiltFactor, f,
#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT
                                          concealment_noise,
@@ -980,7 +979,7 @@ void decoder_tcx_fx(
    test();
    IF( bfi && st->tonal_mdct_plc_active )
    {
        TonalMDCTConceal_Apply( &st->tonalMDCTconceal, x, &x_e );
        TonalMDCTConceal_Apply( st->hTonalMDCTConc, x, &x_e );
    }

    tmp32 = L_deposit_h( 0 );
@@ -996,11 +995,8 @@ void decoder_tcx_fx(
        tmp8 = 1;
        move16();
    }
    TonalMDCTConceal_UpdateState( &st->tonalMDCTconceal,
                                  L_frameTCX,
                                  tmp32,
                                  bfi,
                                  tmp8 );

    TonalMDCTConceal_UpdateState( st->hTonalMDCTConc, L_frameTCX, tmp32, bfi, tmp8 );

    IF( st->enablePlcWaveadjust )
    {
@@ -1013,6 +1009,7 @@ void decoder_tcx_fx(
            /* x_e =31-x_scale; */
            concealment_decode_fix( core, x, &x_e, st->hPlcInfo );
        }

        /* update spectrum buffer, tonality flag, etc. */
        concealment_update_x( bfi, core, st->tonality_flag, x, &x_e, st->hPlcInfo );
    }
+6 −28
Original line number Diff line number Diff line
@@ -439,8 +439,6 @@ Word16 GetPLCModeDecision_ivas_fx(
                test();
                test();
                test();
                // PMT("handle to tonalMDCTconceal is missing")
                //#ifdef ADD_IVAS_HTONALMDCTCONC
                IF( ( st->hTonalMDCTConc != NULL && EQ_16( st->last_core, TCX_20_CORE ) ) && ( EQ_16( st->second_last_core, TCX_20_CORE ) ) && ( ( LE_32( st->old_fpitch, L_deposit_h( shr( st->L_frame, 1 ) ) ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) )
                    /* it is fine to call the detection even if no ltp information
                       is available, meaning that st->old_fpitch ==
@@ -454,12 +452,8 @@ Word16 GetPLCModeDecision_ivas_fx(
                    {
                        pitch = L_add( st->old_fpitch, 0 ); /*Q16*/
                    }
                    // TonalMDCTConceal_Detect_ivas_fx(&st->tonalMDCTconceal, pitch,  &numIndices
                    //     , (st->element_mode == IVAS_CPE_MDCT ? &(st->hTcxCfg->psychParamsTCX20) : st->hTcxCfg->psychParamsCurrent)
                    //);

                    TonalMDCTConceal_Detect_ivas_fx( st->hTonalMDCTConc, pitch, &numIndices, ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ),
                                                     st->element_mode );
                    TonalMDCTConceal_Detect_ivas_fx( st->hTonalMDCTConc, pitch, &numIndices, ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ), st->element_mode );

                    test();
                    test();
@@ -554,6 +548,7 @@ Word16 GetPLCModeDecision_fx(
            core = st->last_core_bfi;
            move16();
        }

        IF( EQ_16( st->nbLostCmpt, 1 ) )
        {
            st->tonal_mdct_plc_active = 0;
@@ -569,9 +564,7 @@ Word16 GetPLCModeDecision_fx(
                test();
                test();
                test();
                // PMT("handle to tonalMDCTconceal is missing")
                //#ifdef ADD_IVAS_HTONALMDCTCONC
                IF( ( /*st->ADD_IVAS_HTONALMDCTCONC != NULL &&*/ EQ_16( st->last_core, TCX_20_CORE ) ) && ( EQ_16( st->second_last_core, TCX_20_CORE ) ) && ( ( LE_32( st->old_fpitch, L_deposit_h( shr( st->L_frame, 1 ) ) ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) )
                IF( ( st->hTonalMDCTConc != NULL && EQ_16( st->last_core, TCX_20_CORE ) ) && ( EQ_16( st->second_last_core, TCX_20_CORE ) ) && ( ( LE_32( st->old_fpitch, L_deposit_h( shr( st->L_frame, 1 ) ) ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) )
                    /* it is fine to call the detection even if no ltp information
                       is available, meaning that st->old_fpitch ==
                       st->tcxltp_second_last_pitch == st->L_frame */
@@ -585,24 +578,9 @@ Word16 GetPLCModeDecision_fx(
                    {
                        pitch = L_add( st->old_fpitch, 0 ); /*Q16*/
                    }
                    IF( st->element_mode == EVS_MONO )
                    {
                        TonalMDCTConceal_Detect( &st->tonalMDCTconceal, pitch, &numIndices, st->element_mode
#ifdef ADD_IVAS_HTONALMDCTCONC
                                                 ,
                                                 ( st->element_mode == IVAS_CPE_MDCT ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent )
#endif
                        );
                    }
                    ELSE
                    {
                        TonalMDCTConceal_Detect( st->hTonalMDCTConc, pitch, &numIndices, st->element_mode
#ifdef ADD_IVAS_HTONALMDCTCONC
                                                 ,
                                                 ( st->element_mode == IVAS_CPE_MDCT ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent )
#endif
                        );
                    }

                    TonalMDCTConceal_Detect( st->hTonalMDCTConc, pitch, &numIndices, st->element_mode,
                                             ( st->element_mode == IVAS_CPE_MDCT ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ) );

                    test();
                    test();
Loading