bvcommon.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. bvcommon.h : Common Fixed-Point Library: common #defines and prototypes
  21. $Log$
  22. ******************************************************************************/
  23. #ifndef BVCOMMON_H
  24. #define BVCOMMON_H
  25. /* ----- Basic Codec Parameters ----- */
  26. #define LPCO 8 /* LPC Order for 8 kHz sampled lowband signal */
  27. #define Ngrd 60
  28. #define LSPMIN 49 /* 0.00150 minimum lsp frequency */
  29. #define LSPMAX 32694 /* 0.99775 maximum lsp frequency */
  30. #define DLSPMIN 410 /* 0.01250 minimum lsp spacing */
  31. #define STBLDIM 3 /* dimension of stability enforcement */
  32. /* LPC bandwidth expansion */
  33. extern Word16 bwel[];
  34. /* LPC to lsp Conversion */
  35. extern Word16 grid[];
  36. /* LPC WEIGHTING FILTER */
  37. extern Word16 STWAL[];
  38. /* Coarse Pitch Search */
  39. extern Word16 invk[];
  40. /* Pitch tap codebook - actually content different for BV16 and BV32 */
  41. extern Word16 pp9cb[];
  42. /* Function prototypes */
  43. void azfilter(
  44. Word16 a[], /* (i) Q12 : prediction coefficients */
  45. Word16 m, /* (i) : LPC order */
  46. Word16 x[], /* (i) Q0 : input signal samples, incl. past */
  47. Word16 y[], /* (o) Q0 : filtered output signal */
  48. Word16 lg /* (i) : size of filtering */
  49. );
  50. void apfilter(
  51. Word16 a[], /* (i) Q12 : prediction coefficients */
  52. Word16 m, /* (i) : LPC order */
  53. Word16 x[], /* (i) Q0 : input signal */
  54. Word16 y[], /* (o) Q0 : output signal */
  55. Word16 lg, /* (i) : size of filtering */
  56. Word16 mem[], /* (i/o) Q0: filter memory */
  57. Word16 update /* (i) : memory update flag */
  58. );
  59. void lsp2a(
  60. Word16 lsp[], /* (i) Q15 : line spectral frequencies */
  61. Word16 a[]); /* (o) Q12 : predictor coefficients (order = 10) */
  62. void stblz_lsp(
  63. Word16 *lsp, /* Q15 */
  64. Word16 order);
  65. Word16 stblchck(
  66. Word16 *x,
  67. Word16 vdim);
  68. void a2lsp(
  69. Word16 a[], /* (i) Q12 : predictor coefficients */
  70. Word16 lsp[], /* (o) Q15 : line spectral frequencies */
  71. Word16 old_lsp[]); /* (i) : old lsp[] (in case not found 10 roots) */
  72. void Autocorr(
  73. Word32 r[], /* (o) : Autocorrelations */
  74. Word16 x[], /* (i) : Input signal */
  75. Word16 window[],/* (i) : LPC Analysis window */
  76. Word16 l_window,/* (i) : window length */
  77. Word16 m); /* (i) : LPC order */
  78. void Spectral_Smoothing(
  79. Word16 m, /* (i) : LPC order */
  80. Word32 rl[], /* (i/o) : Autocorrelations lags */
  81. Word16 lag_h[], /* (i) : SST coefficients (msb) */
  82. Word16 lag_l[]); /* (i) : SST coefficients (lsb) */
  83. void Levinson(
  84. Word32 r32[], /* (i) : r32[] double precision vector of autocorrelation coefficients */
  85. Word16 a[], /* (o) : a[] in Q12 - LPC coefficients */
  86. Word16 old_a[], /* (i/o): old_a[] in Q12 - previous LPC coefficients */
  87. Word16 m); /* (i) : LPC order */
  88. void pp3dec(
  89. Word16 idx,
  90. Word16 *b);
  91. void vqdec(
  92. Word16 *xq,
  93. Word16 idx,
  94. Word16 *cb,
  95. Word16 vdim);
  96. #ifdef _MSC_VER
  97. #include "math.h"
  98. static __inline double round(double val)
  99. {
  100. return floor(val + 0.5);
  101. }
  102. #endif
  103. #endif /* BVCOMMON_H */