aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/zmbv.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/zmbv.c
parent6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff)
downloadffmpeg-759001c534287a96dc96d1e274665feb7059145d.tar.gz
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/zmbv.c')
-rw-r--r--libavcodec/zmbv.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
index 5d4254aec0..8cf6a0cb5b 100644
--- a/libavcodec/zmbv.c
+++ b/libavcodec/zmbv.c
@@ -54,7 +54,6 @@ enum ZmbvFormat {
*/
typedef struct ZmbvContext {
AVCodecContext *avctx;
- AVFrame pic;
int bpp;
unsigned int decomp_size;
@@ -400,6 +399,7 @@ static int zmbv_decode_intra(ZmbvContext *c)
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
{
+ AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ZmbvContext * const c = avctx->priv_data;
@@ -408,12 +408,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
int hi_ver, lo_ver, ret;
uint8_t *tmp;
- if (c->pic.data[0])
- avctx->release_buffer(avctx, &c->pic);
-
- c->pic.reference = 1;
- c->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
- if ((ret = ff_get_buffer(avctx, &c->pic)) < 0) {
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
@@ -524,12 +519,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
c->decomp_len = c->zstream.total_out;
}
if (c->flags & ZMBV_KEYFRAME) {
- c->pic.key_frame = 1;
- c->pic.pict_type = AV_PICTURE_TYPE_I;
+ frame->key_frame = 1;
+ frame->pict_type = AV_PICTURE_TYPE_I;
c->decode_intra(c);
} else {
- c->pic.key_frame = 0;
- c->pic.pict_type = AV_PICTURE_TYPE_P;
+ frame->key_frame = 0;
+ frame->pict_type = AV_PICTURE_TYPE_P;
if (c->decomp_len)
c->decode_xor(c);
}
@@ -539,7 +534,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
uint8_t *out, *src;
int i, j;
- out = c->pic.data[0];
+ out = frame->data[0];
src = c->cur;
switch (c->fmt) {
case ZMBV_FMT_8BPP:
@@ -550,7 +545,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
out[i * 3 + 2] = c->pal[(*src) * 3 + 2];
src++;
}
- out += c->pic.linesize[0];
+ out += frame->linesize[0];
}
break;
case ZMBV_FMT_15BPP:
@@ -562,7 +557,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
out[i * 3 + 1] = (tmp & 0x03E0) >> 2;
out[i * 3 + 2] = (tmp & 0x001F) << 3;
}
- out += c->pic.linesize[0];
+ out += frame->linesize[0];
}
break;
case ZMBV_FMT_16BPP:
@@ -574,7 +569,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
out[i * 3 + 1] = (tmp & 0x07E0) >> 3;
out[i * 3 + 2] = (tmp & 0x001F) << 3;
}
- out += c->pic.linesize[0];
+ out += frame->linesize[0];
}
break;
#ifdef ZMBV_ENABLE_24BPP
@@ -582,7 +577,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
for (j = 0; j < c->height; j++) {
memcpy(out, src, c->width * 3);
src += c->width * 3;
- out += c->pic.linesize[0];
+ out += frame->linesize[0];
}
break;
#endif //ZMBV_ENABLE_24BPP
@@ -593,7 +588,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
src += 4;
AV_WB24(out+(i*3), tmp);
}
- out += c->pic.linesize[0];
+ out += frame->linesize[0];
}
break;
default:
@@ -602,7 +597,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
FFSWAP(uint8_t *, c->cur, c->prev);
}
*got_frame = 1;
- *(AVFrame*)data = c->pic;
/* always report that the buffer was completely consumed */
return buf_size;
@@ -653,8 +647,6 @@ static av_cold int decode_end(AVCodecContext *avctx)
av_freep(&c->decomp_buf);
- if (c->pic.data[0])
- avctx->release_buffer(avctx, &c->pic);
inflateEnd(&c->zstream);
av_freep(&c->cur);
av_freep(&c->prev);