diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-06-13 14:38:01 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-06-13 14:39:21 +0200 |
commit | e9f2e9715b2bf7e379174b4ca3d23b11526561c0 (patch) | |
tree | b99406b7ef06619780077a91fda649e3006df52a /libavcodec/4xm.c | |
parent | 27e8298c037587d88a3bda1c97caf2351e2e3243 (diff) | |
parent | fbd0dacc8d61ab418b3fa8e7be22017558323e56 (diff) | |
download | ffmpeg-e9f2e9715b2bf7e379174b4ca3d23b11526561c0.tar.gz |
Merge commit 'fbd0dacc8d61ab418b3fa8e7be22017558323e56'
* commit 'fbd0dacc8d61ab418b3fa8e7be22017558323e56':
4xm: refactor decode_p_block
Conflicts:
libavcodec/4xm.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/4xm.c')
-rw-r--r-- | libavcodec/4xm.c | 89 |
1 files changed, 44 insertions, 45 deletions
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index dc0ad506d5..5a20c13b80 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -344,61 +344,25 @@ static int decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, uint16_t *start = (uint16_t *)f->last_picture->data[0]; uint16_t *end = start + stride * (f->avctx->height - h + 1) - (1 << log2w); int ret; + int scale = 1; + unsigned dc = 0; av_assert0(code >= 0 && code <= 6 && log2w >= 0); - if (code == 0) { - if (bytestream2_get_bytes_left(&f->g) < 1) { - av_log(f->avctx, AV_LOG_ERROR, "bytestream overread\n"); - return AVERROR_INVALIDDATA; - } - src += f->mv[bytestream2_get_byteu(&f->g)]; - if (start > src || src > end) { - av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n"); - return AVERROR_INVALIDDATA; - } - mcdc(dst, src, log2w, h, stride, 1, 0); - } else if (code == 1) { + if (code == 1) { log2h--; if ((ret = decode_p_block(f, dst, src, log2w, log2h, stride)) < 0) return ret; - if ((ret = decode_p_block(f, dst + (stride << log2h), - src + (stride << log2h), - log2w, log2h, stride)) < 0) - return ret; + return decode_p_block(f, dst + (stride << log2h), + src + (stride << log2h), + log2w, log2h, stride); } else if (code == 2) { log2w--; if ((ret = decode_p_block(f, dst , src, log2w, log2h, stride)) < 0) return ret; - if ((ret = decode_p_block(f, dst + (1 << log2w), - src + (1 << log2w), - log2w, log2h, stride)) < 0) - return ret; - } else if (code == 3 && f->version < 2) { - av_assert0(start <= src && src <= end); - mcdc(dst, src, log2w, h, stride, 1, 0); - } else if (code == 4) { - if (bytestream2_get_bytes_left(&f->g) < 1) { - av_log(f->avctx, AV_LOG_ERROR, "bytestream overread\n"); - return AVERROR_INVALIDDATA; - } - src += f->mv[bytestream2_get_byteu(&f->g)]; - if (start > src || src > end) { - av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n"); - return AVERROR_INVALIDDATA; - } - if (bytestream2_get_bytes_left(&f->g2) < 2){ - av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n"); - return AVERROR_INVALIDDATA; - } - mcdc(dst, src, log2w, h, stride, 1, bytestream2_get_le16u(&f->g2)); - } else if (code == 5) { - if (bytestream2_get_bytes_left(&f->g2) < 2) { - av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n"); - return AVERROR_INVALIDDATA; - } - av_assert0(start <= src && src <= end); - mcdc(dst, src, log2w, h, stride, 0, bytestream2_get_le16u(&f->g2)); + return decode_p_block(f, dst + (1 << log2w), + src + (1 << log2w), + log2w, log2h, stride); } else if (code == 6) { if (bytestream2_get_bytes_left(&f->g2) < 4) { av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n"); @@ -411,7 +375,42 @@ static int decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, dst[0] = bytestream2_get_le16u(&f->g2); dst[stride] = bytestream2_get_le16u(&f->g2); } + return 0; } + + if ((code&3)==0 && bytestream2_get_bytes_left(&f->g) < 1) { + av_log(f->avctx, AV_LOG_ERROR, "bytestream overread\n"); + return AVERROR_INVALIDDATA; + } + + if (code == 0) { + src += f->mv[bytestream2_get_byte(&f->g)]; + } else if (code == 3 && f->version >= 2) { + return 0; + } else if (code == 4) { + src += f->mv[bytestream2_get_byte(&f->g)]; + if (bytestream2_get_bytes_left(&f->g2) < 2){ + av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n"); + return AVERROR_INVALIDDATA; + } + dc = bytestream2_get_le16(&f->g2); + } else if (code == 5) { + if (bytestream2_get_bytes_left(&f->g2) < 2){ + av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n"); + return AVERROR_INVALIDDATA; + } + av_assert0(start <= src && src <= end); + scale = 0; + dc = bytestream2_get_le16(&f->g2); + } + + if (start > src || src > end) { + av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n"); + return AVERROR_INVALIDDATA; + } + + mcdc(dst, src, log2w, h, stride, scale, dc); + return 0; } |