public static int Ebml_Read_Num(this BinaryReader reader, int maxSize, out ulong number)
{
int n = 1;
ulong total = reader.ReadByte();
if (total==0)
throw GenIo("Read error at pos {0} ({0:X})\n",reader);
int read = 8 - FfLog2Tab[total];
if (read > maxSize)
throw GenIo("Invalid EBML number size tag 0x{1:X} at pos {0} ({0:X})\n", reader, total);
total ^= (ulong)(1 << FfLog2Tab[total]);
while (n++ < read)
{
byte b = reader.ReadByte();
total = (total << 8) | b;
}
number = total;
return read;
}