yading@11: /* yading@11: * Copyright (c) 2010 Mans Rullgard yading@11: * yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * FFmpeg is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with FFmpeg; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: #ifndef AVUTIL_ARM_INTMATH_H yading@11: #define AVUTIL_ARM_INTMATH_H yading@11: yading@11: #include yading@11: yading@11: #include "config.h" yading@11: #include "libavutil/attributes.h" yading@11: yading@11: #if HAVE_INLINE_ASM yading@11: yading@11: #if HAVE_ARMV6_INLINE yading@11: yading@11: #define av_clip_uint8 av_clip_uint8_arm yading@11: static av_always_inline av_const unsigned av_clip_uint8_arm(int a) yading@11: { yading@11: unsigned x; yading@11: __asm__ ("usat %0, #8, %1" : "=r"(x) : "r"(a)); yading@11: return x; yading@11: } yading@11: yading@11: #define av_clip_int8 av_clip_int8_arm yading@11: static av_always_inline av_const int av_clip_int8_arm(int a) yading@11: { yading@11: int x; yading@11: __asm__ ("ssat %0, #8, %1" : "=r"(x) : "r"(a)); yading@11: return x; yading@11: } yading@11: yading@11: #define av_clip_uint16 av_clip_uint16_arm yading@11: static av_always_inline av_const unsigned av_clip_uint16_arm(int a) yading@11: { yading@11: unsigned x; yading@11: __asm__ ("usat %0, #16, %1" : "=r"(x) : "r"(a)); yading@11: return x; yading@11: } yading@11: yading@11: #define av_clip_int16 av_clip_int16_arm yading@11: static av_always_inline av_const int av_clip_int16_arm(int a) yading@11: { yading@11: int x; yading@11: __asm__ ("ssat %0, #16, %1" : "=r"(x) : "r"(a)); yading@11: return x; yading@11: } yading@11: yading@11: #define av_clip_uintp2 av_clip_uintp2_arm yading@11: static av_always_inline av_const unsigned av_clip_uintp2_arm(int a, int p) yading@11: { yading@11: unsigned x; yading@11: __asm__ ("usat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p)); yading@11: return x; yading@11: } yading@11: yading@11: #define av_sat_add32 av_sat_add32_arm yading@11: static av_always_inline int av_sat_add32_arm(int a, int b) yading@11: { yading@11: int r; yading@11: __asm__ ("qadd %0, %1, %2" : "=r"(r) : "r"(a), "r"(b)); yading@11: return r; yading@11: } yading@11: yading@11: #define av_sat_dadd32 av_sat_dadd32_arm yading@11: static av_always_inline int av_sat_dadd32_arm(int a, int b) yading@11: { yading@11: int r; yading@11: __asm__ ("qdadd %0, %1, %2" : "=r"(r) : "r"(a), "r"(b)); yading@11: return r; yading@11: } yading@11: yading@11: #endif /* HAVE_ARMV6_INLINE */ yading@11: yading@11: #if HAVE_ASM_MOD_Q yading@11: yading@11: #define av_clipl_int32 av_clipl_int32_arm yading@11: static av_always_inline av_const int32_t av_clipl_int32_arm(int64_t a) yading@11: { yading@11: int x, y; yading@11: __asm__ ("adds %1, %R2, %Q2, lsr #31 \n\t" yading@11: "itet ne \n\t" yading@11: "mvnne %1, #1<<31 \n\t" yading@11: "moveq %0, %Q2 \n\t" yading@11: "eorne %0, %1, %R2, asr #31 \n\t" yading@11: : "=r"(x), "=&r"(y) : "r"(a) : "cc"); yading@11: return x; yading@11: } yading@11: yading@11: #endif /* HAVE_ASM_MOD_Q */ yading@11: yading@11: #endif /* HAVE_INLINE_ASM */ yading@11: yading@11: #endif /* AVUTIL_ARM_INTMATH_H */