forge
Explore
Log in

Don't you dare go Hollow

U16: move History::kept into the H265 next_picture, its only caller

Browse files at this commit

cf857a20a69e05c43e7a60ad2715383b999a5be6Ahmet Kaan GümüşParent: 2b83b50
crates/ec-vk/src/h265.rsmodified+6 -1
@@ -244,7 +244,12 @@ impl H265Encoder {
244244 .history
245245 .next(force_keyframe || self.position >= self.gop_size);
246246 self.poc = if step.key { 0 } else { self.poc + 1 };
247- let keep = self.history.kept(&step);
247+ let reference = step.reference.map(|(slot, _)| slot as usize);
248+ let keep = std::array::from_fn(|i| {
249+ self.history.slots[i]
250+ .filter(|_| i != step.slot as usize && Some(i) != reference)
251+ .map(|h| h.data)
252+ });
248253 self.history.store(&step, self.poc);
249254 self.position = if step.key { 1 } else { self.position + 1 };
250255 self.flight.push(Meta {
crates/ec-vk/src/history.rsmodified+3 -12
@@ -5,10 +5,10 @@ const ANCHOR_EVERY: u64 = 16;
55 const MAX_AGE: u64 = 120;
66
77 #[derive(Debug, Clone, Copy)]
8-struct Held<T> {
8+pub(crate) struct Held<T> {
99 id: u64,
1010 acked: bool,
11- data: T,
11+ pub(crate) data: T,
1212 }
1313
1414 /// Where the next picture goes and what it references.
@@ -26,7 +26,7 @@ pub(crate) struct Step<T> {
2626 /// acknowledged them, the last two chain each picture to the previous one.
2727 pub(crate) struct History<T> {
2828 next_id: u64,
29- slots: [Option<Held<T>>; DPB_SLOTS],
29+ pub(crate) slots: [Option<Held<T>>; DPB_SLOTS],
3030 last: Option<(usize, T)>,
3131 next_anchor: usize,
3232 armed: bool,
@@ -107,15 +107,6 @@ impl<T: Copy> History<T> {
107107 self.last = Some((slot, data));
108108 }
109109
110- pub(crate) fn kept(&self, step: &Step<T>) -> [Option<T>; DPB_SLOTS] {
111- let reference = step.reference.map(|(slot, _)| slot as usize);
112- std::array::from_fn(|i| {
113- self.slots[i]
114- .filter(|_| i != step.slot as usize && Some(i) != reference)
115- .map(|h| h.data)
116- })
117- }
118-
119110 fn newest_acked(&self, id: u64) -> Option<(usize, T)> {
120111 (0..DPB_SLOTS)
121112 .filter_map(|i| self.slots[i].map(|h| (i, h)))