def freq_id_to_stream_id(f_id):
    """ Convert a frequency ID to a stream ID. """
    pre_encode = (0, (f_id % 16), (f_id // 16), (f_id // 256))
    stream_id = (
        (pre_encode[0] & 0xF)
        + ((pre_encode[1] & 0xF) << 4)
        + ((pre_encode[2] & 0xF) << 8)
        + ((pre_encode[3] & 0xF) << 12)
    )
    return stream_id