author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
61,745
23.05.2021 21:23:54
-3,600
4c6b39201a62b48fd3d2bf9749efaf40be29dbea
Add bsd accessor methods
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -78,8 +78,7 @@ static bool realign_weights(\n) {\n// Get the partition descriptor\nunsigned int partition_count = scb.partition_count;\n- const partition_info *pt = get_partition_table(&bsd, partition_count);\n- pt += scb.partition_index;\n+ const auto& pi = bsd.get_partition_info(partition_count, scb.partition_index);\n// Get the quantization table\nconst block_mode& bm = bsd.get_block_mode(scb.block_mode);\n@@ -171,7 +170,7 @@ static bool realign_weights(\n+ (static_cast<float>(uq_pl_weights[texel_weights[2]]) * texel_weights_float[2]\n+ static_cast<float>(uq_pl_weights[texel_weights[3]]) * texel_weights_float[3]));\n- unsigned int partition = pt->partition_of_texel[texel];\n+ unsigned int partition = pi.partition_of_texel[texel];\nweight_base = weight_base + 0.5f;\nfloat plane_weight = astc::flt_rd(weight_base);\n@@ -252,17 +251,14 @@ static float compress_symbolic_block_for_partition_1plane(\n0, 115 - 4, 111 - 4 - PARTITION_INDEX_BITS, 108 - 4 - PARTITION_INDEX_BITS, 105 - 4 - PARTITION_INDEX_BITS\n};\n- const partition_info *pt = get_partition_table(&bsd, partition_count);\n- pt += partition_index;\n+ const auto& pi = bsd.get_partition_info(partition_count, partition_index);\n// Compute ideal weights and endpoint colors, with no quantization or decimation\nendpoints_and_weights& ei = tmpbuf.ei1;\nendpoints_and_weights *eix = tmpbuf.eix1;\n- compute_ideal_colors_and_weights_1plane(bsd, blk, ewb, *pt, ei);\n+ compute_ideal_colors_and_weights_1plane(bsd, blk, ewb, pi, ei);\n// Compute ideal weights and endpoint colors for every decimation\n- const decimation_info *const *dt = bsd.decimation_tables;\n-\nfloat *decimated_quantized_weights = tmpbuf.decimated_quantized_weights;\nfloat *decimated_weights = tmpbuf.decimated_weights;\nfloat *flt_quantized_decimated_quantized_weights = tmpbuf.flt_quantized_decimated_quantized_weights;\n@@ -271,16 +267,18 @@ static float compress_symbolic_block_for_partition_1plane(\n// For each decimation mode, compute an ideal set of weights with no quantization\nfor (unsigned int i = 0; i < bsd.decimation_mode_count; i++)\n{\n- const decimation_mode& dm = bsd.decimation_modes[i];\n+ const auto& dm = bsd.get_decimation_mode(i);\nif (dm.maxprec_1plane < 0 || (only_always && !dm.percentile_always) || !dm.percentile_hit)\n{\ncontinue;\n}\n+ const auto& di = bsd.get_decimation_info(i);\n+\ncompute_ideal_weights_for_decimation(\nei,\neix[i],\n- *(dt[i]),\n+ di,\ndecimated_quantized_weights + i * BLOCK_MAX_WEIGHTS,\ndecimated_weights + i * BLOCK_MAX_WEIGHTS);\n}\n@@ -330,11 +328,13 @@ static float compress_symbolic_block_for_partition_1plane(\n}\nint decimation_mode = bm.decimation_mode;\n+ const auto& di = bsd.get_decimation_info(decimation_mode);\n// Compute weight bitcount for the mode\nunsigned int bits_used_by_weights = get_ise_sequence_bitcount(\n- dt[decimation_mode]->weight_count,\n+ di.weight_count,\nbm.get_quant_mode());\n+\nint bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\nif (bitcount <= 0 || bits_used_by_weights < 24 || bits_used_by_weights > 96)\n{\n@@ -345,7 +345,7 @@ static float compress_symbolic_block_for_partition_1plane(\n// Generate the optimized set of weights for the weight mode\ncompute_quantized_weights_for_decimation(\n- *dt[decimation_mode],\n+ di,\nweight_low_value[i], weight_high_value[i],\ndecimated_quantized_weights + BLOCK_MAX_WEIGHTS * decimation_mode,\nflt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * i,\n@@ -355,7 +355,7 @@ static float compress_symbolic_block_for_partition_1plane(\n// Compute weight quantization errors for the block mode\nqwt_errors[i] = compute_error_of_weight_set_1plane(\neix[decimation_mode],\n- *dt[decimation_mode],\n+ di,\nflt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * i);\n}\n@@ -367,7 +367,7 @@ static float compress_symbolic_block_for_partition_1plane(\nquant_method color_quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\ncompute_ideal_endpoint_formats(\n- bsd, *pt, blk, ewb, ei.ep, qwt_bitcounts, qwt_errors,\n+ bsd, pi, blk, ewb, ei.ep, qwt_bitcounts, qwt_errors,\nconfig.tune_candidate_limit, partition_format_specifiers, block_mode_index,\ncolor_quant_level, color_quant_level_mod);\n@@ -379,6 +379,7 @@ static float compress_symbolic_block_for_partition_1plane(\n{\nTRACE_NODE(node0, \"candidate\");\n+ // TODO: Can this ever happen?\nconst int bm_packed_index = block_mode_index[i];\nif (bm_packed_index < 0)\n{\n@@ -391,7 +392,7 @@ static float compress_symbolic_block_for_partition_1plane(\nint decimation_mode = qw_bm.decimation_mode;\nint weight_quant_mode = qw_bm.quant_mode;\n- const decimation_info& di = *dt[decimation_mode];\n+ const auto& di = bsd.get_decimation_info(decimation_mode);\npromise(di.weight_count > 0);\ntrace_add_data(\"weight_x\", di.weight_x);\n@@ -420,7 +421,7 @@ static float compress_symbolic_block_for_partition_1plane(\nfor (unsigned int l = 0; l < config.tune_refinement_limit; l++)\n{\nrecompute_ideal_colors_1plane(\n- blk, ewb, *pt, di,\n+ blk, ewb, pi, di,\nweight_quant_mode, workscb.weights,\neix[decimation_mode].ep, rgbs_colors, rgbo_colors);\n@@ -610,19 +611,16 @@ static float compress_symbolic_block_for_partition_2planes(\n0, 113 - 4, 109 - 4 - PARTITION_INDEX_BITS, 106 - 4 - PARTITION_INDEX_BITS, 103 - 4 - PARTITION_INDEX_BITS\n};\n- const partition_info *pt = get_partition_table(&bsd, partition_count);\n- pt += partition_index;\n+ const auto& pi = bsd.get_partition_info(partition_count, partition_index);\n// Compute ideal weights and endpoint colors, with no quantization or decimation\nendpoints_and_weights& ei1 = tmpbuf.ei1;\nendpoints_and_weights& ei2 = tmpbuf.ei2;\nendpoints_and_weights* eix1 = tmpbuf.eix1;\nendpoints_and_weights* eix2 = tmpbuf.eix2;\n- compute_ideal_colors_and_weights_2planes(bsd, blk, ewb, *pt, plane2_component, ei1, ei2);\n+ compute_ideal_colors_and_weights_2planes(bsd, blk, ewb, pi, plane2_component, ei1, ei2);\n// Compute ideal weights and endpoint colors for every decimation\n- const decimation_info *const *dt = bsd.decimation_tables;\n-\nfloat *decimated_quantized_weights = tmpbuf.decimated_quantized_weights;\nfloat *decimated_weights = tmpbuf.decimated_weights;\nfloat *flt_quantized_decimated_quantized_weights = tmpbuf.flt_quantized_decimated_quantized_weights;\n@@ -631,23 +629,25 @@ static float compress_symbolic_block_for_partition_2planes(\n// For each decimation mode, compute an ideal set of weights with no quantization\nfor (unsigned int i = 0; i < bsd.decimation_mode_count; i++)\n{\n- const decimation_mode& dm = bsd.decimation_modes[i];\n+ const auto& dm = bsd.get_decimation_mode(i);\nif (dm.maxprec_2planes < 0 || !dm.percentile_hit)\n{\ncontinue;\n}\n+ const auto& di = bsd.get_decimation_info(i);\n+\ncompute_ideal_weights_for_decimation(\nei1,\neix1[i],\n- *(dt[i]),\n+ di,\ndecimated_quantized_weights + (2 * i) * BLOCK_MAX_WEIGHTS,\ndecimated_weights + (2 * i) * BLOCK_MAX_WEIGHTS);\ncompute_ideal_weights_for_decimation(\nei2,\neix2[i],\n- *(dt[i]),\n+ di,\ndecimated_quantized_weights + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\ndecimated_weights + (2 * i + 1) * BLOCK_MAX_WEIGHTS);\n}\n@@ -705,6 +705,7 @@ static float compress_symbolic_block_for_partition_2planes(\n}\nunsigned int decimation_mode = bm.decimation_mode;\n+ const auto& di = bsd.get_decimation_info(decimation_mode);\nif (weight_high_value1[i] > 1.02f * min_wt_cutoff1)\n{\n@@ -718,7 +719,7 @@ static float compress_symbolic_block_for_partition_2planes(\n// Compute weight bitcount for the mode\nunsigned int bits_used_by_weights = get_ise_sequence_bitcount(\n- 2 * dt[decimation_mode]->weight_count,\n+ 2 * di.weight_count,\nbm.get_quant_mode());\nint bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\nif (bitcount <= 0 || bits_used_by_weights < 24 || bits_used_by_weights > 96)\n@@ -730,7 +731,7 @@ static float compress_symbolic_block_for_partition_2planes(\n// Generate the optimized set of weights for the mode\ncompute_quantized_weights_for_decimation(\n- *dt[decimation_mode],\n+ di,\nweight_low_value1[i],\nweight_high_value1[i],\ndecimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * decimation_mode),\n@@ -738,7 +739,7 @@ static float compress_symbolic_block_for_partition_2planes(\nu8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i), bm.get_quant_mode());\ncompute_quantized_weights_for_decimation(\n- *dt[decimation_mode],\n+ di,\nweight_low_value2[i],\nweight_high_value2[i],\ndecimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * decimation_mode + 1),\n@@ -749,7 +750,7 @@ static float compress_symbolic_block_for_partition_2planes(\nqwt_errors[i] = compute_error_of_weight_set_2planes(\neix1[decimation_mode],\neix2[decimation_mode],\n- *dt[decimation_mode],\n+ di,\nflt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i),\nflt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i + 1));\n}\n@@ -765,7 +766,7 @@ static float compress_symbolic_block_for_partition_2planes(\nmerge_endpoints(ei1.ep, ei2.ep, plane2_component, epm);\ncompute_ideal_endpoint_formats(\n- bsd, *pt, blk, ewb, epm, qwt_bitcounts, qwt_errors,\n+ bsd, pi, blk, ewb, epm, qwt_bitcounts, qwt_errors,\nconfig.tune_candidate_limit, partition_format_specifiers, block_mode_index,\ncolor_quant_level, color_quant_level_mod);\n@@ -789,7 +790,7 @@ static float compress_symbolic_block_for_partition_2planes(\nint decimation_mode = qw_bm.decimation_mode;\nint weight_quant_mode = qw_bm.quant_mode;\n- const decimation_info& di = *dt[decimation_mode];\n+ const auto& di = bsd.get_decimation_info(decimation_mode);\npromise(di.weight_count > 0);\ntrace_add_data(\"weight_x\", di.weight_x);\n@@ -822,7 +823,7 @@ static float compress_symbolic_block_for_partition_2planes(\nfor (unsigned int l = 0; l < config.tune_refinement_limit; l++)\n{\nrecompute_ideal_colors_2planes(\n- blk, ewb, *pt, di,\n+ blk, ewb, pi, di,\nweight_quant_mode, workscb.weights, workscb.weights + WEIGHTS_PLANE2_OFFSET,\nepm, rgbs_colors, rgbo_colors, plane2_component);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -261,14 +261,11 @@ void decompress_symbolic_block(\n// Get the appropriate partition-table entry\nint partition_count = scb.partition_count;\n- const partition_info *pt = get_partition_table(&bsd, partition_count);\n- pt += scb.partition_index;\n+ const auto& pi = bsd.get_partition_info(partition_count, scb.partition_index);\n// Get the appropriate block descriptors\n- const block_mode& bm = bsd.get_block_mode(scb.block_mode);\n-\n- const decimation_info *const *dt = bsd.decimation_tables;\n- const decimation_info& di = *(dt[bm.decimation_mode]);\n+ const auto& bm = bsd.get_block_mode(scb.block_mode);\n+ const auto& di = bsd.get_decimation_info(bm.decimation_mode);\nint is_dual_plane = bm.is_dual_plane;\n@@ -298,10 +295,10 @@ void decompress_symbolic_block(\nvmask4 lns_mask(rgb_lns, rgb_lns, rgb_lns, a_lns);\n- int texel_count = pt->partition_texel_count[i];\n+ int texel_count = pi.partition_texel_count[i];\nfor (int j = 0; j < texel_count; j++)\n{\n- int tix = pt->texels_of_partition[i][j];\n+ int tix = pi.texels_of_partition[i][j];\nvint4 color = lerp_color_int(decode_mode,\nep0,\nep1,\n@@ -339,9 +336,7 @@ float compute_symbolic_block_difference(\n// Get the appropriate partition-table entry\nint partition_count = scb.partition_count;\n-\n- const partition_info *pt = get_partition_table(&bsd, partition_count);\n- pt += scb.partition_index;\n+ const auto& pi = bsd.get_partition_info(partition_count, scb.partition_index);\n// Get the appropriate block descriptor\nconst block_mode& bm = bsd.get_block_mode(scb.block_mode);\n@@ -376,10 +371,10 @@ float compute_symbolic_block_difference(\nvmask4 lns_mask(rgb_lns, rgb_lns, rgb_lns, a_lns);\n// Unpack and compute error for each texel in the partition\n- int texel_count = pt->partition_texel_count[i];\n+ int texel_count = pi.partition_texel_count[i];\nfor (int j = 0; j < texel_count; j++)\n{\n- int tix = pt->texels_of_partition[i][j];\n+ int tix = pi.texels_of_partition[i][j];\nvint4 colori = lerp_color_int(config.profile,\nep0, ep1,\nweights[tix],\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -1227,8 +1227,7 @@ astcenc_error astcenc_get_block_info(\n// Otherwise handle a full block ; known to be valid after conditions above have been checked\nint partition_count = scb.partition_count;\n- const partition_info* pt = get_partition_table(&bsd, partition_count);\n- pt += scb.partition_index;\n+ const auto& pi = bsd.get_partition_info(partition_count, scb.partition_index);\nconst block_mode& bm = bsd.get_block_mode(scb.block_mode);\nconst decimation_info& di = *bsd.decimation_tables[bm.decimation_mode];\n@@ -1292,7 +1291,7 @@ astcenc_error astcenc_get_block_info(\n// Unpack partition assignments for each texel\nfor (unsigned int i = 0; i < bsd.texel_count; i++)\n{\n- info->partition_assignment[i] = pt->partition_of_texel[i];\n+ info->partition_assignment[i] = pi.partition_of_texel[i];\n}\nreturn ASTCENC_SUCCESS;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -362,7 +362,7 @@ static void count_partition_mismatch_bits(\nconst uint64_t bitmaps[BLOCK_MAX_PARTITIONS],\nunsigned int mismatch_counts[BLOCK_MAX_PARTITIONINGS]\n) {\n- const partition_info *pt = get_partition_table(&bsd, partition_count);\n+ const auto* pt = bsd.get_partition_table(partition_count);\n// Function pointer dispatch table\nconst mismatch_dispatch dispatch[3] {\n@@ -509,8 +509,6 @@ void find_best_partition_candidates(\nint uses_alpha = imageblock_uses_alpha(&blk);\n- const partition_info* ptab = get_partition_table(&bsd, partition_count);\n-\n// Partitioning errors assuming uncorrelated-chrominance endpoints\nfloat uncor_best_error { ERROR_CALC_DEFAULT };\nunsigned int uncor_best_partition { 0 };\n@@ -532,8 +530,9 @@ void find_best_partition_candidates(\nfor (unsigned int i = 0; i < partition_search_limit; i++)\n{\nunsigned int partition = partition_sequence[i];\n+ const auto& pi = bsd.get_partition_info(partition_count, partition);\n- unsigned int bk_partition_count = ptab[partition].partition_count;\n+ unsigned int bk_partition_count = pi.partition_count;\nif (bk_partition_count < partition_count)\n{\nbreak;\n@@ -542,7 +541,7 @@ void find_best_partition_candidates(\n// Compute weighting to give to each component in each partition\npartition_metrics pms[BLOCK_MAX_PARTITIONS];\n- compute_avgs_and_dirs_4_comp(*(ptab + partition), blk, ewb, pms);\n+ compute_avgs_and_dirs_4_comp(pi, blk, ewb, pms);\nline4 uncor_lines[BLOCK_MAX_PARTITIONS];\nline4 samec_lines[BLOCK_MAX_PARTITIONS];\n@@ -599,7 +598,7 @@ void find_best_partition_candidates(\nfloat samec_error = 0.0f;\nvfloat4 sep_error = vfloat4::zero();\n- compute_error_squared_rgba(*(ptab + partition),\n+ compute_error_squared_rgba(pi,\nblk,\newb,\nuncor_plines,\n@@ -622,7 +621,7 @@ void find_best_partition_candidates(\nfor (unsigned int j = 0; j < partition_count; j++)\n{\npartition_metrics& pm = pms[j];\n- float tpp = (float)(ptab[partition].partition_texel_count[j]);\n+ float tpp = (float)(pi.partition_texel_count[j]);\nvfloat4 ics = pm.icolor_scale;\nvfloat4 error_weights = pm.error_weight * (tpp * weight_imprecision_estim);\n@@ -714,8 +713,9 @@ void find_best_partition_candidates(\nfor (unsigned int i = 0; i < partition_search_limit; i++)\n{\nunsigned int partition = partition_sequence[i];\n+ const auto& pi = bsd.get_partition_info(partition_count, partition);\n- unsigned int bk_partition_count = ptab[partition].partition_count;\n+ unsigned int bk_partition_count = pi.partition_count;\nif (bk_partition_count < partition_count)\n{\nbreak;\n@@ -723,7 +723,7 @@ void find_best_partition_candidates(\n// Compute weighting to give to each component in each partition\npartition_metrics pms[BLOCK_MAX_PARTITIONS];\n- compute_avgs_and_dirs_3_comp(*(ptab + partition), blk, ewb, 3, pms);\n+ compute_avgs_and_dirs_3_comp(pi, blk, ewb, 3, pms);\npartition_lines3 plines[BLOCK_MAX_PARTITIONS];\n@@ -770,7 +770,7 @@ void find_best_partition_candidates(\nfloat samec_error = 0.0f;\nvfloat4 sep_error = vfloat4::zero();\n- compute_error_squared_rgb(*(ptab + partition),\n+ compute_error_squared_rgb(pi,\nblk,\newb,\nplines,\n@@ -792,7 +792,7 @@ void find_best_partition_candidates(\npartition_metrics& pm = pms[j];\npartition_lines3& pl = plines[j];\n- float tpp = (float)(ptab[partition].partition_texel_count[j]);\n+ float tpp = (float)(pi.partition_texel_count[j]);\nvfloat4 ics = pm.icolor_scale;\nics.set_lane<3>(0.0f);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -611,6 +611,52 @@ struct block_size_descriptor\nassert(packed_index != BLOCK_BAD_BLOCK_MODE && packed_index < this->block_mode_count);\nreturn block_modes[packed_index];\n}\n+\n+ /**\n+ * @brief Get the decimation mode structure for index @c decimation_mode.\n+ *\n+ * This function can only return decimation modes that are enabled by the current compressor\n+ * config. The mode array is stored packed, but this is only ever indexed by the packed index\n+ * stored in the @c block_mode and never exists in an unpacked form.\n+ */\n+ const decimation_mode& get_decimation_mode(unsigned int decimation_mode) const\n+ {\n+ return this->decimation_modes[decimation_mode];\n+ }\n+\n+ /**\n+ * @brief Get the decimation info structure for index @c decimation_mode.\n+ *\n+ * This function can only return decimation modes that are enabled by the current compressor\n+ * config. The mode array is stored packed, but this is only ever indexed by the packed index\n+ * stored in the @c block_mode and never exists in an unpacked form.\n+ */\n+ const decimation_info& get_decimation_info(unsigned int decimation_mode) const\n+ {\n+ return *this->decimation_tables[decimation_mode];\n+ }\n+\n+ /**\n+ * @brief Get the partition info structure for a given partition count and seed.\n+ */\n+ const partition_info* get_partition_table(unsigned int partition_count) const\n+ {\n+ // TODO: Why do we do this?\n+ if (partition_count == 1)\n+ {\n+ partition_count = 5;\n+ }\n+ unsigned int index = (partition_count - 2) * BLOCK_MAX_PARTITIONINGS;\n+ return this->partitions + index;\n+ }\n+\n+ /**\n+ * @brief Get the partition info structure for a given partition count and seed.\n+ */\n+ const partition_info& get_partition_info(unsigned int partition_count, unsigned int index) const\n+ {\n+ return get_partition_table(partition_count)[index];\n+ }\n};\n// data structure representing one block of an image.\n@@ -869,17 +915,6 @@ void term_block_size_descriptor(\nvoid init_partition_tables(\nblock_size_descriptor& bsd);\n-static inline const partition_info *get_partition_table(\n- const block_size_descriptor* bsd,\n- unsigned int partition_count\n-) {\n- if (partition_count == 1) {\n- partition_count = 5;\n- }\n- unsigned int index = (partition_count - 2) * BLOCK_MAX_PARTITIONINGS;\n- return bsd->partitions + index;\n-}\n-\n/**\n* @brief Get the percentile table for 2D block modes.\n*\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_symbolic_physical.cpp", "new_path": "Source/astcenc_symbolic_physical.cpp", "diff": "@@ -150,10 +150,9 @@ void symbolic_to_physical(\nweightbuf[i] = 0;\n}\n- const decimation_info *const *dt = bsd.decimation_tables;\n- const block_mode& bm = bsd.get_block_mode(scb.block_mode);\n-\n- int weight_count = dt[bm.decimation_mode]->weight_count;\n+ const auto& bm = bsd.get_block_mode(scb.block_mode);\n+ const auto& di = bsd.get_decimation_info(bm.decimation_mode);\n+ int weight_count = di.weight_count;\nquant_method weight_quant_method = bm.get_quant_mode();\nint is_dual_plane = bm.is_dual_plane;\n@@ -276,9 +275,6 @@ void physical_to_symbolic(\nscb.block_type = SYM_BTYPE_NONCONST;\n- // Fetch the decimation tables\n- const decimation_info *const *dt = bsd.decimation_tables;\n-\n// Extract header fields\nint block_mode = read_bits(11, 0, pcb.data);\nif ((block_mode & 0x1FF) == 0x1FC)\n@@ -350,9 +346,11 @@ void physical_to_symbolic(\nscb.block_type = SYM_BTYPE_ERROR;\nreturn;\n}\n- const struct block_mode& bm = bsd.get_block_mode(block_mode);\n- int weight_count = dt[bm.decimation_mode]->weight_count;\n+ const auto& bm = bsd.get_block_mode(block_mode);\n+ const auto& di = bsd.get_decimation_info(bm.decimation_mode);\n+\n+ int weight_count = di.weight_count;\nquant_method weight_quant_method = (quant_method)bm.quant_mode;\nint is_dual_plane = bm.is_dual_plane;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add bsd accessor methods
61,745
23.05.2021 22:03:16
-3,600
b555fed71c5a0adf2587f823d19fc3447032a7d4
Use { 0 } array initializers
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -136,8 +136,6 @@ static void kmeans_init(\n/**\n* @brief Assign texels to clusters, based on a set of chosen center points.\n*\n- * @todo Can partition of texel be uint8_t not int?\n- *\n* @param blk The image block color data to compress.\n* @param texel_count The number of texels in the block.\n* @param partition_count The number of partitions in the block.\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_integer_sequence.cpp", "new_path": "Source/astcenc_integer_sequence.cpp", "diff": "@@ -666,7 +666,7 @@ void decode_ise(\n// temporary results than the number of outputs. The maximum actual number of results is 64 bit,\n// but we keep 4 additional character_count of padding.\nuint8_t results[68];\n- uint8_t tq_blocks[22]; // Trit-blocks or quint-blocks\n+ uint8_t tq_blocks[22] { 0 }; // Trit-blocks or quint-blocks, must be zeroed\nunsigned int bits = btq_counts[quant_level].bits;\nunsigned int trits = btq_counts[quant_level].trits;\n@@ -675,12 +675,6 @@ void decode_ise(\nunsigned int lcounter = 0;\nunsigned int hcounter = 0;\n- // Trit-blocks or quint-blocks must be zeroed out before we collect them in the loop below\n- for (unsigned int i = 0; i < 22; i++)\n- {\n- tq_blocks[i] = 0;\n- }\n-\n// Collect bits for each element, as well as bits for any trit-blocks and quint-blocks.\nfor (unsigned int i = 0; i < character_count; i++)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -641,7 +641,6 @@ struct block_size_descriptor\n*/\nconst partition_info* get_partition_table(unsigned int partition_count) const\n{\n- // TODO: Why do we do this?\nif (partition_count == 1)\n{\npartition_count = 5;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_symbolic_physical.cpp", "new_path": "Source/astcenc_symbolic_physical.cpp", "diff": "@@ -143,12 +143,7 @@ void symbolic_to_physical(\n// Compress the weights.\n// They are encoded as an ordinary integer-sequence, then bit-reversed\n- // TODO: Use { 0 }?\n- uint8_t weightbuf[16] ;\n- for (unsigned int i = 0; i < 16; i++)\n- {\n- weightbuf[i] = 0;\n- }\n+ uint8_t weightbuf[16] { 0 };\nconst auto& bm = bsd.get_block_mode(scb.block_mode);\nconst auto& di = bsd.get_decimation_info(bm.decimation_mode);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use { 0 } array initializers
61,745
23.05.2021 22:42:14
-3,600
8ea0299dc3ccb1e1d28bebbfad6c662c078f84d0
Shrink types and reorder the BSD
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes.cpp", "new_path": "Source/astcenc_block_sizes.cpp", "diff": "@@ -720,7 +720,6 @@ static void assign_kmeans_texels(\nbsd.kmeans_texels[i] = i;\n}\n- bsd.kmeans_texel_count = bsd.texel_count;\nreturn;\n}\n@@ -747,8 +746,6 @@ static void assign_kmeans_texels(\nseen[texel] = true;\n}\n}\n-\n- bsd.kmeans_texel_count = BLOCK_MAX_KMEANS_TEXELS;\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -453,7 +453,7 @@ static void compute_kmeans_partition_ordering(\n// Construct the block bitmaps of texel assignments to each partition\nuint64_t bitmaps[BLOCK_MAX_PARTITIONS] { 0 };\n- unsigned int texels_to_process = bsd.kmeans_texel_count;\n+ unsigned int texels_to_process = astc::min(bsd.texel_count, BLOCK_MAX_KMEANS_TEXELS);\npromise(texels_to_process > 0);\nfor (unsigned int i = 0; i < texels_to_process; i++)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -79,7 +79,7 @@ static constexpr unsigned int BLOCK_MAX_PARTITIONINGS { 1024 };\nstatic constexpr unsigned int BLOCK_MAX_TEXELS { 216 };\n/** @brief The maximum number of weights used during partition selection for texel clustering. */\n-static constexpr unsigned int BLOCK_MAX_KMEANS_TEXELS { 64 };\n+static constexpr uint8_t BLOCK_MAX_KMEANS_TEXELS { 64 };\n/** @brief The maximum number of weights a block can support. */\nstatic constexpr unsigned int BLOCK_MAX_WEIGHTS { 64 };\n@@ -514,8 +514,8 @@ struct decimation_info\n*/\nstruct block_mode\n{\n- int16_t mode_index;\n- int8_t decimation_mode;\n+ uint16_t mode_index;\n+ uint8_t decimation_mode;\nuint8_t quant_mode;\nuint8_t is_dual_plane : 1;\nuint8_t percentile_hit : 1;\n@@ -560,44 +560,41 @@ struct decimation_mode\nstruct block_size_descriptor\n{\n/** @brief The block X dimension, in texels. */\n- unsigned int xdim;\n+ uint8_t xdim;\n/** @brief The block Y dimension, in texels. */\n- unsigned int ydim;\n+ uint8_t ydim;\n/** @brief The block Z dimension, in texels. */\n- unsigned int zdim;\n+ uint8_t zdim;\n/** @brief The block total texel count. */\n- unsigned int texel_count;\n+ uint8_t texel_count;\n/** @brief The number of stored decimation modes. */\nunsigned int decimation_mode_count;\n+ /** @brief The number of stored block modes. */\n+ unsigned int block_mode_count;\n+\n/** @brief The active decimation modes, stored in low indices. */\ndecimation_mode decimation_modes[WEIGHTS_MAX_DECIMATION_MODES];\n/** @brief The active decimation tables, stored in low indices. */\nconst decimation_info *decimation_tables[WEIGHTS_MAX_DECIMATION_MODES];\n- /** @brief The number of stored block modes. */\n- unsigned int block_mode_count;\n-\n/** @brief The packed block mode array index, or @c BLOCK_BAD_BLOCK_MODE if not active. */\nuint16_t block_mode_packed_index[WEIGHTS_MAX_BLOCK_MODES];\n/** @brief The active block modes, stored in low indices. */\nblock_mode block_modes[WEIGHTS_MAX_BLOCK_MODES];\n- /** @brief The texel count for k-means partition selection. */\n- unsigned int kmeans_texel_count;\n-\n- /** @brief The active texels for k-means partition selection. */\n- unsigned int kmeans_texels[BLOCK_MAX_KMEANS_TEXELS];\n-\n/** @brief The partion tables for all of the possible partitions. */\npartition_info partitions[(3 * BLOCK_MAX_PARTITIONINGS) + 1];\n+ /** @brief The active texels for k-means partition selection. */\n+ uint8_t kmeans_texels[BLOCK_MAX_KMEANS_TEXELS];\n+\n/**\n* @brief Get the block mode structure for index @c block_mode.\n*\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_partition_tables.cpp", "new_path": "Source/astcenc_partition_tables.cpp", "diff": "@@ -348,7 +348,7 @@ static void generate_one_partition_info_entry(\npi.coverage_bitmaps[i] = 0ULL;\n}\n- unsigned int texels_to_process = bsd.kmeans_texel_count;\n+ unsigned int texels_to_process = astc::min(bsd.texel_count, BLOCK_MAX_KMEANS_TEXELS);\nfor (unsigned int i = 0; i < texels_to_process; i++)\n{\nunsigned int idx = bsd.kmeans_texels[i];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Shrink types and reorder the BSD
61,745
23.05.2021 22:45:09
-3,600
d2b03bee9e8dca1b82785155d26374efc00e93cc
Match constants to struct type
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -798,16 +798,16 @@ struct quantization_and_transfer_table\nextern const quantization_and_transfer_table quant_and_xfer_tables[12];\n/** @brief The block is an error block, and will return error color or NaN. */\n-static constexpr unsigned int SYM_BTYPE_ERROR { 0 };\n+static constexpr uint8_t SYM_BTYPE_ERROR { 0 };\n/** @brief The block is a constant color block using FP16 colors. */\n-static constexpr unsigned int SYM_BTYPE_CONST_F16 { 1 };\n+static constexpr uint8_t SYM_BTYPE_CONST_F16 { 1 };\n/** @brief The block is a constant color block using UNORM16 colors. */\n-static constexpr unsigned int SYM_BTYPE_CONST_U16 { 2 };\n+static constexpr uint8_t SYM_BTYPE_CONST_U16 { 2 };\n/** @brief The block is a normal non-constant color block. */\n-static constexpr unsigned int SYM_BTYPE_NONCONST { 3 };\n+static constexpr uint8_t SYM_BTYPE_NONCONST { 3 };\n/**\n* @brief A symbolic representation of a compressed block.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Match constants to struct type
61,745
23.05.2021 23:16:37
-3,600
c6788b26ba3ff25b0c74e5b0ae4f296c04c34145
More unsigned ints ...
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "#include <cassert>\n#include <cstring>\n-#define ANGULAR_STEPS 40\n+\n+static constexpr unsigned int ANGULAR_STEPS { 40 };\n+\n+// Store a reduced sin/cos table for 64 possible weight values; this causes slight quality loss\n+// compared to using sin() and cos() directly. Must be 2^N.\n+static constexpr unsigned int SINCOS_STEPS { 64 };\nstatic_assert((ANGULAR_STEPS % ASTCENC_SIMD_WIDTH) == 0,\n\"ANGULAR_STEPS must be multiple of ASTCENC_SIMD_WIDTH\");\n-static int max_angular_steps_needed_for_quant_level[13];\n+static unsigned int max_angular_steps_needed_for_quant_level[13];\n// The next-to-last entry is supposed to have the value 33. This because the 32-weight mode leaves a\n// double-sized hole in the middle of the weight space, so we are better off matching 33 weights.\n-static const int quantization_steps_for_level[13] = {\n+static const unsigned int quantization_steps_for_level[13] = {\n2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 33, 36\n};\n-// Store a reduced sin/cos table for 64 possible weight values; this causes slight quality loss\n-// compared to using sin() and cos() directly. Must be 2^N.\n-#define SINCOS_STEPS 64\n-\nalignas(ASTCENC_VECALIGN) static float sin_table[SINCOS_STEPS][ANGULAR_STEPS];\nalignas(ASTCENC_VECALIGN) static float cos_table[SINCOS_STEPS][ANGULAR_STEPS];\n/* See header for documentation. */\nvoid prepare_angular_tables()\n{\n- int max_angular_steps_needed_for_quant_steps[ANGULAR_STEPS + 1];\n- for (int i = 0; i < ANGULAR_STEPS; i++)\n+ unsigned int max_angular_steps_needed_for_quant_steps[ANGULAR_STEPS + 1];\n+ for (unsigned int i = 0; i < ANGULAR_STEPS; i++)\n{\nfloat angle_step = (float)(i + 1);\n- for (int j = 0; j < SINCOS_STEPS; j++)\n+ for (unsigned int j = 0; j < SINCOS_STEPS; j++)\n{\nsin_table[j][i] = static_cast<float>(sinf((2.0f * astc::PI / (SINCOS_STEPS - 1.0f)) * angle_step * static_cast<float>(j)));\ncos_table[j][i] = static_cast<float>(cosf((2.0f * astc::PI / (SINCOS_STEPS - 1.0f)) * angle_step * static_cast<float>(j)));\n@@ -81,7 +82,7 @@ void prepare_angular_tables()\nmax_angular_steps_needed_for_quant_steps[i + 1] = astc::min(i + 1, ANGULAR_STEPS - 1);\n}\n- for (int i = 0; i < 13; i++)\n+ for (unsigned int i = 0; i < 13; i++)\n{\nmax_angular_steps_needed_for_quant_level[i] = max_angular_steps_needed_for_quant_steps[quantization_steps_for_level[i]];\n}\n@@ -97,10 +98,10 @@ void prepare_angular_tables()\n* @param[out] offsets The output angular offsets array.\n*/\nstatic void compute_angular_offsets(\n- int sample_count,\n+ unsigned int sample_count,\nconst float* samples,\nconst float* sample_weights,\n- int max_angular_steps,\n+ unsigned int max_angular_steps,\nfloat* offsets\n) {\npromise(sample_count > 0);\n@@ -109,7 +110,7 @@ static void compute_angular_offsets(\nalignas(ASTCENC_VECALIGN) int isamplev[BLOCK_MAX_WEIGHTS] { 0 };\n// Precompute isample; arrays are always allocated 64 elements long\n- for (int i = 0; i < sample_count; i += ASTCENC_SIMD_WIDTH)\n+ for (unsigned int i = 0; i < sample_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Add 2^23 and interpreting bits extracts round-to-nearest int\nvfloat sample = loada(samples + i) * (SINCOS_STEPS - 1.0f) + vfloat(12582912.0f);\n@@ -120,12 +121,12 @@ static void compute_angular_offsets(\n// Arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\nvfloat mult = vfloat(1.0f / (2.0f * astc::PI));\n- for (int i = 0; i < max_angular_steps; i += ASTCENC_SIMD_WIDTH)\n+ for (unsigned int i = 0; i < max_angular_steps; i += ASTCENC_SIMD_WIDTH)\n{\nvfloat anglesum_x = vfloat::zero();\nvfloat anglesum_y = vfloat::zero();\n- for (int j = 0; j < sample_count; j++)\n+ for (unsigned int j = 0; j < sample_count; j++)\n{\nint isample = isamplev[j];\nvfloat sample_weightv(sample_weights[j]);\n@@ -159,11 +160,11 @@ static void compute_angular_offsets(\n* @param[out] cut_high_weight_error Per angular step, the high weight cut error.\n*/\nstatic void compute_lowest_and_highest_weight(\n- int sample_count,\n+ unsigned int sample_count,\nconst float* samples,\nconst float* sample_weights,\n- int max_angular_steps,\n- int max_quant_steps,\n+ unsigned int max_angular_steps,\n+ unsigned int max_quant_steps,\nconst float* offsets,\nint* lowest_weight,\nint* weight_span,\n@@ -177,7 +178,7 @@ static void compute_lowest_and_highest_weight(\nvfloat rcp_stepsize = vfloat::lane_id() + vfloat(1.0f);\n// Arrays are ANGULAR_STEPS long, so always safe to run full vectors\n- for (int sp = 0; sp < max_angular_steps; sp += ASTCENC_SIMD_WIDTH)\n+ for (unsigned int sp = 0; sp < max_angular_steps; sp += ASTCENC_SIMD_WIDTH)\n{\nvint minidx(128);\nvint maxidx(-128);\n@@ -186,7 +187,7 @@ static void compute_lowest_and_highest_weight(\nvfloat cut_high_weight_err = vfloat::zero();\nvfloat offset = loada(&offsets[sp]);\n- for (int j = 0; j < sample_count; ++j)\n+ for (unsigned int j = 0; j < sample_count; ++j)\n{\nvfloat wt = load1(&sample_weights[j]);\nvfloat sval = load1(&samples[j]) * rcp_stepsize - offset;\n@@ -247,17 +248,17 @@ static void compute_lowest_and_highest_weight(\n* @param[out] high_value Per angular step, the highest weight value.\n*/\nstatic void compute_angular_endpoints_for_quant_levels(\n- int sample_count,\n+ unsigned int sample_count,\nconst float* samples,\nconst float* sample_weights,\n- int max_quant_level,\n+ unsigned int max_quant_level,\nfloat low_value[12],\nfloat high_value[12]\n) {\n- int max_quant_steps = quantization_steps_for_level[max_quant_level];\n+ unsigned int max_quant_steps = quantization_steps_for_level[max_quant_level];\nalignas(ASTCENC_VECALIGN) float angular_offsets[ANGULAR_STEPS];\n- int max_angular_steps = max_angular_steps_needed_for_quant_level[max_quant_level];\n+ unsigned int max_angular_steps = max_angular_steps_needed_for_quant_level[max_quant_level];\ncompute_angular_offsets(sample_count, samples, sample_weights, max_angular_steps, angular_offsets);\nalignas(ASTCENC_VECALIGN) int32_t lowest_weight[ANGULAR_STEPS];\n@@ -278,7 +279,7 @@ static void compute_angular_endpoints_for_quant_levels(\n// Initialize the array to some safe defaults\npromise(max_quant_steps > 0);\n- for (int i = 0; i < (max_quant_steps + 4); i++)\n+ for (unsigned int i = 0; i < (max_quant_steps + 4); i++)\n{\n// Lane<0> = Best error\n// Lane<1> = Best scale; -1 indicates no solution found\n@@ -287,7 +288,7 @@ static void compute_angular_endpoints_for_quant_levels(\n}\npromise(max_angular_steps > 0);\n- for (int i = 0; i < max_angular_steps; i++)\n+ for (unsigned int i = 0; i < max_angular_steps; i++)\n{\nint idx_span = weight_span[i];\nfloat error_cut_low = error[i] + cut_low_weight_error[i];\n@@ -323,7 +324,7 @@ static void compute_angular_endpoints_for_quant_levels(\n// If we get a better error for lower sample count then use the lower sample count's error for\n// the higher sample count as well.\n- for (int i = 3; i <= max_quant_steps; i++)\n+ for (unsigned int i = 3; i <= max_quant_steps; i++)\n{\nvfloat4 result = best_results[i];\nvfloat4 prev_result = best_results[i - 1];\n@@ -332,9 +333,9 @@ static void compute_angular_endpoints_for_quant_levels(\n}\npromise(max_quant_level >= 0);\n- for (int i = 0; i <= max_quant_level; i++)\n+ for (unsigned int i = 0; i <= max_quant_level; i++)\n{\n- int q = quantization_steps_for_level[i];\n+ unsigned int q = quantization_steps_for_level[i];\nint bsi = (int)best_results[q].lane<1>();\n// Did we find anything?\n@@ -397,8 +398,8 @@ void compute_angular_endpoints_1plane(\ncontinue;\n}\n- int quant_mode = bm.quant_mode;\n- int decim_mode = bm.decimation_mode;\n+ unsigned int quant_mode = bm.quant_mode;\n+ unsigned int decim_mode = bm.decimation_mode;\nlow_value[i] = low_values[decim_mode][quant_mode];\nhigh_value[i] = high_values[decim_mode][quant_mode];\n@@ -429,7 +430,7 @@ void compute_angular_endpoints_2planes(\ncontinue;\n}\n- int sample_count = bsd.decimation_tables[i]->weight_count;\n+ unsigned int sample_count = bsd.decimation_tables[i]->weight_count;\ncompute_angular_endpoints_for_quant_levels(\nsample_count,\n@@ -453,8 +454,8 @@ void compute_angular_endpoints_2planes(\ncontinue;\n}\n- int quant_mode = bm.quant_mode;\n- int decim_mode = bm.decimation_mode;\n+ unsigned int quant_mode = bm.quant_mode;\n+ unsigned int decim_mode = bm.decimation_mode;\nlow_value1[i] = low_values1[decim_mode][quant_mode];\nhigh_value1[i] = high_values1[decim_mode][quant_mode];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
More unsigned ints ...
61,745
23.05.2021 23:40:51
-3,600
f6921718a5d15adfc6bf41ae63b1d50dfd70dbb1
Remove unneeded short len safety net
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -279,11 +279,6 @@ void compute_avgs_and_dirs_3_comp(\nbest_vector = sum_zp;\n}\n- if (dot3_s(best_vector, best_vector) < 1e-18f)\n- {\n- best_vector = vfloat3(1.0f, 1.0f, 1.0f);\n- }\n-\npm[partition].dir = best_vector;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -374,7 +374,7 @@ static void compute_ideal_colors_and_weights_3_comp(\nvfloat4 dir = pms[i].dir;\nif (hadd_rgb_s(dir) < 0.0f)\n{\n- dir = vfloat4(0.0f) - dir;\n+ dir = vfloat4::zero() - dir;\n}\nlines[i].a = pms[i].avg;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove unneeded short len safety net
61,745
24.05.2021 22:18:26
-3,600
b1f5b8563ad75ebbb0248e3e001528bfcba3afb4
Remove TODO; manual permutes not needed
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -148,8 +148,6 @@ struct vfloat4\n/**\n* @brief Return a swizzled float 2.\n- *\n- * TODO: Implement using permutes.\n*/\ntemplate <int l0, int l1> ASTCENC_SIMD_INLINE vfloat4 swz() const\n{\n@@ -158,8 +156,6 @@ struct vfloat4\n/**\n* @brief Return a swizzled float 3.\n- *\n- * TODO: Implement using permutes.\n*/\ntemplate <int l0, int l1, int l2> ASTCENC_SIMD_INLINE vfloat4 swz() const\n{\n@@ -168,8 +164,6 @@ struct vfloat4\n/**\n* @brief Return a swizzled float 4.\n- *\n- * TODO: Implement using permutes.\n*/\ntemplate <int l0, int l1, int l2, int l3> ASTCENC_SIMD_INLINE vfloat4 swz() const\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove TODO; manual permutes not needed
61,745
24.05.2021 23:45:51
-3,600
886d1a321e2aa857f7ccc879f501e8850750a5bc
Cleanups and documentation for astcenc_internal
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1391,11 +1391,11 @@ void compress_block(\ntrace_add_data(\"pos_z\", blk->zpos);\n// Set stricter block targets for luminance data as we have more bits to play with\n- bool block_is_l = imageblock_is_lum(&blk);\n+ bool block_is_l = blk.is_luminance();\nfloat block_is_l_scale = block_is_l ? 1.0f / 1.5f : 1.0f;\n// Set slightly stricter block targets for lumalpha data as we have more bits to play with\n- bool block_is_la = imageblock_is_lumalp(&blk);\n+ bool block_is_la = blk.is_luminancealpha();\nfloat block_is_la_scale = block_is_la ? 1.0f / 1.05f : 1.0f;\nbool block_skip_two_plane = false;\n@@ -1472,7 +1472,7 @@ void compress_block(\nbest_errorvals_in_modes[i] = 1e30f;\n}\n- int uses_alpha = imageblock_uses_alpha(&blk);\n+ bool uses_alpha = blk.is_using_alpha();\n// Trial using 1 plane of weights and 1 partition.\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -1242,8 +1242,8 @@ astcenc_error astcenc_get_block_info(\ninfo->partition_index = scb.partition_index;\ninfo->dual_plane_component = scb.plane2_component;\n- info->color_level_count = get_quant_method_levels((quant_method)scb.color_quant_level);\n- info->weight_level_count = get_quant_method_levels(bm.get_quant_mode());\n+ info->color_level_count = get_quant_level((quant_method)scb.color_quant_level);\n+ info->weight_level_count = get_quant_level(bm.get_quant_mode());\n// Unpack color endpoints for each active partition\nfor (unsigned int i = 0; i < scb.partition_count; i++)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -505,7 +505,7 @@ void find_best_partition_candidates(\nunsigned int partition_sequence[BLOCK_MAX_PARTITIONINGS];\ncompute_kmeans_partition_ordering(bsd, blk, partition_count, partition_sequence);\n- int uses_alpha = imageblock_uses_alpha(&blk);\n+ bool uses_alpha = blk.is_using_alpha();\n// Partitioning errors assuming uncorrelated-chrominance endpoints\nfloat uncor_best_error { ERROR_CALC_DEFAULT };\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -604,8 +604,7 @@ void compute_ideal_colors_and_weights_1plane(\nconst partition_info& pi,\nendpoints_and_weights& ei\n) {\n- int uses_alpha = imageblock_uses_alpha(&blk);\n- if (uses_alpha)\n+ if (blk.is_using_alpha())\n{\ncompute_ideal_colors_and_weights_4_comp(bsd, blk, ewb, pi, ei);\n}\n@@ -625,7 +624,7 @@ void compute_ideal_colors_and_weights_2planes(\nendpoints_and_weights& ei1,\nendpoints_and_weights& ei2\n) {\n- bool uses_alpha = imageblock_uses_alpha(&blk);\n+ bool uses_alpha = blk.is_using_alpha();;\nassert(plane2_component < BLOCK_MAX_COMPONENTS);\nswitch (plane2_component)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -353,7 +353,11 @@ public:\n}\n};\n-\n+/**\n+ * @brief The ASTC endpoint formats.\n+ *\n+ * Note, the values here are used directly in the encoding in the format so do not rearrange.\n+ */\nenum endpoint_formats\n{\nFMT_LUMINANCE = 0,\n@@ -374,7 +378,11 @@ enum endpoint_formats\nFMT_HDR_RGBA = 15\n};\n-// enumeration of all the quantization methods we support under this format.\n+/**\n+ * @brief The ASTC quantization methods.\n+ *\n+ * Note, the values here are used directly in the encoding in the format so do not rearrange.\n+ */\nenum quant_method\n{\nQUANT_2 = 0,\n@@ -400,7 +408,14 @@ enum quant_method\nQUANT_256 = 20\n};\n-static inline unsigned int get_quant_method_levels(quant_method method)\n+/**\n+ * @brief The number of levels use by an ASTC quantization method.\n+ *\n+ * @param method The quantization method\n+ *\n+ * @return The number of levels used by @c method.\n+ */\n+static inline unsigned int get_quant_level(quant_method method)\n{\nswitch(method)\n{\n@@ -430,97 +445,177 @@ static inline unsigned int get_quant_method_levels(quant_method method)\n}\n}\n+/**\n+ * @brief Computed metrics about a partition in a block.\n+ */\nstruct partition_metrics\n{\n+ /** @brief The square of the color range (max - min) spanned by texels in this partition. */\nvfloat4 range_sq;\n+\n+ /** @brief The sum of the error weights for texels in this partition. */\nvfloat4 error_weight;\n- vfloat4 icolor_scale;\n+\n+ /** @brief The color scale factor used to weight color channels. */\nvfloat4 color_scale;\n+\n+ /** @brief The 1 / color_scale used to avoid divisions. */\n+ vfloat4 icolor_scale;\n+\n+ /** @brief The error-weighted average color in the partition. */\nvfloat4 avg;\n+\n+ /** @brief The dominant error-weighted direction in the partition. */\nvfloat4 dir;\n};\n+/**\n+ * @brief Computed lines for a a three component analysis.\n+ */\nstruct partition_lines3\n{\n+ /** @brief Line for uncorrelated chroma. */\nline3 uncor_line;\n+\n+ /** @brief Line for correlated chroma, passing though the origin. */\nline3 samec_line;\n+ /** @brief Postprocessed line for uncorrelated chroma. */\nprocessed_line3 uncor_pline;\n+\n+ /** @brief Postprocessed line for correlated chroma, passing though the origin. */\nprocessed_line3 samec_pline;\n+ /** @brief The length of the line for uncorrelated chroma. */\nfloat uncor_line_len;\n+\n+ /** @brief The length of the line for correlated chroma. */\nfloat samec_line_len;\n};\n-/*\n- Partition table representation:\n- For each block size, we have 3 tables, each with 1024 partitionings;\n- these three tables correspond to 2, 3 and 4 partitions respectively.\n- For each partitioning, we have:\n- * a 4-entry table indicating how many texels there are in each of the 4 partitions.\n- This may be from 0 to a very large value.\n- * a table indicating the partition index of each of the texels in the block.\n- Each index may be 0, 1, 2 or 3.\n- * Each element in the table is an uint8_t indicating partition index (0, 1, 2 or 3)\n+/**\n+ * @brief The partition information for a single partition.\n+ *\n+ * ASTC has a total of 1024 candidate partitions for each of 2/3/4 partition counts, although this\n+ * 1024 includes seeds that generate duplicates of other seeds and seeds that generate completely\n+ * empty partitions. These are both valid encodings, but astcenc will skip both during compression\n+ * as they are not useful.\n*/\nstruct partition_info\n{\n+ /** @brief The number of partitions in this partitioning. */\nunsigned int partition_count;\n+\n+ /**\n+ * @brief The number of texels in each partition.\n+ *\n+ * Note that some seeds result in zero texels assigned to a partition are valid, but are skipped\n+ * by this compressor as there is no point spending bits encoding an unused color endpoint.\n+ */\nuint8_t partition_texel_count[BLOCK_MAX_PARTITIONS];\n+\n+ /** @brief The partition of each texel in the block. */\nuint8_t partition_of_texel[BLOCK_MAX_TEXELS];\n+\n+ /** @brief The list of texels in each partition. */\nuint8_t texels_of_partition[BLOCK_MAX_PARTITIONS][BLOCK_MAX_TEXELS];\n+\n+ /** @brief The canonical partition coverage pattern used during block partition search. */\nuint64_t coverage_bitmaps[BLOCK_MAX_PARTITIONS];\n};\n-/*\n- In ASTC, we don't necessarily provide a weight for every texel.\n- As such, for each block size, there are a number of patterns where some texels\n- have their weights computed as a weighted average of more than 1 weight.\n- As such, the codec uses a data structure that tells us: for each texel, which\n- weights it is a combination of for each weight, which texels it contributes to.\n- The decimation_table is this data structure.\n+/**\n+ * @brief The weight grid information for a single decimation pattern.\n+ *\n+ * ASTC can store one weight per texel, but is also capable of storing lower resoution weight grids\n+ * that are interpolated during decompression to assign a with to a texel. Storing fewer weights\n+ * can free up a substantial amount of bits that we can then spend on more useful things, such as\n+ * more accurate endpoints and weights, or additional partitions.\n+ *\n+ * This data structure is used to store information about a single weight grid decimation pattern,\n+ * for a single block size.\n*/\nstruct decimation_info\n{\n+ /** @brief The total number of texels in the block. */\nuint8_t texel_count;\n+\n+ /** @brief The total number of weights stored. */\nuint8_t weight_count;\n+\n+ /** @brief The number of stored weights in the X dimension. */\nuint8_t weight_x;\n+\n+ /** @brief The number of stored weights in the Y dimension. */\nuint8_t weight_y;\n+\n+ /** @brief The number of stored weights in the Z dimension. */\nuint8_t weight_z;\n- uint8_t texel_weight_count[BLOCK_MAX_TEXELS]; // number of indices that go into the calculation for a texel\n+ /** @brief The number of stored weights that contribute to each texel, between 1 and 4. */\n+ uint8_t texel_weight_count[BLOCK_MAX_TEXELS];\n+\n+ /** @brief The weight index of the N weights that need to be interpolated for each texel. */\n+ uint8_t texel_weights_4t[4][BLOCK_MAX_TEXELS];\n+\n+ /** @brief The bilinear interpolation weighting of the N input weights for each texel, between 0 and 16. */\n+ uint8_t texel_weights_int_4t[4][BLOCK_MAX_TEXELS];\n+\n+ /** @brief The bilinear interpolation weighting of the N input weights for each texel, between 0 and 1. */\n+ alignas(ASTCENC_VECALIGN) float texel_weights_float_4t[4][BLOCK_MAX_TEXELS];\n- // The 4t and t4 tables are the same data, but transposed to allow optimal\n- // data access patterns depending on how we can unroll loops\n- alignas(ASTCENC_VECALIGN) float texel_weights_float_4t[4][BLOCK_MAX_TEXELS]; // the weight to assign to each weight\n- alignas(ASTCENC_VECALIGN) uint8_t texel_weights_4t[4][BLOCK_MAX_TEXELS]; // the weights that go into a texel calculation\n- alignas(ASTCENC_VECALIGN) uint8_t texel_weights_int_4t[4][BLOCK_MAX_TEXELS]; // the weight to assign to each weight\n+ /** @brief The number of texels that each stored weight contributes to. */\n+ uint8_t weight_texel_count[BLOCK_MAX_WEIGHTS];\n- uint8_t weight_texel_count[BLOCK_MAX_WEIGHTS]; // the number of texels that a given weight contributes to\n+ /** @brief The list of weights that contribute to each texel. */\n+ uint8_t weight_texel[BLOCK_MAX_TEXELS][BLOCK_MAX_WEIGHTS];\n- // Stored transposed to give better access patterns\n- uint8_t weight_texel[BLOCK_MAX_TEXELS][BLOCK_MAX_WEIGHTS]; // the texels that the weight contributes to\n- alignas(ASTCENC_VECALIGN) float weights_flt[BLOCK_MAX_TEXELS][BLOCK_MAX_WEIGHTS]; // the weights that the weight contributes to a texel.\n+ /** @brief The list of weight indices that contribute to each texel. */\n+ alignas(ASTCENC_VECALIGN) float weights_flt[BLOCK_MAX_TEXELS][BLOCK_MAX_WEIGHTS];\n- // folded data structures:\n- // * texel_weights_texel[i][j] = texel_weights[weight_texel[i][j]];\n- // * texel_weights_float_texel[i][j] = texel_weights_float[weight_texel[i][j]]\n+ /**\n+ * @brief Folded structure for faster access:\n+ * texel_weights_texel[i][j][.] = texel_weights[.][weight_texel[i][j]]\n+ */\nuint8_t texel_weights_texel[BLOCK_MAX_WEIGHTS][BLOCK_MAX_TEXELS][4];\n+\n+ /**\n+ * @brief Folded structure for faster access:\n+ * texel_weights_float_texel[i][j][.] = texel_weights_float[.][weight_texel[i][j]]\n+ */\nfloat texel_weights_float_texel[BLOCK_MAX_WEIGHTS][BLOCK_MAX_TEXELS][4];\n};\n/**\n- * @brief Metadata for single block mode for a specific BSD.\n+ * @brief Metadata for single block mode for a specific block size.\n*/\nstruct block_mode\n{\n+ /** @brief The block mode index in the ASTC encoded form. */\nuint16_t mode_index;\n+\n+ /** @brief The decimation mode index in the compressor reindexed list. */\nuint8_t decimation_mode;\n+\n+ /** @brief The weight quantization used by this block mode. */\nuint8_t quant_mode;\n+\n+ /** @brief Is a dual weight plane used by this block mode? */\nuint8_t is_dual_plane : 1;\n+\n+ /** @brief Is this mode enabled in the current search preset? */\nuint8_t percentile_hit : 1;\n+\n+ /** @brief Is this mode enabled for early fast-path searches in the current search preset? */\nuint8_t percentile_always : 1;\n+ /**\n+ * @brief Get the weight quantization used by this block mode.\n+ *\n+ * @return The quantization level.\n+ */\n+ // TODO: Rename this to get_weight_quant_mode, and add accessor to scb for\n+ // get_color_quant_mode.\ninline quant_method get_quant_mode() const\n{\nreturn (quant_method)this->quant_mode;\n@@ -528,13 +623,20 @@ struct block_mode\n};\n/**\n- * @brief Metadata for single decimation mode for a specific BSD.\n+ * @brief Metadata for single decimation mode for a specific block size.\n*/\nstruct decimation_mode\n{\n+ /** @brief The max weight precision for 1 plane, or -1 if not supported. */\nint8_t maxprec_1plane;\n+\n+ /** @brief The max weight precision for 2 planes, or -1 if not supported. */\nint8_t maxprec_2planes;\n+\n+ /** @brief Is this mode enabled in the current search preset? */\nuint8_t percentile_hit : 1;\n+\n+ /** @brief Is this mode enabled for early fast-path searches in the current search preset? */\nuint8_t percentile_always : 1;\n};\n@@ -601,6 +703,10 @@ struct block_size_descriptor\n* This function can only return block modes that are enabled by the current compressor config.\n* Decompression from an arbitrary source should not use this without first checking that the\n* packed block mode index is not @c BLOCK_BAD_BLOCK_MODE.\n+ *\n+ * @param block_mode The packed block mode index.\n+ *\n+ * @return The block mode structure.\n*/\nconst block_mode& get_block_mode(unsigned int block_mode) const\n{\n@@ -615,6 +721,10 @@ struct block_size_descriptor\n* This function can only return decimation modes that are enabled by the current compressor\n* config. The mode array is stored packed, but this is only ever indexed by the packed index\n* stored in the @c block_mode and never exists in an unpacked form.\n+ *\n+ * @param decimation_mode The packed decimation mode index.\n+ *\n+ * @return The decimation mode structure.\n*/\nconst decimation_mode& get_decimation_mode(unsigned int decimation_mode) const\n{\n@@ -627,6 +737,10 @@ struct block_size_descriptor\n* This function can only return decimation modes that are enabled by the current compressor\n* config. The mode array is stored packed, but this is only ever indexed by the packed index\n* stored in the @c block_mode and never exists in an unpacked form.\n+ *\n+ * @param decimation_mode The packed decimation mode index.\n+ *\n+ * @return The decimation info structure.\n*/\nconst decimation_info& get_decimation_info(unsigned int decimation_mode) const\n{\n@@ -634,7 +748,11 @@ struct block_size_descriptor\n}\n/**\n- * @brief Get the partition info structure for a given partition count and seed.\n+ * @brief Get the partition info table for a given partition count.\n+ *\n+ * @param partition_count The number of partitions we want the table for.\n+ *\n+ * @return The pointer to the table of 1024 entries (for 2/3/4 parts) or 1 entry (for 1 part).\n*/\nconst partition_info* get_partition_table(unsigned int partition_count) const\n{\n@@ -648,6 +766,11 @@ struct block_size_descriptor\n/**\n* @brief Get the partition info structure for a given partition count and seed.\n+ *\n+ * @param partition_count The number of partitions we want the info for.\n+ * @param index The partition seed (between 0 and 1023).\n+ *\n+ * @return The partition info structure.\n*/\nconst partition_info& get_partition_info(unsigned int partition_count, unsigned int index) const\n{\n@@ -655,28 +778,65 @@ struct block_size_descriptor\n}\n};\n-// data structure representing one block of an image.\n-// it is expanded to float prior to processing to save some computation time\n-// on conversions to/from uint8_t (this also allows us to handle HDR textures easily)\n+/**\n+ * @brief The image data for a single block.\n+ *\n+ * The @c data_[rgba] fields store the image data in an encoded SoA float form designed for easy\n+ * vectorization. Input data is converted to float and stored as values between 0 and 65535. LDR\n+ * data is stored as direct UNORM data, HDR data is stored as LNS data.\n+ *\n+ * The @c rgb_lns and @c alpha_lns fields that assigned a per-texel use of HDR are only used during\n+ * decompression. The current compressor will always use HDR endpoint formats when in HDR mode.\n+ */\n+// TODO: Rename this image_block?\nstruct imageblock\n{\n- float data_r[BLOCK_MAX_TEXELS]; // the data that we will compress, either linear or LNS (0..65535 in both cases)\n+ /** @brief The input (compress) or output (decompress) data for the red color component. */\n+ float data_r[BLOCK_MAX_TEXELS];\n+\n+ /** @brief The input (compress) or output (decompress) data for the green color component. */\nfloat data_g[BLOCK_MAX_TEXELS];\n+\n+ /** @brief The input (compress) or output (decompress) data for the blue color component. */\nfloat data_b[BLOCK_MAX_TEXELS];\n+\n+ /** @brief The input (compress) or output (decompress) data for the alpha color component. */\nfloat data_a[BLOCK_MAX_TEXELS];\n+ /** @brief The original data for texel 0 for constant color block encoding. */\nvfloat4 origin_texel;\n+\n+ /** @brief The min component value of all texels in the block. */\nvfloat4 data_min;\n+\n+ /** @brief The max component value of all texels in the block. */\nvfloat4 data_max;\n+\n+ /** @brief Is this greyscale block where R == G == B for all texels? */\nbool grayscale;\n- uint8_t rgb_lns[BLOCK_MAX_TEXELS]; // 1 if RGB data are being treated as LNS\n- uint8_t alpha_lns[BLOCK_MAX_TEXELS]; // 1 if Alpha data are being treated as LNS\n+ /** @brief Set to 1 if a texel is using HDR RGB endpoints (decompression only). */\n+ uint8_t rgb_lns[BLOCK_MAX_TEXELS];\n+ /** @brief Set to 1 if a texel is using HDR alpha endpoints (decompression only). */\n+ uint8_t alpha_lns[BLOCK_MAX_TEXELS];\n+\n+ /** @brief The X position of this block in the input or output image. */\nunsigned int xpos;\n+\n+ /** @brief The Y position of this block in the input or output image. */\nunsigned int ypos;\n+\n+ /** @brief The Z position of this block in the input or output image. */\nunsigned int zpos;\n+ /**\n+ * @brief Get an RGBA texel value from the data.\n+ *\n+ * @param index The texel index.\n+ *\n+ * @return The texel in RGBA component ordering.\n+ */\ninline vfloat4 texel(unsigned int index) const\n{\nreturn vfloat4(data_r[index],\n@@ -685,40 +845,72 @@ struct imageblock\ndata_a[index]);\n}\n+ /**\n+ * @brief Get an RGB texel value from the data.\n+ *\n+ * @param index The texel index.\n+ *\n+ * @return The texel in RGB0 component ordering.\n+ */\ninline vfloat4 texel3(unsigned int index) const\n{\nreturn vfloat3(data_r[index],\ndata_g[index],\ndata_b[index]);\n}\n-};\n-// TODO: Convert these to ib member functions\n-static inline float imageblock_default_alpha(const imageblock * blk)\n+ /**\n+ * @brief Get the default alpha value for endpoints that don't store it.\n+ *\n+ * The default depends on whether the alpha endpoint is LDR or HDR.\n+ *\n+ * @return The alpha value in the scaled range used by the compressor.\n+ */\n+ inline float get_default_alpha() const\n{\n- return blk->alpha_lns[0] ? (float)0x7800 : (float)0xFFFF;\n+ return this->alpha_lns[0] ? (float)0x7800 : (float)0xFFFF;\n}\n-static inline bool imageblock_uses_alpha(const imageblock * blk)\n+ /**\n+ * @brief Test if this block is using alpha.\n+ *\n+ * @todo This looks suspect, but matches the original astcenc 1.7 code. This checks that the\n+ * alpha is not constant (no weight needed), NOT that it is 1.0 and not stored as an endpoint.\n+ * Review all uses of this function and check that it is sensible ...\n+ *\n+ * @return @c true if the alpha value is not constant across the block, @c false otherwise.\n+ */\n+ inline bool is_using_alpha() const\n{\n- return blk->data_min.lane<3>() != blk->data_max.lane<3>();\n+ return this->data_min.lane<3>() != this->data_max.lane<3>();\n}\n-static inline bool imageblock_is_lum(const imageblock * blk)\n+ /**\n+ * @brief Test if this block is a luminance block with constant 1.0 alpha.\n+ *\n+ * @return @c true if the block is a luminance block , @c false otherwise.\n+ */\n+ inline bool is_luminance() const\n{\n- float default_alpha = imageblock_default_alpha(blk);\n- bool alpha1 = (blk->data_min.lane<3>() == default_alpha) &&\n- (blk->data_max.lane<3>() == default_alpha);\n- return blk->grayscale && alpha1;\n+ float default_alpha = this->get_default_alpha();\n+ bool alpha1 = (this->data_min.lane<3>() == default_alpha) &&\n+ (this->data_max.lane<3>() == default_alpha);\n+ return this->grayscale && alpha1;\n}\n-static inline bool imageblock_is_lumalp(const imageblock * blk)\n+ /**\n+ * @brief Test if this block is a luminance block with variable alpha.\n+ *\n+ * @return @c true if the block is a luminance + alpha block , @c false otherwise.\n+ */\n+ inline bool is_luminancealpha() const\n{\n- float default_alpha = imageblock_default_alpha(blk);\n- bool alpha1 = (blk->data_min.lane<3>() == default_alpha) &&\n- (blk->data_max.lane<3>() == default_alpha);\n- return blk->grayscale && !alpha1;\n+ float default_alpha = this->get_default_alpha();\n+ bool alpha1 = (this->data_min.lane<3>() == default_alpha) &&\n+ (this->data_max.lane<3>() == default_alpha);\n+ return this->grayscale && !alpha1;\n}\n+};\n/*\nData structure representing error weighting for one block of an image. this is used as\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -144,7 +144,7 @@ static void compute_error_squared_rgb_single_partition(\nvfloat4 ews = ewb.error_weights[tix];\n// Compute the error that arises from just ditching alpha\n- float default_alpha = imageblock_default_alpha(&blk);\n+ float default_alpha = blk.get_default_alpha();\nfloat omalpha = point.lane<3>() - default_alpha;\na_drop_err += omalpha * omalpha * ews.lane<3>();\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleanups and documentation for astcenc_internal
61,745
25.05.2021 08:17:06
-3,600
a9fb54542502194669484338069dddc380e90410
Disambiguate color and weight quant in var names
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -108,7 +108,7 @@ static bool realign_weights(\n{\nunpack_color_endpoints(decode_mode,\nscb.color_formats[pa_idx],\n- scb.color_quant_level,\n+ scb.get_color_quant_mode(),\nscb.color_values[pa_idx],\nrgb_hdr, alpha_hdr,\nendpnt0[pa_idx],\n@@ -332,7 +332,7 @@ static float compress_symbolic_block_for_partition_1plane(\n// Compute weight bitcount for the mode\nunsigned int bits_used_by_weights = get_ise_sequence_bitcount(\ndi.weight_count,\n- bm.get_quant_mode());\n+ bm.get_weight_quant_mode());\nint bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\nif (bitcount <= 0 || bits_used_by_weights < 24 || bits_used_by_weights > 96)\n@@ -349,7 +349,7 @@ static float compress_symbolic_block_for_partition_1plane(\ndecimated_quantized_weights + BLOCK_MAX_WEIGHTS * decimation_mode,\nflt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * i,\nu8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * i,\n- bm.get_quant_mode());\n+ bm.get_weight_quant_mode());\n// Compute weight quantization errors for the block mode\nqwt_errors[i] = compute_error_of_weight_set_1plane(\n@@ -481,11 +481,11 @@ static float compress_symbolic_block_for_partition_1plane(\n// Store header fields\nworkscb.partition_count = partition_count;\nworkscb.partition_index = partition_index;\n- workscb.color_quant_level = workscb.color_formats_matched ? color_quant_level_mod[i] : color_quant_level[i];\n+ workscb.quant_mode = workscb.color_formats_matched ? color_quant_level_mod[i] : color_quant_level[i];\nworkscb.block_mode = qw_bm.mode_index;\nworkscb.block_type = SYM_BTYPE_NONCONST;\n- if (workscb.color_quant_level < 4)\n+ if (workscb.quant_mode < QUANT_6)\n{\nworkscb.block_type = SYM_BTYPE_ERROR;\n}\n@@ -719,7 +719,7 @@ static float compress_symbolic_block_for_partition_2planes(\n// Compute weight bitcount for the mode\nunsigned int bits_used_by_weights = get_ise_sequence_bitcount(\n2 * di.weight_count,\n- bm.get_quant_mode());\n+ bm.get_weight_quant_mode());\nint bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\nif (bitcount <= 0 || bits_used_by_weights < 24 || bits_used_by_weights > 96)\n{\n@@ -735,7 +735,7 @@ static float compress_symbolic_block_for_partition_2planes(\nweight_high_value1[i],\ndecimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * decimation_mode),\nflt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i),\n- u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i), bm.get_quant_mode());\n+ u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i), bm.get_weight_quant_mode());\ncompute_quantized_weights_for_decimation(\ndi,\n@@ -743,7 +743,7 @@ static float compress_symbolic_block_for_partition_2planes(\nweight_high_value2[i],\ndecimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * decimation_mode + 1),\nflt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i + 1),\n- u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i + 1), bm.get_quant_mode());\n+ u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i + 1), bm.get_weight_quant_mode());\n// Compute weight quantization errors for the block mode\nqwt_errors[i] = compute_error_of_weight_set_2planes(\n@@ -882,12 +882,12 @@ static float compress_symbolic_block_for_partition_2planes(\n// Store header fields\nworkscb.partition_count = partition_count;\nworkscb.partition_index = partition_index;\n- workscb.color_quant_level = workscb.color_formats_matched ? color_quant_level_mod[i] : color_quant_level[i];\n+ workscb.quant_mode = workscb.color_formats_matched ? color_quant_level_mod[i] : color_quant_level[i];\nworkscb.block_mode = qw_bm.mode_index;\nworkscb.plane2_component = plane2_component;\nworkscb.block_type = SYM_BTYPE_NONCONST;\n- if (workscb.color_quant_level < 4)\n+ if (workscb.quant_mode < 4)\n{\nworkscb.block_type = SYM_BTYPE_ERROR;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -272,7 +272,7 @@ void decompress_symbolic_block(\n// Unquantize and undecimate the weights\nint weights[BLOCK_MAX_TEXELS];\nint plane2_weights[BLOCK_MAX_TEXELS];\n- unpack_weights(bsd, scb, di, is_dual_plane, bm.get_quant_mode(), weights, plane2_weights);\n+ unpack_weights(bsd, scb, di, is_dual_plane, bm.get_weight_quant_mode(), weights, plane2_weights);\n// Now that we have endpoint colors and weights, we can unpack texel colors\nint plane2_component = is_dual_plane ? scb.plane2_component : -1;\n@@ -288,7 +288,7 @@ void decompress_symbolic_block(\nunpack_color_endpoints(decode_mode,\nscb.color_formats[i],\n- scb.color_quant_level,\n+ scb.get_color_quant_mode(),\nscb.color_values[i],\nrgb_lns, a_lns,\nep0, ep1);\n@@ -347,7 +347,7 @@ float compute_symbolic_block_difference(\n// Unquantize and undecimate the weights\nint weights[BLOCK_MAX_TEXELS];\nint plane2_weights[BLOCK_MAX_TEXELS];\n- unpack_weights(bsd, scb, di, is_dual_plane, bm.get_quant_mode(), weights, plane2_weights);\n+ unpack_weights(bsd, scb, di, is_dual_plane, bm.get_weight_quant_mode(), weights, plane2_weights);\nint plane2_component = is_dual_plane ? scb.plane2_component : -1;\nvmask4 plane2_mask = vint4::lane_id() == vint4(plane2_component);\n@@ -363,7 +363,7 @@ float compute_symbolic_block_difference(\nunpack_color_endpoints(config.profile,\nscb.color_formats[i],\n- scb.color_quant_level,\n+ scb.get_color_quant_mode(),\nscb.color_values[i],\nrgb_lns, a_lns,\nep0, ep1);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -1242,8 +1242,8 @@ astcenc_error astcenc_get_block_info(\ninfo->partition_index = scb.partition_index;\ninfo->dual_plane_component = scb.plane2_component;\n- info->color_level_count = get_quant_level((quant_method)scb.color_quant_level);\n- info->weight_level_count = get_quant_level(bm.get_quant_mode());\n+ info->color_level_count = get_quant_level(scb.get_color_quant_mode());\n+ info->weight_level_count = get_quant_level(bm.get_weight_quant_mode());\n// Unpack color endpoints for each active partition\nfor (unsigned int i = 0; i < scb.partition_count; i++)\n@@ -1254,7 +1254,7 @@ astcenc_error astcenc_get_block_info(\nunpack_color_endpoints(ctx->config.profile,\nscb.color_formats[i],\n- scb.color_quant_level,\n+ scb.get_color_quant_mode(),\nscb.color_values[i],\nrgb_hdr, a_hdr,\nendpnt[0], endpnt[1]);\n@@ -1278,7 +1278,7 @@ astcenc_error astcenc_get_block_info(\nint weight_plane1[BLOCK_MAX_TEXELS];\nint weight_plane2[BLOCK_MAX_TEXELS];\n- unpack_weights(bsd, scb, di, bm.is_dual_plane, bm.get_quant_mode(), weight_plane1, weight_plane2);\n+ unpack_weights(bsd, scb, di, bm.is_dual_plane, bm.get_weight_quant_mode(), weight_plane1, weight_plane2);\nfor (unsigned int i = 0; i < bsd.texel_count; i++)\n{\ninfo->weight_values_plane1[i] = (float)weight_plane1[i] * (1.0f / WEIGHTS_TEXEL_SUM);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -618,9 +618,7 @@ struct block_mode\n*\n* @return The quantization level.\n*/\n- // TODO: Rename this to get_weight_quant_mode, and add accessor to scb for\n- // get_color_quant_mode.\n- inline quant_method get_quant_mode() const\n+ inline quant_method get_weight_quant_mode() const\n{\nreturn (quant_method)this->quant_mode;\n}\n@@ -632,6 +630,7 @@ struct block_mode\nstruct decimation_mode\n{\n/** @brief The max weight precision for 1 plane, or -1 if not supported. */\n+ // TODO: Try unsigned sentinel to avoid signext on load?\nint8_t maxprec_1plane;\n/** @brief The max weight precision for 2 planes, or -1 if not supported. */\n@@ -1163,6 +1162,7 @@ struct symbolic_compressed_block\nuint8_t color_formats_matched;\n/** @brief The plane 2 color component, or -1 if single plane; valid for @c NONCONST blocks. */\n+ // Try unsigned sentintel to avoid signext on load\nint8_t plane2_component;\n/** @brief The block mode; valid for @c NONCONST blocks. */\n@@ -1175,7 +1175,7 @@ struct symbolic_compressed_block\nuint8_t color_formats[BLOCK_MAX_PARTITIONS];\n/** @brief The endpoint color formats for each partition; valid for @c NONCONST blocks. */\n- quant_method color_quant_level;\n+ quant_method quant_mode;\n/** @brief The error of the current encoding; valid for @c NONCONST blocks. */\nfloat errorval;\n@@ -1193,6 +1193,16 @@ struct symbolic_compressed_block\n* If dual plane, the second plane starts at @c weights[WEIGHTS_PLANE2_OFFSET].\n*/\nuint8_t weights[BLOCK_MAX_WEIGHTS];\n+\n+ /**\n+ * @brief Get the weight quantization used by this block mode.\n+ *\n+ * @return The quantization level.\n+ */\n+ inline quant_method get_color_quant_mode() const\n+ {\n+ return this->quant_mode;\n+ }\n};\n/**\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_symbolic_physical.cpp", "new_path": "Source/astcenc_symbolic_physical.cpp", "diff": "@@ -148,7 +148,7 @@ void symbolic_to_physical(\nconst auto& bm = bsd.get_block_mode(scb.block_mode);\nconst auto& di = bsd.get_decimation_info(bm.decimation_mode);\nint weight_count = di.weight_count;\n- quant_method weight_quant_method = bm.get_quant_mode();\n+ quant_method weight_quant_method = bm.get_weight_quant_mode();\nint is_dual_plane = bm.is_dual_plane;\nint real_weight_count = is_dual_plane ? 2 * weight_count : weight_count;\n@@ -257,7 +257,8 @@ void symbolic_to_physical(\nvaluecount_to_encode += vals;\n}\n- encode_ise((quant_method)scb.color_quant_level, valuecount_to_encode, values_to_encode, pcb.data, (scb.partition_count == 1 ? 17 : 19 + PARTITION_INDEX_BITS));\n+ encode_ise(scb.get_color_quant_mode(), valuecount_to_encode, values_to_encode, pcb.data,\n+ scb.partition_count == 1 ? 17 : 19 + PARTITION_INDEX_BITS);\n}\n/* See header for documentation. */\n@@ -464,8 +465,8 @@ void physical_to_symbolic(\n}\nint color_quant_level = quant_mode_table[color_integer_count >> 1][color_bits];\n- scb.color_quant_level = (quant_method)color_quant_level;\n- if (color_quant_level < 4)\n+ scb.quant_mode = (quant_method)color_quant_level;\n+ if (color_quant_level < QUANT_6)\n{\nscb.block_type = SYM_BTYPE_ERROR;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Disambiguate color and weight quant in var names
61,745
25.05.2021 08:30:32
-3,600
a65c7ac55e316b496b4cac930635bee7bdba0329
Return and use viable candidate count
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -365,7 +365,7 @@ static float compress_symbolic_block_for_partition_1plane(\nquant_method color_quant_level[TUNE_MAX_TRIAL_CANDIDATES];\nquant_method color_quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\n- compute_ideal_endpoint_formats(\n+ unsigned int candidate_count = compute_ideal_endpoint_formats(\nbsd, pi, blk, ewb, ei.ep, qwt_bitcounts, qwt_errors,\nconfig.tune_candidate_limit, partition_format_specifiers, block_mode_index,\ncolor_quant_level, color_quant_level_mod);\n@@ -374,18 +374,11 @@ static float compress_symbolic_block_for_partition_1plane(\nfloat best_errorval_in_mode = 1e30f;\nfloat best_errorval_in_scb = scb.errorval;\n- for (unsigned int i = 0; i < config.tune_candidate_limit; i++)\n+ for (unsigned int i = 0; i < candidate_count; i++)\n{\nTRACE_NODE(node0, \"candidate\");\n- // TODO: Can this ever happen?\nconst int bm_packed_index = block_mode_index[i];\n- if (bm_packed_index < 0)\n- {\n- trace_add_data(\"failed\", \"error_block\");\n- continue;\n- }\n-\nassert(bm_packed_index >= 0 && bm_packed_index < (int)bsd.block_mode_count);\nconst block_mode& qw_bm = bsd.block_modes[bm_packed_index];\n@@ -764,7 +757,7 @@ static float compress_symbolic_block_for_partition_2planes(\nendpoints epm;\nmerge_endpoints(ei1.ep, ei2.ep, plane2_component, epm);\n- compute_ideal_endpoint_formats(\n+ unsigned int candidate_count = compute_ideal_endpoint_formats(\nbsd, pi, blk, ewb, epm, qwt_bitcounts, qwt_errors,\nconfig.tune_candidate_limit, partition_format_specifiers, block_mode_index,\ncolor_quant_level, color_quant_level_mod);\n@@ -773,17 +766,11 @@ static float compress_symbolic_block_for_partition_2planes(\nfloat best_errorval_in_mode = 1e30f;\nfloat best_errorval_in_scb = scb.errorval;\n- for (unsigned int i = 0; i < config.tune_candidate_limit; i++)\n+ for (unsigned int i = 0; i < candidate_count; i++)\n{\nTRACE_NODE(node0, \"candidate\");\nconst int bm_packed_index = block_mode_index[i];\n- if (bm_packed_index < 0)\n- {\n- trace_add_data(\"failed\", \"error_block\");\n- continue;\n- }\n-\nassert(bm_packed_index >= 0 && bm_packed_index < (int)bsd.block_mode_count);\nconst block_mode& qw_bm = bsd.block_modes[bm_packed_index];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -2038,13 +2038,15 @@ void unpack_weights(\n* @param ep The ideal endpoints.\n* @param qwt_bitcounts Bit counts for different quantization methods.\n* @param qwt_errors Errors for different quantization methods.\n- * @param tune_candidate_limit The number of candidates to return.\n+ * @param tune_candidate_limit The max number of candidates to return, may be less.\n* @param[out] partition_format_specifiers The best formats per partition.\n- * @param[out] block_mode The best packed block mode index.\n+ * @param[out] block_mode The best packed block mode indexes.\n* @param[out] quant_level The best color quant level.\n* @param[out] quant_level_mod The best color quant level if endpoints are the same.\n+ *\n+ * @return The actual number of candidate matches returned.\n*/\n-void compute_ideal_endpoint_formats(\n+unsigned int compute_ideal_endpoint_formats(\nconst block_size_descriptor& bsd,\nconst partition_info& pi,\nconst imageblock& blk,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -1085,7 +1085,7 @@ static void four_partitions_find_best_combination_for_bitcount(\n}\n/* See header for documentation. */\n-void compute_ideal_endpoint_formats(\n+unsigned int compute_ideal_endpoint_formats(\nconst block_size_descriptor& bsd,\nconst partition_info& pi,\nconst imageblock& blk,\n@@ -1281,9 +1281,12 @@ void compute_ideal_endpoint_formats(\nfor (unsigned int i = 0; i < tune_candidate_limit; i++)\n{\n- block_mode[i] = best_error_weights[i];\n- if (block_mode[i] >= 0)\n+ if (best_error_weights[i] < 0)\n{\n+ return i;\n+ }\n+\n+ block_mode[i] = best_error_weights[i];\nquant_level[i] = best_quant_levels[best_error_weights[i]];\nassert(quant_level[i] >= 0 && quant_level[i] < 21);\nquant_level_mod[i] = best_quant_levels_mod[best_error_weights[i]];\n@@ -1292,7 +1295,8 @@ void compute_ideal_endpoint_formats(\npartition_format_specifiers[i][j] = best_ep_formats[best_error_weights[i]][j];\n}\n}\n- }\n+\n+ return tune_candidate_limit;\n}\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Return and use viable candidate count
61,745
25.05.2021 08:34:10
-3,600
4e885ab021fb7cd7ebbd4172c8622e40d93a75a9
Early out candidate search on first failure
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -1277,6 +1277,11 @@ unsigned int compute_ideal_endpoint_formats(\n{\nerrors_of_best_combination[best_error_index] = 1e30f;\n}\n+ // Early-out if no more candidates are valid\n+ else\n+ {\n+ break;\n+ }\n}\nfor (unsigned int i = 0; i < tune_candidate_limit; i++)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Early out candidate search on first failure
61,745
25.05.2021 08:52:00
-3,600
2f9362c16e71cb6da1ae48bc23ca7e9243ba8f99
Remove redundant copy of the avg_var structure
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compute_variance.cpp", "new_path": "Source/astcenc_compute_variance.cpp", "diff": "@@ -568,13 +568,12 @@ void compute_averages_and_variances(\n/* See header for documentation. */\nunsigned int init_compute_averages_and_variances(\n- astcenc_image& img,\n+ const astcenc_image& img,\nfloat rgb_power,\nfloat alpha_power,\nunsigned int avg_var_kernel_radius,\nunsigned int alpha_kernel_radius,\nconst astcenc_swizzle& swz,\n- pixel_region_variance_args& arg,\navg_var_args& ag\n) {\nunsigned int size_x = img.dim_x;\n@@ -594,23 +593,22 @@ unsigned int init_compute_averages_and_variances(\n// Perform block-wise averages-and-variances calculations across the image\n// Initialize fields which are not populated until later\n- arg.size_x = 0;\n- arg.size_y = 0;\n- arg.size_z = 0;\n- arg.offset_x = 0;\n- arg.offset_y = 0;\n- arg.offset_z = 0;\n- arg.work_memory = nullptr;\n-\n- arg.img = &img;\n- arg.rgb_power = rgb_power;\n- arg.alpha_power = alpha_power;\n- arg.swz = swz;\n- arg.have_z = have_z;\n- arg.avg_var_kernel_radius = avg_var_kernel_radius;\n- arg.alpha_kernel_radius = alpha_kernel_radius;\n-\n- ag.arg = arg;\n+ ag.arg.size_x = 0;\n+ ag.arg.size_y = 0;\n+ ag.arg.size_z = 0;\n+ ag.arg.offset_x = 0;\n+ ag.arg.offset_y = 0;\n+ ag.arg.offset_z = 0;\n+ ag.arg.work_memory = nullptr;\n+\n+ ag.arg.img = &img;\n+ ag.arg.rgb_power = rgb_power;\n+ ag.arg.alpha_power = alpha_power;\n+ ag.arg.swz = swz;\n+ ag.arg.have_z = have_z;\n+ ag.arg.avg_var_kernel_radius = avg_var_kernel_radius;\n+ ag.arg.alpha_kernel_radius = alpha_kernel_radius;\n+\nag.img_size_x = size_x;\nag.img_size_y = size_y;\nag.img_size_z = size_z;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -1024,14 +1024,14 @@ astcenc_error astcenc_compress_image(\nreturn init_compute_averages_and_variances(\nimage, ctx->config.v_rgb_power, ctx->config.v_a_power,\nctx->config.v_rgba_radius, ctx->config.a_scale_radius, *swizzle,\n- ctx->arg, ctx->ag);\n+ ctx->avg_var_preprocess_args);\n};\n// Only the first thread actually runs the initializer\nctx->manage_avg_var.init(init_avg_var);\n// All threads will enter this function and dynamically grab work\n- compute_averages_and_variances(*ctx, ctx->ag);\n+ compute_averages_and_variances(*ctx, ctx->avg_var_preprocess_args);\n}\n// Wait for compute_averages_and_variances to complete before compressing\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1334,13 +1334,8 @@ struct astcenc_context\ncompress_symbolic_block_buffers* working_buffers;\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\n- /** @brief The pixel region and variance arguments. */\n- // TODO: Do we need both? ag include an p_r_v_a structure too?\n- pixel_region_variance_args arg;\n-\n/** @brief The pixel region and variance worker arguments. */\n- // TODO: Can we give these better names. Merge them?\n- avg_var_args ag;\n+ avg_var_args avg_var_preprocess_args;\n/** @brief The per-texel deblocking weights for the current block size. */\n// TODO: Move to the BSD?\n@@ -1693,27 +1688,23 @@ void find_best_partition_candidates(\n* Results are written back into @c img->input_averages, @c img->input_variances,\n* and @c img->input_alpha_averages.\n*\n- * @todo Can img be const here?\n- *\n- * @param[in,out] img The input image data, also holds output data.\n+ * @param img The input image data, also holds output data.\n* @param rgb_power The RGB component power.\n* @param alpha_power The A component power.\n* @param avg_var_kernel_radius The kernel radius (in pixels) for avg and var.\n* @param alpha_kernel_radius The kernel radius (in pixels) for alpha mods.\n* @param swz Input data component swizzle.\n- * @param[out] arg The pixel region arguments to init.\n* @param[out] ag The average variance arguments to init.\n*\n* @return The number of tasks in the processing stage.\n*/\nunsigned int init_compute_averages_and_variances(\n- astcenc_image& img,\n+ const astcenc_image& img,\nfloat rgb_power,\nfloat alpha_power,\nunsigned int avg_var_kernel_radius,\nunsigned int alpha_kernel_radius,\nconst astcenc_swizzle& swz,\n- pixel_region_variance_args& arg,\navg_var_args& ag);\n/**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove redundant copy of the avg_var structure
61,745
31.05.2021 23:41:42
-3,600
03340deaff7f008b23be1adfa8f4d62845e721ea
Make CPU query API use bools
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -2193,34 +2193,33 @@ void physical_to_symbolic(\n/* ============================================================================\nPlatform-specific functions.\n============================================================================ */\n-// TODO: Make these bools\n/**\n* @brief Run-time detection if the host CPU supports the POPCNT extension.\n*\n- * @return Zero if not supported, positive value if it is.\n+ * @return @c true if supported, @c false if not.\n*/\n-int cpu_supports_popcnt();\n+bool cpu_supports_popcnt();\n/**\n* @brief Run-time detection if the host CPU supports F16C extension.\n*\n- * @return Zero if not supported, positive value if it is.\n+ * @return @c true if supported, @c false if not.\n*/\n-int cpu_supports_f16c();\n+bool cpu_supports_f16c();\n/**\n* @brief Run-time detection if the host CPU supports SSE 4.1 extension.\n*\n- * @return Zero if not supported, positive value if it is.\n+ * @return @c true if supported, @c false if not.\n*/\n-int cpu_supports_sse41();\n+bool cpu_supports_sse41();\n/**\n* @brief Run-time detection if the host CPU supports AVX 2 extension.\n*\n- * @return Zero if not supported, positive value if it is.\n+ * @return @c true if supported, @c false if not.\n*/\n-int cpu_supports_avx2();\n+bool cpu_supports_avx2();\n/**\n* @brief Allocate an aligned memory buffer.\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_platform_isa_detection.cpp", "new_path": "Source/astcenc_platform_isa_detection.cpp", "diff": "@@ -115,47 +115,47 @@ static void detect_cpu_isa()\n#endif\n/* See header for documentation. */\n-int cpu_supports_sse41()\n+bool cpu_supports_sse41()\n{\nif (g_cpu_has_sse41 == -1)\n{\ndetect_cpu_isa();\n}\n- return g_cpu_has_sse41;\n+ return g_cpu_has_sse41 == 1;\n}\n/* See header for documentation. */\n-int cpu_supports_popcnt()\n+bool cpu_supports_popcnt()\n{\nif (g_cpu_has_popcnt == -1)\n{\ndetect_cpu_isa();\n}\n- return g_cpu_has_popcnt;\n+ return g_cpu_has_popcnt == 1;\n}\n/* See header for documentation. */\n-int cpu_supports_f16c()\n+bool cpu_supports_f16c()\n{\nif (g_cpu_has_f16c == -1)\n{\ndetect_cpu_isa();\n}\n- return g_cpu_has_f16c;\n+ return g_cpu_has_f16c == 1;\n}\n/* See header for documentation. */\n-int cpu_supports_avx2()\n+bool cpu_supports_avx2()\n{\nif (g_cpu_has_avx2 == -1)\n{\ndetect_cpu_isa();\n}\n- return g_cpu_has_avx2;\n+ return g_cpu_has_avx2 == 1;\n}\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make CPU query API use bools
61,745
31.05.2021 23:43:10
-3,600
dddd206735cd38e866927af4b0c52c729ee46146
Cleanup obsolete TODO
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -877,7 +877,7 @@ struct imageblock\n/**\n* @brief Test if this block is using alpha.\n*\n- * @todo This looks suspect, but matches the original astcenc 1.7 code. This checks that the\n+ * TODO: This looks suspect, but matches the original astcenc 1.7 code. This checks that the\n* alpha is not constant (no weight needed), NOT that it is 1.0 and not stored as an endpoint.\n* Review all uses of this function and check that it is sensible ...\n*\n@@ -989,8 +989,6 @@ struct error_weight_block\n/**\n* @brief Data structure storing the color endpoints for a block.\n- *\n- * @todo Store as interleaved array to get better locality?\n*/\nstruct endpoints\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleanup obsolete TODO
61,745
31.05.2021 23:45:13
-3,600
a01f3bda4dc48c31906f9b1da4b02be744e9499b
Rename imageblock to image_block
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "/* See header for documentation. */\nvoid compute_avgs_and_dirs_4_comp(\nconst partition_info& pi,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\npartition_metrics pm[BLOCK_MAX_PARTITIONS]\n) {\n@@ -136,7 +136,7 @@ void compute_avgs_and_dirs_4_comp(\n/* See header for documentation. */\nvoid compute_avgs_and_dirs_3_comp(\nconst partition_info& pi,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nunsigned int omitted_component,\npartition_metrics pm[BLOCK_MAX_PARTITIONS]\n@@ -286,7 +286,7 @@ void compute_avgs_and_dirs_3_comp(\n/* See header for documentation. */\nvoid compute_avgs_and_dirs_2_comp(\nconst partition_info& pt,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nunsigned int component1,\nunsigned int component2,\n@@ -407,7 +407,7 @@ void compute_avgs_and_dirs_2_comp(\n/* See header for documentation. */\nvoid compute_error_squared_rgba(\nconst partition_info& pi,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst processed_line4 uncor_plines[BLOCK_MAX_PARTITIONS],\nconst processed_line4 samec_plines[BLOCK_MAX_PARTITIONS],\n@@ -565,7 +565,7 @@ void compute_error_squared_rgba(\n/* See header for documentation. */\nvoid compute_error_squared_rgb(\nconst partition_info& pi,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\npartition_lines3 plines[BLOCK_MAX_PARTITIONS],\nfloat& uncor_error,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -70,7 +70,7 @@ static void merge_endpoints(\nstatic bool realign_weights(\nastcenc_profile decode_mode,\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nsymbolic_compressed_block& scb,\nuint8_t* weight_set8_plane1,\n@@ -232,7 +232,7 @@ static bool realign_weights(\nstatic float compress_symbolic_block_for_partition_1plane(\nconst astcenc_config& config,\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nbool only_always,\nfloat tune_errorval_threshold,\n@@ -585,7 +585,7 @@ static float compress_symbolic_block_for_partition_1plane(\nstatic float compress_symbolic_block_for_partition_2planes(\nconst astcenc_config& config,\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nfloat tune_errorval_threshold,\nunsigned int partition_count,\n@@ -1025,7 +1025,7 @@ static float prepare_error_weight_block(\nconst astcenc_context& ctx,\nconst astcenc_image& image,\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nerror_weight_block& ewb\n) {\nunsigned int idx = 0;\n@@ -1226,7 +1226,7 @@ static float prepare_error_weight_block(\n*/\nstatic float prepare_block_statistics(\nint texels_per_block,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb\n) {\n// Compute covariance matrix, as a collection of 10 scalars that form the upper-triangular row\n@@ -1360,7 +1360,7 @@ enum trial_modes {\nvoid compress_block(\nconst astcenc_context& ctx,\nconst astcenc_image& input_image,\n- const imageblock& blk,\n+ const image_block& blk,\nphysical_compressed_block& pcb,\ncompression_working_buffers& tmpbuf)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -180,7 +180,7 @@ void decompress_symbolic_block(\nint ypos,\nint zpos,\nconst symbolic_compressed_block& scb,\n- imageblock& blk\n+ image_block& blk\n) {\nblk.xpos = xpos;\nblk.ypos = ypos;\n@@ -323,7 +323,7 @@ float compute_symbolic_block_difference(\nconst astcenc_config& config,\nconst block_size_descriptor& bsd,\nconst symbolic_compressed_block& scb,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb\n) {\n// If we detected an error-block, blow up immediately.\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -846,7 +846,7 @@ static void compress_image(\n) {\nconst block_size_descriptor *bsd = ctx.bsd;\nastcenc_profile decode_mode = ctx.config.profile;\n- imageblock blk;\n+ image_block blk;\nint block_x = bsd->xdim;\nint block_y = bsd->ydim;\n@@ -927,7 +927,7 @@ static void compress_image(\n// Fetch the full block for compression\nif (use_full_block)\n{\n- fetch_imageblock(decode_mode, image, blk, *bsd, x * block_x, y * block_y, z * block_z, swizzle);\n+ fetch_image_block(decode_mode, image, blk, *bsd, x * block_x, y * block_y, z * block_z, swizzle);\n}\n// Apply alpha scale RDO - substitute constant color block\nelse\n@@ -1121,7 +1121,7 @@ astcenc_error astcenc_decompress_image(\nreturn ASTCENC_ERR_OUT_OF_MEM;\n}\n- imageblock blk;\n+ image_block blk;\n// If context thread count is one then implicitly reset\nif (ctx->thread_count == 1)\n@@ -1161,7 +1161,7 @@ astcenc_error astcenc_decompress_image(\nx * block_x, y * block_y, z * block_z,\nscb, blk);\n- write_imageblock(image_out, blk, *ctx->bsd,\n+ write_image_block(image_out, blk, *ctx->bsd,\nx * block_x, y * block_y, z * block_z, *swizzle);\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "* @param[out] cluster_centers The initital partition cluster center colors.\n*/\nstatic void kmeans_init(\n- const imageblock& blk,\n+ const image_block& blk,\nunsigned int texel_count,\nunsigned int partition_count,\nvfloat4 cluster_centers[BLOCK_MAX_PARTITIONS]\n@@ -143,7 +143,7 @@ static void kmeans_init(\n* @param[out] partition_of_texel The partition assigned for each texel.\n*/\nstatic void kmeans_assign(\n- const imageblock& blk,\n+ const image_block& blk,\nunsigned int texel_count,\nunsigned int partition_count,\nconst vfloat4 cluster_centers[BLOCK_MAX_PARTITIONS],\n@@ -207,7 +207,7 @@ static void kmeans_assign(\n* @param partition_of_texel The partition assigned for each texel.\n*/\nstatic void kmeans_update(\n- const imageblock& blk,\n+ const image_block& blk,\nunsigned int texel_count,\nunsigned int partition_count,\nvfloat4 cluster_centers[BLOCK_MAX_PARTITIONS],\n@@ -429,7 +429,7 @@ static void get_partition_ordering_by_mismatch_bits(\n*/\nstatic void compute_kmeans_partition_ordering(\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nunsigned int partition_count,\nunsigned int partition_ordering[BLOCK_MAX_PARTITIONINGS]\n) {\n@@ -472,7 +472,7 @@ static void compute_kmeans_partition_ordering(\n/* See header for documentation. */\nvoid find_best_partition_candidates(\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nunsigned int partition_count,\nunsigned int partition_search_limit,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "*/\nstatic void compute_ideal_colors_and_weights_1_comp(\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst partition_info& pi,\nendpoints_and_weights& ei,\n@@ -155,7 +155,7 @@ static void compute_ideal_colors_and_weights_1_comp(\n*/\nstatic void compute_ideal_colors_and_weights_2_comp(\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst partition_info& pi,\nendpoints_and_weights& ei,\n@@ -312,7 +312,7 @@ static void compute_ideal_colors_and_weights_2_comp(\n*/\nstatic void compute_ideal_colors_and_weights_3_comp(\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst partition_info& pi,\nendpoints_and_weights& ei,\n@@ -487,7 +487,7 @@ static void compute_ideal_colors_and_weights_3_comp(\n*/\nstatic void compute_ideal_colors_and_weights_4_comp(\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst partition_info& pi,\nendpoints_and_weights& ei\n@@ -599,7 +599,7 @@ static void compute_ideal_colors_and_weights_4_comp(\n/* See header for documentation. */\nvoid compute_ideal_colors_and_weights_1plane(\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst partition_info& pi,\nendpoints_and_weights& ei\n@@ -617,7 +617,7 @@ void compute_ideal_colors_and_weights_1plane(\n/* See header for documentation. */\nvoid compute_ideal_colors_and_weights_2planes(\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst partition_info& pi,\nunsigned int plane2_component,\n@@ -1045,7 +1045,7 @@ static inline vfloat4 compute_rgbo_vector(\n/* See header for documentation. */\nvoid recompute_ideal_colors_1plane(\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst partition_info& pi,\nconst decimation_info& di,\n@@ -1248,7 +1248,7 @@ void recompute_ideal_colors_1plane(\n/* See header for documentation. */\nvoid recompute_ideal_colors_2planes(\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst partition_info& pi,\nconst decimation_info& di,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -148,10 +148,10 @@ static vfloat4 encode_texel_lns(\n}\n/* See header for documentation. */\n-void fetch_imageblock(\n+void fetch_image_block(\nastcenc_profile decode_mode,\nconst astcenc_image& img,\n- imageblock& blk,\n+ image_block& blk,\nconst block_size_descriptor& bsd,\nunsigned int xpos,\nunsigned int ypos,\n@@ -264,9 +264,9 @@ void fetch_imageblock(\n}\n/* See header for documentation. */\n-void write_imageblock(\n+void write_image_block(\nastcenc_image& img,\n- const imageblock& blk,\n+ const image_block& blk,\nconst block_size_descriptor& bsd,\nunsigned int xpos,\nunsigned int ypos,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -791,8 +791,7 @@ struct block_size_descriptor\n* The @c rgb_lns and @c alpha_lns fields that assigned a per-texel use of HDR are only used during\n* decompression. The current compressor will always use HDR endpoint formats when in HDR mode.\n*/\n-// TODO: Rename this image_block?\n-struct imageblock\n+struct image_block\n{\n/** @brief The input (compress) or output (decompress) data for the red color component. */\nfloat data_r[BLOCK_MAX_TEXELS];\n@@ -1537,7 +1536,7 @@ unsigned int get_ise_sequence_bitcount(\n*/\nvoid compute_avgs_and_dirs_2_comp(\nconst partition_info& pi,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nunsigned int component1,\nunsigned int component2,\n@@ -1556,7 +1555,7 @@ void compute_avgs_and_dirs_2_comp(\n*/\nvoid compute_avgs_and_dirs_3_comp(\nconst partition_info& pi,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nunsigned int omitted_component,\npartition_metrics pm[BLOCK_MAX_PARTITIONS]);\n@@ -1573,7 +1572,7 @@ void compute_avgs_and_dirs_3_comp(\n*/\nvoid compute_avgs_and_dirs_4_comp(\nconst partition_info& pi,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\npartition_metrics pm[BLOCK_MAX_PARTITIONS]);\n@@ -1596,7 +1595,7 @@ void compute_avgs_and_dirs_4_comp(\n*/\nvoid compute_error_squared_rgb(\nconst partition_info& pi,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\npartition_lines3 plines[BLOCK_MAX_PARTITIONS],\nfloat& uncor_error,\n@@ -1624,7 +1623,7 @@ void compute_error_squared_rgb(\n*/\nvoid compute_error_squared_rgba(\nconst partition_info& pi,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst processed_line4 uncor_plines[BLOCK_MAX_PARTITIONS],\nconst processed_line4 samec_plines[BLOCK_MAX_PARTITIONS],\n@@ -1653,7 +1652,7 @@ void compute_error_squared_rgba(\n*/\nvoid find_best_partition_candidates(\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nunsigned int partition_count,\nunsigned int partition_search_limit,\n@@ -1721,10 +1720,10 @@ void compute_averages_and_variances(\n* @param zpos The block Z coordinate in the input image.\n* @param swz The swizzle to apply on load.\n*/\n-void fetch_imageblock(\n+void fetch_image_block(\nastcenc_profile decode_mode,\nconst astcenc_image& img,\n- imageblock& blk,\n+ image_block& blk,\nconst block_size_descriptor& bsd,\nunsigned int xpos,\nunsigned int ypos,\n@@ -1742,9 +1741,9 @@ void fetch_imageblock(\n* @param zpos The block Z coordinate in the input image.\n* @param swz The swizzle to apply on store.\n*/\n-void write_imageblock(\n+void write_image_block(\nastcenc_image& img,\n- const imageblock& blk,\n+ const image_block& blk,\nconst block_size_descriptor& bsd,\nunsigned int xpos,\nunsigned int ypos,\n@@ -1770,7 +1769,7 @@ void write_imageblock(\n*/\nvoid compute_ideal_colors_and_weights_1plane(\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst partition_info& pi,\nendpoints_and_weights& ei);\n@@ -1792,7 +1791,7 @@ void compute_ideal_colors_and_weights_1plane(\n*/\nvoid compute_ideal_colors_and_weights_2planes(\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst partition_info& pi,\nunsigned int plane2_component,\n@@ -2026,7 +2025,7 @@ void unpack_weights(\nunsigned int compute_ideal_endpoint_formats(\nconst block_size_descriptor& bsd,\nconst partition_info& pi,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst endpoints& ep,\nconst int* qwt_bitcounts,\n@@ -2054,7 +2053,7 @@ unsigned int compute_ideal_endpoint_formats(\n* @param[out] rgbo_vectors The RGB+offset vectors for HDR blocks.\n*/\nvoid recompute_ideal_colors_1plane(\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst partition_info& pi,\nconst decimation_info& di,\n@@ -2083,7 +2082,7 @@ void recompute_ideal_colors_1plane(\n* @param plane2_component The component assigned to plane 2.\n*/\nvoid recompute_ideal_colors_2planes(\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst partition_info& pi,\nconst decimation_info& di,\n@@ -2134,7 +2133,7 @@ void compute_angular_endpoints_2planes(\nvoid compress_block(\nconst astcenc_context& ctx,\nconst astcenc_image& image,\n- const imageblock& blk,\n+ const image_block& blk,\nphysical_compressed_block& pcb,\ncompression_working_buffers& tmpbuf);\n@@ -2155,7 +2154,7 @@ void decompress_symbolic_block(\nint ypos,\nint zpos,\nconst symbolic_compressed_block& scb,\n- imageblock& blk);\n+ image_block& blk);\n/**\n* @brief Compute the error between a symbolic block and the original input data.\n@@ -2175,7 +2174,7 @@ float compute_symbolic_block_difference(\nconst astcenc_config& config,\nconst block_size_descriptor& bsd,\nconst symbolic_compressed_block& scb,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb) ;\nvoid symbolic_to_physical(\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -110,7 +110,7 @@ static void compute_partition_error_color_weightings(\nstatic void compute_error_squared_rgb_single_partition(\nconst partition_info& pi,\nint partition_index,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst processed_line3& uncor_pline,\nfloat& uncor_err,\n@@ -189,7 +189,7 @@ static void compute_error_squared_rgb_single_partition(\n*/\nstatic void compute_encoding_choice_errors(\nconst block_size_descriptor& bsd,\n- const imageblock& blk,\n+ const image_block& blk,\nconst partition_info& pi,\nconst error_weight_block& ewb,\nconst endpoints& ep,\n@@ -1088,7 +1088,7 @@ static void four_partitions_find_best_combination_for_bitcount(\nunsigned int compute_ideal_endpoint_formats(\nconst block_size_descriptor& bsd,\nconst partition_info& pi,\n- const imageblock& blk,\n+ const image_block& blk,\nconst error_weight_block& ewb,\nconst endpoints& ep,\n// bitcounts and errors computed for the various quantization methods\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Rename imageblock to image_block
61,745
31.05.2021 23:50:00
-3,600
ec832221c12cf72577852ffc683abd4ddec8b663
Use ZI bools for global state trackers
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_platform_isa_detection.cpp", "new_path": "Source/astcenc_platform_isa_detection.cpp", "diff": "#if (ASTCENC_SSE > 0) || (ASTCENC_AVX > 0) || \\\n(ASTCENC_POPCNT > 0) || (ASTCENC_F16C > 0)\n+static bool g_init { false };\n+\n/** Does this CPU support SSE 4.1? Set to -1 if not yet initialized. */\n-static int g_cpu_has_sse41 = -1;\n+static bool g_cpu_has_sse41 { false };\n/** Does this CPU support AVX2? Set to -1 if not yet initialized. */\n-static int g_cpu_has_avx2 = -1;\n+static bool g_cpu_has_avx2 { false };\n/** Does this CPU support POPCNT? Set to -1 if not yet initialized. */\n-static int g_cpu_has_popcnt = -1;\n+static bool g_cpu_has_popcnt { false };\n/** Does this CPU support F16C? Set to -1 if not yet initialized. */\n-static int g_cpu_has_f16c = -1;\n+static bool g_cpu_has_f16c { false };\n/* ============================================================================\nPlatform code for Visual Studio\n@@ -56,27 +58,25 @@ static void detect_cpu_isa()\n__cpuid(data, 0);\nint num_id = data[0];\n- g_cpu_has_sse41 = 0;\n- g_cpu_has_popcnt = 0;\n- g_cpu_has_f16c = 0;\nif (num_id >= 1)\n{\n__cpuidex(data, 1, 0);\n// SSE41 = Bank 1, ECX, bit 19\n- g_cpu_has_sse41 = data[2] & (1 << 19) ? 1 : 0;\n+ g_cpu_has_sse41 = data[2] & (1 << 19) ? true : false;\n// POPCNT = Bank 1, ECX, bit 23\n- g_cpu_has_popcnt = data[2] & (1 << 23) ? 1 : 0;\n+ g_cpu_has_popcnt = data[2] & (1 << 23) ? true : false;\n// F16C = Bank 1, ECX, bit 29\n- g_cpu_has_f16c = data[2] & (1 << 29) ? 1 : 0;\n+ g_cpu_has_f16c = data[2] & (1 << 29) ? true : false;\n}\n- g_cpu_has_avx2 = 0;\nif (num_id >= 7)\n{\n__cpuidex(data, 7, 0);\n// AVX2 = Bank 7, EBX, bit 5\n- g_cpu_has_avx2 = data[1] & (1 << 5) ? 1 : 0;\n+ g_cpu_has_avx2 = data[1] & (1 << 5) ? true : false;\n}\n+\n+ g_init = true;\n}\n/* ============================================================================\n@@ -92,70 +92,69 @@ static void detect_cpu_isa()\n{\nunsigned int data[4];\n- g_cpu_has_sse41 = 0;\n- g_cpu_has_popcnt = 0;\n- g_cpu_has_f16c = 0;\nif (__get_cpuid_count(1, 0, &data[0], &data[1], &data[2], &data[3]))\n{\n// SSE41 = Bank 1, ECX, bit 19\n- g_cpu_has_sse41 = data[2] & (1 << 19) ? 1 : 0;\n+ g_cpu_has_sse41 = data[2] & (1 << 19) ? true : false;\n// POPCNT = Bank 1, ECX, bit 23\n- g_cpu_has_popcnt = data[2] & (1 << 23) ? 1 : 0;\n+ g_cpu_has_popcnt = data[2] & (1 << 23) ? true : false;\n// F16C = Bank 1, ECX, bit 29\n- g_cpu_has_f16c = data[2] & (1 << 29) ? 1 : 0;\n+ g_cpu_has_f16c = data[2] & (1 << 29) ? true : false;\n}\ng_cpu_has_avx2 = 0;\nif (__get_cpuid_count(7, 0, &data[0], &data[1], &data[2], &data[3]))\n{\n// AVX2 = Bank 7, EBX, bit 5\n- g_cpu_has_avx2 = data[1] & (1 << 5) ? 1 : 0;\n+ g_cpu_has_avx2 = data[1] & (1 << 5) ? true : false;\n}\n+\n+ g_init = true;\n}\n#endif\n/* See header for documentation. */\n-bool cpu_supports_sse41()\n+bool cpu_supports_popcnt()\n{\n- if (g_cpu_has_sse41 == -1)\n+ if (!g_init)\n{\ndetect_cpu_isa();\n}\n- return g_cpu_has_sse41 == 1;\n+ return g_cpu_has_popcnt;\n}\n/* See header for documentation. */\n-bool cpu_supports_popcnt()\n+bool cpu_supports_f16c()\n{\n- if (g_cpu_has_popcnt == -1)\n+ if (!g_init)\n{\ndetect_cpu_isa();\n}\n- return g_cpu_has_popcnt == 1;\n+ return g_cpu_has_f16c;\n}\n/* See header for documentation. */\n-bool cpu_supports_f16c()\n+bool cpu_supports_sse41()\n{\n- if (g_cpu_has_f16c == -1)\n+ if (!g_init)\n{\ndetect_cpu_isa();\n}\n- return g_cpu_has_f16c == 1;\n+ return g_cpu_has_sse41;\n}\n/* See header for documentation. */\nbool cpu_supports_avx2()\n{\n- if (g_cpu_has_avx2 == -1)\n+ if (!g_init)\n{\ndetect_cpu_isa();\n}\n- return g_cpu_has_avx2 == 1;\n+ return g_cpu_has_avx2;\n}\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use ZI bools for global state trackers
61,745
31.05.2021 23:57:44
-3,600
8e9731ba0877de1215a13be7d52d97464c49bab7
Add thread syncs on CPU state tracker updates
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_platform_isa_detection.cpp", "new_path": "Source/astcenc_platform_isa_detection.cpp", "diff": "@@ -46,6 +46,8 @@ static bool g_cpu_has_f16c { false };\nPlatform code for Visual Studio\n============================================================================ */\n#if !defined(__clang__) && defined(_MSC_VER)\n+#define WIN32_LEAN_AND_MEAN\n+#include <Windows.h>\n#include <intrin.h>\n/**\n@@ -76,6 +78,8 @@ static void detect_cpu_isa()\ng_cpu_has_avx2 = data[1] & (1 << 5) ? true : false;\n}\n+ // Ensure state bits are updated before init flag is updated\n+ MemoryBarrier();\ng_init = true;\n}\n@@ -109,6 +113,9 @@ static void detect_cpu_isa()\ng_cpu_has_avx2 = data[1] & (1 << 5) ? true : false;\n}\n+\n+ // Ensure state bits are updated before init flag is updated\n+ __sync_synchronize();\ng_init = true;\n}\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add thread syncs on CPU state tracker updates
61,745
01.06.2021 00:24:33
-3,600
1a2d13dbf2b2b6e3ac3e8e8066944aca2f54b803
Tune 2 partition + 2 plane heuristic to skip more often
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1634,7 +1634,7 @@ void compress_block(\n// partitions is even less likely to help, so skip those. This is NOT exposed as a heuristic that the user can\n// control as we've found no need to - this is a very reliable heuristic even on torture\n// test images.\n- if (best_1_partition_2_plane_result > best_1_partition_1_plane_result * ctx.config.tune_2_plane_early_out_limit_factor)\n+ if (best_1_partition_2_plane_result > (best_1_partition_1_plane_result * ctx.config.tune_2_plane_early_out_limit_factor))\n{\ntrace_add_data(\"skip\", \"tune_2_plane_early_out_limit_correlation_builtin\");\ncontinue;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -61,16 +61,16 @@ struct astcenc_preset_config {\nstatic const std::array<astcenc_preset_config, 5> preset_configs_high {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.05f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.65f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 1.05f, 0.5f\n+ 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.65f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 2, 2, 95.0f, 70.0f, 2.5f, 2.5f, 1.2f, 1.25f, 1.05f, 0.75f\n+ 4, 26, 76, 2, 2, 95.0f, 70.0f, 2.5f, 2.5f, 1.2f, 1.25f, 0.65f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 1.05f, 0.95f\n+ 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.75f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n@@ -85,16 +85,16 @@ static const std::array<astcenc_preset_config, 5> preset_configs_high {{\nstatic const std::array<astcenc_preset_config, 5> preset_configs_mid {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.05f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.65f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 1.05f, 0.5f\n+ 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.65f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 2, 2, 95.0f, 70.0f, 3.0f, 3.0f, 1.2f, 1.25f, 1.05f, 0.75f\n+ 4, 26, 76, 2, 2, 95.0f, 70.0f, 3.0f, 3.0f, 1.2f, 1.25f, 0.65f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 1.05f, 0.95f\n+ 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.75f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n@@ -109,13 +109,13 @@ static const std::array<astcenc_preset_config, 5> preset_configs_mid {{\nstatic const std::array<astcenc_preset_config, 5> preset_configs_low {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.05f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.75f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 3, 10, 53, 3, 2, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 1.05f, 0.5f\n+ 3, 10, 53, 3, 2, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 0.75f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 3, 26, 76, 3, 2, 95.0f, 70.0f, 3.5f, 3.5f, 1.2f, 1.25f, 1.05f, 0.75f\n+ 3, 26, 76, 3, 2, 95.0f, 70.0f, 3.5f, 3.5f, 1.2f, 1.25f, 0.75f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n4, 75, 92, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 1.05f, 0.95f\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Tune 2 partition + 2 plane heuristic to skip more often
61,745
01.06.2021 22:34:59
-3,600
b4f22ebc69a0197e4c72acf90fde7e4ca0bf8814
Remove dual plane for 2+ partitions
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -576,8 +576,6 @@ static float compress_symbolic_block_for_partition_1plane(\n* @param blk The image block color data to compress.\n* @param ewb The image block weighted error data.\n* @param tune_errorval_threshold The error value threshold.\n- * @param partition_count The partition count.\n- * @param partition_index The partition index if @c partition_count is 2-4.\n* @param plane2_component The component index for the second plane of weights.\n* @param[out] scb The symbolic compressed block output.\n* @param[out] tmpbuf The quantized weights for plane 1.\n@@ -588,29 +586,20 @@ static float compress_symbolic_block_for_partition_2planes(\nconst image_block& blk,\nconst error_weight_block& ewb,\nfloat tune_errorval_threshold,\n- unsigned int partition_count,\n- unsigned int partition_index,\nunsigned int plane2_component,\nsymbolic_compressed_block& scb,\ncompression_working_buffers& tmpbuf\n) {\n- promise(partition_count > 0);\npromise(config.tune_candidate_limit > 0);\npromise(config.tune_refinement_limit > 0);\npromise(bsd.decimation_mode_count > 0);\n- static const int free_bits_for_partition_count[5] = {\n- 0, 113 - 4, 109 - 4 - PARTITION_INDEX_BITS, 106 - 4 - PARTITION_INDEX_BITS, 103 - 4 - PARTITION_INDEX_BITS\n- };\n-\n- const auto& pi = bsd.get_partition_info(partition_count, partition_index);\n-\n// Compute ideal weights and endpoint colors, with no quantization or decimation\nendpoints_and_weights& ei1 = tmpbuf.ei1;\nendpoints_and_weights& ei2 = tmpbuf.ei2;\nendpoints_and_weights* eix1 = tmpbuf.eix1;\nendpoints_and_weights* eix2 = tmpbuf.eix2;\n- compute_ideal_colors_and_weights_2planes(bsd, blk, ewb, pi, plane2_component, ei1, ei2);\n+ compute_ideal_colors_and_weights_2planes(bsd, blk, ewb, plane2_component, ei1, ei2);\n// Compute ideal weights and endpoint colors for every decimation\nfloat *decimated_quantized_weights = tmpbuf.decimated_quantized_weights;\n@@ -648,16 +637,14 @@ static float compress_symbolic_block_for_partition_2planes(\n// weight pair, compute the smallest weight that will result in a color value greater than 1\nvfloat4 min_ep1(10.0f);\nvfloat4 min_ep2(10.0f);\n- for (unsigned int i = 0; i < partition_count; i++)\n- {\n- vfloat4 ep1 = (vfloat4(1.0f) - ei1.ep.endpt0[i]) / (ei1.ep.endpt1[i] - ei1.ep.endpt0[i]);\n+\n+ vfloat4 ep1 = (vfloat4(1.0f) - ei1.ep.endpt0[0]) / (ei1.ep.endpt1[0] - ei1.ep.endpt0[0]);\nvmask4 use_ep1 = (ep1 > vfloat4(0.5f)) & (ep1 < min_ep1);\nmin_ep1 = select(min_ep1, ep1, use_ep1);\n- vfloat4 ep2 = (vfloat4(1.0f) - ei2.ep.endpt0[i]) / (ei2.ep.endpt1[i] - ei2.ep.endpt0[i]);\n+ vfloat4 ep2 = (vfloat4(1.0f) - ei2.ep.endpt0[0]) / (ei2.ep.endpt1[0] - ei2.ep.endpt0[0]);\nvmask4 use_ep2 = (ep2 > vfloat4(0.5f)) & (ep2 < min_ep2);\nmin_ep2 = select(min_ep2, ep2, use_ep2);\n- }\nvfloat4 err_max(1e30f);\nvmask4 err_mask = vint4::lane_id() == vint4(plane2_component);\n@@ -713,7 +700,7 @@ static float compress_symbolic_block_for_partition_2planes(\nunsigned int bits_used_by_weights = get_ise_sequence_bitcount(\n2 * di.weight_count,\nbm.get_weight_quant_mode());\n- int bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\n+ int bitcount = 113 - 4 - bits_used_by_weights;\nif (bitcount <= 0 || bits_used_by_weights < 24 || bits_used_by_weights > 96)\n{\nqwt_errors[i] = 1e38f;\n@@ -757,6 +744,7 @@ static float compress_symbolic_block_for_partition_2planes(\nendpoints epm;\nmerge_endpoints(ei1.ep, ei2.ep, plane2_component, epm);\n+ const auto& pi = bsd.get_partition_info(1, 0);\nunsigned int candidate_count = compute_ideal_endpoint_formats(\nbsd, pi, blk, ewb, epm, qwt_bitcounts, qwt_errors,\nconfig.tune_candidate_limit, partition_format_specifiers, block_mode_index,\n@@ -809,67 +797,24 @@ static float compress_symbolic_block_for_partition_2planes(\nfor (unsigned int l = 0; l < config.tune_refinement_limit; l++)\n{\nrecompute_ideal_colors_2planes(\n- blk, ewb, pi, di,\n+ blk, ewb, bsd, di,\nweight_quant_mode, workscb.weights, workscb.weights + WEIGHTS_PLANE2_OFFSET,\nepm, rgbs_colors, rgbo_colors, plane2_component);\n// Quantize the chosen color\n- for (unsigned int j = 0; j < partition_count; j++)\n- {\n- workscb.color_formats[j] = pack_color_endpoints(\n- epm.endpt0[j],\n- epm.endpt1[j],\n- rgbs_colors[j], rgbo_colors[j],\n- partition_format_specifiers[i][j],\n- workscb.color_values[j],\n+ workscb.color_formats[0] = pack_color_endpoints(\n+ epm.endpt0[0],\n+ epm.endpt1[0],\n+ rgbs_colors[0], rgbo_colors[0],\n+ partition_format_specifiers[i][0],\n+ workscb.color_values[0],\n(quant_method)color_quant_level[i]);\n- }\n-\n- // If all the color endpoint modes are the same, we get a few more bits to store colors;\n- // let's see if we can take advantage of this: requantize all the colors and see if the\n- // endpoint modes remain the same.\n- workscb.color_formats_matched = 0;\n-\n- if ((partition_count >= 2 && workscb.color_formats[0] == workscb.color_formats[1]\n- && color_quant_level[i] != color_quant_level_mod[i])\n- && (partition_count == 2 || (workscb.color_formats[0] == workscb.color_formats[2]\n- && (partition_count == 3 || (workscb.color_formats[0] == workscb.color_formats[3])))))\n- {\n- uint8_t colorvals[BLOCK_MAX_PARTITIONS][12];\n- int color_formats_mod[BLOCK_MAX_PARTITIONS] { 0 };\n- for (unsigned int j = 0; j < partition_count; j++)\n- {\n- color_formats_mod[j] = pack_color_endpoints(\n- epm.endpt0[j],\n- epm.endpt1[j],\n- rgbs_colors[j],\n- rgbo_colors[j],\n- partition_format_specifiers[i][j],\n- colorvals[j],\n- (quant_method)color_quant_level_mod[i]);\n- }\n-\n- if (color_formats_mod[0] == color_formats_mod[1]\n- && (partition_count == 2 || (color_formats_mod[0] == color_formats_mod[2]\n- && (partition_count == 3 || (color_formats_mod[0] == color_formats_mod[3])))))\n- {\n- workscb.color_formats_matched = 1;\n- for (unsigned int j = 0; j < BLOCK_MAX_PARTITIONS; j++)\n- {\n- for (unsigned int k = 0; k < 8; k++)\n- {\n- workscb.color_values[j][k] = colorvals[j][k];\n- }\n-\n- workscb.color_formats[j] = color_formats_mod[j];\n- }\n- }\n- }\n// Store header fields\n- workscb.partition_count = partition_count;\n- workscb.partition_index = partition_index;\n+ workscb.partition_count = 1;\n+ workscb.partition_index = 0;\nworkscb.quant_mode = workscb.color_formats_matched ? color_quant_level_mod[i] : color_quant_level[i];\n+ workscb.color_formats_matched = 0;\nworkscb.block_mode = qw_bm.mode_index;\nworkscb.plane2_component = plane2_component;\nworkscb.block_type = SYM_BTYPE_NONCONST;\n@@ -1530,8 +1475,6 @@ void compress_block(\nfloat errorval = compress_symbolic_block_for_partition_2planes(\nctx.config, *bsd, blk, ewb,\nerror_threshold * errorval_overshoot,\n- 1, // partition count\n- 0, // partition index\ni, // the color component to test a separate plane of weights for.\nscb, tmpbuf);\n@@ -1582,11 +1525,6 @@ void compress_block(\nfloat best_1_partition_1_plane_result = best_errorvals_in_modes[MODE_0_1_PARTITION_1_PLANE];\n- float best_1_partition_2_plane_result = astc::min(best_errorvals_in_modes[MODE_1_1_PARTITION_2_PLANE_R],\n- best_errorvals_in_modes[MODE_2_1_PARTITION_2_PLANE_G],\n- best_errorvals_in_modes[MODE_3_1_PARTITION_2_PLANE_B],\n- best_errorvals_in_modes[MODE_4_1_PARTITION_2_PLANE_A]);\n-\nfloat best_2_partition_1_plane_result = astc::min(best_errorvals_in_modes[MODE_5_2_PARTITION_1_PLANE_UNCOR],\nbest_errorvals_in_modes[MODE_6_2_PARTITION_1_PLANE_COR]);\n@@ -1608,58 +1546,6 @@ void compress_block(\ntrace_add_data(\"skip\", \"tune_3_partition_early_out_limit_factor\");\ngoto END_OF_TESTS;\n}\n-\n- // Skip testing dual weight planes for:\n- // * 4 partitions (can't be encoded by the format)\n- if (partition_count == 4)\n- {\n- continue;\n- }\n-\n- // * Luminance only blocks (never need for a second plane)\n- if (blk.grayscale && !uses_alpha)\n- {\n- trace_add_data(\"skip\", \"grayscale no alpha block \");\n- continue;\n- }\n-\n- // * Blocks with higher component correlation than the tuning cutoff\n- if (block_skip_two_plane)\n- {\n- trace_add_data(\"skip\", \"tune_2_plane_early_out_limit_correlation\");\n- continue;\n- }\n-\n- // If adding a 2nd plane to 1 partition doesn't help by some margin then trying with more\n- // partitions is even less likely to help, so skip those. This is NOT exposed as a heuristic that the user can\n- // control as we've found no need to - this is a very reliable heuristic even on torture\n- // test images.\n- if (best_1_partition_2_plane_result > (best_1_partition_1_plane_result * ctx.config.tune_2_plane_early_out_limit_factor))\n- {\n- trace_add_data(\"skip\", \"tune_2_plane_early_out_limit_correlation_builtin\");\n- continue;\n- }\n-\n- TRACE_NODE(node1, \"pass\");\n- trace_add_data(\"partition_count\", partition_count);\n- trace_add_data(\"partition_index\", partition_index_2planes & (BLOCK_MAX_PARTITIONINGS - 1));\n- trace_add_data(\"plane_count\", 2);\n- trace_add_data(\"plane_component\", partition_index_2planes >> PARTITION_INDEX_BITS);\n-\n- float errorval = compress_symbolic_block_for_partition_2planes(\n- ctx.config, *bsd, blk, ewb,\n- error_threshold * errorval_overshoot,\n- partition_count,\n- partition_index_2planes & (BLOCK_MAX_PARTITIONINGS - 1),\n- partition_index_2planes >> PARTITION_INDEX_BITS,\n- scb, tmpbuf);\n-\n- // Modes 7, 10 (13 is unreachable)\n- if (errorval < error_threshold)\n- {\n- trace_add_data(\"exit\", \"quality hit\");\n- goto END_OF_TESTS;\n- }\n}\ntrace_add_data(\"exit\", \"quality not hit\");\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -619,11 +619,12 @@ void compute_ideal_colors_and_weights_2planes(\nconst block_size_descriptor& bsd,\nconst image_block& blk,\nconst error_weight_block& ewb,\n- const partition_info& pi,\nunsigned int plane2_component,\nendpoints_and_weights& ei1,\nendpoints_and_weights& ei2\n) {\n+ const auto& pi = bsd.get_partition_info(1, 0);\n+\nbool uses_alpha = blk.is_using_alpha();;\nassert(plane2_component < BLOCK_MAX_COMPONENTS);\n@@ -1110,6 +1111,8 @@ void recompute_ideal_colors_1plane(\nvfloat4 weight_weight_sum = vfloat4(1e-17f);\nfloat psum = 1e-17f;\n+ bool is_decimated = di.weight_count != di.texel_count;\n+\n// TODO: This loop has too many responsibilities, making it inefficient\nfor (int j = 0; j < texel_count; j++)\n{\n@@ -1120,7 +1123,16 @@ void recompute_ideal_colors_1plane(\n// TODO: Move this calculation out to the color block?\nfloat ls_weight = hadd_rgb_s(color_weight);\n- float idx0 = bilinear_infill(di, weight_set, tix);\n+\n+ float idx0;\n+ if (is_decimated)\n+ {\n+ idx0 = bilinear_infill(di, weight_set, tix);\n+ }\n+ else\n+ {\n+ idx0 = weight_set[tix];\n+ }\nfloat om_idx0 = 1.0f - idx0;\nwmin1 = astc::min(idx0, wmin1);\n@@ -1250,7 +1262,7 @@ void recompute_ideal_colors_1plane(\nvoid recompute_ideal_colors_2planes(\nconst image_block& blk,\nconst error_weight_block& ewb,\n- const partition_info& pi,\n+ const block_size_descriptor& bsd,\nconst decimation_info& di,\nint weight_quant_mode,\nconst uint8_t* weight_set8_plane1,\n@@ -1261,10 +1273,8 @@ void recompute_ideal_colors_2planes(\nint plane2_component\n) {\nint weight_count = di.weight_count;\n- int partition_count = pi.partition_count;\npromise(weight_count > 0);\n- promise(partition_count > 0);\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_mode]);\n@@ -1277,19 +1287,15 @@ void recompute_ideal_colors_2planes(\nplane2_weight_set[i] = qat->unquantized_value[weight_set8_plane2[i]] * (1.0f / 64.0f);\n}\n- for (int i = 0; i < partition_count; i++)\n- {\nvfloat4 rgba_sum(1e-17f);\nvfloat4 rgba_weight_sum(1e-17f);\n- int texel_count = pi.partition_texel_count[i];\n- const uint8_t *texel_indexes = pi.texels_of_partition[i];\n+ // TODOEX: Linearize this without PI\n+ int texel_count = bsd.texel_count;\nfor (int j = 0; j < texel_count; j++)\n{\n- int tix = texel_indexes[j];\n-\n- vfloat4 rgba = blk.texel(tix);\n- vfloat4 error_weight = ewb.error_weights[tix];\n+ vfloat4 rgba = blk.texel(j);\n+ vfloat4 error_weight = ewb.error_weights[j];\nrgba_sum += rgba * error_weight;\nrgba_weight_sum += error_weight;\n@@ -1323,17 +1329,16 @@ void recompute_ideal_colors_2planes(\nfloat psum = 1e-17f;\n// TODO: This loop has too many responsibilities, making it inefficient\n+ // TODOEX: Linearize this without PI\nfor (int j = 0; j < texel_count; j++)\n{\n- int tix = texel_indexes[j];\n-\n- vfloat4 rgba = blk.texel(tix);\n- vfloat4 color_weight = ewb.error_weights[tix];\n+ vfloat4 rgba = blk.texel(j);\n+ vfloat4 color_weight = ewb.error_weights[j];\n// TODO: Move this calculation out to the color block?\nfloat ls_weight = hadd_rgb_s(color_weight);\n- float idx0 = bilinear_infill(di, weight_set, tix);\n+ float idx0 = bilinear_infill(di, weight_set, j);\nfloat om_idx0 = 1.0f - idx0;\nwmin1 = astc::min(idx0, wmin1);\n@@ -1359,7 +1364,7 @@ void recompute_ideal_colors_2planes(\nfloat idx1 = 0.0f;\nfloat om_idx1 = 0.0f;\n- idx1 = bilinear_infill(di, plane2_weight_set, tix);\n+ idx1 = bilinear_infill(di, plane2_weight_set, j);\nom_idx1 = 1.0f - idx1;\nwmin2 = astc::min(idx1, wmin2);\n@@ -1392,9 +1397,8 @@ void recompute_ideal_colors_2planes(\nvfloat4 rgbq_sum = color_vec_x + color_vec_y;\nrgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));\n- vfloat4 rgbovec = compute_rgbo_vector(rgba_weight_sum, weight_weight_sum,\n- rgbq_sum, psum);\n- rgbo_vectors[i] = rgbovec;\n+ vfloat4 rgbovec = compute_rgbo_vector(rgba_weight_sum, weight_weight_sum, rgbq_sum, psum);\n+ rgbo_vectors[0] = rgbovec;\n// We will occasionally get a failure due to the use of a singular (non-invertible) matrix.\n// Record whether such a failure has taken place; if it did, compute rgbo_vectors[] with a\n@@ -1408,7 +1412,7 @@ void recompute_ideal_colors_2planes(\nvfloat4 sds = scale_direction * scale_max;\n- rgbs_vectors[i] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), scalediv);\n+ rgbs_vectors[0] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), scalediv);\nif (wmin1 >= wmax1 * 0.999f)\n{\n@@ -1420,10 +1424,10 @@ void recompute_ideal_colors_2planes(\nvmask4 notnan_mask = avg == avg;\nvmask4 full_mask = p1_mask & notnan_mask;\n- ep.endpt0[i] = select(ep.endpt0[i], avg, full_mask);\n- ep.endpt1[i] = select(ep.endpt1[i], avg, full_mask);\n+ ep.endpt0[0] = select(ep.endpt0[0], avg, full_mask);\n+ ep.endpt1[0] = select(ep.endpt1[0], avg, full_mask);\n- rgbs_vectors[i] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), 1.0f);\n+ rgbs_vectors[0] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), 1.0f);\n}\nelse\n{\n@@ -1454,14 +1458,14 @@ void recompute_ideal_colors_2planes(\nvmask4 notnan_mask = (ep0 == ep0) & (ep1 == ep1);\nvmask4 full_mask = p1_mask & det_mask & notnan_mask;\n- ep.endpt0[i] = select(ep.endpt0[i], ep0, full_mask);\n- ep.endpt1[i] = select(ep.endpt1[i], ep1, full_mask);\n+ ep.endpt0[0] = select(ep.endpt0[0], ep0, full_mask);\n+ ep.endpt1[0] = select(ep.endpt1[0], ep1, full_mask);\nif (fabsf(ls_det1) > (ls_mss1 * 1e-4f) && scale_ep0 == scale_ep0 && scale_ep1 == scale_ep1 && scale_ep0 < scale_ep1)\n{\nfloat scalediv2 = scale_ep0 * (1.0f / scale_ep1);\nvfloat4 sdsm = scale_direction * scale_ep1;\n- rgbs_vectors[i] = vfloat4(sdsm.lane<0>(), sdsm.lane<1>(), sdsm.lane<2>(), scalediv2);\n+ rgbs_vectors[0] = vfloat4(sdsm.lane<0>(), sdsm.lane<1>(), sdsm.lane<2>(), scalediv2);\n}\n}\n@@ -1475,8 +1479,8 @@ void recompute_ideal_colors_2planes(\nvmask4 notnan_mask = avg == avg;\nvmask4 full_mask = p2_mask & notnan_mask;\n- ep.endpt0[i] = select(ep.endpt0[i], avg, full_mask);\n- ep.endpt1[i] = select(ep.endpt1[i], avg, full_mask);\n+ ep.endpt0[0] = select(ep.endpt0[0], avg, full_mask);\n+ ep.endpt1[0] = select(ep.endpt1[0], avg, full_mask);\n}\nelse\n{\n@@ -1497,15 +1501,15 @@ void recompute_ideal_colors_2planes(\nvmask4 notnan_mask = (ep0 == ep0) & (ep1 == ep1);\nvmask4 full_mask = p2_mask & det_mask & notnan_mask;\n- ep.endpt0[i] = select(ep.endpt0[i], ep0, full_mask);\n- ep.endpt1[i] = select(ep.endpt1[i], ep1, full_mask);\n+ ep.endpt0[0] = select(ep.endpt0[0], ep0, full_mask);\n+ ep.endpt1[0] = select(ep.endpt1[0], ep1, full_mask);\n}\n// If the calculation of an RGB-offset vector failed, try to compute a value another way\nif (rgbo_fail)\n{\n- vfloat4 v0 = ep.endpt0[i];\n- vfloat4 v1 = ep.endpt1[i];\n+ vfloat4 v0 = ep.endpt0[0];\n+ vfloat4 v1 = ep.endpt1[0];\nfloat avgdif = hadd_rgb_s(v1 - v0) * (1.0f / 3.0f);\navgdif = astc::max(avgdif, 0.0f);\n@@ -1513,8 +1517,7 @@ void recompute_ideal_colors_2planes(\nvfloat4 avg = (v0 + v1) * 0.5f;\nvfloat4 ep0 = avg - vfloat4(avgdif) * 0.5f;\n- rgbo_vectors[i] = vfloat4(ep0.lane<0>(), ep0.lane<1>(), ep0.lane<2>(), avgdif);\n- }\n+ rgbo_vectors[0] = vfloat4(ep0.lane<0>(), ep0.lane<1>(), ep0.lane<2>(), avgdif);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1783,7 +1783,6 @@ void compute_ideal_colors_and_weights_1plane(\n* @param bsd The block size information.\n* @param blk The image block color data to compress.\n* @param ewb The image block weighted error data.\n- * @param pi The partition info for the current trial.\n* @param plane2_component The component assigned to plane 2.\n* @param[out] ei1 The endpoint and weight values for plane 1.\n* @param[out] ei2 The endpoint and weight values for plane 2.\n@@ -1792,7 +1791,6 @@ void compute_ideal_colors_and_weights_2planes(\nconst block_size_descriptor& bsd,\nconst image_block& blk,\nconst error_weight_block& ewb,\n- const partition_info& pi,\nunsigned int plane2_component,\nendpoints_and_weights& ei1,\nendpoints_and_weights& ei2);\n@@ -2070,7 +2068,7 @@ void recompute_ideal_colors_1plane(\n*\n* @param blk The image block color data to compress.\n* @param ewb The image block weighted error data.\n- * @param pi The partition info for the current trial.\n+ * @param bsd The block_size descriptor.\n* @param di The weight grid decimation table.\n* @param weight_quant_mode The weight grid quantization level.\n* @param weight_set8_plane1 The quantized weight set for plane 1.\n@@ -2083,12 +2081,13 @@ void recompute_ideal_colors_1plane(\nvoid recompute_ideal_colors_2planes(\nconst image_block& blk,\nconst error_weight_block& ewb,\n- const partition_info& pi,\n+ const block_size_descriptor& bsd,\nconst decimation_info& di,\nint weight_quant_mode,\nconst uint8_t* weight_set8_plane1,\nconst uint8_t* weight_set8_plane2,\nendpoints& ep,\n+ // TODOEX: Make these not vectors ...\nvfloat4 rgbs_vectors[BLOCK_MAX_PARTITIONS],\nvfloat4 rgbo_vectors[BLOCK_MAX_PARTITIONS],\nint plane2_component);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove dual plane for 2+ partitions
61,745
01.06.2021 22:52:25
-3,600
f4a6c62778d1c5851df29c70007761a06790297a
Skip bilinear weight infill for 1:1 weight grids
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -683,20 +683,41 @@ float compute_error_of_weight_set_1plane(\nfloat error_summa = 0.0f;\nunsigned int texel_count = di.texel_count;\n+ bool is_decimated = di.texel_count != di.weight_count;\n+\n// Process SIMD-width chunks, safe to over-fetch - the extra space is zero initialized\n+ if (is_decimated)\n+ {\nfor (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Compute the bilinear interpolation of the decimated weight grid\nvfloat current_values = bilinear_infill_vla(di, weights, i);\n// Compute the error between the computed value and the ideal weight\n- vfloat actual_values = loada(&(eai.weights[i]));\n+ vfloat actual_values = loada(eai.weights + i);\nvfloat diff = current_values - actual_values;\n- vfloat significance = loada(&(eai.weight_error_scale[i]));\n+ vfloat significance = loada(eai.weight_error_scale + i);\nvfloat error = diff * diff * significance;\nhaccumulate(error_summav, error);\n}\n+ }\n+ else\n+ {\n+ for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n+ {\n+ // Load the weight set directly, without interpolation\n+ vfloat current_values = loada(weights + i);\n+\n+ // Compute the error between the computed value and the ideal weight\n+ vfloat actual_values = loada(eai.weights + i);\n+ vfloat diff = current_values - actual_values;\n+ vfloat significance = loada(eai.weight_error_scale + i);\n+ vfloat error = diff * diff * significance;\n+\n+ haccumulate(error_summav, error);\n+ }\n+ }\n// Resolve the final scalar accumulator sum\nhaccumulate(error_summa, error_summav);\n@@ -715,8 +736,11 @@ float compute_error_of_weight_set_2planes(\nvfloat4 error_summav = vfloat4::zero();\nfloat error_summa = 0.0f;\nunsigned int texel_count = di.texel_count;\n+ bool is_decimated = di.texel_count != di.weight_count;\n// Process SIMD-width chunks, safe to over-fetch - the extra space is zero initialized\n+ if (is_decimated)\n+ {\nfor (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Plane 1\n@@ -724,21 +748,47 @@ float compute_error_of_weight_set_2planes(\nvfloat current_values1 = bilinear_infill_vla(di, weights1, i);\n// Compute the error between the computed value and the ideal weight\n- vfloat actual_values1 = loada(&(eai1.weights[i]));\n+ vfloat actual_values1 = loada(eai1.weights + i);\nvfloat diff = current_values1 - actual_values1;\n- vfloat error1 = diff * diff * loada(&(eai1.weight_error_scale[i]));\n+ vfloat error1 = diff * diff * loada(eai1.weight_error_scale + i);\n// Plane 2\n// Compute the bilinear interpolation of the decimated weight grid\nvfloat current_values2 = bilinear_infill_vla(di, weights2, i);\n// Compute the error between the computed value and the ideal weight\n- vfloat actual_values2 = loada(&(eai2.weights[i]));\n+ vfloat actual_values2 = loada(eai2.weights + i);\ndiff = current_values2 - actual_values2;\n- vfloat error2 = diff * diff * loada(&(eai2.weight_error_scale[i]));\n+ vfloat error2 = diff * diff * loada(eai2.weight_error_scale + i);\nhaccumulate(error_summav, error1 + error2);\n}\n+ }\n+ else\n+ {\n+ for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n+ {\n+ // Plane 1\n+ // Load the weight set directly, without interpolation\n+ vfloat current_values1 = loada(weights1 + i);\n+\n+ // Compute the error between the computed value and the ideal weight\n+ vfloat actual_values1 = loada(eai1.weights + i);\n+ vfloat diff = current_values1 - actual_values1;\n+ vfloat error1 = diff * diff * loada(eai1.weight_error_scale + i);\n+\n+ // Plane 2\n+ // Load the weight set directly, without interpolation\n+ vfloat current_values2 = loada(weights2 + i);\n+\n+ // Compute the error between the computed value and the ideal weight\n+ vfloat actual_values2 = loada(eai2.weights + i);\n+ diff = current_values2 - actual_values2;\n+ vfloat error2 = diff * diff * loada(eai2.weight_error_scale + i);\n+\n+ haccumulate(error_summav, error1 + error2);\n+ }\n+ }\n// Resolve the final scalar accumulator sum\nhaccumulate(error_summa, error_summav);\n@@ -1057,6 +1107,7 @@ void recompute_ideal_colors_1plane(\n) {\nint weight_count = di.weight_count;\nint partition_count = pi.partition_count;\n+ bool is_decimated = di.weight_count != di.texel_count;\npromise(weight_count > 0);\npromise(partition_count > 0);\n@@ -1120,7 +1171,11 @@ void recompute_ideal_colors_1plane(\n// TODO: Move this calculation out to the color block?\nfloat ls_weight = hadd_rgb_s(color_weight);\n- float idx0 = bilinear_infill(di, weight_set, tix);\n+ float idx0 = weight_set[tix];\n+ if (is_decimated)\n+ {\n+ idx0 = bilinear_infill(di, weight_set, tix);\n+ }\nfloat om_idx0 = 1.0f - idx0;\nwmin1 = astc::min(idx0, wmin1);\n@@ -1262,6 +1317,7 @@ void recompute_ideal_colors_2planes(\n) {\nint weight_count = di.weight_count;\nint partition_count = pi.partition_count;\n+ bool is_decimated = di.weight_count != di.texel_count;\npromise(weight_count > 0);\npromise(partition_count > 0);\n@@ -1333,7 +1389,11 @@ void recompute_ideal_colors_2planes(\n// TODO: Move this calculation out to the color block?\nfloat ls_weight = hadd_rgb_s(color_weight);\n- float idx0 = bilinear_infill(di, weight_set, tix);\n+ float idx0 = weight_set[tix];\n+ if (is_decimated)\n+ {\n+ idx0 = bilinear_infill(di, weight_set, tix);\n+ }\nfloat om_idx0 = 1.0f - idx0;\nwmin1 = astc::min(idx0, wmin1);\n@@ -1356,12 +1416,13 @@ void recompute_ideal_colors_2planes(\nright_sum += right;\nlmrs_sum += lmrs;\n- float idx1 = 0.0f;\n- float om_idx1 = 0.0f;\n-\n+ float idx1 = plane2_weight_set[tix];\n+ if (is_decimated)\n+ {\nidx1 = bilinear_infill(di, plane2_weight_set, tix);\n+ }\n- om_idx1 = 1.0f - idx1;\n+ float om_idx1 = 1.0f - idx1;\nwmin2 = astc::min(idx1, wmin2);\nwmax2 = astc::max(idx1, wmax2);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Skip bilinear weight infill for 1:1 weight grids
61,745
01.06.2021 23:18:15
-3,600
5b2a70c3b75f5fb34d3c39e67d207d33a9db1526
Remove now unused compression tuning setting
[ { "change_type": "MODIFY", "old_path": "Docs/ChangeLog-3x.md", "new_path": "Docs/ChangeLog-3x.md", "diff": "@@ -33,9 +33,11 @@ updated `astcenc.h` header.\ndetailed documentation.\n* **Feature:** New heuristics have been added for controlling when to use\n2 planes. The previous `tune_two_plane_early_out_limit` has been renamed to\n- `tune_2_plane_early_out_limit_correlation` and a new heuristic\n- `tune_2_plane_early_out_limit_factor` has been added. See command line help\n- for more detailed documentation.\n+ `tune_2_plane_early_out_limit_correlation`. See command line help for more\n+ detailed documentation.\n+ * **Feature:** Support for using dual weight planes has been restricted to\n+ single partition blocks; it rarely helps blocks with 2+ partitions and\n+ takes considerable compression search time.\n* **API Change:** The core APIs for `astcenc_compress_image()` and for\n`astcenc_decompress_image()` now accept swizzle structures by `const`\npointer, instead of pass-by-value.\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "@@ -541,13 +541,6 @@ struct astcenc_config\n*/\nfloat tune_3_partition_early_out_limit_factor;\n- /**\n- * @brief The threshold for skipping two weight planes (-2planelimitfactor).\n- *\n- * This option is ineffective for normal maps.\n- */\n- float tune_2_plane_early_out_limit_factor;\n-\n/**\n* @brief The threshold for skipping two weight planes (-2planelimitcorrelation).\n*\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1286,16 +1286,10 @@ static float prepare_block_statistics(\n// Do not reorder; we compute array indices programatically\nenum trial_modes {\nMODE_0_1_PARTITION_1_PLANE = 0,\n- MODE_1_1_PARTITION_2_PLANE_R,\n- MODE_2_1_PARTITION_2_PLANE_G,\n- MODE_3_1_PARTITION_2_PLANE_B,\n- MODE_4_1_PARTITION_2_PLANE_A,\nMODE_5_2_PARTITION_1_PLANE_UNCOR,\nMODE_6_2_PARTITION_1_PLANE_COR,\n- MODE_7_2_PARTITION_2_PLANE,\nMODE_8_3_PARTITION_1_PLANE_UNCOR,\nMODE_9_3_PARTITION_1_PLANE_COR,\n- MODE_10_3_PARTITION_2_PLANE,\nMODE_11_4_PARTITION_1_PLANE_UNCOR,\nMODE_12_4_PARTITION_1_PLANE_COR,\nMODE_COUNT\n@@ -1478,8 +1472,6 @@ void compress_block(\ni, // the color component to test a separate plane of weights for.\nscb, tmpbuf);\n- best_errorvals_in_modes[MODE_1_1_PARTITION_2_PLANE_R + i] = errorval;\n-\n// Modes 7, 10 (13 is unreachable)\nif (errorval < error_threshold)\n{\n@@ -1515,7 +1507,7 @@ void compress_block(\nscb, tmpbuf);\n// Modes 5, 6, 8, 9, 11, 12\n- best_errorvals_in_modes[3 * (partition_count - 2) + 5 + i] = errorval;\n+ best_errorvals_in_modes[2 * (partition_count - 2) + 1 + i] = errorval;\nif (errorval < error_threshold)\n{\ntrace_add_data(\"exit\", \"quality hit\");\n@@ -1532,7 +1524,7 @@ void compress_block(\nbest_errorvals_in_modes[MODE_9_3_PARTITION_1_PLANE_COR]);\n// If adding a second partition doesn't improve much over using one partition then skip more\n- // thorough searches. This skips 2pt/2pl, 3pt/1pl, 3pt/2pl, 4pt/1pl.\n+ // thorough searches as it's not likely to help.\nif (partition_count == 2 && (best_2_partition_1_plane_result > (best_1_partition_1_plane_result * ctx.config.tune_2_partition_early_out_limit_factor)))\n{\ntrace_add_data(\"skip\", \"tune_2_partition_early_out_limit_factor\");\n@@ -1540,7 +1532,7 @@ void compress_block(\n}\n// If adding a third partition doesn't improve much over using two partitions then skip more\n- // thorough searches as it's not going to help. This skips 3pt/2pl, 4pt/1pl.\n+ // thorough searches as it's not likely to help.\nif (partition_count == 3 && (best_3_partition_1_plane_result > (best_2_partition_1_plane_result * ctx.config.tune_3_partition_early_out_limit_factor)))\n{\ntrace_add_data(\"skip\", \"tune_3_partition_early_out_limit_factor\");\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -49,7 +49,6 @@ struct astcenc_preset_config {\nfloat tune_refinement_mse_overshoot;\nfloat tune_2_partition_early_out_limit_factor;\nfloat tune_3_partition_early_out_limit_factor;\n- float tune_2_plane_early_out_limit_factor;\nfloat tune_2_plane_early_out_limit_correlation;\n};\n@@ -61,19 +60,19 @@ struct astcenc_preset_config {\nstatic const std::array<astcenc_preset_config, 5> preset_configs_high {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.65f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.65f, 0.5f\n+ 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 2, 2, 95.0f, 70.0f, 2.5f, 2.5f, 1.2f, 1.25f, 0.65f, 0.75f\n+ 4, 26, 76, 2, 2, 95.0f, 70.0f, 2.5f, 2.5f, 1.2f, 1.25f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.75f, 0.95f\n+ 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n}\n}};\n@@ -85,19 +84,19 @@ static const std::array<astcenc_preset_config, 5> preset_configs_high {{\nstatic const std::array<astcenc_preset_config, 5> preset_configs_mid {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.65f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.65f, 0.5f\n+ 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 2, 2, 95.0f, 70.0f, 3.0f, 3.0f, 1.2f, 1.25f, 0.65f, 0.75f\n+ 4, 26, 76, 2, 2, 95.0f, 70.0f, 3.0f, 3.0f, 1.2f, 1.25f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.75f, 0.95f\n+ 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n}\n}};\n@@ -109,19 +108,19 @@ static const std::array<astcenc_preset_config, 5> preset_configs_mid {{\nstatic const std::array<astcenc_preset_config, 5> preset_configs_low {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.75f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 3, 10, 53, 3, 2, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 0.75f, 0.5f\n+ 3, 10, 53, 3, 2, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 3, 26, 76, 3, 2, 95.0f, 70.0f, 3.5f, 3.5f, 1.2f, 1.25f, 0.75f, 0.75f\n+ 3, 26, 76, 3, 2, 95.0f, 70.0f, 3.5f, 3.5f, 1.2f, 1.25f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 75, 92, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 1.05f, 0.95f\n+ 4, 75, 92, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n}\n}};\n@@ -434,7 +433,6 @@ static astcenc_error validate_config(\nconfig.tune_refinement_mse_overshoot = astc::max(config.tune_refinement_mse_overshoot, 1.0f);\nconfig.tune_2_partition_early_out_limit_factor = astc::max(config.tune_2_partition_early_out_limit_factor, 0.0f);\nconfig.tune_3_partition_early_out_limit_factor = astc::max(config.tune_3_partition_early_out_limit_factor, 0.0f);\n- config.tune_2_plane_early_out_limit_factor = astc::max(config.tune_2_plane_early_out_limit_factor, 0.0f);\nconfig.tune_2_plane_early_out_limit_correlation = astc::max(config.tune_2_plane_early_out_limit_correlation, 0.0f);\n// Specifying a zero weight color component is not allowed; force to small value\n@@ -542,7 +540,6 @@ astcenc_error astcenc_config_init(\nconfig.tune_2_partition_early_out_limit_factor = (*preset_configs)[start].tune_2_partition_early_out_limit_factor;\nconfig.tune_3_partition_early_out_limit_factor =(*preset_configs)[start].tune_3_partition_early_out_limit_factor;\n- config.tune_2_plane_early_out_limit_factor = (*preset_configs)[start].tune_2_plane_early_out_limit_factor;\nconfig.tune_2_plane_early_out_limit_correlation = (*preset_configs)[start].tune_2_plane_early_out_limit_correlation;\n}\n// Start and end node are not the same - so interpolate between them\n@@ -578,7 +575,6 @@ astcenc_error astcenc_config_init(\nconfig.tune_2_partition_early_out_limit_factor = LERP(tune_2_partition_early_out_limit_factor);\nconfig.tune_3_partition_early_out_limit_factor = LERP(tune_3_partition_early_out_limit_factor);\n- config.tune_2_plane_early_out_limit_factor = LERP(tune_2_plane_early_out_limit_factor);\nconfig.tune_2_plane_early_out_limit_correlation = LERP(tune_2_plane_early_out_limit_correlation);\n#undef LERP\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -934,17 +934,6 @@ static int edit_astcenc_config(\nconfig.tune_3_partition_early_out_limit_factor = static_cast<float>(atof(argv[argidx - 1]));\n}\n- else if (!strcmp(argv[argidx], \"-2planelimitfactor\"))\n- {\n- argidx += 2;\n- if (argidx > argc)\n- {\n- printf(\"ERROR: -2planelimitfactor switch with no argument\\n\");\n- return 1;\n- }\n-\n- config.tune_2_plane_early_out_limit_factor = static_cast<float>(atof(argv[argidx - 1]));\n- }\nelse if (!strcmp(argv[argidx], \"-2planelimitcorrelation\"))\n{\nargidx += 2;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -399,18 +399,6 @@ ADVANCED COMPRESSION\n-thorough : 1.25\n-exhaustive : 10.00\n- -2planelimitfactor <factor>\n- Skip encodings with two weight planes, unless the best one\n- partition score using two weight planes is better than the\n- best one partition score using one weight plane by this\n- factor. Preset defaults are:\n-\n- -fastest : 1.05\n- -fast : 1.05\n- -medium : 1.05\n- -thorough : 1.05\n- -exhaustive : 10.00\n-\n-2planelimitcorrelation <factor>\nStop compression after testing only one plane of weights, unless\nthe minimum color correlation factor between any pair of color\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove now unused compression tuning setting
61,745
02.06.2021 09:06:12
-3,600
c64feb0d62240a663c8b54d53bba386629fccfdf
Pre-bias and float convert quant constants
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -985,8 +985,12 @@ void compute_quantized_weights_for_decimation(\npromise(weight_count > 0);\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[quant_level]);\n- static const int quant_levels[12] { 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32 };\n- float quant_level_m1 = (float)(quant_levels[quant_level] - 1);\n+ // The available quant levels, stored with a minus 1 bias\n+ static const float quant_levels_m1[12] {\n+ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 7.0f, 9.0f, 11.0f, 15.0f, 19.0f, 23.0f, 31.0f\n+ };\n+\n+ float quant_level_m1 = quant_levels_m1[quant_level];\n// Quantize the weight set using both the specified low/high bounds and standard 0..1 bounds\nassert(high_bound > low_bound);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Pre-bias and float convert quant constants
61,745
02.06.2021 12:05:28
-3,600
3166acdbc80b0fef54eb4c612058012550311a4a
Generalize constant component early-outs for dual plane searches This primarily helps material and mask data where blocks of semi-constant color are not unknown ...
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1457,7 +1457,7 @@ void compress_block(\nbest_errorvals_in_modes[i] = 1e30f;\n}\n- bool uses_alpha = blk.is_using_alpha();\n+ bool uses_alpha = !blk.is_constant_channel(3);\n// Trial using 1 plane of weights and 1 partition.\n@@ -1521,9 +1521,9 @@ void compress_block(\ncontinue;\n}\n- if (!uses_alpha && i == 3)\n+ if (blk.is_constant_channel(i))\n{\n- trace_add_data(\"skip\", \"no alpha component\");\n+ trace_add_data(\"skip\", \"constant component\");\ncontinue;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -505,7 +505,7 @@ void find_best_partition_candidates(\nunsigned int partition_sequence[BLOCK_MAX_PARTITIONINGS];\ncompute_kmeans_partition_ordering(bsd, blk, partition_count, partition_sequence);\n- bool uses_alpha = blk.is_using_alpha();\n+ bool uses_alpha = !blk.is_constant_channel(3);\n// Partitioning errors assuming uncorrelated-chrominance endpoints\nfloat uncor_best_error { ERROR_CALC_DEFAULT };\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -604,7 +604,9 @@ void compute_ideal_colors_and_weights_1plane(\nconst partition_info& pi,\nendpoints_and_weights& ei\n) {\n- if (blk.is_using_alpha())\n+ bool uses_alpha = !blk.is_constant_channel(3);\n+\n+ if (uses_alpha)\n{\ncompute_ideal_colors_and_weights_4_comp(bsd, blk, ewb, pi, ei);\n}\n@@ -624,7 +626,7 @@ void compute_ideal_colors_and_weights_2planes(\nendpoints_and_weights& ei1,\nendpoints_and_weights& ei2\n) {\n- bool uses_alpha = blk.is_using_alpha();;\n+ bool uses_alpha = !blk.is_constant_channel(3);\nassert(plane2_component < BLOCK_MAX_COMPONENTS);\nswitch (plane2_component)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -873,17 +873,19 @@ struct image_block\n}\n/**\n- * @brief Test if this block is using alpha.\n+ * @brief Test if a single color channel is constant across the block.\n*\n- * TODO: This looks suspect, but matches the original astcenc 1.7 code. This checks that the\n- * alpha is not constant (no weight needed), NOT that it is 1.0 and not stored as an endpoint.\n- * Review all uses of this function and check that it is sensible ...\n+ * Constant color channels are easier to compress as interpolating between two identical colors\n+ * always returns the same value, irrespective of the weight used. They therefore can be ignored\n+ * for the purposes of weight selection and use of a second weight plane.\n*\n- * @return @c true if the alpha value is not constant across the block, @c false otherwise.\n+ * @return @c true if the channel is constant across the block, @c false otherwise.\n*/\n- inline bool is_using_alpha() const\n+ inline bool is_constant_channel(int channel) const\n{\n- return this->data_min.lane<3>() != this->data_max.lane<3>();\n+ vmask4 lane_mask = vint4::lane_id() == vint4(channel);\n+ vmask4 color_mask = this->data_min == this->data_max;\n+ return any(lane_mask & color_mask);\n}\n/**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Generalize constant component early-outs for dual plane searches This primarily helps material and mask data where blocks of semi-constant color are not unknown ...
61,745
02.06.2021 12:41:15
-3,600
23e52da48c962f4454d405d09cb9271f1f580c51
Add constant component early outs for 2+ partitions
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1623,6 +1623,15 @@ void compress_block(\ncontinue;\n}\n+ int plane2_component = partition_index_2planes >> PARTITION_INDEX_BITS;\n+ int plane2_partition_index = partition_index_2planes & (BLOCK_MAX_PARTITIONINGS - 1);\n+\n+ // * Constant color channel match (never need for a second plane)\n+ if (blk.is_constant_channel(plane2_component))\n+ {\n+ continue;\n+ }\n+\n// * Blocks with higher component correlation than the tuning cutoff\nif (block_skip_two_plane)\n{\n@@ -1631,9 +1640,9 @@ void compress_block(\n}\n// If adding a 2nd plane to 1 partition doesn't help by some margin then trying with more\n- // partitions is even less likely to help, so skip those. This is NOT exposed as a heuristic that the user can\n- // control as we've found no need to - this is a very reliable heuristic even on torture\n- // test images.\n+ // partitions is even less likely to help, so skip those. This is NOT exposed as a heuristic\n+ // that the user can control as we've found no need to - this is a very reliable heuristic\n+ // even on stress test images.\nif (best_1_partition_2_plane_result > (best_1_partition_1_plane_result * ctx.config.tune_2_plane_early_out_limit_factor))\n{\ntrace_add_data(\"skip\", \"tune_2_plane_early_out_limit_correlation_builtin\");\n@@ -1642,16 +1651,16 @@ void compress_block(\nTRACE_NODE(node1, \"pass\");\ntrace_add_data(\"partition_count\", partition_count);\n- trace_add_data(\"partition_index\", partition_index_2planes & (BLOCK_MAX_PARTITIONINGS - 1));\n+ trace_add_data(\"partition_index\", plane2_partition_index);\ntrace_add_data(\"plane_count\", 2);\n- trace_add_data(\"plane_component\", partition_index_2planes >> PARTITION_INDEX_BITS);\n+ trace_add_data(\"plane_component\", plane2_component);\nfloat errorval = compress_symbolic_block_for_partition_2planes(\nctx.config, *bsd, blk, ewb,\nerror_threshold * errorval_overshoot,\npartition_count,\n- partition_index_2planes & (BLOCK_MAX_PARTITIONINGS - 1),\n- partition_index_2planes >> PARTITION_INDEX_BITS,\n+ plane2_partition_index,\n+ plane2_component,\nscb, tmpbuf);\n// Modes 7, 10 (13 is unreachable)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add constant component early outs for 2+ partitions
61,745
02.06.2021 18:00:02
-3,600
0c9ab672282d79d7d46a7ca1f06b327d1e8cb9d2
Add more missing Doxygen
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1283,7 +1283,8 @@ struct avg_var_args\n};\n#if defined(ASTCENC_DIAGNOSTICS)\n-class TraceLog; // See astcenc_diagnostic_trace for details.\n+/* See astcenc_diagnostic_trace header for details. */\n+class TraceLog;\n#endif\n/**\n@@ -1848,6 +1849,12 @@ void compute_quantized_weights_for_decimation(\n/**\n* @brief Compute the infilled weight for a texel index in a decimated grid.\n+ *\n+ * @param di The weight grid decimation to use.\n+ * @param weights The decimated weight values to use.\n+ * @param index The texel index to interpolate.\n+ *\n+ * @return The interpolated weight for the given texel.\n*/\nstatic inline float bilinear_infill(\nconst decimation_info& di,\n@@ -1862,6 +1869,12 @@ static inline float bilinear_infill(\n/**\n* @brief Compute the infilled weight for N texel indices in a decimated grid.\n+ *\n+ * @param di The weight grid decimation to use.\n+ * @param weights The decimated weight values to use.\n+ * @param index The first texel index to interpolate.\n+ *\n+ * @return The interpolated weight for the given set of SIMD_WIDTH texels.\n*/\nstatic inline vfloat bilinear_infill_vla(\nconst decimation_info& di,\n@@ -2095,12 +2108,36 @@ void recompute_ideal_colors_2planes(\nvfloat4 rgbo_vectors[BLOCK_MAX_PARTITIONS],\nint plane2_component);\n+/**\n+ * @brief Expand the deblock weights based on the config deblocking parameter.\n+ *\n+ * The approach to deblocking is a general purpose approach which elevates the error weight\n+ * significance of texels closest to the block periphery. This function computes the deblock weights\n+ * for each texel, which can be mixed on a block-by-block basis with the other error weighting\n+ * parameters to compute a specific per-texel weight for a trial.\n+ *\n+ * @param[in,out] ctx The context to expand.\n+ */\nvoid expand_deblock_weights(\nastcenc_context& ctx);\n-// functions pertaining to weight alignment\n+/**\n+ * @brief Expand the angular tables needed for the alternative to PCA that we use.\n+ */\nvoid prepare_angular_tables();\n+/**\n+ * @brief Compute the angular endpoints for one plane for each block mode.\n+ *\n+ * // TODO: Terminology here is confusing and needs improving.\n+ *\n+ * @param only_always Only consider block modes that are always enabled.\n+ * @param bsd The block size descriptor for the current trial.\n+ * @param decimated_quantized_weights The decimated and quantized weight values.\n+ * @param decimated_weights The significance of each weight.\n+ * @param[out] low_value The lowest weight to consider for each block mode.\n+ * @param[out] high_value The highest weight to consider for each block mode.\n+ */\nvoid compute_angular_endpoints_1plane(\nbool only_always,\nconst block_size_descriptor& bsd,\n@@ -2109,6 +2146,19 @@ void compute_angular_endpoints_1plane(\nfloat low_value[WEIGHTS_MAX_BLOCK_MODES],\nfloat high_value[WEIGHTS_MAX_BLOCK_MODES]);\n+/**\n+ * @brief Compute the angular endpoints for one plane for each block mode.\n+ *\n+ * // TODO: Terminology here is confusing and needs improving.\n+ *\n+ * @param bsd The block size descriptor for the current trial.\n+ * @param decimated_quantized_weights The decimated and quantized weight values.\n+ * @param decimated_weights The significance of each weight.\n+ * @param[out] low_value1 The lowest weight p1 to consider for each block mode.\n+ * @param[out] high_value1 The highest weight p1 to consider for each block mode.\n+ * @param[out] low_value2 The lowest weight p2 to consider for each block mode.\n+ * @param[out] high_value2 The highest weight p2 to consider for each block mode.\n+ */\nvoid compute_angular_endpoints_2planes(\nconst block_size_descriptor& bsd,\nconst float* decimated_quantized_weights,\n@@ -2178,11 +2228,31 @@ float compute_symbolic_block_difference(\nconst image_block& blk,\nconst error_weight_block& ewb) ;\n+/**\n+ * @brief Convert a symbolic representation into a binary physical encoding.\n+ *\n+ * It is assumed that the symbolic encoding is valid and encodable, or\n+ * previously flagged as an error block if an error color it to be encoded.\n+ *\n+ * @param bsd The block size information.\n+ * @param scb The symbolic representation.\n+ * @param[out] pcb The binary encoded data.\n+ */\nvoid symbolic_to_physical(\nconst block_size_descriptor& bsd,\nconst symbolic_compressed_block& scb,\nphysical_compressed_block& pcb);\n+/**\n+ * @brief Convert a binary physical encoding into a symbolic representation.\n+ *\n+ * This function can cope with arbitrary input data; output blocks will be\n+ * flagged as an error block if the encoding is invalid.\n+ *\n+ * @param bsd The block size information.\n+ * @param pcb The binary encoded data.\n+ * @param[out] scb The output symbolic representation.\n+ */\nvoid physical_to_symbolic(\nconst block_size_descriptor& bsd,\nconst physical_compressed_block& pcb,\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add more missing Doxygen
61,745
02.06.2021 19:42:07
-3,600
123cf2269025b080c17608b3aba9eae3c0f8cbb7
Cleanup error threshold handling
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1283,18 +1283,6 @@ static float prepare_block_statistics(\nreturn lowest_correlation;\n}\n-// Do not reorder; we compute array indices programatically\n-enum trial_modes {\n- MODE_0_1_PARTITION_1_PLANE = 0,\n- MODE_5_2_PARTITION_1_PLANE_UNCOR,\n- MODE_6_2_PARTITION_1_PLANE_COR,\n- MODE_8_3_PARTITION_1_PLANE_UNCOR,\n- MODE_9_3_PARTITION_1_PLANE_COR,\n- MODE_11_4_PARTITION_1_PLANE_UNCOR,\n- MODE_12_4_PARTITION_1_PLANE_COR,\n- MODE_COUNT\n-};\n-\n/* See header for documentation. */\nvoid compress_block(\nconst astcenc_context& ctx,\n@@ -1390,11 +1378,16 @@ void compress_block(\nscb.errorval = 1e30f;\nscb.block_type = SYM_BTYPE_ERROR;\n- float best_errorvals_in_modes[MODE_COUNT];\n- for (int i = 0; i < MODE_COUNT; i++)\n- {\n- best_errorvals_in_modes[i] = 1e30f;\n- }\n+ float best_errorvals_for_pcount[BLOCK_MAX_PARTITIONS] {\n+ 1e30f, 1e30f, 1e30f, 1e30f\n+ };\n+\n+ float exit_thresholds_for_pcount[BLOCK_MAX_PARTITIONS] {\n+ 0.0f,\n+ ctx.config.tune_2_partition_early_out_limit_factor,\n+ ctx.config.tune_3_partition_early_out_limit_factor,\n+ 0.0f\n+ };\n// Trial using 1 plane of weights and 1 partition.\n@@ -1423,8 +1416,7 @@ void compress_block(\nerror_threshold * errorval_mult[i] * errorval_overshoot,\n1, 0, scb, tmpbuf);\n- // Mode 0\n- best_errorvals_in_modes[MODE_0_1_PARTITION_1_PLANE] = errorval;\n+ best_errorvals_for_pcount[0] = astc::min(best_errorvals_for_pcount[0], errorval);\nif (errorval < (error_threshold * errorval_mult[i]))\n{\ntrace_add_data(\"exit\", \"quality hit\");\n@@ -1467,10 +1459,8 @@ void compress_block(\nfloat errorval = compress_symbolic_block_for_partition_2planes(\nctx.config, *bsd, blk, ewb,\nerror_threshold * errorval_overshoot,\n- i, // the color component to test a separate plane of weights for.\n- scb, tmpbuf);\n+ i, scb, tmpbuf);\n- // Modes 7, 10 (13 is unreachable)\nif (errorval < error_threshold)\n{\ntrace_add_data(\"exit\", \"quality hit\");\n@@ -1504,8 +1494,7 @@ void compress_block(\npartition_count, partition_indices_1plane[i],\nscb, tmpbuf);\n- // Modes 5, 6, 8, 9, 11, 12\n- best_errorvals_in_modes[2 * (partition_count - 2) + 1 + i] = errorval;\n+ best_errorvals_for_pcount[partition_count - 1] = astc::min(best_errorvals_for_pcount[partition_count - 1], errorval);\nif (errorval < error_threshold)\n{\ntrace_add_data(\"exit\", \"quality hit\");\n@@ -1513,27 +1502,13 @@ void compress_block(\n}\n}\n- float best_1_partition_1_plane_result = best_errorvals_in_modes[MODE_0_1_PARTITION_1_PLANE];\n-\n- float best_2_partition_1_plane_result = astc::min(best_errorvals_in_modes[MODE_5_2_PARTITION_1_PLANE_UNCOR],\n- best_errorvals_in_modes[MODE_6_2_PARTITION_1_PLANE_COR]);\n-\n- float best_3_partition_1_plane_result = astc::min(best_errorvals_in_modes[MODE_8_3_PARTITION_1_PLANE_UNCOR],\n- best_errorvals_in_modes[MODE_9_3_PARTITION_1_PLANE_COR]);\n-\n- // If adding a second partition doesn't improve much over using one partition then skip more\n- // thorough searches as it's not likely to help.\n- if (partition_count == 2 && (best_2_partition_1_plane_result > (best_1_partition_1_plane_result * ctx.config.tune_2_partition_early_out_limit_factor)))\n- {\n- trace_add_data(\"skip\", \"tune_2_partition_early_out_limit_factor\");\n- goto END_OF_TESTS;\n- }\n-\n- // If adding a third partition doesn't improve much over using two partitions then skip more\n- // thorough searches as it's not likely to help.\n- if (partition_count == 3 && (best_3_partition_1_plane_result > (best_2_partition_1_plane_result * ctx.config.tune_3_partition_early_out_limit_factor)))\n+ // If using N partitions doesn't improve much over using N-1 partitions then skip trying N+1\n+ float best_error = best_errorvals_for_pcount[partition_count - 1];\n+ float best_error_in_prev = best_errorvals_for_pcount[partition_count - 2];\n+ float best_error_scale = exit_thresholds_for_pcount[partition_count - 1];\n+ if (best_error > (best_error_in_prev * best_error_scale))\n{\n- trace_add_data(\"skip\", \"tune_3_partition_early_out_limit_factor\");\n+ trace_add_data(\"skip\", \"tune_partition_early_out_limit_factor\");\ngoto END_OF_TESTS;\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleanup error threshold handling
61,745
02.06.2021 21:43:59
-3,600
b16d6146b84d51462d2310dd14872e1a69504c4d
Scalarize array if known only one partition
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -775,8 +775,8 @@ static float compress_symbolic_block_for_partition_2planes(\n// Recompute the ideal color endpoints before storing them.\nmerge_endpoints(eix1[decimation_mode].ep, eix2[decimation_mode].ep, plane2_component, epm);\n- vfloat4 rgbs_colors[BLOCK_MAX_PARTITIONS];\n- vfloat4 rgbo_colors[BLOCK_MAX_PARTITIONS];\n+ vfloat4 rgbs_color;\n+ vfloat4 rgbo_color;\nsymbolic_compressed_block workscb;\n@@ -799,13 +799,13 @@ static float compress_symbolic_block_for_partition_2planes(\nrecompute_ideal_colors_2planes(\nblk, ewb, bsd, di,\nweight_quant_mode, workscb.weights, workscb.weights + WEIGHTS_PLANE2_OFFSET,\n- epm, rgbs_colors, rgbo_colors, plane2_component);\n+ epm, rgbs_color, rgbo_color, plane2_component);\n// Quantize the chosen color\nworkscb.color_formats[0] = pack_color_endpoints(\nepm.endpt0[0],\nepm.endpt1[0],\n- rgbs_colors[0], rgbo_colors[0],\n+ rgbs_color, rgbo_color,\npartition_format_specifiers[i][0],\nworkscb.color_values[0],\n(quant_method)color_quant_level[i]);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1318,8 +1318,8 @@ void recompute_ideal_colors_2planes(\nconst uint8_t* weight_set8_plane1,\nconst uint8_t* weight_set8_plane2,\nendpoints& ep,\n- vfloat4 rgbs_vectors[BLOCK_MAX_PARTITIONS],\n- vfloat4 rgbo_vectors[BLOCK_MAX_PARTITIONS],\n+ vfloat4& rgbs_vector,\n+ vfloat4& rgbo_vector,\nint plane2_component\n) {\nint weight_count = di.weight_count;\n@@ -1341,7 +1341,6 @@ void recompute_ideal_colors_2planes(\nvfloat4 rgba_sum(1e-17f);\nvfloat4 rgba_weight_sum(1e-17f);\n- // TODOEX: Linearize this without PI\nint texel_count = bsd.texel_count;\nfor (int j = 0; j < texel_count; j++)\n{\n@@ -1380,7 +1379,6 @@ void recompute_ideal_colors_2planes(\nfloat psum = 1e-17f;\n// TODO: This loop has too many responsibilities, making it inefficient\n- // TODOEX: Linearize this without PI\nfor (int j = 0; j < texel_count; j++)\n{\nvfloat4 rgba = blk.texel(j);\n@@ -1453,13 +1451,12 @@ void recompute_ideal_colors_2planes(\nvfloat4 rgbq_sum = color_vec_x + color_vec_y;\nrgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));\n- vfloat4 rgbovec = compute_rgbo_vector(rgba_weight_sum, weight_weight_sum, rgbq_sum, psum);\n- rgbo_vectors[0] = rgbovec;\n+ rgbo_vector = compute_rgbo_vector(rgba_weight_sum, weight_weight_sum, rgbq_sum, psum);\n// We will occasionally get a failure due to the use of a singular (non-invertible) matrix.\n// Record whether such a failure has taken place; if it did, compute rgbo_vectors[] with a\n// different method later\n- float chkval = dot_s(rgbovec, rgbovec);\n+ float chkval = dot_s(rgbo_vector, rgbo_vector);\nint rgbo_fail = chkval != chkval;\n// Initialize the luminance and scale vectors with a reasonable default\n@@ -1468,7 +1465,7 @@ void recompute_ideal_colors_2planes(\nvfloat4 sds = scale_direction * scale_max;\n- rgbs_vectors[0] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), scalediv);\n+ rgbs_vector = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), scalediv);\nif (wmin1 >= wmax1 * 0.999f)\n{\n@@ -1483,7 +1480,7 @@ void recompute_ideal_colors_2planes(\nep.endpt0[0] = select(ep.endpt0[0], avg, full_mask);\nep.endpt1[0] = select(ep.endpt1[0], avg, full_mask);\n- rgbs_vectors[0] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), 1.0f);\n+ rgbs_vector = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), 1.0f);\n}\nelse\n{\n@@ -1521,7 +1518,7 @@ void recompute_ideal_colors_2planes(\n{\nfloat scalediv2 = scale_ep0 * (1.0f / scale_ep1);\nvfloat4 sdsm = scale_direction * scale_ep1;\n- rgbs_vectors[0] = vfloat4(sdsm.lane<0>(), sdsm.lane<1>(), sdsm.lane<2>(), scalediv2);\n+ rgbs_vector = vfloat4(sdsm.lane<0>(), sdsm.lane<1>(), sdsm.lane<2>(), scalediv2);\n}\n}\n@@ -1573,7 +1570,7 @@ void recompute_ideal_colors_2planes(\nvfloat4 avg = (v0 + v1) * 0.5f;\nvfloat4 ep0 = avg - vfloat4(avgdif) * 0.5f;\n- rgbo_vectors[0] = vfloat4(ep0.lane<0>(), ep0.lane<1>(), ep0.lane<2>(), avgdif);\n+ rgbo_vector = vfloat4(ep0.lane<0>(), ep0.lane<1>(), ep0.lane<2>(), avgdif);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -2089,8 +2089,8 @@ void recompute_ideal_colors_1plane(\n* @param weight_set8_plane1 The quantized weight set for plane 1.\n* @param weight_set8_plane2 The quantized weight set for plane 2.\n* @param[in,out] ep The color endpoints (modifed in place).\n- * @param[out] rgbs_vectors The RGB+scale vectors for LDR blocks.\n- * @param[out] rgbo_vectors The RGB+offset vectors for HDR blocks.\n+ * @param[out] rgbs_vector The RGB+scale color for LDR blocks.\n+ * @param[out] rgbo_vector The RGB+offset color for HDR blocks.\n* @param plane2_component The component assigned to plane 2.\n*/\nvoid recompute_ideal_colors_2planes(\n@@ -2102,9 +2102,8 @@ void recompute_ideal_colors_2planes(\nconst uint8_t* weight_set8_plane1,\nconst uint8_t* weight_set8_plane2,\nendpoints& ep,\n- // TODOEX: Make these not vectors ...\n- vfloat4 rgbs_vectors[BLOCK_MAX_PARTITIONS],\n- vfloat4 rgbo_vectors[BLOCK_MAX_PARTITIONS],\n+ vfloat4& rgbs_vector,\n+ vfloat4& rgbo_vector,\nint plane2_component);\n/**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Scalarize array if known only one partition
61,745
02.06.2021 23:13:36
-3,600
77a1d5f8bd03fe1d1dbfb5b7bee3d12c7364ac9d
Precompute block-wide error weighted sums
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1129,11 +1129,15 @@ static float prepare_error_weight_block(\n}\n}\n- vfloat4 error_weight_sum = vfloat4::zero();\n+ // Small bias to avoid divide by zeros and NaN propagation later\n+ vfloat4 texel_weight_sum(1e-17);\n+ vfloat4 error_weight_sum(1e-17);\n+\nint texels_per_block = bsd.texel_count;\nfor (int i = 0; i < texels_per_block; i++)\n{\n- error_weight_sum = error_weight_sum + ewb.error_weights[i];\n+ texel_weight_sum += ewb.error_weights[i] * blk.texel(i);\n+ error_weight_sum += ewb.error_weights[i];\nfloat wr = ewb.error_weights[i].lane<0>();\nfloat wg = ewb.error_weights[i].lane<1>();\n@@ -1157,6 +1161,9 @@ static float prepare_error_weight_block(\newb.texel_weight[i] = (wr + wg + wb + wa) * 0.25f;\n}\n+ ewb.block_error_weighted_rgba_sum = texel_weight_sum;\n+ ewb.block_error_weight_sum = error_weight_sum;\n+\nreturn hadd_s(error_weight_sum);\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1338,19 +1338,10 @@ void recompute_ideal_colors_2planes(\nplane2_weight_set[i] = qat->unquantized_value[weight_set8_plane2[i]] * (1.0f / 64.0f);\n}\n- vfloat4 rgba_sum(1e-17f);\n- vfloat4 rgba_weight_sum(1e-17f);\n+ vfloat4 rgba_sum = ewb.block_error_weighted_rgba_sum;\n+ vfloat4 rgba_weight_sum = ewb.block_error_weight_sum;\nint texel_count = bsd.texel_count;\n- for (int j = 0; j < texel_count; j++)\n- {\n- vfloat4 rgba = blk.texel(j);\n- vfloat4 error_weight = ewb.error_weights[j];\n-\n- rgba_sum += rgba * error_weight;\n- rgba_weight_sum += error_weight;\n- }\n-\nvfloat4 scale_direction = normalize((rgba_sum * (1.0f / rgba_weight_sum)).swz<0, 1, 2>());\nfloat scale_max = 0.0f;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -944,9 +944,16 @@ struct image_block\n*/\nstruct error_weight_block\n{\n+ /** @brief Block error weighted RGBA sum for whole block / 1 partition. */\n+ vfloat4 block_error_weighted_rgba_sum;\n+\n+ /** @brief Block error sum for whole block / 1 partition. */\n+ vfloat4 block_error_weight_sum;\n+\n/** @brief The full per texel per component error weights. */\nvfloat4 error_weights[BLOCK_MAX_TEXELS];\n+\n/** @brief The full per texel per component error weights. */\nfloat texel_weight[BLOCK_MAX_TEXELS];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Precompute block-wide error weighted sums
61,745
02.06.2021 23:28:37
-3,600
e9ffe95e1926d6364a3578f8ccc34ce8ea2b905a
Update version for 3.0 release
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "/** @brief The version header. */\nstatic const char *astcenc_copyright_string =\n-R\"(astcenc v3.0-develop, %u-bit %s%s\n+R\"(astcenc v3.0, %u-bit %s%s\nCopyright 2011-2021 Arm Limited, all rights reserved\n)\";\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update version for 3.0 release
61,745
03.06.2021 06:48:21
-3,600
e08a5d8de3418b468019eba0528414b22954a207
Color formats never match two plane compression
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -398,11 +398,6 @@ static float compress_symbolic_block_for_partition_1plane(\nsymbolic_compressed_block workscb;\n- for (unsigned int j = 0; j < BLOCK_MAX_COMPONENTS; j++)\n- {\n- workscb.constant_color[j] = 0;\n- }\n-\nuint8_t* u8_weight_src = u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * bm_packed_index;\nfor (unsigned int j = 0; j < di.weight_count; j++)\n@@ -780,11 +775,6 @@ static float compress_symbolic_block_for_partition_2planes(\nsymbolic_compressed_block workscb;\n- for (unsigned int j = 0; j < BLOCK_MAX_COMPONENTS; j++)\n- {\n- workscb.constant_color[j] = 0;\n- }\n-\nuint8_t* u8_weight1_src = u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * bm_packed_index);\nuint8_t* u8_weight2_src = u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * bm_packed_index + 1);\n@@ -813,7 +803,7 @@ static float compress_symbolic_block_for_partition_2planes(\n// Store header fields\nworkscb.partition_count = 1;\nworkscb.partition_index = 0;\n- workscb.quant_mode = workscb.color_formats_matched ? color_quant_level_mod[i] : color_quant_level[i];\n+ workscb.quant_mode = color_quant_level[i];\nworkscb.color_formats_matched = 0;\nworkscb.block_mode = qw_bm.mode_index;\nworkscb.plane2_component = plane2_component;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1177,6 +1177,7 @@ struct symbolic_compressed_block\nunion {\n/** @brief The constant color; valid for @c CONST blocks. */\nint constant_color[BLOCK_MAX_COMPONENTS];\n+\n/** @brief The quantized endpoint color pairs; valid for @c NONCONST blocks. */\nuint8_t color_values[BLOCK_MAX_PARTITIONS][8];\n};\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Color formats never match two plane compression
61,745
03.06.2021 07:10:09
-3,600
ee903717fca091e92bccb51ec0e4cbbcaaf48959
Ensure plane2_component is initialized to keep SA happy This is not a bug; the field is never dereferenced for the block mode used, but ensuring it is initialized keeps static analysis happy ...
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -469,6 +469,7 @@ static float compress_symbolic_block_for_partition_1plane(\n// Store header fields\nworkscb.partition_count = partition_count;\nworkscb.partition_index = partition_index;\n+ workscb.plane2_component = -1;\nworkscb.quant_mode = workscb.color_formats_matched ? color_quant_level_mod[i] : color_quant_level[i];\nworkscb.block_mode = qw_bm.mode_index;\nworkscb.block_type = SYM_BTYPE_NONCONST;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Ensure plane2_component is initialized to keep SA happy This is not a bug; the field is never dereferenced for the block mode used, but ensuring it is initialized keeps static analysis happy ...
61,745
03.06.2021 07:20:30
-3,600
54497f97b8846ca872db9c0781661c6390d275fc
Widen MT/s column in test runner report
[ { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -132,7 +132,7 @@ def format_solo_result(image, result):\ntCTime = \"%.3f s\" % result.cTime\ntCMTS = \"%.3f MT/s\" % result.cRate\n- return \"%-32s | %8s | %9s | %9s | %10s\" % \\\n+ return \"%-32s | %8s | %9s | %9s | %11s\" % \\\n(name, tPSNR, tTTime, tCTime, tCMTS)\n@@ -159,7 +159,7 @@ def format_result(image, reference, result):\ntCMTS = \"%.3f MT/s\" % (result.cRate)\nresult = determine_result(image, reference, result)\n- return \"%-32s | %22s | %15s | %15s | %10s | %s\" % \\\n+ return \"%-32s | %22s | %15s | %15s | %11s | %s\" % \\\n(name, tPSNR, tTTime, tCTime, tCMTS, result.name)\n@@ -258,6 +258,14 @@ def get_encoder_params(encoderName, referenceName, imageSet):\nrefName = None\nreturn (encoder, name, outDir, refName)\n+ # 3.x variants\n+ if version.startswith(\"3.\"):\n+ encoder = te.Encoder2xRel(version, simd)\n+ name = f\"reference-{version}-{simd}\"\n+ outDir = \"Test/Images/%s\" % imageSet\n+ refName = None\n+ return (encoder, name, outDir, refName)\n+\n# Latest main\nif version == \"main\":\nencoder = te.Encoder2x(simd)\n@@ -287,6 +295,7 @@ def parse_command_line():\n# All reference encoders\nrefcoders = [\"ref-1.7\",\n\"ref-2.5-neon\", \"ref-2.5-sse2\", \"ref-2.5-sse4.1\", \"ref-2.5-avx2\",\n+ \"ref-3.0-neon\", \"ref-3.0-sse2\", \"ref-3.0-sse4.1\", \"ref-3.0-avx2\",\n\"ref-main-neon\", \"ref-main-sse2\", \"ref-main-sse4.1\", \"ref-main-avx2\"]\n# All test encoders\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Widen MT/s column in test runner report
61,745
03.06.2021 08:39:13
-3,600
7bdaad1ecd71c56716b52ede1b00854991873f16
Update docs for 3.0 release
[ { "change_type": "MODIFY", "old_path": "Docs/ChangeLog-3x.md", "new_path": "Docs/ChangeLog-3x.md", "diff": "@@ -9,11 +9,12 @@ clocked at 4.2 GHz, running astcenc using AVX2 and 6 threads.\n<!-- ---------------------------------------------------------------------- -->\n## 3.0\n-**Status:** ETA, August 2021\n+**Status:** June 2021\n-The 3.0 alpha release is a preview release for the 3.x series. This series is\n-aiming to provide a major update to the codec with more experimental changes\n-than we could make with the 2.x series.\n+The 3.0 release is the first in a series of updates to the compressor that are\n+making more radical changes than we felt we could make with the 2.x series.\n+The primary goals of the 3.x series are to keep the image quality ~static or\n+better compared to the 2.5 release, but continue to improve performance.\nReminder for users of the library interface - the API is not designed to be\nbinary compatible across versions, and this release is not compatible with\n@@ -22,8 +23,14 @@ updated `astcenc.h` header.\n* **General:**\n* **Feature:** The code has been significantly cleaned up, with improved\n- API documentation, function and variable naming conventions, and comments.\n+ comments, API documentation, function naming, and variable naming.\n* **Core API:**\n+ * **API Change:** The core APIs for `astcenc_compress_image()` and for\n+ `astcenc_decompress_image()` now accept swizzle structures by `const`\n+ pointer, instead of pass-by-value.\n+ * **API Change:** Calling the `astcenc_compress_reset()` and the\n+ `astcenc_decompress_reset()` functions between images is no longer required\n+ if the context was created for use by a single thread.\n* **Feature:** New heuristics have been added for controlling when to search\nbeyond 2 partitions and 1 plane, and when to search beyond 3 partitions and\n1 plane. The previous `tune_partition_early_out_limit` config option has\n@@ -32,27 +39,24 @@ updated `astcenc.h` header.\n`tune_3_partition_early_out_limit_factor`. See command line help for more\ndetailed documentation.\n* **Feature:** New heuristics have been added for controlling when to use\n- 2 planes. The previous `tune_two_plane_early_out_limit` has been renamed to\n- `tune_2_plane_early_out_limit_correlation`. See command line help for more\n- detailed documentation.\n+ dual weight planes. The previous `tune_two_plane_early_out_limit` has been\n+ renamed to`tune_2_plane_early_out_limit_correlation`. See command line help\n+ for more detailed documentation.\n* **Feature:** Support for using dual weight planes has been restricted to\n- single partition blocks; it rarely helps blocks with 2+ partitions and\n- takes considerable compression search time.\n- * **API Change:** The core APIs for `astcenc_compress_image()` and for\n- `astcenc_decompress_image()` now accept swizzle structures by `const`\n- pointer, instead of pass-by-value.\n- * **API Change:** Calling the `astcenc_compress_reset()` and the\n- `astcenc_decompress_reset()` functions between images is no longer required\n- if the context was created for use by a single thread.\n+ single partition blocks; it rarely helps blocks with 2 or more partitions\n+ and takes considerable compression search time.\n### Performance:\n-The current performance and image quality for the 3.0 development build vs the\n-stable 2.5 release is shown below.\n+Key for charts:\n* Color = block size (see legend).\n* Letter = image format (N = normal map, G = greyscale, L = LDR, H = HDR).\n+**Absolute performance vs 2.5 release:**\n+\n+![Absolute scores 3.0 vs 2.5](./ChangeLogImg/absolute-2.5-to-3.0.png)\n+\n**Relative performance vs 2.5 release:**\n-![Relative scores 3.0-develop vs 2.5](./ChangeLogImg/relative-main-to-2.5.png)\n+![Relative scores 3.0 vs 2.5](./ChangeLogImg/relative-2.5-to-3.0.png)\n" }, { "change_type": "ADD", "old_path": "Docs/ChangeLogImg/absolute-2.5-to-3.0.png", "new_path": "Docs/ChangeLogImg/absolute-2.5-to-3.0.png", "diff": "Binary files /dev/null and b/Docs/ChangeLogImg/absolute-2.5-to-3.0.png differ\n" }, { "change_type": "ADD", "old_path": "Docs/ChangeLogImg/relative-2.5-to-3.0.png", "new_path": "Docs/ChangeLogImg/relative-2.5-to-3.0.png", "diff": "Binary files /dev/null and b/Docs/ChangeLogImg/relative-2.5-to-3.0.png differ\n" }, { "change_type": "DELETE", "old_path": "Docs/ChangeLogImg/relative-main-to-2.5.png", "new_path": "Docs/ChangeLogImg/relative-main-to-2.5.png", "diff": "Binary files a/Docs/ChangeLogImg/relative-main-to-2.5.png and /dev/null differ\n" }, { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -58,12 +58,15 @@ from 0.89 bits/pixel up to 8 bits/pixel.\nRelease build binaries for the `astcenc` stable releases are provided in the\n[GitHub Releases page][3].\n-**Latest stable release:** 2.5\n+**Latest 3.x stable release:** 3.0\n+* Change log: [3.x series](./Docs/ChangeLog-3x.md)\n+\n+**Latest 2.x stable release:** 2.5\n* Change log: [2.x series](./Docs/ChangeLog-2x.md)\n-**Latest development release:** 3.0-develop\n+**Latest development release:** 3.1-develop\n* Change log: [3.x series](./Docs/ChangeLog-3x.md)\n-* Roadmap: [3.0 and beyond](./Docs/Roadmap.md)\n+* Roadmap: [Ideas ...](./Docs/Roadmap.md)\nBinaries are provided for 64-bit builds on Windows, macOS, and Linux. The\nbuilds of the astcenc are provided as multiple binaries, each tuned for a\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update docs for 3.0 release
61,745
06.06.2021 21:31:51
-3,600
98056bbad732e68ad9f35e80d75b1e70b985b6af
Update valgrind profile wrapper for 3.0
[ { "change_type": "MODIFY", "old_path": "Test/astc_profile_valgrind.py", "new_path": "Test/astc_profile_valgrind.py", "diff": "#!/usr/bin/env python3\n# SPDX-License-Identifier: Apache-2.0\n# -----------------------------------------------------------------------------\n-# Copyright 2020 Arm Limited\n+# Copyright 2020-2021 Arm Limited\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n# use this file except in compliance with the License. You may obtain a copy\n@@ -105,26 +105,25 @@ def run_pass(image, noStartup, encoder, blocksize, quality):\nCalledProcessException: Any subprocess failed.\n\"\"\"\nbinary = \"./astcenc/astcenc-%s\" % encoder\n- qualityFlag = \"-%s\" % quality\nargs = [\"valgrind\", \"--tool=callgrind\", \"--callgrind-out-file=callgrind.txt\",\n- binary, \"-cl\", image, \"out.astc\", blocksize, qualityFlag, \"-j\", \"1\"]\n+ binary, \"-cl\", image, \"out.astc\", blocksize, quality, \"-j\", \"1\"]\nresult = sp.run(args, check=True, universal_newlines=True)\nargs = [\"callgrind_annotate\", \"callgrind.txt\"]\nret = sp.run(args, stdout=sp.PIPE, check=True, encoding=\"utf-8\")\n- postprocess_cga(ret.stdout, \"perf_%s.txt\" % quality)\n+ postprocess_cga(ret.stdout, \"perf_%s.txt\" % quality.replace(\"-\", \"\"))\nif noStartup:\nargs = [\"gprof2dot\", \"--format=callgrind\", \"--output=out.dot\", \"callgrind.txt\",\n- \"-s\", \"-z\", \"compress_block(astcenc_context const&, astcenc_image const&, imageblock const*, symbolic_compressed_block&, physical_compressed_block&, compress_symbolic_block_buffers*)\"]\n+ \"-s\", \"-z\", \"compress_block(astcenc_context const&, astcenc_image const&, image_block const&, physical_compressed_block&, compression_working_buffers&)\"]\nelse:\nargs = [\"gprof2dot\", \"--format=callgrind\", \"--output=out.dot\", \"callgrind.txt\",\n\"-s\", \"-z\", \"main\"]\nresult = sp.run(args, check=True, universal_newlines=True)\n- args = [\"dot\", \"-Tpng\", \"out.dot\", \"-o\", \"perf_%s.png\" % quality]\n+ args = [\"dot\", \"-Tpng\", \"out.dot\", \"-o\", \"perf_%s.png\" % quality.replace(\"-\", \"\")]\nresult = sp.run(args, check=True, universal_newlines=True)\nos.remove(\"out.astc\")\n@@ -149,7 +148,7 @@ def parse_command_line():\nparser.add_argument(\"--encoder\", dest=\"encoders\", default=\"avx2\",\nchoices=encoders, help=\"select encoder variant\")\n- testqualities = [\"fastest\", \"fast\", \"medium\", \"thorough\"]\n+ testqualities = [\"fastest\", \"fast\", \"medium\", \"thorough\", \"20\", \"30\", \"40\", \"50\"]\nqualities = testqualities + [\"all\"]\nparser.add_argument(\"--test-quality\", dest=\"qualities\", default=\"medium\",\nchoices=qualities, help=\"select compression quality\")\n@@ -166,6 +165,8 @@ def parse_command_line():\nif args.qualities == \"all\":\nargs.qualities = testqualities\n+ elif args.qualities in [\"fastest\", \"fast\", \"medium\", \"thorough\"]:\n+ args.qualities = [f\"-{args.qualities}\"]\nelse:\nargs.qualities = [args.qualities]\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update valgrind profile wrapper for 3.0
61,745
06.06.2021 22:43:14
-3,600
b5c194b508a0140df9603451514f94e2bcb60690
Better variable names ...
[ { "change_type": "ADD", "old_path": null, "new_path": "Docs/Terminology.md", "diff": "+# Terminology for the ASTC Encoder\n+\n+Like most software, the `astcenc` code base has a set of naming conventions\n+for variables which are used to ensure both accuracy and reasonable brevity.\n+\n+:construction: These conventions are being used for new patches, so new code\n+will conform to this, but older code is still being cleaned up to follow\n+these conventions.\n+\n+## Counts\n+\n+For counts of things prefer `<x>_count` rather than `<x>s`. For example:\n+\n+* `plane_count`\n+* `weight_count`\n+* `texel_count`\n+\n+Where possible aim for descriptive loop variables, as these are more literate\n+than simple `i` or `j` variables. For example:\n+\n+* `plane_index`\n+* `weight_index`\n+* `texel_index`\n+\n+## Ideal, Unpacked Quantized, vs Packed Quantized\n+\n+Variables that are quantized, such as endpoint colors and weights, have\n+multiple states depending on how they are being used.\n+\n+**Ideal values** represent arbitrary numeric values that can take any value.\n+These are often used during compression to work out the best value before\n+any quantization is applied. For example, integer weights in the 0-64 range can\n+take any of the 65 values available.\n+\n+**Quant uvalues** represent the unpacked numeric value after any quantization\n+rounding has been applied. These are often used during compression to work out\n+the error for the quantized value compared to the ideal value. For example,\n+`QUANT_3` weights in the 0-64 range can only take one of `[0, 32, 64]`.\n+\n+**Quant pvalues** represent the packed numeric value in the quantized alphabet.\n+This is what ends up encoded in the ASTC data, although note that the encoded\n+ordering is scrambled to simplify hardware. For example, `QUANT_3` weights\n+originally in the 0-64 range can only take one of `[0, 1, 2]`.\n+\n+For example:\n+\n+* `weights_ideal_value`\n+* `weights_quant_uvalue`\n+* `weights_quant_pvalue`\n+\n+## Full vs Decimated interpolation weights\n+\n+Weight grids have multiple states depending on how they are being used.\n+\n+**full_weights** represent per texel weight grids, storing one weight per texel.\n+\n+**decimated_weights** represent reduced weight grids, which can store fewer\n+weights and which are bilinear interpolated to generate the full weight grid.\n+\n+Full weights have no variable prefix,but decimated weights are stored with\n+a `dec_` prefix.\n+\n+* `dec_weights_ideal_value`\n+* `dec_weights_quant_uvalue`\n+* `dec_weights_quant_pvalue`\n+\n+## Weight vs Significance\n+\n+The original encoder used \"weight\" for multiple purposes - texel significance\n+(weight the error), color channel significance (weight the error), and endpoint\n+interpolation weights. This gets very confusing in functions using all three!\n+\n+We are slowly refactoring the code to only use \"weight\" to mean the endpoint\n+interpolation weights. The error weighting factors used for other purposes are\n+being updated to use the using the term \"significance\".\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -679,7 +679,7 @@ void compute_ideal_colors_and_weights_2planes(\nfloat compute_error_of_weight_set_1plane(\nconst endpoints_and_weights& eai,\nconst decimation_info& di,\n- const float* weights\n+ const float* dec_weight_quant_uvalue\n) {\nvfloat4 error_summav = vfloat4::zero();\nfloat error_summa = 0.0f;\n@@ -693,7 +693,7 @@ float compute_error_of_weight_set_1plane(\nfor (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Compute the bilinear interpolation of the decimated weight grid\n- vfloat current_values = bilinear_infill_vla(di, weights, i);\n+ vfloat current_values = bilinear_infill_vla(di, dec_weight_quant_uvalue, i);\n// Compute the error between the computed value and the ideal weight\nvfloat actual_values = loada(eai.weights + i);\n@@ -709,7 +709,7 @@ float compute_error_of_weight_set_1plane(\nfor (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Load the weight set directly, without interpolation\n- vfloat current_values = loada(weights + i);\n+ vfloat current_values = loada(dec_weight_quant_uvalue + i);\n// Compute the error between the computed value and the ideal weight\nvfloat actual_values = loada(eai.weights + i);\n@@ -732,8 +732,8 @@ float compute_error_of_weight_set_2planes(\nconst endpoints_and_weights& eai1,\nconst endpoints_and_weights& eai2,\nconst decimation_info& di,\n- const float* weights1,\n- const float* weights2\n+ const float* dec_weight_quant_uvalue_plane1,\n+ const float* dec_weight_quant_uvalue_plane2\n) {\nvfloat4 error_summav = vfloat4::zero();\nfloat error_summa = 0.0f;\n@@ -747,7 +747,7 @@ float compute_error_of_weight_set_2planes(\n{\n// Plane 1\n// Compute the bilinear interpolation of the decimated weight grid\n- vfloat current_values1 = bilinear_infill_vla(di, weights1, i);\n+ vfloat current_values1 = bilinear_infill_vla(di, dec_weight_quant_uvalue_plane1, i);\n// Compute the error between the computed value and the ideal weight\nvfloat actual_values1 = loada(eai1.weights + i);\n@@ -756,7 +756,7 @@ float compute_error_of_weight_set_2planes(\n// Plane 2\n// Compute the bilinear interpolation of the decimated weight grid\n- vfloat current_values2 = bilinear_infill_vla(di, weights2, i);\n+ vfloat current_values2 = bilinear_infill_vla(di, dec_weight_quant_uvalue_plane2, i);\n// Compute the error between the computed value and the ideal weight\nvfloat actual_values2 = loada(eai2.weights + i);\n@@ -772,7 +772,7 @@ float compute_error_of_weight_set_2planes(\n{\n// Plane 1\n// Load the weight set directly, without interpolation\n- vfloat current_values1 = loada(weights1 + i);\n+ vfloat current_values1 = loada(dec_weight_quant_uvalue_plane1 + i);\n// Compute the error between the computed value and the ideal weight\nvfloat actual_values1 = loada(eai1.weights + i);\n@@ -781,7 +781,7 @@ float compute_error_of_weight_set_2planes(\n// Plane 2\n// Load the weight set directly, without interpolation\n- vfloat current_values2 = loada(weights2 + i);\n+ vfloat current_values2 = loada(dec_weight_quant_uvalue_plane2 + i);\n// Compute the error between the computed value and the ideal weight\nvfloat actual_values2 = loada(eai2.weights + i);\n@@ -803,8 +803,8 @@ void compute_ideal_weights_for_decimation(\nconst endpoints_and_weights& eai_in,\nendpoints_and_weights& eai_out,\nconst decimation_info& di,\n- float* weight_set,\n- float* weights\n+ float* dec_weight_ideal_value,\n+ float* dec_weight_ideal_sig\n) {\nunsigned int texel_count = di.texel_count;\nunsigned int weight_count = di.weight_count;\n@@ -823,7 +823,7 @@ void compute_ideal_weights_for_decimation(\nunsigned int weight_count_simd = round_up_to_simd_multiple_vla(weight_count);\nfor (unsigned int i = weight_count; i < weight_count_simd; i++)\n{\n- weight_set[i] = 0.0f;\n+ dec_weight_ideal_value[i] = 0.0f;\n}\n// If we have a 1:1 mapping just shortcut the computation - clone the weights into both the\n@@ -839,8 +839,8 @@ void compute_ideal_weights_for_decimation(\n// Assert it's an identity map for valid texels, and last valid value for any overspill\nassert(((i < texel_count) && (i == di.weight_texel[0][i])) ||\n((i >= texel_count) && (texel_count - 1 == di.weight_texel[0][i])));\n- weight_set[i] = eai_in.weights[i];\n- weights[i] = eai_in.weight_error_scale[i];\n+ dec_weight_ideal_value[i] = eai_in.weights[i];\n+ dec_weight_ideal_sig[i] = eai_in.weight_error_scale[i];\neai_out.weights[i] = eai_in.weights[i];\neai_out.weight_error_scale[i] = eai_in.weight_error_scale[i];\n@@ -901,8 +901,8 @@ void compute_ideal_weights_for_decimation(\ninitial_weight += gatherf(eai_in.weights, texel) * contrib_weight;\n}\n- storea(weight_weight, weights + i);\n- storea(initial_weight / weight_weight, weight_set + i);\n+ storea(weight_weight, dec_weight_ideal_sig + i);\n+ storea(initial_weight / weight_weight, dec_weight_ideal_value + i);\n}\n// Populate the interpolated weight grid based on the initital average\n@@ -911,14 +911,14 @@ void compute_ideal_weights_for_decimation(\nunsigned int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\nfor (/* */; is < clipped_texel_count; is += ASTCENC_SIMD_WIDTH)\n{\n- vfloat weight = bilinear_infill_vla(di, weight_set, is);\n+ vfloat weight = bilinear_infill_vla(di, dec_weight_ideal_value, is);\nstorea(weight, infilled_weights + is);\n}\n// Loop tail\nfor (/* */; is < texel_count; is++)\n{\n- infilled_weights[is] = bilinear_infill(di, weight_set, is);\n+ infilled_weights[is] = bilinear_infill(di, dec_weight_ideal_value, is);\n}\n// Perform a single iteration of refinement\n@@ -928,7 +928,7 @@ void compute_ideal_weights_for_decimation(\nfor (unsigned int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)\n{\n- vfloat weight_val = loada(weight_set + i);\n+ vfloat weight_val = loada(dec_weight_ideal_value + i);\n// Accumulate error weighting of all the texels using this weight\n// Start with a small value to avoid div-by-zero later\n@@ -968,8 +968,8 @@ void compute_ideal_weights_for_decimation(\nvfloat step = (error_change1 * chd_scale) / error_change0;\nstep = clamp(-stepsize, stepsize, step);\n- // Update the weight\n- storea(weight_val + step, weight_set + i);\n+ // Update the weight; note this can store negative values.\n+ storea(weight_val + step, dec_weight_ideal_value + i);\n}\n}\n@@ -978,7 +978,7 @@ void compute_quantized_weights_for_decimation(\nconst decimation_info& di,\nfloat low_bound,\nfloat high_bound,\n- const float* weight_set_in,\n+ const float* dec_weight_ideal_value,\nfloat* weight_set_out,\nuint8_t* quantized_weight_set,\nquant_method quant_level\n@@ -1012,7 +1012,7 @@ void compute_quantized_weights_for_decimation(\n// safe data in compute_ideal_weights_for_decimation and arrays are always 64 elements\nfor (int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)\n{\n- vfloat ix = loada(&weight_set_in[i]) * scalev - scaled_low_boundv;\n+ vfloat ix = loada(&dec_weight_ideal_value[i]) * scalev - scaled_low_boundv;\nix = clampzo(ix);\n// Look up the two closest indexes and return the one that was closest\n@@ -1120,10 +1120,10 @@ void recompute_ideal_colors_1plane(\nconst quantization_and_transfer_table& qat = quant_and_xfer_tables[weight_quant_mode];\n- float weight_set[BLOCK_MAX_WEIGHTS];\n+ float dec_weight_ideal_value[BLOCK_MAX_WEIGHTS];\nfor (int i = 0; i < weight_count; i++)\n{\n- weight_set[i] = qat.unquantized_value[weight_set8[i]] * (1.0f / 64.0f);\n+ dec_weight_ideal_value[i] = qat.unquantized_value[weight_set8[i]] * (1.0f / 64.0f);\n}\nfor (int i = 0; i < partition_count; i++)\n@@ -1178,10 +1178,10 @@ void recompute_ideal_colors_1plane(\n// TODO: Move this calculation out to the color block?\nfloat ls_weight = hadd_rgb_s(color_weight);\n- float idx0 = weight_set[tix];\n+ float idx0 = dec_weight_ideal_value[tix];\nif (is_decimated)\n{\n- idx0 = bilinear_infill(di, weight_set, tix);\n+ idx0 = bilinear_infill(di, dec_weight_ideal_value, tix);\n}\nfloat om_idx0 = 1.0f - idx0;\n@@ -1329,12 +1329,12 @@ void recompute_ideal_colors_2planes(\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_mode]);\n- float weight_set[BLOCK_MAX_WEIGHTS];\n+ float dec_weight_ideal_value[BLOCK_MAX_WEIGHTS];\nfloat plane2_weight_set[BLOCK_MAX_WEIGHTS];\nfor (int i = 0; i < weight_count; i++)\n{\n- weight_set[i] = qat->unquantized_value[weight_set8_plane1[i]] * (1.0f / 64.0f);\n+ dec_weight_ideal_value[i] = qat->unquantized_value[weight_set8_plane1[i]] * (1.0f / 64.0f);\nplane2_weight_set[i] = qat->unquantized_value[weight_set8_plane2[i]] * (1.0f / 64.0f);\n}\n@@ -1378,10 +1378,10 @@ void recompute_ideal_colors_2planes(\n// TODO: Move this calculation out to the color block?\nfloat ls_weight = hadd_rgb_s(color_weight);\n- float idx0 = weight_set[j];\n+ float idx0 = dec_weight_ideal_value[j];\nif (is_decimated)\n{\n- idx0 = bilinear_infill(di, weight_set, j);\n+ idx0 = bilinear_infill(di, dec_weight_ideal_value, j);\n}\nfloat om_idx0 = 1.0f - idx0;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1820,15 +1820,15 @@ void compute_ideal_colors_and_weights_2planes(\n* @param eai_in The non-decimated endpoints and weights.\n* @param eai_out A copy of eai_in we can modify later for refinement.\n* @param di The selected weight decimation.\n- * @param[out] weight_set The output decimated weight set.\n- * @param[out] weights The output decimated weights.\n+ * @param[out] dec_weight_ideal_value The ideal values for the decimated weight set.\n+ * @param[out] dec_weight_ideal_sig The significance of each weight in the decimated weight_set.\n*/\nvoid compute_ideal_weights_for_decimation(\nconst endpoints_and_weights& eai_in,\nendpoints_and_weights& eai_out,\nconst decimation_info& di,\n- float* weight_set,\n- float* weights);\n+ float* dec_weight_ideal_value,\n+ float* dec_weight_ideal_sig);\n/**\n* @brief Compute the optimal quantized weights for a decimation table.\n@@ -1839,18 +1839,18 @@ void compute_ideal_weights_for_decimation(\n* @param di The selected weight decimation.\n* @param low_bound The lowest weight allowed.\n* @param high_bound The highest weight allowed.\n- * @param weight_set_in The ideal weight set.\n- * @param[out] weight_set_out The output quantized weight as a float.\n- * @param[out] quantized_weight_set The output quantized weight as encoded int.\n+ * @param dec_weight_ideal_value The ideal weight set.\n+ * @param[out] dec_weight_quant_uvalue The output quantized weight as a float.\n+ * @param[out] dec_weight_quant_pvalue The output quantized weight as encoded int.\n* @param quant_level The desired weight quant level.\n*/\nvoid compute_quantized_weights_for_decimation(\nconst decimation_info& di,\nfloat low_bound,\nfloat high_bound,\n- const float* weight_set_in,\n- float* weight_set_out,\n- uint8_t* quantized_weight_set,\n+ const float* dec_weight_ideal_value,\n+ float* dec_weight_quant_uvalue,\n+ uint8_t* dec_weight_quant_pvalue,\nquant_method quant_level);\n/**\n@@ -1919,14 +1919,14 @@ static inline vfloat bilinear_infill_vla(\n*\n* @param eai The ideal weights for the full grid.\n* @param di The selected weight decimation.\n- * @param weights The ideal weights for the decimated grid.\n+ * @param dec_weight_quant_uvalue The quantized weights for the decimated grid.\n*\n* @return The accumulated error.\n*/\nfloat compute_error_of_weight_set_1plane(\nconst endpoints_and_weights& eai,\nconst decimation_info& di,\n- const float *weights);\n+ const float* dec_weight_quant_uvalue);\n/**\n* @brief Compute the error of a decimated weight set for 2 planes.\n@@ -1938,8 +1938,8 @@ float compute_error_of_weight_set_1plane(\n* @param eai1 The ideal weights for the full grid and plane 1.\n* @param eai2 The ideal weights for the full grid and plane 2.\n* @param di The selected weight decimation.\n- * @param weights1 The ideal weights for the decimated grid plane 1.\n- * @param weights2 The ideal weights for the decimated grid plane 2.\n+ * @param dec_weight_quant_uvalue_plane1 The quantized weights for the decimated grid plane 1.\n+ * @param dec_weight_quant_uvalue_plane2 The quantized weights for the decimated grid plane 2.\n*\n* @return The accumulated error.\n*/\n@@ -1947,8 +1947,8 @@ float compute_error_of_weight_set_2planes(\nconst endpoints_and_weights& eai1,\nconst endpoints_and_weights& eai2,\nconst decimation_info& di,\n- const float* weights1,\n- const float* weights2);\n+ const float* dec_weight_quant_uvalue_plane1,\n+ const float* dec_weight_quant_uvalue_plane2);\n/**\n* @brief Pack a single pair of color endpoints as effectively as possible.\n@@ -2139,16 +2139,16 @@ void prepare_angular_tables();\n*\n* @param only_always Only consider block modes that are always enabled.\n* @param bsd The block size descriptor for the current trial.\n- * @param decimated_quantized_weights The decimated and quantized weight values.\n- * @param decimated_weights The significance of each weight.\n+ * @param dec_weight_quant_uvalue The decimated and quantized weight values.\n+ * @param dec_weight_quant_sig The significance of each weight.\n* @param[out] low_value The lowest weight to consider for each block mode.\n* @param[out] high_value The highest weight to consider for each block mode.\n*/\nvoid compute_angular_endpoints_1plane(\nbool only_always,\nconst block_size_descriptor& bsd,\n- const float* decimated_quantized_weights,\n- const float* decimated_weights,\n+ const float* dec_weight_quant_uvalue,\n+ const float* dec_weight_quant_sig,\nfloat low_value[WEIGHTS_MAX_BLOCK_MODES],\nfloat high_value[WEIGHTS_MAX_BLOCK_MODES]);\n@@ -2158,8 +2158,8 @@ void compute_angular_endpoints_1plane(\n* // TODO: Terminology here is confusing and needs improving.\n*\n* @param bsd The block size descriptor for the current trial.\n- * @param decimated_quantized_weights The decimated and quantized weight values.\n- * @param decimated_weights The significance of each weight.\n+ * @param dec_weight_quant_uvalue The decimated and quantized weight values.\n+ * @param dec_weight_quant_sig The significance of each weight.\n* @param[out] low_value1 The lowest weight p1 to consider for each block mode.\n* @param[out] high_value1 The highest weight p1 to consider for each block mode.\n* @param[out] low_value2 The lowest weight p2 to consider for each block mode.\n@@ -2167,8 +2167,8 @@ void compute_angular_endpoints_1plane(\n*/\nvoid compute_angular_endpoints_2planes(\nconst block_size_descriptor& bsd,\n- const float* decimated_quantized_weights,\n- const float* decimated_weights,\n+ const float* dec_weight_quant_uvalue,\n+ const float* dec_weight_quant_sig,\nfloat low_value1[WEIGHTS_MAX_BLOCK_MODES],\nfloat high_value1[WEIGHTS_MAX_BLOCK_MODES],\nfloat low_value2[WEIGHTS_MAX_BLOCK_MODES],\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -91,29 +91,29 @@ void prepare_angular_tables()\n/**\n* @brief Compute the angular alignment factors and offsets.\n*\n- * @param sample_count The number of samples.\n- * @param samples The sample data.\n- * @param sample_weights The weight of each sample.\n+ * @param weight_count The number of (decimated) weights.\n+ * @param dec_weight_quant_uvalue The decimated and quantized weight values.\n+ * @param dec_weight_quant_sig The significance of each weight.\n* @param max_angular_steps The maximum number of steps to be tested.\n* @param[out] offsets The output angular offsets array.\n*/\nstatic void compute_angular_offsets(\n- unsigned int sample_count,\n- const float* samples,\n- const float* sample_weights,\n+ unsigned int weight_count,\n+ const float* dec_weight_quant_uvalue,\n+ const float* dec_weight_quant_sig,\nunsigned int max_angular_steps,\nfloat* offsets\n) {\n- promise(sample_count > 0);\n+ promise(weight_count > 0);\npromise(max_angular_steps > 0);\nalignas(ASTCENC_VECALIGN) int isamplev[BLOCK_MAX_WEIGHTS] { 0 };\n// Precompute isample; arrays are always allocated 64 elements long\n- for (unsigned int i = 0; i < sample_count; i += ASTCENC_SIMD_WIDTH)\n+ for (unsigned int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Add 2^23 and interpreting bits extracts round-to-nearest int\n- vfloat sample = loada(samples + i) * (SINCOS_STEPS - 1.0f) + vfloat(12582912.0f);\n+ vfloat sample = loada(dec_weight_quant_uvalue + i) * (SINCOS_STEPS - 1.0f) + vfloat(12582912.0f);\nvint isample = float_as_int(sample) & vint((SINCOS_STEPS - 1));\nstorea(isample, isamplev + i);\n}\n@@ -126,10 +126,10 @@ static void compute_angular_offsets(\nvfloat anglesum_x = vfloat::zero();\nvfloat anglesum_y = vfloat::zero();\n- for (unsigned int j = 0; j < sample_count; j++)\n+ for (unsigned int j = 0; j < weight_count; j++)\n{\nint isample = isamplev[j];\n- vfloat sample_weightv(sample_weights[j]);\n+ vfloat sample_weightv(dec_weight_quant_sig[j]);\nanglesum_x += loada(cos_table[isample] + i) * sample_weightv;\nanglesum_y += loada(sin_table[isample] + i) * sample_weightv;\n}\n@@ -147,9 +147,9 @@ static void compute_angular_offsets(\n* offset, and then compute the resulting error. The cut errors indicate the error that results from\n* forcing samples that should have had one weight value one step up or down.\n*\n- * @param sample_count The number of samples.\n- * @param samples The sample data.\n- * @param sample_weights The weight of each sample.\n+ * @param weight_count The number of (decimated) weights.\n+ * @param dec_weight_quant_uvalue The decimated and quantized weight values.\n+ * @param dec_weight_quant_sig The significance of each weight.\n* @param max_angular_steps The maximum number of steps to be tested.\n* @param max_quant_steps The maximum quantization level to be tested.\n* @param offsets The angular offsets array.\n@@ -160,9 +160,9 @@ static void compute_angular_offsets(\n* @param[out] cut_high_weight_error Per angular step, the high weight cut error.\n*/\nstatic void compute_lowest_and_highest_weight(\n- unsigned int sample_count,\n- const float* samples,\n- const float* sample_weights,\n+ unsigned int weight_count,\n+ const float* dec_weight_quant_uvalue,\n+ const float* dec_weight_quant_sig,\nunsigned int max_angular_steps,\nunsigned int max_quant_steps,\nconst float* offsets,\n@@ -172,7 +172,7 @@ static void compute_lowest_and_highest_weight(\nfloat* cut_low_weight_error,\nfloat* cut_high_weight_error\n) {\n- promise(sample_count > 0);\n+ promise(weight_count > 0);\npromise(max_angular_steps > 0);\nvfloat rcp_stepsize = vfloat::lane_id() + vfloat(1.0f);\n@@ -187,10 +187,10 @@ static void compute_lowest_and_highest_weight(\nvfloat cut_high_weight_err = vfloat::zero();\nvfloat offset = loada(&offsets[sp]);\n- for (unsigned int j = 0; j < sample_count; ++j)\n+ for (unsigned int j = 0; j < weight_count; ++j)\n{\n- vfloat wt = load1(&sample_weights[j]);\n- vfloat sval = load1(&samples[j]) * rcp_stepsize - offset;\n+ vfloat wt = load1(&dec_weight_quant_sig[j]);\n+ vfloat sval = load1(&dec_weight_quant_uvalue[j]) * rcp_stepsize - offset;\nvfloat svalrte = round(sval);\nvint idxv = float_to_int(svalrte);\nvfloat dif = sval - svalrte;\n@@ -240,17 +240,17 @@ static void compute_lowest_and_highest_weight(\n/**\n* @brief The main function for the angular algorithm.\n*\n- * @param sample_count The number of samples.\n- * @param samples The sample data.\n- * @param sample_weights The weight of each sample.\n+ * @param weight_count The number of (decimated) weights.\n+ * @param dec_weight_quant_uvalue The decimated and quantized weight value.\n+ * @param dec_weight_quant_sig The significance of each weight.\n* @param max_quant_level The maximum quantization level to be tested.\n* @param[out] low_value Per angular step, the lowest weight value.\n* @param[out] high_value Per angular step, the highest weight value.\n*/\nstatic void compute_angular_endpoints_for_quant_levels(\n- unsigned int sample_count,\n- const float* samples,\n- const float* sample_weights,\n+ unsigned int weight_count,\n+ const float* dec_weight_quant_uvalue,\n+ const float* dec_weight_quant_sig,\nunsigned int max_quant_level,\nfloat low_value[12],\nfloat high_value[12]\n@@ -259,7 +259,8 @@ static void compute_angular_endpoints_for_quant_levels(\nalignas(ASTCENC_VECALIGN) float angular_offsets[ANGULAR_STEPS];\nunsigned int max_angular_steps = max_angular_steps_needed_for_quant_level[max_quant_level];\n- compute_angular_offsets(sample_count, samples, sample_weights, max_angular_steps, angular_offsets);\n+ compute_angular_offsets(weight_count, dec_weight_quant_uvalue, dec_weight_quant_sig,\n+ max_angular_steps, angular_offsets);\nalignas(ASTCENC_VECALIGN) int32_t lowest_weight[ANGULAR_STEPS];\nalignas(ASTCENC_VECALIGN) int32_t weight_span[ANGULAR_STEPS];\n@@ -267,7 +268,7 @@ static void compute_angular_endpoints_for_quant_levels(\nalignas(ASTCENC_VECALIGN) float cut_low_weight_error[ANGULAR_STEPS];\nalignas(ASTCENC_VECALIGN) float cut_high_weight_error[ANGULAR_STEPS];\n- compute_lowest_and_highest_weight(sample_count, samples, sample_weights,\n+ compute_lowest_and_highest_weight(weight_count, dec_weight_quant_uvalue, dec_weight_quant_sig,\nmax_angular_steps, max_quant_steps,\nangular_offsets, lowest_weight, weight_span, error,\ncut_low_weight_error, cut_high_weight_error);\n@@ -363,8 +364,8 @@ else\nvoid compute_angular_endpoints_1plane(\nbool only_always,\nconst block_size_descriptor& bsd,\n- const float* decimated_quantized_weights,\n- const float* decimated_weights,\n+ const float* dec_weight_quant_uvalue,\n+ const float* dec_weight_quant_sig,\nfloat low_value[WEIGHTS_MAX_BLOCK_MODES],\nfloat high_value[WEIGHTS_MAX_BLOCK_MODES]\n) {\n@@ -380,11 +381,10 @@ void compute_angular_endpoints_1plane(\ncontinue;\n}\n- int sample_count = bsd.decimation_tables[i]->weight_count;\ncompute_angular_endpoints_for_quant_levels(\n- sample_count,\n- decimated_quantized_weights + i * BLOCK_MAX_WEIGHTS,\n- decimated_weights + i * BLOCK_MAX_WEIGHTS,\n+ bsd.decimation_tables[i]->weight_count,\n+ dec_weight_quant_uvalue + i * BLOCK_MAX_WEIGHTS,\n+ dec_weight_quant_sig + i * BLOCK_MAX_WEIGHTS,\ndm.maxprec_1plane, low_values[i], high_values[i]);\n}\n@@ -408,8 +408,8 @@ void compute_angular_endpoints_1plane(\n/* See header for documentation. */\nvoid compute_angular_endpoints_2planes(\nconst block_size_descriptor& bsd,\n- const float* decimated_quantized_weights,\n- const float* decimated_weights,\n+ const float* dec_weight_quant_uvalue,\n+ const float* dec_weight_quant_sig,\nfloat low_value1[WEIGHTS_MAX_BLOCK_MODES],\nfloat high_value1[WEIGHTS_MAX_BLOCK_MODES],\nfloat low_value2[WEIGHTS_MAX_BLOCK_MODES],\n@@ -429,18 +429,18 @@ void compute_angular_endpoints_2planes(\ncontinue;\n}\n- unsigned int sample_count = bsd.decimation_tables[i]->weight_count;\n+ unsigned int weight_count = bsd.decimation_tables[i]->weight_count;\ncompute_angular_endpoints_for_quant_levels(\n- sample_count,\n- decimated_quantized_weights + 2 * i * BLOCK_MAX_WEIGHTS,\n- decimated_weights + 2 * i * BLOCK_MAX_WEIGHTS,\n+ weight_count,\n+ dec_weight_quant_uvalue + 2 * i * BLOCK_MAX_WEIGHTS,\n+ dec_weight_quant_sig + 2 * i * BLOCK_MAX_WEIGHTS,\ndm.maxprec_2planes, low_values1[i], high_values1[i]);\ncompute_angular_endpoints_for_quant_levels(\n- sample_count,\n- decimated_quantized_weights + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\n- decimated_weights + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\n+ weight_count,\n+ dec_weight_quant_uvalue + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\n+ dec_weight_quant_sig + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\ndm.maxprec_2planes, low_values2[i], high_values2[i]);\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Better variable names ...
61,745
07.06.2021 08:35:06
-3,600
8ac87a6cf6e2caacd328295841109d5bc3fd2a1c
Remove obsolete low sample error propagate step. The codec has historically used a pass that uses a lower sample count's error for a higher sample count during compute_angular_endpoints. This is no longer beneficial, costing 2-3% performance and actually reducing image quality.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -296,16 +296,13 @@ static void compute_angular_endpoints_for_quant_levels(\nfloat error_cut_high = error[i] + cut_high_weight_error[i];\nfloat error_cut_low_high = error[i] + cut_low_weight_error[i] + cut_high_weight_error[i];\n- vfloat4 best_result;\n- vfloat4 new_result;\n-\n// Check best error against record N\n- best_result = best_results[idx_span];\n- new_result = vfloat4(error[i], (float)i, 0.0f, 0.0f);\n+ vfloat4 best_result = best_results[idx_span];\n+ vfloat4 new_result = vfloat4(error[i], (float)i, 0.0f, 0.0f);\nvmask4 mask1(best_result.lane<0>() > error[i]);\nbest_results[idx_span] = select(best_result, new_result, mask1);\n- // Check best error against record N-1 with both cut low and cut high\n+ // Check best error against record N-1 with either cut low or cut high\nbest_result = best_results[idx_span - 1];\nnew_result = vfloat4(error_cut_low, (float)i, 1.0f, 0.0f);\n@@ -316,23 +313,13 @@ static void compute_angular_endpoints_for_quant_levels(\nvmask4 mask3(best_result.lane<0>() > error_cut_high);\nbest_results[idx_span - 1] = select(best_result, new_result, mask3);\n- // Check best error against record N-2 with cut low high\n+ // Check best error against record N-2 with both cut low and high\nbest_result = best_results[idx_span - 2];\nnew_result = vfloat4(error_cut_low_high, (float)i, 1.0f, 0.0f);\nvmask4 mask4(best_result.lane<0>() > error_cut_low_high);\nbest_results[idx_span - 2] = select(best_result, new_result, mask4);\n}\n- // If we get a better error for lower sample count then use the lower sample count's error for\n- // the higher sample count as well.\n- for (unsigned int i = 3; i <= max_quant_steps; i++)\n- {\n- vfloat4 result = best_results[i];\n- vfloat4 prev_result = best_results[i - 1];\n- vmask4 mask(result.lane<0>() > prev_result.lane<0>());\n- best_results[i] = select(result, prev_result, mask);\n- }\n-\nfor (unsigned int i = 0; i <= max_quant_level; i++)\n{\nunsigned int q = quantization_steps_for_level[i];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove obsolete low sample error propagate step. The codec has historically used a pass that uses a lower sample count's error for a higher sample count during compute_angular_endpoints. This is no longer beneficial, costing 2-3% performance and actually reducing image quality.
61,745
07.06.2021 08:39:47
-3,600
98f5bcb7c7c2d4bcfc93f15df7ef8cf8590bcd13
Clean up bsi < 0 fail case
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -326,17 +326,15 @@ static void compute_angular_endpoints_for_quant_levels(\nint bsi = (int)best_results[q].lane<1>();\n// Did we find anything?\n- // TODO: Can we do better than bsi = 0 here. We should at least propagate an error?\n#if !defined(NDEBUG)\nif (bsi < 0)\n{\nprintf(\"WARNING: Unable to find encoding within specified error limit\\n\");\n- bsi = 0;\n}\n-else\n- bsi = astc::max(0, bsi);\n#endif\n+ bsi = astc::max(0, bsi);\n+\nfloat stepsize = 1.0f / (1.0f + (float)bsi);\nint lwi = lowest_weight[bsi] + (int)best_results[q].lane<2>();\nint hwi = lwi + q - 1;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Clean up bsi < 0 fail case
61,745
07.06.2021 09:23:09
-3,600
07e29d26e8bb84e3655267eefddad19d9c0971b7
Use ERROR_CALC_DEFAULT not magic numbers
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -371,7 +371,7 @@ static float compress_symbolic_block_for_partition_1plane(\ncolor_quant_level, color_quant_level_mod);\n// Iterate over the N believed-to-be-best modes to find out which one is actually best\n- float best_errorval_in_mode = 1e30f;\n+ float best_errorval_in_mode = ERROR_CALC_DEFAULT;\nfloat best_errorval_in_scb = scb.errorval;\nfor (unsigned int i = 0; i < candidate_count; i++)\n@@ -483,7 +483,7 @@ static float compress_symbolic_block_for_partition_1plane(\nif (l == 0)\n{\nfloat errorval = compute_symbolic_block_difference(config, bsd, workscb, blk, ewb);\n- if (errorval == -1e30f)\n+ if (errorval == -ERROR_CALC_DEFAULT)\n{\nerrorval = -errorval;\nworkscb.block_type = SYM_BTYPE_ERROR;\n@@ -523,7 +523,7 @@ static float compress_symbolic_block_for_partition_1plane(\n// Post-realign test\nfloat errorval = compute_symbolic_block_difference(config, bsd, workscb, blk, ewb);\n- if (errorval == -1e30f)\n+ if (errorval == -ERROR_CALC_DEFAULT)\n{\nerrorval = -errorval;\nworkscb.block_type = SYM_BTYPE_ERROR;\n@@ -642,7 +642,7 @@ static float compress_symbolic_block_for_partition_2planes(\nvmask4 use_ep2 = (ep2 > vfloat4(0.5f)) & (ep2 < min_ep2);\nmin_ep2 = select(min_ep2, ep2, use_ep2);\n- vfloat4 err_max(1e30f);\n+ vfloat4 err_max(ERROR_CALC_DEFAULT);\nvmask4 err_mask = vint4::lane_id() == vint4(plane2_component);\n// Set the plane2 component to max error in ep1\n@@ -747,7 +747,7 @@ static float compress_symbolic_block_for_partition_2planes(\ncolor_quant_level, color_quant_level_mod);\n// Iterate over the N believed-to-be-best modes to find out which one is actually best\n- float best_errorval_in_mode = 1e30f;\n+ float best_errorval_in_mode = ERROR_CALC_DEFAULT;\nfloat best_errorval_in_scb = scb.errorval;\nfor (unsigned int i = 0; i < candidate_count; i++)\n@@ -819,7 +819,7 @@ static float compress_symbolic_block_for_partition_2planes(\nif (l == 0)\n{\nfloat errorval = compute_symbolic_block_difference(config, bsd, workscb, blk, ewb);\n- if (errorval == -1e30f)\n+ if (errorval == -ERROR_CALC_DEFAULT)\n{\nerrorval = -errorval;\nworkscb.block_type = SYM_BTYPE_ERROR;\n@@ -859,7 +859,7 @@ static float compress_symbolic_block_for_partition_2planes(\n// Post-realign test\nfloat errorval = compute_symbolic_block_difference(config, bsd, workscb, blk, ewb);\n- if (errorval == -1e30f)\n+ if (errorval == -ERROR_CALC_DEFAULT)\n{\nerrorval = -errorval;\nworkscb.block_type = SYM_BTYPE_ERROR;\n@@ -1373,11 +1373,11 @@ void compress_block(\n#endif\n// Set SCB and mode errors to a very high error value\n- scb.errorval = 1e30f;\n+ scb.errorval = ERROR_CALC_DEFAULT;\nscb.block_type = SYM_BTYPE_ERROR;\nfloat best_errorvals_for_pcount[BLOCK_MAX_PARTITIONS] {\n- 1e30f, 1e30f, 1e30f, 1e30f\n+ ERROR_CALC_DEFAULT, ERROR_CALC_DEFAULT, ERROR_CALC_DEFAULT, ERROR_CALC_DEFAULT\n};\nfloat exit_thresholds_for_pcount[BLOCK_MAX_PARTITIONS] {\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -329,7 +329,7 @@ float compute_symbolic_block_difference(\n// If we detected an error-block, blow up immediately.\nif (scb.block_type == SYM_BTYPE_ERROR)\n{\n- return 1e29f;\n+ return ERROR_CALC_DEFAULT;\n}\nassert(scb.block_mode >= 0);\n@@ -394,7 +394,7 @@ float compute_symbolic_block_difference(\n// happen, especially at low bit rates ...\nif (color.lane<3>() == 0.0f)\n{\n- return -1e30f;\n+ return -ERROR_CALC_DEFAULT;\n}\n// Compute error based on decoded RGBM color\n@@ -418,7 +418,7 @@ float compute_symbolic_block_difference(\nerror = error * error;\nfloat metric = dot_s(error, ewb.error_weights[tix]);\n- summa += astc::min(metric, 1e30f);\n+ summa += astc::min(metric, ERROR_CALC_DEFAULT);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -514,13 +514,14 @@ static void compute_color_error_for_every_integer_count_and_quant_level(\n// Pick among the available HDR endpoint modes\nfor (int i = 0; i < 8; i++)\n{\n- best_error[i][3] = 1e30f;\n+ best_error[i][3] = ERROR_CALC_DEFAULT;\n+ best_error[i][2] = ERROR_CALC_DEFAULT;\n+ best_error[i][1] = ERROR_CALC_DEFAULT;\n+ best_error[i][0] = ERROR_CALC_DEFAULT;\n+\nformat_of_choice[i][3] = encode_hdr_alpha ? FMT_HDR_RGBA : FMT_HDR_RGB_LDR_ALPHA;\n- best_error[i][2] = 1e30f;\nformat_of_choice[i][2] = FMT_HDR_RGB;\n- best_error[i][1] = 1e30f;\nformat_of_choice[i][1] = FMT_HDR_RGB_SCALE;\n- best_error[i][0] = 1e30f;\nformat_of_choice[i][0] = FMT_HDR_LUMINANCE_LARGE_RANGE;\n}\n@@ -561,10 +562,10 @@ static void compute_color_error_for_every_integer_count_and_quant_level(\n{\nfor (int i = 0; i < 4; i++)\n{\n- best_error[i][3] = 1e30f;\n- best_error[i][2] = 1e30f;\n- best_error[i][1] = 1e30f;\n- best_error[i][0] = 1e30f;\n+ best_error[i][3] = ERROR_CALC_DEFAULT;\n+ best_error[i][2] = ERROR_CALC_DEFAULT;\n+ best_error[i][1] = ERROR_CALC_DEFAULT;\n+ best_error[i][0] = ERROR_CALC_DEFAULT;\nformat_of_choice[i][3] = FMT_RGBA;\nformat_of_choice[i][2] = FMT_RGB;\n@@ -733,7 +734,7 @@ static void two_partitions_find_best_combination_for_every_quantization_and_inte\n{\nfor (int j = 0; j < 7; j++)\n{\n- best_combined_error[i][j] = 1e30f;\n+ best_combined_error[i][j] = ERROR_CALC_DEFAULT;\n}\n}\n@@ -845,7 +846,7 @@ static void three_partitions_find_best_combination_for_every_quantization_and_in\n{\nfor (int j = 0; j < 10; j++)\n{\n- best_combined_error[i][j] = 1e30f;\n+ best_combined_error[i][j] = ERROR_CALC_DEFAULT;\n}\n}\n@@ -968,7 +969,7 @@ static void four_partitions_find_best_combination_for_every_quantization_and_int\n{\nfor (int j = 0; j < 13; j++)\n{\n- best_combined_error[i][j] = 1e30f;\n+ best_combined_error[i][j] = ERROR_CALC_DEFAULT;\n}\n}\n@@ -1140,7 +1141,7 @@ unsigned int compute_ideal_endpoint_formats(\nconst int packed_mode_count_simd_up = round_up_to_simd_multiple_vla(packed_mode_count);\nfor (int i = packed_mode_count; i < packed_mode_count_simd_up; ++i)\n{\n- errors_of_best_combination[i] = 1e30f;\n+ errors_of_best_combination[i] = ERROR_CALC_DEFAULT;\nbest_quant_levels[i] = QUANT_2;\nbest_quant_levels_mod[i] = QUANT_2;\n}\n@@ -1151,9 +1152,9 @@ unsigned int compute_ideal_endpoint_formats(\nfloat error_of_best_combination;\nfor (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n{\n- if (qwt_errors[i] >= 1e29f)\n+ if (qwt_errors[i] >= ERROR_CALC_DEFAULT)\n{\n- errors_of_best_combination[i] = 1e30f;\n+ errors_of_best_combination[i] = ERROR_CALC_DEFAULT;\ncontinue;\n}\n@@ -1178,9 +1179,9 @@ unsigned int compute_ideal_endpoint_formats(\nfor (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n{\n- if (qwt_errors[i] >= 1e29f)\n+ if (qwt_errors[i] >= ERROR_CALC_DEFAULT)\n{\n- errors_of_best_combination[i] = 1e30f;\n+ errors_of_best_combination[i] = ERROR_CALC_DEFAULT;\ncontinue;\n}\n@@ -1204,9 +1205,9 @@ unsigned int compute_ideal_endpoint_formats(\nfor (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n{\n- if (qwt_errors[i] >= 1e29f)\n+ if (qwt_errors[i] >= ERROR_CALC_DEFAULT)\n{\n- errors_of_best_combination[i] = 1e30f;\n+ errors_of_best_combination[i] = ERROR_CALC_DEFAULT;\ncontinue;\n}\n@@ -1230,9 +1231,9 @@ unsigned int compute_ideal_endpoint_formats(\nfor (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n{\n- if (qwt_errors[i] >= 1e29f)\n+ if (qwt_errors[i] >= ERROR_CALC_DEFAULT)\n{\n- errors_of_best_combination[i] = 1e30f;\n+ errors_of_best_combination[i] = ERROR_CALC_DEFAULT;\ncontinue;\n}\n@@ -1251,7 +1252,7 @@ unsigned int compute_ideal_endpoint_formats(\nfor (unsigned int i = 0; i < tune_candidate_limit; i++)\n{\nvint vbest_error_index(-1);\n- vfloat vbest_ep_error(1e30f);\n+ vfloat vbest_ep_error(ERROR_CALC_DEFAULT);\nvint lane_ids = vint::lane_id();\nfor (unsigned int j = 0; j < bsd.block_mode_count; j += ASTCENC_SIMD_WIDTH)\n{\n@@ -1275,7 +1276,7 @@ unsigned int compute_ideal_endpoint_formats(\n// Max the error for this candidate so we don't pick it again\nif (best_error_index >= 0)\n{\n- errors_of_best_combination[best_error_index] = 1e30f;\n+ errors_of_best_combination[best_error_index] = ERROR_CALC_DEFAULT;\n}\n// Early-out if no more candidates are valid\nelse\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -280,12 +280,13 @@ static void compute_angular_endpoints_for_quant_levels(\n// Initialize the array to some safe defaults\npromise(max_quant_steps > 0);\n+ // TODO: Why the + 4 in the current code?\nfor (unsigned int i = 0; i < (max_quant_steps + 4); i++)\n{\n// Lane<0> = Best error\n// Lane<1> = Best scale; -1 indicates no solution found\n// Lane<2> = Cut low weight\n- best_results[i] = vfloat4(1e30f, -1.0f, 0.0f, 0.0f);\n+ best_results[i] = vfloat4(ERROR_CALC_DEFAULT, -1.0f, 0.0f, 0.0f);\n}\npromise(max_angular_steps > 0);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use ERROR_CALC_DEFAULT not magic numbers
61,745
07.06.2021 23:12:44
-3,600
53a7036fc80f1d119fc41bc5ba943886cfe532b3
Add -lowweightmodelimit heuristic
[ { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "@@ -548,6 +548,11 @@ struct astcenc_config\n*/\nfloat tune_2_plane_early_out_limit_correlation;\n+ /**\n+ * @brief The threshold below which (inclusive) we stop testing low/high/low+high cutoffs.\n+ */\n+ unsigned int tune_low_weight_count_limit;\n+\n#if defined(ASTCENC_DIAGNOSTICS)\n/**\n* @brief The path to save the diagnostic trace data to.\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -300,6 +300,7 @@ static float compress_symbolic_block_for_partition_1plane(\nfloat weight_high_value[WEIGHTS_MAX_BLOCK_MODES];\ncompute_angular_endpoints_1plane(\n+ config.tune_low_weight_count_limit,\nonly_always, bsd,\ndecimated_quantized_weights, decimated_weights,\nweight_low_value, weight_high_value);\n@@ -659,6 +660,7 @@ static float compress_symbolic_block_for_partition_2planes(\nfloat weight_high_value2[WEIGHTS_MAX_BLOCK_MODES];\ncompute_angular_endpoints_2planes(\n+ config.tune_low_weight_count_limit,\nbsd, decimated_quantized_weights, decimated_weights,\nweight_low_value1, weight_high_value1,\nweight_low_value2, weight_high_value2);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -50,6 +50,7 @@ struct astcenc_preset_config {\nfloat tune_2_partition_early_out_limit_factor;\nfloat tune_3_partition_early_out_limit_factor;\nfloat tune_2_plane_early_out_limit_correlation;\n+ unsigned int tune_low_weight_count_limit;\n};\n@@ -60,19 +61,19 @@ struct astcenc_preset_config {\nstatic const std::array<astcenc_preset_config, 5> preset_configs_high {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 25\n}, {\nASTCENC_PRE_FAST,\n- 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n+ 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f, 20\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 2, 2, 95.0f, 70.0f, 2.5f, 2.5f, 1.2f, 1.25f, 0.75f\n+ 4, 26, 76, 2, 2, 95.0f, 70.0f, 2.5f, 2.5f, 1.2f, 1.25f, 0.75f, 16\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n+ 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f, 12\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f, 0\n}\n}};\n@@ -84,19 +85,19 @@ static const std::array<astcenc_preset_config, 5> preset_configs_high {{\nstatic const std::array<astcenc_preset_config, 5> preset_configs_mid {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 20\n}, {\nASTCENC_PRE_FAST,\n- 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n+ 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f, 16\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 2, 2, 95.0f, 70.0f, 3.0f, 3.0f, 1.2f, 1.25f, 0.75f\n+ 4, 26, 76, 2, 2, 95.0f, 70.0f, 3.0f, 3.0f, 1.2f, 1.25f, 0.75f, 14\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n+ 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f, 10\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f, 0\n}\n}};\n@@ -108,19 +109,19 @@ static const std::array<astcenc_preset_config, 5> preset_configs_mid {{\nstatic const std::array<astcenc_preset_config, 5> preset_configs_low {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 20\n}, {\nASTCENC_PRE_FAST,\n- 3, 10, 53, 3, 2, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n+ 3, 10, 53, 3, 2, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f, 16\n}, {\nASTCENC_PRE_MEDIUM,\n- 3, 26, 76, 3, 2, 95.0f, 70.0f, 3.5f, 3.5f, 1.2f, 1.25f, 0.75f\n+ 3, 26, 76, 3, 2, 95.0f, 70.0f, 3.5f, 3.5f, 1.2f, 1.25f, 0.75f, 12\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 75, 92, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n+ 4, 75, 92, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f, 10\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f, 0\n}\n}};\n@@ -541,6 +542,7 @@ astcenc_error astcenc_config_init(\nconfig.tune_2_partition_early_out_limit_factor = (*preset_configs)[start].tune_2_partition_early_out_limit_factor;\nconfig.tune_3_partition_early_out_limit_factor =(*preset_configs)[start].tune_3_partition_early_out_limit_factor;\nconfig.tune_2_plane_early_out_limit_correlation = (*preset_configs)[start].tune_2_plane_early_out_limit_correlation;\n+ config.tune_low_weight_count_limit = (*preset_configs)[start].tune_low_weight_count_limit;\n}\n// Start and end node are not the same - so interpolate between them\nelse\n@@ -576,7 +578,7 @@ astcenc_error astcenc_config_init(\nconfig.tune_2_partition_early_out_limit_factor = LERP(tune_2_partition_early_out_limit_factor);\nconfig.tune_3_partition_early_out_limit_factor = LERP(tune_3_partition_early_out_limit_factor);\nconfig.tune_2_plane_early_out_limit_correlation = LERP(tune_2_plane_early_out_limit_correlation);\n-\n+ config.tune_low_weight_count_limit = LERPI(tune_low_weight_count_limit);\n#undef LERP\n#undef LERPI\n#undef LERPUI\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -2135,8 +2135,7 @@ void prepare_angular_tables();\n/**\n* @brief Compute the angular endpoints for one plane for each block mode.\n*\n- * // TODO: Terminology here is confusing and needs improving.\n- *\n+ * @param tune_low_weight_limit Weight count cutoff below which we use simpler searches.\n* @param only_always Only consider block modes that are always enabled.\n* @param bsd The block size descriptor for the current trial.\n* @param dec_weight_quant_uvalue The decimated and quantized weight values.\n@@ -2145,6 +2144,7 @@ void prepare_angular_tables();\n* @param[out] high_value The highest weight to consider for each block mode.\n*/\nvoid compute_angular_endpoints_1plane(\n+ unsigned int tune_low_weight_limit,\nbool only_always,\nconst block_size_descriptor& bsd,\nconst float* dec_weight_quant_uvalue,\n@@ -2155,8 +2155,7 @@ void compute_angular_endpoints_1plane(\n/**\n* @brief Compute the angular endpoints for one plane for each block mode.\n*\n- * // TODO: Terminology here is confusing and needs improving.\n- *\n+ * @param tune_low_weight_limit Weight count cutoff below which we use simpler searches.\n* @param bsd The block size descriptor for the current trial.\n* @param dec_weight_quant_uvalue The decimated and quantized weight values.\n* @param dec_weight_quant_sig The significance of each weight.\n@@ -2166,6 +2165,7 @@ void compute_angular_endpoints_1plane(\n* @param[out] high_value2 The highest weight p2 to consider for each block mode.\n*/\nvoid compute_angular_endpoints_2planes(\n+ unsigned int tune_low_weight_limit,\nconst block_size_descriptor& bsd,\nconst float* dec_weight_quant_uvalue,\nconst float* dec_weight_quant_sig,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -346,8 +346,172 @@ static void compute_angular_endpoints_for_quant_levels(\n}\n}\n+/**\n+ * @brief For a given step size compute the lowest and highest weight, variant for low weight count.\n+ *\n+ * Compute the lowest and highest weight that results from quantizing using the given stepsize and\n+ * offset, and then compute the resulting error. The cut errors indicate the error that results from\n+ * forcing samples that should have had one weight value one step up or down.\n+ *\n+ * @param weight_count The number of (decimated) weights.\n+ * @param dec_weight_quant_uvalue The decimated and quantized weight values.\n+ * @param dec_weight_quant_sig The significance of each weight.\n+ * @param max_angular_steps The maximum number of steps to be tested.\n+ * @param max_quant_steps The maximum quantization level to be tested.\n+ * @param offsets The angular offsets array.\n+ * @param[out] lowest_weight Per angular step, the lowest weight.\n+ * @param[out] weight_span Per angular step, the span between lowest and highest weight.\n+ * @param[out] error Per angular step, the error.\n+ */\n+static void compute_lowest_and_highest_weight_lwc(\n+ unsigned int weight_count,\n+ const float* dec_weight_quant_uvalue,\n+ const float* dec_weight_quant_sig,\n+ unsigned int max_angular_steps,\n+ unsigned int max_quant_steps,\n+ const float* offsets,\n+ int* lowest_weight,\n+ int* weight_span,\n+ float* error\n+) {\n+ promise(weight_count > 0);\n+ promise(max_angular_steps > 0);\n+\n+ vfloat rcp_stepsize = vfloat::lane_id() + vfloat(1.0f);\n+\n+ // Arrays are ANGULAR_STEPS long, so always safe to run full vectors\n+ for (unsigned int sp = 0; sp < max_angular_steps; sp += ASTCENC_SIMD_WIDTH)\n+ {\n+ vint minidx(128);\n+ vint maxidx(-128);\n+ vfloat errval = vfloat::zero();\n+ vfloat offset = loada(&offsets[sp]);\n+\n+ for (unsigned int j = 0; j < weight_count; ++j)\n+ {\n+ vfloat wt = load1(&dec_weight_quant_sig[j]);\n+ vfloat sval = load1(&dec_weight_quant_uvalue[j]) * rcp_stepsize - offset;\n+ vfloat svalrte = round(sval);\n+ vint idxv = float_to_int(svalrte);\n+ vfloat dif = sval - svalrte;\n+ vfloat dwt = dif * wt;\n+ errval += dwt * dif;\n+\n+ // Reset tracker on min hit\n+ vmask mask = idxv < minidx;\n+ minidx = select(minidx, idxv, mask);\n+\n+ // Reset tracker on max hit\n+ mask = idxv > maxidx;\n+ maxidx = select(maxidx, idxv, mask);\n+ }\n+\n+ // Write out min weight and weight span; clamp span to a usable range\n+ vint span = maxidx - minidx + vint(1);\n+ span = min(span, vint(max_quant_steps + 3));\n+ span = max(span, vint(2));\n+ storea(minidx, &lowest_weight[sp]);\n+ storea(span, &weight_span[sp]);\n+\n+ // The cut_(lowest/highest)_weight_error indicate the error that results from forcing\n+ // samples that should have had the weight value one step (up/down).\n+ vfloat ssize = 1.0f / rcp_stepsize;\n+ vfloat errscale = ssize * ssize;\n+ storea(errval * errscale, &error[sp]);\n+\n+ rcp_stepsize = rcp_stepsize + vfloat(ASTCENC_SIMD_WIDTH);\n+ }\n+}\n+\n+/**\n+ * @brief The main function for the angular algorithm, variant for low weight count.\n+ *\n+ * @param weight_count The number of (decimated) weights.\n+ * @param dec_weight_quant_uvalue The decimated and quantized weight value.\n+ * @param dec_weight_quant_sig The significance of each weight.\n+ * @param max_quant_level The maximum quantization level to be tested.\n+ * @param[out] low_value Per angular step, the lowest weight value.\n+ * @param[out] high_value Per angular step, the highest weight value.\n+ */\n+static void compute_angular_endpoints_for_quant_levels_lwc(\n+ unsigned int weight_count,\n+ const float* dec_weight_quant_uvalue,\n+ const float* dec_weight_quant_sig,\n+ unsigned int max_quant_level,\n+ float low_value[12],\n+ float high_value[12]\n+) {\n+ unsigned int max_quant_steps = quantization_steps_for_level[max_quant_level];\n+\n+ alignas(ASTCENC_VECALIGN) float angular_offsets[ANGULAR_STEPS];\n+ unsigned int max_angular_steps = max_angular_steps_needed_for_quant_level[max_quant_level];\n+ compute_angular_offsets(weight_count, dec_weight_quant_uvalue, dec_weight_quant_sig,\n+ max_angular_steps, angular_offsets);\n+\n+ alignas(ASTCENC_VECALIGN) int32_t lowest_weight[ANGULAR_STEPS];\n+ alignas(ASTCENC_VECALIGN) int32_t weight_span[ANGULAR_STEPS];\n+ alignas(ASTCENC_VECALIGN) float error[ANGULAR_STEPS];\n+\n+ compute_lowest_and_highest_weight_lwc(weight_count, dec_weight_quant_uvalue, dec_weight_quant_sig,\n+ max_angular_steps, max_quant_steps,\n+ angular_offsets, lowest_weight, weight_span, error);\n+\n+ // For each quantization level, find the best error terms. Use packed vectors so data-dependent\n+ // branches can become selects. This involves some integer to float casts, but the values are\n+ // small enough so they never round the wrong way.\n+ vfloat4 best_results[40];\n+\n+ // Initialize the array to some safe defaults\n+ promise(max_quant_steps > 0);\n+ // TODO: Why the + 4 in the current code?\n+ for (unsigned int i = 0; i < (max_quant_steps + 4); i++)\n+ {\n+ // Lane<0> = Best error\n+ // Lane<1> = Best scale; -1 indicates no solution found\n+ // Lane<2> = Cut low weight\n+ best_results[i] = vfloat4(ERROR_CALC_DEFAULT, -1.0f, 0.0f, 0.0f);\n+ }\n+\n+ promise(max_angular_steps > 0);\n+ for (unsigned int i = 0; i < max_angular_steps; i++)\n+ {\n+ int idx_span = weight_span[i];\n+\n+ // Check best error against record N\n+ vfloat4 best_result = best_results[idx_span];\n+ vfloat4 new_result = vfloat4(error[i], (float)i, 0.0f, 0.0f);\n+ vmask4 mask1(best_result.lane<0>() > error[i]);\n+ best_results[idx_span] = select(best_result, new_result, mask1);\n+ }\n+\n+ for (unsigned int i = 0; i <= max_quant_level; i++)\n+ {\n+ unsigned int q = quantization_steps_for_level[i];\n+ int bsi = (int)best_results[q].lane<1>();\n+\n+ // Did we find anything?\n+#if !defined(NDEBUG)\n+ if (bsi < 0)\n+ {\n+ printf(\"WARNING: Unable to find encoding within specified error limit\\n\");\n+ }\n+#endif\n+\n+ bsi = astc::max(0, bsi);\n+\n+ float stepsize = 1.0f / (1.0f + (float)bsi);\n+ int lwi = lowest_weight[bsi] + (int)best_results[q].lane<2>();\n+ int hwi = lwi + q - 1;\n+\n+ float offset = angular_offsets[bsi] * stepsize;\n+ low_value[i] = offset + static_cast<float>(lwi) * stepsize;\n+ high_value[i] = offset + static_cast<float>(hwi) * stepsize;\n+ }\n+}\n+\n/* See header for documentation. */\nvoid compute_angular_endpoints_1plane(\n+ unsigned int tune_low_weight_limit,\nbool only_always,\nconst block_size_descriptor& bsd,\nconst float* dec_weight_quant_uvalue,\n@@ -367,12 +531,25 @@ void compute_angular_endpoints_1plane(\ncontinue;\n}\n+ unsigned int weight_count = bsd.decimation_tables[i]->weight_count;\n+\n+ if (weight_count < tune_low_weight_limit)\n+ {\n+ compute_angular_endpoints_for_quant_levels_lwc(\n+ weight_count,\n+ dec_weight_quant_uvalue + i * BLOCK_MAX_WEIGHTS,\n+ dec_weight_quant_sig + i * BLOCK_MAX_WEIGHTS,\n+ dm.maxprec_1plane, low_values[i], high_values[i]);\n+ }\n+ else\n+ {\ncompute_angular_endpoints_for_quant_levels(\n- bsd.decimation_tables[i]->weight_count,\n+ weight_count,\ndec_weight_quant_uvalue + i * BLOCK_MAX_WEIGHTS,\ndec_weight_quant_sig + i * BLOCK_MAX_WEIGHTS,\ndm.maxprec_1plane, low_values[i], high_values[i]);\n}\n+ }\npromise(bsd.block_mode_count > 0);\nfor (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n@@ -393,6 +570,7 @@ void compute_angular_endpoints_1plane(\n/* See header for documentation. */\nvoid compute_angular_endpoints_2planes(\n+ unsigned int tune_low_weight_limit,\nconst block_size_descriptor& bsd,\nconst float* dec_weight_quant_uvalue,\nconst float* dec_weight_quant_sig,\n@@ -417,6 +595,22 @@ void compute_angular_endpoints_2planes(\nunsigned int weight_count = bsd.decimation_tables[i]->weight_count;\n+ if (weight_count < tune_low_weight_limit)\n+ {\n+ compute_angular_endpoints_for_quant_levels_lwc(\n+ weight_count,\n+ dec_weight_quant_uvalue + 2 * i * BLOCK_MAX_WEIGHTS,\n+ dec_weight_quant_sig + 2 * i * BLOCK_MAX_WEIGHTS,\n+ dm.maxprec_2planes, low_values1[i], high_values1[i]);\n+\n+ compute_angular_endpoints_for_quant_levels_lwc(\n+ weight_count,\n+ dec_weight_quant_uvalue + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\n+ dec_weight_quant_sig + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\n+ dm.maxprec_2planes, low_values2[i], high_values2[i]);\n+ }\n+ else\n+ {\ncompute_angular_endpoints_for_quant_levels(\nweight_count,\ndec_weight_quant_uvalue + 2 * i * BLOCK_MAX_WEIGHTS,\n@@ -429,6 +623,7 @@ void compute_angular_endpoints_2planes(\ndec_weight_quant_sig + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\ndm.maxprec_2planes, low_values2[i], high_values2[i]);\n}\n+ }\npromise(bsd.block_mode_count > 0);\nfor (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -945,6 +945,17 @@ static int edit_astcenc_config(\nconfig.tune_2_plane_early_out_limit_correlation = static_cast<float>(atof(argv[argidx - 1]));\n}\n+ else if (!strcmp(argv[argidx], \"-lowweightmodelimit\"))\n+ {\n+ argidx += 2;\n+ if (argidx > argc)\n+ {\n+ printf(\"ERROR: -lowweightmodelimit switch with no argument\\n\");\n+ return 1;\n+ }\n+\n+ config.tune_low_weight_count_limit= atoi(argv[argidx - 1]);\n+ }\nelse if (!strcmp(argv[argidx], \"-refinementlimit\"))\n{\nargidx += 2;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -411,6 +411,16 @@ ADVANCED COMPRESSION\n-thorough : 0.95\n-exhaustive : 0.99\n+ -lowweightmodelimit <weight count>\n+ Use a simpler weight search for weight counts less than or\n+ equal to this threshold. Preset defaults are bitrate dependent:\n+\n+ -fastest : 25\n+ -fast : 20\n+ -medium : 16\n+ -thorough : 12\n+ -exhaustive : 0\n+\nOther options\n-------------\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add -lowweightmodelimit heuristic
61,745
07.06.2021 23:30:18
-3,600
6182aa9b94a849de756a718c2d9c66f8bf2f959c
Cleanup compute_angular_endpoints_for_quant_levels_lwc
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -442,16 +442,17 @@ static void compute_angular_endpoints_for_quant_levels_lwc(\nfloat high_value[12]\n) {\nunsigned int max_quant_steps = quantization_steps_for_level[max_quant_level];\n-\n- alignas(ASTCENC_VECALIGN) float angular_offsets[ANGULAR_STEPS];\nunsigned int max_angular_steps = max_angular_steps_needed_for_quant_level[max_quant_level];\n- compute_angular_offsets(weight_count, dec_weight_quant_uvalue, dec_weight_quant_sig,\n- max_angular_steps, angular_offsets);\n+ alignas(ASTCENC_VECALIGN) float angular_offsets[ANGULAR_STEPS];\nalignas(ASTCENC_VECALIGN) int32_t lowest_weight[ANGULAR_STEPS];\nalignas(ASTCENC_VECALIGN) int32_t weight_span[ANGULAR_STEPS];\nalignas(ASTCENC_VECALIGN) float error[ANGULAR_STEPS];\n+ compute_angular_offsets(weight_count, dec_weight_quant_uvalue, dec_weight_quant_sig,\n+ max_angular_steps, angular_offsets);\n+\n+\ncompute_lowest_and_highest_weight_lwc(weight_count, dec_weight_quant_uvalue, dec_weight_quant_sig,\nmax_angular_steps, max_quant_steps,\nangular_offsets, lowest_weight, weight_span, error);\n@@ -459,17 +460,16 @@ static void compute_angular_endpoints_for_quant_levels_lwc(\n// For each quantization level, find the best error terms. Use packed vectors so data-dependent\n// branches can become selects. This involves some integer to float casts, but the values are\n// small enough so they never round the wrong way.\n- vfloat4 best_results[40];\n+ float best_error[ANGULAR_STEPS];\n+ int best_index[ANGULAR_STEPS];\n// Initialize the array to some safe defaults\npromise(max_quant_steps > 0);\n// TODO: Why the + 4 in the current code?\nfor (unsigned int i = 0; i < (max_quant_steps + 4); i++)\n{\n- // Lane<0> = Best error\n- // Lane<1> = Best scale; -1 indicates no solution found\n- // Lane<2> = Cut low weight\n- best_results[i] = vfloat4(ERROR_CALC_DEFAULT, -1.0f, 0.0f, 0.0f);\n+ best_error[i] = ERROR_CALC_DEFAULT;\n+ best_index[i] = -1;\n}\npromise(max_angular_steps > 0);\n@@ -478,16 +478,18 @@ static void compute_angular_endpoints_for_quant_levels_lwc(\nint idx_span = weight_span[i];\n// Check best error against record N\n- vfloat4 best_result = best_results[idx_span];\n- vfloat4 new_result = vfloat4(error[i], (float)i, 0.0f, 0.0f);\n- vmask4 mask1(best_result.lane<0>() > error[i]);\n- best_results[idx_span] = select(best_result, new_result, mask1);\n+ float current_best = best_error[idx_span];\n+ if (error[i] < current_best)\n+ {\n+ best_error[idx_span] = error[i];\n+ best_index[idx_span] = i;\n+ }\n}\nfor (unsigned int i = 0; i <= max_quant_level; i++)\n{\nunsigned int q = quantization_steps_for_level[i];\n- int bsi = (int)best_results[q].lane<1>();\n+ int bsi = best_index[q];\n// Did we find anything?\n#if !defined(NDEBUG)\n@@ -499,13 +501,11 @@ static void compute_angular_endpoints_for_quant_levels_lwc(\nbsi = astc::max(0, bsi);\n- float stepsize = 1.0f / (1.0f + (float)bsi);\n- int lwi = lowest_weight[bsi] + (int)best_results[q].lane<2>();\n+ int lwi = lowest_weight[bsi];\nint hwi = lwi + q - 1;\n- float offset = angular_offsets[bsi] * stepsize;\n- low_value[i] = offset + static_cast<float>(lwi) * stepsize;\n- high_value[i] = offset + static_cast<float>(hwi) * stepsize;\n+ low_value[i] = (angular_offsets[bsi] + static_cast<float>(lwi)) / (1.0f + (float)bsi);\n+ high_value[i] = (angular_offsets[bsi] + static_cast<float>(hwi)) / (1.0f + (float)bsi);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_result_plot.py", "new_path": "Test/astc_test_result_plot.py", "diff": "@@ -62,10 +62,7 @@ def find_reference_results():\nquality = match.group(2)\nimageSet = os.path.basename(root)\n- if imageSet == \"Small\":\n- continue\n-\n- if imageSet == \"Frymire\":\n+ if imageSet != \"Kodak\":\ncontinue\ntestRef = trs.ResultSet(imageSet)\n@@ -361,6 +358,32 @@ def main():\n\"relative-3.x-quality.png\",\n(None, None)\n],\n+ # --------------------------------------------------------\n+ # Latest 3.x vs 2.5 release charts\n+ [\n+ # Relative scores\n+ [\"thorough\", \"medium\", \"fast\", \"fastest\"],\n+ [\"ref-main-avx2\"],\n+ [\"4x4\", \"6x6\", \"8x8\"],\n+ True,\n+ \"ref-3.0-avx2\",\n+ None,\n+ \"relative-main-vs-3.x.png\",\n+ (None, None),\n+ 1\n+ ],\n+ [\n+ # Relative scores\n+ [\"thorough\", \"medium\", \"fast\"],\n+ [\"ref-main-avx2\"],\n+ [\"4x4\", \"6x6\", \"8x8\"],\n+ True,\n+ \"ref-1.7\",\n+ None,\n+ \"relative-main-vs-1.x.png\",\n+ (None, None),\n+ 1\n+ ],\n]\nresults = find_reference_results()\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleanup compute_angular_endpoints_for_quant_levels_lwc
61,745
08.06.2021 07:52:34
-3,600
482a09ffd14bea213a9a11a4c0f8c2fe36619ae1
Avoid rechecking min/max weight bitcount We know it's valid as checked during table creation
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -336,7 +336,7 @@ static float compress_symbolic_block_for_partition_1plane(\nbm.get_weight_quant_mode());\nint bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\n- if (bitcount <= 0 || bits_used_by_weights < 24 || bits_used_by_weights > 96)\n+ if (bitcount <= 0)\n{\nqwt_errors[i] = 1e38f;\ncontinue;\n@@ -699,7 +699,7 @@ static float compress_symbolic_block_for_partition_2planes(\n2 * di.weight_count,\nbm.get_weight_quant_mode());\nint bitcount = 113 - 4 - bits_used_by_weights;\n- if (bitcount <= 0 || bits_used_by_weights < 24 || bits_used_by_weights > 96)\n+ if (bitcount <= 0)\n{\nqwt_errors[i] = 1e38f;\ncontinue;\n@@ -713,7 +713,8 @@ static float compress_symbolic_block_for_partition_2planes(\nweight_high_value1[i],\ndecimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * decimation_mode),\nflt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i),\n- u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i), bm.get_weight_quant_mode());\n+ u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i),\n+ bm.get_weight_quant_mode());\ncompute_quantized_weights_for_decimation(\ndi,\n@@ -721,7 +722,8 @@ static float compress_symbolic_block_for_partition_2planes(\nweight_high_value2[i],\ndecimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * decimation_mode + 1),\nflt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i + 1),\n- u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i + 1), bm.get_weight_quant_mode());\n+ u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i + 1),\n+ bm.get_weight_quant_mode());\n// Compute weight quantization errors for the block mode\nqwt_errors[i] = compute_error_of_weight_set_2planes(\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Avoid rechecking min/max weight bitcount We know it's valid as checked during table creation
61,745
08.06.2021 08:22:09
-3,600
ffd4fe8cc153e678d55d153a16eaf874c561f060
More weight variable name clenaup
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -258,10 +258,10 @@ static float compress_symbolic_block_for_partition_1plane(\ncompute_ideal_colors_and_weights_1plane(bsd, blk, ewb, pi, ei);\n// Compute ideal weights and endpoint colors for every decimation\n- float *decimated_quantized_weights = tmpbuf.decimated_quantized_weights;\n- float *decimated_weights = tmpbuf.decimated_weights;\n- float *flt_quantized_decimated_quantized_weights = tmpbuf.flt_quantized_decimated_quantized_weights;\n- uint8_t *u8_quantized_decimated_quantized_weights = tmpbuf.u8_quantized_decimated_quantized_weights;\n+ float *dec_weights_ideal_value = tmpbuf.dec_weights_ideal_value;\n+ float *dec_weights_ideal_sig = tmpbuf.dec_weights_ideal_sig;\n+ float *dec_weights_quant_uvalue = tmpbuf.dec_weights_quant_uvalue;\n+ uint8_t *dec_weights_quant_pvalue = tmpbuf.dec_weights_quant_pvalue;\n// For each decimation mode, compute an ideal set of weights with no quantization\nfor (unsigned int i = 0; i < bsd.decimation_mode_count; i++)\n@@ -278,8 +278,8 @@ static float compress_symbolic_block_for_partition_1plane(\nei,\neix[i],\ndi,\n- decimated_quantized_weights + i * BLOCK_MAX_WEIGHTS,\n- decimated_weights + i * BLOCK_MAX_WEIGHTS);\n+ dec_weights_ideal_value + i * BLOCK_MAX_WEIGHTS,\n+ dec_weights_ideal_sig + i * BLOCK_MAX_WEIGHTS);\n}\n// Compute maximum colors for the endpoints and ideal weights, then for each endpoint and ideal\n@@ -302,7 +302,7 @@ static float compress_symbolic_block_for_partition_1plane(\ncompute_angular_endpoints_1plane(\nconfig.tune_low_weight_count_limit,\nonly_always, bsd,\n- decimated_quantized_weights, decimated_weights,\n+ dec_weights_ideal_value, dec_weights_ideal_sig,\nweight_low_value, weight_high_value);\n// For each mode (which specifies a decimation and a quantization):\n@@ -347,16 +347,16 @@ static float compress_symbolic_block_for_partition_1plane(\ncompute_quantized_weights_for_decimation(\ndi,\nweight_low_value[i], weight_high_value[i],\n- decimated_quantized_weights + BLOCK_MAX_WEIGHTS * decimation_mode,\n- flt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * i,\n- u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * i,\n+ dec_weights_ideal_value + BLOCK_MAX_WEIGHTS * decimation_mode,\n+ dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * i,\n+ dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * i,\nbm.get_weight_quant_mode());\n// Compute weight quantization errors for the block mode\nqwt_errors[i] = compute_error_of_weight_set_1plane(\neix[decimation_mode],\ndi,\n- flt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * i);\n+ dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * i);\n}\n// Decide the optimal combination of color endpoint encodings and weight encodings\n@@ -399,7 +399,7 @@ static float compress_symbolic_block_for_partition_1plane(\nsymbolic_compressed_block workscb;\n- uint8_t* u8_weight_src = u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * bm_packed_index;\n+ uint8_t* u8_weight_src = dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * bm_packed_index;\nfor (unsigned int j = 0; j < di.weight_count; j++)\n{\n@@ -599,10 +599,10 @@ static float compress_symbolic_block_for_partition_2planes(\ncompute_ideal_colors_and_weights_2planes(bsd, blk, ewb, plane2_component, ei1, ei2);\n// Compute ideal weights and endpoint colors for every decimation\n- float *decimated_quantized_weights = tmpbuf.decimated_quantized_weights;\n- float *decimated_weights = tmpbuf.decimated_weights;\n- float *flt_quantized_decimated_quantized_weights = tmpbuf.flt_quantized_decimated_quantized_weights;\n- uint8_t *u8_quantized_decimated_quantized_weights = tmpbuf.u8_quantized_decimated_quantized_weights;\n+ float *dec_weights_ideal_value = tmpbuf.dec_weights_ideal_value;\n+ float *dec_weights_ideal_sig = tmpbuf.dec_weights_ideal_sig;\n+ float *dec_weights_quant_uvalue = tmpbuf.dec_weights_quant_uvalue;\n+ uint8_t *dec_weights_quant_pvalue = tmpbuf.dec_weights_quant_pvalue;\n// For each decimation mode, compute an ideal set of weights with no quantization\nfor (unsigned int i = 0; i < bsd.decimation_mode_count; i++)\n@@ -619,15 +619,15 @@ static float compress_symbolic_block_for_partition_2planes(\nei1,\neix1[i],\ndi,\n- decimated_quantized_weights + (2 * i) * BLOCK_MAX_WEIGHTS,\n- decimated_weights + (2 * i) * BLOCK_MAX_WEIGHTS);\n+ dec_weights_ideal_value + (2 * i) * BLOCK_MAX_WEIGHTS,\n+ dec_weights_ideal_sig + (2 * i) * BLOCK_MAX_WEIGHTS);\ncompute_ideal_weights_for_decimation(\nei2,\neix2[i],\ndi,\n- decimated_quantized_weights + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\n- decimated_weights + (2 * i + 1) * BLOCK_MAX_WEIGHTS);\n+ dec_weights_ideal_value + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\n+ dec_weights_ideal_sig + (2 * i + 1) * BLOCK_MAX_WEIGHTS);\n}\n// Compute maximum colors for the endpoints and ideal weights, then for each endpoint and ideal\n@@ -661,7 +661,7 @@ static float compress_symbolic_block_for_partition_2planes(\ncompute_angular_endpoints_2planes(\nconfig.tune_low_weight_count_limit,\n- bsd, decimated_quantized_weights, decimated_weights,\n+ bsd, dec_weights_ideal_value, dec_weights_ideal_sig,\nweight_low_value1, weight_high_value1,\nweight_low_value2, weight_high_value2);\n@@ -711,18 +711,18 @@ static float compress_symbolic_block_for_partition_2planes(\ndi,\nweight_low_value1[i],\nweight_high_value1[i],\n- decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * decimation_mode),\n- flt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i),\n- u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i),\n+ dec_weights_ideal_value + BLOCK_MAX_WEIGHTS * (2 * decimation_mode),\n+ dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * (2 * i),\n+ dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * (2 * i),\nbm.get_weight_quant_mode());\ncompute_quantized_weights_for_decimation(\ndi,\nweight_low_value2[i],\nweight_high_value2[i],\n- decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * decimation_mode + 1),\n- flt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i + 1),\n- u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i + 1),\n+ dec_weights_ideal_value + BLOCK_MAX_WEIGHTS * (2 * decimation_mode + 1),\n+ dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * (2 * i + 1),\n+ dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * (2 * i + 1),\nbm.get_weight_quant_mode());\n// Compute weight quantization errors for the block mode\n@@ -730,8 +730,8 @@ static float compress_symbolic_block_for_partition_2planes(\neix1[decimation_mode],\neix2[decimation_mode],\ndi,\n- flt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i),\n- flt_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * i + 1));\n+ dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * (2 * i),\n+ dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * (2 * i + 1));\n}\n// Decide the optimal combination of color endpoint encodings and weight encodings\n@@ -780,8 +780,8 @@ static float compress_symbolic_block_for_partition_2planes(\nsymbolic_compressed_block workscb;\n- uint8_t* u8_weight1_src = u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * bm_packed_index);\n- uint8_t* u8_weight2_src = u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * (2 * bm_packed_index + 1);\n+ uint8_t* u8_weight1_src = dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * (2 * bm_packed_index);\n+ uint8_t* u8_weight2_src = dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * (2 * bm_packed_index + 1);\nfor (int j = 0; j < di.weight_count; j++)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1020,10 +1020,10 @@ struct endpoints_and_weights\n/** @brief The color endpoints. */\nendpoints ep;\n- /** @brief The undecimated and unquantized weight for each texel. */\n+ /** @brief The ideal weight for each texel; may be undecimated or decimated. */\nalignas(ASTCENC_VECALIGN) float weights[BLOCK_MAX_TEXELS];\n- /** @brief The undecimated and unquantized weight error scaling for each texel. */\n+ /** @brief The ideal weight error scaling for each texel; may be undecimated or decimated. */\nalignas(ASTCENC_VECALIGN) float weight_error_scale[BLOCK_MAX_TEXELS];\n};\n@@ -1062,26 +1062,26 @@ struct alignas(ASTCENC_VECALIGN) compression_working_buffers\n/** @brief Ideal endpoints and weights for plane 2. */\nendpoints_and_weights ei2;\n- /** @brief Ideal endpoints and weights for plane 1. */\n+ /** @brief Ideal decimated endpoints and weights for plane 1. */\nendpoints_and_weights eix1[WEIGHTS_MAX_DECIMATION_MODES];\n- /** @brief Ideal endpoints and weights for plane 2. */\n+ /** @brief Ideal decimated endpoints and weights for plane 2. */\nendpoints_and_weights eix2[WEIGHTS_MAX_DECIMATION_MODES];\n/** @brief The error weight block for the current thread. */\nerror_weight_block ewb;\n- /** @brief Decimated and weight values, rounded to quantization points but not stored packed. */\n- alignas(ASTCENC_VECALIGN) float decimated_quantized_weights[2 * WEIGHTS_MAX_DECIMATION_MODES * BLOCK_MAX_WEIGHTS];\n+ /** @brief Decimated ideal weight values. */\n+ alignas(ASTCENC_VECALIGN) float dec_weights_ideal_value[2 * WEIGHTS_MAX_DECIMATION_MODES * BLOCK_MAX_WEIGHTS];\n- /** @brief Decimated and unquantized weight values. */\n- alignas(ASTCENC_VECALIGN) float decimated_weights[2 * WEIGHTS_MAX_DECIMATION_MODES * BLOCK_MAX_WEIGHTS];\n+ /** @brief Decimated ideal weight significance. */\n+ alignas(ASTCENC_VECALIGN) float dec_weights_ideal_sig[2 * WEIGHTS_MAX_DECIMATION_MODES * BLOCK_MAX_WEIGHTS];\n- /** @brief Decimated and quantized weight values stored in the packed quantized weight range. */\n- alignas(ASTCENC_VECALIGN) float flt_quantized_decimated_quantized_weights[2 * WEIGHTS_MAX_BLOCK_MODES * BLOCK_MAX_WEIGHTS];\n+ /** @brief Decimated and quantized weight values stored in the unpacked quantized weight range. */\n+ alignas(ASTCENC_VECALIGN) float dec_weights_quant_uvalue[2 * WEIGHTS_MAX_BLOCK_MODES * BLOCK_MAX_WEIGHTS];\n/** @brief Decimated and quantized weight values stored in the packed quantized weight range. */\n- alignas(ASTCENC_VECALIGN) uint8_t u8_quantized_decimated_quantized_weights[2 * WEIGHTS_MAX_BLOCK_MODES * BLOCK_MAX_WEIGHTS];\n+ alignas(ASTCENC_VECALIGN) uint8_t dec_weights_quant_pvalue[2 * WEIGHTS_MAX_BLOCK_MODES * BLOCK_MAX_WEIGHTS];\n};\n/**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
More weight variable name clenaup
61,745
08.06.2021 08:38:47
-3,600
ee0af0427504166aa7d082cc124d86c8259002eb
More weight variable naming cleanup
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -64,8 +64,8 @@ static void merge_endpoints(\n* @param blk The image block color data to compress.\n* @param ewb The image block weighted error data.\n* @param[out] scb The symbolic compressed block output.\n- * @param[out] weight_set8_plane1 The quantized weights for plane 1.\n- * @param[out] weight_set8_plane2 The quantized weights for plane 2, @c nullptr if 1 plane.\n+ * @param[out] dec_weights_quant_pvalue_plane1 The weights for plane 1.\n+ * @param[out] dec_weights_quant_pvalue_plane2 The weights for plane 2, or @c nullptr if 1 plane.\n*/\nstatic bool realign_weights(\nastcenc_profile decode_mode,\n@@ -73,8 +73,8 @@ static bool realign_weights(\nconst image_block& blk,\nconst error_weight_block& ewb,\nsymbolic_compressed_block& scb,\n- uint8_t* weight_set8_plane1,\n- uint8_t* weight_set8_plane2\n+ uint8_t* dec_weights_quant_pvalue_plane1,\n+ uint8_t* dec_weights_quant_pvalue_plane2\n) {\n// Get the partition descriptor\nunsigned int partition_count = scb.partition_count;\n@@ -116,7 +116,7 @@ static bool realign_weights(\n}\nuint8_t uq_pl_weights[BLOCK_MAX_WEIGHTS];\n- uint8_t* weight_set8 = weight_set8_plane1;\n+ uint8_t* dec_weights_quant_pvalue = dec_weights_quant_pvalue_plane1;\nbool adjustments = false;\n// For each plane and partition ...\n@@ -135,7 +135,7 @@ static bool realign_weights(\n// Create an unquantized weight grid for this decimation level\nfor (unsigned int we_idx = 0; we_idx < weight_count; we_idx++)\n{\n- uq_pl_weights[we_idx] = qat->unquantized_value[weight_set8[we_idx]];\n+ uq_pl_weights[we_idx] = qat->unquantized_value[dec_weights_quant_pvalue[we_idx]];\n}\n// For each weight compute previous, current, and next errors\n@@ -196,19 +196,19 @@ static bool realign_weights(\nif ((up_error < current_error) && (up_error < down_error))\n{\nuq_pl_weights[we_idx] = next_wt_uq;\n- weight_set8[we_idx] = (uint8_t)((prev_and_next >> 24) & 0xFF);\n+ dec_weights_quant_pvalue[we_idx] = (uint8_t)((prev_and_next >> 24) & 0xFF);\nadjustments = true;\n}\nelse if (down_error < current_error)\n{\nuq_pl_weights[we_idx] = prev_wt_uq;\n- weight_set8[we_idx] = (uint8_t)((prev_and_next >> 16) & 0xFF);\n+ dec_weights_quant_pvalue[we_idx] = (uint8_t)((prev_and_next >> 16) & 0xFF);\nadjustments = true;\n}\n}\n// Prepare iteration for plane 2\n- weight_set8 = weight_set8_plane2;\n+ dec_weights_quant_pvalue = dec_weights_quant_pvalue_plane2;\nplane_mask = ~plane_mask;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1106,7 +1106,7 @@ void recompute_ideal_colors_1plane(\nconst partition_info& pi,\nconst decimation_info& di,\nint weight_quant_mode,\n- const uint8_t* weight_set8,\n+ const uint8_t* dec_weights_quant_pvalue,\nendpoints& ep,\nvfloat4 rgbs_vectors[BLOCK_MAX_PARTITIONS],\nvfloat4 rgbo_vectors[BLOCK_MAX_PARTITIONS]\n@@ -1120,10 +1120,10 @@ void recompute_ideal_colors_1plane(\nconst quantization_and_transfer_table& qat = quant_and_xfer_tables[weight_quant_mode];\n- float dec_weight_ideal_value[BLOCK_MAX_WEIGHTS];\n+ float dec_weight_quant_uvalue[BLOCK_MAX_WEIGHTS];\nfor (int i = 0; i < weight_count; i++)\n{\n- dec_weight_ideal_value[i] = qat.unquantized_value[weight_set8[i]] * (1.0f / 64.0f);\n+ dec_weight_quant_uvalue[i] = qat.unquantized_value[dec_weights_quant_pvalue[i]] * (1.0f / 64.0f);\n}\nfor (int i = 0; i < partition_count; i++)\n@@ -1178,10 +1178,10 @@ void recompute_ideal_colors_1plane(\n// TODO: Move this calculation out to the color block?\nfloat ls_weight = hadd_rgb_s(color_weight);\n- float idx0 = dec_weight_ideal_value[tix];\n+ float idx0 = dec_weight_quant_uvalue[tix];\nif (is_decimated)\n{\n- idx0 = bilinear_infill(di, dec_weight_ideal_value, tix);\n+ idx0 = bilinear_infill(di, dec_weight_quant_uvalue, tix);\n}\nfloat om_idx0 = 1.0f - idx0;\n@@ -1315,8 +1315,8 @@ void recompute_ideal_colors_2planes(\nconst block_size_descriptor& bsd,\nconst decimation_info& di,\nint weight_quant_mode,\n- const uint8_t* weight_set8_plane1,\n- const uint8_t* weight_set8_plane2,\n+ const uint8_t* dec_weights_quant_pvalue_plane1,\n+ const uint8_t* dec_weights_quant_pvalue_plane2,\nendpoints& ep,\nvfloat4& rgbs_vector,\nvfloat4& rgbo_vector,\n@@ -1329,13 +1329,13 @@ void recompute_ideal_colors_2planes(\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_mode]);\n- float dec_weight_ideal_value[BLOCK_MAX_WEIGHTS];\n- float plane2_weight_set[BLOCK_MAX_WEIGHTS];\n+ float dec_weights_quant_uvalue_plane1[BLOCK_MAX_WEIGHTS];\n+ float dec_weights_quant_uvalue_plane2[BLOCK_MAX_WEIGHTS];\nfor (int i = 0; i < weight_count; i++)\n{\n- dec_weight_ideal_value[i] = qat->unquantized_value[weight_set8_plane1[i]] * (1.0f / 64.0f);\n- plane2_weight_set[i] = qat->unquantized_value[weight_set8_plane2[i]] * (1.0f / 64.0f);\n+ dec_weights_quant_uvalue_plane1[i] = qat->unquantized_value[dec_weights_quant_pvalue_plane1[i]] * (1.0f / 64.0f);\n+ dec_weights_quant_uvalue_plane2[i] = qat->unquantized_value[dec_weights_quant_pvalue_plane2[i]] * (1.0f / 64.0f);\n}\nvfloat4 rgba_sum = ewb.block_error_weighted_rgba_sum;\n@@ -1378,10 +1378,10 @@ void recompute_ideal_colors_2planes(\n// TODO: Move this calculation out to the color block?\nfloat ls_weight = hadd_rgb_s(color_weight);\n- float idx0 = dec_weight_ideal_value[j];\n+ float idx0 = dec_weights_quant_uvalue_plane1[j];\nif (is_decimated)\n{\n- idx0 = bilinear_infill(di, dec_weight_ideal_value, j);\n+ idx0 = bilinear_infill(di, dec_weights_quant_uvalue_plane1, j);\n}\nfloat om_idx0 = 1.0f - idx0;\n@@ -1405,10 +1405,10 @@ void recompute_ideal_colors_2planes(\nright_sum += right;\nlmrs_sum += lmrs;\n- float idx1 = plane2_weight_set[j];\n+ float idx1 = dec_weights_quant_uvalue_plane2[j];\nif (is_decimated)\n{\n- idx1 = bilinear_infill(di, plane2_weight_set, j);\n+ idx1 = bilinear_infill(di, dec_weights_quant_uvalue_plane2, j);\n}\nfloat om_idx1 = 1.0f - idx1;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -2067,7 +2067,7 @@ unsigned int compute_ideal_endpoint_formats(\n* @param pi The partition info for the current trial.\n* @param di The weight grid decimation table.\n* @param weight_quant_mode The weight grid quantization level.\n- * @param weight_set8 The quantized weight set.\n+ * @param dec_weights_quant_pvalue The quantized weight set.\n* @param[in,out] ep The color endpoints (modifed in place).\n* @param[out] rgbs_vectors The RGB+scale vectors for LDR blocks.\n* @param[out] rgbo_vectors The RGB+offset vectors for HDR blocks.\n@@ -2078,7 +2078,7 @@ void recompute_ideal_colors_1plane(\nconst partition_info& pi,\nconst decimation_info& di,\nint weight_quant_mode,\n- const uint8_t* weight_set8,\n+ const uint8_t* dec_weights_quant_pvalue,\nendpoints& ep,\nvfloat4 rgbs_vectors[BLOCK_MAX_PARTITIONS],\nvfloat4 rgbo_vectors[BLOCK_MAX_PARTITIONS]);\n@@ -2094,8 +2094,8 @@ void recompute_ideal_colors_1plane(\n* @param bsd The block_size descriptor.\n* @param di The weight grid decimation table.\n* @param weight_quant_mode The weight grid quantization level.\n- * @param weight_set8_plane1 The quantized weight set for plane 1.\n- * @param weight_set8_plane2 The quantized weight set for plane 2.\n+ * @param dec_weights_quant_pvalue_plane1 The quantized weight set for plane 1.\n+ * @param dec_weights_quant_pvalue_plane2 The quantized weight set for plane 2.\n* @param[in,out] ep The color endpoints (modifed in place).\n* @param[out] rgbs_vector The RGB+scale color for LDR blocks.\n* @param[out] rgbo_vector The RGB+offset color for HDR blocks.\n@@ -2107,8 +2107,8 @@ void recompute_ideal_colors_2planes(\nconst block_size_descriptor& bsd,\nconst decimation_info& di,\nint weight_quant_mode,\n- const uint8_t* weight_set8_plane1,\n- const uint8_t* weight_set8_plane2,\n+ const uint8_t* dec_weights_quant_pvalue_plane1,\n+ const uint8_t* dec_weights_quant_pvalue_plane2,\nendpoints& ep,\nvfloat4& rgbs_vector,\nvfloat4& rgbo_vector,\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
More weight variable naming cleanup
61,745
09.06.2021 09:29:07
-3,600
055acba2c53dff3486ed54fc4b820309ee1cdcd6
Workaround MSVC 2019 codegen bug
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "@@ -431,7 +431,15 @@ ASTCENC_SIMD_INLINE vint4 unorm16_to_sf16(vint4 p)\nvmask4 is_one = p == vint4(0xFFFF);\nvmask4 is_small = p < vint4(4);\n+// Manually inline clz() on Visual Studio to avoid release build codegen bug\n+#if !defined(__clang__) && defined(_MSC_VER)\n+ vint a = (~lsr<8>(p)) & p;\n+ a = float_as_int(int_to_float(a));\n+ a = vint4(127 + 31) - lsr<23>(a);\n+ vint4 lz = clamp(0, 32, a) - 16;\n+#else\nvint4 lz = clz(p) - 16;\n+#endif\n// TODO: Could use AVX2 _mm_sllv_epi32() instead of p * 2^<shift>\np = p * two_to_the_n(lz + 1);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Workaround MSVC 2019 codegen bug
61,745
09.06.2021 09:34:40
-3,600
a3b86095f7c81920bfbe1e7eafc84c27cd9fe094
Ensure all header functions are static
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "@@ -381,7 +381,7 @@ static ASTCENC_SIMD_INLINE vfloat4 pow(vfloat4 x, vfloat4 y)\n*\n* Valid for all data values of @c a; will return a per-lane value [0, 32].\n*/\n-ASTCENC_SIMD_INLINE vint4 clz(vint4 a)\n+static ASTCENC_SIMD_INLINE vint4 clz(vint4 a)\n{\n// This function is a horrible abuse of floating point exponents to convert\n// the original integer value into a 2^N encoding we can recover easily.\n@@ -403,7 +403,7 @@ ASTCENC_SIMD_INLINE vint4 clz(vint4 a)\n*\n* Use of signed int mean that this is only valid for values in range [0, 31].\n*/\n-ASTCENC_SIMD_INLINE vint4 two_to_the_n(vint4 a)\n+static ASTCENC_SIMD_INLINE vint4 two_to_the_n(vint4 a)\n{\n// 2^30 is the largest signed number than can be represented\nassert(all(a < vint4(31)));\n@@ -423,7 +423,7 @@ ASTCENC_SIMD_INLINE vint4 two_to_the_n(vint4 a)\n/**\n* @brief Convert unorm16 [0, 65535] to float16 in range [0, 1].\n*/\n-ASTCENC_SIMD_INLINE vint4 unorm16_to_sf16(vint4 p)\n+static ASTCENC_SIMD_INLINE vint4 unorm16_to_sf16(vint4 p)\n{\nvint4 fp16_one = vint4(0x3C00);\nvint4 fp16_small = lsl<8>(p);\n@@ -457,7 +457,7 @@ ASTCENC_SIMD_INLINE vint4 unorm16_to_sf16(vint4 p)\n/**\n* @brief Convert 16-bit LNS to float16.\n*/\n-ASTCENC_SIMD_INLINE vint4 lns_to_sf16(vint4 p)\n+static ASTCENC_SIMD_INLINE vint4 lns_to_sf16(vint4 p)\n{\nvint4 mc = p & 0x7FF;\nvint4 ec = lsr<11>(p);\n@@ -486,7 +486,7 @@ ASTCENC_SIMD_INLINE vint4 lns_to_sf16(vint4 p)\n*\n* @return The mantissa.\n*/\n-static inline vfloat4 frexp(vfloat4 a, vint4& exp)\n+static ASTCENC_SIMD_INLINE vfloat4 frexp(vfloat4 a, vint4& exp)\n{\n// Interpret the bits as an integer\nvint4 ai = float_as_int(a);\n@@ -502,7 +502,7 @@ static inline vfloat4 frexp(vfloat4 a, vint4& exp)\n/**\n* @brief Convert float to 16-bit LNS.\n*/\n-static inline vfloat4 float_to_lns(vfloat4 a)\n+static ASTCENC_SIMD_INLINE vfloat4 float_to_lns(vfloat4 a)\n{\nvint4 exp;\nvfloat4 mant = frexp(a, exp);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Ensure all header functions are static
61,745
09.06.2021 16:11:47
-3,600
2fa1493d18cf3b3b4ecc978c7a4becf6352b3ebb
Add issue reference to MSVC workaround comment
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "@@ -432,6 +432,7 @@ static ASTCENC_SIMD_INLINE vint4 unorm16_to_sf16(vint4 p)\nvmask4 is_small = p < vint4(4);\n// Manually inline clz() on Visual Studio to avoid release build codegen bug\n+ // see https://github.com/ARM-software/astc-encoder/issues/259\n#if !defined(__clang__) && defined(_MSC_VER)\nvint4 a = (~lsr<8>(p)) & p;\na = float_as_int(int_to_float(a));\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add issue reference to MSVC workaround comment
61,745
10.06.2021 00:11:29
-3,600
bff056d4b74cf66b5a30e97532313e8fd26c15a4
Remove unused 2 plane partition selection
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1474,13 +1474,11 @@ void compress_block(\nfor (int partition_count = 2; partition_count <= max_partitions; partition_count++)\n{\nunsigned int partition_indices_1plane[2] { 0, 0 };\n- unsigned int partition_index_2planes { 0 };\nfind_best_partition_candidates(*bsd, blk, ewb, partition_count,\nctx.config.tune_partition_index_limit,\npartition_indices_1plane[0],\n- partition_indices_1plane[1],\n- block_skip_two_plane ? nullptr : &partition_index_2planes);\n+ partition_indices_1plane[1]);\nfor (int i = 0; i < 2; i++)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -477,8 +477,7 @@ void find_best_partition_candidates(\nunsigned int partition_count,\nunsigned int partition_search_limit,\nunsigned int& best_partition_uncor,\n- unsigned int& best_partition_samec,\n- unsigned int* best_partition_dualplane\n+ unsigned int& best_partition_samec\n) {\n// Constant used to estimate quantization error for a given partitioning; the optimal value for\n// this depends on bitrate. These values have been determined empirically.\n@@ -516,13 +515,6 @@ void find_best_partition_candidates(\nfloat samec_best_errors[2] { ERROR_CALC_DEFAULT, ERROR_CALC_DEFAULT };\nunsigned int samec_best_partitions[2] { 0, 0 };\n- // Partitioning errors assuming that one color component is uncorrelated\n- float sep_best_error { ERROR_CALC_DEFAULT };\n- unsigned int sep_best_partition { 0 };\n- unsigned int sep_best_component { 0 };\n-\n- bool skip_two_plane = best_partition_dualplane == nullptr;\n-\nif (uses_alpha)\n{\nfor (unsigned int i = 0; i < partition_search_limit; i++)\n@@ -543,10 +535,6 @@ void find_best_partition_candidates(\nline4 uncor_lines[BLOCK_MAX_PARTITIONS];\nline4 samec_lines[BLOCK_MAX_PARTITIONS];\n- line3 sep_r_lines[BLOCK_MAX_PARTITIONS];\n- line3 sep_g_lines[BLOCK_MAX_PARTITIONS];\n- line3 sep_b_lines[BLOCK_MAX_PARTITIONS];\n- line3 sep_a_lines[BLOCK_MAX_PARTITIONS];\nprocessed_line4 uncor_plines[BLOCK_MAX_PARTITIONS];\nprocessed_line4 samec_plines[BLOCK_MAX_PARTITIONS];\n@@ -571,30 +559,10 @@ void find_best_partition_candidates(\nsamec_plines[j].amod = vfloat4::zero();\nsamec_plines[j].bs = samec_lines[j].b * pm.color_scale;\nsamec_plines[j].bis = samec_lines[j].b * pm.icolor_scale;\n-\n- if (!skip_two_plane)\n- {\n- sep_r_lines[j].a = pm.avg.swz<1, 2, 3>();\n- vfloat4 dirs_gba = pm.dir.swz<1, 2, 3>();\n- sep_r_lines[j].b = normalize_safe(dirs_gba, unit3());\n-\n- sep_g_lines[j].a = pm.avg.swz<0, 2, 3>();\n- vfloat4 dirs_rba = pm.dir.swz<0, 2, 3>();\n- sep_g_lines[j].b = normalize_safe(dirs_rba, unit3());\n-\n- sep_b_lines[j].a = pm.avg.swz<0, 1, 3>();\n- vfloat4 dirs_rga = pm.dir.swz<0, 1, 3>();\n- sep_b_lines[j].b = normalize_safe(dirs_rga, unit3());\n-\n- sep_a_lines[j].a = pm.avg.swz<0, 1, 2>();\n- vfloat4 dirs_rgb = pm.dir.swz<0, 1, 2>();\n- sep_a_lines[j].b = normalize_safe(dirs_rgb, unit3());\n- }\n}\nfloat uncor_error = 0.0f;\nfloat samec_error = 0.0f;\n- vfloat4 sep_error = vfloat4::zero();\ncompute_error_squared_rgba(pi,\nblk,\n@@ -632,26 +600,6 @@ void find_best_partition_candidates(\nuncor_error += dot_s(uncor_vector, error_weights);\nsamec_error += dot_s(samec_vector, error_weights);\n-\n- if (!skip_two_plane)\n- {\n- vfloat4 sep_r_vector = sep_r_lines[j].b * ics.swz<1, 2, 3, 0>();\n- vfloat4 sep_g_vector = sep_g_lines[j].b * ics.swz<0, 2, 3, 1>();\n- vfloat4 sep_b_vector = sep_b_lines[j].b * ics.swz<0, 1, 3, 2>();\n- vfloat4 sep_a_vector = sep_a_lines[j].b * ics.swz<0, 1, 2, 3>();\n-\n- sep_r_vector = sep_r_vector * sep_r_vector;\n- sep_g_vector = sep_g_vector * sep_g_vector;\n- sep_b_vector = sep_b_vector * sep_b_vector;\n- sep_a_vector = sep_a_vector * sep_a_vector;\n-\n- vfloat4 sep_err_inc(dot3_s(sep_r_vector, error_weights.swz<1, 2, 3, 0>()),\n- dot3_s(sep_g_vector, error_weights.swz<0, 2, 3, 1>()),\n- dot3_s(sep_b_vector, error_weights.swz<0, 1, 3, 2>()),\n- dot3_s(sep_a_vector, error_weights.swz<0, 1, 2, 3>()));\n-\n- sep_error = sep_error + sep_err_inc + pm.range_sq * error_weights;\n- }\n}\nif (uncor_error < uncor_best_error)\n@@ -673,37 +621,6 @@ void find_best_partition_candidates(\nsamec_best_errors[1] = samec_error;\nsamec_best_partitions[1] = partition;\n}\n-\n- if (!skip_two_plane)\n- {\n- if (sep_error.lane<0>() < sep_best_error)\n- {\n- sep_best_error = sep_error.lane<0>();\n- sep_best_partition = partition;\n- sep_best_component = 0;\n- }\n-\n- if (sep_error.lane<1>() < sep_best_error)\n- {\n- sep_best_error = sep_error.lane<1>();\n- sep_best_partition = partition;\n- sep_best_component = 1;\n- }\n-\n- if (sep_error.lane<2>() < sep_best_error)\n- {\n- sep_best_error = sep_error.lane<2>();\n- sep_best_partition = partition;\n- sep_best_component = 2;\n- }\n-\n- if (sep_error.lane<3>() < sep_best_error)\n- {\n- sep_best_error = sep_error.lane<3>();\n- sep_best_partition = partition;\n- sep_best_component = 3;\n- }\n- }\n}\n}\nelse\n@@ -725,10 +642,6 @@ void find_best_partition_candidates(\npartition_lines3 plines[BLOCK_MAX_PARTITIONS];\n- line2 sep_r_lines[BLOCK_MAX_PARTITIONS];\n- line2 sep_g_lines[BLOCK_MAX_PARTITIONS];\n- line2 sep_b_lines[BLOCK_MAX_PARTITIONS];\n-\nfor (unsigned int j = 0; j < partition_count; j++)\n{\npartition_metrics& pm = pms[j];\n@@ -747,26 +660,10 @@ void find_best_partition_candidates(\npl.samec_pline.amod = vfloat4::zero();\npl.samec_pline.bs = (pl.samec_line.b * pm.color_scale.swz<0, 1, 2, 3>());\npl.samec_pline.bis = (pl.samec_line.b * pm.icolor_scale.swz<0, 1, 2, 3>());\n-\n- if (!skip_two_plane)\n- {\n- sep_r_lines[j].a = pm.avg.swz<1, 2>();\n- vfloat4 dirs_gb = pm.dir.swz<1, 2>();\n- sep_r_lines[j].b = normalize_safe(dirs_gb, unit2());\n-\n- sep_g_lines[j].a = pm.avg.swz<0, 2>();\n- vfloat4 dirs_rb = pm.dir.swz<0, 2>();\n- sep_g_lines[j].b = normalize_safe(dirs_rb, unit2());\n-\n- sep_b_lines[j].a = pm.avg.swz<0, 1>();\n- vfloat4 dirs_rg = pm.dir.swz<0, 1>();\n- sep_b_lines[j].b = normalize_safe(dirs_rg, unit2());\n- }\n}\nfloat uncor_error = 0.0f;\nfloat samec_error = 0.0f;\n- vfloat4 sep_error = vfloat4::zero();\ncompute_error_squared_rgb(pi,\nblk,\n@@ -806,25 +703,6 @@ void find_best_partition_candidates(\nuncor_error += dot3_s(uncor_vector, error_weights);\nsamec_error += dot3_s(samec_vector, error_weights);\n-\n- if (!skip_two_plane)\n- {\n- vfloat4 sep_r_vector = sep_r_lines[j].b * ics.swz<1, 2>();\n- vfloat4 sep_g_vector = sep_g_lines[j].b * ics.swz<0, 2>();\n- vfloat4 sep_b_vector = sep_b_lines[j].b * ics.swz<0, 1>();\n-\n- sep_r_vector = sep_r_vector * sep_r_vector;\n- sep_g_vector = sep_g_vector * sep_g_vector;\n- sep_b_vector = sep_b_vector * sep_b_vector;\n-\n- sep_error.set_lane<0>(sep_error.lane<0>() + dot_s(sep_r_vector, error_weights.swz<1, 2>()));\n- sep_error.set_lane<1>(sep_error.lane<1>() + dot_s(sep_g_vector, error_weights.swz<0, 2>()));\n- sep_error.set_lane<2>(sep_error.lane<2>() + dot_s(sep_b_vector, error_weights.swz<0, 1>()));\n-\n- sep_error.set_lane<0>(sep_error.lane<0>() + pm.range_sq.lane<0>() * error_weights.lane<0>());\n- sep_error.set_lane<1>(sep_error.lane<1>() + pm.range_sq.lane<1>() * error_weights.lane<1>());\n- sep_error.set_lane<2>(sep_error.lane<2>() + pm.range_sq.lane<2>() * error_weights.lane<2>());\n- }\n}\nif (uncor_error < uncor_best_error)\n@@ -846,30 +724,6 @@ void find_best_partition_candidates(\nsamec_best_errors[1] = samec_error;\nsamec_best_partitions[1] = partition;\n}\n-\n- if (!skip_two_plane)\n- {\n- if (sep_error.lane<0>() < sep_best_error)\n- {\n- sep_best_error = sep_error.lane<0>();\n- sep_best_partition = partition;\n- sep_best_component = 0;\n- }\n-\n- if (sep_error.lane<1>() < sep_best_error)\n- {\n- sep_best_error = sep_error.lane<1>();\n- sep_best_partition = partition;\n- sep_best_component = 1;\n- }\n-\n- if (sep_error.lane<2>() < sep_best_error)\n- {\n- sep_best_error = sep_error.lane<2>();\n- sep_best_partition = partition;\n- sep_best_component = 2;\n- }\n- }\n}\n}\n@@ -877,12 +731,6 @@ void find_best_partition_candidates(\nunsigned int index = samec_best_partitions[0] != uncor_best_partition ? 0 : 1;\nbest_partition_samec = samec_best_partitions[index];\n-\n- if (best_partition_dualplane)\n- {\n- *best_partition_dualplane = (sep_best_component << PARTITION_INDEX_BITS) |\n- (sep_best_partition);\n- }\n}\n#endif\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1646,10 +1646,7 @@ void compute_error_squared_rgba(\n* @brief Find the best set of partitions to trial for a given block.\n*\n* On return @c best_partition_uncor contains the best partition assuming data has uncorrelated\n- * chroma, @c best_partition_samec contains the best partition assuming data has corelated chroma,\n- * and* @c best_partition_dualplane contains the best partition assuming the data has one\n- * uncorrelated color component. The @c best_partition_dualplane is stored packed; bits [9:0]\n- * contain the best partition, bits [11:10] contain the best color component.\n+ * chroma, @c best_partition_samec contains the best partition assuming data has corelated chroma.\n*\n* @param bsd The block size information.\n* @param blk The image block color data to compress.\n@@ -1658,7 +1655,6 @@ void compute_error_squared_rgba(\n* @param partition_search_limit The number of candidate partition encodings to trial.\n* @param[out] best_partition_uncor The best partition for uncorrelated chroma.\n* @param[out] best_partition_samec The best partition for correlated chroma.\n- * @param[out] best_partition_dualplane The best partition for dual plane, but may be @c nullptr.\n*/\nvoid find_best_partition_candidates(\nconst block_size_descriptor& bsd,\n@@ -1667,8 +1663,7 @@ void find_best_partition_candidates(\nunsigned int partition_count,\nunsigned int partition_search_limit,\nunsigned int& best_partition_uncor,\n- unsigned int& best_partition_samec,\n- unsigned int* best_partition_dualplane);\n+ unsigned int& best_partition_samec);\n/* ============================================================================\nFunctionality for managing images and image related data.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove unused 2 plane partition selection
61,745
10.06.2021 13:06:03
-3,600
b3febbfe64882a7470dc5cc1f4dd2e0dc9ac2362
Fix diagnostics builds
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1267,14 +1267,14 @@ static float prepare_block_statistics(\nlowest_correlation = astc::min(lowest_correlation, fabsf(ba_cov));\n// Diagnostic trace points\n- trace_add_data(\"min_r\", blk->data_min.lane<0>());\n- trace_add_data(\"max_r\", blk->data_max.lane<0>());\n- trace_add_data(\"min_g\", blk->data_min.lane<1>());\n- trace_add_data(\"max_g\", blk->data_max.lane<1>());\n- trace_add_data(\"min_b\", blk->data_min.lane<2>());\n- trace_add_data(\"max_b\", blk->data_max.lane<2>());\n- trace_add_data(\"min_a\", blk->data_min.lane<3>());\n- trace_add_data(\"max_a\", blk->data_max.lane<3>());\n+ trace_add_data(\"min_r\", blk.data_min.lane<0>());\n+ trace_add_data(\"max_r\", blk.data_max.lane<0>());\n+ trace_add_data(\"min_g\", blk.data_min.lane<1>());\n+ trace_add_data(\"max_g\", blk.data_max.lane<1>());\n+ trace_add_data(\"min_b\", blk.data_min.lane<2>());\n+ trace_add_data(\"max_b\", blk.data_max.lane<2>());\n+ trace_add_data(\"min_a\", blk.data_min.lane<3>());\n+ trace_add_data(\"max_a\", blk.data_max.lane<3>());\ntrace_add_data(\"cov_rg\", fabsf(rg_cov));\ntrace_add_data(\"cov_rb\", fabsf(rb_cov));\ntrace_add_data(\"cov_ra\", fabsf(ra_cov));\n@@ -1300,9 +1300,9 @@ void compress_block(\nfloat lowest_correl;\nTRACE_NODE(node0, \"block\");\n- trace_add_data(\"pos_x\", blk->xpos);\n- trace_add_data(\"pos_y\", blk->ypos);\n- trace_add_data(\"pos_z\", blk->zpos);\n+ trace_add_data(\"pos_x\", blk.xpos);\n+ trace_add_data(\"pos_y\", blk.ypos);\n+ trace_add_data(\"pos_z\", blk.zpos);\n// Set stricter block targets for luminance data as we have more bits to play with\nbool block_is_l = blk.is_luminance();\n@@ -1325,14 +1325,14 @@ void compress_block(\n#if defined(ASTCENC_DIAGNOSTICS)\n// Do this early in diagnostic builds so we can dump uniform metrics\n// for every block. Do it later in release builds to avoid redundant work!\n- float error_weight_sum = prepare_error_weight_block(ctx, input_image, *bsd, *blk, *ewb);\n+ float error_weight_sum = prepare_error_weight_block(ctx, input_image, *bsd, blk, ewb);\nfloat error_threshold = ctx.config.tune_db_limit\n* error_weight_sum\n* block_is_l_scale\n* block_is_la_scale;\n- lowest_correl = prepare_block_statistics(bsd->texel_count, *blk, *ewb);\n-\n+ lowest_correl = prepare_block_statistics(bsd->texel_count, blk, ewb);\n+ trace_add_data(\"lowest_correl\", lowest_correl);\ntrace_add_data(\"tune_error_threshold\", error_threshold);\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix diagnostics builds
61,745
13.06.2021 21:49:39
-3,600
31191b196a54a6f597f1deb5fe22333d6502cd26
Add heuristic for culling two plane searches
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1432,8 +1432,9 @@ void compress_block(\nblock_skip_two_plane = lowest_correl > ctx.config.tune_2_plane_early_out_limit_correlation;\n- // Test the four possible 1-partition, 2-planes modes\n- for (unsigned int i = 0; i < BLOCK_MAX_COMPONENTS; i++)\n+ // Test the four possible 1-partition, 2-planes modes. Do this in reverse, as\n+ // alpha is the most likely to be non-correlated if it is present in the data.\n+ for (int i = BLOCK_MAX_COMPONENTS - 1; i >= 0; i--)\n{\nTRACE_NODE(node1, \"pass\");\ntrace_add_data(\"partition_count\", 1);\n@@ -1463,6 +1464,13 @@ void compress_block(\nerror_threshold * errorval_overshoot,\ni, scb, tmpbuf);\n+ // If attempting two planes is much worse than the best one plane result\n+ // then further two plane searches are unlikely to help so move on ...\n+ if (errorval > (best_errorvals_for_pcount[0] * 2.0f))\n+ {\n+ break;\n+ }\n+\nif (errorval < error_threshold)\n{\ntrace_add_data(\"exit\", \"quality hit\");\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add heuristic for culling two plane searches
61,745
14.06.2021 09:35:10
-3,600
f05c858051af37ea1a977568f43f312a421a042b
Front-load "always" list entries
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes.cpp", "new_path": "Source/astcenc_block_sizes.cpp", "diff": "@@ -852,6 +852,11 @@ static void construct_block_size_descriptor_2d(\n// Construct the list of block formats referencing the decimation tables\nunsigned int packed_idx = 0;\n+\n+ // Iterate twice; first time keep the \"always\" blocks, second time keep the \"non-always\" blocks.\n+ // This ensures that the always block modes and decimation modes are at the start of the list.\n+ for (unsigned int j = 0; j < 2; j ++)\n+ {\nfor (unsigned int i = 0; i < WEIGHTS_MAX_BLOCK_MODES; i++)\n{\nunsigned int x_weights, y_weights;\n@@ -860,15 +865,29 @@ static void construct_block_size_descriptor_2d(\n// TODO: Make this an enum? It's been validated.\nunsigned int quant_mode;\n- bool valid = decode_block_mode_2d(i, x_weights, y_weights, is_dual_plane, quant_mode);\n-\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\nfloat percentile = percentiles[i];\nbool selected = (percentile <= mode_cutoff) || !can_omit_modes;\n+\n+ if (j == 0 && percentile != 0.0f)\n+ {\n+ continue;\n+ }\n+\n+ if (j == 1 && percentile == 0.0f)\n+ {\n+ continue;\n+ }\n+\n#else\n// Decompressor builds can never discard modes, as we cannot make any\n// assumptions about the modes the original compressor used\nbool selected = true;\n+\n+ if (j == 1)\n+ {\n+ continue;\n+ }\n#endif\n// ASSUMPTION: No compressor will use more weights in a dimension than\n@@ -877,7 +896,8 @@ static void construct_block_size_descriptor_2d(\n// is technically permitted by the specification.\n// Skip modes that are invalid, too large, or not selected by heuristic\n- if (!valid || !selected || (x_weights > x_texels) || (y_weights > y_texels))\n+ bool valid = decode_block_mode_2d(i, x_weights, y_weights, is_dual_plane, quant_mode);\n+ if (!selected || !valid || (x_weights > x_texels) || (y_weights > y_texels))\n{\nbsd.block_mode_packed_index[i] = BLOCK_BAD_BLOCK_MODE;\ncontinue;\n@@ -922,6 +942,7 @@ static void construct_block_size_descriptor_2d(\nbsd.block_mode_packed_index[i] = packed_idx;\npacked_idx++;\n}\n+ }\nbsd.block_mode_count = packed_idx;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -267,7 +267,12 @@ static float compress_symbolic_block_for_partition_1plane(\nfor (unsigned int i = 0; i < bsd.decimation_mode_count; i++)\n{\nconst auto& dm = bsd.get_decimation_mode(i);\n- if (dm.maxprec_1plane < 0 || (only_always && !dm.percentile_always) || !dm.percentile_hit)\n+ if (only_always && !dm.percentile_always)\n+ {\n+ break;\n+ }\n+\n+ if (dm.maxprec_1plane < 0 || !dm.percentile_hit)\n{\ncontinue;\n}\n@@ -313,12 +318,21 @@ static float compress_symbolic_block_for_partition_1plane(\nint qwt_bitcounts[WEIGHTS_MAX_BLOCK_MODES];\nfloat qwt_errors[WEIGHTS_MAX_BLOCK_MODES];\n+ for (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n+ {\n+ qwt_errors[i] = 1e38f;\n+ }\n+\nfor (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n{\nconst block_mode& bm = bsd.block_modes[i];\n- if (bm.is_dual_plane || (only_always && !bm.percentile_always) || !bm.percentile_hit)\n+ if (only_always && !bm.percentile_always)\n+ {\n+ break;\n+ }\n+\n+ if (bm.is_dual_plane || !bm.percentile_hit)\n{\n- qwt_errors[i] = 1e38f;\ncontinue;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -526,7 +526,12 @@ void compute_angular_endpoints_1plane(\nfor (unsigned int i = 0; i < bsd.decimation_mode_count; i++)\n{\nconst decimation_mode& dm = bsd.decimation_modes[i];\n- if (dm.maxprec_1plane < 0 || (only_always && !dm.percentile_always) || !dm.percentile_hit)\n+ if (only_always && !dm.percentile_always)\n+ {\n+ break;\n+ }\n+\n+ if (dm.maxprec_1plane < 0 || !dm.percentile_hit)\n{\ncontinue;\n}\n@@ -555,7 +560,12 @@ void compute_angular_endpoints_1plane(\nfor (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n{\nconst block_mode& bm = bsd.block_modes[i];\n- if (bm.is_dual_plane || (only_always && !bm.percentile_always) || !bm.percentile_hit)\n+ if (only_always && !bm.percentile_always)\n+ {\n+ break;\n+ }\n+\n+ if (bm.is_dual_plane || !bm.percentile_hit)\n{\ncontinue;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Front-load "always" list entries
61,745
14.06.2021 09:55:31
-3,600
3772888db05a2ca2cde63771cba08b0db52dbcf0
Split config print from other operations
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -1079,9 +1079,20 @@ static int edit_astcenc_config(\n}\n#endif\n- if (operation & ASTCENC_STAGE_COMPRESS)\n- {\n- // print all encoding settings unless specifically told otherwise.\n+ return 0;\n+}\n+\n+/**\n+ * @brief Print the config settings in a human readable form.\n+ *\n+ * @param[in] cli_config Command line config.\n+ * @param[in] config Codec configuration.\n+ */\n+static void print_astcenc_config(\n+ const cli_config_options& cli_config,\n+ const astcenc_config& config\n+) {\n+ // Print all encoding settings unless specifically told otherwise\nif (!cli_config.silentmode)\n{\nprintf(\"Compressor settings\\n\");\n@@ -1148,9 +1159,6 @@ static int edit_astcenc_config(\n}\n}\n- return 0;\n-}\n-\n/**\n* @brief Get the value of a single pixel in an image.\n*\n@@ -1588,6 +1596,8 @@ int main(\n// Compress an image\nif (operation & ASTCENC_STAGE_COMPRESS)\n{\n+ print_astcenc_config(cli_config, config);\n+\nunsigned int blocks_x = (image_uncomp_in->dim_x + config.block_x - 1) / config.block_x;\nunsigned int blocks_y = (image_uncomp_in->dim_y + config.block_y - 1) / config.block_y;\nunsigned int blocks_z = (image_uncomp_in->dim_z + config.block_z - 1) / config.block_z;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Split config print from other operations
61,745
14.06.2021 09:58:22
-3,600
26d9c3cdd641603a2954712d82744b0c413036df
Fail early on unknown file type
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "@@ -2217,8 +2217,8 @@ static const struct\n{\".exr\", \".EXR\", 16, store_exr_image_with_tinyexr},\n{\".hdr\", \".HDR\", 16, store_hdr_image_with_stb},\n// Container formats\n- {\".dds\", \".DDS\", -1, store_dds_uncompressed_image},\n- {\".ktx\", \".KTX\", -1, store_ktx_uncompressed_image}\n+ {\".dds\", \".DDS\", 0, store_dds_uncompressed_image},\n+ {\".ktx\", \".KTX\", 0, store_ktx_uncompressed_image}\n};\nstatic const int storer_descr_count = sizeof(storer_descs) / sizeof(storer_descs[0]);\n@@ -2230,7 +2230,7 @@ int get_output_filename_enforced_bitness(\nconst char *eptr = strrchr(filename, '.');\nif (!eptr)\n{\n- return -1;\n+ return 0;\n}\nfor (int i = 0; i < storer_descr_count; i++)\n@@ -2242,8 +2242,7 @@ int get_output_filename_enforced_bitness(\n}\n}\n- printf(\"ERROR: Unknown file extension for output file: %s\\n\", eptr);\n- exit(1);\n+ return -1;\n}\n/* See header for documentation. */\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_internal.h", "new_path": "Source/astcenccli_internal.h", "diff": "@@ -126,7 +126,8 @@ bool store_ncimage(\n* @param filename The file name, containing hte extension to check.\n*\n* @return Valid values are:\n- * * -1 - no enforced bitness.\n+ * * -1 - error - unknown file type.\n+ * * 0 - no enforced bitness.\n* * 8 - enforced 8-bit UNORM.\n* * 16 - enforced 16-bit FP16.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -1476,6 +1476,7 @@ int main(\nelse\n{\nprintf(\"ERROR: Unknown compressed input file type\\n\");\n+ return 1;\n}\n}\n@@ -1507,6 +1508,32 @@ int main(\nastcenc_error codec_status;\nastcenc_context* codec_context;\n+\n+ // Preflight - check we have valid extensions for storing a file\n+ if (operation & ASTCENC_STAGE_ST_NCOMP)\n+ {\n+ int bitness = get_output_filename_enforced_bitness(output_filename.c_str());\n+ if (bitness == -1)\n+ {\n+ return 1;\n+ }\n+ }\n+\n+ if (operation & ASTCENC_STAGE_ST_COMP)\n+ {\n+#if defined(_WIN32)\n+ bool is_null = output_filename == \"NUL\" || output_filename == \"nul\";\n+#else\n+ bool is_null = output_filename == \"/dev/null\";\n+#endif\n+\n+ if (!(is_null || ends_with(output_filename, \".astc\") || ends_with(output_filename, \".ktx\")))\n+ {\n+ printf(\"ERROR: Unknown compressed output file type\\n\");\n+ return 1;\n+ }\n+ }\n+\ncodec_status = astcenc_context_alloc(&config, cli_config.thread_count, &codec_context);\nif (codec_status != ASTCENC_SUCCESS)\n{\n@@ -1645,7 +1672,7 @@ int main(\nif (operation & ASTCENC_STAGE_DECOMPRESS)\n{\nint out_bitness = get_output_filename_enforced_bitness(output_filename.c_str());\n- if (out_bitness == -1)\n+ if (out_bitness == 0)\n{\nbool is_hdr = (config.profile == ASTCENC_PRF_HDR) || (config.profile == ASTCENC_PRF_HDR_RGB_LDR_A);\n// TODO: Make this 32 to use direct passthrough as float\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fail early on unknown file type
61,745
14.06.2021 15:08:52
-3,600
850b0d6d2a5d253058b7819dfd1bea0915b9f487
Dont filter weights in realign_weights for 1:1 grids
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -86,7 +86,7 @@ static bool realign_weights(\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_level]);\n// Get the decimation table\n- const decimation_info& di = *(bsd.decimation_tables[bm.decimation_mode]);\n+ const decimation_info& di = bsd.get_decimation_info(bm.decimation_mode);\nunsigned int weight_count = di.weight_count;\nunsigned int max_plane = bm.is_dual_plane;\n@@ -163,11 +163,18 @@ static bool realign_weights(\nconst uint8_t *texel_weights = di.texel_weights_texel[we_idx][te_idx];\nconst float *texel_weights_float = di.texel_weights_float_texel[we_idx][te_idx];\nfloat twf0 = texel_weights_float[0];\n- float weight_base =\n- ((static_cast<float>(uqw) * twf0\n+\n+ float weight_base = static_cast<float>(uqw) * twf0;\n+\n+ // Don't interpolate filtered weights for a 1:1 weight grid\n+ if (weight_count != bsd.texel_count)\n+ {\n+ weight_base =\n+ (( weight_base\n+ static_cast<float>(uq_pl_weights[texel_weights[1]]) * texel_weights_float[1])\n+ (static_cast<float>(uq_pl_weights[texel_weights[2]]) * texel_weights_float[2]\n+ static_cast<float>(uq_pl_weights[texel_weights[3]]) * texel_weights_float[3]));\n+ }\nunsigned int partition = pi.partition_of_texel[texel];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Dont filter weights in realign_weights for 1:1 grids
61,745
14.06.2021 15:36:46
-3,600
01935907e60d8bedfca0835a6cb033e9f5915d72
Use initializer not assignment
[ { "change_type": "MODIFY", "old_path": "Source/Fuzzers/fuzz_astc_physical_to_symbolic.cpp", "new_path": "Source/Fuzzers/fuzz_astc_physical_to_symbolic.cpp", "diff": "#include <array>\n#include <vector>\n-struct BlockSizes {\n+struct BlockSizes\n+{\nint x;\nint y;\nint z;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "@@ -244,7 +244,8 @@ static const float ASTCENC_PRE_EXHAUSTIVE = 100.0f;\n/**\n* @brief A codec component swizzle selector.\n*/\n-enum astcenc_swz {\n+enum astcenc_swz\n+{\n/** @brief Select the red component. */\nASTCENC_SWZ_R = 0,\n/** @brief Select the green component. */\n@@ -264,7 +265,8 @@ enum astcenc_swz {\n/**\n* @brief A texel component swizzle.\n*/\n-struct astcenc_swizzle {\n+struct astcenc_swizzle\n+{\n/** @brief The red component selector. */\nastcenc_swz r;\n/** @brief The green component selector. */\n@@ -278,7 +280,8 @@ struct astcenc_swizzle {\n/**\n* @brief A texel component data format.\n*/\n-enum astcenc_type {\n+enum astcenc_type\n+{\n/** @brief Unorm 8-bit data per component. */\nASTCENC_TYPE_U8 = 0,\n/** @brief 16-bit float per component. */\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -1059,7 +1059,7 @@ static void quantize_hdr_rgbo(\nbreak;\n}\n- static const int mode_bits[5][3] = {\n+ static const int mode_bits[5][3] {\n{11, 5, 7},\n{11, 6, 5},\n{10, 5, 8},\n@@ -1067,7 +1067,7 @@ static void quantize_hdr_rgbo(\n{8, 7, 6}\n};\n- static const float mode_cutoffs[5][2] = {\n+ static const float mode_cutoffs[5][2] {\n{1024, 4096},\n{2048, 1024},\n{2048, 16384},\n@@ -1075,7 +1075,7 @@ static void quantize_hdr_rgbo(\n{32768, 16384}\n};\n- static const float mode_rscales[5] = {\n+ static const float mode_rscales[5] {\n32.0f,\n32.0f,\n64.0f,\n@@ -1083,7 +1083,7 @@ static void quantize_hdr_rgbo(\n256.0f,\n};\n- static const float mode_scales[5] = {\n+ static const float mode_scales[5] {\n1.0f / 32.0f,\n1.0f / 32.0f,\n1.0f / 64.0f,\n@@ -1398,7 +1398,7 @@ static void quantize_hdr_rgb(\nfloat d1_base = a_base - b1_base - c_base - color0.lane<2>();\n// Number of bits in the various fields in the various modes\n- static const int mode_bits[8][4] = {\n+ static const int mode_bits[8][4] {\n{9, 7, 6, 7},\n{9, 8, 6, 6},\n{10, 6, 7, 7},\n@@ -1411,7 +1411,7 @@ static void quantize_hdr_rgb(\n// Cutoffs to use for the computed values of a,b,c,d, assuming the\n// range 0..65535 are LNS values corresponding to fp16.\n- static const float mode_cutoffs[8][4] = {\n+ static const float mode_cutoffs[8][4] {\n{16384, 8192, 8192, 8}, // mode 0: 9,7,6,7\n{32768, 8192, 4096, 8}, // mode 1: 9,8,6,6\n{4096, 8192, 4096, 4}, // mode 2: 10,6,7,7\n@@ -1422,7 +1422,7 @@ static void quantize_hdr_rgb(\n{1024, 2048, 512, 1}, // mode 7: 12,6,7,6\n};\n- static const float mode_scales[8] = {\n+ static const float mode_scales[8] {\n1.0f / 128.0f,\n1.0f / 128.0f,\n1.0f / 64.0f,\n@@ -1434,7 +1434,7 @@ static void quantize_hdr_rgb(\n};\n// Scaling factors when going from what was encoded in the mode to 16 bits.\n- static const float mode_rscales[8] = {\n+ static const float mode_rscales[8] {\n128.0f,\n128.0f,\n64.0f,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -253,7 +253,7 @@ static float compress_symbolic_block_for_partition_1plane(\npromise(config.tune_refinement_limit > 0);\npromise(bsd.decimation_mode_count > 0);\n- static const int free_bits_for_partition_count[5] = {\n+ static const int free_bits_for_partition_count[5] {\n0, 115 - 4, 111 - 4 - PARTITION_INDEX_BITS, 108 - 4 - PARTITION_INDEX_BITS, 105 - 4 - PARTITION_INDEX_BITS\n};\n@@ -1419,7 +1419,7 @@ void compress_block(\n// optimization is disabled for 4x4 and 5x4 blocks where it nearly always slows down the\n// compression and slightly reduces image quality.\n- float errorval_mult[2] = {\n+ float errorval_mult[2] {\n1.0f / ctx.config.tune_mode0_mse_overshoot,\n1.0f\n};\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "* A 20% overshoot is harder to hit for a higher base db_limit, so we may actually use lower ratios\n* for the more through search presets because the underlying db_limit is so much higher.\n*/\n-struct astcenc_preset_config {\n+struct astcenc_preset_config\n+{\nfloat quality;\nunsigned int tune_partition_count_limit;\nunsigned int tune_partition_index_limit;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -86,7 +86,7 @@ static void kmeans_init(\n}\n// More numbers from random.org for weighted-random center selection\n- const float cluster_cutoffs[9] = {\n+ const float cluster_cutoffs[9] {\n0.626220f, 0.932770f, 0.275454f,\n0.318558f, 0.240113f, 0.009190f,\n0.347661f, 0.731960f, 0.156391f\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_integer_sequence.cpp", "new_path": "Source/astcenc_integer_sequence.cpp", "diff": "#include <array>\n/** @brief Unpacked quint triplets <low,middle,high> for each packed value */\n-static const uint8_t quints_of_integer[128][3] = {\n+static const uint8_t quints_of_integer[128][3] {\n{0, 0, 0}, {1, 0, 0}, {2, 0, 0}, {3, 0, 0},\n{4, 0, 0}, {0, 4, 0}, {4, 4, 0}, {4, 4, 4},\n{0, 1, 0}, {1, 1, 0}, {2, 1, 0}, {3, 1, 0},\n@@ -60,7 +60,7 @@ static const uint8_t quints_of_integer[128][3] = {\n};\n/** @brief Packed quint values for each unpacked value, indexed [hi][mid][lo]. */\n-static const uint8_t integer_of_quints[5][5][5] = {\n+static const uint8_t integer_of_quints[5][5][5] {\n{\n{0, 1, 2, 3, 4},\n{8, 9, 10, 11, 12},\n@@ -99,7 +99,7 @@ static const uint8_t integer_of_quints[5][5][5] = {\n};\n/** @brief Unpacked trit quintuplets <low,...,high> for each packed value */\n-static const uint8_t trits_of_integer[256][5] = {\n+static const uint8_t trits_of_integer[256][5] {\n{0, 0, 0, 0, 0}, {1, 0, 0, 0, 0}, {2, 0, 0, 0, 0}, {0, 0, 2, 0, 0},\n{0, 1, 0, 0, 0}, {1, 1, 0, 0, 0}, {2, 1, 0, 0, 0}, {1, 0, 2, 0, 0},\n{0, 2, 0, 0, 0}, {1, 2, 0, 0, 0}, {2, 2, 0, 0, 0}, {2, 0, 2, 0, 0},\n@@ -167,7 +167,7 @@ static const uint8_t trits_of_integer[256][5] = {\n};\n/** @brief Packed trit values for each unpacked value, indexed [hi][][][][lo]. */\n-static const uint8_t integer_of_trits[3][3][3][3][3] = {\n+static const uint8_t integer_of_trits[3][3][3][3][3] {\n{\n{\n{\n@@ -332,7 +332,8 @@ static const uint8_t integer_of_trits[3][3][3][3][3] = {\n/**\n* @brief The number of bits, trits, and quints needed for a quant level.\n*/\n-struct btq_count {\n+struct btq_count\n+{\n/** @brief The quantization level. */\nuint8_t quant;\n@@ -349,7 +350,7 @@ struct btq_count {\n/**\n* @brief The table of bits, trits, and quints needed for a quant encode.\n*/\n-static const std::array<btq_count, 21> btq_counts = {{\n+static const std::array<btq_count, 21> btq_counts {{\n{ QUANT_2, 1, 0, 0 },\n{ QUANT_3, 0, 1, 0 },\n{ QUANT_4, 2, 0, 0 },\n@@ -379,7 +380,8 @@ static const std::array<btq_count, 21> btq_counts = {{\n* The length of a quantized sequence in bits is:\n* (scale * <sequence_len> + round) / divisor\n*/\n-struct ise_size {\n+struct ise_size\n+{\n/** @brief The quantization level. */\nuint8_t quant;\n@@ -396,7 +398,7 @@ struct ise_size {\n/**\n* @brief The table of scale, round, and divisors needed for quant sizing.\n*/\n-static const std::array<ise_size, 21> ise_sizes = {{\n+static const std::array<ise_size, 21> ise_sizes {{\n{ QUANT_2, 1, 0, 1 },\n{ QUANT_3, 8, 4, 5 },\n{ QUANT_4, 2, 0, 1 },\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib_softfloat.cpp", "new_path": "Source/astcenc_mathlib_softfloat.cpp", "diff": "@@ -189,7 +189,7 @@ static sf32 sf16_to_sf32(sf16 inp)\nstatic sf16 sf32_to_sf16(sf32 inp, roundmode rmode)\n{\n/* for each possible sign/exponent combination, store a case index. This gives a 512-byte table */\n- static const uint8_t tab[512] = {\n+ static const uint8_t tab[512] {\n0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n@@ -227,7 +227,7 @@ static sf16 sf32_to_sf16(sf32 inp, roundmode rmode)\n/* many of the cases below use a case-dependent magic constant. So we look up a magic constant before actually performing the switch. This table allows us to group cases, thereby minimizing code\nsize. */\n- static const uint32_t tabx[60] = {\n+ static const uint32_t tabx[60] {\nUINT32_C(0), UINT32_C(0), UINT32_C(0), UINT32_C(0), UINT32_C(0), UINT32_C(0x8000), UINT32_C(0x80000000), UINT32_C(0x8000), UINT32_C(0x8000), UINT32_C(0x8000),\nUINT32_C(1), UINT32_C(0), UINT32_C(0), UINT32_C(0), UINT32_C(0), UINT32_C(0x8000), UINT32_C(0x8001), UINT32_C(0x8000), UINT32_C(0x8000), UINT32_C(0x8000),\nUINT32_C(0), UINT32_C(0), UINT32_C(0), UINT32_C(0), UINT32_C(0), UINT32_C(0x8000), UINT32_C(0x8000), UINT32_C(0x8000), UINT32_C(0x8000), UINT32_C(0x8000),\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_percentile_tables.cpp", "new_path": "Source/astcenc_percentile_tables.cpp", "diff": "@@ -45,7 +45,7 @@ struct packed_percentile_table\nconst uint16_t *items[2];\n};\n-static const uint16_t percentile_arr_4x4_0[61] = {\n+static const uint16_t percentile_arr_4x4_0[61] {\n0x0242,0x7243,0x6A51,0x6A52,0x5A41,0x4A53,0x8851,0x3842,\n0x3852,0x3853,0x3043,0xFA33,0x1BDF,0x2022,0x1032,0x29CE,\n0x21DE,0x2823,0x0813,0x0A13,0x0A31,0x0A23,0x09CF,0x0833,\n@@ -56,7 +56,7 @@ static const uint16_t percentile_arr_4x4_0[61] = {\n0x039E,0x033E,0x033F,0x038F,0x032F\n};\n-static const uint16_t percentile_arr_4x4_1[84] = {\n+static const uint16_t percentile_arr_4x4_1[84] {\n0x0452,0xFFAE,0x2433,0x1DDF,0x17CD,0x1E21,0x1C43,0x1442,\n0x3FBE,0x1FDD,0x0E31,0x0F4F,0x1423,0x0FBD,0x1451,0x0E03,\n0x05CF,0x0C32,0x0DDE,0x27AD,0x274E,0x0E02,0x0F5E,0x07AF,\n@@ -70,8 +70,7 @@ static const uint16_t percentile_arr_4x4_1[84] = {\n0x070F,0x071E,0x07BF,0x07CE\n};\n-static const packed_percentile_table block_pcd_4x4 =\n-{\n+static const packed_percentile_table block_pcd_4x4 {\n4, 4,\n{ 61, 84 },\n{ 184, 141 },\n@@ -79,7 +78,7 @@ static const packed_percentile_table block_pcd_4x4 =\n{ percentile_arr_4x4_0, percentile_arr_4x4_1 }\n};\n-static const uint16_t percentile_arr_5x4_0[91] = {\n+static const uint16_t percentile_arr_5x4_0[91] {\n0x02C1,0xFAD1,0xE8D3,0xDAC2,0xA8D2,0x70D1,0x50C2,0x80C3,\n0xD2C3,0x4AA2,0x2AD2,0x2242,0x2251,0x42A3,0x1A43,0x4A52,\n0x32B3,0x2A41,0x1042,0x1851,0x5892,0x10A2,0x2253,0x10B2,\n@@ -94,7 +93,7 @@ static const uint16_t percentile_arr_5x4_0[91] = {\n0x039F,0x032F,0x038F\n};\n-static const uint16_t percentile_arr_5x4_1[104] = {\n+static const uint16_t percentile_arr_5x4_1[104] {\n0x0433,0xB621,0x5452,0x4443,0x7FAE,0xFCA3,0x7CC2,0x24B2,\n0x45DF,0x44B3,0x7631,0x27CD,0x1CD1,0x1E03,0x4FBE,0x774F,\n0x1C42,0x7691,0x24A2,0x2681,0x3C23,0x3C93,0x0FBD,0x1C32,\n@@ -110,8 +109,7 @@ static const uint16_t percentile_arr_5x4_1[104] = {\n0x070E,0x079E,0x0622,0x0683,0x070F,0x071E,0x07BF,0x07CE\n};\n-static const packed_percentile_table block_pcd_5x4 =\n-{\n+static const packed_percentile_table block_pcd_5x4 {\n5, 4,\n{ 91, 104 },\n{ 322, 464 },\n@@ -119,7 +117,7 @@ static const packed_percentile_table block_pcd_5x4 =\n{ percentile_arr_5x4_0, percentile_arr_5x4_1 }\n};\n-static const uint16_t percentile_arr_5x5_0[129] = {\n+static const uint16_t percentile_arr_5x5_0[129] {\n0x00F3,0xF8F2,0x70E3,0x62E1,0x60E1,0x4AC1,0x3261,0x38D3,\n0x3271,0x5AF1,0x5873,0x2AD1,0x28E2,0x28F1,0x2262,0x9AC2,\n0x18D2,0x1072,0x1071,0x22A2,0x2062,0x1A51,0x10C2,0x0892,\n@@ -139,7 +137,7 @@ static const uint16_t percentile_arr_5x5_0[129] = {\n0x038F\n};\n-static const uint16_t percentile_arr_5x5_1[126] = {\n+static const uint16_t percentile_arr_5x5_1[126] {\n0x0443,0x6452,0xFE21,0x27AE,0x2433,0x1FCD,0x25DF,0x6CC2,\n0x2C62,0x1F4F,0x4C42,0x1FBE,0x0DEF,0x34A3,0x0E03,0x54B2,\n0x1F7D,0x17DD,0x0DFF,0x0CD1,0x0E31,0x0C71,0x1CF1,0x15FE,\n@@ -158,8 +156,7 @@ static const uint16_t percentile_arr_5x5_1[126] = {\n0x0622,0x0683,0x071E,0x076F,0x07BF,0x07CE\n};\n-static const packed_percentile_table block_pcd_5x5 =\n-{\n+static const packed_percentile_table block_pcd_5x5 {\n5, 5,\n{ 129, 126 },\n{ 258, 291 },\n@@ -167,7 +164,7 @@ static const packed_percentile_table block_pcd_5x5 =\n{ percentile_arr_5x5_0, percentile_arr_5x5_1 }\n};\n-static const uint16_t percentile_arr_6x5_0[165] = {\n+static const uint16_t percentile_arr_6x5_0[165] {\n0x0163,0xF8F3,0x9962,0x8972,0x7961,0x7173,0x6953,0x5943,\n0x4B41,0x3AE1,0x38E3,0x6971,0x32C1,0x28D3,0x2A61,0xC8F2,\n0x2271,0x4873,0x5B21,0x3AD1,0x1B13,0x1952,0x1B51,0x12F1,\n@@ -191,7 +188,7 @@ static const uint16_t percentile_arr_6x5_0[165] = {\n0x033E,0x035E,0x039E,0x032F,0x038F\n};\n-static const uint16_t percentile_arr_6x5_1[145] = {\n+static const uint16_t percentile_arr_6x5_1[145] {\n0x0443,0xEFAE,0x2CC2,0x2E21,0x2C52,0x7C33,0x47CD,0x25DF,\n0x3CA3,0xFFBE,0x2551,0x24B3,0x474F,0x1513,0x2691,0x1603,\n0x1462,0x1D32,0x14B2,0x5442,0x2CD2,0x35EF,0x0CD1,0x3D22,\n@@ -213,8 +210,7 @@ static const uint16_t percentile_arr_6x5_1[145] = {\n0x07CE\n};\n-static const packed_percentile_table block_pcd_6x5 =\n-{\n+static const packed_percentile_table block_pcd_6x5 {\n6, 5,\n{ 165, 145 },\n{ 388, 405 },\n@@ -222,7 +218,7 @@ static const packed_percentile_table block_pcd_6x5 =\n{ percentile_arr_6x5_0, percentile_arr_6x5_1 }\n};\n-static const uint16_t percentile_arr_6x6_0[206] = {\n+static const uint16_t percentile_arr_6x6_0[206] {\n0x006F,0xF908,0xF104,0xE918,0xE963,0xD114,0xB0F3,0xA07E,\n0x7972,0x705F,0x687F,0x6162,0x5953,0x586E,0x610C,0x524D,\n0x5973,0x9943,0x98E3,0x904F,0x8341,0x7AC1,0x3A61,0x70D3,\n@@ -251,7 +247,7 @@ static const uint16_t percentile_arr_6x6_0[206] = {\n0x035D,0x0212,0x033F,0x035E,0x038F,0x032F\n};\n-static const uint16_t percentile_arr_6x6_1[164] = {\n+static const uint16_t percentile_arr_6x6_1[164] {\n0x07AE,0x8443,0x7E21,0x77CD,0x6C62,0x9433,0x6452,0x34C2,\n0x5DDF,0xC7BE,0x25EF,0x24A3,0x3CF1,0xFDFF,0x177D,0x1F4F,\n0xC551,0x5CB3,0x1532,0x1513,0x143E,0x245D,0x14B2,0x2472,\n@@ -275,8 +271,7 @@ static const uint16_t percentile_arr_6x6_1[164] = {\n0x073E,0x076F,0x07BF,0x07CE\n};\n-static const packed_percentile_table block_pcd_6x6 =\n-{\n+static const packed_percentile_table block_pcd_6x6 {\n6, 6,\n{ 206, 164 },\n{ 769, 644 },\n@@ -284,7 +279,7 @@ static const packed_percentile_table block_pcd_6x6 =\n{ percentile_arr_6x6_0, percentile_arr_6x6_1 }\n};\n-static const uint16_t percentile_arr_8x5_0[226] = {\n+static const uint16_t percentile_arr_8x5_0[226] {\n0x0066,0xF865,0xE963,0xA856,0xA1F2,0x9875,0x91C3,0x91E2,\n0x80F3,0x8076,0x61E3,0x6153,0x5172,0x59D2,0x51D3,0x5047,\n0xA943,0x49B3,0x4846,0x4962,0xC037,0x4173,0x39F1,0x7027,\n@@ -316,7 +311,7 @@ static const uint16_t percentile_arr_8x5_0[226] = {\n0x038F,0x039E\n};\n-static const uint16_t percentile_arr_8x5_1[167] = {\n+static const uint16_t percentile_arr_8x5_1[167] {\n0x0621,0xFCC2,0x3443,0xA433,0x5532,0x2551,0x6CA3,0x27AE,\n0x6452,0x8E03,0x3CB3,0x4DA2,0x6DDF,0x37CD,0x6F01,0x1691,\n0x2E82,0x27BE,0x1513,0x34D2,0x1D22,0x3E31,0x2593,0x2CB2,\n@@ -340,8 +335,7 @@ static const uint16_t percentile_arr_8x5_1[167] = {\n0x0683,0x0702,0x073E,0x076F,0x079E,0x07BF,0x07CE\n};\n-static const packed_percentile_table block_pcd_8x5 =\n-{\n+static const packed_percentile_table block_pcd_8x5 {\n8, 5,\n{ 226, 167 },\n{ 763, 517 },\n@@ -349,7 +343,7 @@ static const packed_percentile_table block_pcd_8x5 =\n{ percentile_arr_8x5_0, percentile_arr_8x5_1 }\n};\n-static const uint16_t percentile_arr_8x6_0[273] = {\n+static const uint16_t percentile_arr_8x6_0[273] {\n0x0154,0xF944,0xE066,0xA128,0x9963,0x8118,0x806F,0x79F2,\n0x79E2,0x7108,0xD934,0x6056,0x69C3,0x60F3,0x5972,0x59E3,\n0x5075,0x91B3,0xC9D2,0x807E,0x385F,0x4153,0x3943,0x4162,\n@@ -387,7 +381,7 @@ static const uint16_t percentile_arr_8x6_0[273] = {\n0x039E\n};\n-static const uint16_t percentile_arr_8x6_1[186] = {\n+static const uint16_t percentile_arr_8x6_1[186] {\n0x0621,0xFC33,0x37AE,0x1CC2,0x2C43,0xAD32,0x34A3,0x4551,\n0x6452,0x5C62,0x1FCD,0x14F1,0x4CB3,0x24D2,0x15DF,0x0FBE,\n0x2603,0x3DA2,0x2E31,0x25D1,0x25EF,0x0D22,0x2E91,0x1E82,\n@@ -414,8 +408,7 @@ static const uint16_t percentile_arr_8x6_1[186] = {\n0x07BF,0x07CE\n};\n-static const packed_percentile_table block_pcd_8x6 =\n-{\n+static const packed_percentile_table block_pcd_8x6 {\n8, 6,\n{ 273, 186 },\n{ 880, 300 },\n@@ -423,7 +416,7 @@ static const packed_percentile_table block_pcd_8x6 =\n{ percentile_arr_8x6_0, percentile_arr_8x6_1 }\n};\n-static const uint16_t percentile_arr_8x8_0[347] = {\n+static const uint16_t percentile_arr_8x8_0[347] {\n0x0334,0xFD44,0xDD14,0x9154,0x9B08,0x906A,0x8928,0x8108,\n0xE866,0xC918,0x606F,0xC0FE,0x5963,0x58EE,0x6534,0x505A,\n0x51E2,0xA8CF,0x5354,0x5314,0x5134,0x5524,0x48F3,0x504B,\n@@ -470,7 +463,7 @@ static const uint16_t percentile_arr_8x8_0[347] = {\n0x033E,0x038F,0x039E\n};\n-static const uint16_t percentile_arr_8x8_1[208] = {\n+static const uint16_t percentile_arr_8x8_1[208] {\n0x0621,0x3443,0x47CD,0x97AE,0xFC62,0x14F1,0x24C2,0x25DF,\n0x3C33,0x1C52,0x9C72,0x0FBE,0x0C5D,0x343E,0x24A3,0x1551,\n0x5D32,0x1CD2,0x15EF,0x4E31,0x04DD,0x1FDD,0x174F,0x0DD1,\n@@ -499,8 +492,7 @@ static const uint16_t percentile_arr_8x8_1[208] = {\n0x068D,0x0702,0x073E,0x076F,0x0781,0x079E,0x07BF,0x07CE\n};\n-static const packed_percentile_table block_pcd_8x8 =\n-{\n+static const packed_percentile_table block_pcd_8x8 {\n8, 8,\n{ 347, 208 },\n{ 1144, 267 },\n@@ -508,7 +500,7 @@ static const packed_percentile_table block_pcd_8x8 =\n{ percentile_arr_8x8_0, percentile_arr_8x8_1 }\n};\n-static const uint16_t percentile_arr_10x5_0[274] = {\n+static const uint16_t percentile_arr_10x5_0[274] {\n0x0165,0xF975,0xD866,0xC056,0xA946,0x90C6,0x90F5,0x8963,\n0x80D6,0x80E6,0x60F3,0x61C3,0x59F2,0xA927,0x5075,0x4847,\n0x5153,0x4955,0x49E2,0x48B6,0x41D2,0x4943,0x8305,0x8172,\n@@ -546,7 +538,7 @@ static const uint16_t percentile_arr_10x5_0[274] = {\n0x033E,0x038F\n};\n-static const uint16_t percentile_arr_10x5_1[180] = {\n+static const uint16_t percentile_arr_10x5_1[180] {\n0x0532,0xFCA3,0x3621,0x6E82,0x2CC2,0x3D51,0x3F01,0x2691,\n0x17AE,0x35A2,0x74B3,0x1603,0x4433,0x3C43,0x6C35,0x25D1,\n0x1D13,0x15DF,0x37CD,0x0D93,0x1D22,0x0E81,0x1452,0x0CD2,\n@@ -572,8 +564,7 @@ static const uint16_t percentile_arr_10x5_1[180] = {\n0x073E,0x076F,0x07BF,0x07CE\n};\n-static const packed_percentile_table block_pcd_10x5 =\n-{\n+static const packed_percentile_table block_pcd_10x5 {\n10, 5,\n{ 274, 180 },\n{ 954, 324 },\n@@ -581,7 +572,7 @@ static const packed_percentile_table block_pcd_10x5 =\n{ percentile_arr_10x5_0, percentile_arr_10x5_1 }\n};\n-static const uint16_t percentile_arr_10x6_0[325] = {\n+static const uint16_t percentile_arr_10x6_0[325] {\n0x01A4,0xF954,0xA066,0x9975,0x80F5,0x7056,0x6918,0x6963,\n0x58C6,0x5946,0x5928,0x5174,0x586F,0xA0E6,0x5108,0x48D6,\n0x49E2,0x40F3,0x9172,0x41F2,0xB875,0x3927,0x39C3,0xA953,\n@@ -625,7 +616,7 @@ static const uint16_t percentile_arr_10x6_0[325] = {\n0x035E,0x033F,0x039E,0x032F,0x038F\n};\n-static const uint16_t percentile_arr_10x6_1[199] = {\n+static const uint16_t percentile_arr_10x6_1[199] {\n0x0621,0xBD32,0x5CA3,0x1FAE,0x64C2,0x1D51,0x6C33,0xFC43,\n0x5CB3,0x25A2,0x2E82,0x35D1,0x4F01,0x3FBE,0x3691,0x2DDF,\n0x2E03,0x3FCD,0x14D2,0x1CF1,0x0C52,0x3C35,0x2D22,0x1513,\n@@ -653,8 +644,7 @@ static const uint16_t percentile_arr_10x6_1[199] = {\n0x0683,0x0702,0x070D,0x071E,0x076F,0x07BF,0x07CE\n};\n-static const packed_percentile_table block_pcd_10x6 =\n-{\n+static const packed_percentile_table block_pcd_10x6 {\n10, 6,\n{ 325, 199 },\n{ 922, 381 },\n@@ -662,7 +652,7 @@ static const packed_percentile_table block_pcd_10x6 =\n{ percentile_arr_10x6_0, percentile_arr_10x6_1 }\n};\n-static const uint16_t percentile_arr_10x8_0[400] = {\n+static const uint16_t percentile_arr_10x8_0[400] {\n0x0154,0xAB34,0xAD44,0x8308,0x7866,0x7B64,0x79A4,0x7975,\n0x686A,0x6908,0xC514,0x6174,0x6128,0x6118,0x5B54,0x5163,\n0xF856,0x50F5,0x986F,0xDD34,0x48FE,0x4972,0x48E6,0x4146,\n@@ -715,7 +705,7 @@ static const uint16_t percentile_arr_10x8_0[400] = {\n0x034D,0x034E,0x036D,0x032F,0x033E,0x037D,0x038F,0x039E\n};\n-static const uint16_t percentile_arr_10x8_1[221] = {\n+static const uint16_t percentile_arr_10x8_1[221] {\n0x0621,0xDFAE,0x2443,0x54C2,0x37CD,0x1CF1,0xFCA3,0x14D2,\n0x2D32,0x5551,0x7DDF,0x5C33,0x15D1,0x3462,0x24B3,0x7452,\n0x5FBE,0x6472,0x65A2,0x1D06,0x445D,0x15EF,0x0E31,0x1D71,\n@@ -755,7 +745,7 @@ static const packed_percentile_table block_pcd_10x8 =\n{ percentile_arr_10x8_0, percentile_arr_10x8_1 }\n};\n-static const uint16_t percentile_arr_10x10_0[453] = {\n+static const uint16_t percentile_arr_10x10_0[453] {\n0x0334,0x9514,0x8954,0x806A,0x6F14,0x6724,0x6108,0x6364,\n0x5175,0x5D44,0x5866,0x5118,0x5308,0xA179,0x5128,0xF534,\n0x49A4,0x5354,0x9174,0x486F,0x48EA,0x40F3,0x4963,0x414A,\n@@ -815,7 +805,7 @@ static const uint16_t percentile_arr_10x10_0[453] = {\n0x032F,0x033E,0x035D,0x038F,0x039F\n};\n-static const uint16_t percentile_arr_10x10_1[234] = {\n+static const uint16_t percentile_arr_10x10_1[234] {\n0x07CD,0x6E21,0x24F1,0x8443,0xD7AE,0x24C2,0x1C62,0xCCA3,\n0x1C33,0xFDEF,0x2532,0x55DF,0x1472,0x6C3E,0x14D2,0x34DD,\n0x1452,0x745D,0x4D51,0x8DD1,0x247D,0x75FF,0x0CB3,0x17BE,\n@@ -848,8 +838,7 @@ static const uint16_t percentile_arr_10x10_1[234] = {\n0x07BF,0x07CE\n};\n-static const packed_percentile_table block_pcd_10x10 =\n-{\n+static const packed_percentile_table block_pcd_10x10 {\n10, 10,\n{ 453, 234 },\n{ 1095, 472 },\n@@ -857,7 +846,7 @@ static const packed_percentile_table block_pcd_10x10 =\n{ percentile_arr_10x10_0, percentile_arr_10x10_1 }\n};\n-static const uint16_t percentile_arr_12x10_0[491] = {\n+static const uint16_t percentile_arr_12x10_0[491] {\n0x0334,0x9954,0x8514,0x7128,0x6364,0xC174,0x5D34,0x5866,\n0x5975,0x5354,0xAF14,0x506A,0x5108,0x5724,0x5308,0x4544,\n0x4918,0x4064,0x49E2,0x4179,0x8163,0x4054,0xF81C,0x394A,\n@@ -922,7 +911,7 @@ static const uint16_t percentile_arr_12x10_0[491] = {\n0x035D,0x038F,0x039E\n};\n-static const uint16_t percentile_arr_12x10_1[240] = {\n+static const uint16_t percentile_arr_12x10_1[240] {\n0x0621,0xA443,0xFCC2,0x3CA3,0x1D32,0x14F1,0x7462,0x1433,\n0x27CD,0x2571,0x57AE,0x5DD1,0x64B3,0x44D2,0x2C72,0x25A2,\n0x1E31,0x55DF,0x4C52,0x1DEF,0x0D51,0x3C5D,0x3C3E,0x74DD,\n@@ -964,7 +953,7 @@ static const packed_percentile_table block_pcd_12x10 =\n{ percentile_arr_12x10_0, percentile_arr_12x10_1 }\n};\n-static const uint16_t percentile_arr_12x12_0[529] = {\n+static const uint16_t percentile_arr_12x12_0[529] {\n0x0334,0xF534,0x8514,0x8954,0x7F14,0xFB54,0x7B08,0x7128,\n0x7974,0x6179,0x6B64,0x6908,0x606A,0x6724,0xB544,0xB066,\n0xA14A,0x5118,0x9975,0x51F9,0x981C,0x49CA,0x4854,0x886F,\n@@ -1034,7 +1023,7 @@ static const uint16_t percentile_arr_12x12_0[529] = {\n0x039E\n};\n-static const uint16_t percentile_arr_12x12_1[246] = {\n+static const uint16_t percentile_arr_12x12_1[246] {\n0x0443,0xFFCD,0x2C62,0x2E21,0x3CF1,0x34C2,0x4CDD,0x2452,\n0xD5DF,0x1DD1,0x0FAE,0x64A3,0x0C7D,0x3433,0x1CD2,0x2DEF,\n0x0C3E,0x1D71,0xA472,0x0D32,0x54B3,0x4D51,0x445D,0x0E31,\n@@ -1068,8 +1057,7 @@ static const uint16_t percentile_arr_12x12_1[246] = {\n0x072F,0x076F,0x078D,0x078E,0x07BF,0x07CE\n};\n-static const packed_percentile_table block_pcd_12x12 =\n-{\n+static const packed_percentile_table block_pcd_12x12 {\n12, 12,\n{ 529, 246 },\n{ 1435, 335 },\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -322,7 +322,7 @@ static void compute_color_error_for_every_integer_count_and_quant_level(\n) {\nint partition_size = pi.partition_texel_count[partition_index];\n- static const float baseline_quant_error[21] = {\n+ static const float baseline_quant_error[21] {\n(65536.0f * 65536.0f / 18.0f), // 2 values, 1 step\n(65536.0f * 65536.0f / 18.0f) / (2 * 2), // 3 values, 2 steps\n(65536.0f * 65536.0f / 18.0f) / (3 * 3), // 4 values, 3 steps\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_quantization.cpp", "new_path": "Source/astcenc_quantization.cpp", "diff": "#if !defined(ASTCENC_DECOMPRESS_ONLY)\n-const uint8_t color_quant_tables[21][256] = {\n+const uint8_t color_quant_tables[21][256] {\n{\n0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n@@ -406,7 +406,7 @@ const uint8_t color_quant_tables[21][256] = {\n#endif\n-const uint8_t color_unquant_tables[21][256] = {\n+const uint8_t color_unquant_tables[21][256] {\n{\n0, 255\n},\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -85,7 +85,7 @@ struct vfloat4\n*/\nASTCENC_SIMD_INLINE explicit vfloat4(float a, float b, float c, float d)\n{\n- float v[4] = { a, b, c, d };\n+ float v[4] { a, b, c, d };\nm = vld1q_f32(v);\n}\n@@ -230,7 +230,7 @@ struct vint4\n*/\nASTCENC_SIMD_INLINE explicit vint4(int a, int b, int c, int d)\n{\n- int v[4] = { a, b, c, d };\n+ int v[4] { a, b, c, d };\nm = vld1q_s32(v);\n}\n@@ -339,7 +339,7 @@ struct vmask4\n*/\nASTCENC_SIMD_INLINE explicit vmask4(bool a, bool b, bool c, bool d)\n{\n- int v[4] = {\n+ int v[4] {\na == true ? -1 : 0,\nb == true ? -1 : 0,\nc == true ? -1 : 0,\n@@ -399,7 +399,7 @@ ASTCENC_SIMD_INLINE vmask4 operator~(vmask4 a)\n*/\nASTCENC_SIMD_INLINE unsigned int mask(vmask4 a)\n{\n- static const int shifta[4] = { 0, 1, 2, 3 };\n+ static const int shifta[4] { 0, 1, 2, 3 };\nstatic const int32x4_t shift = vld1q_s32(shifta);\nuint32x4_t tmp = vshrq_n_u32(a.m, 31);\n@@ -609,7 +609,7 @@ ASTCENC_SIMD_INLINE vint4 gatheri(const int* base, vint4 indices)\n*/\nASTCENC_SIMD_INLINE vint4 pack_low_bytes(vint4 a)\n{\n- alignas(16) uint8_t shuf[16] = {\n+ alignas(16) uint8_t shuf[16] {\n0, 4, 8, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n};\nuint8x16_t idx = vld1q_u8(shuf);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -58,7 +58,7 @@ static unsigned int max_angular_steps_needed_for_quant_level[13];\n// The next-to-last entry is supposed to have the value 33. This because the 32-weight mode leaves a\n// double-sized hole in the middle of the weight space, so we are better off matching 33 weights.\n-static const unsigned int quantization_steps_for_level[13] = {\n+static const unsigned int quantization_steps_for_level[13] {\n2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 33, 36\n};\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_quant_xfer_tables.cpp", "new_path": "Source/astcenc_weight_quant_xfer_tables.cpp", "diff": "#define _ 0 // Using _ to indicate an entry that will not be used.\n-const quantization_and_transfer_table quant_and_xfer_tables[12] = {\n+const quantization_and_transfer_table quant_and_xfer_tables[12] {\n// Quantization method 0, range 0..1\n{\nQUANT_2,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "@@ -681,7 +681,8 @@ static uint32_t u32_byterev(uint32_t v)\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9\n-struct format_entry {\n+struct format_entry\n+{\nunsigned int x;\nunsigned int y;\nunsigned int z;\n@@ -793,7 +794,7 @@ struct ktx_header\n};\n// magic 12-byte sequence that must appear at the beginning of every KTX file.\n-static uint8_t ktx_magic[12] = {\n+static uint8_t ktx_magic[12] {\n0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A\n};\n@@ -1736,7 +1737,7 @@ static astcenc_image* load_dds_uncompressed_image(\nuint32_t dxgi_format_number;\n};\n- static const dxgi_params format_params[] = {\n+ static const dxgi_params format_params[] {\n{16, 4, 4, RGBA32F_TO_RGBA16F, DXGI_FORMAT_R32G32B32A32_FLOAT},\n{16, 4, 3, RGB32F_TO_RGBA16F, DXGI_FORMAT_R32G32B32_FLOAT},\n{16, 2, 4, RGBA16F_TO_RGBA16F, DXGI_FORMAT_R16G16B16A16_FLOAT},\n@@ -2183,11 +2184,12 @@ static bool store_dds_uncompressed_image(\n/**\n* @brief Supported uncompressed image load functions, and their associated file extensions.\n*/\n-static const struct {\n+static const struct\n+{\nconst char* ending1;\nconst char* ending2;\nastcenc_image* (*loader_func)(const char*, bool, bool&, unsigned int&);\n-} loader_descs[] = {\n+} loader_descs[] {\n// HDR formats\n{\".exr\", \".EXR\", load_image_with_tinyexr },\n// Container formats\n@@ -2208,7 +2210,7 @@ static const struct\nconst char *ending2;\nint enforced_bitness;\nbool (*storer_func)(const astcenc_image *output_image, const char *filename, int y_flip);\n-} storer_descs[] = {\n+} storer_descs[] {\n// LDR formats\n{\".bmp\", \".BMP\", 8, store_bmp_image_with_stb},\n{\".png\", \".PNG\", 8, store_png_image_with_stb},\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "typedef unsigned int astcenc_operation;\n-struct mode_entry {\n+struct mode_entry\n+{\nconst char* opt;\nastcenc_operation operation;\nastcenc_profile decode_mode;\n@@ -108,7 +109,7 @@ enum astcenc_preprocess\n};\n/** @brief Decode table for command line operation modes. */\n-static const mode_entry modes[] = {\n+static const mode_entry modes[] {\n{\"-cl\", ASTCENC_OP_COMPRESS, ASTCENC_PRF_LDR},\n{\"-dl\", ASTCENC_OP_DECOMPRESS, ASTCENC_PRF_LDR},\n{\"-tl\", ASTCENC_OP_TEST, ASTCENC_PRF_LDR},\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use initializer not assignment
61,745
14.06.2021 15:59:07
-3,600
e594584b0b5be8ea7e8471352aca425f57b659a4
Keep compute_lowest_and_highest_weight core as float
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -180,8 +180,8 @@ static void compute_lowest_and_highest_weight(\n// Arrays are ANGULAR_STEPS long, so always safe to run full vectors\nfor (unsigned int sp = 0; sp < max_angular_steps; sp += ASTCENC_SIMD_WIDTH)\n{\n- vint minidx(128);\n- vint maxidx(-128);\n+ vfloat minidx(128.0f);\n+ vfloat maxidx(-128.0f);\nvfloat errval = vfloat::zero();\nvfloat cut_low_weight_err = vfloat::zero();\nvfloat cut_high_weight_err = vfloat::zero();\n@@ -192,37 +192,37 @@ static void compute_lowest_and_highest_weight(\nvfloat wt = load1(&dec_weight_quant_sig[j]);\nvfloat sval = load1(&dec_weight_quant_uvalue[j]) * rcp_stepsize - offset;\nvfloat svalrte = round(sval);\n- vint idxv = float_to_int(svalrte);\nvfloat dif = sval - svalrte;\nvfloat dwt = dif * wt;\nerrval += dwt * dif;\n// Reset tracker on min hit\n- vmask mask = idxv < minidx;\n- minidx = select(minidx, idxv, mask);\n+ vmask mask = svalrte < minidx;\n+ minidx = select(minidx, svalrte, mask);\ncut_low_weight_err = select(cut_low_weight_err, vfloat::zero(), mask);\n// Accumulate on min hit\n- mask = idxv == minidx;\n+ mask = svalrte == minidx;\nvfloat accum = cut_low_weight_err + wt - vfloat(2.0f) * dwt;\ncut_low_weight_err = select(cut_low_weight_err, accum, mask);\n// Reset tracker on max hit\n- mask = idxv > maxidx;\n- maxidx = select(maxidx, idxv, mask);\n+ mask = svalrte > maxidx;\n+ maxidx = select(maxidx, svalrte, mask);\ncut_high_weight_err = select(cut_high_weight_err, vfloat::zero(), mask);\n// Accumulate on max hit\n- mask = idxv == maxidx;\n+ mask = svalrte == maxidx;\naccum = cut_high_weight_err + wt + vfloat(2.0f) * dwt;\ncut_high_weight_err = select(cut_high_weight_err, accum, mask);\n}\n// Write out min weight and weight span; clamp span to a usable range\n- vint span = maxidx - minidx + vint(1);\n+ // TODO: Can we keeps these as floats?\n+ vint span = float_to_int(maxidx - minidx + vfloat(1));\nspan = min(span, vint(max_quant_steps + 3));\nspan = max(span, vint(2));\n- storea(minidx, &lowest_weight[sp]);\n+ storea(float_to_int(minidx), &lowest_weight[sp]);\nstorea(span, &weight_span[sp]);\n// The cut_(lowest/highest)_weight_error indicate the error that results from forcing\n@@ -382,8 +382,8 @@ static void compute_lowest_and_highest_weight_lwc(\n// Arrays are ANGULAR_STEPS long, so always safe to run full vectors\nfor (unsigned int sp = 0; sp < max_angular_steps; sp += ASTCENC_SIMD_WIDTH)\n{\n- vint minidx(128);\n- vint maxidx(-128);\n+ vfloat minidx(128.0f);\n+ vfloat maxidx(-128.0f);\nvfloat errval = vfloat::zero();\nvfloat offset = loada(&offsets[sp]);\n@@ -392,25 +392,25 @@ static void compute_lowest_and_highest_weight_lwc(\nvfloat wt = load1(&dec_weight_quant_sig[j]);\nvfloat sval = load1(&dec_weight_quant_uvalue[j]) * rcp_stepsize - offset;\nvfloat svalrte = round(sval);\n- vint idxv = float_to_int(svalrte);\nvfloat dif = sval - svalrte;\nvfloat dwt = dif * wt;\nerrval += dwt * dif;\n// Reset tracker on min hit\n- vmask mask = idxv < minidx;\n- minidx = select(minidx, idxv, mask);\n+ vmask mask = svalrte < minidx;\n+ minidx = select(minidx, svalrte, mask);\n// Reset tracker on max hit\n- mask = idxv > maxidx;\n- maxidx = select(maxidx, idxv, mask);\n+ mask = svalrte > maxidx;\n+ maxidx = select(maxidx, svalrte, mask);\n}\n// Write out min weight and weight span; clamp span to a usable range\n- vint span = maxidx - minidx + vint(1);\n+ // TODO: Can we keeps these as floats?\n+ vint span = float_to_int(maxidx - minidx + vfloat(1.0f));\nspan = min(span, vint(max_quant_steps + 3));\nspan = max(span, vint(2));\n- storea(minidx, &lowest_weight[sp]);\n+ storea(float_to_int(minidx), &lowest_weight[sp]);\nstorea(span, &weight_span[sp]);\n// The cut_(lowest/highest)_weight_error indicate the error that results from forcing\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Keep compute_lowest_and_highest_weight core as float
61,745
14.06.2021 18:31:42
-3,600
3713e22aba9d8fc65adf5cc6e35f6d5bf52f1c77
Remove TODO comment - not possible
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -218,7 +218,6 @@ static void compute_lowest_and_highest_weight(\n}\n// Write out min weight and weight span; clamp span to a usable range\n- // TODO: Can we keeps these as floats?\nvint span = float_to_int(maxidx - minidx + vfloat(1));\nspan = min(span, vint(max_quant_steps + 3));\nspan = max(span, vint(2));\n@@ -406,7 +405,6 @@ static void compute_lowest_and_highest_weight_lwc(\n}\n// Write out min weight and weight span; clamp span to a usable range\n- // TODO: Can we keeps these as floats?\nvint span = float_to_int(maxidx - minidx + vfloat(1.0f));\nspan = min(span, vint(max_quant_steps + 3));\nspan = max(span, vint(2));\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove TODO comment - not possible
61,745
14.06.2021 18:58:08
-3,600
26d8dee5cd60e01dba38dd833a8739746fc49eda
Style - use consistent pattern
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -1149,7 +1149,6 @@ unsigned int compute_ideal_endpoint_formats(\n// The block contains 1 partition\nif (partition_count == 1)\n{\n- float error_of_best_combination;\nfor (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n{\nif (qwt_errors[i] >= ERROR_CALC_DEFAULT)\n@@ -1158,12 +1157,12 @@ unsigned int compute_ideal_endpoint_formats(\ncontinue;\n}\n+ float error_of_best_combination;\none_partition_find_best_combination_for_bitcount(\nbest_error[0], format_of_choice[0], qwt_bitcounts[i],\nbest_quant_levels[i], best_ep_formats[i][0], error_of_best_combination);\n- error_of_best_combination += qwt_errors[i];\n- errors_of_best_combination[i] = error_of_best_combination;\n+ errors_of_best_combination[i] = error_of_best_combination + qwt_errors[i];\nbest_quant_levels_mod[i] = best_quant_levels[i];\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Style - use consistent pattern
61,745
14.06.2021 18:59:43
-3,600
46e5216461691be521c6b4031d70b9ddf4d0e80f
Use implicit tail
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -1220,8 +1220,9 @@ unsigned int compute_ideal_endpoint_formats(\n}\n}\n// The block contains 4 partitions\n- else if (partition_count == 4)\n+ else // if (partition_count == 4)\n{\n+ assert(partition_count == 4);\nfloat combined_best_error[21][13];\nint formats_of_choice[21][13][4];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use implicit tail
61,745
15.06.2021 18:35:27
-3,600
43dea0a94f1b8f61f460aff1f061c683fc32349a
Trade some performance for quality boosts
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -62,13 +62,13 @@ struct astcenc_preset_config\nstatic const std::array<astcenc_preset_config, 5> preset_configs_high {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 25\n+ 3, 4, 30, 1, 2, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 25\n}, {\nASTCENC_PRE_FAST,\n- 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f, 20\n+ 3, 12, 55, 3, 3, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f, 20\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 2, 2, 95.0f, 70.0f, 2.5f, 2.5f, 1.2f, 1.25f, 0.75f, 16\n+ 4, 26, 76, 3, 3 , 95.0f, 70.0f, 2.5f, 2.5f, 1.2f, 1.25f, 0.75f, 16\n}, {\nASTCENC_PRE_THOROUGH,\n4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f, 12\n@@ -86,13 +86,13 @@ static const std::array<astcenc_preset_config, 5> preset_configs_high {{\nstatic const std::array<astcenc_preset_config, 5> preset_configs_mid {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 20\n+ 3, 4, 30, 1, 2, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 20\n}, {\nASTCENC_PRE_FAST,\n- 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f, 16\n+ 3, 12, 55, 3, 3, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f, 16\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 2, 2, 95.0f, 70.0f, 3.0f, 3.0f, 1.2f, 1.25f, 0.75f, 14\n+ 4, 26, 76, 3, 3, 95.0f, 70.0f, 3.0f, 3.0f, 1.2f, 1.25f, 0.75f, 14\n}, {\nASTCENC_PRE_THOROUGH,\n4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f, 10\n@@ -110,13 +110,13 @@ static const std::array<astcenc_preset_config, 5> preset_configs_mid {{\nstatic const std::array<astcenc_preset_config, 5> preset_configs_low {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 20\n+ 3, 4, 30, 1, 2, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 20\n}, {\nASTCENC_PRE_FAST,\n- 3, 10, 53, 3, 2, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f, 16\n+ 3, 10, 53, 3, 3, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f, 16\n}, {\nASTCENC_PRE_MEDIUM,\n- 3, 26, 76, 3, 2, 95.0f, 70.0f, 3.5f, 3.5f, 1.2f, 1.25f, 0.75f, 12\n+ 3, 26, 76, 3, 3, 95.0f, 70.0f, 3.5f, 3.5f, 1.2f, 1.25f, 0.75f, 12\n}, {\nASTCENC_PRE_THOROUGH,\n4, 75, 92, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f, 10\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Trade some performance for quality boosts
61,745
17.06.2021 14:46:10
-3,600
d6ef9010cf66a2cab621ee0dbaf399467774b7ae
Fix /W2 warnings on VS2019
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -44,10 +44,10 @@ void compute_avgs_and_dirs_4_comp(\nvfloat4 rgba_max(-1e38f);\nfloat partition_weight = 0.0f;\n- int texel_count = pi.partition_texel_count[partition];\n+ unsigned int texel_count = pi.partition_texel_count[partition];\npromise(texel_count > 0);\n- for (int i = 0; i < texel_count; i++)\n+ for (unsigned int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\nfloat weight = ewb.texel_weight[iwt];\n@@ -65,7 +65,7 @@ void compute_avgs_and_dirs_4_comp(\nerror_sum += error_weight;\n}\n- error_sum = error_sum / texel_count;\n+ error_sum = error_sum / static_cast<float>(texel_count);\nvfloat4 csf = normalize(sqrt(error_sum)) * 2.0f;\nvfloat4 average = base_sum * (1.0f / astc::max(partition_weight, 1e-7f));\n@@ -82,9 +82,9 @@ void compute_avgs_and_dirs_4_comp(\nvfloat4 sum_zp = vfloat4::zero();\nvfloat4 sum_wp = vfloat4::zero();\n- for (int i = 0; i < texel_count; i++)\n+ for (unsigned int i = 0; i < texel_count; i++)\n{\n- int iwt = weights[i];\n+ unsigned int iwt = weights[i];\nfloat weight = ewb.texel_weight[iwt];\nvfloat4 texel_datum = blk.texel(iwt);\ntexel_datum = (texel_datum - average) * weight;\n@@ -182,10 +182,10 @@ void compute_avgs_and_dirs_3_comp(\nerror_vb = ewb.texel_weight_a;\n}\n- int partition_count = pi.partition_count;\n+ unsigned int partition_count = pi.partition_count;\npromise(partition_count > 0);\n- for (int partition = 0; partition < partition_count; partition++)\n+ for (unsigned int partition = 0; partition < partition_count; partition++)\n{\nconst uint8_t *weights = pi.texels_of_partition[partition];\n@@ -195,12 +195,12 @@ void compute_avgs_and_dirs_3_comp(\nvfloat4 rgb_max(-1e38f);\nfloat partition_weight = 0.0f;\n- int texel_count = pi.partition_texel_count[partition];\n+ unsigned int texel_count = pi.partition_texel_count[partition];\npromise(texel_count > 0);\n- for (int i = 0; i < texel_count; i++)\n+ for (unsigned int i = 0; i < texel_count; i++)\n{\n- int iwt = weights[i];\n+ unsigned int iwt = weights[i];\nfloat weight = texel_weights[iwt];\nvfloat4 texel_datum(data_vr[iwt],\n@@ -224,7 +224,7 @@ void compute_avgs_and_dirs_3_comp(\nerror_sum += error_weight;\n}\n- error_sum = error_sum / texel_count;\n+ error_sum = error_sum / static_cast<float>(texel_count);\nvfloat4 csf = normalize(sqrt(error_sum)) * 1.73205080f;\nvfloat4 average = base_sum * (1.0f / astc::max(partition_weight, 1e-7f));\n@@ -240,9 +240,9 @@ void compute_avgs_and_dirs_3_comp(\nvfloat4 sum_yp = vfloat4::zero();\nvfloat4 sum_zp = vfloat4::zero();\n- for (int i = 0; i < texel_count; i++)\n+ for (unsigned int i = 0; i < texel_count; i++)\n{\n- int iwt = weights[i];\n+ unsigned int iwt = weights[i];\nfloat weight = texel_weights[iwt];\nvfloat4 texel_datum = vfloat3(data_vr[iwt],\ndata_vg[iwt],\n@@ -360,7 +360,7 @@ void compute_avgs_and_dirs_2_comp(\nerror_sum += error_weight;\n}\n- error_sum = error_sum / texel_count;\n+ error_sum = error_sum / static_cast<float>(texel_count);\nvfloat4 csf = normalize(sqrt(error_sum)) * 1.41421356f;\nvfloat4 average = base_sum * (1.0f / astc::max(partition_weight, 1e-7f));\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1146,8 +1146,8 @@ static float prepare_error_weight_block(\n}\n// Small bias to avoid divide by zeros and NaN propagation later\n- vfloat4 texel_weight_sum(1e-17);\n- vfloat4 error_weight_sum(1e-17);\n+ vfloat4 texel_weight_sum(1e-17f);\n+ vfloat4 error_weight_sum(1e-17f);\nint texels_per_block = bsd.texel_count;\nfor (int i = 0; i < texels_per_block; i++)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -64,10 +64,10 @@ static vfloat4 load_texel_f16(\nint base_offset\n) {\nconst uint16_t* data16 = static_cast<const uint16_t*>(data);\n- int r = static_cast<float>(data16[base_offset ]);\n- int g = static_cast<float>(data16[base_offset + 1]);\n- int b = static_cast<float>(data16[base_offset + 2]);\n- int a = static_cast<float>(data16[base_offset + 3]);\n+ int r = data16[base_offset ];\n+ int g = data16[base_offset + 1];\n+ int b = data16[base_offset + 2];\n+ int a = data16[base_offset + 3];\nreturn float16_to_float(vint4(r, g, b, a));\n}\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_functional.py", "new_path": "Test/astc_test_functional.py", "diff": "@@ -1209,12 +1209,12 @@ class CLIPTest(CLITestBase):\nself.exec(command)\nrefRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n- command += [\"-3partitionlimitfactor\", \"0.5\"]\n+ command += [\"-3partitionlimitfactor\", \"1.0\"]\nself.exec(command)\ntestRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n# RMSE should get worse (higher) if we reduce search space\n- self.assertGreater(testRMSE, refRMSE)\n+ self.assertNotEqual(testRMSE, refRMSE)\ndef test_2plane_correlation_limit(self):\n\"\"\"\n@@ -1365,7 +1365,7 @@ class CLIPTest(CLITestBase):\ntestCommand = command + params\nself.exec(testCommand)\ntestRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n- self.assertGreater(testRMSE, refRMSE)\n+ self.assertNotEqual(testRMSE, refRMSE)\nresultSet.add(testRMSE)\n# Test that each mutation was \"differently\" worse; i.e. some new\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix /W2 warnings on VS2019
61,745
17.06.2021 15:55:20
-3,600
3845da54f6211c55f7e68d5b88b466051bf58141
Fix /W4 warnings on VS2019
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes.cpp", "new_path": "Source/astcenc_block_sizes.cpp", "diff": "@@ -311,11 +311,11 @@ static void init_decimation_info_2d(\n{\nif (weight[i] != 0)\n{\n- grid_weights_of_texel[texel][weight_count_of_texel[texel]] = qweight[i];\n- weights_of_texel[texel][weight_count_of_texel[texel]] = weight[i];\n+ grid_weights_of_texel[texel][weight_count_of_texel[texel]] = static_cast<uint8_t>(qweight[i]);\n+ weights_of_texel[texel][weight_count_of_texel[texel]] = static_cast<uint8_t>(weight[i]);\nweight_count_of_texel[texel]++;\n- texels_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = texel;\n- texel_weights_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = weight[i];\n+ texels_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = static_cast<uint8_t>(texel);\n+ texel_weights_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = static_cast<uint8_t>(weight[i]);\ntexel_count_of_weight[qweight[i]]++;\nmax_texel_count_of_weight = astc::max(max_texel_count_of_weight, texel_count_of_weight[qweight[i]]);\n}\n@@ -424,10 +424,10 @@ static void init_decimation_info_2d(\n}\n}\n- di.texel_count = texels_per_block;\n- di.weight_count = weights_per_block;\n- di.weight_x = x_weights;\n- di.weight_y = y_weights;\n+ di.texel_count = static_cast<uint8_t>(texels_per_block);\n+ di.weight_count = static_cast<uint8_t>(weights_per_block);\n+ di.weight_x = static_cast<uint8_t>(x_weights);\n+ di.weight_y = static_cast<uint8_t>(y_weights);\ndi.weight_z = 1;\n}\n@@ -580,11 +580,11 @@ static void init_decimation_info_3d(\n{\nif (weight[i] != 0)\n{\n- grid_weights_of_texel[texel][weight_count_of_texel[texel]] = qweight[i];\n- weights_of_texel[texel][weight_count_of_texel[texel]] = weight[i];\n+ grid_weights_of_texel[texel][weight_count_of_texel[texel]] = static_cast<uint8_t>(qweight[i]);\n+ weights_of_texel[texel][weight_count_of_texel[texel]] = static_cast<uint8_t>(weight[i]);\nweight_count_of_texel[texel]++;\n- texels_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = texel;\n- texel_weights_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = weight[i];\n+ texels_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = static_cast<uint8_t>(texel);\n+ texel_weights_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = static_cast<uint8_t>(weight[i]);\ntexel_count_of_weight[qweight[i]]++;\nmax_texel_count_of_weight = astc::max(max_texel_count_of_weight, texel_count_of_weight[qweight[i]]);\n}\n@@ -623,8 +623,8 @@ static void init_decimation_info_3d(\nunsigned int texel = texels_of_weight[i][j];\n// Create transposed versions of these for better vectorization\n- di.weight_texel[j][i] = texel;\n- di.weights_flt[j][i] = (float)texel_weights_of_weight[i][j];\n+ di.weight_texel[j][i] = static_cast<uint8_t>(texel);\n+ di.weights_flt[j][i] = static_cast<float>(texel_weights_of_weight[i][j]);\n// perform a layer of array unrolling. An aspect of this unrolling is that\n// one of the texel-weight indexes is an identity-mapped index; we will use this\n@@ -694,11 +694,11 @@ static void init_decimation_info_3d(\n}\n}\n- di.texel_count = texels_per_block;\n- di.weight_count = weights_per_block;\n- di.weight_x = x_weights;\n- di.weight_y = y_weights;\n- di.weight_z = z_weights;\n+ di.texel_count = static_cast<uint8_t>(texels_per_block);\n+ di.weight_count = static_cast<uint8_t>(weights_per_block);\n+ di.weight_x = static_cast<uint8_t>(x_weights);\n+ di.weight_y = static_cast<uint8_t>(y_weights);\n+ di.weight_z = static_cast<uint8_t>(z_weights);\n}\n/**\n@@ -715,7 +715,7 @@ static void assign_kmeans_texels(\n// Use all texels for kmeans on a small block\nif (bsd.texel_count <= BLOCK_MAX_KMEANS_TEXELS)\n{\n- for (unsigned int i = 0; i < bsd.texel_count; i++)\n+ for (uint8_t i = 0; i < bsd.texel_count; i++)\n{\nbsd.kmeans_texels[i] = i;\n}\n@@ -729,7 +729,7 @@ static void assign_kmeans_texels(\n// Initialize array used for tracking used indices\nbool seen[BLOCK_MAX_TEXELS];\n- for (unsigned int i = 0; i < bsd.texel_count; i++)\n+ for (uint8_t i = 0; i < bsd.texel_count; i++)\n{\nseen[i] = false;\n}\n@@ -738,7 +738,7 @@ static void assign_kmeans_texels(\nunsigned int arr_elements_set = 0;\nwhile (arr_elements_set < BLOCK_MAX_KMEANS_TEXELS)\n{\n- unsigned int texel = (unsigned int)astc::rand(rng_state);\n+ uint8_t texel = static_cast<uint8_t>(astc::rand(rng_state));\ntexel = texel % bsd.texel_count;\nif (!seen[texel])\n{\n@@ -796,8 +796,8 @@ static int construct_dt_entry_2d(\n// At least one of the two should be valid ...\nassert(maxprec_1plane >= 0 || maxprec_2planes >= 0);\n- bsd.decimation_modes[dm_index].maxprec_1plane = maxprec_1plane;\n- bsd.decimation_modes[dm_index].maxprec_2planes = maxprec_2planes;\n+ bsd.decimation_modes[dm_index].maxprec_1plane = static_cast<int8_t>(maxprec_1plane);\n+ bsd.decimation_modes[dm_index].maxprec_2planes = static_cast<int8_t>(maxprec_2planes);\n// Default to not enabled - we'll populate these based on active block modes\nbsd.decimation_modes[dm_index].percentile_hit = false;\n@@ -830,10 +830,10 @@ static void construct_block_size_descriptor_2d(\nstatic const unsigned int MAX_DMI = 12 * 16 + 12;\nint decimation_mode_index[MAX_DMI];\n- bsd.xdim = x_texels;\n- bsd.ydim = y_texels;\n+ bsd.xdim = static_cast<uint8_t>(x_texels);\n+ bsd.ydim = static_cast<uint8_t>(y_texels);\nbsd.zdim = 1;\n- bsd.texel_count = x_texels * y_texels;\n+ bsd.texel_count = static_cast<uint8_t>(x_texels * y_texels);\nbsd.decimation_mode_count = 0;\nfor (unsigned int i = 0; i < MAX_DMI; i++)\n@@ -935,11 +935,11 @@ static void construct_block_size_descriptor_2d(\n}\n#endif\n- bsd.block_modes[packed_idx].decimation_mode = decimation_mode;\n- bsd.block_modes[packed_idx].quant_mode = quant_mode;\n- bsd.block_modes[packed_idx].is_dual_plane = is_dual_plane;\n- bsd.block_modes[packed_idx].mode_index = i;\n- bsd.block_mode_packed_index[i] = packed_idx;\n+ bsd.block_modes[packed_idx].decimation_mode = static_cast<uint8_t>(decimation_mode);\n+ bsd.block_modes[packed_idx].quant_mode = static_cast<uint8_t>(quant_mode);\n+ bsd.block_modes[packed_idx].is_dual_plane = static_cast<uint8_t>(is_dual_plane);\n+ bsd.block_modes[packed_idx].mode_index = static_cast<uint16_t>(i);\n+ bsd.block_mode_packed_index[i] = static_cast<uint16_t>(packed_idx);\npacked_idx++;\n}\n}\n@@ -987,10 +987,10 @@ static void construct_block_size_descriptor_3d(\nint decimation_mode_index[MAX_DMI];\nunsigned int decimation_mode_count = 0;\n- bsd.xdim = x_texels;\n- bsd.ydim = y_texels;\n- bsd.zdim = z_texels;\n- bsd.texel_count = x_texels * y_texels * z_texels;\n+ bsd.xdim = static_cast<uint8_t>(x_texels);\n+ bsd.ydim = static_cast<uint8_t>(y_texels);\n+ bsd.zdim = static_cast<uint8_t>(z_texels);\n+ bsd.texel_count = static_cast<uint8_t>(x_texels * y_texels * z_texels);\nfor (unsigned int i = 0; i < MAX_DMI; i++)\n{\n@@ -1036,8 +1036,8 @@ static void construct_block_size_descriptor_3d(\nmaxprec_2planes = -1;\n}\n- bsd.decimation_modes[decimation_mode_count].maxprec_1plane = maxprec_1plane;\n- bsd.decimation_modes[decimation_mode_count].maxprec_2planes = maxprec_2planes;\n+ bsd.decimation_modes[decimation_mode_count].maxprec_1plane = static_cast<int8_t>(maxprec_1plane);\n+ bsd.decimation_modes[decimation_mode_count].maxprec_2planes = static_cast<int8_t>(maxprec_2planes);\nbsd.decimation_modes[decimation_mode_count].percentile_hit = false;\nbsd.decimation_modes[decimation_mode_count].percentile_always = false;\nbsd.decimation_tables[decimation_mode_count] = di;\n@@ -1086,10 +1086,10 @@ static void construct_block_size_descriptor_3d(\n}\nint decimation_mode = decimation_mode_index[z_weights * 64 + y_weights * 8 + x_weights];\n- bsd.block_modes[packed_idx].decimation_mode = decimation_mode;\n- bsd.block_modes[packed_idx].quant_mode = quant_mode;\n- bsd.block_modes[packed_idx].is_dual_plane = is_dual_plane;\n- bsd.block_modes[packed_idx].mode_index = i;\n+ bsd.block_modes[packed_idx].decimation_mode = static_cast<uint8_t>(decimation_mode);\n+ bsd.block_modes[packed_idx].quant_mode = static_cast<uint8_t>(quant_mode);\n+ bsd.block_modes[packed_idx].is_dual_plane = static_cast<uint8_t>(is_dual_plane);\n+ bsd.block_modes[packed_idx].mode_index = static_cast<uint16_t>(i);\n// No percentile table, so enable everything all the time ...\nbsd.block_modes[packed_idx].percentile_hit = true;\n@@ -1097,7 +1097,8 @@ static void construct_block_size_descriptor_3d(\nbsd.decimation_modes[decimation_mode].percentile_hit = true;\nbsd.decimation_modes[decimation_mode].percentile_always = true;\n- bsd.block_mode_packed_index[i] = packed_idx;\n+ bsd.block_mode_packed_index[i] = static_cast<uint16_t>(packed_idx);\n+\npacked_idx++;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -112,12 +112,12 @@ static void quantize_rgb(\niters++;\n} while (ri0b + gi0b + bi0b > ri1b + gi1b + bi1b);\n- output[0] = ri0;\n- output[1] = ri1;\n- output[2] = gi0;\n- output[3] = gi1;\n- output[4] = bi0;\n- output[5] = bi1;\n+ output[0] = static_cast<uint8_t>(ri0);\n+ output[1] = static_cast<uint8_t>(ri1);\n+ output[2] = static_cast<uint8_t>(gi0);\n+ output[3] = static_cast<uint8_t>(gi1);\n+ output[4] = static_cast<uint8_t>(bi0);\n+ output[5] = static_cast<uint8_t>(bi1);\n}\n/**\n@@ -144,11 +144,8 @@ static void quantize_rgba(\nfloat a0 = astc::clamp255f(color0.lane<3>() * scale);\nfloat a1 = astc::clamp255f(color1.lane<3>() * scale);\n- int ai0 = color_quant_tables[quant_level][astc::flt2int_rtn(a0)];\n- int ai1 = color_quant_tables[quant_level][astc::flt2int_rtn(a1)];\n-\n- output[6] = ai0;\n- output[7] = ai1;\n+ output[6] = color_quant_tables[quant_level][astc::flt2int_rtn(a0)];\n+ output[7] = color_quant_tables[quant_level][astc::flt2int_rtn(a1)];\nquantize_rgb(color0, color1, output, quant_level);\n}\n@@ -218,12 +215,12 @@ static bool try_quantize_rgb_blue_contract(\nreturn false;\n}\n- output[0] = ri1;\n- output[1] = ri0;\n- output[2] = gi1;\n- output[3] = gi0;\n- output[4] = bi1;\n- output[5] = bi0;\n+ output[0] = static_cast<uint8_t>(ri1);\n+ output[1] = static_cast<uint8_t>(ri0);\n+ output[2] = static_cast<uint8_t>(gi1);\n+ output[3] = static_cast<uint8_t>(gi0);\n+ output[4] = static_cast<uint8_t>(bi1);\n+ output[5] = static_cast<uint8_t>(bi0);\nreturn true;\n}\n@@ -391,12 +388,12 @@ static bool try_quantize_rgb_delta(\nreturn false;\n}\n- output[0] = r0be;\n- output[1] = r1de;\n- output[2] = g0be;\n- output[3] = g1de;\n- output[4] = b0be;\n- output[5] = b1de;\n+ output[0] = static_cast<uint8_t>(r0be);\n+ output[1] = static_cast<uint8_t>(r1de);\n+ output[2] = static_cast<uint8_t>(g0be);\n+ output[3] = static_cast<uint8_t>(g1de);\n+ output[4] = static_cast<uint8_t>(b0be);\n+ output[5] = static_cast<uint8_t>(b1de);\nreturn true;\n}\n@@ -536,12 +533,12 @@ static bool try_quantize_rgb_delta_blue_contract(\nreturn false;\n}\n- output[0] = r0be;\n- output[1] = r1de;\n- output[2] = g0be;\n- output[3] = g1de;\n- output[4] = b0be;\n- output[5] = b1de;\n+ output[0] = static_cast<uint8_t>(r0be);\n+ output[1] = static_cast<uint8_t>(r1de);\n+ output[2] = static_cast<uint8_t>(g0be);\n+ output[3] = static_cast<uint8_t>(g1de);\n+ output[4] = static_cast<uint8_t>(b0be);\n+ output[5] = static_cast<uint8_t>(b1de);\nreturn true;\n}\n@@ -582,30 +579,37 @@ static bool try_quantize_alpha_delta(\nint a1d = astc::flt2int_rtn(a1);\na1d <<= 1;\na1d -= a0b;\n+\nif (a1d > 63 || a1d < -64)\n{\nreturn false;\n}\n+\na1d &= 0x7F;\na1d |= (a0b & 0x100) >> 1;\n+\nint a1de = color_quant_tables[quant_level][a1d];\nint a1du = color_unquant_tables[quant_level][a1de];\nif ((a1d ^ a1du) & 0xC0)\n{\nreturn false;\n}\n+\na1du &= 0x7F;\nif (a1du & 0x40)\n{\na1du -= 0x80;\n}\n+\na1du += a0b;\nif (a1du < 0 || a1du > 0x1FF)\n{\nreturn false;\n}\n- output[6] = a0be;\n- output[7] = a1de;\n+\n+ output[6] = static_cast<uint8_t>(a0be);\n+ output[7] = static_cast<uint8_t>(a1de);\n+\nreturn true;\n}\n@@ -643,6 +647,7 @@ static bool try_quantize_luminance_alpha_delta(\nint a0a = astc::flt2int_rtn(a0);\nl0a <<= 1;\na0a <<= 1;\n+\nint l0b = l0a & 0xFF;\nint a0b = a0a & 0xFF;\nint l0be = color_quant_tables[quant_level][l0b];\n@@ -651,20 +656,24 @@ static bool try_quantize_luminance_alpha_delta(\na0b = color_unquant_tables[quant_level][a0be];\nl0b |= l0a & 0x100;\na0b |= a0a & 0x100;\n+\nint l1d = astc::flt2int_rtn(l1);\nint a1d = astc::flt2int_rtn(a1);\nl1d <<= 1;\na1d <<= 1;\nl1d -= l0b;\na1d -= a0b;\n+\nif (l1d > 63 || l1d < -64)\n{\nreturn false;\n}\n+\nif (a1d > 63 || a1d < -64)\n{\nreturn false;\n}\n+\nl1d &= 0x7F;\na1d &= 0x7F;\nl1d |= (l0b & 0x100) >> 1;\n@@ -674,38 +683,47 @@ static bool try_quantize_luminance_alpha_delta(\nint a1de = color_quant_tables[quant_level][a1d];\nint l1du = color_unquant_tables[quant_level][l1de];\nint a1du = color_unquant_tables[quant_level][a1de];\n+\nif ((l1d ^ l1du) & 0xC0)\n{\nreturn false;\n}\n+\nif ((a1d ^ a1du) & 0xC0)\n{\nreturn false;\n}\n+\nl1du &= 0x7F;\na1du &= 0x7F;\n+\nif (l1du & 0x40)\n{\nl1du -= 0x80;\n}\n+\nif (a1du & 0x40)\n{\na1du -= 0x80;\n}\n+\nl1du += l0b;\na1du += a0b;\n+\nif (l1du < 0 || l1du > 0x1FF)\n{\nreturn false;\n}\n+\nif (a1du < 0 || a1du > 0x1FF)\n{\nreturn false;\n}\n- output[0] = l0be;\n- output[1] = l1de;\n- output[2] = a0be;\n- output[3] = a1de;\n+\n+ output[0] = static_cast<uint8_t>(l0be);\n+ output[1] = static_cast<uint8_t>(l1de);\n+ output[2] = static_cast<uint8_t>(a0be);\n+ output[3] = static_cast<uint8_t>(a1de);\nreturn true;\n}\n@@ -797,9 +815,9 @@ static void quantize_rgbs(\nint scale_idx = astc::flt2int_rtn(scalea * 256.0f);\nscale_idx = astc::clamp(scale_idx, 0, 255);\n- output[0] = ri;\n- output[1] = gi;\n- output[2] = bi;\n+ output[0] = static_cast<uint8_t>(ri);\n+ output[1] = static_cast<uint8_t>(gi);\n+ output[2] = static_cast<uint8_t>(bi);\noutput[3] = color_quant_tables[quant_level][scale_idx];\n}\n@@ -822,11 +840,8 @@ static void quantize_rgbs_alpha(\nfloat a0 = astc::clamp255f(color0.lane<3>() * scale);\nfloat a1 = astc::clamp255f(color1.lane<3>() * scale);\n- int ai0 = color_quant_tables[quant_level][astc::flt2int_rtn(a0)];\n- int ai1 = color_quant_tables[quant_level][astc::flt2int_rtn(a1)];\n-\n- output[4] = ai0;\n- output[5] = ai1;\n+ output[4] = color_quant_tables[quant_level][astc::flt2int_rtn(a0)];\n+ output[5] = color_quant_tables[quant_level][astc::flt2int_rtn(a1)];\nquantize_rgbs(color, output, quant_level);\n}\n@@ -904,6 +919,7 @@ static void quantize_luminance_alpha(\nlum0 += 0.5f;\nlum1 -= 0.5f;\n}\n+\nlum0 = astc::clamp255f(lum0);\nlum1 = astc::clamp255f(lum1);\n}\n@@ -920,6 +936,7 @@ static void quantize_luminance_alpha(\na0 += 0.5f;\na1 -= 0.5f;\n}\n+\na0 = astc::clamp255f(a0);\na1 = astc::clamp255f(a1);\n}\n@@ -1038,13 +1055,20 @@ static void quantize_hdr_rgbo(\ncolor = clamp(0.0f, 65535.0f, color);\nvfloat4 color_bak = color;\n+\nint majcomp;\nif (color.lane<0>() > color.lane<1>() && color.lane<0>() > color.lane<2>())\n+ {\nmajcomp = 0; // red is largest component\n+ }\nelse if (color.lane<1>() > color.lane<2>())\n+ {\nmajcomp = 1; // green is largest component\n+ }\nelse\n+ {\nmajcomp = 2; // blue is largest component\n+ }\n// swap around the red component and the largest component.\nswitch (majcomp)\n@@ -1121,7 +1145,8 @@ static void quantize_hdr_rgbo(\nuint8_t r_quantval;\nuint8_t r_uquantval;\n- quantize_and_unquantize_retain_top_two_bits(quant_level, r_lowbits, r_quantval, r_uquantval);\n+ quantize_and_unquantize_retain_top_two_bits(\n+ quant_level, static_cast<uint8_t>(r_lowbits), r_quantval, r_uquantval);\nr_intval = (r_intval & ~0x3f) | (r_uquantval & 0x3f);\nfloat r_fval = static_cast<float>(r_intval) * mode_rscale;\n@@ -1222,8 +1247,10 @@ static void quantize_hdr_rgbo(\nuint8_t g_uquantval;\nuint8_t b_uquantval;\n- quantize_and_unquantize_retain_top_four_bits(quant_level, g_lowbits, g_quantval, g_uquantval);\n- quantize_and_unquantize_retain_top_four_bits(quant_level, b_lowbits, b_quantval, b_uquantval);\n+ quantize_and_unquantize_retain_top_four_bits(\n+ quant_level, static_cast<uint8_t>(g_lowbits), g_quantval, g_uquantval);\n+ quantize_and_unquantize_retain_top_four_bits(\n+ quant_level, static_cast<uint8_t>(b_lowbits), b_quantval, b_uquantval);\ng_intval = (g_intval & ~0x1f) | (g_uquantval & 0x1f);\nb_intval = (b_intval & ~0x1f) | (b_uquantval & 0x1f);\n@@ -1292,7 +1319,9 @@ static void quantize_hdr_rgbo(\nuint8_t s_quantval;\nuint8_t s_uquantval;\n- quantize_and_unquantize_retain_top_four_bits(quant_level, s_lowbits, s_quantval, s_uquantval);\n+ quantize_and_unquantize_retain_top_four_bits(\n+ quant_level, static_cast<uint8_t>(s_lowbits), s_quantval, s_uquantval);\n+\noutput[0] = r_quantval;\noutput[1] = g_quantval;\noutput[2] = b_quantval;\n@@ -1332,7 +1361,8 @@ static void quantize_hdr_rgbo(\nfor (uint8_t i = 0; i < 4; i++)\n{\nuint8_t dummy;\n- quantize_and_unquantize_retain_top_four_bits(quant_level, encvals[i], output[i], dummy);\n+ quantize_and_unquantize_retain_top_four_bits(\n+ quant_level, static_cast<uint8_t>(encvals[i]), output[i], dummy);\n}\nreturn;\n@@ -1494,7 +1524,10 @@ static void quantize_hdr_rgb(\nuint8_t c_quantval;\nuint8_t c_uquantval;\n- quantize_and_unquantize_retain_top_two_bits(quant_level, c_lowbits, c_quantval, c_uquantval);\n+\n+ quantize_and_unquantize_retain_top_two_bits(\n+ quant_level, static_cast<uint8_t>(c_lowbits), c_quantval, c_uquantval);\n+\nc_intval = (c_intval & ~0x3F) | (c_uquantval & 0x3F);\nc_fval = static_cast<float>(c_intval) * mode_rscale;\n@@ -1562,8 +1595,10 @@ static void quantize_hdr_rgb(\nuint8_t b0_uquantval;\nuint8_t b1_uquantval;\n- quantize_and_unquantize_retain_top_two_bits(quant_level, b0_lowbits, b0_quantval, b0_uquantval);\n- quantize_and_unquantize_retain_top_two_bits(quant_level, b1_lowbits, b1_quantval, b1_uquantval);\n+ quantize_and_unquantize_retain_top_two_bits(\n+ quant_level, static_cast<uint8_t>(b0_lowbits), b0_quantval, b0_uquantval);\n+ quantize_and_unquantize_retain_top_two_bits(\n+ quant_level, static_cast<uint8_t>(b1_lowbits), b1_quantval, b1_uquantval);\nb0_intval = (b0_intval & ~0x3f) | (b0_uquantval & 0x3f);\nb1_intval = (b1_intval & ~0x3f) | (b1_uquantval & 0x3f);\n@@ -1657,10 +1692,12 @@ static void quantize_hdr_rgb(\nuint8_t d0_uquantval;\nuint8_t d1_uquantval;\n- quantize_and_unquantize_retain_top_four_bits(quant_level, d0_lowbits, d0_quantval, d0_uquantval);\n- quantize_and_unquantize_retain_top_four_bits(quant_level, d1_lowbits, d1_quantval, d1_uquantval);\n+ quantize_and_unquantize_retain_top_four_bits(\n+ quant_level, static_cast<uint8_t>(d0_lowbits), d0_quantval, d0_uquantval);\n+ quantize_and_unquantize_retain_top_four_bits(\n+ quant_level, static_cast<uint8_t>(d1_lowbits), d1_quantval, d1_uquantval);\n- output[0] = a_quantval;\n+ output[0] = static_cast<uint8_t>(a_quantval);\noutput[1] = c_quantval;\noutput[2] = b0_quantval;\noutput[3] = b1_quantval;\n@@ -1696,7 +1733,8 @@ static void quantize_hdr_rgb(\n{\nuint8_t dummy;\nint idx = astc::flt2int_rtn(vals[i] * 1.0f / 512.0f) + 128;\n- quantize_and_unquantize_retain_top_two_bits(quant_level, idx, output[i], dummy);\n+ quantize_and_unquantize_retain_top_two_bits(\n+ quant_level, static_cast<uint8_t>(idx), output[i], dummy);\n}\nreturn;\n@@ -1721,11 +1759,8 @@ static void quantize_hdr_rgb_ldr_alpha(\nfloat a0 = astc::clamp255f(color0.lane<3>() * scale);\nfloat a1 = astc::clamp255f(color1.lane<3>() * scale);\n- int ai0 = color_quant_tables[quant_level][astc::flt2int_rtn(a0)];\n- int ai1 = color_quant_tables[quant_level][astc::flt2int_rtn(a1)];\n-\n- output[6] = ai0;\n- output[7] = ai1;\n+ output[6] = color_quant_tables[quant_level][astc::flt2int_rtn(a0)];\n+ output[7] = color_quant_tables[quant_level][astc::flt2int_rtn(a1)];\nquantize_hdr_rgb(color0, color1, output, quant_level);\n}\n@@ -1864,8 +1899,8 @@ static bool try_quantize_hdr_luminance_small_range(\nv1d = color_unquant_tables[quant_level][v1e];\nif ((v1d & 0xF0) == (v1 & 0xF0))\n{\n- output[0] = v0e;\n- output[1] = v1e;\n+ output[0] = static_cast<uint8_t>(v0e);\n+ output[1] = static_cast<uint8_t>(v1e);\nreturn true;\n}\n}\n@@ -1901,8 +1936,8 @@ static bool try_quantize_hdr_luminance_small_range(\nreturn false;\n}\n- output[0] = v0e;\n- output[1] = v1e;\n+ output[0] = static_cast<uint8_t>(v0e);\n+ output[1] = static_cast<uint8_t>(v1e);\nreturn true;\n}\n@@ -1967,8 +2002,8 @@ static void quantize_hdr_alpha(\ncontinue;\n}\n- output[0] = v6e;\n- output[1] = v7e;\n+ output[0] = static_cast<uint8_t>(v6e);\n+ output[1] = static_cast<uint8_t>(v7e);\nreturn;\n}\n@@ -1978,10 +2013,8 @@ static void quantize_hdr_alpha(\nv6 = val0 | 0x80;\nv7 = val1 | 0x80;\n- v6e = color_quant_tables[quant_level][v6];\n- v7e = color_quant_tables[quant_level][v7];\n- output[0] = v6e;\n- output[1] = v7e;\n+ output[0] = color_quant_tables[quant_level][v6];\n+ output[1] = color_quant_tables[quant_level][v7];\nreturn;\n}\n@@ -2005,7 +2038,7 @@ static void quantize_hdr_rgb_alpha(\n}\n/* See header for documentation. */\n-int pack_color_endpoints(\n+uint8_t pack_color_endpoints(\nvfloat4 color0,\nvfloat4 color1,\nvfloat4 rgbs_color,\n@@ -2020,7 +2053,7 @@ int pack_color_endpoints(\ncolor0 = max(color0, 0.0f);\ncolor1 = max(color1, 0.0f);\n- int retval = 0;\n+ uint8_t retval = 0;\nswitch (format)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -202,13 +202,13 @@ static bool realign_weights(\n// Check if the prev or next error is better, and if so use it\nif ((up_error < current_error) && (up_error < down_error))\n{\n- uq_pl_weights[we_idx] = next_wt_uq;\n+ uq_pl_weights[we_idx] = static_cast<uint8_t>(next_wt_uq);\ndec_weights_quant_pvalue[we_idx] = (uint8_t)((prev_and_next >> 24) & 0xFF);\nadjustments = true;\n}\nelse if (down_error < current_error)\n{\n- uq_pl_weights[we_idx] = prev_wt_uq;\n+ uq_pl_weights[we_idx] = static_cast<uint8_t>(prev_wt_uq);\ndec_weights_quant_pvalue[we_idx] = (uint8_t)((prev_and_next >> 16) & 0xFF);\nadjustments = true;\n}\n@@ -458,7 +458,7 @@ static float compress_symbolic_block_for_partition_1plane(\n&& (partition_count == 3 || (workscb.color_formats[0] == workscb.color_formats[3])))))\n{\nuint8_t colorvals[BLOCK_MAX_PARTITIONS][12];\n- int color_formats_mod[BLOCK_MAX_PARTITIONS] { 0 };\n+ uint8_t color_formats_mod[BLOCK_MAX_PARTITIONS] { 0 };\nfor (unsigned int j = 0; j < partition_count; j++)\n{\ncolor_formats_mod[j] = pack_color_endpoints(\n@@ -489,8 +489,8 @@ static float compress_symbolic_block_for_partition_1plane(\n}\n// Store header fields\n- workscb.partition_count = partition_count;\n- workscb.partition_index = partition_index;\n+ workscb.partition_count = static_cast<uint8_t>(partition_count);\n+ workscb.partition_index = static_cast<uint16_t>(partition_index);\nworkscb.plane2_component = -1;\nworkscb.quant_mode = workscb.color_formats_matched ? color_quant_level_mod[i] : color_quant_level[i];\nworkscb.block_mode = qw_bm.mode_index;\n@@ -832,7 +832,7 @@ static float compress_symbolic_block_for_partition_2planes(\nworkscb.quant_mode = color_quant_level[i];\nworkscb.color_formats_matched = 0;\nworkscb.block_mode = qw_bm.mode_index;\n- workscb.plane2_component = plane2_component;\n+ workscb.plane2_component = static_cast<int8_t>(plane2_component);\nworkscb.block_type = SYM_BTYPE_NONCONST;\nif (workscb.quant_mode < 4)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -210,7 +210,7 @@ void decompress_symbolic_block(\n(scb.block_type == SYM_BTYPE_CONST_U16))\n{\nvfloat4 color;\n- int use_lns = 0;\n+ uint8_t use_lns = 0;\n// UNORM16 constant color block\nif (scb.block_type == SYM_BTYPE_CONST_U16)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -172,7 +172,7 @@ static void kmeans_assign(\n}\n}\n- partition_of_texel[i] = best_partition;\n+ partition_of_texel[i] = static_cast<uint8_t>(best_partition);\npartition_texel_count[best_partition]++;\n}\n@@ -190,7 +190,7 @@ static void kmeans_assign(\n{\npartition_texel_count[partition_of_texel[i]]--;\npartition_texel_count[i]++;\n- partition_of_texel[i] = i;\n+ partition_of_texel[i] = static_cast<uint8_t>(i);\nproblem_case = true;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -177,8 +177,9 @@ void fetch_image_block(\nbool grayscale = true;\n// This works because we impose the same choice everywhere during encode\n- int rgb_lns = (decode_mode == ASTCENC_PRF_HDR) || (decode_mode == ASTCENC_PRF_HDR_RGB_LDR_A);\n- int a_lns = decode_mode == ASTCENC_PRF_HDR;\n+ uint8_t rgb_lns = (decode_mode == ASTCENC_PRF_HDR) ||\n+ (decode_mode == ASTCENC_PRF_HDR_RGB_LDR_A) ? 1 : 0;\n+ uint8_t a_lns = decode_mode == ASTCENC_PRF_HDR ? 1 : 0;\nvint4 use_lns(rgb_lns, rgb_lns, rgb_lns, a_lns);\nvmask4 lns_mask = use_lns != vint4::zero();\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_integer_sequence.cpp", "new_path": "Source/astcenc_integer_sequence.cpp", "diff": "@@ -680,7 +680,7 @@ void decode_ise(\n// Collect bits for each element, as well as bits for any trit-blocks and quint-blocks.\nfor (unsigned int i = 0; i < character_count; i++)\n{\n- results[i] = read_bits(bits, bit_offset, input_data);\n+ results[i] = static_cast<uint8_t>(read_bits(bits, bit_offset, input_data));\nbit_offset += bits;\nif (trits)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1962,7 +1962,7 @@ float compute_error_of_weight_set_2planes(\n* @return The actual endpoint mode used.\n*/\n// TODO: Format as enum?\n-int pack_color_endpoints(\n+uint8_t pack_color_endpoints(\nvfloat4 color0,\nvfloat4 color1,\nvfloat4 rgbs_color,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_partition_tables.cpp", "new_path": "Source/astcenc_partition_tables.cpp", "diff": "@@ -152,7 +152,7 @@ static uint32_t hash52(\n*\n* @return The assigned partition index for this texel.\n*/\n-static int select_partition(\n+static uint8_t select_partition(\nint seed,\nint x,\nint y,\n@@ -254,7 +254,7 @@ static int select_partition(\nb = 0;\n}\n- int partition;\n+ uint8_t partition;\nif (a >= b && a >= c && a >= d)\n{\npartition = 0;\n@@ -304,7 +304,7 @@ static void generate_one_partition_info_entry(\nfor (unsigned int x = 0; x < bsd.xdim; x++)\n{\nuint8_t part = select_partition(partition_index, x, y, z, partition_count, small_block);\n- pi.texels_of_partition[part][counts[part]++] = texel_idx++;\n+ pi.texels_of_partition[part][counts[part]++] = static_cast<uint8_t>(texel_idx++);\n*partition_of_texel++ = part;\n}\n}\n@@ -344,7 +344,7 @@ static void generate_one_partition_info_entry(\nfor (unsigned int i = 0; i < BLOCK_MAX_PARTITIONS; i++)\n{\n- pi.partition_texel_count[i] = counts[i];\n+ pi.partition_texel_count[i] = static_cast<uint8_t>(counts[i]);\npi.coverage_bitmaps[i] = 0ULL;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_quantization.cpp", "new_path": "Source/astcenc_quantization.cpp", "diff": "@@ -555,14 +555,14 @@ void init_quant_mode_table()\nunsigned int p = get_ise_sequence_bitcount(2 * j, (quant_method)i);\nif (p < 128)\n{\n- quant_mode_table[j][p] = i;\n+ quant_mode_table[j][p] = static_cast<int8_t>(i);\n}\n}\n}\nfor (int i = 0; i <= 16; i++)\n{\n- int largest_value_so_far = -1;\n+ int8_t largest_value_so_far = -1;\nfor (unsigned int j = 0; j < 128; j++)\n{\nif (quant_mode_table[i][j] > largest_value_so_far)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_symbolic_physical.cpp", "new_path": "Source/astcenc_symbolic_physical.cpp", "diff": "@@ -172,7 +172,7 @@ void symbolic_to_physical(\nfor (int i = 0; i < 16; i++)\n{\n- pcb.data[i] = bitrev8(weightbuf[15 - i]);\n+ pcb.data[i] = static_cast<uint8_t>(bitrev8(weightbuf[15 - i]));\n}\nwrite_bits(scb.block_mode, 11, 0, pcb.data);\n@@ -354,12 +354,12 @@ void physical_to_symbolic(\nint partition_count = read_bits(2, 11, pcb.data) + 1;\n- scb.block_mode = block_mode;\n- scb.partition_count = partition_count;\n+ scb.block_mode = static_cast<uint16_t>(block_mode);\n+ scb.partition_count = static_cast<uint8_t>(partition_count);\nfor (int i = 0; i < 16; i++)\n{\n- bswapped[i] = bitrev8(pcb.data[15 - i]);\n+ bswapped[i] = static_cast<uint8_t>(bitrev8(pcb.data[15 - i]));\n}\nint bits_for_weights = get_ise_sequence_bitcount(real_weight_count, weight_quant_method);\n@@ -430,12 +430,12 @@ void physical_to_symbolic(\nbitpos += 2;\n}\n}\n- scb.partition_index = read_bits(6, 13, pcb.data) | (read_bits(PARTITION_INDEX_BITS - 6, 19, pcb.data) << 6);\n+ scb.partition_index = static_cast<uint16_t>(read_bits(6, 13, pcb.data) | (read_bits(PARTITION_INDEX_BITS - 6, 19, pcb.data) << 6));\n}\nfor (int i = 0; i < partition_count; i++)\n{\n- scb.color_formats[i] = color_formats[i];\n+ scb.color_formats[i] = static_cast<uint8_t>(color_formats[i]);\n}\n// Determine number of color endpoint integers\n@@ -489,6 +489,6 @@ void physical_to_symbolic(\n// Fetch component for second-plane in the case of dual plane of weights.\nif (is_dual_plane)\n{\n- scb.plane2_component = read_bits(2, below_weights_pos - 2, pcb.data);\n+ scb.plane2_component = static_cast<int8_t>(read_bits(2, below_weights_pos - 2, pcb.data));\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "@@ -2410,9 +2410,9 @@ int store_cimage(\nhdr.magic[2] = (ASTC_MAGIC_ID >> 16) & 0xFF;\nhdr.magic[3] = (ASTC_MAGIC_ID >> 24) & 0xFF;\n- hdr.block_x = img.block_x;\n- hdr.block_y = img.block_y;\n- hdr.block_z = img.block_z;\n+ hdr.block_x = static_cast<uint8_t>(img.block_x);\n+ hdr.block_y = static_cast<uint8_t>(img.block_y);\n+ hdr.block_z = static_cast<uint8_t>(img.block_z);\nhdr.dim_x[0] = img.dim_x & 0xFF;\nhdr.dim_x[1] = (img.dim_x >> 8) & 0xFF;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -853,7 +853,7 @@ static int edit_astcenc_config(\nreturn 1;\n}\n- config.rgbm_m_scale = atof(argv[argidx - 1]);\n+ config.rgbm_m_scale = static_cast<float>(atof(argv[argidx - 1]));\nconfig.cw_a_weight = 2.0f * config.rgbm_m_scale;\n}\nelse if (!strcmp(argv[argidx], \"-perceptual\"))\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix /W4 warnings on VS2019
61,757
17.06.2021 16:38:18
-3,600
5f13f30f48e50a2eed59db2f26fb2c40a10d0364
Add STATUS to cmake message calls
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -26,12 +26,12 @@ project(astcenc VERSION 3.0.0)\nfunction(printopt optName optVal optArch tgtArch)\nif(${optVal})\nif(${optArch} MATCHES ${tgtArch})\n- message(\" -- ${optName} backend - ON\")\n+ message(STATUS \" ${optName} backend - ON\")\nelse()\n- message(\" -- ${optName} backend - SKIPPED (${optArch} only)\")\n+ message(STATUS \" ${optName} backend - SKIPPED (${optArch} only)\")\nendif()\nelse()\n- message(\" -- ${optName} backend - OFF\")\n+ message(STATUS \" ${optName} backend - OFF\")\nendif()\nendfunction()\n@@ -39,7 +39,7 @@ set(VALID_ARCH aarch64 aarch32 aarch32hf x64)\nset(ARCH x64 CACHE STRING \"Target architecture\")\nset_property(CACHE ARCH PROPERTY STRINGS ${VALID_ARCH})\n-message(\"-- Selecting target astcenc backends:\")\n+message(STATUS \"Selecting target astcenc backends:\")\nlist(FIND VALID_ARCH ${ARCH} index)\nif(index EQUAL -1)\nmessage(FATAL_ERROR \"ARCH must be one of ${VALID_ARCH}\")\n@@ -74,30 +74,30 @@ endif()\noption(ISA_NONE \"Enable builds for no SIMD\")\nif(${ISA_NONE})\nset(ANY_ISA 1)\n- message(\" -- No SIMD backend - ON\")\n+ message(STATUS \" No SIMD backend - ON\")\nelse()\n- message(\" -- No SIMD backend - OFF\")\n+ message(STATUS \" No SIMD backend - OFF\")\nendif()\noption(DECOMPRESSOR \"Enable builds for decompression only\")\nif(${DECOMPRESSOR})\n- message(\" -- Decompress-only backend - ON\")\n+ message(STATUS \" Decompress-only backend - ON\")\nelse()\n- message(\" -- Decompress-only backend - OFF\")\n+ message(STATUS \" Decompress-only backend - OFF\")\nendif()\noption(DIAGNOSTICS \"Enable builds for diagnostic trace\")\nif(${DIAGNOSTICS})\n- message(\" -- Diagnostic tracing - ON\")\n+ message(STATUS \" Diagnostic tracing - ON\")\nelse()\n- message(\" -- Diagnostic tracing - OFF\")\n+ message(STATUS \" Diagnostic tracing - OFF\")\nendif()\noption(UNITTEST \"Enable builds for unit tests\")\nif(${UNITTEST})\n- message(\" -- Unit tests - ON\")\n+ message(STATUS \" Unit tests - ON\")\nelse()\n- message(\" -- Unit tests - OFF\")\n+ message(STATUS \" Unit tests - OFF\")\nendif()\nif(NOT ${ANY_ISA})\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add STATUS to cmake message calls
61,745
16.06.2021 08:18:46
-3,600
0c6d4feee47314be4b44c0e3f3cb65cc5f5d7ca7
Allow high bitrate blocks to use 2 planes more
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -65,10 +65,10 @@ static const std::array<astcenc_preset_config, 5> preset_configs_high {{\n3, 4, 30, 1, 2, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 25\n}, {\nASTCENC_PRE_FAST,\n- 3, 12, 55, 3, 3, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f, 20\n+ 3, 12, 55, 3, 3, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.65f, 20\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 3, 3 , 95.0f, 70.0f, 2.5f, 2.5f, 1.2f, 1.25f, 0.75f, 16\n+ 4, 26, 76, 3, 3 , 95.0f, 70.0f, 2.5f, 2.5f, 1.2f, 1.25f, 0.85f, 16\n}, {\nASTCENC_PRE_THOROUGH,\n4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f, 12\n@@ -116,10 +116,10 @@ static const std::array<astcenc_preset_config, 5> preset_configs_low {{\n3, 10, 53, 3, 3, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f, 16\n}, {\nASTCENC_PRE_MEDIUM,\n- 3, 26, 76, 3, 3, 95.0f, 70.0f, 3.5f, 3.5f, 1.2f, 1.25f, 0.75f, 12\n+ 3, 26, 76, 3, 3, 95.0f, 70.0f, 3.5f, 3.5f, 1.2f, 1.25f, 0.65f, 12\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 75, 92, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f, 10\n+ 4, 75, 92, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.85f, 10\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f, 0\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Allow high bitrate blocks to use 2 planes more
61,745
18.06.2021 20:31:26
-3,600
26a4f4decaedcb9cdcae6e735fec5f981c899d9f
Add support for native binaries
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -79,6 +79,20 @@ else()\nmessage(STATUS \" No SIMD backend - OFF\")\nendif()\n+# Manually provide this as a tristate so we can distinguish the default\n+# not set state from explicitly ON and OFF ...\n+set(ISA_NATIVE AUTO CACHE STRING \"Enable builds for the native local CPU\")\n+set_property(CACHE ISA_NATIVE PROPERTY STRINGS AUTO ON OFF)\n+\n+if(((NOT ${ANY_ISA}) AND (${ISA_NATIVE} STREQUAL AUTO)) OR (${ISA_NATIVE} STREQUAL ON))\n+ set(ISA_NATIVE 1)\n+ set(ANY_ISA 1)\n+ message(STATUS \" Native SIMD backend - ON\")\n+else()\n+ set(ISA_NATIVE 0)\n+ message(STATUS \" Native SIMD backend - OFF\")\n+endif()\n+\noption(DECOMPRESSOR \"Enable builds for decompression only\")\nif(${DECOMPRESSOR})\nmessage(STATUS \" Decompress-only backend - ON\")\n@@ -104,6 +118,7 @@ if(NOT ${ANY_ISA})\nmessage(FATAL_ERROR \"At least one backend ISA must be enabled\")\nendif()\n+\n# Project configuration\n# Must be done after project() but before compiler settings\n" }, { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "@@ -24,9 +24,14 @@ cd build\n# Configure your build of choice, for example:\n-# x86-64\n+# x86-64 using NMake\ncmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.\\ ^\n-DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n+\n+# x86-64 using Visual Studio solution\n+cmake -G \"Visual Studio 16 2019\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.\\ ^\n+ -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n+\n```\nThis example shows all SIMD variants being enabled. It is possible to build a\n@@ -73,11 +78,21 @@ cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n# x86-64\ncmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n-DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n+\n+# x86-64 optimized for the local CPU's microarchitecture\n+cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n+ -DISA_NATIVE=ON ..\n```\nThis example shows all SIMD variants being enabled. It is possible to build a\n-subset of the supported variants by enabling only the ones you require. At\n-least one variant must be enabled.\n+subset of the supported variants by enabling only the ones you require. If no\n+variant is explicitly specified the build will compile a native binary for the\n+build machine.\n+\n+:warning: Compiling a native binary for the build machine usually gives the\n+fastest binaries for that specific CPU type but may produce binaries that do\n+not work (due to using ISA extensions) or run slowly (due to poor instruction\n+scheduling) on other processors.\n### Building\n" }, { "change_type": "MODIFY", "old_path": "Source/CMakeLists.txt", "new_path": "Source/CMakeLists.txt", "diff": "@@ -35,6 +35,14 @@ if (${ISA_NONE})\ninclude(cmake_core.cmake)\nendif()\n+# - - - - - - - - - - - - - - - - - -\n+# Implicit host architecture-specific SIMD\n+\n+if (${ISA_NATIVE})\n+ set(ISA_SIMD native)\n+ include(cmake_core.cmake)\n+endif()\n+\n# - - - - - - - - - - - - - - - - - -\n# Armv8-A architecture-specific SIMD\n" }, { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "@@ -190,6 +190,12 @@ macro(astcenc_set_properties NAME)\nPRIVATE\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-mavx2 -mpopcnt -mf16c>\n$<$<CXX_COMPILER_ID:MSVC>:/arch:AVX2>)\n+\n+ elseif(${ISA_SIMD} MATCHES \"native\")\n+ target_compile_options(${NAME}\n+ PRIVATE\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-march=native>)\n+\nendif()\nendmacro()\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -299,7 +299,7 @@ def parse_command_line():\n\"ref-main-neon\", \"ref-main-sse2\", \"ref-main-sse4.1\", \"ref-main-avx2\"]\n# All test encoders\n- testcoders = [\"none\", \"neon\", \"sse2\", \"sse4.1\", \"avx2\"]\n+ testcoders = [\"none\", \"native\", \"neon\", \"sse2\", \"sse4.1\", \"avx2\"]\ntestcodersAArch64 = [\"none\", \"neon\"]\ntestcodersX86 = [\"none\", \"sse2\", \"sse4.1\", \"avx2\"]\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add support for native binaries
61,745
18.06.2021 20:42:40
-3,600
4e06e7041aa09e2bfc18aebf53e1630efd59f4f8
Clarify build docs for ISA_NATIVE
[ { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "@@ -79,7 +79,7 @@ cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\ncmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n-DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n-# x86-64 optimized for the local CPU's microarchitecture\n+# Host builds optimized for the local CPU's microarchitecture\ncmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n-DISA_NATIVE=ON ..\n```\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Clarify build docs for ISA_NATIVE
61,745
18.06.2021 22:25:27
-3,600
6164d50ab8f48dfacd5645493b6e7417161d974a
Add compute_avgs_and_dirs_3_comp_rgb fast path
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -36,7 +36,7 @@ void compute_avgs_and_dirs_4_comp(\nfor (int partition = 0; partition < partition_count; partition++)\n{\n- const uint8_t *weights = pi.texels_of_partition[partition];\n+ const uint8_t *texel_indexes = pi.texels_of_partition[partition];\nvfloat4 error_sum = vfloat4::zero();\nvfloat4 base_sum = vfloat4::zero();\n@@ -49,7 +49,7 @@ void compute_avgs_and_dirs_4_comp(\nfor (unsigned int i = 0; i < texel_count; i++)\n{\n- int iwt = weights[i];\n+ int iwt = texel_indexes[i];\nfloat weight = ewb.texel_weight[iwt];\nvfloat4 texel_datum = blk.texel(iwt);\nvfloat4 error_weight = ewb.error_weights[iwt];\n@@ -84,7 +84,7 @@ void compute_avgs_and_dirs_4_comp(\nfor (unsigned int i = 0; i < texel_count; i++)\n{\n- unsigned int iwt = weights[i];\n+ unsigned int iwt = texel_indexes[i];\nfloat weight = ewb.texel_weight[iwt];\nvfloat4 texel_datum = blk.texel(iwt);\ntexel_datum = (texel_datum - average) * weight;\n@@ -187,7 +187,7 @@ void compute_avgs_and_dirs_3_comp(\nfor (unsigned int partition = 0; partition < partition_count; partition++)\n{\n- const uint8_t *weights = pi.texels_of_partition[partition];\n+ const uint8_t *texel_indexes = pi.texels_of_partition[partition];\nvfloat4 error_sum = vfloat4::zero();\nvfloat4 base_sum = vfloat4::zero();\n@@ -200,7 +200,7 @@ void compute_avgs_and_dirs_3_comp(\nfor (unsigned int i = 0; i < texel_count; i++)\n{\n- unsigned int iwt = weights[i];\n+ unsigned int iwt = texel_indexes[i];\nfloat weight = texel_weights[iwt];\nvfloat4 texel_datum(data_vr[iwt],\n@@ -242,11 +242,118 @@ void compute_avgs_and_dirs_3_comp(\nfor (unsigned int i = 0; i < texel_count; i++)\n{\n- unsigned int iwt = weights[i];\n+ unsigned int iwt = texel_indexes[i];\nfloat weight = texel_weights[iwt];\n+\nvfloat4 texel_datum = vfloat3(data_vr[iwt],\ndata_vg[iwt],\ndata_vb[iwt]);\n+\n+ texel_datum = (texel_datum - average) * weight;\n+\n+ vfloat4 zero = vfloat4::zero();\n+\n+ vmask4 tdm0 = vfloat4(texel_datum.lane<0>()) > zero;\n+ sum_xp += select(zero, texel_datum, tdm0);\n+\n+ vmask4 tdm1 = vfloat4(texel_datum.lane<1>()) > zero;\n+ sum_yp += select(zero, texel_datum, tdm1);\n+\n+ vmask4 tdm2 = vfloat4(texel_datum.lane<2>()) > zero;\n+ sum_zp += select(zero, texel_datum, tdm2);\n+ }\n+\n+ float prod_xp = dot3_s(sum_xp, sum_xp);\n+ float prod_yp = dot3_s(sum_yp, sum_yp);\n+ float prod_zp = dot3_s(sum_zp, sum_zp);\n+\n+ vfloat4 best_vector = sum_xp;\n+ float best_sum = prod_xp;\n+\n+ if (prod_yp > best_sum)\n+ {\n+ best_vector = sum_yp;\n+ best_sum = prod_yp;\n+ }\n+\n+ if (prod_zp > best_sum)\n+ {\n+ best_vector = sum_zp;\n+ }\n+\n+ pm[partition].dir = best_vector;\n+ }\n+}\n+\n+/* See header for documentation. */\n+void compute_avgs_and_dirs_3_comp_rgb(\n+ const partition_info& pi,\n+ const image_block& blk,\n+ const error_weight_block& ewb,\n+ partition_metrics pm[BLOCK_MAX_PARTITIONS]\n+) {\n+ unsigned int partition_count = pi.partition_count;\n+ promise(partition_count > 0);\n+\n+ for (unsigned int partition = 0; partition < partition_count; partition++)\n+ {\n+ const uint8_t *texel_indexes = pi.texels_of_partition[partition];\n+\n+ vfloat4 error_sum = vfloat4::zero();\n+ vfloat4 base_sum = vfloat4::zero();\n+ vfloat4 rgb_min(1e38f);\n+ vfloat4 rgb_max(-1e38f);\n+ float partition_weight = 0.0f;\n+\n+ unsigned int texel_count = pi.partition_texel_count[partition];\n+ promise(texel_count > 0);\n+\n+ for (unsigned int i = 0; i < texel_count; i++)\n+ {\n+ unsigned int iwt = texel_indexes[i];\n+ float weight = ewb.texel_weight_rgb[iwt];\n+\n+ vfloat4 texel_datum = blk.texel3(iwt);\n+\n+ vfloat4 error_weight(ewb.texel_weight_r[iwt],\n+ ewb.texel_weight_g[iwt],\n+ ewb.texel_weight_b[iwt],\n+ 0.0f);\n+\n+ if (weight > 1e-10f)\n+ {\n+ rgb_min = min(texel_datum, rgb_min);\n+ rgb_max = max(texel_datum, rgb_max);\n+ }\n+\n+ partition_weight += weight;\n+ base_sum += texel_datum * weight;\n+ error_sum += error_weight;\n+ }\n+\n+ error_sum = error_sum / static_cast<float>(texel_count);\n+ vfloat4 csf = normalize(sqrt(error_sum)) * 1.73205080f;\n+\n+ vfloat4 average = base_sum * (1.0f / astc::max(partition_weight, 1e-7f));\n+\n+ pm[partition].error_weight = error_sum;\n+ pm[partition].avg = average * csf;\n+ pm[partition].color_scale = csf;\n+ pm[partition].icolor_scale = 1.0f / max(csf, 1e-7f);\n+ vfloat4 range = max(rgb_max - rgb_min, 1e-10f);\n+ pm[partition].range_sq = range * range;\n+\n+ vfloat4 sum_xp = vfloat4::zero();\n+ vfloat4 sum_yp = vfloat4::zero();\n+ vfloat4 sum_zp = vfloat4::zero();\n+\n+ for (unsigned int i = 0; i < texel_count; i++)\n+ {\n+ unsigned int iwt = texel_indexes[i];\n+ float weight = ewb.texel_weight_rgb[iwt];\n+\n+ vfloat4 texel_datum = blk.texel3(iwt);\n+\ntexel_datum = (texel_datum - average) * weight;\nvfloat4 zero = vfloat4::zero();\n@@ -338,7 +445,7 @@ void compute_avgs_and_dirs_2_comp(\nfor (unsigned int partition = 0; partition < partition_count; partition++)\n{\n- const uint8_t *weights = pt.texels_of_partition[partition];\n+ const uint8_t *texel_indexes = pt.texels_of_partition[partition];\nvfloat4 error_sum = vfloat4::zero();\nvfloat4 base_sum = vfloat4::zero();\n@@ -349,7 +456,7 @@ void compute_avgs_and_dirs_2_comp(\nfor (unsigned int i = 0; i < texel_count; i++)\n{\n- unsigned int iwt = weights[i];\n+ unsigned int iwt = texel_indexes[i];\nfloat weight = texel_weights[iwt];\nvfloat4 texel_datum = vfloat2(data_vr[iwt], data_vg[iwt]) * weight;\n@@ -375,7 +482,7 @@ void compute_avgs_and_dirs_2_comp(\nfor (unsigned int i = 0; i < texel_count; i++)\n{\n- unsigned int iwt = weights[i];\n+ unsigned int iwt = texel_indexes[i];\nfloat weight = texel_weights[iwt];\nvfloat4 texel_datum = vfloat2(data_vr[iwt], data_vg[iwt]);\ntexel_datum = (texel_datum - average) * weight;\n@@ -424,7 +531,7 @@ void compute_error_squared_rgba(\nfor (unsigned int partition = 0; partition < partition_count; partition++)\n{\n- const uint8_t *weights = pi.texels_of_partition[partition];\n+ const uint8_t *texel_indexes = pi.texels_of_partition[partition];\nfloat uncor_loparam = 1e10f;\nfloat uncor_hiparam = -1e10f;\n@@ -474,14 +581,14 @@ void compute_error_squared_rgba(\nvfloat samec_hiparamv(-1e10f);\nvfloat4 samec_errorsumv = vfloat4::zero();\n- // This implementation over-shoots, but this is safe as we initialize the weights array\n+ // This implementation over-shoots, but this is safe as we initialize the texel_indexes array\n// to extend the last value. This means min/max are not impacted, but we need to mask\n// out the dummy values when we compute the line weighting.\nvint lane_ids = vint::lane_id();\nfor (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n{\nvmask mask = lane_ids < vint(texel_count);\n- vint texel_idxs(&(weights[i]));\n+ vint texel_idxs(&(texel_indexes[i]));\nvfloat data_r = gatherf(blk.data_r, texel_idxs);\nvfloat data_g = gatherf(blk.data_g, texel_idxs);\n@@ -580,7 +687,7 @@ void compute_error_squared_rgb(\nfor (unsigned int partition = 0; partition < partition_count; partition++)\n{\npartition_lines3& pl = plines[partition];\n- const uint8_t *weights = pi.texels_of_partition[partition];\n+ const uint8_t *texel_indexes = pi.texels_of_partition[partition];\nunsigned int texel_count = pi.partition_texel_count[partition];\npromise(texel_count > 0);\n@@ -635,7 +742,7 @@ void compute_error_squared_rgb(\nfor (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n{\nvmask mask = lane_ids < vint(texel_count);\n- vint texel_idxs(&(weights[i]));\n+ vint texel_idxs(&(texel_indexes[i]));\nvfloat data_r = gatherf(blk.data_r, texel_idxs);\nvfloat data_g = gatherf(blk.data_g, texel_idxs);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -638,7 +638,7 @@ void find_best_partition_candidates(\n// Compute weighting to give to each component in each partition\npartition_metrics pms[BLOCK_MAX_PARTITIONS];\n- compute_avgs_and_dirs_3_comp(pi, blk, ewb, 3, pms);\n+ compute_avgs_and_dirs_3_comp_rgb(pi, blk, ewb, pms);\npartition_lines3 plines[BLOCK_MAX_PARTITIONS];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1570,6 +1570,25 @@ void compute_avgs_and_dirs_3_comp(\nunsigned int omitted_component,\npartition_metrics pm[BLOCK_MAX_PARTITIONS]);\n+/**\n+ * @brief Compute averages and dominant directions for each partition in a 3 component texture.\n+ *\n+ * This is a specialization of @c compute_avgs_and_dirs_3_comp where the omitted component is\n+ * always alpha, a common case during partition search.\n+ *\n+ * @param pi The partition info for the current trial.\n+ * @param blk The image block color data to be compressed.\n+ * @param ewb The image block weighted error data.\n+ * @param[out] pm The output partition metrics.\n+ * - Only pi.partition_count array entries actually get initialized.\n+ * - Direction vectors @c pm.dir are not normalized.\n+ */\n+void compute_avgs_and_dirs_3_comp_rgb(\n+ const partition_info& pi,\n+ const image_block& blk,\n+ const error_weight_block& ewb,\n+ partition_metrics pm[BLOCK_MAX_PARTITIONS]);\n+\n/**\n* @brief Compute averages and dominant directions for each partition in a 4 component texture.\n*\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add compute_avgs_and_dirs_3_comp_rgb fast path
61,745
19.06.2021 00:45:39
-3,600
2d45bde830cd8d2e5635ced588d601ecb8f127bf
Use vector overprocess without loop tail
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -906,19 +906,12 @@ void compute_ideal_weights_for_decimation(\n}\n// Populate the interpolated weight grid based on the initital average\n- // Process SIMD-width texel coordinates at at time while we can\n- unsigned int is = 0;\n- unsigned int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\n- for (/* */; is < clipped_texel_count; is += ASTCENC_SIMD_WIDTH)\n- {\n- vfloat weight = bilinear_infill_vla(di, dec_weight_ideal_value, is);\n- storea(weight, infilled_weights + is);\n- }\n-\n- // Loop tail\n- for (/* */; is < texel_count; is++)\n+ // Process SIMD-width texel coordinates at at time while we can. Safe to\n+ // over-process full SIMD vectors - the tail is zeroed.\n+ for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n- infilled_weights[is] = bilinear_infill(di, dec_weight_ideal_value, is);\n+ vfloat weight = bilinear_infill_vla(di, dec_weight_ideal_value, i);\n+ storea(weight, infilled_weights + i);\n}\n// Perform a single iteration of refinement\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use vector overprocess without loop tail
61,745
19.06.2021 09:46:29
-3,600
8dc6e782d6920cd4cb6cd436351a894ba967b873
More code size efficient nested loop exit
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -533,7 +533,9 @@ static float compress_symbolic_block_for_partition_1plane(\nif (errorval < tune_errorval_threshold)\n{\n- return errorval;\n+ // Skip remaining candidates - this is \"good enough\"\n+ i = candidate_count;\n+ break;\n}\n}\n}\n@@ -572,7 +574,9 @@ static float compress_symbolic_block_for_partition_1plane(\nif (errorval < tune_errorval_threshold)\n{\n- return errorval;\n+ // Skip remaining candidates - this is \"good enough\"\n+ i = candidate_count;\n+ break;\n}\n}\n@@ -872,7 +876,9 @@ static float compress_symbolic_block_for_partition_2planes(\nif (errorval < tune_errorval_threshold)\n{\n- return errorval;\n+ // Skip remaining candidates - this is \"good enough\"\n+ i = candidate_count;\n+ break;\n}\n}\n}\n@@ -911,7 +917,9 @@ static float compress_symbolic_block_for_partition_2planes(\nif (errorval < tune_errorval_threshold)\n{\n- return errorval;\n+ // Skip remaining candidates - this is \"good enough\"\n+ i = candidate_count;\n+ break;\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
More code size efficient nested loop exit
61,745
19.06.2021 09:53:01
-3,600
d1f869a71995f9396f4027b5dd83625a01c30763
Remove redundanant error setting
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -359,9 +359,9 @@ static float compress_symbolic_block_for_partition_1plane(\nint bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\nif (bitcount <= 0)\n{\n- qwt_errors[i] = 1e38f;\ncontinue;\n}\n+\nqwt_bitcounts[i] = bitcount;\n// Generate the optimized set of weights for the weight mode\n@@ -723,12 +723,13 @@ static float compress_symbolic_block_for_partition_2planes(\nunsigned int bits_used_by_weights = get_ise_sequence_bitcount(\n2 * di.weight_count,\nbm.get_weight_quant_mode());\n+\nint bitcount = 113 - 4 - bits_used_by_weights;\nif (bitcount <= 0)\n{\n- qwt_errors[i] = 1e38f;\ncontinue;\n}\n+\nqwt_bitcounts[i] = bitcount;\n// Generate the optimized set of weights for the mode\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove redundanant error setting
61,745
19.06.2021 15:29:19
-3,600
142e7ffdbef31140ea1ec515a6f879651aeb8050
Use packed 2 plane weights in compression_working_buffers
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -644,15 +644,15 @@ static float compress_symbolic_block_for_partition_2planes(\nei1,\neix1[i],\ndi,\n- dec_weights_ideal_value + (2 * i) * BLOCK_MAX_WEIGHTS,\n- dec_weights_ideal_sig + (2 * i) * BLOCK_MAX_WEIGHTS);\n+ dec_weights_ideal_value + i * BLOCK_MAX_WEIGHTS,\n+ dec_weights_ideal_sig + i * BLOCK_MAX_WEIGHTS);\ncompute_ideal_weights_for_decimation(\nei2,\neix2[i],\ndi,\n- dec_weights_ideal_value + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\n- dec_weights_ideal_sig + (2 * i + 1) * BLOCK_MAX_WEIGHTS);\n+ dec_weights_ideal_value + i * BLOCK_MAX_WEIGHTS + WEIGHTS_PLANE2_OFFSET,\n+ dec_weights_ideal_sig + i * BLOCK_MAX_WEIGHTS + WEIGHTS_PLANE2_OFFSET);\n}\n// Compute maximum colors for the endpoints and ideal weights, then for each endpoint and ideal\n@@ -737,18 +737,18 @@ static float compress_symbolic_block_for_partition_2planes(\ndi,\nweight_low_value1[i],\nweight_high_value1[i],\n- dec_weights_ideal_value + BLOCK_MAX_WEIGHTS * (2 * decimation_mode),\n- dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * (2 * i),\n- dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * (2 * i),\n+ dec_weights_ideal_value + BLOCK_MAX_WEIGHTS * decimation_mode,\n+ dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * i,\n+ dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * i,\nbm.get_weight_quant_mode());\ncompute_quantized_weights_for_decimation(\ndi,\nweight_low_value2[i],\nweight_high_value2[i],\n- dec_weights_ideal_value + BLOCK_MAX_WEIGHTS * (2 * decimation_mode + 1),\n- dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * (2 * i + 1),\n- dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * (2 * i + 1),\n+ dec_weights_ideal_value + BLOCK_MAX_WEIGHTS * decimation_mode + WEIGHTS_PLANE2_OFFSET,\n+ dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * i + WEIGHTS_PLANE2_OFFSET,\n+ dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * i + WEIGHTS_PLANE2_OFFSET,\nbm.get_weight_quant_mode());\n// Compute weight quantization errors for the block mode\n@@ -756,8 +756,8 @@ static float compress_symbolic_block_for_partition_2planes(\neix1[decimation_mode],\neix2[decimation_mode],\ndi,\n- dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * (2 * i),\n- dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * (2 * i + 1));\n+ dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * i,\n+ dec_weights_quant_uvalue + BLOCK_MAX_WEIGHTS * i + WEIGHTS_PLANE2_OFFSET);\n}\n// Decide the optimal combination of color endpoint encodings and weight encodings\n@@ -806,8 +806,8 @@ static float compress_symbolic_block_for_partition_2planes(\nsymbolic_compressed_block workscb;\n- uint8_t* u8_weight1_src = dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * (2 * bm_packed_index);\n- uint8_t* u8_weight2_src = dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * (2 * bm_packed_index + 1);\n+ uint8_t* u8_weight1_src = dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * bm_packed_index;\n+ uint8_t* u8_weight2_src = dec_weights_quant_pvalue + BLOCK_MAX_WEIGHTS * bm_packed_index + WEIGHTS_PLANE2_OFFSET;\nfor (int j = 0; j < di.weight_count; j++)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1322,8 +1322,8 @@ void recompute_ideal_colors_2planes(\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_mode]);\n- float dec_weights_quant_uvalue_plane1[BLOCK_MAX_WEIGHTS];\n- float dec_weights_quant_uvalue_plane2[BLOCK_MAX_WEIGHTS];\n+ float dec_weights_quant_uvalue_plane1[BLOCK_MAX_WEIGHTS_2PLANE];\n+ float dec_weights_quant_uvalue_plane2[BLOCK_MAX_WEIGHTS_2PLANE];\nfor (int i = 0; i < weight_count; i++)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -84,6 +84,9 @@ static constexpr uint8_t BLOCK_MAX_KMEANS_TEXELS { 64 };\n/** @brief The maximum number of weights a block can support. */\nstatic constexpr unsigned int BLOCK_MAX_WEIGHTS { 64 };\n+/** @brief The maximum number of weights a block can support per plane in 2 plane mode. */\n+static constexpr unsigned int BLOCK_MAX_WEIGHTS_2PLANE { BLOCK_MAX_WEIGHTS / 2 };\n+\n/** @brief The minimum number of weight bits a candidate encoding must encode. */\nstatic constexpr unsigned int BLOCK_MIN_WEIGHT_BITS { 24 };\n@@ -97,7 +100,7 @@ static constexpr uint16_t BLOCK_BAD_BLOCK_MODE { 0xFFFFu };\nstatic constexpr unsigned int PARTITION_INDEX_BITS { 10 };\n/** @brief The offset of the plane 2 weights in shared weight arrays. */\n-static constexpr unsigned int WEIGHTS_PLANE2_OFFSET { BLOCK_MAX_WEIGHTS / 2 };\n+static constexpr unsigned int WEIGHTS_PLANE2_OFFSET { BLOCK_MAX_WEIGHTS_2PLANE };\n/** @brief The sum of quantized weights for one texel. */\nstatic constexpr float WEIGHTS_TEXEL_SUM { 16.0f };\n@@ -1071,17 +1074,33 @@ struct alignas(ASTCENC_VECALIGN) compression_working_buffers\n/** @brief The error weight block for the current thread. */\nerror_weight_block ewb;\n- /** @brief Decimated ideal weight values. */\n- alignas(ASTCENC_VECALIGN) float dec_weights_ideal_value[2 * WEIGHTS_MAX_DECIMATION_MODES * BLOCK_MAX_WEIGHTS];\n+ /**\n+ * @brief Decimated ideal weight values.\n+ *\n+ * For two plane encodings, second plane weights start at @c WEIGHTS_PLANE2_OFFSET offsets.\n+ */\n+ alignas(ASTCENC_VECALIGN) float dec_weights_ideal_value[WEIGHTS_MAX_DECIMATION_MODES * BLOCK_MAX_WEIGHTS];\n- /** @brief Decimated ideal weight significance. */\n- alignas(ASTCENC_VECALIGN) float dec_weights_ideal_sig[2 * WEIGHTS_MAX_DECIMATION_MODES * BLOCK_MAX_WEIGHTS];\n+ /**\n+ * @brief Decimated ideal weight significance.\n+ *\n+ * For two plane encodings, second plane weights start at @c WEIGHTS_PLANE2_OFFSET offsets.\n+ */\n+ alignas(ASTCENC_VECALIGN) float dec_weights_ideal_sig[WEIGHTS_MAX_DECIMATION_MODES * BLOCK_MAX_WEIGHTS];\n- /** @brief Decimated and quantized weight values stored in the unpacked quantized weight range. */\n- alignas(ASTCENC_VECALIGN) float dec_weights_quant_uvalue[2 * WEIGHTS_MAX_BLOCK_MODES * BLOCK_MAX_WEIGHTS];\n+ /**\n+ * @brief Decimated and quantized weight values stored in the unpacked quantized weight range.\n+ *\n+ * For two plane encodings, second plane weights start at @c WEIGHTS_PLANE2_OFFSET offsets.\n+ */\n+ alignas(ASTCENC_VECALIGN) float dec_weights_quant_uvalue[WEIGHTS_MAX_BLOCK_MODES * BLOCK_MAX_WEIGHTS];\n- /** @brief Decimated and quantized weight values stored in the packed quantized weight range. */\n- alignas(ASTCENC_VECALIGN) uint8_t dec_weights_quant_pvalue[2 * WEIGHTS_MAX_BLOCK_MODES * BLOCK_MAX_WEIGHTS];\n+ /**\n+ * @brief Decimated and quantized weight values stored in the packed quantized weight range.\n+ *\n+ * For two plane encodings, second plane weights start at @c WEIGHTS_PLANE2_OFFSET offsets.\n+ */\n+ alignas(ASTCENC_VECALIGN) uint8_t dec_weights_quant_pvalue[WEIGHTS_MAX_BLOCK_MODES * BLOCK_MAX_WEIGHTS];\n};\n/**\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -607,28 +607,28 @@ void compute_angular_endpoints_2planes(\n{\ncompute_angular_endpoints_for_quant_levels_lwc(\nweight_count,\n- dec_weight_quant_uvalue + 2 * i * BLOCK_MAX_WEIGHTS,\n- dec_weight_quant_sig + 2 * i * BLOCK_MAX_WEIGHTS,\n+ dec_weight_quant_uvalue + i * BLOCK_MAX_WEIGHTS,\n+ dec_weight_quant_sig + i * BLOCK_MAX_WEIGHTS,\ndm.maxprec_2planes, low_values1[i], high_values1[i]);\ncompute_angular_endpoints_for_quant_levels_lwc(\nweight_count,\n- dec_weight_quant_uvalue + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\n- dec_weight_quant_sig + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\n+ dec_weight_quant_uvalue + i * BLOCK_MAX_WEIGHTS + WEIGHTS_PLANE2_OFFSET,\n+ dec_weight_quant_sig + i * BLOCK_MAX_WEIGHTS + WEIGHTS_PLANE2_OFFSET,\ndm.maxprec_2planes, low_values2[i], high_values2[i]);\n}\nelse\n{\ncompute_angular_endpoints_for_quant_levels(\nweight_count,\n- dec_weight_quant_uvalue + 2 * i * BLOCK_MAX_WEIGHTS,\n- dec_weight_quant_sig + 2 * i * BLOCK_MAX_WEIGHTS,\n+ dec_weight_quant_uvalue + i * BLOCK_MAX_WEIGHTS,\n+ dec_weight_quant_sig + i * BLOCK_MAX_WEIGHTS,\ndm.maxprec_2planes, low_values1[i], high_values1[i]);\ncompute_angular_endpoints_for_quant_levels(\nweight_count,\n- dec_weight_quant_uvalue + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\n- dec_weight_quant_sig + (2 * i + 1) * BLOCK_MAX_WEIGHTS,\n+ dec_weight_quant_uvalue + i * BLOCK_MAX_WEIGHTS + WEIGHTS_PLANE2_OFFSET,\n+ dec_weight_quant_sig + i * BLOCK_MAX_WEIGHTS + WEIGHTS_PLANE2_OFFSET,\ndm.maxprec_2planes, low_values2[i], high_values2[i]);\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use packed 2 plane weights in compression_working_buffers
61,745
19.06.2021 20:02:46
-3,600
251612ecd161e621bb99f78c67667d10b570ad13
Remove min/max filtering Zero weight border texels are replicated copies of non-zero weight ones, so this is not needed.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -54,11 +54,8 @@ void compute_avgs_and_dirs_4_comp(\nvfloat4 texel_datum = blk.texel(iwt);\nvfloat4 error_weight = ewb.error_weights[iwt];\n- if (weight > 1e-10f)\n- {\nrgba_min = min(texel_datum, rgba_min);\nrgba_max = max(texel_datum, rgba_max);\n- }\npartition_weight += weight;\nbase_sum += texel_datum * weight;\n@@ -213,12 +210,8 @@ void compute_avgs_and_dirs_3_comp(\nerror_vb[iwt],\n0.0f);\n- if (weight > 1e-10f)\n- {\nrgb_min = min(texel_datum, rgb_min);\nrgb_max = max(texel_datum, rgb_max);\n- }\n-\npartition_weight += weight;\nbase_sum += texel_datum * weight;\nerror_sum += error_weight;\n@@ -320,12 +313,8 @@ void compute_avgs_and_dirs_3_comp_rgb(\newb.texel_weight_b[iwt],\n0.0f);\n- if (weight > 1e-10f)\n- {\nrgb_min = min(texel_datum, rgb_min);\nrgb_max = max(texel_datum, rgb_max);\n- }\n-\npartition_weight += weight;\nbase_sum += texel_datum * weight;\nerror_sum += error_weight;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove min/max filtering Zero weight border texels are replicated copies of non-zero weight ones, so this is not needed.
61,745
19.06.2021 20:03:36
-3,600
88a4bda2902704328ef937196173c6787bce96c0
Use compute_avgs_and_dirs_3_comp_rgb
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -203,7 +203,7 @@ static void compute_encoding_choice_errors(\npartition_metrics pms[BLOCK_MAX_PARTITIONS];\n- compute_avgs_and_dirs_3_comp(pi, blk, ewb, 3, pms);\n+ compute_avgs_and_dirs_3_comp_rgb(pi, blk, ewb, pms);\nfor (int i = 0; i < partition_count; i++)\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use compute_avgs_and_dirs_3_comp_rgb
61,745
19.06.2021 20:08:50
-3,600
f3fb4c04b516a97db257d415986461a5b1e83f32
Remove min/max from compute_avgs_and_dirs_3_comp
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -188,8 +188,6 @@ void compute_avgs_and_dirs_3_comp(\nvfloat4 error_sum = vfloat4::zero();\nvfloat4 base_sum = vfloat4::zero();\n- vfloat4 rgb_min(1e38f);\n- vfloat4 rgb_max(-1e38f);\nfloat partition_weight = 0.0f;\nunsigned int texel_count = pi.partition_texel_count[partition];\n@@ -210,8 +208,6 @@ void compute_avgs_and_dirs_3_comp(\nerror_vb[iwt],\n0.0f);\n- rgb_min = min(texel_datum, rgb_min);\n- rgb_max = max(texel_datum, rgb_max);\npartition_weight += weight;\nbase_sum += texel_datum * weight;\nerror_sum += error_weight;\n@@ -226,8 +222,7 @@ void compute_avgs_and_dirs_3_comp(\npm[partition].avg = average * csf;\npm[partition].color_scale = csf;\npm[partition].icolor_scale = 1.0f / max(csf, 1e-7f);\n- vfloat4 range = max(rgb_max - rgb_min, 1e-10f);\n- pm[partition].range_sq = range * range;\n+ pm[partition].range_sq = vfloat4::zero();\nvfloat4 sum_xp = vfloat4::zero();\nvfloat4 sum_yp = vfloat4::zero();\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -419,8 +419,8 @@ static void compute_ideal_colors_and_weights_3_comp(\nvfloat4 ep0 = lines[i].a + lines[i].b * lowparam[i];\nvfloat4 ep1 = lines[i].a + lines[i].b * highparam[i];\n- ep0 = ep0 / pms[i].color_scale;\n- ep1 = ep1 / pms[i].color_scale;\n+ ep0 = ep0 * pms[i].icolor_scale;\n+ ep1 = ep1 * pms[i].icolor_scale;\nvfloat4 bmin = blk.data_min;\nvfloat4 bmax = blk.data_max;\n@@ -565,8 +565,8 @@ static void compute_ideal_colors_and_weights_4_comp(\nvfloat4 ep0 = lines[i].a + lines[i].b * lowparam[i];\nvfloat4 ep1 = lines[i].a + lines[i].b * highparam[i];\n- ei.ep.endpt0[i] = ep0 / pms[i].color_scale;\n- ei.ep.endpt1[i] = ep1 / pms[i].color_scale;\n+ ei.ep.endpt0[i] = ep0 * pms[i].icolor_scale;\n+ ei.ep.endpt1[i] = ep1 * pms[i].icolor_scale;\n}\nbool is_constant_wes = true;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove min/max from compute_avgs_and_dirs_3_comp
61,745
19.06.2021 20:10:48
-3,600
30abdf0a0279379458ca4770a23cc5f79a25be5e
Remove obsolete range_sq and computation of it
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -40,8 +40,6 @@ void compute_avgs_and_dirs_4_comp(\nvfloat4 error_sum = vfloat4::zero();\nvfloat4 base_sum = vfloat4::zero();\n- vfloat4 rgba_min(1e38f);\n- vfloat4 rgba_max(-1e38f);\nfloat partition_weight = 0.0f;\nunsigned int texel_count = pi.partition_texel_count[partition];\n@@ -54,9 +52,6 @@ void compute_avgs_and_dirs_4_comp(\nvfloat4 texel_datum = blk.texel(iwt);\nvfloat4 error_weight = ewb.error_weights[iwt];\n- rgba_min = min(texel_datum, rgba_min);\n- rgba_max = max(texel_datum, rgba_max);\n-\npartition_weight += weight;\nbase_sum += texel_datum * weight;\nerror_sum += error_weight;\n@@ -71,8 +66,6 @@ void compute_avgs_and_dirs_4_comp(\npm[partition].avg = average * csf;\npm[partition].color_scale = csf;\npm[partition].icolor_scale = 1.0f / max(csf, 1e-7f);\n- vfloat4 range = max(rgba_max - rgba_min, 1e-10f);\n- pm[partition].range_sq = range * range;\nvfloat4 sum_xp = vfloat4::zero();\nvfloat4 sum_yp = vfloat4::zero();\n@@ -222,7 +215,6 @@ void compute_avgs_and_dirs_3_comp(\npm[partition].avg = average * csf;\npm[partition].color_scale = csf;\npm[partition].icolor_scale = 1.0f / max(csf, 1e-7f);\n- pm[partition].range_sq = vfloat4::zero();\nvfloat4 sum_xp = vfloat4::zero();\nvfloat4 sum_yp = vfloat4::zero();\n@@ -289,8 +281,6 @@ void compute_avgs_and_dirs_3_comp_rgb(\nvfloat4 error_sum = vfloat4::zero();\nvfloat4 base_sum = vfloat4::zero();\n- vfloat4 rgb_min(1e38f);\n- vfloat4 rgb_max(-1e38f);\nfloat partition_weight = 0.0f;\nunsigned int texel_count = pi.partition_texel_count[partition];\n@@ -308,8 +298,6 @@ void compute_avgs_and_dirs_3_comp_rgb(\newb.texel_weight_b[iwt],\n0.0f);\n- rgb_min = min(texel_datum, rgb_min);\n- rgb_max = max(texel_datum, rgb_max);\npartition_weight += weight;\nbase_sum += texel_datum * weight;\nerror_sum += error_weight;\n@@ -324,8 +312,6 @@ void compute_avgs_and_dirs_3_comp_rgb(\npm[partition].avg = average * csf;\npm[partition].color_scale = csf;\npm[partition].icolor_scale = 1.0f / max(csf, 1e-7f);\n- vfloat4 range = max(rgb_max - rgb_min, 1e-10f);\n- pm[partition].range_sq = range * range;\nvfloat4 sum_xp = vfloat4::zero();\nvfloat4 sum_yp = vfloat4::zero();\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -457,9 +457,6 @@ static inline unsigned int get_quant_level(quant_method method)\n*/\nstruct partition_metrics\n{\n- /** @brief The square of the color range (max - min) spanned by texels in this partition. */\n- vfloat4 range_sq;\n-\n/** @brief The sum of the error weights for texels in this partition. */\nvfloat4 error_weight;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove obsolete range_sq and computation of it
61,745
19.06.2021 20:25:21
-3,600
32e87ddde23ae5abf673a80dd69a9277476db675
Simplify params for compute_partition_error_color_weightings
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -31,6 +31,7 @@ void compute_avgs_and_dirs_4_comp(\nconst error_weight_block& ewb,\npartition_metrics pm[BLOCK_MAX_PARTITIONS]\n) {\n+ // TODO: Candidate for 4-group counting\nint partition_count = pi.partition_count;\npromise(partition_count > 0);\n@@ -131,6 +132,7 @@ void compute_avgs_and_dirs_3_comp(\nunsigned int omitted_component,\npartition_metrics pm[BLOCK_MAX_PARTITIONS]\n) {\n+ // TODO: Candidate for 4-group counting\nconst float *texel_weights = ewb.texel_weight_rgb;\nconst float* data_vr = blk.data_r;\n@@ -272,6 +274,7 @@ void compute_avgs_and_dirs_3_comp_rgb(\nconst error_weight_block& ewb,\npartition_metrics pm[BLOCK_MAX_PARTITIONS]\n) {\n+ // TODO: Candidate for 4-group counting\nunsigned int partition_count = pi.partition_count;\npromise(partition_count > 0);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "*\n* @param ewb The block error weights.\n* @param pi The partiion info.\n- * @param[out] pm The output metrics; only writes to @c error_weight field.\n+ * @param[out] error_weights The output per-partition error_weight sum.\n*/\nstatic void compute_partition_error_color_weightings(\nconst error_weight_block& ewb,\nconst partition_info& pi,\n- partition_metrics pm[BLOCK_MAX_PARTITIONS]\n+ vfloat4 error_weights[BLOCK_MAX_PARTITIONS]\n) {\n+ // TODO: Candidate for 4-group counting\nint partition_count = pi.partition_count;\npromise(partition_count > 0);\n@@ -76,11 +77,10 @@ static void compute_partition_error_color_weightings(\nfor (int j = 0; j < texel_count; j++)\n{\nint tidx = pi.texels_of_partition[i][j];\n- error_weight = error_weight + ewb.error_weights[tidx];\n+ error_weight += ewb.error_weights[tidx];\n}\n- error_weight = error_weight / pi.partition_texel_count[i];\n- pm[i].error_weight = error_weight;\n+ error_weights[i] = error_weight / pi.partition_texel_count[i];\n}\n}\n@@ -1123,9 +1123,9 @@ unsigned int compute_ideal_endpoint_formats(\ncompute_encoding_choice_errors(bsd, blk, pi, ewb, ep, eci);\n// For each partition, compute the error weights to apply for that partition\n- partition_metrics pms[BLOCK_MAX_PARTITIONS];\n+ vfloat4 error_weights[BLOCK_MAX_PARTITIONS];\n- compute_partition_error_color_weightings(ewb, pi, pms);\n+ compute_partition_error_color_weightings(ewb, pi, error_weights);\nfloat best_error[BLOCK_MAX_PARTITIONS][21][4];\nint format_of_choice[BLOCK_MAX_PARTITIONS][21][4];\n@@ -1133,7 +1133,7 @@ unsigned int compute_ideal_endpoint_formats(\n{\ncompute_color_error_for_every_integer_count_and_quant_level(\nencode_hdr_rgb, encode_hdr_alpha, i,\n- pi, eci[i], ep, pms[i].error_weight, best_error[i],\n+ pi, eci[i], ep, error_weights[i], best_error[i],\nformat_of_choice[i]);\n}\n@@ -1146,7 +1146,7 @@ unsigned int compute_ideal_endpoint_formats(\n// that will never be picked as best candidate\nconst int packed_mode_count = bsd.block_mode_count;\nconst int packed_mode_count_simd_up = round_up_to_simd_multiple_vla(packed_mode_count);\n- for (int i = packed_mode_count; i < packed_mode_count_simd_up; ++i)\n+ for (int i = packed_mode_count; i < packed_mode_count_simd_up; i++)\n{\nerrors_of_best_combination[i] = ERROR_CALC_DEFAULT;\nbest_quant_levels[i] = QUANT_2;\n@@ -1181,7 +1181,6 @@ unsigned int compute_ideal_endpoint_formats(\ntwo_partitions_find_best_combination_for_every_quantization_and_integer_count(\nbest_error, format_of_choice, combined_best_error, formats_of_choice);\n-\nfor (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n{\nif (qwt_errors[i] >= ERROR_CALC_DEFAULT)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Simplify params for compute_partition_error_color_weightings
61,745
19.06.2021 22:02:02
-3,600
f91dd1a6211b503969be90e23c8eca58eeab27c2
Re-add code to force high to be > low ...
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -988,6 +988,14 @@ void compute_quantized_weights_for_decimation(\nfloat quant_level_m1 = quant_levels_m1[quant_level];\n// Quantize the weight set using both the specified low/high bounds and standard 0..1 bounds\n+\n+ /* TODO: WTF issue that we need to examine some time. */\n+ if (!((high_bound - low_bound) > 0.5f))\n+ {\n+ low_bound = 0.0f;\n+ high_bound = 1.0f;\n+ }\n+\nassert(high_bound > low_bound);\nfloat rscale = high_bound - low_bound;\nfloat scale = 1.0f / rscale;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Re-add code to force high to be > low ...
61,745
19.06.2021 22:11:34
-3,600
1205d61135d65fef6dbbe6d9b08d9690dd438734
Improve code to force high to be > low
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -989,14 +989,13 @@ void compute_quantized_weights_for_decimation(\n// Quantize the weight set using both the specified low/high bounds and standard 0..1 bounds\n- /* TODO: WTF issue that we need to examine some time. */\n- if (!((high_bound - low_bound) > 0.5f))\n+ /* TODO: WTF issue that we need to examine some time. Triggered by test in issue #265. */\n+ if (high_bound < low_bound)\n{\nlow_bound = 0.0f;\nhigh_bound = 1.0f;\n}\n- assert(high_bound > low_bound);\nfloat rscale = high_bound - low_bound;\nfloat scale = 1.0f / rscale;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Improve code to force high to be > low
61,745
19.06.2021 22:19:25
-3,600
898a7a1726d5d375c358cdac0c813875c42c6202
Use count for always blocks, not flag
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes.cpp", "new_path": "Source/astcenc_block_sizes.cpp", "diff": "@@ -801,7 +801,6 @@ static int construct_dt_entry_2d(\n// Default to not enabled - we'll populate these based on active block modes\nbsd.decimation_modes[dm_index].percentile_hit = false;\n- bsd.decimation_modes[dm_index].percentile_always = false;\nbsd.decimation_tables[dm_index] = di;\n@@ -852,6 +851,8 @@ static void construct_block_size_descriptor_2d(\n// Construct the list of block formats referencing the decimation tables\nunsigned int packed_idx = 0;\n+ unsigned int always_block_mode_count = 0;\n+ unsigned int always_decimation_mode_count = 0;\n// Iterate twice; first time keep the \"always\" blocks, second time keep the \"non-always\" blocks.\n// This ensures that the always block modes and decimation modes are at the start of the list.\n@@ -909,28 +910,30 @@ static void construct_block_size_descriptor_2d(\n{\ndecimation_mode = construct_dt_entry_2d(x_texels, y_texels, x_weights, y_weights, bsd);\ndecimation_mode_index[y_weights * 16 + x_weights] = decimation_mode;\n+\n+ #if !defined(ASTCENC_DECOMPRESS_ONLY)\n+ if (percentile == 0.0f)\n+ {\n+ always_decimation_mode_count++;\n+ }\n+ #endif\n}\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\n// Flatten the block mode heuristic into some precomputed flags\nif (percentile == 0.0f)\n{\n- bsd.block_modes[packed_idx].percentile_always = true;\n- bsd.decimation_modes[decimation_mode].percentile_always = true;\n-\n+ always_block_mode_count++;\nbsd.block_modes[packed_idx].percentile_hit = true;\nbsd.decimation_modes[decimation_mode].percentile_hit = true;\n}\nelse if (percentile <= mode_cutoff)\n{\n- bsd.block_modes[packed_idx].percentile_always = false;\n-\nbsd.block_modes[packed_idx].percentile_hit = true;\nbsd.decimation_modes[decimation_mode].percentile_hit = true;\n}\nelse\n{\n- bsd.block_modes[packed_idx].percentile_always = false;\nbsd.block_modes[packed_idx].percentile_hit = false;\n}\n#endif\n@@ -945,6 +948,11 @@ static void construct_block_size_descriptor_2d(\n}\nbsd.block_mode_count = packed_idx;\n+ bsd.always_block_mode_count = always_block_mode_count;\n+ bsd.always_decimation_mode_count = always_decimation_mode_count;\n+\n+ assert(bsd.always_block_mode_count > 0);\n+ assert(bsd.always_decimation_mode_count > 0);\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\ndelete[] percentiles;\n@@ -956,7 +964,6 @@ static void construct_block_size_descriptor_2d(\nbsd.decimation_modes[i].maxprec_1plane = -1;\nbsd.decimation_modes[i].maxprec_2planes = -1;\nbsd.decimation_modes[i].percentile_hit = false;\n- bsd.decimation_modes[i].percentile_always = false;\nbsd.decimation_tables[i] = nullptr;\n}\n@@ -1039,7 +1046,6 @@ static void construct_block_size_descriptor_3d(\nbsd.decimation_modes[decimation_mode_count].maxprec_1plane = static_cast<int8_t>(maxprec_1plane);\nbsd.decimation_modes[decimation_mode_count].maxprec_2planes = static_cast<int8_t>(maxprec_2planes);\nbsd.decimation_modes[decimation_mode_count].percentile_hit = false;\n- bsd.decimation_modes[decimation_mode_count].percentile_always = false;\nbsd.decimation_tables[decimation_mode_count] = di;\ndecimation_mode_count++;\n}\n@@ -1052,11 +1058,11 @@ static void construct_block_size_descriptor_3d(\nbsd.decimation_modes[i].maxprec_1plane = -1;\nbsd.decimation_modes[i].maxprec_2planes = -1;\nbsd.decimation_modes[i].percentile_hit = false;\n- bsd.decimation_modes[i].percentile_always = false;\nbsd.decimation_tables[i] = nullptr;\n}\nbsd.decimation_mode_count = decimation_mode_count;\n+ bsd.always_decimation_mode_count = 1;\n// Construct the list of block formats\nunsigned int packed_idx = 0;\n@@ -1093,9 +1099,7 @@ static void construct_block_size_descriptor_3d(\n// No percentile table, so enable everything all the time ...\nbsd.block_modes[packed_idx].percentile_hit = true;\n- bsd.block_modes[packed_idx].percentile_always = true;\nbsd.decimation_modes[decimation_mode].percentile_hit = true;\n- bsd.decimation_modes[decimation_mode].percentile_always = true;\nbsd.block_mode_packed_index[i] = static_cast<uint16_t>(packed_idx);\n@@ -1103,6 +1107,10 @@ static void construct_block_size_descriptor_3d(\n}\nbsd.block_mode_count = packed_idx;\n+ bsd.always_block_mode_count = 1;\n+\n+ assert(bsd.always_block_mode_count > 0);\n+ assert(bsd.always_decimation_mode_count > 0);\n// Determine the texels to use for kmeans clustering.\nassign_kmeans_texels(bsd);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -271,14 +271,12 @@ static float compress_symbolic_block_for_partition_1plane(\nuint8_t *dec_weights_quant_pvalue = tmpbuf.dec_weights_quant_pvalue;\n// For each decimation mode, compute an ideal set of weights with no quantization\n- for (unsigned int i = 0; i < bsd.decimation_mode_count; i++)\n+ unsigned int max_decimation_modes = only_always ? bsd.always_decimation_mode_count\n+ : bsd.decimation_mode_count;\n+ promise(max_decimation_modes > 0);\n+ for (unsigned int i = 0; i < max_decimation_modes; i++)\n{\nconst auto& dm = bsd.get_decimation_mode(i);\n- if (only_always && !dm.percentile_always)\n- {\n- break;\n- }\n-\nif (dm.maxprec_1plane < 0 || !dm.percentile_hit)\n{\ncontinue;\n@@ -330,14 +328,12 @@ static float compress_symbolic_block_for_partition_1plane(\nqwt_errors[i] = 1e38f;\n}\n- for (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n+ unsigned int max_block_modes = only_always ? bsd.always_block_mode_count\n+ : bsd.block_mode_count;\n+ promise(max_block_modes > 0);\n+ for (unsigned int i = 0; i < max_block_modes; ++i)\n{\nconst block_mode& bm = bsd.block_modes[i];\n- if (only_always && !bm.percentile_always)\n- {\n- break;\n- }\n-\nif (bm.is_dual_plane || !bm.percentile_hit)\n{\ncontinue;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -610,9 +610,6 @@ struct block_mode\n/** @brief Is this mode enabled in the current search preset? */\nuint8_t percentile_hit : 1;\n- /** @brief Is this mode enabled for early fast-path searches in the current search preset? */\n- uint8_t percentile_always : 1;\n-\n/**\n* @brief Get the weight quantization used by this block mode.\n*\n@@ -636,10 +633,7 @@ struct decimation_mode\nint8_t maxprec_2planes;\n/** @brief Is this mode enabled in the current search preset? */\n- uint8_t percentile_hit : 1;\n-\n- /** @brief Is this mode enabled for early fast-path searches in the current search preset? */\n- uint8_t percentile_always : 1;\n+ uint8_t percentile_hit;\n};\n/**\n@@ -678,9 +672,23 @@ struct block_size_descriptor\n/** @brief The number of stored decimation modes. */\nunsigned int decimation_mode_count;\n+ /**\n+ * @brief The number of stored decimation modes which are \"always\" modes.\n+ *\n+ * Always modes are stored at the start of the decimation_modes list.\n+ */\n+ unsigned int always_decimation_mode_count;\n+\n/** @brief The number of stored block modes. */\nunsigned int block_mode_count;\n+ /**\n+ * @brief The number of stored block modes which are \"always\" modes.\n+ *\n+ * Always modes are stored at the start of the block_modes list.\n+ */\n+ unsigned int always_block_mode_count;\n+\n/** @brief The active decimation modes, stored in low indices. */\ndecimation_mode decimation_modes[WEIGHTS_MAX_DECIMATION_MODES];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -520,15 +520,12 @@ void compute_angular_endpoints_1plane(\nfloat low_values[WEIGHTS_MAX_DECIMATION_MODES][12];\nfloat high_values[WEIGHTS_MAX_DECIMATION_MODES][12];\n- promise(bsd.decimation_mode_count > 0);\n- for (unsigned int i = 0; i < bsd.decimation_mode_count; i++)\n+ unsigned int max_decimation_modes = only_always ? bsd.always_decimation_mode_count\n+ : bsd.decimation_mode_count;\n+ promise(max_decimation_modes > 0);\n+ for (unsigned int i = 0; i < max_decimation_modes; i++)\n{\nconst decimation_mode& dm = bsd.decimation_modes[i];\n- if (only_always && !dm.percentile_always)\n- {\n- break;\n- }\n-\nif (dm.maxprec_1plane < 0 || !dm.percentile_hit)\n{\ncontinue;\n@@ -554,15 +551,12 @@ void compute_angular_endpoints_1plane(\n}\n}\n- promise(bsd.block_mode_count > 0);\n- for (unsigned int i = 0; i < bsd.block_mode_count; ++i)\n+ unsigned int max_block_modes = only_always ? bsd.always_block_mode_count\n+ : bsd.block_mode_count;\n+ promise(max_block_modes > 0);\n+ for (unsigned int i = 0; i < max_block_modes; ++i)\n{\nconst block_mode& bm = bsd.block_modes[i];\n- if (only_always && !bm.percentile_always)\n- {\n- break;\n- }\n-\nif (bm.is_dual_plane || !bm.percentile_hit)\n{\ncontinue;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use count for always blocks, not flag
61,745
20.06.2021 00:05:24
-3,600
98356da676bed790f133039419132a838a58c675
Improve debug logs for search failures
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -65,6 +65,10 @@ static const unsigned int quantization_steps_for_level[13] {\nalignas(ASTCENC_VECALIGN) static float sin_table[SINCOS_STEPS][ANGULAR_STEPS];\nalignas(ASTCENC_VECALIGN) static float cos_table[SINCOS_STEPS][ANGULAR_STEPS];\n+#if !defined(NDEBUG)\n+ static bool print_once { true };\n+#endif\n+\n/* See header for documentation. */\nvoid prepare_angular_tables()\n{\n@@ -327,9 +331,10 @@ static void compute_angular_endpoints_for_quant_levels(\n// Did we find anything?\n#if !defined(NDEBUG)\n- if (bsi < 0)\n+ if ((bsi < 0) && print_once)\n{\n- printf(\"WARNING: Unable to find encoding within specified error limit\\n\");\n+ print_once = false;\n+ printf(\"WARNING: Unable to find full encoding within search error limit\\n\\n\");\n}\n#endif\n@@ -491,9 +496,10 @@ static void compute_angular_endpoints_for_quant_levels_lwc(\n// Did we find anything?\n#if !defined(NDEBUG)\n- if (bsi < 0)\n+ if ((bsi < 0) && print_once)\n{\n- printf(\"WARNING: Unable to find encoding within specified error limit\\n\");\n+ print_once = false;\n+ printf(\"WARNING: Unable to find low weight encoding within search error limit\\n\\n\");\n}\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Improve debug logs for search failures
61,745
21.06.2021 10:19:12
-3,600
ee9fdc21e1bce964a639d7588e9fbe6fcdcb2f4c
Rename MODE0 fast path control
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1431,7 +1431,7 @@ void compress_block(\nstatic const float errorval_overshoot = 1.0f / ctx.config.tune_refinement_mse_overshoot;\n- int start_trial = bsd->texel_count < (int)TUNE_MAX_TEXELS_MODE0_FASTPATH ? 1 : 0;\n+ int start_trial = bsd->texel_count < TUNE_MIN_TEXELS_MODE0_FASTPATH ? 1 : 0;\nfor (int i = start_trial; i < 2; i++)\n{\nTRACE_NODE(node1, \"pass\");\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -115,11 +115,11 @@ static constexpr unsigned int WEIGHTS_MAX_DECIMATION_MODES { 87 };\nstatic constexpr float ERROR_CALC_DEFAULT { 1e30f };\n/**\n- * @brief The max texel count in a block which can try the one partition fast path.\n+ * @brief The minimum texel count for a block to use the one partition fast path.\n*\n- * This is enabled for 4x4 and 5x4 block sizes.\n+ * This setting skips 4x4 and 5x4 block sizes.\n*/\n-static constexpr unsigned int TUNE_MAX_TEXELS_MODE0_FASTPATH { 24 };\n+static constexpr unsigned int TUNE_MIN_TEXELS_MODE0_FASTPATH { 24 };\n/**\n* @brief The maximum number of candidate encodings tested for each encoding mode..\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Rename MODE0 fast path control
61,745
21.06.2021 13:44:38
-3,600
fdbd5cf85f7d00d24343cf23179a6da4bb306dfb
Skip MODE0 fast path for 3D textures
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes.cpp", "new_path": "Source/astcenc_block_sizes.cpp", "diff": "@@ -1062,7 +1062,6 @@ static void construct_block_size_descriptor_3d(\n}\nbsd.decimation_mode_count = decimation_mode_count;\n- bsd.always_decimation_mode_count = 1;\n// Construct the list of block formats\nunsigned int packed_idx = 0;\n@@ -1107,10 +1106,10 @@ static void construct_block_size_descriptor_3d(\n}\nbsd.block_mode_count = packed_idx;\n- bsd.always_block_mode_count = 1;\n- assert(bsd.always_block_mode_count > 0);\n- assert(bsd.always_decimation_mode_count > 0);\n+ // These are never used = the MODE0 fast path is skipped for 3D blocks\n+ bsd.always_block_mode_count = 0;\n+ bsd.always_decimation_mode_count = 0;\n// Determine the texels to use for kmeans clustering.\nassign_kmeans_texels(bsd);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1431,7 +1431,12 @@ void compress_block(\nstatic const float errorval_overshoot = 1.0f / ctx.config.tune_refinement_mse_overshoot;\n- int start_trial = bsd->texel_count < TUNE_MIN_TEXELS_MODE0_FASTPATH ? 1 : 0;\n+ int start_trial = 1;\n+ if ((bsd->texel_count < TUNE_MIN_TEXELS_MODE0_FASTPATH) && (bsd->zdim > 1))\n+ {\n+ start_trial = 0;\n+ }\n+\nfor (int i = start_trial; i < 2; i++)\n{\nTRACE_NODE(node1, \"pass\");\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Skip MODE0 fast path for 3D textures
61,745
21.06.2021 21:29:10
-3,600
4601741ce8c000183b23b38aa18fba5c80b15183
Remove TODOs that have been checked
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -246,7 +246,6 @@ void fetch_image_block(\n}\n// Reverse the encoding so we store origin block in the original format\n- // TODO: Move this to when we consume it, as we rarely do?\nvfloat4 data_enc = blk.texel(0);\nvfloat4 data_enc_unorm = data_enc / 65535.0f;\nvfloat4 data_enc_lns = vfloat4::zero();\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1175,7 +1175,6 @@ struct symbolic_compressed_block\nuint8_t partition_count;\n/** @brief Non-zero if the color formats matched; valid for @c NONCONST blocks. */\n- // TODO: Do we need to store this?\nuint8_t color_formats_matched;\n/** @brief The plane 2 color component, or -1 if single plane; valid for @c NONCONST blocks. */\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove TODOs that have been checked
61,745
21.06.2021 22:59:52
-3,600
6ddbbfbb82901ae43ab08b6962c136bf3239db42
Remove old optimization TODOs that have been tried
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes.cpp", "new_path": "Source/astcenc_block_sizes.cpp", "diff": "@@ -863,7 +863,6 @@ static void construct_block_size_descriptor_2d(\nunsigned int x_weights, y_weights;\nbool is_dual_plane;\n- // TODO: Make this an enum? It's been validated.\nunsigned int quant_mode;\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -976,9 +976,6 @@ void expand_deblock_weights(\n* This approach creates relatively large error block tables, but it allows a very flexible level of\n* control over how specific texels and channels are prioritized by the compressor.\n*\n- * TODO: Inline the expand_deblock_weights here? The computation is cheap, and it would remove some\n- * memory allocation from the context, at the expense of recomputing per block.\n- *\n* @param ctx The compressor context and configuration.\n* @param image The input image information.\n* @param bsd The block size information.\n@@ -1035,7 +1032,6 @@ static float prepare_error_weight_block(\n// Compute derivative if we have any use of LNS\nif (any(lns_mask))\n{\n- // TODO: Can we avoid some of the multi-type translation?\nvfloat4 data = blk.texel(idx);\nvint4 datai = lns_to_sf16(float_to_int(data));\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -109,7 +109,6 @@ static inline vfloat4 decode_texel(\nvint4 color_lns = vint4::zero();\nvint4 color_unorm = vint4::zero();\n- // TODO: Why bounce this via fp16 first?\nif (any(lns_mask))\n{\ncolor_lns = lns_to_sf16(data);\n@@ -245,7 +244,6 @@ void decompress_symbolic_block(\n}\n}\n- // TODO: Skip this and add constant color transfer to img block?\nfor (unsigned int i = 0; i < bsd.texel_count; i++)\n{\nblk.data_r[i] = color.lane<0>();\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -800,7 +800,6 @@ astcenc_error astcenc_context_alloc(\n*context = ctx;\n- // TODO: Currently static memory; should move to context memory\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\nprepare_angular_tables();\n#endif\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -425,7 +425,6 @@ static void compute_ideal_colors_and_weights_3_comp(\nvfloat4 bmin = blk.data_min;\nvfloat4 bmax = blk.data_max;\n- // TODO: Probably a programmatic vector permute we can do here ...\nassert(omitted_component < BLOCK_MAX_COMPONENTS);\nswitch (omitted_component)\n{\n@@ -833,7 +832,6 @@ void compute_ideal_weights_for_decimation(\nunsigned int texel_count_simd = round_up_to_simd_multiple_vla(texel_count);\nif (texel_count == weight_count)\n{\n- // TODO: Use SIMD copies?\nfor (unsigned int i = 0; i < texel_count_simd; i++)\n{\n// Assert it's an identity map for valid texels, and last valid value for any overspill\n@@ -989,7 +987,7 @@ void compute_quantized_weights_for_decimation(\n// Quantize the weight set using both the specified low/high bounds and standard 0..1 bounds\n- /* TODO: WTF issue that we need to examine some time. Triggered by test in issue #265. */\n+ // TODO: Oddity to investigate; triggered by test in issue #265.\nif (high_bound < low_bound)\n{\nlow_bound = 0.0f;\n@@ -1167,7 +1165,6 @@ void recompute_ideal_colors_1plane(\nvfloat4 weight_weight_sum = vfloat4(1e-17f);\nfloat psum = 1e-17f;\n- // TODO: This loop has too many responsibilities, making it inefficient\nfor (int j = 0; j < texel_count; j++)\n{\nint tix = texel_indexes[j];\n@@ -1218,7 +1215,6 @@ void recompute_ideal_colors_1plane(\n}\n// Calculations specific to mode #7, the HDR RGB-scale mode\n- // TODO: Can we skip this for LDR textures?\nvfloat4 rgbq_sum = color_vec_x + color_vec_y;\nrgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));\n@@ -1369,7 +1365,6 @@ void recompute_ideal_colors_2planes(\nvfloat4 weight_weight_sum = vfloat4(1e-17f);\nfloat psum = 1e-17f;\n- // TODO: This loop has too many responsibilities, making it inefficient\nfor (int j = 0; j < texel_count; j++)\n{\nvfloat4 rgba = blk.texel(j);\n@@ -1438,7 +1433,6 @@ void recompute_ideal_colors_2planes(\n}\n// Calculations specific to mode #7, the HDR RGB-scale mode\n- // TODO: Can we skip this for LDR textures?\nvfloat4 rgbq_sum = color_vec_x + color_vec_y;\nrgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1356,7 +1356,6 @@ struct astcenc_context\navg_var_args avg_var_preprocess_args;\n/** @brief The per-texel deblocking weights for the current block size. */\n- // TODO: Move to the BSD?\nfloat deblock_weights[BLOCK_MAX_TEXELS];\n/** @brief The parallel manager for averages and variances computation. */\n@@ -1384,8 +1383,6 @@ struct astcenc_context\nFunctionality for managing block sizes and partition tables.\n============================================================================ */\n-// TODO: Make C++ constructor/destructor?\n-\n/**\n* @brief Populate the block size descriptor for the target block size.\n*\n@@ -2003,7 +2000,6 @@ float compute_error_of_weight_set_2planes(\n*\n* @return The actual endpoint mode used.\n*/\n-// TODO: Format as enum?\nuint8_t pack_color_endpoints(\nvfloat4 color0,\nvfloat4 color1,\n@@ -2026,7 +2022,6 @@ uint8_t pack_color_endpoints(\n* @param[out] output0 The output color for endpoint 0.\n* @param[out] output1 The output color for endpoint 1.\n*/\n-// TODO: Format as enum?\nvoid unpack_color_endpoints(\nastcenc_profile decode_mode,\nint format,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -159,7 +159,6 @@ static void compute_error_squared_rgb_single_partition(\nvfloat4 dist2 = rp2 - point;\nsamec_err += dot3_s(ews, dist2 * dist2);\n- // TODO - this is only used for HDR textures. Can we skip?\nfloat param3 = dot3_s(point, rgbl_pline.bs);\nvfloat4 rp3 = rgbl_pline.amod + param3 * rgbl_pline.bis;\nvfloat4 dist3 = rp3 - point;\n@@ -209,7 +208,6 @@ static void compute_encoding_choice_errors(\n{\npartition_metrics& pm = pms[i];\n- // TODO: Can we skip rgb_luma_lines for LDR images?\nline3 uncor_rgb_lines;\nline3 samec_rgb_lines; // for LDR-RGB-scale\nline3 rgb_luma_lines; // for HDR-RGB-scale\n@@ -249,7 +247,6 @@ static void compute_encoding_choice_errors(\nsamec_rgb_plines.bs = samec_rgb_lines.b * csf;\nsamec_rgb_plines.bis = samec_rgb_lines.b * icsf;\n- // TODO - this is only used for HDR textures. Can we skip?\nrgb_luma_plines.amod = (rgb_luma_lines.a - rgb_luma_lines.b * dot3(rgb_luma_lines.a, rgb_luma_lines.b)) * icsf;\nrgb_luma_plines.bs = rgb_luma_lines.b * csf;\nrgb_luma_plines.bis = rgb_luma_lines.b * icsf;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "@@ -442,7 +442,6 @@ static ASTCENC_SIMD_INLINE vint4 unorm16_to_sf16(vint4 p)\nvint4 lz = clz(p) - 16;\n#endif\n- // TODO: Could use AVX2 _mm_sllv_epi32() instead of p * 2^<shift>\np = p * two_to_the_n(lz + 1);\np = p & vint4(0xFFFF);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -283,7 +283,6 @@ static void compute_angular_endpoints_for_quant_levels(\n// Initialize the array to some safe defaults\npromise(max_quant_steps > 0);\n- // TODO: Why the + 4 in the current code?\nfor (unsigned int i = 0; i < (max_quant_steps + 4); i++)\n{\n// Lane<0> = Best error\n@@ -468,7 +467,6 @@ static void compute_angular_endpoints_for_quant_levels_lwc(\n// Initialize the array to some safe defaults\npromise(max_quant_steps > 0);\n- // TODO: Why the + 4 in the current code?\nfor (unsigned int i = 0; i < (max_quant_steps + 4); i++)\n{\nbest_error[i] = ERROR_CALC_DEFAULT;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_image.cpp", "new_path": "Source/astcenccli_image.cpp", "diff": "@@ -180,24 +180,10 @@ astcenc_image* astc_img_from_floatx4_array(\nunsigned int dim_y,\nbool y_flip\n) {\n- // TODO: Make this 32 to use direct passthough as float\nastcenc_image* img = alloc_image(16, dim_x, dim_y, 1);\nfor (unsigned int y = 0; y < dim_y; y++)\n{\n-#if 0\n- float*** data32 = static_cast<float***>(img->data);\n- unsigned int y_src = y_flip ? (dim_y - y - 1) : y;\n- const float* src = data + 4 * dim_x * y_src;\n-\n- for (unsigned int x = 0; x < dim_x; x++)\n- {\n- data32[0][y][4 * x ] = src[4 * x ];\n- data32[0][y][4 * x + 1] = src[4 * x + 1];\n- data32[0][y][4 * x + 2] = src[4 * x + 2];\n- data32[0][y][4 * x + 3] = src[4 * x + 3];\n- }\n-#else\nuint16_t* data16 = static_cast<uint16_t*>(img->data[0]);\nunsigned int y_src = y_flip ? (dim_y - y - 1) : y;\nconst float* src = data + 4 * dim_x * y_src;\n@@ -216,7 +202,6 @@ astcenc_image* astc_img_from_floatx4_array(\ndata16[(4 * dim_x * y) + (4 * x + 2)] = (uint16_t)colorf16.lane<2>();\ndata16[(4 * dim_x * y) + (4 * x + 3)] = (uint16_t)colorf16.lane<3>();\n}\n-#endif\n}\nreturn img;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -353,7 +353,6 @@ static astcenc_image* load_uncomp_file(\n{\nunsigned int dim_x = slices[0]->dim_x;\nunsigned int dim_y = slices[0]->dim_y;\n- // TODO: Make this 32 to use direct pass though as float\nint bitness = is_hdr ? 16 : 8;\nint slice_size = dim_x * dim_y;\n@@ -362,7 +361,6 @@ static astcenc_image* load_uncomp_file(\n// Combine 2D source images into one 3D image\nfor (unsigned int z = 0; z < dim_z; z++)\n{\n- // TODO: This is now a pointless copy, so don't do this ...\nif (image->data_type == ASTCENC_TYPE_U8)\n{\nuint8_t* data8 = static_cast<uint8_t*>(image->data[z]);\n@@ -1449,7 +1447,6 @@ int main(\n{\nif (ends_with(input_filename, \".astc\"))\n{\n- // TODO: Just pass on a std::string\nerror = load_cimage(input_filename.c_str(), image_comp);\nif (error)\n{\n@@ -1458,7 +1455,6 @@ int main(\n}\nelse if (ends_with(input_filename, \".ktx\"))\n{\n- // TODO: Just pass on a std::string\nbool is_srgb;\nerror = load_ktx_compressed_image(input_filename.c_str(), is_srgb, image_comp);\nif (error)\n@@ -1678,7 +1674,6 @@ int main(\nif (out_bitness == 0)\n{\nbool is_hdr = (config.profile == ASTCENC_PRF_HDR) || (config.profile == ASTCENC_PRF_HDR_RGB_LDR_A);\n- // TODO: Make this 32 to use direct passthrough as float\nout_bitness = is_hdr ? 16 : 8;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove old optimization TODOs that have been tried
61,745
22.06.2021 18:43:24
-3,600
8d7ac4dc84fc1af5da159f75f4513b84411ac9a1
Make search warnings INFO messages, as now expected
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -333,7 +333,7 @@ static void compute_angular_endpoints_for_quant_levels(\nif ((bsi < 0) && print_once)\n{\nprint_once = false;\n- printf(\"WARNING: Unable to find full encoding within search error limit\\n\\n\");\n+ printf(\"INFO: Unable to find full encoding within search error limit\\n\\n\");\n}\n#endif\n@@ -497,7 +497,7 @@ static void compute_angular_endpoints_for_quant_levels_lwc(\nif ((bsi < 0) && print_once)\n{\nprint_once = false;\n- printf(\"WARNING: Unable to find low weight encoding within search error limit\\n\\n\");\n+ printf(\"INFO: Unable to find low weight encoding within search error limit\\n\\n\");\n}\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make search warnings INFO messages, as now expected
61,757
23.06.2021 00:27:49
-3,600
f66638ada3845feb1e4fd14aec183f6a414a82e7
Remove aarch32|aarch32hf build support Also removes setting CMAKE_OSX_ARCHITECTURES explicitely to not mess with universal builds
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -35,7 +35,7 @@ function(printopt optName optVal optArch tgtArch)\nendif()\nendfunction()\n-set(VALID_ARCH aarch64 aarch32 aarch32hf x64)\n+set(VALID_ARCH aarch64 x64)\nset(ARCH x64 CACHE STRING \"Target architecture\")\nset_property(CACHE ARCH PROPERTY STRINGS ${VALID_ARCH})\n@@ -66,8 +66,8 @@ if(${ISA_SSE2} AND ${ARCH} MATCHES \"x64\")\nendif()\noption(ISA_NEON \"Enable builds for NEON SIMD\")\n-printopt(\"NEON\" ${ISA_NEON} \"aarch32|aarch32hf|aarch64\" ${ARCH})\n-if(${ISA_NEON} AND ${ARCH} MATCHES \"aarch32|aarch32hf|aarch64\")\n+printopt(\"NEON\" ${ISA_NEON} \"aarch64\" ${ARCH})\n+if(${ISA_NEON} AND ${ARCH} MATCHES \"aarch64\")\nset(ANY_ISA 1)\nendif()\n@@ -118,45 +118,6 @@ if(NOT ${ANY_ISA})\nmessage(FATAL_ERROR \"At least one backend ISA must be enabled\")\nendif()\n-\n-# Project configuration\n-\n-# Must be done after project() but before compiler settings\n-# or it gets overriden (this contradicts the official docs)\n-if(${ARCH} MATCHES \"aarch64\")\n- set(CMAKE_OSX_ARCHITECTURES \"arm64\")\n-\n-elseif(${ARCH} MATCHES \"aarch32|aarch32hf\")\n- # Deliberately use Armv7 for Clang - its most compatible with the current\n- # code; we provide some fallbacks for a few missing v8 intrinsics.\n- if(CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\")\n-\n- set(CMAKE_OSX_ARCHITECTURES \"armv7\")\n- set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -march=armv7-a\")\n- set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfpu=neon-vfpv4\")\n- set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument\")\n- set(CMAKE_CXX_FLAGS_RELEASE \"-O3\")\n-\n- # For GCC we directly target Armv8-A A32, and provide some emulated\n- # fallback intrinsics for functionality that exists for A64 but not A32.\n- elseif (CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\")\n- set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -march=armv8-a\")\n- set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfpu=neon-fp-armv8\")\n- set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfp16-format=ieee\")\n-\n- if(${ARCH} STREQUAL \"aarch32\") # arm-linux-gnueabi-g++\n- set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfloat-abi=softfp\")\n- elseif(${ARCH} STREQUAL \"aarch32hf\") # arm-linux-gnueabihf-g++\n- set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfloat-abi=hard\")\n- endif()\n-\n- # Workaround for Source/tinyexr.h:11025\n- set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-type-limits\")\n- endif()\n-else()\n- set(CMAKE_OSX_ARCHITECTURES \"x86_64\")\n-endif()\n-\nset(CMAKE_CXX_STANDARD 14)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n" }, { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "@@ -120,29 +120,6 @@ To enable this binary variant add `-DISA_NONE=ON` to the CMake command line\nwhen configuring. It is NOT recommended to use this for production; it is\nsignificantly slower than the vectorized SIMD builds.\n-### 32-bit Armv8 builds\n-\n-The build system includes support for building for Armv8 32-bit binaries on\n-Linux, using GCC 9.3 or higher, or Clang 9 or higher. The `aarch32` build uses\n-the soft-float ABI and `aarch32hf` uses the hard-float ABI.\n-\n-We tested these builds using the following cross-compilers on Ubuntu 20.04:\n-\n-* `aarch32`: arm-linux-gnueabi-g++-9 (v 9.3.0)\n-* `aarch32hf`: arm-linux-gnueabihf-g++-9 (v 9.3.0)\n-\n-```shell\n-# Arm aarch32 using the soft-float ABI\n-export CXX=arm-linux-gnueabi-g++-9\n-cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n- -DARCH=aarch32 -DISA_NEON=ON ..\n-\n-# Arm aarch32 using the hard-float ABI\n-export CXX=arm-linux-gnueabihf-g++-9\n-cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n- -DARCH=aarch32hf -DISA_NEON=ON ..\n-```\n-\n### Build Types\nWe support and test the following `CMAKE_BUILD_TYPE` options.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove aarch32|aarch32hf build support Also removes setting CMAKE_OSX_ARCHITECTURES explicitely to not mess with universal builds
61,757
23.06.2021 00:35:15
-3,600
45013b8206e30899b7ab4a14ec4db04016d8bd25
Add back CMAKE_OSX_ARCHITECTURES to enable cross builds
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -118,6 +118,19 @@ if(NOT ${ANY_ISA})\nmessage(FATAL_ERROR \"At least one backend ISA must be enabled\")\nendif()\n+\n+# Project configuration\n+\n+# Must be done after project() but before compiler settings\n+# or it gets overriden (this contradicts the official docs)\n+if(${ARCH} MATCHES \"aarch64\")\n+ set(CMAKE_OSX_ARCHITECTURES \"arm64\")\n+\n+elseif(${ARCH} MATCHES \"x86_64\")\n+ set(CMAKE_OSX_ARCHITECTURES \"x86_64\")\n+\n+endif()\n+\nset(CMAKE_CXX_STANDARD 14)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add back CMAKE_OSX_ARCHITECTURES to enable cross builds
61,757
23.06.2021 00:37:18
-3,600
123379694f579a5e29b8edbbe9e13cc406f7240e
Add else class to flag unsupported architectures
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -129,6 +129,9 @@ if(${ARCH} MATCHES \"aarch64\")\nelseif(${ARCH} MATCHES \"x86_64\")\nset(CMAKE_OSX_ARCHITECTURES \"x86_64\")\n+else()\n+ message(FATAL_ERROR \"Unsupported architecture\")\n+\nendif()\nset(CMAKE_CXX_STANDARD 14)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add else class to flag unsupported architectures
61,745
23.06.2021 09:45:42
-3,600
b755651d494fd443cff2c0416ecca49bbed3745d
Update builds to use explicit ARCH setting
[ { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "@@ -26,11 +26,11 @@ cd build\n# x86-64 using NMake\ncmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.\\ ^\n- -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n+ -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n# x86-64 using Visual Studio solution\ncmake -G \"Visual Studio 16 2019\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.\\ ^\n- -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n+ -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n```\n@@ -77,11 +77,11 @@ cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n# x86-64\ncmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n- -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n+ -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n# Host builds optimized for the local CPU's microarchitecture\ncmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n- -DISA_NATIVE=ON ..\n+ -DARCH=x64 -DISA_NATIVE=ON ..\n```\nThis example shows all SIMD variants being enabled. It is possible to build a\n" }, { "change_type": "MODIFY", "old_path": "jenkins/nightly.Jenkinsfile", "new_path": "jenkins/nightly.Jenkinsfile", "diff": "@@ -72,7 +72,7 @@ pipeline {\nsh '''\nmkdir build_rel\ncd build_rel\n- cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON -DISA_NONE=ON -DUNITTEST=ON ..\n+ cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON -DISA_NONE=ON -DUNITTEST=ON ..\nmake install package -j4\n'''\n}\n@@ -82,7 +82,7 @@ pipeline {\nsh '''\nmkdir build_dbg\ncd build_dbg\n- cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Debug -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON -DISA_NONE=ON ..\n+ cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Debug -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON -DISA_NONE=ON ..\nmake -j4\n'''\n}\n@@ -127,7 +127,7 @@ pipeline {\ncall c:\\\\progra~2\\\\micros~1\\\\2019\\\\buildtools\\\\vc\\\\auxiliary\\\\build\\\\vcvars64.bat\nmkdir build_rel\ncd build_rel\n- cmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n+ cmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\nnmake install package\n'''\n}\n@@ -138,7 +138,7 @@ pipeline {\ncall c:\\\\progra~2\\\\micros~1\\\\2019\\\\buildtools\\\\vc\\\\auxiliary\\\\build\\\\vcvars64.bat\nmkdir build_dbg\ncd build_dbg\n- cmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Debug -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON -DISA_NONE=ON ..\n+ cmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Debug -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON -DISA_NONE=ON ..\nnmake\n'''\n}\n@@ -176,7 +176,7 @@ pipeline {\nsh '''\nmkdir build_rel\ncd build_rel\n- cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n+ cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\nmake install package -j4\n'''\n}\n@@ -186,7 +186,7 @@ pipeline {\nsh '''\nmkdir build_dbg\ncd build_dbg\n- cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Debug -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON -DISA_NONE=ON ..\n+ cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Debug -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON -DISA_NONE=ON ..\nmake -j4\n'''\n}\n" }, { "change_type": "MODIFY", "old_path": "jenkins/release.Jenkinsfile", "new_path": "jenkins/release.Jenkinsfile", "diff": "@@ -73,7 +73,7 @@ spec:\nmkdir build_cov\ncd build_cov\n- cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DISA_AVX2=ON ..\n+ cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DARCH=x64 -DISA_AVX2=ON ..\ncov-configure --template --compiler cc --comptype gcc\ncov-configure --template --compiler c++ --comptype g++\n@@ -133,7 +133,7 @@ spec:\nexport CXX=clang++-9\nmkdir build_rel\ncd build_rel\n- cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON -DISA_NONE=ON ..\n+ cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON -DISA_NONE=ON ..\nmake install package -j4\n'''\n}\n@@ -144,7 +144,7 @@ spec:\nexport CXX=clang++-9\nmkdir build_reldec\ncd build_reldec\n- cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON -DISA_NONE=ON -DDECOMPRESSOR=ON ..\n+ cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON -DISA_NONE=ON -DDECOMPRESSOR=ON ..\nmake -j4\n'''\n}\n@@ -184,7 +184,7 @@ spec:\ncall c:\\\\progra~2\\\\micros~1\\\\2019\\\\buildtools\\\\vc\\\\auxiliary\\\\build\\\\vcvars64.bat\nmkdir build_rel\ncd build_rel\n- cmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n+ cmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\nnmake install package\n'''\n}\n@@ -223,7 +223,7 @@ spec:\nsh '''\nmkdir build_rel\ncd build_rel\n- cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n+ cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DARCH=x64 -DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\nmake install package -j1\n'''\n}\n@@ -278,7 +278,7 @@ spec:\nsh '''\nmkdir build_rel\ncd build_rel\n- cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DISA_NEON=ON -DARCH=aarch64 ..\n+ cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DARCH=aarch64 -DISA_NEON=ON ..\nmake install package -j1\n'''\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update builds to use explicit ARCH setting
61,745
23.06.2021 09:48:08
-3,600
a88feacde24a98425b988e1c9539b94d06a8593b
Remove armv7 NEON backend
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "#include <cstdio>\n-#if defined(__arm__)\n- #include \"astcenc_vecmathlib_neon_armv7_4.h\"\n-#endif\n-\n// ============================================================================\n// vfloat4 data type\n// ============================================================================\n" }, { "change_type": "DELETE", "old_path": "Source/astcenc_vecmathlib_neon_armv7_4.h", "new_path": null, "diff": "-// SPDX-License-Identifier: Apache-2.0\n-// ----------------------------------------------------------------------------\n-// Copyright 2021 Arm Limited\n-//\n-// Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n-// use this file except in compliance with the License. You may obtain a copy\n-// of the License at:\n-//\n-// http://www.apache.org/licenses/LICENSE-2.0\n-//\n-// Unless required by applicable law or agreed to in writing, software\n-// distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n-// License for the specific language governing permissions and limitations\n-// under the License.\n-// ----------------------------------------------------------------------------\n-\n-/**\n- * @brief Intrinsics for Armv7 NEON.\n- *\n- * This module implements a few Armv7-compatible intrinsics indentical to Armv8\n- * ones. Thus, astcenc can be compiled using Armv7 architecture.\n- */\n-\n-#ifndef ASTC_VECMATHLIB_NEON_ARMV7_4_H_INCLUDED\n-#define ASTC_VECMATHLIB_NEON_ARMV7_4_H_INCLUDED\n-\n-#ifndef ASTCENC_SIMD_INLINE\n- #error \"Include astcenc_vecmathlib.h, do not include directly\"\n-#endif\n-\n-#include <algorithm>\n-#include <cfenv>\n-\n-\n-// arm-linux-gnueabi-gcc contains the following functions by using\n-// #pragma GCC target (\"fpu=neon-fp-armv8\"), while clang does not.\n-#if defined(__clang__)\n-\n-/**\n- * @brief Return the max vector of two vectors.\n- *\n- * If one vector element is numeric and the other is a quiet NaN,\n- * the result placed in the vector is the numerical value.\n- */\n-ASTCENC_SIMD_INLINE float32x4_t vmaxnmq_f32(float32x4_t a, float32x4_t b)\n-{\n- uint32x4_t amask = vceqq_f32(a, a);\n- uint32x4_t bmask = vceqq_f32(b, b);\n- a = vbslq_f32(amask, a, b);\n- b = vbslq_f32(bmask, b, a);\n- return vmaxq_f32(a, b);\n-}\n-\n-/**\n- * @brief Return the min vector of two vectors.\n- *\n- * If one vector element is numeric and the other is a quiet NaN,\n- * the result placed in the vector is the numerical value.\n- */\n-ASTCENC_SIMD_INLINE float32x4_t vminnmq_f32(float32x4_t a, float32x4_t b)\n-{\n- uint32x4_t amask = vceqq_f32(a, a);\n- uint32x4_t bmask = vceqq_f32(b, b);\n- a = vbslq_f32(amask, a, b);\n- b = vbslq_f32(bmask, b, a);\n- return vminq_f32(a, b);\n-}\n-\n-/**\n- * @brief Return a float rounded to the nearest integer value.\n- */\n-ASTCENC_SIMD_INLINE float32x4_t vrndnq_f32(float32x4_t a)\n-{\n- assert(std::fegetround() == FE_TONEAREST);\n- float a0 = std::nearbyintf(vgetq_lane_f32(a, 0));\n- float a1 = std::nearbyintf(vgetq_lane_f32(a, 1));\n- float a2 = std::nearbyintf(vgetq_lane_f32(a, 2));\n- float a3 = std::nearbyintf(vgetq_lane_f32(a, 3));\n- float32x4_t c { a0, a1, a2, a3 };\n- return c;\n-}\n-\n-#endif\n-\n-/**\n- * @brief Return the horizontal maximum of a vector.\n- */\n-ASTCENC_SIMD_INLINE float vmaxvq_f32(float32x4_t a)\n-{\n- float a0 = vgetq_lane_f32(a, 0);\n- float a1 = vgetq_lane_f32(a, 1);\n- float a2 = vgetq_lane_f32(a, 2);\n- float a3 = vgetq_lane_f32(a, 3);\n- return std::max(std::max(a0, a1), std::max(a2, a3));\n-}\n-\n-/**\n- * @brief Return the horizontal maximum of a vector.\n- */\n-ASTCENC_SIMD_INLINE float vminvq_f32(float32x4_t a)\n-{\n- float a0 = vgetq_lane_f32(a, 0);\n- float a1 = vgetq_lane_f32(a, 1);\n- float a2 = vgetq_lane_f32(a, 2);\n- float a3 = vgetq_lane_f32(a, 3);\n- return std::min(std::min(a0, a1), std::min(a2, a3));\n-}\n-\n-/**\n- * @brief Return the horizontal maximum of a vector.\n- */\n-ASTCENC_SIMD_INLINE int32_t vmaxvq_s32(int32x4_t a)\n-{\n- int32_t a0 = vgetq_lane_s32(a, 0);\n- int32_t a1 = vgetq_lane_s32(a, 1);\n- int32_t a2 = vgetq_lane_s32(a, 2);\n- int32_t a3 = vgetq_lane_s32(a, 3);\n- return std::max(std::max(a0, a1), std::max(a2, a3));\n-}\n-\n-/**\n- * @brief Return the horizontal maximum of a vector.\n- */\n-ASTCENC_SIMD_INLINE int32_t vminvq_s32(int32x4_t a)\n-{\n- int32_t a0 = vgetq_lane_s32(a, 0);\n- int32_t a1 = vgetq_lane_s32(a, 1);\n- int32_t a2 = vgetq_lane_s32(a, 2);\n- int32_t a3 = vgetq_lane_s32(a, 3);\n- return std::min(std::min(a0, a1), std::min(a2, a3));\n-}\n-\n-/**\n- * @brief Return the sqrt of the lanes in the vector.\n- */\n-ASTCENC_SIMD_INLINE float32x4_t vsqrtq_f32(float32x4_t a)\n-{\n- float a0 = std::sqrt(vgetq_lane_f32(a, 0));\n- float a1 = std::sqrt(vgetq_lane_f32(a, 1));\n- float a2 = std::sqrt(vgetq_lane_f32(a, 2));\n- float a3 = std::sqrt(vgetq_lane_f32(a, 3));\n- float32x4_t c { a0, a1, a2, a3 };\n- return c;\n-}\n-\n-/**\n- * @brief Vector by vector division.\n- */\n-ASTCENC_SIMD_INLINE float32x4_t vdivq_f32(float32x4_t a, float32x4_t b)\n-{\n- float a0 = vgetq_lane_f32(a, 0), b0 = vgetq_lane_f32(b, 0);\n- float a1 = vgetq_lane_f32(a, 1), b1 = vgetq_lane_f32(b, 1);\n- float a2 = vgetq_lane_f32(a, 2), b2 = vgetq_lane_f32(b, 2);\n- float a3 = vgetq_lane_f32(a, 3), b3 = vgetq_lane_f32(b, 3);\n- float32x4_t c { a0 / b0, a1 / b1, a2 / b2, a3 / b3 };\n- return c;\n-}\n-\n-/**\n- * @brief Table vector lookup.\n- */\n-ASTCENC_SIMD_INLINE int8x16_t vqtbl1q_s8(int8x16_t t, uint8x16_t idx)\n-{\n- int8x8x2_t tab;\n- tab.val[0] = vget_low_s8(t);\n- tab.val[1] = vget_high_s8(t);\n- int8x16_t id = vreinterpretq_s8_u8(idx);\n- return vcombine_s8(\n- vtbl2_s8(tab, vget_low_s8(id)),\n- vtbl2_s8(tab, vget_high_s8(id)));\n-}\n-\n-/**\n- * @brief Horizontal integer addition.\n- */\n-ASTCENC_SIMD_INLINE uint32_t vaddvq_u32(uint32x4_t a)\n-{\n- uint32_t a0 = vgetq_lane_u32(a, 0);\n- uint32_t a1 = vgetq_lane_u32(a, 1);\n- uint32_t a2 = vgetq_lane_u32(a, 2);\n- uint32_t a3 = vgetq_lane_u32(a, 3);\n- return a0 + a1 + a2 + a3;\n-}\n-\n-#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove armv7 NEON backend
61,757
25.06.2021 14:36:40
-3,600
335d167b688049266c39801e906c909b14aade31
Fix warning/error on iOS build
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_platform_dependents.cpp", "new_path": "Source/astcenccli_platform_dependents.cpp", "diff": "@@ -103,7 +103,7 @@ double get_time()\n/* See header for documentation */\nint get_cpu_count()\n{\n- return sysconf(_SC_NPROCESSORS_ONLN);\n+ return static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));\n}\n/* See header for documentation */\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix warning/error on iOS build (#269)
61,757
25.06.2021 14:55:06
-3,600
c5209d3f8e9c67b676d9315129c756e50f65811c
Add CLI=ON/OFF option
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -38,6 +38,7 @@ option(ISA_NONE \"Enable builds for no SIMD\")\noption(DECOMPRESSOR \"Enable builds for decompression only\")\noption(DIAGNOSTICS \"Enable builds for diagnostic trace\")\noption(UNITTEST \"Enable builds for unit tests\")\n+option(CLI \"Enable build of CLI\" ON)\nset(UNIVERSAL_BUILD OFF)\nset(MACOS_BUILD OFF)\n" }, { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "@@ -56,6 +56,7 @@ target_include_directories(${ASTC_TARGET}-static\nPUBLIC\n${CMAKE_CURRENT_SOURCE_DIR})\n+if (${CLI})\nadd_executable(${ASTC_TARGET}\nastcenccli_error_metrics.cpp\nastcenccli_image.cpp\n@@ -68,6 +69,7 @@ add_executable(${ASTC_TARGET}\ntarget_link_libraries(${ASTC_TARGET}\nPRIVATE\n${ASTC_TARGET}-static)\n+endif()\nmacro(astcenc_set_properties NAME)\n@@ -242,8 +244,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES \"GNU|Clang\")\nCOMPILE_FLAGS ${EXTERNAL_CXX_FLAGS})\nendif()\n-astcenc_set_properties(${ASTC_TARGET})\n-\nastcenc_set_properties(${ASTC_TARGET}-static)\n+if (${CLI})\n+ astcenc_set_properties(${ASTC_TARGET})\ninstall(TARGETS ${ASTC_TARGET} DESTINATION ${PACKAGE_ROOT})\n+endif()\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add CLI=ON/OFF option (#270)
61,757
28.06.2021 15:42:30
-3,600
9e9d79c4ef390f79cf0a9e0cfee3efd773ce30bd
Disable warning C4324: structure padding
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -20,6 +20,10 @@ cmake_minimum_required(VERSION 3.15)\ncmake_policy(SET CMP0069 NEW) # LTO support\ncmake_policy(SET CMP0091 NEW) # MSVC runtime support\n+if(MSVC)\n+ add_compile_options(\"/wd4324\") # Disable structure was padded due to alignment specifier\n+endif()\n+\nproject(astcencoder VERSION 3.0.0)\nset(CMAKE_CXX_STANDARD 14)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Disable warning C4324: structure padding (#271)
61,745
29.06.2021 14:51:49
-3,600
3d010359c33027c989a1c06e07e101ecc6007349
Disable softfloat in NEON builds
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "@@ -418,7 +418,7 @@ uint64_t rand(uint64_t state[2]);\n/* ============================================================================\nSoftfloat library with fp32 and fp16 conversion functionality.\n============================================================================ */\n-#if ASTCENC_F16C == 0\n+#if (ASTCENC_F16C == 0) && (ASTCENC_NEON == 0)\n/* narrowing float->float conversions */\nuint16_t float_to_sf16(float val);\nfloat sf16_to_float(uint16_t val);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib_softfloat.cpp", "new_path": "Source/astcenc_mathlib_softfloat.cpp", "diff": "/**\n* @brief Soft-float library for IEEE-754.\n*/\n-#if ASTCENC_F16C == 0\n+#if (ASTCENC_F16C == 0) && (ASTCENC_NEON == 0)\n#include \"astcenc_mathlib.h\"\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Disable softfloat in NEON builds
61,757
29.06.2021 17:13:26
-3,600
8e62178a1c71c376e223604bf74811f7c8b50f80
Hide optimisation options behind CLI option Don't force library and LTO settings when building as a library, as these may not be compatible with user code.
[ { "change_type": "MODIFY", "old_path": "Source/CMakeLists.txt", "new_path": "Source/CMakeLists.txt", "diff": "# Overwrite the LTO flags to force fat LTO; worth 3-4% performance\n# See https://gitlab.kitware.com/cmake/cmake/-/issues/16808\n-if(CMAKE_CXX_COMPILER_ID MATCHES \"GNU|Clang\")\n+if(CMAKE_CXX_COMPILER_ID MATCHES \"GNU|Clang\" AND ${CLI})\nset(CMAKE_CXX_COMPILE_OPTIONS_IPO \"-flto\")\nendif()\n" }, { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "@@ -134,6 +134,7 @@ macro(astcenc_set_properties NAME)\n# Use pthreads on Linux/macOS\n$<$<PLATFORM_ID:Linux,Darwin>:-pthread>)\n+ if (${CLI})\n# Enable LTO on release builds\nset_property(TARGET ${NAME}\nPROPERTY\n@@ -143,6 +144,7 @@ macro(astcenc_set_properties NAME)\nset_property(TARGET ${NAME}\nPROPERTY\nMSVC_RUNTIME_LIBRARY \"MultiThreaded$<$<CONFIG:Debug>:Debug>\")\n+ endif()\n# Set up configuration for SIMD ISA builds\nif(${ISA_SIMD} MATCHES \"none\")\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Hide optimisation options behind CLI option (#272) Don't force library and LTO settings when building as a library, as these may not be compatible with user code.
61,745
29.06.2021 17:18:31
-3,600
5706668c8246b9ec130b67f1fcd284be1d244e1e
CMake whitespace cleanup
[ { "change_type": "MODIFY", "old_path": "Source/CMakeLists.txt", "new_path": "Source/CMakeLists.txt", "diff": "# SPDX-License-Identifier: Apache-2.0\n# ----------------------------------------------------------------------------\n-# Copyright 2020 Arm Limited\n+# Copyright 2020-2021 Arm Limited\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n# use this file except in compliance with the License. You may obtain a copy\n" }, { "change_type": "MODIFY", "old_path": "Source/UnitTest/CMakeLists.txt", "new_path": "Source/UnitTest/CMakeLists.txt", "diff": "# SPDX-License-Identifier: Apache-2.0\n# ----------------------------------------------------------------------------\n-# Copyright 2020 Arm Limited\n+# Copyright 2020-2021 Arm Limited\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n# use this file except in compliance with the License. You may obtain a copy\n" }, { "change_type": "MODIFY", "old_path": "Source/UnitTest/cmake_core.cmake", "new_path": "Source/UnitTest/cmake_core.cmake", "diff": "# SPDX-License-Identifier: Apache-2.0\n# ----------------------------------------------------------------------------\n-# Copyright 2020 Arm Limited\n+# Copyright 2020-2021 Arm Limited\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n# use this file except in compliance with the License. You may obtain a copy\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
CMake whitespace cleanup
61,745
29.06.2021 18:11:57
-3,600
2003150070c13536908714bd6eb031e678d7a2ca
CMake configure_file propagates version
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "*/\n#include \"astcenccli_internal.h\"\n+#include \"astcenccli_version.h\"\n/** @brief The version header. */\nstatic const char *astcenc_copyright_string =\n-R\"(astcenc v3.0, %u-bit %s%s\n-Copyright 2011-2021 Arm Limited, all rights reserved\n+R\"(astcenc v%s, %u-bit %s%s\n+Copyright 2011-%s Arm Limited, all rights reserved\n)\";\n/** @brief The short-form help text. */\n@@ -595,7 +596,8 @@ void astcenc_print_header()\n#endif\nunsigned int bits = (int)(sizeof(void*) * 8);\n- printf(astcenc_copyright_string, bits, simdtype, pcnttype);\n+ printf(astcenc_copyright_string,\n+ VERSION_STRING, bits, simdtype, pcnttype, YEAR_STRING);\n}\n/* See header for documentation. */\n" }, { "change_type": "ADD", "old_path": null, "new_path": "Source/astcenccli_version.h.in", "diff": "+// SPDX-License-Identifier: Apache-2.0\n+// ----------------------------------------------------------------------------\n+// Copyright 2021 Arm Limited\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+// use this file except in compliance with the License. You may obtain a copy\n+// of the License at:\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+// License for the specific language governing permissions and limitations\n+// under the License.\n+// ----------------------------------------------------------------------------\n+\n+/**\n+ * @brief Functions and data declarations.\n+ */\n+\n+#ifndef ASTCENCCLI_VERSION_INCLUDED\n+#define ASTCENCCLI_VERSION_INCLUDED\n+\n+#define VERSION_STRING \"@astcencoder_VERSION@\"\n+#define YEAR_STRING \"@astcencoder_YEAR@\"\n+\n+#endif\n" }, { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "@@ -250,5 +250,17 @@ astcenc_set_properties(${ASTC_TARGET}-static)\nif(${CLI})\nastcenc_set_properties(${ASTC_TARGET})\n+\n+ string(TIMESTAMP astcencoder_YEAR \"%Y\")\n+\n+ configure_file(\n+ astcenccli_version.h.in\n+ astcenccli_version.h\n+ ESCAPE_QUOTES @ONLY)\n+\n+ target_include_directories(${ASTC_TARGET}\n+ PRIVATE\n+ ${CMAKE_CURRENT_BINARY_DIR})\n+\ninstall(TARGETS ${ASTC_TARGET} DESTINATION ${PACKAGE_ROOT})\nendif()\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
CMake configure_file propagates version
61,745
01.07.2021 20:10:40
-3,600
7257cbd7188b07960f772f322c54aa4ab4e788a3
Re-add native ISA support
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -39,6 +39,7 @@ option(ISA_SSE41 \"Enable builds for SSE4.1 SIMD\")\noption(ISA_SSE2 \"Enable builds for SSE2 SIMD\")\noption(ISA_NEON \"Enable builds for NEON SIMD\")\noption(ISA_NONE \"Enable builds for no SIMD\")\n+option(ISA_NATIVE \"Enable builds for native SIMD\")\noption(DECOMPRESSOR \"Enable builds for decompression only\")\noption(DIAGNOSTICS \"Enable builds for diagnostic trace\")\noption(UNITTEST \"Enable builds for unit tests\")\n@@ -175,8 +176,9 @@ else()\nendif()\nendif()\n-if((\"${ARM64_ISA_COUNT}\" EQUAL 0) AND (\"${X64_ISA_COUNT}\" EQUAL 0))\n- set(ISA_NONE ON)\n+# If nothing more specific is set then fall back on the compiler's defaults\n+if((\"${ARM64_ISA_COUNT}\" EQUAL 0) AND (\"${X64_ISA_COUNT}\" EQUAL 0) AND (NOT \"${ISA_NONE}\"))\n+ set(ISA_NATIVE ON)\nendif()\nfunction(printopt optName optVal)\n@@ -192,6 +194,7 @@ printopt(\"SSE4.1 backend\" ${ISA_SSE41})\nprintopt(\"SSE2 backend \" ${ISA_SSE2})\nprintopt(\"NEON backend \" ${ISA_NEON})\nprintopt(\"NONE backend \" ${ISA_NONE})\n+printopt(\"NATIVE backend \" ${ISA_NATIVE})\nif(\"${MACOS_BUILD}\")\nprintopt(\"Universal bin \" ${UNIVERSAL_BUILD})\nendif()\n" }, { "change_type": "MODIFY", "old_path": "Source/CMakeLists.txt", "new_path": "Source/CMakeLists.txt", "diff": "@@ -37,8 +37,8 @@ if(${UNIVERSAL_BUILD})\nendif()\ninclude(cmake_core.cmake)\nelse()\n- set(ARTEFACTS none neon avx2 sse4.1 sse2)\n- set(CONFIGS ${ISA_NONE} ${ISA_NEON} ${ISA_AVX2} ${ISA_SSE41} ${ISA_SSE2})\n+ set(ARTEFACTS native none neon avx2 sse4.1 sse2)\n+ set(CONFIGS ${ISA_NATIVE} ${ISA_NONE} ${ISA_NEON} ${ISA_AVX2} ${ISA_SSE41} ${ISA_SSE2})\nlist(LENGTH ARTEFACTS ARTEFACTS_LEN)\nmath(EXPR ARTEFACTS_LEN \"${ARTEFACTS_LEN} - 1\")\n" }, { "change_type": "MODIFY", "old_path": "Source/UnitTest/CMakeLists.txt", "new_path": "Source/UnitTest/CMakeLists.txt", "diff": "@@ -25,8 +25,8 @@ if(${UNIVERSAL_BUILD})\nendif()\ninclude(cmake_core.cmake)\nelse()\n- set(ARTEFACTS none neon avx2 sse4.1 sse2)\n- set(CONFIGS ${ISA_NONE} ${ISA_NEON} ${ISA_AVX2} ${ISA_SSE41} ${ISA_SSE2})\n+ set(ARTEFACTS native none neon avx2 sse4.1 sse2)\n+ set(CONFIGS ${ISA_NATIVE} ${ISA_NONE} ${ISA_NEON} ${ISA_AVX2} ${ISA_SSE41} ${ISA_SSE2})\nlist(LENGTH ARTEFACTS ARTEFACTS_LEN)\nmath(EXPR ARTEFACTS_LEN \"${ARTEFACTS_LEN} - 1\")\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Re-add native ISA support (#274)
61,745
13.07.2021 14:04:38
-3,600
0859af5f10b045613f4b8901e717bcd42e3f3c7e
Add a minimal example of using astcenc library API
[ { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "@@ -175,3 +175,11 @@ make package -j16\nWindows packages will use the `.zip` format, other packages will use the\n`.tar.gz` format.\n+\n+## Integrating as a library into another project\n+\n+The core codec of astcenc is built as a library, and so can be easily\n+integrated into other projects using CMake. An example of the CMake integration\n+and the codec API usage can be found in the `./Utils/Example` directory in the\n+repository. See the [Example Readme](../Utils/Example/README.md) for more\n+details.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "Utils/Example/CMakeLists.txt", "diff": "+# SPDX-License-Identifier: Apache-2.0\n+# ----------------------------------------------------------------------------\n+# Copyright 2021 Arm Limited\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+# use this file except in compliance with the License. You may obtain a copy\n+# of the License at:\n+#\n+# http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+# License for the specific language governing permissions and limitations\n+# under the License.\n+# ----------------------------------------------------------------------------\n+\n+# CMake configuration\n+cmake_minimum_required(VERSION 3.15)\n+include(ExternalProject)\n+\n+project(astcencoder_example VERSION 1.0.0)\n+\n+# Add the external project and pull out the project directories we need\n+\n+# The default build is a native build which supports the highest level of SIMD\n+# exposed by the compiler when using default compiler flags. Add a single\n+# SIMD enable to the CMAKE_CACHE_ARGS option to force something specific, but\n+# remember to change the link library in target_link_libraries() to match.\n+#\n+# * Add \"-DISA_SSE2:String=ON\" and link against \"astcenc-sse2-static\"\n+# * Add \"-DISA_SSE41:String=ON\" and link against \"astcenc-sse4.1-static\"\n+# * Add \"-DISA_AVX2:String=ON\" and link against \"astcenc-avx2-static\"\n+# * Add \"-DISA_NEON:String=ON\" and link against \"astcenc-neon-static\"\n+ExternalProject_Add(astcencoder\n+ GIT_REPOSITORY https://github.com/ARM-software/astc-encoder\n+ GIT_TAG main\n+ CMAKE_CACHE_ARGS -DCLI:String=OFF\n+ INSTALL_COMMAND \"\")\n+\n+ExternalProject_Get_property(astcencoder\n+ SOURCE_DIR)\n+\n+ExternalProject_Get_property(astcencoder\n+ BINARY_DIR)\n+\n+# Build the command line\n+add_executable(astcenc_example astc_api_example.cpp)\n+\n+# ... with astcencoder as a dependency\n+add_dependencies(astcenc_example astcencoder)\n+\n+# ... with astcencoder Source dir on the include path\n+target_include_directories(astcenc_example\n+ PRIVATE\n+ ${SOURCE_DIR}/Source)\n+\n+# ... with astcencoder Binary dir on the library path and as a library dep\n+target_link_directories(astcenc_example\n+ PRIVATE\n+ ${BINARY_DIR}/Source)\n+\n+target_link_libraries(astcenc_example\n+ PRIVATE\n+ astcenc-native-static)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "Utils/Example/README.md", "diff": "+# Library usage example\n+\n+This is a minimal example of using the astcenc codec as a library in another\n+project. This sample shows:\n+\n+ * How to include astcenc as an external project CMake dependency.\n+ * How to use the API to compress and decompress an image.\n+\n+For sake of simplicity the example application uses fixed compression settings,\n+reading an uncompressed LDR image, compressing using 6x6 blocks at medium\n+quality, and then decompressing and writing the decompressed image back to disk\n+as a PNG file.\n+\n+## Building\n+\n+### Linux and macOS\n+\n+From the `./Utils/Example` directory.\n+\n+```\n+mkdir build\n+cd build\n+cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release ..\n+make -j8\n+```\n+\n+### Windows\n+\n+From the `./Utils/Example` directory, in a Visual Studio command prompt.\n+\n+```\n+mkdir build\n+cd build\n+cmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Release ..\n+nmake\n+```\n+\n+## Running\n+\n+From the build directory above.\n+\n+```\n+astcenc_example <input.png> <output.png>\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "Utils/Example/astc_api_example.cpp", "diff": "+// SPDX-License-Identifier: Apache-2.0\n+// ----------------------------------------------------------------------------\n+// Copyright 2021 Arm Limited\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+// use this file except in compliance with the License. You may obtain a copy\n+// of the License at:\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+// License for the specific language governing permissions and limitations\n+// under the License.\n+// ----------------------------------------------------------------------------\n+\n+// This is a minimal example of using the astcenc library.\n+//\n+// This sample shows how to include the astcenc library in your CMake project\n+// as an external dependency, and how to compress and decompress images using\n+// the C library API.\n+//\n+// For sake of clarity the command line exposed by the sample is minimalistic,\n+// and the compression uses a fixed set of options, but the code is commented\n+// to indicate where extension would be possible. Errors handling points are\n+// detected and logged, but resources are not cleaned up on error paths to keep\n+// the sample control path simple, so resources will leak on error.\n+\n+#include <stdio.h>\n+\n+#include \"astcenc.h\"\n+\n+#define STB_IMAGE_IMPLEMENTATION\n+#include \"stb_image.h\"\n+\n+#define STB_IMAGE_WRITE_IMPLEMENTATION\n+#include \"stb_image_write.h\"\n+\n+int main(int argc, char **argv)\n+{\n+ // Parse command line\n+ if (argc != 3)\n+ {\n+ printf(\"Usage:\\n\"\n+ \" %s <source> <dest>\\n\\n\"\n+ \" <source> : Uncompressed LDR source image.\\n\"\n+ \" <dest> : Uncompressed LDR destination image (png).\\n\"\n+ , argv[0]);\n+ return 1;\n+ }\n+\n+ // ------------------------------------------------------------------------\n+ // For the purposes of this sample we hard-code the compressor settings\n+ static const unsigned int thread_count = 1;\n+ static const unsigned int block_x = 6;\n+ static const unsigned int block_y = 6;\n+ static const unsigned int block_z = 1;\n+ static const astcenc_profile profile = ASTCENC_PRF_LDR;\n+ static const float quality = ASTCENC_PRE_MEDIUM;\n+ static const astcenc_swizzle swizzle {\n+ ASTCENC_SWZ_R, ASTCENC_SWZ_G, ASTCENC_SWZ_B, ASTCENC_SWZ_A\n+ };\n+\n+ // ------------------------------------------------------------------------\n+ // Load input image, forcing 4 components\n+ int image_x, image_y, image_c;\n+ uint8_t *image_data = (uint8_t*)stbi_load(argv[1], &image_x, &image_y, &image_c, 4);\n+ if (!image_data)\n+ {\n+ printf(\"Failed to load image \\\"%s\\\"\\n\", image_data);\n+ return 1;\n+ }\n+\n+ // Compute the number of ASTC blocks in each dimension\n+ unsigned int block_count_x = (image_x + block_x - 1) / block_x;\n+ unsigned int block_count_y = (image_y + block_y - 1) / block_y;\n+\n+ // ------------------------------------------------------------------------\n+ // Initialize the default configuration for the block size and quality\n+ astcenc_config config;\n+ config.block_x = block_x;\n+ config.block_y = block_y;\n+ config.profile = profile;\n+\n+ astcenc_error status;\n+ status = astcenc_config_init(profile, block_x, block_y, block_z, quality, 0, &config);\n+ if (status != ASTCENC_SUCCESS)\n+ {\n+ printf(\"ERROR: Codec config init failed: %s\\n\", astcenc_get_error_string(status));\n+ return 1;\n+ }\n+\n+ // ... power users can customize any config settings after calling\n+ // config_init() and before calling context alloc().\n+\n+ // ------------------------------------------------------------------------\n+ // Create a context based on the configuration\n+ astcenc_context* context;\n+ status = astcenc_context_alloc(&config, thread_count, &context);\n+ if (status != ASTCENC_SUCCESS)\n+ {\n+ printf(\"ERROR: Codec context alloc failed: %s\\n\", astcenc_get_error_string(status));\n+ return 1;\n+ }\n+\n+ // ------------------------------------------------------------------------\n+ // Compress the image\n+ astcenc_image image;\n+ image.dim_x = image_x;\n+ image.dim_y = image_y;\n+ image.dim_z = 1;\n+ image.data_type = ASTCENC_TYPE_U8;\n+ uint8_t* slices = image_data;\n+ image.data = reinterpret_cast<void**>(&slices);\n+\n+ // Space needed for 16 bytes of output per compressed block\n+ size_t comp_len = block_count_x * block_count_y * 16;\n+ uint8_t* comp_data = new uint8_t[comp_len];\n+\n+ status = astcenc_compress_image(context, &image, &swizzle, comp_data, comp_len, 0);\n+ if (status != ASTCENC_SUCCESS)\n+ {\n+ printf(\"ERROR: Codec compress failed: %s\\n\", astcenc_get_error_string(status));\n+ return 1;\n+ }\n+\n+ // ... the comp_data array contains the raw compressed data you would pass\n+ // to the graphics API, or pack into a wrapper format such as a KTX file.\n+\n+ // If using multithreaded compression to sequentially compress multiple\n+ // images you should reuse the same context, calling the function\n+ // astcenc_compress_reset() between each image in the series.\n+\n+ // ------------------------------------------------------------------------\n+ // Decompress the image\n+ // Note we just reuse the image structure to store the output here ...\n+ status = astcenc_decompress_image(context, comp_data, comp_len, &image, &swizzle, 0);\n+ if (status != ASTCENC_SUCCESS)\n+ {\n+ printf(\"ERROR: Codec decompress failed: %s\\n\", astcenc_get_error_string(status));\n+ return 1;\n+ }\n+\n+ // If using multithreaded decompression to sequentially decompress multiple\n+ // images you should reuse the same context, calling the function\n+ // astcenc_decompress_reset() between each image in the series.\n+\n+ // ------------------------------------------------------------------------\n+ // Store the result back to disk\n+ stbi_write_png(argv[2], image_x, image_y, 4, image_data, 4 * image_x);\n+\n+ // ------------------------------------------------------------------------\n+ // Cleanup library resources\n+ stbi_image_free(image_data);\n+ astcenc_context_free(context);\n+ delete[] comp_data;\n+\n+ return 0;\n+}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add a minimal example of using astcenc library API (#276)
61,745
13.07.2021 14:11:19
-3,600
d8294c1b92ed999b3957003073ed3b24ef58b2dc
Fake a version header for oss-fuzz builds
[ { "change_type": "MODIFY", "old_path": "Source/Fuzzers/build.sh", "new_path": "Source/Fuzzers/build.sh", "diff": "# This script is invoked by oss-fuzz from <root>/Source/\n+# Generate a dummy verison header (normally built by CMake variable expansion)\n+echo \"#pragma once\" > astcenccli_version.h\n+echo \"#define VERSION_STRING \\\"0.0.0\\\"\" >> astcenccli_version.h\n+echo \"#define YEAR_STRING \\\"2021\\\"\" >> astcenccli_version.h\n+\n# Build the core project for fuzz tests to link against\nfor source in ./*.cpp; do\nBASE=\"${source##*/}\"\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fake a version header for oss-fuzz builds
61,745
13.07.2021 19:29:14
-3,600
1ba523948de1e9de9dcfa05ccba99e9718d01301
Add example note about ExternalProject usage in CMake
[ { "change_type": "MODIFY", "old_path": "Utils/Example/README.md", "new_path": "Utils/Example/README.md", "diff": "@@ -13,6 +13,17 @@ as a PNG file.\n## Building\n+:warning: For sake of simplicity the example CMake project uses the CMake\n+`ExternalProject` mechanism to import the astcenc project from GitHub. This is\n+trivial to integrate, but requires network access during the build to pull the\n+astcenc project.\n+\n+Most users will want to store a copy of astcenc in a project sub-directory,\n+e.g. by using git submodules, and then use `add_subdirectory()` to include the\n+project in their build. This allows the user to directly use the astcenc core\n+library as a link requirement via `target_link_libraries()`, without the\n+additional plumbing that `ExternalProject` requires.\n+\n### Linux and macOS\nFrom the `./Utils/Example` directory.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add example note about ExternalProject usage in CMake