Bug 1236120: [ffmpeg] Use demuxed dimensions to determine picture size and offset. r=gerald a=ritu
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 01 Jan 2016 14:28:56 +1100
changeset 305951 4e8b2e5c39d6171904d136d30922f46fb2b3f5ad
parent 305950 cf6974b887316b7744f1de3a4317f8916057f90b
child 305952 482240e6ab0da9cf663a33152de7032e30e2cc39
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, ritu
bugs1236120
milestone44.0
Bug 1236120: [ffmpeg] Use demuxed dimensions to determine picture size and offset. r=gerald a=ritu Don't assume it always has an offset of (0,0)
dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp
dom/media/platforms/ffmpeg/FFmpegH264Decoder.h
--- a/dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp
@@ -62,38 +62,36 @@ FFmpegH264Decoder<LIBAV_VER>::PtsCorrect
 }
 
 FFmpegH264Decoder<LIBAV_VER>::FFmpegH264Decoder(
   FlushableTaskQueue* aTaskQueue, MediaDataDecoderCallback* aCallback,
   const VideoInfo& aConfig,
   ImageContainer* aImageContainer)
   : FFmpegDataDecoder(aTaskQueue, aCallback, GetCodecId(aConfig.mMimeType))
   , 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.
   mExtraData = new MediaByteBuffer;
   mExtraData->AppendElements(*aConfig.mExtraData);
 }
 
 RefPtr<MediaDataDecoder::InitPromise>
 FFmpegH264Decoder<LIBAV_VER>::Init()
 {
   if (NS_FAILED(InitDecoder())) {
     return InitPromise::CreateAndReject(DecoderFailureReason::INIT_ERROR, __func__);
   }
 
   mCodecContext->get_buffer = AllocateBufferCb;
   mCodecContext->release_buffer = ReleaseBufferCb;
-  mCodecContext->width = mPictureWidth;
-  mCodecContext->height = mPictureHeight;
+  mCodecContext->width = mImage.width;
+  mCodecContext->height = mImage.height;
 
   return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
 }
 
 FFmpegH264Decoder<LIBAV_VER>::DecodeResult
 FFmpegH264Decoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample)
 {
   MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
@@ -202,17 +200,17 @@ FFmpegH264Decoder<LIBAV_VER>::DoDecodeFr
       duration = aSample->mDuration;
       // dts are probably incorrectly reported ; so clear the map as we're
       // unlikely to find them in the future anyway. This also guards
       // against the map becoming extremely big.
       mDurationMap.Clear();
     }
 
     VideoInfo info;
-    info.mDisplay = nsIntSize(mDisplayWidth, mDisplayHeight);
+    info.mDisplay = mDisplay;
 
     VideoData::YCbCrBuffer b;
     b.mPlanes[0].mData = mFrame->data[0];
     b.mPlanes[0].mStride = mFrame->linesize[0];
     b.mPlanes[0].mHeight = mFrame->height;
     b.mPlanes[0].mWidth = mFrame->width;
     b.mPlanes[0].mOffset = b.mPlanes[0].mSkip = 0;
 
@@ -231,17 +229,17 @@ FFmpegH264Decoder<LIBAV_VER>::DoDecodeFr
     RefPtr<VideoData> v = VideoData::Create(info,
                                               mImageContainer,
                                               aSample->mOffset,
                                               pts,
                                               duration,
                                               b,
                                               !!mFrame->key_frame,
                                               -1,
-                                              gfx::IntRect(0, 0, mCodecContext->width, mCodecContext->height));
+                                              mImage);
     if (!v) {
       NS_WARNING("image allocation error.");
       mCallback->Error();
       return DecodeResult::DECODE_ERROR;
     }
     mCallback->Output(v);
     return DecodeResult::DECODE_FRAME;
   }
--- a/dom/media/platforms/ffmpeg/FFmpegH264Decoder.h
+++ b/dom/media/platforms/ffmpeg/FFmpegH264Decoder.h
@@ -59,20 +59,18 @@ private:
    */
   int AllocateYUV420PVideoBuffer(AVCodecContext* aCodecContext,
                                  AVFrame* aFrame);
 
   static int AllocateBufferCb(AVCodecContext* aCodecContext, AVFrame* aFrame);
   static void ReleaseBufferCb(AVCodecContext* aCodecContext, AVFrame* aFrame);
 
   RefPtr<ImageContainer> mImageContainer;
-  uint32_t mPictureWidth;
-  uint32_t mPictureHeight;
-  uint32_t mDisplayWidth;
-  uint32_t mDisplayHeight;
+  nsIntSize mDisplay;
+  nsIntRect mImage;
 
   class PtsCorrectionContext {
   public:
     PtsCorrectionContext();
     int64_t GuessCorrectPts(int64_t aPts, int64_t aDts);
     void Reset();
 
   private: