History

avfilter/vf_overlay: Pass variable type directly in macro

Improves readability.

Andreas Rheinhardt committed 1 year ago

Commit b3edc841 parent ca51a0f1 file · +16 −16Browse files

Unified · Split

libavfilter/vf_overlay.c+16−16
@@ -444,7 +444,7 @@ static av_always_inline void blend_slice_packed_rgb(AVFilterContext *ctx, · 443 unmodified lines
444444 }
445445 }
446446
447−#define DEFINE_BLEND_PLANE(depth, nbits) \
447+#define DEFINE_BLEND_PLANE(depth, T, nbits) \
448448 static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext *ctx, \
449449 AVFrame *dst, const AVFrame *src, \
450450 int src_w, int src_h, \
@@ -469,8 +469,8 @@ static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext · 18 unmodified lines
469469 int xp = x>>hsub; \
470470 int jmax, j, k, kmax; \
471471 int slice_start, slice_end; \
472− const uint##depth##_t max = (1 << nbits) - 1; \
473− const uint##depth##_t mid = (1 << (nbits -1)) ; \
472+ const T max = (1 << nbits) - 1; \
473+ const T mid = (1 << (nbits - 1)); \
474474 int bytes = depth / 8; \
475475 \
476476 dst_step /= bytes; \
@@ -489,10 +489,10 @@ static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext · 12 unmodified lines
489489 \
490490 for (j = slice_start; j < slice_end; j++) { \
491491 k = FFMAX(-xp, 0); \
492− const uint##depth##_t *s = (const uint##depth##_t *)sp + k; \
493− const uint##depth##_t *a = (const uint##depth##_t *)ap + (k<<hsub); \
494− const uint##depth##_t *da = main_has_alpha ? (uint##depth##_t *)dap + ((xp + k) << hsub) : NULL; \
495− uint##depth##_t *d = (uint##depth##_t *)dp + (xp + k) * dst_step; \
492+ const T *s = (const T *)sp + k; \
493+ const T *a = (const T *)ap + (k << hsub); \
494+ const T *da = main_has_alpha ? (T *)dap + ((xp + k) << hsub) : NULL; \
495+ T *d = (T *)dp + (xp + k) * dst_step; \
496496 kmax = FFMIN(-xp + dst_wp, src_wp); \
497497 \
498498 if (nbits == 8 && ((vsub && j+1 < src_hp) || !vsub) && octx->blend_row[i]) { \
@@ -571,20 +571,20 @@ static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext · 72 unmodified lines
571571 dap += (1 << vsub) * dst->linesize[3]; \
572572 } \
573573 }
574−DEFINE_BLEND_PLANE(8, 8)
575−DEFINE_BLEND_PLANE(16, 10)
574+DEFINE_BLEND_PLANE(8, uint8_t, 8)
575+DEFINE_BLEND_PLANE(16, uint16_t, 10)
576576
577−#define DEFINE_ALPHA_COMPOSITE(depth, nbits) \
577+#define DEFINE_ALPHA_COMPOSITE(depth, T, nbits) \
578578 static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, const AVFrame *dst, \
579579 int src_w, int src_h, \
580580 int dst_w, int dst_h, \
581581 int x, int y, \
582582 int jobnr, int nb_jobs) \
583583 { \
584− uint##depth##_t alpha; /* the amount of overlay to blend on to main */ \
584+ T alpha; /* the amount of overlay to blend on to main */ \
585585 int i, imax, j, jmax; \
586586 int slice_start, slice_end; \
587− const uint##depth##_t max = (1 << nbits) - 1; \
587+ const T max = (1 << nbits) - 1; \
588588 \
589589 imax = FFMIN3(-y + dst_h, FFMIN(src_h, dst_h), y + src_h); \
590590 i = FFMAX(-y, 0); \
@@ -597,8 +597,8 @@ static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c · 6 unmodified lines
597597 \
598598 for (i = slice_start; i < slice_end; i++) { \
599599 j = FFMAX(-x, 0); \
600− const uint##depth##_t *s = (const uint##depth##_t *)sa + j; \
601− uint##depth##_t *d = (uint##depth##_t *)da + x+j; \
600+ const T *s = (const T *)sa + j; \
601+ T *d = (T *)da + x + j; \
602602 \
603603 for (jmax = FFMIN(-x + dst_w, src_w); j < jmax; j++) { \
604604 alpha = *s; \
@@ -622,8 +622,8 @@ static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c · 17 unmodified lines
622622 sa += src->linesize[3]; \
623623 } \
624624 }
625−DEFINE_ALPHA_COMPOSITE(8, 8)
626−DEFINE_ALPHA_COMPOSITE(16, 10)
625+DEFINE_ALPHA_COMPOSITE(8, uint8_t, 8)
626+DEFINE_ALPHA_COMPOSITE(16, uint16_t, 10)
627627
628628 #define DEFINE_BLEND_SLICE_YUV(depth, nbits) \
629629 static av_always_inline void blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t