af_afade.c File Reference

fade audio filter More...

#include "libavutil/opt.h"
#include "audio.h"
#include "avfilter.h"
#include "internal.h"
Include dependency graph for af_afade.c:

Go to the source code of this file.

Data Structures

struct  AudioFadeContext
 

Macros

#define OFFSET(x)   offsetof(AudioFadeContext, x)
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define FADE_PLANAR(name, type)
 
#define FADE(name, type)
 

Enumerations

enum  CurveType {
  TRI, QSIN, ESIN, HSIN,
  LOG, PAR, QUA, CUB,
  SQU, CBR
}
 

Functions

 AVFILTER_DEFINE_CLASS (afade)
 
static av_cold int init (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static double fade_gain (int curve, int64_t index, int range)
 
static int config_output (AVFilterLink *outlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *buf)
 

Variables

static const AVOption afade_options []
 
static const AVFilterPad avfilter_af_afade_inputs []
 
static const AVFilterPad avfilter_af_afade_outputs []
 
AVFilter avfilter_af_afade
 

Detailed Description

fade audio filter

Definition in file af_afade.c.

Macro Definition Documentation

#define FADE (   name,
  type 
)
Value:
static void fade_samples_## name (uint8_t **dst, uint8_t * const *src, \
int nb_samples, int channels, int dir, \
int64_t start, int range, int curve) \
{ \
type *d = (type *)dst[0]; \
const type *s = (type *)src[0]; \
int i, c, k = 0; \
for (i = 0; i < nb_samples; i++) { \
double gain = fade_gain(curve, start + i * dir, range); \
for (c = 0; c < channels; c++, k++) \
d[k] = s[k] * gain; \
} \
}
const char * name
Definition: avisynth_c.h:675
Definition: start.py:1
const char * s
Definition: avisynth_c.h:668
static double fade_gain(int curve, int64_t index, int range)
Definition: af_afade.c:120
location of range
set threshold d
uint8_t
for k
AVS_Value src
Definition: avisynth_c.h:523
synthesis window for stochastic i
#define type
static double c[64]
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
for(j=16;j >0;--j)

Definition at line 177 of file af_afade.c.

Referenced by avfilter_register_all().

#define FADE_PLANAR (   name,
  type 
)
Value:
static void fade_samples_## name ##p(uint8_t **dst, uint8_t * const *src, \
int nb_samples, int channels, int dir, \
int64_t start, int range, int curve) \
{ \
int i, c; \
for (i = 0; i < nb_samples; i++) { \
double gain = fade_gain(curve, start + i * dir, range); \
for (c = 0; c < channels; c++) { \
type *d = (type *)dst[c]; \
const type *s = (type *)src[c]; \
\
d[i] = s[i] * gain; \
} \
} \
}
const char * name
Definition: avisynth_c.h:675
Definition: start.py:1
const char * s
Definition: avisynth_c.h:668
static double fade_gain(int curve, int64_t index, int range)
Definition: af_afade.c:120
location of range
set threshold d
uint8_t
AVS_Value src
Definition: avisynth_c.h:523
synthesis window for stochastic i
#define type
static double c[64]
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
for(j=16;j >0;--j)

Definition at line 159 of file af_afade.c.

Definition at line 48 of file af_afade.c.

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

Definition at line 47 of file af_afade.c.

Enumeration Type Documentation

enum CurveType
Enumerator
TRI 
QSIN 
ESIN 
HSIN 
LOG 
PAR 
QUA 
CUB 
SQU 
CBR 

Definition at line 45 of file af_afade.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( afade  )
static int config_output ( AVFilterLink outlink)
static

Definition at line 203 of file af_afade.c.

static double fade_gain ( int  curve,
int64_t  index,
int  range 
)
static

Definition at line 120 of file af_afade.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame buf 
)
static

Definition at line 228 of file af_afade.c.

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 80 of file af_afade.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 90 of file af_afade.c.

Variable Documentation

