openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Openexr-devel] Re: Conversion between half-float and float


From: Derek Ledbetter
Subject: [Openexr-devel] Re: Conversion between half-float and float
Date: Thu, 1 Jul 2004 02:15:12 -0700

On Jun 25, 2004, at 10:17 PM, Kennant Tom wrote:

I have read through that piece of code before. I have thought about
implementing the conversion using the SIMD2 intrinsics. It seems that
the conversion involves more than a few logical shift operations and
the while-loop for denormalizing normalized values is difficult to
implement neatly with SIMD2 intrinsics. Do you know the actual logic
behind the implementation using the AltiVec functions.

Here's the part of the code that converts a denormalized half to a float:
    vector float tiny_result
        = vec_ctf(
            vec_and(
                half_vector,
                half_m_mask),
            14+10);

First it masks out the sign and exponent. (The exponent is already zero, but the sign may not be. The sign is copied to the result at the very end of the function.) Then it treats the mantissa as an integer, multiplies it by 2^(-24), and stores the result as floating-point. This is pretty fast on AltiVec, because it uses the same registers for both integers and floats. This algorithm might be slower with scalar PowerPC instructions, because on the PowerPC, the only way to move a value between an integer register and a floating-point register is to write it to memory and read it again.

--
Derek Ledbetter
address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]