gst/smpte/gstsmpte.c: Some more sanity checks to make sure the input formats match and the input pads are actually ne...

Original commit message from CVS:
* gst/smpte/gstsmpte.c: (gst_smpte_collected):
Some more sanity checks to make sure the input formats match and the
input pads are actually negotiated, in case someone tries to feed
buffers from fakesrc or filesrc. Fixes #398299.
Also const-ify an array, just because we can.
This commit is contained in:
Tim-Philipp Müller 2007-01-19 13:06:07 +00:00
parent 3206d6ee5e
commit 813c331abd
2 changed files with 26 additions and 5 deletions

View file

@ -1,3 +1,11 @@
2007-01-19 Tim-Philipp Müller <tim at centricular dot net>
* gst/smpte/gstsmpte.c: (gst_smpte_collected):
Some more sanity checks to make sure the input formats match and the
input pads are actually negotiated, in case someone tries to feed
buffers from fakesrc or filesrc. Fixes #398299.
Also const-ify an array, just because we can.
2007-01-19 Edward Hervey <edward@fluendo.com>
* gst/smpte/gstsmpte.c: (fill_i420), (gst_smpte_collected):

View file

@ -255,10 +255,10 @@ gst_smpte_class_init (GstSMPTEClass * klass)
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_smpte_change_state);
}
/* wht yel cya grn mag red blu blk -I Q */
static int y_colors[] = { 255, 226, 179, 150, 105, 76, 29, 16, 16, 0 };
static int u_colors[] = { 128, 0, 170, 46, 212, 85, 255, 128, 0, 128 };
static int v_colors[] = { 128, 155, 0, 21, 235, 255, 107, 128, 128, 255 };
/* wht yel cya grn mag red blu blk -I Q */
static const int y_colors[] = { 255, 226, 179, 150, 105, 76, 29, 16, 16, 0 };
static const int u_colors[] = { 128, 0, 170, 46, 212, 85, 255, 128, 0, 128 };
static const int v_colors[] = { 128, 155, 0, 21, 235, 255, 107, 128, 128, 255 };
static void
fill_i420 (guint8 * data, gint width, gint height, gint color)
@ -429,7 +429,10 @@ gst_smpte_collected (GstCollectPads * pads, GstSMPTE * smpte)
GstBuffer *in1 = NULL, *in2 = NULL;
GSList *collected;
if (smpte->fps_num == 0)
if (G_UNLIKELY (smpte->fps_num == 0))
goto not_negotiated;
if (!GST_PAD_CAPS (smpte->sinkpad1) || !GST_PAD_CAPS (smpte->sinkpad2))
goto not_negotiated;
ts = gst_util_uint64_scale_int (smpte->position * GST_SECOND,
@ -457,6 +460,9 @@ gst_smpte_collected (GstCollectPads * pads, GstSMPTE * smpte)
fill_i420 (GST_BUFFER_DATA (in2), smpte->width, smpte->height, 0);
}
if (GST_BUFFER_SIZE (in1) != GST_BUFFER_SIZE (in2))
goto input_formats_do_not_match;
if (smpte->position < smpte->end_position) {
outbuf = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
@ -511,6 +517,13 @@ not_negotiated:
("No input format negotiated"));
return GST_FLOW_NOT_NEGOTIATED;
}
input_formats_do_not_match:
{
GST_ELEMENT_ERROR (smpte, CORE, NEGOTIATION, (NULL),
("input formats don't match: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT,
GST_PAD_CAPS (smpte->sinkpad1), GST_PAD_CAPS (smpte->sinkpad2)));
return GST_FLOW_ERROR;
}
}
static void