use rusty_h264_common::{ChromaFormat, Profile};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Preset {
#[default]
Fast,
Quality,
}
#[derive(Debug, Clone)]
pub struct EncoderConfig {
pub width: usize,
pub height: usize,
pub profile: Profile,
pub chroma: ChromaFormat,
pub level_idc: u8,
pub qp: u8,
pub gop_size: u32,
pub bitrate: u32,
pub framerate: f32,
pub num_ref_frames: u32,
pub preset: Preset,
}
impl EncoderConfig {
pub fn new(width: usize, height: usize) -> Self {
Self {
width,
height,
profile: Profile::ConstrainedBaseline,
chroma: ChromaFormat::Yuv420,
level_idc: 30,
qp: 26,
gop_size: 1,
bitrate: 0,
framerate: 30.0,
num_ref_frames: 1,
preset: Preset::Fast,
}
}
pub fn mb_width(&self) -> usize {
self.width.div_ceil(16)
}
pub fn mb_height(&self) -> usize {
self.height.div_ceil(16)
}
}