enc_qsv: factor out chapter save/restore code.