summaryrefslogtreecommitdiff
path: root/sys/va/gstvavideoformat.c
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-07-27 11:14:02 +0200
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-08-03 15:54:45 +0000
commit9db747e4d015afa645f2b0598259fb603af0d886 (patch)
tree80e74cf69ee70ac072a803e3e4fd1c5caa95c74a /sys/va/gstvavideoformat.c
parent39e55129d5af89028ba33556f45e6fe02574683a (diff)
downloadgstreamer-plugins-bad-9db747e4d015afa645f2b0598259fb603af0d886.tar.gz
va: display: add gst_va_display_get_image_formats()
For this it was also added gst_va_video_format_from_va_image_format() Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1483>
Diffstat (limited to 'sys/va/gstvavideoformat.c')
-rw-r--r--sys/va/gstvavideoformat.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/sys/va/gstvavideoformat.c b/sys/va/gstvavideoformat.c
index 5dbccf6a9..fbf8c53e9 100644
--- a/sys/va/gstvavideoformat.c
+++ b/sys/va/gstvavideoformat.c
@@ -125,6 +125,46 @@ get_format_map_from_video_format (GstVideoFormat format)
return NULL;
}
+static inline gboolean
+va_format_is_rgb (const VAImageFormat * va_format)
+{
+ return va_format->depth != 0;
+}
+
+static inline gboolean
+va_format_is_same_rgb (const VAImageFormat * fmt1, const VAImageFormat * fmt2)
+{
+ return (fmt1->red_mask == fmt2->red_mask
+ && fmt1->green_mask == fmt2->green_mask
+ && fmt1->blue_mask == fmt2->blue_mask
+ && fmt1->alpha_mask == fmt2->alpha_mask);
+}
+
+static inline gboolean
+va_format_is_same (const VAImageFormat * fmt1, const VAImageFormat * fmt2)
+{
+ if (fmt1->fourcc != fmt2->fourcc)
+ return FALSE;
+ if (fmt1->byte_order != VA_NSB_FIRST
+ && fmt2->byte_order != VA_NSB_FIRST
+ && fmt1->byte_order != fmt2->byte_order)
+ return FALSE;
+ return va_format_is_rgb (fmt1) ? va_format_is_same_rgb (fmt1, fmt2) : TRUE;
+}
+
+static const struct FormatMap *
+get_format_map_from_va_image_format (const VAImageFormat * va_format)
+{
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (format_map); i++) {
+ if (va_format_is_same (&format_map[i].va_format, va_format))
+ return &format_map[i];
+ }
+
+ return NULL;
+}
+
GstVideoFormat
gst_va_video_format_from_va_fourcc (guint va_fourcc)
{
@@ -156,3 +196,11 @@ gst_va_image_format_from_video_format (GstVideoFormat format)
return map ? &map->va_format : NULL;
}
+
+GstVideoFormat
+gst_va_video_format_from_va_image_format (const VAImageFormat * va_format)
+{
+ const struct FormatMap *map = get_format_map_from_va_image_format (va_format);
+
+ return map ? map->format : GST_VIDEO_FORMAT_UNKNOWN;
+}