Commit b44e5640 authored by Moises Cardona's avatar Moises Cardona Committed by Thomas Daede

Adds --low_latency and --keyint command line options

parent 72e1fac3
......@@ -31,6 +31,8 @@ impl Ratio {
#[derive(Copy, Clone, Debug)]
pub struct EncoderConfig {
pub key_frame_interval: u64,
pub low_latency: bool,
pub quantizer: usize,
pub speed: usize,
pub tune: Tune
......@@ -38,7 +40,7 @@ pub struct EncoderConfig {
impl Default for EncoderConfig {
fn default() -> Self {
EncoderConfig { quantizer: 100, speed: 0, tune: Tune::Psnr }
EncoderConfig { key_frame_interval: 30, low_latency: false, quantizer: 100, speed: 0, tune: Tune::Psnr }
}
}
......@@ -63,10 +65,12 @@ impl Config {
pub fn parse(&mut self, key: &str, value: &str) -> Result<(), EncoderStatus> {
use self::EncoderStatus::*;
match key {
"quantizer" => self.enc.quantizer = value.parse().map_err(|_e| ParseError)?,
"speed" => self.enc.speed = value.parse().map_err(|_e| ParseError)?,
"tune" => self.enc.tune = value.parse().map_err(|_e| ParseError)?,
_ => return Err(InvalidKey)
"low_latency" => self.enc.low_latency = value.parse().map_err(|_e| ParseError)?,
"key_frame_interval" => self.enc.key_frame_interval = value.parse().map_err(|_e| ParseError)?,
"quantizer" => self.enc.quantizer = value.parse().map_err(|_e| ParseError)?,
"speed" => self.enc.speed = value.parse().map_err(|_e| ParseError)?,
"tune" => self.enc.tune = value.parse().map_err(|_e| ParseError)?,
_ => return Err(InvalidKey)
}
Ok(())
......@@ -175,9 +179,9 @@ impl Context {
}
pub fn frame_properties(&mut self, idx: u64) -> bool {
let key_frame_interval: u64 = 30;
let key_frame_interval: u64 = self.fi.config.key_frame_interval;
let reorder = false;
let reorder = self.fi.config.low_latency;
let multiref = reorder || self.fi.config.speed <= 2;
let pyramid_depth = if reorder { 2 } else { 0 };
......
......@@ -50,6 +50,19 @@ pub fn parse_cli() -> (EncoderIO, EncoderConfig, usize) {
.long("speed")
.takes_value(true)
.default_value("3")
).arg(
Arg::with_name("KEYFRAME_INTERVAL")
.help("Keyframe interval")
.short("I")
.long("keyint")
.takes_value(true)
.default_value("30")
).arg(
Arg::with_name("LOW_LATENCY")
.help("low latency mode. true or false")
.long("low_latency")
.takes_value(true)
.default_value("false")
).arg(
Arg::with_name("TUNE")
.help("Quality tuning (Will enforce partition sizes >= 8x8)")
......@@ -74,6 +87,8 @@ pub fn parse_cli() -> (EncoderIO, EncoderConfig, usize) {
};
let config = EncoderConfig {
key_frame_interval: matches.value_of("KEYFRAME_INTERVAL").unwrap().parse().unwrap(),
low_latency: matches.value_of("LOW_LATENCY").unwrap().parse().unwrap(),
quantizer: matches.value_of("QP").unwrap().parse().unwrap(),
speed: matches.value_of("SPEED").unwrap().parse().unwrap(),
tune: matches.value_of("TUNE").unwrap().parse().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