FFmpeg
Loading...
Searching...
No Matches
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 "filters.h"
#include "formats.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)
 
#define INTERPP(c_name, c_idx)
 
#define OFFSET(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 (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
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_input (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 []
 
const FFFilter 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

◆ R

#define R   0

Definition at line 40 of file vf_fade.c.

◆ G

#define G   1

Definition at line 41 of file vf_fade.c.

◆ B

#define B   2

Definition at line 42 of file vf_fade.c.

◆ A

#define A   3

Definition at line 43 of file vf_fade.c.

◆ Y

#define Y   0

Definition at line 45 of file vf_fade.c.

◆ U

#define U   1

Definition at line 46 of file vf_fade.c.

◆ V

#define V   2

Definition at line 47 of file vf_fade.c.

◆ FADE_IN

#define FADE_IN   0

Definition at line 49 of file vf_fade.c.

Referenced by init().

◆ FADE_OUT

#define FADE_OUT   1

Definition at line 50 of file vf_fade.c.

Referenced by filter_frame().

◆ INTERP

#define INTERP ( c_name,
c_idx )
Value:
av_clip_uint8(((c[c_idx]<<16) + ((int)p[c_name] - (int)c[c_idx]) * s->factor + (1<<15)) >> 16)
#define s(width, name)
Definition cbs_vp9.c:198
#define av_clip_uint8
Definition common.h:106
static double c[64]

Referenced by filter_rgb().

◆ INTERPP

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

Referenced by filter_rgb_planar().

◆ OFFSET

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

Definition at line 538 of file vf_fade.c.

◆ FLAGS

Definition at line 539 of file vf_fade.c.

Function Documentation

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 74 of file vf_fade.c.

◆ query_formats()

static int query_formats ( const AVFilterContext * ctx,
AVFilterFormatsConfig ** cfg_in,
AVFilterFormatsConfig ** cfg_out )
static

Definition at line 104 of file vf_fade.c.

◆ filter_rgb()

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 203 of file vf_fade.c.

Referenced by filter_slice_rgb().

◆ filter_rgb_planar()

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 228 of file vf_fade.c.

Referenced by filter_slice_rgb().

◆ filter_slice_rgb()

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

Definition at line 251 of file vf_fade.c.

Referenced by filter_frame().

◆ filter_slice_luma()

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

Definition at line 271 of file vf_fade.c.

Referenced by config_input().

◆ filter_slice_luma16()

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

Definition at line 296 of file vf_fade.c.

Referenced by config_input().

◆ filter_slice_chroma()

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

Definition at line 321 of file vf_fade.c.

Referenced by config_input().

◆ filter_slice_chroma16()

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

Definition at line 348 of file vf_fade.c.

Referenced by config_input().

◆ filter_slice_alpha()

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

Definition at line 374 of file vf_fade.c.

Referenced by config_input().

◆ filter_slice_alpha16()

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

Definition at line 399 of file vf_fade.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 424 of file vf_fade.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink * inlink,
AVFrame * frame )
static

Definition at line 462 of file vf_fade.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( fade )

Variable Documentation

◆ studio_level_pix_fmts

const enum AVPixelFormat studio_level_pix_fmts[]
static
Initial value:
= {
}
#define AV_PIX_FMT_YUV420P16
Definition pixfmt.h:556
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUV444P9
Definition pixfmt.h:544
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:545
#define AV_PIX_FMT_YUV440P12
Definition pixfmt.h:551
#define AV_PIX_FMT_YUV422P9
Definition pixfmt.h:543
#define AV_PIX_FMT_YUVA444P10
Definition pixfmt.h:598
#define AV_PIX_FMT_YUVA420P16
Definition pixfmt.h:601
#define AV_PIX_FMT_YUV420P12
Definition pixfmt.h:549
#define AV_PIX_FMT_YUVA420P10
Definition pixfmt.h:596
#define AV_PIX_FMT_YUVA422P9
Definition pixfmt.h:594
#define AV_PIX_FMT_YUV422P12
Definition pixfmt.h:550
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:546
#define AV_PIX_FMT_YUV420P9
Definition pixfmt.h:542
#define AV_PIX_FMT_YUVA420P9
Definition pixfmt.h:593
#define AV_PIX_FMT_YUVA422P10
Definition pixfmt.h:597
#define AV_PIX_FMT_YUV420P14
Definition pixfmt.h:553
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
#define AV_PIX_FMT_YUVA422P12
Definition pixfmt.h:599
#define AV_PIX_FMT_YUV422P14
Definition pixfmt.h:554
#define AV_PIX_FMT_YUV422P16
Definition pixfmt.h:557
#define AV_PIX_FMT_YUVA444P16
Definition pixfmt.h:603
#define AV_PIX_FMT_YUVA422P16
Definition pixfmt.h:602
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:555
#define AV_PIX_FMT_YUVA444P9
Definition pixfmt.h:595
#define AV_PIX_FMT_YUVA444P12
Definition pixfmt.h:600
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:558
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:548

Definition at line 187 of file vf_fade.c.

Referenced by config_input().

◆ fade_options

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, .unit = "type" },
{ "t", "set the fade direction", OFFSET(type), AV_OPT_TYPE_INT, { .i64 = FADE_IN }, FADE_IN, FADE_OUT, FLAGS, .unit = "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 FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#define OFFSET(x)
static int64_t duration
Definition ffplay.c:330
static int64_t start_time
Definition ffplay.c:329
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
Definition opt.h:318
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
Definition opt.h:322
cl_device_type type
static const int16_t alpha[]
Definition ilbcdata.h:55
#define FADE_IN
Definition vf_fade.c:49
#define FADE_OUT
Definition vf_fade.c:50

Definition at line 541 of file vf_fade.c.

◆ avfilter_vf_fade_inputs

const AVFilterPad avfilter_vf_fade_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
}
static int config_input(AVFilterLink *inlink)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
Definition filters.h:59

Definition at line 570 of file vf_fade.c.

◆ ff_vf_fade

const FFFilter ff_vf_fade
Initial value:
= {
.p.name = "fade",
.p.description = NULL_IF_CONFIG_SMALL("Fade in/out input video."),
.p.priv_class = &fade_class,
.init = init,
.priv_size = sizeof(FadeContext),
}
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#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:196
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static const AVFilterPad avfilter_vf_fade_inputs[]
Definition vf_fade.c:570
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition video.c:37

Definition at line 580 of file vf_fade.c.