Bug 1496222 - Add missing pixel format in FFmpeg decoder r=padenot
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 04 Oct 2018 09:46:33 +0000
changeset 439558 44cc1c10c5308cc36df0b2b6f4a5c63add05b968
parent 439557 22788736d03621751a3bf7a8f281cc5fe52bd8a2
child 439559 208624601a18d653e0b309798028fe8545b5eb1f
push id70391
push userjyavenard@mozilla.com
push dateThu, 04 Oct 2018 09:47:37 +0000
treeherderautoland@44cc1c10c530 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1496222
milestone64.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 1496222 - Add missing pixel format in FFmpeg decoder r=padenot Differential Revision: https://phabricator.services.mozilla.com/D7664
dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -12,19 +12,20 @@
 #include "VPXDecoder.h"
 #include "mozilla/layers/KnowsCompositor.h"
 
 #include "libavutil/pixfmt.h"
 #if LIBAVCODEC_VERSION_MAJOR < 54
 #define AVPixelFormat PixelFormat
 #define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
 #define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P
+#define AV_PIX_FMT_YUV420P10LE PIX_FMT_YUV420P10LE
 #define AV_PIX_FMT_YUV422P PIX_FMT_YUV422P
+#define AV_PIX_FMT_YUV422P10LE PIX_FMT_YUV422P10LE
 #define AV_PIX_FMT_YUV444P PIX_FMT_YUV444P
-#define AV_PIX_FMT_YUV420P10LE PIX_FMT_YUV420P10LE
 #define AV_PIX_FMT_YUV444P10LE PIX_FMT_YUV444P10LE
 #define AV_PIX_FMT_NONE PIX_FMT_NONE
 #endif
 #include "mozilla/PodOperations.h"
 #include "mozilla/TaskQueue.h"
 #include "nsThreadUtils.h"
 #include "prsystem.h"
 
@@ -43,35 +44,44 @@ using media::TimeUnit;
  * only non-HW accelerated format supported by FFmpeg's H264 and VP9 decoder.
  */
 static AVPixelFormat
 ChoosePixelFormat(AVCodecContext* aCodecContext, const AVPixelFormat* aFormats)
 {
   FFMPEG_LOG("Choosing FFmpeg pixel format for video decoding.");
   for (; *aFormats > -1; aFormats++) {
     switch (*aFormats) {
-      case AV_PIX_FMT_YUV444P:
-        FFMPEG_LOG("Requesting pixel format YUV444P.");
-        return AV_PIX_FMT_YUV444P;
-      case AV_PIX_FMT_YUV422P:
-        FFMPEG_LOG("Requesting pixel format YUV422P.");
-        return AV_PIX_FMT_YUV422P;
       case AV_PIX_FMT_YUV420P:
         FFMPEG_LOG("Requesting pixel format YUV420P.");
         return AV_PIX_FMT_YUV420P;
       case AV_PIX_FMT_YUVJ420P:
         FFMPEG_LOG("Requesting pixel format YUVJ420P.");
         return AV_PIX_FMT_YUVJ420P;
       case AV_PIX_FMT_YUV420P10LE:
         FFMPEG_LOG("Requesting pixel format YUV420P10LE.");
         return AV_PIX_FMT_YUV420P10LE;
+      case AV_PIX_FMT_YUV422P:
+        FFMPEG_LOG("Requesting pixel format YUV422P.");
+        return AV_PIX_FMT_YUV422P;
+      case AV_PIX_FMT_YUV422P10LE:
+        FFMPEG_LOG("Requesting pixel format YUV422P10LE.");
+        return AV_PIX_FMT_YUV422P10LE;
+      case AV_PIX_FMT_YUV444P:
+        FFMPEG_LOG("Requesting pixel format YUV444P.");
+        return AV_PIX_FMT_YUV444P;
       case AV_PIX_FMT_YUV444P10LE:
         FFMPEG_LOG("Requesting pixel format YUV444P10LE.");
         return AV_PIX_FMT_YUV444P10LE;
 #if LIBAVCODEC_VERSION_MAJOR >= 57
+      case AV_PIX_FMT_YUV420P12LE:
+        FFMPEG_LOG("Requesting pixel format YUV420P12LE.");
+        return AV_PIX_FMT_YUV420P12LE;
+      case AV_PIX_FMT_YUV422P12LE:
+        FFMPEG_LOG("Requesting pixel format YUV422P12LE.");
+        return AV_PIX_FMT_YUV422P12LE;
       case AV_PIX_FMT_YUV444P12LE:
         FFMPEG_LOG("Requesting pixel format YUV444P12LE.");
         return AV_PIX_FMT_YUV444P12LE;
 #endif
       default:
         break;
     }
   }
@@ -270,39 +280,56 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(
   b.mPlanes[1].mOffset = b.mPlanes[1].mSkip = 0;
   b.mPlanes[2].mOffset = b.mPlanes[2].mSkip = 0;
 
   b.mPlanes[0].mWidth = mFrame->width;
   b.mPlanes[0].mHeight = mFrame->height;
   if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV444P ||
       mCodecContext->pix_fmt == AV_PIX_FMT_YUV444P10LE
 #if LIBAVCODEC_VERSION_MAJOR >= 57
-      ||
-      mCodecContext->pix_fmt == AV_PIX_FMT_YUV444P12LE
+      || mCodecContext->pix_fmt == AV_PIX_FMT_YUV444P12LE
 #endif
-      ) {
+  ) {
     b.mPlanes[1].mWidth = b.mPlanes[2].mWidth = mFrame->width;
     b.mPlanes[1].mHeight = b.mPlanes[2].mHeight = mFrame->height;
     if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV444P10LE) {
       b.mColorDepth = gfx::ColorDepth::COLOR_10;
     }
 #if LIBAVCODEC_VERSION_MAJOR >= 57
     else if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV444P12LE) {
       b.mColorDepth = gfx::ColorDepth::COLOR_12;
     }
 #endif
-  } else if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV422P) {
+  } else if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV422P ||
+             mCodecContext->pix_fmt == AV_PIX_FMT_YUV422P10LE
+#if LIBAVCODEC_VERSION_MAJOR >= 57
+             || mCodecContext->pix_fmt == AV_PIX_FMT_YUV422P12LE
+#endif
+  ) {
     b.mPlanes[1].mWidth = b.mPlanes[2].mWidth = (mFrame->width + 1) >> 1;
     b.mPlanes[1].mHeight = b.mPlanes[2].mHeight = mFrame->height;
+    if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV422P10LE) {
+      b.mColorDepth = gfx::ColorDepth::COLOR_10;
+    }
+#if LIBAVCODEC_VERSION_MAJOR >= 57
+    else if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV422P12LE) {
+      b.mColorDepth = gfx::ColorDepth::COLOR_12;
+    }
+#endif
   } else {
     b.mPlanes[1].mWidth = b.mPlanes[2].mWidth = (mFrame->width + 1) >> 1;
     b.mPlanes[1].mHeight = b.mPlanes[2].mHeight = (mFrame->height + 1) >> 1;
     if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV420P10LE) {
       b.mColorDepth = gfx::ColorDepth::COLOR_10;
     }
+#if LIBAVCODEC_VERSION_MAJOR >= 57
+    else if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV420P12LE) {
+      b.mColorDepth = gfx::ColorDepth::COLOR_12;
+    }
+#endif
   }
   if (mLib->av_frame_get_colorspace) {
     switch (mLib->av_frame_get_colorspace(mFrame)) {
       case AVCOL_SPC_BT709:
         b.mYUVColorSpace = YUVColorSpace::BT709;
         break;
       case AVCOL_SPC_SMPTE170M:
       case AVCOL_SPC_BT470BG: