bv16cnst.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*****************************************************************************/
  2. /* BroadVoice(R)16 (BV16) Fixed-Point ANSI-C Source Code */
  3. /* Revision Date: November 13, 2009 */
  4. /* Version 1.1 */
  5. /*****************************************************************************/
  6. /*****************************************************************************/
  7. /* Copyright 2000-2009 Broadcom Corporation */
  8. /* */
  9. /* This software is provided under the GNU Lesser General Public License, */
  10. /* version 2.1, as published by the Free Software Foundation ("LGPL"). */
  11. /* This program is distributed in the hope that it will be useful, but */
  12. /* WITHOUT ANY SUPPORT OR WARRANTY; without even the implied warranty of */
  13. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the LGPL for */
  14. /* more details. A copy of the LGPL is available at */
  15. /* http://www.broadcom.com/licenses/LGPLv2.1.php, */
  16. /* or by writing to the Free Software Foundation, Inc., */
  17. /* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  18. /*****************************************************************************/
  19. /*****************************************************************************
  20. bv16cnst.h : BV16 constants
  21. $Log$
  22. ******************************************************************************/
  23. #ifndef BV16CNST_H
  24. #define BV16CNST_H
  25. /* ----- Basic Codec Parameters ----- */
  26. #define FRSZ 40 /* frame size */
  27. #define WINSZ 160 /* lpc analysis WINdow SiZe */
  28. #define MAXPP 137 /* MAXimum Pitch Period */
  29. #define MINPP 10 /* MINimum Pitch Period */
  30. #define PWSZ 120 /* Pitch analysis Window SiZe */
  31. #define MAXPP1 (MAXPP+1)/* MAXimum Pitch Period + 1 */
  32. /* Quantization parameters */
  33. #define VDIM 4 /* excitation vector dimension */
  34. #define CBSZ 16 /* excitation codebook size */
  35. #define PPCBSZ 32 /* pitch predictor codebook size */
  36. #define LGPORDER 8 /* Log-Gain Predictor OODER */
  37. #define LGPECBSZ 16 /* Log-Gain Prediction Error CodeBook SiZe */
  38. #define LSPPORDER 8 /* LSP MA Predictor ORDER */
  39. #define LSPECBSZ1 128 /* codebook size of 1st-stage LSP VQ */
  40. #define LSPECBSZ2 64 /* codebook size of 2nd-stage LSP VQ; 1-bit for sign */
  41. /* Excitation gain quantization */
  42. #define GPO 8 /* order of MA prediction */
  43. #define NG 18 /* number of relative gain bins */
  44. #define GLB -24. /* lower relative gain bound */
  45. #define NGC 12 /* number of gain change bins */
  46. #define GCLB -8. /* lower gain change bound */
  47. #define Minlg 0. /* minimum log-gain */
  48. #define TMinlg 1. /* minimum linear gain */
  49. #define LGCBSZ 16 /* size of codebook */
  50. /* Definitions for periodicity to gain scaling mapping */
  51. #define ScPLCGmin 1639 /* 0.1 Q14 */
  52. #define ScPLCGmax 14746 /* 0.9 Q14 */
  53. #define ScPLCG_b -32768 /* -2.0 in Q14 */
  54. #define ScPLCG_a 31129 /* 1.9 in Q14 */
  55. #define HoldPLCG 8
  56. #define AttnPLCG 50
  57. #define AttnFacPLCG 20971
  58. /* Level Estimation */
  59. #define estl_alpha 32760
  60. #define estl_alpha1 32640
  61. #define estl_beta 32704
  62. #define estl_beta1 64
  63. #define estl_a 32640
  64. #define estl_a1 128
  65. #define estl_TH 6554
  66. #define Nfdm 100 /* Max number of frames with fast decay of Lmin */
  67. /* Log-Gain Limitation */
  68. #define LGLB -24 /* Log-Gain Lower Bound */
  69. #define LGCLB -8 /* Log-Gain Change Lower Bound */
  70. #define NGB 18 /* Number of Gain Bins */
  71. #define NGCB 12 /* Number of Gain Change Bins */
  72. /* Buffer offsets and sizes */
  73. #define XOFF MAXPP1 /* offset for x() frame */
  74. #define LX (XOFF+FRSZ) /* Length of x() buffer */
  75. #define XQOFF (MAXPP1) /* xq() offset before current subframe */
  76. #define LXQ (XQOFF+FRSZ) /* Length of xq() buffer */
  77. #define LTMOFF (MAXPP1) /* Long-Term filter Memory OFFset */
  78. /* Long-term postfilter */
  79. #define DPPQNS 4 /* Delta pitch period for search */
  80. #define NINT 20 /* length of filter interpolation */
  81. #define ATHLD1 18022 /* 0.55 Q15 threshold on normalized pitch correlation */
  82. #define ATHLD2 26214 /* 0.80 Q15 threshold on normalized pitch correlation */
  83. #define ScLTPF 9830 /* 0.3 Q15 scaling of LTPF coefficient */
  84. /* Coarse pitch search */
  85. #define MAX_NPEAKS 7
  86. #define TH1 23921 /* first threshold for cor*cor/energy */
  87. #define TH2 13107 /* second threshold for cor*cor/energy */
  88. #define LPTH1 25887 /* Last Pitch cor*cor/energy THreshold 1 */
  89. #define LPTH2 14090 /* Last Pitch cor*cor/energy THreshold 2 */
  90. #define MPDTH 2130 /* Multiple Pitch Deviation THreshold */
  91. #define SMDTH 3113 /* Sub-Multiple pitch Deviation THreshold 0.125 */
  92. #define MPTH4 9830
  93. /* Decimation parameters */
  94. #define DECF 4 /* DECimation Factor for coarse pitch period search */
  95. #define FRSZD (FRSZ/DECF) /* FRame SiZe in DECF:1 lowband domain */
  96. #define MAXPPD (MAXPP/DECF) /* MAX Pitch in DECF:1, */
  97. #define MINPPD ((int)(MINPP/DECF)) /* MINimum Pitch Period in DECF:1 */
  98. #define PWSZD (PWSZ/DECF) /* Pitch ana Window SiZe in DECF:1 domain */
  99. #define DFO 4
  100. #define MAXPPD1 (MAXPPD+1)
  101. #define LXD (MAXPPD1+PWSZD)
  102. #define XDOFF (LXD-FRSZD)
  103. #define HMAXPPD (MAXPPD/2)
  104. #define M1 (MINPPD-1)
  105. #define M2 MAXPPD1
  106. #define HDECF (DECF/2)
  107. /* Front-end 150 Hz highpass filter */
  108. #define HPO 2 /* High-pass filter order */
  109. /* LPC weighting filter */
  110. #define LTWF 4096 /* 0.5 in Q13 perceptual Weighting Factor Lowband */
  111. /* pole-zero NFC shaping filter */
  112. #define NSTORDER 8
  113. #endif /* BV16CNST_H */