aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-08-10 15:47:07 +0200
committerLuca Barbato <lu_zero@gentoo.org>2012-08-22 17:44:43 +0200
commitac330161584b69c766d955d6ee3ee045cca31030 (patch)
tree8720057e127f23317988c9709b69c5aa662cc9ad
parent5b170c0bea06c5556fe5a74f436c46a88e69e8fc (diff)
downloadffmpeg-ac330161584b69c766d955d6ee3ee045cca31030.tar.gz
mjpegdec: support AVRn interlaced
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r--libavcodec/mjpegdec.c23
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: