Commit 7f6c7c87 authored by David Michael Barr's avatar David Michael Barr Committed by Thomas Daede

Buffer last reconstructed frame

The "Show Existing Frames" feature uses this to copy into the
reconstruction stream.
parent c5d838cc
......@@ -16,8 +16,9 @@ fn main() {
let sequence = Sequence::new();
write_ivf_header(&mut files.output_file, fi.sb_width*64, fi.sb_height*64);
let mut last_rec: Option<Frame> = None;
loop {
if !process_frame(&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(), &mut last_rec) {
break;
}
fi.number += 1;
......
......@@ -22,6 +22,7 @@ fn main() {
let mut rl = Editor::<()>::new();
let _ = rl.load_history(".rav1e-history");
let mut last_rec: Option<Frame> = None;
loop {
let readline = rl.readline(">> ");
match readline {
......@@ -29,7 +30,7 @@ fn main() {
rl.add_history_entry(&line);
match line.split_whitespace().next() {
Some("process_frame") => {
process_frame(&sequence, &fi, &mut files.output_file, &mut y4m_dec, y4m_enc.as_mut());
process_frame(&sequence, &fi, &mut files.output_file, &mut y4m_dec, y4m_enc.as_mut(), &mut last_rec);
fi.number += 1;
if fi.number == files.limit {
break;
......
......@@ -371,10 +371,17 @@ fn encode_tile(fi: &FrameInvariants, fs: &mut FrameState) -> Vec<u8> {
h
}
fn encode_frame(sequence: &Sequence, fi: &FrameInvariants, fs: &mut FrameState) -> Vec<u8> {
fn encode_frame(sequence: &Sequence, fi: &FrameInvariants, fs: &mut FrameState, last_rec: &Option<Frame>) -> Vec<u8> {
let mut packet = Vec::new();
write_uncompressed_header(&mut packet, sequence, fi).unwrap();
if !fi.show_existing_frame {
if fi.show_existing_frame {
match last_rec {
&Some(ref rec) => for p in 0..3 {
fs.rec.planes[p].data.copy_from_slice(rec.planes[p].data.as_slice());
},
&None => (),
}
} else {
let tile = encode_tile(fi, fs);
packet.write(&tile).unwrap();
}
......@@ -385,7 +392,8 @@ fn encode_frame(sequence: &Sequence, fi: &FrameInvariants, fs: &mut FrameState)
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 {
y4m_enc: Option<&mut y4m::Encoder<Box<Write>>>,
last_rec: &mut Option<Frame>) -> bool {
let width = fi.width;
let height = fi.height;
match y4m_dec.read_frame() {
......@@ -413,7 +421,7 @@ pub fn process_frame(sequence: &Sequence, fi: &FrameInvariants,
fs.input.planes[2].data[y*stride+x] = y4m_v[y*width/2+x] as u16;
}
}
let packet = encode_frame(&sequence, &fi, &mut fs);
let packet = encode_frame(&sequence, &fi, &mut fs, &last_rec);
write_ivf_frame(output_file, fi.number, packet.as_ref());
match y4m_enc {
Some(mut y4m_enc) => {
......@@ -443,6 +451,7 @@ pub fn process_frame(sequence: &Sequence, fi: &FrameInvariants,
}
None => {}
}
*last_rec = Some(fs.rec);
true
},
_ => false
......
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