[FFmpeg-devel] [PATCH v3] libavcodec/qsvenc_hevc: encode RGB format rawvideo
Xiang, Haihao
haihao.xiang at intel.com
Mon Feb 21 04:05:57 EET 2022
On Fri, 2022-02-18 at 13:50 +0800, Wenbin Chen wrote:
> 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 at intel.com>
> ---
> libavcodec/qsv.c | 16 ++++++++++++++++
> libavcodec/qsvenc.c | 8 ++++++++
> libavcodec/qsvenc_hevc.c | 6 ++++++
> 3 files changed, 30 insertions(+)
>
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> index 1a432dbd82..b75877e698 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -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:
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index 07be4287b7..40d60cde3c 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -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);
> diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
> index 5cac141c4d..ade546d4ca 100644
> --- a/libavcodec/qsvenc_hevc.c
> +++ b/libavcodec/qsvenc_hevc.c
> @@ -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,
LGTM, will apply
-Haihao
More information about the ffmpeg-devel
mailing list