mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 05:56:31 +00:00
video-format: add gst_video_formats_raw()
The existing GST_VIDEO_FORMATS_ALL macro is not binding friendly. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/676>
This commit is contained in:
parent
51b057ea26
commit
f42e67c639
2 changed files with 65 additions and 0 deletions
|
@ -7031,3 +7031,65 @@ gst_video_format_info_component (const GstVideoFormatInfo * info, guint plane,
|
|||
for (c = i; c < GST_VIDEO_MAX_COMPONENTS; c++)
|
||||
components[c] = -1;
|
||||
}
|
||||
|
||||
struct RawVideoFormats
|
||||
{
|
||||
GstVideoFormat *formats;
|
||||
guint n;
|
||||
};
|
||||
|
||||
static gpointer
|
||||
generate_raw_video_formats (gpointer data)
|
||||
{
|
||||
GValue list = G_VALUE_INIT;
|
||||
struct RawVideoFormats *all = g_new (struct RawVideoFormats, 1);
|
||||
gchar *tmp;
|
||||
guint i;
|
||||
|
||||
g_value_init (&list, GST_TYPE_LIST);
|
||||
/* Workaround a bug in our parser that would lead to segfaults
|
||||
* when deserializing container types using static strings,
|
||||
* see https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/446 */
|
||||
tmp = g_strdup (GST_VIDEO_FORMATS_ALL);
|
||||
g_assert (gst_value_deserialize (&list, tmp));
|
||||
g_free (tmp);
|
||||
|
||||
all->n = gst_value_list_get_size (&list);
|
||||
all->formats = g_new (GstVideoFormat, all->n);
|
||||
|
||||
for (i = 0; i < all->n; i++) {
|
||||
const GValue *v = gst_value_list_get_value (&list, i);
|
||||
|
||||
all->formats[i] = gst_video_format_from_string (g_value_get_string (v));
|
||||
g_assert (all->formats[i] != GST_VIDEO_FORMAT_UNKNOWN
|
||||
&& all->formats[i] != GST_VIDEO_FORMAT_ENCODED);
|
||||
}
|
||||
|
||||
g_value_unset (&list);
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_video_formats_raw:
|
||||
* @len: (out): the number of elements in the returned array
|
||||
*
|
||||
* Return all the raw video formats supported by GStreamer.
|
||||
*
|
||||
* Returns: (transfer none) (array length=len): an array of #GstVideoFormat
|
||||
* Since: 1.18
|
||||
*/
|
||||
const GstVideoFormat *
|
||||
gst_video_formats_raw (guint * len)
|
||||
{
|
||||
static GOnce raw_video_formats_once = G_ONCE_INIT;
|
||||
struct RawVideoFormats *all;
|
||||
|
||||
g_return_val_if_fail (len, NULL);
|
||||
|
||||
g_once (&raw_video_formats_once, generate_raw_video_formats, NULL);
|
||||
|
||||
all = raw_video_formats_once.retval;
|
||||
*len = all->n;
|
||||
return all->formats;
|
||||
}
|
||||
|
|
|
@ -590,6 +590,9 @@ gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsi
|
|||
"Y412_BE, Y412_LE, Y444_12BE, Y444_12LE, GRAY10_LE32, NV12_10LE32, NV16_10LE32, NV12_10LE40, " \
|
||||
"Y444_16BE, Y444_16LE, P016_BE, P016_LE }"
|
||||
|
||||
GST_VIDEO_API
|
||||
const GstVideoFormat * gst_video_formats_raw (guint * len);
|
||||
|
||||
/**
|
||||
* GST_VIDEO_CAPS_MAKE:
|
||||
* @format: string format that describes the pixel layout, as string
|
||||
|
|
Loading…
Reference in a new issue