nengel@2: /* nengel@2: * simple math operations nengel@2: * Copyright (c) 2006 Michael Niedermayer et al nengel@2: * nengel@2: * This file is part of FFmpeg. nengel@2: * nengel@2: * FFmpeg is free software; you can redistribute it and/or nengel@2: * modify it under the terms of the GNU Lesser General Public nengel@2: * License as published by the Free Software Foundation; either nengel@2: * version 2.1 of the License, or (at your option) any later version. nengel@2: * nengel@2: * FFmpeg is distributed in the hope that it will be useful, nengel@2: * but WITHOUT ANY WARRANTY; without even the implied warranty of nengel@2: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU nengel@2: * Lesser General Public License for more details. nengel@2: * nengel@2: * You should have received a copy of the GNU Lesser General Public nengel@2: * License along with FFmpeg; if not, write to the Free Software nengel@2: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA nengel@2: */ nengel@2: nengel@2: #ifndef AVCODEC_X86_MATHOPS_H nengel@2: #define AVCODEC_X86_MATHOPS_H nengel@2: nengel@2: #include "config.h" nengel@2: #include "libavutil/common.h" nengel@2: nengel@2: #if ARCH_X86_32 nengel@2: #define MULL(ra, rb, shift) \ nengel@2: ({ int rt, dummy; __asm__ (\ nengel@2: "imull %3 \n\t"\ nengel@2: "shrdl %4, %%edx, %%eax \n\t"\ nengel@2: : "=a"(rt), "=d"(dummy)\ nengel@2: : "a" ((int)ra), "rm" ((int)rb), "i"(shift));\ nengel@2: rt; }) nengel@2: nengel@2: #define MULH(ra, rb) \ nengel@2: ({ int rt, dummy;\ nengel@2: __asm__ ("imull %3\n\t" : "=d"(rt), "=a"(dummy): "a" ((int)ra), "rm" ((int)rb));\ nengel@2: rt; }) nengel@2: nengel@2: #define MUL64(ra, rb) \ nengel@2: ({ int64_t rt;\ nengel@2: __asm__ ("imull %2\n\t" : "=A"(rt) : "a" ((int)ra), "g" ((int)rb));\ nengel@2: rt; }) nengel@2: #endif nengel@2: nengel@2: // avoid +32 for shift optimization (gcc should do that ...) nengel@2: #define NEG_SSR32 NEG_SSR32 nengel@2: static inline int32_t NEG_SSR32( int32_t a, int8_t s){ nengel@2: __asm__ ("sarl %1, %0\n\t" nengel@2: : "+r" (a) nengel@2: : "ic" ((uint8_t)(-s)) nengel@2: ); nengel@2: return a; nengel@2: } nengel@2: nengel@2: #define NEG_USR32 NEG_USR32 nengel@2: static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ nengel@2: __asm__ ("shrl %1, %0\n\t" nengel@2: : "+r" (a) nengel@2: : "ic" ((uint8_t)(-s)) nengel@2: ); nengel@2: return a; nengel@2: } nengel@2: nengel@2: #endif /* AVCODEC_X86_MATHOPS_H */