spandsp
0.0.6
|
00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * lpc10_encdecs.h - LPC10 low bit rate speech codec. 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2006 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 2.1, 00014 * as published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 */ 00025 00026 #define LPC10_ORDER 10 00027 00028 #if !defined(min) 00029 #define min(a,b) ((a) <= (b) ? (a) : (b)) 00030 #endif 00031 #if !defined(max) 00032 #define max(a,b) ((a) >= (b) ? (a) : (b)) 00033 #endif 00034 00035 void lpc10_placea(int32_t *ipitch, 00036 int32_t voibuf[4][2], 00037 int32_t *obound, 00038 int32_t af, 00039 int32_t vwin[3][2], 00040 int32_t awin[3][2], 00041 int32_t ewin[3][2], 00042 int32_t lframe, 00043 int32_t maxwin); 00044 00045 void lpc10_placev(int32_t *osbuf, 00046 int32_t *osptr, 00047 int32_t oslen, 00048 int32_t *obound, 00049 int32_t vwin[3][2], 00050 int32_t af, 00051 int32_t lframe, 00052 int32_t minwin, 00053 int32_t maxwin, 00054 int32_t dvwinl, 00055 int32_t dvwinh); 00056 00057 void lpc10_voicing(lpc10_encode_state_t *st, 00058 int32_t *vwin, 00059 float *inbuf, 00060 float *lpbuf, 00061 const int32_t buflim[], 00062 int32_t half, 00063 float *minamd, 00064 float *maxamd, 00065 int32_t *mintau, 00066 float *ivrc, 00067 int32_t *obound); 00068 00069 void lpc10_analyse(lpc10_encode_state_t *st, float *speech, int32_t *voice, int32_t *pitch, float *rms, float rc[]); 00070 00071 static __inline__ int32_t pow_ii(int32_t x, int32_t n) 00072 { 00073 int32_t pow; 00074 uint32_t u; 00075 00076 if (n <= 0) 00077 { 00078 if (n == 0 || x == 1) 00079 return 1; 00080 if (x != -1) 00081 return (x == 0) ? 1/x : 0; 00082 n = -n; 00083 } 00084 u = n; 00085 for (pow = 1; ; ) 00086 { 00087 if ((u & 1)) 00088 pow *= x; 00089 if ((u >>= 1) == 0) 00090 break; 00091 x *= x; 00092 } 00093 return pow; 00094 } 00095 /*- End of function --------------------------------------------------------*/ 00096 00097 static __inline__ float r_sign(float a, float b) 00098 { 00099 float x; 00100 00101 x = fabsf(a); 00102 return (b >= 0.0f) ? x : -x; 00103 } 00104 /*- End of function --------------------------------------------------------*/ 00105 /*- End of file ------------------------------------------------------------*/