Ejemplo n.º 1
0
        public void uncompress(int[] inBuf, IntWrapper inPos, int inLen, int[] outBuf, IntWrapper outPos)
        {
            if (inLen == 0)
            {
                return;
            }

            int outLen = inBuf[inPos.get()];

            inPos.increment();

            DeltaZigzagEncoding.Decoder ctx = new DeltaZigzagEncoding.Decoder(0);
            int[] work = new int[BLOCK_LENGTH];

            int ip         = inPos.get();
            int op         = outPos.get();
            int outPosLast = op + outLen;

            for (; op < outPosLast; op += BLOCK_LENGTH)
            {
                int n = inBuf[ip++];
                ip += unpack(inBuf, ip, work, 0, (n >> 24) & 0x3F);
                ip += unpack(inBuf, ip, work, 32, (n >> 16) & 0x3F);
                ip += unpack(inBuf, ip, work, 64, (n >> 8) & 0x3F);
                ip += unpack(inBuf, ip, work, 96, (n >> 0) & 0x3F);
                ctx.decodeArray(work, 0, BLOCK_LENGTH, outBuf, op);
            }

            outPos.add(outLen);
            inPos.set(ip);
        }
        public void uncompress(int[] @in, IntWrapper inpos, int inlength, int[] @out, IntWrapper outpos)
        {
            int s          = 0;
            int val        = 0;
            int p          = inpos.get();
            int finalp     = inpos.get() + inlength;
            int tmpoutpos  = outpos.get();
            int initoffset = 0;

            for (int v = 0, shift = 0; p < finalp;)
            {
                val = @in[p];
                int c = (sbyte)(int)((uint)val >> s);
                s += 8;
                p += s >> 5;
                s  = s & 31;
                v += ((c & 127) << shift);
                if ((c & 128) == 128)
                {
                    @out[tmpoutpos] = v + initoffset;
                    initoffset      = @out[tmpoutpos];
                    tmpoutpos++;
                    v     = 0;
                    shift = 0;
                }
                else
                {
                    shift += 7;
                }
            }
            outpos.set(tmpoutpos);
            inpos.add(inlength);
        }
Ejemplo n.º 3
0
 /*@Override*/
 public void headlessUncompress(int[] @in, IntWrapper inpos, int inlength, int[] @out,
                                IntWrapper outpos, int num)
 {
     num = Util.greatestMultiple(num, BLOCK_SIZE);
     if (num > 0)
     {
         int d = PForDelta.decompressOneBlock(@out, @in, num);
         inpos.add(d / 32);
         outpos.add(num);
     }
 }
