Path: blob/master/dep/cubeb/subprojects/speex/arch.h
4247 views
/* Copyright (C) 2003 Jean-Marc Valin */1/**2@file arch.h3@brief Various architecture definitions Speex4*/5/*6Redistribution and use in source and binary forms, with or without7modification, are permitted provided that the following conditions8are met:910- Redistributions of source code must retain the above copyright11notice, this list of conditions and the following disclaimer.1213- Redistributions in binary form must reproduce the above copyright14notice, this list of conditions and the following disclaimer in the15documentation and/or other materials provided with the distribution.1617- Neither the name of the Xiph.org Foundation nor the names of its18contributors may be used to endorse or promote products derived from19this software without specific prior written permission.2021THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS22``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT23LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR24A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR25CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,26EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,27PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR28PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF29LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING30NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS31SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.32*/3334#ifndef ARCH_H35#define ARCH_H3637/* A couple test to catch stupid option combinations */38#ifdef FIXED_POINT3940#ifdef FLOATING_POINT41#error You cannot compile as floating point and fixed point at the same time42#endif43#ifdef _USE_SSE44#error SSE is only for floating-point45#endif46#if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM))47#error Make up your mind. What CPU do you have?48#endif49#ifdef VORBIS_PSYCHO50#error Vorbis-psy model currently not implemented in fixed-point51#endif5253#else5455#ifndef FLOATING_POINT56#error You now need to define either FIXED_POINT or FLOATING_POINT57#endif58#if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM)59#error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions?60#endif61#ifdef FIXED_POINT_DEBUG62#error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?"63#endif646566#endif6768#ifndef OUTSIDE_SPEEX69#include "speex/speexdsp_types.h"70#endif7172#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */73#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */74#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */75#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */76#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */77#define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 32-bit value. */78#define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */7980#ifdef FIXED_POINT8182typedef spx_int16_t spx_word16_t;83typedef spx_int32_t spx_word32_t;84typedef spx_word32_t spx_mem_t;85typedef spx_word16_t spx_coef_t;86typedef spx_word16_t spx_lsp_t;87typedef spx_word32_t spx_sig_t;8889#define Q15ONE 327679091#define LPC_SCALING 819292#define SIG_SCALING 1638493#define LSP_SCALING 8192.94#define GAMMA_SCALING 32768.95#define GAIN_SCALING 6496#define GAIN_SCALING_1 0.0156259798#define LPC_SHIFT 1399#define LSP_SHIFT 13100#define SIG_SHIFT 14101#define GAIN_SHIFT 6102103#define WORD2INT(x) ((x) < -32767 ? -32768 : ((x) > 32766 ? 32767 : (x)))104105#define VERY_SMALL 0106#define VERY_LARGE32 ((spx_word32_t)2147483647)107#define VERY_LARGE16 ((spx_word16_t)32767)108#define Q15_ONE ((spx_word16_t)32767)109110111#ifdef FIXED_DEBUG112#include "fixed_debug.h"113#else114115#include "fixed_generic.h"116117#ifdef ARM5E_ASM118#include "fixed_arm5e.h"119#elif defined (ARM4_ASM)120#include "fixed_arm4.h"121#elif defined (BFIN_ASM)122#include "fixed_bfin.h"123#endif124125#endif126127128#else129130typedef float spx_mem_t;131typedef float spx_coef_t;132typedef float spx_lsp_t;133typedef float spx_sig_t;134typedef float spx_word16_t;135typedef float spx_word32_t;136137#define Q15ONE 1.0f138#define LPC_SCALING 1.f139#define SIG_SCALING 1.f140#define LSP_SCALING 1.f141#define GAMMA_SCALING 1.f142#define GAIN_SCALING 1.f143#define GAIN_SCALING_1 1.f144145146#define VERY_SMALL 1e-15f147#define VERY_LARGE32 1e15f148#define VERY_LARGE16 1e15f149#define Q15_ONE ((spx_word16_t)1.f)150151#define QCONST16(x,bits) (x)152#define QCONST32(x,bits) (x)153154#define NEG16(x) (-(x))155#define NEG32(x) (-(x))156#define EXTRACT16(x) (x)157#define EXTEND32(x) (x)158#define SHR16(a,shift) (a)159#define SHL16(a,shift) (a)160#define SHR32(a,shift) (a)161#define SHL32(a,shift) (a)162#define PSHR16(a,shift) (a)163#define PSHR32(a,shift) (a)164#define VSHR32(a,shift) (a)165#define SATURATE16(x,a) (x)166#define SATURATE32(x,a) (x)167#define SATURATE32PSHR(x,shift,a) (x)168169#define PSHR(a,shift) (a)170#define SHR(a,shift) (a)171#define SHL(a,shift) (a)172#define SATURATE(x,a) (x)173174#define ADD16(a,b) ((a)+(b))175#define SUB16(a,b) ((a)-(b))176#define ADD32(a,b) ((a)+(b))177#define SUB32(a,b) ((a)-(b))178#define MULT16_16_16(a,b) ((a)*(b))179#define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b))180#define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b))181182#define MULT16_32_Q11(a,b) ((a)*(b))183#define MULT16_32_Q13(a,b) ((a)*(b))184#define MULT16_32_Q14(a,b) ((a)*(b))185#define MULT16_32_Q15(a,b) ((a)*(b))186#define MULT16_32_P15(a,b) ((a)*(b))187188#define MAC16_32_Q11(c,a,b) ((c)+(a)*(b))189#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b))190191#define MAC16_16_Q11(c,a,b) ((c)+(a)*(b))192#define MAC16_16_Q13(c,a,b) ((c)+(a)*(b))193#define MAC16_16_P13(c,a,b) ((c)+(a)*(b))194#define MULT16_16_Q11_32(a,b) ((a)*(b))195#define MULT16_16_Q13(a,b) ((a)*(b))196#define MULT16_16_Q14(a,b) ((a)*(b))197#define MULT16_16_Q15(a,b) ((a)*(b))198#define MULT16_16_P15(a,b) ((a)*(b))199#define MULT16_16_P13(a,b) ((a)*(b))200#define MULT16_16_P14(a,b) ((a)*(b))201202#define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b))203#define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b))204#define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b))205#define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b))206207#define WORD2INT(x) ((x) < -32767.5f ? -32768 : \208((x) > 32766.5f ? 32767 : (spx_int16_t)floor(.5 + (x))))209#endif210211212#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)213214/* 2 on TI C5x DSP */215#define BYTES_PER_CHAR 2216#define BITS_PER_CHAR 16217#define LOG2_BITS_PER_CHAR 4218219#else220221#define BYTES_PER_CHAR 1222#define BITS_PER_CHAR 8223#define LOG2_BITS_PER_CHAR 3224225#endif226227228229#ifdef FIXED_DEBUG230extern long long spx_mips;231#endif232233234#endif235236237