mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-16 13:26:36 +00:00
gst/audioconvert/: Oops, allocate enough space to perform the channel mix.
Original commit message from CVS: * gst/audioconvert/audioconvert.c: (if), (float), (audio_convert_get_func_index), (check_default), (audio_convert_clean_fmt), (audio_convert_prepare_context), (audio_convert_clean_context), (audio_convert_get_sizes), (get_temp_buffer), (audio_convert_convert): * gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_parse_caps), (gst_audio_convert_get_unit_size), (gst_audio_convert_transform_caps), (gst_audio_convert_fixate_caps), (gst_audio_convert_transform): * gst/audioconvert/gstchannelmix.c: (gst_channel_mix_mix): Oops, allocate enough space to perform the channel mix.
This commit is contained in:
parent
ceb84de916
commit
98fbd82d1c
4 changed files with 38 additions and 16 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2005-08-26 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* gst/audioconvert/audioconvert.c: (if), (float),
|
||||
(audio_convert_get_func_index), (check_default),
|
||||
(audio_convert_clean_fmt), (audio_convert_prepare_context),
|
||||
(audio_convert_clean_context), (audio_convert_get_sizes),
|
||||
(get_temp_buffer), (audio_convert_convert):
|
||||
* gst/audioconvert/gstaudioconvert.c:
|
||||
(gst_audio_convert_parse_caps), (gst_audio_convert_get_unit_size),
|
||||
(gst_audio_convert_transform_caps),
|
||||
(gst_audio_convert_fixate_caps), (gst_audio_convert_transform):
|
||||
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_mix):
|
||||
Oops, allocate enough space to perform the channel mix.
|
||||
|
||||
2005-08-26 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* gst/audioconvert/Makefile.am:
|
||||
|
|
|
@ -312,11 +312,13 @@ get_temp_buffer (AudioConvertCtx * ctx, gpointer src, gint srcsize,
|
|||
result = src;
|
||||
} else {
|
||||
if (ctx->tmpbufsize < tmpsize) {
|
||||
ctx->tmpbuf = g_realloc (ctx->tmpbuf, tmpsize);
|
||||
g_free (ctx->tmpbuf);
|
||||
ctx->tmpbuf = g_malloc (tmpsize);
|
||||
ctx->tmpbufsize = tmpsize;
|
||||
}
|
||||
result = ctx->tmpbuf;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -324,13 +326,13 @@ gboolean
|
|||
audio_convert_convert (AudioConvertCtx * ctx, gpointer src,
|
||||
gpointer dst, gint samples, gboolean src_writable)
|
||||
{
|
||||
gint insize;
|
||||
gint insize, outsize;
|
||||
gboolean final;
|
||||
gpointer buf;
|
||||
gint bufsize;
|
||||
gboolean bufwritable;
|
||||
gpointer tmpdst;
|
||||
gint tmpsize;
|
||||
gint tmpsize = 0;
|
||||
|
||||
g_return_val_if_fail (ctx != NULL, FALSE);
|
||||
g_return_val_if_fail (src != NULL, FALSE);
|
||||
|
@ -341,7 +343,7 @@ audio_convert_convert (AudioConvertCtx * ctx, gpointer src,
|
|||
return TRUE;
|
||||
|
||||
insize = ctx->in.unit_size * samples;
|
||||
tmpsize = insize * 32 / ctx->in.width;
|
||||
outsize = ctx->out.unit_size * samples;
|
||||
|
||||
/* this is our source data, we start with the input src data. */
|
||||
buf = src;
|
||||
|
@ -354,8 +356,10 @@ audio_convert_convert (AudioConvertCtx * ctx, gpointer src,
|
|||
|
||||
if (final)
|
||||
tmpdst = dst;
|
||||
else
|
||||
else {
|
||||
tmpsize = insize * 32 / ctx->in.width;
|
||||
tmpdst = get_temp_buffer (ctx, buf, bufsize, bufwritable, tmpsize);
|
||||
}
|
||||
|
||||
ctx->unpack (buf, tmpdst, ctx->scale, samples * ctx->in.channels);
|
||||
|
||||
|
@ -373,8 +377,10 @@ audio_convert_convert (AudioConvertCtx * ctx, gpointer src,
|
|||
|
||||
if (final)
|
||||
tmpdst = dst;
|
||||
else
|
||||
else {
|
||||
tmpsize = outsize * 32 / ctx->out.width;
|
||||
tmpdst = get_temp_buffer (ctx, buf, bufsize, bufwritable, tmpsize);
|
||||
}
|
||||
|
||||
/* convert */
|
||||
gst_channel_mix_mix (ctx, buf, tmpdst, samples);
|
||||
|
|
|
@ -285,22 +285,21 @@ static gboolean
|
|||
gst_audio_convert_get_unit_size (GstBaseTransform * base, GstCaps * caps,
|
||||
guint * size)
|
||||
{
|
||||
AudioConvertFmt ac_caps = { 0 };
|
||||
AudioConvertFmt fmt = { 0 };
|
||||
|
||||
g_return_val_if_fail (size, FALSE);
|
||||
|
||||
if (!gst_audio_convert_parse_caps (caps, &ac_caps))
|
||||
if (!gst_audio_convert_parse_caps (caps, &fmt))
|
||||
goto parse_error;
|
||||
|
||||
g_free (ac_caps.pos);
|
||||
*size = fmt.unit_size;
|
||||
|
||||
*size = ac_caps.unit_size;
|
||||
audio_convert_clean_fmt (&fmt);
|
||||
|
||||
return TRUE;
|
||||
|
||||
parse_error:
|
||||
{
|
||||
g_free (ac_caps.pos);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -545,15 +545,19 @@ gst_channel_mix_mix (AudioConvertCtx * this,
|
|||
gint64 res;
|
||||
gint32 tmp[this->out.channels];
|
||||
gboolean backwards = this->out.channels > this->in.channels;
|
||||
gint inchannels, outchannels;
|
||||
|
||||
inchannels = this->in.channels;
|
||||
outchannels = this->out.channels;
|
||||
|
||||
/* FIXME: use liboil here? */
|
||||
for (n = (backwards ? samples - 1 : 0); n < samples && n >= 0;
|
||||
backwards ? n-- : n++) {
|
||||
for (out = 0; out < this->out.channels; out++) {
|
||||
for (out = 0; out < outchannels; out++) {
|
||||
/* convert */
|
||||
res = 0;
|
||||
for (in = 0; in < this->in.channels; in++) {
|
||||
res += in_data[n * this->in.channels + in] * this->matrix[in][out];
|
||||
for (in = 0; in < inchannels; in++) {
|
||||
res += in_data[n * inchannels + in] * this->matrix[in][out];
|
||||
}
|
||||
|
||||
/* clip (shouldn't we use doubles instead as intermediate format?) */
|
||||
|
@ -563,7 +567,6 @@ gst_channel_mix_mix (AudioConvertCtx * this,
|
|||
res = G_MAXINT32;
|
||||
tmp[out] = res;
|
||||
}
|
||||
memcpy (&out_data[n * this->out.channels], tmp,
|
||||
sizeof (gint32) * this->out.channels);
|
||||
memcpy (&out_data[n * outchannels], tmp, sizeof (gint32) * outchannels);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue