def _CalcLutOffsets(lods, isalpha):
    """
    Compute the offset into the lookup tables by LOD level.
    Return an array of offsets indexed by LOD. Also return
    (appended to the end of the result) the lookuop table size.
    The result differs depending on whether this is the alpha
    or brick LUT.
    The highest LOD is at the start of each table so it by
    definition has offset 0. Since the highest LOD level
    just has a single brick, the second highest will start
    at offset 1.
    """
    result = []
    pos = 0
    for e in reversed(lods):
        result.append(pos)
        pos = pos + e[0]*e[1]*(1 if isalpha else e[2])
    result.reverse()
    result.append(pos)
    #print("## CalcLutOffsets", result)
    return tuple(result)