libg722_1  0.1.0
bv32cnst.h
1 /*
2  * broadvoice - a library for the BroadVoice 16 and 32 codecs
3  *
4  * bv32cnst.h -
5  *
6  * Adapted by Steve Underwood <steveu@coppice.org> from code which is
7  * Copyright 2000-2009 Broadcom Corporation
8  *
9  * All rights reserved.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 2.1,
13  * as published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this program; if not, write to the Free Software
22  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  *
24  * $Id: bv32cnst.h,v 1.1.1.1 2009/11/19 12:10:48 steveu Exp $
25  */
26 
27 #include "typedef.h"
28 
29 #ifndef __BV32__
30 #define __BV32__
31 
32 /* ----- Basic Codec Parameters ----- */
33 #define SF 16 /* input Sampling Frequency (in kHz) */
34 #define FRSZ 80 /* the FRame SiZe */
35 #define MAXPP 265 /* MAXimum Pitch Period */
36 #define MINPP 10 /* Half of MINimum Pitch Period */
37 #define NSF 2 /* number of subframes per frame */
38 #define PWSZ 240 /* Pitch analysis Window SiZe for 8kHz lowband */
39 #define SFRSZ (FRSZ/NSF) /* SubFrame SiZe */
40 #define WINSZ 160 /* Half of LPC analysis WINdow SiZe */
41 #define MAXPP1 (MAXPP+1) /* Half of MAXimum Pitch Period + 1a */
42 
43 /* NFC VQ coding parameters */
44 #define VDIM 4 /* excitation vector dimension */
45 #define CBSZ 32 /* codebook size */
46 #define PPCBSZ 32
47 #define LGPORDER 16 /* Log-Gain Predictor OODER */
48 #define LGPECBSZ 32 /* Log-Gain Prediction Error CodeBook SiZe */
49 #define LSPPORDER 8 /* LSP MA Predictor ORDER */
50 #define LSPECBSZ1 128 /* codebook size of 1st-stage LSP VQ */
51 #define SVD1 3 /* split VQ dimension 1 */
52 #define LSPECBSZ21 32 /* codebook size of 2nd-stage LSP split VQ */
53 #define SVD2 5 /* split VQ dimension 2 */
54 #define LSPECBSZ22 32 /* codebook size of 2nd stage LSP split VQ */
55 
56 #define NVPSF (FRSZ/VDIM)
57 #define NVPSSF (SFRSZ/VDIM)
58 
59 /* Packetloss Concealment */
60 #define ScPLCGmin 0.1
61 #define ScPLCGmax 0.9
62 #define PePLCGmin 0.5
63 #define PePLCGmax 0.9
64 #define ScPLCG_b ((ScPLCGmin - ScPLCGmax)/(PePLCGmax - PePLCGmin))
65 #define ScPLCG_a (ScPLCGmin - ScPLCG_b*PePLCGmax)
66 #define HoldPLCG 8
67 #define AttnPLCG 50
68 #define AttnFacPLCG (1.0/(Float)AttnPLCG)
69 
70 /* Pre-emphasis filter coefficients */
71 #define PEAPFC 0.75
72 #define PEAZFC 0.5
73 
74 #define INVSFRSZ (1./(Float)SFRSZ)
75 #define FECNSF 2 /* number of FEC subframes per frame */
76 
77 #define Minlg -2.0 /* minimum log-gain */
78 #define TMinlg 0.25 /* minimum linear gain */
79 #define GPO 16 /* order of MA prediction */
80 
81 /* Level Estimation */
82 #define estl_alpha (8191.0/8192.0)
83 #define estl_beta (1023.0/1024.0)
84 #define estl_beta1 (1.0 - estl_beta)
85 #define estl_a (511.0/512.0)
86 #define estl_a1 (1 - estl_a)
87 #define estl_TH 0.2
88 
89 /* Log-Gain Limitation */
90 #define LGLB -24 /* Log-Gain Lower Bound */
91 #define GCLB -8 /* Log-Gain Change Lower Bound */
92 #define NGB 18 /* Number of Gain Bins */
93 #define NGCB 11 /* Number of Gain Change Bins */
94 #define MinE -2.0
95 
96 #define PFO 1 /* preemphasis filter order */
97 
98 #define LTMOFF MAXPP1 /* Long-Term filter Memory OFFset */
99 
100 /* Parameters related to the gain decoder trap */
101 #define NCLGLIM_TRAPPED 50 /* 0.125 sec */
102 #define LEVEL_CONVERGENCE_TIME 100 /* 0.25 sec */
103 
104 /* front-end highpass filter */
105 #define HPO 2 /* High-pass filter order */
106 
107 /* LPC weighting filter */
108 #define LTWFL 0.5
109 
110 /* Minimum gain threshold */
111 #define TMinE (SFRSZ*0.25)
112 
113 /* coarse pitch search */
114 #define cpp_Qvalue 3
115 #define cpp_scale (1<<cpp_Qvalue)
116 
117 /* ------ Decimation Parameters ----- */
118 #define DECF 8 /* DECimation Factor for coarse pitch period search */
119 #define FRSZD (FRSZ/DECF) /* FRame SiZe in DECF:1 lowband domain */
120 #define MAXPPD (MAXPP/DECF) /* MAX Pitch in DECF:1, if MAXPP!=4n, ceil() */
121 #define MINPPD ((int) (MINPP/DECF)) /* MINimum Pitch Period in DECF:1 */
122 #define PWSZD (PWSZ/DECF) /* Pitch ana. Window SiZe in DECF:1 domain */
123 #define DFO 4
124 #define MAXPPD1 (MAXPPD + 1)
125 #define LXD (MAXPPD1 + PWSZD)
126 #define XDOFF (LXD - FRSZD)
127 #define HMAXPPD (MAXPPD/2)
128 #define M1 (MINPPD - 1)
129 #define M2 MAXPPD1
130 #define HDECF (DECF/2)
131 #define INVDECF (1.0F/(float)(DECF)) /* INVerse of DECF (decimation factor) */
132 
133 /* coarse pitch */
134 #define MPTH4 0.3 /* value to use for MPTH[] with index >= 4 */
135 #define DEVTH 0.25 /* pitch period DEViation THreshold */
136 #define TH1 0.73 /* first threshold for cor*cor/energy */
137 #define TH2 0.4 /* second threshold for cor*cor/energy */
138 #define LPTH1 0.78 /* Last Pitch cor*cor/energy THreshold 1 */
139 #define LPTH2 0.43 /* Last Pitch cor*cor/energy THreshold 2 */
140 #define MPDTH 0.06 /* Multiple Pitch Deviation THreshold */
141 #define SMDTH 0.095 /* Sub-Multiple pitch Deviation THreshold */
142 #define SMDTH1 (1.0 - SMDTH)
143 #define SMDTH2 (1.0 + SMDTH)
144 #define MPR1 (1.0 - MPDTH) /* Multiple Pitch Range lower threshold */
145 #define MPR2 (1.0 + MPDTH) /* Multiple Pitch Range upper threshold */
146 #define MAX_NPEAKS 7
147 
148 /* buffer offset and length */
149 #define XOFF MAXPP1 /* offset for x() frame */
150 #define LX (XOFF+FRSZ) /* Length of x() buffer */
151 
152 #endif
itu_codec_bitstream_write
void itu_codec_bitstream_write(const uint8_t out_data[], int number_of_bits, int mode, FILE *fp_bitstream)
Write a frame of data to an output file.
Definition: g192_bit_stream.c:62
bv32_encode_state_s
Definition: broadvoice/private/broadvoice.h:156
bv32_decode_state_s
Definition: broadvoice/private/broadvoice.h:128
itu_codec_bitstream_read
int itu_codec_bitstream_read(uint8_t in_data[], int16_t *frame_error_flag, int number_of_bits, int mode, FILE *fp_bitstream)
Read a frame of data from an input file.
Definition: g192_bit_stream.c:94
g192_bit_stream.h