FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
af_afade.c File Reference

fade audio filter More...

#include "libavutil/opt.h"
#include "audio.h"
#include "avfilter.h"
#include "internal.h"

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, const char *args)
 
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, AVFilterBufferRef *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 OFFSET (   x)    offsetof(AudioFadeContext, x)

Definition at line 47 of file af_afade.c.

Definition at line 48 of file af_afade.c.

#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; \
} \
} \
}

Definition at line 166 of file af_afade.c.

#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; \
} \
}

Definition at line 184 of file af_afade.c.

Referenced by avfilter_register_all().

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 av_cold int init ( AVFilterContext ctx,
const char *  args 
)
static

Definition at line 80 of file af_afade.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 97 of file af_afade.c.

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

Definition at line 127 of file af_afade.c.

static int config_output ( AVFilterLink outlink)
static

Definition at line 210 of file af_afade.c.

static int filter_frame ( AVFilterLink inlink,
AVFilterBufferRef buf 
)
static

Definition at line 235 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 second to start fading", OFFSET(start_time), AV_OPT_TYPE_DOUBLE, {.dbl = 0. }, 0, 7*24*60*60,FLAGS },
{ "st", "set expression of second to start fading", OFFSET(start_time), AV_OPT_TYPE_DOUBLE, {.dbl = 0. }, 0, 7*24*60*60,FLAGS },
{ "duration", "set expression for fade duration in seconds", OFFSET(duration), AV_OPT_TYPE_DOUBLE, {.dbl = 0. }, 0, 24*60*60, FLAGS },
{ "d", "set expression for fade duration in seconds", OFFSET(duration), AV_OPT_TYPE_DOUBLE, {.dbl = 0. }, 0, 24*60*60, 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 at line 50 of file af_afade.c.

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

Definition at line 280 of file af_afade.c.

const AVFilterPad avfilter_af_afade_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
{ NULL }
}

Definition at line 289 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,
}

Definition at line 298 of file af_afade.c.