refactor codec input and output
bex encoder v2 prepared