mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 21:48:55 +00:00
video: Add support for a list of any video formats
Adds list of formats that should be used by element in needs to passthrough video. It contains the full list of video format plus DMA_DRM format and will be extended in the future as needed. This patches includes 3 new symbols: - GST_VIDEO_FORMATS_ANY_STR - GST_VIDEO_FORMATS_ANY - gst_video_formats_any() The last one can be used by bindings or for code that prefers having GstVideoFormat values instead of strings. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5386>
This commit is contained in:
parent
6c84d7ef0d
commit
0fc63b58d0
4 changed files with 115 additions and 7 deletions
|
@ -2977,6 +2977,20 @@ Formats are sorted by decreasing "quality", using these criteria by priority:
|
||||||
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h"/>
|
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h"/>
|
||||||
<type name="utf8" c:type="gchar*"/>
|
<type name="utf8" c:type="gchar*"/>
|
||||||
</constant>
|
</constant>
|
||||||
|
<constant name="VIDEO_FORMATS_ANY" value="{ " c:type="GST_VIDEO_FORMATS_ANY" version="1.24">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h">This is similar to %GST_VIDEO_FORMATS_ALL but includes formats like DMA_DRM
|
||||||
|
that do not have a software converter. This should be used for passthrough
|
||||||
|
template caps.</doc>
|
||||||
|
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h"/>
|
||||||
|
<type name="utf8" c:type="gchar*"/>
|
||||||
|
</constant>
|
||||||
|
<constant name="VIDEO_FORMATS_ANY_STR" value="DMA_DRM, " c:type="GST_VIDEO_FORMATS_ANY_STR" version="1.24">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h">This is similar to %GST_VIDEO_FORMATS_ALL_STR but includes formats like
|
||||||
|
DMA_DRM for which no software converter exists. This should be used for
|
||||||
|
passthrough template caps.</doc>
|
||||||
|
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h"/>
|
||||||
|
<type name="utf8" c:type="gchar*"/>
|
||||||
|
</constant>
|
||||||
<function-macro name="VIDEO_FORMAT_INFO_BITS" c:identifier="GST_VIDEO_FORMAT_INFO_BITS" introspectable="0">
|
<function-macro name="VIDEO_FORMAT_INFO_BITS" c:identifier="GST_VIDEO_FORMAT_INFO_BITS" introspectable="0">
|
||||||
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h"/>
|
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h"/>
|
||||||
<parameters>
|
<parameters>
|
||||||
|
@ -18499,6 +18513,25 @@ the #GstVideoFormat if there is one, or NULL otherwise.</doc>
|
||||||
</parameter>
|
</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
</function>
|
</function>
|
||||||
|
<function name="video_formats_any" c:identifier="gst_video_formats_any" version="1.24">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.c">Return all the raw video formats supported by GStreamer including
|
||||||
|
special opaque formats such as %GST_VIDEO_FORMAT_DMA_DRM for which
|
||||||
|
no software conversion exists. This should be use for passthrough
|
||||||
|
template cpas.</doc>
|
||||||
|
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h"/>
|
||||||
|
<return-value transfer-ownership="none">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.c">an array of #GstVideoFormat</doc>
|
||||||
|
<array length="0" zero-terminated="0" c:type="const GstVideoFormat*">
|
||||||
|
<type name="VideoFormat" c:type="GstVideoFormat"/>
|
||||||
|
</array>
|
||||||
|
</return-value>
|
||||||
|
<parameters>
|
||||||
|
<parameter name="len" direction="out" caller-allocates="0" transfer-ownership="full">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.c">the number of elements in the returned array</doc>
|
||||||
|
<type name="guint" c:type="guint*"/>
|
||||||
|
</parameter>
|
||||||
|
</parameters>
|
||||||
|
</function>
|
||||||
<function name="video_formats_raw" c:identifier="gst_video_formats_raw" version="1.18">
|
<function name="video_formats_raw" c:identifier="gst_video_formats_raw" version="1.18">
|
||||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.c">Return all the raw video formats supported by GStreamer.</doc>
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.c">Return all the raw video formats supported by GStreamer.</doc>
|
||||||
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h"/>
|
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-format.h"/>
|
||||||
|
|
|
@ -8041,6 +8041,7 @@ gst_video_format_from_string (const gchar * format)
|
||||||
if (strcmp (GST_VIDEO_FORMAT_INFO_NAME (&formats[i].info), format) == 0)
|
if (strcmp (GST_VIDEO_FORMAT_INFO_NAME (&formats[i].info), format) == 0)
|
||||||
return GST_VIDEO_FORMAT_INFO_FORMAT (&formats[i].info);
|
return GST_VIDEO_FORMAT_INFO_FORMAT (&formats[i].info);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GST_VIDEO_FORMAT_UNKNOWN;
|
return GST_VIDEO_FORMAT_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8204,8 +8205,8 @@ struct RawVideoFormats
|
||||||
guint n;
|
guint n;
|
||||||
};
|
};
|
||||||
|
|
||||||
static gpointer
|
static struct RawVideoFormats *
|
||||||
generate_raw_video_formats (gpointer data)
|
generate_video_formats (const gchar * formats)
|
||||||
{
|
{
|
||||||
GValue list = G_VALUE_INIT;
|
GValue list = G_VALUE_INIT;
|
||||||
struct RawVideoFormats *all = g_new (struct RawVideoFormats, 1);
|
struct RawVideoFormats *all = g_new (struct RawVideoFormats, 1);
|
||||||
|
@ -8217,7 +8218,7 @@ generate_raw_video_formats (gpointer data)
|
||||||
/* Workaround a bug in our parser that would lead to segfaults
|
/* Workaround a bug in our parser that would lead to segfaults
|
||||||
* when deserializing container types using static strings,
|
* when deserializing container types using static strings,
|
||||||
* see https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/446 */
|
* see https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/446 */
|
||||||
tmp = g_strdup (GST_VIDEO_FORMATS_ALL);
|
tmp = g_strdup (formats);
|
||||||
res = gst_value_deserialize (&list, tmp);
|
res = gst_value_deserialize (&list, tmp);
|
||||||
g_assert (res);
|
g_assert (res);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
|
@ -8230,8 +8231,7 @@ generate_raw_video_formats (gpointer data)
|
||||||
|
|
||||||
all->formats[i] = gst_video_format_from_string (g_value_get_string (v));
|
all->formats[i] = gst_video_format_from_string (g_value_get_string (v));
|
||||||
g_assert (all->formats[i] != GST_VIDEO_FORMAT_UNKNOWN
|
g_assert (all->formats[i] != GST_VIDEO_FORMAT_UNKNOWN
|
||||||
&& all->formats[i] != GST_VIDEO_FORMAT_ENCODED
|
&& all->formats[i] != GST_VIDEO_FORMAT_ENCODED);
|
||||||
&& all->formats[i] != GST_VIDEO_FORMAT_DMA_DRM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_value_unset (&list);
|
g_value_unset (&list);
|
||||||
|
@ -8239,6 +8239,18 @@ generate_raw_video_formats (gpointer data)
|
||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
generate_raw_video_formats (gpointer data)
|
||||||
|
{
|
||||||
|
return generate_video_formats (GST_VIDEO_FORMATS_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
generate_any_video_formats (gpointer data)
|
||||||
|
{
|
||||||
|
return generate_video_formats (GST_VIDEO_FORMATS_ANY);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_video_formats_raw:
|
* gst_video_formats_raw:
|
||||||
* @len: (out): the number of elements in the returned array
|
* @len: (out): the number of elements in the returned array
|
||||||
|
@ -8263,6 +8275,33 @@ gst_video_formats_raw (guint * len)
|
||||||
return all->formats;
|
return all->formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_video_formats_any:
|
||||||
|
* @len: (out): the number of elements in the returned array
|
||||||
|
*
|
||||||
|
* Return all the raw video formats supported by GStreamer including
|
||||||
|
* special opaque formats such as %GST_VIDEO_FORMAT_DMA_DRM for which
|
||||||
|
* no software conversion exists. This should be use for passthrough
|
||||||
|
* template cpas.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none) (array length=len): an array of #GstVideoFormat
|
||||||
|
* Since: 1.24
|
||||||
|
*/
|
||||||
|
const GstVideoFormat *
|
||||||
|
gst_video_formats_any (guint * len)
|
||||||
|
{
|
||||||
|
static GOnce any_video_formats_once = G_ONCE_INIT;
|
||||||
|
struct RawVideoFormats *all;
|
||||||
|
|
||||||
|
g_return_val_if_fail (len, NULL);
|
||||||
|
|
||||||
|
g_once (&any_video_formats_once, generate_any_video_formats, NULL);
|
||||||
|
|
||||||
|
all = any_video_formats_once.retval;
|
||||||
|
*len = all->n;
|
||||||
|
return all->formats;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_video_make_raw_caps:
|
* gst_video_make_raw_caps:
|
||||||
* @formats: (array length=len) (nullable): an array of raw #GstVideoFormat, or %NULL
|
* @formats: (array length=len) (nullable): an array of raw #GstVideoFormat, or %NULL
|
||||||
|
@ -8318,8 +8357,7 @@ gst_video_make_raw_caps_with_features (const GstVideoFormat formats[],
|
||||||
GValue v = G_VALUE_INIT;
|
GValue v = G_VALUE_INIT;
|
||||||
|
|
||||||
g_return_val_if_fail (formats[i] != GST_VIDEO_FORMAT_UNKNOWN
|
g_return_val_if_fail (formats[i] != GST_VIDEO_FORMAT_UNKNOWN
|
||||||
&& formats[i] != GST_VIDEO_FORMAT_ENCODED
|
&& formats[i] != GST_VIDEO_FORMAT_ENCODED, NULL);
|
||||||
&& formats[i] != GST_VIDEO_FORMAT_DMA_DRM, NULL);
|
|
||||||
|
|
||||||
g_value_init (&v, G_TYPE_STRING);
|
g_value_init (&v, G_TYPE_STRING);
|
||||||
g_value_set_static_string (&v, gst_video_format_to_string (formats[i]));
|
g_value_set_static_string (&v, gst_video_format_to_string (formats[i]));
|
||||||
|
|
|
@ -1116,6 +1116,17 @@ gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsi
|
||||||
"GRAY10_LE32, GRAY8"
|
"GRAY10_LE32, GRAY8"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GST_VIDEO_FORMATS_ANY_STR:
|
||||||
|
*
|
||||||
|
* This is similar to %GST_VIDEO_FORMATS_ALL_STR but includes formats like
|
||||||
|
* DMA_DRM for which no software converter exists. This should be used for
|
||||||
|
* passthrough template caps.
|
||||||
|
*
|
||||||
|
* Since: 1.24
|
||||||
|
*/
|
||||||
|
#define GST_VIDEO_FORMATS_ANY_STR "DMA_DRM, " GST_VIDEO_FORMATS_ALL_STR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GST_VIDEO_FORMATS_ALL:
|
* GST_VIDEO_FORMATS_ALL:
|
||||||
*
|
*
|
||||||
|
@ -1137,9 +1148,23 @@ gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsi
|
||||||
*/
|
*/
|
||||||
#define GST_VIDEO_FORMATS_ALL "{ " GST_VIDEO_FORMATS_ALL_STR " }"
|
#define GST_VIDEO_FORMATS_ALL "{ " GST_VIDEO_FORMATS_ALL_STR " }"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GST_VIDEO_FORMATS_ANY:
|
||||||
|
*
|
||||||
|
* This is similar to %GST_VIDEO_FORMATS_ALL but includes formats like DMA_DRM
|
||||||
|
* that do not have a software converter. This should be used for passthrough
|
||||||
|
* template caps.
|
||||||
|
*
|
||||||
|
* Since: 1.24
|
||||||
|
*/
|
||||||
|
#define GST_VIDEO_FORMATS_ANY "{ " GST_VIDEO_FORMATS_ANY_STR " }"
|
||||||
|
|
||||||
GST_VIDEO_API
|
GST_VIDEO_API
|
||||||
const GstVideoFormat * gst_video_formats_raw (guint * len);
|
const GstVideoFormat * gst_video_formats_raw (guint * len);
|
||||||
|
|
||||||
|
GST_VIDEO_API
|
||||||
|
const GstVideoFormat * gst_video_formats_any (guint * len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GST_VIDEO_CAPS_MAKE:
|
* GST_VIDEO_CAPS_MAKE:
|
||||||
* @format: string format that describes the pixel layout, as string
|
* @format: string format that describes the pixel layout, as string
|
||||||
|
|
|
@ -4027,6 +4027,18 @@ GST_START_TEST (test_video_make_raw_caps)
|
||||||
fail_unless (gst_caps_is_equal (caps, expected));
|
fail_unless (gst_caps_is_equal (caps, expected));
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
gst_caps_unref (expected);
|
gst_caps_unref (expected);
|
||||||
|
|
||||||
|
guint len;
|
||||||
|
const GstVideoFormat *formats = gst_video_formats_any (&len);
|
||||||
|
caps =
|
||||||
|
gst_video_make_raw_caps_with_features (formats, len,
|
||||||
|
gst_caps_features_new_any ());
|
||||||
|
expected =
|
||||||
|
gst_caps_from_string (GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("ANY",
|
||||||
|
GST_VIDEO_FORMATS_ANY));
|
||||||
|
fail_unless (gst_caps_is_equal (caps, expected));
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
gst_caps_unref (expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
Loading…
Reference in a new issue