diff bswap.h @ 1259:e8c3884f2c7e libavcodec

sh4 optimized idct & bswap patch by (BERO <bero at geocities dot co dot jp>)
author michaelni
date Wed, 14 May 2003 12:18:49 +0000
parents 1e39f273ecd6
children 1831d86117a3
line wrap: on
line diff
--- a/bswap.h	Wed May 14 11:40:16 2003 +0000
+++ b/bswap.h	Wed May 14 12:18:49 2003 +0000
@@ -47,6 +47,39 @@
 }
 #define bswap_64(x) ByteSwap64(x)
 
+#elif defined(ARCH_SH4)
+
+static inline uint16_t ByteSwap16(uint16_t x) {
+	__asm__("swap.b %0,%0":"=r"(x):"0"(x));
+	return x;
+}
+
+static inline uint32_t ByteSwap32(uint32_t x) {
+	__asm__(
+	"swap.b %0,%0\n"
+	"swap.w %0,%0\n"
+	"swap.b %0,%0\n"
+	:"=r"(x):"0"(x));
+	return x;
+}
+
+#define bswap_16(x) ByteSwap16(x)
+#define bswap_32(x) ByteSwap32(x)
+
+inline static uint64_t ByteSwap64(uint64_t x)
+{
+    union { 
+        uint64_t ll;
+        struct {
+           uint32_t l,h;
+        } l;
+    } r;
+    r.l.l = bswap_32 (x);
+    r.l.h = bswap_32 (x>>32);
+    return r.ll;
+}
+#define bswap_64(x) ByteSwap64(x)
+
 #else
 
 #define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8)