4 Revision 1.15 2004/06/26 03:50:14 markster
5 Merge source cleanups (bug #1911)
7 Revision 1.14 2003/02/12 13:59:15 matteo
8 mer feb 12 14:56:57 CET 2003
10 Revision 1.1.1.1 2003/02/12 13:59:15 matteo
11 mer feb 12 14:56:57 CET 2003
13 Revision 1.2 2000/01/05 08:20:40 markster
14 Some OSS fixes and a few lpc changes to make it actually work
16 * Revision 1.1 1996/08/19 22:30:26 jaf
22 /* -- translated by f2c (version 19951025).
23 You must link the resulting object file with the libraries:
24 -lf2c -lm (in that order)
29 #ifdef P_R_O_T_O_T_Y_P_E_S
30 extern int tbdm_(real *speech, integer *lpita, integer *tau, integer *ltau, real *amdf, integer *minptr, integer *maxptr, integer *mintau);
31 /*:ref: difmag_ 14 8 6 4 4 4 4 6 4 4 */
34 /* ********************************************************************** */
39 * Revision 1.15 2004/06/26 03:50:14 markster
40 * Merge source cleanups (bug #1911)
42 /* Revision 1.14 2003/02/12 13:59:15 matteo
43 /* mer feb 12 14:56:57 CET 2003
45 /* Revision 1.1.1.1 2003/02/12 13:59:15 matteo
46 /* mer feb 12 14:56:57 CET 2003
48 /* Revision 1.2 2000/01/05 08:20:40 markster
49 /* Some OSS fixes and a few lpc changes to make it actually work
51 * Revision 1.1 1996/08/19 22:30:26 jaf
54 /* Revision 1.3 1996/03/18 22:14:00 jaf */
55 /* Just added a few comments about which array indices of the arguments */
56 /* are used, and mentioning that this subroutine has no local state. */
58 /* Revision 1.2 1996/03/13 14:48:37 jaf */
59 /* Comments added explaining that none of the local variables of this */
60 /* subroutine need to be saved from one invocation to the next. */
62 /* Revision 1.1 1996/02/07 14:49:54 jaf */
63 /* Initial revision */
66 /* ********************************************************************* */
68 /*TURBO DIFMAG: Compute High Resolution Average Magnitude Difference Function
71 /* Note: There are several constants in here that appear to depend on a */
72 /* particular TAU table. That's not a problem for the LPC10 coder, but */
73 /* watch out if you change the contents of TAU in the subroutine ANALYS. */
76 /* SPEECH - Low pass filtered speech */
77 /* Indices 1 through MAX+LPITA-1 are read, where: */
78 /* MAX = (TAU(LTAU)-TAU(1))/2+1 */
79 /* (If TAU(1) .LT. 39, then larger indices could be read */
80 /* by the last call to DIFMAG below.) */
81 /* LPITA - Length of speech buffer */
82 /* TAU - Table of lags, sorted in increasing order. */
83 /* Indices 1 through LTAU read. */
84 /* LTAU - Number of lag values to compute */
86 /* AMDF - Average Magnitude Difference for each lag in TAU */
87 /* Indices 1 through LTAU written, and several might then be read.*/
88 /* MINPTR - Index of minimum AMDF value */
89 /* MAXPTR - Index of maximum AMDF value within +/- 1/2 octave of min */
90 /* MINTAU - Lag corresponding to minimum AMDF value */
92 /* This subroutine has no local state. */
94 /* Subroutine */ int tbdm_(real *speech, integer *lpita, integer *tau,
95 integer *ltau, real *amdf, integer *minptr, integer *maxptr, integer *
98 /* System generated locals */
99 integer i__1, i__2, i__3, i__4;
101 /* Local variables */
103 integer minp2, ltau2, maxp2, i__;
104 extern /* Subroutine */ int difmag_(real *, integer *, integer *, integer
105 *, integer *, real *, integer *, integer *);
106 integer minamd, ptr, tau2[6];
109 /* REAL SPEECH(LPITA+TAU(LTAU)), AMDF(LTAU) */
110 /* Stupid TOAST doesn't understand expressions */
111 /* Local variables that need not be saved */
114 /* Compute full AMDF using log spaced lags, find coarse minimum */
115 /* Parameter adjustments */
121 difmag_(&speech[1], lpita, &tau[1], ltau, &tau[*ltau], &amdf[1], minptr,
123 *mintau = tau[*minptr];
124 minamd = amdf[*minptr];
125 /* Build table containing all lags within +/- 3 of the AMDF minimum */
126 /* excluding all that have already been computed */
132 i__3 = *mintau + 3, i__4 = tau[*ltau] - 1;
133 i__2 = min(i__3,i__4);
134 for (i__ = max(i__1,41); i__ <= i__2; ++i__) {
135 while(tau[ptr] < i__) {
138 if (tau[ptr] != i__) {
140 tau2[ltau2 - 1] = i__;
143 /* Compute AMDF of the new lags, if there are any, and choose one */
144 /* if it is better than the coarse minimum */
146 difmag_(&speech[1], lpita, tau2, <au2, &tau[*ltau], amdf2, &minp2, &
148 if (amdf2[minp2 - 1] < (real) minamd) {
149 *mintau = tau2[minp2 - 1];
150 minamd = amdf2[minp2 - 1];
153 /* Check one octave up, if there are any lags not yet computed */
156 if ((i__ & 1) == 0) {
164 difmag_(&speech[1], lpita, tau2, <au2, &tau[*ltau], amdf2, &minp2, &
166 if (amdf2[minp2 - 1] < (real) minamd) {
167 *mintau = tau2[minp2 - 1];
168 minamd = amdf2[minp2 - 1];
172 /* Force minimum of the AMDF array to the high resolution minimum */
173 amdf[*minptr] = (real) minamd;
174 /* Find maximum of AMDF within 1/2 octave of minimum */
177 *maxptr = max(i__2,1);
180 i__2 = min(i__1,*ltau);
181 for (i__ = *maxptr + 1; i__ <= i__2; ++i__) {
182 if (amdf[i__] > amdf[*maxptr]) {