FFmpeg
Data Structures | Macros | Functions | Variables
vf_hsvkey.c File Reference
#include <float.h>
#include "libavutil/opt.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "internal.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 inputs []
 
static const AVFilterPad outputs []
 
static const AVOption hsvkey_options []
 
const AVFilter ff_vf_hsvkey
 
static enum AVPixelFormat hold_pixel_fmts []
 
static const AVOption hsvhold_options []
 
const AVFilter ff_vf_hsvhold
 

Macro Definition Documentation

◆ SQR

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

Definition at line 50 of file vf_hsvkey.c.

◆ OFFSET

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

Definition at line 286 of file vf_hsvkey.c.

◆ FLAGS

Definition at line 287 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 87 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 112 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 138 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 174 of file vf_hsvkey.c.

Referenced by config_output().

◆ filter_frame()

static int filter_frame ( AVFilterLink link,
AVFrame frame 
)
static

Definition at line 211 of file vf_hsvkey.c.

◆ config_output()

static av_cold int config_output ( AVFilterLink outlink)
static

Definition at line 225 of file vf_hsvkey.c.

◆ config_input()

static av_cold int config_input ( AVFilterLink inlink)
static

Definition at line 245 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

◆ inputs

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

Definition at line 268 of file vf_hsvkey.c.

◆ outputs

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

Definition at line 278 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 289 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 300 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 331 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 342 of file vf_hsvkey.c.

AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:522
inputs
static const AVFilterPad inputs[]
Definition: vf_hsvkey.c:268
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:162
outputs
static const AVFilterPad outputs[]
Definition: vf_hsvkey.c:278
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:514
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:521
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:516
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:478
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:517
config_input
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_hsvkey.c:245
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:513
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:523
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:476
val
static double val(void *priv, double ch)
Definition: aeval.c:78
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:481
config_output
static av_cold int config_output(AVFilterLink *outlink)
Definition: vf_hsvkey.c:225
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:490
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:108
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:491
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: vf_hsvkey.c:211
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:520
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:475
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:489
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:73
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
NULL
#define NULL
Definition: coverity.c:32
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:479
FLAGS
#define FLAGS
Definition: vf_hsvkey.c:287
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:106
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:483
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:485
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:890
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:174
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:518
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:147
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:238
HSVKeyContext
Definition: vf_hsvkey.c:29
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:477
key_pixel_fmts
static enum AVPixelFormat key_pixel_fmts[]
Definition: vf_hsvkey.c:257
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:515
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:482
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:487
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:519
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:78
OFFSET
#define OFFSET(x)
Definition: vf_hsvkey.c:286
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:117
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:77
hold_pixel_fmts
static enum AVPixelFormat hold_pixel_fmts[]
Definition: vf_hsvkey.c:312
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:488
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:173
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:486
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:52