@@ -5,7 +5,22 @@ namespace AssetRipper.TextureDecoder.Bc;
55
66public static class Bc7
77{
8- internal const int BlockSize = 16 ;
8+ /// <summary>
9+ /// The size of an encoded block, in bytes.
10+ /// </summary>
11+ public const int BlockSize = 16 ;
12+ /// <summary>
13+ /// The width of a decoded block, in pixels.
14+ /// </summary>
15+ private const int BlockWidth = 4 ;
16+ /// <summary>
17+ /// The height of a decoded block, in pixels.
18+ /// </summary>
19+ private const int BlockHeight = 4 ;
20+ /// <summary>
21+ /// The size of the natural pixel type.
22+ /// </summary>
23+ private static int PixelSize => Unsafe . SizeOf < ColorRGBA < byte > > ( ) ;
924
1025 public static int Decompress ( ReadOnlySpan < byte > input , int width , int height , out byte [ ] output )
1126 {
@@ -16,13 +31,13 @@ public static int Decompress(ReadOnlySpan<byte> input, int width, int height, ou
1631 public static int Decompress ( ReadOnlySpan < byte > input , int width , int height , Span < byte > output )
1732 {
1833 int inputOffset = 0 ;
19- for ( int i = 0 ; i < height ; i += 4 )
34+ for ( int i = 0 ; i < height ; i += BlockHeight )
2035 {
21- for ( int j = 0 ; j < width ; j += 4 )
36+ for ( int j = 0 ; j < width ; j += BlockWidth )
2237 {
23- int outputOffset = ( ( i * width ) + j ) * Unsafe . SizeOf < ColorRGBA < byte > > ( ) ;
38+ int outputOffset = ( ( i * width ) + j ) * PixelSize ;
2439 BcHelpers . DecompressBc7 (
25- input . Slice ( inputOffset , BlockSize ) ,
40+ input . Slice ( inputOffset , BlockSize ) ,
2641 output . Slice ( outputOffset ) ,
2742 width * 4 ) ;
2843 inputOffset += BlockSize ;
0 commit comments