<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
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.<br>
<br>
This is the first<br>
<br>
<font face="Courier New, Courier, monospace"> /* uninterleave
samples */<br>
for(i=0;i<bytes/4;i++){<br>
buffer[0][i]=((readbuffer[i*4+1]<<8)|<br>
(0x00ff&(int)readbuffer[i*4]))/32768.f;<br>
buffer[1][i]=((readbuffer[i*4+3]<<8)|<br>
(0x00ff&(int)readbuffer[i*4+2]))/32768.f;<br>
}<br>
</font><br>
<br>
This is the second.<br>
<br>
<font face="Courier New, Courier, monospace"> /* vorbis does some
data preanalysis, then divvies up blocks for<br>
more involved (potentially parallel) processing. Get a single<br>
block for encoding now */<br>
while(vorbis_analysis_blockout(&vd,&vb)==1){<br>
<br>
/* analysis, assume we want to use bitrate management */<br>
vorbis_analysis(&vb,NULL);<br>
vorbis_bitrate_addblock(&vb);<br>
<br>
while(vorbis_bitrate_flushpacket(&vd,&op)){<br>
<br>
/* weld the packet into the bitstream */<br>
ogg_stream_packetin(&os,&op);<br>
<br>
/* write out pages (if any) */<br>
while(!eos){<br>
int result=ogg_stream_pageout(&os,&og);<br>
if(result==0)break;<br>
fwrite(og.header,1,og.header_len,stdout);<br>
fwrite(og.body,1,og.body_len,stdout);<br>
<br>
/* this could be set above, but for illustrative purposes, I
do<br>
it here (to show that vorbis does know where the stream
ends) */<br>
<br>
if(ogg_page_eos(&og))eos=1;<br>
}<br>
}<br>
</font><br>
<br>
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.<br>
<br>
Thanks in advance.<br>
<br>
Dan Mikusa<br>
<a class="moz-txt-link-abbreviated" href="mailto:dan@trz.cc">dan@trz.cc</a><br>
<br>
</body>
</html>