summaryrefslogtreecommitdiff
path: root/tools/src/gbagfx/huff.h
blob: 354cf7de52d6acfa437d478f8601682bb6594be1 (plain)
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
#ifndef HUFF_H
#define HUFF_H

union HuffNode;

struct HuffData {
    unsigned value : 31;
    unsigned isLeaf : 1;
};

struct HuffLeaf {
    struct HuffData header;
    unsigned char key;
};

struct HuffBranch {
    struct HuffData header;
    union HuffNode* left;
    union HuffNode* right;
};

union HuffNode {
    struct HuffData header;
    struct HuffLeaf leaf;
    struct HuffBranch branch;
};

typedef union HuffNode HuffNode_t;

struct BitEncoding {
    unsigned long long nbits : 6;
    unsigned long long bitstring : 58;
};

unsigned char* HuffCompress(unsigned char* buffer, int srcSize, int* compressedSize_p, int bitDepth);
unsigned char* HuffDecompress(unsigned char* buffer, int srcSize, int* uncompressedSize_p);

#endif // HUFF_H