From 5af4bfcabd842318887a4cab2374e66e57ba2ad2 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Mon, 20 Sep 2004 09:58:35 +0000 Subject: [PATCH] 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. --- ChangeLog | 5 +++++ ext/jpeg/gstjpegdec.c | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index aa47e190d7..5e54b777c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-09-20 Johan Dahlin + + * ext/jpeg/gstjpegdec.c (gst_jpegdec_chain): Allocate the buffer + after setting caps. + 2004-09-19 Zaheer Abbas Merali * gst/wavenc/gstwavenc.c: (gst_wavenc_init), (gst_wavenc_chain): diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c index 1f15f0de37..03b9d651e8 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;