43 int nb_samples,
int channels);
46 #define OFFSET(x) offsetof(AudioEchoContext, x)
47 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
64 for (p = item_str; *p; p++) {
71 static void fill_items(
char *item_str,
int *nb_items,
float *items)
73 char *p, *saveptr = NULL;
74 int i, new_nb_items = 0;
77 for (i = 0; i < *nb_items; i++) {
80 new_nb_items += sscanf(tstr,
"%f", &items[i]) == 1;
83 *nb_items = new_nb_items;
102 int nb_delays, nb_decays, i;
120 if (nb_delays != nb_decays) {
121 av_log(ctx,
AV_LOG_ERROR,
"Number of delays %d differs from number of decays %d.\n", nb_delays, nb_decays);
135 for (i = 0; i < nb_delays; i++) {
136 if (s->
delay[i] <= 0 || s->
delay[i] > 90000) {
180 #define MOD(a, b) (((a) >= (b)) ? (a) - (b) : (a))
182 #define ECHO(name, type, min, max) \
183 static void echo_samples_## name ##p(AudioEchoContext *ctx, \
184 uint8_t **delayptrs, \
185 uint8_t * const *src, uint8_t **dst, \
186 int nb_samples, int channels) \
188 const double out_gain = ctx->out_gain; \
189 const double in_gain = ctx->in_gain; \
190 const int nb_echoes = ctx->nb_echoes; \
191 const int max_samples = ctx->max_samples; \
192 int i, j, chan, av_uninit(index); \
194 av_assert1(channels > 0); \
196 for (chan = 0; chan < channels; chan++) { \
197 const type *s = (type *)src[chan]; \
198 type *d = (type *)dst[chan]; \
199 type *dbuf = (type *)delayptrs[chan]; \
201 index = ctx->delay_index; \
202 for (i = 0; i < nb_samples; i++, s++, d++) { \
206 out = in * in_gain; \
207 for (j = 0; j < nb_echoes; j++) { \
208 int ix = index + max_samples - ctx->samples[j]; \
209 ix = MOD(ix, max_samples); \
210 out += dbuf[ix] * ctx->decay[j]; \
214 *d = av_clipd(out, min, max); \
217 index = MOD(index + 1, max_samples); \
220 ctx->delay_index = index; \
223 ECHO(dbl,
double, -1.0, 1.0 )
224 ECHO(flt,
float, -1.0, 1.0 )
225 ECHO(s16, int16_t, INT16_MIN, INT16_MAX)
236 s->
samples[i] = s->
delay[i] * outlink->sample_rate / 1000.0;
238 volume += s->
decay[i];
249 "out_gain %f can cause saturation of output\n", s->
out_gain);
251 switch (outlink->format) {
289 if (
frame != out_frame)
354 .priv_class = &aecho_class,