[FFmpeg-cvslog] avfilter/vsrc_testsrc: rgbtestsrc: fix undefined behaviour

Paul B Mahol git at videolan.org
Wed Oct 16 13:39:27 EEST 2019


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Wed Oct 16 12:31:40 2019 +0200| [b20dee813a5ced2fcef9cc5f0fee58034fe70466] | committer: Paul B Mahol

avfilter/vsrc_testsrc: rgbtestsrc: fix undefined behaviour

Fixes #8238

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b20dee813a5ced2fcef9cc5f0fee58034fe70466
---

 libavfilter/vsrc_testsrc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index f06714807f..2a365bdc15 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -968,10 +968,10 @@ AVFILTER_DEFINE_CLASS(rgbtestsrc);
 #define A 3
 
 static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize,
-                              int x, int y, int r, int g, int b, enum AVPixelFormat fmt,
+                              int x, int y, unsigned r, unsigned g, unsigned b, enum AVPixelFormat fmt,
                               uint8_t rgba_map[4])
 {
-    int32_t v;
+    uint32_t v;
     uint8_t *p;
 
     switch (fmt) {
@@ -991,7 +991,7 @@ static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize,
     case AV_PIX_FMT_BGRA:
     case AV_PIX_FMT_ARGB:
     case AV_PIX_FMT_ABGR:
-        v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)) + (255 << (rgba_map[A]*8));
+        v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)) + (255U << (rgba_map[A]*8));
         p = dst + 4*x + y*dst_linesize;
         AV_WL32(p, v);
         break;



More information about the ffmpeg-cvslog mailing list