Need to start PACKED at 4 bits to get the full 64 bits value range encoded, use nullable for better 0 compression

ryzomclassic-develop
kaetemi 4 years ago
parent b5f320af33
commit 6dfff83589

@ -150,7 +150,7 @@ inline uint readPackedBitCount(CBitMemStream & f)
{ {
uint64 nibbleCount; uint64 nibbleCount;
f.serial(nibbleCount, 4); f.serial(nibbleCount, 4);
uint bits = (nibbleCount << 2); uint bits = (nibbleCount << 2) + 4;
// nlinfo("PACKED: %u bits", (uint32)(bits)); // nlinfo("PACKED: %u bits", (uint32)(bits));
return bits; return bits;
} }

@ -519,7 +519,7 @@ bool CCDBSynchronised::writePermanentDelta( NLMISC::CBitMemStream& s )
inline void pushPackedValue( CBitMemStream& s, uint64 value, uint32& bitsize, uint &bits ) inline void pushPackedValue( CBitMemStream& s, uint64 value, uint32& bitsize, uint &bits )
{ {
// fast count of max bit // fast count of max bit
uint32 next = (uint32)(value >> 32); uint32 next = (uint32)(value >> (32 + 4));
uint32 test; uint32 test;
bits = 0; bits = 0;
if (next) // 64bit if (next) // 64bit
@ -529,7 +529,7 @@ inline void pushPackedValue( CBitMemStream& s, uint64 value, uint32& bitsize, ui
} }
else else
{ {
test = (uint32)(value & 0xFFFFFFFF); // 32 lsb test = (uint32)((value >> 4) & 0xFFFFFFFF); // 32 lsb
} }
next = (test >> 16); next = (test >> 16);
if (next) if (next)
@ -562,6 +562,7 @@ inline void pushPackedValue( CBitMemStream& s, uint64 value, uint32& bitsize, ui
} }
uint64 nibbleCount = (bits >> 2); uint64 nibbleCount = (bits >> 2);
s.serialAndLog2( nibbleCount, 4 ); s.serialAndLog2( nibbleCount, 4 );
bits += 4;
s.serialAndLog2( value, bits ); s.serialAndLog2( value, bits );
bitsize += (4 + bits); bitsize += (4 + bits);
} }

Loading…
Cancel
Save