summaryrefslogtreecommitdiff
path: root/tests/check
diff options
context:
space:
mode:
authorSeungha Yang <seungha@centricular.com>2020-11-10 18:01:12 +0900
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-12-08 07:21:28 +0000
commit410efd196a00fafe6997f98abcd6c656d5ac0e4c (patch)
tree6325c390f66e1871ab87c78c3aa8d723caede718 /tests/check
parent6434db5298156ec41ddc21f18c8d57a02a9ce1c1 (diff)
video-chroma: Add support for any combination of chroma-site flags
We've been allowing only a few known chroma-site values such as jpeg (not co-sited), mpeg2 (horizontally co-sited) and dv (co-sited on alternate lines). That's insufficient for representing all possible chroma-site values. By this commit, we can represent any combination of chroma-site flags. But, an exception here is that any combination with GST_VIDEO_CHROMA_SITE_NONE will be considered as invalid value. For any combination of chroma-site flags, gst_video_chroma_to_string() method is deprecated in order to return newly allocated string via a new gst_video_chroma_site_to_string() method. And for consistent API naming, gst_video_chroma_from_string() is also deprecated. Newly written code should use gst_video_chroma_site_from_string() instead. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/927>
Diffstat (limited to 'tests/check')
-rw-r--r--tests/check/libs/video.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/check/libs/video.c b/tests/check/libs/video.c
index b9b9ec78a..897d9d720 100644
--- a/tests/check/libs/video.c
+++ b/tests/check/libs/video.c
@@ -2398,6 +2398,81 @@ GST_END_TEST;
#undef HEIGHT
#undef TIME
+typedef struct
+{
+ const gchar *name;
+ GstVideoChromaSite site;
+} ChromaSiteElem;
+
+GST_START_TEST (test_video_chroma_site)
+{
+ ChromaSiteElem valid_sites[] = {
+ /* pre-defined flags */
+ {"jpeg", GST_VIDEO_CHROMA_SITE_JPEG},
+ {"mpeg2", GST_VIDEO_CHROMA_SITE_MPEG2},
+ {"dv", GST_VIDEO_CHROMA_SITE_DV},
+ {"alt-line", GST_VIDEO_CHROMA_SITE_ALT_LINE},
+ {"cosited", GST_VIDEO_CHROMA_SITE_COSITED},
+ /* new values */
+ {"v-cosited", GST_VIDEO_CHROMA_SITE_V_COSITED},
+ {"v-cosited+alt-line",
+ GST_VIDEO_CHROMA_SITE_V_COSITED | GST_VIDEO_CHROMA_SITE_ALT_LINE},
+ };
+ ChromaSiteElem unknown_sites[] = {
+ {NULL, GST_VIDEO_CHROMA_SITE_UNKNOWN},
+ /* Any combination with GST_VIDEO_CHROMA_SITE_NONE doesn' make sense */
+ {NULL, GST_VIDEO_CHROMA_SITE_NONE | GST_VIDEO_CHROMA_SITE_H_COSITED},
+ };
+ gint i;
+
+ for (i = 0; i < G_N_ELEMENTS (valid_sites); i++) {
+ gchar *site = gst_video_chroma_site_to_string (valid_sites[i].site);
+
+ fail_unless (site != NULL);
+ fail_unless (g_strcmp0 (site, valid_sites[i].name) == 0);
+ fail_unless (gst_video_chroma_site_from_string (site) ==
+ valid_sites[i].site);
+ g_free (site);
+ }
+
+ for (i = 0; i < G_N_ELEMENTS (unknown_sites); i++) {
+ gchar *site = gst_video_chroma_site_to_string (unknown_sites[i].site);
+ fail_unless (site == NULL);
+ }
+
+ /* totally wrong string */
+ fail_unless (gst_video_chroma_site_from_string ("foo/bar") ==
+ GST_VIDEO_CHROMA_SITE_UNKNOWN);
+
+ /* valid ones */
+ fail_unless (gst_video_chroma_site_from_string ("jpeg") ==
+ GST_VIDEO_CHROMA_SITE_NONE);
+ fail_unless (gst_video_chroma_site_from_string ("none") ==
+ GST_VIDEO_CHROMA_SITE_NONE);
+
+ fail_unless (gst_video_chroma_site_from_string ("mpeg2") ==
+ GST_VIDEO_CHROMA_SITE_H_COSITED);
+ fail_unless (gst_video_chroma_site_from_string ("h-cosited") ==
+ GST_VIDEO_CHROMA_SITE_H_COSITED);
+
+ /* Equal to "cosited" */
+ fail_unless (gst_video_chroma_site_from_string ("v-cosited+h-cosited") ==
+ GST_VIDEO_CHROMA_SITE_COSITED);
+
+ fail_unless (gst_video_chroma_site_from_string ("v-cosited") ==
+ GST_VIDEO_CHROMA_SITE_V_COSITED);
+
+ /* none + something doesn't make sense */
+ fail_unless (gst_video_chroma_site_from_string ("none+v-cosited") ==
+ GST_VIDEO_CHROMA_SITE_UNKNOWN);
+
+ /* mix of valid and invalid strings */
+ fail_unless (gst_video_chroma_site_from_string ("mpeg2+foo/bar") ==
+ GST_VIDEO_CHROMA_SITE_UNKNOWN);
+}
+
+GST_END_TEST;
+
GST_START_TEST (test_video_scaler)
{
GstVideoScaler *scale;
@@ -3959,6 +4034,7 @@ video_suite (void)
tcase_add_test (tc_chain, test_overlay_composition_global_alpha);
tcase_add_test (tc_chain, test_video_pack_unpack2);
tcase_add_test (tc_chain, test_video_chroma);
+ tcase_add_test (tc_chain, test_video_chroma_site);
tcase_add_test (tc_chain, test_video_scaler);
tcase_add_test (tc_chain, test_video_color_convert_rgb_rgb);
tcase_add_test (tc_chain, test_video_color_convert_rgb_yuv);