summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStian Selnes <stian@pexip.com>2016-05-10 13:56:13 +0200
committerTim-Philipp Müller <tim@centricular.com>2016-06-02 17:20:08 +0100
commitf3cdeb836108abab9a44dd3c021d6acf0b19102f (patch)
treef5f2dc6dcc124f98956a2ce2c754090b8b30d440
parentac8ed8746d683d2d1696baacdc2ac6d7b21af31e (diff)
downloadgstreamer-plugins-base-f3cdeb836108abab9a44dd3c021d6acf0b19102f.tar.gz
video-color: Fix colorimetry IS_UNKNOWN
Fix issue with colorimetry default indicies not being in sync with the actual table causing IS_UNKNOWN() to sometimes fail. https://bugzilla.gnome.org/show_bug.cgi?id=767163
-rw-r--r--gst-libs/gst/video/video-color.c6
-rw-r--r--tests/check/libs/video.c57
2 files changed, 60 insertions, 3 deletions
diff --git a/gst-libs/gst/video/video-color.c b/gst-libs/gst/video/video-color.c
index f9733494c..efdb3ab92 100644
--- a/gst-libs/gst/video/video-color.c
+++ b/gst-libs/gst/video/video-color.c
@@ -66,9 +66,9 @@ typedef struct
#define DEFAULT_YUV_SD 0
#define DEFAULT_YUV_HD 1
#define DEFAULT_RGB 3
-#define DEFAULT_GRAY 4
-#define DEFAULT_UNKNOWN 5
-#define DEFAULT_YUV_UHD 6
+#define DEFAULT_YUV_UHD 4
+#define DEFAULT_GRAY 5
+#define DEFAULT_UNKNOWN 6
static const ColorimetryInfo colorimetry[] = {
MAKE_COLORIMETRY (BT601, _16_235, BT601, BT709, SMPTE170M),
diff --git a/tests/check/libs/video.c b/tests/check/libs/video.c
index b8decf1fe..86c565f8c 100644
--- a/tests/check/libs/video.c
+++ b/tests/check/libs/video.c
@@ -847,6 +847,62 @@ GST_START_TEST (test_parse_caps_multiview)
GST_END_TEST;
+typedef struct
+{
+ const gchar *string_from;
+ const gchar *string_to;
+ const gchar *name;
+ GstVideoColorimetry color;
+} ColorimetryTest;
+
+#define MAKE_COLORIMETRY_TEST(s1,s2,n,r,m,t,p) { s1, s2, n, \
+ { GST_VIDEO_COLOR_RANGE ##r, GST_VIDEO_COLOR_MATRIX_ ##m, \
+ GST_VIDEO_TRANSFER_ ##t, GST_VIDEO_COLOR_PRIMARIES_ ##p } }
+
+GST_START_TEST (test_parse_colorimetry)
+{
+ ColorimetryTest tests[] = {
+ MAKE_COLORIMETRY_TEST ("bt601", "bt601", "bt601",
+ _16_235, BT601, BT709, SMPTE170M),
+ MAKE_COLORIMETRY_TEST ("2:4:5:4", "bt601", "bt601",
+ _16_235, BT601, BT709, SMPTE170M),
+ MAKE_COLORIMETRY_TEST ("bt709", "bt709", "bt709",
+ _16_235, BT709, BT709, BT709),
+ MAKE_COLORIMETRY_TEST ("smpte240m", "smpte240m", "smpte240m",
+ _16_235, SMPTE240M, SMPTE240M, SMPTE240M),
+ MAKE_COLORIMETRY_TEST ("sRGB", "sRGB", "sRGB",
+ _0_255, RGB, SRGB, BT709),
+ MAKE_COLORIMETRY_TEST ("bt2020" , "bt2020", "bt2020",
+ _16_235, BT2020, BT2020_12, BT2020),
+ MAKE_COLORIMETRY_TEST ("1:4:0:0", "1:4:0:0", NULL,
+ _0_255, BT601, UNKNOWN, UNKNOWN),
+ };
+ gint i;
+
+ for (i = 0; i < G_N_ELEMENTS (tests); i++) {
+ const ColorimetryTest *test = &tests[i];
+ GstVideoColorimetry color;
+ gchar *string;
+
+ fail_unless (gst_video_colorimetry_from_string (&color, test->string_from));
+ fail_unless_equals_int (color.range, test->color.range);
+ fail_unless_equals_int (color.matrix, test->color.matrix);
+ fail_unless_equals_int (color.transfer, test->color.transfer);
+ fail_unless_equals_int (color.primaries, test->color.primaries);
+
+ string = gst_video_colorimetry_to_string (&color);
+ fail_unless_equals_string (string, test->string_to);
+ g_free (string);
+
+ fail_unless (gst_video_colorimetry_is_equal (&color, &test->color));
+
+ if (test->name)
+ fail_unless (gst_video_colorimetry_matches (&color, test->name));
+ }
+}
+
+GST_END_TEST;
+
GST_START_TEST (test_events)
{
GstEvent *e;
@@ -2706,6 +2762,7 @@ video_suite (void)
tcase_add_test (tc_chain, test_dar_calc);
tcase_add_test (tc_chain, test_parse_caps_rgb);
tcase_add_test (tc_chain, test_parse_caps_multiview);
+ tcase_add_test (tc_chain, test_parse_colorimetry);
tcase_add_test (tc_chain, test_events);
tcase_add_test (tc_chain, test_convert_frame);
tcase_add_test (tc_chain, test_convert_frame_async);