Commit 51ccac7e authored by Khaled Mammou's avatar Khaled Mammou Committed by David Flynn
Browse files

attr: refactor attribute coding to produce IntegerLift variant

This commit reorganises the attribute coders to allow integration
of the RAHT variant.
parent 1f0b0fdf
...@@ -163,6 +163,38 @@ int AttributeDecoder::decodeReflectances( ...@@ -163,6 +163,38 @@ int AttributeDecoder::decodeReflectances(
const uint32_t alphabetSize = 64; const uint32_t alphabetSize = 64;
decoder.start(bitstream, alphabetSize); decoder.start(bitstream, alphabetSize);
decodeReflectancesIntegerLift(decoder, pointCloud);
decoder.stop();
bitstream.size += compressedBitstreamSize;
return 0;
}
//----------------------------------------------------------------------------
int AttributeDecoder::decodeColors(
PCCBitstream &bitstream,
PCCPointSet3 &pointCloud
) {
uint32_t compressedBitstreamSize = 0;
PCCReadFromBuffer<uint32_t>(bitstream.buffer, compressedBitstreamSize, bitstream.size);
PCCResidualsDecoder decoder;
const uint32_t alphabetSize = 64;
decoder.start(bitstream, alphabetSize);
decodeColorsIntegerLift(decoder, pointCloud);
decoder.stop();
bitstream.size += compressedBitstreamSize;
return 0;
}
//----------------------------------------------------------------------------
void AttributeDecoder::decodeReflectancesIntegerLift(
PCCResidualsDecoder &decoder,
PCCPointSet3 &pointCloud
) {
const size_t pointCount = predictors.size(); const size_t pointCount = predictors.size();
for (size_t predictorIndex = 0; predictorIndex < pointCount; ++predictorIndex) { for (size_t predictorIndex = 0; predictorIndex < pointCount; ++predictorIndex) {
auto &predictor = predictors[predictorIndex]; auto &predictor = predictors[predictorIndex];
...@@ -176,23 +208,14 @@ int AttributeDecoder::decodeReflectances( ...@@ -176,23 +208,14 @@ int AttributeDecoder::decodeReflectances(
reflectance = uint16_t(PCCClip(reconstructedQuantAttValue, int64_t(0), reflectance = uint16_t(PCCClip(reconstructedQuantAttValue, int64_t(0),
int64_t(std::numeric_limits<uint16_t>::max()))); int64_t(std::numeric_limits<uint16_t>::max())));
} }
decoder.stop();
bitstream.size += compressedBitstreamSize;
return 0;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int AttributeDecoder::decodeColors( void AttributeDecoder::decodeColorsIntegerLift(
PCCBitstream &bitstream, PCCResidualsDecoder &decoder,
PCCPointSet3 &pointCloud PCCPointSet3 &pointCloud
) { ) {
uint32_t compressedBitstreamSize = 0;
PCCReadFromBuffer<uint32_t>(bitstream.buffer, compressedBitstreamSize, bitstream.size);
PCCResidualsDecoder decoder;
const uint32_t alphabetSize = 64;
decoder.start(bitstream, alphabetSize);
const size_t pointCount = predictors.size(); const size_t pointCount = predictors.size();
for (size_t predictorIndex = 0; predictorIndex < pointCount; ++predictorIndex) { for (size_t predictorIndex = 0; predictorIndex < pointCount; ++predictorIndex) {
auto &predictor = predictors[predictorIndex]; auto &predictor = predictors[predictorIndex];
...@@ -214,9 +237,6 @@ int AttributeDecoder::decodeColors( ...@@ -214,9 +237,6 @@ int AttributeDecoder::decodeColors(
color[k] = uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), int64_t(255))); color[k] = uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), int64_t(255)));
} }
} }
decoder.stop();
bitstream.size += compressedBitstreamSize;
return 0;
} }
//============================================================================ //============================================================================
......
...@@ -45,6 +45,11 @@ ...@@ -45,6 +45,11 @@
namespace pcc { namespace pcc {
//============================================================================
// Opaque definitions (Internal detail)
struct PCCResidualsDecoder;
//============================================================================ //============================================================================
class AttributeDecoder { class AttributeDecoder {
...@@ -52,18 +57,32 @@ public: ...@@ -52,18 +57,32 @@ public:
void buildPredictors( void buildPredictors(
const PCCPointSet3 &pointCloud); const PCCPointSet3 &pointCloud);
// todo(df): return value is always 0 => should be void?
int decodeHeader( int decodeHeader(
const std::string &attributeName, const std::string &attributeName,
PCCBitstream &bitstream); PCCBitstream &bitstream);
// todo(df): return value is always 0 => should be void?
int decodeReflectances( int decodeReflectances(
PCCBitstream &bitstream, PCCBitstream &bitstream,
PCCPointSet3 &pointCloud); PCCPointSet3 &pointCloud);
// todo(df): return value is always 0 => should be void?
int decodeColors( int decodeColors(
PCCBitstream &bitstream, PCCBitstream &bitstream,
PCCPointSet3 &pointCloud); PCCPointSet3 &pointCloud);
protected:
// todo(df): consider alternative encapsulation
void decodeReflectancesIntegerLift(
PCCResidualsDecoder &decoder,
PCCPointSet3 &pointCloud);
void decodeColorsIntegerLift(
PCCResidualsDecoder &decoder,
PCCPointSet3 &pointCloud);
private: private:
std::vector<PCCPredictor> predictors; std::vector<PCCPredictor> predictors;
std::vector<int64_t> quantizationSteps; std::vector<int64_t> quantizationSteps;
......
...@@ -163,6 +163,42 @@ int AttributeEncoder::encodeReflectances( ...@@ -163,6 +163,42 @@ int AttributeEncoder::encodeReflectances(
const uint32_t alphabetSize = 64; const uint32_t alphabetSize = 64;
encoder.start(bitstream, alphabetSize); encoder.start(bitstream, alphabetSize);
encodeReflectancesIntegerLift(reflectanceParams, pointCloud, encoder);
uint32_t compressedBitstreamSize = encoder.stop();
bitstream.size += compressedBitstreamSize;
PCCWriteToBuffer<uint32_t>(compressedBitstreamSize, bitstream.buffer, startSize);
return 0;
}
//----------------------------------------------------------------------------
int AttributeEncoder::encodeColors(
const PCCAttributeEncodeParamaters &colorParams,
PCCPointSet3 &pointCloud,
PCCBitstream &bitstream
) {
uint64_t startSize = bitstream.size;
bitstream.size += 4; // placehoder for bitstream size
PCCResidualsEncoder encoder;
const uint32_t alphabetSize = 64;
encoder.start(bitstream, alphabetSize);
encodeColorsIntegerLift(colorParams, pointCloud, encoder);
uint32_t compressedBitstreamSize = encoder.stop();
bitstream.size += compressedBitstreamSize;
PCCWriteToBuffer<uint32_t>(compressedBitstreamSize, bitstream.buffer, startSize);
return 0;
}
//----------------------------------------------------------------------------
void AttributeEncoder::encodeReflectancesIntegerLift(
const PCCAttributeEncodeParamaters &reflectanceParams,
PCCPointSet3 &pointCloud,
PCCResidualsEncoder &encoder
) {
const size_t pointCount = predictors.size(); const size_t pointCount = predictors.size();
for (size_t predictorIndex = 0; predictorIndex < pointCount; ++predictorIndex) { for (size_t predictorIndex = 0; predictorIndex < pointCount; ++predictorIndex) {
const auto &predictor = predictors[predictorIndex]; const auto &predictor = predictors[predictorIndex];
...@@ -180,25 +216,15 @@ int AttributeEncoder::encodeReflectances( ...@@ -180,25 +216,15 @@ int AttributeEncoder::encodeReflectances(
encoder.encode0(attValue0); encoder.encode0(attValue0);
pointCloud.setReflectance(predictor.index, reconstructedReflectance); pointCloud.setReflectance(predictor.index, reconstructedReflectance);
} }
uint32_t compressedBitstreamSize = encoder.stop();
bitstream.size += compressedBitstreamSize;
PCCWriteToBuffer<uint32_t>(compressedBitstreamSize, bitstream.buffer, startSize);
return 0;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int AttributeEncoder::encodeColors( void AttributeEncoder::encodeColorsIntegerLift(
const PCCAttributeEncodeParamaters &colorParams, const PCCAttributeEncodeParamaters &colorParams,
PCCPointSet3 &pointCloud, PCCPointSet3 &pointCloud,
PCCBitstream &bitstream PCCResidualsEncoder &encoder
) { ) {
uint64_t startSize = bitstream.size;
bitstream.size += 4; // placehoder for bitstream size
PCCResidualsEncoder encoder;
const uint32_t alphabetSize = 64;
encoder.start(bitstream, alphabetSize);
const size_t pointCount = predictors.size(); const size_t pointCount = predictors.size();
for (size_t predictorIndex = 0; predictorIndex < pointCount; ++predictorIndex) { for (size_t predictorIndex = 0; predictorIndex < pointCount; ++predictorIndex) {
const auto &predictor = predictors[predictorIndex]; const auto &predictor = predictors[predictorIndex];
...@@ -229,10 +255,6 @@ int AttributeEncoder::encodeColors( ...@@ -229,10 +255,6 @@ int AttributeEncoder::encodeColors(
} }
pointCloud.setColor(predictor.index, reconstructedColor); pointCloud.setColor(predictor.index, reconstructedColor);
} }
uint32_t compressedBitstreamSize = encoder.stop();
bitstream.size += compressedBitstreamSize;
PCCWriteToBuffer<uint32_t>(compressedBitstreamSize, bitstream.buffer, startSize);
return 0;
} }
//============================================================================ //============================================================================
......
...@@ -45,6 +45,11 @@ ...@@ -45,6 +45,11 @@
namespace pcc { namespace pcc {
//============================================================================
// Opaque definitions (Internal detail)
struct PCCResidualsEncoder;
//============================================================================ //============================================================================
struct PCCAttributeEncodeParamaters { struct PCCAttributeEncodeParamaters {
...@@ -63,21 +68,37 @@ public: ...@@ -63,21 +68,37 @@ public:
const PCCAttributeEncodeParamaters &attributeParams, const PCCAttributeEncodeParamaters &attributeParams,
const PCCPointSet3 &pointCloud); const PCCPointSet3 &pointCloud);
// todo(df): return value is always 0 => should be void?
int encodeHeader( int encodeHeader(
const PCCAttributeEncodeParamaters &attributeParams, const PCCAttributeEncodeParamaters &attributeParams,
const std::string &attributeName, const std::string &attributeName,
PCCBitstream &bitstream) const; PCCBitstream &bitstream) const;
// todo(df): return value is always 0 => should be void?
int encodeReflectances( int encodeReflectances(
const PCCAttributeEncodeParamaters &reflectanceParams, const PCCAttributeEncodeParamaters &reflectanceParams,
PCCPointSet3 &pointCloud, PCCPointSet3 &pointCloud,
PCCBitstream &bitstream); PCCBitstream &bitstream);
// todo(df): return value is always 0 => should be void?
int encodeColors( int encodeColors(
const PCCAttributeEncodeParamaters &colorParams, const PCCAttributeEncodeParamaters &colorParams,
PCCPointSet3 &pointCloud, PCCPointSet3 &pointCloud,
PCCBitstream &bitstream); PCCBitstream &bitstream);
protected:
// todo(df): consider alternative encapsulation
void encodeReflectancesIntegerLift(
const PCCAttributeEncodeParamaters &reflectanceParams,
PCCPointSet3 &pointCloud,
PCCResidualsEncoder &encoder);
void encodeColorsIntegerLift(
const PCCAttributeEncodeParamaters &colorParams,
PCCPointSet3 &pointCloud,
PCCResidualsEncoder &encoder);
private: private:
std::vector<PCCPredictor> predictors; std::vector<PCCPredictor> predictors;
}; };
......
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