A modular encoder and decoder