[FFmpeg-devel,2/2] avutil/imgutils: Optimize writing 4 bytes in memset_bytes()

Submitted by Michael Niedermayer on Dec. 28, 2018, 7:26 p.m.

Details

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

Commit Message

Michael Niedermayer Dec. 28, 2018, 7:26 p.m.
Fixes: Timeout
Fixes: 11502/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664893810769920
Before: Executed clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664893810769920 in 11294 ms
After : Executed clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664893810769920 in 4249 ms

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavutil/imgutils.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Michael Niedermayer Dec. 28, 2018, 7:40 p.m.
On Fri, Dec 28, 2018 at 08:26:58PM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 11502/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664893810769920
> Before: Executed clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664893810769920 in 11294 ms
> After : Executed clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664893810769920 in 4249 ms
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavutil/imgutils.c | 6 ++++++
>  1 file changed, 6 insertions(+)

disregard this, ill send a better one

[...]

Patch hide | download patch | download mbox

diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 229c289c11..2d23079578 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -525,6 +525,12 @@  void av_memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
         }
     } else if (clear_size == 4) {
         uint32_t val = AV_RN32(clear);
+        uint64_t val8 = val * 0x100000001ULL;
+        for (; dst_size >= 32; dst_size -= 32) {
+            AV_WN64(dst   , val8); AV_WN64(dst+ 8, val8);
+            AV_WN64(dst+16, val8); AV_WN64(dst+24, val8);
+            dst += 32;
+        }
         for (; dst_size >= 4; dst_size -= 4) {
             AV_WN32(dst, val);
             dst += 4;