lpcenc.c
上传用户:zslianheng
上传日期:2013-04-03
资源大小:946k
文件大小:5k
源码类别:

Linux/Unix编程

开发平台:

Visual C++

  1. /*
  2. $Log: lpcenc.c,v $
  3. Revision 1.1.1.1  2002/07/28 05:23:31  freeman_yong
  4. lpc10 codec
  5.  * Revision 1.2  1996/08/20  20:31:21  jaf
  6.  * Removed all static local variables that were SAVE'd in the Fortran
  7.  * code, and put them in struct lpc10_encoder_state that is passed as an
  8.  * argument.
  9.  *
  10.  * Removed init function, since all initialization is now done in
  11.  * init_lpc10_encoder_state().
  12.  *
  13.  * Changed name of function from lpcenc_ to lpc10_encode, simply to make
  14.  * all lpc10 functions have more consistent naming with each other.
  15.  *
  16.  * Revision 1.1  1996/08/19  22:31:44  jaf
  17.  * Initial revision
  18.  *
  19. */
  20. #ifdef P_R_O_T_O_T_Y_P_E_S
  21. extern int lpcenc_(real *speech, integer *bits);
  22. extern int initlpcenc_(void);
  23. /*:ref: prepro_ 14 2 6 4 */
  24. /*:ref: analys_ 14 5 6 4 4 6 6 */
  25. /*:ref: encode_ 14 7 4 4 6 6 4 4 4 */
  26. /*:ref: chanwr_ 14 5 4 4 4 4 4 */
  27. /*:ref: initprepro_ 14 0 */
  28. /*:ref: initanalys_ 14 0 */
  29. #endif
  30. /*  -- translated by f2c (version 19951025).
  31.    You must link the resulting object file with the libraries:
  32. -lf2c -lm   (in that order)
  33. */
  34. #include "f2c.h"
  35. /* Table of constant values */
  36. static integer c__180 = 180;
  37. static integer c__10 = 10;
  38. /* ***************************************************************** */
  39. /* $Log: lpcenc.c,v $
  40. /* Revision 1.1.1.1  2002/07/28 05:23:31  freeman_yong
  41. /* lpc10 codec
  42. /*
  43.  * Revision 1.2  1996/08/20  20:31:21  jaf
  44.  * Removed all static local variables that were SAVE'd in the Fortran
  45.  * code, and put them in struct lpc10_encoder_state that is passed as an
  46.  * argument.
  47.  *
  48.  * Removed init function, since all initialization is now done in
  49.  * init_lpc10_encoder_state().
  50.  *
  51.  * Changed name of function from lpcenc_ to lpc10_encode, simply to make
  52.  * all lpc10 functions have more consistent naming with each other.
  53.  *
  54.  * Revision 1.1  1996/08/19  22:31:44  jaf
  55.  * Initial revision
  56.  * */
  57. /* Revision 1.2  1996/03/28  00:01:22  jaf */
  58. /* Commented out some trace statements. */
  59. /* Revision 1.1  1996/03/28  00:00:27  jaf */
  60. /* Initial revision */
  61. /* ***************************************************************** */
  62. /* Encode one frame of 180 speech samples to 54 bits. */
  63. /* Input: */
  64. /*  SPEECH - Speech encoded as real values in the range [-1,+1]. */
  65. /*           Indices 1 through 180 read, and modified (by PREPRO). */
  66. /* Output: */
  67. /*  BITS   - 54 encoded bits, stored 1 per array element. */
  68. /*           Indices 1 through 54 written. */
  69. /* This subroutine maintains local state from one call to the next.  If */
  70. /* you want to switch to using a new audio stream for this filter, or */
  71. /* reinitialize its state for any other reason, call the ENTRY */
  72. /* INITLPCENC. */
  73. /* Subroutine */ int lpc10_encode(real *speech, integer *bits,
  74.   struct lpc10_encoder_state *st)
  75. {
  76.     integer irms, voice[2], pitch, ipitv;
  77.     real rc[10];
  78.     extern /* Subroutine */ int encode_(integer *, integer *, real *, real *, 
  79.     integer *, integer *, integer *), chanwr_(integer *, integer *, 
  80.     integer *, integer *, integer *, struct lpc10_encoder_state *),
  81.             analys_(real *, integer *, 
  82.     integer *, real *, real *, struct lpc10_encoder_state *),
  83.             prepro_(real *, integer *, struct lpc10_encoder_state *);
  84.     integer irc[10];
  85.     real rms;
  86. /*       Arguments */
  87. /* $Log: lpcenc.c,v $
  88. /* Revision 1.1.1.1  2002/07/28 05:23:31  freeman_yong
  89. /* lpc10 codec
  90. /*
  91.  * Revision 1.2  1996/08/20  20:31:21  jaf
  92.  * Removed all static local variables that were SAVE'd in the Fortran
  93.  * code, and put them in struct lpc10_encoder_state that is passed as an
  94.  * argument.
  95.  *
  96.  * Removed init function, since all initialization is now done in
  97.  * init_lpc10_encoder_state().
  98.  *
  99.  * Changed name of function from lpcenc_ to lpc10_encode, simply to make
  100.  * all lpc10 functions have more consistent naming with each other.
  101.  *
  102.  * Revision 1.1  1996/08/19  22:31:44  jaf
  103.  * Initial revision
  104.  * */
  105. /* Revision 1.3  1996/03/29  22:03:47  jaf */
  106. /* Removed definitions for any constants that were no longer used. */
  107. /* Revision 1.2  1996/03/26  19:34:33  jaf */
  108. /* Added comments indicating which constants are not needed in an */
  109. /* application that uses the LPC-10 coder. */
  110. /* Revision 1.1  1996/02/07  14:43:51  jaf */
  111. /* Initial revision */
  112. /*   LPC Configuration parameters: */
  113. /* Frame size, Prediction order, Pitch period */
  114. /*       Local variables that need not be saved */
  115. /*       Uncoded speech parameters */
  116. /*       Coded speech parameters */
  117. /*       Local state */
  118. /*       None */
  119.     /* Parameter adjustments */
  120.     if (speech) {
  121. --speech;
  122. }
  123.     if (bits) {
  124. --bits;
  125. }
  126.     /* Function Body */
  127.     prepro_(&speech[1], &c__180, st);
  128.     analys_(&speech[1], voice, &pitch, &rms, rc, st);
  129.     encode_(voice, &pitch, &rms, rc, &ipitv, &irms, irc);
  130.     chanwr_(&c__10, &ipitv, &irms, irc, &bits[1], st);
  131.     return 0;
  132. } /* lpcenc_ */