--- ray/src/common/depthcodec.c 2020/01/10 01:02:14 2.6 +++ ray/src/common/depthcodec.c 2020/01/25 05:35:34 2.8 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: depthcodec.c,v 2.6 2020/01/10 01:02:14 greg Exp $"; +static const char RCSid[] = "$Id: depthcodec.c,v 2.8 2020/01/25 05:35:34 greg Exp $"; #endif /* * Routines to encode/decoded 16-bit depths @@ -26,7 +26,7 @@ depth2code(double d, double dref) if (d > dref) return (int)(32768.001 - 32768.*dref/d) - 1; - return (int)(32767.*d/dref - 32768.); + return (int)(32767.*d/dref - 32768.999); } #endif @@ -42,10 +42,10 @@ code2depth(int c, double dref) if (c >= 32767) return FHUGE; - if (c >= 0) + if (c >= -1) return dref*32768./(32766.5 - c); - return dref*(32767.5 + c)*(1./32767.); + return dref*(32768.5 + c)*(1./32767.); } #endif