~ubuntu-branches/ubuntu/quantal/linphone/quantal

« back to all changes in this revision

Viewing changes to lpc10-1.5/difmag.c

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2004-06-30 13:58:16 UTC
  • Revision ID: james.westby@ubuntu.com-20040630135816-wwx75gdlodkqbabb
Tags: upstream-0.12.2
ImportĀ upstreamĀ versionĀ 0.12.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
$Log: difmag.c,v $
 
4
Revision 1.1.1.1  2001/11/19 19:50:14  smorlat
 
5
First cvs.
 
6
 
 
7
Revision 1.1.1.1  2001/08/08 21:29:08  simon
 
8
First import
 
9
 
 
10
 * Revision 1.1  1996/08/19  22:32:31  jaf
 
11
 * Initial revision
 
12
 *
 
13
 
 
14
*/
 
15
 
 
16
#ifdef P_R_O_T_O_T_Y_P_E_S
 
17
extern int difmag_(real *speech, integer *lpita, integer *tau, integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *maxptr);
 
18
#endif
 
19
 
 
20
/*  -- translated by f2c (version 19951025).
 
21
   You must link the resulting object file with the libraries:
 
22
        -lf2c -lm   (in that order)
 
23
*/
 
24
 
 
25
#include "f2c.h"
 
26
 
 
27
/* ********************************************************************** */
 
28
 
 
29
/*      DIFMAG Version 49 */
 
30
 
 
31
/* $Log: difmag.c,v $
 
32
/* Revision 1.1.1.1  2001/11/19 19:50:14  smorlat
 
33
/* First cvs.
 
34
/*
 
35
/* Revision 1.1.1.1  2001/08/08 21:29:08  simon
 
36
/* First import
 
37
/*
 
38
 * Revision 1.1  1996/08/19  22:32:31  jaf
 
39
 * Initial revision
 
40
 * */
 
41
/* Revision 1.3  1996/03/15  23:09:39  jaf */
 
42
/* Just added a few comments about which array indices of the arguments */
 
43
/* are used, and mentioning that this subroutine has no local state. */
 
44
 
 
45
/* Revision 1.2  1996/03/13  14:41:31  jaf */
 
46
/* Comments added explaining that none of the local variables of this */
 
47
/* subroutine need to be saved from one invocation to the next. */
 
48
 
 
49
/* Revision 1.1  1996/02/07 14:45:04  jaf */
 
50
/* Initial revision */
 
51
 
 
52
 
 
53
/* ********************************************************************* */
 
54
 
 
55
/*  Compute Average Magnitude Difference Function */
 
56
 
 
57
/* Inputs: */
 
58
/*  SPEECH - Low pass filtered speech */
 
59
/*           Indices MIN_N1 through MAX_N1+LPITA-1 are read, where */
 
60
/*      MIN_N1 = (MAXLAG - MAX_TAU)/2+1  MAX_TAU = max of TAU(I) for I=1,LTAU
 
61
*/
 
62
/*      MAX_N1 = (MAXLAG - MIN_TAU)/2+1  MIN_TAU = min of TAU(I) for I=1,LTAU
 
63
*/
 
64
/*  LPITA  - Length of speech buffer */
 
65
/*  TAU    - Table of lags */
 
66
/*           Indices 1 through LTAU read. */
 
67
/*  LTAU   - Number of lag values to compute */
 
68
/*  MAXLAG - Maximum possible lag value */
 
69
/* Outputs: */
 
70
/*  (All of these outputs are also read, but only after being written.) */
 
71
/*  AMDF   - Average Magnitude Difference for each lag in TAU */
 
72
/*           Indices 1 through LTAU written */
 
73
/*  MINPTR - Index of minimum AMDF value */
 
74
/*  MAXPTR - Index of maximum AMDF value */
 
75
 
 
76
/* This subroutine has no local state. */
 
77
 
 
78
/* Subroutine */ int difmag_(real *speech, integer *lpita, integer *tau, 
 
79
        integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *
 
80
        maxptr)
 
81
{
 
82
    /* System generated locals */
 
83
    integer i__1, i__2;
 
84
    real r__1;
 
85
 
 
86
    /* Local variables */
 
87
    integer i__, j, n1, n2;
 
88
    real sum;
 
89
 
 
90
/*       Arguments */
 
91
/*       Local variables that need not be saved */
 
92
/*       Local state */
 
93
/*       None */
 
94
    /* Parameter adjustments */
 
95
    --amdf;
 
96
    --tau;
 
97
    --speech;
 
98
 
 
99
    /* Function Body */
 
100
    *minptr = 1;
 
101
    *maxptr = 1;
 
102
    i__1 = *ltau;
 
103
    for (i__ = 1; i__ <= i__1; ++i__) {
 
104
        n1 = (*maxlag - tau[i__]) / 2 + 1;
 
105
        n2 = n1 + *lpita - 1;
 
106
        sum = 0.f;
 
107
        i__2 = n2;
 
108
        for (j = n1; j <= i__2; j += 4) {
 
109
            sum += (r__1 = speech[j] - speech[j + tau[i__]], abs(r__1));
 
110
        }
 
111
        amdf[i__] = sum;
 
112
        if (amdf[i__] < amdf[*minptr]) {
 
113
            *minptr = i__;
 
114
        }
 
115
        if (amdf[i__] > amdf[*maxptr]) {
 
116
            *maxptr = i__;
 
117
        }
 
118
    }
 
119
    return 0;
 
120
} /* difmag_ */
 
121