1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00

lavc decoders: work with refcounted frames.

This commit is contained in:
Anton Khirnov
2012-11-21 21:34:46 +01:00
parent 6e7b50b427
commit 759001c534
239 changed files with 3904 additions and 4335 deletions

View File

@@ -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;