[gst-cvs] gstreamer: capsfilter: only set caps when different
Wim Taymans
wtay at kemper.freedesktop.org
Thu Aug 6 02:05:28 PDT 2009
Module: gstreamer
Branch: master
Commit: 2f5ed9e29d46a43073fbffed6eb8ddb498e04965
URL: http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=2f5ed9e29d46a43073fbffed6eb8ddb498e04965
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date: Wed Aug 5 17:55:14 2009 +0200
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.
---
plugins/elements/gstcapsfilter.c | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/plugins/elements/gstcapsfilter.c b/plugins/elements/gstcapsfilter.c
index 9d7a81a..71048e8 100644
--- a/plugins/elements/gstcapsfilter.c
+++ b/plugins/elements/gstcapsfilter.c
@@ -306,14 +306,23 @@ 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_is_metadata_writable (input)) {
+ 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);
+ } else {
+ GST_DEBUG_OBJECT (trans, "Creating sub-buffer and setting caps");
+ *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_set_caps (*buf, caps);
gst_buffer_ref (input);
- } else {
- GST_DEBUG_OBJECT (trans, "Creating sub-buffer and setting caps");
- *buf = gst_buffer_create_sub (input, 0, GST_BUFFER_SIZE (input));
- gst_buffer_set_caps (*buf, caps);
}
} else {
/* Buffer has no caps. See if the output pad only supports fixed caps */
More information about the Gstreamer-commits
mailing list