FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vf_blend.c File Reference
#include "libavutil/imgutils.h"
#include "libavutil/intfloat.h"
#include "libavutil/eval.h"
#include "libavutil/opt.h"
#include "libavutil/pixfmt.h"
#include "avfilter.h"
#include "formats.h"
#include "framesync.h"
#include "internal.h"
#include "video.h"
#include "blend.h"
#include "blend_modes.c"

Go to the source code of this file.

Data Structures

struct  BlendContext
 
struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define TOP   0
 
#define BOTTOM   1
 
#define DEPTH   8
 
#define DEPTH   9
 
#define DEPTH   10
 
#define DEPTH   12
 
#define DEPTH   14
 
#define DEPTH   16
 
#define DEPTH   32
 
#define OFFSET(x)   offsetof(BlendContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
#define COPY(src, depth)
 
#define BLEND_NORMAL(name, type)
 
#define DEFINE_BLEND_EXPR(type, name, div)
 
#define DEFINE_INIT_BLEND_FUNC(depth, nbits)
 

Enumerations

enum  {
  VAR_X, VAR_Y, VAR_W, VAR_H,
  VAR_SW, VAR_SH, VAR_T, VAR_N,
  VAR_A, VAR_B, VAR_TOP, VAR_BOTTOM,
  VAR_VARS_NB
}
 

Functions

 FRAMESYNC_DEFINE_CLASS (blend, BlendContext, fs)
 
static int filter_slice (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static AVFrameblend_frame (AVFilterContext *ctx, AVFrame *top_buf, const AVFrame *bottom_buf)
 
static int blend_frame_for_dualinput (FFFrameSync *fs)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
void ff_blend_init (FilterParams *param, int depth)
 
static int config_params (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 

Variables

static const char *const var_names [] = { "X", "Y", "W", "H", "SW", "SH", "T", "N", "A", "B", "TOP", "BOTTOM", NULL }
 
static const AVOption blend_options []
 
static enum AVPixelFormat pix_fmts []
 

Macro Definition Documentation

◆ TOP

#define TOP   0

Definition at line 33 of file vf_blend.c.

◆ BOTTOM

#define BOTTOM   1

Definition at line 34 of file vf_blend.c.

◆ DEPTH [1/7]

#define DEPTH   8

Definition at line 60 of file vf_blend.c.

◆ DEPTH [2/7]

#define DEPTH   9

Definition at line 60 of file vf_blend.c.

◆ DEPTH [3/7]

#define DEPTH   10

Definition at line 60 of file vf_blend.c.

◆ DEPTH [4/7]

#define DEPTH   12

Definition at line 60 of file vf_blend.c.

◆ DEPTH [5/7]

#define DEPTH   14

Definition at line 60 of file vf_blend.c.

◆ DEPTH [6/7]

#define DEPTH   16

Definition at line 60 of file vf_blend.c.

◆ DEPTH [7/7]

#define DEPTH   32

Definition at line 60 of file vf_blend.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(BlendContext, x)

Definition at line 90 of file vf_blend.c.

◆ FLAGS

Definition at line 91 of file vf_blend.c.

◆ COPY

#define COPY (   src,
  depth 
)
Value:
static void blend_copy ## src##_##depth(const uint8_t *top, ptrdiff_t top_linesize, \
const uint8_t *bottom, ptrdiff_t bottom_linesize,\
uint8_t *dst, ptrdiff_t dst_linesize, \
ptrdiff_t width, ptrdiff_t height, \
FilterParams *param, double *values, int starty) \
{ \
av_image_copy_plane(dst, dst_linesize, src, src ## _linesize, \
width * depth / 8, height); \
}

Definition at line 156 of file vf_blend.c.

◆ BLEND_NORMAL

#define BLEND_NORMAL (   name,
  type 
)
Value:
static void blend_normal_##name(const uint8_t *_top, ptrdiff_t top_linesize, \
const uint8_t *_bottom, ptrdiff_t bottom_linesize,\
uint8_t *_dst, ptrdiff_t dst_linesize, \
ptrdiff_t width, ptrdiff_t height, \
FilterParams *param, double *values, int starty) \
{ \
const type *top = (type*)_top; \
const type *bottom = (type*)_bottom; \
type *dst = (type*)_dst; \
const float opacity = param->opacity; \
\
dst_linesize /= sizeof(type); \
top_linesize /= sizeof(type); \
bottom_linesize /= sizeof(type); \
for (int i = 0; i < height; i++) { \
for (int j = 0; j < width; j++) { \
dst[j] = top[j] * opacity + bottom[j] * (1.f - opacity); \
} \
dst += dst_linesize; \
top += top_linesize; \
bottom += bottom_linesize; \
} \
}

