3 Nov 2010 00:03
Re: lossless conversion broken?
Dan Muresan <danmbox <at> gmail.com>
2010-11-02 23:03:17 GMT
2010-11-02 23:03:17 GMT
Hi, > libecasound/eca-sample-conversion.h: > http://ecasound.git.sourceforge.net/git/gitweb.cgi?p=ecasound/ecasound;a=blob;f=libecasound/eca-sample-conversion.h;h=f11aced93bd9ff2616c5500205d661cc8c554201;hb=HEAD#l96 I looked at the code. I'm surprised at a different asymmetry -- the one between eca_sample_convert_float_to_s32 vs. eca_sample_convert_s32_to_float: int32_t eca_sample_convert_float_to_s32(float inval) { if (inval < 0.0f) return((int32_t)((float)(inval * (INT32_MAX)))); return((int32_t)((float)(inval * INT32_MAX) - 0.5f)); } float eca_sample_convert_s32_to_float(int32_t inval) { return(((float)inval) / INT32_MAX); } The conversion functions should be (at least mathematically) inverse functions, i.e. f (g (x)) = x. If you don't distinguish between positive and negative int's, why do you do so for +/- floats? > This is unit-tested in libecasound/eca-sample-conversion_test.h: > http://ecasound.git.sourceforge.net/git/gitweb.cgi?p=ecasound/ecasound;a=blob;f=libecasound/eca-sample-conversion_test.h;h=fa0c52247290c4886dc98889afde9eaac0f8e70d;hb=HEAD Yes, but that unit test only looks at 0.0f, ((float) INT_MAX) and ((float) INT_MIN). Zero is not distorted, but 1,2,3 etc are:(Continue reading)
RSS Feed