private int GetVarint(out uint value)
{
int b = array[ix];
value = (uint)b;
if ((value & 0x80) == 0)
{
return 1;
}
value &= 0x7F;
b = array[ix + 1];
value |= ((uint)b & 0x7F) << 7;
if ((b & 0x80) == 0)
{
return 2;
}
b = array[ix + 2];
value |= ((uint)b & 0x7F) << 14;
if ((b & 0x80) == 0)
{
return 3;
}
b = array[ix + 3];
value |= ((uint)b & 0x7F) << 21;
if ((b & 0x80) == 0)
{
return 4;
}
b = array[ix + 4];
value |= (uint)b << 28; // can only use 4 bits from this chunk
if ((b & 0xF0) == 0)
{
return 5;
}
throw new OverflowException();
}