Calculate RLE for lossless data compression