def safe_int(val):
    """
    Convert string/float to integer

    If input value is integer - return as-is
    If input value is a hexadecimal (0x00): converts hex to decimal

    Args:
        val: value to convert

    Raises:
        ValueError: if input value can not be converted
    """
    if isinstance(val, int):
        return val
    elif isinstance(val, str) and val.find('x') != -1:
        return int(val, 16)
    else:
        return int(val)
