override internal Object unpack(Info vi, NVorbis.Ogg.BBuffer 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)) { 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) { return(null); } } return(info); }
override internal Object unpack(Info vi, NVorbis.Ogg.BBuffer 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 += Util.icount(cascade); } for (int j = 0; j < acc; j++) { info.booklist[j] = opb.Read(8); } 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); }
internal int unpack(NVorbis.Ogg.BBuffer opb) { int vendorlen = opb.Read(32); if (vendorlen < 0) { Clear(); return(-1); } vendor = new byte[vendorlen + 1]; opb.Read(vendor, vendorlen); comments = opb.Read(32); if (comments < 0) { 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) { 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) { Clear(); return(-1); } return(0); }
// unpacks a codebook from the packet buffer into the codebook struct, // readies the codebook auxiliary structures for decode internal int unpack(NVorbis.Ogg.BBuffer 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(Util.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); } // Do we have a mapping to unpack? switch ((maptype = opb.Read(4))) { case 0: // no mapping break; case 1: case 2: // implicitly populated value mapping // explicitly populated value mapping q_min = opb.Read(32); q_delta = opb.Read(32); q_quant = opb.Read(4) + 1; q_sequencep = opb.Read(1); { int quantvals = 0; switch (maptype) { case 1: quantvals = maptype1_quantvals(); break; case 2: quantvals = entries * dim; break; } // quantized values quantlist = new int[quantvals]; for (i = 0; i < quantvals; i++) { quantlist[i] = opb.Read(q_quant); } if (quantlist[quantvals - 1] == -1) { // goto _eofout; clear(); return(-1); } } break; default: // goto _eofout; clear(); return(-1); } // all set return(0); // _errout: // _eofout: // vorbis_staticbook_clear(s); // return(-1); }
override internal Object unpack(Info vi, NVorbis.Ogg.BBuffer 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) { 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) { 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) { 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)) { info.free(); return(null); } } } info.postlist[0] = 0; info.postlist[1] = 1 << rangebits; return(info); }
// also responsible for range checking override internal Object unpack(Info vi, NVorbis.Ogg.BBuffer opb) { 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(Util.ilog2(vi.Channels)); int testA = info.coupling_ang[i] = opb.Read(Util.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 */ 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) { info.free(); return(null); } } } for (int i = 0; i < info.submaps; i++) { info.timesubmap[i] = opb.Read(8); if (info.timesubmap[i] >= vi.Times) { info.free(); return(null); } info.floorsubmap[i] = opb.Read(8); if (info.floorsubmap[i] >= vi.floors) { info.free(); return(null); } info.residuesubmap[i] = opb.Read(8); if (info.residuesubmap[i] >= vi.residues) { info.free(); return(null); } } return(info); }