arch.h

Go to the documentation of this file.
00001 /* Copyright (C) 2003 Jean-Marc Valin */
00002 /**
00003    @file arch.h
00004    @brief Various architecture definitions Speex
00005 */
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 #ifndef SPEEX_VERSION
00039 #define SPEEX_MAJOR_VERSION 1         /**< Major Speex version. */
00040 #define SPEEX_MINOR_VERSION 1         /**< Minor Speex version. */
00041 #define SPEEX_MICRO_VERSION 15        /**< Micro Speex version. */
00042 #define SPEEX_EXTRA_VERSION ""        /**< Extra Speex version. */
00043 #define SPEEX_VERSION "speex-1.2beta3"  /**< Speex version string. */
00044 #endif
00045 
00046 #define FIXED_POINT
00047 
00048 /* A couple test to catch stupid option combinations */
00049 #ifdef FIXED_POINT
00050 
00051 #ifdef FLOATING_POINT
00052 #error You cannot compile as floating point and fixed point at the same time
00053 #endif
00054 #ifdef _USE_SSE
00055 #error SSE is only for floating-point
00056 #endif
00057 #if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM))
00058 #error Make up your mind. What CPU do you have?
00059 #endif
00060 #ifdef VORBIS_PSYCHO
00061 #error Vorbis-psy model currently not implemented in fixed-point
00062 #endif
00063 
00064 #else
00065 
00066 #ifndef FLOATING_POINT
00067 #error You now need to define either FIXED_POINT or FLOATING_POINT
00068 #endif
00069 #if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM)
00070 #error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions?
00071 #endif
00072 #ifdef FIXED_POINT_DEBUG
00073 #error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?"
00074 #endif
00075 
00076 
00077 #endif
00078 
00079 #ifndef OUTSIDE_SPEEX
00080 #include "speex/speex_types.h"
00081 #endif
00082 
00083 #define ABS(x) ((x) < 0 ? (-(x)) : (x))      /**< Absolute integer value. */
00084 #define ABS16(x) ((x) < 0 ? (-(x)) : (x))    /**< Absolute 16-bit value.  */
00085 #define MIN16(a,b) ((a) < (b) ? (a) : (b))   /**< Maximum 16-bit value.   */
00086 #define MAX16(a,b) ((a) > (b) ? (a) : (b))   /**< Maximum 16-bit value.   */
00087 #define ABS32(x) ((x) < 0 ? (-(x)) : (x))    /**< Absolute 32-bit value.  */
00088 #define MIN32(a,b) ((a) < (b) ? (a) : (b))   /**< Maximum 32-bit value.   */
00089 #define MAX32(a,b) ((a) > (b) ? (a) : (b))   /**< Maximum 32-bit value.   */
00090 
00091 #ifdef FIXED_POINT
00092 
00093 typedef spx_int16_t spx_word16_t;
00094 typedef spx_int32_t   spx_word32_t;
00095 typedef spx_word32_t spx_mem_t;
00096 typedef spx_word16_t spx_coef_t;
00097 typedef spx_word16_t spx_lsp_t;
00098 typedef spx_word32_t spx_sig_t;
00099 
00100 #define Q15ONE 32767
00101 
00102 #define LPC_SCALING  8192
00103 #define SIG_SCALING  16384
00104 #define LSP_SCALING  8192.
00105 #define GAMMA_SCALING 32768.
00106 #define GAIN_SCALING 64
00107 #define GAIN_SCALING_1 0.015625
00108 
00109 #define LPC_SHIFT    13
00110 #define LSP_SHIFT    13
00111 #define SIG_SHIFT    14
00112 #define GAIN_SHIFT   6
00113 
00114 #define VERY_SMALL 0
00115 #define VERY_LARGE32 ((spx_word32_t)2147483647)
00116 #define VERY_LARGE16 ((spx_word16_t)32767)
00117 #define Q15_ONE ((spx_word16_t)32767)
00118 
00119 
00120 #ifdef FIXED_DEBUG
00121 #include "fixed_debug.h"
00122 #else
00123 
00124 #include "fixed_generic.h"
00125 
00126 #ifdef ARM5E_ASM
00127 #include "fixed_arm5e.h"
00128 #elif defined (ARM4_ASM)
00129 #include "fixed_arm4.h"
00130 #elif defined (BFIN_ASM)
00131 #include "fixed_bfin.h"
00132 #endif
00133 
00134 #endif
00135 
00136 
00137 #else
00138 
00139 typedef float spx_mem_t;
00140 typedef float spx_coef_t;
00141 typedef float spx_lsp_t;
00142 typedef float spx_sig_t;
00143 typedef float spx_word16_t;
00144 typedef float spx_word32_t;
00145 
00146 #define Q15ONE 1.0f
00147 #define LPC_SCALING  1.f
00148 #define SIG_SCALING  1.f
00149 #define LSP_SCALING  1.f
00150 #define GAMMA_SCALING 1.f
00151 #define GAIN_SCALING 1.f
00152 #define GAIN_SCALING_1 1.f
00153 
00154 
00155 #define VERY_SMALL 1e-15f
00156 #define VERY_LARGE32 1e15f
00157 #define VERY_LARGE16 1e15f
00158 #define Q15_ONE ((spx_word16_t)1.f)
00159 
00160 #define QCONST16(x,bits) (x)
00161 #define QCONST32(x,bits) (x)
00162 
00163 #define NEG16(x) (-(x))
00164 #define NEG32(x) (-(x))
00165 #define EXTRACT16(x) (x)
00166 #define EXTEND32(x) (x)
00167 #define SHR16(a,shift) (a)
00168 #define SHL16(a,shift) (a)
00169 #define SHR32(a,shift) (a)
00170 #define SHL32(a,shift) (a)
00171 #define PSHR16(a,shift) (a)
00172 #define PSHR32(a,shift) (a)
00173 #define VSHR32(a,shift) (a)
00174 #define SATURATE16(x,a) (x)
00175 #define SATURATE32(x,a) (x)
00176 
00177 #define PSHR(a,shift)       (a)
00178 #define SHR(a,shift)       (a)
00179 #define SHL(a,shift)       (a)
00180 #define SATURATE(x,a) (x)
00181 
00182 #define ADD16(a,b) ((a)+(b))
00183 #define SUB16(a,b) ((a)-(b))
00184 #define ADD32(a,b) ((a)+(b))
00185 #define SUB32(a,b) ((a)-(b))
00186 #define MULT16_16_16(a,b)     ((a)*(b))
00187 #define MULT16_16(a,b)     ((spx_word32_t)(a)*(spx_word32_t)(b))
00188 #define MAC16_16(c,a,b)     ((c)+(spx_word32_t)(a)*(spx_word32_t)(b))
00189 
00190 #define MULT16_32_Q11(a,b)     ((a)*(b))
00191 #define MULT16_32_Q13(a,b)     ((a)*(b))
00192 #define MULT16_32_Q14(a,b)     ((a)*(b))
00193 #define MULT16_32_Q15(a,b)     ((a)*(b))
00194 #define MULT16_32_P15(a,b)     ((a)*(b))
00195 
00196 #define MAC16_32_Q11(c,a,b)     ((c)+(a)*(b))
00197 #define MAC16_32_Q15(c,a,b)     ((c)+(a)*(b))
00198 
00199 #define MAC16_16_Q11(c,a,b)     ((c)+(a)*(b))
00200 #define MAC16_16_Q13(c,a,b)     ((c)+(a)*(b))
00201 #define MAC16_16_P13(c,a,b)     ((c)+(a)*(b))
00202 #define MULT16_16_Q11_32(a,b)     ((a)*(b))
00203 #define MULT16_16_Q13(a,b)     ((a)*(b))
00204 #define MULT16_16_Q14(a,b)     ((a)*(b))
00205 #define MULT16_16_Q15(a,b)     ((a)*(b))
00206 #define MULT16_16_P15(a,b)     ((a)*(b))
00207 #define MULT16_16_P13(a,b)     ((a)*(b))
00208 #define MULT16_16_P14(a,b)     ((a)*(b))
00209 
00210 #define DIV32_16(a,b)     (((spx_word32_t)(a))/(spx_word16_t)(b))
00211 #define PDIV32_16(a,b)     (((spx_word32_t)(a))/(spx_word16_t)(b))
00212 #define DIV32(a,b)     (((spx_word32_t)(a))/(spx_word32_t)(b))
00213 #define PDIV32(a,b)     (((spx_word32_t)(a))/(spx_word32_t)(b))
00214 
00215 
00216 #endif
00217 
00218 
00219 #if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
00220 
00221 /* 2 on TI C5x DSP */
00222 #define BYTES_PER_CHAR 2 
00223 #define BITS_PER_CHAR 16
00224 #define LOG2_BITS_PER_CHAR 4
00225 
00226 #else 
00227 
00228 #define BYTES_PER_CHAR 1
00229 #define BITS_PER_CHAR 8
00230 #define LOG2_BITS_PER_CHAR 3
00231 
00232 #endif
00233 
00234 
00235 
00236 #ifdef FIXED_DEBUG
00237 extern long long spx_mips;
00238 #endif
00239 
00240 
00241 #endif

Generated on Thu Apr 16 06:27:13 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6