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"
#include "blend.h"

Go to the source code of this file.

Data Structures

struct  BlendContext
 
struct  ThreadData
 

Macros

#define TOP   0
 
#define BOTTOM   1
 
#define COMMON_OPTIONS
 
#define OFFSET(x)   offsetof(BlendContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define COPY(src)
 
#define DEFINE_BLEND8(name, expr)
 
#define DEFINE_BLEND16(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)))))
 
#define MULTIPLY(x, a, b)   ((x) * (((a) * (b)) / 65535))
 
#define SCREEN(x, a, b)   (65535 - (x) * ((65535 - (a)) * (65535 - (b)) / 65535))
 
#define BURN(a, b)   (((a) == 0) ? (a) : FFMAX(0, 65535 - ((65535 - (b)) << 16) / (a)))
 
#define DODGE(a, b)   (((a) == 65535) ? (a) : FFMIN(65535, (((b) << 16) / (65535 - (a)))))
 
#define DEFINE_BLEND_EXPR(type, name, div)
 

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

 AVFILTER_DEFINE_CLASS (blend)
 
static void blend_normal_8bit (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)
 
static void blend_normal_16bit (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)
 
 DEFINE_BLEND8 (multiply128, av_clip_uint8((A-128)*B/32.+128))
 
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 av_cold void uninit (AVFilterContext *ctx)
 
void ff_blend_init (FilterParams *param, int is_16bit)
 
static int config_output (AVFilterLink *outlink)
 

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 []
 

Macro Definition Documentation

#define TOP   0

Definition at line 33 of file vf_blend.c.

Referenced by config_output().

#define BOTTOM   1

Definition at line 34 of file vf_blend.c.

Referenced by config_output().

#define COMMON_OPTIONS

Definition at line 62 of file vf_blend.c.

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

Definition at line 109 of file vf_blend.c.

Definition at line 110 of file vf_blend.c.

#define COPY (   src)
Value:
static void blend_copy ## src(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) \
{ \
av_image_copy_plane(dst, dst_linesize, src, src ## _linesize, \
}
uint8_t
#define src
Definition: vp9dsp.c:530
filter data
Definition: mlp.h:74
BYTE int const BYTE int int int height
Definition: avisynth_c.h:676
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:287
static int width

Definition at line 121 of file vf_blend.c.

#define DEFINE_BLEND8 (   name,
  expr 
)
Value:
static void blend_## name##_8bit(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) \
{ \
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; \
} \
}
uint8_t
filter data
Definition: mlp.h:74
BYTE int const BYTE int int int height
Definition: avisynth_c.h:676
for(j=16;j >0;--j)
const char * name
Definition: opengl_enc.c:103
static int width

Definition at line 181 of file vf_blend.c.

#define DEFINE_BLEND16 (   name,
  expr 
)
Value:
static void blend_## name##_16bit(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) \
{ \
const uint16_t *top = (uint16_t*)_top; \
const uint16_t *bottom = (uint16_t*)_bottom; \
uint16_t *dst = (uint16_t*)_dst; \
double opacity = param->opacity; \
int i, j; \
dst_linesize /= 2; \
top_linesize /= 2; \
bottom_linesize /= 2; \
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; \
} \
}
uint8_t
filter data
Definition: mlp.h:74
BYTE int const BYTE int int int height
Definition: avisynth_c.h:676
for(j=16;j >0;--j)
const char * name
Definition: opengl_enc.c:103
static int width

Definition at line 201 of file vf_blend.c.

#define A   top[j]

Definition at line 227 of file vf_blend.c.

#define B   bottom[j]

Definition at line 228 of file vf_blend.c.

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

Definition at line 230 of file vf_blend.c.

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

Definition at line 231 of file vf_blend.c.

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

Definition at line 232 of file vf_blend.c.

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

Definition at line 233 of file vf_blend.c.

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

Definition at line 230 of file vf_blend.c.

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

Definition at line 231 of file vf_blend.c.

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

Definition at line 232 of file vf_blend.c.

#define DODGE (   a,
  b 
)    (((a) == 65535) ? (a) : FFMIN(65535, (((b) << 16) / (65535 - (a)))))

Definition at line 233 of file vf_blend.c.

#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) \
{ \
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; \
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; \
} \
}
#define NULL
Definition: coverity.c:32
Definition: vf_blend.c:51
uint8_t
Definition: vf_blend.c:51
GLint GLenum type
Definition: opengl_enc.c:105
filter data
Definition: mlp.h:74
BYTE int const BYTE int int int height
Definition: avisynth_c.h:676
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:712
Definition: vf_blend.c:51
Definition: vf_blend.c:51
for(j=16;j >0;--j)
const char * name
Definition: opengl_enc.c:103
static int width

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

Function Documentation

AVFILTER_DEFINE_CLASS ( blend  )
static void blend_normal_8bit ( 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 
)
static

Definition at line 137 of file vf_blend.c.

Referenced by ff_blend_init().

static void blend_normal_16bit ( 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 
)
static

Definition at line 156 of file vf_blend.c.

Referenced by ff_blend_init().

DEFINE_BLEND8 ( multiply128  ,
av_clip_uint8((A-128)*B/32.+128)   
)

Definition at line 240 of file vf_blend.c.

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

Definition at line 366 of file vf_blend.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 399 of file vf_blend.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 409 of file vf_blend.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 428 of file vf_blend.c.

void ff_blend_init ( FilterParams param,
int  is_16bit 
)

Definition at line 440 of file vf_blend.c.

Referenced by config_output().

static int config_output ( AVFilterLink outlink)
static

Definition at line 485 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 50 of file vf_blend.c.

Referenced by config_output().

const AVOption blend_options[]
static
Initial value:
= {
{ "shortest", "force termination when the shortest input terminates", OFFSET(dinput.shortest), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
{ "repeatlast", "repeat last bottom frame", OFFSET(dinput.repeatlast), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
{ NULL }
}
#define NULL
Definition: coverity.c:32
#define FLAGS
Definition: vf_blend.c:110
#define COMMON_OPTIONS
Definition: vf_blend.c:62
#define OFFSET(x)
Definition: vf_blend.c:109

Definition at line 112 of file vf_blend.c.