aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vqavideo.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-11-21 21:34:46 +0100
committerAnton Khirnov <anton@khirnov.net>2013-03-08 07:38:30 +0100
commit759001c534287a96dc96d1e274665feb7059145d (patch)
tree6ace9560c20aa30db92067c5b45d7bd86e458d10 /libavcodec/vqavideo.c
parent6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff)
downloadffmpeg-759001c534287a96dc96d1e274665feb7059145d.tar.gz
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/vqavideo.c')
-rw-r--r--libavcodec/vqavideo.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
index ae854cda56..ed4d8147cb 100644
--- a/libavcodec/vqavideo.c
+++ b/libavcodec/vqavideo.c
@@ -94,7 +94,6 @@
typedef struct VqaContext {
AVCodecContext *avctx;
- AVFrame frame;
GetByteContext gb;
uint32_t palette[PALETTE_COUNT];
@@ -188,8 +187,6 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx)
}
s->next_codebook_buffer_index = 0;
- s->frame.data[0] = NULL;
-
return 0;
fail:
av_freep(&s->codebook);
@@ -303,7 +300,7 @@ static int decode_format80(GetByteContext *gb, int src_size,
return 0; // let's display what we decoded anyway
}
-static int vqa_decode_chunk(VqaContext *s)
+static int vqa_decode_chunk(VqaContext *s, AVFrame *frame)
{
unsigned int chunk_type;
unsigned int chunk_size;
@@ -471,7 +468,7 @@ static int vqa_decode_chunk(VqaContext *s)
index_shift = 3;
for (y = 0; y < s->height; y += s->vector_height) {
for (x = 0; x < s->width; x += 4, lobytes++, hibytes++) {
- pixel_ptr = y * s->frame.linesize[0] + x;
+ pixel_ptr = y * frame->linesize[0] + x;
/* get the vector index, the method for which varies according to
* VQA file version */
@@ -486,11 +483,11 @@ static int vqa_decode_chunk(VqaContext *s)
/* uniform color fill - a quick hack */
if (hibyte == 0xFF) {
while (lines--) {
- s->frame.data[0][pixel_ptr + 0] = 255 - lobyte;
- s->frame.data[0][pixel_ptr + 1] = 255 - lobyte;
- s->frame.data[0][pixel_ptr + 2] = 255 - lobyte;
- s->frame.data[0][pixel_ptr + 3] = 255 - lobyte;
- pixel_ptr += s->frame.linesize[0];
+ frame->data[0][pixel_ptr + 0] = 255 - lobyte;
+ frame->data[0][pixel_ptr + 1] = 255 - lobyte;
+ frame->data[0][pixel_ptr + 2] = 255 - lobyte;
+ frame->data[0][pixel_ptr + 3] = 255 - lobyte;
+ pixel_ptr += frame->linesize[0];
}
lines=0;
}
@@ -511,11 +508,11 @@ static int vqa_decode_chunk(VqaContext *s)
}
while (lines--) {
- s->frame.data[0][pixel_ptr + 0] = s->codebook[vector_index++];
- s->frame.data[0][pixel_ptr + 1] = s->codebook[vector_index++];
- s->frame.data[0][pixel_ptr + 2] = s->codebook[vector_index++];
- s->frame.data[0][pixel_ptr + 3] = s->codebook[vector_index++];
- pixel_ptr += s->frame.linesize[0];
+ frame->data[0][pixel_ptr + 0] = s->codebook[vector_index++];
+ frame->data[0][pixel_ptr + 1] = s->codebook[vector_index++];
+ frame->data[0][pixel_ptr + 2] = s->codebook[vector_index++];
+ frame->data[0][pixel_ptr + 3] = s->codebook[vector_index++];
+ pixel_ptr += frame->linesize[0];
}
}
}
@@ -596,26 +593,23 @@ static int vqa_decode_frame(AVCodecContext *avctx,
AVPacket *avpkt)
{
VqaContext *s = avctx->priv_data;
+ AVFrame *frame = data;
int res;
- if (s->frame.data[0])
- avctx->release_buffer(avctx, &s->frame);
-
- if ((res = ff_get_buffer(avctx, &s->frame)) < 0) {
+ if ((res = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(s->avctx, AV_LOG_ERROR, " VQA Video: get_buffer() failed\n");
return res;
}
bytestream2_init(&s->gb, avpkt->data, avpkt->size);
- if ((res = vqa_decode_chunk(s)) < 0)
+ if ((res = vqa_decode_chunk(s, frame)) < 0)
return res;
/* make the palette available on the way out */
- memcpy(s->frame.data[1], s->palette, PALETTE_COUNT * 4);
- s->frame.palette_has_changed = 1;
+ memcpy(frame->data[1], s->palette, PALETTE_COUNT * 4);
+ frame->palette_has_changed = 1;
*got_frame = 1;
- *(AVFrame*)data = s->frame;
/* report that the buffer was completely consumed */
return avpkt->size;
@@ -629,9 +623,6 @@ static av_cold int vqa_decode_end(AVCodecContext *avctx)
av_freep(&s->next_codebook_buffer);
av_freep(&s->decode_buffer);
- if (s->frame.data[0])
- avctx->release_buffer(avctx, &s->frame);
-
return 0;
}