private static sbyte[] calculateRSECC(sbyte[] codewords, sbyte rsEccCodewords, sbyte[] rsBlockOrder, int maxDataCodewords, int maxCodewords) { sbyte[][] numArray1 = new sbyte[256][]; for (int index = 0; index < 256; ++index) { numArray1[index] = new sbyte[(int)rsEccCodewords]; } try { // ISSUE: reference to a compiler-generated method byte[] qrdata = ReadData("rsc" + rsEccCodewords.ToString()); MemoryStream memoryStream = new MemoryStream(qrdata); BufferedStream bufferedStream = new BufferedStream(memoryStream); for (int index = 0; index < 256; ++index) { SystemUtils.ReadInput((Stream)bufferedStream, numArray1[index], 0, numArray1[index].Length); } bufferedStream.Close(); memoryStream.Close(); } catch (Exception ex) { SystemUtils.WriteStackTrace(ex, Console.Error); } int index1 = 0; int index2 = 0; sbyte[][] numArray2 = new sbyte[rsBlockOrder.Length][]; sbyte[] numArray3 = new sbyte[maxCodewords]; Array.Copy((Array)codewords, 0, (Array)numArray3, 0, codewords.Length); for (int index3 = 0; index3 < rsBlockOrder.Length; ++index3) { numArray2[index3] = new sbyte[((int)rsBlockOrder[index3] & (int)byte.MaxValue) - (int)rsEccCodewords]; } for (int index3 = 0; index3 < maxDataCodewords; ++index3) { numArray2[index2][index1] = codewords[index3]; ++index1; if (index1 >= ((int)rsBlockOrder[index2] & (int)byte.MaxValue) - (int)rsEccCodewords) { index1 = 0; ++index2; } } for (int index3 = 0; index3 < rsBlockOrder.Length; ++index3) { sbyte[] numArray4 = new sbyte[numArray2[index3].Length]; numArray2[index3].CopyTo((Array)numArray4, 0); for (int index4 = ((int)rsBlockOrder[index3] & (int)byte.MaxValue) - (int)rsEccCodewords; index4 > 0; --index4) { sbyte num = numArray4[0]; if ((int)num != 0) { sbyte[] xa = new sbyte[numArray4.Length - 1]; Array.Copy((Array)numArray4, 1, (Array)xa, 0, numArray4.Length - 1); sbyte[] xb = numArray1[(int)num & (int)byte.MaxValue]; numArray4 = QRCodeEncoder.calculateByteArrayBits(xa, xb, "xor"); } else if ((int)rsEccCodewords < numArray4.Length) { sbyte[] numArray5 = new sbyte[numArray4.Length - 1]; Array.Copy((Array)numArray4, 1, (Array)numArray5, 0, numArray4.Length - 1); numArray4 = new sbyte[numArray5.Length]; numArray5.CopyTo((Array)numArray4, 0); } else { sbyte[] numArray5 = new sbyte[(int)rsEccCodewords]; Array.Copy((Array)numArray4, 1, (Array)numArray5, 0, numArray4.Length - 1); numArray5[(int)rsEccCodewords - 1] = (sbyte)0; numArray4 = new sbyte[numArray5.Length]; numArray5.CopyTo((Array)numArray4, 0); } } Array.Copy((Array)numArray4, 0, (Array)numArray3, codewords.Length + index3 * (int)rsEccCodewords, (int)(byte)rsEccCodewords); } return(numArray3); }
private static sbyte[] calculateRSECC(sbyte[] codewords, sbyte rsEccCodewords, sbyte[] rsBlockOrder, int maxDataCodewords, int maxCodewords) { sbyte[][] rsCalTableArray = new sbyte[256][]; for (int i = 0; i < 256; i++) { rsCalTableArray[i] = new sbyte[(int)rsEccCodewords]; } try { string fileName = "rsc" + rsEccCodewords.ToString(); MemoryStream memoryStream = new MemoryStream((byte[])Resources.ResourceManager.GetObject(fileName)); BufferedStream bis = new BufferedStream(memoryStream); for (int i = 0; i < 256; i++) { SystemUtils.ReadInput(bis, rsCalTableArray[i], 0, rsCalTableArray[i].Length); } bis.Close(); memoryStream.Close(); } catch (Exception e) { SystemUtils.WriteStackTrace(e, Console.Error); } int j = 0; int rsBlockNumber = 0; sbyte[][] rsTemp = new sbyte[rsBlockOrder.Length][]; sbyte[] res = new sbyte[maxCodewords]; Array.Copy(codewords, 0, res, 0, codewords.Length); for (int i2 = 0; i2 < rsBlockOrder.Length; i2++) { rsTemp[i2] = new sbyte[((int)rsBlockOrder[i2] & 255) - (int)rsEccCodewords]; } for (int i2 = 0; i2 < maxDataCodewords; i2++) { rsTemp[rsBlockNumber][j] = codewords[i2]; j++; if (j >= ((int)rsBlockOrder[rsBlockNumber] & 255) - (int)rsEccCodewords) { j = 0; rsBlockNumber++; } } for (rsBlockNumber = 0; rsBlockNumber < rsBlockOrder.Length; rsBlockNumber++) { sbyte[] rsTempData = new sbyte[rsTemp[rsBlockNumber].Length]; rsTemp[rsBlockNumber].CopyTo(rsTempData, 0); int rsCodewords = (int)rsBlockOrder[rsBlockNumber] & 255; int rsDataCodewords = rsCodewords - (int)rsEccCodewords; for (j = rsDataCodewords; j > 0; j--) { sbyte first = rsTempData[0]; if (first != 0) { sbyte[] leftChr = new sbyte[rsTempData.Length - 1]; Array.Copy(rsTempData, 1, leftChr, 0, rsTempData.Length - 1); sbyte[] cal = rsCalTableArray[(int)first & 255]; rsTempData = QRCodeEncoder.calculateByteArrayBits(leftChr, cal, "xor"); } else { if ((int)rsEccCodewords < rsTempData.Length) { sbyte[] rsTempNew = new sbyte[rsTempData.Length - 1]; Array.Copy(rsTempData, 1, rsTempNew, 0, rsTempData.Length - 1); rsTempData = new sbyte[rsTempNew.Length]; rsTempNew.CopyTo(rsTempData, 0); } else { sbyte[] rsTempNew = new sbyte[(int)rsEccCodewords]; Array.Copy(rsTempData, 1, rsTempNew, 0, rsTempData.Length - 1); rsTempNew[(int)(rsEccCodewords - 1)] = 0; rsTempData = new sbyte[rsTempNew.Length]; rsTempNew.CopyTo(rsTempData, 0); } } } Array.Copy(rsTempData, 0, res, codewords.Length + rsBlockNumber * (int)rsEccCodewords, (int)((byte)rsEccCodewords)); } return(res); }