private static BitList VersionInfoBitList(int version)
 {
     BitList result = new()
     {
         { version, LengthDataBits },
         { BCHCalculator.CalculateBCH(version, VersionBCHPoly), LengthECBits }
     };
Example #2
0
    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);
        }
    }
Example #3
0
        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);
            }
        }
Example #4
0
        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));
            }
        }