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, \
AVRational time_base) \
{ \
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); \
}
const char * s
Definition: avisynth_c.h:768
This structure describes decoded (raw) audio or video data.
Definition: frame.h:201
static int noise(AVBSFContext *ctx, AVPacket *out)
Definition: noise_bsf.c:38
static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, int is_silence, int64_t nb_samples_notify, AVRational time_base)
GLint GLenum type
Definition: opengl_enc.c:105
Rational number (pair of numerator and denominator).
Definition: rational.h:58
for(j=16;j >0;--j)
const char * name
Definition: opengl_enc.c:103

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(), and estimate_pitch().

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 }
}
#define NULL
Definition: coverity.c:32
static int noise(AVBSFContext *ctx, AVPacket *out)
Definition: noise_bsf.c:38
#define OFFSET(x)
int64_t duration
Definition: movenc.c:63
#define FLAGS

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 }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
static int config_input(AVFilterLink *inlink)

Definition at line 189 of file af_silencedetect.c.

const AVFilterPad silencedetect_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 199 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,
}
static const AVFilterPad silencedetect_inputs[]
static const AVFilterPad silencedetect_outputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:389
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:379
static int query_formats(AVFilterContext *ctx)

Definition at line 207 of file af_silencedetect.c.