+2006-05-19 Jan Schmidt <thaytan@mad.scientist.com>
+
+ * sys/xvimage/xvimagesink.c: (gst_xvimagesink_xcontext_clear),
+ (gst_xvimagesink_buffer_alloc):
+ * sys/xvimage/xvimagesink.h:
+ When performing buffer allocations, remember the caps and image format
+ we return so that if the same caps are asked for next time we can
+ return them immediately without doing any caps intersections.
+
2006-05-18 Philippe Kalaf <philippe.kalaf@collabora.co.uk>
* gst-libs/gst/rtp/README:
g_list_free (xvimagesink->xcontext->channels_list);
gst_caps_unref (xvimagesink->xcontext->caps);
+ if (xvimagesink->xcontext->last_caps)
+ gst_caps_replace (&xvimagesink->xcontext->last_caps, NULL);
+
g_free (xvimagesink->xcontext->par);
g_mutex_lock (xvimagesink->x_lock);
xvimagesink = GST_XVIMAGESINK (bsink);
+ if (G_LIKELY (xvimagesink->xcontext->last_caps &&
+ gst_caps_is_equal (caps, xvimagesink->xcontext->last_caps))) {
+ GST_DEBUG_OBJECT (xvimagesink,
+ "buffer alloc for same last_caps, reusing caps");
+ intersection = gst_caps_ref (caps);
+ image_format = xvimagesink->xcontext->last_format;
+
+ goto reuse_last_caps;
+ }
+
GST_DEBUG_OBJECT (xvimagesink, "buffer alloc requested with caps %"
GST_PTR_FORMAT "intersecting with our caps %" GST_PTR_FORMAT, caps,
xvimagesink->xcontext->caps);
GST_DEBUG_OBJECT (xvimagesink, "allocating a buffer with caps %"
GST_PTR_FORMAT, intersection);
+ } else if (gst_caps_is_equal (intersection, caps)) {
+ /* Things work better if we return a buffer with the same caps ptr
+ * as was asked for when we can */
+ gst_caps_replace (&intersection, caps);
}
/* Get image format from caps */
image_format = gst_xvimagesink_get_format_from_caps (xvimagesink,
intersection);
+ /* Store our caps and format as the last_caps to avoid expensive
+ * caps intersection next time */
+ gst_caps_replace (&xvimagesink->xcontext->last_caps, intersection);
+ xvimagesink->xcontext->last_format = image_format;
+
+reuse_last_caps:
+
/* Get geometry from caps */
structure = gst_caps_get_structure (intersection, 0);
if (!gst_structure_get_int (structure, "width", &width) ||
/* We found no suitable image in the pool. Creating... */
GST_DEBUG_OBJECT (xvimagesink, "no usable image in pool, creating xvimage");
xvimage = gst_xvimagesink_xvimage_new (xvimagesink, intersection);
- if (xvimage->size < size) {
+ if (xvimage && xvimage->size < size) {
/* This image is unusable. Destroying... */
gst_xvimage_buffer_free (xvimage);
xvimage = NULL;