mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-04 07:26:33 +00:00
pbutils: descriptions: use subsampling factor to get YUV subsampling
The algorithm used to determine the YUV subsampling string uses width and height subsampling factor, not the raw subsampling. Otherwise all 4:2:0 YUV frames will be detected as 4:4:4 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7360>
This commit is contained in:
parent
419e541199
commit
93be216910
2 changed files with 29 additions and 2 deletions
|
@ -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";
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue