1cc1dc7a3Sopenharmony_ci# Terminology for the ASTC Encoder
2cc1dc7a3Sopenharmony_ci
3cc1dc7a3Sopenharmony_ciLike most software, the `astcenc` code base has a set of naming conventions
4cc1dc7a3Sopenharmony_cifor variables which are used to ensure both accuracy and reasonable brevity.
5cc1dc7a3Sopenharmony_ci
6cc1dc7a3Sopenharmony_ci:construction: These conventions are being used for new patches, so new code
7cc1dc7a3Sopenharmony_ciwill conform to this, but older code is still being cleaned up to follow
8cc1dc7a3Sopenharmony_cithese conventions.
9cc1dc7a3Sopenharmony_ci
10cc1dc7a3Sopenharmony_ci## Counts
11cc1dc7a3Sopenharmony_ci
12cc1dc7a3Sopenharmony_ciFor counts of things prefer `<x>_count` rather than `<x>s`. For example:
13cc1dc7a3Sopenharmony_ci
14cc1dc7a3Sopenharmony_ci* `plane_count`
15cc1dc7a3Sopenharmony_ci* `weight_count`
16cc1dc7a3Sopenharmony_ci* `texel_count`
17cc1dc7a3Sopenharmony_ci
18cc1dc7a3Sopenharmony_ciWhere possible aim for descriptive loop variables, as these are more literate
19cc1dc7a3Sopenharmony_cithan simple `i` or `j` variables. For example:
20cc1dc7a3Sopenharmony_ci
21cc1dc7a3Sopenharmony_ci* `plane_index`
22cc1dc7a3Sopenharmony_ci* `weight_index`
23cc1dc7a3Sopenharmony_ci* `texel_index`
24cc1dc7a3Sopenharmony_ci
25cc1dc7a3Sopenharmony_ci## Ideal, Unpacked Quantized, vs Packed Quantized
26cc1dc7a3Sopenharmony_ci
27cc1dc7a3Sopenharmony_ciVariables that are quantized, such as endpoint colors and weights, have
28cc1dc7a3Sopenharmony_cimultiple states depending on how they are being used.
29cc1dc7a3Sopenharmony_ci
30cc1dc7a3Sopenharmony_ci**Ideal values** represent arbitrary numeric values that can take any value.
31cc1dc7a3Sopenharmony_ciThese are often used during compression to work out the best value before
32cc1dc7a3Sopenharmony_ciany quantization is applied. For example, integer weights in the 0-64 range can
33cc1dc7a3Sopenharmony_citake any of the 65 values available.
34cc1dc7a3Sopenharmony_ci
35cc1dc7a3Sopenharmony_ci**Quant uvalues** represent the unpacked numeric value after any quantization
36cc1dc7a3Sopenharmony_cirounding has been applied. These are often used during compression to work out
37cc1dc7a3Sopenharmony_cithe error for the quantized value compared to the ideal value. For example,
38cc1dc7a3Sopenharmony_ci`QUANT_3` weights in the 0-64 range can only take one of `[0, 32, 64]`.
39cc1dc7a3Sopenharmony_ci
40cc1dc7a3Sopenharmony_ci**Quant pvalues** represent the packed numeric value in the quantized alphabet.
41cc1dc7a3Sopenharmony_ciThis is what ends up encoded in the ASTC data, although note that the encoded
42cc1dc7a3Sopenharmony_ciordering is scrambled to simplify hardware. For example, `QUANT_3` weights
43cc1dc7a3Sopenharmony_cioriginally in the 0-64 range can only take one of `[0, 1, 2]`.
44cc1dc7a3Sopenharmony_ci
45cc1dc7a3Sopenharmony_ciFor example:
46cc1dc7a3Sopenharmony_ci
47cc1dc7a3Sopenharmony_ci* `weights_ideal_value`
48cc1dc7a3Sopenharmony_ci* `weights_quant_uvalue`
49cc1dc7a3Sopenharmony_ci* `weights_quant_pvalue`
50cc1dc7a3Sopenharmony_ci
51cc1dc7a3Sopenharmony_ci## Full vs Decimated interpolation weights
52cc1dc7a3Sopenharmony_ci
53cc1dc7a3Sopenharmony_ciWeight grids have multiple states depending on how they are being used.
54cc1dc7a3Sopenharmony_ci
55cc1dc7a3Sopenharmony_ci**full_weights** represent per texel weight grids, storing one weight per texel.
56cc1dc7a3Sopenharmony_ci
57cc1dc7a3Sopenharmony_ci**decimated_weights** represent reduced weight grids, which can store fewer
58cc1dc7a3Sopenharmony_ciweights and which are bilinear interpolated to generate the full weight grid.
59cc1dc7a3Sopenharmony_ci
60cc1dc7a3Sopenharmony_ciFull weights have no variable prefix,but decimated weights are stored with
61cc1dc7a3Sopenharmony_cia `dec_` prefix.
62cc1dc7a3Sopenharmony_ci
63cc1dc7a3Sopenharmony_ci* `dec_weights_ideal_value`
64cc1dc7a3Sopenharmony_ci* `dec_weights_quant_uvalue`
65cc1dc7a3Sopenharmony_ci* `dec_weights_quant_pvalue`
66cc1dc7a3Sopenharmony_ci
67cc1dc7a3Sopenharmony_ci## Weight vs Significance
68cc1dc7a3Sopenharmony_ci
69cc1dc7a3Sopenharmony_ciThe original encoder used "weight" for multiple purposes - texel significance
70cc1dc7a3Sopenharmony_ci(weight the error), color channel significance (weight the error), and endpoint
71cc1dc7a3Sopenharmony_ciinterpolation weights. This gets very confusing in functions using all three!
72cc1dc7a3Sopenharmony_ci
73cc1dc7a3Sopenharmony_ciWe are slowly refactoring the code to only use "weight" to mean the endpoint
74cc1dc7a3Sopenharmony_ciinterpolation weights. The error weighting factors used for other purposes are
75cc1dc7a3Sopenharmony_cibeing updated to use the using the term "significance".
76cc1dc7a3Sopenharmony_ci
77cc1dc7a3Sopenharmony_ci- - -
78cc1dc7a3Sopenharmony_ci
79cc1dc7a3Sopenharmony_ci_Copyright © 2020-2022, Arm Limited and contributors. All rights reserved._
80