Commit f47efe4c authored by David Flynn's avatar David Flynn
Browse files

geom: convert octree internal positions to int32_t

For consistency with the upcoming change to the pointcloud position
data type, this commit changes the geometry coding to internally
use int32_t rather than uint32_t.
parent 9f898950
......@@ -43,12 +43,12 @@ namespace pcc {
void
updateGeometryOccupancyAtlas(
const Vec3<uint32_t>& currentPosition,
const Vec3<int32_t>& currentPosition,
const int atlasShift,
const pcc::ringbuf<PCCOctree3Node>& fifo,
const pcc::ringbuf<PCCOctree3Node>::iterator& fifoCurrLvlEnd,
MortonMap3D* occupancyAtlas,
Vec3<uint32_t>* atlasOrigin)
Vec3<int32_t>* atlasOrigin)
{
const uint32_t mask = (1 << occupancyAtlas->cubeSizeLog2()) - 1;
const int shift = occupancyAtlas->cubeSizeLog2();
......@@ -81,7 +81,7 @@ updateGeometryOccupancyAtlas(
void
updateGeometryOccupancyAtlasOccChild(
const Vec3<uint32_t>& pos,
const Vec3<int32_t>& pos,
uint8_t childOccupancy,
MortonMap3D* occupancyAtlas)
{
......@@ -141,7 +141,7 @@ updatePatternFromNeighOccupancy(
GeometryNeighPattern
makeGeometryNeighPattern(
bool adjacent_child_contextualization_enabled_flag,
const Vec3<uint32_t>& position,
const Vec3<int32_t>& position,
const int atlasShift,
const MortonMap3D& occupancyAtlas)
{
......
......@@ -206,22 +206,22 @@ struct GeometryNeighPattern {
// the neighbour pattern and derive external adjacency counts for each child.
GeometryNeighPattern makeGeometryNeighPattern(
bool adjacent_child_contextualization_enabled_flag,
const Vec3<uint32_t>& currentPosition,
const Vec3<int32_t>& currentPosition,
const int atlasShift,
const MortonMap3D& occupancyAtlas);
// populate (if necessary) the occupancy atlas with occupancy information
// from @fifo.
void updateGeometryOccupancyAtlas(
const Vec3<uint32_t>& position,
const Vec3<int32_t>& position,
const int atlasShift,
const ringbuf<PCCOctree3Node>& fifo,
const ringbuf<PCCOctree3Node>::iterator& fifoCurrLvlEnd,
MortonMap3D* occupancyAtlas,
Vec3<uint32_t>* atlasOrigin);
Vec3<int32_t>* atlasOrigin);
void updateGeometryOccupancyAtlasOccChild(
const Vec3<uint32_t>& pos,
const Vec3<int32_t>& pos,
uint8_t childOccupancy,
MortonMap3D* occupancyAtlas);
......
......@@ -62,7 +62,7 @@ static const int LUT_th1[5] = {67, 66, 65, 66, 64};
void
predictGeometryOccupancyIntra(
const MortonMap3D& occupancyAtlas,
Vec3<uint32_t> pos,
Vec3<int32_t> pos,
const int atlasShift,
int* occupancyIsPredicted,
int* occupancyPrediction)
......
......@@ -46,7 +46,7 @@ namespace pcc {
void predictGeometryOccupancyIntra(
const MortonMap3D& occupancyAtlas,
Vec3<uint32_t> pos,
Vec3<int32_t> pos,
const int atlasShift,
int* occupacyIsPredIntra,
int* occupacyPredIntra);
......
......@@ -54,7 +54,7 @@ const int MAX_NUM_DM_LEAF_POINTS = 2;
struct PCCOctree3Node {
// 3D position of the current node's origin (local x,y,z = 0).
Vec3<uint32_t> pos;
Vec3<int32_t> pos;
// Range of point indexes spanned by node
uint32_t start;
......
......@@ -158,7 +158,7 @@ public:
bool planarPossibleY,
bool planarPossibleZ);
Vec3<uint32_t> decodePointPosition(
Vec3<int32_t> decodePointPosition(
const Vec3<int>& nodeSizeLog2, uint8_t planarMode, uint8_t planePosBits);
int decodeQpOffset();
......@@ -804,11 +804,11 @@ GeometryOctreeDecoder::decodeOccupancy(
//-------------------------------------------------------------------------
// Decode a position of a point in a given volume.
Vec3<uint32_t>
Vec3<int32_t>
GeometryOctreeDecoder::decodePointPosition(
const Vec3<int>& nodeSizeLog2, uint8_t planarMode, uint8_t planePosBits)
{
Vec3<uint32_t> delta{};
Vec3<int32_t> delta{};
for (int k = 0; k < 3; k++) {
if (nodeSizeLog2[k] <= 0)
continue;
......@@ -878,7 +878,7 @@ GeometryOctreeDecoder::decodeDirectPosition(
}
}
Vec3<uint32_t> pos;
Vec3<int32_t> pos;
for (int i = 0; i < numPoints; i++)
*(outputPoints++) = pos =
decodePointPosition(nodeSizeLog2, node.planarMode, node.planePosBits);
......@@ -893,8 +893,8 @@ GeometryOctreeDecoder::decodeDirectPosition(
//-------------------------------------------------------------------------
// Helper to inverse quantise positions
Vec3<uint32_t>
invQuantPosition(int qp, Vec3<uint32_t> quantMasks, const Vec3<uint32_t>& pos)
Vec3<int32_t>
invQuantPosition(int qp, Vec3<uint32_t> quantMasks, const Vec3<int32_t>& pos)
{
// pos represents the position within the coded tree as follows:
// |pppppqqqqqq|00
......@@ -906,7 +906,7 @@ invQuantPosition(int qp, Vec3<uint32_t> quantMasks, const Vec3<uint32_t>& pos)
QuantizerGeom quantizer(qp);
int shiftBits = (qp - 4) / 6;
Vec3<uint32_t> recon;
Vec3<int32_t> recon;
for (int k = 0; k < 3; k++) {
int posQuant = pos[k] & (quantMasks[k] >> shiftBits);
recon[k] = (pos[k] ^ posQuant) << shiftBits;
......@@ -970,7 +970,7 @@ decodeGeometryOctree(
PCCOctree3Node& node00 = fifo.back();
node00.start = uint32_t(0);
node00.end = uint32_t(0);
node00.pos = uint32_t(0);
node00.pos = int32_t(0);
node00.neighPattern = 0;
node00.numSiblingsPlus1 = 8;
node00.siblingOccupancy = 0;
......@@ -1006,7 +1006,7 @@ decodeGeometryOctree(
// ie, the number of nodes added to the next level of the tree
int numNodesNextLvl = 0;
Vec3<uint32_t> occupancyAtlasOrigin(0xffffffff);
Vec3<int32_t> occupancyAtlasOrigin{-1};
MortonMap3D occupancyAtlas;
if (gps.neighbour_avail_boundary_log2) {
occupancyAtlas.resize(gps.neighbour_avail_boundary_log2);
......@@ -1207,9 +1207,9 @@ decodeGeometryOctree(
}
// the final bits from the leaf:
Vec3<uint32_t> pos{(node0.pos[0] << !(occupancySkip & 4)) + x,
(node0.pos[1] << !(occupancySkip & 2)) + y,
(node0.pos[2] << !(occupancySkip & 1)) + z};
Vec3<int32_t> pos{(node0.pos[0] << !(occupancySkip & 4)) + x,
(node0.pos[1] << !(occupancySkip & 2)) + y,
(node0.pos[2] << !(occupancySkip & 1)) + z};
pos = invQuantPosition(node0.qp, posQuantBitMasks, pos);
const Vec3<double> point(pos[0], pos[1], pos[2]);
......@@ -1247,7 +1247,7 @@ decodeGeometryOctree(
if (isDirectModeEligible(
idcmEnabled, effectiveNodeMaxDimLog2, node0, child)) {
// todo(df): this should go away when output is integer
Vec3<uint32_t> points[2]{};
Vec3<int32_t> points[2]{};
int numPoints = decoder.decodeDirectPosition(
gps.geom_unique_points_flag, effectiveChildSizeLog2, child, points);
......
......@@ -169,7 +169,7 @@ public:
void encodePointPosition(
const Vec3<int>& nodeSizeLog2,
const Vec3<uint32_t>& pos,
const Vec3<int32_t>& pos,
uint8_t planarMode);
void encodeQpOffset(int dqp);
......@@ -798,7 +798,7 @@ GeometryOctreeEncoder::encodeOccupancy(
// Encode a position of a point in a given volume.
void
GeometryOctreeEncoder::encodePointPosition(
const Vec3<int>& nodeSizeLog2, const Vec3<uint32_t>& pos, uint8_t planarMode)
const Vec3<int>& nodeSizeLog2, const Vec3<int32_t>& pos, uint8_t planarMode)
{
for (int k = 0; k < 3; k++) {
if (nodeSizeLog2[k] <= 0)
......@@ -880,11 +880,11 @@ geometryQuantization(
for (int k = 0; k < 3; k++) {
int quantBitsMask = (1 << nodeSizeLog2[k]) - 1;
uint32_t clipMax = ((1 << nodeSizeLog2[k]) >> qpShift) - 1;
int32_t clipMax = ((1 << nodeSizeLog2[k]) >> qpShift) - 1;
for (int i = node.start; i < node.end; i++) {
uint32_t pos = uint32_t(pointCloud[i][k]);
uint32_t quantPos = quantizer.quantize(pos & quantBitsMask);
int32_t pos = int32_t(pointCloud[i][k]);
int32_t quantPos = quantizer.quantize(pos & quantBitsMask);
quantPos = PCCClip(quantPos, 0, clipMax);
// NB: this representation is: |ppppppqqq|00, which is the
......@@ -906,8 +906,8 @@ geometryScale(
for (int k = 0; k < 3; k++) {
int quantBitsMask = (1 << quantNodeSizeLog2[k]) - 1;
for (int i = node.start; i < node.end; i++) {
uint32_t pos = uint32_t(pointCloud[i][k]);
uint32_t quantPos = (pos >> qpShift) & quantBitsMask;
int32_t pos = int32_t(pointCloud[i][k]);
int32_t quantPos = (pos >> qpShift) & quantBitsMask;
pointCloud[i][k] = (pos & ~quantBitsMask) | quantizer.scale(quantPos);
}
}
......@@ -985,9 +985,8 @@ GeometryOctreeEncoder::encodeDirectPosition(
for (auto idx = node.start; idx < node.start + numPoints; idx++)
encodePointPosition(
nodeSizeLog2,
Vec3<uint32_t>{uint32_t(pointCloud[idx][0]),
uint32_t(pointCloud[idx][1]),
uint32_t(pointCloud[idx][2])}
Vec3<int32_t>{int32_t(pointCloud[idx][0]), int32_t(pointCloud[idx][1]),
int32_t(pointCloud[idx][2])}
>> shiftBits,
node.planarMode);
......@@ -1016,7 +1015,7 @@ encodeGeometryOctree(
PCCOctree3Node& node00 = fifo.back();
node00.start = uint32_t(0);
node00.end = uint32_t(pointCloud.getPointCount());
node00.pos = uint32_t(0);
node00.pos = int32_t(0);
node00.neighPattern = 0;
node00.numSiblingsPlus1 = 8;
node00.siblingOccupancy = 0;
......@@ -1090,7 +1089,7 @@ encodeGeometryOctree(
occupancyAtlas.resize(gps.neighbour_avail_boundary_log2);
occupancyAtlas.clear();
}
Vec3<uint32_t> occupancyAtlasOrigin(0xffffffff);
Vec3<int32_t> occupancyAtlasOrigin{-1};
// the node size where quantisation is performed
Vec3<int> quantNodeSizeLog2 = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment