[vorbis] decompressed size ?

Michael Smith msmith at xn.com.au
Thu Feb 1 17:53:18 PST 2001



charlie wallace wrote:
> 
> whats the best way to determine the size of the decompressed data ?
> so if i wanted to preallocate a buffer that would contain the whole
> decompressed sound how would i determine this ?

Assuming you're using vorbisfile (if not, it's complex. See how
vorbisfile does this), then this should do:
  int64 len = ov_pcm_total(&vf, -1);
  len *= ov_info(&vf, -1)->channels;
  len *= sample_size_in_bytes;

Replace int64 with an appropriate 64 bit integer type for your platform,
and replace sample_size_in_bytes with whatever you want (it'll usually
be 2 bytes - 16 bit sound. Vorbis doesn't care, though. vorbisfile lets
you use 1 or 2 (8 or 16 bit sound).

Michael

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis mailing list