Definition at line 178 of file vf_blend.c.

◆ DEFINE_BLEND_EXPR

#define DEFINE_BLEND_EXPR (   type,
  name,
  div 
)
Value:
static void blend_expr_## name(const uint8_t *_top, ptrdiff_t top_linesize, \
const uint8_t *_bottom, ptrdiff_t bottom_linesize, \
uint8_t *_dst, ptrdiff_t dst_linesize, \
ptrdiff_t width, ptrdiff_t height, \
FilterParams *param, double *values, int starty) \
{ \
const type *top = (type*)_top; \
const type *bottom = (type*)_bottom; \
type *dst = (type*)_dst; \
AVExpr *e = param->e; \
int y, x; \
dst_linesize /= div; \
top_linesize /= div; \
bottom_linesize /= div; \
for (y = 0; y < height; y++) { \
values[VAR_Y] = y + starty; \
for (x = 0; x < width; x++) { \
values[VAR_X] = x; \
values[VAR_TOP] = values[VAR_A] = top[x]; \
values[VAR_BOTTOM] = values[VAR_B] = bottom[x]; \
dst[x] = av_expr_eval(e, values, NULL); \
} \
dst += dst_linesize; \
top += top_linesize; \
bottom += bottom_linesize; \
} \
}

Definition at line 208 of file vf_blend.c.

◆ DEFINE_INIT_BLEND_FUNC

#define DEFINE_INIT_BLEND_FUNC (   depth,
  nbits 
)

Definition at line 366 of file vf_blend.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
VAR_X 
VAR_Y 
VAR_W 
VAR_H 
VAR_SW 
VAR_SH 
VAR_T 
VAR_N 
VAR_A 
VAR_B 
VAR_TOP 
VAR_BOTTOM 
VAR_VARS_NB 

Definition at line 79 of file vf_blend.c.

Function Documentation

◆ FRAMESYNC_DEFINE_CLASS()

FRAMESYNC_DEFINE_CLASS ( blend  ,
BlendContext  ,
fs   
)

◆ filter_slice()

static int filter_slice ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 242 of file vf_blend.c.

Referenced by blend_frame().

◆ blend_frame()

static AVFrame* blend_frame ( AVFilterContext ctx,
AVFrame top_buf,
const AVFrame bottom_buf 
)
static

Definition at line 270 of file vf_blend.c.

Referenced by blend_frame_for_dualinput().

◆ blend_frame_for_dualinput()

static int blend_frame_for_dualinput ( FFFrameSync fs)
static

Definition at line 308 of file vf_blend.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 323 of file vf_blend.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 354 of file vf_blend.c.

◆ ff_blend_init()

void ff_blend_init ( FilterParams param,
int  depth 
)

Definition at line 420 of file vf_blend.c.

Referenced by config_params().

◆ config_params()

static int config_params ( AVFilterContext ctx)
static

Definition at line 459 of file vf_blend.c.

Referenced by config_output(), and process_command().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 491 of file vf_blend.c.

◆ process_command()

static int process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  args,
char *  res,
int  res_len,
int  flags 
)
static

Definition at line 541 of file vf_blend.c.

Variable Documentation

◆ var_names

const char* const var_names[] = { "X", "Y", "W", "H", "SW", "SH", "T", "N", "A", "B", "TOP", "BOTTOM", NULL }
static

Definition at line 78 of file vf_blend.c.

Referenced by config_params().

◆ blend_options

const AVOption blend_options[]
static

Definition at line 93 of file vf_blend.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:447
VAR_A
@ VAR_A
Definition: vf_blend.c:79
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:426
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:439
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:446
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:441
VAR_TOP
@ VAR_TOP
Definition: vf_blend.c:79
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:404
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
VAR_B
@ VAR_B
Definition: vf_blend.c:79
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:442
VAR_X
@ VAR_X
Definition: vf_blend.c:79
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:384
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:438
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:422
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:420
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:448
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:402
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:388
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:407
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:248
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:416
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:424
width
#define width
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:425
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:417
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:445
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:401
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:415
av_expr_eval
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:766
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:436
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:385
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:423
NULL
#define NULL
Definition: coverity.c:32
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
src
#define src
Definition: vp8dsp.c:255
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:406
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:405
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:419
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
FilterParams
filter data
Definition: mlp.h:75
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:433
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:409
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:411
height
#define height
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:167
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:443
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
VAR_BOTTOM
@ VAR_BOTTOM
Definition: vf_blend.c:79
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:421
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:100
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:403
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:440
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:408
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:413
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:444
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:434
values
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return values
Definition: filter_design.txt:263
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
_
#define _
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
VAR_Y
@ VAR_Y
Definition: vf_blend.c:79
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:410
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:414
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:386
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:166
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:412