-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] Add timing module in
lib_ccxr
(#1640)
* feat: Add new module for timings functionality * feat: Add timing functionality in `timing.rs` module * feat: List all module & function conversion * chore: Clippy fixes * feat: Equivalent `ccx_common_timing.h` functions in rust module * feat: Add static constants & include struct in `build.rs` * feat: Add extern C functions * feat: Include & use rust extern functions in C * fix: Windows build * fix: Windows build --------- Co-authored-by: Prateek Sunal <[email protected]>
- Loading branch information
1 parent
349020e
commit cbd8e27
Showing
12 changed files
with
1,150 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
//! Provides Rust equivalent for functions in C. Uses Rust-native types as input and output. | ||
use super::*; | ||
|
||
/// Rust equivalent for `add_current_pts` function in C. Uses Rust-native types as input and output. | ||
pub fn add_current_pts(ctx: &mut TimingContext, pts: MpegClockTick) { | ||
ctx.add_current_pts(pts) | ||
} | ||
|
||
/// Rust equivalent for `set_current_pts` function in C. Uses Rust-native types as input and output. | ||
pub fn set_current_pts(ctx: &mut TimingContext, pts: MpegClockTick) { | ||
ctx.set_current_pts(pts) | ||
} | ||
|
||
/// Rust equivalent for `set_fts` function in C. Uses Rust-native types as input and output. | ||
pub fn set_fts(ctx: &mut TimingContext) -> bool { | ||
ctx.set_fts() | ||
} | ||
|
||
/// Rust equivalent for `get_fts` function in C. Uses Rust-native types as input and output. | ||
pub fn get_fts(ctx: &mut TimingContext, current_field: CaptionField) -> Timestamp { | ||
ctx.get_fts(current_field) | ||
} | ||
|
||
/// Rust equivalent for `get_fts_max` function in C. Uses Rust-native types as input and output. | ||
pub fn get_fts_max(ctx: &mut TimingContext) -> Timestamp { | ||
ctx.get_fts_max() | ||
} | ||
|
||
/// Rust equivalent for `print_mstime_static` function in C. Uses Rust-native types as input and output. | ||
pub fn print_mstime_static(mstime: Timestamp, sep: char) -> String { | ||
mstime.to_hms_millis_time(sep).unwrap() | ||
} | ||
|
||
/// Rust equivalent for `print_debug_timing` function in C. Uses Rust-native types as input and output. | ||
pub fn print_debug_timing(ctx: &mut TimingContext) { | ||
ctx.print_debug_timing() | ||
} | ||
|
||
/// Rust equivalent for `calculate_ms_gop_time` function in C. Uses Rust-native types as input and output. | ||
pub fn calculate_ms_gop_time(g: GopTimeCode) -> Timestamp { | ||
g.timestamp() | ||
} | ||
|
||
/// Rust equivalent for `gop_accepted` function in C. Uses Rust-native types as input and output. | ||
pub fn gop_accepted(g: GopTimeCode) -> bool { | ||
let mut timing_info = GLOBAL_TIMING_INFO.write().unwrap(); | ||
|
||
let gop_time = if let Some(gt) = timing_info.gop_time { | ||
gt | ||
} else { | ||
return true; | ||
}; | ||
|
||
if g.did_rollover(&gop_time) { | ||
timing_info.gop_rollover = true; | ||
true | ||
} else { | ||
gop_time.timestamp() <= g.timestamp() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.