summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStian Selnes <stian@pexip.com>2018-02-28 15:46:51 +0100
committerSebastian Dröge <sebastian@centricular.com>2020-06-02 23:59:20 +0300
commit44e4de43dafc550a01c7ba677bd398e135dc550c (patch)
tree4c2833e7b8e5038f4e3f8bead582fa77547107a9
parent1b8df15b7888b6a476f71a8d6906330eb7751ffd (diff)
vpxdec: Check that output width and height != 0
For VP8 it's possible to signal width or height to be 0, but it does not make sense to do so. For VP9 it's impossible. Hence, we most likely have a corrupt stream. Trying to negotiate caps downstream with either width or height as 0 will fail with something like gst_video_decoder_negotiate_default: assertion 'GST_VIDEO_INFO_WIDTH (&state->info) != 0' failed Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/610>
-rw-r--r--ext/vpx/gstvpxdec.c8
-rw-r--r--tests/check/elements/vp8dec.c35
2 files changed, 43 insertions, 0 deletions
diff --git a/ext/vpx/gstvpxdec.c b/ext/vpx/gstvpxdec.c
index 3eafb7f10b..e860715d09 100644
--- a/ext/vpx/gstvpxdec.c
+++ b/ext/vpx/gstvpxdec.c
@@ -586,6 +586,14 @@ gst_vpx_dec_open_codec (GstVPXDec * dec, GstVideoCodecFrame * frame)
GST_WARNING_OBJECT (dec, "No keyframe, skipping");
return GST_FLOW_CUSTOM_SUCCESS_1;
}
+ if (stream_info.w == 0 || stream_info.h == 0) {
+ /* For VP8 it's possible to signal width or height to be 0, but it does
+ * not make sense to do so. For VP9 it's impossible. Hence, we most likely
+ * have a corrupt stream if width or height is 0. */
+ GST_INFO_OBJECT (dec, "Invalid resolution %d x %d", stream_info.w,
+ stream_info.h);
+ return GST_FLOW_CUSTOM_SUCCESS_1;
+ }
gst_vpx_dec_set_stream_info (dec, &stream_info);
gst_vpx_dec_set_default_format (dec, GST_VIDEO_FORMAT_I420, stream_info.w,
diff --git a/tests/check/elements/vp8dec.c b/tests/check/elements/vp8dec.c
index 0ebd70ac29..4ff92c7c1f 100644
--- a/tests/check/elements/vp8dec.c
+++ b/tests/check/elements/vp8dec.c
@@ -19,6 +19,8 @@
*/
#include <gst/check/gstcheck.h>
+#include <gst/check/gstharness.h>
+#include <gst/video/video.h>
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
@@ -248,6 +250,38 @@ GST_START_TEST (test_decode_caps_change)
GST_END_TEST;
+GST_START_TEST (test_decode_invalid_resolution)
+{
+ GstHarness *h;
+
+ guint8 invalid_width[] = {
+ 0x50, 0x48, 0x00, 0x9d, 0x01, 0x2a, 0x00, 0x00, 0x11, 0x44, 0x39, 0x63,
+ };
+ guint8 invalid_height[] = {
+ 0x50, 0x48, 0x00, 0x9d, 0x01, 0x2a, 0x11, 0x44, 0x00, 0x00, 0x39, 0x63,
+ };
+
+ h = gst_harness_new_parse ("vp8dec");
+ gst_harness_set_src_caps_str (h, "video/x-vp8");
+
+ fail_unless_equals_int (GST_FLOW_OK,
+ gst_harness_push (h,
+ gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY, invalid_width,
+ sizeof (invalid_width), 0, sizeof (invalid_width), NULL, NULL)));
+ fail_unless (gst_harness_try_pull (h) == NULL);
+
+ fail_unless_equals_int (GST_FLOW_OK,
+ gst_harness_push (h,
+ gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY, invalid_height,
+ sizeof (invalid_height), 0, sizeof (invalid_height), NULL,
+ NULL)));
+ fail_unless (gst_harness_try_pull (h) == NULL);
+
+ gst_harness_teardown (h);
+}
+
+GST_END_TEST;
+
static Suite *
vp8dec_suite (void)
@@ -259,6 +293,7 @@ vp8dec_suite (void)
tcase_add_test (tc_chain, test_decode_simple);
tcase_add_test (tc_chain, test_decode_caps_change);
+ tcase_add_test (tc_chain, test_decode_invalid_resolution);
return s;
}