• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/avr32/mathops.h

Go to the documentation of this file.
00001 /*
00002  * Simple math operations
00003  * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00022 #ifndef AVCODEC_AVR32_MATHOPS_H
00023 #define AVCODEC_AVR32_MATHOPS_H
00024 
00025 #include <stdint.h>
00026 #include "config.h"
00027 #include "libavutil/common.h"
00028 
00029 #if HAVE_INLINE_ASM
00030 
00031 #define MULL MULL
00032 static inline av_const int MULL(int a, int b, unsigned shift)
00033 {
00034     union { int64_t x; int hl[2]; } x;
00035     __asm__ ("muls.d %0, %1, %2       \n\t"
00036              "lsr    %0, %3           \n\t"
00037              "or     %0, %0, %m0<<%4  \n\t"
00038              : "=r"(x) : "r"(b), "r"(a), "i"(shift), "i"(32-shift));
00039     return x.hl[1];
00040 }
00041 
00042 #define MULH MULH
00043 static inline av_const int MULH(int a, int b)
00044 {
00045     union { int64_t x; int hl[2]; } x;
00046     __asm__ ("muls.d %0, %1, %2" : "=r"(x.x) : "r"(a), "r"(b));
00047     return x.hl[0];
00048 }
00049 
00050 #define MUL64 MUL64
00051 static inline av_const int64_t MUL64(int a, int b)
00052 {
00053     int64_t x;
00054     __asm__ ("muls.d %0, %1, %2" : "=r"(x) : "r"(a), "r"(b));
00055     return x;
00056 }
00057 
00058 static inline av_const int64_t MAC64(int64_t d, int a, int b)
00059 {
00060     __asm__ ("macs.d %0, %1, %2" : "+r"(d) : "r"(a), "r"(b));
00061     return d;
00062 }
00063 #define MAC64(d, a, b) ((d) = MAC64(d, a, b))
00064 #define MLS64(d, a, b) MAC64(d, -(a), b)
00065 
00066 static inline av_const int MAC16(int d, int a, int b)
00067 {
00068     __asm__ ("machh.w %0, %1:b, %2:b" : "+r"(d) : "r"(a), "r"(b));
00069     return d;
00070 }
00071 #define MAC16(d, a, b) ((d) = MAC16(d, a, b))
00072 #define MLS16(d, a, b) MAC16(d, -(a), b)
00073 
00074 #define MUL16 MUL16
00075 static inline av_const int MUL16(int a, int b)
00076 {
00077     int d;
00078     __asm__ ("mulhh.w %0, %1:b, %2:b" : "=r"(d) : "r"(a), "r"(b));
00079     return d;
00080 }
00081 
00082 #define mid_pred mid_pred
00083 static inline av_const int mid_pred(int a, int b, int c)
00084 {
00085     int m;
00086     __asm__ ("mov   %0, %2  \n\t"
00087              "cp.w  %1, %2  \n\t"
00088              "movgt %0, %1  \n\t"
00089              "movgt %1, %2  \n\t"
00090              "cp.w  %1, %3  \n\t"
00091              "movle %1, %3  \n\t"
00092              "cp.w  %0, %1  \n\t"
00093              "movgt %0, %1  \n\t"
00094              : "=&r"(m), "+r"(a)
00095              : "r"(b), "r"(c));
00096     return m;
00097 }
00098 
00099 #endif /* HAVE_INLINE_ASM */
00100 
00101 #endif /* AVCODEC_AVR32_MATHOPS_H */

Generated on Fri Sep 16 2011 17:17:34 for FFmpeg by  doxygen 1.7.1