diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2022-05-19 13:26:34 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2022-05-20 15:03:06 +0300 |
commit | d6fa9218227f5e208dcd1641445630daaea6afe9 (patch) | |
tree | 92b512e7153ef4e73fbf5b1b75b4c54642bfc1b1 | |
parent | 6bca5a9962a0671487f616a3d4097786f41878c3 (diff) |
fmp4mux: Use saturing_sub() in more places
On unclean input, PTS/DTS might go backwards a bit and in those cases
calculate a duration of 0 instead of panicking.
-rw-r--r-- | generic/fmp4/src/fmp4mux/imp.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/generic/fmp4/src/fmp4mux/imp.rs b/generic/fmp4/src/fmp4mux/imp.rs index d5ecd411..0fef270c 100644 --- a/generic/fmp4/src/fmp4mux/imp.rs +++ b/generic/fmp4/src/fmp4mux/imp.rs @@ -414,7 +414,7 @@ impl FMP4Mux { CAT, obj: &stream.sinkpad, "Queued full GOPs duration updated to {}", - prev_gop.end_pts - first_gop.earliest_pts, + prev_gop.end_pts.saturating_sub(first_gop.earliest_pts), ); } @@ -423,7 +423,7 @@ impl FMP4Mux { obj: &stream.sinkpad, "Queued duration updated to {}", Option::zip(stream.queued_gops.front(), stream.queued_gops.back()) - .map(|(end, start)| end.end_pts - start.start_pts) + .map(|(end, start)| end.end_pts.saturating_sub(start.start_pts)) .unwrap_or(gst::ClockTime::ZERO) ); @@ -589,7 +589,7 @@ impl FMP4Mux { CAT, obj: &stream.sinkpad, "Draining {} worth of buffers starting at PTS {} DTS {}, DTS offset {}", - end_pts - earliest_pts, + end_pts.saturating_sub(earliest_pts), earliest_pts, start_dts.display(), dts_offset.display(), @@ -603,7 +603,7 @@ impl FMP4Mux { CAT, obj: &stream.sinkpad, "Queued full GOPs duration updated to {}", - prev_gop.end_pts - first_gop.earliest_pts, + prev_gop.end_pts.saturating_sub(first_gop.earliest_pts), ); } @@ -612,7 +612,7 @@ impl FMP4Mux { obj: &stream.sinkpad, "Queued duration updated to {}", Option::zip(stream.queued_gops.front(), stream.queued_gops.back()) - .map(|(end, start)| end.end_pts - start.start_pts) + .map(|(end, start)| end.end_pts.saturating_sub(start.start_pts)) .unwrap_or(gst::ClockTime::ZERO) ); |