comparison libtwamr/convolve.c @ 329:e230a4a87bd8

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