mirror of
https://github.com/claunia/Claunia.ReedSolomon.git
synced 2025-12-16 19:24:45 +00:00
Add InputByteOutputTableCodingLoop class.
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
<Compile Include="Galois.cs" />
|
<Compile Include="Galois.cs" />
|
||||||
<Compile Include="ICodingLoop.cs" />
|
<Compile Include="ICodingLoop.cs" />
|
||||||
<Compile Include="InputByteOutputExpCodingLoop.cs" />
|
<Compile Include="InputByteOutputExpCodingLoop.cs" />
|
||||||
|
<Compile Include="InputByteOutputTableCodingLoop.cs" />
|
||||||
<Compile Include="Matrix.cs" />
|
<Compile Include="Matrix.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
54
Claunia.ReedSolomon/InputByteOutputTableCodingLoop.cs
Normal file
54
Claunia.ReedSolomon/InputByteOutputTableCodingLoop.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* One specific ordering/nesting of the coding loops.
|
||||||
|
*
|
||||||
|
* Copyright 2015, Backblaze, Inc. All rights reserved.
|
||||||
|
* Copyright © 2019 Natalia Portillo
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Claunia.ReedSolomon
|
||||||
|
{
|
||||||
|
public class InputByteOutputTableCodingLoop : CodingLoopBase
|
||||||
|
{
|
||||||
|
public override void CodeSomeShards(byte[][] matrixRows, byte[][] inputs, int inputCount, byte[][] outputs,
|
||||||
|
int outputCount, int offset, int byteCount)
|
||||||
|
{
|
||||||
|
byte[][] table = Galois.MULTIPLICATION_TABLE;
|
||||||
|
|
||||||
|
{
|
||||||
|
int iInput = 0;
|
||||||
|
byte[] inputShard = inputs[iInput];
|
||||||
|
|
||||||
|
for(int iByte = offset; iByte < offset + byteCount; iByte++)
|
||||||
|
{
|
||||||
|
byte inputByte = inputShard[iByte];
|
||||||
|
byte[] multTableRow = table[inputByte & 0xFF];
|
||||||
|
|
||||||
|
for(int iOutput = 0; iOutput < outputCount; iOutput++)
|
||||||
|
{
|
||||||
|
byte[] outputShard = outputs[iOutput];
|
||||||
|
byte[] matrixRow = matrixRows[iOutput];
|
||||||
|
outputShard[iByte] = multTableRow[matrixRow[iInput] & 0xFF];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int iInput = 1; iInput < inputCount; iInput++)
|
||||||
|
{
|
||||||
|
byte[] inputShard = inputs[iInput];
|
||||||
|
|
||||||
|
for(int iByte = offset; iByte < offset + byteCount; iByte++)
|
||||||
|
{
|
||||||
|
byte inputByte = inputShard[iByte];
|
||||||
|
byte[] multTableRow = table[inputByte & 0xFF];
|
||||||
|
|
||||||
|
for(int iOutput = 0; iOutput < outputCount; iOutput++)
|
||||||
|
{
|
||||||
|
byte[] outputShard = outputs[iOutput];
|
||||||
|
byte[] matrixRow = matrixRows[iOutput];
|
||||||
|
outputShard[iByte] ^= multTableRow[matrixRow[iInput] & 0xFF];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user