Update Vorbis from 1.3.2 to 1.3.6. Updating to this version addresses issue #1890 which discusses vulnerabilities with the current Vorbis version.
This commit is contained in:
+33
-34
@@ -11,7 +11,6 @@
|
||||
********************************************************************
|
||||
|
||||
function: simple example decoder
|
||||
last mod: $Id: decoder_example.c 16243 2009-07-10 02:49:31Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
@@ -75,7 +74,7 @@ int main(){
|
||||
/********** Decode setup ************/
|
||||
|
||||
ogg_sync_init(&oy); /* Now we can read pages */
|
||||
|
||||
|
||||
while(1){ /* we repeat if the bitstream is chained */
|
||||
int eos=0;
|
||||
int i;
|
||||
@@ -89,60 +88,60 @@ int main(){
|
||||
buffer=ogg_sync_buffer(&oy,4096);
|
||||
bytes=fread(buffer,1,4096,stdin);
|
||||
ogg_sync_wrote(&oy,bytes);
|
||||
|
||||
|
||||
/* Get the first page. */
|
||||
if(ogg_sync_pageout(&oy,&og)!=1){
|
||||
/* have we simply run out of data? If so, we're done. */
|
||||
if(bytes<4096)break;
|
||||
|
||||
|
||||
/* error case. Must not be Vorbis data */
|
||||
fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
/* Get the serial number and set up the rest of decode. */
|
||||
/* serialno first; use it to set up a logical stream */
|
||||
ogg_stream_init(&os,ogg_page_serialno(&og));
|
||||
|
||||
|
||||
/* extract the initial header from the first page and verify that the
|
||||
Ogg bitstream is in fact Vorbis data */
|
||||
|
||||
|
||||
/* I handle the initial header first instead of just having the code
|
||||
read all three Vorbis headers at once because reading the initial
|
||||
header is an easy way to identify a Vorbis bitstream and it's
|
||||
useful to see that functionality seperated out. */
|
||||
|
||||
|
||||
vorbis_info_init(&vi);
|
||||
vorbis_comment_init(&vc);
|
||||
if(ogg_stream_pagein(&os,&og)<0){
|
||||
if(ogg_stream_pagein(&os,&og)<0){
|
||||
/* error; stream version mismatch perhaps */
|
||||
fprintf(stderr,"Error reading first page of Ogg bitstream data.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(ogg_stream_packetout(&os,&op)!=1){
|
||||
|
||||
if(ogg_stream_packetout(&os,&op)!=1){
|
||||
/* no page? must not be vorbis */
|
||||
fprintf(stderr,"Error reading initial header packet.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(vorbis_synthesis_headerin(&vi,&vc,&op)<0){
|
||||
|
||||
if(vorbis_synthesis_headerin(&vi,&vc,&op)<0){
|
||||
/* error case; not a vorbis header */
|
||||
fprintf(stderr,"This Ogg bitstream does not contain Vorbis "
|
||||
"audio data.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
/* At this point, we're sure we're Vorbis. We've set up the logical
|
||||
(Ogg) bitstream decoder. Get the comment and codebook headers and
|
||||
set up the Vorbis decoder */
|
||||
|
||||
|
||||
/* The next two packets in order are the comment and codebook headers.
|
||||
They're likely large and may span multiple pages. Thus we read
|
||||
and submit data until we get our two packets, watching that no
|
||||
pages are missing. If a page is missing, error out; losing a
|
||||
header page is the only place where missing data is fatal. */
|
||||
|
||||
|
||||
i=0;
|
||||
while(i<2){
|
||||
while(i<2){
|
||||
@@ -181,7 +180,7 @@ int main(){
|
||||
}
|
||||
ogg_sync_wrote(&oy,bytes);
|
||||
}
|
||||
|
||||
|
||||
/* Throw the comments plus a few lines about the bitstream we're
|
||||
decoding */
|
||||
{
|
||||
@@ -193,7 +192,7 @@ int main(){
|
||||
fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi.channels,vi.rate);
|
||||
fprintf(stderr,"Encoded by: %s\n\n",vc.vendor);
|
||||
}
|
||||
|
||||
|
||||
convsize=4096/vi.channels;
|
||||
|
||||
/* OK, got and parsed all three headers. Initialize the Vorbis
|
||||
@@ -204,7 +203,7 @@ int main(){
|
||||
proceed in parallel. We could init
|
||||
multiple vorbis_block structures
|
||||
for vd here */
|
||||
|
||||
|
||||
/* The rest is just a straight decode loop until end of stream */
|
||||
while(!eos){
|
||||
while(!eos){
|
||||
@@ -218,7 +217,7 @@ int main(){
|
||||
this point */
|
||||
while(1){
|
||||
result=ogg_stream_packetout(&os,&op);
|
||||
|
||||
|
||||
if(result==0)break; /* need more data */
|
||||
if(result<0){ /* missing or corrupt data at this page position */
|
||||
/* no reason to complain; already complained above */
|
||||
@@ -226,21 +225,21 @@ int main(){
|
||||
/* we have a packet. Decode it */
|
||||
float **pcm;
|
||||
int samples;
|
||||
|
||||
|
||||
if(vorbis_synthesis(&vb,&op)==0) /* test for success! */
|
||||
vorbis_synthesis_blockin(&vd,&vb);
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
**pcm is a multichannel float vector. In stereo, for
|
||||
example, pcm[0] is left, and pcm[1] is right. samples is
|
||||
the size of each channel. Convert the float values
|
||||
(-1.<=range<=1.) to whatever PCM format and write it out */
|
||||
|
||||
|
||||
while((samples=vorbis_synthesis_pcmout(&vd,&pcm))>0){
|
||||
int j;
|
||||
int clipflag=0;
|
||||
int bout=(samples<convsize?samples:convsize);
|
||||
|
||||
|
||||
/* convert floats to 16 bit signed ints (host order) and
|
||||
interleave */
|
||||
for(i=0;i<vi.channels;i++){
|
||||
@@ -265,17 +264,17 @@ int main(){
|
||||
ptr+=vi.channels;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(clipflag)
|
||||
fprintf(stderr,"Clipping in frame %ld\n",(long)(vd.sequence));
|
||||
|
||||
|
||||
|
||||
|
||||
fwrite(convbuffer,2*vi.channels,bout,stdout);
|
||||
|
||||
|
||||
vorbis_synthesis_read(&vd,bout); /* tell libvorbis how
|
||||
many samples we
|
||||
actually consumed */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(ogg_page_eos(&og))eos=1;
|
||||
@@ -288,10 +287,10 @@ int main(){
|
||||
if(bytes==0)eos=1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ogg_page and ogg_packet structs always point to storage in
|
||||
libvorbis. They're never freed or manipulated directly */
|
||||
|
||||
|
||||
vorbis_block_clear(&vb);
|
||||
vorbis_dsp_clear(&vd);
|
||||
}else{
|
||||
@@ -300,7 +299,7 @@ int main(){
|
||||
|
||||
/* clean up this logical bitstream; before exit we see if we're
|
||||
followed by another [chained] */
|
||||
|
||||
|
||||
ogg_stream_clear(&os);
|
||||
vorbis_comment_clear(&vc);
|
||||
vorbis_info_clear(&vi); /* must be called last */
|
||||
@@ -308,7 +307,7 @@ int main(){
|
||||
|
||||
/* OK, clean up the framer */
|
||||
ogg_sync_clear(&oy);
|
||||
|
||||
|
||||
fprintf(stderr,"Done.\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user