[Vorbis-dev] [libvorbis] Bugfix: seek broken for large files and on pure 32 bit architectures
Marcel Müller
xiph-mueller at maazl.de
Sun Feb 8 08:35:30 PST 2009
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
More information about the Vorbis-dev
mailing list