本文整理汇总了C#中csogg.csBuffer.read方法的典型用法代码示例。如果您正苦于以下问题:C# csBuffer.read方法的具体用法?C# csBuffer.read怎么用?C# csBuffer.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类csogg.csBuffer
的用法示例。
在下文中一共展示了csBuffer.read方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: unpack
override public Object unpack(Info vi , csBuffer opb)
{
InfoFloor0 info=new InfoFloor0();
info.order=opb.read(8);
info.rate=opb.read(16);
info.barkmap=opb.read(16);
info.ampbits=opb.read(6);
info.ampdB=opb.read(8);
info.numbooks=opb.read(4)+1;
if((info.order<1)||
(info.rate<1)||
(info.barkmap<1)||
(info.numbooks<1))
{
//free_info(info);
return(null);
}
for(int j=0;j<info.numbooks;j++)
{
info.books[j]=opb.read(8);
if(info.books[j]<0 || info.books[j]>=vi.books)
{
//free_info(info);
return(null);
}
}
return(info);
// err_out:
// free_info(info);
// return(NULL);
}
示例2: unpack
override public Object unpack(Info vi, csBuffer opb)
{
int acc=0;
InfoResidue0 info=new InfoResidue0();
info.begin=opb.read(24);
info.end=opb.read(24);
info.grouping=opb.read(24)+1;
info.partitions=opb.read(6)+1;
info.groupbook=opb.read(8);
for(int j=0;j<info.partitions;j++)
{
int cascade=opb.read(3);
if(opb.read(1)!=0)
{
cascade|=(opb.read(5)<<3);
}
info.secondstages[j]=cascade;
acc+=icount(cascade);
}
for(int j=0;j<acc;j++)
{
info.booklist[j]=opb.read(8);
// if(info.booklist[j]==255)info.booklist[j]=-1;
}
if(info.groupbook>=vi.books)
{
free_info(info);
return(null);
}
for(int j=0;j<acc;j++)
{
if(info.booklist[j]>=vi.books)
{
free_info(info);
return(null);
}
}
return(info);
// errout:
// free_info(info);
// return(NULL);
}
示例3: unpack
internal int unpack(csBuffer opb)
{
int vendorlen=opb.read(32);
if(vendorlen<0)
{
//goto err_out;
clear();
return(-1);
}
vendor=new byte[vendorlen+1];
opb.read(vendor,vendorlen);
comments=opb.read(32);
if(comments<0)
{
//goto err_out;
clear();
return(-1);
}
user_comments=new byte[comments+1][];
comment_lengths=new int[comments+1];
for(int i=0;i<comments;i++)
{
int len=opb.read(32);
if(len<0)
{
//goto err_out;
clear();
return(-1);
}
comment_lengths[i]=len;
user_comments[i]=new byte[len+1];
opb.read(user_comments[i], len);
}
if(opb.read(1)!=1)
{
//goto err_out; // EOP check
clear();
return(-1);
}
return(0);
// err_out:
// comment_clear(vc);
// return(-1);
}
示例4: unpack
public override Object unpack(Info vi, csBuffer opb)
{
// also responsible for range checking
InfoMapping0 info=new InfoMapping0();
// !!!!
if(opb.read(1)!=0)
{
info.submaps=opb.read(4)+1;
}
else
{
info.submaps=1;
}
if(opb.read(1)!=0)
{
info.coupling_steps=opb.read(8)+1;
for(int i=0;i<info.coupling_steps;i++)
{
int testM=info.coupling_mag[i]=opb.read(ilog2(vi.channels));
int testA=info.coupling_ang[i]=opb.read(ilog2(vi.channels));
if(testM<0 ||
testA<0 ||
testM==testA ||
testM>=vi.channels ||
testA>=vi.channels)
{
//goto err_out;
info.free();
return(null);
}
}
}
if(opb.read(2)>0)
{ /* 2,3:reserved */
//goto err_out;
info.free();
return(null);
}
if(info.submaps>1)
{
for(int i=0;i<vi.channels;i++)
{
info.chmuxlist[i]=opb.read(4);
if(info.chmuxlist[i]>=info.submaps)
{
//goto err_out;
info.free();
return(null);
}
}
}
for(int i=0;i<info.submaps;i++)
{
info.timesubmap[i]=opb.read(8);
if(info.timesubmap[i]>=vi.times)
{
//goto err_out;
info.free();
return(null);
}
info.floorsubmap[i]=opb.read(8);
if(info.floorsubmap[i]>=vi.floors)
{
//goto err_out;
info.free();
return(null);
}
info.residuesubmap[i]=opb.read(8);
if(info.residuesubmap[i]>=vi.residues)
{
//goto err_out;
info.free();
return(null);
}
}
return info;
//err_out:
//free_info(info);
//return(NULL);
}
示例5: unpack
/*
*/
// unpacks a codebook from the packet buffer into the codebook struct,
// readies the codebook auxiliary structures for decode
internal int unpack(csBuffer opb)
{
int i;
//memset(s,0,sizeof(static_codebook));
// make sure alignment is correct
if(opb.read(24)!=0x564342)
{
// goto _eofout;
clear();
return(-1);
}
// first the basic parameters
dim=opb.read(16);
entries=opb.read(24);
if(entries==-1)
{
// goto _eofout;
clear();
return(-1);
}
// codeword ordering.... length ordered or unordered?
switch(opb.read(1))
{
case 0:
// unordered
lengthlist=new int[entries];
// allocated but unused entries?
if(opb.read(1)!=0)
{
// yes, unused entries
for(i=0;i<entries;i++)
{
if(opb.read(1)!=0)
{
int num=opb.read(5);
if(num==-1)
{
// goto _eofout;
clear();
return(-1);
}
lengthlist[i]=num+1;
}
else
{
lengthlist[i]=0;
}
}
}
else
{
// all entries used; no tagging
for(i=0;i<entries;i++)
{
int num=opb.read(5);
if(num==-1)
{
// goto _eofout;
clear();
return(-1);
}
lengthlist[i]=num+1;
}
}
break;
case 1:
// ordered
{
int length=opb.read(5)+1;
lengthlist=new int[entries];
for(i=0;i<entries;)
{
int num=opb.read(ilog(entries-i));
if(num==-1)
{
// goto _eofout;
clear();
return(-1);
}
for(int j=0;j<num;j++,i++)
{
lengthlist[i]=length;
}
length++;
}
}
break;
default:
// EOF
return(-1);
//.........这里部分代码省略.........
示例6: blocksize
// static void v_writestring(csBuffer o, byte[] s){
// int i=0;
// while(s[i]!=0){
// o.write(s[i++],8);
// }
// }
// static void v_readstring(csBuffer o, byte[] buf, int bytes){
// int i=0
// while(bytes--!=0){
// buf[i++]=o.read(8);
// }
// }
// private csBuffer opb_blocksize=new csBuffer();
public int blocksize(Packet op)
{
//codec_setup_info *ci=vi->codec_setup;
csBuffer opb=new csBuffer();
// synchronized(opb_blocksize){
int mode;
opb.readinit(op.packet_base, op.packet, op.bytes);
/* Check the packet type */
if(opb.read(1)!=0)
{
/* Oops. This is not an audio data packet */
return(OV_ENOTAUDIO);
}
{
int modebits=0;
int v=modes;
while(v>1)
{
modebits++;
v = (int)((uint)v >> 1);
}
/* read our mode and pre/post windowsize */
mode=opb.read(modebits);
}
if(mode==-1)return(OV_EBADPACKET);
return(blocksizes[mode_param[mode].blockflag]);
// }
}
示例7: synthesis_headerin
// The Vorbis header is in three packets; the initial small packet in
// the first page that identifies basic parameters, a second packet
// with bitstream comments and a third packet that holds the
// codebook.
public int synthesis_headerin(Comment vc, Packet op)
{
csBuffer opb=new csBuffer();
if(op!=null)
{
opb.readinit(op.packet_base, op.packet, op.bytes);
// Which of the three types of header is this?
// Also verify header-ness, vorbis
{
byte[] buffer=new byte[6];
int packtype=opb.read(8);
//memset(buffer,0,6);
opb.read(buffer,6);
if(buffer[0]!='v' || buffer[1]!='o' || buffer[2]!='r' ||
buffer[3]!='b' || buffer[4]!='i' || buffer[5]!='s')
{
// not a vorbis header
return(-1);
}
switch(packtype)
{
case 0x01: // least significant *bit* is read first
if(op.b_o_s==0)
{
// Not the initial packet
return(-1);
}
if(rate!=0)
{
// previously initialized info header
return(-1);
}
return(unpack_info(opb));
case 0x03: // least significant *bit* is read first
if(rate==0)
{
// um... we didn't get the initial header
return(-1);
}
return(vc.unpack(opb));
case 0x05: // least significant *bit* is read first
if(rate==0 || vc.vendor==null)
{
// um... we didn;t get the initial header or comments yet
return(-1);
}
return(unpack_books(opb));
default:
// Not a valid vorbis header type
//return(-1);
break;
}
}
}
return(-1);
}
示例8: unpack_books
// all of the real encoding details are here. The modes, books,
// everything
int unpack_books(csBuffer opb)
{
//d* codebooks
books=opb.read(8)+1;
if(book_param==null || book_param.Length!=books)
book_param=new StaticCodeBook[books];
for(int i=0;i<books;i++)
{
book_param[i]=new StaticCodeBook();
if(book_param[i].unpack(opb)!=0)
{
//goto err_out;
clear();
return(-1);
}
}
// time backend settings
times=opb.read(6)+1;
if(time_type==null || time_type.Length!=times) time_type=new int[times];
if(time_param==null || time_param.Length!=times)
time_param=new Object[times];
for(int i=0;i<times;i++)
{
time_type[i]=opb.read(16);
if(time_type[i]<0 || time_type[i]>=VI_TIMEB)
{
//goto err_out;
clear();
return(-1);
}
time_param[i]=FuncTime.time_P[time_type[i]].unpack(this, opb);
if(time_param[i]==null)
{
//goto err_out;
clear();
return(-1);
}
}
// floor backend settings
floors=opb.read(6)+1;
if(floor_type==null || floor_type.Length!=floors)
floor_type=new int[floors];
if(floor_param==null || floor_param.Length!=floors)
floor_param=new Object[floors];
for(int i=0;i<floors;i++)
{
floor_type[i]=opb.read(16);
if(floor_type[i]<0 || floor_type[i]>=VI_FLOORB)
{
//goto err_out;
clear();
return(-1);
}
floor_param[i]=FuncFloor.floor_P[floor_type[i]].unpack(this,opb);
if(floor_param[i]==null)
{
//goto err_out;
clear();
return(-1);
}
}
// residue backend settings
residues=opb.read(6)+1;
if(residue_type==null || residue_type.Length!=residues)
residue_type=new int[residues];
if(residue_param==null || residue_param.Length!=residues)
residue_param=new Object[residues];
for(int i=0;i<residues;i++)
{
residue_type[i]=opb.read(16);
if(residue_type[i]<0 || residue_type[i]>=VI_RESB)
{
// goto err_out;
clear();
return(-1);
}
residue_param[i]=FuncResidue.residue_P[residue_type[i]].unpack(this,opb);
if(residue_param[i]==null)
{
// goto err_out;
clear();
return(-1);
}
}
// map backend settings
maps=opb.read(6)+1;
if(map_type==null || map_type.Length!=maps) map_type=new int[maps];
//.........这里部分代码省略.........
示例9: unpack_info
// Header packing/unpacking
int unpack_info(csBuffer opb)
{
version=opb.read(32);
if(version!=0)return(-1);
channels=opb.read(8);
rate=opb.read(32);
bitrate_upper=opb.read(32);
bitrate_nominal=opb.read(32);
bitrate_lower=opb.read(32);
blocksizes[0]=1<<opb.read(4);
blocksizes[1]=1<<opb.read(4);
if((rate<1) ||
(channels<1)||
(blocksizes[0]<8)||
(blocksizes[1]<blocksizes[0]) ||
(opb.read(1)!=1))
{
//goto err_out; // EOP check
clear();
return(-1);
}
return(0);
// err_out:
// vorbis_info_clear(vi);
// return(-1);
}
示例10: unpack
override public Object unpack(Info vi , csBuffer opb)
{
int count=0,maxclass=-1,rangebits;
InfoFloor1 info=new InfoFloor1();
/* read partitions */
info.partitions=opb.read(5); /* only 0 to 31 legal */
for(int j=0;j<info.partitions;j++)
{
info.partitionclass[j]=opb.read(4); /* only 0 to 15 legal */
if(maxclass<info.partitionclass[j])
maxclass=info.partitionclass[j];
}
/* read partition classes */
for(int j=0;j<maxclass+1;j++)
{
info.class_dim[j]=opb.read(3)+1; /* 1 to 8 */
info.class_subs[j]=opb.read(2); /* 0,1,2,3 bits */
if(info.class_subs[j]<0)
{
//goto err_out;
info.free();
return(null);
}
if(info.class_subs[j]!=0)
{
info.class_book[j]=opb.read(8);
}
if(info.class_book[j]<0 || info.class_book[j]>=vi.books)
{
//goto err_out;
info.free();
return(null);
}
for(int k=0;k<(1<<info.class_subs[j]);k++)
{
info.class_subbook[j][k]=opb.read(8)-1;
if(info.class_subbook[j][k]<-1 || info.class_subbook[j][k]>=vi.books)
{
//goto err_out;
info.free();
return(null);
}
}
}
/* read the post list */
info.mult=opb.read(2)+1; /* only 1,2,3,4 legal now */
rangebits=opb.read(4);
for(int j=0,k=0;j<info.partitions;j++)
{
count+=info.class_dim[info.partitionclass[j]];
for(;k<count;k++)
{
int t=info.postlist[k+2]=opb.read(rangebits);
if(t<0 || t>=(1<<rangebits))
{
//goto err_out;
info.free();
return(null);
}
}
}
info.postlist[0]=0;
info.postlist[1]=1<<rangebits;
return(info);
// err_out:
// info.free();
// return(null);
}