47 const int slice_start = (
frame->
height * jobnr) / nb_jobs;
52 const int w =
s->white;
53 const int b =
s->black;
56 for (y = slice_start; y <
slice_end; y++) {
58 if (luma[x] >=
b && luma[x] <=
w) {
60 }
else if (luma[x] >
b - so && luma[x] <
w + so) {
62 alpha[x] = 255 - (luma[x] -
b + so) * 255 / so;
64 alpha[x] = (luma[x] -
w) * 255 / so;
79 const int slice_start = (
frame->
height * jobnr) / nb_jobs;
84 const int w =
s->white;
85 const int b =
s->black;
89 for (y = slice_start; y <
slice_end; y++) {
91 if (luma[x] >=
b && luma[x] <=
w) {
93 }
else if (luma[x] >
b - so && luma[x] <
w + so) {
95 alpha[x] = m - (luma[x] -
b + so) * m / so;
97 alpha[x] = (luma[x] -
w) * m / so;
115 depth =
desc->comp[0].depth;
120 s->so =
s->softness * 255;
122 s->max = (1 << depth) - 1;
123 s->white =
av_clip((
s->threshold +
s->tolerance) *
s->max, 0,
s->max);
124 s->black =
av_clip((
s->threshold -
s->tolerance) *
s->max, 0,
s->max);
126 s->so =
s->softness *
s->max;
167 char *res,
int res_len,
int flags)
196 #define OFFSET(x) offsetof(LumakeyContext, x)
197 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
212 .priv_class = &lumakey_class,
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
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_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
#define flags(name, subs,...)
#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...
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
static const int16_t alpha[]
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA422P10
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A 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_YUVA444P16
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P12
Describe the class of an AVClass context structure.
A link between two filters.
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int(* do_lumakey_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static const AVFilterPad lumakey_inputs[]
static int do_lumakey_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int config_input(AVFilterLink *inlink)
static av_cold int query_formats(AVFilterContext *ctx)
static const AVOption lumakey_options[]
static int filter_frame(AVFilterLink *link, AVFrame *frame)
AVFILTER_DEFINE_CLASS(lumakey)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static const AVFilterPad lumakey_outputs[]
static int do_lumakey_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)