68inline uint32_t
ones(uint32_t x)
71 x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
72 x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
73 x = (x & 0x0f0f0f0f) + ((x >> 4) & 0x0f0f0f0f);
99 return ones(x>>1) + !isPow2;
105 int32_t i = (127-power)<<23;
107 memcpy(&f, &i,
sizeof(f));
116 memcpy(&wi, &w,
sizeof(wi));
117 int result = 127 - ((wi >> 23) & 0xff);
123 if ( x < a )
return 0;
124 if ( x >= b )
return 1;
126 return x*x * (3 - 2*x);
132 if ( x < a )
return 0;
133 if ( x >= b )
return 1;
135 return x*x*x * (10 + x * (-15 + x*6));
139inline T
halve(T val) {
return T(val>>1); }
141inline float halve(
float val) {
return 0.5f * val; }
147inline float quarter(
float val) {
return 0.25f * val; }
151bool isConstant(
const void* data,
int stride,
int ures,
int vres,
int pixelSize);
154void interleave(
const void* src,
int sstride,
int ures,
int vres,
155 void* dst,
int dstride, DataType dt,
int nchannels);
158void deinterleave(
const void* src,
int sstride,
int ures,
int vres,
159 void* dst,
int dstride, DataType dt,
int nchannels);
167typedef void ReduceFn(
const void* src,
int sstride,
int ures,
int vres,
168 void* dst,
int dstride, DataType dt,
int nchannels);
171void reduce(
const void* src,
int sstride,
int ures,
int vres,
172 void* dst,
int dstride, DataType dt,
int nchannels);
175void reduceu(
const void* src,
int sstride,
int ures,
int vres,
176 void* dst,
int dstride, DataType dt,
int nchannels);
179void reducev(
const void* src,
int sstride,
int ures,
int vres,
180 void* dst,
int dstride, DataType dt,
int nchannels);
183void reduceTri(
const void* src,
int sstride,
int ures,
int vres,
184 void* dst,
int dstride, DataType dt,
int nchannels);
187void average(
const void* src,
int sstride,
int ures,
int vres,
188 void* dst, DataType dt,
int nchannels);
191void fill(
const void* src,
void* dst,
int dstride,
192 int ures,
int vres,
int pixelsize);
195void copy(
const void* src,
int sstride,
void* dst,
int dstride,
196 int nrows,
int rowlen);
199void blend(
const void* src,
float weight,
void* dst,
bool flip,
200 int rowlen, DataType dt,
int nchannels);
203void multalpha(
void* data,
int npixels, DataType dt,
int nchannels,
int alphachan);
206void divalpha(
void* data,
int npixels, DataType dt,
int nchannels,
int alphachan);
211 uint32_t* rfaceids, uint32_t* faceids);
214template<
typename T,
int n>
219 *dst += (float)*val * weight;
221 VecAccum<T,n-1>()(dst+1, val+1, weight);
230 void operator()(
float* dst,
const T* val,
int nchan,
float weight)
232 for (
int i = 0; i < nchan; i++) dst[i] += (
float)val[i] * weight;
237template<
typename T,
int n>
242 *dst = (float)*val * weight;
244 VecMult<T,n-1>()(dst+1, val+1, weight);
253 void operator()(
float* dst,
const T* val,
int nchan,
float weight)
255 for (
int i = 0; i < nchan; i++) dst[i] = (
float)val[i] * weight;
259typedef void (*
ApplyConstFn)(
float weight,
float* dst,
void* data,
int nChan);
265 fn(weight, dst, data, nChan);
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 decodeDifference(void *data, size_t size, DataType dt)
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 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 encodeDifference(void *data, size_t 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)