[Vorbis-dev] A few questions about libvorbis from a newbie

Hiroka IHARA ihara_h at live.jp
Fri Dec 4 01:29:24 PST 2015


Hello Martin,

> how a number of samples with no defined size is translated into 8, 16, or 32 bit values in my buffer
Although I do not know in detail about the actual implementation of libvorbis, most of the decoders should internally produce single-precision (32bit) floating point values, or 32bit integers as the result of PCM decoding.
They are downcast to PCM samples with 8bit, 16bit, or whatever precision you designate.
(So it is easily predicted that there is no point in extracting PCM audio with incongruously high precision from a stream with lower bitrates.)

> does the pcm total only account for one channel? How are channels represented in the file?
Vorbis encoders usually create a group of audio channels whose spectral characteristics linearly correlate to each other.
These groups are called "maps", and all the channels in a map must have the same number of samples within a block.
Therefore, as long as your Vorbis file utilizes the usual multichannel mapping, all channels should have the same number of samples thoughout the stream.
(Of course if you encode each channel as an independent Ogg stream, which I think is extremely rare, the sample size would differ from channel to channel.)
For your first question, the answer is yes because the absolute granule position of the Ogg/Vorbis packet (I misspelled the word in the previous reply as "absolute granularity", sorry) is designed so.

> Also, Is ov_read generating different amounts of data based on the word parameter?
Yes, as I mentioned earlier, the internal representation of PCM audio is downcast to arbitrary precision at that time.

I must apologize that I gave a false explanation about how the total number of samples is calculated from blocksizes.
It should be HALF the sum of blocksizes through the stream, due to overlap-add process in MDCT.

I hope my answers would help, please excuse me if I made some mistakes regarding English.

Regards,
Hiroka
--
Hiroka Ihara
Department of Information and Communication Engineering, the University of Tokyo
PC: ihara_h at live.jp

From: Blake Martin [mailto:blakemartin.official at gmail.com] 
Sent: Friday, December 04, 2015 5:43 PM
To: Hiroka IHARA <ihara_h at live.jp>
Cc: vorbis-dev at xiph.org
Subject: Re: [Vorbis-dev] A few questions about libvorbis from a newbie

Okay, I understand how the number of samples varies and is calculated now. I still do not understand, however, how a number of samples with no defined size is translated into 8, 16, or 32 bit values in my buffer or how channels relate to the pcm total. Specifically, does the pcm total only account for one channel? How are channels represented in the file?
Also, Is ov_read generating different amounts of data based on the word parameter? I can't think of any other reason why my calculation for a reasonable uncompressed buffer size is ov_pcm_total * numChannels * (the word size I pass to ov_read).
Thanks in advance,
Blake


More information about the Vorbis-dev mailing list