video-hdr: add hdr formats
authorStéphane Cerveau <scerveau@collabora.com>
Fri, 8 May 2020 09:06:42 +0000 (11:06 +0200)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 15 Dec 2020 16:37:46 +0000 (16:37 +0000)
Provide enum and helper method to set the hdr format
name in caps by example.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/650>

gst-libs/gst/video/video-hdr.c
gst-libs/gst/video/video-hdr.h

index 5f924cd..3486c77 100644 (file)
   (m)->min_display_mastering_luminance
 
 /**
+ * gst_video_hdr_format_to_string:
+ * @format: a #GstVideoHDRFormat
+ *
+ * Returns: (nullable): a string containing a descriptive name for
+ * the #GstVideoHDRFormat if there is one, or %NULL otherwise.
+ *
+ * Since: 1.20
+ */
+const gchar *
+gst_video_hdr_format_to_string (GstVideoHDRFormat format)
+{
+  switch (format) {
+    case GST_VIDEO_HDR_FORMAT_HDR10:
+      return "hdr10";
+    case GST_VIDEO_HDR_FORMAT_HDR10_PLUS:
+      return "hdr10+";
+    default:
+      return NULL;
+  }
+}
+
+/**
+ * gst_video_hdr_format_from_string:
+ * @format: (nullable): a #GstVideoHDRFormat
+ *
+ * Returns: the #GstVideoHDRFormat for @format or GST_VIDEO_HDR_FORMAT_NONE when the
+ * string is not a known format.
+ *
+ * Since: 1.20
+ */
+GstVideoHDRFormat
+gst_video_hdr_format_from_string (const gchar * format)
+{
+  if (!g_strcmp0 (format, "hdr10"))
+    return GST_VIDEO_HDR_FORMAT_HDR10;
+  else if (!g_strcmp0 (format, "hdr10+"))
+    return GST_VIDEO_HDR_FORMAT_HDR10_PLUS;
+
+  return GST_VIDEO_HDR_FORMAT_NONE;
+}
+
+/**
  * gst_video_mastering_display_info_init:
  * @minfo: a #GstVideoMasteringDisplayInfo
  *
index 54d6e3a..57c038d 100644 (file)
@@ -56,6 +56,12 @@ typedef struct _GstVideoContentLightLevel GstVideoContentLightLevel;
 typedef struct _GstVideoHDR10Plus GstVideoHDR10Plus;
 typedef struct _GstVideoColorVolumeTransformation GstVideoColorVolumeTransformation;
 
+GST_VIDEO_API
+const gchar* gst_video_hdr_format_to_string (GstVideoHDRFormat format) G_GNUC_CONST;
+
+GST_VIDEO_API
+GstVideoHDRFormat gst_video_hdr_format_from_string (const gchar* format) G_GNUC_CONST;
+
 /**
  * GstVideoHDRMeta:
  * @meta: parent #GstMeta