libspandsp 0.0.4
|
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 * $Id: lpc10_encdecs.h,v 1.11 2008/04/17 14:26:56 steveu Exp $ 00026 */ 00027 00028 #define LPC10_ORDER 10 00029 00030 #if !defined(min) 00031 #define min(a,b) ((a) <= (b) ? (a) : (b)) 00032 #endif 00033 #if !defined(max) 00034 #define max(a,b) ((a) >= (b) ? (a) : (b)) 00035 #endif 00036 00037 void lpc10_placea(int32_t *ipitch, 00038 int32_t voibuf[4][2], 00039 int32_t *obound, 00040 int32_t af, 00041 int32_t vwin[3][2], 00042 int32_t awin[3][2], 00043 int32_t ewin[3][2], 00044 int32_t lframe, 00045 int32_t maxwin); 00046 00047 void lpc10_placev(int32_t *osbuf, 00048 int32_t *osptr, 00049 int32_t oslen, 00050 int32_t *obound, 00051 int32_t vwin[3][2], 00052 int32_t af, 00053 int32_t lframe, 00054 int32_t minwin, 00055 int32_t maxwin, 00056 int32_t dvwinl, 00057 int32_t dvwinh); 00058 00059 void lpc10_voicing(lpc10_encode_state_t *st, 00060 int32_t *vwin, 00061 float *inbuf, 00062 float *lpbuf, 00063 const int32_t buflim[], 00064 int32_t half, 00065 float *minamd, 00066 float *maxamd, 00067 int32_t *mintau, 00068 float *ivrc, 00069 int32_t *obound); 00070 00071 void lpc10_analyse(lpc10_encode_state_t *st, float *speech, int32_t *voice, int32_t *pitch, float *rms, float rc[]); 00072 00073 static __inline__ int32_t pow_ii(int32_t x, int32_t n) 00074 { 00075 int32_t pow; 00076 uint32_t u; 00077 00078 if (n <= 0) 00079 { 00080 if (n == 0 || x == 1) 00081 return 1; 00082 if (x != -1) 00083 return (x == 0) ? 1/x : 0; 00084 n = -n; 00085 } 00086 u = n; 00087 for (pow = 1; ; ) 00088 { 00089 if ((u & 1)) 00090 pow *= x; 00091 if ((u >>= 1) == 0) 00092 break; 00093 x *= x; 00094 } 00095 return pow; 00096 } 00097 /*- End of function --------------------------------------------------------*/ 00098 00099 static __inline__ float r_sign(float a, float b) 00100 { 00101 float x; 00102 00103 x = fabsf(a); 00104 return (b >= 0.0f) ? x : -x; 00105 } 00106 /*- End of function --------------------------------------------------------*/ 00107 /*- End of file ------------------------------------------------------------*/