Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / cinelerra / resample.h
blobb95ae823502a96e932bf67c8aa9ed48b75432819
1 #ifndef RESAMPLE_H
2 #define RESAMPLE_H
4 #define BPC 160
5 #define BLACKSIZE 25
7 #include "file.inc"
9 class Resample
11 public:
12 Resample(File *file, int channels);
13 ~Resample();
15 // Reset after seeking
16 void reset(int channel = -1);
17 double blackman(int i, double offset, double fcn, int l);
18 // Query output temp
19 int get_output_size(int channel);
20 void read_output(double *output, int channel, int size);
21 // Resamples input and dumps it to output_temp
22 void resample_chunk(double *input,
23 long in_len,
24 int in_rate,
25 int out_rate,
26 int channel);
27 // Resample from the file handler and store in *output.
28 // Returns the total samples read from the file handler.
29 int resample(double *output,
30 long out_len,
31 int in_rate,
32 int out_rate,
33 int channel,
34 long in_position, // Starting sample in input samplerate
35 long out_position); // Starting sample in output samplerate
36 virtual void read_chunk(double *input,
37 long len,
38 int &reseek,
39 int iteration); // True once for every resample call
41 // History buffer for resampling.
42 double **old;
43 double *itime;
47 // Unaligned resampled output
48 double **output_temp;
51 // Total samples in unaligned output
52 // Tied to each channel independantly
53 long *output_size;
56 // Sample start of output_temp in the resampled domain.
57 long *output_temp_start;
58 // Allocation of unaligned output
59 long output_allocation;
60 // input chunk
61 double *input;
62 // Sample end of input chunks in the input domain.
63 long *input_chunk_end;
64 long input_size;
65 int channels;
66 int *resample_init;
67 // Last sample ratio configured to
68 double last_ratio;
69 double blackfilt[2 * BPC + 1][BLACKSIZE];
70 File *file;
71 // Determine whether to reset after a seek
72 // Sample end of last buffer read for each channel
73 long *last_out_end;
76 class Resample_float
78 public:
79 Resample_float(File *file, int channels);
80 ~Resample_float();
82 // Reset after seeking
83 void reset(int channel = -1);
84 float blackman(int i, float offset, float fcn, int l);
85 // Query output temp
86 int get_output_size(int channel);
87 void read_output(double *output, int channel, int size);
88 // Resamples input and dumps it to output_temp
89 void resample_chunk(float *input,
90 long in_len,
91 int in_rate,
92 int out_rate,
93 int channel);
94 // Resample from the file handler and store in *output.
95 // Returns the total samples read from the file handler.
96 int resample(double *output,
97 long out_len,
98 int in_rate,
99 int out_rate,
100 int channel,
101 long in_position, // Starting sample in input samplerate
102 long out_position); // Starting sample in output samplerate
103 virtual void read_chunk(float *input,
104 long len,
105 int &reseek,
106 int iteration); // True once for every resample call
108 // History buffer for resampling.
109 float **old;
110 float *itime;
114 // Unaligned resampled output
115 double **output_temp;
118 // Total samples in unaligned output
119 // Tied to each channel independantly
120 long *output_size;
123 // Sample start of output_temp in the resampled domain.
124 long *output_temp_start;
125 // Allocation of unaligned output
126 long output_allocation;
127 // input chunk
128 float *input;
129 // Sample end of input chunks in the input domain.
130 long *input_chunk_end;
131 long input_size;
132 int channels;
133 int *resample_init;
134 // Last sample ratio configured to
135 float last_ratio;
136 float blackfilt[2 * BPC + 1][BLACKSIZE];
137 File *file;
138 // Determine whether to reset after a seek
139 // Sample end of last buffer read for each channel
140 long *last_out_end;
143 #endif
145 // Local Variables:
146 // mode: C++
147 // c-file-style: "linux"
148 // End: