diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-11-21 21:34:46 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-03-08 07:38:30 +0100 |
commit | 759001c534287a96dc96d1e274665feb7059145d (patch) | |
tree | 6ace9560c20aa30db92067c5b45d7bd86e458d10 /libavcodec/mxpegdec.c | |
parent | 6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff) | |
download | ffmpeg-759001c534287a96dc96d1e274665feb7059145d.tar.gz |
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/mxpegdec.c')
-rw-r--r-- | libavcodec/mxpegdec.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/libavcodec/mxpegdec.c b/libavcodec/mxpegdec.c index d81e9fc853..68c06c2cd9 100644 --- a/libavcodec/mxpegdec.c +++ b/libavcodec/mxpegdec.c @@ -46,7 +46,6 @@ static av_cold int mxpeg_decode_init(AVCodecContext *avctx) { MXpegDecodeContext *s = avctx->priv_data; - s->picture[0].reference = s->picture[1].reference = 3; s->jpg.picture_ptr = &s->picture[0]; return ff_mjpeg_decode_init(avctx); } @@ -167,7 +166,6 @@ static int mxpeg_decode_frame(AVCodecContext *avctx, const uint8_t *unescaped_buf_ptr; int unescaped_buf_size; int start_code; - AVFrame *picture = data; int ret; buf_ptr = buf; @@ -248,9 +246,9 @@ static int mxpeg_decode_frame(AVCodecContext *avctx, break; } /* use stored SOF data to allocate current picture */ - if (jpg->picture_ptr->data[0]) - avctx->release_buffer(avctx, jpg->picture_ptr); - if (ff_get_buffer(avctx, jpg->picture_ptr) < 0) { + av_frame_unref(jpg->picture_ptr); + if (ff_get_buffer(avctx, jpg->picture_ptr, + AV_GET_BUFFER_FLAG_REF) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return AVERROR(ENOMEM); } @@ -269,7 +267,8 @@ static int mxpeg_decode_frame(AVCodecContext *avctx, /* allocate dummy reference picture if needed */ if (!reference_ptr->data[0] && - ff_get_buffer(avctx, reference_ptr) < 0) { + ff_get_buffer(avctx, reference_ptr, + AV_GET_BUFFER_FLAG_REF) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return AVERROR(ENOMEM); } @@ -293,8 +292,11 @@ static int mxpeg_decode_frame(AVCodecContext *avctx, the_end: if (jpg->got_picture) { + int ret = av_frame_ref(data, jpg->picture_ptr); + if (ret < 0) + return ret; *got_frame = 1; - *picture = *jpg->picture_ptr; + s->picture_index ^= 1; jpg->picture_ptr = &s->picture[s->picture_index]; @@ -318,10 +320,8 @@ static av_cold int mxpeg_decode_end(AVCodecContext *avctx) jpg->picture_ptr = NULL; ff_mjpeg_decode_end(avctx); - for (i = 0; i < 2; ++i) { - if (s->picture[i].data[0]) - avctx->release_buffer(avctx, &s->picture[i]); - } + for (i = 0; i < 2; ++i) + av_frame_unref(&s->picture[i]); av_freep(&s->mxm_bitmask); av_freep(&s->completion_bitmask); |