#include <asm/system.h>
|
#include <asm/system.h>
|
|
|
#define CRCI(x) (crci = (crci << 5) | (x))
|
#define CRCI(x) (crci = (crci << 5) | (x))
|
#define CRCO(x) (crco = (crco << 5) | (x))
|
#define CRCO(x) (crco = (crco << 5) | (x))
|
|
|
unsigned long decompress (unsigned char *in, unsigned char *out)
|
unsigned long decompress (unsigned char *in, unsigned char *out)
|
{
|
{
|
unsigned char hist[0x10000];
|
unsigned char hist[0x10000];
|
unsigned long size;
|
unsigned long size;
|
int b = 0, i;
|
int b = 0, i;
|
unsigned char *orig = in;
|
unsigned char *orig = in;
|
unsigned char *mask;
|
unsigned char *mask;
|
unsigned short hash = 0;
|
unsigned short hash = 0;
|
unsigned long crci = 0, crco = 0;
|
unsigned long crci = 0, crco = 0;
|
|
|
for (i = 0; i < 0x10000; i++) hist[i] = 0;
|
for (i = 0; i < 0x10000; i++) hist[i] = 0;
|
|
|
CRCI(*in); size = (*in++) << 24;
|
CRCI(*in); size = (*in++) << 24;
|
CRCI(*in); size |= (*in++) << 16;
|
CRCI(*in); size |= (*in++) << 16;
|
CRCI(*in); size |= (*in++) << 8;
|
CRCI(*in); size |= (*in++) << 8;
|
CRCI(*in); size |= (*in++) << 0;
|
CRCI(*in); size |= (*in++) << 0;
|
CRCI(*in); mask = in++;
|
CRCI(*in); mask = in++;
|
_print("Size = %x\n", size);
|
_print("Size = %x\n", size);
|
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
unsigned char c;
|
unsigned char c;
|
if ((*mask >> b) & 1) c = hist[hash];
|
if ((*mask >> b) & 1) c = hist[hash];
|
else CRCI(c = *in++);
|
else CRCI(c = *in++);
|
CRCO(*out++ = c);
|
CRCO(*out++ = c);
|
hist[hash] = c;
|
hist[hash] = c;
|
hash <<= 8;
|
hash <<= 8;
|
hash |= c;
|
hash |= c;
|
hash &= 0xffff;
|
hash &= 0xffff;
|
if (++b == 8) {
|
if (++b == 8) {
|
CRCI(*in);
|
CRCI(*in);
|
mask = in++;
|
mask = in++;
|
b = 0;
|
b = 0;
|
}
|
}
|
}
|
}
|
/*
|
/*
|
print_str ("compressed CRC = ");
|
print_str ("compressed CRC = ");
|
print_n (crci);
|
print_n (crci);
|
print_str ("\ndecompressed CRC = ");
|
print_str ("\ndecompressed CRC = ");
|
print_n (crco);
|
print_n (crco);
|
print_str ("\ndecompressed size = ");
|
print_str ("\ndecompressed size = ");
|
print_n (size);
|
print_n (size);
|
print_str (" end ");
|
print_str (" end ");
|
print_n (out);
|
print_n (out);
|
print_str ("\ncompressed size = ");
|
print_str ("\ncompressed size = ");
|
print_n (in - orig);
|
print_n (in - orig);
|
print_str (" end ");
|
print_str (" end ");
|
print_n (in);
|
print_n (in);
|
print_str ("\n");
|
print_str ("\n");
|
*/
|
*/
|
return size;
|
return size;
|
}
|
}
|
|
|
|
|