ref: 58fff5ceabc652747240a8fd2b929f33da192947
parent: 36f3f6222e7e48a79958b181b7f9e617be1b5c9e
author: LoRd_MuldeR <[email protected]>
date: Thu Dec 21 07:58:09 EST 2017
More generalized solution that also fixes compilation with GCC < 4.7.3.
--- a/frontend/mp4read.c
+++ b/frontend/mp4read.c
@@ -49,13 +49,15 @@
static inline uint32_t bswap32(const uint32_t u32)
{
#ifndef WORDS_BIGENDIAN
-#ifdef _MSC_VER
- return _byteswap_ulong(u32);
-#else
+#if defined (__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
return __builtin_bswap32(u32);
+#elif defined (_MSC_VER)
+ return _byteswap_ulong(u32);
+#else
+ return (u32 << 24) | ((u32 << 8) & 0xFF0000) | ((u32 >> 8) & 0xFF00) | (u32 >> 24);
#endif
#else
- return u32;
+ return u32;
#endif
}
@@ -62,15 +64,15 @@
static inline uint16_t bswap16(const uint16_t u16)
{
#ifndef WORDS_BIGENDIAN
-#ifdef _MSC_VER
- return _byteswap_ushort(u16);
-#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
- return __builtin_bswap16(u16);
+#if defined (__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)))
+ return __builtin_bswap16(u16);
+#elif defined (_MSC_VER)
+ return _byteswap_ushort(u16);
#else
- return (u16<<8)|(u16>>8);
+ return (u16 << 8) | (u16 >> 8);
#endif
#else
- return u16;
+ return u16;
#endif
}