Signed-off-by: Paul B Mahol
---
doc/filters.texi | 95 +++
libavfilter/Makefile | 2 +
libavfilter/af_declick.c | 699 +++
libavfilter/allfilters.c | 2 +
4 files changed, 798 insertions(+)
create mode 100644 libavfilter/af_declick.c
diff --git a/doc/filters.texi b/doc/filters.texi
index 7646efb918..7ba61135fd 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2576,6 +2576,101 @@ Optional. It should have a value much less than 1 (e.g.
0.05 or 0.02) and is
used to prevent clipping.
@end table
+@section declick
+Remove impulsive noise from input audio.
+
+Samples detected as impulsive noise are replaced by interpolated samples using
+autoregressive modeling.
+
+@table @option
+@item w
+Set window size, in milliseconds. Allowed range is from @code{10} to
@code{100}.
+Default value is @code{55} milliseconds.
+This sets size of window which will be processed at once.
+
+@item o
+Set window overlap, in percentage of window size. Allowed range is from
@code{50}
+to @code{95}. Default value is @code{75} percent.
+Setting this to very high value increases impulsive noise removal but makes
whole
+processs much slower.
+
+@item a
+Set autoregression order, in percentage of window size. Allowed range is from
+@code{0} to @code{25}. Default value is @code{2} percent. This option also
controls
+quality of interpolated samples using neighbour good samples.
+
+@item t
+Set threshold value. Allowed range is from @code{1} to @code{100}.
+Default value is @code{2}.
+This controls the strength of impulse noise which is going to be removed.
+
+@item b
+Set burst fusion, in percentage of window size. Allowed range is @code{0} to
+@code{40}. Default value is @code{10} percent.
+This controls between how much samples, which are detected as impulsive noise,
+any sample between 2 detected noise samples is considered also as noise sample.
+
+@item m
+Set overlap method.
+
+It accepts the following values:
+@table @option
+@item a
+Select overlap-add method. Clicks are best removed with this method.
+Even not interpolated samples are slightly changed with this method.
+
+@item s
+Select overlap-save method. Less effective method for impulsive noise
reduction,
+but not interpolated samples remain unchanged.
+@end table
+
+Default value is @code{a}.
+@end table
+
+@section declip
+Remove clipped samples from input audio.
+
+Samples detected as clipped are replaced by interpolated samples using
+autoregressive modeling.
+
+@table @option
+@item w
+Set window size, in milliseconds. Allowed range is from @code{10} to
@code{100}.
+Default value is @code{55} milliseconds.
+This sets size of window which will be processed at once.
+
+@item o
+Set window overlap, in percentage of window size. Allowed range is from
@code{50}
+to @code{95}. Default value is @code{75} percent.
+
+@item a
+Set autoregression order, in percentage of window size. Allowed range is from
+@code{0} to @code{25}. Default value is @code{8} percent. This option also
controls
+quality of interpolated samples using neighbour good samples.
+
+@item t
+Set threshold value. Allowed range is from @code{0.2} to @code{1.0}.
+Default value is @code{0.98}.
+Any sample which absolute value is equal or higher of this value will be
+detected as clipped and be replaced with interpolated value.
+
+@item m
+Set overlap method.
+
+It accepts the following values:
+@table @option
+@item a
+Select overlap-add method. Clips are best removed with this method.
+Even not interpolated samples are slightly changed with this method.
+
+@item s
+Select overlap-save method. Less effective method for clip reduction,
+but not interpolated samples remain unchanged.
+@end table
+
+Default value is @code{a}.
+@end table
+
@section drmeter
Measure audio dynamic range.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index f83a2b30ee..4fa9164429 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -89,6 +89,8 @@ OBJS-$(CONFIG_COMPENSATIONDELAY_FILTER) +=
af_compensationdelay.o
OBJS-$(CONFIG_CROSSFEED_FILTER) += af_crossfeed.o
OBJS-$(CONFIG_CRYSTALIZER_FILTER)+= af_crystalizer.o
OBJS-$(CONFIG_DCSHIFT_FILTER)+= af_dcshift.o
+OBJS-$(CONFIG_DECLICK_FILTER)+= af_declick.o
+OBJS-$(CONFIG_DECLIP_FILTER) += af_declick.o
OBJS-$(CONFIG_DRMETER_FILTER)+= af_drmeter.o
OBJS-$(CONFIG_DYNAUDNORM_FILTER) += af_dynaudnorm.o
OBJS-$(CONFIG_EARWAX_FILTER) += af_earwax.o
diff --git a/libavfilter/af_declick.c b/libavfilter/af_declick.c
new file mode 100644
index 00..93ca42c975
--- /dev/null
+++ b/libavfilter/af_declick.c
@@ -0,0 +1,699 @@
+/*
+ * Copyright (c) 2018 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by