[FFmpeg-devel] [PATCH] avcodec/scpr: Use av_memcpy_backptr() in type 17 and 33

Michael Niedermayer michael at niedermayer.cc
Tue Jul 30 03:10:56 EEST 2019


This makes the changed code-path faster.

Change not tested except with the fuzzer testcase as I found no other testcase.

Improves: Timeout (136sec -> 74sec)
Improves: 16040/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-5705876062601216

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
---
 libavcodec/scpr.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c
index 317950dafb..778b064841 100644
--- a/libavcodec/scpr.c
+++ b/libavcodec/scpr.c
@@ -548,9 +548,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
             clr = bytestream2_get_le24(gb);
         }
         for (y = 0; y < avctx->height; y++) {
-            for (x = 0; x < avctx->width; x++) {
-                dst[x] = clr;
-            }
+            dst[0] = clr;
+            av_memcpy_backptr(dst+1, 4, 4*avctx->width - 4);
             dst += s->current_frame->linesize[0] / 4;
         }
     } else if (type == 0 || type == 1) {
-- 
2.22.0



More information about the ffmpeg-devel mailing list