OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [arch/] [or32/] [board/] [uncomp.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 862 simons
#include <asm/system.h>
2
 
3
#define CRCI(x) (crci = (crci << 5) | (x))
4
#define CRCO(x) (crco = (crco << 5) | (x))
5
 
6
unsigned long decompress (unsigned char *in, unsigned char *out)
7
{
8
  unsigned char hist[0x10000];
9
  unsigned long size;
10
  int b = 0, i;
11
  unsigned char *orig = in;
12
  unsigned char *mask;
13
  unsigned short hash = 0;
14
  unsigned long crci = 0, crco = 0;
15
 
16
  for (i = 0; i < 0x10000; i++) hist[i] = 0;
17
 
18
  CRCI(*in); size = (*in++) << 24;
19
  CRCI(*in); size |= (*in++) << 16;
20
  CRCI(*in); size |= (*in++) << 8;
21
  CRCI(*in); size |= (*in++) << 0;
22
  CRCI(*in); mask = in++;
23
_print("Size = %x\n", size);
24
  for (i = 0; i < size; i++) {
25
    unsigned char c;
26
    if ((*mask >> b) & 1) c = hist[hash];
27
    else CRCI(c = *in++);
28
    CRCO(*out++ = c);
29
    hist[hash] = c;
30
    hash <<= 8;
31
    hash |= c;
32
    hash &= 0xffff;
33
    if (++b == 8) {
34
      CRCI(*in);
35
      mask = in++;
36
      b = 0;
37
    }
38
  }
39
/*
40
  print_str ("compressed CRC = ");
41
  print_n (crci);
42
  print_str ("\ndecompressed CRC = ");
43
  print_n (crco);
44
  print_str ("\ndecompressed size = ");
45
  print_n (size);
46
  print_str (" end ");
47
  print_n (out);
48
  print_str ("\ncompressed  size = ");
49
  print_n (in - orig);
50
  print_str (" end ");
51
  print_n (in);
52
  print_str ("\n");
53
*/
54
  return size;
55
}
56
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.