private static void checkEncode( DeltaZigzagEncoding.Encoder e, int[] data, int[] expected) { Assert2.assertArrayEquals(expected, e.encodeArray(data)); Assert2.assertEquals(data[data.Length - 1], e.getContextValue()); }
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); }