-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from B3zaleel/create-encoders
Create encoders
- Loading branch information
Showing
46 changed files
with
1,616 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/Draco/IO/Attributes/PredictionSchemes/IPredictionSchemeEncoder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Draco.IO.Attributes.PredictionSchemes; | ||
|
||
internal interface IPredictionSchemeEncoder<TDataType> : IPredictionSchemeEncoder<TDataType, TDataType> | ||
{ | ||
} | ||
|
||
internal interface IPredictionSchemeEncoder<TDataType, TCorrectedType> : IPredictionSchemeEncoder | ||
{ | ||
public TCorrectedType[] ComputeCorrectionValues(TDataType[] data, int size, int numComponents, List<uint> entryToPointMap); | ||
} | ||
|
||
internal interface IPredictionSchemeEncoder : IPredictionScheme | ||
{ | ||
public void EncodePredictionData(EncoderBuffer encoderBuffer); | ||
} |
56 changes: 56 additions & 0 deletions
56
src/Draco/IO/Attributes/PredictionSchemes/IPredictionSchemeEncodingTransform.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System.Numerics; | ||
using Draco.IO.Enums; | ||
|
||
namespace Draco.IO.Attributes.PredictionSchemes; | ||
|
||
internal interface IPredictionSchemeEncodingTransform<TDataType, TCorrectedType> | ||
where TDataType : struct, | ||
IComparisonOperators<TDataType, TDataType, bool>, | ||
IComparable, | ||
IEqualityOperators<TDataType, TDataType, bool>, | ||
IAdditionOperators<TDataType, TDataType, TDataType>, | ||
ISubtractionOperators<TDataType, TDataType, TDataType>, | ||
IDivisionOperators<TDataType, TDataType, TDataType>, | ||
IMultiplyOperators<TDataType, TDataType, TDataType>, | ||
IDecrementOperators<TDataType>, | ||
IBitwiseOperators<TDataType, TDataType, TDataType>, | ||
IMinMaxValue<TDataType> | ||
where TCorrectedType : struct, | ||
IComparisonOperators<TCorrectedType, TCorrectedType, bool>, | ||
IComparable, | ||
IEqualityOperators<TCorrectedType, TCorrectedType, bool>, | ||
IAdditionOperators<TCorrectedType, TCorrectedType, TCorrectedType>, | ||
ISubtractionOperators<TCorrectedType, TCorrectedType, TCorrectedType>, | ||
IDivisionOperators<TCorrectedType, TCorrectedType, TCorrectedType>, | ||
IMultiplyOperators<TCorrectedType, TCorrectedType, TCorrectedType>, | ||
IDecrementOperators<TCorrectedType>, | ||
IBitwiseOperators<TCorrectedType, TCorrectedType, TCorrectedType>, | ||
IMinMaxValue<TCorrectedType> | ||
{ | ||
public int ComponentsCount { get; set; } | ||
public int QuantizationBits { get; } | ||
public PredictionSchemeTransformType Type { get => PredictionSchemeTransformType.Delta; } | ||
|
||
public virtual void Init(TDataType[] originalData, int size, int componentsCount) | ||
{ | ||
ComponentsCount = componentsCount; | ||
} | ||
|
||
public virtual TCorrectedType[] ComputeCorrectionValue(TDataType[] originalValues, TDataType[] predictedValues) | ||
{ | ||
var correctionValues = new TCorrectedType[ComponentsCount]; | ||
|
||
for (int i = 0; i < ComponentsCount; ++i) | ||
{ | ||
correctionValues[i] = (TCorrectedType)Convert.ChangeType(originalValues[i] - predictedValues[i], typeof(TCorrectedType))!; | ||
} | ||
return correctionValues; | ||
} | ||
|
||
public virtual void EncodeTransformData(EncoderBuffer encoderBuffer) { } | ||
|
||
public virtual bool AreCorrectionsPositive() | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.