Commit 33f72572 authored by Michael Niedermayer's avatar Michael Niedermayer

optimization

Originally committed as revision 4212 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 24dea064
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment