Commit 4a73572f authored by David Flynn's avatar David Flynn
Browse files

attr: refactor lod representation to be member of attribute codec

This commit relocates the LoD state into an AttributeLoDs class in
order to enable reusing the LoD data between multiple attributes
within the same slice.
parent f0eedcdb
/* The copyright in this software is being made available under the BSD
* Licence, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such
* rights are granted under this licence.
*
* Copyright (c) 2017-2019, ISO/IEC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the ISO/IEC nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "AttributeCommon.h"
#include "PCCTMC3Common.h"
namespace pcc {
//============================================================================
// AttributeLods methods
void
AttributeLods::generate(
const AttributeParameterSet& aps,
int minGeomNodeSizeLog2,
const PCCPointSet3& cloud)
{
if (minGeomNodeSizeLog2 > 0)
assert(aps.scalable_lifting_enabled_flag);
buildPredictorsFast(
aps, cloud, minGeomNodeSizeLog2, predictors, numPointsInLod, indexes);
assert(predictors.size() == cloud.getPointCount());
for (auto& predictor : predictors)
predictor.computeWeights();
}
//============================================================================
} // namespace pcc
/* The copyright in this software is being made available under the BSD
* Licence, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such
* rights are granted under this licence.
*
* Copyright (c) 2017-2019, ISO/IEC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the ISO/IEC nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <stdint.h>
#include <vector>
#include "hls.h"
#include "PCCTMC3Common.h"
namespace pcc {
//============================================================================
struct AttributeLods {
bool empty() const { return numPointsInLod.empty(); };
void generate(
const AttributeParameterSet& aps,
int minGeomNodeSizeLog2,
const PCCPointSet3& cloud);
std::vector<PCCPredictor> predictors;
std::vector<uint32_t> numPointsInLod;
std::vector<uint32_t> indexes;
};
//============================================================================
} // namespace pcc
......@@ -208,6 +208,15 @@ AttributeDecoder::decode(
PCCResidualsDecoder decoder;
decoder.start(sps, payload.data() + abhSize, payload.size() - abhSize);
// generate LoDs if necessary
switch (attr_aps.attr_encoding) {
case AttributeEncoding::kLiftingTransform:
case AttributeEncoding::kPredictingTransform:
if (_lods.empty())
_lods.generate(attr_aps, minGeomNodeSizeLog2, pointCloud);
default: break;
}
if (attr_desc.attr_num_dimensions == 1) {
switch (attr_aps.attr_encoding) {
case AttributeEncoding::kRAHTransform:
......@@ -259,7 +268,7 @@ AttributeDecoder::computeReflectancePredictionWeights(
PCCPredictor& predictor,
PCCResidualsDecoder& decoder)
{
predictor.computeWeights();
predictor.predMode = 0;
int64_t maxDiff = 0;
if (predictor.neighborCount > 1) {
......@@ -294,27 +303,20 @@ AttributeDecoder::decodeReflectancesPred(
PCCPointSet3& pointCloud)
{
const size_t pointCount = pointCloud.getPointCount();
std::vector<PCCPredictor> predictors;
std::vector<uint32_t> numberOfPointsPerLOD;
std::vector<uint32_t> indexesLOD;
buildPredictorsFast(
aps, pointCloud, 0, predictors, numberOfPointsPerLOD, indexesLOD);
const int64_t maxReflectance = (1ll << desc.attr_bitdepth) - 1;
int zero_cnt = decoder.decodeZeroCnt(pointCount);
int quantLayer = 0;
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
if (predictorIndex == numberOfPointsPerLOD[quantLayer]) {
if (predictorIndex == _lods.numPointsInLod[quantLayer]) {
quantLayer = std::min(int(qpSet.layers.size()) - 1, quantLayer + 1);
}
const uint32_t pointIndex = indexesLOD[predictorIndex];
const uint32_t pointIndex = _lods.indexes[predictorIndex];
auto quant = qpSet.quantizers(pointCloud[pointIndex], quantLayer);
auto& predictor = predictors[predictorIndex];
auto& predictor = _lods.predictors[predictorIndex];
computeReflectancePredictionWeights(
aps, pointCloud, indexesLOD, predictor, decoder);
aps, pointCloud, _lods.indexes, predictor, decoder);
attr_t& reflectance = pointCloud.getReflectance(pointIndex);
uint32_t attValue0 = 0;
if (zero_cnt > 0) {
......@@ -324,7 +326,7 @@ AttributeDecoder::decodeReflectancesPred(
zero_cnt = decoder.decodeZeroCnt(pointCount);
}
const int64_t quantPredAttValue =
predictor.predictReflectance(pointCloud, indexesLOD);
predictor.predictReflectance(pointCloud, _lods.indexes);
const int64_t delta = divExp2RoundHalfUp(
quant[0].scale(UIntToInt(attValue0)), kFixedPointAttributeShift);
const int64_t reconstructedQuantAttValue = quantPredAttValue + delta;
......@@ -343,7 +345,6 @@ AttributeDecoder::computeColorPredictionWeights(
PCCPredictor& predictor,
PCCResidualsDecoder& decoder)
{
predictor.computeWeights();
int64_t maxDiff = 0;
if (predictor.neighborCount > 1) {
......@@ -382,12 +383,6 @@ AttributeDecoder::decodeColorsPred(
PCCPointSet3& pointCloud)
{
const size_t pointCount = pointCloud.getPointCount();
std::vector<PCCPredictor> predictors;
std::vector<uint32_t> numberOfPointsPerLOD;
std::vector<uint32_t> indexesLOD;
buildPredictorsFast(
aps, pointCloud, 0, predictors, numberOfPointsPerLOD, indexesLOD);
Vec3<int64_t> clipMax{(1 << desc.attr_bitdepth) - 1,
(1 << desc.attr_bitdepth_secondary) - 1,
......@@ -398,15 +393,15 @@ AttributeDecoder::decodeColorsPred(
int quantLayer = 0;
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
if (predictorIndex == numberOfPointsPerLOD[quantLayer]) {
if (predictorIndex == _lods.numPointsInLod[quantLayer]) {
quantLayer = std::min(int(qpSet.layers.size()) - 1, quantLayer + 1);
}
const uint32_t pointIndex = indexesLOD[predictorIndex];
const uint32_t pointIndex = _lods.indexes[predictorIndex];
auto quant = qpSet.quantizers(pointCloud[pointIndex], quantLayer);
auto& predictor = predictors[predictorIndex];
auto& predictor = _lods.predictors[predictorIndex];
computeColorPredictionWeights(
aps, pointCloud, indexesLOD, predictor, decoder);
aps, pointCloud, _lods.indexes, predictor, decoder);
if (zero_cnt > 0) {
values[0] = values[1] = values[2] = 0;
zero_cnt--;
......@@ -416,7 +411,7 @@ AttributeDecoder::decodeColorsPred(
}
Vec3<attr_t>& color = pointCloud.getColor(pointIndex);
const Vec3<attr_t> predictedColor =
predictor.predictColor(pointCloud, indexesLOD);
predictor.predictColor(pointCloud, _lods.indexes);
int64_t residual0 = 0;
for (int k = 0; k < 3; ++k) {
......@@ -575,31 +570,17 @@ AttributeDecoder::decodeColorsLift(
PCCPointSet3& pointCloud)
{
const size_t pointCount = pointCloud.getPointCount();
std::vector<PCCPredictor> predictors;
std::vector<uint32_t> numberOfPointsPerLOD;
std::vector<uint32_t> indexesLOD;
if (minGeomNodeSizeLog2 > 0)
assert(aps.scalable_lifting_enabled_flag);
buildPredictorsFast(
aps, pointCloud, minGeomNodeSizeLog2, predictors, numberOfPointsPerLOD,
indexesLOD);
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
predictors[predictorIndex].computeWeights();
}
std::vector<uint64_t> weights;
if (!aps.scalable_lifting_enabled_flag) {
PCCComputeQuantizationWeights(predictors, weights);
PCCComputeQuantizationWeights(_lods.predictors, weights);
} else {
computeQuantizationWeightsScalable(
predictors, numberOfPointsPerLOD, geom_num_points, minGeomNodeSizeLog2,
weights);
_lods.predictors, _lods.numPointsInLod, geom_num_points,
minGeomNodeSizeLog2, weights);
}
const size_t lodCount = numberOfPointsPerLOD.size();
const size_t lodCount = _lods.numPointsInLod.size();
std::vector<Vec3<int64_t>> colors;
colors.resize(pointCount);
......@@ -614,10 +595,10 @@ AttributeDecoder::decodeColorsLift(
int quantLayer = 0;
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
if (predictorIndex == numberOfPointsPerLOD[quantLayer]) {
if (predictorIndex == _lods.numPointsInLod[quantLayer]) {
quantLayer = std::min(int(qpSet.layers.size()) - 1, quantLayer + 1);
}
const uint32_t pointIndex = indexesLOD[predictorIndex];
const uint32_t pointIndex = _lods.indexes[predictorIndex];
auto quant = qpSet.quantizers(pointCloud[pointIndex], quantLayer);
uint32_t values[3];
......@@ -644,10 +625,11 @@ AttributeDecoder::decodeColorsLift(
// reconstruct
for (size_t lodIndex = 1; lodIndex < lodCount; ++lodIndex) {
const size_t startIndex = numberOfPointsPerLOD[lodIndex - 1];
const size_t endIndex = numberOfPointsPerLOD[lodIndex];
PCCLiftUpdate(predictors, weights, startIndex, endIndex, false, colors);
PCCLiftPredict(predictors, startIndex, endIndex, false, colors);
const size_t startIndex = _lods.numPointsInLod[lodIndex - 1];
const size_t endIndex = _lods.numPointsInLod[lodIndex];
PCCLiftUpdate(
_lods.predictors, weights, startIndex, endIndex, false, colors);
PCCLiftPredict(_lods.predictors, startIndex, endIndex, false, colors);
}
Vec3<int64_t> clipMax{(1 << desc.attr_bitdepth) - 1,
......@@ -661,7 +643,7 @@ AttributeDecoder::decodeColorsLift(
for (size_t d = 0; d < 3; ++d) {
color[d] = attr_t(PCCClip(color0[d], int64_t(0), clipMax[d]));
}
pointCloud.setColor(indexesLOD[f], color);
pointCloud.setColor(_lods.indexes[f], color);
}
}
......@@ -678,32 +660,17 @@ AttributeDecoder::decodeReflectancesLift(
PCCPointSet3& pointCloud)
{
const size_t pointCount = pointCloud.getPointCount();
std::vector<PCCPredictor> predictors;
std::vector<uint32_t> numberOfPointsPerLOD;
std::vector<uint32_t> indexesLOD;
if (minGeomNodeSizeLog2 > 0)
assert(aps.scalable_lifting_enabled_flag);
buildPredictorsFast(
aps, pointCloud, minGeomNodeSizeLog2, predictors, numberOfPointsPerLOD,
indexesLOD);
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
predictors[predictorIndex].computeWeights();
}
std::vector<uint64_t> weights;
if (!aps.scalable_lifting_enabled_flag) {
PCCComputeQuantizationWeights(predictors, weights);
PCCComputeQuantizationWeights(_lods.predictors, weights);
} else {
computeQuantizationWeightsScalable(
predictors, numberOfPointsPerLOD, geom_num_points, minGeomNodeSizeLog2,
weights);
_lods.predictors, _lods.numPointsInLod, geom_num_points,
minGeomNodeSizeLog2, weights);
}
const size_t lodCount = numberOfPointsPerLOD.size();
const size_t lodCount = _lods.numPointsInLod.size();
std::vector<int64_t> reflectances;
reflectances.resize(pointCount);
......@@ -717,10 +684,10 @@ AttributeDecoder::decodeReflectancesLift(
int quantLayer = 0;
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
if (predictorIndex == numberOfPointsPerLOD[quantLayer]) {
if (predictorIndex == _lods.numPointsInLod[quantLayer]) {
quantLayer = std::min(int(qpSet.layers.size()) - 1, quantLayer + 1);
}
const uint32_t pointIndex = indexesLOD[predictorIndex];
const uint32_t pointIndex = _lods.indexes[predictorIndex];
auto quant = qpSet.quantizers(pointCloud[pointIndex], quantLayer);
int64_t detail = 0;
......@@ -739,18 +706,19 @@ AttributeDecoder::decodeReflectancesLift(
// reconstruct
for (size_t lodIndex = 1; lodIndex < lodCount; ++lodIndex) {
const size_t startIndex = numberOfPointsPerLOD[lodIndex - 1];
const size_t endIndex = numberOfPointsPerLOD[lodIndex];
const size_t startIndex = _lods.numPointsInLod[lodIndex - 1];
const size_t endIndex = _lods.numPointsInLod[lodIndex];
PCCLiftUpdate(
predictors, weights, startIndex, endIndex, false, reflectances);
PCCLiftPredict(predictors, startIndex, endIndex, false, reflectances);
_lods.predictors, weights, startIndex, endIndex, false, reflectances);
PCCLiftPredict(
_lods.predictors, startIndex, endIndex, false, reflectances);
}
const int64_t maxReflectance = (1 << desc.attr_bitdepth) - 1;
for (size_t f = 0; f < pointCount; ++f) {
const auto refl =
divExp2RoundHalfInf(reflectances[f], kFixedPointAttributeShift);
pointCloud.setReflectance(
indexesLOD[f], attr_t(PCCClip(refl, int64_t(0), maxReflectance)));
_lods.indexes[f], attr_t(PCCClip(refl, int64_t(0), maxReflectance)));
}
}
......
......@@ -38,6 +38,7 @@
#include <stdint.h>
#include "Attribute.h"
#include "AttributeCommon.h"
#include "PayloadBuffer.h"
#include "PCCTMC3Common.h"
#include "quantization.h"
......@@ -124,6 +125,9 @@ protected:
const std::vector<uint32_t>& indexes,
PCCPredictor& predictor,
PCCResidualsDecoder& decoder);
private:
AttributeLods _lods;
};
//============================================================================
......
......@@ -356,6 +356,15 @@ AttributeEncoder::encode(
PCCResidualsEncoder encoder;
encoder.start(sps, int(pointCloud.getPointCount()));
// generate LoDs if necessary
switch (attr_aps.attr_encoding) {
case AttributeEncoding::kLiftingTransform:
case AttributeEncoding::kPredictingTransform:
if (_lods.empty())
_lods.generate(attr_aps, 0, pointCloud);
default: break;
}
if (desc.attr_num_dimensions == 1) {
switch (attr_aps.attr_encoding) {
case AttributeEncoding::kRAHTransform:
......@@ -424,7 +433,7 @@ AttributeEncoder::computeReflectancePredictionWeights(
PCCResidualsEntropyEstimator& context,
const Quantizer& quant)
{
predictor.computeWeights();
predictor.predMode = 0;
predictor.maxDiff = 0;
if (predictor.neighborCount > 1) {
int64_t minValue = 0;
......@@ -490,13 +499,6 @@ AttributeEncoder::encodeReflectancesPred(
PCCResidualsEncoder& encoder)
{
const uint32_t pointCount = pointCloud.getPointCount();
std::vector<PCCPredictor> predictors;
std::vector<uint32_t> numberOfPointsPerLOD;
std::vector<uint32_t> indexesLOD;
buildPredictorsFast(
aps, pointCloud, 0, predictors, numberOfPointsPerLOD, indexesLOD);
const int64_t clipMax = (1ll << desc.attr_bitdepth) - 1;
PCCResidualsEntropyEstimator context;
int zero_cnt = 0;
......@@ -508,20 +510,20 @@ AttributeEncoder::encodeReflectancesPred(
int quantLayer = 0;
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
if (predictorIndex == numberOfPointsPerLOD[quantLayer]) {
if (predictorIndex == _lods.numPointsInLod[quantLayer]) {
quantLayer = std::min(int(qpSet.layers.size()) - 1, quantLayer + 1);
}
const uint32_t pointIndex = indexesLOD[predictorIndex];
const uint32_t pointIndex = _lods.indexes[predictorIndex];
auto quant = qpSet.quantizers(pointCloud[pointIndex], quantLayer);
auto& predictor = predictors[predictorIndex];
auto& predictor = _lods.predictors[predictorIndex];
computeReflectancePredictionWeights(
aps, pointCloud, indexesLOD, predictorIndex, predictor, encoder, context,
quant[0]);
aps, pointCloud, _lods.indexes, predictorIndex, predictor, encoder,
context, quant[0]);
const uint64_t reflectance = pointCloud.getReflectance(pointIndex);
const attr_t predictedReflectance =
predictor.predictReflectance(pointCloud, indexesLOD);
predictor.predictReflectance(pointCloud, _lods.indexes);
const int64_t quantAttValue = reflectance;
const int64_t quantPredAttValue = predictedReflectance;
const int64_t delta = quant[0].quantize(
......@@ -551,7 +553,7 @@ AttributeEncoder::encodeReflectancesPred(
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
auto& predictor = predictors[predictorIndex];
auto& predictor = _lods.predictors[predictorIndex];
if (predictor.maxDiff >= aps.adaptive_prediction_threshold) {
encoder.encodePredMode(
predictor.predMode, aps.max_num_direct_predictors);
......@@ -604,7 +606,6 @@ AttributeEncoder::computeColorPredictionWeights(
PCCResidualsEntropyEstimator& context,
const Quantizers& quant)
{
predictor.computeWeights();
predictor.maxDiff = 0;
if (predictor.neighborCount > 1) {
int64_t minValue[3] = {0, 0, 0};
......@@ -676,12 +677,6 @@ AttributeEncoder::encodeColorsPred(
PCCResidualsEncoder& encoder)
{
const size_t pointCount = pointCloud.getPointCount();
std::vector<PCCPredictor> predictors;
std::vector<uint32_t> numberOfPointsPerLOD;
std::vector<uint32_t> indexesLOD;
buildPredictorsFast(
aps, pointCloud, 0, predictors, numberOfPointsPerLOD, indexesLOD);
Vec3<int64_t> clipMax{(1 << desc.attr_bitdepth) - 1,
(1 << desc.attr_bitdepth_secondary) - 1,
......@@ -698,19 +693,19 @@ AttributeEncoder::encodeColorsPred(
int quantLayer = 0;
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
if (predictorIndex == numberOfPointsPerLOD[quantLayer]) {
if (predictorIndex == _lods.numPointsInLod[quantLayer]) {
quantLayer = std::min(int(qpSet.layers.size()) - 1, quantLayer + 1);
}
const auto pointIndex = indexesLOD[predictorIndex];
const auto pointIndex = _lods.indexes[predictorIndex];
auto quant = qpSet.quantizers(pointCloud[pointIndex], quantLayer);
auto& predictor = predictors[predictorIndex];
auto& predictor = _lods.predictors[predictorIndex];
computeColorPredictionWeights(
aps, pointCloud, indexesLOD, predictorIndex, predictor, encoder, context,
quant);
aps, pointCloud, _lods.indexes, predictorIndex, predictor, encoder,
context, quant);
const Vec3<attr_t> color = pointCloud.getColor(pointIndex);
const Vec3<attr_t> predictedColor =
predictor.predictColor(pointCloud, indexesLOD);
predictor.predictColor(pointCloud, _lods.indexes);
Vec3<attr_t> reconstructedColor;
int64_t residual0 = 0;
......@@ -757,7 +752,7 @@ AttributeEncoder::encodeColorsPred(
zero_cnt = zerorun[run_index++];
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
auto& predictor = predictors[predictorIndex];
auto& predictor = _lods.predictors[predictorIndex];
if (predictor.maxDiff >= aps.adaptive_prediction_threshold) {
encoder.encodePredMode(
predictor.predMode, aps.max_num_direct_predictors);
......@@ -934,30 +929,21 @@ AttributeEncoder::encodeColorsLift(
PCCResidualsEncoder& encoder)
{
const size_t pointCount = pointCloud.getPointCount();
std::vector<PCCPredictor> predictors;
std::vector<uint32_t> numberOfPointsPerLOD;
std::vector<uint32_t> indexesLOD;
buildPredictorsFast(
aps, pointCloud, 0, predictors, numberOfPointsPerLOD, indexesLOD);
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
predictors[predictorIndex].computeWeights();
}
std::vector<uint64_t> weights;
if (!aps.scalable_lifting_enabled_flag) {
PCCComputeQuantizationWeights(predictors, weights);
PCCComputeQuantizationWeights(_lods.predictors, weights);
} else {
computeQuantizationWeightsScalable(
predictors, numberOfPointsPerLOD, pointCount, 0, weights);
_lods.predictors, _lods.numPointsInLod, pointCount, 0, weights);
}
const size_t lodCount = numberOfPointsPerLOD.size();
const size_t lodCount = _lods.numPointsInLod.size();
std::vector<Vec3<int64_t>> colors;
colors.resize(pointCount);
for (size_t index = 0; index < pointCount; ++index) {
const auto& color = pointCloud.getColor(indexesLOD[index]);
const auto& color = pointCloud.getColor(_lods.indexes[index]);
for (size_t d = 0; d < 3; ++d) {
colors[index][d] = int32_t(color[d]) << kFixedPointAttributeShift;
}
......@@ -965,10 +951,11 @@ AttributeEncoder::encodeColorsLift(
for (size_t i = 0; (i + 1) < lodCount; ++i) {
const size_t lodIndex = lodCount - i - 1;
const size_t startIndex = numberOfPointsPerLOD[lodIndex - 1];
const size_t endIndex = numberOfPointsPerLOD[lodIndex];
PCCLiftPredict(predictors, startIndex, endIndex, true, colors);
PCCLiftUpdate(predictors, weights, startIndex, endIndex, true, colors);
const size_t startIndex = _lods.numPointsInLod[lodIndex - 1];
const size_t endIndex = _lods.numPointsInLod[lodIndex];
PCCLiftPredict(_lods.predictors, startIndex, endIndex, true, colors);
PCCLiftUpdate(
_lods.predictors, weights, startIndex, endIndex, true, colors);
}
// compress
......@@ -976,10 +963,10 @@ AttributeEncoder::encodeColorsLift(
int quantLayer = 0;
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
if (predictorIndex == numberOfPointsPerLOD[quantLayer]) {
if (predictorIndex == _lods.numPointsInLod[quantLayer]) {
quantLayer = std::min(int(qpSet.layers.size()) - 1, quantLayer + 1);
}
const auto pointIndex = indexesLOD[predictorIndex];
const auto pointIndex = _lods.indexes[predictorIndex];
auto quant = qpSet.quantizers(pointCloud[pointIndex], quantLayer);
const int64_t quantWeight = weights[predictorIndex];
......@@ -1011,10 +998,11 @@ AttributeEncoder::encodeColorsLift(
// reconstruct
for (size_t lodIndex = 1; lodIndex < lodCount; ++lodIndex) {