From 5af4bfcabd842318887a4cab2374e66e57ba2ad2 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Mon, 20 Sep 2004 09:58:35 +0000 Subject: ext/jpeg/gstjpegdec.c (gst_jpegdec_chain): Allocate the buffer after setting caps. Fixes mysterious segfault. Blessed... Original commit message from CVS: * ext/jpeg/gstjpegdec.c (gst_jpegdec_chain): Allocate the buffer after setting caps. Fixes mysterious segfault. Blessed by Wim. --- ext/jpeg/gstjpegdec.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'ext') diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c index 1f15f0de..03b9d651 100644 --- a/ext/jpeg/gstjpegdec.c +++ b/ext/jpeg/gstjpegdec.c @@ -406,18 +406,6 @@ gst_jpegdec_chain (GstPad * pad, GstData * _data) width = jpegdec->cinfo.output_width; height = jpegdec->cinfo.output_height; - /* FIXME: someone needs to do the work to figure out how to correctly - * calculate an output size that takes into account everything libjpeg - * needs, like padding for DCT size and so on. */ - outsize = width * height + width * height / 2; - outbuf = gst_pad_alloc_buffer (jpegdec->srcpad, GST_BUFFER_OFFSET_NONE, - outsize); - outdata = GST_BUFFER_DATA (outbuf); - GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); - GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf); - GST_LOG_OBJECT (jpegdec, "width %d, height %d, buffer size %d", width, - height, outsize); - if (jpegdec->height != height || jpegdec->line[0] == NULL) { GstCaps *caps; @@ -437,6 +425,18 @@ gst_jpegdec_chain (GstPad * pad, GstData * _data) gst_caps_free (caps); } + /* FIXME: someone needs to do the work to figure out how to correctly + * calculate an output size that takes into account everything libjpeg + * needs, like padding for DCT size and so on. */ + outsize = width * height + width * height / 2; + outbuf = gst_pad_alloc_buffer (jpegdec->srcpad, GST_BUFFER_OFFSET_NONE, + outsize); + outdata = GST_BUFFER_DATA (outbuf); + GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); + GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf); + GST_LOG_OBJECT (jpegdec, "width %d, height %d, buffer size %d", width, + height, outsize); + /* mind the swap, jpeglib outputs blue chroma first */ /* FIXME: this needs stride love */ base[0] = outdata; -- cgit