亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lzmaencoder.h

?? lzma 壓縮 4.06version
?? H
字號:
// LZMA/Encoder.h

#ifndef __LZMA_ENCODER_H
#define __LZMA_ENCODER_H

#include "../../../Common/MyCom.h"
#include "../../../Common/Alloc.h"
#include "../../ICoder.h"
#include "../LZ/IMatchFinder.h"
#include "../RangeCoder/RangeCoderBitTree.h"

#include "LZMA.h"

namespace NCompress {
namespace NLZMA {

typedef NRangeCoder::CBitEncoder<kNumMoveBits> CMyBitEncoder;

class CBaseState
{
protected:
  CState _state;
  Byte _previousByte;
  bool _peviousIsMatch;
  UInt32 _repDistances[kNumRepDistances];
  void Init()
  {
    _state.Init();
    _previousByte = 0;
    _peviousIsMatch = false;
    for(UInt32 i = 0 ; i < kNumRepDistances; i++)
      _repDistances[i] = 0;
  }
};

struct COptimal
{
  CState State;

  bool Prev1IsChar;
  bool Prev2;

  UInt32 PosPrev2;
  UInt32 BackPrev2;     

  UInt32 Price;    
  UInt32 PosPrev;         // posNext;
  UInt32 BackPrev;     
  UInt32 Backs[kNumRepDistances];
  void MakeAsChar() { BackPrev = UInt32(-1); Prev1IsChar = false; }
  void MakeAsShortRep() { BackPrev = 0; ; Prev1IsChar = false; }
  bool IsShortRep() { return (BackPrev == 0); }
};


extern Byte g_FastPos[1024];
inline UInt32 GetPosSlot(UInt32 pos)
{
  if (pos < (1 << 10))
    return g_FastPos[pos];
  if (pos < (1 << 19))
    return g_FastPos[pos >> 9] + 18;
  return g_FastPos[pos >> 18] + 36;
}

inline UInt32 GetPosSlot2(UInt32 pos)
{
  if (pos < (1 << 16))
    return g_FastPos[pos >> 6] + 12;
  if (pos < (1 << 25))
    return g_FastPos[pos >> 15] + 30;
  return g_FastPos[pos >> 24] + 48;
}

const UInt32 kIfinityPrice = 0xFFFFFFF;

const UInt32 kNumOpts = 1 << 12;


class CLiteralEncoder2
{
  CMyBitEncoder _encoders[0x300];
public:
  void Init()
  {
    for (int i = 0; i < 0x300; i++)
      _encoders[i].Init();
  }
  void Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol);
  void EncodeMatched(NRangeCoder::CEncoder *rangeEncoder, Byte matchByte, Byte symbol);
  UInt32 GetPrice(bool matchMode, Byte matchByte, Byte symbol) const;
};

class CLiteralEncoder
{
  CLiteralEncoder2 *_coders;
  int _numPrevBits;
  int _numPosBits;
  UInt32 _posMask;
public:
  CLiteralEncoder(): _coders(0) {}
  ~CLiteralEncoder()  { Free(); }
  void Free()
  { 
    MyFree(_coders);
    _coders = 0;
  }
  bool Create(int numPosBits, int numPrevBits)
  {
    if (_coders == 0 || (numPosBits + numPrevBits) != 
        (_numPrevBits + _numPosBits) )
    {
      Free();
      UInt32 numStates = 1 << (numPosBits + numPrevBits);
      _coders = (CLiteralEncoder2 *)MyAlloc(numStates * sizeof(CLiteralEncoder2));
    }
    _numPosBits = numPosBits;
    _posMask = (1 << numPosBits) - 1;
    _numPrevBits = numPrevBits;
    return (_coders != 0);
  }
  void Init()
  {
    UInt32 numStates = 1 << (_numPrevBits + _numPosBits);
    for (UInt32 i = 0; i < numStates; i++)
      _coders[i].Init();
  }
  UInt32 GetState(UInt32 pos, Byte prevByte) const
    { return ((pos & _posMask) << _numPrevBits) + (prevByte >> (8 - _numPrevBits)); }
  CLiteralEncoder2 *GetSubCoder(UInt32 pos, Byte prevByte)
    { return &_coders[GetState(pos, prevByte)]; }
  /*
  void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 pos, Byte prevByte, 
      Byte symbol)
    { _coders[GetState(pos, prevByte)].Encode(rangeEncoder, symbol); }
  void EncodeMatched(NRangeCoder::CEncoder *rangeEncoder, UInt32 pos, Byte prevByte, 
      Byte matchByte, Byte symbol)
    { _coders[GetState(pos, prevByte)].Encode(rangeEncoder,
      matchByte, symbol); }
  */
  UInt32 GetPrice(UInt32 pos, Byte prevByte, bool matchMode, Byte matchByte, Byte symbol) const
    { return _coders[GetState(pos, prevByte)].GetPrice(matchMode, matchByte, symbol); }
};

namespace NLength {

class CEncoder
{
  CMyBitEncoder _choice;
  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumLowBits>  _lowCoder[kNumPosStatesEncodingMax];
  CMyBitEncoder  _choice2;
  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumMidBits>  _midCoder[kNumPosStatesEncodingMax];
  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumHighBits>  _highCoder;
public:
  void Init(UInt32 numPosStates);
  void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState);
  UInt32 GetPrice(UInt32 symbol, UInt32 posState) const;
};

const UInt32 kNumSpecSymbols = kNumLowSymbols + kNumMidSymbols;

class CPriceTableEncoder: public CEncoder
{
  UInt32 _prices[kNumSymbolsTotal][kNumPosStatesEncodingMax];
  UInt32 _tableSize;
  UInt32 _counters[kNumPosStatesEncodingMax];
public:
  void SetTableSize(UInt32 tableSize) { _tableSize = tableSize;  }
  UInt32 GetPrice(UInt32 symbol, UInt32 posState) const
    { return _prices[symbol][posState]; }
  void UpdateTable(UInt32 posState)
  {
    for (UInt32 len = 0; len < _tableSize; len++)
      _prices[len][posState] = CEncoder::GetPrice(len, posState);
    _counters[posState] = _tableSize;
  }
  void UpdateTables(UInt32 numPosStates)
  {
    for (UInt32 posState = 0; posState < numPosStates; posState++)
      UpdateTable(posState);
  }
  void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState)
  {
    CEncoder::Encode(rangeEncoder, symbol, posState);
    if (--_counters[posState] == 0)
      UpdateTable(posState);
  }
};

}

class CEncoder : 
  public ICompressCoder,
  public ICompressSetOutStream,
  public ICompressSetCoderProperties,
  public ICompressWriteCoderProperties,
  public CBaseState,
  public CMyUnknownImp
{
  COptimal _optimum[kNumOpts];
  CMyComPtr<IMatchFinder> _matchFinder; // test it
  NRangeCoder::CEncoder _rangeEncoder;

  CMyBitEncoder _isMatch[kNumStates][NLength::kNumPosStatesEncodingMax];
  CMyBitEncoder _isRep[kNumStates];
  CMyBitEncoder _isRepG0[kNumStates];
  CMyBitEncoder _isRepG1[kNumStates];
  CMyBitEncoder _isRepG2[kNumStates];
  CMyBitEncoder _isRep0Long[kNumStates][NLength::kNumPosStatesEncodingMax];

  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumPosSlotBits> _posSlotEncoder[kNumLenToPosStates];

  CMyBitEncoder _posEncoders[kNumFullDistances - kEndPosModelIndex];
  NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumAlignBits> _posAlignEncoder;
  
  NLength::CPriceTableEncoder _lenEncoder;
  NLength::CPriceTableEncoder _repMatchLenEncoder;

  CLiteralEncoder _literalEncoder;

  UInt32 _matchDistances[kMatchMaxLen + 1];

  bool _fastMode;
  bool _maxMode;
  UInt32 _numFastBytes;
  UInt32 _longestMatchLength;    

  UInt32 _additionalOffset;

  UInt32 _optimumEndIndex;
  UInt32 _optimumCurrentIndex;

  bool _longestMatchWasFound;

  UInt32 _posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];
  
  UInt32 _distancesPrices[kNumLenToPosStates][kNumFullDistances];

  UInt32 _alignPrices[kAlignTableSize];
  UInt32 _alignPriceCount;

  UInt32 _distTableSize;

  UInt32 _posStateBits;
  UInt32 _posStateMask;
  UInt32 _numLiteralPosStateBits;
  UInt32 _numLiteralContextBits;

  UInt32 _dictionarySize;

  UInt32 _dictionarySizePrev;
  UInt32 _numFastBytesPrev;

  UInt64 lastPosSlotFillingPos;
  UInt64 nowPos64;
  bool _finished;
  ISequentialInStream *_inStream;

  int _matchFinderIndex;
  #ifdef COMPRESS_MF_MT
  bool _multiThread;
  #endif

  bool _writeEndMark;

  bool _needReleaseMFStream;
  
  HRESULT ReadMatchDistances(UInt32 &len);

  HRESULT MovePos(UInt32 num);
  UInt32 GetRepLen1Price(CState state, UInt32 posState) const
  {
    return _isRepG0[state.Index].GetPrice(0) +
        _isRep0Long[state.Index][posState].GetPrice(0);
  }
  UInt32 GetRepPrice(UInt32 repIndex, UInt32 len, CState state, UInt32 posState) const
  {
    UInt32 price = _repMatchLenEncoder.GetPrice(len - kMatchMinLen, posState);
    if(repIndex == 0)
    {
      price += _isRepG0[state.Index].GetPrice(0);
      price += _isRep0Long[state.Index][posState].GetPrice(1);
    }
    else
    {
      price += _isRepG0[state.Index].GetPrice(1);
      if (repIndex == 1)
        price += _isRepG1[state.Index].GetPrice(0);
      else
      {
        price += _isRepG1[state.Index].GetPrice(1);
        price += _isRepG2[state.Index].GetPrice(repIndex - 2);
      }
    }
    return price;
  }
  /*
  UInt32 GetPosLen2Price(UInt32 pos, UInt32 posState) const
  {
    if (pos >= kNumFullDistances)
      return kIfinityPrice;
    return _distancesPrices[0][pos] + _lenEncoder.GetPrice(0, posState);
  }
  UInt32 GetPosLen3Price(UInt32 pos, UInt32 len, UInt32 posState) const
  {
    UInt32 price;
    UInt32 lenToPosState = GetLenToPosState(len);
    if (pos < kNumFullDistances)
      price = _distancesPrices[lenToPosState][pos];
    else
      price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] + 
          _alignPrices[pos & kAlignMask];
    return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState);
  }
  */
  UInt32 GetPosLenPrice(UInt32 pos, UInt32 len, UInt32 posState) const
  {
    if (len == 2 && pos >= 0x80)
      return kIfinityPrice;
    UInt32 price;
    UInt32 lenToPosState = GetLenToPosState(len);
    if (pos < kNumFullDistances)
      price = _distancesPrices[lenToPosState][pos];
    else
      price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] + 
          _alignPrices[pos & kAlignMask];
    return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState);
  }

  UInt32 Backward(UInt32 &backRes, UInt32 cur);
  HRESULT GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes);
  HRESULT GetOptimumFast(UInt32 position, UInt32 &backRes, UInt32 &lenRes);

  void FillPosSlotPrices();
  void FillDistancesPrices();
  void FillAlignPrices();
    
  void ReleaseMFStream()
  {
    if (_matchFinder && _needReleaseMFStream)
    {
      _matchFinder->ReleaseStream();
      _needReleaseMFStream = false;
    }
  }

  void ReleaseStreams()
  {
    ReleaseMFStream();
    _rangeEncoder.ReleaseStream();
  }

  HRESULT Flush(UInt32 nowPos);
  class CCoderReleaser
  {
    CEncoder *_coder;
  public:
    CCoderReleaser(CEncoder *coder): _coder(coder) {}
    ~CCoderReleaser()
    {
      _coder->ReleaseStreams();
    }
  };
  friend class CCoderReleaser;

  void WriteEndMarker(UInt32 posState);

