FFmpeg
Data Structures | Macros | Functions | Variables
vf_hsvkey.c File Reference
#include <float.h>
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  HSVKeyContext
 

Macros

#define SQR(x)   ((x)*(x))
 
#define OFFSET(x)   offsetof(HSVKeyContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 

Functions

static int do_hsvkey_pixel (HSVKeyContext *s, int y, int u, int v, float hue_key, float sat_key, float val_key)
 
static int do_hsvkey_slice (AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
 
static int do_hsvkey16_slice (AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
 
static int do_hsvhold_slice (AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
 
static int do_hsvhold16_slice (AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *link, AVFrame *frame)
 
static av_cold int config_output (AVFilterLink *outlink)
 
static av_cold int config_input (AVFilterLink *inlink)
 
 AVFILTER_DEFINE_CLASS (hsvkey)
 
 AVFILTER_DEFINE_CLASS (hsvhold)
 

Variables

static enum AVPixelFormat key_pixel_fmts []
 
static const AVFilterPad hsvkey_inputs []
 
static const AVFilterPad hsvkey_outputs []
 
static const AVOption hsvkey_options []
 
const AVFilter ff_vf_hsvkey
 
static enum AVPixelFormat hold_pixel_fmts []
 
static const AVOption hsvhold_options []
 
static const AVFilterPad hsvhold_inputs []
 
static const AVFilterPad hsvhold_outputs []
 
const AVFilter ff_vf_hsvhold
 

Macro Definition Documentation

◆ SQR

#define SQR (   x)    ((x)*(x))

Definition at line 52 of file vf_hsvkey.c.

◆ OFFSET

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

Definition at line 288 of file vf_hsvkey.c.

◆ FLAGS

Definition at line 289 of file vf_hsvkey.c.

Function Documentation

◆ do_hsvkey_pixel()

static int do_hsvkey_pixel ( HSVKeyContext s,
int  y,
int  u,
int  v,
float  hue_key,
float  sat_key,
float  val_key 
)
static

◆ do_hsvkey_slice()

static int do_hsvkey_slice ( AVFilterContext avctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 89 of file vf_hsvkey.c.

Referenced by config_output().

◆ do_hsvkey16_slice()

static int do_hsvkey16_slice ( AVFilterContext avctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 114 of file vf_hsvkey.c.

Referenced by config_output().

◆ do_hsvhold_slice()

static int do_hsvhold_slice ( AVFilterContext avctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 140 of file vf_hsvkey.c.

Referenced by config_output().

◆ do_hsvhold16_slice()

static int do_hsvhold16_slice ( AVFilterContext avctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 176 of file vf_hsvkey.c.

Referenced by config_output().

◆ filter_frame()

static int filter_frame ( AVFilterLink link,
AVFrame frame 
)
static

Definition at line 213 of file vf_hsvkey.c.

◆ config_output()

static av_cold int config_output ( AVFilterLink outlink)
static

Definition at line 227 of file vf_hsvkey.c.

◆ config_input()

static av_cold int config_input ( AVFilterLink inlink)
static

Definition at line 247 of file vf_hsvkey.c.

◆ AVFILTER_DEFINE_CLASS() [1/2]

AVFILTER_DEFINE_CLASS ( hsvkey  )

◆ AVFILTER_DEFINE_CLASS() [2/2]

AVFILTER_DEFINE_CLASS ( hsvhold  )

Variable Documentation

◆ key_pixel_fmts

enum AVPixelFormat key_pixel_fmts[]
static

◆ hsvkey_inputs

const AVFilterPad hsvkey_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_input,
},
}

Definition at line 270 of file vf_hsvkey.c.

◆ hsvkey_outputs

const AVFilterPad hsvkey_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}

Definition at line 280 of file vf_hsvkey.c.

◆ hsvkey_options

const AVOption hsvkey_options[]
static
Initial value:
= {
{ "hue", "set the hue value", OFFSET(hue_opt), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -360, 360, FLAGS },
{ "sat", "set the saturation value", OFFSET(sat), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -1, 1, FLAGS },
{ "val", "set the value value", OFFSET(val), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -1, 1, FLAGS },
{ "similarity", "set the hsvkey similarity value", OFFSET(similarity), AV_OPT_TYPE_FLOAT, { .dbl = 0.01}, 0.00001, 1.0, FLAGS },
{ "blend", "set the hsvkey blend value", OFFSET(blend), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, 0.0, 1.0, FLAGS },
{ NULL }
}

Definition at line 291 of file vf_hsvkey.c.

◆ ff_vf_hsvkey

const AVFilter ff_vf_hsvkey
Initial value:
= {
.name = "hsvkey",
.description = NULL_IF_CONFIG_SMALL("Turns a certain HSV range into transparency. Operates on YUV colors."),
.priv_size = sizeof(HSVKeyContext),
.priv_class = &hsvkey_class,
.process_command = ff_filter_process_command,
}

Definition at line 302 of file vf_hsvkey.c.

◆ hold_pixel_fmts

enum AVPixelFormat hold_pixel_fmts[]
static

◆ hsvhold_options

const AVOption hsvhold_options[]
static
Initial value:
= {
{ "hue", "set the hue value", OFFSET(hue_opt), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -360, 360, FLAGS },
{ "sat", "set the saturation value", OFFSET(sat), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -1, 1, FLAGS },
{ "val", "set the value value", OFFSET(val), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -1, 1, FLAGS },
{ "similarity", "set the hsvhold similarity value", OFFSET(similarity), AV_OPT_TYPE_FLOAT, { .dbl = 0.01 }, 0.00001, 1.0, FLAGS },
{ "blend", "set the hsvhold blend value", OFFSET(blend), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, 0.0, 1.0, FLAGS },
{ NULL }
}

Definition at line 333 of file vf_hsvkey.c.

◆ hsvhold_inputs

const AVFilterPad hsvhold_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_input,
},
}

Definition at line 342 of file vf_hsvkey.c.

◆ hsvhold_outputs

const AVFilterPad hsvhold_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}

Definition at line 352 of file vf_hsvkey.c.

◆ ff_vf_hsvhold

const AVFilter ff_vf_hsvhold
Initial value:
= {
.name = "hsvhold",
.description = NULL_IF_CONFIG_SMALL("Turns a certain HSV range into gray."),
.priv_size = sizeof(HSVKeyContext),
.priv_class = &hsvhold_class,
.process_command = ff_filter_process_command,
}

Definition at line 362 of file vf_hsvkey.c.

AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:447
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:439
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:446
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:441
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:404
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:442
config_input
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_hsvkey.c:247
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:438
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:448
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:402
val
static double val(void *priv, double ch)
Definition: aeval.c:76
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:407
config_output
static av_cold int config_output(AVFilterLink *outlink)
Definition: vf_hsvkey.c:227
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:416
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:417
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: vf_hsvkey.c:213
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:445
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:401
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:415
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
hsvhold_inputs
static const AVFilterPad hsvhold_inputs[]
Definition: vf_hsvkey.c:342
hsvkey_outputs
static const AVFilterPad hsvkey_outputs[]
Definition: vf_hsvkey.c:280
NULL
#define NULL
Definition: coverity.c:32
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:405
FLAGS
#define FLAGS
Definition: vf_hsvkey.c:289
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:409
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:411
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:882
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:167
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:443
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#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:146
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
HSVKeyContext
Definition: vf_hsvkey.c:31
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:403
key_pixel_fmts
static enum AVPixelFormat key_pixel_fmts[]
Definition: vf_hsvkey.c:259
hsvkey_inputs
static const AVFilterPad hsvkey_inputs[]
Definition: vf_hsvkey.c:270
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:440
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:408
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:413
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:444
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
OFFSET
#define OFFSET(x)
Definition: vf_hsvkey.c:288
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:121
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
hold_pixel_fmts
static enum AVPixelFormat hold_pixel_fmts[]
Definition: vf_hsvkey.c:314
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
hsvhold_outputs
static const AVFilterPad hsvhold_outputs[]
Definition: vf_hsvkey.c:352
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:414
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:166
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:412
AVFILTERPAD_FLAG_NEEDS_WRITABLE
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
Definition: internal.h:69