mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
video-color: Allow converting incomplete colorimetry to a string
This is only a good idea for non-raw caps. https://bugzilla.gnome.org/show_bug.cgi?id=771376
This commit is contained in:
parent
ad06b54443
commit
158eae7e7e
3 changed files with 42 additions and 15 deletions
|
@ -145,19 +145,44 @@ gst_video_colorimetry_from_string (GstVideoColorimetry * cinfo,
|
||||||
*/
|
*/
|
||||||
gchar *
|
gchar *
|
||||||
gst_video_colorimetry_to_string (const GstVideoColorimetry * cinfo)
|
gst_video_colorimetry_to_string (const GstVideoColorimetry * cinfo)
|
||||||
|
{
|
||||||
|
return gst_video_colorimetry_to_string_full (cinfo, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_video_colorimetry_to_string_full:
|
||||||
|
* @cinfo: a #GstVideoColorimetry
|
||||||
|
* @allow_unknown: Allow unknown fields
|
||||||
|
*
|
||||||
|
* Make a string representation of @cinfo. If @allow_unknown is TRUE,
|
||||||
|
* colorimetry is even returned if some but not all fields of @cinfo are
|
||||||
|
* UNKNOWN.
|
||||||
|
*
|
||||||
|
* Returns: a string representation of @cinfo.
|
||||||
|
*
|
||||||
|
* Since: 1.12
|
||||||
|
*/
|
||||||
|
gchar *
|
||||||
|
gst_video_colorimetry_to_string_full (const GstVideoColorimetry * cinfo,
|
||||||
|
gboolean allow_unknown)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
|
if (IS_UNKNOWN (cinfo))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; colorimetry[i].name; i++) {
|
for (i = 0; colorimetry[i].name; i++) {
|
||||||
if (IS_EQUAL (&colorimetry[i], cinfo)) {
|
if (IS_EQUAL (&colorimetry[i], cinfo)) {
|
||||||
return g_strdup (colorimetry[i].name);
|
return g_strdup (colorimetry[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!IS_UNKNOWN (cinfo)) {
|
|
||||||
return g_strdup_printf ("%d:%d:%d:%d", cinfo->range, cinfo->matrix,
|
if (!allow_unknown && (!cinfo->range || !cinfo->matrix || !cinfo->transfer
|
||||||
cinfo->transfer, cinfo->primaries);
|
|| !cinfo->primaries))
|
||||||
}
|
return NULL;
|
||||||
return NULL;
|
|
||||||
|
return g_strdup_printf ("%d:%d:%d:%d", cinfo->range, cinfo->matrix,
|
||||||
|
cinfo->transfer, cinfo->primaries);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -193,16 +193,17 @@ typedef struct {
|
||||||
#define GST_VIDEO_COLORIMETRY_SRGB "sRGB"
|
#define GST_VIDEO_COLORIMETRY_SRGB "sRGB"
|
||||||
#define GST_VIDEO_COLORIMETRY_BT2020 "bt2020"
|
#define GST_VIDEO_COLORIMETRY_BT2020 "bt2020"
|
||||||
|
|
||||||
gboolean gst_video_colorimetry_matches (const GstVideoColorimetry *cinfo, const gchar *color);
|
gboolean gst_video_colorimetry_matches (const GstVideoColorimetry *cinfo, const gchar *color);
|
||||||
gboolean gst_video_colorimetry_from_string (GstVideoColorimetry *cinfo, const gchar *color);
|
gboolean gst_video_colorimetry_from_string (GstVideoColorimetry *cinfo, const gchar *color);
|
||||||
gchar * gst_video_colorimetry_to_string (const GstVideoColorimetry *cinfo);
|
gchar * gst_video_colorimetry_to_string (const GstVideoColorimetry *cinfo);
|
||||||
gboolean gst_video_colorimetry_is_equal (const GstVideoColorimetry *cinfo, const GstVideoColorimetry *other);
|
gchar * gst_video_colorimetry_to_string_full (const GstVideoColorimetry *cinfo, gboolean allow_unknown);
|
||||||
|
gboolean gst_video_colorimetry_is_equal (const GstVideoColorimetry *cinfo, const GstVideoColorimetry *other);
|
||||||
|
|
||||||
/* compute offset and scale */
|
/* compute offset and scale */
|
||||||
void gst_video_color_range_offsets (GstVideoColorRange range,
|
void gst_video_color_range_offsets (GstVideoColorRange range,
|
||||||
const GstVideoFormatInfo *info,
|
const GstVideoFormatInfo *info,
|
||||||
gint offset[GST_VIDEO_MAX_COMPONENTS],
|
gint offset[GST_VIDEO_MAX_COMPONENTS],
|
||||||
gint scale[GST_VIDEO_MAX_COMPONENTS]);
|
gint scale[GST_VIDEO_MAX_COMPONENTS]);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -178,7 +178,7 @@ set_default_colorimetry (GstVideoInfo * info)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
validate_colorimetry (GstVideoInfo * info)
|
validate_colorimetry (const GstVideoInfo * info)
|
||||||
{
|
{
|
||||||
const GstVideoFormatInfo *finfo = info->finfo;
|
const GstVideoFormatInfo *finfo = info->finfo;
|
||||||
|
|
||||||
|
@ -571,6 +571,7 @@ gst_video_info_to_caps (GstVideoInfo * info)
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (info != NULL, NULL);
|
||||||
g_return_val_if_fail (info->finfo != NULL, NULL);
|
g_return_val_if_fail (info->finfo != NULL, NULL);
|
||||||
g_return_val_if_fail (info->finfo->format != GST_VIDEO_FORMAT_UNKNOWN, NULL);
|
g_return_val_if_fail (info->finfo->format != GST_VIDEO_FORMAT_UNKNOWN, NULL);
|
||||||
|
g_return_val_if_fail (info->finfo->format != GST_VIDEO_FORMAT_ENCODED, NULL);
|
||||||
|
|
||||||
format = gst_video_format_to_string (info->finfo->format);
|
format = gst_video_format_to_string (info->finfo->format);
|
||||||
g_return_val_if_fail (format != NULL, NULL);
|
g_return_val_if_fail (format != NULL, NULL);
|
||||||
|
@ -644,7 +645,7 @@ gst_video_info_to_caps (GstVideoInfo * info)
|
||||||
colorimetry.matrix);
|
colorimetry.matrix);
|
||||||
colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_RGB;
|
||||||
}
|
}
|
||||||
if ((color = gst_video_colorimetry_to_string (&colorimetry))) {
|
if ((color = gst_video_colorimetry_to_string_full (&colorimetry, FALSE))) {
|
||||||
gst_caps_set_simple (caps, "colorimetry", G_TYPE_STRING, color, NULL);
|
gst_caps_set_simple (caps, "colorimetry", G_TYPE_STRING, color, NULL);
|
||||||
g_free (color);
|
g_free (color);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue