summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad <crh184@psu.edu>2014-12-02 15:58:00 -0500
committerTim-Philipp Müller <tim@centricular.com>2014-12-11 14:21:35 +0000
commit03dc6b82edaa9452c255411a5a94cede0e2785a2 (patch)
treeca06ab19c217f051d91369ce4112f3c1e6d560a6
parent8ec435420d9d4090cd8d6847ee7de385aeeea69a (diff)
audiorate: Use gst_util_uint64_scale_int_round()
Using gst_util_uint64_scale_int() causes slight drift which accumulates over time. https://bugzilla.gnome.org/show_bug.cgi?id=741045
-rw-r--r--gst/audiorate/gstaudiorate.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/gst/audiorate/gstaudiorate.c b/gst/audiorate/gstaudiorate.c
index a0818c919..9ac5beb80 100644
--- a/gst/audiorate/gstaudiorate.c
+++ b/gst/audiorate/gstaudiorate.c
@@ -445,7 +445,7 @@ gst_audio_rate_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
* buffer in that segment, which is the offset expressed in DEFAULT units.
*/
/* convert first timestamp of segment to sample position */
- pos = gst_util_uint64_scale_int (audiorate->src_segment.start,
+ pos = gst_util_uint64_scale_int_round (audiorate->src_segment.start,
GST_AUDIO_INFO_RATE (&audiorate->info), GST_SECOND);
GST_DEBUG_OBJECT (audiorate, "resync to offset %" G_GINT64_FORMAT, pos);
@@ -454,12 +454,13 @@ gst_audio_rate_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
audiorate->discont = TRUE;
audiorate->next_offset = pos;
- audiorate->next_ts = gst_util_uint64_scale_int (audiorate->next_offset,
- GST_SECOND, GST_AUDIO_INFO_RATE (&audiorate->info));
+ audiorate->next_ts =
+ gst_util_uint64_scale_int_round (audiorate->next_offset, GST_SECOND,
+ GST_AUDIO_INFO_RATE (&audiorate->info));
if (audiorate->skip_to_first && GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
GST_DEBUG_OBJECT (audiorate, "but skipping to first buffer instead");
- pos = gst_util_uint64_scale_int (GST_BUFFER_TIMESTAMP (buf),
+ pos = gst_util_uint64_scale_int_round (GST_BUFFER_TIMESTAMP (buf),
GST_AUDIO_INFO_RATE (&audiorate->info), GST_SECOND);
GST_DEBUG_OBJECT (audiorate, "so resync to offset %" G_GINT64_FORMAT,
pos);
@@ -539,10 +540,11 @@ gst_audio_rate_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
* offset to get duration. Necessary complexity to get 'perfect'
* streams */
GST_BUFFER_TIMESTAMP (fill) = audiorate->next_ts;
- audiorate->next_ts = gst_util_uint64_scale_int (audiorate->next_offset,
- GST_SECOND, rate);
- GST_BUFFER_DURATION (fill) = audiorate->next_ts -
- GST_BUFFER_TIMESTAMP (fill);
+ audiorate->next_ts =
+ gst_util_uint64_scale_int_round (audiorate->next_offset, GST_SECOND,
+ rate);
+ GST_BUFFER_DURATION (fill) =
+ audiorate->next_ts - GST_BUFFER_TIMESTAMP (fill);
/* we created this buffer to fill a gap */
GST_BUFFER_FLAG_SET (fill, GST_BUFFER_FLAG_GAP);
@@ -621,7 +623,7 @@ send:
GST_BUFFER_OFFSET_END (buf) = in_offset_end;
GST_BUFFER_TIMESTAMP (buf) = audiorate->next_ts;
- audiorate->next_ts = gst_util_uint64_scale_int (in_offset_end,
+ audiorate->next_ts = gst_util_uint64_scale_int_round (in_offset_end,
GST_SECOND, rate);
GST_BUFFER_DURATION (buf) = audiorate->next_ts - GST_BUFFER_TIMESTAMP (buf);