Exemplo n.º 1
0
        public override IntField Decode(Stream input)
        {
            // Read size
            int w = (int)input.ReadUInt32Optim();
            int h = (int)input.ReadUInt32Optim();

            // Read probabilities
            ulong[] probs = CodecUtil.LoadFreqsCrappy(input, FieldcodeSymbols + 1);
            // Read fields
            ArithmeticSectionsCodec ac = new ArithmeticSectionsCodec(probs, 6);

            ac.Decode(input);
            var fields = new List <int[]>();

            for (int i = 1; i <= 3; i++)
            {
                fields.Add(ac.ReadSection());
            }

            // Undo fieldcode
            IntField transformed = CodecUtil.FieldcodeRunlengthsDe(fields, w, h, new RunLength01MaxSmartCodec(FieldcodeSymbols), this);

            // Undo predictive transform
            transformed.PredictionDeTransformDiff(Seer, 4);
            transformed.ArgbFromField(0, 3);
            return(transformed);
        }