Log2 function

inline R2uint32 log2(R2uint32 x) 
{
      unsigned int i = 0;
      while ( ( x = ( x >> 1 ) ) != 0 ) i++;
      return i;
}