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