FFmpeg
af_silenceremove.c
Go to the documentation of this file.
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/avassert.h"
27 #include "libavutil/mem.h"
28 #include "libavutil/opt.h"
29 #include "audio.h"
30 #include "filters.h"
31 #include "avfilter.h"
32 #include "internal.h"
33 
42 };
43 
48 };
49 
53 };
54 
55 typedef struct SilenceRemoveContext {
56  const AVClass *class;
57 
60  int64_t start_duration;
63  int64_t start_silence;
65 
66  int stop_mode;
68  int64_t stop_duration;
71  int64_t stop_silence;
73 
75 
77 
80 
83 
86 
89 
91  int *start_back;
92 
93  int *stop_front;
94  int *stop_back;
95 
96  int64_t window_duration;
98 
101 
104 
105  double *start_cache;
106  double *stop_cache;
107 
111 
115 
116  int restart;
118  int64_t next_pts;
119 
121 
122  float (*compute_flt)(float *c, float s, float ws, int size, int *front, int *back);
123  double (*compute_dbl)(double *c, double s, double ws, int size, int *front, int *back);
125 
126 #define OFFSET(x) offsetof(SilenceRemoveContext, x)
127 #define AF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
128 #define AFR AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
129 
130 static const AVOption silenceremove_options[] = {
131  { "start_periods", "set periods of silence parts to skip from start", OFFSET(start_periods), AV_OPT_TYPE_INT, {.i64=0}, 0, 9000, AF },
132  { "start_duration", "set start duration of non-silence part", OFFSET(start_duration_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
133  { "start_threshold", "set threshold for start silence detection", OFFSET(start_threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, DBL_MAX, AFR },
134  { "start_silence", "set start duration of silence part to keep", OFFSET(start_silence_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
135  { "start_mode", "set which channel will trigger trimming from start", OFFSET(start_mode), AV_OPT_TYPE_INT, {.i64=T_ANY}, T_ANY, T_ALL, AFR, .unit = "mode" },
136  { "any", 0, 0, AV_OPT_TYPE_CONST, {.i64=T_ANY}, 0, 0, AFR, .unit = "mode" },
137  { "all", 0, 0, AV_OPT_TYPE_CONST, {.i64=T_ALL}, 0, 0, AFR, .unit = "mode" },
138  { "stop_periods", "set periods of silence parts to skip from end", OFFSET(stop_periods), AV_OPT_TYPE_INT, {.i64=0}, -9000, 9000, AF },
139  { "stop_duration", "set stop duration of silence part", OFFSET(stop_duration_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
140  { "stop_threshold", "set threshold for stop silence detection", OFFSET(stop_threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, DBL_MAX, AFR },
141  { "stop_silence", "set stop duration of silence part to keep", OFFSET(stop_silence_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
142  { "stop_mode", "set which channel will trigger trimming from end", OFFSET(stop_mode), AV_OPT_TYPE_INT, {.i64=T_ALL}, T_ANY, T_ALL, AFR, .unit = "mode" },
143  { "detection", "set how silence is detected", OFFSET(detection), AV_OPT_TYPE_INT, {.i64=D_RMS}, 0, D_NB-1, AF, .unit = "detection" },
144  { "avg", "use mean absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_AVG}, 0, 0, AF, .unit = "detection" },
145  { "rms", "use root mean squared values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_RMS}, 0, 0, AF, .unit = "detection" },
146  { "peak", "use max absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_PEAK},0, 0, AF, .unit = "detection" },
147  { "median", "use median of absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_MEDIAN},0, 0, AF, .unit = "detection" },
148  { "ptp", "use absolute of max peak to min peak difference", 0, AV_OPT_TYPE_CONST, {.i64=D_PTP}, 0, 0, AF, .unit = "detection" },
149  { "dev", "use standard deviation from values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_DEV}, 0, 0, AF, .unit = "detection" },
150  { "window", "set duration of window for silence detection", OFFSET(window_duration_opt), AV_OPT_TYPE_DURATION, {.i64=20000}, 0, 100000000, AF },
151  { "timestamp", "set how every output frame timestamp is processed", OFFSET(timestamp_mode), AV_OPT_TYPE_INT, {.i64=TS_WRITE}, 0, TS_NB-1, AF, .unit = "timestamp" },
152  { "write", "full timestamps rewrite, keep only the start time", 0, AV_OPT_TYPE_CONST, {.i64=TS_WRITE}, 0, 0, AF, .unit = "timestamp" },
153  { "copy", "non-dropped frames are left with same timestamp", 0, AV_OPT_TYPE_CONST, {.i64=TS_COPY}, 0, 0, AF, .unit = "timestamp" },
154  { NULL }
155 };
156 
157 AVFILTER_DEFINE_CLASS(silenceremove);
158 
159 #define DEPTH 32
160 #include "silenceremove_template.c"
161 
162 #undef DEPTH
163 #define DEPTH 64
164 #include "silenceremove_template.c"
165 
167 {
168  SilenceRemoveContext *s = ctx->priv;
169 
170  if (s->stop_periods < 0) {
171  s->stop_periods = -s->stop_periods;
172  s->restart = 1;
173  }
174 
175  return 0;
176 }
177 
179 {
180  av_samples_set_silence(s->start_window->extended_data, 0,
181  s->start_window->nb_samples,
182  s->start_window->ch_layout.nb_channels,
183  s->start_window->format);
184  av_samples_set_silence(s->stop_window->extended_data, 0,
185  s->stop_window->nb_samples,
186  s->stop_window->ch_layout.nb_channels,
187  s->stop_window->format);
188 
189  s->start_window_pos = 0;
190  s->start_window_size = 0;
191  s->stop_window_pos = 0;
192  s->stop_window_size = 0;
193  s->start_queue_pos = 0;
194  s->start_queue_size = 0;
195  s->stop_queue_pos = 0;
196  s->stop_queue_size = 0;
197 }
198 
200 {
201  AVFilterContext *ctx = inlink->dst;
202  SilenceRemoveContext *s = ctx->priv;
203 
204  s->next_pts = AV_NOPTS_VALUE;
205  s->window_duration = av_rescale(s->window_duration_opt, inlink->sample_rate,
206  AV_TIME_BASE);
207  s->window_duration = FFMAX(1, s->window_duration);
208 
209  s->start_duration = av_rescale(s->start_duration_opt, inlink->sample_rate,
210  AV_TIME_BASE);
211  s->start_silence = av_rescale(s->start_silence_opt, inlink->sample_rate,
212  AV_TIME_BASE);
213  s->stop_duration = av_rescale(s->stop_duration_opt, inlink->sample_rate,
214  AV_TIME_BASE);
215  s->stop_silence = av_rescale(s->stop_silence_opt, inlink->sample_rate,
216  AV_TIME_BASE);
217 
218  s->start_found_periods = 0;
219  s->stop_found_periods = 0;
220 
221  return 0;
222 }
223 
224 static int config_output(AVFilterLink *outlink)
225 {
226  AVFilterContext *ctx = outlink->src;
227  SilenceRemoveContext *s = ctx->priv;
228 
229  switch (s->detection) {
230  case D_AVG:
231  case D_RMS:
232  s->cache_size = 1;
233  break;
234  case D_DEV:
235  s->cache_size = 2;
236  break;
237  case D_MEDIAN:
238  case D_PEAK:
239  case D_PTP:
240  s->cache_size = s->window_duration;
241  break;
242  }
243 
244  s->start_window = ff_get_audio_buffer(outlink, s->window_duration);
245  s->stop_window = ff_get_audio_buffer(outlink, s->window_duration);
246  s->start_cache = av_calloc(outlink->ch_layout.nb_channels, s->cache_size * sizeof(*s->start_cache));
247  s->stop_cache = av_calloc(outlink->ch_layout.nb_channels, s->cache_size * sizeof(*s->stop_cache));
248  if (!s->start_window || !s->stop_window || !s->start_cache || !s->stop_cache)
249  return AVERROR(ENOMEM);
250 
251  s->start_queuef = ff_get_audio_buffer(outlink, s->start_silence + 1);
252  s->stop_queuef = ff_get_audio_buffer(outlink, s->stop_silence + 1);
253  if (!s->start_queuef || !s->stop_queuef)
254  return AVERROR(ENOMEM);
255 
256  s->start_front = av_calloc(outlink->ch_layout.nb_channels, sizeof(*s->start_front));
257  s->start_back = av_calloc(outlink->ch_layout.nb_channels, sizeof(*s->start_back));
258  s->stop_front = av_calloc(outlink->ch_layout.nb_channels, sizeof(*s->stop_front));
259  s->stop_back = av_calloc(outlink->ch_layout.nb_channels, sizeof(*s->stop_back));
260  if (!s->start_front || !s->start_back || !s->stop_front || !s->stop_back)
261  return AVERROR(ENOMEM);
262 
263  clear_windows(s);
264 
265  switch (s->detection) {
266  case D_AVG:
267  s->compute_flt = compute_avg_flt;
268  s->compute_dbl = compute_avg_dbl;
269  break;
270  case D_DEV:
271  s->compute_flt = compute_dev_flt;
272  s->compute_dbl = compute_dev_dbl;
273  break;
274  case D_PTP:
275  s->compute_flt = compute_ptp_flt;
276  s->compute_dbl = compute_ptp_dbl;
277  break;
278  case D_MEDIAN:
279  s->compute_flt = compute_median_flt;
280  s->compute_dbl = compute_median_dbl;
281  break;
282  case D_PEAK:
283  s->compute_flt = compute_peak_flt;
284  s->compute_dbl = compute_peak_dbl;
285  break;
286  case D_RMS:
287  s->compute_flt = compute_rms_flt;
288  s->compute_dbl = compute_rms_dbl;
289  break;
290  }
291 
292  return 0;
293 }
294 
295 static int filter_frame(AVFilterLink *outlink, AVFrame *in)
296 {
297  const int nb_channels = outlink->ch_layout.nb_channels;
298  AVFilterContext *ctx = outlink->src;
299  SilenceRemoveContext *s = ctx->priv;
300  int max_out_nb_samples;
301  int out_nb_samples = 0;
302  int in_nb_samples;
303  const double *srcd;
304  const float *srcf;
305  AVFrame *out;
306  double *dstd;
307  float *dstf;
308 
309  if (s->next_pts == AV_NOPTS_VALUE)
310  s->next_pts = in->pts;
311 
312  in_nb_samples = in->nb_samples;
313  max_out_nb_samples = in->nb_samples +
314  s->start_silence +
315  s->stop_silence;
316  if (max_out_nb_samples <= 0) {
317  av_frame_free(&in);
318  ff_filter_set_ready(ctx, 100);
319  return 0;
320  }
321 
322  out = ff_get_audio_buffer(outlink, max_out_nb_samples);
323  if (!out) {
324  av_frame_free(&in);
325  return AVERROR(ENOMEM);
326  }
327 
328  if (s->timestamp_mode == TS_WRITE)
329  out->pts = s->next_pts;
330  else
331  out->pts = in->pts;
332 
333  switch (outlink->format) {
334  case AV_SAMPLE_FMT_FLT:
335  srcf = (const float *)in->data[0];
336  dstf = (float *)out->data[0];
337  if (s->start_periods > 0 && s->stop_periods > 0) {
338  const float *src = srcf;
339  if (s->start_found_periods >= 0) {
340  for (int n = 0; n < in_nb_samples; n++) {
341  filter_start_flt(ctx, src + n * nb_channels,
342  dstf, &out_nb_samples,
343  nb_channels);
344  }
345  in_nb_samples = out_nb_samples;
346  out_nb_samples = 0;
347  src = dstf;
348  }
349  for (int n = 0; n < in_nb_samples; n++) {
350  filter_stop_flt(ctx, src + n * nb_channels,
351  dstf, &out_nb_samples,
352  nb_channels);
353  }
354  } else if (s->start_periods > 0) {
355  for (int n = 0; n < in_nb_samples; n++) {
356  filter_start_flt(ctx, srcf + n * nb_channels,
357  dstf, &out_nb_samples,
358  nb_channels);
359  }
360  } else if (s->stop_periods > 0) {
361  for (int n = 0; n < in_nb_samples; n++) {
362  filter_stop_flt(ctx, srcf + n * nb_channels,
363  dstf, &out_nb_samples,
364  nb_channels);
365  }
366  }
367  break;
368  case AV_SAMPLE_FMT_DBL:
369  srcd = (const double *)in->data[0];
370  dstd = (double *)out->data[0];
371  if (s->start_periods > 0 && s->stop_periods > 0) {
372  const double *src = srcd;
373  if (s->start_found_periods >= 0) {
374  for (int n = 0; n < in_nb_samples; n++) {
375  filter_start_dbl(ctx, src + n * nb_channels,
376  dstd, &out_nb_samples,
377  nb_channels);
378  }
379  in_nb_samples = out_nb_samples;
380  out_nb_samples = 0;
381  src = dstd;
382  }
383  for (int n = 0; n < in_nb_samples; n++) {
384  filter_stop_dbl(ctx, src + n * nb_channels,
385  dstd, &out_nb_samples,
386  nb_channels);
387  }
388  } else if (s->start_periods > 0) {
389  for (int n = 0; n < in_nb_samples; n++) {
390  filter_start_dbl(ctx, srcd + n * nb_channels,
391  dstd, &out_nb_samples,
392  nb_channels);
393  }
394  } else if (s->stop_periods > 0) {
395  for (int n = 0; n < in_nb_samples; n++) {
396  filter_stop_dbl(ctx, srcd + n * nb_channels,
397  dstd, &out_nb_samples,
398  nb_channels);
399  }
400  }
401  break;
402  }
403 
404  av_frame_free(&in);
405  if (out_nb_samples > 0) {
406  s->next_pts += out_nb_samples;
407  out->nb_samples = out_nb_samples;
408  return ff_filter_frame(outlink, out);
409  }
410 
411  av_frame_free(&out);
412  ff_filter_set_ready(ctx, 100);
413 
414  return 0;
415 }
416 
418 {
419  AVFilterLink *outlink = ctx->outputs[0];
420  AVFilterLink *inlink = ctx->inputs[0];
421  SilenceRemoveContext *s = ctx->priv;
422  AVFrame *in;
423  int ret;
424 
426 
428  if (ret < 0)
429  return ret;
430  if (ret > 0) {
431  if (s->start_periods == 1 && s->stop_periods == 0 &&
432  s->start_found_periods < 0) {
433  if (s->timestamp_mode == TS_WRITE)
434  in->pts = s->next_pts;
435  s->next_pts += in->nb_samples;
436  return ff_filter_frame(outlink, in);
437  }
438  if (s->start_periods == 0 && s->stop_periods == 0)
439  return ff_filter_frame(outlink, in);
440  return filter_frame(outlink, in);
441  }
442 
445 
446  return FFERROR_NOT_READY;
447 }
448 
450 {
451  SilenceRemoveContext *s = ctx->priv;
452 
453  av_frame_free(&s->start_window);
454  av_frame_free(&s->stop_window);
455  av_frame_free(&s->start_queuef);
456  av_frame_free(&s->stop_queuef);
457 
458  av_freep(&s->start_cache);
459  av_freep(&s->stop_cache);
460  av_freep(&s->start_front);
461  av_freep(&s->start_back);
462  av_freep(&s->stop_front);
463  av_freep(&s->stop_back);
464 }
465 
467  {
468  .name = "default",
469  .type = AVMEDIA_TYPE_AUDIO,
470  .config_props = config_input,
471  },
472 };
473 
475  {
476  .name = "default",
477  .type = AVMEDIA_TYPE_AUDIO,
478  .config_props = config_output,
479  },
480 };
481 
483  .name = "silenceremove",
484  .description = NULL_IF_CONFIG_SMALL("Remove silence."),
485  .priv_size = sizeof(SilenceRemoveContext),
486  .priv_class = &silenceremove_class,
487  .init = init,
488  .activate = activate,
489  .uninit = uninit,
494  .process_command = ff_filter_process_command,
496 };
SilenceRemoveContext::stop_queuef
AVFrame * stop_queuef
Definition: af_silenceremove.c:112
ff_get_audio_buffer
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:97
SilenceRemoveContext::compute_flt
float(* compute_flt)(float *c, float s, float ws, int size, int *front, int *back)
Definition: af_silenceremove.c:122
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
SilenceRemoveContext::stop_cache
double * stop_cache
Definition: af_silenceremove.c:106
out
FILE * out
Definition: movenc.c:55
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1015
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_silenceremove.c:166
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:160
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:486
SilenceRemoveContext::start_front
int * start_front
Definition: af_silenceremove.c:90
TS_COPY
@ TS_COPY
Definition: af_silenceremove.c:46
clear_windows
static void clear_windows(SilenceRemoveContext *s)
Definition: af_silenceremove.c:178
SilenceDetect
SilenceDetect
Definition: af_silenceremove.c:34
av_samples_set_silence
int av_samples_set_silence(uint8_t *const *audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
Definition: samplefmt.c:246
TimestampMode
TimestampMode
Definition: af_silenceremove.c:44
AVOption
AVOption.
Definition: opt.h:357
SilenceRemoveContext::start_silence_count
int start_silence_count
Definition: af_silenceremove.c:82
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Definition: opt.h:259
silenceremove_inputs
static const AVFilterPad silenceremove_inputs[]
Definition: af_silenceremove.c:466
AFR
#define AFR
Definition: af_silenceremove.c:128
SilenceRemoveContext::start_duration_opt
int64_t start_duration_opt
Definition: af_silenceremove.c:61
float.h
silenceremove_template.c
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
SilenceRemoveContext::start_silence_opt
int64_t start_silence_opt
Definition: af_silenceremove.c:64
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:321
SilenceRemoveContext::stop_silence
int64_t stop_silence
Definition: af_silenceremove.c:71
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(silenceremove)
FF_FILTER_FORWARD_STATUS_BACK
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition: filters.h:199
D_DEV
@ D_DEV
Definition: af_silenceremove.c:40
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:395
SilenceRemoveContext::stop_window_size
int stop_window_size
Definition: af_silenceremove.c:103
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1442
SilenceRemoveContext::detection
int detection
Definition: af_silenceremove.c:120
SilenceRemoveContext::start_window_size
int start_window_size
Definition: af_silenceremove.c:100
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
avassert.h
av_cold
#define av_cold
Definition: attributes.h:90
SilenceRemoveContext::start_queue_pos
int start_queue_pos
Definition: af_silenceremove.c:109
SilenceRemoveContext::stop_silence_count
int stop_silence_count
Definition: af_silenceremove.c:85
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_silenceremove.c:224
float
float
Definition: af_crystalizer.c:121
s
#define s(width, name)
Definition: cbs_vp9.c:198
SilenceRemoveContext::start_sample_count
int start_sample_count
Definition: af_silenceremove.c:81
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:247
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
filters.h
SilenceRemoveContext::start_queuef
AVFrame * start_queuef
Definition: af_silenceremove.c:108
ctx
AVFormatContext * ctx
Definition: movenc.c:49
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
filter_frame
static int filter_frame(AVFilterLink *outlink, AVFrame *in)
Definition: af_silenceremove.c:295
SilenceRemoveContext::cache_size
int cache_size
Definition: af_silenceremove.c:97
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
SilenceRemoveContext::stop_front
int * stop_front
Definition: af_silenceremove.c:93
double
double
Definition: af_crystalizer.c:131
SilenceRemoveContext
Definition: af_silenceremove.c:55
SilenceRemoveContext::start_threshold
double start_threshold
Definition: af_silenceremove.c:62
silenceremove_options
static const AVOption silenceremove_options[]
Definition: af_silenceremove.c:130
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_silenceremove.c:449
SilenceRemoveContext::compute_dbl
double(* compute_dbl)(double *c, double s, double ws, int size, int *front, int *back)
Definition: af_silenceremove.c:123
SilenceRemoveContext::window_duration_opt
int64_t window_duration_opt
Definition: af_silenceremove.c:74
SilenceRemoveContext::timestamp_mode
int timestamp_mode
Definition: af_silenceremove.c:76
TS_NB
@ TS_NB
Definition: af_silenceremove.c:47
AF
#define AF
Definition: af_silenceremove.c:127
SilenceRemoveContext::start_found_periods
int start_found_periods
Definition: af_silenceremove.c:78
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_silenceremove.c:199
size
int size
Definition: twinvq_data.h:10344
SilenceRemoveContext::start_window_pos
int start_window_pos
Definition: af_silenceremove.c:99
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
SilenceRemoveContext::stop_periods
int stop_periods
Definition: af_silenceremove.c:67
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:887
SilenceRemoveContext::stop_sample_count
int stop_sample_count
Definition: af_silenceremove.c:84
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
SilenceRemoveContext::stop_queue_pos
int stop_queue_pos
Definition: af_silenceremove.c:113
internal.h
SilenceRemoveContext::start_back
int * start_back
Definition: af_silenceremove.c:91
D_NB
@ D_NB
Definition: af_silenceremove.c:41
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:454
SilenceRemoveContext::stop_silence_opt
int64_t stop_silence_opt
Definition: af_silenceremove.c:72
TS_WRITE
@ TS_WRITE
Definition: af_silenceremove.c:45
ff_af_silenceremove
const AVFilter ff_af_silenceremove
Definition: af_silenceremove.c:482
SilenceRemoveContext::start_window
AVFrame * start_window
Definition: af_silenceremove.c:87
SilenceRemoveContext::stop_mode
int stop_mode
Definition: af_silenceremove.c:66
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
SilenceRemoveContext::start_queue_size
int start_queue_size
Definition: af_silenceremove.c:110
SilenceRemoveContext::stop_duration
int64_t stop_duration
Definition: af_silenceremove.c:68
SilenceRemoveContext::start_cache
double * start_cache
Definition: af_silenceremove.c:105
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
SilenceRemoveContext::stop_found_periods
int stop_found_periods
Definition: af_silenceremove.c:79
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
SilenceRemoveContext::start_mode
int start_mode
Definition: af_silenceremove.c:58
AVFilter
Filter definition.
Definition: avfilter.h:166
SilenceRemoveContext::stop_threshold
double stop_threshold
Definition: af_silenceremove.c:70
ret
ret
Definition: filter_design.txt:187
SilenceRemoveContext::found_nonsilence
int found_nonsilence
Definition: af_silenceremove.c:117
SilenceRemoveContext::restart
int restart
Definition: af_silenceremove.c:116
SilenceRemoveContext::window_duration
int64_t window_duration
Definition: af_silenceremove.c:96
D_PEAK
@ D_PEAK
Definition: af_silenceremove.c:37
OFFSET
#define OFFSET(x)
Definition: af_silenceremove.c:126
SilenceRemoveContext::start_periods
int start_periods
Definition: af_silenceremove.c:59
SilenceRemoveContext::stop_window
AVFrame * stop_window
Definition: af_silenceremove.c:88
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:245
avfilter.h
SilenceRemoveContext::stop_queue_size
int stop_queue_size
Definition: af_silenceremove.c:114
activate
static int activate(AVFilterContext *ctx)
Definition: af_silenceremove.c:417
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
ThresholdMode
ThresholdMode
Definition: af_silenceremove.c:50
mem.h
audio.h
SilenceRemoveContext::stop_duration_opt
int64_t stop_duration_opt
Definition: af_silenceremove.c:69
SilenceRemoveContext::start_silence
int64_t start_silence
Definition: af_silenceremove.c:63
FF_FILTER_FORWARD_STATUS
FF_FILTER_FORWARD_STATUS(inlink, outlink)
D_MEDIAN
@ D_MEDIAN
Definition: af_silenceremove.c:38
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
D_AVG
@ D_AVG
Definition: af_silenceremove.c:35
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
silenceremove_outputs
static const AVFilterPad silenceremove_outputs[]
Definition: af_silenceremove.c:474
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:155
T_ALL
@ T_ALL
Definition: af_silenceremove.c:52
AV_SAMPLE_FMT_DBL
@ AV_SAMPLE_FMT_DBL
double
Definition: samplefmt.h:61
D_RMS
@ D_RMS
Definition: af_silenceremove.c:36
D_PTP
@ D_PTP
Definition: af_silenceremove.c:39
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:254
SilenceRemoveContext::stop_window_pos
int stop_window_pos
Definition: af_silenceremove.c:102
AV_SAMPLE_FMT_FLT
@ AV_SAMPLE_FMT_FLT
float
Definition: samplefmt.h:60
SilenceRemoveContext::start_duration
int64_t start_duration
Definition: af_silenceremove.c:60
SilenceRemoveContext::stop_back
int * stop_back
Definition: af_silenceremove.c:94
T_ANY
@ T_ANY
Definition: af_silenceremove.c:51
FILTER_SAMPLEFMTS
#define FILTER_SAMPLEFMTS(...)
Definition: internal.h:170
ff_filter_set_ready
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Definition: avfilter.c:235
SilenceRemoveContext::next_pts
int64_t next_pts
Definition: af_silenceremove.c:118