58inline uint32_t
ones(uint32_t x)
61 x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
62 x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
63 x = (x & 0x0f0f0f0f) + ((x >> 4) & 0x0f0f0f0f);
89 return ones(x>>1) + !isPow2;
112 int result = 127 - ((wi >> 23) & 0xff);
118 if ( x < a )
return 0;
119 if ( x >= b )
return 1;
121 return x*x * (3 - 2*x);
127 if ( x < a )
return 0;
128 if ( x >= b )
return 1;
130 return x*x*x * (10 + x * (-15 + x*6));
134inline T
abs(T x) {
return x > 0 ? x : -x; }
148inline T
min(T a, T b) {
return a < b ? a : b; }
151inline T
max(T a, T b) {
return a > b ? a : b; }
157inline T
halve(T val) {
return T(val>>1); }
159inline float halve(
float val) {
return 0.5f * val; }
165inline float quarter(
float val) {
return 0.25f * val; }
169bool isConstant(
const void* data,
int stride,
int ures,
int vres,
int pixelSize);
172void interleave(
const void* src,
int sstride,
int ures,
int vres,
173 void* dst,
int dstride, DataType dt,
int nchannels);
176void deinterleave(
const void* src,
int sstride,
int ures,
int vres,
177 void* dst,
int dstride, DataType dt,
int nchannels);
185typedef void ReduceFn(
const void* src,
int sstride,
int ures,
int vres,
186 void* dst,
int dstride, DataType dt,
int nchannels);
189void reduce(
const void* src,
int sstride,
int ures,
int vres,
190 void* dst,
int dstride, DataType dt,
int nchannels);
193void reduceu(
const void* src,
int sstride,
int ures,
int vres,
194 void* dst,
int dstride, DataType dt,
int nchannels);
197void reducev(
const void* src,
int sstride,
int ures,
int vres,
198 void* dst,
int dstride, DataType dt,
int nchannels);
201void reduceTri(
const void* src,
int sstride,
int ures,
int vres,
202 void* dst,
int dstride, DataType dt,
int nchannels);
205void average(
const void* src,
int sstride,
int ures,
int vres,
206 void* dst, DataType dt,
int nchannels);
209void fill(
const void* src,
void* dst,
int dstride,
210 int ures,
int vres,
int pixelsize);
213void copy(
const void* src,
int sstride,
void* dst,
int dstride,
214 int nrows,
int rowlen);
217void blend(
const void* src,
float weight,
void* dst,
bool flip,
218 int rowlen, DataType dt,
int nchannels);
221void multalpha(
void* data,
int npixels, DataType dt,
int nchannels,
int alphachan);
224void divalpha(
void* data,
int npixels, DataType dt,
int nchannels,
int alphachan);
229 uint32_t* rfaceids, uint32_t* faceids);
232template<
typename T,
int n>
237 *dst += (float)*val * weight;
239 VecAccum<T,n-1>()(dst+1, val+1, weight);
248 void operator()(
float* dst,
const T* val,
int nchan,
float weight)
250 for (
int i = 0; i < nchan; i++) dst[i] += (
float)val[i] * weight;
255template<
typename T,
int n>
260 *dst = (float)*val * weight;
262 VecMult<T,n-1>()(dst+1, val+1, weight);
271 void operator()(
float* dst,
const T* val,
int nchan,
float weight)
273 for (
int i = 0; i < nchan; i++) dst[i] = (
float)val[i] * weight;
277typedef void (*
ApplyConstFn)(
float weight,
float* dst,
void* data,
int nChan);
283 fn(weight, dst, data, nChan);
287inline float floor(
float f) {
289 _mm_store_ss(&result, _mm_round_ps(_mm_set1_ps(f), (_MM_FROUND_NO_EXC | _MM_FROUND_TO_NEG_INF)));
292inline float ceil(
float f) {
294 _mm_store_ss(&result, _mm_round_ps(_mm_set1_ps(f), (_MM_FROUND_NO_EXC | _MM_FROUND_TO_POS_INF)));
Definitions related to exported Ptex API symbol visibility.
Half-precision floating-point type.
#define PTEX_NAMESPACE_END
Public API classes for reading, writing, caching, and filtering Ptex files.
float reciprocalPow2(int power)
void genRfaceids(const FaceInfo *faces, int nfaces, uint32_t *rfaceids, uint32_t *faceids)
void reduceu(const void *src, int sstride, int uw, int vw, void *dst, int dstride, DataType dt, int nchan)
void applyConst(float weight, float *dst, void *data, Ptex::DataType dt, int nChan)
uint32_t ones(uint32_t x)
bool isConstant(const void *data, int stride, int ures, int vres, int pixelSize)
void divalpha(void *data, int npixels, DataType dt, int nchannels, int alphachan)
void encodeDifference(void *data, int size, DataType dt)
void reduce(const void *src, int sstride, int uw, int vw, void *dst, int dstride, DataType dt, int nchan)
void deinterleave(const void *src, int sstride, int uw, int vw, void *dst, int dstride, DataType dt, int nchan)
void blend(const void *src, float weight, void *dst, bool flip, int rowlen, DataType dt, int nchan)
int calcResFromWidth(float w)
void decodeDifference(void *data, int size, DataType dt)
void reducev(const void *src, int sstride, int uw, int vw, void *dst, int dstride, DataType dt, int nchan)
void fill(const void *src, void *dst, int dstride, int ures, int vres, int pixelsize)
void reduceTri(const void *src, int sstride, int w, int, void *dst, int dstride, DataType dt, int nchan)
void copy(const void *src, int sstride, void *dst, int dstride, int vres, int rowlen)
float smoothstep(float x, float a, float b)
uint32_t floor_log2(uint32_t x)
void ReduceFn(const void *src, int sstride, int ures, int vres, void *dst, int dstride, DataType dt, int nchannels)
void multalpha(void *data, int npixels, DataType dt, int nchannels, int alphachan)
void interleave(const void *src, int sstride, int uw, int vw, void *dst, int dstride, DataType dt, int nchan)
float qsmoothstep(float x, float a, float b)
void(* ApplyConstFn)(float weight, float *dst, void *data, int nChan)
void average(const void *src, int sstride, int uw, int vw, void *dst, DataType dt, int nchan)
ApplyConstFn applyConstFunctions[20]
uint32_t ceil_log2(uint32_t x)
DataType
Type of data stored in texture file.
Half-precision (16-bit) floating-point type.
void operator()(float *dst, const T *val, int nchan, float weight)
void operator()(float *, const T *, float)
void operator()(float *dst, const T *val, float weight)
void operator()(float *dst, const T *val, int nchan, float weight)
void operator()(float *, const T *, float)
void operator()(float *dst, const T *val, float weight)