Browse code

qsvenc: add support for p010

Anton Khirnov authored on 2016/06/23 02:57:28
Showing 3 changed files
... ...
@@ -385,7 +385,16 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
385 385
         AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx;
386 386
         q->param.mfx.FrameInfo = frames_hwctx->surfaces[0].Info;
387 387
     } else {
388
-        q->param.mfx.FrameInfo.FourCC         = MFX_FOURCC_NV12;
388
+        enum AVPixelFormat sw_format = avctx->pix_fmt == AV_PIX_FMT_QSV ?
389
+                                       avctx->sw_pix_fmt : avctx->pix_fmt;
390
+        const AVPixFmtDescriptor *desc;
391
+
392
+        desc = av_pix_fmt_desc_get(sw_format);
393
+        if (!desc)
394
+            return AVERROR_BUG;
395
+
396
+        ff_qsv_map_pixfmt(sw_format, &q->param.mfx.FrameInfo.FourCC);
397
+
389 398
         q->param.mfx.FrameInfo.Width          = FFALIGN(avctx->width, q->width_align);
390 399
         q->param.mfx.FrameInfo.Height         = FFALIGN(avctx->height, 32);
391 400
         q->param.mfx.FrameInfo.CropX          = 0;
... ...
@@ -396,8 +405,9 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
396 396
         q->param.mfx.FrameInfo.AspectRatioH   = avctx->sample_aspect_ratio.den;
397 397
         q->param.mfx.FrameInfo.PicStruct      = MFX_PICSTRUCT_PROGRESSIVE;
398 398
         q->param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
399
-        q->param.mfx.FrameInfo.BitDepthLuma   = 8;
400
-        q->param.mfx.FrameInfo.BitDepthChroma = 8;
399
+        q->param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
400
+        q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
401
+        q->param.mfx.FrameInfo.Shift          = desc->comp[0].depth > 8;
401 402
     }
402 403
 
403 404
     if (avctx->framerate.den > 0 && avctx->framerate.num > 0) {
... ...
@@ -126,6 +126,7 @@ AVCodec ff_h264_qsv_encoder = {
126 126
     .close          = qsv_enc_close,
127 127
     .capabilities   = AV_CODEC_CAP_DELAY,
128 128
     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
129
+                                                    AV_PIX_FMT_P010,
129 130
                                                     AV_PIX_FMT_QSV,
130 131
                                                     AV_PIX_FMT_NONE },
131 132
     .priv_class     = &class,
... ...
@@ -262,6 +262,7 @@ AVCodec ff_hevc_qsv_encoder = {
262 262
     .close          = qsv_enc_close,
263 263
     .capabilities   = AV_CODEC_CAP_DELAY,
264 264
     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
265
+                                                    AV_PIX_FMT_P010,
265 266
                                                     AV_PIX_FMT_QSV,
266 267
                                                     AV_PIX_FMT_NONE },
267 268
     .priv_class     = &class,