private static BitList VersionInfoBitList(int version) { BitList result = new() { { version, LengthDataBits }, { BCHCalculator.CalculateBCH(version, VersionBCHPoly), LengthECBits } };
private static BitList GetFormatInfoBits(ErrorCorrectionLevel errorLevel, Pattern pattern) { int formatInfo = (int)pattern.MaskPatternType; // Pattern bits length = 3 formatInfo |= GetErrorCorrectionIndicatorBits(errorLevel) << 3; int bchCode = BCHCalculator.CalculateBCH(formatInfo, FormatInfoPoly); // bchCode length = 10 formatInfo = (formatInfo << 10) | bchCode; // xor maskPattern formatInfo ^= FormatInfoMaskPattern; BitList resultBits = new() { { formatInfo, 15 } }; if (resultBits.Count != 15) { throw new Exception("FormatInfoBits length is not 15"); } else { return(resultBits); } }
private void TestOneCase(int inputNum, int expected) { int bchNum = BCHCalculator.CalculateBCH(inputNum, VERSION_INFO_POLY); if (bchNum != expected) { Assert.Fail("InputNum: {0} Actual: {1} Expect: {2}", inputNum, bchNum, expected); } }
private void TestOneCase(int cValue, int expected) { int actualResult = BCHCalculator.PosMSB(cValue); if (actualResult != expected) { Assert.Fail(string.Format("actualResult: {0} expected: {1}", actualResult, expected)); } }