| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
#ifndef ARCH_H |
| 36 |
#define ARCH_H |
| 37 |
|
| 38 |
#ifndef OUTSIDE_SPEEX |
| 39 |
#include "speex/speexdsp_types.h" |
| 40 |
#endif |
| 41 |
|
| 42 |
#define ABS(x) ((x) < 0 ? (-(x)) : (x)) |
| 43 |
#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) |
| 44 |
#define MIN16(a,b) ((a) < (b) ? (a) : (b)) |
| 45 |
#define MAX16(a,b) ((a) > (b) ? (a) : (b)) |
| 46 |
#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) |
| 47 |
#define MIN32(a,b) ((a) < (b) ? (a) : (b)) |
| 48 |
#define MAX32(a,b) ((a) > (b) ? (a) : (b)) |
| 49 |
|
| 50 |
#ifdef FIXED_POINT |
| 51 |
|
| 52 |
typedef spx_int16_t spx_word16_t; |
| 53 |
typedef spx_int32_t spx_word32_t; |
| 54 |
typedef spx_word32_t spx_mem_t; |
| 55 |
typedef spx_word16_t spx_coef_t; |
| 56 |
typedef spx_word16_t spx_lsp_t; |
| 57 |
typedef spx_word32_t spx_sig_t; |
| 58 |
|
| 59 |
#define Q15ONE 32767 |
| 60 |
|
| 61 |
#define LPC_SCALING 8192 |
| 62 |
#define SIG_SCALING 16384 |
| 63 |
#define LSP_SCALING 8192. |
| 64 |
#define GAMMA_SCALING 32768. |
| 65 |
#define GAIN_SCALING 64 |
| 66 |
#define GAIN_SCALING_1 0.015625 |
| 67 |
|
| 68 |
#define LPC_SHIFT 13 |
| 69 |
#define LSP_SHIFT 13 |
| 70 |
#define SIG_SHIFT 14 |
| 71 |
|
| 72 |
#define VERY_SMALL 0 |
| 73 |
#define VERY_LARGE32 ((spx_word32_t)2147483647) |
| 74 |
#define VERY_LARGE16 ((spx_word16_t)32767) |
| 75 |
#define Q15_ONE ((spx_word16_t)32767) |
| 76 |
|
| 77 |
|
| 78 |
#ifdef FIXED_DEBUG |
| 79 |
#include "fixed_debug.h" |
| 80 |
#else |
| 81 |
|
| 82 |
#include "fixed_generic.h" |
| 83 |
|
| 84 |
#ifdef ARM5E_ASM |
| 85 |
#include "fixed_arm5e.h" |
| 86 |
#elif defined (ARM4_ASM) |
| 87 |
#include "fixed_arm4.h" |
| 88 |
#elif defined (ARM5E_ASM) |
| 89 |
#include "fixed_arm5e.h" |
| 90 |
#elif defined (BFIN_ASM) |
| 91 |
#include "fixed_bfin.h" |
| 92 |
#endif |
| 93 |
|
| 94 |
#endif |
| 95 |
|
| 96 |
|
| 97 |
#else |
| 98 |
|
| 99 |
typedef float spx_mem_t; |
| 100 |
typedef float spx_coef_t; |
| 101 |
typedef float spx_lsp_t; |
| 102 |
typedef float spx_sig_t; |
| 103 |
typedef float spx_word16_t; |
| 104 |
typedef float spx_word32_t; |
| 105 |
|
| 106 |
#define Q15ONE 1.0f |
| 107 |
#define LPC_SCALING 1.f |
| 108 |
#define SIG_SCALING 1.f |
| 109 |
#define LSP_SCALING 1.f |
| 110 |
#define GAMMA_SCALING 1.f |
| 111 |
#define GAIN_SCALING 1.f |
| 112 |
#define GAIN_SCALING_1 1.f |
| 113 |
|
| 114 |
#define LPC_SHIFT 0 |
| 115 |
#define LSP_SHIFT 0 |
| 116 |
#define SIG_SHIFT 0 |
| 117 |
|
| 118 |
#define VERY_SMALL 1e-15f |
| 119 |
#define VERY_LARGE32 1e15f |
| 120 |
#define VERY_LARGE16 1e15f |
| 121 |
#define Q15_ONE ((spx_word16_t)1.f) |
| 122 |
|
| 123 |
#define QCONST16(x,bits) (x) |
| 124 |
#define QCONST32(x,bits) (x) |
| 125 |
|
| 126 |
#define NEG16(x) (-(x)) |
| 127 |
#define NEG32(x) (-(x)) |
| 128 |
#define EXTRACT16(x) (x) |
| 129 |
#define EXTEND32(x) (x) |
| 130 |
#define SHR16(a,shift) (a) |
| 131 |
#define SHL16(a,shift) (a) |
| 132 |
#define SHR32(a,shift) (a) |
| 133 |
#define SHL32(a,shift) (a) |
| 134 |
#define PSHR16(a,shift) (a) |
| 135 |
#define PSHR32(a,shift) (a) |
| 136 |
#define VSHR32(a,shift) (a) |
| 137 |
#define SATURATE16(x,a) (x) |
| 138 |
#define SATURATE32(x,a) (x) |
| 139 |
|
| 140 |
#define PSHR(a,shift) (a) |
| 141 |
#define SHR(a,shift) (a) |
| 142 |
#define SHL(a,shift) (a) |
| 143 |
#define SATURATE(x,a) (x) |
| 144 |
|
| 145 |
#define ADD16(a,b) ((a)+(b)) |
| 146 |
#define SUB16(a,b) ((a)-(b)) |
| 147 |
#define ADD32(a,b) ((a)+(b)) |
| 148 |
#define SUB32(a,b) ((a)-(b)) |
| 149 |
#define MULT16_16_16(a,b) ((a)*(b)) |
| 150 |
#define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b)) |
| 151 |
#define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b)) |
| 152 |
|
| 153 |
#define MULT16_32_Q11(a,b) ((a)*(b)) |
| 154 |
#define MULT16_32_Q13(a,b) ((a)*(b)) |
| 155 |
#define MULT16_32_Q14(a,b) ((a)*(b)) |
| 156 |
#define MULT16_32_Q15(a,b) ((a)*(b)) |
| 157 |
#define MULT16_32_P15(a,b) ((a)*(b)) |
| 158 |
|
| 159 |
#define MAC16_32_Q11(c,a,b) ((c)+(a)*(b)) |
| 160 |
#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) |
| 161 |
|
| 162 |
#define MAC16_16_Q11(c,a,b) ((c)+(a)*(b)) |
| 163 |
#define MAC16_16_Q13(c,a,b) ((c)+(a)*(b)) |
| 164 |
#define MAC16_16_P13(c,a,b) ((c)+(a)*(b)) |
| 165 |
#define MULT16_16_Q11_32(a,b) ((a)*(b)) |
| 166 |
#define MULT16_16_Q13(a,b) ((a)*(b)) |
| 167 |
#define MULT16_16_Q14(a,b) ((a)*(b)) |
| 168 |
#define MULT16_16_Q15(a,b) ((a)*(b)) |
| 169 |
#define MULT16_16_P15(a,b) ((a)*(b)) |
| 170 |
#define MULT16_16_P13(a,b) ((a)*(b)) |
| 171 |
#define MULT16_16_P14(a,b) ((a)*(b)) |
| 172 |
|
| 173 |
#define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) |
| 174 |
#define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) |
| 175 |
#define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) |
| 176 |
#define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) |
| 177 |
|
| 178 |
|
| 179 |
#endif |
| 180 |
|
| 181 |
|
| 182 |
#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) |
| 183 |
|
| 184 |
|
| 185 |
#define BYTES_PER_CHAR 2 |
| 186 |
#define BITS_PER_CHAR 16 |
| 187 |
#define LOG2_BITS_PER_CHAR 4 |
| 188 |
|
| 189 |
#else |
| 190 |
|
| 191 |
#define BYTES_PER_CHAR 1 |
| 192 |
#define BITS_PER_CHAR 8 |
| 193 |
#define LOG2_BITS_PER_CHAR 3 |
| 194 |
|
| 195 |
#endif |
| 196 |
|
| 197 |
#endif |