From dba425ad7a910ea59575d758de555de343258e10 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 12 Mar 2012 14:56:40 +0000 Subject: mimic: convert to bytestream2 API Signed-off-by: Paul B Mahol Signed-off-by: Ronald S. Bultje --- libavcodec/mimic.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'libavcodec/mimic.c') diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 11fe7a36e6..0a6ac2607a 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -306,6 +306,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MimicContext *ctx = avctx->priv_data; + GetByteContext gb; int is_pframe; int width, height; int quality, num_coeffs; @@ -316,14 +317,15 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data, return -1; } - buf += 2; /* some constant (always 256) */ - quality = bytestream_get_le16(&buf); - width = bytestream_get_le16(&buf); - height = bytestream_get_le16(&buf); - buf += 4; /* some constant */ - is_pframe = bytestream_get_le32(&buf); - num_coeffs = bytestream_get_byte(&buf); - buf += 3; /* some constant */ + bytestream2_init(&gb, buf, MIMIC_HEADER_SIZE); + bytestream2_skip(&gb, 2); /* some constant (always 256) */ + quality = bytestream2_get_le16u(&gb); + width = bytestream2_get_le16u(&gb); + height = bytestream2_get_le16u(&gb); + bytestream2_skip(&gb, 4); /* some constant */ + is_pframe = bytestream2_get_le32u(&gb); + num_coeffs = bytestream2_get_byteu(&gb); + bytestream2_skip(&gb, 3); /* some constant */ if(!ctx->avctx) { int i; @@ -373,7 +375,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data, return AVERROR(ENOMEM); ctx->dsp.bswap_buf(ctx->swap_buf, - (const uint32_t*) buf, + (const uint32_t*) (buf + MIMIC_HEADER_SIZE), swap_buf_size>>2); init_get_bits(&ctx->gb, ctx->swap_buf, swap_buf_size << 3); -- cgit v1.2.3 From 33c5c3ad070bc1203e48c8af9c6272d71f1d8b4d Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 12 Mar 2012 14:56:41 +0000 Subject: mimic: do not continue if swap_buf_size is 0 Signed-off-by: Paul B Mahol Signed-off-by: Ronald S. Bultje --- libavcodec/mimic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libavcodec/mimic.c') diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 0a6ac2607a..aa14f64658 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -312,7 +312,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data, int quality, num_coeffs; int swap_buf_size = buf_size - MIMIC_HEADER_SIZE; - if(buf_size < MIMIC_HEADER_SIZE) { + if (buf_size <= MIMIC_HEADER_SIZE) { av_log(avctx, AV_LOG_ERROR, "insufficient data\n"); return -1; } -- cgit v1.2.3