-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlpaq6.h
More file actions
73 lines (62 loc) · 1.43 KB
/
Copy pathlpaq6.h
File metadata and controls
73 lines (62 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#if !defined lpaq6_h_included
#define lpaq6_h_included
#pragma warning(disable:4554)
#define WIKI
#include <stdio.h>
// 8, 16, 32 bit unsigned types (adjust as appropriate)
typedef unsigned char U8;
typedef unsigned short U16;
typedef unsigned int U32;
template <int B>
class HashTable {
U8* t; // table: 1 element = B bytes: checksum,priority,data,data,...
const int NB; // size in bytes
public:
HashTable(int n);
U8* get(U32 i);
#ifdef WIKI
U8* get0(U32 i);
U8* get1(U32 i);
#endif
};
#define COMPRESS 1
#define DECOMPRESS 2
class Predictor;
class MatchModel;
class Encoder {
public:
#ifdef WIKI
HashTable<16> t4a; // cxt -> state
HashTable<16> t4b; // cxt -> state
#define t1a t4a
#define t2a t4a
#define t3a t4a
#define t1b t4b
#define t2b t4b
#define t3b t4b
#else
HashTable<16> t1; // cxt -> state
HashTable<16> t2; // cxt -> state
HashTable<16> t3; // cxt -> state
#define t1a t1
#define t2a t2
#define t3a t3
#define t1b t1
#define t2b t2
#define t3b t3
#endif
MatchModel* mm; // predicts next bit by matching context
FILE *archive; // Compressed data file
U32 x1, x2; // Range, initially [0, 1), scaled by 2^32
U32 x; // Decompress mode: last 4 input bytes of archive
U32 p;
int *add2order;
U32 Predictor_upd(int y);
Encoder(int m, FILE* f);
~Encoder();
void flush(); // call this when compression is finished
void compress(int c);
int decompress();
};
void set_PAQ_level(int level);
#endif