public DiffSet() { this.Samples = new List<int> (); this.Offsets = new List<long> (); this.Stream = new BitStream32 (); this.Coder = new EliasDelta (); }
public static PermutationBuilder GetSuccRL2CyclicPerms(int t, IIEncoder32 coder, short block_size) { return delegate (IList<int> perm) { var P = new SuccRL2CyclicPerms_MRRR (); P.Build (perm, t, new SuccRL2CyclicPerms_MRRR.BuildParams (coder, block_size)); return P; }; }
public static BitmapFromList GetDiffSet(short sample_step, IIEncoder32 coder = null) { return delegate (IList<int> L) { var rs = new DiffSet (); rs.Build (L, sample_step, coder); return rs; }; }
public EqualSizeCoder(byte bits_per_code, int max_value) { this.bits_per_code = bits_per_code; var bits_per_symbol = ListIFS.GetNumBits(max_value); this.Coder = new BinaryCoding(bits_per_symbol); // if (coder == null) { // //var numbits = (int)Math.Ceiling(numbits * 1.0 / this.bits_per_code) * this.bits_per_code; // //coder = new BinaryCoding(numbits); // // } // this.Coder = coder; }
public static SequenceBuilder GetGolynskiListRL2(short t = 16, short block_size = 127, IIEncoder32 coder = null) { return delegate (IList<int> seq, int sigma) { var S = new GolynskiListRL2Seq (); //S.PermCodingBuildParams = new SuccRL2CyclicPerms_MRRR.BuildParams (coder, block_size); if (coder == null) { coder = new EliasDelta (); } S.Build (seq, sigma, t, coder, block_size); return S; }; }
public static PermutationBuilder GetCyclicPermsListIDiffs(int t, short bsize, BitmapFromBitStream marks_builder = null, IIEncoder32 encoder = null) { return delegate (IList<int> perm) { var P = new CyclicPerms_MRRR (); var permbuilder = ListIBuilders.GetListIDiffs(bsize, marks_builder, encoder); var backbuilder = ListIBuilders.GetListIFS(); P.Build (perm, t, permbuilder, backbuilder); return P; }; }
/// <summary> /// Saves "coder" to the binary file "Output" /// </summary> public static void Save(BinaryWriter Output, IIEncoder32 coder) { var type = coder.GetType (); byte idType = 255; for (byte i = 0; i < Catalog.Count; i++) { if (type == Catalog [i]) { idType = i; break; } } if (idType == 255) { var s = String.Format ("Type {0} is not a recognized IIEncoder32, please add it to " + "IntegerEncoderGenericIO.Catalog", type); throw new ArgumentException (s); } Output.Write (idType); coder.Save (Output); }
public virtual void Load(BinaryReader Input) { this.SkipCoder = IEncoder32GenericIO.Load (Input); this.Power = Input.ReadByte (); }
public BlockCoding(int power, IIEncoder32 skipcoder) { // power must be an small integer like 3, 4, 5 this.Power = power; this.SkipCoder = skipcoder; }
public static SequenceBuilder GetSeqSinglePermListIDiffs(short t, short bsize = 16, BitmapFromBitStream bitmap_builder = null, IIEncoder32 encoder = null) { var pbuilder = PermutationBuilders.GetCyclicPermsListIDiffs(t, bsize, bitmap_builder, encoder); return GetSeqSinglePerm(pbuilder, null); }
public override void Load(BinaryReader R) { // var POS = R.BaseStream.Position; this.N = R.ReadInt32 (); this.M = R.ReadInt32 (); this.B = R.ReadInt16 (); int num_samples = this.M / this.B; /*if (num_samples > PLAIN_SAMPLES_THRESHOLD) { var sa = new SArray(); sa.Load(R); this.Samples = new SortedListSArray (sa); sa = new SArray (); sa.Load (R); this.Offsets = new SortedListSArray (sa); } else {*/ this.Samples = new List<int>( num_samples ); this.Offsets = new List<long>( num_samples ); PrimitiveIO<int>.LoadVector (R, num_samples, this.Samples); PrimitiveIO<long>.LoadVector (R, num_samples, this.Offsets); //} // POS = R.BaseStream.Position - POS; // Console.WriteLine("=======*******=======>> POS: {0}", POS); this.Coder = IEncoder32GenericIO.Load (R); this.Stream = new BitStream32 (); this.Stream.Load (R); //Console.WriteLine ("xxxxxx load samples.count {0}. N: {1}, M: {2}, B: {3}, BitCount: {4}", // this.Samples.Count, this.N, this.M, this.B, this.Stream.CountBits); }
/// <summary> /// build methods /// </summary> public void Build(IEnumerable<int> orderedList, int n, short b, IIEncoder32 coder = null) { this.N = n; this.B = b; this.M = 0; if (coder == null) { coder = new EliasDelta (); } this.Coder = coder; int prev = -1; foreach (var current in orderedList) { this.Add (current, prev); prev = current; } }
public void Load(BinaryReader Input) { this.Coder = IEncoder32GenericIO.Load (Input); this.Smaller = Input.ReadInt32 (); }
public static BitmapFromBitStream GetDiffSet_wt(short sample_step, IIEncoder32 coder = null) { return delegate (FakeBitmap b) { var rs = new DiffSet (); rs.Build (CreateSortedList (b), b.Count, sample_step, coder); return rs; }; }
public ListSDiffCoderRL(IList<int> list, IIEncoder32 coder, short blocksize) { this.Coder = coder; this.BlockSize = blocksize; this.Build (list); }
public void Load(BinaryReader Input) { var size = Input.ReadInt32 (); this.Alphabet = new WaveletLeaf[size]; this.Coder = IEncoder32GenericIO.Load (Input); // Console.WriteLine ("Input.Position: {0}", Input.BaseStream.Position); this.Root = this.LoadNode (Input, null) as WaveletInner; }
public void Build(IIEncoder32 coder, int alphabet_size, IList<int> text) { this.Alphabet = new WaveletLeaf[alphabet_size]; this.Root = new WaveletInner (null, true); this.Coder = coder; for (int i = 0; i < text.Count; i++) { this.Add (text [i]); } this.FinishBuild (this.Root); }
public void Build(IList<int> text, int alphabet_size, IIEncoder32 coder = null) { this.Alphabet = new WT_Leaf[alphabet_size]; this.Root = new WT_Inner (null, true); if (coder == null) { coder = new BinaryCoding(ListIFS.GetNumBits(alphabet_size-1)); } this.Coder = coder; for (int i = 0; i < text.Count; i++) { this.Add (text [i]); } this.FinishBuild (this.Root); }
/// <summary> /// Build the specified seq, sigma and t. /// </summary> public void Build(IList<int> seq, int sigma, short t = 16, IIEncoder32 rl2_coder = null, short rl2_block_size = 127) { // A counting sort construction of the permutation var counters = new int[sigma]; foreach (var s in seq) { if (s + 1 < sigma) { counters [s + 1]++; } } for (int i = 1; i < sigma; i++) { counters [i] += counters [i - 1]; } var n = seq.Count; var P = new int[n]; for (int i = 0; i < n; i++) { var sym = seq [i]; var pos = counters [sym]; P [pos] = i; counters [sym] = pos + 1; } // the bitmap to save the lengths var lens = new BitStream32 (); int prevc = 0; foreach (var c in counters) { var len = c - prevc; prevc = c; lens.Write (true); lens.Write (false, len); } // an additional 1 to the end, to simplify source code lens.Write (true); var bb_lens = new FakeBitmap (lens); this.LENS = BitmapBuilder (bb_lens); this.PERM = new SuccRL2CyclicPerms_MRRR (); if (rl2_coder == null) { rl2_coder = new EliasGamma32 (); } var build_params = new SuccRL2CyclicPerms_MRRR.BuildParams (rl2_coder, rl2_block_size); this.PERM.Build (P, t, build_params); }
public void Load(BinaryReader Input) { this.Coder = IEncoder32GenericIO.Load(Input); this.bits_per_code = Input.ReadByte(); }
public void Build(IList<int> orderedList, short b, IIEncoder32 coder = null) { int n = 0; if (orderedList.Count > 0) { n = orderedList[orderedList.Count - 1] + 1; } this.Build (orderedList, n, b, coder); }
public ZeroCoding(IIEncoder32 coder, int smaller) { this.Smaller = smaller; this.Coder = coder; }
/// <summary> /// build methods /// </summary> public void Build(IEnumerable<int> orderedList, int n, short b, IIEncoder32 coder = null) { this.N = n; this.B = b; this.M = 0; if (coder == null) { coder = new EliasDelta (); } this.Coder = coder; int prev = -1; var ctx = new BitStreamCtxRL (); foreach (var current in orderedList) { if (current == 0) { prev = AccStart; } this.M++; int diff = current - prev; //Console.WriteLine ("DIFF {0}, num: {1}", diff, num++); if (diff == 1) { ++ctx.run_len; } else { this.Commit (ctx); // Console.WriteLine ("%%%%%% diff: {0}, prev: {1}, curr: {2}", diff, prev, current); Coder.Encode (this.Stream, diff); } if (this.M % this.B == 0) { this.Commit (ctx); this.Samples.Add (current); this.Offsets.Add (this.Stream.CountBits); } if (current >= this.N) { this.N = current + 1; } prev = current; } this.Commit (ctx); /*for (int i = 0; i < this.Samples.Count; i++) { Console.WriteLine ("-- i: {0}, samples: {1}, offset: {2}", i, Samples[i], Offsets[i]); }*/ }
public BuildParams(IIEncoder32 c, short b) { this.coder = c; this.block_size = b; }
public override void Load(BinaryReader R) { this.N = R.ReadInt32 (); this.M = R.ReadInt32 (); this.B = R.ReadInt16 (); int num_samples = this.M / this.B; this.Samples = new int[ num_samples ]; this.Offsets = new long[ num_samples ]; PrimitiveIO<int>.ReadFromFile (R, num_samples, this.Samples); PrimitiveIO<long>.ReadFromFile (R, num_samples, this.Offsets); // Console.WriteLine ("xxxxxx load samples.count {0}. N: {1}, M: {2}, B: {3}", this.Samples.Count, this.N, this.M, this.B); this.Coder = IEncoder32GenericIO.Load (R); this.Stream = new BitStream32 (); this.Stream.Load (R); }