Commit 995703d8 authored by David Flynn's avatar David Flynn
Browse files

attr: signal header elements based on transformType

Rather than coding all syntax elements for both transform types
irrespective of the in-use type, this commit codes only those that
are necessary for a given transform type.
parent 34da2afb
...@@ -127,35 +127,40 @@ int AttributeDecoder::decodeHeader( ...@@ -127,35 +127,40 @@ int AttributeDecoder::decodeHeader(
const std::string &attributeName, const std::string &attributeName,
PCCBitstream &bitstream PCCBitstream &bitstream
) { ) {
uint8_t numberOfNearestNeighborsCount = 0;
PCCReadFromBuffer<uint8_t>(bitstream.buffer, numberOfNearestNeighborsCount, bitstream.size);
numberOfNearestNeighborsInPrediction = numberOfNearestNeighborsCount;
uint8_t lodCount = 0;
PCCReadFromBuffer<uint8_t>(bitstream.buffer, lodCount, bitstream.size);
levelOfDetailCount = lodCount;
dist2.resize(levelOfDetailCount);
for (size_t lodIndex = 0; lodIndex < levelOfDetailCount; ++lodIndex) {
uint32_t d2 = 0;
PCCReadFromBuffer<uint32_t>(bitstream.buffer, d2, bitstream.size);
dist2[lodIndex] = d2;
}
quantizationSteps.resize(levelOfDetailCount);
for (size_t lodIndex = 0; lodIndex < levelOfDetailCount; ++lodIndex) {
uint32_t qs = 0;
PCCReadFromBuffer<uint32_t>(bitstream.buffer, qs, bitstream.size);
quantizationSteps[lodIndex] = qs;
}
uint8_t transType; uint8_t transType;
PCCReadFromBuffer<uint8_t>(bitstream.buffer, transType, bitstream.size); PCCReadFromBuffer<uint8_t>(bitstream.buffer, transType, bitstream.size);
transformType = TransformType(transType); transformType = TransformType(transType);
PCCReadFromBuffer<uint8_t>(bitstream.buffer, depthRaht, bitstream.size); if (transformType == TransformType::kIntegerLift) {
PCCReadFromBuffer<uint8_t>(bitstream.buffer, binaryLevelThresholdRaht, bitstream.size); uint8_t numberOfNearestNeighborsCount = 0;
PCCReadFromBuffer<uint32_t>(bitstream.buffer, quantizationStepRaht, bitstream.size); PCCReadFromBuffer<uint8_t>(bitstream.buffer, numberOfNearestNeighborsCount, bitstream.size);
numberOfNearestNeighborsInPrediction = numberOfNearestNeighborsCount;
uint8_t lodCount = 0;
PCCReadFromBuffer<uint8_t>(bitstream.buffer, lodCount, bitstream.size);
levelOfDetailCount = lodCount;
dist2.resize(levelOfDetailCount);
for (size_t lodIndex = 0; lodIndex < levelOfDetailCount; ++lodIndex) {
uint32_t d2 = 0;
PCCReadFromBuffer<uint32_t>(bitstream.buffer, d2, bitstream.size);
dist2[lodIndex] = d2;
}
quantizationSteps.resize(levelOfDetailCount);
for (size_t lodIndex = 0; lodIndex < levelOfDetailCount; ++lodIndex) {
uint32_t qs = 0;
PCCReadFromBuffer<uint32_t>(bitstream.buffer, qs, bitstream.size);
quantizationSteps[lodIndex] = qs;
}
}
if (transformType == TransformType::kRAHT) {
PCCReadFromBuffer<uint8_t>(bitstream.buffer, depthRaht, bitstream.size);
PCCReadFromBuffer<uint8_t>(bitstream.buffer, binaryLevelThresholdRaht, bitstream.size);
PCCReadFromBuffer<uint32_t>(bitstream.buffer, quantizationStepRaht, bitstream.size);
}
return 0; return 0;
} }
......
...@@ -112,6 +112,10 @@ void AttributeEncoder::buildPredictors( ...@@ -112,6 +112,10 @@ void AttributeEncoder::buildPredictors(
const PCCAttributeEncodeParamaters &attributeParams, const PCCAttributeEncodeParamaters &attributeParams,
const PCCPointSet3 &pointCloud const PCCPointSet3 &pointCloud
) { ) {
// NB: predictors are only used by the TMC3 integer lifting scheme
if (attributeParams.transformType != TransformType::kIntegerLift)
return;
std::vector<uint32_t> numberOfPointsPerLOD; std::vector<uint32_t> numberOfPointsPerLOD;
std::vector<uint32_t> indexes; std::vector<uint32_t> indexes;
PCCBuildPredictors( PCCBuildPredictors(
...@@ -133,35 +137,39 @@ int AttributeEncoder::encodeHeader( ...@@ -133,35 +137,39 @@ int AttributeEncoder::encodeHeader(
PCCBitstream &bitstream PCCBitstream &bitstream
) const { ) const {
PCCWriteToBuffer<uint8_t>( PCCWriteToBuffer<uint8_t>(
uint8_t(attributeParams.numberOfNearestNeighborsInPrediction), uint8_t(attributeParams.transformType), bitstream.buffer, bitstream.size);
bitstream.buffer, bitstream.size);
PCCWriteToBuffer<uint8_t>( if (attributeParams.transformType == TransformType::kIntegerLift) {
uint8_t(attributeParams.levelOfDetailCount), PCCWriteToBuffer<uint8_t>(
bitstream.buffer, bitstream.size); uint8_t(attributeParams.numberOfNearestNeighborsInPrediction),
bitstream.buffer, bitstream.size);
for (size_t lodIndex = 0; lodIndex < attributeParams.levelOfDetailCount; ++lodIndex) { PCCWriteToBuffer<uint8_t>(
const uint32_t d2 = uint32_t(attributeParams.dist2[lodIndex]); uint8_t(attributeParams.levelOfDetailCount),
PCCWriteToBuffer<uint32_t>(d2, bitstream.buffer, bitstream.size); bitstream.buffer, bitstream.size);
}
for (size_t lodIndex = 0; lodIndex < attributeParams.levelOfDetailCount; ++lodIndex) {
const uint32_t qs = uint32_t(attributeParams.quantizationSteps[lodIndex]);
PCCWriteToBuffer<uint32_t>(qs, bitstream.buffer, bitstream.size);
}
PCCWriteToBuffer<uint8_t>( for (size_t lodIndex = 0; lodIndex < attributeParams.levelOfDetailCount; ++lodIndex) {
uint8_t(attributeParams.transformType), bitstream.buffer, bitstream.size); const uint32_t d2 = uint32_t(attributeParams.dist2[lodIndex]);
PCCWriteToBuffer<uint32_t>(d2, bitstream.buffer, bitstream.size);
}
for (size_t lodIndex = 0; lodIndex < attributeParams.levelOfDetailCount; ++lodIndex) {
const uint32_t qs = uint32_t(attributeParams.quantizationSteps[lodIndex]);
PCCWriteToBuffer<uint32_t>(qs, bitstream.buffer, bitstream.size);
}
}
PCCWriteToBuffer<uint8_t>( if (attributeParams.transformType == TransformType::kRAHT) {
uint8_t(attributeParams.depthRaht), bitstream.buffer, bitstream.size); PCCWriteToBuffer<uint8_t>(
uint8_t(attributeParams.depthRaht), bitstream.buffer, bitstream.size);
PCCWriteToBuffer<uint8_t>( PCCWriteToBuffer<uint8_t>(
uint8_t(attributeParams.binaryLevelThresholdRaht), uint8_t(attributeParams.binaryLevelThresholdRaht),
bitstream.buffer, bitstream.size); bitstream.buffer, bitstream.size);
PCCWriteToBuffer<uint32_t>( PCCWriteToBuffer<uint32_t>(
uint32_t(attributeParams.quantizationStepRaht), uint32_t(attributeParams.quantizationStepRaht),
bitstream.buffer, bitstream.size); bitstream.buffer, bitstream.size);
}
return 0; return 0;
} }
......
...@@ -249,28 +249,37 @@ bool ParseParameters(int argc, char *argv[], Parameters &params) { ...@@ -249,28 +249,37 @@ bool ParseParameters(int argc, char *argv[], Parameters &params) {
return false; return false;
} }
// For RAHT, ensure that the unused lod count = 0 (prevents mishaps)
for (auto &attr : params.encodeParameters.attributeEncodeParameters) {
if (attr.second.transformType != TransformType::kIntegerLift) {
attr.second.levelOfDetailCount = 0;
}
}
// sanity checks // sanity checks
// - validate that quantizationSteps, dist2 // - validate that quantizationSteps, dist2
// of each attribute contain levelOfDetailCount elements. // of each attribute contain levelOfDetailCount elements.
for (const auto &attr : params.encodeParameters.attributeEncodeParameters) { for (const auto &attr : params.encodeParameters.attributeEncodeParameters) {
int lod = attr.second.levelOfDetailCount; if (attr.second.transformType == TransformType::kIntegerLift) {
int lod = attr.second.levelOfDetailCount;
if (lod > 255) { if (lod > 255) {
err.error() << attr.first err.error() << attr.first
<< ".levelOfDetailCount must be less than 256\n"; << ".levelOfDetailCount must be less than 256\n";
} }
if (attr.second.dist2.size() != lod) { if (attr.second.dist2.size() != lod) {
err.error() << attr.first << ".dist2 does not have " << lod << " entries\n"; err.error() << attr.first << ".dist2 does not have " << lod << " entries\n";
} }
if (attr.second.quantizationSteps.size() != lod) { if (attr.second.quantizationSteps.size() != lod) {
err.error() << attr.first << ".quantizationSteps does not have " << lod << " entries\n"; err.error() << attr.first << ".quantizationSteps does not have " << lod << " entries\n";
} }
if (attr.second.numberOfNearestNeighborsInPrediction > if (attr.second.numberOfNearestNeighborsInPrediction >
PCCTMC3MaxPredictionNearestNeighborCount) PCCTMC3MaxPredictionNearestNeighborCount)
{ {
err.error() << attr.first err.error() << attr.first
<< ".numberOfNearestNeighborsInPrediction must be less than " << ".numberOfNearestNeighborsInPrediction must be less than "
<< PCCTMC3MaxPredictionNearestNeighborCount << "\n"; << PCCTMC3MaxPredictionNearestNeighborCount << "\n";
}
} }
} }
...@@ -326,26 +335,32 @@ bool ParseParameters(int argc, char *argv[], Parameters &params) { ...@@ -326,26 +335,32 @@ bool ParseParameters(int argc, char *argv[], Parameters &params) {
cout << "\t " << attributeEncodeParameters.first << endl; cout << "\t " << attributeEncodeParameters.first << endl;
cout << "\t\t transformType " cout << "\t\t transformType "
<< attributeEncodeParameters.second.transformType << endl; << attributeEncodeParameters.second.transformType << endl;
cout << "\t\t rahtQuantizationStep "
<< attributeEncodeParameters.second.quantizationStepRaht << endl; if (attributeEncodeParameters.second.transformType == TransformType::kRAHT) {
cout << "\t\t rahtDepth " cout << "\t\t rahtQuantizationStep "
<< attributeEncodeParameters.second.depthRaht << endl; << attributeEncodeParameters.second.quantizationStepRaht << endl;
cout << "\t\t numberOfNearestNeighborsInPrediction " cout << "\t\t rahtDepth "
<< attributeEncodeParameters.second.numberOfNearestNeighborsInPrediction << endl; << attributeEncodeParameters.second.depthRaht << endl;
cout << "\t\t searchRange "
<< attributeEncodeParameters.second.searchRange << endl;
cout << "\t\t levelOfDetailCount "
<< attributeEncodeParameters.second.levelOfDetailCount << endl;
cout << "\t\t dist2 ";
for (const auto qs : attributeEncodeParameters.second.dist2) {
cout << qs << " ";
} }
cout << endl;
cout << "\t\t quantizationSteps "; if (attributeEncodeParameters.second.transformType == TransformType::kIntegerLift) {
for (const auto qs : attributeEncodeParameters.second.quantizationSteps) { cout << "\t\t numberOfNearestNeighborsInPrediction "
cout << qs << " "; << attributeEncodeParameters.second.numberOfNearestNeighborsInPrediction << endl;
cout << "\t\t searchRange "
<< attributeEncodeParameters.second.searchRange << endl;
cout << "\t\t levelOfDetailCount "
<< attributeEncodeParameters.second.levelOfDetailCount << endl;
cout << "\t\t dist2 ";
for (const auto qs : attributeEncodeParameters.second.dist2) {
cout << qs << " ";
}
cout << endl;
cout << "\t\t quantizationSteps ";
for (const auto qs : attributeEncodeParameters.second.quantizationSteps) {
cout << qs << " ";
}
cout << endl;
} }
cout << endl;
} }
cout << endl; cout << endl;
} else { } else {
......
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