diff options
author | Paul B Mahol <onemda@gmail.com> | 2017-03-03 12:17:46 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2017-03-03 12:28:24 +0100 |
commit | 6d93e7d1a3e607d001141784e66cc73ba1f061c6 (patch) | |
tree | 939df85a94385e7d593b7a2ee6b8423232aa3256 | |
parent | 16abc10b0997c76cbb0c0ebedc49f6bc21452f9d (diff) | |
download | ffmpeg-6d93e7d1a3e607d001141784e66cc73ba1f061c6.tar.gz |
avcodec/scpr: fix top left prediction for special case when x is 0 for keyframes
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r-- | libavcodec/scpr.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c index 031ce5152a..1fc0593dbb 100644 --- a/libavcodec/scpr.c +++ b/libavcodec/scpr.c @@ -295,7 +295,8 @@ static int decompress_i(AVCodecContext *avctx, uint32_t *dst, int linesize) SCPRContext *s = avctx->priv_data; GetByteContext *gb = &s->gb; int cx = 0, cx1 = 0, k = 0, clr = 0; - int run, r, g, b, off, y = 0, x = 0, ret; + int run, r, g, b, off, y = 0, x = 0, z, ret; + unsigned backstep = linesize - avctx->width; const int cxshift = s->cxshift; unsigned lx, ly, ptype; @@ -424,18 +425,25 @@ static int decompress_i(AVCodecContext *avctx, uint32_t *dst, int linesize) while (run-- > 0) { uint8_t *odst = (uint8_t *)dst; - if (y < 1 || y >= avctx->height) + if (y < 1 || y >= avctx->height || + (y == 1 && x == 0)) return AVERROR_INVALIDDATA; + if (x == 0) { + z = backstep; + } else { + z = 0; + } + r = odst[(ly * linesize + lx) * 4] + - odst[((y * linesize + x) + off) * 4 + 4] - - odst[((y * linesize + x) + off) * 4]; + odst[((y * linesize + x) + off - z) * 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) * 4 + 1]; + odst[((y * linesize + x) + off - z) * 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) * 4 + 2]; + odst[((y * linesize + x) + off - z) * 4 + 6] - + odst[((y * linesize + x) + off - z) * 4 + 2]; clr = ((b & 0xFF) << 16) + ((g & 0xFF) << 8) + (r & 0xFF); dst[y * linesize + x] = clr; lx = x; @@ -449,10 +457,17 @@ static int decompress_i(AVCodecContext *avctx, uint32_t *dst, int linesize) break; case 5: while (run-- > 0) { - if (y < 1 || y >= avctx->height) + if (y < 1 || y >= avctx->height || + (y == 1 && x == 0)) return AVERROR_INVALIDDATA; - clr = dst[y * linesize + x + off]; + if (x == 0) { + z = backstep; + } else { + z = 0; + } + + clr = dst[y * linesize + x + off - z]; dst[y * linesize + x] = clr; lx = x; ly = y; |