g721.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * This source code is a product of Sun Microsystems, Inc. and is provided
  3. * for unrestricted use. Users may copy or modify this source code without
  4. * charge.
  5. *
  6. * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
  7. * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  8. * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  9. *
  10. * Sun source code is provided with no support and without any obligation on
  11. * the part of Sun Microsystems, Inc. to assist in its use, correction,
  12. * modification or enhancement.
  13. *
  14. * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  15. * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
  16. * OR ANY PART THEREOF.
  17. *
  18. * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  19. * or profits or other special, indirect and consequential damages, even if
  20. * Sun has been advised of the possibility of such damages.
  21. *
  22. * Sun Microsystems, Inc.
  23. * 2550 Garcia Avenue
  24. * Mountain View, California 94043
  25. */
  26. /*
  27. * g72x.h
  28. *
  29. * Header file for CCITT conversion routines.
  30. *
  31. */
  32. #ifndef _G72X_H
  33. #define _G72X_H
  34. /*
  35. * The following is the definition of the state structure
  36. * used by the G.721/G.723 encoder and decoder to preserve their internal
  37. * state between successive calls. The meanings of the majority
  38. * of the state structure fields are explained in detail in the
  39. * CCITT Recommendation G.721. The field names are essentially identical
  40. * to variable names in the bit level description of the coding algorithm
  41. * included in this Recommendation.
  42. */
  43. struct g72x_state {
  44. long yl; /* Locked or steady state step size multiplier. */
  45. short yu; /* Unlocked or non-steady state step size multiplier. */
  46. short dms; /* Short term energy estimate. */
  47. short dml; /* Long term energy estimate. */
  48. short ap; /* Linear weighting coefficient of 'yl' and 'yu'. */
  49. short a[2]; /* Coefficients of pole portion of prediction filter. */
  50. short b[6]; /* Coefficients of zero portion of prediction filter. */
  51. short pk[2]; /*
  52. * Signs of previous two samples of a partially
  53. * reconstructed signal.
  54. */
  55. short dq[6]; /*
  56. * Previous 6 samples of the quantized difference
  57. * signal represented in an internal floating point
  58. * format.
  59. */
  60. short sr[2]; /*
  61. * Previous 2 samples of the quantized difference
  62. * signal represented in an internal floating point
  63. * format.
  64. */
  65. char td; /* delayed tone detect, new in 1988 version */
  66. };
  67. /* External function definitions. */
  68. void g72x_init_state(struct g72x_state*);
  69. int g721_encoder(int sample, struct g72x_state* state_ptr);
  70. int g721_decoder(int code, struct g72x_state* state_ptr);
  71. int quantize(int d, int y, short* table, int size);
  72. int reconstruct(int, int, int);
  73. void
  74. update(int code_size,
  75. int y,
  76. int wi,
  77. int fi,
  78. int dq,
  79. int sr,
  80. int dqsez,
  81. struct g72x_state* state_ptr);
  82. int predictor_zero(struct g72x_state* state_ptr);
  83. int predictor_pole(struct g72x_state* state_ptr);
  84. int step_size(struct g72x_state* state_ptr);
  85. #endif /* !_G72X_H */