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 {
244 .history244 .history
245 .next(force_keyframe || self.position >= self.gop_size);245 .next(force_keyframe || self.position >= self.gop_size);
246 self.poc = if step.key { 0 } else { self.poc + 1 };246 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+ });
248 self.history.store(&step, self.poc);253 self.history.store(&step, self.poc);
249 self.position = if step.key { 1 } else { self.position + 1 };254 self.position = if step.key { 1 } else { self.position + 1 };
250 self.flight.push(Meta {255 self.flight.push(Meta {
crates/ec-vk/src/history.rsmodified+3 -12
@@ -5,10 +5,10 @@ const ANCHOR_EVERY: u64 = 16;
5 const MAX_AGE: u64 = 120;5 const MAX_AGE: u64 = 120;
6 6
7 #[derive(Debug, Clone, Copy)]7 #[derive(Debug, Clone, Copy)]
8-struct Held<T> {8+pub(crate) struct Held<T> {
9 id: u64,9 id: u64,
10 acked: bool,10 acked: bool,
11- data: T,11+ pub(crate) data: T,
12 }12 }
13 13
14 /// Where the next picture goes and what it references.14 /// Where the next picture goes and what it references.
@@ -26,7 +26,7 @@ pub(crate) struct Step<T> {
26 /// acknowledged them, the last two chain each picture to the previous one.26 /// acknowledged them, the last two chain each picture to the previous one.
27 pub(crate) struct History<T> {27 pub(crate) struct History<T> {
28 next_id: u64,28 next_id: u64,
29- slots: [Option<Held<T>>; DPB_SLOTS],29+ pub(crate) slots: [Option<Held<T>>; DPB_SLOTS],
30 last: Option<(usize, T)>,30 last: Option<(usize, T)>,
31 next_anchor: usize,31 next_anchor: usize,
32 armed: bool,32 armed: bool,
@@ -107,15 +107,6 @@ impl<T: Copy> History<T> {
107 self.last = Some((slot, data));107 self.last = Some((slot, data));
108 }108 }
109 109
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-
119 fn newest_acked(&self, id: u64) -> Option<(usize, T)> {110 fn newest_acked(&self, id: u64) -> Option<(usize, T)> {
120 (0..DPB_SLOTS)111 (0..DPB_SLOTS)
121 .filter_map(|i| self.slots[i].map(|h| (i, h)))112 .filter_map(|i| self.slots[i].map(|h| (i, h)))