xiph / vorbis

Reference implementation of the Ogg Vorbis audio format.
BSD 3-Clause "New" or "Revised" License
467 stars 188 forks source link

[Vorbisfile] Incorrect offsets and broken tell/seek function #60

Open Zuzu-Typ opened 4 years ago

Zuzu-Typ commented 4 years ago

Using vorbis 1.3.6, when trying to decode an example Ogg-Vorbis file from Wikipedia, it always starts reading at an offset (of 11968 samples or 0.27138321995464854s respectively). Setting this offset to 0 using ov_pcm_seek(), it still reads from said offset, even though ov_pcm_tell() still returns 0.

When trying to read samples after seeking to 0, the tell position suddenly jumps:

0...
1024...
2048...
3072...
4096...
5120...
6144...
7168...
8192...
9216...
22208 ; what??

Although you might not see it at first glance, but the tell function was lying to you all along. We're reading 10 x 1024 samples, or 10240 total samples. If you add those to the initial offset of 11968, you get (surprise) 22208. So seek didn't do it's job and neither did tell.

The data is also read from the offset and not the beginning of the file.

Whatever I tried, I could not get vorbisfile to decode the first part of the file for some reason. It's not broken either - I could open it with Audacity, VLC, Groove, etc.

I've also tried both ov_read and ov_read_float.