Add OutputInputByteTableCodingLoop class.

This commit is contained in:
2019-02-11 01:43:47 +00:00
parent 98a12bbea4
commit 8ddaf58a3a
3 changed files with 85 additions and 2 deletions

View File

@@ -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>

View File

@@ -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,

View 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;
}
}
}