FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
vf_chromakey.c File Reference
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  ChromakeyContext
 

Macros

#define FIXNUM(x)   lrint((x) * (1 << 10))
 
#define RGB_TO_U(rgb)   (((- FIXNUM(0.16874) * rgb[0] - FIXNUM(0.33126) * rgb[1] + FIXNUM(0.50000) * rgb[2] + (1 << 9) - 1) >> 10) + 128)
 
#define RGB_TO_V(rgb)   ((( FIXNUM(0.50000) * rgb[0] - FIXNUM(0.41869) * rgb[1] - FIXNUM(0.08131) * rgb[2] + (1 << 9) - 1) >> 10) + 128)
 
#define OFFSET(x)   offsetof(ChromakeyContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 

Functions

static uint8_t do_chromakey_pixel (ChromakeyContext *ctx, uint8_t u[9], uint8_t v[9])
 
static av_always_inline void get_pixel_uv (AVFrame *frame, int hsub_log2, int vsub_log2, int x, int y, uint8_t *u, uint8_t *v)
 
static int do_chromakey_slice (AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *link, AVFrame *frame)
 
static av_cold int initialize_chromakey (AVFilterContext *avctx)
 
static av_cold int query_formats (AVFilterContext *avctx)
 
static av_cold int config_input (AVFilterLink *inlink)
 
 AVFILTER_DEFINE_CLASS (chromakey)
 

Variables

static const AVFilterPad chromakey_inputs []
 
static const AVFilterPad chromakey_outputs []
 
static const AVOption chromakey_options []
 
AVFilter ff_vf_chromakey
 

Macro Definition Documentation

#define FIXNUM (   x)    lrint((x) * (1 << 10))

Definition at line 117 of file vf_chromakey.c.

#define RGB_TO_U (   rgb)    (((- FIXNUM(0.16874) * rgb[0] - FIXNUM(0.33126) * rgb[1] + FIXNUM(0.50000) * rgb[2] + (1 << 9) - 1) >> 10) + 128)

Definition at line 118 of file vf_chromakey.c.

Referenced by initialize_chromakey().

#define RGB_TO_V (   rgb)    ((( FIXNUM(0.50000) * rgb[0] - FIXNUM(0.41869) * rgb[1] - FIXNUM(0.08131) * rgb[2] + (1 << 9) - 1) >> 10) + 128)

Definition at line 119 of file vf_chromakey.c.

Referenced by initialize_chromakey().

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

Definition at line 185 of file vf_chromakey.c.

Definition at line 186 of file vf_chromakey.c.

Function Documentation

static uint8_t do_chromakey_pixel ( ChromakeyContext ctx,
uint8_t  u[9],
uint8_t  v[9] 
)
static

Definition at line 43 of file vf_chromakey.c.

Referenced by do_chromakey_slice().

static av_always_inline void get_pixel_uv ( AVFrame frame,
int  hsub_log2,
int  vsub_log2,
int  x,
int  y,
uint8_t u,
uint8_t v 
)
static

Definition at line 64 of file vf_chromakey.c.

Referenced by do_chromakey_slice().

static int do_chromakey_slice ( AVFilterContext avctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 76 of file vf_chromakey.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink link,
AVFrame frame 
)
static

Definition at line 106 of file vf_chromakey.c.

static av_cold int initialize_chromakey ( AVFilterContext avctx)
static

Definition at line 121 of file vf_chromakey.c.

static av_cold int query_formats ( AVFilterContext avctx)
static

Definition at line 136 of file vf_chromakey.c.

static av_cold int config_input ( AVFilterLink inlink)
static

Definition at line 154 of file vf_chromakey.c.

AVFILTER_DEFINE_CLASS ( chromakey  )

Variable Documentation

const AVFilterPad chromakey_inputs[]
static
Initial value:
= {
{
.name = "default",
.needs_writable = 1,
.filter_frame = filter_frame,
.config_props = config_input,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: vf_chromakey.c:106
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_chromakey.c:154

Definition at line 166 of file vf_chromakey.c.

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

Definition at line 177 of file vf_chromakey.c.

const AVOption chromakey_options[]
static
Initial value:
= {
{ "color", "set the chromakey key color", OFFSET(chromakey_rgba), AV_OPT_TYPE_COLOR, { .str = "black" }, CHAR_MIN, CHAR_MAX, FLAGS },
{ "similarity", "set the chromakey similarity value", OFFSET(similarity), AV_OPT_TYPE_FLOAT, { .dbl = 0.01 }, 0.01, 1.0, FLAGS },
{ "blend", "set the chromakey key blend value", OFFSET(blend), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, 0.0, 1.0, FLAGS },
{ "yuv", "color parameter is in yuv instead of rgb", OFFSET(is_yuv), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ NULL }
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
Definition: vf_chromakey.c:185
#define FLAGS
Definition: vf_chromakey.c:186

Definition at line 188 of file vf_chromakey.c.

AVFilter ff_vf_chromakey
Initial value:
= {
.name = "chromakey",
.description = NULL_IF_CONFIG_SMALL("Turns a certain color into transparency. Operates on YUV colors."),
.priv_size = sizeof(ChromakeyContext),
.priv_class = &chromakey_class,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#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:122
static const AVFilterPad chromakey_outputs[]
Definition: vf_chromakey.c:177
static av_cold int initialize_chromakey(AVFilterContext *avctx)
Definition: vf_chromakey.c:121
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:113
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:385
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:375
static int flags
Definition: cpu.c:47
static av_cold int query_formats(AVFilterContext *avctx)
Definition: vf_chromakey.c:136
static const AVFilterPad chromakey_inputs[]
Definition: vf_chromakey.c:166

Definition at line 198 of file vf_chromakey.c.