aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/dfa.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/dfa.c
parent6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff)
downloadffmpeg-759001c534287a96dc96d1e274665feb7059145d.tar.gz
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/dfa.c')
-rw-r--r--libavcodec/dfa.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c
index 119be7066c..bbe4ce2888 100644
--- a/libavcodec/dfa.c
+++ b/libavcodec/dfa.c
@@ -28,8 +28,6 @@
#include "libavutil/mem.h"
typedef struct DfaContext {
- AVFrame pic;
-
uint32_t pal[256];
uint8_t *frame_buf;
} DfaContext;
@@ -311,6 +309,7 @@ static int dfa_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
+ AVFrame *frame = data;
DfaContext *s = avctx->priv_data;
GetByteContext gb;
const uint8_t *buf = avpkt->data;
@@ -319,10 +318,7 @@ static int dfa_decode_frame(AVCodecContext *avctx,
int ret;
int i, pal_elems;
- if (s->pic.data[0])
- avctx->release_buffer(avctx, &s->pic);
-
- if ((ret = ff_get_buffer(avctx, &s->pic))) {
+ if ((ret = ff_get_buffer(avctx, frame, 0))) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
@@ -340,7 +336,7 @@ static int dfa_decode_frame(AVCodecContext *avctx,
s->pal[i] = bytestream2_get_be24(&gb) << 2;
s->pal[i] |= (s->pal[i] >> 6) & 0x333;
}
- s->pic.palette_has_changed = 1;
+ frame->palette_has_changed = 1;
} else if (chunk_type <= 9) {
if (decoder[chunk_type - 2](&gb, s->frame_buf, avctx->width, avctx->height)) {
av_log(avctx, AV_LOG_ERROR, "Error decoding %s chunk\n",
@@ -355,16 +351,15 @@ static int dfa_decode_frame(AVCodecContext *avctx,
}
buf = s->frame_buf;
- dst = s->pic.data[0];
+ dst = frame->data[0];
for (i = 0; i < avctx->height; i++) {
memcpy(dst, buf, avctx->width);
- dst += s->pic.linesize[0];
+ dst += frame->linesize[0];
buf += avctx->width;
}
- memcpy(s->pic.data[1], s->pal, sizeof(s->pal));
+ memcpy(frame->data[1], s->pal, sizeof(s->pal));
*got_frame = 1;
- *(AVFrame*)data = s->pic;
return avpkt->size;
}
@@ -373,9 +368,6 @@ static av_cold int dfa_decode_end(AVCodecContext *avctx)
{
DfaContext *s = avctx->priv_data;
- if (s->pic.data[0])
- avctx->release_buffer(avctx, &s->pic);
-
av_freep(&s->frame_buf);
return 0;