From b4b06cd6f069e1f790ce4adaca71421666467909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Wed, 9 Oct 2024 17:16:46 -0400 Subject: [PATCH] tests: va: fix vapostproc test for DMABuf Now it picks the first format in the template srcpad list and do the convertion. Also the format size is reduced because not all drives support 4K as DMABuf (radeonsi). Part-of: --- .../tests/check/elements/vapostproc.c | 59 ++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/tests/check/elements/vapostproc.c b/subprojects/gst-plugins-bad/tests/check/elements/vapostproc.c index daa9e007bb..959123c51a 100644 --- a/subprojects/gst-plugins-bad/tests/check/elements/vapostproc.c +++ b/subprojects/gst-plugins-bad/tests/check/elements/vapostproc.c @@ -62,18 +62,73 @@ GST_START_TEST (raw_copy) GST_END_TEST; +static GstCaps * +get_drmdma_format (void) +{ + GstElement *vpp; + GstCaps *templ, *allowed_caps, *drm_caps = NULL; + GstPad *srcpad; + guint i; + + vpp = gst_element_factory_make ("vapostproc", NULL); + if (!vpp) + return NULL; + srcpad = gst_element_get_static_pad (vpp, "src"); + fail_unless (srcpad != NULL); + templ = gst_pad_get_pad_template_caps (srcpad); + fail_unless (templ != NULL); + + allowed_caps = gst_caps_normalize (templ); + + for (i = 0; i < gst_caps_get_size (allowed_caps); ++i) { + GstStructure *new_structure; + GstStructure *structure; + + /* non-dmabuf caps don't describe drm-format: skip them */ + structure = gst_caps_get_structure (allowed_caps, i); + if (!gst_structure_has_field (structure, "drm-format")) + continue; + + drm_caps = gst_caps_new_empty (); + new_structure = gst_structure_copy (structure); + gst_structure_set (new_structure, "framerate", GST_TYPE_FRACTION, + 1, 1, NULL); + gst_structure_remove_field (new_structure, "width"); + gst_structure_remove_field (new_structure, "height"); + gst_caps_append_structure (drm_caps, new_structure); + gst_caps_set_features_simple (drm_caps, + gst_caps_features_new_single ("memory:DMABuf")); + + GST_DEBUG ("have caps %" GST_PTR_FORMAT, drm_caps); + /* should be fixed without width/height */ + fail_unless (gst_caps_is_fixed (drm_caps)); + break; + } + + gst_caps_unref (allowed_caps); + gst_object_unref (srcpad); + gst_object_unref (vpp); + + return drm_caps; +} + GST_START_TEST (dmabuf_copy) { GstHarness *h; GstBuffer *buf, *buf_copy; gboolean ret; + GstCaps *drm_caps; h = gst_harness_new_parse ("videotestsrc num-buffers=1 ! " "video/x-raw, width=(int)1024, height=(int)768 ! vapostproc"); ck_assert (h); - gst_harness_set_sink_caps_str (h, - "video/x-raw(memory:DMABuf), format=(string)NV12, width=(int)3840, height=(int)2160"); + drm_caps = get_drmdma_format (); + ck_assert (drm_caps); + gst_caps_set_simple (drm_caps, "width", G_TYPE_INT, 1600, "height", + G_TYPE_INT, 1200, NULL); + + gst_harness_set_sink_caps (h, drm_caps); gst_harness_add_propose_allocation_meta (h, GST_VIDEO_META_API_TYPE, NULL); gst_harness_play (h);