mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-08-12 02:29:00 +08:00
Replace DecodeVarInt function with LEB128
This commit is contained in:
parent
60b3928e56
commit
f51669f55e
@ -47,7 +47,7 @@ section is the header. The second section contains the metadata. This section is
|
|||||||
* When bit reading is finished it will always pad the read to the current
|
* When bit reading is finished it will always pad the read to the current
|
||||||
byte.
|
byte.
|
||||||
|
|
||||||
* varUI32 and varUI64 types must be decoded by the DecodeVarint() function.
|
* varUI32 and varUI64 types must be decoded by the LEB128() function.
|
||||||
|
|
||||||
|
|
||||||
### General Conventions
|
### General Conventions
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
|
|
||||||
## Core Functions
|
## Core Functions
|
||||||
|
|
||||||
### DecodeVarint
|
### LEB128
|
||||||
|
|
||||||
~~~~~
|
~~~~~
|
||||||
void DecodeVarint(out_val) {
|
uint64_t LEB128() {
|
||||||
|
result = 0;
|
||||||
|
shift = 0;
|
||||||
|
while(true) {
|
||||||
in UI8
|
in UI8
|
||||||
if (in & (1 << 7)) {
|
result |= (low order 7 bits of in) << shift;
|
||||||
DecodeVarint(out_val);
|
if (high order bit of in == 0)
|
||||||
out_val = (out_val << 7) | (in & ((1 << 7) - 1));
|
break;
|
||||||
} else {
|
shift += 7;
|
||||||
out_val = in;
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
~~~~~
|
~~~~~
|
||||||
{:.draco-syntax }
|
{:.draco-syntax }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user