44 int jobnr,
int nb_jobs);
53 const int min_diff = (255 + 255 + 255) *
s->similarity;
54 const float blend =
s->blend;
55 const int hsub =
s->hsub_log2;
56 const int vsub =
s->vsub_log2;
60 const uint8_t *srcy =
frame->data[0] +
frame->linesize[0] * y;
61 const uint8_t *srcu =
frame->data[1] +
frame->linesize[1] * (y >> vsub);
62 const uint8_t *srcv =
frame->data[2] +
frame->linesize[2] * (y >> vsub);
63 const uint8_t *bsrcy =
s->background->data[0] +
s->background->linesize[0] * y;
64 const uint8_t *bsrcu =
s->background->data[1] +
s->background->linesize[1] * (y >> vsub);
65 const uint8_t *bsrcv =
s->background->data[2] +
s->background->linesize[2] * (y >> vsub);
67 for (
int x = 0; x <
frame->width; x++) {
68 const int xx = x >>
hsub;
69 const int diff =
FFABS(srcy[x] - bsrcy[x]) +
70 FFABS(srcu[xx] - bsrcu[xx]) +
71 FFABS(srcv[xx] - bsrcv[xx]);
78 A = (
diff > min_diff) ? 255 : 0;
96 const int hsub =
s->hsub_log2;
97 const int vsub =
s->vsub_log2;
98 const int max =
s->max;
99 const int min_diff =
s->similarity * (
s->max +
s->max +
s->max);
100 const float blend =
s->blend;
104 const uint16_t *srcy = (
const uint16_t *)(
frame->data[0] +
frame->linesize[0] * y);
105 const uint16_t *srcu = (
const uint16_t *)(
frame->data[1] +
frame->linesize[1] * (y >> vsub));
106 const uint16_t *srcv = (
const uint16_t *)(
frame->data[2] +
frame->linesize[2] * (y >> vsub));
107 const uint16_t *bsrcy = (
const uint16_t *)(
s->background->data[0] +
s->background->linesize[0] * y);
108 const uint16_t *bsrcu = (
const uint16_t *)(
s->background->data[1] +
s->background->linesize[1] * (y >> vsub));
109 const uint16_t *bsrcv = (
const uint16_t *)(
s->background->data[2] +
s->background->linesize[2] * (y >> vsub));
110 uint16_t *
dst = (uint16_t *)(
frame->data[3] +
frame->linesize[3] * y);
111 for (
int x = 0; x <
frame->width; x++) {
112 const int xx = x >>
hsub;
113 const int diff =
FFABS(srcy[x] - bsrcy[x] ) +
114 FFABS(srcu[xx] - bsrcu[xx]) +
115 FFABS(srcv[xx] - bsrcv[xx]);
129 s->sums[jobnr] = sum;
141 if (!
s->background) {
143 if (!
s->background) {
156 for (
int n = 0; n <
s->nb_threads; n++)
158 if (
s->max_sum *
s->threshold < sum) {
179 depth =
desc->comp[0].depth;
181 s->max = (1 << depth) - 1;
182 s->hsub_log2 =
desc->log2_chroma_w;
183 s->vsub_log2 =
desc->log2_chroma_h;
184 s->max_sum = (
int64_t)(inlink->
w) * inlink->
h *
s->max;
185 s->max_sum += 2LL * (inlink->
w >>
s->hsub_log2) * (inlink->
h >>
s->vsub_log2) *
s->max;
219#define OFFSET(x) offsetof(BackgroundkeyContext, x)
220#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
245 .p.name =
"backgroundkey",
247 .p.priv_class = &backgroundkey_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFFilter ff_vf_backgroundkey
static AVFormatContext * ctx
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.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
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...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#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.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
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_GBRAP12
#define AV_PIX_FMT_GBRAP16
#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_GBRAP
planar GBRA 4:4:4:4 32bpp
@ 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_GBRAP10
#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.
AVFilterLink ** inputs
array of pointers to input links
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
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 *avctx, void *arg, int jobnr, int nb_jobs)
static const AVOption backgroundkey_options[]
static enum AVPixelFormat backgroundkey_fmts[]
static av_cold int config_output(AVFilterLink *outlink)
static const AVFilterPad backgroundkey_inputs[]
static int filter_frame(AVFilterLink *link, AVFrame *frame)
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad backgroundkey_outputs[]
static int do_backgroundkey_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
static int do_backgroundkey16_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)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)