summaryrefslogtreecommitdiffstats
path: root/hostTools/lzma/compress/BinTreeMFMain.h
blob: 543809398fc0054b7e6609fa11e23d1b8affec31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "BinTreeMain.h"

namespace BT_NAMESPACE {

HRESULT CMatchFinderBinTree::Create(UINT32 aSizeHistory,
      UINT32 aKeepAddBufferBefore, UINT32 aMatchMaxLen, 
      UINT32 aKeepAddBufferAfter)
{ 
  const UINT32 kAlignMask = (1 << 16) - 1;
  UINT32 aWindowReservSize = aSizeHistory / 2;
  aWindowReservSize += kAlignMask;
  aWindowReservSize &= ~(kAlignMask);

  const int kMinDictSize = (1 << 19);
  if (aWindowReservSize < kMinDictSize)
    aWindowReservSize = kMinDictSize;
  aWindowReservSize += 256;

  try 
  {
    return CInTree::Create(aSizeHistory, aKeepAddBufferBefore, aMatchMaxLen,
      aKeepAddBufferAfter, aWindowReservSize); 
  }
  catch(...)
  {
    return E_OUTOFMEMORY;
  }
}

}