Bug 1358662 - Store LastSeenFrame dimensions as an nsIntSize. r=jya
This simplifies the comparison and update logic.
MozReview-Commit-ID: A6YII8tlEUn
--- 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