fix int24 to float conversion : the formula was correct, but the sign bit of int32 doesn't help, and my ears confirmed.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22900 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2007-11-11 15:50:11 +00:00
parent 98f16eeec8
commit aa42ed6ec6

View File

@ -76,17 +76,13 @@ public:
inline operator int8() const { return (int8)data[2]; }
inline operator int16() const { return (int16)((uint32)data[2] << 8 | (uint32)data[1]); }
inline operator int32() const { return (int32)((uint32)data[2] << 24 | (uint32)data[1] << 16 | (uint32)data[0] << 8); }
inline operator float() const { return (int32)((uint32)data[2] << 16 | (uint32)data[1] << 8 | (uint32)data[0]) * (1.0f / (2147483647.0f / 256)); }
// XXX is the line above correct? long version:
// inline operator float() const { return (int32)((uint32)data[2] << 24 | (uint32)data[1] << 16 | (uint32)data[0] << 8) * (1.0f / 2147483647.0f); }
inline operator float() const { return (int32)((uint32)data[2] << 24 | (uint32)data[1] << 16 | (uint32)data[0] << 8) * (1.0f / 2147483647.0f); }
#else
inline operator uint8() const { return (int32)data[0] + 128; }
inline operator int8() const { return (int8)data[0]; }
inline operator int16() const { return (int16)((uint32)data[0] << 8 | (uint32)data[1]); }
inline operator int32() const { return (int32)((uint32)data[0] << 24 | (uint32)data[1] << 16 | (uint32)data[2] << 8); }
inline operator float() const { return (int32)((uint32)data[0] << 16 | (uint32)data[1] << 8 | (uint32)data[2]) * (1.0f / (2147483647.0f / 256)); }
// XXX is the line above correct? long version:
// inline operator float() const { return (int32)((uint32)data[0] << 24 | (uint32)data[1] << 16 | (uint32)data[2] << 8) * (1.0f / 2147483647.0f); }
inline operator float() const { return (int32)((uint32)data[0] << 24 | (uint32)data[1] << 16 | (uint32)data[2] << 8) * (1.0f / 2147483647.0f); }
#endif
private:
uint8 data[3];