FFmpeg  4.0
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 void set_meta (AVFrame *insamples, int channel, const char *key, char *value)
 
static av_always_inline void update (SilenceDetectContext *s, AVFrame *insamples, int is_silence, int current_sample, 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)
 
static av_cold void uninit (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

◆ OFFSET

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

Definition at line 53 of file af_silencedetect.c.

◆ FLAGS

Definition at line 54 of file af_silencedetect.c.

◆ SILENCE_DETECT

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

Definition at line 118 of file af_silencedetect.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( silencedetect  )

◆ set_meta()

static void set_meta ( AVFrame insamples,
int  channel,
const char *  key,
char *  value 
)
static

Definition at line 66 of file af_silencedetect.c.

Referenced by update().

◆ update()

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

Definition at line 76 of file af_silencedetect.c.

Referenced by adpcm_decode_frame(), estimate_pitch(), and uninit().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 137 of file af_silencedetect.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame insamples 
)
static

Definition at line 170 of file af_silencedetect.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 196 of file af_silencedetect.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 229 of file af_silencedetect.c.

Variable Documentation

◆ silencedetect_options

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 },
{ "mono", "check each channel separately", OFFSET(mono), AV_OPT_TYPE_BOOL, {.i64=0.}, 0, 1, FLAGS },
{ NULL }
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
int64_t duration
Definition: movenc.c:63
#define FLAGS
static int noise(AVBSFContext *ctx, AVPacket *pkt)
Definition: noise_bsf.c:38

Definition at line 55 of file af_silencedetect.c.

◆ silencedetect_inputs

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 241 of file af_silencedetect.c.

◆ silencedetect_outputs

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

Definition at line 251 of file af_silencedetect.c.

◆ ff_af_silencedetect

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:186
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
static int query_formats(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)

Definition at line 259 of file af_silencedetect.c.