Repository navigation
Expand file tree
/
Copy pathDecompressor.cpp
More file actions
58 lines (43 loc) · 1.63 KB
/
Copy pathDecompressor.cpp
File metadata and controls
58 lines (43 loc) · 1.63 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
#include<bits/stdc++.h>
using namespace std;
#include "HeaderReader.h"
#include "CanonicalDecoder.h"
#include "BitReader.h"
int main(){
auto start = chrono::high_resolution_clock::now();
string compressedFile="compressed.huff";
string outputFile="output.jpg";
HeaderReader header;
header.readHeader(compressedFile);
CanonicalDecoder decoder(header.getHeaderData());
BitReader reader;
reader.decompressFile(compressedFile, outputFile, decoder.getDecodeTable(), header.getHeaderSize(),
header.getOriginalFileSize());
auto end = chrono::high_resolution_clock::now();
ifstream compressed(compressedFile, ios::binary | ios::ate);
long long compressedSize = compressed.tellg();
compressed.close();
ifstream output(outputFile, ios::binary | ios::ate);
long long outputSize = output.tellg();
output.close();
auto duration =
chrono::duration_cast<chrono::milliseconds>(end - start);
cout << "\nDecompression Completed Successfully\n\n";
if(compressedSize >= 1024)
cout << "Compressed Size : "
<< fixed << setprecision(2)
<< compressedSize / 1024.0 << " KB" << endl;
else
cout << "Compressed Size : "
<< compressedSize << " bytes" << endl;
if(outputSize >= 1024)
cout << "Output Size : "
<< fixed << setprecision(2)
<< outputSize / 1024.0 << " KB" << endl;
else
cout << "Output Size : "
<< outputSize << " bytes" << endl;
cout << "Time Taken : "
<< duration.count() << " ms" << endl;
return 0;
}