Haben Sie eine Lösung gefunden? Ich habe mit Hilfe von Michael Cohen dies zu C# für die Dekompression übersetzt. http://volatility.googlecode.com/svn-history/r1609/branches/scudette/contrib/pyxpress/pyxpress.c
Meine Tests zeigt, dass es funktioniert gut, aber Test für sich selbst :)
private static int PAGE_SIZE = 0x00001000;
private static int XPRESS_ENCODE_MAGIC = 0x19880922;
private static int DELTA_PAGE = ((2 * PAGE_SIZE) - 1);
private static int UNCOMPRESSED_BLOCK_SIZE = (PAGE_SIZE * 0x10);
public static byte[] Xpress_Decompress(byte[] inputBuffer, int outputSize)
{
int outputIndex, inputIndex;
int indicator, indicatorBit;
int length;
int offset;
int nibbleIndex;
int nibbleIndicator;
int inputSize = inputBuffer.Length;
outputIndex = 0;
inputIndex = 0;
indicator = 0;
indicatorBit = 0;
length = 0;
offset = 0;
nibbleIndex = 0;
nibbleIndicator = XPRESS_ENCODE_MAGIC;
var outputBuffer = new byte[outputSize];
while ((outputIndex < outputSize) && (inputIndex < inputSize))
{
if (indicatorBit == 0)
{
if (inputIndex + 3 >= inputSize) goto Done;
indicator = GetInt(inputBuffer, inputIndex);
inputIndex += sizeof(int);
indicatorBit = 32;
}
indicatorBit--;
//* check whether the bit specified by IndicatorBit is set or not
//* set in Indicator. For example, if IndicatorBit has value 4
//* check whether the 4th bit of the value in Indicator is set
if (((indicator >> indicatorBit) & 1) == 0)
{
if (outputIndex >= outputSize)
goto Done;
outputBuffer[outputIndex] = inputBuffer[inputIndex];
inputIndex += sizeof(byte);
outputIndex += sizeof(byte);
}
else
{
if (inputIndex + 1 >= inputSize)
goto Done;
length = (inputBuffer[inputIndex + 1] << 8) | inputBuffer[inputIndex];
/*
if ((OutputIndex > 0xD0) && (OutputIndex < 0xF0))
{
printf("DECOMP: READ AT [0x%08X] = %04X \n", InputIndex, Length);
}
*/
inputIndex += sizeof(ushort);
offset = length/8;
length = length % 8;
//if ((OutputIndex > 0xD0) && (OutputIndex < 0xF0)) printf("--1 Len: %02X (%d)\n", Length, Length);
if (length == 7)
{
if (nibbleIndex == 0)
{
nibbleIndex = inputIndex;
if (inputIndex >= inputSize)
goto Done;
length = inputBuffer[inputIndex] % 16;
//if ((OutputIndex > 0xD0) && (OutputIndex < 0xF0)) printf("--2 Len: %02X (%d)\n", Length, Length);
inputIndex += sizeof(byte);
}
else
{
length = inputBuffer[nibbleIndex]/16;
//if ((OutputIndex > 0xD0) && (OutputIndex < 0xF0)) printf("--3 Len: %02X (%d)\n", Length, Length);
nibbleIndex = 0;
}
if (length == 15)
{
if (inputIndex >= inputSize) goto Done;
length = inputBuffer[inputIndex];
//if ((OutputIndex > 0xD0) && (OutputIndex < 0xF0)) printf("--4 Len: %02X (%d)\n", Length, Length);
inputIndex += sizeof(byte);
if (length == 255)
{
if (inputIndex + 2 >= inputSize) goto Done;
length = (inputBuffer[inputIndex + 1] << 8) | inputBuffer[inputIndex];
inputIndex += sizeof(ushort);
length -= (15 + 7);
}
length += 15;
//if ((OutputIndex > 0xD0) && (OutputIndex < 0xF0)) printf("--5 Len: %02X (%d)\n", Length, Length);
}
length += 7;
//if ((OutputIndex > 0xD0) && (OutputIndex < 0xF0)) printf("--6 Len: %02X (%d)\n", Length, Length);
}
length += 3;
//if ((OutputIndex > 0xD0) && (OutputIndex < 0xF0)) printf("--7 Len: %02X (%d)\n", Length, Length);
//if (Length > 280) printf("DECOMP DEBUG: [0x%08X]->[0x%08X] Len: %d Offset: %08X\n",
// OutputIndex, InputIndex, Length, Offset);
while (length != 0)
{
if ((outputIndex >= outputSize) || ((offset + 1) >= outputIndex)) break;
outputBuffer[outputIndex] = outputBuffer[outputIndex - offset - 1];
outputIndex += sizeof(byte);
length -= sizeof(byte);
}
}
}
Done:
if (outputIndex < outputBuffer.Length)
{
var buffer = new byte[outputIndex];
Buffer.BlockCopy(outputBuffer, 0, buffer, 0, outputIndex);
outputBuffer = buffer;
}
return outputBuffer;
}
public static int GetInt(byte[] buffer, int offset)
{
return
((int)buffer[offset]) |
((int)buffer[offset + 1] << 8) |
((int)buffer[offset + 2] << 16) |
((int)buffer[offset + 3] << 24);
}
Was mit Ihrer Suchmaschine der Wahl kaputt ist? mit mehreren verschiedenen Sprachen versucht, kann diese Antwort in Sekunden mit einer Suche nach "LZ77
Seph
MSDN Dokumente sagen, dass ihre Implementierung des Algorithmus ein wenig optimiert ist. Deshalb habe ich nach den genauen Dingen gesucht. Sonst hätte ich hier nicht gepostet. –
meine Erfahrung mit ihrer Version von LZFU war nur sie 'zwickten' es nur durch das Entfernen eines XOR, wenn Sie einen Ausgangspunkt wie diese Quelle haben, können Sie den Rest finden ist nur Lesen der msdn doc und sehen, ob der Code übereinstimmt. – Seph