-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
53 lines (39 loc) · 1.31 KB
/
main.cpp
File metadata and controls
53 lines (39 loc) · 1.31 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
#include "tANS.h"
int main(int argc, char *argv[])
{
std::string fileName;
if (argc == 2)
fileName = argv[1];
else
fileName = "testFile.bin";
std::vector<int> input = readFileAsNibbles(fileName);
EncodedData data;
std::vector<int> symbols;
std::vector<int> counts;
std::vector<DecodeCol> decodeTable;
std::vector<EncodeCol> encodeTable;
symbols = findSymbols(input);
counts = countSymbols(input, symbols);
printf("Symbols and their counts\n");
printSymbols(symbols);
printCounts(counts);
printf("Sorted symbols and their counts\n");
sortCount(&counts, &symbols);
printSymbols(symbols);
printCounts(counts);
counts = normalizeCounts(counts, 64);
printf("Symbols and their normalized counts\n");
printSymbols(symbols);
printCounts(counts);
decodeTable = createDecodingTable(symbols, counts);
encodeTable = createEncodingTable(decodeTable, symbols);
data = encodeData(input, encodeTable);
std::vector<int> output = decodeData(&data, decodeTable, input.size());
if (!areVectorsEqual(input, output))
printf("Input and output doesn't match\n");
else
printf("Input and output matches\n");
//printEncodeTable(encodeTable, symbols);
//printDecodeTable(decodeTable);
return 0;
}