bv16cnst.h 6.62 KB
Newer Older
Sandrine Avakian's avatar
Sandrine Avakian committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*****************************************************************************/
/* BroadVoice(R)16 (BV16) Floating-Point ANSI-C Source Code                  */
/* Revision Date: October 5, 2012                                            */
/* Version 1.2                                                               */
/*****************************************************************************/

/*****************************************************************************/
/* Copyright 2000-2012 Broadcom Corporation                                  */
/*                                                                           */
/* This software is provided under the GNU Lesser General Public License,    */
/* version 2.1, as published by the Free Software Foundation ("LGPL").       */
/* This program is distributed in the hope that it will be useful, but       */
/* WITHOUT ANY SUPPORT OR WARRANTY; without even the implied warranty of     */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the LGPL for     */
/* more details.  A copy of the LGPL is available at                         */
/* http://www.broadcom.com/licenses/LGPLv2.1.php,                            */
/* or by writing to the Free Software Foundation, Inc.,                      */
18
/* 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.                 */
Sandrine Avakian's avatar
Sandrine Avakian committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
/*****************************************************************************/


/*****************************************************************************
  bv16cnst.h : BV16 constants

  $Log$
******************************************************************************/

#ifndef  BV16CNST_H
#define  BV16CNST_H

/* ----- Basic Codec Parameters ----- */
#define FRSZ 	40 		/* frame size */
#define WINSZ	160		/* lpc analysis WINdow SiZe  */
#define MAXPP  137      /* MAXimum Pitch Period         		  */
#define MINPP  10       /* MINimum Pitch Period          		  */
#define PWSZ	120	   /* Pitch analysis Window SiZe   */
#define MAXPP1 (MAXPP+1)/* MAXimum Pitch Period + 1  	  */

/* Quantization parameters */
#define VDIM		  4	/* excitation vector dimension */		
#define CBSZ		 16	/* excitation codebook size */
#define PPCBSZ     32	/* pitch predictor codebook size */
#define LGPORDER	  8	/* Log-Gain Predictor OODER */
#define LGPECBSZ	 16	/* Log-Gain Prediction Error CodeBook SiZe */
#define LSPPORDER   8	/* LSP MA Predictor ORDER */
#define LSPECBSZ1 128	/* codebook size of 1st-stage LSP VQ */
#define LSPECBSZ2  64	/* codebook size of 2nd-stage LSP VQ; 1-bit for sign */

#define INVFRSZ (1./(Float)FRSZ)

/* Excitation gain quantization */
#define LGMEAN   11.45752 /* log2-gain mean               */
#define GPO       8       /* order of MA prediction       */
#define NG       18       /* number of relative gain bins */
#define GLB     -24.      /* lower relative gain bound    */
#define NGC      12       /* number of gain change bins   */
#define GCLB     -8.      /* lower gain change bound      */
#define Minlg     0.      /* minimum log-gain             */
#define TMinlg    1.      /* minimum linear gain          */
#define LGCBSZ   16       /* size of codebook             */

/* Definitions for periodicity to gain scaling mapping */
#define ScPLCGmin 0.1
#define ScPLCGmax 0.9
#define PePLCGmin 0.5
#define PePLCGmax 0.9
#define ScPLCG_b ((ScPLCGmin-ScPLCGmax)/(PePLCGmax-PePLCGmin))
#define ScPLCG_a (ScPLCGmin-ScPLCG_b*PePLCGmax)
#define HoldPLCG  8
#define AttnPLCG 50
#define AttnFacPLCG (1.0/(Float)AttnPLCG)

/* Level Estimation */
#define estl_alpha  (4095./4096.)
#define estl_alpha1 (255./256.)
#define estl_beta   (511./512.)
#define estl_beta1  (1.-estl_beta)
#define estl_a      (255./256)
#define estl_a1     (1-estl_a)
#define estl_TH     0.2
#define Nfdm        100 /* Max number of frames with fast decay of Lmin */

/* Log-Gain Limitation */
#define  LGLB   -24         /* Relative (to input level) Log-Gain Lower Bound */
#define  LGCLB  -8          /* Log-Gain Change Lower Bound */
#define  NGB    18          /* Number of Gain Bins */
#define  NGCB   12          /* Number of Gain Change Bins */

/* Buffer offsets and sizes */
#define XOFF    MAXPP1       /* offset for x() frame      */
#define LX      (XOFF+FRSZ)  /* Length of x() buffer      */
#define XQOFF   (MAXPP1)     /* xq() offset before current subframe */
#define LXQ     (XQOFF+FRSZ) /* Length of xq() buffer */
#define LTMOFF	 (MAXPP1)	  /* Long-Term filter Memory OFFset */

/* Long-term postfilter */
#define DPPQNS 4             /* Delta pitch period for search             */
#define NINT  20             /* length of filter interpolation            */
#define ATHLD1 0.55          /* threshold on normalized pitch correlation */
#define ATHLD2 0.80          /* threshold on normalized pitch correlation */
#define ScLTPF 0.3           /* scaling of LTPF coefficient               */

/* coarse pitch search */
#define	cpp_Qvalue	2
#define	cpp_scale	(1<<cpp_Qvalue)
#define	MAX_NPEAKS 7
#define MPTH4  0.3     /* value to use for MPTH[] with index >= 4 */
#define DEVTH	0.25	  /* pitch period DEViation THreshold 	*/
#define TH1	   0.73    /* first threshold for cor*cor/energy 	*/
#define TH2	   0.4     /* second threshold for cor*cor/energy 	*/
#define LPTH1  0.79    /* Last Pitch cor*cor/energy THreshold 1 */
#define LPTH2  0.43    /* Last Pitch cor*cor/energy THreshold 2 */
#define MPDTH  0.065   /* Multiple Pitch Deviation THreshold */
#define SMDTH  0.095   /* Sub-Multiple pitch Deviation THreshold */
#define SMDTH1  (1.0-SMDTH)    
#define SMDTH2  (1.0+SMDTH)    
#define MPR1   (1.0-MPDTH)    /* Multiple Pitch Range lower threshold */
#define MPR2   (1.0+MPDTH)    /* Multiple Pitch Range upper threshold */

/* Decimation parameters */
#define DECF    4   /* DECimation Factor for coarse pitch period search   */
#define FRSZD   (FRSZ/DECF)    /* FRame SiZe in DECF:1 lowband domain        */
#define MAXPPD  (MAXPP/DECF)   /* MAX Pitch in DECF:1, if MAXPP!=4n, ceil()  */
#define MINPPD  ((int) (MINPP/DECF))   /* MINimum Pitch Period in DECF:1     */
#define PWSZD   (PWSZ/DECF) /* Pitch ana. Window SiZe in DECF:1 domain    */
#define DFO 4
#define MAXPPD1 (MAXPPD+1)
#define LXD (MAXPPD1+PWSZD)
#define XDOFF   (LXD-FRSZD)
#define HMAXPPD (MAXPPD/2)
#define M1  (MINPPD-1)
#define M2  MAXPPD1
#define HDECF (DECF/2)
#define INVDECF (1.0F/(float)(DECF)) /* INVerse of DECF (decimation factor) */

/* Front-end 150 Hz highpass filter */ 
#define HPO     2       /* High-pass filter order */

/* LPC weighting filter */
#define	LTWFL	0.5

/* pole-zero NFC shaping filter */
#define	NSTORDER 8 

#endif /* BV16CNST_H */