Bug 1469257 - [H264] Only check for SPS changes on keyframe. r=bryce, a=RyanVM
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 20 Jun 2018 19:24:34 +0000
changeset 473789 4a7ccfb9d5ed
parent 473788 6bd52895ade2
child 473790 42ee22b7ad56
push id1737
push userryanvm@gmail.com
push date2018-07-02 16:05 +0000
treeherdermozilla-release@ced0b5dc71eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbryce, RyanVM
Bug 1469257 - [H264] Only check for SPS changes on keyframe. r=bryce, a=RyanVM 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) {