Skip to content

Commit b5b6b5a

Browse files
committed
Remove non-generic methods for DXT and YUY2
1 parent 2c2f948 commit b5b6b5a

File tree

5 files changed

+13
-116
lines changed

5 files changed

+13
-116
lines changed

AssetRipper.TextureDecoder.ConsoleApp/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void Main(string[] args)
5252
DecodeRgb(data, width, height, args5, bitmap.Bits);
5353
break;
5454
case "yuy2":
55-
Yuy2Decoder.DecompressYUY2(data, width, height, bitmap.Bits);
55+
Yuy2Decoder.DecompressYUY2<ColorBGRA32, byte>(data, width, height, bitmap.Bits);
5656
break;
5757
default:
5858
throw new NotSupportedException(inputType);
@@ -179,13 +179,13 @@ private static void DecodeDxt(ReadOnlySpan<byte> input, int width, int height, s
179179
switch (mode)
180180
{
181181
case 0:
182-
DxtDecoder.DecompressDXT1(input, width, height, output);
182+
DxtDecoder.DecompressDXT1<ColorBGRA32, byte>(input, width, height, output);
183183
break;
184184
case 1:
185-
DxtDecoder.DecompressDXT3(input, width, height, output);
185+
DxtDecoder.DecompressDXT3<ColorBGRA32, byte>(input, width, height, output);
186186
break;
187187
case 2:
188-
DxtDecoder.DecompressDXT5(input, width, height, output);
188+
DxtDecoder.DecompressDXT5<ColorBGRA32, byte>(input, width, height, output);
189189
break;
190190

191191
default:

AssetRipper.TextureDecoder.Tests/BcTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void Decompress_BC1()
2828
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4 }) //mipmaps 2 and 1 cause a buffer overrun for the output
2929
{
3030
int bytesRead = Bc1.Decompress(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
31-
DxtDecoder.DecompressDXT1(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
31+
DxtDecoder.DecompressDXT1<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
3232
totalBytesRead += bytesRead;
3333
AssertAlmostEqual(dxtDecodedData, bcDecodedData);
3434
}
@@ -43,7 +43,7 @@ public void Decompress_BC2()
4343
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4 }) //mipmaps 2 and 1 cause a buffer overrun for the output
4444
{
4545
int bytesRead = Bc2.Decompress(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
46-
DxtDecoder.DecompressDXT3(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
46+
DxtDecoder.DecompressDXT3<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
4747
totalBytesRead += bytesRead;
4848
AssertAlmostEqual(dxtDecodedData, bcDecodedData);
4949
}
@@ -58,7 +58,7 @@ public void Decompress_BC3()
5858
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4 }) //mipmaps 2 and 1 cause a buffer overrun for the output
5959
{
6060
int bytesRead = Bc3.Decompress(data.Slice(totalBytesRead), size, size, out byte[] bcDecodedData);
61-
DxtDecoder.DecompressDXT5(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
61+
DxtDecoder.DecompressDXT5<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out byte[] dxtDecodedData);
6262
totalBytesRead += bytesRead;
6363
AssertAlmostEqual(dxtDecodedData, bcDecodedData);
6464
}

