vf_blend.c File Reference
#include "libavutil/imgutils.h"
#include "libavutil/eval.h"
#include "libavutil/opt.h"
#include "libavutil/pixfmt.h"
#include "avfilter.h"
#include "bufferqueue.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
Include dependency graph for vf_blend.c:

Go to the source code of this file.

Data Structures

struct  FilterParams
 filter data More...
 
struct  BlendContext
 

Macros

#define TOP   0
 
#define BOTTOM   1
 
#define OFFSET(x)   offsetof(BlendContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define DEFINE_BLEND(name, expr)
 
#define A   top[j]
 
#define B   bottom[j]
 
#define MULTIPLY(x, a, b)   (x * ((a * b) / 255))
 
#define SCREEN(x, a, b)   (255 - x * ((255 - a) * (255 - b) / 255))
 
#define BURN(a, b)   ((a == 0) ? a : FFMAX(0, 255 - ((255 - b) << 8) / a))
 
#define DODGE(a, b)   ((a == 255) ? a : FFMIN(255, ((b << 8) / (255 - a))))
 

Typedefs

typedef struct FilterParams FilterParams
 

Enumerations

enum  BlendMode {
  BLEND_UNSET = -1, BLEND_NORMAL, BLEND_ADDITION, BLEND_AND,
  BLEND_AVERAGE, BLEND_BURN, BLEND_DARKEN, BLEND_DIFFERENCE,
  BLEND_DIVIDE, BLEND_DODGE, BLEND_EXCLUSION, BLEND_HARDLIGHT,
  BLEND_LIGHTEN, BLEND_MULTIPLY, BLEND_NEGATION, BLEND_OR,
  BLEND_OVERLAY, BLEND_PHOENIX, BLEND_PINLIGHT, BLEND_REFLECT,
  BLEND_SCREEN, BLEND_SOFTLIGHT, BLEND_SUBTRACT, BLEND_VIVIDLIGHT,
  BLEND_XOR, BLEND_NB
}
 
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

 AVFILTER_DEFINE_CLASS (blend)
 
static void blend_normal (const uint8_t *top, int top_linesize, const uint8_t *bottom, int bottom_linesize, uint8_t *dst, int dst_linesize, int width, int height, FilterParams *param)
 
 DEFINE_BLEND (overlay,(A< 128)?MULTIPLY(2, A, B):SCREEN(2, A, B))
 
static av_cold int init (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 
static int config_input_top (AVFilterLink *inlink)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int request_frame (AVFilterLink *outlink)
 
static void blend_frame (AVFilterContext *ctx, AVFrame *top_buf, AVFrame *bottom_buf, AVFrame *dst_buf)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *buf)
 

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 const AVFilterPad blend_inputs []
 
static const AVFilterPad blend_outputs []
 
AVFilter avfilter_vf_blend
 

Macro Definition Documentation

#define A   top[j]

Definition at line 167 of file vf_blend.c.

#define B   bottom[j]

Definition at line 168 of file vf_blend.c.

#define BOTTOM   1

Definition at line 32 of file vf_blend.c.

Referenced by config_output(), filter_frame(), and request_frame().

#define BURN (   a,
  b 
)    ((a == 0) ? a : FFMAX(0, 255 - ((255 - b) << 8) / a))

Definition at line 172 of file vf_blend.c.

#define DEFINE_BLEND (   name,
  expr 
)
Value:
static void blend_## name(const uint8_t *top, int top_linesize, \
const uint8_t *bottom, int bottom_linesize, \
uint8_t *dst, int dst_linesize, \
int width, int height, FilterParams *param) \
{ \
double opacity = param->opacity; \
int i, j; \
for (i = 0; i < height; i++) { \
for (j = 0; j < width; j++) { \
dst[j] = top[j] + ((expr) - top[j]) * opacity; \
} \
dst += dst_linesize; \
top += top_linesize; \
bottom += bottom_linesize; \
} \
}
const char * name
Definition: avisynth_c.h:675
uint8_t
static int width
Definition: tests/utils.c:158
filter data
Definition: mlp.h:74
BYTE int const BYTE int int int height
Definition: avisynth_c.h:713
synthesis window for stochastic i
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
for(j=16;j >0;--j)

Definition at line 148 of file vf_blend.c.

#define DODGE (   a,
  b 
)    ((a == 255) ? a : FFMIN(255, ((b << 8) / (255 - a))))

Definition at line 173 of file vf_blend.c.

