43 |
|
long rowStride; // # values to next y position |
44 |
|
int dtyp; // data type flags |
45 |
|
RGBPRIMP primp; // color primaries if tristimulus |
46 |
+ |
bool swap2d; // need to swap 16-bit depths? |
47 |
|
const COLORV * CF3(int x, int y) const { |
48 |
|
return pbase.f + (rowStride*y + x)*3; |
49 |
|
} |
68 |
|
COLRV * SCB(int x, int y) { |
69 |
|
return pbase.b + (rowStride*y + x)*(NCSAMP+1); |
70 |
|
} |
71 |
+ |
void EncodeDepth16(int x, int y, float z) { |
72 |
+ |
short * sp = dbase.s + rowStride*y + x; |
73 |
+ |
*sp = depth2code(z, refDepth); |
74 |
+ |
if (swap2d) swap16((char *)sp, 1); |
75 |
+ |
} |
76 |
+ |
float DecodeDepth16(int x, int y) const { |
77 |
+ |
short sv = dbase.s[rowStride*y + x]; |
78 |
+ |
if (swap2d) swap16((char *)&sv, 1); |
79 |
+ |
return code2depth(sv, refDepth); |
80 |
+ |
} |
81 |
|
public: |
82 |
|
double refDepth; // reference depth |
83 |
|
PixelAccess() { |
84 |
|
refDepth = 1.; |
85 |
+ |
swap2d = !nativebigendian(); |
86 |
|
Init(); |
87 |
|
} |
88 |
|
PixelAccess(COLORV *rp, int ystride, float *zp=NULL) { |
89 |
|
refDepth = 1.; |
90 |
+ |
swap2d = !nativebigendian(); |
91 |
|
Init(rp, ystride, zp); |
92 |
|
} |
93 |
|
PixelAccess(COLRV *bp, int ystride, float *zp=NULL) { |
94 |
|
refDepth = 1.; |
95 |
+ |
swap2d = !nativebigendian(); |
96 |
|
Init(bp, ystride, zp); |
97 |
|
} |
98 |
|
PixelAccess(COLRV *bp, int ystride, short *dp) { |
99 |
|
refDepth = 1.; |
100 |
+ |
swap2d = !nativebigendian(); |
101 |
|
Init(bp, ystride, dp); |
102 |
|
} |
103 |
|
PixelAccess(COLORV *rp, int ystride, short *dp) { |
104 |
|
refDepth = 1.; |
105 |
+ |
swap2d = !nativebigendian(); |
106 |
|
Init(rp, ystride, dp); |
107 |
|
} |
108 |
|
void Init() { |
195 |
|
scolor_scolr(SCB(x,y), pv); |
196 |
|
else |
197 |
|
copyscolor(SCF(x,y), pv); |
198 |
< |
if (RDTdepthT(dtyp) == RDTdfloat) |
198 |
> |
if (DepthType() == RDTdfloat) |
199 |
|
dbase.f[rowStride*y + x] = z; |
200 |
< |
else if (RDTdepthT(dtyp) == RDTdshort) |
201 |
< |
dbase.s[rowStride*y + x] = depth2code(z, refDepth); |
200 |
> |
else if (DepthType() == RDTdshort) |
201 |
> |
EncodeDepth16(x, y, z); |
202 |
|
return true; |
203 |
|
} |
204 |
|
/// Retrieve pixel color (& depth) -- may convert either/both |
213 |
|
else |
214 |
|
copyscolor(pv, SCF(x,y)); |
215 |
|
if (!zp) return true; |
216 |
< |
if (RDTdepthT(dtyp) == RDTdfloat) |
216 |
> |
if (DepthType() == RDTdfloat) |
217 |
|
*zp = dbase.f[rowStride*y + x]; |
218 |
< |
else if (RDTdepthT(dtyp) == RDTdshort) |
219 |
< |
*zp = code2depth(dbase.s[rowStride*y + x], refDepth); |
218 |
> |
else if (DepthType() == RDTdshort) |
219 |
> |
*zp = DecodeDepth16(x, y); |
220 |
|
else |
221 |
|
*zp = .0f; |
222 |
|
return true; |
234 |
|
copyscolr(SCB(dx,dy), SCB(sx,sy)); |
235 |
|
else |
236 |
|
copyscolor(SCF(dx,dy), SCF(sx,sy)); |
237 |
< |
switch (RDTdepthT(dtyp)) { |
237 |
> |
switch (DepthType()) { |
238 |
|
case RDTdfloat: |
239 |
|
dbase.f[rowStride*dy + dx] = |
240 |
|
dbase.f[rowStride*sy + sx]; |
413 |
|
RenderDataType ResumeFrame(const char *pfname, |
414 |
|
const char *dfname=NULL); |
415 |
|
/// Prepare new picture (and depth) output |
416 |
< |
/// Called by RenderFrame() |
416 |
> |
/// Called by RenderFrame() after NewFrame() |
417 |
|
RenderDataType NewOutput(FILE *pdfp[2], const char *pfname, |
418 |
|
RenderDataType dt=RDTrgbe, |
419 |
|
const char *dfname=NULL); |