avcodec/mjpegdec: Fix normal jpeg with bits < 8
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 5 Sep 2013 22:56:44 +0000 (00:56 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 5 Sep 2013 23:19:37 +0000 (01:19 +0200)
Untested due to lack of testcase

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/mjpegdec.c

index a1b7e8a..0d619ef 100644 (file)
@@ -1121,6 +1121,12 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah,
                                 return AVERROR_INVALIDDATA;
                             }
                             s->dsp.idct_put(ptr, linesize[c], s->block);
+                            if (s->bits & 7) {
+                                int block_x, block_y;
+                                    for (block_y=0; block_y<8; block_y++)
+                                        for (block_x=0; block_x<8; block_x++)
+                                            *(ptr + 2*block_x + block_y*linesize[c]) <<= 8 - s->bits;
+                            }
                         }
                     } else {
                         int block_idx  = s->block_stride[c] * (v * mb_y + y) +