aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-12-27 02:21:00 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2018-12-31 17:44:25 +0100
commit20564d23fd931c7f7b55b878b5bcd60e24e0a739 (patch)
tree081ad3078fbe04dbe29b89870acb2c591d49477f
parent609e2e64f6e0b348ce861ccd8d17c7a7651b9157 (diff)
downloadffmpeg-20564d23fd931c7f7b55b878b5bcd60e24e0a739.tar.gz
avcodec/scpr: Factor some indexes out in decode_run_i()
This improves the speed of decode_run_i() After: clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-5656821117747200 in 13516 ms Before: clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-5656821117747200 in 14018 ms Improves: 11270/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-5656821117747200 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/scpr.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/libavcodec/scpr.h b/libavcodec/scpr.h
index bb9b4d6a9b..e22188ab3a 100644
--- a/libavcodec/scpr.h
+++ b/libavcodec/scpr.h
@@ -140,26 +140,28 @@ static int decode_run_i(AVCodecContext *avctx, uint32_t ptype, int run,
case 4:
while (run-- > 0) {
uint8_t *odst = (uint8_t *)dst;
+ int off1 = (ly * linesize + lx) * 4;
+ int off2 = ((y * linesize + x) + off) * 4;
if (y < 1 || y >= avctx->height ||
(y == 1 && x == 0))
return AVERROR_INVALIDDATA;
if (x == 0) {
- z = backstep;
+ z = backstep * 4;
} else {
z = 0;
}
- r = odst[(ly * linesize + lx) * 4] +
- odst[((y * linesize + x) + off) * 4 + 4] -
- odst[((y * linesize + x) + off - z) * 4];
- g = odst[(ly * linesize + lx) * 4 + 1] +
- odst[((y * linesize + x) + off) * 4 + 5] -
- odst[((y * linesize + x) + off - z) * 4 + 1];
- b = odst[(ly * linesize + lx) * 4 + 2] +
- odst[((y * linesize + x) + off) * 4 + 6] -
- odst[((y * linesize + x) + off - z) * 4 + 2];
+ r = odst[off1] +
+ odst[off2 + 4] -
+ odst[off2 - z ];
+ g = odst[off1 + 1] +
+ odst[off2 + 5] -
+ odst[off2 - z + 1];
+ b = odst[off1 + 2] +
+ odst[off2 + 6] -
+ odst[off2 - z + 2];
clr = ((b & 0xFF) << 16) + ((g & 0xFF) << 8) + (r & 0xFF);
dst[y * linesize + x] = clr;
lx = x;