-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathPpmModel.hpp
More file actions
57 lines (31 loc) · 1.08 KB
/
Copy pathPpmModel.hpp
File metadata and controls
57 lines (31 loc) · 1.08 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
/*
* Reference arithmetic coding
*
* Copyright (c) Project Nayuki
* MIT License. See readme file.
* https://www.nayuki.io/page/reference-arithmetic-coding
*/
#pragma once
#include <cstdint>
#include <memory>
#include <vector>
#include "FrequencyTable.hpp"
class PpmModel final {
/*---- Helper structure ----*/
public: class Context final {
public: SimpleFrequencyTable frequencies;
public: std::vector<std::unique_ptr<Context> > subcontexts;
public: explicit Context(std::uint32_t symbols, bool hasSubctx);
};
/*---- Fields ----*/
public: int modelOrder;
private: std::uint32_t symbolLimit;
private: std::uint32_t escapeSymbol;
public: std::unique_ptr<Context> rootContext;
public: SimpleFrequencyTable orderMinus1Freqs;
/*---- Constructor ----*/
public: explicit PpmModel(int order, std::uint32_t symLimit, std::uint32_t escapeSym);
/*---- Methods ----*/
public: void incrementContexts(const std::vector<std::uint32_t> &history, std::uint32_t symbol);
private: static std::vector<std::uint32_t> makeEmpty(std::uint32_t len);
};