public:
  CEncoder();
  void SetWriteEndMarkerMode(bool writeEndMarker)
    { _writeEndMark= writeEndMarker; }

  HRESULT Create();

  MY_UNKNOWN_IMP3(
      ICompressSetOutStream,
      ICompressSetCoderProperties,
      ICompressWriteCoderProperties
      )
    
  HRESULT Init();
  
  // ICompressCoder interface
  HRESULT SetStreams(ISequentialInStream *inStream,
      ISequentialOutStream *outStream,
      const UInt64 *inSize, const UInt64 *outSize);
  HRESULT CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished);

  HRESULT CodeReal(ISequentialInStream *inStream,
      ISequentialOutStream *outStream, 
      const UInt64 *inSize, const UInt64 *outSize,
      ICompressProgressInfo *progress);

  // ICompressCoder interface
  STDMETHOD(Code)(ISequentialInStream *inStream,
      ISequentialOutStream *outStream, 
      const UInt64 *inSize, const UInt64 *outSize,
      ICompressProgressInfo *progress);

  // IInitMatchFinder interface
  STDMETHOD(InitMatchFinder)(IMatchFinder *matchFinder);

  // ICompressSetCoderProperties2
  STDMETHOD(SetCoderProperties)(const PROPID *propIDs, 
      const PROPVARIANT *properties, UInt32 numProperties);
  
  // ICompressWriteCoderProperties
  STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);

  STDMETHOD(SetOutStream)(ISequentialOutStream *outStream);

  virtual ~CEncoder() {}
};

}}

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人av电影在线| 欧美精品一区二区三区视频 | 久久爱另类一区二区小说| 91精品福利视频| 亚洲激情校园春色| 欧美最新大片在线看 | 欧美在线观看禁18| 亚洲成人免费看| 日韩精品中文字幕一区二区三区 | 狠狠色丁香婷综合久久| 精品女同一区二区| 国产精品一区二区男女羞羞无遮挡| 精品国产乱码久久久久久夜甘婷婷 | 国产亚洲人成网站| 成人av在线看| 亚洲在线一区二区三区| 6080yy午夜一二三区久久| 免费看黄色91| 亚洲国产精品99久久久久久久久| av中文字幕亚洲| 亚洲自拍偷拍综合| 日韩三级在线免费观看| 成人在线视频一区| 亚洲一区二区三区影院| 欧美一级日韩免费不卡| 高清免费成人av| 亚洲成av人片一区二区三区| 日韩你懂的在线观看| 成人av资源网站| 秋霞影院一区二区| 国产精品视频一二三区| 欧美日本一区二区三区四区| 国产二区国产一区在线观看| 亚洲一区二区精品视频| 精品国产伦一区二区三区观看体验| 97精品超碰一区二区三区| 青青青爽久久午夜综合久久午夜| 中文字幕国产精品一区二区| 欧美老肥妇做.爰bbww| 国产·精品毛片| 麻豆国产91在线播放| 亚洲精品成人天堂一二三| 精品国产1区二区| 欧美婷婷六月丁香综合色| 国产成人啪免费观看软件| 性欧美疯狂xxxxbbbb| 国产精品久久久久永久免费观看 | 久久精品一区二区三区四区| 在线看日韩精品电影| 国产一区二区不卡在线| 五月天视频一区| 亚洲精品成人天堂一二三| 国产清纯在线一区二区www| 欧美精品一级二级三级| 99re这里只有精品视频首页| 国模无码大尺度一区二区三区| 亚洲综合激情小说| 亚洲丝袜另类动漫二区| 国产亚洲综合在线| 日韩一区二区视频在线观看| 在线观看日韩毛片| 99re8在线精品视频免费播放| 国产精品一品二品| 激情av综合网| 麻豆精品新av中文字幕| 视频一区视频二区在线观看| 一区二区三区在线影院| 国产精品久久久久久久久动漫 | 国产99久久久国产精品潘金网站| 蜜臀久久久99精品久久久久久| 一区二区久久久久| 亚洲乱码日产精品bd | 一区二区不卡在线播放| 国产精品久久久一本精品| 中文字幕精品三区| 国产精品色婷婷| 中文字幕不卡在线| 亚洲国产精品国自产拍av| 国产亚洲欧美在线| 国产午夜精品理论片a级大结局| 精品国产第一区二区三区观看体验| 日韩天堂在线观看| 欧美变态tickle挠乳网站| 日韩欧美国产麻豆| 日韩女优电影在线观看| 精品成人私密视频| 国产香蕉久久精品综合网| 国产欧美一区二区三区在线看蜜臀| 久久久久九九视频| 国产精品网站导航| 亚洲欧美视频在线观看视频| 亚洲天堂av老司机| 亚洲国产你懂的| 日韩av中文在线观看| 麻豆成人免费电影| 国产一区二区不卡| 处破女av一区二区| 精品久久久久久久人人人人传媒| 欧美一区二区免费观在线| 精品久久久久久久久久久院品网| 久久久久久久久久久久久夜| 国产精品伦理在线| 亚洲一区免费视频| 蜜臀久久久久久久| 国产成人综合视频| 色婷婷国产精品| 制服视频三区第一页精品| 久久综合色一综合色88| 国产精品国产三级国产普通话三级| 亚洲人123区| 日本美女视频一区二区| 国产91清纯白嫩初高中在线观看| 99视频一区二区| 欧美一级日韩免费不卡| 国产精品午夜在线| 亚洲r级在线视频| 国产一区二区主播在线| 一本大道久久a久久综合| 欧美一级午夜免费电影| 日韩一区欧美一区| 美腿丝袜亚洲色图| 99re成人精品视频| 26uuu欧美日本| 亚洲综合成人在线视频| 国产精品99久久不卡二区| 欧美性受极品xxxx喷水| wwwwxxxxx欧美| 亚洲欧美欧美一区二区三区| 日本sm残虐另类| 色婷婷综合久久久久中文一区二区| 日韩欧美国产精品一区| 亚洲精品国产一区二区精华液| 久草精品在线观看| 91久久免费观看| 国产日韩在线不卡| 日韩成人一级大片| 色综合天天综合网国产成人综合天| 欧美电视剧在线观看完整版| 亚洲精品免费播放| 国产精品一二一区| 欧美一区二区三区色| 亚洲男同1069视频| 国产精品白丝jk黑袜喷水| 在线观看91视频| 中文字幕亚洲成人| 国产精品影视网| 日韩欧美国产成人一区二区| 一区二区久久久久| 91性感美女视频| 久久久99精品免费观看不卡| 日韩av一级电影| 欧美三级资源在线| 亚洲欧美福利一区二区| 国产91精品在线观看| 欧美精品一区二区在线播放| 日本视频一区二区| 欧美日韩亚洲综合一区二区三区| 亚洲人吸女人奶水| 成人黄色777网| 欧美精彩视频一区二区三区| 久久超碰97人人做人人爱| 欧美日韩激情一区二区三区| 一区二区三区在线观看欧美| eeuss鲁片一区二区三区在线观看| 国产视频一区二区在线| 激情成人午夜视频| 久久精品一区四区| 国产白丝精品91爽爽久久| 久久一区二区三区四区| 国产一区视频导航| 国产三级一区二区三区| 国产精品羞羞答答xxdd| 精品国产乱码久久久久久1区2区 | 韩国欧美国产1区| 欧美电影精品一区二区| 久草精品在线观看| 国产婷婷色一区二区三区四区| 懂色一区二区三区免费观看| 欧美国产97人人爽人人喊| 国产精品911| 中文字幕一区在线观看| 91丨九色丨国产丨porny| 一区二区三区在线不卡| 欧美日韩一区中文字幕| 日韩一区精品视频| 亚洲精品在线观看视频| 国产成人精品午夜视频免费| 国产精品久久久久婷婷二区次| 91视频一区二区三区| 亚洲自拍偷拍图区| 欧美tickling挠脚心丨vk| 国产精品一区二区三区乱码| 亚洲欧洲日韩在线| 欧美日韩一区二区三区四区 | 五月天激情综合网| 亚洲精品在线观看网站| 波多野结衣视频一区| 亚洲一区二区欧美日韩| 日韩欧美一区二区三区在线| 国产夫妻精品视频|