Add ByteInputOutputTableCodingLoop class.

This commit is contained in:
2019-02-11 01:39:58 +00:00
parent 9b0e8fa9ef
commit fb470cad7c
2 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
/**
* One specific ordering/nesting of the coding loops.
*
* Copyright 2015, Backblaze, Inc. All rights reserved.
* Copyright © 2019 Natalia Portillo
*/
namespace Claunia.ReedSolomon
{
public class ByteInputOutputTableCodingLoop : CodingLoopBase
{
public override void CodeSomeShards(byte[][] matrixRows, byte[][] inputs, int inputCount, byte[][] outputs,
int outputCount, int offset, int byteCount)
{
byte[][] table = Galois.MULTIPLICATION_TABLE;
for(int iByte = offset; iByte < offset + byteCount; iByte++)
{
{
int iInput = 0;
byte[] inputShard = inputs[iInput];
byte inputByte = inputShard[iByte];
for(int iOutput = 0; iOutput < outputCount; iOutput++)
{
byte[] outputShard = outputs[iOutput];
byte[] matrixRow = matrixRows[iOutput];
byte[] multTableRow = table[matrixRow[iInput] & 0xFF];
outputShard[iByte] = multTableRow[inputByte & 0xFF];
}
}
for(int iInput = 1; iInput < inputCount; iInput++)
{
byte[] inputShard = inputs[iInput];
byte inputByte = inputShard[iByte];
for(int iOutput = 0; iOutput < outputCount; iOutput++)
{
byte[] outputShard = outputs[iOutput];
byte[] matrixRow = matrixRows[iOutput];
byte[] multTableRow = table[matrixRow[iInput] & 0xFF];
outputShard[iByte] ^= multTableRow[inputByte & 0xFF];
}
}
}
}
}
}

View File

@@ -39,6 +39,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ByteInputOutputExpCodingLoop.cs" />
<Compile Include="ByteInputOutputTableCodingLoop.cs" />
<Compile Include="CodingLoopBase.cs" />
<Compile Include="Galois.cs" />
<Compile Include="ICodingLoop.cs" />