diff options
Diffstat (limited to 'libavcodec/roqvideodec.c')
-rw-r--r-- | libavcodec/roqvideodec.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c index 6812f9a..2309b0b 100644 --- a/libavcodec/roqvideodec.c +++ b/libavcodec/roqvideodec.c @@ -28,6 +28,7 @@ #include "libavutil/avassert.h" #include "avcodec.h" #include "bytestream.h" +#include "internal.h" #include "roqvideo.h" static void roqvideo_decode_frame(RoqContext *ri) @@ -179,10 +180,15 @@ static av_cold int roq_decode_init(AVCodecContext *avctx) s->width = avctx->width; s->height = avctx->height; - avcodec_get_frame_defaults(&s->frames[0]); - avcodec_get_frame_defaults(&s->frames[1]); - 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; @@ -198,8 +204,7 @@ static int roq_decode_frame(AVCodecContext *avctx, int copy= !s->current_frame->data[0]; int ret; - s->current_frame->reference = 3; - if ((ret = avctx->reget_buffer(avctx, s->current_frame)) < 0) { + if ((ret = ff_reget_buffer(avctx, s->current_frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } @@ -211,8 +216,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); @@ -224,11 +230,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; } |