diff --git a/gst/audioconvert/audioconvert.h b/gst/audioconvert/audioconvert.h index 448a2cb7c3..a2bd9dc52a 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 9c7e4412ec..00de794e31 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); } }