4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1992-2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #ifndef _MULTIMEDIA_FIR_H
28 #define _MULTIMEDIA_FIR_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
37 * Finite Impulse Response (FIR) filter object
39 * For every input sample, the FIR filter generates an output sample:
40 * output = coef[0] * input +
41 * coef[1] * state[order - 1] +
42 * coef[2] * state[order - 2] +
44 * coef[order] * state[0]
46 * and the filter states are updated:
50 * state[order - 2] = state[order - 1]
51 * state[order - 1] = input
55 int order
; // filter order, # taps = order + 1
56 double *coef
; // (order + 1) filter coeffs.
57 double *state
; // "order" filter states
58 int delay
; // actual delay between output & input
60 virtual void updateState(double *data
, int size
);
61 virtual void update_short(short *data
, int size
);
62 virtual int flush(short *out
);
64 virtual void resetState(void); // reset states to zero
68 virtual int getOrder(void); // get filter order value
69 virtual int getNumCoefs(void); // get number of coefficients
70 virtual void putCoef(double *coef_in
); // put coef_in in filter coef
71 virtual void getCoef(double *coef_out
); // get filter coef
72 // filter "size" input samples for "size" output samples
73 virtual int filter_noadjust(short *in
, int size
, short *out
);
75 * filter "size" input samples. Output sample sequence is offset by
76 * group delay samples to align with the input sample sequence.
77 * the first call of this routine returns "size - group_delay"
78 * output samples. Call this routine with size = 0
79 * to fill the output buffer such that the total number of output
80 * samples is equal to the number of input samples.
82 virtual int getFlushSize(void); // size of out[] for the last call
83 virtual int filter(short *in
, int size
, short *out
);
90 #endif /* !_MULTIMEDIA_FIR_H */