[Vorbis-dev] BARK implementation (or specification) error
Chris Moore
moore at free.fr
Thu Mar 20 10:56:07 PDT 2014
Hi,
In the course of some work which I describe below, I have found a very significant difference between the BARK function described in the Vorbis specification and its implementation in libvorbis.
In the specificationhttp://xiph.org/vorbis/doc/Vorbis_I_spec.pdf
bark(x) = 13.1arctan(.00074x) + 2.24arctan(.0000000185x**2 + .0001x)
In the libvorbis code http://svn.xiph.org/trunk/vorbis/lib/scales.h
#define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
You will note that the last term is inside the parentheses of the second arctan function in the specification but outside in the libvorbis implementation.
This results in extremely large differences at high frequencies.
Which is correct: the specification or the implementation?
What should I consider to be the reference Vorbis decoder?
Currently I am supposing it to be the vorbisfile_example code in Vorbis but I am rather surprised that while the heavy transcendental functions are in double, many other calculations are only in float.
I would have expected a reference decoder to use the greater precision of double throughout.
Otherwise, for information, I have been looking into the differences between the output of Tremor and the output of the Vorbis floating point decoder reported in the following post:
http://www.mail-archive.com/tremor@xiph.org/msg00072.html
Where floor1 is used the RMS differences are already small: about 0.7
However with a couple of trivial modifications I have been able to reduce the RMS differences to about 0.1
The big problem is that where floor0 is used the RMS differences are *enormous*.
I have investigated these and they are:
a) partly due to an insufficient number of fractional bits in certain places,
b) partly due to insufficient precision in the approximation of transcendental functions (cos, atan, exp, sqrt).
I have been able to significantly improve the results but I hope to do better.
The main difficulties are in the approximation of these transcendental functions.
How should I submit my modifications?
They are basically of three types:
a) trivial improvements having no impact on the results (e.g. constifying, more efficient calculations, saving table space).
b) trivial modifications improving the accuracy of floor1 and the MDCT,
c) substantial modifications to floor0 (these are currently unfinished).
TIA.
Cheers,
Chris
More information about the Vorbis-dev
mailing list