mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 11:32:38 +00:00
audiorate: be more accurate on offset math
Replace gst_util_uint64_scale_int for its rounding version to improve accuracy and avoid inserting samples where they aren't needed. Fixes #499181
This commit is contained in:
parent
eb9acba08f
commit
44d6ebc48f
1 changed files with 4 additions and 2 deletions
|
@ -175,6 +175,7 @@ gst_audio_rate_base_init (gpointer g_class)
|
||||||
gst_element_class_add_pad_template (element_class,
|
gst_element_class_add_pad_template (element_class,
|
||||||
gst_static_pad_template_get (&gst_audio_rate_src_template));
|
gst_static_pad_template_get (&gst_audio_rate_src_template));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audio_rate_class_init (GstAudioRateClass * klass)
|
gst_audio_rate_class_init (GstAudioRateClass * klass)
|
||||||
{
|
{
|
||||||
|
@ -520,14 +521,15 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
|
||||||
in_samples = in_size / audiorate->bytes_per_sample;
|
in_samples = in_size / audiorate->bytes_per_sample;
|
||||||
/* get duration from the size because we can and it's more accurate */
|
/* get duration from the size because we can and it's more accurate */
|
||||||
in_duration =
|
in_duration =
|
||||||
gst_util_uint64_scale_int (in_samples, GST_SECOND, audiorate->rate);
|
gst_util_uint64_scale_int_round (in_samples, GST_SECOND, audiorate->rate);
|
||||||
in_stop = in_time + in_duration;
|
in_stop = in_time + in_duration;
|
||||||
|
|
||||||
/* Figure out the total accumulated segment time. */
|
/* Figure out the total accumulated segment time. */
|
||||||
run_time = in_time + audiorate->src_segment.accum;
|
run_time = in_time + audiorate->src_segment.accum;
|
||||||
|
|
||||||
/* calculate the buffer offset */
|
/* calculate the buffer offset */
|
||||||
in_offset = gst_util_uint64_scale_int (run_time, audiorate->rate, GST_SECOND);
|
in_offset = gst_util_uint64_scale_int_round (run_time, audiorate->rate,
|
||||||
|
GST_SECOND);
|
||||||
in_offset_end = in_offset + in_samples;
|
in_offset_end = in_offset + in_samples;
|
||||||
|
|
||||||
GST_LOG_OBJECT (audiorate,
|
GST_LOG_OBJECT (audiorate,
|
||||||
|
|
Loading…
Reference in a new issue