Пример #1
0
        public void synthesis_headerin(Comment vc, Packet op)
        {
            if (op == null)
            {
                return;
            }

            csBuffer opb = new csBuffer();

            opb.readinit(op.packet_base, op.packet, op.bytes);
            byte[] buffer   = new byte[6];
            int    packtype = opb.read(8);

            opb.read(buffer, 6);

            if (buffer[0] != 'v' || buffer[1] != 'o' || buffer[2] != 'r' ||
                buffer[3] != 'b' || buffer[4] != 'i' || buffer[5] != 's')
            {
                throw new InvalidOperationException("Expected vorbis header");
            }

            switch (packtype)
            {
            case 0x01:                     // least significant *bit* is read first
                unpack_info(opb);
                break;

            case 0x03:                     // least significant *bit* is read first
                vc.unpack(opb);
                break;

            case 0x05:                     // least significant *bit* is read first
                unpack_books(opb);
                break;

            default:
                // Not a valid vorbis header type
                break;
            }
        }
Пример #2
0
        public override 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 += 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);
        }
Пример #3
0
        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
0
        internal int unpack(csBuffer opb)
        {
            int vendorlen = opb.read(32);

            vendor = new byte[vendorlen + 1];
            opb.read(vendor, vendorlen);
            comments      = opb.read(32);
            user_comments = new byte[comments + 1][];

            for (int i = 0; i < comments; i++)
            {
                int len = opb.read(32);
                user_comments[i] = new byte[len + 1];
                opb.read(user_comments[i], len);
            }

            opb.read(1);
            return(0);
        }
Пример #5
0
        // 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);
        }
Пример #6
0
        // 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];
            }
            if (map_param == null || map_param.Length != maps)
            {
                map_param = new Object[maps];
            }
            for (int i = 0; i < maps; i++)
            {
                map_type[i] = opb.read(16);
                if (map_type[i] < 0 || map_type[i] >= VI_MAPB)
                {
                    //	goto err_out;
                    clear();
                    return(-1);
                }
                map_param[i] = FuncMapping.mapping_P[map_type[i]].unpack(this, opb);
                if (map_param[i] == null)
                {
                    //    goto err_out;
                    clear();
                    return(-1);
                }
            }

            // mode settings
            modes = opb.read(6) + 1;
            if (mode_param == null || mode_param.Length != modes)
            {
                mode_param = new InfoMode[modes];
            }
            for (int i = 0; i < modes; i++)
            {
                mode_param[i]               = new InfoMode();
                mode_param[i].blockflag     = opb.read(1);
                mode_param[i].windowtype    = opb.read(16);
                mode_param[i].transformtype = opb.read(16);
                mode_param[i].mapping       = opb.read(8);

                if ((mode_param[i].windowtype >= VI_WINDOWB) ||
                    (mode_param[i].transformtype >= VI_WINDOWB) ||
                    (mode_param[i].mapping >= maps))
                {
                    //      goto err_out;
                    clear();
                    return(-1);
                }
            }

            if (opb.read(1) != 1)
            {
                //goto err_out; // top level EOP check
                clear();
                return(-1);
            }

            return(0);
            // err_out:
            //  vorbis_info_clear(vi);
            //  return(-1);
        }
Пример #7
0
        override public 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);
        }
Пример #8
0
        /*
         */

        // 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);
            }

            // 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);
        }
Пример #9
0
        // 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;

            opb.read(24);
            // first the basic parameters
            dim     = opb.read(16);
            entries = opb.read(24);

            // 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);
                            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);
                        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(VUtils.ilog(entries - i));
                    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);
                    }
                }
                break;

            default:
                return(-1);
            }
            return(0);
        }
Пример #10
0
        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);
        }
Пример #11
0
        public override Object unpack(Info vi, csBuffer opb)
        {
            InfoMapping0 info = new InfoMapping0();

            info.submaps = opb.read(1) != 0
                                ? opb.read(4) + 1 : 1;

            if (opb.read(1) != 0)
            {
                info.coupling_steps = opb.read(8) + 1;

                for (int i = 0; i < info.coupling_steps; i++)
                {
                    info.coupling_mag[i] = opb.read(VUtils.ilog2(vi.channels));
                    info.coupling_ang[i] = opb.read(VUtils.ilog2(vi.channels));
                }
            }
            opb.read(2);

            if (info.submaps > 1)
            {
                for (int i = 0; i < vi.channels; i++)
                {
                    info.chmuxlist[i] = opb.read(4);
                }
            }

            for (int i = 0; i < info.submaps; i++)
            {
                info.timesubmap[i]    = opb.read(8);
                info.floorsubmap[i]   = opb.read(8);
                info.residuesubmap[i] = opb.read(8);
            }
            return(info);
        }
