mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 02:15:31 +00:00
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>
This commit is contained in:
parent
1b8df15b78
commit
44e4de43da
2 changed files with 43 additions and 0 deletions
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue