]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/af_headphone: improve performance and reduce latency
authorPaul B Mahol <onemda@gmail.com>
Sat, 14 Apr 2018 15:25:06 +0000 (17:25 +0200)
committerPaul B Mahol <onemda@gmail.com>
Sat, 14 Apr 2018 15:28:26 +0000 (17:28 +0200)
Remove not needed code.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
doc/filters.texi
libavfilter/af_headphone.c

index 30060ce9182c65183947bfe87295f9e6a4bb8aa5..18a6da155c9a6bf2d74b433d7e5a9d51c70f24e7 100644 (file)
@@ -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
index 2188f7ab24f565e7539b2eb8f467ffdfe4ccaef1..974445e15ccecc5e8bc5ff34d422bc77cdbf648e 100644 (file)
@@ -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 }
 };