After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 499181 - audiorate inserting samples (due to rounding errors ?)
audiorate inserting samples (due to rounding errors ?)
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: 0.10.26
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-11-23 13:46 UTC by Laurent Glayal
Modified: 2009-10-22 12:36 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Laurent Glayal 2007-11-23 13:46:01 UTC
audiorate is inserting one sample periodically, the following command :

GST_DEBUG="audiorate*:5" gst-launch audiotestsrc ! audiorate ! fakesink 2>&1 | egrep "inserting"

results to :

0:00:00.193252000 25729 0x80d3478 DEBUG            audiorate gstaudiorate.c:561:gst_audio_rate_chain:<audiorate0> inserting 1 samples
0:00:00.261406000 25729 0x80d3478 DEBUG            audiorate gstaudiorate.c:561:gst_audio_rate_chain:<audiorate0> inserting 1 samples
0:00:00.334504000 25729 0x80d3478 DEBUG            audiorate gstaudiorate.c:561:gst_audio_rate_chain:<audiorate0> inserting 1 samples
0:00:00.403873000 25729 0x80d3478 DEBUG            audiorate gstaudiorate.c:561:gst_audio_rate_chain:<audiorate0> inserting 1 samples
0:00:00.474330000 25729 0x80d3478 DEBUG            audiorate gstaudiorate.c:561:gst_audio_rate_chain:<audiorate0> inserting 1 samples
0:00:00.539998000 25729 0x80d3478 DEBUG            audiorate gstaudiorate.c:561:gst_audio_rate_chain:<audiorate0> inserting 1 samples
0:00:00.605779000 25729 0x80d3478 DEBUG            audiorate gstaudiorate.c:561:gst_audio_rate_chain:<audiorate0> inserting 1 samples
0:00:00.674456000 25729 0x80d3478 DEBUG            audiorate gstaudiorate.c:561:gst_audio_rate_chain:<audiorate0> inserting 1 samples
0:00:00.746070000 25729 0x80d3478 DEBUG            audiorate gstaudiorate.c:561:gst_audio_rate_chain:<audiorate0> inserting 1 samples
0:00:00.818519000 25729 0x80d3478 DEBUG            audiorate gstaudiorate.c:561:gst_audio_rate_chain:<audiorate0> inserting 1 samples
0:00:00.888520000 25729 0x80d3478 DEBUG            audiorate gstaudiorate.c:561:gst_audio_rate_chain:<audiorate0> inserting 1 samples


These samples seems to be added due to round errors and does not seems to be necessary if round errors are not accumulated.
Comment 1 Gabriel Bouvigne 2008-02-18 11:21:25 UTC
I think that it's a duplicate of this one:
http://bugzilla.gnome.org/show_bug.cgi?id=363119
Comment 2 Thiago Sousa Santos 2009-10-21 12:11:18 UTC
In this pipeline audioconvert is inserting 1 (2 bytes) sample when it does the following math to calculate the next_offset: 

/* Figure out the total accumulated segment time. */
  run_time = in_time + audiorate->src_segment.accum;

  /* calculate the buffer offset */
  in_offset = gst_util_uint64_scale_int (run_time, audiorate->rate, GST_SECOND);
  in_offset_end = in_offset + in_samples;

In one of the cases I got from the logs I have:

10216780045(runtime) * 44100(rate) / 1000000000.0(GST_SECOND) = 450559.9999845, and of course it uses 450559.

Should we be using gst_util_uint64_scale_round ?
Comment 3 Thiago Sousa Santos 2009-10-21 12:19:49 UTC
Also, I can't reproduce it with alsasink, only with fakesink.

This doesn't show the debug line about the samples:
GST_DEBUG=audiorate:4 gst-launch audiotestsrc ! audiorate ! "audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)1" ! alsasink

Replacing alsasink with fakesink shows it.
Comment 4 Sebastian Dröge (slomo) 2009-10-22 08:33:26 UTC
(In reply to comment #2)
>
> Should we be using gst_util_uint64_scale_round ?

Yes, that would definitely improve the situation.
Comment 5 Thiago Sousa Santos 2009-10-22 12:16:50 UTC
Fixed.

commit 44d6ebc48f929cce52b3f187266ee9bf0327340c
Author: Thiago Santos <thiagoss@embedded.ufcg.edu.br>
Date:   Thu Oct 22 08:40:01 2009 -0300

    audiorate: be more accurate on offset math