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/opt.h"
28 #include "audio.h"
29 #include "filters.h"
30 #include "avfilter.h"
31 #include "internal.h"
32 
41 };
42 
47 };
48 
52 };
53 
54 typedef struct SilenceRemoveContext {
55  const AVClass *class;
56 
64 
65  int stop_mode;
72 
74 
76 
79 
82 
85 
88 
90  int *start_back;
91 
92  int *stop_front;
93  int *stop_back;
94 
97 
100 
103 
104  double *start_cache;
105  double *stop_cache;
106 
110 
114 
115  int restart;
118 
120 
121  float (*compute_flt)(float *c, float s, float ws, int size, int *front, int *back);
122  double (*compute_dbl)(double *c, double s, double ws, int size, int *front, int *back);
124 
125 #define OFFSET(x) offsetof(SilenceRemoveContext, x)
126 #define AF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
127 #define AFR AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
128 
129 static const AVOption silenceremove_options[] = {
130  { "start_periods", "set periods of silence parts to skip from start", OFFSET(start_periods), AV_OPT_TYPE_INT, {.i64=0}, 0, 9000, AF },
131  { "start_duration", "set start duration of non-silence part", OFFSET(start_duration_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
132  { "start_threshold", "set threshold for start silence detection", OFFSET(start_threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, DBL_MAX, AFR },
133  { "start_silence", "set start duration of silence part to keep", OFFSET(start_silence_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
134  { "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" },
135  { "any", 0, 0, AV_OPT_TYPE_CONST, {.i64=T_ANY}, 0, 0, AFR, .unit = "mode" },
136  { "all", 0, 0, AV_OPT_TYPE_CONST, {.i64=T_ALL}, 0, 0, AFR, .unit = "mode" },
137  { "stop_periods", "set periods of silence parts to skip from end", OFFSET(stop_periods), AV_OPT_TYPE_INT, {.i64=0}, -9000, 9000, AF },
138  { "stop_duration", "set stop duration of silence part", OFFSET(stop_duration_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
139  { "stop_threshold", "set threshold for stop silence detection", OFFSET(stop_threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, DBL_MAX, AFR },
140  { "stop_silence", "set stop duration of silence part to keep", OFFSET(stop_silence_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
141  { "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" },
142  { "detection", "set how silence is detected", OFFSET(detection), AV_OPT_TYPE_INT, {.i64=D_RMS}, 0, D_NB-1, AF, .unit = "detection" },
143  { "avg", "use mean absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_AVG}, 0, 0, AF, .unit = "detection" },
144  { "rms", "use root mean squared values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_RMS}, 0, 0, AF, .unit = "detection" },
145  { "peak", "use max absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_PEAK},0, 0, AF, .unit = "detection" },
146  { "median", "use median of absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_MEDIAN},0, 0, AF, .unit = "detection" },
147  { "ptp", "use absolute of max peak to min peak difference", 0, AV_OPT_TYPE_CONST, {.i64=D_PTP}, 0, 0, AF, .unit = "detection" },
148  { "dev", "use standard deviation from values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_DEV}, 0, 0, AF, .unit = "detection" },
149  { "window", "set duration of window for silence detection", OFFSET(window_duration_opt), AV_OPT_TYPE_DURATION, {.i64=20000}, 0, 100000000, AF },
150  { "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" },
151  { "write", "full timestamps rewrite, keep only the start time", 0, AV_OPT_TYPE_CONST, {.i64=TS_WRITE}, 0, 0, AF, .unit = "timestamp" },
152  { "copy", "non-dropped frames are left with same timestamp", 0, AV_OPT_TYPE_CONST, {.i64=TS_COPY}, 0, 0, AF, .unit = "timestamp" },
153  { NULL }
154 };
155 
156 AVFILTER_DEFINE_CLASS(silenceremove);
157 
158 #define DEPTH 32
159 #include "silenceremove_template.c"
160 
161 #undef DEPTH
162 #define DEPTH 64
163 #include "silenceremove_template.c"
164 
166 {
167  SilenceRemoveContext *s = ctx->priv;
168 
169  if (s->stop_periods < 0) {
170  s->stop_periods = -s->stop_periods;
171  s->restart = 1;
172  }
173 
174  return 0;
175 }
176 
178 {
179  av_samples_set_silence(s->start_window->extended_data, 0,
180  s->start_window->nb_samples,
181  s->start_window->ch_layout.nb_channels,
182  s->start_window->format);
183  av_samples_set_silence(s->stop_window->extended_data, 0,
184  s->stop_window->nb_samples,
185  s->stop_window->ch_layout.nb_channels,
186  s->stop_window->format);
187 
188  s->start_window_pos = 0;
189  s->start_window_size = 0;
190  s->stop_window_pos = 0;
191  s->stop_window_size = 0;
192  s->start_queue_pos = 0;
193  s->start_queue_size = 0;
194  s->stop_queue_pos = 0;
195  s->stop_queue_size = 0;
196 }
197 
199 {
200  AVFilterContext *ctx = inlink->dst;
201  SilenceRemoveContext *s = ctx->priv;
202 
203  s->next_pts = AV_NOPTS_VALUE;
204  s->window_duration = av_rescale(s->window_duration_opt, inlink->sample_rate,
205  AV_TIME_BASE);
206  s->window_duration = FFMAX(1, s->window_duration);
207 
208  s->start_duration = av_rescale(s->start_duration_opt, inlink->sample_rate,
209  AV_TIME_BASE);
210  s->start_silence = av_rescale(s->start_silence_opt, inlink->sample_rate,
211  AV_TIME_BASE);
212  s->stop_duration = av_rescale(s->stop_duration_opt, inlink->sample_rate,
213  AV_TIME_BASE);
214  s->stop_silence = av_rescale(s->stop_silence_opt, inlink->sample_rate,
215  AV_TIME_BASE);
216 
217  s->start_found_periods = 0;
218  s->stop_found_periods = 0;
219 
220  return 0;
221 }
222 
223 static int config_output(AVFilterLink *outlink)
224 {
225  AVFilterContext *ctx = outlink->src;
226  SilenceRemoveContext *s = ctx->priv;
227 
228  switch (s->detection) {
229  case D_AVG:
230  case D_RMS:
231  s->cache_size = 1;
232  break;
233  case D_DEV:
234  s->cache_size = 2;
235  break;
236  case D_MEDIAN:
237  case D_PEAK:
238  case D_PTP:
239  s->cache_size = s->window_duration;
240  break;
241  }
242 
243  s->start_window = ff_get_audio_buffer(outlink, s->window_duration);
244  s->stop_window = ff_get_audio_buffer(outlink, s->window_duration);
245  s->start_cache = av_calloc(outlink->ch_layout.nb_channels, s->cache_size * sizeof(*s->start_cache));
246  s->stop_cache = av_calloc(outlink->ch_layout.nb_channels, s->cache_size * sizeof(*s->stop_cache));
247  if (!s->start_window || !s->stop_window || !s->start_cache || !s->stop_cache)
248  return AVERROR(ENOMEM);
249 
250  s->start_queuef = ff_get_audio_buffer(outlink, s->start_silence + 1);
251  s->stop_queuef = ff_get_audio_buffer(outlink, s->stop_silence + 1);
252  if (!s->start_queuef || !s->stop_queuef)
253  return AVERROR(ENOMEM);
254 
255  s->start_front = av_calloc(outlink->ch_layout.nb_channels, sizeof(*s->start_front));
256  s->start_back = av_calloc(outlink->ch_layout.nb_channels, sizeof(*s->start_back));
257  s->stop_front = av_calloc(outlink->ch_layout.nb_channels, sizeof(*s->stop_front));
258  s->stop_back = av_calloc(outlink->ch_layout.nb_channels, sizeof(*s->stop_back));
259  if (!s->start_front || !s->start_back || !s->stop_front || !s->stop_back)
260  return AVERROR(ENOMEM);
261 
262  clear_windows(s);
263 
264  switch (s->detection) {
265  case D_AVG:
266  s->compute_flt = compute_avg_flt;
267  s->compute_dbl = compute_avg_dbl;
268  break;
269  case D_DEV:
270  s->compute_flt = compute_dev_flt;
271  s->compute_dbl = compute_dev_dbl;
272  break;
273  case D_PTP:
274  s->compute_flt = compute_ptp_flt;
275  s->compute_dbl = compute_ptp_dbl;
276  break;
277  case D_MEDIAN:
278  s->compute_flt = compute_median_flt;
279  s->compute_dbl = compute_median_dbl;
280  break;
281  case D_PEAK:
282  s->compute_flt = compute_peak_flt;
283  s->compute_dbl = compute_peak_dbl;
284  break;
285  case D_RMS:
286  s->compute_flt = compute_rms_flt;
287  s->compute_dbl = compute_rms_dbl;
288  break;
289  }
290 
291  return 0;
292 }
293 
294 static int filter_frame(AVFilterLink *outlink, AVFrame *in)
295 {
296  const int nb_channels = outlink->ch_layout.nb_channels;
297  AVFilterContext *ctx = outlink->src;
298  SilenceRemoveContext *s = ctx->priv;
299  int max_out_nb_samples;
300  int out_nb_samples = 0;
301  int in_nb_samples;
302  const double *srcd;
303  const float *srcf;
304  AVFrame *out;
305  double *dstd;
306  float *dstf;
307 
308  if (s->next_pts == AV_NOPTS_VALUE)
309  s->next_pts = in->pts;
310 
311  in_nb_samples = in->nb_samples;
312  max_out_nb_samples = in->nb_samples +
313  s->start_silence +
314  s->stop_silence;
315  if (max_out_nb_samples <= 0) {
316  av_frame_free(&in);
317  ff_filter_set_ready(ctx, 100);
318  return 0;
319  }
320 
321  out = ff_get_audio_buffer(outlink, max_out_nb_samples);
322  if (!out) {
323  av_frame_free(&in);
324  return AVERROR(ENOMEM);
325  }
326 
327  if (s->timestamp_mode == TS_WRITE)
328  out->pts = s->next_pts;
329  else
330  out->pts = in->pts;
331 
332  switch (outlink->format) {
333  case AV_SAMPLE_FMT_FLT:
334  srcf = (const float *)in->data[0];
335  dstf = (float *)out->data[0];
336  if (s->start_periods > 0 && s->stop_periods > 0) {
337  const float *src = srcf;
338  if (s->start_found_periods >= 0) {
339  for (int n = 0; n < in_nb_samples; n++) {
340  filter_start_flt(ctx, src + n * nb_channels,
341  dstf, &out_nb_samples,
342  nb_channels);
343  }
344  in_nb_samples = out_nb_samples;
345  out_nb_samples = 0;
346  src = dstf;
347  }
348  for (int n = 0; n < in_nb_samples; n++) {
349  filter_stop_flt(ctx, src + n * nb_channels,
350  dstf, &out_nb_samples,
351  nb_channels);
352  }
353  } else if (s->start_periods > 0) {
354  for (int n = 0; n < in_nb_samples; n++) {
355  filter_start_flt(ctx, srcf + n * nb_channels,
356  dstf, &out_nb_samples,
357  nb_channels);
358  }
359  } else if (s->stop_periods > 0) {
360  for (int n = 0; n < in_nb_samples; n++) {
361  filter_stop_flt(ctx, srcf + n * nb_channels,
362  dstf, &out_nb_samples,
363  nb_channels);
364  }
365  }
366  break;
367  case AV_SAMPLE_FMT_DBL:
368  srcd = (const double *)in->data[0];
369  dstd = (double *)out->data[0];
370  if (s->start_periods > 0 && s->stop_periods > 0) {
371  const double *src = srcd;
372  if (s->start_found_periods >= 0) {
373  for (int n = 0; n < in_nb_samples; n++) {
374  filter_start_dbl(ctx, src + n * nb_channels,
375  dstd, &out_nb_samples,
376  nb_channels);
377  }
378  in_nb_samples = out_nb_samples;
379  out_nb_samples = 0;
380  src = dstd;
381  }
382  for (int n = 0; n < in_nb_samples; n++) {
383  filter_stop_dbl(ctx, src + n * nb_channels,
384  dstd, &out_nb_samples,
385  nb_channels);
386  }
387  } else if (s->start_periods > 0) {
388  for (int n = 0; n < in_nb_samples; n++) {
389  filter_start_dbl(ctx, srcd + n * nb_channels,
390  dstd, &out_nb_samples,
391  nb_channels);
392  }
393  } else if (s->stop_periods > 0) {
394  for (int n = 0; n < in_nb_samples; n++) {
395  filter_stop_dbl(ctx, srcd + n * nb_channels,
396  dstd, &out_nb_samples,
397  nb_channels);
398  }
399  }
400  break;
401  }
402 
403  av_frame_free(&in);
404  if (out_nb_samples > 0) {
405  s->next_pts += out_nb_samples;
406  out->nb_samples = out_nb_samples;
407  return ff_filter_frame(outlink, out);
408  }
409 
410  av_frame_free(&out);
411  ff_filter_set_ready(ctx, 100);
412 
413  return 0;
414 }
415 
417 {
418  AVFilterLink *outlink = ctx->outputs[0];
419  AVFilterLink *inlink = ctx->inputs[0];
420  SilenceRemoveContext *s = ctx->priv;
421  AVFrame *in;
422  int ret;
423 
425 
427  if (ret < 0)
428  return ret;
429  if (ret > 0) {
430  if (s->start_periods == 1 && s->stop_periods == 0 &&
431  s->start_found_periods < 0) {
432  if (s->timestamp_mode == TS_WRITE)
433  in->pts = s->next_pts;
434  s->next_pts += in->nb_samples;
435  return ff_filter_frame(outlink, in);
436  }
437  if (s->start_periods == 0 && s->stop_periods == 0)
438  return ff_filter_frame(outlink, in);
439  return filter_frame(outlink, in);
440  }
441 
444 
445  return FFERROR_NOT_READY;
446 }
447 
449 {
450  SilenceRemoveContext *s = ctx->priv;
451 
452  av_frame_free(&s->start_window);
453  av_frame_free(&s->stop_window);
454  av_frame_free(&s->start_queuef);
455  av_frame_free(&s->stop_queuef);
456 
457  av_freep(&s->start_cache);
458  av_freep(&s->stop_cache);
459  av_freep(&s->start_front);
460  av_freep(&s->start_back);
461  av_freep(&s->stop_front);
462  av_freep(&s->stop_back);
463 }
464 
466  {
467  .name = "default",
468  .type = AVMEDIA_TYPE_AUDIO,
469  .config_props = config_input,
470  },
471 };
472 
474  {
475  .name = "default",
476  .type = AVMEDIA_TYPE_AUDIO,
477  .config_props = config_output,
478  },
479 };
480 
482  .name = "silenceremove",
483  .description = NULL_IF_CONFIG_SMALL("Remove silence."),
484  .priv_size = sizeof(SilenceRemoveContext),
485  .priv_class = &silenceremove_class,
486  .init = init,
487  .activate = activate,
488  .uninit = uninit,
493  .process_command = ff_filter_process_command,
495 };
SilenceRemoveContext::stop_queuef
AVFrame * stop_queuef
Definition: af_silenceremove.c:111
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:121
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:105
out
FILE * out
Definition: movenc.c:54
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_silenceremove.c:165
int64_t
long long int64_t
Definition: coverity.c:34
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:130
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:456
SilenceRemoveContext::start_front
int * start_front
Definition: af_silenceremove.c:89
TS_COPY
@ TS_COPY
Definition: af_silenceremove.c:45
clear_windows
static void clear_windows(SilenceRemoveContext *s)
Definition: af_silenceremove.c:177
SilenceDetect
SilenceDetect
Definition: af_silenceremove.c:33
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:43
AVOption
AVOption.
Definition: opt.h:346
SilenceRemoveContext::start_silence_count
int start_silence_count
Definition: af_silenceremove.c:81
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Definition: opt.h:249
silenceremove_inputs
static const AVFilterPad silenceremove_inputs[]
Definition: af_silenceremove.c:465
AFR
#define AFR
Definition: af_silenceremove.c:127
SilenceRemoveContext::start_duration_opt
int64_t start_duration_opt
Definition: af_silenceremove.c:60
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:63
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:313
SilenceRemoveContext::stop_silence
int64_t stop_silence
Definition: af_silenceremove.c:70
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:39
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:365
SilenceRemoveContext::stop_window_size
int stop_window_size
Definition: af_silenceremove.c:102
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:1445
SilenceRemoveContext::detection
int detection
Definition: af_silenceremove.c:119
SilenceRemoveContext::start_window_size
int start_window_size
Definition: af_silenceremove.c:99
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:108
SilenceRemoveContext::stop_silence_count
int stop_silence_count
Definition: af_silenceremove.c:84
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_silenceremove.c:223
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:80
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:237
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
filters.h
SilenceRemoveContext::start_queuef
AVFrame * start_queuef
Definition: af_silenceremove.c:107
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
filter_frame
static int filter_frame(AVFilterLink *outlink, AVFrame *in)
Definition: af_silenceremove.c:294
SilenceRemoveContext::cache_size
int cache_size
Definition: af_silenceremove.c:96
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:92
double
double
Definition: af_crystalizer.c:131
SilenceRemoveContext
Definition: af_silenceremove.c:54
SilenceRemoveContext::start_threshold
double start_threshold
Definition: af_silenceremove.c:61
silenceremove_options
static const AVOption silenceremove_options[]
Definition: af_silenceremove.c:129
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:448
SilenceRemoveContext::compute_dbl
double(* compute_dbl)(double *c, double s, double ws, int size, int *front, int *back)
Definition: af_silenceremove.c:122
SilenceRemoveContext::window_duration_opt
int64_t window_duration_opt
Definition: af_silenceremove.c:73
SilenceRemoveContext::timestamp_mode
int timestamp_mode
Definition: af_silenceremove.c:75
TS_NB
@ TS_NB
Definition: af_silenceremove.c:46
AF
#define AF
Definition: af_silenceremove.c:126
SilenceRemoveContext::start_found_periods
int start_found_periods
Definition: af_silenceremove.c:77
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:106
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_silenceremove.c:198
size
int size
Definition: twinvq_data.h:10344
SilenceRemoveContext::start_window_pos
int start_window_pos
Definition: af_silenceremove.c:98
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
SilenceRemoveContext::stop_periods
int stop_periods
Definition: af_silenceremove.c:66
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:890
SilenceRemoveContext::stop_sample_count
int stop_sample_count
Definition: af_silenceremove.c:83
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
SilenceRemoveContext::stop_queue_pos
int stop_queue_pos
Definition: af_silenceremove.c:112
internal.h
SilenceRemoveContext::start_back
int * start_back
Definition: af_silenceremove.c:90
D_NB
@ D_NB
Definition: af_silenceremove.c:40
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:424
SilenceRemoveContext::stop_silence_opt
int64_t stop_silence_opt
Definition: af_silenceremove.c:71
TS_WRITE
@ TS_WRITE
Definition: af_silenceremove.c:44
ff_af_silenceremove
const AVFilter ff_af_silenceremove
Definition: af_silenceremove.c:481
SilenceRemoveContext::start_window
AVFrame * start_window
Definition: af_silenceremove.c:86
SilenceRemoveContext::stop_mode
int stop_mode
Definition: af_silenceremove.c:65
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:109
SilenceRemoveContext::stop_duration
int64_t stop_duration
Definition: af_silenceremove.c:67
SilenceRemoveContext::start_cache
double * start_cache
Definition: af_silenceremove.c:104
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:78
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
SilenceRemoveContext::start_mode
int start_mode
Definition: af_silenceremove.c:57
AVFilter
Filter definition.
Definition: avfilter.h:166
SilenceRemoveContext::stop_threshold
double stop_threshold
Definition: af_silenceremove.c:69
ret
ret
Definition: filter_design.txt:187
SilenceRemoveContext::found_nonsilence
int found_nonsilence
Definition: af_silenceremove.c:116
SilenceRemoveContext::restart
int restart
Definition: af_silenceremove.c:115
SilenceRemoveContext::window_duration
int64_t window_duration
Definition: af_silenceremove.c:95
D_PEAK
@ D_PEAK
Definition: af_silenceremove.c:36
OFFSET
#define OFFSET(x)
Definition: af_silenceremove.c:125
SilenceRemoveContext::start_periods
int start_periods
Definition: af_silenceremove.c:58
SilenceRemoveContext::stop_window
AVFrame * stop_window
Definition: af_silenceremove.c:87
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
avfilter.h
SilenceRemoveContext::stop_queue_size
int stop_queue_size
Definition: af_silenceremove.c:113
activate
static int activate(AVFilterContext *ctx)
Definition: af_silenceremove.c:416
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
ThresholdMode
ThresholdMode
Definition: af_silenceremove.c:49
audio.h
SilenceRemoveContext::stop_duration_opt
int64_t stop_duration_opt
Definition: af_silenceremove.c:68
SilenceRemoveContext::start_silence
int64_t start_silence
Definition: af_silenceremove.c:62
FF_FILTER_FORWARD_STATUS
FF_FILTER_FORWARD_STATUS(inlink, outlink)
D_MEDIAN
@ D_MEDIAN
Definition: af_silenceremove.c:37
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
D_AVG
@ D_AVG
Definition: af_silenceremove.c:34
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:473
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:51
AV_SAMPLE_FMT_DBL
@ AV_SAMPLE_FMT_DBL
double
Definition: samplefmt.h:61
D_RMS
@ D_RMS
Definition: af_silenceremove.c:35
D_PTP
@ D_PTP
Definition: af_silenceremove.c:38
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
SilenceRemoveContext::stop_window_pos
int stop_window_pos
Definition: af_silenceremove.c:101
AV_SAMPLE_FMT_FLT
@ AV_SAMPLE_FMT_FLT
float
Definition: samplefmt.h:60
SilenceRemoveContext::start_duration
int64_t start_duration
Definition: af_silenceremove.c:59
SilenceRemoveContext::stop_back
int * stop_back
Definition: af_silenceremove.c:93
T_ANY
@ T_ANY
Definition: af_silenceremove.c:50
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:234
SilenceRemoveContext::next_pts
int64_t next_pts
Definition: af_silenceremove.c:117