FFmpeg
Loading...
Searching...
No Matches
af_adrc.c File Reference
#include <float.h>
#include "libavutil/eval.h"
#include "libavutil/ffmath.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/tx.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"

Go to the source code of this file.

Data Structures

struct  AudioDRCContext
 

Macros

#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
 

Enumerations

enum  var_name {
  VAR_CH , VAR_SN , VAR_NB_CHANNELS , VAR_T ,
  VAR_SR , VAR_P , VAR_F , VAR_VARS_NB
}
 

Functions

 AVFILTER_DEFINE_CLASS (adrc)
 
static void generate_hann_window (float *window, int size)
 
static int config_input (AVFilterLink *inlink)
 
static void apply_window (AudioDRCContext *s, const float *in_frame, float *out_frame, const int add_to_out_frame)
 
static float sqrf (float x)
 
static void get_energy (AVFilterContext *ctx, int len, float *energy, const float *spectral)
 
static void get_target_gain (AVFilterContext *ctx, int len, float *gain, const float *energy, double *var_values, float fx, int bypass)
 
static void get_envelope (AVFilterContext *ctx, int len, float *envelope, const float *energy, const float *gain)
 
static void get_factors (AVFilterContext *ctx, int len, float *factors, const float *envelope)
 
static void apply_factors (AVFilterContext *ctx, int len, float *spectrum, const float *factors)
 
static void feed (AVFilterContext *ctx, int ch, const float *in_samples, float *out_samples, float *in_frame, float *out_dist_frame, float *windowed_frame, float *drc_frame, float *spectrum_buf, float *energy, float *target_gain, float *envelope, float *factors)
 
static int drc_channel (AVFilterContext *ctx, AVFrame *in, AVFrame *out, int ch)
 
static int drc_channels (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 

Variables

static const char *const var_names []
 
static const AVOption adrc_options []
 
static const AVFilterPad inputs []
 
const FFFilter ff_af_adrc
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 95 of file af_adrc.c.

◆ FLAGS

Enumeration Type Documentation

◆ var_name

enum var_name
Enumerator
VAR_CH 
VAR_SN 
VAR_NB_CHANNELS 
VAR_T 
VAR_SR 
VAR_P 
VAR_F 
VAR_VARS_NB 

Definition at line 43 of file af_adrc.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( adrc )

◆ generate_hann_window()

static void generate_hann_window ( float * window,
int size )
static

Definition at line 108 of file af_adrc.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 117 of file af_adrc.c.

◆ apply_window()

static void apply_window ( AudioDRCContext * s,
const float * in_frame,
float * out_frame,
const int add_to_out_frame )
static

Definition at line 175 of file af_adrc.c.

◆ sqrf()

static float sqrf ( float x)
static

Definition at line 190 of file af_adrc.c.

Referenced by get_energy().

◆ get_energy()

static void get_energy ( AVFilterContext * ctx,
int len,
float * energy,
const float * spectral )
static

Definition at line 195 of file af_adrc.c.

Referenced by feed().

◆ get_target_gain()

static void get_target_gain ( AVFilterContext * ctx,
int len,
float * gain,
const float * energy,
double * var_values,
float fx,
int bypass )
static

Definition at line 207 of file af_adrc.c.

Referenced by feed().

◆ get_envelope()

static void get_envelope ( AVFilterContext * ctx,
int len,
float * envelope,
const float * energy,
const float * gain )
static

Definition at line 231 of file af_adrc.c.

Referenced by feed().

◆ get_factors()

static void get_factors ( AVFilterContext * ctx,
int len,
float * factors,
const float * envelope )
static

Definition at line 255 of file af_adrc.c.

Referenced by feed().

◆ apply_factors()

static void apply_factors ( AVFilterContext * ctx,
int len,
float * spectrum,
const float * factors )
static

Definition at line 264 of file af_adrc.c.

Referenced by feed().

◆ feed()

static void feed ( AVFilterContext * ctx,
int ch,
const float * in_samples,
float * out_samples,
float * in_frame,
float * out_dist_frame,
float * windowed_frame,
float * drc_frame,
float * spectrum_buf,
float * energy,
float * target_gain,
float * envelope,
float * factors )
static

Definition at line 275 of file af_adrc.c.

Referenced by drc_channel(), and parse_stream().

◆ drc_channel()

static int drc_channel ( AVFilterContext * ctx,
AVFrame * in,
AVFrame * out,
int ch )
static

Definition at line 324 of file af_adrc.c.

Referenced by drc_channels().

◆ drc_channels()

static int drc_channels ( AVFilterContext * ctx,
void * arg,
int jobnr,
int nb_jobs )
static

Definition at line 347 of file af_adrc.c.

Referenced by filter_frame().

◆ filter_frame()

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

Definition at line 361 of file af_adrc.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 393 of file af_adrc.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 432 of file af_adrc.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 465 of file af_adrc.c.

Variable Documentation

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"ch",
"sn",
"nb_channels",
"t",
"sr",
"p",
"f",
}
#define NULL
Definition coverity.c:32

Definition at line 32 of file af_adrc.c.

◆ adrc_options

const AVOption adrc_options[]
static
Initial value:
= {
{ "transfer", "set the transfer expression", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str="p"}, 0, 0, FLAGS },
{ "attack", "set the attack", OFFSET(attack_ms), AV_OPT_TYPE_DOUBLE, {.dbl=50.}, 1, 1000, FLAGS },
{ "release", "set the release", OFFSET(release_ms), AV_OPT_TYPE_DOUBLE, {.dbl=100.}, 5, 2000, FLAGS },
{ "channels", "set channels to filter",OFFSET(channels_to_filter),AV_OPT_TYPE_STRING,{.str="all"},0, 0, FLAGS },
{NULL}
}
#define FLAGS
Definition cmdutils.c:598
#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 98 of file af_adrc.c.

◆ inputs

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
}
static int config_input(AVFilterLink *inlink)
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201

Definition at line 481 of file af_adrc.c.

◆ ff_af_adrc

const FFFilter ff_af_adrc
Initial value:
= {
.p.name = "adrc",
.p.description = NULL_IF_CONFIG_SMALL("Audio Spectral Dynamic Range Controller."),
.p.priv_class = &adrc_class,
.priv_size = sizeof(AudioDRCContext),
.activate = activate,
.process_command = process_command,
}
static const AVFilterPad inputs[]
Definition af_aap.c:299
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
Definition audio.c:34
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition avfilter.h:204
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition samplefmt.h:66
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(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 489 of file af_adrc.c.