annotate libavcodec/arm/mathops.h @ 3:0b056460c67d

changed code to use VSs
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Mon, 29 Oct 2012 16:44:27 +0100
parents
children
rev   line source
nengel@2 1 /*
nengel@2 2 * simple math operations
nengel@2 3 * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al
nengel@2 4 *
nengel@2 5 * This file is part of FFmpeg.
nengel@2 6 *
nengel@2 7 * FFmpeg is free software; you can redistribute it and/or
nengel@2 8 * modify it under the terms of the GNU Lesser General Public
nengel@2 9 * License as published by the Free Software Foundation; either
nengel@2 10 * version 2.1 of the License, or (at your option) any later version.
nengel@2 11 *
nengel@2 12 * FFmpeg is distributed in the hope that it will be useful,
nengel@2 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nengel@2 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
nengel@2 15 * Lesser General Public License for more details.
nengel@2 16 *
nengel@2 17 * You should have received a copy of the GNU Lesser General Public
nengel@2 18 * License along with FFmpeg; if not, write to the Free Software
nengel@2 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
nengel@2 20 */
nengel@2 21
nengel@2 22 #ifndef AVCODEC_ARM_MATHOPS_H
nengel@2 23 #define AVCODEC_ARM_MATHOPS_H
nengel@2 24
nengel@2 25 #include <stdint.h>
nengel@2 26 #include "config.h"
nengel@2 27 #include "libavutil/common.h"
nengel@2 28
nengel@2 29 #if HAVE_INLINE_ASM
nengel@2 30
nengel@2 31 # define MULL MULL
nengel@2 32 static inline av_const int MULL(int a, int b, unsigned shift)
nengel@2 33 {
nengel@2 34 int lo, hi;
nengel@2 35 __asm__("smull %0, %1, %2, %3 \n\t"
nengel@2 36 "mov %0, %0, lsr %4 \n\t"
nengel@2 37 "add %1, %0, %1, lsl %5 \n\t"
nengel@2 38 : "=&r"(lo), "=&r"(hi)
nengel@2 39 : "r"(b), "r"(a), "ir"(shift), "ir"(32-shift));
nengel@2 40 return hi;
nengel@2 41 }
nengel@2 42
nengel@2 43 #define MULH MULH
nengel@2 44 #if HAVE_ARMV6
nengel@2 45 static inline av_const int MULH(int a, int b)
nengel@2 46 {
nengel@2 47 int r;
nengel@2 48 __asm__ ("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
nengel@2 49 return r;
nengel@2 50 }
nengel@2 51 #else
nengel@2 52 static inline av_const int MULH(int a, int b)
nengel@2 53 {
nengel@2 54 int lo, hi;
nengel@2 55 __asm__ ("smull %0, %1, %2, %3" : "=&r"(lo), "=&r"(hi) : "r"(b), "r"(a));
nengel@2 56 return hi;
nengel@2 57 }
nengel@2 58 #endif
nengel@2 59
nengel@2 60 static inline av_const int64_t MUL64(int a, int b)
nengel@2 61 {
nengel@2 62 union { uint64_t x; unsigned hl[2]; } x;
nengel@2 63 __asm__ ("smull %0, %1, %2, %3"
nengel@2 64 : "=r"(x.hl[0]), "=r"(x.hl[1]) : "r"(a), "r"(b));
nengel@2 65 return x.x;
nengel@2 66 }
nengel@2 67 #define MUL64 MUL64
nengel@2 68
nengel@2 69 static inline av_const int64_t MAC64(int64_t d, int a, int b)
nengel@2 70 {
nengel@2 71 union { uint64_t x; unsigned hl[2]; } x = { d };
nengel@2 72 __asm__ ("smlal %0, %1, %2, %3"
nengel@2 73 : "+r"(x.hl[0]), "+r"(x.hl[1]) : "r"(a), "r"(b));
nengel@2 74 return x.x;
nengel@2 75 }
nengel@2 76 #define MAC64(d, a, b) ((d) = MAC64(d, a, b))
nengel@2 77 #define MLS64(d, a, b) MAC64(d, -(a), b)
nengel@2 78
nengel@2 79 #if HAVE_ARMV5TE
nengel@2 80
nengel@2 81 /* signed 16x16 -> 32 multiply add accumulate */
nengel@2 82 # define MAC16(rt, ra, rb) \
nengel@2 83 __asm__ ("smlabb %0, %1, %2, %0" : "+r"(rt) : "r"(ra), "r"(rb));
nengel@2 84
nengel@2 85 /* signed 16x16 -> 32 multiply */
nengel@2 86 # define MUL16 MUL16
nengel@2 87 static inline av_const int MUL16(int ra, int rb)
nengel@2 88 {
nengel@2 89 int rt;
nengel@2 90 __asm__ ("smulbb %0, %1, %2" : "=r"(rt) : "r"(ra), "r"(rb));
nengel@2 91 return rt;
nengel@2 92 }
nengel@2 93
nengel@2 94 #endif
nengel@2 95
nengel@2 96 #define mid_pred mid_pred
nengel@2 97 static inline av_const int mid_pred(int a, int b, int c)
nengel@2 98 {
nengel@2 99 int m;
nengel@2 100 __asm__ volatile (
nengel@2 101 "mov %0, %2 \n\t"
nengel@2 102 "cmp %1, %2 \n\t"
nengel@2 103 "movgt %0, %1 \n\t"
nengel@2 104 "movgt %1, %2 \n\t"
nengel@2 105 "cmp %1, %3 \n\t"
nengel@2 106 "movle %1, %3 \n\t"
nengel@2 107 "cmp %0, %1 \n\t"
nengel@2 108 "movgt %0, %1 \n\t"
nengel@2 109 : "=&r"(m), "+r"(a)
nengel@2 110 : "r"(b), "r"(c));
nengel@2 111 return m;
nengel@2 112 }
nengel@2 113
nengel@2 114 #endif /* HAVE_INLINE_ASM */
nengel@2 115
nengel@2 116 #endif /* AVCODEC_ARM_MATHOPS_H */