我试图理解 fpaq0 aritmetic 压缩器的代码,但我无法完全理解它。这是代码的链接 - fpaq0.cpp
我无法准确理解 ct[512]['2] 和 cxt 是如何工作的。而且我也不太清楚解码器是如何工作的。为什么在编码每个字符之前调用 e.encode(0) 。
笔记; 我已经理解了链接中提出的算术编码器-数据压缩与算术编码
void update(int y) {
if (++ct[cxt][y] > 65534) {
ct[cxt][0] >>= 1;
ct[cxt][1] >>= 1;
}
if ((cxt+=cxt+y) >= 512)
cxt=1;
}
// Assume a stationary order 0 stream of 9-bit symbols
int p() const {
return 4096*(ct[cxt][1]+1)/(ct[cxt][0]+ct[cxt][1]+2);
}
inline void Encoder::encode(int y) {
// Update the range
const U32 xmid = x1 + ((x2-x1) >> 12) * predictor.p();
assert(xmid >= x1 && xmid …Run Code Online (Sandbox Code Playgroud)