From 326b755332d4dd8cad6aa30e6fc485b15b88a845 Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Wed, 18 Mar 2020 10:11:19 +0800 Subject: [PATCH] msdkh265enc: support 8-bit 422 encoding The media driver can support HEVC 8-bit 422 encoding for non-lowpower mode since ICL[1], so VPP is not needed for this case. Sample pipeline: gst-launch-1.0 videotestsrc ! video/x-raw,format=YUY2 ! msdkh265enc ! \ filesink location=output.h265 [1] https://github.com/intel/media-driver#decodingencoding-features --- sys/msdk/gstmsdkenc.c | 1 + sys/msdk/gstmsdkenc.h | 2 ++ sys/msdk/gstmsdkh265enc.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/sys/msdk/gstmsdkenc.c b/sys/msdk/gstmsdkenc.c index 2f4a67ca4b..0d76ebe4bd 100644 --- a/sys/msdk/gstmsdkenc.c +++ b/sys/msdk/gstmsdkenc.c @@ -376,6 +376,7 @@ gst_msdkenc_init_encoder (GstMsdkEnc * thiz) GST_OBJECT_LOCK (thiz); session = gst_msdk_context_get_session (thiz->context); + thiz->codename = msdk_get_platform_codename (session); thiz->has_vpp = FALSE; if (thiz->use_video_memory) diff --git a/sys/msdk/gstmsdkenc.h b/sys/msdk/gstmsdkenc.h index 2703fb188a..95fa627237 100644 --- a/sys/msdk/gstmsdkenc.h +++ b/sys/msdk/gstmsdkenc.h @@ -159,6 +159,8 @@ struct _GstMsdkEnc gint16 adaptive_b; gboolean reconfig; + + guint16 codename; }; struct _GstMsdkEncClass diff --git a/sys/msdk/gstmsdkh265enc.c b/sys/msdk/gstmsdkh265enc.c index 378028f8a2..a83b677cd5 100644 --- a/sys/msdk/gstmsdkh265enc.c +++ b/sys/msdk/gstmsdkh265enc.c @@ -110,6 +110,7 @@ gst_msdkh265enc_configure (GstMsdkEnc * encoder) encoder->param.mfx.CodecProfile = MFX_PROFILE_HEVC_MAIN10; break; case MFX_FOURCC_AYUV: + case MFX_FOURCC_YUY2: #if (MFX_VERSION >= 1027) case MFX_FOURCC_Y410: case MFX_FOURCC_Y210: @@ -211,6 +212,11 @@ gst_msdkh265enc_set_src_caps (GstMsdkEnc * encoder) case MFX_FOURCC_AYUV: gst_structure_set (structure, "profile", G_TYPE_STRING, "main-444", NULL); break; + case MFX_FOURCC_YUY2: + /* The profile is main-422-10 for 8-bit 422 */ + gst_structure_set (structure, "profile", G_TYPE_STRING, "main-422-10", + NULL); + break; #if (MFX_VERSION >= 1027) case MFX_FOURCC_Y410: gst_structure_set (structure, "profile", G_TYPE_STRING, "main-444-10", @@ -320,6 +326,36 @@ gst_msdkh265enc_set_extra_params (GstMsdkEnc * encoder, gst_msdkenc_add_extra_param (encoder, (mfxExtBuffer *) & h265enc->roi[0]); } +static gboolean +gst_msdkh265enc_need_conversion (GstMsdkEnc * encoder, GstVideoInfo * info, + GstVideoFormat * out_format) +{ + GstMsdkH265Enc *h265enc = GST_MSDKH265ENC (encoder); + + switch (GST_VIDEO_INFO_FORMAT (info)) { + case GST_VIDEO_FORMAT_NV12: + case GST_VIDEO_FORMAT_P010_10LE: + case GST_VIDEO_FORMAT_VUYA: +#if (MFX_VERSION >= 1027) + case GST_VIDEO_FORMAT_Y410: + case GST_VIDEO_FORMAT_Y210: +#endif + return FALSE; + + case GST_VIDEO_FORMAT_YUY2: +#if (MFX_VERSION >= 1027) + if (encoder->codename >= MFX_PLATFORM_ICELAKE && !h265enc->lowpower) + return FALSE; +#endif + default: + if (GST_VIDEO_INFO_COMP_DEPTH (info, 0) == 10) + *out_format = GST_VIDEO_FORMAT_P010_10LE; + else + *out_format = GST_VIDEO_FORMAT_NV12; + return TRUE; + } +} + static void gst_msdkh265enc_class_init (GstMsdkH265EncClass * klass) { @@ -339,6 +375,7 @@ gst_msdkh265enc_class_init (GstMsdkH265EncClass * klass) encoder_class->set_src_caps = gst_msdkh265enc_set_src_caps; encoder_class->need_reconfig = gst_msdkh265enc_need_reconfig; encoder_class->set_extra_params = gst_msdkh265enc_set_extra_params; + encoder_class->need_conversion = gst_msdkh265enc_need_conversion; gst_msdkenc_install_common_properties (encoder_class);