aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_overlay.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-05-01 19:57:44 +0200
committerPaul B Mahol <onemda@gmail.com>2022-05-01 20:02:24 +0200
commitbdf01a9609e49ff602b38826420252356d98ba2a (patch)
tree02905b73ce963f79d636e9ca8fbc182bfa3aa801 /libavfilter/vf_overlay.c
parent987d2c1083d9bc9464000c8732c3353c7bf7e9ca (diff)
downloadffmpeg-bdf01a9609e49ff602b38826420252356d98ba2a.tar.gz
avfilter/vf_overlay: improve premultiplied alpha overlay for YUV
Diffstat (limited to 'libavfilter/vf_overlay.c')
-rw-r--r--libavfilter/vf_overlay.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 685b6069a6..f560d54dae 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -538,12 +538,13 @@ static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext
if (i && yuv) \
*d = av_clip((*d * (max - alpha) + *s * alpha) / max + *s - mid, -mid, mid) + mid; \
else \
- *d = FFMIN((*d * (max - alpha) + *s * alpha) / max + *s, max); \
+ *d = av_clip_uintp2((*d * (max - alpha) + *s * alpha) / max + *s - (16<<(nbits-8)),\
+ nbits);\
} else { \
if (i && yuv) \
*d = av_clip(FAST_DIV255((*d - mid) * (max - alpha)) + *s - mid, -mid, mid) + mid; \
else \
- *d = FFMIN(FAST_DIV255(*d * (max - alpha)) + *s, max); \
+ *d = av_clip_uint8(FAST_DIV255(*d * (255 - alpha)) + *s - 16); \
} \
} \
s++; \