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

libavutil/arm/intmath.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010 Mans Rullgard <mans@mansr.com>
00003  *
00004  * This file is part of Libav.
00005  *
00006  * Libav is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * Libav is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with Libav; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 
00021 #ifndef AVUTIL_ARM_INTMATH_H
00022 #define AVUTIL_ARM_INTMATH_H
00023 
00024 #include <stdint.h>
00025 
00026 #include "config.h"
00027 #include "libavutil/attributes.h"
00028 
00029 #if HAVE_INLINE_ASM
00030 
00031 #if HAVE_ARMV6
00032 
00033 #define FASTDIV FASTDIV
00034 static av_always_inline av_const int FASTDIV(int a, int b)
00035 {
00036     int r;
00037     __asm__ ("cmp     %2, #2               \n\t"
00038              "ldr     %0, [%3, %2, lsl #2] \n\t"
00039              "ite     le                   \n\t"
00040              "lsrle   %0, %1, #1           \n\t"
00041              "smmulgt %0, %0, %1           \n\t"
00042              : "=&r"(r) : "r"(a), "r"(b), "r"(ff_inverse) : "cc");
00043     return r;
00044 }
00045 
00046 #define av_clip_uint8 av_clip_uint8_arm
00047 static av_always_inline av_const uint8_t av_clip_uint8_arm(int a)
00048 {
00049     unsigned x;
00050     __asm__ ("usat %0, #8,  %1" : "=r"(x) : "r"(a));
00051     return x;
00052 }
00053 
00054 #define av_clip_int8 av_clip_int8_arm
00055 static av_always_inline av_const uint8_t av_clip_int8_arm(int a)
00056 {
00057     unsigned x;
00058     __asm__ ("ssat %0, #8,  %1" : "=r"(x) : "r"(a));
00059     return x;
00060 }
00061 
00062 #define av_clip_uint16 av_clip_uint16_arm
00063 static av_always_inline av_const uint16_t av_clip_uint16_arm(int a)
00064 {
00065     unsigned x;
00066     __asm__ ("usat %0, #16, %1" : "=r"(x) : "r"(a));
00067     return x;
00068 }
00069 
00070 #define av_clip_int16 av_clip_int16_arm
00071 static av_always_inline av_const int16_t av_clip_int16_arm(int a)
00072 {
00073     int x;
00074     __asm__ ("ssat %0, #16, %1" : "=r"(x) : "r"(a));
00075     return x;
00076 }
00077 
00078 #define av_clip_uintp2 av_clip_uintp2_arm
00079 static av_always_inline av_const unsigned av_clip_uintp2_arm(int a, int p)
00080 {
00081     unsigned x;
00082     __asm__ ("usat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p));
00083     return x;
00084 }
00085 
00086 
00087 #else /* HAVE_ARMV6 */
00088 
00089 #define FASTDIV FASTDIV
00090 static av_always_inline av_const int FASTDIV(int a, int b)
00091 {
00092     int r, t;
00093     __asm__ ("umull %1, %0, %2, %3"
00094              : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b]));
00095     return r;
00096 }
00097 
00098 #endif /* HAVE_ARMV6 */
00099 
00100 #define av_clipl_int32 av_clipl_int32_arm
00101 static av_always_inline av_const int32_t av_clipl_int32_arm(int64_t a)
00102 {
00103     int x, y;
00104     __asm__ ("adds   %1, %R2, %Q2, lsr #31  \n\t"
00105              "itet   ne                     \n\t"
00106              "mvnne  %1, #1<<31             \n\t"
00107              "moveq  %0, %Q2                \n\t"
00108              "eorne  %0, %1,  %R2, asr #31  \n\t"
00109              : "=r"(x), "=&r"(y) : "r"(a));
00110     return x;
00111 }
00112 
00113 #endif /* HAVE_INLINE_ASM */
00114 
00115 #endif /* AVUTIL_ARM_INTMATH_H */
Generated on Sun Apr 22 2012 21:54:09 for Libav by doxygen 1.7.1