FFmpeg
Loading...
Searching...
No Matches
af_compand.c File Reference

audio compand filter More...

#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/ffmath.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/samplefmt.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"

Go to the source code of this file.

Data Structures

struct  ChanParam
 
struct  CompandSegment
 
struct  CompandContext
 

Macros

#define OFFSET(x)
 
#define A   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define MOD(a, b)
 
#define S(x)
 
#define S(x)
 
#define L(x)
 

Functions

 AVFILTER_DEFINE_CLASS (compand)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (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 []
 
const FFFilter ff_af_compand
 

Detailed Description

audio compand filter

Definition in file af_compand.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 72 of file af_compand.c.

◆ A

Definition at line 73 of file af_compand.c.

◆ MOD

#define MOD ( a,
b )
Value:
(((a) >= (b)) ? (a) - (b) : (a))
int a
#define b
Definition input.c:43

Definition at line 190 of file af_compand.c.

Referenced by compand_delay(), and compand_drain().

◆ S [1/2]

#define S ( x)
Value:
s->segments[2 * ((x) + 1)]
#define s(width, name)
Definition cbs_vp9.c:198

Referenced by config_output().

◆ S [2/2]

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

◆ L

#define L ( x)
Value:
s->segments[i - (x)]
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63

Referenced by config_output().

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( compand )

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 88 of file af_compand.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 95 of file af_compand.c.

Referenced by config_output().

◆ count_items()

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

Definition at line 104 of file af_compand.c.

Referenced by config_output().

◆ update_volume()

static void update_volume ( ChanParam * cp,
double in )
static

Definition at line 115 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 125 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 146 of file af_compand.c.

Referenced by config_output().

◆ compand_delay()

static int compand_delay ( AVFilterContext * ctx,
AVFrame * frame )
static

Definition at line 192 of file af_compand.c.

Referenced by config_output().

◆ compand_drain()

static int compand_drain ( AVFilterLink * outlink)
static

Definition at line 264 of file af_compand.c.

Referenced by request_frame().

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 299 of file af_compand.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink * inlink,
AVFrame * frame )
static

Definition at line 505 of file af_compand.c.

◆ request_frame()

static int request_frame ( AVFilterLink * outlink)
static

Definition at line 513 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 }
}
#define A(x)
Definition vpx_arith.h:28
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition opt.h:266
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275

Definition at line 75 of file af_compand.c.

◆ compand_inputs

const AVFilterPad compand_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
}
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201

Definition at line 527 of file af_compand.c.

◆ compand_outputs

const AVFilterPad compand_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
.config_props = config_output,
},
}
static int request_frame(AVFilterLink *outlink)
Definition af_aecho.c:272
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 535 of file af_compand.c.

◆ ff_af_compand

const FFFilter ff_af_compand
Initial value:
= {
.p.name = "compand",
.p.description = NULL_IF_CONFIG_SMALL(
"Compress or expand audio dynamic range."),
.p.priv_class = &compand_class,
.priv_size = sizeof(CompandContext),
.init = init,
}
static const AVFilterPad compand_inputs[]
Definition af_compand.c:527
static const AVFilterPad compand_outputs[]
Definition af_compand.c:535
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition samplefmt.h:67
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
Definition filters.h:257
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88

Definition at line 545 of file af_compand.c.