From f7cc7532742171f501a6fea329ed6e2f1336e2ad Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Thu, 3 Nov 2022 05:18:03 +0900 Subject: [PATCH] qsvjpegenc: Add support for YUY2 format Now GstD3D11 defines YUY2 format Part-of: --- .../docs/plugins/gst_plugins_cache.json | 2 +- .../gst-plugins-bad/sys/qsv/gstqsvjpegenc.cpp | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json index 119cc2f6c7..4a6af69510 100644 --- a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json +++ b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json @@ -226105,7 +226105,7 @@ "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" }, diff --git a/subprojects/gst-plugins-bad/sys/qsv/gstqsvjpegenc.cpp b/subprojects/gst-plugins-bad/sys/qsv/gstqsvjpegenc.cpp index 2e273596b4..685bc0d088 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/gstqsvjpegenc.cpp +++ b/subprojects/gst-plugins-bad/sys/qsv/gstqsvjpegenc.cpp @@ -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, ¶m, ¶m); + 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, ¶m, ¶m); - /* TODO: Add YUY2 support, d3d11 doesn't support the format yet */ if (status == MFX_ERR_NONE) supported_formats.push_back ("BGRA");