2.2.2.2.1.2.1.4 Four-Byte Unsigned Encoding (FOUR_BYTE_UNSIGNED_ENCODING)

The FOUR_BYTE_UNSIGNED_ENCODING structure is used to encode a value in the range 0x00000000 to 0x3FFFFFFF by using a variable number of bytes. For example, 0x001A1B1C is encoded as { 0x9A, 0x1B, 0x1C }. The two most significant bits of the first byte encode the number of bytes in the structure.


0


1


2


3


4


5


6


7


8


9

1
0


1


2


3


4


5


6


7


8


9

2
0


1


2


3


4


5


6


7


8


9

3
0


1

c

val1

val2 (optional)

val3 (optional)

val4 (optional)

c (2 bits): A 2-bit, unsigned integer field containing an encoded representation of the number of bytes in this structure.

Value

Meaning

ONE_BYTE_VAL

0

Implies that the optional val2, val3, and val4 fields are not present. Hence, the structure is 1 byte in size.

TWO_BYTE_VAL

1

Implies that the optional val2 field is present while the optional val3 and val4 fields are not present. Hence, the structure is 2 bytes in size.

THREE_BYTE_VAL

2

Implies that the optional val2 and val3 fields are present while the optional val4 fields are not present. Hence, the structure is 3 bytes in size.

FOUR_BYTE_VAL

3

Implies that the optional val2, val3, and val4 fields are all present. Hence, the structure is 4 bytes in size.

val1 (6 bits): A 6-bit, unsigned integer field containing the most significant 6 bits of the value represented by this structure.

val2 (1 byte): An 8-bit, unsigned integer containing the second most significant bits of the value represented by this structure.

val3 (1 byte): An 8-bit, unsigned integer containing the third most significant bits of the value represented by this structure.

val4 (1 byte): An 8-bit, unsigned integer containing the least significant bits of the value represented by this structure.