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

Go to the source code of this file.

Data Structures

struct  LFOContext
 
struct  SRContext
 
struct  ACrusherContext
 

Macros

#define OFFSET(x)   offsetof(ACrusherContext, x)
 
#define A   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

 AVFILTER_DEFINE_CLASS (acrusher)
 
static double samplereduction (ACrusherContext *s, SRContext *sr, double in)
 
static double add_dc (double s, double dc, double idc)
 
static double remove_dc (double s, double dc, double idc)
 
static double factor (double y, double k, double aa1, double aa)
 
static double bitreduction (ACrusherContext *s, double in)
 
static double lfo_get (LFOContext *lfo)
 
static void lfo_advance (LFOContext *lfo, unsigned count)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int query_formats (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 

Variables

static const AVOption acrusher_options []
 
static const AVFilterPad avfilter_af_acrusher_inputs []
 
static const AVFilterPad avfilter_af_acrusher_outputs []
 
AVFilter ff_af_acrusher
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 70 of file af_acrusher.c.

◆ A

Definition at line 71 of file af_acrusher.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( acrusher  )

◆ samplereduction()

static double samplereduction ( ACrusherContext s,
SRContext sr,
double  in 
)
static

Definition at line 92 of file af_acrusher.c.

Referenced by filter_frame().

◆ add_dc()

static double add_dc ( double  s,
double  dc,
double  idc 
)
static

Definition at line 108 of file af_acrusher.c.

Referenced by bitreduction().

◆ remove_dc()

static double remove_dc ( double  s,
double  dc,
double  idc 
)
static

Definition at line 113 of file af_acrusher.c.

Referenced by bitreduction().

◆ factor()

static double factor ( double  y,
double  k,
double  aa1,
double  aa 
)
inlinestatic

Definition at line 118 of file af_acrusher.c.

Referenced by bitreduction().

◆ bitreduction()

static double bitreduction ( ACrusherContext s,
double  in 
)
static

Definition at line 123 of file af_acrusher.c.

Referenced by filter_frame().

◆ lfo_get()

static double lfo_get ( LFOContext lfo)
static

Definition at line 196 of file af_acrusher.c.

Referenced by filter_frame().

◆ lfo_advance()

static void lfo_advance ( LFOContext lfo,
unsigned  count 
)
static

Definition at line 209 of file af_acrusher.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 216 of file af_acrusher.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 266 of file af_acrusher.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 296 of file af_acrusher.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 303 of file af_acrusher.c.

Variable Documentation

◆ acrusher_options

const AVOption acrusher_options[]
static
Initial value:
= {
{ "level_in", "set level in", OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A },
{ "level_out","set level out", OFFSET(level_out), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A },
{ "bits", "set bit reduction", OFFSET(bits), AV_OPT_TYPE_DOUBLE, {.dbl=8}, 1, 64, A },
{ "mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=.5}, 0, 1, A },
{ "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, A, "mode" },
{ "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A, "mode" },
{ "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A, "mode" },
{ "dc", "set DC", OFFSET(dc), AV_OPT_TYPE_DOUBLE, {.dbl=1}, .25, 4, A },
{ "aa", "set anti-aliasing", OFFSET(aa), AV_OPT_TYPE_DOUBLE, {.dbl=.5}, 0, 1, A },
{ "samples", "set sample reduction", OFFSET(samples), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 1, 250, A },
{ "lfo", "enable LFO", OFFSET(is_lfo), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, A },
{ "lforange", "set LFO depth", OFFSET(lforange), AV_OPT_TYPE_DOUBLE, {.dbl=20}, 1, 250, A },
{ "lforate", "set LFO rate", OFFSET(lforate), AV_OPT_TYPE_DOUBLE, {.dbl=.3}, .01, 200, A },
{ NULL }
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
Definition: af_acrusher.c:70
static int mix(int c0, int c1)
Definition: 4xm.c:707
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> dc
#define A
Definition: af_acrusher.c:71
mode
Use these values in ebur128_init (or&#39;ed).
Definition: ebur128.h:83

Definition at line 73 of file af_acrusher.c.

◆ avfilter_af_acrusher_inputs

const AVFilterPad avfilter_af_acrusher_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_acrusher.c:216
static int config_input(AVFilterLink *inlink)
Definition: af_acrusher.c:303

Definition at line 335 of file af_acrusher.c.

◆ avfilter_af_acrusher_outputs

const AVFilterPad avfilter_af_acrusher_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 345 of file af_acrusher.c.

◆ ff_af_acrusher

AVFilter ff_af_acrusher
Initial value:
= {
.name = "acrusher",
.description = NULL_IF_CONFIG_SMALL("Reduce audio bit resolution."),
.priv_size = sizeof(ACrusherContext),
.priv_class = &acrusher_class,
}
static int query_formats(AVFilterContext *ctx)
Definition: af_acrusher.c:266
static const AVFilterPad avfilter_af_acrusher_inputs[]
Definition: af_acrusher.c:335
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
static const AVFilterPad avfilter_af_acrusher_outputs[]
Definition: af_acrusher.c:345
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_acrusher.c:296

Definition at line 353 of file af_acrusher.c.