Commit e6f4d5dc authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/ffv1dec_template: Optimize common case in run mode

Fixes: Timeout (14sec -> 9sec)
Fixes: 13398/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5664106709778432

decode_line() becomes 1% faster for fate/vsynth2-ffv1.avi
for another fate sample there is a 0.5% speedup
the effect should be bigger for files with "flat" colored areas
the new faster branch is used in 97-100% of the cases in fate samples
compared to the older more complex (which i tested)

vsynth3-ffv1-v3-bgr0.avi had the lowest percentual useage of about 97%

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 5ddaedca
......@@ -86,11 +86,19 @@ static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w,
run_mode = 2;
}
}
if (sample[1][x - 1] == sample[0][x - 1]) {
while (run_count > 1 && w-x > 1) {
sample[1][x] = sample[0][x];
x++;
run_count--;
}
} else {
while (run_count > 1 && w-x > 1) {
sample[1][x] = RENAME(predict)(sample[1] + x, sample[0] + x);
x++;
run_count--;
}
}
run_count--;
if (run_count < 0) {
run_mode = 0;
......
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