Bug 1364870: [ffmpeg] only check format if frame has been decoded. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 19 May 2017 09:52:12 +0200
changeset 581057 20082a2c4727312416baf4a1076521175ce1cf31
parent 581056 f84810dd33bef8ff44e95e3a7645f18adf8e5eae
child 629472 0375c15589ce94a31a6a73dc176c723ec77b95ae
push id59755
push userbmo:jyavenard@mozilla.com
push dateFri, 19 May 2017 07:54:29 +0000
reviewersgerald
bugs1364870
milestone55.0a1
Bug 1364870: [ffmpeg] only check format if frame has been decoded. r?gerald The format member isn't set when an audio frame hasn't been decoded yet. MozReview-Commit-ID: IgUj6bjVzdF
dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp
--- a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp
@@ -148,30 +148,30 @@ FFmpegAudioDecoder<LIBAV_VER>::ProcessDe
     if (bytesConsumed < 0) {
       NS_WARNING("FFmpeg audio decoder error.");
       return DecodePromise::CreateAndReject(
         MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
                     RESULT_DETAIL("FFmpeg audio error:%d", bytesConsumed)),
         __func__);
     }
 
-    if (mFrame->format != AV_SAMPLE_FMT_FLT &&
-        mFrame->format != AV_SAMPLE_FMT_FLTP &&
-        mFrame->format != AV_SAMPLE_FMT_S16 &&
-        mFrame->format != AV_SAMPLE_FMT_S16P &&
-        mFrame->format != AV_SAMPLE_FMT_S32 &&
-        mFrame->format != AV_SAMPLE_FMT_S32P) {
-      return DecodePromise::CreateAndReject(
-        MediaResult(
-          NS_ERROR_DOM_MEDIA_DECODE_ERR,
-          RESULT_DETAIL("FFmpeg audio decoder outputs unsupported audio format")),
-        __func__);
-    }
-
     if (decoded) {
+      if (mFrame->format != AV_SAMPLE_FMT_FLT &&
+          mFrame->format != AV_SAMPLE_FMT_FLTP &&
+          mFrame->format != AV_SAMPLE_FMT_S16 &&
+          mFrame->format != AV_SAMPLE_FMT_S16P &&
+          mFrame->format != AV_SAMPLE_FMT_S32 &&
+          mFrame->format != AV_SAMPLE_FMT_S32P) {
+        return DecodePromise::CreateAndReject(
+          MediaResult(
+            NS_ERROR_DOM_MEDIA_DECODE_ERR,
+            RESULT_DETAIL(
+              "FFmpeg audio decoder outputs unsupported audio format")),
+          __func__);
+      }
       uint32_t numChannels = mCodecContext->channels;
       AudioConfig::ChannelLayout layout(numChannels);
       if (!layout.IsValid()) {
         return DecodePromise::CreateAndReject(
           MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
                       RESULT_DETAIL("Unsupported channel layout:%u", numChannels)),
           __func__);
       }