diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-06-03 19:03:08 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-03 19:07:12 +0200 |
commit | 6034b4bb88c1e5fc47fe2c2ff81835cb3dd4e872 (patch) | |
tree | 790ff579aa1ba6ca2fbc611c0b8882aefac119d5 | |
parent | ee08beb7d92150c61824a8eee722a6e4677a090c (diff) | |
parent | 7f596368a404363d72b1be6d16c51420a71bc523 (diff) | |
download | ffmpeg-6034b4bb88c1e5fc47fe2c2ff81835cb3dd4e872.tar.gz |
Merge commit '7f596368a404363d72b1be6d16c51420a71bc523'
* commit '7f596368a404363d72b1be6d16c51420a71bc523':
bink: Factorize bink put_pixel
Conflicts:
libavcodec/bink.c
See: b3675f890abee0bc446495711223a5c790234672
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/bink.c | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/libavcodec/bink.c b/libavcodec/bink.c index bc3d25c739..c793fa79e6 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -950,15 +950,32 @@ static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, return 0; } +static int bink_put_pixels(BinkContext *c, + uint8_t *dst, uint8_t *prev, int stride, + uint8_t *ref_start, + uint8_t *ref_end) +{ + int xoff = get_value(c, BINK_SRC_X_OFF); + int yoff = get_value(c, BINK_SRC_Y_OFF); + uint8_t *ref = prev + xoff + yoff * stride; + if (ref < ref_start || ref > ref_end) { + av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n", + xoff, yoff); + return AVERROR_INVALIDDATA; + } + c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8); + + return 0; +} + static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, int plane_idx, int is_chroma) { int blk, ret; int i, j, bx, by; - uint8_t *dst, *prev, *ref, *ref_start, *ref_end; + uint8_t *dst, *prev, *ref_start, *ref_end; int v, col[2]; const uint8_t *scan; - int xoff, yoff; LOCAL_ALIGNED_16(int16_t, block, [64]); LOCAL_ALIGNED_16(uint8_t, ublock, [64]); LOCAL_ALIGNED_16(int32_t, dctblock, [64]); @@ -1080,15 +1097,10 @@ static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, prev += 8; break; case MOTION_BLOCK: - xoff = get_value(c, BINK_SRC_X_OFF); - yoff = get_value(c, BINK_SRC_Y_OFF); - ref = prev + xoff + yoff * stride; - if (ref < ref_start || ref > ref_end) { - av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n", - bx*8 + xoff, by*8 + yoff); - return AVERROR_INVALIDDATA; - } - c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8); + ret = bink_put_pixels(c, dst, prev, stride, + ref_start, ref_end); + if (ret < 0) + return ret; break; case RUN_BLOCK: scan = bink_patterns[get_bits(gb, 4)]; @@ -1114,15 +1126,10 @@ static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS); break; case RESIDUE_BLOCK: - xoff = get_value(c, BINK_SRC_X_OFF); - yoff = get_value(c, BINK_SRC_Y_OFF); - ref = prev + xoff + yoff * stride; - if (ref < ref_start || ref > ref_end) { - av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n", - bx*8 + xoff, by*8 + yoff); - return AVERROR_INVALIDDATA; - } - c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8); + ret = bink_put_pixels(c, dst, prev, stride, + ref_start, ref_end); + if (ret < 0) + return ret; c->bdsp.clear_block(block); v = get_bits(gb, 7); read_residue(gb, block, v); @@ -1139,15 +1146,10 @@ static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, c->bdsp.fill_block_tab[1](dst, v, stride, 8); break; case INTER_BLOCK: - xoff = get_value(c, BINK_SRC_X_OFF); - yoff = get_value(c, BINK_SRC_Y_OFF); - ref = prev + xoff + yoff * stride; - if (ref < ref_start || ref > ref_end) { - av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n", - bx*8 + xoff, by*8 + yoff); - return -1; - } - c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8); + ret = bink_put_pixels(c, dst, prev, stride, + ref_start, ref_end); + if (ret < 0) + return ret; memset(dctblock, 0, sizeof(*dctblock) * 64); dctblock[0] = get_value(c, BINK_SRC_INTER_DC); read_dct_coeffs(gb, dctblock, bink_scan, bink_inter_quant, -1); |