Libav 0.7.1
|
00001 /* 00002 * This file is part of Libav. 00003 * 00004 * Libav is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * Libav is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with Libav; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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_bswap16 av_bswap16 00030 static av_always_inline av_const unsigned av_bswap16(unsigned x) 00031 { 00032 __asm { rev16 x, x } 00033 return x; 00034 } 00035 00036 #define av_bswap32 av_bswap32 00037 static av_always_inline av_const uint32_t av_bswap32(uint32_t x) 00038 { 00039 return __rev(x); 00040 } 00041 #endif /* HAVE_ARMV6 */ 00042 00043 #elif HAVE_INLINE_ASM 00044 00045 #if HAVE_ARMV6 00046 #define av_bswap16 av_bswap16 00047 static av_always_inline av_const unsigned av_bswap16(unsigned x) 00048 { 00049 __asm__("rev16 %0, %0" : "+r"(x)); 00050 return x; 00051 } 00052 #endif 00053 00054 #define av_bswap32 av_bswap32 00055 static av_always_inline av_const uint32_t av_bswap32(uint32_t x) 00056 { 00057 #if HAVE_ARMV6 00058 __asm__("rev %0, %0" : "+r"(x)); 00059 #else 00060 uint32_t t; 00061 __asm__ ("eor %1, %0, %0, ror #16 \n\t" 00062 "bic %1, %1, #0xFF0000 \n\t" 00063 "mov %0, %0, ror #8 \n\t" 00064 "eor %0, %0, %1, lsr #8 \n\t" 00065 : "+r"(x), "=&r"(t)); 00066 #endif /* HAVE_ARMV6 */ 00067 return x; 00068 } 00069 00070 #endif /* __ARMCC_VERSION */ 00071 00072 #endif /* AVUTIL_ARM_BSWAP_H */