[vorbis] problems loading an ogg to memory

Stan Seibert volsung at mailsnare.net
Wed Aug 27 16:16:38 PDT 2003



On Wed, 2003-08-27 at 18:03, Joel Gonzales wrote:
> I'm trying to load an entire ogg file into memory, but having some 
> problems trying to figure out how big the ogg file will be in 
> uncompressed form.  I've tried a couple diffrent ways but no luck.  I'm 
> basically just trying to load the uncompressed file into an array of 
> chars. Any help on this?

Take a look at the ov_pcm_total() function.  It will return the number
of PCM samples in the stream, which you can then multiply by the number
of channels and the sample size to get the number of bytes.  (Note that
when you decode with vorbisfile, you get to pick the sample size.  It
isn't an attribute of the stream like in a WAV file.)

One complication to consider for the general case is that Ogg streams
can be chained, and each link in the chain can have a different number
of channels potentially.  This would affect the calculation of the total
size, so you will have to iterate through the links individually to
count the number of bytes needed in total.


---
Stan Seibert

<p>--- >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