From: Wim Taymans Date: Mon, 10 Oct 2005 13:45:39 +0000 (+0000) Subject: gst/audioconvert/: Alloc temp storage somewhere else where we can do it more portable. X-Git-Tag: 1.19.3~511^2~12668 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b3f6be65c0d8e98fd476196285c47cc8d497091;p=platform%2Fupstream%2Fgstreamer.git gst/audioconvert/: Alloc temp storage somewhere else where we can do it more portable. Original commit message from CVS: * gst/audioconvert/audioconvert.h: * gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix), (gst_channel_mix_setup_matrix), (gst_channel_mix_mix): Alloc temp storage somewhere else where we can do it more portable. --- diff --git a/gst/audioconvert/audioconvert.h b/gst/audioconvert/audioconvert.h index 448a2cb..a2bd9dc 100644 --- a/gst/audioconvert/audioconvert.h +++ b/gst/audioconvert/audioconvert.h @@ -62,6 +62,8 @@ struct _AudioConvertCtx /* channel conversion matrix, m[in_channels][out_channels]. * If identity matrix, passthrough applies. */ gfloat **matrix; + /* temp storage for channelmix */ + gint32 *tmp; gboolean in_default; gboolean mix_passthrough; diff --git a/gst/audioconvert/gstchannelmix.c b/gst/audioconvert/gstchannelmix.c index 9c7e441..00de794 100644 --- a/gst/audioconvert/gstchannelmix.c +++ b/gst/audioconvert/gstchannelmix.c @@ -57,6 +57,8 @@ gst_channel_mix_unset_matrix (AudioConvertCtx * this) g_free (this->matrix); this->matrix = NULL; + g_free (this->tmp); + this->tmp = NULL; } /* @@ -486,6 +488,9 @@ gst_channel_mix_setup_matrix (AudioConvertCtx * this) /* don't lose memory */ gst_channel_mix_unset_matrix (this); + /* temp storage */ + this->tmp = g_new (gint32, this->out.channels); + /* allocate */ this->matrix = g_new0 (gfloat *, this->in.channels); for (i = 0; i < this->in.channels; i++) { @@ -543,12 +548,15 @@ gst_channel_mix_mix (AudioConvertCtx * this, { gint in, out, n; gint64 res; - gint32 tmp[this->out.channels]; - gboolean backwards = this->out.channels > this->in.channels; + gboolean backwards; gint inchannels, outchannels; + g_return_if_fail (this->matrix != NULL); + g_return_if_fail (this->tmp != NULL); + inchannels = this->in.channels; outchannels = this->out.channels; + backwards = outchannels > inchannels; /* FIXME: use liboil here? */ for (n = (backwards ? samples - 1 : 0); n < samples && n >= 0; @@ -565,8 +573,9 @@ gst_channel_mix_mix (AudioConvertCtx * this, res = G_MININT32; else if (res > G_MAXINT32) res = G_MAXINT32; - tmp[out] = res; + this->tmp[out] = res; } - memcpy (&out_data[n * outchannels], tmp, sizeof (gint32) * outchannels); + memcpy (&out_data[n * outchannels], this->tmp, + sizeof (gint32) * outchannels); } }