39 int jobnr,
int nb_jobs);
44 int dr = (
int)
r -
ctx->colorkey_rgba[0];
45 int dg = (
int)
g -
ctx->colorkey_rgba[1];
46 int db = (
int)
b -
ctx->colorkey_rgba[2];
48 double diff = sqrt((dr * dr + dg * dg + db * db) / (255.0 * 255.0 * 3.0));
50 if (
ctx->blend > 0.0001) {
53 return (
diff >
ctx->similarity) ? 255 : 0;
61 const int slice_start = (
frame->
height * jobnr) / nb_jobs;
68 for (y = slice_start; y <
slice_end; ++y) {
87 const int slice_start = (
frame->
height * jobnr) / nb_jobs;
94 for (y = slice_start; y <
slice_end; ++y) {
106 int a = (
r +
g +
b) / 3;
123 if (!strcmp(avctx->
filter->
name,
"colorkey")) {
158 for (
i = 0;
i < 4; ++
i)
201 #define OFFSET(x) offsetof(ColorkeyContext, x)
202 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
204 #if CONFIG_COLORKEY_FILTER
206 static const AVOption colorkey_options[] = {
217 .description =
NULL_IF_CONFIG_SMALL(
"Turns a certain color into transparency. Operates on RGB colors."),
219 .priv_class = &colorkey_class,
229 #if CONFIG_COLORHOLD_FILTER
231 static const AVOption colorhold_options[] = {
242 .description =
NULL_IF_CONFIG_SMALL(
"Turns a certain color range into gray. Operates on RGB colors."),
244 .priv_class = &colorhold_class,
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
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.
static av_cold int init(AVCodecContext *avctx)
#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.
#define AVFILTER_DEFINE_CLASS(fname)
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)
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Describe the class of an AVClass context structure.
AVFilterLink ** inputs
array of pointers to input links
const AVFilter * filter
the AVFilter of which this is an instance
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
avfilter_execute_func * execute
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
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.
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_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static const AVFilterPad colorkey_outputs[]
static av_cold int query_formats(AVFilterContext *avctx)
static const AVFilterPad colorkey_inputs[]
static av_cold int config_output(AVFilterLink *outlink)
static int do_colorkey_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
static int filter_frame(AVFilterLink *link, AVFrame *frame)
static uint8_t do_colorkey_pixel(ColorkeyContext *ctx, uint8_t r, uint8_t g, uint8_t b)
static av_cold int init_filter(AVFilterContext *avctx)
static int do_colorhold_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
static av_always_inline int diff(const uint32_t a, const uint32_t b)