Commit 0cf8cc46 authored by Khaled Mammou's avatar Khaled Mammou
Browse files

code clean up

git-svn-id: http://wg11.sc29.org/svn/repos/MPEG-I/Part5-PointCloudCompression/TM/TMC3/trunk@1223 94298a81-5874-47c9-aab8-bfb24faeed7f
parent 3c6d6979
......@@ -486,8 +486,8 @@ class PCCIncrementalKdTree3 {
return PCC_AXIS3_X;
case PCC_AXIS3_UNDEFINED:
return PCC_AXIS3_X;
default:
return PCC_AXIS3_X;
default:
return PCC_AXIS3_X;
}
}
void insert(PCCIncrementalKdTree3Node &node, const uint32_t parent) {
......
......@@ -48,8 +48,6 @@
#include "ArithmeticCodec.h"
//#define TMCV3_DECODER_VERBOSE
namespace pcc {
class PCCTMC3Decoder3 {
......@@ -319,24 +317,6 @@ class PCCTMC3Decoder3 {
std::vector<uint32_t> indexes;
PCCBuildPredictors(pointCloud, numberOfNearestNeighborsInPrediction, levelOfDetailCount, dist2,
predictors, numberOfPointsPerLOD, indexes);
#ifdef TMCV3_DECODER_VERBOSE
std::cout << "building predictors" << std::endl;
for (size_t lodIndex = 0; lodIndex < numberOfPointsPerLOD.size(); ++lodIndex) {
std::cout << "\t LOD " << lodIndex << " -> " << numberOfPointsPerLOD[lodIndex] << std::endl;
}
for (size_t lodIndex = 0; lodIndex < numberOfPointsPerLOD.size(); ++lodIndex) {
const size_t pointCount = numberOfPointsPerLOD[lodIndex];
PCCPointSet3 pointSet;
pointSet.resize(pointCount);
for (size_t i = 0; i < pointCount; ++i) {
pointSet[i] = pointCloud[indexes[i]];
}
std::stringstream fileName;
fileName << "LOD_dec" << lodIndex << ".ply";
pointSet.write(fileName.str().c_str());
}
std::cout << std::endl;
#endif // TMCV3_DECODER_VERBOSE
}
int decodeAttributeHeader(const std::string &attributeName, PCCBitstream &bitstream) {
......@@ -368,28 +348,6 @@ class PCCTMC3Decoder3 {
PCCReadFromBuffer<uint16_t>(bitstream.buffer, dz, bitstream.size);
quantizationDeadZoneSizes[lodIndex] = dz;
}
#ifdef TMCV3_DECODER_VERBOSE
std::cout << attributeName << " header" << std::endl;
std::cout << "\t numberOfNearestNeighborsInPrediction " << numberOfNearestNeighborsInPrediction
<< std::endl;
std::cout << "\t levelOfDetailCount " << levelOfDetailCount << std::endl;
std::cout << "\t dist2 ";
for (size_t lodIndex = 0; lodIndex < levelOfDetailCount; ++lodIndex) {
std::cout << dist2[lodIndex] << " ";
}
std::cout << std::endl;
std::cout << "\t quantizationSteps ";
for (size_t lodIndex = 0; lodIndex < levelOfDetailCount; ++lodIndex) {
std::cout << quantizationSteps[lodIndex] << " ";
}
std::cout << std::endl;
std::cout << "\t quantizationDeadZoneSizes ";
for (size_t lodIndex = 0; lodIndex < levelOfDetailCount; ++lodIndex) {
std::cout << quantizationDeadZoneSizes[lodIndex] << " ";
}
std::cout << std::endl << std::endl;
#endif // TMCV3_DECODER_VERBOSE
return 0;
}
......@@ -423,20 +381,6 @@ class PCCTMC3Decoder3 {
if (fabs(positionQuantizationScale) < minPositionQuantizationScale) {
positionQuantizationScale = 1.0;
}
#ifdef TMCV3_DECODER_VERBOSE
std::cout << "Positions Header" << std::endl;
std::cout << "\t pointCount " << pointCloud.getPointCount() << std::endl;
std::cout << "\t hasColors " << pointCloud.hasColors() << std::endl;
std::cout << "\t hasReflectances " << pointCloud.hasReflectances() << std::endl;
std::cout << "\t minPositions " << minPositions[0] << ", " << minPositions[1]
<< ", " << minPositions[2] << std::endl;
std::cout << "\t boundingBox (" << boundingBox.min[0] << ", "
<< boundingBox.min[1] << ", " << boundingBox.min[2] << ") (" << boundingBox.max[0]
<< ", " << boundingBox.max[1] << ", " << boundingBox.max[2] << ")" << std::endl;
std::cout << "\t positionQuantizationScale " << positionQuantizationScale << std::endl;
std::cout << std::endl;
#endif // TMCV3_DECODER_VERBOSE
return 0;
}
int decodePositions(PCCBitstream &bitstream, PCCPointSet3 &pointCloud) {
......
......@@ -52,8 +52,6 @@
#include "ArithmeticCodec.h"
//#define TMCV3_ENCODER_VERBOSE
namespace pcc {
struct PCCAttributeEncodeParamaters {
size_t numberOfNearestNeighborsInPrediction;
......@@ -238,7 +236,8 @@ class PCCTMC3Encoder3 {
if (predictor.maxNeighborCount) {
const int64_t quantAttValue = pointCloud.getReflectance(predictor.index);
const int64_t quantPredAttValue = predictor.predictReflectance(pointCloud);
const uint32_t diffAttValue = uint32_t(o3dgc::IntToUInt(long(quantAttValue - quantPredAttValue)));
const uint32_t diffAttValue =
uint32_t(o3dgc::IntToUInt(long(quantAttValue - quantPredAttValue)));
if (maxAttributeValueDiff0 < diffAttValue) {
maxAttributeValueDiff0 = diffAttValue;
}
......@@ -267,7 +266,8 @@ class PCCTMC3Encoder3 {
arithmeticEncoder.start_encoder();
o3dgc::Static_Bit_Model binaryModel0;
o3dgc::Adaptive_Data_Model neighborCountModel;
neighborCountModel.set_alphabet(uint32_t(reflectanceParams.numberOfNearestNeighborsInPrediction));
neighborCountModel.set_alphabet(
uint32_t(reflectanceParams.numberOfNearestNeighborsInPrediction));
for (size_t predictorIndex = 0; predictorIndex < pointCount; ++predictorIndex) {
const auto &predictor = predictors[predictorIndex];
if (!predictor.neighborCount) { // no prediction
......@@ -301,28 +301,6 @@ class PCCTMC3Encoder3 {
int encodeAttributeHeader(const PCCAttributeEncodeParamaters &attributeParams,
const std::string &attributeName, PCCBitstream &bitstream) const {
#ifdef TMCV3_ENCODER_VERBOSE
std::cout << attributeName << " header" << std::endl;
std::cout << "\t numberOfNearestNeighborsInPrediction "
<< attributeParams.numberOfNearestNeighborsInPrediction << std::endl;
std::cout << "\t levelOfDetailCount " << attributeParams.levelOfDetailCount
<< std::endl;
std::cout << "\t dist2 ";
for (size_t lodIndex = 0; lodIndex < attributeParams.levelOfDetailCount; ++lodIndex) {
std::cout << attributeParams.dist2[lodIndex] << " ";
}
std::cout << std::endl;
std::cout << "\t quantizationSteps ";
for (size_t lodIndex = 0; lodIndex < attributeParams.levelOfDetailCount; ++lodIndex) {
std::cout << attributeParams.quantizationSteps[lodIndex] << " ";
}
std::cout << std::endl;
std::cout << "\t quantizationDeadZoneSizes ";
for (size_t lodIndex = 0; lodIndex < attributeParams.levelOfDetailCount; ++lodIndex) {
std::cout << attributeParams.quantizationDeadZoneSizes[lodIndex] << " ";
}
std::cout << std::endl << std::endl;
#endif // TMCV3_ENCODER_VERBOSE
PCCWriteToBuffer<uint8_t>(uint8_t(attributeParams.numberOfNearestNeighborsInPrediction),
bitstream.buffer, bitstream.size);
PCCWriteToBuffer<uint8_t>(uint8_t(attributeParams.levelOfDetailCount), bitstream.buffer,
......@@ -354,7 +332,8 @@ class PCCTMC3Encoder3 {
const PCCColor3B predictedColor = predictor.predictColor(pointCloud);
const int64_t quantAttValue = color[0];
const int64_t quantPredAttValue = predictedColor[0];
const uint32_t diffAttValue = uint32_t(o3dgc::IntToUInt(long(quantAttValue - quantPredAttValue)));
const uint32_t diffAttValue =
uint32_t(o3dgc::IntToUInt(long(quantAttValue - quantPredAttValue)));
if (maxAttributeValueDiff0 < diffAttValue) {
maxAttributeValueDiff0 = diffAttValue;
}
......@@ -462,9 +441,6 @@ class PCCTMC3Encoder3 {
return 0;
}
void computeColorPredictionWeights(const PCCAttributeEncodeParamaters &attributeParams) {
#ifdef TMCV3_ENCODER_VERBOSE
std::cout << "computing colors prediction weights" << std::endl;
#endif // TMCV3_ENCODER_VERBOSE
const size_t pointCount = predictors.size();
double bestCost = std::numeric_limits<double>::max();
size_t bestNeighborCount = 1;
......@@ -492,22 +468,11 @@ class PCCTMC3Encoder3 {
cost += delta1;
}
}
#ifdef TMCV3_ENCODER_VERBOSE
std::cout << "\t neighborCount " << neighborCount << " " << (cost / (3.0 * pointCount))
<< std::endl;
#endif // TMCV3_ENCODER_VERBOSE
if (cost < bestCost) {
bestCost = cost;
bestNeighborCount = neighborCount;
}
}
#ifdef TMCV3_ENCODER_VERBOSE
std::cout << "\t -> bestNeighborCount " << bestNeighborCount << " "
<< (bestCost / (3.0 * pointCount)) << std::endl
<< std::endl;
#endif // TMCV3_ENCODER_VERBOSE
for (size_t predictorIndex = 0; predictorIndex < pointCount; ++predictorIndex) {
auto &predictor = predictors[predictorIndex];
if (!predictor.maxNeighborCount) {
......@@ -517,9 +482,6 @@ class PCCTMC3Encoder3 {
}
}
void computeReflectancePredictionWeights(const PCCAttributeEncodeParamaters &attributeParams) {
#ifdef TMCV3_ENCODER_VERBOSE
std::cout << "computing reflectance prediction weights" << std::endl;
#endif // TMCV3_ENCODER_VERBOSE
const size_t pointCount = predictors.size();
double bestCost = std::numeric_limits<double>::max();
size_t bestNeighborCount = 1;
......@@ -541,21 +503,11 @@ class PCCTMC3Encoder3 {
const uint32_t delta1 = o3dgc::IntToUInt(long(delta0));
cost += delta1;
}
#ifdef TMCV3_ENCODER_VERBOSE
std::cout << "\t neighborCount " << neighborCount << " " << (cost / pointCount) << std::endl;
#endif // TMCV3_ENCODER_VERBOSE
if (cost < bestCost) {
bestCost = cost;
bestNeighborCount = neighborCount;
}
}
#ifdef TMCV3_ENCODER_VERBOSE
std::cout << "\t -> bestNeighborCount " << bestNeighborCount << " " << (bestCost / pointCount)
<< std::endl
<< std::endl;
#endif // TMCV3_ENCODER_VERBOSE
for (size_t predictorIndex = 0; predictorIndex < pointCount; ++predictorIndex) {
auto &predictor = predictors[predictorIndex];
if (!predictor.maxNeighborCount) {
......@@ -571,24 +523,6 @@ class PCCTMC3Encoder3 {
PCCBuildPredictors(pointCloud, attributeParams.numberOfNearestNeighborsInPrediction,
attributeParams.levelOfDetailCount, attributeParams.dist2, predictors,
numberOfPointsPerLOD, indexes);
#ifdef TMCV3_ENCODER_VERBOSE
std::cout << "building predictors" << std::endl;
for (size_t lodIndex = 0; lodIndex < numberOfPointsPerLOD.size(); ++lodIndex) {
std::cout << "\t LOD " << lodIndex << " -> " << numberOfPointsPerLOD[lodIndex] << std::endl;
}
for (size_t lodIndex = 0; lodIndex < numberOfPointsPerLOD.size(); ++lodIndex) {
const size_t pointCount = numberOfPointsPerLOD[lodIndex];
PCCPointSet3 pointSet;
pointSet.resize(pointCount);
for (size_t i = 0; i < pointCount; ++i) {
pointSet[i] = pointCloud[indexes[i]];
}
std::stringstream fileName;
fileName << "LOD_" << lodIndex << ".ply";
pointSet.write(fileName.str().c_str());
}
std::cout << std::endl;
#endif // TMCV3_ENCODER_VERBOSE
}
void reconstructedPointCloud(const PCCTMC3Encoder3Parameters &params,
PCCPointSet3 *reconstructedCloud) {
......@@ -672,7 +606,8 @@ class PCCTMC3Encoder3 {
arithmeticEncoder.encode(1, singlePointPerBlock);
} else {
arithmeticEncoder.encode(0, singlePointPerBlock);
arithmeticEncoder.ExpGolombEncode(uint32_t(count - 1), 0, bModel0, bModelPointCountPerBlock);
arithmeticEncoder.ExpGolombEncode(uint32_t(count - 1), 0, bModel0,
bModelPointCountPerBlock);
}
processedPointCount += count;
} else {
......@@ -688,7 +623,7 @@ class PCCTMC3Encoder3 {
int64_t splitIndex = int64_t(node.start);
if (node.end > node.start) {
assert(node.end > 0);
int64_t last = int64_t(node.end - 1);
int64_t last = int64_t(node.end - 1);
while (splitIndex <= last) {
assert(splitIndex <= node.end);
assert(last >= node.start);
......@@ -737,20 +672,6 @@ class PCCTMC3Encoder3 {
}
int encodePositionsHeader(const PCCTMC3Encoder3Parameters &params,
PCCBitstream &bitstream) const {
#ifdef TMCV3_ENCODER_VERBOSE
std::cout << "positions header" << std::endl;
std::cout << "\t pointCount " << pointCloud.getPointCount() << std::endl;
std::cout << "\t hasColors " << pointCloud.hasColors() << std::endl;
std::cout << "\t hasReflectances " << pointCloud.hasReflectances() << std::endl;
std::cout << "\t minPositions " << minPositions[0] << ", " << minPositions[1]
<< ", " << minPositions[2] << std::endl;
std::cout << "\t boundingBox (" << boundingBox.min[0] << ", "
<< boundingBox.min[1] << ", " << boundingBox.min[2] << ") (" << boundingBox.max[0]
<< ", " << boundingBox.max[1] << ", " << boundingBox.max[2] << ")" << std::endl;
std::cout << "\t positionQuantizationScale " << params.positionQuantizationScale << std::endl;
std::cout << std::endl;
#endif // TMCV3_ENCODER_VERBOSE
PCCWriteToBuffer<uint32_t>(uint32_t(pointCloud.getPointCount()), bitstream.buffer,
bitstream.size);
PCCWriteToBuffer<uint8_t>(uint8_t(pointCloud.hasColors()), bitstream.buffer, bitstream.size);
......@@ -883,15 +804,6 @@ class PCCTMC3Encoder3 {
}
}
}
#ifdef TMCV3_ENCODER_VERBOSE
std::cout << "quantization" << std::endl;
std::cout << "\t input point count " << inputPointCloud.getPointCount() << std::endl;
std::cout << "\t quantized point count " << pointCloud.getPointCount() << std::endl;
std::cout << "\t compress color " << pointCloud.hasColors() << std::endl;
std::cout << "\t compress reflectance " << pointCloud.hasReflectances() << std::endl;
std::cout << std::endl;
#endif // TMCV3_ENCODER_VERBOSE
return 0;
}
......
......@@ -66,8 +66,18 @@ void Usage() {
<< std::endl;
std::cout << "+ Usage" << std::endl;
std::cout << "\t Encode example: \n tmc3 --mode 0 --mergeDuplicatedPoints 1 --uncompressedDataPath Ford_01-0100.ply --compressedStreamPath compressed.bin --colorTransform 1 --numberOfNearestNeighborsInPrediction 8 --positionQuantizationScale 500.0 --levelOfDetailCount 6 --dist2 16777216 4194304 1048576 262144 65536 0 --quantizationSteps 1 1 1 2 2 2 --quantizationDeadZoneSizes 1 1 1 2 2 2 --searchRange 2 --attribute color --attribute reflectance" << std::endl << std::endl;
std::cout << "\t Decode example: \n tmc3 --mode 1 --compressedStreamPath compressed.bin --reconstructedDataPath reconstructed_dec.ply --colorTransform 1" << std::endl << std::endl;
std::cout << "\t Encode example: \n tmc3 --mode 0 --mergeDuplicatedPoints 1 "
"--uncompressedDataPath Ford_01-0100.ply --compressedStreamPath compressed.bin "
"--colorTransform 1 --numberOfNearestNeighborsInPrediction 8 "
"--positionQuantizationScale 500.0 --levelOfDetailCount 6 --dist2 16777216 4194304 "
"1048576 262144 65536 0 --quantizationSteps 1 1 1 2 2 2 --quantizationDeadZoneSizes "
"1 1 1 2 2 2 --searchRange 2 --attribute color --attribute reflectance"
<< std::endl
<< std::endl;
std::cout << "\t Decode example: \n tmc3 --mode 1 --compressedStreamPath compressed.bin "
"--reconstructedDataPath reconstructed_dec.ply --colorTransform 1"
<< std::endl
<< std::endl;
std::cout << std::endl;
}
......
......@@ -45,10 +45,10 @@
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <memory>
#include "PCCPointSet.h"
#include "PCCTMC3Decoder.h"
......
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