libavcodec/qsvenc_hevc: encode RGB format rawvideo

Add support for hevc_qsv to input RGB format frame. It will
transform frame to yuv inside MediaSDK instead of using auto
scale. Now hevc_qsv supports directly encoding BGRA and X2RGB10
format. The X2RGB10 correspond to the A2RGB20 format and BGRA
correspond to RGB4 format in MediaSDK.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
This commit is contained in:
Wenbin Chen 2022-02-18 13:50:12 +08:00 committed by Haihao Xiang
parent b1c26ce9fe
commit 9da19c2909
3 changed files with 30 additions and 0 deletions

View File

@ -189,6 +189,12 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc)
case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
case MFX_FOURCC_P8: return AV_PIX_FMT_PAL8;
#if QSV_VERSION_ATLEAST(1, 9)
case MFX_FOURCC_A2RGB10: return AV_PIX_FMT_X2RGB10;
#endif
#if QSV_VERSION_ATLEAST(1, 17)
case MFX_FOURCC_RGB4: return AV_PIX_FMT_BGRA;
#endif
#if CONFIG_VAAPI
case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
#if QSV_VERSION_ATLEAST(1, 27)
@ -211,6 +217,16 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc)
case AV_PIX_FMT_P010:
*fourcc = MFX_FOURCC_P010;
return AV_PIX_FMT_P010;
#if QSV_VERSION_ATLEAST(1, 9)
case AV_PIX_FMT_X2RGB10:
*fourcc = MFX_FOURCC_A2RGB10;
return AV_PIX_FMT_X2RGB10;
#endif
#if QSV_VERSION_ATLEAST(1, 17)
case AV_PIX_FMT_BGRA:
*fourcc = MFX_FOURCC_RGB4;
return AV_PIX_FMT_BGRA;
#endif
#if CONFIG_VAAPI
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUYV422:

View File

@ -1616,6 +1616,14 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame,
qf->surface.Data.V = qf->surface.Data.UV + 2;
break;
case AV_PIX_FMT_X2RGB10:
case AV_PIX_FMT_BGRA:
qf->surface.Data.B = qf->frame->data[0];
qf->surface.Data.G = qf->frame->data[0] + 1;
qf->surface.Data.R = qf->frame->data[0] + 2;
qf->surface.Data.A = qf->frame->data[0] + 3;
break;
default:
/* should not reach here */
av_assert0(0);

View File

@ -304,6 +304,12 @@ const AVCodec ff_hevc_qsv_encoder = {
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
AV_PIX_FMT_P010,
AV_PIX_FMT_QSV,
#if QSV_VERSION_ATLEAST(1, 17)
AV_PIX_FMT_BGRA,
#endif
#if QSV_VERSION_ATLEAST(1, 9)
AV_PIX_FMT_X2RGB10,
#endif
AV_PIX_FMT_NONE },
.priv_class = &class,
.defaults = qsv_enc_defaults,