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/ptx.c | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) (limited to 'libavcodec/ptx.c') diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c index e8f8bdd72c..f528843944 100644 --- a/libavcodec/ptx.c +++ b/libavcodec/ptx.c @@ -25,26 +25,11 @@ #include "avcodec.h" #include "internal.h" -typedef struct PTXContext { - AVFrame picture; -} PTXContext; - -static av_cold int ptx_init(AVCodecContext *avctx) { - PTXContext *s = avctx->priv_data; - - avcodec_get_frame_defaults(&s->picture); - avctx->coded_frame= &s->picture; - - return 0; -} - static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; const uint8_t *buf_end = avpkt->data + avpkt->size; - PTXContext * const s = avctx->priv_data; - AVFrame *picture = data; - AVFrame * const p = &s->picture; + AVFrame * const p = data; unsigned int offset, w, h, y, stride, bytes_per_pixel; int ret; uint8_t *ptr; @@ -70,14 +55,11 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, buf += offset; - if (p->data[0]) - avctx->release_buffer(avctx, p); - if ((ret = av_image_check_size(w, h, 0, avctx)) < 0) return ret; if (w != avctx->width || h != avctx->height) avcodec_set_dimensions(avctx, w, h); - if ((ret = ff_get_buffer(avctx, p)) < 0) { + if ((ret = ff_get_buffer(avctx, p, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } @@ -99,7 +81,6 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, buf += w*bytes_per_pixel; } - *picture = s->picture; *got_frame = 1; if (y < h) { @@ -110,22 +91,10 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, return offset + w*h*bytes_per_pixel; } -static av_cold int ptx_end(AVCodecContext *avctx) { - PTXContext *s = avctx->priv_data; - - if(s->picture.data[0]) - avctx->release_buffer(avctx, &s->picture); - - return 0; -} - AVCodec ff_ptx_decoder = { .name = "ptx", .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PTX, - .priv_data_size = sizeof(PTXContext), - .init = ptx_init, - .close = ptx_end, .decode = ptx_decode_frame, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("V.Flash PTX image"), -- cgit v1.2.3