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