Bug 1194884: [webm] P2. Retrieve all VPX decoded frames from decoder. r=j^ a=sylvestre
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sun, 16 Aug 2015 00:51:24 +1000
changeset 288812 2bac25974183b0b48faf5513d4de2ef124dfefec
parent 288811 91624ae2b989b83ff3a80a5fba8b8c6fa451f5ac
child 288813 8618de5f122fea2c3b6ee68c275fd9d422417d64
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersj, sylvestre
bugs1194884
milestone42.0a2
Bug 1194884: [webm] P2. Retrieve all VPX decoded frames from decoder. r=j^ a=sylvestre
dom/media/platforms/agnostic/VPXDecoder.cpp
dom/media/platforms/agnostic/VPXDecoder.h
--- a/dom/media/platforms/agnostic/VPXDecoder.cpp
+++ b/dom/media/platforms/agnostic/VPXDecoder.cpp
@@ -24,17 +24,16 @@ extern PRLogModuleInfo* gMediaDecoderLog
 
 VPXDecoder::VPXDecoder(const VideoInfo& aConfig,
                        ImageContainer* aImageContainer,
                        FlushableTaskQueue* aTaskQueue,
                        MediaDataDecoderCallback* aCallback)
   : mImageContainer(aImageContainer)
   , mTaskQueue(aTaskQueue)
   , mCallback(aCallback)
-  , mIter(nullptr)
   , mInfo(aConfig)
 {
   MOZ_COUNT_CTOR(VPXDecoder);
   if (aConfig.mMimeType.EqualsLiteral("video/webm; codecs=vp8")) {
     mCodec = Codec::VP8;
   } else if (aConfig.mMimeType.EqualsLiteral("video/webm; codecs=vp9")) {
     mCodec = Codec::VP9;
   } else {
@@ -69,17 +68,16 @@ VPXDecoder::Init()
   }
   return NS_OK;
 }
 
 nsresult
 VPXDecoder::Flush()
 {
   mTaskQueue->Flush();
-  mIter = nullptr;
   return NS_OK;
 }
 
 int
 VPXDecoder::DoDecodeFrame(MediaRawData* aSample)
 {
 #if defined(DEBUG)
   vpx_codec_stream_info_t si;
@@ -94,19 +92,20 @@ VPXDecoder::DoDecodeFrame(MediaRawData* 
                "VPX Decode Keyframe error sample->mKeyframe and si.si_kf out of sync");
 #endif
 
   if (vpx_codec_err_t r = vpx_codec_decode(&mVPX, aSample->Data(), aSample->Size(), nullptr, 0)) {
     LOG("VPX Decode error: %s", vpx_codec_err_to_string(r));
     return -1;
   }
 
+  vpx_codec_iter_t  iter = nullptr;
   vpx_image_t      *img;
 
-  if ((img = vpx_codec_get_frame(&mVPX, &mIter))) {
+  while ((img = vpx_codec_get_frame(&mVPX, &iter))) {
     NS_ASSERTION(img->fmt == VPX_IMG_FMT_I420, "WebM image format not I420");
 
     // Chroma shifts are rounded down as per the decoding examples in the SDK
     VideoData::YCbCrBuffer b;
     b.mPlanes[0].mData = img->planes[0];
     b.mPlanes[0].mStride = img->stride[0];
     b.mPlanes[0].mHeight = img->d_h;
     b.mPlanes[0].mWidth = img->d_w;
@@ -138,19 +137,17 @@ VPXDecoder::DoDecodeFrame(MediaRawData* 
 
     if (!v) {
       LOG("Image allocation error source %ldx%ld display %ldx%ld picture %ldx%ld",
           img->d_w, img->d_h, mInfo.mDisplay.width, mInfo.mDisplay.height,
           mInfo.mImage.width, mInfo.mImage.height);
       return -1;
     }
     mCallback->Output(v);
-    return 1;
   }
-  mIter = nullptr;
   return 0;
 }
 
 void
 VPXDecoder::DecodeFrame(MediaRawData* aSample)
 {
   if (DoDecodeFrame(aSample) == -1) {
     mCallback->Error();
--- a/dom/media/platforms/agnostic/VPXDecoder.h
+++ b/dom/media/platforms/agnostic/VPXDecoder.h
@@ -49,17 +49,16 @@ private:
   void OutputDelayedFrames ();
 
   nsRefPtr<ImageContainer> mImageContainer;
   RefPtr<FlushableTaskQueue> mTaskQueue;
   MediaDataDecoderCallback* mCallback;
 
   // VPx decoder state
   vpx_codec_ctx_t mVPX;
-  vpx_codec_iter_t mIter;
 
   const VideoInfo& mInfo;
 
   int mCodec;
 };
 
 } // namespace mozilla