fmi.h
来自「自适应算术编码。这个项目假设读者已经了解基本的算术压缩编码的概念。」· C头文件 代码 · 共 85 行
H
85 行
#ifndef __FREQUENCY_MODEL_CLASS_DECLARATION__
#define __FREQUENCY_MODEL_CLASS_DECLARATION__
// DWORD type declaration
#ifndef DWORD
#define DWORD unsigned long
#endif
// Frequency value limit
#define FMI_OVERFLOW_LIMIT ((DWORD)1 << 30)
class CFreqModIncr
{
public:
// Purpose : construction
CFreqModIncr()
: m_dwIncrement(0)
, m_pdwTable(0)
{}
// Purpose : destruction
virtual ~CFreqModIncr()
{ if (m_pdwTable) delete [] m_pdwTable; }
// Purpose : call to get total frequency of the model
// Returns : the total frequency of the model
DWORD GetTotalFrequency()
{ return m_pdwTable[0]; }
// Purpose : call to initialize the model
// Arguments :
// dwTotal = total number of elements to track
void Initialize(DWORD dwTotal);
// Purpose : call to uninitialize the model
void Uninitialize();
// Purpose : call to increase element's frequency and obtain
// the element's frequency interval bounds
// Arguments :
// dwIndex = index of the element
// rdwLeftBound = reference to a variable to keep the left bound
// rdwRightBound = reference to a variable to keep the right bound
void PassByIndex(
DWORD dwIndex,
DWORD &rdwLeftBound,
DWORD &rdwRightBound);
// Purpose : call to obtain the element whose frequency interval contains
// a given point and to increase the element's frequency
// Returns : the index of an element found
// Arguments :
// dwPoint = a given point
// rdwLeftBound = reference to a variable to keep the left bound
// rdwRightBound = reference to a variable to keep the right bound
DWORD PassByPoint(
DWORD dwPoint,
DWORD &rdwLeftBound,
DWORD &rdwRightBound);
// The value to increment frequencies by
DWORD m_dwIncrement;
protected:
// Total number of elements
DWORD m_dwTotal;
// Internal displacement start value
DWORD m_dwStartAddend;
// Frequency table in internal format
DWORD *m_pdwTable;
private:
// Purpose : called to keep frequencies nonzeroes, before
// reducing or upon initializing the model
void AdjustFrequencies();
// Purpose : called to prevent overflows, halves the frequencies
void ReduceByHalf();
};
#endif // __FREQUENCY_MODEL_CLASS_DECLARATION__
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?