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.
This commit is contained in:
parent
c6ae4cb8ca
commit
043693d8d9
@ -1,3 +1,8 @@
|
|||||||
|
2004-03-05 Benjamin Otte <otte@gnome.org>
|
||||||
|
|
||||||
|
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_channels):
|
||||||
|
convert channels correctly. convert correctly to unsigned.
|
||||||
|
|
||||||
2004-03-05 Julien MOUTTE <julien@moutte.net>
|
2004-03-05 Julien MOUTTE <julien@moutte.net>
|
||||||
|
|
||||||
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_change_state): Check if
|
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_change_state): Check if
|
||||||
|
2
common
2
common
@ -1 +1 @@
|
|||||||
Subproject commit 874dab5c3461ad7487f1ae029256b6da82dddf6d
|
Subproject commit 4eb02711e49a6aadf900d6fd9d220c17115fec2a
|
@ -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 GUINT8_IDENTITY (guint8 x) { return x; }
|
||||||
static inline guint8 GINT8_IDENTITY (gint8 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{\
|
#define CONVERT_TO(to, from, type, sign, endianness, LE_FUNC, BE_FUNC) \
|
||||||
type value; \
|
G_STMT_START{ \
|
||||||
memcpy (&value, from, sizeof (type)); \
|
type value; \
|
||||||
from -= sizeof (type); \
|
memcpy (&value, from, sizeof (type)); \
|
||||||
value = (endianness == G_LITTLE_ENDIAN) ? LE_FUNC (value) : BE_FUNC (value); \
|
from -= sizeof (type); \
|
||||||
if (sign) { \
|
value = (endianness == G_LITTLE_ENDIAN) ? LE_FUNC (value) : BE_FUNC (value); \
|
||||||
to = value; \
|
if (sign) { \
|
||||||
} else { \
|
to = value; \
|
||||||
to = (gint64) value - (1 << (sizeof (type) * 8 - 1)); \
|
} else { \
|
||||||
} \
|
to = (gint64) value - (1 << (sizeof (type) * 8 - 1)); \
|
||||||
|
} \
|
||||||
}G_STMT_END;
|
}G_STMT_END;
|
||||||
|
|
||||||
static GstBuffer*
|
static GstBuffer*
|
||||||
@ -680,7 +681,11 @@ gst_audio_convert_buffer_to_default_format (GstAudioConvert *this, GstBuffer *bu
|
|||||||
format val; \
|
format val; \
|
||||||
format* p = (format *) dest; \
|
format* p = (format *) dest; \
|
||||||
int_value >>= (32 - this->srccaps.depth); \
|
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) { \
|
switch (this->srccaps.endianness) { \
|
||||||
case G_LITTLE_ENDIAN: \
|
case G_LITTLE_ENDIAN: \
|
||||||
val = le_func (val); \
|
val = le_func (val); \
|
||||||
@ -753,21 +758,21 @@ gst_audio_convert_channels (GstAudioConvert *this, GstBuffer *buf)
|
|||||||
{
|
{
|
||||||
GstBuffer *ret;
|
GstBuffer *ret;
|
||||||
gint i, count;
|
gint i, count;
|
||||||
guint32 *src, *dest;
|
gint32 *src, *dest;
|
||||||
|
|
||||||
if (this->sinkcaps.channels == this->srccaps.channels)
|
if (this->sinkcaps.channels == this->srccaps.channels)
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
count = GST_BUFFER_SIZE (buf) / 4 / this->sinkcaps.channels;
|
count = GST_BUFFER_SIZE (buf) / 4 / this->sinkcaps.channels;
|
||||||
ret = gst_audio_convert_get_buffer (buf, count * 4 * this->srccaps.channels);
|
ret = gst_audio_convert_get_buffer (buf, count * 4 * this->srccaps.channels);
|
||||||
src = (guint32 *) GST_BUFFER_DATA (buf);
|
src = (gint32 *) GST_BUFFER_DATA (buf);
|
||||||
dest = (guint32 *) GST_BUFFER_DATA (ret);
|
dest = (gint32 *) GST_BUFFER_DATA (ret);
|
||||||
|
|
||||||
if (this->sinkcaps.channels > this->srccaps.channels) {
|
if (this->sinkcaps.channels > this->srccaps.channels) {
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
*dest = *src >> 1;
|
*dest = *src >> 1;
|
||||||
src++;
|
src++;
|
||||||
*dest += (*src + 1) >> 1;
|
*dest += (*src >> 1) + (*src & 1);
|
||||||
src++;
|
src++;
|
||||||
dest++;
|
dest++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user