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
07.01.2021 08:52:52
0
658dbb41e66dc03b17a5e94efb74143ac88b0bfd
Update script to compare to 2.2 by default
[ { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -369,7 +369,7 @@ def parse_command_line():\nparser.add_argument(\"--encoder\", dest=\"encoders\", default=\"avx2\",\nchoices=coders, help=\"test encoder variant\")\n- parser.add_argument(\"--reference\", dest=\"reference\", default=\"ref-2.1-avx2\",\n+ parser.add_argument(\"--reference\", dest=\"reference\", default=\"ref-2.2-avx2\",\nchoices=refcoders, help=\"reference encoder variant\")\nastcProfile = [\"ldr\", \"ldrs\", \"hdr\", \"all\"]\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update script to compare to 2.2 by default
61,745
07.01.2021 12:01:43
0
6be54673ff0cf063c935a8fdf1949505b4f99014
Optimize compute_rgb_range Logic is identical, but the new code is more auto-vectorization friendly and we get better codegen on Clang++.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -110,50 +110,32 @@ static void compute_rgb_range(\nfloat3 rgb_max[4];\nint partition_count = pt->partition_count;\n+\n+ promise(partition_count > 0);\nfor (int i = 0; i < partition_count; i++)\n{\nrgb_min[i] = float3(1e38f);\nrgb_max[i] = float3(-1e38f);\n}\n+ promise(texels_per_block > 0);\nfor (int i = 0; i < texels_per_block; i++)\n{\nif (ewb->texel_weight[i] > 1e-10f)\n{\nint partition = pt->partition_of_texel[i];\n- float redval = blk->data_r[i];\n- if (redval > rgb_max[partition].r)\n- {\n- rgb_max[partition].r = redval;\n- }\n-\n- if (redval < rgb_min[partition].r)\n- {\n- rgb_min[partition].r = redval;\n- }\n-\n- float greenval = blk->data_g[i];\n- if (greenval > rgb_max[partition].g)\n- {\n- rgb_max[partition].g = greenval;\n- }\n-\n- if (greenval < rgb_min[partition].g)\n- {\n- rgb_min[partition].g = greenval;\n- }\n+ float data_r = blk->data_r[i];\n+ float data_g = blk->data_g[i];\n+ float data_b = blk->data_b[i];\n- float blueval = blk->data_b[i];\n- if (blueval > rgb_max[partition].b)\n- {\n- rgb_max[partition].b = blueval;\n- }\n+ rgb_min[partition].r = astc::min(data_r, rgb_min[partition].r);\n+ rgb_min[partition].g = astc::min(data_g, rgb_min[partition].g);\n+ rgb_min[partition].b = astc::min(data_b, rgb_min[partition].b);\n- if (blueval < rgb_min[partition].b)\n- {\n- rgb_min[partition].b = blueval;\n- }\n+ rgb_max[partition].r = astc::max(data_r, rgb_max[partition].r);\n+ rgb_max[partition].g = astc::max(data_g, rgb_max[partition].g);\n+ rgb_max[partition].b = astc::max(data_b, rgb_max[partition].b);\n}\n}\n@@ -161,23 +143,9 @@ static void compute_rgb_range(\n// to avoid divide by zeros later ...\nfor (int i = 0; i < partition_count; i++)\n{\n- rgb_range[i].r = rgb_max[i].r - rgb_min[i].r;\n- if (rgb_range[i].r <= 0.0f)\n- {\n- rgb_range[i].r = 1e-10f;\n- }\n-\n- rgb_range[i].g = rgb_max[i].g - rgb_min[i].g;\n- if (rgb_range[i].g <= 0.0f)\n- {\n- rgb_range[i].g = 1e-10f;\n- }\n-\n- rgb_range[i].b = rgb_max[i].b - rgb_min[i].b;\n- if (rgb_range[i].b <= 0.0f)\n- {\n- rgb_range[i].b = 1e-10f;\n- }\n+ rgb_range[i].r = astc::max(rgb_max[i].r - rgb_min[i].r, 1e-10f);\n+ rgb_range[i].g = astc::max(rgb_max[i].g - rgb_min[i].g, 1e-10f);\n+ rgb_range[i].b = astc::max(rgb_max[i].b - rgb_min[i].b, 1e-10f);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "#include \"astcenc_mathlib.h\"\n#include \"astcenc_vecmathlib.h\"\n+/**\n+ * @brief Make a promise to the compiler's optimizer.\n+ *\n+ * A promise is an expression that the optimizer is can assume is true for to\n+ * help it generate faster code. Common use cases for this are to promise that\n+ * a for loop will iterate more than once, or that the loop iteration count is\n+ * a multiple of a vector length, which avoids pre-loop checks and can avoid\n+ * loop tails if loops are unrolled by the auto-vectorizer.\n+ */\n+#if defined(NDEBUG)\n+ #if defined(_MSC_VER)\n+ #define promise(cond) __assume(cond);\n+ #elif __has_builtin(__builtin_assume)\n+ #define promise(cond) __builtin_assume(cond);\n+ #elif __has_builtin(__builtin_unreachable)\n+ #define promise(cond) __builtin_unreachable(!(cond));\n+ #endif\n+#else\n+ #define promise(cond) assert(cond);\n+#endif\n+\n/* ============================================================================\nConstants\n============================================================================ */\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Optimize compute_rgb_range Logic is identical, but the new code is more auto-vectorization friendly and we get better codegen on Clang++.
61,745
07.01.2021 21:47:47
0
9c155c48e38aba952e44e49f119ccb6a81a27bc0
Add promises for common for loops in hot functions
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -81,6 +81,10 @@ static int realign_weights(\nfloat4 endpnt0f[4];\nfloat4 offset[4];\n+ promise(partition_count > 0);\n+ promise(weight_count > 0);\n+ promise(max_plane >= 0);\n+\nfor (int pa_idx = 0; pa_idx < partition_count; pa_idx++)\n{\nunpack_color_endpoints(decode_mode,\n@@ -140,6 +144,7 @@ static int realign_weights(\n// Interpolate the colors to create the diffs\nint texels_to_evaluate = it->weight_num_texels[we_idx];\n+ promise(texels_to_evaluate > 0);\nfor (int te_idx = 0; te_idx < texels_to_evaluate; te_idx++)\n{\nint texel = it->weight_texel[we_idx][te_idx];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -325,9 +325,15 @@ float compute_symbolic_block_difference(\nconst decimation_table *it = ixtab2[bm.decimation_mode];\nint is_dual_plane = bm.is_dual_plane;\n-\nint weight_quantization_level = bm.quantization_mode;\n+ int weight_count = it->num_weights;\n+ int texel_count = bsd->texel_count;\n+\n+ promise(partition_count > 0);\n+ promise(weight_count > 0);\n+ promise(texel_count > 0);\n+\n// decode the color endpoints\nuint4 color_endpoint0[4];\nuint4 color_endpoint1[4];\n@@ -351,7 +357,6 @@ float compute_symbolic_block_difference(\n// first unquantize the weights\nint uq_plane1_weights[MAX_WEIGHTS_PER_BLOCK];\nint uq_plane2_weights[MAX_WEIGHTS_PER_BLOCK];\n- int weight_count = it->num_weights;\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quantization_level]);\n@@ -372,14 +377,14 @@ float compute_symbolic_block_difference(\nint weights[MAX_TEXELS_PER_BLOCK];\nint plane2_weights[MAX_TEXELS_PER_BLOCK];\n- for (int i = 0; i < bsd->texel_count; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nweights[i] = compute_value_of_texel_int(i, it, uq_plane1_weights);\n}\nif (is_dual_plane)\n{\n- for (int i = 0; i < bsd->texel_count; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nplane2_weights[i] = compute_value_of_texel_int(i, it, uq_plane2_weights);\n}\n@@ -390,7 +395,7 @@ float compute_symbolic_block_difference(\n// now that we have endpoint colors and weights, we can unpack actual colors for\n// each texel.\nfloat summa = 0.0f;\n- for (int i = 0; i < bsd->texel_count; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nint partition = pt->partition_of_texel[i];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -146,6 +146,9 @@ void compute_encoding_choice_errors(\nint partition_count = pi->partition_count;\nint texels_per_block = bsd->texel_count;\n+ promise(partition_count > 0);\n+ promise(texels_per_block > 0);\n+\nfloat3 averages[4];\nfloat3 directions_rgb[4];\nfloat4 error_weightings[4];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -44,16 +44,21 @@ static void compute_endpoints_and_ideal_weights_1_component(\n) {\nint partition_count = pt->partition_count;\nei->ep.partition_count = partition_count;\n+ promise(partition_count > 0);\n+\n+ int texel_count = bsd->texel_count;\n+ promise(texel_count > 0);\n+\n+ float lowvalues[4] { 1e10f, 1e10f, 1e10f, 1e10f };\n+ float highvalues[4] { -1e10f, -1e10f, -1e10f, -1e10f };\n- float lowvalues[4], highvalues[4];\nfloat partition_error_scale[4];\nfloat linelengths_rcp[4];\n- int texels_per_block = bsd->texel_count;\n-\nconst float *error_weights;\nconst float* data_vr = nullptr;\n- assert(component <= 3);\n+\n+ assert(component < 4);\nswitch (component)\n{\ncase 0:\n@@ -74,13 +79,7 @@ static void compute_endpoints_and_ideal_weights_1_component(\nbreak;\n}\n- for (int i = 0; i < partition_count; i++)\n- {\n- lowvalues[i] = 1e10f;\n- highvalues[i] = -1e10f;\n- }\n-\n- for (int i = 0; i < texels_per_block; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nif (error_weights[i] > 1e-10f)\n{\n@@ -118,7 +117,7 @@ static void compute_endpoints_and_ideal_weights_1_component(\nlinelengths_rcp[i] = 1.0f / diff;\n}\n- for (int i = 0; i < texels_per_block; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nfloat value = data_vr[i];\nint partition = pt->partition_of_texel[i];\n@@ -135,6 +134,8 @@ static void compute_endpoints_and_ideal_weights_1_component(\n{\nei->ep.endpt0[i] = float4(blk->data_min.lane<0>(), blk->data_min.lane<1>(), blk->data_min.lane<2>(), blk->data_min.lane<3>());\nei->ep.endpt1[i] = float4(blk->data_max.lane<0>(), blk->data_max.lane<1>(), blk->data_max.lane<2>(), blk->data_max.lane<3>());\n+\n+ assert(component < 4);\nswitch (component)\n{\ncase 0: // red/x\n@@ -149,7 +150,7 @@ static void compute_endpoints_and_ideal_weights_1_component(\nei->ep.endpt0[i].b = lowvalues[i];\nei->ep.endpt1[i].b = highvalues[i];\nbreak;\n- case 3: // alpha/w\n+ default: // alpha/w\nei->ep.endpt0[i].a = lowvalues[i];\nei->ep.endpt1[i].a = highvalues[i];\nbreak;\n@@ -168,6 +169,10 @@ static void compute_endpoints_and_ideal_weights_2_components(\n) {\nint partition_count = pt->partition_count;\nei->ep.partition_count = partition_count;\n+ promise(partition_count > 0);\n+\n+ int texel_count = bsd->texel_count;\n+ promise(texel_count > 0);\nfloat4 error_weightings[4];\nfloat4 color_scalefactors[4];\n@@ -196,13 +201,12 @@ static void compute_endpoints_and_ideal_weights_2_components(\ndata_vg = blk->data_b;\n}\n- int texels_per_block = bsd->texel_count;\n-\ncompute_partition_error_color_weightings(bsd, ewb, pt, error_weightings, color_scalefactors);\nfor (int i = 0; i < partition_count; i++)\n{\nfloat s1 = 0, s2 = 0;\n+ assert(component1 < 4);\nswitch (component1)\n{\ncase 0:\n@@ -214,11 +218,12 @@ static void compute_endpoints_and_ideal_weights_2_components(\ncase 2:\ns1 = color_scalefactors[i].b;\nbreak;\n- case 3:\n+ default:\ns1 = color_scalefactors[i].a;\nbreak;\n}\n+ assert(component2 < 4);\nswitch (component2)\n{\ncase 0:\n@@ -230,14 +235,15 @@ static void compute_endpoints_and_ideal_weights_2_components(\ncase 2:\ns2 = color_scalefactors[i].b;\nbreak;\n- case 3:\n+ default:\ns2 = color_scalefactors[i].a;\nbreak;\n}\nscalefactors[i] = normalize(float2(s1, s2)) * 1.41421356f;\n}\n- float lowparam[4], highparam[4];\n+ float lowparam[4] { 1e10f, 1e10f, 1e10f, 1e10f };\n+ float highparam[4] { -1e10f, -1e10f, -1e10f, -1e10f };\nfloat2 averages[4];\nfloat2 directions[4];\n@@ -246,12 +252,6 @@ static void compute_endpoints_and_ideal_weights_2_components(\nfloat scale[4];\nfloat length_squared[4];\n- for (int i = 0; i < partition_count; i++)\n- {\n- lowparam[i] = 1e10;\n- highparam[i] = -1e10;\n- }\n-\ncompute_averages_and_directions_2_components(pt, blk, ewb, scalefactors, component1, component2, averages, directions);\nfor (int i = 0; i < partition_count; i++)\n@@ -274,7 +274,7 @@ static void compute_endpoints_and_ideal_weights_2_components(\n}\n}\n- for (int i = 0; i < texels_per_block; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nif (error_weights[i] > 1e-10f)\n{\n@@ -344,6 +344,7 @@ static void compute_endpoints_and_ideal_weights_2_components(\nfloat2 ep0 = lowvalues[i];\nfloat2 ep1 = highvalues[i];\n+ assert(component1 < 4);\nswitch (component1)\n{\ncase 0:\n@@ -358,12 +359,13 @@ static void compute_endpoints_and_ideal_weights_2_components(\nei->ep.endpt0[i].b = ep0.r;\nei->ep.endpt1[i].b = ep1.r;\nbreak;\n- case 3:\n+ default:\nei->ep.endpt0[i].a = ep0.r;\nei->ep.endpt1[i].a = ep1.r;\nbreak;\n}\n+ assert(component2 < 4);\nswitch (component2)\n{\ncase 0:\n@@ -378,14 +380,14 @@ static void compute_endpoints_and_ideal_weights_2_components(\nei->ep.endpt0[i].b = ep0.g;\nei->ep.endpt1[i].b = ep1.g;\nbreak;\n- case 3:\n+ default:\nei->ep.endpt0[i].a = ep0.g;\nei->ep.endpt1[i].a = ep1.g;\nbreak;\n}\n}\n- for (int i = 0; i < texels_per_block; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nint partition = pt->partition_of_texel[i];\nfloat idx = (ei->weights[i] - lowparam[partition]) * scale[partition];\n@@ -403,37 +405,39 @@ static void compute_endpoints_and_ideal_weights_3_components(\nconst imageblock* blk,\nconst error_weight_block* ewb,\nendpoints_and_weights* ei,\n- int omittedComponent\n+ int omitted_component\n) {\nint partition_count = pt->partition_count;\nei->ep.partition_count = partition_count;\n+ promise(partition_count > 0);\n+\n+ int texel_count= bsd->texel_count;\n+ promise(texel_count > 0);\nfloat4 error_weightings[4];\nfloat4 color_scalefactors[4];\nfloat3 scalefactors[4];\n- int texels_per_block = bsd->texel_count;\n-\nconst float *error_weights;\nconst float* data_vr = nullptr;\nconst float* data_vg = nullptr;\nconst float* data_vb = nullptr;\n- if (omittedComponent == 0)\n+ if (omitted_component == 0)\n{\nerror_weights = ewb->texel_weight_gba;\ndata_vr = blk->data_g;\ndata_vg = blk->data_b;\ndata_vb = blk->data_a;\n}\n- else if (omittedComponent == 1)\n+ else if (omitted_component == 1)\n{\nerror_weights = ewb->texel_weight_rba;\ndata_vr = blk->data_r;\ndata_vg = blk->data_b;\ndata_vb = blk->data_a;\n}\n- else if (omittedComponent == 2)\n+ else if (omitted_component == 2)\n{\nerror_weights = ewb->texel_weight_rga;\ndata_vr = blk->data_r;\n@@ -453,7 +457,8 @@ static void compute_endpoints_and_ideal_weights_3_components(\nfor (int i = 0; i < partition_count; i++)\n{\nfloat s1 = 0, s2 = 0, s3 = 0;\n- switch (omittedComponent)\n+ assert(omitted_component < 4);\n+ switch (omitted_component)\n{\ncase 0:\ns1 = color_scalefactors[i].g;\n@@ -470,7 +475,7 @@ static void compute_endpoints_and_ideal_weights_3_components(\ns2 = color_scalefactors[i].g;\ns3 = color_scalefactors[i].a;\nbreak;\n- case 3:\n+ default:\ns1 = color_scalefactors[i].r;\ns2 = color_scalefactors[i].g;\ns3 = color_scalefactors[i].b;\n@@ -480,7 +485,8 @@ static void compute_endpoints_and_ideal_weights_3_components(\nscalefactors[i] = normalize(float3(s1, s2, s3)) * 1.73205080f;\n}\n- float lowparam[4], highparam[4];\n+ float lowparam[4] { 1e10f, 1e10f, 1e10f, 1e10f };\n+ float highparam[4] { -1e10f, -1e10f, -1e10f, -1e10f };\nfloat3 averages[4];\nfloat3 directions[4];\n@@ -489,13 +495,8 @@ static void compute_endpoints_and_ideal_weights_3_components(\nfloat scale[4];\nfloat length_squared[4];\n- for (int i = 0; i < partition_count; i++)\n- {\n- lowparam[i] = 1e10f;\n- highparam[i] = -1e10f;\n- }\n- compute_averages_and_directions_3_components(pt, blk, ewb, scalefactors, omittedComponent, averages, directions);\n+ compute_averages_and_directions_3_components(pt, blk, ewb, scalefactors, omitted_component, averages, directions);\nfor (int i = 0; i < partition_count; i++)\n{\n@@ -519,7 +520,7 @@ static void compute_endpoints_and_ideal_weights_3_components(\n}\n}\n- for (int i = 0; i < texels_per_block; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nif (error_weights[i] > 1e-10f)\n{\n@@ -591,7 +592,8 @@ static void compute_endpoints_and_ideal_weights_3_components(\nfloat3 ep0 = lowvalues[i];\nfloat3 ep1 = highvalues[i];\n- switch (omittedComponent)\n+ assert(omitted_component < 4);\n+ switch (omitted_component)\n{\ncase 0:\nei->ep.endpt0[i].g = ep0.r;\n@@ -620,7 +622,7 @@ static void compute_endpoints_and_ideal_weights_3_components(\nei->ep.endpt1[i].g = ep1.g;\nei->ep.endpt1[i].a = ep1.b;\nbreak;\n- case 3:\n+ default:\nei->ep.endpt0[i].r = ep0.r;\nei->ep.endpt0[i].g = ep0.g;\nei->ep.endpt0[i].b = ep0.b;\n@@ -632,7 +634,7 @@ static void compute_endpoints_and_ideal_weights_3_components(\n}\n}\n- for (int i = 0; i < texels_per_block; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nint partition = pt->partition_of_texel[i];\nfloat idx = (ei->weights[i] - lowparam[partition]) * scale[partition];\n@@ -654,12 +656,13 @@ static void compute_endpoints_and_ideal_weights_rgba(\nconst float *error_weights = ewb->texel_weight;\nint partition_count = pt->partition_count;\n- float lowparam[4], highparam[4];\n- for (int i = 0; i < partition_count; i++)\n- {\n- lowparam[i] = 1e10;\n- highparam[i] = -1e10;\n- }\n+\n+ int texel_count= bsd->texel_count;\n+ promise(texel_count > 0);\n+ promise(partition_count > 0);\n+\n+ float lowparam[4] { 1e10, 1e10, 1e10, 1e10 };\n+ float highparam[4] { -1e10, -1e10, -1e10, -1e10 };\nfloat4 averages[4];\nfloat4 directions_rgba[4];\n@@ -673,8 +676,6 @@ static void compute_endpoints_and_ideal_weights_rgba(\nfloat4 color_scalefactors[4];\nfloat4 scalefactors[4];\n- int texels_per_block = bsd->texel_count;\n-\ncompute_partition_error_color_weightings(bsd, ewb, pt, error_weightings, color_scalefactors);\nfor (int i = 0; i < partition_count; i++)\n@@ -708,7 +709,7 @@ static void compute_endpoints_and_ideal_weights_rgba(\n}\n}\n- for (int i = 0; i < texels_per_block; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nif (error_weights[i] > 1e-10f)\n{\n@@ -773,7 +774,7 @@ static void compute_endpoints_and_ideal_weights_rgba(\nei->ep.endpt1[i] = ep1;\n}\n- for (int i = 0; i < texels_per_block; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nint partition = pt->partition_of_texel[i];\nfloat idx = (ei->weights[i] - lowparam[partition]) * scale[partition];\n@@ -820,10 +821,12 @@ void compute_endpoints_and_ideal_weights_2_planes(\nendpoints_and_weights* ei2\n) {\nint uses_alpha = imageblock_uses_alpha(blk);\n+\n+ assert(separate_component < 4);\nswitch (separate_component)\n{\ncase 0: // separate weights for red\n- if (uses_alpha == 1)\n+ if (uses_alpha)\n{\ncompute_endpoints_and_ideal_weights_3_components(bsd, pt, blk, ewb, ei1, 0);\n}\n@@ -835,7 +838,7 @@ void compute_endpoints_and_ideal_weights_2_planes(\nbreak;\ncase 1: // separate weights for green\n- if (uses_alpha == 1)\n+ if (uses_alpha)\n{\ncompute_endpoints_and_ideal_weights_3_components(bsd, pt, blk, ewb, ei1, 1);\n}\n@@ -847,7 +850,7 @@ void compute_endpoints_and_ideal_weights_2_planes(\nbreak;\ncase 2: // separate weights for blue\n- if (uses_alpha == 1)\n+ if (uses_alpha)\n{\ncompute_endpoints_and_ideal_weights_3_components(bsd, pt, blk, ewb, ei1, 2);\n}\n@@ -858,8 +861,8 @@ void compute_endpoints_and_ideal_weights_2_planes(\ncompute_endpoints_and_ideal_weights_1_component(bsd, pt, blk, ewb, ei2, 2);\nbreak;\n- case 3: // separate weights for alpha\n- assert(uses_alpha != 0);\n+ default: // separate weights for alpha\n+ assert(uses_alpha);\ncompute_endpoints_and_ideal_weights_3_components(bsd, pt, blk, ewb, ei1, 3);\ncompute_endpoints_and_ideal_weights_1_component(bsd, pt, blk, ewb, ei2, 3);\nbreak;\n@@ -954,10 +957,13 @@ void compute_ideal_weights_for_decimation_table(\nint texels_per_block = it->num_texels;\nint weight_count = it->num_weights;\n+ promise(texels_per_block > 0);\n+ promise(weight_count > 0);\n+\n// perform a shortcut in the case of a complete decimation table\nif (texels_per_block == weight_count)\n{\n- for (int i = 0; i < it->num_texels; i++)\n+ for (int i = 0; i < texels_per_block; i++)\n{\nint texel = it->weight_texel[i][0];\nweight_set[i] = eai->weights[texel];\n@@ -973,10 +979,11 @@ void compute_ideal_weights_for_decimation_table(\n// compute an initial average for each weight.\nfor (int i = 0; i < weight_count; i++)\n{\n- int texel_count = it->weight_num_texels[i];\n-\nfloat weight_weight = 1e-10f; // to avoid 0/0 later on\nfloat initial_weight = 0.0f;\n+\n+ int texel_count = it->weight_num_texels[i];\n+ promise(texel_count > 0);\nfor (int j = 0; j < texel_count; j++)\n{\nint texel = it->weight_texel[i][j];\n@@ -1012,12 +1019,13 @@ void compute_ideal_weights_for_decimation_table(\nconst uint8_t *weight_texel_ptr = it->weight_texel[i];\nconst float *weights_ptr = it->weights_flt[i];\n- // compute the two error changes that can occur from perturbing the current index.\n- int num_weights = it->weight_num_texels[i];\nfloat error_change0 = 1e-10f; // done in order to ensure that this value isn't 0, in order to avoid a possible divide by zero later.\nfloat error_change1 = 0.0f;\n+ // compute the two error changes that can occur from perturbing the current index.\n+ int num_weights = it->weight_num_texels[i];\n+ promise(num_weights > 0);\nfor (int k = 0; k < num_weights; k++)\n{\nuint8_t weight_texel = weight_texel_ptr[k];\n@@ -1665,15 +1673,20 @@ void recompute_ideal_colors_1plane(\nconst imageblock* pb, // picture-block containing the actual data.\nconst error_weight_block* ewb\n) {\n+ int num_weights = it->num_weights;\n+ int partition_count = pi->partition_count;\n+\n+ promise(num_weights > 0);\n+ promise(partition_count > 0);\n+\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quantization_mode]);\nfloat weight_set[MAX_WEIGHTS_PER_BLOCK];\n- for (int i = 0; i < it->num_weights; i++)\n+ for (int i = 0; i < num_weights; i++)\n{\nweight_set[i] = qat->unquantized_value[weight_set8[i]] * (1.0f / 64.0f);\n}\n- int partition_count = pi->partition_count;\nfor (int i = 0; i < partition_count; i++)\n{\nfloat4 rgba_sum = float4(1e-17f);\n@@ -1681,6 +1694,8 @@ void recompute_ideal_colors_1plane(\nint texelcount = pi->texels_per_partition[i];\nconst uint8_t *texel_indexes = pi->texels_of_partition[i];\n+\n+ promise(texelcount > 0);\nfor (int j = 0; j < texelcount; j++)\n{\nint tix = texel_indexes[j];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_integer_sequence.cpp", "new_path": "Source/astcenc_integer_sequence.cpp", "diff": "@@ -469,6 +469,7 @@ void encode_ise(\nint bits, trits, quints;\nfind_number_of_bits_trits_quints(quantization_level, &bits, &trits, &quints);\n+ promise(elements > 0);\nfor (int i = 0; i < elements; i++)\n{\nlowparts[i] = input_data[i] & ((1 << bits) - 1);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -826,7 +826,7 @@ void compute_averages_and_directions_3_components(\nconst imageblock* blk,\nconst error_weight_block* ewb,\nconst float3 * color_scalefactors,\n- int omittedComponent,\n+ int omitted_component,\nfloat3* averages,\nfloat3* directions);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -91,6 +91,13 @@ alignas(ASTCENC_VECALIGN) static float stepsizes_sqr[ANGULAR_STEPS];\nstatic int max_angular_steps_needed_for_quant_level[13];\n+// yes, the next-to-last entry is supposed to have the value 33. This because under\n+// ASTC, the 32-weight mode leaves a double-sized hole in the middle of the\n+// weight space, so we are better off matching 33 weights than 32.\n+static const int quantization_steps_for_level[13] = {\n+ 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 33, 36\n+};\n+\n// Store a reduced sin/cos table for 64 possible weight values; this causes\n// slight quality loss compared to using sin() and cos() directly. Must be 2^N.\n#define SINCOS_STEPS 64\n@@ -116,14 +123,9 @@ void prepare_angular_tables()\nmax_angular_steps_needed_for_quant_steps[p] = MIN(i + 1, ANGULAR_STEPS - 1);\n}\n- // yes, the next-to-last entry is supposed to have the value 33. This because under\n- // ASTC, the 32-weight mode leaves a double-sized hole in the middle of the\n- // weight space, so we are better off matching 33 weights than 32.\n- static const int steps_of_level[] = { 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 33, 36 };\n-\nfor (int i = 0; i < 13; i++)\n{\n- max_angular_steps_needed_for_quant_level[i] = max_angular_steps_needed_for_quant_steps[steps_of_level[i]];\n+ max_angular_steps_needed_for_quant_level[i] = max_angular_steps_needed_for_quant_steps[quantization_steps_for_level[i]];\n}\n}\n@@ -142,6 +144,9 @@ static void compute_angular_offsets(\nstd::memset(anglesum_x, 0, max_angular_steps*sizeof(anglesum_x[0]));\nstd::memset(anglesum_y, 0, max_angular_steps*sizeof(anglesum_y[0]));\n+ promise(samplecount > 0);\n+ promise(max_angular_steps > 0);\n+\n// compute the angle-sums.\nfor (int i = 0; i < samplecount; i++)\n{\n@@ -193,6 +198,9 @@ static void compute_lowest_and_highest_weight(\nfloat *cut_low_weight_error,\nfloat *cut_high_weight_error\n) {\n+ promise(samplecount > 0);\n+ promise(max_angular_steps > 0);\n+\n// Arrays are always multiple of SIMD width (ANGULAR_STEPS), so this is safe even if overshoot max\nfor (int sp = 0; sp < max_angular_steps; sp += ASTCENC_SIMD_WIDTH)\n{\n@@ -262,8 +270,6 @@ static void compute_angular_endpoints_for_quantization_levels(\nfloat low_value[12],\nfloat high_value[12]\n) {\n- static const int quantization_steps_for_level[13] = { 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 33, 36 };\n-\nint max_quantization_steps = quantization_steps_for_level[max_quantization_level + 1];\nalignas(ASTCENC_VECALIGN) float angular_offsets[ANGULAR_STEPS];\n@@ -292,6 +298,7 @@ static void compute_angular_endpoints_for_quantization_levels(\ncut_low_weight[i] = 0;\n}\n+ promise(max_angular_steps > 0);\nfor (int i = 0; i < max_angular_steps; i++)\n{\nint idx_span = weight_span[i];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add promises for common for loops in hot functions
61,745
07.01.2021 22:00:50
0
2c2ce9afde18252f509d8f19af26b9126656ab03
Consistently use "count" not "num"
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes2.cpp", "new_path": "Source/astcenc_block_sizes2.cpp", "diff": "@@ -300,7 +300,7 @@ static void initialize_decimation_table_2d(\nfor (int i = 0; i < texels_per_block; i++)\n{\n- dt->texel_num_weights[i] = weightcount_of_texel[i];\n+ dt->texel_weight_count[i] = weightcount_of_texel[i];\n// ensure that all 4 entries are actually initialized.\n// This allows a branch-free implementation of compute_value_of_texel_flt()\n@@ -321,7 +321,7 @@ static void initialize_decimation_table_2d(\nfor (int i = 0; i < weights_per_block; i++)\n{\n- dt->weight_num_texels[i] = texelcount_of_weight[i];\n+ dt->weight_texel_count[i] = texelcount_of_weight[i];\nfor (int j = 0; j < texelcount_of_weight[i]; j++)\n{\n@@ -358,8 +358,8 @@ static void initialize_decimation_table_2d(\n}\n}\n- dt->num_texels = texels_per_block;\n- dt->num_weights = weights_per_block;\n+ dt->texel_count = texels_per_block;\n+ dt->weight_count = weights_per_block;\n}\nstatic void initialize_decimation_table_3d(\n@@ -510,7 +510,7 @@ static void initialize_decimation_table_3d(\nfor (int i = 0; i < texels_per_block; i++)\n{\n- dt->texel_num_weights[i] = weightcount_of_texel[i];\n+ dt->texel_weight_count[i] = weightcount_of_texel[i];\n// ensure that all 4 entries are actually initialized.\n// This allows a branch-free implementation of compute_value_of_texel_flt()\n@@ -531,7 +531,7 @@ static void initialize_decimation_table_3d(\nfor (int i = 0; i < weights_per_block; i++)\n{\n- dt->weight_num_texels[i] = texelcount_of_weight[i];\n+ dt->weight_texel_count[i] = texelcount_of_weight[i];\nfor (int j = 0; j < texelcount_of_weight[i]; j++)\n{\nint texel = texels_of_weight[i][j];\n@@ -567,8 +567,8 @@ static void initialize_decimation_table_3d(\n}\n}\n- dt->num_texels = texels_per_block;\n- dt->num_weights = weights_per_block;\n+ dt->texel_count = texels_per_block;\n+ dt->weight_count = weights_per_block;\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -66,7 +66,7 @@ static int realign_weights(\n// Get the decimation table\nconst decimation_table *const *ixtab2 = bsd->decimation_tables;\nconst decimation_table *it = ixtab2[bm.decimation_mode];\n- int weight_count = it->num_weights;\n+ int weight_count = it->weight_count;\nint max_plane = bm.is_dual_plane;\nint plane2_component = max_plane ? scb->plane2_color_component : 0;\n@@ -143,7 +143,7 @@ static int realign_weights(\nfloat down_error = 0.0f;\n// Interpolate the colors to create the diffs\n- int texels_to_evaluate = it->weight_num_texels[we_idx];\n+ int texels_to_evaluate = it->weight_texel_count[we_idx];\npromise(texels_to_evaluate > 0);\nfor (int te_idx = 0; te_idx < texels_to_evaluate; te_idx++)\n{\n@@ -326,7 +326,7 @@ static void compress_symbolic_block_fixed_partition_1_plane(\nint decimation_mode = bm.decimation_mode;\n// compute weight bitcount for the mode\n- int bits_used_by_weights = compute_ise_bitcount(ixtab2[decimation_mode]->num_weights,\n+ int bits_used_by_weights = compute_ise_bitcount(ixtab2[decimation_mode]->weight_count,\n(quantization_method) bm.quantization_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@@ -383,7 +383,7 @@ static void compress_symbolic_block_fixed_partition_1_plane(\nconst decimation_table *it = ixtab2[decimation_mode];\nu8_weight_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * qw_packed_index;\n- weights_to_copy = it->num_weights;\n+ weights_to_copy = it->weight_count;\n// recompute the ideal color endpoints before storing them.\nfloat4 rgbs_colors[4];\n@@ -651,7 +651,7 @@ static void compress_symbolic_block_fixed_partition_2_planes(\n}\n// compute weight bitcount for the mode\n- int bits_used_by_weights = compute_ise_bitcount(2 * ixtab2[decimation_mode]->num_weights,\n+ int bits_used_by_weights = compute_ise_bitcount(2 * ixtab2[decimation_mode]->weight_count,\n(quantization_method) bm.quantization_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@@ -728,7 +728,7 @@ static void compress_symbolic_block_fixed_partition_2_planes(\nu8_weight1_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * qw_packed_index);\nu8_weight2_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * qw_packed_index + 1);\n- weights_to_copy = it->num_weights;\n+ weights_to_copy = it->weight_count;\n// recompute the ideal color endpoints before storing them.\nmerge_endpoints(&(eix1[decimation_mode].ep), &(eix2[decimation_mode].ep), separate_component, &epm);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -30,7 +30,7 @@ static int compute_value_of_texel_int(\nconst int* weights\n) {\nint summed_value = 8;\n- int weights_to_evaluate = it->texel_num_weights[texel_to_get];\n+ int weights_to_evaluate = it->texel_weight_count[texel_to_get];\nfor (int i = 0; i < weights_to_evaluate; i++)\n{\nsummed_value += weights[it->texel_weights[texel_to_get][i]] * it->texel_weights_int[texel_to_get][i];\n@@ -235,7 +235,7 @@ void decompress_symbolic_block(\n// first unquantize the weights\nint uq_plane1_weights[MAX_WEIGHTS_PER_BLOCK];\nint uq_plane2_weights[MAX_WEIGHTS_PER_BLOCK];\n- int weight_count = it->num_weights;\n+ int weight_count = it->weight_count;\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quantization_level]);\n@@ -327,7 +327,7 @@ float compute_symbolic_block_difference(\nint is_dual_plane = bm.is_dual_plane;\nint weight_quantization_level = bm.quantization_mode;\n- int weight_count = it->num_weights;\n+ int weight_count = it->weight_count;\nint texel_count = bsd->texel_count;\npromise(partition_count > 0);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -934,7 +934,7 @@ float compute_error_of_weight_set(\nconst decimation_table* it,\nconst float* weights\n) {\n- int texel_count = it->num_texels;\n+ int texel_count = it->texel_count;\nfloat error_summa = 0.0;\nfor (int i = 0; i < texel_count; i++)\n{\n@@ -954,16 +954,16 @@ void compute_ideal_weights_for_decimation_table(\nfloat* weight_set,\nfloat* weights\n) {\n- int texels_per_block = it->num_texels;\n- int weight_count = it->num_weights;\n+ int texel_count = it->texel_count;\n+ int weight_count = it->weight_count;\n- promise(texels_per_block > 0);\n+ promise(texel_count > 0);\npromise(weight_count > 0);\n// perform a shortcut in the case of a complete decimation table\n- if (texels_per_block == weight_count)\n+ if (texel_count == weight_count)\n{\n- for (int i = 0; i < texels_per_block; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nint texel = it->weight_texel[i][0];\nweight_set[i] = eai->weights[texel];\n@@ -982,9 +982,9 @@ void compute_ideal_weights_for_decimation_table(\nfloat weight_weight = 1e-10f; // to avoid 0/0 later on\nfloat initial_weight = 0.0f;\n- int texel_count = it->weight_num_texels[i];\n- promise(texel_count > 0);\n- for (int j = 0; j < texel_count; j++)\n+ int weight_texel_count = it->weight_texel_count[i];\n+ promise(weight_texel_count > 0);\n+ for (int j = 0; j < weight_texel_count; j++)\n{\nint texel = it->weight_texel[i][j];\nfloat weight = it->weights_flt[i][j];\n@@ -997,7 +997,7 @@ void compute_ideal_weights_for_decimation_table(\nweight_set[i] = initial_weight / weight_weight; // this is the 0/0 that is to be avoided.\n}\n- for (int i = 0; i < texels_per_block; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nconst uint8_t *texel_weights = it->texel_weights[i];\nconst float *texel_weights_float = it->texel_weights_float[i];\n@@ -1024,9 +1024,9 @@ void compute_ideal_weights_for_decimation_table(\nfloat error_change1 = 0.0f;\n// compute the two error changes that can occur from perturbing the current index.\n- int num_weights = it->weight_num_texels[i];\n- promise(num_weights > 0);\n- for (int k = 0; k < num_weights; k++)\n+ int weight_texel_count = it->weight_texel_count[i];\n+ promise(weight_texel_count > 0);\n+ for (int k = 0; k < weight_texel_count; k++)\n{\nuint8_t weight_texel = weight_texel_ptr[k];\nfloat weights2 = weights_ptr[k];\n@@ -1075,7 +1075,7 @@ void compute_ideal_quantized_weights_for_decimation_table(\nuint8_t* quantized_weight_set,\nint quantization_level\n) {\n- int weight_count = it->num_weights;\n+ int weight_count = it->weight_count;\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[quantization_level]);\nstatic const int quant_levels[12] = { 2,3,4,5,6,8,10,12,16,20,24,32 };\n@@ -1247,14 +1247,14 @@ void recompute_ideal_colors_2planes(\nfloat weight_set[MAX_WEIGHTS_PER_BLOCK];\nfloat plane2_weight_set[MAX_WEIGHTS_PER_BLOCK];\n- for (int i = 0; i < it->num_weights; i++)\n+ for (int i = 0; i < it->weight_count; i++)\n{\nweight_set[i] = qat->unquantized_value[weight_set8[i]] * (1.0f / 64.0f);\n}\nif (plane2_weight_set8)\n{\n- for (int i = 0; i < it->num_weights; i++)\n+ for (int i = 0; i < it->weight_count; i++)\n{\nplane2_weight_set[i] = qat->unquantized_value[plane2_weight_set8[i]] * (1.0f / 64.0f);\n}\n@@ -1673,16 +1673,16 @@ void recompute_ideal_colors_1plane(\nconst imageblock* pb, // picture-block containing the actual data.\nconst error_weight_block* ewb\n) {\n- int num_weights = it->num_weights;\n+ int weight_count = it->weight_count;\nint partition_count = pi->partition_count;\n- promise(num_weights > 0);\n+ promise(weight_count > 0);\npromise(partition_count > 0);\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quantization_mode]);\nfloat weight_set[MAX_WEIGHTS_PER_BLOCK];\n- for (int i = 0; i < num_weights; i++)\n+ for (int i = 0; i < weight_count; i++)\n{\nweight_set[i] = qat->unquantized_value[weight_set8[i]] * (1.0f / 64.0f);\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -392,13 +392,13 @@ struct partition_info\n*/\nstruct decimation_table\n{\n- int num_texels;\n- int num_weights;\n- uint8_t texel_num_weights[MAX_TEXELS_PER_BLOCK]; // number of indices that go into the calculation for a texel\n+ int texel_count;\n+ int weight_count;\n+ uint8_t texel_weight_count[MAX_TEXELS_PER_BLOCK]; // number of indices that go into the calculation for a texel\nuint8_t texel_weights_int[MAX_TEXELS_PER_BLOCK][4]; // the weight to assign to each weight\nfloat texel_weights_float[MAX_TEXELS_PER_BLOCK][4]; // the weight to assign to each weight\nuint8_t texel_weights[MAX_TEXELS_PER_BLOCK][4]; // the weights that go into a texel calculation\n- uint8_t weight_num_texels[MAX_WEIGHTS_PER_BLOCK]; // the number of texels that a given weight contributes to\n+ uint8_t weight_texel_count[MAX_WEIGHTS_PER_BLOCK]; // the number of texels that a given weight contributes to\nuint8_t weight_texel[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK]; // the texels that the weight contributes to\nuint8_t weights_int[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK]; // the weights that the weight contributes to a texel.\nfloat weights_flt[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK]; // the weights that the weight contributes to a texel.\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_symbolic_physical.cpp", "new_path": "Source/astcenc_symbolic_physical.cpp", "diff": "@@ -130,7 +130,7 @@ void symbolic_to_physical(\nassert(packed_index >= 0 && packed_index < bsd.block_mode_count);\nconst block_mode& bm = bsd.block_modes[packed_index];\n- int weight_count = ixtab2[bm.decimation_mode]->num_weights;\n+ int weight_count = ixtab2[bm.decimation_mode]->weight_count;\nint weight_quantization_method = bm.quantization_mode;\nint is_dual_plane = bm.is_dual_plane;\n@@ -336,7 +336,7 @@ void physical_to_symbolic(\nassert(packed_index >= 0 && packed_index < bsd.block_mode_count);\nconst struct block_mode& bm = bsd.block_modes[packed_index];\n- int weight_count = ixtab2[bm.decimation_mode]->num_weights;\n+ int weight_count = ixtab2[bm.decimation_mode]->weight_count;\nint weight_quantization_method = bm.quantization_mode;\nint is_dual_plane = bm.is_dual_plane;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -394,7 +394,7 @@ void compute_angular_endpoints_1plane(\ncontinue;\n}\n- int samplecount = bsd->decimation_tables[i]->num_weights;\n+ int samplecount = bsd->decimation_tables[i]->weight_count;\ncompute_angular_endpoints_for_quantization_levels(samplecount,\ndecimated_quantized_weights + i * MAX_WEIGHTS_PER_BLOCK,\ndecimated_weights + i * MAX_WEIGHTS_PER_BLOCK, dm.maxprec_1plane, low_values[i], high_values[i]);\n@@ -439,7 +439,7 @@ void compute_angular_endpoints_2planes(\ncontinue;\n}\n- int samplecount = bsd->decimation_tables[i]->num_weights;\n+ int samplecount = bsd->decimation_tables[i]->weight_count;\ncompute_angular_endpoints_for_quantization_levels(samplecount,\ndecimated_quantized_weights + 2 * i * MAX_WEIGHTS_PER_BLOCK,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "@@ -42,7 +42,7 @@ static astcenc_image* load_image_with_tinyexr(\nconst char* filename,\nbool y_flip,\nbool& is_hdr,\n- unsigned int& num_components\n+ unsigned int& component_count\n) {\nint dim_x, dim_y;\nfloat* image;\n@@ -60,7 +60,7 @@ static astcenc_image* load_image_with_tinyexr(\nfree(image);\nis_hdr = true;\n- num_components = 4;\n+ component_count = 4;\nreturn res_img;\n}\n@@ -68,7 +68,7 @@ static astcenc_image* load_image_with_stb(\nconst char* filename,\nbool y_flip,\nbool& is_hdr,\n- unsigned int& num_components\n+ unsigned int& component_count\n) {\nint dim_x, dim_y;\n@@ -80,7 +80,7 @@ static astcenc_image* load_image_with_stb(\nastcenc_image* img = astc_img_from_floatx4_array(data, dim_x, dim_y, y_flip);\nstbi_image_free(data);\nis_hdr = true;\n- num_components = 4;\n+ component_count = 4;\nreturn img;\n}\n}\n@@ -92,7 +92,7 @@ static astcenc_image* load_image_with_stb(\nastcenc_image* img = astc_img_from_unorm8x4_array(data, dim_x, dim_y, y_flip);\nstbi_image_free(data);\nis_hdr = false;\n- num_components = 4;\n+ component_count = 4;\nreturn img;\n}\n}\n@@ -724,7 +724,7 @@ static astcenc_image* load_ktx_uncompressed_image(\nconst char* filename,\nbool y_flip,\nbool& is_hdr,\n- unsigned int& num_components\n+ unsigned int& component_count\n) {\nFILE *f = fopen(filename, \"rb\");\nif (!f)\n@@ -1042,7 +1042,7 @@ static astcenc_image* load_ktx_uncompressed_image(\ndelete[] buf;\nis_hdr = bitness == 32;\n- num_components = components;\n+ component_count = components;\nreturn astc_img;\n}\n@@ -1486,7 +1486,7 @@ astcenc_image* load_dds_uncompressed_image(\nconst char* filename,\nbool y_flip,\nbool& is_hdr,\n- unsigned int& num_components\n+ unsigned int& component_count\n) {\nFILE *f = fopen(filename, \"rb\");\nif (!f)\n@@ -1757,7 +1757,7 @@ astcenc_image* load_dds_uncompressed_image(\ndelete[] buf;\nis_hdr = bitness == 16;\n- num_components = components;\n+ component_count = components;\nreturn astc_img;\n}\n@@ -2112,7 +2112,7 @@ astcenc_image* load_ncimage(\nconst char* filename,\nbool y_flip,\nbool& is_hdr,\n- unsigned int& num_components\n+ unsigned int& component_count\n) {\n// Get the file extension\nconst char* eptr = strrchr(filename, '.');\n@@ -2128,7 +2128,7 @@ astcenc_image* load_ncimage(\n|| strcmp(eptr, loader_descs[i].ending1) == 0\n|| strcmp(eptr, loader_descs[i].ending2) == 0)\n{\n- return loader_descs[i].loader_func(filename, y_flip, is_hdr, num_components);\n+ return loader_descs[i].loader_func(filename, y_flip, is_hdr, component_count);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_internal.h", "new_path": "Source/astcenccli_internal.h", "diff": "@@ -61,7 +61,7 @@ struct cli_config_options\n* @param filename The file path on disk.\n* @param y_flip Should this image be Y flipped?\n* @param[out] is_hdr Is the loaded image HDR?\n- * @param[out] num_components The number of components in the loaded image.\n+ * @param[out] component_count The number of components in the loaded image.\n*\n* @return The astc image file, or nullptr on error.\n*/\n@@ -69,7 +69,7 @@ astcenc_image* load_ncimage(\nconst char* filename,\nbool y_flip,\nbool& is_hdr,\n- unsigned int& num_components);\n+ unsigned int& component_count);\nint store_ncimage(\nconst astcenc_image* output_image,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -177,7 +177,7 @@ static std::string get_slice_filename(\n* @param dim_z The number of slices to load.\n* @param y_flip Should this image be Y flipped?\n* @param[out] is_hdr Is the loaded image HDR?\n- * @param[out] num_components The number of components in the loaded image.\n+ * @param[out] component_count The number of components in the loaded image.\n*\n* @return The astc image file, or nullptr on error.\n*/\n@@ -186,19 +186,19 @@ static astcenc_image* load_uncomp_file(\nunsigned int dim_z,\nbool y_flip,\nbool& is_hdr,\n- unsigned int& num_components\n+ unsigned int& component_count\n) {\nastcenc_image *image = nullptr;\n// For a 2D image just load the image directly\nif (dim_z == 1)\n{\n- image = load_ncimage(filename, y_flip, is_hdr, num_components);\n+ image = load_ncimage(filename, y_flip, is_hdr, component_count);\n}\nelse\n{\nbool slice_is_hdr;\n- unsigned int slice_num_components;\n+ unsigned int slice_component_count;\nastcenc_image* slice = nullptr;\nstd::vector<astcenc_image*> slices;\n@@ -214,7 +214,7 @@ static astcenc_image* load_uncomp_file(\n}\nslice = load_ncimage(slice_name.c_str(), y_flip,\n- slice_is_hdr, slice_num_components);\n+ slice_is_hdr, slice_component_count);\nif (!slice)\n{\nbreak;\n@@ -232,7 +232,7 @@ static astcenc_image* load_uncomp_file(\n// Check slices are consistent with each other\nif (image_index != 0)\n{\n- if ((is_hdr != slice_is_hdr) || (num_components != slice_num_components))\n+ if ((is_hdr != slice_is_hdr) || (component_count != slice_component_count))\n{\nprintf(\"ERROR: Image array[0] and [%d] are different formats\\n\", image_index);\nbreak;\n@@ -249,7 +249,7 @@ static astcenc_image* load_uncomp_file(\nelse\n{\nis_hdr = slice_is_hdr;\n- num_components = slice_num_components;\n+ component_count = slice_component_count;\n}\n}\n@@ -1319,7 +1319,7 @@ int main(\n}\nastcenc_image* image_uncomp_in = nullptr ;\n- unsigned int image_uncomp_in_num_chan = 0;\n+ unsigned int image_uncomp_in_channel_count = 0;\nbool image_uncomp_in_is_hdr = false;\nastcenc_image* image_decomp_out = nullptr;\n@@ -1338,7 +1338,7 @@ int main(\nif (operation & ASTCENC_STAGE_LD_NCOMP)\n{\nimage_uncomp_in = load_uncomp_file(input_filename.c_str(), cli_config.array_size,\n- cli_config.y_flip, image_uncomp_in_is_hdr, image_uncomp_in_num_chan);\n+ cli_config.y_flip, image_uncomp_in_is_hdr, image_uncomp_in_channel_count);\nif (!image_uncomp_in)\n{\nprintf (\"ERROR: Failed to load uncompressed image file\\n\");\n@@ -1392,7 +1392,7 @@ int main(\nprintf(\" Dimensions: 2D, %ux%u\\n\",\nimage_uncomp_in->dim_x, image_uncomp_in->dim_y);\n}\n- printf(\" Channels: %d\\n\\n\", image_uncomp_in_num_chan);\n+ printf(\" Channels: %d\\n\\n\", image_uncomp_in_channel_count);\n}\n}\n@@ -1486,7 +1486,7 @@ int main(\n// Print metrics in comparison mode\nif (operation & ASTCENC_STAGE_COMPARE)\n{\n- compute_error_metrics(image_uncomp_in_is_hdr, image_uncomp_in_num_chan, image_uncomp_in,\n+ compute_error_metrics(image_uncomp_in_is_hdr, image_uncomp_in_channel_count, image_uncomp_in,\nimage_decomp_out, cli_config.low_fstop, cli_config.high_fstop);\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Consistently use "count" not "num"
61,745
07.01.2021 22:31:41
0
d0a689c05079bc5c087a8236ac10552bb0e40659
More promises on hot loops
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -46,15 +46,19 @@ void compute_averages_and_directions_rgba(\nfloat4* directions_rgba\n) {\nint partition_count = pt->partition_count;\n+ promise(partition_count > 0);\n+\nfor (int partition = 0; partition < partition_count; partition++)\n{\nconst uint8_t *weights = pt->texels_of_partition[partition];\n- int texelcount = pt->texels_per_partition[partition];\nfloat4 base_sum = float4(0.0f);\nfloat partition_weight = 0.0f;\n- for (int i = 0; i < texelcount; i++)\n+ int texel_count = pt->texels_per_partition[partition];\n+ promise(texel_count > 0);\n+\n+ for (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\nfloat weight = ewb->texel_weight[iwt];\n@@ -75,7 +79,7 @@ void compute_averages_and_directions_rgba(\nfloat4 sum_zp = float4(0.0f);\nfloat4 sum_wp = float4(0.0f);\n- for (int i = 0; i < texelcount; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\nfloat weight = ewb->texel_weight[iwt];\n@@ -143,18 +147,22 @@ void compute_averages_and_directions_rgb(\nfloat3* averages,\nfloat3* directions_rgb\n) {\n- int partition_count = pt->partition_count;\nconst float *texel_weights = ewb->texel_weight_rgb;\n+ int partition_count = pt->partition_count;\n+ promise(partition_count > 0);\n+\nfor (int partition = 0; partition < partition_count; partition++)\n{\nconst uint8_t *weights = pt->texels_of_partition[partition];\n- int texelcount = pt->texels_per_partition[partition];\nfloat3 base_sum = float3(0.0f, 0.0f, 0.0f);\nfloat partition_weight = 0.0f;\n- for (int i = 0; i < texelcount; i++)\n+ int texel_count = pt->texels_per_partition[partition];\n+ promise(texel_count > 0);\n+\n+ for (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n@@ -174,7 +182,7 @@ void compute_averages_and_directions_rgb(\nfloat3 sum_yp = float3(0.0f);\nfloat3 sum_zp = float3(0.0f);\n- for (int i = 0; i < texelcount; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n@@ -266,15 +274,19 @@ void compute_averages_and_directions_3_components(\n}\nint partition_count = pt->partition_count;\n+ promise(partition_count > 0);\n+\nfor (int partition = 0; partition < partition_count; partition++)\n{\nconst uint8_t *weights = pt->texels_of_partition[partition];\n- int texelcount = pt->texels_per_partition[partition];\nfloat3 base_sum = float3(0.0f);\nfloat partition_weight = 0.0f;\n- for (int i = 0; i < texelcount; i++)\n+ int texel_count = pt->texels_per_partition[partition];\n+ promise(texel_count > 0);\n+\n+ for (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n@@ -295,7 +307,7 @@ void compute_averages_and_directions_3_components(\nfloat3 sum_yp = float3(0.0f);\nfloat3 sum_zp = float3(0.0f);\n- for (int i = 0; i < texelcount; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n@@ -383,15 +395,19 @@ void compute_averages_and_directions_2_components(\n}\nint partition_count = pt->partition_count;\n+ promise(partition_count > 0);\n+\nfor (int partition = 0; partition < partition_count; partition++)\n{\nconst uint8_t *weights = pt->texels_of_partition[partition];\n- int texelcount = pt->texels_per_partition[partition];\nfloat2 base_sum = float2(0.0f);\nfloat partition_weight = 0.0f;\n- for (int i = 0; i < texelcount; i++)\n+ int texel_count = pt->texels_per_partition[partition];\n+ promise(texel_count > 0);\n+\n+ for (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n@@ -409,7 +425,7 @@ void compute_averages_and_directions_2_components(\nfloat2 sum_xp = float2(0.0f);\nfloat2 sum_yp = float2(0.0f);\n- for (int i = 0; i < texelcount; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n@@ -466,12 +482,14 @@ void compute_error_squared_rgba(\nfloat blue_errorsum = 0.0f;\nfloat alpha_errorsum = 0.0f;\n- for (int partition = 0; partition < pt->partition_count; partition++)\n+ int partition_count = pt->partition_count;\n+ promise(partition_count > 0);\n+\n+ for (int partition = 0; partition < partition_count; partition++)\n{\n// TODO: sort partitions by number of texels. For warp-architectures,\n// this can reduce the running time by about 25-50%.\nconst uint8_t *weights = pt->texels_of_partition[partition];\n- int texelcount = pt->texels_per_partition[partition];\nfloat uncorr_lowparam = 1e10f;\nfloat uncorr_highparam = -1e10f;\n@@ -491,7 +509,10 @@ void compute_error_squared_rgba(\n// TODO: split up this loop due to too many temporaries; in particular,\n// the six line functions will consume 18 vector registers\n- for (int i = 0; i < texelcount; i++)\n+ int texel_count = pt->texels_per_partition[partition];\n+ promise(texel_count > 0);\n+\n+ for (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\n@@ -597,12 +618,14 @@ void compute_error_squared_rgb(\nfloat green_errorsum = 0.0f;\nfloat blue_errorsum = 0.0f;\n- for (int partition = 0; partition < pt->partition_count; partition++)\n+ int partition_count = pt->partition_count;\n+ promise(partition_count > 0);\n+\n+ for (int partition = 0; partition < partition_count; partition++)\n{\n// TODO: sort partitions by number of texels. For warp-architectures,\n// this can reduce the running time by about 25-50%.\nconst uint8_t *weights = pt->texels_of_partition[partition];\n- int texelcount = pt->texels_per_partition[partition];\nfloat uncorr_lowparam = 1e10f;\nfloat uncorr_highparam = -1e10f;\n@@ -621,8 +644,10 @@ void compute_error_squared_rgb(\n// TODO: split up this loop due to too many temporaries; in\n// particular, the six line functions will consume 18 vector registers\n+ int texel_count = pt->texels_per_partition[partition];\n+ promise(texel_count > 0);\n- for (int i = 0; i < texelcount; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -934,8 +934,10 @@ float compute_error_of_weight_set(\nconst decimation_table* it,\nconst float* weights\n) {\n- int texel_count = it->texel_count;\nfloat error_summa = 0.0;\n+\n+ int texel_count = it->texel_count;\n+ promise(texel_count > 0);\nfor (int i = 0; i < texel_count; i++)\n{\nerror_summa += compute_error_of_texel(eai, i, it, weights);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
More promises on hot loops
61,745
09.01.2021 12:01:53
0
7fae1d6c29b8b6e0332ebaa8d8ed462b1d9393fc
Update Building.md Remove -j option from nmake
[ { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "@@ -41,7 +41,7 @@ from your build dir, and install to your target install directory.\n```shell\n# Run a build and install build outputs in `${CMAKE_INSTALL_PREFIX}/astcenc/`\ncd build\n-nmake install -j16\n+nmake install\n```\n## macOS and Linux\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update Building.md Remove -j option from nmake
61,745
09.01.2021 12:02:35
0
be14d8360df966b5baa15a6aef3cc3996d5a9881
Update Building.md Use ^ line continuation in Windows shell command samples
[ { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "@@ -25,7 +25,7 @@ cd build\n# Configure your build of choice, for example:\n# x86-64\n-cmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n+cmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.\\ ^\n-DISA_AVX2=ON -DISA_SSE41=ON -DISA_SSE2=ON ..\n```\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update Building.md Use ^ line continuation in Windows shell command samples
61,745
12.01.2021 15:36:50
0
a1ebd6d0e8e16297a290e8c29b0c26e8e94d4d16
Fix AVX2 lane() on Windows
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_avx2_8.h", "new_path": "Source/astcenc_vecmathlib_avx2_8.h", "diff": "@@ -98,7 +98,7 @@ struct vfloat8\ntemplate <int l> ASTCENC_SIMD_INLINE float lane() const\n{\n#ifdef _MSC_VER\n- return m.m256_f32[i];\n+ return m.m256_f32[l];\n#else\nunion { __m256 m; float f[8]; } cvt;\ncvt.m = m;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix AVX2 lane() on Windows
61,745
12.01.2021 18:48:18
0
cb7153f752111866e00156a556d7f1ef23fd4887
Change quantization_mode_table to use int8_t
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -785,7 +785,7 @@ int is_legal_3d_block_size(\nextern const uint8_t color_quantization_tables[21][256];\nextern const uint8_t color_unquantization_tables[21][256];\n-extern int quantization_mode_table[17][128];\n+extern int8_t quantization_mode_table[17][128];\nvoid encode_ise(\nint quantization_level,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_quantization.cpp", "new_path": "Source/astcenc_quantization.cpp", "diff": "@@ -533,11 +533,10 @@ const uint8_t color_unquantization_tables[21][256] = {\n}\n};\n-// quantization_mode_table[integercount/2][bits] gives\n-// us the quantization level for a given integer count and number of bits that\n-// the integer may fit into. This is needed for color decoding,\n-// and for the color encoding.\n-int quantization_mode_table[17][128];\n+// The quantization_mode_table[integercount/2][bits] gives us the quantization\n+// level for a given integer count and number of bits that the integer may fit\n+// into. This is needed for color decoding, and for the color encoding.\n+int8_t quantization_mode_table[17][128];\nvoid build_quantization_mode_table()\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Change quantization_mode_table to use int8_t
61,745
12.01.2021 18:54:41
0
5e777791c44bb6132c79043b414bfa9fee7ef873
Avoid goto in hdr luma encoding function
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -1685,33 +1685,27 @@ static int try_quantize_hdr_luminance_small_range3(\nv0 = lowval & 0x7F;\nv0e = color_quantization_tables[quantization_level][v0];\nv0d = color_unquantization_tables[quantization_level][v0e];\n- if ((v0d & 0x80) == 0x80)\n- {\n- goto LOW_PRECISION_SUBMODE;\n- }\n- lowval = (lowval & ~0x7F) | (v0d & 0x7F);\n+ if (v0d < 0x80)\n+ {\n+ lowval = (lowval & ~0x7F) | v0d;\ndiffval = highval - lowval;\n- if (diffval < 0 || diffval > 15)\n+ if (diffval >= 0 && diffval <= 15)\n{\n- goto LOW_PRECISION_SUBMODE;\n- }\n-\nv1 = ((lowval >> 3) & 0xF0) | diffval;\nv1e = color_quantization_tables[quantization_level][v1];\nv1d = color_unquantization_tables[quantization_level][v1e];\n- if ((v1d & 0xF0) != (v1 & 0xF0))\n+ if ((v1d & 0xF0) == (v1 & 0xF0))\n{\n- goto LOW_PRECISION_SUBMODE;\n- }\n-\noutput[0] = v0e;\noutput[1] = v1e;\nreturn 1;\n+ }\n+ }\n+ }\n// failed to encode the high-precision submode; well, then try to encode the\n// low-precision submode.\n-LOW_PRECISION_SUBMODE:\nlowval = (ilum0 + 32) >> 6;\nhighval = (ilum1 + 32) >> 6;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Avoid goto in hdr luma encoding function
61,745
12.01.2021 20:07:31
0
6a5ea275b0ba236fa17c1f41da8ea9e7adff7b83
Shrink symbolic_compressed_block
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -1850,7 +1850,6 @@ int pack_color_endpoints(\nint retval = 0;\n- // TODO: Make format an endpoint_fmt enum type\nswitch (format)\n{\ncase FMT_RGB:\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -465,7 +465,7 @@ static void compress_symbolic_block_fixed_partition_1_plane(\nfor (int j = 0; j < weights_to_copy; j++)\n{\n- scb->plane1_weights[j] = u8_weight_src[j];\n+ scb->weights[j] = u8_weight_src[j];\n}\nscb++;\n@@ -815,8 +815,8 @@ static void compress_symbolic_block_fixed_partition_2_planes(\nfor (int j = 0; j < weights_to_copy; j++)\n{\n- scb->plane1_weights[j] = u8_weight1_src[j];\n- scb->plane2_weights[j] = u8_weight2_src[j];\n+ scb->weights[j] = u8_weight1_src[j];\n+ scb->weights[j + PLANE2_WEIGHTS_OFFSET] = u8_weight2_src[j];\n}\nscb++;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -241,14 +241,14 @@ void decompress_symbolic_block(\nfor (int i = 0; i < weight_count; i++)\n{\n- uq_plane1_weights[i] = qat->unquantized_value[scb->plane1_weights[i]];\n+ uq_plane1_weights[i] = qat->unquantized_value[scb->weights[i]];\n}\nif (is_dual_plane)\n{\nfor (int i = 0; i < weight_count; i++)\n{\n- uq_plane2_weights[i] = qat->unquantized_value[scb->plane2_weights[i]];\n+ uq_plane2_weights[i] = qat->unquantized_value[scb->weights[i + PLANE2_WEIGHTS_OFFSET]];\n}\n}\n@@ -362,14 +362,14 @@ float compute_symbolic_block_difference(\nfor (int i = 0; i < weight_count; i++)\n{\n- uq_plane1_weights[i] = qat->unquantized_value[scb->plane1_weights[i]];\n+ uq_plane1_weights[i] = qat->unquantized_value[scb->weights[i]];\n}\nif (is_dual_plane)\n{\nfor (int i = 0; i < weight_count; i++)\n{\n- uq_plane2_weights[i] = qat->unquantized_value[scb->plane2_weights[i]];\n+ uq_plane2_weights[i] = qat->unquantized_value[scb->weights[i + PLANE2_WEIGHTS_OFFSET]];\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "============================================================================ */\n#define MAX_TEXELS_PER_BLOCK 216\n#define MAX_WEIGHTS_PER_BLOCK 64\n+#define PLANE2_WEIGHTS_OFFSET (MAX_WEIGHTS_PER_BLOCK/2)\n#define MIN_WEIGHT_BITS_PER_BLOCK 24\n#define MAX_WEIGHT_BITS_PER_BLOCK 96\n#define PARTITION_BITS 10\n@@ -633,10 +634,8 @@ struct quantization_and_transfer_table\n/** The quantization level used */\nquantization_method method;\n/** The unscrambled unquantized value. */\n- // TODO: Converted to floats to support AVX gathers\nfloat unquantized_value_unsc[33];\n/** The scrambling order: value[map[i]] == value_unsc[i] */\n- // TODO: Converted to u32 to support AVX gathers\nint32_t scramble_map[32];\n/** The scrambled unquantized values. */\nuint8_t unquantized_value[32];\n@@ -681,12 +680,13 @@ struct symbolic_compressed_block\nint partition_index; // 0 to 1023\nint color_formats[4]; // color format for each endpoint color pair.\nint color_formats_matched; // color format for all endpoint pairs are matched.\n- int color_values[4][12]; // quantized endpoint color pairs.\nint color_quantization_level;\n- uint8_t plane1_weights[MAX_WEIGHTS_PER_BLOCK]; // quantized and decimated weights\n- uint8_t plane2_weights[MAX_WEIGHTS_PER_BLOCK];\nint plane2_color_component; // color component for the secondary plane of weights\n+ int color_values[4][12]; // quantized endpoint color pairs.\nint constant_color[4]; // constant-color, as FP16 or UINT16. Used for constant-color blocks only.\n+ // Quantized and decimated weights. In the case of dual plane, the second\n+ // index plane starts at weights[PLANE2_WEIGHTS_OFFSET]\n+ uint8_t weights[MAX_WEIGHTS_PER_BLOCK];\n};\nstruct physical_compressed_block\n@@ -1352,3 +1352,4 @@ void aligned_free(T* ptr)\n}\n#endif\n+\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_symbolic_physical.cpp", "new_path": "Source/astcenc_symbolic_physical.cpp", "diff": "@@ -144,14 +144,14 @@ void symbolic_to_physical(\nuint8_t weights[64];\nfor (int i = 0; i < weight_count; i++)\n{\n- weights[2 * i] = scb.plane1_weights[i];\n- weights[2 * i + 1] = scb.plane2_weights[i];\n+ weights[2 * i] = scb.weights[i];\n+ weights[2 * i + 1] = scb.weights[i + PLANE2_WEIGHTS_OFFSET];\n}\nencode_ise(weight_quantization_method, real_weight_count, weights, weightbuf, 0);\n}\nelse\n{\n- encode_ise(weight_quantization_method, weight_count, scb.plane1_weights, weightbuf, 0);\n+ encode_ise(weight_quantization_method, weight_count, scb.weights, weightbuf, 0);\n}\nfor (int i = 0; i < 16; i++)\n@@ -360,13 +360,13 @@ void physical_to_symbolic(\ndecode_ise(weight_quantization_method, real_weight_count, bswapped, indices, 0);\nfor (int i = 0; i < weight_count; i++)\n{\n- scb.plane1_weights[i] = indices[2 * i];\n- scb.plane2_weights[i] = indices[2 * i + 1];\n+ scb.weights[i] = indices[2 * i];\n+ scb.weights[i + PLANE2_WEIGHTS_OFFSET] = indices[2 * i + 1];\n}\n}\nelse\n{\n- decode_ise(weight_quantization_method, weight_count, bswapped, scb.plane1_weights, 0);\n+ decode_ise(weight_quantization_method, weight_count, bswapped, scb.weights, 0);\n}\nif (is_dual_plane && partition_count == 4)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Shrink symbolic_compressed_block
61,745
12.01.2021 20:11:53
0
0e0e2fa2bcb6f2d80dfaf16c92fbe70aac65fecf
Add missing static function qualifier
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -551,7 +551,7 @@ static int try_quantize_alpha_delta(\nreturn 1;\n}\n-int try_quantize_luminance_alpha_delta(\n+static int try_quantize_luminance_alpha_delta(\nfloat4 color0,\nfloat4 color1,\nint output[8],\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add missing static function qualifier
61,745
12.01.2021 21:09:43
0
37db42bae3fe43685f22d1f668f9ccae15b83ae9
Change some tmp array types to smaller ones
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes2.cpp", "new_path": "Source/astcenc_block_sizes2.cpp", "diff": "@@ -118,7 +118,9 @@ static int decode_block_mode_2d(\nint qmode = (base_quant_mode - 2) + 6 * H;\nint weightbits = compute_ise_bitcount(weight_count, (quantization_method)qmode);\n- if (weight_count > MAX_WEIGHTS_PER_BLOCK || weightbits < MIN_WEIGHT_BITS_PER_BLOCK || weightbits > MAX_WEIGHT_BITS_PER_BLOCK)\n+ if (weight_count > MAX_WEIGHTS_PER_BLOCK ||\n+ weightbits < MIN_WEIGHT_BITS_PER_BLOCK ||\n+ weightbits > MAX_WEIGHT_BITS_PER_BLOCK)\n{\nreturn 0;\n}\n@@ -237,12 +239,12 @@ static void initialize_decimation_table_2d(\nint texels_per_block = xdim * ydim;\nint weights_per_block = x_weights * y_weights;\n- int weightcount_of_texel[MAX_TEXELS_PER_BLOCK];\n- int grid_weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\n- int weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\n+ uint8_t weightcount_of_texel[MAX_TEXELS_PER_BLOCK];\n+ uint8_t grid_weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\n+ uint8_t weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\n- int texelcount_of_weight[MAX_WEIGHTS_PER_BLOCK];\n- int texels_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\n+ uint8_t texelcount_of_weight[MAX_WEIGHTS_PER_BLOCK];\n+ uint8_t texels_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\nint texelweights_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\nfor (int i = 0; i < weights_per_block; i++)\n@@ -302,8 +304,7 @@ static void initialize_decimation_table_2d(\n{\ndt->texel_weight_count[i] = weightcount_of_texel[i];\n- // ensure that all 4 entries are actually initialized.\n- // This allows a branch-free implementation of compute_value_of_texel_flt()\n+ // Init all 4 entries so we can rely on zeros for vectorization\nfor (int j = 0; j < 4; j++)\n{\ndt->texel_weights_int_t4[i][j] = 0;\n@@ -317,13 +318,12 @@ static void initialize_decimation_table_2d(\nfor (int j = 0; j < weightcount_of_texel[i]; j++)\n{\n- // TODO: Why the uint8_t casts? Can we make these smaller?\n- dt->texel_weights_int_t4[i][j] = (uint8_t)weights_of_texel[i][j];\n+ dt->texel_weights_int_t4[i][j] = weights_of_texel[i][j];\ndt->texel_weights_float_t4[i][j] = ((float)weights_of_texel[i][j]) * (1.0f / TEXEL_WEIGHT_SUM);\n- dt->texel_weights_t4[i][j] = (uint8_t)grid_weights_of_texel[i][j];\n+ dt->texel_weights_t4[i][j] = grid_weights_of_texel[i][j];\ndt->texel_weights_float_4t[j][i] = ((float)weights_of_texel[i][j]) * (1.0f / TEXEL_WEIGHT_SUM);\n- dt->texel_weights_4t[j][i] = (uint8_t)grid_weights_of_texel[i][j];\n+ dt->texel_weights_4t[j][i] = grid_weights_of_texel[i][j];\n}\n}\n@@ -333,9 +333,9 @@ static void initialize_decimation_table_2d(\nfor (int j = 0; j < texelcount_of_weight[i]; j++)\n{\n- int texel = texels_of_weight[i][j];\n- dt->weight_texel[i][j] = (uint8_t)texel;\n- dt->weights_int[i][j] = (uint8_t)texelweights_of_weight[i][j];\n+ uint8_t texel = texels_of_weight[i][j];\n+ dt->weight_texel[i][j] = texel;\n+ dt->weights_int[i][j] = texelweights_of_weight[i][j];\ndt->weights_flt[i][j] = (float)texelweights_of_weight[i][j];\n// perform a layer of array unrolling. An aspect of this unrolling is that\n@@ -344,23 +344,23 @@ static void initialize_decimation_table_2d(\nint swap_idx = -1;\nfor (int k = 0; k < 4; k++)\n{\n- int dttw = dt->texel_weights_t4[texel][k];\n+ uint8_t dttw = dt->texel_weights_t4[texel][k];\nfloat dttwf = dt->texel_weights_float_t4[texel][k];\nif (dttw == i && dttwf != 0.0f)\n{\nswap_idx = k;\n}\n- dt->texel_weights_texel[i][j][k] = (uint8_t)dttw;\n+ dt->texel_weights_texel[i][j][k] = dttw;\ndt->texel_weights_float_texel[i][j][k] = dttwf;\n}\nif (swap_idx != 0)\n{\n- int vi = dt->texel_weights_texel[i][j][0];\n+ uint8_t vi = dt->texel_weights_texel[i][j][0];\nfloat vf = dt->texel_weights_float_texel[i][j][0];\ndt->texel_weights_texel[i][j][0] = dt->texel_weights_texel[i][j][swap_idx];\ndt->texel_weights_float_texel[i][j][0] = dt->texel_weights_float_texel[i][j][swap_idx];\n- dt->texel_weights_texel[i][j][swap_idx] = (uint8_t)vi;\n+ dt->texel_weights_texel[i][j][swap_idx] = vi;\ndt->texel_weights_float_texel[i][j][swap_idx] = vf;\n}\n}\n@@ -520,8 +520,7 @@ static void initialize_decimation_table_3d(\n{\ndt->texel_weight_count[i] = weightcount_of_texel[i];\n- // ensure that all 4 entries are actually initialized.\n- // This allows a branch-free implementation of compute_value_of_texel_flt()\n+ // Init all 4 entries so we can rely on zeros for vectorization\nfor (int j = 0; j < 4; j++)\n{\ndt->texel_weights_int_t4[i][j] = 0;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_kmeans_partitioning.cpp", "new_path": "Source/astcenc_kmeans_partitioning.cpp", "diff": "@@ -315,15 +315,6 @@ static inline int partition_mismatch3(\nreturn v0;\n}\n-static inline int MIN3(\n- int a,\n- int b,\n- int c\n-) {\n- int d = astc::min(a, b);\n- return astc::min(c, d);\n-}\n-\n// compute the bit-mismatch for a partitioning in 4-partition mode\nstatic inline int partition_mismatch4(\nuint64_t a0,\n@@ -362,14 +353,12 @@ static inline int partition_mismatch4(\nint mx02 = astc::min(p20 + p32, p22 + p30);\nint mx01 = astc::min(p21 + p30, p20 + p31);\n- int v0 = p00 + MIN3(p11 + mx23, p12 + mx13, p13 + mx12);\n- int v1 = p01 + MIN3(p10 + mx23, p12 + mx03, p13 + mx02);\n- int v2 = p02 + MIN3(p11 + mx03, p10 + mx13, p13 + mx01);\n- int v3 = p03 + MIN3(p11 + mx02, p12 + mx01, p10 + mx12);\n+ int v0 = p00 + astc::min(p11 + mx23, p12 + mx13, p13 + mx12);\n+ int v1 = p01 + astc::min(p10 + mx23, p12 + mx03, p13 + mx02);\n+ int v2 = p02 + astc::min(p11 + mx03, p10 + mx13, p13 + mx01);\n+ int v3 = p03 + astc::min(p11 + mx02, p12 + mx01, p10 + mx12);\n- int x0 = astc::min(v0, v1);\n- int x1 = astc::min(v2, v3);\n- return astc::min(x0, x1);\n+ return astc::min(v0, v1, v2, v3);\n}\nstatic void count_partition_mismatch_bits(\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "@@ -107,6 +107,41 @@ static inline T min(T p, T q)\nreturn p < q ? p : q;\n}\n+/**\n+ * @brief Return the minimum of three values.\n+ *\n+ * For floats, NaNs are turned into @c r.\n+ *\n+ * @param p The first value to compare.\n+ * @param q The second value to compare.\n+ * @param r The third value to compare.\n+ *\n+ * @return The smallest value.\n+ */\n+template<typename T>\n+static inline T min(T p, T q, T r)\n+{\n+ return min(min(p, q), r);\n+}\n+\n+/**\n+ * @brief Return the minimum of four values.\n+ *\n+ * For floats, NaNs are turned into @c s.\n+ *\n+ * @param p The first value to compare.\n+ * @param q The second value to compare.\n+ * @param r The third value to compare.\n+ * @param s The fourth value to compare.\n+ *\n+ * @return The smallest value.\n+ */\n+template<typename T>\n+static inline T min(T p, T q, T r, T s)\n+{\n+ return min(min(p, q), min(r, s));\n+}\n+\n/**\n* @brief Return the maximum of two values.\n*\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Change some tmp array types to smaller ones
61,745
12.01.2021 21:14:08
0
91d3f821e93bf465df8b2b921c338dd414441c01
Shrink arrays for 3D blocks
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes2.cpp", "new_path": "Source/astcenc_block_sizes2.cpp", "diff": "@@ -382,12 +382,12 @@ static void initialize_decimation_table_3d(\nint texels_per_block = xdim * ydim * zdim;\nint weights_per_block = x_weights * y_weights * z_weights;\n- int weightcount_of_texel[MAX_TEXELS_PER_BLOCK];\n- int grid_weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\n- int weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\n+ uint8_t weightcount_of_texel[MAX_TEXELS_PER_BLOCK];\n+ uint8_t grid_weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\n+ uint8_t weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\n- int texelcount_of_weight[MAX_WEIGHTS_PER_BLOCK];\n- int texels_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\n+ uint8_t texelcount_of_weight[MAX_WEIGHTS_PER_BLOCK];\n+ uint8_t texels_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\nint texelweights_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\nfor (int i = 0; i < weights_per_block; i++)\n@@ -533,12 +533,12 @@ static void initialize_decimation_table_3d(\nfor (int j = 0; j < weightcount_of_texel[i]; j++)\n{\n- dt->texel_weights_int_t4[i][j] = (uint8_t)weights_of_texel[i][j];\n+ dt->texel_weights_int_t4[i][j] = weights_of_texel[i][j];\ndt->texel_weights_float_t4[i][j] = ((float)weights_of_texel[i][j]) * (1.0f / TEXEL_WEIGHT_SUM);\n- dt->texel_weights_t4[i][j] = (uint8_t)grid_weights_of_texel[i][j];\n+ dt->texel_weights_t4[i][j] = grid_weights_of_texel[i][j];\ndt->texel_weights_float_4t[j][i] = ((float)weights_of_texel[i][j]) * (1.0f / TEXEL_WEIGHT_SUM);\n- dt->texel_weights_4t[j][i] = (uint8_t)grid_weights_of_texel[i][j];\n+ dt->texel_weights_4t[j][i] = grid_weights_of_texel[i][j];\n}\n}\n@@ -548,8 +548,8 @@ static void initialize_decimation_table_3d(\nfor (int j = 0; j < texelcount_of_weight[i]; j++)\n{\nint texel = texels_of_weight[i][j];\n- dt->weight_texel[i][j] = (uint8_t)texel;\n- dt->weights_int[i][j] = (uint8_t)texelweights_of_weight[i][j];\n+ dt->weight_texel[i][j] = texel;\n+ dt->weights_int[i][j] = texelweights_of_weight[i][j];\ndt->weights_flt[i][j] = (float)texelweights_of_weight[i][j];\n// perform a layer of array unrolling. An aspect of this unrolling is that\n@@ -558,23 +558,23 @@ static void initialize_decimation_table_3d(\nint swap_idx = -1;\nfor (int k = 0; k < 4; k++)\n{\n- int dttw = dt->texel_weights_t4[texel][k];\n+ uint8_t dttw = dt->texel_weights_t4[texel][k];\nfloat dttwf = dt->texel_weights_float_t4[texel][k];\nif (dttw == i && dttwf != 0.0f)\n{\nswap_idx = k;\n}\n- dt->texel_weights_texel[i][j][k] = (uint8_t)dttw;\n+ dt->texel_weights_texel[i][j][k] = dttw;\ndt->texel_weights_float_texel[i][j][k] = dttwf;\n}\nif (swap_idx != 0)\n{\n- int vi = dt->texel_weights_texel[i][j][0];\n+ uint8_t vi = dt->texel_weights_texel[i][j][0];\nfloat vf = dt->texel_weights_float_texel[i][j][0];\ndt->texel_weights_texel[i][j][0] = dt->texel_weights_texel[i][j][swap_idx];\ndt->texel_weights_float_texel[i][j][0] = dt->texel_weights_float_texel[i][j][swap_idx];\n- dt->texel_weights_texel[i][j][swap_idx] = (uint8_t)vi;\n+ dt->texel_weights_texel[i][j][swap_idx] = vi;\ndt->texel_weights_float_texel[i][j][swap_idx] = vf;\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Shrink arrays for 3D blocks
61,745
12.01.2021 21:33:15
0
74625e9f47435736b37c504a355ec3e6bfa71917
Shrink more weight arrays to uint8_t
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes2.cpp", "new_path": "Source/astcenc_block_sizes2.cpp", "diff": "@@ -774,7 +774,7 @@ static void construct_block_size_descriptor_2d(\nastc::rand_init(rng_state);\n// pick 64 random texels for use with bitmap partitioning.\n- int arr[MAX_TEXELS_PER_BLOCK];\n+ uint8_t arr[MAX_TEXELS_PER_BLOCK];\nfor (int i = 0; i < x_dim * y_dim; i++)\n{\narr[i] = 0;\n@@ -942,7 +942,7 @@ static void construct_block_size_descriptor_3d(\nastc::rand_init(rng_state);\n// pick 64 random texels for use with bitmap partitioning.\n- int arr[MAX_TEXELS_PER_BLOCK];\n+ uint8_t arr[MAX_TEXELS_PER_BLOCK];\nfor (int i = 0; i < xdim * ydim * zdim; i++)\n{\narr[i] = 0;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "static int compute_value_of_texel_int(\nint texel_to_get,\nconst decimation_table* it,\n- const int* weights\n+ const uint8_t* weights\n) {\nint summed_value = 8;\nint weights_to_evaluate = it->texel_weight_count[texel_to_get];\n@@ -233,39 +233,36 @@ void decompress_symbolic_block(\n}\n// first unquantize the weights\n- int uq_plane1_weights[MAX_WEIGHTS_PER_BLOCK];\n- int uq_plane2_weights[MAX_WEIGHTS_PER_BLOCK];\n+ uint8_t uq_weights[MAX_WEIGHTS_PER_BLOCK];\nint weight_count = it->weight_count;\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quantization_level]);\nfor (int i = 0; i < weight_count; i++)\n{\n- uq_plane1_weights[i] = qat->unquantized_value[scb->weights[i]];\n+ uq_weights[i] = qat->unquantized_value[scb->weights[i]];\n}\nif (is_dual_plane)\n{\nfor (int i = 0; i < weight_count; i++)\n{\n- uq_plane2_weights[i] = qat->unquantized_value[scb->weights[i + PLANE2_WEIGHTS_OFFSET]];\n+ uq_weights[i + PLANE2_WEIGHTS_OFFSET] = qat->unquantized_value[scb->weights[i + PLANE2_WEIGHTS_OFFSET]];\n}\n}\n// then undecimate them.\n- int weights[MAX_TEXELS_PER_BLOCK];\n- int plane2_weights[MAX_TEXELS_PER_BLOCK];\n-\n+ uint8_t weights[MAX_TEXELS_PER_BLOCK];\nfor (int i = 0; i < bsd->texel_count; i++)\n{\n- weights[i] = compute_value_of_texel_int(i, it, uq_plane1_weights);\n+ weights[i] = compute_value_of_texel_int(i, it, uq_weights);\n}\nif (is_dual_plane)\n{\nfor (int i = 0; i < bsd->texel_count; i++)\n{\n- plane2_weights[i] = compute_value_of_texel_int(i, it, uq_plane2_weights);\n+ weights[i + PLANE2_WEIGHTS_OFFSET] = compute_value_of_texel_int(i, it, uq_weights + PLANE2_WEIGHTS_OFFSET);\n}\n}\n@@ -280,7 +277,7 @@ void decompress_symbolic_block(\ncolor_endpoint0[partition],\ncolor_endpoint1[partition],\nweights[i],\n- plane2_weights[i],\n+ weights[i + PLANE2_WEIGHTS_OFFSET],\nis_dual_plane ? plane2_color_component : -1);\nblk->rgb_lns[i] = rgb_hdr_endpoint[partition];\n@@ -355,38 +352,36 @@ float compute_symbolic_block_difference(\n}\n// first unquantize the weights\n- int uq_plane1_weights[MAX_WEIGHTS_PER_BLOCK];\n- int uq_plane2_weights[MAX_WEIGHTS_PER_BLOCK];\n+ uint8_t uq_weights[MAX_WEIGHTS_PER_BLOCK];\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quantization_level]);\nfor (int i = 0; i < weight_count; i++)\n{\n- uq_plane1_weights[i] = qat->unquantized_value[scb->weights[i]];\n+ uq_weights[i] = qat->unquantized_value[scb->weights[i]];\n}\nif (is_dual_plane)\n{\nfor (int i = 0; i < weight_count; i++)\n{\n- uq_plane2_weights[i] = qat->unquantized_value[scb->weights[i + PLANE2_WEIGHTS_OFFSET]];\n+ uq_weights[i + PLANE2_WEIGHTS_OFFSET] = qat->unquantized_value[scb->weights[i + PLANE2_WEIGHTS_OFFSET]];\n}\n}\n// then undecimate them.\n- int weights[MAX_TEXELS_PER_BLOCK];\n- int plane2_weights[MAX_TEXELS_PER_BLOCK];\n+ uint8_t weights[MAX_TEXELS_PER_BLOCK];\nfor (int i = 0; i < texel_count; i++)\n{\n- weights[i] = compute_value_of_texel_int(i, it, uq_plane1_weights);\n+ weights[i] = compute_value_of_texel_int(i, it, uq_weights);\n}\nif (is_dual_plane)\n{\nfor (int i = 0; i < texel_count; i++)\n{\n- plane2_weights[i] = compute_value_of_texel_int(i, it, uq_plane2_weights);\n+ weights[i + PLANE2_WEIGHTS_OFFSET] = compute_value_of_texel_int(i, it, uq_weights + PLANE2_WEIGHTS_OFFSET);\n}\n}\n@@ -403,7 +398,7 @@ float compute_symbolic_block_difference(\ncolor_endpoint0[partition],\ncolor_endpoint1[partition],\nweights[i],\n- plane2_weights[i],\n+ weights[i + PLANE2_WEIGHTS_OFFSET],\nis_dual_plane ? plane2_color_component : -1);\nfloat4 newColor = float4((float)color.r,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_kmeans_partitioning.cpp", "new_path": "Source/astcenc_kmeans_partitioning.cpp", "diff": "@@ -151,7 +151,7 @@ static void basic_kmeans_assign_pass(\nint partition_count,\nconst imageblock* blk,\nconst float4* cluster_centers,\n- int* partition_of_texel\n+ uint8_t* partition_of_texel\n) {\nint texels_per_block = xdim * ydim * zdim;\n@@ -230,7 +230,7 @@ static void basic_kmeans_update(\nint zdim,\nint partition_count,\nconst imageblock* blk,\n- const int* partition_of_texel,\n+ const uint8_t* partition_of_texel,\nfloat4* cluster_centers\n) {\nint texels_per_block = xdim * ydim * zdim;\n@@ -465,7 +465,7 @@ void kmeans_compute_partition_ordering(\nint* ordering\n) {\nfloat4 cluster_centers[4];\n- int partition_of_texel[MAX_TEXELS_PER_BLOCK];\n+ uint8_t partition_of_texel[MAX_TEXELS_PER_BLOCK];\n// 3 passes of plain k-means partitioning\nfor (int i = 0; i < 3; i++)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Shrink more weight arrays to uint8_t
61,745
13.01.2021 00:17:41
0
c81ae5d8b6d92159e2218f341b54900bbb78df10
Make scalar and vector horizontal vector ops
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -662,6 +662,18 @@ TEST(vfloat4, hmin)\nEXPECT_EQ(r2.lane<3>(), 0.2f);\n}\n+/** @brief Test vfloat4 hmin_s. */\n+TEST(vfloat4, hmin_s)\n+{\n+ vfloat4 a1(1.1f, 1.5f, 1.6f, 4.0f);\n+ float r1 = hmin_s(a1);\n+ EXPECT_EQ(r1, 1.1f);\n+\n+ vfloat4 a2(1.1f, 1.5f, 1.6f, 0.2f);\n+ float r2 = hmin_s(a2);\n+ EXPECT_EQ(r2, 0.2f);\n+}\n+\n/** @brief Test vfloat4 hmax. */\nTEST(vfloat4, hmax)\n{\n@@ -680,12 +692,24 @@ TEST(vfloat4, hmax)\nEXPECT_EQ(r2.lane<3>(), 1.6f);\n}\n+/** @brief Test vfloat4 hmax_s. */\n+TEST(vfloat4, hmax_s)\n+{\n+ vfloat4 a1(1.1f, 1.5f, 1.6f, 4.0f);\n+ float r1 = hmax_s(a1);\n+ EXPECT_EQ(r1, 4.0f);\n+\n+ vfloat4 a2(1.1f, 1.5f, 1.6f, 0.2f);\n+ float r2 = hmax_s(a2);\n+ EXPECT_EQ(r2, 1.6f);\n+}\n+\n/** @brief Test vfloat4 hadd. */\n-TEST(vfloat4, hadd)\n+TEST(vfloat4, hadd_s)\n{\nvfloat4 a1(1.1f, 1.5f, 1.6f, 4.0f);\nfloat sum = 1.1f + 1.5f + 1.6f + 4.0f;\n- float r = hadd(a1);\n+ float r = hadd_s(a1);\nEXPECT_NEAR(r, sum, 0.005f);\n}\n@@ -796,6 +820,26 @@ TEST(vfloat4, dot)\nEXPECT_EQ(r.lane<3>(), 4.0f);\n}\n+/** @brief Test vfloat4 dot_s. */\n+TEST(vfloat4, dot_s)\n+{\n+ vfloat4 a(1.0f, 2.0f, 4.0f, 8.0f);\n+ vfloat4 b(1.0f, 0.5f, 0.25f, 0.125f);\n+ float r = dot_s(a, b);\n+ EXPECT_EQ(r, 4.0f);\n+}\n+\n+/** @brief Test vfloat4 normalize. */\n+TEST(vfloat4, normalize)\n+{\n+ vfloat4 a(1.0f, 2.0f, 3.0f, 4.0f);\n+ vfloat4 r = normalize(a);\n+ EXPECT_NEAR(r.lane<0>(), 1.0f / astc::sqrt(30.0f), 0.0005f);\n+ EXPECT_NEAR(r.lane<1>(), 2.0f / astc::sqrt(30.0f), 0.0005f);\n+ EXPECT_NEAR(r.lane<2>(), 3.0f / astc::sqrt(30.0f), 0.0005f);\n+ EXPECT_NEAR(r.lane<3>(), 4.0f / astc::sqrt(30.0f), 0.0005f);\n+}\n+\n/** @brief Test vfloat4 float_to_int. */\nTEST(vfloat4, float_to_int)\n{\n@@ -1726,6 +1770,18 @@ TEST(vfloat8, hmin)\nEXPECT_EQ(r2.lane<7>(), 0.2f);\n}\n+/** @brief Test vfloat8 hmin_s. */\n+TEST(vfloat8, hmin_s)\n+{\n+ vfloat8 a1(1.1f, 1.5f, 1.6f, 4.0f, 1.1f, 1.5f, 1.6f, 4.0f);\n+ float r1 = hmin_s(a1);\n+ EXPECT_EQ(r1, 1.1f);\n+\n+ vfloat8 a2(1.1f, 1.5f, 1.6f, 0.2f, 1.1f, 1.5f, 1.6f, 0.2f);\n+ float r2 = hmin_s(a2);\n+ EXPECT_EQ(r2, 0.2f);\n+}\n+\n/** @brief Test vfloat8 hmax. */\nTEST(vfloat8, hmax)\n{\n@@ -1752,12 +1808,24 @@ TEST(vfloat8, hmax)\nEXPECT_EQ(r2.lane<7>(), 1.6f);\n}\n-/** @brief Test vfloat8 hadd. */\n-TEST(vfloat8, hadd)\n+/** @brief Test vfloat8 hmax_s. */\n+TEST(vfloat8, hmax_s)\n+{\n+ vfloat8 a1(1.1f, 1.5f, 1.6f, 4.0f, 1.1f, 1.5f, 1.6f, 4.0f);\n+ float r1 = hmax_s(a1);\n+ EXPECT_EQ(r1, 4.0f);\n+\n+ vfloat8 a2(1.1f, 1.5f, 1.6f, 0.2f, 1.1f, 1.5f, 1.6f, 0.2f);\n+ float r2 = hmax_s(a2);\n+ EXPECT_EQ(r2, 1.6f);\n+}\n+\n+/** @brief Test vfloat8 hadd_s. */\n+TEST(vfloat8, hadd_s)\n{\nvfloat8 a1(1.1f, 1.5f, 1.6f, 4.0f, 1.1f, 1.5f, 1.6f, 4.0f);\nfloat sum = 1.1f + 1.5f + 1.6f + 4.0f + 1.1f + 1.5f + 1.6f + 4.0f;\n- float r = hadd(a1);\n+ float r = hadd_s(a1);\nEXPECT_NEAR(r, sum, 0.005f);\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -607,13 +607,13 @@ void compute_error_squared_rgba(\nsamec_errorsumv = samec_errorsumv + samec_error;\n}\n- uncor_loparam = hmin(uncor_loparamv).lane<0>();\n- uncor_hiparam = hmax(uncor_hiparamv).lane<0>();\n- uncor_errorsum += hadd(uncor_errorsumv);\n+ uncor_loparam = hmin_s(uncor_loparamv);\n+ uncor_hiparam = hmax_s(uncor_hiparamv);\n+ uncor_errorsum += hadd_s(uncor_errorsumv);\n- samec_loparam = hmin(samec_loparamv).lane<0>();\n- samec_hiparam = hmax(samec_hiparamv).lane<0>();\n- samec_errorsum += hadd(samec_errorsumv);\n+ samec_loparam = hmin_s(samec_loparamv);\n+ samec_hiparam = hmax_s(samec_hiparamv);\n+ samec_errorsum += hadd_s(samec_errorsumv);\n#endif\n// Loop tail\n@@ -790,13 +790,13 @@ void compute_error_squared_rgb(\nsamec_errorsumv = samec_errorsumv + samec_error;\n}\n- uncor_loparam = hmin(uncor_loparamv).lane<0>();\n- uncor_hiparam = hmax(uncor_hiparamv).lane<0>();\n- uncor_errorsum += hadd(uncor_errorsumv);\n+ uncor_loparam = hmin_s(uncor_loparamv);\n+ uncor_hiparam = hmax_s(uncor_hiparamv);\n+ uncor_errorsum += hadd_s(uncor_errorsumv);\n- samec_loparam = hmin(samec_loparamv).lane<0>();\n- samec_hiparam = hmax(samec_hiparamv).lane<0>();\n- samec_errorsum += hadd(samec_errorsumv);\n+ samec_loparam = hmin_s(samec_loparamv);\n+ samec_hiparam = hmax_s(samec_hiparamv);\n+ samec_errorsum += hadd_s(samec_errorsumv);\n#endif\n// Loop tail\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -914,7 +914,7 @@ float compute_error_of_weight_set(\n}\n// Accumulate the error vectors into a single error sum\n- error_summa += hadd(verror_summa);\n+ error_summa += hadd_s(verror_summa);\n#endif\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_avx2_8.h", "new_path": "Source/astcenc_vecmathlib_avx2_8.h", "diff": "@@ -744,6 +744,14 @@ ASTCENC_SIMD_INLINE vfloat8 hmin(vfloat8 a)\nreturn vfloat8(_mm256_permute_ps(r, 0));\n}\n+/**\n+ * @brief Return the horizontal minimum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE float hmin_s(vfloat8 a)\n+{\n+ return hmin(a).lane<0>();\n+}\n+\n/**\n* @brief Return the horizontal maximum of a vector.\n*/\n@@ -766,10 +774,18 @@ ASTCENC_SIMD_INLINE vfloat8 hmax(vfloat8 a)\nreturn vfloat8(_mm256_permute_ps(r, 0));\n}\n+/**\n+ * @brief Return the horizontal maximum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE float hmax_s(vfloat8 a)\n+{\n+ return hmax(a).lane<0>();\n+}\n+\n/**\n* @brief Return the horizontal sum of a vector.\n*/\n-ASTCENC_SIMD_INLINE float hadd(vfloat8 a)\n+ASTCENC_SIMD_INLINE float hadd_s(vfloat8 a)\n{\n// Add top and bottom halves, lane 3/2/1/0\n__m128 t = _mm_add_ps(_mm256_extractf128_ps(a.m, 1), _mm256_castps256_ps128(a.m));\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -722,6 +722,14 @@ ASTCENC_SIMD_INLINE vfloat4 hmin(vfloat4 a)\nreturn vfloat4(vminvq_f32(a.m));\n}\n+/**\n+ * @brief Return the horizontal minimum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE float hmin_s(vfloat4 a)\n+{\n+ return hmin(a).lane<0>();\n+}\n+\n/**\n* @brief Return the horizontal maximum of a vector.\n*/\n@@ -730,10 +738,18 @@ ASTCENC_SIMD_INLINE vfloat4 hmax(vfloat4 a)\nreturn vfloat4(vmaxvq_f32(a.m));\n}\n+/**\n+ * @brief Return the horizontal maximum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE float hmax_s(vfloat4 a)\n+{\n+ return hmax(a).lane<0>();\n+}\n+\n/**\n* @brief Return the horizontal sum of a vector.\n*/\n-ASTCENC_SIMD_INLINE float hadd(vfloat4 a)\n+ASTCENC_SIMD_INLINE float hadd_s(vfloat4 a)\n{\nfloat32x2_t t = vadd_f32(vget_high_f32(a.m), vget_low_f32(a.m));\nreturn vget_lane_f32(vpadd_f32(t, t), 0);\n@@ -796,6 +812,24 @@ ASTCENC_SIMD_INLINE vfloat4 dot(vfloat4 a, vfloat4 b)\nreturn vfloat4(vaddvq_f32(vmulq_f32(a.m, b.m)));\n}\n+/**\n+ * @brief Return the dot product for the full 4 lanes, returning scalar.\n+ */\n+ASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\n+{\n+ return dot(a, b).lane<0>();\n+}\n+\n+/**\n+ * @brief Normalize a vector to unit length.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 normalize(vfloat4 a)\n+{\n+ vfloat4 length = dot(a, a);\n+ vfloat4 divisor = sqrt(length)\n+ return a / divisor;\n+}\n+\n/**\n* @brief Return a integer value for a float vector, using truncation.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_1.h", "new_path": "Source/astcenc_vecmathlib_none_1.h", "diff": "@@ -621,6 +621,14 @@ ASTCENC_SIMD_INLINE vfloat1 hmin(vfloat1 a)\nreturn a;\n}\n+/**\n+ * @brief Return the horizontal minimum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE float hmin_s(vfloat1 a)\n+{\n+ return a.m;\n+}\n+\n/**\n* @brief Return the horizontal maximum of a vector.\n*/\n@@ -629,10 +637,18 @@ ASTCENC_SIMD_INLINE vfloat1 hmax(vfloat1 a)\nreturn a;\n}\n+/**\n+ * @brief Return the horizontal maximum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE float hmax_s(vfloat1 a)\n+{\n+ return a.m;\n+}\n+\n/**\n* @brief Return the horizontal sum of a vector.\n*/\n-ASTCENC_SIMD_INLINE float hadd(vfloat1 a)\n+ASTCENC_SIMD_INLINE float hadd_s(vfloat1 a)\n{\nreturn a.m;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_4.h", "new_path": "Source/astcenc_vecmathlib_none_4.h", "diff": "@@ -806,6 +806,14 @@ ASTCENC_SIMD_INLINE vfloat4 hmin(vfloat4 a)\nreturn vfloat4(std::min(tmp1, tmp2));\n}\n+/**\n+ * @brief Return the horizontal minimum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE float hmin_s(vfloat4 a)\n+{\n+ return hmin(a).lane<0>();\n+}\n+\n/**\n* @brief Return the horizontal maximum of a vector.\n*/\n@@ -816,10 +824,18 @@ ASTCENC_SIMD_INLINE vfloat4 hmax(vfloat4 a)\nreturn vfloat4(std::max(tmp1, tmp2));\n}\n+/**\n+ * @brief Return the horizontal maximum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE float hmax_s(vfloat4 a)\n+{\n+ return hmax(a).lane<0>();\n+}\n+\n/**\n* @brief Return the horizontal sum of a vector.\n*/\n-ASTCENC_SIMD_INLINE float hadd(vfloat4 a)\n+ASTCENC_SIMD_INLINE float hadd_s(vfloat4 a)\n{\nreturn (a.m[0] + a.m[1]) + (a.m[2] + a.m[3]);\n}\n@@ -892,6 +908,27 @@ ASTCENC_SIMD_INLINE vfloat4 dot(vfloat4 a, vfloat4 b)\nreturn vfloat4(s);\n}\n+/**\n+ * @brief Return the dot product for the full 4 lanes, returning scalar.\n+ */\n+ASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\n+{\n+ return a.m[0] * b.m[0] +\n+ a.m[1] * b.m[1] +\n+ a.m[2] * b.m[2] +\n+ a.m[3] * b.m[3];\n+}\n+\n+/**\n+ * @brief Normalize a vector to unit length.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 normalize(vfloat4 a)\n+{\n+ vfloat4 length = dot(a, a);\n+ vfloat4 divisor = sqrt(length);\n+ return a / divisor;\n+}\n+\n/**\n* @brief Return a integer value for a float vector, using truncation.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -769,6 +769,14 @@ ASTCENC_SIMD_INLINE vfloat4 hmin(vfloat4 a)\nreturn vfloat4(_mm_shuffle_ps(a.m, a.m, _MM_SHUFFLE(0, 0, 0, 0)));\n}\n+/**\n+ * @brief Return the horizontal minimum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE float hmin_s(vfloat4 a)\n+{\n+ return hmin(a).lane<0>();\n+}\n+\n/**\n* @brief Return the horizontal maximum of a vector.\n*/\n@@ -780,9 +788,17 @@ ASTCENC_SIMD_INLINE vfloat4 hmax(vfloat4 a)\n}\n/**\n- * @brief Return the horizontal sum of a vector.\n+ * @brief Return the horizontal maximum of a vector.\n*/\n-ASTCENC_SIMD_INLINE float hadd(vfloat4 a)\n+ASTCENC_SIMD_INLINE float hmax_s(vfloat4 a)\n+{\n+ return hmax(a).lane<0>();\n+}\n+\n+/**\n+ * @brief Return the horizontal sum of a vector as a scalar.\n+ */\n+ASTCENC_SIMD_INLINE float hadd_s(vfloat4 a)\n{\n// Add top and bottom halves, lane 1/0\n__m128 t = _mm_add_ps(a.m, _mm_movehl_ps(a.m, a.m));\n@@ -848,15 +864,37 @@ ASTCENC_SIMD_INLINE vfloat4 dot(vfloat4 a, vfloat4 b)\n#if (ASTCENC_SSE >= 41) && (ASTCENC_ISA_INVARIANCE == 0)\nreturn vfloat4(_mm_dp_ps(a.m, b.m, 0xFF));\n#else\n- alignas(16) float av[4];\n- alignas(16) float bv[4];\n- storea(a, av);\n- storea(b, bv);\n- float s = av[0] * bv[0] + av[1] * bv[1] + av[2] * bv[2] + av[3] * bv[3];\n- return vfloat4(s);\n+ vfloat4 m = a * b;\n+ return vfloat4(hadd_s(m));\n+#endif\n+}\n+\n+/**\n+ * @brief Return the dot product for the full 4 lanes, returning scalar.\n+ */\n+ASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\n+{\n+#if (ASTCENC_SSE >= 41) && (ASTCENC_ISA_INVARIANCE == 0)\n+ return _mm_cvtss_f32(_mm_dp_ps(a.m, b.m, 0xFF));\n+#else\n+ vfloat4 m = a * b;\n+ return hadd_s(m);\n#endif\n}\n+/**\n+ * @brief Normalize a vector to unit length.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 normalize(vfloat4 a)\n+{\n+ // Compute 1/divisor using fast rsqrt with no NR iterations\n+ vfloat4 length = dot(a, a);\n+ __m128 raw = _mm_rsqrt_ps(length.m);\n+\n+ // Apply scaling factor\n+ return vfloat4(_mm_mul_ps(a.m, raw));\n+}\n+\n/**\n* @brief Return a integer value for a float vector, using truncation.\n*/\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make scalar and vector horizontal vector ops
61,745
13.01.2021 00:45:18
0
2ec1e3b731067e2b7c13b4408c9f09f89ce3de4c
Add more functions to vector library
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -446,6 +446,30 @@ TEST(vfloat4, vdiv)\nEXPECT_EQ(a.lane<3>(), 4.0f / 0.4f);\n}\n+/** @brief Test vfloat4 div. */\n+TEST(vfloat4, vsdiv)\n+{\n+ vfloat4 a(1.0f, 2.0f, 3.0f, 4.0f);\n+ float b = 0.3f;\n+ a = a / b;\n+ EXPECT_EQ(a.lane<0>(), 1.0f / 0.3f);\n+ EXPECT_EQ(a.lane<1>(), 2.0f / 0.3f);\n+ EXPECT_EQ(a.lane<2>(), 3.0f / 0.3f);\n+ EXPECT_EQ(a.lane<3>(), 4.0f / 0.3f);\n+}\n+\n+/** @brief Test vfloat4 div. */\n+TEST(vfloat4, svdiv)\n+{\n+ float a = 3.0f;\n+ vfloat4 b(0.1f, 0.2f, 0.3f, 0.4f);\n+ b = a / b;\n+ EXPECT_EQ(b.lane<0>(), 3.0f / 0.1f);\n+ EXPECT_EQ(b.lane<1>(), 3.0f / 0.2f);\n+ EXPECT_EQ(b.lane<2>(), 3.0f / 0.3f);\n+ EXPECT_EQ(b.lane<3>(), 3.0f / 0.4f);\n+}\n+\n/** @brief Test vfloat4 ceq. */\nTEST(vfloat4, ceq)\n{\n@@ -554,6 +578,20 @@ TEST(vfloat4, min)\nEXPECT_EQ(r.lane<1>(), 2.0f);\nEXPECT_EQ(r.lane<2>(), 3.0f);\nEXPECT_EQ(r.lane<3>(), 4.0f);\n+\n+ float c = 0.3f;\n+ r = min(a, c);\n+ EXPECT_EQ(r.lane<0>(), 0.3f);\n+ EXPECT_EQ(r.lane<1>(), 0.3f);\n+ EXPECT_EQ(r.lane<2>(), 0.3f);\n+ EXPECT_EQ(r.lane<3>(), 0.3f);\n+\n+ float d = 1.5f;\n+ r = min(a, d);\n+ EXPECT_EQ(r.lane<0>(), 1.0f);\n+ EXPECT_EQ(r.lane<1>(), 1.5f);\n+ EXPECT_EQ(r.lane<2>(), 1.5f);\n+ EXPECT_EQ(r.lane<3>(), 1.5f);\n}\n/** @brief Test vfloat4 max. */\n@@ -566,6 +604,20 @@ TEST(vfloat4, max)\nEXPECT_EQ(r.lane<1>(), 2.1f);\nEXPECT_EQ(r.lane<2>(), 3.0f);\nEXPECT_EQ(r.lane<3>(), 4.1f);\n+\n+ float c = 4.3f;\n+ r = max(a, c);\n+ EXPECT_EQ(r.lane<0>(), 4.3f);\n+ EXPECT_EQ(r.lane<1>(), 4.3f);\n+ EXPECT_EQ(r.lane<2>(), 4.3f);\n+ EXPECT_EQ(r.lane<3>(), 4.3f);\n+\n+ float d = 1.5f;\n+ r = max(a, d);\n+ EXPECT_EQ(r.lane<0>(), 1.5f);\n+ EXPECT_EQ(r.lane<1>(), 2.0f);\n+ EXPECT_EQ(r.lane<2>(), 3.0f);\n+ EXPECT_EQ(r.lane<3>(), 4.0f);\n}\n/** @brief Test vfloat4 clamp. */\n@@ -829,6 +881,17 @@ TEST(vfloat4, dot_s)\nEXPECT_EQ(r, 4.0f);\n}\n+/** @brief Test vfloat4 reciprocal. */\n+TEST(vfloat4, recip)\n+{\n+ vfloat4 a(1.0f, 2.0f, 3.0f, 4.0f);\n+ vfloat4 r = recip(a);\n+ EXPECT_NEAR(r.lane<0>(), 1.0f / 1.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<1>(), 1.0f / 2.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<2>(), 1.0f / 3.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<3>(), 1.0f / 4.0f, 0.0005f);\n+}\n+\n/** @brief Test vfloat4 normalize. */\nTEST(vfloat4, normalize)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "@@ -186,4 +186,14 @@ ASTCENC_SIMD_INLINE vfloat atan2(vfloat y, vfloat x)\nreturn change_sign(select(z, vfloat(astc::PI) - z, xmask), y);\n}\n+static inline vfloat4 float4_to_vfloat4(const float4& a) {\n+ return vfloat4(a.r, a.g, a.b, a.a);\n+}\n+\n+static inline float4 vfloat4_to_float4(const vfloat4& a) {\n+ float4 ret;\n+ store(a, (float*)&ret);\n+ return ret;\n+}\n+\n#endif // #ifndef ASTC_VECMATHLIB_H_INCLUDED\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -584,6 +584,22 @@ ASTCENC_SIMD_INLINE vfloat4 operator/(vfloat4 a, vfloat4 b)\nreturn vfloat4(vdivq_f32(a.m, b.m));\n}\n+/**\n+ * @brief Overload: vector by scalar division.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 operator/(vfloat4 a, float b)\n+{\n+ return vfloat4(vdivq_f32(a.m, vld1q_dup_f32(&b));\n+}\n+\n+/**\n+ * @brief Overload: scalar by vector division.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 operator/(float a, vfloat4 b)\n+{\n+ return vfloat4(vdivq_f32(vld1q_dup_f32(&a), b.m);\n+}\n+\n/**\n* @brief Overload: vector by vector equality.\n*/\n@@ -643,6 +659,17 @@ ASTCENC_SIMD_INLINE vfloat4 min(vfloat4 a, vfloat4 b)\nreturn vfloat4(vminnmq_f32(a.m, b.m));\n}\n+/**\n+ * @brief Return the min vector of a vector and a scalar.\n+ *\n+ * If either lane value is NaN, @c b will be returned for that lane.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 min(vfloat4 a, float b)\n+{\n+ // Do not reorder - second operand will return if either is NaN\n+ return vfloat4(vminnmq_f32(a.m, vld1q_dup_f32(&b));\n+}\n+\n/**\n* @brief Return the max vector of two vectors.\n*\n@@ -654,6 +681,17 @@ ASTCENC_SIMD_INLINE vfloat4 max(vfloat4 a, vfloat4 b)\nreturn vfloat4(vmaxnmq_f32(a.m, b.m));\n}\n+/**\n+ * @brief Return the max vector of a vector and a scalar.\n+ *\n+ * If either lane value is NaN, @c b will be returned for that lane.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 max(vfloat4 a, float b)\n+{\n+ // Do not reorder - second operand will return if either is NaN\n+ return vfloat4(vmaxnmq_f32(a.m, vld1q_dup_f32(&b)));\n+}\n+\n/**\n* @brief Return the clamped value between min and max.\n*\n@@ -820,6 +858,15 @@ ASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\nreturn dot(a, b).lane<0>();\n}\n+/**\n+ * @brief Generate a reciprocal of a a vector.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n+{\n+ // TODO: Is there a faster approximation we can use here?\n+ return 1.0f / b;\n+}\n+\n/**\n* @brief Normalize a vector to unit length.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_4.h", "new_path": "Source/astcenc_vecmathlib_none_4.h", "diff": "@@ -650,6 +650,28 @@ ASTCENC_SIMD_INLINE vfloat4 operator/(vfloat4 a, vfloat4 b)\na.m[3] / b.m[3]);\n}\n+/**\n+ * @brief Overload: vector by scalar division.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 operator/(vfloat4 a, float b)\n+{\n+ return vfloat4(a.m[0] / b,\n+ a.m[1] / b,\n+ a.m[2] / b,\n+ a.m[3] / b);\n+}\n+\n+/**\n+ * @brief Overload: scalar by vector division.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 operator/(float a, vfloat4 b)\n+{\n+ return vfloat4(a / b.m[0],\n+ a / b.m[1],\n+ a / b.m[2],\n+ a / b.m[3]);\n+}\n+\n/**\n* @brief Overload: vector by vector equality.\n*/\n@@ -729,6 +751,19 @@ ASTCENC_SIMD_INLINE vfloat4 min(vfloat4 a, vfloat4 b)\na.m[3] < b.m[3] ? a.m[3] : b.m[3]);\n}\n+/**\n+ * @brief Return the min vector of a vector and a scalar.\n+ *\n+ * If either lane value is NaN, @c b will be returned for that lane.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 min(vfloat4 a, float b)\n+{\n+ return vfloat4(a.m[0] < b ? a.m[0] : b,\n+ a.m[1] < b ? a.m[1] : b,\n+ a.m[2] < b ? a.m[2] : b,\n+ a.m[3] < b ? a.m[3] : b);\n+}\n+\n/**\n* @brief Return the max vector of two vectors.\n*\n@@ -742,6 +777,19 @@ ASTCENC_SIMD_INLINE vfloat4 max(vfloat4 a, vfloat4 b)\na.m[3] > b.m[3] ? a.m[3] : b.m[3]);\n}\n+/**\n+ * @brief Return the max vector of a vector and a scalar.\n+ *\n+ * If either lane value is NaN, @c b will be returned for that lane.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 max(vfloat4 a, float b)\n+{\n+ return vfloat4(a.m[0] > b ? a.m[0] : b,\n+ a.m[1] > b ? a.m[1] : b,\n+ a.m[2] > b ? a.m[2] : b,\n+ a.m[3] > b ? a.m[3] : b);\n+}\n+\n/**\n* @brief Return the clamped value between min and max.\n*\n@@ -919,6 +967,14 @@ ASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\na.m[3] * b.m[3];\n}\n+/**\n+ * @brief Generate a reciprocal of a a vector.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n+{\n+ return 1.0f / b;\n+}\n+\n/**\n* @brief Normalize a vector to unit length.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -613,6 +613,22 @@ ASTCENC_SIMD_INLINE vfloat4 operator/(vfloat4 a, vfloat4 b)\nreturn vfloat4(_mm_div_ps(a.m, b.m));\n}\n+/**\n+ * @brief Overload: vector by scalar division.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 operator/(vfloat4 a, float b)\n+{\n+ return vfloat4(_mm_div_ps(a.m, _mm_set1_ps(b)));\n+}\n+\n+/**\n+ * @brief Overload: scalar by vector division.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 operator/(float a, vfloat4 b)\n+{\n+ return vfloat4(_mm_div_ps(_mm_set1_ps(a), b.m));\n+}\n+\n/**\n* @brief Overload: vector by vector equality.\n*/\n@@ -672,6 +688,16 @@ ASTCENC_SIMD_INLINE vfloat4 min(vfloat4 a, vfloat4 b)\nreturn vfloat4(_mm_min_ps(a.m, b.m));\n}\n+/**\n+ * @brief Return the min vector of a vector and a scalar.\n+ *\n+ * If either lane value is NaN, @c b will be returned for that lane.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 min(vfloat4 a, float b)\n+{\n+ return vfloat4(_mm_min_ps(a.m, _mm_set1_ps(b)));\n+}\n+\n/**\n* @brief Return the max vector of two vectors.\n*\n@@ -683,6 +709,16 @@ ASTCENC_SIMD_INLINE vfloat4 max(vfloat4 a, vfloat4 b)\nreturn vfloat4(_mm_max_ps(a.m, b.m));\n}\n+/**\n+ * @brief Return the min vector of a vector and a scalar.\n+ *\n+ * If either lane value is NaN, @c b will be returned for that lane.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 max(vfloat4 a, float b)\n+{\n+ return vfloat4(_mm_max_ps(a.m, _mm_set1_ps(b)));\n+}\n+\n/**\n* @brief Return the clamped value between min and max.\n*\n@@ -882,6 +918,17 @@ ASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\n#endif\n}\n+/**\n+ * @brief Generate a reciprocal of a a vector.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n+{\n+ // Reciprocal with a single NR iteration\n+ __m128 t1 = _mm_rcp_ps(b.m);\n+ __m128 t2 = _mm_mul_ps(b.m, _mm_mul_ps(t1, t1));\n+ return vfloat4(_mm_sub_ps(_mm_add_ps(t1, t1), t2));\n+}\n+\n/**\n* @brief Normalize a vector to unit length.\n*/\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add more functions to vector library
61,745
13.01.2021 08:51:30
0
dc6cfa0bbac687293462c7b17337d09d3aefd96d
Add missing initializer for bsd.decimation_mode_count
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes2.cpp", "new_path": "Source/astcenc_block_sizes2.cpp", "diff": "@@ -668,6 +668,7 @@ static void construct_block_size_descriptor_2d(\nbsd.ydim = y_dim;\nbsd.zdim = 1;\nbsd.texel_count = x_dim * y_dim;\n+ bsd.decimation_mode_count = 0;\nfor (int i = 0; i < MAX_DMI; i++)\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add missing initializer for bsd.decimation_mode_count
61,745
13.01.2021 09:52:36
0
3c74cb8f7df12f0fd309eb9baf1b3115dac632da
Fix NEON build issues
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -589,7 +589,7 @@ ASTCENC_SIMD_INLINE vfloat4 operator/(vfloat4 a, vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vfloat4 operator/(vfloat4 a, float b)\n{\n- return vfloat4(vdivq_f32(a.m, vld1q_dup_f32(&b));\n+ return vfloat4(vdivq_f32(a.m, vld1q_dup_f32(&b)));\n}\n/**\n@@ -597,7 +597,7 @@ ASTCENC_SIMD_INLINE vfloat4 operator/(vfloat4 a, float b)\n*/\nASTCENC_SIMD_INLINE vfloat4 operator/(float a, vfloat4 b)\n{\n- return vfloat4(vdivq_f32(vld1q_dup_f32(&a), b.m);\n+ return vfloat4(vdivq_f32(vld1q_dup_f32(&a), b.m));\n}\n/**\n@@ -667,7 +667,7 @@ ASTCENC_SIMD_INLINE vfloat4 min(vfloat4 a, vfloat4 b)\nASTCENC_SIMD_INLINE vfloat4 min(vfloat4 a, float b)\n{\n// Do not reorder - second operand will return if either is NaN\n- return vfloat4(vminnmq_f32(a.m, vld1q_dup_f32(&b));\n+ return vfloat4(vminnmq_f32(a.m, vld1q_dup_f32(&b)));\n}\n/**\n@@ -873,7 +873,7 @@ ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\nASTCENC_SIMD_INLINE vfloat4 normalize(vfloat4 a)\n{\nvfloat4 length = dot(a, a);\n- vfloat4 divisor = sqrt(length)\n+ vfloat4 divisor = sqrt(length);\nreturn a / divisor;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix NEON build issues
61,745
13.01.2021 10:51:25
0
47a692d137d332445361ebe768ad56666e2a1a22
Fix promise() on GCC
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "*/\n#if defined(NDEBUG)\n#if defined(_MSC_VER)\n- #define promise(cond) __assume(cond);\n- #elif __has_builtin(__builtin_assume)\n- #define promise(cond) __builtin_assume(cond);\n+ #define promise(cond) __assume(cond)\n+ #elif defined(__clang__)\n+ #if __has_builtin(__builtin_assume)\n+ #define promise(cond) __builtin_assume(cond)\n#elif __has_builtin(__builtin_unreachable)\n- #define promise(cond) __builtin_unreachable(!(cond));\n+ #define promise(cond) if(!(cond)) { __builtin_unreachable(); }\n+ #else\n+ #define promise(cond)\n+ #endif\n+ #else // Assume GCC\n+ #define promise(cond) if(!(cond)) { __builtin_unreachable(); }\n#endif\n#else\n#define promise(cond) assert(cond);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix promise() on GCC
61,745
13.01.2021 10:51:55
0
a3a699c4828c8ae15275509230e21ca7ca1fc4a1
Swap intrinsics for alternatives available in GCC 7.5
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_avx2_8.h", "new_path": "Source/astcenc_vecmathlib_avx2_8.h", "diff": "@@ -174,7 +174,8 @@ struct vint8\n*/\nASTCENC_SIMD_INLINE explicit vint8(const uint8_t *p)\n{\n- m = _mm256_cvtepu8_epi32(_mm_loadu_si64(p));\n+ // _mm_loadu_si64 would be nicer syntax, but missing on older GCC\n+ m = _mm256_cvtepu8_epi32(_mm_cvtsi64_si128(*(const long long*)p));\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -187,7 +187,8 @@ struct vint4\n*/\nASTCENC_SIMD_INLINE explicit vint4(const uint8_t *p)\n{\n- __m128i t = _mm_loadu_si32(p);\n+ // _mm_loadu_si32 would be nicer syntax, but missing on older GCC\n+ __m128i t = _mm_cvtsi32_si128(*(const int*)p);\n#if ASTCENC_SSE >= 41\nm = _mm_cvtepu8_epi32(t);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Swap intrinsics for alternatives available in GCC 7.5
61,745
13.01.2021 11:23:11
0
cc689279e2a22cb46167bab408d6f969f2f5d022
Fix unit test CMake file
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/cmake_core.cmake", "new_path": "Source/UnitTest/cmake_core.cmake", "diff": "@@ -51,7 +51,7 @@ if(${ISA_SIMD} MATCHES \"none\")\nASTCENC_POPCNT=0)\nif (${ARCH} MATCHES x64)\n- target_compile_options(astcenc-${ISA_SIMD}\n+ target_compile_options(test-simd-${ISA_SIMD}\nPRIVATE\n$<$<CXX_COMPILER_ID:${GNU_LIKE}>:-mfpmath=sse -msse2>)\nendif()\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix unit test CMake file
61,745
13.01.2021 11:24:18
0
16acfb988c602f4624ffc172a86090c9681ea492
Add decompressor build support to CMake Configure with -DDECOMPRESSOR=ON
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -86,6 +86,13 @@ else()\nmessage(\" -- ISA invariant backend - OFF\")\nendif()\n+option(DECOMPRESSOR \"Enable builds for decompression only\")\n+if(${DECOMPRESSOR})\n+ message(\" -- Decompress-only backend - ON\")\n+else()\n+ message(\" -- Decompress-only backend - OFF\")\n+endif()\n+\noption(UNITTEST \"Enable builds for unit tests\")\nif(${UNITTEST})\nmessage(\" -- Unit tests - ON\")\n" }, { "change_type": "MODIFY", "old_path": "Source/CMakeLists.txt", "new_path": "Source/CMakeLists.txt", "diff": "@@ -21,6 +21,12 @@ if(CMAKE_CXX_COMPILER_ID MATCHES \"GNU|Clang\")\nset(CMAKE_CXX_COMPILE_OPTIONS_IPO \"-flto\")\nendif()\n+if (${DECOMPRESSOR})\n+ set(CODEC dec)\n+else()\n+ set(CODEC enc)\n+endif()\n+\n# - - - - - - - - - - - - - - - - - -\n# No architecture-specific SIMD\n" }, { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "# under the License.\n# ----------------------------------------------------------------------------\n-project(astcenc-${ISA_SIMD})\n+project(astc${CODEC}-${ISA_SIMD})\nset(GNU_LIKE \"GNU,Clang,AppleClang\")\n-add_executable(astcenc-${ISA_SIMD})\n+add_executable(astc${CODEC}-${ISA_SIMD})\n-target_sources(astcenc-${ISA_SIMD}\n+target_sources(astc${CODEC}-${ISA_SIMD}\nPRIVATE\nastcenc_averages_and_directions.cpp\nastcenc_block_sizes2.cpp\n@@ -55,18 +55,24 @@ target_sources(astcenc-${ISA_SIMD}\nastcenccli_toplevel.cpp\nastcenccli_toplevel_help.cpp)\n-target_compile_features(astcenc-${ISA_SIMD}\n+target_compile_features(astc${CODEC}-${ISA_SIMD}\nPRIVATE\ncxx_std_14)\n-target_compile_definitions(astcenc-${ISA_SIMD}\n+target_compile_definitions(astc${CODEC}-${ISA_SIMD}\nPRIVATE\n# Common defines\nASTCENC_ISA_INVARIANCE=$<BOOL:${ISA_INVARIANCE}>\n# MSVC defines\n$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>)\n-target_compile_options(astcenc-${ISA_SIMD}\n+if(${DECOMPRESSOR})\n+ target_compile_definitions(astc${CODEC}-${ISA_SIMD}\n+ PRIVATE\n+ ASTCENC_DECOMPRESS_ONLY)\n+endif()\n+\n+target_compile_options(astc${CODEC}-${ISA_SIMD}\nPRIVATE\n# Use pthreads on Linux/macOS\n$<$<PLATFORM_ID:Linux,Darwin>:-pthread>\n@@ -83,17 +89,17 @@ target_compile_options(astcenc-${ISA_SIMD}\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wdouble-promotion>\n$<$<CXX_COMPILER_ID:Clang>:-Wdocumentation>)\n-target_link_options(astcenc-${ISA_SIMD}\n+target_link_options(astc${CODEC}-${ISA_SIMD}\nPRIVATE\n# Use pthreads on Linux/macOS\n$<$<PLATFORM_ID:Linux,Darwin>:-pthread>)\n# Enable LTO on release builds\n-set_property(TARGET astcenc-${ISA_SIMD} PROPERTY\n+set_property(TARGET astc${CODEC}-${ISA_SIMD} PROPERTY\nINTERPROCEDURAL_OPTIMIZATION_RELEASE True)\n# Use a static runtime on MSVC builds (ignored on non-MSVC compilers)\n-set_property(TARGET astcenc-${ISA_SIMD} PROPERTY\n+set_property(TARGET astc${CODEC}-${ISA_SIMD} PROPERTY\nMSVC_RUNTIME_LIBRARY \"MultiThreaded$<$<CONFIG:Debug>:Debug>\")\nif(CMAKE_CXX_COMPILER_ID MATCHES \"GNU|Clang\")\n@@ -108,7 +114,7 @@ endif()\n# Set up configuration for SIMD ISA builds\nif(${ISA_SIMD} MATCHES \"none\")\n- target_compile_definitions(astcenc-${ISA_SIMD}\n+ target_compile_definitions(astc${CODEC}-${ISA_SIMD}\nPRIVATE\nASTCENC_NEON=0\nASTCENC_SSE=0\n@@ -116,7 +122,7 @@ if(${ISA_SIMD} MATCHES \"none\")\nASTCENC_POPCNT=0)\nelseif(${ISA_SIMD} MATCHES \"neon\")\n- target_compile_definitions(astcenc-${ISA_SIMD}\n+ target_compile_definitions(astc${CODEC}-${ISA_SIMD}\nPRIVATE\nASTCENC_NEON=1\nASTCENC_SSE=0\n@@ -124,7 +130,7 @@ elseif(${ISA_SIMD} MATCHES \"neon\")\nASTCENC_POPCNT=0)\nelseif(${ISA_SIMD} MATCHES \"sse2\")\n- target_compile_definitions(astcenc-${ISA_SIMD}\n+ target_compile_definitions(astc${CODEC}-${ISA_SIMD}\nPRIVATE\nASTCENC_NEON=0\nASTCENC_SSE=20\n@@ -132,29 +138,29 @@ elseif(${ISA_SIMD} MATCHES \"sse2\")\nASTCENC_POPCNT=0)\nelseif(${ISA_SIMD} MATCHES \"sse4.1\")\n- target_compile_definitions(astcenc-${ISA_SIMD}\n+ target_compile_definitions(astc${CODEC}-${ISA_SIMD}\nPRIVATE\nASTCENC_NEON=0\nASTCENC_SSE=41\nASTCENC_AVX=0\nASTCENC_POPCNT=1)\n- target_compile_options(astcenc-${ISA_SIMD}\n+ target_compile_options(astc${CODEC}-${ISA_SIMD}\nPRIVATE\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-msse4.1 -mpopcnt>)\nelseif(${ISA_SIMD} MATCHES \"avx2\")\n- target_compile_definitions(astcenc-${ISA_SIMD}\n+ target_compile_definitions(astc${CODEC}-${ISA_SIMD}\nPRIVATE\nASTCENC_NEON=0\nASTCENC_SSE=41\nASTCENC_AVX=2\nASTCENC_POPCNT=1)\n- target_compile_options(astcenc-${ISA_SIMD}\n+ target_compile_options(astc${CODEC}-${ISA_SIMD}\nPRIVATE\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-mavx2 -mpopcnt>\n$<$<CXX_COMPILER_ID:MSVC>:/arch:AVX2>)\nendif()\n-install(TARGETS astcenc-${ISA_SIMD} DESTINATION ${PACKAGE_ROOT})\n+install(TARGETS astc${CODEC}-${ISA_SIMD} DESTINATION ${PACKAGE_ROOT})\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add decompressor build support to CMake Configure with -DDECOMPRESSOR=ON
61,745
13.01.2021 11:25:01
0
5dcd91a6571870e7c3770bb390f546ace9a3e2eb
Fix decompresor-only builds
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes2.cpp", "new_path": "Source/astcenc_block_sizes2.cpp", "diff": "@@ -678,6 +678,10 @@ static void construct_block_size_descriptor_2d(\n// Gather all the decimation grids that can be used with the current block.\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\nconst float *percentiles = get_2d_percentile_table(x_dim, y_dim);\n+#else\n+ // Unused in decompress-only builds\n+ (void)can_omit_modes;\n+ (void)mode_cutoff;\n#endif\n// Construct the list of block formats referencing the decimation tables\n@@ -692,10 +696,11 @@ static void construct_block_size_descriptor_2d(\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\nfloat percentile = percentiles[i];\n- (void)can_omit_modes;\nbool selected = (percentile <= mode_cutoff) || !can_omit_modes;\n#else\n- bool selected == true;\n+ // Decompressor builds can never discard modes, as we cannot make any\n+ // assumptions about the modes the original compressor used\n+ bool selected = true;\n#endif\n// ASSUMPTION: No compressor will use more weights in a dimension than\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -528,7 +528,11 @@ astcenc_error astcenc_context_alloc(\nctx->working_buffers = aligned_malloc<compress_symbolic_block_buffers>(worksize , 32);\nif (!ctx->working_buffers)\n{\n- goto error_oom;\n+ term_block_size_descriptor(bsd);\n+ delete bsd;\n+ delete ctx;\n+ *context = nullptr;\n+ return ASTCENC_ERR_OUT_OF_MEM;\n}\n}\n#endif\n@@ -542,13 +546,6 @@ astcenc_error astcenc_context_alloc(\nbuild_quantization_mode_table();\nreturn ASTCENC_SUCCESS;\n-\n-error_oom:\n- term_block_size_descriptor(bsd);\n- delete bsd;\n- delete ctx;\n- *context = nullptr;\n- return ASTCENC_ERR_OUT_OF_MEM;\n}\nvoid astcenc_context_free(\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix decompresor-only builds
61,745
13.01.2021 11:25:42
0
06389828e66e0fdbe4d0c3a89a56a5cf91660027
Add decompressor builds to Jenkins pipeline
[ { "change_type": "MODIFY", "old_path": "jenkins/release.Jenkinsfile", "new_path": "jenkins/release.Jenkinsfile", "diff": "@@ -90,7 +90,7 @@ pipeline {\nsh 'git clean -ffdx'\n}\n}\n- stage('Build R') {\n+ stage('Build astcenc R') {\nsteps {\nsh '''\nexport CXX=clang++-9\n@@ -101,6 +101,17 @@ pipeline {\n'''\n}\n}\n+ stage('Build astcdec R') {\n+ steps {\n+ sh '''\n+ export CXX=clang++-9\n+ mkdir build_reldec\n+ cd 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+ make -j4\n+ '''\n+ }\n+ }\nstage('Stash') {\nsteps {\ndir('build_rel') {\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add decompressor builds to Jenkins pipeline
61,745
13.01.2021 22:47:59
0
446a1a3eb85dea56d3043ad36a50b5ab8497acfc
Update Small test reference to latest master build
[ { "change_type": "ADD", "old_path": null, "new_path": "Test/Images/Small/astc_reference-master-avx2_fast_results.csv", "diff": "+Image Set,Block Size,Name,PSNR,Total Time,Coding Time,Coding Rate\n+Small,4x4,hdr-rgb-00.hdr,31.3376,0.1407,0.0431,1.5199\n+Small,4x4,ldr-rgb-00.png,37.6618,0.0337,0.0255,2.5691\n+Small,4x4,ldr-rgb-01.png,39.4046,0.0271,0.0191,3.4325\n+Small,4x4,ldr-rgb-02.png,34.4718,0.0390,0.0311,2.1095\n+Small,4x4,ldr-rgb-03.png,45.6691,0.0168,0.0092,7.0872\n+Small,4x4,ldr-rgb-04.png,41.5735,0.0223,0.0142,4.6253\n+Small,4x4,ldr-rgb-05.png,36.8143,0.0376,0.0297,2.2083\n+Small,4x4,ldr-rgb-06.png,34.6369,0.0364,0.0282,2.3237\n+Small,4x4,ldr-rgb-07.png,37.6590,0.0419,0.0336,1.9478\n+Small,4x4,ldr-rgb-08.png,43.0813,0.0205,0.0127,5.1579\n+Small,4x4,ldr-rgb-09.png,41.5732,0.0220,0.0141,4.6358\n+Small,4x4,ldr-rgb-10.png,44.2909,0.0094,0.0038,4.2936\n+Small,4x4,ldr-rgba-00.png,35.2138,0.0443,0.0359,1.8236\n+Small,4x4,ldr-rgba-01.png,38.5731,0.0251,0.0169,3.8674\n+Small,4x4,ldr-rgba-02.png,34.4486,0.0391,0.0309,2.1235\n+Small,4x4,ldr-xy-00.png,37.4768,0.0192,0.0111,5.8973\n+Small,4x4,ldr-xy-01.png,43.6783,0.0203,0.0126,5.1979\n+Small,4x4,ldr-xy-02.png,47.2703,0.0158,0.0077,8.4726\n+Small,4x4,ldrs-rgba-00.png,35.2196,0.0445,0.0362,1.8119\n+Small,4x4,ldrs-rgba-01.png,38.5894,0.0253,0.0172,3.8098\n+Small,4x4,ldrs-rgba-02.png,34.4534,0.0391,0.0309,2.1196\n+Small,5x5,hdr-rgb-00.hdr,25.4328,0.1458,0.0475,1.3802\n+Small,5x5,ldr-rgb-00.png,33.8880,0.0323,0.0233,2.8114\n+Small,5x5,ldr-rgb-01.png,35.9676,0.0235,0.0148,4.4185\n+Small,5x5,ldr-rgb-02.png,30.8007,0.0332,0.0245,2.6697\n+Small,5x5,ldr-rgb-03.png,42.3799,0.0154,0.0070,9.4201\n+Small,5x5,ldr-rgb-04.png,37.0091,0.0214,0.0127,5.1566\n+Small,5x5,ldr-rgb-05.png,32.9125,0.0376,0.0288,2.2746\n+Small,5x5,ldr-rgb-06.png,30.8512,0.0329,0.0240,2.7275\n+Small,5x5,ldr-rgb-07.png,34.2261,0.0318,0.0227,2.8882\n+Small,5x5,ldr-rgb-08.png,39.4359,0.0181,0.0094,6.9853\n+Small,5x5,ldr-rgb-09.png,37.1147,0.0225,0.0137,4.7826\n+Small,5x5,ldr-rgb-10.png,40.0302,0.0098,0.0034,4.7740\n+Small,5x5,ldr-rgba-00.png,31.4679,0.0446,0.0354,1.8520\n+Small,5x5,ldr-rgba-01.png,34.9789,0.0255,0.0165,3.9769\n+Small,5x5,ldr-rgba-02.png,30.9417,0.0448,0.0359,1.8268\n+Small,5x5,ldr-xy-00.png,36.5394,0.0186,0.0099,6.6481\n+Small,5x5,ldr-xy-01.png,39.2424,0.0200,0.0115,5.6958\n+Small,5x5,ldr-xy-02.png,43.0007,0.0156,0.0068,9.6205\n+Small,5x5,ldrs-rgba-00.png,31.4696,0.0451,0.0359,1.8243\n+Small,5x5,ldrs-rgba-01.png,34.9821,0.0258,0.0169,3.8776\n+Small,5x5,ldrs-rgba-02.png,30.9425,0.0452,0.0362,1.8094\n+Small,6x6,hdr-rgb-00.hdr,23.6256,0.1595,0.0602,1.0883\n+Small,6x6,ldr-rgb-00.png,31.3475,0.0473,0.0369,1.7743\n+Small,6x6,ldr-rgb-01.png,32.7552,0.0385,0.0285,2.3018\n+Small,6x6,ldr-rgb-02.png,27.3271,0.0623,0.0523,1.2536\n+Small,6x6,ldr-rgb-03.png,40.3944,0.0183,0.0085,7.6794\n+Small,6x6,ldr-rgb-04.png,33.7448,0.0336,0.0233,2.8183\n+Small,6x6,ldr-rgb-05.png,29.7889,0.0684,0.0583,1.1241\n+Small,6x6,ldr-rgb-06.png,27.3720,0.0628,0.0523,1.2522\n+Small,6x6,ldr-rgb-07.png,32.9172,0.0398,0.0294,2.2287\n+Small,6x6,ldr-rgb-08.png,37.4976,0.0226,0.0125,5.2488\n+Small,6x6,ldr-rgb-09.png,33.3949,0.0370,0.0268,2.4457\n+Small,6x6,ldr-rgb-10.png,36.4596,0.0122,0.0045,3.6294\n+Small,6x6,ldr-rgba-00.png,28.9697,0.0615,0.0509,1.2863\n+Small,6x6,ldr-rgba-01.png,31.9456,0.0319,0.0216,3.0303\n+Small,6x6,ldr-rgba-02.png,27.7267,0.0644,0.0540,1.2138\n+Small,6x6,ldr-xy-00.png,35.4263,0.0216,0.0115,5.7132\n+Small,6x6,ldr-xy-01.png,36.7797,0.0250,0.0151,4.3350\n+Small,6x6,ldr-xy-02.png,41.3918,0.0163,0.0062,10.6513\n+Small,6x6,ldrs-rgba-00.png,28.9713,0.0616,0.0510,1.2838\n+Small,6x6,ldrs-rgba-01.png,31.9497,0.0320,0.0218,3.0126\n+Small,6x6,ldrs-rgba-02.png,27.7257,0.0641,0.0539,1.2160\n+Small,8x8,hdr-rgb-00.hdr,21.2577,0.1711,0.0673,0.9741\n+Small,8x8,ldr-rgb-00.png,27.7752,0.0564,0.0408,1.6056\n+Small,8x8,ldr-rgb-01.png,28.5880,0.0505,0.0352,1.8605\n+Small,8x8,ldr-rgb-02.png,22.9682,0.0785,0.0630,1.0405\n+Small,8x8,ldr-rgb-03.png,37.1356,0.0237,0.0085,7.7557\n+Small,8x8,ldr-rgb-04.png,29.1398,0.0479,0.0321,2.0424\n+Small,8x8,ldr-rgb-05.png,25.6188,0.0887,0.0731,0.8970\n+Small,8x8,ldr-rgb-06.png,23.0556,0.0779,0.0624,1.0500\n+Small,8x8,ldr-rgb-07.png,29.6624,0.0411,0.0255,2.5750\n+Small,8x8,ldr-rgb-08.png,34.1772,0.0296,0.0143,4.5965\n+Small,8x8,ldr-rgb-09.png,28.5664,0.0528,0.0372,1.7628\n+Small,8x8,ldr-rgb-10.png,31.9609,0.0186,0.0055,2.9450\n+Small,8x8,ldr-rgba-00.png,24.7566,0.0693,0.0534,1.2277\n+Small,8x8,ldr-rgba-01.png,28.0959,0.0409,0.0254,2.5821\n+Small,8x8,ldr-rgba-02.png,23.8149,0.0776,0.0621,1.0559\n+Small,8x8,ldr-xy-00.png,32.8578,0.0293,0.0140,4.6939\n+Small,8x8,ldr-xy-01.png,33.7355,0.0307,0.0155,4.2372\n+Small,8x8,ldr-xy-02.png,39.7087,0.0202,0.0049,13.3068\n+Small,8x8,ldrs-rgba-00.png,24.7565,0.0699,0.0538,1.2192\n+Small,8x8,ldrs-rgba-01.png,28.0987,0.0412,0.0256,2.5642\n+Small,8x8,ldrs-rgba-02.png,23.8144,0.0786,0.0628,1.0431\n+Small,12x12,hdr-rgb-00.hdr,18.5302,0.1887,0.0755,0.8679\n+Small,12x12,ldr-rgb-00.png,23.6011,0.0465,0.0221,2.9606\n+Small,12x12,ldr-rgb-01.png,24.6574,0.0391,0.0151,4.3508\n+Small,12x12,ldr-rgb-02.png,19.1654,0.0785,0.0548,1.1958\n+Small,12x12,ldr-rgb-03.png,33.1170,0.0293,0.0057,11.4916\n+Small,12x12,ldr-rgb-04.png,24.4570,0.0444,0.0202,3.2461\n+Small,12x12,ldr-rgb-05.png,21.4105,0.0740,0.0496,1.3218\n+Small,12x12,ldr-rgb-06.png,19.1662,0.0906,0.0657,0.9975\n+Small,12x12,ldr-rgb-07.png,25.1015,0.0371,0.0127,5.1619\n+Small,12x12,ldr-rgb-08.png,30.0111,0.0328,0.0086,7.5826\n+Small,12x12,ldr-rgb-09.png,23.6435,0.0515,0.0273,2.4011\n+Small,12x12,ldr-rgb-10.png,27.1414,0.0251,0.0034,4.8124\n+Small,12x12,ldr-rgba-00.png,21.0194,0.0612,0.0366,1.7928\n+Small,12x12,ldr-rgba-01.png,24.3992,0.0417,0.0174,3.7697\n+Small,12x12,ldr-rgba-02.png,20.1201,0.0804,0.0559,1.1727\n+Small,12x12,ldr-xy-00.png,28.5965,0.0358,0.0116,5.6629\n+Small,12x12,ldr-xy-01.png,30.1260,0.0350,0.0112,5.8740\n+Small,12x12,ldr-xy-02.png,38.2595,0.0284,0.0046,14.1122\n+Small,12x12,ldrs-rgba-00.png,21.0188,0.0613,0.0367,1.7875\n+Small,12x12,ldrs-rgba-01.png,24.3995,0.0418,0.0175,3.7385\n+Small,12x12,ldrs-rgba-02.png,20.1200,0.0806,0.0564,1.1624\n+Small,3x3x3,ldr-l-00-3.dds,50.4842,0.0361,0.0265,9.9080\n+Small,3x3x3,ldr-l-01-3.dds,54.6248,0.0177,0.0106,6.4866\n+Small,6x6x6,ldr-l-00-3.dds,32.6096,0.0977,0.0662,3.9572\n+Small,6x6x6,ldr-l-01-3.dds,41.4223,0.0536,0.0239,2.8778\n" }, { "change_type": "ADD", "old_path": null, "new_path": "Test/Images/Small/astc_reference-master-avx2_fastest_results.csv", "diff": "+Image Set,Block Size,Name,PSNR,Total Time,Coding Time,Coding Rate\n+Small,4x4,hdr-rgb-00.hdr,25.8949,0.1253,0.0275,2.3869\n+Small,4x4,ldr-rgb-00.png,34.9420,0.0170,0.0089,7.3644\n+Small,4x4,ldr-rgb-01.png,38.2563,0.0132,0.0054,12.0270\n+Small,4x4,ldr-rgb-02.png,33.4123,0.0158,0.0079,8.3010\n+Small,4x4,ldr-rgb-03.png,43.7626,0.0132,0.0056,11.7595\n+Small,4x4,ldr-rgb-04.png,40.3909,0.0134,0.0054,12.1113\n+Small,4x4,ldr-rgb-05.png,35.0617,0.0158,0.0077,8.5467\n+Small,4x4,ldr-rgb-06.png,33.4536,0.0166,0.0084,7.8019\n+Small,4x4,ldr-rgb-07.png,35.1122,0.0146,0.0063,10.4373\n+Small,4x4,ldr-rgb-08.png,40.6131,0.0135,0.0057,11.4394\n+Small,4x4,ldr-rgb-09.png,40.3248,0.0133,0.0054,12.1724\n+Small,4x4,ldr-rgb-10.png,41.8939,0.0076,0.0020,8.1891\n+Small,4x4,ldr-rgba-00.png,31.1205,0.0208,0.0125,5.2379\n+Small,4x4,ldr-rgba-01.png,38.0759,0.0139,0.0058,11.2452\n+Small,4x4,ldr-rgba-02.png,33.6414,0.0167,0.0086,7.6553\n+Small,4x4,ldr-xy-00.png,36.7204,0.0144,0.0065,10.0485\n+Small,4x4,ldr-xy-01.png,39.7248,0.0151,0.0073,8.9249\n+Small,4x4,ldr-xy-02.png,43.6438,0.0137,0.0058,11.3642\n+Small,4x4,ldrs-rgba-00.png,31.1210,0.0212,0.0128,5.1368\n+Small,4x4,ldrs-rgba-01.png,38.0852,0.0140,0.0059,11.1003\n+Small,4x4,ldrs-rgba-02.png,33.6452,0.0169,0.0088,7.4821\n+Small,5x5,hdr-rgb-00.hdr,24.2425,0.1231,0.0256,2.5606\n+Small,5x5,ldr-rgb-00.png,32.1123,0.0152,0.0066,9.8685\n+Small,5x5,ldr-rgb-01.png,35.1677,0.0128,0.0045,14.6648\n+Small,5x5,ldr-rgb-02.png,30.2425,0.0139,0.0056,11.6885\n+Small,5x5,ldr-rgb-03.png,40.7817,0.0127,0.0046,14.1697\n+Small,5x5,ldr-rgb-04.png,35.1949,0.0130,0.0045,14.5994\n+Small,5x5,ldr-rgb-05.png,31.1786,0.0142,0.0058,11.2140\n+Small,5x5,ldr-rgb-06.png,30.2780,0.0141,0.0056,11.7726\n+Small,5x5,ldr-rgb-07.png,32.0875,0.0137,0.0050,13.0813\n+Small,5x5,ldr-rgb-08.png,37.6500,0.0130,0.0047,13.9200\n+Small,5x5,ldr-rgb-09.png,35.1843,0.0128,0.0045,14.4225\n+Small,5x5,ldr-rgb-10.png,38.7112,0.0076,0.0016,10.0653\n+Small,5x5,ldr-rgba-00.png,28.6643,0.0189,0.0100,6.5250\n+Small,5x5,ldr-rgba-01.png,34.2635,0.0133,0.0048,13.5883\n+Small,5x5,ldr-rgba-02.png,30.6236,0.0151,0.0065,10.0610\n+Small,5x5,ldr-xy-00.png,35.3047,0.0139,0.0056,11.7134\n+Small,5x5,ldr-xy-01.png,36.1942,0.0147,0.0066,9.8863\n+Small,5x5,ldr-xy-02.png,42.2409,0.0134,0.0049,13.2881\n+Small,5x5,ldrs-rgba-00.png,28.6648,0.0188,0.0101,6.4920\n+Small,5x5,ldrs-rgba-01.png,34.2653,0.0135,0.0050,13.1710\n+Small,5x5,ldrs-rgba-02.png,30.6258,0.0151,0.0066,9.9521\n+Small,6x6,hdr-rgb-00.hdr,22.8020,0.1274,0.0282,2.3244\n+Small,6x6,ldr-rgb-00.png,29.3083,0.0154,0.0062,10.6044\n+Small,6x6,ldr-rgb-01.png,31.1989,0.0135,0.0046,14.2468\n+Small,6x6,ldr-rgb-02.png,26.6412,0.0152,0.0061,10.6612\n+Small,6x6,ldr-rgb-03.png,38.6788,0.0133,0.0046,14.3877\n+Small,6x6,ldr-rgb-04.png,31.4749,0.0139,0.0047,13.8234\n+Small,6x6,ldr-rgb-05.png,27.8968,0.0147,0.0056,11.7319\n+Small,6x6,ldr-rgb-06.png,26.7318,0.0152,0.0059,11.0371\n+Small,6x6,ldr-rgb-07.png,30.2350,0.0142,0.0048,13.7473\n+Small,6x6,ldr-rgb-08.png,35.5110,0.0136,0.0046,14.0963\n+Small,6x6,ldr-rgb-09.png,30.6039,0.0141,0.0050,13.0497\n+Small,6x6,ldr-rgb-10.png,33.8067,0.0084,0.0016,9.8630\n+Small,6x6,ldr-rgba-00.png,26.9290,0.0191,0.0096,6.8502\n+Small,6x6,ldr-rgba-01.png,30.9043,0.0143,0.0050,13.1175\n+Small,6x6,ldr-rgba-02.png,27.2854,0.0160,0.0067,9.7596\n+Small,6x6,ldr-xy-00.png,34.1351,0.0146,0.0056,11.7424\n+Small,6x6,ldr-xy-01.png,34.4469,0.0144,0.0056,11.6242\n+Small,6x6,ldr-xy-02.png,41.2646,0.0141,0.0050,13.2077\n+Small,6x6,ldrs-rgba-00.png,26.9281,0.0193,0.0097,6.7499\n+Small,6x6,ldrs-rgba-01.png,30.9047,0.0145,0.0052,12.6912\n+Small,6x6,ldrs-rgba-02.png,27.2830,0.0162,0.0069,9.5673\n+Small,8x8,hdr-rgb-00.hdr,20.9747,0.1420,0.0391,1.6769\n+Small,8x8,ldr-rgb-00.png,25.4859,0.0186,0.0054,12.1789\n+Small,8x8,ldr-rgb-01.png,27.2589,0.0171,0.0044,14.9147\n+Small,8x8,ldr-rgb-02.png,22.4702,0.0195,0.0065,10.0669\n+Small,8x8,ldr-rgb-03.png,35.2148,0.0168,0.0044,15.0519\n+Small,8x8,ldr-rgb-04.png,26.8544,0.0175,0.0045,14.6445\n+Small,8x8,ldr-rgb-05.png,23.7212,0.0180,0.0049,13.4817\n+Small,8x8,ldr-rgb-06.png,22.4449,0.0197,0.0065,10.0636\n+Small,8x8,ldr-rgb-07.png,26.6314,0.0181,0.0047,14.0122\n+Small,8x8,ldr-rgb-08.png,31.9925,0.0173,0.0043,15.1523\n+Small,8x8,ldr-rgb-09.png,26.1706,0.0178,0.0050,13.2077\n+Small,8x8,ldr-rgb-10.png,30.3623,0.0122,0.0015,11.1173\n+Small,8x8,ldr-rgba-00.png,22.9055,0.0225,0.0091,7.2065\n+Small,8x8,ldr-rgba-01.png,27.0976,0.0179,0.0048,13.6423\n+Small,8x8,ldr-rgba-02.png,23.4839,0.0203,0.0070,9.3719\n+Small,8x8,ldr-xy-00.png,30.2975,0.0184,0.0053,12.2680\n+Small,8x8,ldr-xy-01.png,29.8774,0.0178,0.0051,12.9672\n+Small,8x8,ldr-xy-02.png,39.7072,0.0177,0.0048,13.5964\n+Small,8x8,ldrs-rgba-00.png,22.9128,0.0228,0.0092,7.0988\n+Small,8x8,ldrs-rgba-01.png,27.0997,0.0181,0.0050,13.1994\n+Small,8x8,ldrs-rgba-02.png,23.4814,0.0204,0.0071,9.2523\n+Small,12x12,hdr-rgb-00.hdr,18.4232,0.1500,0.0427,1.5347\n+Small,12x12,ldr-rgb-00.png,22.1611,0.0225,0.0044,14.9212\n+Small,12x12,ldr-rgb-01.png,24.0069,0.0223,0.0043,15.2659\n+Small,12x12,ldr-rgb-02.png,18.4870,0.0222,0.0043,15.0866\n+Small,12x12,ldr-rgb-03.png,32.2406,0.0218,0.0041,15.8568\n+Small,12x12,ldr-rgb-04.png,23.1528,0.0224,0.0042,15.6039\n+Small,12x12,ldr-rgb-05.png,20.3932,0.0223,0.0042,15.7091\n+Small,12x12,ldr-rgb-06.png,18.3866,0.0225,0.0042,15.4487\n+Small,12x12,ldr-rgb-07.png,23.9840,0.0226,0.0041,16.0503\n+Small,12x12,ldr-rgb-08.png,28.8132,0.0220,0.0042,15.6706\n+Small,12x12,ldr-rgb-09.png,21.7323,0.0222,0.0042,15.7840\n+Small,12x12,ldr-rgb-10.png,26.4766,0.0172,0.0016,10.0151\n+Small,12x12,ldr-rgba-00.png,19.6912,0.0237,0.0051,12.9623\n+Small,12x12,ldr-rgba-01.png,23.8408,0.0225,0.0044,14.7475\n+Small,12x12,ldr-rgba-02.png,19.6613,0.0229,0.0046,14.2372\n+Small,12x12,ldr-xy-00.png,26.9214,0.0230,0.0049,13.3963\n+Small,12x12,ldr-xy-01.png,26.0915,0.0226,0.0050,13.0447\n+Small,12x12,ldr-xy-02.png,38.2595,0.0230,0.0049,13.3416\n+Small,12x12,ldrs-rgba-00.png,19.6892,0.0237,0.0053,12.4407\n+Small,12x12,ldrs-rgba-01.png,23.8418,0.0227,0.0046,14.3945\n+Small,12x12,ldrs-rgba-02.png,19.6604,0.0226,0.0047,13.9972\n+Small,3x3x3,ldr-l-00-3.dds,48.6313,0.0340,0.0246,10.6554\n+Small,3x3x3,ldr-l-01-3.dds,54.0170,0.0171,0.0100,6.8777\n+Small,6x6x6,ldr-l-00-3.dds,32.5131,0.0934,0.0614,4.2678\n+Small,6x6x6,ldr-l-01-3.dds,41.1946,0.0530,0.0234,2.9451\n" }, { "change_type": "ADD", "old_path": null, "new_path": "Test/Images/Small/astc_reference-master-avx2_medium_results.csv", "diff": "+Image Set,Block Size,Name,PSNR,Total Time,Coding Time,Coding Rate\n+Small,4x4,hdr-rgb-00.hdr,32.4092,0.1900,0.0928,0.7062\n+Small,4x4,ldr-rgb-00.png,38.6238,0.0999,0.0901,0.7275\n+Small,4x4,ldr-rgb-01.png,40.0148,0.0830,0.0749,0.8755\n+Small,4x4,ldr-rgb-02.png,35.1002,0.0823,0.0742,0.8827\n+Small,4x4,ldr-rgb-03.png,46.9994,0.0541,0.0462,1.4187\n+Small,4x4,ldr-rgb-04.png,41.9930,0.0686,0.0603,1.0874\n+Small,4x4,ldr-rgb-05.png,37.6480,0.0918,0.0836,0.7844\n+Small,4x4,ldr-rgb-06.png,35.2638,0.0745,0.0661,0.9913\n+Small,4x4,ldr-rgb-07.png,38.6293,0.1110,0.1024,0.6400\n+Small,4x4,ldr-rgb-08.png,44.6050,0.0623,0.0542,1.2096\n+Small,4x4,ldr-rgb-09.png,41.9548,0.0697,0.0614,1.0670\n+Small,4x4,ldr-rgb-10.png,44.8515,0.0169,0.0110,1.4728\n+Small,4x4,ldr-rgba-00.png,36.1681,0.1083,0.0997,0.6574\n+Small,4x4,ldr-rgba-01.png,38.8026,0.0604,0.0519,1.2620\n+Small,4x4,ldr-rgba-02.png,34.7708,0.0934,0.0849,0.7721\n+Small,4x4,ldr-xy-00.png,37.6723,0.0467,0.0386,1.6992\n+Small,4x4,ldr-xy-01.png,45.2009,0.0668,0.0589,1.1132\n+Small,4x4,ldr-xy-02.png,50.9440,0.0647,0.0562,1.1667\n+Small,4x4,ldrs-rgba-00.png,36.1725,0.1096,0.1008,0.6502\n+Small,4x4,ldrs-rgba-01.png,38.8164,0.0616,0.0531,1.2339\n+Small,4x4,ldrs-rgba-02.png,34.7734,0.0939,0.0852,0.7689\n+Small,5x5,hdr-rgb-00.hdr,26.5805,0.2079,0.1098,0.5971\n+Small,5x5,ldr-rgb-00.png,35.0188,0.1061,0.0963,0.6806\n+Small,5x5,ldr-rgb-01.png,36.3591,0.0792,0.0699,0.9382\n+Small,5x5,ldr-rgb-02.png,30.9794,0.0815,0.0718,0.9122\n+Small,5x5,ldr-rgb-03.png,43.7026,0.0325,0.0233,2.8114\n+Small,5x5,ldr-rgb-04.png,37.5951,0.0702,0.0604,1.0846\n+Small,5x5,ldr-rgb-05.png,33.4642,0.1131,0.1033,0.6344\n+Small,5x5,ldr-rgb-06.png,31.0224,0.0773,0.0676,0.9692\n+Small,5x5,ldr-rgb-07.png,35.6291,0.1175,0.1076,0.6089\n+Small,5x5,ldr-rgb-08.png,41.2289,0.0507,0.0411,1.5946\n+Small,5x5,ldr-rgb-09.png,37.5153,0.0661,0.0566,1.1581\n+Small,5x5,ldr-rgb-10.png,40.4972,0.0199,0.0127,1.2765\n+Small,5x5,ldr-rgba-00.png,32.7160,0.1332,0.1233,0.5317\n+Small,5x5,ldr-rgba-01.png,35.2078,0.0724,0.0627,1.0456\n+Small,5x5,ldr-rgba-02.png,31.0677,0.1347,0.1249,0.5247\n+Small,5x5,ldr-xy-00.png,37.2111,0.0503,0.0408,1.6047\n+Small,5x5,ldr-xy-01.png,41.0524,0.0671,0.0577,1.1366\n+Small,5x5,ldr-xy-02.png,48.7445,0.0383,0.0287,2.2859\n+Small,5x5,ldrs-rgba-00.png,32.7176,0.1445,0.1343,0.4880\n+Small,5x5,ldrs-rgba-01.png,35.2138,0.0788,0.0690,0.9505\n+Small,5x5,ldrs-rgba-02.png,31.0679,0.1196,0.1099,0.5962\n+Small,6x6,hdr-rgb-00.hdr,24.8436,0.2102,0.1112,0.5896\n+Small,6x6,ldr-rgb-00.png,32.3760,0.1238,0.1127,0.5816\n+Small,6x6,ldr-rgb-01.png,33.0689,0.1149,0.1037,0.6319\n+Small,6x6,ldr-rgb-02.png,27.4386,0.1383,0.1272,0.5153\n+Small,6x6,ldr-rgb-03.png,41.6791,0.0306,0.0197,3.3199\n+Small,6x6,ldr-rgb-04.png,34.1722,0.1038,0.0926,0.7078\n+Small,6x6,ldr-rgb-05.png,30.1347,0.1615,0.1505,0.4355\n+Small,6x6,ldr-rgb-06.png,27.5082,0.1351,0.1239,0.5291\n+Small,6x6,ldr-rgb-07.png,34.0182,0.1327,0.1213,0.5402\n+Small,6x6,ldr-rgb-08.png,39.1558,0.0482,0.0374,1.7526\n+Small,6x6,ldr-rgb-09.png,33.7251,0.1009,0.0900,0.7285\n+Small,6x6,ldr-rgb-10.png,36.9864,0.0228,0.0141,1.1546\n+Small,6x6,ldr-rgba-00.png,30.1808,0.1552,0.1438,0.4558\n+Small,6x6,ldr-rgba-01.png,32.1457,0.0740,0.0627,1.0452\n+Small,6x6,ldr-rgba-02.png,27.8184,0.1350,0.1235,0.5305\n+Small,6x6,ldr-xy-00.png,36.0917,0.0458,0.0348,1.8809\n+Small,6x6,ldr-xy-01.png,38.0215,0.0522,0.0415,1.5790\n+Small,6x6,ldr-xy-02.png,44.9798,0.0327,0.0217,3.0132\n+Small,6x6,ldrs-rgba-00.png,30.1818,0.1550,0.1435,0.4566\n+Small,6x6,ldrs-rgba-01.png,32.1517,0.0746,0.0634,1.0334\n+Small,6x6,ldrs-rgba-02.png,27.8174,0.1348,0.1237,0.5298\n+Small,8x8,hdr-rgb-00.hdr,21.5635,0.2244,0.1195,0.5486\n+Small,8x8,ldr-rgb-00.png,28.7676,0.1610,0.1443,0.4542\n+Small,8x8,ldr-rgb-01.png,28.8931,0.1424,0.1259,0.5205\n+Small,8x8,ldr-rgb-02.png,23.1046,0.1721,0.1554,0.4217\n+Small,8x8,ldr-rgb-03.png,38.5533,0.0375,0.0211,3.1101\n+Small,8x8,ldr-rgb-04.png,29.6280,0.1329,0.1159,0.5657\n+Small,8x8,ldr-rgb-05.png,25.9043,0.1938,0.1768,0.3707\n+Small,8x8,ldr-rgb-06.png,23.2055,0.1686,0.1515,0.4325\n+Small,8x8,ldr-rgb-07.png,30.7502,0.1469,0.1296,0.5056\n+Small,8x8,ldr-rgb-08.png,35.8613,0.0573,0.0407,1.6105\n+Small,8x8,ldr-rgb-09.png,29.0664,0.1296,0.1127,0.5814\n+Small,8x8,ldr-rgb-10.png,32.2152,0.0320,0.0177,0.9181\n+Small,8x8,ldr-rgba-00.png,26.1152,0.1867,0.1692,0.3872\n+Small,8x8,ldr-rgba-01.png,28.2888,0.0878,0.0706,0.9283\n+Small,8x8,ldr-rgba-02.png,23.8939,0.1560,0.1389,0.4717\n+Small,8x8,ldr-xy-00.png,34.0271,0.0606,0.0439,1.4923\n+Small,8x8,ldr-xy-01.png,34.9465,0.0599,0.0434,1.5112\n+Small,8x8,ldr-xy-02.png,40.8072,0.0328,0.0159,4.1093\n+Small,8x8,ldrs-rgba-00.png,26.1157,0.1872,0.1700,0.3855\n+Small,8x8,ldrs-rgba-01.png,28.2920,0.0873,0.0705,0.9301\n+Small,8x8,ldrs-rgba-02.png,23.8935,0.1552,0.1380,0.4751\n+Small,12x12,hdr-rgb-00.hdr,18.7740,0.2594,0.1441,0.4549\n+Small,12x12,ldr-rgb-00.png,24.6271,0.1622,0.1343,0.4878\n+Small,12x12,ldr-rgb-01.png,25.0250,0.1668,0.1391,0.4713\n+Small,12x12,ldr-rgb-02.png,19.2713,0.2073,0.1789,0.3663\n+Small,12x12,ldr-rgb-03.png,34.8097,0.0495,0.0220,2.9780\n+Small,12x12,ldr-rgb-04.png,24.9309,0.1578,0.1307,0.5013\n+Small,12x12,ldr-rgb-05.png,21.6670,0.2283,0.2004,0.3270\n+Small,12x12,ldr-rgb-06.png,19.2690,0.1991,0.1711,0.3830\n+Small,12x12,ldr-rgb-07.png,26.6347,0.1477,0.1193,0.5494\n+Small,12x12,ldr-rgb-08.png,31.3779,0.0681,0.0403,1.6277\n+Small,12x12,ldr-rgb-09.png,24.3028,0.1530,0.1251,0.5238\n+Small,12x12,ldr-rgb-10.png,27.9279,0.0478,0.0229,0.7098\n+Small,12x12,ldr-rgba-00.png,21.8636,0.1696,0.1413,0.4640\n+Small,12x12,ldr-rgba-01.png,24.5735,0.1066,0.0783,0.8366\n+Small,12x12,ldr-rgba-02.png,20.1772,0.1664,0.1383,0.4740\n+Small,12x12,ldr-xy-00.png,29.7776,0.0710,0.0432,1.5174\n+Small,12x12,ldr-xy-01.png,32.1672,0.0634,0.0359,1.8260\n+Small,12x12,ldr-xy-02.png,38.4416,0.0336,0.0063,10.4207\n+Small,12x12,ldrs-rgba-00.png,21.8640,0.1696,0.1413,0.4637\n+Small,12x12,ldrs-rgba-01.png,24.5748,0.1057,0.0778,0.8427\n+Small,12x12,ldrs-rgba-02.png,20.1774,0.1652,0.1371,0.4779\n+Small,3x3x3,ldr-l-00-3.dds,51.9477,0.0494,0.0398,6.5890\n+Small,3x3x3,ldr-l-01-3.dds,54.8800,0.0190,0.0120,5.7329\n+Small,6x6x6,ldr-l-00-3.dds,32.8966,0.1205,0.0886,2.9578\n+Small,6x6x6,ldr-l-01-3.dds,41.5598,0.0544,0.0249,2.7726\n" }, { "change_type": "ADD", "old_path": null, "new_path": "Test/Images/Small/astc_reference-master-avx2_thorough_results.csv", "diff": "+Image Set,Block Size,Name,PSNR,Total Time,Coding Time,Coding Rate\n+Small,4x4,hdr-rgb-00.hdr,32.7084,0.3274,0.2318,0.2827\n+Small,4x4,ldr-rgb-00.png,39.1266,0.2502,0.2415,0.2714\n+Small,4x4,ldr-rgb-01.png,40.3120,0.2362,0.2276,0.2880\n+Small,4x4,ldr-rgb-02.png,35.3545,0.2119,0.2034,0.3222\n+Small,4x4,ldr-rgb-03.png,47.6580,0.2672,0.2589,0.2532\n+Small,4x4,ldr-rgb-04.png,42.2592,0.2122,0.2037,0.3218\n+Small,4x4,ldr-rgb-05.png,37.9702,0.2304,0.2220,0.2953\n+Small,4x4,ldr-rgb-06.png,35.4536,0.2025,0.1939,0.3380\n+Small,4x4,ldr-rgb-07.png,39.7196,0.2673,0.2586,0.2534\n+Small,4x4,ldr-rgb-08.png,45.7039,0.2395,0.2312,0.2834\n+Small,4x4,ldr-rgb-09.png,42.1899,0.2222,0.2139,0.3064\n+Small,4x4,ldr-rgb-10.png,45.0040,0.0368,0.0308,0.5284\n+Small,4x4,ldr-rgba-00.png,36.7577,0.2505,0.2418,0.2711\n+Small,4x4,ldr-rgba-01.png,39.0080,0.2244,0.2158,0.3037\n+Small,4x4,ldr-rgba-02.png,34.9603,0.2568,0.2483,0.2639\n+Small,4x4,ldr-xy-00.png,37.7427,0.1875,0.1789,0.3663\n+Small,4x4,ldr-xy-01.png,45.6589,0.2002,0.1918,0.3417\n+Small,4x4,ldr-xy-02.png,50.9859,0.2611,0.2527,0.2593\n+Small,4x4,ldrs-rgba-00.png,36.7655,0.2526,0.2437,0.2689\n+Small,4x4,ldrs-rgba-01.png,39.0268,0.2271,0.2186,0.2998\n+Small,4x4,ldrs-rgba-02.png,34.9630,0.2574,0.2489,0.2633\n+Small,5x5,hdr-rgb-00.hdr,28.0142,0.3378,0.2400,0.2730\n+Small,5x5,ldr-rgb-00.png,35.3551,0.2718,0.2619,0.2502\n+Small,5x5,ldr-rgb-01.png,36.5061,0.2568,0.2473,0.2650\n+Small,5x5,ldr-rgb-02.png,31.1143,0.2324,0.2228,0.2941\n+Small,5x5,ldr-rgb-03.png,44.4987,0.2726,0.2631,0.2491\n+Small,5x5,ldr-rgb-04.png,37.8247,0.2246,0.2149,0.3050\n+Small,5x5,ldr-rgb-05.png,33.6734,0.2513,0.2416,0.2713\n+Small,5x5,ldr-rgb-06.png,31.1313,0.2245,0.2144,0.3056\n+Small,5x5,ldr-rgb-07.png,36.6129,0.2855,0.2755,0.2379\n+Small,5x5,ldr-rgb-08.png,42.2649,0.2471,0.2376,0.2759\n+Small,5x5,ldr-rgb-09.png,37.6685,0.2374,0.2278,0.2877\n+Small,5x5,ldr-rgb-10.png,40.7287,0.0444,0.0370,0.4399\n+Small,5x5,ldr-rgba-00.png,33.1600,0.2842,0.2741,0.2391\n+Small,5x5,ldr-rgba-01.png,35.3273,0.2562,0.2463,0.2660\n+Small,5x5,ldr-rgba-02.png,31.1580,0.3190,0.3092,0.2120\n+Small,5x5,ldr-xy-00.png,37.2467,0.1614,0.1518,0.4318\n+Small,5x5,ldr-xy-01.png,41.8652,0.2392,0.2297,0.2853\n+Small,5x5,ldr-xy-02.png,49.2012,0.2771,0.2674,0.2451\n+Small,5x5,ldrs-rgba-00.png,33.1619,0.2836,0.2735,0.2396\n+Small,5x5,ldrs-rgba-01.png,35.3351,0.2575,0.2475,0.2648\n+Small,5x5,ldrs-rgba-02.png,31.1583,0.3798,0.3698,0.1772\n+Small,6x6,hdr-rgb-00.hdr,25.0615,0.3877,0.2870,0.2283\n+Small,6x6,ldr-rgb-00.png,32.6733,0.3177,0.3059,0.2143\n+Small,6x6,ldr-rgb-01.png,33.1811,0.3180,0.3066,0.2138\n+Small,6x6,ldr-rgb-02.png,27.5122,0.3252,0.3139,0.2088\n+Small,6x6,ldr-rgb-03.png,42.5306,0.1928,0.1819,0.3602\n+Small,6x6,ldr-rgb-04.png,34.3336,0.3126,0.3010,0.2177\n+Small,6x6,ldr-rgb-05.png,30.2858,0.3248,0.3135,0.2091\n+Small,6x6,ldr-rgb-06.png,27.5818,0.3228,0.3108,0.2108\n+Small,6x6,ldr-rgb-07.png,34.4264,0.3148,0.3030,0.2163\n+Small,6x6,ldr-rgb-08.png,39.9146,0.1807,0.1694,0.3868\n+Small,6x6,ldr-rgb-09.png,33.8589,0.2944,0.2832,0.2314\n+Small,6x6,ldr-rgb-10.png,37.1742,0.0533,0.0445,0.3655\n+Small,6x6,ldr-rgba-00.png,30.4986,0.3163,0.3046,0.2151\n+Small,6x6,ldr-rgba-01.png,32.2353,0.2783,0.2668,0.2456\n+Small,6x6,ldr-rgba-02.png,27.8832,0.3573,0.3455,0.1897\n+Small,6x6,ldr-xy-00.png,36.4012,0.1327,0.1215,0.5395\n+Small,6x6,ldr-xy-01.png,38.5024,0.2034,0.1923,0.3409\n+Small,6x6,ldr-xy-02.png,47.3843,0.2721,0.2606,0.2515\n+Small,6x6,ldrs-rgba-00.png,30.5005,0.3180,0.3062,0.2140\n+Small,6x6,ldrs-rgba-01.png,32.2405,0.2806,0.2692,0.2434\n+Small,6x6,ldrs-rgba-02.png,27.8823,0.3584,0.3467,0.1890\n+Small,8x8,hdr-rgb-00.hdr,21.8500,0.3384,0.2336,0.2806\n+Small,8x8,ldr-rgb-00.png,29.0405,0.3341,0.3165,0.2071\n+Small,8x8,ldr-rgb-01.png,28.9931,0.3194,0.3020,0.2170\n+Small,8x8,ldr-rgb-02.png,23.1743,0.3532,0.3361,0.1950\n+Small,8x8,ldr-rgb-03.png,39.3540,0.0784,0.0615,1.0662\n+Small,8x8,ldr-rgb-04.png,29.7670,0.3198,0.3023,0.2168\n+Small,8x8,ldr-rgb-05.png,26.0370,0.3517,0.3341,0.1961\n+Small,8x8,ldr-rgb-06.png,23.2683,0.3520,0.3346,0.1959\n+Small,8x8,ldr-rgb-07.png,31.1724,0.3228,0.3050,0.2148\n+Small,8x8,ldr-rgb-08.png,36.5480,0.1405,0.1233,0.5313\n+Small,8x8,ldr-rgb-09.png,29.1966,0.2656,0.2484,0.2639\n+Small,8x8,ldr-rgb-10.png,32.4009,0.0605,0.0454,0.3578\n+Small,8x8,ldr-rgba-00.png,26.5430,0.3437,0.3260,0.2010\n+Small,8x8,ldr-rgba-01.png,28.3718,0.2879,0.2705,0.2423\n+Small,8x8,ldr-rgba-02.png,23.9505,0.3601,0.3425,0.1914\n+Small,8x8,ldr-xy-00.png,34.2486,0.1376,0.1203,0.5450\n+Small,8x8,ldr-xy-01.png,35.5130,0.1291,0.1121,0.5844\n+Small,8x8,ldr-xy-02.png,44.2744,0.1458,0.1283,0.5107\n+Small,8x8,ldrs-rgba-00.png,26.5438,0.3445,0.3269,0.2005\n+Small,8x8,ldrs-rgba-01.png,28.3748,0.2885,0.2709,0.2419\n+Small,8x8,ldrs-rgba-02.png,23.9499,0.3610,0.3434,0.1908\n+Small,12x12,hdr-rgb-00.hdr,18.9158,0.3656,0.2498,0.2623\n+Small,12x12,ldr-rgb-00.png,25.0819,0.3714,0.3428,0.1912\n+Small,12x12,ldr-rgb-01.png,25.1507,0.3330,0.3045,0.2152\n+Small,12x12,ldr-rgb-02.png,19.3167,0.4021,0.3732,0.1756\n+Small,12x12,ldr-rgb-03.png,35.9730,0.0907,0.0619,1.0590\n+Small,12x12,ldr-rgb-04.png,25.0477,0.3474,0.3179,0.2062\n+Small,12x12,ldr-rgb-05.png,21.7621,0.3988,0.3698,0.1772\n+Small,12x12,ldr-rgb-06.png,19.3260,0.4025,0.3734,0.1755\n+Small,12x12,ldr-rgb-07.png,27.1258,0.3652,0.3358,0.1951\n+Small,12x12,ldr-rgb-08.png,32.3561,0.1457,0.1166,0.5621\n+Small,12x12,ldr-rgb-09.png,24.4626,0.3091,0.2801,0.2340\n+Small,12x12,ldr-rgb-10.png,28.1612,0.0782,0.0514,0.3162\n+Small,12x12,ldr-rgba-00.png,22.3332,0.3764,0.3469,0.1889\n+Small,12x12,ldr-rgba-01.png,24.6833,0.2851,0.2558,0.2562\n+Small,12x12,ldr-rgba-02.png,20.2124,0.3238,0.2946,0.2225\n+Small,12x12,ldr-xy-00.png,30.4805,0.1777,0.1484,0.4416\n+Small,12x12,ldr-xy-01.png,32.5155,0.1262,0.0971,0.6746\n+Small,12x12,ldr-xy-02.png,39.6307,0.0653,0.0361,1.8131\n+Small,12x12,ldrs-rgba-00.png,22.3350,0.3787,0.3490,0.1878\n+Small,12x12,ldrs-rgba-01.png,24.6847,0.2857,0.2564,0.2556\n+Small,12x12,ldrs-rgba-02.png,20.2126,0.3252,0.2959,0.2215\n+Small,3x3x3,ldr-l-00-3.dds,52.4194,0.1133,0.1036,2.5302\n+Small,3x3x3,ldr-l-01-3.dds,55.3234,0.0435,0.0364,1.8930\n+Small,6x6x6,ldr-l-00-3.dds,33.2699,0.1833,0.1512,1.7336\n+Small,6x6x6,ldr-l-01-3.dds,41.7451,0.0585,0.0291,2.3715\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -369,7 +369,7 @@ def parse_command_line():\nparser.add_argument(\"--encoder\", dest=\"encoders\", default=\"avx2\",\nchoices=coders, help=\"test encoder variant\")\n- parser.add_argument(\"--reference\", dest=\"reference\", default=\"ref-2.2-avx2\",\n+ parser.add_argument(\"--reference\", dest=\"reference\", default=\"ref-master-avx2\",\nchoices=refcoders, help=\"reference encoder variant\")\nastcProfile = [\"ldr\", \"ldrs\", \"hdr\", \"all\"]\n@@ -471,8 +471,16 @@ def main():\ntestSet = tts.TestSet(imageSet, testDir,\nargs.profiles, args.formats, args.testImage)\n+ # The fast and fastest presets are now sufficiently fast that\n+ # the results are noisy without more repeats\n+ testRepeats = args.testRepeats\n+ if quality == \"fast\":\n+ testRepeats *= 2\n+ elif quality == \"fastest\":\n+ testRepeats *= 4\n+\nresultSet = run_test_set(encoder, testRef, testSet, quality,\n- args.blockSizes, args.testRepeats,\n+ args.blockSizes, testRepeats,\nargs.keepOutput)\nresultSet.save_to_file(testRes)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update Small test reference to latest master build
61,745
13.01.2021 23:11:15
0
f4406616d591e41d729aa53f871916fef3979dfc
Variable name / whitespace cleanup
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -459,7 +459,7 @@ void compute_averages_and_directions_2_components(\n}\nvoid compute_error_squared_rgba(\n- const partition_info* pt, // the partition that we use when computing the squared-error.\n+ const partition_info* pt,\nconst imageblock* blk,\nconst error_weight_block* ewb,\nconst processed_line4* uncor_plines,\n@@ -636,23 +636,24 @@ void compute_error_squared_rgba(\nsamec_loparam = astc::min(samec_param, samec_loparam);\nsamec_hiparam = astc::max(samec_param, samec_hiparam);\n- float4 uncorr_dist = (l_uncor.amod - dat) + (uncor_param * l_uncor.bis);\n- uncor_errorsum += dot(ews, uncorr_dist * uncorr_dist);\n+ float4 uncor_dist = (l_uncor.amod - dat)\n+ + (uncor_param * l_uncor.bis);\n+ uncor_errorsum += dot(ews, uncor_dist * uncor_dist);\n- float4 samechroma_dist = (l_samec.amod - dat) +\n- (samec_param * l_samec.bis);\n- samec_errorsum += dot(ews, samechroma_dist * samechroma_dist);\n+ float4 samec_dist = (l_samec.amod - dat)\n+ + (samec_param * l_samec.bis);\n+ samec_errorsum += dot(ews, samec_dist * samec_dist);\n}\n- float uncorr_linelen = uncor_hiparam - uncor_loparam;\n- float samechroma_linelen = samec_hiparam - samec_loparam;\n+ float uncor_linelen = uncor_hiparam - uncor_loparam;\n+ float samec_linelen = samec_hiparam - samec_loparam;\n// Turn very small numbers and NaNs into a small number\n- uncorr_linelen = astc::max(uncorr_linelen, 1e-7f);\n- samechroma_linelen = astc::max(samechroma_linelen, 1e-7f);\n+ uncor_linelen = astc::max(uncor_linelen, 1e-7f);\n+ samec_linelen = astc::max(samec_linelen, 1e-7f);\n- uncor_lengths[partition] = uncorr_linelen;\n- samec_lengths[partition] = samechroma_linelen;\n+ uncor_lengths[partition] = uncor_linelen;\n+ samec_lengths[partition] = samec_linelen;\n}\n*uncor_errors = uncor_errorsum;\n@@ -660,7 +661,7 @@ void compute_error_squared_rgba(\n}\nvoid compute_error_squared_rgb(\n- const partition_info *pt, // the partition that we use when computing the squared-error.\n+ const partition_info *pt,\nconst imageblock *blk,\nconst error_weight_block *ewb,\nconst processed_line3 *uncor_plines, // Uncorrelated channels\n@@ -820,24 +821,24 @@ void compute_error_squared_rgb(\nsamec_loparam = astc::min(samec_param, samec_loparam);\nsamec_hiparam = astc::max(samec_param, samec_hiparam);\n- float3 uncorr_dist = (l_uncor.amod - dat) +\n- (uncor_param * l_uncor.bis);\n- uncor_errorsum += dot(ews, uncorr_dist * uncorr_dist);\n+ float3 uncor_dist = (l_uncor.amod - dat)\n+ + (uncor_param * l_uncor.bis);\n+ uncor_errorsum += dot(ews, uncor_dist * uncor_dist);\n- float3 samechroma_dist = (l_samec.amod - dat) +\n- (samec_param * l_samec.bis);\n- samec_errorsum += dot(ews, samechroma_dist * samechroma_dist);\n+ float3 samec_dist = (l_samec.amod - dat)\n+ + (samec_param * l_samec.bis);\n+ samec_errorsum += dot(ews, samec_dist * samec_dist);\n}\n- float uncorr_linelen = uncor_hiparam - uncor_loparam;\n- float samechroma_linelen = samec_hiparam - samec_loparam;\n+ float uncor_linelen = uncor_hiparam - uncor_loparam;\n+ float samec_linelen = samec_hiparam - samec_loparam;\n// Turn very small numbers and NaNs into a small number\n- uncorr_linelen = astc::max(uncorr_linelen, 1e-7f);\n- samechroma_linelen = astc::max(samechroma_linelen, 1e-7f);\n+ uncor_linelen = astc::max(uncor_linelen, 1e-7f);\n+ samec_linelen = astc::max(samec_linelen, 1e-7f);\n- uncor_lengths[partition] = uncorr_linelen;\n- samec_lengths[partition] = samechroma_linelen;\n+ uncor_lengths[partition] = uncor_linelen;\n+ samec_lengths[partition] = samec_linelen;\n}\n*uncor_errors = uncor_errorsum;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -856,26 +856,26 @@ void compute_averages_and_directions_2_components(\nfloat2* directions);\nvoid compute_error_squared_rgba(\n- const partition_info* pt, // the partition that we use when computing the squared-error.\n+ const partition_info* pt,\nconst imageblock* blk,\nconst error_weight_block* ewb,\n- const processed_line4* plines_uncorr,\n- const processed_line4* plines_samechroma,\n- float* length_uncorr,\n- float* length_samechroma,\n- float* uncorr_error,\n- float* samechroma_error);\n+ const processed_line4* uncor_plines,\n+ const processed_line4* samec_plines,\n+ float* uncor_lengths,\n+ float* samec_lengths,\n+ float* uncor_errors,\n+ float* samec_errors);\nvoid compute_error_squared_rgb(\n- const partition_info* pt, // the partition that we use when computing the squared-error.\n+ const partition_info *pt,\nconst imageblock *blk,\nconst error_weight_block *ewb,\n- const processed_line3* plines_uncorr,\n- const processed_line3* plines_samechroma,\n- float* length_uncorr,\n- float* length_samechroma,\n- float* uncorr_error,\n- float* samechroma_error);\n+ const processed_line3 *uncor_plines,\n+ const processed_line3 *samec_plines,\n+ float *uncor_lengths,\n+ float *samec_lengths,\n+ float *uncor_errors,\n+ float *samec_errors);\n// for each partition, compute its color weightings.\nvoid compute_partition_error_color_weightings(\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Variable name / whitespace cleanup
61,745
15.01.2021 20:33:15
0
c63e673cdb53867b9ac59bbc6989f6f0367360db
Add cast for GCC 7.5 NEON support
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -181,7 +181,8 @@ struct vint4\nASTCENC_SIMD_INLINE explicit vint4(const uint8_t *p)\n{\nuint32x2_t t8 {};\n- t8 = vld1_lane_u32(p, t8, 0);\n+ // Cast is safe - NEON loads are allowed to be unaligned\n+ t8 = vld1_lane_u32((const uint32_t*)p, t8, 0);\nuint16x4_t t16 = vget_low_u16(vmovl_u8(vreinterpret_u8_u32(t8)));\nm = vreinterpretq_s32_u32(vmovl_u16(t16));\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add cast for GCC 7.5 NEON support
61,745
15.01.2021 22:37:11
0
87a868bc7c743270b6bf3b6aeee15029d17d6197
Remove unneeded if check
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1367,9 +1367,6 @@ void compress_block(\ncontinue;\n}\n-\n- if (lowest_correl <= ctx.config.tune_two_plane_early_out_limit)\n- {\ncompress_symbolic_block_fixed_partition_2_planes(\ndecode_mode,\nfalse,\n@@ -1407,7 +1404,6 @@ void compress_block(\ngoto END_OF_TESTS;\n}\n}\n- }\nEND_OF_TESTS:\n// compress/decompress to a physical block\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove unneeded if check
61,745
19.01.2021 23:38:50
0
bc74517efa37ac02633f80fbda4df72d60ef7d30
Support clang-cl on Windows
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "* loop tails if loops are unrolled by the auto-vectorizer.\n*/\n#if defined(NDEBUG)\n- #if defined(_MSC_VER)\n+ #if !defined(__clang__) && defined(_MSC_VER)\n#define promise(cond) __assume(cond)\n#elif defined(__clang__)\n#if __has_builtin(__builtin_assume)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_platform_isa_detection.cpp", "new_path": "Source/astcenc_platform_isa_detection.cpp", "diff": "@@ -32,7 +32,7 @@ static int g_cpu_has_popcnt = -1;\n/* ============================================================================\nPlatform code for Visual Studio\n============================================================================ */\n-#if defined(_MSC_VER)\n+#if !defined(__clang__) && defined(_MSC_VER)\n#include <intrin.h>\nstatic void detect_cpu_isa()\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "#include <arm_neon.h>\n#endif\n-#if defined(_MSC_VER)\n+#if !defined(__clang__) && defined(_MSC_VER)\n#define ASTCENC_SIMD_INLINE __forceinline\n#elif defined(__GNUC__) && !defined(__clang__)\n#define ASTCENC_SIMD_INLINE __attribute__((unused, always_inline)) inline\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_avx2_8.h", "new_path": "Source/astcenc_vecmathlib_avx2_8.h", "diff": "@@ -97,7 +97,7 @@ struct vfloat8\n*/\ntemplate <int l> ASTCENC_SIMD_INLINE float lane() const\n{\n- #ifdef _MSC_VER\n+ #if !defined(__clang__) && defined(_MSC_VER)\nreturn m.m256_f32[l];\n#else\nunion { __m256 m; float f[8]; } cvt;\n@@ -215,7 +215,7 @@ struct vint8\n*/\ntemplate <int l> ASTCENC_SIMD_INLINE int lane() const\n{\n- #ifdef _MSC_VER\n+ #if !defined(__clang__) && defined(_MSC_VER)\nreturn m.m256i_i32[l];\n#else\nunion { __m256i m; int f[8]; } cvt;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Support clang-cl on Windows
61,745
20.01.2021 01:42:40
0
ce25aa5ba71cdf9069c3c54da7e326deeccb2fcf
Initital support for clang++-10 and clang-cl
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -1733,7 +1733,7 @@ static int try_quantize_hdr_luminance_small_range3(\nv1d = color_unquantization_tables[quantization_level][v1e];\nif ((v1d & 0xE0) != (v1 & 0xE0))\n{\n- return 0;;\n+ return 0;\n}\noutput[0] = v0e;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -645,7 +645,7 @@ static void compress_image(\n}\nctx.manage_compress.complete_task_assignment(count);\n- };\n+ }\n}\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": "@@ -55,7 +55,7 @@ static void compute_endpoints_and_ideal_weights_1_component(\nfloat partition_error_scale[4];\nfloat linelengths_rcp[4];\n- const float *error_weights;\n+ const float *error_weights = nullptr;\nconst float* data_vr = nullptr;\nassert(component < 4);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_percentile_tables.cpp", "new_path": "Source/astcenc_percentile_tables.cpp", "diff": "// SPDX-License-Identifier: Apache-2.0\n// ----------------------------------------------------------------------------\n-// Copyright 2011-2020 Arm Limited\n+// Copyright 2011-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@@ -1108,7 +1108,7 @@ static const packed_percentile_table *get_packed_table(\ncase 0x0A0A: return &block_pcd_10x10;\ncase 0x0A0C: return &block_pcd_12x10;\ncase 0x0C0C: return &block_pcd_12x12;\n- };\n+ }\n// Should never hit this with a valid 2D block size\nreturn nullptr;\n@@ -1173,7 +1173,7 @@ int is_legal_2d_block_size(\ncase 0x0C0A:\ncase 0x0C0C:\nreturn 1;\n- };\n+ }\nreturn 0;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "#if !defined(__clang__) && defined(_MSC_VER)\n#define ASTCENC_SIMD_INLINE __forceinline\n#elif defined(__GNUC__) && !defined(__clang__)\n- #define ASTCENC_SIMD_INLINE __attribute__((unused, always_inline)) inline\n+ #define ASTCENC_SIMD_INLINE __attribute__((always_inline)) inline\n#else\n- #define ASTCENC_SIMD_INLINE __attribute__((unused, always_inline, nodebug)) inline\n+ #define ASTCENC_SIMD_INLINE __attribute__((always_inline, nodebug)) inline\n#endif\n#if ASTCENC_AVX >= 2\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_external.cpp", "new_path": "Source/astcenccli_image_external.cpp", "diff": "// SPDX-License-Identifier: Apache-2.0\n// ----------------------------------------------------------------------------\n-// Copyright 2011-2020 Arm Limited\n+// Copyright 2011-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#define STB_IMAGE_IMPLEMENTATION\n#define STB_IMAGE_WRITE_IMPLEMENTATION\n-#define STBI_MSC_SECURE_CRT\n#define STBI_NO_GIF\n#define STBI_NO_PIC\n#define STBI_NO_PNM\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "#include \"astcenccli_internal.h\"\n-#define STBI_HEADER_FILE_ONLY\n-\n#include \"stb_image.h\"\n#include \"stb_image_write.h\"\n#include \"tinyexr.h\"\n@@ -234,7 +232,7 @@ static void copy_scanline(\nd[4*i+3] = oneval; \\\n} \\\n} while (0); \\\n- break;\n+ break\n#define COPY_RG(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n@@ -248,7 +246,7 @@ static void copy_scanline(\nd[4*i+3] = oneval; \\\n} \\\n} while (0); \\\n- break;\n+ break\n#define COPY_RGB(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n@@ -262,7 +260,7 @@ static void copy_scanline(\nd[4*i+3] = oneval; \\\n} \\\n} while (0); \\\n- break;\n+ break\n#define COPY_BGR(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n@@ -276,7 +274,7 @@ static void copy_scanline(\nd[4*i+3] = oneval; \\\n} \\\n} while (0); \\\n- break;\n+ break\n#define COPY_RGBX(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n@@ -290,7 +288,7 @@ static void copy_scanline(\nd[4*i+3] = oneval; \\\n} \\\n} while (0); \\\n- break;\n+ break\n#define COPY_BGRX(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n@@ -304,7 +302,7 @@ static void copy_scanline(\nd[4*i+3] = oneval; \\\n} \\\n} while (0); \\\n- break;\n+ break\n#define COPY_RGBA(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n@@ -318,7 +316,7 @@ static void copy_scanline(\nd[4*i+3] = convfunc(s[4*i+3]); \\\n} \\\n} while (0); \\\n- break;\n+ break\n#define COPY_BGRA(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n@@ -332,7 +330,7 @@ static void copy_scanline(\nd[4*i+3] = convfunc(s[4*i+3]); \\\n} \\\n} while (0); \\\n- break;\n+ break\n#define COPY_L(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n@@ -346,7 +344,7 @@ static void copy_scanline(\nd[4*i+3] = oneval; \\\n} \\\n} while (0); \\\n- break;\n+ break\n#define COPY_LA(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n@@ -360,7 +358,7 @@ static void copy_scanline(\nd[4*i+3] = convfunc(s[2*i+1]); \\\n} \\\n} while (0); \\\n- break;\n+ break\nswitch (method)\n{\n@@ -435,7 +433,7 @@ static void copy_scanline(\nCOPY_L(uint16_t, uint32_t, f32_sf16, 0x3C00);\ncase LA32F_TO_RGBA16F:\nCOPY_LA(uint16_t, uint32_t, f32_sf16, 0x3C00);\n- };\n+ }\n}\n// perform endianness switch on raw data\n@@ -697,7 +695,7 @@ struct ktx_header\n};\n// magic 12-byte sequence that must appear at the beginning of every KTX file.\n-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@@ -799,7 +797,7 @@ static astcenc_image* load_ktx_uncompressed_image(\nprintf(\"KTX file %s has unsupported GL type\\n\", filename);\nfclose(f);\nreturn nullptr;\n- };\n+ }\n// Although these are set up later, we include a default initializer to remove warnings\nint bytes_per_component = 1; // bytes per component in the KTX file.\n@@ -1482,7 +1480,7 @@ struct dds_header_dx10\n#define DDS_MAGIC 0x20534444\n#define DX10_MAGIC 0x30315844\n-astcenc_image* load_dds_uncompressed_image(\n+static astcenc_image* load_dds_uncompressed_image(\nconst char* filename,\nbool y_flip,\nbool& is_hdr,\n@@ -1547,10 +1545,13 @@ astcenc_image* load_dds_uncompressed_image(\nunsigned int dim_y = hdr.height;\nunsigned int dim_z = (hdr.flags & 0x800000) ? hdr.depth : 1;\n- int bitness; // the bitcount that we will use internally in the codec\n- int bytes_per_component; // the bytes per component in the DDS file itself\n- int components;\n- int copy_method;\n+ // The bitcount that we will use internally in the codec\n+ int bitness = 0;\n+\n+ // The bytes per component in the DDS file itself\n+ int bytes_per_component = 0;\n+ int components = 0;\n+ int copy_method = 0;\n// figure out the format actually used in the DDS file.\nif (use_dx10_header)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_platform_dependents.cpp", "new_path": "Source/astcenccli_platform_dependents.cpp", "diff": "// SPDX-License-Identifier: Apache-2.0\n// ----------------------------------------------------------------------------\n-// Copyright 2011-2020 Arm Limited\n+// Copyright 2011-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#if defined(_WIN32) && !defined(__CYGWIN__)\n#define WIN32_LEAN_AND_MEAN\n-#include <windows.h>\n+#include <Windows.h>\ntypedef HANDLE pthread_t;\ntypedef int pthread_attr_t;\n@@ -50,6 +50,7 @@ static int pthread_create(\nvoid* (*threadfunc)(void*),\nvoid* thread_arg\n) {\n+ (void)attribs;\nLPTHREAD_START_ROUTINE func = (LPTHREAD_START_ROUTINE)threadfunc;\n*thread = CreateThread(nullptr, 0, func, thread_arg, 0, nullptr);\nreturn 0;\n@@ -60,6 +61,7 @@ static int pthread_join(\npthread_t thread,\nvoid** value\n) {\n+ (void)value;\nWaitForSingleObject(thread, INFINITE);\nreturn 0;\n}\n@@ -82,13 +84,6 @@ double get_time()\nreturn ((double)ticks) / 1.0e7;\n}\n-/* Public function, see header file for detailed documentation */\n-int unlink_file(const char *filename)\n-{\n- BOOL res = DeleteFileA(filename);\n- return (res ? 0 : -1);\n-}\n-\n/* ============================================================================\nPlatform code for an platform using POSIX APIs.\n============================================================================ */\n@@ -112,12 +107,6 @@ double get_time()\nreturn (double)tv.tv_sec + (double)tv.tv_usec * 1.0e-6;\n}\n-/* Public function, see header file for detailed documentation */\n-int unlink_file(const char *filename)\n-{\n- return unlink(filename);\n-}\n-\n#endif\n/**\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "// SPDX-License-Identifier: Apache-2.0\n// ----------------------------------------------------------------------------\n-// Copyright 2011-2020 Arm Limited\n+// Copyright 2011-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\ntypedef unsigned int astcenc_operation;\nstruct mode_entry {\n- std::string opt;\n+ const char* opt;\nastcenc_operation operation;\nastcenc_profile decode_mode;\n};\n@@ -313,7 +313,7 @@ static astcenc_image* load_uncomp_file(\n*\n* @return 0 if everything is okay, 1 if there is some error\n*/\n-int parse_commandline_options(\n+static int parse_commandline_options(\nint argc,\nchar **argv,\nastcenc_operation& operation,\n@@ -327,7 +327,7 @@ int parse_commandline_options(\nint modes_count = sizeof(modes) / sizeof(modes[0]);\nfor (int i = 0; i < modes_count; i++)\n{\n- if (modes[i].opt == argv[1])\n+ if (!strcmp(modes[i].opt, argv[1]))\n{\noperation = modes[i].operation;\nprofile = modes[i].decode_mode;\n@@ -357,7 +357,7 @@ int parse_commandline_options(\n*\n* @return 0 if everything is okay, 1 if there is some error\n*/\n-int init_astcenc_config(\n+static int init_astcenc_config(\nint argc,\nchar **argv,\nastcenc_profile profile,\n@@ -536,7 +536,7 @@ int init_astcenc_config(\n*\n* @return 0 if everything is Okay, 1 if there is some error\n*/\n-int edit_astcenc_config(\n+static int edit_astcenc_config(\nint argc,\nchar **argv,\nconst astcenc_operation operation,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "#include \"astcenccli_internal.h\"\n-const char *astcenc_copyright_string =\n+static const char *astcenc_copyright_string =\nR\"(ASTC codec v2.3-develop, %u-bit %s%s\nCopyright 2011-2021 Arm Limited, all rights reserved\n)\";\n-\n-const char *astcenc_short_help =\n+static const char *astcenc_short_help =\nR\"(\nBasic usage:\n@@ -67,8 +66,7 @@ The -*H options configure the compressor for full HDR across all channels.\nFor full help documentation run 'astcenc -help'.\n)\";\n-\n-const char *astcenc_long_help = R\"(\n+static const char *astcenc_long_help = R\"(\nNAME\nastcenc - compress or decompress images using the ASTC format\n" }, { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "project(astc${CODEC}-${ISA_SIMD})\nset(GNU_LIKE \"GNU,Clang,AppleClang\")\n+set(CLANG_LIKE \"Clang,AppleClang\")\nadd_executable(astc${CODEC}-${ISA_SIMD})\n@@ -94,8 +95,30 @@ target_compile_options(astc${CODEC}-${ISA_SIMD}\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Werror>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wshadow>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wdouble-promotion>\n+\n+ # Hide noise thrown up by Clang 10 and clang-cl\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-unknown-warning-option>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-c++98-compat-pedantic>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-c++98-c++11-compat-pedantic>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-switch-enum>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-float-equal>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated-declarations>\n+\n+ # Clang 10 also throws up warnings we need to investigate (ours)\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-old-style-cast>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-cast-align>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-sign-conversion>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-implicit-int-conversion>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-implicit-int-float-conversion>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-covered-switch-default>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-cast-qual>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-implicit-int-float-conversion>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-shift-sign-overflow>\n+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-format-nonliteral>\n+\n$<$<CXX_COMPILER_ID:Clang>:-Wdocumentation>)\n+\ntarget_link_options(astc${CODEC}-${ISA_SIMD}\nPRIVATE\n# Use pthreads on Linux/macOS\n@@ -111,9 +134,20 @@ set_property(TARGET astc${CODEC}-${ISA_SIMD} PROPERTY\nif(CMAKE_CXX_COMPILER_ID MATCHES \"GNU|Clang\")\n- string(CONCAT EXTERNAL_CXX_FLAGS \"-Wno-unused-parameter\"\n- \" -Wno-double-promotion\"\n- \" -fno-strict-aliasing\")\n+ string(CONCAT EXTERNAL_CXX_FLAGS\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -fno-strict-aliasing>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-unused-parameter>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-double-promotion>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-zero-as-null-pointer-constant>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-disabled-macro-expansion>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-reserved-id-macro>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-extra-semi-stmt>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-implicit-fallthrough>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-tautological-type-limit-compare>\"\n+ \" $<$<CXX_COMPILER_ID:Clang>: -Wno-missing-prototypes>\"\n+ )\n+\n+\nset_source_files_properties(astcenccli_image_external.cpp\nPROPERTIES COMPILE_FLAGS ${EXTERNAL_CXX_FLAGS})\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Initital support for clang++-10 and clang-cl
61,745
20.01.2021 20:52:25
0
52b48b2a0d4917447d290fe713f0a1a2a1b5dd03
Remove data table for angular steppings an stepsizes This replaces the angular_steppings table with a computationally generated one, where the steppings are evenly spaced 1-40. This isn't quite as effective, reducing quality by up to 0.05dB, but improves performance by 3-6%.
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -892,6 +892,17 @@ TEST(vfloat4, recip)\nEXPECT_NEAR(r.lane<3>(), 1.0f / 4.0f, 0.0005f);\n}\n+/** @brief Test vfloat4 reciprocal. */\n+TEST(vfloat4, fast_recip)\n+{\n+ vfloat4 a(1.0f, 2.0f, 3.0f, 4.0f);\n+ vfloat4 r = fast_recip(a);\n+ EXPECT_NEAR(r.lane<0>(), 1.0f / 1.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<1>(), 1.0f / 2.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<2>(), 1.0f / 3.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<3>(), 1.0f / 4.0f, 0.0005f);\n+}\n+\n/** @brief Test vfloat4 normalize. */\nTEST(vfloat4, normalize)\n{\n@@ -1907,6 +1918,37 @@ TEST(vfloat8, sqrt)\nEXPECT_EQ(r.lane<7>(), std::sqrt(4.0f));\n}\n+\n+/** @brief Test vfloat8 reciprocal. */\n+TEST(vfloat8, recip)\n+{\n+ vfloat8 a(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f);\n+ vfloat8 r = recip(a);\n+ EXPECT_NEAR(r.lane<0>(), 1.0f / 1.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<1>(), 1.0f / 2.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<2>(), 1.0f / 3.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<3>(), 1.0f / 4.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<4>(), 1.0f / 5.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<5>(), 1.0f / 6.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<6>(), 1.0f / 7.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<7>(), 1.0f / 8.0f, 0.0005f);\n+}\n+\n+/** @brief Test vfloat8 reciprocal. */\n+TEST(vfloat8, fast_recip)\n+{\n+ vfloat8 a(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f);\n+ vfloat8 r = fast_recip(a);\n+ EXPECT_NEAR(r.lane<0>(), 1.0f / 1.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<1>(), 1.0f / 2.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<2>(), 1.0f / 3.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<3>(), 1.0f / 4.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<4>(), 1.0f / 5.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<5>(), 1.0f / 6.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<6>(), 1.0f / 7.0f, 0.0005f);\n+ EXPECT_NEAR(r.lane<7>(), 1.0f / 8.0f, 0.0005f);\n+}\n+\n/** @brief Test vfloat8 select. */\nTEST(vfloat8, select)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_avx2_8.h", "new_path": "Source/astcenc_vecmathlib_avx2_8.h", "diff": "@@ -808,6 +808,26 @@ ASTCENC_SIMD_INLINE vfloat8 sqrt(vfloat8 a)\nreturn vfloat8(_mm256_sqrt_ps(a.m));\n}\n+/**\n+ * @brief Generate a reciprocal of a vector.\n+ */\n+ASTCENC_SIMD_INLINE vfloat8 recip(vfloat8 b)\n+{\n+ // Reciprocal with a single NR iteration\n+ __m256 t1 = _mm256_rcp_ps(b.m);\n+ __m256 t2 = _mm256_mul_ps(b.m, _mm256_mul_ps(t1, t1));\n+ return vfloat8(_mm256_sub_ps(_mm256_add_ps(t1, t1), t2));\n+}\n+\n+/**\n+ * @brief Generate an approximate reciprocal of a vector.\n+ */\n+ASTCENC_SIMD_INLINE vfloat8 fast_recip(vfloat8 b)\n+{\n+ // Reciprocal with a no NR iteration\n+ return vfloat8(_mm256_rcp_ps(b.m));\n+}\n+\n/**\n* @brief Return lanes from @c b if MSB of @c cond is set, else @c a.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -860,7 +860,7 @@ ASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\n}\n/**\n- * @brief Generate a reciprocal of a a vector.\n+ * @brief Generate a reciprocal of a vector.\n*/\nASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n{\n@@ -868,6 +868,15 @@ ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\nreturn 1.0f / b;\n}\n+/**\n+ * @brief Generate an approximate reciprocal of a vector.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat8 b)\n+{\n+ // TODO: Is there a faster approximation we can use here?\n+ return 1.0f / b;\n+}\n+\n/**\n* @brief Normalize a vector to unit length.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_1.h", "new_path": "Source/astcenc_vecmathlib_none_1.h", "diff": "@@ -497,6 +497,22 @@ ASTCENC_SIMD_INLINE vfloat1 operator/(vfloat1 a, vfloat1 b)\nreturn vfloat1(a.m / b.m);\n}\n+/**\n+ * @brief Overload: vector by scalar division.\n+ */\n+ASTCENC_SIMD_INLINE vfloat1 operator/(vfloat1 a, float b)\n+{\n+ return vfloat1(a.m / b);\n+}\n+\n+/**\n+ * @brief Overload: scalar by vector division.\n+ */\n+ASTCENC_SIMD_INLINE vfloat1 operator/(float a, vfloat1 b)\n+{\n+ return vfloat1(a / b.m);\n+}\n+\n/**\n* @brief Overload: vector by vector equality.\n*/\n@@ -653,6 +669,22 @@ ASTCENC_SIMD_INLINE float hadd_s(vfloat1 a)\nreturn a.m;\n}\n+/**\n+ * @brief Generate a reciprocal of a vector.\n+ */\n+ASTCENC_SIMD_INLINE vfloat1 recip(vfloat1 b)\n+{\n+ return 1.0f / b;\n+}\n+\n+/**\n+ * @brief Generate an approximate reciprocal of a vector.\n+ */\n+ASTCENC_SIMD_INLINE vfloat1 fast_recip(vfloat1 b)\n+{\n+ return 1.0f / b;\n+}\n+\n/**\n* @brief Return lanes from @c b if MSB of @c cond is set, else @c a.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_4.h", "new_path": "Source/astcenc_vecmathlib_none_4.h", "diff": "@@ -968,13 +968,21 @@ ASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\n}\n/**\n- * @brief Generate a reciprocal of a a vector.\n+ * @brief Generate a reciprocal of a vector.\n*/\nASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n{\nreturn 1.0f / b;\n}\n+/**\n+ * @brief Generate an approximate reciprocal of a vector.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)\n+{\n+ return 1.0f / b;\n+}\n+\n/**\n* @brief Normalize a vector to unit length.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -920,7 +920,7 @@ ASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\n}\n/**\n- * @brief Generate a reciprocal of a a vector.\n+ * @brief Generate a reciprocal of a vector.\n*/\nASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n{\n@@ -930,6 +930,15 @@ ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\nreturn vfloat4(_mm_sub_ps(_mm_add_ps(t1, t1), t2));\n}\n+/**\n+ * @brief Generate an approximate reciprocal of a vector.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)\n+{\n+ // Reciprocal with no NR iteration\n+ return vfloat4(_mm_rcp_ps(b.m));\n+}\n+\n/**\n* @brief Normalize a vector to unit length.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "#include <cassert>\n#include <cstring>\n-#if ASTCENC_SIMD_WIDTH <= 4\n- #define ANGULAR_STEPS 44\n-#elif ASTCENC_SIMD_WIDTH == 8\n- // AVX code path loops over these tables 8 elements at a time,\n- // so make sure to have their size a multiple of 8.\n- #define ANGULAR_STEPS 48\n-#else\n- #error Unknown SIMD width\n-#endif\n-static_assert((ANGULAR_STEPS % ASTCENC_SIMD_WIDTH) == 0, \"ANGULAR_STEPS should be multiple of ASTCENC_SIMD_WIDTH\");\n-\n-alignas(ASTCENC_VECALIGN) static const float angular_steppings[ANGULAR_STEPS] = {\n- 1.0f, 1.25f, 1.5f, 1.75f,\n-\n- 2.0f, 2.5f, 3.0f, 3.5f,\n- 4.0f, 4.5f, 5.0f, 5.5f,\n- 6.0f, 6.5f, 7.0f, 7.5f,\n-\n- 8.0f, 9.0f, 10.0f, 11.0f,\n- 12.0f, 13.0f, 14.0f, 15.0f,\n- 16.0f, 17.0f, 18.0f, 19.0f,\n- 20.0f, 21.0f, 22.0f, 23.0f,\n- 24.0f, 25.0f, 26.0f, 27.0f,\n- 28.0f, 29.0f, 30.0f, 31.0f,\n- 32.0f, 33.0f, 34.0f, 35.0f,\n-#if ANGULAR_STEPS >= 48\n- // This is \"redundant\" and only used in more-than-4-wide\n- // SIMD code paths, to make the steps table size\n- // be a multiple of SIMD width. Values are replicated\n- // from last entry so that AVX2 and SSE code paths\n- // return the same results.\n- 35.0f, 35.0f, 35.0f, 35.0f,\n-#endif\n-};\n-\n-alignas(ASTCENC_VECALIGN) static float stepsizes[ANGULAR_STEPS];\n-alignas(ASTCENC_VECALIGN) static float stepsizes_sqr[ANGULAR_STEPS];\n+#define ANGULAR_STEPS 40\n+static_assert((ANGULAR_STEPS % ASTCENC_SIMD_WIDTH) == 0,\n+ \"ANGULAR_STEPS must be multiple of ASTCENC_SIMD_WIDTH\");\nstatic int max_angular_steps_needed_for_quant_level[13];\n-// yes, the next-to-last entry is supposed to have the value 33. This because under\n-// ASTC, the 32-weight mode leaves a double-sized hole in the middle of the\n-// weight space, so we are better off matching 33 weights than 32.\n+// Yes, the next-to-last entry is supposed to have the value 33. This because\n+// the 32-weight mode leaves a double-sized hole in the middle of the weight\n+// space, so we are better off matching 33 weights than 32.\nstatic const int quantization_steps_for_level[13] = {\n2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 33, 36\n};\n@@ -110,17 +76,15 @@ void prepare_angular_tables()\nint max_angular_steps_needed_for_quant_steps[40];\nfor (int i = 0; i < ANGULAR_STEPS; i++)\n{\n- stepsizes[i] = 1.0f / angular_steppings[i];\n- stepsizes_sqr[i] = stepsizes[i] * stepsizes[i];\n+ float angle_step = (float)(i + 1);\nfor (int j = 0; j < SINCOS_STEPS; j++)\n{\n- sin_table[j][i] = static_cast<float>(sinf((2.0f * astc::PI / (SINCOS_STEPS - 1.0f)) * angular_steppings[i] * j));\n- cos_table[j][i] = static_cast<float>(cosf((2.0f * astc::PI / (SINCOS_STEPS - 1.0f)) * angular_steppings[i] * j));\n+ sin_table[j][i] = static_cast<float>(sinf((2.0f * astc::PI / (SINCOS_STEPS - 1.0f)) * angle_step * j));\n+ cos_table[j][i] = static_cast<float>(cosf((2.0f * astc::PI / (SINCOS_STEPS - 1.0f)) * angle_step * j));\n}\n- int p = astc::flt2int_rd(angular_steppings[i]) + 1;\n- max_angular_steps_needed_for_quant_steps[p] = astc::min(i + 1, ANGULAR_STEPS - 1);\n+ max_angular_steps_needed_for_quant_steps[i + 1] = astc::min(i + 1, ANGULAR_STEPS - 1);\n}\nfor (int i = 0; i < 13; i++)\n@@ -139,15 +103,11 @@ static void compute_angular_offsets(\nint max_angular_steps,\nfloat* offsets\n) {\n- alignas(ASTCENC_VECALIGN) float anglesum_x[ANGULAR_STEPS];\n- alignas(ASTCENC_VECALIGN) float anglesum_y[ANGULAR_STEPS];\n- std::memset(anglesum_x, 0, max_angular_steps*sizeof(anglesum_x[0]));\n- std::memset(anglesum_y, 0, max_angular_steps*sizeof(anglesum_y[0]));\n-\n- promise(samplecount > 0);\n- promise(max_angular_steps > 0);\n+ alignas(ASTCENC_VECALIGN) float anglesum_x[ANGULAR_STEPS] { 0 };\n+ alignas(ASTCENC_VECALIGN) float anglesum_y[ANGULAR_STEPS] { 0 };\n// compute the angle-sums.\n+ promise(samplecount > 0);\nfor (int i = 0; i < samplecount; i++)\n{\nfloat sample = samples[i];\n@@ -160,6 +120,7 @@ static void compute_angular_offsets(\nconst float *cosptr = cos_table[isample];\nvfloat sample_weightv(sample_weight);\n+ promise(max_angular_steps > 0);\nfor (int j = 0; j < max_angular_steps; j += ASTCENC_SIMD_WIDTH) // arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\n{\nvfloat cp = loada(&cosptr[j]);\n@@ -173,10 +134,13 @@ static void compute_angular_offsets(\n// post-process the angle-sums\nvfloat mult = vfloat(1.0f / (2.0f * astc::PI));\n+ vfloat rcp_stepsize = vfloat::lane_id() + vfloat(1.0f);\nfor (int i = 0; i < max_angular_steps; i += ASTCENC_SIMD_WIDTH) // arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\n{\n+ vfloat ssize = fast_recip(rcp_stepsize);\n+ rcp_stepsize = rcp_stepsize + vfloat(ASTCENC_SIMD_WIDTH);\nvfloat angle = atan2(loada(&anglesum_y[i]), loada(&anglesum_x[i]));\n- vfloat ofs = angle * (loada(&stepsizes[i]) * mult);\n+ vfloat ofs = angle * ssize * mult;\nstorea(ofs, &offsets[i]);\n}\n}\n@@ -184,7 +148,6 @@ static void compute_angular_offsets(\n// for a given step-size and a given offset, compute the\n// lowest and highest weight that results from quantizing using the stepsize & offset.\n// also, compute the resulting error.\n-\nstatic void compute_lowest_and_highest_weight(\nint samplecount,\nconst float *samples,\n@@ -201,6 +164,8 @@ static void compute_lowest_and_highest_weight(\npromise(samplecount > 0);\npromise(max_angular_steps > 0);\n+ vfloat rcp_stepsize = vfloat::lane_id() + vfloat(1.0f);\n+\n// Arrays are always multiple of SIMD width (ANGULAR_STEPS), so this is safe even if overshoot max\nfor (int sp = 0; sp < max_angular_steps; sp += ASTCENC_SIMD_WIDTH)\n{\n@@ -209,7 +174,6 @@ static void compute_lowest_and_highest_weight(\nvfloat errval = vfloat::zero();\nvfloat cut_low_weight_err = vfloat::zero();\nvfloat cut_high_weight_err = vfloat::zero();\n- vfloat rcp_stepsize = loada(&angular_steppings[sp]);\nvfloat offset = loada(&offsets[sp]);\nvfloat scaled_offset = rcp_stepsize * offset;\nfor (int j = 0; j < samplecount; ++j)\n@@ -254,10 +218,13 @@ static void compute_lowest_and_highest_weight(\n// The cut_(lowest/highest)_weight_error indicate the error that\n// results from forcing samples that should have had the weight value\n// one step (up/down).\n- vfloat errscale = loada(&stepsizes_sqr[sp]);\n+ vfloat ssize = fast_recip(rcp_stepsize);\n+ vfloat errscale = ssize * ssize;\nstorea(errval * errscale, &error[sp]);\nstorea(cut_low_weight_err * errscale, &cut_low_weight_error[sp]);\nstorea(cut_high_weight_err * errscale, &cut_high_weight_error[sp]);\n+\n+ rcp_stepsize = rcp_stepsize + vfloat(ASTCENC_SIMD_WIDTH);\n}\n}\n@@ -363,7 +330,7 @@ static void compute_angular_endpoints_for_quantization_levels(\nbsi = 0;\n}\n- float stepsize = stepsizes[bsi];\n+ float stepsize = 1.0f / (1.0f + (float)bsi);\nint lwi = lowest_weight[bsi] + cut_low_weight[q];\nint hwi = lwi + q - 1;\nfloat offset = angular_offsets[bsi];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove data table for angular steppings an stepsizes This replaces the angular_steppings table with a computationally generated one, where the steppings are evenly spaced 1-40. This isn't quite as effective, reducing quality by up to 0.05dB, but improves performance by 3-6%.
61,745
20.01.2021 22:21:58
0
86910deffbec56856e5091a3f81866decd313816
Fix loss-of-const warnings flagged by clang-cl
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -845,7 +845,7 @@ astcenc_error astcenc_decompress_image(\n{\nunsigned int offset = (((z * yblocks + y) * xblocks) + x) * 16;\nconst uint8_t* bp = data + offset;\n- physical_compressed_block pcb = *(physical_compressed_block *) bp;\n+ physical_compressed_block pcb = *(const physical_compressed_block*)bp;\nsymbolic_compressed_block scb;\nphysical_to_symbolic(*context->bsd, pcb, scb);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "@@ -222,7 +222,7 @@ static void copy_scanline(\n#define COPY_R(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n- srctype *s = (srctype *)src; \\\n+ const srctype* s = (const srctype*)src; \\\ndsttype* d = (dsttype*)dst; \\\nfor (int i = 0; i < pixels; i++)\\\n{\\\n@@ -236,7 +236,7 @@ static void copy_scanline(\n#define COPY_RG(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n- srctype *s = (srctype *)src; \\\n+ const srctype* s = (const srctype*)src; \\\ndsttype* d = (dsttype*)dst; \\\nfor (int i = 0; i < pixels; i++)\\\n{\\\n@@ -250,7 +250,7 @@ static void copy_scanline(\n#define COPY_RGB(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n- srctype *s = (srctype *)src; \\\n+ const srctype* s = (const srctype*)src; \\\ndsttype* d = (dsttype*)dst; \\\nfor (int i = 0; i < pixels; i++)\\\n{\\\n@@ -264,7 +264,7 @@ static void copy_scanline(\n#define COPY_BGR(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n- srctype *s = (srctype *)src; \\\n+ const srctype* s = (const srctype*)src; \\\ndsttype* d = (dsttype*)dst; \\\nfor (int i = 0; i < pixels; i++)\\\n{\\\n@@ -278,7 +278,7 @@ static void copy_scanline(\n#define COPY_RGBX(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n- srctype *s = (srctype *)src; \\\n+ const srctype* s = (const srctype*)src; \\\ndsttype* d = (dsttype*)dst; \\\nfor (int i = 0; i < pixels; i++)\\\n{\\\n@@ -292,7 +292,7 @@ static void copy_scanline(\n#define COPY_BGRX(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n- srctype *s = (srctype *)src; \\\n+ const srctype* s = (const srctype*)src; \\\ndsttype* d = (dsttype*)dst; \\\nfor (int i = 0; i < pixels; i++)\\\n{\\\n@@ -306,7 +306,7 @@ static void copy_scanline(\n#define COPY_RGBA(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n- srctype *s = (srctype *)src; \\\n+ const srctype* s = (const srctype*)src; \\\ndsttype* d = (dsttype*)dst; \\\nfor (int i = 0; i < pixels; i++)\\\n{\\\n@@ -320,7 +320,7 @@ static void copy_scanline(\n#define COPY_BGRA(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n- srctype *s = (srctype *)src; \\\n+ const srctype* s = (const srctype*)src; \\\ndsttype* d = (dsttype*)dst; \\\nfor (int i = 0; i < pixels; i++)\\\n{\\\n@@ -334,7 +334,7 @@ static void copy_scanline(\n#define COPY_L(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n- srctype *s = (srctype *)src; \\\n+ const srctype* s = (const srctype*)src; \\\ndsttype* d = (dsttype*)dst; \\\nfor (int i = 0; i < pixels; i++)\\\n{\\\n@@ -348,7 +348,7 @@ static void copy_scanline(\n#define COPY_LA(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n- srctype *s = (srctype *)src; \\\n+ const srctype* s = (const srctype*)src; \\\ndsttype* d = (dsttype*)dst; \\\nfor (int i = 0; i < pixels; i++)\\\n{\\\n" }, { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "@@ -109,9 +109,7 @@ target_compile_options(astc${CODEC}-${ISA_SIMD}\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-cast-align>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-sign-conversion>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-implicit-int-conversion>\n- $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-implicit-int-float-conversion>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-covered-switch-default>\n- $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-cast-qual>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-implicit-int-float-conversion>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-shift-sign-overflow>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-format-nonliteral>\n@@ -144,6 +142,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES \"GNU|Clang\")\n\" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-extra-semi-stmt>\"\n\" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-implicit-fallthrough>\"\n\" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-tautological-type-limit-compare>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-cast-qual>\"\n\" $<$<CXX_COMPILER_ID:Clang>: -Wno-missing-prototypes>\"\n)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix loss-of-const warnings flagged by clang-cl
61,745
20.01.2021 22:29:01
0
9b08ca1bcd4ba2ebad10b1ece2ac1234e21bd1fa
Cleanly handle covered-defaults for enum switches
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -76,7 +76,9 @@ static astcenc_error validate_cpu_isa()\nstatic astcenc_error validate_profile(\nastcenc_profile profile\n) {\n- switch(profile)\n+ // Values in this enum are from an external user, so not guaranteed to be\n+ // bounded to the enum values\n+ switch(static_cast<int>(profile))\n{\ncase ASTCENC_PRF_LDR_SRGB:\ncase ASTCENC_PRF_LDR:\n@@ -158,7 +160,9 @@ static astcenc_error validate_compression_swizzle(\nstatic astcenc_error validate_decompression_swz(\nastcenc_swz swizzle\n) {\n- switch(swizzle)\n+ // Values in this enum are from an external user, so not guaranteed to be\n+ // bounded to the enum values\n+ switch(static_cast<int>(swizzle))\n{\ncase ASTCENC_SWZ_R:\ncase ASTCENC_SWZ_G:\n@@ -315,7 +319,9 @@ astcenc_error astcenc_config_init(\n// base db_limit, so we may actually use lower ratios for the more through\n// search presets because the underlying db_limit is so much higher.\n- switch(preset)\n+ // Values in this enum are from an external user, so not guaranteed to be\n+ // bounded to the enum values\n+ switch(static_cast<int>(preset))\n{\ncase ASTCENC_PRE_FASTEST:\nconfig.tune_partition_limit = 2;\n@@ -408,7 +414,10 @@ astcenc_error astcenc_config_init(\nconfig.b_deblock_weight = 0.0f;\nconfig.profile = profile;\n- switch(profile)\n+\n+ // Values in this enum are from an external user, so not guaranteed to be\n+ // bounded to the enum values\n+ switch(static_cast<int>(profile))\n{\ncase ASTCENC_PRF_LDR:\ncase ASTCENC_PRF_LDR_SRGB:\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_integer_sequence.cpp", "new_path": "Source/astcenc_integer_sequence.cpp", "diff": "@@ -630,7 +630,9 @@ int compute_ise_bitcount(\nint items,\nquantization_method quant\n) {\n- switch (quant)\n+ // Values in this enum are from an external data source, so not guaranteed\n+ // to be bounded to the enum values for invalid block encodings\n+ switch (static_cast<int>(quant))\n{\ncase QUANT_2:\nreturn items;\n" }, { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "@@ -109,7 +109,6 @@ target_compile_options(astc${CODEC}-${ISA_SIMD}\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-cast-align>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-sign-conversion>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-implicit-int-conversion>\n- $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-covered-switch-default>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-implicit-int-float-conversion>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-shift-sign-overflow>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-format-nonliteral>\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleanly handle covered-defaults for enum switches
61,745
20.01.2021 22:32:44
0
f7d38ca5d74c8f91408a4d81b4d1a1bb38fc4c38
Cleanly handle -Wswitch-enum
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -128,7 +128,8 @@ static astcenc_error validate_flags(\nstatic astcenc_error validate_compression_swz(\nastcenc_swz swizzle\n) {\n- switch(swizzle)\n+ // Not all enum values are handled; SWZ_Z is invalid for compression\n+ switch(static_cast<int>(swizzle))\n{\ncase ASTCENC_SWZ_R:\ncase ASTCENC_SWZ_G:\n@@ -875,8 +876,12 @@ astcenc_error astcenc_decompress_image(\nconst char* astcenc_get_error_string(\nastcenc_error status\n) {\n- switch(status)\n+ // Values in this enum are from an external user, so not guaranteed to be\n+ // bounded to the enum values\n+ switch(static_cast<int>(status))\n{\n+ case ASTCENC_SUCCESS:\n+ return \"ASTCENC_SUCCESS\";\ncase ASTCENC_ERR_OUT_OF_MEM:\nreturn \"ASTCENC_ERR_OUT_OF_MEM\";\ncase ASTCENC_ERR_BAD_CPU_FLOAT:\n" }, { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "@@ -100,7 +100,6 @@ target_compile_options(astc${CODEC}-${ISA_SIMD}\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-unknown-warning-option>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-c++98-compat-pedantic>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-c++98-c++11-compat-pedantic>\n- $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-switch-enum>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-float-equal>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated-declarations>\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleanly handle -Wswitch-enum
61,745
20.01.2021 22:48:26
0
b1b487f0a31e5d937d0bb72357c2b8c1633b1a3a
Use explicit int-to-float casts to guide optimization
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -980,7 +980,7 @@ static void quantize_hdr_rgbo3(\nquantize_and_unquantize_retain_top_two_bits(quantization_level, r_lowbits, &r_quantval, &r_uquantval);\nr_intval = (r_intval & ~0x3f) | (r_uquantval & 0x3f);\n- float r_fval = r_intval * mode_rscale;\n+ float r_fval = static_cast<float>(r_intval) * mode_rscale;\n// next, recompute G and B, then quantize and unquantize them.\nfloat g_fval = r_fval - color.g;\n@@ -1085,8 +1085,8 @@ static void quantize_hdr_rgbo3(\ng_intval = (g_intval & ~0x1f) | (g_uquantval & 0x1f);\nb_intval = (b_intval & ~0x1f) | (b_uquantval & 0x1f);\n- g_fval = g_intval * mode_rscale;\n- b_fval = b_intval * mode_rscale;\n+ g_fval = static_cast<float>(g_intval) * mode_rscale;\n+ b_fval = static_cast<float>(b_intval) * mode_rscale;\n// finally, recompute the scale value, based on the errors\n// introduced to red, green and blue.\n@@ -1173,7 +1173,7 @@ static void quantize_hdr_rgbo3(\n{\nvals[i] = astc::clamp(vals[i], 0.0f, 65020.0f);\nivals[i] = astc::flt2int_rtn(vals[i] * (1.0f / 512.0f));\n- cvals[i] = ivals[i] * 512.0f;\n+ cvals[i] = static_cast<float>(ivals[i]) * 512.0f;\n}\nfloat rgb_errorsum = (cvals[0] - vals[0]) + (cvals[1] - vals[1]) + (cvals[2] - vals[2]);\n@@ -1329,7 +1329,7 @@ static void quantize_hdr_rgb3(\nint a_quantval = color_quantization_tables[quantization_level][a_lowbits];\nint a_uquantval = color_unquantization_tables[quantization_level][a_quantval];\na_intval = (a_intval & ~0xFF) | a_uquantval;\n- float a_fval = a_intval * mode_rscale;\n+ float a_fval = static_cast<float>(a_intval) * mode_rscale;\n// next, recompute C, then quantize and unquantize it\nfloat c_fval = a_fval - color0.r;\n@@ -1351,7 +1351,7 @@ static void quantize_hdr_rgb3(\nint c_uquantval;\nquantize_and_unquantize_retain_top_two_bits(quantization_level, c_lowbits, &c_quantval, &c_uquantval);\nc_intval = (c_intval & ~0x3F) | (c_uquantval & 0x3F);\n- c_fval = c_intval * mode_rscale;\n+ c_fval = static_cast<float>(c_intval) * mode_rscale;\n// next, recompute B0 and B1, then quantize and unquantize them\nfloat b0_fval = a_fval - color1.g;\n@@ -1423,8 +1423,8 @@ static void quantize_hdr_rgb3(\nb0_intval = (b0_intval & ~0x3f) | (b0_uquantval & 0x3f);\nb1_intval = (b1_intval & ~0x3f) | (b1_uquantval & 0x3f);\n- b0_fval = b0_intval * mode_rscale;\n- b1_fval = b1_intval * mode_rscale;\n+ b0_fval = static_cast<float>(b0_intval) * mode_rscale;\n+ b1_fval = static_cast<float>(b1_intval) * mode_rscale;\n// finally, recompute D0 and D1, then quantize and unquantize them\nfloat d0_fval = a_fval - b0_fval - c_fval - color0.g;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -153,17 +153,17 @@ static int realign_weights(\nconst float *texel_weights_float = it->texel_weights_float_texel[we_idx][te_idx];\nfloat twf0 = texel_weights_float[0];\nfloat weight_base =\n- ((uqw * twf0\n- + uq_pl_weights[texel_weights[1]] * texel_weights_float[1])\n- + (uq_pl_weights[texel_weights[2]] * texel_weights_float[2]\n- + uq_pl_weights[texel_weights[3]] * texel_weights_float[3]));\n+ ((static_cast<float>(uqw) * twf0\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]));\nint partition = pt->partition_of_texel[texel];\nweight_base = weight_base + 0.5f;\nfloat plane_weight = astc::flt_rd(weight_base);\n- float plane_up_weight = astc::flt_rd(weight_base + uqw_next_dif * twf0) - plane_weight;\n- float plane_down_weight = astc::flt_rd(weight_base + uqw_prev_dif * twf0) - plane_weight;\n+ float plane_up_weight = astc::flt_rd(weight_base + static_cast<float>(uqw_next_dif) * twf0) - plane_weight;\n+ float plane_down_weight = astc::flt_rd(weight_base + static_cast<float>(uqw_prev_dif) * twf0) - plane_weight;\nfloat4 color_offset = offset[partition];\nfloat4 color_base = endpnt0f[partition];\n@@ -514,7 +514,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n// heuristic to skip blocks that are unlikely to catch up with\n// the best block we have already.\nint iters_remaining = max_refinement_iters - l;\n- float threshold = (0.05f * iters_remaining) + 1.1f;\n+ float threshold = (0.05f * static_cast<float>(iters_remaining)) + 1.1f;\nif (errorval > (threshold * best_errorval_in_scb))\n{\nbreak;\n@@ -552,7 +552,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n// blocks that are unlikely to catch up with the best block we\n// have already. Assume a 5% per step to give benefit of the doubt\nint iters_remaining = max_refinement_iters - 1 - l;\n- float threshold = (0.05f * iters_remaining) + 1.0f;\n+ float threshold = (0.05f * static_cast<float>(iters_remaining)) + 1.0f;\nif (errorval > (threshold * best_errorval_in_scb))\n{\nbreak;\n@@ -965,7 +965,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n// heuristic to skip blocks that are unlikely to catch up with\n// the best block we have already.\nint iters_remaining = max_refinement_iters - l;\n- float threshold = (0.05f * iters_remaining) + 1.1f;\n+ float threshold = (0.05f * static_cast<float>(iters_remaining)) + 1.1f;\nif (errorval > (threshold * best_errorval_in_scb))\n{\nbreak;\n@@ -1004,7 +1004,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n// blocks that are unlikely to catch up with the best block we\n// have already. Assume a 5% per step to give benefit of the doubt\nint iters_remaining = max_refinement_iters - 1 - l;\n- float threshold = (0.05f * iters_remaining) + 1.0f;\n+ float threshold = (0.05f * static_cast<float>(iters_remaining)) + 1.0f;\nif (errorval > (threshold * best_errorval_in_scb))\n{\nbreak;\n@@ -1039,9 +1039,9 @@ void expand_deblock_weights(\nunsigned int ydim = ctx.config.block_y;\nunsigned int zdim = ctx.config.block_z;\n- float centerpos_x = (xdim - 1) * 0.5f;\n- float centerpos_y = (ydim - 1) * 0.5f;\n- float centerpos_z = (zdim - 1) * 0.5f;\n+ float centerpos_x = static_cast<float>(xdim - 1) * 0.5f;\n+ float centerpos_y = static_cast<float>(ydim - 1) * 0.5f;\n+ float centerpos_z = static_cast<float>(zdim - 1) * 0.5f;\nfloat *bef = ctx.deblock_weights;\nfor (unsigned int z = 0; z < zdim; z++)\n@@ -1050,9 +1050,9 @@ void expand_deblock_weights(\n{\nfor (unsigned int x = 0; x < xdim; x++)\n{\n- float xdif = (x - centerpos_x) / xdim;\n- float ydif = (y - centerpos_y) / ydim;\n- float zdif = (z - centerpos_z) / zdim;\n+ float xdif = (static_cast<float>(x) - centerpos_x) / static_cast<float>(xdim);\n+ float ydif = (static_cast<float>(y) - centerpos_y) / static_cast<float>(ydim);\n+ float zdif = (static_cast<float>(z) - centerpos_z) / static_cast<float>(zdim);\nfloat wdif = 0.36f;\nfloat dist = astc::sqrt(xdif * xdif + ydif * ydif + zdif * zdif + wdif * wdif);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -559,7 +559,8 @@ astcenc_error astcenc_context_alloc(\nbsd = new block_size_descriptor;\nbool can_omit_modes = config.flags & ASTCENC_FLG_SELF_DECOMPRESS_ONLY;\n- init_block_size_descriptor(config.block_x, config.block_y, config.block_z, can_omit_modes, config.tune_block_mode_limit / 100.0f, bsd);\n+ init_block_size_descriptor(config.block_x, config.block_y, config.block_z,\n+ can_omit_modes, static_cast<float>(config.tune_block_mode_limit) / 100.0f, bsd);\nctx->bsd = bsd;\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -347,10 +347,10 @@ void fetch_imageblock(\na = data[swz.a];\n}\n- pb->data_r[idx] = r / 255.0f;\n- pb->data_g[idx] = g / 255.0f;\n- pb->data_b[idx] = b / 255.0f;\n- pb->data_a[idx] = a / 255.0f;\n+ pb->data_r[idx] = static_cast<float>(r) / 255.0f;\n+ pb->data_g[idx] = static_cast<float>(g) / 255.0f;\n+ pb->data_b[idx] = static_cast<float>(b) / 255.0f;\n+ pb->data_a[idx] = static_cast<float>(a) / 255.0f;\nidx++;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_kmeans_partitioning.cpp", "new_path": "Source/astcenc_kmeans_partitioning.cpp", "diff": "@@ -258,7 +258,7 @@ static void basic_kmeans_update(\nfor (int i = 0; i < partition_count; i++)\n{\n- cluster_centers[i] = color_sum[i] * (1.0f / weight_sum[i]);\n+ cluster_centers[i] = color_sum[i] * (1.0f / static_cast<float>(weight_sum[i]));\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": "@@ -117,8 +117,10 @@ static void compute_color_error_for_every_integer_count_and_quantization_level(\n(ep0_range_error_high * ep0_range_error_high) +\n(ep1_range_error_high * ep1_range_error_high);\nfloat rgb_range_error = dot(float3(sum_range_error.r, sum_range_error.g, sum_range_error.b),\n- float3(error_weight.r, error_weight.g, error_weight.b)) * 0.5f * partition_size;\n- float alpha_range_error = sum_range_error.a * error_weight.a * 0.5f * partition_size;\n+ float3(error_weight.r, error_weight.g, error_weight.b))\n+ * 0.5f * static_cast<float>(partition_size);\n+ float alpha_range_error = sum_range_error.a * error_weight.a\n+ * 0.5f * static_cast<float>(partition_size);\nif (encode_hdr_rgb)\n{\n@@ -268,7 +270,7 @@ static void compute_color_error_for_every_integer_count_and_quantization_level(\n// base_quant_error should depend on the scale-factor that would be used\n// during actual encode of the color value.\n- float base_quant_error = baseline_quant_error[i] * partition_size * 1.0f;\n+ float base_quant_error = baseline_quant_error[i] * static_cast<float>(partition_size);\nfloat rgb_quantization_error = error_weight_rgbsum * base_quant_error * 2.0f;\nfloat alpha_quantization_error = error_weight.a * base_quant_error * 2.0f;\nfloat rgba_quantization_error = rgb_quantization_error + alpha_quantization_error;\n@@ -315,7 +317,7 @@ static void compute_color_error_for_every_integer_count_and_quantization_level(\n// pick among the available LDR endpoint modes\nfor (int i = 4; i < 21; i++)\n{\n- float base_quant_error = baseline_quant_error[i] * partition_size * 1.0f;\n+ float base_quant_error = baseline_quant_error[i] * static_cast<float>(partition_size);\nfloat rgb_quantization_error = error_weight_rgbsum * base_quant_error;\nfloat alpha_quantization_error = error_weight.a * base_quant_error;\nfloat rgba_quantization_error = rgb_quantization_error + alpha_quantization_error;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -80,8 +80,8 @@ void prepare_angular_tables()\nfor (int j = 0; j < SINCOS_STEPS; j++)\n{\n- sin_table[j][i] = static_cast<float>(sinf((2.0f * astc::PI / (SINCOS_STEPS - 1.0f)) * angle_step * j));\n- cos_table[j][i] = static_cast<float>(cosf((2.0f * astc::PI / (SINCOS_STEPS - 1.0f)) * angle_step * j));\n+ sin_table[j][i] = static_cast<float>(sinf((2.0f * astc::PI / (SINCOS_STEPS - 1.0f)) * angle_step * static_cast<float>(j)));\n+ cos_table[j][i] = static_cast<float>(cosf((2.0f * astc::PI / (SINCOS_STEPS - 1.0f)) * angle_step * static_cast<float>(j)));\n}\nmax_angular_steps_needed_for_quant_steps[i + 1] = astc::min(i + 1, ANGULAR_STEPS - 1);\n@@ -335,8 +335,8 @@ static void compute_angular_endpoints_for_quantization_levels(\nint hwi = lwi + q - 1;\nfloat offset = angular_offsets[bsi];\n- low_value[i] = offset + lwi * stepsize;\n- high_value[i] = offset + hwi * stepsize;\n+ low_value[i] = offset + static_cast<float>(lwi) * stepsize;\n+ high_value[i] = offset + static_cast<float>(hwi) * stepsize;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "@@ -108,7 +108,6 @@ target_compile_options(astc${CODEC}-${ISA_SIMD}\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-cast-align>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-sign-conversion>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-implicit-int-conversion>\n- $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-implicit-int-float-conversion>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-shift-sign-overflow>\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-format-nonliteral>\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use explicit int-to-float casts to guide optimization
61,745
20.01.2021 23:37:48
0
bdd9ca500b6eea3e1d31f04695a5923693227b79
Fix NEON fast_recip typo
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -871,7 +871,7 @@ ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n/**\n* @brief Generate an approximate reciprocal of a vector.\n*/\n-ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat8 b)\n+ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)\n{\n// TODO: Is there a faster approximation we can use here?\nreturn 1.0f / b;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix NEON fast_recip typo
61,745
20.01.2021 23:46:15
0
3b9672d195005b69c40356ca8265aa4784e6d498
Add NEON fast_recip
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -864,7 +864,6 @@ ASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n{\n- // TODO: Is there a faster approximation we can use here?\nreturn 1.0f / b;\n}\n@@ -873,8 +872,7 @@ ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)\n{\n- // TODO: Is there a faster approximation we can use here?\n- return 1.0f / b;\n+ return vfloat4(vrecpeq_f32(b.m));\n}\n/**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add NEON fast_recip
61,745
22.01.2021 22:17:10
0
0c93ff6604986155133c26f9627f76abe961f5c7
Turn quality into an easily tunable parameter
[ { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "@@ -6,6 +6,36 @@ release of the 2.x series.\nAll performance data on this page is measured on an Intel Core i5-9600K\nclocked at 4.2 GHz, running astcenc using 6 threads.\n+\n+<!-- ---------------------------------------------------------------------- -->\n+## 2.3\n+\n+**Status:** In development\n+\n+The 2.3 release is the fourth release in the 2.x series. It includes a number\n+of performance improvements and new features.\n+\n+Reminder for users of the library interface - the API is not designed to be\n+stable across versions, and this release is not compatible with 2.2. Please\n+recompile your client-side code using the updated `astcenc.h` header.\n+\n+* **Command Line:**\n+ * **Feature:** Quality level now accepts either a preset (`-fast`, etc) or a\n+ float value between 0 and 100, allowing more control over the compression\n+ quality vs performance trade-off. The presets are not evenly spaced in the\n+ float range; they have been spaced to give the best distribution of points\n+ between the fast and through presets.\n+\n+ * `-fastest`: 0.0\n+ * `-fast`: 10.0\n+ * `-medium`: 60.0\n+ * `-thorough`: 98.0\n+ * `-exhaustive`: 100.0\n+\n+* **Core API:**\n+ * **API Change:** Quality level preset enum replaced with a float value\n+ between 0 (`-fastest`) and 100 (`-exhaustive`). See above for more info.\n+\n<!-- ---------------------------------------------------------------------- -->\n## 2.2\n@@ -27,7 +57,7 @@ recompile your client-side code using the updated `astcenc.h` header.\n* **Improvement:** Linux binaries changed to use Clang 9.0, which gives\nup to 15% performance improvement.\n* **Improvement:** Windows binaries are now code signed.\n- * **Improvement:** macOS binaries for Apple Silicon platforms now provided.\n+ * **Improvement:** macOS binaries for Apple silicon platforms now provided.\n* **Improvement:** macOS binaries are now code signed and notarized.\n* **Command Line:**\n* **Feature:** New image preprocess `-pp-normalize` option added. This forces\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "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@@ -171,8 +171,8 @@ enum astcenc_error {\nASTCENC_ERR_BAD_BLOCK_SIZE,\n/** @brief The call failed due to an out-of-spec color profile. */\nASTCENC_ERR_BAD_PROFILE,\n- /** @brief The call failed due to an out-of-spec quality preset. */\n- ASTCENC_ERR_BAD_PRESET,\n+ /** @brief The call failed due to an out-of-spec quality value. */\n+ ASTCENC_ERR_BAD_QUALITY,\n/** @brief The call failed due to an out-of-spec channel swizzle. */\nASTCENC_ERR_BAD_SWIZZLE,\n/** @brief The call failed due to an out-of-spec flag set. */\n@@ -201,21 +201,20 @@ enum astcenc_profile {\nASTCENC_PRF_HDR\n};\n-/**\n- * @brief A codec quality preset.\n- */\n-enum astcenc_preset {\n/** @brief The fastest, lowest quality, search preset. */\n- ASTCENC_PRE_FASTEST = 0,\n+static const float ASTCENC_PRE_FASTEST = 0.0f;\n+\n/** @brief The fast search preset. */\n- ASTCENC_PRE_FAST,\n+static const float ASTCENC_PRE_FAST = 10.0f;\n+\n/** @brief The medium quality search preset. */\n- ASTCENC_PRE_MEDIUM,\n+static const float ASTCENC_PRE_MEDIUM = 60.0f;\n+\n/** @brief The throrough quality search preset. */\n- ASTCENC_PRE_THOROUGH,\n+static const float ASTCENC_PRE_THOROUGH = 98.0f;\n+\n/** @brief The exhaustive, highest quality, search preset. */\n- ASTCENC_PRE_EXHAUSTIVE\n-};\n+static const float ASTCENC_PRE_EXHAUSTIVE = 100.0f;\n/**\n* @brief A codec channel swizzle selector.\n@@ -532,7 +531,10 @@ struct astcenc_image {\n* @param block_x ASTC block size X dimension.\n* @param block_y ASTC block size Y dimension.\n* @param block_z ASTC block size Z dimension.\n- * @param preset Search quality preset.\n+ * @param quality Search quality preset / effort level. Either an\n+ * @c ASTCENC_PRE_* value, or a effort level between 0\n+ * and 100. Performance is not linear between 0 and 100.\n+\n* @param flags A valid set of ASTCENC_FLG_* flag bits.\n* @param[out] config Output config struct to populate.\n*\n@@ -544,7 +546,7 @@ astcenc_error astcenc_config_init(\nunsigned int block_x,\nunsigned int block_y,\nunsigned int block_z,\n- astcenc_preset preset,\n+ float quality,\nunsigned int flags,\nastcenc_config& config);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "* @brief Functions for the library entrypoint.\n*/\n+#include <array>\n#include <cstring>\n#include <new>\n@@ -73,6 +74,52 @@ static astcenc_error validate_cpu_isa()\nreturn ASTCENC_SUCCESS;\n}\n+/**\n+ * @brief Record of the quality tuning parameter values.\n+ *\n+ * See the @c astcenc_config structure for detailed parameter documentation.\n+ *\n+ * Note that the mse_overshoot entries are scaling factors relative to the\n+ * base MSE to hit db_limit. A 20% overshoot is harder to hit for a higher\n+ * base db_limit, so we may actually use lower ratios for the more through\n+ * search presets because the underlying db_limit is so much higher.\n+ */\n+struct astcenc_preset_config {\n+ float quality;\n+ unsigned int tune_partition_limit;\n+ unsigned int tune_block_mode_limit;\n+ unsigned int tune_refinement_limit;\n+ unsigned int tune_candidate_limit;\n+ float tune_db_limit_a_base;\n+ float tune_db_limit_b_base;\n+ float tune_mode0_mse_overshoot;\n+ float tune_refinement_mse_overshoot;\n+ float tune_partition_early_out_limit;\n+ float tune_two_plane_early_out_limit;\n+};\n+\n+/**\n+ * @brief The static quality presets that are built-in.\n+ */\n+static const std::array<astcenc_preset_config, 5> preset_configs {{\n+ {\n+ ASTCENC_PRE_FASTEST,\n+ 2, 25, 1, 1, 75, 53, 1.0f, 1.0f, 1.0f, 0.5f\n+ }, {\n+ ASTCENC_PRE_FAST,\n+ 4, 50, 1, 2, 85, 63, 2.5f, 2.5f, 1.0f, 0.5f\n+ }, {\n+ ASTCENC_PRE_MEDIUM,\n+ 25, 75, 2, 2, 95, 70, 1.75f, 1.75f, 1.2f, 0.75f\n+ }, {\n+ ASTCENC_PRE_THOROUGH,\n+ 100, 95, 4, 3, 105, 77, 10.0f, 10.0f, 2.5f, 0.95f\n+ }, {\n+ ASTCENC_PRE_EXHAUSTIVE,\n+ 1024, 100, 4, 4, 200, 200, 10.0f, 10.0f, 10.0f, 0.99f\n+ }\n+}};\n+\nstatic astcenc_error validate_profile(\nastcenc_profile profile\n) {\n@@ -287,7 +334,7 @@ astcenc_error astcenc_config_init(\nunsigned int block_x,\nunsigned int block_y,\nunsigned int block_z,\n- astcenc_preset preset,\n+ float quality,\nunsigned int flags,\nastcenc_config& config\n) {\n@@ -311,94 +358,84 @@ astcenc_error astcenc_config_init(\nfloat texels = static_cast<float>(block_x * block_y * block_z);\nfloat ltexels = logf(texels) / logf(10.0f);\n- // Process the performance preset; note that this must be done before we\n- // process any additional settings, such as color profile and flags, which\n- // may replace some of these settings with more use case tuned values\n+ // Process the performance quality level or preset; note that this must be\n+ // done before we process any additional settings, such as color profile\n+ // and flags, which may replace some of these settings with more use case\n+ // tuned values\n+ if (quality < ASTCENC_PRE_FASTEST ||\n+ quality > ASTCENC_PRE_EXHAUSTIVE)\n+ {\n+ return ASTCENC_ERR_BAD_QUALITY;\n+ }\n- // Note that the mse_overshoot entries are scaling factors relative to the\n- // base MSE to hit db_limit. A 20% overshoot is harder to hit for a higher\n- // base db_limit, so we may actually use lower ratios for the more through\n- // search presets because the underlying db_limit is so much higher.\n+ // Determine which preset to use, or which pair to interpolate\n+ size_t start;\n+ size_t end;\n+ for (end = 0; end < preset_configs.size(); end++)\n+ {\n+ if (preset_configs[end].quality >= quality)\n+ {\n+ break;\n+ }\n+ }\n- // Values in this enum are from an external user, so not guaranteed to be\n- // bounded to the enum values\n- switch(static_cast<int>(preset))\n+ start = end == 0 ? 0 : end - 1;\n+\n+ // Start and end node are the same - so just transfer the values.\n+ if (start == end)\n{\n- case ASTCENC_PRE_FASTEST:\n- config.tune_partition_limit = 2;\n- config.tune_block_mode_limit = 25;\n- config.tune_refinement_limit = 1;\n- config.tune_candidate_limit = astc::min(1u, TUNE_MAX_TRIAL_CANDIDATES);\n- config.tune_db_limit = astc::max(70 - 35 * ltexels, 53 - 19 * ltexels);\n+ config.tune_partition_limit = preset_configs[start].tune_partition_limit;\n+ config.tune_block_mode_limit = preset_configs[start].tune_block_mode_limit;\n+ config.tune_refinement_limit = preset_configs[start].tune_refinement_limit;\n+ config.tune_candidate_limit = astc::min(preset_configs[start].tune_candidate_limit,\n+ TUNE_MAX_TRIAL_CANDIDATES);\n+ config.tune_db_limit = astc::max(preset_configs[start].tune_db_limit_a_base - 35 * ltexels,\n+ preset_configs[start].tune_db_limit_b_base - 19 * ltexels);\n// Fast and loose - exit as soon as we get a block within the target.\n// This costs an average of around 0.7 dB PSNR ...\n- config.tune_mode0_mse_overshoot = 1.0f;\n- config.tune_refinement_mse_overshoot = 1.0f;\n+ config.tune_mode0_mse_overshoot = preset_configs[start].tune_mode0_mse_overshoot;\n+ config.tune_refinement_mse_overshoot = preset_configs[start].tune_refinement_mse_overshoot;\n- config.tune_partition_early_out_limit = 1.0f;\n- config.tune_two_plane_early_out_limit = 0.5f;\n- break;\n- case ASTCENC_PRE_FAST:\n- config.tune_partition_limit = 4;\n- config.tune_block_mode_limit = 50;\n- config.tune_refinement_limit = 1;\n- config.tune_candidate_limit = astc::min(2u, TUNE_MAX_TRIAL_CANDIDATES);\n- config.tune_db_limit = astc::max(85 - 35 * ltexels, 63 - 19 * ltexels);\n-\n- // Allow some early outs if over threshold.\n- // This costs an average of around 0.1dB PSNR.\n- config.tune_mode0_mse_overshoot = 2.5f;\n- config.tune_refinement_mse_overshoot = 2.5f;\n-\n- config.tune_partition_early_out_limit = 1.0f;\n- config.tune_two_plane_early_out_limit = 0.5f;\n- break;\n- case ASTCENC_PRE_MEDIUM:\n- config.tune_partition_limit = 25;\n- config.tune_block_mode_limit = 75;\n- config.tune_refinement_limit = 2;\n- config.tune_candidate_limit = astc::min(2u, TUNE_MAX_TRIAL_CANDIDATES);\n- config.tune_db_limit = astc::max(95 - 35 * ltexels, 70 - 19 * ltexels);\n-\n- // Allow some early outs if over threshold.\n- // This costs an average of around 0.05dB PSNR.\n- config.tune_mode0_mse_overshoot = 1.75f;\n- config.tune_refinement_mse_overshoot = 1.75f;\n-\n- config.tune_partition_early_out_limit = 1.2f;\n- config.tune_two_plane_early_out_limit = 0.75f;\n- break;\n- case ASTCENC_PRE_THOROUGH:\n- config.tune_partition_limit = 100;\n- config.tune_block_mode_limit = 95;\n- config.tune_refinement_limit = 4;\n- config.tune_candidate_limit = astc::min(3u, TUNE_MAX_TRIAL_CANDIDATES);\n- config.tune_db_limit = astc::max(105 - 35 * ltexels, 77 - 19 * ltexels);\n-\n- // Disable early outs (few blocks hit PSNR target anyway)\n- config.tune_mode0_mse_overshoot = 100.0f;\n- config.tune_refinement_mse_overshoot = 100.0f;\n-\n- config.tune_partition_early_out_limit = 2.5f;\n- config.tune_two_plane_early_out_limit = 0.95f;\n- break;\n- case ASTCENC_PRE_EXHAUSTIVE:\n- config.tune_partition_limit = 1024;\n- config.tune_block_mode_limit = 100;\n- config.tune_refinement_limit = 4;\n- config.tune_candidate_limit = astc::min(4u, TUNE_MAX_TRIAL_CANDIDATES);\n+ config.tune_partition_early_out_limit = preset_configs[start].tune_partition_early_out_limit;\n+ config.tune_two_plane_early_out_limit = preset_configs[start].tune_two_plane_early_out_limit;\n+ }\n+ // Start and end node are not the same - so interpolate between them\n+ else\n+ {\n+ auto& node_a = preset_configs[start];\n+ auto& node_b = preset_configs[end];\n- // Disable early outs (few blocks hit PSNR target anyway)\n- config.tune_mode0_mse_overshoot = 100.0f;\n- config.tune_refinement_mse_overshoot = 100.0f;\n+ float wt_range = node_b.quality - node_a.quality;\n+ assert(wt_range > 0);\n- config.tune_db_limit = 999.0f;\n- config.tune_partition_early_out_limit = 1000.0f;\n- config.tune_two_plane_early_out_limit = 0.99f;\n- break;\n- default:\n- return ASTCENC_ERR_BAD_PRESET;\n+ // Compute interpolation factors\n+ float wt_node_a = (node_b.quality - quality) / wt_range;\n+ float wt_node_b = (quality - node_a.quality) / wt_range;\n+\n+ #define LERP(param) ((node_a.param * wt_node_a) + (node_b.param * wt_node_b))\n+ #define LERPI(param) astc::flt2int_rtn((node_a.param * wt_node_a) + (node_b.param * wt_node_b))\n+ #define LERPUI(param) (unsigned int)astc::flt2int_rtn((node_a.param * wt_node_a) + (node_b.param * wt_node_b))\n+\n+ config.tune_partition_limit = LERPI(tune_partition_limit);\n+ config.tune_block_mode_limit = LERPI(tune_block_mode_limit);\n+ config.tune_refinement_limit = LERPI(tune_refinement_limit);\n+ config.tune_candidate_limit = astc::min(LERPUI(tune_candidate_limit),\n+ TUNE_MAX_TRIAL_CANDIDATES);\n+ config.tune_db_limit = astc::max(LERP(tune_db_limit_a_base) - 35 * ltexels,\n+ LERP(tune_db_limit_b_base) - 19 * ltexels);\n+\n+ // Fast and loose - exit as soon as we get a block within the target.\n+ // This costs an average of around 0.7 dB PSNR ...\n+ config.tune_mode0_mse_overshoot = LERP(tune_mode0_mse_overshoot);\n+ config.tune_refinement_mse_overshoot = LERP(tune_refinement_mse_overshoot);\n+\n+ config.tune_partition_early_out_limit = LERP(tune_partition_early_out_limit);\n+ config.tune_two_plane_early_out_limit = LERP(tune_two_plane_early_out_limit);\n+\n+ #undef LERP\n+ #undef LERPI\n+ #undef LERPUI\n}\n// Set heuristics to the defaults for each color profile\n@@ -895,8 +932,8 @@ const char* astcenc_get_error_string(\nreturn \"ASTCENC_ERR_BAD_BLOCK_SIZE\";\ncase ASTCENC_ERR_BAD_PROFILE:\nreturn \"ASTCENC_ERR_BAD_PROFILE\";\n- case ASTCENC_ERR_BAD_PRESET:\n- return \"ASTCENC_ERR_BAD_PRESET\";\n+ case ASTCENC_ERR_BAD_QUALITY:\n+ return \"ASTCENC_ERR_BAD_QUALITY\";\ncase ASTCENC_ERR_BAD_FLAGS:\nreturn \"ASTCENC_ERR_BAD_FLAGS\";\ncase ASTCENC_ERR_BAD_SWIZZLE:\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -378,7 +378,7 @@ static int init_astcenc_config(\nblock_z = comp_image.block_z;\n}\n- astcenc_preset preset = ASTCENC_PRE_FAST;\n+ float quality = 0.0f;\npreprocess = ASTCENC_PP_NONE;\n// parse the command line's encoding options.\n@@ -402,37 +402,36 @@ static int init_astcenc_config(\nreturn 1;\n}\n- // Read and decode search preset\n+ // Read and decode search quality\nif (argc < 6)\n{\n- printf(\"ERROR: Search preset must be specified\\n\");\n+ printf(\"ERROR: Search quality level must be specified\\n\");\nreturn 1;\n}\nif (!strcmp(argv[5], \"-fastest\"))\n{\n- preset = ASTCENC_PRE_FASTEST;\n+ quality = ASTCENC_PRE_FASTEST;\n}\nelse if (!strcmp(argv[5], \"-fast\"))\n{\n- preset = ASTCENC_PRE_FAST;\n+ quality = ASTCENC_PRE_FAST;\n}\nelse if (!strcmp(argv[5], \"-medium\"))\n{\n- preset = ASTCENC_PRE_MEDIUM;\n+ quality = ASTCENC_PRE_MEDIUM;\n}\nelse if (!strcmp(argv[5], \"-thorough\"))\n{\n- preset = ASTCENC_PRE_THOROUGH;\n+ quality = ASTCENC_PRE_THOROUGH;\n}\nelse if (!strcmp(argv[5], \"-exhaustive\"))\n{\n- preset = ASTCENC_PRE_EXHAUSTIVE;\n+ quality = ASTCENC_PRE_EXHAUSTIVE;\n}\nelse\n{\n- printf(\"ERROR: Search preset '%s' is invalid\\n\", argv[5]);\n- return 1;\n+ quality = static_cast<float>(atof(argv[5]));\n}\nargidx = 6;\n@@ -500,7 +499,8 @@ static int init_astcenc_config(\n}\n#endif\n- astcenc_error status = astcenc_config_init(profile, block_x, block_y, block_z, preset, flags, config);\n+ astcenc_error status = astcenc_config_init(profile, block_x, block_y, block_z,\n+ quality, flags, config);\nif (status == ASTCENC_ERR_BAD_BLOCK_SIZE)\n{\nprintf(\"ERROR: Block size '%s' is invalid\\n\", argv[4]);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Turn quality into an easily tunable parameter
61,745
23.01.2021 12:38:11
0
b8ec8a664a141d382031fdbaf01731c899be5b56
Add better error for an invalid non-float preset
[ { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "@@ -24,7 +24,7 @@ recompile your client-side code using the updated `astcenc.h` header.\nfloat value between 0 and 100, allowing more control over the compression\nquality vs performance trade-off. The presets are not evenly spaced in the\nfloat range; they have been spaced to give the best distribution of points\n- between the fast and through presets.\n+ between the fast and thorough presets.\n* `-fastest`: 0.0\n* `-fast`: 10.0\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "#include <cassert>\n#include <cstring>\n#include <string>\n+#include <sstream>\n#include <vector>\n/* ============================================================================\n@@ -115,8 +116,29 @@ struct compression_workload {\nastcenc_error error;\n};\n-static bool ends_with(const std::string& str, const std::string& suffix)\n-{\n+/**\n+ * @brief Test if a string argument is a well formed float.\n+ */\n+bool is_float(\n+ std::string target\n+) {\n+ float test;\n+ std::istringstream stream(target);\n+\n+ // Leading whitespace is an error\n+ stream >> std::noskipws >> test;\n+\n+ // Ensure entire no remaining string in addition to parse failure\n+ return stream.eof() && !stream.fail();\n+}\n+\n+/**\n+ * @brief Test if a string ends with a given suffix.\n+ */\n+static bool ends_with(\n+ const std::string& str,\n+ const std::string& suffix\n+) {\nreturn (str.size() >= suffix.size()) &&\n(0 == str.compare(str.size() - suffix.size(), suffix.size(), suffix));\n}\n@@ -429,10 +451,15 @@ static int init_astcenc_config(\n{\nquality = ASTCENC_PRE_EXHAUSTIVE;\n}\n- else\n+ else if (is_float(argv[5]))\n{\nquality = static_cast<float>(atof(argv[5]));\n}\n+ else\n+ {\n+ printf(\"ERROR: Search quality/preset '%s' is invalid\\n\", argv[5]);\n+ return 1;\n+ }\nargidx = 6;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add better error for an invalid non-float preset
61,745
25.01.2021 21:35:01
0
f6549d0dac477c2864e7931efb1f2f1675d65fd2
Remove unneeded loop split
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -162,10 +162,6 @@ void compute_partition_error_color_weightings(\nfor (int i = 0; i < pcnt; i++)\n{\nerror_weightings[i] = error_weightings[i] * (1.0f / pi->texels_per_partition[i]);\n- }\n-\n- for (int i = 0; i < pcnt; i++)\n- {\ncolor_scalefactors[i] = sqrt(error_weightings[i]);\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove unneeded loop split
61,745
25.01.2021 22:11:03
0
61a7a7097dd5f6eea0cfec3185392c4a2717b66e
Use astc::min, not a branch
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_kmeans_partitioning.cpp", "new_path": "Source/astcenc_kmeans_partitioning.cpp", "diff": "@@ -307,12 +307,7 @@ static inline int partition_mismatch3(\nint s5 = p11 + p20;\nint v2 = astc::min(s4, s5) + p02;\n- if (v1 < v0)\n- v0 = v1;\n- if (v2 < v0)\n- v0 = v2;\n-\n- return v0;\n+ return astc::min(v0, v1, v2);\n}\n// compute the bit-mismatch for a partitioning in 4-partition mode\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use astc::min, not a branch
61,745
25.01.2021 22:32:57
0
c936e1ec0b1b1a2bdbd170a702aac0f8cf37f67f
Clean up the kmeans functions
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_kmeans_partitioning.cpp", "new_path": "Source/astcenc_kmeans_partitioning.cpp", "diff": "// algorithm similar to XKCD #221. (http://xkcd.com/221/)\n// cluster the texels using the k++ means clustering initialization algorithm.\n-static void kpp_initialize(\n- int xdim,\n- int ydim,\n- int zdim,\n+static void kmeans_init(\n+ int texels_per_block,\nint partition_count,\nconst imageblock* blk,\nfloat4* cluster_centers\n) {\n- int texels_per_block = xdim * ydim * zdim;\n-\nint cluster_center_samples[4];\n// pick a random sample as first center-point.\ncluster_center_samples[0] = 145897 /* number from random.org */ % texels_per_block;\n@@ -144,17 +140,13 @@ static void kpp_initialize(\n// basic K-means clustering: given a set of cluster centers,\n// assign each texel to a partition\n-static void basic_kmeans_assign_pass(\n- int xdim,\n- int ydim,\n- int zdim,\n+static void kmeans_assign(\n+ int texels_per_block,\nint partition_count,\nconst imageblock* blk,\nconst float4* cluster_centers,\nint* partition_of_texel\n) {\n- int texels_per_block = xdim * ydim * zdim;\n-\nfloat distances[MAX_TEXELS_PER_BLOCK];\nint texels_per_partition[4];\n@@ -224,17 +216,13 @@ static void basic_kmeans_assign_pass(\n// basic k-means clustering: given a set of cluster assignments\n// for the texels, find the center position of each cluster.\n-static void basic_kmeans_update(\n- int xdim,\n- int ydim,\n- int zdim,\n+static void kmeans_update(\n+ int texels_per_block,\nint partition_count,\nconst imageblock* blk,\nconst int* partition_of_texel,\nfloat4* cluster_centers\n) {\n- int texels_per_block = xdim * ydim * zdim;\n-\nfloat4 color_sum[4];\nint weight_sum[4];\n@@ -421,23 +409,23 @@ static void count_partition_mismatch_bits(\n}\n-// counting-sort on the mismatch-bits, thereby\n-// sorting the partitions into an ordering.\n+/**\n+ * @brief Use counting sort on the mismatch array to sort partition candidates.\n+ */\nstatic void get_partition_ordering_by_mismatch_bits(\nconst int mismatch_bits[PARTITION_COUNT],\nint partition_ordering[PARTITION_COUNT]\n) {\n- int mscount[256];\n- for (int i = 0; i < 256; i++)\n- {\n- mscount[i] = 0;\n- }\n+ int mscount[256] { 0 };\n+ // Create the histogram of mismatch counts\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\nmscount[mismatch_bits[i]]++;\n}\n+ // Create a running sum from the histogram array\n+ // Cells store previous values only; i.e. exclude self after sum\nint summa = 0;\nfor (int i = 0; i < 256; i++)\n{\n@@ -446,6 +434,8 @@ static void get_partition_ordering_by_mismatch_bits(\nsumma += cnt;\n}\n+ // Use the running sum as the index, incrementing after read to allow\n+ // sequential entries with the same count\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\nint idx = mscount[mismatch_bits[i]]++;\n@@ -462,30 +452,23 @@ void kmeans_compute_partition_ordering(\nfloat4 cluster_centers[4];\nint partition_of_texel[MAX_TEXELS_PER_BLOCK];\n- // 3 passes of plain k-means partitioning\n+ // Use three passes of k-means clustering to partition the block data\nfor (int i = 0; i < 3; i++)\n{\nif (i == 0)\n{\n- kpp_initialize(bsd->xdim, bsd->ydim, bsd->zdim, partition_count, blk, cluster_centers);\n+ kmeans_init(bsd->texel_count, partition_count, blk, cluster_centers);\n}\nelse\n{\n- basic_kmeans_update(bsd->xdim, bsd->ydim, bsd->zdim, partition_count, blk, partition_of_texel, cluster_centers);\n- }\n-\n- basic_kmeans_assign_pass(bsd->xdim, bsd->ydim, bsd->zdim, partition_count, blk, cluster_centers, partition_of_texel);\n+ kmeans_update(bsd->texel_count, partition_count, blk, partition_of_texel, cluster_centers);\n}\n- // at this point, we have a near-ideal partitioning.\n-\n- // construct bitmaps\n- uint64_t bitmaps[4];\n- for (int i = 0; i < 4; i++)\n- {\n- bitmaps[i] = 0ULL;\n+ kmeans_assign(bsd->texel_count, partition_count, blk, cluster_centers, partition_of_texel);\n}\n+ // Construct the block bitmaps of texel assignments to each partition\n+ uint64_t bitmaps[4] { 0 };\nint texels_to_process = bsd->kmeans_texel_count;\nfor (int i = 0; i < texels_to_process; i++)\n{\n@@ -493,12 +476,12 @@ void kmeans_compute_partition_ordering(\nbitmaps[partition_of_texel[idx]] |= 1ULL << i;\n}\n- int bitcounts[PARTITION_COUNT];\n- // for each entry in the partition table, count bits of partition-mismatch.\n- count_partition_mismatch_bits(bsd, partition_count, bitmaps, bitcounts);\n+ // Count the mismatch between the block and the format's partition tables\n+ int mismatch_counts[PARTITION_COUNT];\n+ count_partition_mismatch_bits(bsd, partition_count, bitmaps, mismatch_counts);\n- // finally, sort the partitions by bits-of-partition-mismatch\n- get_partition_ordering_by_mismatch_bits(bitcounts, ordering);\n+ // Sort the partitions based on the number of mismatched bits\n+ get_partition_ordering_by_mismatch_bits(mismatch_counts, ordering);\n}\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Clean up the kmeans functions
61,745
25.01.2021 23:32:05
0
53bd832d652e6268ad82307ebdc6867d67221dd9
Clean up kmeans texel assignment
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes2.cpp", "new_path": "Source/astcenc_block_sizes2.cpp", "diff": "@@ -590,6 +590,56 @@ static void initialize_decimation_table_3d(\ndt->weight_z = z_weights;\n}\n+/**\n+ * @brief Assign the texels to use for kmeans clustering.\n+ *\n+ * The max limit is MAX_KMEANS_TEXELS; above this a random selection is used.\n+ * The @c bsd.texel_count is an input and must be populated beforehand.\n+ *\n+ * @param bsd The block size descriptor to populate.\n+ */\n+static void assign_kmeans_texels(\n+ block_size_descriptor& bsd\n+) {\n+ // Use all texels for kmeans on a small block\n+ if (bsd.texel_count <= MAX_KMEANS_TEXELS)\n+ {\n+ for (int i = 0; i < bsd.texel_count; i++)\n+ {\n+ bsd.kmeans_texels[i] = i;\n+ }\n+\n+ bsd.kmeans_texel_count = bsd.texel_count;\n+ return;\n+ }\n+\n+ // Select a random subset of texels for kmeans on a large block\n+ uint64_t rng_state[2];\n+ astc::rand_init(rng_state);\n+\n+ // Pick 64 random texels for use with bitmap partitioning.\n+ bool seen[MAX_TEXELS_PER_BLOCK];\n+ for (int i = 0; i < bsd.texel_count; i++)\n+ {\n+ seen[i] = false;\n+ }\n+\n+ // Assign 64 random indices, retrying if we see repeats\n+ int arr_elements_set = 0;\n+ while (arr_elements_set < MAX_KMEANS_TEXELS)\n+ {\n+ unsigned int idx = (unsigned int)astc::rand(rng_state);\n+ idx %= bsd.texel_count;\n+ if (!seen[idx])\n+ {\n+ bsd.kmeans_texels[arr_elements_set++] = idx;\n+ seen[idx] = true;\n+ }\n+ }\n+\n+ bsd.kmeans_texel_count = MAX_KMEANS_TEXELS;\n+}\n+\n/**\n* @brief Allocate a single 2D decimation table entry.\n*\n@@ -772,51 +822,7 @@ static void construct_block_size_descriptor_2d(\n}\n// Determine the texels to use for kmeans clustering.\n- if (x_dim * y_dim <= 64)\n- {\n- bsd.kmeans_texel_count = x_dim * y_dim;\n- for (int i = 0; i < x_dim * y_dim; i++)\n- {\n- bsd.kmeans_texels[i] = i;\n- }\n- }\n- else\n- {\n- uint64_t rng_state[2];\n- astc::rand_init(rng_state);\n-\n- // pick 64 random texels for use with bitmap partitioning.\n- int arr[MAX_TEXELS_PER_BLOCK];\n- for (int i = 0; i < x_dim * y_dim; i++)\n- {\n- arr[i] = 0;\n- }\n-\n- int arr_elements_set = 0;\n- while (arr_elements_set < 64)\n- {\n- unsigned int idx = (unsigned int)astc::rand(rng_state);\n- idx %= x_dim * y_dim;\n- if (arr[idx] == 0)\n- {\n- arr_elements_set++;\n- arr[idx] = 1;\n- }\n- }\n-\n- int texel_weights_written = 0;\n- int idx = 0;\n- while (texel_weights_written < 64)\n- {\n- if (arr[idx])\n- {\n- bsd.kmeans_texels[texel_weights_written++] = idx;\n- }\n- idx++;\n- }\n-\n- bsd.kmeans_texel_count = 64;\n- }\n+ assign_kmeans_texels(bsd);\n}\nstatic void construct_block_size_descriptor_3d(\n@@ -940,50 +946,8 @@ static void construct_block_size_descriptor_3d(\n}\nbsd->block_mode_count = packed_idx;\n- if (xdim * ydim * zdim <= 64)\n- {\n- bsd->kmeans_texel_count = xdim * ydim * zdim;\n- for (int i = 0; i < xdim * ydim * zdim; i++)\n- {\n- bsd->kmeans_texels[i] = i;\n- }\n- }\n- else\n- {\n- uint64_t rng_state[2];\n- astc::rand_init(rng_state);\n-\n- // pick 64 random texels for use with bitmap partitioning.\n- int arr[MAX_TEXELS_PER_BLOCK];\n- for (int i = 0; i < xdim * ydim * zdim; i++)\n- {\n- arr[i] = 0;\n- }\n-\n- int arr_elements_set = 0;\n- while (arr_elements_set < 64)\n- {\n- unsigned int idx = (unsigned int)astc::rand(rng_state);\n- idx %= xdim * ydim * zdim;\n- if (arr[idx] == 0)\n- {\n- arr_elements_set++;\n- arr[idx] = 1;\n- }\n- }\n-\n- int texel_weights_written = 0;\n- int idx = 0;\n- while (texel_weights_written < 64)\n- {\n- if (arr[idx])\n- {\n- bsd->kmeans_texels[texel_weights_written++] = idx;\n- }\n- idx++;\n- }\n- bsd->kmeans_texel_count = 64;\n- }\n+ // Determine the texels to use for kmeans clustering.\n+ assign_kmeans_texels(*bsd);\n}\n/* Public function, see header file for detailed documentation */\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "Constants\n============================================================================ */\n#define MAX_TEXELS_PER_BLOCK 216\n+#define MAX_KMEANS_TEXELS 64\n#define MAX_WEIGHTS_PER_BLOCK 64\n#define PLANE2_WEIGHTS_OFFSET (MAX_WEIGHTS_PER_BLOCK/2)\n#define MIN_WEIGHT_BITS_PER_BLOCK 24\n@@ -513,11 +514,11 @@ struct block_size_descriptor\nint16_t block_mode_packed_index[MAX_WEIGHT_MODES];\n- /**< The texel count for k-means partition selection (max 64). */\n+ /**< The texel count for k-means partition selection. */\nint kmeans_texel_count;\n/**< The active texels for k-means partition selection. */\n- int kmeans_texels[64];\n+ int kmeans_texels[MAX_KMEANS_TEXELS];\n/**< The partion tables for all of the possible partitions. */\npartition_info partitions[(3 * PARTITION_COUNT) + 1];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Clean up kmeans texel assignment
61,745
25.01.2021 23:47:44
0
e8e4e88d7635a7f5557b220d7dc5cd5d3adf904c
Use static table for ise_encoding
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_integer_sequence.cpp", "new_path": "Source/astcenc_integer_sequence.cpp", "diff": "#include \"astcenc_internal.h\"\n+#include <array>\n+\n// unpacked quint triplets <low,middle,high> for each packed-quint value\nstatic const uint8_t quints_of_integer[128][3] = {\n{0, 0, 0}, {1, 0, 0}, {2, 0, 0}, {3, 0, 0},\n@@ -329,95 +331,36 @@ static const uint8_t integer_of_trits[3][3][3][3][3] = {\n}\n};\n-static void find_number_of_bits_trits_quints(\n- int quantization_level,\n- int* bits,\n- int* trits,\n- int* quints\n-) {\n- *bits = 0;\n- *trits = 0;\n- *quints = 0;\n- switch (quantization_level)\n- {\n- case QUANT_2:\n- *bits = 1;\n- break;\n- case QUANT_3:\n- *bits = 0;\n- *trits = 1;\n- break;\n- case QUANT_4:\n- *bits = 2;\n- break;\n- case QUANT_5:\n- *bits = 0;\n- *quints = 1;\n- break;\n- case QUANT_6:\n- *bits = 1;\n- *trits = 1;\n- break;\n- case QUANT_8:\n- *bits = 3;\n- break;\n- case QUANT_10:\n- *bits = 1;\n- *quints = 1;\n- break;\n- case QUANT_12:\n- *bits = 2;\n- *trits = 1;\n- break;\n- case QUANT_16:\n- *bits = 4;\n- break;\n- case QUANT_20:\n- *bits = 2;\n- *quints = 1;\n- break;\n- case QUANT_24:\n- *bits = 3;\n- *trits = 1;\n- break;\n- case QUANT_32:\n- *bits = 5;\n- break;\n- case QUANT_40:\n- *bits = 3;\n- *quints = 1;\n- break;\n- case QUANT_48:\n- *bits = 4;\n- *trits = 1;\n- break;\n- case QUANT_64:\n- *bits = 6;\n- break;\n- case QUANT_80:\n- *bits = 4;\n- *quints = 1;\n- break;\n- case QUANT_96:\n- *bits = 5;\n- *trits = 1;\n- break;\n- case QUANT_128:\n- *bits = 7;\n- break;\n- case QUANT_160:\n- *bits = 5;\n- *quints = 1;\n- break;\n- case QUANT_192:\n- *bits = 6;\n- *trits = 1;\n- break;\n- case QUANT_256:\n- *bits = 8;\n- break;\n- }\n-}\n+struct btq_count {\n+ uint8_t quant;\n+ uint8_t bits;\n+ uint8_t trits;\n+ uint8_t quints;\n+};\n+\n+static 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+ { QUANT_5, 0, 0, 1 },\n+ { QUANT_6, 1, 1, 0 },\n+ { QUANT_8, 3, 0, 0 },\n+ { QUANT_10, 1, 0, 1 },\n+ { QUANT_12, 2, 1, 0 },\n+ { QUANT_16, 4, 0, 0 },\n+ { QUANT_20, 2, 0, 1 },\n+ { QUANT_24, 3, 1, 0 },\n+ { QUANT_32, 5, 0, 0 },\n+ { QUANT_40, 3, 0, 1 },\n+ { QUANT_48, 4, 1, 0 },\n+ { QUANT_64, 6, 0, 0 },\n+ { QUANT_80, 4, 0, 1 },\n+ { QUANT_96, 5, 1, 0 },\n+ { QUANT_128, 7, 0, 0 },\n+ { QUANT_160, 5, 0, 1 },\n+ { QUANT_192, 6, 1, 0 },\n+ { QUANT_256, 8, 0, 0 }\n+}};\n// routine to write up to 8 bits\nstatic inline void write_bits(\n@@ -466,8 +409,9 @@ void encode_ise(\nuint8_t highparts[69]; // 64 elements + 5 elements for padding\nuint8_t tq_blocks[22]; // trit-blocks or quint-blocks\n- int bits, trits, quints;\n- find_number_of_bits_trits_quints(quantization_level, &bits, &trits, &quints);\n+ int bits = btq_counts[quantization_level].bits;\n+ int trits = btq_counts[quantization_level].trits;\n+ int quints = btq_counts[quantization_level].quints;\npromise(elements > 0);\nfor (int i = 0; i < elements; i++)\n@@ -548,8 +492,9 @@ void decode_ise(\nuint8_t results[68];\nuint8_t tq_blocks[22]; // trit-blocks or quint-blocks\n- int bits, trits, quints;\n- find_number_of_bits_trits_quints(quantization_level, &bits, &trits, &quints);\n+ int bits = btq_counts[quantization_level].bits;\n+ int trits = btq_counts[quantization_level].trits;\n+ int quints = btq_counts[quantization_level].quints;\nint lcounter = 0;\nint hcounter = 0;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use static table for ise_encoding
61,745
26.01.2021 23:52:15
0
3a65a0db866c2b76439faff9ee60c9c678ac53c1
Use a table-driven approach for computing ISE sizes
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes2.cpp", "new_path": "Source/astcenc_block_sizes2.cpp", "diff": "@@ -117,7 +117,7 @@ static int decode_block_mode_2d(\nint weight_count = N * M * (D + 1);\nint qmode = (base_quant_mode - 2) + 6 * H;\n- int weightbits = compute_ise_bitcount(weight_count, (quantization_method)qmode);\n+ int weightbits = get_ise_sequence_bitcount(weight_count, (quantization_method)qmode);\nif (weight_count > MAX_WEIGHTS_PER_BLOCK ||\nweightbits < MIN_WEIGHT_BITS_PER_BLOCK ||\nweightbits > MAX_WEIGHT_BITS_PER_BLOCK)\n@@ -213,7 +213,7 @@ static int decode_block_mode_3d(\nint weight_count = N * M * Q * (D + 1);\nint qmode = (base_quant_mode - 2) + 6 * H;\n- int weightbits = compute_ise_bitcount(weight_count, (quantization_method)qmode);\n+ int weightbits = get_ise_sequence_bitcount(weight_count, (quantization_method)qmode);\nif (weight_count > MAX_WEIGHTS_PER_BLOCK ||\nweightbits < MIN_WEIGHT_BITS_PER_BLOCK ||\nweightbits > MAX_WEIGHT_BITS_PER_BLOCK)\n@@ -670,7 +670,7 @@ static int construct_dt_entry_2d(\nint maxprec_2planes = -1;\nfor (int i = 0; i < 12; i++)\n{\n- int bits_1plane = compute_ise_bitcount(weight_count, (quantization_method) i);\n+ int bits_1plane = get_ise_sequence_bitcount(weight_count, (quantization_method) i);\nif (bits_1plane >= MIN_WEIGHT_BITS_PER_BLOCK && bits_1plane <= MAX_WEIGHT_BITS_PER_BLOCK)\n{\nmaxprec_1plane = i;\n@@ -678,7 +678,7 @@ static int construct_dt_entry_2d(\nif (try_2planes)\n{\n- int bits_2planes = compute_ise_bitcount(2 * weight_count, (quantization_method) i);\n+ int bits_2planes = get_ise_sequence_bitcount(2 * weight_count, (quantization_method) i);\nif (bits_2planes >= MIN_WEIGHT_BITS_PER_BLOCK && bits_2planes <= MAX_WEIGHT_BITS_PER_BLOCK)\n{\nmaxprec_2planes = i;\n@@ -865,8 +865,8 @@ static void construct_block_size_descriptor_3d(\nint maxprec_2planes = -1;\nfor (int i = 0; i < 12; i++)\n{\n- int bits_1plane = compute_ise_bitcount(weight_count, (quantization_method) i);\n- int bits_2planes = compute_ise_bitcount(2 * weight_count, (quantization_method) i);\n+ int bits_1plane = get_ise_sequence_bitcount(weight_count, (quantization_method) i);\n+ int bits_2planes = get_ise_sequence_bitcount(2 * weight_count, (quantization_method) i);\nif (bits_1plane >= MIN_WEIGHT_BITS_PER_BLOCK && bits_1plane <= MAX_WEIGHT_BITS_PER_BLOCK)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -339,7 +339,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\nint decimation_mode = bm.decimation_mode;\n// compute weight bitcount for the mode\n- int bits_used_by_weights = compute_ise_bitcount(\n+ int bits_used_by_weights = get_ise_sequence_bitcount(\nixtab2[decimation_mode]->weight_count,\n(quantization_method)bm.quantization_mode);\nint bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\n@@ -776,7 +776,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n}\n// compute weight bitcount for the mode\n- int bits_used_by_weights = compute_ise_bitcount(\n+ int bits_used_by_weights = get_ise_sequence_bitcount(\n2 * ixtab2[decimation_mode]->weight_count,\n(quantization_method)bm.quantization_mode);\nint bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_integer_sequence.cpp", "new_path": "Source/astcenc_integer_sequence.cpp", "diff": "@@ -331,14 +331,27 @@ static const uint8_t integer_of_trits[3][3][3][3][3] = {\n}\n};\n+/**\n+ * @brief The number of bits, trits, and quints needed for a quant level.\n+ */\nstruct btq_count {\n+ /**< The quantization level. */\nuint8_t quant;\n+\n+ /**< The number of bits. */\nuint8_t bits;\n+\n+ /**< The number of trits. */\nuint8_t trits;\n+\n+ /**< The number of quints. */\nuint8_t quints;\n};\n-static std::array<btq_count, 21> btq_counts = {{\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{ QUANT_2, 1, 0, 0 },\n{ QUANT_3, 0, 1, 0 },\n{ QUANT_4, 2, 0, 0 },\n@@ -362,6 +375,69 @@ static std::array<btq_count, 21> btq_counts = {{\n{ QUANT_256, 8, 0, 0 }\n}};\n+/**\n+ * @brief The sequence scale, round, and divisors needed to compute sizing.\n+ *\n+ * The length of a quantized sequence in bits is:\n+ * (scale * <sequence_len> + round) / divisor\n+ */\n+struct ise_size {\n+ /**< The quantization level. */\n+ uint8_t quant;\n+\n+ /**< The scaling parameter. */\n+ uint8_t scale;\n+\n+ /**< The rounding parameter. */\n+ uint8_t round;\n+\n+ /**< The divisor parameter. */\n+ uint8_t divisor;\n+};\n+\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+ { QUANT_2, 1, 0, 1 },\n+ { QUANT_3, 8, 4, 5 },\n+ { QUANT_4, 2, 0, 1 },\n+ { QUANT_5, 7, 2, 3 },\n+ { QUANT_6, 13, 4, 5 },\n+ { QUANT_8, 3, 0, 1 },\n+ { QUANT_10, 10, 2, 3 },\n+ { QUANT_12, 18, 4, 5 },\n+ { QUANT_16, 4, 0, 1 },\n+ { QUANT_20, 13, 2, 3 },\n+ { QUANT_24, 23, 4, 5 },\n+ { QUANT_32, 5, 0, 1 },\n+ { QUANT_40, 16, 2, 3 },\n+ { QUANT_48, 28, 4, 5 },\n+ { QUANT_64, 6, 0, 1 },\n+ { QUANT_80, 19, 2, 3 },\n+ { QUANT_96, 33, 4, 5 },\n+ { QUANT_128, 7, 0, 1 },\n+ { QUANT_160, 22, 2, 3 },\n+ { QUANT_192, 38, 4, 5 },\n+ { QUANT_256, 8, 0, 1 }\n+}};\n+\n+/* See header for documentation. */\n+int get_ise_sequence_bitcount(\n+ int items,\n+ quantization_method quant\n+) {\n+ // Cope with out-of bounds values - input might be invalid\n+ if (static_cast<size_t>(quant) >= ise_sizes.size())\n+ {\n+ // Arbitrary large number that's more than an ASTC block can hold\n+ return 1024;\n+ }\n+\n+ auto& entry = ise_sizes[quant];\n+ return (entry.scale * items + entry.round) / entry.divisor;\n+}\n+\n// routine to write up to 8 bits\nstatic inline void write_bits(\nint value,\n@@ -570,58 +646,3 @@ void decode_ise(\noutput_data[i] = results[i];\n}\n}\n-\n-int compute_ise_bitcount(\n- int items,\n- quantization_method quant\n-) {\n- // Values in this enum are from an external data source, so not guaranteed\n- // to be bounded to the enum values for invalid block encodings\n- switch (static_cast<int>(quant))\n- {\n- case QUANT_2:\n- return items;\n- case QUANT_3:\n- return (8 * items + 4) / 5;\n- case QUANT_4:\n- return 2 * items;\n- case QUANT_5:\n- return (7 * items + 2) / 3;\n- case QUANT_6:\n- return (13 * items + 4) / 5;\n- case QUANT_8:\n- return 3 * items;\n- case QUANT_10:\n- return (10 * items + 2) / 3;\n- case QUANT_12:\n- return (18 * items + 4) / 5;\n- case QUANT_16:\n- return items * 4;\n- case QUANT_20:\n- return (13 * items + 2) / 3;\n- case QUANT_24:\n- return (23 * items + 4) / 5;\n- case QUANT_32:\n- return 5 * items;\n- case QUANT_40:\n- return (16 * items + 2) / 3;\n- case QUANT_48:\n- return (28 * items + 4) / 5;\n- case QUANT_64:\n- return 6 * items;\n- case QUANT_80:\n- return (19 * items + 2) / 3;\n- case QUANT_96:\n- return (33 * items + 4) / 5;\n- case QUANT_128:\n- return 7 * items;\n- case QUANT_160:\n- return (22 * items + 2) / 3;\n- case QUANT_192:\n- return (38 * items + 4) / 5;\n- case QUANT_256:\n- return 8 * items;\n- default:\n- return 100000;\n- }\n-}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -813,7 +813,17 @@ void decode_ise(\nuint8_t* output_data,\nint bit_offset);\n-int compute_ise_bitcount(\n+/**\n+ * @brief Return the number of bits needed to encode an ISE sequence.\n+ *\n+ * This implementation assumes that the @c quant level is untrusted, given it\n+ * may come from random data being decompressed, so we return an unencodable\n+ * size if that is the case.\n+ *\n+ * @param items The number of items in the sequence.\n+ * @param quant The desired quantization level.\n+ */\n+int get_ise_sequence_bitcount(\nint items,\nquantization_method quant);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_quantization.cpp", "new_path": "Source/astcenc_quantization.cpp", "diff": "@@ -552,7 +552,7 @@ void build_quantization_mode_table()\n{\nfor (int j = 1; j <= 16; j++)\n{\n- int p = compute_ise_bitcount(2 * j, (quantization_method)i);\n+ int p = get_ise_sequence_bitcount(2 * j, (quantization_method)i);\nif (p < 128)\n{\nquantization_mode_table[j][p] = i;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_symbolic_physical.cpp", "new_path": "Source/astcenc_symbolic_physical.cpp", "diff": "@@ -136,7 +136,7 @@ void symbolic_to_physical(\nint real_weight_count = is_dual_plane ? 2 * weight_count : weight_count;\n- int bits_for_weights = compute_ise_bitcount(real_weight_count,\n+ int bits_for_weights = get_ise_sequence_bitcount(real_weight_count,\n(quantization_method) weight_quantization_method);\nif (is_dual_plane)\n@@ -349,7 +349,7 @@ void physical_to_symbolic(\nbswapped[i] = bitrev8(pcb.data[15 - i]);\n}\n- int bits_for_weights = compute_ise_bitcount(real_weight_count,\n+ int bits_for_weights = get_ise_sequence_bitcount(real_weight_count,\n(quantization_method) weight_quantization_method);\nint below_weights_pos = 128 - bits_for_weights;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use a table-driven approach for computing ISE sizes
61,745
27.01.2021 22:58:48
0
0f1e1b0d5b34a9ac62389a584aaf0ef1ed7a42e7
Tidy up compute_ideal_weights_for_decimation_table
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -257,8 +257,8 @@ static float compress_symbolic_block_fixed_partition_1_plane(\neix[i] = *ei;\ncompute_ideal_weights_for_decimation_table(\n- &(eix[i]),\n- ixtab2[i],\n+ eix[i],\n+ *(ixtab2[i]),\ndecimated_quantized_weights + i * MAX_WEIGHTS_PER_BLOCK,\ndecimated_weights + i * MAX_WEIGHTS_PER_BLOCK);\n}\n@@ -351,7 +351,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\nqwt_bitcounts[i] = bitcount;\n// then, generate the optimized set of weights for the weight mode.\n- compute_ideal_quantized_weights_for_decimation_table(\n+ compute_quantized_weights_for_decimation_table(\nixtab2[decimation_mode],\nweight_low_value[i], weight_high_value[i],\ndecimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * decimation_mode,\n@@ -630,14 +630,14 @@ static float compress_symbolic_block_fixed_partition_2_planes(\neix2[i] = *ei2;\ncompute_ideal_weights_for_decimation_table(\n- &(eix1[i]),\n- ixtab2[i],\n+ eix1[i],\n+ *(ixtab2[i]),\ndecimated_quantized_weights + (2 * i) * MAX_WEIGHTS_PER_BLOCK,\ndecimated_weights + (2 * i) * MAX_WEIGHTS_PER_BLOCK);\ncompute_ideal_weights_for_decimation_table(\n- &(eix2[i]),\n- ixtab2[i],\n+ eix2[i],\n+ *(ixtab2[i]),\ndecimated_quantized_weights + (2 * i + 1) * MAX_WEIGHTS_PER_BLOCK,\ndecimated_weights + (2 * i + 1) * MAX_WEIGHTS_PER_BLOCK);\n}\n@@ -788,7 +788,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nqwt_bitcounts[i] = bitcount;\n// then, generate the optimized set of weights for the mode.\n- compute_ideal_quantized_weights_for_decimation_table(\n+ compute_quantized_weights_for_decimation_table(\nixtab2[decimation_mode],\nweight_low_value1[i],\nweight_high_value1[i],\n@@ -796,7 +796,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nflt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i),\nu8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i), bm.quant_mode);\n- compute_ideal_quantized_weights_for_decimation_table(\n+ compute_quantized_weights_for_decimation_table(\nixtab2[decimation_mode],\nweight_low_value2[i],\nweight_high_value2[i],\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -937,100 +937,97 @@ float compute_error_of_weight_set(\nreturn error_summa;\n}\n-/*\n- Given a complete weight set and a decimation table, try to\n- compute the optimal weight set (assuming infinite precision)\n- given the selected decimation table.\n-*/\n+/* See header for documentation. */\nvoid compute_ideal_weights_for_decimation_table(\n- const endpoints_and_weights* eai,\n- const decimation_table* it,\n- float* weight_set,\n- float* weights\n+ const endpoints_and_weights& eai,\n+ const decimation_table& dt,\n+ float* RESTRICT weight_set,\n+ float* RESTRICT weights\n) {\n- int texel_count = it->texel_count;\n- int weight_count = it->weight_count;\n+ int texel_count = dt.texel_count;\n+ int weight_count = dt.weight_count;\npromise(texel_count > 0);\npromise(weight_count > 0);\n- // perform a shortcut in the case of a complete decimation table\n+ // If we have a 1:1 mapping just shortcut the computation\nif (texel_count == weight_count)\n{\nfor (int i = 0; i < texel_count; i++)\n{\n- int texel = it->weight_texel[i][0];\n- weight_set[i] = eai->weights[texel];\n- weights[i] = eai->weight_error_scale[texel];\n+ assert(i == dt.weight_texel[i][0]);\n+ weight_set[i] = eai.weights[i];\n+ weights[i] = eai.weight_error_scale[i];\n}\nreturn;\n}\n- // if the shortcut is not available, we will instead compute a simple estimate\n- // and perform a single iteration of refinement on that estimate.\n+ // Otherwise compute an estimate and perform single refinement iteration\nfloat infilled_weights[MAX_TEXELS_PER_BLOCK];\n- // compute an initial average for each weight.\n+ // Compute an initial average for each weight\nfor (int i = 0; i < weight_count; i++)\n{\n- float weight_weight = 1e-10f; // to avoid 0/0 later on\n+ // Start with a small value to avoid div-by-zero later\n+ float weight_weight = 1e-10f;\nfloat initial_weight = 0.0f;\n- int weight_texel_count = it->weight_texel_count[i];\n+ // Accumulate error weighting of all the texels using this weight\n+ int weight_texel_count = dt.weight_texel_count[i];\npromise(weight_texel_count > 0);\n+\nfor (int j = 0; j < weight_texel_count; j++)\n{\n- int texel = it->weight_texel[i][j];\n- float weight = it->weights_flt[i][j];\n- float contrib_weight = weight * eai->weight_error_scale[texel];\n+ int texel = dt.weight_texel[i][j];\n+ float weight = dt.weights_flt[i][j];\n+ float contrib_weight = weight * eai.weight_error_scale[texel];\nweight_weight += contrib_weight;\n- initial_weight += eai->weights[texel] * contrib_weight;\n+ initial_weight += eai.weights[texel] * contrib_weight;\n}\nweights[i] = weight_weight;\n- weight_set[i] = initial_weight / weight_weight; // this is the 0/0 that is to be avoided.\n+ weight_set[i] = initial_weight / weight_weight;\n}\n- // TODO: Unroll this using the new SOA _t4 layout?\n+ // Populate the interpolated weight grid based on the initital average\nfor (int i = 0; i < texel_count; i++)\n{\n- const uint8_t *texel_weights = it->texel_weights_t4[i];\n- const float *texel_weights_float = it->texel_weights_float_t4[i];\n+ const uint8_t *texel_weights = dt.texel_weights_t4[i];\n+ const float *texel_weights_float = dt.texel_weights_float_t4[i];\ninfilled_weights[i] = (weight_set[texel_weights[0]] * texel_weights_float[0]\n+ weight_set[texel_weights[1]] * texel_weights_float[1])\n+ (weight_set[texel_weights[2]] * texel_weights_float[2]\n+ weight_set[texel_weights[3]] * texel_weights_float[3]);\n}\n+ // Perform a single iteration of refinement\nconstexpr float stepsize = 0.25f;\n- constexpr float ch0_scale = 4.0f * (stepsize * stepsize * (1.0f / (TEXEL_WEIGHT_SUM * TEXEL_WEIGHT_SUM)));\n- constexpr float ch1_scale = -2.0f * (stepsize * (2.0f / TEXEL_WEIGHT_SUM));\n- constexpr float chd_scale = (ch1_scale / ch0_scale) * stepsize;\n+ constexpr float chd_scale = -TEXEL_WEIGHT_SUM;\nfor (int i = 0; i < weight_count; i++)\n{\nfloat weight_val = weight_set[i];\n- const uint8_t *weight_texel_ptr = it->weight_texel[i];\n- const float *weights_ptr = it->weights_flt[i];\n-\n+ const uint8_t *weight_texel_ptr = dt.weight_texel[i];\n+ const float *weights_ptr = dt.weights_flt[i];\n- float error_change0 = 1e-10f; // done in order to ensure that this value isn't 0, in order to avoid a possible divide by zero later.\n+ // Start with a small value to avoid div-by-zero later\n+ float error_change0 = 1e-10f;\nfloat error_change1 = 0.0f;\n- // compute the two error changes that can occur from perturbing the current index.\n- int weight_texel_count = it->weight_texel_count[i];\n+ // Compute the two error changes that occur from perturbing the current index\n+ int weight_texel_count = dt.weight_texel_count[i];\npromise(weight_texel_count > 0);\nfor (int k = 0; k < weight_texel_count; k++)\n{\n- uint8_t weight_texel = weight_texel_ptr[k];\n- float weights2 = weights_ptr[k];\n+ uint8_t texel = weight_texel_ptr[k];\n+ float contrib_weight = weights_ptr[k];\n- float scale = eai->weight_error_scale[weight_texel] * weights2;\n- float old_weight = infilled_weights[weight_texel];\n- float ideal_weight = eai->weights[weight_texel];\n+ float scale = eai.weight_error_scale[texel] * contrib_weight;\n+ float old_weight = infilled_weights[texel];\n+ float ideal_weight = eai.weights[texel];\n- error_change0 += weights2 * scale;\n+ error_change0 += contrib_weight * scale;\nerror_change1 += (old_weight - ideal_weight) * scale;\n}\n@@ -1053,7 +1050,7 @@ void compute_ideal_weights_for_decimation_table(\nRepeat until we have made a complete processing pass over all weights without\ntriggering any perturbations *OR* we have run 4 full passes.\n*/\n-void compute_ideal_quantized_weights_for_decimation_table(\n+void compute_quantized_weights_for_decimation_table(\nconst decimation_table* it,\nfloat low_bound,\nfloat high_bound,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "#define promise(cond) assert(cond);\n#endif\n+/**\n+ * @brief Make a promise to the compiler's optimizer parameters don't alias.\n+ *\n+ * This is a compiler extension to implement the equivalent of the C99\n+ * @c restrict keyword. Mostly expected to help on functions which are\n+ * reading and writing to arrays via pointers of the same basic type.\n+ */\n+#if !defined(__clang__) && defined(_MSC_VER)\n+ #define RESTRICT __restrict\n+#else // Assume Clang or GCC\n+ #define RESTRICT __restrict__\n+#endif\n+\n/* ============================================================================\nConstants\n============================================================================ */\n@@ -1079,13 +1092,29 @@ void compute_endpoints_and_ideal_weights_2_planes(\nendpoints_and_weights* ei1, // primary plane weights\nendpoints_and_weights* ei2); // secondary plane weights\n+/**\n+ * @brief Compute the optimal weights for a decimation table.\n+ *\n+ * Compute the idealized weight set, assuming infinite precision and no\n+ * quantization. Later functions will use this as a staring points.\n+ *\n+ * @param eai The non-decimated endpoints and weights.\n+ * @param dt The selected decimation table.\n+ * @param[out] weight_set The output decimated weight set.\n+ * @param[out] weights The output decimated weights.\n+ */\nvoid compute_ideal_weights_for_decimation_table(\n- const endpoints_and_weights* eai,\n- const decimation_table* it,\n+ const endpoints_and_weights& eai,\n+ const decimation_table& dt,\nfloat* weight_set,\nfloat* weights);\n-void compute_ideal_quantized_weights_for_decimation_table(\n+/**\n+ * @brief Compute the best quantized weights for a decimation table.\n+ *\n+ * Compute the quantized weight set, for a specific quant level.\n+ */\n+void compute_quantized_weights_for_decimation_table(\nconst decimation_table* it,\nfloat low_bound,\nfloat high_bound,\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Tidy up compute_ideal_weights_for_decimation_table
61,745
28.01.2021 00:39:32
0
752bb3eb847bc74e5fea4f68ee143df42072a156
Add utility for single block test extraction
[ { "change_type": "ADD", "old_path": null, "new_path": "Utils/astc_test_autoextract.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+// Overview\n+// ========\n+//\n+// This is a utility tool to automatically generate single tile test vectors\n+// out of a larger test image. This tool takes three input images:\n+//\n+// - the uncompressed referenced,\n+// - the known-good compressed reference,\n+// - a new compressed image.\n+//\n+// The two compressed images are compared block-by-block, and if any block\n+// differences are found the worst block is extracted from the uncompressed\n+// reference and written back to disk as a single tile output image.\n+//\n+// Limitations\n+// ===========\n+//\n+// This tool only currently supports 2D LDR images.\n+//\n+// Build\n+// =====\n+//\n+// g++ astc_test_autoextract.cpp -I../Source -o astc_test_autoextract\n+\n+#include <stdio.h>\n+#include <stdlib.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+/**\n+ * @brief Compute the array offset in a 2D image\n+ */\n+int pix(int x_pix, int y_idx, int x_idx, int chans, int p_idx)\n+{\n+ return ((y_idx * x_pix) + x_idx) * chans + p_idx;\n+}\n+\n+int main(int argc, char **argv)\n+{\n+\n+ // Parse command line\n+ if (argc < 6)\n+ {\n+ printf(\"Usage: astc_test_extract <blocksize> <ref> <good> <bad> <out>\\n\");\n+ return 1;\n+ }\n+\n+ int blockdim_x, blockdim_y;\n+ if (sscanf(argv[1], \"%dx%d\", &blockdim_x, &blockdim_y) < 2)\n+ {\n+ printf(\"blocksize must be of form WxH; e.g. 8x4\\n\");\n+ return 1;\n+ }\n+\n+ // Load the original reference image\n+ int ref_dim_x, ref_dim_y, ref_ncomp;\n+ uint8_t* data_ref = (uint8_t*)stbi_load(argv[2], &ref_dim_x, &ref_dim_y, &ref_ncomp, 4);\n+ if (!data_ref)\n+ {\n+ printf(\"Failed to load reference image.\\n\");\n+ return 1;\n+ }\n+\n+ // Load the good test image\n+ int good_dim_x, good_dim_y, good_ncomp;\n+ uint8_t* data_good = (uint8_t*)stbi_load(argv[3], &good_dim_x, &good_dim_y, &good_ncomp, 4);\n+ if (!data_good)\n+ {\n+ printf(\"Failed to load good test image.\\n\");\n+ return 1;\n+ }\n+\n+ // Load the bad test image\n+ int bad_dim_x, bad_dim_y, bad_ncomp;\n+ uint8_t* data_bad = (uint8_t*)stbi_load(argv[4], &bad_dim_x, &bad_dim_y, &bad_ncomp, 4);\n+ if (!data_bad)\n+ {\n+ printf(\"Failed to load bad test image.\\n\");\n+ return 1;\n+ }\n+\n+ if (ref_dim_x != good_dim_x || ref_dim_x != bad_dim_x ||\n+ ref_dim_y != good_dim_y || ref_dim_y != bad_dim_y)\n+ {\n+ printf(\"Failed as images are different resolutions.\\n\");\n+ return 1;\n+ }\n+\n+\n+ int x_blocks = (ref_dim_x + blockdim_x - 1) / blockdim_x;\n+ int y_blocks = (ref_dim_y + blockdim_y - 1) / blockdim_y;\n+\n+ int *errorsums = (int*)malloc(x_blocks * y_blocks * 4);\n+ for (int i = 0; i < x_blocks * y_blocks; i++)\n+ {\n+ errorsums[i] = 0;\n+ }\n+\n+ // Diff the two test images to find blocks that differ\n+ for (int y = 0; y < ref_dim_y; y++)\n+ {\n+ for (int x = 0; x < ref_dim_x; x++)\n+ {\n+ int x_block = x / blockdim_x;\n+ int y_block = y / blockdim_y;\n+\n+ int r_gd = data_good[pix(ref_dim_x, y, x, 4, 0)];\n+ int g_gd = data_good[pix(ref_dim_x, y, x, 4, 1)];\n+ int b_gd = data_good[pix(ref_dim_x, y, x, 4, 2)];\n+ int a_gd = data_good[pix(ref_dim_x, y, x, 4, 3)];\n+\n+ int r_bd = data_bad[pix(ref_dim_x, y, x, 4, 0)];\n+ int g_bd = data_bad[pix(ref_dim_x, y, x, 4, 1)];\n+ int b_bd = data_bad[pix(ref_dim_x, y, x, 4, 2)];\n+ int a_bd = data_bad[pix(ref_dim_x, y, x, 4, 3)];\n+\n+ int r_diff = (r_gd - r_bd) * (r_gd - r_bd);\n+ int g_diff = (g_gd - g_bd) * (g_gd - g_bd);\n+ int b_diff = (b_gd - b_bd) * (b_gd - b_bd);\n+ int a_diff = (a_gd - a_bd) * (a_gd - a_bd);\n+\n+ int diff = r_diff + g_diff + b_diff + a_diff;\n+ errorsums[pix(x_blocks, y_block, x_block, 1, 0)] += diff;\n+ }\n+ }\n+\n+ // Diff the two test images to find blocks that differ\n+ float worst_error = 0.0f;\n+ int worst_x_block = 0;\n+ int worst_y_block = 0;\n+ for (int y = 0; y < y_blocks; y++)\n+ {\n+ for (int x = 0; x < x_blocks; x++)\n+ {\n+ float error = errorsums[pix(x_blocks, y, x, 1, 0)];\n+ if (error > worst_error)\n+ {\n+ worst_error = error;\n+ worst_x_block = x;\n+ worst_y_block = y;\n+ }\n+ }\n+ }\n+\n+ if (worst_error == 0.0f)\n+ {\n+ printf(\"No block errors found\\n\");\n+ }\n+ else\n+ {\n+ int start_y = worst_y_block * blockdim_y;\n+ int start_x = worst_x_block * blockdim_x;\n+\n+ int end_y = (worst_y_block + 1) * blockdim_y;\n+ int end_x = (worst_x_block + 1) * blockdim_x;\n+\n+ if (end_x > ref_dim_x)\n+ {\n+ end_x = ref_dim_x;\n+ }\n+\n+ if (end_y > ref_dim_y)\n+ {\n+ end_y = ref_dim_y;\n+ }\n+\n+ int outblk_x = end_x - start_x;\n+ int outblk_y = end_y - start_y;\n+\n+ printf(\"Block errors found at ~(%u, %u) px\\n\", start_x, start_y);\n+\n+ // Write out the worst bad block (from original reference)\n+ uint8_t* data_out = &(data_ref[pix(ref_dim_x, start_y, start_x, 4, 0)]);\n+ stbi_write_png(argv[5], outblk_x, outblk_y, 4, data_out, 4 * ref_dim_x);\n+ }\n+\n+ free(errorsums);\n+ stbi_image_free(data_ref);\n+ stbi_image_free(data_good);\n+ stbi_image_free(data_bad);\n+ return 0;\n+}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add utility for single block test extraction
61,750
28.01.2021 09:02:35
0
fa4369ef1da413f565ff2698d41da530b9773ae8
Pin Jenkinsfile shared libraries version
[ { "change_type": "MODIFY", "old_path": "jenkins/nightly.Jenkinsfile", "new_path": "jenkins/nightly.Jenkinsfile", "diff": "* similarly on different operating systems, so we test one compiler per OS.\n*/\n-@Library('hive-infra-library@master') _\n+@Library('hive-infra-library@changes/88/287488/3') _\npipeline {\nagent none\n" }, { "change_type": "MODIFY", "old_path": "jenkins/release.Jenkinsfile", "new_path": "jenkins/release.Jenkinsfile", "diff": "* similarly on different operating systems, so we test one compiler per OS.\n*/\n-@Library('hive-infra-library@master') _\n+@Library('hive-infra-library@changes/88/287488/3') _\npipeline {\nagent none\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Pin Jenkinsfile shared libraries version (#206)
61,745
28.01.2021 23:53:35
0
7a4a5f3de5719a423d711e3fdc7db3234c5fe370
Minor style cleanups
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes2.cpp", "new_path": "Source/astcenc_block_sizes2.cpp", "diff": "@@ -271,7 +271,6 @@ static void initialize_decimation_table_2d(\nint x_weight_int = x_weight >> 4;\nint y_weight_int = y_weight >> 4;\nint qweight[4];\n- int weight[4];\nqweight[0] = x_weight_int + y_weight_int * x_weights;\nqweight[1] = qweight[0] + 1;\nqweight[2] = qweight[0] + x_weights;\n@@ -280,6 +279,7 @@ static void initialize_decimation_table_2d(\n// truncated-precision bilinear interpolation.\nint prod = x_weight_frac * y_weight_frac;\n+ int weight[4];\nweight[3] = (prod + 8) >> 4;\nweight[1] = x_weight_frac - weight[3];\nweight[2] = y_weight_frac - weight[3];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1626,7 +1626,7 @@ void compress_block(\ntrace_add_data(\"exit\", \"quality not hit\");\nEND_OF_TESTS:\n- // compress/decompress to a physical block\n+ // Compress to a physical block\nsymbolic_to_physical(*bsd, scb, pcb);\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -965,7 +965,7 @@ void compute_ideal_weights_for_decimation_table(\n// Otherwise compute an estimate and perform single refinement iteration\nfloat infilled_weights[MAX_TEXELS_PER_BLOCK];\n- // Compute an initial average for each weight\n+ // Compute an initial average for each decimated weight\nfor (int i = 0; i < weight_count; i++)\n{\n// Start with a small value to avoid div-by-zero later\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Minor style cleanups
61,745
28.01.2021 23:55:33
0
497e2705f04989ccd40f318e81f9aded7ac3ecc2
Optimize encode_ise() Specialize for writing out bits/trits/quints Remove temporary buffers Unroll whole trits/quints blocks Pack trit and quint LSBs with trailing T bits before write
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_integer_sequence.cpp", "new_path": "Source/astcenc_integer_sequence.cpp", "diff": "@@ -481,75 +481,151 @@ void encode_ise(\nuint8_t* output_data,\nint bit_offset\n) {\n- uint8_t lowparts[64];\n- uint8_t highparts[69]; // 64 elements + 5 elements for padding\n- uint8_t tq_blocks[22]; // trit-blocks or quint-blocks\n-\nint bits = btq_counts[quant_level].bits;\nint trits = btq_counts[quant_level].trits;\nint quints = btq_counts[quant_level].quints;\n+ int mask = (1 << bits) - 1;\n- promise(elements > 0);\n- for (int i = 0; i < elements; i++)\n+ // Write out trits and bits\n+ if (trits)\n{\n- lowparts[i] = input_data[i] & ((1 << bits) - 1);\n- highparts[i] = input_data[i] >> bits;\n- }\n+ int i = 0;\n+ int full_trit_blocks = elements / 5;\n- for (int i = elements; i < elements + 5; i++)\n+ for (int j = 0; j < full_trit_blocks; j++)\n{\n- highparts[i] = 0; // padding before we start constructing trit-blocks or quint-blocks\n+ int i4 = input_data[i + 4] >> bits;\n+ int i3 = input_data[i + 3] >> bits;\n+ int i2 = input_data[i + 2] >> bits;\n+ int i1 = input_data[i + 1] >> bits;\n+ int i0 = input_data[i + 0] >> bits;\n+\n+ uint8_t T = integer_of_trits[i4][i3][i2][i1][i0];\n+\n+ // The max size of a trit bit count is 6, so we can always safely\n+ // pack a single MX value with the following 1 or 2 T bits.\n+ uint8_t pack;\n+\n+ // Element 0 + T0 + T1\n+ pack = (input_data[i++] & mask) | (((T >> 0) & 0x3) << bits);\n+ write_bits(pack, bits + 2, bit_offset, output_data);\n+ bit_offset += bits + 2;\n+\n+ // Element 1 + T2 + T3\n+ pack = (input_data[i++] & mask) | (((T >> 2) & 0x3) << bits);\n+ write_bits(pack, bits + 2, bit_offset, output_data);\n+ bit_offset += bits + 2;\n+\n+ // Element 2 + T4\n+ pack = (input_data[i++] & mask) | (((T >> 4) & 0x1) << bits);\n+ write_bits(pack, bits + 1, bit_offset, output_data);\n+ bit_offset += bits + 1;\n+\n+ // Element 3 + T5 + T6\n+ pack = (input_data[i++] & mask) | (((T >> 5) & 0x3) << bits);\n+ write_bits(pack, bits + 2, bit_offset, output_data);\n+ bit_offset += bits + 2;\n+\n+ // Element 4 + T7\n+ pack = (input_data[i++] & mask) | (((T >> 7) & 0x1) << bits);\n+ write_bits(pack, bits + 1, bit_offset, output_data);\n+ bit_offset += bits + 1;\n}\n- // construct trit-blocks or quint-blocks as necessary\n- if (trits)\n+ // Loop tail for a partial block\n+ if (i != elements)\n{\n- int trit_blocks = (elements + 4) / 5;\n- for (int i = 0; i < trit_blocks; i++)\n+ // i4 cannot be present - we know the block is partial\n+ // i0 must be present - we know the block isn't empty\n+ int i4 = 0;\n+ int i3 = i + 3 >= elements ? 0 : input_data[i + 3] >> bits;\n+ int i2 = i + 2 >= elements ? 0 : input_data[i + 2] >> bits;\n+ int i1 = i + 1 >= elements ? 0 : input_data[i + 1] >> bits;\n+ int i0 = input_data[i + 0] >> bits;\n+\n+ uint8_t T = integer_of_trits[i4][i3][i2][i1][i0];\n+\n+ for (int j = 0; i < elements; i++, j++)\n{\n- tq_blocks[i] = integer_of_trits[highparts[5 * i + 4]][highparts[5 * i + 3]][highparts[5 * i + 2]][highparts[5 * i + 1]][highparts[5 * i]];\n+ // Truncated table as this iteration is always partital\n+ static const uint8_t tbits[4] = { 2, 2, 1, 2 };\n+ static const uint8_t tshift[4] = { 0, 2, 4, 5 };\n+\n+ uint8_t pack = (input_data[i] & mask) |\n+ (((T >> tshift[j]) & ((1 << tbits[j]) - 1)) << bits);\n+\n+ write_bits(pack, bits + tbits[j], bit_offset, output_data);\n+ bit_offset += bits + tbits[j];\n}\n}\n-\n- if (quints)\n+ }\n+ // Write out quints and bits\n+ else if (quints)\n{\n- int quint_blocks = (elements + 2) / 3;\n- for (int i = 0; i < quint_blocks; i++)\n+ int i = 0;\n+ int full_quint_blocks = elements / 3;\n+\n+ for (int j = 0; j < full_quint_blocks; j++)\n{\n- tq_blocks[i] = integer_of_quints[highparts[3 * i + 2]][highparts[3 * i + 1]][highparts[3 * i]];\n- }\n+ int i2 = input_data[i + 2] >> bits;\n+ int i1 = input_data[i + 1] >> bits;\n+ int i0 = input_data[i + 0] >> bits;\n+\n+ uint8_t T = integer_of_quints[i2][i1][i0];\n+\n+ // The max size of a quint bit count is 5, so we can always safely\n+ // pack a single M value with the following 2 or 3 T bits.\n+ uint8_t pack;\n+\n+ // Element 0\n+ pack = (input_data[i++] & mask) | (((T >> 0) & 0x7) << bits);\n+ write_bits(pack, bits + 3, bit_offset, output_data);\n+ bit_offset += bits + 3;\n+\n+ // Element 1\n+ pack = (input_data[i++] & mask) | (((T >> 3) & 0x3) << bits);\n+ write_bits(pack, bits + 2, bit_offset, output_data);\n+ bit_offset += bits + 2;\n+\n+ // Element 2\n+ pack = (input_data[i++] & mask) | (((T >> 5) & 0x3) << bits);\n+ write_bits(pack, bits + 2, bit_offset, output_data);\n+ bit_offset += bits + 2;\n}\n- // then, write out the actual bits.\n- int lcounter = 0;\n- int hcounter = 0;\n- for (int i = 0; i < elements; i++)\n+ // Loop tail for a partial block\n+ if (i != elements)\n{\n- write_bits(lowparts[i], bits, bit_offset, output_data);\n- bit_offset += bits;\n+ // i2 cannot be present - we know the block is partial\n+ // i0 must be present - we know the block isn't empty\n+ int i2 = 0;\n+ int i1 = i + 1 >= elements ? 0 : input_data[i + 1] >> bits;\n+ int i0 = input_data[i + 0] >> bits;\n- if (trits)\n+ uint8_t T = integer_of_quints[i2][i1][i0];\n+\n+ for (int j = 0; i < elements; i++, j++)\n{\n- static const int bits_to_write[5] = { 2, 2, 1, 2, 1 };\n- static const int block_shift[5] = { 0, 2, 4, 5, 7 };\n- static const int next_lcounter[5] = { 1, 2, 3, 4, 0 };\n- static const int hcounter_incr[5] = { 0, 0, 0, 0, 1 };\n- write_bits(tq_blocks[hcounter] >> block_shift[lcounter], bits_to_write[lcounter], bit_offset, output_data);\n- bit_offset += bits_to_write[lcounter];\n- hcounter += hcounter_incr[lcounter];\n- lcounter = next_lcounter[lcounter];\n- }\n+ // Truncated table as this iteration is always partital\n+ static const uint8_t tbits[2] = { 3, 2 };\n+ static const uint8_t tshift[2] = { 0, 3 };\n- if (quints)\n+ uint8_t pack = (input_data[i] & mask) |\n+ (((T >> tshift[j]) & ((1 << tbits[j]) - 1)) << bits);\n+\n+ write_bits(pack, bits + tbits[j], bit_offset, output_data);\n+ bit_offset += bits + tbits[j];\n+ }\n+ }\n+ }\n+ // Write out just bits\n+ else\n{\n- static const int bits_to_write[3] = { 3, 2, 2 };\n- static const int block_shift[3] = { 0, 3, 5 };\n- static const int next_lcounter[3] = { 1, 2, 0 };\n- static const int hcounter_incr[3] = { 0, 0, 1 };\n- write_bits(tq_blocks[hcounter] >> block_shift[lcounter], bits_to_write[lcounter], bit_offset, output_data);\n- bit_offset += bits_to_write[lcounter];\n- hcounter += hcounter_incr[lcounter];\n- lcounter = next_lcounter[lcounter];\n+ promise(elements > 0);\n+ for (int i = 0; i < elements; i++)\n+ {\n+ write_bits(input_data[i], bits, bit_offset, output_data);\n+ bit_offset += bits;\n}\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Optimize encode_ise() - Specialize for writing out bits/trits/quints - Remove temporary buffers - Unroll whole trits/quints blocks - Pack trit and quint LSBs with trailing T bits before write
61,745
29.01.2021 00:23:23
0
9010a8b71bd10a8ced14bfab9ba489f6de4b4313
Syntax tidyup around array initializers
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -1787,7 +1787,7 @@ static void quantize_hdr_alpha3(\nv7e = color_quant_tables[quant_level][v7];\nv7d = color_unquant_tables[quant_level][v7e];\n- static const int testbits[3] = { 0xE0, 0xF0, 0xF8 };\n+ static const int testbits[3] { 0xE0, 0xF0, 0xF8 };\nif ((v7 ^ v7d) & testbits[i])\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_color_unquantize.cpp", "new_path": "Source/astcenc_color_unquantize.cpp", "diff": "@@ -404,7 +404,7 @@ static void hdr_rgbo_unpack3(\nred |= bit5 << 10;\n// expand to 12 bits.\n- static const int shamts[6] = { 1, 1, 2, 3, 4, 5 };\n+ static const int shamts[6] { 1, 1, 2, 3, 4, 5 };\nint shamt = shamts[mode];\nred <<= shamt;\ngreen <<= shamt;\n@@ -494,7 +494,7 @@ static void hdr_rgb_unpack3(\nint d1 = v5 & 0x7f;\n// get hold of the number of bits in 'd0' and 'd1'\n- static const int dbits_tab[8] = { 7, 6, 7, 6, 5, 6, 5, 6 };\n+ static const int dbits_tab[8] { 7, 6, 7, 6, 5, 6, 5, 6 };\nint dbits = dbits_tab[modeval];\n// extract six variable-placement bits\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -451,7 +451,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n&& (partition_count == 3 || (workscb.color_formats[0] == workscb.color_formats[3])))))\n{\nint colorvals[4][12];\n- int color_formats_mod[4] = { 0 };\n+ int color_formats_mod[4] { 0 };\nfor (int j = 0; j < partition_count; j++)\n{\ncolor_formats_mod[j] = pack_color_endpoints(\n@@ -900,7 +900,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n&& (partition_count == 3 || (workscb.color_formats[0] == workscb.color_formats[3])))))\n{\nint colorvals[4][12];\n- int color_formats_mod[4] = { 0 };\n+ int color_formats_mod[4] { 0 };\nfor (int j = 0; j < partition_count; j++)\n{\ncolor_formats_mod[j] = pack_color_endpoints(\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -238,7 +238,7 @@ void compute_encoding_choice_errors(\n}\n// Compute the error that arises from just ditching alpha\n- float alpha_drop_error[4] = { 0 };\n+ float alpha_drop_error[4] { 0 };\nfor (int i = 0; i < texels_per_block; i++)\n{\nint partition = pi->partition_of_texel[i];\n@@ -264,8 +264,8 @@ void compute_encoding_choice_errors(\nmerge_endpoints(&(ei1.ep), &(ei2.ep), separate_component, &ep);\n}\n- bool can_offset_encode[4] = { 0 };\n- bool can_blue_contract[4] = { 0 };\n+ bool can_offset_encode[4] { 0 };\n+ bool can_blue_contract[4] { 0 };\nfor (int i = 0; i < partition_count; i++)\n{\nfloat4 endpt0 = ep.endpt0[i];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1062,7 +1062,7 @@ void compute_quantized_weights_for_decimation_table(\nint weight_count = it->weight_count;\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+ static const int quant_levels[12] { 2,3,4,5,6,8,10,12,16,20,24,32 };\nfloat quant_level_m1 = (float)(quant_levels[quant_level] - 1);\n// Quantize the weight set using both the specified low/high bounds\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_integer_sequence.cpp", "new_path": "Source/astcenc_integer_sequence.cpp", "diff": "@@ -548,8 +548,8 @@ void encode_ise(\nfor (int j = 0; i < elements; i++, j++)\n{\n// Truncated table as this iteration is always partital\n- static const uint8_t tbits[4] = { 2, 2, 1, 2 };\n- static const uint8_t tshift[4] = { 0, 2, 4, 5 };\n+ static const uint8_t tbits[4] { 2, 2, 1, 2 };\n+ static const uint8_t tshift[4] { 0, 2, 4, 5 };\nuint8_t pack = (input_data[i] & mask) |\n(((T >> tshift[j]) & ((1 << tbits[j]) - 1)) << bits);\n@@ -607,8 +607,8 @@ void encode_ise(\nfor (int j = 0; i < elements; i++, j++)\n{\n// Truncated table as this iteration is always partital\n- static const uint8_t tbits[2] = { 3, 2 };\n- static const uint8_t tshift[2] = { 0, 3 };\n+ static const uint8_t tbits[2] { 3, 2 };\n+ static const uint8_t tshift[2] { 0, 3 };\nuint8_t pack = (input_data[i] & mask) |\n(((T >> tshift[j]) & ((1 << tbits[j]) - 1)) << bits);\n@@ -665,10 +665,10 @@ void decode_ise(\nif (trits)\n{\n- static const int bits_to_read[5] = { 2, 2, 1, 2, 1 };\n- static const int block_shift[5] = { 0, 2, 4, 5, 7 };\n- static const int next_lcounter[5] = { 1, 2, 3, 4, 0 };\n- static const int hcounter_incr[5] = { 0, 0, 0, 0, 1 };\n+ static const int bits_to_read[5] { 2, 2, 1, 2, 1 };\n+ static const int block_shift[5] { 0, 2, 4, 5, 7 };\n+ static const int next_lcounter[5] { 1, 2, 3, 4, 0 };\n+ static const int hcounter_incr[5] { 0, 0, 0, 0, 1 };\nint tdata = read_bits(bits_to_read[lcounter], bit_offset, input_data);\nbit_offset += bits_to_read[lcounter];\ntq_blocks[hcounter] |= tdata << block_shift[lcounter];\n@@ -678,10 +678,10 @@ void decode_ise(\nif (quints)\n{\n- static const int bits_to_read[3] = { 3, 2, 2 };\n- static const int block_shift[3] = { 0, 3, 5 };\n- static const int next_lcounter[3] = { 1, 2, 0 };\n- static const int hcounter_incr[3] = { 0, 0, 1 };\n+ static const int bits_to_read[3] { 3, 2, 2 };\n+ static const int block_shift[3] { 0, 3, 5 };\n+ static const int next_lcounter[3] { 1, 2, 0 };\n+ static const int hcounter_incr[3] { 0, 0, 1 };\nint tdata = read_bits(bits_to_read[lcounter], bit_offset, input_data);\nbit_offset += bits_to_read[lcounter];\ntq_blocks[hcounter] |= tdata << block_shift[lcounter];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -238,8 +238,8 @@ static void compute_color_error_for_every_integer_count_and_quant_level(\nrgb_mode = 7;\n}\n- static const float rgbo_error_scales[6] = { 4.0f, 4.0f, 16.0f, 64.0f, 256.0f, 1024.0f };\n- static const float rgb_error_scales[9] = { 64.0f, 64.0f, 16.0f, 16.0f, 4.0f, 4.0f, 1.0f, 1.0f, 384.0f };\n+ static const float rgbo_error_scales[6] { 4.0f, 4.0f, 16.0f, 64.0f, 256.0f, 1024.0f };\n+ static const float rgb_error_scales[9] { 64.0f, 64.0f, 16.0f, 16.0f, 4.0f, 4.0f, 1.0f, 1.0f, 384.0f };\nfloat mode7mult = rgbo_error_scales[rgbo_mode] * 0.0015f; // empirically determined ....\nfloat mode11mult = rgb_error_scales[rgb_mode] * 0.010f; // empirically determined ....\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_symbolic_physical.cpp", "new_path": "Source/astcenc_symbolic_physical.cpp", "diff": "@@ -78,7 +78,7 @@ void symbolic_to_physical(\n// This encodes separate constant-color blocks. There is currently\n// no attempt to coalesce them into larger void-extents.\n- static const uint8_t cbytes[8] = { 0xFC, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };\n+ static const uint8_t cbytes[8] { 0xFC, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };\nfor (int i = 0; i < 8; i++)\n{\npcb.data[i] = cbytes[i];\n@@ -99,7 +99,7 @@ void symbolic_to_physical(\n// This encodes separate constant-color blocks. There is currently\n// no attempt to coalesce them into larger void-extents.\n- static const uint8_t cbytes[8] = { 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };\n+ static const uint8_t cbytes[8] { 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };\nfor (int i = 0; i < 8; i++)\n{\npcb.data[i] = cbytes[i];\n@@ -440,7 +440,7 @@ void physical_to_symbolic(\n}\n// then, determine the color endpoint format to use for these integers\n- static const int color_bits_arr[5] = { -1, 115 - 4, 113 - 4 - PARTITION_BITS, 113 - 4 - PARTITION_BITS, 113 - 4 - PARTITION_BITS };\n+ static const int color_bits_arr[5] { -1, 115 - 4, 113 - 4 - PARTITION_BITS, 113 - 4 - PARTITION_BITS, 113 - 4 - PARTITION_BITS };\nint color_bits = color_bits_arr[partition_count] - bits_for_weights - encoded_type_highpart_size;\nif (is_dual_plane)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -140,7 +140,7 @@ struct vfloat4\n*/\nstatic ASTCENC_SIMD_INLINE vfloat4 lane_id()\n{\n- alignas(16) float data[4] = { 0.0f, 1.0f, 2.0f, 3.0f };\n+ alignas(16) float data[4] { 0.0f, 1.0f, 2.0f, 3.0f };\nreturn vfloat4(vld1q_f32(data));\n}\n@@ -204,7 +204,7 @@ struct vint4\n*/\nASTCENC_SIMD_INLINE explicit vint4(int a, int b, int c, int d)\n{\n- int32x4_t v = { a, b, c, d };\n+ int32x4_t v { a, b, c, d };\nm = v;\n}\n@@ -253,7 +253,7 @@ struct vint4\n*/\nstatic ASTCENC_SIMD_INLINE vint4 lane_id()\n{\n- alignas(ASTCENC_VECALIGN) int data[4] = { 0, 1, 2, 3 };\n+ alignas(ASTCENC_VECALIGN) static const int data[4] { 0, 1, 2, 3 };\nreturn vint4(vld1q_s32(data));\n}\n@@ -337,7 +337,7 @@ ASTCENC_SIMD_INLINE vmask4 operator~(vmask4 a)\n*/\nASTCENC_SIMD_INLINE unsigned int mask(vmask4 a)\n{\n- int32x4_t shift = { 0, 1, 2, 3 };\n+ static const int32x4_t shift { 0, 1, 2, 3 };\nuint32x4_t tmp = vshrq_n_u32(a.m, 31);\nreturn vaddvq_u32(vshlq_u32(tmp, shift));\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_error_metrics.cpp", "new_path": "Source/astcenccli_error_metrics.cpp", "diff": "@@ -129,7 +129,7 @@ void compute_error_metrics(\nint fstop_lo,\nint fstop_hi\n) {\n- static int channelmasks[5] = { 0x00, 0x07, 0x0C, 0x07, 0x0F };\n+ static const int channelmasks[5] { 0x00, 0x07, 0x0C, 0x07, 0x0F };\nint channelmask = channelmasks[input_components];\nkahan_accum4 errorsum;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "@@ -1209,7 +1209,9 @@ static int store_ktx_uncompressed_image(\nktx_header hdr;\n- int gl_format_of_channels[4] = { GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };\n+ static const int gl_format_of_channels[4] {\n+ GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA\n+ };\nmemcpy(hdr.magic, ktx_magic, 12);\nhdr.endianness = 0x04030201;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Syntax tidyup around array initializers
61,745
29.01.2021 23:09:31
0
0b14a2a35c9ab1555beb9330d0c727be4cf57673
Update help text for flexible quality
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "#include \"astcenccli_internal.h\"\nstatic const char *astcenc_copyright_string =\n-R\"(ASTC codec v2.3-develop, %u-bit %s%s\n+R\"(astcenc v2.3-develop, %u-bit %s%s\nCopyright 2011-2021 Arm Limited, all rights reserved\n)\";\n@@ -30,23 +30,22 @@ static const char *astcenc_short_help =\nR\"(\nBasic usage:\n-To compress an image use the following command line:\n- astcenc {-cl|-cs|-ch|-cH} <in> <out> <blockdim> <preset> [options]\n+To compress an image use:\n+ astcenc {-cl|-cs|-ch|-cH} <in> <out> <blockdim> <quality> [options]\n-For example, to compress to 8x6 blocks with the thorough preset use:\n+e.g. using LDR profile, 8x6 blocks, and the thorough quality preset:\nastcenc -cl kodim01.png kodim01.astc 8x6 -thorough\n-To decompress an image use the following command line:\n+To decompress an image use:\nastcenc {-dl|-ds|-dh|-dH} <in> <out>\n-For example, use:\n+e.g. using LDR profile:\nastcenc -dl kodim01.astc kodim01.png\n-To perform a compression test, writing back the decompressed output, use\n-the following command line:\n- astcenc {-tl|-ts|-th|-tH} <in> <out> <blockdim> <preset> [options]\n+To perform a compression test, writing back the decompressed output, use:\n+ astcenc {-tl|-ts|-th|-tH} <in> <out> <blockdim> <quality> [options]\n-For example, use:\n+e.g. using LDR profile, 8x6 blocks, and the thorough quality preset:\nastcenc -tl kodim01.png kodim01-test.png 8x6 -thorough\nThe -*l options are used to configure the codec to support only the linear\n@@ -73,9 +72,9 @@ NAME\nSYNOPSIS\nastcenc {-h|-help}\nastcenc {-v|-version}\n- astcenc {-cl|-cs|-ch|-cH} <in> <out> <blocksize> <preset> [options]\n- astcenc {-dl|-ds|-dh|-dH} <in> <out> <blocksize> <preset> [options]\n- astcenc {-tl|-ts|-th|-tH} <in> <out> <blocksize> <preset> [options]\n+ astcenc {-cl|-cs|-ch|-cH} <in> <out> <blocksize> <quality> [options]\n+ astcenc {-dl|-ds|-dh|-dH} <in> <out> <blocksize> <quality> [options]\n+ astcenc {-tl|-ts|-th|-tH} <in> <out> <blocksize> <quality> [options]\nDESCRIPTION\nastcenc compresses image files into the Adaptive Scalable Texture\n@@ -88,10 +87,11 @@ DESCRIPTION\nAll 2D block sizes (4x4 though to 12x12)\nAll 3D block sizes (3x3x3 through to 6x6x6)\n- The compressor provides a number of pre-determined quality presets,\n- which allow users to tradeoff compressed image quality against\n- compression performance. For advanced users the compressor provides\n- many additional control options.\n+ The compressor provides a flexible quality level, allowing users to\n+ trade off compressed image quality against compression performance.\n+ For ease of use, a number of quality presets are also provided. For\n+ advanced users the compressor provides many additional control\n+ options for fine tuning quality.\nastcenc can also be used to decompress ASTC compressed images, and\nperform compression image quality analysis.\n@@ -132,24 +132,24 @@ COMPRESSION\n4x4x4: 2.00 bpp 6x6x5: 0.71 bpp\n5x4x4: 1.60 bpp 6x6x6: 0.59 bpp\n- The quality preset configures the quality-performance tradeoff for\n+ The quality level configures the quality-performance tradeoff for\nthe compressor; more complete searches of the search space improve\n- image quality at the expense of compression time. The available\n- presets are:\n-\n- -fastest\n- -fast\n- -medium\n- -thorough\n- -exhaustive\n-\n- Using the -fastest setting throws away a lot of image quality\n- compared. It is useful for quickly roughing-out new content, but\n- we recommend using higher quality settings for production builds.\n-\n- Using the -exhaustive setting significantly increases compression\n- time, but typically only gives minor quality improvements over\n- using -thorough.\n+ image quality at the expense of compression time. The quality\n+ level can be set to any value between 0 (fastest) and 100\n+ (thorough), or to a fixed quality preset:\n+\n+ -fastest (equivalent to quality = 0)\n+ -fast (equivalent to quality = 10)\n+ -medium (equivalent to quality = 60)\n+ -thorough (equivalent to quality = 98)\n+ -exhaustive (equivalent to quality = 100)\n+\n+ For compression of production content we recommend using a quality\n+ level equivalent to -medium or higher.\n+\n+ Using quality levels higher than -thorough will significantly\n+ increase compression time, but typically only gives minor quality\n+ improvements.\nThere are a number of additional compressor options which are\nuseful to consider for common usage, based on the type of image\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update help text for flexible quality
61,745
30.01.2021 00:15:05
0
4eb2086f9c60a799af5dc633ddecdfd16c5e87f5
Update change log for 2.3 release
[ { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "@@ -19,23 +19,83 @@ Reminder for users of the library interface - the API is not designed to be\nstable across versions, and this release is not compatible with 2.2. Please\nrecompile your client-side code using the updated `astcenc.h` header.\n+* **General:**\n+ * **Feature:** Decompressor-only builds of the codec are supported again.\n+ While this is primarily a feature for library users who want to shrink\n+ binary size, a variant command line tool `astcdec` can be built by\n+ specifying `DECOMPRESSOR=ON` on the CMake configure command line.\n+ * **Feature:** Diagnostic builds of the codec can now be built. These builds\n+ generate a JSON file containing a trace of the compressor execution.\n+ Diagnostic builds are only suitable for codec development; they are slower\n+ and JSON generation cannot be disabled. Build by setting `DIAGNOSTICS=ON`\n+ on the CMake configure command line.\n+ * **Feature:** Code compatibility improved with older versions of GCC,\n+ earliest compiler now tested is GCC 7.5 (was GCC 9.3).\n+ * **Feature:** Code compatibility improved with newer versions of LLVM,\n+ latest compiler now tested is Clang 12.0 (was Clang 9.0).\n+ * **Feature:** Code compatibility improved with the Visual Studio 2019 LLVM\n+ toolset (`clang-cl`). Using the LLVM toolset gives 25% performance\n+ improvements and is recommended.\n* **Command Line:**\n* **Feature:** Quality level now accepts either a preset (`-fast`, etc) or a\nfloat value between 0 and 100, allowing more control over the compression\nquality vs performance trade-off. The presets are not evenly spaced in the\nfloat range; they have been spaced to give the best distribution of points\nbetween the fast and thorough presets.\n-\n* `-fastest`: 0.0\n* `-fast`: 10.0\n* `-medium`: 60.0\n* `-thorough`: 98.0\n* `-exhaustive`: 100.0\n-\n* **Core API:**\n* **API Change:** Quality level preset enum replaced with a float value\nbetween 0 (`-fastest`) and 100 (`-exhaustive`). See above for more info.\n+### Performance\n+\n+This release includes a number of optimizations to improve performance.\n+\n+* New compressor algorithm for handling encoding candidates and refinement.\n+* Vectorized implementation of `compute_error_of_weight_set()`.\n+* Unrolled implementation of `encode_ise()`.\n+* Many other small improvements!\n+\n+The most significant change is the change to the compressor path, which now\n+uses an adaptive approach to candidate trials and block refinement.\n+\n+In earlier releases the quality level will determine the number of encoding\n+candidates and the number of iterative refinement passes that are used for each\n+major encoding trial. This is a fixed behavior; it will always try the full N\n+candidates and M refinement iterations specified by the quality level for each\n+encoding trial.\n+\n+The new approach implements two optimizations for this:\n+\n+* Compression will complete when a block candidate hits the specified target\n+ quality, after its M refinement iterations have been applied. Later block\n+ candidates are simply abandoned.\n+* Block candidates will predict how much refinement can improve them, and\n+ abandon refinement if they are unlikely to improve upon the best known\n+ encoding already in-hand.\n+\n+This pair of optimizations provides significant performance improvement to the\n+high quality modes which use the most block candidates and refinement\n+iterations. A minor loss of image quality is expected, as the blocks we no\n+longer test or refine may have been better coding choices.\n+\n+**Absolute performance vs 2.2 release:**\n+\n+<!-- ![Absolute scores 2.2 vs 2.1](./ChangeLogImg/absolute-2.1-to-2.2.png) -->\n+\n+TBD\n+\n+**Relative performance vs 2.2 release:**\n+\n+<!-- ![Relative scores 2.2 vs 2.1](./ChangeLogImg/relative-2.1-to-2.2.png) -->\n+\n+TBD\n+\n+\n<!-- ---------------------------------------------------------------------- -->\n## 2.2\n@@ -174,6 +234,7 @@ Key for performance charts:\n![Relative scores 2.1 vs 2.0](./ChangeLogImg/relative-2.0-to-2.1.png)\n+\n<!-- ---------------------------------------------------------------------- -->\n## 2.0\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update change log for 2.3 release
61,745
30.01.2021 00:16:26
0
3348128e1ad2755b63192d5197f3ad7182e126cf
Bump tool version to 2.3
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -20,7 +20,7 @@ cmake_minimum_required(VERSION 3.15)\ncmake_policy(SET CMP0069 NEW) # LTO support\ncmake_policy(SET CMP0091 NEW) # MSVC runtime support\n-project(astcenc VERSION 2.2.0)\n+project(astcenc VERSION 2.3.0)\n# Command line configuration\nfunction(printopt optName optVal optArch tgtArch)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "#include \"astcenccli_internal.h\"\nstatic const char *astcenc_copyright_string =\n-R\"(astcenc v2.3-develop, %u-bit %s%s\n+R\"(astcenc v2.3, %u-bit %s%s\nCopyright 2011-2021 Arm Limited, all rights reserved\n)\";\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Bump tool version to 2.3
61,745
30.01.2021 11:49:53
0
91a1aa8a2f84c8c854fc497516721d09b8fa3f6b
Force higher error thresholds for L data
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1372,11 +1372,19 @@ void compress_block(\ntrace_add_data(\"pos_y\", blk->ypos);\ntrace_add_data(\"pos_z\", blk->zpos);\n+ // Set stricter block targets for luminance data as we have more bits to\n+ // play with - fewer endpoints and never need a second weight plane\n+ bool block_is_l = imageblock_is_lum(blk);\n+ float block_is_l_scale = block_is_l ? 1.0f / 1.5f : 1.0f;\n+\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!\nfloat error_weight_sum = prepare_error_weight_block(ctx, input_image, bsd, blk, ewb);\n- float error_threshold = ctx.config.tune_db_limit * error_weight_sum;\n+ float error_threshold = ctx.config.tune_db_limit\n+ * error_weight_sum\n+ * block_is_l_scale;\n+\nlowest_correl = prepare_block_statistics(bsd->texel_count, blk, ewb);\ntrace_add_data(\"tune_error_threshold\", error_threshold);\n@@ -1432,7 +1440,9 @@ void compress_block(\n#if !defined(ASTCENC_DIAGNOSTICS)\nfloat error_weight_sum = prepare_error_weight_block(ctx, input_image, bsd, blk, ewb);\n- float error_threshold = ctx.config.tune_db_limit * error_weight_sum;\n+ float error_threshold = ctx.config.tune_db_limit\n+ * error_weight_sum\n+ * block_is_l_scale;\n#endif\n// Set SCB and mode errors to a very high error value\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -564,6 +564,20 @@ static inline int imageblock_uses_alpha(const imageblock * pb)\nreturn pb->data_min.lane<3>() != pb->data_max.lane<3>();\n}\n+static inline int imageblock_is_lum(const imageblock * pb)\n+{\n+ bool alpha1 = (pb->data_min.lane<3>() == 65535.0f) &&\n+ (pb->data_max.lane<3>() == 65535.0f);\n+ return pb->grayscale && alpha1;\n+}\n+\n+static inline int imageblock_is_lumalp(const imageblock * pb)\n+{\n+ bool alpha1 = (pb->data_min.lane<3>() == 65535.0f) &&\n+ (pb->data_max.lane<3>() == 65535.0f);\n+ return pb->grayscale && !alpha1;\n+}\n+\nvoid imageblock_initialize_orig_from_work(\nimageblock * pb,\nint pixelcount);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Force higher error thresholds for L data
61,745
30.01.2021 11:58:29
0
18b9b156b3be74a0df9d8d398b6ccf299217b73b
Set higher error targets for L+A data
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1377,13 +1377,19 @@ void compress_block(\nbool block_is_l = imageblock_is_lum(blk);\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\n+ // bits to play with - fewer endpoints but may use a second weight plane\n+ bool block_is_la = imageblock_is_lumalp(blk);\n+ float block_is_la_scale = block_is_la ? 1.0f / 1.05f : 1.0f;\n+\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!\nfloat 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_l_scale\n+ * block_is_la_scale;\nlowest_correl = prepare_block_statistics(bsd->texel_count, blk, ewb);\n@@ -1442,7 +1448,8 @@ void compress_block(\nfloat 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_l_scale\n+ * block_is_la_scale;\n#endif\n// Set SCB and mode errors to a very high error value\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Set higher error targets for L+A data
61,745
31.01.2021 22:53:45
0
59f14d033ed196d97d80053ec41013bd7ac54fcb
Update markdown/versions for 2.3 release
[ { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "@@ -8,10 +8,17 @@ clocked at 4.2 GHz, running astcenc using 6 threads.\n<!-- ---------------------------------------------------------------------- -->\n-## 2.3\n+## 2.4\n**Status:** In development\n+The 2.4 release is the fifth release in the 2.x series. It includes ...\n+\n+<!-- ---------------------------------------------------------------------- -->\n+## 2.3\n+\n+**Status:** Released\n+\nThe 2.3 release is the fourth release in the 2.x series. It includes a number\nof performance improvements and new features.\n" }, { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -62,7 +62,7 @@ Release build binaries for the `astcenc` stable releases are provided in the\n[GitHub Releases page](https://github.com/ARM-software/astc-encoder/releases).\nBinaries are provided for 64-bit builds on Windows, macOS, and Linux.\n-* Latest stable release: 2.2\n+* Latest stable release: 2.3\n* Change log: [2.x series](./Docs/ChangeLog.md)\n* Roadmap: [2.x series and beyond](./Docs/Roadmap.md)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "#include \"astcenccli_internal.h\"\nstatic const char *astcenc_copyright_string =\n-R\"(astcenc v2.3, %u-bit %s%s\n+R\"(astcenc v2.4-develop, %u-bit %s%s\nCopyright 2011-2021 Arm Limited, all rights reserved\n)\";\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update markdown/versions for 2.3 release
61,745
03.02.2021 07:50:23
0
52f8cb1709cef491cdc80c887c14cb6ba7bd6ae8
Add trailing quick reference to help text
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -500,6 +500,20 @@ DECOMPRESSION FILE FORMATS\nContainer Formats:\nKhronos Texture KTX (*.ktx)\nDirectDraw Surface DDS (*.dds)\n+\n+QUICK REFERENCE\n+\n+ To compress an image use:\n+ astcenc {-cl|-cs|-ch|-cH} <in> <out> <blockdim> <quality> [options]\n+\n+ To decompress an image use:\n+ astcenc {-dl|-ds|-dh|-dH} <in> <out>\n+\n+ To perform a quality test use:\n+ astcenc {-tl|-ts|-th|-tH} <in> <out> <blockdim> <quality> [options]\n+\n+ Mode -*l = linear LDR, -*s = sRGB LDR, -*h = HDR RGB/LDR A, -*H = HDR.\n+ Quality = -fastest/-fast/-medium/-thorough/-exhaustive/a float [0-100].\n)\";\n// print version and basic build information\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add trailing quick reference to help text
61,745
03.02.2021 08:33:49
0
1a7bb339da88abc84f0623cbd8fb3f8af19b524a
Replace -a zero-weight blocks with constant color This change applied an RDO-like technique to improve packaging compression ratios in textures using edge extrude/dilation. Blocks that are entirely zero-weighted after the alpha radius is taken into account are replaced with constant color black blocks. Fixes
[ { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "@@ -14,6 +14,13 @@ clocked at 4.2 GHz, running astcenc using 6 threads.\nThe 2.4 release is the fifth release in the 2.x series. It includes ...\n+* **General:**\n+ * **Feature:** When using the `-a` option any 2D blocks that are entirely\n+ zero alpha, after the alpha filter radius is taken into account, are\n+ replaced by transparent black constant color blocks. This is an RDO-like\n+ technique to improve compression ratios of any additional packaging level\n+ compression applied.\n+\n<!-- ---------------------------------------------------------------------- -->\n## 2.3\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -717,9 +717,58 @@ static void compress_image(\nint y = rem / row_blocks;\nint x = rem - (y * row_blocks);\n- // Decompress\n- fetch_imageblock(decode_mode, image, &pb, bsd, x * block_x, y * block_y, z * block_z, swizzle);\n+ // Test if we can apply some basic alpha-scale RDO\n+ bool use_full_block = true;\n+ if (ctx.config.a_scale_radius != 0 && block_z == 1)\n+ {\n+ int start_x = x * block_x;\n+ int end_x = astc::min(dim_x, start_x + block_x);\n+\n+ int start_y = y * block_y;\n+ int end_y = astc::min(dim_y, start_y + block_y);\n+\n+ // SATs accumulate error, so don't test exactly zero. Test for\n+ // less than 1 alpha in the expanded block footprint that\n+ // includes the alpha radius.\n+ int x_footprint = block_x +\n+ 2 * (ctx.config.a_scale_radius - 1);\n+\n+ int y_footprint = block_y +\n+ 2 * (ctx.config.a_scale_radius - 1);\n+\n+ float footprint = (float)(x_footprint * y_footprint);\n+ float threshold = 0.9f / (255.0f * footprint);\n+\n+ // Do we have any alpha values?\n+ use_full_block = false;\n+ for (int ay = start_y; ay < end_y; ay++)\n+ {\n+ for (int ax = start_x; ax < end_x; ax++)\n+ {\n+ float a_avg = ctx.input_alpha_averages[ay * dim_x + ax];\n+ if (a_avg > threshold)\n+ {\n+ use_full_block = true;\n+ ax = end_x;\n+ ay = end_y;\n+ }\n+ }\n+ }\n+ }\n+ // Fetch the full block for compression\n+ if (use_full_block)\n+ {\n+ fetch_imageblock(decode_mode, image, &pb, bsd, x * block_x, y * block_y, z * block_z, swizzle);\n+ }\n+ // Apply alpha scale RDO - substitute constant color block\n+ else\n+ {\n+ pb.origin_texel = float4(0.0f, 0.0f, 0.0f, 0.0f);\n+ pb.data_min = vfloat4(0.0f, 0.0f, 0.0f, 0.0f);\n+ pb.data_max = pb.data_min;\n+ pb.grayscale = false;\n+ }\nint offset = ((z * yblocks + y) * xblocks + x) * 16;\nuint8_t *bp = buffer + offset;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -263,6 +263,11 @@ ADVANCED COMPRESSION\nof the texel defined by the <radius> argument. Setting <radius>\nto 0 causes only the texel's own alpha to be used.\n+ ASTC blocks that are entirely zero weighted, after the radius is\n+ taken into account, are replaced by constant color blocks. This\n+ is an RDO-like technique to improve compression ratio in any\n+ application packaging level compression that is applied.\n+\n-cw <red> <green> <blue> <alpha>\nAssign an additional weight scaling to each color channel,\nallowing the channels to be treated differently in terms of\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Replace -a zero-weight blocks with constant color (#209) This change applied an RDO-like technique to improve packaging compression ratios in textures using edge extrude/dilation. Blocks that are entirely zero-weighted after the alpha radius is taken into account are replaced with constant color black blocks. Fixes #208
61,745
09.02.2021 22:56:36
0
8a7d65e44d0d0da27f80a97d9d4c2c6933e42952
Add helper script for objdump
[ { "change_type": "ADD", "old_path": null, "new_path": "Test/astc_dump_binary.py", "diff": "+#!/usr/bin/env python3\n+# 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+The ``astc_dump_binary`` utility provides a wrapper around the ``objdump``\n+utility to extract disassembly of specific functions. Currently only matches\n+the root name, for sake of command line sanity, so all overloads get dumped.\n+\n+Using __attribute__((noinline)) can be useful during profiling to stop any\n+functions of interest getting inlined once they get too small ...\n+\"\"\"\n+\n+\n+import argparse\n+import re\n+import shutil\n+import subprocess as sp\n+import sys\n+\n+\n+def run_objdump(binary, symbol):\n+ \"\"\"\n+ Run objdump on a single binary and extract the range for a given symbol.\n+\n+ Output is printed to stdout.\n+\n+ Args:\n+ binary (str): The path of the binary file to process.\n+ symbol (str): The symbol to match.\n+\n+ Raises:\n+ CalledProcessException: The ``objdump`` subprocess failed for any reason.\n+ \"\"\"\n+ args = [\n+ \"objdump\", \"-C\",\n+ \"-M\", \"intel\",\n+ \"--no-show-raw\",\n+ \"-d\", \"-S\",\n+ binary\n+ ]\n+\n+ result = sp.run(args, stdout=sp.PIPE, stderr=sp.PIPE,\n+ check=True, universal_newlines=True)\n+\n+ funcPattern = re.compile(r\"^[0-9a-f]{16} <(.*)\\(.*\\)>:$\")\n+\n+ funcLines = []\n+ funcActive = False\n+ lines = result.stdout.splitlines()\n+\n+ for line in lines:\n+ match = funcPattern.match(line)\n+ if match:\n+ funcName = match.group(1)\n+ if funcName == symbol:\n+ funcActive = True\n+ else:\n+ funcActive = False\n+\n+ if funcActive:\n+ funcLines.append(line)\n+\n+ print(\"\\n\".join(funcLines))\n+\n+def parse_command_line():\n+ \"\"\"\n+ Parse the command line.\n+\n+ Returns:\n+ Namespace: The parsed command line container.\n+ \"\"\"\n+ parser = argparse.ArgumentParser()\n+\n+ parser.add_argument(\"binary\", type=argparse.FileType(\"r\"),\n+ help=\"The new binary to dump\")\n+\n+ parser.add_argument(\"symbol\", type=str,\n+ help=\"The function name to dump\")\n+\n+ return parser.parse_args()\n+\n+\n+def main():\n+ \"\"\"\n+ The main function.\n+\n+ Returns:\n+ int: The process return code.\n+ \"\"\"\n+ args = parse_command_line()\n+\n+ # Preflight - check that size exists. Note that size might still fail at\n+ # runtime later, e.g. if the binary is not of the correct format\n+ path = shutil.which(\"objdump\")\n+ if not path:\n+ print(\"ERROR: The 'objdump' utility is not installed on the PATH\")\n+ return 1\n+\n+ # Collect the data\n+ try:\n+ run_objdump(args.binary.name, args.symbol)\n+ except sp.CalledProcessError as ex:\n+ print(\"ERROR: The 'objdump' utility failed\")\n+ print(\" %s\" % ex.stderr.strip())\n+ return 1\n+\n+ return 0\n+\n+\n+if __name__ == \"__main__\":\n+ sys.exit(main())\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add helper script for objdump
61,745
10.02.2021 15:04:37
0
f9dcf85f1f5bed95125846c5896f22c611461501
Fix pixel addressing in HDR images HDR images ended up with a row/col skew if they were not square due to index transposition. Fix
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_image.cpp", "new_path": "Source/astcenccli_image.cpp", "diff": "@@ -187,7 +187,7 @@ astcenc_image* astc_img_from_floatx4_array(\n#if 0\nfloat*** data32 = static_cast<float***>(img->data);\nunsigned int y_src = y_flip ? (dim_y - y - 1) : y;\n- const float* src = data + 4 * dim_y * y_src;\n+ const float* src = data + 4 * dim_x * y_src;\nfor (unsigned int x = 0; x < dim_x; x++)\n{\n@@ -199,7 +199,7 @@ astcenc_image* astc_img_from_floatx4_array(\n#else\nuint16_t* data16 = static_cast<uint16_t*>(img->data[0]);\nunsigned int y_src = y_flip ? (dim_y - y - 1) : y;\n- const float* src = data + 4 * dim_y * y_src;\n+ const float* src = data + 4 * dim_x * y_src;\nfor (unsigned int x = 0; x < dim_x; x++)\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix pixel addressing in HDR images HDR images ended up with a row/col skew if they were not square due to index transposition. Fix #211
61,745
10.02.2021 16:23:45
0
8ad3c83e05e1ae7ce93edfa0c1c959ac4eebc13e
Top level changes for 2.4 patch release
[ { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "@@ -12,19 +12,24 @@ clocked at 4.2 GHz, running astcenc using 6 threads.\n**Status:** In development\n-The 2.4 release is the fifth release in the 2.x series. It includes ...\n-\n-* **General:**\n- * **Feature:** When using the `-a` option any 2D blocks that are entirely\n- zero alpha, after the alpha filter radius is taken into account, are\n- replaced by transparent black constant color blocks. This is an RDO-like\n- technique to improve compression ratios of any additional packaging level\n- compression applied.\n+The 2.4 release is the fifth release in the 2.x series. It is primarily a bug\n+fix release for HDR image handling, which impacts all earlier 2.x series\n+releases.\n+\n+**General:**\n+ * **Feature:** When using the `-a` option, or the equivalent config option\n+ for the API, any 2D blocks that are entirely zero alpha after the alpha\n+ filter radius is taken into account are replaced by transparent black\n+ constant color blocks. This is an RDO-like technique to improve compression\n+ ratios of any additional application packaging compression that is applied.\n+**Command Line:**\n+ * **Bug fix:** The command line wrapper now correctly loads HDR images that\n+ have a non-square aspect ratio.\n<!-- ---------------------------------------------------------------------- -->\n## 2.3\n-**Status:** Released\n+**Status:** Released, January 2021\nThe 2.3 release is the fourth release in the 2.x series. It includes a number\nof performance improvements and new features.\n@@ -99,16 +104,11 @@ longer test or refine may have been better coding choices.\n**Absolute performance vs 2.2 release:**\n-<!-- ![Absolute scores 2.2 vs 2.1](./ChangeLogImg/absolute-2.1-to-2.2.png) -->\n-\n-TBD\n+![Absolute scores 2.3 vs 2.2](./ChangeLogImg/absolute-2.2-to-2.3.png)\n**Relative performance vs 2.2 release:**\n-<!-- ![Relative scores 2.2 vs 2.1](./ChangeLogImg/relative-2.1-to-2.2.png) -->\n-\n-TBD\n-\n+![Relative scores 2.3 vs 2.2](./ChangeLogImg/relative-2.2-to-2.3.png)\n<!-- ---------------------------------------------------------------------- -->\n## 2.2\n" }, { "change_type": "ADD", "old_path": "Docs/ChangeLogImg/absolute-2.2-to-2.3.png", "new_path": "Docs/ChangeLogImg/absolute-2.2-to-2.3.png", "diff": "Binary files /dev/null and b/Docs/ChangeLogImg/absolute-2.2-to-2.3.png differ\n" }, { "change_type": "ADD", "old_path": "Docs/ChangeLogImg/relative-2.2-to-2.3.png", "new_path": "Docs/ChangeLogImg/relative-2.2-to-2.3.png", "diff": "Binary files /dev/null and b/Docs/ChangeLogImg/relative-2.2-to-2.3.png differ\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_image.cpp", "new_path": "Source/astcenccli_image.cpp", "diff": "// SPDX-License-Identifier: Apache-2.0\n// ----------------------------------------------------------------------------\n-// Copyright 2011-2020 Arm Limited\n+// Copyright 2011-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/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "#include \"astcenccli_internal.h\"\nstatic const char *astcenc_copyright_string =\n-R\"(astcenc v2.4-develop, %u-bit %s%s\n+R\"(astcenc v2.4, %u-bit %s%s\nCopyright 2011-2021 Arm Limited, all rights reserved\n)\";\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_result_plot.py", "new_path": "Test/astc_test_result_plot.py", "diff": "@@ -273,6 +273,16 @@ def main():\nNone,\n\"absolute-all.png\",\n(absoluteXLimit, None)\n+ ], [\n+ # Plot 2.3 to 2.2 absolute scores\n+ [\"thorough\", \"medium\", \"fast\", \"fastest\"],\n+ [\"ref-2.2-avx2\", \"ref-2.3-avx2\"],\n+ [\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\n+ False,\n+ None,\n+ None,\n+ \"absolute-2.2-to-2.3.png\",\n+ (absoluteXLimit, None)\n], [\n# --------------------------------------------------------\n# Plot all relative scores vs 1.7\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Top level changes for 2.4 patch release
61,745
10.02.2021 16:56:29
0
0c459b952fc51c345cfc090d510938a505607ed7
Setup for 2.5-develop
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -20,7 +20,7 @@ cmake_minimum_required(VERSION 3.15)\ncmake_policy(SET CMP0069 NEW) # LTO support\ncmake_policy(SET CMP0091 NEW) # MSVC runtime support\n-project(astcenc VERSION 2.4.0)\n+project(astcenc VERSION 2.5.0)\n# Command line configuration\nfunction(printopt optName optVal optArch tgtArch)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "#include \"astcenccli_internal.h\"\nstatic const char *astcenc_copyright_string =\n-R\"(astcenc v2.4, %u-bit %s%s\n+R\"(astcenc v2.5-develop, %u-bit %s%s\nCopyright 2011-2021 Arm Limited, all rights reserved\n)\";\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Setup for 2.5-develop
61,745
10.02.2021 19:54:59
0
a5f2e7967f6621c8de1dd91348b139760de53e05
Always start the SCB as an error block
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1454,6 +1454,8 @@ void compress_block(\n// Set SCB and mode errors to a very high error value\nscb.errorval = 1e30f;\n+ scb.error_block = 1;\n+\nfloat best_errorvals_in_modes[13];\nfor (int i = 0; i < 13; i++)\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Always start the SCB as an error block
61,745
12.02.2021 21:09:29
0
faa9ea9bfcdcd0eceefc5964094574bcd48992e8
Add accessor for fetching block texels
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -62,11 +62,7 @@ void compute_averages_and_directions_rgba(\n{\nint iwt = weights[i];\nfloat weight = ewb->texel_weight[iwt];\n-\n- vfloat4 texel_datum(blk->data_r[iwt],\n- blk->data_g[iwt],\n- blk->data_b[iwt],\n- blk->data_a[iwt]);\n+ vfloat4 texel_datum = blk->texel(iwt);\npartition_weight += weight;\nbase_sum = base_sum + texel_datum * weight;\n@@ -84,10 +80,7 @@ void compute_averages_and_directions_rgba(\n{\nint iwt = weights[i];\nfloat weight = ewb->texel_weight[iwt];\n- vfloat4 texel_datum(blk->data_r[iwt],\n- blk->data_g[iwt],\n- blk->data_b[iwt],\n- blk->data_a[iwt]);\n+ vfloat4 texel_datum = blk->texel(iwt);\ntexel_datum = (texel_datum - average) * weight;\nif (texel_datum.lane<0>() > 0.0f)\n@@ -167,11 +160,9 @@ void compute_averages_and_directions_rgb(\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n- float3 texel_datum = float3(blk->data_r[iwt],\n- blk->data_g[iwt],\n- blk->data_b[iwt]) * weight;\n- partition_weight += weight;\n+ float3 texel_datum = blk->texel3(iwt) * weight;\n+ partition_weight += weight;\nbase_sum = base_sum + texel_datum;\n}\n@@ -187,9 +178,7 @@ void compute_averages_and_directions_rgb(\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n- float3 texel_datum = float3(blk->data_r[iwt],\n- blk->data_g[iwt],\n- blk->data_b[iwt]);\n+ float3 texel_datum = blk->texel3(iwt);\ntexel_datum = (texel_datum - average) * weight;\nif (texel_datum.r > 0.0f)\n@@ -622,11 +611,7 @@ void compute_error_squared_rgba(\n{\nint iwt = weights[i];\n- vfloat4 dat(blk->data_r[iwt],\n- blk->data_g[iwt],\n- blk->data_b[iwt],\n- blk->data_a[iwt]);\n-\n+ vfloat4 dat = blk->texel(iwt);\nvfloat4 ews = ewb->error_weights[iwt];\nfloat uncor_param = dot_s(dat, l_uncor.bs);\n@@ -806,10 +791,7 @@ void compute_error_squared_rgb(\n{\nint iwt = weights[i];\n- float3 dat = float3(blk->data_r[iwt],\n- blk->data_g[iwt],\n- blk->data_b[iwt]);\n-\n+ float3 dat = blk->texel3(iwt);\nfloat3 ews = float3(ewb->error_weights[iwt].swz<0, 1, 2>());\nfloat uncor_param = dot(dat, l_uncor.bs);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -170,8 +170,7 @@ static int realign_weights(\nvfloat4 color = color_base + color_offset * plane_weight;\n- vfloat4 origcolor = vfloat4(blk->data_r[texel], blk->data_g[texel],\n- blk->data_b[texel], blk->data_a[texel]);\n+ vfloat4 origcolor = blk->texel(texel);\nvfloat4 error_weight = vfloat4(ewb->texel_weight_r[texel], ewb->texel_weight_g[texel],\newb->texel_weight_b[texel], ewb->texel_weight_a[texel]);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -411,10 +411,7 @@ float compute_symbolic_block_difference(\n(float)color.b,\n(float)color.a);\n- vfloat4 oldColor(pb->data_r[i],\n- pb->data_g[i],\n- pb->data_b[i],\n- pb->data_a[i]);\n+ vfloat4 oldColor = pb->texel(i);\nvfloat4 error = oldColor - newColor;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -112,9 +112,7 @@ static float compute_error_squared_rgb_single_partition(\ncontinue;\n}\n- float3 point = float3(blk->data_r[i],\n- blk->data_g[i],\n- blk->data_b[i]);\n+ float3 point = blk->texel3(i);\nfloat param = dot(point, lin->bs);\nfloat3 rp1 = lin->amod + param * lin->bis;\nfloat3 dist = rp1 - point;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -79,10 +79,7 @@ static void compute_rgba_range(\nif (ewb->texel_weight[i] > 1e-10f)\n{\nint partition = pt->partition_of_texel[i];\n- vfloat4 data(blk->data_r[i],\n- blk->data_g[i],\n- blk->data_b[i],\n- blk->data_a[i]);\n+ vfloat4 data = blk->texel(i);\nrgba_min[partition] = min(data, rgba_min[partition]);\nrgba_max[partition] = max(data, rgba_max[partition]);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -682,7 +682,7 @@ static void compute_endpoints_and_ideal_weights_rgba(\n{\nint partition = pt->partition_of_texel[i];\n- vfloat4 point = vfloat4(blk->data_r[i], blk->data_g[i], blk->data_b[i], blk->data_a[i]) * scalefactors[partition];\n+ vfloat4 point = blk->texel(i) * scalefactors[partition];\nline4 l = lines[partition];\nfloat param = dot_s(point - l.a, l.b);\n@@ -1240,7 +1240,7 @@ void recompute_ideal_colors_2planes(\n{\nint tix = texel_indexes[j];\n- vfloat4 rgba(pb->data_r[tix], pb->data_g[tix], pb->data_b[tix], pb->data_a[tix]);\n+ vfloat4 rgba = pb->texel(tix);\nvfloat4 error_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\nrgba_sum = rgba_sum + (rgba * error_weight);\n@@ -1280,7 +1280,7 @@ void recompute_ideal_colors_2planes(\n{\nint tix = texel_indexes[j];\n- vfloat4 rgba(pb->data_r[tix], pb->data_g[tix], pb->data_b[tix], pb->data_a[tix]);\n+ vfloat4 rgba = pb->texel(tix);\nvfloat4 color_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\nfloat3 color_weight3 = color_weight.swz<0, 1, 2>();\n@@ -1642,7 +1642,7 @@ void recompute_ideal_colors_1plane(\n{\nint tix = texel_indexes[j];\n- vfloat4 rgba(pb->data_r[tix], pb->data_g[tix], pb->data_b[tix], pb->data_a[tix]);\n+ vfloat4 rgba = pb->texel(tix);\nvfloat4 error_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\nrgba_sum = rgba_sum + (rgba * error_weight);\n@@ -1676,7 +1676,7 @@ void recompute_ideal_colors_1plane(\n{\nint tix = texel_indexes[j];\n- vfloat4 rgba(pb->data_r[tix], pb->data_g[tix], pb->data_b[tix], pb->data_a[tix]);\n+ vfloat4 rgba = pb->texel(tix);\nvfloat4 color_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\nfloat3 color_weight3 = color_weight.swz<0, 1, 2>();\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -118,7 +118,7 @@ void imageblock_initialize_deriv(\n// compute derivatives for RGB first\nif (pb->rgb_lns[i])\n{\n- float3 fdata = float3(pb->data_r[i], pb->data_g[i], pb->data_b[i]);\n+ float3 fdata = pb->texel3(i);\nfdata.r = sf16_to_float(lns_to_sf16((uint16_t)fdata.r));\nfdata.g = sf16_to_float(lns_to_sf16((uint16_t)fdata.g));\nfdata.b = sf16_to_float(lns_to_sf16((uint16_t)fdata.b));\n@@ -161,8 +161,7 @@ void imageblock_initialize_work_from_orig(\nimageblock* pb,\nint pixelcount\n) {\n- pb->origin_texel = vfloat4(pb->data_r[0], pb->data_g[0],\n- pb->data_b[0], pb->data_a[0]);\n+ pb->origin_texel = pb->texel(0);\nvfloat4 data_min(1e38f);\nvfloat4 data_max(-1e38f);\n@@ -170,8 +169,7 @@ void imageblock_initialize_work_from_orig(\nfor (int i = 0; i < pixelcount; i++)\n{\n- vfloat4 data = vfloat4(pb->data_r[i], pb->data_g[i],\n- pb->data_b[i], pb->data_a[i]);\n+ vfloat4 data = pb->texel(i);\nif (pb->rgb_lns[i])\n{\n@@ -228,8 +226,7 @@ void imageblock_initialize_orig_from_work(\nfor (int i = 0; i < pixelcount; i++)\n{\n- vfloat4 data = vfloat4(pb->data_r[i], pb->data_g[i],\n- pb->data_b[i], pb->data_a[i]);\n+ vfloat4 data = pb->texel(i);\nif (pb->rgb_lns[i])\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -506,8 +506,24 @@ struct imageblock\nuint8_t alpha_lns[MAX_TEXELS_PER_BLOCK]; // 1 if Alpha data are being treated as LNS\nuint8_t nan_texel[MAX_TEXELS_PER_BLOCK]; // 1 if the texel is a NaN-texel.\nint xpos, ypos, zpos;\n+\n+ inline vfloat4 texel(int index) const\n+ {\n+ return vfloat4(data_r[index],\n+ data_g[index],\n+ data_b[index],\n+ data_a[index]);\n+ }\n+\n+ inline float3 texel3(int index) const\n+ {\n+ return float3(data_r[index],\n+ data_g[index],\n+ data_b[index]);\n+ }\n};\n+\nstatic inline int imageblock_uses_alpha(const imageblock * pb)\n{\nreturn pb->data_min.lane<3>() != pb->data_max.lane<3>();\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_kmeans_partitioning.cpp", "new_path": "Source/astcenc_kmeans_partitioning.cpp", "diff": "@@ -52,18 +52,12 @@ static void kmeans_init(\n// compute the distance to the first point.\nint sample = cluster_center_samples[0];\n- vfloat4 center_color = vfloat4(blk->data_r[sample],\n- blk->data_g[sample],\n- blk->data_b[sample],\n- blk->data_a[sample]);\n+ vfloat4 center_color = blk->texel(sample);\nfloat distance_sum = 0.0f;\nfor (int i = 0; i < texels_per_block; i++)\n{\n- vfloat4 color = vfloat4(blk->data_r[i],\n- blk->data_g[i],\n- blk->data_b[i],\n- blk->data_a[i]);\n+ vfloat4 color = blk->texel(i);\nvfloat4 diff = color - center_color;\nfloat distance = dot_s(diff, diff);\ndistance_sum += distance;\n@@ -106,18 +100,12 @@ static void kmeans_init(\n}\n// update the distances with the new point.\n- center_color = vfloat4(blk->data_r[sample],\n- blk->data_g[sample],\n- blk->data_b[sample],\n- blk->data_a[sample]);\n+ center_color = blk->texel(sample);;\ndistance_sum = 0.0f;\nfor (int i = 0; i < texels_per_block; i++)\n{\n- vfloat4 color = vfloat4(blk->data_r[i],\n- blk->data_g[i],\n- blk->data_b[i],\n- blk->data_a[i]);\n+ vfloat4 color = blk->texel(i);\nvfloat4 diff = color - center_color;\nfloat distance = dot_s(diff, diff);\ndistance = astc::min(distance, distances[i]);\n@@ -130,11 +118,7 @@ static void kmeans_init(\nfor (int i = 0; i < partition_count; i++)\n{\nint center_sample = cluster_center_samples[i];\n- vfloat4 color = vfloat4(blk->data_r[center_sample],\n- blk->data_g[center_sample],\n- blk->data_b[center_sample],\n- blk->data_a[center_sample]);\n- cluster_centers[i] = color;\n+ cluster_centers[i] = blk->texel(center_sample);\n}\n}\n@@ -159,10 +143,7 @@ static void kmeans_assign(\nfor (int i = 0; i < texels_per_block; i++)\n{\n- vfloat4 color = vfloat4(blk->data_r[i],\n- blk->data_g[i],\n- blk->data_b[i],\n- blk->data_a[i]);\n+ vfloat4 color = blk->texel(i);\nvfloat4 diff = color - cluster_centers[0];\nfloat distance = dot_s(diff, diff);\ndistances[i] = distance;\n@@ -175,10 +156,7 @@ static void kmeans_assign(\nfor (int i = 0; i < texels_per_block; i++)\n{\n- vfloat4 color = vfloat4(blk->data_r[i],\n- blk->data_g[i],\n- blk->data_b[i],\n- blk->data_a[i]);\n+ vfloat4 color = blk->texel(i);\nvfloat4 diff = color - center_color;\nfloat distance = dot_s(diff, diff);\nif (distance < distances[i])\n@@ -235,10 +213,7 @@ static void kmeans_update(\n// first, find the center-of-gravity in each cluster\nfor (int i = 0; i < texels_per_block; i++)\n{\n- vfloat4 color = vfloat4(blk->data_r[i],\n- blk->data_g[i],\n- blk->data_b[i],\n- blk->data_a[i]);\n+ vfloat4 color = blk->texel(i);\nint part = partition_of_texel[i];\ncolor_sum[part] = color_sum[part] + color;\nweight_sum[part]++;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add accessor for fetching block texels
61,745
12.02.2021 21:40:53
0
431c5d1e217d3a13083526b2deeeb0805d178458
Make init_orig_from_work static
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -157,7 +157,7 @@ void imageblock_initialize_deriv(\n}\n// helper function to initialize the work-data from the orig-data\n-void imageblock_initialize_work_from_orig(\n+static void imageblock_initialize_work_from_orig(\nimageblock* pb,\nint pixelcount\n) {\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -547,10 +547,6 @@ void imageblock_initialize_orig_from_work(\nimageblock * pb,\nint pixelcount);\n-void imageblock_initialize_work_from_orig(\n- imageblock * pb,\n- int pixelcount);\n-\n/*\nData structure representing error weighting for one block of an image. this is used as\na multiplier for the error weight to apply to each color component when computing PSNR.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make init_orig_from_work static
61,745
12.02.2021 21:44:29
0
8c26c7bafb8d33783074e967258a922e1f54939f
Image address calcs only need min() not clamp()
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -305,16 +305,16 @@ void fetch_imageblock(\nfor (int z = 0; z < bsd->zdim; z++)\n{\n- int zi = astc::clamp(zpos + z, 0, zsize - 1);\n+ int zi = astc::min(zpos + z, zsize - 1);\nuint8_t* data8 = static_cast<uint8_t*>(img.data[zi]);\nfor (int y = 0; y < bsd->ydim; y++)\n{\n- int yi = astc::clamp(ypos + y, 0, ysize - 1);\n+ int yi = astc::min(ypos + y, ysize - 1);\nfor (int x = 0; x < bsd->xdim; x++)\n{\n- int xi = astc::clamp(xpos + x, 0, xsize - 1);\n+ int xi = astc::min(xpos + x, xsize - 1);\nint r = data8[(4 * xsize * yi) + (4 * xi )];\nint g = data8[(4 * xsize * yi) + (4 * xi + 1)];\n@@ -351,16 +351,16 @@ void fetch_imageblock(\nfor (int z = 0; z < bsd->zdim; z++)\n{\n- int zi = astc::clamp(zpos + z, 0, zsize - 1);\n+ int zi = astc::min(zpos + z, zsize - 1);\nuint16_t* data16 = static_cast<uint16_t*>(img.data[zi]);\nfor (int y = 0; y < bsd->ydim; y++)\n{\n- int yi = astc::clamp(ypos + y, 0, ysize - 1);\n+ int yi = astc::min(ypos + y, ysize - 1);\nfor (int x = 0; x < bsd->xdim; x++)\n{\n- int xi = astc::clamp(xpos + x, 0, xsize - 1);\n+ int xi = astc::min(xpos + x, xsize - 1);\nint r = data16[(4 * xsize * yi) + (4 * xi )];\nint g = data16[(4 * xsize * yi) + (4 * xi + 1)];\n@@ -399,16 +399,16 @@ void fetch_imageblock(\nfor (int z = 0; z < bsd->zdim; z++)\n{\n- int zi = astc::clamp(zpos + z, 0, zsize - 1);\n+ int zi = astc::min(zpos + z, zsize - 1);\nfloat* data32 = static_cast<float*>(img.data[zi]);\nfor (int y = 0; y < bsd->ydim; y++)\n{\n- int yi = astc::clamp(ypos + y, 0, ysize - 1);\n+ int yi = astc::min(ypos + y, ysize - 1);\nfor (int x = 0; x < bsd->xdim; x++)\n{\n- int xi = astc::clamp(xpos + x, 0, xsize - 1);\n+ int xi = astc::min(xpos + x, xsize - 1);\nfloat r = data32[(4 * xsize * yi) + (4 * xi )];\nfloat g = data32[(4 * xsize * yi) + (4 * xi + 1)];\n@@ -484,7 +484,7 @@ void write_imageblock(\n{\nfor (int z = 0; z < bsd->zdim; z++)\n{\n- int zc = astc::clamp(zpos + z, 0, zsize - 1);\n+ int zc = astc::min(zpos + z, zsize - 1);\nuint8_t* data8 = static_cast<uint8_t*>(img.data[zc]);\nfor (int y = 0; y < bsd->ydim; y++)\n@@ -554,7 +554,7 @@ void write_imageblock(\n{\nfor (int z = 0; z < bsd->zdim; z++)\n{\n- int zc = astc::clamp(zpos + z, 0, zsize - 1);\n+ int zc = astc::min(zpos + z, zsize - 1);\nuint16_t* data16 = static_cast<uint16_t*>(img.data[zc]);\nfor (int y = 0; y < bsd->ydim; y++)\n@@ -625,7 +625,7 @@ void write_imageblock(\nfor (int z = 0; z < bsd->zdim; z++)\n{\n- int zc = astc::clamp(zpos + z, 0, zsize - 1);\n+ int zc = astc::min(zpos + z, zsize - 1);\nfloat* data32 = static_cast<float*>(img.data[zc]);\nfor (int y = 0; y < bsd->ydim; y++)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Image address calcs only need min() not clamp()
61,745
12.02.2021 22:49:52
0
e4e4e878548bc2c7a43a4bc95c73d6fd20a81986
Use selects not branches
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -274,25 +274,8 @@ static float compress_symbolic_block_fixed_partition_1_plane(\nvfloat4 ep = (vfloat4(1.0f) - ei->ep.endpt0[i]) / (ei->ep.endpt1[i] - ei->ep.endpt0[i]);\n- if (ep.lane<0>() > 0.5f && ep.lane<0>() < min_ep.lane<0>())\n- {\n- min_ep.set_lane<0>(ep.lane<0>());\n- }\n-\n- if (ep.lane<1>() > 0.5f && ep.lane<1>() < min_ep.lane<1>())\n- {\n- min_ep.set_lane<1>(ep.lane<1>());\n- }\n-\n- if (ep.lane<2>() > 0.5f && ep.lane<2>() < min_ep.lane<2>())\n- {\n- min_ep.set_lane<2>(ep.lane<2>());\n- }\n-\n- if (ep.lane<3>() > 0.5f && ep.lane<3>() < min_ep.lane<3>())\n- {\n- min_ep.set_lane<3>(ep.lane<3>());\n- }\n+ vmask4 use_ep = (ep > vfloat4(0.5f)) & (ep < min_ep);\n+ min_ep = select(min_ep, ep, use_ep);\n#ifdef DEBUG_CAPTURE_NAN\nfeenableexcept(FE_DIVBYZERO | FE_INVALID);\n@@ -650,48 +633,12 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n#endif\nvfloat4 ep1 = (vfloat4(1.0f) - ei1->ep.endpt0[i]) / (ei1->ep.endpt1[i] - ei1->ep.endpt0[i]);\n-\n- if (ep1.lane<0>() > 0.5f && ep1.lane<0>() < min_ep1.lane<0>())\n- {\n- min_ep1.set_lane<0>(ep1.lane<0>());\n- }\n-\n- if (ep1.lane<1>() > 0.5f && ep1.lane<1>() < min_ep1.lane<1>())\n- {\n- min_ep1.set_lane<1>(ep1.lane<1>());\n- }\n-\n- if (ep1.lane<2>() > 0.5f && ep1.lane<2>() < min_ep1.lane<2>())\n- {\n- min_ep1.set_lane<2>(ep1.lane<2>());\n- }\n-\n- if (ep1.lane<3>() > 0.5f && ep1.lane<3>() < min_ep1.lane<3>())\n- {\n- min_ep1.set_lane<3>(ep1.lane<3>());\n- }\n+ vmask4 use_ep1 = (ep1 > vfloat4(0.5f)) & (ep1 < min_ep1);\n+ min_ep1 = select(min_ep1, ep1, use_ep1);\nvfloat4 ep2 = (vfloat4(1.0f) - ei2->ep.endpt0[i]) / (ei2->ep.endpt1[i] - ei2->ep.endpt0[i]);\n-\n- if (ep2.lane<0>() > 0.5f && ep2.lane<0>() < min_ep2.lane<0>())\n- {\n- min_ep2.set_lane<0>(ep2.lane<0>());\n- }\n-\n- if (ep2.lane<1>() > 0.5f && ep2.lane<1>() < min_ep2.lane<1>())\n- {\n- min_ep2.set_lane<1>(ep2.lane<1>());\n- }\n-\n- if (ep2.lane<2>() > 0.5f && ep2.lane<2>() < min_ep2.lane<2>())\n- {\n- min_ep2.set_lane<2>(ep2.lane<2>());\n- }\n-\n- if (ep2.lane<3>() > 0.5f && ep2.lane<3>() < min_ep2.lane<3>())\n- {\n- min_ep2.set_lane<3>(ep2.lane<3>());\n- }\n+ vmask4 use_ep2 = (ep2 > vfloat4(0.5f)) & (ep2 < min_ep2);\n+ min_ep2 = select(min_ep2, ep2, use_ep2);\n#ifdef DEBUG_CAPTURE_NAN\nfeenableexcept(FE_DIVBYZERO | FE_INVALID);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use selects not branches
61,745
12.02.2021 23:10:38
0
780678cf9694b4972b6f1c653e6fe2a8b68bb927
Use selects in csb_fixed_part_2_planes
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -645,30 +645,16 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n#endif\n}\n- float min_wt_cutoff1, min_wt_cutoff2;\n- switch (separate_component)\n- {\n- case 0:\n- min_wt_cutoff2 = min_ep2.lane<0>();\n- min_ep1.set_lane<0>(1e30f);\n- break;\n- case 1:\n- min_wt_cutoff2 = min_ep2.lane<1>();\n- min_ep1.set_lane<1>(1e30f);\n- break;\n- case 2:\n- min_wt_cutoff2 = min_ep2.lane<2>();\n- min_ep1.set_lane<2>(1e30f);\n- break;\n- case 3:\n- min_wt_cutoff2 = min_ep2.lane<3>();\n- min_ep1.set_lane<3>(1e30f);\n- break;\n- default:\n- min_wt_cutoff2 = 1e30f;\n- }\n+ vfloat4 err_max(1e30f);\n+ vmask4 err_mask = vint4::lane_id() == vint4(separate_component);\n+\n+ // Set the separate component to max error in ep1\n+ min_ep1 = select(min_ep1, err_max, err_mask);\n+\n+ float min_wt_cutoff1 = hmin_s(min_ep1);\n- min_wt_cutoff1 = hmin_s(min_ep1);\n+ // Set the minwt2 to the separate component min in ep2\n+ float min_wt_cutoff2 = hmin_s(select(err_max, min_ep2, err_mask));\nfloat weight_low_value1[MAX_WEIGHT_MODES];\nfloat weight_high_value1[MAX_WEIGHT_MODES];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -95,8 +95,6 @@ struct vfloat4\n/**\n* @brief Get the scalar value of a single lane.\n- *\n- * TODO: Can we do better for lane0, which is the common case for VLA?\n*/\ntemplate <int l> ASTCENC_SIMD_INLINE float lane() const\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use selects in csb_fixed_part_2_planes
61,745
12.02.2021 23:11:07
0
cb2e68e8d68498005aabfd0a1b53b0baf7f1b1f5
Use default in swtch for smaller code
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -73,7 +73,7 @@ static void compute_endpoints_and_ideal_weights_1_component(\nerror_weights = ewb->texel_weight_b;\ndata_vr = blk->data_b;\nbreak;\n- case 3:\n+ default:\nerror_weights = ewb->texel_weight_a;\ndata_vr = blk->data_a;\nbreak;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use default in swtch for smaller code
61,745
12.02.2021 23:22:05
0
12a39c101feeb3b6a8883e5076bb9c7ce572ab01
Vectorize merge_endpoints
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -49,43 +49,14 @@ void merge_endpoints(\nendpoints * res\n) {\nint partition_count = ep1->partition_count;\n- res->partition_count = partition_count;\n- for (int i = 0; i < partition_count; i++)\n- {\n- res->endpt0[i] = ep1->endpt0[i];\n- res->endpt1[i] = ep1->endpt1[i];\n- }\n+ vmask4 sep_mask = vint4::lane_id() == vint4(separate_component);\n- switch (separate_component)\n- {\n- case 0:\n- for (int i = 0; i < partition_count; i++)\n- {\n- res->endpt0[i].set_lane<0>(ep2->endpt0[i].lane<0>());\n- res->endpt1[i].set_lane<0>(ep2->endpt1[i].lane<0>());\n- }\n- break;\n- case 1:\n- for (int i = 0; i < partition_count; i++)\n- {\n- res->endpt0[i].set_lane<1>(ep2->endpt0[i].lane<1>());\n- res->endpt1[i].set_lane<1>(ep2->endpt1[i].lane<1>());\n- }\n- break;\n- case 2:\n- for (int i = 0; i < partition_count; i++)\n- {\n- res->endpt0[i].set_lane<2>(ep2->endpt0[i].lane<2>());\n- res->endpt1[i].set_lane<2>(ep2->endpt1[i].lane<2>());\n- }\n- break;\n- case 3:\n+ res->partition_count = partition_count;\n+ promise(partition_count > 0);\nfor (int i = 0; i < partition_count; i++)\n{\n- res->endpt0[i].set_lane<3>(ep2->endpt0[i].lane<3>());\n- res->endpt1[i].set_lane<3>(ep2->endpt1[i].lane<3>());\n- }\n- break;\n+ res->endpt0[i] = select(ep1->endpt0[i], ep2->endpt0[i], sep_mask);\n+ res->endpt1[i] = select(ep1->endpt1[i], ep2->endpt1[i], sep_mask);\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Vectorize merge_endpoints
61,745
12.02.2021 23:36:14
0
9a6fc1a8831042d9512c45a00bc194f7db72db7c
Avoid using set_lane in find_best_partitioning
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -374,12 +374,12 @@ void find_best_partitionings(\nuncorr_error += dot_s(uncorr_vector, error_weights);\nsamechroma_error += dot_s(samechroma_vector, error_weights);\n- separate_error.set_lane<0>(separate_error.lane<0>() + dot(separate_red_vector, error_weights.swz<1, 2, 3>()));\n- separate_error.set_lane<1>(separate_error.lane<1>() + dot(separate_green_vector, error_weights.swz<0, 2, 3>()));\n- separate_error.set_lane<2>(separate_error.lane<2>() + dot(separate_blue_vector, error_weights.swz<0, 1, 3>()));\n- separate_error.set_lane<3>(separate_error.lane<3>() + dot(separate_alpha_vector, error_weights.swz<0, 1, 2>()));\n+ vfloat4 sep_err_inc(dot(separate_red_vector, error_weights.swz<1, 2, 3>()),\n+ dot(separate_green_vector, error_weights.swz<0, 2, 3>()),\n+ dot(separate_blue_vector, error_weights.swz<0, 1, 3>()),\n+ dot(separate_alpha_vector, error_weights.swz<0, 1, 2>()));\n- separate_error = separate_error + rgba_range[j] * rgba_range[j] * error_weights;\n+ separate_error = separate_error + sep_err_inc + (rgba_range[j] * rgba_range[j] * error_weights);\n}\nif (uncorr_error < uncorr_best_error)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Avoid using set_lane in find_best_partitioning
61,745
12.02.2021 23:36:38
0
3bc7d20d6c0d622673405211889dcca2b9778690
Vectorize preamble in quantize_hdr_rgb3
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -1188,14 +1188,9 @@ static void quantize_hdr_rgb3(\nint output[6],\nint quant_level\n) {\n- // TODO: If lane 3/a not used, vectorize this ...\n- color0.set_lane<0>(astc::clamp(color0.lane<0>(), 0.0f, 65535.0f));\n- color0.set_lane<1>(astc::clamp(color0.lane<1>(), 0.0f, 65535.0f));\n- color0.set_lane<2>(astc::clamp(color0.lane<2>(), 0.0f, 65535.0f));\n-\n- color1.set_lane<0>(astc::clamp(color1.lane<0>(), 0.0f, 65535.0f));\n- color1.set_lane<1>(astc::clamp(color1.lane<1>(), 0.0f, 65535.0f));\n- color1.set_lane<2>(astc::clamp(color1.lane<2>(), 0.0f, 65535.0f));\n+ // Note: color*.lane<3> is not used so we can ignore it\n+ color0 = clamp(0.0f, 65535.0f, color0);\n+ color1 = clamp(0.0f, 65535.0f, color1);\nvfloat4 color0_bak = color0;\nvfloat4 color1_bak = color1;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Vectorize preamble in quantize_hdr_rgb3
61,745
13.02.2021 00:17:12
0
3cce953c0066b57375ce8846ea511d82da3743da
Replace channel switches with conditional selects.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -120,31 +120,11 @@ static void compute_endpoints_and_ideal_weights_1_component(\nassert(!astc::isnan(ei->weight_error_scale[i]));\n}\n+ vmask4 sep_mask = vint4::lane_id() == vint4(component);\nfor (int i = 0; i < partition_count; i++)\n{\n- ei->ep.endpt0[i] = blk->data_min;\n- ei->ep.endpt1[i] = blk->data_max;\n-\n- assert(component < 4);\n- switch (component)\n- {\n- case 0: // red/x\n- ei->ep.endpt0[i].set_lane<0>(lowvalues[i]);\n- ei->ep.endpt1[i].set_lane<0>(highvalues[i]);\n- break;\n- case 1: // green/y\n- ei->ep.endpt0[i].set_lane<1>(lowvalues[i]);\n- ei->ep.endpt1[i].set_lane<1>(highvalues[i]);\n- break;\n- case 2: // blue/z\n- ei->ep.endpt0[i].set_lane<2>(lowvalues[i]);\n- ei->ep.endpt1[i].set_lane<2>(highvalues[i]);\n- break;\n- default: // alpha/w\n- ei->ep.endpt0[i].set_lane<3>(lowvalues[i]);\n- ei->ep.endpt1[i].set_lane<3>(highvalues[i]);\n- break;\n- }\n+ ei->ep.endpt0[i] = select(blk->data_min, vfloat4(lowvalues[i]), sep_mask);\n+ ei->ep.endpt1[i] = select(blk->data_max, vfloat4(highvalues[i]), sep_mask);\n}\n}\n@@ -317,55 +297,15 @@ static void compute_endpoints_and_ideal_weights_2_components(\nhighvalues[i] = ep1;\n}\n+ vmask4 comp1_mask = vint4::lane_id() == vint4(component1);\n+ vmask4 comp2_mask = vint4::lane_id() == vint4(component2);\nfor (int i = 0; i < partition_count; i++)\n{\n- ei->ep.endpt0[i] = blk->data_min;\n- ei->ep.endpt1[i] = blk->data_max;\n-\n- float2 ep0 = lowvalues[i];\n- float2 ep1 = highvalues[i];\n-\n- assert(component1 < 4);\n- switch (component1)\n- {\n- case 0:\n- ei->ep.endpt0[i].set_lane<0>(ep0.r);\n- ei->ep.endpt1[i].set_lane<0>(ep1.r);\n- break;\n- case 1:\n- ei->ep.endpt0[i].set_lane<1>(ep0.r);\n- ei->ep.endpt1[i].set_lane<1>(ep1.r);\n- break;\n- case 2:\n- ei->ep.endpt0[i].set_lane<2>(ep0.r);\n- ei->ep.endpt1[i].set_lane<2>(ep1.r);\n- break;\n- default:\n- ei->ep.endpt0[i].set_lane<3>(ep0.r);\n- ei->ep.endpt1[i].set_lane<3>(ep1.r);\n- break;\n- }\n+ vfloat4 ep0 = select(blk->data_min, vfloat4(lowvalues[i].r), comp1_mask);\n+ vfloat4 ep1 = select(blk->data_max, vfloat4(highvalues[i].r), comp1_mask);\n- assert(component2 < 4);\n- switch (component2)\n- {\n- case 0:\n- ei->ep.endpt0[i].set_lane<0>(ep0.g);\n- ei->ep.endpt1[i].set_lane<0>(ep1.g);\n- break;\n- case 1:\n- ei->ep.endpt0[i].set_lane<1>(ep0.g);\n- ei->ep.endpt1[i].set_lane<1>(ep1.g);\n- break;\n- case 2:\n- ei->ep.endpt0[i].set_lane<2>(ep0.g);\n- ei->ep.endpt1[i].set_lane<2>(ep1.g);\n- break;\n- default:\n- ei->ep.endpt0[i].set_lane<3>(ep0.g);\n- ei->ep.endpt1[i].set_lane<3>(ep1.g);\n- break;\n- }\n+ ei->ep.endpt0[i] = select(ep0, vfloat4(lowvalues[i].g), comp2_mask);\n+ ei->ep.endpt1[i] = select(ep1, vfloat4(highvalues[i].g), comp2_mask);\n}\nfor (int i = 0; i < texel_count; i++)\n@@ -1406,29 +1346,12 @@ void recompute_ideal_colors_2planes(\n// of all colors in the partition and use that as both endpoint colors.\nvfloat4 avg = (color_vec_x + color_vec_y) * (1.0f / rgba_weight_sum);\n- if (plane2_color_component != 0 && avg.lane<0>() == avg.lane<0>())\n- {\n- ep->endpt0[i].set_lane<0>(avg.lane<0>());\n- ep->endpt1[i].set_lane<0>(avg.lane<0>());\n- }\n-\n- if (plane2_color_component != 1 && avg.lane<1>() == avg.lane<1>())\n- {\n- ep->endpt0[i].set_lane<1>(avg.lane<1>());\n- ep->endpt1[i].set_lane<1>(avg.lane<1>());\n- }\n+ vmask4 p1_mask = vint4::lane_id() != vint4(plane2_color_component);\n+ vmask4 notnan_mask = avg == avg;\n+ vmask4 full_mask = p1_mask & notnan_mask;\n- if (plane2_color_component != 2 && avg.lane<2>() == avg.lane<2>())\n- {\n- ep->endpt0[i].set_lane<2>(avg.lane<2>());\n- ep->endpt1[i].set_lane<2>(avg.lane<2>());\n- }\n-\n- if (plane2_color_component != 3 && avg.lane<3>() == avg.lane<3>())\n- {\n- ep->endpt0[i].set_lane<3>(avg.lane<3>());\n- ep->endpt1[i].set_lane<3>(avg.lane<3>());\n- }\n+ ep->endpt0[i] = select(ep->endpt0[i], avg, full_mask);\n+ ep->endpt1[i] = select(ep->endpt1[i], avg, full_mask);\nrgbs_vectors[i] = vfloat4(sds.r, sds.g, sds.b, 1.0f);\n}\n@@ -1461,33 +1384,13 @@ void recompute_ideal_colors_2planes(\nfloat scale_ep0 = (lmrs_sum.b * scale_vec.r - lmrs_sum.g * scale_vec.g) * ls_rdet1;\nfloat scale_ep1 = (lmrs_sum.r * scale_vec.g - lmrs_sum.g * scale_vec.r) * ls_rdet1;\n- if (plane2_color_component != 0 && fabsf(color_det1.lane<0>()) > (color_mss1.lane<0>() * 1e-4f) &&\n- ep0.lane<0>() == ep0.lane<0>() && ep1.lane<0>() == ep1.lane<0>())\n- {\n- ep->endpt0[i].set_lane<0>(ep0.lane<0>());\n- ep->endpt1[i].set_lane<0>(ep1.lane<0>());\n- }\n-\n- if (plane2_color_component != 1 && fabsf(color_det1.lane<1>()) > (color_mss1.lane<1>() * 1e-4f) &&\n- ep0.lane<1>() == ep0.lane<1>() && ep1.lane<1>() == ep1.lane<1>())\n- {\n- ep->endpt0[i].set_lane<1>(ep0.lane<1>());\n- ep->endpt1[i].set_lane<1>(ep1.lane<1>());\n- }\n-\n- if (plane2_color_component != 2 && fabsf(color_det1.lane<2>()) > (color_mss1.lane<2>() * 1e-4f) &&\n- ep0.lane<2>() == ep0.lane<2>() && ep1.lane<2>() == ep1.lane<2>())\n- {\n- ep->endpt0[i].set_lane<2>(ep0.lane<2>());\n- ep->endpt1[i].set_lane<2>(ep1.lane<2>());\n- }\n+ vmask4 p1_mask = vint4::lane_id() != vint4(plane2_color_component);\n+ vmask4 det_mask = abs(color_det1) > (color_mss1 * 1e-4f);\n+ vmask4 notnan_mask = ep0 == ep0 & ep1 == ep1;\n+ vmask4 full_mask = p1_mask & det_mask & notnan_mask;\n- if (plane2_color_component != 3 && fabsf(color_det1.lane<3>()) > (color_mss1.lane<3>() * 1e-4f) &&\n- ep0.lane<3>() == ep0.lane<3>() && ep1.lane<3>() == ep1.lane<3>())\n- {\n- ep->endpt0[i].set_lane<3>(ep0.lane<3>());\n- ep->endpt1[i].set_lane<3>(ep1.lane<3>());\n- }\n+ ep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);\n+ ep->endpt1[i] = select(ep->endpt1[i], ep1, full_mask);\nif (fabsf(ls_det1) > (ls_mss1 * 1e-4f) && scale_ep0 == scale_ep0 && scale_ep1 == scale_ep1 && scale_ep0 < scale_ep1)\n{\n@@ -1509,29 +1412,12 @@ void recompute_ideal_colors_2planes(\n// of all colors in the partition and use that as both endpoint colors.\nvfloat4 avg = (color_vec_x + color_vec_y) * (1.0f / rgba_weight_sum);\n- if (plane2_color_component == 0 && avg.lane<0>() == avg.lane<0>())\n- {\n- ep->endpt0[i].set_lane<0>(avg.lane<0>());\n- ep->endpt1[i].set_lane<0>(avg.lane<0>());\n- }\n-\n- if (plane2_color_component == 1 && avg.lane<1>() == avg.lane<1>())\n- {\n- ep->endpt0[i].set_lane<1>(avg.lane<1>());\n- ep->endpt1[i].set_lane<1>(avg.lane<1>());\n- }\n+ vmask4 p2_mask = vint4::lane_id() == vint4(plane2_color_component);\n+ vmask4 notnan_mask = avg == avg;\n+ vmask4 full_mask = p2_mask & notnan_mask;\n- if (plane2_color_component == 2 && avg.lane<2>() == avg.lane<2>())\n- {\n- ep->endpt0[i].set_lane<2>(avg.lane<2>());\n- ep->endpt1[i].set_lane<2>(avg.lane<2>());\n- }\n-\n- if (plane2_color_component == 3 && avg.lane<3>() == avg.lane<3>())\n- {\n- ep->endpt0[i].set_lane<3>(avg.lane<3>());\n- ep->endpt1[i].set_lane<3>(avg.lane<3>());\n- }\n+ ep->endpt0[i] = select(ep->endpt0[i], avg, full_mask);\n+ ep->endpt1[i] = select(ep->endpt1[i], avg, full_mask);\n}\nelse\n{\n@@ -1551,33 +1437,13 @@ void recompute_ideal_colors_2planes(\nvfloat4 ep0 = (right2_sum * color_vec_x - middle2_sum * color_vec_y) * color_rdet2;\nvfloat4 ep1 = (left2_sum * color_vec_y - middle2_sum * color_vec_x) * color_rdet2;\n- if (plane2_color_component == 0 && fabsf(color_det2.lane<0>()) > (color_mss2.lane<0>() * 1e-4f) &&\n- ep0.lane<0>() == ep0.lane<0>() && ep1.lane<0>() == ep1.lane<0>())\n- {\n- ep->endpt0[i].set_lane<0>(ep0.lane<0>());\n- ep->endpt1[i].set_lane<0>(ep1.lane<0>());\n- }\n-\n- if (plane2_color_component == 1 && fabsf(color_det2.lane<1>()) > (color_mss2.lane<1>() * 1e-4f) &&\n- ep0.lane<1>() == ep0.lane<1>() && ep1.lane<1>() == ep1.lane<1>())\n- {\n- ep->endpt0[i].set_lane<1>(ep0.lane<1>());\n- ep->endpt1[i].set_lane<1>(ep1.lane<1>());\n- }\n-\n- if (plane2_color_component == 2 && fabsf(color_det2.lane<2>()) > (color_mss2.lane<2>() * 1e-4f) &&\n- ep0.lane<2>() == ep0.lane<2>() && ep1.lane<2>() == ep1.lane<2>())\n- {\n- ep->endpt0[i].set_lane<2>(ep0.lane<2>());\n- ep->endpt1[i].set_lane<2>(ep1.lane<2>());\n- }\n+ vmask4 p2_mask = vint4::lane_id() == vint4(plane2_color_component);\n+ vmask4 det_mask = abs(color_det2) > (color_mss2 * 1e-4f);\n+ vmask4 notnan_mask = ep0 == ep0 & ep1 == ep1;\n+ vmask4 full_mask = p2_mask & det_mask & notnan_mask;\n- if (plane2_color_component == 3 && fabsf(color_det2.lane<3>()) > (color_mss2.lane<3>() * 1e-4f) &&\n- ep0.lane<3>() == ep0.lane<3>() && ep1.lane<3>() == ep1.lane<3>())\n- {\n- ep->endpt0[i].set_lane<3>(ep0.lane<3>());\n- ep->endpt1[i].set_lane<3>(ep1.lane<3>());\n- }\n+ ep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);\n+ ep->endpt1[i] = select(ep->endpt1[i], ep1, full_mask);\n#ifdef DEBUG_CAPTURE_NAN\nfeenableexcept(FE_DIVBYZERO | FE_INVALID);\n@@ -1775,29 +1641,9 @@ void recompute_ideal_colors_1plane(\n// of all colors in the partition and use that as both endpoint colors.\nvfloat4 avg = (color_vec_x + color_vec_y) * (1.0f / rgba_weight_sum);\n- if (avg.lane<0>() == avg.lane<0>())\n- {\n- ep->endpt0[i].set_lane<0>(avg.lane<0>());\n- ep->endpt1[i].set_lane<0>(avg.lane<0>());\n- }\n-\n- if (avg.lane<1>() == avg.lane<1>())\n- {\n- ep->endpt0[i].set_lane<1>(avg.lane<1>());\n- ep->endpt1[i].set_lane<1>(avg.lane<1>());\n- }\n-\n- if (avg.lane<2>() == avg.lane<2>())\n- {\n- ep->endpt0[i].set_lane<2>(avg.lane<2>());\n- ep->endpt1[i].set_lane<2>(avg.lane<2>());\n- }\n-\n- if (avg.lane<3>() == avg.lane<3>())\n- {\n- ep->endpt0[i].set_lane<3>(avg.lane<3>());\n- ep->endpt1[i].set_lane<3>(avg.lane<3>());\n- }\n+ vmask4 notnan_mask = avg == avg;\n+ ep->endpt0[i] = select(ep->endpt0[i], avg, notnan_mask);\n+ ep->endpt1[i] = select(ep->endpt1[i], avg, notnan_mask);\nrgbs_vectors[i] = vfloat4(sds.r, sds.g, sds.b, 1.0f);\n}\n@@ -1827,36 +1673,15 @@ void recompute_ideal_colors_1plane(\nvfloat4 ep0 = (right_sum * color_vec_x - middle_sum * color_vec_y) * color_rdet1;\nvfloat4 ep1 = (left_sum * color_vec_y - middle_sum * color_vec_x) * color_rdet1;\n- float scale_ep0 = (lmrs_sum.b * scale_vec.r - lmrs_sum.g * scale_vec.g) * ls_rdet1;\n- float scale_ep1 = (lmrs_sum.r * scale_vec.g - lmrs_sum.g * scale_vec.r) * ls_rdet1;\n-\n- if (fabsf(color_det1.lane<0>()) > (color_mss1.lane<0>() * 1e-4f) &&\n- ep0.lane<0>() == ep0.lane<0>() && ep1.lane<0>() == ep1.lane<0>())\n- {\n- ep->endpt0[i].set_lane<0>(ep0.lane<0>());\n- ep->endpt1[i].set_lane<0>(ep1.lane<0>());\n- }\n-\n- if (fabsf(color_det1.lane<1>()) > (color_mss1.lane<1>() * 1e-4f) &&\n- ep0.lane<1>() == ep0.lane<1>() && ep1.lane<1>() == ep1.lane<1>())\n- {\n- ep->endpt0[i].set_lane<1>(ep0.lane<1>());\n- ep->endpt1[i].set_lane<1>(ep1.lane<1>());\n- }\n+ vmask4 det_mask = abs(color_det1) > (color_mss1 * 1e-4f);\n+ vmask4 notnan_mask = ep0 == ep0 & ep1 == ep1;\n+ vmask4 full_mask = det_mask & notnan_mask;\n- if (fabsf(color_det1.lane<2>()) > (color_mss1.lane<2>() * 1e-4f) &&\n- ep0.lane<2>() == ep0.lane<2>() && ep1.lane<2>() == ep1.lane<2>())\n- {\n- ep->endpt0[i].set_lane<2>(ep0.lane<2>());\n- ep->endpt1[i].set_lane<2>(ep1.lane<2>());\n- }\n+ ep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);\n+ ep->endpt1[i] = select(ep->endpt1[i], ep1, full_mask);\n- if (fabsf(color_det1.lane<3>()) > (color_mss1.lane<3>() * 1e-4f) &&\n- ep0.lane<3>() == ep0.lane<3>() && ep1.lane<3>() == ep1.lane<3>())\n- {\n- ep->endpt0[i].set_lane<3>(ep0.lane<3>());\n- ep->endpt1[i].set_lane<3>(ep1.lane<3>());\n- }\n+ float scale_ep0 = (lmrs_sum.b * scale_vec.r - lmrs_sum.g * scale_vec.g) * ls_rdet1;\n+ float scale_ep1 = (lmrs_sum.r * scale_vec.g - lmrs_sum.g * scale_vec.r) * ls_rdet1;\nif (fabsf(ls_det1) > (ls_mss1 * 1e-4f) && scale_ep0 == scale_ep0 && scale_ep1 == scale_ep1 && scale_ep0 < scale_ep1)\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Replace channel switches with conditional selects.
61,745
13.02.2021 00:47:49
0
683a20dbf3487f32b23b0fa3881dda2f245abe0e
Cleaned up 1 omitted endpoint merge
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -460,9 +460,6 @@ static void compute_endpoints_and_ideal_weights_3_components(\n}\n}\n- float3 lowvalues[4];\n- float3 highvalues[4];\n-\nfor (int i = 0; i < partition_count; i++)\n{\nfloat length = highparam[i] - lowparam[i];\n@@ -491,56 +488,29 @@ static void compute_endpoints_and_ideal_weights_3_components(\nep1.g /= scalefactors[i].g;\nep1.b /= scalefactors[i].b;\n- lowvalues[i] = ep0;\n- highvalues[i] = ep1;\n- }\n-\n- for (int i = 0; i < partition_count; i++)\n- {\n- ei->ep.endpt0[i] = blk->data_min;\n- ei->ep.endpt1[i] = blk->data_max;\n-\n- float3 ep0 = lowvalues[i];\n- float3 ep1 = highvalues[i];\n+ vfloat4 bmin = blk->data_min;\n+ vfloat4 bmax = blk->data_max;\n+ // TODO: Probably a programmatic vector permute we can do here ...\nassert(omitted_component < 4);\nswitch (omitted_component)\n{\ncase 0:\n- ei->ep.endpt0[i].set_lane<1>(ep0.r);\n- ei->ep.endpt0[i].set_lane<2>(ep0.g);\n- ei->ep.endpt0[i].set_lane<3>(ep0.b);\n-\n- ei->ep.endpt1[i].set_lane<1>(ep1.r);\n- ei->ep.endpt1[i].set_lane<2>(ep1.g);\n- ei->ep.endpt1[i].set_lane<3>(ep1.b);\n+ ei->ep.endpt0[i] = vfloat4(bmin.lane<0>(), ep0.r, ep0.g, ep0.b);\n+ ei->ep.endpt1[i] = vfloat4(bmax.lane<0>(), ep1.r, ep1.g, ep1.b);\nbreak;\ncase 1:\n- ei->ep.endpt0[i].set_lane<0>(ep0.r);\n- ei->ep.endpt0[i].set_lane<2>(ep0.g);\n- ei->ep.endpt0[i].set_lane<3>(ep0.b);\n-\n- ei->ep.endpt1[i].set_lane<0>(ep1.r);\n- ei->ep.endpt1[i].set_lane<2>(ep1.g);\n- ei->ep.endpt1[i].set_lane<3>(ep1.b);\n+ ei->ep.endpt0[i] = vfloat4(ep0.r, bmin.lane<1>(), ep0.g, ep0.b);\n+ ei->ep.endpt1[i] = vfloat4(ep1.r, bmax.lane<1>(), ep1.g, ep1.b);\nbreak;\ncase 2:\n- ei->ep.endpt0[i].set_lane<0>(ep0.r);\n- ei->ep.endpt0[i].set_lane<1>(ep0.g);\n- ei->ep.endpt0[i].set_lane<3>(ep0.b);\n-\n- ei->ep.endpt1[i].set_lane<0>(ep1.r);\n- ei->ep.endpt1[i].set_lane<1>(ep1.g);\n- ei->ep.endpt1[i].set_lane<3>(ep1.b);\n+ ei->ep.endpt0[i] = vfloat4(ep0.r, ep0.g, bmin.lane<2>(), ep0.b);\n+ ei->ep.endpt1[i] = vfloat4(ep1.r, ep1.g, bmax.lane<2>(), ep1.b);\nbreak;\ndefault:\n- ei->ep.endpt0[i].set_lane<0>(ep0.r);\n- ei->ep.endpt0[i].set_lane<1>(ep0.g);\n- ei->ep.endpt0[i].set_lane<2>(ep0.b);\n-\n- ei->ep.endpt1[i].set_lane<0>(ep1.r);\n- ei->ep.endpt1[i].set_lane<1>(ep1.g);\n- ei->ep.endpt1[i].set_lane<2>(ep1.b);\n+ ei->ep.endpt0[i] = vfloat4(ep0.r, ep0.g, ep0.b, bmin.lane<3>());\n+ ei->ep.endpt1[i] = vfloat4(ep1.r, ep1.g, ep1.b, bmax.lane<3>());\n+ break;\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleaned up 1 omitted endpoint merge
61,745
13.02.2021 11:52:17
0
920787f426e8a9b40d5e927425f2529a0d3d2468
Add parens on vmask == and & pairs
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1356,7 +1356,7 @@ void recompute_ideal_colors_2planes(\nvmask4 p1_mask = vint4::lane_id() != vint4(plane2_color_component);\nvmask4 det_mask = abs(color_det1) > (color_mss1 * 1e-4f);\n- vmask4 notnan_mask = ep0 == ep0 & ep1 == ep1;\n+ vmask4 notnan_mask = (ep0 == ep0) & (ep1 == ep1);\nvmask4 full_mask = p1_mask & det_mask & notnan_mask;\nep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);\n@@ -1409,7 +1409,7 @@ void recompute_ideal_colors_2planes(\nvmask4 p2_mask = vint4::lane_id() == vint4(plane2_color_component);\nvmask4 det_mask = abs(color_det2) > (color_mss2 * 1e-4f);\n- vmask4 notnan_mask = ep0 == ep0 & ep1 == ep1;\n+ vmask4 notnan_mask = (ep0 == ep0) & (ep1 == ep1);\nvmask4 full_mask = p2_mask & det_mask & notnan_mask;\nep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);\n@@ -1644,7 +1644,7 @@ void recompute_ideal_colors_1plane(\nvfloat4 ep1 = (left_sum * color_vec_y - middle_sum * color_vec_x) * color_rdet1;\nvmask4 det_mask = abs(color_det1) > (color_mss1 * 1e-4f);\n- vmask4 notnan_mask = ep0 == ep0 & ep1 == ep1;\n+ vmask4 notnan_mask = (ep0 == ep0) & (ep1 == ep1);\nvmask4 full_mask = det_mask & notnan_mask;\nep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add parens on vmask == and & pairs
61,745
13.02.2021 15:08:42
0
06dd409575bfb95d3291da2e938751f41902602c
Use vector ops and hadd_rgb
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -538,8 +538,8 @@ static int try_quantize_luminance_alpha_delta(\n) {\nfloat scale = 1.0f / 257.0f;\n- float l0 = astc::clamp255f((color0.lane<0>() + color0.lane<1>() + color0.lane<2>()) * ((1.0f / 3.0f) * scale));\n- float l1 = astc::clamp255f((color1.lane<0>() + color1.lane<1>() + color1.lane<2>()) * ((1.0f / 3.0f) * scale));\n+ float l0 = astc::clamp255f(hadd_rgb_s(color0) * ((1.0f / 3.0f) * scale));\n+ float l1 = astc::clamp255f(hadd_rgb_s(color1) * ((1.0f / 3.0f) * scale));\nfloat a0 = astc::clamp255f(color0.lane<3>() * scale);\nfloat a1 = astc::clamp255f(color1.lane<3>() * scale);\n@@ -710,16 +710,11 @@ static void quantize_luminance(\n) {\nfloat scale = 1.0f / 257.0f;\n- float r0 = color0.lane<0>() * scale;\n- float g0 = color0.lane<1>() * scale;\n- float b0 = color0.lane<2>() * scale;\n+ color0 = color0 * scale;\n+ color1 = color1 * scale;\n- float r1 = color1.lane<0>() * scale;\n- float g1 = color1.lane<1>() * scale;\n- float b1 = color1.lane<2>() * scale;\n-\n- float lum0 = astc::clamp255f((r0 + g0 + b0) * (1.0f / 3.0f));\n- float lum1 = astc::clamp255f((r1 + g1 + b1) * (1.0f / 3.0f));\n+ float lum0 = astc::clamp255f(hadd_rgb_s(color0) * (1.0f / 3.0f));\n+ float lum1 = astc::clamp255f(hadd_rgb_s(color1) * (1.0f / 3.0f));\nif (lum0 > lum1)\n{\n@@ -740,22 +735,20 @@ static void quantize_luminance_alpha(\n) {\nfloat scale = 1.0f / 257.0f;\n- float r0 = color0.lane<0>() * scale;\n- float g0 = color0.lane<1>() * scale;\n- float b0 = color0.lane<2>() * scale;\n- float a0 = astc::clamp255f(color0.lane<3>() * scale);\n+ color0 = color0 * scale;\n+ color1 = color1 * scale;\n- float r1 = color1.lane<0>() * scale;\n- float g1 = color1.lane<1>() * scale;\n- float b1 = color1.lane<2>() * scale;\n- float a1 = astc::clamp255f(color1.lane<3>() * scale);\n+ float lum0 = astc::clamp255f(hadd_rgb_s(color0) * (1.0f / 3.0f));\n+ float lum1 = astc::clamp255f(hadd_rgb_s(color1) * (1.0f / 3.0f));\n- float lum0 = astc::clamp255f((r0 + g0 + b0) * (1.0f / 3.0f));\n- float lum1 = astc::clamp255f((r1 + g1 + b1) * (1.0f / 3.0f));\n+ float a0 = astc::clamp255f(color0.lane<3>());\n+ float a1 = astc::clamp255f(color1.lane<3>());\n// if the endpoints are *really* close, then pull them apart slightly;\n// this affords for >8 bits precision for normal maps.\n- if (quant_level > 18 && fabsf(lum0 - lum1) < 3.0f)\n+ if (quant_level > 18)\n+ {\n+ if (fabsf(lum0 - lum1) < 3.0f)\n{\nif (lum0 < lum1)\n{\n@@ -770,7 +763,8 @@ static void quantize_luminance_alpha(\nlum0 = astc::clamp255f(lum0);\nlum1 = astc::clamp255f(lum1);\n}\n- if (quant_level > 18 && fabsf(a0 - a1) < 3.0f)\n+\n+ if (fabsf(a0 - a1) < 3.0f)\n{\nif (a0 < a1)\n{\n@@ -785,6 +779,7 @@ static void quantize_luminance_alpha(\na0 = astc::clamp255f(a0);\na1 = astc::clamp255f(a1);\n}\n+ }\noutput[0] = color_quant_tables[quant_level][astc::flt2int_rtn(lum0)];\noutput[1] = color_quant_tables[quant_level][astc::flt2int_rtn(lum1)];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use vector ops and hadd_rgb
61,745
13.02.2021 15:21:58
0
201167218453a12a597380a963deeac8b06b1c17
Use hadd_rgb_s for rgbo_failure case
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1427,8 +1427,7 @@ void recompute_ideal_colors_2planes(\n{\nvfloat4 v0 = ep->endpt0[i];\nvfloat4 v1 = ep->endpt1[i];\n- float avgdif = ((v1.lane<0>() - v0.lane<0>()) + (v1.lane<1>() - v0.lane<1>()) + (v1.lane<2>() - v0.lane<2>())) * (1.0f / 3.0f);\n-\n+ float avgdif = hadd_rgb_s(v1 - v0) * (1.0f / 3.0f);\navgdif = astc::max(avgdif, 0.0f);\nvfloat4 avg = (v0 + v1) * 0.5f;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use hadd_rgb_s for rgbo_failure case
61,745
13.02.2021 16:17:16
0
7f4bb52666ca5fe636d263263de3269ca6a7e7d0
Add more vint4 functions to SIMD library
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -985,6 +985,17 @@ TEST(vfloat4, float_to_int_rtn)\nEXPECT_EQ(r.lane<3>(), 4);\n}\n+/** @brief Test vfloat4 round. */\n+TEST(vfloat4, int_to_float)\n+{\n+ vint4 a(1, 2, 3, 4);\n+ vfloat4 r = int_to_float(a);\n+ EXPECT_EQ(r.lane<0>(), 1.0f);\n+ EXPECT_EQ(r.lane<1>(), 2.0f);\n+ EXPECT_EQ(r.lane<2>(), 3.0f);\n+ EXPECT_EQ(r.lane<3>(), 4.0f);\n+}\n+\n// VINT4 tests - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n@@ -1105,6 +1116,29 @@ TEST(vint4, vsub)\nEXPECT_EQ(a.lane<3>(), 4 - 5);\n}\n+/** @brief Test vint4 mul. */\n+TEST(vint4, vmul)\n+{\n+ vint4 a(1, 2, 4, 4);\n+ vint4 b(2, 3, 3, 5);\n+ a = a * b;\n+ EXPECT_EQ(a.lane<0>(), 1 * 2);\n+ EXPECT_EQ(a.lane<1>(), 2 * 3);\n+ EXPECT_EQ(a.lane<2>(), 4 * 3);\n+ EXPECT_EQ(a.lane<3>(), 4 * 5);\n+}\n+\n+/** @brief Test vint4 mul. */\n+TEST(vint4, vsmul)\n+{\n+ vint4 a(1, 2, 4, 4);\n+ a = a * 3;\n+ EXPECT_EQ(a.lane<0>(), 1 * 3);\n+ EXPECT_EQ(a.lane<1>(), 2 * 3);\n+ EXPECT_EQ(a.lane<2>(), 4 * 3);\n+ EXPECT_EQ(a.lane<3>(), 4 * 3);\n+}\n+\n/** @brief Test vint4 bitwise invert. */\nTEST(vint4, bit_invert)\n{\n@@ -1232,6 +1266,29 @@ TEST(vint4, cle)\nEXPECT_EQ(0x1, mask(r));\n}\n+/** @brief Test vint4 lsr. */\n+TEST(vint4, lsr)\n+{\n+ vint4 a(1, 2, 4, 4);\n+ a = lsr<0>(a);\n+ EXPECT_EQ(a.lane<0>(), 1);\n+ EXPECT_EQ(a.lane<1>(), 2);\n+ EXPECT_EQ(a.lane<2>(), 4);\n+ EXPECT_EQ(a.lane<3>(), 4);\n+\n+ a = lsr<1>(a);\n+ EXPECT_EQ(a.lane<0>(), 0);\n+ EXPECT_EQ(a.lane<1>(), 1);\n+ EXPECT_EQ(a.lane<2>(), 2);\n+ EXPECT_EQ(a.lane<3>(), 2);\n+\n+ a = lsr<2>(a);\n+ EXPECT_EQ(a.lane<0>(), 0);\n+ EXPECT_EQ(a.lane<1>(), 0);\n+ EXPECT_EQ(a.lane<2>(), 0);\n+ EXPECT_EQ(a.lane<3>(), 0);\n+}\n+\n/** @brief Test vint4 min. */\nTEST(vint4, min)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -398,6 +398,22 @@ ASTCENC_SIMD_INLINE vint4 operator-(vint4 a, vint4 b)\nreturn vint4(vsubq_s32(a.m, b.m));\n}\n+/**\n+ * @brief Overload: vector by vector multiplication.\n+ */\n+ASTCENC_SIMD_INLINE vint4 operator*(vint4 a, vint4 b)\n+{\n+ return vint4(vmulq_s32(a.m, b.m));\n+}\n+\n+/**\n+ * @brief Overload: vector by scalar multiplication.\n+ */\n+ASTCENC_SIMD_INLINE vint4 operator*(vint4 a, int b)\n+{\n+ return vint4(vmulq_s32(a.m, vdupq_n_s32(b)));\n+}\n+\n/**\n* @brief Overload: vector bit invert.\n*/\n@@ -462,6 +478,14 @@ ASTCENC_SIMD_INLINE vmask4 operator>(vint4 a, vint4 b)\nreturn vmask4(vcgtq_s32(a.m, b.m));\n}\n+/**\n+ * @brief Logical shift right.\n+ */\n+template <int s> ASTCENC_SIMD_INLINE vint4 lsr(vint4 a)\n+{\n+ return vint4(vshlq_s32(a.m, vdupq_n_s32(-s)));\n+}\n+\n/**\n* @brief Return the min vector of two vectors.\n*/\n@@ -940,6 +964,14 @@ ASTCENC_SIMD_INLINE vint4 float_to_int_rtn(vfloat4 a)\nreturn vint4(vcvtq_s32_f32(a.m));\n}\n+/**\n+ * @brief Return a float value for an integer vector.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 int_to_float(vint4 a)\n+{\n+ return vfloat4(vcvtq_f32_s32(a.m));\n+}\n+\n/**\n* @brief Return a float value as an integer bit pattern (i.e. no conversion).\n*\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_4.h", "new_path": "Source/astcenc_vecmathlib_none_4.h", "diff": "@@ -425,6 +425,28 @@ ASTCENC_SIMD_INLINE vint4 operator-(vint4 a, vint4 b)\na.m[3] - b.m[3]);\n}\n+/**\n+ * @brief Overload: vector by vector multiplication.\n+ */\n+ASTCENC_SIMD_INLINE vint4 operator*(vint4 a, vint4 b)\n+{\n+ return vint4(a.m[0] * b.m[0],\n+ a.m[1] * b.m[1],\n+ a.m[2] * b.m[2],\n+ a.m[3] * b.m[3]);\n+}\n+\n+/**\n+ * @brief Overload: vector by scalar multiplication.\n+ */\n+ASTCENC_SIMD_INLINE vint4 operator*(vint4 a, int b)\n+{\n+ return vint4(a.m[0] * b,\n+ a.m[1] * b,\n+ a.m[2] * b,\n+ a.m[3] * b);\n+}\n+\n/**\n* @brief Overload: vector bit invert.\n*/\n@@ -513,6 +535,17 @@ ASTCENC_SIMD_INLINE vmask4 operator>(vint4 a, vint4 b)\na.m[3] > b.m[3] ? 0xFFFFFFFF : 0);\n}\n+/**\n+ * @brief Logical shift right.\n+ */\n+template <int s> ASTCENC_SIMD_INLINE vint4 lsr(vint4 a)\n+{\n+ return vint4(a.m[0] >> s,\n+ a.m[1] >> s,\n+ a.m[2] >> s,\n+ a.m[3] >> s);\n+}\n+\n/**\n* @brief Return the min vector of two vectors.\n*/\n@@ -1054,6 +1087,17 @@ ASTCENC_SIMD_INLINE vint4 float_to_int_rtn(vfloat4 a)\n(int)(a.m[3] + 0.5f));\n}\n+/**\n+ * @brief Return a integer value for a float vector, using truncation.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 int_to_float(vint4 a)\n+{\n+ return vfloat4((float)a.m[0],\n+ (float)a.m[1],\n+ (float)a.m[2],\n+ (float)a.m[3]);\n+}\n+\n/**\n* @brief Return a float value as an integer bit pattern (i.e. no conversion).\n*\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -403,6 +403,22 @@ ASTCENC_SIMD_INLINE vint4 operator-(vint4 a, vint4 b)\nreturn vint4(_mm_sub_epi32(a.m, b.m));\n}\n+/**\n+ * @brief Overload: vector by vector multiplication.\n+ */\n+ASTCENC_SIMD_INLINE vint4 operator*(vint4 a, vint4 b)\n+{\n+ return vint4(_mm_mullo_epi32 (a.m, b.m));\n+}\n+\n+/**\n+ * @brief Overload: vector by scalar multiplication.\n+ */\n+ASTCENC_SIMD_INLINE vint4 operator*(vint4 a, int b)\n+{\n+ return vint4(_mm_mullo_epi32 (a.m, _mm_set1_epi32(b)));\n+}\n+\n/**\n* @brief Overload: vector bit invert.\n*/\n@@ -467,6 +483,14 @@ ASTCENC_SIMD_INLINE vmask4 operator>(vint4 a, vint4 b)\nreturn vmask4(_mm_cmpgt_epi32(a.m, b.m));\n}\n+/**\n+ * @brief Logical shift right.\n+ */\n+template <int s> ASTCENC_SIMD_INLINE vint4 lsr(vint4 a)\n+{\n+ return vint4(_mm_srli_epi32(a.m, s));\n+}\n+\n/**\n* @brief Return the min vector of two vectors.\n*/\n@@ -1005,6 +1029,14 @@ ASTCENC_SIMD_INLINE vint4 float_to_int_rtn(vfloat4 a)\nreturn vint4(_mm_cvttps_epi32(a.m));\n}\n+/**\n+ * @brief Return a float value for an integer vector.\n+ */\n+ASTCENC_SIMD_INLINE vfloat4 int_to_float(vint4 a)\n+{\n+ return vfloat4(_mm_cvtepi32_ps(a.m));\n+}\n+\n/**\n* @brief Return a float value as an integer bit pattern (i.e. no conversion).\n*\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add more vint4 functions to SIMD library
61,745
13.02.2021 16:29:51
0
82223dd0ecefce014c5839a7da7936b8c7327926
Vectorize lerp_color_int using vint4
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -33,42 +33,38 @@ static int compute_value_of_texel_int(\nint weights_to_evaluate = it->texel_weight_count[texel_to_get];\nfor (int i = 0; i < weights_to_evaluate; i++)\n{\n- summed_value += weights[it->texel_weights_t4[texel_to_get][i]] * it->texel_weights_int_t4[texel_to_get][i];\n+ summed_value += weights[it->texel_weights_t4[texel_to_get][i]]\n+ * it->texel_weights_int_t4[texel_to_get][i];\n}\nreturn summed_value >> 4;\n}\n-static uint4 lerp_color_int(\n+static vfloat4 lerp_color_int(\nastcenc_profile decode_mode,\n- uint4 color0,\n- uint4 color1,\n+ vint4 color0,\n+ vint4 color1,\nint weight,\nint plane2_weight,\n- int plane2_color_component // -1 in 1-plane mode\n+ vmask4 plane2_mask\n) {\n- uint4 weight1 = uint4(\n- plane2_color_component == 0 ? plane2_weight : weight,\n- plane2_color_component == 1 ? plane2_weight : weight,\n- plane2_color_component == 2 ? plane2_weight : weight,\n- plane2_color_component == 3 ? plane2_weight : weight);\n-\n- uint4 weight0 = uint4(64, 64, 64, 64) - weight1;\n+ vint4 weight1 = select(vint4(weight), vint4(plane2_weight), plane2_mask);\n+ vint4 weight0 = vint4(64) - weight1;\nif (decode_mode == ASTCENC_PRF_LDR_SRGB)\n{\n- color0 = uint4(color0.r >> 8, color0.g >> 8, color0.b >> 8, color0.a >> 8);\n- color1 = uint4(color1.r >> 8, color1.g >> 8, color1.b >> 8, color1.a >> 8);\n+ color0 = lsr<8>(color0);\n+ color1 = lsr<8>(color1);\n}\n- uint4 color = (color0 * weight0) + (color1 * weight1) + uint4(32, 32, 32, 32);\n- color = uint4(color.r >> 6, color.g >> 6, color.b >> 6, color.a >> 6);\n+ vint4 color = (color0 * weight0) + (color1 * weight1) + vint4(32);\n+ color = lsr<6>(color);\nif (decode_mode == ASTCENC_PRF_LDR_SRGB)\n{\n- color = color * 257u;\n+ color = color * vint4(257);\n}\n- return color;\n+ return int_to_float(color);\n}\nvoid decompress_symbolic_block(\n@@ -269,28 +265,36 @@ void decompress_symbolic_block(\n}\n}\n- int plane2_color_component = scb->plane2_color_component;\n+ // Now that we have endpoint colors and weights, we can unpack texel colors\n+ int plane2_color_component = is_dual_plane ? scb->plane2_color_component : -1;\n+ vmask4 plane2_mask = vint4::lane_id() == vint4(plane2_color_component);\n- // Now that we have endpoint colors and weights, we can unpack actual colors for each texel.\nfor (int i = 0; i < bsd->texel_count; i++)\n{\nint partition = pt->partition_of_texel[i];\n- uint4 color = lerp_color_int(decode_mode,\n- color_endpoint0[partition],\n- color_endpoint1[partition],\n+ // TODO: Remove uint4 completely\n+ uint4 ep0 = color_endpoint0[partition];\n+ uint4 ep1 = color_endpoint1[partition];\n+\n+ vint4 vep0(ep0.r, ep0.g, ep0.b, ep0.a);\n+ vint4 vep1(ep1.r, ep1.g, ep1.b, ep1.a);\n+\n+ vfloat4 color = lerp_color_int(decode_mode,\n+ vep0,\n+ vep1,\nweights[i],\nplane2_weights[i],\n- is_dual_plane ? plane2_color_component : -1);\n+ plane2_mask);\nblk->rgb_lns[i] = rgb_hdr_endpoint[partition];\nblk->alpha_lns[i] = alpha_hdr_endpoint[partition];\nblk->nan_texel[i] = nan_endpoint[partition];\n- blk->data_r[i] = (float)color.r;\n- blk->data_g[i] = (float)color.g;\n- blk->data_b[i] = (float)color.b;\n- blk->data_a[i] = (float)color.a;\n+ blk->data_r[i] = color.lane<0>();\n+ blk->data_g[i] = color.lane<1>();\n+ blk->data_b[i] = color.lane<2>();\n+ blk->data_a[i] = color.lane<3>();\n}\nimageblock_initialize_orig_from_work(blk, bsd->texel_count);\n@@ -390,30 +394,32 @@ float compute_symbolic_block_difference(\n}\n}\n- int plane2_color_component = scb->plane2_color_component;\n+ // Now that we have endpoint colors and weights, we can unpack texel colors\n+ int plane2_color_component = is_dual_plane ? scb->plane2_color_component : -1;\n+ vmask4 plane2_mask = vint4::lane_id() == vint4(plane2_color_component);\n- // now that we have endpoint colors and weights, we can unpack actual colors for\n- // each texel.\nfloat summa = 0.0f;\nfor (int i = 0; i < texel_count; i++)\n{\nint partition = pt->partition_of_texel[i];\n- uint4 color = lerp_color_int(decode_mode,\n- color_endpoint0[partition],\n- color_endpoint1[partition],\n+ // TODO: Remove uint4 completely\n+ uint4 ep0 = color_endpoint0[partition];\n+ uint4 ep1 = color_endpoint1[partition];\n+\n+ vint4 vep0(ep0.r, ep0.g, ep0.b, ep0.a);\n+ vint4 vep1(ep1.r, ep1.g, ep1.b, ep1.a);\n+\n+ vfloat4 color = lerp_color_int(decode_mode,\n+ vep0,\n+ vep1,\nweights[i],\nplane2_weights[i],\n- is_dual_plane ? plane2_color_component : -1);\n-\n- vfloat4 newColor((float)color.r,\n- (float)color.g,\n- (float)color.b,\n- (float)color.a);\n+ plane2_mask);\nvfloat4 oldColor = pb->texel(i);\n- vfloat4 error = oldColor - newColor;\n+ vfloat4 error = oldColor - color;\nerror = min(abs(error), 1e15f);\nerror = error * error;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Vectorize lerp_color_int using vint4
61,745
13.02.2021 17:03:29
0
e07d4342acedd8db74a2ab3f610ea21031e981e0
Replace int4/uint4 with vint4 and remove vtype4
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -1050,6 +1050,35 @@ TEST(vint4, CopyLoad)\nEXPECT_EQ(a.lane<3>(), 44);\n}\n+/** @brief Test vint4 scalar lane set. */\n+TEST(int4, SetLane)\n+{\n+ vint4 a(0);\n+\n+ a.set_lane<0>(1);\n+ EXPECT_EQ(a.lane<0>(), 1);\n+ EXPECT_EQ(a.lane<1>(), 0);\n+ EXPECT_EQ(a.lane<2>(), 0);\n+ EXPECT_EQ(a.lane<3>(), 0);\n+\n+ a.set_lane<1>(2);\n+ EXPECT_EQ(a.lane<0>(), 1);\n+ EXPECT_EQ(a.lane<1>(), 2);\n+ EXPECT_EQ(a.lane<2>(), 0);\n+ EXPECT_EQ(a.lane<3>(), 0);\n+\n+ a.set_lane<2>(3);\n+ EXPECT_EQ(a.lane<0>(), 1);\n+ EXPECT_EQ(a.lane<1>(), 2);\n+ EXPECT_EQ(a.lane<2>(), 3);\n+ EXPECT_EQ(a.lane<3>(), 0);\n+\n+ a.set_lane<3>(4);\n+ EXPECT_EQ(a.lane<0>(), 1);\n+ EXPECT_EQ(a.lane<1>(), 2);\n+ EXPECT_EQ(a.lane<2>(), 3);\n+ EXPECT_EQ(a.lane<3>(), 4);\n+}\n/** @brief Test vint4 zero. */\nTEST(vint4, Zero)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_color_unquantize.cpp", "new_path": "Source/astcenc_color_unquantize.cpp", "diff": "static int rgb_delta_unpack(\nconst int input[6],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\n// unquantize the color endpoints\nint r0 = color_unquant_tables[quant_level][input[0]];\n@@ -101,15 +101,8 @@ static int rgb_delta_unpack(\ng1e = astc::clamp(g1e, 0, 255);\nb1e = astc::clamp(b1e, 0, 255);\n- output0->r = r0e;\n- output0->g = g0e;\n- output0->b = b0e;\n- output0->a = 0xFF;\n-\n- output1->r = r1e;\n- output1->g = g1e;\n- output1->b = b1e;\n- output1->a = 0xFF;\n+ *output0 = vint4(r0e, g0e, b0e, 0xFF);\n+ *output1 = vint4(r1e, g1e, b1e, 0xFF);\nreturn retval;\n}\n@@ -117,8 +110,8 @@ static int rgb_delta_unpack(\nstatic int rgb_unpack(\nconst int input[6],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nint ri0b = color_unquant_tables[quant_level][input[0]];\nint ri1b = color_unquant_tables[quant_level][input[1]];\n@@ -135,28 +128,14 @@ static int rgb_unpack(\nri1b = (ri1b + bi1b) >> 1;\ngi1b = (gi1b + bi1b) >> 1;\n- output0->r = ri1b;\n- output0->g = gi1b;\n- output0->b = bi1b;\n- output0->a = 255;\n-\n- output1->r = ri0b;\n- output1->g = gi0b;\n- output1->b = bi0b;\n- output1->a = 255;\n+ *output0 = vint4(ri1b, gi1b, bi1b, 255);\n+ *output1 = vint4(ri0b, gi0b, bi0b, 255);\nreturn 1;\n}\nelse\n{\n- output0->r = ri0b;\n- output0->g = gi0b;\n- output0->b = bi0b;\n- output0->a = 255;\n-\n- output1->r = ri1b;\n- output1->g = gi1b;\n- output1->b = bi1b;\n- output1->a = 255;\n+ *output0 = vint4(ri0b, gi0b, bi0b, 255);\n+ *output1 = vint4(ri1b, gi1b, bi1b, 255);\nreturn 0;\n}\n}\n@@ -164,27 +143,27 @@ static int rgb_unpack(\nstatic void rgba_unpack(\nconst int input[8],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nint order = rgb_unpack(input, quant_level, output0, output1);\nif (order == 0)\n{\n- output0->a = color_unquant_tables[quant_level][input[6]];\n- output1->a = color_unquant_tables[quant_level][input[7]];\n+ output0->set_lane<3>(color_unquant_tables[quant_level][input[6]]);\n+ output1->set_lane<3>(color_unquant_tables[quant_level][input[7]]);\n}\nelse\n{\n- output0->a = color_unquant_tables[quant_level][input[7]];\n- output1->a = color_unquant_tables[quant_level][input[6]];\n+ output0->set_lane<3>(color_unquant_tables[quant_level][input[7]]);\n+ output1->set_lane<3>(color_unquant_tables[quant_level][input[6]]);\n}\n}\nstatic void rgba_delta_unpack(\nconst int input[8],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nint a0 = color_unquant_tables[quant_level][input[6]];\nint a1 = color_unquant_tables[quant_level][input[7]];\n@@ -201,21 +180,21 @@ static void rgba_delta_unpack(\nint order = rgb_delta_unpack(input, quant_level, output0, output1);\nif (order == 0)\n{\n- output0->a = a0;\n- output1->a = a1;\n+ output0->set_lane<3>(a0);\n+ output1->set_lane<3>(a1);\n}\nelse\n{\n- output0->a = a1;\n- output1->a = a0;\n+ output0->set_lane<3>(a1);\n+ output1->set_lane<3>(a0);\n}\n}\nstatic void rgb_scale_unpack(\nconst int input[4],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nint ir = color_unquant_tables[quant_level][input[0]];\nint ig = color_unquant_tables[quant_level][input[1]];\n@@ -223,38 +202,38 @@ static void rgb_scale_unpack(\nint iscale = color_unquant_tables[quant_level][input[3]];\n- *output1 = uint4(ir, ig, ib, 255);\n- *output0 = uint4((ir * iscale) >> 8, (ig * iscale) >> 8, (ib * iscale) >> 8, 255);\n+ *output1 = vint4(ir, ig, ib, 255);\n+ *output0 = vint4((ir * iscale) >> 8, (ig * iscale) >> 8, (ib * iscale) >> 8, 255);\n}\nstatic void rgb_scale_alpha_unpack(\nconst int input[6],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nrgb_scale_unpack(input, quant_level, output0, output1);\n- output0->a = color_unquant_tables[quant_level][input[4]];\n- output1->a = color_unquant_tables[quant_level][input[5]];\n+ output0->set_lane<3>(color_unquant_tables[quant_level][input[4]]);\n+ output1->set_lane<3>(color_unquant_tables[quant_level][input[5]]);\n}\nstatic void luminance_unpack(\nconst int input[2],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nint lum0 = color_unquant_tables[quant_level][input[0]];\nint lum1 = color_unquant_tables[quant_level][input[1]];\n- *output0 = uint4(lum0, lum0, lum0, 255);\n- *output1 = uint4(lum1, lum1, lum1, 255);\n+ *output0 = vint4(lum0, lum0, lum0, 255);\n+ *output1 = vint4(lum1, lum1, lum1, 255);\n}\nstatic void luminance_delta_unpack(\nconst int input[2],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nint v0 = color_unquant_tables[quant_level][input[0]];\nint v1 = color_unquant_tables[quant_level][input[1]];\n@@ -263,29 +242,29 @@ static void luminance_delta_unpack(\nl1 = astc::min(l1, 255);\n- *output0 = uint4(l0, l0, l0, 255);\n- *output1 = uint4(l1, l1, l1, 255);\n+ *output0 = vint4(l0, l0, l0, 255);\n+ *output1 = vint4(l1, l1, l1, 255);\n}\nstatic void luminance_alpha_unpack(\nconst int input[4],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nint lum0 = color_unquant_tables[quant_level][input[0]];\nint lum1 = color_unquant_tables[quant_level][input[1]];\nint alpha0 = color_unquant_tables[quant_level][input[2]];\nint alpha1 = color_unquant_tables[quant_level][input[3]];\n- *output0 = uint4(lum0, lum0, lum0, alpha0);\n- *output1 = uint4(lum1, lum1, lum1, alpha1);\n+ *output0 = vint4(lum0, lum0, lum0, alpha0);\n+ *output1 = vint4(lum1, lum1, lum1, alpha1);\n}\nstatic void luminance_alpha_delta_unpack(\nconst int input[4],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nint lum0 = color_unquant_tables[quant_level][input[0]];\nint lum1 = color_unquant_tables[quant_level][input[1]];\n@@ -311,16 +290,16 @@ static void luminance_alpha_delta_unpack(\nlum1 = astc::clamp(lum1, 0, 255);\nalpha1 = astc::clamp(alpha1, 0, 255);\n- *output0 = uint4(lum0, lum0, lum0, alpha0);\n- *output1 = uint4(lum1, lum1, lum1, alpha1);\n+ *output0 = vint4(lum0, lum0, lum0, alpha0);\n+ *output1 = vint4(lum1, lum1, lum1, alpha1);\n}\n// RGB-offset format\nstatic void hdr_rgbo_unpack3(\nconst int input[4],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nint v0 = color_unquant_tables[quant_level][input[0]];\nint v1 = color_unquant_tables[quant_level][input[1]];\n@@ -456,15 +435,15 @@ static void hdr_rgbo_unpack3(\nif (blue0 < 0)\nblue0 = 0;\n- *output0 = uint4(red0 << 4, green0 << 4, blue0 << 4, 0x7800);\n- *output1 = uint4(red << 4, green << 4, blue << 4, 0x7800);\n+ *output0 = vint4(red0 << 4, green0 << 4, blue0 << 4, 0x7800);\n+ *output1 = vint4(red << 4, green << 4, blue << 4, 0x7800);\n}\nstatic void hdr_rgb_unpack3(\nconst int input[6],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nint v0 = color_unquant_tables[quant_level][input[0]];\n@@ -481,8 +460,8 @@ static void hdr_rgb_unpack3(\nif (majcomp == 3)\n{\n- *output0 = uint4(v0 << 8, v2 << 8, (v4 & 0x7F) << 9, 0x7800);\n- *output1 = uint4(v1 << 8, v3 << 8, (v5 & 0x7F) << 9, 0x7800);\n+ *output0 = vint4(v0 << 8, v2 << 8, (v4 & 0x7F) << 9, 0x7800);\n+ *output1 = vint4(v1 << 8, v3 << 8, (v5 & 0x7F) << 9, 0x7800);\nreturn;\n}\n@@ -612,29 +591,29 @@ static void hdr_rgb_unpack3(\nbreak;\n}\n- *output0 = uint4(red0 << 4, green0 << 4, blue0 << 4, 0x7800);\n- *output1 = uint4(red1 << 4, green1 << 4, blue1 << 4, 0x7800);\n+ *output0 = vint4(red0 << 4, green0 << 4, blue0 << 4, 0x7800);\n+ *output1 = vint4(red1 << 4, green1 << 4, blue1 << 4, 0x7800);\n}\nstatic void hdr_rgb_ldr_alpha_unpack3(\nconst int input[8],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nhdr_rgb_unpack3(input, quant_level, output0, output1);\nint v6 = color_unquant_tables[quant_level][input[6]];\nint v7 = color_unquant_tables[quant_level][input[7]];\n- output0->a = v6;\n- output1->a = v7;\n+ output0->set_lane<3>(v6);\n+ output1->set_lane<3>(v7);\n}\nstatic void hdr_luminance_small_range_unpack(\nconst int input[2],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nint v0 = color_unquant_tables[quant_level][input[0]];\nint v1 = color_unquant_tables[quant_level][input[1]];\n@@ -655,15 +634,15 @@ static void hdr_luminance_small_range_unpack(\nif (y1 > 0xFFF)\ny1 = 0xFFF;\n- *output0 = uint4(y0 << 4, y0 << 4, y0 << 4, 0x7800);\n- *output1 = uint4(y1 << 4, y1 << 4, y1 << 4, 0x7800);\n+ *output0 = vint4(y0 << 4, y0 << 4, y0 << 4, 0x7800);\n+ *output1 = vint4(y1 << 4, y1 << 4, y1 << 4, 0x7800);\n}\nstatic void hdr_luminance_large_range_unpack(\nconst int input[2],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nint v0 = color_unquant_tables[quant_level][input[0]];\nint v1 = color_unquant_tables[quant_level][input[1]];\n@@ -679,8 +658,8 @@ static void hdr_luminance_large_range_unpack(\ny0 = (v1 << 4) + 8;\ny1 = (v0 << 4) - 8;\n}\n- *output0 = uint4(y0 << 4, y0 << 4, y0 << 4, 0x7800);\n- *output1 = uint4(y1 << 4, y1 << 4, y1 << 4, 0x7800);\n+ *output0 = vint4(y0 << 4, y0 << 4, y0 << 4, 0x7800);\n+ *output1 = vint4(y1 << 4, y1 << 4, y1 << 4, 0x7800);\n}\nstatic void hdr_alpha_unpack(\n@@ -727,16 +706,16 @@ static void hdr_alpha_unpack(\nstatic void hdr_rgb_hdr_alpha_unpack3(\nconst int input[8],\nint quant_level,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\nhdr_rgb_unpack3(input, quant_level, output0, output1);\nint alpha0, alpha1;\nhdr_alpha_unpack(input + 6, quant_level, &alpha0, &alpha1);\n- output0->a = alpha0;\n- output1->a = alpha1;\n+ output0->set_lane<3>(alpha0);\n+ output1->set_lane<3>(alpha1);\n}\nvoid unpack_color_endpoints(\n@@ -747,8 +726,8 @@ void unpack_color_endpoints(\nint* rgb_hdr,\nint* alpha_hdr,\nint* nan_endpoint,\n- uint4* output0,\n- uint4* output1\n+ vint4* output0,\n+ vint4* output1\n) {\n*nan_endpoint = 0;\n@@ -856,14 +835,14 @@ void unpack_color_endpoints(\n{\nif (decode_mode == ASTCENC_PRF_HDR)\n{\n- output0->a = 0x7800;\n- output1->a = 0x7800;\n+ output0->set_lane<3>(0x7800);\n+ output1->set_lane<3>(0x7800);\n*alpha_hdr = 1;\n}\nelse\n{\n- output0->a = 0x00FF;\n- output1->a = 0x00FF;\n+ output0->set_lane<3>(0x00FF);\n+ output1->set_lane<3>(0x00FF);\n*alpha_hdr = 0;\n}\n}\n@@ -873,27 +852,13 @@ void unpack_color_endpoints(\ncase ASTCENC_PRF_LDR_SRGB:\nif (*rgb_hdr == 1)\n{\n- output0->r = 0xFF00;\n- output0->g = 0x0000;\n- output0->b = 0xFF00;\n- output0->a = 0xFF00;\n-\n- output1->r = 0xFF00;\n- output1->g = 0x0000;\n- output1->b = 0xFF00;\n- output1->a = 0xFF00;\n+ *output0 = vint4(0xFF00, 0x0000, 0xFF00, 0xFF00);\n+ *output1 = vint4(0xFF00, 0x0000, 0xFF00, 0xFF00);\n}\nelse\n{\n- output0->r *= 257;\n- output0->g *= 257;\n- output0->b *= 257;\n- output0->a *= 257;\n-\n- output1->r *= 257;\n- output1->g *= 257;\n- output1->b *= 257;\n- output1->a *= 257;\n+ *output0 = *output0 * 257;\n+ *output1 = *output1 * 257;\n}\n*rgb_hdr = 0;\n*alpha_hdr = 0;\n@@ -902,28 +867,14 @@ void unpack_color_endpoints(\ncase ASTCENC_PRF_LDR:\nif (*rgb_hdr == 1)\n{\n- output0->r = 0xFFFF;\n- output0->g = 0xFFFF;\n- output0->b = 0xFFFF;\n- output0->a = 0xFFFF;\n-\n- output1->r = 0xFFFF;\n- output1->g = 0xFFFF;\n- output1->b = 0xFFFF;\n- output1->a = 0xFFFF;\n+ *output0 = vint4(0xFFFF);\n+ *output1 = vint4(0xFFFF);\n*nan_endpoint = 1;\n}\nelse\n{\n- output0->r *= 257;\n- output0->g *= 257;\n- output0->b *= 257;\n- output0->a *= 257;\n-\n- output1->r *= 257;\n- output1->g *= 257;\n- output1->b *= 257;\n- output1->a *= 257;\n+ *output0 = *output0 * 257;\n+ *output1 = *output1 * 257;\n}\n*rgb_hdr = 0;\n*alpha_hdr = 0;\n@@ -933,18 +884,18 @@ void unpack_color_endpoints(\ncase ASTCENC_PRF_HDR:\nif (*rgb_hdr == 0)\n{\n- output0->r *= 257;\n- output0->g *= 257;\n- output0->b *= 257;\n+ output0->set_lane<0>(output0->lane<0>() * 257);\n+ output0->set_lane<1>(output0->lane<1>() * 257);\n+ output0->set_lane<2>(output0->lane<2>() * 257);\n- output1->r *= 257;\n- output1->g *= 257;\n- output1->b *= 257;\n+ output1->set_lane<0>(output1->lane<0>() * 257);\n+ output1->set_lane<1>(output1->lane<1>() * 257);\n+ output1->set_lane<2>(output1->lane<2>() * 257);\n}\nif (*alpha_hdr == 0)\n{\n- output0->a *= 257;\n- output1->a *= 257;\n+ output0->set_lane<3>(output0->lane<3>() * 257);\n+ output1->set_lane<3>(output1->lane<3>() * 257);\n}\nbreak;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -70,15 +70,15 @@ static int realign_weights(\nint weight_count = it->weight_count;\nint max_plane = bm.is_dual_plane;\n- int plane2_component = max_plane ? scb->plane2_color_component : 0;\n- int plane_mask = max_plane ? 1 << plane2_component : 0;\n+ int plane2_component = bm.is_dual_plane ? scb->plane2_color_component : -1;\n+ vmask4 plane_mask = vint4::lane_id() == vint4(plane2_component);\n// Decode the color endpoints\nint rgb_hdr;\nint alpha_hdr;\nint nan_endpoint;\n- int4 endpnt0[4];\n- int4 endpnt1[4];\n+ vint4 endpnt0[4];\n+ vint4 endpnt1[4];\nvfloat4 endpnt0f[4];\nvfloat4 offset[4];\n@@ -93,9 +93,8 @@ static int realign_weights(\nscb->color_quant_level,\nscb->color_values[pa_idx],\n&rgb_hdr, &alpha_hdr, &nan_endpoint,\n- // TODO: Fix these casts ...\n- reinterpret_cast<uint4*>(&endpnt0[pa_idx]),\n- reinterpret_cast<uint4*>(&endpnt1[pa_idx]));\n+ &endpnt0[pa_idx],\n+ &endpnt1[pa_idx]);\n}\nuint8_t uq_pl_weights[MAX_WEIGHTS_PER_BLOCK];\n@@ -108,16 +107,11 @@ static int realign_weights(\nfor (int pa_idx = 0; pa_idx < partition_count; pa_idx++)\n{\n// Compute the endpoint delta for all channels in current plane\n- int4 epd = endpnt1[pa_idx] - endpnt0[pa_idx];\n+ vint4 epd = endpnt1[pa_idx] - endpnt0[pa_idx];\n+ epd = select(epd, vint4::zero(), plane_mask);\n- if (plane_mask & 1) epd.r = 0;\n- if (plane_mask & 2) epd.g = 0;\n- if (plane_mask & 4) epd.b = 0;\n- if (plane_mask & 8) epd.a = 0;\n-\n- endpnt0f[pa_idx] = vfloat4((float)endpnt0[pa_idx].r, (float)endpnt0[pa_idx].g,\n- (float)endpnt0[pa_idx].b, (float)endpnt0[pa_idx].a);\n- offset[pa_idx] = vfloat4((float)epd.r, (float)epd.g, (float)epd.b, (float)epd.a);\n+ endpnt0f[pa_idx] = int_to_float(endpnt0[pa_idx]);\n+ offset[pa_idx] = int_to_float(epd);\noffset[pa_idx] = offset[pa_idx] * (1.0f / 64.0f);\n}\n@@ -199,7 +193,7 @@ static int realign_weights(\n// Prepare iteration for plane 2\nweight_set8 = plane2_weight_set8;\n- plane_mask ^= 0xF;\n+ plane_mask = ~plane_mask;\n}\nreturn adjustments;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -209,8 +209,8 @@ void decompress_symbolic_block(\nint weight_quant_level = bm.quant_mode;\n// decode the color endpoints\n- uint4 color_endpoint0[4];\n- uint4 color_endpoint1[4];\n+ vint4 color_endpoint0[4];\n+ vint4 color_endpoint1[4];\nint rgb_hdr_endpoint[4];\nint alpha_hdr_endpoint[4];\nint nan_endpoint[4];\n@@ -273,16 +273,12 @@ void decompress_symbolic_block(\n{\nint partition = pt->partition_of_texel[i];\n- // TODO: Remove uint4 completely\n- uint4 ep0 = color_endpoint0[partition];\n- uint4 ep1 = color_endpoint1[partition];\n-\n- vint4 vep0(ep0.r, ep0.g, ep0.b, ep0.a);\n- vint4 vep1(ep1.r, ep1.g, ep1.b, ep1.a);\n+ vint4 ep0 = color_endpoint0[partition];\n+ vint4 ep1 = color_endpoint1[partition];\nvfloat4 color = lerp_color_int(decode_mode,\n- vep0,\n- vep1,\n+ ep0,\n+ ep1,\nweights[i],\nplane2_weights[i],\nplane2_mask);\n@@ -339,8 +335,8 @@ float compute_symbolic_block_difference(\npromise(texel_count > 0);\n// decode the color endpoints\n- uint4 color_endpoint0[4];\n- uint4 color_endpoint1[4];\n+ vint4 color_endpoint0[4];\n+ vint4 color_endpoint1[4];\nint rgb_hdr_endpoint[4];\nint alpha_hdr_endpoint[4];\nint nan_endpoint[4];\n@@ -403,16 +399,12 @@ float compute_symbolic_block_difference(\n{\nint partition = pt->partition_of_texel[i];\n- // TODO: Remove uint4 completely\n- uint4 ep0 = color_endpoint0[partition];\n- uint4 ep1 = color_endpoint1[partition];\n-\n- vint4 vep0(ep0.r, ep0.g, ep0.b, ep0.a);\n- vint4 vep1(ep1.r, ep1.g, ep1.b, ep1.a);\n+ vint4 ep0 = color_endpoint0[partition];\n+ vint4 ep1 = color_endpoint1[partition];\nvfloat4 color = lerp_color_int(decode_mode,\n- vep0,\n- vep1,\n+ ep0,\n+ ep1,\nweights[i],\nplane2_weights[i],\nplane2_mask);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1131,8 +1131,8 @@ void unpack_color_endpoints(\nint* rgb_hdr,\nint* alpha_hdr,\nint* nan_endpoint,\n- uint4* output0,\n- uint4* output1);\n+ vint4* output0,\n+ vint4* output1);\nstruct encoding_choice_errors\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "@@ -567,69 +567,9 @@ vtype3<T> operator*(T p, vtype3<T> q) {\nreturn vtype3<T> { p * q.r, p * q.g, p * q.b };\n}\n-template <typename T> class alignas(16) vtype4\n-{\n-public:\n- // Data storage\n- T r, g, b, a;\n-\n- // Default constructor\n- vtype4() {}\n-\n- // Initialize from 1 scalar\n- vtype4(T p) : r(p), g(p), b(p), a(p) {}\n-\n- // Initialize from N scalars\n- vtype4(T p, T q, T s, T t) : r(p), g(q), b(s), a(t) {}\n-\n- // Initialize from another vector\n- vtype4(const vtype4 & p) : r(p.r), g(p.g), b(p.b), a(p.a) {}\n-\n- // Assignment operator\n- vtype4& operator=(const vtype4 &s) {\n- this->r = s.r;\n- this->g = s.g;\n- this->b = s.b;\n- this->a = s.a;\n- return *this;\n- }\n-};\n-\n-// Vector by vector addition\n-template <typename T>\n-vtype4<T> operator+(vtype4<T> p, vtype4<T> q) {\n- return vtype4<T> { p.r + q.r, p.g + q.g, p.b + q.b, p.a + q.a };\n-}\n-\n-// Vector by vector subtraction\n-template <typename T>\n-vtype4<T> operator-(vtype4<T> p, vtype4<T> q) {\n- return vtype4<T> { p.r - q.r, p.g - q.g, p.b - q.b, p.a - q.a };\n-}\n-\n-// Vector by vector multiplication operator\n-template <typename T>\n-vtype4<T> operator*(vtype4<T> p, vtype4<T> q) {\n- return vtype4<T> { p.r * q.r, p.g * q.g, p.b * q.b, p.a * q.a };\n-}\n-\n-// Vector by scalar multiplication operator\n-template <typename T>\n-vtype4<T> operator*(vtype4<T> p, T q) {\n- return vtype4<T> { p.r * q, p.g * q, p.b * q, p.a * q };\n-}\n-\n-// Scalar by vector multiplication operator\n-template <typename T>\n-vtype4<T> operator*(T p, vtype4<T> q) {\n- return vtype4<T> { p * q.r, p * q.g, p * q.b, p * q.a };\n-}\n-\ntypedef vtype2<float> float2;\ntypedef vtype3<float> float3;\ntypedef vtype3<int> int3;\n-typedef vtype4<int> int4;\n-typedef vtype4<unsigned int> uint4;\nstatic inline float dot(float2 p, float2 q) { return p.r * q.r + p.g * q.g; }\nstatic inline float dot(float3 p, float3 q) { return p.r * q.r + p.g * q.g + p.b * q.b; }\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -244,6 +244,14 @@ struct vint4\nreturn vgetq_lane_s32(m, l);\n}\n+ /**\n+ * @brief Set the scalar value of a single lane.\n+ */\n+ template <int l> ASTCENC_SIMD_INLINE void set_lane(float a)\n+ {\n+ m = vld1q_lane_s32(&a, m, l);\n+ }\n+\n/**\n* @brief Factory that returns a vector of zeros.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_4.h", "new_path": "Source/astcenc_vecmathlib_none_4.h", "diff": "@@ -245,6 +245,14 @@ struct vint4\nreturn m[l];\n}\n+ /**\n+ * @brief Set the scalar value of a single lane.\n+ */\n+ template <int l> ASTCENC_SIMD_INLINE void set_lane(int a)\n+ {\n+ m[l] = a;\n+ }\n+\n/**\n* @brief Factory that returns a vector of zeros.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -252,6 +252,21 @@ struct vint4\nreturn _mm_cvtsi128_si32(_mm_shuffle_epi32(m, l));\n}\n+ /**\n+ * @brief Set the scalar value of a single lane.\n+ */\n+ template <int l> ASTCENC_SIMD_INLINE void set_lane(int a)\n+ {\n+#if ASTCENC_SSE >= 41\n+ m = _mm_insert_epi32(m, a, l);\n+#else\n+ alignas(16) float idx[4];\n+ _mm_store_si128((__m128i*)idx, m);\n+ idx[l] = a;\n+ m = _mm_load_si128((const __m128i*)idx);\n+#endif\n+ }\n+\n/**\n* @brief Factory that returns a vector of zeros.\n*/\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Replace int4/uint4 with vint4 and remove vtype4
61,745
13.02.2021 17:12:20
0
df0dcf1048abef723471da0599888c612ba331fb
Fix vint4.set_lane on NEON
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -247,7 +247,7 @@ struct vint4\n/**\n* @brief Set the scalar value of a single lane.\n*/\n- template <int l> ASTCENC_SIMD_INLINE void set_lane(float a)\n+ template <int l> ASTCENC_SIMD_INLINE void set_lane(int a)\n{\nm = vld1q_lane_s32(&a, m, l);\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix vint4.set_lane on NEON
61,745
13.02.2021 19:03:15
0
70ac5b9c82de5c32fa02a71bad509f2e04f124d4
Fix SSE2 builds
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -423,7 +423,15 @@ ASTCENC_SIMD_INLINE vint4 operator-(vint4 a, vint4 b)\n*/\nASTCENC_SIMD_INLINE vint4 operator*(vint4 a, vint4 b)\n{\n+#if ASTCENC_SSE >= 41\nreturn vint4(_mm_mullo_epi32 (a.m, b.m));\n+#else\n+ __m128i t1 = _mm_mul_epu32(a.m, b.m);\n+ __m128i t2 = _mm_mul_epu32(_mm_srli_si128(a.m, 4), _mm_srli_si128(b.m, 4));\n+ __m128i r = _mm_unpacklo_epi32(_mm_shuffle_epi32(t1, _MM_SHUFFLE (0, 0, 2, 0)),\n+ _mm_shuffle_epi32(t2, _MM_SHUFFLE (0, 0, 2, 0)));\n+ return vint4(r);\n+#endif\n}\n/**\n@@ -431,7 +439,7 @@ ASTCENC_SIMD_INLINE vint4 operator*(vint4 a, vint4 b)\n*/\nASTCENC_SIMD_INLINE vint4 operator*(vint4 a, int b)\n{\n- return vint4(_mm_mullo_epi32 (a.m, _mm_set1_epi32(b)));\n+ return a * vint4(b);\n}\n/**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix SSE2 builds
61,745
13.02.2021 19:31:07
0
114eed77198d6186b06953ce8a1bca213cde4bb8
Fix vint4.set_lane on SSE2
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -1166,6 +1166,13 @@ TEST(vint4, vsmul)\nEXPECT_EQ(a.lane<1>(), 2 * 3);\nEXPECT_EQ(a.lane<2>(), 4 * 3);\nEXPECT_EQ(a.lane<3>(), 4 * 3);\n+\n+ vint4 b(1, 2, -4, 4);\n+ b = b * -3;\n+ EXPECT_EQ(b.lane<0>(), 1 * -3);\n+ EXPECT_EQ(b.lane<1>(), 2 * -3);\n+ EXPECT_EQ(b.lane<2>(), -4 * -3);\n+ EXPECT_EQ(b.lane<3>(), 4 * -3);\n}\n/** @brief Test vint4 bitwise invert. */\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -260,7 +260,7 @@ struct vint4\n#if ASTCENC_SSE >= 41\nm = _mm_insert_epi32(m, a, l);\n#else\n- alignas(16) float idx[4];\n+ alignas(16) int idx[4];\n_mm_store_si128((__m128i*)idx, m);\nidx[l] = a;\nm = _mm_load_si128((const __m128i*)idx);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix vint4.set_lane on SSE2
61,745
13.02.2021 19:39:11
0
18618d5414fb049d032ba30d39f9882c0da3d183
Use more hadd_rgb_s() for luma sums
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -668,7 +668,7 @@ static void quantize_rgbs_new(\nint gu = color_unquant_tables[quant_level][gi];\nint bu = color_unquant_tables[quant_level][bi];\n- float oldcolorsum = (rgbs_color.lane<0>() + rgbs_color.lane<1>() + rgbs_color.lane<02>()) * scale;\n+ float oldcolorsum = hadd_rgb_s(rgbs_color) * scale;\nfloat newcolorsum = (float)(ru + gu + bu);\nfloat scalea = astc::clamp1f(rgbs_color.lane<3>() * (oldcolorsum + 1e-10f) / (newcolorsum + 1e-10f));\n@@ -1562,9 +1562,8 @@ static void quantize_hdr_luminance_large_range3(\nint output[2],\nint quant_level\n) {\n-\n- float lum1 = (color1.lane<0>() + color1.lane<1>() + color1.lane<2>()) * (1.0f / 3.0f);\n- float lum0 = (color0.lane<0>() + color0.lane<1>() + color0.lane<2>()) * (1.0f / 3.0f);\n+ float lum0 = hadd_rgb_s(color0) * (1.0f / 3.0f);\n+ float lum1 = hadd_rgb_s(color1) * (1.0f / 3.0f);\nif (lum1 < lum0)\n{\n@@ -1627,8 +1626,8 @@ static int try_quantize_hdr_luminance_small_range3(\nint output[2],\nint quant_level\n) {\n- float lum1 = (color1.lane<0>() + color1.lane<1>() + color1.lane<2>()) * (1.0f / 3.0f);\n- float lum0 = (color0.lane<0>() + color0.lane<1>() + color0.lane<2>()) * (1.0f / 3.0f);\n+ float lum0 = hadd_rgb_s(color0) * (1.0f / 3.0f);\n+ float lum1 = hadd_rgb_s(color1) * (1.0f / 3.0f);\nif (lum1 < lum0)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1032,8 +1032,8 @@ static float prepare_error_weight_block(\nvfloat4 variance = ctx.input_variances[zpos * zdt + ypos * ydt + xpos];\nvariance = variance * variance;\n- float favg = (avg.lane<0>() + avg.lane<1>() + avg.lane<2>()) * (1.0f / 3.0f);\n- float fvar = (variance.lane<0>() + variance.lane<1>() + variance.lane<2>()) * (1.0f / 3.0f);\n+ float favg = hadd_rgb_s(avg) * (1.0f / 3.0f);\n+ float fvar = hadd_rgb_s(variance) * (1.0f / 3.0f);\nfloat mixing = ctx.config.v_rgba_mean_stdev_mix;\navg.set_lane<0>(favg * mixing + avg.lane<0>() * (1.0f - mixing));\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -570,7 +570,7 @@ static void compute_endpoints_and_ideal_weights_rgba(\nfor (int i = 0; i < partition_count; i++)\n{\nvfloat4 direc = directions_rgba[i];\n- if (direc.lane<0>() + direc.lane<1>() + direc.lane<2>() < 0.0f)\n+ if (hadd_rgb_s(direc) < 0.0f)\n{\ndirections_rgba[i] = vfloat4::zero() - direc;\n}\n@@ -1197,7 +1197,7 @@ void recompute_ideal_colors_2planes(\nfloat3 rgb = rgba.swz<0, 1, 2>();\n// FIXME: move this calculation out to the color block.\n- float ls_weight = color_weight.lane<0>() + color_weight.lane<1>() + color_weight.lane<2>();\n+ float ls_weight = hadd_rgb_s(color_weight);\nconst uint8_t *texel_weights = it->texel_weights_t4[tix];\nconst float *texel_weights_float = it->texel_weights_float_t4[tix];\n@@ -1276,7 +1276,7 @@ void recompute_ideal_colors_2planes(\nfloat red_sum = color_vec_x.lane<0>() + color_vec_y.lane<0>();\nfloat green_sum = color_vec_x.lane<1>() + color_vec_y.lane<1>();\nfloat blue_sum = color_vec_x.lane<2>() + color_vec_y.lane<2>();\n- float qsum = color_vec_y.lane<0>() + color_vec_y.lane<1>() + color_vec_y.lane<2>();\n+ float qsum = hadd_rgb_s(color_vec_y);\n#ifdef DEBUG_CAPTURE_NAN\nfedisableexcept(FE_DIVBYZERO | FE_INVALID);\n@@ -1518,7 +1518,7 @@ void recompute_ideal_colors_1plane(\nfloat3 rgb = rgba.swz<0, 1, 2>();\n// FIXME: move this calculation out to the color block.\n- float ls_weight = (color_weight.lane<0>() + color_weight.lane<1>() + color_weight.lane<2>());\n+ float ls_weight = hadd_rgb_s(color_weight);\nconst uint8_t *texel_weights = it->texel_weights_t4[tix];\nconst float *texel_weights_float = it->texel_weights_float_t4[tix];\n@@ -1570,7 +1570,7 @@ void recompute_ideal_colors_1plane(\nfloat red_sum = color_vec_x.lane<0>() + color_vec_y.lane<0>();\nfloat green_sum = color_vec_x.lane<1>() + color_vec_y.lane<1>();\nfloat blue_sum = color_vec_x.lane<2>() + color_vec_y.lane<2>();\n- float qsum = color_vec_y.lane<0>() + color_vec_y.lane<1>() + color_vec_y.lane<2>();\n+ float qsum = hadd_rgb_s(color_vec_y);\n#ifdef DEBUG_CAPTURE_NAN\nfedisableexcept(FE_DIVBYZERO | FE_INVALID);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -925,8 +925,7 @@ ASTCENC_SIMD_INLINE float hadd_s(vfloat4 a)\n*/\nASTCENC_SIMD_INLINE float hadd_rgb_s(vfloat4 a)\n{\n- a.set_lane<3>(0.0f);\n- return hadd_s(a);\n+ return a.lane<0>() + a.lane<1>() + a.lane<2>();\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_error_metrics.cpp", "new_path": "Source/astcenccli_error_metrics.cpp", "diff": "@@ -334,7 +334,7 @@ void compute_error_metrics(\nalpha_psnr = 10.0f * log10f(denom / alpha_num);\nprintf(\" Alpha-weighted PSNR: %9.4f dB\\n\", (double)alpha_psnr);\n- float rgb_num = errorsum.sum.lane<0>() + errorsum.sum.lane<1>() + errorsum.sum.lane<2>();\n+ float rgb_num = hadd_rgb_s(errorsum.sum);\nif (rgb_num == 0.0f)\nrgb_psnr = 999.0f;\nelse\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use more hadd_rgb_s() for luma sums
61,745
13.02.2021 23:00:10
0
914fb26d6e39aa1ca9737f4c2a2fc19e60daae9a
Use local frexp
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -41,7 +41,7 @@ static float float_to_lns(float p)\n}\nint expo;\n- float normfrac = frexpf(p, &expo);\n+ float normfrac = astc::frexp(p, &expo);\nfloat p1;\nif (expo < -13)\n{\n@@ -56,11 +56,17 @@ static float float_to_lns(float p)\n}\nif (p1 < 384.0f)\n+ {\np1 *= 4.0f / 3.0f;\n+ }\nelse if (p1 <= 1408.0f)\n+ {\np1 += 128.0f;\n+ }\nelse\n+ {\np1 = (p1 + 512.0f) * (4.0f / 5.0f);\n+ }\np1 += ((float)expo) * 2048.0f;\nreturn p1 + 1.0f;\n@@ -72,15 +78,23 @@ static uint16_t lns_to_sf16(uint16_t p)\nuint16_t ec = p >> 11;\nuint16_t mt;\nif (mc < 512)\n+ {\nmt = 3 * mc;\n+ }\nelse if (mc < 1536)\n+ {\nmt = 4 * mc - 512;\n+ }\nelse\n+ {\nmt = 5 * mc - 2048;\n+ }\nuint16_t res = (ec << 10) | (mt >> 3);\nif (res > 0x7BFF)\n+ {\nres = 0x7BFF;\n+ }\nreturn res;\n}\n@@ -91,10 +105,14 @@ static uint16_t lns_to_sf16(uint16_t p)\nuint16_t unorm16_to_sf16(uint16_t p)\n{\nif (p == 0xFFFF)\n+ {\nreturn 0x3C00; // value of 1.0\n+ }\nif (p < 4)\n+ {\nreturn p << 8;\n+ }\nint lz = clz32(p) - 16;\np <<= (lz + 1);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "to future vectorization.\n============================================================================ */\n+// Union for manipulation of float bit patterns\n+typedef union\n+{\n+ uint32_t u;\n+ int32_t s;\n+ float f;\n+} if32;\n+\n// These are namespaced to avoid colliding with C standard library functions.\nnamespace astc\n{\n@@ -405,6 +413,23 @@ static inline float sqrt(float v)\nreturn std::sqrt(v);\n}\n+/**\n+ * @brief Extract mantissa and exponent of a float value.\n+ *\n+ * @param v The input value.\n+ * @param[out] expo The output exponent.\n+ *\n+ * @return The mantissa.\n+ */\n+static inline float frexp(float v, int* expo)\n+{\n+ if32 p;\n+ p.f = v;\n+ *expo = ((p.u >> 23) & 0xFF) - 126;\n+ p.u = (p.u & 0x807fffff) | 0x3f000000;\n+ return p.f;\n+}\n+\n/**\n* @brief Log base 2, linearized from 2^-14.\n*\n@@ -580,13 +605,6 @@ static inline float3 normalize(float3 p) { return p * astc::rsqrt(dot(p, p)); }\n/* ============================================================================\nSoftfloat library with fp32 and fp16 conversion functionality.\n============================================================================ */\n-typedef union if32_\n-{\n- uint32_t u;\n- int32_t s;\n- float f;\n-} if32;\n-\nuint32_t clz32(uint32_t p);\n/* sized soft-float types. These are mapped to the sized integer\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use local frexp
61,745
14.02.2021 00:50:07
0
3213182282b439a55a516de467fefa445afa7363
Fix 4 lane swz for NEON
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -167,9 +167,9 @@ struct vfloat4\n*\n* TODO: Implement using permutes.\n*/\n- template <int l0, int l1, int l2, int l3> ASTCENC_SIMD_INLINE float3 swz() const\n+ template <int l0, int l1, int l2, int l3> ASTCENC_SIMD_INLINE vfloat4 swz() const\n{\n- return float3(lane<l0>(), lane<l1>(), lane<l2>(), lane<l3>());\n+ return vfloat4(lane<l0>(), lane<l1>(), lane<l2>(), lane<l3>());\n}\n/**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix 4 lane swz for NEON
61,745
14.02.2021 00:54:38
0
627a5d4760cce759a7120961ab8dd288a7442bde
Ensure NEON dot3() returns clear lane 3
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -942,8 +942,12 @@ ASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vfloat4 dot3(vfloat4 a, vfloat4 b)\n{\n+ // Clear lane to zero to ensure it's not in the dot()\na.set_lane<3>(0.0f);\n- return vfloat4(vaddvq_f32(vmulq_f32(a.m, b.m)));\n+ a = vfloat4(vaddvq_f32(vmulq_f32(a.m, b.m)));\n+ // Clear lane so we return only a vec3\n+ a.set_lane<3>(0.0f);\n+ return a;\n}\n/**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Ensure NEON dot3() returns clear lane 3
61,745
14.02.2021 13:36:01
0
8513e58fc4c2579a97c619fcda4bd312bf5c63b8
Directly use mask for _mm_shuffle_ps This is a workaround for GCC 7.5 which doesn't like the indirection via constexpr in debug builds (it works OK in release builds).
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -162,8 +162,7 @@ struct vfloat4\n*/\ntemplate <int l0, int l1, int l2> ASTCENC_SIMD_INLINE vfloat4 swz() const\n{\n- constexpr int mask = l0 | l1 << 2 | l2 << 4;\n- vfloat4 result(_mm_shuffle_ps(m, m, mask));\n+ vfloat4 result(_mm_shuffle_ps(m, m, l0 | l1 << 2 | l2 << 4));\nresult.set_lane<3>(0.0f);\nreturn result;\n}\n@@ -173,8 +172,7 @@ struct vfloat4\n*/\ntemplate <int l0, int l1, int l2, int l3> ASTCENC_SIMD_INLINE vfloat4 swz() const\n{\n- constexpr int mask = l0 | l1 << 2 | l2 << 4 | l3 << 6;\n- return vfloat4(_mm_shuffle_ps(m, m, mask));\n+ return vfloat4(_mm_shuffle_ps(m, m, l0 | l1 << 2 | l2 << 4 | l3 << 6));\n}\n/**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Directly use mask for _mm_shuffle_ps This is a workaround for GCC 7.5 which doesn't like the indirection via constexpr in debug builds (it works OK in release builds).
61,764
14.02.2021 15:42:14
-7,200
6b8d280bb325628a510f59c6226fe72e0e95106f
Turn int return values to bool in astcenc_color_quantize.cpp Turn int return value to bool in try_quantize_rgb_blue_contract and try_quantize_rgb_delta_blue_contract. It's more literate programming style, and makes it easier to convert to e.g. C#.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -115,7 +115,7 @@ static void quantize_rgba(\n}\n/* attempt to quantize RGB endpoint values with blue-contraction. Returns 1 on failure, 0 on success. */\n-static int try_quantize_rgb_blue_contract(\n+static bool try_quantize_rgb_blue_contract(\nvfloat4 color0, // assumed to be the smaller color\nvfloat4 color1, // assumed to be the larger color\nint output[6],\n@@ -141,7 +141,7 @@ static int try_quantize_rgb_blue_contract(\nif (r0 < 0.0f || r0 > 255.0f || g0 < 0.0f || g0 > 255.0f || b0 < 0.0f || b0 > 255.0f ||\nr1 < 0.0f || r1 > 255.0f || g1 < 0.0f || g1 > 255.0f || b1 < 0.0f || b1 > 255.0f)\n{\n- return 0;\n+ return false;\n}\n// quantize the inverse-blue-contracted color\n@@ -165,7 +165,7 @@ static int try_quantize_rgb_blue_contract(\n// we must only test AFTER blue-contraction.\nif (ru1 + gu1 + bu1 <= ru0 + gu0 + bu0)\n{\n- return 0;\n+ return false;\n}\noutput[0] = ri1;\n@@ -175,7 +175,7 @@ static int try_quantize_rgb_blue_contract(\noutput[4] = bi1;\noutput[5] = bi0;\n- return 1;\n+ return true;\n}\n/* quantize an RGBA color with blue-contraction */\n@@ -204,7 +204,7 @@ static int try_quantize_rgba_blue_contract(\n// if the sum of the offsets is nonnegative, then we encode a regular delta.\n/* attempt to quantize an RGB endpoint value with delta-encoding. */\n-static int try_quantize_rgb_delta(\n+static bool try_quantize_rgb_delta(\nvfloat4 color0,\nvfloat4 color1,\nint output[6],\n@@ -263,7 +263,7 @@ static int try_quantize_rgb_delta(\n// check if the difference is too large to be encodable.\nif (r1d > 63 || g1d > 63 || b1d > 63 || r1d < -64 || g1d < -64 || b1d < -64)\n{\n- return 0;\n+ return false;\n}\n// insert top bit of the base into the offset\n@@ -288,7 +288,7 @@ static int try_quantize_rgb_delta(\nif (((r1d ^ r1du) | (g1d ^ g1du) | (b1d ^ b1du)) & 0xC0)\n{\n- return 0;\n+ return false;\n}\n// check that the sum of the encoded offsets is nonnegative, else encoding fails\n@@ -313,7 +313,7 @@ static int try_quantize_rgb_delta(\nif (r1du + g1du + b1du < 0)\n{\n- return 0;\n+ return false;\n}\n// check that the offsets produce legitimate sums as well.\n@@ -322,7 +322,7 @@ static int try_quantize_rgb_delta(\nb1du += b0b;\nif (r1du < 0 || r1du > 0x1FF || g1du < 0 || g1du > 0x1FF || b1du < 0 || b1du > 0x1FF)\n{\n- return 0;\n+ return false;\n}\n// OK, we've come this far; we can now encode legitimate values.\n@@ -333,10 +333,10 @@ static int try_quantize_rgb_delta(\noutput[4] = b0be;\noutput[5] = b1de;\n- return 1;\n+ return true;\n}\n-static int try_quantize_rgb_delta_blue_contract(\n+static bool try_quantize_rgb_delta_blue_contract(\nvfloat4 color0,\nvfloat4 color1,\nint output[6],\n@@ -363,7 +363,7 @@ static int try_quantize_rgb_delta_blue_contract(\nif (r0 < 0.0f || r0 > 255.0f || g0 < 0.0f || g0 > 255.0f || b0 < 0.0f || b0 > 255.0f ||\nr1 < 0.0f || r1 > 255.0f || g1 < 0.0f || g1 > 255.0f || b1 < 0.0f || b1 > 255.0f)\n{\n- return 0;\n+ return false;\n}\n// transform r0 to unorm9\n@@ -408,7 +408,7 @@ static int try_quantize_rgb_delta_blue_contract(\n// check if the difference is too large to be encodable.\nif (r1d > 63 || g1d > 63 || b1d > 63 || r1d < -64 || g1d < -64 || b1d < -64)\n{\n- return 0;\n+ return false;\n}\n// insert top bit of the base into the offset\n@@ -433,7 +433,7 @@ static int try_quantize_rgb_delta_blue_contract(\nif (((r1d ^ r1du) | (g1d ^ g1du) | (b1d ^ b1du)) & 0xC0)\n{\n- return 0;\n+ return false;\n}\n// check that the sum of the encoded offsets is negative, else encoding fails\n@@ -459,7 +459,7 @@ static int try_quantize_rgb_delta_blue_contract(\nif (r1du + g1du + b1du >= 0)\n{\n- return 0;\n+ return false;\n}\n// check that the offsets produce legitimate sums as well.\n@@ -469,7 +469,7 @@ static int try_quantize_rgb_delta_blue_contract(\nif (r1du < 0 || r1du > 0x1FF || g1du < 0 || g1du > 0x1FF || b1du < 0 || b1du > 0x1FF)\n{\n- return 0;\n+ return false;\n}\n// OK, we've come this far; we can now encode legitimate values.\n@@ -480,10 +480,10 @@ static int try_quantize_rgb_delta_blue_contract(\noutput[4] = b0be;\noutput[5] = b1de;\n- return 1;\n+ return true;\n}\n-static int try_quantize_alpha_delta(\n+static bool try_quantize_alpha_delta(\nvfloat4 color0,\nvfloat4 color1,\nint output[8],\n@@ -505,7 +505,7 @@ static int try_quantize_alpha_delta(\na1d -= a0b;\nif (a1d > 63 || a1d < -64)\n{\n- return 0;\n+ return false;\n}\na1d &= 0x7F;\na1d |= (a0b & 0x100) >> 1;\n@@ -513,7 +513,7 @@ static int try_quantize_alpha_delta(\nint a1du = color_unquant_tables[quant_level][a1de];\nif ((a1d ^ a1du) & 0xC0)\n{\n- return 0;\n+ return false;\n}\na1du &= 0x7F;\nif (a1du & 0x40)\n@@ -523,14 +523,14 @@ static int try_quantize_alpha_delta(\na1du += a0b;\nif (a1du < 0 || a1du > 0x1FF)\n{\n- return 0;\n+ return false;\n}\noutput[6] = a0be;\noutput[7] = a1de;\n- return 1;\n+ return true;\n}\n-static int try_quantize_luminance_alpha_delta(\n+static bool try_quantize_luminance_alpha_delta(\nvfloat4 color0,\nvfloat4 color1,\nint output[8],\n@@ -564,11 +564,11 @@ static int try_quantize_luminance_alpha_delta(\na1d -= a0b;\nif (l1d > 63 || l1d < -64)\n{\n- return 0;\n+ return false;\n}\nif (a1d > 63 || a1d < -64)\n{\n- return 0;\n+ return false;\n}\nl1d &= 0x7F;\na1d &= 0x7F;\n@@ -581,11 +581,11 @@ static int try_quantize_luminance_alpha_delta(\nint a1du = color_unquant_tables[quant_level][a1de];\nif ((l1d ^ l1du) & 0xC0)\n{\n- return 0;\n+ return false;\n}\nif ((a1d ^ a1du) & 0xC0)\n{\n- return 0;\n+ return false;\n}\nl1du &= 0x7F;\na1du &= 0x7F;\n@@ -601,37 +601,37 @@ static int try_quantize_luminance_alpha_delta(\na1du += a0b;\nif (l1du < 0 || l1du > 0x1FF)\n{\n- return 0;\n+ return false;\n}\nif (a1du < 0 || a1du > 0x1FF)\n{\n- return 0;\n+ return false;\n}\noutput[0] = l0be;\noutput[1] = l1de;\noutput[2] = a0be;\noutput[3] = a1de;\n- return 1;\n+ return true;\n}\n-static int try_quantize_rgba_delta(\n+static bool try_quantize_rgba_delta(\nvfloat4 color0,\nvfloat4 color1,\nint output[8],\nint quant_level\n) {\n- int alpha_delta_res = try_quantize_alpha_delta(color0, color1, output, quant_level);\n+ bool alpha_delta_res = try_quantize_alpha_delta(color0, color1, output, quant_level);\n- if (alpha_delta_res == 0)\n+ if (alpha_delta_res == false)\n{\n- return 0;\n+ return false;\n}\nreturn try_quantize_rgb_delta(color0, color1, output, quant_level);\n}\n-static int try_quantize_rgba_delta_blue_contract(\n+static bool try_quantize_rgba_delta_blue_contract(\nvfloat4 color0,\nvfloat4 color1,\nint output[8],\n@@ -643,7 +643,7 @@ static int try_quantize_rgba_delta_blue_contract(\nif (alpha_delta_res == 0)\n{\n- return 0;\n+ return false;\n}\nreturn try_quantize_rgb_delta_blue_contract(color0, color1, output, quant_level);\n@@ -1620,7 +1620,7 @@ static void quantize_hdr_luminance_large_range3(\noutput[1] = color_quant_tables[quant_level][v1];\n}\n-static int try_quantize_hdr_luminance_small_range3(\n+static bool try_quantize_hdr_luminance_small_range3(\nvfloat4 color0,\nvfloat4 color1,\nint output[2],\n@@ -1642,7 +1642,7 @@ static int try_quantize_hdr_luminance_small_range3(\n// difference of more than a factor-of-2 results in immediate failure.\nif (ilum1 - ilum0 > 2048)\n{\n- return 0;\n+ return false;\n}\nint lowval, highval, diffval;\n@@ -1674,7 +1674,7 @@ static int try_quantize_hdr_luminance_small_range3(\n{\noutput[0] = v0e;\noutput[1] = v1e;\n- return 1;\n+ return true;\n}\n}\n}\n@@ -1693,14 +1693,14 @@ static int try_quantize_hdr_luminance_small_range3(\nv0d = color_unquant_tables[quant_level][v0e];\nif ((v0d & 0x80) == 0)\n{\n- return 0;\n+ return false;\n}\nlowval = (lowval & ~0x7F) | (v0d & 0x7F);\ndiffval = highval - lowval;\nif (diffval < 0 || diffval > 31)\n{\n- return 0;\n+ return false;\n}\nv1 = ((lowval >> 2) & 0xE0) | diffval;\n@@ -1708,12 +1708,12 @@ static int try_quantize_hdr_luminance_small_range3(\nv1d = color_unquant_tables[quant_level][v1e];\nif ((v1d & 0xE0) != (v1 & 0xE0))\n{\n- return 0;\n+ return false;\n}\noutput[0] = v0e;\noutput[1] = v1e;\n- return 1;\n+ return true;\n}\nstatic void quantize_hdr_alpha3(\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Turn int return values to bool in astcenc_color_quantize.cpp (#213) Turn int return value to bool in try_quantize_rgb_blue_contract and try_quantize_rgb_delta_blue_contract. It's more literate programming style, and makes it easier to convert to e.g. C#.
61,745
14.02.2021 21:15:25
0
0b9ef289a626f5393a7e014b32443d82d2868b21
Use less approximate vfloat4::normalize()
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -1059,12 +1059,19 @@ ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vfloat4 normalize(vfloat4 a)\n{\n- // Compute 1/divisor using fast rsqrt with no NR iterations\n+ // Compute 1/divisor using rsqrt with one NR iteration\n+ vfloat4 half = vfloat4(0.5f);\n+ vfloat4 three = vfloat4(3.0f);\nvfloat4 length = dot(a, a);\n+\n__m128 raw = _mm_rsqrt_ps(length.m);\n+ // Apply NR iteration\n+ __m128 ref = _mm_mul_ps(_mm_mul_ps(length.m, raw), raw);\n+ ref = _mm_mul_ps(_mm_mul_ps(half.m, raw), _mm_sub_ps(three.m, ref));\n+\n// Apply scaling factor\n- return vfloat4(_mm_mul_ps(a.m, raw));\n+ return vfloat4(_mm_mul_ps(a.m, ref));\n}\n/**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use less approximate vfloat4::normalize()
61,745
14.02.2021 22:23:45
0
b75916edc42be1002595e6fc7d4f5be8304521fd
Stop using some fast approx when ISA_INVARIANCE=ON
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -433,8 +433,11 @@ ASTCENC_SIMD_INLINE vint4 operator*(vint4 a, vint4 b)\nreturn vint4(_mm_mullo_epi32 (a.m, b.m));\n#else\n__m128i t1 = _mm_mul_epu32(a.m, b.m);\n- __m128i t2 = _mm_mul_epu32(_mm_srli_si128(a.m, 4), _mm_srli_si128(b.m, 4));\n- __m128i r = _mm_unpacklo_epi32(_mm_shuffle_epi32(t1, _MM_SHUFFLE (0, 0, 2, 0)),\n+ __m128i t2 = _mm_mul_epu32(\n+ _mm_srli_si128(a.m, 4),\n+ _mm_srli_si128(b.m, 4));\n+ __m128i r = _mm_unpacklo_epi32(\n+ _mm_shuffle_epi32(t1, _MM_SHUFFLE (0, 0, 2, 0)),\n_mm_shuffle_epi32(t2, _MM_SHUFFLE (0, 0, 2, 0)));\nreturn vint4(r);\n#endif\n@@ -1039,10 +1042,14 @@ ASTCENC_SIMD_INLINE vfloat4 dot3(vfloat4 a, vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n{\n+#if ASTCENC_ISA_INVARIANCE == 0\n// Reciprocal with a single NR iteration\n__m128 t1 = _mm_rcp_ps(b.m);\n__m128 t2 = _mm_mul_ps(b.m, _mm_mul_ps(t1, t1));\nreturn vfloat4(_mm_sub_ps(_mm_add_ps(t1, t1), t2));\n+#else\n+ return 1.0f / b;\n+#endif\n}\n/**\n@@ -1050,8 +1057,12 @@ ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)\n{\n+#if ASTCENC_ISA_INVARIANCE == 0\n// Reciprocal with no NR iteration\nreturn vfloat4(_mm_rcp_ps(b.m));\n+#else\n+ return 1.0f / b;\n+#endif\n}\n/**\n@@ -1059,19 +1070,23 @@ ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vfloat4 normalize(vfloat4 a)\n{\n+#if ASTCENC_ISA_INVARIANCE == 0\n// Compute 1/divisor using rsqrt with one NR iteration\n- vfloat4 half = vfloat4(0.5f);\n- vfloat4 three = vfloat4(3.0f);\nvfloat4 length = dot(a, a);\n-\n__m128 raw = _mm_rsqrt_ps(length.m);\n// Apply NR iteration\n+ vfloat4 half = vfloat4(0.5f);\n+ vfloat4 three = vfloat4(3.0f);\n__m128 ref = _mm_mul_ps(_mm_mul_ps(length.m, raw), raw);\nref = _mm_mul_ps(_mm_mul_ps(half.m, raw), _mm_sub_ps(three.m, ref));\n// Apply scaling factor\nreturn vfloat4(_mm_mul_ps(a.m, ref));\n+#else\n+ vfloat4 length = dot(a, a);\n+ return a / sqrt(length);\n+#endif\n}\n/**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Stop using some fast approx when ISA_INVARIANCE=ON
61,745
14.02.2021 22:41:14
0
ef1677e5ca23c6a68ffd3a053103a16e3b4671a3
Avoid loading alpha channel in c_e_s_rgb
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -83,7 +83,7 @@ static float compute_error_squared_rgb_single_partition(\ncontinue;\n}\n- vfloat4 point = blk->texel(i);\n+ vfloat4 point = blk->texel3(i);\nfloat param = dot3_s(point, lin->bs);\nvfloat4 rp1 = lin->amod + param * lin->bis;\nvfloat4 dist = rp1 - point;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Avoid loading alpha channel in c_e_s_rgb
61,745
15.02.2021 08:44:58
0
a00dc722924d0c56a7f757e617d07cbe704b0199
Make all builds ISA invariant, and remove option
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -79,13 +79,6 @@ else()\nmessage(\" -- No SIMD backend - OFF\")\nendif()\n-option(ISA_INVARIANCE \"Enable builds for ISA invariance\")\n-if(${ISA_INVARIANCE})\n- message(\" -- ISA invariant backend - ON\")\n-else()\n- message(\" -- ISA invariant backend - OFF\")\n-endif()\n-\noption(DECOMPRESSOR \"Enable builds for decompression only\")\nif(${DECOMPRESSOR})\nmessage(\" -- Decompress-only backend - ON\")\n" }, { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "@@ -105,23 +105,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-### ISA Invariance\n-\n-Normal builds are not ISA invariant, meaning that builds for different\n-instruction sets on the same CPU hardware can produce subtly different outputs.\n-This is caused by precision differences between, e.g, FMA and DOT hardware\n-instructions and their equivalent C code.\n-\n-To build an ISA invariant build add `-DISA_INVARIANCE=ON` to the CMake command\n-line when configuring. Note that this will reduce performance, as it will\n-disable use of hardware instructions that cannot be matched by the reference\n-functionality available in SSE2.\n-\n-Note that even with ISA invariance enabled we do not guarantee invariant output\n-across CPU implementations or compilers. The C specification does not require\n-bit-exact implementations for many maths library functions (`sin()`, `cos()`,\n-etc) and there are known precision differences across vendors.\n-\n### Build Types\nWe support and test the following `CMAKE_BUILD_TYPE` options.\n" }, { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "@@ -6,6 +6,19 @@ release of the 2.x series.\nAll performance data on this page is measured on an Intel Core i5-9600K\nclocked at 4.2 GHz, running astcenc using 6 threads.\n+<!-- ---------------------------------------------------------------------- -->\n+## 2.5\n+\n+**Status:** In development\n+\n+The 2.5 release is the sixth release in the 2.x series. For this release\n+onwards the 2.x series is aiming to freeze image quality compared to 2.4,\n+allowing only minor differences caused by rounding and association changes.\n+\n+**General:**\n+ * **Feature:** The `ISA_INVARIANCE` build option is no longer supported, as\n+ there is no longer any performance benefit from the variant paths. All\n+ builds are now using the equivalent of the `ISA_INVARIANCE=ON` setting.\n<!-- ---------------------------------------------------------------------- -->\n## 2.4\n" }, { "change_type": "MODIFY", "old_path": "Source/Fuzzers/build.sh", "new_path": "Source/Fuzzers/build.sh", "diff": "# SPDX-License-Identifier: Apache-2.0\n# ----------------------------------------------------------------------------\n-# Copyright 2020 Arm Limited\n+# Copyright 2020-2021 Arm Limited\n# Copyright 2020 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n@@ -31,7 +31,6 @@ for source in ./*.cpp; do\n-DASTCENC_SSE=0 \\\n-DASTCENC_AVX=0 \\\n-DASTCENC_POPCNT=0 \\\n- -DASTCENC_ISA_INVARIANCE=0 \\\n-I. -std=c++14 -mfpmath=sse -msse2 -fno-strict-aliasing -O0 -g \\\n$source \\\n-o ${BASE}.o\n@@ -45,7 +44,6 @@ for fuzzer in ./Fuzzers/fuzz_*.cpp; do\n-DASTCENC_SSE=0 \\\n-DASTCENC_AVX=0 \\\n-DASTCENC_POPCNT=0 \\\n- -DASTCENC_ISA_INVARIANCE=0 \\\n-I. -std=c++14 $fuzzer $LIB_FUZZING_ENGINE ./libastcenc.a \\\n-o $OUT/$(basename -s .cpp $fuzzer)\ndone\n" }, { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -970,28 +970,6 @@ TEST(vfloat4, dot3_s)\nEXPECT_EQ(r, 3.0f);\n}\n-/** @brief Test vfloat4 reciprocal. */\n-TEST(vfloat4, recip)\n-{\n- vfloat4 a(1.0f, 2.0f, 3.0f, 4.0f);\n- vfloat4 r = recip(a);\n- EXPECT_NEAR(r.lane<0>(), 1.0f / 1.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<1>(), 1.0f / 2.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<2>(), 1.0f / 3.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<3>(), 1.0f / 4.0f, 0.0005f);\n-}\n-\n-/** @brief Test vfloat4 reciprocal. */\n-TEST(vfloat4, fast_recip)\n-{\n- vfloat4 a(1.0f, 2.0f, 3.0f, 4.0f);\n- vfloat4 r = fast_recip(a);\n- EXPECT_NEAR(r.lane<0>(), 1.0f / 1.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<1>(), 1.0f / 2.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<2>(), 1.0f / 3.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<3>(), 1.0f / 4.0f, 0.0005f);\n-}\n-\n/** @brief Test vfloat4 normalize. */\nTEST(vfloat4, normalize)\n{\n@@ -1762,6 +1740,40 @@ TEST(vfloat8, vdiv)\nEXPECT_EQ(a.lane<7>(), 8.0f / 0.8f);\n}\n+/** @brief Test vfloat8 div. */\n+TEST(vfloat8, vsdiv)\n+{\n+ vfloat8 a(0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f);\n+ float b = 3.14f;\n+ vfloat8 r = a / b;\n+\n+ EXPECT_EQ(r.lane<0>(), 0.1f / 3.14f);\n+ EXPECT_EQ(r.lane<1>(), 0.2f / 3.14f);\n+ EXPECT_EQ(r.lane<2>(), 0.3f / 3.14f);\n+ EXPECT_EQ(r.lane<3>(), 0.4f / 3.14f);\n+ EXPECT_EQ(r.lane<4>(), 0.5f / 3.14f);\n+ EXPECT_EQ(r.lane<5>(), 0.6f / 3.14f);\n+ EXPECT_EQ(r.lane<6>(), 0.7f / 3.14f);\n+ EXPECT_EQ(r.lane<7>(), 0.8f / 3.14f);\n+}\n+\n+/** @brief Test vfloat8 div. */\n+TEST(vfloat8, svdiv)\n+{\n+ float a = 3.14f;\n+ vfloat8 b(0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f);\n+ vfloat8 r = a / b;\n+\n+ EXPECT_EQ(r.lane<0>(), 3.14f / 0.1f);\n+ EXPECT_EQ(r.lane<1>(), 3.14f / 0.2f);\n+ EXPECT_EQ(r.lane<2>(), 3.14f / 0.3f);\n+ EXPECT_EQ(r.lane<3>(), 3.14f / 0.4f);\n+ EXPECT_EQ(r.lane<4>(), 3.14f / 0.5f);\n+ EXPECT_EQ(r.lane<5>(), 3.14f / 0.6f);\n+ EXPECT_EQ(r.lane<6>(), 3.14f / 0.7f);\n+ EXPECT_EQ(r.lane<7>(), 3.14f / 0.8f);\n+}\n+\n/** @brief Test vfloat8 ceq. */\nTEST(vfloat8, ceq)\n{\n@@ -2100,37 +2112,6 @@ TEST(vfloat8, sqrt)\nEXPECT_EQ(r.lane<7>(), std::sqrt(4.0f));\n}\n-\n-/** @brief Test vfloat8 reciprocal. */\n-TEST(vfloat8, recip)\n-{\n- vfloat8 a(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f);\n- vfloat8 r = recip(a);\n- EXPECT_NEAR(r.lane<0>(), 1.0f / 1.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<1>(), 1.0f / 2.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<2>(), 1.0f / 3.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<3>(), 1.0f / 4.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<4>(), 1.0f / 5.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<5>(), 1.0f / 6.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<6>(), 1.0f / 7.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<7>(), 1.0f / 8.0f, 0.0005f);\n-}\n-\n-/** @brief Test vfloat8 reciprocal. */\n-TEST(vfloat8, fast_recip)\n-{\n- vfloat8 a(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f);\n- vfloat8 r = fast_recip(a);\n- EXPECT_NEAR(r.lane<0>(), 1.0f / 1.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<1>(), 1.0f / 2.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<2>(), 1.0f / 3.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<3>(), 1.0f / 4.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<4>(), 1.0f / 5.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<5>(), 1.0f / 6.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<6>(), 1.0f / 7.0f, 0.0005f);\n- EXPECT_NEAR(r.lane<7>(), 1.0f / 8.0f, 0.0005f);\n-}\n-\n/** @brief Test vfloat8 select. */\nTEST(vfloat8, select)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "#define ASTCENC_VECALIGN 16\n#endif\n-#ifndef ASTCENC_ISA_INVARIANCE\n- #define ASTCENC_ISA_INVARIANCE 0\n-#endif\n-\n#if ASTCENC_SSE != 0 || ASTCENC_AVX != 0\n#include <immintrin.h>\n#endif\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_avx2_8.h", "new_path": "Source/astcenc_vecmathlib_avx2_8.h", "diff": "@@ -597,6 +597,24 @@ ASTCENC_SIMD_INLINE vfloat8 operator/(vfloat8 a, vfloat8 b)\nreturn vfloat8(_mm256_div_ps(a.m, b.m));\n}\n+/**\n+ * @brief Overload: vector by scalar division.\n+ */\n+ASTCENC_SIMD_INLINE vfloat8 operator/(vfloat8 a, float b)\n+{\n+ return vfloat8(_mm256_div_ps(a.m, _mm256_set1_ps(b)));\n+}\n+\n+\n+/**\n+ * @brief Overload: scalar by vector division.\n+ */\n+ASTCENC_SIMD_INLINE vfloat8 operator/(float a, vfloat8 b)\n+{\n+ return vfloat8(_mm256_div_ps(_mm256_set1_ps(a), b.m));\n+}\n+\n+\n/**\n* @brief Overload: vector by vector equality.\n*/\n@@ -808,26 +826,6 @@ ASTCENC_SIMD_INLINE vfloat8 sqrt(vfloat8 a)\nreturn vfloat8(_mm256_sqrt_ps(a.m));\n}\n-/**\n- * @brief Generate a reciprocal of a vector.\n- */\n-ASTCENC_SIMD_INLINE vfloat8 recip(vfloat8 b)\n-{\n- // Reciprocal with a single NR iteration\n- __m256 t1 = _mm256_rcp_ps(b.m);\n- __m256 t2 = _mm256_mul_ps(b.m, _mm256_mul_ps(t1, t1));\n- return vfloat8(_mm256_sub_ps(_mm256_add_ps(t1, t1), t2));\n-}\n-\n-/**\n- * @brief Generate an approximate reciprocal of a vector.\n- */\n-ASTCENC_SIMD_INLINE vfloat8 fast_recip(vfloat8 b)\n-{\n- // Reciprocal with a no NR iteration\n- return vfloat8(_mm256_rcp_ps(b.m));\n-}\n-\n/**\n* @brief Return lanes from @c b if MSB of @c cond is set, else @c a.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -958,22 +958,6 @@ ASTCENC_SIMD_INLINE float dot3_s(vfloat4 a, vfloat4 b)\nreturn dot3(a, b).lane<0>();\n}\n-/**\n- * @brief Generate a reciprocal of a vector.\n- */\n-ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n-{\n- return 1.0f / b;\n-}\n-\n-/**\n- * @brief Generate an approximate reciprocal of a vector.\n- */\n-ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)\n-{\n- return vfloat4(vrecpeq_f32(b.m));\n-}\n-\n/**\n* @brief Normalize a vector to unit length.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_1.h", "new_path": "Source/astcenc_vecmathlib_none_1.h", "diff": "@@ -669,22 +669,6 @@ ASTCENC_SIMD_INLINE float hadd_s(vfloat1 a)\nreturn a.m;\n}\n-/**\n- * @brief Generate a reciprocal of a vector.\n- */\n-ASTCENC_SIMD_INLINE vfloat1 recip(vfloat1 b)\n-{\n- return 1.0f / b;\n-}\n-\n-/**\n- * @brief Generate an approximate reciprocal of a vector.\n- */\n-ASTCENC_SIMD_INLINE vfloat1 fast_recip(vfloat1 b)\n-{\n- return 1.0f / b;\n-}\n-\n/**\n* @brief Return lanes from @c b if MSB of @c cond is set, else @c a.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_4.h", "new_path": "Source/astcenc_vecmathlib_none_4.h", "diff": "@@ -1065,22 +1065,6 @@ ASTCENC_SIMD_INLINE vfloat4 dot3(vfloat4 a, vfloat4 b)\nreturn vfloat4(d3, d3, d3, 0.0f);\n}\n-/**\n- * @brief Generate a reciprocal of a vector.\n- */\n-ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n-{\n- return 1.0f / b;\n-}\n-\n-/**\n- * @brief Generate an approximate reciprocal of a vector.\n- */\n-ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)\n-{\n- return 1.0f / b;\n-}\n-\n/**\n* @brief Normalize a vector to unit length.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -989,12 +989,8 @@ ASTCENC_SIMD_INLINE void storea(vfloat4 a, float* p)\n*/\nASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\n{\n-#if (ASTCENC_SSE >= 41) && (ASTCENC_ISA_INVARIANCE == 0)\n- return _mm_cvtss_f32(_mm_dp_ps(a.m, b.m, 0xFF));\n-#else\nvfloat4 m = a * b;\nreturn hadd_s(m);\n-#endif\n}\n/**\n@@ -1002,12 +998,8 @@ ASTCENC_SIMD_INLINE float dot_s(vfloat4 a, vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vfloat4 dot(vfloat4 a, vfloat4 b)\n{\n-#if (ASTCENC_SSE >= 41) && (ASTCENC_ISA_INVARIANCE == 0)\n- return vfloat4(_mm_dp_ps(a.m, b.m, 0xFF));\n-#else\nvfloat4 m = a * b;\nreturn vfloat4(hadd_s(m));\n-#endif\n}\n/**\n@@ -1015,12 +1007,8 @@ ASTCENC_SIMD_INLINE vfloat4 dot(vfloat4 a, vfloat4 b)\n*/\nASTCENC_SIMD_INLINE float dot3_s(vfloat4 a, vfloat4 b)\n{\n-#if (ASTCENC_SSE >= 41) && (ASTCENC_ISA_INVARIANCE == 0)\n- return _mm_cvtss_f32(_mm_dp_ps(a.m, b.m, 0x77));\n-#else\nvfloat4 m = a * b;\nreturn hadd_rgb_s(m);\n-#endif\n}\n/**\n@@ -1028,13 +1016,9 @@ ASTCENC_SIMD_INLINE float dot3_s(vfloat4 a, vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vfloat4 dot3(vfloat4 a, vfloat4 b)\n{\n-#if (ASTCENC_SSE >= 41) && (ASTCENC_ISA_INVARIANCE == 0)\n- return vfloat4(_mm_dp_ps(a.m, b.m, 0x77));\n-#else\nvfloat4 m = a * b;\nfloat d3 = hadd_rgb_s(m);\nreturn vfloat4(d3, d3, d3, 0.0f);\n-#endif\n}\n/**\n@@ -1042,27 +1026,7 @@ ASTCENC_SIMD_INLINE vfloat4 dot3(vfloat4 a, vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\n{\n-#if ASTCENC_ISA_INVARIANCE == 0\n- // Reciprocal with a single NR iteration\n- __m128 t1 = _mm_rcp_ps(b.m);\n- __m128 t2 = _mm_mul_ps(b.m, _mm_mul_ps(t1, t1));\n- return vfloat4(_mm_sub_ps(_mm_add_ps(t1, t1), t2));\n-#else\nreturn 1.0f / b;\n-#endif\n-}\n-\n-/**\n- * @brief Generate an approximate reciprocal of a vector.\n- */\n-ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)\n-{\n-#if ASTCENC_ISA_INVARIANCE == 0\n- // Reciprocal with no NR iteration\n- return vfloat4(_mm_rcp_ps(b.m));\n-#else\n- return 1.0f / b;\n-#endif\n}\n/**\n@@ -1070,23 +1034,8 @@ ASTCENC_SIMD_INLINE vfloat4 fast_recip(vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vfloat4 normalize(vfloat4 a)\n{\n-#if ASTCENC_ISA_INVARIANCE == 0\n- // Compute 1/divisor using rsqrt with one NR iteration\n- vfloat4 length = dot(a, a);\n- __m128 raw = _mm_rsqrt_ps(length.m);\n-\n- // Apply NR iteration\n- vfloat4 half = vfloat4(0.5f);\n- vfloat4 three = vfloat4(3.0f);\n- __m128 ref = _mm_mul_ps(_mm_mul_ps(length.m, raw), raw);\n- ref = _mm_mul_ps(_mm_mul_ps(half.m, raw), _mm_sub_ps(three.m, ref));\n-\n- // Apply scaling factor\n- return vfloat4(_mm_mul_ps(a.m, ref));\n-#else\nvfloat4 length = dot(a, a);\nreturn a / sqrt(length);\n-#endif\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -137,7 +137,7 @@ static void compute_angular_offsets(\nvfloat rcp_stepsize = vfloat::lane_id() + vfloat(1.0f);\nfor (int i = 0; i < max_angular_steps; i += ASTCENC_SIMD_WIDTH) // arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\n{\n- vfloat ssize = fast_recip(rcp_stepsize);\n+ vfloat ssize = 1.0f / rcp_stepsize;\nrcp_stepsize = rcp_stepsize + vfloat(ASTCENC_SIMD_WIDTH);\nvfloat angle = atan2(loada(&anglesum_y[i]), loada(&anglesum_x[i]));\nvfloat ofs = angle * ssize * mult;\n@@ -218,7 +218,7 @@ static void compute_lowest_and_highest_weight(\n// The cut_(lowest/highest)_weight_error indicate the error that\n// results from forcing samples that should have had the weight value\n// one step (up/down).\n- vfloat ssize = fast_recip(rcp_stepsize);\n+ vfloat ssize = 1.0f / rcp_stepsize;\nvfloat errscale = ssize * ssize;\nstorea(errval * errscale, &error[sp]);\nstorea(cut_low_weight_err * errscale, &cut_low_weight_error[sp]);\n" }, { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "@@ -63,8 +63,6 @@ target_compile_features(astc${CODEC}-${ISA_SIMD}\ntarget_compile_definitions(astc${CODEC}-${ISA_SIMD}\nPRIVATE\n- # Common defines\n- ASTCENC_ISA_INVARIANCE=$<BOOL:${ISA_INVARIANCE}>\n# MSVC defines\n$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make all builds ISA invariant, and remove option
61,745
15.02.2021 21:50:07
0
00a4ed44db844ff9f18f23787e32e7f7d91a0c1c
Add vint4 unaligned store
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -904,6 +904,18 @@ TEST(vfloat4, gatherf)\nEXPECT_EQ(r.lane<3>(), 2.0f);\n}\n+/** @brief Test vfloat4 storea. */\n+TEST(vfloat4, storea)\n+{\n+ alignas(16) float out[4];\n+ vfloat4 a(f32_data);\n+ storea(a, out);\n+ EXPECT_EQ(out[0], 0.0f);\n+ EXPECT_EQ(out[1], 1.0f);\n+ EXPECT_EQ(out[2], 2.0f);\n+ EXPECT_EQ(out[3], 3.0f);\n+}\n+\n/** @brief Test vfloat4 store. */\nTEST(vfloat4, store)\n{\n@@ -916,18 +928,6 @@ TEST(vfloat4, store)\nEXPECT_EQ(out[4], 3.0f);\n}\n-/** @brief Test vfloat4 storea. */\n-TEST(vfloat4, storea)\n-{\n- alignas(16) float out[4];\n- vfloat4 a(f32_data);\n- store(a, out);\n- EXPECT_EQ(out[0], 0.0f);\n- EXPECT_EQ(out[1], 1.0f);\n- EXPECT_EQ(out[2], 2.0f);\n- EXPECT_EQ(out[3], 3.0f);\n-}\n-\n/** @brief Test vfloat4 dot. */\nTEST(vfloat4, dot)\n{\n@@ -1397,6 +1397,18 @@ TEST(vint4, storea)\nEXPECT_EQ(out[3], 3);\n}\n+/** @brief Test vint4 store. */\n+TEST(vint4, store)\n+{\n+ alignas(16) int out[5];\n+ vint4 a(s32_data);\n+ store(a, &(out[1]));\n+ EXPECT_EQ(out[1], 0);\n+ EXPECT_EQ(out[2], 1);\n+ EXPECT_EQ(out[3], 2);\n+ EXPECT_EQ(out[4], 3);\n+}\n+\n/** @brief Test vint4 store_nbytes. */\nTEST(vint4, store_nbytes)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -534,6 +534,14 @@ ASTCENC_SIMD_INLINE void storea(vint4 a, int* p)\nvst1q_s32(p, a.m);\n}\n+/**\n+ * @brief Store a vector to an unaligned memory address.\n+ */\n+ASTCENC_SIMD_INLINE void store(vint4 a, int* p)\n+{\n+ vst1q_s32(p, a.m);\n+}\n+\n/**\n* @brief Store lowest N (vector width) bytes into an unaligned address.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_4.h", "new_path": "Source/astcenc_vecmathlib_none_4.h", "diff": "@@ -601,6 +601,17 @@ ASTCENC_SIMD_INLINE void storea(vint4 a, int* p)\np[3] = a.m[3];\n}\n+/**\n+ * @brief Store a vector to an unaligned memory address.\n+ */\n+ASTCENC_SIMD_INLINE void store(vint4 a, int* p)\n+{\n+ p[0] = a.m[0];\n+ p[1] = a.m[1];\n+ p[2] = a.m[2];\n+ p[3] = a.m[3];\n+}\n+\n/**\n* @brief Store lowest N (vector width) bytes into an unaligned address.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -571,14 +571,21 @@ ASTCENC_SIMD_INLINE void storea(vint4 a, int* p)\n_mm_store_si128((__m128i*)p, a.m);\n}\n+/**\n+ * @brief Store a vector to an unaligned memory address.\n+ */\n+ASTCENC_SIMD_INLINE void store(vint4 a, int* p)\n+{\n+ // Cast due to missing intrinsics\n+ _mm_storeu_ps((float*)p, _mm_castsi128_ps(a.m));\n+}\n+\n/**\n* @brief Store lowest N (vector width) bytes into an unaligned address.\n*/\nASTCENC_SIMD_INLINE void store_nbytes(vint4 a, uint8_t* p)\n{\n- // This is the most logical implementation, but the convenience intrinsic\n- // is missing on older compilers (supported in g++ 9 and clang++ 9).\n- // _mm_storeu_si32(ptr, v.m);\n+ // Cast due to missing intrinsics\n_mm_store_ss((float*)p, _mm_castsi128_ps(a.m));\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add vint4 unaligned store
61,745
15.02.2021 21:50:19
0
0d5e577ebb39737ea640a79af912b8d48b2dd25a
Vectorize constant color blocks
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1325,21 +1325,10 @@ void compress_block(\n// Encode as UNORM16 if NOT using HDR.\nscb.block_mode = -2;\nscb.partition_count = 0;\n- vfloat4 orig_color = blk->origin_texel;\n- float red = orig_color.lane<0>();\n- float green = orig_color.lane<1>();\n- float blue = orig_color.lane<2>();\n- float alpha = orig_color.lane<3>();\n-\n- red = astc::clamp(red, 0.0f, 1.0f);\n- green = astc::clamp(green, 0.0f, 1.0f);\n- blue = astc::clamp(blue, 0.0f, 1.0f);\n- alpha = astc::clamp(alpha, 0.0f, 1.0f);\n-\n- scb.constant_color[0] = astc::flt2int_rtn(red * 65535.0f);\n- scb.constant_color[1] = astc::flt2int_rtn(green * 65535.0f);\n- scb.constant_color[2] = astc::flt2int_rtn(blue * 65535.0f);\n- scb.constant_color[3] = astc::flt2int_rtn(alpha * 65535.0f);\n+\n+ vfloat4 color_u16f = clamp(0.0f, 1.0f, blk->origin_texel) * 65535.0f;\n+ vint4 color_u16i = float_to_int_rtn(color_u16f);\n+ store(color_u16i, scb.constant_color);\n}\ntrace_add_data(\"exit\", \"quality hit\");\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Vectorize constant color blocks
61,745
15.02.2021 22:16:08
0
8b4d31e63aff40243c8b57d6da8b12a8eda06486
Drop int3 and vtype3 template
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compute_variance.cpp", "new_path": "Source/astcenc_compute_variance.cpp", "diff": "@@ -119,13 +119,13 @@ static void compute_pixel_region_variance(\nastcenc_swizzle swz = arg->swz;\nint have_z = arg->have_z;\n- int size_x = arg->size.r;\n- int size_y = arg->size.g;\n- int size_z = arg->size.b;\n+ int size_x = arg->size_x;\n+ int size_y = arg->size_y;\n+ int size_z = arg->size_z;\n- int offset_x = arg->offset.r;\n- int offset_y = arg->offset.g;\n- int offset_z = arg->offset.b;\n+ int offset_x = arg->offset_x;\n+ int offset_y = arg->offset_y;\n+ int offset_z = arg->offset_z;\nint avg_var_kernel_radius = arg->avg_var_kernel_radius;\nint alpha_kernel_radius = arg->alpha_kernel_radius;\n@@ -536,15 +536,14 @@ void compute_averages_and_variances(\npixel_region_variance_args arg = ag.arg;\narg.work_memory = new vfloat4[ag.work_memory_size];\n- int size_x = ag.img_size.r;\n- int size_y = ag.img_size.g;\n- int size_z = ag.img_size.b;\n+ int size_x = ag.img_size_x;\n+ int size_y = ag.img_size_y;\n+ int size_z = ag.img_size_z;\n- int step_x = ag.blk_size.r;\n- int step_y = ag.blk_size.g;\n- int step_z = ag.blk_size.b;\n+ int step_xy = ag.blk_size_xy;\n+ int step_z = ag.blk_size_z;\n- int y_tasks = (size_y + step_y - 1) / step_y;\n+ int y_tasks = (size_y + step_xy - 1) / step_xy;\n// All threads run this processing loop until there is no work remaining\nwhile (true)\n@@ -558,18 +557,18 @@ void compute_averages_and_variances(\nassert(count == 1);\nint z = (base / (y_tasks)) * step_z;\n- int y = (base - (z * y_tasks)) * step_y;\n+ int y = (base - (z * y_tasks)) * step_xy;\n- arg.size.b = astc::min(step_z, size_z - z);\n- arg.offset.b = z;\n+ arg.size_z = astc::min(step_z, size_z - z);\n+ arg.offset_z = z;\n- arg.size.g = astc::min(step_y, size_y - y);\n- arg.offset.g = y;\n+ arg.size_y = astc::min(step_xy, size_y - y);\n+ arg.offset_y = y;\n- for (int x = 0; x < size_x; x += step_x)\n+ for (int x = 0; x < size_x; x += step_xy)\n{\n- arg.size.r = astc::min(step_x, size_x - x);\n- arg.offset.r = x;\n+ arg.size_x = astc::min(step_xy, size_x - x);\n+ arg.offset_x = x;\ncompute_pixel_region_variance(ctx, &arg);\n}\n@@ -607,8 +606,12 @@ 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 = int3(0);\n- arg.offset = int3(0);\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;\narg.work_memory = nullptr;\narg.img = &img;\n@@ -620,8 +623,11 @@ unsigned int init_compute_averages_and_variances(\narg.alpha_kernel_radius = alpha_kernel_radius;\nag.arg = arg;\n- ag.img_size = int3(size_x, size_y, size_z);\n- ag.blk_size = int3(max_blk_size_xy, max_blk_size_xy, max_blk_size_z);\n+ ag.img_size_x = size_x;\n+ ag.img_size_y = size_y;\n+ ag.img_size_z = size_z;\n+ ag.blk_size_xy = max_blk_size_xy;\n+ ag.blk_size_z = max_blk_size_z;\nag.work_memory_size = 2 * max_padsize_xy * max_padsize_xy * max_padsize_z;\n// The parallel task count\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -946,9 +946,13 @@ struct pixel_region_variance_args\n/** The kernel radius for alpha processing. */\nint alpha_kernel_radius;\n/** The size of the working data to process. */\n- int3 size;\n+ int size_x;\n+ int size_y;\n+ int size_z;\n/** The position of first src and dst data in the data set. */\n- int3 offset;\n+ int offset_x;\n+ int offset_y;\n+ int offset_z;\n/** The working memory buffer. */\nvfloat4 *work_memory;\n};\n@@ -961,9 +965,12 @@ struct avg_var_args\n/** The arguments for the nested variance computation. */\npixel_region_variance_args arg;\n/** The image dimensions. */\n- int3 img_size;\n+ int img_size_x;\n+ int img_size_y;\n+ int img_size_z;\n/** The maximum working block dimensions. */\n- int3 blk_size;\n+ int blk_size_xy;\n+ int blk_size_z;\n/** The working block memory size. */\nint work_memory_size;\n};\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "@@ -531,65 +531,7 @@ vtype2<T> operator*(T p, vtype2<T> q) {\nreturn vtype2<T> { p * q.r, p * q.g };\n}\n-template <typename T> class vtype3\n-{\n-public:\n- // Data storage\n- T r, g, b;\n-\n- // Default constructor\n- vtype3() {}\n-\n- // Initialize from 1 scalar\n- vtype3(T p) : r(p), g(p), b(p) {}\n-\n- // Initialize from N scalars\n- vtype3(T p, T q, T s) : r(p), g(q), b(s) {}\n-\n- // Initialize from another vector\n- vtype3(const vtype3 & p) : r(p.r), g(p.g), b(p.b) {}\n-\n- // Assignment operator\n- vtype3& operator=(const vtype3 &s) {\n- this->r = s.r;\n- this->g = s.g;\n- this->b = s.b;\n- return *this;\n- }\n-};\n-\n-// Vector by vector addition\n-template <typename T>\n-vtype3<T> operator+(vtype3<T> p, vtype3<T> q) {\n- return vtype3<T> { p.r + q.r, p.g + q.g, p.b + q.b };\n-}\n-\n-// Vector by vector subtraction\n-template <typename T>\n-vtype3<T> operator-(vtype3<T> p, vtype3<T> q) {\n- return vtype3<T> { p.r - q.r, p.g - q.g, p.b - q.b };\n-}\n-\n-// Vector by vector multiplication operator\n-template <typename T>\n-vtype3<T> operator*(vtype3<T> p, vtype3<T> q) {\n- return vtype3<T> { p.r * q.r, p.g * q.g, p.b * q.b };\n-}\n-\n-// Vector by scalar multiplication operator\n-template <typename T>\n-vtype3<T> operator*(vtype3<T> p, T q) {\n- return vtype3<T> { p.r * q, p.g * q, p.b * q };\n-}\n-\n-// Scalar by vector multiplication operator\n-template <typename T>\n-vtype3<T> operator*(T p, vtype3<T> q) {\n- return vtype3<T> { p * q.r, p * q.g, p * q.b };\n-}\n-\ntypedef vtype2<float> float2;\n-typedef vtype3<int> int3;\nstatic inline float dot(float2 p, float2 q) { return p.r * q.r + p.g * q.g; }\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Drop int3 and vtype3 template
61,745
15.02.2021 23:57:06
0
05a435d649e61c1bb4be8244a767bf4f680e78d9
Restructure compute_encoding_choice_errors
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -75,13 +75,15 @@ static void compute_error_squared_rgb_single_partition(\nconst processed_line3* rgbl_pline,\nfloat* rgbl_err,\nconst processed_line3* l_pline,\n- float* l_err\n+ float* l_err,\n+ float* a_drop_err\n) {\nint texels_per_block = bsd->texel_count;\nfloat uncor_errorsum = 0.0f;\nfloat samec_errorsum = 0.0f;\nfloat rgbl_errorsum = 0.0f;\nfloat l_errorsum = 0.0f;\n+ float a_drop_errorsum = 0.0f;\nfor (int i = 0; i < texels_per_block; i++)\n{\n@@ -92,9 +94,14 @@ static void compute_error_squared_rgb_single_partition(\ncontinue;\n}\n- vfloat4 point = blk->texel3(i);\n+ vfloat4 point = blk->texel(i);\nvfloat4 ews = ewb->error_weights[i];\n+ // Compute the error that arises from just ditching alpha\n+ float default_alpha = blk->alpha_lns[i] ? (float)0x7800 : (float)0xFFFF;\n+ float omalpha = point.lane<3>() - default_alpha;\n+ a_drop_errorsum += omalpha * omalpha * ews.lane<3>();\n+\n{\nfloat param = dot3_s(point, uncor_pline->bs);\nvfloat4 rp1 = uncor_pline->amod + param * uncor_pline->bis;\n@@ -118,7 +125,8 @@ static void compute_error_squared_rgb_single_partition(\n{\nfloat param = dot3_s(point, l_pline->bs);\n- vfloat4 rp1 = l_pline->amod + param * l_pline->bis;\n+ // No luma amod - we know it's always zero\n+ vfloat4 rp1 = /* l_pline->amod + */ param * l_pline->bis;\nvfloat4 dist = rp1 - point;\nl_errorsum += dot3_s(ews, dist * dist);\n}\n@@ -128,6 +136,7 @@ static void compute_error_squared_rgb_single_partition(\n*samec_err = samec_errorsum;\n*rgbl_err = rgbl_errorsum;\n*l_err = l_errorsum;\n+ *a_drop_err = a_drop_errorsum;\n}\n/*\n@@ -157,157 +166,122 @@ void compute_encoding_choice_errors(\nvfloat4 directions_rgb[4];\nvfloat4 error_weightings[4];\nvfloat4 color_scalefactors[4];\n- vfloat4 inverse_color_scalefactors[4];\ncompute_partition_error_color_weightings(bsd, ewb, pi, error_weightings, color_scalefactors);\ncompute_averages_and_directions_rgb(pi, pb, ewb, color_scalefactors, averages, directions_rgb);\n- line3 uncorr_rgb_lines[4];\n- line3 samechroma_rgb_lines[4]; // for LDR-RGB-scale\n- line3 rgb_luma_lines[4]; // for HDR-RGB-scale\n- line3 luminance_lines[4];\n-\n- processed_line3 proc_uncorr_rgb_lines[4];\n- processed_line3 proc_samechroma_rgb_lines[4]; // for LDR-RGB-scale\n- processed_line3 proc_rgb_luma_lines[4]; // for HDR-RGB-scale\n- processed_line3 proc_luminance_lines[4];\n+ endpoints ep;\n+ if (separate_component == -1)\n+ {\n+ endpoints_and_weights ei;\n+ compute_endpoints_and_ideal_weights_1_plane(bsd, pi, pb, ewb, &ei);\n+ ep = ei.ep;\n+ }\n+ else\n+ {\n+ endpoints_and_weights ei1, ei2;\n+ compute_endpoints_and_ideal_weights_2_planes(bsd, pi, pb, ewb, separate_component, &ei1, &ei2);\n+ merge_endpoints(&(ei1.ep), &(ei2.ep), separate_component, &ep);\n+ }\nfor (int i = 0; i < partition_count; i++)\n{\n- inverse_color_scalefactors[i] = 1.0f / max(color_scalefactors[i], 1e-7f);\n+ // TODO: Can we skip rgb_luma_lines for LDR images?\n+ line3 uncorr_rgb_lines;\n+ line3 samechroma_rgb_lines; // for LDR-RGB-scale\n+ line3 rgb_luma_lines; // for HDR-RGB-scale\n+\n+ processed_line3 proc_uncorr_rgb_lines;\n+ processed_line3 proc_samechroma_rgb_lines; // for LDR-RGB-scale\n+ processed_line3 proc_rgb_luma_lines; // for HDR-RGB-scale\n+ processed_line3 proc_luminance_lines;\n+\n+ float uncorr_rgb_error;\n+ float samechroma_rgb_error;\n+ float rgb_luma_error;\n+ float luminance_rgb_error;\n+ float alpha_drop_error;\nvfloat4 csf = color_scalefactors[i];\ncsf.set_lane<3>(0.0f);\n- vfloat4 icsf = inverse_color_scalefactors[i];\n+ vfloat4 icsf = 1.0f / max(color_scalefactors[i], 1e-7f);\nicsf.set_lane<3>(0.0f);\n- uncorr_rgb_lines[i].a = averages[i];\n+ uncorr_rgb_lines.a = averages[i];\nif (dot3_s(directions_rgb[i], directions_rgb[i]) == 0.0f)\n{\n- uncorr_rgb_lines[i].b = normalize(csf);\n+ uncorr_rgb_lines.b = normalize(csf);\n}\nelse\n{\n- uncorr_rgb_lines[i].b = normalize(directions_rgb[i]);\n+ uncorr_rgb_lines.b = normalize(directions_rgb[i]);\n}\n- samechroma_rgb_lines[i].a = vfloat4::zero();\n+ samechroma_rgb_lines.a = vfloat4::zero();\nif (dot3_s(averages[i], averages[i]) < 1e-20f)\n{\n- samechroma_rgb_lines[i].b = normalize(csf);\n+ samechroma_rgb_lines.b = normalize(csf);\n}\nelse\n{\n- samechroma_rgb_lines[i].b = normalize(averages[i]);\n+ samechroma_rgb_lines.b = normalize(averages[i]);\n}\n- rgb_luma_lines[i].a = averages[i];\n- rgb_luma_lines[i].b = normalize(csf);\n+ rgb_luma_lines.a = averages[i];\n+ rgb_luma_lines.b = normalize(csf);\n- luminance_lines[i].a = vfloat4::zero();\n- luminance_lines[i].b = normalize(csf);\n+ proc_uncorr_rgb_lines.amod = (uncorr_rgb_lines.a - uncorr_rgb_lines.b * dot3_s(uncorr_rgb_lines.a, uncorr_rgb_lines.b)) * icsf;\n+ proc_uncorr_rgb_lines.bs = uncorr_rgb_lines.b * csf;\n+ proc_uncorr_rgb_lines.bis = uncorr_rgb_lines.b * icsf;\n- // TODO: Can these just be dot3() (not scalar - return three lanes)\n- proc_uncorr_rgb_lines[i].amod = (uncorr_rgb_lines[i].a - uncorr_rgb_lines[i].b * dot3_s(uncorr_rgb_lines[i].a, uncorr_rgb_lines[i].b)) * icsf;\n- proc_uncorr_rgb_lines[i].bs = uncorr_rgb_lines[i].b * csf;\n- proc_uncorr_rgb_lines[i].bis = uncorr_rgb_lines[i].b * icsf;\n+ proc_samechroma_rgb_lines.amod = (samechroma_rgb_lines.a - samechroma_rgb_lines.b * dot3_s(samechroma_rgb_lines.a, samechroma_rgb_lines.b)) * icsf;\n+ proc_samechroma_rgb_lines.bs = samechroma_rgb_lines.b * csf;\n+ proc_samechroma_rgb_lines.bis = samechroma_rgb_lines.b * icsf;\n- proc_samechroma_rgb_lines[i].amod = (samechroma_rgb_lines[i].a - samechroma_rgb_lines[i].b * dot3_s(samechroma_rgb_lines[i].a, samechroma_rgb_lines[i].b)) * icsf;\n- proc_samechroma_rgb_lines[i].bs = samechroma_rgb_lines[i].b * csf;\n- proc_samechroma_rgb_lines[i].bis = samechroma_rgb_lines[i].b * icsf;\n+ proc_rgb_luma_lines.amod = (rgb_luma_lines.a - rgb_luma_lines.b * dot3_s(rgb_luma_lines.a, rgb_luma_lines.b)) * icsf;\n+ proc_rgb_luma_lines.bs = rgb_luma_lines.b * csf;\n+ proc_rgb_luma_lines.bis = rgb_luma_lines.b * icsf;\n- proc_rgb_luma_lines[i].amod = (rgb_luma_lines[i].a - rgb_luma_lines[i].b * dot3_s(rgb_luma_lines[i].a, rgb_luma_lines[i].b)) * icsf;\n- proc_rgb_luma_lines[i].bs = rgb_luma_lines[i].b * csf;\n- proc_rgb_luma_lines[i].bis = rgb_luma_lines[i].b * icsf;\n-\n- proc_luminance_lines[i].amod = (luminance_lines[i].a - luminance_lines[i].b * dot3_s(luminance_lines[i].a, luminance_lines[i].b)) * icsf;\n- proc_luminance_lines[i].bs = luminance_lines[i].b * csf;\n- proc_luminance_lines[i].bis = luminance_lines[i].b * icsf;\n- }\n+ // Luminance always goes though zero, so this is simpler than the others\n+ proc_luminance_lines.amod = vfloat4::zero();\n+ proc_luminance_lines.bs = normalize(csf) * csf;\n+ proc_luminance_lines.bis = normalize(csf) * icsf;\n- float uncorr_rgb_error[4];\n- float samechroma_rgb_error[4];\n- float rgb_luma_error[4];\n- float luminance_rgb_error[4];\n-\n- for (int i = 0; i < partition_count; i++)\n- {\ncompute_error_squared_rgb_single_partition(\ni, bsd, pi, pb, ewb,\n- proc_uncorr_rgb_lines + i, uncorr_rgb_error + i,\n- proc_samechroma_rgb_lines + i, samechroma_rgb_error + i,\n- proc_rgb_luma_lines + i, rgb_luma_error + i,\n- proc_luminance_lines + i, luminance_rgb_error + i);\n- }\n-\n- // Compute the error that arises from just ditching alpha\n- // TODO: Skip this if the input has constant 1 alpha\n- float alpha_drop_error[4] { 0 };\n- for (int i = 0; i < texels_per_block; i++)\n- {\n- int partition = pi->partition_of_texel[i];\n- float alpha = pb->data_a[i];\n- float default_alpha = pb->alpha_lns[i] ? (float)0x7800 : (float)0xFFFF;\n-\n- float omalpha = alpha - default_alpha;\n- alpha_drop_error[partition] += omalpha * omalpha * ewb->error_weights[i].lane<3>();\n- }\n+ &proc_uncorr_rgb_lines, &uncorr_rgb_error,\n+ &proc_samechroma_rgb_lines, &samechroma_rgb_error,\n+ &proc_rgb_luma_lines, &rgb_luma_error,\n+ &proc_luminance_lines, &luminance_rgb_error,\n+ &alpha_drop_error);\n- // check if we are eligible for blue-contraction and offset-encoding\n- endpoints ep;\n- if (separate_component == -1)\n- {\n- endpoints_and_weights ei;\n- compute_endpoints_and_ideal_weights_1_plane(bsd, pi, pb, ewb, &ei);\n- ep = ei.ep;\n- }\n- else\n- {\n- endpoints_and_weights ei1, ei2;\n- compute_endpoints_and_ideal_weights_2_planes(bsd, pi, pb, ewb, separate_component, &ei1, &ei2);\n- merge_endpoints(&(ei1.ep), &(ei2.ep), separate_component, &ep);\n- }\n-\n- bool can_offset_encode[4] { 0 };\n- bool can_blue_contract[4] { 0 };\n- for (int i = 0; i < partition_count; i++)\n- {\n+ // Determine if we can offset encode RGB lanes\nvfloat4 endpt0 = ep.endpt0[i];\nvfloat4 endpt1 = ep.endpt1[i];\n-\n- vfloat4 endpt_dif = endpt1 - endpt0;\n- if (fabsf(endpt_dif.lane<0>()) < (0.12f * 65535.0f) &&\n- fabsf(endpt_dif.lane<1>()) < (0.12f * 65535.0f) &&\n- fabsf(endpt_dif.lane<2>()) < (0.12f * 65535.0f))\n- {\n- can_offset_encode[i] = true;\n- }\n-\n- endpt0.set_lane<0>(endpt0.lane<0>() + (endpt0.lane<0>() - endpt0.lane<2>()));\n- endpt0.set_lane<1>(endpt0.lane<1>() + (endpt0.lane<1>() - endpt0.lane<2>()));\n-\n- endpt1.set_lane<0>(endpt1.lane<0>() + (endpt1.lane<0>() - endpt1.lane<2>()));\n- endpt1.set_lane<1>(endpt1.lane<1>() + (endpt1.lane<1>() - endpt1.lane<2>()));\n-\n- if (endpt0.lane<0>() > (0.01f * 65535.0f) && endpt0.lane<0>() < (0.99f * 65535.0f) &&\n- endpt1.lane<0>() > (0.01f * 65535.0f) && endpt1.lane<0>() < (0.99f * 65535.0f) &&\n- endpt0.lane<1>() > (0.01f * 65535.0f) && endpt0.lane<1>() < (0.99f * 65535.0f) &&\n- endpt1.lane<1>() > (0.01f * 65535.0f) && endpt1.lane<1>() < (0.99f * 65535.0f))\n- {\n- can_blue_contract[i] = true;\n- }\n- }\n-\n- // finally, gather up our results\n- for (int i = 0; i < partition_count; i++)\n- {\n- eci[i].rgb_scale_error = (samechroma_rgb_error[i] - uncorr_rgb_error[i]) * 0.7f; // empirical\n- eci[i].rgb_luma_error = (rgb_luma_error[i] - uncorr_rgb_error[i]) * 1.5f; // wild guess\n- eci[i].luminance_error = (luminance_rgb_error[i] - uncorr_rgb_error[i]) * 3.0f; // empirical\n- eci[i].alpha_drop_error = alpha_drop_error[i] * 3.0f;\n- eci[i].can_offset_encode = can_offset_encode[i];\n- eci[i].can_blue_contract = can_blue_contract[i];\n+ vfloat4 endpt_diff = abs(endpt1 - endpt0);\n+ vmask4 endpt_can_offset = endpt_diff < vfloat4(0.12f * 65535.0f);\n+ bool can_offset_encode = (mask(endpt_can_offset) & 0x7) == 0x7;\n+\n+ // Determine if we can blue contract encode RGB lanes\n+ vfloat4 endpt_diff_bc(\n+ endpt0.lane<0>() + (endpt0.lane<0>() - endpt0.lane<2>()),\n+ endpt1.lane<0>() + (endpt1.lane<0>() - endpt1.lane<2>()),\n+ endpt0.lane<1>() + (endpt0.lane<1>() - endpt0.lane<2>()),\n+ endpt1.lane<1>() + (endpt1.lane<1>() - endpt1.lane<2>())\n+ );\n+\n+ vmask4 endpt_can_bc_lo = endpt_diff_bc > vfloat4(0.01f * 65535.0f);\n+ vmask4 endpt_can_bc_hi = endpt_diff_bc < vfloat4(0.99f * 65535.0f);\n+ bool can_blue_contract = (mask(endpt_can_bc_lo & endpt_can_bc_hi) & 0x7) == 0x7;\n+\n+ // Store out the settings\n+ eci[i].rgb_scale_error = (samechroma_rgb_error - uncorr_rgb_error) * 0.7f; // empirical\n+ eci[i].rgb_luma_error = (rgb_luma_error - uncorr_rgb_error) * 1.5f; // wild guess\n+ eci[i].luminance_error = (luminance_rgb_error - uncorr_rgb_error) * 3.0f; // empirical\n+ eci[i].alpha_drop_error = alpha_drop_error * 3.0f;\n+ eci[i].can_offset_encode = can_offset_encode;\n+ eci[i].can_blue_contract = can_blue_contract;\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Restructure compute_encoding_choice_errors
61,745
17.02.2021 07:45:44
0
8509164cfda8264248b00c84158d85fe0b384013
Remove compute_averages_and_directions_rgb Reducing code size and using the already existing common compute_averages_and_directions_3_components is slightly faster ...
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -133,92 +133,6 @@ void compute_averages_and_directions_rgba(\n}\n}\n-void compute_averages_and_directions_rgb(\n- const partition_info* pt,\n- const imageblock* blk,\n- const error_weight_block* ewb,\n- const vfloat4* color_scalefactors,\n- vfloat4* averages,\n- vfloat4* directions_rgb\n-) {\n- const float *texel_weights = ewb->texel_weight_rgb;\n-\n- int partition_count = pt->partition_count;\n- promise(partition_count > 0);\n-\n- for (int partition = 0; partition < partition_count; partition++)\n- {\n- const uint8_t *weights = pt->texels_of_partition[partition];\n-\n- vfloat4 base_sum = vfloat4::zero();\n- float partition_weight = 0.0f;\n-\n- int texel_count = pt->texels_per_partition[partition];\n- promise(texel_count > 0);\n-\n- for (int i = 0; i < texel_count; i++)\n- {\n- int iwt = weights[i];\n- float weight = texel_weights[iwt];\n- vfloat4 texel_datum = blk->texel3(iwt) * weight;\n-\n- partition_weight += weight;\n- base_sum = base_sum + texel_datum;\n- }\n-\n- vfloat4 csf = color_scalefactors[partition];\n- vfloat4 average = base_sum * (1.0f / astc::max(partition_weight, 1e-7f));\n- averages[partition] = average * csf;\n-\n- vfloat4 sum_xp = vfloat4::zero();\n- vfloat4 sum_yp = vfloat4::zero();\n- vfloat4 sum_zp = vfloat4::zero();\n-\n- for (int i = 0; i < texel_count; i++)\n- {\n- int iwt = weights[i];\n- float weight = texel_weights[iwt];\n- vfloat4 texel_datum = blk->texel3(iwt);\n- texel_datum = (texel_datum - average) * weight;\n-\n- if (texel_datum.lane<0>() > 0.0f)\n- {\n- sum_xp = sum_xp + texel_datum;\n- }\n-\n- if (texel_datum.lane<1>() > 0.0f)\n- {\n- sum_yp = sum_yp + texel_datum;\n- }\n-\n- if (texel_datum.lane<2>() > 0.0f)\n- {\n- sum_zp = sum_zp + texel_datum;\n- }\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- directions_rgb[partition] = best_vector;\n- }\n-}\n-\nvoid compute_averages_and_directions_3_components(\nconst partition_info* pt,\nconst imageblock* blk,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -168,7 +168,7 @@ void compute_encoding_choice_errors(\nvfloat4 color_scalefactors[4];\ncompute_partition_error_color_weightings(bsd, ewb, pi, error_weightings, color_scalefactors);\n- compute_averages_and_directions_rgb(pi, pb, ewb, color_scalefactors, averages, directions_rgb);\n+ compute_averages_and_directions_3_components(pi, pb, ewb, color_scalefactors, 3, averages, directions_rgb);\nendpoints ep;\nif (separate_component == -1)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -465,7 +465,7 @@ void find_best_partitionings(\nvfloat4 averages[4];\nvfloat4 directions_rgb[4];\n- compute_averages_and_directions_rgb(ptab + partition, blk, ewb, color_scalefactors, averages, directions_rgb);\n+ compute_averages_and_directions_3_components(ptab + partition, blk, ewb, color_scalefactors, 3, averages, directions_rgb);\nline3 uncorr_lines[4];\nline3 samechroma_lines[4];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -824,15 +824,6 @@ void build_quant_mode_table(void);\n// functions to compute color averages and dominant directions\n// for each partition in a block\n-\n-void compute_averages_and_directions_rgb(\n- const partition_info* pt,\n- const imageblock* blk,\n- const error_weight_block* ewb,\n- const vfloat4* color_scalefactors,\n- vfloat4* averages,\n- vfloat4* directions_rgb);\n-\nvoid compute_averages_and_directions_rgba(\nconst partition_info* pt,\nconst imageblock* blk,\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove compute_averages_and_directions_rgb Reducing code size and using the already existing common compute_averages_and_directions_3_components is slightly faster ...