msdk: Modify the caps order when register plugins

With this patch, the caps is registered in the order of memory features
as: VAMemory, DMABuf then raw caps in linux path, and D3D11Memory then
raw caps in windows path. It helps to prioritize the video memory for all
msdk elements when doing negotiation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5898>
This commit is contained in:
Mengkejiergeli Ba 2024-01-08 11:09:51 +08:00 committed by GStreamer Marge Bot
parent 7d62166098
commit 14c5d3ee91

View file

@ -887,26 +887,24 @@ static GstCaps *
_enc_create_sink_caps (GstMsdkContext * context, guint codec_id,
const ResolutionRange * res, GValue * supported_formats)
{
GstCaps *caps, *dma_caps;
caps = gst_caps_from_string ("video/x-raw");
gst_caps_set_value (caps, "format", supported_formats);
GstCaps *caps, *dma_caps, *raw_caps;
#ifndef _WIN32
caps = gst_caps_from_string
("video/x-raw(memory:VAMemory), format=(string){ NV12 }");
dma_caps = _create_dma_drm_caps (context, GST_MSDK_JOB_ENCODER,
supported_formats);
gst_caps_append (caps, dma_caps);
gst_caps_append (caps,
gst_caps_from_string
("video/x-raw(memory:VAMemory), format=(string){ NV12 }"));
#else
VAR_UNUSED (dma_caps);
gst_caps_append (caps,
gst_caps_from_string
("video/x-raw(memory:D3D11Memory), format=(string){ NV12 }"));
caps = gst_caps_from_string
("video/x-raw(memory:D3D11Memory), format=(string){ NV12 }");
#endif
raw_caps = gst_caps_from_string ("video/x-raw");
gst_caps_set_value (raw_caps, "format", supported_formats);
gst_caps_append (caps, raw_caps);
gst_caps_set_simple (caps,
"width", GST_TYPE_INT_RANGE, res->min_width, res->max_width,
"height", GST_TYPE_INT_RANGE, res->min_height, res->max_height,
@ -1207,30 +1205,28 @@ _dec_create_src_caps (GstMsdkContext * context,
mfxSession * session, guint codec_id,
mfxDecoderDescription * dec_desc, GValue * supported_formats)
{
GstCaps *caps, *dma_caps;
GstCaps *caps, *dma_caps, *raw_caps;
ResolutionRange res = { 1, G_MAXUINT16, 1, G_MAXUINT16 };
if (!_dec_get_resolution_range (session, dec_desc, codec_id, &res))
return NULL;
caps = gst_caps_from_string ("video/x-raw");
gst_caps_set_value (caps, "format", supported_formats);
#ifndef _WIN32
caps = gst_caps_from_string
("video/x-raw(memory:VAMemory), format=(string){ NV12 }");
dma_caps = _create_dma_drm_caps (context, GST_MSDK_JOB_DECODER,
supported_formats);
gst_caps_append (caps, dma_caps);
gst_caps_append (caps,
gst_caps_from_string
("video/x-raw(memory:VAMemory), format=(string){ NV12 }"));
#else
VAR_UNUSED (dma_caps);
gst_caps_append (caps,
gst_caps_from_string
("video/x-raw(memory:D3D11Memory), format=(string){ NV12 }"));
caps = gst_caps_from_string
("video/x-raw(memory:D3D11Memory), format=(string){ NV12 }");
#endif
raw_caps = gst_caps_from_string ("video/x-raw");
gst_caps_set_value (raw_caps, "format", supported_formats);
gst_caps_append (caps, raw_caps);
gst_caps_set_simple (caps,
"width", GST_TYPE_INT_RANGE, res.min_width, res.max_width,
"height", GST_TYPE_INT_RANGE, res.min_height, res.max_height,
@ -1460,24 +1456,21 @@ static GstCaps *
_vpp_create_caps (GstMsdkContext * context,
GValue * supported_fmts, ResolutionRange * res)
{
GstCaps *caps, *dma_caps;
caps = gst_caps_from_string ("video/x-raw");
gst_caps_set_value (caps, "format", supported_fmts);
GstCaps *caps, *dma_caps, *raw_caps;
#ifndef _WIN32
caps = gst_caps_from_string ("video/x-raw(memory:VAMemory), "
"format=(string){ NV12, VUYA, P010_10LE }");
dma_caps = _create_dma_drm_caps (context, GST_MSDK_JOB_VPP, supported_fmts);
gst_caps_append (caps, dma_caps);
gst_caps_append (caps,
gst_caps_from_string ("video/x-raw(memory:VAMemory), "
"format=(string){ NV12, VUYA, P010_10LE }"));
#else
VAR_UNUSED (dma_caps);
gst_caps_append (caps,
gst_caps_from_string ("video/x-raw(memory:D3D11Memory), "
"format=(string){ NV12, VUYA, P010_10LE }"));
caps = gst_caps_from_string ("video/x-raw(memory:D3D11Memory), "
"format=(string){ NV12, VUYA, P010_10LE }");
#endif
raw_caps = gst_caps_from_string ("video/x-raw");
gst_caps_set_value (raw_caps, "format", supported_fmts);
gst_caps_append (caps, raw_caps);
gst_caps_set_simple (caps,
"width", GST_TYPE_INT_RANGE, res->min_width, res->max_width,