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 do_chromahold_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)
 
 AVFILTER_DEFINE_CLASS (chromahold)
 

Variables

static const AVFilterPad chromakey_inputs []
 
static const AVFilterPad chromakey_outputs []
 
static const AVOption chromakey_options []
 
AVFilter ff_vf_chromakey
 
static const AVOption chromahold_options []
 
static const AVFilterPad chromahold_inputs []
 
static const AVFilterPad chromahold_outputs []
 
AVFilter ff_vf_chromahold
 

Macro Definition Documentation

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

Definition at line 153 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 154 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 155 of file vf_chromakey.c.

Referenced by initialize_chromakey().

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

Definition at line 237 of file vf_chromakey.c.

Definition at line 238 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 46 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 67 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 79 of file vf_chromakey.c.

Referenced by initialize_chromakey().

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

Definition at line 109 of file vf_chromakey.c.

Referenced by initialize_chromakey().

static int filter_frame ( AVFilterLink link,
AVFrame frame 
)
static

Definition at line 141 of file vf_chromakey.c.

static av_cold int initialize_chromakey ( AVFilterContext avctx)
static

Definition at line 157 of file vf_chromakey.c.

static av_cold int query_formats ( AVFilterContext avctx)
static

Definition at line 178 of file vf_chromakey.c.

static av_cold int config_input ( AVFilterLink inlink)
static

Definition at line 206 of file vf_chromakey.c.

AVFILTER_DEFINE_CLASS ( chromakey  )
AVFILTER_DEFINE_CLASS ( chromahold  )

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:141
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_chromakey.c:206

Definition at line 218 of file vf_chromakey.c.

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

Definition at line 229 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:237
#define FLAGS
Definition: vf_chromakey.c:238

Definition at line 240 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:125
static const AVFilterPad chromakey_outputs[]
Definition: vf_chromakey.c:229
static av_cold int initialize_chromakey(AVFilterContext *avctx)
Definition: vf_chromakey.c:157
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
#define flags(name, subs,...)
Definition: cbs_av1.c:596
static av_cold int query_formats(AVFilterContext *avctx)
Definition: vf_chromakey.c:178
static const AVFilterPad chromakey_inputs[]
Definition: vf_chromakey.c:218

Definition at line 250 of file vf_chromakey.c.

const AVOption chromahold_options[]
static
Initial value:
= {
{ "color", "set the chromahold key color", OFFSET(chromakey_rgba), AV_OPT_TYPE_COLOR, { .str = "black" }, CHAR_MIN, CHAR_MAX, FLAGS },
{ "similarity", "set the chromahold similarity value", OFFSET(similarity), AV_OPT_TYPE_FLOAT, { .dbl = 0.01 }, 0.01, 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:237
#define FLAGS
Definition: vf_chromakey.c:238

Definition at line 262 of file vf_chromakey.c.

const AVFilterPad chromahold_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:141
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_chromakey.c:206

Definition at line 269 of file vf_chromakey.c.

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

Definition at line 280 of file vf_chromakey.c.

AVFilter ff_vf_chromahold
Initial value:
= {
.name = "chromahold",
.description = NULL_IF_CONFIG_SMALL("Turns a certain color range into gray."),
.priv_size = sizeof(ChromakeyContext),
.priv_class = &chromahold_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:125
static const AVFilterPad chromahold_inputs[]
Definition: vf_chromakey.c:269
static av_cold int initialize_chromakey(AVFilterContext *avctx)
Definition: vf_chromakey.c:157
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
static const AVFilterPad chromahold_outputs[]
Definition: vf_chromakey.c:280
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
#define flags(name, subs,...)
Definition: cbs_av1.c:596
static av_cold int query_formats(AVFilterContext *avctx)
Definition: vf_chromakey.c:178

Definition at line 290 of file vf_chromakey.c.