summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2005-08-26 17:30:41 +0000
committerWim Taymans <wim.taymans@gmail.com>2005-08-26 17:30:41 +0000
commit98fbd82d1c5546348a50f229ed68a28a7141d3aa (patch)
tree14221ff265004d60613dfc6cffaf3e5836b8e003
parentceb84de91677d60d4cb42084c300a6cd104936d5 (diff)
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.
-rw-r--r--ChangeLog14
-rw-r--r--gst/audioconvert/audioconvert.c18
-rw-r--r--gst/audioconvert/gstaudioconvert.c9
-rw-r--r--gst/audioconvert/gstchannelmix.c13
4 files changed, 38 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 60123204d..3674e524b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
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:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
diff --git a/gst/audioconvert/audioconvert.c b/gst/audioconvert/audioconvert.c
index 8ec67dd74..f3435d78d 100644
--- a/gst/audioconvert/audioconvert.c
+++ b/gst/audioconvert/audioconvert.c
@@ -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);
diff --git a/gst/audioconvert/gstaudioconvert.c b/gst/audioconvert/gstaudioconvert.c
index 7c91aec01..f2864b3f2 100644
--- a/gst/audioconvert/gstaudioconvert.c
+++ b/gst/audioconvert/gstaudioconvert.c
@@ -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;
}
}
diff --git a/gst/audioconvert/gstchannelmix.c b/gst/audioconvert/gstchannelmix.c
index 570a854a7..9c7e4412e 100644
--- a/gst/audioconvert/gstchannelmix.c
+++ b/gst/audioconvert/gstchannelmix.c
@@ -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);
}
}