FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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

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

Definition at line 70 of file af_acrusher.c.

Definition at line 71 of file af_acrusher.c.

Function Documentation

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

Definition at line 92 of file af_acrusher.c.

Referenced by filter_frame().

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

Definition at line 108 of file af_acrusher.c.

Referenced by bitreduction().

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

Definition at line 113 of file af_acrusher.c.

Referenced by bitreduction().

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

Definition at line 118 of file af_acrusher.c.

Referenced by bitreduction().

static double bitreduction ( ACrusherContext s,
double  in 
)
static

Definition at line 123 of file af_acrusher.c.

Referenced by filter_frame().

static double lfo_get ( LFOContext lfo)
static

Definition at line 196 of file af_acrusher.c.

Referenced by filter_frame().

static void lfo_advance ( LFOContext lfo,
unsigned  count 
)
static

Definition at line 209 of file af_acrusher.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 216 of file af_acrusher.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 266 of file af_acrusher.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 296 of file af_acrusher.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 303 of file af_acrusher.c.

Variable Documentation

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
uint8_t bits
Definition: crc.c:296
mode
Definition: f_perms.c:27
#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,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> dc
#define A
Definition: af_acrusher.c:71

Definition at line 73 of file af_acrusher.c.

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.

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.

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:176
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:386
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:376
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.