arithmeticcoderc.h

来自「转自德国Eric Bodden的数据压缩算术编码专著。有极强的学术价值。」· C头文件 代码 · 共 46 行

H
46
字号
#ifndef __ARITHMETICCODERC_H__
#define __ARITHMETICCODERC_H__

#include <fstream>
using namespace std;

class ArithmeticCoderC  
{
public:
	ArithmeticCoderC();

	void SetFile( fstream *file );

	void Encode( const unsigned int low_count, 
	             const unsigned int high_count, 
	             const unsigned int total );
	void EncodeFinish();

	void DecodeStart();
	unsigned int DecodeTarget( const unsigned int total );
	void Decode( const unsigned int low_count, 
	             const unsigned int high_count );

protected:
	// bit operations
	void SetBit( const unsigned char bit );
	void SetBitFlush();
	unsigned char GetBit();

	unsigned char mBitBuffer;
	unsigned char mBitCount;

	// in-/output stream
	fstream *mFile;

	// encoder & decoder
	unsigned int mLow;
	unsigned int mHigh;
	unsigned int mStep;
	unsigned int mScale;

	// decoder
	unsigned int mBuffer;
};

#endif

⌨️ 快捷键说明

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