msdkh265enc: add support 12-bit 420 encoding

P016 is used for 12-bit encoding in MediaSDK, so the Shift flag is set
in the mfx parameters

Sample pipeline:
gst-launch-1.0 videotestsrc ! video/x-raw,format=P012_LE ! msdkh265enc ! \
fakesink

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1174>
This commit is contained in:
Haihao Xiang 2020-04-08 14:40:56 +08:00
parent 52be289847
commit f685893ed2
2 changed files with 28 additions and 2 deletions

View file

@ -573,6 +573,15 @@ gst_msdkenc_init_encoder (GstMsdkEnc * thiz)
thiz->param.mfx.FrameInfo.BitDepthLuma = 8;
thiz->param.mfx.FrameInfo.BitDepthChroma = 8;
break;
#if (MFX_VERSION >= 1031)
case GST_VIDEO_FORMAT_P012_LE:
thiz->param.mfx.FrameInfo.FourCC = MFX_FOURCC_P016;
thiz->param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
thiz->param.mfx.FrameInfo.BitDepthLuma = 12;
thiz->param.mfx.FrameInfo.BitDepthChroma = 12;
thiz->param.mfx.FrameInfo.Shift = 1;
break;
#endif
default:
thiz->param.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12;
thiz->param.mfx.FrameInfo.BitDepthLuma = 8;

View file

@ -54,11 +54,17 @@ enum
#define PROP_MAX_SLICE_SIZE_DEFAULT 0
#define RAW_FORMATS "NV12, I420, YV12, YUY2, UYVY, BGRA, P010_10LE, VUYA"
#define PROFILES "main, main-10, main-444"
#if (MFX_VERSION >= 1027)
#if (MFX_VERSION >= 1031)
#define COMMON_FORMAT "{ " RAW_FORMATS ", Y410, Y210, P012_LE }"
#define PRFOLIE_STR "{ " PROFILES ", main-444-10, main-422-10, main-12 }"
#elif (MFX_VERSION >= 1027)
#define COMMON_FORMAT "{ " RAW_FORMATS ", Y410, Y210 }"
#define PRFOLIE_STR "{ " PROFILES ", main-444-10, main-422-10 }"
#else
#define COMMON_FORMAT "{ " RAW_FORMATS " }"
#define PRFOLIE_STR "{ " PROFILES " }"
#endif
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
@ -74,7 +80,7 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
"framerate = (fraction) [0/1, MAX], "
"width = (int) [ 1, MAX ], height = (int) [ 1, MAX ], "
"stream-format = (string) byte-stream , alignment = (string) au , "
"profile = (string) { main, main-10, main-444, main-444-10, main-422-10 } ")
"profile = (string) " PRFOLIE_STR)
);
#define gst_msdkh265enc_parent_class parent_class
@ -223,6 +229,9 @@ gst_msdkh265enc_configure (GstMsdkEnc * encoder)
#if (MFX_VERSION >= 1027)
case MFX_FOURCC_Y410:
case MFX_FOURCC_Y210:
#endif
#if (MFX_VERSION >= 1031)
case MFX_FOURCC_P016:
#endif
encoder->param.mfx.CodecProfile = MFX_PROFILE_HEVC_REXT;
break;
@ -335,6 +344,11 @@ gst_msdkh265enc_set_src_caps (GstMsdkEnc * encoder)
gst_structure_set (structure, "profile", G_TYPE_STRING, "main-422-10",
NULL);
break;
#endif
#if (MFX_VERSION >= 1031)
case MFX_FOURCC_P016:
gst_structure_set (structure, "profile", G_TYPE_STRING, "main-12", NULL);
break;
#endif
default:
gst_structure_set (structure, "profile", G_TYPE_STRING, "main", NULL);
@ -461,6 +475,9 @@ gst_msdkh265enc_need_conversion (GstMsdkEnc * encoder, GstVideoInfo * info,
#if (MFX_VERSION >= 1027)
case GST_VIDEO_FORMAT_Y410:
case GST_VIDEO_FORMAT_Y210:
#endif
#if (MFX_VERSION >= 1031)
case GST_VIDEO_FORMAT_P012_LE:
#endif
return FALSE;