00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef AVUTIL_ARM_BSWAP_H
00020 #define AVUTIL_ARM_BSWAP_H
00021
00022 #include <stdint.h>
00023 #include "config.h"
00024 #include "libavutil/attributes.h"
00025
00026 #ifdef __ARMCC_VERSION
00027
00028 #if HAVE_ARMV6
00029 #define av_bswap32 av_bswap32
00030 static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
00031 {
00032 return __rev(x);
00033 }
00034 #endif
00035
00036 #elif HAVE_INLINE_ASM
00037
00038 #if HAVE_ARMV6_INLINE
00039 #define av_bswap16 av_bswap16
00040 static av_always_inline av_const unsigned av_bswap16(unsigned x)
00041 {
00042 __asm__("rev16 %0, %0" : "+r"(x));
00043 return x;
00044 }
00045 #endif
00046
00047 #if !AV_GCC_VERSION_AT_LEAST(4,5)
00048 #define av_bswap32 av_bswap32
00049 static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
00050 {
00051 #if HAVE_ARMV6_INLINE
00052 __asm__("rev %0, %0" : "+r"(x));
00053 #else
00054 uint32_t t;
00055 __asm__ ("eor %1, %0, %0, ror #16 \n\t"
00056 "bic %1, %1, #0xFF0000 \n\t"
00057 "mov %0, %0, ror #8 \n\t"
00058 "eor %0, %0, %1, lsr #8 \n\t"
00059 : "+r"(x), "=&r"(t));
00060 #endif
00061 return x;
00062 }
00063 #endif
00064
00065 #endif
00066
00067 #endif