diff mbox series

[FFmpeg-devel,1/2] lavc/texturedsp: fix premult2straight inversion

Message ID 20240202003400.30850-1-connorbworley@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] lavc/texturedsp: fix premult2straight inversion | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 fail Make fate failed

Commit Message

Connor Worley Feb. 2, 2024, 12:33 a.m. UTC
This function should convert premultiplied alpha to straight, but does the opposite.

Signed-off-by: Connor Worley <connorbworley@gmail.com>
---
 libavcodec/texturedsp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/texturedsp.c b/libavcodec/texturedsp.c
index 5fb79937da..1b8237e9f7 100644
--- a/libavcodec/texturedsp.c
+++ b/libavcodec/texturedsp.c
@@ -175,9 +175,9 @@  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;
+    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);
 }
 
 /**