qsvdec: add support for P010 (10-bit 420) decoding
authorAnton Khirnov <anton@khirnov.net>
Wed, 22 Jun 2016 09:53:00 +0000 (11:53 +0200)
committerAnton Khirnov <anton@khirnov.net>
Sun, 3 Jul 2016 07:13:29 +0000 (09:13 +0200)
libavcodec/qsv.c
libavcodec/qsvdec.c
libavcodec/qsvdec_h2645.c

index 5be6405..5f7653a 100644 (file)
@@ -96,6 +96,9 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc)
     case AV_PIX_FMT_YUVJ420P:
         *fourcc = MFX_FOURCC_NV12;
         return AV_PIX_FMT_NV12;
+    case AV_PIX_FMT_YUV420P10:
+        *fourcc = MFX_FOURCC_P010;
+        return AV_PIX_FMT_P010;
     default:
         return AVERROR(ENOSYS);
     }
index 02d5e28..929b9af 100644 (file)
@@ -31,6 +31,7 @@
 #include "libavutil/hwcontext_qsv.h"
 #include "libavutil/mem.h"
 #include "libavutil/log.h"
+#include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/time.h"
 
@@ -86,11 +87,16 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses
 
 static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
 {
+    const AVPixFmtDescriptor *desc;
     mfxSession session = NULL;
     int iopattern = 0;
     mfxVideoParam param = { { 0 } };
     int ret;
 
+    desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
+    if (!desc)
+        return AVERROR_BUG;
+
     if (!q->async_fifo) {
         q->async_fifo = av_fifo_alloc((1 + q->async_depth) *
                                       (sizeof(mfxSyncPoint*) + sizeof(QSVFrame*)));
@@ -136,9 +142,9 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
     param.mfx.CodecProfile = avctx->profile;
     param.mfx.CodecLevel   = avctx->level;
 
-    param.mfx.FrameInfo.BitDepthLuma   = 8;
-    param.mfx.FrameInfo.BitDepthChroma = 8;
-    param.mfx.FrameInfo.Shift          = 0;
+    param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
+    param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
+    param.mfx.FrameInfo.Shift          = desc->comp[0].depth > 8;
     param.mfx.FrameInfo.FourCC         = q->fourcc;
     param.mfx.FrameInfo.Width          = avctx->coded_width;
     param.mfx.FrameInfo.Height         = avctx->coded_height;
@@ -452,7 +458,8 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q,
         qsv_format = ff_qsv_map_pixfmt(q->parser->format, &q->fourcc);
         if (qsv_format < 0) {
             av_log(avctx, AV_LOG_ERROR,
-                   "Only 8-bit YUV420 streams are supported.\n");
+                   "Decoding pixel format '%s' is not supported\n",
+                   av_get_pix_fmt_name(q->parser->format));
             ret = AVERROR(ENOSYS);
             goto reinit_fail;
         }
index 4bc1cd3..a26f150 100644 (file)
@@ -269,6 +269,7 @@ AVCodec ff_hevc_qsv_decoder = {
     .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1,
     .priv_class     = &hevc_class,
     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+                                                    AV_PIX_FMT_P010,
                                                     AV_PIX_FMT_QSV,
                                                     AV_PIX_FMT_NONE },
 };
@@ -307,6 +308,7 @@ AVCodec ff_h264_qsv_decoder = {
     .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1,
     .priv_class     = &class,
     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+                                                    AV_PIX_FMT_P010,
                                                     AV_PIX_FMT_QSV,
                                                     AV_PIX_FMT_NONE },
 };