aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/bswap.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2005-05-10 19:54:38 +0000
committerMichael Niedermayer <michaelni@gmx.at>2005-05-10 19:54:38 +0000
commit33f725723f525357861abb4b3be8de250b6a7393 (patch)
treeda0d8da0fb55f0c9895a4f7b2bbfd9b60580e9f3 /libavcodec/bswap.h
parent24dea064cc30cf769a91c5417972401192d96fc3 (diff)
downloadffmpeg-33f725723f525357861abb4b3be8de250b6a7393.tar.gz
optimization
Originally committed as revision 4212 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/bswap.h')
-rw-r--r--libavcodec/bswap.h26
1 files changed, 18 insertions, 8 deletions
diff --git a/libavcodec/bswap.h b/libavcodec/bswap.h
index a55dc4664f..2e55337f9a 100644
--- a/libavcodec/bswap.h
+++ b/libavcodec/bswap.h
@@ -19,7 +19,7 @@
#if defined(ARCH_X86) || defined(ARCH_X86_64)
static always_inline uint16_t bswap_16(uint16_t x)
{
- __asm("xchgb %b0,%h0" :
+ __asm("rorw $8, %0" :
LEGACY_REGS (x) :
"0" (x));
return x;
@@ -48,12 +48,15 @@ static inline uint64_t bswap_64(uint64_t x)
"0" (x));
return x;
#else
- register union { __extension__ uint64_t __ll;
- uint32_t __l[2]; } __x;
- asm("xchgl %0,%1":
- "=r"(__x.__l[0]),"=r"(__x.__l[1]):
- "0"(bswap_32((uint32_t)x)),"1"(bswap_32((uint32_t)(x>>32))));
- return __x.__ll;
+ 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;
#endif
}
@@ -92,11 +95,17 @@ static always_inline uint16_t bswap_16(uint16_t x){
}
static always_inline uint32_t bswap_32(uint32_t x){
- return (x >> 24) | ((x & 0x00ff0000) >> 8) | ((x & 0x0000ff00) << 8) | (x << 24);
+ x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
+ return (x>>16) | (x<<16);
}
static inline uint64_t bswap_64(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];
@@ -105,6 +114,7 @@ static inline uint64_t bswap_64(uint64_t x)
r.l[0] = bswap_32 (w.l[1]);
r.l[1] = bswap_32 (w.l[0]);
return r.ll;
+#endif
}
#endif /* !ARCH_X86 */