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,6 +127,11 @@ int AttributeDecoder::decodeHeader(
const std::string &attributeName,
PCCBitstream &bitstream
) {
uint8_t transType;
PCCReadFromBuffer<uint8_t>(bitstream.buffer, transType, bitstream.size);
transformType = TransformType(transType);
if (transformType == TransformType::kIntegerLift) {
uint8_t numberOfNearestNeighborsCount = 0;
PCCReadFromBuffer<uint8_t>(bitstream.buffer, numberOfNearestNeighborsCount, bitstream.size);
numberOfNearestNeighborsInPrediction = numberOfNearestNeighborsCount;
......@@ -148,14 +153,14 @@ int AttributeDecoder::decodeHeader(
PCCReadFromBuffer<uint32_t>(bitstream.buffer, qs, bitstream.size);
quantizationSteps[lodIndex] = qs;
}
}
uint8_t transType;
PCCReadFromBuffer<uint8_t>(bitstream.buffer, transType, bitstream.size);
transformType = TransformType(transType);
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;
}
......
......@@ -112,6 +112,10 @@ void AttributeEncoder::buildPredictors(
const PCCAttributeEncodeParamaters &attributeParams,
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> indexes;
PCCBuildPredictors(
......@@ -132,6 +136,10 @@ int AttributeEncoder::encodeHeader(
const std::string &attributeName,
PCCBitstream &bitstream
) const {
PCCWriteToBuffer<uint8_t>(
uint8_t(attributeParams.transformType), bitstream.buffer, bitstream.size);
if (attributeParams.transformType == TransformType::kIntegerLift) {
PCCWriteToBuffer<uint8_t>(
uint8_t(attributeParams.numberOfNearestNeighborsInPrediction),
bitstream.buffer, bitstream.size);
......@@ -148,10 +156,9 @@ int AttributeEncoder::encodeHeader(
const uint32_t qs = uint32_t(attributeParams.quantizationSteps[lodIndex]);
PCCWriteToBuffer<uint32_t>(qs, bitstream.buffer, bitstream.size);
}
}
PCCWriteToBuffer<uint8_t>(
uint8_t(attributeParams.transformType), bitstream.buffer, bitstream.size);
if (attributeParams.transformType == TransformType::kRAHT) {
PCCWriteToBuffer<uint8_t>(
uint8_t(attributeParams.depthRaht), bitstream.buffer, bitstream.size);
......@@ -162,6 +169,7 @@ int AttributeEncoder::encodeHeader(
PCCWriteToBuffer<uint32_t>(
uint32_t(attributeParams.quantizationStepRaht),
bitstream.buffer, bitstream.size);
}
return 0;
}
......
......@@ -249,10 +249,18 @@ bool ParseParameters(int argc, char *argv[], Parameters &params) {
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
// - validate that quantizationSteps, dist2
// of each attribute contain levelOfDetailCount elements.
for (const auto &attr : params.encodeParameters.attributeEncodeParameters) {
if (attr.second.transformType == TransformType::kIntegerLift) {
int lod = attr.second.levelOfDetailCount;
if (lod > 255) {
......@@ -273,6 +281,7 @@ bool ParseParameters(int argc, char *argv[], Parameters &params) {
<< PCCTMC3MaxPredictionNearestNeighborCount << "\n";
}
}
}
// check required arguments are specified
......@@ -326,10 +335,15 @@ bool ParseParameters(int argc, char *argv[], Parameters &params) {
cout << "\t " << attributeEncodeParameters.first << endl;
cout << "\t\t transformType "
<< attributeEncodeParameters.second.transformType << endl;
if (attributeEncodeParameters.second.transformType == TransformType::kRAHT) {
cout << "\t\t rahtQuantizationStep "
<< attributeEncodeParameters.second.quantizationStepRaht << endl;
cout << "\t\t rahtDepth "
<< attributeEncodeParameters.second.depthRaht << endl;
}
if (attributeEncodeParameters.second.transformType == TransformType::kIntegerLift) {
cout << "\t\t numberOfNearestNeighborsInPrediction "
<< attributeEncodeParameters.second.numberOfNearestNeighborsInPrediction << endl;
cout << "\t\t searchRange "
......@@ -347,6 +361,7 @@ bool ParseParameters(int argc, char *argv[], Parameters &params) {
}
cout << endl;
}
}
cout << endl;
} else {
cout << "\t roundOutputPositions " << params.roundOutputPositions << endl;
......
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