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

Linux/Unix编程

开发平台:

Visual C++

  1. /*
  2. $Log: placev.c,v $
  3. Revision 1.1.1.1  2002/07/28 05:23:43  freeman_yong
  4. lpc10 codec
  5.  * Revision 1.1  1996/08/19  22:31:02  jaf
  6.  * Initial revision
  7.  *
  8. */
  9. #ifdef P_R_O_T_O_T_Y_P_E_S
  10. extern int placev_(integer *osbuf, integer *osptr, integer *oslen, integer *obound, integer *vwin, integer *af, integer *lframe, integer *minwin, integer *maxwin, integer *dvwinl, integer *dvwinh);
  11. #endif
  12. /*  -- translated by f2c (version 19951025).
  13.    You must link the resulting object file with the libraries:
  14. -lf2c -lm   (in that order)
  15. */
  16. #include "f2c.h"
  17. /* ****************************************************************** */
  18. /*  PLACEV Version 48 */
  19. /* $Log: placev.c,v $
  20. /* Revision 1.1.1.1  2002/07/28 05:23:43  freeman_yong
  21. /* lpc10 codec
  22. /*
  23.  * Revision 1.1  1996/08/19  22:31:02  jaf
  24.  * Initial revision
  25.  * */
  26. /* Revision 1.6  1996/03/19  20:42:19  jaf */
  27. /* Added some conditions satisfied by the output values in VWIN. */
  28. /* Revision 1.5  1996/03/19  18:37:56  jaf */
  29. /* Strengthened the specification of which indices of VWIN are read and */
  30. /* written. */
  31. /* Revision 1.4  1996/03/15  16:38:33  jaf */
  32. /* One tiny comment added. */
  33. /* Revision 1.3  1996/03/15  16:36:13  jaf */
  34. /* Added comments giving In/Out status of arguments. */
  35. /* Revision 1.2  1996/03/12  23:56:01  jaf */
  36. /* Comments added explaining that none of the local variables of this */
  37. /* subroutine need to be saved from one invocation to the next. */
  38. /* Revision 1.1  1996/02/07 14:48:39  jaf */
  39. /* Initial revision */
  40. /* ****************************************************************** */
  41. /* Input: */
  42. /*  OSBUF Buffer which holds sorted indexes of onsets */
  43. /*        I believe that only indices 1 through OSPTR-1 can be read. */
  44. /*  OSLEN */
  45. /*  OSPTR Free pointer into OSBUF */
  46. /*  AF */
  47. /*  LFRAME */
  48. /*  MINWIN */
  49. /*  MAXWIN */
  50. /*  DVWINL */
  51. /*  DVWINH (This argument is never used.  Should it be?) */
  52. /* Input/Output: */
  53. /*  VWIN Buffer of Voicing Window Positions (Modified) */
  54. /*        Index (2,AF-1) is read. */
  55. /*        Indices (1,AF) and (2,AF) are written, */
  56. /*        and then possibly read. */
  57. /*        All other indices are unused. */
  58. /*              In all cases, the final values will satsify the condition:*/
  59. /*               VWIN(2,AF)-VWIN(1,AF)+1 .LE. MAXWIN */
  60. /*               I'm not certain yet, but they may also satisfy: */
  61. /*               MINWIN .LE. VWIN(2,AF)-VWIN(1,AF)+1 */
  62. /* Output: */
  63. /*  OBOUND This variable is set by this procedure and used */
  64. /*  in placing analysis windows (PLACEA).  Bit 1 */
  65. /*  indicates whether an onset bounds the left side */
  66. /*  of the voicing window, and bit 2 indicates whether */
  67. /*  an onset bounds the right side of the voicing window. */
  68. /* This subroutine has no local state. */
  69. /* Subroutine */ int placev_(integer *osbuf, integer *osptr, integer *oslen, 
  70. integer *obound, integer *vwin, integer *af, integer *lframe, integer 
  71. *minwin, integer *maxwin, integer *dvwinl, integer *dvwinh)
  72. {
  73.     /* System generated locals */
  74.     integer i__1, i__2;
  75.     /* Local variables */
  76.     logical crit;
  77.     integer i__, q, osptr1, hrange, lrange;
  78. /*       Arguments */
  79. /*       Local variables that need not be saved */
  80. /*   Variables */
  81. /*    LRANGE, HRANGE  Range in which window is placed */
  82. /*    OSPTR1     OSPTR excluding samples in 3F */
  83. /*       Local state */
  84. /*       None */
  85. /*   Voicing Window Placement */
  86. /*         __________________ __________________ ______________ */
  87. /*        |                  |                  | */
  88. /*        |        1F        |        2F        |        3F ... */
  89. /*        |__________________|__________________|______________ */
  90. /*    Previous | */
  91. /*      Window | */
  92. /*  ...________| */
  93. /*             |                                | */
  94. /*      ------>| This window's placement range  |<------ */
  95. /*             |                                | */
  96. /*   There are three cases.  Note that these are different from those */
  97. /*   given in the LPC-10e phase 1 report. */
  98. /*   1.  If there are no onsets in this range, then the voicing window */
  99. /*   is centered in the pitch window.  If such a placement is not within 
  100. */
  101. /*   the window's placement range, then the window is placed in the left- 
  102. */
  103. /*   most portion of the placement range.  Its length is always MAXWIN. */
  104. /*   2.  If the first onset is in 2F and there is sufficient room to place
  105.  */
  106. /*   the window immediately before this onset, then the window is placed 
  107. */
  108. /*   there, and its length is set to the maximum possible under these */
  109. /*   constraints. */
  110. /*  "Critical Region Exception":  If there is another onset in 2F */
  111. /*  such that a window can be placed between the two onsets, the */
  112. /*  window is placed there (ie, as in case 3). */
  113. /*   3.  Otherwise, the window is placed immediately after the onset.  The
  114.  */
  115. /*   window's length */
  116. /*  is the longest length that can fit in the range under these constraint
  117. s,*/
  118. /*  except that the window may be shortened even further to avoid overlapp
  119. ing*/
  120. /*  other onsets in the placement range.  In any case, the window's length
  121. */
  122. /*   is at least MINWIN. */
  123. /*   Note that the values of MINWIN and LFRAME must be chosen such */
  124. /*   that case 2 = false implies case 3 = true.   This means that */
  125. /*   MINWIN <= LFRAME/2.  If this were not the case, then a fourth case */
  126. /*   would have to be added for when the window cannot fit either before 
  127. */
  128. /*   or after the onset. */
  129. /*   Note also that onsets which weren't in 2F last time may be in 1F this
  130.  */
  131. /*  time, due to the filter delays in computing onsets.  The result is tha
  132. t*/
  133. /*   occasionally a voicing window will overlap that onset.  The only way 
  134. */
  135. /*   to circumvent this problem is to add more delay in processing input 
  136. */
  137. /*   speech.  In the trade-off between delay and window-placement, window 
  138. */
  139. /*   placement lost. */
  140. /* Compute the placement range */
  141.     /* Parameter adjustments */
  142.     --osbuf;
  143.     vwin -= 3;
  144.     /* Function Body */
  145. /* Computing MAX */
  146.     i__1 = vwin[(*af - 1 << 1) + 2] + 1, i__2 = (*af - 2) * *lframe + 1;
  147.     lrange = max(i__1,i__2);
  148.     hrange = *af * *lframe;
  149. /* Compute OSPTR1, so the following code only looks at relevant onsets. */
  150.     for (osptr1 = *osptr - 1; osptr1 >= 1; --osptr1) {
  151. if (osbuf[osptr1] <= hrange) {
  152.     goto L90;
  153. }
  154.     }
  155. L90:
  156.     ++osptr1;
  157. /* Check for case 1 first (fast case): */
  158.     if (osptr1 <= 1 || osbuf[osptr1 - 1] < lrange) {
  159. /* Computing MAX */
  160. i__1 = vwin[(*af - 1 << 1) + 2] + 1;
  161. vwin[(*af << 1) + 1] = max(i__1,*dvwinl);
  162. vwin[(*af << 1) + 2] = vwin[(*af << 1) + 1] + *maxwin - 1;
  163. *obound = 0;
  164.     } else {
  165. /* Search backward in OSBUF for first onset in range. */
  166. /* This code relies on the above check being performed first. */
  167. for (q = osptr1 - 1; q >= 1; --q) {
  168.     if (osbuf[q] < lrange) {
  169. goto L100;
  170.     }
  171. }
  172. L100:
  173. ++q;
  174. /* Check for case 2 (placement before onset): */
  175. /* Check for critical region exception: */
  176. i__1 = osptr1 - 1;
  177. for (i__ = q + 1; i__ <= i__1; ++i__) {
  178.     if (osbuf[i__] - osbuf[q] >= *minwin) {
  179. crit = TRUE_;
  180. goto L105;
  181.     }
  182. }
  183. crit = FALSE_;
  184. L105:
  185. /* Computing MAX */
  186. i__1 = (*af - 1) * *lframe, i__2 = lrange + *minwin - 1;
  187. if (! crit && osbuf[q] > max(i__1,i__2)) {
  188.     vwin[(*af << 1) + 2] = osbuf[q] - 1;
  189. /* Computing MAX */
  190.     i__1 = lrange, i__2 = vwin[(*af << 1) + 2] - *maxwin + 1;
  191.     vwin[(*af << 1) + 1] = max(i__1,i__2);
  192.     *obound = 2;
  193. /* Case 3 (placement after onset) */
  194. } else {
  195.     vwin[(*af << 1) + 1] = osbuf[q];
  196. L110:
  197.     ++q;
  198.     if (q >= osptr1) {
  199. goto L120;
  200.     }
  201.     if (osbuf[q] > vwin[(*af << 1) + 1] + *maxwin) {
  202. goto L120;
  203.     }
  204.     if (osbuf[q] < vwin[(*af << 1) + 1] + *minwin) {
  205. goto L110;
  206.     }
  207.     vwin[(*af << 1) + 2] = osbuf[q] - 1;
  208.     *obound = 3;
  209.     return 0;
  210. L120:
  211. /* Computing MIN */
  212.     i__1 = vwin[(*af << 1) + 1] + *maxwin - 1;
  213.     vwin[(*af << 1) + 2] = min(i__1,hrange);
  214.     *obound = 1;
  215. }
  216.     }
  217.     return 0;
  218. } /* placev_ */