Commit 508b3755 authored by Anton Khirnov's avatar Anton Khirnov

tiertexseqv: use the AVFrame API properly.

parent 68af7f54
......@@ -32,7 +32,7 @@
typedef struct SeqVideoContext {
AVCodecContext *avctx;
AVFrame frame;
AVFrame *frame;
} SeqVideoContext;
......@@ -93,14 +93,14 @@ static const unsigned char *seq_decode_op1(SeqVideoContext *seq,
src = seq_unpack_rle_block(src, src_end, block, sizeof(block));
for (b = 0; b < 8; b++) {
memcpy(dst, &block[b * 8], 8);
dst += seq->frame.linesize[0];
dst += seq->frame->linesize[0];
}
break;
case 2:
src = seq_unpack_rle_block(src, src_end, block, sizeof(block));
for (i = 0; i < 8; i++) {
for (b = 0; b < 8; b++)
dst[b * seq->frame.linesize[0]] = block[i * 8 + b];
dst[b * seq->frame->linesize[0]] = block[i * 8 + b];
++dst;
}
break;
......@@ -117,7 +117,7 @@ static const unsigned char *seq_decode_op1(SeqVideoContext *seq,
for (b = 0; b < 8; b++) {
for (i = 0; i < 8; i++)
dst[i] = color_table[get_bits(&gb, bits)];
dst += seq->frame.linesize[0];
dst += seq->frame->linesize[0];
}
}
......@@ -137,7 +137,7 @@ static const unsigned char *seq_decode_op2(SeqVideoContext *seq,
for (i = 0; i < 8; i++) {
memcpy(dst, src, 8);
src += 8;
dst += seq->frame.linesize[0];
dst += seq->frame->linesize[0];
}
return src;
......@@ -154,7 +154,7 @@ static const unsigned char *seq_decode_op3(SeqVideoContext *seq,
if (src_end - src < 2)
return NULL;
pos = *src++;
offset = ((pos >> 3) & 7) * seq->frame.linesize[0] + (pos & 7);
offset = ((pos >> 3) & 7) * seq->frame->linesize[0] + (pos & 7);
dst[offset] = *src++;
} while (!(pos & 0x80));
......@@ -173,7 +173,7 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int
flags = *data++;
if (flags & 1) {
palette = (uint32_t *)seq->frame.data[1];
palette = (uint32_t *)seq->frame->data[1];
if (data_end - data < 256 * 3)
return AVERROR_INVALIDDATA;
for (i = 0; i < 256; i++) {
......@@ -181,7 +181,7 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int
c[j] = (*data << 2) | (*data >> 4);
palette[i] = AV_RB24(c);
}
seq->frame.palette_has_changed = 1;
seq->frame->palette_has_changed = 1;
}
if (flags & 2) {
......@@ -190,7 +190,7 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int
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];
dst = &seq->frame->data[0][y * seq->frame->linesize[0] + x];
op = get_bits(&gb, 2);
switch (op) {
case 1:
......@@ -217,7 +217,9 @@ static av_cold int seqvideo_decode_init(AVCodecContext *avctx)
seq->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
avcodec_get_frame_defaults(&seq->frame);
seq->frame = av_frame_alloc();
if (!seq->frame)
return AVERROR(ENOMEM);
return 0;
}
......@@ -232,7 +234,7 @@ static int seqvideo_decode_frame(AVCodecContext *avctx,
SeqVideoContext *seq = avctx->priv_data;
if ((ret = ff_reget_buffer(avctx, &seq->frame)) < 0) {
if ((ret = ff_reget_buffer(avctx, seq->frame)) < 0) {
av_log(seq->avctx, AV_LOG_ERROR, "tiertexseqvideo: reget_buffer() failed\n");
return ret;
}
......@@ -240,7 +242,7 @@ static int seqvideo_decode_frame(AVCodecContext *avctx,
if (seqvideo_decode(seq, buf, buf_size))
return AVERROR_INVALIDDATA;
if ((ret = av_frame_ref(data, &seq->frame)) < 0)
if ((ret = av_frame_ref(data, seq->frame)) < 0)
return ret;
*got_frame = 1;
......@@ -251,7 +253,7 @@ static av_cold int seqvideo_decode_end(AVCodecContext *avctx)
{
SeqVideoContext *seq = avctx->priv_data;
av_frame_unref(&seq->frame);
av_frame_free(&seq->frame);
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment