Properly clean up encoder state upon codec change.