Ejemplo n.º 4
0
 /*@Override*/
 public void headlessCompress(int[] @in, IntWrapper inpos, int inlength, int[] @out,
                              IntWrapper outpos)
 {
     inlength = Util.greatestMultiple(inlength, BLOCK_SIZE);
     if (inlength > 0)
     {
         int[] out2 = PForDelta.compressOneBlockOpt(@in, inlength);
         inpos.add(inlength);
         Array.Copy(out2, 0, @out, outpos.get(), out2.Length);
         outpos.add(out2.Length);
     }
 }
        public void headlessCompress(int[] @in, IntWrapper inpos, int inlength, int[] @out, IntWrapper outpos, IntWrapper initvalue)
        {
            inlength = Util.greatestMultiple(inlength, BLOCK_SIZE);
            if (inlength == 0)
            {
                return;
            }
            int tmpoutpos  = outpos.get();
            int initoffset = initvalue.get();

            initvalue.set(@in[inpos.get() + inlength - 1]);
            int s = inpos.get();

            for (; s + BLOCK_SIZE * 4 - 1 < inpos.get() + inlength; s += BLOCK_SIZE * 4)
            {
                int mbits1      = Util.maxdiffbits(initoffset, @in, s, BLOCK_SIZE);
                int initoffset2 = @in[s + 31];
                int mbits2      = Util.maxdiffbits(initoffset2, @in, s + BLOCK_SIZE, BLOCK_SIZE);
                int initoffset3 = @in[s + BLOCK_SIZE + 31];
                int mbits3      = Util
                                  .maxdiffbits(initoffset3, @in, s + 2 * BLOCK_SIZE, BLOCK_SIZE);
                int initoffset4 = @in[s + 2 * BLOCK_SIZE + 31];
                int mbits4      = Util
                                  .maxdiffbits(initoffset4, @in, s + 3 * BLOCK_SIZE, BLOCK_SIZE);
                @out[tmpoutpos++] = (mbits1 << 24) | (mbits2 << 16) | (mbits3 << 8)
                                    | (mbits4);
                IntegratedBitPacking.integratedpack(initoffset, @in, s, @out,
                                                    tmpoutpos, mbits1);
                tmpoutpos += mbits1;
                IntegratedBitPacking.integratedpack(initoffset2, @in, s + BLOCK_SIZE, @out,
                                                    tmpoutpos, mbits2);
                tmpoutpos += mbits2;
                IntegratedBitPacking.integratedpack(initoffset3, @in, s + 2 * BLOCK_SIZE,
                                                    @out, tmpoutpos, mbits3);
                tmpoutpos += mbits3;
                IntegratedBitPacking.integratedpack(initoffset4, @in, s + 3 * BLOCK_SIZE,
                                                    @out, tmpoutpos, mbits4);
                tmpoutpos += mbits4;
                initoffset = @in[s + 3 * BLOCK_SIZE + 31];
            }
            for (; s < inpos.get() + inlength; s += BLOCK_SIZE)
            {
                int mbits = Util.maxdiffbits(initoffset, @in, s, BLOCK_SIZE);
                @out[tmpoutpos++] = mbits;
                IntegratedBitPacking.integratedpack(initoffset, @in, s, @out,
                                                    tmpoutpos, mbits);
                tmpoutpos += mbits;
                initoffset = @in[s + 31];
            }
            inpos.add(inlength);
            outpos.set(tmpoutpos);
        }
        public void compress(int[] @in, IntWrapper inpos, int inlength, sbyte[] @out, IntWrapper outpos)
        {
            if (inlength == 0)
            {
                return;
            }
            int initoffset = 0;
            int outpostmp  = outpos.get();

            for (int k = inpos.get(); k < inpos.get() + inlength; ++k)
            {
                long val = (@in[k] - initoffset) & 0xFFFFFFFFL;  // To be consistent with unsigned integers in C/C++
                initoffset = @in[k];
                if (val < (1 << 7))
                {
                    @out[outpostmp++] = (sbyte)(val | (1 << 7));
                }
                else if (val < (1 << 14))
                {
                    @out[outpostmp++] = (sbyte)extract7bits(0, val);
                    @out[outpostmp++] = (sbyte)(extract7bitsmaskless(1, (val)) | (1 << 7));
                }
                else if (val < (1 << 21))
                {
                    @out[outpostmp++] = (sbyte)extract7bits(0, val);
                    @out[outpostmp++] = (sbyte)extract7bits(1, val);
                    @out[outpostmp++] = (sbyte)(extract7bitsmaskless(2, (val)) | (1 << 7));
                }
                else if (val < (1 << 28))
                {
                    @out[outpostmp++] = (sbyte)extract7bits(0, val);
                    @out[outpostmp++] = (sbyte)extract7bits(1, val);
                    @out[outpostmp++] = (sbyte)extract7bits(2, val);
                    @out[outpostmp++] = (sbyte)(extract7bitsmaskless(3, (val)) | (1 << 7));
                }
                else
                {
                    @out[outpostmp++] = (sbyte)extract7bits(0, val);
                    @out[outpostmp++] = (sbyte)extract7bits(1, val);
                    @out[outpostmp++] = (sbyte)extract7bits(2, val);
                    @out[outpostmp++] = (sbyte)extract7bits(3, val);
                    @out[outpostmp++] = (sbyte)(extract7bitsmaskless(4, (val)) | (1 << 7));
                }
            }
            outpos.set(outpostmp);
            inpos.add(inlength);
        }
        public void headlessUncompress(int[] @in, IntWrapper inpos, int inlength, int[] @out, IntWrapper outpos, int num, IntWrapper initvalue)
        {
            int outlength  = Util.greatestMultiple(num, BLOCK_SIZE);
            int tmpinpos   = inpos.get();
            int initoffset = initvalue.get();
            int s          = outpos.get();

            for (; s + BLOCK_SIZE * 4 - 1 < outpos.get() + outlength; s += BLOCK_SIZE * 4)
            {
                int mbits1 = (int)((uint)@in[tmpinpos] >> 24);
                int mbits2 = (int)((uint)@in[tmpinpos] >> 16) & 0xFF;
                int mbits3 = (int)((uint)@in[tmpinpos] >> 8) & 0xFF;
                int mbits4 = (@in[tmpinpos]) & 0xFF;

                ++tmpinpos;
                IntegratedBitPacking.integratedunpack(initoffset, @in, tmpinpos,
                                                      @out, s, mbits1);
                tmpinpos  += mbits1;
                initoffset = @out[s + 31];
                IntegratedBitPacking.integratedunpack(initoffset, @in, tmpinpos,
                                                      @out, s + BLOCK_SIZE, mbits2);
                tmpinpos  += mbits2;
                initoffset = @out[s + BLOCK_SIZE + 31];
                IntegratedBitPacking.integratedunpack(initoffset, @in, tmpinpos,
                                                      @out, s + 2 * BLOCK_SIZE, mbits3);
                tmpinpos  += mbits3;
                initoffset = @out[s + 2 * BLOCK_SIZE + 31];
                IntegratedBitPacking.integratedunpack(initoffset, @in, tmpinpos,
                                                      @out, s + 3 * BLOCK_SIZE, mbits4);
                tmpinpos  += mbits4;
                initoffset = @out[s + 3 * BLOCK_SIZE + 31];
            }
            for (; s < outpos.get() + outlength; s += BLOCK_SIZE)
            {
                int mbits = @in[tmpinpos];
                ++tmpinpos;
                IntegratedBitPacking.integratedunpack(initoffset, @in, tmpinpos,
                                                      @out, s, mbits);
                initoffset = @out[s + 31];

                tmpinpos += mbits;
            }
            outpos.add(outlength);
            initvalue.set(initoffset);
            inpos.set(tmpinpos);
        }
