diff --git a/AssetRipper.TextureDecoder.ConsoleApp/Program.cs b/AssetRipper.TextureDecoder.ConsoleApp/Program.cs index ca1c760..3b724e5 100644 --- a/AssetRipper.TextureDecoder.ConsoleApp/Program.cs +++ b/AssetRipper.TextureDecoder.ConsoleApp/Program.cs @@ -52,7 +52,7 @@ internal static partial class Program DecodeRgb(data, width, height, args5, bitmap.Bits); break; case "yuy2": - Yuy2Decoder.DecompressYUY2(data, width, height, bitmap.Bits); + Yuy2Decoder.DecompressYUY2(data, width, height, bitmap.Bits); break; default: throw new NotSupportedException(inputType); @@ -179,13 +179,13 @@ internal static partial class Program switch (mode) { case 0: - DxtDecoder.DecompressDXT1(input, width, height, output); + DxtDecoder.DecompressDXT1(input, width, height, output); break; case 1: - DxtDecoder.DecompressDXT3(input, width, height, output); + DxtDecoder.DecompressDXT3(input, width, height, output); break; case 2: - DxtDecoder.DecompressDXT5(input, width, height, output); + DxtDecoder.DecompressDXT5(input, width, height, output); break; default: diff --git a/AssetRipper.TextureDecoder.Tests/BcTests.cs b/AssetRipper.TextureDecoder.Tests/BcTests.cs index 34bf292..a10e427 100644 --- a/AssetRipper.TextureDecoder.Tests/BcTests.cs +++ b/AssetRipper.TextureDecoder.Tests/BcTests.cs @@ -28,7 +28,7 @@ namespace AssetRipper.TextureDecoder.Tests foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4 }) //mipmaps 2 and 1 cause a buffer overrun for the output { int bytesRead = Bc1.Decompress(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData); - DxtDecoder.DecompressDXT1(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData); + DxtDecoder.DecompressDXT1(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData); totalBytesRead += bytesRead; AssertAlmostEqual(dxtDecodedData, bcDecodedData); } @@ -43,7 +43,7 @@ namespace AssetRipper.TextureDecoder.Tests foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4 }) //mipmaps 2 and 1 cause a buffer overrun for the output { int bytesRead = Bc2.Decompress(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData); - DxtDecoder.DecompressDXT3(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData); + DxtDecoder.DecompressDXT3(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData); totalBytesRead += bytesRead; AssertAlmostEqual(dxtDecodedData, bcDecodedData); } @@ -58,7 +58,7 @@ namespace AssetRipper.TextureDecoder.Tests foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4 }) //mipmaps 2 and 1 cause a buffer overrun for the output { int bytesRead = Bc3.Decompress(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData); - DxtDecoder.DecompressDXT5(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData); + DxtDecoder.DecompressDXT5(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData); totalBytesRead += bytesRead; AssertAlmostEqual(dxtDecodedData, bcDecodedData); } diff --git a/AssetRipper.TextureDecoder.Tests/DxtTests.cs b/AssetRipper.TextureDecoder.Tests/DxtTests.cs index 1e0f416..c98b4a8 100644 --- a/AssetRipper.TextureDecoder.Tests/DxtTests.cs +++ b/AssetRipper.TextureDecoder.Tests/DxtTests.cs @@ -1,4 +1,6 @@ -namespace AssetRipper.TextureDecoder.Tests +using AssetRipper.TextureDecoder.Rgb.Formats; + +namespace AssetRipper.TextureDecoder.Tests { public sealed class DxtTests { @@ -9,7 +11,7 @@ int totalBytesRead = 0; foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps { - int bytesRead = Dxt.DxtDecoder.DecompressDXT1(data.Slice(totalBytesRead), size, size, out _); + int bytesRead = Dxt.DxtDecoder.DecompressDXT1(data.Slice(totalBytesRead), size, size, out _); totalBytesRead += bytesRead; } Assert.That(totalBytesRead, Is.EqualTo(data.Length)); @@ -22,7 +24,7 @@ int totalBytesRead = 0; foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps { - int bytesRead = Dxt.DxtDecoder.DecompressDXT3(data.Slice(totalBytesRead), size, size, out _); + int bytesRead = Dxt.DxtDecoder.DecompressDXT3(data.Slice(totalBytesRead), size, size, out _); totalBytesRead += bytesRead; } Assert.That(totalBytesRead, Is.EqualTo(data.Length)); @@ -35,7 +37,7 @@ int totalBytesRead = 0; foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps { - int bytesRead = Dxt.DxtDecoder.DecompressDXT5(data.Slice(totalBytesRead), size, size, out _); + int bytesRead = Dxt.DxtDecoder.DecompressDXT5(data.Slice(totalBytesRead), size, size, out _); totalBytesRead += bytesRead; } Assert.That(totalBytesRead, Is.EqualTo(data.Length)); diff --git a/AssetRipper.TextureDecoder/Dxt/DxtDecoder.cs b/AssetRipper.TextureDecoder/Dxt/DxtDecoder.cs index 86d4aab..1bb263b 100644 --- a/AssetRipper.TextureDecoder/Dxt/DxtDecoder.cs +++ b/AssetRipper.TextureDecoder/Dxt/DxtDecoder.cs @@ -6,32 +6,6 @@ namespace AssetRipper.TextureDecoder.Dxt { public static class DxtDecoder { - /// - /// Decompress a DXT1 image - /// - /// Input buffer containing the compressed image. - /// Pixel width of the image. - /// Pixel height of the image. - /// An output buffer of size 4 * width * height. - /// Number of bytes read from - public static int DecompressDXT1(ReadOnlySpan input, int width, int height, out byte[] output) - { - return DecompressDXT1(input, width, height, out output); - } - - /// - /// Decompress a DXT1 image - /// - /// Input buffer containing the compressed image. - /// Pixel width of the image. - /// Pixel height of the image. - /// An output buffer. Must be at least 4 * width * height. - /// Number of bytes read from - public static int DecompressDXT1(ReadOnlySpan input, int width, int height, Span output) - { - return DecompressDXT1(input, width, height, output); - } - /// /// Decompress a DXT1 image /// @@ -128,32 +102,6 @@ namespace AssetRipper.TextureDecoder.Dxt return offset; } - /// - /// Decompress a DXT3 image - /// - /// Input buffer containing the compressed image. - /// Pixel width of the image. - /// Pixel height of the image. - /// An output buffer of size 4 * width * height. - /// Number of bytes read from - public static int DecompressDXT3(ReadOnlySpan input, int width, int height, out byte[] output) - { - return DecompressDXT3(input, width, height, out output); - } - - /// - /// Decompress a DXT3 image - /// - /// Input buffer containing the compressed image. - /// Pixel width of the image. - /// Pixel height of the image. - /// An output buffer. Must be at least 4 * width * height. - /// Number of bytes read from - public static int DecompressDXT3(ReadOnlySpan input, int width, int height, Span output) - { - return DecompressDXT3(input, width, height, output); - } - /// /// Decompress a DXT3 image /// @@ -260,32 +208,6 @@ namespace AssetRipper.TextureDecoder.Dxt return offset; } - /// - /// Decompress a DXT5 image - /// - /// Input buffer containing the compressed image. - /// Pixel width of the image. - /// Pixel height of the image. - /// An output buffer of size 4 * width * height. - /// Number of bytes read from - public static int DecompressDXT5(ReadOnlySpan input, int width, int height, out byte[] output) - { - return DecompressDXT5(input, width, height, out output); - } - - /// - /// Decompress a DXT5 image - /// - /// Input buffer containing the compressed image. - /// Pixel width of the image. - /// Pixel height of the image. - /// An output buffer. Must be at least 4 * width * height. - /// Number of bytes read from - public static int DecompressDXT5(ReadOnlySpan input, int width, int height, Span output) - { - return DecompressDXT5(input, width, height, output); - } - /// /// Decompress a DXT5 image /// diff --git a/AssetRipper.TextureDecoder/Yuy2/Yuy2Decoder.cs b/AssetRipper.TextureDecoder/Yuy2/Yuy2Decoder.cs index c947d00..4b06298 100644 --- a/AssetRipper.TextureDecoder/Yuy2/Yuy2Decoder.cs +++ b/AssetRipper.TextureDecoder/Yuy2/Yuy2Decoder.cs @@ -1,36 +1,9 @@ using AssetRipper.TextureDecoder.Rgb; -using AssetRipper.TextureDecoder.Rgb.Formats; namespace AssetRipper.TextureDecoder.Yuy2 { public static class Yuy2Decoder { - /// - /// Decompress a YUY2 image - /// - /// Input buffer containing the compressed image. - /// Pixel width of the image. - /// Pixel height of the image. - /// An output buffer of size 4 * width * height. - /// Number of bytes read from - public static int DecompressYUY2(ReadOnlySpan input, int width, int height, out byte[] output) - { - return DecompressYUY2(input, width, height, out output); - } - - /// - /// Decompress a YUY2 image - /// - /// Input buffer containing the compressed image. - /// Pixel width of the image. - /// Pixel height of the image. - /// An output buffer. Must be at least 4 * width * height. - /// Number of bytes read from - public static int DecompressYUY2(ReadOnlySpan input, int width, int height, Span output) - { - return DecompressYUY2(input, width, height, output); - } - /// /// Decompress a YUY2 image ///