arith.h

来自「wavelet codec there are 34 files with co」· C头文件 代码 · 共 49 行

H
49
字号

// These objects implement arithmetic coding as described in
// Bell, Cleary, and Witten "Text Compression" Prentice Hall.

#ifndef _ARITH_CODER_
#define _ARITH_CODER_

#include <iostream.h>
#include "iHisto.h"
#include "BitIO.h"

class CodingValues {
public:
    long low, high, value;
    static const int CodeValueBits;
    static const long MaxFreq;
    static const long One;
    static const long Qtr;
    static const long Half;
    static const long ThreeQtr;
};		

class ArithEncoder : public CodingValues {    
    BitOut &output;
    inline void bpf(int bit)
    {
	output.output_bit(bit);
	for (int i = 0; i < bitsToFollow; i++) {
	    output.output_bit(1 - bit);
	}
	bitsToFollow = 0;
    }
public:
    ArithEncoder(BitOut &bo);
    void Encode(int count, int countLeft, int countTot);
    void flush(void);
    int bitsToFollow;
};

class ArithDecoder : public CodingValues {
    BitIn &input;
public:
    ArithDecoder(BitIn &bi);
    int Decode(iHistogram &h);
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?