diff options
Diffstat (limited to 'libavcodec/tiertexseqv.c')
-rw-r--r-- | libavcodec/tiertexseqv.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c index e24d401..af39f74 100644 --- a/libavcodec/tiertexseqv.c +++ b/libavcodec/tiertexseqv.c @@ -2,20 +2,20 @@ * Tiertex Limited SEQ Video Decoder * Copyright (c) 2006 Gregory Montoir (cyx@users.sourceforge.net) * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -26,7 +26,7 @@ #define BITSTREAM_READER_LE #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "internal.h" @@ -41,18 +41,18 @@ static const unsigned char *seq_unpack_rle_block(const unsigned char *src, unsigned char *dst, int dst_size) { int i, len, sz; - BitstreamContext bc; + GetBitContext gb; int code_table[64]; /* get the rle codes */ - bitstream_init8(&bc, src, src_end - src); + init_get_bits(&gb, src, (src_end - src) * 8); for (i = 0, sz = 0; i < 64 && sz < dst_size; i++) { - if (bitstream_bits_left(&bc) < 4) + if (get_bits_left(&gb) < 4) return NULL; - code_table[i] = bitstream_read_signed(&bc, 4); + code_table[i] = get_sbits(&gb, 4); sz += FFABS(code_table[i]); } - src += (bitstream_tell(&bc) + 7) / 8; + src += (get_bits_count(&gb) + 7) / 8; /* do the rle unpacking */ for (i = 0; i < 64 && dst_size > 0; i++) { @@ -81,7 +81,7 @@ static const unsigned char *seq_decode_op1(SeqVideoContext *seq, { const unsigned char *color_table; int b, i, len, bits; - BitstreamContext bc; + GetBitContext gb; unsigned char block[8 * 8]; if (src_end - src < 1) @@ -113,11 +113,10 @@ static const unsigned char *seq_decode_op1(SeqVideoContext *seq, return NULL; color_table = src; src += len; - bitstream_init8(&bc, src, bits * 8); - src += bits * 8; + init_get_bits(&gb, src, bits * 8 * 8); src += bits * 8; for (b = 0; b < 8; b++) { for (i = 0; i < 8; i++) - dst[i] = color_table[bitstream_read(&bc, bits)]; + dst[i] = color_table[get_bits(&gb, bits)]; dst += seq->frame->linesize[0]; } } @@ -165,7 +164,7 @@ static const unsigned char *seq_decode_op3(SeqVideoContext *seq, static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size) { const unsigned char *data_end = data + data_size; - BitstreamContext bc; + GetBitContext gb; int flags, i, j, x, y, op; unsigned char c[3]; unsigned char *dst; @@ -180,7 +179,7 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int for (i = 0; i < 256; i++) { for (j = 0; j < 3; j++, data++) c[j] = (*data << 2) | (*data >> 4); - palette[i] = AV_RB24(c); + palette[i] = 0xFFU << 24 | AV_RB24(c); } seq->frame->palette_has_changed = 1; } @@ -188,12 +187,11 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int if (flags & 2) { if (data_end - data < 128) return AVERROR_INVALIDDATA; - bitstream_init8(&bc, data, 128); - data += 128; + init_get_bits(&gb, data, 128 * 8); data += 128; for (y = 0; y < 128; y += 8) for (x = 0; x < 256; x += 8) { dst = &seq->frame->data[0][y * seq->frame->linesize[0] + x]; - op = bitstream_read(&bc, 2); + op = get_bits(&gb, 2); switch (op) { case 1: data = seq_decode_op1(seq, data, data_end, dst); @@ -215,10 +213,15 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int static av_cold int seqvideo_decode_init(AVCodecContext *avctx) { SeqVideoContext *seq = avctx->priv_data; + int ret; seq->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_PAL8; + ret = ff_set_dimensions(avctx, 256, 128); + if (ret < 0) + return ret; + seq->frame = av_frame_alloc(); if (!seq->frame) return AVERROR(ENOMEM); @@ -236,10 +239,8 @@ static int seqvideo_decode_frame(AVCodecContext *avctx, SeqVideoContext *seq = avctx->priv_data; - if ((ret = ff_reget_buffer(avctx, seq->frame)) < 0) { - av_log(seq->avctx, AV_LOG_ERROR, "tiertexseqvideo: reget_buffer() failed\n"); + if ((ret = ff_reget_buffer(avctx, seq->frame)) < 0) return ret; - } if (seqvideo_decode(seq, buf, buf_size)) return AVERROR_INVALIDDATA; |