[Ffmpeg-devel] Incorrect JPEG decoding with patch

Kostya kostya.shishkov
Mon Nov 20 06:51:15 CET 2006


On Fri, Nov 17, 2006 at 07:34:34PM +0100, Michael Niedermayer wrote:
> Hi
> 
[...]
> 
> can the normal mjpeg_decode_scan() with nb_components=1 instead of 3 not
> be used?

Yes

> 
> > +
> > +
> >  static int mjpeg_decode_sos(MJpegDecodeContext *s)
> >  {
> >      int len, nb_components, i, h, v, predictor, point_transform;
> [...]
> >      /* XXX: only interleaved scan accepted */
> >      if ((nb_components != s->nb_components) && !s->ls)
> >      {
> > -        dprintf("decode_sos: components(%d) mismatch\n", nb_components);
> > -        return -1;
> > +        dprintf("decode_sos: multiple scan detected, id of current ");
> > +        /* return -1; */
> 
> if something is wrong remove it, dont comment it out
> 
[...]

Here is my variant for this.
I had to replace {h,v}_scount[s->comp_index[0]] with {h,v}_scount[0] because with
this JPEGs s->comp_index[0] == plane index and referenced value is zero.
It may fail with JPEGs with non-standard plane indexes (i.e. 3,4,5) but I suppose
that is very exotic case.

> [...]
> 
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> In the past you could go to a library and read, borrow or copy any book
> Today you'd get arrested for mere telling someone where the library is
> 
-------------- next part --------------
--- mjpeg.c.svn	2006-11-19 18:01:36.000000000 +0200
+++ mjpeg.c	2006-11-19 18:42:13.000000000 +0200
@@ -1643,12 +1643,6 @@
         dprintf("decode_sos: invalid len (%d)\n", len);
         return -1;
     }
-    /* XXX: only interleaved scan accepted */
-    if ((nb_components != s->nb_components) && !s->ls && !s->progressive)
-    {
-        dprintf("decode_sos: components(%d) mismatch\n", nb_components);
-        return -1;
-    }
     vmax = 0;
     hmax = 0;
     for(i=0;i<nb_components;i++) {
@@ -1709,8 +1703,8 @@
         s->mb_width  = (s->width  + s->h_max * block_size - 1) / (s->h_max * block_size);
         s->mb_height = (s->height + s->v_max * block_size - 1) / (s->v_max * block_size);
     } else if(!s->ls) { /* skip this for JPEG-LS */
-        h = s->h_max / s->h_scount[s->comp_index[0]];
-        v = s->v_max / s->v_scount[s->comp_index[0]];
+        h = s->h_max / s->h_scount[0];
+        v = s->v_max / s->v_scount[0];
         s->mb_width  = (s->width  + h * block_size - 1) / (h * block_size);
         s->mb_height = (s->height + v * block_size - 1) / (v * block_size);
         s->nb_blocks[0] = 1;



More information about the ffmpeg-devel mailing list