[vorbis-dev] Finding size of decoded data

Michael Smith msmith at labyrinth.net.au
Tue Oct 22 02:53:32 PDT 2002



At 05:19 AM 10/22/02 -0400, you wrote:
>Hi all,
>
>This is a newbie question, but I can't seem to find an answer to it.
>
>I want to know if it's possible to find out, or compute, the total PCM decoded
>size of a coded vorbis sound file.
>
>What I'm trying to do is decode all data to a buffer, but I don't know how
>to allocate the buffer. Worst case I could do some kind of smaller buffer
>list, but I would prefer not to, as it would degrade performance.

If you're using libvorbisfile (if you aren't, you probably should):
  length = ov_pcm_total(&vf, 0);
  length_in_bytes = length * ov_info(&vf, 0) * 2;

This assumes: a) you're decoding to 16 bit samples, and b) you're only
interested in the first logical stream (stream 0).
Otherwise, you can loop over the n streams, for n = ov_streams(&vf), and
calculate the length for each segment in the same way.

Mike

<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-dev-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-dev mailing list