Commit 5b070f12 authored by Luca Barbato's avatar Luca Barbato Committed by Luca Barbato

Hide away the garbage_collect detail

parent 2ff9055f
......@@ -585,17 +585,21 @@ impl Context {
}
pub fn receive_packet(&mut self) -> Result<Packet, EncoderStatus> {
let mut idx = self.idx;
while !self.set_frame_properties(idx) {
self.idx += 1;
idx = self.idx;
}
let idx = {
let mut idx = self.idx;
while !self.set_frame_properties(idx) {
self.idx += 1;
idx = self.idx;
}
if !self.needs_more_frames(self.frame_data.get(&idx).unwrap().number) {
self.idx += 1;
return Err(EncoderStatus::EnoughData)
}
if !self.needs_more_frames(self.frame_data.get(&idx).unwrap().number) {
self.idx += 1;
return Err(EncoderStatus::EnoughData);
}
idx
};
let ret = {
let fi = self.frame_data.get_mut(&idx).unwrap();
if fi.show_existing_frame {
self.idx += 1;
......@@ -654,9 +658,16 @@ impl Context {
Err(EncoderStatus::NeedMoreData)
}
}
};
if let Ok(ref pkt) = ret {
self.garbage_collect(pkt.number);
}
ret
}
pub fn garbage_collect(&mut self, cur_frame: u64) {
fn garbage_collect(&mut self, cur_frame: u64) {
if cur_frame == 0 {
return;
}
......
......@@ -417,7 +417,6 @@ pub fn process_frame(
y4m_enc_uw.write_frame(&rec_frame).unwrap();
}
}
ctx.garbage_collect(pkt.number);
frame_summaries.push(pkt.into());
}
Ok(frame_summaries)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment