From: Benjamin Otte Date: Thu, 4 Mar 2004 23:30:29 +0000 (+0000) Subject: gst/audioconvert/gstaudioconvert.c: make float=>int conversion work correctly even... X-Git-Tag: 1.19.3~511^2~14570 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02c11b879e87286125d118ad9998bfac45ffc9e3;p=platform%2Fupstream%2Fgstreamer.git gst/audioconvert/gstaudioconvert.c: make float=>int conversion work correctly even in cornercases. Original commit message from CVS: 2004-03-05 Benjamin Otte * gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_buffer_to_default_format): make float=>int conversion work correctly even in cornercases. --- diff --git a/ChangeLog b/ChangeLog index c277d1b..ec0511a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-03-05 Benjamin Otte + + * gst/audioconvert/gstaudioconvert.c: + (gst_audio_convert_buffer_to_default_format): + make float=>int conversion work correctly even in cornercases. + 2004-03-04 David I. Lehn * debian/README.Debian: @@ -100,7 +106,8 @@ 2004-04-03 Christian Schaller * gst-plugins.spec.in: - Change names of plugins to actually be correct. Try to keep things alphabetical to avoid getting beat up by Thomas + Change names of plugins to actually be correct. Try to keep things + alphabetical to avoid getting beat up by Thomas 2004-03-03 Julien MOUTTE diff --git a/gst/audioconvert/gstaudioconvert.c b/gst/audioconvert/gstaudioconvert.c index bfbcc5a..29145e3 100644 --- a/gst/audioconvert/gstaudioconvert.c +++ b/gst/audioconvert/gstaudioconvert.c @@ -25,7 +25,6 @@ #endif #include -#include #include GST_DEBUG_CATEGORY_STATIC (audio_convert_debug); @@ -136,20 +135,19 @@ GST_STATIC_PAD_TEMPLATE ( GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ( - "audio/x-raw-int, " \ - "rate = (int) [ 1, MAX ], " \ - "channels = (int) [ 1, MAX ], " \ - "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \ - "width = (int) { 8, 16, 32 }, " \ - "depth = (int) [ 1, 32 ], " \ - "signed = (boolean) { true, false }; " - - "audio/x-raw-float, " \ - "rate = (int) [ 1, MAX ], " - "channels = (int) [ 1, MAX ], " - "endianness = (int) BYTE_ORDER, " - "width = (int) 32, " - "buffer-frames = (int) [ 0, MAX ]" + "audio/x-raw-int, " + "rate = (int) [ 1, MAX ], " + "channels = (int) [ 1, MAX ], " + "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " + "width = (int) { 8, 16, 32 }, " + "depth = (int) [ 1, 32 ], " + "signed = (boolean) { true, false }; " + "audio/x-raw-float, " + "rate = (int) [ 1, MAX ], " + "channels = (int) [ 1, MAX ], " + "endianness = (int) BYTE_ORDER, " + "width = (int) 32, " + "buffer-frames = (int) [ 0, MAX ]" ) ); @@ -666,8 +664,12 @@ gst_audio_convert_buffer_to_default_format (GstAudioConvert *this, GstBuffer *bu in = (gfloat*)GST_BUFFER_DATA (buf); out = (gint32*)GST_BUFFER_DATA (ret); /* increment `in' via the for, cause CLAMP duplicates the first arg */ - for (i = buf->size / sizeof(float); i; i--, in++) - *(out++) = (gint32) gst_cast_float(CLAMP (*in, -1.f, 1.f) * 2147483647.0F); + for (i = buf->size / sizeof(float); i > 0; i--) { + *in *= 2147483647.0f + .5; + *out = (gint32) CLAMP ((gint64) *in, -2147483648ll, 2147483647ll); + out++; + in++; + } } gst_buffer_unref (buf);