csvorbis.Residue0.pack C# (CSharp) Method

pack() public method

public pack ( Object vr, csBuffer opb ) : void
vr Object
opb csogg.csBuffer
return void
        public override void pack(Object vr, csBuffer opb)
        {
            InfoResidue0 info=(InfoResidue0)vr;
            int acc=0;
            opb.write(info.begin,24);
            opb.write(info.end,24);

            opb.write(info.grouping-1,24);  /* residue vectors to group and
                     code with a partitioned book */
            opb.write(info.partitions-1,6); /* possible partition choices */
            opb.write(info.groupbook,8);  /* group huffman book */

            /* secondstages is a bitmask; as encoding progresses pass by pass, a
               bitmask of one indicates this partition class has bits to write
               this pass */
            for(int j=0;j<info.partitions;j++)
            {
                if(ilog(info.secondstages[j])>3)
                {
                    /* yes, this is a minor hack due to not thinking ahead */
                    opb.write(info.secondstages[j],3);
                    opb.write(1,1);
                    opb.write(info.secondstages[j] >> 3,5);
                }
                else
                {
                    opb.write(info.secondstages[j],4); /* trailing zero */
                }
                acc+=icount(info.secondstages[j]);
            }
            for(int j=0;j<acc;j++)
            {
                opb.write(info.booklist[j],8);
            }
        }