48 for (i = 0; i < 9; ++i) {
52 diff += sqrt((du * du + dv * dv) / (255.0 * 255.0));
57 if (ctx->
blend > 0.0001) {
58 return av_clipd((diff - ctx->
similarity) / ctx->
blend, 0.0, 1.0) * 255.0;
66 if (x < 0 || x >= frame->
width || y < 0 || y >= frame->
height)
80 const int slice_start = (frame->
height * jobnr) / nb_jobs;
91 for (y = slice_start; y <
slice_end; ++y) {
92 for (x = 0; x < frame->
width; ++x) {
93 for (yo = 0; yo < 3; ++yo) {
94 for (xo = 0; xo < 3; ++xo) {
117 #define FIXNUM(x) lrint((x) * (1 << 10))
118 #define RGB_TO_U(rgb) (((- FIXNUM(0.16874) * rgb[0] - FIXNUM(0.33126) * rgb[1] + FIXNUM(0.50000) * rgb[2] + (1 << 9) - 1) >> 10) + 128)
119 #define RGB_TO_V(rgb) ((( FIXNUM(0.50000) * rgb[0] - FIXNUM(0.41869) * rgb[1] - FIXNUM(0.08131) * rgb[2] + (1 << 9) - 1) >> 10) + 128)
185 #define OFFSET(x) offsetof(ChromakeyContext, x)
186 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
200 .description =
NULL_IF_CONFIG_SMALL(
"Turns a certain color into transparency. Operates on YUV colors."),
202 .priv_class = &chromakey_class,
205 .
inputs = chromakey_inputs,
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
Main libavfilter public API header.
static av_cold int init(AVCodecContext *avctx)
static enum AVSampleFormat formats[]
AVFILTER_DEFINE_CLASS(chromakey)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static const AVFilterPad chromakey_outputs[]
static av_cold int initialize_chromakey(AVFilterContext *avctx)
A filter pad used for either input or output.
static const AVOption chromakey_options[]
A link between two filters.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
int width
width and height of the video frame
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static uint8_t do_chromakey_pixel(ChromakeyContext *ctx, uint8_t u[9], uint8_t v[9])
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
uint8_t chromakey_rgba[4]
static const AVFilterPad outputs[]
static int filter_frame(AVFilterLink *link, AVFrame *frame)
int format
agreed upon media format
static const AVFilterPad inputs[]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Describe the class of an AVClass context structure.
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int query_formats(AVFilterContext *avctx)
static const AVFilterPad chromakey_inputs[]
static av_always_inline void get_pixel_uv(AVFrame *frame, int hsub_log2, int vsub_log2, int x, int y, uint8_t *u, uint8_t *v)
avfilter_execute_func * execute
static av_cold int config_input(AVFilterLink *inlink)
static int do_chromakey_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
static av_always_inline int diff(const uint32_t a, const uint32_t b)
AVFilterContext * dst
dest filter
AVPixelFormat
Pixel format.