Go to the documentation of this file.
47 int jobnr,
int nb_jobs);
50 #define SQR(x) ((x)*(x))
53 float hue_key,
float sat_key,
float val_key)
55 const float similarity =
s->similarity;
56 const float scale =
s->scale;
57 const float blend =
s->blend;
58 const int imax =
s->max;
59 const float max = imax;
60 const float half =
s->half;
61 const float uf =
u -
half;
62 const float vf = v -
half;
63 const float hue = hue_key < 0.f ? -hue_key :
atan2f(uf, vf) +
M_PI;
64 const float sat = sat_key < 0.f ? -sat_key :
sqrtf((uf * uf + vf * vf) / (
half *
half * 2.
f));
65 const float val = val_key < 0.f ? -val_key :
scale * y;
68 hue_key =
fabsf(hue_key);
69 sat_key =
fabsf(sat_key);
70 val_key =
fabsf(val_key);
73 SQR(sat_key) *
SQR(val_key) -
74 2.
f * sat *
val * sat_key * val_key *
cosf(hue_key - hue) +
76 if (
diff < similarity) {
78 }
else if (blend > FLT_MIN) {
93 const int hsub_log2 =
s->hsub_log2;
94 const int vsub_log2 =
s->vsub_log2;
95 const float hue =
s->hue;
96 const float sat =
s->sat;
97 const float val =
s->val;
118 const int hsub_log2 =
s->hsub_log2;
119 const int vsub_log2 =
s->vsub_log2;
120 const float hue =
s->hue;
121 const float sat =
s->sat;
122 const float val =
s->val;
142 const int hsub_log2 =
s->hsub_log2;
143 const int vsub_log2 =
s->vsub_log2;
148 const float scale =
s->scale;
149 const float hue =
s->hue;
150 const float sat =
s->sat;
151 const float val =
s->val;
154 for (
int x = 0; x <
width; ++x) {
163 float f = 1.f - t *
scale;
165 dstu[x] = 128 + (
u - 128) *
f;
166 dstv[x] = 128 + (v - 128) *
f;
178 const int hsub_log2 =
s->hsub_log2;
179 const int vsub_log2 =
s->vsub_log2;
184 const float scale =
s->scale;
185 const float half =
s->half;
186 const float hue =
s->hue;
187 const float sat =
s->sat;
188 const float val =
s->val;
191 for (
int x = 0; x <
width; ++x) {
200 float f = 1.f - t *
scale;
231 s->depth =
desc->comp[0].depth;
232 s->max = (1 <<
s->depth) - 1;
233 s->half = 0.5f *
s->max;
234 s->scale = 1.f /
s->max;
251 s->hsub_log2 =
desc->log2_chroma_w;
252 s->vsub_log2 =
desc->log2_chroma_h;
286 #define OFFSET(x) offsetof(HSVKeyContext, x)
287 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
302 .description =
NULL_IF_CONFIG_SMALL(
"Turns a certain HSV range into transparency. Operates on YUV colors."),
304 .priv_class = &hsvkey_class,
346 .priv_class = &hsvhold_class,
#define AV_PIX_FMT_YUVA422P16
static const AVFilterPad inputs[]
AVPixelFormat
Pixel format.
#define u(width, name, range_min, range_max)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define FILTER_PIXFMTS_ARRAY(array)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
static const AVFilterPad outputs[]
#define AV_PIX_FMT_YUVA422P9
This structure describes decoded (raw) audio or video data.
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV420P10
static uint8_t half(int a, int b)
const char * name
Filter name.
A link between two filters.
#define AV_PIX_FMT_YUVA422P10
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int config_input(AVFilterLink *inlink)
#define AV_PIX_FMT_YUVA420P9
AVFILTER_DEFINE_CLASS(hsvkey)
static int do_hsvhold_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
void * priv
private data for use by the filter
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUV422P9
static double val(void *priv, double ch)
static __device__ float fabsf(float a)
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
static av_cold int config_output(AVFilterLink *outlink)
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
#define AV_PIX_FMT_YUV422P16
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_PIX_FMT_YUV444P16
static int filter_frame(AVFilterLink *link, AVFrame *frame)
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
static int do_hsvkey_pixel(HSVKeyContext *s, int y, int u, int v, float hue_key, float sat_key, float val_key)
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_INPUTS(array)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
Describe the class of an AVClass context structure.
static int do_hsvhold16_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
static const AVOption hsvkey_options[]
static int do_hsvkey16_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
static __device__ float sqrtf(float a)
#define AV_PIX_FMT_YUV422P10
static const AVOption hsvhold_options[]
static void scale(int *out, const int *in, const int w, const int h, const int shift)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
float fmaxf(float, float)
int format
agreed upon media format
#define AV_PIX_FMT_YUV422P12
const AVFilter ff_vf_hsvkey
#define AV_PIX_FMT_YUV444P12
AVFilterContext * src
source filter
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.
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
static int do_hsvkey_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
#define AV_PIX_FMT_YUVA444P10
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
int(* do_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
const AVFilter ff_vf_hsvhold
const char * name
Pad name.
#define AV_PIX_FMT_YUV444P9
static enum AVPixelFormat key_pixel_fmts[]
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUVA422P12
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static enum AVPixelFormat hold_pixel_fmts[]
#define FILTER_OUTPUTS(array)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AV_PIX_FMT_YUV444P14
const AVFilter * filter
the AVFilter of which this is an instance
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14
AVFilterLink ** outputs
array of pointers to output links
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.