blob: e9794da506cd855aaf3124cd61057dda29eb8261 [file] [log] [blame]
Bill Yi4e213d52015-06-23 13:53:11 -07001.TH DSP 3
2.SH NAME
3initdp, freedp, dotprod, sumsq, peakval -\ SIMD-assisted
4digital signal processing primitives
5.SH SYNOPSIS
6.nf
7.ft
8#include "fec.h"
9
10void *initdp(signed short *coeffs,int len);
11long dotprod(void *p,signed short *a);
12void freedp(void *p);
13
14unsigned long long sumsq(signed short *in,int cnt);
15
16int peakval(signed short *b,int cnt);
17
18.SH DESCRIPTION
19These functions provide several basic primitives useful in digital
20signal processing (DSP), especially in modems. The \fBinitdp\fR,
21\fBdotprod\fR and \fBfreedp\fR functions implement an integer dot
22product useful in correlation and filtering operations on signed
2316-bit integers. \fBsumsq\fR computes the sum
24of the squares of an array of signed 16-bit integers,
25useful for measuring the energy of a signal. \fBpeakval\fR returns the
26absolute value of the largest magitude element in the input array,
27useful for scaling a signal's amplitude.
28
29Each function uses IA32 or PowerPC Altivec instructions when
30available; otherwise, a portable C version is used.
31
32.SH USAGE
33To create a FIR filter or correlator, call \fBinitdp\fR with the
34coefficients in \fBcoeff\fR and their number in \fBlen\fR. This
35creates the appropriate data structures and returns a handle.
36
37To compute a dot product, pass the handle from \fBinitdp\fR and the
38input array to \fBdotprod\fR. No length field is needed as the number
39of samples will be taken from the \fBlen\fR parameter originally given
40to \fBinitdp\fR. There must be at least as many samples in the input
41array as there were coefficients passed to \fBinitdp\fR.
42
43When the filter or correlator is no longer needed, the data structures
44may be freed by passing the handle to \fBfreedp\fR.
45
46The user is responsible for scaling the inputs to \fBinitdp\fR and
47\fBdotprod\fR, as the 32-bit result from \fBdotprod\fR will silently
48wrap around in the event of overflow.
49
50To compute the sum of the squares of an array of signed 16-bit
51integers, use sumsq\fR. This returns a 64 bit sum.
52
53\fBpeakval\fR computes the absolute value of each 16-bit element in
54the input array and returns the largest.
55
56.SH RETURN VALUES
57
58\fBinitdp\fR returns a handle that points to a control block, or NULL in
59the event of an error (such as a memory allocation failure). \fBsumsq\fR
60and \fBpeakval\fR have no error returns.
61
62.SH AUTHOR and COPYRIGHT
63Phil Karn, KA9Q (karn@ka9q.net)