OpenImageIO
|
#include <cmath>
#include <limits>
#include <typeinfo>
#include <algorithm>
#include <stdint.h>
#include "version.h"
Go to the source code of this file.
Classes | |
struct | is_same< T, U > |
struct | is_same< T, T > |
struct | DataProxy< I, E > |
struct | ConstDataProxy< I, E > |
struct | DataArrayProxy< I, E > |
struct | ConstDataArrayProxy< I, E > |
Functions | |
template<class T > | |
T | clamp (T a, T l, T h) |
uint32_t | clamped_mult32 (uint32_t a, uint32_t b) |
uint64_t | clamped_mult64 (uint64_t a, uint64_t b) |
template<typename S , typename D , typename F > | |
D | scaled_conversion (const S &src, F scale, F min, F max) |
template<typename S , typename D > | |
void | convert_type (const S *src, D *dst, size_t n, D _zero=0, D _one=1, D _min=std::numeric_limits< D >::min(), D _max=std::numeric_limits< D >::max()) |
template<typename S , typename D > | |
D | convert_type (const S &src) |
template<unsigned int FROM_BITS, unsigned int TO_BITS> | |
unsigned int | bit_range_convert (unsigned int in) |
unsigned int | bit_range_convert (unsigned int in, unsigned int FROM_BITS, unsigned int TO_BITS) |
template<class T , class Q > | |
T | lerp (T v0, T v1, Q x) |
template<class T , class Q > | |
T | bilerp (T v0, T v1, T v2, T v3, Q s, Q t) |
template<class T , class Q > | |
void | bilerp (const T *v0, const T *v1, const T *v2, const T *v3, Q s, Q t, int n, T *result) |
template<class T , class Q > | |
void | bilerp_mad (const T *v0, const T *v1, const T *v2, const T *v3, Q s, Q t, Q scale, int n, T *result) |
template<class T , class Q > | |
T | trilerp (T v0, T v1, T v2, T v3, T v4, T v5, T v6, T v7, Q s, Q t, Q r) |
template<class T , class Q > | |
void | trilerp (const T *v0, const T *v1, const T *v2, const T *v3, const T *v4, const T *v5, const T *v6, const T *v7, Q s, Q t, Q r, int n, T *result) |
template<class T , class Q > | |
void | trilerp_mad (const T *v0, const T *v1, const T *v2, const T *v3, const T *v4, const T *v5, const T *v6, const T *v7, Q s, Q t, Q r, Q scale, int n, T *result) |
int | RoundToInt (double val) |
int | RoundToInt (float val) |
int | FloorToInt (double val) |
int | FloorToInt (float val) |
int | CeilToInt (double val) |
int | CeilToInt (float val) |
int | FloatToInt (double val) |
int | FloatToInt (float val) |
float | floorfrac (float x, int *xint) |
float | radians (float deg) |
float | degrees (float rad) |
float | fast_expf (float x) |
Fast float exp. | |
void | float_to_rational (float f, unsigned int &num, unsigned int &den) |
void | float_to_rational (float f, int &num, int &den) |
void | sincos (float x, float *sine, float *cosine) |
void | sincos (double x, double *sine, double *cosine) |
float | safe_asinf (float x) |
float | safe_acosf (float x) |
double | safe_sqrt (double x) |
float | safe_sqrtf (float x) |
float | safe_inversesqrt (float x) |
Safe (clamping) inverse sqrt. | |
float | safe_log (float x) |
float | safe_log2 (float x) |
float | safe_log10 (float x) |
float | safe_logb (float x) |
template<class T , class Func > | |
T | invert (Func &func, T y, T xmin=0.0, T xmax=1.0, int maxiters=32, T eps=1.0e-6, bool *brack=0) |
Variables | |
OIIO_NAMESPACE_ENTER | |
A variety of floating-point math helper routines (and, slight misnomer, some int stuff as well).
|
inline |
Bilinearly interoplate values v0-v3 (v0 upper left, v1 upper right, v2 lower left, v3 lower right) at coordinates (s,t) and return the result. This is a template, and so should work for any types.
|
inline |
Bilinearly interoplate arrays of values v0-v3 (v0 upper left, v1 upper right, v2 lower left, v3 lower right) at coordinates (s,t), storing the results in 'result'. These are all vectors, so do it for each of 'n' contiguous values (using the same s,t interpolants).
|
inline |
Bilinearly interoplate arrays of values v0-v3 (v0 upper left, v1 upper right, v2 lower left, v3 lower right) at coordinates (s,t), SCALING the interpolated value by 'scale' and then ADDING to 'result'. These are all vectors, so do it for each of 'n' contiguous values (using the same s,t interpolants).
|
inline |
Helper function to convert channel values between different bit depths. Roughly equivalent to:
out = round (in * (pow (2, TO_BITS) - 1) / (pow (2, FROM_BITS) - 1));
but utilizes an integer math trick for speed. It can be proven that the absolute error of this method is less or equal to 1, with an average error (with respect to the entire domain) below 0.2.
It is assumed that the original value is a valid FROM_BITS integer, i.e. shifted fully to the right.
|
inline |
Fast (int)ceil(val) See Michael Herf's "Know Your FPU" page: http://www.stereopsis.com/sree/fpu2006.html
|
inline |
clamp a to bounds [l,h].
|
inline |
Multiply two unsigned 32-bit ints safely, carefully checking for overflow, and clamping to uint32_t's maximum value.
|
inline |
Multiply two unsigned 64-bit ints safely, carefully checking for overflow, and clamping to uint64_t's maximum value.
void convert_type | ( | const S * | src, |
D * | dst, | ||
size_t | n, | ||
D | _zero = 0 , |
||
D | _one = 1 , |
||
D | _min = std::numeric_limits<D>::min() , |
||
D | _max = std::numeric_limits<D>::max() |
||
) |
Convert n consecutive values from the type of S to the type of D. The conversion is not a simple cast, but correctly remaps the 0.0->1.0 range from and to the full positive range of integral types. Take a memcpy shortcut if both types are the same and no conversion is necessary. Optional arguments can give nonstandard quantizations.
D convert_type | ( | const S & | src | ) |
Convert a single value from the type of S to the type of D. The conversion is not a simple cast, but correctly remaps the 0.0->1.0 range from and to the full positive range of integral types. Take a copy shortcut if both types are the same and no conversion is necessary.
|
inline |
Convert radians to degrees
|
inline |
Fast float exp.
|
inline |
Simple conversion of a (presumably non-negative) float into a rational. This does not attempt to find the simplest fraction that approximates the float, for example 52.83 will simply return 5283/100. This does not attempt to gracefully handle floats that are out of range that could be easily int/int.
|
inline |
Simple conversion of a float into a rational. This does not attempt to find the simplest fraction that approximates the float, for example 52.83 will simply return 5283/100. This does not attempt to gracefully handle floats that are out of range that could be easily int/int.
|
inline |
Fast (int)val See Michael Herf's "Know Your FPU" page: http://www.stereopsis.com/sree/fpu2006.html
|
inline |
Return (x-floor(x)) and put (int)floor(x) in *xint. This is similar to the built-in modf, but returns a true int, always rounds down (compared to modf which rounds toward 0), and always returns frac >= 0 (comapred to modf which can return <0 if x<0).
|
inline |
Fast (int)floor(val) See Michael Herf's "Know Your FPU" page: http://www.stereopsis.com/sree/fpu2006.html
T invert | ( | Func & | func, |
T | y, | ||
T | xmin = 0.0 , |
||
T | xmax = 1.0 , |
||
int | maxiters = 32 , |
||
T | eps = 1.0e-6 , |
||
bool * | brack = 0 |
||
) |
Solve for the x for which func(x) == y on the interval [xmin,xmax]. Use a maximum of maxiter iterations, and stop any time the remaining search interval or the function evaluations <= eps. If brack is non-NULL, set it to true if y is in [f(xmin), f(xmax)], otherwise false (in which case the caller should know that the results may be unreliable. Results are undefined if the function is not monotonic on that interval or if there are multiple roots in the interval (it may not converge, or may converge to any of the roots without telling you that there are more than one).
|
inline |
Linearly interpolate values v0-v1 at x: v0*(1-x) + v1*x. This is a template, and so should work for any types.
|
inline |
Convert degrees to radians.
|
inline |
Fast rounding to nearest integer. See Michael Herf's "Know Your FPU" page: http://www.stereopsis.com/sree/fpu2006.html
|
inline |
Safe (clamping) arccosine.
|
inline |
Safe (clamping) arcsine.
|
inline |
Safe (clamping) inverse sqrt.
|
inline |
Safe (clamping) sqrt.
D scaled_conversion | ( | const S & | src, |
F | scale, | ||
F | min, | ||
F | max | ||
) |
Multiply src by scale, clamp to [min,max], and round to the nearest D (presumed to be integer). This is just a helper for the convert_type templates, it probably has no other use.
|
inline |
Trilinearly interoplate arrays of values v0-v7 (v0 upper left top, v1 upper right top, ...) at coordinates (s,t,r), and return the result. This is a template, and so should work for any types.
|
inline |
Trilinearly interoplate arrays of values v0-v7 (v0 upper left top, v1 upper right top, ...) at coordinates (s,t,r), storing the results in 'result'. These are all vectors, so do it for each of 'n' contiguous values (using the same s,t,r interpolants).
|
inline |
Trilinearly interoplate arrays of values v0-v7 (v0 upper left top, v1 upper right top, ...) at coordinates (s,t,r), SCALING the interpolated value by 'scale' and then ADDING to 'result'. These are all vectors, so do it for each of 'n' contiguous values (using the same s,t,r interpolants).