comparison bswap.h @ 477:8d25a4b50588 libavutil

Pure, const and malloc attributes to libavutil. Patch by Zuxy Meng: zuxy meng gmail com Original thread: [FFmpeg-devel] [PATCH] Pure, const and malloc attributes to libavutil Date: 03/18/2008 6:09 AM
author benoit
date Tue, 18 Mar 2008 15:27:15 +0000
parents bdc8433d739e
children 8d2c05ebf5f1
comparison
equal deleted inserted replaced
476:3075323f2c2c 477:8d25a4b50588
38 # define LEGACY_REGS "=Q" 38 # define LEGACY_REGS "=Q"
39 #else 39 #else
40 # define LEGACY_REGS "=q" 40 # define LEGACY_REGS "=q"
41 #endif 41 #endif
42 42
43 static av_always_inline uint16_t bswap_16(uint16_t x) 43 static av_always_inline av_const uint16_t bswap_16(uint16_t x)
44 { 44 {
45 #if defined(ARCH_X86) 45 #if defined(ARCH_X86)
46 __asm("rorw $8, %0" : 46 __asm("rorw $8, %0" :
47 LEGACY_REGS (x) : 47 LEGACY_REGS (x) :
48 "0" (x)); 48 "0" (x));
52 x= (x>>8) | (x<<8); 52 x= (x>>8) | (x<<8);
53 #endif 53 #endif
54 return x; 54 return x;
55 } 55 }
56 56
57 static av_always_inline uint32_t bswap_32(uint32_t x) 57 static av_always_inline av_const uint32_t bswap_32(uint32_t x)
58 { 58 {
59 #if defined(ARCH_X86) 59 #if defined(ARCH_X86)
60 #ifdef HAVE_BSWAP 60 #ifdef HAVE_BSWAP
61 __asm("bswap %0": 61 __asm("bswap %0":
62 "=r" (x) : 62 "=r" (x) :
91 x= (x>>16) | (x<<16); 91 x= (x>>16) | (x<<16);
92 #endif 92 #endif
93 return x; 93 return x;
94 } 94 }
95 95
96 static inline uint64_t bswap_64(uint64_t x) 96 static inline uint64_t av_const bswap_64(uint64_t x)
97 { 97 {
98 #if 0 98 #if 0
99 x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); 99 x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL);
100 x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL); 100 x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL);
101 return (x>>32) | (x<<32); 101 return (x>>32) | (x<<32);