Ejemplo n.º 8
0
        public void compress(int[] inBuf, IntWrapper inPos, int inLen, int[] outBuf, IntWrapper outPos)
        {
            inLen = inLen - inLen % BLOCK_LENGTH;
            if (inLen == 0)
            {
                return;
            }

            outBuf[outPos.get()] = inLen;
            outPos.increment();

            int context = 0;

            int[] work = new int[32];

            int op        = outPos.get();
            int ip        = inPos.get();
            int inPosLast = ip + inLen;

            for (; ip < inPosLast; ip += BLOCK_LENGTH)
            {
                int bits1 = xorMaxBits(inBuf, ip + 0, 32, context);
                int bits2 = xorMaxBits(inBuf, ip + 32, 32,
                                       inBuf[ip + 31]);
                int bits3 = xorMaxBits(inBuf, ip + 64, 32,
                                       inBuf[ip + 63]);
                int bits4 = xorMaxBits(inBuf, ip + 96, 32,
                                       inBuf[ip + 95]);
                outBuf[op++] = (bits1 << 24) | (bits2 << 16)
                               | (bits3 << 8) | (bits4 << 0);
                op += xorPack(inBuf, ip + 0, outBuf, op, bits1,
                              context, work);
                op += xorPack(inBuf, ip + 32, outBuf, op, bits2,
                              inBuf[ip + 31], work);
                op += xorPack(inBuf, ip + 64, outBuf, op, bits3,
                              inBuf[ip + 63], work);
                op += xorPack(inBuf, ip + 96, outBuf, op, bits4,
                              inBuf[ip + 95], work);
                context = inBuf[ip + 127];
            }

            inPos.add(inLen);
            outPos.set(op);
        }
Ejemplo n.º 9
0
        public void headlessCompress(int[] @in, IntWrapper inpos, int inlength, int[] @out, IntWrapper outpos)
        {
            inlength = Util.greatestMultiple(inlength, BLOCK_SIZE);
            int tmpoutpos = outpos.get();
            int s         = inpos.get();

            for (; s + BLOCK_SIZE * 4 - 1 < inpos.get() + inlength; s += BLOCK_SIZE * 4)
            {
                int mbits1 = Util.maxbits(@in, s, BLOCK_SIZE);

                int mbits2 = Util.maxbits(@in, s + BLOCK_SIZE, BLOCK_SIZE);

                int mbits3 = Util.maxbits(@in, s + 2 * BLOCK_SIZE, BLOCK_SIZE);

                int mbits4 = Util.maxbits(@in, s + 3 * BLOCK_SIZE, BLOCK_SIZE);
                @out[tmpoutpos++] = (mbits1 << 24) | (mbits2 << 16)
                                    | (mbits3 << 8) | (mbits4);
                BitPacking.fastpackwithoutmask(@in, s, @out, tmpoutpos,
                                               mbits1);
                tmpoutpos += mbits1;
                BitPacking.fastpackwithoutmask(@in, s + BLOCK_SIZE, @out,
                                               tmpoutpos, mbits2);
                tmpoutpos += mbits2;
                BitPacking.fastpackwithoutmask(@in, s + 2 * BLOCK_SIZE, @out,
                                               tmpoutpos, mbits3);
                tmpoutpos += mbits3;
                BitPacking.fastpackwithoutmask(@in, s + 3 * BLOCK_SIZE, @out,
                                               tmpoutpos, mbits4);
                tmpoutpos += mbits4;
            }
            for (; s < inpos.get() + inlength; s += BLOCK_SIZE)
            {
                int mbits = Util.maxbits(@in, s, BLOCK_SIZE);
                @out[tmpoutpos++] = mbits;
                BitPacking.fastpackwithoutmask(@in, s, @out, tmpoutpos,
                                               mbits);
                tmpoutpos += mbits;
            }
            inpos.add(inlength);
            outpos.set(tmpoutpos);
        }
Ejemplo n.º 10
0
        public void uncompress(int[] inBuf, IntWrapper inPos, int inLen, int[] outBuf, IntWrapper outPos)
        {
            if (inLen == 0)
            {
                return;
            }

            int outLen = inBuf[inPos.get()];

            inPos.increment();

            int context = 0;

            int[] work = new int[32];

            int ip         = inPos.get();
            int op         = outPos.get();
            int outPosLast = op + outLen;

            for (; op < outPosLast; op += BLOCK_LENGTH)
            {
                int bits1 = (int)((uint)inBuf[ip] >> 24);
                int bits2 = (int)((uint)inBuf[ip] >> 16) & 0xFF;
                int bits3 = (int)((uint)inBuf[ip] >> 8) & 0xFF;
                int bits4 = (int)((uint)inBuf[ip] >> 0) & 0xFF;
                ++ip;
                ip += xorUnpack(inBuf, ip, outBuf, op + 0, bits1,
                                context, work);
                ip += xorUnpack(inBuf, ip, outBuf, op + 32, bits2,
                                outBuf[op + 31], work);
                ip += xorUnpack(inBuf, ip, outBuf, op + 64, bits3,
                                outBuf[op + 63], work);
                ip += xorUnpack(inBuf, ip, outBuf, op + 96, bits4,
                                outBuf[op + 95], work);
                context = outBuf[op + 127];
            }

            outPos.add(outLen);
            inPos.set(ip);
        }
Ejemplo n.º 11
0
        public void uncompress(sbyte[] @in, IntWrapper inpos, int inlength, int[] @out, IntWrapper outpos)
        {
            int p          = inpos.get();
            int initoffset = 0;
            int finalp     = inpos.get() + inlength;
            int tmpoutpos  = outpos.get();

            for (int v = 0; p < finalp; @out[tmpoutpos++] = (initoffset = initoffset + v))
            {
                v = @in[p] & 0x7F;
                if (@in[p] < 0)
                {
                    p += 1;
                    continue;
                }
                v = ((@in[p + 1] & 0x7F) << 7) | v;
                if (@in[p + 1] < 0)
                {
                    p += 2;
                    continue;
                }
                v = ((@in[p + 2] & 0x7F) << 14) | v;
                if (@in[p + 2] < 0)
                {
                    p += 3;
                    continue;
                }
                v = ((@in[p + 3] & 0x7F) << 21) | v;
                if (@in[p + 3] < 0)
                {
                    p += 4;
                    continue;
                }
                v  = ((@in[p + 4] & 0x7F) << 28) | v;
                p += 5;
            }
            outpos.set(tmpoutpos);
            inpos.add(p);
        }
