gst/audioconvert/gstaudioconvert.c: make float=>int conversion work correctly even in cornercases.

Original commit message from CVS:
2004-03-05  Benjamin Otte  <otte@gnome.org>

* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_buffer_to_default_format):
make float=>int conversion work correctly even in cornercases.
This commit is contained in:
Benjamin Otte 2004-03-04 23:30:29 +00:00
parent 53e241ccd4
commit 02c11b879e
2 changed files with 27 additions and 18 deletions

View file

@ -1,3 +1,9 @@
2004-03-05 Benjamin Otte <otte@gnome.org>
* 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 <dlehn@users.sourceforge.net>
* debian/README.Debian:
@ -100,7 +106,8 @@
2004-04-03 Christian Schaller <Uraeus@gnome.org>
* 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 <julien@moutte.net>

View file

@ -25,7 +25,6 @@
#endif
#include <gst/gst.h>
#include <gst/floatcast/floatcast.h>
#include <string.h>
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);