mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
video-info: check if alternate caps has the feature as well
It's invalid to have a 'interlace-mode=alternate' without the Interlaced caps feature as well. Modify gst_video_info_from_caps() to reject such case so we can easily spot them in bugged elements.
This commit is contained in:
parent
6ba860021c
commit
10ce73b6eb
2 changed files with 36 additions and 0 deletions
|
@ -455,6 +455,17 @@ gst_video_info_from_caps (GstVideoInfo * info, const GstCaps * caps)
|
|||
else
|
||||
info->interlace_mode = GST_VIDEO_INTERLACE_MODE_PROGRESSIVE;
|
||||
|
||||
/* Interlaced feature is mandatory for raw alternate streams */
|
||||
if (info->interlace_mode == GST_VIDEO_INTERLACE_MODE_ALTERNATE &&
|
||||
format != GST_VIDEO_FORMAT_ENCODED) {
|
||||
GstCapsFeatures *f;
|
||||
|
||||
f = gst_caps_get_features (caps, 0);
|
||||
if (!f
|
||||
|| !gst_caps_features_contains (f, GST_CAPS_FEATURE_FORMAT_INTERLACED))
|
||||
goto alternate_no_feature;
|
||||
}
|
||||
|
||||
if ((info->interlace_mode == GST_VIDEO_INTERLACE_MODE_INTERLEAVED ||
|
||||
info->interlace_mode == GST_VIDEO_INTERLACE_MODE_ALTERNATE) &&
|
||||
(s = gst_structure_get_string (structure, "field-order"))) {
|
||||
|
@ -541,6 +552,12 @@ no_height:
|
|||
GST_ERROR ("no height property given");
|
||||
return FALSE;
|
||||
}
|
||||
alternate_no_feature:
|
||||
{
|
||||
GST_ERROR
|
||||
("caps has 'interlace-mode=alternate' but doesn't have the Interlaced feature");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1309,6 +1309,25 @@ GST_START_TEST (test_interlace_mode)
|
|||
GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST);
|
||||
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* gst_video_info_from_caps() fails if an alternate stream doesn't contain
|
||||
* the caps feature. */
|
||||
caps =
|
||||
gst_caps_from_string
|
||||
("video/x-raw, format=NV12, width=320, height=240, interlace-mode=alternate");
|
||||
fail_unless (caps);
|
||||
|
||||
fail_if (gst_video_info_from_caps (&vinfo, caps));
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* ... but it's ok for encoded video */
|
||||
caps =
|
||||
gst_caps_from_string
|
||||
("video/x-h265, width=320, height=240, interlace-mode=alternate");
|
||||
fail_unless (caps);
|
||||
|
||||
fail_unless (gst_video_info_from_caps (&vinfo, caps));
|
||||
gst_caps_unref (caps);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
|
Loading…
Reference in a new issue