Init foo_input_joc
build / windows (push) Has been cancelled

This commit is contained in:
TheM14 committed 2026-09-25 17:07:04 +08:00
commit ad62a914e6
127 files changed
+38545

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
#include "foundation/bit_reader.h"
namespace joc::bits {
bool variable_bits(BitReader& reader, unsigned width, unsigned max_groups, std::uint32_t* out_value) {
std::uint32_t value = 0;
for (unsigned group = 0; group < max_groups; ++group) {
value += reader.read(width);
if (reader.failed()) {
return false;
}
const std::uint32_t more = reader.read(1);
if (reader.failed()) {
return false;
}
if (more == 0u) {
if (out_value != nullptr) {
*out_value = value;
}
return true;
}
value = (value + 1u) << width;
}
// Same failure mode as the reference implementation: an extension chain
// that never terminates is a syntax error, not a truncation.
reader.fail(JOC_ERR_EMDF_SYNTAX, "variable_bits extension groups exceeded");
return false;
}
} // namespace joc::bits