diff libavcodec/mathops.h @ 2:897f711a7157

rearrange to work with autoconf
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Tue, 25 Sep 2012 15:55:33 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libavcodec/mathops.h	Tue Sep 25 15:55:33 2012 +0200
     1.3 @@ -0,0 +1,145 @@
     1.4 +/*
     1.5 + * simple math operations
     1.6 + * Copyright (c) 2001, 2002 Fabrice Bellard
     1.7 + * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al
     1.8 + *
     1.9 + * This file is part of FFmpeg.
    1.10 + *
    1.11 + * FFmpeg is free software; you can redistribute it and/or
    1.12 + * modify it under the terms of the GNU Lesser General Public
    1.13 + * License as published by the Free Software Foundation; either
    1.14 + * version 2.1 of the License, or (at your option) any later version.
    1.15 + *
    1.16 + * FFmpeg is distributed in the hope that it will be useful,
    1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.19 + * Lesser General Public License for more details.
    1.20 + *
    1.21 + * You should have received a copy of the GNU Lesser General Public
    1.22 + * License along with FFmpeg; if not, write to the Free Software
    1.23 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    1.24 + */
    1.25 +#ifndef AVCODEC_MATHOPS_H
    1.26 +#define AVCODEC_MATHOPS_H
    1.27 +
    1.28 +#include "libavutil/common.h"
    1.29 +#include "libavutil/internal.h"
    1.30 +
    1.31 +#if   ARCH_ARM
    1.32 +#   include "arm/mathops.h"
    1.33 +#elif ARCH_PPC
    1.34 +#   include "ppc/mathops.h"
    1.35 +#elif ARCH_X86
    1.36 +#   include "x86/mathops.h"
    1.37 +#endif
    1.38 +
    1.39 +/* generic implementation */
    1.40 +
    1.41 +#ifndef MULL
    1.42 +#   define MULL(a,b,s) (((int64_t)(a) * (int64_t)(b)) >> (s))
    1.43 +#endif
    1.44 +
    1.45 +#ifndef MULH
    1.46 +//gcc 3.4 creates an incredibly bloated mess out of this
    1.47 +//#    define MULH(a,b) (((int64_t)(a) * (int64_t)(b))>>32)
    1.48 +
    1.49 +static av_always_inline int MULH(int a, int b){
    1.50 +    return ((int64_t)(a) * (int64_t)(b))>>32;
    1.51 +}
    1.52 +#endif
    1.53 +
    1.54 +#ifndef UMULH
    1.55 +static av_always_inline unsigned UMULH(unsigned a, unsigned b){
    1.56 +    return ((uint64_t)(a) * (uint64_t)(b))>>32;
    1.57 +}
    1.58 +#endif
    1.59 +
    1.60 +#ifndef MUL64
    1.61 +#   define MUL64(a,b) ((int64_t)(a) * (int64_t)(b))
    1.62 +#endif
    1.63 +
    1.64 +#ifndef MAC64
    1.65 +#   define MAC64(d, a, b) ((d) += MUL64(a, b))
    1.66 +#endif
    1.67 +
    1.68 +#ifndef MLS64
    1.69 +#   define MLS64(d, a, b) ((d) -= MUL64(a, b))
    1.70 +#endif
    1.71 +
    1.72 +/* signed 16x16 -> 32 multiply add accumulate */
    1.73 +#ifndef MAC16
    1.74 +#   define MAC16(rt, ra, rb) rt += (ra) * (rb)
    1.75 +#endif
    1.76 +
    1.77 +/* signed 16x16 -> 32 multiply */
    1.78 +#ifndef MUL16
    1.79 +#   define MUL16(ra, rb) ((ra) * (rb))
    1.80 +#endif
    1.81 +
    1.82 +#ifndef MLS16
    1.83 +#   define MLS16(rt, ra, rb) ((rt) -= (ra) * (rb))
    1.84 +#endif
    1.85 +
    1.86 +/* median of 3 */
    1.87 +#ifndef mid_pred
    1.88 +#define mid_pred mid_pred
    1.89 +static inline av_const int mid_pred(int a, int b, int c)
    1.90 +{
    1.91 +#if 0
    1.92 +    int t= (a-b)&((a-b)>>31);
    1.93 +    a-=t;
    1.94 +    b+=t;
    1.95 +    b-= (b-c)&((b-c)>>31);
    1.96 +    b+= (a-b)&((a-b)>>31);
    1.97 +
    1.98 +    return b;
    1.99 +#else
   1.100 +    if(a>b){
   1.101 +        if(c>b){
   1.102 +            if(c>a) b=a;
   1.103 +            else    b=c;
   1.104 +        }
   1.105 +    }else{
   1.106 +        if(b>c){
   1.107 +            if(c>a) b=c;
   1.108 +            else    b=a;
   1.109 +        }
   1.110 +    }
   1.111 +    return b;
   1.112 +#endif
   1.113 +}
   1.114 +#endif
   1.115 +
   1.116 +#ifndef sign_extend
   1.117 +static inline av_const int sign_extend(int val, unsigned bits)
   1.118 +{
   1.119 +    return (val << (INT_BIT - bits)) >> (INT_BIT - bits);
   1.120 +}
   1.121 +#endif
   1.122 +
   1.123 +#ifndef zero_extend
   1.124 +static inline av_const unsigned zero_extend(unsigned val, unsigned bits)
   1.125 +{
   1.126 +    return (val << (INT_BIT - bits)) >> (INT_BIT - bits);
   1.127 +}
   1.128 +#endif
   1.129 +
   1.130 +#ifndef COPY3_IF_LT
   1.131 +#define COPY3_IF_LT(x, y, a, b, c, d)\
   1.132 +if ((y) < (x)) {\
   1.133 +    (x) = (y);\
   1.134 +    (a) = (b);\
   1.135 +    (c) = (d);\
   1.136 +}
   1.137 +#endif
   1.138 +
   1.139 +#ifndef NEG_SSR32
   1.140 +#   define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
   1.141 +#endif
   1.142 +
   1.143 +#ifndef NEG_USR32
   1.144 +#   define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
   1.145 +#endif
   1.146 +
   1.147 +#endif /* AVCODEC_MATHOPS_H */
   1.148 +