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;
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 .p.description =
NULL_IF_CONFIG_SMALL(
"Turns a certain HSV range into transparency. Operates on YUV colors."),
303 .p.priv_class = &hsvkey_class,
345 .p.priv_class = &hsvhold_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int const int8_t const int8_t * vf
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_hsvhold
const FFFilter ff_vf_hsvkey
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next 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.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
static __device__ float sqrtf(float a)
static __device__ float fabsf(float a)
float fmaxf(float, float)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static int config_output(AVBitStreamFilterLink *outlink)
#define u(width, name, range_min, range_max)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
#define FILTER_PIXFMTS_ARRAY(array)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static uint8_t half(int a, int b)
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUV420P14
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10
Describe the class of an AVClass context structure.
const AVFilter * filter
the AVFilter of which this is an instance
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
AVFilterContext * src
source filter
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
const char * name
Filter name.
This structure describes decoded (raw) audio or video data.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int(* do_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int imax(const int a, const int b)
static AVFormatContext * ctx
static enum AVPixelFormat hold_pixel_fmts[]
static int do_hsvhold_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
static av_cold int config_output(AVFilterLink *outlink)
static av_cold int config_input(AVFilterLink *inlink)
static const AVOption hsvhold_options[]
static int filter_frame(AVFilterLink *link, AVFrame *frame)
static const AVOption hsvkey_options[]
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_hsvhold16_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
static enum AVPixelFormat key_pixel_fmts[]
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 av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)