# HG changeset patch # User voroshil # Date 1192297138 0 # Node ID e0a872dd3ea14f57ea6d77639ef85f958e5b209f # Parent ced30500e2b18b509b1add57ba8082e46556efb2 Fix MJPEG decoder for AMV files. Since decoding is doing from the end and aligned by 16 previous code worked correctly only when picture height was dividable by 16, otherwise it provides garbage in top lines and truncates bottom. New code adjusts data[] pointers taking in account alignment issue. diff -r ced30500e2b1 -r e0a872dd3ea1 mjpegdec.c --- a/mjpegdec.c Sat Oct 13 12:25:31 2007 +0000 +++ b/mjpegdec.c Sat Oct 13 17:38:58 2007 +0000 @@ -671,7 +671,8 @@ linesize[c]=s->linesize[c]; if(s->avctx->codec->id==CODEC_ID_AMV) { //picture should be flipped upside-down for this codec - data[c] += (linesize[c] * (s->v_scount[i] * 8 * s->mb_height - 1)); + assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE)); + data[c] += (linesize[c] * (s->v_scount[i] * (8 * s->mb_height -((s->height/s->v_max)&7)) - 1 )); linesize[c] *= -1; } } diff -r ced30500e2b1 -r e0a872dd3ea1 sp5xdec.c --- a/sp5xdec.c Sat Oct 13 12:25:31 2007 +0000 +++ b/sp5xdec.c Sat Oct 13 17:38:58 2007 +0000 @@ -87,6 +87,7 @@ recoded[j++] = 0xFF; recoded[j++] = 0xD9; + avctx->flags &= ~CODEC_FLAG_EMU_EDGE; i = ff_mjpeg_decode_frame(avctx, data, data_size, recoded, j); av_free(recoded); @@ -207,6 +208,5 @@ ff_mjpeg_decode_init, NULL, ff_mjpeg_decode_end, - sp5x_decode_frame, - CODEC_CAP_DR1 + sp5x_decode_frame };