MCPcopy Create free account
hub / github.com/TheRealMJP/SHforHLSL / decodeVByte

Function decodeVByte

SHTest/Externals/meshoptimizer/indexcodec.cpp:95–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95static unsigned int decodeVByte(const unsigned char*& data)
96{
97 unsigned char lead = *data++;
98
99 // fast path: single byte
100 if (lead < 128)
101 return lead;
102
103 // slow path: up to 4 extra bytes
104 // note that this loop always terminates, which is important for malformed data
105 unsigned int result = lead & 127;
106 unsigned int shift = 7;
107
108 for (int i = 0; i < 4; ++i)
109 {
110 unsigned char group = *data++;
111 result |= unsigned(group & 127) << shift;
112 shift += 7;
113
114 if (group < 128)
115 break;
116 }
117
118 return result;
119}
120
121static void encodeIndex(unsigned char*& data, unsigned int index, unsigned int last)
122{

Callers 2

decodeIndexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected