Commit a3bc1ac4 authored by David Flynn's avatar David Flynn
Browse files

entropy: arithmetic codec wrapper to allow compile time selection

This commit adds an arithmetic codec interface class that allows a
compile time choice of arithmetic codec implementation.  Context types
are renamed to support compile time selection, and existing support
functions that were added to the third-party arithmetic codec are
moved to the wrapper.
parent 89fae502
...@@ -76,14 +76,6 @@ OF SUCH DAMAGE. ...@@ -76,14 +76,6 @@ OF SUCH DAMAGE.
namespace o3dgc { namespace o3dgc {
inline unsigned long IntToUInt(long value)
{
return (value < 0) ? static_cast<unsigned long>(-1 - (2 * value)) : static_cast<unsigned long>(2 * value);
}
inline long UIntToInt(unsigned long uiValue)
{
return (uiValue & 1) ? -(static_cast<long>((uiValue + 1) >> 1)) : (static_cast<long>(uiValue >> 1));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - Class definitions - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - Class definitions - - - - - - - - - - - - - - - - - - - - - - - - - - -
class Static_Bit_Model // static model for binary data class Static_Bit_Model // static model for binary data
...@@ -229,49 +221,7 @@ public: ...@@ -229,49 +221,7 @@ public:
Adaptive_Data_Model&); Adaptive_Data_Model&);
unsigned decode(Adaptive_Data_Model&); unsigned decode(Adaptive_Data_Model&);
// This section was added by K. Mammou
void ExpGolombEncode(unsigned int symbol,
int k,
Static_Bit_Model& bModel0,
Adaptive_Bit_Model& bModel1)
{
while (1) {
if (symbol >= static_cast<unsigned int>(1 << k)) {
encode(1, bModel1);
symbol = symbol - (1 << k);
k++;
}
else {
encode(0, bModel1); // now terminated zero of unary part
while (k--) // next binary part
{
encode(static_cast<signed short>((symbol >> k) & 1), bModel0);
}
break;
}
}
}
unsigned ExpGolombDecode(int k,
Static_Bit_Model& bModel0,
Adaptive_Bit_Model& bModel1)
{
unsigned int l;
int symbol = 0;
int binary_symbol = 0;
do {
l = decode(bModel1);
if (l == 1) {
symbol += (1 << k);
k++;
}
} while (l != 0);
while (k--) //next binary part
if (decode(bModel0) == 1) {
binary_symbol |= (1 << k);
}
return static_cast<unsigned int>(symbol + binary_symbol);
}
//---------------------------------------------------------- //----------------------------------------------------------
private: // . . . . . . . . . . . . . . . . . . . . . . private: // . . . . . . . . . . . . . . . . . . . . . .
...@@ -282,65 +232,7 @@ private: // . . . . . . . . . . . . . . . . . . . . . . ...@@ -282,65 +232,7 @@ private: // . . . . . . . . . . . . . . . . . . . . . .
unsigned base, value, length; // arithmetic coding state unsigned base, value, length; // arithmetic coding state
unsigned buffer_size, mode; // mode: 0 = undef, 1 = encoder, 2 = decoder unsigned buffer_size, mode; // mode: 0 = undef, 1 = encoder, 2 = decoder
}; };
inline long DecodeIntACEGC(Arithmetic_Codec& acd,
Adaptive_Data_Model& mModelValues,
Static_Bit_Model& bModel0,
Adaptive_Bit_Model& bModel1,
const unsigned long exp_k,
const unsigned long M)
{
unsigned long uiValue = acd.decode(mModelValues);
if (uiValue == M) {
uiValue += acd.ExpGolombDecode(exp_k, bModel0, bModel1);
}
return UIntToInt(uiValue);
}
inline unsigned long DecodeUIntACEGC(Arithmetic_Codec& acd,
Adaptive_Data_Model& mModelValues,
Static_Bit_Model& bModel0,
Adaptive_Bit_Model& bModel1,
const unsigned long exp_k,
const unsigned long M)
{
unsigned long uiValue = acd.decode(mModelValues);
if (uiValue == M) {
uiValue += acd.ExpGolombDecode(exp_k, bModel0, bModel1);
}
return uiValue;
}
inline void EncodeIntACEGC(long predResidual,
Arithmetic_Codec& ace,
Adaptive_Data_Model& mModelValues,
Static_Bit_Model& bModel0,
Adaptive_Bit_Model& bModel1,
const unsigned long M)
{
unsigned long uiValue = IntToUInt(predResidual);
if (uiValue < M) {
ace.encode(uiValue, mModelValues);
}
else {
ace.encode(M, mModelValues);
ace.ExpGolombEncode(uiValue - M, 0, bModel0, bModel1);
}
}
inline void EncodeUIntACEGC(long predResidual,
Arithmetic_Codec& ace,
Adaptive_Data_Model& mModelValues,
Static_Bit_Model& bModel0,
Adaptive_Bit_Model& bModel1,
const unsigned long M)
{
unsigned long uiValue = static_cast<unsigned long>(predResidual);
if (uiValue < M) {
ace.encode(uiValue, mModelValues);
}
else {
ace.encode(M, mModelValues);
ace.ExpGolombEncode(uiValue - M, 0, bModel0, bModel1);
}
}
} }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#endif #endif
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "DualLutCoder.h" #include "DualLutCoder.h"
#include "constants.h" #include "constants.h"
#include "entropy.h"
#include "io_hls.h" #include "io_hls.h"
#include "RAHT.h" #include "RAHT.h"
...@@ -46,11 +47,11 @@ namespace pcc { ...@@ -46,11 +47,11 @@ namespace pcc {
// An encapsulation of the entropy decoding methods used in attribute coding // An encapsulation of the entropy decoding methods used in attribute coding
struct PCCResidualsDecoder { struct PCCResidualsDecoder {
o3dgc::Arithmetic_Codec arithmeticDecoder; EntropyDecoder arithmeticDecoder;
o3dgc::Static_Bit_Model binaryModel0; StaticBitModel binaryModel0;
o3dgc::Adaptive_Bit_Model binaryModelPred; AdaptiveBitModel binaryModelPred;
o3dgc::Adaptive_Bit_Model binaryModelDiff[7]; AdaptiveBitModel binaryModelDiff[7];
o3dgc::Adaptive_Bit_Model binaryModelIsZero[7]; AdaptiveBitModel binaryModelIsZero[7];
DualLutCoder<false> symbolCoder[2]; DualLutCoder<false> symbolCoder[2];
void start(const char* buf, int buf_len); void start(const char* buf, int buf_len);
...@@ -66,10 +67,8 @@ struct PCCResidualsDecoder { ...@@ -66,10 +67,8 @@ struct PCCResidualsDecoder {
void void
PCCResidualsDecoder::start(const char* buf, int buf_len) PCCResidualsDecoder::start(const char* buf, int buf_len)
{ {
arithmeticDecoder.set_buffer( arithmeticDecoder.setBuffer(buf_len, buf);
buf_len, reinterpret_cast<uint8_t*>(const_cast<char*>(buf))); arithmeticDecoder.start();
arithmeticDecoder.start_decoder();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -77,7 +76,7 @@ PCCResidualsDecoder::start(const char* buf, int buf_len) ...@@ -77,7 +76,7 @@ PCCResidualsDecoder::start(const char* buf, int buf_len)
void void
PCCResidualsDecoder::stop() PCCResidualsDecoder::stop()
{ {
arithmeticDecoder.stop_decoder(); arithmeticDecoder.stop();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -100,7 +99,7 @@ PCCResidualsDecoder::decodeSymbol(int k1, int k2) ...@@ -100,7 +99,7 @@ PCCResidualsDecoder::decodeSymbol(int k1, int k2)
uint32_t value = symbolCoder[k2].decode(&arithmeticDecoder); uint32_t value = symbolCoder[k2].decode(&arithmeticDecoder);
if (value == kAttributeResidualAlphabetSize) { if (value == kAttributeResidualAlphabetSize) {
value += value +=
arithmeticDecoder.ExpGolombDecode(0, binaryModel0, binaryModelDiff[k1]); arithmeticDecoder.decodeExpGolomb(0, binaryModel0, binaryModelDiff[k1]);
} }
++value; ++value;
...@@ -243,8 +242,7 @@ AttributeDecoder::decodeReflectancesPred( ...@@ -243,8 +242,7 @@ AttributeDecoder::decodeReflectancesPred(
const uint32_t attValue0 = decoder.decode(); const uint32_t attValue0 = decoder.decode();
const int64_t quantPredAttValue = predictor.predictReflectance(pointCloud); const int64_t quantPredAttValue = predictor.predictReflectance(pointCloud);
const int64_t delta = const int64_t delta = PCCInverseQuantization(UIntToInt(attValue0), qs);
PCCInverseQuantization(o3dgc::UIntToInt(attValue0), qs);
const int64_t reconstructedQuantAttValue = quantPredAttValue + delta; const int64_t reconstructedQuantAttValue = quantPredAttValue + delta;
reflectance = uint16_t( reflectance = uint16_t(
PCCClip(reconstructedQuantAttValue, int64_t(0), maxReflectance)); PCCClip(reconstructedQuantAttValue, int64_t(0), maxReflectance));
...@@ -319,8 +317,7 @@ AttributeDecoder::decodeColorsPred( ...@@ -319,8 +317,7 @@ AttributeDecoder::decodeColorsPred(
PCCColor3B& color = pointCloud.getColor(predictor.index); PCCColor3B& color = pointCloud.getColor(predictor.index);
const PCCColor3B predictedColor = predictor.predictColor(pointCloud); const PCCColor3B predictedColor = predictor.predictColor(pointCloud);
const int64_t quantPredAttValue = predictedColor[0]; const int64_t quantPredAttValue = predictedColor[0];
const int64_t delta = const int64_t delta = PCCInverseQuantization(UIntToInt(values[0]), qs);
PCCInverseQuantization(o3dgc::UIntToInt(values[0]), qs);
const int64_t reconstructedQuantAttValue = quantPredAttValue + delta; const int64_t reconstructedQuantAttValue = quantPredAttValue + delta;
int64_t clipMax = (1 << desc.attr_bitdepth) - 1; int64_t clipMax = (1 << desc.attr_bitdepth) - 1;
...@@ -328,8 +325,7 @@ AttributeDecoder::decodeColorsPred( ...@@ -328,8 +325,7 @@ AttributeDecoder::decodeColorsPred(
uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax)); uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax));
for (size_t k = 1; k < 3; ++k) { for (size_t k = 1; k < 3; ++k) {
const int64_t quantPredAttValue = predictedColor[k]; const int64_t quantPredAttValue = predictedColor[k];
const int64_t delta = const int64_t delta = PCCInverseQuantization(UIntToInt(values[k]), qs2);
PCCInverseQuantization(o3dgc::UIntToInt(values[k]), qs2);
const int64_t reconstructedQuantAttValue = quantPredAttValue + delta; const int64_t reconstructedQuantAttValue = quantPredAttValue + delta;
color[k] = color[k] =
uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax)); uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax));
...@@ -388,7 +384,7 @@ AttributeDecoder::decodeReflectancesRaht( ...@@ -388,7 +384,7 @@ AttributeDecoder::decodeReflectancesRaht(
int* sortedIntegerizedAttributes = new int[voxelCount]; int* sortedIntegerizedAttributes = new int[voxelCount];
for (int n = 0; n < voxelCount; ++n) { for (int n = 0; n < voxelCount; ++n) {
const uint32_t attValue0 = decoder.decode(); const uint32_t attValue0 = decoder.decode();
sortedIntegerizedAttributes[n] = o3dgc::UIntToInt(attValue0); sortedIntegerizedAttributes[n] = UIntToInt(attValue0);
} }
// Unsort integerized attributes by weight. // Unsort integerized attributes by weight.
...@@ -479,14 +475,13 @@ AttributeDecoder::decodeColorsRaht( ...@@ -479,14 +475,13 @@ AttributeDecoder::decodeColorsRaht(
if ( if (
binaryLayer[sortedWeight[n].index] >= aps.raht_binary_level_threshold) { binaryLayer[sortedWeight[n].index] >= aps.raht_binary_level_threshold) {
decoder.decode(values); decoder.decode(values);
sortedIntegerizedAttributes[n] = o3dgc::UIntToInt(values[0]); sortedIntegerizedAttributes[n] = UIntToInt(values[0]);
for (int d = 1; d < 3; ++d) { for (int d = 1; d < 3; ++d) {
sortedIntegerizedAttributes[voxelCount * d + n] = sortedIntegerizedAttributes[voxelCount * d + n] = UIntToInt(values[d]);
o3dgc::UIntToInt(values[d]);
} }
} else { } else {
values[0] = decoder.decode(); values[0] = decoder.decode();
sortedIntegerizedAttributes[n] = o3dgc::UIntToInt(values[0]); sortedIntegerizedAttributes[n] = UIntToInt(values[0]);
for (int d = 1; d < 3; d++) { for (int d = 1; d < 3; d++) {
sortedIntegerizedAttributes[voxelCount * d + n] = 0; sortedIntegerizedAttributes[voxelCount * d + n] = 0;
} }
...@@ -573,11 +568,11 @@ AttributeDecoder::decodeColorsLift( ...@@ -573,11 +568,11 @@ AttributeDecoder::decodeColorsLift(
const int64_t qs2 = aps.quant_step_size_chroma; const int64_t qs2 = aps.quant_step_size_chroma;
const double quantWeight = sqrt(weights[predictorIndex]); const double quantWeight = sqrt(weights[predictorIndex]);
auto& color = colors[predictorIndex]; auto& color = colors[predictorIndex];
const int64_t delta = o3dgc::UIntToInt(values[0]); const int64_t delta = UIntToInt(values[0]);
const double reconstructedDelta = PCCInverseQuantization(delta, qs); const double reconstructedDelta = PCCInverseQuantization(delta, qs);
color[0] = reconstructedDelta / quantWeight; color[0] = reconstructedDelta / quantWeight;
for (size_t d = 1; d < 3; ++d) { for (size_t d = 1; d < 3; ++d) {
const int64_t delta = o3dgc::UIntToInt(values[d]); const int64_t delta = UIntToInt(values[d]);
const double reconstructedDelta = PCCInverseQuantization(delta, qs2); const double reconstructedDelta = PCCInverseQuantization(delta, qs2);
color[d] = reconstructedDelta / quantWeight; color[d] = reconstructedDelta / quantWeight;
} }
...@@ -638,7 +633,7 @@ AttributeDecoder::decodeReflectancesLift( ...@@ -638,7 +633,7 @@ AttributeDecoder::decodeReflectancesLift(
const int64_t qs = aps.quant_step_size_luma; const int64_t qs = aps.quant_step_size_luma;
const double quantWeight = sqrt(weights[predictorIndex]); const double quantWeight = sqrt(weights[predictorIndex]);
auto& reflectance = reflectances[predictorIndex]; auto& reflectance = reflectances[predictorIndex];
const int64_t delta = o3dgc::UIntToInt(detail); const int64_t delta = UIntToInt(detail);
const double reconstructedDelta = PCCInverseQuantization(delta, qs); const double reconstructedDelta = PCCInverseQuantization(delta, qs);
reflectance = reconstructedDelta / quantWeight; reflectance = reconstructedDelta / quantWeight;
} }
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "ArithmeticCodec.h" #include "ArithmeticCodec.h"
#include "DualLutCoder.h" #include "DualLutCoder.h"
#include "constants.h" #include "constants.h"
#include "entropy.h"
#include "RAHT.h" #include "RAHT.h"
namespace pcc { namespace pcc {
...@@ -45,11 +46,11 @@ namespace pcc { ...@@ -45,11 +46,11 @@ namespace pcc {
// An encapsulation of the entropy coding methods used in attribute coding // An encapsulation of the entropy coding methods used in attribute coding
struct PCCResidualsEncoder { struct PCCResidualsEncoder {
o3dgc::Arithmetic_Codec arithmeticEncoder; EntropyEncoder arithmeticEncoder;
o3dgc::Static_Bit_Model binaryModel0; StaticBitModel binaryModel0;
o3dgc::Adaptive_Bit_Model binaryModelPred; AdaptiveBitModel binaryModelPred;
o3dgc::Adaptive_Bit_Model binaryModelDiff[7]; AdaptiveBitModel binaryModelDiff[7];
o3dgc::Adaptive_Bit_Model binaryModelIsZero[7]; AdaptiveBitModel binaryModelIsZero[7];
DualLutCoder<false> symbolCoder[2]; DualLutCoder<false> symbolCoder[2];
void start(int numPoints); void start(int numPoints);
...@@ -67,8 +68,8 @@ PCCResidualsEncoder::start(int pointCount) ...@@ -67,8 +68,8 @@ PCCResidualsEncoder::start(int pointCount)
{ {
// todo(df): remove estimate when arithmetic codec is replaced // todo(df): remove estimate when arithmetic codec is replaced
int maxAcBufLen = pointCount * 3 * 2 + 1024; int maxAcBufLen = pointCount * 3 * 2 + 1024;
arithmeticEncoder.set_buffer(maxAcBufLen, nullptr); arithmeticEncoder.setBuffer(maxAcBufLen, nullptr);
arithmeticEncoder.start_encoder(); arithmeticEncoder.start();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -76,7 +77,7 @@ PCCResidualsEncoder::start(int pointCount) ...@@ -76,7 +77,7 @@ PCCResidualsEncoder::start(int pointCount)
int int
PCCResidualsEncoder::stop() PCCResidualsEncoder::stop()
{ {
return arithmeticEncoder.stop_encoder(); return arithmeticEncoder.stop();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -103,7 +104,7 @@ PCCResidualsEncoder::encodeSymbol(uint32_t value, int k1, int k2) ...@@ -103,7 +104,7 @@ PCCResidualsEncoder::encodeSymbol(uint32_t value, int k1, int k2)
} else { } else {
int alphabetSize = kAttributeResidualAlphabetSize; int alphabetSize = kAttributeResidualAlphabetSize;
symbolCoder[k2].encode(alphabetSize, &arithmeticEncoder); symbolCoder[k2].encode(alphabetSize, &arithmeticEncoder);
arithmeticEncoder.ExpGolombEncode( arithmeticEncoder.encodeExpGolomb(
value - alphabetSize, 0, binaryModel0, binaryModelDiff[k1]); value - alphabetSize, 0, binaryModel0, binaryModelDiff[k1]);
} }
} }
...@@ -329,7 +330,7 @@ AttributeEncoder::computeReflectanceResidual( ...@@ -329,7 +330,7 @@ AttributeEncoder::computeReflectanceResidual(
const int64_t quantAttValue = reflectance; const int64_t quantAttValue = reflectance;
const int64_t quantPredAttValue = predictedReflectance; const int64_t quantPredAttValue = predictedReflectance;
const int64_t delta = PCCQuantization(quantAttValue - quantPredAttValue, qs); const int64_t delta = PCCQuantization(quantAttValue - quantPredAttValue, qs);
return o3dgc::IntToUInt(delta); return IntToUInt(delta);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -418,7 +419,7 @@ AttributeEncoder::encodeReflectancesPred( ...@@ -418,7 +419,7 @@ AttributeEncoder::encodeReflectancesPred(
const int64_t quantPredAttValue = predictedReflectance; const int64_t quantPredAttValue = predictedReflectance;
const int64_t delta = const int64_t delta =
PCCQuantization(quantAttValue - quantPredAttValue, qs); PCCQuantization(quantAttValue - quantPredAttValue, qs);
const uint32_t attValue0 = uint32_t(o3dgc::IntToUInt(long(delta))); const uint32_t attValue0 = uint32_t(IntToUInt(long(delta)));
const int64_t reconstructedDelta = PCCInverseQuantization(delta, qs); const int64_t reconstructedDelta = PCCInverseQuantization(delta, qs);
const int64_t reconstructedQuantAttValue = const int64_t reconstructedQuantAttValue =
quantPredAttValue + reconstructedDelta; quantPredAttValue + reconstructedDelta;
...@@ -443,13 +444,13 @@ AttributeEncoder::computeColorResiduals( ...@@ -443,13 +444,13 @@ AttributeEncoder::computeColorResiduals(
const int64_t quantAttValue = color[0]; const int64_t quantAttValue = color[0];
const int64_t quantPredAttValue = predictedColor[0]; const int64_t quantPredAttValue = predictedColor[0];
const int64_t delta = PCCQuantization(quantAttValue - quantPredAttValue, qs); const int64_t delta = PCCQuantization(quantAttValue - quantPredAttValue, qs);
residuals[0] = o3dgc::IntToUInt(delta); residuals[0] = IntToUInt(delta);
for (size_t k = 1; k < 3; ++k) { for (size_t k = 1; k < 3; ++k) {
const int64_t quantAttValue = color[k]; const int64_t quantAttValue = color[k];
const int64_t quantPredAttValue = predictedColor[k]; const int64_t quantPredAttValue = predictedColor[k];
const int64_t delta = const int64_t delta =
PCCQuantization(quantAttValue - quantPredAttValue, qs2); PCCQuantization(quantAttValue - quantPredAttValue, qs2);
residuals[k] = o3dgc::IntToUInt(delta); residuals[k] = IntToUInt(delta);
} }
return residuals; return residuals;
} }
...@@ -550,7 +551,7 @@ AttributeEncoder::encodeColorsPred( ...@@ -550,7 +551,7 @@ AttributeEncoder::encodeColorsPred(
const int64_t reconstructedDelta = PCCInverseQuantization(delta, qs); const int64_t reconstructedDelta = PCCInverseQuantization(delta, qs);
const int64_t reconstructedQuantAttValue = const int64_t reconstructedQuantAttValue =
quantPredAttValue + reconstructedDelta; quantPredAttValue + reconstructedDelta;
values[0] = uint32_t(o3dgc::IntToUInt(long(delta))); values[0] = uint32_t(IntToUInt(long(delta)));
PCCColor3B reconstructedColor; PCCColor3B reconstructedColor;
reconstructedColor[0] = reconstructedColor[0] =
uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax)); uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax));
...@@ -562,7 +563,7 @@ AttributeEncoder::encodeColorsPred( ...@@ -562,7 +563,7 @@ AttributeEncoder::encodeColorsPred(
const int64_t reconstructedDelta = PCCInverseQuantization(delta, qs2); const int64_t reconstructedDelta = PCCInverseQuantization(delta, qs2);
const int64_t reconstructedQuantAttValue = const int64_t reconstructedQuantAttValue =
quantPredAttValue + reconstructedDelta; quantPredAttValue + reconstructedDelta;
values[k] = uint32_t(o3dgc::IntToUInt(long(delta))); values[k] = uint32_t(IntToUInt(long(delta)));
reconstructedColor[k] = reconstructedColor[k] =
uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax)); uint8_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax));
} }
...@@ -638,7 +639,7 @@ AttributeEncoder::encodeReflectancesTransformRaht( ...@@ -638,7 +639,7 @@ AttributeEncoder::encodeReflectancesTransformRaht(
} }
// Entropy encode. // Entropy encode.
for (int n = 0; n < voxelCount; ++n) { for (int n = 0; n < voxelCount; ++n) {
const int64_t detail = o3dgc::IntToUInt(sortedIntegerizedAttributes[n]); const int64_t detail = IntToUInt(sortedIntegerizedAttributes[n]);
assert(detail < std::numeric_limits<uint32_t>::max()); assert(detail < std::numeric_limits<uint32_t>::max());
const uint32_t attValue0 = uint32_t(detail); const uint32_t attValue0 = uint32_t(detail);
encoder.encode(attValue0); encoder.encode(attValue0);
...@@ -759,14 +760,14 @@ AttributeEncoder::encodeColorsTransformRaht( ...@@ -759,14 +760,14 @@ AttributeEncoder::encodeColorsTransformRaht(
// Entropy encode. // Entropy encode.
uint32_t values[3]; uint32_t values[3];
for (int n = 0; n < voxelCount; ++n) { for (int n = 0; n < voxelCount; ++n) {
const int64_t detail = o3dgc::IntToUInt(sortedIntegerizedAttributes[n]); const int64_t detail = IntToUInt(sortedIntegerizedAttributes[n]);
assert(detail < std::numeric_limits<uint32_t>::max()); assert(detail < std::numeric_limits<uint32_t>::max());
values[0] = uint32_t(detail); values[0] = uint32_t(detail);
if ( if (
binaryLayer[sortedWeight[n].index] >= aps.raht_binary_level_threshold) { binaryLayer[sortedWeight[n].index] >= aps.raht_binary_level_threshold) {
for (int d = 1; d < 3; ++d) { for (int d = 1; d < 3; ++d) {
const int64_t detail = const int64_t detail =
o3dgc::IntToUInt(sortedIntegerizedAttributes[voxelCount * d + n]); IntToUInt(sortedIntegerizedAttributes[voxelCount * d + n]);
assert(detail < std::numeric_limits<uint32_t>::max()); assert(detail < std::numeric_limits<uint32_t>::max());
values[d] = uint32_t(detail); values[d] = uint32_t(detail);
} }
...@@ -881,7 +882,7 @@ AttributeEncoder::encodeColorsLift( ...@@ -881,7 +882,7 @@ AttributeEncoder::encodeColorsLift(
const double quantWeight = sqrt(weights[predictorIndex]); const double quantWeight = sqrt(weights[predictorIndex]);
auto& color = colors[predictorIndex]; auto& color = colors[predictorIndex];
const int64_t delta = PCCQuantization(color[0] * quantWeight, qs); const int64_t delta = PCCQuantization(color[0] * quantWeight, qs);
const int64_t detail = o3dgc::IntToUInt(delta); const int64_t detail = IntToUInt(delta);
assert(detail < std::numeric_limits<uint32_t>::max()); assert(detail < std::numeric_limits<uint32_t>::max());
const double reconstructedDelta = PCCInverseQuantization(delta, qs); const double reconstructedDelta = PCCInverseQuantization(delta, qs);
color[0] = reconstructedDelta / quantWeight; color[0] = reconstructedDelta / quantWeight;
...@@ -890,7 +891,7 @@ AttributeEncoder::encodeColorsLift( ...@@ -890,7 +891,7 @@ AttributeEncoder::encodeColorsLift(
const size_t qs2 = aps.quant_step_size_chroma; const size_t qs2 = aps.quant_step_size_chroma;
for (size_t d = 1; d < 3; ++d) { for (size_t d = 1; d < 3; ++d) {
const int64_t delta = PCCQuantization(color[d] * quantWeight, qs2); const int64_t delta = PCCQuantization(color[d] * quantWeight, qs2);
const int64_t detail = o3dgc::IntToUInt(delta); const int64_t detail = IntToUInt(delta);
assert(detail < std::numeric_limits<uint32_t>::max()); assert(detail < std::numeric_limits<uint32_t>::max());
const double reconstructedDelta = PCCInverseQuantization(delta, qs2); const double reconstructedDelta = PCCInverseQuantization(delta, qs2);
color[d] = reconstructedDelta / quantWeight; color[d] = reconstructedDelta / quantWeight;
...@@ -967,7 +968,7 @@ AttributeEncoder::encodeReflectancesLift( ...@@ -967,7 +968,7 @@ AttributeEncoder::encodeReflectancesLift(
const double quantWeight = sqrt(weights[predictorIndex]); const double quantWeight = sqrt(weights[predictorIndex]);
auto& reflectance = reflectances[predictorIndex]; auto& reflectance = reflectances[predictorIndex];
const int64_t delta = PCCQuantization(reflectance * quantWeight, qs); const int64_t delta = PCCQuantization(reflectance * quantWeight, qs);
const int64_t detail = o3dgc::IntToUInt(delta); const int64_t detail = IntToUInt(delta);
assert(detail < std::numeric_limits<uint32_t>::max()); assert(detail < std::numeric_limits<uint32_t>::max());
const double reconstructedDelta = PCCInverseQuantization(delta, qs); const double reconstructedDelta = PCCInverseQuantization(delta, qs);
reflectance = reconstructedDelta / quantWeight; reflectance = reconstructedDelta / quantWeight;
......
...@@ -72,6 +72,9 @@ file(GLOB PROJECT_INC_FILES ...@@ -72,6 +72,9 @@ file(GLOB PROJECT_INC_FILES
"RAHT.h" "RAHT.h"
"TMC3.h" "TMC3.h"
"constants.h" "constants.h"
"entropy.h"
"entropyo3dgc.h"
"entropyutils.h"
"geometry.h" "geometry.h"
"geometry_intra_pred.h" "geometry_intra_pred.h"
"geometry_octree.h" "geometry_octree.h"
......
...@@ -211,7 +211,7 @@ DualLutCoder<_limitedContextMode>::resetLut() ...@@ -211,7 +211,7 @@ DualLutCoder<_limitedContextMode>::resetLut()
template<> template<>
void void
DualLutCoder<true>::encodeFrequencySortedLutIndex(