public void checkDecodeSimple() { DeltaZigzagEncoding.Decoder d = new DeltaZigzagEncoding.Decoder(0); checkDecode(d, new int[] { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); }
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); }
private static void checkDecode( DeltaZigzagEncoding.Decoder d, int[] data, int[] expected) { int[] r = d.decodeArray(data); Assert2.assertArrayEquals(expected, r); Assert2.assertEquals(r[r.Length - 1], d.getContextValue()); }
public void checkZigzagDecoder() { DeltaZigzagEncoding.Decoder d = new DeltaZigzagEncoding.Decoder(0); Assert2.assertEquals(0, zigzagDecode(d, 0)); Assert2.assertEquals(-1, zigzagDecode(d, 1)); Assert2.assertEquals(1, zigzagDecode(d, 2)); Assert2.assertEquals(-2, zigzagDecode(d, 3)); Assert2.assertEquals(2, zigzagDecode(d, 4)); Assert2.assertEquals(-3, zigzagDecode(d, 5)); }
private static int zigzagDecode(DeltaZigzagEncoding.Decoder d, int value) { d.setContextValue(0); return(d.decodeInt(value)); }