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
444 }444 }
445}445}
446 446
447#define DEFINE_BLEND_PLANE(depth, nbits) \447#define DEFINE_BLEND_PLANE(depth, T, nbits) \
448static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext *ctx, \448static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext *ctx, \
449 AVFrame *dst, const AVFrame *src, \449 AVFrame *dst, const AVFrame *src, \
450 int src_w, int src_h, \450 int src_w, int src_h, \
@@ -469,8 +469,8 @@ static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext · 18 unmodified lines
469 int xp = x>>hsub; \469 int xp = x>>hsub; \
470 int jmax, j, k, kmax; \470 int jmax, j, k, kmax; \
471 int slice_start, slice_end; \471 int slice_start, slice_end; \
472 const uint##depth##_t max = (1 << nbits) - 1; \472 const T max = (1 << nbits) - 1; \
473 const uint##depth##_t mid = (1 << (nbits -1)) ; \473 const T mid = (1 << (nbits - 1)); \
474 int bytes = depth / 8; \474 int bytes = depth / 8; \
475 \475 \
476 dst_step /= bytes; \476 dst_step /= bytes; \
@@ -489,10 +489,10 @@ static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext · 12 unmodified lines
489 \489 \
490 for (j = slice_start; j < slice_end; j++) { \490 for (j = slice_start; j < slice_end; j++) { \
491 k = FFMAX(-xp, 0); \491 k = FFMAX(-xp, 0); \
492 const uint##depth##_t *s = (const uint##depth##_t *)sp + k; \492 const T *s = (const T *)sp + k; \
493 const uint##depth##_t *a = (const uint##depth##_t *)ap + (k<<hsub); \493 const T *a = (const T *)ap + (k << hsub); \
494 const uint##depth##_t *da = main_has_alpha ? (uint##depth##_t *)dap + ((xp + k) << hsub) : NULL; \494 const T *da = main_has_alpha ? (T *)dap + ((xp + k) << hsub) : NULL; \
495 uint##depth##_t *d = (uint##depth##_t *)dp + (xp + k) * dst_step; \495 T *d = (T *)dp + (xp + k) * dst_step; \
496 kmax = FFMIN(-xp + dst_wp, src_wp); \496 kmax = FFMIN(-xp + dst_wp, src_wp); \
497 \497 \
498 if (nbits == 8 && ((vsub && j+1 < src_hp) || !vsub) && octx->blend_row[i]) { \498 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
571 dap += (1 << vsub) * dst->linesize[3]; \571 dap += (1 << vsub) * dst->linesize[3]; \
572 } \572 } \
573}573}
574DEFINE_BLEND_PLANE(8, 8)574DEFINE_BLEND_PLANE(8, uint8_t, 8)
575DEFINE_BLEND_PLANE(16, 10)575DEFINE_BLEND_PLANE(16, uint16_t, 10)
576 576
577#define DEFINE_ALPHA_COMPOSITE(depth, nbits) \577#define DEFINE_ALPHA_COMPOSITE(depth, T, nbits) \
578static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, const AVFrame *dst, \578static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, const AVFrame *dst, \
579 int src_w, int src_h, \579 int src_w, int src_h, \
580 int dst_w, int dst_h, \580 int dst_w, int dst_h, \
581 int x, int y, \581 int x, int y, \
582 int jobnr, int nb_jobs) \582 int jobnr, int nb_jobs) \
583{ \583{ \
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 */ \
585 int i, imax, j, jmax; \585 int i, imax, j, jmax; \
586 int slice_start, slice_end; \586 int slice_start, slice_end; \
587 const uint##depth##_t max = (1 << nbits) - 1; \587 const T max = (1 << nbits) - 1; \
588 \588 \
589 imax = FFMIN3(-y + dst_h, FFMIN(src_h, dst_h), y + src_h); \589 imax = FFMIN3(-y + dst_h, FFMIN(src_h, dst_h), y + src_h); \
590 i = FFMAX(-y, 0); \590 i = FFMAX(-y, 0); \
@@ -597,8 +597,8 @@ static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c · 6 unmodified lines
597 \597 \
598 for (i = slice_start; i < slice_end; i++) { \598 for (i = slice_start; i < slice_end; i++) { \
599 j = FFMAX(-x, 0); \599 j = FFMAX(-x, 0); \
600 const uint##depth##_t *s = (const uint##depth##_t *)sa + j; \600 const T *s = (const T *)sa + j; \
601 uint##depth##_t *d = (uint##depth##_t *)da + x+j; \601 T *d = (T *)da + x + j; \
602 \602 \
603 for (jmax = FFMIN(-x + dst_w, src_w); j < jmax; j++) { \603 for (jmax = FFMIN(-x + dst_w, src_w); j < jmax; j++) { \
604 alpha = *s; \604 alpha = *s; \
@@ -622,8 +622,8 @@ static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c · 17 unmodified lines
622 sa += src->linesize[3]; \622 sa += src->linesize[3]; \
623 } \623 } \
624}624}
625DEFINE_ALPHA_COMPOSITE(8, 8)625DEFINE_ALPHA_COMPOSITE(8, uint8_t, 8)
626DEFINE_ALPHA_COMPOSITE(16, 10)626DEFINE_ALPHA_COMPOSITE(16, uint16_t, 10)
627 627
628#define DEFINE_BLEND_SLICE_YUV(depth, nbits) \628#define DEFINE_BLEND_SLICE_YUV(depth, nbits) \
629static av_always_inline void blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx, \629static 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