Commit e8daa5c8 authored by Luc Trudeau's avatar Luc Trudeau

Move frame_number inside FrameInvariants

parent 8a74a222
......@@ -12,18 +12,16 @@ fn main() {
Some(rec_file) => Some(y4m::encode(width, height, y4m::Ratio::new(30,1)).write_header(rec_file).unwrap()),
None => None
};
let fi = FrameInvariants::new(width, height);
let mut fi = FrameInvariants::new(width, height);
let sequence = Sequence::new();
write_ivf_header(&mut files.output_file, fi.sb_width*64, fi.sb_height*64);
let mut frame_number = 0;
loop {
if !process_frame(frame_number, &sequence, &fi,
&mut files.output_file, &mut y4m_dec, y4m_enc.as_mut()) {
if !process_frame(&sequence, &fi, &mut files.output_file, &mut y4m_dec, y4m_enc.as_mut()) {
break;
}
frame_number += 1;
if frame_number == files.limit {
fi.number += 1;
if fi.number == files.limit {
break;
}
}
......
......@@ -16,11 +16,10 @@ fn main() {
Some(rec_file) => Some(y4m::encode(width, height, y4m::Ratio::new(30,1)).write_header(rec_file).unwrap()),
None => None
};
let fi = FrameInvariants::new(width, height);
let mut fi = FrameInvariants::new(width, height);
let sequence = Sequence::new();
write_ivf_header(&mut files.output_file, fi.sb_width*64, fi.sb_height*64);
let mut frame_number = 0;
let mut rl = Editor::<()>::new();
let _ = rl.load_history(".rav1e-history");
loop {
......@@ -30,10 +29,9 @@ fn main() {
rl.add_history_entry(&line);
match line.split_whitespace().next() {
Some("process_frame") => {
process_frame(frame_number, &sequence, &fi,
&mut files.output_file, &mut y4m_dec, y4m_enc.as_mut());
frame_number += 1;
if frame_number == files.limit {
process_frame(&sequence, &fi, &mut files.output_file, &mut y4m_dec, y4m_enc.as_mut());
fi.number += 1;
if fi.number == files.limit {
break;
}
},
......
......@@ -124,6 +124,7 @@ pub enum FrameType {
Inter
}
// Frame Invariants are invariant inside a frame
#[allow(dead_code)]
pub struct FrameInvariants {
pub qindex: usize,
......@@ -132,6 +133,7 @@ pub struct FrameInvariants {
pub sb_width: usize,
pub sb_height: usize,
pub frame_type: FrameType,
pub number: u64,
}
impl FrameInvariants {
......@@ -143,6 +145,7 @@ impl FrameInvariants {
sb_width: (width+63)/64,
sb_height: (height+63)/64,
frame_type: FrameType::Intra,
number: 0,
}
}
}
......@@ -419,7 +422,7 @@ fn encode_frame(sequence: &Sequence, fi: &FrameInvariants, fs: &mut FrameState)
}
/// Encode and write a frame.
pub fn process_frame(frame_number: u64, sequence: &Sequence, fi: &FrameInvariants,
pub fn process_frame(sequence: &Sequence, fi: &FrameInvariants,
output_file: &mut Write,
y4m_dec: &mut y4m::Decoder<Box<Read>>,
y4m_enc: Option<&mut y4m::Encoder<Box<Write>>>) -> bool {
......@@ -430,7 +433,7 @@ pub fn process_frame(frame_number: u64, sequence: &Sequence, fi: &FrameInvariant
let y4m_y = y4m_frame.get_y_plane();
let y4m_u = y4m_frame.get_u_plane();
let y4m_v = y4m_frame.get_v_plane();
eprintln!("Frame {}", frame_number);
eprintln!("Frame {}", fi.frame_number);
let mut fs = FrameState::new(&fi);
for y in 0..height {
for x in 0..width {
......@@ -451,7 +454,7 @@ pub fn process_frame(frame_number: u64, sequence: &Sequence, fi: &FrameInvariant
}
}
let packet = encode_frame(&sequence, &fi, &mut fs);
write_ivf_frame(output_file, frame_number, packet.as_ref());
write_ivf_frame(output_file, fi.number, packet.as_ref());
match y4m_enc {
Some(mut y4m_enc) => {
let mut rec_y = vec![128 as u8; width*height];
......
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