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

Hiroka IHARA ihara_h at live.jp
Thu Dec 3 23:28:37 PST 2015


I am deeply sorry about the corrupt message just being sent; there seems to have been a compatibility issue with my mailer and my browser.
This is an identical copy of the previous message:

Hello Martin,

Vorbis encoders are lossy, which is in a sense equivalent to converting the sample size of the raw PCM stream into something that would result in the desired bitrate.
The "sample size" of the compressed audio varies over time (this is related to VBR algorithm), and as Ian has pointed out, the notion of fixed sample size is meaningless.
Instead, the Vorbis codec packs the audio samples block by block, where a block consists of a fixed number of samples (e.g. 4096 samples per block when audio information is sparse, or 256 samples per block when dense).
So when the decoder fetches a block from the Ogg stream, it can determine the number of samples inside it just by reading the "blocksize" flag in the block header (thus you can calculate pcmtotal as the sum of blocksizes).

However, libvorbis uses a different approach to calculate pcmtotal.
It is dictated in the Vorbis I spec that all encoders must populate the absolute granularity field (I recall this field is left for implementation-defined use) of each Ogg packet with "the total number of PCM samples between the head of the audio stream and the end of the packet". 
libvorbis makes use of this information to seek through the audio, and to provide information about the uncompressed PCM position, without actually decoding the Vorbis packet enclosed in the Ogg stream.

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

From: vorbis-dev-bounces at xiph.org [mailto:vorbis-dev-bounces at xiph.org] On Behalf Of Blake Martin
Sent: Friday, December 04, 2015 2:10 PM
To: vorbis-dev at xiph.org
Subject: [Vorbis-dev] A few questions about libvorbis from a newbie

Sorry about the personal reply Ian. I hope keeping the subject the same is the way to reply to the list (I have never used a mailing list before).
The last thing I am not grasping is how pcm_total works without a concept of sample size?
If the sample size is whatever I decide to read it as, how does it calculate the number of samples (of one channel I'm assuming because we have to multiply it)?


More information about the Vorbis-dev mailing list