Bug 1358662 - Store LastSeenFrame dimensions as an nsIntSize. r=jya draft
authorRalph Giles <giles@mozilla.com>
Fri, 21 Apr 2017 18:05:46 -0700
changeset 571592 e8ed144c5ba95540037a78b2cdfcd7a70a821c89
parent 571414 bfc7b187005cabbc828ed9f5b61daf139c3cfd90
child 571593 7876422fb86708fb0f60ec09b2c37ff3478fe784
push id56862
push userbmo:giles@thaumas.net
push dateWed, 03 May 2017 00:23:00 +0000
reviewersjya
bugs1358662
milestone55.0a1
Bug 1358662 - Store LastSeenFrame dimensions as an nsIntSize. r=jya This simplifies the comparison and update logic. MozReview-Commit-ID: A6YII8tlEUn
dom/media/webm/WebMDemuxer.cpp
dom/media/webm/WebMDemuxer.h
--- a/dom/media/webm/WebMDemuxer.cpp
+++ b/dom/media/webm/WebMDemuxer.cpp
@@ -687,26 +687,24 @@ WebMDemuxer::GetNextPacket(TrackInfo::Tr
         case NESTEGG_CODEC_VP9:
           vpx_codec_peek_stream_info(vpx_codec_vp9_dx(), data, length, &si);
           break;
         }
         isKeyframe = si.is_kf;
         if (isKeyframe) {
           // We only look for resolution changes on keyframes for both VP8 and
           // VP9. Other resolution changes are invalid.
-          if (mLastSeenFrameWidth.isSome()
-              && mLastSeenFrameHeight.isSome()
-              && (si.w != mLastSeenFrameWidth.value()
-                  || si.h != mLastSeenFrameHeight.value())) {
-            mInfo.mVideo.mDisplay = nsIntSize(si.w, si.h);
+          auto dimensions = nsIntSize(si.w, si.h);
+          if (mLastSeenFrameSize.isSome()
+              && (dimensions != mLastSeenFrameSize.value())) {
+            mInfo.mVideo.mDisplay = dimensions;
             mSharedVideoTrackInfo =
               new TrackInfoSharedPtr(mInfo.mVideo, ++sStreamSourceID);
           }
-          mLastSeenFrameWidth = Some(si.w);
-          mLastSeenFrameHeight = Some(si.h);
+          mLastSeenFrameSize = Some(dimensions);
         }
       }
     }
 
     WEBM_DEBUG("push sample tstamp: %" PRId64 " next_tstamp: %" PRId64 " length: %" PRIuSIZE " kf: %d",
                tstamp, next_tstamp, length, isKeyframe);
     RefPtr<MediaRawData> sample;
     if (mInfo.mVideo.HasAlpha() && alphaLength != 0) {
--- a/dom/media/webm/WebMDemuxer.h
+++ b/dom/media/webm/WebMDemuxer.h
@@ -252,18 +252,17 @@ private:
   bool mNeedReIndex;
 
   // The last complete block parsed by the WebMBufferedState. -1 if not set.
   // We cache those values rather than retrieving them for performance reasons
   // as nestegg only performs 1-byte read at a time.
   int64_t mLastWebMBlockOffset;
   const bool mIsMediaSource;
 
-  Maybe<uint32_t> mLastSeenFrameWidth;
-  Maybe<uint32_t> mLastSeenFrameHeight;
+  Maybe<nsIntSize> mLastSeenFrameSize;
   // This will be populated only if a resolution change occurs, otherwise it
   // will be left as null so the original metadata is used
   RefPtr<TrackInfoSharedPtr> mSharedVideoTrackInfo;
 
   EncryptionInfo mCrypto;
 };
 
 class WebMTrackDemuxer : public MediaTrackDemuxer