aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2023-05-27 11:13:48 +0200
committerPaul B Mahol <onemda@gmail.com>2023-05-27 11:18:02 +0200
commit8d662adcc9a28da7a9422bff8be68881692ca6bd (patch)
treee58cc1a3fdd1e367aefdd7ccf70c6f61525349dc /libavfilter
parent965f99f904a433c341c04ac992d5ab8f08f0aae2 (diff)
downloadffmpeg-8d662adcc9a28da7a9422bff8be68881692ca6bd.tar.gz
avfilter/af_silenceremove: speed-up filtering once start-trim is over
No point to call filter_start on samples that will pass them unchanged once initial trimming stopped.
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/af_silenceremove.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/libavfilter/af_silenceremove.c b/libavfilter/af_silenceremove.c
index 865df4d13a..8398eeadb2 100644
--- a/libavfilter/af_silenceremove.c
+++ b/libavfilter/af_silenceremove.c
@@ -294,15 +294,19 @@ static int filter_frame(AVFilterLink *outlink, AVFrame *in)
srcf = (const float *)in->data[0];
dstf = (float *)out->data[0];
if (s->start_periods > 0 && s->stop_periods > 0) {
- for (int n = 0; n < in_nb_samples; n++) {
- filter_start_flt(ctx, srcf + n * nb_channels,
- dstf, &out_nb_samples,
- nb_channels);
+ const float *src = srcf;
+ if (s->start_found_periods >= 0) {
+ for (int n = 0; n < in_nb_samples; n++) {
+ filter_start_flt(ctx, src + n * nb_channels,
+ dstf, &out_nb_samples,
+ nb_channels);
+ }
+ in_nb_samples = out_nb_samples;
+ out_nb_samples = 0;
+ src = dstf;
}
- in_nb_samples = out_nb_samples;
- out_nb_samples = 0;
for (int n = 0; n < in_nb_samples; n++) {
- filter_stop_flt(ctx, dstf + n * nb_channels,
+ filter_stop_flt(ctx, src + n * nb_channels,
dstf, &out_nb_samples,
nb_channels);
}
@@ -324,15 +328,19 @@ static int filter_frame(AVFilterLink *outlink, AVFrame *in)
srcd = (const double *)in->data[0];
dstd = (double *)out->data[0];
if (s->start_periods > 0 && s->stop_periods > 0) {
- for (int n = 0; n < in_nb_samples; n++) {
- filter_start_dbl(ctx, srcd + n * nb_channels,
- dstd, &out_nb_samples,
- nb_channels);
+ const double *src = srcd;
+ if (s->start_found_periods >= 0) {
+ for (int n = 0; n < in_nb_samples; n++) {
+ filter_start_dbl(ctx, src + n * nb_channels,
+ dstd, &out_nb_samples,
+ nb_channels);
+ }
+ in_nb_samples = out_nb_samples;
+ out_nb_samples = 0;
+ src = dstd;
}
- in_nb_samples = out_nb_samples;
- out_nb_samples = 0;
for (int n = 0; n < in_nb_samples; n++) {
- filter_stop_dbl(ctx, dstd + n * nb_channels,
+ filter_stop_dbl(ctx, src + n * nb_channels,
dstd, &out_nb_samples,
nb_channels);
}