FFmpeg
Data Structures | Macros | Functions | Variables
af_compand.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/ffmath.h"
#include "libavutil/opt.h"
#include "libavutil/samplefmt.h"
#include "audio.h"
#include "avfilter.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  ChanParam
 
struct  CompandSegment
 
struct  CompandContext
 

Macros

#define OFFSET(x)   offsetof(CompandContext, x)
 
#define A   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define MOD(a, b)   (((a) >= (b)) ? (a) - (b) : (a))
 
#define S(x)   s->segments[2 * ((x) + 1)]
 
#define S(x)   s->segments[2 * (x)]
 
#define L(x)   s->segments[i - (x)]
 

Functions

 AVFILTER_DEFINE_CLASS (compand)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static void count_items (char *item_str, int *nb_items)
 
static void update_volume (ChanParam *cp, double in)
 
static double get_volume (CompandContext *s, double in_lin)
 
static int compand_nodelay (AVFilterContext *ctx, AVFrame *frame)
 
static int compand_delay (AVFilterContext *ctx, AVFrame *frame)
 
static int compand_drain (AVFilterLink *outlink)
 
static int config_output (AVFilterLink *outlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static int request_frame (AVFilterLink *outlink)
 

Variables

static const AVOption compand_options []
 
static const AVFilterPad compand_inputs []
 
static const AVFilterPad compand_outputs []
 
AVFilter ff_af_compand
 

Detailed Description

audio compand filter

Definition in file af_compand.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 71 of file af_compand.c.

◆ A

Definition at line 72 of file af_compand.c.

◆ MOD

#define MOD (   a,
  b 
)    (((a) >= (b)) ? (a) - (b) : (a))

Definition at line 219 of file af_compand.c.

◆ S [1/2]

#define S (   x)    s->segments[2 * ((x) + 1)]

◆ S [2/2]

#define S (   x)    s->segments[2 * (x)]

◆ L

#define L (   x)    s->segments[i - (x)]

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( compand  )

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 87 of file af_compand.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 94 of file af_compand.c.

Referenced by config_output().

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 103 of file af_compand.c.

◆ count_items()

static void count_items ( char *  item_str,
int nb_items 
)
static

Definition at line 133 of file af_compand.c.

Referenced by config_output().

◆ update_volume()

static void update_volume ( ChanParam cp,
double  in 
)
static

Definition at line 144 of file af_compand.c.

Referenced by compand_delay(), and compand_nodelay().

◆ get_volume()

static double get_volume ( CompandContext s,
double  in_lin 
)
static

Definition at line 154 of file af_compand.c.

Referenced by compand_delay(), compand_drain(), and compand_nodelay().

◆ compand_nodelay()

static int compand_nodelay ( AVFilterContext ctx,
AVFrame frame 
)
static

Definition at line 175 of file af_compand.c.

Referenced by config_output().

◆ compand_delay()

static int compand_delay ( AVFilterContext ctx,
AVFrame frame 
)
static

Definition at line 221 of file af_compand.c.

Referenced by config_output().

◆ compand_drain()

static int compand_drain ( AVFilterLink outlink)
static

Definition at line 293 of file af_compand.c.

Referenced by request_frame().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 328 of file af_compand.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 546 of file af_compand.c.

◆ request_frame()

static int request_frame ( AVFilterLink outlink)
static

Definition at line 554 of file af_compand.c.

Variable Documentation

◆ compand_options

const AVOption compand_options[]
static
Initial value:
= {
{ "attacks", "set time over which increase of volume is determined", OFFSET(attacks), AV_OPT_TYPE_STRING, { .str = "0" }, 0, 0, A },
{ "decays", "set time over which decrease of volume is determined", OFFSET(decays), AV_OPT_TYPE_STRING, { .str = "0.8" }, 0, 0, A },
{ "points", "set points of transfer function", OFFSET(points), AV_OPT_TYPE_STRING, { .str = "-70/-70|-60/-20|1/0" }, 0, 0, A },
{ "soft-knee", "set soft-knee", OFFSET(curve_dB), AV_OPT_TYPE_DOUBLE, { .dbl = 0.01 }, 0.01, 900, A },
{ "gain", "set output gain", OFFSET(gain_dB), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -900, 900, A },
{ "volume", "set initial volume", OFFSET(initial_volume), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -900, 0, A },
{ "delay", "set delay for samples before sending them to volume adjuster", OFFSET(delay), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, 0, 20, A },
{ NULL }
}

Definition at line 74 of file af_compand.c.

◆ compand_inputs

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

Definition at line 568 of file af_compand.c.

◆ compand_outputs

const AVFilterPad compand_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
.config_props = config_output,
},
{ NULL }
}

Definition at line 577 of file af_compand.c.

◆ ff_af_compand

AVFilter ff_af_compand
Initial value:
= {
.name = "compand",
.description = NULL_IF_CONFIG_SMALL(
"Compress or expand audio dynamic range."),
.query_formats = query_formats,
.priv_size = sizeof(CompandContext),
.priv_class = &compand_class,
.init = init,
}

Definition at line 588 of file af_compand.c.

query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_compand.c:103
OFFSET
#define OFFSET(x)
Definition: af_compand.c:71
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_compand.c:87
CompandContext
Definition: af_compand.c:50
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: af_compand.c:554
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_compand.c:328
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:227
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
compand_inputs
static const AVFilterPad compand_inputs[]
Definition: af_compand.c:568
NULL
#define NULL
Definition: coverity.c:32
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: af_compand.c:546
A
#define A
Definition: af_compand.c:72
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_compand.c:94
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
compand_outputs
static const AVFilterPad compand_outputs[]
Definition: af_compand.c:577