xine-lib  1.2.10
filter.h
Go to the documentation of this file.
1 /*=============================================================================
2  *
3  * This software has been released under the terms of the GNU Public
4  * license. See http://www.gnu.org/copyleft/gpl.html for details.
5  *
6  * Copyright 2001 Anders Johansson ajh@atri.curtin.edu.au
7  *
8  *=============================================================================
9  */
10 
11 #if !defined _DSP_H
12 # error "Never use <filter.h> directly; include <dsp.h> instead"
13 #endif
14 
15 #ifndef _FILTER_H
16 #define _FILTER_H 1
17 
18 /* Design and implementation of different types of digital filters */
19 
20 /* Flags used for filter design */
21 
22 /* Filter characteristics */
23 #define LP 0x00010000 /* Low pass */
24 #define HP 0x00020000 /* High pass */
25 #define BP 0x00040000 /* Band pass */
26 #define BS 0x00080000 /* Band stop */
27 #define TYPE_MASK 0x000F0000
28 
29 /* Window types */
30 #define BOXCAR 0x00000001
31 #define TRIANG 0x00000002
32 #define HAMMING 0x00000004
33 #define HANNING 0x00000008
34 #define BLACKMAN 0x00000010
35 #define FLATTOP 0x00000011
36 #define KAISER 0x00000012
37 #define WINDOW_MASK 0x0000001F
38 
39 /* Parallel filter design */
40 #define FWD 0x00000001 /* Forward indexing of polyphase filter */
41 #define REW 0x00000002 /* Reverse indexing of polyphase filter */
42 #define ODD 0x00000010 /* Make filter HP */
43 
44 /* Exported functions */
45 extern _ftype_t fir(unsigned int n, _ftype_t* w, _ftype_t* x);
46 
47 extern _ftype_t* pfir(unsigned int n, unsigned int k, unsigned int xi, _ftype_t** w, _ftype_t** x, _ftype_t* y, unsigned int s);
48 
49 extern int updateq(unsigned int n, unsigned int xi, _ftype_t* xq, _ftype_t* in);
50 extern int updatepq(unsigned int n, unsigned int k, unsigned int xi, _ftype_t** xq, _ftype_t* in, unsigned int s);
51 
52 extern int design_fir(unsigned int n, _ftype_t* w, _ftype_t* fc, unsigned int flags, _ftype_t opt);
53 
54 extern int design_pfir(unsigned int n, unsigned int k, _ftype_t* w, _ftype_t** pw, _ftype_t g, unsigned int flags);
55 extern void prewarp(_ftype_t* a, _ftype_t fc, _ftype_t fs);
56 void bilinear(_ftype_t* a, _ftype_t* b, _ftype_t* k, _ftype_t fs, _ftype_t *coef);
57 
58 extern int szxform(const _ftype_t* a, const _ftype_t* b, _ftype_t Q, _ftype_t fc, _ftype_t fs, _ftype_t *k, _ftype_t *coef);
59 
60 /* Add new data to circular queue designed to be used with a FIR
61  * filter. xq is the circular queue, in pointing at the new sample, xi
62  * current index for xq and n the length of the filter. xq must be n*2
63  * long.
64  */
65 #define updateq(n,xi,xq,in)\
66  xq[xi]=(xq)[(xi)+(n)]=*(in);\
67  xi=(++(xi))&((n)-1);
68 
69 #endif
triang
void triang(int n, float *w)
Definition: window.c:50
dsp.h
flattop
void flattop(int n, float *w)
Definition: window.c:129
design_pfir
int design_pfir(unsigned int n, unsigned int k, _ftype_t *w, _ftype_t **pw, _ftype_t g, unsigned int flags)
kaiser
void kaiser(int n, float *w, float b)
Definition: window.c:192
szxform
int szxform(const _ftype_t *a, const _ftype_t *b, _ftype_t Q, _ftype_t fc, _ftype_t fs, _ftype_t *k, _ftype_t *coef)
WINDOW_MASK
#define WINDOW_MASK
Definition: filter.h:37
ODD
#define ODD
Definition: filter.h:42
hanning
void hanning(int n, float *w)
Definition: window.c:71
HANNING
#define HANNING
Definition: filter.h:33
updatepq
int updatepq(unsigned int n, unsigned int d, unsigned int xi, float **xq, float *in, unsigned int s)
Definition: filter.c:70
REW
#define REW
Definition: filter.h:41
fir
_ftype_t fir(unsigned int n, _ftype_t *w, _ftype_t *x)
KAISER
#define KAISER
Definition: filter.h:36
updateq
#define updateq(n, xi, xq, in)
Definition: filter.h:65
szxform
int szxform(const float *a, const float *b, float Q, float fc, float fs, float *k, float *coef)
Definition: filter.c:417
pfir
float * pfir(unsigned int n, unsigned int d, unsigned int xi, float **w, float **x, float *y, unsigned int s)
Definition: filter.c:51
BS
#define BS
Definition: filter.h:26
bilinear
void bilinear(_ftype_t *a, _ftype_t *b, _ftype_t *k, _ftype_t fs, _ftype_t *coef)
blackman
void blackman(int n, float *w)
Definition: window.c:109
Q
#define Q
Definition: upmix.c:45
BP
#define BP
Definition: filter.h:25
HP
#define HP
Definition: filter.h:24
_ftype_t
#define _ftype_t
Definition: dsp.h:17
fir
float fir(register unsigned int n, float *w, float *x)
Definition: filter.c:30
prewarp
void prewarp(float *a, float fc, float fs)
Definition: filter.c:281
prewarp
void prewarp(_ftype_t *a, _ftype_t fc, _ftype_t fs)
design_pfir
int design_pfir(unsigned int n, unsigned int k, float *w, float **pw, float g, unsigned int flags)
Definition: filter.c:240
updatepq
int updatepq(unsigned int n, unsigned int k, unsigned int xi, _ftype_t **xq, _ftype_t *in, unsigned int s)
BOXCAR
#define BOXCAR
Definition: filter.h:30
FLATTOP
#define FLATTOP
Definition: filter.h:35
design_fir
int design_fir(unsigned int n, _ftype_t *w, _ftype_t *fc, unsigned int flags, _ftype_t opt)
LP
#define LP
Definition: filter.h:23
hamming
void hamming(int n, float *w)
Definition: window.c:90
BLACKMAN
#define BLACKMAN
Definition: filter.h:34
pfir
_ftype_t * pfir(unsigned int n, unsigned int k, unsigned int xi, _ftype_t **w, _ftype_t **x, _ftype_t *y, unsigned int s)
boxcar
void boxcar(int n, float *w)
Definition: window.c:30
TRIANG
#define TRIANG
Definition: filter.h:31
config.h
bilinear
void bilinear(float *a, float *b, float *k, float fs, float *coef)
Definition: filter.c:317
design_fir
int design_fir(unsigned int n, float *w, float *fc, unsigned int flags, float opt)
Definition: filter.c:100
HAMMING
#define HAMMING
Definition: filter.h:32