Bug 1469257 - [H264] Only check for SPS changes on keyframe r=bryce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 20 Jun 2018 19:24:34 +0000
changeset 423120 ddde6ad6d9e6
parent 423119 3c53e83acb19
child 423121 08b8d3da8635
push id34163
push usercsabou@mozilla.com
push dateThu, 21 Jun 2018 01:14:46 +0000
treeherdermozilla-central@e09fbaee1456 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 1469257 - [H264] Only check for SPS changes on keyframe r=bryce Some invalid streams contain SPS changes and those appear to only occur on non-keyframe, this cause all frames to be dropped until the next keyframe is found. This result in apparent freezes. While it is theoretically possible to have SPS changes inband on non-keyframe those should be very rare (I've never seen one). The content would have been invalid anyway in an non-fragmented mp4. So we now only check for a SPS change on keyframe. This would cause no affect on either windows, android or ffmpeg as those decoders handle format change fine. The mac decoder could however show garbled frames temporarily. Differential Revision: https://phabricator.services.mozilla.com/D1733
--- a/dom/media/platforms/wrappers/H264Converter.cpp
+++ b/dom/media/platforms/wrappers/H264Converter.cpp
@@ -404,38 +404,36 @@ H264Converter::DecodeFirstSample(MediaRa
 H264Converter::CheckForSPSChange(MediaRawData* aSample)
   RefPtr<MediaByteBuffer> extra_data =
-    H264::ExtractExtraData(aSample);
+    aSample->mKeyframe ? H264::ExtractExtraData(aSample) : nullptr;
   if (!H264::HasSPS(extra_data)) {
     if (!*mCanRecycleDecoder) {
       // If the decoder can't be recycled, the out of band extradata will never
       // change as the H264Converter will be recreated by the MediaFormatReader
       // instead. So there's no point in testing for changes.
       return NS_OK;
     // This sample doesn't contain inband SPS/PPS
     // We now check if the out of band one has changed.
     // This scenario can only occur on Android with devices that can recycle a
     // decoder.
     if (!H264::HasSPS(aSample->mExtraData) ||
-        H264::CompareExtraData(aSample->mExtraData,
-                                            mOriginalExtraData)) {
+        H264::CompareExtraData(aSample->mExtraData, mOriginalExtraData)) {
       return NS_OK;
     extra_data = mOriginalExtraData = aSample->mExtraData;
-  if (H264::CompareExtraData(extra_data,
-                                          mCurrentConfig.mExtraData)) {
+  if (H264::CompareExtraData(extra_data, mCurrentConfig.mExtraData)) {
     return NS_OK;
   if (*mCanRecycleDecoder) {
     // Do not recreate the decoder, reuse it.
     if (!aSample->mTrackInfo) {