[FFmpeg-cvslog] avfilter/af_silenceremove: speed-up filtering once start-trim is over
Paul B Mahol
git at videolan.org
Sat May 27 12:19:12 EEST 2023
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat May 27 11:13:48 2023 +0200| [8d662adcc9a28da7a9422bff8be68881692ca6bd] | committer: Paul B Mahol
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.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d662adcc9a28da7a9422bff8be68881692ca6bd
---
libavfilter/af_silenceremove.c | 36 ++++++++++++++++++++++--------------
1 file 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);
}
More information about the ffmpeg-cvslog
mailing list