MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / ReadBitpacked

Function ReadBitpacked

modules/engine/runtime/serde/binary/reader.cpp:117–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115{
116template <class T>
117inline int ReadBitpacked(skr_binary_reader_t* reader, T& value, IntegerPackConfig<T> config)
118{
119 SKR_ASSERT(config.min <= config.max);
120 SKR_ASSERT(reader->vread_bits);
121 if (!reader->vread_bits)
122 {
123 SKR_LOG_ERROR(u8"vread_bits is not implemented. falling back to vread");
124 return reader->read(&value, sizeof(T));
125 }
126 auto bits = 64 - skr::CountLeadingZeros64(config.max - config.min);
127 T compressed = 0;
128 int ret = reader->read_bits(&compressed, bits);
129 if (ret != 0)
130 return ret;
131 value = compressed + config.min;
132 return ret;
133}
134template <class T, class ScalarType>
135inline int ReadBitpacked(skr_binary_reader_t* reader, T& value, VectorPackConfig<ScalarType> config)
136{

Callers 1

ReadMethod · 0.85

Calls 5

CountLeadingZeros64Function · 0.50
isnanFunction · 0.50
readMethod · 0.45
read_bitsMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected