Skip to content

Commit 705dc88

Browse files
committed
Use more Span in AstcDecoder
1 parent 3187e92 commit 705dc88

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

AssetRipper.TextureDecoder/Astc/AstcDecoder.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private unsafe static void DecodeBlockParameters(byte* input, ref BlockData pBlo
238238

239239
private unsafe static void DecodeEndpoints(byte* input, ref BlockData pBlock)
240240
{
241-
IntSeqData* epSeq = stackalloc IntSeqData[32];
241+
Span<IntSeqData> epSeq = stackalloc IntSeqData[32];
242242
DecodeIntseq(input, pBlock.part_num == 1 ? 17 : 29, CemTableA[pBlock.cem_range], CemTableB[pBlock.cem_range], pBlock.endpoint_value_num, false, epSeq);
243243

244244
int* ev = stackalloc int[32];
@@ -485,10 +485,10 @@ private unsafe static void DecodeEndpoints(byte* input, ref BlockData pBlock)
485485

486486
private unsafe static void DecodeWeights(byte* input, ref BlockData block)
487487
{
488-
IntSeqData* wSeq = stackalloc IntSeqData[128];
488+
Span<IntSeqData> wSeq = stackalloc IntSeqData[128];
489489
DecodeIntseq(input, 128, WeightPrecTableA[block.weight_range], WeightPrecTableB[block.weight_range], block.weight_num, true, wSeq);
490490

491-
int* wv = stackalloc int[128];
491+
Span<int> wv = stackalloc int[128];
492492
if (WeightPrecTableA[block.weight_range] == 0)
493493
{
494494
switch (WeightPrecTableB[block.weight_range])
@@ -660,17 +660,19 @@ private unsafe static void SelectPartition(byte* input, ref BlockData block)
660660
rnum ^= rnum >> 17;
661661
}
662662

663-
int* seeds = stackalloc int[8];
663+
Span<int> seeds = stackalloc int[8];
664664
for (int i = 0; i < 8; i++)
665665
{
666666
seeds[i] = (int)((rnum >> (i * 4)) & 0xF);
667667
seeds[i] *= seeds[i];
668668
}
669669

670670

671-
int* sh = stackalloc int[2];
672-
sh[0] = (seed & 2) != 0 ? 4 : 5;
673-
sh[1] = block.part_num == 3 ? 6 : 5;
671+
ReadOnlySpan<int> sh = stackalloc int[2]
672+
{
673+
(seed & 2) != 0 ? 4 : 5,
674+
block.part_num == 3 ? 6 : 5
675+
};
674676

675677
if ((seed & 1) != 0)
676678
{
@@ -774,7 +776,7 @@ private unsafe static void ApplicateColor(BlockData block, Span<uint> output)
774776
}
775777
}
776778

777-
private unsafe static void DecodeIntseq(byte* input, int offset, int a, int b, int count, bool reverse, IntSeqData* _out)
779+
private unsafe static void DecodeIntseq(byte* input, int offset, int a, int b, int count, bool reverse, Span<IntSeqData> _out)
778780
{
779781
if (count <= 0)
780782
{

0 commit comments

Comments
 (0)