FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
af_silenceremove.c File Reference
#include <float.h>
#include "libavutil/opt.h"
#include "libavutil/timestamp.h"
#include "audio.h"
#include "formats.h"
#include "avfilter.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  SilenceRemoveContext
 

Macros

#define OFFSET(x)   offsetof(SilenceRemoveContext, x)
 
#define AF   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
 

Enumerations

enum  SilenceDetect { D_PEAK, D_RMS }
 
enum  ThresholdMode { T_ANY, T_ALL }
 
enum  SilenceMode {
  SILENCE_TRIM, SILENCE_TRIM_FLUSH, SILENCE_COPY, SILENCE_COPY_FLUSH,
  SILENCE_STOP
}
 

Functions

 AVFILTER_DEFINE_CLASS (silenceremove)
 
static double compute_peak (SilenceRemoveContext *s, double sample)
 
static void update_peak (SilenceRemoveContext *s, double sample)
 
static double compute_rms (SilenceRemoveContext *s, double sample)
 
static void update_rms (SilenceRemoveContext *s, double sample)
 
static av_cold int init (AVFilterContext *ctx)
 
static void clear_window (SilenceRemoveContext *s)
 
static int config_input (AVFilterLink *inlink)
 
static void flush (SilenceRemoveContext *s, AVFrame *out, AVFilterLink *outlink, int *nb_samples_written, int *ret, int flush_silence)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int request_frame (AVFilterLink *outlink)
 
static int query_formats (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption silenceremove_options []
 
static const AVFilterPad silenceremove_inputs []
 
static const AVFilterPad silenceremove_outputs []
 
AVFilter ff_af_silenceremove
 

Macro Definition Documentation

#define OFFSET (   x)    offsetof(SilenceRemoveContext, x)

Definition at line 103 of file af_silenceremove.c.

Definition at line 104 of file af_silenceremove.c.

Enumeration Type Documentation

Enumerator
D_PEAK 
D_RMS 

Definition at line 33 of file af_silenceremove.c.

Enumerator
T_ANY 
T_ALL 

Definition at line 38 of file af_silenceremove.c.

Enumerator
SILENCE_TRIM 
SILENCE_TRIM_FLUSH 
SILENCE_COPY 
SILENCE_COPY_FLUSH 
SILENCE_STOP 

Definition at line 43 of file af_silenceremove.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( silenceremove  )
static double compute_peak ( SilenceRemoveContext s,
double  sample 
)
static

Definition at line 128 of file af_silenceremove.c.

Referenced by init().

static void update_peak ( SilenceRemoveContext s,
double  sample 
)
static

Definition at line 139 of file af_silenceremove.c.

Referenced by init().

static double compute_rms ( SilenceRemoveContext s,
double  sample 
)
static

Definition at line 150 of file af_silenceremove.c.

Referenced by init().

static void update_rms ( SilenceRemoveContext s,
double  sample 
)
static

Definition at line 161 of file af_silenceremove.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 172 of file af_silenceremove.c.

static void clear_window ( SilenceRemoveContext s)
static

Definition at line 195 of file af_silenceremove.c.

Referenced by config_input(), and filter_frame().

static int config_input ( AVFilterLink inlink)
static

Definition at line 204 of file af_silenceremove.c.

static void flush ( SilenceRemoveContext s,
AVFrame out,
AVFilterLink outlink,
int nb_samples_written,
int ret,
int  flush_silence 
)
static

Definition at line 265 of file af_silenceremove.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 319 of file af_silenceremove.c.

static int request_frame ( AVFilterLink outlink)
static

Definition at line 576 of file af_silenceremove.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 608 of file af_silenceremove.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 637 of file af_silenceremove.c.

Variable Documentation

const AVOption silenceremove_options[]
static
Initial value:
= {
{ "start_periods", NULL, OFFSET(start_periods), AV_OPT_TYPE_INT, {.i64=0}, 0, 9000, AF },
{ "start_duration", "set start duration of non-silence part", OFFSET(start_duration_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
{ "start_threshold", "set threshold for start silence detection", OFFSET(start_threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, DBL_MAX, AF },
{ "start_silence", "set start duration of silence part to keep", OFFSET(start_silence_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
{ "start_mode", "set which channel will trigger trimming from start", OFFSET(start_mode), AV_OPT_TYPE_INT, {.i64=T_ANY}, T_ANY, T_ALL, AF, "mode" },
{ "any", 0, 0, AV_OPT_TYPE_CONST, {.i64=T_ANY}, 0, 0, AF, "mode" },
{ "all", 0, 0, AV_OPT_TYPE_CONST, {.i64=T_ALL}, 0, 0, AF, "mode" },
{ "stop_periods", NULL, OFFSET(stop_periods), AV_OPT_TYPE_INT, {.i64=0}, -9000, 9000, AF },
{ "stop_duration", "set stop duration of non-silence part", OFFSET(stop_duration_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
{ "stop_threshold", "set threshold for stop silence detection", OFFSET(stop_threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, DBL_MAX, AF },
{ "stop_silence", "set stop duration of silence part to keep", OFFSET(stop_silence_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
{ "stop_mode", "set which channel will trigger trimming from end", OFFSET(stop_mode), AV_OPT_TYPE_INT, {.i64=T_ANY}, T_ANY, T_ALL, AF, "mode" },
{ "detection", "set how silence is detected", OFFSET(detection), AV_OPT_TYPE_INT, {.i64=D_RMS}, D_PEAK,D_RMS, AF, "detection" },
{ "peak", "use absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_PEAK},0, 0, AF, "detection" },
{ "rms", "use squared values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_RMS}, 0, 0, AF, "detection" },
{ "window", "set duration of window in seconds", OFFSET(window_ratio), AV_OPT_TYPE_DOUBLE, {.dbl=0.02}, 0, 10, AF },
{ NULL }
}
#define NULL
Definition: coverity.c:32
#define AF
#define OFFSET(x)

Definition at line 106 of file af_silenceremove.c.

const AVFilterPad silenceremove_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
{ NULL }
}
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
#define NULL
Definition: coverity.c:32
static int config_input(AVFilterLink *inlink)

Definition at line 648 of file af_silenceremove.c.

const AVFilterPad silenceremove_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int request_frame(AVFilterLink *outlink)

Definition at line 658 of file af_silenceremove.c.

AVFilter ff_af_silenceremove
Initial value:
= {
.name = "silenceremove",
.description = NULL_IF_CONFIG_SMALL("Remove silence."),
.priv_size = sizeof(SilenceRemoveContext),
.priv_class = &silenceremove_class,
.init = init,
}
static const AVFilterPad silenceremove_outputs[]
static av_cold int init(AVFilterContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad silenceremove_inputs[]
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
static av_cold void uninit(AVFilterContext *ctx)

Definition at line 667 of file af_silenceremove.c.