mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-10 01:54:11 +00:00
audioresample: corrected buffer duration calculation to account for nonzero initial timestamp
Since we calculate timestamps by: timestamp = t0 + (out samples) / (out rate) and durations by: duration = ((out samples) + (processed samples)) / (out rate) - timestamp if t0 is nonzero, this would simplify to duration = t0 + (processed samples) / (out rate). This duration is too large by the amount t0. We should have done: duration = t0 + ((out samples) + (processed samples)) / (out rate) - timestamp so that duration = (processed samples) / (out rate).
This commit is contained in:
parent
25a154be5f
commit
5bfe1baab3
1 changed files with 2 additions and 2 deletions
|
@ -889,7 +889,7 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
|
|||
GST_BUFFER_TIMESTAMP (outbuf) = resample->t0 +
|
||||
gst_util_uint64_scale_int_round (resample->samples_out, GST_SECOND,
|
||||
resample->outrate);
|
||||
GST_BUFFER_DURATION (outbuf) =
|
||||
GST_BUFFER_DURATION (outbuf) = resample->t0 +
|
||||
gst_util_uint64_scale_int_round (resample->samples_out + out_processed,
|
||||
GST_SECOND, resample->outrate) - GST_BUFFER_TIMESTAMP (outbuf);
|
||||
} else {
|
||||
|
@ -1137,7 +1137,7 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
|
|||
GST_BUFFER_TIMESTAMP (outbuf) = resample->t0 +
|
||||
gst_util_uint64_scale_int_round (resample->samples_out, GST_SECOND,
|
||||
resample->outrate);
|
||||
GST_BUFFER_DURATION (outbuf) =
|
||||
GST_BUFFER_DURATION (outbuf) = resample->t0 +
|
||||
gst_util_uint64_scale_int_round (resample->samples_out + out_processed,
|
||||
GST_SECOND, resample->outrate) - GST_BUFFER_TIMESTAMP (outbuf);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue