27template<
int Precision,
int BitsPerPixel,
int ScaleBits = 0>
45template<
int Precision>
47 uint8_t
depth[2][Precision / 8];
54template<
int Precision,
int BitsPerPixel,
int ScaleBits = 0>
56 uint8_t
depth[2][Precision / 8];
63template<
class DepthQuantize>
70 for (
unsigned i = 3; i > 0; --i) {
71 if (i <=
sizeof(q.
depth[idx]))
72 q.
depth[idx][i - 1] = value & 0xff;
78template<
class DepthQuantize>
86template<
class DepthQuantize>
93 for (
unsigned i = 0; i <
sizeof(q.
bits); ++i) {
99template<
class DepthQuantize>
106 q.
bits[bit >> 3] |= (value & 1) << (bit & 7);
110template<
class DepthQuantize>
117 q.
bits[bit >> 3] &= ~(1 << (bit & 7));
121template<
class DepthQuantize>
128 return (q.
bits[bit >> 3] >> (bit & 7)) & 1;
132template<
class DepthQuantize>
140 for (
int i=bit; i<bit+nbits; ++i) {
145 const uint32_t mask = (1 << block) - 1;
146 for (
int i = bit + nbits - 1; i >= bit; i -= block) {
147 q.
bits[i >> 3] |= (value & mask) << (i & 7);
154template<
class DepthQuantize>
163 q.
bits[i] = bits & 0xff;
169template<
class DepthQuantize>
177 for (
int i = bit + nbits - 1; i >= bit; --i) {
185template<
class DepthQuantize>
200template<DepthFormat format,
int bpp>
205 get_depth(
const unsigned char *img,
int x,
int y,
int w,
int h);
214 const float df = ((
float *)img)[y * w + x];
215 uint32_t di = df * 0x00ffffffU;
216 if (di > 0x00ffffffU)
228 const unsigned char *dp = &img[(y * w + x) * 4];
229 return ((dp[2] * 256 + dp[1]) * 256 + dp[0]);
239 const unsigned char *dp = &img[(y * w + x) * 1];
240 return *dp * 0x0010101U;
250 const unsigned char *dp = &img[(y * w + x) * 2];
251 return (dp[1] * 256 + dp[0]) * 256 + dp[1];
261 const unsigned char *dp = &img[(y * w + x) * 3];
262 return ((dp[3] * 256 + dp[2]) * 256 + dp[1]);
272 const unsigned char *dp = &img[(y * w + x) * 4];
273 return ((dp[3] * 256 + dp[2]) * 256 + dp[1]);
278 int height,
int stride = -1);
280 int width,
int height,
int stride = -1);
287 int width,
int height,
int stride = -1);
289 int width,
int height,
int stride = -1);
#define V_RHREXPORT
Definition: export.h:9
DepthQuantize< 16, 4, 0 > DepthQuantize16
Definition: depthquant.h:59
uint32_t get_depth< DepthFloat, 4 >(const unsigned char *img, int x, int y, int w, int h)
Definition: depthquant.h:212
DepthQuantizeBits< 16, 4, 0 > DepthQuantizeBits16
Definition: depthquant.h:41
uint32_t get_depth(const unsigned char *img, int x, int y, int w, int h)
unsigned dq_getbits(const DepthQuantize &q, int bit, int nbits)
get multiple bits from DepthQuantize struct
Definition: depthquant.h:174
void depthdequant_planar(char *zbuf, const char *quantbuf, DepthFormat format, int depthps, int dx, int dy, int width, int height, int stride)
Definition: depthquant.cpp:322
uint32_t get_depth< DepthInteger, 1 >(const unsigned char *img, int x, int y, int w, int h)
Definition: depthquant.h:237
DepthQuantizeBits< 24, 3, 4 > DepthQuantizeBits24
Definition: depthquant.h:42
uint32_t get_depth< DepthInteger, 3 >(const unsigned char *img, int x, int y, int w, int h)
Definition: depthquant.h:259
void depthquant_planar(char *quantbufS, const char *zbufS, DepthFormat format, int depthps, int x, int y, int width, int height, int stride)
Definition: depthquant.cpp:728
void depthquant(char *quantbufS, const char *zbufS, DepthFormat format, int depthps, int x, int y, int width, int height, int stride)
transform depth buffer into quantized values on 4x4 pixel tiles
Definition: depthquant.cpp:660
void setdepth(DepthQuantize &q, int idx, uint32_t value)
set depth bits for a single pixel
Definition: depthquant.h:68
DepthQuantizeMinMaxDepth< 24 > MinMaxDepth24
Definition: depthquant.h:51
DepthQuantizeMinMaxDepth< 16 > MinMaxDepth16
Definition: depthquant.h:50
void dq_clearbits(DepthQuantize &q)
zero depth bits for a 4x4 tile
Definition: depthquant.h:91
uint32_t get_depth< DepthRGBA, 4 >(const unsigned char *img, int x, int y, int w, int h)
Definition: depthquant.h:226
unsigned dq_getbit(const DepthQuantize &q, int bit)
retrieve a single bit from DepthQuantize struct
Definition: depthquant.h:126
uint8_t depth[2][Precision/8]
minimum and maximum depth data
Definition: depthquant.h:47
void depthdequant(char *zbuf, const char *quantbuf, DepthFormat format, int depthps, int dx, int dy, int width, int height, int stride)
reverse transformation done by depthquant
Definition: depthquant.cpp:281
DepthFormat
Definition: depthquant.h:20
@ DepthRGBA
Definition: depthquant.h:23
@ DepthFloat
Definition: depthquant.h:22
@ DepthInteger
Definition: depthquant.h:21
uint32_t get_depth< DepthInteger, 4 >(const unsigned char *img, int x, int y, int w, int h)
Definition: depthquant.h:270
size_t depthquant_size(DepthFormat format, int depthps, int width, int height)
return size required by depthquant for quantized image
Definition: depthquant.cpp:64
uint32_t getdepth(const DepthQuantize &q, int idx)
retrieve depth bits for a single pixel
DepthQuantize< 24, 3, 4 > DepthQuantize24
Definition: depthquant.h:60
void dq_clearbit(DepthQuantize &q, int bit)
clear a single bit in DepthQuantize struct
Definition: depthquant.h:115
void dq_setbit(DepthQuantize &q, int bit, unsigned value=1)
set a single bit in DepthQuantize struct
Definition: depthquant.h:104
void dq_setbits(DepthQuantize &q, int bit, int nbits, unsigned value, int block=1)
set multiple bits in DepthQuantize struct
Definition: depthquant.h:137
uint32_t get_depth< DepthInteger, 2 >(const unsigned char *img, int x, int y, int w, int h)
Definition: depthquant.h:248
min/max depth for a single 4x4 pixel tile (when storing depths and interpolation bits separately)
Definition: depthquant.h:46
quantized depth data for a single 4x4 pixel tile
Definition: depthquant.h:28
uint8_t bits[num_bytes]
per-pixel interpolation weights
Definition: depthquant.h:38
@ num_bytes
Definition: depthquant.h:35
@ edge
Definition: depthquant.h:32
@ precision
Definition: depthquant.h:30
@ scale_bits
Definition: depthquant.h:33
@ bits_per_pixel
Definition: depthquant.h:34
quantized depth data for a single 4x4 pixel tile
Definition: depthquant.h:55
uint8_t depth[2][Precision/8]
minimum and maximum depth data
Definition: depthquant.h:56