From 9dcbebf1ca0e0d65735bf88c124ed75b6ab2ab28 Mon Sep 17 00:00:00 2001 From: trav90 Date: Thu, 6 Apr 2017 10:10:19 -0500 Subject: [PATCH] Don't skip audio samples with a negative presentation time This makes WMF have the same decoding behavior as other platforms. --- dom/media/platforms/wmf/WMFAudioMFTManager.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/dom/media/platforms/wmf/WMFAudioMFTManager.cpp b/dom/media/platforms/wmf/WMFAudioMFTManager.cpp index 3844dedffa..50573c1285 100644 --- a/dom/media/platforms/wmf/WMFAudioMFTManager.cpp +++ b/dom/media/platforms/wmf/WMFAudioMFTManager.cpp @@ -251,7 +251,6 @@ WMFAudioMFTManager::Output(int64_t aStreamOffset, // reset the frame counters, and capture the timestamp. Future timestamps // will be offset from this block's timestamp. UINT32 discontinuity = false; - int32_t numFramesToStrip = 0; sample->GetUINT32(MFSampleExtension_Discontinuity, &discontinuity); if (mMustRecaptureAudioPosition || discontinuity) { // Update the output type, in case this segment has a different @@ -267,21 +266,11 @@ WMFAudioMFTManager::Output(int64_t aStreamOffset, NS_ENSURE_TRUE(SUCCEEDED(hr), hr); hr = HNsToFrames(timestampHns, mAudioRate, &mAudioFrameOffset); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); - if (mAudioFrameOffset < 0) { - // First sample has a negative timestamp. Strip off the samples until - // we reach positive territory. - numFramesToStrip = -mAudioFrameOffset; - mAudioFrameOffset = 0; - } mMustRecaptureAudioPosition = false; } - MOZ_ASSERT(numFramesToStrip >= 0); // We can assume PCM 16 output. int32_t numSamples = currentLength / 2; int32_t numFrames = numSamples / mAudioChannels; - int32_t offset = std::min(numFramesToStrip, numFrames); - numFrames -= offset; - numSamples -= offset * mAudioChannels; MOZ_ASSERT(numFrames >= 0); MOZ_ASSERT(numSamples >= 0); if (numFrames == 0) { @@ -292,10 +281,7 @@ WMFAudioMFTManager::Output(int64_t aStreamOffset, nsAutoArrayPtr audioData(new AudioDataValue[numSamples]); - int16_t* pcm = ((int16_t*)data) + (offset * mAudioChannels); - MOZ_ASSERT(pcm >= (int16_t*)data); - MOZ_ASSERT(pcm <= (int16_t*)(data + currentLength)); - MOZ_ASSERT(pcm+numSamples <= (int16_t*)(data + currentLength)); + int16_t* pcm = (int16_t*)data; for (int32_t i = 0; i < numSamples; ++i) { audioData[i] = AudioSampleToFloat(pcm[i]); }