Main Page | Class List | Directories | File List | Class Members | File Members

misc.h

Go to the documentation of this file.
00001 /* Copyright (C) 2002 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 MISC_H
00036 #define MISC_H
00037 
00038 #ifndef VERSION
00039 #define VERSION "speex-1.1"
00040 #endif
00041 
00042 #ifdef FIXED_POINT
00043 
00044 typedef signed short spx_word16_t;
00045 typedef signed int   spx_word32_t;
00046 typedef spx_word32_t spx_mem_t;
00047 typedef spx_word16_t spx_coef_t;
00048 typedef spx_word16_t spx_lsp_t;
00049 typedef spx_word32_t spx_sig_t;
00050 
00051 #define LPC_SCALING  8192.
00052 #define SIG_SCALING  16384
00053 #define LSP_SCALING  8192.
00054 
00055 #define LPC_SHIFT    13
00056 #define SIG_SHIFT    14
00057 
00058 #define PSHR(a,shift) (((a)+(1<<((shift)-1))) >> (shift))
00059 #define SHR(a,shift) ((a) >> (shift))
00060 #define SHL(a,shift) ((a) << (shift))
00061 
00062 /* result fits in 16 bits */
00063 #define MULT16_16_16(a,b)     (((short)(a))*(b))
00064 
00065 #define MULT16_16(a,b)     (((signed int)(a))*(b))
00066 #define MULT16_32_Q13(a,b) (((a)*((b)>>13)) + ((a)*((signed int)((b)&0x00001fff))>>13))
00067 #define MULT16_32_Q14(a,b) (((a)*((b)>>14)) + ((a)*((signed int)((b)&0x00003fff))>>14))
00068 #define MULT16_32_Q15(a,b) (((a)*((b)>>15)) + ((a)*((signed int)((b)&0x00007fff))>>15))
00069 
00070 #define MULT16_16_Q13(a,b) (((signed int)(a))*(b)>>13)
00071 #define MULT16_16_Q14(a,b) (((signed int)(a))*(b)>>14)
00072 #define MULT16_16_Q15(a,b) (((signed int)(a))*(b)>>15)
00073 
00074 #define MULT16_16_P14(a,b) ((8192+((signed int)(a))*(b))>>14)
00075 
00076 
00077 #define DIV32_16(a,b) (((signed int)(a))/(b))
00078 
00079 #else
00080 
00081 typedef float spx_mem_t;
00082 typedef float spx_coef_t;
00083 typedef float spx_lsp_t;
00084 typedef float spx_sig_t;
00085 typedef float spx_word16_t;
00086 typedef float spx_word32_t;
00087 
00088 #define LPC_SCALING  1.
00089 #define SIG_SCALING  1.
00090 #define LSP_SCALING  1.
00091 
00092 #define LPC_SHIFT    0
00093 #define SIG_SHIFT    0
00094 
00095 #define PSHR(a,shift)       (a)
00096 #define SHR(a,shift)       (a)
00097 #define SHL(a,shift)       (a)
00098 #define MULT16_16_16(a,b)     ((a)*(b))
00099 #define MULT16_16(a,b)     ((a)*(b))
00100 
00101 #define MULT16_32_Q13(a,b)     ((a)*(b))
00102 #define MULT16_32_Q14(a,b)     ((a)*(b))
00103 #define MULT16_32_Q15(a,b)     ((a)*(b))
00104 
00105 #define MULT16_16_Q13(a,b)     ((a)*(b))
00106 #define MULT16_16_Q14(a,b)     ((a)*(b))
00107 #define MULT16_16_Q15(a,b)     ((a)*(b))
00108 
00109 
00110 #endif
00111 
00112 #ifndef RELEASE
00113 void print_vec(float *vec, int len, char *name);
00114 #endif
00115 
00116 unsigned int be_int(unsigned int i);
00117 unsigned int le_int(unsigned int i);
00118 
00119 
00120 unsigned short be_short(unsigned short s);
00121 unsigned short le_short(unsigned short s);
00122 
00124 void *speex_alloc (int size);
00125 
00127 void *speex_realloc (void *ptr, int size);
00128 
00130 void speex_free (void *ptr);
00131 
00133 void *speex_move (void *dest, void *src, int n);
00134 
00135 void speex_error(char *str);
00136 
00137 void speex_warning(char *str);
00138 
00139 void speex_warning_int(char *str, int val);
00140 
00141 void speex_rand_vec(float std, spx_sig_t *data, int len);
00142 
00143 float speex_rand(float std);
00144 
00145 void _speex_putc(int ch, void *file);
00146 
00147 #endif

Generated on Wed Aug 24 01:08:53 2005 for Speex by  doxygen 1.4.2