arch.h

Go to the documentation of this file.
00001 /* Copyright (C) 2003 Jean-Marc Valin */
00006 /*
00007    Redistribution and use in source and binary forms, with or without
00008    modification, are permitted provided that the following conditions
00009    are met:
00010    
00011    - Redistributions of source code must retain the above copyright
00012    notice, this list of conditions and the following disclaimer.
00013    
00014    - Redistributions in binary form must reproduce the above copyright
00015    notice, this list of conditions and the following disclaimer in the
00016    documentation and/or other materials provided with the distribution.
00017    
00018    - Neither the name of the Xiph.org Foundation nor the names of its
00019    contributors may be used to endorse or promote products derived from
00020    this software without specific prior written permission.
00021    
00022    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00025    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
00026    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00027    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00028    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00029    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00030    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00031    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 */
00034 
00035 #ifndef ARCH_H
00036 #define ARCH_H
00037 
00038 #include "speex/speex_types.h"
00039 
00040 #define ABS(x) ((x) < 0 ? (-(x)) : (x))      
00041 #define ABS16(x) ((x) < 0 ? (-(x)) : (x))    
00042 #define MAX16(a,b) ((a) > (b) ? (a) : (b))   
00043 #define ABS32(x) ((x) < 0 ? (-(x)) : (x))    
00045 #ifdef FIXED_POINT
00046 
00047 typedef spx_int16_t spx_word16_t;
00048 typedef spx_int32_t   spx_word32_t;
00049 #ifdef _MSC_VER
00050 typedef __int64      spx_word64_t;
00051 #elif defined NO_LONGLONG
00052 typedef double    spx_word64_t;
00053 #else
00054 typedef long long    spx_word64_t;
00055 #endif
00056 typedef spx_word32_t spx_mem_t;
00057 typedef spx_word16_t spx_coef_t;
00058 typedef spx_word16_t spx_lsp_t;
00059 typedef spx_word32_t spx_sig_t;
00060 
00061 #define Q15ONE 32767
00062 
00063 #define LPC_SCALING  8192
00064 #define SIG_SCALING  16384
00065 #define LSP_SCALING  8192.
00066 #define GAMMA_SCALING 32768.
00067 #define GAIN_SCALING 64
00068 #define GAIN_SCALING_1 0.015625
00069 
00070 #define LPC_SHIFT    13
00071 #define LSP_SHIFT    13
00072 #define SIG_SHIFT    14
00073 
00074 #define VERY_SMALL 0
00075 #define VERY_LARGE32 ((spx_word32_t)2147483647)
00076 #define VERY_LARGE16 ((spx_word16_t)32767)
00077 
00078 
00079 #ifdef FIXED_DEBUG
00080 #include "fixed_debug.h"
00081 #else
00082 
00083 #include "fixed_generic.h"
00084 
00085 #ifdef ARM5E_ASM
00086 #include "fixed_arm5e.h"
00087 #elif defined (ARM4_ASM)
00088 #include "fixed_arm4.h"
00089 #elif defined (ARM5E_ASM)
00090 #include "fixed_arm5e.h"
00091 #elif defined (BFIN_ASM)
00092 #include "fixed_bfin.h"
00093 #endif
00094 
00095 #endif
00096 
00097 
00098 #else
00099 
00100 typedef float spx_mem_t;
00101 typedef float spx_coef_t;
00102 typedef float spx_lsp_t;
00103 typedef float spx_sig_t;
00104 typedef float spx_word16_t;
00105 typedef float spx_word32_t;
00106 typedef float spx_word64_t;
00107 
00108 #define Q15ONE 1.0f
00109 #define LPC_SCALING  1.f
00110 #define SIG_SCALING  1.f
00111 #define LSP_SCALING  1.f
00112 #define GAMMA_SCALING 1.f
00113 #define GAIN_SCALING 1.f
00114 #define GAIN_SCALING_1 1.f
00115 
00116 #define LPC_SHIFT    0
00117 #define LSP_SHIFT    0
00118 #define SIG_SHIFT    0
00119 
00120 #define VERY_SMALL 1e-15f
00121 #define VERY_LARGE32 1e15f
00122 #define VERY_LARGE16 1e15f
00123 
00124 #define QCONST16(x,bits) (x)
00125 #define QCONST32(x,bits) (x)
00126 
00127 #define NEG16(x) (-(x))
00128 #define NEG32(x) (-(x))
00129 #define EXTRACT16(x) (x)
00130 #define EXTEND32(x) (x)
00131 #define SHR16(a,shift) (a)
00132 #define SHL16(a,shift) (a)
00133 #define SHR32(a,shift) (a)
00134 #define SHL32(a,shift) (a)
00135 #define PSHR16(a,shift) (a)
00136 #define PSHR32(a,shift) (a)
00137 #define SATURATE16(x,a) (x)
00138 #define SATURATE32(x,a) (x)
00139 
00140 #define PSHR(a,shift)       (a)
00141 #define SHR(a,shift)       (a)
00142 #define SHL(a,shift)       (a)
00143 #define SATURATE(x,a) (x)
00144 
00145 #define ADD16(a,b) ((a)+(b))
00146 #define SUB16(a,b) ((a)-(b))
00147 #define ADD32(a,b) ((a)+(b))
00148 #define SUB32(a,b) ((a)-(b))
00149 #define ADD64(a,b) ((a)+(b))
00150 #define MULT16_16_16(a,b)     ((a)*(b))
00151 #define MULT16_16(a,b)     ((spx_word32_t)(a)*(spx_word32_t)(b))
00152 #define MAC16_16(c,a,b)     ((c)+(spx_word32_t)(a)*(spx_word32_t)(b))
00153 
00154 #define MULT16_32_Q11(a,b)     ((a)*(b))
00155 #define MULT16_32_Q13(a,b)     ((a)*(b))
00156 #define MULT16_32_Q14(a,b)     ((a)*(b))
00157 #define MULT16_32_Q15(a,b)     ((a)*(b))
00158 
00159 #define MAC16_32_Q11(c,a,b)     ((c)+(a)*(b))
00160 #define MAC16_32_Q15(c,a,b)     ((c)+(a)*(b))
00161 
00162 #define MAC16_16_Q11(c,a,b)     ((c)+(a)*(b))
00163 #define MAC16_16_Q13(c,a,b)     ((c)+(a)*(b))
00164 #define MULT16_16_Q11_32(a,b)     ((a)*(b))
00165 #define MULT16_16_Q13(a,b)     ((a)*(b))
00166 #define MULT16_16_Q14(a,b)     ((a)*(b))
00167 #define MULT16_16_Q15(a,b)     ((a)*(b))
00168 #define MULT16_16_P15(a,b)     ((a)*(b))
00169 
00170 #define DIV32_16(a,b)     ((a)/(b))
00171 #define DIV32(a,b)     ((a)/(b))
00172 
00173 
00174 #endif
00175 
00176 
00177 #ifdef CONFIG_TI_C55X
00178 
00179 /* 2 on TI C5x DSP */
00180 #define BYTES_PER_CHAR 2 
00181 #define BITS_PER_CHAR 16
00182 #define LOG2_BITS_PER_CHAR 4
00183 
00184 #else 
00185 
00186 #define BYTES_PER_CHAR 1
00187 #define BITS_PER_CHAR 8
00188 #define LOG2_BITS_PER_CHAR 3
00189 
00190 #endif
00191 
00192 #endif

Generated on Wed Dec 27 23:21:03 2006 for speex by  doxygen 1.5.1