From 759001c534287a96dc96d1e274665feb7059145d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 21 Nov 2012 21:34:46 +0100 Subject: lavc decoders: work with refcounted frames. --- libavcodec/fraps.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) (limited to 'libavcodec/fraps.c') diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index 237cb743f9..2a5a5a8b38 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -36,6 +36,7 @@ #include "huffman.h" #include "bytestream.h" #include "dsputil.h" +#include "internal.h" #define FPS_TAG MKTAG('F', 'P', 'S', 'x') @@ -60,7 +61,6 @@ static av_cold int decode_init(AVCodecContext *avctx) { FrapsContext * const s = avctx->priv_data; - avctx->coded_frame = &s->frame; avctx->pix_fmt = AV_PIX_FMT_NONE; /* set in decode_frame */ s->avctx = avctx; @@ -161,7 +161,7 @@ static int decode_frame(AVCodecContext *avctx, pix_fmt = version & 1 ? AV_PIX_FMT_BGR24 : AV_PIX_FMT_YUVJ420P; if (avctx->pix_fmt != pix_fmt && f->data[0]) { - avctx->release_buffer(avctx, f); + av_frame_unref(f); } avctx->pix_fmt = pix_fmt; @@ -184,11 +184,7 @@ static int decode_frame(AVCodecContext *avctx, return AVERROR_INVALIDDATA; } - f->reference = 1; - f->buffer_hints = FF_BUFFER_HINTS_VALID | - FF_BUFFER_HINTS_PRESERVE | - FF_BUFFER_HINTS_REUSABLE; - if ((ret = avctx->reget_buffer(avctx, f)) < 0) { + if ((ret = ff_reget_buffer(avctx, f)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } @@ -225,11 +221,7 @@ static int decode_frame(AVCodecContext *avctx, return AVERROR_INVALIDDATA; } - f->reference = 1; - f->buffer_hints = FF_BUFFER_HINTS_VALID | - FF_BUFFER_HINTS_PRESERVE | - FF_BUFFER_HINTS_REUSABLE; - if ((ret = avctx->reget_buffer(avctx, f)) < 0) { + if ((ret = ff_reget_buffer(avctx, f)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } @@ -252,11 +244,7 @@ static int decode_frame(AVCodecContext *avctx, * Fraps v4 is virtually the same */ planes = 3; - f->reference = 1; - f->buffer_hints = FF_BUFFER_HINTS_VALID | - FF_BUFFER_HINTS_PRESERVE | - FF_BUFFER_HINTS_REUSABLE; - if ((ret = avctx->reget_buffer(avctx, f)) < 0) { + if ((ret = ff_reget_buffer(avctx, f)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } @@ -300,11 +288,7 @@ static int decode_frame(AVCodecContext *avctx, case 5: /* Virtually the same as version 4, but is for RGB24 */ planes = 3; - f->reference = 1; - f->buffer_hints = FF_BUFFER_HINTS_VALID | - FF_BUFFER_HINTS_PRESERVE | - FF_BUFFER_HINTS_REUSABLE; - if ((ret = avctx->reget_buffer(avctx, f)) < 0) { + if ((ret = ff_reget_buffer(avctx, f)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } @@ -350,7 +334,8 @@ static int decode_frame(AVCodecContext *avctx, break; } - *frame = *f; + if ((ret = av_frame_ref(frame, f)) < 0) + return ret; *got_frame = 1; return buf_size; @@ -366,8 +351,7 @@ static av_cold int decode_end(AVCodecContext *avctx) { FrapsContext *s = (FrapsContext*)avctx->priv_data; - if (s->frame.data[0]) - avctx->release_buffer(avctx, &s->frame); + av_frame_unref(&s->frame); av_freep(&s->tmpbuf); return 0; -- cgit v1.2.3