⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bittreecoder.h

📁 经过项目量产验证的代码.开发环境是sparc+vxworks. 这个LZMA是专门为sparc做的优化压缩,性能是最好的.
💻 H
字号:
// BitTreeCoder.h#ifndef __BITTREECODER_H#define __BITTREECODER_H#include "AriBitCoder.h"#include "RCDefs.h"class CBitTreeDecoder3{  CBitDecoder m_Models[1 << 3];public:  void Init()  {    for(int i = 1; i < (1 << 3); i++)      m_Models[i].Init();  }  int Decode(CRangeDecoder *rangeDecoder)  {    int modelIndex = 1;    RC_INIT_VAR    for(int bitIndex = 3; bitIndex > 0; bitIndex--)    {      // modelIndex = (modelIndex << 1) + m_Models[modelIndex].Decode(rangeDecoder);      RC_GETBIT(m_Models[modelIndex].m_Probability, modelIndex)    }    RC_FLUSH_VAR    return modelIndex - (1 << 3);  };};class CBitTreeDecoder6{  CBitDecoder m_Models[1 << 6];public:  void Init()  {    for(int i = 1; i < (1 << 6); i++)      m_Models[i].Init();  }  int Decode(CRangeDecoder *rangeDecoder)  {    int modelIndex = 1;    RC_INIT_VAR    for(int bitIndex = 6; bitIndex > 0; bitIndex--)    {      // modelIndex = (modelIndex << 1) + m_Models[modelIndex].Decode(rangeDecoder);      RC_GETBIT(m_Models[modelIndex].m_Probability, modelIndex)    }    RC_FLUSH_VAR    return modelIndex - (1 << 6);  };};class CBitTreeDecoder8{  CBitDecoder m_Models[1 << 8];public:  void Init()  {    for(int i = 1; i < (1 << 8); i++)      m_Models[i].Init();  }  int Decode(CRangeDecoder *rangeDecoder)  {    int modelIndex = 1;    RC_INIT_VAR    for(int bitIndex = 8; bitIndex > 0; bitIndex--)    {      // modelIndex = (modelIndex << 1) + m_Models[modelIndex].Decode(rangeDecoder);      RC_GETBIT(m_Models[modelIndex].m_Probability, modelIndex)    }    RC_FLUSH_VAR    return modelIndex - (1 << 8);  };};class CReverseBitTreeDecoder2{  CBitDecoder *m_Models;  int m_NumBitLevels;public:  CReverseBitTreeDecoder2(): m_Models(0) { }  BYTE *Create(BYTE *memory, int numBitLevels)  {    m_NumBitLevels = numBitLevels;    // m_Models = new CBitDecoder<aNumMoveBits>[1 << numBitLevels];    // return (m_Models != 0);    m_Models = (CBitDecoder *)memory;    return memory + sizeof(CBitDecoder) * (1 << numBitLevels);  }  void Init()  {    int numModels = 1 << m_NumBitLevels;    for(int i = 1; i < numModels; i++)      m_Models[i].Init();  }  int Decode(CRangeDecoder *rangeDecoder)  {    int modelIndex = 1;    int symbol = 0;    RC_INIT_VAR    for(int bitIndex = 0; bitIndex < m_NumBitLevels; bitIndex++)    {      // int bit = m_Models[modelIndex].Decode(rangeDecoder);      // modelIndex <<= 1;      // modelIndex += bit;      // symbol |= (bit << bitIndex);      RC_GETBIT2(m_Models[modelIndex].m_Probability, modelIndex, ; , symbol |= (1 << bitIndex))    }    RC_FLUSH_VAR    return symbol;  };};class CReverseBitTreeDecoder4{  CBitDecoder m_Models[1 << 4];public:  void Init()  {    for(int i = 1; i < (1 << 4); i++)      m_Models[i].Init();  }  int Decode(CRangeDecoder *rangeDecoder)  {    int modelIndex = 1;    int symbol = 0;    RC_INIT_VAR    for(int bitIndex = 0; bitIndex < 4; bitIndex++)    {      // int bit = m_Models[modelIndex].Decode(rangeDecoder);      // modelIndex <<= 1;      // modelIndex += bit;      // symbol |= (bit << bitIndex);      RC_GETBIT2(m_Models[modelIndex].m_Probability, modelIndex, ; , symbol |= (1 << bitIndex))    }    RC_FLUSH_VAR    return symbol;  }};#endif

⌨️ 快捷键说明

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