From fa3f6a55e40ec47ab4bf6ea601fac7267d0e2756 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Wed, 22 May 2013 07:40:29 -0400 Subject: [PATCH] Backed out changeset 9b5a9cd5032d (bug 870400) for Windows mochitest-1 failures. --- content/media/wmf/WMFReader.cpp | 56 +++------------------------------ content/media/wmf/WMFReader.h | 7 ----- 2 files changed, 4 insertions(+), 59 deletions(-) diff --git a/content/media/wmf/WMFReader.cpp b/content/media/wmf/WMFReader.cpp index 3c7ce2534632..f975de5530e4 100644 --- a/content/media/wmf/WMFReader.cpp +++ b/content/media/wmf/WMFReader.cpp @@ -48,8 +48,6 @@ WMFReader::WMFReader(AbstractMediaDecoder* aDecoder) mVideoWidth(0), mVideoHeight(0), mVideoStride(0), - mAudioFrameSum(0), - mAudioFrameOffset(0), mHasAudio(false), mHasVideo(false), mCanSeek(false), @@ -607,31 +605,6 @@ GetSampleDuration(IMFSample* aSample) return HNsToUsecs(duration); } -HRESULT -HNsToFrames(int64_t aHNs, uint32_t aRate, int64_t* aOutFrames) -{ - MOZ_ASSERT(aOutFrames); - const int64_t HNS_PER_S = USECS_PER_S * 10; - CheckedInt i = aHNs; - i *= aRate; - i /= HNS_PER_S; - NS_ENSURE_TRUE(i.isValid(), E_FAIL); - *aOutFrames = i.value(); - return S_OK; -} - -HRESULT -FramesToUsecs(int64_t aSamples, uint32_t aRate, int64_t* aOutUsecs) -{ - MOZ_ASSERT(aOutUsecs); - CheckedInt i = aSamples; - i *= USECS_PER_S; - i /= aRate; - NS_ENSURE_TRUE(i.isValid(), E_FAIL); - *aOutUsecs = i.value(); - return S_OK; -} - bool WMFReader::DecodeAudioData() { @@ -687,32 +660,11 @@ WMFReader::DecodeAudioData() memcpy(pcmSamples.get(), data, currentLength); buffer->Unlock(); - // We calculate the timestamp and the duration based on the number of audio - // frames we've already played. We don't trust the timestamp stored on the - // IMFSample, as sometimes it's wrong, possibly due to buggy encoders? + int64_t offset = mDecoder->GetResource()->Tell(); + int64_t timestamp = HNsToUsecs(timestampHns); + int64_t duration = GetSampleDuration(sample); - // If this sample block comes after a discontinuity (i.e. a gap or seek) - // reset the frame counters, and capture the timestamp. Future timestamps - // will be offset from this block's timestamp. - UINT32 discontinuity = false; - sample->GetUINT32(MFSampleExtension_Discontinuity, &discontinuity); - if (discontinuity) { - mAudioFrameSum = 0; - hr = HNsToFrames(timestampHns, mAudioRate, &mAudioFrameOffset); - NS_ENSURE_TRUE(SUCCEEDED(hr), false); - } - - int64_t timestamp; - hr = FramesToUsecs(mAudioFrameOffset + mAudioFrameSum, mAudioRate, ×tamp); - NS_ENSURE_TRUE(SUCCEEDED(hr), false); - - mAudioFrameSum += numFrames; - - int64_t duration; - hr = FramesToUsecs(numFrames, mAudioRate, &duration); - NS_ENSURE_TRUE(SUCCEEDED(hr), false); - - mAudioQueue.Push(new AudioData(mDecoder->GetResource()->Tell(), + mAudioQueue.Push(new AudioData(offset, timestamp, duration, numFrames, diff --git a/content/media/wmf/WMFReader.h b/content/media/wmf/WMFReader.h index 6a1b87ef7a99..54f9431a6743 100644 --- a/content/media/wmf/WMFReader.h +++ b/content/media/wmf/WMFReader.h @@ -91,13 +91,6 @@ private: uint32_t mVideoHeight; uint32_t mVideoStride; - // The offset, in audio frames, at which playback started since the - // last discontinuity. - int64_t mAudioFrameOffset; - // The number of audio frames that we've played since the last - // discontinuity. - int64_t mAudioFrameSum; - bool mHasAudio; bool mHasVideo; bool mCanSeek;