decompress static method

List<int> decompress(
  1. List<int> input
)

Decompresses the input data using DEFLATE algorithm

Implementation

static List<int> decompress(List<int> input) {
  _BitReader bitReader = _BitReader(input);
  final int cmf = bitReader.readByte();
  int cm = cmf & 15;
  if (cm != 8) {
    throw MessageException('invalid CM');
  }
  int cinfo = (cmf >> 4) & 15; // Compression info
  if (cinfo > 7) {
    throw MessageException('invalid CINFO');
  }
  int flg = bitReader.readByte();
  if ((cmf * 256 + flg) % 31 != 0) {
    throw MessageException('CMF+FLG checksum failed');
  }
  int fdict = (flg >> 5) & 1;
  if (fdict != 0) {
    throw MessageException('preset dictionary not supported');
  }
  List<int> out = _inflate(bitReader); // decompress DEFLATE data

  bitReader.readBytes(4);
  return out;
}