Save and restore the codec state when re-decoding