mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-01 22:21:13 +00:00
libs: video-format: add a helper function of get_formats_by_chroma.
The function iterates all supported video formats and returns the formats belong to the specified chroma type. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/315>
This commit is contained in:
parent
5d56ce6927
commit
2b1809e9d3
2 changed files with 36 additions and 0 deletions
|
@ -476,6 +476,39 @@ gst_vaapi_video_format_get_best_native (GstVideoFormat format)
|
|||
return gst_vaapi_video_format_from_chroma (chroma_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_video_format_get_formats_by_chroma:
|
||||
* @chroma: a #GstVaapiChromaType
|
||||
*
|
||||
* Get all #GstVideoFormat which belong to #GstVaapiChromaType.
|
||||
*
|
||||
* Returns: an array of #GstVideoFormat.
|
||||
**/
|
||||
GArray *
|
||||
gst_vaapi_video_format_get_formats_by_chroma (guint chroma)
|
||||
{
|
||||
const GstVideoFormatMap *entry;
|
||||
GArray *formats;
|
||||
guint i;
|
||||
|
||||
formats = g_array_new (FALSE, FALSE, sizeof (GstVideoFormat));
|
||||
if (!formats)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < gst_vaapi_video_formats_map->len; i++) {
|
||||
entry = &g_array_index (gst_vaapi_video_formats_map, GstVideoFormatMap, i);
|
||||
if (entry->chroma_type == chroma)
|
||||
g_array_append_val (formats, entry->format);
|
||||
}
|
||||
|
||||
if (formats->len == 0) {
|
||||
g_array_unref (formats);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return formats;
|
||||
}
|
||||
|
||||
struct ImageFormatsData
|
||||
{
|
||||
VAImageFormat *formats;
|
||||
|
|
|
@ -64,6 +64,9 @@ gst_vaapi_video_format_from_chroma (guint chroma);
|
|||
GstVideoFormat
|
||||
gst_vaapi_video_format_get_best_native (GstVideoFormat format);
|
||||
|
||||
GArray *
|
||||
gst_vaapi_video_format_get_formats_by_chroma (guint chroma);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_video_format_create_map (VAImageFormat * formats, guint n);
|
||||
|
||||
|
|
Loading…
Reference in a new issue