Bug 1406503 - P3. Also drain av_parser when draining. r=jwwang
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 27 Oct 2017 00:41:17 +0200
changeset 389039 5f06da1362df0f9cb0587378d31e3785aeb40a5a
parent 389038 a1f28a42c07fb09a46ed6862749eb9a377e477f7
child 389040 6a20de1a556f868360ac4c55d38efad5cdb82bf7
push id32777
push userarchaeopteryx@coole-files.de
push dateMon, 30 Oct 2017 22:44:45 +0000
treeherdermozilla-central@dd0f265a1300 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang
bugs1406503
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1406503 - P3. Also drain av_parser when draining. r=jwwang Per FFmpeg documentation: to signal EOF to the av_parser, input length should be 0 (so that the last frame can be output). MozReview-Commit-ID: F22RcRnT3HS
dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
--- a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
@@ -135,40 +135,43 @@ MediaResult
 FFmpegDataDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample, bool* aGotFrame,
                                        MediaDataDecoder::DecodedData& aResults)
 {
   uint8_t* inputData = const_cast<uint8_t*>(aSample->Data());
   size_t inputSize = aSample->Size();
 
   mLastInputDts = aSample->mTimecode;
 
-  if (inputSize && mCodecParser) {
-    while (inputSize) {
+  if (mCodecParser) {
+    if (aGotFrame) {
+      *aGotFrame = false;
+    }
+    do {
       uint8_t* data = inputData;
       int size = inputSize;
       int len = mLib->av_parser_parse2(
         mCodecParser, mCodecContext, &data, &size, inputData, inputSize,
         aSample->mTime.ToMicroseconds(), aSample->mTimecode.ToMicroseconds(),
         aSample->mOffset);
       if (size_t(len) > inputSize) {
         return NS_ERROR_DOM_MEDIA_DECODE_ERR;
       }
-      inputData += len;
-      inputSize -= len;
-      if (size) {
+      if (size || !inputSize) {
         bool gotFrame = false;
         MediaResult rv = DoDecode(aSample, data, size, &gotFrame, aResults);
         if (NS_FAILED(rv)) {
           return rv;
         }
         if (gotFrame && aGotFrame) {
           *aGotFrame = true;
         }
       }
-    }
+      inputData += len;
+      inputSize -= len;
+    } while (inputSize > 0);
     return NS_OK;
   }
   return DoDecode(aSample, inputData, inputSize, aGotFrame, aResults);
 }
 
 RefPtr<MediaDataDecoder::FlushPromise>
 FFmpegDataDecoder<LIBAV_VER>::Flush()
 {