FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
af_silencedetect.c File Reference

Audio silence detector. More...

#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  SilenceDetectContext
 

Macros

#define OFFSET(x)   offsetof(SilenceDetectContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
 
#define SILENCE_DETECT(name, type)
 

Functions

 AVFILTER_DEFINE_CLASS (silencedetect)
 
static char * get_metadata_val (AVFrame *insamples, const char *key)
 
static av_always_inline void update (SilenceDetectContext *s, AVFrame *insamples, int is_silence, int64_t nb_samples_notify, AVRational time_base)
 
static int config_input (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *insamples)
 
static int query_formats (AVFilterContext *ctx)
 

Variables

static const AVOption silencedetect_options []
 
static const AVFilterPad silencedetect_inputs []
 
static const AVFilterPad silencedetect_outputs []
 
AVFilter ff_af_silencedetect
 

Detailed Description

Audio silence detector.

Definition in file af_silencedetect.c.

Macro Definition Documentation

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

Definition at line 48 of file af_silencedetect.c.

Definition at line 49 of file af_silencedetect.c.

#define SILENCE_DETECT (   name,
  type 
)
Value:
static void silencedetect_##name(SilenceDetectContext *s, AVFrame *insamples, \
int nb_samples, int64_t nb_samples_notify, \
{ \
const type *p = (const type *)insamples->data[0]; \
const type noise = s->noise; \
int i; \
\
for (i = 0; i < nb_samples; i++, p++) \
update(s, insamples, *p < noise && *p > -noise, \
nb_samples_notify, time_base); \
}

Definition at line 96 of file af_silencedetect.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( silencedetect  )
static char* get_metadata_val ( AVFrame insamples,
const char *  key 
)
static

Definition at line 60 of file af_silencedetect.c.

Referenced by update().

static av_always_inline void update ( SilenceDetectContext s,
AVFrame insamples,
int  is_silence,
int64_t  nb_samples_notify,
AVRational  time_base 
)
static

Definition at line 66 of file af_silencedetect.c.

Referenced by adpcm_decode_frame().

static int config_input ( AVFilterLink inlink)
static

Definition at line 115 of file af_silencedetect.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame insamples 
)
static

Definition at line 136 of file af_silencedetect.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 156 of file af_silencedetect.c.

Variable Documentation

const AVOption silencedetect_options[]
static
Initial value:
= {
{ "n", "set noise tolerance", OFFSET(noise), AV_OPT_TYPE_DOUBLE, {.dbl=0.001}, 0, DBL_MAX, FLAGS },
{ "noise", "set noise tolerance", OFFSET(noise), AV_OPT_TYPE_DOUBLE, {.dbl=0.001}, 0, DBL_MAX, FLAGS },
{ "d", "set minimum duration in seconds", OFFSET(duration), AV_OPT_TYPE_DOUBLE, {.dbl=2.}, 0, 24*60*60, FLAGS },
{ "duration", "set minimum duration in seconds", OFFSET(duration), AV_OPT_TYPE_DOUBLE, {.dbl=2.}, 0, 24*60*60, FLAGS },
{ NULL }
}

Definition at line 50 of file af_silencedetect.c.

const AVFilterPad silencedetect_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
{ NULL }
}

Definition at line 186 of file af_silencedetect.c.

const AVFilterPad silencedetect_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}

Definition at line 196 of file af_silencedetect.c.

AVFilter ff_af_silencedetect
Initial value:
= {
.name = "silencedetect",
.description = NULL_IF_CONFIG_SMALL("Detect silence."),
.priv_size = sizeof(SilenceDetectContext),
.priv_class = &silencedetect_class,
}

Definition at line 204 of file af_silencedetect.c.