annotate src/opus-1.3/celt/arm/fixed_armv5e.h @ 81:7029a4916348

Merge build update
author Chris Cannam
date Thu, 31 Oct 2019 13:36:58 +0000
parents 7aeed7906520
children
rev   line source
Chris@69 1 /* Copyright (C) 2007-2009 Xiph.Org Foundation
Chris@69 2 Copyright (C) 2003-2008 Jean-Marc Valin
Chris@69 3 Copyright (C) 2007-2008 CSIRO
Chris@69 4 Copyright (C) 2013 Parrot */
Chris@69 5 /*
Chris@69 6 Redistribution and use in source and binary forms, with or without
Chris@69 7 modification, are permitted provided that the following conditions
Chris@69 8 are met:
Chris@69 9
Chris@69 10 - Redistributions of source code must retain the above copyright
Chris@69 11 notice, this list of conditions and the following disclaimer.
Chris@69 12
Chris@69 13 - Redistributions in binary form must reproduce the above copyright
Chris@69 14 notice, this list of conditions and the following disclaimer in the
Chris@69 15 documentation and/or other materials provided with the distribution.
Chris@69 16
Chris@69 17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Chris@69 18 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Chris@69 19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Chris@69 20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
Chris@69 21 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Chris@69 22 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Chris@69 23 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Chris@69 24 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Chris@69 25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Chris@69 26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Chris@69 27 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Chris@69 28 */
Chris@69 29
Chris@69 30 #ifndef FIXED_ARMv5E_H
Chris@69 31 #define FIXED_ARMv5E_H
Chris@69 32
Chris@69 33 #include "fixed_armv4.h"
Chris@69 34
Chris@69 35 /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */
Chris@69 36 #undef MULT16_32_Q16
Chris@69 37 static OPUS_INLINE opus_val32 MULT16_32_Q16_armv5e(opus_val16 a, opus_val32 b)
Chris@69 38 {
Chris@69 39 int res;
Chris@69 40 __asm__(
Chris@69 41 "#MULT16_32_Q16\n\t"
Chris@69 42 "smulwb %0, %1, %2\n\t"
Chris@69 43 : "=r"(res)
Chris@69 44 : "r"(b),"r"(a)
Chris@69 45 );
Chris@69 46 return res;
Chris@69 47 }
Chris@69 48 #define MULT16_32_Q16(a, b) (MULT16_32_Q16_armv5e(a, b))
Chris@69 49
Chris@69 50
Chris@69 51 /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */
Chris@69 52 #undef MULT16_32_Q15
Chris@69 53 static OPUS_INLINE opus_val32 MULT16_32_Q15_armv5e(opus_val16 a, opus_val32 b)
Chris@69 54 {
Chris@69 55 int res;
Chris@69 56 __asm__(
Chris@69 57 "#MULT16_32_Q15\n\t"
Chris@69 58 "smulwb %0, %1, %2\n\t"
Chris@69 59 : "=r"(res)
Chris@69 60 : "r"(b), "r"(a)
Chris@69 61 );
Chris@69 62 return SHL32(res,1);
Chris@69 63 }
Chris@69 64 #define MULT16_32_Q15(a, b) (MULT16_32_Q15_armv5e(a, b))
Chris@69 65
Chris@69 66
Chris@69 67 /** 16x32 multiply, followed by a 15-bit shift right and 32-bit add.
Chris@69 68 b must fit in 31 bits.
Chris@69 69 Result fits in 32 bits. */
Chris@69 70 #undef MAC16_32_Q15
Chris@69 71 static OPUS_INLINE opus_val32 MAC16_32_Q15_armv5e(opus_val32 c, opus_val16 a,
Chris@69 72 opus_val32 b)
Chris@69 73 {
Chris@69 74 int res;
Chris@69 75 __asm__(
Chris@69 76 "#MAC16_32_Q15\n\t"
Chris@69 77 "smlawb %0, %1, %2, %3;\n"
Chris@69 78 : "=r"(res)
Chris@69 79 : "r"(SHL32(b,1)), "r"(a), "r"(c)
Chris@69 80 );
Chris@69 81 return res;
Chris@69 82 }
Chris@69 83 #define MAC16_32_Q15(c, a, b) (MAC16_32_Q15_armv5e(c, a, b))
Chris@69 84
Chris@69 85 /** 16x32 multiply, followed by a 16-bit shift right and 32-bit add.
Chris@69 86 Result fits in 32 bits. */
Chris@69 87 #undef MAC16_32_Q16
Chris@69 88 static OPUS_INLINE opus_val32 MAC16_32_Q16_armv5e(opus_val32 c, opus_val16 a,
Chris@69 89 opus_val32 b)
Chris@69 90 {
Chris@69 91 int res;
Chris@69 92 __asm__(
Chris@69 93 "#MAC16_32_Q16\n\t"
Chris@69 94 "smlawb %0, %1, %2, %3;\n"
Chris@69 95 : "=r"(res)
Chris@69 96 : "r"(b), "r"(a), "r"(c)
Chris@69 97 );
Chris@69 98 return res;
Chris@69 99 }
Chris@69 100 #define MAC16_32_Q16(c, a, b) (MAC16_32_Q16_armv5e(c, a, b))
Chris@69 101
Chris@69 102 /** 16x16 multiply-add where the result fits in 32 bits */
Chris@69 103 #undef MAC16_16
Chris@69 104 static OPUS_INLINE opus_val32 MAC16_16_armv5e(opus_val32 c, opus_val16 a,
Chris@69 105 opus_val16 b)
Chris@69 106 {
Chris@69 107 int res;
Chris@69 108 __asm__(
Chris@69 109 "#MAC16_16\n\t"
Chris@69 110 "smlabb %0, %1, %2, %3;\n"
Chris@69 111 : "=r"(res)
Chris@69 112 : "r"(a), "r"(b), "r"(c)
Chris@69 113 );
Chris@69 114 return res;
Chris@69 115 }
Chris@69 116 #define MAC16_16(c, a, b) (MAC16_16_armv5e(c, a, b))
Chris@69 117
Chris@69 118 /** 16x16 multiplication where the result fits in 32 bits */
Chris@69 119 #undef MULT16_16
Chris@69 120 static OPUS_INLINE opus_val32 MULT16_16_armv5e(opus_val16 a, opus_val16 b)
Chris@69 121 {
Chris@69 122 int res;
Chris@69 123 __asm__(
Chris@69 124 "#MULT16_16\n\t"
Chris@69 125 "smulbb %0, %1, %2;\n"
Chris@69 126 : "=r"(res)
Chris@69 127 : "r"(a), "r"(b)
Chris@69 128 );
Chris@69 129 return res;
Chris@69 130 }
Chris@69 131 #define MULT16_16(a, b) (MULT16_16_armv5e(a, b))
Chris@69 132
Chris@69 133 #ifdef OPUS_ARM_INLINE_MEDIA
Chris@69 134
Chris@69 135 #undef SIG2WORD16
Chris@69 136 static OPUS_INLINE opus_val16 SIG2WORD16_armv6(opus_val32 x)
Chris@69 137 {
Chris@69 138 celt_sig res;
Chris@69 139 __asm__(
Chris@69 140 "#SIG2WORD16\n\t"
Chris@69 141 "ssat %0, #16, %1, ASR #12\n\t"
Chris@69 142 : "=r"(res)
Chris@69 143 : "r"(x+2048)
Chris@69 144 );
Chris@69 145 return EXTRACT16(res);
Chris@69 146 }
Chris@69 147 #define SIG2WORD16(x) (SIG2WORD16_armv6(x))
Chris@69 148
Chris@69 149 #endif /* OPUS_ARM_INLINE_MEDIA */
Chris@69 150
Chris@69 151 #endif