Bug 1531500 - Fix HE-AAC with WMF decoder. r=cpearce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 01 Mar 2019 00:54:32 +0000
changeset 519723 62d4e16fbb2b655a82418553929c9883279273a5
parent 519722 39ceb46c4c4506a846965fe03240cc854b696617
child 519724 51ffa59f14882531251a889b57ed73530c8997ac
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1531500, 1530234
milestone67.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 1531500 - Fix HE-AAC with WMF decoder. r=cpearce The rate changes after decoding the first sample to what was indicated in the container. The code to handle that case was incorrectly removed in bug 1530234 Differential Revision: https://phabricator.services.mozilla.com/D21618
dom/media/platforms/wmf/WMFAudioMFTManager.cpp
dom/media/platforms/wmf/WMFAudioMFTManager.h
--- a/dom/media/platforms/wmf/WMFAudioMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFAudioMFTManager.cpp
@@ -251,16 +251,28 @@ WMFAudioMFTManager::Output(int64_t aStre
           LOG("Reporting telemetry AUDIO_MFT_OUTPUT_NULL_SAMPLES");
           Telemetry::Accumulate(
               Telemetry::HistogramID::AUDIO_MFT_OUTPUT_NULL_SAMPLES, 1);
         });
     SystemGroup::Dispatch(TaskCategory::Other, task.forget());
     return E_FAIL;
   }
 
+  UINT32 discontinuity = false;
+  sample->GetUINT32(MFSampleExtension_Discontinuity, &discontinuity);
+  if (mFirstFrame || discontinuity) {
+    // Update the output type, in case this segment has a different
+    // rate. This also triggers on the first sample, which can have a
+    // different rate than is advertised in the container, and sometimes we
+    // don't get a MF_E_TRANSFORM_STREAM_CHANGE when the rate changes.
+    hr = UpdateOutputType();
+    NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+    mFirstFrame = false;
+  }
+
   TimeUnit pts = GetSampleTime(sample);
   NS_ENSURE_TRUE(pts.IsValid(), E_FAIL);
 
   RefPtr<IMFMediaBuffer> buffer;
   hr = sample->ConvertToContiguousBuffer(getter_AddRefs(buffer));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   BYTE* data = nullptr;  // Note: *data will be owned by the IMFMediaBuffer, we
--- a/dom/media/platforms/wmf/WMFAudioMFTManager.h
+++ b/dom/media/platforms/wmf/WMFAudioMFTManager.h
@@ -44,13 +44,15 @@ class WMFAudioMFTManager : public MFTMan
   uint32_t mAudioRate;
   nsTArray<BYTE> mUserData;
 
   enum StreamType { Unknown, AAC, MP3 };
   StreamType mStreamType;
 
   const GUID& GetMFTGUID();
   const GUID& GetMediaSubtypeGUID();
+
+  bool mFirstFrame = true;
 };
 
 }  // namespace mozilla
 
 #endif  // WMFAudioOutputSource_h_