nengel@2: /* nengel@2: * This file is part of FFmpeg. nengel@2: * nengel@2: * FFmpeg is free software; you can redistribute it and/or nengel@2: * modify it under the terms of the GNU Lesser General Public nengel@2: * License as published by the Free Software Foundation; either nengel@2: * version 2.1 of the License, or (at your option) any later version. nengel@2: * nengel@2: * FFmpeg is distributed in the hope that it will be useful, nengel@2: * but WITHOUT ANY WARRANTY; without even the implied warranty of nengel@2: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU nengel@2: * Lesser General Public License for more details. nengel@2: * nengel@2: * You should have received a copy of the GNU Lesser General Public nengel@2: * License along with FFmpeg; if not, write to the Free Software nengel@2: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA nengel@2: */ nengel@2: nengel@2: #ifndef AVUTIL_ARM_BSWAP_H nengel@2: #define AVUTIL_ARM_BSWAP_H nengel@2: nengel@2: #include nengel@2: #include "config.h" nengel@2: #include "libavutil/attributes.h" nengel@2: nengel@2: #ifdef __ARMCC_VERSION nengel@2: nengel@2: #if HAVE_ARMV6 nengel@2: #define bswap_16 bswap_16 nengel@2: static av_always_inline av_const unsigned bswap_16(unsigned x) nengel@2: { nengel@2: __asm { rev16 x, x } nengel@2: return x; nengel@2: } nengel@2: nengel@2: #define bswap_32 bswap_32 nengel@2: static av_always_inline av_const uint32_t bswap_32(uint32_t x) nengel@2: { nengel@2: return __rev(x); nengel@2: } nengel@2: #endif /* HAVE_ARMV6 */ nengel@2: nengel@2: #elif HAVE_INLINE_ASM nengel@2: nengel@2: #if HAVE_ARMV6 nengel@2: #define bswap_16 bswap_16 nengel@2: static av_always_inline av_const unsigned bswap_16(unsigned x) nengel@2: { nengel@2: __asm__("rev16 %0, %0" : "+r"(x)); nengel@2: return x; nengel@2: } nengel@2: #endif nengel@2: nengel@2: #define bswap_32 bswap_32 nengel@2: static av_always_inline av_const uint32_t bswap_32(uint32_t x) nengel@2: { nengel@2: #if HAVE_ARMV6 nengel@2: __asm__("rev %0, %0" : "+r"(x)); nengel@2: #else nengel@2: uint32_t t; nengel@2: __asm__ ("eor %1, %0, %0, ror #16 \n\t" nengel@2: "bic %1, %1, #0xFF0000 \n\t" nengel@2: "mov %0, %0, ror #8 \n\t" nengel@2: "eor %0, %0, %1, lsr #8 \n\t" nengel@2: : "+r"(x), "=&r"(t)); nengel@2: #endif /* HAVE_ARMV6 */ nengel@2: return x; nengel@2: } nengel@2: nengel@2: #endif /* __ARMCC_VERSION */ nengel@2: nengel@2: #endif /* AVUTIL_ARM_BSWAP_H */