mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 17:18:15 +00:00
cleanups, debugging and memleak fixes
Original commit message from CVS: cleanups, debugging and memleak fixes
This commit is contained in:
parent
ec928a3d33
commit
c793316e38
3 changed files with 47 additions and 20 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2004-08-09 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
|
* ext/jpeg/gstjpegdec.c: (gst_jpegdec_init_source),
|
||||||
|
(gst_jpegdec_fill_input_buffer), (gst_jpegdec_skip_input_data),
|
||||||
|
(gst_jpegdec_resync_to_restart), (gst_jpegdec_term_source),
|
||||||
|
(gst_jpegdec_init), (gst_jpegdec_chain):
|
||||||
|
* gst/multipart/multipartdemux.c: (gst_multipart_demux_init),
|
||||||
|
(gst_multipart_demux_chain), (gst_multipart_demux_change_state):
|
||||||
|
cleanups, debugging fixes and memleak plugging
|
||||||
|
|
||||||
2004-08-09 Wim Taymans <wim@fluendo.com>
|
2004-08-09 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* ext/theora/theoradec.c: (gst_theora_dec_class_init),
|
* ext/theora/theoradec.c: (gst_theora_dec_class_init),
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#endif
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/*#define DEBUG_ENABLED*/
|
|
||||||
#include "gstjpegdec.h"
|
#include "gstjpegdec.h"
|
||||||
#include <gst/video/video.h>
|
#include <gst/video/video.h>
|
||||||
|
|
||||||
|
@ -130,39 +129,39 @@ gst_jpegdec_class_init (GstJpegDec * klass)
|
||||||
static void
|
static void
|
||||||
gst_jpegdec_init_source (j_decompress_ptr cinfo)
|
gst_jpegdec_init_source (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("gst_jpegdec_chain: init_source");
|
GST_DEBUG ("init_source");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_jpegdec_fill_input_buffer (j_decompress_ptr cinfo)
|
gst_jpegdec_fill_input_buffer (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("gst_jpegdec_chain: fill_input_buffer");
|
GST_DEBUG ("fill_input_buffer");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_jpegdec_skip_input_data (j_decompress_ptr cinfo, glong num_bytes)
|
gst_jpegdec_skip_input_data (j_decompress_ptr cinfo, glong num_bytes)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("gst_jpegdec_chain: skip_input_data");
|
GST_DEBUG ("skip_input_data");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_jpegdec_resync_to_restart (j_decompress_ptr cinfo, gint desired)
|
gst_jpegdec_resync_to_restart (j_decompress_ptr cinfo, gint desired)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("gst_jpegdec_chain: resync_to_start");
|
GST_DEBUG ("resync_to_start");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_jpegdec_term_source (j_decompress_ptr cinfo)
|
gst_jpegdec_term_source (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("gst_jpegdec_chain: term_source");
|
GST_DEBUG ("term_source");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_jpegdec_init (GstJpegDec * jpegdec)
|
gst_jpegdec_init (GstJpegDec * jpegdec)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("gst_jpegdec_init: initializing");
|
GST_DEBUG ("initializing");
|
||||||
/* create the sink and src pads */
|
/* create the sink and src pads */
|
||||||
|
|
||||||
jpegdec->sinkpad =
|
jpegdec->sinkpad =
|
||||||
|
@ -380,14 +379,13 @@ gst_jpegdec_chain (GstPad * pad, GstData * _data)
|
||||||
|
|
||||||
data = (guchar *) GST_BUFFER_DATA (buf);
|
data = (guchar *) GST_BUFFER_DATA (buf);
|
||||||
size = GST_BUFFER_SIZE (buf);
|
size = GST_BUFFER_SIZE (buf);
|
||||||
GST_DEBUG ("gst_jpegdec_chain: got buffer of %ld bytes in '%s'", size,
|
GST_LOG_OBJECT (jpegdec, "got buffer of %ld bytes", size);
|
||||||
GST_OBJECT_NAME (jpegdec));
|
|
||||||
|
|
||||||
jpegdec->jsrc.next_input_byte = data;
|
jpegdec->jsrc.next_input_byte = data;
|
||||||
jpegdec->jsrc.bytes_in_buffer = size;
|
jpegdec->jsrc.bytes_in_buffer = size;
|
||||||
|
|
||||||
|
|
||||||
GST_DEBUG ("gst_jpegdec_chain: reading header %08lx", *(gulong *) data);
|
GST_LOG_OBJECT (jpegdec, "reading header %08lx", *(gulong *) data);
|
||||||
jpeg_read_header (&jpegdec->cinfo, TRUE);
|
jpeg_read_header (&jpegdec->cinfo, TRUE);
|
||||||
|
|
||||||
r_h = jpegdec->cinfo.cur_comp_info[0]->h_samp_factor;
|
r_h = jpegdec->cinfo.cur_comp_info[0]->h_samp_factor;
|
||||||
|
@ -402,17 +400,23 @@ gst_jpegdec_chain (GstPad * pad, GstData * _data)
|
||||||
jpegdec->cinfo.out_color_space = JCS_YCbCr;
|
jpegdec->cinfo.out_color_space = JCS_YCbCr;
|
||||||
jpegdec->cinfo.dct_method = JDCT_IFAST;
|
jpegdec->cinfo.dct_method = JDCT_IFAST;
|
||||||
jpegdec->cinfo.raw_data_out = TRUE;
|
jpegdec->cinfo.raw_data_out = TRUE;
|
||||||
GST_DEBUG ("gst_jpegdec_chain: starting decompress");
|
GST_LOG_OBJECT (jpegdec, "starting decompress");
|
||||||
guarantee_huff_tables (&jpegdec->cinfo);
|
guarantee_huff_tables (&jpegdec->cinfo);
|
||||||
jpeg_start_decompress (&jpegdec->cinfo);
|
jpeg_start_decompress (&jpegdec->cinfo);
|
||||||
width = jpegdec->cinfo.output_width;
|
width = jpegdec->cinfo.output_width;
|
||||||
height = jpegdec->cinfo.output_height;
|
height = jpegdec->cinfo.output_height;
|
||||||
GST_DEBUG ("gst_jpegdec_chain: width %d, height %d", width, height);
|
|
||||||
|
|
||||||
outbuf = gst_buffer_new ();
|
/* FIXME: someone needs to do the work to figure out how to correctly
|
||||||
outsize = GST_BUFFER_SIZE (outbuf) = width * height + width * height / 2;
|
* calculate an output size that takes into account everything libjpeg
|
||||||
outdata = GST_BUFFER_DATA (outbuf) = g_malloc (outsize);
|
* 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_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) {
|
if (jpegdec->height != height || jpegdec->line[0] == NULL) {
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
@ -427,18 +431,21 @@ gst_jpegdec_chain (GstPad * pad, GstData * _data)
|
||||||
"width", G_TYPE_INT, width,
|
"width", G_TYPE_INT, width,
|
||||||
"height", G_TYPE_INT, height,
|
"height", G_TYPE_INT, height,
|
||||||
"framerate", G_TYPE_DOUBLE, jpegdec->fps, NULL);
|
"framerate", G_TYPE_DOUBLE, jpegdec->fps, NULL);
|
||||||
|
GST_DEBUG_OBJECT (jpegdec, "height changed, setting caps %" GST_PTR_FORMAT,
|
||||||
|
caps);
|
||||||
gst_pad_set_explicit_caps (jpegdec->srcpad, caps);
|
gst_pad_set_explicit_caps (jpegdec->srcpad, caps);
|
||||||
gst_caps_free (caps);
|
gst_caps_free (caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mind the swap, jpeglib outputs blue chroma first */
|
/* mind the swap, jpeglib outputs blue chroma first */
|
||||||
|
/* FIXME: this needs stride love */
|
||||||
base[0] = outdata;
|
base[0] = outdata;
|
||||||
base[1] = base[0] + width * height;
|
base[1] = base[0] + width * height;
|
||||||
base[2] = base[1] + width * height / 4;
|
base[2] = base[1] + width * height / 4;
|
||||||
|
|
||||||
width2 = width >> 1;
|
width2 = width >> 1;
|
||||||
|
|
||||||
GST_DEBUG ("gst_jpegdec_chain: decompressing %u",
|
GST_LOG_OBJECT (jpegdec, "decompressing %u",
|
||||||
jpegdec->cinfo.rec_outbuf_height);
|
jpegdec->cinfo.rec_outbuf_height);
|
||||||
for (i = 0; i < height; i += r_v * DCTSIZE) {
|
for (i = 0; i < height; i += r_v * DCTSIZE) {
|
||||||
for (j = 0, k = 0; j < (r_v * DCTSIZE); j += r_v, k++) {
|
for (j = 0, k = 0; j < (r_v * DCTSIZE); j += r_v, k++) {
|
||||||
|
@ -459,10 +466,10 @@ gst_jpegdec_chain (GstPad * pad, GstData * _data)
|
||||||
jpeg_read_raw_data (&jpegdec->cinfo, jpegdec->line, r_v * DCTSIZE);
|
jpeg_read_raw_data (&jpegdec->cinfo, jpegdec->line, r_v * DCTSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG ("gst_jpegdec_chain: decompressing finished");
|
GST_LOG_OBJECT (jpegdec, "decompressing finished");
|
||||||
jpeg_finish_decompress (&jpegdec->cinfo);
|
jpeg_finish_decompress (&jpegdec->cinfo);
|
||||||
|
|
||||||
GST_DEBUG ("gst_jpegdec_chain: sending buffer");
|
GST_LOG_OBJECT (jpegdec, "sending buffer");
|
||||||
gst_pad_push (jpegdec->srcpad, GST_DATA (outbuf));
|
gst_pad_push (jpegdec->srcpad, GST_DATA (outbuf));
|
||||||
|
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
|
@ -165,7 +165,6 @@ gst_multipart_demux_init (GstMultipartDemux * multipart)
|
||||||
GST_FLAG_SET (multipart, GST_ELEMENT_EVENT_AWARE);
|
GST_FLAG_SET (multipart, GST_ELEMENT_EVENT_AWARE);
|
||||||
|
|
||||||
multipart->maxlen = 4096;
|
multipart->maxlen = 4096;
|
||||||
multipart->buffer = g_malloc (multipart->maxlen);
|
|
||||||
multipart->parsing_mime = NULL;
|
multipart->parsing_mime = NULL;
|
||||||
multipart->numpads = 0;
|
multipart->numpads = 0;
|
||||||
multipart->scanpos = 0;
|
multipart->scanpos = 0;
|
||||||
|
@ -321,9 +320,10 @@ gst_multipart_demux_chain (GstPad * pad, GstData * buffer)
|
||||||
}
|
}
|
||||||
// move rest downward
|
// move rest downward
|
||||||
multipart->bufsize -= multipart->scanpos;
|
multipart->bufsize -= multipart->scanpos;
|
||||||
memcpy (multipart->buffer, multipart->buffer + multipart->scanpos,
|
memmove (multipart->buffer, multipart->buffer + multipart->scanpos,
|
||||||
multipart->bufsize);
|
multipart->bufsize);
|
||||||
|
|
||||||
|
g_free (multipart->parsing_mime);
|
||||||
multipart->parsing_mime = mime_type;
|
multipart->parsing_mime = mime_type;
|
||||||
multipart->scanpos = 0;
|
multipart->scanpos = 0;
|
||||||
}
|
}
|
||||||
|
@ -344,10 +344,20 @@ gst_multipart_demux_change_state (GstElement * element)
|
||||||
|
|
||||||
switch (GST_STATE_TRANSITION (element)) {
|
switch (GST_STATE_TRANSITION (element)) {
|
||||||
case GST_STATE_NULL_TO_READY:
|
case GST_STATE_NULL_TO_READY:
|
||||||
|
break;
|
||||||
case GST_STATE_READY_TO_PAUSED:
|
case GST_STATE_READY_TO_PAUSED:
|
||||||
|
multipart->buffer = g_malloc (multipart->maxlen);
|
||||||
|
break;
|
||||||
case GST_STATE_PAUSED_TO_PLAYING:
|
case GST_STATE_PAUSED_TO_PLAYING:
|
||||||
|
break;
|
||||||
case GST_STATE_PLAYING_TO_PAUSED:
|
case GST_STATE_PLAYING_TO_PAUSED:
|
||||||
|
break;
|
||||||
case GST_STATE_PAUSED_TO_READY:
|
case GST_STATE_PAUSED_TO_READY:
|
||||||
|
g_free (multipart->parsing_mime);
|
||||||
|
multipart->parsing_mime = NULL;
|
||||||
|
g_free (multipart->buffer);
|
||||||
|
multipart->buffer = NULL;
|
||||||
|
break;
|
||||||
case GST_STATE_READY_TO_NULL:
|
case GST_STATE_READY_TO_NULL:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue