summaryrefslogtreecommitdiff
path: root/libavcodec/mjpegbdec.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/mjpegbdec.c
parent6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff)
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/mjpegbdec.c')
-rw-r--r--libavcodec/mjpegbdec.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/libavcodec/mjpegbdec.c b/libavcodec/mjpegbdec.c
index 9d5a8f31ef..5edc0e4e24 100644
--- a/libavcodec/mjpegbdec.c
+++ b/libavcodec/mjpegbdec.c
@@ -45,10 +45,10 @@ static int mjpegb_decode_frame(AVCodecContext *avctx,
int buf_size = avpkt->size;
MJpegDecodeContext *s = avctx->priv_data;
const uint8_t *buf_end, *buf_ptr;
- AVFrame *picture = data;
GetBitContext hgb; /* for the header */
uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs;
uint32_t field_size, sod_offs;
+ int ret;
buf_ptr = buf;
buf_end = buf + buf_size;
@@ -136,17 +136,13 @@ read_header:
//XXX FIXME factorize, this looks very similar to the EOI code
- *picture= *s->picture_ptr;
+ if ((ret = av_frame_ref(data, s->picture_ptr)) < 0)
+ return ret;
*got_frame = 1;
- if(!s->lossless){
- picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]);
- picture->qstride= 0;
- picture->qscale_table= s->qscale_table;
- memset(picture->qscale_table, picture->quality, (s->width+15)/16);
- if(avctx->debug & FF_DEBUG_QP)
- av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality);
- picture->quality*= FF_QP2LAMBDA;
+ if (!s->lossless && avctx->debug & FF_DEBUG_QP) {
+ av_log(avctx, AV_LOG_DEBUG, "QP: %d\n",
+ FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]));
}
return buf_size;