[libvorbis] Bugfix: seek broken for large files and on pure 32 bit architectures

Marcel Müller <[email protected]>
Newsgroups gmane.comp.multimedia.ogg.vorbis.devel
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.