[Matroska-devel] Signed integers in EBML

Richard Stitz richardstitz at gmail.com
Sun Jan 11 12:20:32 CET 2009


According to the PDF I downloaded about MKV/EBML:


  Signed integers have the following value: Read the integer as Unsigned Integer
  and then subtract
      __int64 vsint_subtr [] =
           { 0x3F, 0x1FFF, 0x0FFFFF, 0x07FFFFFF,
             0x03FFFFFFFF, 0x01FFFFFFFFFF,
             0x00FFFFFFFFFFFFFF, 0x007FFFFFFFFFFFFF };


At first glance, it looked like the value to be subtracted could be
calculated as:

  2^(x * 7 - 1) - 1

Where 'x' is the number of octets in the integer.  This would seem to
make perfect sense, allowing exactly half of the integer range to be
positive and half negative.  However, the last two values in the array
listed on the PDF do not conform to this formula.  Is this a typo in
the PDF, or should these 'imbalanced' values really be used?  Thanks.


More information about the Matroska-devel mailing list