mp4mux: Fix edit list shift for streams with initial DTS smaller earliest PTS but initial DTS positive

This would be a stream where the initial DTS is negative if the initial
PTS was zero, but it is offset so the initial DTS became positive now.
The edit list shift has to happen exactly the same way though.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1014>
This commit is contained in:
Sebastian Dröge 2022-12-15 18:52:47 +02:00
parent ed429d570e
commit 9307acf7fa

View file

@ -1683,9 +1683,11 @@ fn write_elst(
v.extend(duration.to_be_bytes());
// Media time
if let Some(gst::Signed::Negative(start_dts)) = stream.start_dts {
let shift = (stream.earliest_pts + start_dts)
if let Some(start_dts) = stream.start_dts {
let shift = (gst::Signed::Positive(stream.earliest_pts) - start_dts)
.nseconds()
.positive()
.unwrap_or(0)
.mul_div_round(timescale as u64, gst::ClockTime::SECOND.nseconds())
.context("too big track duration")?;