Bug 1016148 - Ensure we mark IMFSamples after a flush as discontinuities, so that A/V sync works after seek in MP4Reader. r=padenot
authorChris Pearce <cpearce@mozilla.com>
Thu, 10 Jul 2014 09:25:14 +1200
changeset 214012 2dfa46ff5ecaa78220cacb889f9d830b88ab7909
parent 214011 47ff2362d955f1fd1016082a738c5015a5d3342b
child 214013 fc4d6b5ee8cedbe6d80424cace3a6cecd8a121f0
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1016148
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1016148 - Ensure we mark IMFSamples after a flush as discontinuities, so that A/V sync works after seek in MP4Reader. r=padenot
content/media/fmp4/wmf/MFTDecoder.cpp
content/media/fmp4/wmf/MFTDecoder.h
--- a/content/media/fmp4/wmf/MFTDecoder.cpp
+++ b/content/media/fmp4/wmf/MFTDecoder.cpp
@@ -16,16 +16,17 @@ PRLogModuleInfo* GetDemuxerLog();
 #define LOG(...)
 #endif
 
 
 namespace mozilla {
 
 MFTDecoder::MFTDecoder()
   : mMFTProvidesOutputSamples(false)
+  , mDiscontinuity(true)
 {
   memset(&mInputStreamInfo, 0, sizeof(MFT_INPUT_STREAM_INFO));
   memset(&mOutputStreamInfo, 0, sizeof(MFT_OUTPUT_STREAM_INFO));
 }
 
 MFTDecoder::~MFTDecoder()
 {
 }
@@ -232,16 +233,21 @@ MFTDecoder::Output(RefPtr<IMFSample>* aO
     // so don't warn on encountering it.
     return hr;
   }
   // Treat other errors as unexpected, and warn.
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   MOZ_ASSERT(output.pSample);
 
+  if (mDiscontinuity) {
+    output.pSample->SetUINT32(MFSampleExtension_Discontinuity, TRUE);
+    mDiscontinuity = false;
+  }
+
   *aOutput = output.pSample; // AddRefs
   if (mMFTProvidesOutputSamples) {
     // If the MFT is providing samples, we must release the sample here.
     // Typically only the H.264 MFT provides samples when using DXVA,
     // and it always re-uses the same sample, so if we don't release it
     // MFT::ProcessOutput() deadlocks waiting for the sample to be released.
     output.pSample->Release();
     output.pSample = nullptr;
@@ -272,16 +278,18 @@ MFTDecoder::Input(const uint8_t* aData,
 }
 
 HRESULT
 MFTDecoder::Flush()
 {
   HRESULT hr = SendMFTMessage(MFT_MESSAGE_COMMAND_FLUSH, 0);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
+  mDiscontinuity = true;
+
   return S_OK;
 }
 
 HRESULT
 MFTDecoder::GetOutputMediaType(RefPtr<IMFMediaType>& aMediaType)
 {
   NS_ENSURE_TRUE(mDecoder, E_POINTER);
   return mDecoder->GetOutputCurrentType(0, byRef(aMediaType));
--- a/content/media/fmp4/wmf/MFTDecoder.h
+++ b/content/media/fmp4/wmf/MFTDecoder.h
@@ -91,13 +91,16 @@ private:
   MFT_OUTPUT_STREAM_INFO mOutputStreamInfo;
 
   RefPtr<IMFTransform> mDecoder;
 
   GUID mOutputSubtype;
 
   // True if the IMFTransform allocates the samples that it returns.
   bool mMFTProvidesOutputSamples;
+
+  // True if we need to mark the next sample as a discontinuity.
+  bool mDiscontinuity;
 };
 
 } // namespace mozilla
 
 #endif