Bug 1223270: P2. Remove unecessary copy in FFmpeg on windows. r?mattwoodrow draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 18 Nov 2015 11:13:37 +1100
changeset 357722 bfb340c8d4985b8bfdacf4acca8ded769bfd7d0f
parent 357721 cfa02b69e30083b9a7099365a5c5fc37eb2b615b
child 519688 3a320e7c7190a479c14e1a5598a8be5431d184c5
push id16827
push userbmo:jyavenard@mozilla.com
push dateFri, 29 Apr 2016 06:12:30 +0000
reviewersmattwoodrow
bugs1223270
milestone49.0a1
Bug 1223270: P2. Remove unecessary copy in FFmpeg on windows. r?mattwoodrow MozReview-Commit-ID: nEcr2yQtzY
dom/media/platforms/ffmpeg/FFmpegDecoderModule.h
dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h
--- a/dom/media/platforms/ffmpeg/FFmpegDecoderModule.h
+++ b/dom/media/platforms/ffmpeg/FFmpegDecoderModule.h
@@ -35,17 +35,17 @@ public:
                      layers::LayersBackend aLayersBackend,
                      layers::ImageContainer* aImageContainer,
                      FlushableTaskQueue* aVideoTaskQueue,
                      MediaDataDecoderCallback* aCallback,
                      DecoderDoctorDiagnostics* aDiagnostics) override
   {
     RefPtr<MediaDataDecoder> decoder =
       new FFmpegVideoDecoder<V>(mLib, aVideoTaskQueue, aCallback, aConfig,
-                                aImageContainer);
+                                aLayersBackend, aImageContainer);
     return decoder.forget();
   }
 
   already_AddRefed<MediaDataDecoder>
   CreateAudioDecoder(const AudioInfo& aConfig,
                      FlushableTaskQueue* aAudioTaskQueue,
                      MediaDataDecoderCallback* aCallback,
                      DecoderDoctorDiagnostics* aDiagnostics) override
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -98,18 +98,20 @@ FFmpegVideoDecoder<LIBAV_VER>::PtsCorrec
   mNumFaultyDts = 0;
   mLastPts = INT64_MIN;
   mLastDts = INT64_MIN;
 }
 
 FFmpegVideoDecoder<LIBAV_VER>::FFmpegVideoDecoder(FFmpegLibWrapper* aLib,
   FlushableTaskQueue* aTaskQueue, MediaDataDecoderCallback* aCallback,
   const VideoInfo& aConfig,
+  LayersBackend aBackend,
   ImageContainer* aImageContainer)
   : FFmpegDataDecoder(aLib, aTaskQueue, aCallback, GetCodecId(aConfig.mMimeType))
+  , mLayersBackend(aBackend)
   , mImageContainer(aImageContainer)
   , mInfo(aConfig)
   , mCodecParser(nullptr)
 {
   MOZ_COUNT_CTOR(FFmpegVideoDecoder);
   // Use a new MediaByteBuffer as the object will be modified during initialization.
   mExtraData = new MediaByteBuffer;
   mExtraData->AppendElements(*aConfig.mExtraData);
@@ -298,17 +300,18 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecodeF
                                             mImageContainer,
                                             aSample->mOffset,
                                             pts,
                                             duration,
                                             b,
                                             !!mFrame->key_frame,
                                             -1,
                                             mInfo.ScaledImageRect(mFrame->width,
-                                                                  mFrame->height));
+                                                                  mFrame->height),
+                                            mLayersBackend);
 
     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/FFmpegVideoDecoder.h
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h
@@ -20,27 +20,29 @@ class FFmpegVideoDecoder : public FFmpeg
 {
 };
 
 template <>
 class FFmpegVideoDecoder<LIBAV_VER> : public FFmpegDataDecoder<LIBAV_VER>
 {
   typedef mozilla::layers::Image Image;
   typedef mozilla::layers::ImageContainer ImageContainer;
+  typedef mozilla::layers::LayersBackend LayersBackend;
 
   enum DecodeResult {
     DECODE_FRAME,
     DECODE_NO_FRAME,
     DECODE_ERROR
   };
 
 public:
   FFmpegVideoDecoder(FFmpegLibWrapper* aLib, FlushableTaskQueue* aTaskQueue,
                      MediaDataDecoderCallback* aCallback,
                      const VideoInfo& aConfig,
+                     LayersBackend aLayersBackend,
                      ImageContainer* aImageContainer);
   virtual ~FFmpegVideoDecoder();
 
   RefPtr<InitPromise> Init() override;
   nsresult Input(MediaRawData* aSample) override;
   void ProcessDrain() override;
   void ProcessFlush() override;
   void InitCodecContext() override;
@@ -65,16 +67,17 @@ private:
    * This method allocates a buffer for FFmpeg's decoder, wrapped in an Image.
    * Currently it only supports Planar YUV420, which appears to be the only
    * non-hardware accelerated image format that FFmpeg's H264 decoder is
    * capable of outputting.
    */
   int AllocateYUV420PVideoBuffer(AVCodecContext* aCodecContext,
                                  AVFrame* aFrame);
 
+  LayersBackend mLayersBackend;
   RefPtr<ImageContainer> mImageContainer;
   VideoInfo mInfo;
 
   // Parser used for VP8 and VP9 decoding.
   AVCodecParserContext* mCodecParser;
 
   class PtsCorrectionContext {
   public: