Commit 6e05a11e authored by Paul B Mahol's avatar Paul B Mahol

avfilter/af_afir: make max IR length configurable

Also increase max allowed dry/wet value.
Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 68383594
......@@ -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.
@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
......
......@@ -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 }
};
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment