File tree Expand file tree Collapse file tree 1 file changed +15
-14
lines changed
AssetRipper.TextureDecoder/Bc Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change 22
33internal ref struct BitStream
44{
5- private ulong low ;
6- private ulong high ;
5+ private UInt128 value ;
6+
7+ private readonly uint BottomBits
8+ {
9+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
10+ get => unchecked ( ( uint ) this . value ) ;
11+ }
712
813 public BitStream ( ulong low , ulong high )
914 {
10- this . low = low ;
11- this . high = high ;
15+ value = new UInt128 ( high , low ) ;
1216 }
13-
17+
18+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
1419 public uint ReadBits ( int numBits )
1520 {
1621 uint mask = ( 1u << numBits ) - 1u ;
17- // Read the low N bits
18- uint bits = unchecked ( ( uint ) ( this . low & mask ) ) ;
19-
20- this . low >>= numBits ;
21- // Put the low N bits of "high" into the high 64-N bits of "low".
22- this . low |= ( this . high & mask ) << ( ( sizeof ( ulong ) * 8 ) - numBits ) ;
23- this . high >>= numBits ;
24-
22+ uint bits = BottomBits & mask ;
23+ this . value >>= numBits ;
2524 return bits ;
2625 }
2726
2827 [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
2928 public uint ReadBit ( )
3029 {
31- return this . ReadBits ( 1 ) ;
30+ uint result = BottomBits & 1u ;
31+ this . value >>= 1 ;
32+ return result ;
3233 }
3334
3435 /// <summary>
You can’t perform that action at this time.
0 commit comments