ex
Fork of mbed-os-example-mbed5-blinky by
DuerOS-Light-SDK-v1.1.0/duer-os-light/external/speex/libspeex/arch.h@47:9e361da97763, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:54:45 2017 +0800
- Revision:
- 47:9e361da97763
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 47:9e361da97763 | 1 | /* Copyright (C) 2003 Jean-Marc Valin */ |
| TMBOY | 47:9e361da97763 | 2 | /** |
| TMBOY | 47:9e361da97763 | 3 | @file arch.h |
| TMBOY | 47:9e361da97763 | 4 | @brief Various architecture definitions Speex |
| TMBOY | 47:9e361da97763 | 5 | */ |
| TMBOY | 47:9e361da97763 | 6 | /* |
| TMBOY | 47:9e361da97763 | 7 | Redistribution and use in source and binary forms, with or without |
| TMBOY | 47:9e361da97763 | 8 | modification, are permitted provided that the following conditions |
| TMBOY | 47:9e361da97763 | 9 | are met: |
| TMBOY | 47:9e361da97763 | 10 | |
| TMBOY | 47:9e361da97763 | 11 | - Redistributions of source code must retain the above copyright |
| TMBOY | 47:9e361da97763 | 12 | notice, this list of conditions and the following disclaimer. |
| TMBOY | 47:9e361da97763 | 13 | |
| TMBOY | 47:9e361da97763 | 14 | - Redistributions in binary form must reproduce the above copyright |
| TMBOY | 47:9e361da97763 | 15 | notice, this list of conditions and the following disclaimer in the |
| TMBOY | 47:9e361da97763 | 16 | documentation and/or other materials provided with the distribution. |
| TMBOY | 47:9e361da97763 | 17 | |
| TMBOY | 47:9e361da97763 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its |
| TMBOY | 47:9e361da97763 | 19 | contributors may be used to endorse or promote products derived from |
| TMBOY | 47:9e361da97763 | 20 | this software without specific prior written permission. |
| TMBOY | 47:9e361da97763 | 21 | |
| TMBOY | 47:9e361da97763 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| TMBOY | 47:9e361da97763 | 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| TMBOY | 47:9e361da97763 | 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| TMBOY | 47:9e361da97763 | 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR |
| TMBOY | 47:9e361da97763 | 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| TMBOY | 47:9e361da97763 | 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| TMBOY | 47:9e361da97763 | 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| TMBOY | 47:9e361da97763 | 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| TMBOY | 47:9e361da97763 | 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| TMBOY | 47:9e361da97763 | 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| TMBOY | 47:9e361da97763 | 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| TMBOY | 47:9e361da97763 | 33 | */ |
| TMBOY | 47:9e361da97763 | 34 | |
| TMBOY | 47:9e361da97763 | 35 | #ifndef ARCH_H |
| TMBOY | 47:9e361da97763 | 36 | #define ARCH_H |
| TMBOY | 47:9e361da97763 | 37 | |
| TMBOY | 47:9e361da97763 | 38 | #ifndef OUTSIDE_SPEEX |
| TMBOY | 47:9e361da97763 | 39 | #include "speex/speex_types.h" |
| TMBOY | 47:9e361da97763 | 40 | #endif |
| TMBOY | 47:9e361da97763 | 41 | |
| TMBOY | 47:9e361da97763 | 42 | #define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */ |
| TMBOY | 47:9e361da97763 | 43 | #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */ |
| TMBOY | 47:9e361da97763 | 44 | #define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */ |
| TMBOY | 47:9e361da97763 | 45 | #define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ |
| TMBOY | 47:9e361da97763 | 46 | #define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */ |
| TMBOY | 47:9e361da97763 | 47 | #define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 32-bit value. */ |
| TMBOY | 47:9e361da97763 | 48 | #define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ |
| TMBOY | 47:9e361da97763 | 49 | |
| TMBOY | 47:9e361da97763 | 50 | #ifdef FIXED_POINT |
| TMBOY | 47:9e361da97763 | 51 | |
| TMBOY | 47:9e361da97763 | 52 | typedef spx_int16_t spx_word16_t; |
| TMBOY | 47:9e361da97763 | 53 | typedef spx_int32_t spx_word32_t; |
| TMBOY | 47:9e361da97763 | 54 | typedef spx_word32_t spx_mem_t; |
| TMBOY | 47:9e361da97763 | 55 | typedef spx_word16_t spx_coef_t; |
| TMBOY | 47:9e361da97763 | 56 | typedef spx_word16_t spx_lsp_t; |
| TMBOY | 47:9e361da97763 | 57 | typedef spx_word32_t spx_sig_t; |
| TMBOY | 47:9e361da97763 | 58 | |
| TMBOY | 47:9e361da97763 | 59 | #define Q15ONE 32767 |
| TMBOY | 47:9e361da97763 | 60 | |
| TMBOY | 47:9e361da97763 | 61 | #define LPC_SCALING 8192 |
| TMBOY | 47:9e361da97763 | 62 | #define SIG_SCALING 16384 |
| TMBOY | 47:9e361da97763 | 63 | #define LSP_SCALING 8192. |
| TMBOY | 47:9e361da97763 | 64 | #define GAMMA_SCALING 32768. |
| TMBOY | 47:9e361da97763 | 65 | #define GAIN_SCALING 64 |
| TMBOY | 47:9e361da97763 | 66 | #define GAIN_SCALING_1 0.015625 |
| TMBOY | 47:9e361da97763 | 67 | |
| TMBOY | 47:9e361da97763 | 68 | #define LPC_SHIFT 13 |
| TMBOY | 47:9e361da97763 | 69 | #define LSP_SHIFT 13 |
| TMBOY | 47:9e361da97763 | 70 | #define SIG_SHIFT 14 |
| TMBOY | 47:9e361da97763 | 71 | |
| TMBOY | 47:9e361da97763 | 72 | #define VERY_SMALL 0 |
| TMBOY | 47:9e361da97763 | 73 | #define VERY_LARGE32 ((spx_word32_t)2147483647) |
| TMBOY | 47:9e361da97763 | 74 | #define VERY_LARGE16 ((spx_word16_t)32767) |
| TMBOY | 47:9e361da97763 | 75 | #define Q15_ONE ((spx_word16_t)32767) |
| TMBOY | 47:9e361da97763 | 76 | |
| TMBOY | 47:9e361da97763 | 77 | |
| TMBOY | 47:9e361da97763 | 78 | #ifdef FIXED_DEBUG |
| TMBOY | 47:9e361da97763 | 79 | #include "fixed_debug.h" |
| TMBOY | 47:9e361da97763 | 80 | #else |
| TMBOY | 47:9e361da97763 | 81 | |
| TMBOY | 47:9e361da97763 | 82 | #include "fixed_generic.h" |
| TMBOY | 47:9e361da97763 | 83 | |
| TMBOY | 47:9e361da97763 | 84 | #ifdef ARM5E_ASM |
| TMBOY | 47:9e361da97763 | 85 | #include "fixed_arm5e.h" |
| TMBOY | 47:9e361da97763 | 86 | #elif defined (ARM4_ASM) |
| TMBOY | 47:9e361da97763 | 87 | #include "fixed_arm4.h" |
| TMBOY | 47:9e361da97763 | 88 | #elif defined (ARM5E_ASM) |
| TMBOY | 47:9e361da97763 | 89 | #include "fixed_arm5e.h" |
| TMBOY | 47:9e361da97763 | 90 | #elif defined (BFIN_ASM) |
| TMBOY | 47:9e361da97763 | 91 | #include "fixed_bfin.h" |
| TMBOY | 47:9e361da97763 | 92 | #endif |
| TMBOY | 47:9e361da97763 | 93 | |
| TMBOY | 47:9e361da97763 | 94 | #endif |
| TMBOY | 47:9e361da97763 | 95 | |
| TMBOY | 47:9e361da97763 | 96 | |
| TMBOY | 47:9e361da97763 | 97 | #else |
| TMBOY | 47:9e361da97763 | 98 | |
| TMBOY | 47:9e361da97763 | 99 | typedef float spx_mem_t; |
| TMBOY | 47:9e361da97763 | 100 | typedef float spx_coef_t; |
| TMBOY | 47:9e361da97763 | 101 | typedef float spx_lsp_t; |
| TMBOY | 47:9e361da97763 | 102 | typedef float spx_sig_t; |
| TMBOY | 47:9e361da97763 | 103 | typedef float spx_word16_t; |
| TMBOY | 47:9e361da97763 | 104 | typedef float spx_word32_t; |
| TMBOY | 47:9e361da97763 | 105 | |
| TMBOY | 47:9e361da97763 | 106 | #define Q15ONE 1.0f |
| TMBOY | 47:9e361da97763 | 107 | #define LPC_SCALING 1.f |
| TMBOY | 47:9e361da97763 | 108 | #define SIG_SCALING 1.f |
| TMBOY | 47:9e361da97763 | 109 | #define LSP_SCALING 1.f |
| TMBOY | 47:9e361da97763 | 110 | #define GAMMA_SCALING 1.f |
| TMBOY | 47:9e361da97763 | 111 | #define GAIN_SCALING 1.f |
| TMBOY | 47:9e361da97763 | 112 | #define GAIN_SCALING_1 1.f |
| TMBOY | 47:9e361da97763 | 113 | |
| TMBOY | 47:9e361da97763 | 114 | #define LPC_SHIFT 0 |
| TMBOY | 47:9e361da97763 | 115 | #define LSP_SHIFT 0 |
| TMBOY | 47:9e361da97763 | 116 | #define SIG_SHIFT 0 |
| TMBOY | 47:9e361da97763 | 117 | |
| TMBOY | 47:9e361da97763 | 118 | #define VERY_SMALL 1e-15f |
| TMBOY | 47:9e361da97763 | 119 | #define VERY_LARGE32 1e15f |
| TMBOY | 47:9e361da97763 | 120 | #define VERY_LARGE16 1e15f |
| TMBOY | 47:9e361da97763 | 121 | #define Q15_ONE ((spx_word16_t)1.f) |
| TMBOY | 47:9e361da97763 | 122 | |
| TMBOY | 47:9e361da97763 | 123 | #define QCONST16(x,bits) (x) |
| TMBOY | 47:9e361da97763 | 124 | #define QCONST32(x,bits) (x) |
| TMBOY | 47:9e361da97763 | 125 | |
| TMBOY | 47:9e361da97763 | 126 | #define NEG16(x) (-(x)) |
| TMBOY | 47:9e361da97763 | 127 | #define NEG32(x) (-(x)) |
| TMBOY | 47:9e361da97763 | 128 | #define EXTRACT16(x) (x) |
| TMBOY | 47:9e361da97763 | 129 | #define EXTEND32(x) (x) |
| TMBOY | 47:9e361da97763 | 130 | #define SHR16(a,shift) (a) |
| TMBOY | 47:9e361da97763 | 131 | #define SHL16(a,shift) (a) |
| TMBOY | 47:9e361da97763 | 132 | #define SHR32(a,shift) (a) |
| TMBOY | 47:9e361da97763 | 133 | #define SHL32(a,shift) (a) |
| TMBOY | 47:9e361da97763 | 134 | #define PSHR16(a,shift) (a) |
| TMBOY | 47:9e361da97763 | 135 | #define PSHR32(a,shift) (a) |
| TMBOY | 47:9e361da97763 | 136 | #define VSHR32(a,shift) (a) |
| TMBOY | 47:9e361da97763 | 137 | #define SATURATE16(x,a) (x) |
| TMBOY | 47:9e361da97763 | 138 | #define SATURATE32(x,a) (x) |
| TMBOY | 47:9e361da97763 | 139 | |
| TMBOY | 47:9e361da97763 | 140 | #define PSHR(a,shift) (a) |
| TMBOY | 47:9e361da97763 | 141 | #define SHR(a,shift) (a) |
| TMBOY | 47:9e361da97763 | 142 | #define SHL(a,shift) (a) |
| TMBOY | 47:9e361da97763 | 143 | #define SATURATE(x,a) (x) |
| TMBOY | 47:9e361da97763 | 144 | |
| TMBOY | 47:9e361da97763 | 145 | #define ADD16(a,b) ((a)+(b)) |
| TMBOY | 47:9e361da97763 | 146 | #define SUB16(a,b) ((a)-(b)) |
| TMBOY | 47:9e361da97763 | 147 | #define ADD32(a,b) ((a)+(b)) |
| TMBOY | 47:9e361da97763 | 148 | #define SUB32(a,b) ((a)-(b)) |
| TMBOY | 47:9e361da97763 | 149 | #define MULT16_16_16(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 150 | #define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b)) |
| TMBOY | 47:9e361da97763 | 151 | #define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b)) |
| TMBOY | 47:9e361da97763 | 152 | |
| TMBOY | 47:9e361da97763 | 153 | #define MULT16_32_Q11(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 154 | #define MULT16_32_Q13(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 155 | #define MULT16_32_Q14(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 156 | #define MULT16_32_Q15(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 157 | #define MULT16_32_P15(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 158 | |
| TMBOY | 47:9e361da97763 | 159 | #define MAC16_32_Q11(c,a,b) ((c)+(a)*(b)) |
| TMBOY | 47:9e361da97763 | 160 | #define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) |
| TMBOY | 47:9e361da97763 | 161 | |
| TMBOY | 47:9e361da97763 | 162 | #define MAC16_16_Q11(c,a,b) ((c)+(a)*(b)) |
| TMBOY | 47:9e361da97763 | 163 | #define MAC16_16_Q13(c,a,b) ((c)+(a)*(b)) |
| TMBOY | 47:9e361da97763 | 164 | #define MAC16_16_P13(c,a,b) ((c)+(a)*(b)) |
| TMBOY | 47:9e361da97763 | 165 | #define MULT16_16_Q11_32(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 166 | #define MULT16_16_Q13(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 167 | #define MULT16_16_Q14(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 168 | #define MULT16_16_Q15(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 169 | #define MULT16_16_P15(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 170 | #define MULT16_16_P13(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 171 | #define MULT16_16_P14(a,b) ((a)*(b)) |
| TMBOY | 47:9e361da97763 | 172 | |
| TMBOY | 47:9e361da97763 | 173 | #define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) |
| TMBOY | 47:9e361da97763 | 174 | #define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) |
| TMBOY | 47:9e361da97763 | 175 | #define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) |
| TMBOY | 47:9e361da97763 | 176 | #define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) |
| TMBOY | 47:9e361da97763 | 177 | |
| TMBOY | 47:9e361da97763 | 178 | |
| TMBOY | 47:9e361da97763 | 179 | #endif |
| TMBOY | 47:9e361da97763 | 180 | |
| TMBOY | 47:9e361da97763 | 181 | |
| TMBOY | 47:9e361da97763 | 182 | #if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) |
| TMBOY | 47:9e361da97763 | 183 | |
| TMBOY | 47:9e361da97763 | 184 | /* 2 on TI C5x DSP */ |
| TMBOY | 47:9e361da97763 | 185 | #define BYTES_PER_CHAR 2 |
| TMBOY | 47:9e361da97763 | 186 | #define BITS_PER_CHAR 16 |
| TMBOY | 47:9e361da97763 | 187 | #define LOG2_BITS_PER_CHAR 4 |
| TMBOY | 47:9e361da97763 | 188 | |
| TMBOY | 47:9e361da97763 | 189 | #else |
| TMBOY | 47:9e361da97763 | 190 | |
| TMBOY | 47:9e361da97763 | 191 | #define BYTES_PER_CHAR 1 |
| TMBOY | 47:9e361da97763 | 192 | #define BITS_PER_CHAR 8 |
| TMBOY | 47:9e361da97763 | 193 | #define LOG2_BITS_PER_CHAR 3 |
| TMBOY | 47:9e361da97763 | 194 | |
| TMBOY | 47:9e361da97763 | 195 | #endif |
| TMBOY | 47:9e361da97763 | 196 | |
| TMBOY | 47:9e361da97763 | 197 | #endif |