AssetRipper.TextureDecoder.Tests/DxtTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace AssetRipper.TextureDecoder.Tests
1+
using AssetRipper.TextureDecoder.Rgb.Formats;
2+
3+
namespace AssetRipper.TextureDecoder.Tests
24
{
35
public sealed class DxtTests
46
{
@@ -9,7 +11,7 @@ public void DecompressDXT1Test()
911
int totalBytesRead = 0;
1012
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
1113
{
12-
int bytesRead = Dxt.DxtDecoder.DecompressDXT1(data.Slice(totalBytesRead), size, size, out _);
14+
int bytesRead = Dxt.DxtDecoder.DecompressDXT1<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
1315
totalBytesRead += bytesRead;
1416
}
1517
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
@@ -22,7 +24,7 @@ public void DecompressDXT3Test()
2224
int totalBytesRead = 0;
2325
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
2426
{
25-
int bytesRead = Dxt.DxtDecoder.DecompressDXT3(data.Slice(totalBytesRead), size, size, out _);
27+
int bytesRead = Dxt.DxtDecoder.DecompressDXT3<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
2628
totalBytesRead += bytesRead;
2729
}
2830
Assert.That(totalBytesRead, Is.EqualTo(data.Length));
@@ -35,7 +37,7 @@ public void DecompressDXT5Test()
3537
int totalBytesRead = 0;
3638
foreach (int size in new int[] { 256, 128, 64, 32, 16, 8, 4, 2, 1 }) //mip maps
3739
{
38-
int bytesRead = Dxt.DxtDecoder.DecompressDXT5(data.Slice(totalBytesRead), size, size, out _);
40+
int bytesRead = Dxt.DxtDecoder.DecompressDXT5<ColorBGRA32, byte>(data.Slice(totalBytesRead), size, size, out _);
3941
totalBytesRead += bytesRead;
4042
}
4143
Assert.That(totalBytesRead, Is.EqualTo(data.Length));

AssetRipper.TextureDecoder/Dxt/DxtDecoder.cs

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,6 @@ namespace AssetRipper.TextureDecoder.Dxt
66
{
77
public static class DxtDecoder
88
{
9-
/// <summary>
10-
/// Decompress a DXT1 image
11-
/// </summary>
12-
/// <param name="input">Input buffer containing the compressed image.</param>
13-
/// <param name="width">Pixel width of the image.</param>
14-
/// <param name="height">Pixel height of the image.</param>
15-
/// <param name="output">An output buffer of size 4 * width * height.</param>
16-
/// <returns>Number of bytes read from <paramref name="input"/></returns>
17-
public static int DecompressDXT1(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
18-
{
19-
return DecompressDXT1<ColorBGRA32, byte>(input, width, height, out output);
20-
}
21-
22-
/// <summary>
23-
/// Decompress a DXT1 image
24-
/// </summary>
25-
/// <param name="input">Input buffer containing the compressed image.</param>
26-
/// <param name="width">Pixel width of the image.</param>
27-
/// <param name="height">Pixel height of the image.</param>
28-
/// <param name="output">An output buffer. Must be at least 4 * width * height.</param>
29-
/// <returns>Number of bytes read from <paramref name="input"/></returns>
30-
public static int DecompressDXT1(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
31-
{
32-
return DecompressDXT1<ColorBGRA32, byte>(input, width, height, output);
33-
}
34-
359
/// <summary>
3610
/// Decompress a DXT1 image
3711
/// </summary>
@@ -128,32 +102,6 @@ public static int DecompressDXT1<TOutputColor, TOutputChannelValue>(ReadOnlySpan
128102
return offset;
129103
}
130104

131-
/// <summary>
132-
/// Decompress a DXT3 image
133-
/// </summary>
134-
/// <param name="input">Input buffer containing the compressed image.</param>
135-
/// <param name="width">Pixel width of the image.</param>
136-
/// <param name="height">Pixel height of the image.</param>
137-
/// <param name="output">An output buffer of size 4 * width * height.</param>
138-
/// <returns>Number of bytes read from <paramref name="input"/></returns>
139-
public static int DecompressDXT3(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
140-
{
141-
return DecompressDXT3<ColorBGRA32, byte>(input, width, height, out output);
142-
}
143-
144-
/// <summary>
145-
/// Decompress a DXT3 image
146-
/// </summary>
147-
/// <param name="input">Input buffer containing the compressed image.</param>
148-
/// <param name="width">Pixel width of the image.</param>
149-
/// <param name="height">Pixel height of the image.</param>
150-
/// <param name="output">An output buffer. Must be at least 4 * width * height.</param>
151-
/// <returns>Number of bytes read from <paramref name="input"/></returns>
152-
public static int DecompressDXT3(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
153-
{
154-
return DecompressDXT3<ColorBGRA32, byte>(input, width, height, output);
155-
}
156-
157105
/// <summary>
158106
/// Decompress a DXT3 image
159107
/// </summary>
@@ -260,32 +208,6 @@ public static int DecompressDXT3<TOutputColor, TOutputChannelValue>(ReadOnlySpan
260208
return offset;
261209
}
262210

263-
/// <summary>
264-
/// Decompress a DXT5 image
265-
/// </summary>
266-
/// <param name="input">Input buffer containing the compressed image.</param>
267-
/// <param name="width">Pixel width of the image.</param>
268-
/// <param name="height">Pixel height of the image.</param>
269-
/// <param name="output">An output buffer of size 4 * width * height.</param>
270-
/// <returns>Number of bytes read from <paramref name="input"/></returns>
271-
public static int DecompressDXT5(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
272-
{
273-
return DecompressDXT5<ColorBGRA32, byte>(input, width, height, out output);
274-
}
275-
276-
/// <summary>
277-
/// Decompress a DXT5 image
278-
/// </summary>
279-
/// <param name="input">Input buffer containing the compressed image.</param>
280-
/// <param name="width">Pixel width of the image.</param>
281-
/// <param name="height">Pixel height of the image.</param>
282-
/// <param name="output">An output buffer. Must be at least 4 * width * height.</param>
283-
/// <returns>Number of bytes read from <paramref name="input"/></returns>
284-
public static int DecompressDXT5(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
285-
{
286-
return DecompressDXT5<ColorBGRA32, byte>(input, width, height, output);
287-
}
288-
289211
/// <summary>
290212
/// Decompress a DXT5 image
291213
/// </summary>

AssetRipper.TextureDecoder/Yuy2/Yuy2Decoder.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,9 @@
11
using AssetRipper.TextureDecoder.Rgb;
2-
using AssetRipper.TextureDecoder.Rgb.Formats;
32

43
namespace AssetRipper.TextureDecoder.Yuy2
54
{
65
public static class Yuy2Decoder
76
{
8-
/// <summary>
9-
/// Decompress a YUY2 image
10-
/// </summary>
11-
/// <param name="input">Input buffer containing the compressed image.</param>
12-
/// <param name="width">Pixel width of the image.</param>
13-
/// <param name="height">Pixel height of the image.</param>
14-
/// <param name="output">An output buffer of size 4 * width * height.</param>
15-
/// <returns>Number of bytes read from <paramref name="input"/></returns>
16-
public static int DecompressYUY2(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
17-
{
18-
return DecompressYUY2<ColorBGRA32, byte>(input, width, height, out output);
19-
}
20-
21-
/// <summary>
22-
/// Decompress a YUY2 image
23-
/// </summary>
24-
/// <param name="input">Input buffer containing the compressed image.</param>
25-
/// <param name="width">Pixel width of the image.</param>
26-
/// <param name="height">Pixel height of the image.</param>
27-
/// <param name="output">An output buffer. Must be at least 4 * width * height.</param>
28-
/// <returns>Number of bytes read from <paramref name="input"/></returns>
29-
public static int DecompressYUY2(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
30-
{
31-
return DecompressYUY2<ColorBGRA32, byte>(input, width, height, output);
32-
}
33-
347
/// <summary>
358
/// Decompress a YUY2 image
369
/// </summary>

0 commit comments

Comments
 (0)