OSDN Git Service

wwww
[proj16/16.git] / src / lib / doslib / ext / vorbtool / resample.h
1 /* This program is licensed under the GNU Library General Public License,
2  * version 2, a copy of which is included with this program (LICENCE.LGPL).
3  *   
4  * (c) 2002 Simon Hosie <gumboot@clear.net.nz>
5  *
6  *
7  * A resampler
8  *
9  * reference:
10  *     'Digital Filters', third edition, by R. W. Hamming  ISBN 0-486-65088-X
11  *
12  * history:
13  *    2002-05-31    ready for the world (or some small section thereof)
14  *
15  *
16  * TOOD:
17  *     zero-crossing clipping in coefficient table
18  */
19
20 #ifndef _RESAMPLE_H_INCLUDED
21 #define _RESAMPLE_H_INCLUDED
22
23 typedef float SAMPLE;
24
25 typedef struct
26 {
27     unsigned int channels, infreq, outfreq, taps;
28     float *table;
29     SAMPLE *pool;
30
31     /* dynamic bits */
32     int poolfill;
33     int offset;
34 } res_state;
35
36 typedef enum
37 {
38     RES_END,
39     RES_GAIN,    /* (double)1.0 */
40     RES_CUTOFF,    /* (double)0.80 */ 
41     RES_TAPS,    /* (int)45 */
42     RES_BETA    /* (double)16.0 */
43 } res_parameter;
44
45 int res_init(res_state *state, int channels, int outfreq, int infreq, res_parameter op1, ...);
46 /*
47  * Configure *state to manage a data stream with the specified parameters.  The
48  * string 'params' is currently unspecified, but will configure the parameters
49  * of the filter.
50  *
51  * This function allocates memory, and requires that res_clear() be called when
52  * the buffer is no longer needed.
53  *
54  *
55  * All counts/lengths used in the following functions consider only the data in
56  * a single channel, and in numbers of samples rather than bytes, even though
57  * functionality will be mirrored across as many channels as specified here.
58  */
59
60
61 int res_push_max_input(res_state const *state, size_t maxoutput);
62 /*
63  *  Returns the maximum number of input elements that may be provided without
64  *  risk of flooding an output buffer of size maxoutput.  maxoutput is
65  *  specified in counts of elements, NOT in bytes.
66  */
67
68
69 int res_push_check(res_state const *state, size_t srclen);
70 /*
71  * Returns the number of elements that will be returned if the given srclen
72  * is used in the next call to res_push().
73  */
74
75
76 int res_push(res_state *state, SAMPLE **dstlist, SAMPLE const **srclist, size_t srclen);
77 int res_push_interleaved(res_state *state, SAMPLE *dest, SAMPLE const *source, size_t srclen);
78 /*
79  * Pushes srclen samples into the front end of the filter, and returns the
80  * number of resulting samples.
81  *
82  * res_push(): srclist and dstlist point to lists of pointers, each of which
83  * indicates the beginning of a list of samples.
84  *
85  * res_push_interleaved(): source and dest point to the beginning of a list of
86  * interleaved samples.
87  */
88
89
90 int res_drain(res_state *state, SAMPLE **dstlist);
91 int res_drain_interleaved(res_state *state, SAMPLE *dest);
92 /*
93  * Recover the remaining elements by flushing the internal pool with 0 values,
94  * and storing the resulting samples.
95  *
96  * After either of these functions are called, *state should only re-used in a
97  * final call to res_clear().
98  */
99
100
101 void res_clear(res_state *state);
102 /*
103  * Free allocated buffers, etc.
104  */
105
106 #endif
107