FFmpeg
Data Structures | Macros | Functions | Variables
vf_fade.c File Reference

video fade filter based heavily on vf_negate.c by Bobby Bingham More...

#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/common.h"
#include "libavutil/eval.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "drawutils.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  FadeContext
 

Macros

#define R   0
 
#define G   1
 
#define B   2
 
#define A   3
 
#define Y   0
 
#define U   1
 
#define V   2
 
#define FADE_IN   0
 
#define FADE_OUT   1
 
#define INTERP(c_name, c_idx)   av_clip_uint8(((c[c_idx]<<16) + ((int)p[c_name] - (int)c[c_idx]) * s->factor + (1<<15)) >> 16)
 
#define INTERPP(c_name, c_idx)   av_clip_uint8(((c[c_idx]<<16) + ((int)c_name - (int)c[c_idx]) * s->factor + (1<<15)) >> 16)
 
#define OFFSET(x)   offsetof(FadeContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

static av_cold int init (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static av_always_inline void filter_rgb (FadeContext *s, const AVFrame *frame, int slice_start, int slice_end, int do_alpha, int step)
 
static av_always_inline void filter_rgb_planar (FadeContext *s, const AVFrame *frame, int slice_start, int slice_end, int do_alpha)
 
static int filter_slice_rgb (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_slice_luma (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_slice_luma16 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_slice_chroma (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_slice_chroma16 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_slice_alpha (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_slice_alpha16 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int config_props (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
 AVFILTER_DEFINE_CLASS (fade)
 

Variables

static const enum AVPixelFormat studio_level_pix_fmts []
 
static const AVOption fade_options []
 
static const AVFilterPad avfilter_vf_fade_inputs []
 
static const AVFilterPad avfilter_vf_fade_outputs []
 
AVFilter ff_vf_fade
 

Detailed Description

video fade filter based heavily on vf_negate.c by Bobby Bingham

Definition in file vf_fade.c.

Macro Definition Documentation

#define R   0

Definition at line 40 of file vf_fade.c.

Referenced by filter_rgb().

#define G   1

Definition at line 41 of file vf_fade.c.

Referenced by filter_rgb().

#define B   2

Definition at line 42 of file vf_fade.c.

Referenced by filter_rgb().

#define A   3

Definition at line 43 of file vf_fade.c.

Referenced by filter_rgb(), filter_slice_alpha(), and filter_slice_alpha16().

#define Y   0

Definition at line 45 of file vf_fade.c.

#define U   1

Definition at line 46 of file vf_fade.c.

#define V   2

Definition at line 47 of file vf_fade.c.

#define FADE_IN   0

Definition at line 49 of file vf_fade.c.

Referenced by init().

#define FADE_OUT   1

Definition at line 50 of file vf_fade.c.

Referenced by filter_frame().

#define INTERP (   c_name,
  c_idx 
)    av_clip_uint8(((c[c_idx]<<16) + ((int)p[c_name] - (int)c[c_idx]) * s->factor + (1<<15)) >> 16)

Referenced by filter_rgb().

#define INTERPP (   c_name,
  c_idx 
)    av_clip_uint8(((c[c_idx]<<16) + ((int)c_name - (int)c[c_idx]) * s->factor + (1<<15)) >> 16)

Referenced by filter_rgb_planar().

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

Definition at line 517 of file vf_fade.c.

Definition at line 518 of file vf_fade.c.

Function Documentation

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 73 of file vf_fade.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 103 of file vf_fade.c.

static av_always_inline void filter_rgb ( FadeContext s,
const AVFrame frame,
int  slice_start,
int  slice_end,
int  do_alpha,
int  step 
)
static

Definition at line 185 of file vf_fade.c.

Referenced by filter_slice_rgb().

static av_always_inline void filter_rgb_planar ( FadeContext s,
const AVFrame frame,
int  slice_start,
int  slice_end,
int  do_alpha 
)
static

Definition at line 210 of file vf_fade.c.

Referenced by filter_slice_rgb().

static int filter_slice_rgb ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 233 of file vf_fade.c.

Referenced by filter_frame().

static int filter_slice_luma ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 253 of file vf_fade.c.

static int filter_slice_luma16 ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 278 of file vf_fade.c.

Referenced by config_props().

static int filter_slice_chroma ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 303 of file vf_fade.c.

static int filter_slice_chroma16 ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 330 of file vf_fade.c.

Referenced by config_props().

static int filter_slice_alpha ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 356 of file vf_fade.c.

static int filter_slice_alpha16 ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 381 of file vf_fade.c.

Referenced by config_props().

static int config_props ( AVFilterLink inlink)
static

Definition at line 406 of file vf_fade.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 439 of file vf_fade.c.

AVFILTER_DEFINE_CLASS ( fade  )

Variable Documentation

const enum AVPixelFormat studio_level_pix_fmts[]
static
Initial value:
= {
}
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:442
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:434
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:436
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:409
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:437
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:403
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:433
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:412
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:404
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:441
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:443
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:402
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:397
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:440
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:438
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:398
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:410
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:407
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:399
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:405
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:396
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:408
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:400
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:406
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:435
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:411
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:439

Definition at line 169 of file vf_fade.c.

Referenced by config_props().

const AVOption fade_options[]
static
Initial value:
= {
{ "type", "set the fade direction", OFFSET(type), AV_OPT_TYPE_INT, { .i64 = FADE_IN }, FADE_IN, FADE_OUT, FLAGS, "type" },
{ "t", "set the fade direction", OFFSET(type), AV_OPT_TYPE_INT, { .i64 = FADE_IN }, FADE_IN, FADE_OUT, FLAGS, "type" },
{ "in", "fade-in", 0, AV_OPT_TYPE_CONST, { .i64 = FADE_IN }, .flags = FLAGS, .unit = "type" },
{ "out", "fade-out", 0, AV_OPT_TYPE_CONST, { .i64 = FADE_OUT }, .flags = FLAGS, .unit = "type" },
{ "start_frame", "Number of the first frame to which to apply the effect.",
OFFSET(start_frame), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
{ "s", "Number of the first frame to which to apply the effect.",
OFFSET(start_frame), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
{ "nb_frames", "Number of frames to which the effect should be applied.",
OFFSET(nb_frames), AV_OPT_TYPE_INT, { .i64 = 25 }, 1, INT_MAX, FLAGS },
{ "n", "Number of frames to which the effect should be applied.",
OFFSET(nb_frames), AV_OPT_TYPE_INT, { .i64 = 25 }, 1, INT_MAX, FLAGS },
{ "alpha", "fade alpha if it is available on the input", OFFSET(alpha), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FLAGS },
{ "start_time", "Number of seconds of the beginning of the effect.",
OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
{ "st", "Number of seconds of the beginning of the effect.",
OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
{ "duration", "Duration of the effect in seconds.",
OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
{ "d", "Duration of the effect in seconds.",
OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
{ "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, 0, 0, FLAGS },
{ "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, 0, 0, FLAGS },
{ NULL }
}
#define NULL
Definition: coverity.c:32
GLint GLenum type
Definition: opengl_enc.c:104
static int64_t start_time
Definition: ffplay.c:332
#define FLAGS
Definition: vf_fade.c:518
int64_t duration
Definition: movenc.c:63
#define FADE_OUT
Definition: vf_fade.c:50
static const int16_t alpha[]
Definition: ilbcdata.h:55
#define FADE_IN
Definition: vf_fade.c:49
#define OFFSET(x)
Definition: vf_fade.c:517

Definition at line 520 of file vf_fade.c.

const AVFilterPad avfilter_vf_fade_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_props,
.filter_frame = filter_frame,
.needs_writable = 1,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_props(AVFilterLink *inlink)
Definition: vf_fade.c:406
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_fade.c:439

Definition at line 549 of file vf_fade.c.

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

Definition at line 560 of file vf_fade.c.

AVFilter ff_vf_fade
Initial value:
= {
.name = "fade",
.description = NULL_IF_CONFIG_SMALL("Fade in/out input video."),
.init = init,
.priv_size = sizeof(FadeContext),
.priv_class = &fade_class,
}
static const AVFilterPad avfilter_vf_fade_outputs[]
Definition: vf_fade.c:560
static int query_formats(AVFilterContext *ctx)
Definition: vf_fade.c:103
static av_cold int init(AVFilterContext *ctx)
Definition: vf_fade.c:73
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:153
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
static const AVFilterPad avfilter_vf_fade_inputs[]
Definition: vf_fade.c:549
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
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
#define flags(name, subs,...)
Definition: cbs_av1.c:560

Definition at line 568 of file vf_fade.c.