[FFmpeg-cvslog] avfilter/af_afir: make max IR length configurable
Paul B Mahol
git at videolan.org
Mon Apr 16 20:13:18 EEST 2018
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Apr 16 19:06:09 2018 +0200| [6e05a11e8968d1781cc60666aa130520259cc1b1] | committer: Paul B Mahol
avfilter/af_afir: make max IR length configurable
Also increase max allowed dry/wet value.
Signed-off-by: Paul B Mahol <onemda at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6e05a11e8968d1781cc60666aa130520259cc1b1
---
doc/filters.texi | 4 ++++
libavfilter/af_afir.c | 11 ++++++-----
libavfilter/af_afir.h | 3 +--
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index f267d26b9d..fc82ad4eb2 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -959,6 +959,10 @@ Set Impulse Response filter length. Default is 1, which means whole IR is proces
@item again
Enable applying gain measured from power of IR.
+
+ at item maxir
+Set max allowed Impulse Response filter duration in seconds. Default is 30 seconds.
+Allowed range is 0.1 to 60 seconds.
@end table
@subsection Examples
diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index 6687242631..9318484cd0 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -290,7 +290,7 @@ static int read_ir(AVFilterLink *link, AVFrame *frame)
return ret;
nb_taps = av_audio_fifo_size(s->fifo[1]);
- max_nb_taps = MAX_IR_DURATION * ctx->outputs[0]->sample_rate;
+ max_nb_taps = s->max_ir_len * ctx->outputs[0]->sample_rate;
if (nb_taps > max_nb_taps) {
av_log(ctx, AV_LOG_ERROR, "Too big number of coefficients: %d > %d.\n", nb_taps, max_nb_taps);
return AVERROR(EINVAL);
@@ -533,10 +533,11 @@ static const AVFilterPad afir_outputs[] = {
#define OFFSET(x) offsetof(AudioFIRContext, x)
static const AVOption afir_options[] = {
- { "dry", "set dry gain", OFFSET(dry_gain), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 1, AF },
- { "wet", "set wet gain", OFFSET(wet_gain), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 1, AF },
- { "length", "set IR length", OFFSET(length), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 1, AF },
- { "again", "enable auto gain", OFFSET(again), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, AF },
+ { "dry", "set dry gain", OFFSET(dry_gain), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 10, AF },
+ { "wet", "set wet gain", OFFSET(wet_gain), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 10, AF },
+ { "length", "set IR length", OFFSET(length), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 1, AF },
+ { "again", "enable auto gain", OFFSET(again), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, AF },
+ { "maxir", "set max ir length", OFFSET(max_ir_len), AV_OPT_TYPE_FLOAT, {.dbl=30}, 0.1, 60, AF },
{ NULL }
};
diff --git a/libavfilter/af_afir.h b/libavfilter/af_afir.h
index aaeb66536f..7712e6ada8 100644
--- a/libavfilter/af_afir.h
+++ b/libavfilter/af_afir.h
@@ -32,8 +32,6 @@
#include "formats.h"
#include "internal.h"
-#define MAX_IR_DURATION 30
-
typedef struct AudioFIRContext {
const AVClass *class;
@@ -41,6 +39,7 @@ typedef struct AudioFIRContext {
float dry_gain;
float length;
int again;
+ float max_ir_len;
float gain;
More information about the ffmpeg-cvslog
mailing list