[MPlayer-dev-eng] Flaoting point endianness??

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Feb 22 17:34:23 CET 2005


Hi,
I ran across an annoying problem: Floating point values have endianness
issues as well, and fp and integer endianess can differ...
So I came up with a patch for bswap.h (only for float and double, as I
don't really know about long double).
But at least a configure patch is still needed... Any suggestions?
Please?

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: bswap.h
===================================================================
RCS file: /cvsroot/mplayer/main/bswap.h,v
retrieving revision 1.5
diff -u -r1.5 bswap.h
--- bswap.h	21 Oct 2004 11:55:19 -0000	1.5
+++ bswap.h	22 Feb 2005 16:33:45 -0000
@@ -117,6 +117,18 @@
 
 #endif	/* !HAVE_BYTESWAP_H */
 
+static float inline bswap_flt(float x) {
+  uint32_t *t = (uint32_t *)(void *)&x;
+  *t = bswap_32(*t);
+  return x;
+}
+
+static double inline bswap_dbl(double x) {
+  uint64_t *t = (uint64_t *)(void *)&x;
+  *t = bswap_64(*t);
+  return x;
+}
+
 // be2me ... BigEndian to MachineEndian
 // le2me ... LittleEndian to MachineEndian
 
@@ -136,4 +148,16 @@
 #define le2me_64(x) (x)
 #endif
 
+#ifdef FP_BIGENDIAN
+#define be2me_flt(x) (x)
+#define be2me_dbl(x) (x)
+#define le2me_flt(x) bswap_flt(x)
+#define le2me_dbl(x) bswap_dbl(x)
+#else
+#define be2me_flt(x) bswap_flt(x)
+#define be2me_dbl(x) bswap_dbl(x)
+#define le2me_flt(x) (x)
+#define le2me_dbl(x) (x)
+#endif
+
 #endif /* __BSWAP_H__ */


More information about the MPlayer-dev-eng mailing list