From 09f605e45da83fff4734bd80260ff3cb116f371b Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Sun, 5 Oct 2025 23:11:47 -0700 Subject: [PATCH] Remove non-generic PVRTC methods --- .../Program.cs | 2 +- .../PvrtcTests.cs | 5 ++-- .../Pvrtc/PvrtcDecoder.cs | 30 +------------------ 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/AssetRipper.TextureDecoder.ConsoleApp/Program.cs b/AssetRipper.TextureDecoder.ConsoleApp/Program.cs index 7a406dd..ca1c760 100644 --- a/AssetRipper.TextureDecoder.ConsoleApp/Program.cs +++ b/AssetRipper.TextureDecoder.ConsoleApp/Program.cs @@ -241,7 +241,7 @@ internal static partial class Program { Console.WriteLine("Arg at index 5 : 2bitMode"); bool do2bit = bool.Parse(do2bitModeString); - PvrtcDecoder.DecompressPVRTC(input, width, height, do2bit, output); + PvrtcDecoder.DecompressPVRTC(input, width, height, do2bit, output); } public static void WriteAllBytes(string path, ReadOnlySpan bytes) diff --git a/AssetRipper.TextureDecoder.Tests/PvrtcTests.cs b/AssetRipper.TextureDecoder.Tests/PvrtcTests.cs index 024eff1..744b5f1 100644 --- a/AssetRipper.TextureDecoder.Tests/PvrtcTests.cs +++ b/AssetRipper.TextureDecoder.Tests/PvrtcTests.cs @@ -1,4 +1,5 @@ using AssetRipper.TextureDecoder.Pvrtc; +using AssetRipper.TextureDecoder.Rgb.Formats; namespace AssetRipper.TextureDecoder.Tests; @@ -11,7 +12,7 @@ public sealed class PvrtcTests int totalBytesRead = 0; foreach (int size in new int[] { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps { - int bytesRead = PvrtcDecoder.DecompressPVRTC(data, size, size, false, out _); + int bytesRead = PvrtcDecoder.DecompressPVRTC(data, size, size, false, out _); totalBytesRead += bytesRead; } Assert.That(totalBytesRead, Is.EqualTo(data.Length)); @@ -32,7 +33,7 @@ public sealed class PvrtcTests private static void AssertCorrectDecompression(bool do2bitMode, double maxMeanDeviation, double maxStandardDeviation) where T : ITexture { ReadOnlySpan data = T.Data; - int bytesRead = PvrtcDecoder.DecompressPVRTC(data, T.Width, T.Height, do2bitMode, out byte[] decompressedData); + int bytesRead = PvrtcDecoder.DecompressPVRTC(data, T.Width, T.Height, do2bitMode, out byte[] decompressedData); if (!T.Mips) { Assert.That(bytesRead, Is.EqualTo(data.Length)); diff --git a/AssetRipper.TextureDecoder/Pvrtc/PvrtcDecoder.cs b/AssetRipper.TextureDecoder/Pvrtc/PvrtcDecoder.cs index c9425d1..1e79cf3 100644 --- a/AssetRipper.TextureDecoder/Pvrtc/PvrtcDecoder.cs +++ b/AssetRipper.TextureDecoder/Pvrtc/PvrtcDecoder.cs @@ -2,41 +2,12 @@ #define ASSUME_IMAGE_TILING using AssetRipper.TextureDecoder.Rgb; -using AssetRipper.TextureDecoder.Rgb.Formats; using System.Diagnostics; namespace AssetRipper.TextureDecoder.Pvrtc { public static partial class PvrtcDecoder { - /// - /// Decompresses PVRTC to BGRA 8888 - /// - /// The PVRTC texture data to decompress - /// X dimension (width) of the texture - /// Y dimension (height) of the texture - /// The decompressed texture data - /// Signifies whether the data is PVRTC2 or PVRTC4 - /// The number of bytes read from - public static int DecompressPVRTC(ReadOnlySpan input, int xDim, int yDim, bool do2bitMode, out byte[] output) - { - return DecompressPVRTC(input, xDim, yDim, do2bitMode, out output); - } - - /// - /// Decompresses PVRTC to BGRA 8888 - /// - /// The PVRTC texture data to decompress - /// X dimension (width) of the texture - /// Y dimension (height) of the texture - /// The decompressed texture data - /// Signifies whether the data is PVRTC2 or PVRTC4 - /// The number of bytes read from - public static int DecompressPVRTC(ReadOnlySpan input, int xDim, int yDim, bool do2bitMode, Span output) - { - return DecompressPVRTC(input, xDim, yDim, do2bitMode, output); - } - /// /// Decompresses PVRTC /// @@ -91,6 +62,7 @@ namespace AssetRipper.TextureDecoder.Pvrtc where TOutputColor : unmanaged, IColor { ThrowHelper.ThrowIfNotLittleEndian(); + ThrowHelper.ThrowIfNotEnoughSpace(output.Length, xDim * yDim); int xBlockSize = do2bitMode ? BlockX2bpp : BlockX4bpp; // for MBX don't allow the sizes to get too small int blockXDim = Math.Max(2, xDim / xBlockSize);