Commit 5b3f6be6 authored by Wim Taymans's avatar Wim Taymans
Browse files

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.
parent 6771e8b7
......@@ -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;
......
......@@ -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);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment