Marcel Müller
2009-Feb-08 16:35 UTC
[Vorbis-dev] [libvorbis] Bugfix: seek broken for large files and on pure 32 bit architectures
In file vorbisfile.c, function int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos) the calculation of the approximate seek point causes an overflow for very large files and on pure 32 bit architectures. /* take a (pretty decent) guess. */ bisect=begin + (target-begintime)*(end-begin)/(endtime-begintime) - CHUNKSIZE; The temporary expression (target-begintime)*(end-begin) grows with the square of the file size. This effectively limits the file size to the square root of the maximum value of ogg_int64_t. In consequence the file is scanned from the very beginning which is pretty slow over a network. FIX: bisect=begin + (ogg_int64_t)((double)(target-begintime)*(end-begin)/(endtime-begintime)) - CHUNKSIZE; Since it is an approximation anyway, the calculation should be done using floating point arithmetics. Marcel
Erik de Castro Lopo
2009-Mar-02 21:14 UTC
[Vorbis-dev] [libvorbis] Bugfix: seek broken for large files and on pure 32 bit architectures
Hi all, This has been sitting here for a while. Anyone see any obvious prblems with this? If not, I will test it and commit it if it seems to work ok. Cheers, Erik Marcel M?ller wrote:> In file vorbisfile.c, function > > int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos) > > the calculation of the approximate seek point causes an overflow for > very large files and on pure 32 bit architectures. > > /* take a (pretty decent) guess. */ > bisect=begin + > (target-begintime)*(end-begin)/(endtime-begintime) - CHUNKSIZE; > > The temporary expression (target-begintime)*(end-begin) grows with the > square of the file size. This effectively limits the file size to the > square root of the maximum value of ogg_int64_t. In consequence the file > is scanned from the very beginning which is pretty slow over a network. > > > FIX: > > bisect=begin + > (ogg_int64_t)((double)(target-begintime)*(end-begin)/(endtime-begintime)) > - CHUNKSIZE; > > Since it is an approximation anyway, the calculation should be done > using floating point arithmetics. > > > Marcel > > _______________________________________________ > Vorbis-dev mailing list > Vorbis-dev at xiph.org > http://lists.xiph.org/mailman/listinfo/vorbis-dev-- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- Everything that I've learned about computers I have boiled down into three principles: PC/Windows: You think it won't work, and it won't. Macintosh: You think it will work, but it won't. Unix: You think it won't work, but if you find the right guru, you can make it work.