Skip to content

Commit 09f605e

Browse files
committed
Remove non-generic PVRTC methods
1 parent 40ef1f6 commit 09f605e

File tree

3 files changed

+5
-32
lines changed

3 files changed

+5
-32
lines changed

AssetRipper.TextureDecoder.ConsoleApp/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private static void DecodePvrtc(ReadOnlySpan<byte> input, int width, int height,
241241
{
242242
Console.WriteLine("Arg at index 5 : 2bitMode");
243243
bool do2bit = bool.Parse(do2bitModeString);
244-
PvrtcDecoder.DecompressPVRTC(input, width, height, do2bit, output);
244+
PvrtcDecoder.DecompressPVRTC<ColorBGRA32, byte>(input, width, height, do2bit, output);
245245
}
246246

247247
public static void WriteAllBytes(string path, ReadOnlySpan<byte> bytes)

AssetRipper.TextureDecoder.Tests/PvrtcTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using AssetRipper.TextureDecoder.Pvrtc;
2+
using AssetRipper.TextureDecoder.Rgb.Formats;
23

34
namespace AssetRipper.TextureDecoder.Tests;
45

@@ -11,7 +12,7 @@ public void DecompressPVRTCTest()
1112
int totalBytesRead = 0;
1213
foreach (int size in new int[] { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
1314
{
14-
int bytesRead = PvrtcDecoder.DecompressPVRTC(data, size, size, false, out _);
15+
int bytesRead = PvrtcDecoder.DecompressPVRTC<ColorBGRA32, byte>(data, size, size, false, out _);
1516
totalBytesRead += bytesRead;
1617
}
1718
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
@@ -32,7 +33,7 @@ public void DecompressPVRTCTest()
3233
private static void AssertCorrectDecompression<T>(bool do2bitMode, double maxMeanDeviation, double maxStandardDeviation) where T : ITexture
3334
{
3435
ReadOnlySpan<byte> data = T.Data;
35-
int bytesRead = PvrtcDecoder.DecompressPVRTC(data, T.Width, T.Height, do2bitMode, out byte[] decompressedData);
36+
int bytesRead = PvrtcDecoder.DecompressPVRTC<ColorBGRA32, byte>(data, T.Width, T.Height, do2bitMode, out byte[] decompressedData);
3637
if (!T.Mips)
3738
{
3839
Assert.That(bytesRead, Is.EqualTo(data.Length));

AssetRipper.TextureDecoder/Pvrtc/PvrtcDecoder.cs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,12 @@
22
#define ASSUME_IMAGE_TILING
33

44
using AssetRipper.TextureDecoder.Rgb;
5-
using AssetRipper.TextureDecoder.Rgb.Formats;
65
using System.Diagnostics;
76

87
namespace AssetRipper.TextureDecoder.Pvrtc
98
{
109
public static partial class PvrtcDecoder
1110
{
12-
/// <summary>
13-
/// Decompresses PVRTC to BGRA 8888
14-
/// </summary>
15-
/// <param name="input">The PVRTC texture data to decompress</param>
16-
/// <param name="xDim">X dimension (width) of the texture</param>
17-
/// <param name="yDim">Y dimension (height) of the texture</param>
18-
/// <param name="output">The decompressed texture data</param>
19-
/// <param name="do2bitMode">Signifies whether the data is PVRTC2 or PVRTC4</param>
20-
/// <returns>The number of bytes read from <paramref name="input"/></returns>
21-
public static int DecompressPVRTC(ReadOnlySpan<byte> input, int xDim, int yDim, bool do2bitMode, out byte[] output)
22-
{
23-
return DecompressPVRTC<ColorBGRA32, byte>(input, xDim, yDim, do2bitMode, out output);
24-
}
25-
26-
/// <summary>
27-
/// Decompresses PVRTC to BGRA 8888
28-
/// </summary>
29-
/// <param name="input">The PVRTC texture data to decompress</param>
30-
/// <param name="xDim">X dimension (width) of the texture</param>
31-
/// <param name="yDim">Y dimension (height) of the texture</param>
32-
/// <param name="output">The decompressed texture data</param>
33-
/// <param name="do2bitMode">Signifies whether the data is PVRTC2 or PVRTC4</param>
34-
/// <returns>The number of bytes read from <paramref name="input"/></returns>
35-
public static int DecompressPVRTC(ReadOnlySpan<byte> input, int xDim, int yDim, bool do2bitMode, Span<byte> output)
36-
{
37-
return DecompressPVRTC<ColorBGRA32, byte>(input, xDim, yDim, do2bitMode, output);
38-
}
39-
4011
/// <summary>
4112
/// Decompresses PVRTC
4213
/// </summary>
@@ -91,6 +62,7 @@ public static int DecompressPVRTC<TOutputColor, TOutputChannelValue>(ReadOnlySpa
9162
where TOutputColor : unmanaged, IColor<TOutputChannelValue>
9263
{
9364
ThrowHelper.ThrowIfNotLittleEndian();
65+
ThrowHelper.ThrowIfNotEnoughSpace(output.Length, xDim * yDim);
9466
int xBlockSize = do2bitMode ? BlockX2bpp : BlockX4bpp;
9567
// for MBX don't allow the sizes to get too small
9668
int blockXDim = Math.Max(2, xDim / xBlockSize);

0 commit comments

Comments
 (0)