blob: 159aad0a55f07d60cd0ed62a5809c9976313c46e
1 | /*****************************************************************************/ |
2 | /* BroadVoice(R)32 (BV32) Floating-Point ANSI-C Source Code */ |
3 | /* Revision Date: October 5, 2012 */ |
4 | /* Version 1.2 */ |
5 | /*****************************************************************************/ |
6 | |
7 | |
8 | /***************************************************************************** |
9 | bv32cnst.h : BV32 constants |
10 | |
11 | $Log$ |
12 | ******************************************************************************/ |
13 | |
14 | #ifndef BV32CNST_H |
15 | #define BV32CNST_H |
16 | |
17 | /* ----- Basic Codec Parameters ----- */ |
18 | #define SF 16 /* input Sampling Frequency (in kHz) */ |
19 | #define FRSZ 80 /* the FRame SiZe */ |
20 | #define MAXPP 265 /* MAXimum Pitch Period */ |
21 | #define MINPP 10 /* Half of MINimum Pitch Period */ |
22 | #define NSF 2 /* number of subframes per frame */ |
23 | #define PWSZ 240 /* Pitch analysis Window SiZe for 8 kHz lowband */ |
24 | #define SFRSZ (FRSZ/NSF) /* SubFrame SiZe */ |
25 | #define WINSZ 160 /* Half of lpc analysis WINdow SiZe */ |
26 | #define MAXPP1 (MAXPP+1) /* Half of MAXimum Pitch Period + 1a */ |
27 | |
28 | /* NFC VQ coding parameters */ |
29 | #define VDIM 4 /* excitation vector dimension */ |
30 | #define CBSZ 32 /* codebook size */ |
31 | #define PPCBSZ 32 |
32 | #define LGPORDER 16 /* Log-Gain Predictor OODER */ |
33 | #define LGPECBSZ 32 /* Log-Gain Prediction Error CodeBook SiZe */ |
34 | #define LSPPORDER 8 /* LSP MA Predictor ORDER */ |
35 | #define LSPECBSZ1 128 /* codebook size of 1st-stage LSP VQ */ |
36 | #define SVD1 3 /* split VQ dimension 1 */ |
37 | #define LSPECBSZ21 32 /* codebook size of 2nd-stage LSP split VQ */ |
38 | #define SVD2 5 /* split VQ dimension 2 */ |
39 | #define LSPECBSZ22 32 /* codebook size of 2nd stage LSP split VQ */ |
40 | |
41 | #define NVPSF (FRSZ/VDIM) |
42 | #define NVPSSF (SFRSZ/VDIM) |
43 | |
44 | /* Packetloss Concealment */ |
45 | #define ScPLCGmin 0.1f |
46 | #define ScPLCGmax 0.9f |
47 | #define PePLCGmin 0.5f |
48 | #define PePLCGmax 0.9f |
49 | #define ScPLCG_b ((ScPLCGmin-ScPLCGmax)/(PePLCGmax-PePLCGmin)) |
50 | #define ScPLCG_a (ScPLCGmin-ScPLCG_b*PePLCGmax) |
51 | #define HoldPLCG 8 |
52 | #define AttnPLCG 50 |
53 | #define AttnFacPLCG (1.0f/(Float)AttnPLCG) |
54 | |
55 | /* Pre-emphasis filter coefficients */ |
56 | #define PEAPFC 0.75f |
57 | #define PEAZFC 0.5f |
58 | |
59 | #define INVSFRSZ (1.0f/(Float)SFRSZ) |
60 | #define FECNSF 2 /* number of FEC subframes per frame */ |
61 | |
62 | #define Minlg -2.0f /* minimum log-gain */ |
63 | #define TMinlg 0.25f /* minimum linear gain */ |
64 | #define GPO 16 /* order of MA prediction */ |
65 | |
66 | /* Level Estimation */ |
67 | #define estl_alpha (8191.0f/8192.0f) |
68 | #define estl_beta (1023.0f/1024.0f) |
69 | #define estl_beta1 (1.0f-estl_beta) |
70 | #define estl_a (511.0f/512.0f) |
71 | #define estl_a1 (1-estl_a) |
72 | #define estl_TH 0.2f |
73 | |
74 | /* Log-Gain Limitation */ |
75 | #define LGLB -24 /* Log-Gain Lower Bound */ |
76 | #define GCLB -8 /* Log-Gain Change Lower Bound */ |
77 | #define NGB 18 /* Number of Gain Bins */ |
78 | #define NGCB 11 /* Number of Gain Change Bins */ |
79 | #define MinE -2.0 |
80 | |
81 | #define PFO 1 /* preemphasis filter order */ |
82 | |
83 | #define LTMOFF MAXPP1 /* Long-Term filter Memory OFFset */ |
84 | |
85 | /* Parameters related to the gain decoder trap */ |
86 | #define NCLGLIM_TRAPPED 50 /* 0.125 sec */ |
87 | #define LEVEL_CONVERGENCE_TIME 100 /* 0.25 sec */ |
88 | |
89 | /* front-end highpass filter */ |
90 | #define HPO 2 /* High-pass filter order */ |
91 | |
92 | /* lpc weighting filter */ |
93 | #define LTWFL 0.5f |
94 | |
95 | /* Minimum gain threshold */ |
96 | #define TMinE (SFRSZ*0.25f) |
97 | |
98 | /* coarse pitch search */ |
99 | #define cpp_Qvalue 3 |
100 | #define cpp_scale (1<<cpp_Qvalue) |
101 | |
102 | /* ------ Decimation Parameters ----- */ |
103 | #define DECF 8 /* DECimation Factor for coarse pitch period search */ |
104 | #define FRSZD (FRSZ/DECF) /* FRame SiZe in DECF:1 lowband domain */ |
105 | #define MAXPPD (MAXPP/DECF) /* MAX Pitch in DECF:1, if MAXPP!=4n, ceil() */ |
106 | #define MINPPD ((int) (MINPP/DECF)) /* MINimum Pitch Period in DECF:1 */ |
107 | #define PWSZD (PWSZ/DECF) /* Pitch ana. Window SiZe in DECF:1 domain */ |
108 | #define DFO 4 |
109 | #define MAXPPD1 (MAXPPD+1) |
110 | #define LXD (MAXPPD1+PWSZD) |
111 | #define XDOFF (LXD-FRSZD) |
112 | #define HMAXPPD (MAXPPD/2) |
113 | #define M1 (MINPPD-1) |
114 | #define M2 MAXPPD1 |
115 | #define HDECF (DECF/2) |
116 | #define INVDECF (1.0F/(float)(DECF)) /* INVerse of DECF (decimation factor) */ |
117 | |
118 | /* coarse pitch */ |
119 | #define MPTH4 0.3f /* value to use for MPTH[] with index >= 4 */ |
120 | #define DEVTH 0.25f /* pitch period DEViation THreshold */ |
121 | #define TH1 0.73f /* first threshold for cor*cor/energy */ |
122 | #define TH2 0.4f /* second threshold for cor*cor/energy */ |
123 | #define LPTH1 0.78f /* Last Pitch cor*cor/energy THreshold 1 */ |
124 | #define LPTH2 0.43f /* Last Pitch cor*cor/energy THreshold 2 */ |
125 | #define MPDTH 0.06f /* Multiple Pitch Deviation THreshold */ |
126 | #define SMDTH 0.095f /* Sub-Multiple pitch Deviation THreshold */ |
127 | #define SMDTH1 (1.0f-SMDTH) |
128 | #define SMDTH2 (1.0f+SMDTH) |
129 | #define MPR1 (1.0f-MPDTH) /* Multiple Pitch Range lower threshold */ |
130 | #define MPR2 (1.0f+MPDTH) /* Multiple Pitch Range upper threshold */ |
131 | #define MAX_NPEAKS 7 |
132 | |
133 | /* buffer offset and length */ |
134 | #define XOFF MAXPP1 /* offset for x() frame */ |
135 | #define LX (XOFF+FRSZ) /* Length of x() buffer */ |
136 | |
137 | #endif |
138 | |
139 |