diff --git a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/descriptions.c b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/descriptions.c index 7e85b14ad0..e8a8827e91 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/descriptions.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/descriptions.c @@ -471,8 +471,8 @@ format_info_get_desc (const FormatInfo * info, const GstCaps * caps) const gchar *subs; gint w_sub, h_sub, n_semi; - w_sub = GST_VIDEO_FORMAT_INFO_W_SUB (finfo, 1); - h_sub = GST_VIDEO_FORMAT_INFO_H_SUB (finfo, 1); + w_sub = 1 << GST_VIDEO_FORMAT_INFO_W_SUB (finfo, 1); + h_sub = 1 << GST_VIDEO_FORMAT_INFO_H_SUB (finfo, 1); if (w_sub == 1 && h_sub == 1) { subs = "4:4:4"; diff --git a/subprojects/gst-plugins-base/tests/check/libs/pbutils.c b/subprojects/gst-plugins-base/tests/check/libs/pbutils.c index 37eea09208..b7b7245e2c 100644 --- a/subprojects/gst-plugins-base/tests/check/libs/pbutils.c +++ b/subprojects/gst-plugins-base/tests/check/libs/pbutils.c @@ -453,10 +453,36 @@ static const gchar *caps_strings[] = { /* raw video */ "video/x-raw, format=(string)RGB16, width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1", "video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1", + "video/x-raw, format=(string)I420, width=(int)320, height=(int)240, framerate=(fraction)30/1", + "video/x-raw, format=(string)AYUV, width=(int)320, height=(int)240, framerate=(fraction)30/1", /* and a made-up format */ "video/x-tpm" }; +static gboolean +validate_video_subsampling (GstCaps * caps, gchar * desc) +{ + GstStructure *st; + const gchar *format; + + st = gst_caps_get_structure (caps, 0); + if (!gst_structure_has_name (st, "video/x-raw")) + return TRUE; + + format = gst_structure_get_string (st, "format"); + if (!format) + return TRUE; + + if (g_strcmp0 (format, "YUY2") == 0) + return g_str_has_suffix (desc, "4:2:2"); + if (g_strcmp0 (format, "I420") == 0) + return g_str_has_suffix (desc, "4:2:0"); + if (g_strcmp0 (format, "AYUV") == 0) + return g_str_has_suffix (desc, "4:4:4"); + + return TRUE; +} + GST_START_TEST (test_pb_utils_get_codec_description) { gint i; @@ -475,6 +501,7 @@ GST_START_TEST (test_pb_utils_get_codec_description) fail_unless (desc != NULL); GST_LOG (" - codec : %s", desc); fail_unless (g_utf8_validate (desc, -1, NULL)); + fail_unless (validate_video_subsampling (caps, desc)); g_free (desc); desc = gst_pb_utils_get_decoder_description (caps); fail_unless (desc != NULL);