• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/arm/mathops.h

Go to the documentation of this file.
00001 /*
00002  * simple math operations
00003  * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00022 #ifndef AVCODEC_ARM_MATHOPS_H
00023 #define AVCODEC_ARM_MATHOPS_H
00024 
00025 #include <stdint.h>
00026 #include "libavutil/common.h"
00027 
00028 #   define MULL MULL
00029 static inline av_const int MULL(int a, int b, unsigned shift)
00030 {
00031     int lo, hi;
00032     __asm__("smull %0, %1, %2, %3     \n\t"
00033             "mov   %0, %0,     lsr %4 \n\t"
00034             "add   %1, %0, %1, lsl %5 \n\t"
00035             : "=&r"(lo), "=&r"(hi)
00036             : "r"(b), "r"(a), "ir"(shift), "ir"(32-shift));
00037     return hi;
00038 }
00039 
00040 #define MULH MULH
00041 #if HAVE_ARMV6
00042 static inline av_const int MULH(int a, int b)
00043 {
00044     int r;
00045     __asm__ ("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
00046     return r;
00047 }
00048 #else
00049 static inline av_const int MULH(int a, int b)
00050 {
00051     int lo, hi;
00052     __asm__ ("smull %0, %1, %2, %3" : "=&r"(lo), "=&r"(hi) : "r"(b), "r"(a));
00053     return hi;
00054 }
00055 #endif
00056 
00057 static inline av_const int64_t MUL64(int a, int b)
00058 {
00059     union { uint64_t x; unsigned hl[2]; } x;
00060     __asm__ ("smull %0, %1, %2, %3"
00061              : "=r"(x.hl[0]), "=r"(x.hl[1]) : "r"(a), "r"(b));
00062     return x.x;
00063 }
00064 #define MUL64 MUL64
00065 
00066 static inline av_const int64_t MAC64(int64_t d, int a, int b)
00067 {
00068     union { uint64_t x; unsigned hl[2]; } x = { d };
00069     __asm__ ("smlal %0, %1, %2, %3"
00070              : "+r"(x.hl[0]), "+r"(x.hl[1]) : "r"(a), "r"(b));
00071     return x.x;
00072 }
00073 #define MAC64(d, a, b) ((d) = MAC64(d, a, b))
00074 #define MLS64(d, a, b) MAC64(d, -(a), b)
00075 
00076 #if HAVE_ARMV5TE
00077 
00078 /* signed 16x16 -> 32 multiply add accumulate */
00079 #   define MAC16(rt, ra, rb)                                            \
00080     __asm__ ("smlabb %0, %1, %2, %0" : "+r"(rt) : "r"(ra), "r"(rb));
00081 
00082 /* signed 16x16 -> 32 multiply */
00083 #   define MUL16 MUL16
00084 static inline av_const int MUL16(int ra, int rb)
00085 {
00086     int rt;
00087     __asm__ ("smulbb %0, %1, %2" : "=r"(rt) : "r"(ra), "r"(rb));
00088     return rt;
00089 }
00090 
00091 #endif
00092 
00093 #define mid_pred mid_pred
00094 static inline av_const int mid_pred(int a, int b, int c)
00095 {
00096     int m;
00097     __asm__ volatile (
00098         "mov   %0, %2  \n\t"
00099         "cmp   %1, %2  \n\t"
00100         "movgt %0, %1  \n\t"
00101         "movgt %1, %2  \n\t"
00102         "cmp   %1, %3  \n\t"
00103         "movle %1, %3  \n\t"
00104         "cmp   %0, %1  \n\t"
00105         "movgt %0, %1  \n\t"
00106         : "=&r"(m), "+r"(a)
00107         : "r"(b), "r"(c));
00108     return m;
00109 }
00110 
00111 #endif /* AVCODEC_ARM_MATHOPS_H */

Generated on Tue Nov 4 2014 12:59:21 for ffmpeg by  doxygen 1.7.1