Blake Martin
2015-Dec-04 05:10 UTC
[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)? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/vorbis-dev/attachments/20151203/7e756bc9/attachment.htm
Ihara Hiroka
2015-Dec-04 07:08 UTC
[Vorbis-dev] A few questions about libvorbis from a newbie
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 Date: Thu, 3 Dec 2015 23:10:29 -0600 From: blakemartin.official at gmail.com 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)? _______________________________________________ Vorbis-dev mailing list Vorbis-dev at xiph.org http://lists.xiph.org/mailman/listinfo/vorbis-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/vorbis-dev/attachments/20151204/7a7d70a6/attachment.htm