[gst-devel] float caps, category, audioconvert changes
Leif Johnson
leif at ambient.2y.net
Sun Jul 20 06:52:04 CEST 2003
On Sun, 20 Jul 2003, Ronald Bultje wrote:
> On Sun, 2003-07-20 at 02:34, David Schleef wrote:
> > On Sat, Jul 19, 2003 at 07:53:41PM -0400, Leif Johnson wrote:
> > > I'm still working on fully integrating float audio into the audioconvert
> > > plugin. If anyone has a quick macro to change the endianness of a float or
> > > double, I could use one. :) I'll check in my float changes as soon as they
> > > work for me, but the int side of things should hopefully still work.
> > GUINT32_TO_LE() and GUINT64_TO_LE().
>
> Do UINT functions work for FLOAT types, too? As far as I understand, it
> will just cast it to a guint64 and return it as such, too.
>
> [rbultje at shrek tmp]$ grep GUINT64_TO_LE glibconfig.h
> #define GUINT64_TO_LE(val) ((guint64) (val))
> [rbultje at shrek tmp]$
I suppose I could just typecast the result from the macros, that might be a
good idea in any case.
> Could you test these in a row (i.e. start with your own endianness, go
> to the other and go back) and see if the data still works? If so, you
> could try to make a file and let people with the "other" endianness read
> it and see if it works for them. If so, we've got a winner.
I'll give it a whirl.
> In all the above, I'm assuming that byte order is the only issue here,
> and that the order of mantissa, sign etc. doesn't change (as the IEEE
> seems to prescribe). I'm not sure of this at all, since I've never known
> a single thing about floats. ;).
From </usr/include/glib-2.0/glib/gtypes.h> :
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
union _GFloatIEEE754
{
gfloat v_float;
struct {
guint mantissa : 23;
guint biased_exponent : 8;
guint sign : 1;
} mpn;
};
/* ... */
#elif G_BYTE_ORDER == G_BIG_ENDIAN
union _GFloatIEEE754
{
gfloat v_float;
struct {
guint sign : 1;
guint biased_exponent : 8;
guint mantissa : 23;
} mpn;
};
But using the integer byte swap functions still works, since reversing the
entire union will reverse the order of the component parts *and* the bit
order in each of the respective parts. ... Is that right ? :)
leif
--
Leif Morgan Johnson : http://ambient.2y.net/leif/
More information about the gstreamer-devel
mailing list