Kostya Shishkov <[email protected]> added the comment:

Another JPEG format abuse: ILV (aka Se) value is stored as 255 
instead of correct 63 thus causing next value misread.

This simple patch will fix first plane decoding (making ffmjpeg 
decode colour data is less trivial).

Index: libavcodec/mjpegdec.c
================================================================
===
--- libavcodec/mjpegdec.c       (revision 16921)
+++ libavcodec/mjpegdec.c       (working copy)
@@ -946,8 +946,13 @@
 
     predictor= get_bits(&s->gb, 8); /* JPEG Ss / lossless JPEG 
predictor /JPEG-LS NEAR */
     ilv= get_bits(&s->gb, 8);    /* JPEG Se / JPEG-LS ILV */
+    if(ilv != 255){
     prev_shift = get_bits(&s->gb, 4); /* Ah */
     point_transform= get_bits(&s->gb, 4); /* Al */
+    }else{
+    prev_shift = 0;
+    point_transform = 0;
+    }
 
     for(i=0;i<nb_components;i++)
         s->last_dc[i] = 1024;

____________________________________________________
FFmpeg issue tracker <[email protected]>
<https://roundup.ffmpeg.org/roundup/ffmpeg/issue777>
____________________________________________________

Reply via email to