From: Paul B Mahol Date: Sat, 14 Apr 2018 15:25:06 +0000 (+0200) Subject: avfilter/af_headphone: improve performance and reduce latency X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=2b0f821f51d10ade2fa6d3efc33b09e594d0fcac;p=ffmpeg avfilter/af_headphone: improve performance and reduce latency Remove not needed code. Signed-off-by: Paul B Mahol --- diff --git a/doc/filters.texi b/doc/filters.texi index 30060ce9182..18a6da155c9 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3175,6 +3175,10 @@ Default is @var{freq}. @item lfe Set custom gain for LFE channels. Value is in dB. Default is 0. + +@item size +Set size of frame in number of samples which will be processed at once. +Default value is @var{1024}. Allowed range is from 1024 to 96000. @end table @subsection Examples diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c index 2188f7ab24f..974445e15cc 100644 --- a/libavfilter/af_headphone.c +++ b/libavfilter/af_headphone.c @@ -404,7 +404,7 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink) int i, j; s->buffer_length = 1 << (32 - ff_clz(s->ir_len)); - s->n_fft = n_fft = 1 << (32 - ff_clz(s->ir_len + inlink->sample_rate)); + s->n_fft = n_fft = 1 << (32 - ff_clz(s->ir_len + s->size)); if (s->type == FREQUENCY_DOMAIN) { fft_in_l = av_calloc(n_fft, sizeof(*fft_in_l)); @@ -650,12 +650,6 @@ static int config_input(AVFilterLink *inlink) AVFilterContext *ctx = inlink->dst; HeadphoneContext *s = ctx->priv; - if (s->type == FREQUENCY_DOMAIN) { - inlink->partial_buf_size = - inlink->min_samples = - inlink->max_samples = inlink->sample_rate; - } - if (s->nb_irs < inlink->channels) { av_log(ctx, AV_LOG_ERROR, "Number of inputs must be >= %d.\n", inlink->channels + 1); return AVERROR(EINVAL); @@ -719,11 +713,6 @@ static int config_output(AVFilterLink *outlink) AVFilterLink *inlink = ctx->inputs[0]; int i; - if (s->type == TIME_DOMAIN) - s->size = 1024; - else - s->size = inlink->sample_rate; - for (i = 0; i < s->nb_inputs; i++) { s->in[i].fifo = av_audio_fifo_alloc(ctx->inputs[i]->format, ctx->inputs[i]->channels, 1024); if (!s->in[i].fifo) @@ -798,6 +787,7 @@ static const AVOption headphone_options[] = { { "type", "set processing", OFFSET(type), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, .flags = FLAGS, "type" }, { "time", "time domain", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, .flags = FLAGS, "type" }, { "freq", "frequency domain", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, .flags = FLAGS, "type" }, + { "size", "set frame size", OFFSET(size), AV_OPT_TYPE_INT, {.i64=1024},1024,96000, .flags = FLAGS }, { NULL } };