diff options
author | He Junyan <junyan.he@hotmail.com> | 2020-04-10 21:21:43 +0800 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2020-05-16 19:58:15 +0000 |
commit | 2b1809e9d384c143487ef6065af0cf0112669b06 (patch) | |
tree | 464ea16a91e88c0bee8b80d69e0394bc8a3df4d8 /gst-libs | |
parent | 5d56ce69277c844d10d54b2dfd278cd44ca79db6 (diff) |
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>
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/vaapi/video-format.c | 33 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/video-format.h | 3 |
2 files changed, 36 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/video-format.c b/gst-libs/gst/vaapi/video-format.c index 5ebb211c..6c1e8e7f 100644 --- a/gst-libs/gst/vaapi/video-format.c +++ b/gst-libs/gst/vaapi/video-format.c @@ -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; diff --git a/gst-libs/gst/vaapi/video-format.h b/gst-libs/gst/vaapi/video-format.h index 466e115a..953194e5 100644 --- a/gst-libs/gst/vaapi/video-format.h +++ b/gst-libs/gst/vaapi/video-format.h @@ -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); |