qsvjpegenc: Add support for YUY2 format
authorSeungha Yang <seungha@centricular.com>
Wed, 2 Nov 2022 20:18:03 +0000 (05:18 +0900)
committerSeungha Yang <seungha@centricular.com>
Wed, 2 Nov 2022 21:40:10 +0000 (06:40 +0900)
Now GstD3D11 defines YUY2 format

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3316>

subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json
subprojects/gst-plugins-bad/sys/qsv/gstqsvjpegenc.cpp

index 119cc2f..4a6af69 100644 (file)
                 "klass": "Codec/Encoder/Video/Hardware",
                 "pad-templates": {
                     "sink": {
-                        "caps": "video/x-raw(memory:D3D11Memory):\n         format: { NV12, BGRA }\n          width: [ 16, 16384 ]\n         height: [ 16, 16384 ]\n\nvideo/x-raw(memory:VAMemory):\n         format: { NV12, BGRA }\n          width: [ 16, 16384 ]\n         height: [ 16, 16384 ]\nvideo/x-raw:\n         format: { NV12, BGRA }\n          width: [ 16, 16384 ]\n         height: [ 16, 16384 ]\n",
+                        "caps": "video/x-raw(memory:D3D11Memory):\n         format: { NV12, YUY2, BGRA }\n          width: [ 16, 16384 ]\n         height: [ 16, 16384 ]\n\nvideo/x-raw(memory:VAMemory):\n         format: { NV12, YUY2, BGRA }\n          width: [ 16, 16384 ]\n         height: [ 16, 16384 ]\nvideo/x-raw:\n         format: { NV12, YUY2, BGRA }\n          width: [ 16, 16384 ]\n         height: [ 16, 16384 ]\n",
                         "direction": "sink",
                         "presence": "always"
                     },
index 2e27359..685bc0d 100644 (file)
@@ -59,7 +59,7 @@ enum
 #define DEFAULT_JPEG_QUALITY 85
 
 #define DOC_SINK_CAPS_COMM \
-    "format = (string) { NV12, BGRA }, " \
+    "format = (string) { NV12, YUY2, BGRA }, " \
     "width = (int) [ 16, 16384 ], height = (int) [ 16, 16384 ]"
 
 #define DOC_SINK_CAPS \
@@ -290,6 +290,12 @@ gst_qsv_jpeg_enc_set_format (GstQsvEncoder * encoder,
       frame_info->BitDepthLuma = 8;
       frame_info->BitDepthChroma = 8;
       break;
+    case GST_VIDEO_FORMAT_YUY2:
+      frame_info->ChromaFormat = MFX_CHROMAFORMAT_YUV422;
+      frame_info->FourCC = MFX_FOURCC_YUY2;
+      frame_info->BitDepthLuma = 8;
+      frame_info->BitDepthChroma = 8;
+      break;
     case GST_VIDEO_FORMAT_BGRA:
       frame_info->ChromaFormat = MFX_CHROMAFORMAT_YUV444;
       frame_info->FourCC = MFX_FOURCC_RGB4;
@@ -411,11 +417,16 @@ gst_qsv_jpeg_enc_register (GstPlugin * plugin, guint rank, guint impl_index,
 
   supported_formats.push_back ("NV12");
 
+  mfx->FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV422;
+  mfx->FrameInfo.FourCC = MFX_FOURCC_YUY2;
+  status = MFXVideoENCODE_Query (session, &param, &param);
+  if (status == MFX_ERR_NONE)
+    supported_formats.push_back ("YUY2");
+
   mfx->FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV444;
   mfx->FrameInfo.FourCC = MFX_FOURCC_RGB4;
   status = MFXVideoENCODE_Query (session, &param, &param);
 
-  /* TODO: Add YUY2 support, d3d11 doesn't support the format yet */
   if (status == MFX_ERR_NONE)
     supported_formats.push_back ("BGRA");