[Vorbis] encoder_example.c Questions
Daniel Mikusa
dan at trz.cc
Mon Sep 26 12:20:22 PDT 2005
I've been trying to piece my way through the encoder_example.c program
to better understand how to encode files as ogg/vorbis. I'm stuck on
two sections of the code.
This is the first
/* uninterleave samples */
for(i=0;i<bytes/4;i++){
buffer[0][i]=((readbuffer[i*4+1]<<8)|
(0x00ff&(int)readbuffer[i*4]))/32768.f;
buffer[1][i]=((readbuffer[i*4+3]<<8)|
(0x00ff&(int)readbuffer[i*4+2]))/32768.f;
}
This is the second.
/* vorbis does some data preanalysis, then divvies up blocks for
more involved (potentially parallel) processing. Get a single
block for encoding now */
while(vorbis_analysis_blockout(&vd,&vb)==1){
/* analysis, assume we want to use bitrate management */
vorbis_analysis(&vb,NULL);
vorbis_bitrate_addblock(&vb);
while(vorbis_bitrate_flushpacket(&vd,&op)){
/* weld the packet into the bitstream */
ogg_stream_packetin(&os,&op);
/* write out pages (if any) */
while(!eos){
int result=ogg_stream_pageout(&os,&og);
if(result==0)break;
fwrite(og.header,1,og.header_len,stdout);
fwrite(og.body,1,og.body_len,stdout);
/* this could be set above, but for illustrative purposes, I do
it here (to show that vorbis does know where the stream
ends) */
if(ogg_page_eos(&og))eos=1;
}
}
Can anyone elaborate on what is happening in these two sections of
code? Also if anyone has more / better examples for libvorbis please
let me know.
Thanks in advance.
Dan Mikusa
dan at trz.cc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/vorbis/attachments/20050926/70007247/attachment.htm
More information about the Vorbis
mailing list