mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-14 00:58:38 +02:00
avcodec/pictordec: Optimize picmemset() for single plane full lines
Fixes: Timeout (72sec -> 1sec) Fixes: 15512/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PICTOR_fuzzer-5663942342344704 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
34f6d1a7d7
commit
5231e89eb9
@ -66,6 +66,7 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run,
|
|||||||
int xl = *x;
|
int xl = *x;
|
||||||
int yl = *y;
|
int yl = *y;
|
||||||
int planel = *plane;
|
int planel = *plane;
|
||||||
|
int pixels_per_value = 8/bits_per_plane;
|
||||||
value <<= shift;
|
value <<= shift;
|
||||||
|
|
||||||
d = frame->data[0] + yl * frame->linesize[0];
|
d = frame->data[0] + yl * frame->linesize[0];
|
||||||
@ -74,7 +75,7 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run,
|
|||||||
for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) {
|
for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) {
|
||||||
d[xl] |= (value >> j) & mask;
|
d[xl] |= (value >> j) & mask;
|
||||||
xl += 1;
|
xl += 1;
|
||||||
if (xl == s->width) {
|
while (xl == s->width) {
|
||||||
yl -= 1;
|
yl -= 1;
|
||||||
xl = 0;
|
xl = 0;
|
||||||
if (yl < 0) {
|
if (yl < 0) {
|
||||||
@ -86,6 +87,19 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run,
|
|||||||
mask <<= bits_per_plane;
|
mask <<= bits_per_plane;
|
||||||
}
|
}
|
||||||
d = frame->data[0] + yl * frame->linesize[0];
|
d = frame->data[0] + yl * frame->linesize[0];
|
||||||
|
if (s->nb_planes == 1 &&
|
||||||
|
run*pixels_per_value >= s->width &&
|
||||||
|
pixels_per_value < s->width &&
|
||||||
|
s->width % pixels_per_value == 0
|
||||||
|
) {
|
||||||
|
for (; xl < pixels_per_value; xl ++) {
|
||||||
|
j = (j < bits_per_plane ? 8 : j) - bits_per_plane;
|
||||||
|
d[xl] |= (value >> j) & mask;
|
||||||
|
}
|
||||||
|
av_memcpy_backptr(d+xl, pixels_per_value, s->width - xl);
|
||||||
|
run -= s->width / pixels_per_value;
|
||||||
|
xl = s->width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
run--;
|
run--;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user