uncompress static method
Implementation
static void uncompress(
InputBuffer compressed, int nCompressed, Uint16List? raw, int nRaw) {
if (nCompressed == 0) {
if (nRaw != 0) {
throw ImageException('Incomplete huffman data');
}
return;
}
final start = compressed.offset;
final im = compressed.readUint32();
final iM = compressed.readUint32();
compressed.skip(4); // tableLength
final nBits = compressed.readUint32();
if (im < 0 || im >= HUF_ENCSIZE || iM < 0 || iM >= HUF_ENCSIZE) {
throw ImageException('Invalid huffman table size');
}
compressed.skip(4);
final freq = List<int>.filled(HUF_ENCSIZE, 0);
final hdec = List<ExrHufDec>.generate(HUF_DECSIZE, (_) => ExrHufDec(),
growable: false);
unpackEncTable(compressed, nCompressed - 20, im, iM, freq);
if (nBits > 8 * (nCompressed - (compressed.offset - start))) {
throw ImageException('Error in header for Huffman-encoded data '
'(invalid number of bits).');
}
buildDecTable(freq, im, iM, hdec);
decode(freq, hdec, compressed, nBits, iM, nRaw, raw);
}