Пример #12
0
        public int synthesis(Packet op)
        {
            Info vi = vd.vi;

            // first things first.  Make sure decode is ready
            // ripcord();
            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(-1);
            }

            // read our mode and pre/post windowsize
            int _mode = opb.read(vd.modebits);

            if (_mode == -1)
            {
                return(-1);
            }

            mode = _mode;
            W    = vi.mode_param[mode].blockflag;
            if (W != 0)
            {
                lW = opb.read(1);
                nW = opb.read(1);
                if (nW == -1)
                {
                    return(-1);
                }
            }
            else
            {
                lW = 0;
                nW = 0;
            }

            // more setup
            granulepos = op.granulepos;
            sequence   = op.packetno - 3;       // first block is third packet
            eofflag    = op.e_o_s;

            // alloc pcm passback storage
            pcmend = vi.blocksizes[W];
            //pcm=alloc(vi.channels);
            if (pcm.Length < vi.channels)
            {
                pcm = new float[vi.channels][];
            }
            for (int i = 0; i < vi.channels; i++)
            {
                if (pcm[i] == null || pcm[i].Length < pcmend)
                {
                    pcm[i] = new float[pcmend];
                    //pcm[i]=alloc(pcmend);
                }
                else
                {
                    for (int j = 0; j < pcmend; j++)
                    {
                        pcm[i][j] = 0;
                    }
                }
            }

            // unpack_header enforces range checking
            int type = vi.map_type[vi.mode_param[mode].mapping];

            return(FuncMapping.mapping_P[type].inverse(this, vd.mode[mode]));
        }
Пример #13
0
        void unpack_books(csBuffer opb)
        {
            books      = opb.read(8) + 1;
            book_param = new StaticCodeBook[books];
            for (int i = 0; i < books; i++)
            {
                book_param[i] = new StaticCodeBook();
                book_param[i].unpack(opb);
            }

            times = opb.read(6) + 1;
            for (int i = 0; i < times; i++)
            {
                opb.read(16);
            }

            floors      = opb.read(6) + 1;
            floor_funcs = new Floor1[floors];
            floor_param = new object[floors];
            for (int i = 0; i < floors; i++)
            {
                int type = opb.read(16);
                if (type != 1)
                {
                    throw new csorbisException("floor type must be 1");
                }
                floor_funcs[i] = new Floor1();
                floor_param[i] = floor_funcs[i].unpack(this, opb);
            }

            residues      = opb.read(6) + 1;
            residue_funcs = new FuncResidue[residues];
            residue_param = new object[residues];
            for (int i = 0; i < residues; i++)
            {
                int type = opb.read(16);
                if (type > 2)
                {
                    throw new csorbisException("residue type must be <= 2");
                }
                residue_funcs[i] = FuncResidue.make(type);
                residue_param[i] = residue_funcs[i].unpack(this, opb);
            }

            maps      = opb.read(6) + 1;
            map_funcs = new FuncMapping[maps];
            map_param = new object[maps];
            for (int i = 0; i < maps; i++)
            {
                int type = opb.read(16);
                if (type != 0)
                {
                    throw new csorbisException("mapping type must be 0");
                }
                map_funcs[i] = new Mapping0();
                map_param[i] = map_funcs[i].unpack(this, opb);
            }

            modes      = opb.read(6) + 1;
            mode_param = new InfoMode[modes];
            for (int i = 0; i < modes; i++)
            {
                mode_param[i]               = new InfoMode();
                mode_param[i].blockflag     = opb.read(1);
                mode_param[i].windowtype    = opb.read(16);
                mode_param[i].transformtype = opb.read(16);
                mode_param[i].mapping       = opb.read(8);
            }
            opb.read(1);
        }
Пример #14
0
        // Also responsible for range checking
        public override object unpack(Info vi, csBuffer 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)
                    {
                        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);
        }