diff options
author | anatoly <anatoly.nenashev@ovsoft.ru> | 2011-03-27 22:16:25 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-04-26 22:06:13 +0200 |
commit | dd1e5bfd5e402d3c455c3a349d6554bf07c88f92 (patch) | |
tree | e7ff29d47abadebc873d9f0a21d4f91db31dd8d0 | |
parent | 7e6a9e64447a300cdd067c5e1bd7e72806530134 (diff) | |
download | ffmpeg-dd1e5bfd5e402d3c455c3a349d6554bf07c88f92.tar.gz |
Add support for picture_ptr field in MJpegDecodeContext
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/mjpegbdec.c | 2 | ||||
-rw-r--r-- | libavcodec/mjpegdec.c | 31 | ||||
-rw-r--r-- | libavcodec/mjpegdec.h | 1 |
3 files changed, 20 insertions, 14 deletions
diff --git a/libavcodec/mjpegbdec.c b/libavcodec/mjpegbdec.c index fc045ba4df..5f863433ef 100644 --- a/libavcodec/mjpegbdec.c +++ b/libavcodec/mjpegbdec.c @@ -129,7 +129,7 @@ read_header: //XXX FIXME factorize, this looks very similar to the EOI code - *picture= s->picture; + *picture= *s->picture_ptr; *data_size = sizeof(AVFrame); if(!s->lossless){ diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index ca8dceb316..2fe2070cc0 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -34,6 +34,7 @@ #include <assert.h> #include "libavutil/imgutils.h" +#include "libavutil/avassert.h" #include "avcodec.h" #include "dsputil.h" #include "mjpeg.h" @@ -81,6 +82,9 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) { MJpegDecodeContext *s = avctx->priv_data; + if (!s->picture_ptr) + s->picture_ptr = &s->picture; + s->avctx = avctx; dsputil_init(&s->dsp, avctx); ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct); @@ -282,8 +286,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) s->height < ((s->org_height * 3) / 4)) { s->interlaced = 1; s->bottom_field = s->interlace_polarity; - s->picture.interlaced_frame = 1; - s->picture.top_field_first = !s->interlace_polarity; + s->picture_ptr->interlaced_frame = 1; + s->picture_ptr->top_field_first = !s->interlace_polarity; height *= 2; } @@ -342,20 +346,19 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) s->avctx->pix_fmt = PIX_FMT_GRAY16; } - if(s->picture.data[0]) - s->avctx->release_buffer(s->avctx, &s->picture); + if(s->picture_ptr->data[0]) + s->avctx->release_buffer(s->avctx, s->picture_ptr); - s->picture.reference= 0; - if(s->avctx->get_buffer(s->avctx, &s->picture) < 0){ + if(s->avctx->get_buffer(s->avctx, s->picture_ptr) < 0){ av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } - s->picture.pict_type= FF_I_TYPE; - s->picture.key_frame= 1; + s->picture_ptr->pict_type= FF_I_TYPE; + s->picture_ptr->key_frame= 1; s->got_picture = 1; for(i=0; i<3; i++){ - s->linesize[i]= s->picture.linesize[i] << s->interlaced; + s->linesize[i]= s->picture_ptr->linesize[i] << s->interlaced; } // printf("%d %d %d %d %d %d\n", s->width, s->height, s->linesize[0], s->linesize[1], s->interlaced, s->avctx->height); @@ -804,7 +807,7 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i } for(i=0; i < nb_components; i++) { int c = s->comp_index[i]; - data[c] = s->picture.data[c]; + data[c] = s->picture_ptr->data[c]; reference_data[c] = reference ? reference->data[c] : NULL; linesize[c]=s->linesize[c]; s->coefs_finished[c] |= 1; @@ -1017,6 +1020,7 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, skip_bits(&s->gb, 8); if(s->lossless){ + av_assert0(s->picture_ptr == &s->picture); if(CONFIG_JPEGLS_DECODER && s->ls){ // for(){ // reset_ls_coding_parameters(s, 0); @@ -1034,6 +1038,7 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, } }else{ if(s->progressive && predictor) { + av_assert0(s->picture_ptr == &s->picture); if(mjpeg_decode_scan_progressive_ac(s, predictor, ilv, prev_shift, point_transform) < 0) return -1; } else { @@ -1504,7 +1509,7 @@ eoi_parser: if (s->bottom_field == !s->interlace_polarity) goto not_the_end; } - *picture = s->picture; + *picture = *s->picture_ptr; *data_size = sizeof(AVFrame); if(!s->lossless){ @@ -1576,8 +1581,8 @@ av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx) MJpegDecodeContext *s = avctx->priv_data; int i, j; - if (s->picture.data[0]) - avctx->release_buffer(avctx, &s->picture); + if (s->picture_ptr && s->picture_ptr->data[0]) + avctx->release_buffer(avctx, s->picture_ptr); av_free(s->buffer); av_free(s->qscale_table); diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h index 9c78ab21ea..beefdb998c 100644 --- a/libavcodec/mjpegdec.h +++ b/libavcodec/mjpegdec.h @@ -81,6 +81,7 @@ typedef struct MJpegDecodeContext { int quant_index[4]; /* quant table index for each component */ int last_dc[MAX_COMPONENTS]; /* last DEQUANTIZED dc (XXX: am I right to do that ?) */ AVFrame picture; /* picture structure */ + AVFrame *picture_ptr; /* pointer to picture structure */ int got_picture; ///< we found a SOF and picture is valid, too. int linesize[MAX_COMPONENTS]; ///< linesize << interlaced int8_t *qscale_table; |