[FFmpeg-cvslog] wav: Always seek to an even offset

Luca Barbato git at videolan.org
Sun May 12 14:35:55 CEST 2013


ffmpeg | branch: release/1.1 | Luca Barbato <lu_zero at gentoo.org> | Sat May  4 12:18:57 2013 +0200| [52ab9e898485b370a4da46febb91e1ba50a1c357] | committer: Reinhard Tartler

wav: Always seek to an even offset

RIFF chunks are aligned to 16bit according to the specification.

Bug-Id:500
CC:libav-stable at libav.org
(cherry picked from commit ac87eaf856e0fb51917266b899bb15d19b907baf)

Signed-off-by: Reinhard Tartler <siretart at tauware.de>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=52ab9e898485b370a4da46febb91e1ba50a1c357
---

 libavformat/wavdec.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index c9f7abb..e9dda92 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -50,6 +50,12 @@ static int64_t next_tag(AVIOContext *pb, uint32_t *tag)
     return avio_rl32(pb);
 }
 
+/* RIFF chunks are always on a even offset. */
+static int64_t wav_seek_tag(AVIOContext *s, int64_t offset, int whence)
+{
+    return avio_seek(s, offset + (offset & 1), whence);
+}
+
 /* return the size of the found tag */
 static int64_t find_tag(AVIOContext *pb, uint32_t tag1)
 {
@@ -62,7 +68,7 @@ static int64_t find_tag(AVIOContext *pb, uint32_t tag1)
         size = next_tag(pb, &tag);
         if (tag == tag1)
             break;
-        avio_skip(pb, size);
+        wav_seek_tag(pb, size, SEEK_CUR);
     }
     return size;
 }
@@ -301,7 +307,7 @@ static int wav_read_header(AVFormatContext *s)
 
         /* seek to next tag unless we know that we'll run into EOF */
         if ((avio_size(pb) > 0 && next_tag_ofs >= avio_size(pb)) ||
-            avio_seek(pb, next_tag_ofs, SEEK_SET) < 0) {
+            wav_seek_tag(pb, next_tag_ofs, SEEK_SET) < 0) {
             break;
         }
     }



More information about the ffmpeg-cvslog mailing list