summaryrefslogtreecommitdiff
path: root/libavcodec/roqvideodec.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/roqvideodec.c
parent6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff)
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/roqvideodec.c')
-rw-r--r--libavcodec/roqvideodec.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c
index 3ee62c01b5..ef561a3210 100644
--- a/libavcodec/roqvideodec.c
+++ b/libavcodec/roqvideodec.c
@@ -31,6 +31,7 @@
#include "avcodec.h"
#include "bytestream.h"
+#include "internal.h"
#include "roqvideo.h"
static void roqvideo_decode_frame(RoqContext *ri)
@@ -168,8 +169,15 @@ static av_cold int roq_decode_init(AVCodecContext *avctx)
s->width = avctx->width;
s->height = avctx->height;
- s->last_frame = &s->frames[0];
- s->current_frame = &s->frames[1];
+
+ s->last_frame = av_frame_alloc();
+ s->current_frame = av_frame_alloc();
+ if (!s->current_frame || !s->last_frame) {
+ av_frame_free(&s->current_frame);
+ av_frame_free(&s->last_frame);
+ return AVERROR(ENOMEM);
+ }
+
avctx->pix_fmt = AV_PIX_FMT_YUV444P;
return 0;
@@ -183,11 +191,11 @@ static int roq_decode_frame(AVCodecContext *avctx,
int buf_size = avpkt->size;
RoqContext *s = avctx->priv_data;
int copy= !s->current_frame->data[0];
+ int ret;
- s->current_frame->reference = 3;
- if (avctx->reget_buffer(avctx, s->current_frame)) {
+ if ((ret = ff_reget_buffer(avctx, s->current_frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, " RoQ: get_buffer() failed\n");
- return -1;
+ return ret;
}
if(copy)
@@ -197,8 +205,9 @@ static int roq_decode_frame(AVCodecContext *avctx,
bytestream2_init(&s->gb, buf, buf_size);
roqvideo_decode_frame(s);
+ if ((ret = av_frame_ref(data, s->current_frame)) < 0)
+ return ret;
*got_frame = 1;
- *(AVFrame*)data = *s->current_frame;
/* shuffle frames */
FFSWAP(AVFrame *, s->current_frame, s->last_frame);
@@ -210,11 +219,8 @@ static av_cold int roq_decode_end(AVCodecContext *avctx)
{
RoqContext *s = avctx->priv_data;
- /* release the last frame */
- if (s->last_frame->data[0])
- avctx->release_buffer(avctx, s->last_frame);
- if (s->current_frame->data[0])
- avctx->release_buffer(avctx, s->current_frame);
+ av_frame_free(&s->current_frame);
+ av_frame_free(&s->last_frame);
return 0;
}