aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-08-06 18:05:02 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-11-15 12:25:45 +0100
commit23f54b4db28ae5fe35f92e521b76f49e7d989eb9 (patch)
tree93bd2e49e5c3b6262dbfca83168173e6826854e7
parentfd897acc35d45f0b72aee2021170a679b53ffe50 (diff)
downloadffmpeg-23f54b4db28ae5fe35f92e521b76f49e7d989eb9.tar.gz
avcodec/hevc_refs: Optimize 16bit generate_missing_ref()
Fixes: Timeout (86sec -> 8sec) [these numbers assume also "[FFmpeg-devel] [PATCH 2/5] [RFC] avcodec/hevcdec: Check for overread in hls_decode_entry()"] Fixes: 15702/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5657764929470464 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit da8936969fe695a042282d5686e12227745d299a) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/hevc_refs.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index ac462d350b..b14afe3a87 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -397,7 +397,7 @@ static void mark_ref(HEVCFrame *frame, int flag)
static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
{
HEVCFrame *frame;
- int i, x, y;
+ int i, y;
frame = alloc_frame(s);
if (!frame)
@@ -410,11 +410,11 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
frame->frame->buf[i]->size);
} else {
for (i = 0; frame->frame->data[i]; i++)
- for (y = 0; y < (s->ps.sps->height >> s->ps.sps->vshift[i]); y++)
- for (x = 0; x < (s->ps.sps->width >> s->ps.sps->hshift[i]); x++) {
- AV_WN16(frame->frame->data[i] + y * frame->frame->linesize[i] + 2 * x,
- 1 << (s->ps.sps->bit_depth - 1));
- }
+ for (y = 0; y < (s->ps.sps->height >> s->ps.sps->vshift[i]); y++) {
+ uint8_t *dst = frame->frame->data[i] + y * frame->frame->linesize[i];
+ AV_WN16(dst, 1 << (s->ps.sps->bit_depth - 1));
+ av_memcpy_backptr(dst + 2, 2, 2*(s->ps.sps->width >> s->ps.sps->hshift[i]) - 2);
+ }
}
}