FreeCalypso > hg > gsm-codec-lib
comparison libgsmefr/convolve.c @ 53:49dd1ac8e75b
libgsmefr: import most *.c files from ETSI source
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Fri, 25 Nov 2022 16:18:21 +0000 |
| parents | |
| children | 8de2f0f9bd78 |
comparison
equal
deleted
inserted
replaced
| 52:988fd7ff514f | 53:49dd1ac8e75b |
|---|---|
| 1 /************************************************************************* | |
| 2 * | |
| 3 * FUNCTION: Convolve | |
| 4 * | |
| 5 * PURPOSE: | |
| 6 * Perform the convolution between two vectors x[] and h[] and | |
| 7 * write the result in the vector y[]. All vectors are of length L | |
| 8 * and only the first L samples of the convolution are computed. | |
| 9 * | |
| 10 * DESCRIPTION: | |
| 11 * The convolution is given by | |
| 12 * | |
| 13 * y[n] = sum_{i=0}^{n} x[i] h[n-i], n=0,...,L-1 | |
| 14 * | |
| 15 *************************************************************************/ | |
| 16 | |
| 17 #include "typedef.h" | |
| 18 #include "basic_op.h" | |
| 19 #include "count.h" | |
| 20 | |
| 21 void Convolve ( | |
| 22 Word16 x[], /* (i) : input vector */ | |
| 23 Word16 h[], /* (i) : impulse response */ | |
| 24 Word16 y[], /* (o) : output vector */ | |
| 25 Word16 L /* (i) : vector size */ | |
| 26 ) | |
| 27 { | |
| 28 Word16 i, n; | |
| 29 Word32 s; | |
| 30 | |
| 31 for (n = 0; n < L; n++) | |
| 32 { | |
| 33 s = 0; move32 (); | |
| 34 for (i = 0; i <= n; i++) | |
| 35 { | |
| 36 s = L_mac (s, x[i], h[n - i]); | |
| 37 } | |
| 38 s = L_shl (s, 3); | |
| 39 y[n] = extract_h (s); move16 (); | |
| 40 } | |
| 41 | |
| 42 return; | |
| 43 } |
