FFmpeg
Data Structures | Macros | Functions | Variables
af_sidechaincompress.c File Reference
#include "config_components.h"
#include "libavutil/audio_fifo.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/opt.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "hermite.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  SidechainCompressContext
 

Macros

#define OFFSET(x)   offsetof(SidechainCompressContext, x)
 
#define A   AV_OPT_FLAG_AUDIO_PARAM
 
#define F   AV_OPT_FLAG_FILTERING_PARAM
 
#define R   AV_OPT_FLAG_RUNTIME_PARAM
 
#define FAKE_INFINITY   (65536.0 * 65536.0)
 
#define IS_FAKE_INFINITY(value)   (fabs(value-FAKE_INFINITY) < 1.0)
 

Functions

 AVFILTER_DEFINE_CLASS_EXT (sidechaincompress_acompressor, "acompressor/sidechaincompress", options)
 
static double output_gain (double lin_slope, double ratio, double thres, double knee, double knee_start, double knee_stop, double compressed_knee_start, double compressed_knee_stop, int detection, int mode)
 
static int compressor_config_output (AVFilterLink *outlink)
 
static void compressor (SidechainCompressContext *s, const double *src, double *dst, const double *scsrc, int nb_samples, double level_in, double level_sc, AVFilterLink *inlink, AVFilterLink *sclink)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 

Variables

static const AVOption options []
 

Detailed Description

Audio (Sidechain) Compressor filter

Definition in file af_sidechaincompress.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 71 of file af_sidechaincompress.c.

◆ A

#define A   AV_OPT_FLAG_AUDIO_PARAM

Definition at line 72 of file af_sidechaincompress.c.

◆ F

Definition at line 73 of file af_sidechaincompress.c.

◆ R

#define R   AV_OPT_FLAG_RUNTIME_PARAM

Definition at line 74 of file af_sidechaincompress.c.

◆ FAKE_INFINITY

#define FAKE_INFINITY   (65536.0 * 65536.0)

Definition at line 103 of file af_sidechaincompress.c.

◆ IS_FAKE_INFINITY

#define IS_FAKE_INFINITY (   value)    (fabs(value-FAKE_INFINITY) < 1.0)

Definition at line 106 of file af_sidechaincompress.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS_EXT()

AVFILTER_DEFINE_CLASS_EXT ( sidechaincompress_acompressor  ,
"acompressor/sidechaincompress"  ,
options   
)

◆ output_gain()

static double output_gain ( double  lin_slope,
double  ratio,
double  thres,
double  knee,
double  knee_start,
double  knee_stop,
double  compressed_knee_start,
double  compressed_knee_stop,
int  detection,
int  mode 
)
static

Definition at line 108 of file af_sidechaincompress.c.

Referenced by compressor().

◆ compressor_config_output()

static int compressor_config_output ( AVFilterLink outlink)
static

Definition at line 144 of file af_sidechaincompress.c.

Referenced by process_command().

◆ compressor()

static void compressor ( SidechainCompressContext s,
const double src,
double dst,
const double scsrc,
int  nb_samples,
double  level_in,
double  level_sc,
AVFilterLink inlink,
AVFilterLink sclink 
)
static

Definition at line 165 of file af_sidechaincompress.c.

◆ process_command()

static int process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  args,
char *  res,
int  res_len,
int  flags 
)
static

Definition at line 220 of file af_sidechaincompress.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "level_in", "set input gain", OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A|F|R },
{ "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, A|F|R, .unit = "mode" },
{ "downward",0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F|R, .unit = "mode" },
{ "upward", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F|R, .unit = "mode" },
{ "threshold", "set threshold", OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0.125}, 0.000976563, 1, A|F|R },
{ "ratio", "set ratio", OFFSET(ratio), AV_OPT_TYPE_DOUBLE, {.dbl=2}, 1, 20, A|F|R },
{ "attack", "set attack", OFFSET(attack), AV_OPT_TYPE_DOUBLE, {.dbl=20}, 0.01, 2000, A|F|R },
{ "release", "set release", OFFSET(release), AV_OPT_TYPE_DOUBLE, {.dbl=250}, 0.01, 9000, A|F|R },
{ "makeup", "set make up gain", OFFSET(makeup), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 1, 64, A|F|R },
{ "knee", "set knee", OFFSET(knee), AV_OPT_TYPE_DOUBLE, {.dbl=2.82843}, 1, 8, A|F|R },
{ "link", "set link type", OFFSET(link), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, A|F|R, .unit = "link" },
{ "average", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F|R, .unit = "link" },
{ "maximum", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F|R, .unit = "link" },
{ "detection", "set detection", OFFSET(detection), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, A|F|R, .unit = "detection" },
{ "peak", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F|R, .unit = "detection" },
{ "rms", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F|R, .unit = "detection" },
{ "level_sc", "set sidechain gain", OFFSET(level_sc), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A|F|R },
{ "mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, A|F|R },
{ NULL }
}

Definition at line 76 of file af_sidechaincompress.c.

mix
static int mix(int c0, int c1)
Definition: 4xm.c:715
A
#define A
Definition: af_sidechaincompress.c:72
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:237
link
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 link
Definition: filter_design.txt:23
NULL
#define NULL
Definition: coverity.c:32
OFFSET
#define OFFSET(x)
Definition: af_sidechaincompress.c:71
R
#define R
Definition: af_sidechaincompress.c:74
F
#define F
Definition: af_sidechaincompress.c:73
mode
mode
Definition: ebur128.h:83
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244