forked from kevinjlang/cpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fm85Compression.h
73 lines (50 loc) · 2.31 KB
/
fm85Compression.h
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
// Copyright 2018, Kevin Lang, Oath Research
#ifndef GOT_FM85_COMPRESSION_H
#include "common.h"
#include "fm85.h"
#include "fm85Util.h"
/****************************************/
#define MAYBE_FLUSH_BITBUF(wordarr,wordindex) \
if (bufbits >= 32) { \
(wordarr)[(wordindex)++] = (U32) (bitbuf & 0xffffffff); \
bitbuf = bitbuf >> 32; bufbits -= 32;}
#define MAYBE_FILL_BITBUF(wordarr,wordindex,minbits) \
if (bufbits < (minbits)) { \
bitbuf |= (((U64) (wordarr)[(wordindex)++]) << bufbits); \
bufbits += 32; \
}
/****************************************/
void makeTheDecodingTables (void); // call this at startup
/****************************************/
// Here "pairs" refers to row/column pairs that specify
// the positions of surprising values in the bit matrix.
// returns the number of compressedWords actually used
Long lowLevelCompressPairs (U32 * pairArray, // input
Long numPairs, // input
Long numBaseBits, // input
U32 * compressedWords); // output
void lowLevelUncompressPairs (U32 * pairArray, // output
Long numPairs, // input
Long numBaseBits, // input
U32 * compressedWords, // input
Long numCompressedWords); // input
/****************************************/
// This returns the number of compressedWords that were actually used. It is the caller's
// responsibility to ensure that the compressedWords array is long enough to prevent over-run.
Long lowLevelCompressBytes (U8 * byteArray, // input
Long numBytesToEncode, // input
U16 * encodingTable, // input
U32 * compressedWords); // output
/****************************************/
void lowLevelUncompressBytes (U8 * byteArray, // output
Long numBytesToDecode, // input (but refers to the output)
U16 * decodingTable, // input
U32 * compressedWords, // input
Long numCompressedWords); // input
/****************************************/
FM85 * fm85Compress (FM85 * uncompressedSketch); // returns a compressed copy of its input
FM85 * fm85Uncompress (FM85 * compressedSketch); // returns an updateable copy of its input
// Note: in the final system, compressed and uncompressed sketches will have different types
/****************************************/
#define GOT_FM85_COMPRESSION_H
#endif