[xiph-commits] r10404 - trunk/xiph-rtp
lu_zero at svn.xiph.org
lu_zero at svn.xiph.org
Fri Nov 18 11:35:06 PST 2005
Author: lu_zero
Date: 2005-11-18 11:35:03 -0800 (Fri, 18 Nov 2005)
New Revision: 10404
Modified:
trunk/xiph-rtp/vorbisrtp-client.c
Log:
Vorbis parser complete
Modified: trunk/xiph-rtp/vorbisrtp-client.c
===================================================================
--- trunk/xiph-rtp/vorbisrtp-client.c 2005-11-18 17:14:28 UTC (rev 10403)
+++ trunk/xiph-rtp/vorbisrtp-client.c 2005-11-18 19:35:03 UTC (rev 10404)
@@ -75,7 +75,7 @@
int param_blockflag[64];
} ogg_context_t;
-static int _ilog(unsigned int v){
+static int rtp_ilog(unsigned int v){
int ret=0;
while(v){
ret++;
@@ -234,18 +234,20 @@
channels = ogg->op.packet[11];
//cb packet
oggpack_readinit(&opb, ogg->op.packet + 30, ogg->op.bytes - 30);
- oggpack_read(&opb,8);
- for(i=6;i<0;i--) oggpack_read(&opb,8);
-
+ if (5 != oggpack_read(&opb,8)) exit(9);
+ for(i=6;i>0;i--) { oggpack_read(&opb,8);
+ }
+
num = oggpack_read(&opb,8)+1;
for(;num>0;num--)
{
- int entries, quantvals=0, maptype, q_quant, dim;
- oggpack_read(&opb,24);
- dim = oggpack_read(&opb,16);
- entries = oggpack_read(&opb,24);
+ int entries, quantvals=-1, maptype, q_quant, dim;
+ oggpack_read(&opb,24); //magic
+ dim = oggpack_read(&opb,16); //dimensions
+ entries = oggpack_read(&opb,24); //entries
+
switch(oggpack_read(&opb,1)){
- case 0:
+ case 0: //unordered
if(oggpack_read(&opb,1))
{
for(i=0; i<entries; i++)
@@ -256,10 +258,10 @@
for(i=0; i<entries; i++)
oggpack_read(&opb,5);
break;
- case 1:
- oggpack_read(&opb,5);
- for(i=0; i<entries; i++)
- oggpack_read(&opb,_ilog(entries-i));
+ case 1: //ordered
+ oggpack_read(&opb,5); //len
+ for(i=0;i<entries;)
+ i+=oggpack_read(&opb,rtp_ilog(entries-i));
break;
}
switch((maptype=oggpack_read(&opb,4))){
@@ -269,7 +271,7 @@
case 1: case 2:
oggpack_read(&opb,32);
oggpack_read(&opb,32);
- q_quant=oggpack_read(&opb,4);
+ q_quant = oggpack_read(&opb,4) + 1;
oggpack_read(&opb,1);
switch (maptype){
@@ -284,8 +286,9 @@
for(i=0;i<quantvals;i++)
oggpack_read(&opb,q_quant);
-
+ break;
}
+
}
//times
@@ -299,9 +302,9 @@
switch(oggpack_read(&opb,16)){
case 0:
- oggpack_read(&opb,8);
oggpack_read(&opb,16);
oggpack_read(&opb,16);
+ oggpack_read(&opb,16);
oggpack_read(&opb,6);
oggpack_read(&opb,8);
for(i=oggpack_read(&opb,4)+1;i>0;i--)
@@ -309,17 +312,17 @@
break;
case 1:
{
- int partitionclass[31], dim[16],
- rangebits, count=0,
+ int pclass[31], pdim[16],
+ rangebits,
partitions=oggpack_read(&opb,5);
for(i=0;i<partitions;i++)
- {
- partitionclass[i]=oggpack_read(&opb,4);
- if(k<partitionclass[i])k=partitionclass[i];
+ {
+ pclass[i]=oggpack_read(&opb,4);
+ if(k<pclass[i])k=pclass[i];
}
for(j=0;j<k+1;j++){
int subs;
- dim[j] = oggpack_read(&opb,3)+1; // dim
+ pdim[j] = oggpack_read(&opb,3)+1; // dim
subs=oggpack_read(&opb,2);
if(subs) oggpack_read(&opb,8); // book
for(i=0;i<(1<<subs);i++)
@@ -330,9 +333,7 @@
rangebits=oggpack_read(&opb,4);
for(j=0,k=0;j<partitions;j++)
{
- count+=dim[partitionclass[j]];
- for(;k<count;k++)
- oggpack_read(&opb,rangebits);
+ oggpack_read(&opb,rangebits*pdim[pclass[j]]);
}
}
}
@@ -367,8 +368,8 @@
submaps=oggpack_read(&opb,4)+1;
if(oggpack_read(&opb,1))
for(i=oggpack_read(&opb,8)+1;i>0;i--){
- oggpack_read(&opb,_ilog(channels-1));
- oggpack_read(&opb,_ilog(channels-1));
+ oggpack_read(&opb,rtp_ilog(channels-1));
+ oggpack_read(&opb,rtp_ilog(channels-1));
}
oggpack_read(&opb,2);
if(submaps>1)
@@ -477,7 +478,7 @@
cfg_parse(ogg);
#if CHECK
- fprintf(stderr,"parsed: rate %ld, blocksizes %ld %ld\n ",
+ fprintf(stderr,"parsed: rate %ld, blocksizes %ld %ld, blockflags ",
ogg->vi.rate,
ogg->blocksizes[0],
ogg->blocksizes[1]
More information about the commits
mailing list