Re: [ecasound] lossless conversion broken?

From: Sergei Steshenko <sergstesh@email-addr-hidden>
Date: Wed Nov 03 2010 - 08:40:08 EET

--- On Tue, 11/2/10, Dan Muresan <danmbox@email-addr-hidden> wrote:

> From: Dan Muresan <danmbox@email-addr-hidden>
> Subject: Re: [ecasound] lossless conversion broken?
> To: "Kai Vehmanen" <kvehmanen@email-addr-hidden>
> Cc: ecasound-list@email-addr-hidden
> Date: Tuesday, November 2, 2010, 4:03 PM
> 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?
>
[snip]

Looks like a bug in 'ecasound' to me. And your findings confirm my simple
test program results, i.e. trivial short int -> float -> short int
conversion with no explicit rounding keeps it bit-accurate at least for
0 .. 31 range.

Regards,
  Sergei.

      

------------------------------------------------------------------------------
Achieve Improved Network Security with IP and DNS Reputation.
Defend against bad network traffic, including botnets, malware,
phishing sites, and compromised hosts - saving your company time,
money, and embarrassment. Learn More!
http://p.sf.net/sfu/hpdev2dev-nov
_______________________________________________
Ecasound-list mailing list
Ecasound-list@email-addr-hidden
https://lists.sourceforge.net/lists/listinfo/ecasound-list
Received on Wed Nov 3 12:15:01 2010

This archive was generated by hypermail 2.1.8 : Wed Nov 03 2010 - 12:15:02 EET