diff options
-rw-r--r-- | libavcodec/mjpegdec.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 81aa36ab17..f79eabe25b 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1051,9 +1051,6 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, prev_shift = get_bits(&s->gb, 4); /* Ah */ point_transform = get_bits(&s->gb, 4); /* Al */ - for (i = 0; i < nb_components; i++) - s->last_dc[i] = 1024; - if (nb_components > 1) { /* interleaved stream */ s->mb_width = (s->width + s->h_max * block_size - 1) / (s->h_max * block_size); @@ -1079,6 +1076,10 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, for (i = s->mjpb_skiptosod; i > 0; i--) skip_bits(&s->gb, 8); +next_field: + for (i = 0; i < nb_components; i++) + s->last_dc[i] = 1024; + if (s->lossless) { if (CONFIG_JPEGLS_DECODER && s->ls) { // for () { @@ -1113,6 +1114,22 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, return ret; } } + + if (s->interlaced && + get_bits_left(&s->gb) > 32 && + show_bits(&s->gb, 8) == 0xFF) { + GetBitContext bak = s->gb; + align_get_bits(&bak); + if (show_bits(&bak, 16) == 0xFFD1) { + av_dlog(s->avctx, "AVRn interlaced picture marker found\n"); + s->gb = bak; + skip_bits(&s->gb, 16); + s->bottom_field ^= 1; + + goto next_field; + } + } + emms_c(); return 0; out_of_range: |