mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
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
This commit is contained in:
parent
49611eb364
commit
e397b03f35
1 changed files with 11 additions and 9 deletions
|
@ -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.
|
* buffer in that segment, which is the offset expressed in DEFAULT units.
|
||||||
*/
|
*/
|
||||||
/* convert first timestamp of segment to sample position */
|
/* 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_AUDIO_INFO_RATE (&audiorate->info), GST_SECOND);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (audiorate, "resync to offset %" G_GINT64_FORMAT, pos);
|
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->discont = TRUE;
|
||||||
|
|
||||||
audiorate->next_offset = pos;
|
audiorate->next_offset = pos;
|
||||||
audiorate->next_ts = gst_util_uint64_scale_int (audiorate->next_offset,
|
audiorate->next_ts =
|
||||||
GST_SECOND, GST_AUDIO_INFO_RATE (&audiorate->info));
|
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)) {
|
if (audiorate->skip_to_first && GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
|
||||||
GST_DEBUG_OBJECT (audiorate, "but skipping to first buffer instead");
|
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_AUDIO_INFO_RATE (&audiorate->info), GST_SECOND);
|
||||||
GST_DEBUG_OBJECT (audiorate, "so resync to offset %" G_GINT64_FORMAT,
|
GST_DEBUG_OBJECT (audiorate, "so resync to offset %" G_GINT64_FORMAT,
|
||||||
pos);
|
pos);
|
||||||
|
@ -539,10 +540,11 @@ gst_audio_rate_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
* offset to get duration. Necessary complexity to get 'perfect'
|
* offset to get duration. Necessary complexity to get 'perfect'
|
||||||
* streams */
|
* streams */
|
||||||
GST_BUFFER_TIMESTAMP (fill) = audiorate->next_ts;
|
GST_BUFFER_TIMESTAMP (fill) = audiorate->next_ts;
|
||||||
audiorate->next_ts = gst_util_uint64_scale_int (audiorate->next_offset,
|
audiorate->next_ts =
|
||||||
GST_SECOND, rate);
|
gst_util_uint64_scale_int_round (audiorate->next_offset, GST_SECOND,
|
||||||
GST_BUFFER_DURATION (fill) = audiorate->next_ts -
|
rate);
|
||||||
GST_BUFFER_TIMESTAMP (fill);
|
GST_BUFFER_DURATION (fill) =
|
||||||
|
audiorate->next_ts - GST_BUFFER_TIMESTAMP (fill);
|
||||||
|
|
||||||
/* we created this buffer to fill a gap */
|
/* we created this buffer to fill a gap */
|
||||||
GST_BUFFER_FLAG_SET (fill, GST_BUFFER_FLAG_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_OFFSET_END (buf) = in_offset_end;
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (buf) = audiorate->next_ts;
|
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_SECOND, rate);
|
||||||
GST_BUFFER_DURATION (buf) = audiorate->next_ts - GST_BUFFER_TIMESTAMP (buf);
|
GST_BUFFER_DURATION (buf) = audiorate->next_ts - GST_BUFFER_TIMESTAMP (buf);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue