Bug 1364870 - [ffmpeg] only check format if frame has been decoded. r=gerald, a=gchang
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 19 May 2017 09:52:12 +0200
changeset 585422 808da66ef9e2e19f930e4e03f67223b34e236845
parent 585421 87c4fb9521d8542d5003d6e1dc4a7ca25b13b327
child 585423 984ed49b767e0bb84fefe79a48ce611dcaa9ab2f
push id61106
push userbmo:dkeeler@mozilla.com
push dateFri, 26 May 2017 21:26:31 +0000
reviewersgerald, gchang
bugs1364870
milestone54.0
Bug 1364870 - [ffmpeg] only check format if frame has been decoded. r=gerald, a=gchang 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__);
       }