msdkh265enc: add support 12-bit 420 encoding
authorHaihao Xiang <haihao.xiang@intel.com>
Wed, 8 Apr 2020 06:40:56 +0000 (14:40 +0800)
committerHaihao Xiang <haihao.xiang@intel.com>
Mon, 1 Jun 2020 05:04:30 +0000 (05:04 +0000)
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>

sys/msdk/gstmsdkenc.c
sys/msdk/gstmsdkh265enc.c

index 0d76ebe..be19bda 100644 (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;
index 0ddc0ef..46aa375 100644 (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
@@ -224,6 +230,9 @@ gst_msdkh265enc_configure (GstMsdkEnc * encoder)
     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;
     default:
@@ -336,6 +345,11 @@ gst_msdkh265enc_set_src_caps (GstMsdkEnc * encoder)
           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);
       break;
@@ -462,6 +476,9 @@ gst_msdkh265enc_need_conversion (GstMsdkEnc * encoder, GstVideoInfo * info,
     case GST_VIDEO_FORMAT_Y410:
     case GST_VIDEO_FORMAT_Y210:
 #endif
+#if (MFX_VERSION >= 1031)
+    case GST_VIDEO_FORMAT_P012_LE:
+#endif
       return FALSE;
 
     case GST_VIDEO_FORMAT_YUY2: