[Matroska-devel] EBML specification component for review - Variable size integer

Erik Piil piil.erik at gmail.com
Thu Apr 30 05:56:31 CEST 2015


This discussion relates to the “Variable size integer” portion of the
earlier EBML RFC Draft for revision/incorporation into the final EBML
specification.


>From the RFC Draft:


Variable size integer


For both element ID and size descriptor EBML uses a variable size integer,
coded according to a schema similar to that of UTF-8 [UTF-8] encoding. The
variable size integer begins with zero or more zero bits to define the
width of the integer. Zero zeroes means a width of one byte, one zero a
width of two bytes etc. The zeroes are followed by a marker of one set bit
and then follows the actual integer data. The integer data consists of
alignment data and tail data. The alignment data together with the width
descriptor and the marker makes up one ore more complete bytes. The tail
data is as many bytes as there were zeroes in the width descriptor, i.e.
width-1.


VINT = VINT_WIDTH VINT_MARKER VINT_DATA

VINT_WIDTH = *%b0

VINT_MARKER = %b1

VINT_DATA = VINT_ALIGNMENT VINT_TAIL

VINT_ALIGNMENT = *BIT

VINT_TAIL = *BYTE


An alternate way of expressing this is the following definition, where the
width is the number of levels of expansion.


VINT = ( %b0 VINT 7BIT ) / ( %b1 7BIT )


Some examples of the encoding of integers of width 1 to 4. The x:es
represent bits where the actual integer value would be stored.


Width  Size  Representation

1  2^7  1xxx xxxx

2  2^14  01xx xxxx xxxx xxxx

3  2^21  001x xxxx xxxx xxxx xxxx xxxx

4  2^28  0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx


Any thoughts are most appreciated.


Best,


Erik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.matroska.org/pipermail/matroska-devel/attachments/20150429/65b9ac30/attachment.html>


More information about the Matroska-devel mailing list