FFmpeg
Macros
blend_modes.c File Reference
#include "libavutil/common.h"
#include "libavutil/intfloat.h"
#include "avfilter.h"
#include "video.h"
#include "blend.h"

Go to the source code of this file.

Macros

#define PIXEL   uint16_t
 
#define MAX   ((1 << DEPTH) - 1)
 
#define HALF   (1 << (DEPTH - 1))
 
#define CLIP(x)   ((int)av_clip_uintp2(x, DEPTH))
 
#define MULTIPLY(x, a, b)   ((x) * (((a) * (b)) / MAX))
 
#define SCREEN(x, a, b)   (MAX - (x) * ((MAX - (a)) * (MAX - (b)) / MAX))
 
#define BURN(a, b)   (((a) == 0) ? (a) : FFMAX(0, MAX - ((MAX - (b)) << DEPTH) / (a)))
 
#define DODGE(a, b)   (((a) == MAX) ? (a) : FFMIN(MAX, (((b) << DEPTH) / (MAX - (a)))))
 
#define GEOMETRIC(a, b)   (lrintf(sqrtf((unsigned)A * B)))
 
#define INT2FLOAT(x)   (x)
 
#define FLOAT2INT(x)   (x)
 
#define MDIV   (0.125f * (1 << DEPTH))
 
#define LRINTF(x)   lrintf(x)
 
#define A   top[j]
 
#define B   bottom[j]
 
#define fn2(a, b)   blend_##a##_##b##bit
 
#define fn1(name, depth)   fn2(name, depth)
 
#define fn0(name)   fn1(name, DEPTH)
 
#define fn(NAME, EXPR)
 

Macro Definition Documentation

◆ PIXEL

#define PIXEL   uint16_t

Definition at line 43 of file blend_modes.c.

◆ MAX

#define MAX   ((1 << DEPTH) - 1)

Definition at line 44 of file blend_modes.c.

◆ HALF

#define HALF   (1 << (DEPTH - 1))

Definition at line 45 of file blend_modes.c.

◆ CLIP

#define CLIP (   x)    ((int)av_clip_uintp2(x, DEPTH))

Definition at line 46 of file blend_modes.c.

◆ MULTIPLY

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

Definition at line 60 of file blend_modes.c.

◆ SCREEN

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

Definition at line 61 of file blend_modes.c.

◆ BURN

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

Definition at line 62 of file blend_modes.c.

◆ DODGE

#define DODGE (   a,
  b 
)    (((a) == MAX) ? (a) : FFMIN(MAX, (((b) << DEPTH) / (MAX - (a)))))

Definition at line 63 of file blend_modes.c.

◆ GEOMETRIC

#define GEOMETRIC (   a,
  b 
)    (lrintf(sqrtf((unsigned)A * B)))

Definition at line 64 of file blend_modes.c.

◆ INT2FLOAT

#define INT2FLOAT (   x)    (x)

Definition at line 65 of file blend_modes.c.

◆ FLOAT2INT

#define FLOAT2INT (   x)    (x)

Definition at line 66 of file blend_modes.c.

◆ MDIV

#define MDIV   (0.125f * (1 << DEPTH))

Definition at line 67 of file blend_modes.c.

◆ LRINTF

#define LRINTF (   x)    lrintf(x)

Definition at line 68 of file blend_modes.c.

◆ A

#define A   top[j]

Definition at line 81 of file blend_modes.c.

◆ B

#define B   bottom[j]

Definition at line 82 of file blend_modes.c.

◆ fn2

#define fn2 (   a,
  b 
)    blend_##a##_##b##bit

Definition at line 84 of file blend_modes.c.

◆ fn1

#define fn1 (   name,
  depth 
)    fn2(name, depth)

Definition at line 85 of file blend_modes.c.

◆ fn0

#define fn0 (   name)    fn1(name, DEPTH)

Definition at line 86 of file blend_modes.c.

◆ fn

#define fn (   NAME,
  EXPR 
)
Value:
static void fn0(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, SliceParams *sliceparam) \
{ \
const PIXEL *top = (const PIXEL *)_top; \
const PIXEL *bottom = (const PIXEL *)_bottom; \
PIXEL *dst = (PIXEL *)_dst; \
const float opacity = param->opacity; \
\
dst_linesize /= sizeof(PIXEL); \
top_linesize /= sizeof(PIXEL); \
bottom_linesize /= sizeof(PIXEL); \
for (int i = 0; i < height; i++) { \
for (int 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 88 of file blend_modes.c.

_dst
uint8_t * _dst
Definition: dsp.h:52
height
#define height
Definition: dsp.h:85
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
SliceParams
Definition: blend.h:72
PIXEL
#define PIXEL
Definition: blend_modes.c:43
fn0
#define fn0(name)
Definition: blend_modes.c:86
width
#define width
Definition: dsp.h:85