Commit 384d7de8 authored by Thomas Daede's avatar Thomas Daede Committed by Luca Barbato

Write real framerates.

parent 84d67cf9
......@@ -8,13 +8,14 @@ fn main() {
let mut y4m_dec = y4m::decode(&mut files.input_file).unwrap();
let width = y4m_dec.get_width();
let height = y4m_dec.get_height();
let framerate = y4m_dec.get_framerate();
let mut y4m_enc = match files.rec_file.as_mut() {
Some(rec_file) => Some(y4m::encode(width, height, y4m::Ratio::new(30,1)).write_header(rec_file).unwrap()),
Some(rec_file) => Some(y4m::encode(width, height, framerate).write_header(rec_file).unwrap()),
None => None
};
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);
write_ivf_header(&mut files.output_file, fi.sb_width*64, fi.sb_height*64, framerate.num, framerate.den);
let mut last_rec: Option<Frame> = None;
loop {
......
......@@ -12,13 +12,14 @@ fn main() {
let mut y4m_dec = y4m::decode(&mut files.input_file).unwrap();
let width = y4m_dec.get_width();
let height = y4m_dec.get_height();
let framerate = y4m_dec.get_framerate();
let mut y4m_enc = match files.rec_file.as_mut() {
Some(rec_file) => Some(y4m::encode(width, height, y4m::Ratio::new(30,1)).write_header(rec_file).unwrap()),
Some(rec_file) => Some(y4m::encode(width, height, framerate).write_header(rec_file).unwrap()),
None => None
};
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);
write_ivf_header(&mut files.output_file, fi.sb_width*64, fi.sb_height*64, framerate.num, framerate.den);
let mut rl = Editor::<()>::new();
let _ = rl.load_history(".rav1e-history");
......
......@@ -184,15 +184,15 @@ impl EncoderConfig {
}
// TODO: possibly just use bitwriter instead of byteorder
pub fn write_ivf_header(output_file: &mut Write, width: usize, height: usize) {
pub fn write_ivf_header(output_file: &mut Write, width: usize, height: usize, num: usize, den: usize) {
output_file.write(b"DKIF").unwrap();
output_file.write_u16::<LittleEndian>(0).unwrap(); // version
output_file.write_u16::<LittleEndian>(32).unwrap(); // header length
output_file.write(b"AV01").unwrap();
output_file.write_u16::<LittleEndian>(width as u16).unwrap();
output_file.write_u16::<LittleEndian>(height as u16).unwrap();
output_file.write_u32::<LittleEndian>(60).unwrap();
output_file.write_u32::<LittleEndian>(1).unwrap();
output_file.write_u32::<LittleEndian>(num as u32).unwrap();
output_file.write_u32::<LittleEndian>(den as u32).unwrap();
output_file.write_u32::<LittleEndian>(0).unwrap();
output_file.write_u32::<LittleEndian>(0).unwrap();
}
......
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