Commit 99e0bcef authored by Luca Barbato's avatar Luca Barbato Committed by Luca Barbato
Browse files

Use time_base

parent 7df33426
...@@ -32,7 +32,7 @@ pub struct VideoDetails { ...@@ -32,7 +32,7 @@ pub struct VideoDetails {
pub bit_depth: usize, pub bit_depth: usize,
pub chroma_sampling: ChromaSampling, pub chroma_sampling: ChromaSampling,
pub chroma_sample_position: ChromaSamplePosition, pub chroma_sample_position: ChromaSamplePosition,
pub framerate: Rational, pub time_base: Rational,
} }
impl Default for VideoDetails { impl Default for VideoDetails {
...@@ -46,7 +46,7 @@ impl Default for VideoDetails { ...@@ -46,7 +46,7 @@ impl Default for VideoDetails {
bit_depth: 8, bit_depth: 8,
chroma_sampling: ChromaSampling::Cs420, chroma_sampling: ChromaSampling::Cs420,
chroma_sample_position: ChromaSamplePosition::Unknown, chroma_sample_position: ChromaSamplePosition::Unknown,
framerate: Rational { num: 1, den: 1 } time_base: Rational { num: 30, den: 1 }
} }
} }
} }
......
...@@ -23,7 +23,7 @@ impl Decoder for y4m::Decoder<'_, Box<dyn Read>> { ...@@ -23,7 +23,7 @@ impl Decoder for y4m::Decoder<'_, Box<dyn Read>> {
}; };
let (chroma_sampling, chroma_sample_position) = map_y4m_color_space(color_space); let (chroma_sampling, chroma_sample_position) = map_y4m_color_space(color_space);
let framerate = self.get_framerate(); let framerate = self.get_framerate();
let framerate = Rational::new(framerate.num as u64, framerate.den as u64); let time_base = Rational::new(framerate.den as u64, framerate.num as u64);
VideoDetails { VideoDetails {
width, width,
height, height,
...@@ -33,7 +33,7 @@ impl Decoder for y4m::Decoder<'_, Box<dyn Read>> { ...@@ -33,7 +33,7 @@ impl Decoder for y4m::Decoder<'_, Box<dyn Read>> {
mono, mono,
chroma_sampling, chroma_sampling,
chroma_sample_position, chroma_sample_position,
framerate, time_base,
} }
} }
......
...@@ -29,7 +29,7 @@ fn main() { ...@@ -29,7 +29,7 @@ fn main() {
y4m::encode( y4m::encode(
video_info.width, video_info.width,
video_info.height, video_info.height,
y4m::Ratio::new(video_info.framerate.num as usize, video_info.framerate.den as usize) y4m::Ratio::new(video_info.time_base.den as usize, video_info.time_base.num as usize)
).with_colorspace(y4m_dec.get_colorspace()) ).with_colorspace(y4m_dec.get_colorspace())
.write_header(rec) .write_header(rec)
.unwrap() .unwrap()
...@@ -52,20 +52,20 @@ fn main() { ...@@ -52,20 +52,20 @@ fn main() {
"{}x{} @ {}/{} fps", "{}x{} @ {}/{} fps",
video_info.width, video_info.width,
video_info.height, video_info.height,
video_info.framerate.num, video_info.time_base.den,
video_info.framerate.den video_info.time_base.num
); );
write_ivf_header( write_ivf_header(
&mut cli.io.output, &mut cli.io.output,
video_info.width, video_info.width,
video_info.height, video_info.height,
video_info.framerate.num as usize, video_info.time_base.den as usize,
video_info.framerate.den as usize video_info.time_base.num as usize
); );
let mut progress = ProgressInfo::new( let mut progress = ProgressInfo::new(
video_info.framerate, Rational { num: video_info.time_base.den, den: video_info.time_base.num },
if cli.limit == 0 { None } else { Some(cli.limit) }, if cli.limit == 0 { None } else { Some(cli.limit) },
cfg.enc.show_psnr cfg.enc.show_psnr
); );
......
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