]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_paletteuse: Fix left shift outside of range of int
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 22 Jan 2020 00:47:21 +0000 (01:47 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Sun, 28 Mar 2021 16:47:15 +0000 (18:47 +0200)
by keeping the variable uint32_t which in this situation is the natural
type anyway. This affected the FATE-test filter-paletteuse-sierra2_4a.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavfilter/vf_paletteuse.c

index fc07c2581dbe98852a271b5bccf7cd6b348a823e..f4c7d60435bcb994f36eec940e3df03ace218a55 100644 (file)
@@ -152,9 +152,10 @@ static int query_formats(AVFilterContext *ctx)
     return 0;
 }
 
-static av_always_inline int dither_color(uint32_t px, int er, int eg, int eb, int scale, int shift)
+static av_always_inline uint32_t dither_color(uint32_t px, int er, int eg,
+                                              int eb, int scale, int shift)
 {
-    return av_clip_uint8( px >> 24                                      ) << 24
+    return                px >> 24                                        << 24
          | av_clip_uint8((px >> 16 & 0xff) + ((er * scale) / (1<<shift))) << 16
          | av_clip_uint8((px >>  8 & 0xff) + ((eg * scale) / (1<<shift))) <<  8
          | av_clip_uint8((px       & 0xff) + ((eb * scale) / (1<<shift)));