[Matroska-devel] Signed integers in EBML

Alexander Noé alex at alexander-noe.com
Sun Jan 11 13:07:27 CET 2009


Richard Stitz schrieb:
> Hello,
>
> According to the PDF I downloaded about MKV/EBML:
>
> ---------
>
>   Signed integers have the following value: Read the integer as Unsigned Integer
>   and then subtract
>       vsint_subtr[length-1]
>   where
>       __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.  
The last value is correct, but the second last isn't: it should be:

0x00FFFFFFFFFFFF


regards,
Alex



More information about the Matroska-devel mailing list