From 043693d8d98870c3bae51d76391fbcec27fefd8b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 5 Mar 2004 21:05:26 +0000 Subject: [PATCH] gst/audioconvert/gstaudioconvert.c: convert channels correctly. convert correctly to unsigned. Original commit message from CVS: * gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_channels): convert channels correctly. convert correctly to unsigned. --- ChangeLog | 5 +++++ common | 2 +- gst/audioconvert/gstaudioconvert.c | 35 +++++++++++++++++------------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index f60ae11861..2fc974b5f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-03-05 Benjamin Otte + + * gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_channels): + convert channels correctly. convert correctly to unsigned. + 2004-03-05 Julien MOUTTE * sys/xvimage/xvimagesink.c: (gst_xvimagesink_change_state): Check if diff --git a/common b/common index 874dab5c34..4eb02711e4 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 874dab5c3461ad7487f1ae029256b6da82dddf6d +Subproject commit 4eb02711e49a6aadf900d6fd9d220c17115fec2a diff --git a/gst/audioconvert/gstaudioconvert.c b/gst/audioconvert/gstaudioconvert.c index 29145e39b0..d057d665e2 100644 --- a/gst/audioconvert/gstaudioconvert.c +++ b/gst/audioconvert/gstaudioconvert.c @@ -589,16 +589,17 @@ gst_audio_convert_get_buffer (GstBuffer *buf, guint size) static inline guint8 GUINT8_IDENTITY (guint8 x) { return x; } static inline guint8 GINT8_IDENTITY (gint8 x) { return x; } -#define CONVERT_TO(to, from, type, sign, endianness, LE_FUNC, BE_FUNC) G_STMT_START{\ - type value; \ - memcpy (&value, from, sizeof (type)); \ - from -= sizeof (type); \ - value = (endianness == G_LITTLE_ENDIAN) ? LE_FUNC (value) : BE_FUNC (value); \ - if (sign) { \ - to = value; \ - } else { \ - to = (gint64) value - (1 << (sizeof (type) * 8 - 1)); \ - } \ +#define CONVERT_TO(to, from, type, sign, endianness, LE_FUNC, BE_FUNC) \ +G_STMT_START{ \ + type value; \ + memcpy (&value, from, sizeof (type)); \ + from -= sizeof (type); \ + value = (endianness == G_LITTLE_ENDIAN) ? LE_FUNC (value) : BE_FUNC (value); \ + if (sign) { \ + to = value; \ + } else { \ + to = (gint64) value - (1 << (sizeof (type) * 8 - 1)); \ + } \ }G_STMT_END; static GstBuffer* @@ -680,7 +681,11 @@ gst_audio_convert_buffer_to_default_format (GstAudioConvert *this, GstBuffer *bu format val; \ format* p = (format *) dest; \ int_value >>= (32 - this->srccaps.depth); \ - val = (format) int_value; \ + if (this->srccaps.sign) { \ + val = (format) int_value; \ + } else { \ + val = (format) int_value + (1 << (this->srccaps.depth - 1)); \ + } \ switch (this->srccaps.endianness) { \ case G_LITTLE_ENDIAN: \ val = le_func (val); \ @@ -753,21 +758,21 @@ gst_audio_convert_channels (GstAudioConvert *this, GstBuffer *buf) { GstBuffer *ret; gint i, count; - guint32 *src, *dest; + gint32 *src, *dest; if (this->sinkcaps.channels == this->srccaps.channels) return buf; count = GST_BUFFER_SIZE (buf) / 4 / this->sinkcaps.channels; ret = gst_audio_convert_get_buffer (buf, count * 4 * this->srccaps.channels); - src = (guint32 *) GST_BUFFER_DATA (buf); - dest = (guint32 *) GST_BUFFER_DATA (ret); + src = (gint32 *) GST_BUFFER_DATA (buf); + dest = (gint32 *) GST_BUFFER_DATA (ret); if (this->sinkcaps.channels > this->srccaps.channels) { for (i = 0; i < count; i++) { *dest = *src >> 1; src++; - *dest += (*src + 1) >> 1; + *dest += (*src >> 1) + (*src & 1); src++; dest++; }