MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / sseLog2

Function sseLog2

src/OpenColorIO/SSE.h:184–228  ·  view source on GitHub ↗

log2 function in SSE version 2 The function log2() is evaluated by performing argument reduction and then using Chebyshev polynomials to evaluate the function over a restricted range.

Source from the content-addressed store, hash-verified

182// reduction and then using Chebyshev polynomials to evaluate the function
183// over a restricted range.
184inline __m128 sseLog2(__m128 x)
185{
186 // y = log2( x ) = log2( 2^exponent * mantissa )
187 // = exponent + log2( mantissa )
188
189 __m128 mantissa
190 = _mm_or_ps( // OR with EONE
191 _mm_andnot_ps( // NOT(EMASK) AND x
192 _mm_castsi128_ps(EMASK), x), // reinterpret cast int to float
193 EONE);
194
195 __m128 log2
196 = _mm_add_ps(
197 _mm_mul_ps(
198 _mm_add_ps(
199 _mm_mul_ps(
200 _mm_add_ps(
201 _mm_mul_ps(
202 _mm_add_ps(
203 _mm_mul_ps(
204 _mm_add_ps(
205 _mm_mul_ps(PNLOG5, mantissa),
206 PNLOG4),
207 mantissa),
208 PNLOG3),
209 mantissa),
210 PNLOG2),
211 mantissa),
212 PNLOG1),
213 mantissa),
214 PNLOG0);
215
216 __m128i exponent
217 = _mm_sub_epi32( // subtract EBIAS
218 _mm_srli_epi32( // right-shift by EXP_SHIFT
219 _mm_and_si128(_mm_castps_si128(x), // bit-wise AND with EMASK
220 EMASK),
221 EXP_SHIFT),
222 EBIAS);
223
224 log2 = _mm_add_ps(log2,
225 _mm_cvtepi32_ps(exponent)); // convert exponent to float
226
227 return log2;
228}
229
230// exp2 function in SSE version 2
231//

Callers 5

ssePowerFunction · 0.85
applyMethod · 0.85
LinLogFunction · 0.85
LinLogFunction · 0.85
OCIO_ADD_TESTFunction · 0.85

Calls

no outgoing calls

Tested by 1

OCIO_ADD_TESTFunction · 0.68