layered encoding and generation