Commit 8c4727ae authored by David Flynn's avatar David Flynn
Browse files

attr: update methods that always return 0 -> void

Little is gained from the return type checks, it mostly serves to
clutter the code.
parent c3d42c2d
......@@ -123,7 +123,7 @@ void AttributeDecoder::buildPredictors(const PCCPointSet3 &pointCloud) {
//----------------------------------------------------------------------------
int AttributeDecoder::decodeHeader(
void AttributeDecoder::decodeHeader(
const std::string &attributeName,
PCCBitstream &bitstream
) {
......@@ -160,13 +160,11 @@ int AttributeDecoder::decodeHeader(
PCCReadFromBuffer<uint8_t>(bitstream.buffer, binaryLevelThresholdRaht, bitstream.size);
PCCReadFromBuffer<uint32_t>(bitstream.buffer, quantizationStepRaht, bitstream.size);
}
return 0;
}
//----------------------------------------------------------------------------
int AttributeDecoder::decodeReflectances(
void AttributeDecoder::decodeReflectances(
PCCBitstream &bitstream,
PCCPointSet3 &pointCloud
) {
......@@ -188,12 +186,11 @@ int AttributeDecoder::decodeReflectances(
decoder.stop();
bitstream.size += compressedBitstreamSize;
return 0;
}
//----------------------------------------------------------------------------
int AttributeDecoder::decodeColors(
void AttributeDecoder::decodeColors(
PCCBitstream &bitstream,
PCCPointSet3 &pointCloud
) {
......@@ -215,7 +212,6 @@ int AttributeDecoder::decodeColors(
decoder.stop();
bitstream.size += compressedBitstreamSize;
return 0;
}
//----------------------------------------------------------------------------
......
......@@ -57,18 +57,15 @@ public:
void buildPredictors(
const PCCPointSet3 &pointCloud);
// todo(df): return value is always 0 => should be void?
int decodeHeader(
void decodeHeader(
const std::string &attributeName,
PCCBitstream &bitstream);
// todo(df): return value is always 0 => should be void?
int decodeReflectances(
void decodeReflectances(
PCCBitstream &bitstream,
PCCPointSet3 &pointCloud);
// todo(df): return value is always 0 => should be void?
int decodeColors(
void decodeColors(
PCCBitstream &bitstream,
PCCPointSet3 &pointCloud);
......
......@@ -131,7 +131,7 @@ void AttributeEncoder::buildPredictors(
//----------------------------------------------------------------------------
int AttributeEncoder::encodeHeader(
void AttributeEncoder::encodeHeader(
const PCCAttributeEncodeParamaters &attributeParams,
const std::string &attributeName,
PCCBitstream &bitstream
......@@ -170,13 +170,11 @@ int AttributeEncoder::encodeHeader(
uint32_t(attributeParams.quantizationStepRaht),
bitstream.buffer, bitstream.size);
}
return 0;
}
//----------------------------------------------------------------------------
int AttributeEncoder::encodeReflectances(
void AttributeEncoder::encodeReflectances(
const PCCAttributeEncodeParamaters &reflectanceParams,
PCCPointSet3 &pointCloud,
PCCBitstream &bitstream
......@@ -200,12 +198,11 @@ int AttributeEncoder::encodeReflectances(
uint32_t compressedBitstreamSize = encoder.stop();
bitstream.size += compressedBitstreamSize;
PCCWriteToBuffer<uint32_t>(compressedBitstreamSize, bitstream.buffer, startSize);
return 0;
}
//----------------------------------------------------------------------------
int AttributeEncoder::encodeColors(
void AttributeEncoder::encodeColors(
const PCCAttributeEncodeParamaters &colorParams,
PCCPointSet3 &pointCloud,
PCCBitstream &bitstream
......@@ -229,7 +226,6 @@ int AttributeEncoder::encodeColors(
uint32_t compressedBitstreamSize = encoder.stop();
bitstream.size += compressedBitstreamSize;
PCCWriteToBuffer<uint32_t>(compressedBitstreamSize, bitstream.buffer, startSize);
return 0;
}
//----------------------------------------------------------------------------
......
......@@ -72,20 +72,17 @@ public:
const PCCAttributeEncodeParamaters &attributeParams,
const PCCPointSet3 &pointCloud);
// todo(df): return value is always 0 => should be void?
int encodeHeader(
void encodeHeader(
const PCCAttributeEncodeParamaters &attributeParams,
const std::string &attributeName,
PCCBitstream &bitstream) const;
// todo(df): return value is always 0 => should be void?
int encodeReflectances(
void encodeReflectances(
const PCCAttributeEncodeParamaters &reflectanceParams,
PCCPointSet3 &pointCloud,
PCCBitstream &bitstream);
// todo(df): return value is always 0 => should be void?
int encodeColors(
void encodeColors(
const PCCAttributeEncodeParamaters &colorParams,
PCCPointSet3 &pointCloud,
PCCBitstream &bitstream);
......
......@@ -99,13 +99,11 @@ class PCCTMC3Decoder3 {
if (pointCloud.hasColors()) {
uint64_t colorsSize = bitstream.size;
if (int ret = attrDecoder.decodeHeader("color", bitstream)) {
return ret;
}
attrDecoder.decodeHeader("color", bitstream);
attrDecoder.buildPredictors(pointCloud);
if (int ret = attrDecoder.decodeColors(bitstream, pointCloud)) {
return ret;
}
attrDecoder.decodeColors(bitstream, pointCloud);
colorsSize = bitstream.size - colorsSize;
std::cout << "colors bitstream size " << colorsSize << " B" << std::endl;
std::cout << std::endl;
......@@ -113,13 +111,11 @@ class PCCTMC3Decoder3 {
if (pointCloud.hasReflectances()) {
uint64_t reflectancesSize = bitstream.size;
if (int ret = attrDecoder.decodeHeader("reflectance", bitstream)) {
return ret;
}
attrDecoder.decodeHeader("reflectance", bitstream);
attrDecoder.buildPredictors(pointCloud);
if (int ret = attrDecoder.decodeReflectances(bitstream, pointCloud)) {
return ret;
}
attrDecoder.decodeReflectances(bitstream, pointCloud);
reflectancesSize = bitstream.size - reflectancesSize;
std::cout << "reflectances bitstream size " << reflectancesSize << " B" << std::endl;
}
......@@ -141,25 +137,21 @@ class PCCTMC3Decoder3 {
}
uint64_t positionsSize = bitstream.size;
if (int ret = decodePositionsHeader(bitstream, pointCloud)) {
return ret;
}
if (int ret = decodePositions(bitstream, pointCloud)) {
return ret;
}
decodePositionsHeader(bitstream, pointCloud);
decodePositions(bitstream, pointCloud);
positionsSize = bitstream.size - positionsSize;
std::cout << "positions bitstream size " << positionsSize << " B" << std::endl;
if (pointCloud.hasColors()) {
AttributeDecoder attrDecoder;
uint64_t colorsSize = bitstream.size;
if (int ret = attrDecoder.decodeHeader("color", bitstream)) {
return ret;
}
attrDecoder.decodeHeader("color", bitstream);
attrDecoder.buildPredictors(pointCloud);
if (int ret = attrDecoder.decodeColors(bitstream, pointCloud)) {
return ret;
}
attrDecoder.decodeColors(bitstream, pointCloud);
colorsSize = bitstream.size - colorsSize;
std::cout << "colors bitstream size " << colorsSize << " B" << std::endl;
std::cout << std::endl;
......@@ -168,13 +160,11 @@ class PCCTMC3Decoder3 {
if (pointCloud.hasReflectances()) {
AttributeDecoder attrDecoder;
uint64_t reflectancesSize = bitstream.size;
if (int ret = attrDecoder.decodeHeader("reflectance", bitstream)) {
return ret;
}
attrDecoder.decodeHeader("reflectance", bitstream);
attrDecoder.buildPredictors(pointCloud);
if (int ret = attrDecoder.decodeReflectances(bitstream, pointCloud)) {
return ret;
}
attrDecoder.decodeReflectances(bitstream, pointCloud);
reflectancesSize = bitstream.size - reflectancesSize;
std::cout << "reflectances bitstream size " << reflectancesSize << " B" << std::endl;
}
......@@ -204,10 +194,10 @@ class PCCTMC3Decoder3 {
size_t level;
double intToOrigScale;
PCCPoint3D intToOrigTranslation;
if (int ret = decodeTrisoupHeader(bitstream, pointCloud, depth, level, intToOrigScale,
intToOrigTranslation)) {
return ret;
}
decodeTrisoupHeader(
bitstream, pointCloud,
depth, level, intToOrigScale, intToOrigTranslation);
// Write out TMC1 geometry bitstream from the converged TMC13 bitstream.
uint32_t binSize = 0;
......@@ -247,13 +237,11 @@ class PCCTMC3Decoder3 {
if (pointCloud.hasColors()) {
AttributeDecoder attrDecoder;
uint64_t colorsSize = bitstream.size;
if (int ret = attrDecoder.decodeHeader("color", bitstream)) {
return ret;
}
attrDecoder.decodeHeader("color", bitstream);
attrDecoder.buildPredictors(pointCloud);
if (int ret = attrDecoder.decodeColors(bitstream, pointCloud)) {
return ret;
}
attrDecoder.decodeColors(bitstream, pointCloud);
colorsSize = bitstream.size - colorsSize;
std::cout << "colors bitstream size " << colorsSize << " B" << std::endl;
std::cout << std::endl;
......@@ -262,13 +250,11 @@ class PCCTMC3Decoder3 {
if (pointCloud.hasReflectances()) {
AttributeDecoder attrDecoder;
uint64_t reflectancesSize = bitstream.size;
if (int ret = attrDecoder.decodeHeader("reflectance", bitstream)) {
return ret;
}
attrDecoder.decodeHeader("reflectance", bitstream);
attrDecoder.buildPredictors(pointCloud);
if (int ret = attrDecoder.decodeReflectances(bitstream, pointCloud)) {
return ret;
}
attrDecoder.decodeReflectances(bitstream, pointCloud);
reflectancesSize = bitstream.size - reflectancesSize;
std::cout << "reflectances bitstream size " << reflectancesSize << " B" << std::endl;
}
......@@ -283,7 +269,7 @@ class PCCTMC3Decoder3 {
}
private:
int decodePositionsHeader(PCCBitstream &bitstream, PCCPointSet3 &pointCloud) {
void decodePositionsHeader(PCCBitstream &bitstream, PCCPointSet3 &pointCloud) {
uint32_t pointCount = 0;
PCCReadFromBuffer<uint32_t>(bitstream.buffer, pointCount, bitstream.size);
uint8_t hasColors = 0;
......@@ -324,10 +310,9 @@ class PCCTMC3Decoder3 {
if (fabs(positionQuantizationScale) < minPositionQuantizationScale) {
positionQuantizationScale = 1.0;
}
return 0;
}
int decodeTrisoupHeader(PCCBitstream &bitstream, PCCPointSet3 &pointCloud, size_t &depth,
void decodeTrisoupHeader(PCCBitstream &bitstream, PCCPointSet3 &pointCloud, size_t &depth,
size_t &level, double &intToOrigScale, PCCPoint3D &intToOrigTranslation) {
uint32_t pointCount = 0;
PCCReadFromBuffer<uint32_t>(bitstream.buffer, pointCount, bitstream.size);
......@@ -362,7 +347,6 @@ class PCCTMC3Decoder3 {
PCCReadFromBuffer<size_t>(bitstream.buffer, level, bitstream.size);
PCCReadFromBuffer<double>(bitstream.buffer, intToOrigScale, bitstream.size);
PCCReadFromBuffer<PCCPoint3D>(bitstream.buffer, intToOrigTranslation, bitstream.size);
return 0;
}
//-------------------------------------------------------------------------
......@@ -515,7 +499,7 @@ class PCCTMC3Decoder3 {
//-------------------------------------------------------------------------
int decodePositions(PCCBitstream &bitstream, PCCPointSet3 &pointCloud) {
void decodePositions(PCCBitstream &bitstream, PCCPointSet3 &pointCloud) {
uint32_t compressedBitstreamSize;
PCCReadFromBuffer<uint32_t>(bitstream.buffer, compressedBitstreamSize, bitstream.size);
o3dgc::Arithmetic_Codec arithmeticDecoder;
......@@ -668,7 +652,6 @@ class PCCTMC3Decoder3 {
arithmeticDecoder.stop_decoder();
bitstream.size += compressedBitstreamSize;
return 0;
}
void inverseQuantization(PCCPointSet3 &pointCloud, const bool roundOutputPositions) {
......
......@@ -139,13 +139,11 @@ class PCCTMC3Encoder3 {
AttributeEncoder attrEncoder;
const auto &colorParams = params.attributeEncodeParameters.find("color")->second;
uint64_t colorsSize = bitstream.size;
if (int ret = attrEncoder.encodeHeader(colorParams, "color", bitstream)) {
return ret;
}
attrEncoder.encodeHeader(colorParams, "color", bitstream);
attrEncoder.buildPredictors(colorParams, pointCloud);
if (int ret = attrEncoder.encodeColors(colorParams, pointCloud, bitstream)) {
return ret;
}
attrEncoder.encodeColors(colorParams, pointCloud, bitstream);
colorsSize = bitstream.size - colorsSize;
std::cout << "colors bitstream size " << colorsSize << " B ("
<< (8.0 * colorsSize) / inputPointCloud.getPointCount() << " bpp)" << std::endl;
......@@ -155,13 +153,11 @@ class PCCTMC3Encoder3 {
AttributeEncoder attrEncoder;
const auto &reflectanceParams = params.attributeEncodeParameters.find("reflectance")->second;
uint64_t reflectancesSize = bitstream.size;
if (int ret = attrEncoder.encodeHeader(reflectanceParams, "reflectance", bitstream)) {
return ret;
}
attrEncoder.encodeHeader(reflectanceParams, "reflectance", bitstream);
attrEncoder.buildPredictors(reflectanceParams, pointCloud);
if (int ret = attrEncoder.encodeReflectances(reflectanceParams, pointCloud, bitstream)) {
return ret;
}
attrEncoder.encodeReflectances(reflectanceParams, pointCloud, bitstream);
reflectancesSize = bitstream.size - reflectancesSize;
std::cout << "reflectances bitstream size " << reflectancesSize << " B ("
<< (8.0 * reflectancesSize) / inputPointCloud.getPointCount() << " bpp)"
......@@ -182,13 +178,11 @@ class PCCTMC3Encoder3 {
if (int ret = quantization(inputPointCloud, params)) {
return ret;
}
uint64_t positionsSize = bitstream.size;
if (int ret = encodePositionsHeader(params, bitstream)) {
return ret;
}
if (int ret = encodePositions(params, bitstream)) {
return ret;
}
encodePositionsHeader(params, bitstream);
encodePositions(params, bitstream);
positionsSize = bitstream.size - positionsSize;
std::cout << "positions bitstream size " << positionsSize << " B ("
<< (8.0 * positionsSize) / inputPointCloud.getPointCount() << " bpp)" << std::endl;
......@@ -197,13 +191,11 @@ class PCCTMC3Encoder3 {
AttributeEncoder attrEncoder;
const auto &colorParams = params.attributeEncodeParameters.find("color")->second;
uint64_t colorsSize = bitstream.size;
if (int ret = attrEncoder.encodeHeader(colorParams, "color", bitstream)) {
return ret;
}
attrEncoder.encodeHeader(colorParams, "color", bitstream);
attrEncoder.buildPredictors(colorParams, pointCloud);
if (int ret = attrEncoder.encodeColors(colorParams, pointCloud, bitstream)) {
return ret;
}
attrEncoder.encodeColors(colorParams, pointCloud, bitstream);
colorsSize = bitstream.size - colorsSize;
std::cout << "colors bitstream size " << colorsSize << " B ("
<< (8.0 * colorsSize) / inputPointCloud.getPointCount() << " bpp)" << std::endl;
......@@ -213,13 +205,11 @@ class PCCTMC3Encoder3 {
AttributeEncoder attrEncoder;
const auto &reflectanceParams = params.attributeEncodeParameters.find("reflectance")->second;
uint64_t reflectancesSize = bitstream.size;
if (int ret = attrEncoder.encodeHeader(reflectanceParams, "reflectance", bitstream)) {
return ret;
}
attrEncoder.encodeHeader(reflectanceParams, "reflectance", bitstream);
attrEncoder.buildPredictors(reflectanceParams, pointCloud);
if (int ret = attrEncoder.encodeReflectances(reflectanceParams, pointCloud, bitstream)) {
return ret;
}
attrEncoder.encodeReflectances(reflectanceParams, pointCloud, bitstream);
reflectancesSize = bitstream.size - reflectancesSize;
std::cout << "reflectances bitstream size " << reflectancesSize << " B ("
<< (8.0 * reflectancesSize) / inputPointCloud.getPointCount() << " bpp)"
......@@ -296,9 +286,8 @@ class PCCTMC3Encoder3 {
// Encode positions.
uint64_t positionsSize = bitstream.size;
if (int ret = encodeTrisoupHeader(params, bitstream)) {
return ret;
}
encodeTrisoupHeader(params, bitstream);
// Read in TMC1 geometry bitstream and put it into the converged TMC13 bitstream.
std::ifstream fin("outbin/outbin_0000.bin", std::ios::binary);
if (!fin.is_open()) {
......@@ -324,13 +313,11 @@ class PCCTMC3Encoder3 {
AttributeEncoder attrEncoder;
const auto &colorParams = params.attributeEncodeParameters.find("color")->second;
uint64_t colorsSize = bitstream.size;
attrEncoder.buildPredictors(colorParams, pointCloud);
if (int ret = attrEncoder.encodeHeader(colorParams, "color", bitstream)) {
return ret;
}
if (int ret = attrEncoder.encodeColors(colorParams, pointCloud, bitstream)) {
return ret;
}
attrEncoder.encodeHeader(colorParams, "color", bitstream);
attrEncoder.encodeColors(colorParams, pointCloud, bitstream);
colorsSize = bitstream.size - colorsSize;
std::cout << "colors bitstream size " << colorsSize << " B ("
<< (8.0 * colorsSize) / inputPointCloud.getPointCount() << " bpp)" << std::endl;
......@@ -340,14 +327,11 @@ class PCCTMC3Encoder3 {
AttributeEncoder attrEncoder;
const auto &reflectanceParams = params.attributeEncodeParameters.find("reflectance")->second;
uint64_t reflectancesSize = bitstream.size;
attrEncoder.buildPredictors(reflectanceParams, pointCloud);
attrEncoder.encodeHeader(reflectanceParams, "reflectance", bitstream);
attrEncoder.encodeReflectances(reflectanceParams, pointCloud, bitstream);
if (int ret = attrEncoder.encodeHeader(reflectanceParams, "reflectance", bitstream)) {
return ret;
}
if (int ret = attrEncoder.encodeReflectances(reflectanceParams, pointCloud, bitstream)) {
return ret;
}
reflectancesSize = bitstream.size - reflectancesSize;
std::cout << "reflectances bitstream size " << reflectancesSize << " B ("
<< (8.0 * reflectancesSize) / inputPointCloud.getPointCount() << " bpp)"
......@@ -542,7 +526,7 @@ class PCCTMC3Encoder3 {
//-------------------------------------------------------------------------
int encodePositions(
void encodePositions(
const PCCTMC3Encoder3Parameters& params,
PCCBitstream& bitstream
) {
......@@ -767,10 +751,9 @@ class PCCTMC3Encoder3 {
const uint32_t compressedBitstreamSize = arithmeticEncoder.stop_encoder();
bitstream.size += compressedBitstreamSize;
PCCWriteToBuffer<uint32_t>(compressedBitstreamSize, bitstream.buffer, startSize);
return 0;
}
int encodePositionsHeader(const PCCTMC3Encoder3Parameters &params,
void encodePositionsHeader(const PCCTMC3Encoder3Parameters &params,
PCCBitstream &bitstream) const {
PCCWriteToBuffer<uint32_t>(uint32_t(pointCloud.getPointCount()), bitstream.buffer,
bitstream.size);
......@@ -795,10 +778,9 @@ class PCCTMC3Encoder3 {
PCCWriteToBuffer<uint32_t>(boundingBox.max[k], bitstream.buffer, bitstream.size);
}
PCCWriteToBuffer<double>(params.positionQuantizationScale, bitstream.buffer, bitstream.size);
return 0;
}
int encodeTrisoupHeader(const PCCTMC3Encoder3Parameters &params, PCCBitstream &bitstream) const {
void encodeTrisoupHeader(const PCCTMC3Encoder3Parameters &params, PCCBitstream &bitstream) const {
PCCWriteToBuffer<uint32_t>(uint32_t(pointCloud.getPointCount()), bitstream.buffer,
bitstream.size);
PCCWriteToBuffer<uint8_t>(uint8_t(pointCloud.hasColors()), bitstream.buffer, bitstream.size);
......@@ -820,9 +802,8 @@ class PCCTMC3Encoder3 {
params.triSoup.intToOrigTranslation[1],
params.triSoup.intToOrigTranslation[2]
), bitstream.buffer, bitstream.size);
return 0;
}
void computeMinPositions(const PCCPointSet3 &inputPointCloud) {
const size_t inputPointCount = inputPointCloud.getPointCount();
minPositions = inputPointCloud[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