aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/af_silenceremove.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2023-05-28 17:37:55 +0200
committerPaul B Mahol <onemda@gmail.com>2023-05-29 11:47:10 +0200
commitf02964aee1ed06ac4a67103904d5fae2862fa45e (patch)
tree9b8287adb5aa73acdaec4fadee3b1b618292c728 /libavfilter/af_silenceremove.c
parentaa4acc111e6ea1117dfec230435fdb26ec7631d9 (diff)
downloadffmpeg-f02964aee1ed06ac4a67103904d5fae2862fa45e.tar.gz
avfilter/af_silenceremove: add standard deviation detector
Useful in cases audio samples DC offset is not ~0.0, where other detectors will fail to detect silence.
Diffstat (limited to 'libavfilter/af_silenceremove.c')
-rw-r--r--libavfilter/af_silenceremove.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavfilter/af_silenceremove.c b/libavfilter/af_silenceremove.c
index c7975a9365..4cb662080b 100644
--- a/libavfilter/af_silenceremove.c
+++ b/libavfilter/af_silenceremove.c
@@ -38,6 +38,7 @@ enum SilenceDetect {
D_PEAK,
D_MEDIAN,
D_PTP,
+ D_DEV,
D_NB
};
@@ -146,6 +147,7 @@ static const AVOption silenceremove_options[] = {
{ "peak", "use max absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_PEAK},0, 0, AF, "detection" },
{ "median", "use median of absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_MEDIAN},0, 0, AF, "detection" },
{ "ptp", "use absolute of max peak to min peak difference", 0, AV_OPT_TYPE_CONST, {.i64=D_PTP}, 0, 0, AF, "detection" },
+ { "dev", "use standard deviation from values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_DEV}, 0, 0, AF, "detection" },
{ "window", "set duration of window for silence detection", OFFSET(window_duration_opt), AV_OPT_TYPE_DURATION, {.i64=20000}, 0, 100000000, AF },
{ "timestamp", "set how every output frame timestamp is processed", OFFSET(timestamp_mode), AV_OPT_TYPE_INT, {.i64=TS_WRITE}, 0, TS_NB-1, AF, "timestamp" },
{ "write", "full timestamps rewrite, keep only the start time", 0, AV_OPT_TYPE_CONST, {.i64=TS_WRITE}, 0, 0, AF, "timestamp" },
@@ -230,6 +232,9 @@ static int config_output(AVFilterLink *outlink)
case D_RMS:
s->cache_size = 1;
break;
+ case D_DEV:
+ s->cache_size = 2;
+ break;
case D_MEDIAN:
case D_PEAK:
case D_PTP:
@@ -263,6 +268,10 @@ static int config_output(AVFilterLink *outlink)
s->compute_flt = compute_avg_flt;
s->compute_dbl = compute_avg_dbl;
break;
+ case D_DEV:
+ s->compute_flt = compute_dev_flt;
+ s->compute_dbl = compute_dev_dbl;
+ break;
case D_PTP:
s->compute_flt = compute_ptp_flt;
s->compute_dbl = compute_ptp_dbl;