bv32cnst.h

00001 /*
00002  * broadvoice - a library for the BroadVoice 16 and 32 codecs
00003  *
00004  * bv32cnst.h - 
00005  *
00006  * Adapted by Steve Underwood <steveu@coppice.org> from code which is
00007  * Copyright 2000-2009 Broadcom Corporation
00008  *
00009  * All rights reserved.
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU Lesser General Public License version 2.1,
00013  * as published by the Free Software Foundation.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU Lesser General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00023  *
00024  * $Id: bv32cnst.h,v 1.1.1.1 2009/11/19 12:10:48 steveu Exp $
00025  */
00026 
00027 #include "typedef.h"
00028 
00029 #ifndef __BV32__
00030 #define __BV32__
00031 
00032 /* ----- Basic Codec Parameters ----- */
00033 #define SF              16                      /* input Sampling Frequency (in kHz) */
00034 #define FRSZ    80              /* the FRame SiZe */
00035 #define MAXPP   265             /* MAXimum Pitch Period */
00036 #define MINPP   10              /* Half of MINimum Pitch Period */
00037 #define NSF     2                           /* number of subframes per frame */
00038 #define PWSZ    240         /* Pitch analysis Window SiZe for 8kHz lowband */
00039 #define SFRSZ   (FRSZ/NSF)      /* SubFrame SiZe */
00040 #define WINSZ   160             /* Half of LPC analysis WINdow SiZe     */
00041 #define MAXPP1  (MAXPP+1)       /* Half of MAXimum Pitch Period + 1a */
00042 
00043 /* NFC VQ coding parameters */
00044 #define VDIM            4           /* excitation vector dimension */
00045 #define CBSZ            32          /* codebook size */
00046 #define PPCBSZ          32
00047 #define LGPORDER        16          /* Log-Gain Predictor OODER */
00048 #define LGPECBSZ        32          /* Log-Gain Prediction Error CodeBook SiZe */
00049 #define LSPPORDER       8           /* LSP MA Predictor ORDER */
00050 #define LSPECBSZ1       128         /* codebook size of 1st-stage LSP VQ */
00051 #define SVD1            3           /* split VQ dimension 1 */
00052 #define LSPECBSZ21      32          /* codebook size of 2nd-stage LSP split VQ */
00053 #define SVD2            5           /* split VQ dimension 2 */
00054 #define LSPECBSZ22      32          /* codebook size of 2nd stage LSP split VQ */
00055 
00056 #define NVPSF           (FRSZ/VDIM)
00057 #define NVPSSF          (SFRSZ/VDIM)
00058 
00059 /* Packetloss Concealment */
00060 #define ScPLCGmin   0.1
00061 #define ScPLCGmax   0.9
00062 #define PePLCGmin   0.5
00063 #define PePLCGmax   0.9
00064 #define ScPLCG_b    ((ScPLCGmin - ScPLCGmax)/(PePLCGmax - PePLCGmin))
00065 #define ScPLCG_a    (ScPLCGmin - ScPLCG_b*PePLCGmax)
00066 #define HoldPLCG    8
00067 #define AttnPLCG    50
00068 #define AttnFacPLCG (1.0/(Float)AttnPLCG)
00069 
00070 /* Pre-emphasis filter coefficients */
00071 #define PEAPFC      0.75
00072 #define PEAZFC      0.5
00073 
00074 #define INVSFRSZ (1./(Float)SFRSZ)
00075 #define FECNSF      2       /* number of FEC subframes per frame */
00076 
00077 #define Minlg       -2.0    /* minimum log-gain */
00078 #define TMinlg      0.25    /* minimum linear gain */
00079 #define GPO         16      /* order of MA prediction */
00080 
00081 /* Level Estimation */
00082 #define estl_alpha  (8191.0/8192.0)
00083 #define estl_beta   (1023.0/1024.0)
00084 #define estl_beta1  (1.0 - estl_beta)
00085 #define estl_a      (511.0/512.0)
00086 #define estl_a1     (1 - estl_a)
00087 #define estl_TH     0.2
00088 
00089 /* Log-Gain Limitation */
00090 #define LGLB   -24      /* Log-Gain Lower Bound */
00091 #define GCLB    -8      /* Log-Gain Change Lower Bound */
00092 #define NGB     18      /* Number of Gain Bins */
00093 #define NGCB    11      /* Number of Gain Change Bins */
00094 #define MinE  -2.0
00095 
00096 #define PFO     1   /* preemphasis filter order */
00097 
00098 #define LTMOFF MAXPP1   /* Long-Term filter Memory OFFset */
00099 
00100 /* Parameters related to the gain decoder trap */
00101 #define NCLGLIM_TRAPPED        50  /* 0.125 sec */
00102 #define LEVEL_CONVERGENCE_TIME 100 /* 0.25 sec */
00103 
00104 /* front-end highpass filter */
00105 #define HPO     2       /* High-pass filter order */
00106 
00107 /* LPC weighting filter */
00108 #define LTWFL   0.5
00109 
00110 /* Minimum gain threshold */
00111 #define TMinE (SFRSZ*0.25)
00112 
00113 /* coarse pitch search */
00114 #define cpp_Qvalue  3
00115 #define cpp_scale   (1<<cpp_Qvalue)
00116 
00117 /* ------ Decimation Parameters ----- */
00118 #define DECF    8   /* DECimation Factor for coarse pitch period search   */
00119 #define FRSZD   (FRSZ/DECF)    /* FRame SiZe in DECF:1 lowband domain        */
00120 #define MAXPPD  (MAXPP/DECF)   /* MAX Pitch in DECF:1, if MAXPP!=4n, ceil()  */
00121 #define MINPPD  ((int) (MINPP/DECF))   /* MINimum Pitch Period in DECF:1     */
00122 #define PWSZD   (PWSZ/DECF) /* Pitch ana. Window SiZe in DECF:1 domain    */
00123 #define DFO 4
00124 #define MAXPPD1 (MAXPPD + 1)
00125 #define LXD     (MAXPPD1 + PWSZD)
00126 #define XDOFF   (LXD - FRSZD)
00127 #define HMAXPPD (MAXPPD/2)
00128 #define M1      (MINPPD - 1)
00129 #define M2      MAXPPD1
00130 #define HDECF   (DECF/2)
00131 #define INVDECF (1.0F/(float)(DECF)) /* INVerse of DECF (decimation factor) */
00132 
00133 /* coarse pitch */
00134 #define MPTH4   0.3     /* value to use for MPTH[] with index >= 4 */
00135 #define DEVTH   0.25    /* pitch period DEViation THreshold     */
00136 #define TH1         0.73    /* first threshold for cor*cor/energy       */
00137 #define TH2         0.4     /* second threshold for cor*cor/energy      */
00138 #define LPTH1   0.78    /* Last Pitch cor*cor/energy THreshold 1 */
00139 #define LPTH2   0.43    /* Last Pitch cor*cor/energy THreshold 2 */
00140 #define MPDTH   0.06    /* Multiple Pitch Deviation THreshold */
00141 #define SMDTH   0.095   /* Sub-Multiple pitch Deviation THreshold */
00142 #define SMDTH1  (1.0 - SMDTH)
00143 #define SMDTH2  (1.0 + SMDTH)
00144 #define MPR1    (1.0 - MPDTH)    /* Multiple Pitch Range lower threshold */
00145 #define MPR2    (1.0 + MPDTH)    /* Multiple Pitch Range upper threshold */
00146 #define MAX_NPEAKS      7
00147 
00148 /* buffer offset and length */
00149 #define XOFF    MAXPP1         /* offset for x() frame      */
00150 #define LX      (XOFF+FRSZ)    /* Length of x() buffer      */
00151 
00152 #endif

Generated on 15 Mar 2017 for libg722_1 by  doxygen 1.6.1