mirror of
https://github.com/claunia/Claunia.ReedSolomon.git
synced 2025-12-16 19:24:45 +00:00
Add OutputInputByteTableCodingLoop class.
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
<Compile Include="OutputByteInputExpCodingLoop.cs" />
|
<Compile Include="OutputByteInputExpCodingLoop.cs" />
|
||||||
<Compile Include="OutputByteInputTableCodingLoop.cs" />
|
<Compile Include="OutputByteInputTableCodingLoop.cs" />
|
||||||
<Compile Include="OutputInputByteExpCodingLoop.cs" />
|
<Compile Include="OutputInputByteExpCodingLoop.cs" />
|
||||||
|
<Compile Include="OutputInputByteTableCodingLoop.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ namespace Claunia.ReedSolomon
|
|||||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
public static readonly ICodingLoop[] ALL_CODING_LOOPS =
|
public static readonly ICodingLoop[] ALL_CODING_LOOPS =
|
||||||
{
|
{
|
||||||
/*new ByteInputOutputExpCodingLoop(), new ByteInputOutputTableCodingLoop(),
|
new ByteInputOutputExpCodingLoop(), new ByteInputOutputTableCodingLoop(),
|
||||||
new ByteOutputInputExpCodingLoop(), new ByteOutputInputTableCodingLoop(),
|
new ByteOutputInputExpCodingLoop(), new ByteOutputInputTableCodingLoop(),
|
||||||
new InputByteOutputExpCodingLoop(), new InputByteOutputTableCodingLoop(),
|
new InputByteOutputExpCodingLoop(), new InputByteOutputTableCodingLoop(),
|
||||||
new InputOutputByteExpCodingLoop(), new InputOutputByteTableCodingLoop(),
|
new InputOutputByteExpCodingLoop(), new InputOutputByteTableCodingLoop(),
|
||||||
new OutputByteInputExpCodingLoop(), new OutputByteInputTableCodingLoop(),
|
new OutputByteInputExpCodingLoop(), new OutputByteInputTableCodingLoop(),
|
||||||
new OutputInputByteExpCodingLoop(), new OutputInputByteTableCodingLoop()*/
|
new OutputInputByteExpCodingLoop(), new OutputInputByteTableCodingLoop()
|
||||||
};
|
};
|
||||||
|
|
||||||
public abstract void CodeSomeShards(byte[][] matrixRows, byte[][] inputs, int inputCount, byte[][] outputs,
|
public abstract void CodeSomeShards(byte[][] matrixRows, byte[][] inputs, int inputCount, byte[][] outputs,
|
||||||
|
|||||||
82
Claunia.ReedSolomon/OutputInputByteTableCodingLoop.cs
Normal file
82
Claunia.ReedSolomon/OutputInputByteTableCodingLoop.cs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/**
|
||||||
|
* One specific ordering/nesting of the coding loops.
|
||||||
|
*
|
||||||
|
* Copyright 2015, Backblaze, Inc. All rights reserved.
|
||||||
|
* Copyright © 2019 Natalia Portillo
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Claunia.ReedSolomon
|
||||||
|
{
|
||||||
|
public class OutputInputByteTableCodingLoop : 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 iOutput = 0; iOutput < outputCount; iOutput++)
|
||||||
|
{
|
||||||
|
byte[] outputShard = outputs[iOutput];
|
||||||
|
byte[] matrixRow = matrixRows[iOutput];
|
||||||
|
|
||||||
|
{
|
||||||
|
int iInput = 0;
|
||||||
|
byte[] inputShard = inputs[iInput];
|
||||||
|
byte[] multTableRow = table[matrixRow[iInput] & 0xFF];
|
||||||
|
|
||||||
|
for(int iByte = offset; iByte < offset + byteCount; iByte++)
|
||||||
|
outputShard[iByte] = multTableRow[inputShard[iByte] & 0xFF];
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int iInput = 1; iInput < inputCount; iInput++)
|
||||||
|
{
|
||||||
|
byte[] inputShard = inputs[iInput];
|
||||||
|
byte[] multTableRow = table[matrixRow[iInput] & 0xFF];
|
||||||
|
|
||||||
|
for(int iByte = offset; iByte < offset + byteCount; iByte++)
|
||||||
|
outputShard[iByte] ^= multTableRow[inputShard[iByte] & 0xFF];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CheckSomeShards(byte[][] matrixRows, byte[][] inputs, int inputCount, byte[][] toCheck,
|
||||||
|
int checkCount, int offset, int byteCount, byte[] tempBuffer)
|
||||||
|
{
|
||||||
|
if(tempBuffer == null)
|
||||||
|
return base.CheckSomeShards(matrixRows, inputs, inputCount, toCheck, checkCount, offset, byteCount,
|
||||||
|
null);
|
||||||
|
|
||||||
|
byte[][] table = Galois.MULTIPLICATION_TABLE;
|
||||||
|
|
||||||
|
for(int iOutput = 0; iOutput < checkCount; iOutput++)
|
||||||
|
{
|
||||||
|
byte[] outputShard = toCheck[iOutput];
|
||||||
|
byte[] matrixRow = matrixRows[iOutput];
|
||||||
|
|
||||||
|
{
|
||||||
|
int iInput = 0;
|
||||||
|
byte[] inputShard = inputs[iInput];
|
||||||
|
byte[] multTableRow = table[matrixRow[iInput] & 0xFF];
|
||||||
|
|
||||||
|
for(int iByte = offset; iByte < offset + byteCount; iByte++)
|
||||||
|
tempBuffer[iByte] = multTableRow[inputShard[iByte] & 0xFF];
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int iInput = 1; iInput < inputCount; iInput++)
|
||||||
|
{
|
||||||
|
byte[] inputShard = inputs[iInput];
|
||||||
|
byte[] multTableRow = table[matrixRow[iInput] & 0xFF];
|
||||||
|
|
||||||
|
for(int iByte = offset; iByte < offset + byteCount; iByte++)
|
||||||
|
tempBuffer[iByte] ^= multTableRow[inputShard[iByte] & 0xFF];
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int iByte = offset; iByte < offset + byteCount; iByte++)
|
||||||
|
if(tempBuffer[iByte] != outputShard[iByte])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user