1 /**
2 * @file filter.c
3 * @note Copyright (C) 2013 Miroslav Lichvar <mlichvar@redhat.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
20 #include "filter_private.h"
21 #include "mave.h"
22 #include "mmedian.h"
24 struct filter *filter_create(enum filter_type type, int length)
25 {
26 switch (type) {
27 case FILTER_MOVING_AVERAGE:
28 return mave_create(length);
29 case FILTER_MOVING_MEDIAN:
30 return mmedian_create(length);
31 default:
32 return NULL;
33 }
34 }
36 void filter_destroy(struct filter *filter)
37 {
38 filter->destroy(filter);
39 }
41 tmv_t filter_sample(struct filter *filter, tmv_t sample)
42 {
43 return filter->sample(filter, sample);
44 }
46 void filter_reset(struct filter *filter)
47 {
48 filter->reset(filter);
49 }