2.2.2.2.1.2.1.2 Two-Byte Unsigned Encoding (TWO_BYTE_UNSIGNED_ENCODING)

The TWO_BYTE_UNSIGNED_ENCODING structure is used to encode a value in the range 0x0000 to 0x7FFF by using a variable number of bytes. For example, 0x1A1B is encoded as { 0x9A, 0x1B }. The most significant bit of the first byte encodes 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)

c (1 bit): A 1-bit, unsigned integer field that contains an encoded representation of the number of bytes in this structure.

Value

Meaning

ONE_BYTE_VAL

0

Implies that the optional val2 field is not present. Hence, the structure is 1 byte in size.

TWO_BYTE_VAL

1

Implies that the optional val2 field is present. Hence, the structure is 2 bytes in size.

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

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