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;
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;
100 for (
int x = 0; x <
frame->width; x++) {
101 int Y =
frame->data[0][
frame->linesize[0] * y + x];
102 int u =
frame->data[1][
frame->linesize[1] * (y >> vsub_log2) + (x >> hsub_log2)];
103 int v =
frame->data[2][
frame->linesize[2] * (y >> vsub_log2) + (x >> hsub_log2)];
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;
125 for (
int x = 0; x <
frame->width; ++x) {
126 uint16_t *
dst = (uint16_t *)(
frame->data[3] +
frame->linesize[3] * y);
128 int u =
AV_RN16(&
frame->data[1][
frame->linesize[1] * (y >> vsub_log2) + 2 * (x >> hsub_log2)]);
129 int v =
AV_RN16(&
frame->data[2][
frame->linesize[2] * (y >> vsub_log2) + 2 * (x >> hsub_log2)]);
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) {
155 uint8_t *dstu =
frame->data[1] +
frame->linesize[1] * y;
156 uint8_t *dstv =
frame->data[2] +
frame->linesize[2] * y;
157 int Y =
frame->data[0][
frame->linesize[0] * (y << vsub_log2) + (x << hsub_log2)];
158 int u =
frame->data[1][
frame->linesize[1] * y + x];
159 int v =
frame->data[2][
frame->linesize[2] * y + 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) {
192 uint16_t *dstu = (uint16_t *)(
frame->data[1] +
frame->linesize[1] * y);
193 uint16_t *dstv = (uint16_t *)(
frame->data[2] +
frame->linesize[2] * y);
194 int Y =
AV_RN16(&
frame->data[0][
frame->linesize[0] * (y << vsub_log2) + 2 * (x << hsub_log2)]);
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 FILTER_PIXFMTS_ARRAY(array)
#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)
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
#define FILTER_INPUTS(array)
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
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)
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
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)
#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 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_OUTPUTS(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
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
static const AVOption hsvhold_options[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
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...
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
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[]
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
#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 void scale(int *out, const int *in, const int w, const int h, const int shift)
static enum AVPixelFormat hold_pixel_fmts[]
#define AV_PIX_FMT_YUV444P14
const AVFilter * filter
the AVFilter of which this is an instance
uint8_t ptrdiff_t const uint8_t ptrdiff_t int const int8_t const int8_t * vf
@ 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