summaryrefslogtreecommitdiffstats
path: root/libavcodec/mxpegdec.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/mxpegdec.c')
-rw-r--r--libavcodec/mxpegdec.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/libavcodec/mxpegdec.c b/libavcodec/mxpegdec.c
index 59d41b6..5b72d42 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);
}
@@ -168,7 +167,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;
@@ -249,9 +247,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);
}
@@ -270,7 +268,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);
}
@@ -294,8 +293,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];
@@ -319,10 +321,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);
OpenPOWER on IntegriCloud