44 int nb_samples,
int channels);
47 #define OFFSET(x) offsetof(AudioEchoContext, x)
48 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
65 for (p = item_str; *p; p++) {
72 static void fill_items(
char *item_str,
int *nb_items,
float *items)
74 char *p, *saveptr = NULL;
75 int i, new_nb_items = 0;
78 for (i = 0; i < *nb_items; i++) {
81 new_nb_items += sscanf(tstr,
"%f", &items[i]) == 1;
84 *nb_items = new_nb_items;
103 int nb_delays, nb_decays, i;
121 if (nb_delays != nb_decays) {
122 av_log(ctx,
AV_LOG_ERROR,
"Number of delays %d differs from number of decays %d.\n", nb_delays, nb_decays);
136 for (i = 0; i < nb_delays; i++) {
137 if (s->
delay[i] <= 0 || s->
delay[i] > 90000) {
181 #define MOD(a, b) (((a) >= (b)) ? (a) - (b) : (a))
183 #define ECHO(name, type, min, max) \
184 static void echo_samples_## name ##p(AudioEchoContext *ctx, \
185 uint8_t **delayptrs, \
186 uint8_t * const *src, uint8_t **dst, \
187 int nb_samples, int channels) \
189 const double out_gain = ctx->out_gain; \
190 const double in_gain = ctx->in_gain; \
191 const int nb_echoes = ctx->nb_echoes; \
192 const int max_samples = ctx->max_samples; \
193 int i, j, chan, av_uninit(index); \
195 av_assert1(channels > 0); \
197 for (chan = 0; chan < channels; chan++) { \
198 const type *s = (type *)src[chan]; \
199 type *d = (type *)dst[chan]; \
200 type *dbuf = (type *)delayptrs[chan]; \
202 index = ctx->delay_index; \
203 for (i = 0; i < nb_samples; i++, s++, d++) { \
207 out = in * in_gain; \
208 for (j = 0; j < nb_echoes; j++) { \
209 int ix = index + max_samples - ctx->samples[j]; \
210 ix = MOD(ix, max_samples); \
211 out += dbuf[ix] * ctx->decay[j]; \
215 *d = av_clipd(out, min, max); \
218 index = MOD(index + 1, max_samples); \
221 ctx->delay_index = index; \
224 ECHO(dbl,
double, -1.0, 1.0 )
225 ECHO(flt,
float, -1.0, 1.0 )
226 ECHO(s16, int16_t, INT16_MIN, INT16_MAX)
237 s->
samples[i] = s->
delay[i] * outlink->sample_rate / 1000.0;
239 volume += s->
decay[i];
250 "out_gain %f can cause saturation of output\n", s->
out_gain);
252 switch (outlink->format) {
288 if (frame != out_frame)
354 .priv_class = &aecho_class,