avcodec/cbs_av1_syntax_template: Check ref_frame_idx before use