|
@@ -34,6 +34,7 @@
|
|
#include <assert.h>
|
|
#include <assert.h>
|
|
|
|
|
|
#include "libavutil/imgutils.h"
|
|
#include "libavutil/imgutils.h"
|
|
|
|
+#include "libavutil/avassert.h"
|
|
#include "avcodec.h"
|
|
#include "avcodec.h"
|
|
#include "dsputil.h"
|
|
#include "dsputil.h"
|
|
#include "mjpeg.h"
|
|
#include "mjpeg.h"
|
|
@@ -81,6 +82,9 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
|
|
{
|
|
{
|
|
MJpegDecodeContext *s = avctx->priv_data;
|
|
MJpegDecodeContext *s = avctx->priv_data;
|
|
|
|
|
|
|
|
+ if (!s->picture_ptr)
|
|
|
|
+ s->picture_ptr = &s->picture;
|
|
|
|
+
|
|
s->avctx = avctx;
|
|
s->avctx = avctx;
|
|
dsputil_init(&s->dsp, avctx);
|
|
dsputil_init(&s->dsp, avctx);
|
|
ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
|
|
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->height < ((s->org_height * 3) / 4)) {
|
|
s->interlaced = 1;
|
|
s->interlaced = 1;
|
|
s->bottom_field = s->interlace_polarity;
|
|
s->bottom_field = s->interlace_polarity;
|
|
- s->picture.interlaced_frame = 1;
|
|
+ s->picture_ptr->interlaced_frame = 1;
|
|
- s->picture.top_field_first = !s->interlace_polarity;
|
|
+ s->picture_ptr->top_field_first = !s->interlace_polarity;
|
|
height *= 2;
|
|
height *= 2;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -342,20 +346,19 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
|
|
s->avctx->pix_fmt = PIX_FMT_GRAY16;
|
|
s->avctx->pix_fmt = PIX_FMT_GRAY16;
|
|
}
|
|
}
|
|
|
|
|
|
- if(s->picture.data[0])
|
|
+ if(s->picture_ptr->data[0])
|
|
- s->avctx->release_buffer(s->avctx, &s->picture);
|
|
+ s->avctx->release_buffer(s->avctx, s->picture_ptr);
|
|
|
|
|
|
- s->picture.reference= 0;
|
|
+ if(s->avctx->get_buffer(s->avctx, s->picture_ptr) < 0){
|
|
- if(s->avctx->get_buffer(s->avctx, &s->picture) < 0){
|
|
|
|
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
|
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
- s->picture.pict_type= FF_I_TYPE;
|
|
+ s->picture_ptr->pict_type= FF_I_TYPE;
|
|
- s->picture.key_frame= 1;
|
|
+ s->picture_ptr->key_frame= 1;
|
|
s->got_picture = 1;
|
|
s->got_picture = 1;
|
|
|
|
|
|
for(i=0; i<3; i++){
|
|
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;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -804,7 +807,7 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i
|
|
}
|
|
}
|
|
for(i=0; i < nb_components; i++) {
|
|
for(i=0; i < nb_components; i++) {
|
|
int c = s->comp_index[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;
|
|
reference_data[c] = reference ? reference->data[c] : NULL;
|
|
linesize[c]=s->linesize[c];
|
|
linesize[c]=s->linesize[c];
|
|
s->coefs_finished[c] |= 1;
|
|
s->coefs_finished[c] |= 1;
|
|
@@ -1017,6 +1020,7 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s,
|
|
skip_bits(&s->gb, 8);
|
|
skip_bits(&s->gb, 8);
|
|
|
|
|
|
if(s->lossless){
|
|
if(s->lossless){
|
|
|
|
+ av_assert0(s->picture_ptr == &s->picture);
|
|
if(CONFIG_JPEGLS_DECODER && s->ls){
|
|
if(CONFIG_JPEGLS_DECODER && s->ls){
|
|
|
|
|
|
|
|
|
|
@@ -1034,6 +1038,7 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s,
|
|
}
|
|
}
|
|
}else{
|
|
}else{
|
|
if(s->progressive && predictor) {
|
|
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)
|
|
if(mjpeg_decode_scan_progressive_ac(s, predictor, ilv, prev_shift, point_transform) < 0)
|
|
return -1;
|
|
return -1;
|
|
} else {
|
|
} else {
|
|
@@ -1504,7 +1509,7 @@ eoi_parser:
|
|
if (s->bottom_field == !s->interlace_polarity)
|
|
if (s->bottom_field == !s->interlace_polarity)
|
|
goto not_the_end;
|
|
goto not_the_end;
|
|
}
|
|
}
|
|
- *picture = s->picture;
|
|
+ *picture = *s->picture_ptr;
|
|
*data_size = sizeof(AVFrame);
|
|
*data_size = sizeof(AVFrame);
|
|
|
|
|
|
if(!s->lossless){
|
|
if(!s->lossless){
|
|
@@ -1576,8 +1581,8 @@ av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
|
|
MJpegDecodeContext *s = avctx->priv_data;
|
|
MJpegDecodeContext *s = avctx->priv_data;
|
|
int i, j;
|
|
int i, j;
|
|
|
|
|
|
- if (s->picture.data[0])
|
|
+ if (s->picture_ptr && s->picture_ptr->data[0])
|
|
- avctx->release_buffer(avctx, &s->picture);
|
|
+ avctx->release_buffer(avctx, s->picture_ptr);
|
|
|
|
|
|
av_free(s->buffer);
|
|
av_free(s->buffer);
|
|
av_free(s->qscale_table);
|
|
av_free(s->qscale_table);
|