Commit 7492fc5b authored by Luca Barbato's avatar Luca Barbato Committed by Thomas Daede

Rename Ratio to Rational

And restrict it to u64 instead of usize.
parent 555c32f0
......@@ -17,14 +17,14 @@ use std::sync::Arc;
// TODO: use the num crate?
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct Ratio {
pub num: usize,
pub den: usize
pub struct Rational {
pub num: u64,
pub den: u64
}
impl Ratio {
pub fn new(num: usize, den: usize) -> Self {
Ratio { num, den }
impl Rational {
pub fn new(num: u64, den: u64) -> Self {
Rational { num, den }
}
}
......@@ -56,7 +56,7 @@ pub struct FrameInfo {
#[derive(Clone, Copy, Debug)]
pub struct Config {
pub frame_info: FrameInfo,
pub timebase: Ratio,
pub timebase: Rational,
pub enc: EncoderConfig
}
......@@ -95,7 +95,7 @@ impl Config {
pub struct Context {
fi: FrameInvariants,
seq: Sequence,
// timebase: Ratio,
// timebase: Rational,
frame_count: u64,
idx: u64,
frame_q: BTreeMap<u64, Option<Arc<Frame>>>, // packet_q: VecDeque<Packet>
......
......@@ -55,7 +55,7 @@ fn main() {
let cfg = Config {
frame_info: FrameInfo { width, height, bit_depth, chroma_sampling },
timebase: Ratio::new(framerate.den, framerate.num),
timebase: Rational::new(framerate.den as u64, framerate.num as u64),
enc
};
......
......@@ -61,7 +61,7 @@ fn main() {
let cfg = Config {
frame_info: FrameInfo { width, height, bit_depth, chroma_sampling },
timebase: Ratio::new(framerate.den, framerate.num),
timebase: Rational::new(framerate.den as u64, framerate.num as u64),
enc
};
let mut ctx = cfg.new_context();
......
......@@ -83,7 +83,7 @@ fn setup_encoder(
let cfg = Config {
frame_info: FrameInfo { width: w, height: h, bit_depth, chroma_sampling },
timebase: Ratio::new(1, 1000),
timebase: Rational::new(1, 1000),
enc
};
......
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