FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
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 "dualinput.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  FilterParams
 filter data More...
 
struct  ThreadData
 
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))))
 

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 start, int end, FilterParams *param, double *values)
 
 DEFINE_BLEND (overlay,(A< 128)?MULTIPLY(2, A, B):SCREEN(2, A, B))
 
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 av_cold int init (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int request_frame (AVFilterLink *outlink)
 
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 ff_vf_blend
 

Macro Definition Documentation

#define TOP   0
#define BOTTOM   1

Definition at line 33 of file vf_blend.c.

Referenced by config_output().

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

Definition at line 100 of file vf_blend.c.

Definition at line 101 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 start, int end, \
FilterParams *param, double *values) \
{ \
double opacity = param->opacity; \
int i, j; \
for (i = start; i < end; i++) { \
for (j = 0; j < width; j++) { \
dst[j] = top[j] + ((expr) - top[j]) * opacity; \
} \
dst += dst_linesize; \
top += top_linesize; \
bottom += bottom_linesize; \
} \
}

Definition at line 159 of file vf_blend.c.

#define A   top[j]

Definition at line 179 of file vf_blend.c.

#define B   bottom[j]

Definition at line 180 of file vf_blend.c.

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

Definition at line 182 of file vf_blend.c.

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

Definition at line 183 of file vf_blend.c.

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

Definition at line 184 of file vf_blend.c.

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

Definition at line 185 of file vf_blend.c.

Enumeration Type Documentation

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

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

Function Documentation

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  start,
int  end,
FilterParams param,
double *  values 
)
static

Definition at line 150 of file vf_blend.c.

Referenced by init().

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

Definition at line 194 of file vf_blend.c.

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

Definition at line 234 of file vf_blend.c.

Referenced by blend_frame().

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

Definition at line 261 of file vf_blend.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 293 of file vf_blend.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 351 of file vf_blend.c.

static int config_output ( AVFilterLink outlink)
static

Definition at line 364 of file vf_blend.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 409 of file vf_blend.c.

static int request_frame ( AVFilterLink outlink)
static

Definition at line 419 of file vf_blend.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame buf 
)
static

Definition at line 425 of file vf_blend.c.

Variable Documentation

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

Definition at line 64 of file vf_blend.c.

Referenced by init().

const AVOption blend_options[]
static

Definition at line 103 of file vf_blend.c.

const AVFilterPad blend_inputs[]
static
Initial value:
= {
{
.name = "top",
.filter_frame = filter_frame,
},{
.name = "bottom",
.filter_frame = filter_frame,
},
{ NULL }
}

Definition at line 431 of file vf_blend.c.

const AVFilterPad blend_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
.request_frame = request_frame,
},
{ NULL }
}

Definition at line 444 of file vf_blend.c.

AVFilter ff_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,
}

Definition at line 454 of file vf_blend.c.