return CI_IS_EQUAL (cinfo, other);
}
+/**
+ * gst_video_colorimetry_is_equivalent:
+ * @cinfo: a #GstVideoColorimetry
+ * @bitdepth: bitdepth of a format associated with @cinfo
+ * @other: another #GstVideoColorimetry
+ * @other_bitdepth: bitdepth of a format associated with @other
+ *
+ * Compare the 2 colorimetry sets for functionally equality
+ *
+ * Returns: %TRUE if @cinfo and @other are equivalent.
+ *
+ * Since: 1.22
+ */
+gboolean
+gst_video_colorimetry_is_equivalent (const GstVideoColorimetry * cinfo,
+ guint bitdepth, const GstVideoColorimetry * other, guint other_bitdepth)
+{
+ g_return_val_if_fail (cinfo != NULL, FALSE);
+ g_return_val_if_fail (other != NULL, FALSE);
+
+ if (cinfo->range != other->range || cinfo->matrix != other->matrix)
+ return FALSE;
+
+ if (!gst_video_color_primaries_is_equivalent (cinfo->primaries,
+ other->primaries)) {
+ return FALSE;
+ }
+
+ return gst_video_transfer_function_is_equivalent (cinfo->transfer, bitdepth,
+ other->transfer, other_bitdepth);
+}
+
#define WP_C 0.31006, 0.31616
#define WP_D65 0.31271, 0.32902
#define WP_CENTRE (1/3), (1/3)
}
/**
+ * gst_video_color_primaries_is_equivalent:
+ * @primaries: a #GstVideoColorPrimaries
+ * @other: another #GstVideoColorPrimaries
+ *
+ * Checks whether @primaries and @other are functionally equivalent
+ *
+ * Returns: TRUE if @primaries and @other can be considered equivalent.
+ *
+ * Since: 1.22
+ */
+gboolean
+gst_video_color_primaries_is_equivalent (GstVideoColorPrimaries primaries,
+ GstVideoColorPrimaries other)
+{
+ if (primaries == other)
+ return TRUE;
+
+ /* smpte-170m and 240m use the same reference RGB primaries and white point */
+ if ((primaries == GST_VIDEO_COLOR_PRIMARIES_SMPTE170M ||
+ primaries == GST_VIDEO_COLOR_PRIMARIES_SMPTE240M) &&
+ (other == GST_VIDEO_COLOR_PRIMARIES_SMPTE170M ||
+ other == GST_VIDEO_COLOR_PRIMARIES_SMPTE240M)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
* gst_video_color_matrix_get_Kr_Kb:
* @matrix: a #GstVideoColorMatrix
* @Kr: (out): result red channel coefficient
const GstVideoColorPrimariesInfo *
gst_video_color_primaries_get_info (GstVideoColorPrimaries primaries);
+GST_VIDEO_API
+gboolean gst_video_color_primaries_is_equivalent (GstVideoColorPrimaries primaries,
+ GstVideoColorPrimaries other);
+
/**
* GstVideoColorimetry:
* @range: the color range. This is the valid range for the samples.
GST_VIDEO_API
gboolean gst_video_colorimetry_is_equal (const GstVideoColorimetry *cinfo, const GstVideoColorimetry *other);
+GST_VIDEO_API
+gboolean gst_video_colorimetry_is_equivalent (const GstVideoColorimetry *cinfo,
+ guint bitdepth,
+ const GstVideoColorimetry *other,
+ guint other_bitdepth);
+
/* compute offset and scale */
GST_VIDEO_API
GST_END_TEST;
+static gboolean
+is_equal_primaries_coord (const GstVideoColorPrimariesInfo * a,
+ const GstVideoColorPrimariesInfo * b)
+{
+ return (a->Wx == b->Wx && a->Wy == b->Wy && a->Rx == b->Rx && a->Ry == a->Ry
+ && a->Gx == b->Gx && a->Gy == b->Gy && a->Bx == b->Bx && a->By == b->By);
+}
+
+GST_START_TEST (test_video_color_primaries_equivalent)
+{
+ guint i, j;
+
+ for (i = 0; i <= GST_VIDEO_COLOR_PRIMARIES_EBU3213; i++) {
+ for (j = 0; j <= GST_VIDEO_COLOR_PRIMARIES_EBU3213; j++) {
+ GstVideoColorPrimaries primaries = (GstVideoColorPrimaries) i;
+ GstVideoColorPrimaries other = (GstVideoColorPrimaries) j;
+ const GstVideoColorPrimariesInfo *primaries_info =
+ gst_video_color_primaries_get_info (primaries);
+ const GstVideoColorPrimariesInfo *other_info =
+ gst_video_color_primaries_get_info (other);
+ gboolean equal =
+ gst_video_color_primaries_is_equivalent (primaries, other);
+ gboolean same_coord = is_equal_primaries_coord (primaries_info,
+ other_info);
+
+ if (equal)
+ fail_unless (same_coord);
+ else
+ fail_if (same_coord);
+ }
+ }
+}
+
+GST_END_TEST;
+
static Suite *
video_suite (void)
{
tcase_add_test (tc_chain, test_video_make_raw_caps);
tcase_add_test (tc_chain, test_video_extrapolate_stride);
tcase_add_test (tc_chain, test_auto_video_frame_unmap);
+ tcase_add_test (tc_chain, test_video_color_primaries_equivalent);
return s;
}