c9eeb1bc2ddd8cd297ab07a2b0d6b56234227229
[platform/upstream/gst-plugins-good.git] / gst / audiofx / audiofxbasefirfilter.h
1 /* -*- c-basic-offset: 2 -*-
2  * 
3  * GStreamer
4  * Copyright (C) 1999-2001 Erik Walthinsen <omega@cse.ogi.edu>
5  *               2006 Dreamlab Technologies Ltd. <mathis.hofer@dreamlab.net>
6  *               2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  * 
23  */
24
25 #ifndef __GST_AUDIO_FX_BASE_FIR_FILTER_H__
26 #define __GST_AUDIO_FX_BASE_FIR_FILTER_H__
27
28 #include <gst/gst.h>
29 #include <gst/audio/gstaudiofilter.h>
30 #include <gst/fft/gstfftf64.h>
31
32 G_BEGIN_DECLS
33
34 #define GST_TYPE_AUDIO_FX_BASE_FIR_FILTER \
35   (gst_audio_fx_base_fir_filter_get_type())
36 #define GST_AUDIO_FX_BASE_FIR_FILTER(obj) \
37   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_FX_BASE_FIR_FILTER,GstAudioFXBaseFIRFilter))
38 #define GST_AUDIO_FX_BASE_FIR_FILTER_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_FX_BASE_FIR_FILTER,GstAudioFXBaseFIRFilterClass))
40 #define GST_IS_AUDIO_FX_BASE_FIR_FILTER(obj) \
41   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_FX_BASE_FIR_FILTER))
42 #define GST_IS_AUDIO_FX_BASE_FIR_FILTER_CLASS(klass) \
43   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_FX_BASE_FIR_FILTER))
44
45 typedef struct _GstAudioFXBaseFIRFilter GstAudioFXBaseFIRFilter;
46 typedef struct _GstAudioFXBaseFIRFilterClass GstAudioFXBaseFIRFilterClass;
47
48 typedef guint (*GstAudioFXBaseFIRFilterProcessFunc) (GstAudioFXBaseFIRFilter *, const guint8 *, guint8 *, guint);
49
50 /**
51  * GstAudioFXBaseFIRFilter:
52  *
53  * Opaque data structure.
54  */
55 struct _GstAudioFXBaseFIRFilter {
56   GstAudioFilter element;
57
58   /* properties */
59   gdouble *kernel;              /* filter kernel -- time domain */
60   guint kernel_length;          /* length of the filter kernel -- time domain */
61
62   guint64 latency;              /* pre-latency of the filter kernel */
63   gboolean low_latency;         /* work in slower low latency mode */
64
65   gboolean drain_on_changes;    /* If the filter should be drained when
66                                  * coeficients change */
67
68   /* < private > */
69   GstAudioFXBaseFIRFilterProcessFunc process;
70
71   gdouble *buffer;              /* buffer for storing samples of previous buffers */
72   guint buffer_fill;            /* fill level of buffer */
73   guint buffer_length;          /* length of the buffer -- meaning depends on processing mode */
74
75   /* FFT convolution specific data */
76   GstFFTF64 *fft;
77   GstFFTF64 *ifft;
78   GstFFTF64Complex *frequency_response;  /* filter kernel -- frequency domain */
79   guint frequency_response_length;       /* length of filter kernel -- frequency domain */
80   GstFFTF64Complex *fft_buffer;          /* FFT buffer, has the length of the frequency response */
81   guint block_length;                    /* Length of the processing blocks -- time domain */
82
83   GstClockTime start_ts;        /* start timestamp after a discont */
84   guint64 start_off;            /* start offset after a discont */
85   guint64 nsamples_out;         /* number of output samples since last discont */
86   guint64 nsamples_in;          /* number of input samples since last discont */
87 };
88
89 struct _GstAudioFXBaseFIRFilterClass {
90   GstAudioFilterClass parent_class;
91 };
92
93 GType gst_audio_fx_base_fir_filter_get_type (void);
94 void gst_audio_fx_base_fir_filter_set_kernel (GstAudioFXBaseFIRFilter *filter, gdouble *kernel, guint kernel_length, guint64 latency);
95 void gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter *filter);
96
97 G_END_DECLS
98
99 #endif /* __GST_AUDIO_FX_BASE_FIR_FILTER_H__ */