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

fixed_generic.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 FIXED_GENERIC_H 00036 #define FIXED_GENERIC_H 00037 00038 #define SHR(a,shift) ((a) >> (shift)) 00039 #define SHL(a,shift) ((a) << (shift)) 00040 00041 #define SATURATE(x,a) ((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)) 00042 00043 #define ADD16(a,b) ((short)((short)(a)+(short)(b))) 00044 #define SUB16(a,b) ((a)-(b)) 00045 #define ADD32(a,b) ((a)+(b)) 00046 #define SUB32(a,b) ((a)-(b)) 00047 #define ADD64(a,b) ((a)+(b)) 00048 00049 #define PSHR(a,shift) (SHR((a)+(1<<((shift)-1)),shift)) 00050 00051 /* result fits in 16 bits */ 00052 #define MULT16_16_16(a,b) ((((short)(a))*((short)(b)))) 00053 00054 #define MULT16_16(a,b) (((short)(a))*((short)(b))) 00055 00056 00057 00058 00059 #define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b)))) 00060 #define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12)) 00061 #define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13)) 00062 #define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14)) 00063 00064 #define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)) 00065 #define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))) 00066 00067 #define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)) 00068 #define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))) 00069 00070 00071 #define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11))) 00072 00073 #define MULT16_16_Q11(a,b) (SHR(MULT16_16((a),(b)),11)) 00074 #define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13)) 00075 #define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14)) 00076 #define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15)) 00077 00078 #define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13)) 00079 #define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14)) 00080 #define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15)) 00081 00082 #define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15)) 00083 00084 00085 00086 #define DIV32_16(a,b) ((short)(((signed int)(a))/((short)(b)))) 00087 #define DIV32(a,b) (((signed int)(a))/((signed int)(b))) 00088 00089 00090 00091 #endif

Generated on Thu Aug 12 11:55:01 2004 for speex by doxygen 1.3.8