]> git.sesse.net Git - ffmpeg/blob - libavfilter/af_silenceremove.c
avfilter/af_silenceremove: prefer outlink instead of inlink
[ffmpeg] / libavfilter / af_silenceremove.c
1 /*
2  * Copyright (c) 2001 Heikki Leinonen
3  * Copyright (c) 2001 Chris Bagwell
4  * Copyright (c) 2003 Donnie Smith
5  * Copyright (c) 2014 Paul B Mahol
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23
24 #include <float.h> /* DBL_MAX */
25
26 #include "libavutil/opt.h"
27 #include "libavutil/timestamp.h"
28 #include "audio.h"
29 #include "formats.h"
30 #include "avfilter.h"
31 #include "internal.h"
32
33 enum SilenceMode {
34     SILENCE_TRIM,
35     SILENCE_TRIM_FLUSH,
36     SILENCE_COPY,
37     SILENCE_COPY_FLUSH,
38     SILENCE_STOP
39 };
40
41 typedef struct SilenceRemoveContext {
42     const AVClass *class;
43
44     enum SilenceMode mode;
45
46     int start_periods;
47     int64_t start_duration;
48     int64_t start_duration_opt;
49     double start_threshold;
50     int64_t start_silence;
51     int64_t start_silence_opt;
52     int start_mode;
53
54     int stop_periods;
55     int64_t stop_duration;
56     int64_t stop_duration_opt;
57     double stop_threshold;
58     int64_t stop_silence;
59     int64_t stop_silence_opt;
60     int stop_mode;
61
62     double *start_holdoff;
63     double *start_silence_hold;
64     size_t start_holdoff_offset;
65     size_t start_holdoff_end;
66     size_t start_silence_offset;
67     size_t start_silence_end;
68     int    start_found_periods;
69
70     double *stop_holdoff;
71     double *stop_silence_hold;
72     size_t stop_holdoff_offset;
73     size_t stop_holdoff_end;
74     size_t stop_silence_offset;
75     size_t stop_silence_end;
76     int    stop_found_periods;
77
78     double window_ratio;
79     double *window;
80     double *window_current;
81     double *window_end;
82     int window_size;
83     double sum;
84
85     int restart;
86     int64_t next_pts;
87
88     int detection;
89     void (*update)(struct SilenceRemoveContext *s, double sample);
90     double(*compute)(struct SilenceRemoveContext *s, double sample);
91 } SilenceRemoveContext;
92
93 #define OFFSET(x) offsetof(SilenceRemoveContext, x)
94 #define AF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
95
96 static const AVOption silenceremove_options[] = {
97     { "start_periods",   NULL, OFFSET(start_periods),       AV_OPT_TYPE_INT,      {.i64=0},     0,      9000, AF },
98     { "start_duration",  NULL, OFFSET(start_duration_opt),  AV_OPT_TYPE_DURATION, {.i64=0},     0, INT32_MAX, AF },
99     { "start_threshold", NULL, OFFSET(start_threshold),     AV_OPT_TYPE_DOUBLE,   {.dbl=0},     0,   DBL_MAX, AF },
100     { "start_silence",   NULL, OFFSET(start_silence_opt),   AV_OPT_TYPE_DURATION, {.i64=0},     0, INT32_MAX, AF },
101     { "start_mode",      NULL, OFFSET(start_mode),          AV_OPT_TYPE_INT,      {.i64=0},     0,         1, AF, "mode" },
102     {   "any",           0,    0,                           AV_OPT_TYPE_CONST,    {.i64=0},     0,         0, AF, "mode" },
103     {   "all",           0,    0,                           AV_OPT_TYPE_CONST,    {.i64=1},     0,         0, AF, "mode" },
104     { "stop_periods",    NULL, OFFSET(stop_periods),        AV_OPT_TYPE_INT,      {.i64=0}, -9000,      9000, AF },
105     { "stop_duration",   NULL, OFFSET(stop_duration_opt),   AV_OPT_TYPE_DURATION, {.i64=0},     0, INT32_MAX, AF },
106     { "stop_threshold",  NULL, OFFSET(stop_threshold),      AV_OPT_TYPE_DOUBLE,   {.dbl=0},     0,   DBL_MAX, AF },
107     { "stop_silence",    NULL, OFFSET(stop_silence_opt),    AV_OPT_TYPE_DURATION, {.i64=0},     0, INT32_MAX, AF },
108     { "stop_mode",       NULL, OFFSET(stop_mode),           AV_OPT_TYPE_INT,      {.i64=0},     0,         1, AF, "mode" },
109     { "detection",       NULL, OFFSET(detection),           AV_OPT_TYPE_INT,      {.i64=1},     0,         1, AF, "detection" },
110     {   "peak",          0,    0,                           AV_OPT_TYPE_CONST,    {.i64=0},     0,         0, AF, "detection" },
111     {   "rms",           0,    0,                           AV_OPT_TYPE_CONST,    {.i64=1},     0,         0, AF, "detection" },
112     { "window",          NULL, OFFSET(window_ratio),        AV_OPT_TYPE_DOUBLE,   {.dbl=0.02},  0,        10, AF },
113     { NULL }
114 };
115
116 AVFILTER_DEFINE_CLASS(silenceremove);
117
118 static double compute_peak(SilenceRemoveContext *s, double sample)
119 {
120     double new_sum;
121
122     new_sum  = s->sum;
123     new_sum -= *s->window_current;
124     new_sum += fabs(sample);
125
126     return new_sum / s->window_size;
127 }
128
129 static void update_peak(SilenceRemoveContext *s, double sample)
130 {
131     s->sum -= *s->window_current;
132     *s->window_current = fabs(sample);
133     s->sum += *s->window_current;
134
135     s->window_current++;
136     if (s->window_current >= s->window_end)
137         s->window_current = s->window;
138 }
139
140 static double compute_rms(SilenceRemoveContext *s, double sample)
141 {
142     double new_sum;
143
144     new_sum  = s->sum;
145     new_sum -= *s->window_current;
146     new_sum += sample * sample;
147
148     return sqrt(new_sum / s->window_size);
149 }
150
151 static void update_rms(SilenceRemoveContext *s, double sample)
152 {
153     s->sum -= *s->window_current;
154     *s->window_current = sample * sample;
155     s->sum += *s->window_current;
156
157     s->window_current++;
158     if (s->window_current >= s->window_end)
159         s->window_current = s->window;
160 }
161
162 static av_cold int init(AVFilterContext *ctx)
163 {
164     SilenceRemoveContext *s = ctx->priv;
165
166     if (s->stop_periods < 0) {
167         s->stop_periods = -s->stop_periods;
168         s->restart = 1;
169     }
170
171     switch (s->detection) {
172     case 0:
173         s->update = update_peak;
174         s->compute = compute_peak;
175         break;
176     case 1:
177         s->update = update_rms;
178         s->compute = compute_rms;
179         break;
180     }
181
182     return 0;
183 }
184
185 static void clear_window(SilenceRemoveContext *s)
186 {
187     memset(s->window, 0, s->window_size * sizeof(*s->window));
188
189     s->window_current = s->window;
190     s->window_end = s->window + s->window_size;
191     s->sum = 0;
192 }
193
194 static int config_input(AVFilterLink *inlink)
195 {
196     AVFilterContext *ctx = inlink->dst;
197     SilenceRemoveContext *s = ctx->priv;
198
199     s->window_size = FFMAX((inlink->sample_rate * s->window_ratio), 1) * inlink->channels;
200     s->window = av_malloc_array(s->window_size, sizeof(*s->window));
201     if (!s->window)
202         return AVERROR(ENOMEM);
203
204     clear_window(s);
205
206     s->start_duration = av_rescale(s->start_duration_opt, inlink->sample_rate,
207                                    AV_TIME_BASE);
208     s->start_silence  = av_rescale(s->start_silence_opt, inlink->sample_rate,
209                                    AV_TIME_BASE);
210     s->stop_duration  = av_rescale(s->stop_duration_opt, inlink->sample_rate,
211                                    AV_TIME_BASE);
212     s->stop_silence   = av_rescale(s->stop_silence_opt, inlink->sample_rate,
213                                    AV_TIME_BASE);
214
215     s->start_holdoff = av_malloc_array(FFMAX(s->start_duration, 1),
216                                        sizeof(*s->start_holdoff) *
217                                        inlink->channels);
218     if (!s->start_holdoff)
219         return AVERROR(ENOMEM);
220
221     s->start_silence_hold = av_malloc_array(FFMAX(s->start_silence, 1),
222                                             sizeof(*s->start_silence_hold) *
223                                             inlink->channels);
224     if (!s->start_silence_hold)
225         return AVERROR(ENOMEM);
226
227     s->start_holdoff_offset = 0;
228     s->start_holdoff_end    = 0;
229     s->start_found_periods  = 0;
230
231     s->stop_holdoff = av_malloc_array(FFMAX(s->stop_duration, 1),
232                                       sizeof(*s->stop_holdoff) *
233                                       inlink->channels);
234     if (!s->stop_holdoff)
235         return AVERROR(ENOMEM);
236
237     s->stop_silence_hold = av_malloc_array(FFMAX(s->stop_silence, 1),
238                                            sizeof(*s->stop_silence_hold) *
239                                            inlink->channels);
240     if (!s->stop_silence_hold)
241         return AVERROR(ENOMEM);
242
243     s->stop_holdoff_offset = 0;
244     s->stop_holdoff_end    = 0;
245     s->stop_found_periods  = 0;
246
247     if (s->start_periods)
248         s->mode = SILENCE_TRIM;
249     else
250         s->mode = SILENCE_COPY;
251
252     return 0;
253 }
254
255 static void flush(SilenceRemoveContext *s,
256                   AVFrame *out, AVFilterLink *outlink,
257                   int *nb_samples_written, int *ret, int flush_silence)
258 {
259     AVFrame *silence;
260
261     if (*nb_samples_written) {
262         out->nb_samples = *nb_samples_written / outlink->channels;
263
264         out->pts = s->next_pts;
265         s->next_pts += av_rescale_q(out->nb_samples,
266                                     (AVRational){1, outlink->sample_rate},
267                                     outlink->time_base);
268
269         *ret = ff_filter_frame(outlink, out);
270         if (*ret < 0)
271             return;
272         *nb_samples_written = 0;
273     } else {
274         av_frame_free(&out);
275     }
276
277     if (s->stop_silence_end <= 0 || !flush_silence)
278         return;
279
280     silence = ff_get_audio_buffer(outlink, s->stop_silence_end / outlink->channels);
281     if (!silence) {
282         *ret = AVERROR(ENOMEM);
283         return;
284     }
285
286     if (s->stop_silence_offset < s->stop_silence_end) {
287         memcpy(silence->data[0],
288                &s->stop_silence_hold[s->stop_silence_offset],
289                (s->stop_silence_end - s->stop_silence_offset) * sizeof(double));
290     }
291
292     if (s->stop_silence_offset > 0) {
293         memcpy(silence->data[0] + (s->stop_silence_end - s->stop_silence_offset) * sizeof(double),
294                &s->stop_silence_hold[0],
295                s->stop_silence_offset * sizeof(double));
296     }
297
298     s->stop_silence_offset = 0;
299     s->stop_silence_end = 0;
300
301     silence->pts = s->next_pts;
302     s->next_pts += av_rescale_q(silence->nb_samples,
303                                 (AVRational){1, outlink->sample_rate},
304                                 outlink->time_base);
305
306     *ret = ff_filter_frame(outlink, silence);
307 }
308
309 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
310 {
311     AVFilterContext *ctx = inlink->dst;
312     AVFilterLink *outlink = ctx->outputs[0];
313     SilenceRemoveContext *s = ctx->priv;
314     int i, j, threshold, ret = 0;
315     int nbs, nb_samples_read, nb_samples_written;
316     double *obuf, *ibuf = (double *)in->data[0];
317     AVFrame *out;
318
319     nb_samples_read = nb_samples_written = 0;
320
321     switch (s->mode) {
322     case SILENCE_TRIM:
323 silence_trim:
324         nbs = in->nb_samples - nb_samples_read / outlink->channels;
325         if (!nbs)
326             break;
327
328         for (i = 0; i < nbs; i++) {
329             if (s->start_mode) {
330                 threshold = 0;
331                 for (j = 0; j < outlink->channels; j++) {
332                     threshold |= s->compute(s, ibuf[j]) > s->start_threshold;
333                 }
334             } else {
335                 threshold = 1;
336                 for (j = 0; j < outlink->channels; j++) {
337                     threshold &= s->compute(s, ibuf[j]) > s->start_threshold;
338                 }
339             }
340
341             if (threshold) {
342                 for (j = 0; j < outlink->channels; j++) {
343                     s->update(s, *ibuf);
344                     s->start_holdoff[s->start_holdoff_end++] = *ibuf++;
345                 }
346                 nb_samples_read += outlink->channels;
347
348                 if (s->start_holdoff_end >= s->start_duration * outlink->channels) {
349                     if (++s->start_found_periods >= s->start_periods) {
350                         s->mode = SILENCE_TRIM_FLUSH;
351                         goto silence_trim_flush;
352                     }
353
354                     s->start_holdoff_offset = 0;
355                     s->start_holdoff_end = 0;
356                     s->start_silence_offset = 0;
357                     s->start_silence_end = 0;
358                 }
359             } else {
360                 s->start_holdoff_end = 0;
361
362                 for (j = 0; j < outlink->channels; j++) {
363                     s->update(s, ibuf[j]);
364                     if (s->start_silence) {
365                         s->start_silence_hold[s->start_silence_offset++] = ibuf[j];
366                         s->start_silence_end = FFMIN(s->start_silence_end + 1, outlink->channels * s->start_silence);
367                         if (s->start_silence_offset >= outlink->channels * s->start_silence) {
368                             s->start_silence_offset = 0;
369                         }
370                     }
371                 }
372
373                 ibuf += outlink->channels;
374                 nb_samples_read += outlink->channels;
375             }
376         }
377         break;
378
379     case SILENCE_TRIM_FLUSH:
380 silence_trim_flush:
381         nbs  = s->start_holdoff_end - s->start_holdoff_offset;
382         nbs -= nbs % outlink->channels;
383         if (!nbs)
384             break;
385
386         out = ff_get_audio_buffer(outlink, nbs / outlink->channels + s->start_silence_end / outlink->channels);
387         if (!out) {
388             av_frame_free(&in);
389             return AVERROR(ENOMEM);
390         }
391
392         if (s->start_silence_end > 0) {
393             if (s->start_silence_offset < s->start_silence_end) {
394                 memcpy(out->data[0],
395                        &s->start_silence_hold[s->start_silence_offset],
396                        (s->start_silence_end - s->start_silence_offset) * sizeof(double));
397             }
398
399             if (s->start_silence_offset > 0) {
400                 memcpy(out->data[0] + (s->start_silence_end - s->start_silence_offset) * sizeof(double),
401                        &s->start_silence_hold[0],
402                        s->start_silence_offset * sizeof(double));
403             }
404         }
405
406         memcpy(out->data[0] + s->start_silence_end * sizeof(double),
407                &s->start_holdoff[s->start_holdoff_offset],
408                nbs * sizeof(double));
409
410         out->pts = s->next_pts;
411         s->next_pts += av_rescale_q(out->nb_samples,
412                                     (AVRational){1, outlink->sample_rate},
413                                     outlink->time_base);
414
415         s->start_holdoff_offset += nbs;
416
417         ret = ff_filter_frame(outlink, out);
418
419         if (s->start_holdoff_offset == s->start_holdoff_end) {
420             s->start_holdoff_offset = 0;
421             s->start_holdoff_end = 0;
422             s->start_silence_offset = 0;
423             s->start_silence_end = 0;
424             s->mode = SILENCE_COPY;
425             goto silence_copy;
426         }
427         break;
428
429     case SILENCE_COPY:
430 silence_copy:
431         nbs = in->nb_samples - nb_samples_read / outlink->channels;
432         if (!nbs)
433             break;
434
435         out = ff_get_audio_buffer(outlink, nbs);
436         if (!out) {
437             av_frame_free(&in);
438             return AVERROR(ENOMEM);
439         }
440         obuf = (double *)out->data[0];
441
442         if (s->stop_periods) {
443             for (i = 0; i < nbs; i++) {
444                 if (s->stop_mode) {
445                     threshold = 0;
446                     for (j = 0; j < outlink->channels; j++) {
447                         threshold |= s->compute(s, ibuf[j]) > s->stop_threshold;
448                     }
449                 } else {
450                     threshold = 1;
451                     for (j = 0; j < outlink->channels; j++) {
452                         threshold &= s->compute(s, ibuf[j]) > s->stop_threshold;
453                     }
454                 }
455
456                 if (threshold && s->stop_holdoff_end && !s->stop_silence) {
457                     s->mode = SILENCE_COPY_FLUSH;
458                     flush(s, out, outlink, &nb_samples_written, &ret, 0);
459                     goto silence_copy_flush;
460                 } else if (threshold) {
461                     for (j = 0; j < outlink->channels; j++) {
462                         s->update(s, *ibuf);
463                         *obuf++ = *ibuf++;
464                     }
465                     nb_samples_read    += outlink->channels;
466                     nb_samples_written += outlink->channels;
467                 } else if (!threshold) {
468                     for (j = 0; j < outlink->channels; j++) {
469                         s->update(s, *ibuf);
470                         if (s->stop_silence) {
471                             s->stop_silence_hold[s->stop_silence_offset++] = *ibuf;
472                             s->stop_silence_end = FFMIN(s->stop_silence_end + 1, outlink->channels * s->stop_silence);
473                             if (s->stop_silence_offset >= outlink->channels * s->stop_silence) {
474                                 s->stop_silence_offset = 0;
475                             }
476                         }
477
478                         s->stop_holdoff[s->stop_holdoff_end++] = *ibuf++;
479                     }
480                     nb_samples_read += outlink->channels;
481
482                     if (s->stop_holdoff_end >= s->stop_duration * outlink->channels) {
483                         if (++s->stop_found_periods >= s->stop_periods) {
484                             s->stop_holdoff_offset = 0;
485                             s->stop_holdoff_end = 0;
486
487                             if (!s->restart) {
488                                 s->mode = SILENCE_STOP;
489                                 flush(s, out, outlink, &nb_samples_written, &ret, 1);
490                                 goto silence_stop;
491                             } else {
492                                 s->stop_found_periods = 0;
493                                 s->start_found_periods = 0;
494                                 s->start_holdoff_offset = 0;
495                                 s->start_holdoff_end = 0;
496                                 s->start_silence_offset = 0;
497                                 s->start_silence_end = 0;
498                                 clear_window(s);
499                                 s->mode = SILENCE_TRIM;
500                                 flush(s, out, outlink, &nb_samples_written, &ret, 1);
501                                 goto silence_trim;
502                             }
503                         }
504                         s->mode = SILENCE_COPY_FLUSH;
505                         flush(s, out, outlink, &nb_samples_written, &ret, 0);
506                         goto silence_copy_flush;
507                     }
508                 }
509             }
510             flush(s, out, outlink, &nb_samples_written, &ret, 0);
511         } else {
512             memcpy(obuf, ibuf, sizeof(double) * nbs * outlink->channels);
513
514             out->pts = s->next_pts;
515             s->next_pts += av_rescale_q(out->nb_samples,
516                                         (AVRational){1, outlink->sample_rate},
517                                         outlink->time_base);
518
519             ret = ff_filter_frame(outlink, out);
520         }
521         break;
522
523     case SILENCE_COPY_FLUSH:
524 silence_copy_flush:
525         nbs  = s->stop_holdoff_end - s->stop_holdoff_offset;
526         nbs -= nbs % outlink->channels;
527         if (!nbs)
528             break;
529
530         out = ff_get_audio_buffer(outlink, nbs / outlink->channels);
531         if (!out) {
532             av_frame_free(&in);
533             return AVERROR(ENOMEM);
534         }
535
536         memcpy(out->data[0], &s->stop_holdoff[s->stop_holdoff_offset],
537                nbs * sizeof(double));
538         s->stop_holdoff_offset += nbs;
539
540         out->pts = s->next_pts;
541         s->next_pts += av_rescale_q(out->nb_samples,
542                                     (AVRational){1, outlink->sample_rate},
543                                     outlink->time_base);
544
545         ret = ff_filter_frame(outlink, out);
546
547         if (s->stop_holdoff_offset == s->stop_holdoff_end) {
548             s->stop_holdoff_offset = 0;
549             s->stop_holdoff_end = 0;
550             s->stop_silence_offset = 0;
551             s->stop_silence_end = 0;
552             s->mode = SILENCE_COPY;
553             goto silence_copy;
554         }
555         break;
556     case SILENCE_STOP:
557 silence_stop:
558         break;
559     }
560
561     av_frame_free(&in);
562
563     return ret;
564 }
565
566 static int request_frame(AVFilterLink *outlink)
567 {
568     AVFilterContext *ctx = outlink->src;
569     SilenceRemoveContext *s = ctx->priv;
570     int ret;
571
572     ret = ff_request_frame(ctx->inputs[0]);
573     if (ret == AVERROR_EOF && (s->mode == SILENCE_COPY_FLUSH ||
574                                s->mode == SILENCE_COPY)) {
575         int nbs = s->stop_holdoff_end - s->stop_holdoff_offset;
576         if (nbs) {
577             AVFrame *frame;
578
579             frame = ff_get_audio_buffer(outlink, nbs / outlink->channels);
580             if (!frame)
581                 return AVERROR(ENOMEM);
582
583             memcpy(frame->data[0], &s->stop_holdoff[s->stop_holdoff_offset],
584                    nbs * sizeof(double));
585
586             frame->pts = s->next_pts;
587             s->next_pts += av_rescale_q(frame->nb_samples,
588                                         (AVRational){1, outlink->sample_rate},
589                                         outlink->time_base);
590
591             ret = ff_filter_frame(outlink, frame);
592         }
593         s->mode = SILENCE_STOP;
594     }
595     return ret;
596 }
597
598 static int query_formats(AVFilterContext *ctx)
599 {
600     AVFilterFormats *formats = NULL;
601     AVFilterChannelLayouts *layouts = NULL;
602     static const enum AVSampleFormat sample_fmts[] = {
603         AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE
604     };
605     int ret;
606
607     layouts = ff_all_channel_counts();
608     if (!layouts)
609         return AVERROR(ENOMEM);
610     ret = ff_set_common_channel_layouts(ctx, layouts);
611     if (ret < 0)
612         return ret;
613
614     formats = ff_make_format_list(sample_fmts);
615     if (!formats)
616         return AVERROR(ENOMEM);
617     ret = ff_set_common_formats(ctx, formats);
618     if (ret < 0)
619         return ret;
620
621     formats = ff_all_samplerates();
622     if (!formats)
623         return AVERROR(ENOMEM);
624     return ff_set_common_samplerates(ctx, formats);
625 }
626
627 static av_cold void uninit(AVFilterContext *ctx)
628 {
629     SilenceRemoveContext *s = ctx->priv;
630
631     av_freep(&s->start_holdoff);
632     av_freep(&s->start_silence_hold);
633     av_freep(&s->stop_holdoff);
634     av_freep(&s->stop_silence_hold);
635     av_freep(&s->window);
636 }
637
638 static const AVFilterPad silenceremove_inputs[] = {
639     {
640         .name         = "default",
641         .type         = AVMEDIA_TYPE_AUDIO,
642         .config_props = config_input,
643         .filter_frame = filter_frame,
644     },
645     { NULL }
646 };
647
648 static const AVFilterPad silenceremove_outputs[] = {
649     {
650         .name          = "default",
651         .type          = AVMEDIA_TYPE_AUDIO,
652         .request_frame = request_frame,
653     },
654     { NULL }
655 };
656
657 AVFilter ff_af_silenceremove = {
658     .name          = "silenceremove",
659     .description   = NULL_IF_CONFIG_SMALL("Remove silence."),
660     .priv_size     = sizeof(SilenceRemoveContext),
661     .priv_class    = &silenceremove_class,
662     .init          = init,
663     .uninit        = uninit,
664     .query_formats = query_formats,
665     .inputs        = silenceremove_inputs,
666     .outputs       = silenceremove_outputs,
667 };