|
2 | 2 | #define ASSUME_IMAGE_TILING |
3 | 3 |
|
4 | 4 | using AssetRipper.TextureDecoder.Rgb; |
5 | | -using AssetRipper.TextureDecoder.Rgb.Formats; |
6 | 5 | using System.Diagnostics; |
7 | 6 |
|
8 | 7 | namespace AssetRipper.TextureDecoder.Pvrtc |
9 | 8 | { |
10 | 9 | public static partial class PvrtcDecoder |
11 | 10 | { |
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 | | - |
40 | 11 | /// <summary> |
41 | 12 | /// Decompresses PVRTC |
42 | 13 | /// </summary> |
@@ -91,6 +62,7 @@ public static int DecompressPVRTC<TOutputColor, TOutputChannelValue>(ReadOnlySpa |
91 | 62 | where TOutputColor : unmanaged, IColor<TOutputChannelValue> |
92 | 63 | { |
93 | 64 | ThrowHelper.ThrowIfNotLittleEndian(); |
| 65 | + ThrowHelper.ThrowIfNotEnoughSpace(output.Length, xDim * yDim); |
94 | 66 | int xBlockSize = do2bitMode ? BlockX2bpp : BlockX4bpp; |
95 | 67 | // for MBX don't allow the sizes to get too small |
96 | 68 | int blockXDim = Math.Max(2, xDim / xBlockSize); |
|
0 commit comments