From c09f5b9f683bd0dfd1d470244aba2bf7946c4f16 Mon Sep 17 00:00:00 2001 From: trav90 Date: Thu, 1 Dec 2016 02:58:50 -0600 Subject: [PATCH] Use demuxed dimensions to determine picture size and offset Don't assume it always has an offset of (0,0) --- dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp | 14 ++++++-------- dom/media/platforms/ffmpeg/FFmpegH264Decoder.h | 6 ++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp b/dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp index e0130ff87d..46d12401d8 100644 --- a/dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp @@ -30,10 +30,8 @@ FFmpegH264Decoder::FFmpegH264Decoder( : FFmpegDataDecoder(aTaskQueue, GetCodecId(aConfig.mMimeType)) , mCallback(aCallback) , mImageContainer(aImageContainer) - , mPictureWidth(aConfig.mImage.width) - , mPictureHeight(aConfig.mImage.height) - , mDisplayWidth(aConfig.mDisplay.width) - , mDisplayHeight(aConfig.mDisplay.height) + , mDisplay(aConfig.mDisplay) + , mImage(aConfig.mImage) { MOZ_COUNT_CTOR(FFmpegH264Decoder); // Use a new MediaByteBuffer as the object will be modified during initialization. @@ -49,8 +47,8 @@ FFmpegH264Decoder::Init() mCodecContext->get_buffer = AllocateBufferCb; mCodecContext->release_buffer = ReleaseBufferCb; - mCodecContext->width = mPictureWidth; - mCodecContext->height = mPictureHeight; + mCodecContext->width = mImage.width; + mCodecContext->height = mImage.height; return NS_OK; } @@ -114,7 +112,7 @@ FFmpegH264Decoder::DoDecodeFrame(MediaRawData* aSample) pts, mCodecContext->reordered_opaque); VideoInfo info; - info.mDisplay = nsIntSize(mDisplayWidth, mDisplayHeight); + info.mDisplay = mDisplay; VideoData::YCbCrBuffer b; b.mPlanes[0].mData = mFrame->data[0]; @@ -143,7 +141,7 @@ FFmpegH264Decoder::DoDecodeFrame(MediaRawData* aSample) b, aSample->mKeyframe, -1, - gfx::IntRect(0, 0, mCodecContext->width, mCodecContext->height)); + mImage); if (!v) { NS_WARNING("image allocation error."); mCallback->Error(); diff --git a/dom/media/platforms/ffmpeg/FFmpegH264Decoder.h b/dom/media/platforms/ffmpeg/FFmpegH264Decoder.h index 88c2f68a73..3fb00d2d8f 100644 --- a/dom/media/platforms/ffmpeg/FFmpegH264Decoder.h +++ b/dom/media/platforms/ffmpeg/FFmpegH264Decoder.h @@ -63,10 +63,8 @@ private: MediaDataDecoderCallback* mCallback; nsRefPtr mImageContainer; - uint32_t mPictureWidth; - uint32_t mPictureHeight; - uint32_t mDisplayWidth; - uint32_t mDisplayHeight; + nsIntSize mDisplay; + nsIntRect mImage; }; } // namespace mozilla