public static int SwfEncodedSizeOf(ulong value)
{
int numBytes = 0;
while (value > 0) // While the size of the value is greater than the
{ // current number of bytes can represent
value = value >> 7; // Reduce the representation of the value by 7 bit
numBytes++; // that are stored is one byte
if (value == 1) // If the value of the current byte is one
break; // no other byte needed
}
return numBytes > 0 ? numBytes : 1; // At least one byte is used to represent a value
}