libg722_1 0.1.0
bv16cnst.h
1/*****************************************************************************/
2/* BroadVoice(R)16 (BV16) Floating-Point ANSI-C Source Code */
3/* Revision Date: August 19, 2009 */
4/* Version 1.0 */
5/*****************************************************************************/
6
7/*****************************************************************************/
8/* Copyright 2000-2009 Broadcom Corporation */
9/* */
10/* This software is provided under the GNU Lesser General Public License, */
11/* version 2.1, as published by the Free Software Foundation ("LGPL"). */
12/* This program is distributed in the hope that it will be useful, but */
13/* WITHOUT ANY SUPPORT OR WARRANTY; without even the implied warranty of */
14/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the LGPL for */
15/* more details. A copy of the LGPL is available at */
16/* http://www.broadcom.com/licenses/LGPLv2.1.php, */
17/* or by writing to the Free Software Foundation, Inc., */
18/* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19/*****************************************************************************/
20
21
22/*****************************************************************************
23 bv16cnst.h : BV16 constants
24
25 $Log: bv16cnst.h,v $
26 Revision 1.1.1.1 2009/11/19 12:10:48 steveu
27 Start from Broadcom's code
28
29 Revision 1.1.1.1 2009/11/17 14:06:02 steveu
30 start
31
32******************************************************************************/
33
34#include "typedef.h"
35
36#ifndef BV16CNST_H
37#define BV16CNST_H
38
39
40/* ----- Basic Codec Parameters ----- */
41#define FRSZ 40 /* frame size */
42#define WINSZ 160 /* lpc analysis WINdow SiZe */
43#define MAXPP 137 /* MAXimum Pitch Period */
44#define MINPP 10 /* MINimum Pitch Period */
45#define PWSZ 120 /* Pitch analysis Window SiZe */
46#define MAXPP1 (MAXPP+1)/* MAXimum Pitch Period + 1 */
47
48/* Quantization parameters */
49#define VDIM 4 /* excitation vector dimension */
50#define CBSZ 16 /* excitation codebook size */
51#define PPCBSZ 32 /* pitch predictor codebook size */
52#define LGPORDER 8 /* Log-Gain Predictor OODER */
53#define LGPECBSZ 16 /* Log-Gain Prediction Error CodeBook SiZe */
54#define LSPPORDER 8 /* LSP MA Predictor ORDER */
55#define LSPECBSZ1 128 /* codebook size of 1st-stage LSP VQ */
56#define LSPECBSZ2 64 /* codebook size of 2nd-stage LSP VQ; 1-bit for sign */
57
58#define INVFRSZ (1./(Float)FRSZ)
59
60/* Excitation gain quantization */
61#define LGMEAN 11.45752 /* log2-gain mean */
62#define GPO 8 /* order of MA prediction */
63#define NG 18 /* number of relative gain bins */
64#define GLB -24. /* lower relative gain bound */
65#define NGC 12 /* number of gain change bins */
66#define GCLB -8. /* lower gain change bound */
67#define Minlg 0. /* minimum log-gain */
68#define TMinlg 1. /* minimum linear gain */
69#define LGCBSZ 16 /* size of codebook */
70
71/* Definitions for periodicity to gain scaling mapping */
72#define ScPLCGmin 0.1
73#define ScPLCGmax 0.9
74#define PePLCGmin 0.5
75#define PePLCGmax 0.9
76#define ScPLCG_b ((ScPLCGmin-ScPLCGmax)/(PePLCGmax-PePLCGmin))
77#define ScPLCG_a (ScPLCGmin-ScPLCG_b*PePLCGmax)
78#define HoldPLCG 8
79#define AttnPLCG 50
80#define AttnFacPLCG (1.0/(Float)AttnPLCG)
81
82/* Level Estimation */
83#define estl_alpha (4095./4096.)
84#define estl_alpha1 (255./256.)
85#define estl_beta (511./512.)
86#define estl_beta1 (1.-estl_beta)
87#define estl_a (255./256)
88#define estl_a1 (1-estl_a)
89#define estl_TH 0.2
90#define Nfdm 100 /* Max number of frames with fast decay of Lmin */
91
92/* Log-Gain Limitation */
93#define LGLB -24 /* Relative (to input level) Log-Gain Lower Bound */
94#define LGCLB -8 /* Log-Gain Change Lower Bound */
95#define NGB 18 /* Number of Gain Bins */
96#define NGCB 12 /* Number of Gain Change Bins */
97
98/* Buffer offsets and sizes */
99#define XOFF MAXPP1 /* offset for x() frame */
100#define LX (XOFF+FRSZ) /* Length of x() buffer */
101#define XQOFF (MAXPP1) /* xq() offset before current subframe */
102#define LXQ (XQOFF+FRSZ) /* Length of xq() buffer */
103#define LTMOFF (MAXPP1) /* Long-Term filter Memory OFFset */
104
105/* Long-term postfilter */
106#define DPPQNS 4 /* Delta pitch period for search */
107#define NINT 20 /* length of filter interpolation */
108#define ATHLD1 0.55 /* threshold on normalized pitch correlation */
109#define ATHLD2 0.80 /* threshold on normalized pitch correlation */
110#define ScLTPF 0.3 /* scaling of LTPF coefficient */
111
112/* coarse pitch search */
113#define cpp_Qvalue 2
114#define cpp_scale (1<<cpp_Qvalue)
115#define MAX_NPEAKS 7
116#define MPTH4 0.3 /* value to use for MPTH[] with index >= 4 */
117#define DEVTH 0.25 /* pitch period DEViation THreshold */
118#define TH1 0.73 /* first threshold for cor*cor/energy */
119#define TH2 0.4 /* second threshold for cor*cor/energy */
120#define LPTH1 0.79 /* Last Pitch cor*cor/energy THreshold 1 */
121#define LPTH2 0.43 /* Last Pitch cor*cor/energy THreshold 2 */
122#define MPDTH 0.065 /* Multiple Pitch Deviation THreshold */
123#define SMDTH 0.095 /* Sub-Multiple pitch Deviation THreshold */
124#define SMDTH1 (1.0-SMDTH)
125#define SMDTH2 (1.0+SMDTH)
126#define MPR1 (1.0-MPDTH) /* Multiple Pitch Range lower threshold */
127#define MPR2 (1.0+MPDTH) /* Multiple Pitch Range upper threshold */
128
129/* Decimation parameters */
130#define DECF 4 /* DECimation Factor for coarse pitch period search */
131#define FRSZD (FRSZ/DECF) /* FRame SiZe in DECF:1 lowband domain */
132#define MAXPPD (MAXPP/DECF) /* MAX Pitch in DECF:1, if MAXPP!=4n, ceil() */
133#define MINPPD ((int) (MINPP/DECF)) /* MINimum Pitch Period in DECF:1 */
134#define PWSZD (PWSZ/DECF) /* Pitch ana. Window SiZe in DECF:1 domain */
135#define DFO 4
136#define MAXPPD1 (MAXPPD + 1)
137#define LXD (MAXPPD1 + PWSZD)
138#define XDOFF (LXD - FRSZD)
139#define HMAXPPD (MAXPPD/2)
140#define M1 (MINPPD - 1)
141#define M2 MAXPPD1
142#define HDECF (DECF/2)
143#define INVDECF (1.0F/(float)(DECF)) /* INVerse of DECF (decimation factor) */
144
145/* Front-end 150 Hz highpass filter */
146#define HPO 2 /* High-pass filter order */
147
148/* LPC weighting filter */
149#define LTWFL 0.5
150
151/* pole-zero NFC shaping filter */
152#define NSTORDER 8
153
154#endif /* BV16CNST_H */