avcodec/pictordec: Optimize more odd cases for picmemset()

Fixes: Timeout
Fixes: 36875/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PICTOR_fuzzer-4842960888922112

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Tested-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2021-08-31 19:48:18 +02:00
parent cbf111059d
commit 31f03120e8

View File

@ -89,8 +89,7 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run,
d = frame->data[0] + yl * frame->linesize[0]; d = frame->data[0] + yl * frame->linesize[0];
if (s->nb_planes == 1 && if (s->nb_planes == 1 &&
run*pixels_per_value >= s->width && run*pixels_per_value >= s->width &&
pixels_per_value < s->width && pixels_per_value < (s->width / pixels_per_value * pixels_per_value)
s->width % pixels_per_value == 0
) { ) {
for (; xl < pixels_per_value; xl ++) { for (; xl < pixels_per_value; xl ++) {
j = (j < bits_per_plane ? 8 : j) - bits_per_plane; j = (j < bits_per_plane ? 8 : j) - bits_per_plane;
@ -98,7 +97,7 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run,
} }
av_memcpy_backptr(d+xl, pixels_per_value, s->width - xl); av_memcpy_backptr(d+xl, pixels_per_value, s->width - xl);
run -= s->width / pixels_per_value; run -= s->width / pixels_per_value;
xl = s->width; xl = s->width / pixels_per_value * pixels_per_value;
} }
} }
} }