private static void MatchFinderMt3_Skip(CMatchFinderMt p, uint num) { do { if (p.mBtBufPos == p.mBtBufPosLimit) { p.MatchFinderMt_GetNextBlock_Bt(); } if (p.mBtNumAvailBytes-- >= 3) { P <byte> cur = p.mPointerToCurPos; uint[] hash = p.mLocalHash; uint temp = cur[0].CRC() ^ cur[1]; uint hash2Value = temp & (kHash2Size - 1); uint hash3Value = (temp ^ ((uint)cur[2] << 8)) & (kHash3Size - 1); hash[kFix3HashSize + hash3Value] = p.mLzPos; hash[hash2Value] = p.mLzPos; } p.mLzPos++; p.mPointerToCurPos++; p.mBtBufPos += p.mBtBuf[p.mBtBufPos] + 1; }while (--num != 0); }
private static P <uint> MixMatches4(CMatchFinderMt p, uint matchMinPos, P <uint> distances) { uint[] hash = p.mHash; P <byte> cur = p.mPointerToCurPos; uint lzPos = p.mLzPos; uint temp = cur[0].CRC() ^ cur[1]; uint hash2Value = temp & (kHash2Size - 1); uint hash3Value = (temp ^ ((uint)cur[2] << 8)) & (kHash3Size - 1); uint hash4Value = (temp ^ ((uint)cur[2] << 8) ^ (cur[3].CRC() << 5)) & (kHash4Size - 1); uint curMatch2 = hash[hash2Value]; uint curMatch3 = hash[kFix3HashSize + hash3Value]; uint curMatch4 = hash[kFix4HashSize + hash4Value]; hash[hash2Value] = lzPos; hash[kFix3HashSize + hash3Value] = lzPos; hash[kFix4HashSize + hash4Value] = lzPos; if (curMatch2 >= matchMinPos && cur[(long)curMatch2 - lzPos] == cur[0]) { distances[1] = lzPos - curMatch2 - 1; if (cur[(long)curMatch2 - lzPos + 2] == cur[2]) { distances[0] = (cur[(long)curMatch2 - lzPos + 3] == cur[3]) ? 4u : 3u; return(distances + 2); } distances[0] = 2; distances += 2; } if (curMatch3 >= matchMinPos && cur[(long)curMatch3 - lzPos] == cur[0]) { distances[1] = lzPos - curMatch3 - 1; if (cur[(long)curMatch3 - lzPos + 3] == cur[3]) { distances[0] = 4; return(distances + 2); } distances[0] = 3; distances += 2; } if (curMatch4 >= matchMinPos && cur[(long)curMatch4 - lzPos] == cur[0] && cur[(long)curMatch4 - lzPos + 3] == cur[3]) { distances[0] = 4; distances++; distances[0] = lzPos - curMatch4 - 1; distances++; } return(distances); }
private static void MatchFinderMt0_Skip(CMatchFinderMt p, uint num) { do { if (p.mBtBufPos == p.mBtBufPosLimit) { p.MatchFinderMt_GetNextBlock_Bt(); } p.mBtNumAvailBytes--; p.mLzPos++; p.mPointerToCurPos++; p.mBtBufPos += p.mBtBuf[p.mBtBufPos] + 1; }while (--num != 0); }
private static uint MatchFinderMt_GetMatches(CMatchFinderMt p, P <uint> distances) { TR("MatchFinderMt_GetMatches", p.mBtBufPos); P <uint> btBuf = p.mBtBuf + p.mBtBufPos; uint len = btBuf[0]; btBuf++; p.mBtBufPos += 1 + len; if (len == 0) { if (p.mBtNumAvailBytes-- >= 4) { len = (uint)(p.mInterface.MixMatchesFunc(p, p.mLzPos - p.mLocalHistorySize, distances) - distances); } } else { // Condition: there are matches in btBuf with length < p.numHashBytes p.mBtNumAvailBytes--; P <uint> distances2 = p.mInterface.MixMatchesFunc(p, p.mLzPos - btBuf[1], distances); do { distances2[0] = btBuf[0]; distances2++; btBuf++; distances2[0] = btBuf[0]; distances2++; btBuf++; len -= 2; }while (len != 0); len = (uint)(distances2 - distances); } p.mLzPos++; p.mPointerToCurPos++; return(len); }
private static P <uint> MixMatches2(CMatchFinderMt p, uint matchMinPos, P <uint> distances) { uint[] hash = p.mLocalHash; P <byte> cur = p.mPointerToCurPos; uint lzPos = p.mLzPos; uint hash2Value = (cur[0].CRC() ^ cur[1]) & (kHash2Size - 1); uint curMatch2 = hash[hash2Value]; hash[hash2Value] = lzPos; if (curMatch2 >= matchMinPos && cur[(long)curMatch2 - lzPos] == cur[0]) { distances[0] = 2; distances++; distances[0] = lzPos - curMatch2 - 1; distances++; } return(distances); }
private static void MatchFinderMt2_Skip(CMatchFinderMt p, uint num) { do { if (p.mBtBufPos == p.mBtBufPosLimit) { p.MatchFinderMt_GetNextBlock_Bt(); } if (p.mBtNumAvailBytes-- >= 2) { P <byte> cur = p.mPointerToCurPos; uint[] hash = p.mLocalHash; uint hash2Value = (cur[0].CRC() ^ cur[1]) & (kHash2Size - 1); hash[hash2Value] = p.mLzPos; } p.mLzPos++; p.mPointerToCurPos++; p.mBtBufPos += p.mBtBuf[p.mBtBufPos] + 1; }while (--num != 0); }
/* Call it after ReleaseStream / SetStream */ private static void MatchFinderMt_Init(CMatchFinderMt p) { CMatchFinder mf = p; p.mBtBufPos = p.mBtBufPosLimit = 0; p.mHashBufPos = p.mHashBufPosLimit = 0; mf.MatchFinder_Init(); p.mPointerToCurPos = mf.MatchFinder_GetPointerToCurrentPos(); p.mBtNumAvailBytes = 0; p.mLzPos = p.mLocalHistorySize + 1; p.mLocalHash = mf.mHash; p.mLocalFixedHashSize = mf.mFixedHashSize; p.mLocalSon = mf.mSon; p.mLocalMatchMaxLen = mf.mMatchMaxLen; p.mLocalNumHashBytes = mf.mNumHashBytes; p.mLocalPos = mf.mPos; p.mLocalBuffer = mf.mBuffer; p.mLocalCyclicBufferPos = mf.mCyclicBufferPos; p.mLocalCyclicBufferSize = mf.mCyclicBufferSize; p.mLocalCutValue = mf.mCutValue; }
private static uint MatchFinderMt2_GetMatches(CMatchFinderMt p, P <uint> distances) { P <uint> btBuf = p.mBtBuf + p.mBtBufPos; uint len = btBuf[0]; btBuf++; p.mBtBufPos += 1 + len; p.mBtNumAvailBytes--; for (uint i = 0; i < len; i += 2) { distances[0] = btBuf[0]; distances++; btBuf++; distances[0] = btBuf[0]; distances++; btBuf++; } p.mLzPos++; p.mPointerToCurPos++; return(len); }
private static uint MatchFinderMt_GetMatches(CMatchFinderMt p, P<uint> distances) { TR("MatchFinderMt_GetMatches", p.mBtBufPos); P<uint> btBuf = p.mBtBuf + p.mBtBufPos; uint len = btBuf[0]; btBuf++; p.mBtBufPos += 1 + len; if(len == 0) { if(p.mBtNumAvailBytes-- >= 4) len = (uint)(p.mInterface.MixMatchesFunc(p, p.mLzPos - p.mLocalHistorySize, distances) - distances); } else { // Condition: there are matches in btBuf with length < p.numHashBytes p.mBtNumAvailBytes--; P<uint> distances2 = p.mInterface.MixMatchesFunc(p, p.mLzPos - btBuf[1], distances); do { distances2[0] = btBuf[0]; distances2++; btBuf++; distances2[0] = btBuf[0]; distances2++; btBuf++; len -= 2; } while(len != 0); len = (uint)(distances2 - distances); } p.mLzPos++; p.mPointerToCurPos++; return len; }
private static P<uint> MixMatches3(CMatchFinderMt p, uint matchMinPos, P<uint> distances) { uint[] hash = p.mLocalHash; P<byte> cur = p.mPointerToCurPos; uint lzPos = p.mLzPos; uint temp = cur[0].CRC() ^ cur[1]; uint hash2Value = temp & (kHash2Size - 1); uint hash3Value = (temp ^ ((uint)cur[2] << 8)) & (kHash3Size - 1); uint curMatch2 = hash[hash2Value]; uint curMatch3 = hash[kFix3HashSize + hash3Value]; hash[hash2Value] = lzPos; hash[kFix3HashSize + hash3Value] = lzPos; if(curMatch2 >= matchMinPos && cur[curMatch2 - lzPos] == cur[0]) { distances[1] = lzPos - curMatch2 - 1; if(cur[curMatch2 - lzPos + 2] == cur[2]) { distances[0] = 3; return distances + 2; } distances[0] = 2; distances += 2; } if(curMatch3 >= matchMinPos && cur[curMatch3 - lzPos] == cur[0]) { distances[0] = 3; distances++; distances[0] = lzPos - curMatch3 - 1; distances++; } return distances; }
private static P<uint> MixMatches2(CMatchFinderMt p, uint matchMinPos, P<uint> distances) { uint[] hash = p.mLocalHash; P<byte> cur = p.mPointerToCurPos; uint lzPos = p.mLzPos; uint hash2Value = (cur[0].CRC() ^ cur[1]) & (kHash2Size - 1); uint curMatch2 = hash[hash2Value]; hash[hash2Value] = lzPos; if(curMatch2 >= matchMinPos && cur[(long)curMatch2 - lzPos] == cur[0]) { distances[0] = 2; distances++; distances[0] = lzPos - curMatch2 - 1; distances++; } return distances; }
private static void MatchFinderMt2_Skip(CMatchFinderMt p, uint num) { do { if(p.mBtBufPos == p.mBtBufPosLimit) p.MatchFinderMt_GetNextBlock_Bt(); if(p.mBtNumAvailBytes-- >= 2) { P<byte> cur = p.mPointerToCurPos; uint[] hash = p.mLocalHash; uint hash2Value = (cur[0].CRC() ^ cur[1]) & (kHash2Size - 1); hash[hash2Value] = p.mLzPos; } p.mLzPos++; p.mPointerToCurPos++; p.mBtBufPos += p.mBtBuf[p.mBtBufPos] + 1; } while(--num != 0); }
private static uint MatchFinderMt2_GetMatches(CMatchFinderMt p, P<uint> distances) { P<uint> btBuf = p.mBtBuf + p.mBtBufPos; uint len = btBuf[0]; btBuf++; p.mBtBufPos += 1 + len; p.mBtNumAvailBytes--; for(uint i = 0; i < len; i += 2) { distances[0] = btBuf[0]; distances++; btBuf++; distances[0] = btBuf[0]; distances++; btBuf++; } p.mLzPos++; p.mPointerToCurPos++; return len; }
private static void MatchFinderMt4_Skip(CMatchFinderMt p, uint count) { do { if(p.mBtBufPos == p.mBtBufPosLimit) p.MatchFinderMt_GetNextBlock_Bt(); if(p.mBtNumAvailBytes-- >= 4) { P<byte> cur = p.mPointerToCurPos; uint[] hash = p.mHash; uint temp = cur[0].CRC() ^ cur[1]; uint hash2Value = temp & (kHash2Size - 1); uint hash3Value = (temp ^ ((uint)cur[2] << 8)) & (kHash3Size - 1); uint hash4Value = (temp ^ ((uint)cur[2] << 8) ^ (cur[3].CRC() << 5)) & (kHash4Size - 1); hash[kFix4HashSize + hash4Value] = p.mLzPos; hash[kFix3HashSize + hash3Value] = p.mLzPos; hash[hash2Value] = p.mLzPos; } p.mLzPos++; p.mPointerToCurPos++; p.mBtBufPos += p.mBtBuf[p.mBtBufPos] + 1; } while(--count != 0); }
internal CLzmaEnc() // LzmaEnc_Construct { mRC.RangeEnc_Construct(); #if !_7ZIP_ST mMatchFinderMt = new CMatchFinderMt(); mMatchFinderBase = mMatchFinderMt; #else mMatchFinderBase = new CMatchFinder(); #endif LzmaEnc_SetProps(CLzmaEncProps.LzmaEncProps_Init()); LzmaEnc_FastPosInit(); LzmaEnc_InitPriceTables(mProbPrices); mLitProbs = null; mSaveState.mLitProbs = null; }
private static void MatchFinderMt0_Skip(CMatchFinderMt p, uint num) { do { if(p.mBtBufPos == p.mBtBufPosLimit) p.MatchFinderMt_GetNextBlock_Bt(); p.mBtNumAvailBytes--; p.mLzPos++; p.mPointerToCurPos++; p.mBtBufPos += p.mBtBuf[p.mBtBufPos] + 1; } while(--num != 0); }