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.
This commit is contained in:
Johan Dahlin 2004-09-20 09:58:35 +00:00
parent e3beb3a1d5
commit 5af4bfcabd
2 changed files with 17 additions and 12 deletions

View file

@ -1,3 +1,8 @@
2004-09-20 Johan Dahlin <johan@gnome.org>
* ext/jpeg/gstjpegdec.c (gst_jpegdec_chain): Allocate the buffer
after setting caps.
2004-09-19 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* gst/wavenc/gstwavenc.c: (gst_wavenc_init), (gst_wavenc_chain):

View file

@ -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;