Exemplo n.º 1
0
            internal Octets Final(Octets oin)
            {
                if (oin.size() == 0 && legacy_in == 0)
                    return oin;

                Octets oout = Update(oin);
                int osize = oout.size();
                oout.reserve(osize + (int)legacy_in * 9 / 8 + 6);
                byte[] obuf = oout.buffer();
                uint opos = (uint)osize;
                compress_block(obuf, ref opos, legacy_in);
                oout.resize((int)opos);
                return oin.swap(oout);
            }
Exemplo n.º 2
0
            internal Octets Update(Octets oin)
            {
                Octets oout = new Octets();
                uint ipos = 0, opos = 0;
                byte[] ibuf = oin.buffer();
                uint isize = (uint)oin.size();
                uint remain = (uint)MPPC.MPPC_HIST_LEN - histptr - legacy_in;

                if (isize >= remain)
                {
                    oout.resize((int)(isize + legacy_in) * 9 / 8 + 6);
                    byte[] obuf = oout.buffer();
                    Array.Copy(ibuf, ipos, history, histptr + legacy_in, remain);
                    isize -= remain;
                    ipos += remain;
                    compress_block(obuf, ref opos, remain + legacy_in);
                    histptr = 0;

                    for (; isize >= (uint)MPPC.MPPC_HIST_LEN;
                        isize -= (uint)MPPC.MPPC_HIST_LEN, ipos += (uint)MPPC.MPPC_HIST_LEN)
                    {
                        Array.Copy(ibuf, ipos, history, histptr, (int)MPPC.MPPC_HIST_LEN);
                        compress_block(obuf, ref opos, (uint)MPPC.MPPC_HIST_LEN);
                        histptr = 0;
                    }
                    oout.resize((int)opos);
                }

                Array.Copy(ibuf, ipos, history, histptr + legacy_in, isize);
                legacy_in += isize;
                return oin.swap(oout);
            }