You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avfilter/vf_blend: refactor similar code
This commit is contained in:
@@ -142,74 +142,35 @@ COPY(bottom, 32)
|
|||||||
|
|
||||||
#undef COPY
|
#undef COPY
|
||||||
|
|
||||||
static void blend_normal_8bit(const uint8_t *top, ptrdiff_t top_linesize,
|
#define BLEND_NORMAL(name, type) \
|
||||||
const uint8_t *bottom, ptrdiff_t bottom_linesize,
|
static void blend_normal_##name(const uint8_t *_top, ptrdiff_t top_linesize, \
|
||||||
uint8_t *dst, ptrdiff_t dst_linesize,
|
const uint8_t *_bottom, ptrdiff_t bottom_linesize,\
|
||||||
ptrdiff_t width, ptrdiff_t height,
|
uint8_t *_dst, ptrdiff_t dst_linesize, \
|
||||||
FilterParams *param, double *values, int starty)
|
ptrdiff_t width, ptrdiff_t height, \
|
||||||
{
|
FilterParams *param, double *values, int starty) \
|
||||||
const float opacity = param->opacity;
|
{ \
|
||||||
int i, j;
|
const type *top = (type*)_top; \
|
||||||
|
const type *bottom = (type*)_bottom; \
|
||||||
for (i = 0; i < height; i++) {
|
type *dst = (type*)_dst; \
|
||||||
for (j = 0; j < width; j++) {
|
const float opacity = param->opacity; \
|
||||||
dst[j] = top[j] * opacity + bottom[j] * (1.f - opacity);
|
\
|
||||||
}
|
dst_linesize /= sizeof(type); \
|
||||||
dst += dst_linesize;
|
top_linesize /= sizeof(type); \
|
||||||
top += top_linesize;
|
bottom_linesize /= sizeof(type); \
|
||||||
bottom += bottom_linesize;
|
\
|
||||||
}
|
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; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blend_normal_16bit(const uint8_t *_top, ptrdiff_t top_linesize,
|
BLEND_NORMAL(8bit, uint8_t)
|
||||||
const uint8_t *_bottom, ptrdiff_t bottom_linesize,
|
BLEND_NORMAL(16bit, uint16_t)
|
||||||
uint8_t *_dst, ptrdiff_t dst_linesize,
|
BLEND_NORMAL(32bit, float)
|
||||||
ptrdiff_t width, ptrdiff_t height,
|
|
||||||
FilterParams *param, double *values, int starty)
|
|
||||||
{
|
|
||||||
const uint16_t *top = (uint16_t*)_top;
|
|
||||||
const uint16_t *bottom = (uint16_t*)_bottom;
|
|
||||||
uint16_t *dst = (uint16_t*)_dst;
|
|
||||||
const float 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] * opacity + bottom[j] * (1.f - opacity);
|
|
||||||
}
|
|
||||||
dst += dst_linesize;
|
|
||||||
top += top_linesize;
|
|
||||||
bottom += bottom_linesize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void blend_normal_32bit(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 float *top = (float*)_top;
|
|
||||||
const float *bottom = (float*)_bottom;
|
|
||||||
float *dst = (float*)_dst;
|
|
||||||
const float opacity = param->opacity;
|
|
||||||
int i, j;
|
|
||||||
dst_linesize /= 4;
|
|
||||||
top_linesize /= 4;
|
|
||||||
bottom_linesize /= 4;
|
|
||||||
|
|
||||||
for (i = 0; i < height; i++) {
|
|
||||||
for (j = 0; j < width; j++) {
|
|
||||||
dst[j] = top[j] * opacity + bottom[j] * (1.f - opacity);
|
|
||||||
}
|
|
||||||
dst += dst_linesize;
|
|
||||||
top += top_linesize;
|
|
||||||
bottom += bottom_linesize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DEFINE_BLEND8(name, expr) \
|
#define DEFINE_BLEND8(name, expr) \
|
||||||
static void blend_## name##_8bit(const uint8_t *top, ptrdiff_t top_linesize, \
|
static void blend_## name##_8bit(const uint8_t *top, ptrdiff_t top_linesize, \
|
||||||
|
Reference in New Issue
Block a user