templatematch: Pass video through when nothing to match against

The early return was bypassing the call to gst_pad_push. With no
filter->template (and thus no filter->cvTemplateImage) the rest of this
function is essentially a no-op (except for the call to gst_pad_push).

This (plus the previous commit) allows templatematch to be
enabled/disabled without removing it entirely from the pipeline, by
setting/unsetting the template property.
This commit is contained in:
David Rothlisberger 2012-06-01 16:07:34 +01:00 committed by Thiago Santos
parent 056d652b92
commit c77808055d

View file

@ -316,9 +316,7 @@ gst_template_match_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
filter = GST_TEMPLATE_MATCH (parent); filter = GST_TEMPLATE_MATCH (parent);
/* FIXME Why template == NULL returns OK? if ((!filter) || (!buf)) {
* shouldn't it be a passthrough instead? */
if ((!filter) || (!buf) || filter->template == NULL) {
return GST_FLOW_OK; return GST_FLOW_OK;
} }
GST_LOG_OBJECT (filter, "Buffer size %u", (guint) gst_buffer_get_size (buf)); GST_LOG_OBJECT (filter, "Buffer size %u", (guint) gst_buffer_get_size (buf));
@ -327,7 +325,7 @@ gst_template_match_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
gst_buffer_map (buf, &info, GST_MAP_READWRITE); gst_buffer_map (buf, &info, GST_MAP_READWRITE);
filter->cvImage->imageData = (char *) info.data; filter->cvImage->imageData = (char *) info.data;
if (!filter->cvDistImage) { if (filter->cvTemplateImage && !filter->cvDistImage) {
if (filter->cvTemplateImage->width > filter->cvImage->width) { if (filter->cvTemplateImage->width > filter->cvImage->width) {
GST_WARNING ("Template Image is wider than input image"); GST_WARNING ("Template Image is wider than input image");
} else if (filter->cvTemplateImage->height > filter->cvImage->height) { } else if (filter->cvTemplateImage->height > filter->cvImage->height) {