FFmpeg
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 158 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 159 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 160 of file vf_chromakey.c.

Referenced by initialize_chromakey().

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

Definition at line 242 of file vf_chromakey.c.

Definition at line 243 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 146 of file vf_chromakey.c.

static av_cold int initialize_chromakey ( AVFilterContext avctx)
static

Definition at line 162 of file vf_chromakey.c.

static av_cold int query_formats ( AVFilterContext avctx)
static

Definition at line 183 of file vf_chromakey.c.

static av_cold int config_input ( AVFilterLink inlink)
static

Definition at line 211 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:146
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_chromakey.c:211

Definition at line 223 of file vf_chromakey.c.

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

Definition at line 234 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:242
#define FLAGS
Definition: vf_chromakey.c:243

Definition at line 245 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:234
static av_cold int initialize_chromakey(AVFilterContext *avctx)
Definition: vf_chromakey.c:162
#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 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:561
static av_cold int query_formats(AVFilterContext *avctx)
Definition: vf_chromakey.c:183
static const AVFilterPad chromakey_inputs[]
Definition: vf_chromakey.c:223

Definition at line 255 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 },
{ "blend", "set the chromahold 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:242
#define FLAGS
Definition: vf_chromakey.c:243

Definition at line 267 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:146
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_chromakey.c:211

Definition at line 275 of file vf_chromakey.c.

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

Definition at line 286 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:275
static av_cold int initialize_chromakey(AVFilterContext *avctx)
Definition: vf_chromakey.c:162
#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:286
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:561
static av_cold int query_formats(AVFilterContext *avctx)
Definition: vf_chromakey.c:183

Definition at line 296 of file vf_chromakey.c.