public override ProbingState HandleData(byte[] buf, int offset, int len) { int codingState; int max = offset + len; for (int i = offset; i < max; i++) { codingState = codingSM.NextState(buf[i]); if (codingState == StateMachineModel.ERROR) { state = ProbingState.NotMe; break; } if (codingState == StateMachineModel.ITSME) { state = ProbingState.FoundIt; break; } if (codingState == StateMachineModel.START) { int charLen = codingSM.CurrentCharLen; if (i == offset) { lastChar[1] = buf[offset]; contextAnalyser.HandleOneChar(lastChar, 0, charLen); distributionAnalyser.HandleOneChar(lastChar, 0, charLen); } else { contextAnalyser.HandleOneChar(buf, i - 1, charLen); distributionAnalyser.HandleOneChar(buf, i - 1, charLen); } } } lastChar[0] = buf[max - 1]; if (state == ProbingState.Detecting) { if (contextAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) { state = ProbingState.FoundIt; } } return(state); }
public override ProbingState HandleData(byte[] aBuf, int aLen) { SMState codingState; for (int i = 0; i < aBuf.Length && i < aLen; i++) { codingState = mCodingSM.NextState(aBuf[i]); if (codingState == SMState.Error) { mState = ProbingState.NotMe; break; } if (codingState == SMState.ItsMe) { mState = ProbingState.FoundIt; break; } if (codingState == SMState.Start) { int charLen = mCodingSM.CurrentCharLen; if (i == 0) { mLastChar[1] = aBuf[0]; //mContextAnalyser.HandleOneChar(mLastChar, charLen); mDistributionAnalyser.HandleOneChar(mLastChar, charLen); } else { //mContextAnalyser.HandleOneChar(aBuf+i-1, charLen); //mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen); } } } mLastChar[0] = aBuf[aLen - 1]; if (mState == ProbingState.Detecting) { if (mContextAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) { mState = ProbingState.FoundIt; } } return(mState); }
public override ProbingState HandleData(byte[] buf, int offset, int len) { int codingState = SMModel.START; int max = offset + len; for (int i = offset; i < max; i++) { codingState = codingSM.NextState(buf[i]); if (codingState == SMModel.ERROR) { state = ProbingState.NotMe; break; } if (codingState == SMModel.ITSME) { state = ProbingState.FoundIt; break; } if (codingState == SMModel.START) { if (codingSM.CurrentCharLen >= 2) { numOfMBChar++; } } } if (state == ProbingState.Detecting) { if (GetConfidence() > SHORTCUT_THRESHOLD) { state = ProbingState.FoundIt; } } return(state); }