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

Submitted by Michael Niedermayer on Jan. 31, 2019, 1:09 p.m.

Details

Message ID 20190131130902.26536-2-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Jan. 31, 2019, 1:09 p.m.
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@niedermayer.cc>
---
 libavcodec/gifdec.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Patch hide | download patch | download mbox

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)