57 int nb_samples,
int channels);
60 #define OFFSET(x) offsetof(AudioPhaserContext, x)
61 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
122 void *
table,
int table_size,
123 double min,
double max,
double phase)
125 uint32_t i, phase_offset = phase /
M_PI / 2 * table_size + 0.5;
127 for (i = 0; i < table_size; i++) {
128 uint32_t point = (i + phase_offset) % table_size;
133 d = (sin((
double)point / table_size * 2 *
M_PI) + 1) / 2;
136 d = (double)point * 2 / table_size;
137 switch (4 * point / table_size) {
138 case 0: d = d + 0.5;
break;
140 case 2: d = 1.5 - d;
break;
141 case 3: d = d - 1.5;
break;
148 d = d * (max -
min) + min;
149 switch (sample_fmt) {
151 float *
fp = (
float *)table;
156 double *dp = (
double *)table;
162 d += d < 0 ? -0.5 : 0.5;
163 switch (sample_fmt) {
180 #define MOD(a, b) (((a) >= (b)) ? (a) - (b) : (a))
182 #define PHASER_PLANAR(name, type) \
183 static void phaser_## name ##p(AudioPhaserContext *p, \
184 uint8_t * const *src, uint8_t **dst, \
185 int nb_samples, int channels) \
187 int i, c, delay_pos, modulation_pos; \
189 av_assert0(channels > 0); \
190 for (c = 0; c < channels; c++) { \
191 type *s = (type *)src[c]; \
192 type *d = (type *)dst[c]; \
193 double *buffer = p->delay_buffer + \
194 c * p->delay_buffer_length; \
196 delay_pos = p->delay_pos; \
197 modulation_pos = p->modulation_pos; \
199 for (i = 0; i < nb_samples; i++, s++, d++) { \
200 double v = *s * p->in_gain + buffer[ \
201 MOD(delay_pos + p->modulation_buffer[ \
203 p->delay_buffer_length)] * p->decay; \
205 modulation_pos = MOD(modulation_pos + 1, \
206 p->modulation_buffer_length); \
207 delay_pos = MOD(delay_pos + 1, p->delay_buffer_length); \
208 buffer[delay_pos] = v; \
210 *d = v * p->out_gain; \
214 p->delay_pos = delay_pos; \
215 p->modulation_pos = modulation_pos; \
218 #define PHASER(name, type) \
219 static void phaser_## name (AudioPhaserContext *p, \
220 uint8_t * const *src, uint8_t **dst, \
221 int nb_samples, int channels) \
223 int i, c, delay_pos, modulation_pos; \
224 type *s = (type *)src[0]; \
225 type *d = (type *)dst[0]; \
226 double *buffer = p->delay_buffer; \
228 delay_pos = p->delay_pos; \
229 modulation_pos = p->modulation_pos; \
231 for (i = 0; i < nb_samples; i++) { \
232 int pos = MOD(delay_pos + p->modulation_buffer[modulation_pos], \
233 p->delay_buffer_length) * channels; \
236 delay_pos = MOD(delay_pos + 1, p->delay_buffer_length); \
237 npos = delay_pos * channels; \
238 for (c = 0; c < channels; c++, s++, d++) { \
239 double v = *s * p->in_gain + buffer[pos + c] * p->decay; \
241 buffer[npos + c] = v; \
243 *d = v * p->out_gain; \
246 modulation_pos = MOD(modulation_pos + 1, \
247 p->modulation_buffer_length); \
250 p->delay_pos = delay_pos; \
251 p->modulation_pos = modulation_pos; \
357 .priv_class = &aphaser_class,