2.2.2.1 BitCompress(K)

BitCompress(K) is a method of encoding 32-bit unsigned integer values to a BitStream field structure. The encoding attempts to save space by representing only the significant bits.

The format of the BitCompress(K) is represented in the following table.


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

FirstKBits (variable)

...

E

ExtraBits (variable)

...

FirstKBits (K bits): The size of first bit field in the structure is a parameter in the encoding method. The first field of the BitCompress(K) structure stores most significant bits of the integer value. Notation for the BitCompress(K) structure includes the value of K in parenthesis.

E (1 bit): If the E field is set to zero, the ExtraBits field MUST NOT be present, and the integer value MUST equal the FirstKBits field. If E is set to 1, the ExtraBits field MUST be present.

ExtraBits (variable): A BitStream field structure within the BitCompress(K) structure that stores the least significant bits of the integer value. The size, in bits, of this structure MUST be 3, 7, 12, 18, 25, 33, or 42. Depending on the size, one of the following structures is used:

ExtraBits(2): 3-bit 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

X1

X0

S

ExtraBits(5): 7-bit 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

X4

X3

C

X2

X1

X0

S

ExtraBits(9): 12-bit 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

X8

X7

C

X6

X5

X4

C

X3

X2

X1

X0

S

ExtraBits(14): 18-bit 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

X

13

X

12

C

X

11

X

10

X9

C

X8

X7

X6

X5

C

X4

X3

X2

X1

X0

S

ExtraBits(20): 25-bit 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

X

19

X

18

C

X

17

X

16

X

15

C

X

14

X

13

X

12

X

11

C

X

10

X9

X8

X7

X6

C

X5

X4

X3

X2

X1

X0

S

ExtraBits(27): 33-bit 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

X

26

X

25

C

X

24

X

23

X

22

C

X

21

X

20

X

19

X

18

C

X

17

X

16

X

15

X

14

X

13

C

X

12

X

11

X

10

X9

X8

X7

C

X6

X5

X4

X3

X2

X1

X0

S

ExtraBits(35): 42-bit 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

P

P

C

P

X

31

X

30

C

X

29

X

28

X

27

X

26

C

X

25

X

24

X

23

X

22

X

21

C

X

20

X

19

X

18

X

17

X

16

X

15

C

X

14

X

13

X

12

X

11

X

10

X9

X8

C

X7

X6

X5

X4

X3

X2

X1

X0

S

In the preceding structures:

X0, X1, … , X31 (1 bit each): Represent the bits of the integer value. X0 is the least significant bit of the integer value.

C (1 bit): Continuation bit which MUST be set to 1. It indicates that the structure is to be continued with additional fields.

S (1 bit): Stop bit which MUST be set to 0. It indicates that the structure does not contain subsequent fields.

P (1 bit): Padding bits which MUST be set to 0. The padding bits are used when the cumulated size of the BitStream field structure is more than 32 bits. In this case, padding bits are added to the left-side field(s) (FirstKBits field or ExtraBits field) so that the least significant bit X0 is always the last bit before the stop bit.

Examples:

The value 5 represented as BitCompress(7):


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

0

0

0

0

1

0

1

0

The value 0xCCC represented as BitCompress(7):


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

1

1

0

0

1

1

0

1

0

1

1

1

0

0

0

The value 0xFFFFFFFE represented as BitCompress(2):


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

0

0

1

0

0

1

0

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

0

0