Re: [AD] patch for the FLC reader

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On mar, dic 02, 2003 at 04:39:05 +0100, Eric Botcazou wrote:
> > but this alignment byte IS COUNTED in the frame size, that is why
> > the Allegro player (after an odd chunk) works anyway (because jump
> > the frame size that contains that extra byte).
> 
> Do you mean that it skips the remaining chunks in the frame, after an 
> odd-sized chunk has been encountered?

More or less, Allegro doesn't skip the chunks, Allegro tries to read
the next chunk, but fails because uses the alignment byte (=0) to read
the chunk size and then the chunk type (in this instance we could get
any error (an invalid chunk type or a valid chunk type with erroneous
data)).

> Your patch makes sense (and it has a visible effect on the
> testcases, thanks for providing them) so I'll apply on both
> branches.  However, don't you need to additionally decrement
> 'frame_size' for an odd-sized chunk?  And does this mean that the
> following lines
> 
>       if (c == frame_header.chunks-1)
> 	 sz += frame_size;
> 
> would be obsoleted?

Yes, you're right, they're obsolete, also, those lines are a bad
implementation because we can't add more size to a chunk when it
doesn't need it.

About the decrement, I didn't see before, but it's important, because
the "_fli_parse_chunk" routine makes some checks with it.  At the end,
the patch should be:

@@ -770,9 +770,6 @@
       sz = chunk.size - sizeof_FLI_CHUNK;
       frame_size -= chunk.size;
 
-      if (c == frame_header.chunks-1)
-	 sz += frame_size;
-
       switch (chunk.type) {
 
 	 case 4: 
@@ -809,6 +806,12 @@
       }
 
       p += sz;
+
+      /* alignment */
+      if (sz & 1) {
+	 p++;
+	 frame_size--;
+      }
    }
 
    /* move on to the next frame */





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/