diff options
author | Connor Worley <connorbworley@gmail.com> | 2024-02-08 11:07:08 -0800 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2024-02-08 20:36:04 +0100 |
commit | c4e9556cf54609b9182dfb1766d3e2c43299a9d6 (patch) | |
tree | 09caefb002a73d559406284639d1c9e44973e647 /libavcodec | |
parent | f6ec01147f7fdb429495b7bd7f25c208208f39a3 (diff) | |
download | ffmpeg-c4e9556cf54609b9182dfb1766d3e2c43299a9d6.tar.gz |
lavc/texturedsp: fix premult2straight inversion
This function should convert premultiplied alpha to straight, but does the opposite.
Signed-off-by: Connor Worley <connorbworley@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/texturedsp.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libavcodec/texturedsp.c b/libavcodec/texturedsp.c index 5fb79937da..721bfc17f5 100644 --- a/libavcodec/texturedsp.c +++ b/libavcodec/texturedsp.c @@ -175,9 +175,12 @@ static av_always_inline void premult2straight(uint8_t *src) int b = src[2]; int a = src[3]; /* unchanged */ - src[0] = (uint8_t) r * a / 255; - src[1] = (uint8_t) g * a / 255; - src[2] = (uint8_t) b * a / 255; + if (a == 0) + return; + + src[0] = (uint8_t) FFMIN(r * 255 / a, 255); + src[1] = (uint8_t) FFMIN(g * 255 / a, 255); + src[2] = (uint8_t) FFMIN(b * 255 / a, 255); } /** |