aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2018-11-08 22:07:14 +0100
committerPaul B Mahol <onemda@gmail.com>2018-11-08 22:07:14 +0100
commit36348d77b86a76041d09bbf876af6d267042b8bb (patch)
treeed1694a820c71261e583a70eb06bfbb3f4d7156e
parent698e67bef2ee76f317193e27f354c129b241332c (diff)
downloadffmpeg-36348d77b86a76041d09bbf876af6d267042b8bb.tar.gz
avfilter/af_afir: add minp/maxp options to control latency and speed
-rw-r--r--doc/filters.texi10
-rw-r--r--libavfilter/af_afir.c6
-rw-r--r--libavfilter/af_afir.h2
3 files changed, 16 insertions, 2 deletions
diff --git a/doc/filters.texi b/doc/filters.texi
index c99a384c29..d16a8b8b1b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1217,6 +1217,16 @@ Set video stream size. This option is used only when @var{response} is enabled.
@item rate
Set video stream frame rate. This option is used only when @var{response} is enabled.
+
+@item minp
+Set minimal partition size used for convolution. Default is @var{16}.
+Allowed range is from @var{16} to @var{65536}.
+Lower values decreases latency at cost of higher CPU usage.
+
+@item maxp
+Set maximal partition size used for convolution. Default is @var{65536}.
+Allowed range is from @var{16} to @var{65536}.
+Lower values decreases latency at cost of higher CPU usage.
@end table
@subsection Examples
diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index 624eab093f..f12049f7ba 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -310,8 +310,8 @@ static int convert_coeffs(AVFilterContext *ctx)
if (s->nb_taps <= 0)
return AVERROR(EINVAL);
- for (n = 4; (1 << n) < s->nb_taps; n++);
- N = FFMIN(n, 16);
+ for (n = av_log2(s->minp); (1 << n) < s->nb_taps; n++);
+ N = FFMIN(n, av_log2(s->maxp));
s->ir_length = 1 << n;
s->fft_length = (1 << (N + 1)) + 1;
s->part_size = 1 << (N - 1);
@@ -786,6 +786,8 @@ static const AVOption afir_options[] = {
{ "channel", "set IR channel to display frequency response", OFFSET(ir_channel), AV_OPT_TYPE_INT, {.i64=0}, 0, 1024, VF },
{ "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "hd720"}, 0, 0, VF },
{ "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT32_MAX, VF },
+ { "minp", "set min partition size", OFFSET(minp), AV_OPT_TYPE_INT, {.i64=16}, 16, 65536, AF },
+ { "maxp", "set max partition size", OFFSET(maxp), AV_OPT_TYPE_INT, {.i64=65536}, 16, 65536, AF },
{ NULL }
};
diff --git a/libavfilter/af_afir.h b/libavfilter/af_afir.h
index 3dc2f86f7e..f6727edf0e 100644
--- a/libavfilter/af_afir.h
+++ b/libavfilter/af_afir.h
@@ -46,6 +46,8 @@ typedef struct AudioFIRContext {
int w, h;
AVRational frame_rate;
int ir_channel;
+ int minp;
+ int maxp;
float gain;