From c063cb00e7b8756fe97b1faf616fe46cb189ab53 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Thu, 29 Jun 2017 23:11:06 +0200 Subject: [PATCH] Bug 1215089 - P3: Add support to 10 and 12 bits YUV images to FFmpeg decoder. r=kentuckyfriedtakahe This allows for decoding VP9 profile 2 and 3. At this stage, it is not possible to render the decoded frames. MozReview-Commit-ID: DFXMvaM8Ynb --HG-- extra : rebase_source : d9a639c2a65b1fd37d44336310af999e420155fe --- .../platforms/ffmpeg/FFmpegVideoDecoder.cpp | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp index cfa9c1d2eb7e..1cee0801b658 100644 --- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp @@ -19,6 +19,8 @@ #define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P #define AV_PIX_FMT_YUV422P PIX_FMT_YUV422P #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" @@ -58,6 +60,17 @@ ChoosePixelFormat(AVCodecContext* aCodecContext, const AVPixelFormat* aFormats) 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_YUV444P10LE: + FFMPEG_LOG("Requesting pixel format YUV444P10LE."); + return AV_PIX_FMT_YUV444P10LE; +#if LIBAVCODEC_VERSION_MAJOR >= 57 + case AV_PIX_FMT_YUV444P12LE: + FFMPEG_LOG("Requesting pixel format YUV444P12LE."); + return AV_PIX_FMT_YUV444P12LE; +#endif default: break; } @@ -321,15 +334,32 @@ FFmpegVideoDecoder::DoDecode(MediaRawData* aSample, b.mPlanes[0].mWidth = mFrame->width; b.mPlanes[0].mHeight = mFrame->height; - if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV444P) { + 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 +#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.mDepth = 10; + } +#if LIBAVCODEC_VERSION_MAJOR >= 57 + else if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV444P12LE) { + b.mDepth = 12; + } +#endif } else if (mCodecContext->pix_fmt == AV_PIX_FMT_YUV422P) { b.mPlanes[1].mWidth = b.mPlanes[2].mWidth = (mFrame->width + 1) >> 1; b.mPlanes[1].mHeight = b.mPlanes[2].mHeight = mFrame->height; } 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.mDepth = 10; + } } if (mLib->av_frame_get_colorspace) { switch (mLib->av_frame_get_colorspace(mFrame)) {