diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2012-03-24 17:37:43 -0700 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2012-03-25 16:31:16 -0700 |
commit | b2af057a36375cd16a68894437136d22bcca69a0 (patch) | |
tree | a1a50d89385fdaa4848dd1dd41b75809842b4579 /libavcodec/smacker.c | |
parent | c3bbd0b53b5d105078de5985f54f7623fd5545ce (diff) | |
download | ffmpeg-b2af057a36375cd16a68894437136d22bcca69a0.tar.gz |
smacker: convert palette and header reading to bytestream2.
Diffstat (limited to 'libavcodec/smacker.c')
-rw-r--r-- | libavcodec/smacker.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index c7889afb59..05f4a925fb 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -357,17 +357,17 @@ static av_always_inline int smk_get_code(GetBitContext *gb, int *recode, int *la static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; SmackVContext * const smk = avctx->priv_data; uint8_t *out; uint32_t *pal; + GetByteContext gb2; GetBitContext gb; int blocks, blk, bw, bh; int i; int stride; + int flags; - if(buf_size <= 769) + if (avpkt->size <= 769) return 0; smk->pic.reference = 1; @@ -379,23 +379,23 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac /* make the palette available on the way out */ pal = (uint32_t*)smk->pic.data[1]; - smk->pic.palette_has_changed = buf[0] & 1; - smk->pic.key_frame = !!(buf[0] & 2); + bytestream2_init(&gb2, avpkt->data, avpkt->size); + flags = bytestream2_get_byteu(&gb2); + smk->pic.palette_has_changed = flags & 1; + smk->pic.key_frame = !!(flags & 2); if(smk->pic.key_frame) smk->pic.pict_type = AV_PICTURE_TYPE_I; else smk->pic.pict_type = AV_PICTURE_TYPE_P; - buf++; for(i = 0; i < 256; i++) - *pal++ = bytestream_get_be24(&buf); - buf_size -= 769; + *pal++ = bytestream2_get_be24u(&gb2); last_reset(smk->mmap_tbl, smk->mmap_last); last_reset(smk->mclr_tbl, smk->mclr_last); last_reset(smk->full_tbl, smk->full_last); last_reset(smk->type_tbl, smk->type_last); - init_get_bits(&gb, buf, buf_size * 8); + init_get_bits(&gb, avpkt->data + 769, (avpkt->size - 769) * 8); blk = 0; bw = avctx->width >> 2; @@ -506,7 +506,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac *(AVFrame*)data = smk->pic; /* always report that the buffer was completely consumed */ - return buf_size; + return avpkt->size; } |