const AVOption afade_options[]
static
Initial value:
= {
{ "type", "set the fade direction", OFFSET(type), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS, "type" },
{ "t", "set the fade direction", OFFSET(type), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS, "type" },
{ "in", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, "type" },
{ "out", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, "type" },
{ "start_sample", "set expression of sample to start fading", OFFSET(start_sample), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, FLAGS },
{ "ss", "set expression of sample to start fading", OFFSET(start_sample), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, FLAGS },
{ "nb_samples", "set expression for fade duration in samples", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 44100}, 1, INT32_MAX, FLAGS },
{ "ns", "set expression for fade duration in samples", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 44100}, 1, INT32_MAX, FLAGS },
{ "start_time", "set expression of time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
{ "st", "set expression of time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
{ "duration", "set expression for fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
{ "d", "set expression for fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
{ "curve", "set expression for fade curve", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, TRI, CBR, FLAGS, "curve" },
{ "c", "set expression for fade curve", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, TRI, CBR, FLAGS, "curve" },
{ "tri", "linear slope", 0, AV_OPT_TYPE_CONST, {.i64 = TRI }, 0, 0, FLAGS, "curve" },
{ "qsin", "quarter of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = QSIN }, 0, 0, FLAGS, "curve" },
{ "esin", "exponential sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = ESIN }, 0, 0, FLAGS, "curve" },
{ "hsin", "half of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = HSIN }, 0, 0, FLAGS, "curve" },
{ "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64 = LOG }, 0, 0, FLAGS, "curve" },
{ "par", "inverted parabola", 0, AV_OPT_TYPE_CONST, {.i64 = PAR }, 0, 0, FLAGS, "curve" },
{ "qua", "quadratic", 0, AV_OPT_TYPE_CONST, {.i64 = QUA }, 0, 0, FLAGS, "curve" },
{ "cub", "cubic", 0, AV_OPT_TYPE_CONST, {.i64 = CUB }, 0, 0, FLAGS, "curve" },
{ "squ", "square root", 0, AV_OPT_TYPE_CONST, {.i64 = SQU }, 0, 0, FLAGS, "curve" },
{ "cbr", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64 = CBR }, 0, 0, FLAGS, "curve" },
{NULL},
}
Definition: af_afade.c:45
static int64_t start_time
Definition: ffplay.c:293
static int64_t duration
Definition: ffplay.c:294
Definition: af_afade.c:45
Definition: af_afade.c:45
NULL
Definition: eval.c:55
Definition: af_afade.c:45
Definition: af_afade.c:45
Definition: af_afade.c:45
#define FLAGS
Definition: af_afade.c:48
Definition: af_afade.c:45
#define type
Definition: af_afade.c:45
#define OFFSET(x)
Definition: af_afade.c:47
Definition: af_afade.c:45
Definition: af_afade.c:45

Definition at line 50 of file af_afade.c.

AVFilter avfilter_af_afade
Initial value:
= {
.name = "afade",
.description = NULL_IF_CONFIG_SMALL("Fade in/out input audio."),
.query_formats = query_formats,
.priv_size = sizeof(AudioFadeContext),
.init = init,
.priv_class = &afade_class,
}
static const AVFilterPad avfilter_af_afade_inputs[]
Definition: af_afade.c:273
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
static int query_formats(AVFilterContext *ctx)
Definition: af_afade.c:90
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static const AVFilterPad avfilter_af_afade_outputs[]
Definition: af_afade.c:282
static av_cold int init(AVFilterContext *ctx)
Definition: af_afade.c:80
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs

Definition at line 291 of file af_afade.c.

const AVFilterPad avfilter_af_afade_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}
NULL
Definition: eval.c:55
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: af_afade.c:228

Definition at line 273 of file af_afade.c.

const AVFilterPad avfilter_af_afade_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
{ NULL }
}
static int config_output(AVFilterLink *outlink)
Definition: af_afade.c:203
NULL
Definition: eval.c:55

Definition at line 282 of file af_afade.c.