FFmpeg
Data Structures | Macros | Functions | Variables
af_apsyclip.c File Reference
#include "libavutil/opt.h"
#include "libavutil/tx.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  AudioPsyClipContext
 

Macros

#define OFFSET(x)   offsetof(AudioPsyClipContext, x)
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
 

Functions

 AVFILTER_DEFINE_CLASS (apsyclip)
 
static void generate_hann_window (float *window, float *inv_window, int size)
 
static void set_margin_curve (AudioPsyClipContext *s, const int(*points)[2], int num_points, int sample_rate)
 
static void generate_spread_table (AudioPsyClipContext *s)
 
static int config_input (AVFilterLink *inlink)
 
static void apply_window (AudioPsyClipContext *s, const float *in_frame, float *out_frame, const int add_to_out_frame)
 
static void calculate_mask_curve (AudioPsyClipContext *s, const float *spectrum, float *mask_curve)
 
static void clip_to_window (AudioPsyClipContext *s, const float *windowed_frame, float *clipping_delta, float delta_boost)
 
static void limit_clip_spectrum (AudioPsyClipContext *s, float *clip_spectrum, const float *mask_curve)
 
static void r2c (float *buffer, int size)
 
static void c2r (float *buffer, int size)
 
static void feed (AVFilterContext *ctx, int ch, const float *in_samples, float *out_samples, int diff_only, float *in_frame, float *out_dist_frame, float *windowed_frame, float *clipping_delta, float *spectrum_buf, float *mask_curve)
 
static int psy_channel (AVFilterContext *ctx, AVFrame *in, AVFrame *out, int ch)
 
static int psy_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)
 

Variables

static const AVOption apsyclip_options []
 
static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
const AVFilter ff_af_apsyclip
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 67 of file af_apsyclip.c.

◆ FLAGS

Definition at line 68 of file af_apsyclip.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( apsyclip  )

◆ generate_hann_window()

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

Definition at line 83 of file af_apsyclip.c.

Referenced by config_input().

◆ set_margin_curve()

static void set_margin_curve ( AudioPsyClipContext s,
const int(*)  points[2],
int  num_points,
int  sample_rate 
)
static

Definition at line 94 of file af_apsyclip.c.

Referenced by config_input().

◆ generate_spread_table()

static void generate_spread_table ( AudioPsyClipContext s)
static

Definition at line 120 of file af_apsyclip.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 185 of file af_apsyclip.c.

◆ apply_window()

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

Definition at line 267 of file af_apsyclip.c.

Referenced by feed().

◆ calculate_mask_curve()

static void calculate_mask_curve ( AudioPsyClipContext s,
const float spectrum,
float mask_curve 
)
static

Definition at line 281 of file af_apsyclip.c.

Referenced by feed().

◆ clip_to_window()

static void clip_to_window ( AudioPsyClipContext s,
const float windowed_frame,
float clipping_delta,
float  delta_boost 
)
static

Definition at line 331 of file af_apsyclip.c.

Referenced by feed().

◆ limit_clip_spectrum()

static void limit_clip_spectrum ( AudioPsyClipContext s,
float clip_spectrum,
const float mask_curve 
)
static

Definition at line 348 of file af_apsyclip.c.

Referenced by feed().

◆ r2c()

static void r2c ( float buffer,
int  size 
)
static

Definition at line 377 of file af_apsyclip.c.

Referenced by feed().

◆ c2r()

static void c2r ( float buffer,
int  size 
)
static

Definition at line 386 of file af_apsyclip.c.

Referenced by feed().

◆ feed()

static void feed ( AVFilterContext ctx,
int  ch,
const float in_samples,
float out_samples,
int  diff_only,
float in_frame,
float out_dist_frame,
float windowed_frame,
float clipping_delta,
float spectrum_buf,
float mask_curve 
)
static

Definition at line 395 of file af_apsyclip.c.

Referenced by psy_channel().

◆ psy_channel()

static int psy_channel ( AVFilterContext ctx,
AVFrame in,
AVFrame out,
int  ch 
)
static

Definition at line 510 of file af_apsyclip.c.

Referenced by psy_channels().

◆ psy_channels()

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

Definition at line 531 of file af_apsyclip.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 544 of file af_apsyclip.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 571 of file af_apsyclip.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 601 of file af_apsyclip.c.

Variable Documentation

◆ apsyclip_options

const AVOption apsyclip_options[]
static
Initial value:
= {
{ "level_in", "set input level", OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=1},.015625, 64, FLAGS },
{ "level_out", "set output level", OFFSET(level_out), AV_OPT_TYPE_DOUBLE, {.dbl=1},.015625, 64, FLAGS },
{ "clip", "set clip level", OFFSET(clip_level), AV_OPT_TYPE_DOUBLE, {.dbl=1},.015625, 1, FLAGS },
{ "diff", "enable difference", OFFSET(diff_only), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
{ "adaptive", "set adaptive distortion", OFFSET(adaptive), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 1, FLAGS },
{ "iterations", "set iterations", OFFSET(iterations), AV_OPT_TYPE_INT, {.i64=10}, 1, 20, FLAGS },
{ "level", "set auto level", OFFSET(auto_level), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
{NULL}
}

Definition at line 70 of file af_apsyclip.c.

◆ inputs

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
}

Definition at line 631 of file af_apsyclip.c.

◆ outputs

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

Definition at line 639 of file af_apsyclip.c.

◆ ff_af_apsyclip

const AVFilter ff_af_apsyclip
Initial value:
= {
.name = "apsyclip",
.description = NULL_IF_CONFIG_SMALL("Audio Psychoacoustic Clipper."),
.priv_size = sizeof(AudioPsyClipContext),
.priv_class = &apsyclip_class,
.activate = activate,
.process_command = ff_filter_process_command,
}

Definition at line 646 of file af_apsyclip.c.

AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
FILTER_SINGLE_SAMPLEFMT
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
Definition: internal.h:183
activate
static int activate(AVFilterContext *ctx)
Definition: af_apsyclip.c:571
AudioPsyClipContext
Definition: af_apsyclip.c:29
FLAGS
#define FLAGS
Definition: af_apsyclip.c:68
inputs
static const AVFilterPad inputs[]
Definition: af_apsyclip.c:631
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:227
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
OFFSET
#define OFFSET(x)
Definition: af_apsyclip.c:67
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
NULL
#define NULL
Definition: coverity.c:32
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_apsyclip.c:601
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
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:863
outputs
static const AVFilterPad outputs[]
Definition: af_apsyclip.c:639
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:127
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#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:160
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_apsyclip.c:185