Path: blob/a-new-beginning/libavcodec.xcframework/ios-arm64/libavcodec.framework/Headers/arm/mathops.h
2 views
/*1* simple math operations2* Copyright (c) 2006 Michael Niedermayer <[email protected]> et al3*4* This file is part of FFmpeg.5*6* FFmpeg is free software; you can redistribute it and/or7* modify it under the terms of the GNU Lesser General Public8* License as published by the Free Software Foundation; either9* version 2.1 of the License, or (at your option) any later version.10*11* FFmpeg is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU14* Lesser General Public License for more details.15*16* You should have received a copy of the GNU Lesser General Public17* License along with FFmpeg; if not, write to the Free Software18* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA19*/2021#ifndef AVCODEC_ARM_MATHOPS_H22#define AVCODEC_ARM_MATHOPS_H2324#include <stdint.h>25#include "config.h"26#include "libavutil/common.h"2728#if HAVE_INLINE_ASM2930#if HAVE_ARMV6_INLINE31#define MULH MULH32static inline av_const int MULH(int a, int b)33{34int r;35__asm__ ("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));36return r;37}3839#define FASTDIV FASTDIV40static av_always_inline av_const int FASTDIV(int a, int b)41{42int r;43__asm__ ("cmp %2, #2 \n\t"44"ldr %0, [%3, %2, lsl #2] \n\t"45"ite le \n\t"46"lsrle %0, %1, #1 \n\t"47"smmulgt %0, %0, %1 \n\t"48: "=&r"(r) : "r"(a), "r"(b), "r"(ff_inverse) : "cc");49return r;50}5152#else /* HAVE_ARMV6_INLINE */5354#define FASTDIV FASTDIV55static av_always_inline av_const int FASTDIV(int a, int b)56{57int r, t;58__asm__ ("umull %1, %0, %2, %3"59: "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b]));60return r;61}62#endif6364#define MLS64(d, a, b) MAC64(d, -(a), b)6566#if HAVE_ARMV5TE_INLINE6768/* signed 16x16 -> 32 multiply add accumulate */69# define MAC16(rt, ra, rb) \70__asm__ ("smlabb %0, %1, %2, %0" : "+r"(rt) : "r"(ra), "r"(rb));7172/* signed 16x16 -> 32 multiply */73# define MUL16 MUL1674static inline av_const int MUL16(int ra, int rb)75{76int rt;77__asm__ ("smulbb %0, %1, %2" : "=r"(rt) : "r"(ra), "r"(rb));78return rt;79}8081#endif8283#define mid_pred mid_pred84static inline av_const int mid_pred(int a, int b, int c)85{86int m;87__asm__ (88"mov %0, %2 \n\t"89"cmp %1, %2 \n\t"90"itt gt \n\t"91"movgt %0, %1 \n\t"92"movgt %1, %2 \n\t"93"cmp %1, %3 \n\t"94"it le \n\t"95"movle %1, %3 \n\t"96"cmp %0, %1 \n\t"97"it gt \n\t"98"movgt %0, %1 \n\t"99: "=&r"(m), "+r"(a)100: "r"(b), "r"(c)101: "cc");102return m;103}104105#endif /* HAVE_INLINE_ASM */106107#endif /* AVCODEC_ARM_MATHOPS_H */108109110