private static BitList VersionInfoBitList(int version)
 {
     BitList result = new()
     {
         { version, LengthDataBits },
         { BCHCalculator.CalculateBCH(version, VersionBCHPoly), LengthECBits }
     };
Exemplo n.º 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);
        }
    }
Exemplo n.º 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);
            }
        }