MCPcopy Create free account
hub / github.com/IENT/YUView / readNS

Method readNS

YUViewLib/src/parser/common/SubByteReader.cpp:225–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225std::tuple<uint64_t, std::string> SubByteReader::readNS(uint64_t maxVal)
226{
227 if (maxVal == 0)
228 return {};
229
230 // FloorLog2
231 uint64_t floorVal;
232 {
233 auto x = maxVal;
234 unsigned s = 0;
235 while (x != 0)
236 {
237 x = x >> 1;
238 s++;
239 }
240 floorVal = s - 1;
241 }
242
243 auto w = floorVal + 1;
244 auto m = (uint64_t(1) << w) - maxVal;
245
246 auto [v, coding] = this->readBits(w - 1);
247 if (v < m)
248 return {v, coding};
249
250 auto [extra_bit, extra_bit_coding] = this->readBits(1);
251 return {(v << 1) - m + extra_bit, coding + extra_bit_coding};
252}
253
254std::tuple<int64_t, std::string> SubByteReader::readSU(unsigned nrBits)
255{

Callers 2

parseMethod · 0.45
decode_subexpFunction · 0.45

Calls 1

readBitsMethod · 0.95

Tested by

no test coverage detected