natix.CompactDS.RRR.Build C# (CSharp) Method

Build() public method

public Build ( BitStream32 B, short blockSize ) : void
B BitStream32
blockSize short
return void
        public void Build(BitStream32 B, short blockSize)
        {
            this.N = (int)B.CountBits;
            this.BlockSize = (short)blockSize;
            this.InitClasses();
            this.Offsets = new BitStream32 ();
            IList<int> _L = new ListIFS (15, B);
            IList<int> L;
            if ((B.CountBits % 15) == 0) {
                L = _L;
            } else {
                int D = _L.Count;
                int C = 15 * D;
                var ctx = new BitStreamCtx(0);
                ctx.Seek(C);
                int last_block = (int)B.Read(((int)B.CountBits) - C, ctx);
                L = new ListGen<int>(delegate(int a) {
                    if (a == D) {
                        return last_block;
                    } else {
                        return _L[a];
                    }
                }, D+1);
            }
            this.AbsRank = new int[(int)Math.Ceiling(((float)L.Count) / this.BlockSize)];
            this.AbsOffset = new int[ this.AbsRank.Length ];
            int I = 0;
            int acc = 0;
            for (int i = 0; i < L.Count; i++) {
                var u = (short)L[i];
                var klass = GetClass(u);
                this.EncodeClass(klass);
                if (i % this.BlockSize == 0) {
                    this.AbsRank[I] = acc;
                    this.AbsOffset[I] = (int)this.Offsets.CountBits;
                    I++;
                }
                var numbits = NumBits[klass];
                if (numbits > 0) {
                    int offset = this.GetOffset (u, klass);
                    this.Offsets.Write (offset, numbits);
                }
                acc += klass;
            }
        }

Usage Example

Exemplo n.º 1
0
 public static BitmapFromBitStream GetRRR_wt(short sample_step)
 {
     return delegate (FakeBitmap b) {
         var rs = new RRR ();
         rs.Build (b.B, sample_step);
         return rs;
     };
 }
All Usage Examples Of natix.CompactDS.RRR::Build