mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:56:14 +00:00
qtmux: replace _scale with _scale_round
Use the rounding version for improved sync between streams. Small variations in the duration when muxing might lead to cumullative wrong timestamping when demuxing. Fixes #602936
This commit is contained in:
parent
259c204f42
commit
79a9031c16
1 changed files with 5 additions and 5 deletions
|
@ -1326,7 +1326,7 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
|
||||||
|
|
||||||
gst_buffer_replace (&pad->last_buf, buf);
|
gst_buffer_replace (&pad->last_buf, buf);
|
||||||
|
|
||||||
last_dts = gst_util_uint64_scale (pad->last_dts,
|
last_dts = gst_util_uint64_scale_round (pad->last_dts,
|
||||||
atom_trak_get_timescale (pad->trak), GST_SECOND);
|
atom_trak_get_timescale (pad->trak), GST_SECOND);
|
||||||
|
|
||||||
/* raw audio has many samples per buffer (= chunk) */
|
/* raw audio has many samples per buffer (= chunk) */
|
||||||
|
@ -1348,10 +1348,10 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
|
||||||
gint64 scaled_dts;
|
gint64 scaled_dts;
|
||||||
pad->last_dts = GST_BUFFER_OFFSET_END (last_buf);
|
pad->last_dts = GST_BUFFER_OFFSET_END (last_buf);
|
||||||
if ((gint64) (pad->last_dts) < 0) {
|
if ((gint64) (pad->last_dts) < 0) {
|
||||||
scaled_dts = -gst_util_uint64_scale (-pad->last_dts,
|
scaled_dts = -gst_util_uint64_scale_round (-pad->last_dts,
|
||||||
atom_trak_get_timescale (pad->trak), GST_SECOND);
|
atom_trak_get_timescale (pad->trak), GST_SECOND);
|
||||||
} else {
|
} else {
|
||||||
scaled_dts = gst_util_uint64_scale (pad->last_dts,
|
scaled_dts = gst_util_uint64_scale_round (pad->last_dts,
|
||||||
atom_trak_get_timescale (pad->trak), GST_SECOND);
|
atom_trak_get_timescale (pad->trak), GST_SECOND);
|
||||||
}
|
}
|
||||||
scaled_duration = scaled_dts - last_dts;
|
scaled_duration = scaled_dts - last_dts;
|
||||||
|
@ -1361,7 +1361,7 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
|
||||||
* trak timescale, then derive delta;
|
* trak timescale, then derive delta;
|
||||||
* this ensures sums of (scale)delta add up to converted timestamp,
|
* this ensures sums of (scale)delta add up to converted timestamp,
|
||||||
* which only deviates at most 1/scale from timestamp itself */
|
* which only deviates at most 1/scale from timestamp itself */
|
||||||
scaled_duration = gst_util_uint64_scale (pad->last_dts + duration,
|
scaled_duration = gst_util_uint64_scale_round (pad->last_dts + duration,
|
||||||
atom_trak_get_timescale (pad->trak), GST_SECOND) - last_dts;
|
atom_trak_get_timescale (pad->trak), GST_SECOND) - last_dts;
|
||||||
pad->last_dts += duration;
|
pad->last_dts += duration;
|
||||||
}
|
}
|
||||||
|
@ -1396,7 +1396,7 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
|
||||||
if ((pad->have_dts || qtmux->guess_pts) && pad->is_out_of_order) {
|
if ((pad->have_dts || qtmux->guess_pts) && pad->is_out_of_order) {
|
||||||
guint64 pts;
|
guint64 pts;
|
||||||
|
|
||||||
pts = gst_util_uint64_scale (GST_BUFFER_TIMESTAMP (last_buf),
|
pts = gst_util_uint64_scale_round (GST_BUFFER_TIMESTAMP (last_buf),
|
||||||
atom_trak_get_timescale (pad->trak), GST_SECOND);
|
atom_trak_get_timescale (pad->trak), GST_SECOND);
|
||||||
pts_offset = (gint64) (pts - last_dts);
|
pts_offset = (gint64) (pts - last_dts);
|
||||||
do_pts = TRUE;
|
do_pts = TRUE;
|
||||||
|
|
Loading…
Reference in a new issue