nagaraja.sreerama@wipro.com
2004-Dec-16 20:30 UTC
[Vorbis-dev] Qyery on bark equation in floor0 code
Hi All, I need some clarifications regarding the mismatch I found in the code and the specification. (a) In the specification, the bark(x) equation is given as: bark(x) = 13.1 atan(.00074x) + 2.24 atan(.0000000158(x^2)) + .0001x whereas in the code it is given as: #define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) Which one of these is the proper one ? (b) Also, we are planning to implement a fixed point code for the Vorbis decoder. And as usual the obvious criteria is the compliance and how accurately this fixed point code should generate the output that matches mathematically the floating code implementation. Specifically I feel that the tremor code implements the linear approximation depending on some specific baud scales (0, 100, 200, 301, 405, 516 etc...). I have a feeling that this leads to some inaccuracy in the results compared to the floating point code. Is this acceptable ? What is the basis for acceptance say the algorithm should mathematically match the specification ? Can somebody throw light on this ? Best regards, nags.. Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately and destroy all copies of this message and any attachments. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/vorbis-dev/attachments/20041217/d8dcac94/attachment.html
On Fri, Dec 17, 2004 at 09:55:39AM +0530, nagaraja.sreerama@wipro.com wrote:> I need some clarifications regarding the mismatch I found in the code > and the specification. > > (a) In the specification, the bark(x) equation is given as: > > bark(x) = 13.1 atan(.00074x) + 2.24 atan(.0000000158(x^2)) + .0001x > > whereas in the code it is given as: > > #define toBARK(n) > (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) > > Which one of these is the proper one ?Can you be more specific about what the mismatch is. Are these not identical to within floating point precision?> (b) Also, we are planning to implement a fixed point code for the Vorbis > decoder. And as usual the obvious criteria is the compliance and how > accurately this fixed point code should generate the output that matches > mathematically the floating code implementation. Specifically I feel > that the tremor code implements the linear approximation depending on > some specific baud scales (0, 100, 200, 301, 405, 516 etc...). I have a > feeling that this leads to some inaccuracy in the results compared to > the floating point code. Is this acceptable ? What is the basis for > acceptance say the algorithm should mathematically match the > specification ?Monty is the best one to comment on this. I believe Tremor is considered a compliant encoder, but it's possible it's only accurate for 16 bit output. What monty has remarked on in the past is that a major issue with fixed point implementations is maintaining enough headroom in applying the residue to the floor curve, at this requires more than 24 bits of dynamic range. -r
On Fri, Dec 17, 2004 at 09:55:39AM +0530, nagaraja.sreerama@wipro.com wrote:> (a) In the specification, the bark(x) equation is given as: > > bark(x) = 13.1 atan(.00074x) + 2.24 atan(.0000000158(x^2)) + .0001x > > whereas in the code it is given as: > > #define toBARK(n) > (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))Ah, it is pointed out to me that the second atan arg is 1.58 or 1.85. Sorry. I don't know, though I imagine following the code would be safer. Monty, do you have a preference? -r
On Friday 17 December 2004 15:25, nagaraja.sreerama@wipro.com wrote:> Hi All, > I need some clarifications regarding the mismatch I found in the code > and the specification. > > (a) In the specification, the bark(x) equation is given as: > > bark(x) = 13.1 atan(.00074x) + 2.24 atan(.0000000158(x^2)) + .0001x > > whereas in the code it is given as: > > #define toBARK(n) > (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) > > Which one of these is the proper one ?The one from the code is what is in wide use - it also matches more closely with the commonly quoted references for this scale. I'm pretty sure this is a typo in the spec - I'll wait to see if Monty replies before changing it, though. Thanks for picking up on it! Mike