annotate libavcodec/x86/mathops.h @ 6:55fb61482128

VSs working
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Wed, 06 Mar 2013 14:35:39 +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_X86_MATHOPS_H
nengel@2 23 #define AVCODEC_X86_MATHOPS_H
nengel@2 24
nengel@2 25 #include "config.h"
nengel@2 26 #include "libavutil/common.h"
nengel@2 27
nengel@2 28 #if ARCH_X86_32
nengel@2 29 #define MULL(ra, rb, shift) \
nengel@2 30 ({ int rt, dummy; __asm__ (\
nengel@2 31 "imull %3 \n\t"\
nengel@2 32 "shrdl %4, %%edx, %%eax \n\t"\
nengel@2 33 : "=a"(rt), "=d"(dummy)\
nengel@2 34 : "a" ((int)ra), "rm" ((int)rb), "i"(shift));\
nengel@2 35 rt; })
nengel@2 36
nengel@2 37 #define MULH(ra, rb) \
nengel@2 38 ({ int rt, dummy;\
nengel@2 39 __asm__ ("imull %3\n\t" : "=d"(rt), "=a"(dummy): "a" ((int)ra), "rm" ((int)rb));\
nengel@2 40 rt; })
nengel@2 41
nengel@2 42 #define MUL64(ra, rb) \
nengel@2 43 ({ int64_t rt;\
nengel@2 44 __asm__ ("imull %2\n\t" : "=A"(rt) : "a" ((int)ra), "g" ((int)rb));\
nengel@2 45 rt; })
nengel@2 46 #endif
nengel@2 47
nengel@2 48 // avoid +32 for shift optimization (gcc should do that ...)
nengel@2 49 #define NEG_SSR32 NEG_SSR32
nengel@2 50 static inline int32_t NEG_SSR32( int32_t a, int8_t s){
nengel@2 51 __asm__ ("sarl %1, %0\n\t"
nengel@2 52 : "+r" (a)
nengel@2 53 : "ic" ((uint8_t)(-s))
nengel@2 54 );
nengel@2 55 return a;
nengel@2 56 }
nengel@2 57
nengel@2 58 #define NEG_USR32 NEG_USR32
nengel@2 59 static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
nengel@2 60 __asm__ ("shrl %1, %0\n\t"
nengel@2 61 : "+r" (a)
nengel@2 62 : "ic" ((uint8_t)(-s))
nengel@2 63 );
nengel@2 64 return a;
nengel@2 65 }
nengel@2 66
nengel@2 67 #endif /* AVCODEC_X86_MATHOPS_H */