static int config_output(AVFilterLink *outlink) { AudioPhaserContext *p = outlink->src->priv; AVFilterLink *inlink = outlink->src->inputs[0]; p->delay_buffer_length = p->delay * 0.001 * inlink->sample_rate + 0.5; p->delay_buffer = av_calloc(p->delay_buffer_length, sizeof(*p->delay_buffer) * inlink->channels); p->modulation_buffer_length = inlink->sample_rate / p->speed + 0.5; p->modulation_buffer = av_malloc_array(p->modulation_buffer_length, sizeof(*p->modulation_buffer)); if (!p->modulation_buffer || !p->delay_buffer) return AVERROR(ENOMEM); ff_generate_wave_table(p->type, AV_SAMPLE_FMT_S32, p->modulation_buffer, p->modulation_buffer_length, 1., p->delay_buffer_length, M_PI / 2.0); p->delay_pos = p->modulation_pos = 0; switch (inlink->format) { case AV_SAMPLE_FMT_DBL: p->phaser = phaser_dbl; break; case AV_SAMPLE_FMT_DBLP: p->phaser = phaser_dblp; break; case AV_SAMPLE_FMT_FLT: p->phaser = phaser_flt; break; case AV_SAMPLE_FMT_FLTP: p->phaser = phaser_fltp; break; case AV_SAMPLE_FMT_S16: p->phaser = phaser_s16; break; case AV_SAMPLE_FMT_S16P: p->phaser = phaser_s16p; break; case AV_SAMPLE_FMT_S32: p->phaser = phaser_s32; break; case AV_SAMPLE_FMT_S32P: p->phaser = phaser_s32p; break; default: av_assert0(0); } return 0; }
static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; FlangerContext *s = ctx->priv; s->max_samples = (s->delay_min + s->delay_depth) * inlink->sample_rate + 2.5; s->lfo_length = inlink->sample_rate / s->speed; s->delay_last = av_calloc(inlink->channels, sizeof(*s->delay_last)); s->lfo = av_calloc(s->lfo_length, sizeof(*s->lfo)); if (!s->lfo || !s->delay_last) return AVERROR(ENOMEM); ff_generate_wave_table(s->wave_shape, AV_SAMPLE_FMT_FLT, s->lfo, s->lfo_length, floor(s->delay_min * inlink->sample_rate + 0.5), s->max_samples - 2., 3 * M_PI_2); return av_samples_alloc_array_and_samples(&s->delay_buffer, NULL, inlink->channels, s->max_samples, inlink->format, 0); }