Skip to content

Commit

Permalink
fix: frame formula for timings
Browse files Browse the repository at this point in the history
  • Loading branch information
IshanGrover2004 committed Feb 17, 2024
1 parent 69155ee commit e40f895
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/lib_ccx/ccx_common_timing.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ size_t print_scc_time(struct ccx_boundary_time time, char *buf)
char *fmt = "%02u:%02u:%02u;%02u";
double frame;

// since 1000 ms has 29.97 frames ; each ms has 29.97/1000 frames
frame = time.time_in_ms * 29.97 / 1000;
frame = ((double)(time.time_in_ms - 1000 * (time.ss + 60 * (time.mm + 60 * time.hh))) * 29.97 / 1000);

return (size_t)sprintf(buf + time.set, fmt, time.hh, time.mm, time.ss, (unsigned)frame);
}
Expand Down
7 changes: 6 additions & 1 deletion src/rust/src/decoder/timing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ impl ccx_boundary_time {

/// Returns a hh:mm:ss;frame string of time for SCC format
pub fn get_scc_time_str(time: ccx_boundary_time) -> String {
let frame = (time.time_in_ms as f32 * 29.97 / 1000.00) as u8;
// Feel sorry for formatting:(
let frame: u8 = (((time.time_in_ms
- 1000 * ((time.ss as i64) + 60 * ((time.mm as i64) + 60 * (time.hh as i64))))
as f64)
* 29.97
/ 1000.0) as u8;
format!("{:02}:{:02}:{:02};{:02}", time.hh, time.mm, time.ss, frame)
}

0 comments on commit e40f895

Please sign in to comment.