Commit 1fa6ffe1 authored by Jan Kiene's avatar Jan Kiene
Browse files

fix bug in nrg correction for tonal concealment

also zero-out noise above IGF starting freq when generating concealment
noise -> could lead to wrong energy if tonal components are detected in
the IGF region
parent ff7a8064
Loading
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -685,7 +685,7 @@ void TonalMDCTConceal_InsertNoise(
                    {
                        mdctSpectrum[l] = g * y - crossfadeGain * x;
                    }
                    hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[i] * mdctSpectrum[i];
                    hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[l] * mdctSpectrum[l];
                }
                for ( i = 1; i < hTonalMDCTConc->pTCI->numIndexes; i++ )
                {
@@ -702,7 +702,7 @@ void TonalMDCTConceal_InsertNoise(
                        {
                            mdctSpectrum[l] = g * y - crossfadeGain * x;
                        }
                        hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[i] * mdctSpectrum[i];
                        hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[l] * mdctSpectrum[l];
                    }
                }

@@ -719,7 +719,7 @@ void TonalMDCTConceal_InsertNoise(
                    {
                        mdctSpectrum[l] = g * y - crossfadeGain * x;
                    }
                    hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[i] * mdctSpectrum[i];
                    hTonalMDCTConc->faded_signal_nrg += mdctSpectrum[l] * mdctSpectrum[l];
                }

                for ( l = crossOverFreq; l < hTonalMDCTConc->lastBlockData.nSamples; l++ )
@@ -1129,6 +1129,14 @@ void TonalMdctConceal_create_concealment_noise(
        }
    }

    if ( st->tonal_mdct_plc_active )
    {
        for ( i = crossOverFreq; i < max( crossOverFreq, hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ); ++i )
        {
            concealment_noise[i] *= 0.0f;
        }
    }

    /* restore common seed
         - after finishing the first channel
         - after a first subframe if the current channel is TCX10 */