48 static uint32_t
ones(uint32_t x)
51 x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
52 x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
53 x = (x & 0x0f0f0f0f) + ((x >> 4) & 0x0f0f0f0f);
79 return ones(x>>1) + !isPow2;
91 int result = 127 - ((wi >> 23) & 0xff);
97 if ( x < a )
return 0;
98 if ( x >= b )
return 1;
100 return x*x * (3 - 2*x);
106 if ( x < a )
return 0;
107 if ( x >= b )
return 1;
109 return x*x*x * (10 + x * (-15 + x*6));
113 static T
cond(
bool c, T a, T b) {
return (T)((T)c * a + (T)!c * b); }
116 static T
min(T a, T b) {
return cond(a < b, a, b); }
119 static T
max(T a, T b) {
return cond(a >= b, a, b); }
122 static T
clamp(T x, T lo, T hi) {
return cond(x < lo, lo,
cond(x > hi, hi, x)); }
124 static bool isConstant(
const void* data,
int stride,
int ures,
int vres,
126 static void interleave(
const void* src,
int sstride,
int ures,
int vres,
127 void* dst,
int dstride,
DataType dt,
int nchannels);
128 static void deinterleave(
const void* src,
int sstride,
int ures,
int vres,
129 void* dst,
int dstride,
DataType dt,
int nchannels);
132 typedef void ReduceFn(
const void* src,
int sstride,
int ures,
int vres,
133 void* dst,
int dstride,
DataType dt,
int nchannels);
134 static void reduce(
const void* src,
int sstride,
int ures,
int vres,
135 void* dst,
int dstride,
DataType dt,
int nchannels);
136 static void reduceu(
const void* src,
int sstride,
int ures,
int vres,
137 void* dst,
int dstride,
DataType dt,
int nchannels);
138 static void reducev(
const void* src,
int sstride,
int ures,
int vres,
139 void* dst,
int dstride,
DataType dt,
int nchannels);
140 static void reduceTri(
const void* src,
int sstride,
int ures,
int vres,
141 void* dst,
int dstride,
DataType dt,
int nchannels);
142 static void average(
const void* src,
int sstride,
int ures,
int vres,
143 void* dst,
DataType dt,
int nchannels);
144 static void fill(
const void* src,
void* dst,
int dstride,
145 int ures,
int vres,
int pixelsize);
146 static void copy(
const void* src,
int sstride,
void* dst,
int dstride,
147 int nrows,
int rowlen);
148 static void blend(
const void* src,
float weight,
void* dst,
bool flip,
149 int rowlen,
DataType dt,
int nchannels);
150 static void multalpha(
void* data,
int npixels,
DataType dt,
int nchannels,
int alphachan);
151 static void divalpha(
void* data,
int npixels,
DataType dt,
int nchannels,
int alphachan);
154 uint32_t* rfaceids, uint32_t* faceids);
157 template<
typename T,
int n>
162 *dst += (float)*val * weight;
164 VecAccum<T,n-1>()(dst+1, val+1, weight);
173 void operator()(
float* dst,
const T* val,
int nchan,
float weight)
175 for (
int i = 0; i < nchan; i++) dst[i] += (
float)val[i] * weight;
180 template<
typename T,
int n>
185 *dst = (float)*val * weight;
187 VecMult<T,n-1>()(dst+1, val+1, weight);
196 void operator()(
float* dst,
const T* val,
int nchan,
float weight)
198 for (
int i = 0; i < nchan; i++) dst[i] = (
float)val[i] * weight;
202 typedef void (*
ApplyConstFn)(
float weight,
float* dst,
void* data,
int nChan);
207 ApplyConstFn fn = applyConstFunctions[((unsigned)nChan<=4)*nChan*4 + dt];
208 fn(weight, dst, data, nChan);
void operator()(float *dst, const T *val, float weight)
static void multalpha(void *data, int npixels, DataType dt, int nchannels, int alphachan)
Common data structures and enums used throughout the API.
static uint32_t ceil_log2(uint32_t x)
static bool isPowerOfTwo(int x)
static void reduceTri(const void *src, int sstride, int ures, int vres, void *dst, int dstride, DataType dt, int nchannels)
DataType
Type of data stored in texture file.
static void blend(const void *src, float weight, void *dst, bool flip, int rowlen, DataType dt, int nchannels)
void(* ApplyConstFn)(float weight, float *dst, void *data, int nChan)
static void average(const void *src, int sstride, int ures, int vres, void *dst, DataType dt, int nchannels)
void operator()(float *dst, const T *val, int nchan, float weight)
static void copy(const void *src, int sstride, void *dst, int dstride, int nrows, int rowlen)
void operator()(float *dst, const T *val, int nchan, float weight)
void operator()(float *dst, const T *val, float weight)
static ApplyConstFn applyConstFunctions[20]
void operator()(float *, const T *, float)
static T clamp(T x, T lo, T hi)
static void genRfaceids(const FaceInfo *faces, int nfaces, uint32_t *rfaceids, uint32_t *faceids)
DataType
Type of data stored in texture file.
static int calcResFromWidth(float w)
void ReduceFn(const void *src, int sstride, int ures, int vres, void *dst, int dstride, DataType dt, int nchannels)
static void fill(const void *src, void *dst, int dstride, int ures, int vres, int pixelsize)
static uint32_t floor_log2(uint32_t x)
static float smoothstep(float x, float a, float b)
void operator()(float *, const T *, float)
static void encodeDifference(void *data, int size, DataType dt)
static void divalpha(void *data, int npixels, DataType dt, int nchannels, int alphachan)
static void deinterleave(const void *src, int sstride, int ures, int vres, void *dst, int dstride, DataType dt, int nchannels)
static void reduceu(const void *src, int sstride, int ures, int vres, void *dst, int dstride, DataType dt, int nchannels)
static void interleave(const void *src, int sstride, int ures, int vres, void *dst, int dstride, DataType dt, int nchannels)
static uint32_t ones(uint32_t x)
static void reducev(const void *src, int sstride, int ures, int vres, void *dst, int dstride, DataType dt, int nchannels)
Information about a face, as stored in the Ptex file header.
static void decodeDifference(void *data, int size, DataType dt)
static void reduce(const void *src, int sstride, int ures, int vres, void *dst, int dstride, DataType dt, int nchannels)
static bool isConstant(const void *data, int stride, int ures, int vres, int pixelSize)
Public API classes for reading, writing, caching, and filtering Ptex files.
static T cond(bool c, T a, T b)
static void applyConst(float weight, float *dst, void *data, Ptex::DataType dt, int nChan)
static float qsmoothstep(float x, float a, float b)