[vorbis-dev] Uncompressed size in bytes
Michael Smith
msmith at xiph.org
Tue Jul 29 17:47:27 PDT 2003
On Wednesday 30 July 2003 07:43, Andrew Csikvari wrote:
> Hi!
>
> I would like to decompress an ogg vorbis file from the memory to the
> memory.
> I wrote my own callbacks for it (Why isn't there callback functions for
> it? Just for void* data, and a size_t size).
Not sure what you mean here - there ARE callbacks for everything neccesary.
> Now I can read the ogg file from the memory but I don't know the total
> size of the uncompressed data (I would like to decompress the data at
> once).
> How can I get the bitstream decompressed size?
>
> Another question:
> The sample bits are always 16?
> The ov_read can handle 8 bit samples (one of it's parameters), but where
> can I see whether the ogg file contains 8 or 16 bit samples?
>
As others described, sample size is an application choice, not a bitstream
parameter. 16 bit is probably appropriate for you to use always.
Then the total size (assuming a seekable input, so your callbacks must
implement seeking for this to work) of the decompressed audio is:
ogg_int64_t total_size = 0;
for(i=0; i < ov_streams(&vf); i++) {
total_size += ov_info(&vf, i)->channels * ov_pcm_total(&vf, i);
}
But note that since the number of channels can vary between different streams
in the file, this won't directly give you anything particularly useful. You
probably only want to decode one stream at a time, perhaps the first one:
total_size = ov_info(&vf, 0)->channels * ov_pcm_total(&vf, i);
Mike
--- >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