1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libspeex_resampler/src/arch.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,239 @@ 1.4 +/* Copyright (C) 2003 Jean-Marc Valin */ 1.5 +/** 1.6 + @file arch.h 1.7 + @brief Various architecture definitions Speex 1.8 +*/ 1.9 +/* 1.10 + Redistribution and use in source and binary forms, with or without 1.11 + modification, are permitted provided that the following conditions 1.12 + are met: 1.13 + 1.14 + - Redistributions of source code must retain the above copyright 1.15 + notice, this list of conditions and the following disclaimer. 1.16 + 1.17 + - Redistributions in binary form must reproduce the above copyright 1.18 + notice, this list of conditions and the following disclaimer in the 1.19 + documentation and/or other materials provided with the distribution. 1.20 + 1.21 + - Neither the name of the Xiph.org Foundation nor the names of its 1.22 + contributors may be used to endorse or promote products derived from 1.23 + this software without specific prior written permission. 1.24 + 1.25 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.26 + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.27 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.28 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 1.29 + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1.30 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1.31 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1.32 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 1.33 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 1.34 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 1.35 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.36 +*/ 1.37 + 1.38 +#ifndef ARCH_H 1.39 +#define ARCH_H 1.40 + 1.41 +#ifndef SPEEX_VERSION 1.42 +#define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */ 1.43 +#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */ 1.44 +#define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */ 1.45 +#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */ 1.46 +#define SPEEX_VERSION "speex-1.2beta3" /**< Speex version string. */ 1.47 +#endif 1.48 + 1.49 +/* A couple test to catch stupid option combinations */ 1.50 +#ifdef FIXED_POINT 1.51 + 1.52 +#ifdef FLOATING_POINT 1.53 +#error You cannot compile as floating point and fixed point at the same time 1.54 +#endif 1.55 +#ifdef _USE_SSE 1.56 +#error SSE is only for floating-point 1.57 +#endif 1.58 +#if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM)) 1.59 +#error Make up your mind. What CPU do you have? 1.60 +#endif 1.61 +#ifdef VORBIS_PSYCHO 1.62 +#error Vorbis-psy model currently not implemented in fixed-point 1.63 +#endif 1.64 + 1.65 +#else 1.66 + 1.67 +#ifndef FLOATING_POINT 1.68 +#error You now need to define either FIXED_POINT or FLOATING_POINT 1.69 +#endif 1.70 +#if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM) 1.71 +#error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions? 1.72 +#endif 1.73 +#ifdef FIXED_POINT_DEBUG 1.74 +#error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?" 1.75 +#endif 1.76 + 1.77 + 1.78 +#endif 1.79 + 1.80 +#ifndef OUTSIDE_SPEEX 1.81 +#include "../include/speex/speex_types.h" 1.82 +#endif 1.83 + 1.84 +#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */ 1.85 +#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */ 1.86 +#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */ 1.87 +#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ 1.88 +#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */ 1.89 +#define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 32-bit value. */ 1.90 +#define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ 1.91 + 1.92 +#ifdef FIXED_POINT 1.93 + 1.94 +typedef spx_int16_t spx_word16_t; 1.95 +typedef spx_int32_t spx_word32_t; 1.96 +typedef spx_word32_t spx_mem_t; 1.97 +typedef spx_word16_t spx_coef_t; 1.98 +typedef spx_word16_t spx_lsp_t; 1.99 +typedef spx_word32_t spx_sig_t; 1.100 + 1.101 +#define Q15ONE 32767 1.102 + 1.103 +#define LPC_SCALING 8192 1.104 +#define SIG_SCALING 16384 1.105 +#define LSP_SCALING 8192. 1.106 +#define GAMMA_SCALING 32768. 1.107 +#define GAIN_SCALING 64 1.108 +#define GAIN_SCALING_1 0.015625 1.109 + 1.110 +#define LPC_SHIFT 13 1.111 +#define LSP_SHIFT 13 1.112 +#define SIG_SHIFT 14 1.113 +#define GAIN_SHIFT 6 1.114 + 1.115 +#define VERY_SMALL 0 1.116 +#define VERY_LARGE32 ((spx_word32_t)2147483647) 1.117 +#define VERY_LARGE16 ((spx_word16_t)32767) 1.118 +#define Q15_ONE ((spx_word16_t)32767) 1.119 + 1.120 + 1.121 +#ifdef FIXED_DEBUG 1.122 +#include "fixed_debug.h" 1.123 +#else 1.124 + 1.125 +#include "fixed_generic.h" 1.126 + 1.127 +#ifdef ARM5E_ASM 1.128 +#include "fixed_arm5e.h" 1.129 +#elif defined (ARM4_ASM) 1.130 +#include "fixed_arm4.h" 1.131 +#elif defined (BFIN_ASM) 1.132 +#include "fixed_bfin.h" 1.133 +#endif 1.134 + 1.135 +#endif 1.136 + 1.137 + 1.138 +#else 1.139 + 1.140 +typedef float spx_mem_t; 1.141 +typedef float spx_coef_t; 1.142 +typedef float spx_lsp_t; 1.143 +typedef float spx_sig_t; 1.144 +typedef float spx_word16_t; 1.145 +typedef float spx_word32_t; 1.146 + 1.147 +#define Q15ONE 1.0f 1.148 +#define LPC_SCALING 1.f 1.149 +#define SIG_SCALING 1.f 1.150 +#define LSP_SCALING 1.f 1.151 +#define GAMMA_SCALING 1.f 1.152 +#define GAIN_SCALING 1.f 1.153 +#define GAIN_SCALING_1 1.f 1.154 + 1.155 + 1.156 +#define VERY_SMALL 1e-15f 1.157 +#define VERY_LARGE32 1e15f 1.158 +#define VERY_LARGE16 1e15f 1.159 +#define Q15_ONE ((spx_word16_t)1.f) 1.160 + 1.161 +#define QCONST16(x,bits) (x) 1.162 +#define QCONST32(x,bits) (x) 1.163 + 1.164 +#define NEG16(x) (-(x)) 1.165 +#define NEG32(x) (-(x)) 1.166 +#define EXTRACT16(x) (x) 1.167 +#define EXTEND32(x) (x) 1.168 +#define SHR16(a,shift) (a) 1.169 +#define SHL16(a,shift) (a) 1.170 +#define SHR32(a,shift) (a) 1.171 +#define SHL32(a,shift) (a) 1.172 +#define PSHR16(a,shift) (a) 1.173 +#define PSHR32(a,shift) (a) 1.174 +#define VSHR32(a,shift) (a) 1.175 +#define SATURATE16(x,a) (x) 1.176 +#define SATURATE32(x,a) (x) 1.177 + 1.178 +#define PSHR(a,shift) (a) 1.179 +#define SHR(a,shift) (a) 1.180 +#define SHL(a,shift) (a) 1.181 +#define SATURATE(x,a) (x) 1.182 + 1.183 +#define ADD16(a,b) ((a)+(b)) 1.184 +#define SUB16(a,b) ((a)-(b)) 1.185 +#define ADD32(a,b) ((a)+(b)) 1.186 +#define SUB32(a,b) ((a)-(b)) 1.187 +#define MULT16_16_16(a,b) ((a)*(b)) 1.188 +#define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b)) 1.189 +#define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b)) 1.190 + 1.191 +#define MULT16_32_Q11(a,b) ((a)*(b)) 1.192 +#define MULT16_32_Q13(a,b) ((a)*(b)) 1.193 +#define MULT16_32_Q14(a,b) ((a)*(b)) 1.194 +#define MULT16_32_Q15(a,b) ((a)*(b)) 1.195 +#define MULT16_32_P15(a,b) ((a)*(b)) 1.196 + 1.197 +#define MAC16_32_Q11(c,a,b) ((c)+(a)*(b)) 1.198 +#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) 1.199 + 1.200 +#define MAC16_16_Q11(c,a,b) ((c)+(a)*(b)) 1.201 +#define MAC16_16_Q13(c,a,b) ((c)+(a)*(b)) 1.202 +#define MAC16_16_P13(c,a,b) ((c)+(a)*(b)) 1.203 +#define MULT16_16_Q11_32(a,b) ((a)*(b)) 1.204 +#define MULT16_16_Q13(a,b) ((a)*(b)) 1.205 +#define MULT16_16_Q14(a,b) ((a)*(b)) 1.206 +#define MULT16_16_Q15(a,b) ((a)*(b)) 1.207 +#define MULT16_16_P15(a,b) ((a)*(b)) 1.208 +#define MULT16_16_P13(a,b) ((a)*(b)) 1.209 +#define MULT16_16_P14(a,b) ((a)*(b)) 1.210 + 1.211 +#define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) 1.212 +#define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) 1.213 +#define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) 1.214 +#define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) 1.215 + 1.216 + 1.217 +#endif 1.218 + 1.219 + 1.220 +#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) 1.221 + 1.222 +/* 2 on TI C5x DSP */ 1.223 +#define BYTES_PER_CHAR 2 1.224 +#define BITS_PER_CHAR 16 1.225 +#define LOG2_BITS_PER_CHAR 4 1.226 + 1.227 +#else 1.228 + 1.229 +#define BYTES_PER_CHAR 1 1.230 +#define BITS_PER_CHAR 8 1.231 +#define LOG2_BITS_PER_CHAR 3 1.232 + 1.233 +#endif 1.234 + 1.235 + 1.236 + 1.237 +#ifdef FIXED_DEBUG 1.238 +extern long long spx_mips; 1.239 +#endif 1.240 + 1.241 + 1.242 +#endif