1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libopus/celt/arm/fixed_armv5e.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,116 @@ 1.4 +/* Copyright (C) 2007-2009 Xiph.Org Foundation 1.5 + Copyright (C) 2003-2008 Jean-Marc Valin 1.6 + Copyright (C) 2007-2008 CSIRO 1.7 + Copyright (C) 2013 Parrot */ 1.8 +/* 1.9 + Redistribution and use in source and binary forms, with or without 1.10 + modification, are permitted provided that the following conditions 1.11 + are met: 1.12 + 1.13 + - Redistributions of source code must retain the above copyright 1.14 + notice, this list of conditions and the following disclaimer. 1.15 + 1.16 + - Redistributions in binary form must reproduce the above copyright 1.17 + notice, this list of conditions and the following disclaimer in the 1.18 + documentation and/or other materials provided with the distribution. 1.19 + 1.20 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.21 + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.22 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.23 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 1.24 + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1.25 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1.26 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1.27 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 1.28 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 1.29 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 1.30 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.31 +*/ 1.32 + 1.33 +#ifndef FIXED_ARMv5E_H 1.34 +#define FIXED_ARMv5E_H 1.35 + 1.36 +#include "fixed_armv4.h" 1.37 + 1.38 +/** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ 1.39 +#undef MULT16_32_Q16 1.40 +static OPUS_INLINE opus_val32 MULT16_32_Q16_armv5e(opus_val16 a, opus_val32 b) 1.41 +{ 1.42 + int res; 1.43 + __asm__( 1.44 + "#MULT16_32_Q16\n\t" 1.45 + "smulwb %0, %1, %2\n\t" 1.46 + : "=r"(res) 1.47 + : "r"(b),"r"(a) 1.48 + ); 1.49 + return res; 1.50 +} 1.51 +#define MULT16_32_Q16(a, b) (MULT16_32_Q16_armv5e(a, b)) 1.52 + 1.53 + 1.54 +/** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ 1.55 +#undef MULT16_32_Q15 1.56 +static OPUS_INLINE opus_val32 MULT16_32_Q15_armv5e(opus_val16 a, opus_val32 b) 1.57 +{ 1.58 + int res; 1.59 + __asm__( 1.60 + "#MULT16_32_Q15\n\t" 1.61 + "smulwb %0, %1, %2\n\t" 1.62 + : "=r"(res) 1.63 + : "r"(b), "r"(a) 1.64 + ); 1.65 + return res<<1; 1.66 +} 1.67 +#define MULT16_32_Q15(a, b) (MULT16_32_Q15_armv5e(a, b)) 1.68 + 1.69 + 1.70 +/** 16x32 multiply, followed by a 15-bit shift right and 32-bit add. 1.71 + b must fit in 31 bits. 1.72 + Result fits in 32 bits. */ 1.73 +#undef MAC16_32_Q15 1.74 +static OPUS_INLINE opus_val32 MAC16_32_Q15_armv5e(opus_val32 c, opus_val16 a, 1.75 + opus_val32 b) 1.76 +{ 1.77 + int res; 1.78 + __asm__( 1.79 + "#MAC16_32_Q15\n\t" 1.80 + "smlawb %0, %1, %2, %3;\n" 1.81 + : "=r"(res) 1.82 + : "r"(b<<1), "r"(a), "r"(c) 1.83 + ); 1.84 + return res; 1.85 +} 1.86 +#define MAC16_32_Q15(c, a, b) (MAC16_32_Q15_armv5e(c, a, b)) 1.87 + 1.88 +/** 16x16 multiply-add where the result fits in 32 bits */ 1.89 +#undef MAC16_16 1.90 +static OPUS_INLINE opus_val32 MAC16_16_armv5e(opus_val32 c, opus_val16 a, 1.91 + opus_val16 b) 1.92 +{ 1.93 + int res; 1.94 + __asm__( 1.95 + "#MAC16_16\n\t" 1.96 + "smlabb %0, %1, %2, %3;\n" 1.97 + : "=r"(res) 1.98 + : "r"(a), "r"(b), "r"(c) 1.99 + ); 1.100 + return res; 1.101 +} 1.102 +#define MAC16_16(c, a, b) (MAC16_16_armv5e(c, a, b)) 1.103 + 1.104 +/** 16x16 multiplication where the result fits in 32 bits */ 1.105 +#undef MULT16_16 1.106 +static OPUS_INLINE opus_val32 MULT16_16_armv5e(opus_val16 a, opus_val16 b) 1.107 +{ 1.108 + int res; 1.109 + __asm__( 1.110 + "#MULT16_16\n\t" 1.111 + "smulbb %0, %1, %2;\n" 1.112 + : "=r"(res) 1.113 + : "r"(a), "r"(b) 1.114 + ); 1.115 + return res; 1.116 +} 1.117 +#define MULT16_16(a, b) (MULT16_16_armv5e(a, b)) 1.118 + 1.119 +#endif