capsfilter: only set caps when different

When we have an input buffer with caps and when those caps are different from
the caps we want, only then make a writable copy of the input buffer as the
output buffer and set the caps on that output buffer. This avoids some cases
where we took a subbuffer for setting caps that were the same.
This commit is contained in:
Wim Taymans 2009-08-05 17:55:14 +02:00
parent db6ce33e3a
commit 2f5ed9e29d

View file

@ -306,7 +306,11 @@ gst_capsfilter_prepare_buf (GstBaseTransform * trans, GstBuffer * input,
/* FIXME : Move this behaviour to basetransform. The given caps are the ones
* of the source pad, therefore our outgoing buffers should always have
* those caps. */
if (GST_BUFFER_CAPS (input) != caps) {
/* caps are different, make a metadata writable output buffer to set
* caps */
if (gst_buffer_is_metadata_writable (input)) {
/* input is writable, just set caps and use this as the output */
*buf = input;
gst_buffer_set_caps (*buf, caps);
gst_buffer_ref (input);
@ -315,6 +319,11 @@ gst_capsfilter_prepare_buf (GstBaseTransform * trans, GstBuffer * input,
*buf = gst_buffer_create_sub (input, 0, GST_BUFFER_SIZE (input));
gst_buffer_set_caps (*buf, caps);
}
} else {
/* caps are right, just use a ref of the input as the outbuf */
*buf = input;
gst_buffer_ref (input);
}
} else {
/* Buffer has no caps. See if the output pad only supports fixed caps */
GstCaps *out_caps;