From 7ac077828f3fed0104757f2ce2407d69417823ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 1 Sep 2008 17:49:59 +0000 Subject: gst/mpegtsmux/mpegtsmux_aac.c: Allocate a fixed size buffer on the stack instead of using malloc(). Original commit message from CVS: * gst/mpegtsmux/mpegtsmux_aac.c: (mpegtsmux_prepare_aac): Allocate a fixed size buffer on the stack instead of using malloc(). * gst/mpegtsmux/tsmux/tsmux.c: (tsmux_new), (tsmux_free), (tsmux_program_new), (tsmux_program_free): * gst/mpegtsmux/tsmux/tsmuxstream.c: (tsmux_stream_new), (tsmux_stream_free), (tsmux_stream_consume), (tsmux_stream_add_data): Use GSlice. --- ChangeLog | 12 ++++++++++++ gst/mpegtsmux/mpegtsmux_aac.c | 3 +-- gst/mpegtsmux/tsmux/tsmux.c | 8 ++++---- gst/mpegtsmux/tsmux/tsmuxstream.c | 8 ++++---- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index a33d2b8d..c73f6b89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-09-01 Sebastian Dröge + + * gst/mpegtsmux/mpegtsmux_aac.c: (mpegtsmux_prepare_aac): + Allocate a fixed size buffer on the stack instead of using malloc(). + + * gst/mpegtsmux/tsmux/tsmux.c: (tsmux_new), (tsmux_free), + (tsmux_program_new), (tsmux_program_free): + * gst/mpegtsmux/tsmux/tsmuxstream.c: (tsmux_stream_new), + (tsmux_stream_free), (tsmux_stream_consume), + (tsmux_stream_add_data): + Use GSlice. + 2008-09-01 Sebastian Dröge * gst/mpegtsmux/mpegtsmux.c: (mpegtsmux_create_stream): diff --git a/gst/mpegtsmux/mpegtsmux_aac.c b/gst/mpegtsmux/mpegtsmux_aac.c index 71727f21..5afefc83 100644 --- a/gst/mpegtsmux/mpegtsmux_aac.c +++ b/gst/mpegtsmux/mpegtsmux_aac.c @@ -93,7 +93,7 @@ GST_DEBUG_CATEGORY_EXTERN (mpegtsmux_debug); GstBuffer * mpegtsmux_prepare_aac (GstBuffer * buf, MpegTsPadData * data, MpegTsMux * mux) { - guint8 *adts_header = g_malloc0 (7); + guint8 adts_header[7] = { 0, }; GstBuffer *out_buf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buf) + 7); gsize out_offset = 0; guint8 rate_idx = 0, channels = 0, obj_type = 0; @@ -140,7 +140,6 @@ mpegtsmux_prepare_aac (GstBuffer * buf, MpegTsPadData * data, MpegTsMux * mux) /* Insert ADTS header */ memcpy (GST_BUFFER_DATA (out_buf) + out_offset, adts_header, 7); - g_free (adts_header); out_offset += 7; /* Now copy complete frame */ diff --git a/gst/mpegtsmux/tsmux/tsmux.c b/gst/mpegtsmux/tsmux/tsmux.c index 0952f699..ffb92388 100644 --- a/gst/mpegtsmux/tsmux/tsmux.c +++ b/gst/mpegtsmux/tsmux/tsmux.c @@ -130,7 +130,7 @@ tsmux_new () { TsMux *mux; - mux = g_new0 (TsMux, 1); + mux = g_slice_new0 (TsMux); mux->transport_id = TSMUX_DEFAULT_TS_ID; @@ -229,7 +229,7 @@ tsmux_free (TsMux * mux) } g_list_free (mux->streams); - g_free (mux); + g_slice_free (TsMux, mux); } /** @@ -252,7 +252,7 @@ tsmux_program_new (TsMux * mux) if (mux->nb_programs == TSMUX_MAX_PROGRAMS) return NULL; - program = g_new0 (TsMuxProgram, 1); + program = g_slice_new0 (TsMuxProgram); program->pmt_changed = TRUE; program->last_pmt_ts = -1; @@ -811,7 +811,7 @@ tsmux_program_free (TsMuxProgram * program) g_return_if_fail (program != NULL); g_array_free (program->streams, TRUE); - g_free (program); + g_slice_free (TsMuxProgram, program); } static gboolean diff --git a/gst/mpegtsmux/tsmux/tsmuxstream.c b/gst/mpegtsmux/tsmux/tsmuxstream.c index 74b3c82b..342bb9ea 100644 --- a/gst/mpegtsmux/tsmux/tsmuxstream.c +++ b/gst/mpegtsmux/tsmux/tsmuxstream.c @@ -115,7 +115,7 @@ struct TsMuxStreamBuffer TsMuxStream * tsmux_stream_new (guint16 pid, TsMuxStreamType stream_type) { - TsMuxStream *stream = g_new0 (TsMuxStream, 1); + TsMuxStream *stream = g_slice_new0 (TsMuxStream); stream->state = TSMUX_STREAM_STATE_HEADER; stream->pi.pid = pid; @@ -193,7 +193,7 @@ tsmux_stream_free (TsMuxStream * stream) { g_return_if_fail (stream != NULL); - g_free (stream); + g_slice_free (TsMuxStream, stream); } /** @@ -243,7 +243,7 @@ tsmux_stream_consume (TsMuxStream * stream, guint len) stream->cur_buffer->user_data); } - g_free (stream->cur_buffer); + g_slice_free (TsMuxStreamBuffer, stream->cur_buffer); stream->cur_buffer = NULL; /* FIXME: As a hack, for unbounded streams, start a new PES packet for each * incoming packet we receive. This assumes that incoming data is @@ -571,7 +571,7 @@ tsmux_stream_add_data (TsMuxStream * stream, guint8 * data, guint len, g_return_if_fail (stream != NULL); - packet = g_new (TsMuxStreamBuffer, 1); + packet = g_slice_new (TsMuxStreamBuffer); packet->data = data; packet->size = len; packet->user_data = user_data; -- cgit v1.2.1