[FFmpeg-devel] [PATCH 2/2] avcodec/gifdec: Optimize gif_fill() by using av_memset_bytes()

Michael Niedermayer michael at niedermayer.cc
Thu Jan 31 15:09:02 EET 2019


Improves speed for 780/clusterfuzz-testcase-6393552642768896 from 95 sec to 60 sec

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/gifdec.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index 2115da163f..c85f310140 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -86,11 +86,7 @@ static void gif_read_palette(GifState *s, uint32_t *pal, int nb)
 
 static void gif_fill(AVFrame *picture, uint32_t color)
 {
-    uint32_t *p = (uint32_t *)picture->data[0];
-    uint32_t *p_end = p + (picture->linesize[0] / sizeof(uint32_t)) * picture->height;
-
-    for (; p < p_end; p++)
-        *p = color;
+    av_memset_bytes(picture->data[0], picture->linesize[0] * picture->height, &color, 4);
 }
 
 static void gif_fill_rect(AVFrame *picture, uint32_t color, int l, int t, int w, int h)
-- 
2.20.1



More information about the ffmpeg-devel mailing list