annotate libtwamr/convolve.c @ 458:e26b974f7ba3

doc/AMR-study-utils: update for the current situation
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 10 May 2024 18:45:36 +0000
parents e230a4a87bd8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
329
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : convolve.c
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Perform the convolution between two vectors x[]
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 * : and h[] and write the result in the vector y[].
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 * : All vectors are of length L and only the first
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 * : L samples of the convolution are computed.
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 *
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 ********************************************************************************
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 */
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 /*
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 ********************************************************************************
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 * MODULE INCLUDE FILE AND VERSION ID
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 ********************************************************************************
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 */
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #include "namespace.h"
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 #include "convolve.h"
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 /*
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 ********************************************************************************
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 * INCLUDE FILES
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 ********************************************************************************
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 */
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "typedef.h"
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "basic_op.h"
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "no_count.h"
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 /*
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 ********************************************************************************
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 * LOCAL VARIABLES AND TABLES
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 ********************************************************************************
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 */
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 /*
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 ********************************************************************************
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 * PUBLIC PROGRAM CODE
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 ********************************************************************************
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 */
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 /*************************************************************************
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 *
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 * FUNCTION: Convolve
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 *
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 * PURPOSE:
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 * Perform the convolution between two vectors x[] and h[] and
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 * write the result in the vector y[]. All vectors are of length L
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 * and only the first L samples of the convolution are computed.
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 *
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 * DESCRIPTION:
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 * The convolution is given by
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 *
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 * y[n] = sum_{i=0}^{n} x[i] h[n-i], n=0,...,L-1
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 *
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 *************************************************************************/
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 void Convolve (
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 Word16 x[], /* (i) : input vector */
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 Word16 h[], /* (i) : impulse response */
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 Word16 y[], /* (o) : output vector */
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 Word16 L /* (i) : vector size */
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 )
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 {
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 Word16 i, n;
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 Word32 s;
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 for (n = 0; n < L; n++)
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 {
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 s = 0; move32 ();
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 for (i = 0; i <= n; i++)
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 {
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 s = L_mac (s, x[i], h[n - i]);
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 s = L_shl (s, 3);
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 y[n] = extract_h (s); move16 ();
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 }
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 return;
e230a4a87bd8 libtwamr: integrate convolve.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 }