]> git.nihav.org Git - nihav.git/commitdiff
AVI: align parsed chunks
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 4 Jun 2017 12:38:24 +0000 (14:38 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 4 Jun 2017 12:38:24 +0000 (14:38 +0200)
src/demuxers/avi.rs

index 56cf023e50309c71f71ae2863ae9b1d09e82e106..2a3f8f0bb49fc3f84680c7002d4139b5794b1386 100644 (file)
@@ -148,6 +148,7 @@ impl<'a> AVIDemuxer<'a> {
             if RIFFTag::Chunk(tag) == CHUNKS[i].tag {
                 let psize = (CHUNKS[i].parse)(self, size)?;
                 if psize != size { return Err(InvalidData); }
+                if (psize & 1) == 1 { self.src.read_skip(1)?; }
                 return Ok((size + 8, false));
             }
             if RIFFTag::List(tag, ltag) == CHUNKS[i].tag {
@@ -159,12 +160,18 @@ impl<'a> AVIDemuxer<'a> {
                     let (psize, _) = self.parse_chunk(end_tag, rest_size, depth+1)?;
                     if psize > rest_size { return Err(InvalidData); }
                     rest_size -= psize;
+                    if (psize & 1) == 1 {
+                        if rest_size > 0 {
+                            rest_size -= 1;
+                        }
+                    }
                 }
 
                 return Ok((size + 8, false));
             }
         }
         self.src.read_skip(size)?;
+        if (size & 1) == 1 { self.src.read_skip(1)?; }
         return Ok((size + 8, false));
     }