1/*
2 * DeltaEncoder
3 *
4 * Author: Lasse Collin <lasse.collin@tukaani.org>
5 *
6 * This file has been put into the public domain.
7 * You can do whatever you want with this file.
8 */
9
10package org.tukaani.xz.delta;
11
12public class DeltaEncoder extends DeltaCoder {
13    public DeltaEncoder(int distance) {
14        super(distance);
15    }
16
17    public void encode(byte[] in, int in_off, int len, byte[] out) {
18        for (int i = 0; i < len; ++i) {
19            byte tmp = history[(distance + pos) & DISTANCE_MASK];
20            history[pos-- & DISTANCE_MASK] = in[in_off + i];
21            out[i] = (byte)(in[in_off + i] - tmp);
22        }
23    }
24}
25