aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/wav.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-05-04 12:18:57 +0200
committerReinhard Tartler <siretart@tauware.de>2013-05-07 07:15:26 +0200
commit31ed79af7f47e64ed723321ba264cd1778d225a5 (patch)
treeaca6e8e9f1542e0fd75701bc3da89d6fb4be65d1 /libavformat/wav.c
parentf4bb72d33db2f12a3b4666c6843479d718ceecaf (diff)
downloadffmpeg-31ed79af7f47e64ed723321ba264cd1778d225a5.tar.gz
wav: Always seek to an even offset
RIFF chunks are aligned to 16bit according to the specification. Bug-Id:500 CC:libav-stable@libav.org (cherry picked from commit ac87eaf856e0fb51917266b899bb15d19b907baf) Signed-off-by: Reinhard Tartler <siretart@tauware.de>
Diffstat (limited to 'libavformat/wav.c')
-rw-r--r--libavformat/wav.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libavformat/wav.c b/libavformat/wav.c
index b873166b10..7539ce0506 100644
--- a/libavformat/wav.c
+++ b/libavformat/wav.c
@@ -230,6 +230,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)
{
@@ -242,7 +248,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;
}
@@ -483,7 +489,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;
}
}