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

cfg: automatic derivation of dist2 series

This commit introduces automatic derivation of dist2 values by the
frontend.  Automatic derivation occurs if fewer than levelOfDetailCount
values are provided.  No syntax changes are made.

cfg update:
 - use single dist2 values based on existing config
 - ford: 16383 -> 16384
parent 764d40d4
......@@ -29,7 +29,7 @@ categories:
- &mitsubishiLosslessAttrs
- numberOfNearestNeighborsInPrediction: 3
- levelOfDetailCount: 9
- dist2: 134217728 33554432 8388608 2097152 524288 131072 32768 8192 0
- dist2: 8192
- quantizationStepLuma: 0
- quantizationStepChroma: 0
- bitdepth: 8
......@@ -88,7 +88,7 @@ categories:
- &fordLosslessAttrs
- numberOfNearestNeighborsInPrediction: 3
- levelOfDetailCount: 6
- dist2: 4194301 1048582 262149 65534 16383 0
- dist2: 16384
- quantizationStepLuma: 0
- bitdepth: 8
- attribute: reflectance
......
......@@ -30,7 +30,7 @@ categories:
- &commonAttr
- numberOfNearestNeighborsInPrediction: 3
- levelOfDetailCount: 9
- dist2: 134217728 33554432 8388608 2097152 524288 131072 32768 8192 0
- dist2: 8192
- quantizationStepLuma:
r01: 256
r02: 128
......
......@@ -30,7 +30,7 @@ categories:
- &mitsubishiNearlosslessAttrs
- numberOfNearestNeighborsInPrediction: 3
- levelOfDetailCount: 9
- dist2: 134217728 33554432 8388608 2097152 524288 131072 32768 8192 0
- dist2: 8192
- &mitsubishiNearlosslessAttrsColour8
- *mitsubishiNearlosslessAttrs
- quantizationStepLuma:
......@@ -101,7 +101,7 @@ categories:
- &fordNearlosslessAttrsRefl8
- numberOfNearestNeighborsInPrediction: 3
- levelOfDetailCount: 6
- dist2: 4194301 1048582 262149 65534 16383 0
- dist2: 16384
- quantizationStepLuma:
r01: 2
r02: 4
......
......@@ -34,12 +34,12 @@ categories:
r05: 6
r06: 6
- dist2:
r01: 6 0
r02: 21 5 1 0
r03: 85 21 5 1 0
r04: 508 127 32 8 2 0
r05: 10486 2621 655 164 41 0
r06: 317194 79299 19825 4956 1239 0
r01: 6
r02: 1
r03: 1
r04: 2
r05: 41
r06: 1239
- quantizationStepLuma: 8
- bitdepth: 8
- attribute: reflectance
......
......@@ -352,7 +352,8 @@ ParseParameters(int argc, char* argv[], Parameters& params)
("dist2",
params_attr.aps.dist2, {},
"Attribute's list of squared distances (one for each LoD)")
"Attribute's list of squared distances, or initial value for automatic"
"derivation")
;
/* clang-format on */
......@@ -390,6 +391,25 @@ ParseParameters(int argc, char* argv[], Parameters& params)
attr_aps.quant_step_size_chroma = 0;
}
bool isLifting =
attr_aps.attr_encoding == AttributeEncoding::kPredictingTransform
|| attr_aps.attr_encoding == AttributeEncoding::kLiftingTransform;
// derive the dist2 values based on an initial value
if (isLifting && !attr_aps.dist2.empty()) {
if (attr_aps.dist2.size() < attr_aps.numDetailLevels) {
attr_aps.dist2.resize(attr_aps.numDetailLevels);
const double distRatio = 4.0;
uint64_t d2 = attr_aps.dist2[0];
for (int i = 1; i < attr_aps.numDetailLevels; ++i) {
attr_aps.dist2[attr_aps.numDetailLevels - 1 - i] = d2;
d2 = uint64_t(std::round(distRatio * d2));
}
attr_aps.dist2[attr_aps.numDetailLevels - 1] = 0;
}
}
// Set default threshold based on bitdepth
if (attr_aps.adaptive_prediction_threshold == -1) {
attr_aps.adaptive_prediction_threshold = 1
......@@ -433,9 +453,9 @@ ParseParameters(int argc, char* argv[], Parameters& params)
if (isLifting) {
int lod = attr_aps.numDetailLevels;
if (lod > 255) {
if (lod > 255 || lod < 1) {
err.error() << it.first
<< ".levelOfDetailCount must be less than 256\n";
<< ".levelOfDetailCount must be in the range [1,255]\n";
}
if (attr_aps.dist2.size() != lod) {
err.error() << it.first << ".dist2 does not have " << lod
......
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