summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/vaapi/video-format.c33
-rw-r--r--gst-libs/gst/vaapi/video-format.h3
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);