Ejemplo n.º 12
0
        public void compress(int[] inBuf, IntWrapper inPos, int inLen, int[] outBuf, IntWrapper outPos)
        {
            inLen = inLen - inLen % BLOCK_LENGTH;
            if (inLen == 0)
            {
                return;
            }

            outBuf[outPos.get()] = inLen;
            outPos.increment();

            DeltaZigzagEncoding.Encoder ctx = new DeltaZigzagEncoding.Encoder(0);
            int[] work = new int[BLOCK_LENGTH];

            int op        = outPos.get();
            int ip        = inPos.get();
            int inPosLast = ip + inLen;

            for (; ip < inPosLast; ip += BLOCK_LENGTH)
            {
                ctx.encodeArray(inBuf, ip, BLOCK_LENGTH, work);
                int bits1 = Util.maxbits32(work, 0);
                int bits2 = Util.maxbits32(work, 32);
                int bits3 = Util.maxbits32(work, 64);
                int bits4 = Util.maxbits32(work, 96);
                outBuf[op++] = (bits1 << 24) | (bits2 << 16)
                               | (bits3 << 8) | (bits4 << 0);
                op += pack(work, 0, outBuf, op, bits1);
                op += pack(work, 32, outBuf, op, bits2);
                op += pack(work, 64, outBuf, op, bits3);
                op += pack(work, 96, outBuf, op, bits4);
            }

            inPos.add(inLen);
            outPos.set(op);
        }
Ejemplo n.º 13
0
        public void compress(int[] @in, IntWrapper inpos, int inlength, int[] @out, IntWrapper outpos)
        {
            if (inlength == 0)
            {
                return;
            }
            int initoffset = 0;

            ByteBuffer buf = ByteBuffer.allocateDirect(inlength * 8);

            buf.order(ByteOrder.LITTLE_ENDIAN);

            for (int k = inpos.get(); k < inpos.get() + inlength; ++k)
            {
                long val = (@in[k] - initoffset) & 0xFFFFFFFFL; // To be consistent with unsigned integers in C/C++
                initoffset = @in[k];
                if (val < (1 << 7))
                {
                    buf.put((sbyte)(val | (1 << 7)));
                }
                else if (val < (1 << 14))
                {
                    buf.put((sbyte)extract7bits(0, val));
                    buf.put((sbyte)(extract7bitsmaskless(1, (val)) | (1 << 7)));
                }
                else if (val < (1 << 21))
                {
                    buf.put((sbyte)extract7bits(0, val));
                    buf.put((sbyte)extract7bits(1, val));
                    buf.put((sbyte)(extract7bitsmaskless(2, (val)) | (1 << 7)));
                }
                else if (val < (1 << 28))
                {
                    buf.put((sbyte)extract7bits(0, val));
                    buf.put((sbyte)extract7bits(1, val));
                    buf.put((sbyte)extract7bits(2, val));
                    buf.put((sbyte)(extract7bitsmaskless(3, (val)) | (1 << 7)));
                }
                else
                {
                    buf.put((sbyte)extract7bits(0, val));
                    buf.put((sbyte)extract7bits(1, val));
                    buf.put((sbyte)extract7bits(2, val));
                    buf.put((sbyte)extract7bits(3, val));
                    buf.put((sbyte)(extract7bitsmaskless(4, (val)) | (1 << 7)));
                }
            }
            while (buf.position() % 4 != 0)
            {
                buf.put((sbyte)0);
            }
            int length = buf.position();

            buf.flip();
            IntBuffer ibuf = buf.asIntBuffer();

            ibuf.get(@out, outpos.get(), length / 4);

            outpos.add(length / 4);
            inpos.add(inlength);
        }