Commit 0a9dd0e3 authored by fotopoulou's avatar fotopoulou
Browse files

fix additional issue on TCX 5 transition

parent b6f72cb0
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
@@ -1252,27 +1252,80 @@ void decoder_tcx_noisefilling(
                if ( ( frame_cnt == 0 ) && ( L_frameTCX == hTcxDec->L_frameTCX >> 1 ) && ( st->tcxonly ) && ( !st->tonal_mdct_plc_active ) && ( st->nbLostCmpt == 1 ) && ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) && ( hTcxCfg->tcx_curr_overlap_mode != FULL_OVERLAP ) )
                {
                    E_2ndlast = E_last = EPSILON;
#ifdef FIX_575_LOW_OVERLAP_PLC_RECOVERY
                    if ( st->element_mode > EVS_MONO )
                    {
                        for ( i = 0; i < L_frameTCX; i = i + 2 )
                        {
                            E_2ndlast += st->hTonalMDCTConc->lastBlockData.spectralData[i] * st->hTonalMDCTConc->lastBlockData.spectralData[i];
                            E_last += st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] * st->hTonalMDCTConc->lastBlockData.spectralData[i + 1];
                        }
                    }
                    else
                    {
                        for ( i = 0; i < infoIGFStartLine; i = i + 2 )
                        {
                            E_2ndlast += st->hTonalMDCTConc->lastBlockData.spectralData[i] * st->hTonalMDCTConc->lastBlockData.spectralData[i];
                            E_last += st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] * st->hTonalMDCTConc->lastBlockData.spectralData[i + 1];
                        }
                    }
#else
                    for ( i = 0; i < infoIGFStartLine; i = i + 2 )
                    {
                        E_2ndlast += st->hTonalMDCTConc->lastBlockData.spectralData[i] * st->hTonalMDCTConc->lastBlockData.spectralData[i];
                        E_last += st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] * st->hTonalMDCTConc->lastBlockData.spectralData[i + 1];
                    }
#endif
                    tmp2 = E_2ndlast / E_last;

                    /* replace higher energy TCX5 frame by lower one to avoid energy fluctuation */
                    if ( tmp2 > 2 )
                    {
#ifdef FIX_575_LOW_OVERLAP_PLC_RECOVERY
                        if ( st->element_mode > EVS_MONO )
                        {
                            for ( i = 0; i < L_frameTCX; i = i + 2 )
                            {
                                st->hTonalMDCTConc->lastBlockData.spectralData[i] = st->hTonalMDCTConc->lastBlockData.spectralData[i + 1];
                            }
                        }
                        else
                        {
                            for ( i = 0; i < infoIGFStartLine; i = i + 2 )
                            {
                                st->hTonalMDCTConc->lastBlockData.spectralData[i] = st->hTonalMDCTConc->lastBlockData.spectralData[i + 1];
                            }
                        }
#else
                        for ( i = 0; i < infoIGFStartLine; i = i + 2 )
                        {
                            st->hTonalMDCTConc->lastBlockData.spectralData[i] = st->hTonalMDCTConc->lastBlockData.spectralData[i + 1];
                        }
#endif
                    }
                    else if ( tmp2 < 0.5 )
                    {
#ifdef FIX_575_LOW_OVERLAP_PLC_RECOVERY
                        if ( st->element_mode > EVS_MONO )
                        {
                            for ( i = 0; i < L_frameTCX; i = i + 2 )
                            {
                                st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData[i];
                            }
                        }
                        else
                        {
                            for ( i = 0; i < infoIGFStartLine; i = i + 2 )
                            {
                                st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData[i];
                            }
                        }
#else
                        for ( i = 0; i < infoIGFStartLine; i = i + 2 )
                        {
                            st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData[i];
                        }
#endif
                    }
                }