code: public static long decodeFromExtendedUTF8(byte[] input) {
      int leadOnes = 0;
      int leadMask = 128;
      int work = input[0];
      while((work & leadMask) > 0) {
        leadOnes++;
        work = work << 1;
      }
      int valMask = 255 >>> (leadOnes+1);
      long val = input[0] & valMask;
      for(int i = 1; i < leadOnes; i++) {
        int midMask = 0x3F;
        val = val << 6;
        val = (input[i] & midMask) | val;
      }
      return val;
    }
docs: Decode an extended UTF8(as used in FLAC), to a long value.
  @param input extended UTF8 encoded value.
  @return value represented by the UTF8 input.