s->avctx->sample_aspect_ratio.num,
s->avctx->sample_aspect_ratio.den);
- t_w = get_bits(&s->gb, 8);
- t_h = get_bits(&s->gb, 8);
- if (t_w && t_h) {
- /* skip thumbnail */
- if (len -10 - (t_w * t_h * 3) > 0)
- len -= t_w * t_h * 3;
+ len -= 8;
+ if (len >= 2) {
+ t_w = get_bits(&s->gb, 8);
+ t_h = get_bits(&s->gb, 8);
+ if (t_w && t_h) {
+ /* skip thumbnail */
+ if (len -10 - (t_w * t_h * 3) > 0)
+ len -= t_w * t_h * 3;
+ }
+ len -= 2;
}
- len -= 10;
goto out;
}
ret = mjpeg_decode_com(s);
if (ret < 0)
return ret;
+ } else if (start_code == DQT) {
+ ff_mjpeg_decode_dqt(s);
}
ret = -1;
s->restart_count = 0;
/* nothing to do on SOI */
break;
- case DQT:
- ff_mjpeg_decode_dqt(s);
- break;
case DHT:
if ((ret = ff_mjpeg_decode_dht(s)) < 0) {
av_log(avctx, AV_LOG_ERROR, "huffman table decode error\n");