annotate libavcodec/ppc/mathops.h @ 9:ea1ba68cf0ed

update to match api changes + add sscc produced source
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Wed, 05 Jun 2013 14:43:26 +0200
parents
children
rev   line source
nengel@2 1 /*
nengel@2 2 * simple math operations
nengel@2 3 * Copyright (c) 2001, 2002 Fabrice Bellard
nengel@2 4 * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al
nengel@2 5 *
nengel@2 6 * This file is part of FFmpeg.
nengel@2 7 *
nengel@2 8 * FFmpeg is free software; you can redistribute it and/or
nengel@2 9 * modify it under the terms of the GNU Lesser General Public
nengel@2 10 * License as published by the Free Software Foundation; either
nengel@2 11 * version 2.1 of the License, or (at your option) any later version.
nengel@2 12 *
nengel@2 13 * FFmpeg is distributed in the hope that it will be useful,
nengel@2 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nengel@2 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
nengel@2 16 * Lesser General Public License for more details.
nengel@2 17 *
nengel@2 18 * You should have received a copy of the GNU Lesser General Public
nengel@2 19 * License along with FFmpeg; if not, write to the Free Software
nengel@2 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
nengel@2 21 */
nengel@2 22
nengel@2 23 #ifndef AVCODEC_PPC_MATHOPS_H
nengel@2 24 #define AVCODEC_PPC_MATHOPS_H
nengel@2 25
nengel@2 26 #include <stdint.h>
nengel@2 27 #include "config.h"
nengel@2 28 #include "libavutil/common.h"
nengel@2 29
nengel@2 30 #if HAVE_PPC4XX
nengel@2 31 /* signed 16x16 -> 32 multiply add accumulate */
nengel@2 32 #define MAC16(rt, ra, rb) \
nengel@2 33 __asm__ ("maclhw %0, %2, %3" : "=r" (rt) : "0" (rt), "r" (ra), "r" (rb));
nengel@2 34
nengel@2 35 /* signed 16x16 -> 32 multiply */
nengel@2 36 #define MUL16(ra, rb) \
nengel@2 37 ({ int __rt; \
nengel@2 38 __asm__ ("mullhw %0, %1, %2" : "=r" (__rt) : "r" (ra), "r" (rb)); \
nengel@2 39 __rt; })
nengel@2 40 #endif
nengel@2 41
nengel@2 42 #define MULH MULH
nengel@2 43 static inline av_const int MULH(int a, int b){
nengel@2 44 int r;
nengel@2 45 __asm__ ("mulhw %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
nengel@2 46 return r;
nengel@2 47 }
nengel@2 48
nengel@2 49 #if !ARCH_PPC64
nengel@2 50 static inline av_const int64_t MAC64(int64_t d, int a, int b)
nengel@2 51 {
nengel@2 52 union { uint64_t x; unsigned hl[2]; } x = { d };
nengel@2 53 int h, l;
nengel@2 54 __asm__ ("mullw %3, %4, %5 \n\t"
nengel@2 55 "mulhw %2, %4, %5 \n\t"
nengel@2 56 "addc %1, %1, %3 \n\t"
nengel@2 57 "adde %0, %0, %2 \n\t"
nengel@2 58 : "+r"(x.hl[0]), "+r"(x.hl[1]), "=&r"(h), "=&r"(l)
nengel@2 59 : "r"(a), "r"(b));
nengel@2 60 return x.x;
nengel@2 61 }
nengel@2 62 #define MAC64(d, a, b) ((d) = MAC64(d, a, b))
nengel@2 63
nengel@2 64 static inline av_const int64_t MLS64(int64_t d, int a, int b)
nengel@2 65 {
nengel@2 66 union { uint64_t x; unsigned hl[2]; } x = { d };
nengel@2 67 int h, l;
nengel@2 68 __asm__ ("mullw %3, %4, %5 \n\t"
nengel@2 69 "mulhw %2, %4, %5 \n\t"
nengel@2 70 "subfc %1, %3, %1 \n\t"
nengel@2 71 "subfe %0, %2, %0 \n\t"
nengel@2 72 : "+r"(x.hl[0]), "+r"(x.hl[1]), "=&r"(h), "=&r"(l)
nengel@2 73 : "r"(a), "r"(b));
nengel@2 74 return x.x;
nengel@2 75 }
nengel@2 76 #define MLS64(d, a, b) ((d) = MLS64(d, a, b))
nengel@2 77 #endif
nengel@2 78
nengel@2 79 #endif /* AVCODEC_PPC_MATHOPS_H */