protected override uint DecodePacket(out byte[] packet) { if (nextBlock >= codecInfo.Count) { // No more data packet = null; return(0); } packet = outputBuffer; BlockCodecInfo info = codecInfo[nextBlock]; nextBlock++; BinReader reader = currentChunk.GetReader(); // .IMX file reader.Position = info.Offset; reader.Read(inputBuffer, 0, info.CompressedSize); uint result; switch (info.Codec) { case 0x00: // Uncompressed result = DecodeUncompressed(inputBuffer, packet, info.CompressedSize); break; case 0x01: case 0x02: // case 0x03: // case 0x0A: // case 0x0B: // case 0x0C: // packet = null; result = 0; break; case 0x0D: // result = DecodeVIMA(inputBuffer, packet, info.CompressedSize, 1); break; case 0x0F: // result = DecodeVIMA(inputBuffer, packet, info.CompressedSize, 2); break; default: throw new DecodingException("Unsupported IMC codec: {0}", info.Codec); } if (nextBlock >= codecInfo.Count) { result = lastBlockSize; } return(result); }
protected void ReadCompressionTable(Chunk compChunk) { codecInfo = new List <BlockCodecInfo>(); BinReader reader = compChunk.GetReader(); reader.Position = 4; uint count = reader.ReadU32BE(); reader.Position = 12; lastBlockSize = reader.ReadU32BE(); reader.Position = 16; for (int i = 0; i < count; i++) { BlockCodecInfo info = new BlockCodecInfo(); info.Offset = reader.ReadU32BE(); info.CompressedSize = reader.ReadU32BE(); info.Codec = reader.ReadS32BE(); uint skip = reader.ReadU32BE(); Debug.Assert(skip == 0, "Found unknown codec info != 0"); codecInfo.Add(info); } }