forked from pjmikkol/bwtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntropyCoders.cpp
107 lines (98 loc) · 2.57 KB
/
EntropyCoders.cpp
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* @file EntropyCoders.cpp
* @author Dominik Kempa <[email protected]>
*
* @section LICENSE
*
* This file is part of bwtc.
*
* bwtc is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* bwtc is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bwtc. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
* Implementation of base classes for entropy coders.
*
*/
#include <iostream>
#include <string>
#include <vector>
#include "IFCoders.hpp"
#include "EntropyCoders.hpp"
#include "WaveletCoders.hpp"
#include "HuffmanCoders.hpp"
#include "ArithmeticCoders.hpp"
#include "MTFCoders.hpp"
#include "InterpolativeCoders.hpp"
namespace bwtc {
EntropyEncoder*
giveEntropyEncoder(char encoder) {
if(encoder == 'H') {
if(verbosity > 1) {
std::clog << "Using Huffman encoder\n";
}
return new HuffmanEncoder();
} else if(encoder=='W') {
if(verbosity > 1) {
std::clog << "Using Wavelet tree encoder\n";
}
return new WaveletEncoder(encoder);
} else if(encoder=='m') {
if(verbosity > 1) {
std::clog << "Using Arithmetic encoder\n";
}
return new ArithmeticEncoder();
} else if(encoder=='i') {
return new InterpolativeEncoder();
} else if(encoder=='G') {
return new IFEncoder();
}
else {
if(verbosity > 1) {
std::clog << "Using MTF encoder\n";
}
return new MTFEncoder(encoder);
}
}
EntropyDecoder* giveEntropyDecoder(char decoder) {
if(decoder == 'H') {
if(verbosity > 1) {
std::clog << "Using Huffman decoder\n";
}
return new HuffmanDecoder();
}
else if(decoder=='W') {
if(verbosity > 1) {
std::clog << "Using Wavelet tree decoder\n";
}
return new WaveletDecoder(decoder);
} else if(decoder=='m') {
if(verbosity > 1) {
std::clog << "Using Arithmetic decoder\n";
}
return new ArithmeticDecoder();
}
else if(decoder=='i') {
return new InterpolativeDecoder();
}
else if(decoder=='G') {
return new IFDecoder();
}
else {
if(verbosity > 1) {
std::clog << "Using MTF decoder\n";
}
return new MTFDecoder(decoder);
}
}
} // namespace bwtc