Hiroka IHARA
2015-Dec-04 07:28 UTC
[Vorbis-dev] A few questions about libvorbis from a newbie
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)?
Blake Martin
2015-Dec-04 08:42 UTC
[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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/vorbis-dev/attachments/20151204/ef703411/attachment.htm