//! The eight reference slots (AV1 spec 7.20, VP9 spec 8.10), shared by the VA-API and Vulkan decoders. use ec_av1_syntax::NUM_REF_FRAMES; /// What each reference slot holds, generic over the decoder's picture type. #[derive(Debug, Clone)] pub(crate) struct RefSlots { slots: [Option; NUM_REF_FRAMES], } impl RefSlots { pub(crate) fn new() -> Self { RefSlots { slots: std::array::from_fn(|_| None), } } pub(crate) fn get(&self, slot: usize) -> Option<&S> { self.slots.get(slot)?.as_ref() } #[cfg_attr(not(target_os = "linux"), allow(dead_code))] pub(crate) fn as_array(&self) -> &[Option; NUM_REF_FRAMES] { &self.slots } pub(crate) fn filled(&self) -> impl Iterator { self.slots.iter().flatten() } /// Store `value` in every slot named by the `refresh_frame_flags` bit mask. pub(crate) fn refresh(&mut self, flags: u8, value: Option) { for (slot, entry) in self.slots.iter_mut().enumerate() { if flags & (1 << slot) != 0 { entry.clone_from(&value); } } } }