Commit b02246d3 authored by Vittorio Giovara's avatar Vittorio Giovara Committed by Luca Barbato
Browse files

crav1e: lib: Introduce a new function to parse options as integer

parent 099a4920
...@@ -12,6 +12,7 @@ use std::slice; ...@@ -12,6 +12,7 @@ use std::slice;
use std::sync::Arc; use std::sync::Arc;
use std::ffi::CStr; use std::ffi::CStr;
use std::ffi::CString;
use std::os::raw::c_char; use std::os::raw::c_char;
use std::os::raw::c_int; use std::os::raw::c_int;
...@@ -164,7 +165,7 @@ unsafe fn option_match( ...@@ -164,7 +165,7 @@ unsafe fn option_match(
Ok(()) Ok(())
} }
/// Set a configuration parameter using its key and value /// Set a configuration parameter using its key and value as string.
/// ///
/// Available keys and values /// Available keys and values
/// - "quantizer": 0-255, default 100 /// - "quantizer": 0-255, default 100
...@@ -181,6 +182,21 @@ pub unsafe extern "C" fn rav1e_config_parse( ...@@ -181,6 +182,21 @@ pub unsafe extern "C" fn rav1e_config_parse(
if option_match(cfg, key, value) == Ok(()) { 0 } else { -1 } if option_match(cfg, key, value) == Ok(()) { 0 } else { -1 }
} }
/// Set a configuration parameter using its key and value as integer.
///
/// Available keys and values are the same as rav1e_config_parse()
///
/// Return a negative value on error or 0.
#[no_mangle]
pub unsafe extern "C" fn rav1e_config_parse_int(
cfg: *mut Config,
key: *const c_char,
value: c_int,
) -> c_int {
let val = CString::new(value.to_string()).unwrap();
if option_match(cfg, key, val.as_ptr()) == Ok(()) { 0 } else { -1 }
}
/// Generate a new encoding context from a populated encoder configuration /// Generate a new encoding context from a populated encoder configuration
/// ///
/// Multiple contexts can be generated through it. /// Multiple contexts can be generated through it.
......
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