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

attr: don't specialise k=0 case in (de/en)codeColorsPred

This converts an unrolled loop (with special case for the initial
iteration) to the rolled up form in order to improve readability.
parent f38332a3
...@@ -399,20 +399,14 @@ AttributeDecoder::decodeColorsPred( ...@@ -399,20 +399,14 @@ AttributeDecoder::decodeColorsPred(
Vec3<uint8_t>& color = pointCloud.getColor(pointIndex); Vec3<uint8_t>& color = pointCloud.getColor(pointIndex);
const Vec3<uint8_t> predictedColor = const Vec3<uint8_t> predictedColor =
predictor.predictColor(pointCloud, indexesLOD); predictor.predictColor(pointCloud, indexesLOD);
const int64_t quantPredAttValue = predictedColor[0];
const int64_t delta = divExp2RoundHalfUp(
quant[0].scale(UIntToInt(values[0])), kFixedPointAttributeShift);
const int64_t reconstructedQuantAttValue = quantPredAttValue + delta;
int64_t clipMax = (1 << desc.attr_bitdepth) - 1; int64_t clipMax = (1 << desc.attr_bitdepth) - 1;
color[0] = for (int k = 0; k < 3; ++k) {
uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax)); const auto& q = quant[std::min(k, 1)];
for (size_t k = 1; k < 3; ++k) { const int64_t residual = divExp2RoundHalfUp(
const int64_t quantPredAttValue = predictedColor[k]; q.scale(UIntToInt(values[k])), kFixedPointAttributeShift);
const int64_t delta = divExp2RoundHalfUp( const int64_t recon = predictedColor[k] + residual;
quant[1].scale(UIntToInt(values[k])), kFixedPointAttributeShift); color[k] = uint8_t(PCCClip(recon, int64_t(0), clipMax));
const int64_t reconstructedQuantAttValue = quantPredAttValue + delta;
color[k] =
uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax));
} }
} }
} }
......
...@@ -695,30 +695,20 @@ AttributeEncoder::encodeColorsPred( ...@@ -695,30 +695,20 @@ AttributeEncoder::encodeColorsPred(
const Vec3<uint8_t> color = pointCloud.getColor(pointIndex); const Vec3<uint8_t> color = pointCloud.getColor(pointIndex);
const Vec3<uint8_t> predictedColor = const Vec3<uint8_t> predictedColor =
predictor.predictColor(pointCloud, indexesLOD); predictor.predictColor(pointCloud, indexesLOD);
const int64_t quantAttValue = color[0];
const int64_t quantPredAttValue = predictedColor[0];
const int64_t delta = quant[0].quantize(
(quantAttValue - quantPredAttValue) << kFixedPointAttributeShift);
const int64_t reconstructedDelta =
divExp2RoundHalfUp(quant[0].scale(delta), kFixedPointAttributeShift);
const int64_t reconstructedQuantAttValue =
quantPredAttValue + reconstructedDelta;
values[0] = uint32_t(IntToUInt(long(delta)));
Vec3<uint8_t> reconstructedColor; Vec3<uint8_t> reconstructedColor;
reconstructedColor[0] = for (int k = 0; k < 3; ++k) {
uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax)); const auto& q = quant[std::min(k, 1)];
for (size_t k = 1; k < 3; ++k) { int64_t residual = color[k] - predictedColor[k];
const int64_t quantAttValue = color[k];
const int64_t quantPredAttValue = predictedColor[k]; int64_t residualQ = q.quantize(residual << kFixedPointAttributeShift);
const int64_t delta = quant[1].quantize( int64_t residualR =
(quantAttValue - quantPredAttValue) << kFixedPointAttributeShift); divExp2RoundHalfUp(q.scale(residualQ), kFixedPointAttributeShift);
const int64_t reconstructedDelta =
divExp2RoundHalfUp(quant[1].scale(delta), kFixedPointAttributeShift); values[k] = uint32_t(IntToUInt(long(residualQ)));
const int64_t reconstructedQuantAttValue =
quantPredAttValue + reconstructedDelta; int64_t recon = predictedColor[k] + residualR;
values[k] = uint32_t(IntToUInt(long(delta))); reconstructedColor[k] = uint8_t(PCCClip(recon, int64_t(0), clipMax));
reconstructedColor[k] =
uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax));
} }
pointCloud.setColor(pointIndex, reconstructedColor); pointCloud.setColor(pointIndex, reconstructedColor);
......
Markdown is supported
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