Commit ee776724 authored by Khaled Mammou's avatar Khaled Mammou Committed by David Flynn
Browse files

m42642/attr: add hls signalling of adaptive prediction threshold

This commit replaces the hard coded threshold values with APS signalling.
The default configuration maintains the hard-coded threshold values based
on bitdepth.
parent b3c5d0fa
......@@ -231,7 +231,7 @@ AttributeDecoder::decodeReflectancesPred(
aps.num_pred_nearest_neighbours, predictors);
const size_t pointCount = pointCloud.getPointCount();
const int64_t maxReflectance = (1ll << desc.attr_bitdepth) - 1;
const int64_t threshold = 1ll << (desc.attr_bitdepth - 2);
const int64_t threshold = aps.adaptive_prediction_threshold;
for (size_t predictorIndex = 0; predictorIndex < pointCount;
++predictorIndex) {
auto& predictor = predictors[predictorIndex];
......@@ -309,7 +309,7 @@ AttributeDecoder::decodeColorsPred(
PCCComputePredictors2(
pointCloud, numberOfPointsPerLOD, indexesLOD,
aps.num_pred_nearest_neighbours, predictors);
const int64_t threshold = 1ll << (desc.attr_bitdepth - 2);
const int64_t threshold = aps.adaptive_prediction_threshold;
const size_t pointCount = pointCloud.getPointCount();
uint32_t values[3];
for (size_t predictorIndex = 0; predictorIndex < pointCount;
......
......@@ -395,8 +395,7 @@ AttributeEncoder::encodeReflectancesPred(
pointCloud, numberOfPointsPerLOD, indexesLOD,
aps.num_pred_nearest_neighbours, predictors);
// todo(??): what about attr_bitdepth < 2?
const int64_t threshold = 1ll << (desc.attr_bitdepth - 2);
const int64_t threshold = aps.adaptive_prediction_threshold;
const int64_t clipMax = (1ll << desc.attr_bitdepth) - 1;
PCCResidualsEntropyEstimator context;
for (size_t predictorIndex = 0; predictorIndex < pointCount;
......@@ -528,8 +527,7 @@ AttributeEncoder::encodeColorsPred(
pointCloud, numberOfPointsPerLOD, indexesLOD,
aps.num_pred_nearest_neighbours, predictors);
// todo(??): what about attr_bitdepth < 2?
const int64_t threshold = 1ll << (desc.attr_bitdepth - 2);
const int64_t threshold = aps.adaptive_prediction_threshold;
const int64_t clipMax = (1ll << desc.attr_bitdepth) - 1;
uint32_t values[3];
PCCResidualsEntropyEstimator context;
......
......@@ -332,6 +332,12 @@ ParseParameters(int argc, char* argv[], Parameters& params)
params_attr.aps.num_pred_nearest_neighbours, 4,
"Attribute's maximum number of nearest neighbors to be used for prediction")
("adaptivePredictionThreshold",
params_attr.aps.adaptive_prediction_threshold, -1,
"Neighbouring attribute value difference that enables choice of "
"single|multi predictors. Applies to transformType=2 only.\n"
" -1: auto = 2**(bitdepth-2)")
("levelOfDetailCount",
params_attr.aps.numDetailLevels, 1,
"Attribute's number of levels of detail")
......@@ -378,12 +384,25 @@ ParseParameters(int argc, char* argv[], Parameters& params)
1.0f / params.encoder.sps.donotuse_trisoup_int_to_orig_scale;
}
// For RAHT, ensure that the unused lod count = 0 (prevents mishaps)
// fixup any per-attribute settings
for (const auto& it : params.encoder.attributeIdxMap) {
auto& attr_sps = params.encoder.sps.attributeSets[it.second];
auto& attr_aps = params.encoder.aps[it.second];
// Set default threshold based on bitdepth
if (attr_aps.adaptive_prediction_threshold == -1) {
attr_aps.adaptive_prediction_threshold = 1
<< (attr_sps.attr_bitdepth - 2);
}
if (attr_aps.attr_encoding == AttributeEncoding::kLiftingTransform) {
attr_aps.adaptive_prediction_threshold = 0;
}
// For RAHT, ensure that the unused lod count = 0 (prevents mishaps)
if (attr_aps.attr_encoding == AttributeEncoding::kRAHTransform) {
attr_aps.numDetailLevels = 0;
attr_aps.adaptive_prediction_threshold = 0;
}
}
......@@ -432,6 +451,11 @@ ParseParameters(int argc, char* argv[], Parameters& params)
}
}
if (attr_aps.adaptive_prediction_threshold < 0) {
err.error() << it.first
<< ".adaptivePredictionThreshold must be positive\n";
}
if (
attr_aps.num_pred_nearest_neighbours
> PCCTMC3MaxPredictionNearestNeighborCount) {
......
......@@ -233,9 +233,10 @@ struct AttributeParameterSet {
int aps_seq_parameter_set_id;
AttributeEncoding attr_encoding;
//--- lifting transform parameters
//--- lifting/predicting transform parameters
int num_pred_nearest_neighbours;
int adaptive_prediction_threshold;
// NB: derived from num_detail_levels_minus1
int numDetailLevels;
......
......@@ -270,7 +270,13 @@ write(const AttributeParameterSet& aps)
if (chroma_quant_steps_present_flag)
bs.writeUe(aps.quant_step_size_chroma[idx]);
}
} else if (aps.attr_encoding == AttributeEncoding::kRAHTransform) {
}
if (aps.attr_encoding == AttributeEncoding::kPredictingTransform) {
bs.writeUe(aps.adaptive_prediction_threshold);
}
if (aps.attr_encoding == AttributeEncoding::kRAHTransform) {
bs.writeUe(aps.raht_depth);
bs.writeUe(aps.raht_binary_level_threshold);
bs.write(aps.quant_step_size_luma[0]);
......@@ -321,7 +327,13 @@ parseAps(const PayloadBuffer& buf)
bs.readUe(&aps.quant_step_size_chroma[idx]);
}
}
} else if (aps.attr_encoding == AttributeEncoding::kRAHTransform) {
}
if (aps.attr_encoding == AttributeEncoding::kPredictingTransform) {
bs.readUe(&aps.adaptive_prediction_threshold);
}
if (aps.attr_encoding == AttributeEncoding::kRAHTransform) {
bs.readUe(&aps.raht_depth);
bs.readUe(&aps.raht_binary_level_threshold);
......
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