From 631489de230d5e1c43f8ded596e220561824ca1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Fri, 8 May 2020 11:06:42 +0200 Subject: [PATCH] video-hdr: add hdr formats Provide enum and helper method to set the hdr format name in caps by example. Part-of: --- gst-libs/gst/video/video-hdr.c | 42 ++++++++++++++++++++++++++++++++++ gst-libs/gst/video/video-hdr.h | 6 +++++ 2 files changed, 48 insertions(+) diff --git a/gst-libs/gst/video/video-hdr.c b/gst-libs/gst/video/video-hdr.c index 5f924cd1e0..3486c77f13 100644 --- a/gst-libs/gst/video/video-hdr.c +++ b/gst-libs/gst/video/video-hdr.c @@ -45,6 +45,48 @@ (m)->max_display_mastering_luminance, \ (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 diff --git a/gst-libs/gst/video/video-hdr.h b/gst-libs/gst/video/video-hdr.h index 54d6e3af91..57c038dbea 100644 --- a/gst-libs/gst/video/video-hdr.h +++ b/gst-libs/gst/video/video-hdr.h @@ -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