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 |
12.04.2021 22:25:47
| -3,600 |
cc14d268ce9dc05d9af4748bb20bd997669daf3d
|
Simplify error block / end point handling
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_color_unquantize.cpp",
"new_path": "Source/astcenc_color_unquantize.cpp",
"diff": "@@ -671,14 +671,10 @@ void unpack_color_endpoints(\nconst int* input,\nbool* rgb_hdr,\nbool* alpha_hdr,\n- bool* nan_endpoint,\nvint4* output0,\nvint4* output1\n) {\n- // Assume no NaNs and LDR endpoints\n-\n- // TODO: Review use of NaN endpoint. It's never set for HDR images ...\n- *nan_endpoint = false;\n+ // Assume no NaNs and LDR endpoints unless set later\n*rgb_hdr = false;\n*alpha_hdr = false;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -75,7 +75,6 @@ static int realign_weights(\n// Decode the color endpoints\nbool rgb_hdr;\nbool alpha_hdr;\n- bool nan_endpoint;\nvint4 endpnt0[4];\nvint4 endpnt1[4];\nvfloat4 endpnt0f[4];\n@@ -91,7 +90,7 @@ static int realign_weights(\nscb->color_formats[pa_idx],\nscb->color_quant_level,\nscb->color_values[pa_idx],\n- &rgb_hdr, &alpha_hdr, &nan_endpoint,\n+ &rgb_hdr, &alpha_hdr,\n&endpnt0[pa_idx],\n&endpnt1[pa_idx]);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_decompress_symbolic.cpp",
"new_path": "Source/astcenc_decompress_symbolic.cpp",
"diff": "@@ -153,34 +153,15 @@ void decompress_symbolic_block(\n// If we detected an error-block, blow up immediately.\nif (scb->error_block)\n- {\n- // TODO: Check this - isn't linear LDR magenta too? Same below ...\n- // Yes, but currently applied later as special case during block copy.\n- if (decode_mode == ASTCENC_PRF_LDR_SRGB)\n- {\n- for (int i = 0; i < bsd->texel_count; i++)\n- {\n- blk->data_r[i] = 1.0f;\n- blk->data_g[i] = 0.0f;\n- blk->data_b[i] = 1.0f;\n- blk->data_a[i] = 1.0f;\n- blk->rgb_lns[i] = 0;\n- blk->alpha_lns[i] = 0;\n- blk->nan_texel[i] = 0;\n- }\n- }\n- else\n{\nfor (int i = 0; i < bsd->texel_count; i++)\n{\n- blk->data_r[i] = 0.0f;\n- blk->data_g[i] = 0.0f;\n- blk->data_b[i] = 0.0f;\n- blk->data_a[i] = 0.0f;\n+ blk->data_r[i] = std::numeric_limits<float>::quiet_NaN();\n+ blk->data_g[i] = std::numeric_limits<float>::quiet_NaN();\n+ blk->data_b[i] = std::numeric_limits<float>::quiet_NaN();\n+ blk->data_a[i] = std::numeric_limits<float>::quiet_NaN();\nblk->rgb_lns[i] = 0;\nblk->alpha_lns[i] = 0;\n- blk->nan_texel[i] = 1;\n- }\n}\nreturn;\n@@ -190,7 +171,6 @@ void decompress_symbolic_block(\n{\nvfloat4 color;\nint use_lns = 0;\n- int use_nan = 0;\nif (scb->block_mode == -2)\n{\n@@ -212,11 +192,8 @@ void decompress_symbolic_block(\nswitch (decode_mode)\n{\ncase ASTCENC_PRF_LDR_SRGB:\n- color = vfloat4(1.0f, 0.0f, 1.0f, 1.0f);\n- break;\ncase ASTCENC_PRF_LDR:\n- color = vfloat4(0.0f);\n- use_nan = 1;\n+ color = vfloat4(std::numeric_limits<float>::quiet_NaN());\nbreak;\ncase ASTCENC_PRF_HDR_RGB_LDR_A:\ncase ASTCENC_PRF_HDR:\n@@ -236,7 +213,6 @@ void decompress_symbolic_block(\nblk->data_a[i] = color.lane<3>();\nblk->rgb_lns[i] = use_lns;\nblk->alpha_lns[i] = use_lns;\n- blk->nan_texel[i] = use_nan;\n}\nreturn;\n@@ -274,7 +250,6 @@ void decompress_symbolic_block(\nvint4 ep0;\nvint4 ep1;\nbool rgb_lns;\n- bool nan;\nbool a_lns;\nunpack_color_endpoints(decode_mode,\n@@ -283,7 +258,6 @@ void decompress_symbolic_block(\nscb->color_values[i],\n&rgb_lns,\n&a_lns,\n- &nan,\n&ep0,\n&ep1);\n@@ -302,7 +276,6 @@ void decompress_symbolic_block(\nvfloat4 colorf = decode_texel(color, lns_mask);\n- blk->nan_texel[tix] = nan;\nblk->data_r[tix] = colorf.lane<0>();\nblk->data_g[tix] = colorf.lane<1>();\nblk->data_b[tix] = colorf.lane<2>();\n@@ -357,14 +330,13 @@ float compute_symbolic_block_difference(\nvint4 ep0;\nvint4 ep1;\nbool rgb_lns;\n- bool nan;\nbool a_lns;\nunpack_color_endpoints(config.profile,\nscb->color_formats[i],\nscb->color_quant_level,\nscb->color_values[i],\n- &rgb_lns, &a_lns, &nan,\n+ &rgb_lns, &a_lns,\n&ep0, &ep1);\nvmask4 lns_mask(rgb_lns, rgb_lns, rgb_lns, a_lns);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -1084,14 +1084,13 @@ astcenc_error astcenc_get_block_info(\n{\nbool rgb_hdr;\nbool a_hdr;\n- bool nan;\nvint4 endpnt[2];\nunpack_color_endpoints(ctx->config.profile,\nscb.color_formats[i],\nscb.color_quant_level,\nscb.color_values[i],\n- &rgb_hdr, &a_hdr, &nan,\n+ &rgb_hdr, &a_hdr,\nendpnt, endpnt + 1);\n// Store the color endpoint mode info\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_image.cpp",
"new_path": "Source/astcenc_image.cpp",
"diff": "@@ -296,7 +296,6 @@ void fetch_imageblock(\n{\nblk->rgb_lns[i] = rgb_lns;\nblk->alpha_lns[i] = alpha_lns;\n- blk->nan_texel[i] = 0;\n}\nimageblock_initialize_work_from_orig(blk, bsd->texel_count);\n@@ -312,7 +311,6 @@ void write_imageblock(\nint zpos,\nastcenc_swizzle swz\n) {\n- const uint8_t *nptr = blk->nan_texel;\nint xsize = img.dim_x;\nint ysize = img.dim_y;\nint zsize = img.dim_z;\n@@ -354,7 +352,7 @@ void write_imageblock(\n{\nvint4 colori = vint4::zero();\n- if (*nptr)\n+ if (blk->data_r[idx] == std::numeric_limits<float>::quiet_NaN())\n{\n// Can't display NaN - show magenta error color\ncolori = vint4(0xFF, 0x00, 0xFF, 0xFF);\n@@ -391,13 +389,10 @@ void write_imageblock(\nstore_nbytes(colori, data8 + (4 * xsize * y) + (4 * x ));\nidx++;\n- nptr++;\n}\nidx += x_nudge;\n- nptr += x_nudge;\n}\nidx += y_nudge;\n- nptr += y_nudge;\n}\n}\nelse if (img.data_type == ASTCENC_TYPE_F16)\n@@ -413,7 +408,7 @@ void write_imageblock(\n{\nvint4 color;\n- if (*nptr)\n+ if (blk->data_r[idx] == std::numeric_limits<float>::quiet_NaN())\n{\ncolor = vint4(0xFFFF);\n}\n@@ -451,13 +446,10 @@ void write_imageblock(\ndata16[(4 * xsize * y) + (4 * x + 3)] = (uint16_t)color.lane<3>();\nidx++;\n- nptr++;\n}\nidx += x_nudge;\n- nptr += x_nudge;\n}\nidx += y_nudge;\n- nptr += y_nudge;\n}\n}\nelse // if (img.data_type == ASTCENC_TYPE_F32)\n@@ -475,7 +467,7 @@ void write_imageblock(\n{\nvfloat4 color = blk->texel(idx);\n- if (*nptr)\n+ if (color.lane<0>() == std::numeric_limits<float>::quiet_NaN())\n{\ncolor = vfloat4(std::numeric_limits<float>::quiet_NaN());\n}\n@@ -504,13 +496,10 @@ void write_imageblock(\nstore(color, data32 + (4 * xsize * y) + (4 * x ));\nidx++;\n- nptr++;\n}\nidx += x_nudge;\n- nptr += x_nudge;\n}\nidx += y_nudge;\n- nptr += y_nudge;\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -535,7 +535,7 @@ struct imageblock\nuint8_t rgb_lns[MAX_TEXELS_PER_BLOCK]; // 1 if RGB data are being treated as LNS\nuint8_t alpha_lns[MAX_TEXELS_PER_BLOCK]; // 1 if Alpha data are being treated as LNS\n- uint8_t nan_texel[MAX_TEXELS_PER_BLOCK]; // 1 if the texel is a NaN-texel.\n+\nint xpos, ypos, zpos;\ninline vfloat4 texel(int index) const\n@@ -560,7 +560,6 @@ static inline float imageblock_default_alpha(const imageblock * blk)\nreturn blk->alpha_lns[0] ? (float)0x7800 : (float)0xFFFF;\n}\n-\nstatic inline int imageblock_uses_alpha(const imageblock * blk)\n{\nreturn blk->data_min.lane<3>() != blk->data_max.lane<3>();\n@@ -1235,7 +1234,6 @@ void unpack_color_endpoints(\nconst int* input,\nbool* rgb_hdr,\nbool* alpha_hdr,\n- bool* nan_endpoint,\nvint4* output0,\nvint4* output1);\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Simplify error block / end point handling
|
61,745 |
12.04.2021 23:37:31
| -3,600 |
bcd361cf17af84950074225e385de3778f68b229
|
Use part_texels in compute_error_squared_rgb_single_partition
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_encoding_choice_error.cpp",
"new_path": "Source/astcenc_encoding_choice_error.cpp",
"diff": "@@ -64,7 +64,6 @@ void merge_endpoints(\n// a particular partition.\nstatic void compute_error_squared_rgb_single_partition(\nint partition_to_test,\n- const block_size_descriptor* bsd,\nconst partition_info* pt, // the partition that we use when computing the squared-error.\nconst imageblock* blk,\nconst error_weight_block* ewb,\n@@ -78,24 +77,26 @@ static void compute_error_squared_rgb_single_partition(\nfloat* l_err,\nfloat* a_drop_err\n) {\n- int 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;\nfloat a_drop_errorsum = 0.0f;\n- for (int i = 0; i < texels_per_block; i++)\n+ int texels_in_partition = pt->partition_texel_count[partition_to_test];\n+ promise(texels_in_partition > 0);\n+\n+ for (int i = 0; i < texels_in_partition; i++)\n{\n- int partition = pt->partition_of_texel[i];\n- float texel_weight = ewb->texel_weight_rgb[i];\n- if (partition != partition_to_test || texel_weight < 1e-20f)\n+ int tix = pt->texels_of_partition[partition_to_test][i];\n+ float texel_weight = ewb->texel_weight_rgb[tix];\n+ if (texel_weight < 1e-20f)\n{\ncontinue;\n}\n- vfloat4 point = blk->texel(i);\n- vfloat4 ews = ewb->error_weights[i];\n+ vfloat4 point = blk->texel(tix);\n+ vfloat4 ews = ewb->error_weights[tix];\n// Compute the error that arises from just ditching alpha\nfloat default_alpha = imageblock_default_alpha(blk);\n@@ -238,7 +239,7 @@ void compute_encoding_choice_errors(\nluminance_plines.bis = csfn * icsf;\ncompute_error_squared_rgb_single_partition(\n- i, bsd, pt, blk, ewb,\n+ i, pt, blk, ewb,\n&uncor_rgb_plines, &uncorr_rgb_error,\n&samec_rgb_plines, &samechroma_rgb_error,\n&rgb_luma_plines, &rgb_luma_error,\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use part_texels in compute_error_squared_rgb_single_partition
|
61,745 |
12.04.2021 23:40:49
| -3,600 |
1ea2994b5c3070d6f4e24fa4272bf12f100d1dd3
|
Remove softfloat if hardware fp16 available
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_mathlib.h",
"new_path": "Source/astcenc_mathlib.h",
"diff": "@@ -490,11 +490,11 @@ static inline float2 normalize(float2 p) { return p * astc::rsqrt(dot(p, p)); }\n/* ============================================================================\nSoftfloat library with fp32 and fp16 conversion functionality.\n============================================================================ */\n-uint32_t clz32(uint32_t p);\n-\n+#if ASTCENC_F16C == 0\n/* narrowing float->float conversions */\nuint16_t float_to_sf16(float val);\nfloat sf16_to_float(uint16_t val);\n+#endif\n/*********************************\nVector library\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_mathlib_softfloat.cpp",
"new_path": "Source/astcenc_mathlib_softfloat.cpp",
"diff": "/**\n* @brief Soft-float library for IEEE-754.\n*/\n+#if ASTCENC_F16C == 0\n#include \"astcenc_mathlib.h\"\n@@ -61,7 +62,7 @@ typedef uint32_t sf32;\n/*\n32-bit count-leading-zeros function: use the Assembly instruction whenever possible. */\n-uint32_t clz32(uint32_t inp)\n+static uint32_t clz32(uint32_t inp)\n{\n#if defined(__GNUC__) && (defined(__i386) || defined(__amd64))\nuint32_t bsr;\n@@ -401,3 +402,5 @@ uint16_t float_to_sf16(float p)\ni.f = p;\nreturn sf32_to_sf16(i.u, SF_NEARESTEVEN);\n}\n+\n+#endif\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenccli_image.cpp",
"new_path": "Source/astcenccli_image.cpp",
"diff": "@@ -285,10 +285,15 @@ float* floatx4_array_from_astc_img(\nfor (unsigned int x = 0; x < dim_x; x++)\n{\n- dst[4 * x ] = sf16_to_float(data16[(4 * dim_x * ymod) + (4 * x )]);\n- dst[4 * x + 1] = sf16_to_float(data16[(4 * dim_x * ymod) + (4 * x + 1)]);\n- dst[4 * x + 2] = sf16_to_float(data16[(4 * dim_x * ymod) + (4 * x + 2)]);\n- dst[4 * x + 3] = sf16_to_float(data16[(4 * dim_x * ymod) + (4 * x + 3)]);\n+ vint4 colori(\n+ data16[(4 * dim_x * ymod) + (4 * x )],\n+ data16[(4 * dim_x * ymod) + (4 * x + 1)],\n+ data16[(4 * dim_x * ymod) + (4 * x + 2)],\n+ data16[(4 * dim_x * ymod) + (4 * x + 3)]\n+ );\n+\n+ vfloat4 color = float16_to_float(colori);\n+ store(color, dst + 4 * x);\n}\n}\n}\n@@ -351,10 +356,19 @@ uint8_t* unorm8x4_array_from_astc_img(\nfor (unsigned int x = 0; x < dim_x; x++)\n{\n- dst[4 * x ] = (uint8_t)astc::flt2int_rtn(astc::clamp1f(sf16_to_float(data16[(4 * dim_x * ymod) + (4 * x )])) * 255.0f);\n- dst[4 * x + 1] = (uint8_t)astc::flt2int_rtn(astc::clamp1f(sf16_to_float(data16[(4 * dim_x * ymod) + (4 * x + 1)])) * 255.0f);\n- dst[4 * x + 2] = (uint8_t)astc::flt2int_rtn(astc::clamp1f(sf16_to_float(data16[(4 * dim_x * ymod) + (4 * x + 2)])) * 255.0f);\n- dst[4 * x + 3] = (uint8_t)astc::flt2int_rtn(astc::clamp1f(sf16_to_float(data16[(4 * dim_x * ymod) + (4 * x + 3)])) * 255.0f);\n+ vint4 colori(\n+ data16[(4 * dim_x * ymod) + (4 * x )],\n+ data16[(4 * dim_x * ymod) + (4 * x + 1)],\n+ data16[(4 * dim_x * ymod) + (4 * x + 2)],\n+ data16[(4 * dim_x * ymod) + (4 * x + 3)]\n+ );\n+\n+ vfloat4 color = float16_to_float(colori);\n+ color = clamp(0.0f, 1.0f, color) * 255.0f;\n+\n+ colori = float_to_int_rtn(color);\n+ pack_low_bytes(colori);\n+ store_nbytes(colori, dst + 4 * x);\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenccli_toplevel.cpp",
"new_path": "Source/astcenccli_toplevel.cpp",
"diff": "@@ -1128,24 +1128,26 @@ static vfloat4 image_get_pixel(\n{\nuint16_t* data = static_cast<uint16_t*>(img.data[z]);\n- float r = sf16_to_float(data[(4 * img.dim_x * y) + (4 * x )]);\n- float g = sf16_to_float(data[(4 * img.dim_x * y) + (4 * x + 1)]);\n- float b = sf16_to_float(data[(4 * img.dim_x * y) + (4 * x + 2)]);\n- float a = sf16_to_float(data[(4 * img.dim_x * y) + (4 * x + 3)]);\n+ vint4 colori(\n+ data[(4 * img.dim_x * y) + (4 * x )],\n+ data[(4 * img.dim_x * y) + (4 * x + 1)],\n+ data[(4 * img.dim_x * y) + (4 * x + 2)],\n+ data[(4 * img.dim_x * y) + (4 * x + 3)]\n+ );\n- return vfloat4(r, g, b, a);\n+ return float16_to_float(colori);\n}\nelse // if (img.data_type == ASTCENC_TYPE_F32)\n{\nassert(img.data_type == ASTCENC_TYPE_F32);\nfloat* data = static_cast<float*>(img.data[z]);\n- float r = data[(4 * img.dim_x * y) + (4 * x )];\n- float g = data[(4 * img.dim_x * y) + (4 * x + 1)];\n- float b = data[(4 * img.dim_x * y) + (4 * x + 2)];\n- float a = data[(4 * img.dim_x * y) + (4 * x + 3)];\n-\n- return vfloat4(r, g, b, a);\n+ return vfloat4(\n+ data[(4 * img.dim_x * y) + (4 * x )],\n+ data[(4 * img.dim_x * y) + (4 * x + 1)],\n+ data[(4 * img.dim_x * y) + (4 * x + 2)],\n+ data[(4 * img.dim_x * y) + (4 * x + 3)]\n+ );\n}\n}\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Remove softfloat if hardware fp16 available
|
61,745 |
13.04.2021 00:10:46
| -3,600 |
d21566c95b303fdbc8577a748080b3f6951db81e
|
Correct error weight index
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_decompress_symbolic.cpp",
"new_path": "Source/astcenc_decompress_symbolic.cpp",
"diff": "@@ -388,7 +388,7 @@ float compute_symbolic_block_difference(\nerror = min(abs(error), 1e15f);\nerror = error * error;\n- float metric = dot_s(error, ewb->error_weights[i]);\n+ float metric = dot_s(error, ewb->error_weights[tix]);\nsumma += astc::min(metric, 1e30f);\n}\n}\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Correct error weight index
|
61,745 |
13.04.2021 00:17:05
| -3,600 |
d8947aeebfa862ed6d973cefa6ae69307bb35d1c
|
Use static function table for partition mismatch counting
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_kmeans_partitioning.cpp",
"new_path": "Source/astcenc_kmeans_partitioning.cpp",
"diff": "@@ -212,13 +212,11 @@ static void kmeans_update(\n* @brief Compute bit-mismatch for partitioning in 2-partition mode.\n*/\nstatic inline int partition_mismatch2(\n- uint64_t a0,\n- uint64_t a1,\n- uint64_t b0,\n- uint64_t b1\n+ const uint64_t* a,\n+ const uint64_t* b\n) {\n- int v1 = astc::popcount(a0 ^ b0) + astc::popcount(a1 ^ b1);\n- int v2 = astc::popcount(a0 ^ b1) + astc::popcount(a1 ^ b0);\n+ int v1 = astc::popcount(a[0] ^ b[0]) + astc::popcount(a[1] ^ b[1]);\n+ int v2 = astc::popcount(a[0] ^ b[1]) + astc::popcount(a[1] ^ b[0]);\nreturn astc::min(v1, v2);\n}\n@@ -226,24 +224,20 @@ static inline int partition_mismatch2(\n* @brief Compute bit-mismatch for partitioning in 3-partition mode.\n*/\nstatic inline int partition_mismatch3(\n- uint64_t a0,\n- uint64_t a1,\n- uint64_t a2,\n- uint64_t b0,\n- uint64_t b1,\n- uint64_t b2\n+ const uint64_t* a,\n+ const uint64_t* b\n) {\n- int p00 = astc::popcount(a0 ^ b0);\n- int p01 = astc::popcount(a0 ^ b1);\n- int p02 = astc::popcount(a0 ^ b2);\n+ int p00 = astc::popcount(a[0] ^ b[0]);\n+ int p01 = astc::popcount(a[0] ^ b[1]);\n+ int p02 = astc::popcount(a[0] ^ b[2]);\n- int p10 = astc::popcount(a1 ^ b0);\n- int p11 = astc::popcount(a1 ^ b1);\n- int p12 = astc::popcount(a1 ^ b2);\n+ int p10 = astc::popcount(a[1] ^ b[0]);\n+ int p11 = astc::popcount(a[1] ^ b[1]);\n+ int p12 = astc::popcount(a[1] ^ b[2]);\n- int p20 = astc::popcount(a2 ^ b0);\n- int p21 = astc::popcount(a2 ^ b1);\n- int p22 = astc::popcount(a2 ^ b2);\n+ int p20 = astc::popcount(a[2] ^ b[0]);\n+ int p21 = astc::popcount(a[2] ^ b[1]);\n+ int p22 = astc::popcount(a[2] ^ b[2]);\nint s0 = p11 + p22;\nint s1 = p12 + p21;\n@@ -264,34 +258,28 @@ static inline int partition_mismatch3(\n* @brief Compute bit-mismatch for partitioning in 4-partition mode.\n*/\nstatic inline int partition_mismatch4(\n- uint64_t a0,\n- uint64_t a1,\n- uint64_t a2,\n- uint64_t a3,\n- uint64_t b0,\n- uint64_t b1,\n- uint64_t b2,\n- uint64_t b3\n+ const uint64_t* a,\n+ const uint64_t* b\n) {\n- int p00 = astc::popcount(a0 ^ b0);\n- int p01 = astc::popcount(a0 ^ b1);\n- int p02 = astc::popcount(a0 ^ b2);\n- int p03 = astc::popcount(a0 ^ b3);\n-\n- int p10 = astc::popcount(a1 ^ b0);\n- int p11 = astc::popcount(a1 ^ b1);\n- int p12 = astc::popcount(a1 ^ b2);\n- int p13 = astc::popcount(a1 ^ b3);\n-\n- int p20 = astc::popcount(a2 ^ b0);\n- int p21 = astc::popcount(a2 ^ b1);\n- int p22 = astc::popcount(a2 ^ b2);\n- int p23 = astc::popcount(a2 ^ b3);\n-\n- int p30 = astc::popcount(a3 ^ b0);\n- int p31 = astc::popcount(a3 ^ b1);\n- int p32 = astc::popcount(a3 ^ b2);\n- int p33 = astc::popcount(a3 ^ b3);\n+ int p00 = astc::popcount(a[0] ^ b[0]);\n+ int p01 = astc::popcount(a[0] ^ b[1]);\n+ int p02 = astc::popcount(a[0] ^ b[2]);\n+ int p03 = astc::popcount(a[0] ^ b[3]);\n+\n+ int p10 = astc::popcount(a[1] ^ b[0]);\n+ int p11 = astc::popcount(a[1] ^ b[1]);\n+ int p12 = astc::popcount(a[1] ^ b[2]);\n+ int p13 = astc::popcount(a[1] ^ b[3]);\n+\n+ int p20 = astc::popcount(a[2] ^ b[0]);\n+ int p21 = astc::popcount(a[2] ^ b[1]);\n+ int p22 = astc::popcount(a[2] ^ b[2]);\n+ int p23 = astc::popcount(a[2] ^ b[3]);\n+\n+ int p30 = astc::popcount(a[3] ^ b[0]);\n+ int p31 = astc::popcount(a[3] ^ b[1]);\n+ int p32 = astc::popcount(a[3] ^ b[2]);\n+ int p33 = astc::popcount(a[3] ^ b[3]);\nint mx23 = astc::min(p22 + p33, p23 + p32);\nint mx13 = astc::min(p21 + p33, p23 + p31);\n@@ -308,6 +296,9 @@ static inline int partition_mismatch4(\nreturn astc::min(v0, v1, v2, v3);\n}\n+\n+using mismatch_dispatch = int (*)(const uint64_t*, const uint64_t*);\n+\n/**\n* @brief Count the partition table mismatches vs the data clustering.\n*/\n@@ -319,59 +310,25 @@ static void count_partition_mismatch_bits(\n) {\nconst partition_info *pt = get_partition_table(&bsd, partition_count);\n- if (partition_count == 2)\n- {\n- uint64_t bm0 = bitmaps[0];\n- uint64_t bm1 = bitmaps[1];\n- for (int i = 0; i < PARTITION_COUNT; i++)\n- {\n- int bitcount = 255;\n- if (pt->partition_count == 2)\n- {\n- bitcount = partition_mismatch2(bm0, bm1, pt->coverage_bitmaps[0], pt->coverage_bitmaps[1]);\n- }\n-\n- bitcounts[i] = bitcount;\n- pt++;\n- }\n- }\n- else if (partition_count == 3)\n- {\n- uint64_t bm0 = bitmaps[0];\n- uint64_t bm1 = bitmaps[1];\n- uint64_t bm2 = bitmaps[2];\n- for (int i = 0; i < PARTITION_COUNT; i++)\n- {\n- int bitcount = 255;\n- if (pt->partition_count == 3)\n- {\n- bitcount = partition_mismatch3(bm0, bm1, bm2, pt->coverage_bitmaps[0], pt->coverage_bitmaps[1], pt->coverage_bitmaps[2]);\n- }\n+ // Function pointer dispatch table\n+ const mismatch_dispatch dispatch[3] {\n+ partition_mismatch2,\n+ partition_mismatch3,\n+ partition_mismatch4\n+ };\n- bitcounts[i] = bitcount;\n- pt++;\n- }\n- }\n- else // if (partition_count == 4)\n- {\n- assert(partition_count == 4);\n- uint64_t bm0 = bitmaps[0];\n- uint64_t bm1 = bitmaps[1];\n- uint64_t bm2 = bitmaps[2];\n- uint64_t bm3 = bitmaps[3];\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\nint bitcount = 255;\n- if (pt->partition_count == 4)\n+ if (pt->partition_count == partition_count)\n{\n- bitcount = partition_mismatch4(bm0, bm1, bm2, bm3, pt->coverage_bitmaps[0], pt->coverage_bitmaps[1], pt->coverage_bitmaps[2], pt->coverage_bitmaps[3]);\n+ bitcount = dispatch[partition_count - 2](bitmaps, pt->coverage_bitmaps);\n}\nbitcounts[i] = bitcount;\npt++;\n}\n}\n-}\n/**\n* @brief Use counting sort on the mismatch array to sort partition candidates.\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use static function table for partition mismatch counting
|
61,745 |
13.04.2021 09:50:27
| -3,600 |
de22981660f81dff3cc5e468a6462d4f2856ab0f
|
Remove reviewed TODO that we can't change easily
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -385,7 +385,6 @@ static float compress_symbolic_block_fixed_partition_1_plane(\nvfloat4 rgbs_colors[4];\nvfloat4 rgbo_colors[4];\n- // TODO: Can we ping-pong between two buffers and make this zero copy?\nsymbolic_compressed_block workscb;\nfor (int l = 0; l < max_refinement_iters; l++)\n{\n@@ -796,7 +795,6 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nvfloat4 rgbs_colors[4];\nvfloat4 rgbo_colors[4];\n- // TODO: Ping-pong between two buffers and make this zero copy\nsymbolic_compressed_block workscb;\nfor (int l = 0; l < max_refinement_iters; l++)\n{\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Remove reviewed TODO that we can't change easily
|
61,745 |
13.04.2021 21:01:10
| -3,600 |
293c15d424645838d2ad9a3b41641a8aa6547201
|
Change realign_weights return type
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "* over all weights (per partition and per plane) and attempt to improve image\n* quality by moving each weight up by one or down by one quantization step.\n*/\n-static int realign_weights(\n+static bool realign_weights(\nastcenc_profile decode_mode,\nconst block_size_descriptor* bsd,\nconst imageblock* blk,\n@@ -97,7 +97,7 @@ static int realign_weights(\nuint8_t uq_pl_weights[MAX_WEIGHTS_PER_BLOCK];\nuint8_t* weight_set8 = plane1_weight_set8;\n- int adjustments = 0;\n+ bool adjustments = false;\n// For each plane and partition ...\nfor (int pl_idx = 0; pl_idx <= max_plane; pl_idx++)\n@@ -179,13 +179,13 @@ static int realign_weights(\n{\nuq_pl_weights[we_idx] = next_wt_uq;\nweight_set8[we_idx] = (uint8_t)((prev_and_next >> 24) & 0xFF);\n- adjustments++;\n+ adjustments = true;\n}\nelse if (down_error < current_error)\n{\nuq_pl_weights[we_idx] = prev_wt_uq;\nweight_set8[we_idx] = (uint8_t)((prev_and_next >> 16) & 0xFF);\n- adjustments++;\n+ adjustments = true;\n}\n}\n@@ -509,7 +509,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n}\n// perform a final pass over the weights to try to improve them.\n- int adjustments = realign_weights(\n+ bool adjustments = realign_weights(\nconfig.profile, bsd, blk, ewb, &workscb,\nu8_weight_src, nullptr);\n@@ -551,7 +551,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n}\n}\n- if (adjustments == 0)\n+ if (!adjustments)\n{\nbreak;\n}\n@@ -914,7 +914,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n}\n// perform a final pass over the weights to try to improve them.\n- int adjustments = realign_weights(\n+ bool adjustments = realign_weights(\nconfig.profile, bsd, blk, ewb, &workscb,\nu8_weight1_src, u8_weight2_src);\n@@ -957,7 +957,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n}\n}\n- if (adjustments == 0)\n+ if (!adjustments)\n{\nbreak;\n}\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Change realign_weights return type
|
61,745 |
13.04.2021 23:35:07
| -3,600 |
7615b1b693df639424de931037d406d874d918cc
|
Add scalar vmask4 constructor
|
[
{
"change_type": "MODIFY",
"old_path": "Source/UnitTest/test_simd.cpp",
"new_path": "Source/UnitTest/test_simd.cpp",
"diff": "@@ -1829,8 +1829,30 @@ TEST(vint4, select_msb)\n}\n// VMASK4 tests - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n-/** @brief Test vmask4 scalar constructor. */\n-TEST(vmask4, scalar_construct)\n+/** @brief Test vmask4 scalar literal constructor. */\n+TEST(vmask4, scalar_literal_construct)\n+{\n+ vfloat4 m1a(0, 0, 0, 0);\n+ vfloat4 m1b(1, 1, 1, 1);\n+ vmask4 m1(true);\n+\n+ vfloat4 r = select(m1a, m1b, m1);\n+\n+ EXPECT_EQ(r.lane<0>(), 1);\n+ EXPECT_EQ(r.lane<1>(), 1);\n+ EXPECT_EQ(r.lane<2>(), 1);\n+ EXPECT_EQ(r.lane<3>(), 1);\n+\n+ r = select(m1b, m1a, m1);\n+\n+ EXPECT_EQ(r.lane<0>(), 0);\n+ EXPECT_EQ(r.lane<1>(), 0);\n+ EXPECT_EQ(r.lane<2>(), 0);\n+ EXPECT_EQ(r.lane<3>(), 0);\n+}\n+\n+/** @brief Test vmask4 literal constructor. */\n+TEST(vmask4, literal_construct)\n{\nvfloat4 m1a(0, 0, 0, 0);\nvfloat4 m1b(1, 1, 1, 1);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_vecmathlib_neon_4.h",
"new_path": "Source/astcenc_vecmathlib_neon_4.h",
"diff": "@@ -329,7 +329,17 @@ struct vmask4\n#endif\n/**\n- * @brief Construct from an existing SIMD register.\n+ * @brief Construct from 1 scalar value.\n+ */\n+ ASTCENC_SIMD_INLINE explicit vmask4(bool a)\n+ {\n+ m = vreinterpretq_u32_s32(vdupq_n_s32(a == true ? -1 : 0));\n+ }\n+\n+ /**\n+ * @brief Construct from 4 scalar values.\n+ *\n+ * The value of @c a is stored to lane 0 (LSB) in the SIMD register.\n*/\nASTCENC_SIMD_INLINE explicit vmask4(bool a, bool b, bool c, bool d)\n{\n@@ -344,7 +354,6 @@ struct vmask4\nm = vreinterpretq_u32_s32(ms);\n}\n-\n/**\n* @brief The vector ...\n*/\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_vecmathlib_none_4.h",
"new_path": "Source/astcenc_vecmathlib_none_4.h",
"diff": "@@ -317,6 +317,17 @@ struct vmask4\nm[3] = p[3];\n}\n+ /**\n+ * @brief Construct from 1 scalar value.\n+ */\n+ ASTCENC_SIMD_INLINE explicit vmask4(bool a)\n+ {\n+ m[0] = a == false ? 0 : -1;\n+ m[1] = a == false ? 0 : -1;\n+ m[2] = a == false ? 0 : -1;\n+ m[3] = a == false ? 0 : -1;\n+ }\n+\n/**\n* @brief Construct from 4 scalar values.\n*\n@@ -330,6 +341,7 @@ struct vmask4\nm[3] = d == false ? 0 : -1;\n}\n+\n/**\n* @brief The vector ...\n*/\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_vecmathlib_sse_4.h",
"new_path": "Source/astcenc_vecmathlib_sse_4.h",
"diff": "@@ -336,6 +336,15 @@ struct vmask4\nm = _mm_castsi128_ps(a);\n}\n+ /**\n+ * @brief Construct from 1 scalar values.\n+ */\n+ ASTCENC_SIMD_INLINE explicit vmask4(bool a)\n+ {\n+ vint4 mask(a == false ? 0 : -1);\n+ m = _mm_castsi128_ps(mask.m);\n+ }\n+\n/**\n* @brief Construct from 4 scalar values.\n*\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add scalar vmask4 constructor
|
61,745 |
13.04.2021 23:35:30
| -3,600 |
513c67df408b04b7d11071c3dec05929af5795c9
|
Use select() for compute_angular_endpoints_for_quant_levels
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_weight_align.cpp",
"new_path": "Source/astcenc_weight_align.cpp",
"diff": "@@ -246,76 +246,75 @@ static void compute_angular_endpoints_for_quant_levels(\nangular_offsets, lowest_weight, weight_span, error,\ncut_low_weight_error, cut_high_weight_error);\n- // for each quantization level, find the best error terms.\n- float best_errors[40];\n- int best_scale[40];\n- uint8_t cut_low_weight[40];\n+ // For each quantization level, find the best error terms. Use packed\n+ // vectors so data-dependent branches can become selects. This involves\n+ // some integer to float casts, but the values are small enough so they\n+ // never round the wrong way.\n+ vfloat4 best_results[40];\n+\n+ // Initialize the array to some safe defaults\nfor (int i = 0; i < (max_quantization_steps + 4); i++)\n{\n- best_scale[i] = -1; // Indicates no solution found\n- best_errors[i] = 1e30f;\n- cut_low_weight[i] = 0;\n+ // Lane<0> = Best error\n+ // Lane<1> = Best scale; -1 indicates no solution found\n+ // Lane<2> = Cut low weight\n+ best_results[i] = vfloat4(1e30f, -1.0f, 0.0f, 0.0f);\n}\npromise(max_angular_steps > 0);\nfor (int i = 0; i < max_angular_steps; i++)\n{\nint idx_span = weight_span[i];\n-\n- if (best_errors[idx_span] > error[i])\n- {\n- best_errors[idx_span] = error[i];\n- best_scale[idx_span] = i;\n- cut_low_weight[idx_span] = 0;\n- }\n-\nfloat error_cut_low = error[i] + cut_low_weight_error[i];\nfloat error_cut_high = error[i] + cut_high_weight_error[i];\nfloat error_cut_low_high = error[i] + cut_low_weight_error[i] + cut_high_weight_error[i];\n- if (best_errors[idx_span - 1] > error_cut_low)\n- {\n- best_errors[idx_span - 1] = error_cut_low;\n- best_scale[idx_span - 1] = i;\n- cut_low_weight[idx_span - 1] = 1;\n- }\n+ vfloat4 best_result;\n+ vfloat4 new_result;\n- if (best_errors[idx_span - 1] > error_cut_high)\n- {\n- best_errors[idx_span - 1] = error_cut_high;\n- best_scale[idx_span - 1] = i;\n- cut_low_weight[idx_span - 1] = 0;\n- }\n+ // Check best error against record N\n+ best_result = best_results[idx_span];\n+ new_result = vfloat4(error[i], (float)i, 0.0f, 0.0f);\n+ vmask4 mask1(best_result.lane<0>() > error[i]);\n+ best_results[idx_span] = select(best_result, new_result, mask1);\n- if (best_errors[idx_span - 2] > error_cut_low_high)\n- {\n- best_errors[idx_span - 2] = error_cut_low_high;\n- best_scale[idx_span - 2] = i;\n- cut_low_weight[idx_span - 2] = 1;\n- }\n+ // Check best error against record N-1 with both cut low and cut high\n+ best_result = best_results[idx_span - 1];\n+\n+ new_result = vfloat4(error_cut_low, (float)i, 1.0f, 0.0f);\n+ vmask4 mask2(best_result.lane<0>() > error_cut_low);\n+ best_result = select(best_result, new_result, mask2);\n+\n+ new_result = vfloat4(error_cut_high, (float)i, 0.0f, 0.0f);\n+ vmask4 mask3(best_result.lane<0>() > error_cut_high);\n+ best_results[idx_span - 1] = select(best_result, new_result, mask3);\n+\n+ // Check best error against record N-2 with cut low high\n+ best_result = best_results[idx_span - 2];\n+ new_result = vfloat4(error_cut_low_high, (float)i, 1.0f, 0.0f);\n+ vmask4 mask4(best_result.lane<0>() > error_cut_low_high);\n+ best_results[idx_span - 2] = select(best_result, new_result, mask4);\n}\n- // if we got a better error-value for a low sample count than for a high one,\n- // use the low sample count error value for the higher sample count as well.\n+ // If we get a better error for lower sample count then use the lower\n+ // sample count's error for the higher sample count as well.\nfor (int i = 3; i <= max_quantization_steps; i++)\n{\n- if (best_errors[i] > best_errors[i - 1])\n- {\n- best_errors[i] = best_errors[i - 1];\n- best_scale[i] = best_scale[i - 1];\n- cut_low_weight[i] = cut_low_weight[i - 1];\n- }\n+ vfloat4 result = best_results[i];\n+ vfloat4 prev_result = best_results[i - 1];\n+ vmask4 mask(result.lane<0>() > prev_result.lane<0>());\n+ best_results[i] = select(result, prev_result, mask);\n}\nfor (int i = 0; i <= max_quant_level; i++)\n{\nint q = quantization_steps_for_level[i];\n- int bsi = best_scale[q];\n+ int bsi = (int)best_results[q].lane<1>();\n// Did we find anything?\n// TODO: Can we do better than bsi = 0 here. We should at least\n// propagate an error (and move the printf into the CLI).\n-#if defined(NDEBUG)\n+#if !defined(NDEBUG)\nif (bsi < 0)\n{\nprintf(\"WARNING: Unable to find encoding within specified error limit\\n\");\n@@ -326,7 +325,7 @@ else\n#endif\nfloat stepsize = 1.0f / (1.0f + (float)bsi);\n- int lwi = lowest_weight[bsi] + cut_low_weight[q];\n+ int lwi = lowest_weight[bsi] + (int)best_results[q].lane<2>();\nint hwi = lwi + q - 1;\nfloat offset = angular_offsets[bsi] * stepsize;\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use select() for compute_angular_endpoints_for_quant_levels
|
61,745 |
16.04.2021 22:11:46
| -3,600 |
11e7f579b1038cb4ebb370f4b1a94c1057069366
|
Add scalar vmask8 constructor
|
[
{
"change_type": "MODIFY",
"old_path": "Source/UnitTest/test_simd.cpp",
"new_path": "Source/UnitTest/test_simd.cpp",
"diff": "@@ -3164,6 +3164,24 @@ TEST(vint8, select_msb)\n}\n// vmask8 tests - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n+\n+/** @brief Test vmask8 scalar literal constructor. */\n+TEST(vmask8, scalar_literal_construct)\n+{\n+ vfloat8 ma(0.0f);\n+ vfloat8 mb(1.0f);\n+\n+ vmask8 m1(true);\n+ vfloat8 r1 = select(ma, mb, m1);\n+ vmask8 rm1 = r1 == mb;\n+ EXPECT_EQ(all(rm1), true);\n+\n+ vmask8 m2(false);\n+ vfloat8 r2 = select(ma, mb, m2);\n+ vmask8 rm2 = r2 == mb;\n+ EXPECT_EQ(any(rm2), false);\n+}\n+\n/** @brief Test vmask8 or. */\nTEST(vmask8, or)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_vecmathlib_avx2_8.h",
"new_path": "Source/astcenc_vecmathlib_avx2_8.h",
"diff": "@@ -284,6 +284,15 @@ struct vmask8\nm = _mm256_castsi256_ps(a);\n}\n+ /**\n+ * @brief Construct from 1 scalar value.\n+ */\n+ ASTCENC_SIMD_INLINE explicit vmask8(bool a)\n+ {\n+ vint8 mask(a == false ? 0 : -1);\n+ m = _mm256_castsi256_ps(mask.m);\n+ }\n+\n/**\n* @brief The vector ...\n*/\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_vecmathlib_sse_4.h",
"new_path": "Source/astcenc_vecmathlib_sse_4.h",
"diff": "@@ -337,7 +337,7 @@ struct vmask4\n}\n/**\n- * @brief Construct from 1 scalar values.\n+ * @brief Construct from 1 scalar value.\n*/\nASTCENC_SIMD_INLINE explicit vmask4(bool a)\n{\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add scalar vmask8 constructor
|
61,745 |
16.04.2021 22:47:27
| -3,600 |
b0c2ebfe401dfd1cd5f426004bfa333ea233df05
|
Reorder struct to minimize cache fetches for constant wes
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1099,11 +1099,13 @@ struct endpoints\nstruct endpoints_and_weights\n{\nendpoints ep;\n+\nalignas(ASTCENC_VECALIGN) float weights[MAX_TEXELS_PER_BLOCK];\n- alignas(ASTCENC_VECALIGN) float weight_error_scale[MAX_TEXELS_PER_BLOCK];\n/**< True if all active values in weight_error_scale are the same. */\nbool is_constant_weight_error_scale;\n+\n+ alignas(ASTCENC_VECALIGN) float weight_error_scale[MAX_TEXELS_PER_BLOCK];\n};\nvoid compute_endpoints_and_ideal_weights_1_plane(\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Reorder struct to minimize cache fetches for constant wes
|
61,745 |
16.04.2021 23:59:55
| -3,600 |
17e5fa88c5a5ec38652682354f4613ad46ff50b8
|
Remove bias on max_quant_steps
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_weight_align.cpp",
"new_path": "Source/astcenc_weight_align.cpp",
"diff": "@@ -229,7 +229,7 @@ static void compute_angular_endpoints_for_quant_levels(\nfloat low_value[12],\nfloat high_value[12]\n) {\n- int max_quantization_steps = quantization_steps_for_level[max_quant_level + 1];\n+ int max_quantization_steps = quantization_steps_for_level[max_quant_level];\nalignas(ASTCENC_VECALIGN) float angular_offsets[ANGULAR_STEPS];\nint max_angular_steps = max_angular_steps_needed_for_quant_level[max_quant_level];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Remove bias on max_quant_steps
|
61,745 |
17.04.2021 00:10:33
| -3,600 |
e263230bf16b115ed61cf9972b4b529edad68638
|
Fix test runner for main reference runs
|
[
{
"change_type": "MODIFY",
"old_path": "Test/astc_test_image.py",
"new_path": "Test/astc_test_image.py",
"diff": "@@ -259,8 +259,8 @@ def get_encoder_params(encoderName, referenceName, imageSet):\nreturn (encoder, name, outDir, refName)\n# Latest main\n- if version == main:\n- encoder = te.Encoder2x(version, simd)\n+ if version == \"main\":\n+ encoder = te.Encoder2x(simd)\nname = f\"reference-{version}-{simd}\"\noutDir = \"Test/Images/%s\" % imageSet\nrefName = None\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Fix test runner for main reference runs
|
61,745 |
17.04.2021 20:14:34
| -3,600 |
3e162202343337b5fcba2f2cc9214325ca26bbfa
|
Update graph plot script for new releases
|
[
{
"change_type": "MODIFY",
"old_path": "Test/astc_test_result_plot.py",
"new_path": "Test/astc_test_result_plot.py",
"diff": "@@ -252,77 +252,103 @@ def main():\nabsoluteXLimit = 35\ncharts = [\n+ # --------------------------------------------------------\n+ # Latest in stable series charts\n[\n- # Plot headline 1.7 to 2.3 scores\n- [\"medium\"],\n- [\"ref-2.3-avx2\"],\n+ # Relative scores\n+ [\"thorough\", \"medium\", \"fast\"],\n+ [\"ref-2.5-avx2\"],\n[\"4x4\", \"6x6\", \"8x8\"],\nTrue,\n\"ref-1.7\",\nNone,\n- \"relative-1.7-to-2.3.png\",\n+ \"relative-stable-series.png\",\n(10, None)\n], [\n- # --------------------------------------------------------\n- # Plot all absolute scores\n- [\"thorough\", \"medium\", \"fast\", \"fastest\"],\n- [\"ref-2.2-avx2\", \"ref-2.3-avx2\"],\n- [\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\n+ # Absolute scores\n+ [\"thorough\", \"medium\", \"fast\"],\n+ [\"ref-1.7\", \"ref-2.5-avx2\"],\n+ [\"4x4\", \"6x6\", \"8x8\"],\nFalse,\nNone,\nNone,\n- \"absolute-all.png\",\n+ \"absolute-stable-series.png\",\n(absoluteXLimit, None)\n+ ],\n+ # --------------------------------------------------------\n+ # Latest 2.x vs 1.7 release charts\n+ [\n+ # Relative scores\n+ [\"thorough\", \"medium\", \"fast\", \"fastest\"],\n+ [\"ref-2.5-avx2\"],\n+ [\"4x4\", \"6x6\", \"8x8\"],\n+ True,\n+ \"ref-1.7\",\n+ None,\n+ \"relative-2.x-vs-1.x.png\",\n+ (None, None)\n], [\n- # Plot 2.3 to 2.2 absolute scores\n+ # Absolute scores\n[\"thorough\", \"medium\", \"fast\", \"fastest\"],\n- [\"ref-2.2-avx2\", \"ref-2.3-avx2\"],\n- [\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\n+ [\"ref-1.7\", \"ref-2.5-avx2\"],\n+ [\"4x4\", \"6x6\", \"8x8\"],\nFalse,\nNone,\nNone,\n- \"absolute-2.2-to-2.3.png\",\n+ \"absolute-2.x-vs-1.x.png\",\n(absoluteXLimit, None)\n], [\n- # --------------------------------------------------------\n- # Plot all relative scores vs 1.7\n- [\"thorough\", \"medium\", \"fast\"],\n- [\"ref-2.2-avx2\", \"ref-2.3-avx2\"],\n- [\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\n+ # Relative ISAs of latest\n+ [\"thorough\", \"medium\", \"fast\", \"fastest\"],\n+ [\"ref-2.5-sse4.1\", \"ref-2.5-avx2\"],\n+ [\"4x4\", \"6x6\", \"8x8\"],\nTrue,\n- \"ref-1.7\",\n+ \"ref-2.5-sse2\",\nNone,\n- \"relative-all-v1.7.png\",\n+ \"relative-2.x-isa.png\",\n(None, None)\n], [\n- # Plot 2.2 to 2.3 relative scores\n- [\"thorough\", \"medium\", \"fast\", \"fastest\"],\n- [\"ref-2.3-avx2\"],\n- [\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\n+ # Relative quality of latest\n+ [\"medium\", \"fast\", \"fastest\"],\n+ [\"ref-2.5-avx2\"],\n+ [\"4x4\", \"6x6\", \"8x8\"],\nTrue,\n- \"ref-2.2-avx2\",\nNone,\n- \"relative-2.2-to-2.3.png\",\n- (None, None),\n- ], [\n- # Plot relative scores of ISAs of latest\n+ \"thorough\",\n+ \"relative-2.x-quality.png\",\n+ (None, None)\n+ ],\n+ # --------------------------------------------------------\n+ # Latest main vs last stable release charts\n+ [\n+ # Relative scores\n[\"thorough\", \"medium\", \"fast\", \"fastest\"],\n- [\"ref-2.3-sse4.1\", \"ref-2.3-avx2\"],\n- [\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\n+ [\"ref-main-avx2\"],\n+ [\"4x4\", \"6x6\", \"8x8\"],\nTrue,\n- \"ref-2.3-sse2\",\n+ \"ref-2.5-avx2\",\nNone,\n- \"relative-2.3-isas.png\",\n+ \"relative-main-vs-2.x.png\",\n(None, None)\n], [\n- # Plot relative scores of qualities of latest\n+ # Absolute scores\n+ [\"thorough\", \"medium\", \"fast\", \"fastest\"],\n+ [\"ref-2.5-avx2\", \"ref-main-avx2\"],\n+ [\"4x4\", \"6x6\", \"8x8\"],\n+ False,\n+ None,\n+ None,\n+ \"absolute-main-vs-2.x.png\",\n+ (absoluteXLimit, None)\n+ ], [\n+ # Relative quality of latest\n[\"medium\", \"fast\", \"fastest\"],\n- [\"ref-2.3-avx2\"],\n- [\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\n+ [\"ref-main-avx2\"],\n+ [\"4x4\", \"6x6\", \"8x8\"],\nTrue,\nNone,\n\"thorough\",\n- \"relative-2.3-qualities.png\",\n+ \"relative-main-quality.png\",\n(None, None)\n]\n]\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Update graph plot script for new releases
|
61,745 |
17.04.2021 21:30:03
| -3,600 |
cbe526491c682000e2ec34554a5063ceaec4667f
|
Remove high/low_bound limiter
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -1080,15 +1080,7 @@ void compute_quantized_weights_for_decimation_table(\n// Quantize the weight set using both the specified low/high bounds\n// and the standard 0..1 weight bounds.\n- /*\n- TODO: WTF issue that we need to examine some time\n- */\n- if (!((high_bound - low_bound) > 0.5f))\n- {\n- low_bound = 0.0f;\n- high_bound = 1.0f;\n- }\n-\n+ assert(high_bound > low_bound);\nfloat rscale = high_bound - low_bound;\nfloat scale = 1.0f / rscale;\n@@ -1098,7 +1090,7 @@ void compute_quantized_weights_for_decimation_table(\nint i = 0;\n#if ASTCENC_SIMD_WIDTH > 1\n- // SIMD loop; process weights in SIMD width batches while we can.\n+ // SIMD loop; process weights in SIMD width batches while we can\nvfloat scalev(scale);\nvfloat scaled_low_boundv(scaled_low_bound);\nvfloat quant_level_m1v(quant_level_m1);\n@@ -1111,7 +1103,7 @@ void compute_quantized_weights_for_decimation_table(\nvfloat ix = loada(&weight_set_in[i]) * scalev - scaled_low_boundv;\nix = clampzo(ix);\n- //Llook up the two closest indexes and return the one that was closest.\n+ // Look up the two closest indexes and return the one that was closest\nvfloat ix1 = ix * quant_level_m1v;\nvint weight = float_to_int(ix1);\nvint weight1 = weight + vint(1);\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Remove high/low_bound limiter
|
61,745 |
17.04.2021 21:42:02
| -3,600 |
435844cf3e31372ec7864187f9a17766fc2585cc
|
Use accumulate operator
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -914,8 +914,8 @@ void compute_ideal_weights_for_decimation_table(\nvfloat contrib_weight = weight * weight_error_scale;\n- weight_weight = weight_weight + contrib_weight;\n- initial_weight = initial_weight + gatherf(eai_in.weights, texel) * contrib_weight;\n+ weight_weight += contrib_weight;\n+ initial_weight += gatherf(eai_in.weights, texel) * contrib_weight;\n}\nstorea(weight_weight, weights + i);\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use accumulate operator
|
61,745 |
17.04.2021 22:14:29
| -3,600 |
283243ec1cfde8d63f8deb301d394f12bca32515
|
Remove texel_weights_float_t4
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_block_sizes2.cpp",
"new_path": "Source/astcenc_block_sizes2.cpp",
"diff": "@@ -308,7 +308,6 @@ static void initialize_decimation_table_2d(\nfor (int j = 0; j < 4; j++)\n{\ndt->texel_weights_int_t4[i][j] = 0;\n- dt->texel_weights_float_t4[i][j] = 0.0f;\ndt->texel_weights_t4[i][j] = 0;\ndt->texel_weights_float_4t[j][i] = 0.0f;\n@@ -319,7 +318,6 @@ static void initialize_decimation_table_2d(\nfor (int j = 0; j < weightcount_of_texel[i]; j++)\n{\ndt->texel_weights_int_t4[i][j] = weights_of_texel[i][j];\n- dt->texel_weights_float_t4[i][j] = ((float)weights_of_texel[i][j]) * (1.0f / TEXEL_WEIGHT_SUM);\ndt->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@@ -335,8 +333,6 @@ static void initialize_decimation_table_2d(\n{\nuint8_t texel = texels_of_weight[i][j];\n- dt->weights_int[i][j] = texelweights_of_weight[i][j];\n-\n// Create transposed versions of these for better vectorization\ndt->weight_texel[j][i] = texel;\ndt->weights_flt[j][i] = (float)texelweights_of_weight[i][j];\n@@ -348,7 +344,7 @@ static void initialize_decimation_table_2d(\nfor (int k = 0; k < 4; k++)\n{\nuint8_t dttw = dt->texel_weights_t4[texel][k];\n- float dttwf = dt->texel_weights_float_t4[texel][k];\n+ float dttwf = dt->texel_weights_float_4t[k][texel];\nif (dttw == i && dttwf != 0.0f)\n{\nswap_idx = k;\n@@ -530,7 +526,6 @@ static void initialize_decimation_table_3d(\nfor (int j = 0; j < 4; j++)\n{\ndt->texel_weights_int_t4[i][j] = 0;\n- dt->texel_weights_float_t4[i][j] = 0.0f;\ndt->texel_weights_t4[i][j] = 0;\ndt->texel_weights_float_4t[j][i] = 0.0f;\n@@ -540,7 +535,6 @@ static void initialize_decimation_table_3d(\nfor (int j = 0; j < weightcount_of_texel[i]; j++)\n{\ndt->texel_weights_int_t4[i][j] = weights_of_texel[i][j];\n- dt->texel_weights_float_t4[i][j] = ((float)weights_of_texel[i][j]) * (1.0f / TEXEL_WEIGHT_SUM);\ndt->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@@ -555,8 +549,6 @@ static void initialize_decimation_table_3d(\n{\nint texel = texels_of_weight[i][j];\n- dt->weights_int[i][j] = texelweights_of_weight[i][j];\n-\n// Create transposed versions of these for better vectorization\ndt->weight_texel[j][i] = texel;\ndt->weights_flt[j][i] = (float)texelweights_of_weight[i][j];\n@@ -568,7 +560,7 @@ static void initialize_decimation_table_3d(\nfor (int k = 0; k < 4; k++)\n{\nuint8_t dttw = dt->texel_weights_t4[texel][k];\n- float dttwf = dt->texel_weights_float_t4[texel][k];\n+ float dttwf = dt->texel_weights_float_4t[k][texel];\nif (dttw == i && dttwf != 0.0f)\n{\nswap_idx = k;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -406,14 +406,9 @@ struct decimation_table\nalignas(ASTCENC_VECALIGN) float texel_weights_float_4t[4][MAX_TEXELS_PER_BLOCK]; // the weight to assign to each weight\nalignas(ASTCENC_VECALIGN) uint8_t texel_weights_4t[4][MAX_TEXELS_PER_BLOCK]; // the weights that go into a texel calculation\n- // TODO: Can we remove the copies?\n- float texel_weights_float_t4[MAX_TEXELS_PER_BLOCK][4]; // the weight to assign to each weight\nuint8_t texel_weights_t4[MAX_TEXELS_PER_BLOCK][4]; // the weights that go into a texel calculation\n-\nuint8_t texel_weights_int_t4[MAX_TEXELS_PER_BLOCK][4]; // the weight to assign to each weight\n-\nuint8_t weight_texel_count[MAX_WEIGHTS_PER_BLOCK]; // the number of texels that a given weight contributes to\n- uint8_t weights_int[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK]; // the weights that the weight contributes to a texel.\n// Stored transposed to give better access patterns\nuint8_t weight_texel[MAX_TEXELS_PER_BLOCK][MAX_WEIGHTS_PER_BLOCK]; // the texels that the weight contributes to\n@@ -1169,10 +1164,10 @@ static inline float bilinear_infill(\nconst float* weights,\nint index\n) {\n- return (weights[dt.texel_weights_t4[index][0]] * dt.texel_weights_float_t4[index][0] +\n- weights[dt.texel_weights_t4[index][1]] * dt.texel_weights_float_t4[index][1]) +\n- (weights[dt.texel_weights_t4[index][2]] * dt.texel_weights_float_t4[index][2] +\n- weights[dt.texel_weights_t4[index][3]] * dt.texel_weights_float_t4[index][3]);\n+ return (weights[dt.texel_weights_4t[0][index]] * dt.texel_weights_float_4t[0][index] +\n+ weights[dt.texel_weights_4t[1][index]] * dt.texel_weights_float_4t[1][index]) +\n+ (weights[dt.texel_weights_4t[2][index]] * dt.texel_weights_float_4t[2][index] +\n+ weights[dt.texel_weights_4t[3][index]] * dt.texel_weights_float_4t[3][index]);\n}\n/**\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_weight_align.cpp",
"new_path": "Source/astcenc_weight_align.cpp",
"diff": "@@ -348,6 +348,7 @@ void compute_angular_endpoints_1plane(\nfloat low_values[MAX_DECIMATION_MODES][12];\nfloat high_values[MAX_DECIMATION_MODES][12];\n+ promise(bsd->decimation_mode_count > 0);\nfor (int i = 0; i < bsd->decimation_mode_count; i++)\n{\nconst decimation_mode& dm = bsd->decimation_modes[i];\n@@ -364,6 +365,7 @@ void compute_angular_endpoints_1plane(\ndm.maxprec_1plane, low_values[i], high_values[i]);\n}\n+ promise(bsd->block_mode_count > 0);\nfor (int i = 0; i < bsd->block_mode_count; ++i)\n{\nconst block_mode& bm = bsd->block_modes[i];\n@@ -395,6 +397,7 @@ void compute_angular_endpoints_2planes(\nfloat low_values2[MAX_DECIMATION_MODES][12];\nfloat high_values2[MAX_DECIMATION_MODES][12];\n+ promise(bsd->decimation_mode_count > 0);\nfor (int i = 0; i < bsd->decimation_mode_count; i++)\n{\nconst decimation_mode& dm = bsd->decimation_modes[i];\n@@ -418,6 +421,7 @@ void compute_angular_endpoints_2planes(\ndm.maxprec_2planes, low_values2[i], high_values2[i]);\n}\n+ promise(bsd->block_mode_count > 0);\nfor (int i = 0; i < bsd->block_mode_count; ++i)\n{\nconst block_mode& bm = bsd->block_modes[i];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Remove texel_weights_float_t4
|
61,745 |
18.04.2021 19:30:25
| -3,600 |
d10971fae89b204f1f5367f6becbc89e97d39c9e
|
Specialize compute_error_of_weight_set_2planes
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -329,7 +329,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\nbm.quant_mode);\n// then, compute weight-errors for the weight mode.\n- qwt_errors[i] = compute_error_of_weight_set(\n+ qwt_errors[i] = compute_error_of_weight_set_1plane(\n&(eix[decimation_mode]),\ndts[decimation_mode],\nflt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * i);\n@@ -728,14 +728,11 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n// then, compute quantization errors for the block mode.\n- qwt_errors[i] = compute_error_of_weight_set(\n+ qwt_errors[i] = compute_error_of_weight_set_2planes(\n&(eix1[decimation_mode]),\n- dts[decimation_mode],\n- flt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i))\n-\n- + compute_error_of_weight_set(\n&(eix2[decimation_mode]),\ndts[decimation_mode],\n+ flt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i),\nflt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i + 1));\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -755,7 +755,7 @@ void compute_endpoints_and_ideal_weights_2_planes(\ngo into a given texel.\n*/\n-float compute_error_of_weight_set(\n+float compute_error_of_weight_set_1plane(\nconst endpoints_and_weights* eai,\nconst decimation_table* dt,\nconst float* weights\n@@ -818,6 +818,86 @@ float compute_error_of_weight_set(\nreturn error_summa;\n}\n+float compute_error_of_weight_set_2planes(\n+ const endpoints_and_weights* eai1,\n+ const endpoints_and_weights* eai2,\n+ const decimation_table* dt,\n+ const float* weights1,\n+ const float* weights2\n+) {\n+ vfloat4 error_summav = vfloat4::zero();\n+ float error_summa = 0.0f;\n+ int texel_count = dt->texel_count;\n+\n+ int i = 0;\n+\n+ // Process SIMD-width texel coordinates at at time while we can\n+ int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\n+ for (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n+ {\n+ // Plane 1\n+ // Compute the bilinear interpolation of the decimated weight grid\n+ vfloat current_values1 = bilinear_infill_vla(*dt, weights1, i);\n+\n+ // Compute the error between the computed value and the ideal weight\n+ vfloat actual_values1 = loada(&(eai1->weights[i]));\n+ vfloat diff = current_values1 - actual_values1;\n+ vfloat error1 = diff * diff * loada(&(eai1->weight_error_scale[i]));\n+\n+ // Plane 2\n+ // Compute the bilinear interpolation of the decimated weight grid\n+ vfloat current_values2 = bilinear_infill_vla(*dt, weights2, i);\n+\n+ // Compute the error between the computed value and the ideal weight\n+ vfloat actual_values2 = loada(&(eai2->weights[i]));\n+ diff = current_values2 - actual_values2;\n+ vfloat error2 = diff * diff * loada(&(eai2->weight_error_scale[i]));\n+\n+ haccumulate(error_summav, error1 + error2);\n+ }\n+\n+ // Loop tail\n+ // Error is buffered and accumulated in blocks of 4 to ensure that\n+ // the partial sums added to the accumulator are invariant with the\n+ // vector implementation, irrespective of vector size ...\n+ alignas(16) float errorsum_tmp[4] { 0 };\n+ for (/* */; i < texel_count; i++)\n+ {\n+ // Plane 1\n+ float current_value1 = bilinear_infill(*dt, weights1, i);\n+ float valuedif1 = current_value1 - eai1->weights[i];\n+ float error1 = valuedif1 * valuedif1 * eai1->weight_error_scale[i];\n+\n+ // Plane 2\n+ float current_value2 = bilinear_infill(*dt, weights2, i);\n+ float valuedif2 = current_value2 - eai2->weights[i];\n+ float error2 = valuedif2 * valuedif2 * eai2->weight_error_scale[i];\n+\n+ // Accumulate error sum in the temporary array\n+ int error_index = i & 0x3;\n+ errorsum_tmp[error_index] = error1 + error2;\n+\n+#if ASTCENC_SIMD_WIDTH == 8\n+ // Zero the temporary staging buffer every 4 items unless last. Note\n+ // that this block can only trigger for 6x5 blocks, all other partials\n+ // tails are shorter than 4 ...\n+ if ((i & 0x7) == 0x03)\n+ {\n+ haccumulate(error_summav, vfloat4::loada(errorsum_tmp));\n+ storea(vfloat4::zero(), errorsum_tmp);\n+ }\n+#endif\n+ }\n+\n+ // Accumulate the loop tail using the vfloat4 swizzle\n+ haccumulate(error_summav, vfloat4::loada(errorsum_tmp));\n+\n+ // Resolve the final scalar accumulator sum\n+ haccumulate(error_summa, error_summav);\n+\n+ return error_summa;\n+}\n+\n/* See header for documentation. */\n// Note: This function is vectorized, but needs to use gathers to access the\n// decimation table structures so vectorization is currently only enabled for\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1201,11 +1201,18 @@ static inline vfloat bilinear_infill_vla(\n(weight_val2 * tex_weight_float2 + weight_val3 * tex_weight_float3);\n}\n-float compute_error_of_weight_set(\n+float compute_error_of_weight_set_1plane(\nconst endpoints_and_weights* eai,\nconst decimation_table* dt,\nconst float *weights);\n+float compute_error_of_weight_set_2planes(\n+ const endpoints_and_weights* eai1,\n+ const endpoints_and_weights* eai2,\n+ const decimation_table* dt,\n+ const float* weights1,\n+ const float* weights2);\n+\nvoid merge_endpoints(\nconst endpoints* ep1, // contains three of the color components\nconst endpoints* ep2, // contains the remaining color component\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Specialize compute_error_of_weight_set_2planes
|
61,745 |
18.04.2021 21:16:03
| -3,600 |
f0be37fc58c8a8e84a0d71bf54de19a0e77835d0
|
Round up comp_quant_weights_for_dt to avoid loop tail
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -927,6 +927,15 @@ void compute_ideal_weights_for_decimation_table(\neai_out.ep = eai_in.ep;\neai_out.is_constant_weight_error_scale = eai_in.is_constant_weight_error_scale;\n+ // Ensure that the end of the output arrays that are used for SIMD paths later are filled so we\n+ // can safely run SIMD elsewhere without a loop tail. Note that this is always safe as weight\n+ // arrays always contain space for 64 elements\n+ int simd_weight_count = round_up_to_simd_multiple_vla(weight_count);\n+ for (i = weight_count; i < simd_weight_count; i++)\n+ {\n+ weight_set[i] = 0.0f;\n+ }\n+\n// If we have a 1:1 mapping just shortcut the computation - clone the\n// weights into both the weight set and the output epw copy.\nif (texel_count == weight_count)\n@@ -940,6 +949,7 @@ void compute_ideal_weights_for_decimation_table(\neai_out.weights[i] = eai_in.weights[i];\neai_out.weight_error_scale[i] = eai_in.weight_error_scale[i];\n}\n+\nreturn;\n}\n// If we don't have a 1:1 mapping just clone the weights into the output\n@@ -1167,18 +1177,15 @@ void compute_quantized_weights_for_decimation_table(\nfloat scaled_low_bound = low_bound * scale;\nrscale *= 1.0f / 64.0f;\n- int i = 0;\n-\n-#if ASTCENC_SIMD_WIDTH > 1\n- // SIMD loop; process weights in SIMD width batches while we can\nvfloat scalev(scale);\nvfloat scaled_low_boundv(scaled_low_bound);\nvfloat quant_level_m1v(quant_level_m1);\nvfloat rscalev(rscale);\nvfloat low_boundv(low_bound);\n- int clipped_weight_count = round_down_to_simd_multiple_vla(weight_count);\n- for (/* */; i < clipped_weight_count; i += ASTCENC_SIMD_WIDTH)\n+ // This runs to the rounded-up SIMD size, which is safe as the loop tail is filled with known\n+ // safe data in compute_ideal_weights_for_decimation_table and arrays are always 64 elements\n+ for (int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)\n{\nvfloat ix = loada(&weight_set_in[i]) * scalev - scaled_low_boundv;\nix = clampzo(ix);\n@@ -1202,30 +1209,6 @@ void compute_quantized_weights_for_decimation_table(\nvint scn = pack_low_bytes(scm);\nstore_nbytes(scn, &quantized_weight_set[i]);\n}\n-#endif // #if ASTCENC_SIMD_WIDTH > 1\n-\n- // Loop tail\n- for (/* */; i < weight_count; i++)\n- {\n- float ix = (weight_set_in[i] * scale) - scaled_low_bound;\n- ix = astc::clamp1f(ix);\n-\n- // look up the two closest indexes and return the one that was closest.\n- float ix1 = ix * quant_level_m1;\n- int weight = (int)ix1;\n- float ixl = qat->unquantized_value_unsc[weight];\n- float ixh = qat->unquantized_value_unsc[weight + 1];\n-\n- if (ixl + ixh < 128.0f * ix)\n- {\n- weight++;\n- ixl = ixh;\n- }\n-\n- // Invert the weight-scaling that was done initially\n- weight_set_out[i] = (ixl * rscale) + low_bound;\n- quantized_weight_set[i] = (uint8_t)qat->scramble_map[weight];\n- }\n}\nstatic inline vfloat4 compute_rgbovec(\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Round up comp_quant_weights_for_dt to avoid loop tail
|
61,745 |
18.04.2021 22:52:08
| -3,600 |
2882b9d784e8e1e2ebeb2301f14016625f6c2c35
|
Round up comp_ideal_weights_for_dt to avoid loop tail
This also enables the vector path for SSE and NEON builds as it
is now a net gain (previously AVX2 only).
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_block_sizes2.cpp",
"new_path": "Source/astcenc_block_sizes2.cpp",
"diff": "@@ -244,6 +244,7 @@ static void initialize_decimation_table_2d(\nuint8_t weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\nuint8_t texelcount_of_weight[MAX_WEIGHTS_PER_BLOCK];\n+ uint8_t max_texelcount_of_weight = 0;\nuint8_t texels_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\nint texelweights_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\n@@ -276,7 +277,7 @@ static void initialize_decimation_table_2d(\nqweight[2] = qweight[0] + x_weights;\nqweight[3] = qweight[2] + 1;\n- // truncated-precision bilinear interpolation.\n+ // Truncated-precision bilinear interpolation\nint prod = x_weight_frac * y_weight_frac;\nint weight[4];\n@@ -295,6 +296,7 @@ static void initialize_decimation_table_2d(\ntexels_of_weight[qweight[i]][texelcount_of_weight[qweight[i]]] = texel;\ntexelweights_of_weight[qweight[i]][texelcount_of_weight[qweight[i]]] = weight[i];\ntexelcount_of_weight[qweight[i]]++;\n+ max_texelcount_of_weight = astc::max(max_texelcount_of_weight, texelcount_of_weight[qweight[i]]);\n}\n}\n}\n@@ -304,17 +306,6 @@ static void initialize_decimation_table_2d(\n{\ndt->texel_weight_count[i] = weightcount_of_texel[i];\n- // Init all 4 entries so we can rely on zeros for vectorization\n- for (int j = 0; j < 4; j++)\n- {\n- dt->texel_weights_int_t4[i][j] = 0;\n- dt->texel_weights_t4[i][j] = 0;\n-\n- dt->texel_weights_float_4t[j][i] = 0.0f;\n- dt->texel_weights_4t[j][i] = 0;\n-\n- }\n-\nfor (int j = 0; j < weightcount_of_texel[i]; j++)\n{\ndt->texel_weights_int_t4[i][j] = weights_of_texel[i][j];\n@@ -323,13 +314,24 @@ static void initialize_decimation_table_2d(\ndt->texel_weights_float_4t[j][i] = ((float)weights_of_texel[i][j]) * (1.0f / TEXEL_WEIGHT_SUM);\ndt->texel_weights_4t[j][i] = grid_weights_of_texel[i][j];\n}\n+\n+ // Init all 4 entries so we can rely on zeros for vectorization\n+ for (int j = weightcount_of_texel[i]; j < 4; j++)\n+ {\n+ dt->texel_weights_int_t4[i][j] = 0;\n+ dt->texel_weights_t4[i][j] = 0;\n+\n+ dt->texel_weights_float_4t[j][i] = 0.0f;\n+ dt->texel_weights_4t[j][i] = 0;\n+ }\n}\nfor (int i = 0; i < weights_per_block; i++)\n{\n- dt->weight_texel_count[i] = texelcount_of_weight[i];\n+ int texel_count_wt = texelcount_of_weight[i];\n+ dt->weight_texel_count[i] = (uint8_t)texel_count_wt;\n- for (int j = 0; j < texelcount_of_weight[i]; j++)\n+ for (int j = 0; j < texel_count_wt; j++)\n{\nuint8_t texel = texels_of_weight[i][j];\n@@ -363,6 +365,32 @@ static void initialize_decimation_table_2d(\ndt->texel_weights_float_texel[i][j][swap_idx] = vf;\n}\n}\n+\n+ // Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n+ // Match last texel in active lane in SIMD group, for better gathers\n+ uint8_t last_texel = dt->weight_texel[texel_count_wt - 1][i];\n+ for (int j = texel_count_wt; j < max_texelcount_of_weight; j++)\n+ {\n+ dt->weight_texel[j][i] = last_texel;\n+ dt->weights_flt[j][i] = 0.0f;\n+ }\n+ }\n+\n+ // Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n+ // Match last texel in active lane in SIMD group, for better gathers\n+ int last_texel_count_wt = texelcount_of_weight[weights_per_block - 1];\n+ uint8_t last_texel = dt->weight_texel[last_texel_count_wt - 1][weights_per_block - 1];\n+\n+ int weights_per_block_simd = round_up_to_simd_multiple_vla(weights_per_block);\n+ for (int i = weights_per_block; i < weights_per_block_simd; i++)\n+ {\n+ dt->weight_texel_count[i] = 0;\n+\n+ for (int j = 0; j < max_texelcount_of_weight; j++)\n+ {\n+ dt->weight_texel[j][i] = last_texel;\n+ dt->weights_flt[j][i] = 0.0f;\n+ }\n}\ndt->texel_count = texels_per_block;\n@@ -389,6 +417,7 @@ static void initialize_decimation_table_3d(\nuint8_t weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\nuint8_t texelcount_of_weight[MAX_WEIGHTS_PER_BLOCK];\n+ uint8_t max_texelcount_of_weight = 0;\nuint8_t texels_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\nint texelweights_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\n@@ -512,6 +541,7 @@ static void initialize_decimation_table_3d(\ntexels_of_weight[qweight[i]][texelcount_of_weight[qweight[i]]] = texel;\ntexelweights_of_weight[qweight[i]][texelcount_of_weight[qweight[i]]] = weight[i];\ntexelcount_of_weight[qweight[i]]++;\n+ max_texelcount_of_weight = astc::max(max_texelcount_of_weight, texelcount_of_weight[qweight[i]]);\n}\n}\n}\n@@ -544,8 +574,10 @@ static void initialize_decimation_table_3d(\nfor (int i = 0; i < weights_per_block; i++)\n{\n- dt->weight_texel_count[i] = texelcount_of_weight[i];\n- for (int j = 0; j < texelcount_of_weight[i]; j++)\n+ int texel_count_wt = texelcount_of_weight[i];\n+ dt->weight_texel_count[i] = (uint8_t)texel_count_wt;\n+\n+ for (int j = 0; j < texel_count_wt; j++)\n{\nint texel = texels_of_weight[i][j];\n@@ -579,6 +611,28 @@ static void initialize_decimation_table_3d(\ndt->texel_weights_float_texel[i][j][swap_idx] = vf;\n}\n}\n+\n+ // Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n+ // TODO: Match an active lane in SIMD group, as better for gathers?\n+ for (int j = texel_count_wt; j < max_texelcount_of_weight; j++)\n+ {\n+ dt->weight_texel[j][i] = 0;\n+ dt->weights_flt[j][i] = 0.0f;\n+ }\n+ }\n+\n+ // Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n+ // TODO: Match an active lane in SIMD group, as better for gathers?\n+ int weights_per_block_simd = round_up_to_simd_multiple_vla(weights_per_block);\n+ for (int i = weights_per_block; i < weights_per_block_simd; i++)\n+ {\n+ dt->weight_texel_count[i] = 0;\n+\n+ for (int j = 0; j < max_texelcount_of_weight; j++)\n+ {\n+ dt->weight_texel[j][i] = 0;\n+ dt->weights_flt[j][i] = 0.0f;\n+ }\n}\ndt->texel_count = texels_per_block;\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,6 @@ void compute_ideal_weights_for_decimation_table(\nfloat* RESTRICT weight_set,\nfloat* RESTRICT weights\n) {\n- int i;\nint texel_count = dt.texel_count;\nint weight_count = dt.weight_count;\n@@ -931,7 +930,7 @@ void compute_ideal_weights_for_decimation_table(\n// can safely run SIMD elsewhere without a loop tail. Note that this is always safe as weight\n// arrays always contain space for 64 elements\nint simd_weight_count = round_up_to_simd_multiple_vla(weight_count);\n- for (i = weight_count; i < simd_weight_count; i++)\n+ for (int i = weight_count; i < simd_weight_count; i++)\n{\nweight_set[i] = 0.0f;\n}\n@@ -940,7 +939,7 @@ void compute_ideal_weights_for_decimation_table(\n// weights into both the weight set and the output epw copy.\nif (texel_count == weight_count)\n{\n- for (i = 0; i < texel_count; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\nassert(i == dt.weight_texel[0][i]);\nweight_set[i] = eai_in.weights[i];\n@@ -956,7 +955,7 @@ void compute_ideal_weights_for_decimation_table(\n// epw copy and then do the full algorithm to decimate weights.\nelse\n{\n- for (i = 0; i < texel_count; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\neai_out.weights[i] = eai_in.weights[i];\neai_out.weight_error_scale[i] = eai_in.weight_error_scale[i];\n@@ -967,15 +966,12 @@ void compute_ideal_weights_for_decimation_table(\nalignas(ASTCENC_VECALIGN) float infilled_weights[MAX_TEXELS_PER_BLOCK];\n// Compute an initial average for each decimated weight\n- i = 0;\n-\n-#if ASTCENC_SIMD_WIDTH >= 8\n- int clipped_weight_count = round_down_to_simd_multiple_vla(weight_count);\n-\nbool constant_wes = eai_in.is_constant_weight_error_scale;\nvfloat weight_error_scale(eai_in.weight_error_scale[0]);\n- for (/* */; i < clipped_weight_count; i += ASTCENC_SIMD_WIDTH)\n+ // This overshoots - this is OK as we initialize the array tails in the\n+ // decimation table structures to safe values ...\n+ for (int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Start with a small value to avoid div-by-zero later\nvfloat weight_weight(1e-10f);\n@@ -1011,58 +1007,28 @@ void compute_ideal_weights_for_decimation_table(\nstorea(weight_weight, weights + i);\nstorea(initial_weight / weight_weight, weight_set + i);\n}\n-#endif\n-\n- // Loop tail\n- for (/* */; i < weight_count; i++)\n- {\n- // Start with a small value to avoid div-by-zero later\n- float weight_weight = 1e-10f;\n- float initial_weight = 0.0f;\n-\n- // Accumulate error weighting of all the texels using this weight\n- int weight_texel_count = dt.weight_texel_count[i];\n- promise(weight_texel_count > 0);\n-\n- for (int j = 0; j < weight_texel_count; j++)\n- {\n- int texel = dt.weight_texel[j][i];\n- float weight = dt.weights_flt[j][i];\n- float contrib_weight = weight * eai_in.weight_error_scale[texel];\n- weight_weight += contrib_weight;\n- initial_weight += eai_in.weights[texel] * contrib_weight;\n- }\n-\n- weights[i] = weight_weight;\n- weight_set[i] = initial_weight / weight_weight;\n- }\n// Populate the interpolated weight grid based on the initital average\n- i = 0;\n-\n-#if ASTCENC_SIMD_WIDTH >= 8\n// Process SIMD-width texel coordinates at at time while we can\n+ int is = 0;\nint clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\n- for (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n+ for (/* */; is < clipped_texel_count; is += ASTCENC_SIMD_WIDTH)\n{\n- vfloat weight = bilinear_infill_vla(dt, weight_set, i);\n- storea(weight, infilled_weights + i);\n+ vfloat weight = bilinear_infill_vla(dt, weight_set, is);\n+ storea(weight, infilled_weights + is);\n}\n-#endif\n// Loop tail\n- for (/* */; i < texel_count; i++)\n+ for (/* */; is < texel_count; is++)\n{\n- infilled_weights[i] = bilinear_infill(dt, weight_set, i);\n+ infilled_weights[is] = bilinear_infill(dt, weight_set, is);\n}\n// Perform a single iteration of refinement\nconstexpr float stepsize = 0.25f;\nconstexpr float chd_scale = -TEXEL_WEIGHT_SUM;\n- i = 0;\n-#if ASTCENC_SIMD_WIDTH >= 8\n- for (/* */; i < clipped_weight_count; i += ASTCENC_SIMD_WIDTH)\n+ for (int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Start with a small value to avoid div-by-zero later\nvfloat weight_val = loada(weight_set + i);\n@@ -1106,39 +1072,6 @@ void compute_ideal_weights_for_decimation_table(\n// update the weight\nstorea(weight_val + step, weight_set + i);\n}\n-#endif\n-\n- // Loop tail\n- for (/* */; i < weight_count; i++)\n- {\n- float weight_val = weight_set[i];\n-\n- // Start with a small value to avoid div-by-zero later\n- float error_change0 = 1e-10f;\n- float error_change1 = 0.0f;\n-\n- // Compute the two error changes that occur from perturbing the current index\n- int weight_texel_count = dt.weight_texel_count[i];\n- promise(weight_texel_count > 0);\n- for (int k = 0; k < weight_texel_count; k++)\n- {\n- uint8_t texel = dt.weight_texel[k][i];\n- float contrib_weight = dt.weights_flt[k][i];\n-\n- float scale = eai_in.weight_error_scale[texel] * contrib_weight;\n- float old_weight = infilled_weights[texel];\n- float ideal_weight = eai_in.weights[texel];\n-\n- error_change0 += contrib_weight * scale;\n- error_change1 += (old_weight - ideal_weight) * scale;\n- }\n-\n- float step = (error_change1 * chd_scale) / error_change0;\n- step = astc::clamp(step, -stepsize, stepsize);\n-\n- // update the weight\n- weight_set[i] = weight_val + step;\n- }\n}\n/*\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Round up comp_ideal_weights_for_dt to avoid loop tail
This also enables the vector path for SSE and NEON builds as it
is now a net gain (previously AVX2 only).
|
61,745 |
18.04.2021 23:32:37
| -3,600 |
0b32dbb36605f9a007d82ad2428acb580643832d
|
Remove loop tail from compute_error_rgb/rgba
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_averages_and_directions.cpp",
"new_path": "Source/astcenc_averages_and_directions.cpp",
"diff": "@@ -414,9 +414,13 @@ void compute_error_squared_rgba(\nvfloat samec_hiparamv(-1e10f);\nvfloat4 samec_errorsumv = vfloat4::zero();\n- int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\n- for (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n+ // This implementation over-shoots, but this is safe as we initialize the weights array\n+ // to extend the last value. This means min/max are not impacted, but we need to mask\n+ // out the dummy values when we compute the line weighting.\n+ vint lane_ids = vint::lane_id();\n+ for (/* */; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n+ vmask mask = lane_ids < vint(texel_count);\nvint texel_idxs(&(weights[i]));\nvfloat data_r = gatherf(blk->data_r, texel_idxs);\n@@ -446,12 +450,13 @@ void compute_error_squared_rgba(\nvfloat uncor_dist3 = (l_uncor_amod3 - data_a)\n+ (uncor_param * l_uncor_bis3);\n- vfloat uncor_error = (ew_r * uncor_dist0 * uncor_dist0)\n+ vfloat uncor_err = (ew_r * uncor_dist0 * uncor_dist0)\n+ (ew_g * uncor_dist1 * uncor_dist1)\n+ (ew_b * uncor_dist2 * uncor_dist2)\n+ (ew_a * uncor_dist3 * uncor_dist3);\n- haccumulate(uncor_errorsumv, uncor_error);\n+ uncor_err = select(vfloat::zero(), uncor_err, mask);\n+ haccumulate(uncor_errorsumv, uncor_err);\n// Process samechroma data\nvfloat samec_param = (data_r * l_samec_bs0)\n@@ -467,12 +472,15 @@ void compute_error_squared_rgba(\nvfloat samec_dist2 = samec_param * l_samec_bis2 - data_b;\nvfloat samec_dist3 = samec_param * l_samec_bis3 - data_a;\n- vfloat samec_error = (ew_r * samec_dist0 * samec_dist0)\n+ vfloat samec_err = (ew_r * samec_dist0 * samec_dist0)\n+ (ew_g * samec_dist1 * samec_dist1)\n+ (ew_b * samec_dist2 * samec_dist2)\n+ (ew_a * samec_dist3 * samec_dist3);\n- haccumulate(samec_errorsumv, samec_error);\n+ samec_err = select(vfloat::zero(), samec_err, mask);\n+ haccumulate(samec_errorsumv, samec_err);\n+\n+ lane_ids = lane_ids + vint(ASTCENC_SIMD_WIDTH);\n}\nuncor_loparam = hmin_s(uncor_loparamv);\n@@ -481,56 +489,6 @@ void compute_error_squared_rgba(\nsamec_loparam = hmin_s(samec_loparamv);\nsamec_hiparam = hmax_s(samec_hiparamv);\n- // Loop tail\n- // Error is buffered and accumulated in blocks of 4 to ensure that\n- // the partial sums added to the accumulator are invariant with the\n- // vector implementation, irrespective of vector size ...\n- alignas(16) float uncor_errorsum_tmp[4] { 0 };\n- alignas(16) float samec_errorsum_tmp[4] { 0 };\n- for (/* */; i < texel_count; i++)\n- {\n- int iwt = weights[i];\n-\n- vfloat4 dat = blk->texel(iwt);\n- vfloat4 ews = ewb->error_weights[iwt];\n-\n- float uncor_param = dot_s(dat, l_uncor.bs);\n- uncor_loparam = astc::min(uncor_param, uncor_loparam);\n- uncor_hiparam = astc::max(uncor_param, uncor_hiparam);\n-\n- float samec_param = dot_s(dat, l_samec.bs);\n- samec_loparam = astc::min(samec_param, samec_loparam);\n- samec_hiparam = astc::max(samec_param, samec_hiparam);\n-\n- vfloat4 uncor_dist = (l_uncor.amod - dat)\n- + (uncor_param * l_uncor.bis);\n- float uncor_error_tmp = dot_s(ews, uncor_dist * uncor_dist);\n-\n- vfloat4 samec_dist = samec_param * l_samec.bis - dat;\n- float samec_error_tmp = dot_s(ews, samec_dist * samec_dist);\n-\n- // Accumulate error sum in the temporary array\n- int error_index = i & 0x3;\n- uncor_errorsum_tmp[error_index] = uncor_error_tmp;\n- samec_errorsum_tmp[error_index] = samec_error_tmp;\n-\n-#if ASTCENC_SIMD_WIDTH == 8\n- // Zero the temporary staging buffer every 4 items unless last iter\n- if ((i & 0x7) == 0x03)\n- {\n- haccumulate(uncor_errorsumv, vfloat4::loada(uncor_errorsum_tmp));\n- storea(vfloat4::zero(), uncor_errorsum_tmp);\n-\n- haccumulate(samec_errorsumv, vfloat4::loada(samec_errorsum_tmp));\n- storea(vfloat4::zero(), samec_errorsum_tmp);\n- }\n-#endif\n- }\n-\n- // Accumulate the loop tail using the vfloat4 swizzle\n- haccumulate(uncor_errorsumv, vfloat4::loada(uncor_errorsum_tmp));\n- haccumulate(samec_errorsumv, vfloat4::loada(samec_errorsum_tmp));\n-\n// Resolve the final scalar accumulator sum\nhaccumulate(uncor_errorsum, uncor_errorsumv);\nhaccumulate(samec_errorsum, samec_errorsumv);\n@@ -539,11 +497,8 @@ void compute_error_squared_rgba(\nfloat samec_linelen = samec_hiparam - samec_loparam;\n// Turn very small numbers and NaNs into a small number\n- uncor_linelen = astc::max(uncor_linelen, 1e-7f);\n- samec_linelen = astc::max(samec_linelen, 1e-7f);\n-\n- uncor_lengths[partition] = uncor_linelen;\n- samec_lengths[partition] = samec_linelen;\n+ uncor_lengths[partition] = astc::max(uncor_linelen, 1e-7f);\n+ samec_lengths[partition] = astc::max(samec_linelen, 1e-7f);\n}\n*uncor_errors = uncor_errorsum;\n@@ -580,8 +535,6 @@ void compute_error_squared_rgb(\nprocessed_line3 l_uncor = pl.uncor_pline;\nprocessed_line3 l_samec = pl.samec_pline;\n- int i = 0;\n-\n// This implementation is an example vectorization of this function.\n// It works for - the codec is a 2-4% faster than not vectorizing - but\n// the benefit is limited by the use of gathers and register pressure\n@@ -617,9 +570,13 @@ void compute_error_squared_rgb(\nvfloat samec_hiparamv(-1e10f);\nvfloat4 samec_errorsumv = vfloat4::zero();\n- int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\n- for (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n+ // This implementation over-shoots, but this is safe as we initialize the weights array\n+ // to extend the last value. This means min/max are not impacted, but we need to mask\n+ // out the dummy values when we compute the line weighting.\n+ vint lane_ids = vint::lane_id();\n+ for (int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n+ vmask mask = lane_ids < vint(texel_count);\nvint texel_idxs(&(weights[i]));\nvfloat data_r = gatherf(blk->data_r, texel_idxs);\n@@ -648,6 +605,7 @@ void compute_error_squared_rgb(\n+ (ew_g * uncor_dist1 * uncor_dist1)\n+ (ew_b * uncor_dist2 * uncor_dist2);\n+ uncor_err = select(vfloat::zero(), uncor_err, mask);\nhaccumulate(uncor_errorsumv, uncor_err);\n// Process samechroma data\n@@ -667,7 +625,10 @@ void compute_error_squared_rgb(\n+ (ew_g * samec_dist1 * samec_dist1)\n+ (ew_b * samec_dist2 * samec_dist2);\n+ samec_err = select(vfloat::zero(), samec_err, mask);\nhaccumulate(samec_errorsumv, samec_err);\n+\n+ lane_ids = lane_ids + vint(ASTCENC_SIMD_WIDTH);\n}\nuncor_loparam = hmin_s(uncor_loparamv);\n@@ -676,56 +637,6 @@ void compute_error_squared_rgb(\nsamec_loparam = hmin_s(samec_loparamv);\nsamec_hiparam = hmax_s(samec_hiparamv);\n- // Loop tail\n- // Error is buffered and accumulated in blocks of 4 to ensure that\n- // the partial sums added to the accumulator are invariant with the\n- // vector implementation, irrespective of vector size ...\n- alignas(16) float uncor_errorsum_tmp[4] { 0 };\n- alignas(16) float samec_errorsum_tmp[4] { 0 };\n- for (/* */; i < texel_count; i++)\n- {\n- int iwt = weights[i];\n-\n- vfloat4 dat = blk->texel3(iwt);\n- vfloat4 ews = ewb->error_weights[iwt];\n-\n- float uncor_param = dot3_s(dat, l_uncor.bs);\n- uncor_loparam = astc::min(uncor_param, uncor_loparam);\n- uncor_hiparam = astc::max(uncor_param, uncor_hiparam);\n-\n- float samec_param = dot3_s(dat, l_samec.bs);\n- samec_loparam = astc::min(samec_param, samec_loparam);\n- samec_hiparam = astc::max(samec_param, samec_hiparam);\n-\n- vfloat4 uncor_dist = (l_uncor.amod - dat)\n- + (uncor_param * l_uncor.bis);\n- float uncor_error_tmp = dot3_s(ews, uncor_dist * uncor_dist);\n-\n- vfloat4 samec_dist = samec_param * l_samec.bis - dat;\n- float samec_error_tmp = dot3_s(ews, samec_dist * samec_dist);\n-\n- // Accumulate error sum in the temporary array\n- int error_index = i & 0x3;\n- uncor_errorsum_tmp[error_index] = uncor_error_tmp;\n- samec_errorsum_tmp[error_index] = samec_error_tmp;\n-\n-#if ASTCENC_SIMD_WIDTH == 8\n- // Emit the staging buffer every 4 items unless last iteration\n- if ((i & 0x7) == 0x03)\n- {\n- haccumulate(uncor_errorsumv, vfloat4::loada(uncor_errorsum_tmp));\n- storea(vfloat4::zero(), uncor_errorsum_tmp);\n-\n- haccumulate(samec_errorsumv, vfloat4::loada(samec_errorsum_tmp));\n- storea(vfloat4::zero(), samec_errorsum_tmp);\n- }\n-#endif\n- }\n-\n- // Accumulate the loop tail using the vfloat4 swizzle\n- haccumulate(uncor_errorsumv, vfloat4::loada(uncor_errorsum_tmp));\n- haccumulate(samec_errorsumv, vfloat4::loada(samec_errorsum_tmp));\n-\n// Resolve the final scalar accumulator sum\nhaccumulate(uncor_errorsum, uncor_errorsumv);\nhaccumulate(samec_errorsum, samec_errorsumv);\n@@ -734,11 +645,8 @@ void compute_error_squared_rgb(\nfloat samec_linelen = samec_hiparam - samec_loparam;\n// Turn very small numbers and NaNs into a small number\n- uncor_linelen = astc::max(uncor_linelen, 1e-7f);\n- samec_linelen = astc::max(samec_linelen, 1e-7f);\n-\n- pl.uncor_line_len = uncor_linelen;\n- pl.samec_line_len = samec_linelen;\n+ pl.uncor_line_len = astc::max(uncor_linelen, 1e-7f);\n+ pl.samec_line_len = astc::max(samec_linelen, 1e-7f);\n}\nuncor_error = uncor_errorsum;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "#define MAX_DECIMATION_MODES 87\n#define MAX_WEIGHT_MODES 2048\n+static_assert((MAX_TEXELS_PER_BLOCK % ASTCENC_SIMD_WIDTH) == 0,\n+ \"MAX_TEXELS_PER_BLOCK must be multiple of ASTCENC_SIMD_WIDTH\");\n+\n+static_assert((MAX_WEIGHTS_PER_BLOCK % ASTCENC_SIMD_WIDTH) == 0,\n+ \"MAX_WEIGHTS_PER_BLOCK must be multiple of ASTCENC_SIMD_WIDTH\");\n+\n+static_assert((MAX_WEIGHT_MODES % ASTCENC_SIMD_WIDTH) == 0,\n+ \"MAX_WEIGHT_MODES must be multiple of ASTCENC_SIMD_WIDTH\");\n+\n// A high default error value\nstatic const float ERROR_CALC_DEFAULT { 1e30f };\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_partition_tables.cpp",
"new_path": "Source/astcenc_partition_tables.cpp",
"diff": "@@ -249,6 +249,8 @@ static void generate_one_partition_table(\nuint8_t *partition_of_texel = pt->partition_of_texel;\n+ int texel_idx = 0;\n+ int counts[4] { 0 };\nfor (int z = 0; z < bsd->zdim; z++)\n{\nfor (int y = 0; y < bsd->ydim; y++)\n@@ -256,26 +258,21 @@ static void generate_one_partition_table(\nfor (int x = 0; x < bsd->xdim; x++)\n{\nuint8_t part = select_partition(partition_index, x, y, z, partition_count, small_block);\n+ pt->texels_of_partition[part][counts[part]++] = texel_idx++;\n*partition_of_texel++ = part;\n}\n}\n}\n- int counts[4];\n- for (int i = 0; i < 4; i++)\n+ // Fill loop tail so we can overfetch later\n+ for (int i = 0; i < partition_count; i++)\n{\n- counts[i] = 0;\n- }\n-\n- for (int i = 0; i < texels_per_block; i++)\n+ int ptex_count = counts[i];\n+ int ptex_count_simd = round_up_to_simd_multiple_vla(ptex_count);\n+ for (int j = ptex_count; j < ptex_count_simd; j++)\n{\n- int partition = pt->partition_of_texel[i];\n- pt->texels_of_partition[partition][counts[partition]++] = i;\n+ pt->texels_of_partition[i][j] = pt->texels_of_partition[i][ptex_count - 1];\n}\n-\n- for (int i = 0; i < 4; i++)\n- {\n- pt->partition_texel_count[i] = counts[i];\n}\nif (counts[0] == 0)\n@@ -301,6 +298,7 @@ static void generate_one_partition_table(\nfor (int i = 0; i < 4; i++)\n{\n+ pt->partition_texel_count[i] = counts[i];\npt->coverage_bitmaps[i] = 0ULL;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"new_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"diff": "@@ -935,8 +935,6 @@ void determine_optimal_set_of_endpoint_formats_to_use(\n// Go through the results and pick the best candidate modes\nint best_error_weights[TUNE_MAX_TRIAL_CANDIDATES];\n- static_assert((MAX_WEIGHT_MODES % ASTCENC_SIMD_WIDTH) == 0,\n- \"MAX_WEIGHT_MODES should be multiple of ASTCENC_SIMD_WIDTH\");\nfor (int i = 0; i < tune_candidate_limit; i++)\n{\nvint vbest_error_index(-1);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_weight_align.cpp",
"new_path": "Source/astcenc_weight_align.cpp",
"diff": "#include <cstring>\n#define ANGULAR_STEPS 40\n+\nstatic_assert((ANGULAR_STEPS % ASTCENC_SIMD_WIDTH) == 0,\n\"ANGULAR_STEPS must be multiple of ASTCENC_SIMD_WIDTH\");\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Remove loop tail from compute_error_rgb/rgba
|
61,745 |
19.04.2021 08:56:04
| -3,600 |
d738063449b422e243e7af0523c4a06d290ec8df
|
Update test reference to use latest main scores for CI
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "Test/Images/Small/astc_reference-main-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.2477,0.1295,0.0325,2.0175\n+Small,4x4,ldr-rgb-00.png,37.6610,0.0283,0.0200,3.2781\n+Small,4x4,ldr-rgb-01.png,39.4292,0.0225,0.0144,4.5398\n+Small,4x4,ldr-rgb-02.png,34.5574,0.0316,0.0235,2.7890\n+Small,4x4,ldr-rgb-03.png,45.5738,0.0138,0.0059,11.0331\n+Small,4x4,ldr-rgb-04.png,41.5970,0.0185,0.0101,6.4727\n+Small,4x4,ldr-rgb-05.png,36.8167,0.0316,0.0233,2.8150\n+Small,4x4,ldr-rgb-06.png,34.6862,0.0295,0.0211,3.1003\n+Small,4x4,ldr-rgb-07.png,37.6751,0.0361,0.0273,2.4039\n+Small,4x4,ldr-rgb-08.png,43.0856,0.0175,0.0094,6.9438\n+Small,4x4,ldr-rgb-09.png,41.5841,0.0186,0.0104,6.3247\n+Small,4x4,ldr-rgb-10.png,44.2719,0.0089,0.0032,5.0438\n+Small,4x4,ldr-rgba-00.png,35.1813,0.0368,0.0282,2.3200\n+Small,4x4,ldr-rgba-01.png,38.6094,0.0210,0.0128,5.1352\n+Small,4x4,ldr-rgba-02.png,34.5734,0.0296,0.0212,3.0865\n+Small,4x4,ldr-xy-00.png,37.4323,0.0160,0.0080,8.2117\n+Small,4x4,ldr-xy-01.png,43.7017,0.0171,0.0091,7.1749\n+Small,4x4,ldr-xy-02.png,47.3356,0.0139,0.0057,11.4513\n+Small,4x4,ldrs-rgba-00.png,35.1865,0.0370,0.0283,2.3166\n+Small,4x4,ldrs-rgba-01.png,38.6273,0.0212,0.0127,5.1595\n+Small,4x4,ldrs-rgba-02.png,34.5762,0.0300,0.0215,3.0455\n+Small,5x5,hdr-rgb-00.hdr,25.5487,0.1307,0.0336,1.9530\n+Small,5x5,ldr-rgb-00.png,33.8997,0.0264,0.0171,3.8214\n+Small,5x5,ldr-rgb-01.png,36.0026,0.0199,0.0111,5.8908\n+Small,5x5,ldr-rgb-02.png,30.8682,0.0263,0.0174,3.7641\n+Small,5x5,ldr-rgb-03.png,42.3215,0.0135,0.0047,13.8820\n+Small,5x5,ldr-rgb-04.png,37.0861,0.0186,0.0095,6.9159\n+Small,5x5,ldr-rgb-05.png,32.9505,0.0302,0.0211,3.1092\n+Small,5x5,ldr-rgb-06.png,30.8961,0.0265,0.0173,3.7889\n+Small,5x5,ldr-rgb-07.png,34.2655,0.0267,0.0171,3.8227\n+Small,5x5,ldr-rgb-08.png,39.4441,0.0156,0.0068,9.6604\n+Small,5x5,ldr-rgb-09.png,37.1601,0.0190,0.0102,6.4542\n+Small,5x5,ldr-rgb-10.png,40.0273,0.0094,0.0030,5.4955\n+Small,5x5,ldr-rgba-00.png,31.4666,0.0353,0.0261,2.5157\n+Small,5x5,ldr-rgba-01.png,35.0320,0.0213,0.0120,5.4478\n+Small,5x5,ldr-rgba-02.png,31.0113,0.0316,0.0225,2.9157\n+Small,5x5,ldr-xy-00.png,36.5528,0.0158,0.0068,9.5676\n+Small,5x5,ldr-xy-01.png,39.4512,0.0169,0.0082,8.0207\n+Small,5x5,ldr-xy-02.png,43.2162,0.0145,0.0055,11.9331\n+Small,5x5,ldrs-rgba-00.png,31.4682,0.0356,0.0262,2.5041\n+Small,5x5,ldrs-rgba-01.png,35.0390,0.0214,0.0121,5.3997\n+Small,5x5,ldrs-rgba-02.png,31.0130,0.0318,0.0227,2.8867\n+Small,6x6,hdr-rgb-00.hdr,23.7324,0.1384,0.0403,1.6279\n+Small,6x6,ldr-rgb-00.png,31.3977,0.0354,0.0252,2.6020\n+Small,6x6,ldr-rgb-01.png,32.7929,0.0292,0.0191,3.4267\n+Small,6x6,ldr-rgb-02.png,27.3311,0.0424,0.0324,2.0197\n+Small,6x6,ldr-rgb-03.png,40.3214,0.0156,0.0058,11.3366\n+Small,6x6,ldr-rgb-04.png,33.8184,0.0253,0.0150,4.3600\n+Small,6x6,ldr-rgb-05.png,29.8302,0.0468,0.0365,1.7931\n+Small,6x6,ldr-rgb-06.png,27.3838,0.0432,0.0329,1.9914\n+Small,6x6,ldr-rgb-07.png,32.9779,0.0304,0.0198,3.3082\n+Small,6x6,ldr-rgb-08.png,37.5727,0.0189,0.0088,7.4821\n+Small,6x6,ldr-rgb-09.png,33.4003,0.0274,0.0173,3.7926\n+Small,6x6,ldr-rgb-10.png,36.4844,0.0112,0.0035,4.6563\n+Small,6x6,ldr-rgba-00.png,28.9487,0.0445,0.0340,1.9272\n+Small,6x6,ldr-rgba-01.png,31.9959,0.0259,0.0156,4.2046\n+Small,6x6,ldr-rgba-02.png,27.7614,0.0425,0.0322,2.0322\n+Small,6x6,ldr-xy-00.png,35.4728,0.0179,0.0079,8.3433\n+Small,6x6,ldr-xy-01.png,36.8816,0.0201,0.0102,6.4107\n+Small,6x6,ldr-xy-02.png,41.5957,0.0150,0.0049,13.3281\n+Small,6x6,ldrs-rgba-00.png,28.9498,0.0448,0.0342,1.9142\n+Small,6x6,ldrs-rgba-01.png,32.0017,0.0254,0.0152,4.3087\n+Small,6x6,ldrs-rgba-02.png,27.7600,0.0429,0.0326,2.0099\n+Small,8x8,hdr-rgb-00.hdr,21.2477,0.1505,0.0468,1.4010\n+Small,8x8,ldr-rgb-00.png,27.8158,0.0429,0.0280,2.3444\n+Small,8x8,ldr-rgb-01.png,28.6606,0.0373,0.0227,2.8823\n+Small,8x8,ldr-rgb-02.png,23.0128,0.0527,0.0380,1.7260\n+Small,8x8,ldr-rgb-03.png,37.1637,0.0205,0.0063,10.3614\n+Small,8x8,ldr-rgb-04.png,29.2645,0.0363,0.0213,3.0696\n+Small,8x8,ldr-rgb-05.png,25.6930,0.0605,0.0457,1.4349\n+Small,8x8,ldr-rgb-06.png,23.0579,0.0537,0.0388,1.6893\n+Small,8x8,ldr-rgb-07.png,29.7469,0.0326,0.0173,3.7817\n+Small,8x8,ldr-rgb-08.png,34.2196,0.0248,0.0102,6.4107\n+Small,8x8,ldr-rgb-09.png,28.6136,0.0387,0.0241,2.7184\n+Small,8x8,ldr-rgb-10.png,31.9517,0.0166,0.0041,4.0070\n+Small,8x8,ldr-rgba-00.png,24.7487,0.0508,0.0355,1.8449\n+Small,8x8,ldr-rgba-01.png,28.1720,0.0332,0.0184,3.5681\n+Small,8x8,ldr-rgba-02.png,23.8683,0.0524,0.0374,1.7501\n+Small,8x8,ldr-xy-00.png,32.9813,0.0244,0.0100,6.5752\n+Small,8x8,ldr-xy-01.png,34.1143,0.0260,0.0115,5.6845\n+Small,8x8,ldr-xy-02.png,39.8270,0.0184,0.0037,17.7512\n+Small,8x8,ldrs-rgba-00.png,24.7485,0.0508,0.0357,1.8373\n+Small,8x8,ldrs-rgba-01.png,28.1741,0.0333,0.0185,3.5431\n+Small,8x8,ldrs-rgba-02.png,23.8680,0.0526,0.0375,1.7455\n+Small,12x12,hdr-rgb-00.hdr,18.6187,0.1669,0.0560,1.1697\n+Small,12x12,ldr-rgb-00.png,23.6301,0.0390,0.0161,4.0595\n+Small,12x12,ldr-rgb-01.png,24.7554,0.0344,0.0122,5.3529\n+Small,12x12,ldr-rgb-02.png,19.2200,0.0574,0.0351,1.8667\n+Small,12x12,ldr-rgb-03.png,33.0978,0.0257,0.0039,16.8296\n+Small,12x12,ldr-rgb-04.png,24.5342,0.0357,0.0131,4.9855\n+Small,12x12,ldr-rgb-05.png,21.4474,0.0521,0.0298,2.1969\n+Small,12x12,ldr-rgb-06.png,19.1652,0.0598,0.0372,1.7623\n+Small,12x12,ldr-rgb-07.png,25.3299,0.0328,0.0102,6.3962\n+Small,12x12,ldr-rgb-08.png,29.9994,0.0290,0.0068,9.6761\n+Small,12x12,ldr-rgb-09.png,23.7428,0.0428,0.0204,3.2130\n+Small,12x12,ldr-rgb-10.png,27.3160,0.0234,0.0035,4.6210\n+Small,12x12,ldr-rgba-00.png,21.0174,0.0492,0.0265,2.4696\n+Small,12x12,ldr-rgba-01.png,24.4633,0.0356,0.0130,5.0444\n+Small,12x12,ldr-rgba-02.png,20.1576,0.0596,0.0374,1.7506\n+Small,12x12,ldr-xy-00.png,28.8142,0.0320,0.0097,6.7486\n+Small,12x12,ldr-xy-01.png,30.5809,0.0311,0.0091,7.1924\n+Small,12x12,ldr-xy-02.png,38.1333,0.0247,0.0025,25.9858\n+Small,12x12,ldrs-rgba-00.png,21.0169,0.0494,0.0264,2.4808\n+Small,12x12,ldrs-rgba-01.png,24.4644,0.0355,0.0131,5.0142\n+Small,12x12,ldrs-rgba-02.png,20.1576,0.0601,0.0373,1.7577\n+Small,3x3x3,ldr-l-00-3.dds,50.7196,0.0276,0.0181,14.4966\n+Small,3x3x3,ldr-l-01-3.dds,54.1048,0.0147,0.0077,8.9218\n+Small,6x6x6,ldr-l-00-3.dds,32.6120,0.0814,0.0522,5.0262\n+Small,6x6x6,ldr-l-01-3.dds,40.8080,0.0463,0.0198,3.4746\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "Test/Images/Small/astc_reference-main-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.9013,0.1177,0.0214,3.0610\n+Small,4x4,ldr-rgb-00.png,35.5401,0.0189,0.0105,6.2315\n+Small,4x4,ldr-rgb-01.png,38.6539,0.0141,0.0060,10.8975\n+Small,4x4,ldr-rgb-02.png,33.9017,0.0226,0.0144,4.5562\n+Small,4x4,ldr-rgb-03.png,44.3820,0.0120,0.0041,15.8148\n+Small,4x4,ldr-rgb-04.png,40.6541,0.0127,0.0044,14.7633\n+Small,4x4,ldr-rgb-05.png,35.3252,0.0171,0.0088,7.4754\n+Small,4x4,ldr-rgb-06.png,33.9736,0.0214,0.0131,5.0192\n+Small,4x4,ldr-rgb-07.png,35.7343,0.0194,0.0108,6.0732\n+Small,4x4,ldr-rgb-08.png,41.1869,0.0134,0.0053,12.4003\n+Small,4x4,ldr-rgb-09.png,40.8303,0.0129,0.0046,14.1639\n+Small,4x4,ldr-rgb-10.png,42.1183,0.0079,0.0022,7.4811\n+Small,4x4,ldr-rgba-00.png,32.3988,0.0236,0.0151,4.3508\n+Small,4x4,ldr-rgba-01.png,38.1315,0.0142,0.0057,11.4256\n+Small,4x4,ldr-rgba-02.png,33.8019,0.0196,0.0111,5.9058\n+Small,4x4,ldr-xy-00.png,36.9627,0.0130,0.0049,13.2471\n+Small,4x4,ldr-xy-01.png,40.4676,0.0136,0.0057,11.4256\n+Small,4x4,ldr-xy-02.png,44.0312,0.0118,0.0036,17.9847\n+Small,4x4,ldrs-rgba-00.png,32.4007,0.0236,0.0150,4.3673\n+Small,4x4,ldrs-rgba-01.png,38.1423,0.0142,0.0058,11.2567\n+Small,4x4,ldrs-rgba-02.png,33.8070,0.0195,0.0112,5.8755\n+Small,5x5,hdr-rgb-00.hdr,24.4136,0.1187,0.0206,3.1807\n+Small,5x5,ldr-rgb-00.png,32.7271,0.0155,0.0067,9.7523\n+Small,5x5,ldr-rgb-01.png,35.3125,0.0116,0.0031,21.0877\n+Small,5x5,ldr-rgb-02.png,30.5420,0.0157,0.0072,9.1455\n+Small,5x5,ldr-rgb-03.png,41.0861,0.0112,0.0029,22.2375\n+Small,5x5,ldr-rgb-04.png,35.6324,0.0118,0.0030,21.5354\n+Small,5x5,ldr-rgb-05.png,31.6696,0.0144,0.0058,11.3286\n+Small,5x5,ldr-rgb-06.png,30.5668,0.0164,0.0075,8.7463\n+Small,5x5,ldr-rgb-07.png,32.5480,0.0144,0.0054,12.1028\n+Small,5x5,ldr-rgb-08.png,38.0961,0.0120,0.0034,19.0187\n+Small,5x5,ldr-rgb-09.png,35.6999,0.0118,0.0033,19.8784\n+Small,5x5,ldr-rgb-10.png,39.1121,0.0079,0.0018,9.0512\n+Small,5x5,ldr-rgba-00.png,29.8331,0.0198,0.0108,6.0419\n+Small,5x5,ldr-rgba-01.png,34.3688,0.0129,0.0041,15.9073\n+Small,5x5,ldr-rgba-02.png,30.6074,0.0165,0.0078,8.4300\n+Small,5x5,ldr-xy-00.png,35.8833,0.0120,0.0035,18.6776\n+Small,5x5,ldr-xy-01.png,37.6405,0.0129,0.0047,14.0934\n+Small,5x5,ldr-xy-02.png,42.1351,0.0111,0.0025,26.0795\n+Small,5x5,ldrs-rgba-00.png,29.8410,0.0197,0.0108,6.0710\n+Small,5x5,ldrs-rgba-01.png,34.3699,0.0131,0.0042,15.7613\n+Small,5x5,ldrs-rgba-02.png,30.6094,0.0166,0.0078,8.4445\n+Small,6x6,hdr-rgb-00.hdr,22.8332,0.1198,0.0214,3.0609\n+Small,6x6,ldr-rgb-00.png,29.9673,0.0161,0.0066,10.0010\n+Small,6x6,ldr-rgb-01.png,31.7369,0.0129,0.0036,18.2607\n+Small,6x6,ldr-rgb-02.png,26.8848,0.0189,0.0096,6.8473\n+Small,6x6,ldr-rgb-03.png,39.0272,0.0119,0.0029,22.7718\n+Small,6x6,ldr-rgb-04.png,32.1322,0.0132,0.0037,17.6068\n+Small,6x6,ldr-rgb-05.png,28.5736,0.0160,0.0066,9.9916\n+Small,6x6,ldr-rgb-06.png,26.8934,0.0192,0.0096,6.8054\n+Small,6x6,ldr-rgb-07.png,30.5921,0.0143,0.0046,14.3908\n+Small,6x6,ldr-rgb-08.png,35.8266,0.0126,0.0033,19.8769\n+Small,6x6,ldr-rgb-09.png,31.5938,0.0142,0.0048,13.6423\n+Small,6x6,ldr-rgb-10.png,34.7916,0.0085,0.0017,9.4344\n+Small,6x6,ldr-rgba-00.png,27.0795,0.0205,0.0106,6.1815\n+Small,6x6,ldr-rgba-01.png,31.3888,0.0137,0.0041,16.0428\n+Small,6x6,ldr-rgba-02.png,27.4101,0.0194,0.0098,6.7142\n+Small,6x6,ldr-xy-00.png,34.4941,0.0129,0.0036,17.9988\n+Small,6x6,ldr-xy-01.png,34.9906,0.0131,0.0041,15.8880\n+Small,6x6,ldr-xy-02.png,41.1217,0.0116,0.0023,28.5676\n+Small,6x6,ldrs-rgba-00.png,27.0789,0.0205,0.0108,6.0839\n+Small,6x6,ldrs-rgba-01.png,31.3922,0.0138,0.0042,15.7659\n+Small,6x6,ldrs-rgba-02.png,27.4091,0.0194,0.0098,6.6880\n+Small,8x8,hdr-rgb-00.hdr,20.7980,0.1330,0.0309,2.1184\n+Small,8x8,ldr-rgb-00.png,26.1239,0.0195,0.0059,11.1075\n+Small,8x8,ldr-rgb-01.png,27.6111,0.0169,0.0036,18.2099\n+Small,8x8,ldr-rgb-02.png,22.6838,0.0256,0.0122,5.3569\n+Small,8x8,ldr-rgb-03.png,35.3649,0.0157,0.0026,25.3227\n+Small,8x8,ldr-rgb-04.png,27.5653,0.0175,0.0039,16.6039\n+Small,8x8,ldr-rgb-05.png,24.6789,0.0202,0.0067,9.7599\n+Small,8x8,ldr-rgb-06.png,22.6886,0.0255,0.0119,5.5132\n+Small,8x8,ldr-rgb-07.png,26.9996,0.0176,0.0037,17.7501\n+Small,8x8,ldr-rgb-08.png,32.3082,0.0167,0.0034,19.3209\n+Small,8x8,ldr-rgb-09.png,26.9700,0.0182,0.0048,13.7336\n+Small,8x8,ldr-rgb-10.png,30.5983,0.0127,0.0017,9.3209\n+Small,8x8,ldr-rgba-00.png,23.2909,0.0235,0.0097,6.7494\n+Small,8x8,ldr-rgba-01.png,27.5382,0.0179,0.0044,14.8543\n+Small,8x8,ldr-rgba-02.png,23.5988,0.0262,0.0125,5.2308\n+Small,8x8,ldr-xy-00.png,31.0189,0.0174,0.0042,15.7885\n+Small,8x8,ldr-xy-01.png,31.6160,0.0166,0.0035,18.6827\n+Small,8x8,ldr-xy-02.png,39.5041,0.0156,0.0023,28.0659\n+Small,8x8,ldrs-rgba-00.png,23.2903,0.0234,0.0097,6.7689\n+Small,8x8,ldrs-rgba-01.png,27.5393,0.0180,0.0044,14.9252\n+Small,8x8,ldrs-rgba-02.png,23.5981,0.0264,0.0128,5.1276\n+Small,12x12,hdr-rgb-00.hdr,18.4553,0.1410,0.0338,1.9374\n+Small,12x12,ldr-rgb-00.png,22.2178,0.0216,0.0030,22.1783\n+Small,12x12,ldr-rgb-01.png,23.9444,0.0205,0.0024,27.2049\n+Small,12x12,ldr-rgb-02.png,18.8268,0.0232,0.0049,13.4823\n+Small,12x12,ldr-rgb-03.png,32.1095,0.0199,0.0024,26.8043\n+Small,12x12,ldr-rgb-04.png,23.1291,0.0213,0.0028,23.7271\n+Small,12x12,ldr-rgb-05.png,20.3606,0.0214,0.0030,21.5017\n+Small,12x12,ldr-rgb-06.png,18.7069,0.0233,0.0048,13.6789\n+Small,12x12,ldr-rgb-07.png,23.8295,0.0214,0.0026,25.1489\n+Small,12x12,ldr-rgb-08.png,28.6338,0.0207,0.0024,27.3293\n+Small,12x12,ldr-rgb-09.png,21.9118,0.0214,0.0031,21.3813\n+Small,12x12,ldr-rgb-10.png,26.3721,0.0172,0.0014,11.4400\n+Small,12x12,ldr-rgba-00.png,20.0485,0.0256,0.0067,9.7323\n+Small,12x12,ldr-rgba-01.png,23.8042,0.0213,0.0028,23.6678\n+Small,12x12,ldr-rgba-02.png,19.8784,0.0237,0.0051,12.9672\n+Small,12x12,ldr-xy-00.png,27.2775,0.0214,0.0031,20.9574\n+Small,12x12,ldr-xy-01.png,27.5355,0.0216,0.0035,18.7951\n+Small,12x12,ldr-xy-02.png,38.1044,0.0208,0.0026,25.6703\n+Small,12x12,ldrs-rgba-00.png,20.0498,0.0258,0.0070,9.3757\n+Small,12x12,ldrs-rgba-01.png,23.8055,0.0212,0.0029,22.5921\n+Small,12x12,ldrs-rgba-02.png,19.8779,0.0237,0.0051,12.7376\n+Small,3x3x3,ldr-l-00-3.dds,49.3077,0.0252,0.0158,16.5484\n+Small,3x3x3,ldr-l-01-3.dds,53.8732,0.0139,0.0069,10.0527\n+Small,6x6x6,ldr-l-00-3.dds,32.1162,0.0723,0.0437,5.9964\n+Small,6x6x6,ldr-l-01-3.dds,40.5942,0.0453,0.0188,3.6569\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "Test/Images/Small/astc_reference-main-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.3616,0.1573,0.0604,1.0855\n+Small,4x4,ldr-rgb-00.png,38.6186,0.0662,0.0576,1.1381\n+Small,4x4,ldr-rgb-01.png,39.9904,0.0589,0.0504,1.3003\n+Small,4x4,ldr-rgb-02.png,35.0864,0.0591,0.0508,1.2907\n+Small,4x4,ldr-rgb-03.png,46.9643,0.0380,0.0297,2.2047\n+Small,4x4,ldr-rgb-04.png,41.9794,0.0494,0.0406,1.6135\n+Small,4x4,ldr-rgb-05.png,37.6292,0.0657,0.0572,1.1465\n+Small,4x4,ldr-rgb-06.png,35.2309,0.0539,0.0452,1.4513\n+Small,4x4,ldr-rgb-07.png,38.6220,0.0789,0.0700,0.9361\n+Small,4x4,ldr-rgb-08.png,44.5908,0.0432,0.0348,1.8810\n+Small,4x4,ldr-rgb-09.png,41.9104,0.0497,0.0411,1.5964\n+Small,4x4,ldr-rgb-10.png,44.8283,0.0138,0.0078,2.0732\n+Small,4x4,ldr-rgba-00.png,36.1397,0.0763,0.0674,0.9725\n+Small,4x4,ldr-rgba-01.png,38.8010,0.0428,0.0342,1.9166\n+Small,4x4,ldr-rgba-02.png,34.7461,0.0611,0.0525,1.2493\n+Small,4x4,ldr-xy-00.png,37.6959,0.0371,0.0286,2.2905\n+Small,4x4,ldr-xy-01.png,44.9855,0.0500,0.0419,1.5655\n+Small,4x4,ldr-xy-02.png,50.9056,0.0499,0.0415,1.5775\n+Small,4x4,ldrs-rgba-00.png,36.1447,0.0765,0.0676,0.9700\n+Small,4x4,ldrs-rgba-01.png,38.8178,0.0437,0.0349,1.8772\n+Small,4x4,ldrs-rgba-02.png,34.7492,0.0615,0.0529,1.2388\n+Small,5x5,hdr-rgb-00.hdr,26.5109,0.1676,0.0697,0.9409\n+Small,5x5,ldr-rgb-00.png,35.0090,0.0716,0.0617,1.0621\n+Small,5x5,ldr-rgb-01.png,36.3409,0.0549,0.0453,1.4457\n+Small,5x5,ldr-rgb-02.png,30.9700,0.0567,0.0472,1.3887\n+Small,5x5,ldr-rgb-03.png,43.5605,0.0235,0.0143,4.5740\n+Small,5x5,ldr-rgb-04.png,37.5544,0.0484,0.0385,1.7034\n+Small,5x5,ldr-rgb-05.png,33.4512,0.0772,0.0676,0.9700\n+Small,5x5,ldr-rgb-06.png,30.9908,0.0536,0.0439,1.4931\n+Small,5x5,ldr-rgb-07.png,35.6054,0.0794,0.0692,0.9464\n+Small,5x5,ldr-rgb-08.png,41.1642,0.0366,0.0270,2.4295\n+Small,5x5,ldr-rgb-09.png,37.4845,0.0460,0.0364,1.7996\n+Small,5x5,ldr-rgb-10.png,40.4607,0.0159,0.0088,1.8471\n+Small,5x5,ldr-rgba-00.png,32.7043,0.0907,0.0807,0.8117\n+Small,5x5,ldr-rgba-01.png,35.2094,0.0490,0.0392,1.6719\n+Small,5x5,ldr-rgba-02.png,31.0406,0.0755,0.0657,0.9977\n+Small,5x5,ldr-xy-00.png,37.1119,0.0368,0.0273,2.3994\n+Small,5x5,ldr-xy-01.png,40.9182,0.0455,0.0361,1.8176\n+Small,5x5,ldr-xy-02.png,48.7008,0.0287,0.0191,3.4339\n+Small,5x5,ldrs-rgba-00.png,32.7055,0.0912,0.0813,0.8065\n+Small,5x5,ldrs-rgba-01.png,35.2164,0.0491,0.0392,1.6730\n+Small,5x5,ldrs-rgba-02.png,31.0419,0.0754,0.0652,1.0051\n+Small,6x6,hdr-rgb-00.hdr,24.7385,0.1699,0.0705,0.9291\n+Small,6x6,ldr-rgb-00.png,32.3260,0.0804,0.0694,0.9449\n+Small,6x6,ldr-rgb-01.png,33.0332,0.0710,0.0601,1.0905\n+Small,6x6,ldr-rgb-02.png,27.3868,0.0840,0.0729,0.8988\n+Small,6x6,ldr-rgb-03.png,41.4371,0.0230,0.0126,5.2088\n+Small,6x6,ldr-rgb-04.png,34.1262,0.0631,0.0522,1.2552\n+Small,6x6,ldr-rgb-05.png,30.1074,0.0959,0.0849,0.7718\n+Small,6x6,ldr-rgb-06.png,27.4380,0.0820,0.0708,0.9253\n+Small,6x6,ldr-rgb-07.png,33.9560,0.0854,0.0741,0.8844\n+Small,6x6,ldr-rgb-08.png,39.0372,0.0346,0.0238,2.7580\n+Small,6x6,ldr-rgb-09.png,33.6201,0.0640,0.0530,1.2357\n+Small,6x6,ldr-rgb-10.png,36.8847,0.0180,0.0094,1.7248\n+Small,6x6,ldr-rgba-00.png,30.1167,0.0993,0.0881,0.7439\n+Small,6x6,ldr-rgba-01.png,32.1289,0.0501,0.0391,1.6773\n+Small,6x6,ldr-rgba-02.png,27.7847,0.0795,0.0683,0.9594\n+Small,6x6,ldr-xy-00.png,36.0269,0.0337,0.0228,2.8686\n+Small,6x6,ldr-xy-01.png,37.9553,0.0376,0.0271,2.4207\n+Small,6x6,ldr-xy-02.png,45.0705,0.0248,0.0138,4.7445\n+Small,6x6,ldrs-rgba-00.png,30.1179,0.1002,0.0889,0.7375\n+Small,6x6,ldrs-rgba-01.png,32.1342,0.0503,0.0392,1.6702\n+Small,6x6,ldrs-rgba-02.png,27.7833,0.0803,0.0693,0.9456\n+Small,8x8,hdr-rgb-00.hdr,21.4936,0.1812,0.0770,0.8513\n+Small,8x8,ldr-rgb-00.png,28.6884,0.1043,0.0884,0.7411\n+Small,8x8,ldr-rgb-01.png,28.8598,0.0875,0.0719,0.9111\n+Small,8x8,ldr-rgb-02.png,23.0842,0.1013,0.0852,0.7690\n+Small,8x8,ldr-rgb-03.png,38.2738,0.0307,0.0153,4.2865\n+Small,8x8,ldr-rgb-04.png,29.5762,0.0817,0.0656,0.9994\n+Small,8x8,ldr-rgb-05.png,25.8720,0.1157,0.0997,0.6576\n+Small,8x8,ldr-rgb-06.png,23.1231,0.1007,0.0844,0.7762\n+Small,8x8,ldr-rgb-07.png,30.6667,0.0942,0.0777,0.8435\n+Small,8x8,ldr-rgb-08.png,35.7049,0.0425,0.0265,2.4687\n+Small,8x8,ldr-rgb-09.png,29.0061,0.0807,0.0648,1.0113\n+Small,8x8,ldr-rgb-10.png,32.1215,0.0260,0.0128,1.2678\n+Small,8x8,ldr-rgba-00.png,26.0361,0.1227,0.1065,0.6154\n+Small,8x8,ldr-rgba-01.png,28.2824,0.0585,0.0423,1.5483\n+Small,8x8,ldr-rgba-02.png,23.8814,0.0924,0.0761,0.8610\n+Small,8x8,ldr-xy-00.png,33.9902,0.0456,0.0299,2.1886\n+Small,8x8,ldr-xy-01.png,34.9440,0.0444,0.0288,2.2786\n+Small,8x8,ldr-xy-02.png,40.7557,0.0255,0.0095,6.9225\n+Small,8x8,ldrs-rgba-00.png,26.0368,0.1223,0.1061,0.6177\n+Small,8x8,ldrs-rgba-01.png,28.2857,0.0594,0.0431,1.5223\n+Small,8x8,ldrs-rgba-02.png,23.8810,0.0921,0.0759,0.8632\n+Small,12x12,hdr-rgb-00.hdr,18.7396,0.2112,0.0974,0.6729\n+Small,12x12,ldr-rgb-00.png,24.5069,0.1096,0.0838,0.7823\n+Small,12x12,ldr-rgb-01.png,25.0074,0.1096,0.0840,0.7799\n+Small,12x12,ldr-rgb-02.png,19.2602,0.1316,0.1059,0.6187\n+Small,12x12,ldr-rgb-03.png,34.6538,0.0394,0.0140,4.6705\n+Small,12x12,ldr-rgb-04.png,24.8521,0.0971,0.0712,0.9204\n+Small,12x12,ldr-rgb-05.png,21.5895,0.1357,0.1101,0.5954\n+Small,12x12,ldr-rgb-06.png,19.2042,0.1204,0.0942,0.6960\n+Small,12x12,ldr-rgb-07.png,26.5943,0.0986,0.0724,0.9050\n+Small,12x12,ldr-rgb-08.png,31.1520,0.0510,0.0258,2.5358\n+Small,12x12,ldr-rgb-09.png,24.2497,0.1047,0.0796,0.8230\n+Small,12x12,ldr-rgb-10.png,27.8993,0.0444,0.0214,0.7609\n+Small,12x12,ldr-rgba-00.png,21.7698,0.1145,0.0885,0.7404\n+Small,12x12,ldr-rgba-01.png,24.5786,0.0743,0.0484,1.3535\n+Small,12x12,ldr-rgba-02.png,20.1586,0.1131,0.0871,0.7521\n+Small,12x12,ldr-xy-00.png,29.7015,0.0561,0.0311,2.1054\n+Small,12x12,ldr-xy-01.png,31.9137,0.0507,0.0252,2.5975\n+Small,12x12,ldr-xy-02.png,38.1657,0.0281,0.0034,19.5226\n+Small,12x12,ldrs-rgba-00.png,21.7703,0.1149,0.0893,0.7339\n+Small,12x12,ldrs-rgba-01.png,24.5804,0.0729,0.0473,1.3868\n+Small,12x12,ldrs-rgba-02.png,20.1585,0.1122,0.0862,0.7600\n+Small,3x3x3,ldr-l-00-3.dds,51.8519,0.0383,0.0290,9.0345\n+Small,3x3x3,ldr-l-01-3.dds,54.3882,0.0148,0.0077,8.9636\n+Small,6x6x6,ldr-l-00-3.dds,32.9172,0.0936,0.0647,4.0516\n+Small,6x6x6,ldr-l-01-3.dds,40.8335,0.0458,0.0191,3.6048\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "Test/Images/Small/astc_reference-main-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.6276,0.2320,0.1361,0.4816\n+Small,4x4,ldr-rgb-00.png,39.1011,0.1497,0.1405,0.4664\n+Small,4x4,ldr-rgb-01.png,40.2753,0.1441,0.1354,0.4839\n+Small,4x4,ldr-rgb-02.png,35.3312,0.1306,0.1221,0.5368\n+Small,4x4,ldr-rgb-03.png,47.6554,0.1515,0.1433,0.4572\n+Small,4x4,ldr-rgb-04.png,42.2447,0.1297,0.1211,0.5413\n+Small,4x4,ldr-rgb-05.png,37.9471,0.1431,0.1343,0.4879\n+Small,4x4,ldr-rgb-06.png,35.4333,0.1238,0.1151,0.5693\n+Small,4x4,ldr-rgb-07.png,39.6965,0.1634,0.1543,0.4248\n+Small,4x4,ldr-rgb-08.png,45.6562,0.1392,0.1308,0.5011\n+Small,4x4,ldr-rgb-09.png,42.1581,0.1343,0.1257,0.5214\n+Small,4x4,ldr-rgb-10.png,44.9944,0.0254,0.0191,0.8507\n+Small,4x4,ldr-rgba-00.png,36.7422,0.1548,0.1456,0.4501\n+Small,4x4,ldr-rgba-01.png,39.0115,0.1365,0.1275,0.5141\n+Small,4x4,ldr-rgba-02.png,34.9453,0.1533,0.1446,0.4534\n+Small,4x4,ldr-xy-00.png,37.7350,0.1324,0.1238,0.5294\n+Small,4x4,ldr-xy-01.png,45.4828,0.1299,0.1217,0.5386\n+Small,4x4,ldr-xy-02.png,51.0007,0.1598,0.1511,0.4337\n+Small,4x4,ldrs-rgba-00.png,36.7505,0.1558,0.1467,0.4467\n+Small,4x4,ldrs-rgba-01.png,39.0325,0.1369,0.1282,0.5112\n+Small,4x4,ldrs-rgba-02.png,34.9504,0.1531,0.1441,0.4548\n+Small,5x5,hdr-rgb-00.hdr,27.4649,0.2581,0.1593,0.4113\n+Small,5x5,ldr-rgb-00.png,35.3227,0.1856,0.1757,0.3730\n+Small,5x5,ldr-rgb-01.png,36.4857,0.1727,0.1630,0.4019\n+Small,5x5,ldr-rgb-02.png,31.1011,0.1370,0.1274,0.5144\n+Small,5x5,ldr-rgb-03.png,44.4625,0.1504,0.1412,0.4643\n+Small,5x5,ldr-rgb-04.png,37.7979,0.1325,0.1225,0.5349\n+Small,5x5,ldr-rgb-05.png,33.6559,0.1503,0.1406,0.4663\n+Small,5x5,ldr-rgb-06.png,31.0952,0.1324,0.1223,0.5357\n+Small,5x5,ldr-rgb-07.png,36.5891,0.1710,0.1609,0.4073\n+Small,5x5,ldr-rgb-08.png,42.2367,0.1399,0.1300,0.5040\n+Small,5x5,ldr-rgb-09.png,37.6643,0.1398,0.1299,0.5044\n+Small,5x5,ldr-rgb-10.png,40.7404,0.0297,0.0225,0.7226\n+Small,5x5,ldr-rgba-00.png,33.1225,0.1661,0.1557,0.4209\n+Small,5x5,ldr-rgba-01.png,35.3487,0.1483,0.1384,0.4736\n+Small,5x5,ldr-rgba-02.png,31.1475,0.1758,0.1657,0.3954\n+Small,5x5,ldr-xy-00.png,37.2677,0.1182,0.1085,0.6041\n+Small,5x5,ldr-xy-01.png,41.7306,0.1470,0.1377,0.4761\n+Small,5x5,ldr-xy-02.png,49.2472,0.1634,0.1534,0.4273\n+Small,5x5,ldrs-rgba-00.png,33.1249,0.1681,0.1581,0.4146\n+Small,5x5,ldrs-rgba-01.png,35.3573,0.1487,0.1388,0.4721\n+Small,5x5,ldrs-rgba-02.png,31.1476,0.1775,0.1676,0.3910\n+Small,6x6,hdr-rgb-00.hdr,24.8386,0.2334,0.1349,0.4859\n+Small,6x6,ldr-rgb-00.png,32.6492,0.1812,0.1698,0.3860\n+Small,6x6,ldr-rgb-01.png,33.1763,0.1830,0.1722,0.3806\n+Small,6x6,ldr-rgb-02.png,27.4903,0.1839,0.1729,0.3791\n+Small,6x6,ldr-rgb-03.png,42.5103,0.1106,0.0999,0.6563\n+Small,6x6,ldr-rgb-04.png,34.3338,0.1750,0.1639,0.3999\n+Small,6x6,ldr-rgb-05.png,30.2805,0.1871,0.1761,0.3722\n+Small,6x6,ldr-rgb-06.png,27.5521,0.1835,0.1722,0.3806\n+Small,6x6,ldr-rgb-07.png,34.3790,0.1826,0.1711,0.3831\n+Small,6x6,ldr-rgb-08.png,39.8933,0.1075,0.0962,0.6810\n+Small,6x6,ldr-rgb-09.png,33.8281,0.1667,0.1557,0.4209\n+Small,6x6,ldr-rgb-10.png,37.1218,0.0350,0.0264,0.6157\n+Small,6x6,ldr-rgba-00.png,30.4850,0.1862,0.1748,0.3749\n+Small,6x6,ldr-rgba-01.png,32.2500,0.1604,0.1490,0.4399\n+Small,6x6,ldr-rgba-02.png,27.8831,0.1977,0.1863,0.3518\n+Small,6x6,ldr-xy-00.png,36.3665,0.0873,0.0763,0.8594\n+Small,6x6,ldr-xy-01.png,38.4721,0.1252,0.1145,0.5722\n+Small,6x6,ldr-xy-02.png,47.4519,0.1607,0.1495,0.4384\n+Small,6x6,ldrs-rgba-00.png,30.4860,0.1866,0.1752,0.3741\n+Small,6x6,ldrs-rgba-01.png,32.2561,0.1620,0.1508,0.4346\n+Small,6x6,ldrs-rgba-02.png,27.8824,0.1983,0.1869,0.3506\n+Small,8x8,hdr-rgb-00.hdr,21.7853,0.2480,0.1439,0.4555\n+Small,8x8,ldr-rgb-00.png,28.9714,0.2064,0.1896,0.3456\n+Small,8x8,ldr-rgb-01.png,29.0084,0.1949,0.1784,0.3673\n+Small,8x8,ldr-rgb-02.png,23.1777,0.2088,0.1923,0.3408\n+Small,8x8,ldr-rgb-03.png,39.4347,0.0611,0.0452,1.4505\n+Small,8x8,ldr-rgb-04.png,29.7727,0.1959,0.1791,0.3659\n+Small,8x8,ldr-rgb-05.png,26.0312,0.2120,0.1954,0.3354\n+Small,8x8,ldr-rgb-06.png,23.2320,0.2084,0.1919,0.3415\n+Small,8x8,ldr-rgb-07.png,31.1334,0.1997,0.1828,0.3586\n+Small,8x8,ldr-rgb-08.png,36.5089,0.0964,0.0800,0.8197\n+Small,8x8,ldr-rgb-09.png,29.2001,0.1642,0.1478,0.4434\n+Small,8x8,ldr-rgb-10.png,32.3501,0.0436,0.0296,0.5486\n+Small,8x8,ldr-rgba-00.png,26.5025,0.2117,0.1949,0.3362\n+Small,8x8,ldr-rgba-01.png,28.3989,0.1756,0.1590,0.4122\n+Small,8x8,ldr-rgba-02.png,23.9603,0.2067,0.1902,0.3446\n+Small,8x8,ldr-xy-00.png,34.2721,0.0985,0.0822,0.7975\n+Small,8x8,ldr-xy-01.png,35.4956,0.0913,0.0753,0.8704\n+Small,8x8,ldr-xy-02.png,44.4209,0.1011,0.0847,0.7739\n+Small,8x8,ldrs-rgba-00.png,26.5042,0.2125,0.1958,0.3348\n+Small,8x8,ldrs-rgba-01.png,28.4019,0.1778,0.1612,0.4066\n+Small,8x8,ldrs-rgba-02.png,23.9598,0.2087,0.1917,0.3418\n+Small,12x12,hdr-rgb-00.hdr,18.9038,0.2769,0.1634,0.4011\n+Small,12x12,ldr-rgb-00.png,24.9543,0.2251,0.1990,0.3293\n+Small,12x12,ldr-rgb-01.png,25.1698,0.2052,0.1785,0.3671\n+Small,12x12,ldr-rgb-02.png,19.3141,0.2363,0.2095,0.3128\n+Small,12x12,ldr-rgb-03.png,36.1337,0.0696,0.0432,1.5178\n+Small,12x12,ldr-rgb-04.png,25.0126,0.2097,0.1829,0.3583\n+Small,12x12,ldr-rgb-05.png,21.7224,0.2368,0.2099,0.3122\n+Small,12x12,ldr-rgb-06.png,19.2786,0.2333,0.2065,0.3174\n+Small,12x12,ldr-rgb-07.png,27.0502,0.2159,0.1887,0.3473\n+Small,12x12,ldr-rgb-08.png,32.2375,0.0958,0.0691,0.9489\n+Small,12x12,ldr-rgb-09.png,24.4441,0.2006,0.1738,0.3772\n+Small,12x12,ldr-rgb-10.png,28.1380,0.0659,0.0420,0.3867\n+Small,12x12,ldr-rgba-00.png,22.2836,0.2278,0.2010,0.3260\n+Small,12x12,ldr-rgba-01.png,24.7086,0.1746,0.1475,0.4442\n+Small,12x12,ldr-rgba-02.png,20.2134,0.2035,0.1763,0.3717\n+Small,12x12,ldr-xy-00.png,30.5300,0.1245,0.0978,0.6699\n+Small,12x12,ldr-xy-01.png,32.4629,0.0913,0.0646,1.0144\n+Small,12x12,ldr-xy-02.png,39.8690,0.0609,0.0340,1.9287\n+Small,12x12,ldrs-rgba-00.png,22.2836,0.2288,0.2017,0.3250\n+Small,12x12,ldrs-rgba-01.png,24.7101,0.1753,0.1482,0.4421\n+Small,12x12,ldrs-rgba-02.png,20.2135,0.2030,0.1759,0.3725\n+Small,3x3x3,ldr-l-00-3.dds,52.4074,0.0862,0.0770,3.4058\n+Small,3x3x3,ldr-l-01-3.dds,55.4199,0.0380,0.0309,2.2275\n+Small,6x6x6,ldr-l-00-3.dds,33.2677,0.1447,0.1156,2.2678\n+Small,6x6x6,ldr-l-01-3.dds,41.7102,0.0554,0.0289,2.3853\n"
},
{
"change_type": "MODIFY",
"old_path": "Test/astc_test_image.py",
"new_path": "Test/astc_test_image.py",
"diff": "@@ -299,7 +299,7 @@ def parse_command_line():\nparser.add_argument(\"--encoder\", dest=\"encoders\", default=\"avx2\",\nchoices=coders, help=\"test encoder variant\")\n- parser.add_argument(\"--reference\", dest=\"reference\", default=\"ref-2.5-avx2\",\n+ parser.add_argument(\"--reference\", dest=\"reference\", default=\"ref-main-avx2\",\nchoices=refcoders, help=\"reference encoder variant\")\nastcProfile = [\"ldr\", \"ldrs\", \"hdr\", \"all\"]\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Update test reference to use latest main scores for CI
|
61,745 |
19.04.2021 22:12:01
| -3,600 |
6742cd79eda156f767ad167015e78d009e42c7e1
|
Add bitrate-specific presets
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "#include \"astcenc_internal.h\"\n#include \"astcenc_diagnostic_trace.h\"\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_count_limit;\n+ unsigned int tune_partition_index_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 for high bandwidth\n+ * presets (x < 25 texels per block).\n+ */\n+static const std::array<astcenc_preset_config, 5> preset_configs_high {{\n+ {\n+ ASTCENC_PRE_FASTEST,\n+ 3, 2, 30, 1, 1, 79, 57, 2.0f, 2.0f, 1.0f, 0.5f\n+ }, {\n+ ASTCENC_PRE_FAST,\n+ 3, 12, 55, 3, 2, 85, 63, 3.5f, 3.5f, 1.0f, 0.5f\n+ }, {\n+ ASTCENC_PRE_MEDIUM,\n+ 4, 25, 75, 2, 2, 95, 70, 1.75f, 1.75f, 1.2f, 0.75f\n+ }, {\n+ ASTCENC_PRE_THOROUGH,\n+ 4, 75, 92, 4, 4, 105, 77, 10.0f, 10.0f, 2.5f, 0.95f\n+ }, {\n+ ASTCENC_PRE_EXHAUSTIVE,\n+ 4, 1024, 100, 4, 4, 200, 200, 10.0f, 10.0f, 10.0f, 0.99f\n+ }\n+}};\n+\n+/**\n+ * @brief The static quality presets that are built-in for medium bandwidth\n+ * presets (25 <= x < 64 texels per block).\n+ */\n+static const std::array<astcenc_preset_config, 5> preset_configs_mid {{\n+ {\n+ ASTCENC_PRE_FASTEST,\n+ 3, 2, 30, 1, 1, 79, 57, 2.0f, 2.0f, 1.0f, 0.5f\n+ }, {\n+ ASTCENC_PRE_FAST,\n+ 3, 10, 55, 2, 2, 85, 63, 3.5f, 3.5f, 1.0f, 0.5f\n+ }, {\n+ ASTCENC_PRE_MEDIUM,\n+ 3, 27, 77, 2, 2, 95, 70, 1.75f, 1.75f, 1.2f, 0.75f\n+ }, {\n+ ASTCENC_PRE_THOROUGH,\n+ 4, 75, 92, 4, 4, 105, 77, 10.0f, 10.0f, 2.5f, 0.95f\n+ }, {\n+ ASTCENC_PRE_EXHAUSTIVE,\n+ 4, 1024, 100, 4, 4, 200, 200, 10.0f, 10.0f, 10.0f, 0.99f\n+ }\n+}};\n+\n+/**\n+ * @brief The static quality presets that are built-in for low bandwidth\n+ * presets (64 <= x texels per block).\n+ */\n+static const std::array<astcenc_preset_config, 5> preset_configs_low {{\n+ {\n+ ASTCENC_PRE_FASTEST,\n+ 3, 2, 30, 1, 1, 79, 57, 2.0f, 2.0f, 1.0f, 0.5f\n+ }, {\n+ ASTCENC_PRE_FAST,\n+ 3, 6, 52, 2, 2, 85, 63, 3.5f, 3.5f, 1.0f, 0.5f\n+ }, {\n+ ASTCENC_PRE_MEDIUM,\n+ 3, 27, 77, 3, 2, 95, 70, 1.75f, 1.75f, 1.2f, 0.75f\n+ }, {\n+ ASTCENC_PRE_THOROUGH,\n+ 3, 77, 94, 4, 4, 105, 77, 10.0f, 10.0f, 2.5f, 0.95f\n+ }, {\n+ ASTCENC_PRE_EXHAUSTIVE,\n+ 4, 1024, 100, 4, 4, 200, 200, 10.0f, 10.0f, 10.0f, 0.99f\n+ }\n+}};\n+\n+\n// The ASTC codec is written with the assumption that a float threaded through\n// the \"if32\" union will in fact be stored and reloaded as a 32-bit IEEE-754 single-precision\n// float, stored with round-to-nearest rounding. This is always the case in an\n@@ -81,53 +176,6 @@ 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_count_limit;\n- unsigned int tune_partition_index_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- 4, 2, 30, 1, 1, 79, 57, 2.0f, 2.0f, 1.0f, 0.5f\n- }, {\n- ASTCENC_PRE_FAST,\n- 4, 4, 50, 2, 2, 85, 63, 3.5f, 3.5f, 1.0f, 0.5f\n- }, {\n- ASTCENC_PRE_MEDIUM,\n- 4, 25, 75, 2, 2, 95, 70, 1.75f, 1.75f, 1.2f, 0.75f\n- }, {\n- ASTCENC_PRE_THOROUGH,\n- 4, 75, 92, 4, 4, 105, 77, 10.0f, 10.0f, 2.5f, 0.95f\n- }, {\n- ASTCENC_PRE_EXHAUSTIVE,\n- 4, 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@@ -375,12 +423,30 @@ astcenc_error astcenc_config_init(\nreturn ASTCENC_ERR_BAD_QUALITY;\n}\n+ static const std::array<astcenc_preset_config, 5>* preset_configs;\n+ int texels_int = block_x * block_y * block_z;\n+ if (texels_int < 25)\n+ {\n+ preset_configs = &preset_configs_high;\n+ printf(\"High bitrate config\\n\");\n+ }\n+ else if (texels_int < 64)\n+ {\n+ preset_configs = &preset_configs_mid;\n+ printf(\"Mid bitrate config\\n\");\n+ }\n+ else\n+ {\n+ preset_configs = &preset_configs_low;\n+ printf(\"Low bitrate config\\n\");\n+ }\n+\n// Determine which preset to use, or which pair to interpolate\nsize_t start;\nsize_t end;\n- for (end = 0; end < preset_configs.size(); end++)\n+ for (end = 0; end < preset_configs->size(); end++)\n{\n- if (preset_configs[end].quality >= quality)\n+ if ((*preset_configs)[end].quality >= quality)\n{\nbreak;\n}\n@@ -391,26 +457,26 @@ astcenc_error astcenc_config_init(\n// Start and end node are the same - so just transfer the values.\nif (start == end)\n{\n- config.tune_partition_count_limit = preset_configs[start].tune_partition_count_limit;\n- config.tune_partition_index_limit = preset_configs[start].tune_partition_index_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+ config.tune_partition_count_limit = (*preset_configs)[start].tune_partition_count_limit;\n+ config.tune_partition_index_limit = (*preset_configs)[start].tune_partition_index_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,\nTUNE_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+ 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- 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_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 = 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+ 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\nelse\n{\n- auto& node_a = preset_configs[start];\n- auto& node_b = preset_configs[end];\n+ auto& node_a = (*preset_configs)[start];\n+ auto& node_b = (*preset_configs)[end];\nfloat wt_range = node_b.quality - node_a.quality;\nassert(wt_range > 0);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenccli_toplevel_help.cpp",
"new_path": "Source/astcenccli_toplevel_help.cpp",
"diff": "@@ -300,15 +300,18 @@ ADVANCED COMPRESSION\n------------------------------------\nThese options provide low-level control of the codec heuristics that\n- drive the performance-quality trade off.\n+ drive the performance-quality trade off. The presets vary by block\n+ bitrate; the recommended starting pioint for a 4x4 block is very\n+ different to a 8x8 block. The presets documented here are for the\n+ high bitrate mode (fewer than 25 texels).\n-partitioncountlimit <number>\nTest up to and including <number> partitions for each block.\nHigher numbers give better quality, as more complex blocks can\nbe encoded, but will increase search time. Preset defaults are:\n- -fastest : 4\n- -fast : 4\n+ -fastest : 3\n+ -fast : 3\n-medium : 4\n-thorough : 4\n-exhaustive : 4\n@@ -320,8 +323,8 @@ ADVANCED COMPRESSION\ndefaults are:\n-fastest : 2\n- -fast : 4\n- -medium : 26\n+ -fast : 12\n+ -medium : 25\n-thorough : 75\n-exhaustive : 1024\n@@ -330,8 +333,8 @@ ADVANCED COMPRESSION\ndetermined distribution of block mode frequency. This option is\nineffective for 3D textures. Preset defaults are:\n- -fastest : 25\n- -fast : 50\n+ -fastest : 30\n+ -fast : 55\n-medium : 75\n-thorough : 92\n-exhaustive : 100\n@@ -341,7 +344,7 @@ ADVANCED COMPRESSION\nweights. Minimum value is 1. Preset defaults are:\n-fastest : 1\n- -fast : 1\n+ -fast : 3\n-medium : 2\n-thorough : 4\n-exhaustive : 4\n@@ -361,7 +364,7 @@ ADVANCED COMPRESSION\nineffective for HDR textures. Preset defaults, where N is the\nnumber of texels in a block, are:\n- -fastest : MAX(53-19*log10(N), 70-35*log10(N))\n+ -fastest : MAX(57-19*log10(N), 79-35*log10(N))\n-fast : MAX(63-19*log10(N), 85-35*log10(N))\n-medium : MAX(70-19*log10(N), 95-35*log10(N))\n-thorough : MAX(77-19*log10(N), 105-35*log10(N))\n@@ -378,7 +381,7 @@ ADVANCED COMPRESSION\n-fast : 1.0\n-medium : 1.2\n-thorough : 2.5\n- -exhaustive : 1000.0\n+ -exhaustive : 10.0\n-planecorlimit <factor>\nStop compression after testing only one plane of weights, unless\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add bitrate-specific presets
|
61,745 |
20.04.2021 22:03:13
| -3,600 |
382c62ee9122ec971826b9ff44a14baa7e6918ef
|
Fix bad present value in -help text
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenccli_toplevel_help.cpp",
"new_path": "Source/astcenccli_toplevel_help.cpp",
"diff": "@@ -388,7 +388,7 @@ ADVANCED COMPRESSION\noption is ineffective for normal maps. Preset defaults are:\n-fastest : 1.00\n- -fast : 1.00\n+ -fast : 1.10\n-medium : 1.25\n-thorough : 1.25\n-exhaustive : 10.00\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Fix bad present value in -help text
|
61,745 |
20.04.2021 22:13:07
| -3,600 |
b4d16c0f27a8a676ddbe8ca627f963d50833b2a0
|
Allow restricted search pruning for normal maps
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc.h",
"new_path": "Source/astcenc.h",
"diff": "@@ -528,14 +528,14 @@ struct astcenc_config\n/**\n* @brief The threshold for skipping 2.2/3.1/3.2/4.1 trials (-2partitionearlylimit).\n*\n- * This option is ineffective for normal maps.\n+ * This option is further scaled for normal maps, so it skips less often.\n*/\nfloat tune_2_partition_early_out_limit;\n/**\n* @brief The threshold for skipping 3.2/4.1 trials (-3partitionearlylimit).\n*\n- * This option is ineffective for normal maps.\n+ * This option is further scaled for normal maps, so it skips less often.\n*/\nfloat tune_3_partition_early_out_limit;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -521,8 +521,8 @@ astcenc_error astcenc_config_init(\n{\nconfig.cw_g_weight = 0.0f;\nconfig.cw_b_weight = 0.0f;\n- config.tune_2_partition_early_out_limit = 1000.0f;\n- config.tune_3_partition_early_out_limit = 1000.0f;\n+ config.tune_2_partition_early_out_limit *= 1.5f;\n+ config.tune_3_partition_early_out_limit *= 1.5f;\nconfig.tune_two_plane_early_out_limit = 0.99f;\nif (flags & ASTCENC_FLG_USE_PERCEPTUAL)\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenccli_toplevel_help.cpp",
"new_path": "Source/astcenccli_toplevel_help.cpp",
"diff": "@@ -371,8 +371,8 @@ ADVANCED COMPRESSION\nStop compression work on a block after only testing blocks with\nup to two partions and one plane of weights, unless the two\npartition error term is lower than the error term from encoding\n- with one partition by more than the specified factor. This\n- option is ineffective for normal maps. Preset defaults are:\n+ with one partition by more than the specified factor. Preset\n+ defaults are:\n-fastest : 1.00\n-fast : 1.00\n@@ -384,8 +384,8 @@ ADVANCED COMPRESSION\nStop compression work on a block after only testing blocks with\nup to three partions and one plane of weights, unless the three\npartition error term is lower than the error term from encoding\n- with two partitions by more than the specified factor. This\n- option is ineffective for normal maps. Preset defaults are:\n+ with two partitions by more than the specified factor. Preset\n+ defaults are:\n-fastest : 1.00\n-fast : 1.10\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Allow restricted search pruning for normal maps
|
61,745 |
21.04.2021 08:59:48
| -3,600 |
185b8cdc6520ecd74bd0ea5287c3e74172e18fa2
|
Tune presets to offset losses due to new heuristic
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -60,19 +60,19 @@ struct astcenc_preset_config {\nstatic const std::array<astcenc_preset_config, 5> preset_configs_high {{\n{\nASTCENC_PRE_FASTEST,\n- 4, 2, 30, 1, 1, 79, 57, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 4, 4, 50, 2, 2, 85, 63, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n+ 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 25, 75, 2, 2, 95, 70, 1.75f, 1.75f, 1.2f, 1.25f, 0.75f\n+ 4, 26, 76, 2, 2, 95.0f, 70.0f, 1.75f, 1.75f, 1.2f, 1.25f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 75, 92, 4, 4, 105, 77, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n+ 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 4, 1024, 100, 4, 4, 200, 200, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n}\n}};\n@@ -83,19 +83,19 @@ static const std::array<astcenc_preset_config, 5> preset_configs_high {{\nstatic const std::array<astcenc_preset_config, 5> preset_configs_mid {{\n{\nASTCENC_PRE_FASTEST,\n- 4, 2, 30, 1, 1, 79, 57, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 4, 4, 50, 2, 2, 85, 63, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n+ 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 25, 75, 2, 2, 95, 70, 1.75f, 1.75f, 1.2f, 1.25f, 0.75f\n+ 4, 26, 76, 2, 2, 95.0f, 70.0f, 1.75f, 1.75f, 1.2f, 1.25f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 75, 92, 4, 4, 105, 77, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n+ 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 4, 1024, 100, 4, 4, 200, 200, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n}\n}};\n@@ -106,19 +106,19 @@ static const std::array<astcenc_preset_config, 5> preset_configs_mid {{\nstatic const std::array<astcenc_preset_config, 5> preset_configs_low {{\n{\nASTCENC_PRE_FASTEST,\n- 4, 2, 30, 1, 1, 79, 57, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 4, 4, 50, 2, 2, 85, 63, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n+ 3, 10, 53, 3, 2, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 25, 75, 2, 2, 95, 70, 1.75f, 1.75f, 1.2f, 1.25f, 0.75f\n+ 3, 26, 76, 3, 2, 95.0f, 70.0f, 1.75f, 1.75f, 1.2f, 1.25f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 75, 92, 4, 4, 105, 77, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n+ 4, 75, 92, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 4, 1024, 100, 4, 4, 200, 200, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n}\n}};\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Tune presets to offset losses due to new heuristic
|
61,745 |
21.04.2021 22:34:18
| -3,600 |
0667b6828507af1dbf77bfd79ba7802b57368d88
|
Workaround some compiler variance issues
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenccli_error_metrics.cpp",
"new_path": "Source/astcenccli_error_metrics.cpp",
"diff": "@@ -166,7 +166,7 @@ void compute_error_metrics(\ndata8[(4 * xsize1 * y) + (4 * x + 2)],\ndata8[(4 * xsize1 * y) + (4 * x + 3)]);\n- color1 = color1 * (1.0f / 255.0f);\n+ color1 = color1 / 255.0f;\n}\nelse if (img1->data_type == ASTCENC_TYPE_F16)\n{\n@@ -205,7 +205,7 @@ void compute_error_metrics(\ndata8[(4 * xsize2 * y) + (4 * x + 2)],\ndata8[(4 * xsize2 * y) + (4 * x + 3)]);\n- color2 = color2 * (1.0f / 255.0f);\n+ color2 = color2 / 255.0f;\n}\nelse if (img2->data_type == ASTCENC_TYPE_F16)\n{\n@@ -237,7 +237,8 @@ void compute_error_metrics(\nrgb_peak = astc::max(color1.lane<0>(), color1.lane<1>(), color1.lane<2>(), rgb_peak);\nvfloat4 diffcolor = color1 - color2;\n- errorsum += diffcolor * diffcolor;\n+ vfloat4 diffcolor_sq = diffcolor * diffcolor;\n+ errorsum += diffcolor_sq;\nvfloat4 alpha_scaled_diffcolor = vfloat4(\ndiffcolor.lane<0>() * color1.lane<3>(),\n@@ -245,8 +246,8 @@ void compute_error_metrics(\ndiffcolor.lane<2>() * color1.lane<3>(),\ndiffcolor.lane<3>());\n- alpha_scaled_errorsum += alpha_scaled_diffcolor * \\\n- alpha_scaled_diffcolor;\n+ vfloat4 alpha_scaled_diffcolor_sq = alpha_scaled_diffcolor * alpha_scaled_diffcolor;\n+ alpha_scaled_errorsum += alpha_scaled_diffcolor_sq;\nif (compute_hdr_metrics)\n{\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Workaround some compiler variance issues
|
61,745 |
25.04.2021 21:28:29
| -3,600 |
fd8447eae95cdd34e80fd8d6991000a7ece395fd
|
Add sweep helper script.
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "Test/astc_image_sweep.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+A benchmarking sweep helper, which can genrate a performance-vs-quality sweep\n+for a single input images. Like other test functionality, this uses structured\n+image directory layouts for determining image settings to pass to the codec.\n+\"\"\"\n+\n+import argparse\n+import os\n+import platform\n+import sys\n+\n+import testlib.encoder as te\n+import testlib.image as ti\n+\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+ # All reference encoders\n+ parser.add_argument(\"--step\", dest=\"step\", default=\"10\", type=int, help=\"step size\")\n+ parser.add_argument(\"--repeats\", dest=\"repeats\", type=int, default=1, help=\"repeats\")\n+\n+ parser.add_argument(dest=\"image\", default=None,\n+ help=\"select the test image to run\")\n+\n+ args = parser.parse_args()\n+ return args\n+\n+\n+def main():\n+ \"\"\"\n+ The main function.\n+\n+ Returns:\n+ int: The process return code.\n+ \"\"\"\n+ # Parse command lines\n+ args = parse_command_line()\n+\n+ blockSizes = [\"4x4\", \"5x5\", \"6x6\", \"8x8\", \"10x10\"]\n+ repeats = max(args.repeats, 1)\n+ step = max(args.step, 1)\n+\n+ image = ti.TestImage(args.image)\n+ codec = te.Encoder2x(\"avx2\")\n+\n+ print(\"Block Size, Quality, PSNR (dB), Coding Time (s), Coding Rate (MT/s)\")\n+\n+ for blockSize in blockSizes:\n+ for quality in range(0, 101, args.step):\n+ localRepeats = repeats\n+ if quality < 20:\n+ localRepeats = localRepeats * 2\n+ if quality < 40:\n+ localRepeats = localRepeats * 2\n+\n+ results = codec.run_test(image, blockSize, f\"{quality}\", localRepeats, False)\n+ psnr = results[0]\n+ codingTime = results[2]\n+ mts = results[3]\n+\n+ print(f\"{blockSize}, {quality}, {psnr}, {codingTime}, {mts}\")\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 sweep helper script.
|
61,745 |
26.04.2021 21:53:12
| -3,600 |
d4db7655c4b011aefdec62ea6aeb547d2bd35490
|
Add heuristic for skipping two planes earlier
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc.h",
"new_path": "Source/astcenc.h",
"diff": "@@ -526,25 +526,32 @@ struct astcenc_config\nfloat tune_refinement_mse_overshoot;\n/**\n- * @brief The threshold for skipping 2.2/3.1/3.2/4.1 trials (-2partitionearlylimit).\n+ * @brief The threshold for skipping 2.2/3.1/3.2/4.1 trials (-2partitionlimitfactor).\n*\n* This option is further scaled for normal maps, so it skips less often.\n*/\n- float tune_2_partition_early_out_limit;\n+ float tune_2_partition_early_out_limit_factor;\n/**\n- * @brief The threshold for skipping 3.2/4.1 trials (-3partitionearlylimit).\n+ * @brief The threshold for skipping 3.2/4.1 trials (-3partitionlimitfactor).\n*\n* This option is further scaled for normal maps, so it skips less often.\n*/\n- float tune_3_partition_early_out_limit;\n+ float tune_3_partition_early_out_limit_factor;\n/**\n- * @brief The threshold for skipping 2 weight planess (-planecorlimit).\n+ * @brief The threshold for skipping two weight planes (-2planelimitfactor).\n*\n* This option is ineffective for normal maps.\n*/\n- float tune_two_plane_early_out_limit;\n+ float tune_2_plane_early_out_limit_factor;\n+\n+ /**\n+ * @brief The threshold for skipping two weight planes (-2planelimitcorrelation).\n+ *\n+ * This option is ineffective for normal maps.\n+ */\n+ float tune_2_plane_early_out_limit_correlation;\n#if defined(ASTCENC_DIAGNOSTICS)\n/**\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -1437,7 +1437,7 @@ void compress_block(\nlowest_correl = prepare_block_statistics(bsd->texel_count, blk, ewb);\n#endif\n- block_skip_two_plane = lowest_correl > ctx.config.tune_two_plane_early_out_limit;\n+ block_skip_two_plane = lowest_correl > ctx.config.tune_2_plane_early_out_limit_correlation;\n// next, test the four possible 1-partition, 2-planes modes\nfor (int i = 0; i < 4; i++)\n@@ -1449,7 +1449,7 @@ void compress_block(\nif (block_skip_two_plane)\n{\n- trace_add_data(\"skip\", \"tune_two_plane_early_out_limit\");\n+ trace_add_data(\"skip\", \"tune_2_plane_early_out_limit_correlation\");\ncontinue;\n}\n@@ -1475,6 +1475,8 @@ void compress_block(\ni, // the color component to test a separate plane of weights for.\nblk, ewb, scb, &tmpbuf->planes);\n+ best_errorvals_in_modes[MODE_1_1_PARTITION_2_PLANE_R + i] = errorval;\n+\n// Modes 7, 10 (13 is unreachable)\nif (errorval < error_threshold)\n{\n@@ -1522,25 +1524,30 @@ void compress_block(\nfloat best_1_partition_1_plane_result = best_errorvals_in_modes[MODE_0_1_PARTITION_1_PLANE];\n+ float best_1_partition_2_plane_result = astc::min(best_errorvals_in_modes[MODE_1_1_PARTITION_2_PLANE_R],\n+ best_errorvals_in_modes[MODE_1_1_PARTITION_2_PLANE_R],\n+ best_errorvals_in_modes[MODE_1_1_PARTITION_2_PLANE_R],\n+ best_errorvals_in_modes[MODE_1_1_PARTITION_2_PLANE_R]);\n+\nfloat best_2_partition_1_plane_result = astc::min(best_errorvals_in_modes[MODE_5_2_PARTITION_1_PLANE_UNCOR],\nbest_errorvals_in_modes[MODE_6_2_PARTITION_1_PLANE_COR]);\n+ float best_3_partition_1_plane_result = astc::min(best_errorvals_in_modes[MODE_8_3_PARTITION_1_PLANE_UNCOR],\n+ best_errorvals_in_modes[MODE_9_3_PARTITION_1_PLANE_COR]);\n+\n// If adding a second partition doesn't improve much over using one partition then skip more\n// thorough searches. This skips 2pt/2pl, 3pt/1pl, 3pt/2pl, 4pt/1pl.\n- if (partition_count == 2 && (best_2_partition_1_plane_result > (best_1_partition_1_plane_result * ctx.config.tune_2_partition_early_out_limit)))\n+ if (partition_count == 2 && (best_2_partition_1_plane_result > (best_1_partition_1_plane_result * ctx.config.tune_2_partition_early_out_limit_factor)))\n{\n- trace_add_data(\"skip\", \"tune_2_partition_early_out_limit\");\n+ trace_add_data(\"skip\", \"tune_2_partition_early_out_limit_factor\");\ngoto END_OF_TESTS;\n}\n// If adding a third partition doesn't improve much over using two partitions then skip more\n// thorough searches as it's not going to help. This skips 3pt/2pl, 4pt/1pl.\n- float best_3_partition_1_plane_result = astc::min(best_errorvals_in_modes[MODE_8_3_PARTITION_1_PLANE_UNCOR],\n- best_errorvals_in_modes[MODE_9_3_PARTITION_1_PLANE_COR]);\n-\n- if (partition_count == 3 && (best_3_partition_1_plane_result > (best_2_partition_1_plane_result * ctx.config.tune_3_partition_early_out_limit)))\n+ if (partition_count == 3 && (best_3_partition_1_plane_result > (best_2_partition_1_plane_result * ctx.config.tune_3_partition_early_out_limit_factor)))\n{\n- trace_add_data(\"skip\", \"tune_3_partition_early_out\");\n+ trace_add_data(\"skip\", \"tune_3_partition_early_out_limit_factor\");\ngoto END_OF_TESTS;\n}\n@@ -1561,10 +1568,19 @@ void compress_block(\n// * Blocks with higher component correlation than the tuning cutoff\nif (block_skip_two_plane)\n{\n- trace_add_data(\"skip\", \"tune_two_plane_early_out_limit\");\n+ trace_add_data(\"skip\", \"tune_2_plane_early_out_limit_correlation\");\ncontinue;\n}\n+ // If adding a 2nd plane to 1 partition doesn't help by some margin then trying with more\n+ // partitions is even less likely to help, so skip those. This is NOT exposed as a heuristic that the user can\n+ // control as we've found no need to - this is a very reliable heuristic even on torture\n+ // test images.\n+ if (best_1_partition_2_plane_result > best_1_partition_1_plane_result * ctx.config.tune_2_plane_early_out_limit_factor)\n+ {\n+ trace_add_data(\"skip\", \"tune_2_plane_early_out_limit_correlation_builtin\");\n+ continue;\n+ }\nTRACE_NODE(node1, \"pass\");\ntrace_add_data(\"partition_count\", partition_count);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -48,11 +48,13 @@ struct astcenc_preset_config {\nfloat tune_db_limit_b_base;\nfloat tune_mode0_mse_overshoot;\nfloat tune_refinement_mse_overshoot;\n- float tune_2_partition_early_out_limit;\n- float tune_3_partition_early_out_limit;\n- float tune_two_plane_early_out_limit;\n+ float tune_2_partition_early_out_limit_factor;\n+ float tune_3_partition_early_out_limit_factor;\n+ float tune_2_plane_early_out_limit_factor;\n+ float tune_2_plane_early_out_limit_correlation;\n};\n+\n/**\n* @brief The static quality presets that are built-in for high bandwidth\n* presets (x < 25 texels per block).\n@@ -60,22 +62,23 @@ struct astcenc_preset_config {\nstatic const std::array<astcenc_preset_config, 5> preset_configs_high {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.05f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n+ 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 1.05f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 2, 2, 95.0f, 70.0f, 1.75f, 1.75f, 1.2f, 1.25f, 0.75f\n+ 4, 26, 76, 2, 2, 95.0f, 70.0f, 1.75f, 1.75f, 1.2f, 1.25f, 1.05f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n+ 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 1.05f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n}\n}};\n+\n/**\n* @brief The static quality presets that are built-in for medium bandwidth\n* presets (25 <= x < 64 texels per block).\n@@ -83,22 +86,23 @@ static const std::array<astcenc_preset_config, 5> preset_configs_high {{\nstatic const std::array<astcenc_preset_config, 5> preset_configs_mid {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.05f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n+ 3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 1.05f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 2, 2, 95.0f, 70.0f, 1.75f, 1.75f, 1.2f, 1.25f, 0.75f\n+ 4, 26, 76, 2, 2, 95.0f, 70.0f, 1.75f, 1.75f, 1.2f, 1.25f, 1.05f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n+ 4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 1.05f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n}\n}};\n+\n/**\n* @brief The static quality presets that are built-in for low bandwidth\n* presets (64 <= x texels per block).\n@@ -106,19 +110,19 @@ static const std::array<astcenc_preset_config, 5> preset_configs_mid {{\nstatic const std::array<astcenc_preset_config, 5> preset_configs_low {{\n{\nASTCENC_PRE_FASTEST,\n- 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f\n+ 3, 2, 30, 1, 1, 79.0f, 57.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.05f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 3, 10, 53, 3, 2, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 0.5f\n+ 3, 10, 53, 3, 2, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 1.05f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 3, 26, 76, 3, 2, 95.0f, 70.0f, 1.75f, 1.75f, 1.2f, 1.25f, 0.75f\n+ 3, 26, 76, 3, 2, 95.0f, 70.0f, 1.75f, 1.75f, 1.2f, 1.25f, 1.05f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 4, 75, 92, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 0.95f\n+ 4, 75, 92, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 1.05f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200.0f, 200.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 0.99f\n}\n}};\n@@ -361,9 +365,10 @@ static astcenc_error validate_config(\nconfig.tune_db_limit = astc::max(config.tune_db_limit, 0.0f);\nconfig.tune_mode0_mse_overshoot = astc::max(config.tune_mode0_mse_overshoot, 1.0f);\nconfig.tune_refinement_mse_overshoot = astc::max(config.tune_refinement_mse_overshoot, 1.0f);\n- config.tune_2_partition_early_out_limit = astc::max(config.tune_2_partition_early_out_limit, 0.0f);\n- config.tune_3_partition_early_out_limit = astc::max(config.tune_3_partition_early_out_limit, 0.0f);\n- config.tune_two_plane_early_out_limit = astc::max(config.tune_two_plane_early_out_limit, 0.0f);\n+ config.tune_2_partition_early_out_limit_factor = astc::max(config.tune_2_partition_early_out_limit_factor, 0.0f);\n+ config.tune_3_partition_early_out_limit_factor = astc::max(config.tune_3_partition_early_out_limit_factor, 0.0f);\n+ config.tune_2_plane_early_out_limit_factor = astc::max(config.tune_2_plane_early_out_limit_factor, 0.0f);\n+ config.tune_2_plane_early_out_limit_correlation = astc::max(config.tune_2_plane_early_out_limit_correlation, 0.0f);\n// Specifying a zero weight color component is not allowed; force to small value\nfloat max_weight = astc::max(astc::max(config.cw_r_weight, config.cw_g_weight),\n@@ -468,9 +473,10 @@ astcenc_error astcenc_config_init(\nconfig.tune_mode0_mse_overshoot = (*preset_configs)[start].tune_mode0_mse_overshoot;\nconfig.tune_refinement_mse_overshoot = (*preset_configs)[start].tune_refinement_mse_overshoot;\n- config.tune_2_partition_early_out_limit = (*preset_configs)[start].tune_2_partition_early_out_limit;\n- config.tune_3_partition_early_out_limit =(*preset_configs)[start].tune_3_partition_early_out_limit;\n- config.tune_two_plane_early_out_limit = (*preset_configs)[start].tune_two_plane_early_out_limit;\n+ config.tune_2_partition_early_out_limit_factor = (*preset_configs)[start].tune_2_partition_early_out_limit_factor;\n+ config.tune_3_partition_early_out_limit_factor =(*preset_configs)[start].tune_3_partition_early_out_limit_factor;\n+ config.tune_2_plane_early_out_limit_factor = (*preset_configs)[start].tune_2_plane_early_out_limit_factor;\n+ config.tune_2_plane_early_out_limit_correlation = (*preset_configs)[start].tune_2_plane_early_out_limit_correlation;\n}\n// Start and end node are not the same - so interpolate between them\nelse\n@@ -503,9 +509,10 @@ astcenc_error astcenc_config_init(\nconfig.tune_mode0_mse_overshoot = LERP(tune_mode0_mse_overshoot);\nconfig.tune_refinement_mse_overshoot = LERP(tune_refinement_mse_overshoot);\n- config.tune_2_partition_early_out_limit = LERP(tune_2_partition_early_out_limit);\n- config.tune_3_partition_early_out_limit = LERP(tune_3_partition_early_out_limit);\n- config.tune_two_plane_early_out_limit = LERP(tune_two_plane_early_out_limit);\n+ config.tune_2_partition_early_out_limit_factor = LERP(tune_2_partition_early_out_limit_factor);\n+ config.tune_3_partition_early_out_limit_factor = LERP(tune_3_partition_early_out_limit_factor);\n+ config.tune_2_plane_early_out_limit_factor = LERP(tune_2_plane_early_out_limit_factor);\n+ config.tune_2_plane_early_out_limit_correlation = LERP(tune_2_plane_early_out_limit_correlation);\n#undef LERP\n#undef LERPI\n@@ -584,9 +591,9 @@ astcenc_error astcenc_config_init(\n{\nconfig.cw_g_weight = 0.0f;\nconfig.cw_b_weight = 0.0f;\n- config.tune_2_partition_early_out_limit *= 1.5f;\n- config.tune_3_partition_early_out_limit *= 1.5f;\n- config.tune_two_plane_early_out_limit = 0.99f;\n+ config.tune_2_partition_early_out_limit_factor *= 1.5f;\n+ config.tune_3_partition_early_out_limit_factor *= 1.5f;\n+ config.tune_2_plane_early_out_limit_correlation = 0.99f;\nif (flags & ASTCENC_FLG_USE_PERCEPTUAL)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenccli_toplevel.cpp",
"new_path": "Source/astcenccli_toplevel.cpp",
"diff": "@@ -872,38 +872,49 @@ static int edit_astcenc_config(\nconfig.tune_db_limit = static_cast<float>(atof(argv[argidx - 1]));\n}\n}\n- else if (!strcmp(argv[argidx], \"-2partitionearlylimit\"))\n+ else if (!strcmp(argv[argidx], \"-2partitionlimitfactor\"))\n{\nargidx += 2;\nif (argidx > argc)\n{\n- printf(\"ERROR: -2partitionearlylimit switch with no argument\\n\");\n+ printf(\"ERROR: -2partitionlimitfactor switch with no argument\\n\");\nreturn 1;\n}\n- config.tune_2_partition_early_out_limit = static_cast<float>(atof(argv[argidx - 1]));\n+ config.tune_2_partition_early_out_limit_factor = static_cast<float>(atof(argv[argidx - 1]));\n}\n- else if (!strcmp(argv[argidx], \"-3partitionearlylimit\"))\n+ else if (!strcmp(argv[argidx], \"-3partitionlimitfactor\"))\n{\nargidx += 2;\nif (argidx > argc)\n{\n- printf(\"ERROR: -3partitionearlylimit switch with no argument\\n\");\n+ printf(\"ERROR: -3partitionlimitfactor switch with no argument\\n\");\nreturn 1;\n}\n- config.tune_3_partition_early_out_limit = static_cast<float>(atof(argv[argidx - 1]));\n+ config.tune_3_partition_early_out_limit_factor = static_cast<float>(atof(argv[argidx - 1]));\n}\n- else if (!strcmp(argv[argidx], \"-planecorlimit\"))\n+ else if (!strcmp(argv[argidx], \"-2planelimitfactor\"))\n{\nargidx += 2;\nif (argidx > argc)\n{\n- printf(\"ERROR: -planecorlimit switch with no argument\\n\");\n+ printf(\"ERROR: -2planelimitfactor switch with no argument\\n\");\nreturn 1;\n}\n- config.tune_two_plane_early_out_limit = static_cast<float>(atof(argv[argidx - 1]));\n+ config.tune_2_plane_early_out_limit_factor = static_cast<float>(atof(argv[argidx - 1]));\n+ }\n+ else if (!strcmp(argv[argidx], \"-2planelimitcorrelation\"))\n+ {\n+ argidx += 2;\n+ if (argidx > argc)\n+ {\n+ printf(\"ERROR: -2planelimitcorrelation switch with no argument\\n\");\n+ return 1;\n+ }\n+\n+ config.tune_2_plane_early_out_limit_correlation = static_cast<float>(atof(argv[argidx - 1]));\n}\nelse if (!strcmp(argv[argidx], \"-refinementlimit\"))\n{\n@@ -1087,9 +1098,9 @@ static int edit_astcenc_config(\nprintf(\" Partition cutoff: %u partitions\\n\", config.tune_partition_count_limit);\nprintf(\" Partition index cutoff: %u partition ids\\n\", config.tune_partition_index_limit);\nprintf(\" PSNR cutoff: %g dB\\n\", (double)config.tune_db_limit);\n- printf(\" 2.2+ partition cutoff: %g\\n\", (double)config.tune_2_partition_early_out_limit);\n- printf(\" 3.2+ partition cutoff: %g\\n\", (double)config.tune_3_partition_early_out_limit);\n- printf(\" 2 plane correlation cutoff: %g\\n\", (double)config.tune_two_plane_early_out_limit);\n+ printf(\" 2.2+ partition cutoff: %g\\n\", (double)config.tune_2_partition_early_out_limit_factor);\n+ printf(\" 3.2+ partition cutoff: %g\\n\", (double)config.tune_3_partition_early_out_limit_factor);\n+ printf(\" 2 plane correlation cutoff: %g\\n\", (double)config.tune_2_plane_early_out_limit_correlation);\nprintf(\" Block mode centile cutoff: %g%%\\n\", (double)(config.tune_block_mode_limit));\nprintf(\" Max refinement cutoff: %u iterations\\n\", config.tune_refinement_limit);\nprintf(\" Compressor thread count: %d\\n\", cli_config.thread_count);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenccli_toplevel_help.cpp",
"new_path": "Source/astcenccli_toplevel_help.cpp",
"diff": "@@ -370,7 +370,7 @@ ADVANCED COMPRESSION\n-thorough : MAX(77-19*log10(N), 105-35*log10(N))\n-exhaustive : 999\n- -2partitionearlylimit <factor>\n+ -2partitionlimitfactor <factor>\nStop compression work on a block after only testing blocks with\nup to two partions and one plane of weights, unless the two\npartition error term is lower than the error term from encoding\n@@ -383,7 +383,7 @@ ADVANCED COMPRESSION\n-thorough : 2.50\n-exhaustive : 10.00\n- -3partitionearlylimit <factor>\n+ -3partitionlimitfactor <factor>\nStop compression work on a block after only testing blocks with\nup to three partions and one plane of weights, unless the three\npartition error term is lower than the error term from encoding\n@@ -396,7 +396,7 @@ ADVANCED COMPRESSION\n-thorough : 1.25\n-exhaustive : 10.00\n- -planecorlimit <factor>\n+ -2planelimitcorrelation <factor>\nStop compression after testing only one plane of weights, unless\nthe minimum color correlation factor between any pair of color\ncomponents is below this factor. This option is ineffective for\n"
},
{
"change_type": "MODIFY",
"old_path": "Test/astc_test_functional.py",
"new_path": "Test/astc_test_functional.py",
"diff": "@@ -1187,7 +1187,7 @@ class CLIPTest(CLITestBase):\nself.exec(command)\nrefRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n- command += [\"-2partitionearlylimit\", \"1.0\"]\n+ command += [\"-2partitionlimitfactor\", \"1.0\"]\nself.exec(command)\ntestRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n@@ -1209,16 +1209,16 @@ class CLIPTest(CLITestBase):\nself.exec(command)\nrefRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n- command += [\"-3partitionearlylimit\", \"0.5\"]\n+ command += [\"-3partitionlimitfactor\", \"0.5\"]\nself.exec(command)\ntestRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n# RMSE should get worse (higher) if we reduce search space\nself.assertGreater(testRMSE, refRMSE)\n- def test_dual_plane_correlation_limit(self):\n+ def test_2plane_correlation_limit(self):\n\"\"\"\n- Test dual plane correlation limit.\n+ Test 2 plane correlation limit.\n\"\"\"\ninputFile = \"./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png\"\ndecompFile = self.get_tmp_image_path(\"LDR\", \"decomp\")\n@@ -1231,7 +1231,7 @@ class CLIPTest(CLITestBase):\nself.exec(command)\nrefRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n- command += [\"-planecorlimit\", \"0.1\"]\n+ command += [\"-2planelimitcorrelation\", \"0.1\"]\nself.exec(command)\ntestRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n@@ -1974,7 +1974,7 @@ class CLINTest(CLITestBase):\ndef test_cl_2partitionearlylimit_missing_args(self):\n\"\"\"\n- Test -cl with -2partitionearlylimit and missing arguments.\n+ Test -cl with -2partitionlimitfactor and missing arguments.\n\"\"\"\n# Build a valid command\ncommand = [\n@@ -1982,14 +1982,14 @@ class CLINTest(CLITestBase):\nself.get_ref_image_path(\"LDR\", \"input\", \"A\"),\nself.get_tmp_image_path(\"LDR\", \"comp\"),\n\"4x4\", \"-fast\",\n- \"-2partitionearlylimit\", \"3\"]\n+ \"-2partitionlimitfactor\", \"3\"]\n# Run the command, incrementally omitting arguments\nself.exec_with_omit(command, 7)\ndef test_cl_3partitionearlylimit_missing_args(self):\n\"\"\"\n- Test -cl with -3partitionearlylimit and missing arguments.\n+ Test -cl with -3partitionlimitfactor and missing arguments.\n\"\"\"\n# Build a valid command\ncommand = [\n@@ -1997,14 +1997,14 @@ class CLINTest(CLITestBase):\nself.get_ref_image_path(\"LDR\", \"input\", \"A\"),\nself.get_tmp_image_path(\"LDR\", \"comp\"),\n\"4x4\", \"-fast\",\n- \"-3partitionearlylimit\", \"3\"]\n+ \"-3partitionlimitfactor\", \"3\"]\n# Run the command, incrementally omitting arguments\nself.exec_with_omit(command, 7)\n- def test_cl_planecorlimit_missing_args(self):\n+ def test_cl_2planeearlylimit_missing_args(self):\n\"\"\"\n- Test -cl with -planecorlimit and missing arguments.\n+ Test -cl with -2planelimitcorrelation and missing arguments.\n\"\"\"\n# Build a valid command\ncommand = [\n@@ -2012,7 +2012,7 @@ class CLINTest(CLITestBase):\nself.get_ref_image_path(\"LDR\", \"input\", \"A\"),\nself.get_tmp_image_path(\"LDR\", \"comp\"),\n\"4x4\", \"-fast\",\n- \"-planecorlimit\", \"0.66\"]\n+ \"-2planelimitcorrelation\", \"0.66\"]\n# Run the command, incrementally omitting arguments\nself.exec_with_omit(command, 7)\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add heuristic for skipping two planes earlier
|
61,745 |
26.04.2021 22:40:55
| -3,600 |
f481acea400704a16281ba2bbe474024098a5a76
|
Add help text for new option
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenccli_toplevel_help.cpp",
"new_path": "Source/astcenccli_toplevel_help.cpp",
"diff": "@@ -396,6 +396,18 @@ ADVANCED COMPRESSION\n-thorough : 1.25\n-exhaustive : 10.00\n+ -2planelimitfactor <factor>\n+ Skip encodings with two weight planes, unless the best one\n+ partition score using two weight planes is better than the\n+ best one partition score using one weight plane by this\n+ factor. Preset defaults are:\n+\n+ -fastest : 1.05\n+ -fast : 1.05\n+ -medium : 1.05\n+ -thorough : 1.05\n+ -exhaustive : 10.00\n+\n-2planelimitcorrelation <factor>\nStop compression after testing only one plane of weights, unless\nthe minimum color correlation factor between any pair of color\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add help text for new option
|
61,745 |
27.04.2021 10:21:51
| -3,600 |
788e108f9b3d0350b02a6f24380f226ac33788ab
|
Spend some performance to bump medium quality
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -68,7 +68,7 @@ static const std::array<astcenc_preset_config, 5> preset_configs_high {{\n3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 1.05f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 2, 2, 95.0f, 70.0f, 1.75f, 1.75f, 1.2f, 1.25f, 1.05f, 0.75f\n+ 4, 26, 76, 2, 2, 95.0f, 70.0f, 2.5f, 2.5f, 1.2f, 1.25f, 1.05f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 1.05f, 0.95f\n@@ -92,7 +92,7 @@ static const std::array<astcenc_preset_config, 5> preset_configs_mid {{\n3, 12, 55, 3, 2, 85.2f, 63.2f, 3.5f, 3.5f, 1.0f, 1.1f, 1.05f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 4, 26, 76, 2, 2, 95.0f, 70.0f, 1.75f, 1.75f, 1.2f, 1.25f, 1.05f, 0.75f\n+ 4, 26, 76, 2, 2, 95.0f, 70.0f, 3.0f, 3.0f, 1.2f, 1.25f, 1.05f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n4, 76, 93, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 1.05f, 0.95f\n@@ -116,7 +116,7 @@ static const std::array<astcenc_preset_config, 5> preset_configs_low {{\n3, 10, 53, 3, 2, 85.0f, 63.0f, 3.5f, 3.5f, 1.0f, 1.1f, 1.05f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 3, 26, 76, 3, 2, 95.0f, 70.0f, 1.75f, 1.75f, 1.2f, 1.25f, 1.05f, 0.75f\n+ 3, 26, 76, 3, 2, 95.0f, 70.0f, 3.5f, 3.5f, 1.2f, 1.25f, 1.05f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n4, 75, 92, 4, 4, 105.0f, 77.0f, 10.0f, 10.0f, 2.5f, 1.25f, 1.05f, 0.95f\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Spend some performance to bump medium quality
|
61,745 |
27.04.2021 11:46:31
| -3,600 |
db333171f67816c3c448df4461c6176552db8346
|
Add a main vs 1.7 plot
|
[
{
"change_type": "MODIFY",
"old_path": "Test/astc_test_result_plot.py",
"new_path": "Test/astc_test_result_plot.py",
"diff": "@@ -249,7 +249,7 @@ def main():\nint: The process return code.\n\"\"\"\n- absoluteXLimit = 35\n+ absoluteXLimit = 40\ncharts = [\n# --------------------------------------------------------\n@@ -320,6 +320,17 @@ def main():\n],\n# --------------------------------------------------------\n# Latest main vs last stable release charts\n+ [\n+ # Relative scores\n+ [\"thorough\", \"medium\", \"fast\"],\n+ [\"ref-main-avx2\"],\n+ [\"4x4\", \"6x6\", \"8x8\"],\n+ True,\n+ \"ref-1.7\",\n+ None,\n+ \"relative-main-vs-1.x.png\",\n+ (None, None)\n+ ],\n[\n# Relative scores\n[\"thorough\", \"medium\", \"fast\", \"fastest\"],\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add a main vs 1.7 plot
|
61,745 |
27.04.2021 23:37:38
| -3,600 |
3f710ff6511645aac5a09f0418f5b9fb896cc19e
|
Add promises to avoid loop preamble
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -214,6 +214,11 @@ static float compress_symbolic_block_fixed_partition_1_plane(\nsymbolic_compressed_block& scb,\ncompress_fixed_partition_buffers* tmpbuf\n) {\n+ promise(partition_count > 0);\n+ promise(tune_candidate_limit > 0);\n+ promise(max_refinement_iters > 0);\n+ promise(bsd->decimation_mode_count > 0);\n+\nstatic const int free_bits_for_partition_count[5] = {\n0, 115 - 4, 111 - 4 - PARTITION_BITS, 108 - 4 - PARTITION_BITS, 105 - 4 - PARTITION_BITS\n};\n@@ -358,7 +363,6 @@ static float compress_symbolic_block_fixed_partition_1_plane(\nTRACE_NODE(node0, \"candidate\");\nuint8_t *u8_weight_src;\n- int weights_to_copy;\nconst int qw_packed_index = quantized_weight[i];\nif (qw_packed_index < 0)\n@@ -373,8 +377,8 @@ static float compress_symbolic_block_fixed_partition_1_plane(\nint decimation_mode = qw_bm.decimation_mode;\nint weight_quant_mode = qw_bm.quant_mode;\nconst decimation_table *dt = dts[decimation_mode];\n+ promise(dt->weight_count > 0);\nu8_weight_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * qw_packed_index;\n- weights_to_copy = dt->weight_count;\ntrace_add_data(\"weight_x\", dt->weight_x);\ntrace_add_data(\"weight_y\", dt->weight_y);\n@@ -467,7 +471,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n// Pre-realign test\nif (l == 0)\n{\n- for (int j = 0; j < weights_to_copy; j++)\n+ for (int j = 0; j < dt->weight_count; j++)\n{\nworkscb.weights[j] = u8_weight_src[j];\n}\n@@ -514,7 +518,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\nu8_weight_src, nullptr);\n// Post-realign test\n- for (int j = 0; j < weights_to_copy; j++)\n+ for (int j = 0; j < dt->weight_count; j++)\n{\nworkscb.weights[j] = u8_weight_src[j];\n}\n@@ -575,6 +579,11 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nsymbolic_compressed_block& scb,\ncompress_fixed_partition_buffers* tmpbuf\n) {\n+ promise(partition_count > 0);\n+ promise(tune_candidate_limit > 0);\n+ promise(max_refinement_iters > 0);\n+ promise(bsd->decimation_mode_count > 0);\n+\nstatic const int free_bits_for_partition_count[5] = {\n0, 113 - 4, 109 - 4 - PARTITION_BITS, 106 - 4 - PARTITION_BITS, 103 - 4 - PARTITION_BITS\n};\n@@ -767,7 +776,6 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nuint8_t *u8_weight1_src;\nuint8_t *u8_weight2_src;\n- int weights_to_copy;\nassert(qw_packed_index >= 0 && qw_packed_index < bsd->block_mode_count);\nconst block_mode& qw_bm = bsd->block_modes[qw_packed_index];\n@@ -775,10 +783,10 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nint decimation_mode = qw_bm.decimation_mode;\nint weight_quant_mode = qw_bm.quant_mode;\nconst decimation_table *dt = dts[decimation_mode];\n+ promise(dt->weight_count > 0);\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 = dt->weight_count;\ntrace_add_data(\"weight_x\", dt->weight_x);\ntrace_add_data(\"weight_y\", dt->weight_y);\n@@ -867,7 +875,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n// Pre-realign test\nif (l == 0)\n{\n- for (int j = 0; j < weights_to_copy; j++)\n+ for (int j = 0; j < dt->weight_count; j++)\n{\nworkscb.weights[j] = u8_weight1_src[j];\nworkscb.weights[j + PLANE2_WEIGHTS_OFFSET] = u8_weight2_src[j];\n@@ -915,7 +923,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nu8_weight1_src, u8_weight2_src);\n// Post-realign test\n- for (int j = 0; j < weights_to_copy; j++)\n+ for (int j = 0; j < dt->weight_count; j++)\n{\nworkscb.weights[j] = u8_weight1_src[j];\nworkscb.weights[j + PLANE2_WEIGHTS_OFFSET] = u8_weight2_src[j];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add promises to avoid loop preamble
|
61,745 |
27.04.2021 23:40:40
| -3,600 |
6cb693b68116ac9bfe5c8162bb4609012ca431b2
|
Use existing vfloat4 error_weights
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -1251,7 +1251,7 @@ void recompute_ideal_colors_2planes(\nint tix = texel_indexes[j];\nvfloat4 rgba = blk->texel(tix);\n- vfloat4 error_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\n+ vfloat4 error_weight = ewb->error_weights[tix];\nrgba_sum += rgba * error_weight;\nrgba_weight_sum += error_weight;\n@@ -1290,7 +1290,7 @@ void recompute_ideal_colors_2planes(\nint tix = texel_indexes[j];\nvfloat4 rgba = blk->texel(tix);\n- vfloat4 color_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\n+ vfloat4 color_weight = ewb->error_weights[tix];\n// FIXME: move this calculation out to the color block.\nfloat ls_weight = hadd_rgb_s(color_weight);\n@@ -1553,7 +1553,7 @@ void recompute_ideal_colors_1plane(\nint tix = texel_indexes[j];\nvfloat4 rgba = blk->texel(tix);\n- vfloat4 error_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\n+ vfloat4 error_weight = ewb->error_weights[tix];\nrgba_sum += rgba * error_weight;\nrgba_weight_sum += error_weight;\n@@ -1586,7 +1586,7 @@ void recompute_ideal_colors_1plane(\nint tix = texel_indexes[j];\nvfloat4 rgba = blk->texel(tix);\n- vfloat4 color_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\n+ vfloat4 color_weight = ewb->error_weights[tix];\n// FIXME: move this calculation out to the color block.\nfloat ls_weight = hadd_rgb_s(color_weight);\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use existing vfloat4 error_weights
|
61,745 |
27.04.2021 23:45:45
| -3,600 |
bef49ea3a891aafdfb3f8dea7d4f55914ec42d22
|
texelcount/weightcount rename to {x}_count
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_block_sizes2.cpp",
"new_path": "Source/astcenc_block_sizes2.cpp",
"diff": "@@ -239,23 +239,23 @@ static void initialize_decimation_table_2d(\nint texels_per_block = xdim * ydim;\nint weights_per_block = x_weights * y_weights;\n- uint8_t weightcount_of_texel[MAX_TEXELS_PER_BLOCK];\n+ uint8_t weight_count_of_texel[MAX_TEXELS_PER_BLOCK];\nuint8_t grid_weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\nuint8_t weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\n- uint8_t texelcount_of_weight[MAX_WEIGHTS_PER_BLOCK];\n- uint8_t max_texelcount_of_weight = 0;\n+ uint8_t texel_count_of_weight[MAX_WEIGHTS_PER_BLOCK];\n+ uint8_t max_texel_count_of_weight = 0;\nuint8_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{\n- texelcount_of_weight[i] = 0;\n+ texel_count_of_weight[i] = 0;\n}\nfor (int i = 0; i < texels_per_block; i++)\n{\n- weightcount_of_texel[i] = 0;\n+ weight_count_of_texel[i] = 0;\n}\nfor (int y = 0; y < ydim; y++)\n@@ -290,13 +290,13 @@ static void initialize_decimation_table_2d(\n{\nif (weight[i] != 0)\n{\n- grid_weights_of_texel[texel][weightcount_of_texel[texel]] = qweight[i];\n- weights_of_texel[texel][weightcount_of_texel[texel]] = weight[i];\n- weightcount_of_texel[texel]++;\n- texels_of_weight[qweight[i]][texelcount_of_weight[qweight[i]]] = texel;\n- texelweights_of_weight[qweight[i]][texelcount_of_weight[qweight[i]]] = weight[i];\n- texelcount_of_weight[qweight[i]]++;\n- max_texelcount_of_weight = astc::max(max_texelcount_of_weight, texelcount_of_weight[qweight[i]]);\n+ grid_weights_of_texel[texel][weight_count_of_texel[texel]] = qweight[i];\n+ weights_of_texel[texel][weight_count_of_texel[texel]] = weight[i];\n+ weight_count_of_texel[texel]++;\n+ texels_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = texel;\n+ texelweights_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = weight[i];\n+ texel_count_of_weight[qweight[i]]++;\n+ max_texel_count_of_weight = astc::max(max_texel_count_of_weight, texel_count_of_weight[qweight[i]]);\n}\n}\n}\n@@ -304,9 +304,9 @@ static void initialize_decimation_table_2d(\nfor (int i = 0; i < texels_per_block; i++)\n{\n- dt->texel_weight_count[i] = weightcount_of_texel[i];\n+ dt->texel_weight_count[i] = weight_count_of_texel[i];\n- for (int j = 0; j < weightcount_of_texel[i]; j++)\n+ for (int j = 0; j < weight_count_of_texel[i]; j++)\n{\ndt->texel_weights_int_t4[i][j] = weights_of_texel[i][j];\ndt->texel_weights_t4[i][j] = grid_weights_of_texel[i][j];\n@@ -316,7 +316,7 @@ static void initialize_decimation_table_2d(\n}\n// Init all 4 entries so we can rely on zeros for vectorization\n- for (int j = weightcount_of_texel[i]; j < 4; j++)\n+ for (int j = weight_count_of_texel[i]; j < 4; j++)\n{\ndt->texel_weights_int_t4[i][j] = 0;\ndt->texel_weights_t4[i][j] = 0;\n@@ -328,7 +328,7 @@ static void initialize_decimation_table_2d(\nfor (int i = 0; i < weights_per_block; i++)\n{\n- int texel_count_wt = texelcount_of_weight[i];\n+ int texel_count_wt = texel_count_of_weight[i];\ndt->weight_texel_count[i] = (uint8_t)texel_count_wt;\nfor (int j = 0; j < texel_count_wt; j++)\n@@ -369,7 +369,7 @@ static void initialize_decimation_table_2d(\n// Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n// Match last texel in active lane in SIMD group, for better gathers\nuint8_t last_texel = dt->weight_texel[texel_count_wt - 1][i];\n- for (int j = texel_count_wt; j < max_texelcount_of_weight; j++)\n+ for (int j = texel_count_wt; j < max_texel_count_of_weight; j++)\n{\ndt->weight_texel[j][i] = last_texel;\ndt->weights_flt[j][i] = 0.0f;\n@@ -378,7 +378,7 @@ static void initialize_decimation_table_2d(\n// Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n// Match last texel in active lane in SIMD group, for better gathers\n- int last_texel_count_wt = texelcount_of_weight[weights_per_block - 1];\n+ int last_texel_count_wt = texel_count_of_weight[weights_per_block - 1];\nuint8_t last_texel = dt->weight_texel[last_texel_count_wt - 1][weights_per_block - 1];\nint weights_per_block_simd = round_up_to_simd_multiple_vla(weights_per_block);\n@@ -386,7 +386,7 @@ static void initialize_decimation_table_2d(\n{\ndt->weight_texel_count[i] = 0;\n- for (int j = 0; j < max_texelcount_of_weight; j++)\n+ for (int j = 0; j < max_texel_count_of_weight; j++)\n{\ndt->weight_texel[j][i] = last_texel;\ndt->weights_flt[j][i] = 0.0f;\n@@ -412,23 +412,23 @@ static void initialize_decimation_table_3d(\nint texels_per_block = xdim * ydim * zdim;\nint weights_per_block = x_weights * y_weights * z_weights;\n- uint8_t weightcount_of_texel[MAX_TEXELS_PER_BLOCK];\n+ uint8_t weight_count_of_texel[MAX_TEXELS_PER_BLOCK];\nuint8_t grid_weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\nuint8_t weights_of_texel[MAX_TEXELS_PER_BLOCK][4];\n- uint8_t texelcount_of_weight[MAX_WEIGHTS_PER_BLOCK];\n- uint8_t max_texelcount_of_weight = 0;\n+ uint8_t texel_count_of_weight[MAX_WEIGHTS_PER_BLOCK];\n+ uint8_t max_texel_count_of_weight = 0;\nuint8_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{\n- texelcount_of_weight[i] = 0;\n+ texel_count_of_weight[i] = 0;\n}\nfor (int i = 0; i < texels_per_block; i++)\n{\n- weightcount_of_texel[i] = 0;\n+ weight_count_of_texel[i] = 0;\n}\nfor (int z = 0; z < zdim; z++)\n@@ -535,13 +535,13 @@ static void initialize_decimation_table_3d(\n{\nif (weight[i] != 0)\n{\n- grid_weights_of_texel[texel][weightcount_of_texel[texel]] = qweight[i];\n- weights_of_texel[texel][weightcount_of_texel[texel]] = weight[i];\n- weightcount_of_texel[texel]++;\n- texels_of_weight[qweight[i]][texelcount_of_weight[qweight[i]]] = texel;\n- texelweights_of_weight[qweight[i]][texelcount_of_weight[qweight[i]]] = weight[i];\n- texelcount_of_weight[qweight[i]]++;\n- max_texelcount_of_weight = astc::max(max_texelcount_of_weight, texelcount_of_weight[qweight[i]]);\n+ grid_weights_of_texel[texel][weight_count_of_texel[texel]] = qweight[i];\n+ weights_of_texel[texel][weight_count_of_texel[texel]] = weight[i];\n+ weight_count_of_texel[texel]++;\n+ texels_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = texel;\n+ texelweights_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = weight[i];\n+ texel_count_of_weight[qweight[i]]++;\n+ max_texel_count_of_weight = astc::max(max_texel_count_of_weight, texel_count_of_weight[qweight[i]]);\n}\n}\n}\n@@ -550,7 +550,7 @@ static void initialize_decimation_table_3d(\nfor (int i = 0; i < texels_per_block; i++)\n{\n- dt->texel_weight_count[i] = weightcount_of_texel[i];\n+ dt->texel_weight_count[i] = weight_count_of_texel[i];\n// Init all 4 entries so we can rely on zeros for vectorization\nfor (int j = 0; j < 4; j++)\n@@ -562,7 +562,7 @@ static void initialize_decimation_table_3d(\ndt->texel_weights_4t[j][i] = 0;\n}\n- for (int j = 0; j < weightcount_of_texel[i]; j++)\n+ for (int j = 0; j < weight_count_of_texel[i]; j++)\n{\ndt->texel_weights_int_t4[i][j] = weights_of_texel[i][j];\ndt->texel_weights_t4[i][j] = grid_weights_of_texel[i][j];\n@@ -574,7 +574,7 @@ static void initialize_decimation_table_3d(\nfor (int i = 0; i < weights_per_block; i++)\n{\n- int texel_count_wt = texelcount_of_weight[i];\n+ int texel_count_wt = texel_count_of_weight[i];\ndt->weight_texel_count[i] = (uint8_t)texel_count_wt;\nfor (int j = 0; j < texel_count_wt; j++)\n@@ -614,7 +614,7 @@ static void initialize_decimation_table_3d(\n// Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n// TODO: Match an active lane in SIMD group, as better for gathers?\n- for (int j = texel_count_wt; j < max_texelcount_of_weight; j++)\n+ for (int j = texel_count_wt; j < max_texel_count_of_weight; j++)\n{\ndt->weight_texel[j][i] = 0;\ndt->weights_flt[j][i] = 0.0f;\n@@ -628,7 +628,7 @@ static void initialize_decimation_table_3d(\n{\ndt->weight_texel_count[i] = 0;\n- for (int j = 0; j < max_texelcount_of_weight; j++)\n+ for (int j = 0; j < max_texel_count_of_weight; j++)\n{\ndt->weight_texel[j][i] = 0;\ndt->weights_flt[j][i] = 0.0f;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -1211,9 +1211,9 @@ void recompute_ideal_colors_2planes(\nendpoints* ep, // contains the endpoints we wish to update\nvfloat4* rgbs_vectors, // used to return RGBS-vectors for endpoint mode #6\nvfloat4* rgbo_vectors, // used to return RGBO-vectors for endpoint mode #7\n- const uint8_t* weight_set8, // the current set of weight values\n- const uint8_t* plane2_weight_set8, // nullptr if plane 2 is not actually used.\n- int plane2_component, // color component for 2nd plane of weights; -1 if the 2nd plane of weights is not present\n+ const uint8_t* weight_set8_plane1, // Plane 1 weight set\n+ const uint8_t* weight_set8_plane2, // Plane 2 weight set\n+ int plane2_component, // Color component for 2nd plane of weights\nconst partition_info* pt,\nconst decimation_table* dt,\nconst imageblock* blk, // picture-block containing the actual data.\n@@ -1226,27 +1226,19 @@ void recompute_ideal_colors_2planes(\nfor (int i = 0; i < dt->weight_count; i++)\n{\n- weight_set[i] = qat->unquantized_value[weight_set8[i]] * (1.0f / 64.0f);\n- }\n-\n- if (plane2_weight_set8)\n- {\n- for (int i = 0; i < dt->weight_count; i++)\n- {\n- plane2_weight_set[i] = qat->unquantized_value[plane2_weight_set8[i]] * (1.0f / 64.0f);\n- }\n+ weight_set[i] = qat->unquantized_value[weight_set8_plane1[i]] * (1.0f / 64.0f);\n+ plane2_weight_set[i] = qat->unquantized_value[weight_set8_plane2[i]] * (1.0f / 64.0f);\n}\nint partition_count = pt->partition_count;\n-\nfor (int i = 0; i < partition_count; i++)\n{\nvfloat4 rgba_sum(1e-17f);\nvfloat4 rgba_weight_sum(1e-17f);\n- int texelcount = pt->partition_texel_count[i];\n+ int texel_count = pt->partition_texel_count[i];\nconst uint8_t *texel_indexes = pt->texels_of_partition[i];\n- for (int j = 0; j < texelcount; j++)\n+ for (int j = 0; j < texel_count; j++)\n{\nint tix = texel_indexes[j];\n@@ -1285,7 +1277,7 @@ void recompute_ideal_colors_2planes(\nfloat psum = 1e-17f;\n// FIXME: the loop below has too many responsibilities, making it inefficient.\n- for (int j = 0; j < texelcount; j++)\n+ for (int j = 0; j < texel_count; j++)\n{\nint tix = texel_indexes[j];\n@@ -1544,11 +1536,11 @@ void recompute_ideal_colors_1plane(\nvfloat4 rgba_sum(1e-17f);\nvfloat4 rgba_weight_sum(1e-17f);\n- int texelcount = pt->partition_texel_count[i];\n+ int texel_count = pt->partition_texel_count[i];\nconst uint8_t *texel_indexes = pt->texels_of_partition[i];\n- promise(texelcount > 0);\n- for (int j = 0; j < texelcount; j++)\n+ promise(texel_count > 0);\n+ for (int j = 0; j < texel_count; j++)\n{\nint tix = texel_indexes[j];\n@@ -1581,7 +1573,7 @@ void recompute_ideal_colors_1plane(\nfloat psum = 1e-17f;\n// FIXME: the loop below has too many responsibilities, making it inefficient.\n- for (int j = 0; j < texelcount; j++)\n+ for (int j = 0; j < texel_count; j++)\n{\nint tix = texel_indexes[j];\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1339,9 +1339,9 @@ void recompute_ideal_colors_2planes(\nendpoints* ep, // contains the endpoints we wish to update\nvfloat4* rgbs_vectors, // used to return RGBS-vectors for endpoint mode #6 (LDR RGB base + scale)\nvfloat4* rgbo_vectors, // used to return RGBS-vectors for endpoint mode #7 (HDR RGB base + scale)\n- const uint8_t* weight_set8, // the current set of weight values\n- const uint8_t* plane2_weight_set8, // nullptr if plane 2 is not actually used.\n- int plane2_component, // color component for 2nd plane of weights; -1 if the 2nd plane of weights is not present\n+ const uint8_t* weight_set8_plane1, // Plane 1 weight values\n+ const uint8_t* weight_set8_plane2, // Plane 2 weight values\n+ int plane2_component, // color component for 2nd plane of weights\nconst partition_info* pt,\nconst decimation_table* dt,\nconst imageblock* blk, // picture-block containing the actual data.\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
texelcount/weightcount rename to {x}_count
|
61,745 |
27.04.2021 23:46:45
| -3,600 |
3c9ae014e11a2876418c7ba8c6d35fb656e6a58d
|
texelweights -> texel_weights
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_block_sizes2.cpp",
"new_path": "Source/astcenc_block_sizes2.cpp",
"diff": "@@ -246,7 +246,7 @@ static void initialize_decimation_table_2d(\nuint8_t texel_count_of_weight[MAX_WEIGHTS_PER_BLOCK];\nuint8_t max_texel_count_of_weight = 0;\nuint8_t texels_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\n- int texelweights_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\n+ int texel_weights_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\nfor (int i = 0; i < weights_per_block; i++)\n{\n@@ -294,7 +294,7 @@ static void initialize_decimation_table_2d(\nweights_of_texel[texel][weight_count_of_texel[texel]] = weight[i];\nweight_count_of_texel[texel]++;\ntexels_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = texel;\n- texelweights_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = weight[i];\n+ texel_weights_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = weight[i];\ntexel_count_of_weight[qweight[i]]++;\nmax_texel_count_of_weight = astc::max(max_texel_count_of_weight, texel_count_of_weight[qweight[i]]);\n}\n@@ -337,7 +337,7 @@ static void initialize_decimation_table_2d(\n// Create transposed versions of these for better vectorization\ndt->weight_texel[j][i] = texel;\n- dt->weights_flt[j][i] = (float)texelweights_of_weight[i][j];\n+ dt->weights_flt[j][i] = (float)texel_weights_of_weight[i][j];\n// perform a layer of array unrolling. An aspect of this unrolling is that\n// one of the texel-weight indexes is an identity-mapped index; we will use this\n@@ -419,7 +419,7 @@ static void initialize_decimation_table_3d(\nuint8_t texel_count_of_weight[MAX_WEIGHTS_PER_BLOCK];\nuint8_t max_texel_count_of_weight = 0;\nuint8_t texels_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\n- int texelweights_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\n+ int texel_weights_of_weight[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK];\nfor (int i = 0; i < weights_per_block; i++)\n{\n@@ -539,7 +539,7 @@ static void initialize_decimation_table_3d(\nweights_of_texel[texel][weight_count_of_texel[texel]] = weight[i];\nweight_count_of_texel[texel]++;\ntexels_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = texel;\n- texelweights_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = weight[i];\n+ texel_weights_of_weight[qweight[i]][texel_count_of_weight[qweight[i]]] = weight[i];\ntexel_count_of_weight[qweight[i]]++;\nmax_texel_count_of_weight = astc::max(max_texel_count_of_weight, texel_count_of_weight[qweight[i]]);\n}\n@@ -583,7 +583,7 @@ static void initialize_decimation_table_3d(\n// Create transposed versions of these for better vectorization\ndt->weight_texel[j][i] = texel;\n- dt->weights_flt[j][i] = (float)texelweights_of_weight[i][j];\n+ dt->weights_flt[j][i] = (float)texel_weights_of_weight[i][j];\n// perform a layer of array unrolling. An aspect of this unrolling is that\n// one of the texel-weight indexes is an identity-mapped index; we will use this\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
texelweights -> texel_weights
|
61,745 |
28.04.2021 00:17:11
| -3,600 |
28f71b9899524375785823dbb438cc63038786f5
|
Add more promises to reduce loop preamble
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_find_best_partitioning.cpp",
"new_path": "Source/astcenc_find_best_partitioning.cpp",
"diff": "@@ -60,6 +60,7 @@ static void compute_partition_error_color_weightings_and_range(\npartition_metrics pm[4]\n) {\nint partition_count = pt.partition_count;\n+ promise(partition_count > 0);\nfor (int i = 0; i < partition_count; i++)\n{\n@@ -68,6 +69,8 @@ static void compute_partition_error_color_weightings_and_range(\nvfloat4 rgba_max(-1e38f);\nint texel_count = pt.partition_texel_count[i];\n+ promise(texel_count > 0);\n+\nfor (int j = 0; j < texel_count; j++)\n{\nint tidx = pt.texels_of_partition[i][j];\n@@ -97,12 +100,15 @@ void compute_partition_error_color_weightings(\npartition_metrics pm[4]\n) {\nint partition_count = pt.partition_count;\n+ promise(partition_count > 0);\nfor (int i = 0; i < partition_count; i++)\n{\nvfloat4 error_weight(1e-12f);\nint texel_count = pt.partition_texel_count[i];\n+ promise(texel_count > 0);\n+\nfor (int j = 0; j < texel_count; j++)\n{\nint tidx = pt.texels_of_partition[i][j];\n@@ -147,6 +153,9 @@ void find_best_partitionings(\nweight_imprecision_estim = 0.05f;\n}\n+ promise(partition_count > 0);\n+ promise(partition_search_limit > 0);\n+\nweight_imprecision_estim = weight_imprecision_estim * weight_imprecision_estim;\nint partition_sequence[PARTITION_COUNT];\n@@ -175,7 +184,6 @@ void find_best_partitionings(\nif (uses_alpha)\n{\n-\nfor (int i = 0; i < partition_search_limit; i++)\n{\nint partition = partition_sequence[i];\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -1095,6 +1095,7 @@ void compute_quantized_weights_for_decimation_table(\nint quant_level\n) {\nint weight_count = dt->weight_count;\n+ promise(weight_count > 0);\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[quant_level]);\nstatic const int quant_levels[12] { 2,3,4,5,6,8,10,12,16,20,24,32 };\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_weight_align.cpp",
"new_path": "Source/astcenc_weight_align.cpp",
"diff": "@@ -308,6 +308,7 @@ static void compute_angular_endpoints_for_quant_levels(\nbest_results[i] = select(result, prev_result, mask);\n}\n+ promise(max_quant_level >= 0);\nfor (int i = 0; i <= max_quant_level; i++)\n{\nint q = quantization_steps_for_level[i];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add more promises to reduce loop preamble
|
61,745 |
28.04.2021 00:22:15
| -3,600 |
e2ea7ac18c7ece53c32218fd4e0cd1df965d5398
|
Standardize on function postifx
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -200,7 +200,7 @@ static bool realign_weights(\n/*\nfunction for compressing a block symbolically, given that we have already decided on a partition\n*/\n-static float compress_symbolic_block_fixed_partition_1_plane(\n+static float compress_symbolic_block_fixed_partition_1plane(\nconst astcenc_config& config,\nbool only_always,\nint tune_candidate_limit,\n@@ -230,7 +230,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n// there is no quantization or decimation going on.\nendpoints_and_weights *ei = &tmpbuf->ei1;\nendpoints_and_weights *eix = tmpbuf->eix1;\n- compute_endpoints_and_ideal_weights_1_plane(bsd, pt, blk, ewb, ei);\n+ compute_endpoints_and_ideal_weights_1plane(bsd, pt, blk, ewb, ei);\n// next, compute ideal weights and endpoint colors for every decimation.\nconst decimation_table *const *dts = bsd->decimation_tables;\n@@ -565,7 +565,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\nreturn best_errorval_in_mode;\n}\n-static float compress_symbolic_block_fixed_partition_2_planes(\n+static float compress_symbolic_block_fixed_partition_2planes(\nconst astcenc_config& config,\nint tune_candidate_limit,\nfloat tune_errorval_threshold,\n@@ -596,7 +596,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nendpoints_and_weights *ei2 = &tmpbuf->ei2;\nendpoints_and_weights *eix1 = tmpbuf->eix1;\nendpoints_and_weights *eix2 = tmpbuf->eix2;\n- compute_endpoints_and_ideal_weights_2_planes(bsd, pt, blk, ewb, plane2_component, ei1, ei2);\n+ compute_endpoints_and_ideal_weights_2planes(bsd, pt, blk, ewb, plane2_component, ei1, ei2);\n// next, compute ideal weights and endpoint colors for every decimation.\nconst decimation_table *const *dts = bsd->decimation_tables;\n@@ -1424,7 +1424,7 @@ void compress_block(\ntrace_add_data(\"plane_count\", 1);\ntrace_add_data(\"search_mode\", i);\n- float errorval = compress_symbolic_block_fixed_partition_1_plane(\n+ float errorval = compress_symbolic_block_fixed_partition_1plane(\nctx.config, i == 0,\nctx.config.tune_candidate_limit,\nerror_threshold * errorval_mult[i] * errorval_overshoot,\n@@ -1472,7 +1472,7 @@ void compress_block(\ncontinue;\n}\n- float errorval = compress_symbolic_block_fixed_partition_2_planes(\n+ float errorval = compress_symbolic_block_fixed_partition_2planes(\nctx.config,\nctx.config.tune_candidate_limit,\nerror_threshold * errorval_overshoot,\n@@ -1512,7 +1512,7 @@ void compress_block(\ntrace_add_data(\"plane_count\", 1);\ntrace_add_data(\"search_mode\", i);\n- float errorval = compress_symbolic_block_fixed_partition_1_plane(\n+ float errorval = compress_symbolic_block_fixed_partition_1plane(\nctx.config, false,\nctx.config.tune_candidate_limit,\nerror_threshold * errorval_overshoot,\n@@ -1595,7 +1595,7 @@ void compress_block(\ntrace_add_data(\"plane_count\", 2);\ntrace_add_data(\"plane_component\", partition_index_2planes >> PARTITION_BITS);\n- float errorval = compress_symbolic_block_fixed_partition_2_planes(\n+ float errorval = compress_symbolic_block_fixed_partition_2planes(\nctx.config,\nctx.config.tune_candidate_limit,\nerror_threshold * errorval_overshoot,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_encoding_choice_error.cpp",
"new_path": "Source/astcenc_encoding_choice_error.cpp",
"diff": "@@ -174,13 +174,13 @@ void compute_encoding_choice_errors(\nif (plane2_component == -1)\n{\nendpoints_and_weights ei;\n- compute_endpoints_and_ideal_weights_1_plane(bsd, pt, blk, ewb, &ei);\n+ compute_endpoints_and_ideal_weights_1plane(bsd, pt, blk, ewb, &ei);\nep = ei.ep;\n}\nelse\n{\nendpoints_and_weights ei1, ei2;\n- compute_endpoints_and_ideal_weights_2_planes(bsd, pt, blk, ewb, plane2_component, &ei1, &ei2);\n+ compute_endpoints_and_ideal_weights_2planes(bsd, pt, blk, ewb, plane2_component, &ei1, &ei2);\nmerge_endpoints(&(ei1.ep), &(ei2.ep), plane2_component, &ep);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -644,7 +644,7 @@ static void compute_endpoints_and_ideal_weights_4_comp(\nThese data allow us to assess the error introduced by removing and quantizing the per-pixel weights.\n*/\n-void compute_endpoints_and_ideal_weights_1_plane(\n+void compute_endpoints_and_ideal_weights_1plane(\nconst block_size_descriptor* bsd,\nconst partition_info* pt,\nconst imageblock* blk,\n@@ -662,7 +662,7 @@ void compute_endpoints_and_ideal_weights_1_plane(\n}\n}\n-void compute_endpoints_and_ideal_weights_2_planes(\n+void compute_endpoints_and_ideal_weights_2planes(\nconst block_size_descriptor* bsd,\nconst partition_info* pt,\nconst imageblock* blk,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1112,14 +1112,14 @@ struct endpoints_and_weights\nalignas(ASTCENC_VECALIGN) float weight_error_scale[MAX_TEXELS_PER_BLOCK];\n};\n-void compute_endpoints_and_ideal_weights_1_plane(\n+void compute_endpoints_and_ideal_weights_1plane(\nconst block_size_descriptor* bsd,\nconst partition_info* pt,\nconst imageblock* blk,\nconst error_weight_block* ewb,\nendpoints_and_weights* ei);\n-void compute_endpoints_and_ideal_weights_2_planes(\n+void compute_endpoints_and_ideal_weights_2planes(\nconst block_size_descriptor* bsd,\nconst partition_info* pt,\nconst imageblock* blk,\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Standardize on function postifx
|
61,745 |
28.04.2021 00:23:37
| -3,600 |
7c8afa08e50c0448dc8cee8a950f938088f64493
|
Naming convention update
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_weight_align.cpp",
"new_path": "Source/astcenc_weight_align.cpp",
"diff": "@@ -148,7 +148,7 @@ static void compute_lowest_and_highest_weight(\nconst float* samples,\nconst float* sample_weights,\nint max_angular_steps,\n- int max_quantization_steps,\n+ int max_quant_steps,\nconst float* offsets,\nint* lowest_weight,\nint* weight_span,\n@@ -204,7 +204,7 @@ static void compute_lowest_and_highest_weight(\n// Write out min weight and weight span; clamp span to a usable range\nvint span = maxidx - minidx + vint(1);\n- span = min(span, vint(max_quantization_steps + 3));\n+ span = min(span, vint(max_quant_steps + 3));\nspan = max(span, vint(2));\nstorea(minidx, &lowest_weight[sp]);\nstorea(span, &weight_span[sp]);\n@@ -231,7 +231,7 @@ static void compute_angular_endpoints_for_quant_levels(\nfloat low_value[12],\nfloat high_value[12]\n) {\n- int max_quantization_steps = quantization_steps_for_level[max_quant_level];\n+ int max_quant_steps = quantization_steps_for_level[max_quant_level];\nalignas(ASTCENC_VECALIGN) float angular_offsets[ANGULAR_STEPS];\nint max_angular_steps = max_angular_steps_needed_for_quant_level[max_quant_level];\n@@ -244,7 +244,7 @@ static void compute_angular_endpoints_for_quant_levels(\nalignas(ASTCENC_VECALIGN) float cut_high_weight_error[ANGULAR_STEPS];\ncompute_lowest_and_highest_weight(samplecount, samples, sample_weights,\n- max_angular_steps, max_quantization_steps,\n+ max_angular_steps, max_quant_steps,\nangular_offsets, lowest_weight, weight_span, error,\ncut_low_weight_error, cut_high_weight_error);\n@@ -255,7 +255,7 @@ static void compute_angular_endpoints_for_quant_levels(\nvfloat4 best_results[40];\n// Initialize the array to some safe defaults\n- for (int i = 0; i < (max_quantization_steps + 4); i++)\n+ for (int i = 0; i < (max_quant_steps + 4); i++)\n{\n// Lane<0> = Best error\n// Lane<1> = Best scale; -1 indicates no solution found\n@@ -300,7 +300,7 @@ static void compute_angular_endpoints_for_quant_levels(\n// If we get a better error for lower sample count then use the lower\n// sample count's error for the higher sample count as well.\n- for (int i = 3; i <= max_quantization_steps; i++)\n+ for (int i = 3; i <= max_quant_steps; i++)\n{\nvfloat4 result = best_results[i];\nvfloat4 prev_result = best_results[i - 1];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Naming convention update
|
61,745 |
28.04.2021 00:24:17
| -3,600 |
f7dff7f53378d37fb6501dc4e3b48955df756732
|
samplecount -> sample_count
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_weight_align.cpp",
"new_path": "Source/astcenc_weight_align.cpp",
"diff": "@@ -144,7 +144,7 @@ static void compute_angular_offsets(\n// lowest and highest weight that results from quantizing using the stepsize & offset.\n// also, compute the resulting error.\nstatic void compute_lowest_and_highest_weight(\n- int samplecount,\n+ int sample_count,\nconst float* samples,\nconst float* sample_weights,\nint max_angular_steps,\n@@ -156,7 +156,7 @@ static void compute_lowest_and_highest_weight(\nfloat* cut_low_weight_error,\nfloat* cut_high_weight_error\n) {\n- promise(samplecount > 0);\n+ promise(sample_count > 0);\npromise(max_angular_steps > 0);\nvfloat rcp_stepsize = vfloat::lane_id() + vfloat(1.0f);\n@@ -171,7 +171,7 @@ static void compute_lowest_and_highest_weight(\nvfloat cut_high_weight_err = vfloat::zero();\nvfloat offset = loada(&offsets[sp]);\n- for (int j = 0; j < samplecount; ++j)\n+ for (int j = 0; j < sample_count; ++j)\n{\nvfloat wt = load1(&sample_weights[j]);\nvfloat sval = load1(&samples[j]) * rcp_stepsize - offset;\n@@ -224,7 +224,7 @@ static void compute_lowest_and_highest_weight(\n// main function for running the angular algorithm.\nstatic void compute_angular_endpoints_for_quant_levels(\n- int samplecount,\n+ int sample_count,\nconst float* samples,\nconst float* sample_weights,\nint max_quant_level,\n@@ -235,7 +235,7 @@ static void compute_angular_endpoints_for_quant_levels(\nalignas(ASTCENC_VECALIGN) float angular_offsets[ANGULAR_STEPS];\nint max_angular_steps = max_angular_steps_needed_for_quant_level[max_quant_level];\n- compute_angular_offsets(samplecount, samples, sample_weights, max_angular_steps, angular_offsets);\n+ compute_angular_offsets(sample_count, samples, sample_weights, max_angular_steps, angular_offsets);\nalignas(ASTCENC_VECALIGN) int32_t lowest_weight[ANGULAR_STEPS];\nalignas(ASTCENC_VECALIGN) int32_t weight_span[ANGULAR_STEPS];\n@@ -243,7 +243,7 @@ static void compute_angular_endpoints_for_quant_levels(\nalignas(ASTCENC_VECALIGN) float cut_low_weight_error[ANGULAR_STEPS];\nalignas(ASTCENC_VECALIGN) float cut_high_weight_error[ANGULAR_STEPS];\n- compute_lowest_and_highest_weight(samplecount, samples, sample_weights,\n+ compute_lowest_and_highest_weight(sample_count, samples, sample_weights,\nmax_angular_steps, max_quant_steps,\nangular_offsets, lowest_weight, weight_span, error,\ncut_low_weight_error, cut_high_weight_error);\n@@ -359,9 +359,9 @@ void compute_angular_endpoints_1plane(\ncontinue;\n}\n- int samplecount = bsd->decimation_tables[i]->weight_count;\n+ int sample_count = bsd->decimation_tables[i]->weight_count;\ncompute_angular_endpoints_for_quant_levels(\n- samplecount,\n+ sample_count,\ndecimated_quantized_weights + i * MAX_WEIGHTS_PER_BLOCK,\ndecimated_weights + i * MAX_WEIGHTS_PER_BLOCK,\ndm.maxprec_1plane, low_values[i], high_values[i]);\n@@ -407,16 +407,16 @@ void compute_angular_endpoints_2planes(\ncontinue;\n}\n- int samplecount = bsd->decimation_tables[i]->weight_count;\n+ int sample_count = bsd->decimation_tables[i]->weight_count;\ncompute_angular_endpoints_for_quant_levels(\n- samplecount,\n+ sample_count,\ndecimated_quantized_weights + 2 * i * MAX_WEIGHTS_PER_BLOCK,\ndecimated_weights + 2 * i * MAX_WEIGHTS_PER_BLOCK,\ndm.maxprec_2planes, low_values1[i], high_values1[i]);\ncompute_angular_endpoints_for_quant_levels(\n- samplecount,\n+ sample_count,\ndecimated_quantized_weights + (2 * i + 1) * MAX_WEIGHTS_PER_BLOCK,\ndecimated_weights + (2 * i + 1) * MAX_WEIGHTS_PER_BLOCK,\ndm.maxprec_2planes, low_values2[i], high_values2[i]);\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
samplecount -> sample_count
|
61,745 |
28.04.2021 23:02:53
| -3,600 |
74d623a9a841e51117040358ac9169bb18224d36
|
Remove NaN traps; replaced with diagnostic trace
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_averages_and_directions.cpp",
"new_path": "Source/astcenc_averages_and_directions.cpp",
"diff": "#include <cassert>\n-#ifdef DEBUG_CAPTURE_NAN\n- #ifndef _GNU_SOURCE\n- #define _GNU_SOURCE\n- #endif\n-\n- #include <fenv.h>\n-#endif\n-\n// For a full block, functions to compute averages and dominant directions. The\n// averages and directions are computed separately for each partition.\n// We have separate versions for blocks with and without alpha, since the\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "#include <cstring>\n#include <cstdio>\n-#ifdef DEBUG_CAPTURE_NAN\n- #ifndef _GNU_SOURCE\n- #define _GNU_SOURCE\n- #endif\n-\n- #include <fenv.h>\n-#endif\n-\n/**\n* @brief Attempt to improve weights given a chosen configuration.\n*\n@@ -264,18 +256,10 @@ static float compress_symbolic_block_fixed_partition_1plane(\nvfloat4 min_ep(10.0f);\nfor (int i = 0; i < partition_count; i++)\n{\n- #ifdef DEBUG_CAPTURE_NAN\n- fedisableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\nvfloat4 ep = (vfloat4(1.0f) - ei->ep.endpt0[i]) / (ei->ep.endpt1[i] - ei->ep.endpt0[i]);\nvmask4 use_ep = (ep > vfloat4(0.5f)) & (ep < min_ep);\nmin_ep = select(min_ep, ep, use_ep);\n-\n- #ifdef DEBUG_CAPTURE_NAN\n- feenableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n}\nfloat min_wt_cutoff = hmin_s(min_ep);\n@@ -638,10 +622,6 @@ static float compress_symbolic_block_fixed_partition_2planes(\nvfloat4 min_ep2(10.0f);\nfor (int i = 0; i < partition_count; i++)\n{\n- #ifdef DEBUG_CAPTURE_NAN\n- fedisableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\nvfloat4 ep1 = (vfloat4(1.0f) - ei1->ep.endpt0[i]) / (ei1->ep.endpt1[i] - ei1->ep.endpt0[i]);\nvmask4 use_ep1 = (ep1 > vfloat4(0.5f)) & (ep1 < min_ep1);\nmin_ep1 = select(min_ep1, ep1, use_ep1);\n@@ -649,10 +629,6 @@ static float compress_symbolic_block_fixed_partition_2planes(\nvfloat4 ep2 = (vfloat4(1.0f) - ei2->ep.endpt0[i]) / (ei2->ep.endpt1[i] - ei2->ep.endpt0[i]);\nvmask4 use_ep2 = (ep2 > vfloat4(0.5f)) & (ep2 < min_ep2);\nmin_ep2 = select(min_ep2, ep2, use_ep2);\n-\n- #ifdef DEBUG_CAPTURE_NAN\n- feenableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n}\nvfloat4 err_max(1e30f);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "#include \"astcenc_internal.h\"\n#include \"astcenc_vecmathlib.h\"\n-#ifdef DEBUG_CAPTURE_NAN\n- #ifndef _GNU_SOURCE\n- #define _GNU_SOURCE\n- #endif\n-\n- #include <fenv.h>\n-#endif\n-\nstatic void compute_endpoints_and_ideal_weights_1_comp(\nconst block_size_descriptor* bsd,\nconst partition_info* pt,\n@@ -1196,10 +1188,6 @@ static inline vfloat4 compute_rgbovec(\nvfloat4 mat3(mZYP, mZQX, mRYX, Z * YX);\nvfloat4 vect = rgbq_sum * rdet;\n- #ifdef DEBUG_CAPTURE_NAN\n- fedisableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\nreturn vfloat4(dot_s(mat0, vect),\ndot_s(mat1, vect),\ndot_s(mat2, vect),\n@@ -1348,10 +1336,6 @@ void recompute_ideal_colors_2planes(\nvfloat4 rgbq_sum = color_vec_x + color_vec_y;\nrgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));\n- #ifdef DEBUG_CAPTURE_NAN\n- fedisableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\nvfloat4 rgbovec = compute_rgbovec(rgba_weight_sum, weight_weight_sum,\nrgbq_sum, psum);\nrgbo_vectors[i] = rgbovec;\n@@ -1365,17 +1349,9 @@ void recompute_ideal_colors_2planes(\n// Initialize the luminance and scale vectors with a reasonable\n// default, just in case the subsequent calculation blows up.\n- #ifdef DEBUG_CAPTURE_NAN\n- fedisableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\nfloat scalediv = scale_min * (1.0f / astc::max(scale_max, 1e-10f));\nscalediv = astc::clamp1f(scalediv);\n- #ifdef DEBUG_CAPTURE_NAN\n- feenableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\nvfloat4 sds = scale_direction * scale_max;\nrgbs_vectors[i] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), scalediv);\n@@ -1399,11 +1375,6 @@ void recompute_ideal_colors_2planes(\n{\n// otherwise, complete the analytic calculation of ideal-endpoint-values\n// for the given set of texel weights and pixel colors.\n-\n- #ifdef DEBUG_CAPTURE_NAN\n- fedisableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\nvfloat4 color_det1 = (left_sum * right_sum) - (middle_sum * middle_sum);\nvfloat4 color_rdet1 = 1.0f / color_det1;\n@@ -1438,10 +1409,6 @@ void recompute_ideal_colors_2planes(\nvfloat4 sdsm = scale_direction * scale_ep1;\nrgbs_vectors[i] = vfloat4(sdsm.lane<0>(), sdsm.lane<1>(), sdsm.lane<2>(), scalediv2);\n}\n-\n- #ifdef DEBUG_CAPTURE_NAN\n- feenableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n}\nif (wmin2 >= wmax2 * 0.999f)\n@@ -1459,10 +1426,6 @@ void recompute_ideal_colors_2planes(\n}\nelse\n{\n- #ifdef DEBUG_CAPTURE_NAN\n- fedisableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\n// otherwise, complete the analytic calculation of ideal-endpoint-values\n// for the given set of texel weights and pixel colors.\nvfloat4 color_det2 = (left2_sum * right2_sum) - (middle2_sum * middle2_sum);\n@@ -1482,10 +1445,6 @@ void recompute_ideal_colors_2planes(\nep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);\nep->endpt1[i] = select(ep->endpt1[i], ep1, full_mask);\n-\n- #ifdef DEBUG_CAPTURE_NAN\n- feenableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n}\n// if the calculation of an RGB-offset vector failed, try to compute\n@@ -1624,10 +1583,6 @@ void recompute_ideal_colors_1plane(\nvfloat4 rgbq_sum = color_vec_x + color_vec_y;\nrgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));\n- #ifdef DEBUG_CAPTURE_NAN\n- fedisableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\nvfloat4 rgbovec = compute_rgbovec(rgba_weight_sum, weight_weight_sum,\nrgbq_sum, psum);\nrgbo_vectors[i] = rgbovec;\n@@ -1641,17 +1596,9 @@ void recompute_ideal_colors_1plane(\n// Initialize the luminance and scale vectors with a reasonable\n// default, just in case the subsequent calculation blows up.\n- #ifdef DEBUG_CAPTURE_NAN\n- fedisableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\nfloat scalediv = scale_min * (1.0f / astc::max(scale_max, 1e-10f));\nscalediv = astc::clamp1f(scalediv);\n- #ifdef DEBUG_CAPTURE_NAN\n- feenableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\nvfloat4 sds = scale_direction * scale_max;\nrgbs_vectors[i] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), scalediv);\n@@ -1672,11 +1619,6 @@ void recompute_ideal_colors_1plane(\n{\n// otherwise, complete the analytic calculation of ideal-endpoint-values\n// for the given set of texel weights and pixel colors.\n-\n- #ifdef DEBUG_CAPTURE_NAN\n- fedisableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\nvfloat4 color_det1 = (left_sum * right_sum) - (middle_sum * middle_sum);\nvfloat4 color_rdet1 = 1.0f / color_det1;\n@@ -1710,10 +1652,6 @@ void recompute_ideal_colors_1plane(\nvfloat4 sdsm = scale_direction * scale_ep1;\nrgbs_vectors[i] = vfloat4(sdsm.lane<0>(), sdsm.lane<1>(), sdsm.lane<2>(), scalediv2);\n}\n-\n- #ifdef DEBUG_CAPTURE_NAN\n- feenableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n}\n// if the calculation of an RGB-offset vector failed, try to compute\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -117,13 +117,6 @@ static const unsigned int TUNE_MAX_TEXELS_MODE0_FASTPATH { 24 };\n// Default: depends on quality preset\nstatic const unsigned int TUNE_MAX_TRIAL_CANDIDATES { 4 };\n-/* ============================================================================\n- Other configuration parameters\n-============================================================================ */\n-\n-// Uncomment to enable checking for inappropriate NaNs; Linux only, and slow!\n-// #define DEBUG_CAPTURE_NAN\n-\n/* ============================================================================\nParallel execution control\n============================================================================ */\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenccli_toplevel.cpp",
"new_path": "Source/astcenccli_toplevel.cpp",
"diff": "@@ -1337,10 +1337,6 @@ int main(\n) {\ndouble start_time = get_time();\n- #ifdef DEBUG_CAPTURE_NAN\n- feenableexcept(FE_DIVBYZERO | FE_INVALID);\n- #endif\n-\nif (argc < 2)\n{\nastcenc_print_shorthelp();\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Remove NaN traps; replaced with diagnostic trace
|
61,745 |
29.04.2021 23:23:25
| -3,600 |
5540ff9c2e94301060f34721adc9e8b24c92531d
|
Use vfloat4 not float2
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_averages_and_directions.cpp",
"new_path": "Source/astcenc_averages_and_directions.cpp",
"diff": "@@ -348,8 +348,8 @@ void compute_avgs_and_dirs_2_comp(\n{\nconst uint8_t *weights = pt->texels_of_partition[partition];\n- float2 error_sum = float2(0.0f);\n- float2 base_sum = float2(0.0f);\n+ vfloat4 error_sum = vfloat4::zero();\n+ vfloat4 base_sum = vfloat4::zero();\nfloat partition_weight = 0.0f;\nint texel_count = pt->partition_texel_count[partition];\n@@ -359,51 +359,48 @@ void compute_avgs_and_dirs_2_comp(\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n- float2 texel_datum = float2(data_vr[iwt], data_vg[iwt]) * weight;\n+ vfloat4 texel_datum = vfloat4(data_vr[iwt], data_vg[iwt], 0.0f, 0.0f) * weight;\n- float2 error_weight = float2(error_vr[iwt], error_vg[iwt]);\n+ vfloat4 error_weight = vfloat4(error_vr[iwt], error_vg[iwt], 0.0f, 0.0f);\npartition_weight += weight;\nbase_sum += texel_datum;\nerror_sum += error_weight;\n}\n- vfloat4 error_sum4 = vfloat4(error_sum.r, error_sum.g, 0.0f, 0.0f) * (1.0f / texel_count);\n- vfloat4 csf = normalize(sqrt(error_sum4)) * 1.41421356f;\n- vfloat4 average4 = vfloat4(base_sum.r, base_sum.g, 0.0f, 0.0f) * (1.0f / astc::max(partition_weight, 1e-7f));\n+ error_sum = error_sum / texel_count;\n+ vfloat4 csf = normalize(sqrt(error_sum)) * 1.41421356f;\n+ vfloat4 average = base_sum * (1.0f / astc::max(partition_weight, 1e-7f));\n- pm[partition].error_weight = error_sum4;\n- pm[partition].avg = average4 * csf;\n- float2 average = float2(average4.lane<0>(), average4.lane<1>());\n+ pm[partition].error_weight = error_sum;\n+ pm[partition].avg = average * csf;\npm[partition].color_scale = csf;\npm[partition].icolor_scale = 1.0f / max(csf, 1e-7f);\n- float2 sum_xp = float2(0.0f);\n- float2 sum_yp = float2(0.0f);\n+ vfloat4 sum_xp = vfloat4::zero();\n+ vfloat4 sum_yp = vfloat4::zero();\nfor (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n- float2 texel_datum = float2(data_vr[iwt], data_vg[iwt]);\n+ vfloat4 texel_datum = vfloat4(data_vr[iwt], data_vg[iwt], 0.0f, 0.0f);\ntexel_datum = (texel_datum - average) * weight;\n- if (texel_datum.r > 0.0f)\n- {\n- sum_xp += texel_datum;\n- }\n+ vfloat4 zero = vfloat4::zero();\n- if (texel_datum.g > 0.0f)\n- {\n- sum_yp += texel_datum;\n- }\n+ vmask4 tdm0 = vfloat4(texel_datum.lane<0>()) > zero;\n+ sum_xp += select(zero, texel_datum, tdm0);\n+\n+ vmask4 tdm1 = vfloat4(texel_datum.lane<1>()) > zero;\n+ sum_yp += select(zero, texel_datum, tdm1);\n}\n- float prod_xp = dot(sum_xp, sum_xp);\n- float prod_yp = dot(sum_yp, sum_yp);\n+ float prod_xp = dot_s(sum_xp, sum_xp);\n+ float prod_yp = dot_s(sum_yp, sum_yp);\n- float2 best_vector = sum_xp;\n+ vfloat4 best_vector = sum_xp;\nfloat best_sum = prod_xp;\nif (prod_yp > best_sum)\n@@ -411,7 +408,7 @@ void compute_avgs_and_dirs_2_comp(\nbest_vector = sum_yp;\n}\n- pm[partition].dir = vfloat4(best_vector.r, best_vector.g, 0.0f, 0.0f);\n+ pm[partition].dir = best_vector;\n}\n}\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use vfloat4 not float2
|
61,745 |
30.04.2021 00:01:54
| -3,600 |
3c295d6c2c5139411329c7a3e8241053c651e3bb
|
Load vector form of ewb->error_weights
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -155,8 +155,7 @@ static bool realign_weights(\nvfloat4 color = color_base + color_offset * plane_weight;\nvfloat4 origcolor = blk->texel(texel);\n- vfloat4 error_weight = vfloat4(ewb->texel_weight_r[texel], ewb->texel_weight_g[texel],\n- ewb->texel_weight_b[texel], ewb->texel_weight_a[texel]);\n+ vfloat4 error_weight = ewb->error_weights[texel];\nvfloat4 colordiff = color - origcolor;\nvfloat4 color_up_diff = colordiff + color_offset * plane_up_weight;\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Load vector form of ewb->error_weights
|
61,745 |
30.04.2021 09:45:03
| -3,600 |
002103bfe2c3c1fc1e3f8be219a07d387b99f61c
|
Inline computation of derivatives
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -991,13 +991,17 @@ static float prepare_error_weight_block(\nctx.config.v_rgb_mean != 0.0f || ctx.config.v_rgb_stdev != 0.0f || \\\nctx.config.v_a_mean != 0.0f || ctx.config.v_a_stdev != 0.0f;\n- vfloat4 derv[MAX_TEXELS_PER_BLOCK];\n- imageblock_initialize_deriv(blk, bsd->texel_count, derv);\nvfloat4 color_weights(ctx.config.cw_r_weight,\nctx.config.cw_g_weight,\nctx.config.cw_b_weight,\nctx.config.cw_a_weight);\n+ // This works because HDR is imposed globally at compression time\n+ int rgb_lns = blk->rgb_lns[0];\n+ int a_lns = blk->alpha_lns[0];\n+ vint4 use_lns(rgb_lns, rgb_lns, rgb_lns, a_lns);\n+ vmask4 lns_mask = use_lns != vint4::zero();\n+\nfor (int z = 0; z < bsd->zdim; z++)\n{\nfor (int y = 0; y < bsd->ydim; y++)\n@@ -1014,6 +1018,34 @@ static float prepare_error_weight_block(\n}\nelse\n{\n+ vfloat4 derv(65535.0f);\n+\n+ // Compute derivative if we have any use of LNS\n+ if (any(lns_mask))\n+ {\n+ // TODO: Can we avoid some of the multi-type translation?\n+ vfloat4 data = blk->texel(idx);\n+ vint4 datai = lns_to_sf16(float_to_int(data));\n+\n+ vfloat4 dataf = float16_to_float(datai);\n+ dataf = max(dataf, 6e-5f);\n+\n+ vfloat4 data_lns1 = dataf * 1.05f;\n+ data_lns1 = float_to_lns(data_lns1);\n+\n+ vfloat4 data_lns2 = dataf;\n+ data_lns2 = float_to_lns(data_lns2);\n+\n+ vfloat4 divisor_lns = dataf * 0.05f;\n+\n+ // Clamp derivatives between 1/32 and 2^25\n+ float lo = 1.0f / 32.0f;\n+ float hi = 33554432.0f;\n+ vfloat4 derv_lns = clamp(lo, hi, (data_lns1 - data_lns2) / divisor_lns);\n+ derv = select(derv, derv_lns, lns_mask);\n+ }\n+\n+ // Compute error weight\nvfloat4 error_weight(ctx.config.v_rgb_base,\nctx.config.v_rgb_base,\nctx.config.v_rgb_base,\n@@ -1099,7 +1131,7 @@ static float prepare_error_weight_block(\n// which is equivalent to dividing by the derivative of the transfer\n// function.\n- error_weight = error_weight / (derv[idx] * derv[idx] * 1e-10f);\n+ error_weight = error_weight / (derv * derv * 1e-10f);\newb->error_weights[idx] = error_weight;\n}\nidx++;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_image.cpp",
"new_path": "Source/astcenc_image.cpp",
"diff": "#include \"astcenc_internal.h\"\n-void imageblock_initialize_deriv(\n- const imageblock* blk,\n- int pixelcount,\n- vfloat4* dptr\n-) {\n- // TODO: For LDR on the current codec we can skip this if no LNS and just\n- // early-out as we use the same LNS settings everywhere ...\n- for (int i = 0; i < pixelcount; i++)\n- {\n- vfloat4 derv_unorm(65535.0f);\n- vfloat4 derv_lns = vfloat4::zero();\n-\n- // TODO: Pack these into bits and avoid the disjoint fetch\n- int rgb_lns = blk->rgb_lns[i];\n- int a_lns = blk->alpha_lns[i];\n-\n- // Compute derivatives if we have any use of LNS\n- if (rgb_lns || a_lns)\n- {\n- vfloat4 data = blk->texel(i);\n- vint4 datai = lns_to_sf16(float_to_int(data));\n-\n- vfloat4 dataf = float16_to_float(datai);\n- dataf = max(dataf, 6e-5f);\n-\n- vfloat4 data_lns1 = dataf * 1.05f;\n- data_lns1 = float_to_lns(data_lns1);\n-\n- vfloat4 data_lns2 = dataf;\n- data_lns2 = float_to_lns(data_lns2);\n-\n- vfloat4 divisor_lns = dataf * 0.05f;\n-\n- // Clamp derivatives between 1/32 and 2^25\n- float lo = 1.0f / 32.0f;\n- float hi = 33554432.0f;\n- derv_lns = clamp(lo, hi, (data_lns1 - data_lns2) / divisor_lns);\n- }\n-\n- vint4 use_lns(rgb_lns, rgb_lns, rgb_lns, a_lns);\n- vmask4 lns_mask = use_lns != vint4::zero();\n- *dptr = select(derv_unorm, derv_lns, lns_mask);\n- dptr++;\n- }\n-}\n-\n// helper function to initialize the work-data from the orig-data\nstatic void imageblock_initialize_work_from_orig(\nimageblock* blk,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1344,11 +1344,6 @@ void expand_deblock_weights(\n// functions pertaining to weight alignment\nvoid prepare_angular_tables();\n-void imageblock_initialize_deriv(\n- const imageblock* blk,\n- int pixelcount,\n- vfloat4* dptr);\n-\nvoid compute_angular_endpoints_1plane(\nbool only_always,\nconst block_size_descriptor* bsd,\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Inline computation of derivatives
|
61,745 |
30.04.2021 10:46:49
| -3,600 |
a9f23ad16e942499950deb797c2faec777e55cf6
|
Use function pointer pipeline for data loading
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_image.cpp",
"new_path": "Source/astcenc_image.cpp",
"diff": "#include \"astcenc_internal.h\"\n-// helper function to initialize the work-data from the orig-data\n-static void imageblock_initialize_work_from_orig(\n- imageblock* blk,\n- int pixelcount\n+/**\n+ * @brief Loader pipeline function type for data fetch from memory.\n+ */\n+using pixel_loader = vfloat4(*)(const void*, int);\n+\n+/**\n+ * @brief Loader pipeline function type for swizzling data in a vector.\n+ */\n+using pixel_swizzler = vfloat4(*)(vfloat4, const astcenc_swizzle&);\n+\n+/**\n+ * @brief Loader pipeline function type for converting data in a vector to LNS.\n+ */\n+using pixel_converter = vfloat4(*)(vfloat4, vmask4);\n+\n+/**\n+ * @brief Load a 8-bit UNORM texel from a data array.\n+ *\n+ * @param data The data pointer.\n+ * @param base_offset The index offset to the start of the pixel.\n+ */\n+static vfloat4 load_texel_u8(\n+ const void* data,\n+ int base_offset\n) {\n- blk->origin_texel = blk->texel(0);\n+ const uint8_t* data8 = static_cast<const uint8_t*>(data);\n+ return int_to_float(vint4(data8 + base_offset)) / 255.0f;\n- vfloat4 data_min(1e38f);\n- vfloat4 data_max(-1e38f);\n- bool grayscale = true;\n+}\n- for (int i = 0; i < pixelcount; i++)\n- {\n- vfloat4 data = blk->texel(i);\n- vfloat4 color_lns = vfloat4::zero();\n- vfloat4 color_unorm = data * 65535.0f;\n+/**\n+ * @brief Load a 16-bit fp16 texel from a data array.\n+ *\n+ * @param data The data pointer.\n+ * @param base_offset The index offset to the start of the pixel.\n+ */\n+static vfloat4 load_texel_f16(\n+ const void* data,\n+ int base_offset\n+) {\n+ const uint16_t* data16 = static_cast<const uint16_t*>(data);\n+ int r = static_cast<float>(data16[base_offset ]);\n+ int g = static_cast<float>(data16[base_offset + 1]);\n+ int b = static_cast<float>(data16[base_offset + 2]);\n+ int a = static_cast<float>(data16[base_offset + 3]);\n+ return float16_to_float(vint4(r, g, b, a));\n+}\n- int rgb_lns = blk->rgb_lns[i];\n- int a_lns = blk->alpha_lns[i];\n+/**\n+ * @brief Load a 32-bit float texel from a data array.\n+ *\n+ * @param data The data pointer.\n+ * @param base_offset The index offset to the start of the pixel.\n+ */\n+static vfloat4 load_texel_f32(\n+ const void* data,\n+ int base_offset\n+) {\n+ const float* data32 = static_cast<const float*>(data);\n+ return vfloat4(data32 + base_offset);\n+}\n- if (rgb_lns || a_lns)\n- {\n- color_lns = float_to_lns(data);\n+/**\n+ * @brief Dummy no-op swizzle function.\n+ *\n+ * @param data The source RGBA vector to swizzle.\n+ * @param swz The swizzle to use.\n+ */\n+static vfloat4 swz_texel_skip(\n+ vfloat4 data,\n+ const astcenc_swizzle& swz\n+) {\n+ (void)swz;\n+ return data;\n}\n- vint4 use_lns(rgb_lns, rgb_lns, rgb_lns, a_lns);\n- vmask4 lns_mask = use_lns != vint4::zero();\n- data = select(color_unorm, color_lns, lns_mask);\n+/**\n+ * @brief Swizzle a texel into a new arrangement.\n+ *\n+ * @param data The source RGBA vector to swizzle.\n+ * @param swz The swizzle to use.\n+ */\n+static vfloat4 swz_texel(\n+ vfloat4 data,\n+ const astcenc_swizzle& swz\n+) {\n+ alignas(16) float datas[6];\n- // Compute block metadata\n- data_min = min(data_min, data);\n- data_max = max(data_max, data);\n+ storea(data, datas);\n+ datas[ASTCENC_SWZ_0] = 0.0f;\n+ datas[ASTCENC_SWZ_1] = 1.0f;\n- if (grayscale && (data.lane<0>() != data.lane<1>() || data.lane<0>() != data.lane<2>()))\n- {\n- grayscale = false;\n+ return vfloat4(datas[swz.r], datas[swz.g], datas[swz.b], datas[swz.a]);\n}\n- // Store block data\n- blk->data_r[i] = data.lane<0>();\n- blk->data_g[i] = data.lane<1>();\n- blk->data_b[i] = data.lane<2>();\n- blk->data_a[i] = data.lane<3>();\n+/**\n+ * @brief Encode a texel that is entirely LDR linear.\n+ *\n+ * @param data The RGBA data to encode.\n+ * @param lns_mask The mask for the HDR channels than need LNS encoding.\n+ */\n+static vfloat4 encode_texel_unorm(\n+ vfloat4 data,\n+ vmask4 lns_mask\n+) {\n+ (void)lns_mask;\n+ return data * 65535.0f;\n}\n- // Store block metadata\n- blk->data_min = data_min;\n- blk->data_max = data_max;\n- blk->grayscale = grayscale;\n+/**\n+ * @brief Encode a texel that includes at least some HDR LNS texels.\n+ *\n+ * @param data The RGBA data to encode.\n+ * @param lns_mask The mask for the HDR channels than need LNS encoding.\n+ */\n+static vfloat4 encode_texel_lns(\n+ vfloat4 data,\n+ vmask4 lns_mask\n+) {\n+ vfloat4 datav_unorm = data * 65535.0f;\n+ vfloat4 datav_lns = float_to_lns(data);\n+ return select(datav_unorm, datav_lns, lns_mask);\n}\n// fetch an imageblock from the input file.\n@@ -100,111 +173,44 @@ void fetch_imageblock(\n(swz.b != ASTCENC_SWZ_B) || (swz.a != ASTCENC_SWZ_A);\nint idx = 0;\n- if (img.data_type == ASTCENC_TYPE_U8)\n- {\n- uint8_t data[6];\n- data[ASTCENC_SWZ_0] = 0x00;\n- data[ASTCENC_SWZ_1] = 0xFF;\n-\n- for (int z = 0; z < bsd->zdim; z++)\n- {\n- int zi = astc::min(zpos + z, zsize - 1);\n- uint8_t* data8 = static_cast<uint8_t*>(img.data[zi]);\n- for (int y = 0; y < bsd->ydim; y++)\n- {\n- int yi = astc::min(ypos + y, ysize - 1);\n-\n- for (int x = 0; x < bsd->xdim; x++)\n- {\n- int xi = astc::min(xpos + x, xsize - 1);\n+ vfloat4 data_min(1e38f);\n+ vfloat4 data_max(-1e38f);\n+ bool grayscale = true;\n- int r = data8[(4 * xsize * yi) + (4 * xi )];\n- int g = data8[(4 * xsize * yi) + (4 * xi + 1)];\n- int b = data8[(4 * xsize * yi) + (4 * xi + 2)];\n- int a = data8[(4 * xsize * yi) + (4 * xi + 3)];\n+ // This works because we impose the same choice everywhere during encode\n+ int rgb_lns = (decode_mode == ASTCENC_PRF_HDR) || (decode_mode == ASTCENC_PRF_HDR_RGB_LDR_A);\n+ int a_lns = decode_mode == ASTCENC_PRF_HDR;\n+ vint4 use_lns(rgb_lns, rgb_lns, rgb_lns, a_lns);\n+ vmask4 lns_mask = use_lns != vint4::zero();\n- if (needs_swz)\n+ // Set up the function pointers for loading pipeline as needed\n+ pixel_loader loader = load_texel_u8;\n+ if (img.data_type == ASTCENC_TYPE_F16)\n{\n- data[ASTCENC_SWZ_R] = r;\n- data[ASTCENC_SWZ_G] = g;\n- data[ASTCENC_SWZ_B] = b;\n- data[ASTCENC_SWZ_A] = a;\n-\n- r = data[swz.r];\n- g = data[swz.g];\n- b = data[swz.b];\n- a = data[swz.a];\n- }\n-\n- blk->data_r[idx] = static_cast<float>(r) / 255.0f;\n- blk->data_g[idx] = static_cast<float>(g) / 255.0f;\n- blk->data_b[idx] = static_cast<float>(b) / 255.0f;\n- blk->data_a[idx] = static_cast<float>(a) / 255.0f;\n- idx++;\n- }\n- }\n+ loader = load_texel_f16;\n}\n- }\n- else if (img.data_type == ASTCENC_TYPE_F16)\n- {\n- uint16_t data[6];\n- data[ASTCENC_SWZ_0] = 0x0000;\n- data[ASTCENC_SWZ_1] = 0x3C00;\n-\n- for (int z = 0; z < bsd->zdim; z++)\n- {\n- int zi = astc::min(zpos + z, zsize - 1);\n- uint16_t* data16 = static_cast<uint16_t*>(img.data[zi]);\n-\n- for (int y = 0; y < bsd->ydim; y++)\n+ else if (img.data_type == ASTCENC_TYPE_F32)\n{\n- int yi = astc::min(ypos + y, ysize - 1);\n-\n- for (int x = 0; x < bsd->xdim; x++)\n- {\n- int xi = astc::min(xpos + x, xsize - 1);\n-\n- int r = data16[(4 * xsize * yi) + (4 * xi )];\n- int g = data16[(4 * xsize * yi) + (4 * xi + 1)];\n- int b = data16[(4 * xsize * yi) + (4 * xi + 2)];\n- int a = data16[(4 * xsize * yi) + (4 * xi + 3)];\n+ loader = load_texel_f32;\n+ }\n+ pixel_swizzler swizzler = swz_texel_skip;\nif (needs_swz)\n{\n- data[ASTCENC_SWZ_R] = r;\n- data[ASTCENC_SWZ_G] = g;\n- data[ASTCENC_SWZ_B] = b;\n- data[ASTCENC_SWZ_A] = a;\n-\n- r = data[swz.r];\n- g = data[swz.g];\n- b = data[swz.b];\n- a = data[swz.a];\n+ swizzler = swz_texel;\n}\n- vfloat4 dataf = max(float16_to_float(vint4(r, g, b, a)), 1e-8f);\n- blk->data_r[idx] = dataf.lane<0>();\n- blk->data_g[idx] = dataf.lane<1>();\n- blk->data_b[idx] = dataf.lane<2>();\n- blk->data_a[idx] = dataf.lane<3>();\n- idx++;\n- }\n- }\n- }\n- }\n- else // if (img.data_type == ASTCENC_TYPE_F32)\n+ pixel_converter converter = encode_texel_unorm;\n+ if (any(lns_mask))\n{\n- assert(img.data_type == ASTCENC_TYPE_F32);\n-\n- float data[6];\n- data[ASTCENC_SWZ_0] = 0.0f;\n- data[ASTCENC_SWZ_1] = 1.0f;\n+ converter = encode_texel_lns;\n+ }\nfor (int z = 0; z < bsd->zdim; z++)\n{\nint zi = astc::min(zpos + z, zsize - 1);\n- float* data32 = static_cast<float*>(img.data[zi]);\n+ void* plane = img.data[zi];\nfor (int y = 0; y < bsd->ydim; y++)\n{\n@@ -214,45 +220,49 @@ void fetch_imageblock(\n{\nint xi = astc::min(xpos + x, xsize - 1);\n- float r = data32[(4 * xsize * yi) + (4 * xi )];\n- float g = data32[(4 * xsize * yi) + (4 * xi + 1)];\n- float b = data32[(4 * xsize * yi) + (4 * xi + 2)];\n- float a = data32[(4 * xsize * yi) + (4 * xi + 3)];\n+ vfloat4 datav = loader(plane, (4 * xsize * yi) + (4 * xi ));\n+ datav = swizzler(datav, swz);\n+ datav = converter(datav, lns_mask);\n- if (needs_swz)\n- {\n- data[ASTCENC_SWZ_R] = r;\n- data[ASTCENC_SWZ_G] = g;\n- data[ASTCENC_SWZ_B] = b;\n- data[ASTCENC_SWZ_A] = a;\n+ // Compute block metadata\n+ data_min = min(data_min, datav);\n+ data_max = max(data_max, datav);\n- r = data[swz.r];\n- g = data[swz.g];\n- b = data[swz.b];\n- a = data[swz.a];\n+ if (grayscale && (datav.lane<0>() != datav.lane<1>() || datav.lane<0>() != datav.lane<2>()))\n+ {\n+ grayscale = false;\n}\n- blk->data_r[idx] = astc::max(r, 1e-8f);\n- blk->data_g[idx] = astc::max(g, 1e-8f);\n- blk->data_b[idx] = astc::max(b, 1e-8f);\n- blk->data_a[idx] = astc::max(a, 1e-8f);\n+ blk->data_r[idx] = datav.lane<0>();\n+ blk->data_g[idx] = datav.lane<1>();\n+ blk->data_b[idx] = datav.lane<2>();\n+ blk->data_a[idx] = datav.lane<3>();\n+\n+ blk->rgb_lns[idx] = rgb_lns;\n+ blk->alpha_lns[idx] = a_lns;\n+\nidx++;\n}\n}\n}\n- }\n- int rgb_lns = (decode_mode == ASTCENC_PRF_HDR) || (decode_mode == ASTCENC_PRF_HDR_RGB_LDR_A);\n- int alpha_lns = decode_mode == ASTCENC_PRF_HDR;\n+ // Reverse the encoding so we store origin block in the original format\n+ // TODO: Move this to when we consume it, as we rarely do?\n+ vfloat4 data_enc = blk->texel(0);\n+ vfloat4 data_enc_unorm = data_enc / 65535.0f;\n+ vfloat4 data_enc_lns = vfloat4::zero();\n- // impose the choice on every pixel when encoding.\n- for (int i = 0; i < bsd->texel_count; i++)\n+ if (rgb_lns || a_lns)\n{\n- blk->rgb_lns[i] = rgb_lns;\n- blk->alpha_lns[i] = alpha_lns;\n+ data_enc_lns = float16_to_float(lns_to_sf16(float_to_int(data_enc)));\n}\n- imageblock_initialize_work_from_orig(blk, bsd->texel_count);\n+ blk->origin_texel = select(data_enc_unorm, data_enc_lns, lns_mask);;\n+\n+ // Store block metadata\n+ blk->data_min = data_min;\n+ blk->data_max = data_max;\n+ blk->grayscale = grayscale;\n}\nvoid write_imageblock(\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use function pointer pipeline for data loading
|
61,745 |
30.04.2021 23:07:00
| -3,600 |
f17007d523468d6734d8a7592bbf2d2d37fd78b2
|
Add some loop count promises
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_integer_sequence.cpp",
"new_path": "Source/astcenc_integer_sequence.cpp",
"diff": "@@ -481,6 +481,8 @@ void encode_ise(\nuint8_t* output_data,\nint bit_offset\n) {\n+ promise(elements > 0);\n+\nint bits = btq_counts[quant_level].bits;\nint trits = btq_counts[quant_level].trits;\nint quints = btq_counts[quant_level].quints;\n@@ -637,6 +639,8 @@ void decode_ise(\nuint8_t* output_data,\nint bit_offset\n) {\n+ promise(elements > 0);\n+\n// note: due to how the trit/quint-block unpacking is done in this function,\n// we may write more temporary results than the number of outputs\n// The maximum actual number of results is 64 bit, but we keep 4 additional elements\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"new_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"diff": "@@ -790,6 +790,9 @@ void determine_optimal_set_of_endpoint_formats_to_use(\n) {\nint partition_count = pt->partition_count;\n+ promise(partition_count > 0);\n+ promise(bsd->block_mode_count > 0);\n+\nint encode_hdr_rgb = blk->rgb_lns[0];\nint encode_hdr_alpha = blk->alpha_lns[0];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add some loop count promises
|
61,745 |
03.05.2021 21:20:39
| -3,600 |
46c4e13943e8a4b29964628c854076fc979367e7
|
Add VLA for compute_value_of_texel_int
|
[
{
"change_type": "MODIFY",
"old_path": "Source/UnitTest/test_simd.cpp",
"new_path": "Source/UnitTest/test_simd.cpp",
"diff": "@@ -1296,6 +1296,19 @@ TEST(vint4, vadd)\nEXPECT_EQ(a.lane<3>(), 4 + 5);\n}\n+/** @brief Test vint4 self-add. */\n+TEST(vint4, vselfadd)\n+{\n+ vint4 a(1, 2, 3, 4);\n+ vint4 b(2, 3, 4, 5);\n+ a += b;\n+\n+ EXPECT_EQ(a.lane<0>(), 1 + 2);\n+ EXPECT_EQ(a.lane<1>(), 2 + 3);\n+ EXPECT_EQ(a.lane<2>(), 3 + 4);\n+ EXPECT_EQ(a.lane<3>(), 4 + 5);\n+}\n+\n/** @brief Test vint4 add. */\nTEST(vint4, vsadd)\n{\n@@ -2692,7 +2705,6 @@ TEST(vint8, UnalignedLoad8)\nEXPECT_EQ(a.lane<7>(), 8);\n}\n-\n/** @brief Test scalar duplicated vint8 load. */\nTEST(vint8, ScalarDupLoad)\n{\n@@ -2809,6 +2821,24 @@ TEST(vint8, vadd)\nEXPECT_EQ(a.lane<7>(), 4 + 5);\n}\n+\n+/** @brief Test vint8 self-add. */\n+TEST(vint8, vselfadd1)\n+{\n+ vint8 a(1, 2, 3, 4, 1, 2, 3, 4);\n+ vint8 b(2, 3, 4, 5, 2, 3, 4, 5);\n+ a += b;\n+\n+ EXPECT_EQ(a.lane<0>(), 1 + 2);\n+ EXPECT_EQ(a.lane<1>(), 2 + 3);\n+ EXPECT_EQ(a.lane<2>(), 3 + 4);\n+ EXPECT_EQ(a.lane<3>(), 4 + 5);\n+ EXPECT_EQ(a.lane<4>(), 1 + 2);\n+ EXPECT_EQ(a.lane<5>(), 2 + 3);\n+ EXPECT_EQ(a.lane<6>(), 3 + 4);\n+ EXPECT_EQ(a.lane<7>(), 4 + 5);\n+}\n+\n/** @brief Test vint8 sub. */\nTEST(vint8, vsub)\n{\n@@ -2825,6 +2855,22 @@ TEST(vint8, vsub)\nEXPECT_EQ(a.lane<7>(), 4 - 5);\n}\n+/** @brief Test vint8 mul. */\n+TEST(vint8, vmul)\n+{\n+ vint8 a(1, 2, 4, 4, 1, 2, 4, 4);\n+ vint8 b(2, 3, 3, 5, 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+ EXPECT_EQ(a.lane<4>(), 1 * 2);\n+ EXPECT_EQ(a.lane<5>(), 2 * 3);\n+ EXPECT_EQ(a.lane<6>(), 4 * 3);\n+ EXPECT_EQ(a.lane<7>(), 4 * 5);\n+}\n+\n/** @brief Test vint8 bitwise invert. */\nTEST(vint8, bit_invert)\n{\n@@ -3000,6 +3046,78 @@ TEST(vint8, max)\nEXPECT_EQ(r.lane<7>(), 5);\n}\n+/** @brief Test vint8 lsr. */\n+TEST(vint8, lsr)\n+{\n+ vint8 a(1, 2, 4, -4, 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>(), 0xFFFFFFFC);\n+ EXPECT_EQ(a.lane<4>(), 1);\n+ EXPECT_EQ(a.lane<5>(), 2);\n+ EXPECT_EQ(a.lane<6>(), 4);\n+ EXPECT_EQ(a.lane<7>(), 0xFFFFFFFC);\n+\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>(), 0x7FFFFFFE);\n+ EXPECT_EQ(a.lane<4>(), 0);\n+ EXPECT_EQ(a.lane<5>(), 1);\n+ EXPECT_EQ(a.lane<6>(), 2);\n+ EXPECT_EQ(a.lane<7>(), 0x7FFFFFFE);\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>(), 0x1FFFFFFF);\n+ EXPECT_EQ(a.lane<4>(), 0);\n+ EXPECT_EQ(a.lane<5>(), 0);\n+ EXPECT_EQ(a.lane<6>(), 0);\n+ EXPECT_EQ(a.lane<7>(), 0x1FFFFFFF);\n+}\n+\n+/** @brief Test vint8 asr. */\n+TEST(vint8, asr)\n+{\n+ vint8 a(1, 2, 4, -4, 1, 2, 4, -4);\n+ a = asr<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+ EXPECT_EQ(a.lane<4>(), 1);\n+ EXPECT_EQ(a.lane<5>(), 2);\n+ EXPECT_EQ(a.lane<6>(), 4);\n+ EXPECT_EQ(a.lane<7>(), -4);\n+\n+ a = asr<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+ EXPECT_EQ(a.lane<4>(), 0);\n+ EXPECT_EQ(a.lane<5>(), 1);\n+ EXPECT_EQ(a.lane<6>(), 2);\n+ EXPECT_EQ(a.lane<7>(), -2);\n+\n+ // Note - quirk of asr is that you will get \"stuck\" at -1\n+ a = asr<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>(), -1);\n+ EXPECT_EQ(a.lane<4>(), 0);\n+ EXPECT_EQ(a.lane<5>(), 0);\n+ EXPECT_EQ(a.lane<6>(), 0);\n+ EXPECT_EQ(a.lane<7>(), -1);\n+}\n+\n/** @brief Test vint8 hmin. */\nTEST(vint8, hmin)\n{\n@@ -3068,6 +3186,22 @@ TEST(vint8, storea)\nEXPECT_EQ(out[7], 7);\n}\n+/** @brief Test vint8 store. */\n+TEST(vint8, store)\n+{\n+ alignas(32) int out[9];\n+ vint8 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+ EXPECT_EQ(out[5], 4);\n+ EXPECT_EQ(out[6], 5);\n+ EXPECT_EQ(out[7], 6);\n+ EXPECT_EQ(out[8], 7);\n+}\n+\n/** @brief Test vint8 store_nbytes. */\nTEST(vint8, store_nbytes)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_block_sizes2.cpp",
"new_path": "Source/astcenc_block_sizes2.cpp",
"diff": "@@ -308,9 +308,7 @@ static void initialize_decimation_table_2d(\nfor (int j = 0; j < weight_count_of_texel[i]; j++)\n{\n- dt->texel_weights_int_t4[i][j] = weights_of_texel[i][j];\n- dt->texel_weights_t4[i][j] = grid_weights_of_texel[i][j];\n-\n+ dt->texel_weights_int_4t[j][i] = weights_of_texel[i][j];\ndt->texel_weights_float_4t[j][i] = ((float)weights_of_texel[i][j]) * (1.0f / TEXEL_WEIGHT_SUM);\ndt->texel_weights_4t[j][i] = grid_weights_of_texel[i][j];\n}\n@@ -318,9 +316,7 @@ static void initialize_decimation_table_2d(\n// Init all 4 entries so we can rely on zeros for vectorization\nfor (int j = weight_count_of_texel[i]; j < 4; j++)\n{\n- dt->texel_weights_int_t4[i][j] = 0;\n- dt->texel_weights_t4[i][j] = 0;\n-\n+ dt->texel_weights_int_4t[j][i] = 0;\ndt->texel_weights_float_4t[j][i] = 0.0f;\ndt->texel_weights_4t[j][i] = 0;\n}\n@@ -345,7 +341,7 @@ static void initialize_decimation_table_2d(\nint swap_idx = -1;\nfor (int k = 0; k < 4; k++)\n{\n- uint8_t dttw = dt->texel_weights_t4[texel][k];\n+ uint8_t dttw = dt->texel_weights_4t[k][texel];\nfloat dttwf = dt->texel_weights_float_4t[k][texel];\nif (dttw == i && dttwf != 0.0f)\n{\n@@ -555,18 +551,14 @@ static void initialize_decimation_table_3d(\n// Init all 4 entries so we can rely on zeros for vectorization\nfor (int j = 0; j < 4; j++)\n{\n- dt->texel_weights_int_t4[i][j] = 0;\n- dt->texel_weights_t4[i][j] = 0;\n-\n+ dt->texel_weights_int_4t[j][i] = 0;\ndt->texel_weights_float_4t[j][i] = 0.0f;\ndt->texel_weights_4t[j][i] = 0;\n}\nfor (int j = 0; j < weight_count_of_texel[i]; j++)\n{\n- dt->texel_weights_int_t4[i][j] = weights_of_texel[i][j];\n- dt->texel_weights_t4[i][j] = grid_weights_of_texel[i][j];\n-\n+ dt->texel_weights_int_4t[j][i] = weights_of_texel[i][j];\ndt->texel_weights_float_4t[j][i] = ((float)weights_of_texel[i][j]) * (1.0f / TEXEL_WEIGHT_SUM);\ndt->texel_weights_4t[j][i] = grid_weights_of_texel[i][j];\n}\n@@ -591,7 +583,7 @@ static void initialize_decimation_table_3d(\nint swap_idx = -1;\nfor (int k = 0; k < 4; k++)\n{\n- uint8_t dttw = dt->texel_weights_t4[texel][k];\n+ uint8_t dttw = dt->texel_weights_4t[k][texel];\nfloat dttwf = dt->texel_weights_float_4t[k][texel];\nif (dttw == i && dttwf != 0.0f)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_decompress_symbolic.cpp",
"new_path": "Source/astcenc_decompress_symbolic.cpp",
"diff": "@@ -33,12 +33,32 @@ static int compute_value_of_texel_int(\nint weights_to_evaluate = dt->texel_weight_count[texel_to_get];\nfor (int i = 0; i < weights_to_evaluate; i++)\n{\n- summed_value += weights[dt->texel_weights_t4[texel_to_get][i]]\n- * dt->texel_weights_int_t4[texel_to_get][i];\n+ summed_value += weights[dt->texel_weights_4t[i][texel_to_get]]\n+ * dt->texel_weights_int_4t[i][texel_to_get];\n}\nreturn summed_value >> 4;\n}\n+static vint compute_value_of_texel_int_vla(\n+ int texel_to_get,\n+ const decimation_table* dt,\n+ const int* weights\n+) {\n+ vint summed_value(8);\n+ vint weight_count(dt->texel_weight_count + texel_to_get);\n+ int max_weight_count = hmax(weight_count).lane<0>();\n+\n+ for (int i = 0; i < max_weight_count; i++)\n+ {\n+ vint texel_weights(dt->texel_weights_4t[i] + texel_to_get);\n+ vint texel_weights_int(dt->texel_weights_int_4t[i] + texel_to_get);\n+\n+ summed_value += gatheri(weights, texel_weights) * texel_weights_int;\n+ }\n+\n+ return lsr<4>(summed_value);\n+}\n+\nstatic vint4 lerp_color_int(\nastcenc_profile decode_mode,\nvint4 color0,\n@@ -120,15 +140,31 @@ void unpack_weights(\n}\n// Second, undecimate the weights ...\n- for (int i = 0; i < bsd.texel_count; i++)\n+ int clipped_texel_count = round_down_to_simd_multiple_vla(bsd.texel_count);\n+ if (!is_dual_plane)\n{\n- weights_plane1[i] = compute_value_of_texel_int(i, &dt, uq_plane1_weights);\n+ for (int i = 0; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n+ {\n+ store(compute_value_of_texel_int_vla(i, &dt, uq_plane1_weights), weights_plane1 + i);\n+\n}\n- if (is_dual_plane)\n+ for (int i = clipped_texel_count; i < bsd.texel_count; i++)\n+ {\n+ weights_plane1[i] = compute_value_of_texel_int(i, &dt, uq_plane1_weights);\n+ }\n+ }\n+ else\n+ {\n+ for (int i = 0; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n- for (int i = 0; i < bsd.texel_count; i++)\n+ store(compute_value_of_texel_int_vla(i, &dt, uq_plane1_weights), weights_plane1 + i);\n+ store(compute_value_of_texel_int_vla(i, &dt, uq_plane2_weights), weights_plane2 + i);\n+ }\n+\n+ for (int i = clipped_texel_count; i < bsd.texel_count; i++)\n{\n+ weights_plane1[i] = compute_value_of_texel_int(i, &dt, uq_plane1_weights);\nweights_plane2[i] = compute_value_of_texel_int(i, &dt, uq_plane2_weights);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -407,9 +407,8 @@ struct decimation_table\n// data access patterns depending on how we can unroll loops\nalignas(ASTCENC_VECALIGN) float texel_weights_float_4t[4][MAX_TEXELS_PER_BLOCK]; // the weight to assign to each weight\nalignas(ASTCENC_VECALIGN) uint8_t texel_weights_4t[4][MAX_TEXELS_PER_BLOCK]; // the weights that go into a texel calculation\n+ alignas(ASTCENC_VECALIGN) uint8_t texel_weights_int_4t[4][MAX_TEXELS_PER_BLOCK]; // the weight to assign to each weight\n- uint8_t texel_weights_t4[MAX_TEXELS_PER_BLOCK][4]; // the weights that go into a texel calculation\n- uint8_t texel_weights_int_t4[MAX_TEXELS_PER_BLOCK][4]; // the weight to assign to each weight\nuint8_t weight_texel_count[MAX_WEIGHTS_PER_BLOCK]; // the number of texels that a given weight contributes to\n// Stored transposed to give better access patterns\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_vecmathlib_avx2_8.h",
"new_path": "Source/astcenc_vecmathlib_avx2_8.h",
"diff": "@@ -372,6 +372,15 @@ ASTCENC_SIMD_INLINE vint8 operator+(vint8 a, vint8 b)\nreturn vint8(_mm256_add_epi32(a.m, b.m));\n}\n+/**\n+ * @brief Overload: vector by vector incremental addition.\n+ */\n+ASTCENC_SIMD_INLINE vint8& operator+=(vint8& a, const vint8& b)\n+{\n+ a = a + b;\n+ return a;\n+}\n+\n/**\n* @brief Overload: vector by vector subtraction.\n*/\n@@ -380,6 +389,14 @@ ASTCENC_SIMD_INLINE vint8 operator-(vint8 a, vint8 b)\nreturn vint8(_mm256_sub_epi32(a.m, b.m));\n}\n+/**\n+ * @brief Overload: vector by vector multiplication.\n+ */\n+ASTCENC_SIMD_INLINE vint8 operator*(vint8 a, vint8 b)\n+{\n+ return vint8(_mm256_mullo_epi32(a.m, b.m));\n+}\n+\n/**\n* @brief Overload: vector bit invert.\n*/\n@@ -444,6 +461,22 @@ ASTCENC_SIMD_INLINE vmask8 operator>(vint8 a, vint8 b)\nreturn vmask8(_mm256_cmpgt_epi32(a.m, b.m));\n}\n+/**\n+ * @brief Arithmetic shift right.\n+ */\n+template <int s> ASTCENC_SIMD_INLINE vint8 asr(vint8 a)\n+{\n+ return vint8(_mm256_srai_epi32(a.m, s));\n+}\n+\n+/**\n+ * @brief Logical shift right.\n+ */\n+template <int s> ASTCENC_SIMD_INLINE vint8 lsr(vint8 a)\n+{\n+ return vint8(_mm256_srli_epi32(a.m, s));\n+}\n+\n/**\n* @brief Return the min vector of two vectors.\n*/\n@@ -504,6 +537,14 @@ ASTCENC_SIMD_INLINE void storea(vint8 a, int* p)\n_mm256_store_si256((__m256i*)p, a.m);\n}\n+/**\n+ * @brief Store a vector to an unaligned memory address.\n+ */\n+ASTCENC_SIMD_INLINE void store(vint8 a, int* p)\n+{\n+ _mm256_storeu_si256((__m256i*)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_common_4.h",
"new_path": "Source/astcenc_vecmathlib_common_4.h",
"diff": "@@ -64,6 +64,15 @@ ASTCENC_SIMD_INLINE vint4 operator+(vint4 a, int b)\nreturn a + vint4(b);\n}\n+/**\n+ * @brief Overload: vector by vector incremental addition.\n+ */\n+ASTCENC_SIMD_INLINE vint4& operator+=(vint4& a, const vint4& b)\n+{\n+ a = a + b;\n+ return a;\n+}\n+\n/**\n* @brief Overload: vector by scalar subtraction.\n*/\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add VLA for compute_value_of_texel_int
|
61,745 |
03.05.2021 21:51:13
| -3,600 |
60adc668a5531f931b4acf5efa84e19cdc1542d2
|
Init array tail for compute_value_of_texel_int and remove loop tail
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_block_sizes2.cpp",
"new_path": "Source/astcenc_block_sizes2.cpp",
"diff": "@@ -372,6 +372,20 @@ static void initialize_decimation_table_2d(\n}\n}\n+ // Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n+ int texels_per_block_simd = round_up_to_simd_multiple_vla(texels_per_block);\n+ for (int i = texels_per_block; i < texels_per_block_simd; i++)\n+ {\n+ dt->texel_weight_count[i] = 0;\n+\n+ for (int j = 0; j < 4; j++)\n+ {\n+ dt->texel_weights_float_4t[j][i] = 0;\n+ dt->texel_weights_4t[j][i] = 0;\n+ dt->texel_weights_int_4t[j][i] = 0;\n+ }\n+ }\n+\n// Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n// Match last texel in active lane in SIMD group, for better gathers\nint last_texel_count_wt = texel_count_of_weight[weights_per_block - 1];\n@@ -605,16 +619,34 @@ static void initialize_decimation_table_3d(\n}\n// Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n- // TODO: Match an active lane in SIMD group, as better for gathers?\n+ // Match last texel in active lane in SIMD group, for better gathers\n+ uint8_t last_texel = dt->weight_texel[texel_count_wt - 1][i];\nfor (int j = texel_count_wt; j < max_texel_count_of_weight; j++)\n{\n- dt->weight_texel[j][i] = 0;\n+ dt->weight_texel[j][i] = last_texel;\ndt->weights_flt[j][i] = 0.0f;\n}\n}\n// Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n- // TODO: Match an active lane in SIMD group, as better for gathers?\n+ int texels_per_block_simd = round_up_to_simd_multiple_vla(texels_per_block);\n+ for (int i = texels_per_block; i < texels_per_block_simd; i++)\n+ {\n+ dt->texel_weight_count[i] = 0;\n+\n+ for (int j = 0; j < 4; j++)\n+ {\n+ dt->texel_weights_float_4t[j][i] = 0;\n+ dt->texel_weights_4t[j][i] = 0;\n+ dt->texel_weights_int_4t[j][i] = 0;\n+ }\n+ }\n+\n+ // Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n+ // Match last texel in active lane in SIMD group, for better gathers\n+ int last_texel_count_wt = texel_count_of_weight[weights_per_block - 1];\n+ uint8_t last_texel = dt->weight_texel[last_texel_count_wt - 1][weights_per_block - 1];\n+\nint weights_per_block_simd = round_up_to_simd_multiple_vla(weights_per_block);\nfor (int i = weights_per_block; i < weights_per_block_simd; i++)\n{\n@@ -622,7 +654,7 @@ static void initialize_decimation_table_3d(\nfor (int j = 0; j < max_texel_count_of_weight; j++)\n{\n- dt->weight_texel[j][i] = 0;\n+ dt->weight_texel[j][i] = last_texel;\ndt->weights_flt[j][i] = 0.0f;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_decompress_symbolic.cpp",
"new_path": "Source/astcenc_decompress_symbolic.cpp",
"diff": "#include <stdio.h>\n#include <assert.h>\n-static int compute_value_of_texel_int(\n- int texel_to_get,\n- const decimation_table* dt,\n- const int* weights\n-) {\n- int summed_value = 8;\n- int weights_to_evaluate = dt->texel_weight_count[texel_to_get];\n- for (int i = 0; i < weights_to_evaluate; i++)\n- {\n- summed_value += weights[dt->texel_weights_4t[i][texel_to_get]]\n- * dt->texel_weights_int_4t[i][texel_to_get];\n- }\n- return summed_value >> 4;\n-}\n-\nstatic vint compute_value_of_texel_int_vla(\nint texel_to_get,\nconst decimation_table* dt,\n@@ -126,46 +111,32 @@ void unpack_weights(\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_level]);\n- for (int i = 0; i < weight_count; i++)\n- {\n- uq_plane1_weights[i] = qat->unquantized_value[scb.weights[i]];\n- }\n-\n- if (is_dual_plane)\n- {\n- for (int i = 0; i < weight_count; i++)\n- {\n- uq_plane2_weights[i] = qat->unquantized_value[scb.weights[i + PLANE2_WEIGHTS_OFFSET]];\n- }\n- }\n-\n// Second, undecimate the weights ...\n- int clipped_texel_count = round_down_to_simd_multiple_vla(bsd.texel_count);\n+ // Safe to overshoot as all arrays are allocated to full size\nif (!is_dual_plane)\n{\n- for (int i = 0; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n+ for (int i = 0; i < weight_count; i++)\n{\n- store(compute_value_of_texel_int_vla(i, &dt, uq_plane1_weights), weights_plane1 + i);\n-\n+ uq_plane1_weights[i] = qat->unquantized_value[scb.weights[i]];\n}\n- for (int i = clipped_texel_count; i < bsd.texel_count; i++)\n+ for (int i = 0; i < bsd.texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n- weights_plane1[i] = compute_value_of_texel_int(i, &dt, uq_plane1_weights);\n+ store(compute_value_of_texel_int_vla(i, &dt, uq_plane1_weights), weights_plane1 + i);\n}\n}\nelse\n{\n- for (int i = 0; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n+ for (int i = 0; i < weight_count; i++)\n{\n- store(compute_value_of_texel_int_vla(i, &dt, uq_plane1_weights), weights_plane1 + i);\n- store(compute_value_of_texel_int_vla(i, &dt, uq_plane2_weights), weights_plane2 + i);\n+ uq_plane1_weights[i] = qat->unquantized_value[scb.weights[i]];\n+ uq_plane2_weights[i] = qat->unquantized_value[scb.weights[i + PLANE2_WEIGHTS_OFFSET]];\n}\n- for (int i = clipped_texel_count; i < bsd.texel_count; i++)\n+ for (int i = 0; i < bsd.texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n- weights_plane1[i] = compute_value_of_texel_int(i, &dt, uq_plane1_weights);\n- weights_plane2[i] = compute_value_of_texel_int(i, &dt, uq_plane2_weights);\n+ store(compute_value_of_texel_int_vla(i, &dt, uq_plane1_weights), weights_plane1 + i);\n+ store(compute_value_of_texel_int_vla(i, &dt, uq_plane2_weights), weights_plane2 + i);\n}\n}\n}\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Init array tail for compute_value_of_texel_int and remove loop tail
|
61,745 |
03.05.2021 22:02:46
| -3,600 |
92ae8bceab4dc4cbdb1c167dc50462ad68226045
|
Fuse two adjacent loops
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -429,10 +429,7 @@ static float compress_symbolic_block_fixed_partition_1plane(\n{\nworkscb.color_values[j][k] = colorvals[j][k];\n}\n- }\n- for (int j = 0; j < 4; j++)\n- {\nworkscb.color_formats[j] = color_formats_mod[j];\n}\n}\n@@ -824,10 +821,7 @@ static float compress_symbolic_block_fixed_partition_2planes(\n{\nworkscb.color_values[j][k] = colorvals[j][k];\n}\n- }\n- for (int j = 0; j < 4; j++)\n- {\nworkscb.color_formats[j] = color_formats_mod[j];\n}\n}\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Fuse two adjacent loops
|
61,745 |
03.05.2021 22:28:47
| -3,600 |
81748d559973f3b85379b386c837b8f0d28d3dea
|
Add promise to loop
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -1123,18 +1123,23 @@ void recompute_ideal_colors_2planes(\nconst imageblock* blk, // picture-block containing the actual data.\nconst error_weight_block* ewb\n) {\n+ int weight_count = dt->weight_count;\n+ int partition_count = pt->partition_count;\n+\n+ promise(weight_count > 0);\n+ promise(partition_count > 0);\n+\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_mode]);\nfloat weight_set[MAX_WEIGHTS_PER_BLOCK];\nfloat plane2_weight_set[MAX_WEIGHTS_PER_BLOCK];\n- for (int i = 0; i < dt->weight_count; i++)\n+ for (int i = 0; i < weight_count; i++)\n{\nweight_set[i] = qat->unquantized_value[weight_set8_plane1[i]] * (1.0f / 64.0f);\nplane2_weight_set[i] = qat->unquantized_value[weight_set8_plane2[i]] * (1.0f / 64.0f);\n}\n- int partition_count = pt->partition_count;\nfor (int i = 0; i < partition_count; i++)\n{\nvfloat4 rgba_sum(1e-17f);\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add promise to loop
|
61,745 |
04.05.2021 09:04:08
| -3,600 |
425d74cbe6b8611afa62d42fa0457d8571450e1b
|
Remove loop tail from compute_error_of_weight_set_1/2plane
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -121,6 +121,14 @@ static void compute_endpoints_and_ideal_weights_1_comp(\nis_constant_wes = is_constant_wes && ei->weight_error_scale[i] == constant_wes;\n}\n+ // Zero initialize any SIMD over-fetch\n+ int texel_count_simd = round_up_to_simd_multiple_vla(texel_count);\n+ for (int i = texel_count; i < texel_count_simd; i++)\n+ {\n+ ei->weights[i] = 0.0f;\n+ ei->weight_error_scale[i] = 0.0f;\n+ }\n+\nei->is_constant_weight_error_scale = is_constant_wes;\n}\n@@ -270,6 +278,14 @@ static void compute_endpoints_and_ideal_weights_2_comp(\nis_constant_wes = is_constant_wes && ei->weight_error_scale[i] == constant_wes;\n}\n+ // Zero initialize any SIMD over-fetch\n+ int texel_count_simd = round_up_to_simd_multiple_vla(texel_count);\n+ for (int i = texel_count; i < texel_count_simd; i++)\n+ {\n+ ei->weights[i] = 0.0f;\n+ ei->weight_error_scale[i] = 0.0f;\n+ }\n+\nei->is_constant_weight_error_scale = is_constant_wes;\n}\n@@ -429,6 +445,14 @@ static void compute_endpoints_and_ideal_weights_3_comp(\nis_constant_wes = is_constant_wes && ei->weight_error_scale[i] == constant_wes;\n}\n+ // Zero initialize any SIMD over-fetch\n+ int texel_count_simd = round_up_to_simd_multiple_vla(texel_count);\n+ for (int i = texel_count; i < texel_count_simd; i++)\n+ {\n+ ei->weights[i] = 0.0f;\n+ ei->weight_error_scale[i] = 0.0f;\n+ }\n+\nei->is_constant_weight_error_scale = is_constant_wes;\n}\n@@ -541,6 +565,14 @@ static void compute_endpoints_and_ideal_weights_4_comp(\nis_constant_wes = is_constant_wes && ei->weight_error_scale[i] == constant_wes;\n}\n+ // Zero initialize any SIMD over-fetch\n+ int texel_count_simd = round_up_to_simd_multiple_vla(texel_count);\n+ for (int i = texel_count; i < texel_count_simd; i++)\n+ {\n+ ei->weights[i] = 0.0f;\n+ ei->weight_error_scale[i] = 0.0f;\n+ }\n+\nei->is_constant_weight_error_scale = is_constant_wes;\n}\n@@ -671,11 +703,9 @@ float compute_error_of_weight_set_1plane(\nfloat error_summa = 0.0f;\nint texel_count = dt->texel_count;\n- int i = 0;\n-\n- // Process SIMD-width texel coordinates at at time while we can\n- int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\n- for (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n+ // Process SIMD-width chunks\n+ // Safe to over-fetch - the extra space is zero initialized\n+ for (int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Compute the bilinear interpolation of the decimated weight grid\nvfloat current_values = bilinear_infill_vla(*dt, weights, i);\n@@ -689,36 +719,6 @@ float compute_error_of_weight_set_1plane(\nhaccumulate(error_summav, error);\n}\n- // Loop tail\n- // Error is buffered and accumulated in blocks of 4 to ensure that\n- // the partial sums added to the accumulator are invariant with the\n- // vector implementation, irrespective of vector size ...\n- alignas(16) float errorsum_tmp[4] { 0 };\n- for (/* */; i < texel_count; i++)\n- {\n- float current_value = bilinear_infill(*dt, weights, i);\n- float valuedif = current_value - eai->weights[i];\n- float error = valuedif * valuedif * eai->weight_error_scale[i];\n-\n- // Accumulate error sum in the temporary array\n- int error_index = i & 0x3;\n- errorsum_tmp[error_index] = error;\n-\n-#if ASTCENC_SIMD_WIDTH == 8\n- // Zero the temporary staging buffer every 4 items unless last. Note\n- // that this block can only trigger for 6x5 blocks, all other partials\n- // tails are shorter than 4 ...\n- if ((i & 0x7) == 0x03)\n- {\n- haccumulate(error_summav, vfloat4::loada(errorsum_tmp));\n- storea(vfloat4::zero(), errorsum_tmp);\n- }\n-#endif\n- }\n-\n- // Accumulate the loop tail using the vfloat4 swizzle\n- haccumulate(error_summav, vfloat4::loada(errorsum_tmp));\n-\n// Resolve the final scalar accumulator sum\nhaccumulate(error_summa, error_summav);\n@@ -736,11 +736,9 @@ float compute_error_of_weight_set_2planes(\nfloat error_summa = 0.0f;\nint texel_count = dt->texel_count;\n- int i = 0;\n-\n- // Process SIMD-width texel coordinates at at time while we can\n- int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\n- for (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n+ // Process SIMD-width chunks\n+ // Safe to over-fetch - the extra space is zero initialized\n+ for (int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Plane 1\n// Compute the bilinear interpolation of the decimated weight grid\n@@ -763,42 +761,6 @@ float compute_error_of_weight_set_2planes(\nhaccumulate(error_summav, error1 + error2);\n}\n- // Loop tail\n- // Error is buffered and accumulated in blocks of 4 to ensure that\n- // the partial sums added to the accumulator are invariant with the\n- // vector implementation, irrespective of vector size ...\n- alignas(16) float errorsum_tmp[4] { 0 };\n- for (/* */; i < texel_count; i++)\n- {\n- // Plane 1\n- float current_value1 = bilinear_infill(*dt, weights1, i);\n- float valuedif1 = current_value1 - eai1->weights[i];\n- float error1 = valuedif1 * valuedif1 * eai1->weight_error_scale[i];\n-\n- // Plane 2\n- float current_value2 = bilinear_infill(*dt, weights2, i);\n- float valuedif2 = current_value2 - eai2->weights[i];\n- float error2 = valuedif2 * valuedif2 * eai2->weight_error_scale[i];\n-\n- // Accumulate error sum in the temporary array\n- int error_index = i & 0x3;\n- errorsum_tmp[error_index] = error1 + error2;\n-\n-#if ASTCENC_SIMD_WIDTH == 8\n- // Zero the temporary staging buffer every 4 items unless last. Note\n- // that this block can only trigger for 6x5 blocks, all other partials\n- // tails are shorter than 4 ...\n- if ((i & 0x7) == 0x03)\n- {\n- haccumulate(error_summav, vfloat4::loada(errorsum_tmp));\n- storea(vfloat4::zero(), errorsum_tmp);\n- }\n-#endif\n- }\n-\n- // Accumulate the loop tail using the vfloat4 swizzle\n- haccumulate(error_summav, vfloat4::loada(errorsum_tmp));\n-\n// Resolve the final scalar accumulator sum\nhaccumulate(error_summa, error_summav);\n@@ -836,17 +798,21 @@ void compute_ideal_weights_for_decimation_table(\n// Ensure that the end of the output arrays that are used for SIMD paths later are filled so we\n// can safely run SIMD elsewhere without a loop tail. Note that this is always safe as weight\n// arrays always contain space for 64 elements\n- int simd_weight_count = round_up_to_simd_multiple_vla(weight_count);\n- for (int i = weight_count; i < simd_weight_count; i++)\n+ int weight_count_simd = round_up_to_simd_multiple_vla(weight_count);\n+ for (int i = weight_count; i < weight_count_simd; i++)\n{\nweight_set[i] = 0.0f;\n}\n// If we have a 1:1 mapping just shortcut the computation - clone the\n// weights into both the weight set and the output epw copy.\n+\n+ // Transfer enough to also copy zero initialized SIMD over-fetch region\n+ int texel_count_simd = round_up_to_simd_multiple_vla(texel_count);\nif (texel_count == weight_count)\n{\n- for (int i = 0; i < texel_count; i++)\n+ // TODO: Use SIMD copies?\n+ for (int i = 0; i < texel_count_simd; i++)\n{\nassert(i == dt.weight_texel[0][i]);\nweight_set[i] = eai_in.weights[i];\n@@ -862,7 +828,7 @@ void compute_ideal_weights_for_decimation_table(\n// epw copy and then do the full algorithm to decimate weights.\nelse\n{\n- for (int i = 0; i < texel_count; i++)\n+ for (int i = 0; i < texel_count_simd; i++)\n{\neai_out.weights[i] = eai_in.weights[i];\neai_out.weight_error_scale[i] = eai_in.weight_error_scale[i];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Remove loop tail from compute_error_of_weight_set_1/2plane
|
61,745 |
04.05.2021 21:08:15
| -3,600 |
fb745816cdcc9378e9f7d5d42fc1be2c51606729
|
Use normalize_safe
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -494,14 +494,7 @@ static void compute_endpoints_and_ideal_weights_4_comp(\n}\nlines[i].a = pms[i].avg;\n- if (dot_s(dir, dir) == 0.0f)\n- {\n- lines[i].b = normalize(vfloat4(1.0f));\n- }\n- else\n- {\n- lines[i].b = normalize(dir);\n- }\n+ lines[i].b = normalize_safe(dir, unit4());\n}\nfor (int i = 0; i < texel_count; i++)\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use normalize_safe
|
61,745 |
05.05.2021 22:21:58
| -3,600 |
28adb3266d8dba28dfcd87a240dbfea3423239ed
|
Cleanup astcenc_encoding_choice_error.cpp and add Doxygen
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -722,7 +722,7 @@ static float compress_symbolic_block_fixed_partition_2planes(\nint color_quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\nendpoints epm;\n- merge_endpoints(&(ei1->ep), &(ei2->ep), plane2_component, &epm);\n+ merge_endpoints(ei1->ep, ei2->ep, plane2_component, epm);\ndetermine_optimal_set_of_endpoint_formats_to_use(\nbsd, pt, blk, ewb, &epm, plane2_component, qwt_bitcounts, qwt_errors,\n@@ -765,7 +765,7 @@ static float compress_symbolic_block_fixed_partition_2planes(\ntrace_add_data(\"weight_quant\", weight_quant_mode);\n// recompute the ideal color endpoints before storing them.\n- merge_endpoints(&(eix1[decimation_mode].ep), &(eix2[decimation_mode].ep), plane2_component, &epm);\n+ merge_endpoints(eix1[decimation_mode].ep, eix2[decimation_mode].ep, plane2_component, epm);\nvfloat4 rgbs_colors[4];\nvfloat4 rgbo_colors[4];\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_encoding_choice_error.cpp",
"new_path": "Source/astcenc_encoding_choice_error.cpp",
"diff": "/**\n* @brief Functions for finding color error post-compression.\n*\n- * We assume there are two independent sources of error in any given partition.\n- * - encoding choice errors\n- * - quantization errors\n+ * We assume there are two independent sources of error in any given partition:\n*\n- * Encoding choice errors are caused by encoder decisions, such as:\n- * - using luminance rather than RGB.\n- * - using RGB+scale instead of two full RGB endpoints.\n- * - dropping the alpha component.\n+ * - Encoding choice errors\n+ * - Quantization errors\n*\n- * Quantization errors occur due to the limited precision we use for storage.\n- * These errors generally scale with quantization level, but are not actually\n- * independent of color encoding. In particular:\n- * - if we can use offset encoding then quantization error is halved.\n- * - if we can use blue-contraction, quantization error for RG is halved.\n- * - quantization error is higher for the HDR endpoint modes.\n- * Other than these errors, quantization error is assumed to be proportional to\n- * the quantization step.\n+ * Encoding choice errors are caused by encoder decisions. For example:\n+ *\n+ * - Using luminance instead of separate RGB components.\n+ * - Using a constant 1.0 alpha instead of storing an alpha component.\n+ * - Using RGB+scale instead of storing two full RGB endpoints.\n+ *\n+ * Quantization errors occur due to the limited precision we use for storage. These errors generally\n+ * scale with quantization level, but are not actually independent of color encoding. In particular:\n+ *\n+ * - If we can use offset encoding then quantization error is halved.\n+ * - If we can use blue-contraction then quantization error for RG is halved.\n+ * - If we use HDR endpoints the quantization error is higher.\n+ *\n+ * Apart from these effects, we assume the error is proportional to the quantization step size.\n*/\n#include \"astcenc_internal.h\"\n-// helper function to merge two endpoint-colors\n-void merge_endpoints(\n- const endpoints* ep1, // contains three of the color components\n- const endpoints* ep2, // contains the remaining color component\n- int plane2_component,\n- endpoints* res\n-) {\n- int partition_count = ep1->partition_count;\n- vmask4 sep_mask = vint4::lane_id() == vint4(plane2_component);\n-\n- res->partition_count = partition_count;\n- promise(partition_count > 0);\n- for (int i = 0; i < partition_count; i++)\n- {\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-\n-// function to compute the error across a tile when using a particular line for\n-// a particular partition.\n+/**\n+ * @brief Compute the errors of the endpoint line options for one partition.\n+ *\n+ * Uncorrelated data assumes storing completely independent RGBA channels for\n+ * each endpoint. Same chroma data assumes storing RGBA endpoints which pass\n+ * though the origin (LDR only). RGBL data assumes storing RGB + lumashift (HDR\n+ * only). Luminance error assumes storing RGB channels as a single value.\n+ *\n+ *\n+ * @param pi The partition info data.\n+ * @param partition_index The partition index to compule the error for.\n+ * @param blk The image block.\n+ * @param ewb The error weight block.\n+ * @param uncor_pline The endpoint line assuming uncorrelated endpoints.\n+ * @param[out] uncor_err The computed error for the uncorrelated endpoint line.\n+ * @param samec_pline The endpoint line assuming the same chroma for both endpoints.\n+ * @param[out] samec_err The computed error for the uncorrelated endpoint line.\n+ * @param rgbl_pline The endpoint line assuming RGB + lumashift data.\n+ * @param[out] rgbl_err The computed error for the RGB + lumashift endpoint line.\n+ * @param l_pline The endpoint line assuming luminance data.\n+ * @param[out] l_err The computed error for the luminance endpoint line.\n+ * @param[out] a_drop_err The computed error for dropping the alpha component.\n+ */\nstatic void compute_error_squared_rgb_single_partition(\n- int partition_to_test,\n- const partition_info* pt, // the partition that we use when computing the squared-error.\n- const imageblock* blk,\n- const error_weight_block* ewb,\n- const processed_line3* uncor_pline,\n- float* uncor_err,\n- const processed_line3* samec_pline,\n- float* samec_err,\n- const processed_line3* rgbl_pline,\n- float* rgbl_err,\n- const processed_line3* l_pline,\n- float* l_err,\n- float* a_drop_err\n+ const partition_info& pi,\n+ int partition_index,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\n+ const processed_line3& uncor_pline,\n+ float& uncor_err,\n+ const processed_line3& samec_pline,\n+ float& samec_err,\n+ const processed_line3& rgbl_pline,\n+ float& rgbl_err,\n+ const processed_line3& l_pline,\n+ float& l_err,\n+ float& a_drop_err\n) {\n- float uncor_errorsum = 0.0f;\n- float samec_errorsum = 0.0f;\n- float rgbl_errorsum = 0.0f;\n- float l_errorsum = 0.0f;\n- float a_drop_errorsum = 0.0f;\n+ uncor_err = 0.0f;\n+ samec_err = 0.0f;\n+ rgbl_err = 0.0f;\n+ l_err = 0.0f;\n+ a_drop_err = 0.0f;\n- int texels_in_partition = pt->partition_texel_count[partition_to_test];\n+ int texels_in_partition = pi.partition_texel_count[partition_index];\npromise(texels_in_partition > 0);\nfor (int i = 0; i < texels_in_partition; i++)\n{\n- int tix = pt->texels_of_partition[partition_to_test][i];\n- float texel_weight = ewb->texel_weight_rgb[tix];\n+ int tix = pi.texels_of_partition[partition_index][i];\n+ float texel_weight = ewb.texel_weight_rgb[tix];\nif (texel_weight < 1e-20f)\n{\ncontinue;\n}\n- vfloat4 point = blk->texel(tix);\n- vfloat4 ews = ewb->error_weights[tix];\n+ vfloat4 point = blk.texel(tix);\n+ vfloat4 ews = ewb.error_weights[tix];\n// Compute the error that arises from just ditching alpha\n- float default_alpha = imageblock_default_alpha(blk);\n+ float default_alpha = imageblock_default_alpha(&blk);\nfloat omalpha = point.lane<3>() - default_alpha;\n- a_drop_errorsum += omalpha * omalpha * ews.lane<3>();\n+ a_drop_err += omalpha * omalpha * ews.lane<3>();\n- {\n- float param = dot3_s(point, uncor_pline->bs);\n- vfloat4 rp1 = uncor_pline->amod + param * uncor_pline->bis;\n- vfloat4 dist = rp1 - point;\n- uncor_errorsum += dot3_s(ews, dist * dist);\n- }\n+ float param1 = dot3_s(point, uncor_pline.bs);\n+ vfloat4 rp1 = uncor_pline.amod + param1 * uncor_pline.bis;\n+ vfloat4 dist1 = rp1 - point;\n+ uncor_err += dot3_s(ews, dist1 * dist1);\n- {\n- float param = dot3_s(point, samec_pline->bs);\n+ float param2 = dot3_s(point, samec_pline.bs);\n// No samec amod - we know it's always zero\n- vfloat4 rp1 = /* samec_pline->amod + */ param * samec_pline->bis;\n- vfloat4 dist = rp1 - point;\n- samec_errorsum += dot3_s(ews, dist * dist);\n- }\n+ vfloat4 rp2 = /* samec_pline.amod + */ param2 * samec_pline.bis;\n+ vfloat4 dist2 = rp2 - point;\n+ samec_err += dot3_s(ews, dist2 * dist2);\n- {\n- float param = dot3_s(point, rgbl_pline->bs);\n- vfloat4 rp1 = rgbl_pline->amod + param * rgbl_pline->bis;\n- vfloat4 dist = rp1 - point;\n- rgbl_errorsum += dot3_s(ews, dist * dist);\n- }\n+ // TODO - this is only used for HDR textures. Can we skip?\n+ float param3 = dot3_s(point, rgbl_pline.bs);\n+ vfloat4 rp3 = rgbl_pline.amod + param3 * rgbl_pline.bis;\n+ vfloat4 dist3 = rp3 - point;\n+ rgbl_err += dot3_s(ews, dist3 * dist3);\n- {\n- float param = dot3_s(point, l_pline->bs);\n+ float param4 = dot3_s(point, l_pline.bs);\n// No luma amod - we know it's always zero\n- vfloat4 rp1 = /* l_pline->amod + */ param * l_pline->bis;\n- vfloat4 dist = rp1 - point;\n- l_errorsum += dot3_s(ews, dist * dist);\n+ vfloat4 rp4 = /* l_pline.amod + */ param4 * l_pline.bis;\n+ vfloat4 dist4 = rp4 - point;\n+ l_err += dot3_s(ews, dist4 * dist4);\n}\n}\n- *uncor_err = uncor_errorsum;\n- *samec_err = samec_errorsum;\n- *rgbl_err = rgbl_errorsum;\n- *l_err = l_errorsum;\n- *a_drop_err = a_drop_errorsum;\n-}\n+/* See header for documentation. */\n+void merge_endpoints(\n+ const endpoints& ep_plane1,\n+ const endpoints& ep_plane2,\n+ int component_plane2,\n+ endpoints& result\n+) {\n+ int partition_count = ep_plane1.partition_count;\n+ vmask4 sep_mask = vint4::lane_id() == vint4(component_plane2);\n-/*\n- for a given set of input colors and a given partitioning, determine: color error that results\n- from RGB-scale encoding (relevant for LDR only) color error that results from RGB-lumashift encoding\n- (relevant for HDR only) color error that results from luminance-encoding color error that results\n- form dropping alpha. whether we are eligible for offset encoding whether we are eligible for\n- blue-contraction\n+ result.partition_count = partition_count;\n+ promise(partition_count > 0);\n+ for (int i = 0; i < partition_count; i++)\n+ {\n+ result.endpt0[i] = select(ep_plane1.endpt0[i], ep_plane2.endpt0[i], sep_mask);\n+ result.endpt1[i] = select(ep_plane1.endpt1[i], ep_plane2.endpt1[i], sep_mask);\n+ }\n+}\n- The input data are: color data partitioning error-weight data\n- */\n+ /* See header for documentation. */\nvoid compute_encoding_choice_errors(\n- const block_size_descriptor* bsd,\n- const imageblock* blk,\n- const partition_info* pt,\n- const error_weight_block* ewb,\n- int plane2_component, // component that is separated out in 2-plane mode, -1 in 1-plane mode\n- encoding_choice_errors* eci)\n+ const block_size_descriptor& bsd,\n+ const imageblock& blk,\n+ const partition_info& pi,\n+ const error_weight_block& ewb,\n+ int component_plane2,\n+ encoding_choice_errors eci[4])\n{\n- int partition_count = pt->partition_count;\n- int texels_per_block = bsd->texel_count;\n+ int partition_count = pi.partition_count;\n+ int texels_per_block = bsd.texel_count;\npromise(partition_count > 0);\npromise(texels_per_block > 0);\npartition_metrics pms[4];\n- compute_avgs_and_dirs_3_comp(pt, blk, ewb, 3, pms);\n+ compute_avgs_and_dirs_3_comp(&pi, &blk, &ewb, 3, pms);\nendpoints ep;\n- if (plane2_component == -1)\n+\n+ // TODO: We only use the endpoints here, and throw away the weights.\n+ // That seems ... inefficient ...\n+ if (component_plane2 == -1)\n{\nendpoints_and_weights ei;\n- compute_endpoints_and_ideal_weights_1plane(bsd, pt, blk, ewb, &ei);\n+ compute_endpoints_and_ideal_weights_1plane(&bsd, &pi, &blk, &ewb, &ei);\nep = ei.ep;\n}\nelse\n{\nendpoints_and_weights ei1, ei2;\n- compute_endpoints_and_ideal_weights_2planes(bsd, pt, blk, ewb, plane2_component, &ei1, &ei2);\n- merge_endpoints(&(ei1.ep), &(ei2.ep), plane2_component, &ep);\n+ compute_endpoints_and_ideal_weights_2planes(&bsd, &pi, &blk, &ewb, component_plane2, &ei1, &ei2);\n+ merge_endpoints(ei1.ep, ei2.ep, component_plane2, ep);\n}\nfor (int i = 0; i < partition_count; i++)\n@@ -226,6 +231,7 @@ void compute_encoding_choice_errors(\nsamec_rgb_plines.bs = samec_rgb_lines.b * csf;\nsamec_rgb_plines.bis = samec_rgb_lines.b * icsf;\n+ // TODO - this is only used for HDR textures. Can we skip?\nrgb_luma_plines.amod = (rgb_luma_lines.a - rgb_luma_lines.b * dot3(rgb_luma_lines.a, rgb_luma_lines.b)) * icsf;\nrgb_luma_plines.bs = rgb_luma_lines.b * csf;\nrgb_luma_plines.bis = rgb_luma_lines.b * icsf;\n@@ -236,12 +242,12 @@ void compute_encoding_choice_errors(\nluminance_plines.bis = csfn * icsf;\ncompute_error_squared_rgb_single_partition(\n- i, pt, blk, ewb,\n- &uncor_rgb_plines, &uncorr_rgb_error,\n- &samec_rgb_plines, &samechroma_rgb_error,\n- &rgb_luma_plines, &rgb_luma_error,\n- &luminance_plines, &luminance_rgb_error,\n- &alpha_drop_error);\n+ pi, i, blk, ewb,\n+ uncor_rgb_plines, uncorr_rgb_error,\n+ samec_rgb_plines, samechroma_rgb_error,\n+ rgb_luma_plines, rgb_luma_error,\n+ luminance_plines, luminance_rgb_error,\n+ alpha_drop_error);\n// Determine if we can offset encode RGB lanes\nvfloat4 endpt0 = ep.endpt0[i];\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -374,7 +374,6 @@ struct partition_lines3\nEach index may be 0, 1, 2 or 3.\n* Each element in the table is an uint8_t indicating partition index (0, 1, 2 or 3)\n*/\n-\nstruct partition_info\n{\nint partition_count;\n@@ -1212,14 +1211,22 @@ float compute_error_of_weight_set_2planes(\nconst float* weights1,\nconst float* weights2);\n-void merge_endpoints(\n- const endpoints* ep1, // contains three of the color components\n- const endpoints* ep2, // contains the remaining color component\n- int plane2_component,\n- endpoints* res);\n-\n// functions dealing with color endpoints\n+/**\n+ * @brief Merge two planes of endpoints into a single vector.\n+ *\n+ * @param ep_plane1 The endpoints for plane 1.\n+ * @param ep_plane2 The endpoints for plane 2.\n+ * @param component_plane2 The color component for plane 2.\n+ * @param[out] result The merged output.\n+ */\n+void merge_endpoints(\n+ const endpoints& ep_plane1,\n+ const endpoints& ep_plane2,\n+ int component_plane2,\n+ endpoints& result);\n+\n// function to pack a pair of color endpoints into a series of integers.\n// the format used may or may not match the format specified;\n// the return value is the format actually used.\n@@ -1288,13 +1295,28 @@ struct compress_symbolic_block_buffers\ncompress_fixed_partition_buffers planes;\n};\n+\n+/**\n+ * @brief For a given set of input colors and partitioning determine endpoint encode errors.\n+ *\n+ * This function determines the color error that results from RGB-scale encoding (LDR only),\n+ * RGB-lumashift encoding (HDR only), luminance-encoding, and alpha drop. Also determines whether\n+ * the endpoints are eligible for offset encoding or blue-contraction\n+ *\n+ * @param bsd The block size information.\n+ * @param blk The image block.\n+ * @param pi The partition info data.\n+ * @param ewb The error weight block.\n+ * @param component_plane2 The component assigned to a second plane, or -1 if no second plane.\n+ * @param[out] eci The resulting encoding choice error metrics.\n+ */\nvoid compute_encoding_choice_errors(\n- const block_size_descriptor* bsd,\n- const imageblock* blk,\n- const partition_info* pt,\n- const error_weight_block* ewb,\n- int plane2_component, // component that is separated out in 2-plane mode, -1 in 1-plane mode\n- encoding_choice_errors* eci);\n+ const block_size_descriptor& bsd,\n+ const imageblock& blk,\n+ const partition_info& pi,\n+ const error_weight_block& ewb,\n+ int component_plane2,\n+ encoding_choice_errors eci[4]);\nvoid determine_optimal_set_of_endpoint_formats_to_use(\nconst block_size_descriptor* bsd,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"new_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"diff": "@@ -800,7 +800,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\n// encoding choices (such as using luminance instead of RGB, discarding Alpha,\n// using RGB-scale in place of two separate RGB endpoints and so on)\nencoding_choice_errors eci[4];\n- compute_encoding_choice_errors(bsd, blk, pt, ewb, plane2_component, eci);\n+ compute_encoding_choice_errors(*bsd, *blk, *pt, *ewb, plane2_component, eci);\n// for each partition, compute the error weights to apply for that partition.\npartition_metrics pms[4];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup astcenc_encoding_choice_error.cpp and add Doxygen
|
61,745 |
06.05.2021 08:46:37
| -3,600 |
c56fe5afb6a9406ea1f7e1fd0656e0334afd013a
|
Don't call compute_endpoints_and_ideal_weights twice
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "#include <cstring>\n#include <cstdio>\n+/**\n+ * @brief Merge two planes of endpoints into a single vector.\n+ *\n+ * @param ep_plane1 The endpoints for plane 1.\n+ * @param ep_plane2 The endpoints for plane 2.\n+ * @param component_plane2 The color component for plane 2.\n+ * @param[out] result The merged output.\n+ */\n+static void merge_endpoints(\n+ const endpoints& ep_plane1,\n+ const endpoints& ep_plane2,\n+ int component_plane2,\n+ endpoints& result\n+) {\n+ int partition_count = ep_plane1.partition_count;\n+ vmask4 sep_mask = vint4::lane_id() == vint4(component_plane2);\n+\n+ result.partition_count = partition_count;\n+ promise(partition_count > 0);\n+ for (int i = 0; i < partition_count; i++)\n+ {\n+ result.endpt0[i] = select(ep_plane1.endpt0[i], ep_plane2.endpt0[i], sep_mask);\n+ result.endpt1[i] = select(ep_plane1.endpt1[i], ep_plane2.endpt1[i], sep_mask);\n+ }\n+}\n+\n/**\n* @brief Attempt to improve weights given a chosen configuration.\n*\n@@ -331,7 +357,7 @@ static float compress_symbolic_block_fixed_partition_1plane(\nint color_quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\ndetermine_optimal_set_of_endpoint_formats_to_use(\n- bsd, pt, blk, ewb, &(ei->ep), -1, qwt_bitcounts, qwt_errors,\n+ bsd, pt, blk, ewb, &(ei->ep), qwt_bitcounts, qwt_errors,\ntune_candidate_limit, partition_format_specifiers, quantized_weight,\ncolor_quant_level, color_quant_level_mod);\n@@ -725,7 +751,7 @@ static float compress_symbolic_block_fixed_partition_2planes(\nmerge_endpoints(ei1->ep, ei2->ep, plane2_component, epm);\ndetermine_optimal_set_of_endpoint_formats_to_use(\n- bsd, pt, blk, ewb, &epm, plane2_component, qwt_bitcounts, qwt_errors,\n+ bsd, pt, blk, ewb, &epm, qwt_bitcounts, qwt_errors,\ntune_candidate_limit, partition_format_specifiers, quantized_weight,\ncolor_quant_level, color_quant_level_mod);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_encoding_choice_error.cpp",
"new_path": "Source/astcenc_encoding_choice_error.cpp",
"diff": "@@ -132,32 +132,13 @@ static void compute_error_squared_rgb_single_partition(\n}\n}\n-/* See header for documentation. */\n-void merge_endpoints(\n- const endpoints& ep_plane1,\n- const endpoints& ep_plane2,\n- int component_plane2,\n- endpoints& result\n-) {\n- int partition_count = ep_plane1.partition_count;\n- vmask4 sep_mask = vint4::lane_id() == vint4(component_plane2);\n-\n- result.partition_count = partition_count;\n- promise(partition_count > 0);\n- for (int i = 0; i < partition_count; i++)\n- {\n- result.endpt0[i] = select(ep_plane1.endpt0[i], ep_plane2.endpt0[i], sep_mask);\n- result.endpt1[i] = select(ep_plane1.endpt1[i], ep_plane2.endpt1[i], sep_mask);\n- }\n-}\n-\n/* See header for documentation. */\nvoid compute_encoding_choice_errors(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nconst partition_info& pi,\nconst error_weight_block& ewb,\n- int component_plane2,\n+ const endpoints& ep,\nencoding_choice_errors eci[4])\n{\nint partition_count = pi.partition_count;\n@@ -170,23 +151,6 @@ void compute_encoding_choice_errors(\ncompute_avgs_and_dirs_3_comp(&pi, &blk, &ewb, 3, pms);\n- endpoints ep;\n-\n- // TODO: We only use the endpoints here, and throw away the weights.\n- // That seems ... inefficient ...\n- if (component_plane2 == -1)\n- {\n- endpoints_and_weights ei;\n- compute_endpoints_and_ideal_weights_1plane(&bsd, &pi, &blk, &ewb, &ei);\n- ep = ei.ep;\n- }\n- else\n- {\n- endpoints_and_weights ei1, ei2;\n- compute_endpoints_and_ideal_weights_2planes(&bsd, &pi, &blk, &ewb, component_plane2, &ei1, &ei2);\n- merge_endpoints(ei1.ep, ei2.ep, component_plane2, ep);\n- }\n-\nfor (int i = 0; i < partition_count; i++)\n{\npartition_metrics& pm = pms[i];\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1213,20 +1213,6 @@ float compute_error_of_weight_set_2planes(\n// functions dealing with color endpoints\n-/**\n- * @brief Merge two planes of endpoints into a single vector.\n- *\n- * @param ep_plane1 The endpoints for plane 1.\n- * @param ep_plane2 The endpoints for plane 2.\n- * @param component_plane2 The color component for plane 2.\n- * @param[out] result The merged output.\n- */\n-void merge_endpoints(\n- const endpoints& ep_plane1,\n- const endpoints& ep_plane2,\n- int component_plane2,\n- endpoints& result);\n-\n// function to pack a pair of color endpoints into a series of integers.\n// the format used may or may not match the format specified;\n// the return value is the format actually used.\n@@ -1307,7 +1293,7 @@ struct compress_symbolic_block_buffers\n* @param blk The image block.\n* @param pi The partition info data.\n* @param ewb The error weight block.\n- * @param component_plane2 The component assigned to a second plane, or -1 if no second plane.\n+ * @param ep The idealized endpoints.\n* @param[out] eci The resulting encoding choice error metrics.\n*/\nvoid compute_encoding_choice_errors(\n@@ -1315,7 +1301,7 @@ void compute_encoding_choice_errors(\nconst imageblock& blk,\nconst partition_info& pi,\nconst error_weight_block& ewb,\n- int component_plane2,\n+ const endpoints& ep,\nencoding_choice_errors eci[4]);\nvoid determine_optimal_set_of_endpoint_formats_to_use(\n@@ -1324,7 +1310,6 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nconst imageblock* blk,\nconst error_weight_block* ewb,\nconst endpoints* ep,\n- int plane2_component, // separate color component for 2-plane mode; -1 for single-plane mode\n// bitcounts and errors computed for the various quantization methods\nconst int* qwt_bitcounts,\nconst float* qwt_errors,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"new_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"diff": "@@ -777,7 +777,6 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nconst imageblock* blk,\nconst error_weight_block* ewb,\nconst endpoints* ep,\n- int plane2_component, // separate color component for 2-plane mode; -1 for single-plane mode\n// bitcounts and errors computed for the various quantization methods\nconst int* qwt_bitcounts,\nconst float* qwt_errors,\n@@ -800,7 +799,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\n// encoding choices (such as using luminance instead of RGB, discarding Alpha,\n// using RGB-scale in place of two separate RGB endpoints and so on)\nencoding_choice_errors eci[4];\n- compute_encoding_choice_errors(*bsd, *blk, *pt, *ewb, plane2_component, eci);\n+ compute_encoding_choice_errors(*bsd, *blk, *pt, *ewb, *ep, eci);\n// for each partition, compute the error weights to apply for that partition.\npartition_metrics pms[4];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Don't call compute_endpoints_and_ideal_weights twice
|
61,745 |
06.05.2021 13:52:40
| -3,600 |
3b8541f077fa773147e11ea194dacc88064421d2
|
Fix out-of-date assert
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -807,7 +807,9 @@ void compute_ideal_weights_for_decimation_table(\n// TODO: Use SIMD copies?\nfor (int i = 0; i < texel_count_simd; i++)\n{\n- assert(i == dt.weight_texel[0][i]);\n+ // Assert it's an identity map for valid texels, and last valid value for any overspill\n+ assert((i < texel_count) && (i == dt.weight_texel[0][i]) ||\n+ (i >= texel_count) && (texel_count - 1 == dt.weight_texel[0][i]));\nweight_set[i] = eai_in.weights[i];\nweights[i] = eai_in.weight_error_scale[i];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Fix out-of-date assert
|
61,745 |
06.05.2021 22:13:10
| -3,600 |
b01c75bacd6be9b9419e347486460aff627e7aba
|
Fix color_scale assignment
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -205,7 +205,7 @@ static void compute_endpoints_and_ideal_weights_2_comp(\nif (error_weights[i] > 1e-10f)\n{\nint partition = pt->partition_of_texel[i];\n- float2 point = float2(data_vr[i], data_vg[i]) * float2(pms[partition].color_scale.lane<0>(), pms[partition].color_scale.lane<0>());\n+ float2 point = float2(data_vr[i], data_vg[i]) * float2(pms[partition].color_scale.lane<0>(), pms[partition].color_scale.lane<1>());\nline2 l = lines[partition];\nfloat param = dot(point - l.a, l.b);\nei->weights[i] = param;\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Fix color_scale assignment
|
61,745 |
06.05.2021 22:28:49
| -3,600 |
a3472605c9c73a30b336465666079ff208e0f996
|
Remove float2 and alias to 2 lanes of SIMD vfloat4
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_find_best_partitioning.cpp",
"new_path": "Source/astcenc_find_best_partitioning.cpp",
"diff": "@@ -389,37 +389,16 @@ void find_best_partitionings(\nif (!skip_two_plane)\n{\nsep_r_lines[j].a = pm.avg.swz<1, 2>();\n- float2 dirs_gb = pm.dir.swz<1, 2>();\n- if (dot(dirs_gb, dirs_gb) == 0.0f)\n- {\n- sep_r_lines[j].b = normalize(float2(1.0f));\n- }\n- else\n- {\n- sep_r_lines[j].b = normalize(dirs_gb);\n- }\n+ vfloat4 dirs_gb = pm.dir.swz<1, 2>();\n+ sep_r_lines[j].b = normalize_safe(dirs_gb, unit2());\nsep_g_lines[j].a = pm.avg.swz<0, 2>();\n- float2 dirs_rb = pm.dir.swz<0, 2>();\n- if (dot(dirs_rb, dirs_rb) == 0.0f)\n- {\n- sep_g_lines[j].b = normalize(float2(1.0f));\n- }\n- else\n- {\n- sep_g_lines[j].b = normalize(dirs_rb);\n- }\n+ vfloat4 dirs_rb = pm.dir.swz<0, 2>();\n+ sep_g_lines[j].b = normalize_safe(dirs_rb, unit2());\nsep_b_lines[j].a = pm.avg.swz<0, 1>();\n- float2 dirs_rg = pm.dir.swz<0, 1>();\n- if (dot(dirs_rg, dirs_rg) == 0.0f)\n- {\n- sep_b_lines[j].b = normalize(float2(1.0f));\n- }\n- else\n- {\n- sep_b_lines[j].b = normalize(dirs_rg);\n- }\n+ vfloat4 dirs_rg = pm.dir.swz<0, 1>();\n+ sep_b_lines[j].b = normalize_safe(dirs_rg, unit2());\nsep_r_plines[j].amod = (sep_r_lines[j].a - sep_r_lines[j].b * dot(sep_r_lines[j].a, sep_r_lines[j].b)) * pm.icolor_scale.swz<1, 2>();\nsep_r_plines[j].bs = (sep_r_lines[j].b * pm.color_scale.swz<1, 2>());\n@@ -482,17 +461,17 @@ void find_best_partitionings(\nif (!skip_two_plane)\n{\n- float2 sep_r_vector = sep_r_lines[j].b * ics.swz<1, 2>();\n- float2 sep_g_vector = sep_g_lines[j].b * ics.swz<0, 2>();\n- float2 sep_b_vector = sep_b_lines[j].b * ics.swz<0, 1>();\n+ vfloat4 sep_r_vector = sep_r_lines[j].b * ics.swz<1, 2>();\n+ vfloat4 sep_g_vector = sep_g_lines[j].b * ics.swz<0, 2>();\n+ vfloat4 sep_b_vector = sep_b_lines[j].b * ics.swz<0, 1>();\nsep_r_vector = sep_r_vector * sep_r_vector;\nsep_g_vector = sep_g_vector * sep_g_vector;\nsep_b_vector = sep_b_vector * sep_b_vector;\n- sep_error.set_lane<0>(sep_error.lane<0>() + dot(sep_r_vector, error_weights.swz<1, 2>()));\n- sep_error.set_lane<1>(sep_error.lane<1>() + dot(sep_g_vector, error_weights.swz<0, 2>()));\n- sep_error.set_lane<2>(sep_error.lane<2>() + dot(sep_b_vector, error_weights.swz<0, 1>()));\n+ sep_error.set_lane<0>(sep_error.lane<0>() + dot_s(sep_r_vector, error_weights.swz<1, 2>()));\n+ sep_error.set_lane<1>(sep_error.lane<1>() + dot_s(sep_g_vector, error_weights.swz<0, 2>()));\n+ sep_error.set_lane<2>(sep_error.lane<2>() + dot_s(sep_b_vector, error_weights.swz<0, 1>()));\nsep_error.set_lane<0>(sep_error.lane<0>() + pm.range_sq.lane<0>() * error_weights.lane<0>());\nsep_error.set_lane<1>(sep_error.lane<1>() + pm.range_sq.lane<1>() * error_weights.lane<1>());\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -183,21 +183,14 @@ static void compute_endpoints_and_ideal_weights_2_comp(\nfor (int i = 0; i < partition_count; i++)\n{\n- float2 dir = pms[i].dir.swz<0, 1>();\n- if (dir.r + dir.g < 0.0f)\n+ vfloat4 dir = pms[i].dir.swz<0, 1>();\n+ if (hadd_s(dir) < 0.0f)\n{\n- dir = float2(0.0f) - dir;\n+ dir = vfloat4::zero() - dir;\n}\nlines[i].a = pms[i].avg.swz<0, 1>();\n- if (dot(dir, dir) == 0.0f)\n- {\n- lines[i].b = normalize(float2(1.0f));\n- }\n- else\n- {\n- lines[i].b = normalize(dir);\n- }\n+ lines[i].b = normalize_safe(dir, unit2());\n}\nfor (int i = 0; i < texel_count; i++)\n@@ -205,9 +198,9 @@ static void compute_endpoints_and_ideal_weights_2_comp(\nif (error_weights[i] > 1e-10f)\n{\nint partition = pt->partition_of_texel[i];\n- float2 point = float2(data_vr[i], data_vg[i]) * float2(pms[partition].color_scale.lane<0>(), pms[partition].color_scale.lane<1>());\n+ vfloat4 point = vfloat2(data_vr[i], data_vg[i]) * pms[partition].color_scale.swz<0, 1>();\nline2 l = lines[partition];\n- float param = dot(point - l.a, l.b);\n+ float param = dot_s(point - l.a, l.b);\nei->weights[i] = param;\nlowparam[partition] = astc::min(param, lowparam[partition]);\n@@ -219,8 +212,8 @@ static void compute_endpoints_and_ideal_weights_2_comp(\n}\n}\n- float2 lowvalues[4];\n- float2 highvalues[4];\n+ vfloat4 lowvalues[4];\n+ vfloat4 highvalues[4];\nfor (int i = 0; i < partition_count; i++)\n{\n@@ -238,14 +231,12 @@ static void compute_endpoints_and_ideal_weights_2_comp(\nlength_squared[i] = length * length;\nscale[i] = 1.0f / length;\n- float2 ep0 = lines[i].a + lines[i].b * lowparam[i];\n- float2 ep1 = lines[i].a + lines[i].b * highparam[i];\n+ vfloat4 ep0 = lines[i].a + lines[i].b * lowparam[i];\n+ vfloat4 ep1 = lines[i].a + lines[i].b * highparam[i];\n- ep0.r /= pms[i].color_scale.lane<0>();\n- ep0.g /= pms[i].color_scale.lane<1>();\n+ ep0 = ep0.swz<0, 1>() / pms[i].color_scale;\n- ep1.r /= pms[i].color_scale.lane<0>();\n- ep1.g /= pms[i].color_scale.lane<1>();\n+ ep1 = ep1.swz<0, 1>() / pms[i].color_scale;\nlowvalues[i] = ep0;\nhighvalues[i] = ep1;\n@@ -255,11 +246,11 @@ static void compute_endpoints_and_ideal_weights_2_comp(\nvmask4 comp2_mask = vint4::lane_id() == vint4(component2);\nfor (int i = 0; i < partition_count; i++)\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+ vfloat4 ep0 = select(blk->data_min, vfloat4(lowvalues[i].lane<0>()), comp1_mask);\n+ vfloat4 ep1 = select(blk->data_max, vfloat4(highvalues[i].lane<0>()), comp1_mask);\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+ ei->ep.endpt0[i] = select(ep0, vfloat4(lowvalues[i].lane<1>()), comp2_mask);\n+ ei->ep.endpt1[i] = select(ep1, vfloat4(highvalues[i].lane<1>()), comp2_mask);\n}\nbool is_constant_wes = true;\n@@ -365,7 +356,7 @@ static void compute_endpoints_and_ideal_weights_3_comp(\nif (error_weights[i] > 1e-10f)\n{\nint partition = pt->partition_of_texel[i];\n- vfloat4 point = vfloat4(data_vr[i], data_vg[i], data_vb[i], 0.0f) * pms[partition].color_scale;\n+ vfloat4 point = vfloat3(data_vr[i], data_vg[i], data_vb[i]) * pms[partition].color_scale;\nline3 l = lines[partition];\nfloat param = dot3_s(point - l.a, l.b);\nei->weights[i] = param;\n@@ -1141,7 +1132,7 @@ void recompute_ideal_colors_2planes(\nvfloat4 color_vec_x = vfloat4::zero();\nvfloat4 color_vec_y = vfloat4::zero();\n- float2 scale_vec = float2(0.0f);\n+ vfloat4 scale_vec = vfloat4::zero();\nvfloat4 weight_weight_sum = vfloat4(1e-17f);\nfloat psum = 1e-17f;\n@@ -1207,7 +1198,7 @@ void recompute_ideal_colors_2planes(\ncolor_vec_y += cwiprod;\ncolor_vec_x += cwprod - cwiprod;\n- scale_vec += float2(om_idx0, idx0) * (ls_weight * scale);\n+ scale_vec += vfloat2(om_idx0, idx0) * (ls_weight * scale);\nweight_weight_sum += (color_weight * color_idx);\npsum += dot3_s(color_weight * color_idx, color_idx);\n}\n@@ -1273,8 +1264,8 @@ void recompute_ideal_colors_2planes(\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.lane<2>() * scale_vec.r - lmrs_sum.lane<1>() * scale_vec.g) * ls_rdet1;\n- float scale_ep1 = (lmrs_sum.lane<0>() * scale_vec.g - lmrs_sum.lane<1>() * scale_vec.r) * ls_rdet1;\n+ float scale_ep0 = (lmrs_sum.lane<2>() * scale_vec.lane<0>() - lmrs_sum.lane<1>() * scale_vec.lane<1>()) * ls_rdet1;\n+ float scale_ep1 = (lmrs_sum.lane<0>() * scale_vec.lane<1>() - lmrs_sum.lane<1>() * scale_vec.lane<0>()) * ls_rdet1;\nvmask4 p1_mask = vint4::lane_id() != vint4(plane2_component);\nvmask4 det_mask = abs(color_det1) > (color_mss1 * 1e-4f);\n@@ -1408,7 +1399,7 @@ void recompute_ideal_colors_1plane(\nvfloat4 color_vec_x = vfloat4::zero();\nvfloat4 color_vec_y = vfloat4::zero();\n- float2 scale_vec = float2(0.0f);\n+ vfloat4 scale_vec = vfloat4::zero();\nvfloat4 weight_weight_sum = vfloat4(1e-17f);\nfloat psum = 1e-17f;\n@@ -1454,7 +1445,7 @@ void recompute_ideal_colors_1plane(\ncolor_vec_y += cwiprod;\ncolor_vec_x += cwprod - cwiprod;\n- scale_vec += (float2(om_idx0, idx0) * (ls_weight * scale));\n+ scale_vec += vfloat2(om_idx0, idx0) * (ls_weight * scale);\nweight_weight_sum += color_weight * color_idx;\npsum += dot3_s(color_weight * color_idx, color_idx);\n}\n@@ -1524,8 +1515,8 @@ void recompute_ideal_colors_1plane(\nep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);\nep->endpt1[i] = select(ep->endpt1[i], ep1, full_mask);\n- float scale_ep0 = (lmrs_sum.lane<2>() * scale_vec.r - lmrs_sum.lane<1>() * scale_vec.g) * ls_rdet1;\n- float scale_ep1 = (lmrs_sum.lane<0>() * scale_vec.g - lmrs_sum.lane<1>() * scale_vec.r) * ls_rdet1;\n+ float scale_ep0 = (lmrs_sum.lane<2>() * scale_vec.lane<0>() - lmrs_sum.lane<1>() * scale_vec.lane<1>()) * ls_rdet1;\n+ float scale_ep1 = (lmrs_sum.lane<0>() * scale_vec.lane<1>() - lmrs_sum.lane<1>() * scale_vec.lane<0>()) * ls_rdet1;\nif (fabsf(ls_det1) > (ls_mss1 * 1e-4f) && scale_ep0 == scale_ep0 && scale_ep1 == scale_ep1 && scale_ep0 < scale_ep1)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_mathlib.h",
"new_path": "Source/astcenc_mathlib.h",
"diff": "@@ -415,78 +415,6 @@ uint64_t rand(uint64_t state[2]);\n}\n-/* ============================================================================\n- Utility vector template classes with basic operations\n-============================================================================ */\n-\n-template <typename T> class vtype2\n-{\n-public:\n- // Data storage\n- T r, g;\n-\n- // Default constructor\n- vtype2() {}\n-\n- // Initialize from 1 scalar\n- vtype2(T p) : r(p), g(p) {}\n-\n- // Initialize from N scalars\n- vtype2(T p, T q) : r(p), g(q) {}\n-\n- // Initialize from another vector\n- vtype2(const vtype2 & p) : r(p.r), g(p.g) {}\n-\n- // Assignment operator\n- vtype2& operator=(const vtype2 &s) {\n- this->r = s.r;\n- this->g = s.g;\n- return *this;\n- }\n-};\n-\n-// Vector by vector addition\n-template <typename T>\n-vtype2<T> operator+(vtype2<T> p, vtype2<T> q) {\n- return vtype2<T> { p.r + q.r, p.g + q.g };\n-}\n-\n-template <typename T>\n-vtype2<T>& operator+=(vtype2<T>& p, const vtype2<T>& q) {\n- p = p + q;\n- return p;\n-}\n-\n-// Vector by vector subtraction\n-template <typename T>\n-vtype2<T> operator-(vtype2<T> p, vtype2<T> q) {\n- return vtype2<T> { p.r - q.r, p.g - q.g };\n-}\n-\n-// Vector by vector multiplication operator\n-template <typename T>\n-vtype2<T> operator*(vtype2<T> p, vtype2<T> q) {\n- return vtype2<T> { p.r * q.r, p.g * q.g };\n-}\n-\n-// Vector by scalar multiplication operator\n-template <typename T>\n-vtype2<T> operator*(vtype2<T> p, T q) {\n- return vtype2<T> { p.r * q, p.g * q };\n-}\n-\n-// Scalar by vector multiplication operator\n-template <typename T>\n-vtype2<T> operator*(T p, vtype2<T> q) {\n- return vtype2<T> { p * q.r, p * q.g };\n-}\n-\n-typedef vtype2<float> float2;\n-\n-static inline float dot(float2 p, float2 q) { return p.r * q.r + p.g * q.g; }\n-\n-static inline float2 normalize(float2 p) { return p * astc::rsqrt(dot(p, p)); }\n-\n/* ============================================================================\nSoftfloat library with fp32 and fp16 conversion functionality.\n============================================================================ */\n@@ -508,8 +436,8 @@ static inline float2 normalize(float2 p) { return p * astc::rsqrt(dot(p, p)); }\nstruct line2\n{\n- float2 a;\n- float2 b;\n+ vfloat4 a;\n+ vfloat4 b;\n};\n// parametric line, 3D\n@@ -528,9 +456,9 @@ struct line4\nstruct processed_line2\n{\n- float2 amod;\n- float2 bs;\n- float2 bis;\n+ vfloat4 amod;\n+ vfloat4 bs;\n+ vfloat4 bis;\n};\nstruct processed_line3\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_vecmathlib.h",
"new_path": "Source/astcenc_vecmathlib.h",
"diff": "@@ -246,6 +246,30 @@ static ASTCENC_SIMD_INLINE vfloat4 unit3()\nreturn vfloat4(0.57735f, 0.57735f, 0.57735f, 0.0f);\n}\n+/**\n+ * @brief Factory that returns a unit length 2 component vfloat4.\n+ */\n+static ASTCENC_SIMD_INLINE vfloat4 unit2()\n+{\n+ return vfloat4(0.70711f, 0.70711f, 0.0f, 0.0f);\n+}\n+\n+/**\n+ * @brief Factory that returns a 3 component vfloat4.\n+ */\n+static ASTCENC_SIMD_INLINE vfloat4 vfloat3(float a, float b, float c)\n+{\n+ return vfloat4(a, b, c, 0.0f);\n+}\n+\n+/**\n+ * @brief Factory that returns a 2 component vfloat4.\n+ */\n+static ASTCENC_SIMD_INLINE vfloat4 vfloat2(float a, float b)\n+{\n+ return vfloat4(a, b, 0.0f, 0.0f);\n+}\n+\n/**\n* @brief Normalize a non-zero length vector to unit length.\n*/\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_vecmathlib_neon_4.h",
"new_path": "Source/astcenc_vecmathlib_neon_4.h",
"diff": "@@ -148,10 +148,12 @@ struct vfloat4\n/**\n* @brief Return a swizzled float 2.\n+ *\n+ * TODO: Implement using permutes.\n*/\n- template <int l0, int l1> ASTCENC_SIMD_INLINE float2 swz() const\n+ template <int l0, int l1> ASTCENC_SIMD_INLINE vfloat4 swz() const\n{\n- return float2(lane<l0>(), lane<l1>());\n+ return vfloat4(lane<l0>(), lane<l1>(), 0.0f, 0.0f);\n}\n/**\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_vecmathlib_none_4.h",
"new_path": "Source/astcenc_vecmathlib_none_4.h",
"diff": "@@ -152,7 +152,7 @@ struct vfloat4\n*/\ntemplate <int l0, int l1> ASTCENC_SIMD_INLINE float2 swz() const\n{\n- return float2(lane<l0>(), lane<l1>());\n+ return vfloat4(lane<l0>(), lane<l1>(), 0.0f, 0.0f);\n}\n/**\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_vecmathlib_sse_4.h",
"new_path": "Source/astcenc_vecmathlib_sse_4.h",
"diff": "@@ -152,9 +152,12 @@ struct vfloat4\n/**\n* @brief Return a swizzled float 2.\n*/\n- template <int l0, int l1> ASTCENC_SIMD_INLINE float2 swz() const\n+ template <int l0, int l1> ASTCENC_SIMD_INLINE vfloat4 swz() const\n{\n- return float2(lane<l0>(), lane<l1>());\n+ vfloat4 result(_mm_shuffle_ps(m, m, l0 | l1 << 2));\n+ result.set_lane<2>(0.0f);\n+ result.set_lane<3>(0.0f);\n+ return result;\n}\n/**\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Remove float2 and alias to 2 lanes of SIMD vfloat4
|
61,745 |
06.05.2021 22:35:29
| -3,600 |
47641ede48ba9882f85f0e88d0d7ad74e4358511
|
Use vfloat2/3 factories where is makes sense to
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_averages_and_directions.cpp",
"new_path": "Source/astcenc_averages_and_directions.cpp",
"diff": "@@ -247,10 +247,9 @@ void compute_avgs_and_dirs_3_comp(\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n- vfloat4 texel_datum = vfloat4(data_vr[iwt],\n+ vfloat4 texel_datum = vfloat3(data_vr[iwt],\ndata_vg[iwt],\n- data_vb[iwt],\n- 0.0f);\n+ data_vb[iwt]);\ntexel_datum = (texel_datum - average) * weight;\nvfloat4 zero = vfloat4::zero();\n@@ -285,7 +284,7 @@ void compute_avgs_and_dirs_3_comp(\nif (dot3_s(best_vector, best_vector) < 1e-18f)\n{\n- best_vector = vfloat4(1.0f, 1.0f, 1.0f, 0.0f);\n+ best_vector = vfloat3(1.0f, 1.0f, 1.0f);\n}\npm[partition].dir = best_vector;\n@@ -359,9 +358,9 @@ void compute_avgs_and_dirs_2_comp(\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n- vfloat4 texel_datum = vfloat4(data_vr[iwt], data_vg[iwt], 0.0f, 0.0f) * weight;\n+ vfloat4 texel_datum = vfloat2(data_vr[iwt], data_vg[iwt]) * weight;\n- vfloat4 error_weight = vfloat4(error_vr[iwt], error_vg[iwt], 0.0f, 0.0f);\n+ vfloat4 error_weight = vfloat2(error_vr[iwt], error_vg[iwt]);\npartition_weight += weight;\nbase_sum += texel_datum;\n@@ -385,7 +384,7 @@ void compute_avgs_and_dirs_2_comp(\n{\nint iwt = weights[i];\nfloat weight = texel_weights[iwt];\n- vfloat4 texel_datum = vfloat4(data_vr[iwt], data_vg[iwt], 0.0f, 0.0f);\n+ vfloat4 texel_datum = vfloat2(data_vr[iwt], data_vg[iwt]);\ntexel_datum = (texel_datum - average) * weight;\nvfloat4 zero = vfloat4::zero();\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_find_best_partitioning.cpp",
"new_path": "Source/astcenc_find_best_partitioning.cpp",
"diff": "@@ -416,7 +416,7 @@ void find_best_partitionings(\nfloat uncor_error = 0.0f;\nfloat samec_error = 0.0f;\n- vfloat4 sep_error = vfloat4(0.0f);\n+ vfloat4 sep_error = vfloat4::zero();\ncompute_error_squared_rgb(ptab + partition,\nblk,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -1162,10 +1162,9 @@ void recompute_ideal_colors_2planes(\nvfloat4 middle = color_weight * (om_idx0 * idx0);\nvfloat4 right = color_weight * (idx0 * idx0);\n- vfloat4 lmrs = vfloat4(om_idx0 * om_idx0,\n+ vfloat4 lmrs = vfloat3(om_idx0 * om_idx0,\nom_idx0 * idx0,\n- idx0 * idx0,\n- 0.0f) * ls_weight;\n+ idx0 * idx0) * ls_weight;\nleft_sum += left;\nmiddle_sum += middle;\n@@ -1428,10 +1427,9 @@ void recompute_ideal_colors_1plane(\nvfloat4 middle = color_weight * (om_idx0 * idx0);\nvfloat4 right = color_weight * (idx0 * idx0);\n- vfloat4 lmrs = vfloat4(om_idx0 * om_idx0,\n+ vfloat4 lmrs = vfloat3(om_idx0 * om_idx0,\nom_idx0 * idx0,\n- idx0 * idx0,\n- 0.0f) * ls_weight;\n+ idx0 * idx0) * ls_weight;\nleft_sum += left;\nmiddle_sum += middle;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -543,10 +543,9 @@ struct imageblock\ninline vfloat4 texel3(int index) const\n{\n- return vfloat4(data_r[index],\n+ return vfloat3(data_r[index],\ndata_g[index],\n- data_b[index],\n- 0.0f);\n+ data_b[index]);\n}\n};\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use vfloat2/3 factories where is makes sense to
|
61,745 |
06.05.2021 22:50:52
| -3,600 |
32c9d858727cfb4f804484eb39ca384fd84ae9c5
|
Remove legacy #define that's always true
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"new_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"diff": "@@ -1054,7 +1054,6 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nint best_quant_levels_mod[MAX_WEIGHT_MODES];\nint best_ep_formats[MAX_WEIGHT_MODES][4];\n-#if ASTCENC_SIMD_WIDTH > 1\n// have to ensure that the \"overstep\" of the last iteration in the vectorized\n// loop will contain data that will never be picked as best candidate\nconst int packed_mode_count = bsd->block_mode_count;\n@@ -1065,7 +1064,6 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nbest_quant_levels[i] = 0;\nbest_quant_levels_mod[i] = 0;\n}\n-#endif // #if ASTCENC_SIMD_WIDTH > 1\n// code for the case where the block contains 1 partition\nif (partition_count == 1)\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Remove legacy #define that's always true
|
61,745 |
06.05.2021 23:06:11
| -3,600 |
07925527f31f2000edf058a992143855b73b6559
|
Use a bool return for queries
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -825,18 +825,18 @@ const float *get_2d_percentile_table(\n/**\n* @brief Query if a 2D block size is legal.\n*\n- * @return A non-zero value if legal, zero otherwise.\n+ * @return True if legal, false otherwise.\n*/\n-int is_legal_2d_block_size(\n+bool is_legal_2d_block_size(\nint xdim,\nint ydim);\n/**\n* @brief Query if a 3D block size is legal.\n*\n- * @return A non-zero value if legal, zero otherwise.\n+ * @return True if legal, false otherwise.\n*/\n-int is_legal_3d_block_size(\n+bool is_legal_3d_block_size(\nint xdim,\nint ydim,\nint zdim);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_percentile_tables.cpp",
"new_path": "Source/astcenc_percentile_tables.cpp",
"diff": "@@ -1151,7 +1151,7 @@ const float *get_2d_percentile_table(\n#endif\n/* Public function, see header file for detailed documentation */\n-int is_legal_2d_block_size(\n+bool is_legal_2d_block_size(\nint xdim,\nint ydim\n) {\n@@ -1172,14 +1172,14 @@ int is_legal_2d_block_size(\ncase 0x0A0A:\ncase 0x0C0A:\ncase 0x0C0C:\n- return 1;\n+ return true;\n}\n- return 0;\n+ return false;\n}\n/* Public function, see header file for detailed documentation */\n-int is_legal_3d_block_size(\n+bool is_legal_3d_block_size(\nint xdim,\nint ydim,\nint zdim\n@@ -1197,8 +1197,8 @@ int is_legal_3d_block_size(\ncase 0x060505:\ncase 0x060605:\ncase 0x060606:\n- return 1;\n- default:\n- return 0;\n+ return true;\n}\n+\n+ return false;\n}\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use a bool return for queries
|
61,745 |
07.05.2021 17:01:27
| -3,600 |
21a037e23997d9eff405e4a671cc02adc8d8e7eb
|
Fix typo in none SIMD file
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_vecmathlib_none_4.h",
"new_path": "Source/astcenc_vecmathlib_none_4.h",
"diff": "@@ -150,7 +150,7 @@ struct vfloat4\n/**\n* @brief Return a swizzled float 2.\n*/\n- template <int l0, int l1> ASTCENC_SIMD_INLINE float2 swz() const\n+ template <int l0, int l1> ASTCENC_SIMD_INLINE vfloat4 swz() const\n{\nreturn vfloat4(lane<l0>(), lane<l1>(), 0.0f, 0.0f);\n}\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Fix typo in none SIMD file
|
61,745 |
07.05.2021 17:16:24
| -3,600 |
b6d3af2ffe059b0254e90be9c99a8de187b0db5a
|
Add missing refactor of vfloat2 test file
|
[
{
"change_type": "MODIFY",
"old_path": "Source/UnitTest/test_simd.cpp",
"new_path": "Source/UnitTest/test_simd.cpp",
"diff": "@@ -412,13 +412,13 @@ TEST(vfloat4, swz3)\nTEST(vfloat4, swz2)\n{\nvfloat4 a(1.0f, 2.0f, 3.0f, 4.0f);\n- float2 r = a.swz<0, 3>();\n- EXPECT_EQ(r.r, 1.0f);\n- EXPECT_EQ(r.g, 4.0f);\n+ vfloat4 r = a.swz<0, 3>();\n+ EXPECT_EQ(r.lane<0>(), 1.0f);\n+ EXPECT_EQ(r.lane<1>(), 4.0f);\nr = a.swz<2, 1>();\n- EXPECT_EQ(r.r, 3.0f);\n- EXPECT_EQ(r.g, 2.0f);\n+ EXPECT_EQ(r.lane<0>(), 3.0f);\n+ EXPECT_EQ(r.lane<1>(), 2.0f);\n}\n/** @brief Test vfloat4 add. */\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add missing refactor of vfloat2 test file
|
61,745 |
07.05.2021 17:28:40
| -3,600 |
9a0392450d63c692666be047d194b35c1e7bbdf4
|
Add parens for GCC SA warning
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -799,8 +799,8 @@ void compute_ideal_weights_for_decimation_table(\nfor (int i = 0; i < texel_count_simd; i++)\n{\n// Assert it's an identity map for valid texels, and last valid value for any overspill\n- assert((i < texel_count) && (i == dt.weight_texel[0][i]) ||\n- (i >= texel_count) && (texel_count - 1 == dt.weight_texel[0][i]));\n+ assert(((i < texel_count) && (i == dt.weight_texel[0][i])) ||\n+ ((i >= texel_count) && (texel_count - 1 == dt.weight_texel[0][i])));\nweight_set[i] = eai_in.weights[i];\nweights[i] = eai_in.weight_error_scale[i];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Add parens for GCC SA warning
|
61,745 |
10.05.2021 20:53:50
| -3,600 |
538fc235d200dc25809319deb434248796cb144a
|
Clean up function signatures for compute_avgs_and_dirs_*_comp
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_averages_and_directions.cpp",
"new_path": "Source/astcenc_averages_and_directions.cpp",
"diff": "#include <cassert>\n-// For a full block, functions to compute averages and dominant directions. The\n-// averages and directions are computed separately for each partition.\n-// We have separate versions for blocks with and without alpha, since the\n-// processing for blocks with alpha is significantly more expensive. The\n-// direction vectors it produces are NOT normalized.\n+/* See header for documentation. */\nvoid compute_avgs_and_dirs_4_comp(\n- const partition_info* pt,\n- const imageblock* blk,\n- const error_weight_block* ewb,\n+ const partition_info& pi,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\npartition_metrics pm[4]\n) {\n- int partition_count = pt->partition_count;\n+ int partition_count = pi.partition_count;\npromise(partition_count > 0);\nfor (int partition = 0; partition < partition_count; partition++)\n{\n- const uint8_t *weights = pt->texels_of_partition[partition];\n+ const uint8_t *weights = pi.texels_of_partition[partition];\nvfloat4 error_sum = vfloat4::zero();\nvfloat4 base_sum = vfloat4::zero();\n@@ -48,15 +44,15 @@ void compute_avgs_and_dirs_4_comp(\nvfloat4 rgba_max(-1e38f);\nfloat partition_weight = 0.0f;\n- int texel_count = pt->partition_texel_count[partition];\n+ int texel_count = pi.partition_texel_count[partition];\npromise(texel_count > 0);\nfor (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\n- float weight = ewb->texel_weight[iwt];\n- vfloat4 texel_datum = blk->texel(iwt);\n- vfloat4 error_weight = ewb->error_weights[iwt];\n+ float weight = ewb.texel_weight[iwt];\n+ vfloat4 texel_datum = blk.texel(iwt);\n+ vfloat4 error_weight = ewb.error_weights[iwt];\nif (weight > 1e-10f)\n{\n@@ -89,8 +85,8 @@ void compute_avgs_and_dirs_4_comp(\nfor (int i = 0; i < texel_count; i++)\n{\nint iwt = weights[i];\n- float weight = ewb->texel_weight[iwt];\n- vfloat4 texel_datum = blk->texel(iwt);\n+ float weight = ewb.texel_weight[iwt];\n+ vfloat4 texel_datum = blk.texel(iwt);\ntexel_datum = (texel_datum - average) * weight;\nvfloat4 zero = vfloat4::zero();\n@@ -137,60 +133,61 @@ void compute_avgs_and_dirs_4_comp(\n}\n}\n+/* See header for documentation. */\nvoid compute_avgs_and_dirs_3_comp(\n- const partition_info* pt,\n- const imageblock* blk,\n- const error_weight_block* ewb,\n+ const partition_info& pi,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\nint omitted_component,\npartition_metrics pm[4]\n) {\n- const float *texel_weights = ewb->texel_weight_rgb;\n+ const float *texel_weights = ewb.texel_weight_rgb;\n- const float* data_vr = blk->data_r;\n- const float* data_vg = blk->data_g;\n- const float* data_vb = blk->data_b;\n+ const float* data_vr = blk.data_r;\n+ const float* data_vg = blk.data_g;\n+ const float* data_vb = blk.data_b;\n- const float* error_vr = ewb->texel_weight_r;\n- const float* error_vg = ewb->texel_weight_g;\n- const float* error_vb = ewb->texel_weight_b;\n+ const float* error_vr = ewb.texel_weight_r;\n+ const float* error_vg = ewb.texel_weight_g;\n+ const float* error_vb = ewb.texel_weight_b;\nif (omitted_component == 0)\n{\n- texel_weights = ewb->texel_weight_gba;\n+ texel_weights = ewb.texel_weight_gba;\n- data_vr = blk->data_g;\n- data_vg = blk->data_b;\n- data_vb = blk->data_a;\n+ data_vr = blk.data_g;\n+ data_vg = blk.data_b;\n+ data_vb = blk.data_a;\n- error_vr = ewb->texel_weight_g;\n- error_vg = ewb->texel_weight_b;\n- error_vb = ewb->texel_weight_a;\n+ error_vr = ewb.texel_weight_g;\n+ error_vg = ewb.texel_weight_b;\n+ error_vb = ewb.texel_weight_a;\n}\nelse if (omitted_component == 1)\n{\n- texel_weights = ewb->texel_weight_rba;\n+ texel_weights = ewb.texel_weight_rba;\n- data_vg = blk->data_b;\n- data_vb = blk->data_a;\n+ data_vg = blk.data_b;\n+ data_vb = blk.data_a;\n- error_vg = ewb->texel_weight_b;\n- error_vb = ewb->texel_weight_a;\n+ error_vg = ewb.texel_weight_b;\n+ error_vb = ewb.texel_weight_a;\n}\nelse if (omitted_component == 2)\n{\n- texel_weights = ewb->texel_weight_rga;\n+ texel_weights = ewb.texel_weight_rga;\n- data_vb = blk->data_a;\n+ data_vb = blk.data_a;\n- error_vb = ewb->texel_weight_a;\n+ error_vb = ewb.texel_weight_a;\n}\n- int partition_count = pt->partition_count;\n+ int partition_count = pi.partition_count;\npromise(partition_count > 0);\nfor (int partition = 0; partition < partition_count; partition++)\n{\n- const uint8_t *weights = pt->texels_of_partition[partition];\n+ const uint8_t *weights = pi.texels_of_partition[partition];\nvfloat4 error_sum = vfloat4::zero();\nvfloat4 base_sum = vfloat4::zero();\n@@ -198,7 +195,7 @@ void compute_avgs_and_dirs_3_comp(\nvfloat4 rgb_max(-1e38f);\nfloat partition_weight = 0.0f;\n- int texel_count = pt->partition_texel_count[partition];\n+ int texel_count = pi.partition_texel_count[partition];\npromise(texel_count > 0);\nfor (int i = 0; i < texel_count; i++)\n@@ -291,10 +288,11 @@ void compute_avgs_and_dirs_3_comp(\n}\n}\n+/* See header for documentation. */\nvoid compute_avgs_and_dirs_2_comp(\n- const partition_info* pt,\n- const imageblock* blk,\n- const error_weight_block* ewb,\n+ const partition_info& pt,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\nint component1,\nint component2,\npartition_metrics pm[4]\n@@ -309,49 +307,49 @@ void compute_avgs_and_dirs_2_comp(\nif (component1 == 0 && component2 == 1)\n{\n- texel_weights = ewb->texel_weight_rg;\n+ texel_weights = ewb.texel_weight_rg;\n- data_vr = blk->data_r;\n- data_vg = blk->data_g;\n+ data_vr = blk.data_r;\n+ data_vg = blk.data_g;\n- error_vr = ewb->texel_weight_r;\n- error_vg = ewb->texel_weight_g;\n+ error_vr = ewb.texel_weight_r;\n+ error_vg = ewb.texel_weight_g;\n}\nelse if (component1 == 0 && component2 == 2)\n{\n- texel_weights = ewb->texel_weight_rb;\n+ texel_weights = ewb.texel_weight_rb;\n- data_vr = blk->data_r;\n- data_vg = blk->data_b;\n+ data_vr = blk.data_r;\n+ data_vg = blk.data_b;\n- error_vr = ewb->texel_weight_r;\n- error_vg = ewb->texel_weight_b;\n+ error_vr = ewb.texel_weight_r;\n+ error_vg = ewb.texel_weight_b;\n}\nelse // (component1 == 1 && component2 == 2)\n{\nassert(component1 == 1 && component2 == 2);\n- texel_weights = ewb->texel_weight_gb;\n+ texel_weights = ewb.texel_weight_gb;\n- data_vr = blk->data_g;\n- data_vg = blk->data_b;\n+ data_vr = blk.data_g;\n+ data_vg = blk.data_b;\n- error_vr = ewb->texel_weight_g;\n- error_vg = ewb->texel_weight_b;\n+ error_vr = ewb.texel_weight_g;\n+ error_vg = ewb.texel_weight_b;\n}\n- int partition_count = pt->partition_count;\n+ int partition_count = pt.partition_count;\npromise(partition_count > 0);\nfor (int partition = 0; partition < partition_count; partition++)\n{\n- const uint8_t *weights = pt->texels_of_partition[partition];\n+ const uint8_t *weights = pt.texels_of_partition[partition];\nvfloat4 error_sum = vfloat4::zero();\nvfloat4 base_sum = vfloat4::zero();\nfloat partition_weight = 0.0f;\n- int texel_count = pt->partition_texel_count[partition];\n+ int texel_count = pt.partition_texel_count[partition];\npromise(texel_count > 0);\nfor (int i = 0; i < texel_count; i++)\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_find_best_partitioning.cpp",
"new_path": "Source/astcenc_find_best_partitioning.cpp",
"diff": "@@ -152,7 +152,7 @@ void find_best_partitionings(\n// Compute weighting to give to each component in each partition\npartition_metrics pms[4];\n- compute_avgs_and_dirs_4_comp(ptab + partition, blk, ewb, pms);\n+ compute_avgs_and_dirs_4_comp(*(ptab + partition), *blk, *ewb, pms);\nline4 uncor_lines[4];\nline4 samec_lines[4];\n@@ -355,7 +355,7 @@ void find_best_partitionings(\n// Compute weighting to give to each component in each partition\npartition_metrics pms[4];\n- compute_avgs_and_dirs_3_comp(ptab + partition, blk, ewb, 3, pms);\n+ compute_avgs_and_dirs_3_comp(*(ptab + partition), *blk, *ewb, 3, pms);\npartition_lines3 plines[4];\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -179,7 +179,7 @@ static void compute_endpoints_and_ideal_weights_2_comp(\nfloat scale[4];\nfloat length_squared[4];\n- compute_avgs_and_dirs_2_comp(pt, blk, ewb, component1, component2, pms);\n+ compute_avgs_and_dirs_2_comp(*pt, *blk, *ewb, component1, component2, pms);\nfor (int i = 0; i < partition_count; i++)\n{\n@@ -337,7 +337,7 @@ static void compute_endpoints_and_ideal_weights_3_comp(\nfloat scale[4];\nfloat length_squared[4];\n- compute_avgs_and_dirs_3_comp(pt, blk, ewb, omitted_component, pms);\n+ compute_avgs_and_dirs_3_comp(*pt, *blk, *ewb, omitted_component, pms);\nfor (int i = 0; i < partition_count; i++)\n{\n@@ -472,7 +472,7 @@ static void compute_endpoints_and_ideal_weights_4_comp(\npartition_metrics pms[4];\n- compute_avgs_and_dirs_4_comp(pt, blk, ewb, pms);\n+ compute_avgs_and_dirs_4_comp(*pt, *blk, *ewb, pms);\n// if the direction-vector ends up pointing from light to dark, FLIP IT!\n// this will make the first endpoint the darkest one.\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -883,25 +883,56 @@ void build_quant_mode_table(void);\n// functions and data pertaining to partitioning\n// **********************************************\n-// functions to compute color averages and dominant directions\n-// for each partition in a block\n+/**\n+ * @brief Compute averages and dominant directions for each partition in a 4 component texture.\n+ *\n+ * @param pi The partition info for the current trial.\n+ * @param blk The image block color data to be compressed.\n+ * @param ewb The image block weighted error data.\n+ * @param[out] pm The output partition metrics.\n+ * - Only pi.partition_count array entries actually get initialized.\n+ * - Direction vectors @c pm.dir are not normalized.\n+ */\nvoid compute_avgs_and_dirs_4_comp(\n- const partition_info* pt,\n- const imageblock* blk,\n- const error_weight_block* ewb,\n+ const partition_info& pi,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\npartition_metrics pm[4]);\n+/**\n+ * @brief Compute averages and dominant directions for each partition in a 3 component texture.\n+ *\n+ * @param pi The partition info for the current trial.\n+ * @param blk The image block color data to be compressed.\n+ * @param ewb The image block weighted error data.\n+ * @param omitted_component The component excluded from the analysis.\n+ * @param[out] pm The output partition metrics.\n+ * - Only pi.partition_count array entries actually get initialized.\n+ * - Direction vectors @c pm.dir are not normalized.\n+ */\nvoid compute_avgs_and_dirs_3_comp(\n- const partition_info* pt,\n- const imageblock* blk,\n- const error_weight_block* ewb,\n+ const partition_info& pi,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\nint omitted_component,\npartition_metrics pm[4]);\n+/**\n+ * @brief Compute averages and dominant directions for each partition in a 2 component texture.\n+ *\n+ * @param pi The partition info for the current trial.\n+ * @param blk The image block color data to be compressed.\n+ * @param ewb The image block weighted error data.\n+ * @param component1 The first component included in the analysis.\n+ * @param component2 The second component included in the analysis.\n+ * @param[out] pm The output partition metrics.\n+ * - Only pi.partition_count array entries actually get initialized.\n+ * - Direction vectors @c pm.dir are not normalized.\n+ */\nvoid compute_avgs_and_dirs_2_comp(\n- const partition_info* pt,\n- const imageblock* blk,\n- const error_weight_block* ewb,\n+ const partition_info& pi,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\nint component1,\nint component2,\npartition_metrics pm[4]);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"new_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"diff": "@@ -166,7 +166,7 @@ static void compute_encoding_choice_errors(\npartition_metrics pms[4];\n- compute_avgs_and_dirs_3_comp(&pi, &blk, &ewb, 3, pms);\n+ compute_avgs_and_dirs_3_comp(pi, blk, ewb, 3, pms);\nfor (int i = 0; i < partition_count; i++)\n{\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Clean up function signatures for compute_avgs_and_dirs_*_comp
|
61,745 |
10.05.2021 21:23:46
| -3,600 |
0d7223a650a73121c802ec0d9d86fd53272d809a
|
API cleanup for compute_error_squared_rgb/a
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_averages_and_directions.cpp",
"new_path": "Source/astcenc_averages_and_directions.cpp",
"diff": "@@ -409,26 +409,27 @@ void compute_avgs_and_dirs_2_comp(\n}\n}\n+/* See header for documentation. */\nvoid compute_error_squared_rgba(\n- const partition_info* pt,\n- const imageblock* blk,\n- const error_weight_block* ewb,\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\n+ const partition_info& pi,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\n+ const processed_line4 uncor_plines[4],\n+ const processed_line4 samec_plines[4],\n+ float uncor_lengths[4],\n+ float samec_lengths[4],\n+ float& uncor_error,\n+ float& samec_error\n) {\n- float uncor_errorsum = 0.0f;\n- float samec_errorsum = 0.0f;\n-\n- int partition_count = pt->partition_count;\n+ int partition_count = pi.partition_count;\npromise(partition_count > 0);\n+ uncor_error = 0.0f;\n+ samec_error = 0.0f;\n+\nfor (int partition = 0; partition < partition_count; partition++)\n{\n- const uint8_t *weights = pt->texels_of_partition[partition];\n+ const uint8_t *weights = pi.texels_of_partition[partition];\nfloat uncor_loparam = 1e10f;\nfloat uncor_hiparam = -1e10f;\n@@ -439,11 +440,9 @@ void compute_error_squared_rgba(\nprocessed_line4 l_uncor = uncor_plines[partition];\nprocessed_line4 l_samec = samec_plines[partition];\n- int texel_count = pt->partition_texel_count[partition];\n+ int texel_count = pi.partition_texel_count[partition];\npromise(texel_count > 0);\n- int i = 0;\n-\n// Vectorize some useful scalar inputs\nvfloat l_uncor_bs0(l_uncor.bs.lane<0>());\nvfloat l_uncor_bs1(l_uncor.bs.lane<1>());\n@@ -484,20 +483,20 @@ void compute_error_squared_rgba(\n// to extend the last value. This means min/max are not impacted, but we need to mask\n// out the dummy values when we compute the line weighting.\nvint lane_ids = vint::lane_id();\n- for (/* */; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n+ for (int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)\n{\nvmask mask = lane_ids < vint(texel_count);\nvint texel_idxs(&(weights[i]));\n- vfloat data_r = gatherf(blk->data_r, texel_idxs);\n- vfloat data_g = gatherf(blk->data_g, texel_idxs);\n- vfloat data_b = gatherf(blk->data_b, texel_idxs);\n- vfloat data_a = gatherf(blk->data_a, texel_idxs);\n+ vfloat data_r = gatherf(blk.data_r, texel_idxs);\n+ vfloat data_g = gatherf(blk.data_g, texel_idxs);\n+ vfloat data_b = gatherf(blk.data_b, texel_idxs);\n+ vfloat data_a = gatherf(blk.data_a, texel_idxs);\n- vfloat ew_r = gatherf(ewb->texel_weight_r, texel_idxs);\n- vfloat ew_g = gatherf(ewb->texel_weight_g, texel_idxs);\n- vfloat ew_b = gatherf(ewb->texel_weight_b, texel_idxs);\n- vfloat ew_a = gatherf(ewb->texel_weight_a, texel_idxs);\n+ vfloat ew_r = gatherf(ewb.texel_weight_r, texel_idxs);\n+ vfloat ew_g = gatherf(ewb.texel_weight_g, texel_idxs);\n+ vfloat ew_b = gatherf(ewb.texel_weight_b, texel_idxs);\n+ vfloat ew_a = gatherf(ewb.texel_weight_a, texel_idxs);\nvfloat uncor_param = (data_r * l_uncor_bs0)\n+ (data_g * l_uncor_bs1)\n@@ -556,8 +555,8 @@ void compute_error_squared_rgba(\nsamec_hiparam = hmax_s(samec_hiparamv);\n// Resolve the final scalar accumulator sum\n- haccumulate(uncor_errorsum, uncor_errorsumv);\n- haccumulate(samec_errorsum, samec_errorsumv);\n+ haccumulate(uncor_error, uncor_errorsumv);\n+ haccumulate(samec_error, samec_errorsumv);\nfloat uncor_linelen = uncor_hiparam - uncor_loparam;\nfloat samec_linelen = samec_hiparam - samec_loparam;\n@@ -566,30 +565,28 @@ void compute_error_squared_rgba(\nuncor_lengths[partition] = astc::max(uncor_linelen, 1e-7f);\nsamec_lengths[partition] = astc::max(samec_linelen, 1e-7f);\n}\n-\n- *uncor_errors = uncor_errorsum;\n- *samec_errors = samec_errorsum;\n}\n+/* See header for documentation. */\nvoid compute_error_squared_rgb(\n- const partition_info *pt,\n- const imageblock *blk,\n- const error_weight_block *ewb,\n+ const partition_info& pi,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\npartition_lines3 plines[4],\nfloat& uncor_error,\nfloat& samec_error\n) {\n- float uncor_errorsum = 0.0f;\n- float samec_errorsum = 0.0f;\n-\n- int partition_count = pt->partition_count;\n+ int partition_count = pi.partition_count;\npromise(partition_count > 0);\n+ uncor_error = 0.0f;\n+ samec_error = 0.0f;\n+\nfor (int partition = 0; partition < partition_count; partition++)\n{\npartition_lines3& pl = plines[partition];\n- const uint8_t *weights = pt->texels_of_partition[partition];\n- int texel_count = pt->partition_texel_count[partition];\n+ const uint8_t *weights = pi.texels_of_partition[partition];\n+ int texel_count = pi.partition_texel_count[partition];\npromise(texel_count > 0);\nfloat uncor_loparam = 1e10f;\n@@ -645,13 +642,13 @@ void compute_error_squared_rgb(\nvmask mask = lane_ids < vint(texel_count);\nvint texel_idxs(&(weights[i]));\n- vfloat data_r = gatherf(blk->data_r, texel_idxs);\n- vfloat data_g = gatherf(blk->data_g, texel_idxs);\n- vfloat data_b = gatherf(blk->data_b, texel_idxs);\n+ vfloat data_r = gatherf(blk.data_r, texel_idxs);\n+ vfloat data_g = gatherf(blk.data_g, texel_idxs);\n+ vfloat data_b = gatherf(blk.data_b, texel_idxs);\n- vfloat ew_r = gatherf(ewb->texel_weight_r, texel_idxs);\n- vfloat ew_g = gatherf(ewb->texel_weight_g, texel_idxs);\n- vfloat ew_b = gatherf(ewb->texel_weight_b, texel_idxs);\n+ vfloat ew_r = gatherf(ewb.texel_weight_r, texel_idxs);\n+ vfloat ew_g = gatherf(ewb.texel_weight_g, texel_idxs);\n+ vfloat ew_b = gatherf(ewb.texel_weight_b, texel_idxs);\nvfloat uncor_param = (data_r * l_uncor_bs0)\n+ (data_g * l_uncor_bs1)\n@@ -704,8 +701,8 @@ void compute_error_squared_rgb(\nsamec_hiparam = hmax_s(samec_hiparamv);\n// Resolve the final scalar accumulator sum\n- haccumulate(uncor_errorsum, uncor_errorsumv);\n- haccumulate(samec_errorsum, samec_errorsumv);\n+ haccumulate(uncor_error, uncor_errorsumv);\n+ haccumulate(samec_error, samec_errorsumv);\nfloat uncor_linelen = uncor_hiparam - uncor_loparam;\nfloat samec_linelen = samec_hiparam - samec_loparam;\n@@ -714,9 +711,6 @@ void compute_error_squared_rgb(\npl.uncor_line_len = astc::max(uncor_linelen, 1e-7f);\npl.samec_line_len = astc::max(samec_linelen, 1e-7f);\n}\n-\n- uncor_error = uncor_errorsum;\n- samec_error = samec_errorsum;\n}\n#endif\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_find_best_partitioning.cpp",
"new_path": "Source/astcenc_find_best_partitioning.cpp",
"diff": "@@ -229,15 +229,15 @@ void find_best_partitionings(\nfloat samec_error = 0.0f;\nvfloat4 sep_error = vfloat4::zero();\n- compute_error_squared_rgba(ptab + partition,\n- blk,\n- ewb,\n+ compute_error_squared_rgba(*(ptab + partition),\n+ *blk,\n+ *ewb,\nuncor_plines,\nsamec_plines,\nuncor_line_lens,\nsamec_line_lens,\n- &uncor_error,\n- &samec_error);\n+ uncor_error,\n+ samec_error);\n/*\nCompute an estimate of error introduced by weight quantization imprecision.\n@@ -418,9 +418,9 @@ void find_best_partitionings(\nfloat samec_error = 0.0f;\nvfloat4 sep_error = vfloat4::zero();\n- compute_error_squared_rgb(ptab + partition,\n- blk,\n- ewb,\n+ compute_error_squared_rgb(*(ptab + partition),\n+ *blk,\n+ *ewb,\nplines,\nuncor_error,\nsamec_error);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -937,21 +937,58 @@ void compute_avgs_and_dirs_2_comp(\nint component2,\npartition_metrics pm[4]);\n+/**\n+ * @brief Compute the RGBA error for uncorrelated and same chroma projections.\n+ *\n+ * The output of compute averages and dirs is post processed to define two lines, both of which go\n+ * through the mean-color-value. One line has a direction defined by the dominant direction; this\n+ * is used to assess the error from using an uncorrelated color representation. The other line goes\n+ * through (0,0,0,1) and is used to assess the error from using an RGBS color representation.\n+ *\n+ * This function computes the squared error when using these two representations.\n+ *\n+ * @param pi The partition info for the current trial.\n+ * @param blk The image block color data to be compressed.\n+ * @param ewb The image block weighted error data.\n+ * @param uncor_plines Processed uncorrelated partition lines for each partition.\n+ * @param samec_plines Processed same chroma partition lines for each partition.\n+ * @param[out] uncor_lengths The length of each components deviation from the line.\n+ * @param[out] samec_lengths The length of each components deviation from the line.\n+ * @param[out] uncor_error The cumulative error for using the uncorrelated line.\n+ * @param[out] samec_error The cumulative error for using the same chroma line.\n+ */\nvoid compute_error_squared_rgba(\n- const partition_info* pt,\n- const imageblock* blk,\n- const error_weight_block* ewb,\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);\n+ const partition_info& pi,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\n+ const processed_line4 uncor_plines[4],\n+ const processed_line4 samec_plines[4],\n+ float uncor_lengths[4],\n+ float samec_lengths[4],\n+ float& uncor_error,\n+ float& samec_error);\n+/**\n+ * @brief Compute the RGB error for uncorrelated and same chroma projections.\n+ *\n+ * The output of compute averages and dirs is post processed to define two lines, both of which go\n+ * through the mean-color-value. One line has a direction defined by the dominant direction; this\n+ * is used to assess the error from using an uncorrelated color representation. The other line goes\n+ * through (0,0,0) and is used to assess the error from using an RGBS color representation.\n+ *\n+ * This function computes the squared error when using these two representations.\n+ *\n+ * @param pi The partition info for the current trial.\n+ * @param blk The image block color data to be compressed.\n+ * @param ewb The image block weighted error data.\n+ * @param[in,out] plines Processed line inputs, and line length outputs.\n+ * @param[out] uncor_error The cumulative error for using the uncorrelated line.\n+ * @param[out] samec_error The cumulative error for using the same chroma line.\n+ */\nvoid compute_error_squared_rgb(\n- const partition_info *pt,\n- const imageblock *blk,\n- const error_weight_block *ewb,\n+ const partition_info& pi,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\npartition_lines3 plines[4],\nfloat& uncor_error,\nfloat& samec_error);\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
API cleanup for compute_error_squared_rgb/a
|
61,745 |
13.05.2021 13:13:16
| -3,600 |
43f85b761534eeabe9fd9c51cd39e7d427a3cb93
|
Update oss-fuzz test to new API.
|
[
{
"change_type": "MODIFY",
"old_path": "Source/Fuzzers/fuzz_astc_physical_to_symbolic.cpp",
"new_path": "Source/Fuzzers/fuzz_astc_physical_to_symbolic.cpp",
"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@@ -69,7 +69,7 @@ bool bsd_initializer()\ntestSz[i].z,\nfalse,\n1.0f,\n- &(testBSD[i]));\n+ testBSD[i]);\n}\nreturn true;\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Update oss-fuzz test to new API.
|
61,745 |
14.05.2021 20:57:16
| -3,600 |
16d1904c702f1bff3549e4d1dc3aa05a6bd11e5c
|
API cleanup for color_unquantize
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_color_quantize.cpp",
"new_path": "Source/astcenc_color_quantize.cpp",
"diff": "@@ -1006,7 +1006,7 @@ static inline void quantize_and_unquantize_retain_top_four_bits(\n}\n/**\n- * @brief Quantize a HDR RGB color using RGB + scale.\n+ * @brief Quantize a HDR RGB color using RGB + offset.\n*\n* @param color The input unquantized color endpoint and offset.\n* @param[out] output The output endpoints, returned as packed RGBS with some mode bits.\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_color_unquantize.cpp",
"new_path": "Source/astcenc_color_unquantize.cpp",
"diff": "#include \"astcenc_internal.h\"\n+/**\n+ * @brief Unquantize a color.\n+ *\n+ * This function uses a lookup table as the quantization is encoded to make\n+ * hardware implementations easier, and is not a simple lerp.\n+ *\n+ * @param quant_level The quantization level to use.\n+ * @param inputq The input quantized color.\n+ *\n+ * @return The unquantized color.\n+ */\nstatic ASTCENC_SIMD_INLINE vint4 unquant_color(\nint quant_level,\nvint4 inputq\n@@ -32,6 +43,15 @@ static ASTCENC_SIMD_INLINE vint4 unquant_color(\nunq[inputq.lane<2>()], unq[inputq.lane<3>()]);\n}\n+/**\n+ * @brief Un-blue-contract a color.\n+ *\n+ * This function reverses any applied blue contraction.\n+ *\n+ * @param input The input color that has been blue-contracted.\n+ *\n+ * @return The uncontracted color.\n+ */\nstatic ASTCENC_SIMD_INLINE vint4 uncontract_color(\nvint4 input\n) {\n@@ -40,6 +60,15 @@ static ASTCENC_SIMD_INLINE vint4 uncontract_color(\nreturn select(input, bc0, mask);\n}\n+/**\n+ * @brief Unpack an LDR RGBA color that uses delta encoding.\n+ *\n+ * @param input0q The raw quantized endpoint 0 color.\n+ * @param input1q The raw quantized endpoint 1 color deltas.\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void rgba_delta_unpack(\nvint4 input0q,\nvint4 input1q,\n@@ -75,6 +104,17 @@ static void rgba_delta_unpack(\noutput1 = clamp(0, 255, input1);\n}\n+/**\n+ * @brief Unpack an LDR RGB color that uses delta encoding.\n+ *\n+ * Output alpha set to 255.\n+ *\n+ * @param input0q The raw quantized endpoint 0 color.\n+ * @param input1q The raw quantized endpoint 1 color deltas.\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void rgb_delta_unpack(\nvint4 input0q,\nvint4 input1q,\n@@ -87,6 +127,15 @@ static void rgb_delta_unpack(\noutput1.set_lane<3>(255);\n}\n+/**\n+ * @brief Unpack an LDR RGBA color that uses direct encoding.\n+ *\n+ * @param input0q The raw quantized endpoint 0 color.\n+ * @param input1q The raw quantized endpoint 1 color.\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void rgba_unpack(\nvint4 input0q,\nvint4 input1q,\n@@ -110,6 +159,17 @@ static void rgba_unpack(\noutput1 = input1;\n}\n+/**\n+ * @brief Unpack an LDR RGB color that uses direct encoding.\n+ *\n+ * Output alpha set to 255.\n+ *\n+ * @param input0q The raw quantized endpoint 0 color.\n+ * @param input1q The raw quantized endpoint 1 color.\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void rgb_unpack(\nvint4 input0q,\nvint4 input1q,\n@@ -122,6 +182,18 @@ static void rgb_unpack(\noutput1.set_lane<3>(255);\n}\n+/**\n+ * @brief Unpack an LDR RGBA color that uses scaled encoding.\n+ *\n+ * Note only the RGB channels use the scaled encoding, alpha uses direct.\n+ *\n+ * @param input0q The raw quantized endpoint 0 color.\n+ * @param alpha1q The raw quantized endpoint 1 alpha value.\n+ * @param scaleq The raw quantized scale.\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void rgb_scale_alpha_unpack(\nvint4 input0q,\nint alpha1q,\n@@ -142,6 +214,17 @@ static void rgb_scale_alpha_unpack(\noutput0.set_lane<3>(input.lane<3>());\n}\n+/**\n+ * @brief Unpack an LDR RGB color that uses scaled encoding.\n+ *\n+ * Output alpha is 255.\n+ *\n+ * @param input0q The raw quantized endpoint 0 color.\n+ * @param scaleq The raw quantized scale.\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void rgb_scale_unpack(\nvint4 input0q,\nint scaleq,\n@@ -159,23 +242,43 @@ static void rgb_scale_unpack(\noutput0.set_lane<3>(255);\n}\n+/**\n+ * @brief Unpack an LDR L color that uses direct encoding.\n+ *\n+ * Output alpha is 255.\n+ *\n+ * @param input The raw quantized endpoints.\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void luminance_unpack(\nconst int input[2],\nint quant_level,\n- vint4* output0,\n- vint4* 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 = vint4(lum0, lum0, lum0, 255);\n- *output1 = vint4(lum1, lum1, lum1, 255);\n+ output0 = vint4(lum0, lum0, lum0, 255);\n+ output1 = vint4(lum1, lum1, lum1, 255);\n}\n+/**\n+ * @brief Unpack an LDR L color that uses delta encoding.\n+ *\n+ * Output alpha is 255.\n+ *\n+ * @param input The raw quantized endpoints (L0, L1).\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void luminance_delta_unpack(\nconst int input[2],\nint quant_level,\n- vint4* output0,\n- vint4* 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@@ -184,29 +287,45 @@ static void luminance_delta_unpack(\nl1 = astc::min(l1, 255);\n- *output0 = vint4(l0, l0, l0, 255);\n- *output1 = vint4(l1, l1, l1, 255);\n+ output0 = vint4(l0, l0, l0, 255);\n+ output1 = vint4(l1, l1, l1, 255);\n}\n+/**\n+ * @brief Unpack an LDR LA color that uses direct encoding.\n+ *\n+ * @param input The raw quantized endpoints (L0, L1, A0, A1).\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void luminance_alpha_unpack(\nconst int input[4],\nint quant_level,\n- vint4* output0,\n- vint4* 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 = vint4(lum0, lum0, lum0, alpha0);\n- *output1 = vint4(lum1, lum1, lum1, alpha1);\n+ output0 = vint4(lum0, lum0, lum0, alpha0);\n+ output1 = vint4(lum1, lum1, lum1, alpha1);\n}\n+/**\n+ * @brief Unpack an LDR LA color that uses delta encoding.\n+ *\n+ * @param input The raw quantized endpoints (L0, L1, A0, A1).\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void luminance_alpha_delta_unpack(\nconst int input[4],\nint quant_level,\n- vint4* output0,\n- vint4* 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@@ -232,16 +351,23 @@ static void luminance_alpha_delta_unpack(\nlum1 = astc::clamp(lum1, 0, 255);\nalpha1 = astc::clamp(alpha1, 0, 255);\n- *output0 = vint4(lum0, lum0, lum0, alpha0);\n- *output1 = vint4(lum1, lum1, lum1, alpha1);\n+ output0 = vint4(lum0, lum0, lum0, alpha0);\n+ output1 = vint4(lum1, lum1, lum1, alpha1);\n}\n-// RGB-offset format\n-static void hdr_rgbo_unpack3(\n+/**\n+ * @brief Unpack an HDR RGB + offset encoding.\n+ *\n+ * @param input The raw quantized endpoints (packed and modal).\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\n+static void hdr_rgbo_unpack(\nconst int input[4],\nint quant_level,\n- vint4* output0,\n- vint4* 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@@ -377,15 +503,23 @@ static void hdr_rgbo_unpack3(\nif (blue0 < 0)\nblue0 = 0;\n- *output0 = vint4(red0 << 4, green0 << 4, blue0 << 4, 0x7800);\n- *output1 = vint4(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}\n-static void hdr_rgb_unpack3(\n+/**\n+ * @brief Unpack an HDR RGB direct encoding.\n+ *\n+ * @param input The raw quantized endpoints (packed and modal).\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\n+static void hdr_rgb_unpack(\nconst int input[6],\nint quant_level,\n- vint4* output0,\n- vint4* output1\n+ vint4& output0,\n+ vint4& output1\n) {\nint v0 = color_unquant_tables[quant_level][input[0]];\n@@ -402,8 +536,8 @@ static void hdr_rgb_unpack3(\nif (majcomp == 3)\n{\n- *output0 = vint4(v0 << 8, v2 << 8, (v4 & 0x7F) << 9, 0x7800);\n- *output1 = vint4(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@@ -537,29 +671,45 @@ static void hdr_rgb_unpack3(\nbreak;\n}\n- *output0 = vint4(red0 << 4, green0 << 4, blue0 << 4, 0x7800);\n- *output1 = vint4(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}\n-static void hdr_rgb_ldr_alpha_unpack3(\n+/**\n+ * @brief Unpack an HDR RGB + LDR A direct encoding.\n+ *\n+ * @param input The raw quantized endpoints (packed and modal).\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\n+static void hdr_rgb_ldr_alpha_unpack(\nconst int input[8],\nint quant_level,\n- vint4* output0,\n- vint4* output1\n+ vint4& output0,\n+ vint4& output1\n) {\n- hdr_rgb_unpack3(input, quant_level, output0, output1);\n+ hdr_rgb_unpack(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->set_lane<3>(v6);\n- output1->set_lane<3>(v7);\n+ output0.set_lane<3>(v6);\n+ output1.set_lane<3>(v7);\n}\n+/**\n+ * @brief Unpack an HDR L (small range) direct encoding.\n+ *\n+ * @param input The raw quantized endpoints (packed and modal).\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void hdr_luminance_small_range_unpack(\nconst int input[2],\nint quant_level,\n- vint4* output0,\n- vint4* 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@@ -580,15 +730,23 @@ static void hdr_luminance_small_range_unpack(\nif (y1 > 0xFFF)\ny1 = 0xFFF;\n- *output0 = vint4(y0 << 4, y0 << 4, y0 << 4, 0x7800);\n- *output1 = vint4(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}\n+/**\n+ * @brief Unpack an HDR L (large range) direct encoding.\n+ *\n+ * @param input The raw quantized endpoints (packed and modal).\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void hdr_luminance_large_range_unpack(\nconst int input[2],\nint quant_level,\n- vint4* output0,\n- vint4* 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@@ -604,15 +762,24 @@ static void hdr_luminance_large_range_unpack(\ny0 = (v1 << 4) + 8;\ny1 = (v0 << 4) - 8;\n}\n- *output0 = vint4(y0 << 4, y0 << 4, y0 << 4, 0x7800);\n- *output1 = vint4(y1 << 4, y1 << 4, y1 << 4, 0x7800);\n+\n+ output0 = vint4(y0 << 4, y0 << 4, y0 << 4, 0x7800);\n+ output1 = vint4(y1 << 4, y1 << 4, y1 << 4, 0x7800);\n}\n+/**\n+ * @brief Unpack an HDR A direct encoding.\n+ *\n+ * @param input The raw quantized endpoints (packed and modal).\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\nstatic void hdr_alpha_unpack(\nconst int input[2],\nint quant_level,\n- int* output0,\n- int* output1\n+ int& output0,\n+ int& output1\n) {\nint v6 = color_unquant_tables[quant_level][input[0]];\n@@ -623,8 +790,8 @@ static void hdr_alpha_unpack(\nv7 &= 0x7F;\nif (selector == 3)\n{\n- *output0 = v6 << 5;\n- *output1 = v7 << 5;\n+ output0 = v6 << 5;\n+ output1 = v7 << 5;\n}\nelse\n{\n@@ -641,42 +808,51 @@ static void hdr_alpha_unpack(\nelse if (v7 > 0xFFF)\nv7 = 0xFFF;\n- *output0 = v6;\n- *output1 = v7;\n+ output0 = v6;\n+ output1 = v7;\n}\n- *output0 <<= 4;\n- *output1 <<= 4;\n+ output0 <<= 4;\n+ output1 <<= 4;\n}\n-static void hdr_rgb_hdr_alpha_unpack3(\n+/**\n+ * @brief Unpack an HDR RGBA direct encoding.\n+ *\n+ * @param input The raw quantized endpoints (packed and modal).\n+ * @param quant_level The quantization level to use.\n+ * @param[out] output0 The unpacked and unquantized endpoint 0 color.\n+ * @param[out] output1 The unpacked and unquantized endpoint 1 color.\n+ */\n+static void hdr_rgb_hdr_alpha_unpack(\nconst int input[8],\nint quant_level,\n- vint4* output0,\n- vint4* output1\n+ vint4& output0,\n+ vint4& output1\n) {\n- hdr_rgb_unpack3(input, quant_level, output0, output1);\n+ hdr_rgb_unpack(input, quant_level, output0, output1);\nint alpha0, alpha1;\n- hdr_alpha_unpack(input + 6, quant_level, &alpha0, &alpha1);\n+ hdr_alpha_unpack(input + 6, quant_level, alpha0, alpha1);\n- output0->set_lane<3>(alpha0);\n- output1->set_lane<3>(alpha1);\n+ output0.set_lane<3>(alpha0);\n+ output1.set_lane<3>(alpha1);\n}\n+/* See header for documentation. */\nvoid unpack_color_endpoints(\nastcenc_profile decode_mode,\nint format,\nint quant_level,\nconst int* input,\n- bool* rgb_hdr,\n- bool* alpha_hdr,\n- vint4* output0,\n- vint4* output1\n+ bool& rgb_hdr,\n+ bool& alpha_hdr,\n+ vint4& output0,\n+ vint4& output1\n) {\n// Assume no NaNs and LDR endpoints unless set later\n- *rgb_hdr = false;\n- *alpha_hdr = false;\n+ rgb_hdr = false;\n+ alpha_hdr = false;\nbool alpha_hdr_default = false;\n@@ -691,13 +867,13 @@ void unpack_color_endpoints(\nbreak;\ncase FMT_HDR_LUMINANCE_SMALL_RANGE:\n- *rgb_hdr = true;\n+ rgb_hdr = true;\nalpha_hdr_default = true;\nhdr_luminance_small_range_unpack(input, quant_level, output0, output1);\nbreak;\ncase FMT_HDR_LUMINANCE_LARGE_RANGE:\n- *rgb_hdr = true;\n+ rgb_hdr = true;\nalpha_hdr_default = true;\nhdr_luminance_large_range_unpack(input, quant_level, output0, output1);\nbreak;\n@@ -714,7 +890,7 @@ void unpack_color_endpoints(\n{\nvint4 input0q(input[0], input[1], input[2], 0);\nint scale = input[3];\n- rgb_scale_unpack(input0q, scale, quant_level, *output0, *output1);\n+ rgb_scale_unpack(input0q, scale, quant_level, output0, output1);\n}\nbreak;\n@@ -723,21 +899,21 @@ void unpack_color_endpoints(\nvint4 input0q(input[0], input[1], input[2], input[4]);\nint alpha1q = input[5];\nint scaleq = input[3];\n- rgb_scale_alpha_unpack(input0q, alpha1q, scaleq, quant_level, *output0, *output1);\n+ rgb_scale_alpha_unpack(input0q, alpha1q, scaleq, quant_level, output0, output1);\n}\nbreak;\ncase FMT_HDR_RGB_SCALE:\n- *rgb_hdr = true;\n+ rgb_hdr = true;\nalpha_hdr_default = true;\n- hdr_rgbo_unpack3(input, quant_level, output0, output1);\n+ hdr_rgbo_unpack(input, quant_level,output0, output1);\nbreak;\ncase FMT_RGB:\n{\nvint4 input0q(input[0], input[2], input[4], 0);\nvint4 input1q(input[1], input[3], input[5], 0);\n- rgb_unpack(input0q, input1q, quant_level, *output0, *output1);\n+ rgb_unpack(input0q, input1q, quant_level, output0, output1);\n}\nbreak;\n@@ -745,21 +921,21 @@ void unpack_color_endpoints(\n{\nvint4 input0q(input[0], input[2], input[4], 0);\nvint4 input1q(input[1], input[3], input[5], 0);\n- rgb_delta_unpack(input0q, input1q, quant_level, *output0, *output1);\n+ rgb_delta_unpack(input0q, input1q, quant_level, output0, output1);\n}\nbreak;\ncase FMT_HDR_RGB:\n- *rgb_hdr = true;\n+ rgb_hdr = true;\nalpha_hdr_default = true;\n- hdr_rgb_unpack3(input, quant_level, output0, output1);\n+ hdr_rgb_unpack(input, quant_level, output0, output1);\nbreak;\ncase FMT_RGBA:\n{\nvint4 input0q(input[0], input[2], input[4], input[6]);\nvint4 input1q(input[1], input[3], input[5], input[7]);\n- rgba_unpack(input0q, input1q, quant_level, *output0, *output1);\n+ rgba_unpack(input0q, input1q, quant_level, output0, output1);\n}\nbreak;\n@@ -767,19 +943,19 @@ void unpack_color_endpoints(\n{\nvint4 input0q(input[0], input[2], input[4], input[6]);\nvint4 input1q(input[1], input[3], input[5], input[7]);\n- rgba_delta_unpack(input0q, input1q, quant_level, *output0, *output1);\n+ rgba_delta_unpack(input0q, input1q, quant_level, output0, output1);\n}\nbreak;\ncase FMT_HDR_RGB_LDR_ALPHA:\n- *rgb_hdr = true;\n- hdr_rgb_ldr_alpha_unpack3(input, quant_level, output0, output1);\n+ rgb_hdr = true;\n+ hdr_rgb_ldr_alpha_unpack(input, quant_level, output0, output1);\nbreak;\ncase FMT_HDR_RGBA:\n- *rgb_hdr = true;\n- *alpha_hdr = true;\n- hdr_rgb_hdr_alpha_unpack3(input, quant_level, output0, output1);\n+ rgb_hdr = true;\n+ alpha_hdr = true;\n+ hdr_rgb_hdr_alpha_unpack(input, quant_level, output0, output1);\nbreak;\n}\n@@ -788,15 +964,15 @@ void unpack_color_endpoints(\n{\nif (decode_mode == ASTCENC_PRF_HDR)\n{\n- output0->set_lane<3>(0x7800);\n- output1->set_lane<3>(0x7800);\n- *alpha_hdr = true;\n+ output0.set_lane<3>(0x7800);\n+ output1.set_lane<3>(0x7800);\n+ alpha_hdr = true;\n}\nelse\n{\n- output0->set_lane<3>(0x00FF);\n- output1->set_lane<3>(0x00FF);\n- *alpha_hdr = false;\n+ output0.set_lane<3>(0x00FF);\n+ output1.set_lane<3>(0x00FF);\n+ alpha_hdr = false;\n}\n}\n@@ -809,23 +985,23 @@ void unpack_color_endpoints(\n(decode_mode == ASTCENC_PRF_LDR_SRGB))\n{\n// Also matches HDR alpha, as cannot have HDR alpha without HDR RGB\n- if (*rgb_hdr == true)\n+ if (rgb_hdr == true)\n{\n- *output0 = vint4(0xFF00, 0x0000, 0xFF00, 0xFF00);\n- *output1 = vint4(0xFF00, 0x0000, 0xFF00, 0xFF00);\n+ output0 = vint4(0xFF00, 0x0000, 0xFF00, 0xFF00);\n+ output1 = vint4(0xFF00, 0x0000, 0xFF00, 0xFF00);\noutput_scale = hdr_scale;\n- *rgb_hdr = false;\n- *alpha_hdr = false;\n+ rgb_hdr = false;\n+ alpha_hdr = false;\n}\n}\n// An HDR profile image\nelse\n{\n- vmask4 hdr_lanes(*rgb_hdr, *rgb_hdr, *rgb_hdr, *alpha_hdr);\n+ vmask4 hdr_lanes(rgb_hdr, rgb_hdr, rgb_hdr, alpha_hdr);\noutput_scale = select(ldr_scale, hdr_scale, hdr_lanes);\n}\n- *output0 = *output0 * output_scale;\n- *output1 = *output1 * output_scale;\n+ output0 = output0 * output_scale;\n+ output1 = output1 * output_scale;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -108,9 +108,9 @@ static bool realign_weights(\nscb->color_formats[pa_idx],\nscb->color_quant_level,\nscb->color_values[pa_idx],\n- &rgb_hdr, &alpha_hdr,\n- &endpnt0[pa_idx],\n- &endpnt1[pa_idx]);\n+ rgb_hdr, alpha_hdr,\n+ endpnt0[pa_idx],\n+ endpnt1[pa_idx]);\n}\nuint8_t uq_pl_weights[MAX_WEIGHTS_PER_BLOCK];\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_decompress_symbolic.cpp",
"new_path": "Source/astcenc_decompress_symbolic.cpp",
"diff": "@@ -263,10 +263,8 @@ void decompress_symbolic_block(\nscb->color_formats[i],\nscb->color_quant_level,\nscb->color_values[i],\n- &rgb_lns,\n- &a_lns,\n- &ep0,\n- &ep1);\n+ rgb_lns, a_lns,\n+ ep0, ep1);\nvmask4 lns_mask(rgb_lns, rgb_lns, rgb_lns, a_lns);\n@@ -343,8 +341,8 @@ float compute_symbolic_block_difference(\nscb->color_formats[i],\nscb->color_quant_level,\nscb->color_values[i],\n- &rgb_lns, &a_lns,\n- &ep0, &ep1);\n+ rgb_lns, a_lns,\n+ ep0, ep1);\nvmask4 lns_mask(rgb_lns, rgb_lns, rgb_lns, a_lns);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -1165,8 +1165,8 @@ astcenc_error astcenc_get_block_info(\nscb.color_formats[i],\nscb.color_quant_level,\nscb.color_values[i],\n- &rgb_hdr, &a_hdr,\n- endpnt, endpnt + 1);\n+ rgb_hdr, a_hdr,\n+ endpnt[0], endpnt[1]);\n// Store the color endpoint mode info\ninfo->color_endpoint_modes[i] = scb.color_formats[i];\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1286,7 +1286,7 @@ float compute_error_of_weight_set_2planes(\nconst float* weights2);\n/**\n- * @brief Quantize a color as effectively as possible.\n+ * @brief Pack a single pair of color endpoints as effectively as possible.\n*\n* The user requests a base color endpoint mode in @c format, but the quantizer may choose a\n* delta-based representation. It will report back the format variant it actually used.\n@@ -1310,16 +1310,28 @@ int pack_color_endpoints(\nint* output,\nquant_method quant_level);\n-// unpack a pair of color endpoints from a series of integers.\n+/**\n+ * @brief Unpack a single pair of encoded and quantized color endpoints.\n+ *\n+ * @param decode_mode The decode mode (LDR, HDR).\n+ * @param format The color endpoint mode used.\n+ * @param quant_level The quantization level used.\n+ * @param input The raw array of encoded input integers. The length of this array\n+ * depends on @c format; it can be safely assumed to be large enough.\n+ * @param[out] rgb_hdr Is the endpoint using HDR for the RGB channels?\n+ * @param[out] alpha_hdr Is the endpoint using HDR for the A channel?\n+ * @param[out] output0 The output color for endpoint 0.\n+ * @param[out] output1 The output color for endpoint 1.\n+ */\nvoid unpack_color_endpoints(\nastcenc_profile decode_mode,\nint format,\nint quant_level,\nconst int* input,\n- bool* rgb_hdr,\n- bool* alpha_hdr,\n- vint4* output0,\n- vint4* output1);\n+ bool& rgb_hdr,\n+ bool& alpha_hdr,\n+ vint4& output0,\n+ vint4& output1);\n// unquantize and undecimate a weight grid\nvoid unpack_weights(\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
API cleanup for color_unquantize
|
61,745 |
14.05.2021 22:26:41
| -3,600 |
8f0f258d1f6720ec65c704d45e0940203fad5f5d
|
Cleanup API for compute_variance
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compute_variance.cpp",
"new_path": "Source/astcenc_compute_variance.cpp",
"diff": "#include <cassert>\n/**\n- * @brief Generate a prefix-sum array using Brent-Kung algorithm.\n+ * @brief Generate a prefix-sum array using the Brent-Kung algorithm.\n*\n* This will take an input array of the form:\n* v0, v1, v2, ...\n@@ -106,34 +106,35 @@ static void brent_kung_prefix_sum(\n* The routine computes both in a single pass, using a summed-area table to\n* decouple the running time from the averaging/variance kernel size.\n*\n+ * @param[out] ctx The compressor context storing the output data.\n* @param arg The input parameter structure.\n*/\nstatic void compute_pixel_region_variance(\nastcenc_context& ctx,\n- const pixel_region_variance_args* arg\n+ const pixel_region_variance_args& arg\n) {\n// Unpack the memory structure into local variables\n- const astcenc_image* img = arg->img;\n- float rgb_power = arg->rgb_power;\n- float alpha_power = arg->alpha_power;\n- astcenc_swizzle swz = arg->swz;\n- bool have_z = arg->have_z;\n+ const astcenc_image* img = arg.img;\n+ float rgb_power = arg.rgb_power;\n+ float alpha_power = arg.alpha_power;\n+ astcenc_swizzle swz = arg.swz;\n+ bool have_z = arg.have_z;\n- int size_x = arg->size_x;\n- int size_y = arg->size_y;\n- int size_z = arg->size_z;\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_x;\n- int offset_y = arg->offset_y;\n- int offset_z = arg->offset_z;\n+ int offset_x = arg.offset_x;\n+ int offset_y = arg.offset_y;\n+ int offset_z = arg.offset_z;\n- int avg_var_kernel_radius = arg->avg_var_kernel_radius;\n- int alpha_kernel_radius = arg->alpha_kernel_radius;\n+ int avg_var_kernel_radius = arg.avg_var_kernel_radius;\n+ int alpha_kernel_radius = arg.alpha_kernel_radius;\nfloat* input_alpha_averages = ctx.input_alpha_averages;\nvfloat4* input_averages = ctx.input_averages;\nvfloat4* input_variances = ctx.input_variances;\n- vfloat4 *work_memory = arg->work_memory;\n+ vfloat4* work_memory = arg.work_memory;\n// Compute memory sizes and dimensions that we need\nint kernel_radius = astc::max(avg_var_kernel_radius, alpha_kernel_radius);\n@@ -556,7 +557,7 @@ void compute_averages_and_variances(\n{\narg.size_x = astc::min(step_xy, size_x - x);\narg.offset_x = x;\n- compute_pixel_region_variance(ctx, &arg);\n+ compute_pixel_region_variance(ctx, arg);\n}\n}\n@@ -566,7 +567,7 @@ void compute_averages_and_variances(\ndelete[] arg.work_memory;\n}\n-/* Public function, see header file for detailed documentation */\n+/* See header for documentation. */\nunsigned int init_compute_averages_and_variances(\nastcenc_image& img,\nfloat rgb_power,\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup API for compute_variance
|
61,745 |
14.05.2021 22:29:15
| -3,600 |
2ec1b5b068d4304257fbd3777c36806266f62f7d
|
API change - pass swizzzle structs by reference.
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc.h",
"new_path": "Source/astcenc.h",
"diff": "@@ -729,7 +729,7 @@ ASTCENC_PUBLIC astcenc_error astcenc_context_alloc(\n*\n* @param context Codec context.\n* @param[in,out] image An input image, in 2D slices.\n- * @param swizzle Compression data swizzle.\n+ * @param swizzle Compression data swizzle, applied before compression.\n* @param[out] data_out Pointer to output data array.\n* @param data_len Length of the output data array.\n* @param thread_index Thread index [0..N-1] of calling thread.\n@@ -739,7 +739,7 @@ ASTCENC_PUBLIC astcenc_error astcenc_context_alloc(\nASTCENC_PUBLIC astcenc_error astcenc_compress_image(\nastcenc_context* context,\nastcenc_image* image,\n- astcenc_swizzle swizzle,\n+ const astcenc_swizzle* swizzle,\nuint8_t* data_out,\nsize_t data_len,\nunsigned int thread_index);\n@@ -766,7 +766,7 @@ ASTCENC_PUBLIC astcenc_error astcenc_compress_reset(\n* @param[in] data Pointer to compressed data.\n* @param data_len Length of the compressed data, in bytes.\n* @param[in,out] image_out Output image.\n- * @param swizzle Decompression data swizzle.\n+ * @param swizzle Decompression data swizzle, applied after decompression.\n* @param thread_index Thread index [0..N-1] of calling thread.\n*\n* @return ASTCENC_SUCCESS on success, or an error if decompression failed.\n@@ -776,7 +776,7 @@ ASTCENC_PUBLIC astcenc_error astcenc_decompress_image(\nconst uint8_t* data,\nsize_t data_len,\nastcenc_image* image_out,\n- astcenc_swizzle swizzle,\n+ const astcenc_swizzle* swizzle,\nunsigned int thread_index);\n/**\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compute_variance.cpp",
"new_path": "Source/astcenc_compute_variance.cpp",
"diff": "@@ -574,7 +574,7 @@ unsigned int init_compute_averages_and_variances(\nfloat alpha_power,\nint avg_var_kernel_radius,\nint alpha_kernel_radius,\n- astcenc_swizzle swz,\n+ const astcenc_swizzle& swz,\npixel_region_variance_args& arg,\navg_var_args& ag\n) {\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -254,7 +254,7 @@ static astcenc_error validate_compression_swz(\n}\nstatic astcenc_error validate_compression_swizzle(\n- astcenc_swizzle swizzle\n+ const astcenc_swizzle& swizzle\n) {\nif (validate_compression_swz(swizzle.r) ||\nvalidate_compression_swz(swizzle.g) ||\n@@ -289,7 +289,7 @@ static astcenc_error validate_decompression_swz(\n}\nstatic astcenc_error validate_decompression_swizzle(\n- astcenc_swizzle swizzle\n+ const astcenc_swizzle& swizzle\n) {\nif (validate_decompression_swz(swizzle.r) ||\nvalidate_decompression_swz(swizzle.g) ||\n@@ -875,7 +875,7 @@ static void compress_image(\nastcenc_error astcenc_compress_image(\nastcenc_context* ctx,\nastcenc_image* imagep,\n- astcenc_swizzle swizzle,\n+ const astcenc_swizzle* swizzle,\nuint8_t* data_out,\nsize_t data_len,\nunsigned int thread_index\n@@ -897,7 +897,7 @@ astcenc_error astcenc_compress_image(\nreturn ASTCENC_ERR_BAD_CONTEXT;\n}\n- status = validate_compression_swizzle(swizzle);\n+ status = validate_compression_swizzle(*swizzle);\nif (status != ASTCENC_SUCCESS)\n{\nreturn status;\n@@ -938,7 +938,7 @@ astcenc_error astcenc_compress_image(\nreturn init_compute_averages_and_variances(\nimage, ctx->config.v_rgb_power, ctx->config.v_a_power,\n- ctx->config.v_rgba_radius, ctx->config.a_scale_radius, swizzle,\n+ ctx->config.v_rgba_radius, ctx->config.a_scale_radius, *swizzle,\nctx->arg, ctx->ag);\n};\n@@ -952,7 +952,7 @@ astcenc_error astcenc_compress_image(\n// Wait for compute_averages_and_variances to complete before compressing\nctx->manage_avg_var.wait();\n- compress_image(*ctx, thread_index, image, swizzle, data_out);\n+ compress_image(*ctx, thread_index, image, *swizzle, data_out);\n// Wait for compress to complete before freeing memory\nctx->manage_compress.wait();\n@@ -998,7 +998,7 @@ astcenc_error astcenc_decompress_image(\nconst uint8_t* data,\nsize_t data_len,\nastcenc_image* image_outp,\n- astcenc_swizzle swizzle,\n+ const astcenc_swizzle* swizzle,\nunsigned int thread_index\n) {\nastcenc_error status;\n@@ -1010,7 +1010,7 @@ astcenc_error astcenc_decompress_image(\nreturn ASTCENC_ERR_BAD_PARAM;\n}\n- status = validate_decompression_swizzle(swizzle);\n+ status = validate_decompression_swizzle(*swizzle);\nif (status != ASTCENC_SUCCESS)\n{\nreturn status;\n@@ -1069,7 +1069,7 @@ astcenc_error astcenc_decompress_image(\n&scb, &blk);\nwrite_imageblock(image_out, &blk, ctx->bsd,\n- x * block_x, y * block_y, z * block_z, swizzle);\n+ x * block_x, y * block_y, z * block_z, *swizzle);\n}\nctx->manage_decompress.complete_task_assignment(count);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_image.cpp",
"new_path": "Source/astcenc_image.cpp",
"diff": "@@ -158,7 +158,7 @@ void fetch_imageblock(\nint xpos,\nint ypos,\nint zpos,\n- astcenc_swizzle swz\n+ const astcenc_swizzle& swz\n) {\nint xsize = img.dim_x;\nint ysize = img.dim_y;\n@@ -273,7 +273,7 @@ void write_imageblock(\nint xpos,\nint ypos,\nint zpos,\n- astcenc_swizzle swz\n+ const astcenc_swizzle& swz\n) {\nint xsize = img.dim_x;\nint ysize = img.dim_y;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1114,7 +1114,7 @@ unsigned int init_compute_averages_and_variances(\nfloat alpha_power,\nint avg_var_kernel_radius,\nint alpha_kernel_radius,\n- astcenc_swizzle swz,\n+ const astcenc_swizzle& swz,\npixel_region_variance_args& arg,\navg_var_args& ag);\n@@ -1132,7 +1132,7 @@ void fetch_imageblock(\nint xpos,\nint ypos,\nint zpos,\n- astcenc_swizzle swz);\n+ const astcenc_swizzle& swz);\n// write an image block to the output file buffer.\n// the data written are taken from orig_data.\n@@ -1144,7 +1144,7 @@ void write_imageblock(\nint xpos,\nint ypos,\nint zpos,\n- astcenc_swizzle swz);\n+ const astcenc_swizzle& swz);\nfloat compute_symbolic_block_difference(\nconst astcenc_config& config,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenccli_toplevel.cpp",
"new_path": "Source/astcenccli_toplevel.cpp",
"diff": "@@ -161,7 +161,7 @@ static void compression_workload_runner(\ncompression_workload* work = static_cast<compression_workload*>(payload);\nastcenc_error error = astcenc_compress_image(\n- work->context, work->image, work->swizzle,\n+ work->context, work->image, &work->swizzle,\nwork->data_out, work->data_len, thread_id);\n// This is a racy update, so which error gets returned is a random, but it\n@@ -182,7 +182,7 @@ static void decompression_workload_runner(\ndecompression_workload* work = static_cast<decompression_workload*>(payload);\nastcenc_error error = astcenc_decompress_image(\nwork->context, work->data, work->data_len,\n- work->image_out, work->swizzle, thread_id);\n+ work->image_out, &work->swizzle, thread_id);\n// This is a racy update, so which error gets returned is a random, but it\n// will reliably report an error if an error occurs\n@@ -1561,7 +1561,7 @@ int main(\nelse\n{\nwork.error = astcenc_compress_image(\n- work.context, work.image, work.swizzle,\n+ work.context, work.image, &work.swizzle,\nwork.data_out, work.data_len, 0);\n}\n@@ -1613,7 +1613,7 @@ int main(\n{\nwork.error = astcenc_decompress_image(\nwork.context, work.data, work.data_len,\n- work.image_out, work.swizzle, 0);\n+ work.image_out, &work.swizzle, 0);\n}\nif (work.error != ASTCENC_SUCCESS)\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
API change - pass swizzzle structs by reference.
|
61,745 |
14.05.2021 23:06:07
| -3,600 |
5dfd12c559fa84b803bd9256199f17fdffb7f215
|
Cleanup API for decompress_symbolic
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -498,7 +498,7 @@ static float compress_symbolic_block_fixed_partition_1plane(\nworkscb.weights[j] = u8_weight_src[j];\n}\n- float errorval = compute_symbolic_block_difference(config, &bsd, &workscb, &blk, &ewb);\n+ float errorval = compute_symbolic_block_difference(config, bsd, workscb, blk, ewb);\nif (errorval == -1e30f)\n{\nerrorval = -errorval;\n@@ -545,7 +545,7 @@ static float compress_symbolic_block_fixed_partition_1plane(\nworkscb.weights[j] = u8_weight_src[j];\n}\n- float errorval = compute_symbolic_block_difference(config, &bsd, &workscb, &blk, &ewb);\n+ float errorval = compute_symbolic_block_difference(config, bsd, workscb, blk, ewb);\nif (errorval == -1e30f)\n{\nerrorval = -errorval;\n@@ -903,7 +903,7 @@ static float compress_symbolic_block_fixed_partition_2planes(\nworkscb.weights[j + PLANE2_WEIGHTS_OFFSET] = u8_weight2_src[j];\n}\n- float errorval = compute_symbolic_block_difference(config, &bsd, &workscb, &blk, &ewb);\n+ float errorval = compute_symbolic_block_difference(config, bsd, workscb, blk, ewb);\nif (errorval == -1e30f)\n{\nerrorval = -errorval;\n@@ -951,7 +951,7 @@ static float compress_symbolic_block_fixed_partition_2planes(\nworkscb.weights[j + PLANE2_WEIGHTS_OFFSET] = u8_weight2_src[j];\n}\n- float errorval = compute_symbolic_block_difference(config, &bsd, &workscb, &blk, &ewb);\n+ float errorval = compute_symbolic_block_difference(config, bsd, workscb, blk, ewb);\nif (errorval == -1e30f)\n{\nerrorval = -errorval;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_decompress_symbolic.cpp",
"new_path": "Source/astcenc_decompress_symbolic.cpp",
"diff": "#include <stdio.h>\n#include <assert.h>\n-static vint compute_value_of_texel_int_vla(\n+/**\n+ * @brief Compute a vector of texel weights by interpolating the decimated weight grid.\n+ *\n+ * @param texel_to_get The first texel to get; N (SIMD width) consecutive texels are loaded.\n+ * @param dt The weight grid decimation table.\n+ * @param weights The raw weights.\n+ *\n+ * @return The undecimated weight for N (SIMD width) texels.\n+ */\n+static vint compute_value_of_texel_weight_int_vla(\nint texel_to_get,\n- const decimation_table* dt,\n+ const decimation_table& dt,\nconst int* weights\n) {\nvint summed_value(8);\n- vint weight_count(dt->texel_weight_count + texel_to_get);\n+ vint weight_count(dt.texel_weight_count + texel_to_get);\nint max_weight_count = hmax(weight_count).lane<0>();\n+ promise(max_weight_count > 0);\nfor (int i = 0; i < max_weight_count; i++)\n{\n- vint texel_weights(dt->texel_weights_4t[i] + texel_to_get);\n- vint texel_weights_int(dt->texel_weights_int_4t[i] + texel_to_get);\n+ vint texel_weights(dt.texel_weights_4t[i] + texel_to_get);\n+ vint texel_weights_int(dt.texel_weights_int_4t[i] + texel_to_get);\nsummed_value += gatheri(weights, texel_weights) * texel_weights_int;\n}\n@@ -44,15 +54,27 @@ static vint compute_value_of_texel_int_vla(\nreturn lsr<4>(summed_value);\n}\n+/**\n+ * @brief Compute the integer linear interpolation of two color endpoints.\n+ *\n+ * @param decode_mode The ASTC profile (linear or sRGB)\n+ * @param color0 The endpoint0 color.\n+ * @param color1 The endpoint1 color.\n+ * @param weight_plane1 The interpolation weight (between 0 and 64) for plane 1.\n+ * @param weight_plane2 The interpolation weight (between 0 and 64) for plane 2.\n+ * @param plane2_mask The mask pattern for the plane assignment (set = plane 2).\n+ *\n+ * @return The interpolated color.\n+ */\nstatic vint4 lerp_color_int(\nastcenc_profile decode_mode,\nvint4 color0,\nvint4 color1,\n- int weight,\n- int plane2_weight,\n+ int weight_plane1,\n+ int weight_plane2,\nvmask4 plane2_mask\n) {\n- vint4 weight1 = select(vint4(weight), vint4(plane2_weight), plane2_mask);\n+ vint4 weight1 = select(vint4(weight_plane1), vint4(weight_plane2), plane2_mask);\nvint4 weight0 = vint4(64) - weight1;\nif (decode_mode == ASTCENC_PRF_LDR_SRGB)\n@@ -72,7 +94,14 @@ static vint4 lerp_color_int(\nreturn color;\n}\n-// Turn packed unorm16 or LNS data into generic float data\n+/**\n+ * @brief Convert integer color value into a float value for the decoder.\n+ *\n+ * @param data The integer color value post-interpolation.\n+ * @param lns_mask If set treat lane as HDR (LNS) else LDR (unorm16).\n+ *\n+ * @return The float color value.\n+ */\nstatic inline vfloat4 decode_texel(\nvint4 data,\nvmask4 lns_mask\n@@ -80,6 +109,7 @@ static inline vfloat4 decode_texel(\nvint4 color_lns = vint4::zero();\nvint4 color_unorm = vint4::zero();\n+ // TODO: Why bounce this via fp16 first?\nif (any(lns_mask))\n{\ncolor_lns = lns_to_sf16(data);\n@@ -95,12 +125,13 @@ static inline vfloat4 decode_texel(\nreturn float16_to_float(datai);\n}\n+/* See header for documentation. */\nvoid unpack_weights(\nconst block_size_descriptor& bsd,\nconst symbolic_compressed_block& scb,\nconst decimation_table& dt,\nbool is_dual_plane,\n- int weight_quant_level,\n+ int quant_level,\nint weights_plane1[MAX_TEXELS_PER_BLOCK],\nint weights_plane2[MAX_TEXELS_PER_BLOCK]\n) {\n@@ -109,7 +140,7 @@ void unpack_weights(\nint uq_plane2_weights[MAX_WEIGHTS_PER_BLOCK];\nint weight_count = dt.weight_count;\n- const quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_level]);\n+ const quantization_and_transfer_table *qat = &(quant_and_xfer_tables[quant_level]);\n// Second, undecimate the weights ...\n// Safe to overshoot as all arrays are allocated to full size\n@@ -122,7 +153,7 @@ void unpack_weights(\nfor (int i = 0; i < bsd.texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n- store(compute_value_of_texel_int_vla(i, &dt, uq_plane1_weights), weights_plane1 + i);\n+ store(compute_value_of_texel_weight_int_vla(i, dt, uq_plane1_weights), weights_plane1 + i);\n}\n}\nelse\n@@ -135,53 +166,54 @@ void unpack_weights(\nfor (int i = 0; i < bsd.texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n- store(compute_value_of_texel_int_vla(i, &dt, uq_plane1_weights), weights_plane1 + i);\n- store(compute_value_of_texel_int_vla(i, &dt, uq_plane2_weights), weights_plane2 + i);\n+ store(compute_value_of_texel_weight_int_vla(i, dt, uq_plane1_weights), weights_plane1 + i);\n+ store(compute_value_of_texel_weight_int_vla(i, dt, uq_plane2_weights), weights_plane2 + i);\n}\n}\n}\n+/* See header for documentation. */\nvoid decompress_symbolic_block(\nastcenc_profile decode_mode,\n- const block_size_descriptor* bsd,\n+ const block_size_descriptor& bsd,\nint xpos,\nint ypos,\nint zpos,\n- const symbolic_compressed_block* scb,\n- imageblock* blk\n+ const symbolic_compressed_block& scb,\n+ imageblock& blk\n) {\n- blk->xpos = xpos;\n- blk->ypos = ypos;\n- blk->zpos = zpos;\n+ blk.xpos = xpos;\n+ blk.ypos = ypos;\n+ blk.zpos = zpos;\n- blk->data_min = vfloat4::zero();\n- blk->data_max = vfloat4::zero();\n- blk->grayscale = false;\n+ blk.data_min = vfloat4::zero();\n+ blk.data_max = vfloat4::zero();\n+ blk.grayscale = false;\n// If we detected an error-block, blow up immediately.\n- if (scb->error_block)\n+ if (scb.error_block)\n{\n- for (int i = 0; i < bsd->texel_count; i++)\n+ for (int i = 0; i < bsd.texel_count; i++)\n{\n- blk->data_r[i] = std::numeric_limits<float>::quiet_NaN();\n- blk->data_g[i] = std::numeric_limits<float>::quiet_NaN();\n- blk->data_b[i] = std::numeric_limits<float>::quiet_NaN();\n- blk->data_a[i] = std::numeric_limits<float>::quiet_NaN();\n- blk->rgb_lns[i] = 0;\n- blk->alpha_lns[i] = 0;\n+ blk.data_r[i] = std::numeric_limits<float>::quiet_NaN();\n+ blk.data_g[i] = std::numeric_limits<float>::quiet_NaN();\n+ blk.data_b[i] = std::numeric_limits<float>::quiet_NaN();\n+ blk.data_a[i] = std::numeric_limits<float>::quiet_NaN();\n+ blk.rgb_lns[i] = 0;\n+ blk.alpha_lns[i] = 0;\n}\nreturn;\n}\n- if (scb->block_mode < 0)\n+ if (scb.block_mode < 0)\n{\nvfloat4 color;\nint use_lns = 0;\n- if (scb->block_mode == -2)\n+ if (scb.block_mode == -2)\n{\n- vint4 colori(scb->constant_color);\n+ vint4 colori(scb.constant_color);\n// For sRGB decoding a real decoder would just use the top 8 bits\n// for color conversion. We don't color convert, so linearly scale\n@@ -205,50 +237,50 @@ void decompress_symbolic_block(\ncase ASTCENC_PRF_HDR_RGB_LDR_A:\ncase ASTCENC_PRF_HDR:\n// Constant-color block; unpack from FP16 to FP32.\n- color = float16_to_float(vint4(scb->constant_color));\n+ color = float16_to_float(vint4(scb.constant_color));\nuse_lns = 1;\nbreak;\n}\n}\n// TODO: Skip this and add constant color transfer to img block?\n- for (int i = 0; i < bsd->texel_count; i++)\n+ for (int i = 0; i < bsd.texel_count; i++)\n{\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- blk->rgb_lns[i] = use_lns;\n- blk->alpha_lns[i] = use_lns;\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+ blk.rgb_lns[i] = use_lns;\n+ blk.alpha_lns[i] = use_lns;\n}\nreturn;\n}\n// Get the appropriate partition-table entry\n- int partition_count = scb->partition_count;\n- const partition_info *pt = get_partition_table(bsd, partition_count);\n- pt += scb->partition_index;\n+ int partition_count = scb.partition_count;\n+ const partition_info *pt = get_partition_table(&bsd, partition_count);\n+ pt += scb.partition_index;\n// Get the appropriate block descriptor\n- const decimation_table *const *dts = bsd->decimation_tables;\n+ const decimation_table *const *dts = bsd.decimation_tables;\n- const int packed_index = bsd->block_mode_packed_index[scb->block_mode];\n+ const int packed_index = bsd.block_mode_packed_index[scb.block_mode];\nassert(packed_index >= 0 && packed_index < bsd->block_mode_count);\n- const block_mode& bm = bsd->block_modes[packed_index];\n- const decimation_table *dt = dts[bm.decimation_mode];\n+ const block_mode& bm = bsd.block_modes[packed_index];\n+ const decimation_table& dt = *(dts[bm.decimation_mode]);\nint is_dual_plane = bm.is_dual_plane;\n- int weight_quant_level = bm.quant_mode;\n+ int quant_level = bm.quant_mode;\n// Unquantize and undecimate the weights\nint weights[MAX_TEXELS_PER_BLOCK];\nint plane2_weights[MAX_TEXELS_PER_BLOCK];\n- unpack_weights(*bsd, *scb, *dt, is_dual_plane, weight_quant_level, weights, plane2_weights);\n+ unpack_weights(bsd, scb, dt, is_dual_plane, quant_level, weights, plane2_weights);\n// Now that we have endpoint colors and weights, we can unpack texel colors\n- int plane2_component = is_dual_plane ? scb->plane2_component : -1;\n+ int plane2_component = is_dual_plane ? scb.plane2_component : -1;\nvmask4 plane2_mask = vint4::lane_id() == vint4(plane2_component);\nfor (int i = 0; i < partition_count; i++)\n@@ -260,9 +292,9 @@ void decompress_symbolic_block(\nbool a_lns;\nunpack_color_endpoints(decode_mode,\n- scb->color_formats[i],\n- scb->color_quant_level,\n- scb->color_values[i],\n+ scb.color_formats[i],\n+ scb.color_quant_level,\n+ scb.color_values[i],\nrgb_lns, a_lns,\nep0, ep1);\n@@ -281,51 +313,52 @@ void decompress_symbolic_block(\nvfloat4 colorf = decode_texel(color, lns_mask);\n- blk->data_r[tix] = colorf.lane<0>();\n- blk->data_g[tix] = colorf.lane<1>();\n- blk->data_b[tix] = colorf.lane<2>();\n- blk->data_a[tix] = colorf.lane<3>();\n+ blk.data_r[tix] = colorf.lane<0>();\n+ blk.data_g[tix] = colorf.lane<1>();\n+ blk.data_b[tix] = colorf.lane<2>();\n+ blk.data_a[tix] = colorf.lane<3>();\n}\n}\n}\n-// Returns a negative error for encodings we want to reject as a part of a\n-// heuristic check, e.g. for RGBM textures which have zero M values.\n+#if !defined(ASTCENC_DECOMPRESS_ONLY)\n+\n+/* See header for documentation. */\nfloat compute_symbolic_block_difference(\nconst astcenc_config& config,\n- const block_size_descriptor* bsd,\n- const symbolic_compressed_block* scb,\n- const imageblock* blk,\n- const error_weight_block *ewb\n+ const block_size_descriptor& bsd,\n+ const symbolic_compressed_block& scb,\n+ const imageblock& blk,\n+ const error_weight_block& ewb\n) {\n// If we detected an error-block, blow up immediately.\n- if (scb->error_block)\n+ if (scb.error_block)\n{\nreturn 1e29f;\n}\n- assert(scb->block_mode >= 0);\n+ assert(scb.block_mode >= 0);\n// Get the appropriate partition-table entry\n- int partition_count = scb->partition_count;\n+ int partition_count = scb.partition_count;\n- const partition_info *pt = get_partition_table(bsd, partition_count);\n- pt += scb->partition_index;\n+ const partition_info *pt = get_partition_table(&bsd, partition_count);\n+ pt += scb.partition_index;\n// Get the appropriate block descriptor\n- const int packed_index = bsd->block_mode_packed_index[scb->block_mode];\n- assert(packed_index >= 0 && packed_index < bsd->block_mode_count);\n- const block_mode& bm = bsd->block_modes[packed_index];\n- const decimation_table *dt = bsd->decimation_tables[bm.decimation_mode];\n+ const int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n+ assert(packed_index >= 0 && packed_index < bsd.block_mode_count);\n+ const block_mode& bm = bsd.block_modes[packed_index];\n+ const decimation_table& dt = *(bsd.decimation_tables[bm.decimation_mode]);\nbool is_dual_plane = bm.is_dual_plane != 0;\n// Unquantize and undecimate the weights\nint weights[MAX_TEXELS_PER_BLOCK];\nint plane2_weights[MAX_TEXELS_PER_BLOCK];\n- unpack_weights(*bsd, *scb, *dt, is_dual_plane, bm.quant_mode, weights, plane2_weights);\n+ unpack_weights(bsd, scb, dt, is_dual_plane, bm.quant_mode, weights, plane2_weights);\n- int plane2_component = is_dual_plane ? scb->plane2_component : -1;\n+ int plane2_component = is_dual_plane ? scb.plane2_component : -1;\nvmask4 plane2_mask = vint4::lane_id() == vint4(plane2_component);\nfloat summa = 0.0f;\n@@ -338,9 +371,9 @@ float compute_symbolic_block_difference(\nbool a_lns;\nunpack_color_endpoints(config.profile,\n- scb->color_formats[i],\n- scb->color_quant_level,\n- scb->color_values[i],\n+ scb.color_formats[i],\n+ scb.color_quant_level,\n+ scb.color_values[i],\nrgb_lns, a_lns,\nep0, ep1);\n@@ -357,7 +390,7 @@ float compute_symbolic_block_difference(\nplane2_weights[tix], plane2_mask);\nvfloat4 color = int_to_float(colori);\n- vfloat4 oldColor = blk->texel(tix);\n+ vfloat4 oldColor = blk.texel(tix);\n// Compare error using a perceptual decode metric for RGBM textures\nif (config.flags & ASTCENC_FLG_MAP_RGBM)\n@@ -393,11 +426,12 @@ float compute_symbolic_block_difference(\nerror = min(abs(error), 1e15f);\nerror = error * error;\n- float metric = dot_s(error, ewb->error_weights[tix]);\n+ float metric = dot_s(error, ewb.error_weights[tix]);\nsumma += astc::min(metric, 1e30f);\n}\n}\n-\nreturn summa;\n}\n+\n+#endif\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -1064,9 +1064,9 @@ astcenc_error astcenc_decompress_image(\nphysical_to_symbolic(*ctx->bsd, pcb, scb);\n- decompress_symbolic_block(ctx->config.profile, ctx->bsd,\n+ decompress_symbolic_block(ctx->config.profile, *ctx->bsd,\nx * block_x, y * block_y, z * block_z,\n- &scb, &blk);\n+ scb, blk);\nwrite_imageblock(image_out, &blk, ctx->bsd,\nx * block_x, y * block_y, z * block_z, *swizzle);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1146,13 +1146,6 @@ void write_imageblock(\nint zpos,\nconst astcenc_swizzle& swz);\n-float compute_symbolic_block_difference(\n- const astcenc_config& config,\n- const block_size_descriptor* bsd,\n- const symbolic_compressed_block* scb,\n- const imageblock* blk,\n- const error_weight_block *ewb) ;\n-\n// ***********************************************************\n// functions pertaining to computing texel weights for a block\n// ***********************************************************\n@@ -1333,13 +1326,23 @@ void unpack_color_endpoints(\nvint4& output0,\nvint4& output1);\n-// unquantize and undecimate a weight grid\n+/**\n+ * @brief Unpack a set of quantized and decimated weights.\n+ *\n+ * @param bsd The block size information.\n+ * @param scb The symbolic compressed encoding.\n+ * @param dt The weight grid decimation table.\n+ * @param is_dual_plane @c true if this is a dual plane block, @c false otherwise.\n+ * @param quant_level The weight quantization level.\n+ * @param[out] weights_plane1 The output array for storing the plane 1 weights.\n+ * @param[out] weights_plane2 The output array for storing the plane 2 weights.\n+ */\nvoid unpack_weights(\nconst block_size_descriptor& bsd,\nconst symbolic_compressed_block& scb,\nconst decimation_table& dt,\nbool is_dual_plane,\n- int weight_quant_level,\n+ int quant_level,\nint weights_plane1[MAX_TEXELS_PER_BLOCK],\nint weights_plane2[MAX_TEXELS_PER_BLOCK]);\n@@ -1444,7 +1447,7 @@ void compute_angular_endpoints_2planes(\n/* *********************************** high-level encode and decode functions ************************************ */\n/**\n- * @brief Determine the lowest cross-channel correlation factor.\n+ * @brief Compress an image block into a physical block.\n*\n* @param ctx The compressor context and configuration.\n* @param image The input image information.\n@@ -1459,14 +1462,45 @@ void compress_block(\nphysical_compressed_block& pcb,\ncompress_symbolic_block_buffers& tmpbuf);\n+/**\n+ * @brief Decompress a symbolic block in to an image block.\n+ *\n+ * @param decode_mode The decode mode (LDR, HDR, etc).\n+ * @param bsd The block size information.\n+ * @param xpos The X coordinate of the block in the overall image.\n+ * @param ypos The Y coordinate of the block in the overall image.\n+ * @param zpos The Z coordinate of the block in the overall image.\n+ * @param[out] blk The decompressed image block color data.\n+ */\nvoid decompress_symbolic_block(\nastcenc_profile decode_mode,\n- const block_size_descriptor* bsd,\n+ const block_size_descriptor& bsd,\nint xpos,\nint ypos,\nint zpos,\n- const symbolic_compressed_block* scb,\n- imageblock* blk);\n+ const symbolic_compressed_block& scb,\n+ imageblock& blk);\n+\n+/**\n+ * @brief Compute the error between a symbolic block and the original input data.\n+ *\n+ * In RGBM mode this will reject blocks that attempt to encode a zero M value.\n+ *\n+ * @param config The compressor config.\n+ * @param bsd The block size information.\n+ * @param scb The symbolic compressed encoding.\n+ * @param blk The original image block color data.\n+ * @param ewb The error weight block data.\n+ *\n+ * @return Returns the computed error, or a negative value if the encoding\n+ * should be rejected for any reason.\n+ */\n+float compute_symbolic_block_difference(\n+ const astcenc_config& config,\n+ const block_size_descriptor& bsd,\n+ const symbolic_compressed_block& scb,\n+ const imageblock& blk,\n+ const error_weight_block& ewb) ;\nvoid symbolic_to_physical(\nconst block_size_descriptor& bsd,\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup API for decompress_symbolic
|
61,745 |
14.05.2021 23:08:48
| -3,600 |
85317ae8fe97ead270d1608ede06b527de52cac8
|
Cleanup API for diagnostic_trace
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_diagnostic_trace.cpp",
"new_path": "Source/astcenc_diagnostic_trace.cpp",
"diff": "@@ -43,6 +43,7 @@ TraceLog::TraceLog(\nm_root = new TraceNode(\"root\");\n}\n+/* See header for documentation. */\nTraceNode* TraceLog::get_current_leaf()\n{\nif (m_stack.size())\n@@ -53,11 +54,13 @@ TraceNode* TraceLog::get_current_leaf()\nreturn nullptr;\n}\n+/* See header for documentation. */\nint TraceLog::get_depth()\n{\nreturn m_stack.size();\n}\n+/* See header for documentation. */\nTraceLog::~TraceLog()\n{\nassert(g_TraceLog == this);\n@@ -65,6 +68,7 @@ TraceLog::~TraceLog()\ng_TraceLog = nullptr;\n}\n+/* See header for documentation. */\nTraceNode::TraceNode(\nconst char* format,\n...\n@@ -119,6 +123,7 @@ TraceNode::TraceNode(\nout << in_indents << \"[\";\n}\n+/* See header for documentation. */\nvoid TraceNode::add_attrib(\nstd::string type,\nstd::string key,\n@@ -143,6 +148,7 @@ void TraceNode::add_attrib(\n<< value << \" ]\";\n}\n+/* See header for documentation. */\nTraceNode::~TraceNode()\n{\ng_TraceLog->m_stack.pop_back();\n@@ -169,6 +175,7 @@ TraceNode::~TraceNode()\nout << out_indents << \"]\";\n}\n+/* See header for documentation. */\nvoid trace_add_data(\nconst char* key,\nconst char* format,\n@@ -191,6 +198,7 @@ void trace_add_data(\nnode->add_attrib(\"str\", key, value);\n}\n+/* See header for documentation. */\nvoid trace_add_data(\nconst char* key,\nfloat value\n@@ -201,6 +209,7 @@ void trace_add_data(\nnode->add_attrib(\"float\", key, buffer);\n}\n+/* See header for documentation. */\nvoid trace_add_data(\nconst char* key,\nint value\n@@ -209,6 +218,7 @@ void trace_add_data(\nnode->add_attrib(\"int\", key, std::to_string(value));\n}\n+/* See header for documentation. */\nvoid trace_add_data(\nconst char* key,\nunsigned int value\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup API for diagnostic_trace
|
61,745 |
14.05.2021 23:27:06
| -3,600 |
172d511f7b80b75b24430f417e14304699eadbc5
|
Cleanup API for astcenc_entry
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "*\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+ * Note that the mse_overshoot entries are scaling factors relative to the base MSE to hit db_limit.\n+ * A 20% overshoot is harder to hit for a higher base db_limit, so we may actually use lower ratios\n+ * for the more through search presets because the underlying db_limit is so much higher.\n*/\nstruct astcenc_preset_config {\nfloat quality;\n@@ -126,13 +125,16 @@ static const std::array<astcenc_preset_config, 5> preset_configs_low {{\n}\n}};\n-\n-// The ASTC codec is written with the assumption that a float threaded through\n-// the \"if32\" union will in fact be stored and reloaded as a 32-bit IEEE-754 single-precision\n-// float, stored with round-to-nearest rounding. This is always the case in an\n-// IEEE-754 compliant system, however not every system is actually IEEE-754 compliant\n-// in the first place. As such, we run a quick test to check that this is actually the case\n-// (e.g. gcc on 32-bit x86 will typically fail unless -msse2 -mfpmath=sse2 is specified).\n+/**\n+ * @brief Validate CPU floating point meets assumptions made in the codec.\n+ *\n+ * The codec is written with the assumption that a float threaded through the @c if32 union will be\n+ * stored and reloaded as a 32-bit IEEE-754 float with round-to-nearest rounding. This is always the\n+ * case in an IEEE-754 compliant system, however not every system or compilation mode is actually\n+ * IEEE-754 compliant. This normally fails if the code is compiled with fast math enabled.\n+ *\n+ * @return Return @c ASTCENC_SUCCESS if validated, otherwise an error on failure.\n+ */\nstatic astcenc_error validate_cpu_float()\n{\nif32 p;\n@@ -148,6 +150,15 @@ static astcenc_error validate_cpu_float()\nreturn ASTCENC_SUCCESS;\n}\n+/**\n+ * @brief Validate CPU ISA support meets the requirements of this build of the library.\n+ *\n+ * Each library build is statically compiled for a particular set of CPU ISA features, such as the\n+ * SIMD support or other ISA extensions such as POPCNT. This function checks that the host CPU\n+ * actually supports everything this build needs.\n+ *\n+ * @return Return @c ASTCENC_SUCCESS if validated, otherwise an error on failure.\n+ */\nstatic astcenc_error validate_cpu_isa()\n{\n#if ASTCENC_SSE >= 41\n@@ -181,6 +192,13 @@ static astcenc_error validate_cpu_isa()\nreturn ASTCENC_SUCCESS;\n}\n+/**\n+ * @brief Validate config profile.\n+ *\n+ * @param profile The profile to check.\n+ *\n+ * @return Return @c ASTCENC_SUCCESS if validated, otherwise an error on failure.\n+ */\nstatic astcenc_error validate_profile(\nastcenc_profile profile\n) {\n@@ -198,6 +216,15 @@ static astcenc_error validate_profile(\n}\n}\n+/**\n+ * @brief Validate block size.\n+ *\n+ * @param block_x The block x dimensions.\n+ * @param block_y The block y dimensions.\n+ * @param block_z The block z dimensions.\n+ *\n+ * @return Return @c ASTCENC_SUCCESS if validated, otherwise an error on failure.\n+ */\nstatic astcenc_error validate_block_size(\nunsigned int block_x,\nunsigned int block_y,\n@@ -212,6 +239,13 @@ static astcenc_error validate_block_size(\nreturn ASTCENC_ERR_BAD_BLOCK_SIZE;\n}\n+/**\n+ * @brief Validate flags.\n+ *\n+ * @param flags The flags to check.\n+ *\n+ * @return Return @c ASTCENC_SUCCESS if validated, otherwise an error on failure.\n+ */\nstatic astcenc_error validate_flags(\nunsigned int flags\n) {\n@@ -235,6 +269,14 @@ static astcenc_error validate_flags(\n}\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\n+\n+/**\n+ * @brief Validate single channel compression swizzle.\n+ *\n+ * @param swizzle The swizzle to check.\n+ *\n+ * @return Return @c ASTCENC_SUCCESS if validated, otherwise an error on failure.\n+ */\nstatic astcenc_error validate_compression_swz(\nastcenc_swz swizzle\n) {\n@@ -253,6 +295,13 @@ static astcenc_error validate_compression_swz(\n}\n}\n+/**\n+ * @brief Validate overall compression swizzle.\n+ *\n+ * @param swizzle The swizzle to check.\n+ *\n+ * @return Return @c ASTCENC_SUCCESS if validated, otherwise an error on failure.\n+ */\nstatic astcenc_error validate_compression_swizzle(\nconst astcenc_swizzle& swizzle\n) {\n@@ -268,6 +317,13 @@ static astcenc_error validate_compression_swizzle(\n}\n#endif\n+/**\n+ * @brief Validate single channel decompression swizzle.\n+ *\n+ * @param swizzle The swizzle to check.\n+ *\n+ * @return Return @c ASTCENC_SUCCESS if validated, otherwise an error on failure.\n+ */\nstatic astcenc_error validate_decompression_swz(\nastcenc_swz swizzle\n) {\n@@ -288,6 +344,13 @@ static astcenc_error validate_decompression_swz(\n}\n}\n+/**\n+ * @brief Validate overall decompression swizzle.\n+ *\n+ * @param swizzle The swizzle to check.\n+ *\n+ * @return Return @c ASTCENC_SUCCESS if validated, otherwise an error on failure.\n+ */\nstatic astcenc_error validate_decompression_swizzle(\nconst astcenc_swizzle& swizzle\n) {\n@@ -311,6 +374,10 @@ static astcenc_error validate_decompression_swizzle(\n* ranges. No error is thrown for out-of-range inputs in this case.\n* * Numerical inputs and logic inputs are are logically invalid and which\n* make no sense algorithmically will return an error.\n+ *\n+ * @param[in,out] config The input compressor configuration.\n+ *\n+ * @return Return @c ASTCENC_SUCCESS if validated, otherwise an error on failure.\n*/\nstatic astcenc_error validate_config(\nastcenc_config &config\n@@ -390,6 +457,7 @@ static astcenc_error validate_config(\nreturn ASTCENC_SUCCESS;\n}\n+/* See header for documentation. */\nastcenc_error astcenc_config_init(\nastcenc_profile profile,\nunsigned int block_x,\n@@ -628,6 +696,7 @@ astcenc_error astcenc_config_init(\nreturn ASTCENC_SUCCESS;\n}\n+/* See header for documentation. */\nastcenc_error astcenc_context_alloc(\nconst astcenc_config* configp,\nunsigned int thread_count,\n@@ -742,6 +811,7 @@ astcenc_error astcenc_context_alloc(\nreturn ASTCENC_SUCCESS;\n}\n+/* See header dor documentation. */\nvoid astcenc_context_free(\nastcenc_context* ctx\n) {\n@@ -758,11 +828,21 @@ void astcenc_context_free(\n}\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\n+\n+/**\n+ * @brief Compress an image, after any preflight has completed.\n+ *\n+ * @param[out] ctx The compressor context.\n+ * @param thread_index The thread index.\n+ * @param image The intput image.\n+ * @param swizzle The input swizzle.\n+ * @param[out] buffer The output array for the compressed data.\n+ */\nstatic void compress_image(\nastcenc_context& ctx,\nunsigned int thread_index,\nconst astcenc_image& image,\n- astcenc_swizzle swizzle,\n+ const astcenc_swizzle& swizzle,\nuint8_t* buffer\n) {\nconst block_size_descriptor *bsd = ctx.bsd;\n@@ -785,7 +865,7 @@ static void compress_image(\nint plane_blocks = xblocks * yblocks;\n// Use preallocated scratch buffer\n- auto temp_buffers = &(ctx.working_buffers[thread_index]);\n+ auto& temp_buffers = ctx.working_buffers[thread_index];\n// Only the first thread actually runs the initializer\nctx.manage_compress.init(zblocks * yblocks * xblocks);\n@@ -821,11 +901,9 @@ static void compress_image(\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+ int x_footprint = block_x + 2 * (ctx.config.a_scale_radius - 1);\n- int y_footprint = block_y +\n- 2 * (ctx.config.a_scale_radius - 1);\n+ int y_footprint = block_y + 2 * (ctx.config.a_scale_radius - 1);\nfloat footprint = (float)(x_footprint * y_footprint);\nfloat threshold = 0.9f / (255.0f * footprint);\n@@ -864,14 +942,16 @@ static void compress_image(\nint offset = ((z * yblocks + y) * xblocks + x) * 16;\nuint8_t *bp = buffer + offset;\nphysical_compressed_block* pcb = reinterpret_cast<physical_compressed_block*>(bp);\n- compress_block(ctx, image, blk, *pcb, *temp_buffers);\n+ compress_block(ctx, image, blk, *pcb, temp_buffers);\n}\nctx.manage_compress.complete_task_assignment(count);\n}\n}\n+\n#endif\n+/* See header for documentation. */\nastcenc_error astcenc_compress_image(\nastcenc_context* ctx,\nastcenc_image* imagep,\n@@ -975,6 +1055,7 @@ astcenc_error astcenc_compress_image(\n#endif\n}\n+/* See header for documentation. */\nastcenc_error astcenc_compress_reset(\nastcenc_context* ctx\n) {\n@@ -993,6 +1074,7 @@ astcenc_error astcenc_compress_reset(\n#endif\n}\n+/* See header for documentation. */\nastcenc_error astcenc_decompress_image(\nastcenc_context* ctx,\nconst uint8_t* data,\n@@ -1078,6 +1160,7 @@ astcenc_error astcenc_decompress_image(\nreturn ASTCENC_SUCCESS;\n}\n+/* See header for documentation. */\nastcenc_error astcenc_decompress_reset(\nastcenc_context* ctx\n) {\n@@ -1085,6 +1168,7 @@ astcenc_error astcenc_decompress_reset(\nreturn ASTCENC_SUCCESS;\n}\n+/* See header for documentation. */\nastcenc_error astcenc_get_block_info(\nastcenc_context* ctx,\nconst uint8_t data[16],\n@@ -1206,7 +1290,7 @@ astcenc_error astcenc_get_block_info(\n#endif\n}\n-\n+/* See header for documentation. */\nconst char* astcenc_get_error_string(\nastcenc_error status\n) {\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup API for astcenc_entry
|
61,745 |
14.05.2021 23:47:16
| -3,600 |
654f80bac0c4b1f6682bbd34551580bb126ccee1
|
Cleanup API for pick_best_endpoint_format
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -1588,10 +1588,10 @@ void compress_block(\nint partition_indices_1plane[2] { 0, 0 };\nint partition_index_2planes = 0;\n- find_best_partitionings(bsd, &blk, &ewb, partition_count,\n+ find_best_partitionings(*bsd, blk, ewb, partition_count,\nctx.config.tune_partition_index_limit,\n- &(partition_indices_1plane[0]),\n- &(partition_indices_1plane[1]),\n+ partition_indices_1plane[0],\n+ partition_indices_1plane[1],\nblock_skip_two_plane ? nullptr : &partition_index_2planes);\nfor (int i = 0; i < 2; i++)\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_find_best_partitioning.cpp",
"new_path": "Source/astcenc_find_best_partitioning.cpp",
"diff": "* @brief Functions for finding best partition for a block.\n*\n* Major step 1:\n- * - find best partitioning assuming uncorrelated colors\n- * - find best partitioning assuming RGBS color representation\n+ *\n+ * - Find best partitioning assuming uncorrelated colors.\n+ * - Find best partitioning assuming RGBS color representation.\n*\n* Finding best partitioning for a block:\n*\n- * foreach available partitioning:\n- * - compute mean-color-value and dominant direction.\n- * - this defines two lines, both of which go through the mean-color-value.\n- * - one line has a direction defined by the dominant direction; this is used\n+ * For each available partitioning compute mean color and dominant direction.\n+ * This defines two lines, both of which go through the mean-color-value.\n+ *\n+ * - One line has a direction defined by the dominant direction; this is used\n* to assess the error from using an uncorrelated color representation.\n- * - the other line goes through (0,0,0,1) and is used to assess the error from\n+ * - The other line goes through (0,0,0,1) and is used to assess the error from\n* using an RGBS color representation.\n- * - we then compute, as a sum across the block, the squared-errors that result\n- * from using the dominant-direction-lines and the squared-errors that result\n- * from using the 0001-lines.\n- *\n- * Partition table representation:\n- * We have 3 tables, each with 1024 partitions\n- * (these correspond to the 3x128 hardware partitions crossed with all the\n- * partition-transform modes in the hardware.)\n*\n- * For each partitioning, we have:\n- * * a 4-entry table indicating how many texels there are in each of the 4\n- * partitions. this may be from 2 to about 60 or so.\n- * * a 64-entry table indicating the partition index of each of the 64 texels\n- * in the block. each index may be 0, 1, 2 or 3.\n- *\n- * each element in the table is an uint8_t indicating partition index (0, 1, 2 or 3)\n+ * Then compute the block's squared-errors that result from using the these\n+ * two lines for endpoint selection.\n*/\n#include \"astcenc_internal.h\"\n-void compute_partition_error_color_weightings(\n- const error_weight_block& ewb,\n- const partition_info& pt,\n- partition_metrics pm[4]\n-) {\n- int partition_count = pt.partition_count;\n- promise(partition_count > 0);\n-\n- for (int i = 0; i < partition_count; i++)\n- {\n- vfloat4 error_weight(1e-12f);\n-\n- int texel_count = pt.partition_texel_count[i];\n- promise(texel_count > 0);\n-\n- for (int j = 0; j < texel_count; j++)\n- {\n- int tidx = pt.texels_of_partition[i][j];\n- error_weight = error_weight + ewb.error_weights[tidx];\n- }\n-\n- error_weight = error_weight / pt.partition_texel_count[i];\n- pm[i].error_weight = error_weight;\n- }\n-}\n-\n-/* main function to identify the best partitioning for a given number of texels */\n+/* See header for documentation. */\nvoid find_best_partitionings(\n- const block_size_descriptor* bsd,\n- const imageblock* blk,\n- const error_weight_block* ewb,\n+ const block_size_descriptor& bsd,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\nint partition_count,\nint partition_search_limit,\n- int* best_partition_uncor,\n- int* best_partition_samec,\n+ int& best_partition_uncor,\n+ int& best_partition_samec,\nint* best_partition_dualplane\n) {\n// constant used to estimate quantization error for a given partitioning;\n// the optimal value for this constant depends on bitrate.\n// These constants have been determined empirically.\n- int texels_per_block = bsd->texel_count;\n+ int texels_per_block = bsd.texel_count;\nfloat weight_imprecision_estim = 0.055f;\nif (texels_per_block <= 20)\n{\n@@ -115,11 +77,11 @@ void find_best_partitionings(\nint partition_sequence[PARTITION_COUNT];\n- kmeans_compute_partition_ordering(*bsd, *blk, partition_count, partition_sequence);\n+ kmeans_compute_partition_ordering(bsd, blk, partition_count, partition_sequence);\n- int uses_alpha = imageblock_uses_alpha(blk);\n+ int uses_alpha = imageblock_uses_alpha(&blk);\n- const partition_info* ptab = get_partition_table(bsd, partition_count);\n+ const partition_info* ptab = get_partition_table(&bsd, partition_count);\n// Partitioning errors assuming uncorrelated-chrominance endpoints\nfloat uncor_best_error { ERROR_CALC_DEFAULT };\n@@ -152,7 +114,7 @@ void find_best_partitionings(\n// Compute weighting to give to each component in each partition\npartition_metrics pms[4];\n- compute_avgs_and_dirs_4_comp(*(ptab + partition), *blk, *ewb, pms);\n+ compute_avgs_and_dirs_4_comp(*(ptab + partition), blk, ewb, pms);\nline4 uncor_lines[4];\nline4 samec_lines[4];\n@@ -210,8 +172,8 @@ void find_best_partitionings(\nvfloat4 sep_error = vfloat4::zero();\ncompute_error_squared_rgba(*(ptab + partition),\n- *blk,\n- *ewb,\n+ blk,\n+ ewb,\nuncor_plines,\nsamec_plines,\nuncor_line_lens,\n@@ -335,7 +297,7 @@ void find_best_partitionings(\n// Compute weighting to give to each component in each partition\npartition_metrics pms[4];\n- compute_avgs_and_dirs_3_comp(*(ptab + partition), *blk, *ewb, 3, pms);\n+ compute_avgs_and_dirs_3_comp(*(ptab + partition), blk, ewb, 3, pms);\npartition_lines3 plines[4];\n@@ -383,8 +345,8 @@ void find_best_partitionings(\nvfloat4 sep_error = vfloat4::zero();\ncompute_error_squared_rgb(*(ptab + partition),\n- *blk,\n- *ewb,\n+ blk,\n+ ewb,\nplines,\nuncor_error,\nsamec_error);\n@@ -489,10 +451,10 @@ void find_best_partitionings(\n}\n}\n- *best_partition_uncor = uncor_best_partition;\n+ best_partition_uncor = uncor_best_partition;\nint index = samec_best_partitions[0] != uncor_best_partition ? 0 : 1;\n- *best_partition_samec = samec_best_partitions[index];\n+ best_partition_samec = samec_best_partitions[index];\nif (best_partition_dualplane)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1000,32 +1000,32 @@ void compute_error_squared_rgb(\nfloat& uncor_error,\nfloat& samec_error);\n-// for each partition, compute its color weightings.\n-void compute_partition_error_color_weightings(\n- const error_weight_block& ewb,\n- const partition_info& pt,\n- partition_metrics pm[4]);\n-\n/**\n* @brief Find the best set of partitions to trial for a given block.\n*\n- * On return @c best_partition_uncorrelated contains the best partition\n- * assuming the data has noncorrelated chroma, @c best_partition_samechroma\n- * contains the best partition assuming the data has corelated chroma, and\n- * @c best_partition_dualplane contains the best partition assuming the data\n- * has one uncorrelated color component.\n+ * On return @c best_partition_uncor contains the best partition assuming data has uncorrelated\n+ * chroma, @c best_partition_samec contains the best partition assuming data has corelated chroma,\n+ * and* @c best_partition_dualplane contains the best partition assuming the data has one\n+ * uncorrelated color component. The @c best_partition_dualplane is stored packed; bits [9:0]\n+ * contain the best partition, bits [11:10] contain the best color component.\n*\n- * @c best_partition_dualplane is stored packed; bits [9:0] contain the\n- * best partition, bits [11:10] contain the best color component.\n+ * @param bsd The block size information.\n+ * @param blk The image block color data to compress.\n+ * @param ewb The image block weighted error data.\n+ * @param partition_count The number of partitions in the block.\n+ * @param partition_search_limit The number of candidate partition encodings to trial.\n+ * @param[out] best_partition_uncor The best partition for uncorrelated chroma.\n+ * @param[out] best_partition_samec The best partition for correlated chroma.\n+ * @param[out] best_partition_dualplane The best partition for dual plane, but may be @c nullptr.\n*/\nvoid find_best_partitionings(\n- const block_size_descriptor* bsd,\n- const imageblock* blk,\n- const error_weight_block* ewb,\n+ const block_size_descriptor& bsd,\n+ const imageblock& blk,\n+ const error_weight_block& ewb,\nint partition_count,\nint partition_search_limit,\n- int* best_partition_uncorrelated,\n- int* best_partition_samechroma,\n+ int& best_partition_uncor,\n+ int& best_partition_samec,\nint* best_partition_dualplane);\n// use k-means clustering to compute a partition ordering for a block.\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"new_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"diff": "#include <assert.h>\n+/**\n+ * @brief Compute cumulative error weight of each partition.\n+ *\n+ * The cumulative error weight is used to determine the relative importance of\n+ * each partiton when deciding how to quantize colors, as not all partitions\n+ * are equal. For example, some partitions will have far fewer texels than\n+ * others in the same block.\n+ *\n+ * @param ewb The block error weights.\n+ * @param pi The partiion info.\n+ * @param[out] pm The output metrics; only writes to @c error_weight field.\n+ */\n+static void compute_partition_error_color_weightings(\n+ const error_weight_block& ewb,\n+ const partition_info& pi,\n+ partition_metrics pm[4]\n+) {\n+ int partition_count = pi.partition_count;\n+ promise(partition_count > 0);\n+\n+ for (int i = 0; i < partition_count; i++)\n+ {\n+ vfloat4 error_weight(1e-12f);\n+\n+ int texel_count = pi.partition_texel_count[i];\n+ promise(texel_count > 0);\n+\n+ for (int j = 0; j < texel_count; j++)\n+ {\n+ int tidx = pi.texels_of_partition[i][j];\n+ error_weight = error_weight + ewb.error_weights[tidx];\n+ }\n+\n+ error_weight = error_weight / pi.partition_texel_count[i];\n+ pm[i].error_weight = error_weight;\n+ }\n+}\n+\n/**\n* @brief Compute the errors of the endpoint line options for one partition.\n*\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup API for pick_best_endpoint_format
|
61,745 |
15.05.2021 23:12:36
| -3,600 |
996a7feb5b885924cc3bc983cad5f192fc570539
|
Cleanup API for kmeans_partitioning
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1028,7 +1028,14 @@ void find_best_partitionings(\nint& best_partition_samec,\nint* best_partition_dualplane);\n-// use k-means clustering to compute a partition ordering for a block.\n+/**\n+ * @brief Use k-means clustering to compute a partition ordering for a block..\n+ *\n+ * @param bsd The block size information.\n+ * @param blk The image block color data to compress.\n+ * @param partition_count The desired number of partitions in the block.\n+ * @param[out] partition_ordering The list of recommended partition indices, in priority order.\n+ */\nvoid kmeans_compute_partition_ordering(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_kmeans_partitioning.cpp",
"new_path": "Source/astcenc_kmeans_partitioning.cpp",
"diff": "/**\n* @brief Pick some initital kmeans cluster centers.\n+ *\n+ * @param blk The image block color data to compress.\n+ * @param texel_count The number of texels in the block.\n+ * @param partition_count The number of partitions in the block.\n+ * @param[out] cluster_centers The initital partition cluster center colors.\n*/\nstatic void kmeans_init(\nconst imageblock& blk,\n@@ -113,6 +118,14 @@ static void kmeans_init(\n/**\n* @brief Assign texels to clusters, based on a set of chosen center points.\n+ *\n+ * @todo Can partition of texel be uint8_t not int?\n+ *\n+ * @param blk The image block color data to compress.\n+ * @param texel_count The number of texels in the block.\n+ * @param partition_count The number of partitions in the block.\n+ * @param cluster_centers The partition cluster center colors.\n+ * @param[out] partition_of_texel The partition assigned for each texel.\n*/\nstatic void kmeans_assign(\nconst imageblock& blk,\n@@ -172,6 +185,12 @@ static void kmeans_assign(\n/**\n* @brief Compute new cluster centers based on their center of gravity.\n+ *\n+ * @param blk The image block color data to compress.\n+ * @param texel_count The number of texels in the block.\n+ * @param partition_count The number of partitions in the block.\n+ * @param[out] cluster_centers The new cluster center colors.\n+ * @param partition_of_texel The partition assigned for each texel.\n*/\nstatic void kmeans_update(\nconst imageblock& blk,\n@@ -210,10 +229,15 @@ static void kmeans_update(\n/**\n* @brief Compute bit-mismatch for partitioning in 2-partition mode.\n+ *\n+ * @param a The texel assignment bitvector for the block.\n+ * @param b The texel assignment bitvector for the partition table.\n+ *\n+ * @return The number of bit mismatches.\n*/\nstatic inline int partition_mismatch2(\n- const uint64_t* a,\n- const uint64_t* b\n+ const uint64_t a[2],\n+ const uint64_t b[2]\n) {\nint v1 = astc::popcount(a[0] ^ b[0]) + astc::popcount(a[1] ^ b[1]);\nint v2 = astc::popcount(a[0] ^ b[1]) + astc::popcount(a[1] ^ b[0]);\n@@ -222,10 +246,15 @@ static inline int partition_mismatch2(\n/**\n* @brief Compute bit-mismatch for partitioning in 3-partition mode.\n+ *\n+ * @param a The texel assignment bitvector for the block.\n+ * @param b The texel assignment bitvector for the partition table.\n+ *\n+ * @return The number of bit mismatches.\n*/\nstatic inline int partition_mismatch3(\n- const uint64_t* a,\n- const uint64_t* b\n+ const uint64_t a[3],\n+ const uint64_t b[3]\n) {\nint p00 = astc::popcount(a[0] ^ b[0]);\nint p01 = astc::popcount(a[0] ^ b[1]);\n@@ -256,10 +285,15 @@ static inline int partition_mismatch3(\n/**\n* @brief Compute bit-mismatch for partitioning in 4-partition mode.\n+ *\n+ * @param a The texel assignment bitvector for the block.\n+ * @param b The texel assignment bitvector for the partition table.\n+ *\n+ * @return The number of bit mismatches.\n*/\nstatic inline int partition_mismatch4(\n- const uint64_t* a,\n- const uint64_t* b\n+ const uint64_t a[4],\n+ const uint64_t b[4]\n) {\nint p00 = astc::popcount(a[0] ^ b[0]);\nint p01 = astc::popcount(a[0] ^ b[1]);\n@@ -296,17 +330,21 @@ static inline int partition_mismatch4(\nreturn astc::min(v0, v1, v2, v3);\n}\n-\nusing mismatch_dispatch = int (*)(const uint64_t*, const uint64_t*);\n/**\n* @brief Count the partition table mismatches vs the data clustering.\n+ *\n+ * @param bsd The block size information.\n+ * @param partition_count The number of partitions in the block.\n+ * @param bitmaps The block texel partition assignment patterns.\n+ * @param[out] mismatch_counts The array storing per partitioning mismatch counts.\n*/\nstatic void count_partition_mismatch_bits(\nconst block_size_descriptor& bsd,\nint partition_count,\nconst uint64_t bitmaps[4],\n- int bitcounts[PARTITION_COUNT]\n+ int mismatch_counts[PARTITION_COUNT]\n) {\nconst partition_info *pt = get_partition_table(&bsd, partition_count);\n@@ -325,16 +363,19 @@ static void count_partition_mismatch_bits(\nbitcount = dispatch[partition_count - 2](bitmaps, pt->coverage_bitmaps);\n}\n- bitcounts[i] = bitcount;\n+ mismatch_counts[i] = bitcount;\npt++;\n}\n}\n/**\n* @brief Use counting sort on the mismatch array to sort partition candidates.\n+ *\n+ * @param mismatch_count Partitioning mismatch counts, in index order.\n+ * @param[out] partition_ordering Partition index values, in mismatch order.\n*/\nstatic void get_partition_ordering_by_mismatch_bits(\n- const int mismatch_bits[PARTITION_COUNT],\n+ const int mismatch_count[PARTITION_COUNT],\nint partition_ordering[PARTITION_COUNT]\n) {\nint mscount[256] { 0 };\n@@ -342,7 +383,7 @@ static void get_partition_ordering_by_mismatch_bits(\n// Create the histogram of mismatch counts\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\n- mscount[mismatch_bits[i]]++;\n+ mscount[mismatch_count[i]]++;\n}\n// Create a running sum from the histogram array\n@@ -359,11 +400,12 @@ static void get_partition_ordering_by_mismatch_bits(\n// sequential entries with the same count\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\n- int idx = mscount[mismatch_bits[i]]++;\n+ int idx = mscount[mismatch_count[i]]++;\npartition_ordering[idx] = i;\n}\n}\n+/* See header for documentation. */\nvoid kmeans_compute_partition_ordering(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup API for kmeans_partitioning
|
61,745 |
15.05.2021 23:23:17
| -3,600 |
4858dda53f2c3ba0ced62a896fea89acccb3d2e4
|
Cleanup API for astcenc_image.cpp
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -928,7 +928,7 @@ static void compress_image(\n// Fetch the full block for compression\nif (use_full_block)\n{\n- fetch_imageblock(decode_mode, image, &blk, bsd, x * block_x, y * block_y, z * block_z, swizzle);\n+ fetch_imageblock(decode_mode, image, blk, *bsd, x * block_x, y * block_y, z * block_z, swizzle);\n}\n// Apply alpha scale RDO - substitute constant color block\nelse\n@@ -1150,7 +1150,7 @@ astcenc_error astcenc_decompress_image(\nx * block_x, y * block_y, z * block_z,\nscb, blk);\n- write_imageblock(image_out, &blk, ctx->bsd,\n+ write_imageblock(image_out, blk, *ctx->bsd,\nx * block_x, y * block_y, z * block_z, *swizzle);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_image.cpp",
"new_path": "Source/astcenc_image.cpp",
"diff": "@@ -51,7 +51,6 @@ static vfloat4 load_texel_u8(\n) {\nconst uint8_t* data8 = static_cast<const uint8_t*>(data);\nreturn int_to_float(vint4(data8 + base_offset)) / 255.0f;\n-\n}\n/**\n@@ -148,13 +147,12 @@ static vfloat4 encode_texel_lns(\nreturn select(datav_unorm, datav_lns, lns_mask);\n}\n-// fetch an imageblock from the input file.\n+/* See header for documentation */\nvoid fetch_imageblock(\nastcenc_profile decode_mode,\nconst astcenc_image& img,\n- imageblock* blk, // picture-block to initialize with image data\n- const block_size_descriptor* bsd,\n- // position in texture.\n+ imageblock& blk,\n+ const block_size_descriptor& bsd,\nint xpos,\nint ypos,\nint zpos,\n@@ -164,9 +162,9 @@ void fetch_imageblock(\nint ysize = img.dim_y;\nint zsize = img.dim_z;\n- blk->xpos = xpos;\n- blk->ypos = ypos;\n- blk->zpos = zpos;\n+ blk.xpos = xpos;\n+ blk.ypos = ypos;\n+ blk.zpos = zpos;\n// True if any non-identity swizzle\nbool needs_swz = (swz.r != ASTCENC_SWZ_R) || (swz.g != ASTCENC_SWZ_G) ||\n@@ -207,16 +205,16 @@ void fetch_imageblock(\nconverter = encode_texel_lns;\n}\n- for (int z = 0; z < bsd->zdim; z++)\n+ for (int z = 0; z < bsd.zdim; z++)\n{\nint zi = astc::min(zpos + z, zsize - 1);\nvoid* plane = img.data[zi];\n- for (int y = 0; y < bsd->ydim; y++)\n+ for (int y = 0; y < bsd.ydim; y++)\n{\nint yi = astc::min(ypos + y, ysize - 1);\n- for (int x = 0; x < bsd->xdim; x++)\n+ for (int x = 0; x < bsd.xdim; x++)\n{\nint xi = astc::min(xpos + x, xsize - 1);\n@@ -233,13 +231,13 @@ void fetch_imageblock(\ngrayscale = false;\n}\n- blk->data_r[idx] = datav.lane<0>();\n- blk->data_g[idx] = datav.lane<1>();\n- blk->data_b[idx] = datav.lane<2>();\n- blk->data_a[idx] = datav.lane<3>();\n+ blk.data_r[idx] = datav.lane<0>();\n+ blk.data_g[idx] = datav.lane<1>();\n+ blk.data_b[idx] = datav.lane<2>();\n+ blk.data_a[idx] = datav.lane<3>();\n- blk->rgb_lns[idx] = rgb_lns;\n- blk->alpha_lns[idx] = a_lns;\n+ blk.rgb_lns[idx] = rgb_lns;\n+ blk.alpha_lns[idx] = a_lns;\nidx++;\n}\n@@ -248,7 +246,7 @@ void fetch_imageblock(\n// Reverse the encoding so we store origin block in the original format\n// TODO: Move this to when we consume it, as we rarely do?\n- vfloat4 data_enc = blk->texel(0);\n+ vfloat4 data_enc = blk.texel(0);\nvfloat4 data_enc_unorm = data_enc / 65535.0f;\nvfloat4 data_enc_lns = vfloat4::zero();\n@@ -257,19 +255,19 @@ void fetch_imageblock(\ndata_enc_lns = float16_to_float(lns_to_sf16(float_to_int(data_enc)));\n}\n- blk->origin_texel = select(data_enc_unorm, data_enc_lns, lns_mask);;\n+ blk.origin_texel = select(data_enc_unorm, data_enc_lns, lns_mask);;\n// Store block metadata\n- blk->data_min = data_min;\n- blk->data_max = data_max;\n- blk->grayscale = grayscale;\n+ blk.data_min = data_min;\n+ blk.data_max = data_max;\n+ blk.grayscale = grayscale;\n}\n+/* See header for documentation. */\nvoid write_imageblock(\nastcenc_image& img,\n- const imageblock* blk, // picture-block to initialize with image data. We assume that orig_data is valid.\n- const block_size_descriptor* bsd,\n- // position to write the block to\n+ const imageblock& blk,\n+ const block_size_descriptor& bsd,\nint xpos,\nint ypos,\nint zpos,\n@@ -280,15 +278,15 @@ void write_imageblock(\nint zsize = img.dim_z;\nint x_start = xpos;\n- int x_end = std::min(xsize, xpos + bsd->xdim);\n- int x_nudge = bsd->xdim - (x_end - x_start);\n+ int x_end = std::min(xsize, xpos + bsd.xdim);\n+ int x_nudge = bsd.xdim - (x_end - x_start);\nint y_start = ypos;\n- int y_end = std::min(ysize, ypos + bsd->ydim);\n- int y_nudge = (bsd->ydim - (y_end - y_start)) * bsd->xdim;\n+ int y_end = std::min(ysize, ypos + bsd.ydim);\n+ int y_nudge = (bsd.ydim - (y_end - y_start)) * bsd.xdim;\nint z_start = zpos;\n- int z_end = std::min(zsize, zpos + bsd->zdim);\n+ int z_end = std::min(zsize, zpos + bsd.zdim);\nfloat data[7];\ndata[ASTCENC_SWZ_0] = 0.0f;\n@@ -316,17 +314,17 @@ void write_imageblock(\n{\nvint4 colori = vint4::zero();\n- if (blk->data_r[idx] == std::numeric_limits<float>::quiet_NaN())\n+ if (blk.data_r[idx] == std::numeric_limits<float>::quiet_NaN())\n{\n// Can't display NaN - show magenta error color\ncolori = vint4(0xFF, 0x00, 0xFF, 0xFF);\n}\nelse if (needs_swz)\n{\n- data[ASTCENC_SWZ_R] = blk->data_r[idx];\n- data[ASTCENC_SWZ_G] = blk->data_g[idx];\n- data[ASTCENC_SWZ_B] = blk->data_b[idx];\n- data[ASTCENC_SWZ_A] = blk->data_a[idx];\n+ data[ASTCENC_SWZ_R] = blk.data_r[idx];\n+ data[ASTCENC_SWZ_G] = blk.data_g[idx];\n+ data[ASTCENC_SWZ_B] = blk.data_b[idx];\n+ data[ASTCENC_SWZ_A] = blk.data_a[idx];\nif (needs_z)\n{\n@@ -345,7 +343,7 @@ void write_imageblock(\n}\nelse\n{\n- vfloat4 color = blk->texel(idx);\n+ vfloat4 color = blk.texel(idx);\ncolori = float_to_int_rtn(min(color, 1.0f) * 255.0f);\n}\n@@ -372,16 +370,16 @@ void write_imageblock(\n{\nvint4 color;\n- if (blk->data_r[idx] == std::numeric_limits<float>::quiet_NaN())\n+ if (blk.data_r[idx] == std::numeric_limits<float>::quiet_NaN())\n{\ncolor = vint4(0xFFFF);\n}\nelse if (needs_swz)\n{\n- data[ASTCENC_SWZ_R] = blk->data_r[idx];\n- data[ASTCENC_SWZ_G] = blk->data_g[idx];\n- data[ASTCENC_SWZ_B] = blk->data_b[idx];\n- data[ASTCENC_SWZ_A] = blk->data_a[idx];\n+ data[ASTCENC_SWZ_R] = blk.data_r[idx];\n+ data[ASTCENC_SWZ_G] = blk.data_g[idx];\n+ data[ASTCENC_SWZ_B] = blk.data_b[idx];\n+ data[ASTCENC_SWZ_A] = blk.data_a[idx];\nif (needs_z)\n{\n@@ -400,7 +398,7 @@ void write_imageblock(\n}\nelse\n{\n- vfloat4 colorf = blk->texel(idx);\n+ vfloat4 colorf = blk.texel(idx);\ncolor = float_to_float16(colorf);\n}\n@@ -429,7 +427,7 @@ void write_imageblock(\n{\nfor (int x = x_start; x < x_end; x++)\n{\n- vfloat4 color = blk->texel(idx);\n+ vfloat4 color = blk.texel(idx);\nif (color.lane<0>() == std::numeric_limits<float>::quiet_NaN())\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1129,25 +1129,43 @@ void compute_averages_and_variances(\nastcenc_context& ctx,\nconst avg_var_args& ag);\n-// fetch an image-block from the input file\n+/**\n+ * @brief Fetch a single image block from the input image\n+ *\n+ * @param decode_mode The compression color profile.\n+ * @param img The input image data.\n+ * @param[out] blk The image block to populate.\n+ * @param bsd The block size information.\n+ * @param xpos The block X coordinate in the input image.\n+ * @param ypos The block Y coordinate in the input image.\n+ * @param zpos The block Z coordinate in the input image.\n+ * @param swz The swizzle to apply on load.\n+ */\nvoid fetch_imageblock(\nastcenc_profile decode_mode,\nconst astcenc_image& img,\n- imageblock* blk, // picture-block to initialize with image data\n- const block_size_descriptor* bsd,\n- // position in picture to fetch block from\n+ imageblock& blk,\n+ const block_size_descriptor& bsd,\nint xpos,\nint ypos,\nint zpos,\nconst astcenc_swizzle& swz);\n-// write an image block to the output file buffer.\n-// the data written are taken from orig_data.\n+/**\n+ * @brief Write a single image block from the output image\n+ *\n+ * @param[out] img The input image data.\n+ * @param blk The image block to populate.\n+ * @param bsd The block size information.\n+ * @param xpos The block X coordinate in the input image.\n+ * @param ypos The block Y coordinate in the input image.\n+ * @param zpos The block Z coordinate in the input image.\n+ * @param swz The swizzle to apply on store.\n+ */\nvoid write_imageblock(\nastcenc_image& img,\n- const imageblock* blk, // picture-block to initialize with image data\n- const block_size_descriptor* bsd,\n- // position in picture to write block to.\n+ const imageblock& blk,\n+ const block_size_descriptor& bsd,\nint xpos,\nint ypos,\nint zpos,\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup API for astcenc_image.cpp
|
61,745 |
15.05.2021 23:51:28
| -3,600 |
1d3bd32038558674053aa6dbbacbd3f32712fc54
|
Cleanup API for integer_sequence
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_integer_sequence.cpp",
"new_path": "Source/astcenc_integer_sequence.cpp",
"diff": "#include <array>\n-// unpacked quint triplets <low,middle,high> for each packed-quint value\n+/** @brief Unpacked quint triplets <low,middle,high> for each packed value */\nstatic const uint8_t quints_of_integer[128][3] = {\n{0, 0, 0}, {1, 0, 0}, {2, 0, 0}, {3, 0, 0},\n{4, 0, 0}, {0, 4, 0}, {4, 4, 0}, {4, 4, 4},\n@@ -59,8 +59,7 @@ static const uint8_t quints_of_integer[128][3] = {\n{4, 3, 3}, {3, 4, 3}, {0, 3, 4}, {1, 3, 4}\n};\n-// packed quint-value for every unpacked quint-triplet\n-// indexed by [high][middle][low]\n+/** @brief Packed quint values for each unpacked value, indexed [hi][mid][lo]. */\nstatic const uint8_t integer_of_quints[5][5][5] = {\n{\n{0, 1, 2, 3, 4},\n@@ -99,7 +98,7 @@ static const uint8_t integer_of_quints[5][5][5] = {\n}\n};\n-// unpacked trit quintuplets <low,_,_,_,high> for each packed-quint value\n+/** @brief Unpacked trit quintuplets <low,...,high> for each packed value */\nstatic const uint8_t trits_of_integer[256][5] = {\n{0, 0, 0, 0, 0}, {1, 0, 0, 0, 0}, {2, 0, 0, 0, 0}, {0, 0, 2, 0, 0},\n{0, 1, 0, 0, 0}, {1, 1, 0, 0, 0}, {2, 1, 0, 0, 0}, {1, 0, 2, 0, 0},\n@@ -167,8 +166,7 @@ static const uint8_t trits_of_integer[256][5] = {\n{0, 2, 2, 2, 2}, {1, 2, 2, 2, 2}, {2, 2, 2, 2, 2}, {2, 1, 2, 2, 2}\n};\n-// packed trit-value for every unpacked trit-quintuplet\n-// indexed by [high][][][][low]\n+/** @brief Packed trit values for each unpacked value, indexed [hi][][][][lo]. */\nstatic const uint8_t integer_of_trits[3][3][3][3][3] = {\n{\n{\n@@ -424,26 +422,36 @@ static const std::array<ise_size, 21> ise_sizes = {{\n/* See header for documentation. */\nint get_ise_sequence_bitcount(\n- int items,\n- quant_method quant\n+ int character_count,\n+ quant_method quant_level\n) {\n// Cope with out-of bounds values - input might be invalid\n- if (static_cast<size_t>(quant) >= ise_sizes.size())\n+ if (static_cast<size_t>(quant_level) >= ise_sizes.size())\n{\n// Arbitrary large number that's more than an ASTC block can hold\nreturn 1024;\n}\n- auto& entry = ise_sizes[quant];\n- return (entry.scale * items + entry.round) / entry.divisor;\n+ auto& entry = ise_sizes[quant_level];\n+ return (entry.scale * character_count + entry.round) / entry.divisor;\n}\n-// routine to write up to 8 bits\n+/**\n+ * @brief Write up to 8 bits at an arbitrary bit offset.\n+ *\n+ * The stored value is at most 8 bits, but can be stored at an offset of\n+ * between 0 and 7 bits so may span two separate bytes in memory.\n+ *\n+ * @param value The value to write.\n+ * @param bitcount The number of bits to write, starting from LSB.\n+ * @param bitoffset The bit offset to store at, between 0 and 7.\n+ * @param[in,out] ptr The data pointer to write to.\n+ */\nstatic inline void write_bits(\nint value,\nint bitcount,\nint bitoffset,\n- uint8_t* ptr\n+ uint8_t ptr[2]\n) {\nint mask = (1 << bitcount) - 1;\nvalue &= mask;\n@@ -459,7 +467,18 @@ static inline void write_bits(\nptr[1] |= value >> 8;\n}\n-// routine to read up to 8 bits\n+/**\n+ * @brief Read up to 8 bits at an arbitrary bit offset.\n+ *\n+ * The stored value is at most 8 bits, but can be stored at an offset of\n+ * between 0 and 7 bits so may span two separate bytes in memory.\n+ *\n+ * @param bitcount The number of bits to read.\n+ * @param bitoffset The bit offset to read from, between 0 and 7.\n+ * @param[in,out] ptr The data pointer to read from.\n+ *\n+ * @return The read value.\n+ */\nstatic inline int read_bits(\nint bitcount,\nint bitoffset,\n@@ -474,14 +493,15 @@ static inline int read_bits(\nreturn value;\n}\n+/* See header for details. */\nvoid encode_ise(\n- int quant_level,\n- int elements,\n+ quant_method quant_level,\n+ int character_count,\nconst uint8_t* input_data,\nuint8_t* output_data,\nint bit_offset\n) {\n- promise(elements > 0);\n+ promise(character_count > 0);\nint bits = btq_counts[quant_level].bits;\nint trits = btq_counts[quant_level].trits;\n@@ -492,7 +512,7 @@ void encode_ise(\nif (trits)\n{\nint i = 0;\n- int full_trit_blocks = elements / 5;\n+ int full_trit_blocks = character_count / 5;\nfor (int j = 0; j < full_trit_blocks; j++)\n{\n@@ -535,19 +555,19 @@ void encode_ise(\n}\n// Loop tail for a partial block\n- if (i != elements)\n+ if (i != character_count)\n{\n// i4 cannot be present - we know the block is partial\n// i0 must be present - we know the block isn't empty\nint 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 i3 = i + 3 >= character_count ? 0 : input_data[i + 3] >> bits;\n+ int i2 = i + 2 >= character_count ? 0 : input_data[i + 2] >> bits;\n+ int i1 = i + 1 >= character_count ? 0 : input_data[i + 1] >> bits;\nint i0 = input_data[i + 0] >> bits;\nuint8_t T = integer_of_trits[i4][i3][i2][i1][i0];\n- for (int j = 0; i < elements; i++, j++)\n+ for (int j = 0; i < character_count; i++, j++)\n{\n// Truncated table as this iteration is always partital\nstatic const uint8_t tbits[4] { 2, 2, 1, 2 };\n@@ -565,7 +585,7 @@ void encode_ise(\nelse if (quints)\n{\nint i = 0;\n- int full_quint_blocks = elements / 3;\n+ int full_quint_blocks = character_count / 3;\nfor (int j = 0; j < full_quint_blocks; j++)\n{\n@@ -596,17 +616,17 @@ void encode_ise(\n}\n// Loop tail for a partial block\n- if (i != elements)\n+ if (i != character_count)\n{\n// i2 cannot be present - we know the block is partial\n// i0 must be present - we know the block isn't empty\nint i2 = 0;\n- int i1 = i + 1 >= elements ? 0 : input_data[i + 1] >> bits;\n+ int i1 = i + 1 >= character_count ? 0 : input_data[i + 1] >> bits;\nint i0 = input_data[i + 0] >> bits;\nuint8_t T = integer_of_quints[i2][i1][i0];\n- for (int j = 0; i < elements; i++, j++)\n+ for (int j = 0; i < character_count; i++, j++)\n{\n// Truncated table as this iteration is always partital\nstatic const uint8_t tbits[2] { 3, 2 };\n@@ -623,8 +643,8 @@ void encode_ise(\n// Write out just bits\nelse\n{\n- promise(elements > 0);\n- for (int i = 0; i < elements; i++)\n+ promise(character_count > 0);\n+ for (int i = 0; i < character_count; i++)\n{\nwrite_bits(input_data[i], bits, bit_offset, output_data);\nbit_offset += bits;\n@@ -632,18 +652,19 @@ void encode_ise(\n}\n}\n+/* See header for details. */\nvoid decode_ise(\n- int quant_level,\n- int elements,\n+ quant_method quant_level,\n+ int character_count,\nconst uint8_t* input_data,\nuint8_t* output_data,\nint bit_offset\n) {\n- promise(elements > 0);\n+ promise(character_count > 0);\n// note: due to how the trit/quint-block unpacking is done in this function,\n// we may write more temporary results than the number of outputs\n- // The maximum actual number of results is 64 bit, but we keep 4 additional elements\n+ // The maximum actual number of results is 64 bit, but we keep 4 additional character_count\n// of padding.\nuint8_t results[68];\nuint8_t tq_blocks[22]; // trit-blocks or quint-blocks\n@@ -662,7 +683,7 @@ void decode_ise(\n}\n// collect bits for each element, as well as bits for any trit-blocks and quint-blocks.\n- for (int i = 0; i < elements; i++)\n+ for (int i = 0; i < character_count; i++)\n{\nresults[i] = read_bits(bits, bit_offset, input_data);\nbit_offset += bits;\n@@ -697,7 +718,7 @@ void decode_ise(\n// unpack trit-blocks or quint-blocks as needed\nif (trits)\n{\n- int trit_blocks = (elements + 4) / 5;\n+ int trit_blocks = (character_count + 4) / 5;\nfor (int i = 0; i < trit_blocks; i++)\n{\nconst uint8_t *tritptr = trits_of_integer[tq_blocks[i]];\n@@ -711,7 +732,7 @@ void decode_ise(\nif (quints)\n{\n- int quint_blocks = (elements + 2) / 3;\n+ int quint_blocks = (character_count + 2) / 3;\nfor (int i = 0; i < quint_blocks; i++)\n{\nconst uint8_t *quintptr = quints_of_integer[tq_blocks[i]];\n@@ -721,7 +742,7 @@ void decode_ise(\n}\n}\n- for (int i = 0; i < elements; i++)\n+ for (int i = 0; i < character_count; i++)\n{\noutput_data[i] = results[i];\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -856,16 +856,41 @@ extern const uint8_t color_quant_tables[21][256];\nextern const uint8_t color_unquant_tables[21][256];\nextern int8_t quant_mode_table[17][128];\n+/**\n+ * @brief Encode a packed string using BISE.\n+ *\n+ * Note that BISE can return strings that are not a whole number of bytes\n+ * in length, and ASTC can start storing strings in a block at arbitrary bit\n+ * offsets in the encoded data.\n+ *\n+ * @param quant_level The BISE alphabet size.\n+ * @param character_count The number of characters in the string.\n+ * @param input_data The unpacked string, one byte per character.\n+ * @param[in,out] output_data The output packed string.\n+ * @param bit_offset The starting offset in the output storage.\n+ */\nvoid encode_ise(\n- int quant_level,\n- int elements,\n+ quant_method quant_level,\n+ int character_count,\nconst uint8_t* input_data,\nuint8_t* output_data,\nint bit_offset);\n+/**\n+ * @brief Decode a packed string using BISE.\n+ *\n+ * Note that BISE input strings are not a whole number of bytes in length, and\n+ * ASTC can start strings at arbitrary bit offsets in the encoded data.\n+ *\n+ * @param quant_level The BISE alphabet size.\n+ * @param character_count The number of characters in the string.\n+ * @param input_data The packed string.\n+ * @param[in,out] output_data The output storage, one byte per character.\n+ * @param bit_offset The starting offset in the output storage.\n+ */\nvoid decode_ise(\n- int quant_level,\n- int elements,\n+ quant_method quant_level,\n+ int character_count,\nconst uint8_t* input_data,\nuint8_t* output_data,\nint bit_offset);\n@@ -877,12 +902,14 @@ void decode_ise(\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+ * @param character_count The number of items in the sequence.\n+ * @param quant_level The desired quantization level.\n+ *\n+ * @return The number of bits needed to encode the BISE string.\n*/\nint get_ise_sequence_bitcount(\n- int items,\n- quant_method quant);\n+ int character_count,\n+ quant_method quant_level);\nvoid build_quant_mode_table(void);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_symbolic_physical.cpp",
"new_path": "Source/astcenc_symbolic_physical.cpp",
"diff": "@@ -131,7 +131,7 @@ void symbolic_to_physical(\nconst block_mode& bm = bsd.block_modes[packed_index];\nint weight_count = dts[bm.decimation_mode]->weight_count;\n- int weight_quant_method = bm.quant_mode;\n+ quant_method weight_quant_method = (quant_method)bm.quant_mode;\nint is_dual_plane = bm.is_dual_plane;\nint real_weight_count = is_dual_plane ? 2 * weight_count : weight_count;\n@@ -244,7 +244,7 @@ void symbolic_to_physical(\n}\n// then, encode an ISE based on them.\n- encode_ise(scb.color_quant_level, valuecount_to_encode, values_to_encode, pcb.data, (scb.partition_count == 1 ? 17 : 19 + PARTITION_BITS));\n+ encode_ise((quant_method)scb.color_quant_level, valuecount_to_encode, values_to_encode, pcb.data, (scb.partition_count == 1 ? 17 : 19 + PARTITION_BITS));\n}\nvoid physical_to_symbolic(\n@@ -334,7 +334,7 @@ void physical_to_symbolic(\nconst struct block_mode& bm = bsd.block_modes[packed_index];\nint weight_count = dts[bm.decimation_mode]->weight_count;\n- int weight_quant_method = bm.quant_mode;\n+ quant_method weight_quant_method = (quant_method)bm.quant_mode;\nint is_dual_plane = bm.is_dual_plane;\nint real_weight_count = is_dual_plane ? 2 * weight_count : weight_count;\n@@ -349,8 +349,7 @@ void physical_to_symbolic(\nbswapped[i] = bitrev8(pcb.data[15 - i]);\n}\n- int bits_for_weights = get_ise_sequence_bitcount(real_weight_count,\n- (quant_method)weight_quant_method);\n+ int bits_for_weights = get_ise_sequence_bitcount(real_weight_count, weight_quant_method);\nint below_weights_pos = 128 - bits_for_weights;\n@@ -461,7 +460,7 @@ void physical_to_symbolic(\n// then unpack the integer-bits\nuint8_t values_to_decode[32];\n- decode_ise(color_quant_level, color_integer_count, pcb.data, values_to_decode, (partition_count == 1 ? 17 : 19 + PARTITION_BITS));\n+ decode_ise((quant_method)color_quant_level, color_integer_count, pcb.data, values_to_decode, (partition_count == 1 ? 17 : 19 + PARTITION_BITS));\n// and distribute them over the endpoint types\nint valuecount_to_decode = 0;\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup API for integer_sequence
|
61,745 |
16.05.2021 19:50:07
| -3,600 |
f0cbaf34488690ad8a130fdd1ae70678256d28ae
|
Cleanup API for partition_tables
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_block_sizes.cpp",
"new_path": "Source/astcenc_block_sizes.cpp",
"diff": "@@ -1098,7 +1098,7 @@ void init_block_size_descriptor(\nconstruct_block_size_descriptor_2d(x_texels, y_texels, can_omit_modes, mode_cutoff, bsd);\n}\n- init_partition_tables(&bsd);\n+ init_partition_tables(bsd);\n}\n/* See header for documentation. */\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_integer_sequence.cpp",
"new_path": "Source/astcenc_integer_sequence.cpp",
"diff": "@@ -493,7 +493,7 @@ static inline int read_bits(\nreturn value;\n}\n-/* See header for details. */\n+/* See header for documentation. */\nvoid encode_ise(\nquant_method quant_level,\nint character_count,\n@@ -652,7 +652,7 @@ void encode_ise(\n}\n}\n-/* See header for details. */\n+/* See header for documentation. */\nvoid decode_ise(\nquant_method quant_level,\nint character_count,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -793,13 +793,13 @@ void term_block_size_descriptor(\n/**\n* @brief Populate the partition tables for the target block size.\n*\n- * Note the block_size_size descriptor must be initialized before calling this\n- * function.\n+ * Note the @c bsd descriptor must be initialized by calling @c init_block_size_descriptor() before\n+ * calling this function.\n*\n- * @param bsd The structure to populate.\n+ * @param[out] bsd The block size information structure to populate.\n*/\nvoid init_partition_tables(\n- block_size_descriptor* bsd);\n+ block_size_descriptor& bsd);\nstatic inline const partition_info *get_partition_table(\nconst block_size_descriptor* bsd,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_partition_tables.cpp",
"new_path": "Source/astcenc_partition_tables.cpp",
"diff": "#include \"astcenc_internal.h\"\n-/*\n- Produce a canonicalized representation of a partition pattern\n-\n- The largest possible such representation is 432 bits, equal to 7 uint64_t values.\n+/**\n+ * @brief Generate a canonical representation of a partition pattern.\n+ *\n+ * The returned value stores two bits per texel, for up to 6x6x6 texels, where\n+ * the two bits store the remapped texel index. Remapping ensures that we only\n+ * match on the partition pattern, independent of the partition order generated\n+ * by the hash.\n+ *\n+ * @param texel_count The number of texels in the block.\n+ * @param partition_of_texel The partition assignments, in hash order.\n+ * @param[out] bit_pattern The output bit pattern representation.\n*/\n-static void gen_canonicalized_partition_table(\n+static void generate_canonical_partitioning(\nint texel_count,\n- const uint8_t* partition_table,\n- uint64_t canonicalized[7]\n+ const uint8_t* partition_of_texel,\n+ uint64_t bit_pattern[7]\n) {\n+ // Clear the pattern\nfor (int i = 0; i < 7; i++)\n{\n- canonicalized[i] = 0;\n+ bit_pattern[i] = 0;\n}\n+ // Store a mapping to reorder the raw partitions so that the the partitions\n+ // are ordered such that the lowest texel index in partition N is smaller\n+ // than the lowest texel index in partition N + 1.\nint mapped_index[4];\nint map_weight_count = 0;\n+\nfor (int i = 0; i < 4; i++)\n{\nmapped_index[i] = -1;\n@@ -45,67 +57,84 @@ static void gen_canonicalized_partition_table(\nfor (int i = 0; i < texel_count; i++)\n{\n- int index = partition_table[i];\n+ int index = partition_of_texel[i];\n+\nif (mapped_index[index] == -1)\n{\nmapped_index[index] = map_weight_count++;\n}\n+\nuint64_t xlat_index = mapped_index[index];\n- canonicalized[i >> 5] |= xlat_index << (2 * (i & 0x1F));\n+ bit_pattern[i >> 5] |= xlat_index << (2 * (i & 0x1F));\n}\n}\n-static int compare_canonicalized_partition_tables(\n+/**\n+ * @brief Compare two canonical patterns to see if they are the same.\n+ *\n+ * @param part1 The first canonical bit pattern to check.\n+ * @param part2 The second canonical bit pattern to check.\n+ *\n+ * @return @c true if the patterns are the same, @c false otherwise.\n+ */\n+static bool compare_canonical_partitionings(\nconst uint64_t part1[7],\nconst uint64_t part2[7]\n) {\n- if ((part1[0] != part2[0]) || (part1[1] != part2[1]) || (part1[2] != part2[2]) ||\n- (part1[3] != part2[3]) || (part1[4] != part2[4]) || (part1[5] != part2[5]) ||\n- (part1[6] != part2[6]))\n- {\n- return 0;\n+ return (part1[0] == part2[0]) && (part1[1] == part2[1]) &&\n+ (part1[2] == part2[2]) && (part1[3] == part2[3]) &&\n+ (part1[4] == part2[4]) && (part1[5] == part2[5]) &&\n+ (part1[6] == part2[6]);\n}\n- return 1;\n-}\n-\n-/*\n- For a partition table, detect partitions that are equivalent, then mark them\n- as invalid. This reduces the number of partitions that the codec has to\n- consider and thus improves encode performance. */\n-static void partition_table_zap_equal_elements(\n+/**\n+ * @brief Compare all partition patterns and remove duplicates.\n+ *\n+ * The partitioning algorithm uses a hash function for texel assignment that can produce partitions\n+ * which have the same texel assignment groupings. It is only useful for the compressor to test one\n+ * of each, so we mark duplicates as invalid.\n+ *\n+ * @param texel_count The first canonical bit pattern to check.\n+ * @param[in,out] pt The table of partitioning information entries.\n+ */\n+static void remove_duplicate_partitionings(\nint texel_count,\n- partition_info* pt\n+ partition_info pt[PARTITION_COUNT]\n) {\n- int partition_tables_zapped = 0;\n- uint64_t *canonicalizeds = new uint64_t[PARTITION_COUNT * 7];\n+ uint64_t bit_patterns[PARTITION_COUNT * 7];\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\n- gen_canonicalized_partition_table(texel_count, pt[i].partition_of_texel, canonicalizeds + i * 7);\n+ generate_canonical_partitioning(texel_count, pt[i].partition_of_texel, bit_patterns + i * 7);\n}\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\nfor (int j = 0; j < i; j++)\n{\n- if (compare_canonicalized_partition_tables(canonicalizeds + 7 * i, canonicalizeds + 7 * j))\n+ if (compare_canonical_partitionings(bit_patterns + 7 * i, bit_patterns + 7 * j))\n{\npt[i].partition_count = 0;\n- partition_tables_zapped++;\nbreak;\n}\n}\n}\n-\n- delete[] canonicalizeds;\n}\n-static uint32_t hash52(uint32_t inp)\n-{\n+/**\n+ * @brief Hash function used for procedural partition assignment.\n+ *\n+ * @param inp The hash seed.\n+ *\n+ * @return The hashed value.\n+ */\n+static uint32_t hash52(\n+ uint32_t inp\n+) {\ninp ^= inp >> 15;\n- inp *= 0xEEDE0891; // (2^4+1)*(2^7+1)*(2^17-1)\n+ // (2^4 + 1) * (2^7 + 1) * (2^17 - 1)\n+ inp *= 0xEEDE0891;\ninp ^= inp >> 5;\ninp += inp << 16;\ninp ^= inp >> 7;\n@@ -115,14 +144,27 @@ static uint32_t hash52(uint32_t inp)\nreturn inp;\n}\n+/**\n+ * @brief Select texel assignment for a single coordinate.\n+ *\n+ * @param seed The seed - the partition index from the block.\n+ * @param x The texel X coordinate in the block.\n+ * @param y The texel Y coordinate in the block.\n+ * @param z The texel Z coordinate in the block.\n+ * @param partition_count The total partition count of this encoding.\n+ * @param small_block @c true if the blockhas fewer than 32 texels.\n+ *\n+ * @return The assigned partition index for this texel.\n+ */\nstatic int select_partition(\nint seed,\nint x,\nint y,\nint z,\n- int partitioncount,\n- int small_block\n+ int partition_count,\n+ bool small_block\n) {\n+ // For small blocks bias the coordinates to get better distribution\nif (small_block)\n{\nx <<= 1;\n@@ -130,7 +172,7 @@ static int select_partition(\nz <<= 1;\n}\n- seed += (partitioncount - 1) * 1024;\n+ seed += (partition_count - 1) * 1024;\nuint32_t rnum = hash52(seed);\n@@ -147,8 +189,7 @@ static int select_partition(\nuint8_t seed11 = (rnum >> 26) & 0xF;\nuint8_t seed12 = ((rnum >> 30) | (rnum << 2)) & 0xF;\n- // squaring all the seeds in order to bias their distribution\n- // towards lower values.\n+ // Squaring all the seeds in order to bias their distribution towards lower values.\nseed1 *= seed1;\nseed2 *= seed2;\nseed3 *= seed3;\n@@ -166,11 +207,11 @@ static int select_partition(\nif (seed & 1)\n{\nsh1 = (seed & 2 ? 4 : 5);\n- sh2 = (partitioncount == 3 ? 6 : 5);\n+ sh2 = (partition_count == 3 ? 6 : 5);\n}\nelse\n{\n- sh1 = (partitioncount == 3 ? 6 : 5);\n+ sh1 = (partition_count == 3 ? 6 : 5);\nsh2 = (seed & 2 ? 4 : 5);\n}\n@@ -202,17 +243,17 @@ static int select_partition(\nd &= 0x3F;\n// remove some of the components if we are to output < 4 partitions.\n- if (partitioncount <= 3)\n+ if (partition_count <= 3)\n{\nd = 0;\n}\n- if (partitioncount <= 2)\n+ if (partition_count <= 2)\n{\nc = 0;\n}\n- if (partitioncount <= 1)\n+ if (partition_count <= 1)\n{\nb = 0;\n}\n@@ -238,27 +279,36 @@ static int select_partition(\nreturn partition;\n}\n-static void generate_one_partition_table(\n- const block_size_descriptor* bsd,\n+/**\n+ * @brief Generate a single partition info structure.\n+ *\n+ * @param bsd The block size information.\n+ * @param partition_count The partition count of this partitioning.\n+ * @param partition_index The partition index / see of this partitioning.\n+ * @param[out] pi The partition info structure to populate.\n+ */\n+static void generate_one_partition_info_entry(\n+ const block_size_descriptor& bsd,\nint partition_count,\nint partition_index,\n- partition_info* pt\n+ partition_info& pi\n) {\n- int texels_per_block = bsd->texel_count;\n- int small_block = texels_per_block < 32;\n+ int texels_per_block = bsd.texel_count;\n+ bool small_block = texels_per_block < 32;\n- uint8_t *partition_of_texel = pt->partition_of_texel;\n+ uint8_t *partition_of_texel = pi.partition_of_texel;\n+ // Assign texels to partitions\nint texel_idx = 0;\nint counts[4] { 0 };\n- for (int z = 0; z < bsd->zdim; z++)\n+ for (int z = 0; z < bsd.zdim; z++)\n{\n- for (int y = 0; y < bsd->ydim; y++)\n+ for (int y = 0; y < bsd.ydim; y++)\n{\n- for (int x = 0; x < bsd->xdim; x++)\n+ for (int x = 0; x < bsd.xdim; x++)\n{\nuint8_t part = select_partition(partition_index, x, y, z, partition_count, small_block);\n- pt->texels_of_partition[part][counts[part]++] = texel_idx++;\n+ pi.texels_of_partition[part][counts[part]++] = texel_idx++;\n*partition_of_texel++ = part;\n}\n}\n@@ -271,63 +321,63 @@ static void generate_one_partition_table(\nint ptex_count_simd = round_up_to_simd_multiple_vla(ptex_count);\nfor (int j = ptex_count; j < ptex_count_simd; j++)\n{\n- pt->texels_of_partition[i][j] = pt->texels_of_partition[i][ptex_count - 1];\n+ pi.texels_of_partition[i][j] = pi.texels_of_partition[i][ptex_count - 1];\n}\n}\nif (counts[0] == 0)\n{\n- pt->partition_count = 0;\n+ pi.partition_count = 0;\n}\nelse if (counts[1] == 0)\n{\n- pt->partition_count = 1;\n+ pi.partition_count = 1;\n}\nelse if (counts[2] == 0)\n{\n- pt->partition_count = 2;\n+ pi.partition_count = 2;\n}\nelse if (counts[3] == 0)\n{\n- pt->partition_count = 3;\n+ pi.partition_count = 3;\n}\nelse\n{\n- pt->partition_count = 4;\n+ pi.partition_count = 4;\n}\nfor (int i = 0; i < 4; i++)\n{\n- pt->partition_texel_count[i] = counts[i];\n- pt->coverage_bitmaps[i] = 0ULL;\n+ pi.partition_texel_count[i] = counts[i];\n+ pi.coverage_bitmaps[i] = 0ULL;\n}\n- int texels_to_process = bsd->kmeans_texel_count;\n+ int texels_to_process = bsd.kmeans_texel_count;\nfor (int i = 0; i < texels_to_process; i++)\n{\n- int idx = bsd->kmeans_texels[i];\n- pt->coverage_bitmaps[pt->partition_of_texel[idx]] |= 1ULL << i;\n+ int idx = bsd.kmeans_texels[i];\n+ pi.coverage_bitmaps[pi.partition_of_texel[idx]] |= 1ULL << i;\n}\n}\n-/* Public function, see header file for detailed documentation */\n+/* See header for documentation. */\nvoid init_partition_tables(\n- block_size_descriptor* bsd\n+ block_size_descriptor& bsd\n) {\n- partition_info *par_tab2 = bsd->partitions;\n+ partition_info *par_tab2 = bsd.partitions;\npartition_info *par_tab3 = par_tab2 + PARTITION_COUNT;\npartition_info *par_tab4 = par_tab3 + PARTITION_COUNT;\npartition_info *par_tab1 = par_tab4 + PARTITION_COUNT;\n- generate_one_partition_table(bsd, 1, 0, par_tab1);\n+ generate_one_partition_info_entry(bsd, 1, 0, *par_tab1);\nfor (int i = 0; i < 1024; i++)\n{\n- generate_one_partition_table(bsd, 2, i, par_tab2 + i);\n- generate_one_partition_table(bsd, 3, i, par_tab3 + i);\n- generate_one_partition_table(bsd, 4, i, par_tab4 + i);\n+ generate_one_partition_info_entry(bsd, 2, i, par_tab2[i]);\n+ generate_one_partition_info_entry(bsd, 3, i, par_tab3[i]);\n+ generate_one_partition_info_entry(bsd, 4, i, par_tab4[i]);\n}\n- partition_table_zap_equal_elements(bsd->texel_count, par_tab2);\n- partition_table_zap_equal_elements(bsd->texel_count, par_tab3);\n- partition_table_zap_equal_elements(bsd->texel_count, par_tab4);\n+ remove_duplicate_partitionings(bsd.texel_count, par_tab2);\n+ remove_duplicate_partitionings(bsd.texel_count, par_tab3);\n+ remove_duplicate_partitionings(bsd.texel_count, par_tab4);\n}\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup API for partition_tables
|
61,745 |
16.05.2021 19:58:07
| -3,600 |
a54a5011d9ab8a0bb1582c565927a99326e0a92a
|
Cleanup API for percentile_tables
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_percentile_tables.cpp",
"new_path": "Source/astcenc_percentile_tables.cpp",
"diff": "@@ -1114,7 +1114,7 @@ static const packed_percentile_table *get_packed_table(\nreturn nullptr;\n}\n-/* Public function, see header file for detailed documentation */\n+/* See header for documentation. */\nconst float *get_2d_percentile_table(\nint xdim,\nint ydim\n@@ -1150,7 +1150,7 @@ const float *get_2d_percentile_table(\n}\n#endif\n-/* Public function, see header file for detailed documentation */\n+/* See header for documentation. */\nbool is_legal_2d_block_size(\nint xdim,\nint ydim\n@@ -1178,7 +1178,7 @@ bool is_legal_2d_block_size(\nreturn false;\n}\n-/* Public function, see header file for detailed documentation */\n+/* See header for documentation. */\nbool is_legal_3d_block_size(\nint xdim,\nint ydim,\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup API for percentile_tables
|
61,745 |
16.05.2021 20:13:15
| -3,600 |
14f7dfdb0fee66e310bc96c61840c6cd3340ddc0
|
Cleanup API for weight_align
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -308,7 +308,7 @@ static float compress_symbolic_block_fixed_partition_1plane(\nfloat weight_high_value[MAX_WEIGHT_MODES];\ncompute_angular_endpoints_1plane(\n- only_always, &bsd,\n+ only_always, bsd,\ndecimated_quantized_weights, decimated_weights,\nweight_low_value, weight_high_value);\n@@ -699,8 +699,7 @@ static float compress_symbolic_block_fixed_partition_2planes(\nfloat weight_high_value2[MAX_WEIGHT_MODES];\ncompute_angular_endpoints_2planes(\n- &bsd,\n- decimated_quantized_weights, decimated_weights,\n+ bsd, decimated_quantized_weights, decimated_weights,\nweight_low_value1, weight_high_value1,\nweight_low_value2, weight_high_value2);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1589,14 +1589,14 @@ void prepare_angular_tables();\nvoid compute_angular_endpoints_1plane(\nbool only_always,\n- const block_size_descriptor* bsd,\n+ const block_size_descriptor& bsd,\nconst float* decimated_quantized_weights,\nconst float* decimated_weights,\nfloat low_value[MAX_WEIGHT_MODES],\nfloat high_value[MAX_WEIGHT_MODES]);\nvoid compute_angular_endpoints_2planes(\n- const block_size_descriptor * bsd,\n+ const block_size_descriptor& bsd,\nconst float* decimated_quantized_weights,\nconst float* decimated_weights,\nfloat low_value1[MAX_WEIGHT_MODES],\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_weight_align.cpp",
"new_path": "Source/astcenc_weight_align.cpp",
"diff": "@@ -72,6 +72,7 @@ static const int quantization_steps_for_level[13] = {\nalignas(ASTCENC_VECALIGN) static float sin_table[SINCOS_STEPS][ANGULAR_STEPS];\nalignas(ASTCENC_VECALIGN) static float cos_table[SINCOS_STEPS][ANGULAR_STEPS];\n+/* See header for documentation. */\nvoid prepare_angular_tables()\n{\nint max_angular_steps_needed_for_quant_steps[ANGULAR_STEPS + 1];\n@@ -94,9 +95,15 @@ void prepare_angular_tables()\n}\n}\n-// function to compute angular sums; then, from the\n-// angular sums, compute alignment factor and offset.\n-\n+/**\n+ * @brief Compute the angular alignment factors and offsets.\n+ *\n+ * @param sample_count The number of samples.\n+ * @param samples The sample data.\n+ * @param sample_weights The weight of each sample.\n+ * @param max_angular_steps The maximum number of steps to be tested.\n+ * @param[out] offsets The output angular offsets array.\n+ */\nstatic void compute_angular_offsets(\nint sample_count,\nconst float* samples,\n@@ -140,9 +147,25 @@ static void compute_angular_offsets(\n}\n}\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+/**\n+ * @brief For a given step size compute the lowest and highest weight.\n+ *\n+ * Compute the lowest and highest weight that results from quantizing using the given stepsize and\n+ * offset, and then compute the resulting error. The cut errors indicate the error that results from\n+ * forcing samples that should have had one weight value one step up or down.\n+ *\n+ * @param sample_count The number of samples.\n+ * @param samples The sample data.\n+ * @param sample_weights The weight of each sample.\n+ * @param max_angular_steps The maximum number of steps to be tested.\n+ * @param max_quant_steps The maximum quantization level to be tested.\n+ * @param offsets The angular offsets array.\n+ * @param[out] lowest_weight Per angular step, the lowest weight.\n+ * @param[out] weight_span Per angular step, the span between lowest and highest weight.\n+ * @param[out] error Per angular step, the error.\n+ * @param[out] cut_low_weight_error Per angular step, the low weight cut error.\n+ * @param[out] cut_high_weight_error Per angular step, the high weight cut error.\n+ */\nstatic void compute_lowest_and_highest_weight(\nint sample_count,\nconst float* samples,\n@@ -222,7 +245,16 @@ static void compute_lowest_and_highest_weight(\n}\n}\n-// main function for running the angular algorithm.\n+/**\n+ * @brief The main function for the angular algorithm.\n+ *\n+ * @param sample_count The number of samples.\n+ * @param samples The sample data.\n+ * @param sample_weights The weight of each sample.\n+ * @param max_quant_level The maximum quantization level to be tested.\n+ * @param[out] low_value Per angular step, the lowest weight value.\n+ * @param[out] high_value Per angular step, the highest weight value.\n+ */\nstatic void compute_angular_endpoints_for_quant_levels(\nint sample_count,\nconst float* samples,\n@@ -338,11 +370,10 @@ else\n}\n}\n-// helper functions that will compute ideal angular-endpoints\n-// for a given set of weights and a given block size descriptors\n+/* See header for documentation. */\nvoid compute_angular_endpoints_1plane(\nbool only_always,\n- const block_size_descriptor* bsd,\n+ const block_size_descriptor& bsd,\nconst float* decimated_quantized_weights,\nconst float* decimated_weights,\nfloat low_value[MAX_WEIGHT_MODES],\n@@ -351,16 +382,16 @@ void compute_angular_endpoints_1plane(\nfloat low_values[MAX_DECIMATION_MODES][12];\nfloat high_values[MAX_DECIMATION_MODES][12];\n- promise(bsd->decimation_mode_count > 0);\n- for (int i = 0; i < bsd->decimation_mode_count; i++)\n+ promise(bsd.decimation_mode_count > 0);\n+ for (int i = 0; i < bsd.decimation_mode_count; i++)\n{\n- const decimation_mode& dm = bsd->decimation_modes[i];\n+ const decimation_mode& dm = bsd.decimation_modes[i];\nif (dm.maxprec_1plane < 0 || (only_always && !dm.percentile_always) || !dm.percentile_hit)\n{\ncontinue;\n}\n- int sample_count = bsd->decimation_tables[i]->weight_count;\n+ int sample_count = bsd.decimation_tables[i]->weight_count;\ncompute_angular_endpoints_for_quant_levels(\nsample_count,\ndecimated_quantized_weights + i * MAX_WEIGHTS_PER_BLOCK,\n@@ -368,10 +399,10 @@ void compute_angular_endpoints_1plane(\ndm.maxprec_1plane, low_values[i], high_values[i]);\n}\n- promise(bsd->block_mode_count > 0);\n- for (int i = 0; i < bsd->block_mode_count; ++i)\n+ promise(bsd.block_mode_count > 0);\n+ for (int i = 0; i < bsd.block_mode_count; ++i)\n{\n- const block_mode& bm = bsd->block_modes[i];\n+ const block_mode& bm = bsd.block_modes[i];\nif (bm.is_dual_plane || (only_always && !bm.percentile_always) || !bm.percentile_hit)\n{\ncontinue;\n@@ -385,8 +416,9 @@ void compute_angular_endpoints_1plane(\n}\n}\n+/* See header for documentation. */\nvoid compute_angular_endpoints_2planes(\n- const block_size_descriptor* bsd,\n+ const block_size_descriptor& bsd,\nconst float* decimated_quantized_weights,\nconst float* decimated_weights,\nfloat low_value1[MAX_WEIGHT_MODES],\n@@ -399,16 +431,16 @@ void compute_angular_endpoints_2planes(\nfloat low_values2[MAX_DECIMATION_MODES][12];\nfloat high_values2[MAX_DECIMATION_MODES][12];\n- promise(bsd->decimation_mode_count > 0);\n- for (int i = 0; i < bsd->decimation_mode_count; i++)\n+ promise(bsd.decimation_mode_count > 0);\n+ for (int i = 0; i < bsd.decimation_mode_count; i++)\n{\n- const decimation_mode& dm = bsd->decimation_modes[i];\n+ const decimation_mode& dm = bsd.decimation_modes[i];\nif (dm.maxprec_2planes < 0 || !dm.percentile_hit)\n{\ncontinue;\n}\n- int sample_count = bsd->decimation_tables[i]->weight_count;\n+ int sample_count = bsd.decimation_tables[i]->weight_count;\ncompute_angular_endpoints_for_quant_levels(\nsample_count,\n@@ -423,10 +455,10 @@ void compute_angular_endpoints_2planes(\ndm.maxprec_2planes, low_values2[i], high_values2[i]);\n}\n- promise(bsd->block_mode_count > 0);\n- for (int i = 0; i < bsd->block_mode_count; ++i)\n+ promise(bsd.block_mode_count > 0);\n+ for (int i = 0; i < bsd.block_mode_count; ++i)\n{\n- const block_mode& bm = bsd->block_modes[i];\n+ const block_mode& bm = bsd.block_modes[i];\nif (!bm.is_dual_plane || !bm.percentile_hit)\n{\ncontinue;\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup API for weight_align
|
61,745 |
16.05.2021 20:14:28
| -3,600 |
f4f5cfbe8832e7075002f903e9c7a9e7d6b28748
|
Comment style cleanup
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_weight_quant_xfer_tables.cpp",
"new_path": "Source/astcenc_weight_quant_xfer_tables.cpp",
"diff": "#include \"astcenc_internal.h\"\n-#define _ 0 // using _ to indicate an entry that will not be used.\n+#define _ 0 // Using _ to indicate an entry that will not be used.\nconst quantization_and_transfer_table quant_and_xfer_tables[12] = {\n- // quantization method 0, range 0..1\n+ // Quantization method 0, range 0..1\n{\nQUANT_2,\n{0, 64, 255},\n@@ -34,7 +34,7 @@ const quantization_and_transfer_table quant_and_xfer_tables[12] = {\n_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,\n0x01004000}\n},\n- // quantization method 1, range 0..2\n+ // Quantization method 1, range 0..2\n{\nQUANT_3,\n{0, 32, 64, 255},\n@@ -44,7 +44,7 @@ const quantization_and_transfer_table quant_and_xfer_tables[12] = {\n_,_,0x02004000,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,\n_,_,_,_,0x02014020}\n},\n- // quantization method 2, range 0..3\n+ // Quantization method 2, range 0..3\n{\nQUANT_4,\n{0, 21, 43, 64, 255},\n@@ -54,7 +54,7 @@ const quantization_and_transfer_table quant_and_xfer_tables[12] = {\n_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,0x03014015,_,_,_,_,_,_,_,_,_,_,_,_,\n_,_,_,_,_,_,_,_,0x0302402b}\n},\n- // quantization method 3, range 0..4\n+ // Quantization method 3, range 0..4\n{\nQUANT_5,\n{0, 16, 32, 48, 64, 255},\n@@ -64,7 +64,7 @@ const quantization_and_transfer_table quant_and_xfer_tables[12] = {\n_,_,_,_,_,_,0x03013010,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,0x04024020,_,_,_,\n_,_,_,_,_,_,_,_,_,_,_,_,0x04034030}\n},\n- // quantization method 4, range 0..5\n+ // Quantization method 4, range 0..5\n{\nQUANT_6,\n{0, 12, 25, 39, 52, 64, 255},\n@@ -74,7 +74,7 @@ const quantization_and_transfer_table quant_and_xfer_tables[12] = {\n0x0502270c,_,_,_,_,_,_,_,_,_,_,_,_,_,0x03043419,_,_,_,_,_,_,_,_,_,_,\n_,_,0x01054027,_,_,_,_,_,_,_,_,_,_,_,0x01034034}\n},\n- // quantization method 5, range 0..7\n+ // Quantization method 5, range 0..7\n{\nQUANT_8,\n{0, 9, 18, 27, 37, 46, 55, 64, 255},\n@@ -84,7 +84,7 @@ const quantization_and_transfer_table quant_and_xfer_tables[12] = {\n_,_,_,_,_,_,0x04022512,_,_,_,_,_,_,_,_,_,0x05032e1b,_,_,_,_,_,_,_,_,\n0x06043725,_,_,_,_,_,_,_,_,0x0705402e,_,_,_,_,_,_,_,_,0x07064037}\n},\n- // quantization method 6, range 0..9\n+ // Quantization method 6, range 0..9\n{\nQUANT_10,\n{0, 7, 14, 21, 28, 36, 43, 50, 57, 64, 255},\n@@ -95,7 +95,7 @@ const quantization_and_transfer_table quant_and_xfer_tables[12] = {\n_,0x05093224,_,_,_,_,_,_,0x0307392b,_,_,_,_,_,_,0x01054032,_,_,_,_,_,\n_,0x01034039}\n},\n- // quantization method 7, range 0..11\n+ // Quantization method 7, range 0..11\n{\nQUANT_12,\n{0, 5, 11, 17, 23, 28, 36, 41, 47, 53, 59, 64, 255},\n@@ -106,7 +106,7 @@ const quantization_and_transfer_table quant_and_xfer_tables[12] = {\n0x070a291c,_,_,_,_,0x030b2f24,_,_,_,_,_,0x09073529,_,_,_,_,_,\n0x05033b2f,_,_,_,_,_,0x01094035,_,_,_,_,0x0105403b}\n},\n- // quantization method 8, range 0..15\n+ // Quantization method 8, range 0..15\n{\nQUANT_16,\n{0, 4, 8, 12, 17, 21, 25, 29, 35, 39, 43, 47, 52, 56, 60, 64, 255},\n@@ -117,7 +117,7 @@ const quantization_and_transfer_table quant_and_xfer_tables[12] = {\n_,0x0907271d,_,_,_,0x0a082b23,_,_,_,0x0b092f27,_,_,_,0x0c0a342b,_,_,_,\n_,0x0d0b382f,_,_,_,0x0e0c3c34,_,_,_,0x0f0d4038,_,_,_,0x0f0e403c}\n},\n- // quantization method 9, range 0..19\n+ // Quantization method 9, range 0..19\n{\nQUANT_20,\n{0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 35, 38, 41, 45, 48, 51, 55, 58,\n@@ -131,7 +131,7 @@ const quantization_and_transfer_table quant_and_xfer_tables[12] = {\n0x070f2d26,_,_,_,0x030b3029,_,_,0x1107332d,_,_,0x0d033730,_,_,_,\n0x09113a33,_,_,0x050d3d37,_,_,0x0109403a,_,_,0x0105403d}\n},\n- // quantization method 10, range 0..23\n+ // Quantization method 10, range 0..23\n{\nQUANT_24,\n{0, 2, 5, 8, 11, 13, 16, 19, 22, 24, 27, 30, 34, 37, 40, 42, 45, 48,\n@@ -147,7 +147,7 @@ const quantization_and_transfer_table quant_and_xfer_tables[12] = {\n_,_,0x0b053530,_,0x03133833,_,_,0x110b3b35,_,_,0x09033e38,_,_,\n0x0111403b,_,0x0109403e}\n},\n- // quantization method 11, range 0..31\n+ // Quantization method 11, range 0..31\n{\nQUANT_32,\n{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 34, 36, 38,\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Comment style cleanup
|
61,745 |
16.05.2021 20:16:53
| -3,600 |
fea1f414f2bb44b43c2fa8b41e95cc9f5eaa04b3
|
Cleanup platform_isa_detection
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_image.cpp",
"new_path": "Source/astcenc_image.cpp",
"diff": "@@ -147,7 +147,7 @@ static vfloat4 encode_texel_lns(\nreturn select(datav_unorm, datav_lns, lns_mask);\n}\n-/* See header for documentation */\n+/* See header for documentation. */\nvoid fetch_imageblock(\nastcenc_profile decode_mode,\nconst astcenc_image& img,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_platform_isa_detection.cpp",
"new_path": "Source/astcenc_platform_isa_detection.cpp",
"diff": "#if (ASTCENC_SSE > 0) || (ASTCENC_AVX > 0) || \\\n(ASTCENC_POPCNT > 0) || (ASTCENC_F16C > 0)\n+/** Does this CPU support SSE 4.1? Set to -1 if not yet initialized. */\nstatic int g_cpu_has_sse41 = -1;\n+\n+/** Does this CPU support AVX2? Set to -1 if not yet initialized. */\nstatic int g_cpu_has_avx2 = -1;\n+\n+/** Does this CPU support POPCNT? Set to -1 if not yet initialized. */\nstatic int g_cpu_has_popcnt = -1;\n+\n+/** Does this CPU support F16C? Set to -1 if not yet initialized. */\nstatic int g_cpu_has_f16c = -1;\n/* ============================================================================\n@@ -39,6 +46,9 @@ static int g_cpu_has_f16c = -1;\n#if !defined(__clang__) && defined(_MSC_VER)\n#include <intrin.h>\n+/**\n+ * @brief Detect platform CPU ISA support and update global trackers.\n+ */\nstatic void detect_cpu_isa()\n{\nint data[4];\n@@ -75,6 +85,9 @@ static void detect_cpu_isa()\n#else\n#include <cpuid.h>\n+/**\n+ * @brief Detect platform CPU ISA support and update global trackers.\n+ */\nstatic void detect_cpu_isa()\n{\nunsigned int data[4];\n@@ -101,7 +114,7 @@ static void detect_cpu_isa()\n}\n#endif\n-/* Public function, see header file for detailed documentation */\n+/* See header for documentation. */\nint cpu_supports_sse41()\n{\nif (g_cpu_has_sse41 == -1)\n@@ -112,7 +125,7 @@ int cpu_supports_sse41()\nreturn g_cpu_has_sse41;\n}\n-/* Public function, see header file for detailed documentation */\n+/* See header for documentation. */\nint cpu_supports_popcnt()\n{\nif (g_cpu_has_popcnt == -1)\n@@ -123,7 +136,7 @@ int cpu_supports_popcnt()\nreturn g_cpu_has_popcnt;\n}\n-/* Public function, see header file for detailed documentation */\n+/* See header for documentation. */\nint cpu_supports_f16c()\n{\nif (g_cpu_has_f16c == -1)\n@@ -134,7 +147,7 @@ int cpu_supports_f16c()\nreturn g_cpu_has_f16c;\n}\n-/* Public function, see header file for detailed documentation */\n+/* See header for documentation. */\nint cpu_supports_avx2()\n{\nif (g_cpu_has_avx2 == -1)\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup platform_isa_detection
|
61,745 |
16.05.2021 20:27:17
| -3,600 |
764be242ef99659243c30482aa1d779130624479
|
Cleanup API for symbolic_physical
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_symbolic_physical.cpp",
"new_path": "Source/astcenc_symbolic_physical.cpp",
"diff": "#include <assert.h>\n-// routine to write up to 8 bits\n+/**\n+ * @brief Write up to 8 bits at an arbitrary bit offset.\n+ *\n+ * The stored value is at most 8 bits, but can be stored at an offset of\n+ * between 0 and 7 bits so may span two separate bytes in memory.\n+ *\n+ * @param value The value to write.\n+ * @param bitcount The number of bits to write, starting from LSB.\n+ * @param bitoffset The bit offset to store at, between 0 and 7.\n+ * @param[in,out] ptr The data pointer to write to.\n+ */\nstatic inline void write_bits(\nint value,\nint bitcount,\n@@ -44,7 +54,18 @@ static inline void write_bits(\nptr[1] |= value >> 8;\n}\n-// routine to read up to 8 bits\n+/**\n+ * @brief Read up to 8 bits at an arbitrary bit offset.\n+ *\n+ * The stored value is at most 8 bits, but can be stored at an offset of\n+ * between 0 and 7 bits so may span two separate bytes in memory.\n+ *\n+ * @param bitcount The number of bits to read.\n+ * @param bitoffset The bit offset to read from, between 0 and 7.\n+ * @param[in,out] ptr The data pointer to read from.\n+ *\n+ * @return The read value.\n+ */\nstatic inline int read_bits(\nint bitcount,\nint bitoffset,\n@@ -59,14 +80,22 @@ static inline int read_bits(\nreturn value;\n}\n+/**\n+ * @brief Reverse bits in a byte.\n+ *\n+ * @param p The value to reverse.\n+ *\n+ * @return The reversed result.\n+ */\nstatic inline int bitrev8(int p)\n{\n- p = ((p & 0xF) << 4) | ((p >> 4) & 0xF);\n+ p = ((p & 0x0F) << 4) | ((p >> 4) & 0x0F);\np = ((p & 0x33) << 2) | ((p >> 2) & 0x33);\np = ((p & 0x55) << 1) | ((p >> 1) & 0x55);\nreturn p;\n}\n+/* See header for documentation. */\nvoid symbolic_to_physical(\nconst block_size_descriptor& bsd,\nconst symbolic_compressed_block& scb,\n@@ -116,8 +145,8 @@ void symbolic_to_physical(\nint partition_count = scb.partition_count;\n- // first, compress the weights. They are encoded as an ordinary\n- // integer-sequence, then bit-reversed\n+ // First, compress the weights.\n+ // They are encoded as an ordinary integer-sequence, then bit-reversed\nuint8_t weightbuf[16];\nfor (int i = 0; i < 16; i++)\n{\n@@ -164,8 +193,7 @@ void symbolic_to_physical(\nint below_weights_pos = 128 - bits_for_weights;\n- // encode partition index and color endpoint types for blocks with\n- // 2 or more partitions.\n+ // Encode partition index and color endpoint types for blocks with 2+ partitions\nif (partition_count > 1)\n{\nwrite_bits(scb.partition_index, 6, 13, pcb.data);\n@@ -177,8 +205,7 @@ void symbolic_to_physical(\n}\nelse\n{\n- // go through the selected endpoint type classes for each partition\n- // in order to determine the lowest class present.\n+ // Check endpoint types for each partition to determine the lowest class present\nint low_class = 4;\nfor (int i = 0; i < partition_count; i++)\n@@ -223,14 +250,13 @@ void symbolic_to_physical(\nwrite_bits(scb.color_formats[0], 4, 13, pcb.data);\n}\n- // in dual-plane mode, encode the color component of the second plane of weights\n+ // In dual-plane mode, encode the color component of the second plane of weights\nif (is_dual_plane)\n{\nwrite_bits(scb.plane2_component, 2, below_weights_pos - 2, pcb.data);\n}\n- // finally, encode the color bits\n- // first, get hold of all the color components to encode\n+ // Encode the color components\nuint8_t values_to_encode[32];\nint valuecount_to_encode = 0;\nfor (int i = 0; i < scb.partition_count; i++)\n@@ -243,10 +269,10 @@ void symbolic_to_physical(\nvaluecount_to_encode += vals;\n}\n- // then, encode an ISE based on them.\nencode_ise((quant_method)scb.color_quant_level, valuecount_to_encode, values_to_encode, pcb.data, (scb.partition_count == 1 ? 17 : 19 + PARTITION_BITS));\n}\n+/* See header for documentation. */\nvoid physical_to_symbolic(\nconst block_size_descriptor& bsd,\nconst physical_compressed_block& pcb,\n@@ -256,16 +282,16 @@ void physical_to_symbolic(\nscb.error_block = 0;\n- // get hold of the decimation tables.\n+ // Fetch the decimation tables\nconst decimation_table *const *dts = bsd.decimation_tables;\n- // extract header fields\n+ // Extract header fields\nint block_mode = read_bits(11, 0, pcb.data);\nif ((block_mode & 0x1FF) == 0x1FC)\n{\n- // void-extent block!\n+ // Constant color block\n- // check what format the data has\n+ // Check what format the data has\nif (block_mode & 0x200)\n{\nscb.block_mode = -1; // floating-point\n@@ -281,7 +307,7 @@ void physical_to_symbolic(\nscb.constant_color[i] = pcb.data[2 * i + 8] | (pcb.data[2 * i + 9] << 8);\n}\n- // additionally, check that the void-extent\n+ // Additionally, check that the void-extent\nif (bsd.zdim == 1)\n{\n// 2D void-extent\n@@ -375,7 +401,7 @@ void physical_to_symbolic(\nscb.color_formats_matched = 0;\n- // then, determine the format of each endpoint pair\n+ // Determine the format of each endpoint pair\nint color_formats[4];\nint encoded_type_highpart_size = 0;\nif (partition_count == 1)\n@@ -425,7 +451,7 @@ void physical_to_symbolic(\nscb.color_formats[i] = color_formats[i];\n}\n- // then, determine the number of integers we need to unpack for the endpoint pairs\n+ // Determine number of color endpoint integers\nint color_integer_count = 0;\nfor (int i = 0; i < partition_count; i++)\n{\n@@ -438,7 +464,7 @@ void physical_to_symbolic(\nscb.error_block = 1;\n}\n- // then, determine the color endpoint format to use for these integers\n+ // Determine the color endpoint format to use\nstatic 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@@ -458,13 +484,11 @@ void physical_to_symbolic(\nscb.error_block = 1;\n}\n- // then unpack the integer-bits\n+ // Unpack the integer color values and assign to endpoints\nuint8_t values_to_decode[32];\ndecode_ise((quant_method)color_quant_level, color_integer_count, pcb.data, values_to_decode, (partition_count == 1 ? 17 : 19 + PARTITION_BITS));\n- // and distribute them over the endpoint types\nint valuecount_to_decode = 0;\n-\nfor (int i = 0; i < partition_count; i++)\n{\nint vals = 2 * (color_formats[i] >> 2) + 2;\n@@ -475,7 +499,7 @@ void physical_to_symbolic(\nvaluecount_to_decode += vals;\n}\n- // get hold of color component for second-plane in the case of dual plane of weights.\n+ // Fetch component for second-plane in the case of dual plane of weights.\nif (is_dual_plane)\n{\nscb.plane2_component = read_bits(2, below_weights_pos - 2, pcb.data);\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Cleanup API for symbolic_physical
|
61,745 |
18.05.2021 20:11:12
| -3,600 |
f732aac1dbedd969ba7f3b3509f51b5625f96ea0
|
Use incremental add
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -913,8 +913,8 @@ void compute_ideal_weights_for_decimation_table(\nvfloat old_weight = gatherf(infilled_weights, texel);\nvfloat ideal_weight = gatherf(eai_in.weights, texel);\n- error_change0 = error_change0 + contrib_weight * scale;\n- error_change1 = error_change1 + (old_weight - ideal_weight) * scale;\n+ error_change0 += contrib_weight * scale;\n+ error_change1 += (old_weight - ideal_weight) * scale;\n}\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use incremental add
|
61,745 |
18.05.2021 20:34:29
| -3,600 |
2aae3ca9ad4b28a56c35becb1a5dc75e82310db2
|
Remove needless copies in compress_symbolic
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -387,8 +387,6 @@ static float compress_symbolic_block_fixed_partition_1plane(\n{\nTRACE_NODE(node0, \"candidate\");\n- uint8_t *u8_weight_src;\n-\nconst int bm_packed_index = block_mode_index[i];\nif (bm_packed_index < 0)\n{\n@@ -403,7 +401,6 @@ static float compress_symbolic_block_fixed_partition_1plane(\nint weight_quant_mode = qw_bm.quant_mode;\nconst decimation_table& dt = *dts[decimation_mode];\npromise(dt.weight_count > 0);\n- u8_weight_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * bm_packed_index;\ntrace_add_data(\"weight_x\", dt.weight_x);\ntrace_add_data(\"weight_y\", dt.weight_y);\n@@ -415,11 +412,18 @@ static float compress_symbolic_block_fixed_partition_1plane(\nvfloat4 rgbo_colors[4];\nsymbolic_compressed_block workscb;\n+\n+ uint8_t* u8_weight_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * bm_packed_index;\n+ for (int j = 0; j < dt.weight_count; j++)\n+ {\n+ workscb.weights[j] = u8_weight_src[j];\n+ }\n+\nfor (unsigned int l = 0; l < config.tune_refinement_limit; l++)\n{\nrecompute_ideal_colors_1plane(\nblk, ewb, *pt, dt,\n- weight_quant_mode, u8_weight_src,\n+ weight_quant_mode, workscb.weights,\neix[decimation_mode].ep, rgbs_colors, rgbo_colors);\n// quantize the chosen color\n@@ -469,7 +473,7 @@ static float compress_symbolic_block_fixed_partition_1plane(\nworkscb.color_formats_matched = 1;\nfor (int j = 0; j < 4; j++)\n{\n- for (int k = 0; k < 12; k++)\n+ for (int k = 0; k < 8; k++)\n{\nworkscb.color_values[j][k] = colorvals[j][k];\n}\n@@ -494,11 +498,6 @@ static float compress_symbolic_block_fixed_partition_1plane(\n// Pre-realign test\nif (l == 0)\n{\n- for (int j = 0; j < dt.weight_count; j++)\n- {\n- workscb.weights[j] = u8_weight_src[j];\n- }\n-\nfloat errorval = compute_symbolic_block_difference(config, bsd, workscb, blk, ewb);\nif (errorval == -1e30f)\n{\n@@ -538,14 +537,9 @@ static float compress_symbolic_block_fixed_partition_1plane(\n// perform a final pass over the weights to try to improve them.\nbool adjustments = realign_weights(\nconfig.profile, bsd, blk, ewb, workscb,\n- u8_weight_src, nullptr);\n+ workscb.weights, nullptr);\n// Post-realign test\n- for (int j = 0; j < dt.weight_count; j++)\n- {\n- workscb.weights[j] = u8_weight_src[j];\n- }\n-\nfloat errorval = compute_symbolic_block_difference(config, bsd, workscb, blk, ewb);\nif (errorval == -1e30f)\n{\n@@ -799,9 +793,6 @@ static float compress_symbolic_block_fixed_partition_2planes(\ncontinue;\n}\n- uint8_t *u8_weight1_src;\n- uint8_t *u8_weight2_src;\n-\nassert(bm_packed_index >= 0 && bm_packed_index < bsd.block_mode_count);\nconst block_mode& qw_bm = bsd.block_modes[bm_packed_index];\n@@ -810,9 +801,6 @@ static float compress_symbolic_block_fixed_partition_2planes(\nconst decimation_table& dt = *dts[decimation_mode];\npromise(dt.weight_count > 0);\n- u8_weight1_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * bm_packed_index);\n- u8_weight2_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * bm_packed_index + 1);\n-\ntrace_add_data(\"weight_x\", dt.weight_x);\ntrace_add_data(\"weight_y\", dt.weight_y);\ntrace_add_data(\"weight_z\", dt.weight_z);\n@@ -825,11 +813,20 @@ static float compress_symbolic_block_fixed_partition_2planes(\nvfloat4 rgbo_colors[4];\nsymbolic_compressed_block workscb;\n+\n+ uint8_t* u8_weight1_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * bm_packed_index);\n+ uint8_t* u8_weight2_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * bm_packed_index + 1);\n+ for (int j = 0; j < dt.weight_count; j++)\n+ {\n+ workscb.weights[j] = u8_weight1_src[j];\n+ workscb.weights[j + PLANE2_WEIGHTS_OFFSET] = u8_weight2_src[j];\n+ }\n+\nfor (unsigned int l = 0; l < config.tune_refinement_limit; l++)\n{\nrecompute_ideal_colors_2planes(\nblk, ewb, *pt, dt,\n- weight_quant_mode, u8_weight1_src, u8_weight2_src,\n+ weight_quant_mode, workscb.weights, workscb.weights + PLANE2_WEIGHTS_OFFSET,\nepm, rgbs_colors, rgbo_colors, plane2_component);\n// store the colors for the block\n@@ -872,7 +869,7 @@ static float compress_symbolic_block_fixed_partition_2planes(\nworkscb.color_formats_matched = 1;\nfor (int j = 0; j < 4; j++)\n{\n- for (int k = 0; k < 12; k++)\n+ for (int k = 0; k < 8; k++)\n{\nworkscb.color_values[j][k] = colorvals[j][k];\n}\n@@ -898,12 +895,6 @@ static float compress_symbolic_block_fixed_partition_2planes(\n// Pre-realign test\nif (l == 0)\n{\n- for (int j = 0; j < dt.weight_count; j++)\n- {\n- workscb.weights[j] = u8_weight1_src[j];\n- workscb.weights[j + PLANE2_WEIGHTS_OFFSET] = u8_weight2_src[j];\n- }\n-\nfloat errorval = compute_symbolic_block_difference(config, bsd, workscb, blk, ewb);\nif (errorval == -1e30f)\n{\n@@ -943,15 +934,9 @@ static float compress_symbolic_block_fixed_partition_2planes(\n// perform a final pass over the weights to try to improve them.\nbool adjustments = realign_weights(\nconfig.profile, bsd, blk, ewb, workscb,\n- u8_weight1_src, u8_weight2_src);\n+ workscb.weights, workscb.weights + PLANE2_WEIGHTS_OFFSET);\n// Post-realign test\n- for (int j = 0; j < dt.weight_count; j++)\n- {\n- workscb.weights[j] = u8_weight1_src[j];\n- workscb.weights[j + PLANE2_WEIGHTS_OFFSET] = u8_weight2_src[j];\n- }\n-\nfloat errorval = compute_symbolic_block_difference(config, bsd, workscb, blk, ewb);\nif (errorval == -1e30f)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -743,7 +743,7 @@ struct symbolic_compressed_block\nint plane2_component; // color component for second plane of weights\n// TODO: Under what circumstances is this ever more than 8 (4 pairs) colors\n- int color_values[4][12]; // quantized endpoint color pairs.\n+ int color_values[4][8]; // 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"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_symbolic_physical.cpp",
"new_path": "Source/astcenc_symbolic_physical.cpp",
"diff": "#include \"astcenc_internal.h\"\n-#include <assert.h>\n+#include <cassert>\n/**\n* @brief Write up to 8 bits at an arbitrary bit offset.\n@@ -262,6 +262,7 @@ void symbolic_to_physical(\nfor (int i = 0; i < scb.partition_count; i++)\n{\nint vals = 2 * (scb.color_formats[i] >> 2) + 2;\n+ assert(vals <= 8);\nfor (int j = 0; j < vals; j++)\n{\nvalues_to_encode[j + valuecount_to_encode] = scb.color_values[i][j];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Remove needless copies in compress_symbolic
|
61,745 |
18.05.2021 22:35:34
| -3,600 |
8b19852e5c85bdf816471e7a1467092e9bcdce58
|
Remove RESTRICT - no longer beneficial
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "@@ -754,8 +754,8 @@ void compute_ideal_weights_for_decimation_table(\nconst endpoints_and_weights& eai_in,\nendpoints_and_weights& eai_out,\nconst decimation_table& dt,\n- float* RESTRICT weight_set,\n- float* RESTRICT weights\n+ float* weight_set,\n+ float* weights\n) {\nint texel_count = dt.texel_count;\nint weight_count = dt.weight_count;\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"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Remove RESTRICT - no longer beneficial
|
61,745 |
18.05.2021 23:47:36
| -3,600 |
07e9211be0748a6a388f888bb8011af40c77fb37
|
Refactor many function names
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_block_sizes.cpp",
"new_path": "Source/astcenc_block_sizes.cpp",
"diff": "@@ -244,7 +244,7 @@ static int decode_block_mode_3d(\n* @param y_weights The number of weights in the Y dimension.\n* @param[out] di The decimation info structure to populate.\n*/\n-static void initialize_decimation_info_2d(\n+static void init_decimation_info_2d(\nint x_texels,\nint y_texels,\nint x_weights,\n@@ -436,7 +436,7 @@ static void initialize_decimation_info_2d(\n* @param z_weights The number of weights in the Z dimension.\n* @param[out] di The decimation info structure to populate.\n*/\n-static void initialize_decimation_info_3d(\n+static void init_decimation_info_3d(\nint x_texels,\nint y_texels,\nint z_texels,\n@@ -766,7 +766,7 @@ static int construct_dt_entry_2d(\nbool try_2planes = (2 * weight_count) <= MAX_WEIGHTS_PER_BLOCK;\ndecimation_info *di = aligned_malloc<decimation_info>(sizeof(decimation_info), ASTCENC_VECALIGN);\n- initialize_decimation_info_2d(x_texels, y_texels, x_weights, y_weights, *di);\n+ init_decimation_info_2d(x_texels, y_texels, x_weights, y_weights, *di);\nint maxprec_1plane = -1;\nint maxprec_2planes = -1;\n@@ -984,7 +984,7 @@ static void construct_block_size_descriptor_3d(\ndecimation_info *di = aligned_malloc<decimation_info>(sizeof(decimation_info), ASTCENC_VECALIGN);\ndecimation_mode_index[z_weights * 64 + y_weights * 8 + x_weights] = decimation_mode_count;\n- initialize_decimation_info_3d(x_texels, y_texels, z_texels, x_weights, y_weights, z_weights, *di);\n+ init_decimation_info_3d(x_texels, y_texels, z_texels, x_weights, y_weights, z_weights, *di);\nint maxprec_1plane = -1;\nint maxprec_2planes = -1;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_color_quantize.cpp",
"new_path": "Source/astcenc_color_quantize.cpp",
"diff": "* @return The encoded quantized value. These are not necessarily in the order; the compressor\n* scrambles the values slightly to make hardware implementation easier.\n*/\n-static inline int cqt_lookup(\n+static inline int quant_color(\nquant_method quant_level,\nint value\n) {\n@@ -79,12 +79,12 @@ static void quantize_rgb(\nint iters = 0;\ndo\n{\n- ri0 = cqt_lookup(quant_level, astc::flt2int_rd(r0 + rgb0_addon));\n- gi0 = cqt_lookup(quant_level, astc::flt2int_rd(g0 + rgb0_addon));\n- bi0 = cqt_lookup(quant_level, astc::flt2int_rd(b0 + rgb0_addon));\n- ri1 = cqt_lookup(quant_level, astc::flt2int_rd(r1 + rgb1_addon));\n- gi1 = cqt_lookup(quant_level, astc::flt2int_rd(g1 + rgb1_addon));\n- bi1 = cqt_lookup(quant_level, astc::flt2int_rd(b1 + rgb1_addon));\n+ ri0 = quant_color(quant_level, astc::flt2int_rd(r0 + rgb0_addon));\n+ gi0 = quant_color(quant_level, astc::flt2int_rd(g0 + rgb0_addon));\n+ bi0 = quant_color(quant_level, astc::flt2int_rd(b0 + rgb0_addon));\n+ ri1 = quant_color(quant_level, astc::flt2int_rd(r1 + rgb1_addon));\n+ gi1 = quant_color(quant_level, astc::flt2int_rd(g1 + rgb1_addon));\n+ bi1 = quant_color(quant_level, astc::flt2int_rd(b1 + rgb1_addon));\nri0b = color_unquant_tables[quant_level][ri0];\ngi0b = color_unquant_tables[quant_level][gi0];\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -233,7 +233,7 @@ static bool realign_weights(\n* @param[out] scb The symbolic compressed block output.\n* @param[out] tmpbuf The quantized weights for plane 1.\n*/\n-static float compress_symbolic_block_fixed_partition_1plane(\n+static float compress_symbolic_block_for_partition_1plane(\nconst astcenc_config& config,\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\n@@ -261,7 +261,7 @@ static float compress_symbolic_block_fixed_partition_1plane(\n// there is no quantization or decimation going on.\nendpoints_and_weights& ei = tmpbuf.ei1;\nendpoints_and_weights *eix = tmpbuf.eix1;\n- compute_endpoints_and_ideal_weights_1plane(bsd, blk, ewb, *pt, ei);\n+ compute_ideal_colors_and_weights_1plane(bsd, blk, ewb, *pt, ei);\n// next, compute ideal weights and endpoint colors for every decimation.\nconst decimation_info *const *dt = bsd.decimation_tables;\n@@ -281,7 +281,7 @@ static float compress_symbolic_block_fixed_partition_1plane(\ncontinue;\n}\n- compute_ideal_weights_for_decimation_table(\n+ compute_ideal_weights_for_decimation(\nei,\neix[i],\n*(dt[i]),\n@@ -348,7 +348,7 @@ static float compress_symbolic_block_fixed_partition_1plane(\nqwt_bitcounts[i] = bitcount;\n// then, generate the optimized set of weights for the weight mode.\n- compute_quantized_weights_for_decimation_table(\n+ compute_quantized_weights_for_decimation(\n*dt[decimation_mode],\nweight_low_value[i], weight_high_value[i],\ndecimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * decimation_mode,\n@@ -373,7 +373,7 @@ static float compress_symbolic_block_fixed_partition_1plane(\nint color_quant_level[TUNE_MAX_TRIAL_CANDIDATES];\nint color_quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\n- determine_optimal_set_of_endpoint_formats_to_use(\n+ compute_ideal_endpoint_formats(\nbsd, *pt, blk, ewb, ei.ep, qwt_bitcounts, qwt_errors,\nconfig.tune_candidate_limit, partition_format_specifiers, block_mode_index,\ncolor_quant_level, color_quant_level_mod);\n@@ -596,7 +596,7 @@ static float compress_symbolic_block_fixed_partition_1plane(\n* @param[out] scb The symbolic compressed block output.\n* @param[out] tmpbuf The quantized weights for plane 1.\n*/\n-static float compress_symbolic_block_fixed_partition_2planes(\n+static float compress_symbolic_block_for_partition_2planes(\nconst astcenc_config& config,\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\n@@ -625,7 +625,7 @@ static float compress_symbolic_block_fixed_partition_2planes(\nendpoints_and_weights& ei2 = tmpbuf.ei2;\nendpoints_and_weights* eix1 = tmpbuf.eix1;\nendpoints_and_weights* eix2 = tmpbuf.eix2;\n- compute_endpoints_and_ideal_weights_2planes(bsd, blk, ewb, *pt, plane2_component, ei1, ei2);\n+ compute_ideal_colors_and_weights_2planes(bsd, blk, ewb, *pt, plane2_component, ei1, ei2);\n// next, compute ideal weights and endpoint colors for every decimation.\nconst decimation_info *const *dt = bsd.decimation_tables;\n@@ -644,14 +644,14 @@ static float compress_symbolic_block_fixed_partition_2planes(\ncontinue;\n}\n- compute_ideal_weights_for_decimation_table(\n+ compute_ideal_weights_for_decimation(\nei1,\neix1[i],\n*(dt[i]),\ndecimated_quantized_weights + (2 * i) * MAX_WEIGHTS_PER_BLOCK,\ndecimated_weights + (2 * i) * MAX_WEIGHTS_PER_BLOCK);\n- compute_ideal_weights_for_decimation_table(\n+ compute_ideal_weights_for_decimation(\nei2,\neix2[i],\n*(dt[i]),\n@@ -738,7 +738,7 @@ static float compress_symbolic_block_fixed_partition_2planes(\nqwt_bitcounts[i] = bitcount;\n// then, generate the optimized set of weights for the mode.\n- compute_quantized_weights_for_decimation_table(\n+ compute_quantized_weights_for_decimation(\n*dt[decimation_mode],\nweight_low_value1[i],\nweight_high_value1[i],\n@@ -746,7 +746,7 @@ static float compress_symbolic_block_fixed_partition_2planes(\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_quantized_weights_for_decimation_table(\n+ compute_quantized_weights_for_decimation(\n*dt[decimation_mode],\nweight_low_value2[i],\nweight_high_value2[i],\n@@ -772,7 +772,7 @@ static float compress_symbolic_block_fixed_partition_2planes(\nendpoints epm;\nmerge_endpoints(ei1.ep, ei2.ep, plane2_component, epm);\n- determine_optimal_set_of_endpoint_formats_to_use(\n+ compute_ideal_endpoint_formats(\nbsd, *pt, blk, ewb, epm, qwt_bitcounts, qwt_errors,\nconfig.tune_candidate_limit, partition_format_specifiers, block_mode_index,\ncolor_quant_level, color_quant_level_mod);\n@@ -1504,7 +1504,7 @@ void compress_block(\ntrace_add_data(\"plane_count\", 1);\ntrace_add_data(\"search_mode\", i);\n- float errorval = compress_symbolic_block_fixed_partition_1plane(\n+ float errorval = compress_symbolic_block_for_partition_1plane(\nctx.config, *bsd, blk, ewb, i == 0,\nerror_threshold * errorval_mult[i] * errorval_overshoot,\n1, 0, scb, tmpbuf.planes);\n@@ -1550,7 +1550,7 @@ void compress_block(\ncontinue;\n}\n- float errorval = compress_symbolic_block_fixed_partition_2planes(\n+ float errorval = compress_symbolic_block_for_partition_2planes(\nctx.config, *bsd, blk, ewb,\nerror_threshold * errorval_overshoot,\n1, // partition count\n@@ -1574,7 +1574,7 @@ void compress_block(\nint partition_indices_1plane[2] { 0, 0 };\nint partition_index_2planes = 0;\n- find_best_partitionings(*bsd, blk, ewb, partition_count,\n+ find_best_partition_candidates(*bsd, blk, ewb, partition_count,\nctx.config.tune_partition_index_limit,\npartition_indices_1plane[0],\npartition_indices_1plane[1],\n@@ -1588,7 +1588,7 @@ void compress_block(\ntrace_add_data(\"plane_count\", 1);\ntrace_add_data(\"search_mode\", i);\n- float errorval = compress_symbolic_block_fixed_partition_1plane(\n+ float errorval = compress_symbolic_block_for_partition_1plane(\nctx.config, *bsd, blk, ewb, false,\nerror_threshold * errorval_overshoot,\npartition_count, partition_indices_1plane[i],\n@@ -1669,7 +1669,7 @@ void compress_block(\ntrace_add_data(\"plane_count\", 2);\ntrace_add_data(\"plane_component\", partition_index_2planes >> PARTITION_BITS);\n- float errorval = compress_symbolic_block_fixed_partition_2planes(\n+ float errorval = compress_symbolic_block_for_partition_2planes(\nctx.config, *bsd, blk, ewb,\nerror_threshold * errorval_overshoot,\npartition_count,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_decompress_symbolic.cpp",
"new_path": "Source/astcenc_decompress_symbolic.cpp",
"diff": "/**\n* @brief Compute a vector of texel weights by interpolating the decimated weight grid.\n*\n- * @param texel_to_get The first texel to get; N (SIMD width) consecutive texels are loaded.\n- * @param di The weight grid decimation table.\n+ * @param base_texel_index The first texel to get; N (SIMD width) consecutive texels are loaded.\n+ * @param di The weight grid decimation to use.\n* @param weights The raw weights.\n*\n* @return The undecimated weight for N (SIMD width) texels.\n*/\nstatic vint compute_value_of_texel_weight_int_vla(\n- int texel_to_get,\n+ int base_texel_index,\nconst decimation_info& di,\nconst int* weights\n) {\nvint summed_value(8);\n- vint weight_count(di.texel_weight_count + texel_to_get);\n+ vint weight_count(di.texel_weight_count + base_texel_index);\nint max_weight_count = hmax(weight_count).lane<0>();\npromise(max_weight_count > 0);\nfor (int i = 0; i < max_weight_count; i++)\n{\n- vint texel_weights(di.texel_weights_4t[i] + texel_to_get);\n- vint texel_weights_int(di.texel_weights_int_4t[i] + texel_to_get);\n+ vint texel_weights(di.texel_weights_4t[i] + base_texel_index);\n+ vint texel_weights_int(di.texel_weights_int_4t[i] + base_texel_index);\nsummed_value += gatheri(weights, texel_weights) * texel_weights_int;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -806,7 +806,7 @@ astcenc_error astcenc_context_alloc(\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\nprepare_angular_tables();\n#endif\n- build_quant_mode_table();\n+ init_quant_mode_table();\nreturn ASTCENC_SUCCESS;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_find_best_partitioning.cpp",
"new_path": "Source/astcenc_find_best_partitioning.cpp",
"diff": "#include \"astcenc_internal.h\"\n/* See header for documentation. */\n-void find_best_partitionings(\n+void find_best_partition_candidates(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nconst error_weight_block& ewb,\n@@ -77,7 +77,7 @@ void find_best_partitionings(\nint partition_sequence[PARTITION_COUNT];\n- kmeans_compute_partition_ordering(bsd, blk, partition_count, partition_sequence);\n+ compute_partition_ordering(bsd, blk, partition_count, partition_sequence);\nint uses_alpha = imageblock_uses_alpha(&blk);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp",
"diff": "* @param[out] ei The computed ideal endpoints and weights.\n* @param component The color component to compute.\n*/\n-static void compute_endpoints_and_ideal_weights_1_comp(\n+static void compute_ideal_colors_and_weights_1_comp(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nconst error_weight_block& ewb,\n@@ -153,7 +153,7 @@ static void compute_endpoints_and_ideal_weights_1_comp(\n* @param component1 The first color component to compute.\n* @param component2 The second color component to compute.\n*/\n-static void compute_endpoints_and_ideal_weights_2_comp(\n+static void compute_ideal_colors_and_weights_2_comp(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nconst error_weight_block& ewb,\n@@ -311,7 +311,7 @@ static void compute_endpoints_and_ideal_weights_2_comp(\n* @param[out] ei The computed ideal endpoints and weights.\n* @param omitted_component The color component excluded from the calculation.\n*/\n-static void compute_endpoints_and_ideal_weights_3_comp(\n+static void compute_ideal_colors_and_weights_3_comp(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nconst error_weight_block& ewb,\n@@ -487,7 +487,7 @@ static void compute_endpoints_and_ideal_weights_3_comp(\n* @param pi The partition info for the current trial.\n* @param[out] ei The computed ideal endpoints and weights.\n*/\n-static void compute_endpoints_and_ideal_weights_4_comp(\n+static void compute_ideal_colors_and_weights_4_comp(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nconst error_weight_block& ewb,\n@@ -599,7 +599,7 @@ static void compute_endpoints_and_ideal_weights_4_comp(\n}\n/* See header for documentation. */\n-void compute_endpoints_and_ideal_weights_1plane(\n+void compute_ideal_colors_and_weights_1plane(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nconst error_weight_block& ewb,\n@@ -609,16 +609,16 @@ void compute_endpoints_and_ideal_weights_1plane(\nint uses_alpha = imageblock_uses_alpha(&blk);\nif (uses_alpha)\n{\n- compute_endpoints_and_ideal_weights_4_comp(bsd, blk, ewb, pi, ei);\n+ compute_ideal_colors_and_weights_4_comp(bsd, blk, ewb, pi, ei);\n}\nelse\n{\n- compute_endpoints_and_ideal_weights_3_comp(bsd,blk, ewb, pi, ei, 3);\n+ compute_ideal_colors_and_weights_3_comp(bsd,blk, ewb, pi, ei, 3);\n}\n}\n/* See header for documentation. */\n-void compute_endpoints_and_ideal_weights_2planes(\n+void compute_ideal_colors_and_weights_2planes(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nconst error_weight_block& ewb,\n@@ -635,43 +635,43 @@ void compute_endpoints_and_ideal_weights_2planes(\ncase 0: // separate weights for red\nif (uses_alpha)\n{\n- compute_endpoints_and_ideal_weights_3_comp(bsd, blk, ewb, pi, ei1, 0);\n+ compute_ideal_colors_and_weights_3_comp(bsd, blk, ewb, pi, ei1, 0);\n}\nelse\n{\n- compute_endpoints_and_ideal_weights_2_comp(bsd, blk, ewb, pi, ei1, 1, 2);\n+ compute_ideal_colors_and_weights_2_comp(bsd, blk, ewb, pi, ei1, 1, 2);\n}\n- compute_endpoints_and_ideal_weights_1_comp(bsd, blk, ewb, pi, ei2, 0);\n+ compute_ideal_colors_and_weights_1_comp(bsd, blk, ewb, pi, ei2, 0);\nbreak;\ncase 1: // separate weights for green\nif (uses_alpha)\n{\n- compute_endpoints_and_ideal_weights_3_comp(bsd,blk, ewb, pi, ei1, 1);\n+ compute_ideal_colors_and_weights_3_comp(bsd,blk, ewb, pi, ei1, 1);\n}\nelse\n{\n- compute_endpoints_and_ideal_weights_2_comp(bsd, blk, ewb, pi, ei1, 0, 2);\n+ compute_ideal_colors_and_weights_2_comp(bsd, blk, ewb, pi, ei1, 0, 2);\n}\n- compute_endpoints_and_ideal_weights_1_comp(bsd, blk, ewb, pi, ei2, 1);\n+ compute_ideal_colors_and_weights_1_comp(bsd, blk, ewb, pi, ei2, 1);\nbreak;\ncase 2: // separate weights for blue\nif (uses_alpha)\n{\n- compute_endpoints_and_ideal_weights_3_comp(bsd, blk, ewb, pi, ei1, 2);\n+ compute_ideal_colors_and_weights_3_comp(bsd, blk, ewb, pi, ei1, 2);\n}\nelse\n{\n- compute_endpoints_and_ideal_weights_2_comp(bsd, blk, ewb, pi, ei1, 0, 1);\n+ compute_ideal_colors_and_weights_2_comp(bsd, blk, ewb, pi, ei1, 0, 1);\n}\n- compute_endpoints_and_ideal_weights_1_comp(bsd, blk, ewb, pi, ei2, 2);\n+ compute_ideal_colors_and_weights_1_comp(bsd, blk, ewb, pi, ei2, 2);\nbreak;\ndefault: // separate weights for alpha\nassert(uses_alpha);\n- compute_endpoints_and_ideal_weights_3_comp(bsd, blk, ewb, pi, ei1, 3);\n- compute_endpoints_and_ideal_weights_1_comp(bsd, blk, ewb, pi, ei2, 3);\n+ compute_ideal_colors_and_weights_3_comp(bsd, blk, ewb, pi, ei1, 3);\n+ compute_ideal_colors_and_weights_1_comp(bsd, blk, ewb, pi, ei2, 3);\nbreak;\n}\n}\n@@ -750,7 +750,7 @@ float compute_error_of_weight_set_2planes(\n}\n/* See header for documentation. */\n-void compute_ideal_weights_for_decimation_table(\n+void compute_ideal_weights_for_decimation(\nconst endpoints_and_weights& eai_in,\nendpoints_and_weights& eai_out,\nconst decimation_info& di,\n@@ -927,7 +927,7 @@ void compute_ideal_weights_for_decimation_table(\n}\n/* See header for documentation. */\n-void compute_quantized_weights_for_decimation_table(\n+void compute_quantized_weights_for_decimation(\nconst decimation_info& di,\nfloat low_bound,\nfloat high_bound,\n@@ -960,7 +960,7 @@ void compute_quantized_weights_for_decimation_table(\nvfloat low_boundv(low_bound);\n// This runs to the rounded-up SIMD size, which is safe as the loop tail is filled with known\n- // safe data in compute_ideal_weights_for_decimation_table and arrays are always 64 elements\n+ // safe data in compute_ideal_weights_for_decimation and arrays are always 64 elements\nfor (int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)\n{\nvfloat ix = loada(&weight_set_in[i]) * scalev - scaled_low_boundv;\n@@ -1004,7 +1004,7 @@ void compute_quantized_weights_for_decimation_table(\n* @param rgbq_sum Sum of partition component error weights * texel weight * color data.\n* @param psum Sum of RGB color weights * texel weight^2.\n*/\n-static inline vfloat4 compute_rgbovec(\n+static inline vfloat4 compute_rgbo_vector(\nvfloat4 rgba_weight_sum,\nvfloat4 weight_weight_sum,\nvfloat4 rgbq_sum,\n@@ -1167,7 +1167,7 @@ void recompute_ideal_colors_1plane(\nvfloat4 rgbq_sum = color_vec_x + color_vec_y;\nrgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));\n- vfloat4 rgbovec = compute_rgbovec(rgba_weight_sum, weight_weight_sum,\n+ vfloat4 rgbovec = compute_rgbo_vector(rgba_weight_sum, weight_weight_sum,\nrgbq_sum, psum);\nrgbo_vectors[i] = rgbovec;\n@@ -1402,7 +1402,7 @@ void recompute_ideal_colors_2planes(\nvfloat4 rgbq_sum = color_vec_x + color_vec_y;\nrgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));\n- vfloat4 rgbovec = compute_rgbovec(rgba_weight_sum, weight_weight_sum,\n+ vfloat4 rgbovec = compute_rgbo_vector(rgba_weight_sum, weight_weight_sum,\nrgbq_sum, psum);\nrgbo_vectors[i] = rgbovec;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -898,7 +898,7 @@ int get_ise_sequence_bitcount(\nint character_count,\nquant_method quant_level);\n-void build_quant_mode_table(void);\n+void init_quant_mode_table(void);\n// **********************************************\n// functions and data pertaining to partitioning\n@@ -1032,7 +1032,7 @@ void compute_error_squared_rgb(\n* @param[out] best_partition_samec The best partition for correlated chroma.\n* @param[out] best_partition_dualplane The best partition for dual plane, but may be @c nullptr.\n*/\n-void find_best_partitionings(\n+void find_best_partition_candidates(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nconst error_weight_block& ewb,\n@@ -1050,7 +1050,7 @@ void find_best_partitionings(\n* @param partition_count The desired number of partitions in the block.\n* @param[out] partition_ordering The list of recommended partition indices, in priority order.\n*/\n-void kmeans_compute_partition_ordering(\n+void compute_partition_ordering(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nint partition_count,\n@@ -1221,7 +1221,7 @@ struct endpoints_and_weights\n* @param pi The partition info for the current trial.\n* @param[out] ei The endpoint and weight values.\n*/\n-void compute_endpoints_and_ideal_weights_1plane(\n+void compute_ideal_colors_and_weights_1plane(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nconst error_weight_block& ewb,\n@@ -1244,7 +1244,7 @@ void compute_endpoints_and_ideal_weights_1plane(\n* @param[out] ei1 The endpoint and weight values for plane 1.\n* @param[out] ei2 The endpoint and weight values for plane 2.\n*/\n-void compute_endpoints_and_ideal_weights_2planes(\n+void compute_ideal_colors_and_weights_2planes(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nconst error_weight_block& ewb,\n@@ -1270,7 +1270,7 @@ void compute_endpoints_and_ideal_weights_2planes(\n* @param[out] weight_set The output decimated weight set.\n* @param[out] weights The output decimated weights.\n*/\n-void compute_ideal_weights_for_decimation_table(\n+void compute_ideal_weights_for_decimation(\nconst endpoints_and_weights& eai_in,\nendpoints_and_weights& eai_out,\nconst decimation_info& di,\n@@ -1291,7 +1291,7 @@ void compute_ideal_weights_for_decimation_table(\n* @param[out] quantized_weight_set The output quantized weight as encoded int.\n* @param quant_level The desired weight quant level.\n*/\n-void compute_quantized_weights_for_decimation_table(\n+void compute_quantized_weights_for_decimation(\nconst decimation_info& di,\nfloat low_bound,\nfloat high_bound,\n@@ -1514,7 +1514,7 @@ struct compress_symbolic_block_buffers\n* @param[out] quant_level The best color quant level.\n* @param[out] quant_level_mod The best color quant level if endpoints are the same.\n*/\n-void determine_optimal_set_of_endpoint_formats_to_use(\n+void compute_ideal_endpoint_formats(\nconst block_size_descriptor& bsd,\nconst partition_info& pi,\nconst imageblock& blk,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_kmeans_partitioning.cpp",
"new_path": "Source/astcenc_kmeans_partitioning.cpp",
"diff": "@@ -406,7 +406,7 @@ static void get_partition_ordering_by_mismatch_bits(\n}\n/* See header for documentation. */\n-void kmeans_compute_partition_ordering(\n+void compute_partition_ordering(\nconst block_size_descriptor& bsd,\nconst imageblock& blk,\nint partition_count,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_partition_tables.cpp",
"new_path": "Source/astcenc_partition_tables.cpp",
"diff": "@@ -106,10 +106,7 @@ static void remove_duplicate_partitionings(\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\ngenerate_canonical_partitioning(texel_count, pt[i].partition_of_texel, bit_patterns + i * 7);\n- }\n- for (int i = 0; i < PARTITION_COUNT; i++)\n- {\nfor (int j = 0; j < i; j++)\n{\nif (compare_canonical_partitionings(bit_patterns + 7 * i, bit_patterns + 7 * j))\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"new_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"diff": "@@ -1086,7 +1086,7 @@ static void four_partitions_find_best_combination_for_bitcount(\n}\n/* See header for documentation. */\n-void determine_optimal_set_of_endpoint_formats_to_use(\n+void compute_ideal_endpoint_formats(\nconst block_size_descriptor& bsd,\nconst partition_info& pi,\nconst imageblock& blk,\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_quantization.cpp",
"new_path": "Source/astcenc_quantization.cpp",
"diff": "@@ -539,7 +539,7 @@ const uint8_t color_unquant_tables[21][256] = {\nint8_t quant_mode_table[17][128];\n/* See header for documentation. */\n-void build_quant_mode_table()\n+void init_quant_mode_table()\n{\nfor (int i = 0; i <= 16; i++)\n{\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Refactor many function names
|
61,745 |
19.05.2021 14:28:41
| -3,600 |
7a38c63cd89046551c1985d1124f6441f43a9885
|
Ensure best_integer_count cant be negative
This is unreachable, but keeps static analysis tools happy
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"new_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"diff": "@@ -681,12 +681,13 @@ static void one_partition_find_best_combination_for_bitcount(\nint& best_format,\nfloat& best_error\n) {\n- int best_integer_count = -1;\n+ int best_integer_count = 0;\nfloat best_integer_count_error = 1e20f;\n- for (int i = 0; i < 4; i++)\n+\n+ for (int integer_count = 1; integer_count <= 4; integer_count++)\n{\n// Compute the quantization level for a given number of integers and a given number of bits\n- int quant_level = quant_mode_table[i + 1][bits_available];\n+ int quant_level = quant_mode_table[integer_count][bits_available];\n// Don't have enough bits to represent a given endpoint format at all!\nif (quant_level == -1)\n@@ -694,10 +695,11 @@ static void one_partition_find_best_combination_for_bitcount(\ncontinue;\n}\n- if (best_combined_error[quant_level][i] < best_integer_count_error)\n+ float integer_count_error = best_combined_error[quant_level][integer_count - 1];\n+ if (integer_count_error < best_integer_count_error)\n{\n- best_integer_count_error = best_combined_error[quant_level][i];\n- best_integer_count = i;\n+ best_integer_count_error = integer_count_error;\n+ best_integer_count = integer_count;\n}\n}\n@@ -796,7 +798,6 @@ static void two_partitions_find_best_combination_for_bitcount(\n}\nfloat integer_count_error = best_combined_error[quant_level][integer_count - 2];\n-\nif (integer_count_error < best_integer_count_error)\n{\nbest_integer_count_error = integer_count_error;\n@@ -920,7 +921,6 @@ static void three_partitions_find_best_combination_for_bitcount(\n}\nfloat integer_count_error = best_combined_error[quant_level][integer_count - 3];\n-\nif (integer_count_error < best_integer_count_error)\n{\nbest_integer_count_error = integer_count_error;\n@@ -1055,7 +1055,6 @@ static void four_partitions_find_best_combination_for_bitcount(\n}\nfloat integer_count_error = best_combined_error[quant_level][integer_count - 4];\n-\nif (integer_count_error < best_integer_count_error)\n{\nbest_integer_count_error = integer_count_error;\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Ensure best_integer_count cant be negative
This is unreachable, but keeps static analysis tools happy
|
61,745 |
19.05.2021 15:28:05
| -3,600 |
44428ac7a1aeae47fa0c9283f3597d7c26320bfb
|
Ensure constant_color is initialized
This is unreachable, but it keeps static analysis happy.
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -408,7 +408,13 @@ static float compress_symbolic_block_for_partition_1plane(\nsymbolic_compressed_block workscb;\n+ for (int j = 0; j < 4; j++)\n+ {\n+ workscb.constant_color[j] = 0;\n+ }\n+\nuint8_t* u8_weight_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * bm_packed_index;\n+\nfor (int j = 0; j < di.weight_count; j++)\n{\nworkscb.weights[j] = u8_weight_src[j];\n@@ -804,8 +810,14 @@ static float compress_symbolic_block_for_partition_2planes(\nsymbolic_compressed_block workscb;\n+ for (int j = 0; j < 4; j++)\n+ {\n+ workscb.constant_color[j] = 0;\n+ }\n+\nuint8_t* u8_weight1_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * bm_packed_index);\nuint8_t* u8_weight2_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * bm_packed_index + 1);\n+\nfor (int j = 0; j < di.weight_count; j++)\n{\nworkscb.weights[j] = u8_weight1_src[j];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Ensure constant_color is initialized
This is unreachable, but it keeps static analysis happy.
|
61,745 |
19.05.2021 15:59:35
| -3,600 |
670af35d2d71500e1d7d99685f3c960c3a9f770a
|
Fix quant off-by-one in one_partition_find_best_combination_for_bitcount
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"new_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"diff": "@@ -699,7 +699,7 @@ static void one_partition_find_best_combination_for_bitcount(\nif (integer_count_error < best_integer_count_error)\n{\nbest_integer_count_error = integer_count_error;\n- best_integer_count = integer_count;\n+ best_integer_count = integer_count - 1;\n}\n}\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Fix quant off-by-one in one_partition_find_best_combination_for_bitcount
|
61,745 |
19.05.2021 21:57:32
| -3,600 |
df5510dcefa69c933f84bc8e4a9cd078ffac8714
|
Single threaded contexts implicitly reset between images
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc.h",
"new_path": "Source/astcenc.h",
"diff": "@@ -749,6 +749,8 @@ ASTCENC_PUBLIC astcenc_error astcenc_compress_image(\n* only be called when all threads have exited the @c astcenc_compress_image() function for image N,\n* but before any thread enters it for image N + 1.\n*\n+ * Calling this is not required (but won't hurt), if the context is created for single threaded use.\n+ *\n* @param context Codec context.\n*\n* @return @c ASTCENC_SUCCESS on success, or an error if reset failed.\n@@ -783,6 +785,8 @@ ASTCENC_PUBLIC astcenc_error astcenc_decompress_image(\n* only be called when all threads have exited the @c astcenc_decompress_image() function for image\n* N, but before any thread enters it for image N + 1.\n*\n+ * Calling this is not required (but won't hurt), if the context is created for single threaded use.\n+ *\n* @param context Codec context.\n*\n* @return @c ASTCENC_SUCCESS on success, or an error if reset failed.\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -1002,6 +1002,12 @@ astcenc_error astcenc_compress_image(\nreturn ASTCENC_ERR_OUT_OF_MEM;\n}\n+ // If context thread count is one then implicitly reset\n+ if (ctx->thread_count == 1)\n+ {\n+ astcenc_compress_reset(ctx);\n+ }\n+\nif (ctx->config.v_rgb_mean != 0.0f || ctx->config.v_rgb_stdev != 0.0f ||\nctx->config.v_a_mean != 0.0f || ctx->config.v_a_stdev != 0.0f ||\nctx->config.a_scale_radius != 0)\n@@ -1117,6 +1123,12 @@ astcenc_error astcenc_decompress_image(\nimageblock blk;\n+ // If context thread count is one then implicitly reset\n+ if (ctx->thread_count == 1)\n+ {\n+ astcenc_decompress_reset(ctx);\n+ }\n+\n// Only the first thread actually runs the initializer\nctx->manage_decompress.init(zblocks * yblocks * xblocks);\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Single threaded contexts implicitly reset between images
|
61,745 |
22.05.2021 14:26:05
| -3,600 |
ac6f179e3b5d3320e1616abe64d0bd4216a134da
|
astcenc_block_info uses unsigned ints
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc.h",
"new_path": "Source/astcenc.h",
"diff": "@@ -602,16 +602,16 @@ struct astcenc_block_info\nastcenc_profile profile;\n/** @brief The number of texels in the X dimension. */\n- int block_x;\n+ unsigned int block_x;\n/** @brief The number of texels in the Y dimension. */\n- int block_y;\n+ unsigned int block_y;\n/** @brief The number of texel in the Z dimension. */\n- int block_z;\n+ unsigned int block_z;\n/** @brief The number of texels in the block. */\n- int texel_count;\n+ unsigned int texel_count;\n/** @brief True if this block is an error block. */\nbool is_error_block;\n@@ -626,31 +626,31 @@ struct astcenc_block_info\nbool is_dual_plane_block;\n/** @brief The number of partitions if not constant color. */\n- int partition_count;\n+ unsigned int partition_count;\n/** @brief The partition index if 2 - 4 partitions used. */\n- int partition_index;\n+ unsigned int partition_index;\n/** @brief The component index of the second plane if dual plane. */\n- int dual_plane_component;\n+ unsigned int dual_plane_component;\n/** @brief The color endpoint encoding mode for each partition. */\n- int color_endpoint_modes[4];\n+ unsigned int color_endpoint_modes[4];\n/** @brief The number of color endpoint quantization levels. */\n- int color_level_count;\n+ unsigned int color_level_count;\n/** @brief The number of weight quantization levels. */\n- int weight_level_count;\n+ unsigned int weight_level_count;\n/** @brief The number of weights in the X dimension. */\n- int weight_x;\n+ unsigned int weight_x;\n/** @brief The number of weights in the Y dimension. */\n- int weight_y;\n+ unsigned int weight_y;\n/** @brief The number of weights in the Z dimension. */\n- int weight_z;\n+ unsigned int weight_z;\n/** @brief The unpacked color endpoints for each partition. */\nfloat color_endpoints[4][2][4];\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
astcenc_block_info uses unsigned ints
|
61,745 |
22.05.2021 14:30:20
| -3,600 |
8bfc7403d94c785dbfecb8a34b0419c5ccd85462
|
Use unsigned types in avg/var computations
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compute_variance.cpp",
"new_path": "Source/astcenc_compute_variance.cpp",
"diff": "@@ -571,26 +571,26 @@ unsigned int init_compute_averages_and_variances(\nastcenc_image& img,\nfloat rgb_power,\nfloat alpha_power,\n- int avg_var_kernel_radius,\n- int alpha_kernel_radius,\n+ unsigned int avg_var_kernel_radius,\n+ unsigned int alpha_kernel_radius,\nconst astcenc_swizzle& swz,\npixel_region_variance_args& arg,\navg_var_args& ag\n) {\n- int size_x = img.dim_x;\n- int size_y = img.dim_y;\n- int size_z = img.dim_z;\n+ unsigned int size_x = img.dim_x;\n+ unsigned int size_y = img.dim_y;\n+ unsigned int size_z = img.dim_z;\n// Compute maximum block size and from that the working memory buffer size\n- int kernel_radius = astc::max(avg_var_kernel_radius, alpha_kernel_radius);\n- int kerneldim = 2 * kernel_radius + 1;\n+ unsigned int kernel_radius = astc::max(avg_var_kernel_radius, alpha_kernel_radius);\n+ unsigned int kerneldim = 2 * kernel_radius + 1;\nbool have_z = (size_z > 1);\n- int max_blk_size_xy = have_z ? 16 : 32;\n- int max_blk_size_z = astc::min(size_z, have_z ? 16 : 1);\n+ unsigned int max_blk_size_xy = have_z ? 16 : 32;\n+ unsigned int max_blk_size_z = astc::min(size_z, have_z ? 16u : 1u);\n- int max_padsize_xy = max_blk_size_xy + kerneldim;\n- int max_padsize_z = max_blk_size_z + (have_z ? kerneldim : 0);\n+ unsigned int max_padsize_xy = max_blk_size_xy + kerneldim;\n+ unsigned int max_padsize_z = max_blk_size_z + (have_z ? kerneldim : 0);\n// Perform block-wise averages-and-variances calculations across the image\n// Initialize fields which are not populated until later\n@@ -619,8 +619,8 @@ unsigned int init_compute_averages_and_variances(\nag.work_memory_size = 2 * max_padsize_xy * max_padsize_xy * max_padsize_z;\n// The parallel task count\n- int z_tasks = (size_z + max_blk_size_z - 1) / max_blk_size_z;\n- int y_tasks = (size_y + max_blk_size_xy - 1) / max_blk_size_xy;\n+ unsigned int z_tasks = (size_z + max_blk_size_z - 1) / max_blk_size_z;\n+ unsigned int y_tasks = (size_y + max_blk_size_xy - 1) / max_blk_size_xy;\nreturn z_tasks * y_tasks;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -1067,17 +1067,17 @@ struct pixel_region_variance_args\n/** Should the algorithm bother with Z axis processing? */\nbool have_z;\n/** The kernel radius for average and variance. */\n- int avg_var_kernel_radius;\n+ unsigned int avg_var_kernel_radius;\n/** The kernel radius for alpha processing. */\n- int alpha_kernel_radius;\n+ unsigned int alpha_kernel_radius;\n/** The size of the working data to process. */\n- int size_x;\n- int size_y;\n- int size_z;\n+ unsigned int size_x;\n+ unsigned int size_y;\n+ unsigned int size_z;\n/** The position of first src and dst data in the data set. */\n- int offset_x;\n- int offset_y;\n- int offset_z;\n+ unsigned int offset_x;\n+ unsigned int offset_y;\n+ unsigned int offset_z;\n/** The working memory buffer. */\nvfloat4 *work_memory;\n};\n@@ -1090,14 +1090,14 @@ struct avg_var_args\n/** The arguments for the nested variance computation. */\npixel_region_variance_args arg;\n/** The image dimensions. */\n- int img_size_x;\n- int img_size_y;\n- int img_size_z;\n+ unsigned int img_size_x;\n+ unsigned int img_size_y;\n+ unsigned int img_size_z;\n/** The maximum working block dimensions. */\n- int blk_size_xy;\n- int blk_size_z;\n+ unsigned int blk_size_xy;\n+ unsigned int blk_size_z;\n/** The working block memory size. */\n- int work_memory_size;\n+ unsigned int work_memory_size;\n};\n/**\n@@ -1121,8 +1121,8 @@ unsigned int init_compute_averages_and_variances(\nastcenc_image& img,\nfloat rgb_power,\nfloat alpha_power,\n- int avg_var_kernel_radius,\n- int alpha_kernel_radius,\n+ unsigned int avg_var_kernel_radius,\n+ unsigned int alpha_kernel_radius,\nconst astcenc_swizzle& swz,\npixel_region_variance_args& arg,\navg_var_args& ag);\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use unsigned types in avg/var computations
|
61,745 |
22.05.2021 14:38:31
| -3,600 |
7e5ce3456c614a45d790399b95f9a653ce6eac0b
|
More use of unsigned types
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_block_sizes.cpp",
"new_path": "Source/astcenc_block_sizes.cpp",
"diff": "* @return Returns true of valid mode, false otherwise.\n*/\nstatic bool decode_block_mode_2d(\n- int block_mode,\n- int& x_weights,\n- int& y_weights,\n+ unsigned int block_mode,\n+ unsigned int& x_weights,\n+ unsigned int& y_weights,\nbool& is_dual_plane,\n- int& quant_mode\n+ unsigned int& quant_mode\n) {\nint base_quant_mode = (block_mode >> 4) & 1;\nint H = (block_mode >> 9) & 1;\n@@ -146,13 +146,13 @@ static bool decode_block_mode_2d(\n*\n* @return Returns true of valid mode, false otherwise.\n*/\n-static int decode_block_mode_3d(\n- int block_mode,\n- int& x_weights,\n- int& y_weights,\n- int& z_weights,\n+static bool decode_block_mode_3d(\n+ unsigned int block_mode,\n+ unsigned int& x_weights,\n+ unsigned int& y_weights,\n+ unsigned int& z_weights,\nbool& is_dual_plane,\n- int& quant_mode\n+ unsigned int& quant_mode\n) {\nint base_quant_mode = (block_mode >> 4) & 1;\nint H = (block_mode >> 9) & 1;\n@@ -814,15 +814,15 @@ static int construct_dt_entry_2d(\n* @param[out] bsd The block size descriptor to populate.\n*/\nstatic void construct_block_size_descriptor_2d(\n- int x_texels,\n- int y_texels,\n+ unsigned int x_texels,\n+ unsigned int y_texels,\nbool can_omit_modes,\nfloat mode_cutoff,\nblock_size_descriptor& bsd\n) {\n// Store a remap table for storing packed decimation modes.\n// Indexing uses [Y * 16 + X] and max size for each axis is 12.\n- static const int MAX_DMI = 12 * 16 + 12;\n+ static const unsigned int MAX_DMI = 12 * 16 + 12;\nint decimation_mode_index[MAX_DMI];\nbsd.xdim = x_texels;\n@@ -831,7 +831,7 @@ static void construct_block_size_descriptor_2d(\nbsd.texel_count = x_texels * y_texels;\nbsd.decimation_mode_count = 0;\n- for (int i = 0; i < MAX_DMI; i++)\n+ for (unsigned int i = 0; i < MAX_DMI; i++)\n{\ndecimation_mode_index[i] = -1;\n}\n@@ -846,13 +846,14 @@ static void construct_block_size_descriptor_2d(\n#endif\n// Construct the list of block formats referencing the decimation tables\n- int packed_idx = 0;\n- for (int i = 0; i < MAX_WEIGHT_MODES; i++)\n+ unsigned int packed_idx = 0;\n+ for (unsigned int i = 0; i < MAX_WEIGHT_MODES; i++)\n{\n- int x_weights, y_weights;\n+ unsigned int x_weights, y_weights;\nbool is_dual_plane;\n+\n// TODO: Make this an enum? It's been validated.\n- int quant_mode;\n+ unsigned int quant_mode;\nbool valid = decode_block_mode_2d(i, x_weights, y_weights, is_dual_plane, quant_mode);\n@@ -924,7 +925,7 @@ static void construct_block_size_descriptor_2d(\n#endif\n// Ensure the end of the array contains valid data (should never get read)\n- for (int i = bsd.decimation_mode_count; i < MAX_DECIMATION_MODES; i++)\n+ for (unsigned int i = bsd.decimation_mode_count; i < MAX_DECIMATION_MODES; i++)\n{\nbsd.decimation_modes[i].maxprec_1plane = -1;\nbsd.decimation_modes[i].maxprec_2planes = -1;\n@@ -949,9 +950,9 @@ static void construct_block_size_descriptor_2d(\n* @param[out] bsd The block size descriptor to populate.\n*/\nstatic void construct_block_size_descriptor_3d(\n- int x_texels,\n- int y_texels,\n- int z_texels,\n+ unsigned int x_texels,\n+ unsigned int y_texels,\n+ unsigned int z_texels,\nblock_size_descriptor& bsd\n) {\n// Store a remap table for storing packed decimation modes.\n@@ -971,11 +972,11 @@ static void construct_block_size_descriptor_3d(\n}\n// gather all the infill-modes that can be used with the current block size\n- for (int x_weights = 2; x_weights <= x_texels; x_weights++)\n+ for (unsigned int x_weights = 2; x_weights <= x_texels; x_weights++)\n{\n- for (int y_weights = 2; y_weights <= y_texels; y_weights++)\n+ for (unsigned int y_weights = 2; y_weights <= y_texels; y_weights++)\n{\n- for (int z_weights = 2; z_weights <= z_texels; z_weights++)\n+ for (unsigned int z_weights = 2; z_weights <= z_texels; z_weights++)\n{\nunsigned int weight_count = x_weights * y_weights * z_weights;\nif (weight_count > MAX_WEIGHTS_PER_BLOCK)\n@@ -989,7 +990,7 @@ static void construct_block_size_descriptor_3d(\nint maxprec_1plane = -1;\nint maxprec_2planes = -1;\n- for (int i = 0; i < 12; i++)\n+ for (unsigned int i = 0; i < 12; i++)\n{\nunsigned int bits_1plane = get_ise_sequence_bitcount(weight_count, (quant_method)i);\nif (bits_1plane >= MIN_WEIGHT_BITS_PER_BLOCK && bits_1plane <= MAX_WEIGHT_BITS_PER_BLOCK)\n@@ -1020,7 +1021,7 @@ static void construct_block_size_descriptor_3d(\n}\n// Ensure the end of the array contains valid data (should never get read)\n- for (int i = decimation_mode_count; i < MAX_DECIMATION_MODES; i++)\n+ for (unsigned int i = decimation_mode_count; i < MAX_DECIMATION_MODES; i++)\n{\nbsd.decimation_modes[i].maxprec_1plane = -1;\nbsd.decimation_modes[i].maxprec_2planes = -1;\n@@ -1032,24 +1033,24 @@ static void construct_block_size_descriptor_3d(\nbsd.decimation_mode_count = decimation_mode_count;\n// Construct the list of block formats\n- int packed_idx = 0;\n- for (int i = 0; i < MAX_WEIGHT_MODES; i++)\n+ unsigned int packed_idx = 0;\n+ for (unsigned int i = 0; i < MAX_WEIGHT_MODES; i++)\n{\n- int x_weights, y_weights, z_weights;\n+ unsigned int x_weights, y_weights, z_weights;\nbool is_dual_plane;\n- int quant_mode;\n- int permit_encode = 1;\n+ unsigned int quant_mode;\n+ bool permit_encode = true;\nif (decode_block_mode_3d(i, x_weights, y_weights, z_weights, is_dual_plane, quant_mode))\n{\nif (x_weights > x_texels || y_weights > y_texels || z_weights > z_texels)\n{\n- permit_encode = 0;\n+ permit_encode = false;\n}\n}\nelse\n{\n- permit_encode = 0;\n+ permit_encode = false;\n}\nbsd.block_mode_packed_index[i] = -1;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -1284,10 +1284,10 @@ astcenc_error astcenc_get_block_info(\nunpack_weights(bsd, scb, di, bm.is_dual_plane, bm.get_quant_mode(), weight_plane1, weight_plane2);\nfor (unsigned int i = 0; i < bsd.texel_count; i++)\n{\n- info->weight_values_plane1[i] = (float)weight_plane1[i] / (float)TEXEL_WEIGHT_SUM;\n+ info->weight_values_plane1[i] = (float)weight_plane1[i] * (1.0f / TEXEL_WEIGHT_SUM);\nif (info->is_dual_plane_block)\n{\n- info->weight_values_plane2[i] = (float)weight_plane2[i] / (float)TEXEL_WEIGHT_SUM;\n+ info->weight_values_plane2[i] = (float)weight_plane2[i] * (1.0f / TEXEL_WEIGHT_SUM);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "/* ============================================================================\nConstants\n============================================================================ */\n-static const unsigned int MAX_TEXELS_PER_BLOCK { 216 };\n-static const unsigned int MAX_KMEANS_TEXELS { 64 };\n+static constexpr unsigned int MAX_TEXELS_PER_BLOCK { 216 };\n+static constexpr unsigned int MAX_KMEANS_TEXELS { 64 };\n-static const unsigned int MAX_WEIGHTS_PER_BLOCK { 64 };\n-static const unsigned int MIN_WEIGHT_BITS_PER_BLOCK { 24 };\n-static const unsigned int MAX_WEIGHT_BITS_PER_BLOCK { 96 };\n+static constexpr unsigned int MAX_WEIGHTS_PER_BLOCK { 64 };\n+static constexpr unsigned int MIN_WEIGHT_BITS_PER_BLOCK { 24 };\n+static constexpr unsigned int MAX_WEIGHT_BITS_PER_BLOCK { 96 };\n-static const unsigned int PLANE2_WEIGHTS_OFFSET { MAX_WEIGHTS_PER_BLOCK / 2 };\n-static const unsigned int PARTITION_BITS { 10 };\n-static const unsigned int PARTITION_COUNT { 1024 };\n+static constexpr unsigned int PLANE2_WEIGHTS_OFFSET { MAX_WEIGHTS_PER_BLOCK / 2 };\n+static constexpr unsigned int PARTITION_BITS { 10 };\n+static constexpr unsigned int PARTITION_COUNT { 1024 };\n// the sum of weights for one texel.\n-#define TEXEL_WEIGHT_SUM 16\n-#define MAX_DECIMATION_MODES 87\n-#define MAX_WEIGHT_MODES 2048\n+static constexpr float TEXEL_WEIGHT_SUM { 16.0f };\n+static constexpr unsigned int MAX_DECIMATION_MODES { 87 };\n+static constexpr unsigned int MAX_WEIGHT_MODES { 2048 };\nstatic_assert((MAX_TEXELS_PER_BLOCK % ASTCENC_SIMD_WIDTH) == 0,\n\"MAX_TEXELS_PER_BLOCK must be multiple of ASTCENC_SIMD_WIDTH\");\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
More use of unsigned types
|
61,745 |
22.05.2021 15:34:29
| -3,600 |
07f9604653a2d3e254fa2a91ae9c95424ab1fd82
|
Consolidate a block_type field
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -486,11 +486,11 @@ static float compress_symbolic_block_for_partition_1plane(\nworkscb.partition_index = partition_index;\nworkscb.color_quant_level = workscb.color_formats_matched ? color_quant_level_mod[i] : color_quant_level[i];\nworkscb.block_mode = qw_bm.mode_index;\n- workscb.error_block = 0;\n+ workscb.block_type = SYM_BTYPE_NONCONST;\nif (workscb.color_quant_level < 4)\n{\n- workscb.error_block = 1; // Should never happen ...\n+ workscb.block_type = SYM_BTYPE_ERROR;\n}\n// Pre-realign test\n@@ -500,10 +500,9 @@ static float compress_symbolic_block_for_partition_1plane(\nif (errorval == -1e30f)\n{\nerrorval = -errorval;\n- workscb.error_block = 1;\n+ workscb.block_type = SYM_BTYPE_ERROR;\n}\n-\ntrace_add_data(\"error_prerealign\", errorval);\nbest_errorval_in_mode = astc::min(errorval, best_errorval_in_mode);\n@@ -541,7 +540,7 @@ static float compress_symbolic_block_for_partition_1plane(\nif (errorval == -1e30f)\n{\nerrorval = -errorval;\n- workscb.error_block = 1;\n+ workscb.block_type = SYM_BTYPE_ERROR;\n}\ntrace_add_data(\"error_postrealign\", errorval);\n@@ -890,11 +889,11 @@ static float compress_symbolic_block_for_partition_2planes(\nworkscb.color_quant_level = workscb.color_formats_matched ? color_quant_level_mod[i] : color_quant_level[i];\nworkscb.block_mode = qw_bm.mode_index;\nworkscb.plane2_component = plane2_component;\n- workscb.error_block = 0;\n+ workscb.block_type = SYM_BTYPE_NONCONST;\nif (workscb.color_quant_level < 4)\n{\n- workscb.error_block = 1; // Should never happen ...\n+ workscb.block_type = SYM_BTYPE_ERROR;\n}\n// Pre-realign test\n@@ -904,10 +903,9 @@ static float compress_symbolic_block_for_partition_2planes(\nif (errorval == -1e30f)\n{\nerrorval = -errorval;\n- workscb.error_block = 1;\n+ workscb.block_type = SYM_BTYPE_ERROR;\n}\n-\ntrace_add_data(\"error_prerealign\", errorval);\nbest_errorval_in_mode = astc::min(errorval, best_errorval_in_mode);\n@@ -945,7 +943,7 @@ static float compress_symbolic_block_for_partition_2planes(\nif (errorval == -1e30f)\n{\nerrorval = -errorval;\n- workscb.error_block = 1;\n+ workscb.block_type = SYM_BTYPE_ERROR;\n}\ntrace_add_data(\"error_postrealign\", errorval);\n@@ -1435,21 +1433,20 @@ void compress_block(\ntrace_add_data(\"partition_count\", 0);\ntrace_add_data(\"plane_count\", 1);\n- scb.error_block = 0;\nscb.partition_count = 0;\n// Encode as FP16 if using HDR\nif ((decode_mode == ASTCENC_PRF_HDR) ||\n(decode_mode == ASTCENC_PRF_HDR_RGB_LDR_A))\n{\n- scb.block_mode = -1;\n+ scb.block_type = SYM_BTYPE_CONST_F16;\nvint4 color_f16 = float_to_float16(blk.origin_texel);\nstore(color_f16, scb.constant_color);\n}\n// Encode as UNORM16 if NOT using HDR\nelse\n{\n- scb.block_mode = -2;\n+ scb.block_type = SYM_BTYPE_CONST_U16;\nvfloat4 color_f32 = clamp(0.0f, 1.0f, blk.origin_texel) * 65535.0f;\nvint4 color_u16 = float_to_int_rtn(color_f32);\nstore(color_u16, scb.constant_color);\n@@ -1471,7 +1468,7 @@ void compress_block(\n// Set SCB and mode errors to a very high error value\nscb.errorval = 1e30f;\n- scb.error_block = 1;\n+ scb.block_type = SYM_BTYPE_ERROR;\nfloat best_errorvals_in_modes[MODE_COUNT];\nfor (int i = 0; i < MODE_COUNT; i++)\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_decompress_symbolic.cpp",
"new_path": "Source/astcenc_decompress_symbolic.cpp",
"diff": "@@ -191,7 +191,7 @@ void decompress_symbolic_block(\nblk.grayscale = false;\n// If we detected an error-block, blow up immediately.\n- if (scb.error_block)\n+ if (scb.block_type == SYM_BTYPE_ERROR)\n{\nfor (unsigned int i = 0; i < bsd.texel_count; i++)\n{\n@@ -206,12 +206,14 @@ void decompress_symbolic_block(\nreturn;\n}\n- if (scb.block_mode < 0)\n+ if ((scb.block_type == SYM_BTYPE_CONST_F16) ||\n+ (scb.block_type == SYM_BTYPE_CONST_U16))\n{\nvfloat4 color;\nint use_lns = 0;\n- if (scb.block_mode == -2)\n+ // UNORM16 constant color block\n+ if (scb.block_type == SYM_BTYPE_CONST_U16)\n{\nvint4 colori(scb.constant_color);\n@@ -225,6 +227,7 @@ void decompress_symbolic_block(\nvint4 colorf16 = unorm16_to_sf16(colori);\ncolor = float16_to_float(colorf16);\n}\n+ // FLOAT16 constant color block\nelse\n{\nswitch (decode_mode)\n@@ -329,7 +332,7 @@ float compute_symbolic_block_difference(\nconst error_weight_block& ewb\n) {\n// If we detected an error-block, blow up immediately.\n- if (scb.error_block)\n+ if (scb.block_type == SYM_BTYPE_ERROR)\n{\nreturn 1e29f;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -1210,15 +1210,16 @@ astcenc_error astcenc_get_block_info(\ninfo->block_z = ctx->config.block_z;\ninfo->texel_count = bsd.texel_count;\n- // Check for error blocks first - block_mode will be negative\n- info->is_error_block = scb.error_block != 0;\n+ // Check for error blocks first\n+ info->is_error_block = scb.block_type == SYM_BTYPE_ERROR;\nif (info->is_error_block)\n{\nreturn ASTCENC_SUCCESS;\n}\n- // Check for constant color blocks second - block_mode will be negative\n- info->is_constant_block = scb.block_mode < 0;\n+ // Check for constant color blocks second\n+ info->is_constant_block = scb.block_type == SYM_BTYPE_CONST_F16 ||\n+ scb.block_type == SYM_BTYPE_CONST_U16;\nif (info->is_constant_block)\n{\nreturn ASTCENC_SUCCESS;\n@@ -1249,7 +1250,7 @@ astcenc_error astcenc_get_block_info(\ninfo->weight_level_count = get_quant_method_levels(bm.get_quant_mode());\n// Unpack color endpoints for each active partition\n- for (int i = 0; i < scb.partition_count; i++)\n+ for (unsigned int i = 0; i < scb.partition_count; i++)\n{\nbool rgb_hdr;\nbool a_hdr;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -92,18 +92,18 @@ static_assert((MAX_WEIGHT_MODES % ASTCENC_SIMD_WIDTH) == 0,\n\"MAX_WEIGHT_MODES must be multiple of ASTCENC_SIMD_WIDTH\");\n// A high default error value\n-static const float ERROR_CALC_DEFAULT { 1e30f };\n+static constexpr float ERROR_CALC_DEFAULT { 1e30f };\n/* ============================================================================\nCompile-time tuning parameters\n============================================================================ */\n// The max texel count in a block which can try the one partition fast path.\n// Default: enabled for 4x4 and 5x4 blocks.\n-static const unsigned int TUNE_MAX_TEXELS_MODE0_FASTPATH { 24 };\n+static constexpr unsigned int TUNE_MAX_TEXELS_MODE0_FASTPATH { 24 };\n// The maximum number of candidate encodings returned for each encoding mode.\n// Default: depends on quality preset\n-static const unsigned int TUNE_MAX_TRIAL_CANDIDATES { 4 };\n+static constexpr unsigned int TUNE_MAX_TRIAL_CANDIDATES { 4 };\n/* ============================================================================\nParallel execution control\n@@ -451,7 +451,6 @@ struct partition_info\n*/\nstruct decimation_info\n{\n- // TODO: Make these byte values\nuint8_t texel_count;\nuint8_t weight_count;\nuint8_t weight_x;\n@@ -710,12 +709,18 @@ struct quantization_and_transfer_table\nextern const quantization_and_transfer_table quant_and_xfer_tables[12];\n+static constexpr unsigned int SYM_BTYPE_ERROR { 0 };\n+static constexpr unsigned int SYM_BTYPE_CONST_F16 { 1 };\n+static constexpr unsigned int SYM_BTYPE_CONST_U16 { 2 };\n+static constexpr unsigned int SYM_BTYPE_NONCONST { 3 };\n+\nstruct symbolic_compressed_block\n{\n- int error_block; // 1 marks error block, 0 marks non-error-block.\n- int block_mode; // 0 to 2047. Negative value marks constant-color block (-1: FP16, -2:UINT16)\n- int partition_count; // 1 to 4; Zero marks a constant-color block.\n- int partition_index; // 0 to 1023\n+ unsigned int block_type;\n+ unsigned int block_mode;\n+ unsigned int partition_count;\n+ unsigned int partition_index;\n+\nint color_formats[4]; // color format for each endpoint color pair.\nint color_formats_matched; // color format for all endpoint pairs are matched.\nint color_quant_level;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_symbolic_physical.cpp",
"new_path": "Source/astcenc_symbolic_physical.cpp",
"diff": "@@ -101,12 +101,10 @@ void symbolic_to_physical(\nconst symbolic_compressed_block& scb,\nphysical_compressed_block& pcb\n) {\n- if (scb.block_mode == -2)\n+ // Constant color block using UNORM16 colors\n+ if (scb.block_type == SYM_BTYPE_CONST_U16)\n{\n- // UNORM16 constant-color block.\n- // This encodes separate constant-color blocks. There is currently\n- // no attempt to coalesce them into larger void-extents.\n-\n+ // There is currently no attempt to coalesce larger void-extents\nstatic const uint8_t cbytes[8] { 0xFC, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };\nfor (int i = 0; i < 8; i++)\n{\n@@ -122,12 +120,10 @@ void symbolic_to_physical(\nreturn;\n}\n- if (scb.block_mode == -1)\n+ // Constant color block using FP16 colors\n+ if (scb.block_type == SYM_BTYPE_CONST_F16)\n{\n- // FP16 constant-color block.\n- // This encodes separate constant-color blocks. There is currently\n- // no attempt to coalesce them into larger void-extents.\n-\n+ // There is currently no attempt to coalesce larger void-extents\nstatic const uint8_t cbytes[8] { 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };\nfor (int i = 0; i < 8; i++)\n{\n@@ -258,7 +254,7 @@ void symbolic_to_physical(\n// Encode the color components\nuint8_t values_to_encode[32];\nint valuecount_to_encode = 0;\n- for (int i = 0; i < scb.partition_count; i++)\n+ for (unsigned int i = 0; i < scb.partition_count; i++)\n{\nint vals = 2 * (scb.color_formats[i] >> 2) + 2;\nassert(vals <= 8);\n@@ -280,7 +276,7 @@ void physical_to_symbolic(\n) {\nuint8_t bswapped[16];\n- scb.error_block = 0;\n+ scb.block_type = SYM_BTYPE_NONCONST;\n// Fetch the decimation tables\nconst decimation_info *const *dt = bsd.decimation_tables;\n@@ -294,11 +290,11 @@ void physical_to_symbolic(\n// Check what format the data has\nif (block_mode & 0x200)\n{\n- scb.block_mode = -1; // floating-point\n+ scb.block_type = SYM_BTYPE_CONST_F16;\n}\nelse\n{\n- scb.block_mode = -2; // unorm16.\n+ scb.block_type = SYM_BTYPE_CONST_U16;\n}\nscb.partition_count = 0;\n@@ -314,7 +310,7 @@ void physical_to_symbolic(\nint rsvbits = read_bits(2, 10, pcb.data);\nif (rsvbits != 3)\n{\n- scb.error_block = 1;\n+ scb.block_type = SYM_BTYPE_ERROR;\n}\nint vx_low_s = read_bits(8, 12, pcb.data) | (read_bits(5, 12 + 8, pcb.data) << 8);\n@@ -326,7 +322,7 @@ void physical_to_symbolic(\nif ((vx_low_s >= vx_high_s || vx_low_t >= vx_high_t) && !all_ones)\n{\n- scb.error_block = 1;\n+ scb.block_type = SYM_BTYPE_ERROR;\n}\n}\nelse\n@@ -343,7 +339,7 @@ void physical_to_symbolic(\nif ((vx_low_s >= vx_high_s || vx_low_t >= vx_high_t || vx_low_p >= vx_high_p) && !all_ones)\n{\n- scb.error_block = 1;\n+ scb.block_type = SYM_BTYPE_ERROR;\n}\n}\n@@ -353,7 +349,7 @@ void physical_to_symbolic(\nconst int packed_index = bsd.block_mode_packed_index[block_mode];\nif (packed_index < 0)\n{\n- scb.error_block = 1;\n+ scb.block_type = SYM_BTYPE_ERROR;\nreturn;\n}\nassert(packed_index >= 0 && packed_index < bsd.block_mode_count);\n@@ -396,7 +392,7 @@ void physical_to_symbolic(\nif (is_dual_plane && partition_count == 4)\n{\n- scb.error_block = 1;\n+ scb.block_type = SYM_BTYPE_ERROR;\n}\nscb.color_formats_matched = 0;\n@@ -461,7 +457,7 @@ void physical_to_symbolic(\nif (color_integer_count > 18)\n{\n- scb.error_block = 1;\n+ scb.block_type = SYM_BTYPE_ERROR;\n}\n// Determine the color endpoint format to use\n@@ -481,7 +477,7 @@ void physical_to_symbolic(\nscb.color_quant_level = color_quant_level;\nif (color_quant_level < 4)\n{\n- scb.error_block = 1;\n+ scb.block_type = SYM_BTYPE_ERROR;\n}\n// Unpack the integer color values and assign to endpoints\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Consolidate a block_type field
|
61,745 |
22.05.2021 15:38:43
| -3,600 |
6268c029afc689e52dd6e91b436a7893575349e8
|
Use uint8_t storage for quant color
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_color_quantize.cpp",
"new_path": "Source/astcenc_color_quantize.cpp",
"diff": "@@ -73,7 +73,7 @@ static inline int quant_color(\nstatic void quantize_rgb(\nvfloat4 color0,\nvfloat4 color1,\n- int output[6],\n+ uint8_t output[6],\nquant_method quant_level\n) {\nfloat scale = 1.0f / 257.0f;\n@@ -136,7 +136,7 @@ static void quantize_rgb(\nstatic void quantize_rgba(\nvfloat4 color0,\nvfloat4 color1,\n- int output[8],\n+ uint8_t output[8],\nquant_method quant_level\n) {\nfloat scale = 1.0f / 257.0f;\n@@ -168,7 +168,7 @@ static void quantize_rgba(\nstatic bool try_quantize_rgb_blue_contract(\nvfloat4 color0,\nvfloat4 color1,\n- int output[6],\n+ uint8_t output[6],\nquant_method quant_level\n) {\nfloat scale = 1.0f / 257.0f;\n@@ -243,7 +243,7 @@ static bool try_quantize_rgb_blue_contract(\nstatic int try_quantize_rgba_blue_contract(\nvfloat4 color0,\nvfloat4 color1,\n- int output[8],\n+ uint8_t output[8],\nquant_method quant_level\n) {\nfloat scale = 1.0f / 257.0f;\n@@ -274,7 +274,7 @@ static int try_quantize_rgba_blue_contract(\nstatic bool try_quantize_rgb_delta(\nvfloat4 color0,\nvfloat4 color1,\n- int output[6],\n+ uint8_t output[6],\nquant_method quant_level\n) {\nfloat scale = 1.0f / 257.0f;\n@@ -404,7 +404,7 @@ static bool try_quantize_rgb_delta(\nstatic bool try_quantize_rgb_delta_blue_contract(\nvfloat4 color0,\nvfloat4 color1,\n- int output[6],\n+ uint8_t output[6],\nquant_method quant_level\n) {\n// Note: Switch around endpoint colors already at start\n@@ -565,7 +565,7 @@ static bool try_quantize_rgb_delta_blue_contract(\nstatic bool try_quantize_alpha_delta(\nvfloat4 color0,\nvfloat4 color1,\n- int output[8],\n+ uint8_t output[8],\nquant_method quant_level\n) {\nfloat scale = 1.0f / 257.0f;\n@@ -628,7 +628,7 @@ static bool try_quantize_alpha_delta(\nstatic bool try_quantize_luminance_alpha_delta(\nvfloat4 color0,\nvfloat4 color1,\n- int output[4],\n+ uint8_t output[4],\nquant_method quant_level\n) {\nfloat scale = 1.0f / 257.0f;\n@@ -729,7 +729,7 @@ static bool try_quantize_luminance_alpha_delta(\nstatic bool try_quantize_rgba_delta(\nvfloat4 color0,\nvfloat4 color1,\n- int output[8],\n+ uint8_t output[8],\nquant_method quant_level\n) {\nreturn try_quantize_rgb_delta(color0, color1, output, quant_level) &&\n@@ -756,7 +756,7 @@ static bool try_quantize_rgba_delta(\nstatic bool try_quantize_rgba_delta_blue_contract(\nvfloat4 color0,\nvfloat4 color1,\n- int output[8],\n+ uint8_t output[8],\nquant_method quant_level\n) {\n// Note that we swap the color0 and color1 ordering for alpha to match RGB blue-contract\n@@ -773,7 +773,7 @@ static bool try_quantize_rgba_delta_blue_contract(\n*/\nstatic void quantize_rgbs(\nvfloat4 color,\n- int output[4],\n+ uint8_t output[4],\nquant_method quant_level\n) {\nfloat scale = 1.0f / 257.0f;\n@@ -814,7 +814,7 @@ static void quantize_rgbs_alpha(\nvfloat4 color0,\nvfloat4 color1,\nvfloat4 color,\n- int output[6],\n+ uint8_t output[6],\nquant_method quant_level\n) {\nfloat scale = 1.0f / 257.0f;\n@@ -842,7 +842,7 @@ static void quantize_rgbs_alpha(\nstatic void quantize_luminance(\nvfloat4 color0,\nvfloat4 color1,\n- int output[2],\n+ uint8_t output[2],\nquant_method quant_level\n) {\nfloat scale = 1.0f / 257.0f;\n@@ -875,7 +875,7 @@ static void quantize_luminance(\nstatic void quantize_luminance_alpha(\nvfloat4 color0,\nvfloat4 color1,\n- int output[4],\n+ uint8_t output[4],\nquant_method quant_level\n) {\nfloat scale = 1.0f / 257.0f;\n@@ -941,13 +941,13 @@ static void quantize_luminance_alpha(\n*/\nstatic inline void quantize_and_unquantize_retain_top_two_bits(\nquant_method quant_level,\n- int value,\n- int& quant_value,\n- int& unquant_value\n+ uint8_t value,\n+ uint8_t& quant_value,\n+ uint8_t& unquant_value\n) {\nint perform_loop;\n- int quantval;\n- int uquantval;\n+ uint8_t quantval;\n+ uint8_t uquantval;\ndo\n{\n@@ -985,13 +985,13 @@ static inline void quantize_and_unquantize_retain_top_two_bits(\n*/\nstatic inline void quantize_and_unquantize_retain_top_four_bits(\nquant_method quant_level,\n- int value,\n- int& quant_value,\n- int& unquant_value\n+ uint8_t value,\n+ uint8_t& quant_value,\n+ uint8_t& unquant_value\n) {\n- int perform_loop;\n- int quantval;\n- int uquantval;\n+ uint8_t perform_loop;\n+ uint8_t quantval;\n+ uint8_t uquantval;\ndo\n{\n@@ -1028,7 +1028,7 @@ static inline void quantize_and_unquantize_retain_top_four_bits(\n*/\nstatic void quantize_hdr_rgbo(\nvfloat4 color,\n- int output[4],\n+ uint8_t output[4],\nquant_method quant_level\n) {\ncolor.set_lane<0>(color.lane<0>() + color.lane<3>());\n@@ -1119,8 +1119,8 @@ static void quantize_hdr_rgbo(\nr_lowbits |= (mode_enc & 3) << 6;\n- int r_quantval;\n- int r_uquantval;\n+ uint8_t r_quantval;\n+ uint8_t r_uquantval;\nquantize_and_unquantize_retain_top_two_bits(quant_level, r_lowbits, r_quantval, r_uquantval);\nr_intval = (r_intval & ~0x3f) | (r_uquantval & 0x3f);\n@@ -1217,10 +1217,10 @@ static void quantize_hdr_rgbo(\nb_lowbits |= bit2 << 6;\nb_lowbits |= bit3 << 5;\n- int g_quantval;\n- int b_quantval;\n- int g_uquantval;\n- int b_uquantval;\n+ uint8_t g_quantval;\n+ uint8_t b_quantval;\n+ uint8_t g_uquantval;\n+ uint8_t b_uquantval;\nquantize_and_unquantize_retain_top_four_bits(quant_level, g_lowbits, g_quantval, g_uquantval);\nquantize_and_unquantize_retain_top_four_bits(quant_level, b_lowbits, b_quantval, b_uquantval);\n@@ -1289,8 +1289,8 @@ static void quantize_hdr_rgbo(\ns_lowbits |= bit5 << 6;\ns_lowbits |= bit4 << 7;\n- int s_quantval;\n- int s_uquantval;\n+ uint8_t s_quantval;\n+ uint8_t s_uquantval;\nquantize_and_unquantize_retain_top_four_bits(quant_level, s_lowbits, s_quantval, s_uquantval);\noutput[0] = r_quantval;\n@@ -1329,9 +1329,9 @@ static void quantize_hdr_rgbo(\nencvals[2] = (ivals[2] & 0x7f) | 0x80;\nencvals[3] = (ivals[3] & 0x7f) | ((ivals[0] & 0x40) << 1);\n- for (int i = 0; i < 4; i++)\n+ for (uint8_t i = 0; i < 4; i++)\n{\n- int dummy;\n+ uint8_t dummy;\nquantize_and_unquantize_retain_top_four_bits(quant_level, encvals[i], output[i], dummy);\n}\n@@ -1349,7 +1349,7 @@ static void quantize_hdr_rgbo(\nstatic void quantize_hdr_rgb(\nvfloat4 color0,\nvfloat4 color1,\n- int output[6],\n+ uint8_t output[6],\nquant_method quant_level\n) {\n// Note: color*.lane<3> is not used so we can ignore it\n@@ -1492,8 +1492,8 @@ static void quantize_hdr_rgb(\nc_lowbits |= (mode & 1) << 7;\nc_lowbits |= (a_intval & 0x100) >> 2;\n- int c_quantval;\n- int c_uquantval;\n+ uint8_t c_quantval;\n+ uint8_t c_uquantval;\nquantize_and_unquantize_retain_top_two_bits(quant_level, c_lowbits, c_quantval, c_uquantval);\nc_intval = (c_intval & ~0x3F) | (c_uquantval & 0x3F);\nc_fval = static_cast<float>(c_intval) * mode_rscale;\n@@ -1557,10 +1557,10 @@ static void quantize_hdr_rgb(\nb0_lowbits |= ((mode >> 1) & 1) << 7;\nb1_lowbits |= ((mode >> 2) & 1) << 7;\n- int b0_quantval;\n- int b1_quantval;\n- int b0_uquantval;\n- int b1_uquantval;\n+ uint8_t b0_quantval;\n+ uint8_t b1_quantval;\n+ uint8_t b0_uquantval;\n+ uint8_t b1_uquantval;\nquantize_and_unquantize_retain_top_two_bits(quant_level, b0_lowbits, b0_quantval, b0_uquantval);\nquantize_and_unquantize_retain_top_two_bits(quant_level, b1_lowbits, b1_quantval, b1_uquantval);\n@@ -1652,10 +1652,10 @@ static void quantize_hdr_rgb(\nd0_lowbits |= (majcomp & 1) << 7;\nd1_lowbits |= ((majcomp >> 1) & 1) << 7;\n- int d0_quantval;\n- int d1_quantval;\n- int d0_uquantval;\n- int d1_uquantval;\n+ uint8_t d0_quantval;\n+ uint8_t d1_quantval;\n+ uint8_t d0_uquantval;\n+ uint8_t d1_uquantval;\nquantize_and_unquantize_retain_top_four_bits(quant_level, d0_lowbits, d0_quantval, d0_uquantval);\nquantize_and_unquantize_retain_top_four_bits(quant_level, d1_lowbits, d1_quantval, d1_uquantval);\n@@ -1694,9 +1694,9 @@ static void quantize_hdr_rgb(\nfor (int i = 4; i < 6; i++)\n{\n- int dummy;\n+ uint8_t dummy;\nint idx = astc::flt2int_rtn(vals[i] * 1.0f / 512.0f) + 128;\n- quantize_and_unquantize_retain_top_two_bits(quant_level, idx, (output[i]), dummy);\n+ quantize_and_unquantize_retain_top_two_bits(quant_level, idx, output[i], dummy);\n}\nreturn;\n@@ -1713,7 +1713,7 @@ static void quantize_hdr_rgb(\nstatic void quantize_hdr_rgb_ldr_alpha(\nvfloat4 color0,\nvfloat4 color1,\n- int output[8],\n+ uint8_t output[8],\nquant_method quant_level\n) {\nfloat scale = 1.0f / 257.0f;\n@@ -1741,7 +1741,7 @@ static void quantize_hdr_rgb_ldr_alpha(\nstatic void quantize_hdr_luminance_large_range(\nvfloat4 color0,\nvfloat4 color1,\n- int output[2],\n+ uint8_t output[2],\nquant_method quant_level\n) {\nfloat lum0 = hadd_rgb_s(color0) * (1.0f / 3.0f);\n@@ -1815,7 +1815,7 @@ static void quantize_hdr_luminance_large_range(\nstatic bool try_quantize_hdr_luminance_small_range(\nvfloat4 color0,\nvfloat4 color1,\n- int output[2],\n+ uint8_t output[2],\nquant_method quant_level\n) {\nfloat lum0 = hadd_rgb_s(color0) * (1.0f / 3.0f);\n@@ -1917,7 +1917,7 @@ static bool try_quantize_hdr_luminance_small_range(\nstatic void quantize_hdr_alpha(\nfloat alpha0,\nfloat alpha1,\n- int output[2],\n+ uint8_t output[2],\nquant_method quant_level\n) {\nalpha0 = astc::clamp(alpha0, 0.0f, 65280.0f);\n@@ -1997,7 +1997,7 @@ static void quantize_hdr_alpha(\nstatic void quantize_hdr_rgb_alpha(\nvfloat4 color0,\nvfloat4 color1,\n- int output[8],\n+ uint8_t output[8],\nquant_method quant_level\n) {\nquantize_hdr_rgb(color0, color1, output, quant_level);\n@@ -2011,7 +2011,7 @@ int pack_color_endpoints(\nvfloat4 rgbs_color,\nvfloat4 rgbo_color,\nint format,\n- int* output,\n+ uint8_t* output,\nquant_method quant_level\n) {\nassert(quant_level < 21);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_color_unquantize.cpp",
"new_path": "Source/astcenc_color_unquantize.cpp",
"diff": "* @return The unquantized color.\n*/\nstatic ASTCENC_SIMD_INLINE vint4 unquant_color(\n- int quant_level,\n+ quant_method quant_level,\nvint4 inputq\n) {\nconst uint8_t* unq = color_unquant_tables[quant_level];\n@@ -72,7 +72,7 @@ static ASTCENC_SIMD_INLINE vint4 uncontract_color(\nstatic void rgba_delta_unpack(\nvint4 input0q,\nvint4 input1q,\n- int quant_level,\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -118,7 +118,7 @@ static void rgba_delta_unpack(\nstatic void rgb_delta_unpack(\nvint4 input0q,\nvint4 input1q,\n- int quant_level,\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -139,7 +139,7 @@ static void rgb_delta_unpack(\nstatic void rgba_unpack(\nvint4 input0q,\nvint4 input1q,\n- int quant_level,\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -173,7 +173,7 @@ static void rgba_unpack(\nstatic void rgb_unpack(\nvint4 input0q,\nvint4 input1q,\n- int quant_level,\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -196,16 +196,16 @@ static void rgb_unpack(\n*/\nstatic void rgb_scale_alpha_unpack(\nvint4 input0q,\n- int alpha1q,\n- int scaleq,\n- int quant_level,\n+ uint8_t alpha1q,\n+ uint8_t scaleq,\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n// Unquantize color endpoints\nvint4 input = unquant_color(quant_level, input0q);\n- int alpha1 = color_unquant_tables[quant_level][alpha1q];\n- int scale = color_unquant_tables[quant_level][scaleq];\n+ uint8_t alpha1 = color_unquant_tables[quant_level][alpha1q];\n+ uint8_t scale = color_unquant_tables[quant_level][scaleq];\noutput1 = input;\noutput1.set_lane<3>(alpha1);\n@@ -228,7 +228,7 @@ static void rgb_scale_alpha_unpack(\nstatic void rgb_scale_unpack(\nvint4 input0q,\nint scaleq,\n- int quant_level,\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -253,8 +253,8 @@ static void rgb_scale_unpack(\n* @param[out] output1 The unpacked and unquantized endpoint 1 color.\n*/\nstatic void luminance_unpack(\n- const int input[2],\n- int quant_level,\n+ const uint8_t input[2],\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -275,8 +275,8 @@ static void luminance_unpack(\n* @param[out] output1 The unpacked and unquantized endpoint 1 color.\n*/\nstatic void luminance_delta_unpack(\n- const int input[2],\n- int quant_level,\n+ const uint8_t input[2],\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -300,8 +300,8 @@ static void luminance_delta_unpack(\n* @param[out] output1 The unpacked and unquantized endpoint 1 color.\n*/\nstatic void luminance_alpha_unpack(\n- const int input[4],\n- int quant_level,\n+ const uint8_t input[4],\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -322,8 +322,8 @@ static void luminance_alpha_unpack(\n* @param[out] output1 The unpacked and unquantized endpoint 1 color.\n*/\nstatic void luminance_alpha_delta_unpack(\n- const int input[4],\n- int quant_level,\n+ const uint8_t input[4],\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -364,8 +364,8 @@ static void luminance_alpha_delta_unpack(\n* @param[out] output1 The unpacked and unquantized endpoint 1 color.\n*/\nstatic void hdr_rgbo_unpack(\n- const int input[4],\n- int quant_level,\n+ const uint8_t input[4],\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -516,8 +516,8 @@ static void hdr_rgbo_unpack(\n* @param[out] output1 The unpacked and unquantized endpoint 1 color.\n*/\nstatic void hdr_rgb_unpack(\n- const int input[6],\n- int quant_level,\n+ const uint8_t input[6],\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -684,8 +684,8 @@ static void hdr_rgb_unpack(\n* @param[out] output1 The unpacked and unquantized endpoint 1 color.\n*/\nstatic void hdr_rgb_ldr_alpha_unpack(\n- const int input[8],\n- int quant_level,\n+ const uint8_t input[8],\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -706,8 +706,8 @@ static void hdr_rgb_ldr_alpha_unpack(\n* @param[out] output1 The unpacked and unquantized endpoint 1 color.\n*/\nstatic void hdr_luminance_small_range_unpack(\n- const int input[2],\n- int quant_level,\n+ const uint8_t input[2],\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -743,8 +743,8 @@ static void hdr_luminance_small_range_unpack(\n* @param[out] output1 The unpacked and unquantized endpoint 1 color.\n*/\nstatic void hdr_luminance_large_range_unpack(\n- const int input[2],\n- int quant_level,\n+ const uint8_t input[2],\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -776,8 +776,8 @@ static void hdr_luminance_large_range_unpack(\n* @param[out] output1 The unpacked and unquantized endpoint 1 color.\n*/\nstatic void hdr_alpha_unpack(\n- const int input[2],\n- int quant_level,\n+ const uint8_t input[2],\n+ quant_method quant_level,\nint& output0,\nint& output1\n) {\n@@ -825,8 +825,8 @@ static void hdr_alpha_unpack(\n* @param[out] output1 The unpacked and unquantized endpoint 1 color.\n*/\nstatic void hdr_rgb_hdr_alpha_unpack(\n- const int input[8],\n- int quant_level,\n+ const uint8_t input[8],\n+ quant_method quant_level,\nvint4& output0,\nvint4& output1\n) {\n@@ -843,8 +843,8 @@ static void hdr_rgb_hdr_alpha_unpack(\nvoid unpack_color_endpoints(\nastcenc_profile decode_mode,\nint format,\n- int quant_level,\n- const int* input,\n+ quant_method quant_level,\n+ const uint8_t* input,\nbool& rgb_hdr,\nbool& alpha_hdr,\nvint4& output0,\n@@ -889,7 +889,7 @@ void unpack_color_endpoints(\ncase FMT_RGB_SCALE:\n{\nvint4 input0q(input[0], input[1], input[2], 0);\n- int scale = input[3];\n+ uint8_t scale = input[3];\nrgb_scale_unpack(input0q, scale, quant_level, output0, output1);\n}\nbreak;\n@@ -897,8 +897,8 @@ void unpack_color_endpoints(\ncase FMT_RGB_SCALE_ALPHA:\n{\nvint4 input0q(input[0], input[1], input[2], input[4]);\n- int alpha1q = input[5];\n- int scaleq = input[3];\n+ uint8_t alpha1q = input[5];\n+ uint8_t scaleq = input[3];\nrgb_scale_alpha_unpack(input0q, alpha1q, scaleq, quant_level, output0, output1);\n}\nbreak;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -365,9 +365,8 @@ static float compress_symbolic_block_for_partition_1plane(\nint partition_format_specifiers[TUNE_MAX_TRIAL_CANDIDATES][4];\nint block_mode_index[TUNE_MAX_TRIAL_CANDIDATES];\n- // TODO: Make these enums?\n- int color_quant_level[TUNE_MAX_TRIAL_CANDIDATES];\n- int color_quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\n+ quant_method color_quant_level[TUNE_MAX_TRIAL_CANDIDATES];\n+ quant_method color_quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\ncompute_ideal_endpoint_formats(\nbsd, *pt, blk, ewb, ei.ep, qwt_bitcounts, qwt_errors,\n@@ -450,7 +449,7 @@ static float compress_symbolic_block_for_partition_1plane(\n&& (partition_count == 2 || (workscb.color_formats[0] == workscb.color_formats[2]\n&& (partition_count == 3 || (workscb.color_formats[0] == workscb.color_formats[3])))))\n{\n- int colorvals[4][12];\n+ uint8_t colorvals[4][12];\nint color_formats_mod[4] { 0 };\nfor (int j = 0; j < partition_count; j++)\n{\n@@ -761,9 +760,8 @@ static float compress_symbolic_block_for_partition_2planes(\nint partition_format_specifiers[TUNE_MAX_TRIAL_CANDIDATES][4];\nint block_mode_index[TUNE_MAX_TRIAL_CANDIDATES];\n- // TODO: Make these enums?\n- int color_quant_level[TUNE_MAX_TRIAL_CANDIDATES];\n- int color_quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\n+ quant_method color_quant_level[TUNE_MAX_TRIAL_CANDIDATES];\n+ quant_method color_quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\nendpoints epm;\nmerge_endpoints(ei1.ep, ei2.ep, plane2_component, epm);\n@@ -852,7 +850,7 @@ static float compress_symbolic_block_for_partition_2planes(\n&& (partition_count == 2 || (workscb.color_formats[0] == workscb.color_formats[2]\n&& (partition_count == 3 || (workscb.color_formats[0] == workscb.color_formats[3])))))\n{\n- int colorvals[4][12];\n+ uint8_t colorvals[4][12];\nint color_formats_mod[4] { 0 };\nfor (int j = 0; j < partition_count; j++)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -606,6 +606,7 @@ struct imageblock\n}\n};\n+// TODO: Convert these to ib member functions\nstatic inline float imageblock_default_alpha(const imageblock * blk)\n{\nreturn blk->alpha_lns[0] ? (float)0x7800 : (float)0xFFFF;\n@@ -723,9 +724,9 @@ struct symbolic_compressed_block\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_quant_level;\n+ quant_method color_quant_level;\nint plane2_component; // color component for second plane of weights\n- int color_values[4][8]; // quantized endpoint color pairs.\n+ uint8_t color_values[4][8]; // 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@@ -1396,13 +1397,14 @@ float compute_error_of_weight_set_2planes(\n*\n* @return The actual endpoint mode used.\n*/\n+// TODO: Format as enum?\nint pack_color_endpoints(\nvfloat4 color0,\nvfloat4 color1,\nvfloat4 rgbs_color,\nvfloat4 rgbo_color,\nint format,\n- int* output,\n+ uint8_t* output,\nquant_method quant_level);\n/**\n@@ -1418,11 +1420,12 @@ int pack_color_endpoints(\n* @param[out] output0 The output color for endpoint 0.\n* @param[out] output1 The output color for endpoint 1.\n*/\n+// TODO: Format as enum?\nvoid unpack_color_endpoints(\nastcenc_profile decode_mode,\nint format,\n- int quant_level,\n- const int* input,\n+ quant_method quant_level,\n+ const uint8_t* input,\nbool& rgb_hdr,\nbool& alpha_hdr,\nvint4& output0,\n@@ -1511,11 +1514,11 @@ void compute_ideal_endpoint_formats(\nconst endpoints& ep,\nconst int* qwt_bitcounts,\nconst float* qwt_errors,\n- int tune_candidate_limit,\n+ unsigned int tune_candidate_limit,\nint partition_format_specifiers[TUNE_MAX_TRIAL_CANDIDATES][4],\nint block_mode[TUNE_MAX_TRIAL_CANDIDATES],\n- int quant_level[TUNE_MAX_TRIAL_CANDIDATES],\n- int quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES]);\n+ quant_method quant_level[TUNE_MAX_TRIAL_CANDIDATES],\n+ quant_method quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES]);\n/**\n* @brief For a given 1 plane weight set recompute the endpoint colors.\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"new_path": "Source/astcenc_pick_best_endpoint_format.cpp",
"diff": "@@ -677,7 +677,7 @@ static void one_partition_find_best_combination_for_bitcount(\nconst float best_combined_error[21][4],\nconst int best_combined_format[21][4],\nint bits_available,\n- int& best_quant_level,\n+ quant_method& best_quant_level,\nint& best_format,\nfloat& best_error\n) {\n@@ -705,7 +705,7 @@ static void one_partition_find_best_combination_for_bitcount(\nint ql = quant_mode_table[best_integer_count + 1][bits_available];\n- best_quant_level = ql;\n+ best_quant_level = (quant_method)ql;\nbest_format = FMT_LUMINANCE;\nbest_error = best_integer_count_error;\n@@ -778,8 +778,8 @@ static void two_partitions_find_best_combination_for_bitcount(\nfloat best_combined_error[21][7],\nint best_combined_format[21][7][2],\nint bits_available,\n- int& best_quant_level,\n- int& best_quant_level_mod,\n+ quant_method& best_quant_level,\n+ quant_method& best_quant_level_mod,\nint* best_formats,\nfloat& best_error\n) {\n@@ -808,8 +808,8 @@ static void two_partitions_find_best_combination_for_bitcount(\nint ql = quant_mode_table[best_integer_count][bits_available];\nint ql_mod = quant_mode_table[best_integer_count][bits_available + 2];\n- best_quant_level = ql;\n- best_quant_level_mod = ql_mod;\n+ best_quant_level = (quant_method)ql;\n+ best_quant_level_mod = (quant_method)ql_mod;\nbest_error = best_integer_count_error;\nif (ql >= 0)\n{\n@@ -901,8 +901,8 @@ static void three_partitions_find_best_combination_for_bitcount(\nconst float best_combined_error[21][10],\nconst int best_combined_format[21][10][3],\nint bits_available,\n- int& best_quant_level,\n- int& best_quant_level_mod,\n+ quant_method& best_quant_level,\n+ quant_method& best_quant_level_mod,\nint* best_formats,\nfloat& best_error\n) {\n@@ -931,8 +931,8 @@ static void three_partitions_find_best_combination_for_bitcount(\nint ql = quant_mode_table[best_integer_count][bits_available];\nint ql_mod = quant_mode_table[best_integer_count][bits_available + 5];\n- best_quant_level = ql;\n- best_quant_level_mod = ql_mod;\n+ best_quant_level = (quant_method)ql;\n+ best_quant_level_mod = (quant_method)ql_mod;\nbest_error = best_integer_count_error;\nif (ql >= 0)\n{\n@@ -1035,8 +1035,8 @@ static void four_partitions_find_best_combination_for_bitcount(\nconst float best_combined_error[21][13],\nconst int best_combined_format[21][13][4],\nint bits_available,\n- int& best_quant_level,\n- int& best_quant_level_mod,\n+ quant_method& best_quant_level,\n+ quant_method& best_quant_level_mod,\nint* best_formats,\nfloat& best_error\n) {\n@@ -1065,8 +1065,8 @@ static void four_partitions_find_best_combination_for_bitcount(\nint ql = quant_mode_table[best_integer_count][bits_available];\nint ql_mod = quant_mode_table[best_integer_count][bits_available + 8];\n- best_quant_level = ql;\n- best_quant_level_mod = ql_mod;\n+ best_quant_level = (quant_method)ql;\n+ best_quant_level_mod = (quant_method)ql_mod;\nbest_error = best_integer_count_error;\nif (ql >= 0)\n{\n@@ -1094,12 +1094,12 @@ void compute_ideal_endpoint_formats(\n// bitcounts and errors computed for the various quantization methods\nconst int* qwt_bitcounts,\nconst float* qwt_errors,\n- int tune_candidate_limit,\n+ unsigned int tune_candidate_limit,\n// output data\nint partition_format_specifiers[TUNE_MAX_TRIAL_CANDIDATES][4],\nint block_mode[TUNE_MAX_TRIAL_CANDIDATES],\n- int quant_level[TUNE_MAX_TRIAL_CANDIDATES],\n- int quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES]\n+ quant_method quant_level[TUNE_MAX_TRIAL_CANDIDATES],\n+ quant_method quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES]\n) {\nint partition_count = pi.partition_count;\n@@ -1130,8 +1130,8 @@ void compute_ideal_endpoint_formats(\n}\nalignas(ASTCENC_VECALIGN) float errors_of_best_combination[MAX_WEIGHT_MODES];\n- alignas(ASTCENC_VECALIGN) int best_quant_levels[MAX_WEIGHT_MODES];\n- int best_quant_levels_mod[MAX_WEIGHT_MODES];\n+ alignas(ASTCENC_VECALIGN) quant_method best_quant_levels[MAX_WEIGHT_MODES];\n+ quant_method best_quant_levels_mod[MAX_WEIGHT_MODES];\nint best_ep_formats[MAX_WEIGHT_MODES][4];\n// Ensure that the \"overstep\" of the last iteration in the vectorized loop will contain data\n@@ -1141,8 +1141,8 @@ void compute_ideal_endpoint_formats(\nfor (int i = packed_mode_count; i < packed_mode_count_simd_up; ++i)\n{\nerrors_of_best_combination[i] = 1e30f;\n- best_quant_levels[i] = 0;\n- best_quant_levels_mod[i] = 0;\n+ best_quant_levels[i] = QUANT_2;\n+ best_quant_levels_mod[i] = QUANT_2;\n}\n// The block contains 1 partition\n@@ -1248,7 +1248,7 @@ void compute_ideal_endpoint_formats(\n// Go through the results and pick the best candidate modes\nint best_error_weights[TUNE_MAX_TRIAL_CANDIDATES];\n- for (int i = 0; i < tune_candidate_limit; i++)\n+ for (unsigned int i = 0; i < tune_candidate_limit; i++)\n{\nvint vbest_error_index(-1);\nvfloat vbest_ep_error(1e30f);\n@@ -1257,7 +1257,7 @@ void compute_ideal_endpoint_formats(\n{\nvfloat err = vfloat(&errors_of_best_combination[j]);\nvmask mask1 = err < vbest_ep_error;\n- vmask mask2 = vint(&best_quant_levels[j]) > vint(4);\n+ vmask mask2 = vint((int*)(&best_quant_levels[j])) > vint(4);\nvmask mask = mask1 & mask2;\nvbest_ep_error = select(vbest_ep_error, err, mask);\nvbest_error_index = select(vbest_error_index, lane_ids, mask);\n@@ -1279,7 +1279,7 @@ void compute_ideal_endpoint_formats(\n}\n}\n- for (int i = 0; i < tune_candidate_limit; i++)\n+ for (unsigned int i = 0; i < tune_candidate_limit; i++)\n{\nblock_mode[i] = best_error_weights[i];\nif (block_mode[i] >= 0)\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_symbolic_physical.cpp",
"new_path": "Source/astcenc_symbolic_physical.cpp",
"diff": "@@ -474,7 +474,7 @@ void physical_to_symbolic(\n}\nint color_quant_level = quant_mode_table[color_integer_count >> 1][color_bits];\n- scb.color_quant_level = color_quant_level;\n+ scb.color_quant_level = (quant_method)color_quant_level;\nif (color_quant_level < 4)\n{\nscb.block_type = SYM_BTYPE_ERROR;\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use uint8_t storage for quant color
|
61,745 |
22.05.2021 16:01:57
| -3,600 |
01db996504c4ce09bef2ee4e040bbf12b0cad271
|
Repack symbolic_compressed_block
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -710,27 +710,67 @@ struct quantization_and_transfer_table\nextern const quantization_and_transfer_table quant_and_xfer_tables[12];\n+/** @brief The block is an error block, and will return error color or NaN. */\nstatic constexpr unsigned int SYM_BTYPE_ERROR { 0 };\n+\n+/** @brief The block is a constant color block using FP16 colors. */\nstatic constexpr unsigned int SYM_BTYPE_CONST_F16 { 1 };\n+\n+/** @brief The block is a constant color block using UNORM16 colors. */\nstatic constexpr unsigned int SYM_BTYPE_CONST_U16 { 2 };\n+\n+/** @brief The block is a normal non-constant color block. */\nstatic constexpr unsigned int SYM_BTYPE_NONCONST { 3 };\n+/**\n+ * @brief A symbolic representation of a compressed block.\n+ *\n+ * The symbolic representation stores the unpacked content of a single\n+ * @c physical_compressed_block, in a form which is much easier to access for\n+ * the rest of the compressor code.\n+ */\nstruct symbolic_compressed_block\n{\n- unsigned int block_type;\n- unsigned int block_mode;\n- unsigned int partition_count;\n- unsigned int partition_index;\n+ /** @brief The block type, one of the @c SYM_BTYPE_* constants. */\n+ uint8_t block_type;\n+\n+ /** @brief The number of partitions; valid for @c NONCONST blocks. */\n+ uint8_t partition_count;\n+\n+ /** @brief Non-zero if the color formats matched; valid for @c NONCONST blocks. */\n+ // TODO: Do we need to store this?\n+ uint8_t color_formats_matched;\n+\n+ /** @brief The plane 2 color component, or -1 if single plane; valid for @c NONCONST blocks. */\n+ int8_t plane2_component;\n- int color_formats[4]; // color format for each endpoint color pair.\n- int color_formats_matched; // color format for all endpoint pairs are matched.\n+ /** @brief The block mode; valid for @c NONCONST blocks. */\n+ uint16_t block_mode;\n+\n+ /** @brief The partition index; valid for @c NONCONST blocks if 2 or more partitions. */\n+ uint16_t partition_index;\n+\n+ /** @brief The endpoint color formats for each partition; valid for @c NONCONST blocks. */\n+ uint8_t color_formats[4];\n+\n+ /** @brief The endpoint color formats for each partition; valid for @c NONCONST blocks. */\nquant_method color_quant_level;\n- int plane2_component; // color component for second plane of weights\n- uint8_t color_values[4][8]; // quantized endpoint color pairs.\n- int 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- float errorval; // The error of the current encoding\n+\n+ /** @brief The error of the current encoding; valid for @c NONCONST blocks. */\n+ float errorval;\n+\n+ // We can't have both of these at the same time\n+ union {\n+ /** @brief The constant color; valid for @c CONST blocks. */\n+ int constant_color[4];\n+ /** @brief The quantized endpoint color pairs; valid for @c NONCONST blocks. */\n+ uint8_t color_values[4][8];\n+ };\n+\n+ /** @brief The quantized and decimated weights.\n+ *\n+ * If dual plane, the second plane starts at @c weights[PLANE2_WEIGHTS_OFFSET].\n+ */\nuint8_t weights[MAX_WEIGHTS_PER_BLOCK];\n};\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Repack symbolic_compressed_block
|
61,745 |
22.05.2021 17:26:32
| -3,600 |
9baed835109fbbfd8354b18107c05ebef98726b9
|
Use unsigned ints in block size calculations
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_block_sizes.cpp",
"new_path": "Source/astcenc_block_sizes.cpp",
"diff": "@@ -39,10 +39,10 @@ static bool decode_block_mode_2d(\nbool& is_dual_plane,\nunsigned int& quant_mode\n) {\n- int base_quant_mode = (block_mode >> 4) & 1;\n- int H = (block_mode >> 9) & 1;\n- int D = (block_mode >> 10) & 1;\n- int A = (block_mode >> 5) & 0x3;\n+ unsigned int base_quant_mode = (block_mode >> 4) & 1;\n+ unsigned int H = (block_mode >> 9) & 1;\n+ unsigned int D = (block_mode >> 10) & 1;\n+ unsigned int A = (block_mode >> 5) & 0x3;\nx_weights = 0;\ny_weights = 0;\n@@ -50,7 +50,7 @@ static bool decode_block_mode_2d(\nif ((block_mode & 3) != 0)\n{\nbase_quant_mode |= (block_mode & 3) << 1;\n- int B = (block_mode >> 7) & 3;\n+ unsigned int B = (block_mode >> 7) & 3;\nswitch ((block_mode >> 2) & 3)\n{\ncase 0:\n@@ -88,7 +88,7 @@ static bool decode_block_mode_2d(\nreturn false;\n}\n- int B = (block_mode >> 9) & 3;\n+ unsigned int B = (block_mode >> 9) & 3;\nswitch ((block_mode >> 7) & 3)\n{\ncase 0:\n@@ -154,10 +154,10 @@ static bool decode_block_mode_3d(\nbool& is_dual_plane,\nunsigned int& quant_mode\n) {\n- int base_quant_mode = (block_mode >> 4) & 1;\n- int H = (block_mode >> 9) & 1;\n- int D = (block_mode >> 10) & 1;\n- int A = (block_mode >> 5) & 0x3;\n+ unsigned int base_quant_mode = (block_mode >> 4) & 1;\n+ unsigned int H = (block_mode >> 9) & 1;\n+ unsigned int D = (block_mode >> 10) & 1;\n+ unsigned int A = (block_mode >> 5) & 0x3;\nx_weights = 0;\ny_weights = 0;\n@@ -166,8 +166,8 @@ static bool decode_block_mode_3d(\nif ((block_mode & 3) != 0)\n{\nbase_quant_mode |= (block_mode & 3) << 1;\n- int B = (block_mode >> 7) & 3;\n- int C = (block_mode >> 2) & 0x3;\n+ unsigned int B = (block_mode >> 7) & 3;\n+ unsigned int C = (block_mode >> 2) & 0x3;\nx_weights = A + 2;\ny_weights = B + 2;\nz_weights = C + 2;\n@@ -261,7 +261,12 @@ static void init_decimation_info_2d(\nuint8_t texel_count_of_weight[BLOCK_MAX_WEIGHTS];\nuint8_t max_texel_count_of_weight = 0;\nuint8_t texels_of_weight[BLOCK_MAX_WEIGHTS][BLOCK_MAX_TEXELS];\n- int texel_weights_of_weight[BLOCK_MAX_WEIGHTS][BLOCK_MAX_TEXELS];\n+ uint8_t texel_weights_of_weight[BLOCK_MAX_WEIGHTS][BLOCK_MAX_TEXELS];\n+\n+ promise(weights_per_block > 0);\n+ promise(texels_per_block > 0);\n+ promise(x_texels > 0);\n+ promise(y_texels > 0);\nfor (unsigned int i = 0; i < weights_per_block; i++)\n{\n@@ -322,7 +327,7 @@ static void init_decimation_info_2d(\n{\ndi.texel_weight_count[i] = weight_count_of_texel[i];\n- for (int j = 0; j < weight_count_of_texel[i]; j++)\n+ for (unsigned int j = 0; j < weight_count_of_texel[i]; j++)\n{\ndi.texel_weights_int_4t[j][i] = weights_of_texel[i][j];\ndi.texel_weights_float_4t[j][i] = ((float)weights_of_texel[i][j]) * (1.0f / WEIGHTS_TEXEL_SUM);\n@@ -355,7 +360,7 @@ static void init_decimation_info_2d(\n// one of the texel-weight indexes is an identity-mapped index; we will use this\n// fact to reorder the indexes so that the first one is the identity index.\nint swap_idx = -1;\n- for (int k = 0; k < 4; k++)\n+ for (unsigned int k = 0; k < 4; k++)\n{\nuint8_t dttw = di.texel_weights_4t[k][texel];\nfloat dttwf = di.texel_weights_float_4t[k][texel];\n@@ -394,7 +399,7 @@ static void init_decimation_info_2d(\n{\ndi.texel_weight_count[i] = 0;\n- for (int j = 0; j < 4; j++)\n+ for (unsigned int j = 0; j < 4; j++)\n{\ndi.texel_weights_float_4t[j][i] = 0;\ndi.texel_weights_4t[j][i] = 0;\n@@ -404,15 +409,15 @@ static void init_decimation_info_2d(\n// Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n// Match last texel in active lane in SIMD group, for better gathers\n- int last_texel_count_wt = texel_count_of_weight[weights_per_block - 1];\n+ unsigned int last_texel_count_wt = texel_count_of_weight[weights_per_block - 1];\nuint8_t last_texel = di.weight_texel[last_texel_count_wt - 1][weights_per_block - 1];\n- int weights_per_block_simd = round_up_to_simd_multiple_vla(weights_per_block);\n- for (int i = weights_per_block; i < weights_per_block_simd; i++)\n+ unsigned int weights_per_block_simd = round_up_to_simd_multiple_vla(weights_per_block);\n+ for (unsigned int i = weights_per_block; i < weights_per_block_simd; i++)\n{\ndi.weight_texel_count[i] = 0;\n- for (int j = 0; j < max_texel_count_of_weight; j++)\n+ for (unsigned int j = 0; j < max_texel_count_of_weight; j++)\n{\ndi.weight_texel[j][i] = last_texel;\ndi.weights_flt[j][i] = 0.0f;\n@@ -438,16 +443,16 @@ static void init_decimation_info_2d(\n* @param[out] di The decimation info structure to populate.\n*/\nstatic void init_decimation_info_3d(\n- int x_texels,\n- int y_texels,\n- int z_texels,\n- int x_weights,\n- int y_weights,\n- int z_weights,\n+ unsigned int x_texels,\n+ unsigned int y_texels,\n+ unsigned int z_texels,\n+ unsigned int x_weights,\n+ unsigned int y_weights,\n+ unsigned int z_weights,\ndecimation_info& di\n) {\n- int texels_per_block = x_texels * y_texels * z_texels;\n- int weights_per_block = x_weights * y_weights * z_weights;\n+ unsigned int texels_per_block = x_texels * y_texels * z_texels;\n+ unsigned int weights_per_block = x_weights * y_weights * z_weights;\nuint8_t weight_count_of_texel[BLOCK_MAX_TEXELS];\nuint8_t grid_weights_of_texel[BLOCK_MAX_TEXELS][4];\n@@ -456,23 +461,26 @@ static void init_decimation_info_3d(\nuint8_t texel_count_of_weight[BLOCK_MAX_WEIGHTS];\nuint8_t max_texel_count_of_weight = 0;\nuint8_t texels_of_weight[BLOCK_MAX_WEIGHTS][BLOCK_MAX_TEXELS];\n- int texel_weights_of_weight[BLOCK_MAX_WEIGHTS][BLOCK_MAX_TEXELS];\n+ uint8_t texel_weights_of_weight[BLOCK_MAX_WEIGHTS][BLOCK_MAX_TEXELS];\n- for (int i = 0; i < weights_per_block; i++)\n+ promise(weights_per_block > 0);\n+ promise(texels_per_block > 0);\n+\n+ for (unsigned int i = 0; i < weights_per_block; i++)\n{\ntexel_count_of_weight[i] = 0;\n}\n- for (int i = 0; i < texels_per_block; i++)\n+ for (unsigned int i = 0; i < texels_per_block; i++)\n{\nweight_count_of_texel[i] = 0;\n}\n- for (int z = 0; z < z_texels; z++)\n+ for (unsigned int z = 0; z < z_texels; z++)\n{\n- for (int y = 0; y < y_texels; y++)\n+ for (unsigned int y = 0; y < y_texels; y++)\n{\n- for (int x = 0; x < x_texels; x++)\n+ for (unsigned int x = 0; x < x_texels; x++)\n{\nint texel = (z * y_texels + y) * x_texels + x;\n@@ -568,7 +576,7 @@ static void init_decimation_info_3d(\nweight[2] = w2;\nweight[3] = w3;\n- for (int i = 0; i < 4; i++)\n+ for (unsigned int i = 0; i < 4; i++)\n{\nif (weight[i] != 0)\n{\n@@ -585,19 +593,19 @@ static void init_decimation_info_3d(\n}\n}\n- for (int i = 0; i < texels_per_block; i++)\n+ for (unsigned int i = 0; i < texels_per_block; i++)\n{\ndi.texel_weight_count[i] = weight_count_of_texel[i];\n// Init all 4 entries so we can rely on zeros for vectorization\n- for (int j = 0; j < 4; j++)\n+ for (unsigned int j = 0; j < 4; j++)\n{\ndi.texel_weights_int_4t[j][i] = 0;\ndi.texel_weights_float_4t[j][i] = 0.0f;\ndi.texel_weights_4t[j][i] = 0;\n}\n- for (int j = 0; j < weight_count_of_texel[i]; j++)\n+ for (unsigned int j = 0; j < weight_count_of_texel[i]; j++)\n{\ndi.texel_weights_int_4t[j][i] = weights_of_texel[i][j];\ndi.texel_weights_float_4t[j][i] = ((float)weights_of_texel[i][j]) * (1.0f / WEIGHTS_TEXEL_SUM);\n@@ -605,14 +613,14 @@ static void init_decimation_info_3d(\n}\n}\n- for (int i = 0; i < weights_per_block; i++)\n+ for (unsigned int i = 0; i < weights_per_block; i++)\n{\n- int texel_count_wt = texel_count_of_weight[i];\n+ unsigned int texel_count_wt = texel_count_of_weight[i];\ndi.weight_texel_count[i] = (uint8_t)texel_count_wt;\n- for (int j = 0; j < texel_count_wt; j++)\n+ for (unsigned int j = 0; j < texel_count_wt; j++)\n{\n- int texel = texels_of_weight[i][j];\n+ unsigned int texel = texels_of_weight[i][j];\n// Create transposed versions of these for better vectorization\ndi.weight_texel[j][i] = texel;\n@@ -622,7 +630,7 @@ static void init_decimation_info_3d(\n// one of the texel-weight indexes is an identity-mapped index; we will use this\n// fact to reorder the indexes so that the first one is the identity index.\nint swap_idx = -1;\n- for (int k = 0; k < 4; k++)\n+ for (unsigned int k = 0; k < 4; k++)\n{\nuint8_t dttw = di.texel_weights_4t[k][texel];\nfloat dttwf = di.texel_weights_float_4t[k][texel];\n@@ -648,7 +656,7 @@ static void init_decimation_info_3d(\n// Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n// Match last texel in active lane in SIMD group, for better gathers\nuint8_t last_texel = di.weight_texel[texel_count_wt - 1][i];\n- for (int j = texel_count_wt; j < max_texel_count_of_weight; j++)\n+ for (unsigned int j = texel_count_wt; j < max_texel_count_of_weight; j++)\n{\ndi.weight_texel[j][i] = last_texel;\ndi.weights_flt[j][i] = 0.0f;\n@@ -656,12 +664,12 @@ static void init_decimation_info_3d(\n}\n// Initialize array tail so we can over-fetch with SIMD later to avoid loop tails\n- int texels_per_block_simd = round_up_to_simd_multiple_vla(texels_per_block);\n- for (int i = texels_per_block; i < texels_per_block_simd; i++)\n+ unsigned int texels_per_block_simd = round_up_to_simd_multiple_vla(texels_per_block);\n+ for (unsigned int i = texels_per_block; i < texels_per_block_simd; i++)\n{\ndi.texel_weight_count[i] = 0;\n- for (int j = 0; j < 4; j++)\n+ for (unsigned int j = 0; j < 4; j++)\n{\ndi.texel_weights_float_4t[j][i] = 0;\ndi.texel_weights_4t[j][i] = 0;\n@@ -674,8 +682,8 @@ static void init_decimation_info_3d(\nint last_texel_count_wt = texel_count_of_weight[weights_per_block - 1];\nuint8_t last_texel = di.weight_texel[last_texel_count_wt - 1][weights_per_block - 1];\n- int weights_per_block_simd = round_up_to_simd_multiple_vla(weights_per_block);\n- for (int i = weights_per_block; i < weights_per_block_simd; i++)\n+ unsigned int weights_per_block_simd = round_up_to_simd_multiple_vla(weights_per_block);\n+ for (unsigned int i = weights_per_block; i < weights_per_block_simd; i++)\n{\ndi.weight_texel_count[i] = 0;\n@@ -754,13 +762,13 @@ static void assign_kmeans_texels(\n* @return The new entry's index in the compacted decimation table array.\n*/\nstatic int construct_dt_entry_2d(\n- int x_texels,\n- int y_texels,\n- int x_weights,\n- int y_weights,\n+ unsigned int x_texels,\n+ unsigned int y_texels,\n+ unsigned int x_weights,\n+ unsigned int y_weights,\nblock_size_descriptor& bsd\n) {\n- int dm_index = bsd.decimation_mode_count;\n+ unsigned int dm_index = bsd.decimation_mode_count;\nunsigned int weight_count = x_weights * y_weights;\nassert(weight_count <= BLOCK_MAX_WEIGHTS);\n@@ -957,16 +965,16 @@ static void construct_block_size_descriptor_3d(\n) {\n// Store a remap table for storing packed decimation modes.\n// Indexing uses [Z * 64 + Y * 8 + X] and max size for each axis is 6.\n- static const int MAX_DMI = 6 * 64 + 6 * 8 + 6;\n+ static constexpr unsigned int MAX_DMI = 6 * 64 + 6 * 8 + 6;\nint decimation_mode_index[MAX_DMI];\n- int decimation_mode_count = 0;\n+ unsigned int decimation_mode_count = 0;\nbsd.xdim = x_texels;\nbsd.ydim = y_texels;\nbsd.zdim = z_texels;\nbsd.texel_count = x_texels * y_texels * z_texels;\n- for (int i = 0; i < MAX_DMI; i++)\n+ for (unsigned int i = 0; i < MAX_DMI; i++)\n{\ndecimation_mode_index[i] = -1;\n}\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use unsigned ints in block size calculations
|
61,745 |
22.05.2021 17:32:47
| -3,600 |
5aff341446534c9bb281689f98aa4633fef52702
|
Fix int/uint compare in debug builds
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -83,7 +83,7 @@ static bool realign_weights(\n// Get the quantization table\nconst int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n- assert(packed_index >= 0 && packed_index < bsd.block_mode_count);\n+ assert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\nconst block_mode& bm = bsd.block_modes[packed_index];\nint weight_quant_level = bm.quant_mode;\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_level]);\n@@ -388,7 +388,7 @@ static float compress_symbolic_block_for_partition_1plane(\ncontinue;\n}\n- assert(bm_packed_index >= 0 && bm_packed_index < bsd.block_mode_count);\n+ assert(bm_packed_index >= 0 && bm_packed_index < (int)bsd.block_mode_count);\nconst block_mode& qw_bm = bsd.block_modes[bm_packed_index];\nint decimation_mode = qw_bm.decimation_mode;\n@@ -786,7 +786,7 @@ static float compress_symbolic_block_for_partition_2planes(\ncontinue;\n}\n- assert(bm_packed_index >= 0 && bm_packed_index < bsd.block_mode_count);\n+ assert(bm_packed_index >= 0 && bm_packed_index < (int)bsd.block_mode_count);\nconst block_mode& qw_bm = bsd.block_modes[bm_packed_index];\nint decimation_mode = qw_bm.decimation_mode;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_decompress_symbolic.cpp",
"new_path": "Source/astcenc_decompress_symbolic.cpp",
"diff": "@@ -268,7 +268,7 @@ void decompress_symbolic_block(\nconst decimation_info *const *dt = bsd.decimation_tables;\nconst int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n- assert(packed_index >= 0 && packed_index < bsd.block_mode_count);\n+ assert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\nconst block_mode& bm = bsd.block_modes[packed_index];\nconst decimation_info& di = *(dt[bm.decimation_mode]);\n@@ -347,7 +347,7 @@ float compute_symbolic_block_difference(\n// Get the appropriate block descriptor\nconst int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n- assert(packed_index >= 0 && packed_index < bsd.block_mode_count);\n+ assert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\nconst block_mode& bm = bsd.block_modes[packed_index];\nconst decimation_info& di = *(bsd.decimation_tables[bm.decimation_mode]);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -1232,7 +1232,7 @@ astcenc_error astcenc_get_block_info(\npt += scb.partition_index;\nconst int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n- assert(packed_index >= 0 && packed_index < bsd.block_mode_count);\n+ assert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\nconst block_mode& bm = bsd.block_modes[packed_index];\nconst decimation_info& di = *bsd.decimation_tables[bm.decimation_mode];\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_symbolic_physical.cpp",
"new_path": "Source/astcenc_symbolic_physical.cpp",
"diff": "@@ -153,7 +153,7 @@ void symbolic_to_physical(\nconst decimation_info *const *dt = bsd.decimation_tables;\nconst int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n- assert(packed_index >= 0 && packed_index < bsd.block_mode_count);\n+ assert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\nconst block_mode& bm = bsd.block_modes[packed_index];\nint weight_count = dt[bm.decimation_mode]->weight_count;\n@@ -353,7 +353,7 @@ void physical_to_symbolic(\nscb.block_type = SYM_BTYPE_ERROR;\nreturn;\n}\n- assert(packed_index >= 0 && packed_index < bsd.block_mode_count);\n+ assert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\nconst struct block_mode& bm = bsd.block_modes[packed_index];\nint weight_count = dt[bm.decimation_mode]->weight_count;\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Fix int/uint compare in debug builds
|
61,745 |
23.05.2021 20:50:52
| -3,600 |
e2049a7a92dd2c75702ff91ce0c9dbb487b2a51e
|
More unsigned int usage
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "static void merge_endpoints(\nconst endpoints& ep_plane1,\nconst endpoints& ep_plane2,\n- int component_plane2,\n+ unsigned int component_plane2,\nendpoints& result\n) {\n- int partition_count = ep_plane1.partition_count;\n+ unsigned int partition_count = ep_plane1.partition_count;\nvmask4 sep_mask = vint4::lane_id() == vint4(component_plane2);\nresult.partition_count = partition_count;\npromise(partition_count > 0);\n- for (int i = 0; i < partition_count; i++)\n+ for (unsigned int i = 0; i < partition_count; i++)\n{\nresult.endpt0[i] = select(ep_plane1.endpt0[i], ep_plane2.endpt0[i], sep_mask);\nresult.endpt1[i] = select(ep_plane1.endpt1[i], ep_plane2.endpt1[i], sep_mask);\n@@ -77,7 +77,7 @@ static bool realign_weights(\nuint8_t* weight_set8_plane2\n) {\n// Get the partition descriptor\n- int partition_count = scb.partition_count;\n+ unsigned int partition_count = scb.partition_count;\nconst partition_info *pt = get_partition_table(&bsd, partition_count);\npt += scb.partition_index;\n@@ -85,14 +85,15 @@ static bool realign_weights(\nconst int packed_index = bsd.block_mode_packed_index[scb.block_mode];\nassert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\nconst block_mode& bm = bsd.block_modes[packed_index];\n- int weight_quant_level = bm.quant_mode;\n+\n+ unsigned int weight_quant_level = bm.quant_mode;\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_level]);\n// Get the decimation table\nconst decimation_info& di = *(bsd.decimation_tables[bm.decimation_mode]);\n- int weight_count = di.weight_count;\n+ unsigned int weight_count = di.weight_count;\n- int max_plane = bm.is_dual_plane;\n+ unsigned int max_plane = bm.is_dual_plane;\nint plane2_component = bm.is_dual_plane ? scb.plane2_component : -1;\nvmask4 plane_mask = vint4::lane_id() == vint4(plane2_component);\n@@ -108,7 +109,7 @@ static bool realign_weights(\npromise(weight_count > 0);\npromise(max_plane >= 0);\n- for (int pa_idx = 0; pa_idx < partition_count; pa_idx++)\n+ for (unsigned int pa_idx = 0; pa_idx < partition_count; pa_idx++)\n{\nunpack_color_endpoints(decode_mode,\nscb.color_formats[pa_idx],\n@@ -124,9 +125,9 @@ static bool realign_weights(\nbool adjustments = false;\n// For each plane and partition ...\n- for (int pl_idx = 0; pl_idx <= max_plane; pl_idx++)\n+ for (unsigned int pl_idx = 0; pl_idx <= max_plane; pl_idx++)\n{\n- for (int pa_idx = 0; pa_idx < partition_count; pa_idx++)\n+ for (unsigned int pa_idx = 0; pa_idx < partition_count; pa_idx++)\n{\n// Compute the endpoint delta for all components in current plane\nvint4 epd = endpnt1[pa_idx] - endpnt0[pa_idx];\n@@ -137,19 +138,19 @@ static bool realign_weights(\n}\n// Create an unquantized weight grid for this decimation level\n- for (int we_idx = 0; we_idx < weight_count; we_idx++)\n+ for (unsigned int we_idx = 0; we_idx < weight_count; we_idx++)\n{\nuq_pl_weights[we_idx] = qat->unquantized_value[weight_set8[we_idx]];\n}\n// For each weight compute previous, current, and next errors\n- for (int we_idx = 0; we_idx < weight_count; we_idx++)\n+ for (unsigned int we_idx = 0; we_idx < weight_count; we_idx++)\n{\n- int uqw = uq_pl_weights[we_idx];\n+ unsigned int uqw = uq_pl_weights[we_idx];\nuint32_t prev_and_next = qat->prev_next_values[uqw];\n- int prev_wt_uq = prev_and_next & 0xFF;\n- int next_wt_uq = (prev_and_next >> 8) & 0xFF;\n+ unsigned int prev_wt_uq = prev_and_next & 0xFF;\n+ unsigned int next_wt_uq = (prev_and_next >> 8) & 0xFF;\nint uqw_next_dif = next_wt_uq - uqw;\nint uqw_prev_dif = prev_wt_uq - uqw;\n@@ -159,11 +160,11 @@ static bool realign_weights(\nfloat down_error = 0.0f;\n// Interpolate the colors to create the diffs\n- int texels_to_evaluate = di.weight_texel_count[we_idx];\n+ unsigned int texels_to_evaluate = di.weight_texel_count[we_idx];\npromise(texels_to_evaluate > 0);\n- for (int te_idx = 0; te_idx < texels_to_evaluate; te_idx++)\n+ for (unsigned int te_idx = 0; te_idx < texels_to_evaluate; te_idx++)\n{\n- int texel = di.weight_texel[te_idx][we_idx];\n+ unsigned int texel = di.weight_texel[te_idx][we_idx];\nconst uint8_t *texel_weights = di.texel_weights_texel[we_idx][te_idx];\nconst float *texel_weights_float = di.texel_weights_float_texel[we_idx][te_idx];\nfloat twf0 = texel_weights_float[0];\n@@ -173,7 +174,7 @@ static bool realign_weights(\n+ (static_cast<float>(uq_pl_weights[texel_weights[2]]) * texel_weights_float[2]\n+ static_cast<float>(uq_pl_weights[texel_weights[3]]) * texel_weights_float[3]));\n- int partition = pt->partition_of_texel[texel];\n+ unsigned int partition = pt->partition_of_texel[texel];\nweight_base = weight_base + 0.5f;\nfloat plane_weight = astc::flt_rd(weight_base);\n@@ -240,8 +241,8 @@ static float compress_symbolic_block_for_partition_1plane(\nconst error_weight_block& ewb,\nbool only_always,\nfloat tune_errorval_threshold,\n- int partition_count,\n- int partition_index,\n+ unsigned int partition_count,\n+ unsigned int partition_index,\nsymbolic_compressed_block& scb,\ncompress_fixed_partition_buffers& tmpbuf\n) {\n@@ -290,7 +291,7 @@ static float compress_symbolic_block_for_partition_1plane(\n// Compute maximum colors for the endpoints and ideal weights, then for each endpoint and ideal\n// weight pair, compute the smallest weight that will result in a color value greater than 1\nvfloat4 min_ep(10.0f);\n- for (int i = 0; i < partition_count; i++)\n+ for (unsigned int i = 0; i < partition_count; i++)\n{\nvfloat4 ep = (vfloat4(1.0f) - ei.ep.endpt0[i]) / (ei.ep.endpt1[i] - ei.ep.endpt0[i]);\n@@ -414,7 +415,7 @@ static float compress_symbolic_block_for_partition_1plane(\nuint8_t* u8_weight_src = u8_quantized_decimated_quantized_weights + BLOCK_MAX_WEIGHTS * bm_packed_index;\n- for (int j = 0; j < di.weight_count; j++)\n+ for (unsigned int j = 0; j < di.weight_count; j++)\n{\nworkscb.weights[j] = u8_weight_src[j];\n}\n@@ -427,7 +428,7 @@ static float compress_symbolic_block_for_partition_1plane(\neix[decimation_mode].ep, rgbs_colors, rgbo_colors);\n// Quantize the chosen color\n- for (int j = 0; j < partition_count; j++)\n+ for (unsigned int j = 0; j < partition_count; j++)\n{\nworkscb.color_formats[j] = pack_color_endpoints(\neix[decimation_mode].ep.endpt0[j],\n@@ -451,7 +452,7 @@ static float compress_symbolic_block_for_partition_1plane(\n{\nuint8_t colorvals[BLOCK_MAX_PARTITIONS][12];\nint color_formats_mod[BLOCK_MAX_PARTITIONS] { 0 };\n- for (int j = 0; j < partition_count; j++)\n+ for (unsigned int j = 0; j < partition_count; j++)\n{\ncolor_formats_mod[j] = pack_color_endpoints(\neix[decimation_mode].ep.endpt0[j],\n@@ -509,7 +510,7 @@ static float compress_symbolic_block_for_partition_1plane(\n// iteration can help more so we give it a extra 10% leeway. Use this knowledge to\n// drive a heuristic to skip blocks that are unlikely to catch up with the best\n// block we have already.\n- int iters_remaining = config.tune_refinement_limit - l;\n+ unsigned int iters_remaining = config.tune_refinement_limit - l;\nfloat threshold = (0.05f * static_cast<float>(iters_remaining)) + 1.1f;\nif (errorval > (threshold * best_errorval_in_scb))\n{\n@@ -548,7 +549,7 @@ static float compress_symbolic_block_for_partition_1plane(\n// Average refinement improvement is 3.5% per iteration, so skip blocks that are\n// unlikely to catch up with the best block we have already. Assume a 5% per step to\n// give benefit of the doubt ...\n- int iters_remaining = config.tune_refinement_limit - 1 - l;\n+ unsigned int iters_remaining = config.tune_refinement_limit - 1 - l;\nfloat threshold = (0.05f * static_cast<float>(iters_remaining)) + 1.0f;\nif (errorval > (threshold * best_errorval_in_scb))\n{\n@@ -597,9 +598,9 @@ static float compress_symbolic_block_for_partition_2planes(\nconst imageblock& blk,\nconst error_weight_block& ewb,\nfloat tune_errorval_threshold,\n- int partition_count,\n- int partition_index,\n- int plane2_component,\n+ unsigned int partition_count,\n+ unsigned int partition_index,\n+ unsigned int plane2_component,\nsymbolic_compressed_block& scb,\ncompress_fixed_partition_buffers& tmpbuf\n) {\n@@ -658,7 +659,7 @@ static float compress_symbolic_block_for_partition_2planes(\n// weight pair, compute the smallest weight that will result in a color value greater than 1\nvfloat4 min_ep1(10.0f);\nvfloat4 min_ep2(10.0f);\n- for (int i = 0; i < partition_count; i++)\n+ for (unsigned int i = 0; i < partition_count; i++)\n{\nvfloat4 ep1 = (vfloat4(1.0f) - ei1.ep.endpt0[i]) / (ei1.ep.endpt1[i] - ei1.ep.endpt0[i]);\nvmask4 use_ep1 = (ep1 > vfloat4(0.5f)) & (ep1 < min_ep1);\n@@ -829,7 +830,7 @@ static float compress_symbolic_block_for_partition_2planes(\nepm, rgbs_colors, rgbo_colors, plane2_component);\n// Quantize the chosen color\n- for (int j = 0; j < partition_count; j++)\n+ for (unsigned int j = 0; j < partition_count; j++)\n{\nworkscb.color_formats[j] = pack_color_endpoints(\nepm.endpt0[j],\n@@ -852,7 +853,7 @@ static float compress_symbolic_block_for_partition_2planes(\n{\nuint8_t colorvals[BLOCK_MAX_PARTITIONS][12];\nint color_formats_mod[BLOCK_MAX_PARTITIONS] { 0 };\n- for (int j = 0; j < partition_count; j++)\n+ for (unsigned int j = 0; j < partition_count; j++)\n{\ncolor_formats_mod[j] = pack_color_endpoints(\nepm.endpt0[j],\n@@ -911,7 +912,7 @@ static float compress_symbolic_block_for_partition_2planes(\n// iteration can help more so we give it a extra 10% leeway. Use this knowledge to\n// drive a heuristic to skip blocks that are unlikely to catch up with the best\n// block we have already.\n- int iters_remaining = config.tune_refinement_limit - l;\n+ unsigned int iters_remaining = config.tune_refinement_limit - l;\nfloat threshold = (0.05f * static_cast<float>(iters_remaining)) + 1.1f;\nif (errorval > (threshold * best_errorval_in_scb))\n{\n@@ -950,7 +951,7 @@ static float compress_symbolic_block_for_partition_2planes(\n// Average refinement improvement is 3.5% per iteration, so skip blocks that are\n// unlikely to catch up with the best block we have already. Assume a 5% per step to\n// give benefit of the doubt ...\n- int iters_remaining = config.tune_refinement_limit - 1 - l;\n+ unsigned int iters_remaining = config.tune_refinement_limit - 1 - l;\nfloat threshold = (0.05f * static_cast<float>(iters_remaining)) + 1.0f;\nif (errorval > (threshold * best_errorval_in_scb))\n{\n@@ -1043,8 +1044,8 @@ static float prepare_error_weight_block(\nconst imageblock& blk,\nerror_weight_block& ewb\n) {\n- int idx = 0;\n- int any_mean_stdev_weight =\n+ unsigned int idx = 0;\n+ bool any_mean_stdev_weight =\nctx.config.v_rgb_mean != 0.0f || ctx.config.v_rgb_stdev != 0.0f || \\\nctx.config.v_a_mean != 0.0f || ctx.config.v_a_stdev != 0.0f;\n@@ -1054,8 +1055,8 @@ static float prepare_error_weight_block(\nctx.config.cw_a_weight);\n// This works because HDR is imposed globally at compression time\n- int rgb_lns = blk.rgb_lns[0];\n- int a_lns = blk.alpha_lns[0];\n+ unsigned int rgb_lns = blk.rgb_lns[0];\n+ unsigned int a_lns = blk.alpha_lns[0];\nvint4 use_lns(rgb_lns, rgb_lns, rgb_lns, a_lns);\nvmask4 lns_mask = use_lns != vint4::zero();\n@@ -1112,8 +1113,8 @@ static float prepare_error_weight_block(\nctx.config.v_rgb_base,\nctx.config.v_a_base);\n- int ydt = image.dim_x;\n- int zdt = image.dim_x * image.dim_y;\n+ unsigned int ydt = image.dim_x;\n+ unsigned int zdt = image.dim_x * image.dim_y;\nif (any_mean_stdev_weight)\n{\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
More unsigned int usage
|
61,745 |
23.05.2021 20:53:57
| -3,600 |
72303ea9c08fb1c1584b5ff066fc68c0b509b129
|
Use unsigned sentinel for bad block modes
|
[
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_block_sizes.cpp",
"new_path": "Source/astcenc_block_sizes.cpp",
"diff": "@@ -882,7 +882,7 @@ static void construct_block_size_descriptor_2d(\n// Skip modes that are invalid, too large, or not selected by heuristic\nif (!valid || !selected || (x_weights > x_texels) || (y_weights > y_texels))\n{\n- bsd.block_mode_packed_index[i] = -1;\n+ bsd.block_mode_packed_index[i] = BLOCK_BAD_BLOCK_MODE;\ncontinue;\n}\n@@ -1061,9 +1061,9 @@ static void construct_block_size_descriptor_3d(\npermit_encode = false;\n}\n- bsd.block_mode_packed_index[i] = -1;\nif (!permit_encode)\n{\n+ bsd.block_mode_packed_index[i] = BLOCK_BAD_BLOCK_MODE;\ncontinue;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_compress_symbolic.cpp",
"new_path": "Source/astcenc_compress_symbolic.cpp",
"diff": "@@ -82,10 +82,7 @@ static bool realign_weights(\npt += scb.partition_index;\n// Get the quantization table\n- const int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n- assert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\n- const block_mode& bm = bsd.block_modes[packed_index];\n-\n+ const block_mode& bm = bsd.get_block_mode(scb.block_mode);\nunsigned int weight_quant_level = bm.quant_mode;\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_level]);\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_decompress_symbolic.cpp",
"new_path": "Source/astcenc_decompress_symbolic.cpp",
"diff": "@@ -264,12 +264,10 @@ void decompress_symbolic_block(\nconst partition_info *pt = get_partition_table(&bsd, partition_count);\npt += scb.partition_index;\n- // Get the appropriate block descriptor\n- const decimation_info *const *dt = bsd.decimation_tables;\n+ // Get the appropriate block descriptors\n+ const block_mode& bm = bsd.get_block_mode(scb.block_mode);\n- const int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n- assert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\n- const block_mode& bm = bsd.block_modes[packed_index];\n+ const decimation_info *const *dt = bsd.decimation_tables;\nconst decimation_info& di = *(dt[bm.decimation_mode]);\nint is_dual_plane = bm.is_dual_plane;\n@@ -346,9 +344,7 @@ float compute_symbolic_block_difference(\npt += scb.partition_index;\n// Get the appropriate block descriptor\n- const int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n- assert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\n- const block_mode& bm = bsd.block_modes[packed_index];\n+ const block_mode& bm = bsd.get_block_mode(scb.block_mode);\nconst decimation_info& di = *(bsd.decimation_tables[bm.decimation_mode]);\nbool is_dual_plane = bm.is_dual_plane != 0;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_entry.cpp",
"new_path": "Source/astcenc_entry.cpp",
"diff": "@@ -1225,15 +1225,12 @@ astcenc_error astcenc_get_block_info(\nreturn ASTCENC_SUCCESS;\n}\n- // Otherwise, handle a full block with partition payload; values are known\n- // to be valid once the two conditions above have been checked\n+ // Otherwise handle a full block ; known to be valid after conditions above have been checked\nint partition_count = scb.partition_count;\nconst partition_info* pt = get_partition_table(&bsd, partition_count);\npt += scb.partition_index;\n- const int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n- assert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\n- const block_mode& bm = bsd.block_modes[packed_index];\n+ const block_mode& bm = bsd.get_block_mode(scb.block_mode);\nconst decimation_info& di = *bsd.decimation_tables[bm.decimation_mode];\ninfo->weight_x = di.weight_x;\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_internal.h",
"new_path": "Source/astcenc_internal.h",
"diff": "@@ -90,6 +90,9 @@ static constexpr unsigned int BLOCK_MIN_WEIGHT_BITS { 24 };\n/** @brief The maximum number of weight bits a candidate encoding can encode. */\nstatic constexpr unsigned int BLOCK_MAX_WEIGHT_BITS { 96 };\n+/** @brief The index indicating a bad (unused) block mode in the remap array. */\n+static constexpr uint16_t BLOCK_BAD_BLOCK_MODE { 0xFFFFu };\n+\n/** @brief The number of partition index bits supported by the ASTC format . */\nstatic constexpr unsigned int PARTITION_INDEX_BITS { 10 };\n@@ -511,12 +514,12 @@ struct decimation_info\n*/\nstruct block_mode\n{\n+ int16_t mode_index;\nint8_t decimation_mode;\n- int8_t quant_mode;\n+ uint8_t quant_mode;\nuint8_t is_dual_plane : 1;\nuint8_t percentile_hit : 1;\nuint8_t percentile_always : 1;\n- int16_t mode_index;\ninline quant_method get_quant_mode() const\n{\n@@ -580,8 +583,8 @@ struct block_size_descriptor\n/** @brief The number of stored block modes. */\nunsigned int block_mode_count;\n- /** @brief The block mode array index, or -1 if not valid in current config. */\n- int16_t block_mode_packed_index[WEIGHTS_MAX_BLOCK_MODES];\n+ /** @brief The packed block mode array index, or @c BLOCK_BAD_BLOCK_MODE if not active. */\n+ uint16_t block_mode_packed_index[WEIGHTS_MAX_BLOCK_MODES];\n/** @brief The active block modes, stored in low indices. */\nblock_mode block_modes[WEIGHTS_MAX_BLOCK_MODES];\n@@ -594,6 +597,20 @@ struct block_size_descriptor\n/** @brief The partion tables for all of the possible partitions. */\npartition_info partitions[(3 * BLOCK_MAX_PARTITIONINGS) + 1];\n+\n+ /**\n+ * @brief Get the block mode structure for index @c block_mode.\n+ *\n+ * This function can only return block modes that are enabled by the current compressor config.\n+ * Decompression from an arbitrary source should not use this without first checking that the\n+ * packed block mode index is not @c BLOCK_BAD_BLOCK_MODE.\n+ */\n+ const block_mode& get_block_mode(unsigned int block_mode) const\n+ {\n+ unsigned int packed_index = this->block_mode_packed_index[block_mode];\n+ assert(packed_index != BLOCK_BAD_BLOCK_MODE && packed_index < this->block_mode_count);\n+ return block_modes[packed_index];\n+ }\n};\n// data structure representing one block of an image.\n"
},
{
"change_type": "MODIFY",
"old_path": "Source/astcenc_symbolic_physical.cpp",
"new_path": "Source/astcenc_symbolic_physical.cpp",
"diff": "@@ -151,10 +151,7 @@ void symbolic_to_physical(\n}\nconst decimation_info *const *dt = bsd.decimation_tables;\n-\n- const int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n- assert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\n- const block_mode& bm = bsd.block_modes[packed_index];\n+ const block_mode& bm = bsd.get_block_mode(scb.block_mode);\nint weight_count = dt[bm.decimation_mode]->weight_count;\nquant_method weight_quant_method = bm.get_quant_mode();\n@@ -347,14 +344,13 @@ void physical_to_symbolic(\nreturn;\n}\n- const int packed_index = bsd.block_mode_packed_index[block_mode];\n- if (packed_index < 0)\n+ unsigned int packed_index = bsd.block_mode_packed_index[block_mode];\n+ if (packed_index == BLOCK_BAD_BLOCK_MODE)\n{\nscb.block_type = SYM_BTYPE_ERROR;\nreturn;\n}\n- assert(packed_index >= 0 && packed_index < (int)bsd.block_mode_count);\n- const struct block_mode& bm = bsd.block_modes[packed_index];\n+ const struct block_mode& bm = bsd.get_block_mode(block_mode);\nint weight_count = dt[bm.decimation_mode]->weight_count;\nquant_method weight_quant_method = (quant_method)bm.quant_mode;\n"
}
] |
C
|
Apache License 2.0
|
arm-software/astc-encoder
|
Use unsigned sentinel for bad block modes
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.