Commit da893696 authored by Michael Niedermayer's avatar Michael Niedermayer

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/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 950a21e8
...@@ -394,7 +394,7 @@ static void mark_ref(HEVCFrame *frame, int flag) ...@@ -394,7 +394,7 @@ static void mark_ref(HEVCFrame *frame, int flag)
static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc) static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
{ {
HEVCFrame *frame; HEVCFrame *frame;
int i, x, y; int i, y;
frame = alloc_frame(s); frame = alloc_frame(s);
if (!frame) if (!frame)
...@@ -407,10 +407,10 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc) ...@@ -407,10 +407,10 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
frame->frame->buf[i]->size); frame->frame->buf[i]->size);
} else { } else {
for (i = 0; frame->frame->data[i]; i++) for (i = 0; frame->frame->data[i]; i++)
for (y = 0; y < (s->ps.sps->height >> s->ps.sps->vshift[i]); y++) 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++) { uint8_t *dst = frame->frame->data[i] + y * frame->frame->linesize[i];
AV_WN16(frame->frame->data[i] + y * frame->frame->linesize[i] + 2 * x, AV_WN16(dst, 1 << (s->ps.sps->bit_depth - 1));
1 << (s->ps.sps->bit_depth - 1)); av_memcpy_backptr(dst + 2, 2, 2*(s->ps.sps->width >> s->ps.sps->hshift[i]) - 2);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment