}
s->picture.pict_type= FF_I_TYPE;
s->picture.key_frame= 1;
+ s->got_picture = 1;
for(i=0; i<3; i++){
s->linesize[i]= s->picture.linesize[i] << s->interlaced;
}
}
}
- /* (< 1350) buggy workaround for Spectralfan.mov, should be fixed */
- if (s->restart_interval && (s->restart_interval < 1350) &&
- !--s->restart_count) {
+
+ if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16); /* skip RSTn */
for (i=0; i<nb_components; i++) /* reset dc */
if (s->dc_index[i] < 0 || s->ac_index[i] < 0 ||
s->dc_index[i] >= 4 || s->ac_index[i] >= 4)
goto out_of_range;
-#if 0 //buggy
- switch(s->start_code)
- {
- case SOF0:
- if (dc_index[i] > 1 || ac_index[i] > 1)
- goto out_of_range;
- break;
- case SOF1:
- case SOF2:
- if (dc_index[i] > 3 || ac_index[i] > 3)
- goto out_of_range;
- break;
- case SOF3:
- if (dc_index[i] > 3 || ac_index[i] != 0)
- goto out_of_range;
- break;
- }
-#endif
+ if (!s->vlcs[0][s->dc_index[i]].table || !s->vlcs[1][s->ac_index[i]].table)
+ goto out_of_range;
}
predictor= get_bits(&s->gb, 8); /* JPEG Ss / lossless JPEG predictor /JPEG-LS NEAR */
}
val = -1;
found:
-#ifdef DEBUG
- av_log(NULL, AV_LOG_VERBOSE, "find_marker skipped %d bytes\n", skipped);
-#endif
+ dprintf(NULL, "find_marker skipped %d bytes\n", skipped);
*pbuf_ptr = buf_ptr;
return val;
}
int start_code;
AVFrame *picture = data;
+ s->got_picture = 0; // picture from previous image can not be reused
buf_ptr = buf;
buf_end = buf + buf_size;
while (buf_ptr < buf_end) {
}
break;
case SOF0:
+ case SOF1:
s->lossless=0;
s->ls=0;
s->progressive=0;
if ((s->buggy_avid && !s->interlaced) || s->restart_interval)
break;
eoi_parser:
+ if (!s->got_picture) {
+ av_log(avctx, AV_LOG_WARNING, "Found EOI before any SOF, ignoring\n");
+ break;
+ }
{
if (s->interlaced) {
s->bottom_field ^= 1;
}
break;
case SOS:
+ if (!s->got_picture) {
+ av_log(avctx, AV_LOG_WARNING, "Can not process SOS before SOF, skipping\n");
+ break;
+ }
ff_mjpeg_decode_sos(s);
/* buggy avid puts EOI every 10-20th frame */
/* if restart period is over process EOI */
case DRI:
mjpeg_decode_dri(s);
break;
- case SOF1:
case SOF5:
case SOF6:
case SOF7:
}
}
}
+ if (s->got_picture) {
+ av_log(avctx, AV_LOG_WARNING, "EOI missing, emulating\n");
+ goto eoi_parser;
+ }
+ av_log(avctx, AV_LOG_FATAL, "No JPEG data found in image\n");
+ return -1;
the_end:
av_log(avctx, AV_LOG_DEBUG, "mjpeg decode frame unused %td bytes\n", buf_end - buf_ptr);
// return buf_end - buf_ptr;
MJpegDecodeContext *s = avctx->priv_data;
int i, j;
+ if (s->picture.data[0])
+ avctx->release_buffer(avctx, &s->picture);
+
av_free(s->buffer);
av_free(s->qscale_table);