1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

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.
This commit is contained in:
Paul B Mahol 2023-05-27 11:13:48 +02:00
parent 965f99f904
commit 8d662adcc9

View File

@ -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);
}