avfilter/vf_framerate: remove duplicate code with macro-based function
Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
parent
fd5fdca953
commit
86f0411a52
@ -28,8 +28,7 @@
|
|||||||
ptrdiff_t width, ptrdiff_t height, \
|
ptrdiff_t width, ptrdiff_t height, \
|
||||||
int factor1, int factor2, int half
|
int factor1, int factor2, int half
|
||||||
|
|
||||||
#define BLEND_FACTOR_DEPTH8 7
|
#define BLEND_FACTOR_DEPTH(n) (n-1)
|
||||||
#define BLEND_FACTOR_DEPTH16 15
|
|
||||||
|
|
||||||
typedef void (*blend_func)(BLEND_FUNC_PARAMS);
|
typedef void (*blend_func)(BLEND_FUNC_PARAMS);
|
||||||
|
|
||||||
|
@ -235,44 +235,38 @@ static int query_formats(AVFilterContext *ctx)
|
|||||||
return ff_set_common_formats(ctx, fmts_list);
|
return ff_set_common_formats(ctx, fmts_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blend_frames_c(BLEND_FUNC_PARAMS)
|
#define BLEND_FRAME_FUNC(nbits) \
|
||||||
{
|
static void blend_frames##nbits##_c(BLEND_FUNC_PARAMS) \
|
||||||
int line, pixel;
|
{ \
|
||||||
for (line = 0; line < height; line++) {
|
int line, pixel; \
|
||||||
for (pixel = 0; pixel < width; pixel++)
|
uint##nbits##_t *dstw = (uint##nbits##_t *)dst; \
|
||||||
dst[pixel] = ((src1[pixel] * factor1) + (src2[pixel] * factor2) + half) >> BLEND_FACTOR_DEPTH8;
|
uint##nbits##_t *src1w = (uint##nbits##_t *)src1; \
|
||||||
src1 += src1_linesize;
|
uint##nbits##_t *src2w = (uint##nbits##_t *)src2; \
|
||||||
src2 += src2_linesize;
|
int bytes = nbits / 8; \
|
||||||
dst += dst_linesize;
|
width /= bytes; \
|
||||||
}
|
src1_linesize /= bytes; \
|
||||||
}
|
src2_linesize /= bytes; \
|
||||||
|
dst_linesize /= bytes; \
|
||||||
static void blend_frames16_c(BLEND_FUNC_PARAMS)
|
for (line = 0; line < height; line++) { \
|
||||||
{
|
for (pixel = 0; pixel < width; pixel++) \
|
||||||
int line, pixel;
|
dstw[pixel] = ((src1w[pixel] * factor1) + \
|
||||||
uint16_t *dstw = (uint16_t *)dst;
|
(src2w[pixel] * factor2) + half) \
|
||||||
uint16_t *src1w = (uint16_t *)src1;
|
>> BLEND_FACTOR_DEPTH(nbits); \
|
||||||
uint16_t *src2w = (uint16_t *)src2;
|
src1w += src1_linesize; \
|
||||||
width /= 2;
|
src2w += src2_linesize; \
|
||||||
src1_linesize /= 2;
|
dstw += dst_linesize; \
|
||||||
src2_linesize /= 2;
|
} \
|
||||||
dst_linesize /= 2;
|
|
||||||
for (line = 0; line < height; line++) {
|
|
||||||
for (pixel = 0; pixel < width; pixel++)
|
|
||||||
dstw[pixel] = ((src1w[pixel] * factor1) + (src2w[pixel] * factor2) + half) >> BLEND_FACTOR_DEPTH16;
|
|
||||||
src1w += src1_linesize;
|
|
||||||
src2w += src2_linesize;
|
|
||||||
dstw += dst_linesize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
BLEND_FRAME_FUNC(8)
|
||||||
|
BLEND_FRAME_FUNC(16)
|
||||||
|
|
||||||
void ff_framerate_init(FrameRateContext *s)
|
void ff_framerate_init(FrameRateContext *s)
|
||||||
{
|
{
|
||||||
if (s->bitdepth == 8) {
|
if (s->bitdepth == 8) {
|
||||||
s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH8;
|
s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH(8);
|
||||||
s->blend = blend_frames_c;
|
s->blend = blend_frames8_c;
|
||||||
} else {
|
} else {
|
||||||
s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH16;
|
s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH(16);
|
||||||
s->blend = blend_frames16_c;
|
s->blend = blend_frames16_c;
|
||||||
}
|
}
|
||||||
if (ARCH_X86)
|
if (ARCH_X86)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user