diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-09-03 15:46:56 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-09-03 15:48:33 +0200 |
commit | 84b6451d29eca20d8ee27ff162fd9e2adcd3d98b (patch) | |
tree | 160ba82491ea5dcc280b4e26b5d1fa07ed174b33 | |
parent | a4e70918316c6d1423e559aad15823a5e0453fcf (diff) | |
download | ffmpeg-84b6451d29eca20d8ee27ff162fd9e2adcd3d98b.tar.gz |
avcodec/vcr1: simplify code, drop buf_size
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/vcr1.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c index d6b617a11e..f97add132d 100644 --- a/libavcodec/vcr1.c +++ b/libavcodec/vcr1.c @@ -50,13 +50,13 @@ static int vcr1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; VCR1Context *const a = avctx->priv_data; AVFrame *const p = data; const uint8_t *bytestream = buf; + const uint8_t *bytestream_end = bytestream + avpkt->size; int i, x, y, ret; - if(buf_size < 16 + avctx->height + avctx->width*avctx->height*5/8){ + if(avpkt->size < 16 + avctx->height + avctx->width*avctx->height*5/8){ av_log(avctx, AV_LOG_ERROR, "Insufficient input data.\n"); return AVERROR(EINVAL); } @@ -69,7 +69,6 @@ static int vcr1_decode_frame(AVCodecContext *avctx, void *data, for (i = 0; i < 16; i++) { a->delta[i] = *bytestream++; bytestream++; - buf_size--; } for (y = 0; y < avctx->height; y++) { @@ -80,11 +79,10 @@ static int vcr1_decode_frame(AVCodecContext *avctx, void *data, uint8_t *cb = &p->data[1][(y >> 2) * p->linesize[1]]; uint8_t *cr = &p->data[2][(y >> 2) * p->linesize[2]]; - av_assert0 (buf_size >= 4 + avctx->width); + av_assert0 (bytestream_end - bytestream >= 4 + avctx->width); for (i = 0; i < 4; i++) a->offset[i] = *bytestream++; - buf_size -= 4; offset = a->offset[0] - a->delta[bytestream[2] & 0xF]; for (x = 0; x < avctx->width; x += 4) { @@ -98,10 +96,9 @@ static int vcr1_decode_frame(AVCodecContext *avctx, void *data, *cr++ = bytestream[1]; bytestream += 4; - buf_size -= 4; } } else { - av_assert0 (buf_size >= avctx->width / 2); + av_assert0 (bytestream_end - bytestream >= avctx->width / 2); offset = a->offset[y & 3] - a->delta[bytestream[2] & 0xF]; @@ -116,7 +113,6 @@ static int vcr1_decode_frame(AVCodecContext *avctx, void *data, luma[7] = offset += a->delta[bytestream[1] >> 4]; luma += 8; bytestream += 4; - buf_size -= 4; } } } |