[gst-cvs] gst-plugins-good: jpegdec: free temporary buffer when changing state to NULL
Tim Mueller
tpm at kemper.freedesktop.org
Mon Nov 9 07:34:17 PST 2009
Module: gst-plugins-good
Branch: master
Commit: 7af7d93b273ae633121818ccefdee38c21696b2d
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=7af7d93b273ae633121818ccefdee38c21696b2d
Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date: Mon Nov 9 15:20:00 2009 +0000
jpegdec: free temporary buffer when changing state to NULL
Free temporary allocations in the state change function and not
only when the object is finalised.
---
ext/jpeg/gstjpegdec.c | 25 ++++++++++++++++++-------
1 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c
index ef94a5a..61a051c 100644
--- a/ext/jpeg/gstjpegdec.c
+++ b/ext/jpeg/gstjpegdec.c
@@ -148,19 +148,12 @@ static void
gst_jpeg_dec_finalize (GObject * object)
{
GstJpegDec *dec = GST_JPEG_DEC (object);
- gint i;
jpeg_destroy_decompress (&dec->cinfo);
if (dec->tempbuf)
gst_buffer_unref (dec->tempbuf);
- for (i = 0; i < 16; i++) {
- g_free (dec->idr_y[i]);
- g_free (dec->idr_u[i]);
- g_free (dec->idr_v[i]);
- }
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -682,6 +675,23 @@ hresamplecpy1 (guint8 * dest, const guint8 * src, guint len)
}
}
+static void
+gst_jpeg_dec_free_buffers (GstJpegDec * dec)
+{
+ gint i;
+
+ for (i = 0; i < 16; i++) {
+ g_free (dec->idr_y[i]);
+ g_free (dec->idr_u[i]);
+ g_free (dec->idr_v[i]);
+ dec->idr_y[i] = NULL;
+ dec->idr_u[i] = NULL;
+ dec->idr_v[i] = NULL;
+ }
+
+ dec->idr_width_allocated = 0;
+}
+
static inline gboolean
gst_jpeg_dec_ensure_buffers (GstJpegDec * dec, guint maxrowbytes)
{
@@ -1430,6 +1440,7 @@ gst_jpeg_dec_change_state (GstElement * element, GstStateChange transition)
gst_buffer_unref (dec->tempbuf);
dec->tempbuf = NULL;
}
+ gst_jpeg_dec_free_buffers (dec);
break;
default:
break;
More information about the Gstreamer-commits
mailing list