-
Notifications
You must be signed in to change notification settings - Fork 0
/
filters.h
99 lines (91 loc) · 3.75 KB
/
filters.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* filters.h
*
* some filters for sequences of integers
*
* Copyright (C) 2019 <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef _FILTERS_H
#else
#define _FILTERS_H
/*
* outut status of filters
*/
struct status {
int ended;
int hasout;
int flush;
};
/*
* the filters
*/
void *read_init(char *filename, int ascii, struct status *status);
void *log_init(char *filename, int ascii, struct status *status);
void *scale_init(struct status *status);
void *diff_init(struct status *status);
void *amplify_init(double factor, struct status *status);
void *stabilize_init(struct status *status);
void *maximal_init(int size, struct status *status);
void *trigger_init(int bound, struct status *status);
void *background_init(struct status *status);
void *positive_init(struct status *status);
void *boost_init(int size, struct status *status);
void *valley_init(int size, struct status *status);
void *runlength_init(struct status *status);
void *collapse_init(struct status *status);
void *best_init(char *logfile, struct status *status);
int read_value(int value, void *internal, struct status *status);
int log_value(int value, void *internal, struct status *status);
int scale_value(int value, void *internal, struct status *status);
int diff_value(int value, void *internal, struct status *status);
int amplify_value(int value, void *internal, struct status *status);
int stabilize_value(int value, void *internal, struct status *status);
int maximal_value(int value, void *internal, struct status *status);
int trigger_value(int value, void *internal, struct status *status);
int background_value(int value, void *internal, struct status *status);
int positive_value(int value, void *internal, struct status *status);
int boost_value(int value, void *internal, struct status *status);
int valley_value(int value, void *internal, struct status *status);
int runlength_value(int value, void *internal, struct status *status);
int collapse_value(int value, void *internal, struct status *status);
int best_value(int value, void *internal, struct status *status);
int read_end(void *internal, struct status *status);
int log_end(void *internal, struct status *status);
int scale_end(void *internal, struct status *status);
int diff_end(void *internal, struct status *status);
int amplify_end(void *internal, struct status *status);
int stabilize_end(void *internal, struct status *status);
int maximal_end(void *internal, struct status *status);
int trigger_end(void *internal, struct status *status);
int background_end(void *internal, struct status *status);
int positive_end(void *internal, struct status *status);
int boost_end(void *internal, struct status *status);
int valley_end(void *internal, struct status *status);
int runlength_end(void *internal, struct status *status);
int collapse_end(void *internal, struct status *status);
int best_end(void *internal, struct status *status);
/*
* apply a filter
*/
#define FILTER_VALUE(filter, value, internal, status) { \
(status)->ended = 0; \
(status)->hasout = 1; \
(status)->flush = 0; \
value = filter ## _value (value, internal, status); \
if ((status)->ended) break; \
if (! (status)->hasout) continue; \
}
#endif