Merge commit '8a9de5c52401aa1e87bdb147524831c640d1ec53'
[ffmpeg.git] / libavutil / bswap.h
index 303bcf3..91cb795 100644 (file)
 
 #include "config.h"
 
-#if   ARCH_ARM
+#if   ARCH_AARCH64
+#   include "aarch64/bswap.h"
+#elif ARCH_ARM
 #   include "arm/bswap.h"
 #elif ARCH_AVR32
 #   include "avr32/bswap.h"
-#elif ARCH_BFIN
-#   include "bfin/bswap.h"
 #elif ARCH_SH4
 #   include "sh4/bswap.h"
 #elif ARCH_X86
@@ -65,29 +65,14 @@ static av_always_inline av_const uint16_t av_bswap16(uint16_t x)
 #ifndef av_bswap32
 static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
 {
-    x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
-    x= (x>>16) | (x<<16);
-    return x;
+    return AV_BSWAP32C(x);
 }
 #endif
 
 #ifndef av_bswap64
 static inline uint64_t av_const av_bswap64(uint64_t x)
 {
-#if 0
-    x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL);
-    x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL);
-    return (x>>32) | (x<<32);
-#else
-    union {
-        uint64_t ll;
-        uint32_t l[2];
-    } w, r;
-    w.ll = x;
-    r.l[0] = av_bswap32 (w.l[1]);
-    r.l[1] = av_bswap32 (w.l[0]);
-    return r.ll;
-#endif
+    return (uint64_t)av_bswap32(x) << 32 | av_bswap32(x >> 32);
 }
 #endif