diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2019-04-22 22:33:55 +0300 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2019-04-25 15:49:50 +0300 |
commit | b91786360f481e8fbc062af8c05dd0f971398afa (patch) | |
tree | 5aebdec731ba313b9de35080df4ea4bafe745cdf /libavcodec/zmbv.c | |
parent | 1ae5a6445724457a27c665a5a793c98aebff7d33 (diff) |
avcodec/zmbv: optimize motion compensation with memcpy()
Fixes: Timeout (16 sec - 7 sec)
Fixes: 14237/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZMBV_fuzzer-5693453897302016
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/zmbv.c')
-rw-r--r-- | libavcodec/zmbv.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index 898b62d065..99e735cfd9 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -121,6 +121,8 @@ static int zmbv_decode_xor_8(ZmbvContext *c) for (j = 0; j < bh2; j++) { if (my + j < 0 || my + j >= c->height) { memset(out, 0, bw2); + } else if (mx >= 0 && mx + bw2 <= c->width){ + memcpy(out, tprev, sizeof(*out) * bw2); } else { for (i = 0; i < bw2; i++) { if (mx + i < 0 || mx + i >= c->width) @@ -193,6 +195,8 @@ static int zmbv_decode_xor_16(ZmbvContext *c) for (j = 0; j < bh2; j++) { if (my + j < 0 || my + j >= c->height) { memset(out, 0, bw2 * 2); + } else if (mx >= 0 && mx + bw2 <= c->width){ + memcpy(out, tprev, sizeof(*out) * bw2); } else { for (i = 0; i < bw2; i++) { if (mx + i < 0 || mx + i >= c->width) @@ -270,6 +274,8 @@ static int zmbv_decode_xor_24(ZmbvContext *c) for (j = 0; j < bh2; j++) { if (my + j < 0 || my + j >= c->height) { memset(out, 0, bw2 * 3); + } else if (mx >= 0 && mx + bw2 <= c->width){ + memcpy(out, tprev, 3 * bw2); } else { for (i = 0; i < bw2; i++){ if (mx + i < 0 || mx + i >= c->width) { @@ -351,6 +357,8 @@ static int zmbv_decode_xor_32(ZmbvContext *c) for (j = 0; j < bh2; j++) { if (my + j < 0 || my + j >= c->height) { memset(out, 0, bw2 * 4); + } else if (mx >= 0 && mx + bw2 <= c->width){ + memcpy(out, tprev, sizeof(*out) * bw2); } else { for (i = 0; i < bw2; i++){ if (mx + i < 0 || mx + i >= c->width) |