[FFmpeg-cvslog] avfilter/af_headphone: improve performance and reduce latency
Paul B Mahol
git at videolan.org
Sat Apr 14 18:52:21 EEST 2018
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Apr 14 17:25:06 2018 +0200| [2b0f821f51d10ade2fa6d3efc33b09e594d0fcac] | committer: Paul B Mahol
avfilter/af_headphone: improve performance and reduce latency
Remove not needed code.
Signed-off-by: Paul B Mahol <onemda at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2b0f821f51d10ade2fa6d3efc33b09e594d0fcac
---
doc/filters.texi | 4 ++++
libavfilter/af_headphone.c | 14 ++------------
2 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 30060ce918..18a6da155c 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.
+
+ at 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 2188f7ab24..974445e15c 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 }
};
More information about the ffmpeg-cvslog
mailing list