FFmpeg
 All Data Structures Namespaces 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)
 
static int query_formats (AVFilterContext *ctx)
 
static double fade_gain (int curve, int64_t index, int range)
 
static int config_input (AVFilterLink *inlink)
 
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 ff_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; \
} \
} \
}
const char * s
Definition: avisynth_c.h:631
static double fade_gain(int curve, int64_t index, int range)
Definition: af_afade.c:123
uint8_t
AVS_Value src
Definition: avisynth_c.h:482
GLint GLenum type
Definition: opengl_enc.c:105
static double c[64]
void INT64 start
Definition: avisynth_c.h:553
for(j=16;j >0;--j)
const char * name
Definition: opengl_enc.c:103

Definition at line 162 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; \
} \
}
const char * s
Definition: avisynth_c.h:631
static double fade_gain(int curve, int64_t index, int range)
Definition: af_afade.c:123
uint8_t
AVS_Value src
Definition: avisynth_c.h:482
GLint GLenum type
Definition: opengl_enc.c:105
static double c[64]
void INT64 start
Definition: avisynth_c.h:553
for(j=16;j >0;--j)
const char * name
Definition: opengl_enc.c:103

Definition at line 180 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)
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.

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

Definition at line 123 of file af_afade.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 206 of file af_afade.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame buf 
)
static

Definition at line 230 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", "fade-in", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, "type" },
{ "out", "fade-out", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, "type" },
{ "start_sample", "set number of first sample to start fading", OFFSET(start_sample), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, FLAGS },
{ "ss", "set number of first sample to start fading", OFFSET(start_sample), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, FLAGS },
{ "nb_samples", "set number of samples for fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 44100}, 1, INT32_MAX, FLAGS },
{ "ns", "set number of samples for fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 44100}, 1, INT32_MAX, FLAGS },
{ "start_time", "set time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
{ "st", "set time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
{ "duration", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
{ "d", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
{ "curve", "set fade curve type", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, TRI, CBR, FLAGS, "curve" },
{ "c", "set fade curve type", 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 }
}
#define NULL
Definition: coverity.c:32
Definition: af_afade.c:45
static int64_t start_time
Definition: ffplay.c:320
static int64_t duration
Definition: ffplay.c:321
Definition: af_afade.c:45
Definition: af_afade.c:45
Definition: af_afade.c:45
GLint GLenum type
Definition: opengl_enc.c:105
Definition: af_afade.c:45
Definition: af_afade.c:45
#define FLAGS
Definition: af_afade.c:48
Definition: af_afade.c:45
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.

const AVFilterPad avfilter_af_afade_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_input,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_input(AVFilterLink *inlink)
Definition: af_afade.c:206
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: af_afade.c:230

Definition at line 275 of file af_afade.c.

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

Definition at line 285 of file af_afade.c.

AVFilter ff_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:275
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:248
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:451
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. ...
Definition: internal.h:175
static const AVFilterPad avfilter_af_afade_outputs[]
Definition: af_afade.c:285
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:239
static int flags
Definition: cpu.c:47
static av_cold int init(AVFilterContext *ctx)
Definition: af_afade.c:80

Definition at line 293 of file af_afade.c.