Skip to content

Commit e57cf3c

Browse files
committed
quality & dict size presets
1 parent 30d1ca8 commit e57cf3c

File tree

3 files changed

+46
-29
lines changed

3 files changed

+46
-29
lines changed

Source/astcenc_entry.cpp

+27-24
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ struct astcenc_preset_config
5656
float tune_3partition_early_out_limit_factor;
5757
float tune_2plane_early_out_limit_correlation;
5858
float tune_search_mode0_enable;
59+
float rdo_quality;
60+
unsigned int rdo_dict_size;
5961
};
6062

6163
/**
@@ -64,22 +66,22 @@ struct astcenc_preset_config
6466
static const std::array<astcenc_preset_config, 6> preset_configs_high {{
6567
{
6668
ASTCENC_PRE_FASTEST,
67-
2, 10, 6, 4, 43, 2, 2, 2, 2, 2, 85.2f, 63.2f, 3.5f, 1.0f, 1.0f, 0.85f, 0.0f
69+
2, 10, 6, 4, 43, 2, 2, 2, 2, 2, 85.2f, 63.2f, 3.5f, 1.0f, 1.0f, 0.85f, 0.0f, 4.0f, 256
6870
}, {
6971
ASTCENC_PRE_FAST,
70-
3, 18, 10, 8, 55, 3, 3, 2, 2, 2, 85.2f, 63.2f, 3.5f, 1.0f, 1.0f, 0.90f, 0.0f
72+
3, 18, 10, 8, 55, 3, 3, 2, 2, 2, 85.2f, 63.2f, 3.5f, 1.0f, 1.0f, 0.90f, 0.0f, 2.0f, 1024
7173
}, {
7274
ASTCENC_PRE_MEDIUM,
73-
4, 34, 28, 16, 77, 3, 3, 2, 2, 2, 95.0f, 70.0f, 2.5f, 1.1f, 1.05f, 0.95f, 0.0f
75+
4, 34, 28, 16, 77, 3, 3, 2, 2, 2, 95.0f, 70.0f, 2.5f, 1.1f, 1.05f, 0.95f, 0.0f, 1.0f, 4096
7476
}, {
7577
ASTCENC_PRE_THOROUGH,
76-
4, 82, 60, 30, 94, 4, 4, 3, 2, 2, 105.0f, 77.0f, 10.0f, 1.35f, 1.15f, 0.97f, 0.0f
78+
4, 82, 60, 30, 94, 4, 4, 3, 2, 2, 105.0f, 77.0f, 10.0f, 1.35f, 1.15f, 0.97f, 0.0f, 0.5f, 4096
7779
}, {
7880
ASTCENC_PRE_VERYTHOROUGH,
79-
4, 256, 128, 64, 98, 4, 6, 8, 6, 4, 200.0f, 200.0f, 10.0f, 1.6f, 1.4f, 0.98f, 0.0f
81+
4, 256, 128, 64, 98, 4, 6, 8, 6, 4, 200.0f, 200.0f, 10.0f, 1.6f, 1.4f, 0.98f, 0.0f, 0.4f, 4096
8082
}, {
8183
ASTCENC_PRE_EXHAUSTIVE,
82-
4, 512, 512, 512, 100, 4, 8, 8, 8, 8, 200.0f, 200.0f, 10.0f, 2.0f, 2.0f, 0.99f, 0.0f
84+
4, 512, 512, 512, 100, 4, 8, 8, 8, 8, 200.0f, 200.0f, 10.0f, 2.0f, 2.0f, 0.99f, 0.0f, 0.2f, 4096
8385
}
8486
}};
8587

@@ -89,22 +91,22 @@ static const std::array<astcenc_preset_config, 6> preset_configs_high {{
8991
static const std::array<astcenc_preset_config, 6> preset_configs_mid {{
9092
{
9193
ASTCENC_PRE_FASTEST,
92-
2, 10, 6, 4, 43, 2, 2, 2, 2, 2, 85.2f, 63.2f, 3.5f, 1.0f, 1.0f, 0.80f, 1.0f
94+
2, 10, 6, 4, 43, 2, 2, 2, 2, 2, 85.2f, 63.2f, 3.5f, 1.0f, 1.0f, 0.80f, 1.0f, 4.0f, 256
9395
}, {
9496
ASTCENC_PRE_FAST,
95-
3, 18, 12, 10, 55, 3, 3, 2, 2, 2, 85.2f, 63.2f, 3.5f, 1.0f, 1.0f, 0.85f, 1.0f
97+
3, 18, 12, 10, 55, 3, 3, 2, 2, 2, 85.2f, 63.2f, 3.5f, 1.0f, 1.0f, 0.85f, 1.0f, 2.0f, 1024
9698
}, {
9799
ASTCENC_PRE_MEDIUM,
98-
3, 34, 28, 16, 77, 3, 3, 2, 2, 2, 95.0f, 70.0f, 3.0f, 1.1f, 1.05f, 0.90f, 1.0f
100+
3, 34, 28, 16, 77, 3, 3, 2, 2, 2, 95.0f, 70.0f, 3.0f, 1.1f, 1.05f, 0.90f, 1.0f, 1.0f, 4096
99101
}, {
100102
ASTCENC_PRE_THOROUGH,
101-
4, 82, 60, 30, 94, 4, 4, 3, 2, 2, 105.0f, 77.0f, 10.0f, 1.4f, 1.2f, 0.95f, 0.0f
103+
4, 82, 60, 30, 94, 4, 4, 3, 2, 2, 105.0f, 77.0f, 10.0f, 1.4f, 1.2f, 0.95f, 0.0f, 0.5f, 4096
102104
}, {
103105
ASTCENC_PRE_VERYTHOROUGH,
104-
4, 256, 128, 64, 98, 4, 6, 8, 6, 3, 200.0f, 200.0f, 10.0f, 1.6f, 1.4f, 0.98f, 0.0f
106+
4, 256, 128, 64, 98, 4, 6, 8, 6, 3, 200.0f, 200.0f, 10.0f, 1.6f, 1.4f, 0.98f, 0.0f, 0.4f, 4096
105107
}, {
106108
ASTCENC_PRE_EXHAUSTIVE,
107-
4, 256, 256, 256, 100, 4, 8, 8, 8, 8, 200.0f, 200.0f, 10.0f, 2.0f, 2.0f, 0.99f, 0.0f
109+
4, 256, 256, 256, 100, 4, 8, 8, 8, 8, 200.0f, 200.0f, 10.0f, 2.0f, 2.0f, 0.99f, 0.0f, 0.2f, 4096
108110
}
109111
}};
110112

@@ -114,22 +116,22 @@ static const std::array<astcenc_preset_config, 6> preset_configs_mid {{
114116
static const std::array<astcenc_preset_config, 6> preset_configs_low {{
115117
{
116118
ASTCENC_PRE_FASTEST,
117-
2, 10, 6, 4, 40, 2, 2, 2, 2, 2, 85.0f, 63.0f, 3.5f, 1.0f, 1.0f, 0.80f, 1.0f
119+
2, 10, 6, 4, 40, 2, 2, 2, 2, 2, 85.0f, 63.0f, 3.5f, 1.0f, 1.0f, 0.80f, 1.0f, 4.0f, 256
118120
}, {
119121
ASTCENC_PRE_FAST,
120-
2, 18, 12, 10, 55, 3, 3, 2, 2, 2, 85.0f, 63.0f, 3.5f, 1.0f, 1.0f, 0.85f, 1.0f
122+
2, 18, 12, 10, 55, 3, 3, 2, 2, 2, 85.0f, 63.0f, 3.5f, 1.0f, 1.0f, 0.85f, 1.0f, 2.0f, 1024
121123
}, {
122124
ASTCENC_PRE_MEDIUM,
123-
3, 34, 28, 16, 77, 3, 3, 2, 2, 2, 95.0f, 70.0f, 3.5f, 1.1f, 1.05f, 0.90f, 1.0f
125+
3, 34, 28, 16, 77, 3, 3, 2, 2, 2, 95.0f, 70.0f, 3.5f, 1.1f, 1.05f, 0.90f, 1.0f, 1.0f, 4096
124126
}, {
125127
ASTCENC_PRE_THOROUGH,
126-
4, 82, 60, 30, 93, 4, 4, 3, 2, 2, 105.0f, 77.0f, 10.0f, 1.3f, 1.2f, 0.97f, 1.0f
128+
4, 82, 60, 30, 93, 4, 4, 3, 2, 2, 105.0f, 77.0f, 10.0f, 1.3f, 1.2f, 0.97f, 1.0f, 0.5f, 4096
127129
}, {
128130
ASTCENC_PRE_VERYTHOROUGH,
129-
4, 256, 128, 64, 98, 4, 6, 8, 5, 2, 200.0f, 200.0f, 10.0f, 1.6f, 1.4f, 0.98f, 1.0f
131+
4, 256, 128, 64, 98, 4, 6, 8, 5, 2, 200.0f, 200.0f, 10.0f, 1.6f, 1.4f, 0.98f, 1.0f, 0.4f, 4096
130132
}, {
131133
ASTCENC_PRE_EXHAUSTIVE,
132-
4, 256, 256, 256, 100, 4, 8, 8, 8, 8, 200.0f, 200.0f, 10.0f, 2.0f, 2.0f, 0.99f, 1.0f
134+
4, 256, 256, 256, 100, 4, 8, 8, 8, 8, 200.0f, 200.0f, 10.0f, 2.0f, 2.0f, 0.99f, 1.0f, 0.2f, 4096
133135
}
134136
}};
135137

@@ -533,6 +535,8 @@ astcenc_error astcenc_config_init(
533535
config.tune_3partition_early_out_limit_factor = (*preset_configs)[start].tune_3partition_early_out_limit_factor;
534536
config.tune_2plane_early_out_limit_correlation = (*preset_configs)[start].tune_2plane_early_out_limit_correlation;
535537
config.tune_search_mode0_enable = (*preset_configs)[start].tune_search_mode0_enable;
538+
config.rdo_quality = (*preset_configs)[start].rdo_quality;
539+
config.rdo_dict_size = (*preset_configs)[start].rdo_dict_size;
536540
}
537541
// Start and end node are not the same - so interpolate between them
538542
else
@@ -572,11 +576,16 @@ astcenc_error astcenc_config_init(
572576
config.tune_3partition_early_out_limit_factor = LERP(tune_3partition_early_out_limit_factor);
573577
config.tune_2plane_early_out_limit_correlation = LERP(tune_2plane_early_out_limit_correlation);
574578
config.tune_search_mode0_enable = LERP(tune_search_mode0_enable);
579+
config.rdo_quality = LERP(rdo_quality);
580+
config.rdo_dict_size = LERP(rdo_dict_size);
575581
#undef LERP
576582
#undef LERPI
577583
#undef LERPUI
578584
}
579585

586+
config.rdo_max_smooth_block_error_scale = 10.0f;
587+
config.rdo_max_smooth_block_std_dev = 18.0f;
588+
580589
// Set heuristics to the defaults for each color profile
581590
config.cw_r_weight = 1.0f;
582591
config.cw_g_weight = 1.0f;
@@ -655,12 +664,6 @@ astcenc_error astcenc_config_init(
655664
}
656665
config.flags = flags;
657666

658-
// These are the reasonable defaults that leverages performance & compression rate
659-
config.rdo_quality = 1.0f;
660-
config.rdo_dict_size = 4096;
661-
config.rdo_max_smooth_block_error_scale = 10.0f;
662-
config.rdo_max_smooth_block_std_dev = 18.0f;
663-
664667
return ASTCENC_SUCCESS;
665668
}
666669

Source/astcenccli_toplevel.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ static int edit_astcenc_config(
11811181
config.rdo_enabled = true;
11821182

11831183
// Unpacking RDO trials blocks requires full initialization
1184-
if (config.rdo_quality > 0.0f && static_cast<bool>(config.flags & ASTCENC_FLG_SELF_DECOMPRESS_ONLY))
1184+
if (static_cast<bool>(config.flags & ASTCENC_FLG_SELF_DECOMPRESS_ONLY))
11851185
{
11861186
config.flags &= ~ASTCENC_FLG_SELF_DECOMPRESS_ONLY;
11871187
}
@@ -1325,7 +1325,7 @@ static void print_astcenc_config(
13251325
printf(" Candidate cutoff: %u candidates\n", config.tune_candidate_limit);
13261326
printf(" Refinement cutoff: %u iterations\n", config.tune_refinement_limit);
13271327
printf(" Compressor thread count: %d\n", cli_config.thread_count);
1328-
printf(" RDO: %s\n", config.rdo_enabled ? "Enabled" : "Disabled");
1328+
printf(" Rate-distortion opt: %s\n", config.rdo_enabled ? "Enabled" : "Disabled");
13291329
if (config.rdo_enabled)
13301330
{
13311331
printf(" RDO multithreading: %s\n", config.rdo_no_multithreading ? "Disabled" : "Enabled");

Source/astcenccli_toplevel_help.cpp

+17-3
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,25 @@ ADVANCED COMPRESSION
396396
RDO quality scalar (lambda). Lower values yield higher
397397
quality/larger LZ compressed files, higher values yield lower
398398
quality/smaller LZ compressed files. A good range to try is [.2,4].
399-
Full range is [.001,50.0]. Default is 1.0.
399+
Full range is [.001,50.0]. Preset defaults are:
400+
401+
-fastest : 4.0
402+
-fast : 2.0
403+
-medium : 1.0
404+
-thorough : 0.5
405+
-verythorough : 0.4
406+
-exhaustive : 0.2
400407
401408
-rdo-dict-size <number>
402-
RDO dictionary size in bytes. Default is 4096. Lower
403-
values=faster, but give less compression. Range is [64,65536].
409+
RDO dictionary size in bytes. Lower values=faster,
410+
but give less compression. Range is [64,65536]. Preset defaults are:
411+
412+
-fastest : 256
413+
-fast : 1024
414+
-medium : 4096
415+
-thorough : 4096
416+
-verythorough : 4096
417+
-exhaustive : 4096
404418
405419
-rdo-max-smooth-block-error-scale <factor>
406420
RDO max smooth block error scale. Range is [1,300].

0 commit comments

Comments
 (0)