sys/xvimage/xvimagesink.*: When performing buffer allocations, remember the caps and image format we return so that i...

Original commit message from CVS:
* 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.
This commit is contained in:
Jan Schmidt 2006-05-19 11:50:17 +00:00
parent 8675bc89e4
commit 47e7f3f367
4 changed files with 39 additions and 2 deletions

View file

@ -1,3 +1,12 @@
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:

2
common

@ -1 +1 @@
Subproject commit 6811863fce665ce0a466bc03ee2ac5e2d5f47d28
Subproject commit 764c5f25101d20da7f26942c36ba840ba65c63d7

View file

@ -1497,6 +1497,9 @@ gst_xvimagesink_xcontext_clear (GstXvImageSink * xvimagesink)
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);
@ -1881,6 +1884,16 @@ gst_xvimagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
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);
@ -1936,12 +1949,23 @@ gst_xvimagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
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) ||
@ -1984,7 +2008,7 @@ gst_xvimagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
/* 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;

View file

@ -121,6 +121,10 @@ struct _GstXContext {
GList *channels_list;
GstCaps *caps;
/* Optimisation storage for buffer_alloc return */
GstCaps *last_caps;
gint last_format;
};
/**