Commit fd6bfc88 authored by Luca Barbato's avatar Luca Barbato Committed by Thomas Daede

Fix and improve the stats output

Store the frame_type in the packet and implement Display for it.
parent 2444eeaf
...@@ -69,7 +69,14 @@ pub enum EncoderStatus { ...@@ -69,7 +69,14 @@ pub enum EncoderStatus {
pub struct Packet { pub struct Packet {
pub data: Vec<u8>, pub data: Vec<u8>,
pub rec: Frame, pub rec: Frame,
pub number: usize pub number: usize,
pub frame_type: FrameType
}
impl fmt::Display for Packet {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Frame {} - {} - {} bytes", self.number, self.frame_type, self.data.len())
}
} }
impl Context { impl Context {
...@@ -139,7 +146,7 @@ impl Context { ...@@ -139,7 +146,7 @@ impl Context {
update_rec_buffer(&mut self.fi, fs); update_rec_buffer(&mut self.fi, fs);
Ok(Packet { data, rec, number }) Ok(Packet { data, rec, number, frame_type: self.fi.frame_type })
} else { } else {
unimplemented!("Flushing not implemented") unimplemented!("Flushing not implemented")
} }
......
...@@ -126,10 +126,9 @@ pub fn process_frame(ctx: &mut Context, ...@@ -126,10 +126,9 @@ pub fn process_frame(ctx: &mut Context,
_ => panic! ("unknown input bit depth!"), _ => panic! ("unknown input bit depth!"),
} }
eprintln!("{}", ctx);
let _ = ctx.send_frame(input); let _ = ctx.send_frame(input);
let pkt = ctx.receive_packet().unwrap(); let pkt = ctx.receive_packet().unwrap();
eprintln!("{}", pkt);
write_ivf_frame(output_file, pkt.number as u64, pkt.data.as_ref()); write_ivf_frame(output_file, pkt.number as u64, pkt.data.as_ref());
if let Some(mut y4m_enc) = y4m_enc { if let Some(mut y4m_enc) = y4m_enc {
let pitch_y = if bit_depth > 8 { let pitch_y = if bit_depth > 8 {
......
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