Definition at line 93 of file vf_blend.c.

#define MULTIPLY (   x,
  a,
  b 
)    (x * ((a * b) / 255))

Definition at line 170 of file vf_blend.c.

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

Definition at line 92 of file vf_blend.c.

#define SCREEN (   x,
  a,
  b 
)    (255 - x * ((255 - a) * (255 - b) / 255))

Definition at line 171 of file vf_blend.c.

#define TOP   0

Definition at line 31 of file vf_blend.c.

Referenced by config_output(), and request_frame().

Typedef Documentation

typedef struct FilterParams FilterParams

Enumeration Type Documentation

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 64 of file vf_blend.c.

enum BlendMode
Enumerator
BLEND_UNSET 
BLEND_NORMAL 
BLEND_ADDITION 
BLEND_AND 
BLEND_AVERAGE 
BLEND_BURN 
BLEND_DARKEN 
BLEND_DIFFERENCE 
BLEND_DIVIDE 
BLEND_DODGE 
BLEND_EXCLUSION 
BLEND_HARDLIGHT 
BLEND_LIGHTEN 
BLEND_MULTIPLY 
BLEND_NEGATION 
BLEND_OR 
BLEND_OVERLAY 
BLEND_PHOENIX 
BLEND_PINLIGHT 
BLEND_REFLECT 
BLEND_SCREEN 
BLEND_SOFTLIGHT 
BLEND_SUBTRACT 
BLEND_VIVIDLIGHT 
BLEND_XOR 
BLEND_NB 

Definition at line 34 of file vf_blend.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( blend  )
static void blend_frame ( AVFilterContext ctx,
AVFrame top_buf,
AVFrame bottom_buf,
AVFrame dst_buf 
)
static

Definition at line 365 of file vf_blend.c.

Referenced by filter_frame().

static void blend_normal ( const uint8_t top,
int  top_linesize,
const uint8_t bottom,
int  bottom_linesize,
uint8_t dst,
int  dst_linesize,
int  width,
int  height,
FilterParams param 
)
static

Definition at line 140 of file vf_blend.c.

Referenced by init().

static int config_input_top ( AVFilterLink inlink)
static

Definition at line 327 of file vf_blend.c.

static int config_output ( AVFilterLink outlink)
static

Definition at line 293 of file vf_blend.c.

DEFINE_BLEND ( overlay  ,
(A< 128)?MULTIPLY(2, A, B):SCREEN(2, A, B  
)

Definition at line 182 of file vf_blend.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame buf 
)
static

Definition at line 397 of file vf_blend.c.

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 223 of file vf_blend.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 280 of file vf_blend.c.

static int request_frame ( AVFilterLink outlink)
static

Definition at line 349 of file vf_blend.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 337 of file vf_blend.c.

Variable Documentation

AVFilter avfilter_vf_blend
Initial value:
= {
.name = "blend",
.description = NULL_IF_CONFIG_SMALL("Blend two video frames into each other."),
.init = init,
.uninit = uninit,
.priv_size = sizeof(BlendContext),
.priv_class = &blend_class,
}
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_blend.c:337
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_cold int init(AVFilterContext *ctx)
Definition: vf_blend.c:223
static const AVFilterPad blend_inputs[]
Definition: vf_blend.c:433
static const AVFilterPad blend_outputs[]
Definition: vf_blend.c:447
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 inputs
static int query_formats(AVFilterContext *ctx)
Definition: vf_blend.c:280

Definition at line 457 of file vf_blend.c.

const AVFilterPad blend_inputs[]
static
Initial value:
= {
{
.name = "top",
.config_props = config_input_top,
.filter_frame = filter_frame,
},{
.name = "bottom",
.filter_frame = filter_frame,
},
{ NULL }
}
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: vf_blend.c:397
NULL
Definition: eval.c:55
static int config_input_top(AVFilterLink *inlink)
Definition: vf_blend.c:327

Definition at line 433 of file vf_blend.c.

const AVOption blend_options[]
static

Definition at line 95 of file vf_blend.c.

const AVFilterPad blend_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
.request_frame = request_frame,
},
{ NULL }
}
static int request_frame(AVFilterLink *outlink)
Definition: vf_blend.c:349
static int config_output(AVFilterLink *outlink)
Definition: vf_blend.c:293
NULL
Definition: eval.c:55

Definition at line 447 of file vf_blend.c.

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

Definition at line 63 of file vf_blend.c.

Referenced by init().