s->picture[0] = av_frame_alloc();
s->picture[1] = av_frame_alloc();
- if (!s->picture[0] || !s->picture[1]) {
- mxpeg_decode_end(avctx);
+ if (!s->picture[0] || !s->picture[1])
return AVERROR(ENOMEM);
- }
s->jpg.picture_ptr = s->picture[0];
return ff_mjpeg_decode_init(avctx);
buf_end = buf + buf_size;
jpg->got_picture = 0;
s->got_mxm_bitmask = 0;
+ jpg->seen_sof = s->got_sof_data = !!s->got_sof_data;
while (buf_ptr < buf_end) {
start_code = ff_mjpeg_find_marker(jpg, &buf_ptr, buf_end,
&unescaped_buf_ptr, &unescaped_buf_size);
return ret;
break;
case SOF0:
- s->got_sof_data = 0;
+ if (s->got_sof_data > 1) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Multiple SOF in a frame\n");
+ return AVERROR_INVALIDDATA;
+ }
ret = ff_mjpeg_decode_sof(jpg);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR,
"SOF data decode error\n");
+ s->got_sof_data = 0;
return ret;
}
if (jpg->interlaced) {
av_log(avctx, AV_LOG_ERROR,
"Interlaced mode not supported in MxPEG\n");
+ s->got_sof_data = 0;
return AVERROR(EINVAL);
}
- s->got_sof_data = 1;
+ s->got_sof_data ++;
break;
case SOS:
if (!s->got_sof_data) {
return buf_ptr - buf;
}
-AVCodec ff_mxpeg_decoder = {
+const AVCodec ff_mxpeg_decoder = {
.name = "mxpeg",
.long_name = NULL_IF_CONFIG_SMALL("Mobotix MxPEG video"),
.type = AVMEDIA_TYPE_VIDEO,
.decode = mxpeg_decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
.max_lowres = 3,
- .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
};