00001 /*****************************************************************************/ 00002 /* BroadVoice(R)16 (BV16) Floating-Point ANSI-C Source Code */ 00003 /* Revision Date: August 19, 2009 */ 00004 /* Version 1.0 */ 00005 /*****************************************************************************/ 00006 00007 /*****************************************************************************/ 00008 /* Copyright 2000-2009 Broadcom Corporation */ 00009 /* */ 00010 /* This software is provided under the GNU Lesser General Public License, */ 00011 /* version 2.1, as published by the Free Software Foundation ("LGPL"). */ 00012 /* This program is distributed in the hope that it will be useful, but */ 00013 /* WITHOUT ANY SUPPORT OR WARRANTY; without even the implied warranty of */ 00014 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the LGPL for */ 00015 /* more details. A copy of the LGPL is available at */ 00016 /* http://www.broadcom.com/licenses/LGPLv2.1.php, */ 00017 /* or by writing to the Free Software Foundation, Inc., */ 00018 /* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 00019 /*****************************************************************************/ 00020 00021 00022 /***************************************************************************** 00023 bv16cnst.h : BV16 constants 00024 00025 $Log: bv16cnst.h,v $ 00026 Revision 1.1.1.1 2009/11/19 12:10:48 steveu 00027 Start from Broadcom's code 00028 00029 Revision 1.1.1.1 2009/11/17 14:06:02 steveu 00030 start 00031 00032 ******************************************************************************/ 00033 00034 #include "typedef.h" 00035 00036 #ifndef BV16CNST_H 00037 #define BV16CNST_H 00038 00039 00040 /* ----- Basic Codec Parameters ----- */ 00041 #define FRSZ 40 /* frame size */ 00042 #define WINSZ 160 /* lpc analysis WINdow SiZe */ 00043 #define MAXPP 137 /* MAXimum Pitch Period */ 00044 #define MINPP 10 /* MINimum Pitch Period */ 00045 #define PWSZ 120 /* Pitch analysis Window SiZe */ 00046 #define MAXPP1 (MAXPP+1)/* MAXimum Pitch Period + 1 */ 00047 00048 /* Quantization parameters */ 00049 #define VDIM 4 /* excitation vector dimension */ 00050 #define CBSZ 16 /* excitation codebook size */ 00051 #define PPCBSZ 32 /* pitch predictor codebook size */ 00052 #define LGPORDER 8 /* Log-Gain Predictor OODER */ 00053 #define LGPECBSZ 16 /* Log-Gain Prediction Error CodeBook SiZe */ 00054 #define LSPPORDER 8 /* LSP MA Predictor ORDER */ 00055 #define LSPECBSZ1 128 /* codebook size of 1st-stage LSP VQ */ 00056 #define LSPECBSZ2 64 /* codebook size of 2nd-stage LSP VQ; 1-bit for sign */ 00057 00058 #define INVFRSZ (1./(Float)FRSZ) 00059 00060 /* Excitation gain quantization */ 00061 #define LGMEAN 11.45752 /* log2-gain mean */ 00062 #define GPO 8 /* order of MA prediction */ 00063 #define NG 18 /* number of relative gain bins */ 00064 #define GLB -24. /* lower relative gain bound */ 00065 #define NGC 12 /* number of gain change bins */ 00066 #define GCLB -8. /* lower gain change bound */ 00067 #define Minlg 0. /* minimum log-gain */ 00068 #define TMinlg 1. /* minimum linear gain */ 00069 #define LGCBSZ 16 /* size of codebook */ 00070 00071 /* Definitions for periodicity to gain scaling mapping */ 00072 #define ScPLCGmin 0.1 00073 #define ScPLCGmax 0.9 00074 #define PePLCGmin 0.5 00075 #define PePLCGmax 0.9 00076 #define ScPLCG_b ((ScPLCGmin-ScPLCGmax)/(PePLCGmax-PePLCGmin)) 00077 #define ScPLCG_a (ScPLCGmin-ScPLCG_b*PePLCGmax) 00078 #define HoldPLCG 8 00079 #define AttnPLCG 50 00080 #define AttnFacPLCG (1.0/(Float)AttnPLCG) 00081 00082 /* Level Estimation */ 00083 #define estl_alpha (4095./4096.) 00084 #define estl_alpha1 (255./256.) 00085 #define estl_beta (511./512.) 00086 #define estl_beta1 (1.-estl_beta) 00087 #define estl_a (255./256) 00088 #define estl_a1 (1-estl_a) 00089 #define estl_TH 0.2 00090 #define Nfdm 100 /* Max number of frames with fast decay of Lmin */ 00091 00092 /* Log-Gain Limitation */ 00093 #define LGLB -24 /* Relative (to input level) Log-Gain Lower Bound */ 00094 #define LGCLB -8 /* Log-Gain Change Lower Bound */ 00095 #define NGB 18 /* Number of Gain Bins */ 00096 #define NGCB 12 /* Number of Gain Change Bins */ 00097 00098 /* Buffer offsets and sizes */ 00099 #define XOFF MAXPP1 /* offset for x() frame */ 00100 #define LX (XOFF+FRSZ) /* Length of x() buffer */ 00101 #define XQOFF (MAXPP1) /* xq() offset before current subframe */ 00102 #define LXQ (XQOFF+FRSZ) /* Length of xq() buffer */ 00103 #define LTMOFF (MAXPP1) /* Long-Term filter Memory OFFset */ 00104 00105 /* Long-term postfilter */ 00106 #define DPPQNS 4 /* Delta pitch period for search */ 00107 #define NINT 20 /* length of filter interpolation */ 00108 #define ATHLD1 0.55 /* threshold on normalized pitch correlation */ 00109 #define ATHLD2 0.80 /* threshold on normalized pitch correlation */ 00110 #define ScLTPF 0.3 /* scaling of LTPF coefficient */ 00111 00112 /* coarse pitch search */ 00113 #define cpp_Qvalue 2 00114 #define cpp_scale (1<<cpp_Qvalue) 00115 #define MAX_NPEAKS 7 00116 #define MPTH4 0.3 /* value to use for MPTH[] with index >= 4 */ 00117 #define DEVTH 0.25 /* pitch period DEViation THreshold */ 00118 #define TH1 0.73 /* first threshold for cor*cor/energy */ 00119 #define TH2 0.4 /* second threshold for cor*cor/energy */ 00120 #define LPTH1 0.79 /* Last Pitch cor*cor/energy THreshold 1 */ 00121 #define LPTH2 0.43 /* Last Pitch cor*cor/energy THreshold 2 */ 00122 #define MPDTH 0.065 /* Multiple Pitch Deviation THreshold */ 00123 #define SMDTH 0.095 /* Sub-Multiple pitch Deviation THreshold */ 00124 #define SMDTH1 (1.0-SMDTH) 00125 #define SMDTH2 (1.0+SMDTH) 00126 #define MPR1 (1.0-MPDTH) /* Multiple Pitch Range lower threshold */ 00127 #define MPR2 (1.0+MPDTH) /* Multiple Pitch Range upper threshold */ 00128 00129 /* Decimation parameters */ 00130 #define DECF 4 /* DECimation Factor for coarse pitch period search */ 00131 #define FRSZD (FRSZ/DECF) /* FRame SiZe in DECF:1 lowband domain */ 00132 #define MAXPPD (MAXPP/DECF) /* MAX Pitch in DECF:1, if MAXPP!=4n, ceil() */ 00133 #define MINPPD ((int) (MINPP/DECF)) /* MINimum Pitch Period in DECF:1 */ 00134 #define PWSZD (PWSZ/DECF) /* Pitch ana. Window SiZe in DECF:1 domain */ 00135 #define DFO 4 00136 #define MAXPPD1 (MAXPPD + 1) 00137 #define LXD (MAXPPD1 + PWSZD) 00138 #define XDOFF (LXD - FRSZD) 00139 #define HMAXPPD (MAXPPD/2) 00140 #define M1 (MINPPD - 1) 00141 #define M2 MAXPPD1 00142 #define HDECF (DECF/2) 00143 #define INVDECF (1.0F/(float)(DECF)) /* INVerse of DECF (decimation factor) */ 00144 00145 /* Front-end 150 Hz highpass filter */ 00146 #define HPO 2 /* High-pass filter order */ 00147 00148 /* LPC weighting filter */ 00149 #define LTWFL 0.5 00150 00151 /* pole-zero NFC shaping filter */ 00152 #define NSTORDER 8 00153 00154 #endif /* BV16CNST_H */