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

audio compand filter More...

#include "libavutil/avassert.h"
#include "libavutil/avstring.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

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

Definition at line 70 of file af_compand.c.

Definition at line 71 of file af_compand.c.

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

Definition at line 215 of file af_compand.c.

Referenced by compand_delay().

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

Function Documentation

AVFILTER_DEFINE_CLASS ( compand  )
static av_cold int init ( AVFilterContext ctx)
static

Definition at line 86 of file af_compand.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 93 of file af_compand.c.

Referenced by config_output().

static int query_formats ( AVFilterContext ctx)
static

Definition at line 102 of file af_compand.c.

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

Definition at line 129 of file af_compand.c.

Referenced by config_output().

static void update_volume ( ChanParam cp,
double  in 
)
static

Definition at line 140 of file af_compand.c.

Referenced by compand_delay(), and compand_nodelay().

static double get_volume ( CompandContext s,
double  in_lin 
)
static

Definition at line 150 of file af_compand.c.

Referenced by compand_delay(), and compand_nodelay().

static int compand_nodelay ( AVFilterContext ctx,
AVFrame frame 
)
static

Definition at line 171 of file af_compand.c.

Referenced by config_output().

static int compand_delay ( AVFilterContext ctx,
AVFrame frame 
)
static

Definition at line 217 of file af_compand.c.

Referenced by config_output().

static int compand_drain ( AVFilterLink outlink)
static

Definition at line 290 of file af_compand.c.

Referenced by request_frame().

static int config_output ( AVFilterLink outlink)
static

Definition at line 326 of file af_compand.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 531 of file af_compand.c.

static int request_frame ( AVFilterLink outlink)
static

Definition at line 539 of file af_compand.c.

Variable Documentation

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.3" }, 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" }, 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 73 of file af_compand.c.

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

Definition at line 553 of file af_compand.c.

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

Definition at line 562 of file af_compand.c.

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 573 of file af_compand.c.